ThrowIfError() public static method

Throws if a native method returns an error code
public static ThrowIfError ( JsErrorCode error ) : void
error JsErrorCode The error
return void
コード例 #1
0
        /// <summary>
        /// Creates a <c>Number</c> value from a <c>double</c> value
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="value">The value to be converted</param>
        /// <returns>The new <c>Number</c> value</returns>
        public static EdgeJsValue FromDouble(double value)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsDoubleToNumber(value, out reference));

            return(reference);
        }
コード例 #2
0
        /// <summary>
        /// Test if an object has a value at the specified index
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="index">The index to test</param>
        /// <returns>Whether the object has an value at the specified index</returns>
        public bool HasIndexedProperty(EdgeJsValue index)
        {
            bool hasProperty;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsHasIndexedProperty(this, index, out hasProperty));

            return(hasProperty);
        }
コード例 #3
0
        /// <summary>
        /// Compare two JavaScript values for strict equality
        /// </summary>
        /// <remarks>
        /// <para>
        /// This function is equivalent to the "===" operator in JavaScript.
        /// </para>
        /// <para>
        /// Requires an active script context.
        /// </para>
        /// </remarks>
        /// <param name="other">The object to compare</param>
        /// <returns>Whether the values are strictly equal</returns>
        public bool StrictEquals(EdgeJsValue other)
        {
            bool equals;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsStrictEquals(this, other, out equals));

            return(equals);
        }
コード例 #4
0
        /// <summary>
        /// Determines whether an object has a property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="propertyId">The ID of the property</param>
        /// <returns>Whether the object (or a prototype) has the property</returns>
        public bool HasProperty(EdgeJsPropertyId propertyId)
        {
            bool hasProperty;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsHasProperty(this, propertyId, out hasProperty));

            return(hasProperty);
        }
コード例 #5
0
        /// <summary>
        /// Deletes a object's property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="propertyId">The ID of the property</param>
        /// <param name="useStrictRules">The property set should follow strict mode rules</param>
        /// <returns>Whether the property was deleted</returns>
        public EdgeJsValue DeleteProperty(EdgeJsPropertyId propertyId, bool useStrictRules)
        {
            EdgeJsValue returnReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsDeleteProperty(this, propertyId, useStrictRules, out returnReference));

            return(returnReference);
        }
コード例 #6
0
        /// <summary>
        /// Converts a value to <c>String</c> using regular JavaScript semantics
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The converted value</returns>
        public EdgeJsValue ConvertToString()
        {
            EdgeJsValue stringReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsConvertValueToString(this, out stringReference));

            return(stringReference);
        }
コード例 #7
0
        /// <summary>
        /// Gets a property descriptor for an object's own property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="propertyId">The ID of the property</param>
        /// <returns>The property descriptor</returns>
        public EdgeJsValue GetOwnPropertyDescriptor(EdgeJsPropertyId propertyId)
        {
            EdgeJsValue descriptorReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsGetOwnPropertyDescriptor(this, propertyId, out descriptorReference));

            return(descriptorReference);
        }
コード例 #8
0
        /// <summary>
        /// Creates a new JavaScript function
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="function">The method to call when the function is invoked</param>
        /// <param name="callbackData">Data to be provided to all function callbacks</param>
        /// <returns>The new function object</returns>
        public static EdgeJsValue CreateFunction(EdgeJsNativeFunction function, IntPtr callbackData)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateFunction(function, callbackData, out reference));

            return(reference);
        }
コード例 #9
0
        /// <summary>
        /// Creates a JavaScript array object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="length">The initial length of the array</param>
        /// <returns>The new array object</returns>
        public static EdgeJsValue CreateArray(uint length)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateArray(length, out reference));

            return(reference);
        }
コード例 #10
0
        /// <summary>
        /// Creates a new <c>Object</c>
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The new <c>Object</c></returns>
        public static EdgeJsValue CreateObject()
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateObject(out reference));

            return(reference);
        }
コード例 #11
0
        /// <summary>
        /// Creates a new <c>Object</c> that stores some external data
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="data">External data that the object will represent. May be null</param>
        /// <param name="finalizer">The callback for when the object is finalized. May be null.</param>
        /// <returns>The new <c>Object</c></returns>
        public static EdgeJsValue CreateExternalObject(IntPtr data, JsObjectFinalizeCallback finalizer)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateExternalObject(data, finalizer, out reference));

            return(reference);
        }
コード例 #12
0
        /// <summary>
        /// Creates a JavaScript value that is a projection of the passed in object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="value">The object to be projected</param>
        /// <returns>The JavaScript value that is a projection of the object</returns>
        public static EdgeJsValue FromObject(object value)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsVariantToValue(ref value, out reference));

            return(reference);
        }
コード例 #13
0
        /// <summary>
        /// Creates a <c>String</c> value from a string pointer
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="value">The string  to convert to a <c>String</c> value</param>
        /// <returns>The new <c>String</c> value</returns>
        public static EdgeJsValue FromString(string value)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsPointerToString(value, new UIntPtr((uint)value.Length), out reference));

            return(reference);
        }
コード例 #14
0
        /// <summary>
        /// Creates a <c>Number</c> value from a <c>int</c> value
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="value">The value to be converted</param>
        /// <returns>The new <c>Number</c> value</returns>
        public static EdgeJsValue FromInt32(int value)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsIntToNumber(value, out reference));

            return(reference);
        }
コード例 #15
0
        /// <summary>
        /// Converts a value to <c>Boolean</c> using regular JavaScript semantics
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The converted value</returns>
        public EdgeJsValue ConvertToBoolean()
        {
            EdgeJsValue booleanReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsConvertValueToBoolean(this, out booleanReference));

            return(booleanReference);
        }
コード例 #16
0
        /// <summary>
        /// Creates a new JavaScript URIError error object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="message">Message for the error object</param>
        /// <returns>The new error object</returns>
        public static EdgeJsValue CreateUriError(EdgeJsValue message)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateURIError(message, out reference));

            return(reference);
        }
コード例 #17
0
        /// <summary>
        /// Converts a value to <c>Number</c> using regular JavaScript semantics
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The converted value</returns>
        public EdgeJsValue ConvertToNumber()
        {
            EdgeJsValue numberReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsConvertValueToNumber(this, out numberReference));

            return(numberReference);
        }
コード例 #18
0
        /// <summary>
        /// Adds a reference to the object
        /// </summary>
        /// <remarks>
        /// This only needs to be called on objects that are not going to be stored somewhere on
        /// the stack. Calling AddRef ensures that the JavaScript object the value refers to will not be freed
        /// until Release is called.
        /// </remarks>
        /// <returns>The object's new reference count</returns>
        public uint AddRef()
        {
            uint count;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsAddRef(this, out count));

            return(count);
        }
コード例 #19
0
        /// <summary>
        /// Converts a value to <c>Object</c> using regular JavaScript semantics
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The converted value</returns>
        public EdgeJsValue ConvertToObject()
        {
            EdgeJsValue objectReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsConvertValueToObject(this, out objectReference));

            return(objectReference);
        }
コード例 #20
0
        /// <summary>
        /// Releases a reference to the object
        /// </summary>
        /// <remarks>
        /// Removes a reference that was created by AddRef.
        /// </remarks>
        /// <returns>The object's new reference count</returns>
        public uint Release()
        {
            uint count;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsRelease(this, out count));

            return(count);
        }
コード例 #21
0
        /// <summary>
        /// Gets a list of all properties on the object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>An array of property names</returns>
        public EdgeJsValue GetOwnPropertyNames()
        {
            EdgeJsValue propertyNamesReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsGetOwnPropertyNames(this, out propertyNamesReference));

            return(propertyNamesReference);
        }
コード例 #22
0
        /// <summary>
        /// Retrieves a <c>bool</c> value of a <c>Boolean</c> value
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The converted value</returns>
        public bool ToBoolean()
        {
            bool value;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsBooleanToBool(this, out value));

            return(value);
        }
コード例 #23
0
        /// <summary>
        /// Gets a object's property
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="id">The ID of the property</param>
        /// <returns>The value of the property</returns>
        public EdgeJsValue GetProperty(EdgeJsPropertyId id)
        {
            EdgeJsValue propertyReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsGetProperty(this, id, out propertyReference));

            return(propertyReference);
        }
コード例 #24
0
        /// <summary>
        /// Retrieves a <c>double</c> value of a <c>Number</c> value
        /// </summary>
        /// <remarks>
        /// <para>
        /// This function retrieves the value of a Number value. It will fail with
        /// <c>InvalidArgument</c> if the type of the value is not <c>Number</c>.
        /// </para>
        /// <para>
        /// Requires an active script context.
        /// </para>
        /// </remarks>
        /// <returns>The <c>double</c> value</returns>
        public double ToDouble()
        {
            double value;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsNumberToDouble(this, out value));

            return(value);
        }
コード例 #25
0
        /// <summary>
        /// Defines a new object's own property from a property descriptor
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="propertyId">The ID of the property</param>
        /// <param name="propertyDescriptor">The property descriptor</param>
        /// <returns>Whether the property was defined</returns>
        public bool DefineProperty(EdgeJsPropertyId propertyId, EdgeJsValue propertyDescriptor)
        {
            bool result;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsDefineProperty(this, propertyId, propertyDescriptor, out result));

            return(result);
        }
コード例 #26
0
        /// <summary>
        /// Retrieves a <c>int</c> value of a <c>Number</c> value
        /// </summary>
        /// <remarks>
        /// <para>
        /// This function retrieves the value of a Number value. It will fail with
        /// <c>InvalidArgument</c> if the type of the value is not <c>Number</c>.
        /// </para>
        /// <para>
        /// Requires an active script context.
        /// </para>
        /// </remarks>
        /// <returns>The <c>int</c> value</returns>
        public int ToInt32()
        {
            int value;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsNumberToInt(this, out value));

            return(value);
        }
コード例 #27
0
        /// <summary>
        /// Retrieve a value at the specified index of an object
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="index">The index to retrieve</param>
        /// <returns>The retrieved value</returns>
        public EdgeJsValue GetIndexedProperty(EdgeJsValue index)
        {
            EdgeJsValue propertyReference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsGetIndexedProperty(this, index, out propertyReference));

            return(propertyReference);
        }
コード例 #28
0
        /// <summary>
        /// Retrieves a object representation of an <c>Object</c> value
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <returns>The object representation of the value</returns>
        public object ToObject()
        {
            object value;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsValueToVariant(this, out value));

            return(value);
        }
コード例 #29
0
        /// <summary>
        /// Gets a property ID associated with the name
        /// </summary>
        /// <remarks>
        /// <para>
        /// Property IDs are specific to a context and cannot be used across contexts.
        /// </para>
        /// <para>
        /// Requires an active script context.
        /// </para>
        /// </remarks>
        /// <param name="name">The name of the property ID to get or create.
        /// The name may consist of only digits.</param>
        /// <returns>The property ID in this runtime for the given name</returns>
        public static EdgeJsPropertyId FromString(string name)
        {
            EdgeJsPropertyId id;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsGetPropertyIdFromName(name, out id));

            return(id);
        }
コード例 #30
0
        /// <summary>
        /// Creates a <c>Boolean</c> value from a <c>bool</c> value
        /// </summary>
        /// <remarks>
        /// Requires an active script context.
        /// </remarks>
        /// <param name="value">The value to be converted</param>
        /// <returns>The converted value</returns>
        public static EdgeJsValue FromBoolean(bool value)
        {
            EdgeJsValue reference;

            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsBoolToBoolean(value, out reference));

            return(reference);
        }