aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/target/c++/type.lux
blob: 3ee6de6fb9f2e3e3623b3847b4a33ed83f59d378 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except char int function)
   [meta
    [macro
     ["[0]" template]]]]]
 ["/" //])

(with_template [<name>]
  [(def .public <name>
     /.Type
     (/.type (/.global [(list) (template.text [<name>])] (list))))]

  [void]
  [bool]
  [char]
  [short]
  [int]
  [long]
  [float]
  [double]
  )

(with_template [<ns> <name>/*]
  [(`` (with_template [<lux> <c++>]
         [(def .public <lux>
            /.Type
            (/.type (/.global [(list <ns>) <c++>] (list))))]

         (,, (template.spliced <name>/*))))]

  ... https://en.cppreference.com/w/cpp/string/basic_string
  [/.standard
   [[string "string"]
    [wide_string "wstring"]
    [u08_string "u8string"]
    [u16_string "u16string"]
    [u32_string "u32string"]]]
  )

(with_template [<lux> <c++>]
  [(def .public <lux>
     /.Type
     (/.type (/.global [(list) <c++>] (list))))]

  [char08 "char8_t"]
  [char16 "char16_t"]
  [char32 "char32_t"]

  [int_08 "int8_t"]
  [int_16 "int16_t"]
  [int_32 "int32_t"]
  [int_64 "int64_t"]

  [int_fast_08 "int_fast8_t"]
  [int_fast_16 "int_fast16_t"]
  [int_fast_32 "int_fast32_t"]
  [int_fast_64 "int_fast64_t"]

  [int_least_08 "int_least8_t"]
  [int_least_16 "int_least16_t"]
  [int_least_32 "int_least32_t"]
  [int_least_64 "int_least64_t"]

  [int_max "intmax_t"]
  [int_ptr "intptr_t"]
  
  [uint_08 "uint8_t"]
  [uint_16 "uint16_t"]
  [uint_32 "uint32_t"]
  [uint_64 "uint64_t"]

  [uint_fast_08 "uint_fast8_t"]
  [uint_fast_16 "uint_fast16_t"]
  [uint_fast_32 "uint_fast32_t"]
  [uint_fast_64 "uint_fast64_t"]

  [uint_least_08 "uint_least8_t"]
  [uint_least_16 "uint_least16_t"]
  [uint_least_32 "uint_least32_t"]
  [uint_least_64 "uint_least64_t"]

  [uint_max "uintmax_t"]
  [uint_ptr "uintptr_t"]
  )

(def .public shared_ptr
  (-> /.Type
      /.Type)
  (|>> list
       (/.global [(list /.standard) "shared_ptr"])
       /.type))

(def .public (function arguments return)
  (-> (List /.Parameter) /.Parameter
      /.Type)
  (/.type (/.global [(list /.standard) "function"]
                    (list (/.function_type_parameter arguments return)))))