-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds all bindings required to translate the `libclang` tutorial to Haskell.
- Loading branch information
Showing
9 changed files
with
554 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
dist-newstyle/ | ||
unversioned | ||
cabal.project.local | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <clang-c/Index.h> | ||
|
||
#include "clang_wrappers.h" | ||
|
||
/** | ||
* Cursor manipulations | ||
*/ | ||
|
||
CXCursor* wrap_malloc_getTranslationUnitCursor (CXTranslationUnit unit) { | ||
CXCursor result = clang_getTranslationUnitCursor(unit); | ||
CXCursor *wrapped = malloc(sizeof(CXCursor)); | ||
memcpy(wrapped, &result, sizeof(CXCursor)); | ||
return wrapped; | ||
} | ||
|
||
/** | ||
* Traversing the AST with cursors | ||
*/ | ||
|
||
unsigned wrap_visitChildren(CXCursor* parent, CXCursorVisitor visitor, CXClientData client_data) { | ||
return clang_visitChildren(*parent, visitor, client_data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Wrappers for clang functions that take structs, or return them, by value. | ||
* | ||
* For functions that return structs by value, we instead allocate memory and | ||
* return a pointer. It is the responsibility of the caller to attach a | ||
* finalizer to these pointers; to remind the caller to do so, these functions | ||
* are prefixed with @wrap_malloc_@; the other functions are prefixed with | ||
* @wrap_@ (in both cases this prefixes replaces the @clang_@ prefix). | ||
*/ | ||
|
||
#include <clang-c/Index.h> | ||
|
||
// Cursor manipulations | ||
|
||
CXCursor* wrap_malloc_getTranslationUnitCursor (CXTranslationUnit unit); | ||
|
||
// Traversing the AST with cursors | ||
|
||
unsigned wrap_visitChildren(CXCursor* parent, CXCursorVisitor visitor, CXClientData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.