// Register this browser helper object. This method is invoked by regsrv32.exe // during installation to set the Windows Registry keys that tell Internet // Explorer that we are a Browser Helper Object server. HRESULT __stdcall DllRegisterServer(void) { HKEY hkBHO = NULL, hkVerity = NULL; LPTYPELIB pTypeLib = NULL; HRESULT hr; WCHAR lpzLibrary[MAX_PATH]; LPTSTR lpzControlName = _T("Verity Controller"); LPTSTR lpzClassKey = _T("CLSID\\") CLSID_VERITY; LPTSTR lpzContextKey = _T("CLSID\\{7CD57D42-C553-4B82-A52A-513082F57EE0}"); LPTSTR lpzOnDocumentKey = _T("CLSID\\{42939237-42F0-4E3F-818E-FA63E4EB5A82}"); LPTSTR lpzBHOKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\") _T("Explorer\\Browser Helper Objects"); if (!GetModuleFileNameW(hDllModule, lpzLibrary, MAX_PATH)) { hr = E_FAIL; goto exit; } if (hr = AddClass(L"CLSID\\" CLSID_VERITY, L"Verity Controller", lpzLibrary)) { goto exit; } if (hr = AddClass(L"CLSID\\{73C6AB50-2BEE-4DC0-AB1C-910C255D1C23}", L"Verity ActiveScriptSite", lpzLibrary)) { goto exit; } if (hr = AddClass(L"CLSID\\{42939237-42F0-4E3F-818E-FA63E4EB5A82}", L"Verity OnDocument Handler", lpzLibrary)) { goto exit; } if (hr = AddClass(L"CLSID\\{7CD57D42-C553-4B82-A52A-513082F57EE0}", L"Verity Script Context", lpzLibrary)) { goto exit; } if (hr = CreateKey(HKEY_LOCAL_MACHINE, lpzBHOKey, &hkBHO)) goto exit; if (hr = CreateKey(hkBHO, CLSID_VERITY, &hkVerity)) goto exit; if (hr = SetString(hkVerity, NULL, lpzControlName)) goto exit; if (hr = LoadTypeLib(lpzLibrary, &pTypeLib)) goto exit; if (hr = RegisterTypeLib(pTypeLib, lpzLibrary, NULL)) goto exit; exit: if (hkBHO) { RegCloseKey(hkBHO); } if (hkVerity) { RegCloseKey(hkVerity); } if (pTypeLib) { pTypeLib->lpVtbl->Release(pTypeLib); } return hr; }
ISClass* SAnalyzeExternalClass(Lexer::ILexer* lexer, SyntaxApi::IClass* base_class, SemanticApi::ISClass* _sbase_class, TExternalClassDecl decl, TGlobalBuildContext build_context, std::vector<SemanticApi::TExternalSMethod> external_classes_bindings, int& curr_bind) { auto sbase_class = dynamic_cast<TSClass*>(_sbase_class); lexer->ParseSource(decl.source.c_str()); auto cl = SyntaxApi::AnalyzeNestedClass(lexer, base_class); TSClass* scl = new TSClass(sbase_class, cl); sbase_class->AddClass(scl); scl->Build(); scl->LinkSignature(build_context); scl->SetSize(decl.size); if (scl->GetType() == SemanticApi::TNodeWithTemplatesType::Template) scl->SetAutoMethodsInitialized(); else scl->InitAutoMethods(); //scl->CalculateMethodsSizes(); //TODO проверка что заданы все external_func scl->SetExternal(external_classes_bindings, curr_bind); return scl; }
void FNativeClassHierarchy::AddClassesForModule(const FName& InModuleName) { FAddClassMetrics AddClassMetrics; // Find the class package for this module UPackage* const ClassPackage = FindPackage(nullptr, *(FString("/Script/") + InModuleName.ToString())); if(!ClassPackage) { return; } TSet<FName> GameModules = GetGameModules(); TMap<FName, FName> PluginModules = GetPluginModules(); TArray<UObject*> PackageObjects; GetObjectsWithOuter(ClassPackage, PackageObjects, false); for(UObject* Object : PackageObjects) { UClass* const CurrentClass = Cast<UClass>(Object); if(CurrentClass) { AddClass(CurrentClass, GameModules, PluginModules, AddClassMetrics); } } UE_LOG(LogContentBrowser, Log, TEXT("Native class hierarchy updated for '%s' in %0.4f seconds. Added %d classes and %d folders."), *InModuleName.ToString(), FPlatformTime::Seconds() - AddClassMetrics.StartTime, AddClassMetrics.NumClassesAdded, AddClassMetrics.NumFoldersAdded); ClassHierarchyUpdatedDelegate.Broadcast(); }
bool NFCClassModule::Load(rapidxml::xml_node<>* attrNode, NF_SHARE_PTR<NFIClass> pParentClass) { const char* pstrLogicClassName = attrNode->first_attribute("Id")->value(); const char* pstrType = attrNode->first_attribute("Type")->value(); const char* pstrPath = attrNode->first_attribute("Path")->value(); const char* pstrInstancePath = attrNode->first_attribute("InstancePath")->value(); //printf( "-----------------------------------------------------\n"); //printf( "%s:\n", pstrLogicClassName ); NF_SHARE_PTR<NFIClass> pClass(NF_NEW NFCClass(pstrLogicClassName)); AddElement(pstrLogicClassName, pClass); pClass->SetParent(pParentClass); pClass->SetTypeName(pstrType); pClass->SetInstancePath(pstrInstancePath); AddClass(pstrPath, pClass); for (rapidxml::xml_node<>* pDataNode = attrNode->first_node(); pDataNode; pDataNode = pDataNode->next_sibling()) { //her children Load(pDataNode, pClass); } //printf( "-----------------------------------------------------\n"); return true; }
void _zune_add_root_class (void) { /* g_print("adding rootclass\n"); */ if (!GetPublicClass(ROOTCLASS)) AddClass(&rootclass); }
void NASReader::PushFeature( const char *pszElement, const Attributes &attrs ) { int iClass; /* -------------------------------------------------------------------- */ /* Find the class of this element. */ /* -------------------------------------------------------------------- */ for( iClass = 0; iClass < GetClassCount(); iClass++ ) { if( EQUAL(pszElement,GetClass(iClass)->GetElementName()) ) break; } /* -------------------------------------------------------------------- */ /* Create a new feature class for this element, if there is no */ /* existing class for it. */ /* -------------------------------------------------------------------- */ if( iClass == GetClassCount() ) { CPLAssert( !IsClassListLocked() ); GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement ); AddClass( poNewClass ); } /* -------------------------------------------------------------------- */ /* Create a feature of this feature class. */ /* -------------------------------------------------------------------- */ GMLFeature *poFeature = new GMLFeature( GetClass( iClass ) ); /* -------------------------------------------------------------------- */ /* Create and push a new read state. */ /* -------------------------------------------------------------------- */ GMLReadState *poState; poState = new GMLReadState(); poState->m_poFeature = poFeature; PushState( poState ); /* -------------------------------------------------------------------- */ /* Check for gml:id, and if found push it as an attribute named */ /* gml_id. */ /* -------------------------------------------------------------------- */ int nFIDIndex; XMLCh anFID[100]; tr_strcpy( anFID, "gml:id" ); nFIDIndex = attrs.getIndex( anFID ); if( nFIDIndex != -1 ) { char *pszFID = tr_strdup( attrs.getValue( nFIDIndex ) ); SetFeatureProperty( "gml_id", pszFID ); CPLFree( pszFID ); } }
void CreateInternalClasses(Lexer::ILexer* lexer, SyntaxApi::IClass* base_class, SemanticApi::ISClass* _sbase_class) { lexer->ParseSource("class dword {}"); SyntaxApi::IClass* t_syntax = SyntaxApi::AnalyzeNestedClass(lexer, base_class); auto sbase_class = dynamic_cast<TSClass*>(_sbase_class); TSClass* t = new TSClass(sbase_class, t_syntax); t->SetSize(1); t->SetSignatureLinked(); t->SetBodyLinked(); sbase_class->AddClass(t); }
ASM SAVEDS int __UserLibInit( register __a6 struct Library *libbase ) { #ifndef __AROS__ SysBase = *(struct ExecBase**)4; #endif D(bug("picture.datatype/__UserLibInit\n")); if((LayersBase = OpenLibrary("layers.library", 39))) { if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39))) { if((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39))) { if((DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39))) { if((DiskfontBase = OpenLibrary("diskfont.library", 37))) { #ifdef __AROS__ if((UtilityBase = (struct UtilityBase *)OpenLibrary("utility.library", 37))) #else if((UtilityBase = (struct Library *)OpenLibrary("utility.library", 37))) #endif { if((DataTypesBase = OpenLibrary("datatypes.library", 37))) { if((IFFParseBase = OpenLibrary("iffparse.library", 37))) { if((CyberGfxBase = OpenLibrary("cybergraphics.library", 37))) { if((dt_class = DT_MakeClass(libbase))) { AddClass(dt_class); D(bug("picture.datatype/__UserLibInit: Returning success\n")); return 0; } } } } } } } } } } D(bug("picture.datatype/__UserLibInit: Returning failure\n")); return -1; }
M_RESULT SnarlInterface::AddClass(LPCWSTR Class, LPCWSTR Description, SNARL_CLASS_FLAGS Flags, LPCWSTR DefaultTitle, LPCWSTR DefaultIcon, LONG32 DefaultTimeout) { LPCSTR szClass = WideToUTF8(Class); LPCSTR szDescription = WideToUTF8(Description); LPCSTR szDefaultTitle = WideToUTF8(DefaultTitle); LPCSTR szDefaultIcon = WideToUTF8(DefaultIcon); M_RESULT result = AddClass(szClass, szDescription, Flags, szDefaultTitle, szDefaultIcon, DefaultTimeout); delete [] szClass; delete [] szDescription; delete [] szDefaultTitle; delete [] szDefaultIcon; return result; }
void GMLReader::PushFeature( const char *pszElement, const char *pszFID ) { int iClass; /* -------------------------------------------------------------------- */ /* Find the class of this element. */ /* -------------------------------------------------------------------- */ for( iClass = 0; iClass < GetClassCount(); iClass++ ) { if( EQUAL(pszElement,GetClass(iClass)->GetElementName()) ) break; } /* -------------------------------------------------------------------- */ /* Create a new feature class for this element, if there is no */ /* existing class for it. */ /* -------------------------------------------------------------------- */ if( iClass == GetClassCount() ) { CPLAssert( !IsClassListLocked() ); GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement ); AddClass( poNewClass ); } /* -------------------------------------------------------------------- */ /* Create a feature of this feature class. Try to set the fid */ /* if available. */ /* -------------------------------------------------------------------- */ GMLFeature *poFeature = new GMLFeature( GetClass( iClass ) ); if( pszFID != NULL ) { poFeature->SetFID( pszFID ); } /* -------------------------------------------------------------------- */ /* Create and push a new read state. */ /* -------------------------------------------------------------------- */ GMLReadState *poState; poState = new GMLReadState(); poState->m_poFeature = poFeature; PushState( poState ); }
Class *MakeTimerClass() { #if (HASHED_STRINGS) struct MethodDescr mdescr[] = { { (IPTR (*)())_Timer_Start, M_Timer_Start }, { (IPTR (*)())_Timer_Stop, M_Timer_Stop }, { (IPTR (*)())_Timer_PrintElapsed, M_Timer_PrintElapsed }, { (IPTR (*)())_Timer_TestMethod, M_Timer_TestMethod }, }; struct InterfaceDescr ifdescr[]= { { mdescr, "Timer", 4}, { NULL, 0UL, 0UL} }; #endif #if (HASHED_IFS || HASHED_METHODS) IPTR (*methods[])() = { (IPTR (*)())_Timer_Start, (IPTR (*)())_Timer_Stop, (IPTR (*)())_Timer_PrintElapsed, (IPTR (*)())_Timer_TestMethod, }; struct InterfaceDescr ifdescr[] = { { methods, I_Timer, 4}, { NULL, 0UL, 0UL} }; #endif Class *cl; cl = MakeClass(TIMERCLASS, ROOTCLASS, ifdescr, sizeof (struct TimerData)); if (cl) { AddClass(cl); } return (cl); }
/* * Given the index in builtin classes, construct the * class and make it public (because of the fake lib base). */ static Class * builtin_to_public_class(ULONG idx) { const struct __MUIBuiltinClass *desc = builtins[idx]; Class *cl; Class *super; super = MUI_GetClass(desc->supername); if (!super) return NULL; cl = MakeClass(desc->name, NULL, super, desc->datasize, 0); if (!cl) return NULL; cl->cl_Dispatcher.h_Entry = desc->dispatcher; AddClass(cl); return cl; }
void FNativeClassHierarchy::PopulateHierarchy() { FAddClassMetrics AddClassMetrics; RootNodes.Empty(); TSet<FName> GameModules = GetGameModules(); TMap<FName, FName> PluginModules = GetPluginModules(); for(TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt) { UClass* const CurrentClass = *ClassIt; AddClass(CurrentClass, GameModules, PluginModules, AddClassMetrics); } UE_LOG(LogContentBrowser, Log, TEXT("Native class hierarchy populated in %0.4f seconds. Added %d classes and %d folders."), FPlatformTime::Seconds() - AddClassMetrics.StartTime, AddClassMetrics.NumClassesAdded, AddClassMetrics.NumFoldersAdded); ClassHierarchyUpdatedDelegate.Broadcast(); }
//------------------------------------------------------------------------------ //! Summary: Called to set the value of a class member using the specified //! XML element //! //! Parameters: \li eXmlBlock - the enumerated block identifier //! \li pMLPropMember - the element that contains the value //! //! Returns: true if successful //------------------------------------------------------------------------------ bool CMLAddDataPubResponse::SetXmlValue(EMLXMLBlock eXmlBlock, CMLPropMember* pMLPropMember) { CMLPropMember* pClass = NULL; bool bSuccessful = true; switch(eXmlBlock) { case ML_XML_BLOCK_DATA: if(lstrcmpi("federationExecutionModelHandle", pMLPropMember->GetName()) == 0) { m_fedExecModelHandle.SetMuthurId(pMLPropMember->GetValue()); } else if(lstrcmpi("subscriptions", pMLPropMember->GetName()) == 0) { pClass = pMLPropMember->GetFirstChild(); while(pClass != NULL) { if(lstrcmpi("className", pClass->GetName()) == 0) { AddClass(CMLHelper::GetCPPClassName(pClass->GetValue())); } pClass = pMLPropMember->GetNextChild(); } } else { bSuccessful = CMLEvent::SetXmlValue(eXmlBlock, pMLPropMember); } break; default: bSuccessful = CMLEvent::SetXmlValue(eXmlBlock, pMLPropMember); break; }// switch(eXmlBlock) return bSuccessful; }
//------------------------------------------------------------------------------ //! Summary: Called to make a copy of the specified source object //! //! Parameters: \li rSource - the object to be copied //! //! Returns: None //------------------------------------------------------------------------------ void CMLAddDataPubResponse::Copy(const CMLAddDataPubResponse& rSource) { PTRNODE Pos = NULL; CMLString* pClass = NULL; CMLEvent::Copy(rSource); // base class processing first m_fedExecModelHandle = rSource.m_fedExecModelHandle; // Copy all the published classes m_apClasses.RemoveAll(TRUE); const CMLPtrList& rClasses = rSource.m_apClasses; Pos = rClasses.GetHeadPosition(); while(Pos != NULL) { if((pClass = (CMLString*)(rClasses.GetNext(Pos))) != NULL) { AddClass(*pClass); } } }
/* add the classes of a mapped file to a class list */ void FindClasses(char *fmem,char *fname) { int dstring_offset; int classes_in_file,class_id,class_offset; bof_class_header *class_data; bof_dispatch *dispatch_section; bof_dstring *dstring_data; int line_table_offset; bof_line_table *line_table; bof_class_props *props; bof_list_elem *classes; int i; dstring_offset = ((bof_file_header *)fmem)->dstring_offset; dstring_data = (bof_dstring *)(fmem + dstring_offset); line_table_offset = ((bof_file_header *)fmem)->line_table_offset; if (line_table_offset == 0) /* means no line number table */ line_table = NULL; else line_table = (bof_line_table *)(fmem + line_table_offset); classes_in_file = ((bof_file_header *)fmem)->num_classes; classes = &((bof_file_header *)fmem)->classes; for (i=0;i<classes_in_file;i++) { class_id = classes[i].id; class_offset = classes[i].offset; class_data = (bof_class_header *)(fmem + class_offset); props = (bof_class_props *)(fmem + class_data->offset_properties); dispatch_section = (bof_dispatch *)(fmem + class_data->offset_dispatch); AddClass(class_id,class_data,fname,fmem,dstring_data,line_table,props); SetClassNumMessages(class_id,dispatch_section->num_messages); FindMessages(fmem,class_id,dispatch_section); } }
int GMLReader::LoadClasses( const char *pszFile ) { // Add logic later to determine reasonable default schema file. if( pszFile == NULL ) return FALSE; /* -------------------------------------------------------------------- */ /* Load the raw XML file. */ /* -------------------------------------------------------------------- */ FILE *fp; int nLength; char *pszWholeText; fp = VSIFOpen( pszFile, "rb" ); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open file %s.", pszFile ); return FALSE; } VSIFSeek( fp, 0, SEEK_END ); nLength = VSIFTell( fp ); VSIFSeek( fp, 0, SEEK_SET ); pszWholeText = (char *) VSIMalloc(nLength+1); if( pszWholeText == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Failed to allocate %d byte buffer for %s,\n" "is this really a GMLFeatureClassList file?", nLength, pszFile ); VSIFClose( fp ); return FALSE; } if( VSIFRead( pszWholeText, nLength, 1, fp ) != 1 ) { VSIFree( pszWholeText ); VSIFClose( fp ); CPLError( CE_Failure, CPLE_AppDefined, "Read failed on %s.", pszFile ); return FALSE; } pszWholeText[nLength] = '\0'; VSIFClose( fp ); if( strstr( pszWholeText, "<GMLFeatureClassList>" ) == NULL ) { VSIFree( pszWholeText ); CPLError( CE_Failure, CPLE_AppDefined, "File %s does not contain a GMLFeatureClassList tree.", pszFile ); return FALSE; } /* -------------------------------------------------------------------- */ /* Convert to XML parse tree. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psRoot; psRoot = CPLParseXMLString( pszWholeText ); VSIFree( pszWholeText ); // We assume parser will report errors via CPL. if( psRoot == NULL ) return FALSE; if( psRoot->eType != CXT_Element || !EQUAL(psRoot->pszValue,"GMLFeatureClassList") ) { CPLDestroyXMLNode(psRoot); CPLError( CE_Failure, CPLE_AppDefined, "File %s is not a GMLFeatureClassList document.", pszFile ); return FALSE; } /* -------------------------------------------------------------------- */ /* Extract feature classes for all definitions found. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psThis; for( psThis = psRoot->psChild; psThis != NULL; psThis = psThis->psNext ) { if( psThis->eType == CXT_Element && EQUAL(psThis->pszValue,"GMLFeatureClass") ) { GMLFeatureClass *poClass; poClass = new GMLFeatureClass(); if( !poClass->InitializeFromXML( psThis ) ) { delete poClass; CPLDestroyXMLNode( psRoot ); return FALSE; } poClass->SetSchemaLocked( TRUE ); AddClass( poClass ); } } CPLDestroyXMLNode( psRoot ); SetClassListLocked( TRUE ); return TRUE; }
Class *init_bitmapclass(struct class_static_data *csd) { struct MethodDescr root_descr[NUM_ROOT_METHODS + 1] = { {(IPTR (*)())bitmap_new , moRoot_New }, {(IPTR (*)())bitmap_dispose, moRoot_Dispose}, {NULL, 0UL} }; struct MethodDescr bitMap_descr[NUM_BITMAP_METHODS + 1] = { {NULL, 0UL} }; struct InterfaceDescr ifdescr[] = { {root_descr, IID_Root , NUM_ROOT_METHODS}, {bitMap_descr, IID_Hidd_BitMap, NUM_BITMAP_METHODS}, {NULL, NULL, 0} }; AttrBase MetaAttrBase = GetAttrBase(IID_Meta); struct TagItem tags[] = { {aMeta_SuperID, (IPTR) CLID_Hidd_BitMap}, {aMeta_InterfaceDescr, (IPTR) ifdescr}, {aMeta_ID, (IPTR) CLID_Hidd_BitMapAmigaIntui}, {aMeta_InstSize, (IPTR) sizeof(struct HIDDBitMapAmigaIntuiData)}, {TAG_DONE, 0UL} }; Class *cl = NULL; EnterFunc(bug("init_bitmapclassAmigaIntui(csd=%p)\n", csd)); if(MetaAttrBase) { cl = NewObject(NULL, CLID_HiddMeta, tags); if(cl) { D(bug("BitMap class ok\n")); csd->bitmapclass = cl; cl->UserData = (APTR) csd; /* Get attrbase for the BitMap interface */ HiddBitMapAttrBase = ObtainAttrBase(IID_Hidd_BitMap); if(HiddBitMapAttrBase) { AddClass(cl); } else { free_bitmapclass(csd); cl = NULL; } } } /* if(MetaAttrBase) */ ReturnPtr("init_bitmapclassAmigaIntui", Class *, cl); }
/*************************************************************************************** NAME : ParseDefclass DESCRIPTION : (defclass ...) is a construct (as opposed to a function), thus no variables may be used. This means classes may only be STATICALLY defined (like rules). INPUTS : The logical name of the router for the parser input RETURNS : FALSE if successful parse, TRUE otherwise SIDE EFFECTS : Inserts valid class definition into Class Table. NOTES : H/L Syntax : (defclass <name> [<comment>] (is-a <superclass-name>+) <class-descriptor>*) <class-descriptor> :== (slot <name> <slot-descriptor>*) | (role abstract|concrete) | (pattern-match reactive|non-reactive) These are for documentation only: (message-handler <name> [<type>]) <slot-descriptor> :== (default <default-expression>) | (default-dynamic <default-expression>) | (storage shared|local) | (access read-only|read-write|initialize-only) | (propagation no-inherit|inherit) | (source composite|exclusive) (pattern-match reactive|non-reactive) (visibility public|private) (override-message <message-name>) (type ...) | (cardinality ...) | (allowed-symbols ...) | (allowed-strings ...) | (allowed-numbers ...) | (allowed-integers ...) | (allowed-floats ...) | (allowed-values ...) | (allowed-instance-names ...) | (allowed-classes ...) | (range ...) <default-expression> ::= ?NONE | ?VARIABLE | <expression>* ***************************************************************************************/ globle int ParseDefclass( void *theEnv, char *readSource) { SYMBOL_HN *cname; DEFCLASS *cls; PACKED_CLASS_LINKS *sclasses,*preclist; TEMP_SLOT_LINK *slots = NULL; int roleSpecified = FALSE, abstract = FALSE, parseError; #if DEFRULE_CONSTRUCT int patternMatchSpecified = FALSE, reactive = TRUE; #endif SetPPBufferStatus(theEnv,ON); FlushPPBuffer(theEnv); SetIndentDepth(theEnv,3); SavePPBuffer(theEnv,"(defclass "); #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE if ((Bloaded(theEnv)) && (! ConstructData(theEnv)->CheckSyntaxMode)) { CannotLoadWithBloadMessage(theEnv,"defclass"); return(TRUE); } #endif cname = GetConstructNameAndComment(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken,"defclass", EnvFindDefclass,NULL,"#",TRUE, TRUE,TRUE); if (cname == NULL) return(TRUE); if (ValidClassName(theEnv,ValueToString(cname),&cls) == FALSE) return(TRUE); sclasses = ParseSuperclasses(theEnv,readSource,cname); if (sclasses == NULL) return(TRUE); preclist = FindPrecedenceList(theEnv,cls,sclasses); if (preclist == NULL) { DeletePackedClassLinks(theEnv,sclasses,TRUE); return(TRUE); } parseError = FALSE; GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken); while (GetType(DefclassData(theEnv)->ObjectParseToken) != RPAREN) { if (GetType(DefclassData(theEnv)->ObjectParseToken) != LPAREN) { SyntaxErrorMessage(theEnv,"defclass"); parseError = TRUE; break; } PPBackup(theEnv); PPCRAndIndent(theEnv); SavePPBuffer(theEnv,"("); GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken); if (GetType(DefclassData(theEnv)->ObjectParseToken) != SYMBOL) { SyntaxErrorMessage(theEnv,"defclass"); parseError = TRUE; break; } if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),ROLE_RLN) == 0) { if (ParseSimpleQualifier(theEnv,readSource,ROLE_RLN,CONCRETE_RLN,ABSTRACT_RLN, &roleSpecified,&abstract) == FALSE) { parseError = TRUE; break; } } #if DEFRULE_CONSTRUCT else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),MATCH_RLN) == 0) { if (ParseSimpleQualifier(theEnv,readSource,MATCH_RLN,NONREACTIVE_RLN,REACTIVE_RLN, &patternMatchSpecified,&reactive) == FALSE) { parseError = TRUE; break; } } #endif else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),SLOT_RLN) == 0) { slots = ParseSlot(theEnv,readSource,slots,preclist,FALSE,FALSE); if (slots == NULL) { parseError = TRUE; break; } } else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),SGL_SLOT_RLN) == 0) { slots = ParseSlot(theEnv,readSource,slots,preclist,FALSE,TRUE); if (slots == NULL) { parseError = TRUE; break; } } else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),MLT_SLOT_RLN) == 0) { slots = ParseSlot(theEnv,readSource,slots,preclist,TRUE,TRUE); if (slots == NULL) { parseError = TRUE; break; } } else if (strcmp(DOToString(DefclassData(theEnv)->ObjectParseToken),HANDLER_DECL) == 0) { if (ReadUntilClosingParen(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken) == FALSE) { parseError = TRUE; break; } } else { SyntaxErrorMessage(theEnv,"defclass"); parseError = TRUE; break; } GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken); } if ((GetType(DefclassData(theEnv)->ObjectParseToken) != RPAREN) || (parseError == TRUE)) { DeletePackedClassLinks(theEnv,sclasses,TRUE); DeletePackedClassLinks(theEnv,preclist,TRUE); DeleteSlots(theEnv,slots); return(TRUE); } SavePPBuffer(theEnv,"\n"); /* ========================================================================= The abstract/reactive qualities of a class are inherited if not specified ========================================================================= */ if (roleSpecified == FALSE) { if (preclist->classArray[1]->system && /* Change to cause */ (DefclassData(theEnv)->ClassDefaultsMode == CONVENIENCE_MODE)) /* default role of */ { abstract = FALSE; } /* classes to be concrete. */ else { abstract = preclist->classArray[1]->abstract; } } #if DEFRULE_CONSTRUCT if (patternMatchSpecified == FALSE) { if ((preclist->classArray[1]->system) && /* Change to cause */ (! abstract) && /* default pattern-match */ (DefclassData(theEnv)->ClassDefaultsMode == CONVENIENCE_MODE)) /* of classes to be */ { reactive = TRUE; } /* reactive. */ else { reactive = preclist->classArray[1]->reactive; } } /* ================================================================ An abstract class cannot have direct instances, thus it makes no sense for it to be reactive since it will have no objects to respond to pattern-matching ================================================================ */ if (abstract && reactive) { PrintErrorID(theEnv,"CLASSPSR",1,FALSE); EnvPrintRouter(theEnv,WERROR,"An abstract class cannot be reactive.\n"); DeletePackedClassLinks(theEnv,sclasses,TRUE); DeletePackedClassLinks(theEnv,preclist,TRUE); DeleteSlots(theEnv,slots); return(TRUE); } #endif /* ======================================================= If we're only checking syntax, don't add the successfully parsed defclass to the KB. ======================================================= */ if (ConstructData(theEnv)->CheckSyntaxMode) { DeletePackedClassLinks(theEnv,sclasses,TRUE); DeletePackedClassLinks(theEnv,preclist,TRUE); DeleteSlots(theEnv,slots); return(FALSE); } cls = NewClass(theEnv,cname); cls->abstract = abstract; #if DEFRULE_CONSTRUCT cls->reactive = reactive; #endif cls->directSuperclasses.classCount = sclasses->classCount; cls->directSuperclasses.classArray = sclasses->classArray; /* ======================================================= This is a hack to let functions which need to iterate over a class AND its superclasses to conveniently do so The real precedence list starts in position 1 ======================================================= */ preclist->classArray[0] = cls; cls->allSuperclasses.classCount = preclist->classCount; cls->allSuperclasses.classArray = preclist->classArray; rtn_struct(theEnv,packedClassLinks,sclasses); rtn_struct(theEnv,packedClassLinks,preclist); /* ================================= Shove slots into contiguous array ================================= */ if (slots != NULL) PackSlots(theEnv,cls,slots); AddClass(theEnv,cls); return(FALSE); }
int GMLReader::ReArrangeTemplateClasses ( GFSTemplateList *pCC ) { /* rearranging the final FeatureClass list [SEQUENTIAL] */ int m_nSavedClassCount = GetClassCount(); /* saving the previous FeatureClass list */ GMLFeatureClass **m_papoSavedClass = (GMLFeatureClass **) CPLMalloc( sizeof(void*) * m_nSavedClassCount ); int clIdx; for (clIdx = 0; clIdx < GetClassCount(); clIdx++) { /* tranferring any previous FeatureClass */ m_papoSavedClass[clIdx] = m_papoClass[clIdx]; } /* cleaning the previous FeatureClass list */ SetClassListLocked( FALSE ); CPLFree( m_papoClass ); m_nClassCount = 0; m_papoClass = NULL; GFSTemplateItem *pItem = pCC->GetFirst(); while ( pItem != NULL ) { /* * re-inserting any required FeatureClassup * accordingly to actual SEQUENTIAL layout */ GMLFeatureClass* poClass = NULL; for( int iClass = 0; iClass < m_nSavedClassCount; iClass++ ) { GMLFeatureClass* poItem = m_papoSavedClass[iClass]; if( EQUAL(poItem->GetName(), pItem->GetName() )) { poClass = poItem; break; } } if (poClass != NULL) { if (poClass->GetFeatureCount() > 0) AddClass( poClass ); } pItem = pItem->GetNext(); } SetClassListLocked( TRUE ); /* destroying the saved List and any unused FeatureClass */ for( int iClass = 0; iClass < m_nSavedClassCount; iClass++ ) { int bUnused = TRUE; GMLFeatureClass* poClass = m_papoSavedClass[iClass]; for( int iClass2 = 0; iClass2 < m_nClassCount; iClass2++ ) { if (m_papoClass[iClass2] == poClass) { bUnused = FALSE; break; } } if ( bUnused == TRUE ) delete poClass; } CPLFree( m_papoSavedClass ); return 1; }
int GMLReader::ParseXSD( const char *pszFile ) { if( pszFile == NULL ) return FALSE; /* -------------------------------------------------------------------- */ /* Load the raw XML file. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psXSDTree = CPLParseXMLFile( pszFile ); if( psXSDTree == NULL ) return FALSE; /* -------------------------------------------------------------------- */ /* Strip off any namespace qualifiers. */ /* -------------------------------------------------------------------- */ CPLStripXMLNamespace( psXSDTree, NULL, TRUE ); /* -------------------------------------------------------------------- */ /* Find <schema> root element. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psSchemaNode = CPLGetXMLNode( psXSDTree, "=schema" ); if( psSchemaNode == NULL ) { CPLDestroyXMLNode( psXSDTree ); return FALSE; } /* ==================================================================== */ /* Process each feature class definition. */ /* ==================================================================== */ CPLXMLNode *psThis; int bIsLevel0 = TRUE; for( psThis = psSchemaNode->psChild; psThis != NULL; psThis = psThis->psNext ) { /* -------------------------------------------------------------------- */ /* Check for <xs:element> node. */ /* -------------------------------------------------------------------- */ if( psThis->eType != CXT_Element || !EQUAL(psThis->pszValue,"element") ) continue; /* -------------------------------------------------------------------- */ /* Check the substitution group. */ /* -------------------------------------------------------------------- */ const char *pszSubGroup = StripNS(CPLGetXMLValue(psThis,"substitutionGroup","")); // Old OGR produced elements for the feature collection. if( EQUAL(pszSubGroup, "_FeatureCollection") ) continue; if( !EQUAL(pszSubGroup, "_Feature") ) { bIsLevel0 = FALSE; break; } /* -------------------------------------------------------------------- */ /* Get name */ /* -------------------------------------------------------------------- */ const char *pszName; pszName = CPLGetXMLValue( psThis, "name", NULL ); if( pszName == NULL ) { bIsLevel0 = FALSE; break; } /* -------------------------------------------------------------------- */ /* Get type and verify relationship with name. */ /* -------------------------------------------------------------------- */ const char *pszType; pszType = CPLGetXMLValue( psThis, "type", NULL ); if( strstr( pszType, ":" ) != NULL ) pszType = strstr( pszType, ":" ) + 1; if( pszType == NULL || !EQUALN(pszType,pszName,strlen(pszName)) || !(EQUAL(pszType+strlen(pszName),"_Type") || EQUAL(pszType+strlen(pszName),"Type")) ) { bIsLevel0 = FALSE; break; } /* -------------------------------------------------------------------- */ /* The very next element should be the corresponding */ /* complexType declaration for the element. */ /* -------------------------------------------------------------------- */ psThis = psThis->psNext; while( psThis != NULL && psThis->eType == CXT_Comment ) psThis = psThis->psNext; if( psThis == NULL || psThis->eType != CXT_Element || !EQUAL(psThis->pszValue,"complexType") || !EQUAL(CPLGetXMLValue(psThis,"name",""),pszType) ) { bIsLevel0 = FALSE; break; } /* -------------------------------------------------------------------- */ /* Grab the sequence of extensions greatgrandchild. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psAttrSeq = CPLGetXMLNode( psThis, "complexContent.extension.sequence" ); if( psAttrSeq == NULL ) { bIsLevel0 = FALSE; break; } /* -------------------------------------------------------------------- */ /* We are pretty sure this going to be a valid Feature class */ /* now, so create it. */ /* -------------------------------------------------------------------- */ GMLFeatureClass *poClass = new GMLFeatureClass( pszName ); /* -------------------------------------------------------------------- */ /* Loop over each of the attribute elements being defined for */ /* this feature class. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psAttrDef; for( psAttrDef = psAttrSeq->psChild; psAttrDef != NULL; psAttrDef = psAttrDef->psNext ) { if( !EQUAL(psAttrDef->pszValue,"element") ) continue; // For now we skip geometries .. fixup later. if( CPLGetXMLNode( psAttrDef, "simpleType" ) == NULL ) continue; GMLPropertyDefn *poProp = new GMLPropertyDefn( CPLGetXMLValue( psAttrDef, "name", "unnamed" ), CPLGetXMLValue( psAttrDef, "name", "unnamed" ) ); const char *pszBase = StripNS( CPLGetXMLValue( psAttrDef, "simpleType.restriction.base", "" )); if( EQUAL(pszBase,"decimal") ) { poProp->SetType( GMLPT_Real ); const char *pszWidth = CPLGetXMLValue( psAttrDef, "simpleType.restriction.totalDigits.value", "0" ); const char *pszPrecision = CPLGetXMLValue( psAttrDef, "simpleType.restriction.fractionDigits.value", "0" ); poProp->SetWidth( atoi(pszWidth) ); poProp->SetPrecision( atoi(pszPrecision) ); } else if( EQUAL(pszBase,"float") || EQUAL(pszBase,"double") ) poProp->SetType( GMLPT_Real ); else if( EQUAL(pszBase,"integer") ) { poProp->SetType( GMLPT_Integer ); const char *pszWidth = CPLGetXMLValue( psAttrDef, "simpleType.restriction.totalDigits.value", "0" ); poProp->SetWidth( atoi(pszWidth) ); } else if( EQUAL(pszBase,"string") ) { poProp->SetType( GMLPT_String ); const char *pszWidth = CPLGetXMLValue( psAttrDef, "simpleType.restriction.maxLength.value", "0" ); poProp->SetWidth( atoi(pszWidth) ); } else poProp->SetType( GMLPT_Untyped ); poClass->AddProperty( poProp ); } /* -------------------------------------------------------------------- */ /* Class complete, add to reader class list. */ /* -------------------------------------------------------------------- */ poClass->SetSchemaLocked( TRUE ); AddClass( poClass ); } CPLDestroyXMLNode( psXSDTree ); if( m_nClassCount > 0 ) { SetClassListLocked( TRUE ); return TRUE; } else return FALSE; }
void CCodeProcessor::ProcessModule( bool forcequiet, int depth, int& maxdepth, int& numheaders, int& skippedfiles, const char *srcroot, const char *baseroot, const char *root, const char *module ) { char filename[ 256 ]; if ( depth > maxdepth ) { maxdepth = depth; } int filelength; char *buffer = NULL; // Always skip these particular modules/headers if ( SkipFile( module ) ) { CODE_MODULE module; module.skipped = true; m_Modules.Insert( filename, module ); skippedfiles++; return; } if ( !LoadFile( &buffer, filename, module, forcequiet, depth, filelength, numheaders, skippedfiles, srcroot, root, baseroot ) ) { CODE_MODULE module; module.skipped = true; m_Modules.Insert( filename, module ); skippedfiles++; return; } assert( buffer ); m_nBytesProcessed += filelength; CODE_MODULE m; m.skipped = false; m_Modules.Insert( filename, m ); if ( !forcequiet ) { strcpy( m_szCurrentCPP, filename ); } AddHeader( depth, filename, m_szCurrentCPP ); bool onclient = !strnicmp( m_szBaseEntityClass, "C_", 2 ) ? true : false; // Parse tokens looking for #include directives or class starts char *current = buffer; current = CC_ParseToken( current ); while ( 1 ) { // No more tokens if ( !current ) break; if ( !stricmp( com_token, "#include" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 && com_token[ 0 ] != '<' ) { //vprint( "#include %s\n", com_token ); m_nHeadersProcessed++; numheaders++; ProcessModule( true, depth + 1, maxdepth, numheaders, skippedfiles, srcroot, baseroot, root, com_token ); } } else if ( !stricmp( com_token, "class" ) || !stricmp( com_token, "struct" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { //vprint( depth, "class %s\n", com_token ); CClass *cl = AddClass( com_token ); // Now see if there's a base class current = CC_ParseToken( current ); if ( !stricmp( com_token, ":" ) ) { // Parse out public and then classname an current = CC_ParseToken( current ); if ( !stricmp( com_token, "public" ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { cl->SetBaseClass( com_token ); do { current = CC_ParseToken( current ); } while ( strlen( com_token ) && stricmp( com_token, "{" ) ); if ( !stricmp( com_token, "{" ) ) { current = cl->ParseClassDeclaration( current ); } } } } else if ( !stricmp( com_token, "{" ) ) { current = cl->ParseClassDeclaration( current ); } } } else if ( !strnicmp( com_token, "PREDICTABLE_CLASS", strlen( "PREDICTABLE_CLASS" ) ) ) { char prefix[ 32 ]; prefix[ 0 ] = 0; int type = 0; int bases = 1; int usebase = 0; if ( !stricmp( com_token, "PREDICTABLE_CLASS_ALIASED" ) ) { type = 2; bases = 2; if ( onclient ) { strcpy( prefix, "C_" ); } else { strcpy( prefix, "C" ); usebase = 1; } } else if ( !stricmp( com_token, "PREDICTABLE_CLASS_SHARED" ) ) { type = 1; bases = 1; } else if ( !stricmp( com_token, "PREDICTABLE_CLASS" ) ) { type = 0; bases = 1; if ( onclient ) { strcpy( prefix, "C_" ); } else { strcpy( prefix, "C" ); } } else if ( !stricmp( com_token, "PREDICTABLE_CLASS_ALIASED_PREFIXED" ) ) { // Nothing } else { vprint( 0, "PREDICTABLE_CLASS of unknown type!!! %s\n", com_token ); } // parse the ( current = CC_ParseToken( current ); if ( !strcmp( com_token, "(" ) ) { // Now the classname current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { //vprint( depth, "class %s\n", com_token ); CClass *cl = AddClass( com_token ); // Now see if there's a base class current = CC_ParseToken( current ); if ( !stricmp( com_token, "," ) ) { // Parse out public and then classname an current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { char basename[ 256 ]; sprintf( basename, "%s%s", prefix, com_token ); bool valid = true; if ( bases == 2 ) { valid = false; current = CC_ParseToken( current ); if ( !stricmp( com_token, "," ) ) { current = CC_ParseToken( current ); if ( strlen( com_token ) > 0 ) { valid = true; if ( usebase == 1 ) { sprintf( basename, "%s%s", prefix, com_token ); } } } } if ( valid ) { cl->SetBaseClass( basename ); strcpy( cl->m_szTypedefBaseClass, basename ); } do { current = CC_ParseToken( current ); } while ( strlen( com_token ) && stricmp( com_token, ")" ) ); if ( !stricmp( com_token, ")" ) ) { current = cl->ParseClassDeclaration( current ); } } } else if ( !stricmp( com_token, ")" ) ) { current = cl->ParseClassDeclaration( current ); } } } } else if ( !strcmp( com_token, "TYPEDESCRIPTION" ) || !strcmp( com_token, "typedescription_t" ) ) { current = ParseTypeDescription( current, false ); } else if ( !strcmp( com_token, "BEGIN_DATADESC" ) || !strcmp( com_token, "BEGIN_DATADESC_NO_BASE" ) || !strcmp( com_token, "BEGIN_SIMPLE_DATADESC" ) ) { current = ParseTypeDescription( current, true ); } else if ( !strcmp( com_token, "BEGIN_PREDICTION_DATA" ) || !strcmp( com_token, "BEGIN_EMBEDDED_PREDDESC" ) ) { current = ParsePredictionTypeDescription( current ); } else if ( !strcmp( com_token, "BEGIN_RECV_TABLE" ) || !strcmp( com_token, "BEGIN_RECV_TABLE_NOBASE" ) || !strcmp( com_token, "IMPLEMENT_CLIENTCLASS_DT" ) || !strcmp( com_token, "IMPLEMENT_CLIENTCLASS_DT_NOBASE" ) ) { current = ParseReceiveTable( current ); } else if ( !strcmp( com_token, "IMPLEMENT_PREDICTABLE_NODATA" ) ) { current = CC_ParseToken( current ); if ( !strcmp( com_token, "(" ) ) { current = CC_ParseToken( current ); CClass *cl = FindClass( com_token ); if ( cl ) { if ( cl->m_bHasPredictionData ) { if ( !forcequiet ) { vprint( 0, "Class %s declared predictable and implemented with IMPLEMENT_PREDICTABLE_NODATA in typedescription\n", cl->m_szName ); } cl->m_bHasPredictionData = false; } } current = CC_ParseToken( current ); } } current = CC_ParseToken( current ); } COM_FreeFile( (unsigned char *)buffer ); if ( !forcequiet && !GetQuiet() ) { vprint( 0, " %s: headers (%i game / %i total)", (char *)&filename[ m_nOffset ], numheaders - skippedfiles, numheaders ); if ( maxdepth > 1 ) { vprint( 0, ", depth %i", maxdepth ); } vprint( 0, "\n" ); } m_nLinesOfCode += linesprocessed; linesprocessed = 0; }