void UpdateFieldDumper::BuildUpdateFieldEnum(Enum& enumData, std::string const& name, std::vector<UpdateField> const& data, std::string const& end, std::string const& fieldBase) { enumData.SetName(name); std::uint32_t i = 0; while (i < data.size()) { UpdateField const* field = &data[i]; std::string name = GetInputData()->GetString(data[i].NameAddress); if (name == "CGUnitData::npcFlags[UMNW0]") { name = "CGUnitData::npcFlags"; field = &data[i + 1]; } std::string oldName = GetOldName(name.c_str()); if (!oldName.empty()) name = oldName; enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), name, static_cast<std::ostringstream&>(std::ostringstream() << "Size: " << field->Size << ", Flags: " << GetUpdateFieldFlagName(field->Flags)).str())); i += field->Size; } enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), end, "")); }
bool CheckSpecifier::visit(EnumSpecifierAST *ast) { unsigned sourceLocation = ast->firstToken(); if (ast->name) sourceLocation = ast->name->firstToken(); Name *name = semantic()->check(ast->name, _scope); Enum *e = control()->newEnum(sourceLocation, name); e->setStartOffset(tokenAt(ast->firstToken()).offset); e->setEndOffset(tokenAt(ast->lastToken()).offset); e->setVisibility(semantic()->currentVisibility()); _scope->enterSymbol(e); _fullySpecifiedType.setType(e); for (EnumeratorAST *enumerator = ast->enumerators; enumerator; enumerator = enumerator->next) { Identifier *id = identifier(enumerator->identifier_token); if (! id) continue; NameId *enumeratorName = control()->nameId(id); Declaration *decl = control()->newDeclaration(enumerator->firstToken(), enumeratorName); e->addMember(decl); } accept(ast->next); return false; }
void AlgorithmWidget::property(const char* name, Enum& value) { QStringList enums; for (int i = 0; i < value.size(); ++i) enums << value.names()[i]; QtProperty* property = enum_manager->addProperty(nice_name(name)); enum_manager->setValue(property, value); enum_manager->setEnumNames(property, enums); property_browser->addProperty(property); enum_pointers[property] = &value; }
void DumpUIErrors(std::shared_ptr<Process> wow) { static std::uintptr_t const UIErrorsOffset = 0xCB01D0; static std::size_t const UIErrorsSize = 945; Enum uiErrors; uiErrors.SetName("GAME_ERROR_TYPE"); std::vector<UIErrorInfo> errors = wow->ReadArray<UIErrorInfo>(UIErrorsOffset, UIErrorsSize); for (std::size_t i = 0; i < errors.size(); ++i) { std::string error = wow->Read<std::string>(errors[i].ErrorName); if (!error.empty()) uiErrors.AddMember(Enum::Member(i, error, "")); } DumpEnum(uiErrors, "UIErrors"); }
void DumpFrameXML_Events(std::shared_ptr<Process> wow) { static std::uintptr_t const FrameXML_EventsOffset = 0xE66430; static std::size_t const FrameXML_EventsSize = 1054; Enum frameXML; frameXML.SetName("FrameXML_Events"); std::vector<char const*> events = wow->ReadArray<char const*>(FrameXML_EventsOffset, FrameXML_EventsSize); for (std::size_t i = 0; i < events.size(); ++i) { std::string evt = wow->Read<std::string>(events[i]); if (!evt.empty()) frameXML.AddMember(Enum::Member(i, evt, "")); } DumpEnum(frameXML, "FrameXML_Events"); }
void PackageParser::parseEnum(const EmojicodeString &documentation, bool exported) { EmojicodeChar name, enamespace; parseAndValidateNewTypeName(&name, &enamespace); Enum *eenum = new Enum(name, package_, documentation); package_->registerType(Type(eenum, false), name, enamespace, exported); auto token = stream_.consumeToken(IDENTIFIER); if (token.value[0] != E_GRAPES) { ecCharToCharStack(token.value[0], s); throw CompilerErrorException(token, "Expected 🍇 but found %s instead.", s); } while (stream_.nextTokenIsEverythingBut(E_WATERMELON)) { eenum->addValueFor(stream_.consumeToken().value[0]); } stream_.consumeToken(IDENTIFIER); }
void UpdateFieldDumper::BuildDynamicUpdateFieldEnum(Enum& enumData, std::string const& name, std::vector<DynamicUpdateField> const& data, std::string const& end, std::string const& fieldBase) { enumData.SetName(name); std::uint32_t i = 0; while (i < data.size()) { DynamicUpdateField const* field = &data[i]; std::string name = GetInputData()->GetString(data[i].NameAddress); std::string oldName = GetOldName(name.c_str()); if (!oldName.empty()) name = oldName; enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), name, static_cast<std::ostringstream&>(std::ostringstream() << "Flags: " << GetUpdateFieldFlagName(field->Flags)).str())); ++i; } enumData.AddMember(Enum::Member(i, FormatValue(i, fieldBase), end, "")); }
// Enum *e = Module:EnumCreate(name) int li_module_enum_create(lua_State *L) { CHECK_COUNT("enumCreate",2) CHECK_ARGUMENT("enumCreate",2,string) // check we have a module, then convert it to a Module CHECK_ARGUMENT_TYPE("typeCreate",1,Module,m) // now create the Enum Enum *e = new Enum(m, new std::string(lua_tostring(L, 2))); if(e == NULL) gen_error("enum could not be created"); // now add this enum to the module m->objectAdd(new std::string(luaL_checkstring(L, 2)), e); CREATE_TABLE(L, e); e->lua_table(L); // now we just return the table :) return 1; }
MY_OPERATOR_SCOPE::MY_OPERATOR::UpdateType MY_OPERATOR_SCOPE::MY_OPERATOR::convertEnumToUpdateType(Enum const &e) { string value = e.getValue(); if(value == "NODE") { return MY_OPERATOR_SCOPE::MY_OPERATOR::NODE; } else if(value == "EDGE") { return MY_OPERATOR_SCOPE::MY_OPERATOR::EDGE; } else { // throw something throw("Invalid update type in convertEnumToUpdateType"); } }
MY_OPERATOR_SCOPE::MY_OPERATOR::UpdateFlags MY_OPERATOR_SCOPE::MY_OPERATOR::convertEnumToUpdateFlags(Enum const &e) { string value = e.getValue(); if(value == "ADD") { return MY_OPERATOR_SCOPE::MY_OPERATOR::ADD; } else if(value =="REMOVE") { return MY_OPERATOR_SCOPE::MY_OPERATOR::REMOVE; } else if(value == "CLEAR") { return MY_OPERATOR_SCOPE::MY_OPERATOR::CLEAR; } else { // throw something throw("Invalid update type in convertEnumToUpdateType"); } }
//------------------------------------------------------------------------------------------------- bool Enum::operator==(const Enum& other) const { return name() == other.name(); }
const bool Enum::operator > ( const Enum& other ) const { return value() > other.value(); }
void TalkyUnit::onEnumMember(const std::string name) { // cout << "new enum member " << name << endl; Enum* theEnum = dynamic_cast<Enum*> (currentDefinition); theEnum->onNewMember(name); }
const bool Enum::operator !=( const Enum& other ) const { return value() != other.value(); }
uint64_t DeltaCodeArr::lookup(uint64_t pos) const { Enum e; getEnum(pos, &e); return e.next(); }
void HeaderFile::parse() { Parser p( contents() ); p.scan( "\nclass " ); while ( !p.atEnd() ) { EString className = p.identifier(); EString superclass = 0; p.whitespace(); if ( p.lookingAt( ":" ) ) { p.step(); EString inheritance = p.word(); if ( inheritance != "public" ) { (void)new Error( this, p.line(), "Non-public inheritance for class " + className ); return; } EString parent = p.identifier(); if ( parent.isEmpty() ) { (void)new Error( this, p.line(), "Cannot parse superclass name for class " + className ); return; } superclass = parent; } p.whitespace(); if ( p.lookingAt( "{" ) ) { Class * c = Class::find( className ); if ( !c ) c = new Class( className, 0, 0 ); c->setParent( superclass ); if ( c && c->file() ) { (void) new Error( this, p.line(), "Class " + className + " conflicts with " + className + " at " + c->file()->name() + ":" + fn( c->line() ) ); (void) new Error( c->file(), c->line(), "Class " + className + " conflicts with " + className + " at " + name() + ":" + fn( p.line() ) ); } else { c->setSource( this, p.line() ); } p.step(); bool ok = false; do { ok = false; p.whitespace(); while ( p.lookingAt( "public:" ) || p.lookingAt( "private:" ) || p.lookingAt( "protected:" ) ) { p.scan( ":" ); p.step(); p.whitespace(); } if ( p.lookingAt( "virtual " ) ) p.scan( " " ); p.whitespace(); EString t; EString n; uint l = p.line(); if ( p.lookingAt( "operator " ) ) { n = p.identifier(); } else if ( p.lookingAt( "enum " ) ) { p.scan( " " ); Enum * e = new Enum( c, p.word(), this, l ); p.whitespace(); if ( p.lookingAt( "{" ) ) { bool again = true; while ( again ) { p.step(); p.whitespace(); EString v = p.word(); if ( v.isEmpty() ) (void)new Error( this, p.line(), "Could not parse " "enum value" ); else e->addValue( v ); p.whitespace(); if ( p.lookingAt( "=" ) ) { p.step(); p.whitespace(); (void)p.value(); p.whitespace(); } again = p.lookingAt( "," ); } if ( p.lookingAt( "}" ) ) { p.step(); ok = true; } else { (void)new Error( this, p.line(), "Enum definition for " + className + "::" + n + " does not end with '}'" ); } } else if ( p.lookingAt( ";" ) ) { // senseless crap ok = true; } else { (void)new Error( this, l, "Cannot parse enum " + className + "::" + n ); } } else if ( p.lookingAt( "typedef " ) ) { ok = true; } else { t = p.type(); n = p.identifier(); if ( n.isEmpty() ) { // constructor/destructor? if ( t == className || t == "~" + className ) { n = t; t = ""; } else if ( t.isEmpty() && p.lookingAt( "~" ) ) { p.step(); n = "~" + p.identifier(); } } } if ( !n.isEmpty() ) { p.whitespace(); if ( p.lookingAt( ";" ) ) ok = true; EString a = p.argumentList(); p.whitespace(); bool fc = false; if ( p.lookingAt( "const" ) ) { fc = true; p.word(); } if ( !n.isEmpty() && n.find( ':' ) < 0 && !a.isEmpty() ) { n = className + "::" + n; Function * f = Function::find( n, a, fc ); if ( !f ) f = new Function( t, n, a, fc, this, l ); ok = true; } } if ( ok ) { p.whitespace(); if ( p.lookingAt( "{" ) ) { uint level = 0; while ( level > 0 || p.lookingAt( "{" ) ) { if ( p.lookingAt( "{" ) ) { level++; } else if ( p.lookingAt( "}" ) ) { level--; } p.step(); p.whitespace(); } } else { p.scan( ";" ); } } } while ( ok ); } p.scan( "\nclass " ); } }
uint64_t DiffArray<IntArray>::lookup(uint64_t pos) const { Enum e; getEnum(pos, &e); return e.next(); }