Skip to content

Commit

Permalink
Remove factory functions
Browse files Browse the repository at this point in the history
Adding overloads for these would add more clutter than utility. We
should remove these from all of the types as the constructors should
always be used to ensure class invariants.
  • Loading branch information
Tim Haines committed Nov 24, 2021
1 parent cf56fef commit 345c96c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
4 changes: 1 addition & 3 deletions symtabAPI/h/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,7 @@ class SYMTAB_EXPORT typeEnum : public derivedType {
typeEnum(boost::shared_ptr<Type> underlying_type, std::string name, typeId_t ID);
typeEnum(boost::shared_ptr<Type> underlying_type, std::string name, typeId_t ID, scoped_t) :
typeEnum(underlying_type, std::move(name), ID) { is_scoped_=true; }
static typeEnum *create(std::string &name, dyn_c_vector<std::pair<std::string, int> *>&elements,
Symtab *obj = NULL);
static typeEnum *create(std::string &name, dyn_c_vector<std::string> &constNames, Symtab *obj);

bool addConstant(const std::string &fieldname,int value);
dyn_c_vector<std::pair<std::string, int> > &getConstants();
bool isCompatible(boost::shared_ptr<Type> x) { return isCompatible(x.get()); }
Expand Down
25 changes: 0 additions & 25 deletions symtabAPI/src/Type.C
Original file line number Diff line number Diff line change
Expand Up @@ -309,31 +309,6 @@ typeEnum::typeEnum(boost::shared_ptr<Type> underlying_type, std::string name, ty
typeEnum::typeEnum(boost::shared_ptr<Type> underlying_type, std::string name) :
typeEnum(underlying_type, name, ::getUniqueTypeId()) {}

typeEnum *typeEnum::create(std::string &name, dyn_c_vector< std::pair<std::string, int> *> &constants, Symtab *obj)
{
typeEnum *typ = new typeEnum(name);
for(unsigned i=0; i<constants.size();i++)
typ->addConstant(constants[i]->first, constants[i]->second);

if(obj)
obj->addType(typ);
//obj->addType(typ); TODO: declare a static container if obj is NULL and add to it.
//Symtab::noObjTypes->push_back(typ); ??
return typ;
}

typeEnum *typeEnum::create(std::string &name, dyn_c_vector<std::string> &constNames, Symtab *obj)
{
typeEnum *typ = new typeEnum(name);
for(unsigned i=0; i<constNames.size();i++)
typ->addConstant(constNames[i], i);
if(obj)
obj->addType(typ);
//obj->addType(typ); TODO: declare a static container if obj is NULL and add to it.
//Symtab::noObjTypes->push_back(typ); ??
return typ;
}

dyn_c_vector<std::pair<std::string, int> > &typeEnum::getConstants()
{
return consts;
Expand Down

0 comments on commit 345c96c

Please sign in to comment.