void FuncEmitter::setBuiltinFunc(const ClassInfo::MethodInfo* info, BuiltinFunction bif, BuiltinFunction nif, Offset base_) { assert(info); m_info = info; Attr attrs_ = AttrBuiltin; if (info->attribute & (ClassInfo::RefVariableArguments | ClassInfo::MixedVariableArguments)) { attrs_ |= AttrVariadicByRef; } if (info->attribute & ClassInfo::IsReference) { attrs_ |= AttrReference; } if (info->attribute & ClassInfo::NoInjection) { attrs_ |= AttrNoInjection; } if (info->attribute & ClassInfo::NoFCallBuiltin) { attrs_ |= AttrNoFCallBuiltin; } if (info->attribute & ClassInfo::ParamCoerceModeNull) { attrs_ |= AttrParamCoerceModeNull; } else if (info->attribute & ClassInfo::ParamCoerceModeFalse) { attrs_ |= AttrParamCoerceModeFalse; } if (pce()) { if (info->attribute & ClassInfo::IsStatic) { attrs_ |= AttrStatic; } if (info->attribute & ClassInfo::IsFinal) { attrs_ |= AttrFinal; } if (info->attribute & ClassInfo::IsAbstract) { attrs_ |= AttrAbstract; } if (info->attribute & ClassInfo::IsPrivate) { attrs_ |= AttrPrivate; } else if (info->attribute & ClassInfo::IsProtected) { attrs_ |= AttrProtected; } else { attrs_ |= AttrPublic; } } else if (info->attribute & ClassInfo::AllowOverride) { attrs_ |= AttrAllowOverride; } returnType = info->returnType; docComment = makeStaticString(info->docComment); setLocation(0, 0); setBuiltinFunc(bif, nif, attrs_, base_); for (unsigned i = 0; i < info->parameters.size(); ++i) { // For builtin only, we use a dummy ParamInfo FuncEmitter::ParamInfo pi; const auto& parameter = info->parameters[i]; pi.byRef = parameter->attribute & ClassInfo::IsReference; pi.builtinType = parameter->argType; appendParam(makeStaticString(parameter->name), pi); } }
void FuncEmitter::setBuiltinFunc(const ClassInfo::MethodInfo* info, BuiltinFunction bif, BuiltinFunction nif, Offset base) { assert(info); assert(bif); m_info = info; m_builtinFuncPtr = bif; m_nativeFuncPtr = nif; m_base = base; m_top = true; m_docComment = StringData::GetStaticString(info->docComment); m_line1 = 0; m_line2 = 0; m_attrs = AttrBuiltin | AttrSkipFrame; // TODO: Task #1137917: See if we can avoid marking most builtins with // "MayUseVV" and still make things work m_attrs = m_attrs | AttrMayUseVV; if (info->attribute & (ClassInfo::RefVariableArguments | ClassInfo::MixedVariableArguments)) { m_attrs = m_attrs | AttrVariadicByRef; } if (info->attribute & ClassInfo::IsReference) { m_attrs = m_attrs | AttrReference; } if (info->attribute & ClassInfo::NoInjection) { m_attrs = m_attrs | AttrNoInjection; } if (pce()) { if (info->attribute & ClassInfo::IsStatic) { m_attrs = m_attrs | AttrStatic; } if (info->attribute & ClassInfo::IsFinal) { m_attrs = m_attrs | AttrFinal; } if (info->attribute & ClassInfo::IsAbstract) { m_attrs = m_attrs | AttrAbstract; } if (info->attribute & ClassInfo::IsPrivate) { m_attrs = m_attrs | AttrPrivate; } else if (info->attribute & ClassInfo::IsProtected) { m_attrs = m_attrs | AttrProtected; } else { m_attrs = m_attrs | AttrPublic; } } else if (info->attribute & ClassInfo::AllowOverride) { m_attrs = m_attrs | AttrAllowOverride; } m_returnType = info->returnType; for (unsigned i = 0; i < info->parameters.size(); ++i) { // For builtin only, we use a dummy ParamInfo FuncEmitter::ParamInfo pi; pi.setRef((bool)(info->parameters[i]->attribute & ClassInfo::IsReference)); pi.setBuiltinType(info->parameters[i]->argType); appendParam(StringData::GetStaticString(info->parameters[i]->name), pi); } }
void FuncEmitter::init(int line1, int line2, Offset base, Attr attrs, bool top, const StringData* docComment) { m_line1 = line1; m_line2 = line2; m_base = base; m_attrs = attrs; m_top = top; m_docComment = docComment; if (!SystemLib::s_inited) { m_attrs = m_attrs | AttrBuiltin; if (!pce()) m_attrs = m_attrs | AttrSkipFrame; } }
void FuncEmitter::setBuiltinFunc(const ClassInfo::MethodInfo* info, BuiltinFunction funcPtr, Offset base) { ASSERT(info); ASSERT(funcPtr); m_info = info; m_builtinFuncPtr = funcPtr; m_base = base; m_top = true; m_docComment = StringData::GetStaticString(info->docComment); m_line1 = 0; m_line2 = 0; m_attrs = AttrNone; // TODO: Task #1137917: See if we can avoid marking most builtins with // "MayUseVV" and still make things work m_attrs = (Attr)(m_attrs | AttrMayUseVV); if (info->attribute & (ClassInfo::RefVariableArguments | ClassInfo::MixedVariableArguments)) { m_attrs = Attr(m_attrs | AttrVariadicByRef); } if (info->attribute & ClassInfo::IsReference) { m_attrs = (Attr)(m_attrs | AttrReference); } if (info->attribute & ClassInfo::NoInjection) { m_attrs = (Attr)(m_attrs | AttrNoInjection); } if (pce()) { if (info->attribute & ClassInfo::IsStatic) { m_attrs = (Attr)(m_attrs | AttrStatic); } if (info->attribute & ClassInfo::IsFinal) { m_attrs = (Attr)(m_attrs | AttrFinal); } if (info->attribute & ClassInfo::IsAbstract) { m_attrs = (Attr)(m_attrs | AttrAbstract); } if (info->attribute & ClassInfo::IsPrivate) { m_attrs = (Attr)(m_attrs | AttrPrivate); } else if (info->attribute & ClassInfo::IsProtected) { m_attrs = (Attr)(m_attrs | AttrProtected); } else { m_attrs = (Attr)(m_attrs | AttrPublic); } } for (unsigned i = 0; i < info->parameters.size(); ++i) { // For builtin only, we use a dummy ParamInfo FuncEmitter::ParamInfo pi; pi.setRef((bool)(info->parameters[i]->attribute & ClassInfo::IsReference)); appendParam(StringData::GetStaticString(info->parameters[i]->name), pi); } }
void FuncEmitter::init(int l1, int l2, Offset base_, Attr attrs_, bool top_, const StringData* docComment_) { base = base_; line1 = l1; line2 = l2; top = top_; attrs = attrs_; docComment = docComment_; if (!isPseudoMain()) { if (!SystemLib::s_inited) { assertx(attrs & AttrBuiltin); } if ((attrs & AttrBuiltin) && !pce()) { attrs |= AttrSkipFrame; } } }
void ComThread::sendNotify(struct anoubis_msg *notifyMsg) { int type; Notification *notify; NotificationCtrl *notifyCtrl; type = get_value((notifyMsg->u.general)->type); notify = NULL; /* * NOTE: We must not allocate the NotificationCtrl from the * NOTE: ComThread. It must be created in the main Thread. * NOTE: This is particularly imporant in tests where the * NOTE: event handlers of the NotificationCtrl do not work. */ notifyCtrl = NotificationCtrl::existingInstance(); if (type == ANOUBIS_N_POLICYCHANGE) { wxCommandEvent pce(anEVT_POLICY_CHANGE); pce.SetInt(get_value(notifyMsg->u.policychange->prio)); pce.SetExtraLong(get_value(notifyMsg->u.policychange->uid)); if (dynamic_cast<AnoubisGuiApp*>(wxTheApp)) { wxPostEvent(AnEvents::instance(), pce); } } else if (type == ANOUBIS_N_PGCHANGE) { wxCommandEvent pgchange(anEVT_PG_CHANGE); unsigned int pgop = get_value(notifyMsg->u.pgchange->pgop); uint64_t pgid = get_value(notifyMsg->u.pgchange->pgid); const char *cmd = notifyMsg->u.pgchange->cmd; /* XXX CEH: Should be a long long... */ pgchange.SetString(wxString::Format(wxT("%hs"), cmd)); pgchange.SetExtraLong(pgid); if (pgop == ANOUBIS_PGCHANGE_TERMINATE) { pgchange.SetInt(0); /* Terminated := not running */ Debug::info(_("Playground %llx (%hs) terminated"), pgid, cmd); } else if (pgop == ANOUBIS_PGCHANGE_CREATE) { pgchange.SetInt(1); /* Running */ Debug::info(_("Playground %llx (%hs) created"), pgid, cmd); } if (dynamic_cast<AnoubisGuiApp *>(wxTheApp)) wxPostEvent(AnEvents::instance(), pgchange); } else if (type == ANOUBIS_N_STATUSNOTIFY) { unsigned int key, value; if (!VERIFY_FIELD(notifyMsg, statusnotify, statuskey) || !VERIFY_FIELD(notifyMsg, statusnotify, statusvalue)) { anoubis_msg_free(notifyMsg); Debug::err(_("Dropping short message from Daemon")); return; } key = get_value(notifyMsg->u.statusnotify->statuskey); value = get_value(notifyMsg->u.statusnotify->statusvalue); switch(key) { case ANOUBIS_STATUS_UPGRADE: { if (dynamic_cast<AnoubisGuiApp*>(wxTheApp)) { wxCommandEvent upg(anEVT_UPGRADENOTIFY); wxPostEvent(AnEvents::instance(), upg); } break; } default: Debug::info(_("Unkown status message key=%x value=%d"), key, value); } } else { /* * Ignore any notifies if we don't have a * NotificationCtrl. This can happen in unit tests. */ if (notifyCtrl) { notify = Notification::factory(notifyMsg); if (notify != NULL) { notifyCtrl->addNotification(notify); notifyMsg = NULL; } } } if (notifyMsg) anoubis_msg_free(notifyMsg); }