Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 07 April 2013 - 09:43 PM

Hi Andreas smile.png

 

with asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT we can create all objects from c++ code, for deserealization - It work fine!

but, for scripts, i think no need use this.

 

exemple:

this code work, but it's not goood

 

 

 

 

class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s;
}
 

 



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3292

Like
0Likes
Like

Posted 08 April 2013 - 08:15 AM

The flag asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT is to tell the compiler to implement the default constructor even though the class has a defined non-default constructor. This is mostly used for backwards compatibility as it was the behaviour in the compiler before version 2.22.1. When deserializing objects you should use the method CreateUninitializedScriptObject() to get the object and then fill out all the members explicitly.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 08 April 2013 - 09:22 PM

yes you are absolutely right!
CreateUninitializedScriptObject work from c++ - and this good, but def counstructor we can use from script - it's not good!
I want to even when the flag is set, it shows an error - not defined a default constructor( only from script ).
 
ex:
 

 

// asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, false
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // No default constructor for object of type 'SomeClass'.
}

//-----------------------------------------------------------------------------

//next 
// asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, true ( current time )
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // work
}

//-----------------------------------------------------------------------------

// a want to, we set asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT true, and we have - 
class SomeClass{
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // No default constructor for object of type 'SomeClass'.
}
// add constructor
class SomeClass{
     SomeClass(){  /* def constructor */ }      
     SomeClass( int init_param ){}
}
void f(){
     SomeClass s; // work
}

 


Edited by FDsagizi, 08 April 2013 - 09:31 PM.


#4 Andreas Jonsson   Moderators   -  Reputation: 3292

Like
0Likes
Like

Posted 09 April 2013 - 08:45 AM

No. Since you don't want the default constructor to be available automatically, then you should _not_ set the flag asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT to true.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#5 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 09 April 2013 - 09:03 PM

No. Since you don't want the default constructor to be available automatically, then you should _not_ set the flag asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT to true.

oh yes, im sorry!rolleyes.gif

i thinking CreateUninitializedScriptObject work only with asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT to true.

cool!smile.png 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS