this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Buildable but untested initial CoreServices code and misc changes

+281 -111
+1
CMakeLists.txt
··· 113 113 #add_subdirectory(src/libunwind-darwin-gcc) 114 114 add_subdirectory(src/libncurses) 115 115 add_subdirectory(src/CoreSecurity) 116 + add_subdirectory(src/CoreServices) 116 117 add_subdirectory(src/thin) 117 118 118 119 add_dependencies(dyld${SUFFIX} mach-o)
+2 -2
etc/dylib.conf
··· 4 4 libstdc++.6.dylib=libSystem.B.dylib.so 5 5 #libncurses.5.4.dylib=libncurses.so.5 6 6 #/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation=libCoreFoundation.so 7 - #/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation=libgnustep-corebase.so 8 - /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices=/dev/null 7 + /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation=libgnustep-corebase.so 8 + /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices=libCoreServices.so 9 9 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation=libobjc.A.dylib.so 10 10 /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit=libAppKit.so 11 11 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa=libCocoa.so
+41
src/CoreServices/CMakeLists.txt
··· 1 + project(CoreServices) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + if(COMMAND cmake_policy) 5 + cmake_policy(SET CMP0003 NEW) 6 + endif(COMMAND cmake_policy) 7 + 8 + enable_language(ASM_NASM) 9 + 10 + #if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 11 + # message(FATAL_ERROR "Clang is the only supported compiler.") 12 + #endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 13 + 14 + #configure_file(config.h.in config.h) 15 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") 16 + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks") 17 + 18 + #find_path(LIBCXX_INCLUDE_DIR c++/v1/vector) 19 + #if (DEFINED LIBCXX_INCLUDE_DIR) 20 + # message(STATUS "Found libcxx in ${LIBCXX_INCLUDE_DIR}") 21 + #else (DEFINED LIBCXX_INCLUDE_DIR) 22 + # message(FATAL_ERROR "libcxx not found") 23 + #endif (DEFINED LIBCXX_INCLUDE_DIR) 24 + 25 + #include_directories(${LIBCXX_INCLUDE_DIR}) 26 + 27 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 28 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 29 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../util) 30 + 31 + set(CoreServices_SRCS 32 + MacLocales.cpp 33 + UnicodeUtilities.cpp 34 + Gestalt.cpp 35 + ) 36 + 37 + add_library(CoreServices SHARED ${CoreServices_SRCS}) 38 + target_link_libraries(CoreServices -licuuc) 39 + 40 + install(TARGETS CoreServices DESTINATION "lib${SUFFIX}/darling") 41 +
+46
src/CoreServices/Gestalt.cpp
··· 1 + #include "MacErrors.h" 2 + #include "../libSystem/libc/sysctl.h" 3 + #include <cstring> 4 + #include <cstdio> 5 + #include "Gestalt.h" 6 + 7 + OSStatus Gestalt(uint32_t type, int* value) 8 + { 9 + switch (type) 10 + { 11 + case gestaltSystemVersion: 12 + case gestaltSystemVersionMajor: 13 + case gestaltSystemVersionMinor: 14 + case gestaltSystemVersionPatch: 15 + { 16 + // We may be mixing the Darwin and OS version, but this API is deprecated anyway 17 + int name[2] = { CTL_KERN, KERN_OSRELEASE }; 18 + char version[32]; 19 + size_t version_len = sizeof(version) - 1; 20 + int maj, min, patch; 21 + 22 + __darwin_sysctl(name, 2, version, &version_len, nullptr, 0); 23 + sscanf(version, "%d.%d.%d", &maj, &min, &patch); 24 + 25 + if (type == gestaltSystemVersion) 26 + *value = 0x100 * maj + 0x10 * min; 27 + else if (type == gestaltSystemVersionMajor) 28 + *value = maj; 29 + else if (type == gestaltSystemVersionMinor) 30 + *value = min; 31 + else if (type == gestaltSystemVersionPatch) 32 + *value = patch; 33 + } 34 + case gestaltSysArchitecture: 35 + #ifdef __powerpc__ 36 + *value = gestaltPowerPC; 37 + #elif defined(__x86_64__) || defined(__i386__) 38 + *value = gestaltIntel; 39 + #endif 40 + break; 41 + default: 42 + *value = 0; 43 + return unimpErr; 44 + } 45 + return 0; 46 + }
+16
src/CoreServices/Gestalt.h
··· 1 + #ifndef GESTALT_H 2 + #define GESTALT_H 3 + 4 + #define gestaltSystemVersion 'sysv' 5 + #define gestaltSystemVersionMajor 'sys1' 6 + #define gestaltSystemVersionMinor 'sys2' 7 + #define gestaltSystemVersionPatch 'sys3' 8 + 9 + #define gestaltSysArchitecture 'sysa' 10 + #define gestaltPowerPC 2 11 + #define gestaltIntel 10 12 + 13 + extern "C" OSStatus Gestalt(uint32_t type, int* value); 14 + 15 + #endif 16 +
+2
src/CoreServices/MacErrors.h
··· 5 5 6 6 inline OSStatus makeOSStatus(int errNo) { return 100000 + errNo; } 7 7 8 + #define unimpErr -4 9 + 8 10 #endif
+17 -8
src/CoreServices/MacLocales.cpp
··· 1 1 #include "MacLocales.h" 2 2 #include "MacErrors.h" 3 3 #include "libSystem/libc/darwin_errno_codes.h" 4 + #include "libSystem/libc/errno.h" 4 5 #include <unicode/locid.h> 5 6 #include <unicode/coll.h> 6 7 #include <cstring> 7 8 #include <algorithm> 8 9 #include <iconv.h> 10 + #include <errno.h> 9 11 #include <cassert> 10 12 11 - static iconv_t g_icUtf32ToUtf16 = -1; 13 + static iconv_t g_icUtf32ToUtf16 = nullptr; 12 14 13 15 __attribute__((constructor)) void initConversions() 14 16 { ··· 29 31 return 0; 30 32 } 31 33 32 - // TODO: This needs to be checked for ABI compatibility 34 + // LocaleRef is a pointer to a struct 35 + // Instead of storing a pointer, we simply use 4 bytes of the pointer to save the lang code 33 36 char lc[3], rc[3]; 34 37 lc[0] = char(langCode & 255); 35 38 lc[1] = char(langCode >> 8); ··· 162 165 str += ")"; 163 166 164 167 const UChar* buf = str.getTerminatedBuffer(); 165 - size_t inLen = (str.length+1) * sizeof(UChar); 168 + size_t inLen = (str.length()+1) * sizeof(UChar); 166 169 size_t outLen = maxLen * sizeof(Utf16Char); 167 170 const char* inbuf = reinterpret_cast<const char*>(buf); 168 171 char* outbuf = reinterpret_cast<char*>(displayName); 169 - size_t r = iconv(g_icUtf32ToUtf16, &inbuf, &inLen, &outbuf, &outLen); 172 + size_t r = iconv(g_icUtf32ToUtf16, const_cast<char**>(&inbuf), &inLen, &outbuf, &outLen); 170 173 171 174 if (r == size_t(-1)) 172 175 { 173 176 if (errno == E2BIG) 174 177 { 175 178 displayName[maxLen-1] = 0; 176 - rv = maxLen; 179 + r = maxLen; 177 180 } 178 181 else 179 182 { 180 - *lenOut = 0; 183 + r = 0; 181 184 *displayName = 0; 182 - return makeOSStatus(errnoLinuxToDarwin()); 185 + return makeOSStatus(errnoLinuxToDarwin(errno)); 183 186 } 184 187 } 185 188 186 - *lenOut = rv; 189 + *lenOut = r; 187 190 return 0; 188 191 } 189 192 190 193 OSStatus LocaleCountNames(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long* countOut) 191 194 { 195 + return unimpErr; 192 196 } 193 197 194 198 OSStatus LocaleGetIndName(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale) 195 199 { 200 + return unimpErr; 196 201 } 197 202 198 203 OSStatus LocaleGetRegionLanguageName(RegionCode regionCode, char name[256]) 199 204 { 205 + return unimpErr; 200 206 } 201 207 202 208 OSStatus LocaleOperationGetName(LocaleOperationClass cls, LocaleRef ref, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName) 203 209 { 210 + return unimpErr; 204 211 } 205 212 206 213 OSStatus LocaleOperationCountNames(LocaleOperationClass cls, unsigned long* count) 207 214 { 215 + return unimpErr; 208 216 } 209 217 210 218 OSStatus LocaleOperationGetIndName(LocaleOperationClass cls, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale) 211 219 { 220 + return unimpErr; 212 221 } 213 222 214 223
+5
src/dyld/MachOLoader.cpp
··· 43 43 FileMap g_file_map; 44 44 static std::vector<std::string> g_bound_names; 45 45 46 + char g_darwin_loader_path[PATH_MAX] = ""; 47 + 46 48 extern char g_darwin_executable_path[PATH_MAX]; 47 49 extern int g_argc; 48 50 extern char** g_argv; ··· 460 462 461 463 intptr slide = 0; 462 464 intptr base = 0; 465 + 466 + strncpy(g_darwin_loader_path, sourcePath.c_str(), PATH_MAX-1); 467 + g_darwin_loader_path[PATH_MAX-1] = 0; 463 468 464 469 loadSegments(mach, &slide, &base); 465 470
+12 -16
src/dyld/Trampoline.cpp
··· 35 35 TrampolineMgr* TrampolineMgr::m_pInstance = 0; 36 36 std::map<std::string, TrampolineMgr::FunctionInfo> TrampolineMgr::m_functionInfo; 37 37 struct timeval TrampolineMgr::m_startup; 38 - void* TrampolineMgr::m_objcDarwin = 0; 39 38 40 39 static __thread std::stack<TrampolineMgr::ReturnInfo>* g_returnInfo = 0; 41 40 static std::ofstream* g_logger = 0; ··· 185 184 186 185 while (std::getline(file, line)) 187 186 { 188 - size_t p = line.find(':'); 187 + size_t p = line.rfind(':'); 189 188 if (p == std::string::npos) 190 189 continue; 191 190 ··· 222 221 ss << secs << 's'; 223 222 ms -= double(secs) * SECS; 224 223 } 225 - ss << ms << "ms"; 224 + ss << int(ms) /*<< "ms"*/; // double value here sometime causes crashes, why? 225 + ss << '.' << int(ms*10)%10 << "ms"; // workaround 226 226 return ss.str(); 227 227 } 228 228 ··· 286 286 287 287 bool TrampolineMgr::loadObjCHelper() 288 288 { 289 - m_objcDarwin = ::dlopen(LIB_OBJCDARWIN, RTLD_NOW | RTLD_NOLOAD); 290 - if (!m_objcDarwin) 291 - return false; 292 - *((void**)&objc_helper) = ::dlsym(m_objcDarwin, "trampoline_objcMsgInfo"); 293 - if (!objc_helper) 294 - return false; 295 - return true; 289 + *((void**)&objc_helper) = ::dlsym(RTLD_DEFAULT, "trampoline_objcMsgInfo"); 290 + return objc_helper != 0; 296 291 } 297 292 298 293 void* TrampolineMgr::printInfo(uint32_t index, CallStack* stack) 299 - { 294 + { 295 + const AddrEntry& e = m_pInstance->m_entries[index]; 300 296 FunctionInfo* info = 0; 301 - const AddrEntry& e = m_pInstance->m_entries[index]; 302 297 std::map<std::string, FunctionInfo>::iterator it; 303 - std::string stamp; 304 298 std::ostream* out; 305 299 ReturnInfo retInfo; 306 300 ArgumentWalker w(stack); 307 301 std::string searchable = e.name; 308 302 309 - stamp = timeStamp(); 310 303 out = m_pInstance->getLogger(); 311 304 312 305 if (!g_returnInfo) 313 306 g_returnInfo = new std::stack<TrampolineMgr::ReturnInfo>; 307 + 308 + std::string stamp = timeStamp(); 314 309 315 310 (*out) << std::string(20 - stamp.size(), ' '); 316 - (*out) << '[' << stamp << "] "; 311 + (*out) << '[' << timeStamp() << "] "; 317 312 (*out) << std::string(g_returnInfo->size(), ' '); 318 313 319 314 // Special handling for Objective-C ··· 334 329 (*out) << e.printName; 335 330 (*out) << '('; 336 331 332 + // std::cout << "Looking for " << searchable << std::endl; 337 333 it = m_functionInfo.find(searchable); 338 334 339 335 if (it != m_functionInfo.end()) ··· 353 349 } 354 350 else 355 351 (*out) << "?) "; 356 - (*out) << "ret_ip=" << stack->retAddr /*<< '(' << m_pInstance->inFile(stack->retAddr) << ')'*/ << std::endl << std::flush; 352 + (*out) << "ret_ip=" << stack->retAddr << std::endl << std::flush; 357 353 358 354 retInfo.retAddr = stack->retAddr; 359 355 retInfo.it = it;
-1
src/dyld/Trampoline.h
··· 145 145 std::string m_wd; 146 146 static struct timeval m_startup; 147 147 static std::map<std::string, FunctionInfo> m_functionInfo; 148 - static void* m_objcDarwin; 149 148 }; 150 149 151 150 #pragma pack(1)
+24 -14
src/dyld/ld.cpp
··· 37 37 #include <sys/stat.h> 38 38 #include <limits.h> 39 39 #include <regex.h> 40 + #include <libgen.h> 40 41 #include <cassert> 41 42 #include <list> 42 43 #include <algorithm> ··· 63 64 64 65 extern MachOLoader* g_loader; 65 66 extern char g_darwin_executable_path[PATH_MAX]; 67 + extern char g_darwin_loader_path[PATH_MAX]; 66 68 extern char g_sysroot[PATH_MAX]; 67 69 extern int g_argc; 68 70 extern char** g_argv; ··· 90 92 { 91 93 std::cerr << e.what() << std::endl; 92 94 } 95 + } 96 + 97 + static std::string replacePathPrefix(const char* prefix, const char* prefixed, const char* replacement) 98 + { 99 + std::string path = replacement; 100 + char* repl = new char[strlen(replacement)]; 101 + 102 + strcpy(repl, replacement); 103 + path = dirname(repl); 104 + path += (prefixed + strlen(prefix)); 105 + 106 + delete [] repl; 107 + return path; 93 108 } 94 109 95 110 void* __darwin_dlopen(const char* filename, int flag) ··· 210 225 } 211 226 else if (strncmp(filename, "@executable_path", 16) == 0) 212 227 { 213 - size_t lastSlash; 214 - path = g_darwin_executable_path; 215 - 216 - lastSlash = path.rfind('/'); 217 - if (lastSlash != std::string::npos) 218 - { 219 - path.resize(lastSlash); 220 - path += filename + 16; 221 - } 222 - else 223 - { 224 - path = filename + 16; 225 - } 226 - 228 + path = replacePathPrefix("@executable_path", filename, g_darwin_executable_path); 229 + std::cout << "Full path: " << path << std::endl; 230 + if (::access(path.c_str(), R_OK) == 0) 231 + RET_IF( attemptDlopen(path.c_str(), flag) ); 232 + } 233 + else if (strncmp(filename, "@loader_path", 12) == 0) 234 + { 235 + path = replacePathPrefix("@loader_path", filename, g_darwin_loader_path); 227 236 if (::access(path.c_str(), R_OK) == 0) 228 237 RET_IF( attemptDlopen(path.c_str(), flag) ); 229 238 } 239 + // TODO: @rpath - https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath 230 240 else 231 241 { 232 242 if (const char* ldp = getenv("DYLD_LIBRARY_PATH"))
+1 -1
src/libSystem/CMakeLists.txt
··· 94 94 target_link_libraries(System.B.dylib -ldl -lpthread -luuid -l:../../libmach-o.so -lrt -lssl -lbsd -l:libobjc.so.4) 95 95 add_dependencies(System.B.dylib mach-o) 96 96 97 - install(TARGETS System.B.dylib DESTINATION "lib${SUFFIX}/darling") 97 + install(TARGETS System.B.dylib DESTINATION "lib${SUFFIX}") 98 98
+17 -5
src/libSystem/libc/sysctl.cpp
··· 74 74 return -1; 75 75 } 76 76 77 - if (*oldlenp == 4) 78 - *reinterpret_cast<uint32_t*>(oldp) = val; 79 - else if (*oldlenp == 8) 80 - *reinterpret_cast<uint64_t*>(oldp) = val; 77 + if (oldp) 78 + { 79 + if (*oldlenp == 4) 80 + *reinterpret_cast<uint32_t*>(oldp) = val; 81 + else if (*oldlenp == 8) 82 + *reinterpret_cast<uint64_t*>(oldp) = val; 83 + } 84 + else 85 + *oldlenp = sizeof(long); 81 86 return 0; 82 87 } 83 88 ··· 88 93 case KERN_OSRELEASE: 89 94 90 95 // TODO: use real uname? 91 - strcpy((char*)oldp, "10.6.0"); 96 + if (oldp) 97 + strcpy((char*)oldp, "10.7.0"); 98 + *oldlenp = 7; 99 + break; 100 + 101 + case KERN_OSVERSION: 102 + if (oldp) 103 + strcpy((char*)oldp, "10J869"); 92 104 *oldlenp = 7; 93 105 break; 94 106
+2 -1
src/libSystem/libc/sysctl.h
··· 3 3 #include <stdint.h> 4 4 #include <string.h> 5 5 6 - // From /usr/include/sys/sysctl.h 6 + // http://fxr.watson.org/fxr/source/bsd/sys/sysctl.h?v=xnu-1228#L373 7 7 8 8 #define CTL_KERN 1 9 9 #define CTL_HW 6 10 10 #define KERN_OSRELEASE 2 11 + #define KERN_OSVERSION 65 11 12 12 13 extern "C" int __darwin_sysctl(int* name, unsigned int namelen, void* oldp, size_t* oldlenp, void* newp, size_t newlen); 13 14
+1 -1
src/libmacarchive/CMakeLists.txt
··· 17 17 add_library(macarchive SHARED ${macarchive_SRCS}) 18 18 target_link_libraries(macarchive -lssl -lz -lbz2) 19 19 20 - install(TARGETS macarchive DESTINATION "lib{SUFFIX}/darling") 20 + install(TARGETS macarchive DESTINATION "lib${SUFFIX}/darling") 21 21 22 22
+1 -1
src/libncurses/CMakeLists.txt
··· 23 23 # -luuid to make uuid_ functions available for Darwin apps 24 24 target_link_libraries(ncurses.5.4.dylib -lncurses) 25 25 26 - install(TARGETS ncurses.5.4.dylib DESTINATION "lib${SUFFIX}/darling") 26 + install(TARGETS ncurses.5.4.dylib DESTINATION "lib${SUFFIX}") 27 27
+3 -3
src/libobjcdarwin/CMakeLists.txt
··· 25 25 objc_msgSend.nasm 26 26 NameTranslate.cpp 27 27 ClassRegister.cpp 28 - TrampolineHelper.cpp 28 + TrampolineHelper.mm 29 29 30 30 common/attribute.cpp 31 31 common/property.cpp ··· 48 48 ) 49 49 50 50 add_library(objc.A.dylib SHARED ${objcdarwin_SRCS}) 51 - target_link_libraries(objc.A.dylib -l:libobjc.so.4 -lgnustep-base) 51 + target_link_libraries(objc.A.dylib -l:libobjc.so.4 -lgnustep-base -l:../../libutil.a) 52 52 53 - install(TARGETS objc.A.dylib DESTINATION "lib${SUFFIX}/darling") 53 + install(TARGETS objc.A.dylib DESTINATION "lib${SUFFIX}") 54 54
+3 -1
src/libobjcdarwin/ClassRegister.h
··· 1 1 #ifndef CLASSREGISTER_H 2 2 #define CLASSREGISTER_H 3 - #define __STDC_LIMIT_MACROS 3 + #ifndef __STDC_LIMIT_MACROS 4 + # define __STDC_LIMIT_MACROS 5 + #endif 4 6 #include <stdint.h> 5 7 #include <cstddef> 6 8 #include <algorithm>
-56
src/libobjcdarwin/TrampolineHelper.cpp
··· 1 - #include <string> 2 - #include <objc/runtime.h> 3 - #include <cstring> 4 - #include <sstream> 5 - #include "visibility.h" 6 - #include "../util/stlutils.h" 7 - 8 - DARLING_VISIBLE std::string trampoline_objcMsgInfo(const std::string& invoker, void* arg1, SEL sel, std::string& searchable) asm("trampoline_objcMsgInfo"); 9 - 10 - std::string trampoline_objcMsgInfo(const std::string& invoker, void* arg1, SEL sel, std::string& searchable) 11 - { 12 - id obj; 13 - Class type; 14 - std::stringstream ret; 15 - 16 - if (string_startsWith(invoker, "objc_msgSendSuper2")) 17 - { 18 - const objc_super* s = static_cast<objc_super*>(arg1); 19 - obj = (id) class_getSuperclass(Class(s->super_class)); 20 - } 21 - else if (string_startsWith(invoker, "objc_msgSendSuper")) 22 - { 23 - const objc_super* s = static_cast<objc_super*>(arg1); 24 - obj = (id) s->super_class; 25 - } 26 - else 27 - obj = id(arg1); 28 - 29 - if (obj) 30 - { 31 - type = object_getClass(obj); 32 - 33 - if (class_isMetaClass(type)) 34 - ret << "+["; 35 - else 36 - ret << "-["; 37 - 38 - ret << class_getName(type); 39 - searchable = ret.str(); 40 - 41 - ret << '('; 42 - ret << obj << ") "; 43 - 44 - searchable += ' '; 45 - searchable += sel_getName(sel); 46 - searchable += ']'; 47 - } 48 - else 49 - ret << "?[nil(0x0) "; 50 - 51 - ret << sel_getName(sel); 52 - ret << ']'; 53 - 54 - return ret.str(); 55 - } 56 -
+86
src/libobjcdarwin/TrampolineHelper.mm
··· 1 + #include <string> 2 + #include <objc/runtime.h> 3 + #include <cstring> 4 + #include <sstream> 5 + #include <iostream> 6 + #include <Foundation/NSObject.h> 7 + #include "visibility.h" 8 + #include "../util/stlutils.h" 9 + 10 + DARLING_VISIBLE std::string trampoline_objcMsgInfo(const std::string& invoker, void* arg1, SEL sel, std::string& searchable) asm("trampoline_objcMsgInfo"); 11 + 12 + std::string trampoline_objcMsgInfo(const std::string& invoker, void* arg1, SEL sel, std::string& searchable) 13 + { 14 + id obj; 15 + Class type; 16 + std::stringstream ret; 17 + 18 + if (string_startsWith(invoker, "objc_msgSendSuper2")) 19 + { 20 + const objc_super* s = static_cast<objc_super*>(arg1); 21 + obj = (id) class_getSuperclass(Class(s->super_class)); 22 + } 23 + else if (string_startsWith(invoker, "objc_msgSendSuper")) 24 + { 25 + const objc_super* s = static_cast<objc_super*>(arg1); 26 + obj = (id) s->super_class; 27 + } 28 + else 29 + obj = id(arg1); 30 + 31 + if (string_endsWith(invoker, "_fixup")) 32 + { 33 + struct fixable 34 + { 35 + void* pfn; 36 + SEL sel; 37 + }; 38 + const fixable* f = (fixable*) sel; 39 + sel = f->sel; 40 + } 41 + 42 + const char* selname = sel_getName(sel); 43 + if (obj) 44 + { 45 + const char* clsname; 46 + bool isMeta; 47 + 48 + type = object_getClass(obj); 49 + clsname = class_getName(type); 50 + 51 + isMeta = class_isMetaClass(type) == YES; 52 + if (isMeta) 53 + ret << "+["; 54 + else 55 + ret << "-["; 56 + 57 + // std::cout << "Resp: " << bool([[NSObject class] instancesRespondToSelector:@selector(description)]) << std::endl; 58 + 59 + searchable = ret.str(); 60 + if ( (!isMeta && [NSObject instancesRespondToSelector:sel]) || 61 + (isMeta && ([[NSObject class] instancesRespondToSelector:sel] || !strcmp(selname, "alloc"))) 62 + ) 63 + { 64 + searchable += "NSObject"; 65 + } 66 + else 67 + searchable += clsname; 68 + 69 + ret << clsname; 70 + 71 + ret << '('; 72 + ret << obj << ") "; 73 + 74 + searchable += ' '; 75 + searchable += selname; 76 + searchable += ']'; 77 + } 78 + else 79 + ret << "?[nil(0x0) "; 80 + 81 + ret << selname; 82 + ret << ']'; 83 + 84 + return ret.str(); 85 + } 86 +
+1 -1
src/libobjcdarwin/common/method.h
··· 13 13 14 14 LOG << "Method: selName: " << m->selName << "; types: " << m->types << "; impl: " << m->impl << std::endl; 15 15 16 - SEL sel = sel_registerName(m->selName); 16 + SEL sel = sel_registerTypedName_np(m->selName, m->types); 17 17 class_addMethod(c, sel, reinterpret_cast<IMP>(m->impl), m->types); 18 18 } 19 19 }