Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to compile with class-dump headers #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mmmulani
Copy link

This fixes a few problems from trying to compile in with class-dump headers.
Namely:

  • CDUnknownBlockType and CDUnknownFunctionPointerType are helpful but the CDTypes.h file is not automatically included and even if it were, it is too specific
  • .cxx_destruct methods are included in the header (which cannot be compiled)
  • if there is a setter for a read-only property, it is exposed incorrectly

Mehdi Mulani added 3 commits February 24, 2015 17:05
These methods can't be compiled.
Even if we include these types in the compilation, they are too specific to be useful.
Instead let's trust the consumer of these APIs to know what they're doing.
In the rare case of having a setting for a read-only property, we must ensure the setter has the correct type as its argument, otherwise the header will not compile.
@ryanrhee
Copy link

Ping~

@nicolasgoutaland
Copy link

Any plan to merge this PR ?

@nygard
Copy link
Owner

nygard commented May 3, 2015

Yes, when I have time to look at it.

@nicolasgoutaland
Copy link

Thanks a lot !
In fact, I'm currently trying to develop an XCode plug-in, and include extracted headers files in my project.
But the problem is that I have a lot of compilation issues due to misimported headers, or misnamed.

For example, in DVTKit.framework, I have some protocol headers (DVTProgressIndicatorProvidingView => DVTProgressIndicatorProvidingView-Protocol.h) that are generated suffixed by the string -Protocol, whereas they are imported without this suffix (in DVTOutlineView.h).

Am I using it wrong ?

Regards,

@mmmulani
Copy link
Author

mmmulani commented May 4, 2015

@nicolasgoutaland did you try using this PR?

though I expect even after applying this there will still be some problems

@nicolasgoutaland
Copy link

Hi,

Yes, but there is still some problems ;)

Concerning the anonymous types I prefer to redefine types in a PCH

#define CDUnknownFunctionPointerType    void *
#define CDUnknownBlockType                     id

This will allow compilation, without loosing any information.

The other problems generating headers concerns mainly protocols, that are imported without there suffix in name.
Last one is about importing classes that are available in frameworks, such as

#import "NSObject.h"
#import "NSView.h"
...

A good fix may be to prevent include of theses files, but I think it's too specific. Perhaps providing an exclusion list ?

The only working way I found so far is to include classes one at a time, once needed for my work, and manually edit the header file.

Regards

@nicolasgoutaland
Copy link

Hi,

@mmmulani, Here is another problem preventing compilation.
When class contains some properties / ivar implementing a protocol

    id <DVTCancellable> _closeAfterDelayToken;  // 312 = 0x138

In this case, corresponding header file isn't imported.
I assume in this case CDType class is used, and **- (NSString *)formattedString:(NSString )previousName formatter:(CDTypeFormatter )typeFormatter level:(NSUInteger)level; method is used to generate content, but it seems that protocols in protocols properties isn't added in containing class.
Method **- (NSString )formattedStringForMembersAtLevel:(NSUInteger)level formatter:(CDTypeFormatter )typeFormatter; is called to generate all members declaration, but imports are done in an other class CDMultiFileVisitor, and is not used in this case.

@nygard Do you confirms that ?

Let me know if can help to fix that.

Regards,

Edit:

Just found some other cases, for example, in IDESourceExpressionSource protocol, parameter

- (void)symbolsForExpression:(DVTSourceExpression *)arg1 inQueue:(NSObject<OS_dispatch_queue> *)arg2 completionBlock:(void (^)(IDEIndexCollection *, NSDictionary *))arg3;

This method will generate a @Class NSObject<OS_dispatch_queue> preventing compilation.

Second problem with this method is with IDEIndexCollection class that isn't import. Perhaps a problem importing classes referenced in block parameters ?

phatblat added a commit to mas-cli/class-dump that referenced this pull request Nov 24, 2018
manicmaniac added a commit to manicmaniac/class-dump that referenced this pull request Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants