aboutsummaryrefslogtreecommitdiff
path: root/lux-c++/source
diff options
context:
space:
mode:
Diffstat (limited to 'lux-c++/source')
-rw-r--r--lux-c++/source/program.lux87
1 files changed, 87 insertions, 0 deletions
diff --git a/lux-c++/source/program.lux b/lux-c++/source/program.lux
new file mode 100644
index 000000000..6bfa65d4f
--- /dev/null
+++ b/lux-c++/source/program.lux
@@ -0,0 +1,87 @@
+... 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)]
+ ["[0]" function]
+ [concurrency
+ ["[0]" async (.only Async)]]]
+ [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 (.only)
+ ["_" js]]
+ [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]
+ ["[0]" js (.only)
+ ["[0]" runtime]
+ ["[1]/[0]" reference]]]]]]
+ [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 _
+ (program []
+ (do io.monad
+ [? (cppyy::cppdef ["void say_hello() { std::cout << 123 << std::endl; }"])
+ .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++")))))