🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

about string type in 2.11.0

Started by
3 comments, last by WitchLord 16 years, 6 months ago
I upgrade my System to 2.11.0. But it seems that there is some thing different. such as that: string couldn't be declared with object type among the modules. (I use scriptstring as string type) EX: MODULE1 string TEST(const uint op) { string s="test"; return s; } void main() { TEST(1); } MODULE2 import string TEST(const uint) from "MODULE1"; void main() { TEST(2); } If I build MODULE1 and run it , It is OK. But if I build MODULE2, MODULE1, and Binding, it will result in Binding Error! I must rewrite the codes: MODULE1 string@ TEST(const uint op) { string s="test"; return @s; } void main() { TEST(1); } MODULE2 import string@ TEST(const uint) from "MODULE1"; void main() { TEST(2); } It seems that, In the import function, I could only use string handle as parameter type ? Am I right. Or could I change the string registration to support instance? Thanks a lot.
Advertisement
OK!
I found the answer from source code (as_builder.cpp)

line 585

// Reference types cannot be returned by value from system functions
if( (func->returnType.GetObjectType() &&
(func->returnType.GetObjectType()->flags & asOBJ_REF)) &&
!(func->returnType.IsReference() ||
func->returnType.IsObjectHandle()) )
return asINVALID_DECLARATION;

In conclusion, If I want to use string reference, I should change all import functions. And this is a big trouble for me.
This is a bug in AngelScript. The validation you found in the CBuilder class is only meant for application registered functions. Unfortunately my regression tests didn't contain binding of functions with registered reference types passed by value, that's why I didn't catch it before. Fortunately the bug was easy to fix and you can now download it from the SVN.

Thanks for the report.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks a lot.
Now the 2.11.1 is working for me.
Great, thanks!

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement