functionalscript 0.0.591 → 0.1.593
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +3 -3
- package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
- package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.mjs +9 -0
- package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
- package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cs/testlib.f.mjs +10 -0
- package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
- package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
- package/com/rust/testlib.f.mjs +10 -0
- package/com/test/{build.f.cjs → build.f.mjs} +6 -6
- package/com/test/{build.cjs → build.mjs} +16 -8
- package/com/types/{module.f.cjs → module.f.mjs} +9 -8
- package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
- package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
- package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
- package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
- package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
- package/commonjs/module.f.mjs +11 -0
- package/commonjs/{module.cjs → module.mjs} +8 -6
- package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
- package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
- package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
- package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
- package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
- package/commonjs/{test.cjs → test.mjs} +4 -4
- package/dev/{module.f.cjs → module.f.mjs} +1 -1
- package/dev/module.mjs +20 -13
- package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
- package/dev/{test.f.cjs → test.f.mjs} +1 -1
- package/dev/test.mjs +1 -1
- package/djs/{module.f.cjs → module.f.mjs} +18 -15
- package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
- package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/djs/{test.f.cjs → test.f.mjs} +7 -5
- package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
- package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/fsc/{module.f.cjs → module.f.mjs} +17 -16
- package/fsc/{test.f.cjs → test.f.mjs} +6 -4
- package/fsm/{module.f.cjs → module.f.mjs} +28 -24
- package/fsm/{test.f.cjs → test.f.mjs} +13 -9
- package/html/{module.f.cjs → module.f.mjs} +16 -13
- package/html/{test.f.cjs → test.f.mjs} +5 -5
- package/index.f.mjs +83 -0
- package/issues/README.md +15 -0
- package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
- package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/json/{module.f.cjs → module.f.mjs} +18 -17
- package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
- package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
- package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
- package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
- package/json/{test.f.cjs → test.f.mjs} +6 -4
- package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
- package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
- package/jsr.json +2 -2
- package/nodejs/version/main.mjs +5 -0
- package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
- package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
- package/package.json +4 -4
- package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
- package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
- package/secp/{module.f.cjs → module.f.mjs} +7 -6
- package/secp/{test.f.cjs → test.f.mjs} +6 -6
- package/sha2/{module.f.cjs → module.f.mjs} +5 -5
- package/sha2/{test.f.cjs → test.f.mjs} +7 -6
- package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
- package/text/ascii/test.f.mjs +14 -0
- package/text/{module.f.cjs → module.f.mjs} +6 -6
- package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
- package/text/{test.f.cjs → test.f.mjs} +5 -4
- package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
- package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
- package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
- package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
- package/tsconfig.json +2 -2
- package/types/array/{module.f.cjs → module.f.mjs} +2 -2
- package/types/array/{test.f.cjs → test.f.mjs} +5 -4
- package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
- package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
- package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
- package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
- package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
- package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
- package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
- package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
- package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
- package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
- package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
- package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
- package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
- package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
- package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
- package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
- package/types/function/{module.f.cjs → module.f.mjs} +1 -5
- package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
- package/types/function/{test.f.cjs → test.f.mjs} +4 -2
- package/types/list/{module.f.cjs → module.f.mjs} +12 -12
- package/types/list/{test.f.cjs → test.f.mjs} +13 -11
- package/types/map/{module.f.cjs → module.f.mjs} +21 -18
- package/types/map/{test.f.cjs → test.f.mjs} +5 -4
- package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
- package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
- package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
- package/types/number/module.f.mjs +26 -0
- package/types/number/{test.f.cjs → test.f.mjs} +3 -2
- package/types/object/{module.f.cjs → module.f.mjs} +6 -6
- package/types/object/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range/{module.f.cjs → module.f.mjs} +1 -1
- package/types/range/{test.f.cjs → test.f.mjs} +2 -2
- package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
- package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
- package/types/result/{module.f.cjs → module.f.mjs} +1 -1
- package/types/result/{module.cjs → module.mjs} +3 -3
- package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
- package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
- package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
- package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
- package/types/string/{module.f.cjs → module.f.mjs} +8 -7
- package/types/string/{test.f.cjs → test.f.mjs} +5 -3
- package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
- package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
- package/com/cpp/testlib.f.cjs +0 -6
- package/com/cs/testlib.f.cjs +0 -6
- package/com/module.f.cjs +0 -6
- package/com/rust/testlib.f.cjs +0 -6
- package/commonjs/module.f.cjs +0 -20
- package/index.f.cjs +0 -40
- package/nodejs/module.f.cjs +0 -4
- package/nodejs/version/main.cjs +0 -6
- package/text/ascii/test.f.cjs +0 -12
- package/types/number/module.f.cjs +0 -24
- package/types/object/test.html +0 -9
package/.github/workflows/ci.yml
CHANGED
|
@@ -34,14 +34,14 @@ jobs:
|
|
|
34
34
|
|
|
35
35
|
strategy:
|
|
36
36
|
matrix:
|
|
37
|
-
deno-version: [2]
|
|
37
|
+
deno-version: [1, 2]
|
|
38
38
|
|
|
39
39
|
steps:
|
|
40
40
|
- uses: actions/checkout@v2
|
|
41
41
|
- uses: denoland/setup-deno@v1
|
|
42
42
|
with:
|
|
43
43
|
deno-version: ${{ matrix.deno-version }}
|
|
44
|
-
- run: deno run --quiet --allow-read --allow-env --allow-net
|
|
44
|
+
- run: deno run --quiet --allow-read --allow-env --allow-net ./dev/test.mjs
|
|
45
45
|
|
|
46
46
|
bun:
|
|
47
47
|
|
|
@@ -64,7 +64,7 @@ jobs:
|
|
|
64
64
|
- uses: actions/checkout@v3
|
|
65
65
|
- uses: actions/setup-node@v2
|
|
66
66
|
with:
|
|
67
|
-
node-version:
|
|
67
|
+
node-version: 23
|
|
68
68
|
- uses: actions/setup-dotnet@v3
|
|
69
69
|
with:
|
|
70
70
|
dotnet-version: 9
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import types, * as typesT from '../types/module.f.mjs'
|
|
2
|
+
import text, * as textT from '../../text/module.f.mjs'
|
|
3
|
+
import obj, * as O from '../../types/object/module.f.mjs'
|
|
4
|
+
import list from '../../types/list/module.f.mjs'
|
|
5
|
+
import string from '../../types/string/module.f.mjs'
|
|
6
|
+
const { join } = string
|
|
2
7
|
const { paramList } = types
|
|
3
|
-
const text = require('../../text/module.f.cjs')
|
|
4
|
-
const obj = require('../../types/object/module.f.cjs')
|
|
5
|
-
const list = require('../../types/list/module.f.cjs')
|
|
6
8
|
const { map, flatMap, flat } = list
|
|
7
|
-
const { join } = require('../../types/string/module.f.cjs')
|
|
8
9
|
const { entries } = Object
|
|
9
10
|
|
|
10
|
-
/** @type {(name: string) => (body:
|
|
11
|
+
/** @type {(name: string) => (body: textT.Block) => textT.Block} */
|
|
11
12
|
const struct = name => body => [`struct ${name}`, '{', body, '};']
|
|
12
13
|
|
|
13
14
|
const baseTypeMap = {
|
|
@@ -26,7 +27,7 @@ const baseTypeMap = {
|
|
|
26
27
|
bool: 'bool',
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
/** @type {(t:
|
|
30
|
+
/** @type {(t: typesT.BaseType) => string} */
|
|
30
31
|
const baseType = t => baseTypeMap[t]
|
|
31
32
|
|
|
32
33
|
const resultVoid = types.result('void')
|
|
@@ -42,17 +43,17 @@ const ptr = id => `${id} const*`
|
|
|
42
43
|
/** @type {(id: string) => string} */
|
|
43
44
|
const ref = id => `${id} const&`
|
|
44
45
|
|
|
45
|
-
/** @type {(p:
|
|
46
|
+
/** @type {(p: typesT.Field) => string} */
|
|
46
47
|
const paramName = ([name]) => name
|
|
47
48
|
|
|
48
49
|
const mapParamName = map(paramName)
|
|
49
50
|
|
|
50
51
|
const joinComma = join(', ')
|
|
51
52
|
|
|
52
|
-
/** @type {(name: string) => (lib:
|
|
53
|
+
/** @type {(name: string) => (lib: typesT.Library) => textT.Block} */
|
|
53
54
|
const cpp = name => lib => {
|
|
54
55
|
|
|
55
|
-
/** @type {(t:
|
|
56
|
+
/** @type {(t: typesT.Type) => string|null} */
|
|
56
57
|
const interface_ = t => {
|
|
57
58
|
if (!(t instanceof Array) || t.length !== 1) {
|
|
58
59
|
return null
|
|
@@ -61,7 +62,7 @@ const cpp = name => lib => {
|
|
|
61
62
|
return 'interface' in lib[name] ? name : null
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
/** @type {(i: (t: string) => string) => (t:
|
|
65
|
+
/** @type {(i: (t: string) => string) => (t: typesT.Type) => string} */
|
|
65
66
|
const objectType = i => t => {
|
|
66
67
|
if (typeof (t) === 'string') { return baseType(t) }
|
|
67
68
|
if (t.length === 2) { return `${type(t[1])} const*` }
|
|
@@ -73,27 +74,27 @@ const cpp = name => lib => {
|
|
|
73
74
|
|
|
74
75
|
const resultType = objectType(ptr)
|
|
75
76
|
|
|
76
|
-
/** @type {(s:
|
|
77
|
+
/** @type {(s: typesT.Field) => textT.Item} */
|
|
77
78
|
const field = ([name, t]) => `${type(t)} ${name};`
|
|
78
79
|
|
|
79
80
|
const mapField = map(field)
|
|
80
81
|
|
|
81
|
-
/** @type {(s:
|
|
82
|
+
/** @type {(s: typesT.Struct) => textT.Block} */
|
|
82
83
|
const defStruct = s => mapField(entries(s.struct))
|
|
83
84
|
|
|
84
|
-
/** @type {(fa:
|
|
85
|
+
/** @type {(fa: typesT.FieldArray) => string} */
|
|
85
86
|
const cppResult = resultVoid(resultType)
|
|
86
87
|
|
|
87
|
-
/** @type {(p:
|
|
88
|
+
/** @type {(p: typesT.Field) => string} */
|
|
88
89
|
const param = ([name, t]) => `${objectType(ref)(t)} ${name}`
|
|
89
90
|
|
|
90
91
|
const mapParam = map(param)
|
|
91
92
|
|
|
92
|
-
/** @type {(result: string) => (paramArrayStr: string) => (name: string) =>
|
|
93
|
+
/** @type {(result: string) => (paramArrayStr: string) => (name: string) => textT.Item} */
|
|
93
94
|
const methodHeader = result => paramArrayStr => name =>
|
|
94
95
|
`virtual ${result} ${name}${paramArrayStr} const noexcept = 0;`
|
|
95
96
|
|
|
96
|
-
/** @type {(m:
|
|
97
|
+
/** @type {(m: typesT.Method) => readonly textT.Item[]} */
|
|
97
98
|
const method = ([name, paramArray]) => {
|
|
98
99
|
const result = cppResult(paramArray)
|
|
99
100
|
const paramL = paramList(paramArray)
|
|
@@ -114,7 +115,7 @@ const cpp = name => lib => {
|
|
|
114
115
|
|
|
115
116
|
const mapMethod = flatMap(method)
|
|
116
117
|
|
|
117
|
-
/** @type {(i:
|
|
118
|
+
/** @type {(i: typesT.Interface) => textT.Block} */
|
|
118
119
|
const defInterface = ({ guid, interface: i }) => {
|
|
119
120
|
const g = guid.replaceAll('-', '');
|
|
120
121
|
const lo = g.substring(0, 16);
|
|
@@ -125,7 +126,7 @@ const cpp = name => lib => {
|
|
|
125
126
|
])
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
/** @type {(kv:
|
|
129
|
+
/** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
|
|
129
130
|
const def = ([name, d]) => 'interface' in d
|
|
130
131
|
? [
|
|
131
132
|
`class ${name} : public ::nanocom::IUnknown`,
|
|
@@ -136,7 +137,7 @@ const cpp = name => lib => {
|
|
|
136
137
|
]
|
|
137
138
|
: struct(name)(defStruct(d))
|
|
138
139
|
|
|
139
|
-
/** @type {(kv:
|
|
140
|
+
/** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
|
|
140
141
|
const forward = ([name]) => [`struct ${name};`]
|
|
141
142
|
|
|
142
143
|
const e = entries(lib)
|
|
@@ -147,7 +148,7 @@ const cpp = name => lib => {
|
|
|
147
148
|
])
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
+
export default {
|
|
151
152
|
/** @readonly */
|
|
152
153
|
cpp,
|
|
153
154
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import string from '../../types/string/module.f.mjs'
|
|
2
|
+
const { join } = string
|
|
3
|
+
import text from '../../text/module.f.mjs'
|
|
4
|
+
const { flat } = text
|
|
5
|
+
import library from '../types/testlib.f.mjs'
|
|
6
|
+
import m from './module.f.mjs'
|
|
7
|
+
const { cpp } = m
|
|
8
|
+
|
|
9
|
+
export default () => join('\n')(flat(' ')(cpp('My')(library)))
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import types, * as typesT from '../types/module.f.mjs'
|
|
2
2
|
const { result, paramList } = types
|
|
3
|
-
|
|
3
|
+
import text, * as textT from '../../text/module.f.mjs'
|
|
4
4
|
const { curly } = text
|
|
5
|
-
|
|
5
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
6
6
|
const { flat, map, some, flatMap } = list
|
|
7
|
-
|
|
8
|
-
const
|
|
7
|
+
import string from '../../types/string/module.f.mjs'
|
|
8
|
+
const { join } = string
|
|
9
|
+
import obj, * as O from '../../types/object/module.f.mjs'
|
|
9
10
|
const { entries } = Object
|
|
10
11
|
|
|
11
12
|
/** @type {(v: string) => string} */
|
|
12
13
|
const using = v => `using ${v};`
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* @type {(attributes:
|
|
16
|
+
* @type {(attributes: List.List<string>) =>
|
|
16
17
|
* (type: string) =>
|
|
17
18
|
* (name: string) =>
|
|
18
|
-
* (body:
|
|
19
|
-
*
|
|
19
|
+
* (body: textT.Block) =>
|
|
20
|
+
* List.List<textT.Item>}
|
|
20
21
|
*/
|
|
21
22
|
const typeDef = attributes => type => name => body =>
|
|
22
23
|
flat([
|
|
@@ -40,33 +41,33 @@ const baseTypeMap = {
|
|
|
40
41
|
usize: 'UIntPtr',
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
/** @type {(t:
|
|
44
|
+
/** @type {(t: typesT.BaseType) => string} */
|
|
44
45
|
const baseType = t => baseTypeMap[t]
|
|
45
46
|
|
|
46
47
|
/** @type {(isUnsafe: boolean) => string} */
|
|
47
48
|
const unsafe = isUnsafe => isUnsafe ? 'unsafe ' : ''
|
|
48
49
|
|
|
49
|
-
/** @type {(t:
|
|
50
|
+
/** @type {(t: typesT.Type) => readonly[boolean, string]} */
|
|
50
51
|
const fullType = t =>
|
|
51
52
|
typeof (t) === 'string' ? [false, baseType(t)] :
|
|
52
53
|
t.length === 1 ? [false, t[0]] :
|
|
53
54
|
[true, `${type(t[1])}*`]
|
|
54
55
|
|
|
55
|
-
/** @type {(m:
|
|
56
|
+
/** @type {(m: typesT.Type) => string} */
|
|
56
57
|
const type = t => fullType(t)[1]
|
|
57
58
|
|
|
58
|
-
/** @type {(f:
|
|
59
|
+
/** @type {(f: typesT.Field) => string} */
|
|
59
60
|
const param = ([name, t]) => `${type(t)} ${name}`
|
|
60
61
|
|
|
61
62
|
const mapParam = map(param)
|
|
62
63
|
|
|
63
|
-
/** @type {(f:
|
|
64
|
+
/** @type {(f: typesT.Field) => string} */
|
|
64
65
|
const field = ([name, comType]) => {
|
|
65
66
|
const [isUnsafe, t] = fullType(comType)
|
|
66
67
|
return `public ${unsafe(isUnsafe)}${t} ${name};`
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/** @type {(field:
|
|
70
|
+
/** @type {(field: typesT.Field) => boolean} */
|
|
70
71
|
const isUnsafeField = field => fullType(field[1])[0]
|
|
71
72
|
|
|
72
73
|
const mapIsUnsafeField = map(isUnsafeField)
|
|
@@ -75,7 +76,7 @@ const resultVoid = result('void')
|
|
|
75
76
|
|
|
76
77
|
const joinComma = join(', ')
|
|
77
78
|
|
|
78
|
-
/** @type {(e:
|
|
79
|
+
/** @type {(e: O.Entry<typesT.FieldArray>) => readonly string[]} */
|
|
79
80
|
const method = ([name, m]) => {
|
|
80
81
|
const paramAndResultList = entries(m)
|
|
81
82
|
const pl = paramList(m)
|
|
@@ -94,7 +95,7 @@ const mapField = map(field)
|
|
|
94
95
|
|
|
95
96
|
const flatMapMethod = flatMap(method)
|
|
96
97
|
|
|
97
|
-
/** @type {(e:
|
|
98
|
+
/** @type {(e: O.Entry<typesT.Definition>) => List.List<textT.Item>} */
|
|
98
99
|
const def = ([n, d]) => {
|
|
99
100
|
return !('interface' in d) ?
|
|
100
101
|
struct(n)(mapField(entries(d.struct))) :
|
|
@@ -109,21 +110,21 @@ const flatMapDef = flatMap(def)
|
|
|
109
110
|
|
|
110
111
|
const namespace = curly('namespace')
|
|
111
112
|
|
|
112
|
-
/** @type {
|
|
113
|
+
/** @type {textT.Block} */
|
|
113
114
|
const header = [
|
|
114
115
|
using('System'),
|
|
115
116
|
using('System.Runtime.InteropServices'),
|
|
116
117
|
''
|
|
117
118
|
]
|
|
118
119
|
|
|
119
|
-
/** @type {(name: string) => (library:
|
|
120
|
+
/** @type {(name: string) => (library: typesT.Library) => textT.Block} */
|
|
120
121
|
const cs = name => library => {
|
|
121
122
|
const v = flatMapDef(entries(library))
|
|
122
123
|
const ns = namespace(name)(v)
|
|
123
124
|
return flat([header, ns])
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
export default {
|
|
127
128
|
/** @readonly */
|
|
128
129
|
cs,
|
|
129
130
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import text from '../../text/module.f.mjs'
|
|
2
|
+
const { flat } = text
|
|
3
|
+
import string from '../../types/string/module.f.mjs'
|
|
4
|
+
const { join } = string
|
|
5
|
+
import x from './module.f.mjs'
|
|
6
|
+
import library from '../types/testlib.f.mjs'
|
|
7
|
+
|
|
8
|
+
const { cs } = x
|
|
9
|
+
|
|
10
|
+
export default join('\n')(flat(' ')(cs('My')(library)))
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import types, * as typesT from '../types/module.f.mjs'
|
|
2
2
|
const { paramList } = types
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { flat, map, flatMap
|
|
3
|
+
import text, * as textT from '../../text/module.f.mjs'
|
|
4
|
+
import object, * as O from '../../types/object/module.f.mjs'
|
|
5
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
6
|
+
const { flat, map, flatMap } = list
|
|
7
7
|
const { entries } = Object
|
|
8
|
-
|
|
9
|
-
const {
|
|
8
|
+
import func from '../../types/function/module.f.mjs'
|
|
9
|
+
const { fn } = func
|
|
10
|
+
import string from '../../types/string/module.f.mjs'
|
|
11
|
+
const { join } = string
|
|
10
12
|
|
|
11
13
|
/** @type {(field: string) => string} */
|
|
12
14
|
const rustField = field => `pub ${field},`
|
|
13
15
|
|
|
14
16
|
const mapRustField = map(rustField)
|
|
15
17
|
|
|
16
|
-
/** @type {(b:
|
|
18
|
+
/** @type {(b: List.Thunk<string>) => (name: string) => textT.Block} */
|
|
17
19
|
const rustStruct = b => name => [`#[repr(C)]`, `pub struct ${name} {`, mapRustField(b), `}`]
|
|
18
20
|
|
|
19
21
|
const commaJoin = join(', ')
|
|
@@ -26,21 +28,21 @@ const obj = name => `&${name}::Object`
|
|
|
26
28
|
|
|
27
29
|
const self = ['&self']
|
|
28
30
|
|
|
29
|
-
/** @type {(p:
|
|
31
|
+
/** @type {(p: typesT.Field) => string} */
|
|
30
32
|
const paramName = ([n]) => n
|
|
31
33
|
|
|
32
|
-
/** @type {(p:
|
|
34
|
+
/** @type {(p: typesT.FieldArray) => List.Thunk<string>} */
|
|
33
35
|
const callList = p => map(paramName)(paramList(p))
|
|
34
36
|
|
|
35
|
-
/** @type {(p:
|
|
37
|
+
/** @type {(p: typesT.FieldArray) => string} */
|
|
36
38
|
const call = p => commaJoin(callList(p))
|
|
37
39
|
|
|
38
|
-
/** @type {(p:
|
|
40
|
+
/** @type {(p: typesT.FieldArray) => string} */
|
|
39
41
|
const virtualCall = p => commaJoin(flat([['self'], callList(p)]))
|
|
40
42
|
|
|
41
43
|
const super_ = 'super::'
|
|
42
44
|
|
|
43
|
-
/** @type {(m:
|
|
45
|
+
/** @type {(m: typesT.Method) => string} */
|
|
44
46
|
const assign = ([n]) => `${n}: Self::${n},`
|
|
45
47
|
|
|
46
48
|
const mapAssign = map(assign)
|
|
@@ -58,10 +60,10 @@ const rustType = n => `pub type ${n} = nanocom::${n}<Interface>;`
|
|
|
58
60
|
/** @typedef {{readonly where: readonly string[]}} Where */
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
|
-
* @typedef {OptionalProperty<Where> & {readonly content:
|
|
63
|
+
* @typedef {OptionalProperty<Where> & {readonly content: textT.Block}} WhereContent
|
|
62
64
|
*/
|
|
63
65
|
|
|
64
|
-
/** @type {(h: string) => (wh: WhereContent) =>
|
|
66
|
+
/** @type {(h: string) => (wh: WhereContent) => textT.Block} */
|
|
65
67
|
const whereContent = h => wh => {
|
|
66
68
|
const w = 'where' in wh ? [
|
|
67
69
|
h,
|
|
@@ -82,11 +84,11 @@ const whereContent = h => wh => {
|
|
|
82
84
|
* readonly trait: string
|
|
83
85
|
* readonly type: string
|
|
84
86
|
* readonly where?: readonly string[]
|
|
85
|
-
* readonly content:
|
|
87
|
+
* readonly content: textT.Block
|
|
86
88
|
* }} Impl
|
|
87
89
|
*/
|
|
88
90
|
|
|
89
|
-
/** @type {(impl: Impl) =>
|
|
91
|
+
/** @type {(impl: Impl) => textT.Block} */
|
|
90
92
|
const rustImpl = i => {
|
|
91
93
|
const p = 'param' in i ? `<${i.param}>` : ''
|
|
92
94
|
const header = `impl${p} ${i.trait} for ${i.type}`
|
|
@@ -98,7 +100,7 @@ const rustImpl = i => {
|
|
|
98
100
|
* readonly pub?: true
|
|
99
101
|
* readonly type: string
|
|
100
102
|
* readonly where?: readonly string[]
|
|
101
|
-
* readonly content:
|
|
103
|
+
* readonly content: textT.Block
|
|
102
104
|
* }} Trait
|
|
103
105
|
*/
|
|
104
106
|
|
|
@@ -107,14 +109,14 @@ const comma = s => `${s},`
|
|
|
107
109
|
|
|
108
110
|
const mapComma = map(comma)
|
|
109
111
|
|
|
110
|
-
/** @type {(t: Trait) =>
|
|
112
|
+
/** @type {(t: Trait) => textT.Block} */
|
|
111
113
|
const trait = t => {
|
|
112
114
|
const p = t.pub === true ? 'pub ' : ''
|
|
113
115
|
const h = `${p}trait ${t.type}`
|
|
114
116
|
return whereContent(h)(t)
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
/** @type {(t: Trait) =>
|
|
119
|
+
/** @type {(t: Trait) => textT.Block} */
|
|
118
120
|
const traitImpl = t => {
|
|
119
121
|
const i = rustImpl({
|
|
120
122
|
param: 'T',
|
|
@@ -128,12 +130,12 @@ const traitImpl = t => {
|
|
|
128
130
|
|
|
129
131
|
const where = ['Self: nanocom::Class<Interface = Interface>', 'nanocom::CObject<Self>: Ex']
|
|
130
132
|
|
|
131
|
-
/** @type {(library:
|
|
133
|
+
/** @type {(library: typesT.Library) => textT.Block} */
|
|
132
134
|
const rust = library => {
|
|
133
135
|
|
|
134
|
-
/** @type {(p: string) => (o: (_: string) => string) => (t:
|
|
136
|
+
/** @type {(p: string) => (o: (_: string) => string) => (t: typesT.Type) => string} */
|
|
135
137
|
const type = p => {
|
|
136
|
-
/** @type {(o: (_: string) => string) => (t:
|
|
138
|
+
/** @type {(o: (_: string) => string) => (t: typesT.Type) => string} */
|
|
137
139
|
const f = o => t => {
|
|
138
140
|
if (typeof t === 'string') { return t }
|
|
139
141
|
if (t.length === 2) { return `*const ${f(ref)(t[1])}` }
|
|
@@ -144,7 +146,7 @@ const rust = library => {
|
|
|
144
146
|
return f
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
/** @type {(p: string) => (o: (_: string) => string) => (f:
|
|
149
|
+
/** @type {(p: string) => (o: (_: string) => string) => (f: typesT.Field) => string} */
|
|
148
150
|
const pf = p => o => ([name, t]) => `${name}: ${type(p)(o)(t)}`
|
|
149
151
|
|
|
150
152
|
const param = pf(super_)(obj)
|
|
@@ -153,36 +155,36 @@ const rust = library => {
|
|
|
153
155
|
|
|
154
156
|
const mapField = map(pf('')(ref))
|
|
155
157
|
|
|
156
|
-
/** @type {(fa:
|
|
158
|
+
/** @type {(fa: typesT.FieldArray) => (name: string) => textT.Block} */
|
|
157
159
|
const struct = fn(entries)
|
|
158
160
|
.then(mapField)
|
|
159
161
|
.then(rustStruct)
|
|
160
162
|
.result
|
|
161
163
|
|
|
162
|
-
/** @type {(first: readonly string[]) => (p:
|
|
164
|
+
/** @type {(first: readonly string[]) => (p: typesT.FieldArray) => string} */
|
|
163
165
|
const func = first => p => {
|
|
164
166
|
const resultStr = '_' in p ? ` -> ${type(super_)(ref)(p._)}` : ''
|
|
165
167
|
const params = commaJoin(flat([first, mapParam(paramList(p))]))
|
|
166
168
|
return `(${params})${resultStr}`
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
/** @type {(n: string) => (p:
|
|
171
|
+
/** @type {(n: string) => (p: typesT.FieldArray) => string} */
|
|
170
172
|
const virtualFnType = n => p => `extern "system" fn${n}${func(this_)(p)}`
|
|
171
173
|
|
|
172
|
-
/** @type {(m:
|
|
174
|
+
/** @type {(m: typesT.Method) => string} */
|
|
173
175
|
const virtualFn = ([n, p]) => `${n}: unsafe ${virtualFnType('')(p)}`
|
|
174
176
|
|
|
175
177
|
const mapVirtualFn = map(virtualFn)
|
|
176
178
|
|
|
177
|
-
/** @type {(m:
|
|
179
|
+
/** @type {(m: typesT.Method) => string} */
|
|
178
180
|
const headerFn = ([n, p]) => `fn ${n}${func(self)(p)}`
|
|
179
181
|
|
|
180
|
-
/** @type {(m:
|
|
182
|
+
/** @type {(m: typesT.Method) => string} */
|
|
181
183
|
const traitFn = m => `${headerFn(m)};`
|
|
182
184
|
|
|
183
185
|
const mapTraitFn = map(traitFn)
|
|
184
186
|
|
|
185
|
-
/** @type {(m:
|
|
187
|
+
/** @type {(m: typesT.Method) => textT.Block} */
|
|
186
188
|
const implFn = m => {
|
|
187
189
|
const [n, p] = m
|
|
188
190
|
return [
|
|
@@ -194,7 +196,7 @@ const rust = library => {
|
|
|
194
196
|
|
|
195
197
|
const flatMapImplFn = flatMap(implFn)
|
|
196
198
|
|
|
197
|
-
/** @type {(m:
|
|
199
|
+
/** @type {(m: typesT.Method) => textT.Block} */
|
|
198
200
|
const impl = ([n, p]) => {
|
|
199
201
|
const type = virtualFnType(` ${n}`)(p)
|
|
200
202
|
return [
|
|
@@ -206,7 +208,7 @@ const rust = library => {
|
|
|
206
208
|
|
|
207
209
|
const flatMapImpl = flatMap(impl)
|
|
208
210
|
|
|
209
|
-
/** @type {(i:
|
|
211
|
+
/** @type {(i: typesT.Interface) => (name: string) => textT.Block} */
|
|
210
212
|
const interface_ = ({ interface: i, guid }) => name => {
|
|
211
213
|
|
|
212
214
|
const e = entries(i)
|
|
@@ -250,13 +252,13 @@ const rust = library => {
|
|
|
250
252
|
]
|
|
251
253
|
}
|
|
252
254
|
|
|
253
|
-
/** @type {(type:
|
|
255
|
+
/** @type {(type: O.Entry<typesT.Definition>) => textT.Block} */
|
|
254
256
|
const def = ([name, type]) => ('interface' in type ? interface_(type) : struct(type.struct))(name)
|
|
255
257
|
|
|
256
258
|
return flat([['#![allow(non_snake_case)]'], flatMap(def)(entries(library))])
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
|
|
261
|
+
export default {
|
|
260
262
|
/** @readonly */
|
|
261
263
|
rust,
|
|
262
264
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import text from '../../text/module.f.mjs'
|
|
2
|
+
const { flat } = text
|
|
3
|
+
import string from '../../types/string/module.f.mjs'
|
|
4
|
+
const { join } = string
|
|
5
|
+
import x from './module.f.mjs'
|
|
6
|
+
import library from '../types/testlib.f.mjs'
|
|
7
|
+
|
|
8
|
+
const { rust } = x
|
|
9
|
+
|
|
10
|
+
export default join('\n')(flat(' ')(rust(library)))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import list, * as List from '../../types/list/module.f.mjs'
|
|
2
2
|
const { flat } = list
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import cppContent from '../cpp/testlib.f.mjs'
|
|
5
|
+
import csContent from '../cs/testlib.f.mjs'
|
|
6
|
+
import rustContent from '../rust/testlib.f.mjs'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {|
|
|
@@ -34,7 +34,7 @@ const rustContent = require("../rust/testlib.f.cjs")
|
|
|
34
34
|
* readonly name: string
|
|
35
35
|
* readonly content: string
|
|
36
36
|
* }
|
|
37
|
-
* readonly line:
|
|
37
|
+
* readonly line: List.List<List.List<string>>
|
|
38
38
|
* }} Output
|
|
39
39
|
*/
|
|
40
40
|
|
|
@@ -99,7 +99,7 @@ const rust = ({ dirname }) => ({
|
|
|
99
99
|
line: [['cargo', 'build' /**, '--locked' */]]
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
export default {
|
|
103
103
|
/** @readonly */
|
|
104
104
|
cpp,
|
|
105
105
|
/** @readonly */
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { writeFileSync } from 'node:fs'
|
|
2
|
+
import { execSync } from 'node:child_process'
|
|
3
|
+
import { platform, exit } from 'node:process'
|
|
4
|
+
import build, * as buildT from './build.f.mjs'
|
|
5
5
|
const { cpp, cs, rust } = build
|
|
6
|
-
|
|
6
|
+
import string from '../../types/string/module.f.mjs'
|
|
7
|
+
const { join } = string
|
|
7
8
|
const { log, error } = console
|
|
8
|
-
|
|
9
|
-
const
|
|
9
|
+
import sgr from '../../text/sgr/module.f.mjs'
|
|
10
|
+
const { bold, reset } = sgr
|
|
11
|
+
import list from '../../types/list/module.f.mjs'
|
|
12
|
+
|
|
13
|
+
import { fileURLToPath } from 'node:url'
|
|
14
|
+
import { dirname } from 'node:path'
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename)
|
|
10
18
|
|
|
11
19
|
const nodeJs = {
|
|
12
20
|
dirname: __dirname,
|
|
13
21
|
platform,
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
/** @type {(f:
|
|
24
|
+
/** @type {(f: buildT.Func) => void} */
|
|
17
25
|
const run = f => {
|
|
18
26
|
const { file: { name, content }, line } = f(nodeJs)
|
|
19
27
|
log(`${bold}writing: ${name}${reset}`)
|