swiftMetadataInitializerRealloc-dylib2.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "test.h"
  2. #include "swift-class-def.m"
  3. @interface SwiftDylib1A: NSObject @end
  4. @interface SwiftDylib1B: NSObject @end
  5. @interface NSObject (DylibCategories)
  6. - (char *)dylib1ACategoryInSameDylib;
  7. - (char *)dylib1BCategoryInSameDylib;
  8. - (char *)dylib1ACategoryInOtherDylib;
  9. - (char *)dylib1BCategoryInOtherDylib;
  10. - (char *)dylib1ACategoryInApp;
  11. - (char *)dylib1BCategoryInApp;
  12. + (void)testFromOtherDylib;
  13. @end
  14. @implementation SwiftDylib1A (Category)
  15. - (const char *)dylib1ACategoryInOtherDylib { return "dylib1ACategoryInOtherDylib"; }
  16. @end
  17. @implementation SwiftDylib1B (Category)
  18. - (const char *)dylib1BCategoryInOtherDylib { return "dylib1BCategoryInOtherDylib"; }
  19. @end
  20. SWIFT_STUB_CLASSREF(SwiftDylib1A);
  21. SWIFT_STUB_CLASSREF(SwiftDylib1B);
  22. Class objc_loadClassref(_Nullable Class * _Nonnull clsref);
  23. @implementation SwiftDylib1A (Test)
  24. + (void)testFromOtherDylib {
  25. Class SwiftDylib1A = objc_loadClassref(&SwiftDylib1AClassref);
  26. Class SwiftDylib1B = objc_loadClassref(&SwiftDylib1BClassref);
  27. testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInSameDylib], "dylib1ACategoryInSameDylib") == 0);
  28. testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInSameDylib], "dylib1BCategoryInSameDylib") == 0);
  29. testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInApp], "dylib1ACategoryInApp") == 0);
  30. testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInApp], "dylib1BCategoryInApp") == 0);
  31. testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInOtherDylib], "dylib1ACategoryInOtherDylib") == 0);
  32. testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInOtherDylib], "dylib1BCategoryInOtherDylib") == 0);
  33. }
  34. @end