示例#1
0
        internal JavaScriptValue(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine)
        {
            Debug.Assert(handle != null);
            Debug.Assert(engine != null);
            Debug.Assert(Enum.IsDefined(typeof(JavaScriptValueType), type));
            handle.SetEngine(engine);
            api_ = engine.Api;

            uint count;
            Errors.ThrowIfIs(api_.JsAddRef(handle.DangerousGetHandle(), out count));

            handle_ = handle;
            type_ = type;
            engine_ = new WeakReference<JavaScriptEngine>(engine);
        }
 internal JavaScriptArrayBuffer(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine):
     base(handle, type, engine)
 {
     len_ = new Lazy<uint>(GetLength);
 }
示例#3
0
        internal JavaScriptFunction(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine):
            base(handle, type, engine)
        {

        }
示例#4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (handle_ != null)
         {
             handle_.Dispose();
             handle_ = null;
         }
     }
 }
 internal JavaScriptTypedArray(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine):
     base(handle, type, engine)
 {
     arrayType_ = new Lazy<JavaScriptTypedArrayType>(GetArrayType);
 }
示例#6
0
        internal JavaScriptArray CreateArrayFromHandle(JavaScriptValueSafeHandle handle)
        {
            ClaimContext();

            JsValueType kind;
            Errors.ThrowIfIs(api_.JsGetValueType(handle, out kind));

            switch (kind)
            {
                case JsValueType.JsArray:
                    return new JavaScriptArray(handle, JavaScriptValueType.Array, this);

                case JsValueType.JsFunction:
                case JsValueType.JsObject:
                case JsValueType.JsError:
                case JsValueType.JsNull:
                case JsValueType.JsArrayBuffer:
                case JsValueType.JsTypedArray:
                case JsValueType.JsDataView:
                case JsValueType.JsBoolean:
                case JsValueType.JsNumber:
                case JsValueType.JsString:
                case JsValueType.JsUndefined:
                case JsValueType.JsSymbol:
                default:
                    throw new ArgumentException();
            }
        }
示例#7
0
        internal JavaScriptValue CreateValueFromHandle(JavaScriptValueSafeHandle handle)
        {
            ClaimContext();

            JsValueType kind;
            Errors.ThrowIfIs(api_.JsGetValueType(handle, out kind));

            switch (kind)
            {
                case JsValueType.JsArray:
                    return new JavaScriptArray(handle, JavaScriptValueType.Array, this);

                case JsValueType.JsFunction:
                    return new JavaScriptFunction(handle, JavaScriptValueType.Function, this);

                case JsValueType.JsObject:
                case JsValueType.JsNull:
                case JsValueType.JsError:
                    return new JavaScriptObject(handle, JavaScriptValueType.Object, this);

                case JsValueType.JsSymbol:
                    return new JavaScriptSymbol(handle, JavaScriptValueType.Symbol, this);

                case JsValueType.JsArrayBuffer:
                    return new JavaScriptArrayBuffer(handle, JavaScriptValueType.ArrayBuffer, this);

                case JsValueType.JsTypedArray:
                    return new JavaScriptTypedArray(handle, JavaScriptValueType.TypedArray, this);

                case JsValueType.JsDataView:
                    return new JavaScriptDataView(handle, JavaScriptValueType.DataView, this);

                case JsValueType.JsBoolean:
                case JsValueType.JsNumber:
                case JsValueType.JsString:
                case JsValueType.JsUndefined:
                default:
                    return new JavaScriptValue(handle, kind.ToApiValueType(), this);
            }
        }
示例#8
0
        internal JavaScriptDataView(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine) :
            base(handle, type, engine)
        {

        }
示例#9
0
        internal JavaScriptSymbol(JavaScriptValueSafeHandle handle, JavaScriptValueType type, JavaScriptEngine engine):
            base(handle, type, engine)
        {

        }