Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualGrimshaw

Posted 07 March 2013 - 10:46 AM

I dont have an easy way to have an isolated and complete example to reproduce this, as all the code is intrincate within my engine, but I can help with all you said:

 

 

// All-purpose default constructor factory
template<typename T>
T* genericFactory()
{
cout<<"instancing ref type"<<endl;
return new T();
}


/// Adds a reference
void RefCountable::addReference(){
refCount++;
cout<<"[RefCount:"<<this<<"] Add: "<<refCount <<endl;
};


/// Removes a reference and destroys if necessary
void RefCountable::removeReference(){
cout<<"[RefCount:"<<this<<"] Released: "<<refCount - 1<<endl; 
if(--refCount == 0){
delete this;
}
};
 engine->getASEngine()->RegisterObjectType("UIButton", sizeof(UIButton), asOBJ_REF);
 

 

if(engine->getPortableMode())
{
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_FACTORY, "UIButton@ f()", WRAP_FN(genericFactory<UIButton>), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_ADDREF, "void f()", WRAP_MFN(UIButton, addReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_RELEASE, "void f()", WRAP_MFN(UIButton, removeReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_IMPLICIT_REF_CAST, "UIControl@ f()", WRAP_OBJ_LAST(UIButtonRefCast), asCALL_GENERIC);


  engine->getASEngine()->RegisterObjectMethod("UIButton", "void bindSignal(const string &in, Slot@)", WRAP_MFN(UIButton, bindSignal), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setPosition(float,float)", WRAP_MFN(UIButton, setPosition), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setSize(float,float)", WRAP_MFN(UIButton, setSize), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setLabel(const string &in)", WRAP_MFN(UIButton, setLabel), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setProperty(const string &in, const string &in)", WRAP_MFN(UIButton, setRawProperty), asCALL_GENERIC);


}
 

 

About inheritance:

 

UIButton -> UIControl

UIControl -> Animable, sigc::Trackable, RefCountable

 

All constructors are chained properly.

 

This behavior is very weird. For one call to genericFactory(), RefCountable constructor is called 4 times in different addresses. And we are only talking about 1 global variable.

 

 


#2Grimshaw

Posted 07 March 2013 - 10:38 AM

I dont have an easy way to have an isolated and complete example to reproduce this, as all the code is intrincate within my engine, but I can help with all you said:

 

 

// All-purpose default constructor factory
template<typename T>
T* genericFactory()
{
cout<<"instancing ref type"<<endl;
return new T();
}


/// Adds a reference
void RefCountable::addReference(){
refCount++;
cout<<"[RefCount:"<<this<<"] Add: "<<refCount <<endl;
};


/// Removes a reference and destroys if necessary
void RefCountable::removeReference(){
cout<<"[RefCount:"<<this<<"] Released: "<<refCount - 1<<endl; 
if(--refCount == 0){
delete this;
}
};
 engine->getASEngine()->RegisterObjectType("UIButton", sizeof(UIButton), asOBJ_REF);
 

 

if(engine->getPortableMode())
{
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_FACTORY, "UIButton@ f()", WRAP_FN(genericFactory<UIButton>), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_ADDREF, "void f()", WRAP_MFN(UIButton, addReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_RELEASE, "void f()", WRAP_MFN(UIButton, removeReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_IMPLICIT_REF_CAST, "UIControl@ f()", WRAP_OBJ_LAST(UIButtonRefCast), asCALL_GENERIC);


  engine->getASEngine()->RegisterObjectMethod("UIButton", "void bindSignal(const string &in, Slot@)", WRAP_MFN(UIButton, bindSignal), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setPosition(float,float)", WRAP_MFN(UIButton, setPosition), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setSize(float,float)", WRAP_MFN(UIButton, setSize), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setLabel(const string &in)", WRAP_MFN(UIButton, setLabel), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setProperty(const string &in, const string &in)", WRAP_MFN(UIButton, setRawProperty), asCALL_GENERIC);


}
 

 

About inheritance:

 

UIButton -> UIControl

UIControl -> Animable, sigc::Trackable, RefCountable

 

All constructors are chained properly.

 

This behavior is very weird. For one call to genericFactory(), RefCountable constructor is called 4 times in different addresses. And we are only talking about 1 global variable.

 

(I am using aswrappedcall from the previous AS I used, not from the most recent one, could this be an issue?)

 

 


#1Grimshaw

Posted 07 March 2013 - 10:36 AM

I dont have an easy way to have an isolated and complete example to reproduce this, as all the code is intrincate within my engine, but I can help with all you said:

 

 

// All-purpose default constructor factory
template<typename T>
T* genericFactory()
{
cout<<"instancing ref type"<<endl;
return new T();
}


/// Adds a reference
void RefCountable::addReference(){
refCount++;
cout<<"[RefCount:"<<this<<"] Add: "<<refCount <<endl;
};


/// Removes a reference and destroys if necessary
void RefCountable::removeReference(){
cout<<"[RefCount:"<<this<<"] Released: "<<refCount - 1<<endl; 
if(--refCount == 0){
delete this;
}
};
 engine->getASEngine()->RegisterObjectType("UIButton", sizeof(UIButton), asOBJ_REF);
 

 

if(engine->getPortableMode())
{
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_FACTORY, "UIButton@ f()", WRAP_FN(genericFactory<UIButton>), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_ADDREF, "void f()", WRAP_MFN(UIButton, addReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_RELEASE, "void f()", WRAP_MFN(UIButton, removeReference), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectBehaviour("UIButton", asBEHAVE_IMPLICIT_REF_CAST, "UIControl@ f()", WRAP_OBJ_LAST(UIButtonRefCast), asCALL_GENERIC);


  engine->getASEngine()->RegisterObjectMethod("UIButton", "void bindSignal(const string &in, Slot@)", WRAP_MFN(UIButton, bindSignal), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setPosition(float,float)", WRAP_MFN(UIButton, setPosition), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setSize(float,float)", WRAP_MFN(UIButton, setSize), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setLabel(const string &in)", WRAP_MFN(UIButton, setLabel), asCALL_GENERIC);
engine->getASEngine()->RegisterObjectMethod("UIButton", "void setProperty(const string &in, const string &in)", WRAP_MFN(UIButton, setRawProperty), asCALL_GENERIC);


}
 

 

About inheritance:

 

UIButton -> UIControl

UIControl -> Animable, sigc::Trackable, RefCountable

 

All constructors are chained properly.

 

This behavior is very weird. For one call to genericFactory(), RefCountable constructor is called 4 times in different addresses. And we are only talking about 1 global variable.

 

 


PARTNERS