Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Chisel/Chisel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
7ABD17981DF7F998006118F8 /* ChiselTests */,
7ABD178C1DF7F998006118F8 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
};
7ABD178C1DF7F998006118F8 /* Products */ = {
Expand Down
42 changes: 33 additions & 9 deletions Chisel/Chisel/CHLObjcInstanceCommands.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ void PrintInstances(const char *type, const char *pred)
{
NSPredicate *predicate = nil;
if (pred != nullptr && *pred != '\0') {
predicate = [NSPredicate predicateWithFormat:@(pred)];
@try {
predicate = [NSPredicate predicateWithFormat:@(pred)];
} @catch (NSException *e) {
printf("Error: Invalid predicate; %s\n", [e reason].UTF8String);
return;
}
}

const std::unordered_set<Class> objcClasses = CHLObjcClassSet();
Expand All @@ -144,17 +149,36 @@ void PrintInstances(const char *type, const char *pred)
}
}

bool exactClass = false;
if (type[0] == '*') {
exactClass = true;
++type;
Class cls = objc_getClass(type);
if (cls != nullptr) {
}

auto addMatch = [&](Class cls) {
if (exactClass) {
matchClasses.insert(cls);
} else {
for (auto c : objcClasses) {
if (isSubclassOf(c, cls)) {
matchClasses.insert(c);
}
}
}
} else if (Class kind = objc_getClass(type)) {
// This could be optimized for type == "NSObject", but it won't be a typical search.
for (auto cls : objcClasses) {
if (isSubclassOf(cls, kind)) {
matchClasses.insert(cls);
};

Class cls = objc_getClass(type);
if (cls != Nil) {
addMatch(cls);
} else {
// The given class name hasn't been found, this could be a Swift class which case has
// a module name prefix. Loop over all classes to look for matching class names.
for (auto c : objcClasses) {
// SwiftModule.ClassName
// ^- dot + 1
auto dot = strchr(class_getName(c), '.');
if (dot && strcmp(type, dot + 1) == 0) {
addMatch(c);
}
}
}
Expand All @@ -167,7 +191,7 @@ void PrintInstances(const char *type, const char *pred)

NSSet *keyPaths = CHLVariableKeyPaths(predicate);

std::vector<id, zone_allocator<id>> instances = CHLScanObjcInstances(matchClasses);
auto instances = CHLScanObjcInstances(matchClasses);
unsigned int matches = 0;

for (id obj : instances) {
Expand Down
4 changes: 2 additions & 2 deletions Chisel/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PREFIX ?= /usr/local/lib

export INSTALL_NAME = ""
ifneq ($(LD_DYLIB_INSTALL_NAME), "")
export INSTALL_NAME =
ifneq ($(LD_DYLIB_INSTALL_NAME),)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keith does this change look legit? The original here was still adding LD_DYLIB_INSTALL_NAME=... to xcodebuild command, but this change appears to fix that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea seems fine, shouldn't have had the quotes in the first place I think, my bad.

INSTALL_NAME = "LD_DYLIB_INSTALL_NAME=$(LD_DYLIB_INSTALL_NAME)"
endif

Expand Down