void ARMAttributeParser::DIV_use(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "If Available", "Not Permitted", "Permitted" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::Advanced_SIMD_arch(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "NEONv1", "NEONv2+FMA", "ARMv8-a NEON" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_PCS_GOT_use(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *const Strings[] = { "Not Permitted", "Direct", "GOT-Indirect" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_HardFP_use(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Tag_FP_arch", "Single-Precision", "Reserved", "Tag_FP_arch (deprecated)" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_FP_number_model(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "Finite Only", "RTABI", "IEEE-754" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_PCS_wchar_t(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "Unknown", "2-byte", "Unknown", "4-byte" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_VFP_args(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "AAPCS", "AAPCS VFP", "Custom", "Not Permitted" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_PCS_RW_data(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Absolute", "PC-relative", "SB-relative", "Not Permitted" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_FP_denormal(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *const Strings[] = { "Unsupported", "IEEE-754", "Sign Only" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "Packed", "Int32", "External Int32" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::PCS_config(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "None", "Bare Platform", "Linux Application", "Linux DSO", "Palm OS 2004", "Reserved (Palm OS)", "Symbian OS 2004", "Reserved (Symbian OS)" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::FP_arch(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16", "ARMv8-a FP", "ARMv8-a FP-D16" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::Virtualization_use(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "TrustZone", "Virtualization Extensions", "TrustZone + Virtualization Extensions" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::CPU_arch(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Pre-v4", "ARM v4", "ARM v4T", "ARM v5T", "ARM v5TE", "ARM v5TEJ", "ARM v6", "ARM v6KZ", "ARM v6T2", "ARM v6K", "ARM v7", "ARM v6-M", "ARM v6S-M", "ARM v7E-M", "ARM v8" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
void ARMAttributeParser::ABI_FP_optimization_goals(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "None", "Speed", "Aggressive Speed", "Size", "Aggressive Size", "Accuracy", "Best Accuracy" }; uint64_t Value = ParseInteger(Data, Offset); StringRef ValueDesc = (Value < array_lengthof(Strings)) ? Strings[Value] : nullptr; PrintAttribute(Tag, Value, ValueDesc); }
bool nsMediaFragmentURIParser::ParseXYWH(nsDependentSubstring aString) { int32_t x, y, w, h; ClipUnit clipUnit; // Determine units. if (StringBeginsWith(aString, NS_LITERAL_STRING("pixel:"))) { clipUnit = eClipUnit_Pixel; aString.Rebind(aString, 6); } else if (StringBeginsWith(aString, NS_LITERAL_STRING("percent:"))) { clipUnit = eClipUnit_Percent; aString.Rebind(aString, 8); } else { clipUnit = eClipUnit_Pixel; } // Read and validate coordinates. if (ParseInteger(aString, x) && x >= 0 && ParseCommaSeparator(aString) && ParseInteger(aString, y) && y >= 0 && ParseCommaSeparator(aString) && ParseInteger(aString, w) && w > 0 && ParseCommaSeparator(aString) && ParseInteger(aString, h) && h > 0 && aString.Length() == 0) { // Reject invalid percentage coordinates. if (clipUnit == eClipUnit_Percent && (x + w > 100 || y + h > 100)) { return false; } mClip.construct(x, y, w, h); mClipUnit = clipUnit; return true; } return false; }
bool ObjectImporter::Import(std::wstring file, ImportedObjectData* rawData) { size_t first = file.find_last_of('\\') + 1; size_t last = file.find_last_of('.'); rawData->name = file.substr(first, last-first); std::wifstream in (file); if(!in.is_open()) { std::wstring msg = L"Failed to open file: \n"; msg.append(file); MessageBox(0, msg.c_str(), L"Import error", 0); return false; } else { std::wstring buff; while (!in.eof()) { in >> buff; if(buff.size()) { if(buff == ObjImpFormat::animationCount) { int count = 0; if(!ParseInteger(in, count)) return false; if(count) { rawData->animations.resize(count); if(!ParseAnimationFile(in, rawData)) return false; } else if(!ParseStandardFile(in, rawData)) return false; } else { ParseLine(in, true); } } } in.close(); } return true; }
void NumericEdit::__EditCompleted( Edit& sender ) { if ( busy ) return; if ( sender.IsReadOnly() ) return; busy = true; try { double newValue; bool hasChanged = false; if ( isReal ) { double tolerance = Pow10I<double>()( -int( precision + 1 ) ); newValue = ParseReal( sender.Text(), lowerBound, upperBound, tolerance ); newValue = Round( newValue, ActualPrecision( precision, newValue ) ); hasChanged = Sign( newValue ) != Sign( value ) || Abs( newValue - value ) > tolerance; } else { newValue = ParseInteger( sender.Text(), lowerBound, upperBound ); hasChanged = newValue != value; } if ( hasChanged ) { value = newValue; UpdateControls(); if ( onValueUpdated != 0 ) (onValueUpdatedReceiver->*onValueUpdated)( *this, value ); } else UpdateControls(); busy = false; return; } ERROR_HANDLER busy = false; UpdateControls(); }
void Parser::ParseRenderer() { unsigned int bounce = 5; unsigned int samplesPerPixel = 4; while (HasNextTag()) { std::string tag = NextTag(); if (tag == "bounce") { SkipSpace(); bounce = ParseInteger(); } else if (tag == "sample") { SkipSpace(); samplesPerPixel = ParseInteger(); } else if (tag == "/renderer") { renderer = new Renderer(bounce, samplesPerPixel); break; } } }
void ARMAttributeParser::CPU_arch_profile(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { uint64_t Encoded = ParseInteger(Data, Offset); StringRef Profile; switch (Encoded) { default: Profile = "Unknown"; break; case 'A': Profile = "Application"; break; case 'R': Profile = "Real-time"; break; case 'M': Profile = "Microcontroller"; break; case 'S': Profile = "Classic"; break; case '0': Profile = "None"; break; } PrintAttribute(Tag, Encoded, Profile); }
double ParseDouble(const char* p) { float s = p[0]=='-' ? -1.0f : 1.0f; p += (p[0]=='-') | (p[0]=='+'); double r = 0; for(; p[0]>='0' && p[0]<='9'; ++p) r = r*10.0 + (double)(p[0] - '0'); if(p[0]=='.' || p[0]==',') { double k = 0.1; for(++p; p[0]>='0' && p[0]<='9'; ++p, k *= 0.1) r += k*(double)(p[0] - '0'); } if(p[0]=='e' || p[0]=='E') r *= pow(10.0, (double)ParseInteger(p + 1)); return r*s; }
void ARMAttributeParser::ABI_align_needed(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { static const char *Strings[] = { "Not Permitted", "8-byte alignment", "4-byte alignment", "Reserved" }; uint64_t Value = ParseInteger(Data, Offset); std::string Description; if (Value < array_lengthof(Strings)) Description = std::string(Strings[Value]); else if (Value <= 12) Description = std::string("8-byte alignment, ") + utostr(1 << Value) + std::string("-byte extended alignment"); else Description = "Invalid"; PrintAttribute(Tag, Value, Description); }
bool ParseStandardFile (std::wifstream& in, ImportedObjectData* d) { std::wstring flag; bool result = true; while(!in.eof()) { in >> flag; if(!in.eof()) { if(flag == ObjImpFormat::vertexCount) { int count = 0; if(!ParseInteger(in, count)) { DisplayText("File:\n" + in.getloc().name() + "\nDoes not contain any vertex information"); return false; } else if(!count) { DisplayText("File:\n" + in.getloc().name() + "\nHas invalid vertex count (0)"); return false; } //No animations, then only one mesh is valid d->objects.resize(1); d->objects[0].vertex = new std::vector<VERTEX::VertexPNT>(count); d->objects[0].material = 0; } else if(flag == ObjImpFormat::material) { d->objects[0].material = ParseMaterial(in); } else if(flag == ObjImpFormat::v) { result = ParseV(in,d->objects[0]); } else if(flag == ObjImpFormat::vt) { result = ParseVT(in,d->objects[0]); } else if(flag == ObjImpFormat::vn) { result = ParseVN(in,d->objects[0]); } else if(flag == ObjImpFormat::comment) { ParseLine(in, true); } if(!result) return result; } } return result; }
void ARMAttributeParser::compatibility(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { uint64_t Integer = ParseInteger(Data, Offset); StringRef String = ParseString(Data, Offset); DictScope AS(SW, "Attribute"); SW.printNumber("Tag", Tag); SW.startLine() << "Value: " << Integer << ", " << String << '\n'; SW.printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false)); switch (Integer) { case 0: SW.printString("Description", StringRef("No Specific Requirements")); break; case 1: SW.printString("Description", StringRef("AEABI Conformant")); break; default: SW.printString("Description", StringRef("AEABI Non-Conformant")); break; } }
int ParseMaterial (std::wifstream& in) { ObjectMaterial::OBJECT_MATERIAL_DESC md; md.device = D3DShell::self()->getDevice(); md.dc = D3DShell::self()->getDeviceContext(); md.name = ParseLine(in); std::wstring buffer = L""; bool done = false; std::vector<std::streamoff> val; do { in >> buffer; if(buffer.size()) { if(buffer == ObjImpFormat::ambient) { ParseVector4(in, md.ambient); } else if(buffer == ObjImpFormat::diffuse) { ParseVector4(in, md.diffuse); } else if(buffer == ObjImpFormat::specular) { ParseVector4(in, md.specular); } else if(buffer == ObjImpFormat::specularPower) { ParseInteger(in, md.specualarPow); } else if(buffer == ObjImpFormat::ambientTexture) { md.ambientTexture = ParseLine(in); } else if(buffer == ObjImpFormat::diffuseTexture) { md.diffuseTexture = ParseLine(in); } else if(buffer == ObjImpFormat::specularTexture) { md.specularTexture = ParseLine(in); } else if(buffer == ObjImpFormat::glowTexture) { md.glowTexture = ParseLine(in); } else if(buffer == ObjImpFormat::normalTexture) { md.normalTexture = ParseLine(in); } else if(buffer == ObjImpFormat::comment) { ParseLine(in, true); } else if(buffer == ObjImpFormat::endMaterial) { done = true; //Return newly created material id return MaterialHandler::AddMaterial(md); } } } while (!done || !in.eof()); return -1; }
//top level parse function sgdm::StackGuard<JsonValue>&& JsonParser::ParsePrimary(){ switch(currentTok){ case tok_endl: return std::move(Error("primary fail")); case tok_identifier: return std::move(ParseName()); case tok_integer: return std::move(ParseInteger()); case tok_double: return std::move(ParseDouble()); case '[': return std::move(ParseArray(alloc)); case '{': return std::move(ParseObject(alloc)); default: return std::move(Error("unknown token found near place" + std::to_string(indexCount))); } sgdm::StackGuard<JsonValue>&& JsonParser::Parse(){ getNextTok(); return std::move(ParsePrimary(alloc)); }
void ARMAttributeParser::IntegerAttribute(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { SW.printNumber(ARMBuildAttrs::AttrTypeAsString(Tag), ParseInteger(Data, Offset)); }
void ARMAttributeParser::nodefaults(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { uint64_t Value = ParseInteger(Data, Offset); PrintAttribute(Tag, Value, "Unspecified Tags UNDEFINED"); }
static int Open(vlc_object_t *object) { demux_t *demux = (demux_t*)object; const uint8_t *peek; if (vlc_stream_Peek(demux->s, &peek, 11) != 11) return VLC_EGENERIC; bool is_stl_25 = !memcmp(&peek[3], "STL25.01", 8); bool is_stl_30 = !memcmp(&peek[3], "STL30.01", 8); if (!is_stl_25 && !is_stl_30) return VLC_EGENERIC; const double fps = is_stl_25 ? 25 : 30; uint8_t header[1024]; if (vlc_stream_Read(demux->s, header, sizeof(header)) != sizeof(header)) { msg_Err(demux, "Incomplete EBU STL header"); return VLC_EGENERIC; } const int cct = ParseInteger(&header[12], 2); const mtime_t program_start = ParseTextTimeCode(&header[256], fps); const int tti_count = ParseInteger(&header[238], 5); msg_Dbg(demux, "Detected EBU STL : CCT=%d TTI=%d start=%8.8s %"PRId64, cct, tti_count, &header[256], program_start); demux_sys_t *sys = xmalloc(sizeof(*sys)); sys->next_date = 0; sys->current = 0; sys->count = 0; sys->index = xcalloc(tti_count, sizeof(*sys->index)); bool comment = false; stl_entry_t *s = &sys->index[0]; s->count = 0; for (int i = 0; i < tti_count; i++) { uint8_t tti[16]; if (vlc_stream_Read(demux->s, tti, 16) != 16 || vlc_stream_Read(demux->s, NULL, 112) != 112) { msg_Warn(demux, "Incomplete EBU STL file"); break; } const int ebn = tti[3]; if (ebn >= 0xf0 && ebn <= 0xfd) continue; if (ebn == 0xfe) continue; if (s->count <= 0) { comment = tti[15] != 0; s->start = ParseTimeCode(&tti[5], fps) - program_start; s->stop = ParseTimeCode(&tti[9], fps) - program_start; s->index = i; } s->count++; if (ebn == 0xff && !comment) s = &sys->index[++sys->count]; if (ebn == 0xff && sys->count < tti_count) s->count = 0; } if (sys->count > 0) vlc_stream_Seek(demux->s, 1024 + 128LL * sys->index[0].index); es_format_t fmt; es_format_Init(&fmt, SPU_ES, VLC_CODEC_EBU_STL); fmt.i_extra = sizeof(header); fmt.p_extra = header; sys->es = es_out_Add(demux->out, &fmt); fmt.i_extra = 0; fmt.p_extra = NULL; es_format_Clean(&fmt); demux->p_sys = sys; demux->pf_demux = Demux; demux->pf_control = Control; return VLC_SUCCESS; }
void NoiseFloorCommand(int client) { int nfc[MCHAIN],nfe[MCHAIN]; int ip, np; int error; int attempt; int margin; int index; int code; int timeout; int ngot; int nf[2*MCHAIN]; int nfmany; char buffer[MBUFFER]; char *name; int frequency; int ht40; int rxchain; int reset; int bandwidth; // // prepare beginning of error message in case we need to use it // error=0; timeout= 100; nfmany=1; nf[0]=-110; margin=MERROR; attempt=MATTEMPT; frequency= -1; ht40=2; bandwidth=BW_AUTOMATIC; rxchain=0x7; reset=0; // // parse arguments and do it // np=CommandParameterMany(); for(ip=0; ip<np; ip++) { name=CommandParameterName(ip); index=ParameterSelectIndex(name,NoiseFloorParameter,sizeof(NoiseFloorParameter)/sizeof(NoiseFloorParameter[0])); if(index>=0) { code=NoiseFloorParameter[index].code; switch(code) { case LinkParameterFrequency: ngot=ParseIntegerList(ip,name,&frequency,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case LinkParameterHt40: ngot=ParseIntegerList(ip,name,&ht40,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } else { switch(ht40){ case 0: bandwidth=BW_HT20; break; case 1: bandwidth=BW_HT40_PLUS; break; case -1: bandwidth=BW_HT40_MINUS; break; case 2: bandwidth=BW_AUTOMATIC; break; default: error++; break; } } break; case LinkParameterChain: case LinkParameterRxChain: ngot=ParseIntegerList(ip,name,&rxchain,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case LinkParameterReset: ngot=ParseIntegerList(ip,name,&reset,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case NoiseFloorValue: nfmany=ParseInteger(ip,name,2*MCHAIN,nf); if(nfmany<=0) { error++; } break; case NoiseFloorTimeout: ngot=ParseInteger(ip,name,1,&timeout); if(ngot<=0) { error++; } break; case NoiseFloorMargin: ngot=ParseInteger(ip,name,1,&margin); if(ngot<=0) { error++; } break; case NoiseFloorAttempt: ngot=ParseInteger(ip,name,1,&attempt); if(ngot<=0) { error++; } break; case LinkParameterBandwidth: ngot=ParseIntegerList(ip,name,&bandwidth,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; default: ErrorPrint(ParseBadParameter,name); error++; break; } } else { error++; ErrorPrint(ParseBadParameter,name); } } if(nfmany<=0) { SendError(client,"target noise floor value is required."); error++; } if(reset) { if(frequency<=0) { SendError(client,"frequency is required."); error++; } } if(attempt>0 && (attempt%2)==0) { attempt++; } // // do it // if(error==0) { // // if there's no card loaded, return error // if(CardCheckAndLoad(-1)!=0) { ErrorPrint(CardNoneLoaded); return; } if(frequency>0) { error=CardResetIfNeeded(frequency,rxchain,rxchain,reset,bandwidth); if(error!=0) { return; } } error=NoiseFloorDo(frequency,nf,nfmany,margin,attempt,timeout,0,nfc,nfe,MCHAIN); if(error!=0) { SformatOutput(buffer,MBUFFER-1,"Noise Floor Calibration error = %d",error); buffer[MBUFFER-1]=0; SendError(client,buffer); } } SendDone(client); }