aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/ffi.py.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/ffi.py.lux')
-rw-r--r--stdlib/source/library/lux/ffi.py.lux37
1 files changed, 33 insertions, 4 deletions
diff --git a/stdlib/source/library/lux/ffi.py.lux b/stdlib/source/library/lux/ffi.py.lux
index 93eaf6ccc..70b9fe281 100644
--- a/stdlib/source/library/lux/ffi.py.lux
+++ b/stdlib/source/library/lux/ffi.py.lux
@@ -23,11 +23,13 @@
["." code]
["." template]]]])
-(abstract: .public (Object brand) Any)
+(abstract: .public (Object brand)
+ {}
+ Any)
(template [<name>]
[(with_expansions [<brand> (template.identifier [<name> "'"])]
- (abstract: <brand> Any)
+ (abstract: <brand> {} Any)
(type: .public <name>
(..Object <brand>)))]
@@ -212,7 +214,29 @@
(:as ..Function (~ source))
(~+ (list\map (with_none g!temp) g!inputs)))))))))))
-(syntax: .public (import: {import ..import})
+(syntax: .public (import: [import ..import])
+ {#.doc (example "Easily import types, methods, functions and constants."
+ (import: os
+ ["#::."
+ (#static F_OK ..Integer)
+ (#static R_OK ..Integer)
+ (#static W_OK ..Integer)
+ (#static X_OK ..Integer)
+
+ (#static mkdir [..String] #io #try #? Any)
+ (#static access [..String ..Integer] #io #try ..Boolean)
+ (#static remove [..String] #io #try #? Any)
+ (#static rmdir [..String] #io #try #? Any)
+ (#static rename [..String ..String] #io #try #? Any)
+ (#static listdir [..String] #io #try (Array ..String))])
+
+ (import: os/path
+ ["#::."
+ (#static isfile [..String] #io #try ..Boolean)
+ (#static isdir [..String] #io #try ..Boolean)
+ (#static sep ..String)
+ (#static getsize [..String] #io #try ..Integer)
+ (#static getmtime [..String] #io #try ..Float)]))}
(with_identifiers [g!temp]
(case import
(#Class [class format members])
@@ -252,7 +276,7 @@
(#Field [static? field fieldT])
(if static?
- (` ((~! syntax:) ((~ (qualify field)))
+ (` ((~! syntax:) ((~ (qualify field)) [])
(\ (~! meta.monad) (~' in)
(list (` (.:as (~ (noneable_type fieldT))
("python object get" (~ (code.text field))
@@ -308,6 +332,11 @@
)))
(template: .public (lambda <inputs> <output>)
+ {#.doc (example "Allows defining closures/anonymous-functions in the form that Python expects."
+ "This is useful for adapting Lux functions for usage by Python code."
+ (: ..Function
+ (lambda [left right]
+ (do_something (:as Foo left) (:as Bar right)))))}
(.:as ..Function
(`` ("python function"
(~~ (template.amount <inputs>))