| 19 | }; |
| 20 | |
| 21 | class JsArgConverter { |
| 22 | public: |
| 23 | |
| 24 | JsArgConverter(const v8::Local<v8::Object>& caller, const v8::FunctionCallbackInfo<v8::Value>& args, const std::string& methodSignature, MetadataEntry* entry); |
| 25 | |
| 26 | JsArgConverter(const v8::FunctionCallbackInfo<v8::Value>& args, bool hasImplementationObject, const std::string& methodSignature, MetadataEntry* entry); |
| 27 | |
| 28 | JsArgConverter(const v8::FunctionCallbackInfo<v8::Value>& args, const std::string& methodSignature); |
| 29 | |
| 30 | ~JsArgConverter(); |
| 31 | |
| 32 | jvalue* ToArgs(); |
| 33 | |
| 34 | int Length() const; |
| 35 | |
| 36 | bool IsValid() const; |
| 37 | |
| 38 | struct Error; |
| 39 | |
| 40 | Error GetError() const; |
| 41 | |
| 42 | struct Error { |
| 43 | Error() : |
| 44 | index(-1), msg(std::string()) { |
| 45 | } |
| 46 | |
| 47 | int index; |
| 48 | std::string msg; |
| 49 | }; |
| 50 | |
| 51 | static BufferCastType GetCastType(const v8::Local<v8::ArrayBufferView>& view); |
| 52 | |
| 53 | private: |
| 54 | |
| 55 | bool ConvertArg(const v8::Local<v8::Value>& arg, int index); |
| 56 | |
| 57 | bool ConvertJavaScriptArray(const v8::Local<v8::Array>& jsArr, int index); |
| 58 | |
| 59 | bool ConvertJavaScriptNumber(const v8::Local<v8::Value>& jsValue, int index); |
| 60 | |
| 61 | bool ConvertJavaScriptBoolean(const v8::Local<v8::Value>& jsValue, int index); |
| 62 | |
| 63 | bool ConvertJavaScriptString(const v8::Local<v8::Value>& jsValue, int index); |
| 64 | |
| 65 | void SetConvertedObject(int index, jobject obj, bool isGlobal = false); |
| 66 | |
| 67 | template<typename T> |
| 68 | bool ConvertFromCastFunctionObject(T value, int index); |
| 69 | |
| 70 | v8::Isolate* m_isolate; |
| 71 | |
| 72 | int m_argsLen; |
| 73 | |
| 74 | bool m_isValid; |
| 75 | |
| 76 | jvalue m_args[255]; |
| 77 | int m_args_refs[255]; |
| 78 | int m_args_refs_size = 0; |