Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielmschmidt/objective-c-parser
Get the JSON representation of an Objective-C header file
https://github.com/danielmschmidt/objective-c-parser
babel code-generation javascript objective-c parser
Last synced: 5 days ago
JSON representation
Get the JSON representation of an Objective-C header file
- Host: GitHub
- URL: https://github.com/danielmschmidt/objective-c-parser
- Owner: DanielMSchmidt
- License: mit
- Created: 2017-06-13T19:06:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-19T03:14:57.000Z (about 2 months ago)
- Last Synced: 2024-10-19T05:15:26.450Z (18 days ago)
- Topics: babel, code-generation, javascript, objective-c, parser
- Language: Objective-C
- Homepage:
- Size: 2.62 MB
- Stars: 25
- Watchers: 2
- Forks: 7
- Open Issues: 12
-
Metadata Files:
- Readme: readme.md
- Changelog: Changelog.md
- License: license
Awesome Lists containing this project
README
# objective-c-parser [![Build Status](https://travis-ci.org/DanielMSchmidt/objective-c-parser.svg?branch=master)](https://travis-ci.org/DanielMSchmidt/objective-c-parser) [![Coverage Status](https://coveralls.io/repos/github/DanielMSchmidt/objective-c-parser/badge.svg?branch=master)](https://coveralls.io/github/DanielMSchmidt/objective-c-parser?branch=master) [![BCH compliance](https://bettercodehub.com/edge/badge/DanielMSchmidt/objective-c-parser?branch=master)](https://bettercodehub.com/)
> Get an objective-c header file and translate it to equivalent javascript calls
## Install
```
$ npm install objective-c-parser
```## Usage
```js
const fs = require("fs");
const objectiveCParser = require("objective-c-parser");
const content = fs.readFileSync("/path/to/objective-c/Ponies.h", "utf8");const output = objectiveCParser(content);
fs.writeFileSync("/path/to/project/ponies.json", JSON.stringify(output));
```## Example
```objective-c
#import
@protocol Ponies, Foo;
@interface BasicName : NSObject// Another comment
@property(nonatomic, readonly) uninteresting matcher;// This is the comment of basic method one
- (NSInteger)basicMethodOne;/**
* This is the comment of basic method two.
* It has multiple lines
*/
- (NSString *) basicMethodTwoWithArgOne:(NSInteger)argOne AndArgTwo:(NSString *)argTwo;
@end
``````json
{
"name": "BasicName",
"methods": [
{
"args": [],
"comment": "This is the comment of basic method one",
"name": "basicMethodOne",
"returnType": "NSInteger"
},
{
"args": [
{
"type": "NSInteger",
"name": "argOne"
},
{
"type": "NSString",
"name": "argTwo"
}
],
"comment": "This is the comment of basic method two.\nIt has multiple lines",
"name": "basicMethodTwoWithArgOneAndArgTwo",
"returnType": "NSString"
}
]
}
```Please be aware that `name` can be undefined if the headerfile does not contain an `@interface` declaration.
## License
MIT © [Daniel Schmidt](http://danielmschmidt.de)