πŸŽ‰ 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!

registering a template struct

Started by
14 comments, last by WitchLord 2Β years, 3Β months ago

i want to register this struct [olc::v2d_generic](https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L671)​​

it has fourgithub.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L673github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L673 typedefs
[olc::vi2d](https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L673)
​​[olc::vu2d](https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L674)
​​[olc::vf2d](https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L675)
​​[olc::vd2d](https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L608-L676)​​
i'm

Advertisement

god i hate this site. editing the post doesn't do anything

basically i'm having problems with the reference counting system and checking out RegisterStdString didn't help. i want to move my player class to angelscript
any help is appreciated

Fixed the link: olc::vX2d

This is a simple struct. I recommend you register them as a value type.

You can see in the math add-on how to register a similar type: complex. (source code)

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

hi. Thanks for the reference. although i'm still having problems cause i need to register the conversion operator. i'm getting invalid type conversion in asMETHODPR

Please how you try to register it and the compiler error you get

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

hi

template<typename T>
static void v2d_Constructor_def(void* self)
{
    ::new(self) olc::v2d_generic<T>();
}

template<typename T>
static void v2d_Constructor_copy(const olc::v2d_generic<T>& other, void* self)
{
    ::new(self) olc::v2d_generic<T>(other);
}

template<typename T>
static void v2d_Constructor(const T& x, const T& y, void* self)
{
    ::new(self) olc::v2d_generic<T>(x, y);
}

template<typename T>
static void v2d_Destructor(void* self)
{
    ::delete self;
}

// Register the constructors
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(v2d_Constructor_def<int32_t>, (void*), void),  asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f(const vi2d&in)", asFUNCTIONPR(v2d_Constructor_copy<int32_t>, (const olc::v2d_generic<int32_t>&, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f(const int32&in, const int32&in)", asFUNCTIONPR(v2d_Constructor<int32_t>, (const int32_t&, const int32_t&, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_DESTRUCT,  "void f()", asFUNCTIONPR(v2d_Destructor<int32_t>, (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);

i'm getting a breakpoint trigger in line 238 in file as_callfunc_x86.cpp:

case ICC_CDECL_OBJLAST:
	retQW = CallCDeclFunctionObjLast(obj, args, paramSize<<2, func);
	break;

i'm only using the x y constructor in angelscript

okay more investigation. the exception is getting thrown during ctx->execute() during the factory calling. after continuing i'm getting exit error 0xC0000374 and error A memory segment has been corrupted

I don't see anything wrong in the code you showed.

Can you provide a complete sample code that reproduces the problem so I can do some debugging myself?

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

@WitchLord that would be difficult. i do have a github if you don't mind getting the project from there as my angelscript wrappers are way too large.
https://www.github.com/github-MaxCE/pixelgame

the file in question is AngelScriptEngine.cpp

This topic is closed to new replies.

Advertisement