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.

43 lines
1.3 KiB

  1. #ifndef SQUIRREL_BINDINGS_UTILS_WIN32_H
  2. #define SQUIRREL_BINDINGS_UTILS_WIN32_H
  3. #ifdef WIN32
  4. #ifndef _INC_WINDOWS
  5. #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
  6. // Windows Header Files:
  7. #include <windows.h>
  8. #endif
  9. #ifndef __IUnknown_INTERFACE_DEFINED__
  10. #include <unknwn.h>
  11. #endif
  12. #endif
  13. #ifndef SQUIRREL_BINDINGS_UTILS_H
  14. #include "SquirrelBindingsUtils.h"
  15. #endif
  16. #define _DECLARE_REFCOUNTED_NEW(cppclass,classname) \
  17. SquirrelObject new_##classname(cppclass *ptr) { \
  18. if(CreateRefCountedInstance(SquirrelVM::GetVMPtr(),_T(#classname),ptr)) { \
  19. HSQOBJECT o; \
  20. sq_getstackobj(SquirrelVM::GetVMPtr(),-1,&o); \
  21. SquirrelObject tmp = o; \
  22. sq_pop(SquirrelVM::GetVMPtr(),1); \
  23. return tmp; \
  24. } \
  25. return SquirrelObject() ; \
  26. }
  27. #define _RETURN_REFCOUNTED_INSTANCE(classname,ptr) \
  28. if(!CreateRefCountedInstance(SquirrelVM::GetVMPtr(),_T(#classname),ptr)) { \
  29. return sa.ThrowError(_T("cannot create the class instance")); \
  30. } \
  31. return 1;
  32. BOOL CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC);
  33. BOOL CreateRefCountedInstanceChached(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC);
  34. SQInteger refcounted_release_hook(SQUserPointer p, SQInteger size);
  35. int construct_RefCounted(IUnknown *p);
  36. #endif // SQUIRREL_BINDINGS_UTILS_WIN32_H