Beispiel #1
0
int Term::intProp(Symbol key, int defaultValue)
{
    Value* value = term_get_property(this, key);
    if (value == NULL)
        return defaultValue;
    else
        return as_int(value);
}
Beispiel #2
0
std::string Term::stringProp(Symbol key, const char* defaultValue)
{
    Value* value = term_get_property(this, key);
    if (value == NULL)
        return defaultValue;
    else
        return as_string(value);
}
Beispiel #3
0
void term_move_property(Term* from, Term* to, const char* propName)
{
    if (!from->hasProperty(propName))
        return;

    term_set_property(to, propName, term_get_property(from, propName));
    term_remove_property(from, propName);
}
Beispiel #4
0
bool Term::boolProp(Symbol key, bool defaultValue)
{
    Value* value = term_get_property(this, key);
    if (value == NULL)
        return defaultValue;
    else
        return as_bool(value);
}
Beispiel #5
0
std::string Term::stringPropOptional(std::string const& name, std::string const& defaultValue)
{
    caValue* value = term_get_property(this, name.c_str());
    if (value == NULL)
        return defaultValue;
    else
        return as_string(value);
}
Beispiel #6
0
void term_move_property(Term* from, Term* to, Symbol key)
{
    Value* existing = term_get_property(from, key);
    if (existing == NULL)
        return;

    term_set_property(to, key, existing);
    term_remove_property(from, key);
}
Beispiel #7
0
void Term__has_property(VM* vm)
{
    Term* t = as_term_ref(vm->input(0));
    if (t == NULL)
        return vm->throw_str("NULL reference");
    Symbol key = as_symbol(vm->input(1));
    Value* value = term_get_property(t, key);
    set_bool(vm->output(), value != NULL);
}
Beispiel #8
0
void Term__property(VM* vm)
{
    Term* t = as_term_ref(vm->input(0));
    if (t == NULL)
        return vm->throw_str("NULL reference");

    Symbol key = as_symbol(vm->input(1));
    Value* value = term_get_property(t, key);

    if (value == NULL)
        set_null(vm->output());
    else
        circa::copy(value, vm->output());
}
Beispiel #9
0
void Term__property_opt(VM* vm)
{
    Term* t = as_term_ref(vm->input(0));
    if (t == NULL)
        return vm->throw_str("NULL reference");

    Symbol key = as_symbol(vm->input(1));
    Value* value = term_get_property(t, key);
    Value* defaultValue = vm->input(2);

    if (value == NULL)
        copy(defaultValue, vm->output());
    else
        copy(value, vm->output());
}
void Term__property(caStack* stack)
{
    Term* t = as_term_ref(circa_input(stack, 0));
    if (t == NULL)
        return circa_output_error(stack, "NULL reference");

    const char* key = circa_string_input(stack, 1);

    caValue* value = term_get_property(t, key);

    if (value == NULL)
        set_null(circa_output(stack, 0));
    else
        circa::copy(value, circa_output(stack, 0));
}
Beispiel #11
0
Value* Term::getProp(Symbol key)
{
    return term_get_property(this, key);
}
Beispiel #12
0
bool Term::hasProperty(Symbol key)
{
    return term_get_property(this, key) != NULL;
}