Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

[SQplus] Binding arbitrary value as member variable

Last post 06-30-2009, 5:41 PM by Toji. 1 replies.
Sort Posts: Previous Next
  •  06-16-2009, 1:45 PM 3312

    [SQplus] Binding arbitrary value as member variable

    Hi,
    I have binded a class MyClass to Squirrel. Now I need to add a specific value (which is not member of the class in C++) to be able to access it (read) from Squirrel script as if it was ordinary member variable.

    I tried several ways to do it, but all failde (either the C++ compiler threw errorss, the squirrel crashed with memory acces violation error or it just didn't see the value as class member).

    TY
  •  06-30-2009, 5:41 PM 3341 in reply to 3312

    Re: [SQplus] Binding arbitrary value as member variable

    I haven't tried the following code, but it's the only thing I can think of that would work in SqPlus. It may only work on tables or class instances, though:

    SquirrelObject obj = SquirrelVM::GetRootTable(); //Substitute for your object here
    BindVariable(obj, &myMember, _SC("myMember"));

    Hate to toot my own horn here, but if that doesn't work out for you, you may want to take a peek at sqrat. It provides mechanisms to do what you're looking for:

    myClass.SetValue(_SC("myMember"), &myMember);

    Good Luck!

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems