From 4051a1cbe0999ee22bc395b059ea1556bcc002a0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 1 Sep 2021 01:01:22 -0400 Subject: Updates to the JS compiler. --- stdlib/source/documentation/lux/ffi.js.lux | 73 ++++++++++++++++++++++ .../source/documentation/lux/meta/annotation.lux | 5 +- 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 stdlib/source/documentation/lux/ffi.js.lux (limited to 'stdlib/source/documentation') diff --git a/stdlib/source/documentation/lux/ffi.js.lux b/stdlib/source/documentation/lux/ffi.js.lux new file mode 100644 index 000000000..72ee6ef34 --- /dev/null +++ b/stdlib/source/documentation/lux/ffi.js.lux @@ -0,0 +1,73 @@ +(.module: + [library + [lux (#- int char type :as) + ["$" documentation (#+ documentation:)] + [data + ["." text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.null + "The null pointer.") + +(documentation: /.import: + "Easily import types, methods, functions and constants." + [(import: Uint8Array) + + (import: TextEncoder + ["#::." + (new [/.String]) + (encode [/.String] Uint8Array)]) + + (import: TextDecoder + ["#::." + (new [/.String]) + (decode [/.String] String)])]) + +(documentation: /.type_of + "The type of an object, as text." + [(= "boolean" + (type_of #1))] + [(= "number" + (type_of +123.456))] + [(= "string" + (type_of "789"))] + [(= "function" + (type_of (function (_ value) value)))]) + +(documentation: /.constant + "Allows using definitions from the JavaScript host platform." + [(constant .Frac [Math PI])]) + +(documentation: /.closure + (format "Allows defining closures/anonymous-functions in the form that JavaScript expects." + \n "This is useful for adapting Lux functions for usage by JavaScript code.") + [(: /.Function + (closure [left right] + (do_something (:as Foo left) (:as Bar right))))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..null + ..import: + ..type_of + ..constant + ..closure + ($.default (/.Object brand)) + ($.default /.Function) + ($.default /.Symbol) + ($.default /.Null) + ($.default /.Undefined) + ($.default /.Boolean) + ($.default /.Number) + ($.default /.String) + ($.default /.null?) + ($.default /.on_browser?) + ($.default /.on_nashorn?) + ($.default /.on_node_js?)] + [])) diff --git a/stdlib/source/documentation/lux/meta/annotation.lux b/stdlib/source/documentation/lux/meta/annotation.lux index c46961d3a..2ddb4826a 100644 --- a/stdlib/source/documentation/lux/meta/annotation.lux +++ b/stdlib/source/documentation/lux/meta/annotation.lux @@ -46,9 +46,6 @@ ..tuple ..record ($.default /.Annotation) - ($.default /.documentation) ($.default /.flagged?) - ($.default /.implementation?) - ($.default /.function_arguments) - ($.default /.type_arguments)] + ($.default /.implementation?)] [])) -- cgit v1.2.3