![]() |
Hide Changes |
![]() |
Edit |
![]() |
|
![]() |
Recent Changes |
![]() |
Subscriptions |
![]() |
Lost and Found |
![]() |
Find References |
![]() |
Rename |
![]() |
Administration Page |
![]() |
Topic Locks |
Search |
History
4/3/2008 8:08:30 PM |
-68.55.74.66 |
3/21/2008 11:40:57 AM |
1.25-82.232.160.50 |
7/10/2007 4:10:46 PM |
ad-remover-84.49.122.139 |
5/30/2007 12:22:24 PM |
-125.72.28.38 |
5/28/2007 3:49:06 AM |
-59.93.164.37 |
![]() |
List all versions |
This will cause sqplus not to bind a default constructor / release function for you. Which means if you want one, you have to do it yourself, but at least you aren't required to have it.
in sqplus.h
with the rest of the defines near the top put this:
// Comment out to turn off automatic binding of default constructor. //#define SQ_AUTO_DEFINE_DEFAULT_CONSTRUCTOR
wrap this:
template<typename T> struct ConstructReleaseClass { static int construct(HSQUIRRELVM v) { return PostConstruct<T>(v,new T(),release); } // construct SQ_DECLARE_RELEASE(T) };
like this:
#ifdef SQ_AUTO_DEFINE_DEFAULT_CONSTRUCTOR template<typename T> struct ConstructReleaseClass { static int construct(HSQUIRRELVM v) { return PostConstruct<T>(v,new T(),release); } // construct SQ_DECLARE_RELEASE(T) }; #endif
just a bit below that wrap this:
SquirrelVM::CreateFunction(newClass,&ConstructReleaseClass<T>::construct,_T("constructor"));
like this:
#ifdef SQ_AUTO_DEFINE_DEFAULT_CONSTRUCTOR SquirrelVM::CreateFunction(newClass,&ConstructReleaseClass<T>::construct,_T("constructor")); #endif
I second this addition. It's required for abstract base classes or for factory-created objects.
//From testSqPlus2.cpp: // === BEGIN Interface Test === class PureInterface { public: virtual void pureFunc1(void)=0; virtual void pureFunc2(void)=0; }; class MyImp : public PureInterface { public: PureInterface * getInterface(void) { return (PureInterface *)this; } void pureFunc1(void) { scprintf(_T("PureFunc1 called [0x%p].\n"),this); } void pureFunc2(void) { scprintf(_T("PureFunc2 called [0x%p].\n"),this); } }; class InterfaceHolder { public: PureInterface * theInterface; void setInterface(PureInterface * pureInterface) { theInterface = pureInterface; } PureInterface * getInterface(void) { return theInterface; } }; DECLARE_INSTANCE_TYPE(PureInterface) DECLARE_INSTANCE_TYPE(MyImp) DECLARE_INSTANCE_TYPE(InterfaceHolder) void testPureVirtualInterface(void) { SQClassDefNoConstructor<PureInterface>(_T("PureInterface")). func(&PureInterface::pureFunc1,_T("pureFunc1")). func(&PureInterface::pureFunc2,_T("pureFunc2")); SQClassDef<InterfaceHolder>(_T("InterfaceHolder")). func(&InterfaceHolder::setInterface,_T("setInterface")). func(&InterfaceHolder::getInterface,_T("getInterface")); SQClassDef<MyImp>(_T("MyImp")). func(&MyImp::getInterface,_T("getInterface")); MyImp myImp; SquirrelObject test = SquirrelVM::CompileBuffer(_T("ih <- InterfaceHolder();")); SquirrelVM::RunScript(test); SquirrelObject root = SquirrelVM::GetRootTable(); SquirrelObject ih = root.GetValue(_T("ih")); InterfaceHolder * ihp = (InterfaceHolder * )ih.GetInstanceUP(ClassType<InterfaceHolder>::type()); ihp->setInterface(&myImp); test = SquirrelVM::CompileBuffer(_T("\ ih.getInterface().pureFunc1(); \n\ ih.getInterface().pureFunc2(); \n\ ihp <- ih.getInterface(); \n\ ihp.pureFunc1(); \n\ ihp.pureFunc2(); \n\ myIh <- MyImp(); \n\ ih.setInterface(myIh.getInterface()); \n\ ih.getInterface().pureFunc1(); \n\ ih.getInterface().pureFunc2(); \n\ ")); SquirrelVM::RunScript(test); } // testPureVirtualInterface
tCED5W <a href="http://wawrdndypcwg.com/">wawrdndypcwg</a>, [url=http://wldqzjdxxqnf.com/]wldqzjdxxqnf[/url], [link=http://qgoffbjnboui.com/]qgoffbjnboui[/link], http://qtvofrpgrxnk.com/