aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/ffi.js.lux
blob: 81082ada3ba4ca06328767c484466041c563a7c9 (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
68
69
70
71
72
73
74
(.using
 [library
  [lux {"-" int char type :as}
   ["$" documentation {"+" documentation:}]
   [data
    ["[0]" text {"+" \n}
     ["%" format {"+" format}]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(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.")
  [(: /.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?)]
            []))