1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
cabal-version: 2.2
name: monkeypatch
version: 0.1.0.0
synopsis: Monkey-patch C module dependencies from haskell.
description: This tool generates all the glue neccessary to make use of
functions defined in a C source code file from Haskell. This
includes generating stubs for C functions the C file does not
define but does expect to be linked with. These stubs can be
overwritten at run-time from Haskell by using a setter (i.e. they
may be monkey-patched). Any stub that is called before it is
monkey-patched, has a default implementation that outputs a
console message with the symbol name and Haskell type.
.
For example,
.
> $ ./monkeypatch -- ctox/toxcore/onion_client.c
> writing MonkeyPatch/OnionClient.hs
> writing MonkeyPatch/OnionClient_patch.c
.
The C file name onion_client.c yielded a Haskell module
MonkeyPatch.OnionClient and another C module named
OnionClient_patch.c. The first contains all the foreign imports
neccessary to call functions defined in onion_client.c and also
setters for setting Haskell implementations for functions used,
but not defined, in the module. The OnionClient_patch.c provides
the symbols neccessary to link onion_client.c and invoke whatever
Haskell functions are set as their implementation.
.
Any options, such as -I include paths, neccessary to compile the C
file, may be passed before the file name, but after the \-\-.
Options provided before that symbol are interpretted by the
monkeypatch tool itself.
.
In some cases, such as when an external symbol is used that refers
to a variable or constant that is not a function, the tool will be
unable to generate a monkey-patchable stub. To work around this,
more than one C file can be specified. Only the last one on the
command line will export symbols to Haskell, the others may
provide C-implementations for dependencies that will not be
monkey-patched. These support modules may also be provided in
already-compiled form (as .o object files).
homepage: http://github.com/joecrayne/monkeypatch
bug-reports: http://github.com/joecrayne/monkeypatch/issues
license: GPL-3.0-only
license-file: LICENSE
author: Joe Crayne
maintainer: joe@jerkface.net
copyright: (c) 2018 Joseph Crayne
category: Development
extra-source-files: CHANGELOG.md
executable monkeypatch
main-is: monkeypatch.hs
other-modules: Comments
-- other-extensions:
build-depends: base >=4.10.1.0 && <=4.12
, containers ^>=0.5.10.2
, language-c
, haskell-src-exts
, bytestring
, syb
, template-haskell
, pretty
, pretty-show
, process
, directory
-- hs-source-dirs:
default-language: Haskell2010
|