Here is code to register a single reference type
nRet = (asERetCodes) pScriptEngine->RegisterObjectType("Single", 0, asOBJ_REF | asOBJ_NOHANDLE);
assert( nRet >= 0 );
nRet = (asERetCodes) pScriptEngine->RegisterObjectMethod("Single", "bool isRepeat()", asMETHOD(Single, isRepeat), asCALL_THISCALL);
assert( nRet >= 0);
After I register another methods, which is to return the reference:
nRet = (asERetCodes) pScriptEngine->RegisterObjectMethod("Test", "Single @getSingle()", asMETHOD(Test, getSingle), asCALL_THISCALL);
assert( nRet >= 0);
Above got compiling error, which is said to be invalid declearion.
nRet = (asERetCodes) pScriptEngine->RegisterObjectMethod("Test", "Single &getSingle()", asMETHOD(Test, getSingle), asCALL_THISCALL);
assert( nRet >= 0);
Above is passed.
And then I register a global variable, which is Test type.
I called following sentense:
MobyKeys@ a = gTest.getSingle();
It gave me error message as return value -1.
Can u point out wat's wrong?
I want to register a reference type, and the script engine won't create or delete the object. And it can only get from functions or methods as reference type. I think Single reference type is suitable for this. What's wrong with my above?