XPFCapability* PluginOILFilter::CreateColourNode(xmlNodePtr pNode) { XPFCapability* pCap = NULL; wxString strName = CXMLUtils::ConvertToWXString(pNode->name); if (strName == _T("#text") || xmlNodeIsText(pNode)) { wxString str = CXMLUtils::ConvertToWXString(xmlNodeGetContent(pNode)); TRACEUSER("Phil", _T("CreateColourNode ignoring text %s\n"), (LPCTSTR)str); return(NULL); } XPFConvertType AsType = XPFCONVTYPE_UNKNOWN; BOOL bOK = GetConvertAsType(pNode, &AsType); if (!bOK) { TRACEUSER("Phil", _T("CreateColourNode GetConvertAsType failed\n")); return NULL; } if (strName == _T("Colour")) { pCap = new XPFCColour(AsType); } else { ERROR1(NULL, _R(IDE_XPF_BADXML_UNEXPECTED_COLOURTYPE)); } xmlNodePtr pChild; pChild = pNode->children; XPFCapability* pLast = NULL; while (pChild) { XPFCapability* pCapNode = CreateColourNode(pChild); if (pCapNode) { // If we have a node then add it to the list // If we do not have a node already then set m_pObjects if (pLast) { pLast->SetNext(pCapNode); } else { pCap->SetChild(pCapNode); } pLast = pCapNode; } pChild = pChild->next; } return(pCap); }
BOOL PluginOILFilter::ReadColour(xmlNodePtr pNode, CapabilityTree* pCapTree) { // We must loop through the tree of elements // pNode is the Attributes element so read the default as attribute XPFCapability* pCols = NULL; XPFConvertType ColType = XPFCONVTYPE_UNKNOWN; BOOL bOK = GetConvertAsType(pNode, &ColType); if (!bOK) { TRACEUSER("Phil", _T("ReadColour GetConvertAsType failed\n")); return FALSE; } // Loop through each child calling the CreateColourNode recursive function // for each one xmlNodePtr pChild; pChild = pNode->children; XPFCapability* pLast = NULL; while (pChild) { XPFCapability* pCap = CreateColourNode(pChild); if (pCap) { // If we have a node then add it to the list // If we do not have a node already then set m_pObjects if (pLast) { pLast->SetNext(pCap); } else { pCols = pCap; } pLast = pCap; } pChild = pChild->next; } pCapTree->SetColoursTree(pCols, ColType); return TRUE; }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ Parser_v0_1_ARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); } #endif /* NDEBUG */ /* Check that the stack is large enough to grow by a single entry ** if the RHS of the rule is empty. This ensures that there is room ** enough on the stack to push the LHS value */ if( yyRuleInfo[yyruleno].nrhs==0 ){ #ifdef YYTRACKMAXSTACKDEPTH if( yypParser->yyidx>yypParser->yyidxMax ){ yypParser->yyidxMax = yypParser->yyidx; } #endif #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH-1 ){ yyStackOverflow(yypParser); return; } #else if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyGrowStack(yypParser); if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyStackOverflow(yypParser); return; } } #endif } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= IDENTIFIER NUMBER types */ { *arg = yymsp[0].minor.yy11; } break; case 1: /* types ::= types type */ { yylhsminor.yy11 = yymsp[-1].minor.yy11; Add(yylhsminor.yy11, yymsp[0].minor.yy33); } yymsp[-1].minor.yy11 = yylhsminor.yy11; break; case 2: /* types ::= type */ { yylhsminor.yy11 = CreateProgramNode(); Add(yylhsminor.yy11, yymsp[0].minor.yy33); } yymsp[0].minor.yy11 = yylhsminor.yy11; break; case 3: /* type ::= IDENTIFIER LBRACE values RBRACE SEMICOLON */ { yylhsminor.yy33 = yymsp[-2].minor.yy33; SetIden(yylhsminor.yy33, yymsp[-4].minor.yy0); } yymsp[-4].minor.yy33 = yylhsminor.yy33; break; case 4: /* values ::= values value */ { yylhsminor.yy33 = yymsp[-1].minor.yy33; Add(yylhsminor.yy33, yymsp[0].minor.yy30); } yymsp[-1].minor.yy33 = yylhsminor.yy33; break; case 5: /* values ::= value */ { yylhsminor.yy33 = CreateTypeNode(); Add(yylhsminor.yy33, yymsp[0].minor.yy30); } yymsp[0].minor.yy33 = yylhsminor.yy33; break; case 6: /* value ::= IDENTIFIER COLON expression SEMICOLON */ { yylhsminor.yy30 = CreateAssignNode(yymsp[-3].minor.yy0, yymsp[-1].minor.yy37); } yymsp[-3].minor.yy30 = yylhsminor.yy30; break; case 7: /* expression ::= number */ { yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy10); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 8: /* expression ::= IDENTIFIER */ { yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy0); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 9: /* expression ::= IDENTIFIER vector */ { yylhsminor.yy37 = CreateColourNode(yymsp[-1].minor.yy0, yymsp[0].minor.yy6); } yymsp[-1].minor.yy37 = yylhsminor.yy37; break; case 10: /* expression ::= number IDENTIFIER */ { yylhsminor.yy37 = CreateUnitValueNode(yymsp[-1].minor.yy10, yymsp[0].minor.yy0); } yymsp[-1].minor.yy37 = yylhsminor.yy37; break; case 11: /* expression ::= vector */ { yylhsminor.yy37 = CreateVecExprNode(yymsp[0].minor.yy6); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 12: /* vector ::= LESSER vector_vals GREATER */ { yymsp[-2].minor.yy6 = yymsp[-1].minor.yy6; } break; case 13: /* vector_vals ::= vector_vals COMMA number */ { yylhsminor.yy6 = yymsp[-2].minor.yy6; Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); } yymsp[-2].minor.yy6 = yylhsminor.yy6; break; case 14: /* vector_vals ::= number */ { yylhsminor.yy6 = CreateVectorNode(); Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); } yymsp[0].minor.yy6 = yylhsminor.yy6; break; case 15: /* number ::= HEXVAL */ case 16: /* number ::= NUMBER */ yytestcase(yyruleno==16); { yylhsminor.yy10 = yymsp[0].minor.yy0; } yymsp[0].minor.yy10 = yylhsminor.yy10; break; default: break; /********** End reduce actions ************************************************/ }; assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; yypParser->yyidx -= yysize - 1; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact); }else{ assert( yyact == YY_ACCEPT_ACTION ); yypParser->yyidx -= yysize; yy_accept(yypParser); } }