Hi,
We got some problems when binding CEGUI into Squirrel
here is the declaration of CEGUI::WindowEventArgs
--- in CEGUIInputEvents.h ---
class CEGUIEXPORT WindowEventArgs : public EventArgs
{
public:
WindowEventArgs(Window* wnd) : window(wnd) {
this->d_hasWindow = true;
}
Window* window; //!< pointer to a Window object of relevance to the event.
};
---
and we bind it as the following code
--- embeds ---
DECLARE_INSTANCE_TYPE_NOCOPY(Window); // since CEGUI::Window has a protected operator=
DECLARE_INSTANCE_TYPE(EventArgs);
DECLARE_INSTANCE_TYPE(WindowEventArgs);
SQClassDefNoConstructor<Window>( "Window").
func( &Window::getName, "getName");
SQClassDefNoConstructor<EventArgs>( "EventArgs" ).
var( &EventArgs::handled, "handled" );
SQClassDefNoConstructor<WindowEventArgs, EventArgs>( "WindowEventArgs" ).
var( &WindowEventArgs::window, "window" );
---
the first problem is when complier implements CreateCopyInstance<Window>,
CreateCopyInstance copy the instance as
T * newClass = (T *)up; // at SqPlus.h(688)
we got an error from here since CEGUI::Window has a protected operator=
so we modified CreateCopyInstance into below to stop complier complaints
// T * newClass = (T *)up; // at SqPlus.h(688)
ClassType<T>::copy(newClass, const_cast<T*>(&classToCopy));
is this correct? or other better way to solve this problem?
but in logic, we declare CEGUI::Window as NOCOPY, is it sould be copied here or just return FALSE?
our another problem is when using data member 'window' of WindowEventArgs as the following script
--- in script ---
function HandleEvent(e)
{
local args = toWindowEventArgs(e); // cast EventArgs to WindowEventArgs
local wnd = args.window;
print( wnd.getName() ); // crash here!
}
---
window is a pointer data member of WindowEventArgs pointed to CEGUI::Window , but Squirrel seems use it as an object of CEGUI::Window.
we traced the wnd is an instance of Window, but it's user pointer is the address of &args.window (type of Window**)
instead of args.window (type of Window*) pointed to, then we got a crash when calling getName.
Is something wrong with our embedding? or any way to solve it?
thnks a lot!
Regards,
KZ