Пример #1
0
void KEventObject::_AddEventListener(const ValueList& args, KValueRef result)
{
    std::string event;
    KMethodRef callback;

    if (args.size() > 1 && args.at(0)->IsString() && args.at(1)->IsMethod())
    {
        event = args.GetString(0);
        callback = args.GetMethod(1);
    }
    else if (args.size() > 0 && args.at(0)->IsMethod())
    {
        event = Event::ALL;
        callback = args.GetMethod(0);
    }
    else
    {
        throw ValueException::FromString("Incorrect arguments passed to addEventListener");
    }

    this->AddEventListener(event, callback);
    result->SetMethod(callback);
}
Пример #2
0
 void APIBinding::_CreateKMethod(const ValueList& args, KValueRef result)
 {
     args.VerifyException("createKMethod", "m");
     KMethodRef wrapped = args.GetMethod(0);
     result->SetMethod(new KMethodWrapper(args.GetMethod(0)));
 }