ps::StructInfo Class Reference

Class holding the definition of an external struct. More...

#include <structinfo.hpp>

List of all members.

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< MemberInfomembers
std::vector
< FunctionInfo
functions


Detailed Description

Class holding the definition of an external struct.

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.


Constructor & Destructor Documentation

ps::StructInfo::StructInfo (  ) 

ps::StructInfo::~StructInfo (  ) 


Member Function Documentation

void ps::StructInfo::setSize ( int  size  )  [inline]

template<typename T>
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.

template<typename T>
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.

template<typename T>
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.

Parameters:
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.

Parameters:
name Name of the function
function Pointer to the function
rettype Return type
arguments Array with the type of the function arguments


Member Data Documentation

int ps::StructInfo::size

void* ps::StructInfo::constructor

void* ps::StructInfo::destructor

void* ps::StructInfo::opequal

std::vector<MemberInfo> ps::StructInfo::members

std::vector<FunctionInfo> ps::StructInfo::functions


The documentation for this class was generated from the following file:
Generated on Sun Feb 3 21:38:49 2008 for libplusscript++ by  doxygen 1.5.3