Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
libclang.node
*.swp
node_modules
.DS_Store
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,37 @@ AST Traversal
```javascript
var libclang = require('libclang');

var index = new libclang.index();
var tu = new libclang.translationunit();

tu.fromSource(idx, 'myLibrary.h', ['-I/path/to/my/project']);

tu.cursor().visitChildren(function (parent) {
switch (this.kind) {
case libclang.KINDS.CXCursor_FunctionDecl:
console.log(this.spelling);
break;
}
return libclang.CXChildVisit_Continue;
var
Cursor = libclang.Cursor,
Index = libclang.Index,
TranslationUnit = libclang.TranslationUnit;

var dclang = require('./node_modules/libclang/lib/dynamic_clang');
var consts = dclang.CONSTANTS;

var index = new Index(true, true);
var tu = new TranslationUnit.fromSource(index, '/path/to/my/sourcefile/myLibrary.h', [
'-xc++',
]);

tu.cursor.visitChildren(function (parent) {
if(this.spelling == "__llvm__") {
return;
} else {
console.log("Name = " + this.spelling);
console.log("Kind = " + consts.CXCursorKind[this.kind]);
console.log("Type = " + consts.CXTypeKind[this.type.kind]);
console.log("Line Number = " + this.location.presumedLocation.line);
console.log("Column Number = " + this.location.presumedLocation.column);
console.log("------------");
return Cursor.Recurse;
}

});

index.dispose();
tu.dispose();
tu.dispose;

````

Generate FFI Bindings
Expand Down
Binary file added lib/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions lib/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ var Cursor = function (instance) {
}
});

Object.defineProperty(this, 'pointeeType', {
get: function () {
return new Type(lib.clang_getPointeeType(lib.clang_getCursorType(self._instance)));
}
});

Object.defineProperty(this, 'enumType', {
get: function () {
return new Type(lib.clang_getEnumDeclIntegerType(self._instance));
Expand Down