void PropertiesDock::currentItemChanged(QtBrowserItem *item) { bool isCustomProperty = mPropertyBrowser->isCustomPropertyItem(item); bool external = isExternal(mPropertyBrowser->object()); mActionRemoveProperty->setEnabled(isCustomProperty && !external); mActionRenameProperty->setEnabled(isCustomProperty && !external); }
void UmlActivityPartition::write(FileOut & out) { const char * p = (parent()->kind() == aPartition) ? "subpartition" : "group"; out.indent(); out << "<" << p << " xmi:type=\"uml:ActivityPartition\" name=\""; out.quote((const char*)name());//[jasa] ambiguous call out << '"'; out.id(this); if (isDimension()) out << " isDimension=\"true\""; if (isExternal()) out << " isExternal=\"true\""; if (represents() != 0) out.ref(represents(), "represents"); out << ">\n"; out.indent(+1); write_description_properties(out); const Q3PtrVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->write(out); out.indent(-1); out.indent(); out << "</" << p << ">\n"; unload(); }
/* * Generate a class reference, including its owning module if necessary and * handling forward references if necessary. */ static void prClassRef(classDef *cd, moduleDef *mod, ifaceFileList *defined, int pep484, FILE *fp) { if (pep484) { /* * We assume that an external class will be handled properly by some * handwritten type hint code. */ int is_defined = (isExternal(cd) || isDefined(cd->iff, cd->ecd, mod, defined)); if (!is_defined) fprintf(fp, "'"); if (cd->iff->module != mod) fprintf(fp, "%s.", cd->iff->module->name); prScopedPythonName(fp, cd->ecd, cd->pyname->text); if (!is_defined) fprintf(fp, "'"); } else { prScopedPythonName(fp, cd->ecd, cd->pyname->text); } }
/* * Generate the API file. */ void generateAPI(sipSpec *pt, moduleDef *mod, const char *apiFile) { overDef *od; classDef *cd; FILE *fp; /* Generate the file. */ if ((fp = fopen(apiFile, "w")) == NULL) fatal("Unable to create file \"%s\"\n", apiFile); apiEnums(pt, mod, NULL, fp); apiVars(pt, mod, NULL, fp); for (od = mod->overs; od != NULL; od = od->next) { if (od->common->module != mod) continue; if (od->common->slot != no_slot) continue; apiOverload(pt, mod, NULL, od, fp); } for (cd = pt->classes; cd != NULL; cd = cd->next) { ctorDef *ct; if (cd->iff->module != mod) continue; if (isExternal(cd)) continue; apiEnums(pt, mod, cd, fp); apiVars(pt, mod, cd, fp); for (ct = cd->ctors; ct != NULL; ct = ct->next) { if (isPrivateCtor(ct)) continue; apiCtor(pt, mod, cd, ct, fp); } for (od = cd->overs; od != NULL; od = od->next) { if (isPrivate(od)) continue; if (od->common->slot != no_slot) continue; apiOverload(pt, mod, cd, od, fp); } } fclose(fp); }
font_t* Font::getExternal(RPG2kString::const_iterator& it) { if( isExternal(it++) ) { if( std::islower(*it) ) return EXTERNAL_LW[*(it++) - 'a']; else if( std::isupper(*it) ) return EXTERNAL_UP[*(it++) - 'A']; } throw std::runtime_error("unknown char"); }
strvec MtxLP::getExternals()const{ strvec rv; strvec rows = getRowNames(); for (strvec::iterator it = rows.begin(); it != rows.end(); ++it) if (isExternal(*it)) rv.push_back(*it); return rv; }
void PropertiesDock::currentObjectChanged(Object *object) { mPropertyBrowser->setObject(object); const bool enabled = object != 0 && !isExternal(object); mPropertyBrowser->setEnabled(enabled); mActionAddProperty->setEnabled(enabled); }
void Link::ExecutePageLink () { auto link = std::dynamic_pointer_cast<Poppler::LinkGoto> (Link_); const QString& filename = link->isExternal () ? link->fileName () : QString (); const auto& dest = link->destination (); Doc_->RequestNavigation (filename, dest.pageNumber () - 1, dest.left (), dest.top ()); }
void UmlActivityPartition::html(Q3CString pfix, unsigned int rank, unsigned int level) { define(); chapter("Activity partition", pfix, rank, "activitypartition", level); Q3CString s = description(); if (!s.isEmpty()) { fw.write("<p>"); writeq(s); fw.write("<br /></p>"); } if (isDimension()) fw.write((isExternal()) ? "<p>is dimension, is external</p>\n" : "<p>is dimension</p>\n"); else if (isExternal()) fw.write("<p>is external</p>\n"); if (represents() != 0) { fw.write("<p>represents "); represents()->write(); fw.write("</p>"); } write_dependencies(); UmlDiagram * d = associatedDiagram(); if (d != 0) { fw.write("<p>Diagram : "); d->write(); fw.write("</p>\n"); } write_properties(); write_children(pfix, rank, level); unload(FALSE, FALSE); }
CharType Font::check(RPG2kString::const_iterator const& it) { int first = *it & 0xff; if( isExternal(it) || rpg2k::within(0x81, first, 0xa0) || rpg2k::within(0xe0, first, 0xf0) ) return FULL; else if( rpg2k::within(0x00, first, 0x80) || rpg2k::within(0xa1, first, 0xe0) ) return HALF; else throw std::runtime_error("unknown char"); }
// This write a function of object Chip void Func::writeCFiles(string path) const { if (isExternal()) { // Do nothing } else { ostringstream out; // Header out << "/** Auto generated C++ code started by "<<__FILE__<<":"<<__LINE__<< " */" << endl; out << endl; out << "#include \"Types.h\"" << endl; out << "#include \"Chip.h\"" << endl; if (m_isInternalMachineFunc) { out << "#include \"" << m_machineStr << "_Controller.h\"" << endl; } out << endl; // Generate function header string code; Type* void_type_ptr = g_sym_table.getType("void"); string return_type = m_type_ptr->cIdent(); code += return_type; if (existPair("return_by_ref") && m_type_ptr != void_type_ptr) { code += "&"; } if (!m_isInternalMachineFunc) { code += " Chip::" + cIdent() + "("; } else { code += " " + m_machineStr + "_Controller::" + cIdent() + "("; } int size = m_param_type_vec.size(); for(int i=0; i<size; i++) { // Generate code if (i != 0) { code += ", "; } code += m_param_string_vec[i]; } code += ")"; // Function body code += "\n{\n"; code += m_body; code += "}\n"; out << code << endl; // Write it out conditionally_write_file(path + cIdent() + ".C", out); } }
/* * Lookup a class. */ static classDef *lookupClass(sipSpec *pt, const char *name, classDef *scope_cd) { classDef *cd; for (cd = pt->classes; cd != NULL; cd = cd->next) if (strcmp(cd->pyname->text, name) == 0 && cd->ecd == scope_cd && !isExternal(cd)) { classDef *impl = getClassImplementation(pt, cd); if (impl != NULL) return impl; } return NULL; }
void MtxLP::setMixedObjective(stomap* sto){ emptyObjective(); for (stomap::iterator i = sto->begin(); i != sto->end(); ++i){ string name = i->first; if (nrow(name) != 0){ setRowObjCoef(name, i->second); //if the metabolite is internal, externalise it and add to the list of temp. externals. if (!isExternal(name)){ strvec buff (1, name); // Added by Andrzej Kierzek externalise(buff); // Added by Andrzej Kierzek tmp_externals.push_back(name); } } else updateObjCoef(i->first, i->second); } }
void BarnesHutTree::updateForceOnBody(const shared_ptr<Body>& body) { if (isExternal()) { body->addToAccelerationDueToOneBody(m_bodyInTree); } else if (m_Quadrant.sideLength() / body->twoDimensionalDistanceToOtherBody(m_bodyInTree) < 2) { body->addToAccelerationDueToOneBody(m_bodyInTree); } else { if (m_NW) m_NW->updateForceOnBody(body); if (m_NE) m_NE->updateForceOnBody(body); if (m_SW) m_SW->updateForceOnBody(body); if (m_SE) m_SE->updateForceOnBody(body); } };
//------------------------------------------------------------------------------------- NetworkInterface::NetworkInterface(Network::EventDispatcher * pDispatcher, int32 extlisteningPort_min, int32 extlisteningPort_max, const char * extlisteningInterface, uint32 extrbuffer, uint32 extwbuffer, int32 intlisteningPort, const char * intlisteningInterface, uint32 intrbuffer, uint32 intwbuffer): extEndpoint_(), intEndpoint_(), channelMap_(), pDispatcher_(pDispatcher), pExtensionData_(NULL), pExtListenerReceiver_(NULL), pIntListenerReceiver_(NULL), pDelayedChannels_(new DelayedChannels()), pChannelTimeOutHandler_(NULL), pChannelDeregisterHandler_(NULL), isExternal_(extlisteningPort_min != -1), numExtChannels_(0) { if(isExternal()) { pExtListenerReceiver_ = new ListenerReceiver(extEndpoint_, Channel::EXTERNAL, *this); this->recreateListeningSocket("EXTERNAL", htons(extlisteningPort_min), htons(extlisteningPort_max), extlisteningInterface, &extEndpoint_, pExtListenerReceiver_, extrbuffer, extwbuffer); // 如果配置了对外端口范围, 如果范围过小这里extEndpoint_可能没有端口可用了 if(extlisteningPort_min != -1) { KBE_ASSERT(extEndpoint_.good() && "Channel::EXTERNAL: no available port, " "please check for kbengine[_defs].xml!\n"); } } if(intlisteningPort != -1) { pIntListenerReceiver_ = new ListenerReceiver(intEndpoint_, Channel::INTERNAL, *this); this->recreateListeningSocket("INTERNAL", intlisteningPort, intlisteningPort, intlisteningInterface, &intEndpoint_, pIntListenerReceiver_, intrbuffer, intwbuffer); } KBE_ASSERT(good() && "NetworkInterface::NetworkInterface: no available port, " "please check for kbengine[_defs].xml!\n"); pDelayedChannels_->init(this->dispatcher(), this); }
//------------------------------------------------------------------------------------- NetworkInterface::NetworkInterface(Mercury::EventDispatcher * pMainDispatcher, int32 extlisteningPort_min, int32 extlisteningPort_max, const char * extlisteningInterface, int32 intlisteningPort, const char * intlisteningInterface): extEndpoint_(), intEndpoint_(), channelMap_(), pDispatcher_(new EventDispatcher), pMainDispatcher_(NULL), pExtensionData_(NULL), pExtListenerReceiver_(NULL), pIntListenerReceiver_(NULL), pDelayedChannels_(new DelayedChannels()), pChannelTimeOutHandler_(NULL), pChannelDeregisterHandler_(NULL), isExternal_(extlisteningPort_min != -1) { if(isExternal()) { pExtListenerReceiver_ = new ListenerReceiver(extEndpoint_, Channel::EXTERNAL, *this); this->recreateListeningSocket("EXTERNAL", htons(extlisteningPort_min), htons(extlisteningPort_max), extlisteningInterface, &extEndpoint_, pExtListenerReceiver_); // 如果配置了对外端口范围, 如果范围过小这里extEndpoint_可能没有端口可用了 if(extlisteningPort_min != -1) { KBE_ASSERT(extEndpoint_.good() && "Channel::EXTERNAL: no available port!\n"); } } if(intlisteningPort != -1) { pIntListenerReceiver_ = new ListenerReceiver(intEndpoint_, Channel::INTERNAL, *this); this->recreateListeningSocket("INTERNAL", intlisteningPort, intlisteningPort, intlisteningInterface, &intEndpoint_, pIntListenerReceiver_); } KBE_ASSERT(good()); if (pMainDispatcher != NULL) { this->attach(*pMainDispatcher); } }
/* * Generate the XML export file. */ void generateXML(sipSpec *pt, moduleDef *mod, const char *xmlFile) { FILE *fp; classDef *cd; memberDef *md; if ((fp = fopen(xmlFile, "w")) == NULL) fatal("Unable to create file \"%s\"\n", xmlFile); fprintf(fp, "<?xml version=\"1.0\"?>\n"); fprintf(fp, "<Module version=\"%u\" name=\"%s\">\n", XML_VERSION_NR, mod->name); /* * Note that we don't yet handle mapped types, templates or exceptions. */ for (cd = pt->classes; cd != NULL; cd = cd->next) { if (cd->iff->module != mod) continue; if (isExternal(cd)) continue; xmlClass(pt, mod, cd, fp); } for (cd = mod->proxies; cd != NULL; cd = cd->next) xmlClass(pt, mod, cd, fp); xmlEnums(pt, mod, NULL, 1, fp); xmlVars(pt, mod, NULL, 1, fp); for (md = mod->othfuncs; md != NULL; md = md->next) xmlFunction(pt, NULL, md, mod->overs, 1, fp); fprintf(fp, "</Module>\n"); fclose(fp); }
font_t* Font::getFullFrom(RPG2kString::const_iterator& it, font_t (&src)[KU_MAX][TEN_MAX][FONT_H]) { if( isExternal(it) ) return getExternal(it); uint ku = 0, ten = 0; // calculate ku int first = *(it++) & 0xff; if( rpg2k::within(0x81, first, 0xa0) ) ku = first - 0x81 + 0x00; else if( rpg2k::within(0xe0, first, 0xf0) ) ku = first - 0xe0 + 0x20; else rpg2k_assert(false); ku *= 2; // calculate ten int second = *(it++) & 0xff; if( rpg2k::within(0x40, second, 0x7f) ) { ten = second - 0x40 + 0x00; ku += 0; } else if( rpg2k::within(0x80, second, 0x9f) ) { ten = second - 0x80 + 0x3f; ku += 0; } else if( rpg2k::within(0x9f, second, 0xfd) ) { ten = second - 0x9f + 0x00; ku += 1; } else rpg2k_assert(false); return src[ku][ten]; }
void Func::funcPrototype(string& code) const { if (isExternal()) { // Do nothing } else { string return_type = m_type_ptr->cIdent(); Type* void_type_ptr = g_sym_table.getType("void"); if (existPair("return_by_ref") && (m_type_ptr != void_type_ptr)) { return_type += "&"; } code += return_type + " " + cIdent() + "("; int size = m_param_string_vec.size(); for(int i=0; i<size; i++) { // Generate code if (i != 0) { code += ", "; } code += m_param_string_vec[i]; } code += ");\n"; } }
void UmlTransition::write_it(FileOut & out) { out.indent(); out << "<transition xmi:type=\"uml:Transition\""; out.id(this); if (!name().isEmpty() && (name() != "<transition>")) { out << " name=\""; out.quote(name()); out << '"'; } out.ref(parent(), "source"); out.ref(target(), "target"); if (parent() == target()) out << " kind=\"" << ((isExternal()) ? "external" : "internal") << '"'; out << ">\n"; out.indent(+1); write_description_properties(out); WrapperStr trig; WrapperStr grd; WrapperStr effect; switch (_lang) { case Uml: trig = trigger(); grd = guard(); effect = activity(); break; case Cpp: trig = cppTrigger(); grd = cppGuard(); effect = cppActivity(); break; default: // Java trig = javaTrigger(); grd = javaGuard(); effect = javaActivity(); break; } if (! trig.isEmpty()) { out.indent(); out << "<trigger xmi:type=\"uml:Trigger\""; out.id_prefix(this, "TRIGGER_"); out << " name=\""; out.quote(trig); out << "\"/>\n"; } if (! grd.isEmpty()) { out.indent(); out << "<guard xmi:type=\"uml:Constraint\""; out.id_prefix(this, "GUARD_"); out << ">\n"; out.indent(); out << "\t<specification xmi:type=\"uml:OpaqueExpression\""; out.id_prefix(this, "GUARD_EXPR_"); out << ">\n"; out.indent(); out << "\t\t<body>"; out.quote(grd); out << "</body>\n"; out.indent(); out << "\t</specification>\n"; out.indent(); out << "</guard>\n"; } if (! effect.isEmpty()) { out.indent(); out << "<effect xmi:type=\"uml:Activity\""; out.id_prefix(this, "EFFECT_"); out << ">\n"; out.indent(); out << "\t<body>"; out.quote(effect); out << "</body>\n"; out.indent(); out << "</effect>\n"; } out.indent(-1); out.indent(); out << "</transition>\n"; unload(); }
bool good() const{ return (!isExternal() || extEndpoint_.good()) && (intEndpoint_.good()); }
void BarnesHutTree::insertBody(const Body& body) { //If there's not a body there already, put the body there. if (m_bodyInTree.mass() == 0) { m_bodyInTree.set_mass(body.mass()); m_bodyInTree.set_xPosition(body.xPosition()); m_bodyInTree.set_yPosition(body.yPosition()); m_bodyInTree.set_zPosition(body.zPosition()); } //If there's already a body there, but it's not an external node //combine the two bodies and figure out which quadrant of the //tree it should be located in. Then recursively update the nodes below it. else if (isExternal() == false) { double newMass = m_bodyInTree.mass() + body.mass(); m_bodyInTree.set_xPosition((m_bodyInTree.xPosition()*m_bodyInTree.mass() + body.xPosition()*body.mass()) / newMass); m_bodyInTree.set_yPosition((m_bodyInTree.yPosition()*m_bodyInTree.mass() + body.yPosition()*body.mass()) / newMass); m_bodyInTree.set_zPosition((m_bodyInTree.zPosition()*m_bodyInTree.mass() + body.zPosition()*body.mass()) / newMass); m_bodyInTree.set_mass(m_bodyInTree.mass() + body.mass()); if (body.isInQuadrant(m_Quadrant.NWQuad())) { if (!m_NW) { m_NW = new BarnesHutTree(m_Quadrant.NWQuad()); } m_NW->insertBody(body); } else if (body.isInQuadrant(m_Quadrant.NEQuad())) { if (!m_NE) { m_NE = new BarnesHutTree(m_Quadrant.NEQuad()); } m_NE->insertBody(body); } else if (body.isInQuadrant(m_Quadrant.SWQuad())) { if (!m_SW) { m_SW = new BarnesHutTree(m_Quadrant.SWQuad()); } m_SW->insertBody(body); } else if (body.isInQuadrant(m_Quadrant.SEQuad())) { if (!m_SE) { m_SE = new BarnesHutTree(m_Quadrant.SEQuad()); }; m_SE->insertBody(body); }; } //If the node is external and contains one other body, create BHTrees //where the bodies should go, update the node, and end //(do not do anything recursively) else if (isExternal() == true) { //there is only one body in this tree if (m_bodyInTree.isInQuadrant(m_Quadrant.NWQuad())) { if (!m_NW) { m_NW = new BarnesHutTree(m_Quadrant.NWQuad()); }; m_NW->insertBody(m_bodyInTree); } else if (m_bodyInTree.isInQuadrant(m_Quadrant.NEQuad())) { if (!m_NE) { m_NE = new BarnesHutTree(m_Quadrant.NEQuad()); }; m_NE->insertBody(m_bodyInTree); } else if (m_bodyInTree.isInQuadrant(m_Quadrant.SWQuad())) { if (!m_SW) { m_SW = new BarnesHutTree(m_Quadrant.SWQuad()); }; m_SW->insertBody(m_bodyInTree); } else if (m_bodyInTree.isInQuadrant(m_Quadrant.SEQuad())) { if (!m_SE) { m_SE = new BarnesHutTree(m_Quadrant.SEQuad()); }; m_SE->insertBody(m_bodyInTree); } insertBody(body); } };
/* * Generate the type hints for an ordinary module. */ static void pyiModule(sipSpec *pt, moduleDef *mod, FILE *fp) { char *cp; int first; memberDef *md; classDef *cd; mappedTypeDef *mtd; ifaceFileList *defined; moduleListDef *mld; /* * Generate the imports. Note that we assume the super-types are the * standard SIP ones. */ fprintf(fp, "import typing\n" "import sip\n" ); first = TRUE; for (mld = mod->imports; mld != NULL; mld = mld->next) { /* We lie about the indent because we only want one blank line. */ first = separate(first, 1, fp); if ((cp = strrchr(mld->module->fullname->text, '.')) == NULL) { fprintf(fp, "import %s\n", mld->module->name); } else { *cp = '\0'; fprintf(fp, "from %s import %s\n", mld->module->fullname->text, mld->module->name); *cp = '.'; } } /* * Generate any exported type hint code and any module-specific type hint * code. */ pyiTypeHintCode(pt->exptypehintcode, 0, fp); pyiTypeHintCode(mod->typehintcode, 0, fp); /* Generate the types - global enums must be first. */ pyiEnums(pt, mod, NULL, NULL, 0, fp); defined = NULL; for (cd = pt->classes; cd != NULL; cd = cd->next) { classDef *impl; if (cd->iff->module != mod) continue; if (isExternal(cd)) continue; impl = getClassImplementation(pt, cd); if (impl != NULL) { if (impl->no_typehint) continue; /* Only handle non-nested classes here. */ if (impl->ecd != NULL) continue; pyiClass(pt, mod, impl, &defined, 0, fp); } } for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next) { mappedTypeDef *impl; if (mtd->iff->module != mod) continue; impl = getMappedTypeImplementation(pt, mtd); if (impl != NULL && impl->pyname != NULL) pyiMappedType(pt, mod, impl, &defined, 0, fp); } pyiVars(pt, mod, NULL, defined, 0, fp); first = TRUE; for (md = mod->othfuncs; md != NULL; md = md->next) if (md->slot == no_slot) { first = separate(first, 0, fp); pyiCallable(pt, mod, md, mod->overs, FALSE, defined, 0, fp); } }