コード例 #1
0
ファイル: muse_builtin_json.c プロジェクト: jbulow/mse
/**
 * If the object has only constant values, it pre-evalutes the object.
 * so that the expression doesn't need to be evaluated repeatedly.
 */
static muse_cell json_share_object_expr( muse_env *env, muse_cell objexpr )
{
	muse_cell listitems = _tail(_head(_tail(objexpr)));

	while ( listitems ) {
		if ( !json_is_constant( env, _next(&listitems) ) )
			return objexpr;
	}

	return muse_eval( env, objexpr, MUSE_FALSE );
}
コード例 #2
0
ファイル: ListBox.C プロジェクト: Stabledog/dddbash
// Mark list
Box *ListBox::tag(Data *d, DataLink *dl)
{
    if (!isEmpty())
    {
	// In a list: mark all children
	_head() = _head()->tag(d, dl);
	_tail() = _tail()->tag(d, dl);
    }

    // The list itself is never marked, since it is not drawn
    return this;
}
コード例 #3
0
ファイル: muse_builtin_json.c プロジェクト: jbulow/mse
/**
 * Returns arr if sub-expresions are not constant.
 * Otherwise creates a constant vector.
 */
static muse_cell json_share_array_expr( muse_env *env, muse_cell arr )
{
	muse_cell items = _tail(arr);

	while ( items ) {
		if ( !json_is_constant( env, _head(items) ) )
			return arr;

		items = _tail(items);
	}

	return muse_eval( env, arr, MUSE_FALSE );
}
コード例 #4
0
ファイル: muse_builtin_json.c プロジェクト: jbulow/mse
static void json_write_object( muse_port_t p, muse_cell obj )
{
	muse_env *env = p->env;
	muse_cell plist = object_plist( env, obj );
	port_putc( '{', p );
	while ( plist ) {
		muse_cell ht = _next(&plist);
		json_write_string(p, _symname(_head(ht)));
		port_putc(':',p);
		json_write(p,_tail(ht));
		if ( plist )
			port_putc( ',', p );
	}
	port_putc( '}', p );
}
コード例 #5
0
ファイル: muse_builtin_json.c プロジェクト: jbulow/mse
static void json_write_hash( muse_port_t p, muse_cell obj )
{
	muse_env *env = p->env;
	int sp = _spos();
	muse_cell alist = fn_hashtable_to_alist( env, NULL, _cons(obj,MUSE_NIL) );
	_unwind(sp);
	port_putc( '{', p );
	while ( alist ) {
		muse_cell ht = _next(&alist);
		json_write_string(p, _symname(_head(ht)));
		port_putc(':',p);
		json_write(p,_tail(ht));
		if ( alist )
			port_putc( ',', p );
	}
	port_putc( '}', p );
}