-
Notifications
You must be signed in to change notification settings - Fork 49
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
Some way to import c-header-files directly would be a huge advantage #166
Comments
I think, it may be easier to implement it as output driver for c2ffi, see this (untested, will not compile, currently only have older llvm installed): |
Given that the existing output drivers for c2ffi are language-agnostic, it looks like it would be difficult to have it merged upstream. If a user's OS packages c2ffi, too, then it's more hassle for them to have to compile a custom version rather than using the existing one and passing its output to a Perl script. |
Nice, most things should work now. Unions may be implemented as variants maybe, but I don't think, they are important. |
One simple error I found: |
Some other problem: |
I currently try to make a more complete opengl wrapper using your perl program: https://github.com/porky11/dale-opengl |
Thanks for raising this issue, the script should cover the main use cases well enough now. Some comments on specifics:
This has been implemented.
Do you mean using the per-binding file information from the c2ffi data to produce separate output files?
This has been implemented, via the
This is a tricky problem, as per your comments. Using macros just for void typedefs won't work, and using them for all typedefs will make the common case more annoying, as well as requiring parentheses for struct typedefs due to not being able to distinguish them from others. Given that this should be relatively uncommon, it skips defining them and leaves it to the user to fix, per your pull request. |
I meant you can specify multiple files for different objects (one for functions, one for constants etc.), but I don't think, this is that useful (pcl-autowrap can do it, I think). Specifying output files seems useful enough which can also be done by multiple calls. |
I found some problems: |
Not sure how I missed the need to retain the original bindings :S. It should work properly now. The option to include only the bindings from a specified file has been restored, too, via the |
some things don't work correctly
I get this:
Errors:
Namespaces don't get expanded correctly:
Other problem: when namespaces and casing is enabled, not everything gets cased the same way. For type-definitions, they prefix only is dropped at define position, sometimes casing is disabled. For variant sub-struct names casing and namespaces are disabled. |
Thanks, these problems have been fixed (assuming I understand all the problems correctly). |
Most important was the double struct problem, which lasts pretty long to fix manually. |
Hey, can't macros in dale execute basically any code? If you can. You could write a C pre-processor in dale. And a C parser. And then you could use those to implement an include macro which processes and parses and generates declarations in dale? Seems like it would be neat to be able to just include C files in the language instead of running an external tool. Afaik Terra does something like this. |
Parsing directly in dale was also my first idea. Maybe that's better than using c2ffi, since some information isn't shown in its output. |
I think since there is shared pointers etc it should be easy to use that to build some higher level DSL stuff which makes it feel fairly high level. You could probably basically implement scheme except without the eval. But to be honest when I write parsers in higher level languages I miss pointer arithmetic. |
For optimal usability you'd really kind of need to parse the header and transpile it. Since they could sometimes contain static function definitions or C macros. So you'd also need to be able to translate that into dale lol. But You could probably also just skip them since that's rare. And in that case a Dale programmer can translate by hand. |
I also thought, it would be possible to implement some real lisp (i.e. CL) in dale. Most things should be implementable in dale itself, reader macros would need parsing, which could also be done in dale, but not (that easily) be used in the same file. |
And writing eval should also be possible. There is a cto function called eval-expression, so it's possible to add a repl with something like this
|
Yeah compile time eval is possible. I just meant that without implementing an actual interpreter that you embed in your program, you can't have runtime eval that modifies the entire dale program. It would sort of live a little bit outside your dale program, but you could still use compile-time introspection to expose basically all of your program's API to an interactive environment! Well, in C, when you parse a string you can just use pointer arithmetic while iterating over, and if you have a function like But yeah I would like to have reader macros in dale itself. Lisps quasi quotation syntax is more pleasant than qq. So it would be neat to be able to make a quasi quote reader macro that expands to qq. |
When I wrote a parser in C (or when writing read macros in CL) I just used read-char, peek-char and unread-char, but for more complicated parsers this may probably become too complicated. Wouldn't it be preferable to define some Substring class, which contains two indices and a string reference, instead of copying? I like that dale itself doesn't have reader macros, so it's easier to use it as IR, that's easy to generate. |
Well in some parsers you wanna be able to backtrack when you failed parsing. And a nice way to do this is to just save the pointer for the current state, try to parse, and then if you fail set the value back to where it starter. For the thing you mentioned that's basically what I did in .NET but with only an offset from the beginning since I don't need to offset from the end of the string while parsing. I don't see how having reader macros in Dale would make it harder to use it as IR. And nor is the purpose of Dale to be IR to the best of my knowledge. |
I just thought, it would also be good as IR for other languages, since generating sexpressions is easier than generating llvm or similar directly. |
I mean that's fine. But having reader macros in dale would be a none issue for that use case. Since you would still have the ability to output code that is without reader macros. |
This may be done with c2ffi, (but I'm not experienced with it, nor json)
It could be implemented as a cto-function and macro
I need to know the functions anyway, but when I need foreign types and variables, where I don't have to know the exact values, nor all struct fields, I'd still have to rewrite them in dale for all libraries.
maybe even cl-autowrap can be copied without too much effort
The text was updated successfully, but these errors were encountered: