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.

35 lines
1.3 KiB

  1. // This is part of squirrelobject.h that removes circular dependency between sqplus.h and squirrelobject.h: it depends on both
  2. #ifndef _SQUIRREL_OBJECT_IMPL_H_
  3. #define _SQUIRREL_OBJECT_IMPL_H_
  4. // === BEGIN code suggestion from the Wiki ===
  5. // Get any bound type from this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
  6. template<typename _ty>
  7. inline _ty SquirrelObject::Get(void) {
  8. sq_pushobject(SquirrelVM::_VM,GetObjectHandle());
  9. _ty val = SqPlus::Get(SqPlus::TypeWrapper<_ty>(),SquirrelVM::_VM,-1);
  10. sq_poptop(SquirrelVM::_VM);
  11. return val;
  12. }
  13. // Set any bound type to this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
  14. template<typename _ty>
  15. inline SquirrelObject SquirrelObject::SetByValue(_ty val) { // classes/structs should be passed by ref (below) to avoid an extra copy.
  16. SqPlus::Push(SquirrelVM::_VM,val);
  17. AttachToStackObject(-1);
  18. sq_poptop(SquirrelVM::_VM);
  19. return *this;
  20. }
  21. // Set any bound type to this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
  22. template<typename _ty>
  23. inline SquirrelObject SquirrelObject::Set(_ty & val) {
  24. SqPlus::Push(SquirrelVM::_VM,val);
  25. AttachToStackObject(-1);
  26. sq_poptop(SquirrelVM::_VM);
  27. return *this;
  28. }
  29. // === END code suggestion from the Wiki ===
  30. #endif