aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/ffi.php.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-08-24 05:23:45 -0400
committerEduardo Julian2021-08-24 05:23:45 -0400
commit36303d6cb2ce3ab9e36d045b9516c997bd461862 (patch)
treeb9d2f1495143054d61d9af129f36833624db9dac /stdlib/source/library/lux/ffi.php.lux
parentec1f31b5a1492d5e0ab260397291d4449483bbd9 (diff)
Outsourced the syntax for labelled type definitions to macros.
Diffstat (limited to 'stdlib/source/library/lux/ffi.php.lux')
-rw-r--r--stdlib/source/library/lux/ffi.php.lux127
1 files changed, 65 insertions, 62 deletions
diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux
index 453f2c59e..82208f783 100644
--- a/stdlib/source/library/lux/ffi.php.lux
+++ b/stdlib/source/library/lux/ffi.php.lux
@@ -23,11 +23,11 @@
["." code]
["." template]]]])
-(abstract: .public (Object brand) Any)
+(abstract: .public (Object brand) {} Any)
(template [<name>]
[(with_expansions [<brand> (template.identifier [<name> "'"])]
- (abstract: .public <brand> Any)
+ (abstract: .public <brand> {} Any)
(type: .public <name>
(..Object <brand>)))]
@@ -97,8 +97,9 @@
(type: Virtual_Method Common_Method)
(type: Method
- (#Static Static_Method)
- (#Virtual Virtual_Method))
+ (Variant
+ (#Static Static_Method)
+ (#Virtual Virtual_Method)))
(def: common_method
(Parser Common_Method)
@@ -119,8 +120,9 @@
..common_method)))
(type: Member
- (#Field Field)
- (#Method Method))
+ (Variant
+ (#Field Field)
+ (#Method Method)))
(def: member
(Parser Member)
@@ -132,8 +134,8 @@
(def: input_variables
(-> (List Nullable) (List [Bit Code]))
(|>> list.enumeration
- (list\map (function (_ [idx [nullable? type]])
- [nullable? (|> idx %.nat code.local_identifier)]))))
+ (list\each (function (_ [idx [nullable? type]])
+ [nullable? (|> idx %.nat code.local_identifier)]))))
(def: (nullable_type [nullable? type])
(-> Nullable Code)
@@ -165,9 +167,10 @@
(.panic! "Null is an invalid value!"))))))
(type: Import
- (#Class Text (Maybe Alias) Text (List Member))
- (#Function Static_Method)
- (#Constant Field))
+ (Variant
+ (#Class Text (Maybe Alias) Text (List Member))
+ (#Function Static_Method)
+ (#Constant Field)))
(def: import
(Parser Import)
@@ -219,8 +222,8 @@
(-> Code Code Code (List Nullable) Bit Bit Nullable Code)
(let [g!inputs (input_variables inputsT)]
(` (def: ((~ g!method)
- [(~+ (list\map product.right g!inputs))])
- (-> [(~+ (list\map nullable_type inputsT))]
+ [(~+ (list\each product.right g!inputs))])
+ (-> [(~+ (list\each nullable_type inputsT))]
(~ (|> (nullable_type outputT)
(try_type try?)
(io_type io?))))
@@ -230,7 +233,7 @@
(without_null g!temp outputT)
(` ("php apply"
(:as ..Function (~ source))
- (~+ (list\map (with_null g!temp) g!inputs)))))))))))
+ (~+ (list\each (with_null g!temp) g!inputs)))))))))))
(syntax: .public (import: [import ..import])
(with_identifiers [g!temp]
@@ -247,54 +250,54 @@
class_import (` ("php constant" (~ (code.text class))))]
(in (list& (` (type: (~ g!type)
(..Object (primitive (~ (code.text class))))))
- (list\map (function (_ member)
- (case member
- (#Field [static? field alias fieldT])
- (if static?
- (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) [])
- (\ (~! meta.monad) (~' in)
- (list (` (.:as (~ (nullable_type fieldT))
- ("php constant" (~ (code.text (%.format class "::" field))))))))))
- (` (def: ((~ (qualify field))
- (~ g!object))
- (-> (~ g!type)
- (~ (nullable_type fieldT)))
- (:expected
- (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field))
- (:as (..Object .Any) (~ g!object))))))))))
-
- (#Method method)
- (case method
- (#Static [method alias inputsT io? try? outputT])
- (..make_function (qualify (maybe.else method alias))
- g!temp
- (` ("php object get" (~ (code.text method))
- (:as (..Object .Any)
- ("php constant" (~ (code.text (%.format class "::" method)))))))
- inputsT
- io?
- try?
- outputT)
-
- (#Virtual [method alias inputsT io? try? outputT])
- (let [g!inputs (input_variables inputsT)]
- (` (def: ((~ (qualify (maybe.else method alias)))
- [(~+ (list\map product.right g!inputs))]
- (~ g!object))
- (-> [(~+ (list\map nullable_type inputsT))]
- (~ g!type)
- (~ (|> (nullable_type outputT)
- (try_type try?)
- (io_type io?))))
- (:expected
- (~ (<| (with_io io?)
- (with_try try?)
- (without_null g!temp outputT)
- (` ("php object do"
- (~ (code.text method))
- (~ g!object)
- (~+ (list\map (with_null g!temp) g!inputs)))))))))))))
- members)))))
+ (list\each (function (_ member)
+ (case member
+ (#Field [static? field alias fieldT])
+ (if static?
+ (` ((~! syntax:) ((~ (qualify (maybe.else field alias))) [])
+ (\ (~! meta.monad) (~' in)
+ (list (` (.:as (~ (nullable_type fieldT))
+ ("php constant" (~ (code.text (%.format class "::" field))))))))))
+ (` (def: ((~ (qualify field))
+ (~ g!object))
+ (-> (~ g!type)
+ (~ (nullable_type fieldT)))
+ (:expected
+ (~ (without_null g!temp fieldT (` ("php object get" (~ (code.text field))
+ (:as (..Object .Any) (~ g!object))))))))))
+
+ (#Method method)
+ (case method
+ (#Static [method alias inputsT io? try? outputT])
+ (..make_function (qualify (maybe.else method alias))
+ g!temp
+ (` ("php object get" (~ (code.text method))
+ (:as (..Object .Any)
+ ("php constant" (~ (code.text (%.format class "::" method)))))))
+ inputsT
+ io?
+ try?
+ outputT)
+
+ (#Virtual [method alias inputsT io? try? outputT])
+ (let [g!inputs (input_variables inputsT)]
+ (` (def: ((~ (qualify (maybe.else method alias)))
+ [(~+ (list\each product.right g!inputs))]
+ (~ g!object))
+ (-> [(~+ (list\each nullable_type inputsT))]
+ (~ g!type)
+ (~ (|> (nullable_type outputT)
+ (try_type try?)
+ (io_type io?))))
+ (:expected
+ (~ (<| (with_io io?)
+ (with_try try?)
+ (without_null g!temp outputT)
+ (` ("php object do"
+ (~ (code.text method))
+ (~ g!object)
+ (~+ (list\each (with_null g!temp) g!inputs)))))))))))))
+ members)))))
(#Function [name alias inputsT io? try? outputT])
(let [imported (` ("php constant" (~ (code.text name))))]