Skip to content

Instantly share code, notes, and snippets.

@badosu
Created February 13, 2015 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badosu/1a7515b837372fb00ea1 to your computer and use it in GitHub Desktop.
Save badosu/1a7515b837372fb00ea1 to your computer and use it in GitHub Desktop.
~/C/cxx2rs ❯❯❯ python2.7 --version
Python 2.7.9
~/C/cxx2rs ❯❯❯ rustc --version
rustc 1.0.0-nightly (ba2f13ef0 2015-02-04 20:03:55 +0000)
~/C/cxx2rs ❯❯❯ python2.7 ~/Code/cxx2rs/cxx2rs.py lv2 /usr/include/lv2.h
#![crate_type = "lib"]
#![crate_name = "ssh"]
extern crate libc;
use std::mem;
/*
struct _LV2_Feature
(const char *) URI
(void *) data
*/
#[repr(C)]
pub struct _LV2_Feature {
URI: *const libc::c_char,
data: *mut libc::c_void,
}
/*
struct _LV2_Descriptor
(const char *) URI
(LV2_Handle (*)(const struct _LV2_Descriptor *, double, const char *, const LV2_Feature *const *)) instantiate [void *(*)(const struct _LV2_Descriptor *, double, const char *, const struct _LV2_Feature *const *)]
(void (*)(LV2_Handle, uint32_t, void *)) connect_port [void (*)(void *, unsigned int, void *)]
(void (*)(LV2_Handle)) activate [void (*)(void *)]
(void (*)(LV2_Handle, uint32_t)) run [void (*)(void *, unsigned int)]
(void (*)(LV2_Handle)) deactivate [void (*)(void *)]
(void (*)(LV2_Handle)) cleanup [void (*)(void *)]
(const void *(*)(const char *)) extension_data [const void *(*)(const char *)]
*/
#[repr(C)]
pub struct _LV2_Descriptor {
URI: *const libc::c_char,
instantiate: Option<extern fn(*const _LV2_Descriptor, libc::c_double, *const libc::c_char, *const *const _LV2_Feature) -> *mut libc::c_void>,
connect_port: Option<extern fn(*mut libc::c_void, libc::c_uint, *mut libc::c_void)>,
activate: Option<extern fn(*mut libc::c_void)>,
run: Option<extern fn(*mut libc::c_void, libc::c_uint)>,
deactivate: Option<extern fn(*mut libc::c_void)>,
cleanup: Option<extern fn(*mut libc::c_void)>,
extension_data: Option<extern fn(*const libc::c_char) -> *const libc::c_void>,
}
/*
struct
(LV2_Lib_Handle) handle [void *]
(uint32_t) size [unsigned int]
(void (*)(LV2_Lib_Handle)) cleanup [void (*)(void *)]
(const LV2_Descriptor *(*)(LV2_Lib_Handle, uint32_t)) get_plugin [const struct _LV2_Descriptor *(*)(void *, unsigned int)]
*/
#[repr(C)]
pub struct {
handle: *mut libc::c_void,
size: libc::c_uint,
cleanup: Option<extern fn(*mut libc::c_void)>,
get_plugin: Option<extern fn(*mut libc::c_void, libc::c_uint) -> *const _LV2_Descriptor>,
}
Traceback (most recent call last):
File "/home/badosu/Code/cxx2rs/cxx2rs.py", line 78, in <module>
main()
File "/home/badosu/Code/cxx2rs/cxx2rs.py", line 57, in main
print "/*\n%s*/" % stringify_function_declaration(func)
File "/home/badosu/Code/cxx2rs/stringify.py", line 21, in stringify_function_declaration
canonical_function_name(node),
File "/home/badosu/Code/cxx2rs/parser.py", line 94, in canonical_function_name
for p in parent_path(node):
File "/home/badosu/Code/cxx2rs/parser.py", line 89, in parent_path
res = parent_path(parent) + [parent]
File "/home/badosu/Code/cxx2rs/parser.py", line 86, in parent_path
if parent.spelling is None:
AttributeError: 'NoneType' object has no attribute 'spelling'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment