aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/ffi.js.lux
blob: 07c5e5759bd911212a9ddbd2c38c18bede64fe01 (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
(.require
 [library
  [lux (.except int char)
   ["$" documentation]
   [data
    ["[0]" text (.only \n)
     ["%" \\format (.only format)]]]]]
 [\\library
  ["[0]" /]])

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [($.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?)

             ($.documentation /.null
               "The null pointer.")

             ($.documentation /.import
               "Easily import types, methods, functions and constants."
               [(import Uint8Array
                  "[1]::[0]")

                (import TextEncoder
                  "[1]::[0]"
                  (new [/.String])
                  (encode [/.String] Uint8Array))

                (import TextDecoder
                  "[1]::[0]"
                  (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.")
               [(is /.Function
                    (closure [left right]
                             (do_something (as Foo left) (as Bar right))))])]
            []))