Ignore:
Timestamp:
Mar 25, 2007, 8:32:59 PM (18 years ago)
Author:
cinc
Message:

Code cleanups.

Location:
trunk/idl-compiler/parser_c
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/parser_c/classversion_parser.c

    r267 r271  
    4040
    4141extern GScanner *gScanner;
    42 extern PINTERFACE pCurInterface;
     42extern PPARSEINFO pParseInfo;
     43
    4344/*
    4445  Parse the class version. Note that the identifier is the current symbol..
     
    7677    }
    7778  value=gScanner->value;
    78   pCurInterface->ulMajor=value.v_int;
     79  pParseInfo->pCurInterface->ulMajor=value.v_int;
    7980
    8081  if(!matchNext(','))
     
    103104    }
    104105  value=gScanner->value;
    105   pCurInterface->ulMinor=value.v_int;
     106  pParseInfo->pCurInterface->ulMinor=value.v_int;
    106107
    107108  if(!matchNext(')'))
  • trunk/idl-compiler/parser_c/instancevar_parser.c

    r267 r271  
    4040
    4141extern GScanner *gScanner;
    42 extern PINTERFACE pCurInterface;
     42extern PPARSEINFO pParseInfo;
    4343
    4444/*
     
    122122      exit(1);
    123123    }
    124   if(!pCurInterface)
     124  if(!pParseInfo->pCurInterface)
    125125    {
    126126      g_message("Error: no interface for some reason");
    127127    }
    128128
    129   g_ptr_array_add(pCurInterface->pInstanceVarArray , (gpointer) pInstanceVar);
     129  g_ptr_array_add(pParseInfo->pCurInterface->pInstanceVarArray , (gpointer) pInstanceVar);
    130130}
  • trunk/idl-compiler/parser_c/interface_parser.c

    r270 r271  
    4141
    4242extern GScanner *gScanner;
    43 extern GTokenType curToken;
    44 extern PINTERFACE pCurInterface;
    4543/* The pointer array holding the interfaces we found */
    4644extern GPtrArray* pInterfaceArray;
    47 extern PARSEINFO parseInfo;
     45extern PPARSEINFO pParseInfo;
    4846
    4947static void registerInterface(void)
     
    5149  PSYMBOL pNewSymbol=g_malloc0(sizeof(SYMBOL));
    5250
    53   g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface);
     51  if(!strcmp(pParseInfo->chrRootSourceFile, pParseInfo->pCurInterface->chrSourceFileName))
     52    pParseInfo->pCurInterface->fIsInRootFile=TRUE;
     53
     54  g_ptr_array_add(pInterfaceArray, (gpointer) pParseInfo->pCurInterface);
    5455
    5556  /* Any found interface is registered as a new type so it can be
    5657     used in other classes. */
    57   pNewSymbol->chrSymbolName=g_strdup(pCurInterface->chrName); /* We create a copy here because
    58                                                                  when cleaning up the symbol space
    59                                                                  the string will be freed. */
     58  pNewSymbol->chrSymbolName=g_strdup(pParseInfo->pCurInterface->chrName); /* We create a copy here because
     59                                                                             when cleaning up the symbol space
     60                                                                             the string will be freed. */
    6061  pNewSymbol->uiKind=KIND_TYPESPEC;
    6162  pNewSymbol->uiSymbolToken=IDL_SYMBOL_REGINTERFACE;
    62   g_tree_insert(parseInfo.pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName);
     63  g_tree_insert(pParseInfo->pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName);
    6364  g_scanner_scope_add_symbol(gScanner, ID_SCOPE, pNewSymbol->chrSymbolName,
    6465                             pNewSymbol);
     
    6869  pNewSymbol->uiKind=KIND_TYPESPEC;
    6970  pNewSymbol->uiSymbolToken=IDL_SYMBOL_REGINTERFACE;
    70   pNewSymbol->chrSymbolName=g_strconcat("P", pCurInterface->chrName, NULL);
    71   g_message("%s: %s", __FUNCTION__, pNewSymbol->chrSymbolName);
    72   g_tree_insert(parseInfo.pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName);
     71  pNewSymbol->chrSymbolName=g_strconcat("P", pParseInfo->pCurInterface->chrName, NULL);
     72  g_tree_insert(pParseInfo->pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName);
    7373  g_scanner_scope_add_symbol(gScanner, ID_SCOPE, pNewSymbol->chrSymbolName,
    7474                             pNewSymbol);
     75  //g_message("%s: %s", __FUNCTION__, pNewSymbol->chrSymbolName);
    7576}
    7677
     
    179180  /* Save interface info */
    180181  GTokenValue value=gScanner->value;
    181   pCurInterface->chrName=g_strdup(value.v_identifier);
     182  pParseInfo->pCurInterface->chrName=g_strdup(value.v_identifier);
    182183}
    183184
     
    247248      exit(1);
    248249    }
    249   pCurInterface->chrParent=g_strdup(pCurSymbol->chrSymbolName);
     250  pParseInfo->pCurInterface->chrParent=g_strdup(pCurSymbol->chrSymbolName);
    250251
    251252  /* Check if the parent interface is known. */
    252   if(!findInterfaceFromName(pCurInterface->chrParent))
     253  if(!findInterfaceFromName(pParseInfo->pCurInterface->chrParent))
    253254  {
    254255    g_scanner_unexp_token(gScanner,
     
    295296void parseInterface(GTokenType token)
    296297{
    297   pCurInterface=createInterfaceStruct();
     298  pParseInfo->pCurInterface=createInterfaceStruct();
    298299
    299300  /* Get the interface name */
    300301  parseIFace(token);
     302  pParseInfo->pCurInterface->chrSourceFileName=g_strdup(pParseInfo->chrCurrentSourceFile);
     303
    301304  /* It's save to register the interface right here even if the struct is almost empty.
    302305     If anything goes wrong later we will exit anyway. */
     
    305308  if(matchNext(';'))
    306309    {
    307       pCurInterface->fIsForwardDeclaration=TRUE;
     310      pParseInfo->pCurInterface->fIsForwardDeclaration=TRUE;
    308311    }
    309312  else if(matchNext(':'))
  • trunk/idl-compiler/parser_c/lineinfo_parser.c

    r267 r271  
    4141
    4242extern GScanner *gScanner;
    43 extern PARSEINFO parseInfo;
     43extern PPARSEINFO pParseInfo;
    4444
    4545/*
     
    5454  /* Line number */
    5555  value=gScanner->value;
    56   parseInfo.uiLineCorrection=g_scanner_cur_line(gScanner)-value.v_int+1;
     56  pParseInfo->uiLineCorrection=g_scanner_cur_line(gScanner)-value.v_int+1;
    5757
    5858  if(!matchNext(G_TOKEN_STRING))
     
    6969    }
    7070
     71  value=gScanner->value;
     72
     73  /* Root source file? */
     74  if(!pParseInfo->chrRootSourceFile)
     75    pParseInfo->chrRootSourceFile=g_strdup(value.v_string);
     76
    7177  /* Current source file */
    72   if(parseInfo.chrCurrentSourceFile)
    73     g_free(parseInfo.chrCurrentSourceFile);
     78  if(pParseInfo->chrCurrentSourceFile)
     79    g_free(pParseInfo->chrCurrentSourceFile);
    7480
    75   value=gScanner->value;
    76   parseInfo.chrCurrentSourceFile=g_strdup(value.v_string);
     81  pParseInfo->chrCurrentSourceFile=g_strdup(value.v_string);
    7782
    7883  /* Trailing file include level info isn't used for now. Note that for the root
  • trunk/idl-compiler/parser_c/method_parser.c

    r269 r271  
    4141extern GScanner *gScanner;
    4242extern GTokenType curToken;
    43 extern PINTERFACE pCurInterface;
     43extern PPARSEINFO pParseInfo;
    4444
    4545/* In override_parser.c */
     
    180180  pMethod->chrName=g_strdup(value.v_identifier);
    181181
    182   /* Now check if the method was introduced by some parent */
    183   if((pif=findInterfaceForMethod(pCurInterface, pMethod->chrName))!=NULL)
     182  /* Now check if the method was introduced by some parent. The interface struct contains
     183     the parent name if any and the function will follow the chain of parents. */
     184  if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pMethod->chrName))!=NULL)
    184185    {
    185186      gchar* chrMessage;
     
    226227          exit(1);
    227228        }
    228       g_ptr_array_add( pCurInterface->pMethodArray, (gpointer) pMethod);
     229      g_ptr_array_add( pParseInfo->pCurInterface->pMethodArray, (gpointer) pMethod);
    229230      return;
    230231    }
     
    259260    }
    260261
    261   g_ptr_array_add( pCurInterface->pMethodArray, (gpointer) pMethod);
     262  g_ptr_array_add( pParseInfo->pCurInterface->pMethodArray, (gpointer) pMethod);
    262263}
  • trunk/idl-compiler/parser_c/override_parser.c

    r267 r271  
    4242
    4343extern GScanner *gScanner;
    44 extern PINTERFACE pCurInterface;
     44//extern PINTERFACE pCurInterface;
     45extern PPARSEINFO pParseInfo;
    4546
    4647PINTERFACE findInterfaceForMethod(PINTERFACE pStartInterface, gchar* chrMethodName)
     
    105106
    106107  /* Now check if the method was introduced by some parent */
    107   if((pif=findInterfaceForMethod(pCurInterface, pOMethod->chrName))==NULL)
     108  if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pOMethod->chrName))==NULL)
    108109    {
    109110
     
    139140      exit(1);
    140141    }
    141   g_ptr_array_add(pCurInterface->pOverrideArray, (gpointer) pOMethod);
     142  g_ptr_array_add(pParseInfo->pCurInterface->pOverrideArray, (gpointer) pOMethod);
    142143}
Note: See TracChangeset for help on using the changeset viewer.