src/squirrel.cpp
branchnoai
changeset 9679 788e083db48b
parent 9674 15f7b310b6cf
child 9782 e8d8d8894f23
equal deleted inserted replaced
9678:c78400096127 9679:788e083db48b
   176 		/* Find our instance */
   176 		/* Find our instance */
   177 		sq_getstackobj(vm, -1, instance);
   177 		sq_getstackobj(vm, -1, instance);
   178 		/* Add a reference to it, so it survives for ever */
   178 		/* Add a reference to it, so it survives for ever */
   179 		sq_addref(vm, instance);
   179 		sq_addref(vm, instance);
   180 	}
   180 	}
       
   181 	sq_remove(vm, -2); // Class-name
       
   182 	sq_remove(vm, -2); // Root-table
       
   183 
   181 	/* Store it in the class */
   184 	/* Store it in the class */
   182 	sq_setinstanceup(vm, -1, real_instance);
   185 	sq_setinstanceup(vm, -1, real_instance);
   183 	if (release_hook != NULL) sq_setreleasehook(vm, -1, release_hook);
   186 	if (release_hook != NULL) sq_setreleasehook(vm, -1, release_hook);
   184 
   187 
   185 	/* Reset the top */
   188 	if (instance != NULL) sq_settop(vm, oldtop);
   186 	sq_settop(vm, oldtop);
       
   187 
   189 
   188 	return true;
   190 	return true;
   189 }
   191 }
   190 
   192 
   191 bool Squirrel::CreateClassInstance(const char *class_name, void *real_instance, HSQOBJECT *instance)
   193 bool Squirrel::CreateClassInstance(const char *class_name, void *real_instance, HSQOBJECT *instance)