//handle production " Args -> ...|... " FieldList *handleArgs(CSNode *root) { if(isProduction_3(root,MyARGS,MyEXP,MyCOMMA,MyARGS) == 1) { SpecialType *type = handleExp(root->firstChild); FieldList *fd1 = getAndSetFieldList(NULL,type,NULL); FieldList *fd2 = NULL; fd2 = handleArgs(root->firstChild->nextSibling->nextSibling); return linkList(fd1,fd2); } else if(isProduction_1(root,MyARGS,MyEXP) == 1) { SpecialType *type = handleExp(root->firstChild); FieldList *fd = getAndSetFieldList(NULL,type,NULL); return fd; } else { printf("error Args production\n"); semanticFlag = 0; return NULL; } }
bool ChordRest::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "durationType") { setDurationType(e.readElementText()); if (actualDurationType().type() != TDuration::DurationType::V_MEASURE) { if ((type() == Element::Type::REST) && // for backward compatibility, convert V_WHOLE rests to V_MEASURE // if long enough to fill a measure. // OTOH, freshly created (un-initialized) rests have numerator == 0 (< 4/4) // (see Fraction() constructor in fraction.h; this happens for instance // when pasting selection from clipboard): they should not be converted duration().numerator() != 0 && // rest durations are initialized to full measure duration when // created upon reading the <Rest> tag (see Measure::read() ) // so a V_WHOLE rest in a measure of 4/4 or less => V_MEASURE (actualDurationType()==TDuration::DurationType::V_WHOLE && duration() <= Fraction(4, 4)) ) { // old pre 2.0 scores: convert setDurationType(TDuration::DurationType::V_MEASURE); } else // not from old score: set duration fraction from duration type setDuration(actualDurationType().fraction()); } else { if (score()->mscVersion() < 115) { SigEvent event = score()->sigmap()->timesig(e.tick()); setDuration(event.timesig()); } } } else if (tag == "BeamMode") { QString val(e.readElementText()); Beam::Mode bm = Beam::Mode::AUTO; if (val == "auto") bm = Beam::Mode::AUTO; else if (val == "begin") bm = Beam::Mode::BEGIN; else if (val == "mid") bm = Beam::Mode::MID; else if (val == "end") bm = Beam::Mode::END; else if (val == "no") bm = Beam::Mode::NONE; else if (val == "begin32") bm = Beam::Mode::BEGIN32; else if (val == "begin64") bm = Beam::Mode::BEGIN64; else bm = Beam::Mode(val.toInt()); _beamMode = Beam::Mode(bm); } else if (tag == "Attribute" || tag == "Articulation") { // obsolete: "Attribute" Articulation* atr = new Articulation(score()); atr->read(e); add(atr); } else if (tag == "leadingSpace") { qDebug("ChordRest: leadingSpace obsolete"); // _extraLeadingSpace = Spatium(val.toDouble()); e.skipCurrentElement(); } else if (tag == "trailingSpace") { qDebug("ChordRest: trailingSpace obsolete"); // _extraTrailingSpace = Spatium(val.toDouble()); e.skipCurrentElement(); } else if (tag == "Beam") { int id = e.readInt(); Beam* beam = e.findBeam(id); if (beam) beam->add(this); // also calls this->setBeam(beam) else qDebug("Beam id %d not found", id); } else if (tag == "small") _small = e.readInt(); else if (tag == "duration") setDuration(e.readFraction()); else if (tag == "ticklen") { // obsolete (version < 1.12) int mticks = score()->sigmap()->timesig(e.tick()).timesig().ticks(); int i = e.readInt(); if (i == 0) i = mticks; if ((type() == Element::Type::REST) && (mticks == i)) { setDurationType(TDuration::DurationType::V_MEASURE); setDuration(Fraction::fromTicks(i)); } else { Fraction f = Fraction::fromTicks(i); setDuration(f); setDurationType(TDuration(f)); } } else if (tag == "dots") setDots(e.readInt()); else if (tag == "move") _staffMove = e.readInt(); else if (tag == "Slur") { int id = e.intAttribute("id"); if (id == 0) id = e.intAttribute("number"); // obsolete Spanner* spanner = e.findSpanner(id); if (!spanner) qDebug("ChordRest::read(): Slur id %d not found", id); else { QString atype(e.attribute("type")); if (atype == "start") { spanner->setTick(e.tick()); if (spanner->ticks() > 0) // stop has been read first, ticks is tick2 - (-1) spanner->setTick2(spanner->ticks() - 1); spanner->setTrack(track()); if (spanner->type() == Element::Type::SLUR) spanner->setStartElement(this); if (e.pasteMode()) { for (Element* e : spanner->linkList()) { if (e == spanner) continue; Spanner* ls = static_cast<Spanner*>(e); ls->setTick(spanner->tick()); for (Element* ee : linkList()) { ChordRest* cr = static_cast<ChordRest*>(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack(cr->track()); if (ls->type() == Element::Type::SLUR) ls->setStartElement(cr); break; } } } } } else if (atype == "stop") { spanner->setTick2(e.tick()); spanner->setTrack2(track()); if (spanner->type() == Element::Type::SLUR) spanner->setEndElement(this); Chord* start = static_cast<Chord*>(spanner->startElement()); if (start) spanner->setTrack(start->track()); if (e.pasteMode()) { for (Element* e : spanner->linkList()) { if (e == spanner) continue; Spanner* ls = static_cast<Spanner*>(e); ls->setTick2(spanner->tick2()); for (Element* ee : linkList()) { ChordRest* cr = static_cast<ChordRest*>(ee); if (cr->score() == ee->score() && cr->staffIdx() == ls->staffIdx()) { ls->setTrack2(cr->track()); if (ls->type() == Element::Type::SLUR) ls->setEndElement(cr); break; } } } } } else qDebug("ChordRest::read(): unknown Slur type <%s>", qPrintable(atype)); } e.readNext(); } else if (tag == "Lyrics" /*|| tag == "FiguredBass"*/) { Element* element = Element::name2Element(tag, score()); element->setTrack(e.track()); element->read(e); add(element); } else if (tag == "pos") { QPointF pt = e.readPoint(); if (score()->mscVersion() > 114) setUserOff(pt * spatium()); } else if (tag == "offset") { if (score()->mscVersion() > 114) // || voice() >= 2) { DurationElement::readProperties(e); else if (type() == Element::Type::REST) { DurationElement::readProperties(e); setUserXoffset(0.0); // honor Y offset but not X for rests in older scores } else e.skipCurrentElement(); // ignore manual layout otherwise } else if (DurationElement::readProperties(e)) return true; else return false; return true; }
/************************************************************************ * Function: main() * Description: Main entry point for the demonstration *************************************************************************/ int main() { volatile long demo_counter; volatile int pfa_demo=0; int sum = 0; volatile char cvar; /* sample char variable */ REC_TYPE1 q; volatile int localInt1; volatile long localLong1; /* Setup the global string array */ globalstring[0] = "zero"; globalstring[1] = "one"; globalstring[2] = "two"; /* Initialize the rectest structure */ rectest.long_integer = 0xFFFFEEEE; rectest.short_integer = 5555; rectest.integer_array[0] = 0; rectest.integer_array[1] = 10; rectest.integer_array[2] = 20; rectest.integer_array[3] = 30; rectest.string_pointer = "Wind River's Tools Product Family"; /* * Fill a table with factorials using recursive calls. */ factorialDemo( ); /* * Fill a table with the fibonnacci sequence using recursive calls. */ fibonacciDemo( ); /* set a local variable */ pfa_demo = 3; /* * Infinite Loop ... * Could use demo_counter as a modulo-maxcount-for-sizeof(long) * to count the iterations of the demo loop and view in a watch window. */ for ( demo_counter=0; FOREVER ;demo_counter++ ) { /* * Setup and examine 'engineer structure'. This function illustrates * arrays of structures and pointers to array of structures. */ status = engineers( 0x1234 ); /* * Setup and examine link-list structure. This function illustrates * structure pointers and pointer-to-pointers. */ status = linkList( 0x5678 ); /* * Calculate the factorial of a number. Since factorials * get very large quickly, only calculate the factorial * of the number 3 once every 25 iterations using the C modulo operator * to detect 25th iteration in the infinite loop. * * Add 'demo_counter' in a watch window and set a breakpoint * on the 'localInt1=factorial(3);' line. If there are no other * enabled breakpoints in the loop, then every time the * run button is pressed, the demo_counter is updated. But * the modulo operator filters calls to the factorial function * only once every 25 iterations through the loop. */ if ( !(demo_counter % 25) ) localInt1 = factorial( 3 ); /* * Calculate the fibonacci of a fixed number, 5, * once every 100th iteration of the main test loop. */ if ( !(demo_counter % 100) ) globalInt1 = fibonacci( 5 ); /* * Demonstrate some calendar functions. */ localLong1 = 0x12345678; globalLong1 = calendar( localLong1 ); /* * Manipulate some local and global structures. */ q.a = 55; strcpy(q.b,"December"); q.c = 12345678L; q.color = red; sum = 0; wait_index = 0; wait_count = 5; quick_index = 5; recordvar.color = red; /* * Call a function written in assembler */ while (wait_index < wait_count) { wait_index = addone(wait_index); sum = sum + 1; } cvar = date(); recordvar.a = 0; for (quick_index = 0; quick_index <= 4 ;++quick_index) { ++recordvar.a; } recordvar.color = blue; /* * Before starting the demo_count loop once again, increment * pfa_demo counter variable using a ternary condition operator. * Also, maintain a modulo-3 range on its value. */ if (pfa_demo==3) { pfa_demo=0; } else { ++pfa_demo; } } return 0; }