Jurassic.Library.FunctionInstance.CallFromNative C# (CSharp) Method

CallFromNative() private method

Calls this function, passing in the given "this" value and zero or more arguments.
private CallFromNative ( string function, object thisObject ) : object
function string The name of the caller function.
thisObject object The value of the "this" keyword within the function.
return object
        internal object CallFromNative(string function, object thisObject, params object[] argumentValues)
        {
            this.Engine.PushStackFrame("native", function, 0);
            try
            {
                return CallLateBound(thisObject, argumentValues);
            }
            finally
            {
                this.Engine.PopStackFrame();
            }
        }

Usage Example

Exemplo n.º 1
0
        public TypedArrayInstance From(object source, FunctionInstance mapFn = null, object thisArg = null)
        {
            var items = TypeConverter.ToObject(Engine, source);

            var iterator = TypeUtilities.GetIterator(Engine, items);

            if (iterator != null)
            {
                // Loop.
                var values = new List <object>();
                foreach (var value in TypeUtilities.Iterate(Engine, iterator))
                {
                    // Collect the values.
                    values.Add(value);
                }

                // Convert the values into a typed array instance.
                var result = new TypedArrayInstance(this.InstancePrototype, this.type,
                                                    Engine.ArrayBuffer.Construct(values.Count * BytesPerElement), 0, values.Count);
                for (int i = 0; i < values.Count; i++)
                {
                    if (mapFn != null)
                    {
                        result[i] = mapFn.CallFromNative("from", thisArg, values[i], i);
                    }
                    else
                    {
                        result[i] = values[i];
                    }
                }
                return(result);
            }
            else
            {
                // There was no iterator symbol value, so fall back on the alternate method.
                int length = TypeConverter.ToInt32(items["length"]);
                var result = new TypedArrayInstance(this.InstancePrototype, this.type, Engine.ArrayBuffer.Construct(length * BytesPerElement), 0, length);
                for (int i = 0; i < length; i++)
                {
                    if (mapFn != null)
                    {
                        result[i] = mapFn.CallFromNative("from", thisArg, items[i], i);
                    }
                    else
                    {
                        result[i] = items[i];
                    }
                }
                return(result);
            }
        }
All Usage Examples Of Jurassic.Library.FunctionInstance::CallFromNative