Namespace *SKS::GetNamespace(Position &pos, bool noName) { Namespace *name = new Namespace(); if(!noName) name->SetName(GetName(pos)); while(true) { if(islineEndOfFile(pos)) { break; } SkipComment(pos); if(isLineNamespaceEnd(pos)) { ExitNamespace(pos); break; } else if(isLineNamespace(pos)) { name->AddNamespace(GetNamespace(pos)); } else if(isLineKeyValue(pos)) { name->AddKeyValue(GetKeyValue(pos)); } else break; } return name; }
void generate_inline (Context& ctx, SemanticGraph::Schema& schema, bool i) { Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; Namespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; AnonymousType anonymous_type (ctx, i); Complex complex (ctx, anonymous_type, i); Enumeration enumeration (ctx, i); ns.edge_traverser (names); names.node_traverser (complex); names.node_traverser (enumeration); names.node_traverser (anonymous_type); traverser.traverse (schema); }
Namespace& Namespace::walkTo(const string& path, bool create) { size_t sepPos = path.find("::"); pair<string, string> pathParts; if (sepPos == 0) { string relativePath = path.substr(2, path.length()); return Register::getSingleton().walkTo(relativePath, create); } else if (path == "") return *this; else if (sepPos != string::npos) pathParts = splitName(path, NameHead); else pathParts = make_pair<string, string>(path.c_str(), ""); try { Namespace& ns = getItem_<Namespace>(pathParts.first); return ns.walkTo(pathParts.second, create); } catch (NotFoundException& e) { if (create) { Namespace* ns = new Namespace(pathParts.first, *this); items_.insert(ns); ownItems_.insert(ns); return ns->walkTo(pathParts.second, create); } else { throw e; } } }
static void namespaceGetNamespacesCallback( const Namespace& k , NamespaceDetails& v , list<string>* l ) { if ( ! k.hasDollarSign() || k == "local.oplog.$main" ) { // we call out local.oplog.$main specifically as its the only "normal" // collection that has a $, so we make sure it gets added l->push_back( k.toString() ); } }
void generate_forward (Context& ctx, SemanticGraph::Schema& schema) { ctx.os << "// Forward declarations." << endl; Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; Namespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; Complex complex (ctx); Enumeration enumeration (ctx); ns.edge_traverser (names); names.node_traverser (complex); names.node_traverser (enumeration); traverser.traverse (schema); }
bool linkNamespaces(const char *parent, const char *child) { Namespace *pns = lookupNamespace(parent); Namespace *cns = lookupNamespace(child); if(pns && cns) return cns->classLinkTo(pns); return false; }
void Namespace::ensureNoConflicts(const scene::INodePtr& root) { // Instantiate a new, temporary namespace for the nodes below root Namespace foreignNamespace; // Move all nodes below (and including) root into this temporary namespace foreignNamespace.connect(root); // Collect all namespaced items from the foreign root GatherNamespacedWalker walker; root->traverse(walker); rDebug() << "Namespace::ensureNoConflicts(): imported set of " << walker.result.size() << " namespaced nodes" << std::endl; // Build a union set containing all imported names and all existing names. // We need to know all existing names to ensure that newly created names are // unique in *both* namespaces UniqueNameSet allNames = _uniqueNames; allNames.merge(foreignNamespace._uniqueNames); // Process each object in the to-be-imported tree of nodes, ensuring that it // has a unique name for (const NamespacedPtr& n : walker.result) { // If the imported node conflicts with a name in THIS namespace, then it // needs to be given a new name which is unique in BOTH namespaces. if (_uniqueNames.nameExists(n->getName())) { // Name exists in the target namespace, get a new name std::string uniqueName = allNames.insertUnique(n->getName()); rMessage() << "Namespace::ensureNoConflicts(): '" << n->getName() << "' already exists in this namespace. Rename it to '" << uniqueName << "'\n"; // Change the name of the imported node, this should trigger all // observers in the foreign namespace n->changeName(uniqueName); } else { // Name does not exist yet, insert it into the local combined // namespace (but not our destination namespace, this will be // populated in the subsequent call to connect()). allNames.insert(n->getName()); } } // at this point, all names in the foreign namespace have been converted to // something unique in this namespace. The calling code can now move the // nodes into this namespace without name conflicts // Disconnect the root from the foreign namespace again, it will be destroyed now foreignNamespace.disconnect(root); }
bool ObjectNamespace::setAttrIfHas(const std::string& attr, Object* obj) { if (dict["__inner__"]->dict.find(attr) != dict.end()) { dict[attr]->setAttr(attr, obj); return true; } else if (dict["__parent__"].ref_not_equal(nullptr)) { Namespace* parent = ToolKit::SafeConvert<Namespace>(dict["__parent__"].GetPtr()); return parent->setAttrIfHas(attr, obj); } else return false; }
void Doclet::prewalk(Namespace& instance) { std::string namespaceName = instance.getName(); if (instance.hasDocumentation()) { Documentation* documentation = instance.getDocumentation(); if (documentation->containsAnnotation("@prototype") || documentation->containsAnnotation("@prototyped")) { } } typedef std::vector <Include*>::iterator IncludeIterType; for (IncludeIterType iter = instance.getIncludes().begin(); iter != instance.getIncludes().end(); iter++) { prewalk(**iter); } typedef std::vector <Class*>::iterator ClassIterType; for (ClassIterType iter = instance.getClasses().begin(); iter != instance.getClasses().end(); iter++) { prewalk(**iter); } typedef std::vector <Namespace*>::iterator NamespaceIterType; for (NamespaceIterType iter = instance.getNamespaces().begin(); iter != instance.getNamespaces().end(); iter++) { prewalk(**iter); } }
std::unique_ptr<Node> Namespace::clone() const { Namespace* ns = new Namespace(); ns->lineNumber = lineNumber; ns->columnNumber = columnNumber; ns->comment = comment; ns->namespacePrefix = namespacePrefix; ns->namespaceUri = namespaceUri; for (auto& child : children) { ns->addChild(child->clone()); } return std::unique_ptr<Node>(ns); }
void XmlWriter::WriteNamespace(const Namespace& rNamespace) { if (rNamespace.GetPrefix().empty()) { m_rStream << " xmlns"; } else { m_rStream << " xmlns:" << rNamespace.GetPrefix(); } m_rStream << "=\"" << EscapeString(rNamespace.GetUri()) << "\""; }
void generate_writer_header (Context& ctx, SemanticGraph::Schema& schema) { ctx.os << "#include \"XMLSchema/Writer.hpp\"" << endl << endl; { Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; WriterNamespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; AnonymousType anonymous_type (ctx); Complex complex (ctx, anonymous_type); Enumeration enumeration (ctx); ns.edge_traverser (names); names.node_traverser (complex); names.node_traverser (enumeration); names.node_traverser (anonymous_type); traverser.traverse (schema); } { Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; Namespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; Element element (ctx); ns.edge_traverser (names); names.node_traverser (element); traverser.traverse (schema); } }
void ReflectionParser::Parse(void) { m_index = clang_createIndex( true, m_options.displayDiagnostics ); std::vector<const char *> arguments; #if defined(SYSTEM_INCLUDE_DIRECTORY) arguments.emplace_back( "-I" SYSTEM_INCLUDE_DIRECTORY ); #endif for (auto &argument : m_options.arguments) arguments.emplace_back( argument.c_str( ) ); if (m_options.displayDiagnostics) { for (auto *argument : arguments) std::cout << argument << std::endl; } m_translationUnit = clang_createTranslationUnitFromSourceFile( m_index, m_options.inputSourceFile.c_str( ), static_cast<int>( arguments.size( ) ), arguments.data( ), 0, nullptr ); auto cursor = clang_getTranslationUnitCursor( m_translationUnit ); Namespace tempNamespace; buildClasses( cursor, tempNamespace ); tempNamespace.clear( ); buildGlobals( cursor, tempNamespace ); tempNamespace.clear( ); buildGlobalFunctions( cursor, tempNamespace ); tempNamespace.clear( ); buildEnums( cursor, tempNamespace ); }
bool unlinkNamespaces(const char *parent, const char *child) { Namespace *pns = lookupNamespace(parent); Namespace *cns = lookupNamespace(child); if(pns == cns) { Con::warnf("Con::unlinkNamespaces - trying to unlink '%s' from itself, aborting.", parent); return false; } if(pns && cns) return cns->unlinkClass(pns); return false; }
void fluidinfo::Namespace::getSubNamespaceInfo(const std::string& path, Namespace& ns, Session& session, bool returnDescription, bool returnTags, bool returnNamespaces) { ns.setParentSession(&session); ns.init(); string url = ns.mainURL; std::string returndesc = ( (returnDescription==false) ? "False" : "True" ); std::string returntags = ( (returnTags == false) ? "False" : "True" ); std::string returnnamespaces = ( (returnNamespaces == false) ? "False" : "True" ); url = url + path + "?returnDescription=" + returndesc + "&returnNamespaces=" + returnnamespaces + "&returnTags=" + returntags; ns.runCURL(GET, url, NULL, FWgetSubNamespaceInfo, const_cast<Namespace*>(&ns)); }
NotFoundException::NotFoundException(const Namespace& name_space, const Item& item) throw() { string nsCategory; if (dynamic_cast<const Class*>(&name_space)) nsCategory = "Class"; else nsCategory = "Namespace"; string itemCategory; const Method* method = NULL; if (dynamic_cast<const Class*>(&item)) itemCategory = "Class"; else if (dynamic_cast<const Namespace*>(&item)) itemCategory = "Namespace"; else if (dynamic_cast<const Property*>(&item)) itemCategory = "Property"; else if (dynamic_cast<const Method*>(&item)) { itemCategory = "Method"; method = dynamic_cast<const Method*>(&item); } else if (dynamic_cast<const Function*>(&item)) itemCategory = "Function"; else if (dynamic_cast<const Type*>(&item)) itemCategory = "Type"; msg = nsCategory + " " + name_space.getName() + " has no " + itemCategory; if (!method || !method->hasFullSignature()) msg += " with name " + item.getUnqualifiedName(); else msg += " with signature " + method->getSignature(); }
void NamespaceIndex::add_ns( const Namespace& ns, const NamespaceDetails* details ) { string nsString = ns.toString(); Lock::assertWriteLocked( nsString ); massert( 17315, "no . in ns", nsString.find( '.' ) != string::npos ); init(); uassert( 10081, "too many namespaces/collections", _ht->put(ns, *details)); }
void generate_writer_source (Context& ctx, SemanticGraph::Schema& schema) { { Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; WriterNamespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; AnonymousType anonymous (ctx); Complex complex (ctx, anonymous); Enumeration enumeration (ctx); ns.edge_traverser (names); names.node_traverser (complex); names.node_traverser (enumeration); names.node_traverser (anonymous); traverser.traverse (schema); } { Traversal::Schema traverser; Traversal::Sources sources; Traversal::Names schema_names; Namespace ns (ctx); traverser.edge_traverser (sources); traverser.edge_traverser (schema_names); sources.node_traverser (traverser); schema_names.node_traverser (ns); Traversal::Names names; Writer writer (ctx); ns.edge_traverser (names); names.node_traverser (writer); traverser.traverse (schema); } }
void NamespaceIndex::add_ns( OperationContext* txn, const Namespace& ns, const NamespaceDetails* details ) { string nsString = ns.toString(); txn->lockState()->assertWriteLocked( nsString ); massert( 17315, "no . in ns", nsString.find( '.' ) != string::npos ); init( txn ); uassert( 10081, "too many namespaces/collections", _ht->put(txn, ns, *details)); }
void Doclet::process(Namespace& instance) { if (&instance != _root) { _outputBuffer += "namespace " + instance.getName() + "\n"; _outputBuffer += "{\n"; } typedef std::vector <Include*>::iterator IncludeIterType; for (IncludeIterType iter = instance.getIncludes().begin(); iter != instance.getIncludes().end(); iter++) { process(**iter); } _outputBuffer += "\n"; typedef std::vector <Namespace*>::iterator NamespaceIterType; for (NamespaceIterType iter = instance.getNamespaces().begin(); iter != instance.getNamespaces().end(); iter++) { process(**iter); } typedef std::vector <Class*>::iterator ClassIterType; for (ClassIterType iter = instance.getClasses().begin(); iter != instance.getClasses().end(); iter++) { process(**iter); } if (&instance != _root) { _outputBuffer += "}\n\n\n"; } }
void Sequence::apply(apc::Proxy_client& client, const Namespace& nspace) const { client.apply_sequence(nspace.str(), apc::write_barrier::F, asserts_, updates_); }
Namespace *SKS::GetNamespaceFromFile(const char *fileName) { // Creates a stream to read the file from fstream sksFile(fileName, ios::in); // Breaks of the file couldn't be open if(sksFile.fail()) return NULL; // Seek end of file sksFile.seekg(0, ios::end); // saves length of file m_lengthOfFile = (unsigned int)sksFile.tellg(); // Seeks the beginning of the file sksFile.seekg(0, ios::beg); // Allocates memory for the file in memory m_fileContents = new char [m_lengthOfFile]; // Reads the entire file sksFile.read(m_fileContents, m_lengthOfFile); sksFile.close(); // Currents position in the file Position curPosition; // Creates the namespace that gets filled with the info from the file Namespace *topLevel; // Adds sets the namespace without a name topLevel = GetNamespace(curPosition, true); // Sorts the names for a faster search topLevel->SortIndexes(); // Deletes the character buffer delete []m_fileContents; m_fileContents = NULL; return topLevel; }
void InterfaceType::CreateFromParcel(StatementBlock* addTo, Variable* v, Variable* parcel, Variable**) { // v = Interface.asInterface(parcel.readStrongBinder()); string type = v->type->QualifiedName(); type += ".Stub"; addTo->Add(new Assignment(v, new MethodCall( NAMES.Find(type), "asInterface", 1, new MethodCall(parcel, "readStrongBinder")))); }
bool CheckDeclaration::visit(NamespaceAST *ast) { Identifier *id = identifier(ast->identifier_token); Name *namespaceName = control()->nameId(id); unsigned sourceLocation = ast->firstToken(); if (ast->identifier_token) sourceLocation = ast->identifier_token; Namespace *ns = control()->newNamespace(sourceLocation, namespaceName); ns->setStartOffset(tokenAt(ast->firstToken()).offset); ns->setEndOffset(tokenAt(ast->lastToken()).offset); ast->symbol = ns; _scope->enterSymbol(ns); semantic()->check(ast->linkage_body, ns->members()); // ### we'll do the merge later. return false; }
ArrayObject *DomainObject::getVariables (Atom a) { ArrayObject *result = toplevel()->arrayClass->newArray(0); TraitsBindingsp traits = getTraits(a)->getTraitsBindings(); int i = 0; while ((i = traits->next(i)) != 0) { Namespace *ns = traits->nsAt(i); Stringp name = traits->keyAt(i); Binding b = traits->valueAt(i); if (core()->isVarBinding(b) && ns->getType() == Namespace::NS_Public) { Atom nameAtom = core()->internString(name)->atom(); result->push(&nameAtom, 1); } } return result; }
void NamespaceIndex::add_ns(OperationContext* txn, const Namespace& ns, const NamespaceDetails* details) { const NamespaceString nss(ns.toString()); invariant(txn->lockState()->isDbLockedForMode(nss.db(), MODE_X)); massert(17315, "no . in ns", nsIsFull(nss.toString())); uassert(10081, "too many namespaces/collections", _ht->put(txn, ns, *details)); }
void get_possible_event_objects(const std::string & strEventName, const Events & events, std::vector<EventObject> & vectEventObject) { TMap_NSID_NS::iterator itNamespace; for (itNamespace = events.m_map_NSID_NS.begin(); itNamespace != events.m_map_NSID_NS.end(); itNamespace++) { Namespace * pNamespace = itNamespace->second; const TMap_ID_EventObject & m = pNamespace->get_id_eventobject_map(); TMap_ID_EventObject::const_iterator itIDEventObject; for (itIDEventObject = m.begin(); itIDEventObject != m.end(); itIDEventObject++) { std::string strName = itIDEventObject->second->get_name(); if (strName == strEventName) { vectEventObject.push_back(*itIDEventObject->second); } } } }
static Namespace::Entry* GetEntry(const char* nameSpace, const char* name) { Namespace* ns = NULL; if (!nameSpace || !dStrlen(nameSpace)) ns = Namespace::mGlobalNamespace; else { nameSpace = StringTable->insert(nameSpace); ns = Namespace::find(nameSpace); //can specify a package here, maybe need, maybe not } if (!ns) return NULL; name = StringTable->insert(name); Namespace::Entry* entry = ns->lookupRecursive(name); return entry; }
IArray* TypeManager::getArrayOf( IType* elementType ) { if( !elementType ) CORAL_THROW( IllegalArgumentException, "null element type" ); const std::string& elementTypeName = elementType->getName(); std::string arrayName; arrayName.reserve( elementTypeName.length() + 2 ); arrayName.append( elementTypeName ); arrayName.append( "[]" ); Namespace* ns = static_cast<Namespace*>( elementType->getNamespace() ); // try to locate an existing array of this type IType* existingArrayType = ns->getType( arrayName ); if( existingArrayType ) { assert( existingArrayType->getKind() == TK_ARRAY ); return static_cast<IArray*>( existingArrayType ); } // otherwise, try to create it TypeKind kind = elementType->getKind(); if( kind == TK_ARRAY ) CORAL_THROW( IllegalArgumentException, "arrays of arrays are illegal" ); if( !isData( kind ) ) CORAL_THROW( IllegalArgumentException, "arrays of " << kind << "s are illegal" ); RefPtr<ArrayType> arrayType = new ArrayType; arrayType->setType( TK_ARRAY, elementType->getName() + "[]", ns ); arrayType->setElementType( elementType ); ns->addType( arrayType.get() ); return arrayType.get(); }
void TypeManager::defineBuiltInTypes() { Namespace* rootNS = _rootNS.get(); // register all basic types in the root namespace: for( uint8 k = 0; k < TK_COUNT; ++k ) { TypeComponent* type = static_cast<TypeComponent*>( BASIC_TYPES[k].get() ); if( !type ) continue; type->setNamespace( rootNS ); rootNS->addType( type ); } // pre-load the 'co.IService' type and all its dependencies Namespace* coNS = static_cast<Namespace*>( rootNS->defineChildNamespace( "co" ) ); assert( coNS ); RefPtr<Interface> serviceType = new Interface; serviceType->setType( TK_INTERFACE, "IService", coNS ); coNS->addType( serviceType.get() ); loadTypeOrThrow( "co.IService" ); }