blob: 3c3a037fcbdfbe2333089cd0a54a43b15c6464f5 (
plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
... https://github.com/wlav/cppyy
(.require
[library
[lux (.except)
[program (.only program)]
["[0]" ffi (.only import)]
["[0]" debug]
[abstract
[monad (.only do)]]
[control
["[0]" maybe (.use "[1]#[0]" monad)]
["[0]" try (.only Try)]
["[0]" exception (.only Exception)]
["[0]" io (.only IO io)]]
[data
["[0]" product]
[text
["%" \\format (.only format)]
[encoding
["[0]" utf8]]]
[collection
["[0]" array (.only Array)]]]
[math
[number
["n" nat]
["i" int]
["[0]" i64]]]
["[0]" world
["[0]" file]
["[1]/[0]" environment]]
[meta
[target
["_" c++]]
[macro
["^" pattern]
["[0]" template]]
[compiler
[reference
[variable (.only Register)]]
[language
[lux
[program (.only Program)]
[translation (.only Host)]
[analysis
[macro (.only Expander)]]
["[0]" phase (.only Operation Phase)
["[0]" extension (.only Extender Handler)
["[0]" analysis
["[1]" js]]
["[0]" translation
["[1]" js]]]
[translation
["[0]" reference]
[c++
["[0]" runtime]
["[0]" type]
["[0]" primitive]]]]]]
[default
["[0]" platform (.only Platform)]]
[meta
["[0]" cli]
["[0]" context]
[archive (.only Archive)
["[0]" unit]]
["[0]" packager
["[1]" script]]]]]]]
[program
["/" compositor]])
(import cppyy
"[1]::[0]"
("static" cppdef [Text] "io" Bit)
("static" gbl (ffi.Object Any)))
(def standard_out (_.global [_.standard "cout"] (list)))
(def \n (_.global [_.standard "endl"] (list)))
(def (print it)
(-> _.Expression
_.Statement)
(|> standard_out
(_.<< it)
(_.<< \n)
_.;))
(with_expansions [<say_hello> "say_hello"]
(def _
(program []
(do io.monad
[? (cppyy::cppdef [(_.code (all _.then
runtime.declaration
(_.include "iostream")
(_.function (_.local <say_hello>)
(list)
(list)
_.void
(all _.then
... (print (primitive.bit true))
... (print (primitive.i64 +123))
... (print (primitive.f64 -456.789))
... (print (primitive.text "YOLO"))
... (print (runtime.lux_value type.bit (primitive.bit true)))
... (print (runtime.lux_value type.i64 (primitive.i64 +123)))
... (print (runtime.lux_value type.f64 (primitive.f64 -456.789)))
... (print (runtime.lux_value type.text (primitive.text "YOLO")))
... (print (_.deref (runtime.host_value type.bit (runtime.lux_value type.bit (primitive.bit true)))))
(print (_.deref (runtime.host_value type.i64 (runtime.lux_value type.i64 (primitive.i64 +123)))))
... (print (_.deref (runtime.host_value type.f64 (runtime.lux_value type.f64 (primitive.f64 -456.789)))))
... (print (_.deref (runtime.host_value type.text (runtime.lux_value type.text (primitive.text "YOLO")))))
))))])
.let [_ (debug.log! (%.format "BEFORE " (%.bit ?)))]
global (cppyy::gbl)
.let [say_hello (as ffi.Function
(.python_object_get# <say_hello> global))
_ (debug.log! "AFTER")
_ (.python_apply# say_hello [])]]
(in (debug.log! "Hello, C++"))))))
|