public static unsafe bool EvaluateScript(
            JSContextPtr cx,
            JSHandleObject scope,
            string chars,
            string filename,
            uint lineno,
            JSMutableHandleValue rval
            )
        {
            fixed(char *pChars = chars)
            fixed(char *pFilename = filename)
            {
                byte *pFilenameBytes = null;

                if (filename != null)
                {
                    byte *temp = stackalloc byte[filename.Length + 1];
                    pFilenameBytes = temp;

                    Encoding.ASCII.GetBytes(
                        pFilename, filename.Length,
                        pFilenameBytes, filename.Length
                        );
                }

                return(EvaluateUCScript(
                           cx, scope,
                           (IntPtr)pChars, chars.Length,
                           (IntPtr)pFilenameBytes, lineno,
                           rval
                           ));
            }
        }
 public static unsafe bool SetProperty(
     JSContextPtr cx,
     JSHandleObject obj,
     string name,
     JSHandleValue vp
     ) {
     fixed(char *pName = name)
     return(SetUCProperty(cx, obj, (IntPtr)pName, (uint)name.Length, vp));
 }
        public Rooted <JS.Value> InvokeFunction(
            JSContextPtr context,
            JSHandleObject thisReference,
            params JS.Value[] arguments
            )
        {
            var thisValue = new JS.Value(this);

            return(thisValue.InvokeFunction(context, thisReference, arguments));
        }
 public static unsafe JSFunctionPtr DefineFunction(
     JSContextPtr cx,
     JSHandleObject obj,
     string name,
     JSNative call,
     uint nargs, uint attrs
     ) {
     fixed(char *pName = name)
     return(DefineUCFunction(
                cx, obj, (IntPtr)pName, (uint)name.Length, call, nargs, attrs
                ));
 }
 public static unsafe bool CompileScript(
     JSContextPtr cx,
     JSHandleObject obj,
     string chars,
     JSCompileOptions options,
     JSMutableHandleScript script
     ) {
     fixed(char *pChars = chars)
     return(CompileUCScript(
                cx, obj,
                (IntPtr)pChars, (uint)chars.Length,
                options,
                script
                ));
 }
        public static unsafe bool CompileFunction(
            JSContextPtr cx, JSHandleObject obj,
            string name,
            UInt32 nargs, string[] argnames,
            string chars,
            JSCompileOptions options,
            JSMutableHandleFunction fun
            )
        {
            if (argnames == null)
            {
                argnames = new string[0];
            }

            if (nargs != argnames.Length)
            {
                throw new ArgumentException("Wrong number of argument names", "nargs");
            }
            char **argNameBuffers = stackalloc char *[argnames.Length];

            for (int i = 0; i < argnames.Length; i++)
            {
                argNameBuffers[i] = (char *)Marshal.StringToHGlobalAnsi(argnames[i]);
            }

            try {
                fixed(char *pChars = chars)
                return(CompileUCFunction(
                           cx, obj,
                           name, nargs, (IntPtr)argNameBuffers,
                           (IntPtr)pChars, (uint)chars.Length,
                           options,
                           fun
                           ));
            } finally {
                for (int i = 0; i < argnames.Length; i++)
                {
                    Marshal.FreeHGlobal((IntPtr)argNameBuffers[i]);
                }
            }
        }
 unsafe static JSHandleObject() {
     fixed(JSObjectPtr *pZero = &ZeroPtr)
     Zero = new JSHandleObject(pZero);
 }