xuipathpicker.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <precomp.h>
  2. #include "xuipathpicker.h"
  3. // -----------------------------------------------------------------------
  4. const wchar_t PathPickerXuiObjectStr[] = L"Wasabi:PathPicker";
  5. char PathPickerXuiSvcName[] = "Wasabi:PathPicker xui object";
  6. // -----------------------------------------------------------------------
  7. ScriptPathPicker::ScriptPathPicker() {
  8. getScriptObject()->vcpu_setInterface(pathPickerGuid, (void *)static_cast<PathPicker *>(this));
  9. getScriptObject()->vcpu_setClassName(L"PathPicker"); // this is the script class name
  10. getScriptObject()->vcpu_setController(pathPickerController);
  11. }
  12. // -----------------------------------------------------------------------
  13. ScriptPathPicker::~ScriptPathPicker() {
  14. }
  15. // -----------------------------------------------------------------------
  16. // Script Object
  17. PathPickerScriptController _pathPickerController;
  18. PathPickerScriptController *pathPickerController = &_pathPickerController;
  19. // -- Functions table -------------------------------------
  20. function_descriptor_struct PathPickerScriptController::exportedFunction[] = {
  21. {L"getPath", 0, (void*)PathPickerScriptController::PathPicker_getPath},
  22. {L"onPathChanged", 1, (void*)PathPickerScriptController::PathPicker_onPathChanged},
  23. };
  24. ScriptObject *PathPickerScriptController::instantiate() {
  25. ScriptPathPicker *sddl = new ScriptPathPicker;
  26. ASSERT(sddl != NULL);
  27. return sddl->getScriptObject();
  28. }
  29. void PathPickerScriptController::destroy(ScriptObject *o) {
  30. ScriptPathPicker *sddl= static_cast<ScriptPathPicker *>(o->vcpu_getInterface(pathPickerGuid));
  31. ASSERT(sddl != NULL);
  32. delete sddl;
  33. }
  34. void *PathPickerScriptController::encapsulate(ScriptObject *o) {
  35. return NULL; // no encapsulation
  36. }
  37. void PathPickerScriptController::deencapsulate(void *o) {
  38. }
  39. int PathPickerScriptController::getNumFunctions() {
  40. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  41. }
  42. const function_descriptor_struct *PathPickerScriptController::getExportedFunctions() {
  43. return exportedFunction;
  44. }
  45. scriptVar PathPickerScriptController::PathPicker_getPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  46. SCRIPT_FUNCTION_INIT
  47. ScriptPathPicker *sddl = static_cast<ScriptPathPicker*>(o->vcpu_getInterface(pathPickerGuid));
  48. const wchar_t *p=L"";
  49. if (sddl) p = sddl->getPath();
  50. return MAKE_SCRIPT_STRING(p);
  51. }
  52. // PathPickerScriptController::PathPicker_onNewPath(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(newpath));
  53. scriptVar PathPickerScriptController::PathPicker_onPathChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newpath) {
  54. SCRIPT_FUNCTION_INIT;
  55. PROCESS_HOOKS1(o, pathPickerController, newpath);
  56. SCRIPT_FUNCTION_CHECKABORTEVENT;
  57. SCRIPT_EXEC_EVENT1(o, newpath);
  58. }