and registered like this: engine->RegisterObjectMethod("Integer", "Integer opAdd(const Integer &in) const", asFUNCTIONPR(operator+, (const Block_Integer&, const Block_Integer&), Block_Integer), asCALL_CDECL_OBJFIRST);
My test script looks like this: Integer intA(5), intB(7), intC;
intC = intA + intB;
When I run my script, in my operator Block_Integer argument "a" comes properly with value "5", but argument Block_Integer "b" is null. I also tried to place this operator inside my Block_Integer class (with asCALL_THISCALL calling convention) but result was the same.
Is there any issue with overloaded operators registered to AS?
I'm no expert, but I think asOBJ_APP_PRIMITIVE is reserved for truly primitive C++ types and not class like your Block_Integer. I guess that you have at least an assignment operator in your class and a constructor in order to make your declaration and "intC = intA + intB" to compile, so somewhere you might wanna have a "asOBJ_APP_CLASS_*" in your declartion flag (http://www.angelcode.com/angelscript/sdk/docs/manual/angelscript_8h.html#855d86fa9ee15b9f75e553ee376b5c7af15f3dd82be0e77e05ee0dbea096bb36)
Anyway, just to be sure I tried to reproduce your problem, and I did with flags "asOBJ_VALUE | asOBJ_APP_PRIMITIVE", but it worked fine with flags "asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA"
Note to self: remember to never ever again try to paste some italic code in a message body...
I'm not aware of any issues with overloaded operators in AngelScript, but I'll investigate this to see if I can reproduce the problem you reported.Can you tell me a bit more about how the Block_Integer class is declared in the C++ application? You say it is a class, but you registered it as if it was a primitive. Quittouff is correct, asOBJ_APP_PRIMITIVE is only meant for primitive C++ datatypes (except float/double), all classes and structures should be registered with the asOBJ_APP_CLASS flag + respective flag for constructor, destructor, assignment operator, and or copy constructor.
I solved this problem. I just changed flags to "asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA", added assignment operator (without registering it to AS) and it works fine now. So in this case the problem were: wrong flags and missing assignment operator. And additionally I've registered the default constructor.