functionalscript 0.0.424 → 0.0.427
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/Cargo.lock +7 -0
- package/Cargo.toml +2 -1
- package/com/cpp/test.f.cjs +1 -1
- package/com/cs/test.f.cjs +1 -1
- package/com/rust/module.f.cjs +42 -16
- package/com/rust/test.f.cjs +99 -74
- package/com/types/{test.f.cjs → testlib.f.cjs} +0 -0
- package/commonjs/build/test.f.cjs +2 -4
- package/commonjs/package/dependencies/test.f.cjs +1 -3
- package/commonjs/package/test.f.cjs +1 -5
- package/commonjs/path/test.f.cjs +158 -170
- package/commonjs/test.cjs +52 -61
- package/html/test.f.cjs +12 -13
- package/json/test.f.cjs +41 -37
- package/json/tokenizer/test.f.cjs +238 -296
- package/nodejs/version/test.f.cjs +1 -3
- package/package.json +1 -1
- package/sha2/test.f.cjs +37 -40
- package/test.mjs +51 -19
- package/text/test.f.cjs +1 -3
- package/text/utf16/test.f.cjs +96 -109
- package/text/utf8/test.f.cjs +116 -135
- package/types/array/test.f.cjs +84 -84
- package/types/btree/find/test.f.cjs +2 -2
- package/types/btree/remove/test.f.cjs +6 -3
- package/types/btree/set/test.f.cjs +372 -370
- package/types/btree/test.f.cjs +11 -7
- package/types/byteSet/module.f.cjs +2 -4
- package/types/byteSet/test.f.cjs +37 -40
- package/types/function/compare/module.f.cjs +1 -1
- package/types/function/compare/test.f.cjs +1 -3
- package/types/function/test.f.cjs +1 -3
- package/types/list/test.f.cjs +208 -219
- package/types/map/test.f.cjs +57 -57
- package/types/nibbleSet/test.f.cjs +37 -40
- package/types/number/test.f.cjs +24 -26
- package/types/object/test.f.cjs +12 -13
- package/types/option/test.f.cjs +1 -3
- package/types/range/test.f.cjs +1 -3
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/com/cpp/test.f.cjs
CHANGED
package/com/cs/test.f.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const text = require('../../text/module.f.cjs')
|
|
3
|
-
const library = require('../types/
|
|
3
|
+
const library = require('../types/testlib.f.cjs')
|
|
4
4
|
const { join } = require('../../types/string/module.f.cjs')
|
|
5
5
|
|
|
6
6
|
const f = () =>
|
package/com/rust/module.f.cjs
CHANGED
|
@@ -29,15 +29,23 @@ const self = ['&self']
|
|
|
29
29
|
/** @type {(p: types.Field) => string} */
|
|
30
30
|
const paramName = ([n]) => n
|
|
31
31
|
|
|
32
|
+
/** @type {(p: types.FieldArray) => list.Thunk<string>} */
|
|
33
|
+
const callList = p => map(paramName)(paramList(p))
|
|
34
|
+
|
|
35
|
+
/** @type {(p: types.FieldArray) => string} */
|
|
36
|
+
const call = p => commaJoin(callList(p))
|
|
37
|
+
|
|
32
38
|
/** @type {(p: types.FieldArray) => string} */
|
|
33
|
-
const
|
|
39
|
+
const virtualCall = p => commaJoin(flat([['self'], callList(p)]))
|
|
40
|
+
|
|
41
|
+
const super_ = 'super::'
|
|
34
42
|
|
|
35
43
|
/** @type {(m: types.Method) => string} */
|
|
36
44
|
const assign = ([n]) => `${n}: Self::${n},`
|
|
37
45
|
|
|
38
46
|
const mapAssign = map(assign)
|
|
39
47
|
|
|
40
|
-
const
|
|
48
|
+
const this_ = ['this: &Object']
|
|
41
49
|
|
|
42
50
|
/** @type {(library: types.Library) => text.Block} */
|
|
43
51
|
const rust = library => {
|
|
@@ -78,6 +86,14 @@ const rust = library => {
|
|
|
78
86
|
return `(${params})${resultStr}`
|
|
79
87
|
}
|
|
80
88
|
|
|
89
|
+
/** @type {(n: string) => (p: types.FieldArray) => string} */
|
|
90
|
+
const virtualFnType = n => p => `extern "system" fn${n}${func(this_)(p)}`
|
|
91
|
+
|
|
92
|
+
/** @type {(m: types.Method) => string} */
|
|
93
|
+
const virtualFn = ([n, p]) => `${n}: unsafe ${virtualFnType('')(p)}`
|
|
94
|
+
|
|
95
|
+
const mapVirtualFn = map(virtualFn)
|
|
96
|
+
|
|
81
97
|
/** @type {(m: types.Method) => string} */
|
|
82
98
|
const headerFn = ([n, p]) => `fn ${n}${func(self)(p)}`
|
|
83
99
|
|
|
@@ -91,35 +107,38 @@ const rust = library => {
|
|
|
91
107
|
const [n, p] = m
|
|
92
108
|
return [
|
|
93
109
|
`${headerFn(m)} {`,
|
|
94
|
-
[`unsafe { (self.interface().${n})(${
|
|
110
|
+
[`unsafe { (self.interface().${n})(${virtualCall(p)}) }`],
|
|
95
111
|
'}'
|
|
96
112
|
]
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
const flatMapImplFn = flatMap(implFn)
|
|
100
116
|
|
|
101
|
-
/** @type {(
|
|
102
|
-
const
|
|
117
|
+
/** @type {(m: types.Method) => text.Block} */
|
|
118
|
+
const impl = ([n, p]) => {
|
|
119
|
+
const type = virtualFnType(` ${n}`)(p)
|
|
120
|
+
return [
|
|
121
|
+
`${type} {`,
|
|
122
|
+
[`unsafe { Self::to_cobject(this) }.${n}(${call(p)})`],
|
|
123
|
+
'}'
|
|
124
|
+
]
|
|
125
|
+
}
|
|
103
126
|
|
|
104
|
-
|
|
127
|
+
const flatMapImpl = flatMap(impl)
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
/** @type {(i: types.Interface) => (name: string) => text.Block} */
|
|
130
|
+
const interface_ = ({ interface: i, guid }) => name => {
|
|
108
131
|
|
|
109
132
|
const e = entries(i)
|
|
110
133
|
|
|
111
|
-
const nameEx = `${name}Ex`
|
|
112
|
-
|
|
113
|
-
const nameVmt = `${name}Vmt`
|
|
114
|
-
|
|
115
134
|
return [
|
|
116
135
|
`pub mod ${name} {`,
|
|
117
136
|
[
|
|
118
|
-
'type Object = nanocom::Object<Interface>;',
|
|
119
|
-
'type Ref = nanocom::Ref<Interface>;',
|
|
120
|
-
'type Vmt = nanocom::Vmt<Interface>;',
|
|
137
|
+
'pub type Object = nanocom::Object<Interface>;',
|
|
138
|
+
'pub type Ref = nanocom::Ref<Interface>;',
|
|
139
|
+
'pub type Vmt = nanocom::Vmt<Interface>;',
|
|
121
140
|
],
|
|
122
|
-
rustStruct(
|
|
141
|
+
rustStruct(mapVirtualFn(e))('Interface'),
|
|
123
142
|
[ 'impl nanocom::Interface for Interface {',
|
|
124
143
|
[ `const GUID: nanocom::GUID = 0x${guid.replaceAll('-', '_')};`],
|
|
125
144
|
'}',
|
|
@@ -139,6 +158,13 @@ const rust = library => {
|
|
|
139
158
|
],
|
|
140
159
|
'}',
|
|
141
160
|
'impl<T: nanocom::Class<Interface = Interface>> ClassEx for T where nanocom::CObject<T>: Ex {}',
|
|
161
|
+
'trait PrivateClassEx: nanocom::Class<Interface = Interface>',
|
|
162
|
+
'where',
|
|
163
|
+
[ 'nanocom::CObject<Self>: Ex'],
|
|
164
|
+
`{`,
|
|
165
|
+
flatMapImpl(e),
|
|
166
|
+
`}`,
|
|
167
|
+
'impl<T: nanocom::Class<Interface = Interface>> PrivateClassEx for T where nanocom::CObject<T>: Ex {}',
|
|
142
168
|
],
|
|
143
169
|
'}'
|
|
144
170
|
]
|
package/com/rust/test.f.cjs
CHANGED
|
@@ -1,78 +1,103 @@
|
|
|
1
1
|
const { rust } = require('./module.f.cjs')
|
|
2
2
|
const { flat } = require('../../text/module.f.cjs')
|
|
3
3
|
const { join } = require('../../types/string/module.f.cjs')
|
|
4
|
-
const library = require('../types/
|
|
4
|
+
const library = require('../types/testlib.f.cjs')
|
|
5
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
|
-
|
|
6
|
+
module.exports = {
|
|
7
|
+
result: () => {
|
|
8
|
+
const e =
|
|
9
|
+
'#![allow(non_snake_case)]\n' +
|
|
10
|
+
'#[repr(C)]\n' +
|
|
11
|
+
'pub struct Slice {\n' +
|
|
12
|
+
' pub Start: *const u8,\n' +
|
|
13
|
+
' pub Size: usize,\n' +
|
|
14
|
+
' pub M: IMy::Ref,\n' +
|
|
15
|
+
'}\n' +
|
|
16
|
+
'pub mod IMy {\n' +
|
|
17
|
+
' pub type Object = nanocom::Object<Interface>;\n' +
|
|
18
|
+
' pub type Ref = nanocom::Ref<Interface>;\n' +
|
|
19
|
+
' pub type Vmt = nanocom::Vmt<Interface>;\n' +
|
|
20
|
+
' #[repr(C)]\n' +
|
|
21
|
+
' pub struct Interface {\n' +
|
|
22
|
+
' pub GetSlice: unsafe extern "system" fn(this: &Object) -> super::Slice,\n' +
|
|
23
|
+
' pub SetSlice: unsafe extern "system" fn(this: &Object, slice: super::Slice),\n' +
|
|
24
|
+
' pub GetUnsafe: unsafe extern "system" fn(this: &Object) -> *const bool,\n' +
|
|
25
|
+
' pub SetUnsafe: unsafe extern "system" fn(this: &Object, p: *const super::Slice, size: u32),\n' +
|
|
26
|
+
' pub Some: unsafe extern "system" fn(this: &Object, p: &super::IMy::Object) -> bool,\n' +
|
|
27
|
+
' pub GetIMy: unsafe extern "system" fn(this: &Object) -> super::IMy::Ref,\n' +
|
|
28
|
+
' }\n' +
|
|
29
|
+
' impl nanocom::Interface for Interface {\n' +
|
|
30
|
+
' const GUID: nanocom::GUID = 0xC66FB270_2D80_49AD_BB6E_88C1F90B805D;\n' +
|
|
31
|
+
' }\n' +
|
|
32
|
+
' pub trait Ex {\n' +
|
|
33
|
+
' fn GetSlice(&self) -> super::Slice;\n' +
|
|
34
|
+
' fn SetSlice(&self, slice: super::Slice);\n' +
|
|
35
|
+
' fn GetUnsafe(&self) -> *const bool;\n' +
|
|
36
|
+
' fn SetUnsafe(&self, p: *const super::Slice, size: u32);\n' +
|
|
37
|
+
' fn Some(&self, p: &super::IMy::Object) -> bool;\n' +
|
|
38
|
+
' fn GetIMy(&self) -> super::IMy::Ref;\n' +
|
|
39
|
+
' }\n' +
|
|
40
|
+
' impl Ex for Object {\n' +
|
|
41
|
+
' fn GetSlice(&self) -> super::Slice {\n' +
|
|
42
|
+
' unsafe { (self.interface().GetSlice)(self) }\n' +
|
|
43
|
+
' }\n' +
|
|
44
|
+
' fn SetSlice(&self, slice: super::Slice) {\n' +
|
|
45
|
+
' unsafe { (self.interface().SetSlice)(self, slice) }\n' +
|
|
46
|
+
' }\n' +
|
|
47
|
+
' fn GetUnsafe(&self) -> *const bool {\n' +
|
|
48
|
+
' unsafe { (self.interface().GetUnsafe)(self) }\n' +
|
|
49
|
+
' }\n' +
|
|
50
|
+
' fn SetUnsafe(&self, p: *const super::Slice, size: u32) {\n' +
|
|
51
|
+
' unsafe { (self.interface().SetUnsafe)(self, p, size) }\n' +
|
|
52
|
+
' }\n' +
|
|
53
|
+
' fn Some(&self, p: &super::IMy::Object) -> bool {\n' +
|
|
54
|
+
' unsafe { (self.interface().Some)(self, p) }\n' +
|
|
55
|
+
' }\n' +
|
|
56
|
+
' fn GetIMy(&self) -> super::IMy::Ref {\n' +
|
|
57
|
+
' unsafe { (self.interface().GetIMy)(self) }\n' +
|
|
58
|
+
' }\n' +
|
|
59
|
+
' }\n' +
|
|
60
|
+
' pub trait ClassEx: nanocom::Class<Interface = Interface>\n' +
|
|
61
|
+
' where\n' +
|
|
62
|
+
' nanocom::CObject<Self>: Ex,\n' +
|
|
63
|
+
' {\n' +
|
|
64
|
+
' const INTERFACE: Interface = Interface {\n' +
|
|
65
|
+
' GetSlice: Self::GetSlice,\n' +
|
|
66
|
+
' SetSlice: Self::SetSlice,\n' +
|
|
67
|
+
' GetUnsafe: Self::GetUnsafe,\n' +
|
|
68
|
+
' SetUnsafe: Self::SetUnsafe,\n' +
|
|
69
|
+
' Some: Self::Some,\n' +
|
|
70
|
+
' GetIMy: Self::GetIMy,\n' +
|
|
71
|
+
' };\n' +
|
|
72
|
+
' }\n' +
|
|
73
|
+
' impl<T: nanocom::Class<Interface = Interface>> ClassEx for T where nanocom::CObject<T>: Ex {}\n' +
|
|
74
|
+
' trait PrivateClassEx: nanocom::Class<Interface = Interface>\n' +
|
|
75
|
+
' where\n' +
|
|
76
|
+
' nanocom::CObject<Self>: Ex\n' +
|
|
77
|
+
' {\n' +
|
|
78
|
+
' extern "system" fn GetSlice(this: &Object) -> super::Slice {\n' +
|
|
79
|
+
' unsafe { Self::to_cobject(this) }.GetSlice()\n' +
|
|
80
|
+
' }\n' +
|
|
81
|
+
' extern "system" fn SetSlice(this: &Object, slice: super::Slice) {\n' +
|
|
82
|
+
' unsafe { Self::to_cobject(this) }.SetSlice(slice)\n' +
|
|
83
|
+
' }\n' +
|
|
84
|
+
' extern "system" fn GetUnsafe(this: &Object) -> *const bool {\n' +
|
|
85
|
+
' unsafe { Self::to_cobject(this) }.GetUnsafe()\n' +
|
|
86
|
+
' }\n' +
|
|
87
|
+
' extern "system" fn SetUnsafe(this: &Object, p: *const super::Slice, size: u32) {\n' +
|
|
88
|
+
' unsafe { Self::to_cobject(this) }.SetUnsafe(p, size)\n' +
|
|
89
|
+
' }\n' +
|
|
90
|
+
' extern "system" fn Some(this: &Object, p: &super::IMy::Object) -> bool {\n' +
|
|
91
|
+
' unsafe { Self::to_cobject(this) }.Some(p)\n' +
|
|
92
|
+
' }\n' +
|
|
93
|
+
' extern "system" fn GetIMy(this: &Object) -> super::IMy::Ref {\n' +
|
|
94
|
+
' unsafe { Self::to_cobject(this) }.GetIMy()\n' +
|
|
95
|
+
' }\n' +
|
|
96
|
+
' }\n' +
|
|
97
|
+
' impl<T: nanocom::Class<Interface = Interface>> PrivateClassEx for T where nanocom::CObject<T>: Ex {}\n' +
|
|
98
|
+
'}'
|
|
99
|
+
const r = join('\n')(flat(' ')(rust(library)))
|
|
100
|
+
if (r !== e) { throw [e, r] }
|
|
101
|
+
return r
|
|
102
|
+
}
|
|
103
|
+
}
|
|
File without changes
|
|
@@ -69,7 +69,7 @@ const getOrBuild = _.getOrBuild
|
|
|
69
69
|
(packageGet)
|
|
70
70
|
(/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
|
|
71
71
|
|
|
72
|
-
{
|
|
72
|
+
module.exports = () => {
|
|
73
73
|
let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
|
|
74
74
|
if (JSON.stringify(r) !==
|
|
75
75
|
'["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js","x/r":"/node_modules/x/r.js"}}]'
|
|
@@ -82,12 +82,10 @@ const getOrBuild = _.getOrBuild
|
|
|
82
82
|
) {
|
|
83
83
|
throw r
|
|
84
84
|
}
|
|
85
|
-
[r, m] = getOrBuild({ package: '', path: ['c.js']})(m)
|
|
85
|
+
[r, m] = getOrBuild({ package: '', path: ['c.js'] })(m)
|
|
86
86
|
if (JSON.stringify(r) !==
|
|
87
87
|
'["error",["file not found"]]'
|
|
88
88
|
) {
|
|
89
89
|
throw r
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = {}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
4
4
|
if (!_.isDependenciesJson(undefined)) { throw 'error' }
|
|
5
5
|
if (_.isDependenciesJson(null)) { throw 'error' }
|
|
6
6
|
if (!_.isDependenciesJson({})) { throw 'error' }
|
|
7
7
|
if (!_.isDependenciesJson({'a':'b'})) { throw 'error' }
|
|
8
8
|
if (_.isDependenciesJson({ 'a': 12 })) { throw 'error' }
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
module.exports = {}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
6
4
|
if (_.isPackageJson(null)) { throw 'error' }
|
|
7
5
|
if (_.isPackageJson({})) { throw 'error' }
|
|
8
6
|
if (_.isPackageJson({name:'x',version:12})) { throw 'error' }
|
|
@@ -12,5 +10,3 @@ require('./dependencies/test.f.cjs')
|
|
|
12
10
|
if (_.isPackageJson({name:'b', version: "", dependencies: { x: 12} })) { throw 'error' }
|
|
13
11
|
if (!_.isPackageJson({name:'c', version: "", dependencies: { x: "12" } })) { throw 'error' }
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
module.exports = {}
|