Ignore:
Timestamp:
Mar 24, 2007, 5:18:50 PM (18 years ago)
Author:
cinc
Message:

Bail out on duplicate method definition. MEthod overriding checks for method.

File:
1 edited

Legend:

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

    r259 r263  
    4242extern PINTERFACE pCurInterface;
    4343
     44/* In override_parser.c */
     45extern PINTERFACE findInterfaceForMethod(PINTERFACE pStartInterface, gchar* chrMethodName);
     46
    4447static PMETHOD createMethodStruct()
    4548{
     
    146149  GTokenValue value;
    147150  PMETHOD pMethod=createMethodStruct();
    148 
     151  PINTERFACE pif;
    149152  //g_printf("%d: ", __LINE__);
    150153  //printToken(curToken);
     
    157160    {
    158161      getNextToken(); /* Make sure error references the correct token */
    159       printToken(curToken);
    160162      g_scanner_unexp_token(gScanner,
    161163                            G_TOKEN_IDENTIFIER,
     
    169171  value=gScanner->value;
    170172  pMethod->chrName=g_strdup(value.v_identifier);
     173
     174  /* Now check if the method was introduced by some parent */
     175  if((pif=findInterfaceForMethod(pCurInterface, pMethod->chrName))!=NULL)
     176    {
     177      gchar* chrMessage;
     178      chrMessage=g_strdup_printf("A method '%s' is already present in interface '%s'.",
     179                                 pMethod->chrName, pif->chrName);
     180
     181      g_scanner_unexp_token(gScanner,
     182                            G_TOKEN_IDENTIFIER,
     183                            NULL,
     184                            NULL,
     185                            NULL,
     186                            chrMessage,
     187                            TRUE); /* is_error */
     188      exit(1);
     189    }
    171190
    172191  /* Handle parameters  if any */
Note: See TracChangeset for help on using the changeset viewer.