void BaseUnitTest() { bool baseOk = false; SetConsoleTitle("Unit-Test: base.c/ base.h"); printf("\n\t\t\tTEST BEGINN"); baseOk = BaseInit("G:\\Coding\\buildcfg\\unittest\\base"); if(!baseOk){ printf("\aDatei konnte nicht geoeffnnet werden\n\n"); return; } printf("Test der Zeichen-Funktonen:\n\n"); printf("\t Erstes Zeichen, mit Cur(): %c, Pos: %ld [ \'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) ); printf("\t Zweites Zeichen mit Next(): %c, Pos: %ld[ \'z\' erwartet, Pos: 0 (\'a\') ]\n", Next(), ftell( base->datei ) ); printf("\t Zweites Zeichen mit Fwd(): %c, Pos: %ld [\'z\' erwartet, Pos: 0 (\'z\') ]\n", Fwd(), ftell( base->datei) ); printf("\t Erstes Zeichen mit Last(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'z\') ]\n", Last(), ftell( base->datei) ); printf("\t Erstes Zeichen mit Rwd(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'a\') ]\n", Rwd(), ftell( base->datei ) ); printf("\t Erstes Zeichen mit Cur(): %c, Pos: %ld [\'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) ); printf(" Skip(): "); printf("\n\tIn Zeile 2 wechseln.\n\n"); while( Cur() != '\n'){ Fwd(); } Fwd(); printf("\n\tSchleife beendet!"); Skip(); printf("\n\n\t naechtes Zeichen: %c, Zeile (F erwartet, in Zeile 13 oder so)\n\n", Cur()); printf(" GetLineCount():\n\n"); printf("\n\n\t\t200 Zeichen weiter...\n\n"); for(int i = 0; i < 200; i++) Fwd(); printf("\t\tDatei-Position vorher: %ld\n\n", ftell( base->datei )); printf("\t\tDas sollte Zeile: %d sein.\n\n", GetLineCount()); printf("\t\tUnd das die Position nachher: %ld", ftell( base->datei )); printf("\nBaseClose():\n\n"); BaseClose(); if( base ){ printf("\t\nBaseClose fehlgeschlagen!\n"); return; }else{ printf("\t\nBaseClose erfolgreich!\n"); } printf("\n\n\t\t\tTEST ABGESCHLOSSEN\n\n"); }
bool Parser::ParseBlendFactor(ngfx::BlendFactor & src, ngfx::BlendFactor & dst) { if (!LookAhead(Token::TOK_IDENTIFIER) || !IsBlendFactor(Cur().Str())) { SpawnError("Parsing source Blend factor failed", "Unexpected token !"); return false; } src = blendFactorKeywords[Consume().Str()]; if (!LookAhead(Token::TOK_IDENTIFIER) || !IsBlendFactor(Cur().Str())) { SpawnError("Parsing dest Blend factor failed", "Unexpected token !"); return false; } dst = blendFactorKeywords[Consume().Str()]; return true; }
Seg Reg::Next() { cur++; // if (cur >= v.size()) // cur = 0; return Cur(); }
int GetPosInLine( ) { int i = 0, curPos = ftell( base->datei ); for(i; Cur() != '\n'; i--) Rwd(); fseek(base->datei, curPos, SEEK_SET); return i*-1; }
bool Eof() { if( feof(base->datei) || (Cur() == EOF) ) return true; else{ fseek( base->datei, -1, SEEK_CUR); return false; } }
NodePtr Parser::StencilZFail(std::unique_ptr<ParserNode> left, const Token & tok) { if (!IsStencilOperation(Cur())) { SpawnError("Parsing zfail stencil operation failed"); return left; } StencilNode* stNode = static_cast<StencilNode*>(left.get()); stNode->m_ZFail = stencilKeywords[(std::string)Consume().Str()]; return left; }
int Next() { int ret; fseek( base->datei, 1, SEEK_CUR ); ret = Cur(); if( ret == EOF ) return EOF; fseek( base->datei, -1, SEEK_CUR ); return ret; }
NodePtr Parser::StencilComp(std::unique_ptr<ParserNode> left, const Token & tok) { if (!IsComparisonFunction(Cur())) { SpawnError("Failed to parse stencil comparison function value", "Expected integer here"); return left; } StencilNode* stNode = static_cast<StencilNode*>(left.get()); stNode->m_Comp = comparisonKeywords[(std::string)Consume().Str()]; return left; }
NodePtr Parser::StencilRef(std::unique_ptr<ParserNode> left, const Token & tok) { auto curTok = Cur(); if (!Match(Token::TOK_INTEGER)) { SpawnError("Failed to parse stencil ref value", "Expected integer here"); return left; } StencilNode* stNode = static_cast<StencilNode*>(left.get()); stNode->m_Ref = curTok.Int(); return left; }
int Skip() { printf("\nSkip()\n"); while( (!feof(base->datei)) && (Cur() != EOF) ){ switch( Cur() ){ //Nicht-druckbare Zeichen printf("Skip: Loop: Nichts Druckbares!\n"); case '\t': case '\a': case '\b': case '\f': case '\v': case '\r': case '\n': case ' ': Fwd(); break; case '/': //Kommentar (//) printf("Skip Loop: Kommentar!\n"); if( Next() == '/') //Kommentar oder doch nur ein einzelner Backslash? while( (!feof(base->datei) && (Cur() != EOF)) && (Cur() != '\n') ) Fwd(); //Zur Nächsten Zeile gehen. else return 0; break; case EOF: printf("Skip Loop: EOF"); return 1; default: printf("Skip() beendet, gefundenes Zeichen %c\n", Cur()); return 0; } } printf("Skip beendet, EOF!"); return 1; }
bool Parser::ParseBlendFactor(ngfx::RenderTargetBlendState& src) { std::string tokStr = (std::string)Cur().Str(); if (tokStr == "Off") { Consume(); src.blendEnable = false; } else if (IsBlendFactor(Cur().Str())) { if (!ParseBlendFactor(src.srcColor, src.destColor)) { return false; } if (LookAhead(Token::TOK_COMMA)) { // Alpha Consume(); if (!ParseBlendFactor(src.srcAlpha, src.destAlpha)) { return false; } } src.blendEnable = true; } else { SpawnError("Unexpected blend factor here", "See syntax on https://docs.unity3d.com/Manual/SL-Blend.html"); return false; } return true; }
// Stencil Off | BLOCK NodePtr Parser::Stencil(std::unique_ptr<ParserNode> left, const Token & tok) { auto CurTok = (std::string)Cur().Str(); ngfx::DepthStencilState* depthStencil = ExtractDepthStencil(left.get()); if (LookAhead(Token::TOK_LEFT_BRACE)) { auto Stencil = StencilBlock(); // } else if (CurTok == "Off") { depthStencil->stencilTest = (false); } else { SpawnError("Parsing stencil state failed", "Expected \' or 'Off' here"); } return left; }
InputIterator ConvertIntegerToStringRadix( T Val, InputIterator Beg, InputIterator End ) { Detail::TRadixAbstraction<T, RadixValue> RA; typedef typename std::iterator_traits<InputIterator>::value_type TChar; InputIterator Cur(Beg); //Текущий символ InputIterator FirstDigit(Beg); //Первая записанная цифра if( Val < 0 ) //Если число отрицательное выводим знак { if( Cur == End ) return Beg; #pragma warning( push ) #pragma warning( disable: 4146 ) Val = -Val; #pragma warning( pop ) *Cur = '-'; ++Cur; ++FirstDigit; } do { if( Cur == End ) return Beg; *Cur = RA.template toChar<TChar>( Val % RA.radix() ); ++Cur; Val /= RA.radix(); } while( Val > 0 ); InputIterator RetVal(Cur); //Итератор стоящий за последним записанным символом //Мы получили перевёрнутое число. Восстанавливаем нормальный порядок --Cur; TChar Tmp; while( FirstDigit < Cur ) { Tmp = *Cur; *Cur = *FirstDigit; *FirstDigit = Tmp; ++FirstDigit; --Cur; } return RetVal; }
irr::core::vector3df MouseTo3D(const MyEventReceiver& Receiver, irr::scene::ISceneCollisionManager *colMan, irr::scene::ITriangleSelector *triSel) { irr::core::position2d<irr::s32> Cur ( Receiver.MouseState.Position ); const irr::core::line3d<irr::f32> Ray = colMan->getRayFromScreenCoordinates(Cur); irr::core::vector3df point; irr::core::triangle3df triangle; const irr::scene::ISceneNode *node = NULL; if (colMan->getCollisionPoint( Ray, triSel, point, triangle, node)) return point; return irr::core::vector3df(0,0,0); }
bool Parser::ParseBlendOperation(ngfx::BlendOperation & color, ngfx::BlendOperation & alpha) { if (!IsBlendOperation(Cur().Str())) { SpawnError("Failed to parse color blend operation"); return false; } color = blendOpKeywords[Consume().Str()]; if (Match(Token::TOK_COMMA)) { Token alphaTok = Consume(); if (!IsBlendOperation(alphaTok.Str())) { SpawnError("Failed to parse alpha blend operation"); return false; } alpha = blendOpKeywords[alphaTok.Str()]; } return true; }
int GetLineCount() { int ret = 0; long int curP = ftell( base->datei ); // Alle \n vom Dateinfang bis zur aktuellen Position zählen. rewind( base->datei ); for( int i = 0; i < curP; i++){ if( Cur() == '\n') ret++; Fwd(); } //Dateizeiger wieder zur usrprünglichen positin fseek( base->datei, curP, SEEK_SET ); return ret; }
// Blend Off // [Num] One Zero SrcColor SrcAlpha DstColor DstAlpha OneMinusSrcColor OneMinusSrcAlpha OneMinusDstColor OneMinusDstAlpha // Blend N SrcFactor DstFactor // Blend N SrcFactor DstFactor, SrcFactorA DstFactorA // @see https://docs.unity3d.com/Manual/SL-Blend.html NodePtr Parser::Blend(std::unique_ptr<ParserNode> left, const Token & tok) { auto CurTok = Cur(); ngfx::BlendState* BS = ExtractBlend(left.get()); if (CurTok.GetType() == Token::TOK_IDENTIFIER) { if (!ParseBlendFactor(BS->renderTargets[0])) { SpawnError("Parsing blend factor for RenderTarget0 failed"); return left; } } else if (CurTok.GetType() == Token::TOK_INTEGER) { int target = Consume().Int(); if (!ParseBlendFactor(BS->renderTargets[target])) { SpawnError("Parsing blend factor for RenderTarget failed"); return left; } } else { SpawnError("Parsing blend factor failed, unexpected token", ""); return left; } return left; }
// BlendOp [N] Op // BlendOp [N] OpColor, OpAlpha // Op: Add Sub RevSub Min Max LogicalClear LogicalSet LogicalNoop LogicalInvert LogicalAnd LogicalNand LogicalOr // @see https://docs.unity3d.com/Manual/SL-Blend.html NodePtr Parser::BlendOp(std::unique_ptr<ParserNode> left, const Token & tok) { ngfx::BlendState* BS = ExtractBlend(left.get()); auto CurTok = Cur(); if (Match(Token::TOK_INTEGER)) { if (!ParseBlendOperation(BS->renderTargets[CurTok.Int()].colorOp, BS->renderTargets[CurTok.Int()].alphaOp)) { SpawnError("Failed to blend operation with Dest RenderTarget."); return left; } } else if (CurTok.GetType() == Token::TOK_IDENTIFIER) { if (!ParseBlendOperation(BS->renderTargets[0].colorOp, BS->renderTargets[0].alphaOp)) { SpawnError("Failed to blend operation with RenderTarget0"); return left; } } else { SpawnError("Failed to blend operation with RenderTarget0", "Unexpected token"); } return left; }
bool BaseInit(const char* projPfd ) { char* tmpCpy; printf(" \nIn BaseInit:\n\n "); if( !projPfd ) return false; base = malloc( sizeof( PStatus ) ); tmpCpy = malloc( strlen(projPfd) + strlen("\\build.bcfg") + 5 ); if( (!base) || (!tmpCpy) ) return false; // Build-Datei sollte unter projPfad\build.cfg gespeichert sein. strcpy( tmpCpy, projPfd ); //Pfad zu Datei erstellen. strcat(tmpCpy, "\\build.bcfg" ); printf("\tPfad: %s\n\n", tmpCpy); base->datei = fopen( tmpCpy, "r"); if( !(base->datei) ){ printf("Datei konnte icht geoeffnet werden!"); return false; }else{ printf("\tDatei erfolgreich geoeffnet, Cur(): %c\n\n", Cur() ); } base->dir = projPfd; base->pfad = tmpCpy; return true; }
Seg Face::Next() { cur++; return Cur(); }
int Rwd() { fseek( base->datei, -1, SEEK_CUR ); return Cur(); }