Advertisement
snake5

SGScript - C++ binding compiler output example

Oct 27th, 2013
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.19 KB | None | 0 0
  1. // SGS/CPP-BC
  2. // warning: do not modify this file, it may be regenerated during any build
  3. // generated: 10/27/13 18:26:46
  4.  
  5. #include "thing.h"
  6.  
  7. static int _sgs_method__thing__getTotalSize( SGS_CTX )
  8. {
  9.     int method_call = sgs_Method( C );
  10.     sgs_FuncName( C, method_call ? "thing.getTotalSize" : "thing_getTotalSize" );
  11.     if( !sgs_IsObject( C, 0, thing::_sgs_interface ) )
  12.         return sgs_ArgErrorExt( C, 0, method_call, "thing", "" );
  13.     thing* data = static_cast<thing*>( sgs_GetObjectData( C, 0 ) );
  14.     sgs_PushVar(C,data->getTotalSize());
  15.     return 1;
  16. }
  17.  
  18. static int _sgs_method__thing__addThing( SGS_CTX )
  19. {
  20.     int method_call = sgs_Method( C );
  21.     sgs_FuncName( C, method_call ? "thing.addThing" : "thing_addThing" );
  22.     if( !sgs_IsObject( C, 0, thing::_sgs_interface ) )
  23.         return sgs_ArgErrorExt( C, 0, method_call, "thing", "" );
  24.     thing* data = static_cast<thing*>( sgs_GetObjectData( C, 0 ) );
  25.     data->addThing(sgs_GetVar<thing>(C,1,true));
  26.     return 0;
  27. }
  28.  
  29. int thing::_sgs_getindex( SGS_CTX, sgs_VarObj* obj, int param )
  30. {
  31.     char* name;
  32.     if( sgs_ParseString( C, 0, &name, NULL ) )
  33.     {
  34.         if( strcmp( name, "getTotalSize" ) == 0 )
  35.         {
  36.             sgs_PushCFunction( C, _sgs_method__thing__getTotalSize );
  37.             return SGS_SUCCESS;
  38.         }
  39.         if( strcmp( name, "addThing" ) == 0 )
  40.         {
  41.             sgs_PushCFunction( C, _sgs_method__thing__addThing );
  42.             return SGS_SUCCESS;
  43.         }
  44.         if( strcmp( name, "size" ) == 0 )
  45.         {
  46.             sgs_PushVar( C, static_cast<thing*>( obj->data )->size );
  47.             return SGS_SUCCESS;
  48.         }
  49.     }
  50.     return SGS_ENOTFND;
  51. }
  52.  
  53. int thing::_sgs_setindex( SGS_CTX, sgs_VarObj* obj, int param )
  54. {
  55.     char* name;
  56.     if( sgs_ParseString( C, 0, &name, NULL ) )
  57.     {
  58.         if( strcmp( name, "size" ) == 0 )
  59.         {
  60.             static_cast<thing*>( obj->data )->size = sgs_GetVar<int>( C, 1 );
  61.             return SGS_SUCCESS;
  62.         }
  63.     }
  64.     return SGS_ENOTFND;
  65. }
  66.  
  67. int thing::_sgs_convert( SGS_CTX, sgs_VarObj* obj, int param )
  68. {
  69.     if( param == SGS_CONVOP_TOTYPE || param == SGS_VT_STRING )
  70.     {
  71.         sgs_PushString( C, "thing" );
  72.         return SGS_SUCCESS;
  73.     }
  74.     return SGS_ENOTSUP;
  75. }
  76.  
  77. sgs_ObjCallback thing::_sgs_interface[] =
  78. {
  79.     SGS_OP_GETINDEX, thing::_sgs_getindex,
  80.     SGS_OP_SETINDEX, thing::_sgs_setindex,
  81.     SGS_OP_CONVERT, thing::_sgs_convert,
  82.     SGS_OP_END
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement