Rev 1602 | Rev 1607 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1602 | Rev 1604 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | logging::Logger Module::LOG("vm::plugin::module"); |
31 | logging::Logger Module::LOG("vm::plugin::module"); |
| 32 | 32 | ||
| 33 | Module::Module() |
33 | Module::Module() |
| 34 | { |
34 | { |
| 35 | this->name_ = "module"; |
35 | this->name_ = "module"; |
| 36 | this->tracker_ = TrackerPointer(new char); |
- | |
| 37 | 36 | ||
| 38 | this->ImportFunction("Module_OnChange"); |
37 | this->ImportFunction("Module_OnChange"); |
| 39 | this->ImportFunction("Module_OnMessage"); |
38 | this->ImportFunction("Module_OnMessage"); |
| 40 | 39 | ||
| 41 | this->ExportFunction("Module_SendMessage", Module::Export_SendModuleMessage); |
40 | this->ExportFunction("Module_SendMessage", Module::Export_SendModuleMessage); |
| - | 41 | this->ExportFunction("Module_IsModuleAvailable", Module::Export_IsModuleAvailable); |
|
| 42 | } |
42 | } |
| 43 | 43 | ||
| 44 | Module::~Module() |
44 | Module::~Module() |
| 45 | { |
45 | { |
| 46 | this->tracker_.reset(); |
46 | this->tracker_.reset(); |
| Line 78... | Line 78... | ||
| 78 | } |
78 | } |
| 79 | 79 | ||
| 80 | this->Call("Module_OnMessage", arguments); |
80 | this->Call("Module_OnMessage", arguments); |
| 81 | } |
81 | } |
| 82 | 82 | ||
| 83 | Value |
83 | Value Module::Export_SendModuleMessage(const v8::Arguments& args) |
| 84 | { |
84 | { |
| - | 85 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
|
| - | 86 | ||
| - | 87 | if (args.Length() < 3) |
|
| - | 88 | { |
|
| - | 89 | LOG.Error("To few arguments."); |
|
| - | 90 | } |
|
| - | 91 | ||
| 85 | type::StringMap variables; |
92 | type::StringMap variables; |
| 86 | 93 | ||
| 87 | v8::String::AsciiValue full_id(args[0]); |
94 | v8::String::AsciiValue full_id(args[0]); |
| 88 | v8::String::AsciiValue command(args[1]); |
95 | v8::String::AsciiValue command(args[1]); |
| 89 | unsigned int length = args[2]->Uint32Value(); |
96 | unsigned int length = args[2]->Uint32Value(); |
| 90 | 97 | ||
| 91 | for (unsigned int n = 3; n < length * 2 + 3; n += 2) |
98 | for (unsigned int n = 3; n < length * 2 + 3; n += 2) |
| 92 | { |
99 | { |
| 93 | v8::String::AsciiValue name(args[n]); |
100 | v8::String::AsciiValue name(args[n]); |
| 94 | v8::String::AsciiValue value(args[n + 1]); |
101 | v8::String::AsciiValue value(args[n + 1]); |
| 95 | 102 | ||
| 96 | variables[std::string(*name)] = std::string(*value); |
103 | variables[std::string(*name)] = std::string(*value); |
| 97 | } |
104 | } |
| 98 | 105 | ||
| 99 | can::Manager::Instance()->SendMessage(std::string(*full_id), std::string(*command), variables); |
106 | can::Manager::Instance()->SendMessage(std::string(*full_id), std::string(*command), variables); |
| - | 107 | ||
| - | 108 | return v8::Undefined(); |
|
| - | 109 | } |
|
| - | 110 | ||
| - | 111 | Value Module::Export_IsModuleAvailable(const v8::Arguments& args) |
|
| - | 112 | { |
|
| - | 113 | LOG.Debug(std::string(__FUNCTION__) + " called!"); |
|
| - | 114 | ||
| - | 115 | if (args.Length() < 1) |
|
| - | 116 | { |
|
| - | 117 | LOG.Error("To few arguments."); |
|
| - | 118 | } |
|
| - | 119 | ||
| - | 120 | v8::String::AsciiValue full_id(args[0]); |
|
| - | 121 | ||
| - | 122 | return v8::Boolean::New(can::Manager::Instance()->IsModuleAvailable(std::string(*full_id))); |
|
| 100 | } |
123 | } |
| 101 | 124 | ||
| 102 | }; // namespace plugin |
125 | }; // namespace plugin |
| 103 | }; // namespace vm |
126 | }; // namespace vm |
| 104 | }; // namespace atom |
127 | }; // namespace atom |