src/tools/moc/moc.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   656                     parseInterfaces(&def);
   656                     parseInterfaces(&def);
   657                     break;
   657                     break;
   658                 case Q_PRIVATE_SLOT_TOKEN:
   658                 case Q_PRIVATE_SLOT_TOKEN:
   659                     parseSlotInPrivate(&def, access);
   659                     parseSlotInPrivate(&def, access);
   660                     break;
   660                     break;
       
   661                 case Q_PRIVATE_PROPERTY_TOKEN:
       
   662                     parsePrivateProperty(&def);
       
   663                     break;
   661                 case ENUM: {
   664                 case ENUM: {
   662                     EnumDef enumDef;
   665                     EnumDef enumDef;
   663                     if (parseEnum(&enumDef))
   666                     if (parseEnum(&enumDef))
   664                         def.enumList += enumDef;
   667                         def.enumList += enumDef;
   665                 } break;
   668                 } break;
   870             def->signalList += funcDef;
   873             def->signalList += funcDef;
   871         }
   874         }
   872     }
   875     }
   873 }
   876 }
   874 
   877 
   875 
   878 void Moc::createPropertyDef(PropertyDef &propDef)
   876 void Moc::parseProperty(ClassDef *def)
   879 {
   877 {
       
   878     next(LPAREN);
       
   879     PropertyDef propDef;
       
   880     QByteArray type = parseType().name;
   880     QByteArray type = parseType().name;
   881     if (type.isEmpty())
   881     if (type.isEmpty())
   882         error();
   882         error();
   883     propDef.designable = propDef.scriptable = propDef.stored = "true";
   883     propDef.designable = propDef.scriptable = propDef.stored = "true";
   884     propDef.user = "false";
   884     propDef.user = "false";
   962             break;
   962             break;
   963         default:
   963         default:
   964             error(2);
   964             error(2);
   965         }
   965         }
   966     }
   966     }
   967     next(RPAREN);
       
   968     if (propDef.read.isNull()) {
   967     if (propDef.read.isNull()) {
   969         QByteArray msg;
   968         QByteArray msg;
   970         msg += "Property declaration ";
   969         msg += "Property declaration ";
   971         msg += propDef.name;
   970         msg += propDef.name;
   972         msg += " has no READ accessor function. The property will be invalid.";
   971         msg += " has no READ accessor function. The property will be invalid.";
   986         msg += propDef.name;
   985         msg += propDef.name;
   987         msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
   986         msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
   988         propDef.constant = false;
   987         propDef.constant = false;
   989         warning(msg.constData());
   988         warning(msg.constData());
   990     }
   989     }
       
   990 }
       
   991 
       
   992 void Moc::parseProperty(ClassDef *def)
       
   993 {
       
   994     next(LPAREN);
       
   995     PropertyDef propDef;
       
   996     createPropertyDef(propDef);
       
   997     next(RPAREN);
       
   998 
       
   999 
       
  1000     if(!propDef.notify.isEmpty())
       
  1001         def->notifyableProperties++;
       
  1002     def->propertyList += propDef;
       
  1003 }
       
  1004 
       
  1005 void Moc::parsePrivateProperty(ClassDef *def)
       
  1006 {
       
  1007     next(LPAREN);
       
  1008     PropertyDef propDef;
       
  1009     next(IDENTIFIER);
       
  1010     propDef.inPrivateClass = lexem();
       
  1011     while (test(SCOPE)) {
       
  1012         propDef.inPrivateClass += lexem();
       
  1013         next(IDENTIFIER);
       
  1014         propDef.inPrivateClass += lexem();
       
  1015     }
       
  1016     // also allow void functions
       
  1017     if (test(LPAREN)) {
       
  1018         next(RPAREN);
       
  1019         propDef.inPrivateClass += "()";
       
  1020     }
       
  1021 
       
  1022     next(COMMA);
       
  1023 
       
  1024     createPropertyDef(propDef);
   991 
  1025 
   992     if(!propDef.notify.isEmpty())
  1026     if(!propDef.notify.isEmpty())
   993         def->notifyableProperties++;
  1027         def->notifyableProperties++;
   994 
  1028 
   995     def->propertyList += propDef;
  1029     def->propertyList += propDef;