void WavefrontObj::Load(const path_type& filename) { std::vector<char> objText; std::ifstream meshFile(filename); if( !meshFile ) return; objText.assign( std::istreambuf_iterator<char>(meshFile), std::istreambuf_iterator<char>()); std::vector<ObjPosition> pos; std::vector<ObjTexCoords> tex; std::vector<ObjNormal> norm; std::vector<ObjFace> face; // // Read in vertex data // auto it = objText.begin(); while (it != objText.end()) { switch (*it) { case 'v': switch (*++it) { case 't': // vt = texture coord tex.push_back(ParseObjTexCoords(++it, objText.end())); break; case 'n': // vn = normal norm.push_back(ParseObjNormal(++it, objText.end())); break; case 'p': // vp = parametrized coords -- unhandled EndLine(it, objText.end()); break; default: // v = vertex position pos.push_back(ParseObjPosition(it, objText.end())); break; } break; case 'f': // f = face face.push_back(ParseObjFace(++it, objText.end())); break; default: // skip this line EndLine(it, objText.end()); break; }; } m_pos.swap(pos); m_tex.swap(tex); m_norm.swap(norm); m_face.swap(face); }
static void sendCommand(const char *string) { // Prepare Buffer for Response while (*string) { EUSART_Write(*string++); } EndLine(); }
static void FreeMacExp (MacExp* E) /* Remove and free the current macro expansion */ { unsigned I; /* One macro expansion less */ --MacExpansions; /* No longer expanding this macro */ --E->M->Expansions; /* Free the parameter lists */ for (I = 0; I < E->ParamCount; ++I) { /* Free one parameter list */ TokNode* N = E->Params[I]; while (N) { TokNode* P = N->Next; FreeTokNode (N); N = P; } } xfree (E->Params); /* Free the additional line info */ if (E->ParamLI) { EndLine (E->ParamLI); } if (E->LI) { EndLine (E->LI); } /* Free the final token if we have one */ if (E->Final) { FreeTokNode (E->Final); } /* Free the structure itself */ xfree (E); }
void DbgInfoLine (void) /* Parse and handle LINE subcommand of the .dbg pseudo instruction */ { long Line; FilePos Pos = STATIC_FILEPOS_INITIALIZER; /* Any new line info terminates the last one */ if (CurLineInfo) { EndLine (CurLineInfo); CurLineInfo = 0; } /* If a parameters follow, this is actual line info. If no parameters ** follow, the last line info is terminated. */ if (CurTok.Tok == TOK_SEP) { return; } /* Parameters are separated by a comma */ ConsumeComma (); /* The name of the file follows */ if (CurTok.Tok != TOK_STRCON) { ErrorSkip ("String constant expected"); return; } /* Get the index in the file table for the name */ Pos.Name = GetFileIndex (&CurTok.SVal); /* Skip the name */ NextTok (); /* Comma expected */ ConsumeComma (); /* Line number */ Line = ConstExpression (); if (Line < 0) { ErrorSkip ("Line number is out of valid range"); return; } Pos.Line = Line; /* Generate a new external line info */ CurLineInfo = StartLine (&Pos, LI_TYPE_EXT, 0); }
void CodeWriter::WriteLine(int indent, const char* fileName, int lineNumber, const char* format, ...) { va_list args; va_start(args, format); BeginLine(indent, fileName, lineNumber); char buffer[_maxLineLength]; int result = String_Printf(buffer, sizeof(buffer), format, args); ASSERT(result != -1); m_buffer += buffer; EndLine(); va_end(args); }
void CodeWriter::WriteLine(int indent, const char* format, ...) { va_list args; va_start(args, format); char buffer[_maxLineLength]; int result = String_Printf(buffer, sizeof(buffer), format, args); ASSERT(result != -1); for (int i = 0; i < indent * m_spacesPerIndent; ++i) { m_buffer += " "; } m_buffer += buffer; EndLine(); va_end(args); }
static void sendDataCommand(const char *string, uint8_t* appData, uint8_t dataLength) { // String while (*string) { EUSART_Write(*string++); } // Port No & space for (uint8_t byteCount = 0; byteCount < 3; byteCount++) { EUSART_Write(appData[byteCount]); } //Space EUSART_Write(appData[3]); //Data for (uint8_t byteCount = 4; byteCount < dataLength; byteCount++) { EUSART_Write(hexToStr(appData[byteCount] >> 4)); EUSART_Write(hexToStr(appData[byteCount] & 0x0F)); } EndLine(); }
ERMsg COutputFile::open(const std::string& filePath) { ERMsg msg = ofStream::open(filePath); if (msg) { assert(!m_parameters.empty()); for (size_t i = 0; i < m_parameters.size(); i++) { ((std::ofstream&)*this) << m_parameters[i].GetName(); ((std::ofstream&)*this) << m_separator; } EndLine(); flags(std::ios::fixed | std::ios::right); precision(5); } return msg; }
bool FChunkManifestGenerator::GenerateAssetChunkInformationCSV(const FString& OutputPath) { FString TmpString; FString CSVString; FString HeaderText(TEXT("ChunkID, Package Name, Class Type, Hard or Soft Chunk, File Size, Other Chunks\n")); FString EndLine(TEXT("\n")); FString NoneText(TEXT("None\n")); CSVString = HeaderText; for (int32 ChunkID = 0, ChunkNum = FinalChunkManifests.Num(); ChunkID < ChunkNum; ++ChunkID) { FString PerChunkManifestCSV = HeaderText; TMap<FName, FAssetData*> GeneratedAssetRegistryData; for (auto& AssetData : AssetRegistryData) { // Add only assets that have actually been cooked and belong to any chunk if (AssetData.ChunkIDs.Num() > 0) { FString Fullname; if (AssetData.ChunkIDs.Contains(ChunkID) && FPackageName::DoesPackageExist(*AssetData.PackageName.ToString(), nullptr, &Fullname)) { auto FileSize = IFileManager::Get().FileSize(*FPackageName::LongPackageNameToFilename(*AssetData.PackageName.ToString(), FPackageName::GetAssetPackageExtension())); if (FileSize == INDEX_NONE) { FileSize = IFileManager::Get().FileSize(*FPackageName::LongPackageNameToFilename(*AssetData.PackageName.ToString(), FPackageName::GetMapPackageExtension())); } if (FileSize == INDEX_NONE) { FileSize = 0; } FString SoftChain; bool bHardChunk = false; if (ChunkID < ChunkManifests.Num()) { bHardChunk = ChunkManifests[ChunkID] && ChunkManifests[ChunkID]->Contains(AssetData.PackageName); if (!bHardChunk) { // SoftChain = GetShortestReferenceChain(AssetData.PackageName, ChunkID); } } if (SoftChain.IsEmpty()) { SoftChain = TEXT("Soft: Possibly Unassigned Asset"); } TmpString = FString::Printf(TEXT("%d,%s,%s,%s,%lld,"), ChunkID, *AssetData.PackageName.ToString(), *AssetData.AssetClass.ToString(), bHardChunk ? TEXT("Hard") : *SoftChain, FileSize); CSVString += TmpString; PerChunkManifestCSV += TmpString; if (AssetData.ChunkIDs.Num() == 1) { CSVString += NoneText; PerChunkManifestCSV += NoneText; } else { for (const auto& OtherChunk : AssetData.ChunkIDs) { if (OtherChunk != ChunkID) { TmpString = FString::Printf(TEXT("%d "), OtherChunk); CSVString += TmpString; PerChunkManifestCSV += TmpString; } } CSVString += EndLine; PerChunkManifestCSV += EndLine; } } } } FFileHelper::SaveStringToFile(PerChunkManifestCSV, *FPaths::Combine(*OutputPath, *FString::Printf(TEXT("Chunks%dInfo.csv"), ChunkID))); } return FFileHelper::SaveStringToFile(CSVString, *FPaths::Combine(*OutputPath, TEXT("AllChunksInfo.csv"))); }
/// SingleComponentLSScan::ParseMCU // Parse a single MCU in this scan. Return true if there are more // MCUs in this row. bool SingleComponentLSScan::ParseMCU(void) { #if ACCUSOFT_CODE int lines = m_ulRemaining[0]; // total number of MCU lines processed. UBYTE preshift = m_ucLowBit + FractionalColorBitsOf(); struct Line *line = CurrentLine(0); // // If a DNL marker is present, the number of remaining lines is zero. Fix it. if (m_pFrame->HeightOf() == 0) { assert(lines == 0); lines = 8; } assert(m_ucCount == 1); // // A "MCU" in respect to the code organization is eight lines. if (lines > 8) { lines = 8; } if (m_pFrame->HeightOf() > 0) m_ulRemaining[0] -= lines; assert(lines > 0); // Loop over lines and columns do { LONG length = m_ulWidth[0]; LONG *lp = line->m_pData; #ifdef DEBUG_LS int xpos = 0; static int linenumber = 0; printf("\n%4d : ",++linenumber); #endif StartLine(0); if (BeginReadMCU(m_Stream.ByteStreamOf())) { // No error handling strategy. No RST in scans. Bummer! do { LONG a,b,c,d; // neighbouring values. LONG d1,d2,d3; // local gradients. GetContext(0,a,b,c,d); d1 = d - b; // compute local gradients d2 = b - c; d3 = c - a; if (isRunMode(d1,d2,d3)) { LONG run = DecodeRun(length,m_lRunIndex[0]); // // Now fill the data. while(run) { // Update so that the next process gets the correct value. UpdateContext(0,a); // And insert the value into the target line as well. *lp++ = a << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,a); #endif run--,length--; // As long as there are pixels on the line. } // // More data on the line? I.e. the run did not cover the full m_lJ samples? // Now decode the run interruption sample. if (length) { bool negative; // the sign variable bool rtype; // run interruption type LONG errval; // the prediction error LONG merr; // the mapped error (symbol) LONG rx; // the reconstructed value UBYTE k; // golomb parameter // Get the neighbourhood. GetContext(0,a,b,c,d); // Get the prediction mode. rtype = InterruptedPredictionMode(negative,a,b); // Get the golomb parameter for run interruption coding. k = GolombParameter(rtype); // Golomb-decode the error symbol. merr = GolombDecode(k,m_lLimit - m_lJ[m_lRunIndex[0]] - 1); // Inverse the error mapping procedure. errval = InverseErrorMapping(merr + rtype,ErrorMappingOffset(rtype,rtype || merr,k)); // Compute the reconstructed value. rx = Reconstruct(negative,rtype?a:b,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Fill in the value into the line *lp = rx << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,*lp); #endif // Update the variables of the run mode. UpdateState(rtype,errval); // Update the run index now. This is not part of // EncodeRun because the non-reduced run-index is // required for the golomb coder length limit. if (m_lRunIndex[0] > 0) m_lRunIndex[0]--; } else break; // end of line. } else { UWORD ctxt; bool negative; // the sign variable. LONG px; // the predicted variable. LONG rx; // the reconstructed value. LONG errval; // the error value. LONG merr; // the mapped error value. UBYTE k; // the Golomb parameter. // Quantize the gradients. d1 = QuantizedGradient(d1); d2 = QuantizedGradient(d2); d3 = QuantizedGradient(d3); // Compute the context. ctxt = Context(negative,d1,d2,d3); // Compute the predicted value. px = Predict(a,b,c); // Correct the prediction. px = CorrectPrediction(ctxt,negative,px); // Compute the golomb parameter k from the context. k = GolombParameter(ctxt); // Decode the error symbol. merr = GolombDecode(k,m_lLimit); // Inverse the error symbol into an error value. errval = InverseErrorMapping(merr,ErrorMappingOffset(ctxt,k)); // Update the variables. UpdateState(ctxt,errval); // Compute the reconstructed value. rx = Reconstruct(negative,px,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // And insert the value into the target line as well. *lp = rx << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,*lp); #endif } } while(++lp,--length); } // No error handling here. EndLine(0); line = line->m_pNext; } while(--lines); // // If this is the last line, gobble up all the // bits from bitstuffing the last byte may have left. // As SkipStuffing is idempotent, we can also do that // all the time. m_Stream.SkipStuffing(); #endif return false; }
/// SingleComponentLSScan::WriteMCU // Write a single MCU in this scan. bool SingleComponentLSScan::WriteMCU(void) { #if ACCUSOFT_CODE int lines = m_ulRemaining[0]; // total number of MCU lines processed. UBYTE preshift = m_ucLowBit + FractionalColorBitsOf(); struct Line *line = CurrentLine(0); assert(m_ucCount == 1); // // A "MCU" in respect to the code organization is eight lines. if (lines > 8) { lines = 8; } m_ulRemaining[0] -= lines; assert(lines > 0); // Loop over lines and columns do { LONG length = m_ulWidth[0]; LONG *lp = line->m_pData; BeginWriteMCU(m_Stream.ByteStreamOf()); // MCU is a single line. StartLine(0); do { LONG a,b,c,d,x; // neighbouring values. LONG d1,d2,d3; // local gradients. GetContext(0,a,b,c,d); x = *lp >> preshift; d1 = d - b; // compute local gradients d2 = b - c; d3 = c - a; if (isRunMode(d1,d2,d3)) { LONG runval = a; LONG runcnt = 0; do { x = *lp >> preshift; if (x - runval < -m_lNear || x - runval > m_lNear) break; // Update so that the next process gets the correct value. // Also updates the line pointers. UpdateContext(0,runval); } while(lp++,runcnt++,--length); // Encode the run. Depends on whether the run was interrupted // by the end of the line. EncodeRun(runcnt,length == 0,m_lRunIndex[0]); // Continue the encoding of the end of the run if there are more // samples to encode. if (length) { bool negative; // the sign variable bool rtype; // run interruption type LONG errval; // the prediction error LONG merr; // the mapped error (symbol) LONG rx; // the reconstructed value UBYTE k; // golomb parameter // Get the neighbourhood. GetContext(0,a,b,c,d); // Get the prediction mode. rtype = InterruptedPredictionMode(negative,a,b); // Compute the error value. errval = x - ((rtype)?(a):(b)); if (negative) errval = -errval; // Quantize the error. errval = QuantizePredictionError(errval); // Compute the reconstructed value. rx = Reconstruct(negative,rtype?a:b,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Get the golomb parameter for run interruption coding. k = GolombParameter(rtype); // Map the error into a symbol. merr = ErrorMapping(errval,ErrorMappingOffset(rtype,errval != 0,k)) - rtype; // Golomb-coding of the error. GolombCode(k,merr,m_lLimit - m_lJ[m_lRunIndex[0]] - 1); // Update the variables of the run mode. UpdateState(rtype,errval); // Update the run index now. This is not part of // EncodeRun because the non-reduced run-index is // required for the golomb coder length limit. if (m_lRunIndex[0] > 0) m_lRunIndex[0]--; } else break; // Line ended, abort the loop over the line. } else { UWORD ctxt; bool negative; // the sign variable. LONG px; // the predicted variable. LONG rx; // the reconstructed value. LONG errval; // the error value. LONG merr; // the mapped error value. UBYTE k; // the Golomb parameter. // Quantize the gradients. d1 = QuantizedGradient(d1); d2 = QuantizedGradient(d2); d3 = QuantizedGradient(d3); // Compute the context. ctxt = Context(negative,d1,d2,d3); // Compute the predicted value. px = Predict(a,b,c); // Correct the prediction. px = CorrectPrediction(ctxt,negative,px); // Compute the error value. errval = x - px; if (negative) errval = -errval; // Quantize the prediction error if NEAR > 0 errval = QuantizePredictionError(errval); // Compute the reconstructed value. rx = Reconstruct(negative,px,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Compute the golomb parameter k from the context. k = GolombParameter(ctxt); // Map the error into a symbol merr = ErrorMapping(errval,ErrorMappingOffset(ctxt,k)); // Golomb-coding of the error. GolombCode(k,merr,m_lLimit); // Update the variables. UpdateState(ctxt,errval); } } while(++lp,--length); EndLine(0); line = line->m_pNext; } while(--lines);
static int MacExpand (void* Data) /* If we're currently expanding a macro, set the the scanner token and * attribute to the next value and return true. If we are not expanding * a macro, return false. */ { /* Cast the Data pointer to the actual data structure */ MacExp* Mac = (MacExp*) Data; /* Check if we should abort this macro */ if (DoMacAbort) { /* Reset the flag */ DoMacAbort = 0; /* Abort any open .IF statements in this macro expansion */ CleanupIfStack (Mac->IfSP); /* Terminate macro expansion */ goto MacEnd; } /* We're expanding a macro. Check if we are expanding one of the * macro parameters. */ ExpandParam: if (Mac->ParamExp) { /* Ok, use token from parameter list */ TokSet (Mac->ParamExp); /* Create new line info for this parameter token */ if (Mac->ParamLI) { EndLine (Mac->ParamLI); } Mac->ParamLI = StartLine (&CurTok.Pos, LI_TYPE_MACPARAM, Mac->MacExpansions); /* Set pointer to next token */ Mac->ParamExp = Mac->ParamExp->Next; /* Done */ return 1; } else if (Mac->ParamLI) { /* There's still line info open from the parameter expansion - end it */ EndLine (Mac->ParamLI); Mac->ParamLI = 0; } /* We're not expanding macro parameters. Check if we have tokens left from * the macro itself. */ if (Mac->Exp) { /* Use next macro token */ TokSet (Mac->Exp); /* Create new line info for this token */ if (Mac->LI) { EndLine (Mac->LI); } Mac->LI = StartLine (&CurTok.Pos, LI_TYPE_MACRO, Mac->MacExpansions); /* Set pointer to next token */ Mac->Exp = Mac->Exp->Next; /* Is it a request for actual parameter count? */ if (CurTok.Tok == TOK_PARAMCOUNT) { CurTok.Tok = TOK_INTCON; CurTok.IVal = Mac->ParamCount; return 1; } /* Is it the name of a macro parameter? */ if (CurTok.Tok == TOK_MACPARAM) { /* Start to expand the parameter token list */ Mac->ParamExp = Mac->Params[CurTok.IVal]; /* Go back and expand the parameter */ goto ExpandParam; } /* If it's an identifier, it may in fact be a local symbol */ if ((CurTok.Tok == TOK_IDENT || CurTok.Tok == TOK_LOCAL_IDENT) && Mac->M->LocalCount) { /* Search for the local symbol in the list */ unsigned Index = 0; IdDesc* I = Mac->M->Locals; while (I) { if (SB_Compare (&CurTok.SVal, &I->Id) == 0) { /* This is in fact a local symbol, change the name. Be sure * to generate a local label name if the original name was * a local label, and also generate a name that cannot be * generated by a user. */ if (SB_At (&I->Id, 0) == LocalStart) { /* Must generate a local symbol */ SB_Printf (&CurTok.SVal, "%cLOCAL-MACRO_SYMBOL-%04X", LocalStart, Mac->LocalStart + Index); } else { /* Global symbol */ SB_Printf (&CurTok.SVal, "LOCAL-MACRO_SYMBOL-%04X", Mac->LocalStart + Index); } break; } /* Next symbol */ ++Index; I = I->Next; } /* Done */ return 1; } /* The token was successfully set */ return 1; } /* No more macro tokens. Do we have a final token? */ if (Mac->Final) { /* Set the final token and remove it */ TokSet (Mac->Final); FreeTokNode (Mac->Final); Mac->Final = 0; /* Problem: When a .define style macro is expanded within the call * of a classic one, the latter may be terminated and removed while * the expansion of the .define style macro is still active. Because * line info slots are "stacked", this runs into a CHECK FAILED. For * now, we will fix that by removing the .define style macro expansion * immediately, once the final token is placed. The better solution * would probably be to not require AllocLineInfoSlot/FreeLineInfoSlot * to be called in FIFO order, but this is a bigger change. */ /* End of macro expansion and pop the input function */ FreeMacExp (Mac); PopInput (); /* The token was successfully set */ return 1; } MacEnd: /* End of macro expansion */ FreeMacExp (Mac); /* Pop the input function */ PopInput (); /* No token available */ return 0; }
void scSelection::MoveSelect( eSelectMove moveSelect ) { int setmax = 1; switch ( moveSelect ) { case ePrevChar: case eNextChar: case ePrevCharInPara: case eNextCharInPara: SLCCharacterMove( *this, moveSelect ); break; case ePrevWord: PrevWord( ); break; case eNextWord: NextWord( ); break; case ePrevSpellWord: PrevSpellWord( ); break; case eNextSpellWord: NextSpellWord( ); break; case eStartWord: StartWord( ); break; case eEndWord: EndWord( ); break; case ePrevEntireLine: PrevEntireLine(); break; case eNextEntireLine: NextEntireLine(); break; case ePrevLine: PrevLine(); setmax = 0; break; case eNextLine: NextLine(); setmax = 0; break; case eStartLine: StartLine(); break; case eEndLine: EndLine(); break; case ePrevPara: case eNextPara: case eFirstPara: case eLastPara: Para( moveSelect ); break; case eBeginPara: BeginPara(); break; case eEndPara: EndPara(); break; case ePrevEntireColumn: PrevColumn(); break; case eNextEntireColumn: NextColumn(); break; case eBeginColumn: StartColumn( ); break; case eEndColumn: EndColumn(); break; case eStartStream: fMark.SelectStartStream(); fPoint.SelectStartStream(); break; case eEndStream: fMark.SelectEndStream(); fPoint.SelectEndStream(); break; default: SCDebugBreak(); break; } fMark.UpdateInfo( setmax ); fPoint.UpdateInfo( setmax ); }