Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
871 B

  1. #include "sqplus.h"
  2. //#include "SquirrelObject.h"
  3. //#include "SquirrelVM.h"
  4. #include "SquirrelBindingsUtilsWin32.h"
  5. #if defined(VSCRIPT_DLL_EXPORT) || defined(VSQUIRREL_TEST)
  6. #include "memdbgon.h"
  7. #endif
  8. SQInteger refcounted_release_hook(SQUserPointer p, SQInteger size)
  9. {
  10. IUnknown *pRC = (IUnknown*)p;
  11. pRC->Release();
  12. return 0;
  13. }
  14. static BOOL __CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC,SQRELEASEHOOK hook)
  15. {
  16. if(!CreateNativeClassInstance(v,classname,pRC,hook)) return FALSE;
  17. return TRUE;
  18. }
  19. int construct_RefCounted(IUnknown *p)
  20. {
  21. sq_setinstanceup(SquirrelVM::GetVMPtr(),1,p);
  22. sq_setreleasehook(SquirrelVM::GetVMPtr(),1,refcounted_release_hook);
  23. return 1;
  24. }
  25. BOOL CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC)
  26. {
  27. return __CreateRefCountedInstance(v,classname,pRC,refcounted_release_hook);
  28. }