Comments (6)
It works like this:
- you use the same ctypes API to describe structs, functions, etc.
(so you should be able to keep your existing code mostly intact) - you place the descriptions from step 1 inside functors that accept modules of type
Ctypes.TYPE
(for the structs) andCtypes.FOREIGN
(for the functions). - you pass the functors to
Cstubs.write_ml
andCstubs.write_c
to generate code that you can statically link into your program.
Conceptually, the idea is to give the ctypes bindings DSL a different interpretation so that it works as a compiler than an interpreter. The tradeoffs are similar to the interpreter/compiler tradeoff, too: it's a bit more work to set up the build, but in return you get faster code and better type-checking (since the generated code is checked against library headers).
If you decide to try this route there are various examples around, such as ocaml-mariadb
or ocaml-yaml
that it might be useful to copy.
from libdash.
Out of interest, have you considered using ctypes without dynamic linking?
from libdash.
No, I hadn't, because I didn't know you could. You've got my attention! How does it work?
from libdash.
That sounds very promising! I'll take a look.
I would need ocamlmklib
call that just included the .a
file from the original library along with the .o
from those generated stubs, right? I'd generate the stubs at build time and then be able to ship a single, statically linked .cmxa
?
from libdash.
I would need
ocamlmklib
call that just included the.a
file from the original library along with the.o
from those generated stubs, right?
Yes, along with the .cmx
code from the generated OCaml.
I'd generate the stubs at build time and then be able to ship a single, statically linked
.cmxa
?
Yes.
from libdash.
Resolved in #29.
from libdash.
Related Issues (17)
- Incorrect handling of single-quoted escape sequences in `ast.ml`
- Add OPAM testing to CI HOT 1
- Unify AST with Smoosh
- Prompt callbacks HOT 1
- Better pretty printing HOT 2
- Parsing and unparsing has super-linear runtime HOT 6
- AST mishandles for loop arguments
- Build on macOS produces funny .so files HOT 1
- Proper documentation of AST
- Migrating python bindings from PaSh
- Shell AST server HOT 1
- Failed building wheel for libdash on Apple Silicon
- Completion of error handling HOT 1
- Use shasta to return python AST objects
- Move to binpash organization
- Add `CTLMBCHAR` support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libdash.