Beispiel #1
0
void
CRB_set_command_line_args(CRB_Interpreter *interpreter,
                          int argc, char **argv)
{
    int i;
    CRB_Char *wc_str;
    CRB_Value args;
    CRB_Value elem;

    args.type = CRB_ARRAY_VALUE;
    args.u.object = crb_create_array_i(interpreter, argc);
    CRB_push_value(interpreter, &args);

    for (i = 0; i < argc; i++) {
        wc_str = CRB_mbstowcs_alloc(interpreter, NULL, 0, argv[i]);
        if (wc_str == NULL) {
            fprintf(stderr, "bad command line argument(%dth)", i);
            return;
        }
        elem.type = CRB_STRING_VALUE;
        elem.u.object = crb_create_crowbar_string_i(interpreter, wc_str);
        CRB_array_set(interpreter, NULL, args.u.object, i, &elem);
    }
    CRB_add_global_variable(interpreter, "ARGS", &args, CRB_TRUE);

    CRB_pop_value(interpreter);
}
Beispiel #2
0
CRB_Object *
CRB_create_crowbar_string(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
                          char *str)
{
    CRB_Object *ret;

    ret = crb_create_crowbar_string_i(inter, str);
    add_ref_in_native_method(env, ret);

    return ret;
}
Beispiel #3
0
void
chain_string(SIMCAR_Interpreter *inter, SIMCAR_Value *left, SIMCAR_Value *right,
             SIMCAR_Value *result)
{
    char        *right_str;
    SIMCAR_Object *right_obj;
    int         len;
    char        *str;

    right_str = SIMCAR_value_to_string(right);
    right_obj = crb_create_crowbar_string_i(inter, right_str);

    result->type = SIMCAR_STRING_VALUE;
    len = strlen(left->u.object->u.string.string)
        + strlen(right_obj->u.string.string);
    str = MEM_malloc(len + 1);
    strcpy(str, left->u.object->u.string.string);
    strcat(str, right_obj->u.string.string);
    result->u.object = crb_create_crowbar_string_i(inter, str);
}