Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Register functions with default value parameters


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 25 July 2012 - 04:03 PM

Hi,

I want to register this function,

virtual void Ogre::ManualObject::begin  (  const String &   materialName,
  RenderOperation::OperationType   opType = RenderOperation::OT_TRIANGLE_LIST,
  const String &   groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
)

i register it so;
r = engine->RegisterObjectMethod("ManualObject", "void begin(const string &in, int renderop)", asMETHOD(ManualObject, begin), asCALL_THISCALL);
  assert( r >= 0);

call it with
manual.begin("lootray", OT_LINE_STRIP);
causes this assertion:
Run-Time Check Failure #2 - Stack around the variable 'retQW' was corrupted

this function works, if i register the whole thing
void begin(const string &in, int renderop, const string &in)
i think i do the registeration wrong.

How do i register functions with default parameters?

Thanks.

Sponsor:

#2 InvalidPointer   Members   -  Reputation: 1433

Like
1Likes
Like

Posted 25 July 2012 - 04:47 PM

Default parameters are entirely a compiler thing-- they're just instructions to the compiler to add some behind-the-scenes code if you don't manually specify arguments when the function is called. Due to how Angelscript works, you can't take advantage of this since it doesn't call functions the 'normal' way. You'll need to actually add the default arguments to the AS declaration instead of just assuming the compiler will handle it.

EDIT: For clarity, I refer specifically to the "void begin(const string &in, int renderop, const string &in)" bit.

Edited by InvalidPointer, 25 July 2012 - 04:47 PM.

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.

#3 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 25 July 2012 - 05:29 PM

Default parameters are entirely a compiler thing-- they're just instructions to the compiler to add some behind-the-scenes code if you don't manually specify arguments when the function is called. Due to how Angelscript works, you can't take advantage of this since it doesn't call functions the 'normal' way. You'll need to actually add the default arguments to the AS declaration instead of just assuming the compiler will handle it.

EDIT: For clarity, I refer specifically to the "void begin(const string &in, int renderop, const string &in)" bit.


i didnt know angelscript supports default values in declearations.
another awesome feature i missed.

r = engine->RegisterObjectMethod("ManualObject", ("void begin(const string &in, int renderop = 4, const string &in group= \"" + ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME + "\")").c_str(), asMETHOD(ManualObject, begin), asCALL_THISCALL);

thank you.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS