🎉 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!

object property

Started by
2 comments, last by Deyja 17 years, 9 months ago
Hi, I have a class in cpp code like this --- class page : IOleClientSite /*... several other COM interfaces */ { public : HWND hWnd; IWebBrowser2 *browser; /* Several other pointers to COM interfaces */ DWORD adviseCookie; thrust::uint uiHostInfoFlags; // Mark this one // --- IUnknown --- HRESULT STDMETHODCALLTYPE QueryInterface(const IID &riid, void **pp); ULONG STDMETHODCALLTYPE AddRef(void) {return S_OK;} /// .. many other methods page(); virtual ~page(); void navigate(const char *url); bool write(const char *code); /* Some other methods. */ }; --- which is registered to script as this --- ui::page::Register(interpreter, "page"); interpreter->RegisterObjectProperty("page", "uint pagestyle", offsetof(ui::page, ui::page::uiHostInfoFlags)); interpreter->RegisterObjectMethod("page", "void navigate(string ∈)", asFUNCTION(uiPageNavigate), asCALL_CDECL_OBJFIRST); interpreter->RegisterObjectMethod("page", "bool write(string ∈)", asFUNCTION(uiPageWrite), asCALL_CDECL_OBJFIRST); --- The property uiHostInfoFlags or pagestyle as in the script can be reached read only. I can read it's value, but writes silently disappears. It is a small project which i'm just switched from 2.4.1e to 2.7.0 No other classes on my other projects reproduced this problem. Did I missed something somewhere?
Advertisement
For the offset macro it's enough to write offsetof(ui::page, uiHostInfoFlags), but that's hardly the cause of your problem.

I've never seen a problem like yours before, but that doesn't mean it can't be a problem with AngelScript. Though I need to know more in order to determine the true cause.

- What goes on inside the ui::page::Register() method?
- How are you using the property in the script? Give me example of both a working part and a non-working part.

Regards,
Andreas


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

Ignore
ui::page::Register(interpreter, "page");
and replace it with
interpreter->RegisterObjectType("page", sizeof(ui::page), asOBJ_CLASS);

It is a remnant from a what if.. :)

the object _was_ being constructed by a function defined as

ui::page uiPageNew()
{
return *new ui::page;
}

and registered as

interpreter->RegisterGlobalFunction("page newPage()", asFUNCTION(uiPageNew), asCALL_CDECL);

I used 'was' above since I realized that I made a grave mistake by keeping the data in the script-allocated space. Since one of the OLE objects being used by the class requires a registration with the object during the construction (like oo->SetClientSite(this); which making the object uncopyable) now, i'm keeping a sizeof(ui::page *) sized "page" object in the scrpit-allocated space and using it as a pointer via proxies. So i no longer have access to it's properties. However if you want i can send -current- code. (Or try to revert it to old one :D) I've two other classes (much much smaller) in this project currently registered with the script but neither of them have this problem.
Quote: ui::page uiPageNew()
{
return *new ui::page;
}


Good thing you got rid of that too. That's a memory leak.

This topic is closed to new replies.

Advertisement