#include <structinfo.hpp>
Public Member Functions | |
StructInfo () | |
~StructInfo () | |
void | setSize (int size) |
template<typename T> | |
void | setConstructor (void(*constructor)(T *)) |
Sets the constructor of the struct. | |
template<typename T> | |
void | setDestructor (void(*destructor)(T *)) |
Sets the destructor of the struct. | |
template<typename T> | |
void | setOpEqual (void(*opequal)(T *, int, char *, void *)) |
Sets the assignment constructor of the struct. | |
void | addMember (std::string name, TypeInfo type, int offset, int size) |
Adds a member variable. | |
void | addFunction (std::string name, void *function, TypeInfo rettype=TypeInfo(ETC_None), std::vector< TypeInfo > arguments=std::vector< TypeInfo >()) |
Adds a member function. | |
Public Attributes | |
int | size |
void * | constructor |
void * | destructor |
void * | opequal |
std::vector< MemberInfo > | members |
std::vector < FunctionInfo > | functions |
The struct can have member variables and functions which then can be directly modified/called from scripts, as well as a constructor, a destructor and operators.
ps::StructInfo::StructInfo | ( | ) |
ps::StructInfo::~StructInfo | ( | ) |
void ps::StructInfo::setSize | ( | int | size | ) | [inline] |
void ps::StructInfo::setConstructor | ( | void(*)(T *) | constructor | ) | [inline] |
Sets the constructor of the struct.
The constructor is called after the memory is reserved, the first argument is a pointer to the new struct.
void ps::StructInfo::setDestructor | ( | void(*)(T *) | destructor | ) | [inline] |
Sets the destructor of the struct.
The constructor is called right before the memory is freed, the first argument is a pointer to the struct.
void ps::StructInfo::setOpEqual | ( | void(*)(T *, int, char *, void *) | opequal | ) | [inline] |
Sets the assignment constructor of the struct.
The first argument is a pointer to the struct, the second is the variable class (declared in module.h), the third is the type name (usable with structs).
The forth argument holds the new value, it is either a pointer to a struct or can be casted directly to an integer or float, depending on the variable class like (int value = *((int*)&ptr)).
void ps::StructInfo::addMember | ( | std::string | name, | |
TypeInfo | type, | |||
int | offset, | |||
int | size | |||
) |
Adds a member variable.
name | Name of the variable | |
type | Variable type | |
offset | Offset of the variable | |
size | Size of the variable |
void ps::StructInfo::addFunction | ( | std::string | name, | |
void * | function, | |||
TypeInfo | rettype = TypeInfo(ETC_None) , |
|||
std::vector< TypeInfo > | arguments = std::vector< TypeInfo >() | |||
) |
Adds a member function.
The first parameter of the function (which must not be included in "arguments") is a pointer to the struct.
name | Name of the function | |
function | Pointer to the function | |
rettype | Return type | |
arguments | Array with the type of the function arguments |
void* ps::StructInfo::opequal |
std::vector<MemberInfo> ps::StructInfo::members |
std::vector<FunctionInfo> ps::StructInfo::functions |