sgsVariable [class]
class sgsVariable
This is the class used for handling all SGScript variables.
Variables
sgs_Variable var
- the internal variable dataSGS_CTX
(sgs_Context* C
) - associated context
Constructors
sgsVariable()
- initializes a NULL variablesgsVariable( const sgsVariable& h )
- initializes variable from another variablesgsVariable( sgs_Context* c )
- initialize a NULL variable and associate contextsgsVariable( sgs_Context* c, sgs_StkIdx item )
- initialize a variable from current stack framesgsVariable( sgs_Context* c, sgs_StkIdx item, EMayNotExist )
- initialize a variable from current stack frame (index may not be valid, in which case the variable is initialized to NULL)sgsVariable( sgs_Context* c, EPickAndPop )
- initialize a variable from the topmost stack item, pop it afterwardssgsVariable( sgs_Context* c, sgs_Variable* v )
- initialize a variable from data pointersgsVariable( const sgsString& s )
- initialize a variable from the specified string handletemplate< class T > sgsVariable( const sgsHandle<T>& h )
- initialize a variable from the specified class handle
Methods
void push( sgs_Context* c = NULL ) const
- push the variable (optionally specify context if variable might not have it)void gcmark()
- mark the variable as accessible (using sgs_GCMark)bool not_null() const
- return if variable is not NULLbool is_object( sgs_ObjInterface* iface )
- check if variable is an object with the specified interfacetemplate< class T > bool is_handle()
- check if variable is an instance of the specified SGS_OBJECT classsgs_VarObj* get_object_struct() const
- get the internal object structuretemplate< class T > T* get_object_data()
- get object pointer from variable (WARNING: this method does not do any safety checks)template< class T > sgsHandle<T> get_handle()
- get the class handletemplate< class T > sgsHandle<T> downcast()
- get the class handle (allow casting to inherited types)int type_id() const
- get the type ID (one of SGS_VT_*** constants)bool is_string() const
- return if this variable is a stringsgsString get_string()
- get the string handlevoid set_meta_obj( sgsVariable metaobj )
- set the metaobject for this objectsgsVariable get_meta_obj()
- get the metaobject of this objectbool get_metamethods_enabled()
- check if metamethods are enabled for this objectvoid enable_metamethods( bool e )
- set if metamethods are enabled for this objectsgsVariable getsubitem( sgsVariable key, bool prop )
- retrieve an index/property valuesgsVariable getsubitem( const char* key, bool prop )
- retrieve an index/property value (string key)sgsVariable getprop( sgsVariable key )
- retrieve a property valuesgsVariable getindex( sgsVariable key )
- retrieve an index valuesgsVariable getprop( const char* key )
- retrieve a property value (string key)sgsVariable getindex( const char* key )
- retrieve an index value (string key)bool setsubitem( sgsVariable key, sgsVariable val, bool prop )
- set an index/property valuebool setsubitem( const char* key, sgsVariable val, bool prop )
- set an index/property value (string key)bool setprop( sgsVariable key, sgsVariable val )
- set a property valuebool setindex( sgsVariable key, sgsVariable val )
- set an index valuebool setprop( const char* key, sgsVariable val )
- set a property value (string key)bool setindex( const char* key, sgsVariable val )
- set an index value (string key)template< class T > T get()
- retrieve a C++ value from the variabletemplate< class T > T getdef( const T& def )
- retrieve a C++ value from the variable, usingdef
fornull
sgsVariable& set_null()
- set variable tonull
sgsVariable& set_bool( bool v )
- set variable to the specified boolean valuesgsVariable& set_int( sgs_Int v )
- set variable to the specified integer valuesgsVariable& set_real( sgs_Real v )
- set variable to the specified real number valuesgsVariable& set( sgsString v )
- set variable to the specified string valuesgsVariable& set( sgs_CFunc v )
- set variable to the specified C function valuetemplate< class T > sgsVariable& set( sgsHandle< T > v )
- set variable to the specified class handletemplate< class T > sgsVariable& set( T* v )
- set variable to the specified C++/SGScript classbool call( sgs_Context* c, int args = 0, int ret = 0 )
- call variable as function using arguments from stackbool thiscall( sgs_Context* c, sgsVariable func, int args = 0, int ret = 0 )
- use variable asthis
in a method call tofunc
bool thiscall( sgs_Context* c, const char* key, int args = 0, int ret = 0 )
- use variable asthis
in a method call to its functionRT tcall( sgs_Context* c, ... )
- call the variable with specified arguments on the given contextRT tthiscall( sgs_Context* c, sgsVariable func, ... )
- use variable asthis
in a method call tofunc
RT tthiscall( sgs_Context* c, const char* key, ... )
- use variable asthis
in a method call to its functionvoid _acquire()
- increment reference count on variablevoid _release()
- decrement reference count on variable, remove it from the class
Operators
const sgsVariable& operator = ( const sgsVariable& h )
- handle assignmentbool operator <
,bool operator ==
- comparison operators (the required minimum used for sorting)