Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 23 Sep 2012
Offline Last Active May 14 2013 07:41 AM

Posts I've Made

In Topic: Returning text crashes as with Mingw 4.71 but not with 4.4.1

29 March 2013 - 02:41 AM

I tried the latest svn version via sourceforge tarball download of trunk, same problem. 


As usual I caution that I may not be registering things properly and this might just be my fault (though i did try my best to do things correctly).

In Topic: Returning text crashes as with Mingw 4.71 but not with 4.4.1

28 March 2013 - 01:52 PM

I am using the latest version: 2.26.1. (I am the dude that first brought up the issue with mingw 4.7.1 behaving strangely a few months back).

In Topic: This changes when returning value objects

26 March 2013 - 02:47 AM

Oh, that is worrying. Is it possible for end user like myself know how a value type should be registered? Is there a method end users can use to deduce how it should be done in all cases? 

In Topic: This changes when returning value objects

25 March 2013 - 12:10 PM

I have seen something that might be a problem here.


If a class that does not define any constructors contains a member variable that does define them then these traits return that the class with the member variable actually does have these functions (even though it does not).


struct TestA {
TestA() {}

struct TestB {
TestA a;

bool hasConstructor =  std::is_default_constructible<TestB>::value && !std::has_trivial_default_constructor<TestB>::value; // hasConstructor == true



I have a feeling that this is something that angelscript would not like during automatic registration.

In Topic: This changes when returning value objects

12 March 2013 - 06:17 AM

Ok, I have now dug deep into gccs type_traits and tr1/type_traits files and this looks like it might work after some simple testing (will need to do more testing, will report back later). Only problem with this one appears to be that I cannot find a c++11 has_trivial_copy function, it appears to be unimplemented, but it does exist in the tr1 (pre c++11 file)


#include <type_traits>
#include <tr1/type_traits>
template<typename T>
void automaticallyRegisterObjectTypeAsValue(asIScriptEngine *engine, std::string name) {
        bool hasConstructor =  std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value;
        bool hasDestructor = std::is_destructible<T>::value && !std::has_trivial_destructor<T>::value;
        bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::has_trivial_copy_assign<T>::value;
        bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::tr1::has_trivial_copy<T>::value;

       asDWORD flags = asOBJ_VALUE | asOBJ_APP_CLASS;
       if(hasConstructor) flags = flags | asOBJ_APP_CLASS_CONSTRUCTOR;
       if(hasDestructor) flags = flags | asOBJ_APP_CLASS_DESTRUCTOR;
       if(hasAssignmentOperator) flags = flags | asOBJ_APP_CLASS_ASSIGNMENT;
       if(hasCopyConstructor) flags = flags | asOBJ_APP_CLASS_COPY_CONSTRUCTOR;

       int r = engine->RegisterObjectType(name.c_str(), sizeof(T), flags ); assert( r >= 0 );