Memory macros

Macros listed below allow to allocate managed memory from C++ application side. This is the same what new operator does in SC scripts (though on the host side it is only allowed to use default constructors).

Example

   
   TSCPtr<TSCPtr<Soldier> > s1 = SC_ALLOC(TSCPtr<Soldier>, 4, NULL);   //array of 4 Soldier managed pointers
   TSCPtr<Soldier> s2 = SC_ALLOC(Soldier, 1, NULL);                 //one Soldier object
   TSCPtr<Soldier> s3 = SC_ALLOC_DERIVED(Soldier, Marine, 1, NULL); //derived Marine class 

Namespace

Used to define data in namespaces.

Example

   typedef void (SCSTDCALL* TFuncVoidInt)(Int x);
   
   ...
   
   ISCType *tTFuncVoidInt = SC_FUNC_PTR_TYPE(ns, void, TFuncVoidInt, (Int x));
   if(!tTFuncVoidInt)
      return 0;
          
   ...
   Int *extIntPtr = NULL;
   ISCSymbol *vExtIntPtr = SC_VARIABLE(ns, Int*, extIntPtr);  

Class

Used to define data in classes.

Example

   //That is a parametrized constructor and
   //such a form should always be used.
   Soldier& SCSTDCALL InitSoldier(Soldier &s, Int h)
   {
      SC_CONSTRUCTOR_BODY(Soldier, s, (h));
   }
   
   ...
   
   ISCType *tSoldier = SC_BASE_CLASS(ns, Soldier);
   if(!SC_ATTRIBUTE(tSoldier, Soldier, Int, health) ||
      !SC_ATTRIBUTE(tSoldier, Soldier, TSCPtr<Soldier>, leader) ||		
      !SC_CONSTRUCTOR(tSoldier, Soldier, InitSoldier, (Soldier *s, Int h)) || 		
      !SC_METHOD(tSoldier, Soldier, void, Hit, (Int damage)) ||
      !SC_METHOD(tSoldier, Soldier, void, Show, () const) )
         return -1;
    
    ...

Getting data from scripts

Allow to obtain some data from scripts.

Example. It is assumed that TestFuncDoubleConstVec3Ref function exists in vmScript.

   typedef Double (SCSTDCALL *TFuncDoubleConstVec3Ref)(const Vec3& a);
   ...
   TSCFuncPtr<TFuncDoubleConstVec3Ref> fptr1;
   fptr1 = SC_GET_FUNC_PTR(vmScript,TFuncDoubleConstVec3Ref, "TestFuncDoubleConstVec3Ref");
   ...

Script user variables

Allow to register some variable directly in the main block of the script, passed while script creation.

Example

   Int userIntVar = 1;	
   Character selfChar;
  	
   ISCUserVarInfo userVarInfo[] = {
      SC_USER_VAR_INFO(Int, userIntVar),
      SC_USER_VAR_INFO_PTR_N(Character, &selfChar, "self")
   };

Special function

Allow to register special functions for types. Note that for classes assignment of non constant object is defined. If special function already exists ,error is reported and NULL returned.

Example.

   ISCType *tVec3 = SC_BASE_CLASS(ns, Vec3);
  
   if(!SC_ADD(tVec3, Vec3, const Vec3, const Vec3) ||
      !SC_SUB(tVec3, Vec3, const Vec3, const Vec3) ||
      !SC_MUL(tVec3, Vec3, const Vec3, const Vec3) ||
      !SC_DIV(tVec3, Vec3, const Vec3, const Vec3))
        return -1;