Jump to content
  • Advertisement
Sign in to follow this  
CyberGorgolith

Problem with passing string objects

This topic is 4041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a function void S_SetObjectMaterial(int id, asCScriptString &matName); which I register using rval = se->RegisterGlobalFunction("void SetObjectMaterial(int id, string &matName);", asFUNCTION(S_SetObjectMaterial), asCALL_CDECL); The problem is that when I call this function from inside a script and pass 0 as the integer argument, I get an exception inside angelscript in the opcode BC_CHKREF. Digging into angelscript a bit I find that I have a stack with the integer argument at l_sp + 0x0 followed by a pointer to the string object at l_sp + 0x4. The opcode before BC_CHKREF is BC_GETOBJREF, which copies the pointer onto the stack on top of some existing value. BC_CHKREF always checks l_sp + 0x0 for a null value, instead of the pointer at l_sp + 0x4, so it fails when the integer argument is 0. Am I doing something wrong? I just commented out the BC_CHKREF check for now. This is with recent code from the SVN. Thanks! edit- Here's the listing for that statement: - 28,2 - 57 4 * SUSPEND 58 4 * STR 5 (l:7 s:"penguin") 59 6 * CALLSYS 28 (string@ ?(const int, const uint8&)) 61 4 * STOREOBJ v1 62 4 * PSF v1 63 5 * CHKREF 64 5 * POP 1 65 4 * VAR v1 66 5 * PshV4 v0 67 6 * GETOBJREF 1 68 6 * CHKREF 69 6 * CALLSYS 85 (void SetObjectMaterial(int, string&inout)) 71 4 * PSF v1 72 5 * FREE 0x282d890

Share this post


Link to post
Share on other sites
Advertisement
Interesting, the checkref is indeed placed incorrectly by the AngelScript compiler. I'll have to look into this. Thanks for the report.

Update: I've reproduced the problem. It shouldn't be long before I have a fix ready.

Regards,
Andreas

[Edited by - WitchLord on June 24, 2007 8:08:56 AM]

Share this post


Link to post
Share on other sites
Ok, thanks!

But there's a new problem, this time with BC_ChkNullS:

as_context.cpp line 2840

size_t *a = (asDWORD*)*(size_t*)(l_sp + WORDARG0(l_bc));
should be
size_t *a = (size_t*)(l_sp + WORDARG0(l_bc));

It is checking the first bytes of the object rather than the pointer to the object.

Share this post


Link to post
Share on other sites
I get a compile error like this as well. Using latest SVN rev 160 with MSVC++ 6.

d:\visual c++\as\sdk\angelscript\source\as_context.cpp(2840) : error C2440: 'initializing' : cannot convert from 'unsigned long *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Same error in Dev-C++.

Share this post


Link to post
Share on other sites
CyberGorgolith: You're right. That was sloppy of me. I must have been tired yesterday. I'll correct it a.s.a.p.

Blednik: I'll have a look at the compiler error as well. Thanks.

Share this post


Link to post
Share on other sites
It should be working now. I've fixed some other bugs as well (unrelated to this) so you can get the latest revision from SVN (163).

Thanks for the help.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!