From: Jay Freeman (saurik) Date: Sat, 9 Jan 2016 15:05:42 +0000 (-0800) Subject: Maintain type flags in Type subclass Copy() logic. X-Git-Tag: v0.9.590~21 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/0c172698f8957c8238cd9915ca09eb8a2b68db97 Maintain type flags in Type subclass Copy() logic. --- diff --git a/sig/copy.cpp b/sig/copy.cpp index 1f9decd..b8fc6b6 100644 --- a/sig/copy.cpp +++ b/sig/copy.cpp @@ -48,42 +48,42 @@ void Copy(CYPool &pool, Signature &lhs, const Signature &rhs) { } Void *Void::Copy(CYPool &pool, const char *rename) const { - return new(pool) Void(); + return Flag(new(pool) Void()); } Unknown *Unknown::Copy(CYPool &pool, const char *rename) const { - return new(pool) Unknown(); + return Flag(new(pool) Unknown()); } String *String::Copy(CYPool &pool, const char *rename) const { - return new(pool) String(); + return Flag(new(pool) String()); } #ifdef CY_OBJECTIVEC Meta *Meta::Copy(CYPool &pool, const char *rename) const { - return new(pool) Meta(); + return Flag(new(pool) Meta()); } Selector *Selector::Copy(CYPool &pool, const char *rename) const { - return new(pool) Selector(); + return Flag(new(pool) Selector()); } #endif Bits *Bits::Copy(CYPool &pool, const char *rename) const { - return new(pool) Bits(size); + return Flag(new(pool) Bits(size)); } Pointer *Pointer::Copy(CYPool &pool, const char *rename) const { - return new(pool) Pointer(*type.Copy(pool)); + return Flag(new(pool) Pointer(*type.Copy(pool))); } Array *Array::Copy(CYPool &pool, const char *rename) const { - return new(pool) Array(*type.Copy(pool), size); + return Flag(new(pool) Array(*type.Copy(pool), size)); } #ifdef CY_OBJECTIVEC Object *Object::Copy(CYPool &pool, const char *rename) const { - return new(pool) Object(pool.strdup(name)); + return Flag(new(pool) Object(pool.strdup(name))); } #endif @@ -98,7 +98,7 @@ Enum *Enum::Copy(CYPool &pool, const char *rename) const { copy->constants[i].name = pool.strdup(constants[i].name); copy->constants[i].value = constants[i].value; } - return copy; + return Flag(copy); } Aggregate *Aggregate::Copy(CYPool &pool, const char *rename) const { @@ -108,20 +108,20 @@ Aggregate *Aggregate::Copy(CYPool &pool, const char *rename) const { rename = NULL; Aggregate *copy(new(pool) Aggregate(overlap, rename)); sig::Copy(pool, copy->signature, signature); - return copy; + return Flag(copy); } Function *Function::Copy(CYPool &pool, const char *rename) const { Function *copy(new(pool) Function(variadic)); sig::Copy(pool, copy->signature, signature); - return copy; + return Flag(copy); } #ifdef CY_OBJECTIVEC Block *Block::Copy(CYPool &pool, const char *rename) const { Block *copy(new(pool) Block()); sig::Copy(pool, copy->signature, signature); - return copy; + return Flag(copy); } #endif diff --git a/sig/types.hpp b/sig/types.hpp index d32d1da..e98147c 100644 --- a/sig/types.hpp +++ b/sig/types.hpp @@ -57,6 +57,12 @@ struct Type { { } + template + _finline Type_ *Flag(Type_ *type) const { + type->flags = flags; + return type; + } + virtual Type *Copy(CYPool &pool, const char *rename = NULL) const = 0; virtual const char *GetName() const; @@ -73,7 +79,7 @@ struct Primitive : Type { Primitive *Copy(CYPool &pool, const char *name) const { - return new(pool) Primitive(); + return Flag(new(pool) Primitive()); } const char *Encode(CYPool &pool) const override;