@@ -39,93 +39,6 @@ static UInt8 getSystemVersion() {
3939 return result;
4040}
4141
42- static int compareIdentifiers (const char * nullTerminated, const char * notNullTerminated, size_t length) {
43- int result = strncmp (nullTerminated, notNullTerminated, length);
44- return (result == 0 ) ? strlen (nullTerminated) - length : result;
45- }
46-
47- const InterfaceMeta* GlobalTable::findInterfaceMeta (WTF::StringImpl* identifier) const {
48- return this ->findInterfaceMeta (reinterpret_cast <const char *>(identifier->utf8 ().data ()), identifier->length (), identifier->hash ());
49- }
50-
51- const InterfaceMeta* GlobalTable::findInterfaceMeta (const char * identifierString) const {
52- unsigned hash = WTF::StringHasher::computeHashAndMaskTop8Bits<LChar>(reinterpret_cast <const LChar*>(identifierString));
53- return this ->findInterfaceMeta (identifierString, strlen (identifierString), hash);
54- }
55-
56- const InterfaceMeta* GlobalTable::findInterfaceMeta (const char * identifierString, size_t length, unsigned hash) const {
57- const Meta* meta = MetaFile::instance ()->globalTable ()->findMeta (identifierString, length, hash, /* onlyIfAvailable*/ false );
58- if (meta == nullptr ) {
59- return nullptr ;
60- }
61-
62- // Meta should be an interface, but it could also be a protocol in case of a
63- // private interface having the same name as a public protocol
64- assert (meta->type () == MetaType::Interface || (meta->type () == MetaType::ProtocolType && objc_getClass (meta->name ()) != nullptr && objc_getProtocol (meta->name ()) != nullptr ));
65-
66- if (meta->type () != MetaType::Interface) {
67- return nullptr ;
68- }
69-
70- const InterfaceMeta* interfaceMeta = static_cast <const InterfaceMeta*>(meta);
71- if (interfaceMeta->isAvailable ()) {
72- return interfaceMeta;
73- } else {
74- const char * baseName = interfaceMeta->baseName ();
75-
76- NSLog (@" ** \" %s \" introduced in iOS SDK %d .%d is currently unavailable, attempting to load its base: \" %s \" . **" ,
77- std::string (identifierString, length).c_str(),
78- getMajorVersion(interfaceMeta->introducedIn ()),
79- getMinorVersion(interfaceMeta->introducedIn ()),
80- baseName);
81-
82- return this ->findInterfaceMeta (baseName);
83- }
84- }
85-
86- const ProtocolMeta* GlobalTable::findProtocol (WTF::StringImpl* identifier) const {
87- return this ->findProtocol (reinterpret_cast <const char *>(identifier->utf8 ().data ()), identifier->length (), identifier->hash ());
88- }
89-
90- const ProtocolMeta* GlobalTable::findProtocol (const char * identifierString) const {
91- unsigned hash = WTF::StringHasher::computeHashAndMaskTop8Bits<LChar>(reinterpret_cast <const LChar*>(identifierString));
92- return this ->findProtocol (identifierString, strlen (identifierString), hash);
93- }
94-
95- const ProtocolMeta* GlobalTable::findProtocol (const char * identifierString, size_t length, unsigned hash) const {
96- // Do not check for availability when returning a protocol. Apple regularly create new protocols and move
97- // existing interface members there (e.g. iOS 12.0 introduced the UIFocusItemScrollableContainer protocol
98- // in UIKit which contained members that have existed in UIScrollView since iOS 2.0)
99-
100- auto meta = this ->findMeta (identifierString, length, hash, /* onlyIfAvailable*/ false );
101- ASSERT (!meta || meta->type () == ProtocolType);
102- return static_cast <const ProtocolMeta*>(meta);
103- }
104-
105- const Meta* GlobalTable::findMeta (WTF::StringImpl* identifier, bool onlyIfAvailable) const {
106- return this ->findMeta (reinterpret_cast <const char *>(identifier->utf8 ().data ()), identifier->length (), identifier->hash (), onlyIfAvailable);
107- }
108-
109- const Meta* GlobalTable::findMeta (const char * identifierString, bool onlyIfAvailable) const {
110- unsigned hash = WTF::StringHasher::computeHashAndMaskTop8Bits<LChar>(reinterpret_cast <const LChar*>(identifierString));
111- return this ->findMeta (identifierString, strlen (identifierString), hash, onlyIfAvailable);
112- }
113-
114- const Meta* GlobalTable::findMeta (const char * identifierString, size_t length, unsigned hash, bool onlyIfAvailable) const {
115- int bucketIndex = hash % buckets.count ;
116- if (this ->buckets [bucketIndex].isNull ()) {
117- return nullptr ;
118- }
119- const ArrayOfPtrTo<Meta>& bucketContent = buckets[bucketIndex].value ();
120- for (ArrayOfPtrTo<Meta>::iterator it = bucketContent.begin (); it != bucketContent.end (); it++) {
121- const Meta* meta = (*it).valuePtr ();
122- if (compareIdentifiers (meta->jsName (), identifierString, length) == 0 ) {
123- return onlyIfAvailable ? (meta->isAvailable () ? meta : nullptr ) : meta;
124- }
125- }
126- return nullptr ;
127- }
128-
12942// Meta
13043bool Meta::isAvailable () const {
13144 UInt8 introducedIn = this ->introducedIn ();
@@ -369,7 +282,7 @@ void collectInheritanceChainMembers(const char* identifier, size_t length, Membe
369282vector<const MethodMeta*> BaseClassMeta::initializersWithProtocols (vector<const MethodMeta*>& container, KnownUnknownClassPair klasses, const ProtocolMetas& additionalProtocols) const {
370283 this ->initializers (container, klasses);
371284 for (Array<String>::iterator it = this ->protocols ->begin (); it != this ->protocols ->end (); it++) {
372- const ProtocolMeta* protocolMeta = MetaFile::instance ()->globalTable ()->findProtocol ((*it).valuePtr ());
285+ const ProtocolMeta* protocolMeta = MetaFile::instance ()->globalTableJs ()->findProtocol ((*it).valuePtr ());
373286 if (protocolMeta != nullptr )
374287 protocolMeta->initializersWithProtocols (container, klasses, ProtocolMetas ());
375288 }
@@ -379,48 +292,6 @@ void collectInheritanceChainMembers(const char* identifier, size_t length, Membe
379292 return container;
380293}
381294
382- const Meta* GlobalTable::iterator::getCurrent () {
383- return this ->_globalTable ->buckets [_topLevelIndex].value ()[_bucketIndex].valuePtr ();
384- }
385-
386- GlobalTable::iterator& GlobalTable::iterator::operator ++() {
387- this ->_bucketIndex ++;
388- this ->findNext ();
389- return *this ;
390- }
391-
392- const Meta* GlobalTable::iterator::operator *() {
393- return this ->getCurrent ();
394- }
395-
396- bool GlobalTable::iterator::operator ==(const iterator& other) const {
397- return _globalTable == other._globalTable && _topLevelIndex == other._topLevelIndex && _bucketIndex == other._bucketIndex ;
398- }
399-
400- bool GlobalTable::iterator::operator !=(const iterator& other) const {
401- return !(*this == other);
402- }
403-
404- void GlobalTable::iterator::findNext () {
405- if (this ->_topLevelIndex == this ->_globalTable ->buckets .count ) {
406- return ;
407- }
408-
409- do {
410- if (!this ->_globalTable ->buckets [_topLevelIndex].isNull ()) {
411- int bucketLength = this ->_globalTable ->buckets [_topLevelIndex].value ().count ;
412- while (this ->_bucketIndex < bucketLength) {
413- if (this ->getCurrent () != nullptr ) {
414- return ;
415- }
416- this ->_bucketIndex ++;
417- }
418- }
419- this ->_bucketIndex = 0 ;
420- this ->_topLevelIndex ++;
421- } while (this ->_topLevelIndex < this ->_globalTable ->buckets .count );
422- }
423-
424295static MetaFile* metaFileInstance (nullptr );
425296
426297MetaFile* MetaFile::instance () {
0 commit comments