Exemple #1
0
static int init_cc(parser_ctx_t *ctx)
{
    cc_ctx_t *cc;
    cc_var_t v;

    static const WCHAR _win32W[] = {'_','w','i','n','3','2',0};
    static const WCHAR _win64W[] = {'_','w','i','n','6','4',0};
    static const WCHAR _x86W[] = {'_','x','8','6',0};
    static const WCHAR _amd64W[] = {'_','a','m','d','6','4',0};
    static const WCHAR _jscriptW[] = {'_','j','s','c','r','i','p','t',0};
    static const WCHAR _jscript_buildW[] = {'_','j','s','c','r','i','p','t','_','b','u','i','l','d',0};
    static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0};

    if(ctx->script->cc)
        return 0;

    cc = heap_alloc(sizeof(cc_ctx_t));
    if(!cc)
        return lex_error(ctx, E_OUTOFMEMORY);

    cc->vars = NULL;
    v.is_num = FALSE;
    v.u.b = VARIANT_TRUE;
    if(!add_cc_var(cc, _jscriptW, &v)
       || !add_cc_var(cc, sizeof(void*) == 8 ? _win64W : _win32W, &v)
       || !add_cc_var(cc, sizeof(void*) == 8 ? _amd64W : _x86W, &v)) {
        release_cc(cc);
        return lex_error(ctx, E_OUTOFMEMORY);
    }

    v.is_num = TRUE;
    v.u.n = JSCRIPT_BUILD_VERSION;
    if(!add_cc_var(cc, _jscript_buildW, &v)) {
        release_cc(cc);
        return lex_error(ctx, E_OUTOFMEMORY);
    }

    v.u.n = JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0;
    if(!add_cc_var(cc, _jscript_versionW, &v)) {
        release_cc(cc);
        return lex_error(ctx, E_OUTOFMEMORY);
    }

    ctx->script->cc = cc;
    return 0;
}
Exemple #2
0
void script_release(script_ctx_t *ctx)
{
    if(--ctx->ref)
        return;

    if(ctx->cc)
        release_cc(ctx->cc);
    jsheap_free(&ctx->tmp_heap);
    SysFreeString(ctx->last_match);
    heap_free(ctx);
}
Exemple #3
0
void script_release(script_ctx_t *ctx)
{
    if(--ctx->ref)
        return;

    clear_ei(ctx);
    if(ctx->cc)
        release_cc(ctx->cc);
    heap_pool_free(&ctx->tmp_heap);
    if(ctx->last_match)
        jsstr_release(ctx->last_match);

    ctx->jscaller->ctx = NULL;
    IServiceProvider_Release(&ctx->jscaller->IServiceProvider_iface);

    heap_free(ctx);
}
Exemple #4
0
static BOOL init_cc(parser_ctx_t *ctx)
{
    cc_ctx_t *cc;

    static const WCHAR _win32W[] = {'_','w','i','n','3','2',0};
    static const WCHAR _win64W[] = {'_','w','i','n','6','4',0};
    static const WCHAR _x86W[] = {'_','x','8','6',0};
    static const WCHAR _amd64W[] = {'_','a','m','d','6','4',0};
    static const WCHAR _jscriptW[] = {'_','j','s','c','r','i','p','t',0};
    static const WCHAR _jscript_buildW[] = {'_','j','s','c','r','i','p','t','_','b','u','i','l','d',0};
    static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0};

    if(ctx->script->cc)
        return TRUE;

    cc = heap_alloc(sizeof(cc_ctx_t));
    if(!cc) {
        lex_error(ctx, E_OUTOFMEMORY);
        return FALSE;
    }

    cc->vars = NULL;

    if(!new_cc_var(cc, _jscriptW, -1, ccval_bool(TRUE))
       || !new_cc_var(cc, sizeof(void*) == 8 ? _win64W : _win32W, -1, ccval_bool(TRUE))
       || !new_cc_var(cc, sizeof(void*) == 8 ? _amd64W : _x86W, -1, ccval_bool(TRUE))
       || !new_cc_var(cc, _jscript_versionW, -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0))
       || !new_cc_var(cc, _jscript_buildW, -1, ccval_num(JSCRIPT_BUILD_VERSION))) {
        release_cc(cc);
        lex_error(ctx, E_OUTOFMEMORY);
        return FALSE;
    }

    ctx->script->cc = cc;
    return TRUE;
}