internal object NativeObjectTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef) { if (getValueApi.GetJsValueType(isolate, value, isByRef) == JsValueType.NativeObject) { var objPtr = getValueApi.GetNativeObject(isolate, value, isByRef); var obj = objectPool.Get(objPtr.ToInt32()); return(obj); } return(null); }
internal object AnyTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef) { var type = getValueApi.GetJsValueType(isolate, value, isByRef); switch (type) { case JsValueType.BigInt: return(getValueApi.GetBigInt(isolate, value, isByRef)); case JsValueType.Boolean: return(getValueApi.GetBoolean(isolate, value, isByRef)); case JsValueType.Date: return(DateTranslator(isolate, getValueApi, value, isByRef)); case JsValueType.ArrayBuffer: return(getValueApi.GetArrayBuffer(isolate, value, isByRef)); case JsValueType.Function: return(getValueApi.GetFunction(isolate, value, isByRef)); case JsValueType.JsObject: return(getValueApi.GetJSObject(isolate, value, isByRef)); case JsValueType.NativeObject: var typeId = getValueApi.GetTypeId(isolate, value, isByRef); if (!typeRegister.IsArray(typeId)) { var objType = typeRegister.GetType(typeId); if (objType != typeof(object) && generalGetterMap.ContainsKey(objType)) { return(generalGetterMap[objType](isolate, getValueApi, value, isByRef)); } } var objPtr = getValueApi.GetNativeObject(isolate, value, isByRef); var result = objectPool.Get(objPtr.ToInt32()); var typedValueResult = result as TypedValue; if (typedValueResult != null) { return(typedValueResult.Target); } return(result); case JsValueType.Number: return(getValueApi.GetNumber(isolate, value, isByRef)); case JsValueType.String: return(getValueApi.GetString(isolate, value, isByRef)); default: return(null); } }
private object GenericDelegateTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef) { var jsValueType = getValueApi.GetJsValueType(isolate, value, isByRef); if (jsValueType == JsValueType.Function) { var nativePtr = getValueApi.GetFunction(isolate, value, isByRef); return(new GenericDelegate(nativePtr, jsEnv)); } else { return(AnyTranslator(isolate, getValueApi, value, isByRef)); } }
private object JSObjectTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef) { var jsValueType = getValueApi.GetJsValueType(isolate, value, isByRef); if (jsValueType == JsValueType.JsObject) { IntPtr DLLJSObjectPtr = getValueApi.GetJSObject(isolate, value, isByRef); return(jsEnv.jsObjectFactory.GetOrCreateJSObject(DLLJSObjectPtr, jsEnv)); } else { return(AnyTranslator(isolate, getValueApi, value, isByRef)); } }
internal object AnyTranslator(IntPtr isolate, IGetValueFromJs getValueApi, IntPtr value, bool isByRef) { var type = getValueApi.GetJsValueType(isolate, value, isByRef); switch (type) { case JsValueType.BigInt: return(getValueApi.GetBigInt(isolate, value, isByRef)); case JsValueType.Boolean: return(getValueApi.GetBoolean(isolate, value, isByRef)); case JsValueType.Date: return(DateTranslator(isolate, getValueApi, value, isByRef)); //case JsValueType.Function: //case JsValueType.JsObject: case JsValueType.NativeObject: var typeId = getValueApi.GetTypeId(isolate, value, isByRef); var objType = typeRegister.GetType(typeId); if (objType != typeof(object) && generalGetterMap.ContainsKey(objType)) { return(generalGetterMap[objType](isolate, getValueApi, value, isByRef)); } var objPtr = getValueApi.GetObject(isolate, value, isByRef); return(objectPool.Get(objPtr.ToInt32())); case JsValueType.Number: return(getValueApi.GetNumber(isolate, value, isByRef)); case JsValueType.String: return(getValueApi.GetString(isolate, value, isByRef)); default: return(null); } }