]> git.saurik.com Git - cycript.git/blobdiff - Analyze.cpp
Instance's toPointer() should return as CFTypeRef.
[cycript.git] / Analyze.cpp
index f1ef1073652197e10ebad5b610b8d713ca96f610..9a056e5993ae68b7571fa64f2b23af3145a577ae 100644 (file)
@@ -367,8 +367,10 @@ static void CYParseType(CXType type, CYType *typed) {
         } break;
 
         case CXType_Bool: typed->specifier_ = $ CYTypeVariable("bool"); break;
-        case CXType_Float: typed->specifier_ = $ CYTypeVariable("float"); break;
-        case CXType_Double: typed->specifier_ = $ CYTypeVariable("double"); break;
+        case CXType_WChar: typed->specifier_ = $ CYTypeVariable("wchar_t"); break;
+        case CXType_Float: typed->specifier_ = $ CYTypeFloating(0); break;
+        case CXType_Double: typed->specifier_ = $ CYTypeFloating(1); break;
+        case CXType_LongDouble: typed->specifier_ = $ CYTypeFloating(2); break;
 
         case CXType_Char_U: typed->specifier_ = $ CYTypeCharacter(CYTypeNeutral); break;
         case CXType_Char_S: typed->specifier_ = $ CYTypeCharacter(CYTypeNeutral); break;
@@ -500,6 +502,10 @@ static CXChildVisitResult CYChildVisit(CXCursor cursor, CXCursor parent, CXClien
         } break;
 
         case CXCursor_EnumDecl: {
+            // the enum constants are implemented separately *also*
+            // XXX: maybe move output logic to function we can call
+            result = CXChildVisit_Recurse;
+
             if (spelling[0] == '\0')
                 goto skip;
             // XXX: this was blindly copied from StructDecl
@@ -518,10 +524,6 @@ static CXChildVisitResult CYChildVisit(CXCursor cursor, CXCursor parent, CXClien
             value << ".withName(\"" << name << "\")";
             name = "$cye" + name;
             flags = CYBridgeType;
-
-            // the enum constants are implemented separately *also*
-            // XXX: maybe move output logic to function we can call
-            result = CXChildVisit_Recurse;
         } break;
 
         case CXCursor_MacroDefinition: {
@@ -654,8 +656,13 @@ static CXChildVisitResult CYChildVisit(CXCursor cursor, CXCursor parent, CXClien
                 goto skip;
 
             if (code == NULL) {
+                value << "*";
                 CXType type(clang_getCursorType(cursor));
-                value << "*(typedef " << CYCXString(clang_getTypeSpelling(type)) << ").pointerTo()(dlsym(RTLD_DEFAULT,'" << label.substr(1) << "'))";
+                CYType *typed(CYDecodeType(type));
+                CYOptions options;
+                CYOutput out(*value.rdbuf(), options);
+                CYTypeExpression(typed).Output(out, CYNoBFC);
+                value << ".pointerTo()(dlsym(RTLD_DEFAULT,'" << label.substr(1) << "'))";
             } else {
                 CYOptions options;
                 CYOutput out(*value.rdbuf(), options);