void	as_listener::broadcast(const fn_call& fn)
	{
		assert(fn.env);

		if (m_reentrance)
		{
			// keep call args
			// we must process one event completely then another
			array<as_value> arg;
			for (int i = 0; i < fn.nargs; i++)
			{
				arg.push_back(fn.arg(i));
			}
			m_suspended_event.push(arg);
			return;
		}
		m_reentrance = true;

		// event handler may affects 'fn.arg' using broadcastMessage
		// so we iterate through the copy of args
		tu_string event_name = fn.arg(0).to_tu_string();
		for (int j = fn.nargs - 1; j > 0; j--)
		{
			fn.env->push(fn.arg(j));
		}
			
		m_listeners.notify(event_name, 
			fn_call(NULL, 0, fn.env, fn.nargs - 1, fn.env->get_top_index()));

		fn.env->drop(fn.nargs - 1);

		// check reentrances
		while (m_suspended_event.size() > 0)
		{
			// event handler may affects m_suspended_event using broadcastMessage
			// so we iterate through the copy of args
			array<as_value>& arg = m_suspended_event.front();
			tu_string event_name = arg[0].to_tu_string();
			for (int j = arg.size() - 1; j > 0; j--)
			{
				fn.env->push(arg[j]);
			}
				
			m_listeners.notify(event_name, 
				fn_call(NULL, 0, fn.env, arg.size() - 1, fn.env->get_top_index()));

			fn.env->drop(fn.nargs - 1);
			m_suspended_event.pop();
		}

		m_reentrance = false;
	}
	// call static method
	void as_property::get(const as_value& primitive, as_value* val) const
	{
		if (m_getter != NULL)
		{
			(*m_getter.get_ptr())(fn_call(val, primitive, NULL, 0,	0));
		}
	}
Exemple #3
0
static void
generic_callback(GtkWidget * /*widget*/, gpointer data)
{
//    GNASH_REPORT_FUNCTION;
//    g_print ("Hello World - %d\n", *(int *)data;
    const char *event = (const char *)data;

    as_value handler = callbacks[event];
    as_function *as_func = handler.to_function();

//	start the debugger when this callback is activated.
// 	debugger.enabled(true);
// 	debugger.console();

    // FIXME: Delete events don't seem to pass in data in a form we
    // can access it. So for now we just hack in a quit, since we know
    // we're done, we hope...
    if (*event == 0) {
	gtk_main_quit();
	return;
    } else {
	cerr << "event is: \"" << event << "\"" << endl;
    }
    
    as_value val;
    as_environment env(getVM(*as_func));

    fn_call::Args args;
    args += handler, event, handler;

    as_object obj = val.to_object(*getGlobal(fn));

    // Call the AS function defined in the source file using this extension
    (*as_func)(fn_call(&obj, &env, args));
}
Exemple #4
0
void t()
{
    int i;
    int x;
    for( i = 0; i < 100000000; i++ ) {
        fn_call (i < 100000000);
    }
}
Exemple #5
0
	void as_property::get(as_object* target, as_value* val) const
	{
		assert(target);

		// env is used when m_getter->m_env is NULL
		as_environment env(target->get_player());
		if (m_getter != NULL)
		{
			smart_ptr<as_object> tar = target;
			(*m_getter.get_ptr())(fn_call(val, tar.get_ptr(), &env, 0,	0));
		}
	}
Exemple #6
0
	void	as_property::set(as_object* target, const as_value& val)
	{
		assert(target);

		as_environment env(target->get_player());
		env.push(val);
		if (m_setter != NULL)
		{
			smart_ptr<as_object> tar = target;
			(*m_setter.get_ptr())(fn_call(NULL, tar.get_ptr(),	&env, 1, env.get_top_index()));
		}
	}
Exemple #7
0
VOID fn_indirect_call(CONTEXT* ctxt, ADDRINT target) {
    trace_enter();

    // Indirect call, we have to look up the function each time
    // The functions `fn_lookup` & `fn_register` needs PIN's Lock.
    // Locking is not implicit in inserted call, as opposed
    // to callback added with *_AddInstrumentFunction().
    PIN_LockClient();
    FID fid = fn_lookup_by_address(target);
    PIN_UnlockClient();

    fn_call(ctxt, fid);

    trace_leave();
}
	void as_property::get(as_object* target, as_value* val) const
	{
		if (target == NULL)
		{
			val->set_undefined();
			return;
		}

		// env is used when m_getter->m_env is NULL
		as_environment env(target->get_player());
		if (m_getter != NULL)
		{
			gc_ptr<as_object> tar = target;
			(*m_getter.get_ptr())(fn_call(val, tar.get_ptr(), &env, 0,	0));
		}
	}
	void as_object::call_watcher(const tu_stringi& name, const as_value& old_val, as_value* new_val)
	{
		if (m_watch)
		{
			as_watch watch;
			m_watch->get(name, &watch);
			if (watch.m_func)
			{
				as_environment env(get_player());
				env.push(watch.m_user_data);	// params
				env.push(*new_val);		// newVal
				env.push(old_val);	// oldVal
				env.push(name);	// property
				new_val->set_undefined();
				(*watch.m_func)(fn_call(new_val, this, &env, 4, env.get_top_index()));
			}
		}
	}
Exemple #10
0
int main()
{
    int i = 1;
    fn_call((myunion*)&i);
    return 0;
}