From: Jay Freeman (saurik) <saurik@saurik.com>
Date: Sat, 15 Jun 2013 21:27:33 +0000 (-0700)
Subject: Don't rely on cc1obj for Objective-C struct tables.
X-Git-Tag: v0.9.500%b1~92
X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/5e7d51885f0a1062999ddaffc40bc73b26dd2c58

Don't rely on cc1obj for Objective-C struct tables.
---

diff --git a/.gitignore b/.gitignore
index 159fb21..a324699 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,5 @@ lex.cy.cpp
 cycript
 Trampoline.t.hpp
 Bridge.hpp
-Struct.hpp
 package
 aclocal.m4
diff --git a/Makefile.am b/Makefile.am
index fc22872..205c1c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,14 +49,6 @@ endif
 if CY_OBJECTIVEC
 filters += ObjectiveC
 libcycript_la_SOURCES += ObjectiveC/Output.mm ObjectiveC/Replace.cpp ObjectiveC/Library.mm
-
-ObjectiveC/Library.lo: Struct.hpp
-
-# XXX: this is not architecture-specific... isn't this just totally wrong?!
-# XXX: clang doesn't support this feature... that makes me really very sad.
-CLEANFILES += Struct.hpp
-Struct.hpp:
-	$$($(OBJCXX) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
 endif
 
 if CY_MACH
diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm
index f4a72d7..f0e6b20 100644
--- a/ObjectiveC/Library.mm
+++ b/ObjectiveC/Library.mm
@@ -19,10 +19,6 @@
 **/
 /* }}} */
 
-#ifdef __APPLE__
-#include "Struct.hpp"
-#endif
-
 #include <Foundation/Foundation.h>
 
 #include "ObjectiveC/Internal.hpp"
@@ -2166,6 +2162,18 @@ static void ObjectiveC_Constants_getPropertyNames(JSContextRef context, JSObject
 }
 
 #ifdef __APPLE__
+#if defined(__i386__) || defined(__x86_64__)
+#define OBJC_MAX_STRUCT_BY_VALUE 8
+static int struct_forward_array[] = {
+    0, 0, 0, 1, 0, 1, 1, 1, 0 };
+#elif defined(__arm__)
+#define OBJC_MAX_STRUCT_BY_VALUE 1
+static int struct_forward_array[] = {
+    0, 0 };
+#else
+#error missing objc-runtime-info
+#endif
+
 static bool stret(ffi_type *ffi_type) {
     return ffi_type->type == FFI_TYPE_STRUCT && (
         ffi_type->size > OBJC_MAX_STRUCT_BY_VALUE ||