/// <summary> /// Evaluates JavaScript code represented as a <see cref="String"/> in this V8 context. /// </summary> /// <param name="code">The JavaScript code.</param> /// <param name="scriptUrl">The URL where the script in question can be found, if any.</param> /// <param name="line">The base line number to use for error reporting.</param> /// <returns>The completion value of evaluating the given code.</returns> /// <exception cref="CefNetJSExcepton"> /// Thrown when an exception is raised in the JavaScript engine. /// </exception> public CefV8Value Eval(string code, string scriptUrl, int line = 1) { if (line <= 0) { throw new ArgumentOutOfRangeException(nameof(line)); } if (code is null) throw new ArgumentNullException(nameof(code)); fixed(char *s0 = code) fixed(char *s1 = scriptUrl) { var cstr0 = new cef_string_t { Str = s0, Length = code.Length }; var cstr1 = new cef_string_t { Str = s1, Length = scriptUrl != null ? scriptUrl.Length : 0 }; cef_v8value_t * rv = null; cef_v8value_t ** pRv = &rv; cef_v8exception_t * jsex = null; cef_v8exception_t **pJsex = &jsex; if (NativeInstance->Eval(&cstr0, &cstr1, line, pRv, pJsex) != 0) { return(CefV8Value.Wrap(CefV8Value.Create, rv)); } GC.KeepAlive(this); throw new CefNetJSExcepton(CefV8Exception.Wrap(CefV8Exception.Create, jsex)); } }
/// <summary> /// Execute a string of JavaScript code in this V8 context. The |script_url| /// parameter is the URL where the script in question can be found, if any. The /// |start_line| parameter is the base line number to use for error reporting. /// On success |retval| will be set to the return value, if any, and the /// function will return true (1). On failure |exception| will be set to the /// exception, if any, and the function will return false (0). /// </summary> public unsafe virtual bool Eval(string code, string scriptUrl, int startLine, ref CefV8Value retval, ref CefV8Exception exception) { fixed(char *s0 = code) fixed(char *s1 = scriptUrl) { var cstr0 = new cef_string_t { Str = s0, Length = code != null ? code.Length : 0 }; var cstr1 = new cef_string_t { Str = s1, Length = scriptUrl != null ? scriptUrl.Length : 0 }; cef_v8value_t * p3 = (retval != null) ? retval.GetNativeInstance() : null; cef_v8value_t ** pp3 = &p3; cef_v8exception_t * p4 = (exception != null) ? exception.GetNativeInstance() : null; cef_v8exception_t **pp4 = &p4; var rv = NativeInstance->Eval(&cstr0, &cstr1, startLine, pp3, pp4) != 0; retval = CefV8Value.Wrap(CefV8Value.Create, p3); exception = CefV8Exception.Wrap(CefV8Exception.Create, p4); GC.KeepAlive(this); return(rv); } }
public static int eval(cef_v8context_t *self, cef_string_t *code, cef_string_t *script_url, int start_line, cef_v8value_t **retval, cef_v8exception_t **exception) { eval_delegate d; var p = self->_eval; if (p == _pc) { d = _dc; } else { d = (eval_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(eval_delegate)); if (_pc == IntPtr.Zero) { _dc = d; _pc = p; } } return(d(self, code, script_url, start_line, retval, exception)); }
public unsafe extern int Eval([Immutable] cef_string_t *code, [Immutable] cef_string_t *script_url, int start_line, cef_v8value_t **retval, cef_v8exception_t **exception);
/// <summary> /// Evaluates the specified JavaScript code using this context's global object. /// On success |retval| will be set to the return value, if any, and the /// function will return true. On failure |exception| will be set to the /// exception, if any, and the function will return false. /// </summary> public int Eval(cef_string_t *code, cef_v8value_t **retval, cef_v8exception_t **exception) { throw new NotImplementedException(); // TODO: CefV8Context.Eval }
public unsafe int Eval([Immutable] cef_string_t *code, [Immutable] cef_string_t *script_url, int start_line, cef_v8value_t **retval, cef_v8exception_t **exception) { fixed(cef_v8context_t *self = &this) { return(((delegate * unmanaged[Stdcall] < cef_v8context_t *, cef_string_t *, cef_string_t *, int, cef_v8value_t **, cef_v8exception_t **, int >)eval)(self, code, script_url, start_line, retval, exception)); } }