コード例 #1
0
ファイル: e_module.c プロジェクト: olofson/eel
static void load_buffer(EEL_vm *vm, EEL_module *m,
		const char *source, unsigned len)
{
	EEL_state *es = VMP->state;
	char buf[256];
	const char *sn;

	/* Construct name */
	snprintf(buf, sizeof(buf) - 1, "memory script, %u bytes from %p",
			len, source);
	buf[sizeof(buf) - 1] = '\0';

	eel_table_setss(m->exports, "__filename", buf);
	eel_table_setss(m->exports, "__modname", buf);

	sn = eel_table_getss(m->exports, "__filename");
	if(!sn)
		eel_cerror(es, "Script name went missing in action!");

	m->len = len;
	m->source = (unsigned char *)malloc(m->len + 1);
	if(!m->source)
		eel_serror(es, "Could not allocate space for source!");

	memcpy(m->source, source, len);
	m->source[len] = 0;
	DBG1(printf("Loaded module \"%s\" (ID: %d)\n", sn, m->id);)
}
コード例 #2
0
ファイル: ec_symtab.c プロジェクト: coppolaemilio/eel
void eel_s_rename(EEL_state *es, EEL_symbol *s, const char *name)
{
	if(s->name)
		eel_o_disown_nz(s->name);
	s->name = eel_ps_new(es->vm, name);
	if(!s->name)
		eel_serror(es, "Could not rename symbol!"
				" (Failed to create new EEL_string.)");
}
コード例 #3
0
ファイル: ec_symtab.c プロジェクト: coppolaemilio/eel
EEL_symbol *eel_s_add(EEL_state *es, EEL_symbol *parent,
		const char *name, EEL_symtypes type)
{
	EEL_symbol *sym = (EEL_symbol *)eel_malloc(es->vm, sizeof(EEL_symbol));
	if(!sym)
		eel_serror(es, "Out of memory when adding symbol!");
	memset(sym, 0, sizeof(EEL_symbol));
	sym->parent = parent;
	if(name)
	{
		sym->name = eel_ps_new(es->vm, name);
		if(!name)
			eel_serror(es, "Could not create symbol name!");
	}
	sym->type = type;
	if(parent)
	{
		eel_s_link(parent, sym);
		sym->uvlevel = parent->uvlevel;
	}
	if(EEL_SFUNCTION == type)
		++sym->uvlevel;
	return sym;
}
コード例 #4
0
ファイル: ec_symtab.c プロジェクト: coppolaemilio/eel
EEL_symbol *eel_s_find(EEL_state *es, EEL_symbol *table,
		const char *name, EEL_symtypes type)
{
	EEL_symbol *sym = table->symbols;
	EEL_object *no = eel_ps_new(es->vm, name);
	if(!no)
		eel_serror(es, "Could not get name object!");
	while(sym)
	{
		if((sym->type == type) && (sym->name == no))
			break;
		sym = sym->next;
	}
	eel_o_disown_nz(no);
	return sym;
}