v 0. Pasted by Anonymous as cpp at 2012-09-25 14:05:46 MSK and set expiration to never.

Paste will expire never.

  1. int des_count = 0;
  2.  
  3. struct TestClass
  4. {
  5.     TestClass(){}
  6.     ~TestClass(){ 
  7.         std::cout << "des_count: " << ++des_count << "\n";
  8.     }
  9. };
  10.  
  11. static void ConstructTestClass(TestClass *thisPointer)
  12. {
  13.     new(thisPointer) TestClass();
  14. }
  15. static void CopyConstructTestClass(const TestClass &other, TestClass *thisPointer)
  16. {
  17.     new(thisPointer) TestClass(other);
  18. }
  19. static void DestructTestClass(TestClass *thisPointer)
  20. {
  21.     thisPointer->~TestClass();
  22. }
  23.  
  24.  
  25.  
  26.     r=en->RegisterObjectType( "TestLink",   sizeof( TestClass ), asOBJ_VALUE | asOBJ_APP_CLASS_CDK ); assert( r >= 0 );
  27.  
  28.     r=en->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT,  "void f()",                    asFUNCTION(ConstructTestClass), asCALL_CDECL_OBJLAST); assert( r >= 0 );
  29.     r=en->RegisterObjectBehaviour("TestLink", asBEHAVE_CONSTRUCT,  "void f(const TestLink &in)",    asFUNCTION(CopyConstructTestClass), asCALL_CDECL_OBJLAST); assert( r >= 0 );
  30.     r=en->RegisterObjectBehaviour("TestLink", asBEHAVE_DESTRUCT,   "void f()",                    asFUNCTION(DestructTestClass),  asCALL_CDECL_OBJLAST); assert( r >= 0 );
  31.  
  32.  
  33.  
  34. //------------------------------------------------------------------------------------
  35. //------------------------------------------------------------------------------------
  36. //------------------------------------------------------------------------------------
  37.  
  38. script:
  39.  
  40.  
  41. class Object3
  42. {
  43.     Object3( TestLink str )
  44.     {
  45.         Object2 @null_object = null;
  46.        
  47.         null_object.Do();
  48.     }
  49.  
  50.     void Do() {}
  51. }
  52.  
  53.  
  54. void Main()
  55. {
  56.    Object3 @oo = Object3( TestLink() );
  57. }