Пример #1
0
void Polyplexer::stop()
{
    if ( dynamic_cast<QIODevice*>(_connector) )
    {
        this->sendData("M"+QString::number(MCODE_END_CONNECTION)+"\n");

        /*qApp->processEvents();
        ClosedLoopTimer loop;
        loop.startClosedLoop( 1000 );
        qApp->processEvents();
        //static_cast<SerialPort*>(_connector)->disconnectPort();
        //disconnect(_connector,SIGNAL(readyRead()),this,SLOT(parseData()));
        //disconnect(_connector,SIGNAL(aboutToClose()),this,SLOT(disConnect()));*/
        if ( _connector->isOpen() )
        {
            _connector->close();
            cout<<"Polyplexer::close()"<<endl;
            qApp->processEvents();
            ClosedLoopTimer loop;
            loop.startClosedLoop( 1000 );
            qApp->processEvents();
        }
        _connector = NULL;
        _connectorType = Noone;
    }
    emit newType(_connectorType);

}
Пример #2
0
static void exp__exp_lb_exp_rb(Node* node){
    if(node == NULL) return;
    Node* exp1 = node->firstChild;
    Node* exp2 = exp1->nextSibling->nextSibling;
    handle(exp1);handle(exp2);

#ifdef _DEBUG
showType(exp1->type);
showType(exp2->type);
#endif
    if(exp2->type != NULL && exp2->type->myType != NULL && exp2->type->myType != BASIC_INT){
        semanticError(node->line, "Index should be integer\n", NULL);
    }
    if(exp1->type != NULL && exp1->type->myType != NULL){
        if(exp1->type->myType->typeTag != type_array){
            semanticError(node->line, "Illegal use of '[]'\n", NULL);
        }else{
            node->type = newType();
            node->type->myType = exp1->type->myType->array.element;
#ifdef _DEBUG
printf("what the elment\n");
showType(node->type->myType);
#endif
        }
    }
}
Пример #3
0
void CreatureManager::loadCreatureBuffer(const std::string& buffer)
{
    TiXmlDocument doc;
    doc.Parse(buffer.c_str());
    if(doc.Error())
        stdext::throw_exception(stdext::format("cannot load creature buffer: %s", doc.ErrorDesc()));

    TiXmlElement* root = doc.FirstChildElement();
    if(!root || (root->ValueStr() != "monster" && root->ValueStr() != "npc"))
        stdext::throw_exception("invalid root tag name");

    std::string cName = root->Attribute("name");
    stdext::tolower(cName);
    stdext::trim(cName);
    stdext::ucwords(cName);

    CreatureTypePtr newType(new CreatureType(cName));
    for(TiXmlElement* attrib = root->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) {
        if(attrib->ValueStr() != "look")
            continue;

        internalLoadCreatureBuffer(attrib, newType);
        break;
    }

    doc.Clear();
}
Пример #4
0
static void structspecifier__struct_lc_deflist_rc(Node* node){
    if(node == NULL) return;
    inStruct = true;

    Type* tmp = newType();
    tmp->name = "nameless struct";
    tmp->typeTag = define_struct;

    Node* deflist = node->firstChild->nextSibling->nextSibling;
    if(deflist->tag == _DefList){
        structElement = (Type**)malloc(sizeof(Type*) * maxElement);
        memset(structElement, 0, sizeof(Type*) * maxElement);
        elementIndex = 0;

        handle(deflist);//将数据成员的指针存到tmp->element中

        tmp->structure.elementCount = elementIndex;
        tmp->structure.element = structElement;
    }else{
        tmp->structure.elementCount = 0;
        tmp->structure.element = NULL;        
    }
    node->type = tmp;

    inStruct = false;
}
Пример #5
0
    DataType TypeParser::parseTypePostfixes(const DataType& type) {
        DataType newType(type);

        if (_helper->nextIf(Token::Type::OperatorNot)) {
            newType.setAccess(DataType::Access::ReadWrite);
        }

        if (_helper->nextIf(Token::Type::OperatorQuestionMark)) {
            switch (type.kind()) {
                case DataType::Kind::Pointer:
                    newType.setKind(DataType::Kind::NullablePointer);
                    break;
                case DataType::Kind::GenericPointer:
                    newType.setKind(DataType::Kind::GenericNullablePointer);
                    break;
                case DataType::Kind::Generic:
                    newType = DataType::wrapInType(DataType::Kind::GenericNullablePointer, newType);
                    break;
                default:
                    newType = DataType::wrapInType(DataType::Kind::NullablePointer, newType);
                    break;
            }
        }

        return newType;
    }
Пример #6
0
static void structspecifier__struct_id_lc_deflist_rc(Node* node){
    if(node == NULL) return;
    inStruct = true;

    Node* id = node->firstChild->nextSibling;

    Type* tmp = newType();
    tmp->name = id->text;
    tmp->typeTag = define_struct;

    Node* deflist = id->nextSibling->nextSibling;
    if(deflist->tag == _DefList){
        structElement = (Type**)malloc(sizeof(Type*) * maxElement);
        memset(structElement, 0, sizeof(Type*) * maxElement);
        elementIndex = 0;

        handle(deflist);//将数据成员的指针存到tmp->element中

        tmp->structure.elementCount = elementIndex;
        tmp->structure.element = structElement;
    }else{
        tmp->structure.elementCount = 0;
        tmp->structure.element = NULL;        
    }
    if(!insertSymbolTableType(tmp)){
        semanticError(id->line, "Duplicated definition of '%s'\n", tmp->name);
    }
    node->type = tmp;
    inStruct = false;
}
Пример #7
0
ComplexType Parser::parseComplexType( ParserContext *context, const QDomElement &element )
{
  ComplexType newType( d->mNameSpace );

  newType.setName( element.attribute( QLatin1String("name") ) );

  if (debugParsing())
      qDebug() << "complexType:" << d->mNameSpace << newType.name();

  if ( element.hasAttribute( QLatin1String("mixed") ) )
    newType.setContentModel( XSDType::MIXED );

  QDomElement childElement = element.firstChildElement();

  AttributeGroup::List attributeGroups;
  Group::List groups;

  while ( !childElement.isNull() ) {
    NSManager namespaceManager( context, childElement );
    const QName name( childElement.tagName() );
    if ( name.localName() == QLatin1String("all") ) {
      all( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("sequence") || name.localName() == QLatin1String("choice") ) {
      Element::List elems;
      parseCompositor( context, childElement, newType.nameSpace(), &elems, &groups );
      foreach ( const Element& elem, elems )
          newType.addElement( elem );
    } else if ( name.localName() == QLatin1String("attribute") ) {
Пример #8
0
void
NBTypeCont::insert(const std::string& id, int numLanes, SUMOReal maxSpeed, int prio,
                   SVCPermissions permissions, SUMOReal width, bool oneWayIsDefault, SUMOReal sidewalkWidth, SUMOReal bikeLaneWidth) {

    TypeDefinition newType(numLanes, maxSpeed, prio, width, permissions, oneWayIsDefault, sidewalkWidth, bikeLaneWidth);
    TypesCont::iterator old = myTypes.find(id);
    if (old != myTypes.end()) {
        newType.restrictions.insert(old->second.restrictions.begin(), old->second.restrictions.end());
        newType.attrs.insert(old->second.attrs.begin(), old->second.attrs.end());
    }
    myTypes[id] = newType;
}
Пример #9
0
HomeButton::HomeButton( int w, int h, QWidget *parent) :
    QPushButton(parent)
{
    changeIconOnConnectorType(  Polyplexer::connectorType() );
    setText("");
    setSize( w, h);
    setFlat( true );
    connect( Polyplexer::getInstance( this ),
            SIGNAL(newType(Polyplexer::ConnectorType)),
            this,
            SLOT(changeIconOnConnectorType(Polyplexer::ConnectorType)));
}
Пример #10
0
void MarkerEditor::sl_onMarkerRemoved(const QString &markerName) {
    { // TODO: make common way to get marked object output port
        assert(1 == cfg->getOutputPorts().size());
        Port *outPort = cfg->getOutputPorts().at(0);
        assert(outPort->getOutputType()->isMap());
        QMap<Descriptor, DataTypePtr> outTypeMap = outPort->getOutputType()->getDatatypesMap();

        outTypeMap.remove(markerName);
        DataTypePtr newType(new MapDataType(dynamic_cast<Descriptor&>(*(outPort->getType())), outTypeMap));
        outPort->setNewType(newType);
    }
    emit si_configurationChanged();
}
Пример #11
0
AssetTypeDialog::AssetTypeDialog( QWidget * parent )
: QDialog( parent )
{
	setupUi( this );
	mAssetTypes = AssetType::select().sorted( "name" );
	resetList();
	connect( mNewType, SIGNAL( clicked() ), SLOT( newType() ) );
	connect( mRemoveType, SIGNAL( clicked() ), SLOT( toggleTypeDisabled() ) );
	connect( mEditType, SIGNAL( clicked() ), SLOT( editType() ) );

	connect( mShowDisabled, SIGNAL( toggled( bool ) ), SLOT( showDisabled( bool ) ) );
	connect( mTypeList, SIGNAL( currentTextChanged( const QString & ) ), SLOT( currentTypeChanged( const QString & ) ) );
	currentTypeChanged("");
}
Пример #12
0
static void vardec__id(Node* node){
    if(node == NULL) return;

    Type* t = node->type;
    Node* id = node->firstChild;

#ifdef _DEBUG
    printf("vardec__id : %s\n", id->text);
#endif
    if(t != NULL){
        Type* me = newType();
        me->name = id->text;
        me->typeTag = type_general;
        me->myType = t; // myType => 普通变量的类型
        node->type = me;        
    }
    else{
        node->type = newType();
        node->type->name = id->text;
        node->type->typeTag = type_general;
        node->type->myType = BASIC_UNKNOWN_TYPE;
    }
}
Пример #13
0
ComplexType Parser::parseComplexType( ParserContext *context, const QDomElement &element )
{
  ComplexType newType( d->mNameSpace );

  newType.setName( element.attribute( QLatin1String("name") ) );

  if (debugParsing())
      qDebug() << "complexType:" << d->mNameSpace << newType.name();

  if ( element.hasAttribute( QLatin1String("mixed") ) )
    newType.setContentModel( XSDType::MIXED );

  QDomElement childElement = element.firstChildElement();

  AttributeGroup::List attributeGroups;

  while ( !childElement.isNull() ) {
    NSManager namespaceManager( context, childElement );
    const QName name( childElement.tagName() );
    if ( name.localName() == QLatin1String("all") ) {
      all( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("sequence") ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("choice") ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("attribute") ) {
      newType.addAttribute( parseAttribute( context, childElement ) );
    } else if ( name.localName() == QLatin1String("attributeGroup") ) {
      AttributeGroup g = parseAttributeGroup( context, childElement );
      attributeGroups.append( g );
    } else if ( name.localName() == QLatin1String("anyAttribute") ) {
      addAnyAttribute( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("complexContent") ) {
      parseComplexContent( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("simpleContent") ) {
      parseSimpleContent( context, childElement, newType );
    } else if ( name.localName() == QLatin1String("annotation") ) {
      Annotation::List annotations = parseAnnotation( context, childElement );
      newType.setDocumentation( annotations.documentation() );
      newType.setAnnotations( annotations );
    }

    childElement = childElement.nextSiblingElement();
  }

  newType.setAttributeGroups( attributeGroups );

  return newType;
}
Пример #14
0
Polyplexer::ConnectionStatus Polyplexer::start(QIODevice *connector, ConnectorType connector_type)
{
    if ( connector_type == Noone )
    {
        return Polyplexer::NothingToDo;
    }
    _connectorType = connector_type;
    _connector = connector;

    connect(_connector,SIGNAL(readyRead()),this,SLOT(parseData()));
    //connect(_connector,SIGNAL(aboutToClose()),this,SLOT(disConnect()));

    emit newType(_connectorType);
    return Polyplexer::Connected;

}
Пример #15
0
static void fundec__id_lp_rp(Node* node){
    if(node == NULL) return;
    Node* id = node->firstChild;

    Type* tmp = newType();
    tmp->function.ret = node->type;
    tmp->typeTag = type_func;
    tmp->name = id->text;
    tmp->function.argc = 0;
    tmp->function.argv = NULL;
    node->type = tmp;

    if(!insertSymbolTableType(tmp)){
        semanticError(id->line, "Redefined function '%s'\n", tmp->name);
    }
}
Пример #16
0
void MarkerEditor::sl_onMarkerAdded(const QString &markerName) {
    Marker *marker = markerModel->getMarker(markerName);
    SAFE_POINT(NULL != marker, "NULL marker", );

    { // TODO: make common way to get marked object output port
        assert(1 == cfg->getOutputPorts().size());
        Port *outPort = cfg->getOutputPorts().at(0);
        assert(outPort->getOutputType()->isMap());
        QMap<Descriptor, DataTypePtr> outTypeMap = outPort->getOutputType()->getDatatypesMap();

        Descriptor newSlot = MarkerSlots::getSlotByMarkerType(marker->getType(), marker->getName());
        outTypeMap[newSlot] = BaseTypes::STRING_TYPE();
        DataTypePtr newType(new MapDataType(dynamic_cast<Descriptor&>(*(outPort->getType())), outTypeMap));
        outPort->setNewType(newType);
    }
}
Пример #17
0
ComplexType Parser::parseComplexType( ParserContext *context,
                                      const QDomElement &complexTypeElement,
                                      const QString elementName )
{
  ComplexType newType( d->mNameSpace );

  newType.setName( complexTypeElement.attribute( "name" ) );

  if ( complexTypeElement.hasAttribute( "mixed" ) )
    newType.setContentModel( XSDType::MIXED );

  QDomElement childElement = complexTypeElement.firstChildElement();

  AttributeGroup::List attributeGroups;

  while ( !childElement.isNull() ) {
    QName name = childElement.tagName();
    if ( name.localName() == "all" ) {
      all( context, childElement, newType );
    } else if ( name.localName() == "sequence" ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == "choice" ) {
      parseCompositor( context, childElement, newType );
    } else if ( name.localName() == "attribute" ) {
      newType.addAttribute( parseAttribute( context, childElement, elementName ) );
    } else if ( name.localName() == "attributeGroup" ) {
      AttributeGroup g = parseAttributeGroup( context, childElement );
      attributeGroups.append( g );
    } else if ( name.localName() == "anyAttribute" ) {
      addAnyAttribute( context, childElement, newType );
    } else if ( name.localName() == "complexContent" ) {
      parseComplexContent( context, childElement, newType );
    } else if ( name.localName() == "simpleContent" ) {
      parseSimpleContent( context, childElement, newType );
    } else if ( name.localName() == "annotation" ) {
      Annotation::List annotations = parseAnnotation( context, childElement );
      newType.setDocumentation( annotations.documentation() );
      newType.setAnnotations( annotations );
    }

    childElement = childElement.nextSiblingElement();
  }

  newType.setAttributeGroups( attributeGroups );

  return newType;
}
Пример #18
0
void startElement(void *userData, const char *name, const char **atts)
{
    int  att;

    if (P_DEBUG) {
        printf ("s:name='%s'\n", name);
        for (att=0; atts[att]; att++)
             printf (((att % 2) ? "=%s\n" : "    %s"), atts[att]);
    }

    if (strcasecmp (name, "FIELD") == 0) {
	FIELD *new = (FIELD *) newType (TY_FIELD);

	in_field = 1;
	if (vot->fields)
	    vot->f_last->next = new;
	else
Пример #19
0
static void vardec__vardec_lb_int_rb(Node* node){
    if(node == NULL) return;
    Node* sub = node->firstChild;
    Node* size = sub->nextSibling->nextSibling;
    int s = size->intVal;

    Type* tmp = newType();
    tmp->typeTag = type_array;
    tmp->array.size = s;
    tmp->array.element = node->type;
    // tmp->myType = node->type;

    sub->type = tmp;
    handle(sub);
    node->type = sub->type;
    // node->type->typeTag = type_array;
}
Пример #20
0
int
main(int argc, char * argv[])
{
    char buf[BUFSIZ];
    FILE *in;
    XML_Parser parser;


    if (!argv[1]) {
        in = stdin;

    } else if (!(in = fopen (argv[1], "r"))) {
        printf ("Unable to open input file %s\n", argv[1]);
        return (2);
    }

  
    /*  Create the parser and set the input handlers.
    */
    parser = XML_ParserCreate(NULL);
    XML_SetElementHandler (parser, startElement, endElement);
    XML_SetCharacterDataHandler (parser, charData);

    vot = (VOTable *) newType (TY_VOTABLE);

    do {
        size_t len = fread (buf, 1, sizeof(buf), in);
        done = len < sizeof(buf);
        if (!XML_Parse (parser, buf, len, done)) {
            fprintf (stderr, "Error: %s at line %d\n",
                XML_ErrorString(XML_GetErrorCode(parser)),
                XML_GetCurrentLineNumber(parser));
            return (1);
        }
    } while (!done);

    XML_ParserFree(parser);

    if (in != stdin) 
	fclose (in);

    free ((void *)vot);

    return (0);
}
Пример #21
0
    DataType TypeParser::parseTypeSpecifiers(const DataType& type) {
        if (type.kind() == DataType::Kind::Character) {
            return this->parseCharacterTypeSpecifiers(type);
        }

        DataType newType(type);

        uint32_t value = 0;

        // width specifier (or, colon)
        if (_helper->nextIf(Token::Type::PunctuationColon)) {
            if (_helper->peek().type() != Token::Type::PunctuationColon) {
                if (!this->parseIntegerSpecifierValue(&value)) {
                    return DataType();
                }

                newType.setWidthSpecifier(value);
            }
        }

        // alignment (or, colon)
        if (_helper->nextIf(Token::Type::PunctuationColon)) {
            if (_helper->peek().type() != Token::Type::PunctuationColon) {
                if (!this->parseIntegerSpecifierValue(&value)) {
                    return DataType();
                }

                newType.setAlignmentSpecifier(value);
            }
        }

        // vector
        if (_helper->nextIf(Token::Type::PunctuationColon)) {
            if (!this->parseIntegerSpecifierValue(&value)) {
                return DataType();
            }

            newType.setVectorSizeSpecifier(value);
        }

        return newType;
    }
Пример #22
0
    DataType TypeParser::parseCharacterTypeSpecifiers(const DataType& type) {
        if (!_helper->nextIf(Token::Type::PunctuationColon)) {
            return type;
        }

        assert(_helper->peek().type() == Token::Type::Identifier);

        auto it = _characterEncodingMap.find(_helper->next().str());

        if (it == _characterEncodingMap.cend()) {
            assert(0 && "Message about invalid character encoding");
            return DataType();
        }

        DataType newType(type);

        newType.setCharacterEncoding(it->second);

        return newType;
    }
Пример #23
0
static void fundec__id_lp_varlist_rp(Node* node){
    if(node == NULL) return;
    Node* id = node->firstChild;
    Node* varlist = id->nextSibling->nextSibling;

    Type* tmp = newType();
    tmp->function.ret = node->type;
    tmp->typeTag = type_func;
    tmp->name = id->text;

    funcArgIndex = 0;
    funcArgv = (Type**)malloc(sizeof(Type*) * maxArgc);
    memset(funcArgv, 0, sizeof(Type*) * maxArgc);
    handle(varlist);
    tmp->function.argc = funcArgIndex;
    tmp->function.argv = funcArgv;
    node->type = tmp;

    if(!insertSymbolTableType(tmp)){
        semanticError(id->line, "Redefined function '%s'\n", tmp->name);
    }
}
Пример #24
0
OpenPage::OpenPage(PolyboxModule* poly,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OpenPage)
{
    if ( poly != NULL )
    {
        _polybox = poly;
    }
    else
    {
        qApp->exit( 42 );
    }
    ui->setupUi(this);
    changeLogo();
    _handler = NULL;

    connect(PolyboxModule::getInstance(),
            SIGNAL(newType(PolyboxModule::ConnectorType)),
            this,
            SLOT(changeLogo()));

}
Пример #25
0
static void installGlobals(ModulePtr m) {
    m->env = new Env(m);
    vector<TopLevelItemPtr>::iterator i, end;
    for (i = m->topLevelItems.begin(), end = m->topLevelItems.end();
         i != end; ++i) {
        TopLevelItem *x = i->ptr();
        x->env = m->env;
        switch (x->objKind) {
        case ENUM_DECL : {
            EnumDecl *enumer = (EnumDecl *)x;
            TypePtr t = enumType(enumer);
            addGlobal(m, enumer->name, enumer->visibility, t.ptr());
            for (unsigned i = 0 ; i < enumer->members.size(); ++i) {
                EnumMember *member = enumer->members[i].ptr();
                member->index = (int)i;
                member->type = t;
                addGlobal(m, member->name, enumer->visibility, member);
            }
            break;
        }
        case NEW_TYPE_DECL : {
            NewTypeDecl *nt = (NewTypeDecl *)x;
            TypePtr t = newType(nt);
            addGlobal(m, nt->name, nt->visibility, t.ptr());
            break;
        }
        case PROCEDURE : {
            Procedure *proc = (Procedure *)x;
            if (proc->interface != NULL)
                proc->interface->env = m->env;
            // fallthrough
        }
        default :
            if (x->name.ptr())
                addGlobal(m, x->name, x->visibility, x);
            break;
        }
    }
}
Пример #26
0
void CSetClientUid::PerformAction(TRequestStatus& aStatus)
	{
	switch (iState)
		{
		case EMain:
			{
			RProcess thisProcess;
			thisProcess.Open(thisProcess.Id());
			CleanupClosePushL(thisProcess);
			TUidType type = thisProcess.Type();
			TUidType newType(type[0], type[1], iUid);
			thisProcess.SetType(newType);
			CleanupStack::PopAndDestroy(); // thisProcess
			
			iState = EFinished;
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, KErrNone);
			break;
			}

		case EFinished:
			{
			TRequestStatus* status = &aStatus;
			User::RequestComplete(status, aStatus.Int());
			if (aStatus == iExpectedResult)
				{
				iResult = ETrue;
				}
			else
				{
				iResult = EFalse;
				}
			
			iActionState = EPostrequisite;
			}
			break;
		}
	}
Пример #27
0
void ThingTypeManager::parseItemType(uint16 id, TiXmlElement* elem)
{
    uint16 serverId = id;
    if(serverId > 20000 && id < 20100) {
        serverId -= 20000;

        ItemTypePtr newType(new ItemType);
        newType->setServerId(serverId);
        addItemType(newType);
    }

    ItemTypePtr itemType = getItemType(serverId);
    itemType->setName(elem->Attribute("name"));
    for(TiXmlElement* attrib = elem->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) {
        if(attrib->ValueStr() != "attribute")
            break;

        if(attrib->Attribute("key") == "description") {
            itemType->setDesc(attrib->Attribute("value"));
            break;
        }
    }
}
Пример #28
0
void ThingTypeManager::loadXml(const std::string& file)
{
    /// Read XML
    TiXmlDocument doc;
    doc.Parse(g_resources.loadFile(file).c_str());
    if(doc.Error())
        stdext::throw_exception(stdext::format("failed to parse '%s': '%s'", file, doc.ErrorDesc()));

    TiXmlElement* root = doc.FirstChildElement();
    if(!root || root->ValueTStr() != "items")
        stdext::throw_exception("invalid root tag name");

    for (TiXmlElement *element = root->FirstChildElement(); element; element = element->NextSiblingElement()) {
        if(element->ValueTStr() != "item")
            continue;

        uint16 id = element->readType<uint16>("id");
        if(id > 20000 && id < 20100) {
            id -= 20000;
            ItemTypePtr newType(new ItemType);
            newType->setServerId(id);
            addItemType(newType);
        }

        if(id != 0)
            parseItemType(id, element);
        else {
            uint16 fromId = element->readType<uint16>("fromid"), toId = element->readType<uint16>("toid");
            for(uint16 i = fromId; i < toId; ++i)
                parseItemType(i, element);
        }
    }

    doc.Clear();
    m_xmlLoaded = true;
    g_logger.debug("items.xml read successfully.");
}
Пример #29
0
		SHOULD_EQUAL(obj1->type, obj2->type)
		SHOULD_NOT_EQUAL(obj1->props, obj2->props)
		SHOULD_NOT_EQUAL(obj1->props->name, obj2->props->name)
		SHOULD_EQUAL(strcmp(obj1->props->name, obj2->props->name), 0)
		SHOULD_EQUAL(obj1->props->value->ev.intval, obj2->props->value->ev.intval)
		freeExpr(expr);
		freeObj(obj1);
		freeObj(obj2);
	END_IT
END_DESCRIBE

DESCRIBE(newType, "type* newType (datatype id, char* name, stringlist* required, typelist* inherits, property* properties)")
	IT("Creates a new composite type")
		expression* expr = newExpressionNil();
		string* str = newString(strDup("fun1"));
		type* comptyp = newType(TYPE_COMP_START, "comp", newStringlist(str, NULL), newTypelist(TYPE_OBJ), newProperty("prop1", newTypelist(TYPE_NIL), PROP_PRIVACY_PRIVATE, PROP_RANGE_LOCAL, expr));
		SHOULD_EQUAL(strcmp(comptyp->name, "comp"), 0)
		SHOULD_EQUAL(strcmp(comptyp->required->str->content, "fun1"), 0)
		SHOULD_EQUAL(comptyp->inherits->type, TYPE_OBJ)
		SHOULD_EQUAL(comptyp->properties->value->type, TYPE_NIL)
		freeExpr(expr);
		freeStr(str);
		freeCompTyp(comptyp);
	END_IT
END_DESCRIBE

DESCRIBE(newProperty, "property* newProperty (char* name, typelist* types, int privacy, int range, expression* value)")
	IT("Creates a new property")
		expression* expr = newExpressionStr(newString(strDup("hi")));
		property* prop = newProperty("sample-prop", newTypelist(TYPE_STR), PROP_PRIVACY_PRIVATE, PROP_RANGE_GLOBAL, expr);
		SHOULD_EQUAL(strcmp(prop->name, "sample-prop"), 0)
Пример #30
0
static void exp__float(Node* node){
    if(node == NULL) return;
    node->type = newType();
    node->type->myType = BASIC_FLOAT;
}