objcontrollert.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __SCRIPTOBJECTCONTROLLERT_H
  2. #define __SCRIPTOBJECTCONTROLLERT_H
  3. #include "objcontroller.h"
  4. template <class T, class A>
  5. class ScriptObjectControllerT : public ScriptObjectControllerI {
  6. public:
  7. virtual const wchar_t *getClassName() { return T::scriptobject_getClassName(); }
  8. virtual const wchar_t *getAncestorClassName() { return A::scriptobject_getClassName(); }
  9. virtual ScriptObjectController *getAncestorController() {
  10. return WASABI_API_MAKI->maki_getController(A::scriptobject_getClassGuid());
  11. }
  12. virtual GUID getClassGuid() { return T::scriptobject_getClassGuid(); }
  13. virtual ScriptObject *instantiate() {
  14. return (new T)->getScriptObject();
  15. }
  16. virtual void destroy(ScriptObject *o) {
  17. T *t = static_cast<T *>(o->vcpu_getInterface(T::scriptobject_getClassGuid()));
  18. delete t;
  19. }
  20. virtual void *encapsulate(ScriptObject *o) { return NULL; }
  21. virtual void deencapsulate(void *o) { }
  22. #if 0
  23. virtual int getNumFunctions() { return fn_descs.getNumItems(); }
  24. virtual const function_descriptor_struct *getExportedFunctions() {
  25. return fn_descs.enumRef(0);
  26. }
  27. protected:
  28. void addFn(const wchar_t *fnname, scriptcb *cb) {
  29. function_descriptor_struct fds;
  30. fds.function_name = fnname;
  31. fds.nparams = cb->getNumParams();
  32. fds.physical_ptr = cb->
  33. }
  34. private:
  35. TList fn_descs;
  36. #endif
  37. };
  38. #if 0
  39. class scriptcb {
  40. public:
  41. virtual void *getNumParams()=0;
  42. virtual void *getfn()=0;
  43. };
  44. template <class T>
  45. class scriptcb0v : public scriptcb {
  46. typedef void (T::*fnPtrType)();
  47. public:
  48. scriptcb0v(fnPtrType _fn) : fn(_fn) { }
  49. static scriptVar call(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  50. SCRIPT_FUNCTION_INIT
  51. T *t = static_cast<T *>(o->vcpu_getInterface(T::scriptobject_getClassGuid()));
  52. if (t) (t->*fn)();
  53. RETURN_SCRIPT_VOID;
  54. }
  55. virtual void *getNumParams() { return 0; }
  56. virtual void *getfn() {
  57. return static_cast<void *>(call);
  58. }
  59. };
  60. #endif
  61. #endif