pub(crate) fn new() -> io::Result<Context> {
        let latest_evaluate_context = Box::into_raw(Box::new(vec![]));

        let ctx = unsafe {
            duktape::duk_create_heap(
                None,
                None,
                None,
                latest_evaluate_context as *mut c_void,
                None,
            )
        };

        unsafe {
            duktape::duk_push_global_object(ctx);
            duktape::duk_push_c_function(ctx, Some(jsaas_btoa), 1);
            duktape::duk_put_prop_string(ctx, -2, GLOBAL_FN_BTOA as *const std::os::raw::c_char);
            duktape::duk_push_c_function(ctx, Some(jsaas_atob), 1);
            duktape::duk_put_prop_string(ctx, -2, GLOBAL_FN_ATOB as *const std::os::raw::c_char);
            duktape::duk_pop(ctx);
        }

        if ctx.is_null() {
            Err(io::Error::new(
                io::ErrorKind::Other,
                "error initializing Duktape heap",
            ))
        } else {
            Ok(Context {
                ctx,
                latest_evaluate_context,
            })
        }
    }
/// Creates a new `Context` that can be used to evaluate JavaScript functions.
Creates a new `Context` that can be used to evaluate JavaScript functions.
Creates a new ` Context ` that can be used to evaluate JavaScript functions .
pub(crate) fn new() -> io::Result<Context> {
        let latest_evaluate_context = Box::into_raw(Box::new(vec![]));
        let ctx = unsafe {
            duktape::duk_create_heap(
                None,
                None,
                None,
                latest_evaluate_context as *mut c_void,
                None,
            )
        };
        unsafe {
            duktape::duk_push_global_object(ctx);
            duktape::duk_push_c_function(ctx, Some(jsaas_btoa), 1);
            duktape::duk_put_prop_string(ctx, -2, GLOBAL_FN_BTOA as *const std::os::raw::c_char);
            duktape::duk_push_c_function(ctx, Some(jsaas_atob), 1);
            duktape::duk_put_prop_string(ctx, -2, GLOBAL_FN_ATOB as *const std::os::raw::c_char);
            duktape::duk_pop(ctx);
        }
        if ctx.is_null() {
            Err(io::Error::new(
                io::ErrorKind::Other,
                "error initializing Duktape heap",
            ))
        } else {
            Ok(Context {
                ctx,
                latest_evaluate_context,
            })
        }
    }
pub ( crate ) fn new ( ) -> io :: Result < Context > { let latest_evaluate_context = Box :: into_raw ( Box :: new ( vec ! [ ] ) ) ; let ctx = unsafe { duktape :: duk_create_heap ( None , None , None , latest_evaluate_context as * mut c_void , None , ) } ; unsafe { duktape :: duk_push_global_object ( ctx ) ; duktape :: duk_push_c_function ( ctx , Some ( jsaas_btoa ) , 1 ) ; duktape :: duk_put_prop_string ( ctx , - 2 , GLOBAL_FN_BTOA as * const std :: os :: raw :: c_char ) ; duktape :: duk_push_c_function ( ctx , Some ( jsaas_atob ) , 1 ) ; duktape :: duk_put_prop_string ( ctx , - 2 , GLOBAL_FN_ATOB as * const std :: os :: raw :: c_char ) ; duktape :: duk_pop ( ctx ) ; } if ctx . is_null ( ) { Err ( io :: Error :: new ( io :: ErrorKind :: Other , " " , ) ) } else { Ok ( Context { ctx , latest_evaluate_context , } ) } }
Creates a new `Context` that can be used to evaluate JavaScript functions.
Creates a new ` Context ` that can be used to evaluate JavaScript functions .