Show Changes Show Changes
Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Administration Page Administration Page
Topic Locks Topic Locks

Search

History

2/22/2017 3:56:51 AM
-92.222.238.172
7/10/2007 3:44:28 PM
ad-remover-84.49.122.139
5/30/2007 12:32:19 PM
-125.72.28.38
5/28/2007 6:45:25 AM
-69.136.148.27
10/14/2005 7:20:16 PM
info@brightland.com-66.27.77.187
List all versions List all versions

RSS feed for the SquirrelWiki namespace

Registering Pre Allocated Elements
.

Back to SqPlus

Summary

C/C++ binding:


// Example from forum post question:
class STestScripts {}; // Proxy class
class TestScripts {
public:
  int Var_ToBind1,Var_ToBind2;

  void InitScript1(void) {
    Var_ToBind1 = 808;
    RegisterGlobal(*this,Test1,"Test1");
    RegisterGlobal(*this,Test2,"Test2");
    BindVariable(&Var_ToBind1,"Var_ToBind1");
  } // InitScript1

  void InitScript2(void) {
    Var_ToBind2 = 909;
    SQClassDef<STestScripts>("STestScripts").
      staticFunc(*this,Test1,"Test1").
      staticFunc(*this,Test2,"Test2").
      staticVar(&Var_ToBind2,"Var_ToBind2");
  } // InitScript2

  void Test1(void) {
    printf("Test1 called.\n");
  }
  void Test2(void) {
    printf("Test2 called.\n");
  }
} testScripts;

Script test:

testScripts.InitScript1();
testScripts.InitScript2();
SquirrelObject testScriptBinding = SquirrelVM::CompileBuffer("\
  local testScripts = STestScripts(); \n\
  testScripts.Test1(); \n\
  testScripts.Test2(); \n\
  print(testScripts.Var_ToBind2); \n\
  Test1(); \n\
  Test2(); \n\
  print(Var_ToBind1); \n\
");
SquirrelVM::RunScript(testScriptBinding);
Not logged in. Log in

squirrel's community wiki

This is FlexWiki, an open source wiki engine.

Change Style

Recent Topics