functionalscript 0.0.443 → 0.0.445
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/com/rust/module.f.cjs +6 -2
- package/com/rust/nanocom/tests/itmod.rs +8 -11
- package/com/rust/test.f.cjs +11 -8
- package/com/test/rust/src/lib.rs +42 -0
- package/package.json +1 -1
- package/types/range_map/module.f.cjs +60 -0
- package/types/range_map/test.f.cjs +81 -0
- package/types/sorted_list/module.f.cjs +1 -6
package/com/rust/module.f.cjs
CHANGED
|
@@ -230,8 +230,12 @@ const rust = library => {
|
|
|
230
230
|
traitImpl({
|
|
231
231
|
pub: true,
|
|
232
232
|
type: 'ClassEx',
|
|
233
|
-
content: [
|
|
234
|
-
|
|
233
|
+
content: ['const VMT: Vmt = Vmt {',
|
|
234
|
+
[ 'iunknown: Self::IUNKNOWN,',
|
|
235
|
+
'interface: Interface {',
|
|
236
|
+
mapAssign(e),
|
|
237
|
+
'},',
|
|
238
|
+
],
|
|
235
239
|
'};'
|
|
236
240
|
]
|
|
237
241
|
}),
|
|
@@ -36,9 +36,12 @@ mod library {
|
|
|
36
36
|
where
|
|
37
37
|
nanocom::CObject<Self>: Ex,
|
|
38
38
|
{
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const VMT: Vmt = Vmt {
|
|
40
|
+
iunknown: Self::IUNKNOWN,
|
|
41
|
+
interface: Interface {
|
|
42
|
+
A: Self::A,
|
|
43
|
+
B: Self::B,
|
|
44
|
+
}
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -73,10 +76,7 @@ mod number {
|
|
|
73
76
|
impl nanocom::Class for X {
|
|
74
77
|
type Interface = IMy::Interface;
|
|
75
78
|
fn static_vmt() -> &'static Vmt<Self::Interface> {
|
|
76
|
-
static V: IMy::Vmt =
|
|
77
|
-
iunknown: X::IUNKNOWN,
|
|
78
|
-
interface: X::INTERFACE,
|
|
79
|
-
};
|
|
79
|
+
static V: IMy::Vmt = X::VMT;
|
|
80
80
|
&V
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -142,10 +142,7 @@ mod destructor {
|
|
|
142
142
|
impl nanocom::Class for X {
|
|
143
143
|
type Interface = IMy::Interface;
|
|
144
144
|
fn static_vmt() -> &'static Vmt<Self::Interface> {
|
|
145
|
-
static V: IMy::Vmt =
|
|
146
|
-
iunknown: X::IUNKNOWN,
|
|
147
|
-
interface: X::INTERFACE,
|
|
148
|
-
};
|
|
145
|
+
static V: IMy::Vmt = X::VMT;
|
|
149
146
|
&V
|
|
150
147
|
}
|
|
151
148
|
}
|
package/com/rust/test.f.cjs
CHANGED
|
@@ -66,14 +66,17 @@ module.exports = () => {
|
|
|
66
66
|
' Self: nanocom::Class<Interface = Interface>,\n' +
|
|
67
67
|
' nanocom::CObject<Self>: Ex,\n' +
|
|
68
68
|
' {\n' +
|
|
69
|
-
' const
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
69
|
+
' const VMT: Vmt = Vmt {\n' +
|
|
70
|
+
' iunknown: Self::IUNKNOWN,\n' +
|
|
71
|
+
' interface: Interface {\n' +
|
|
72
|
+
' GetSlice: Self::GetSlice,\n' +
|
|
73
|
+
' SetSlice: Self::SetSlice,\n' +
|
|
74
|
+
' GetUnsafe: Self::GetUnsafe,\n' +
|
|
75
|
+
' SetUnsafe: Self::SetUnsafe,\n' +
|
|
76
|
+
' Some: Self::Some,\n' +
|
|
77
|
+
' GetIMy: Self::GetIMy,\n' +
|
|
78
|
+
' SetManagedStruct: Self::SetManagedStruct,\n' +
|
|
79
|
+
' },\n' +
|
|
77
80
|
' };\n' +
|
|
78
81
|
' }\n' +
|
|
79
82
|
' impl<T> ClassEx for T\n' +
|
package/com/test/rust/src/lib.rs
CHANGED
|
@@ -1 +1,43 @@
|
|
|
1
|
+
use crate::_result::IMy::ClassEx;
|
|
2
|
+
|
|
1
3
|
mod _result;
|
|
4
|
+
|
|
5
|
+
struct My {}
|
|
6
|
+
|
|
7
|
+
impl nanocom::Class for My {
|
|
8
|
+
type Interface = _result::IMy::Interface;
|
|
9
|
+
fn static_vmt() -> &'static _result::IMy::Vmt {
|
|
10
|
+
static VMT: _result::IMy::Vmt = My::VMT;
|
|
11
|
+
&VMT
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl _result::IMy::Ex for nanocom::CObject<My> {
|
|
16
|
+
fn GetSlice(&self) -> _result::Slice {
|
|
17
|
+
todo!()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fn SetSlice(&self, slice: _result::Slice) {
|
|
21
|
+
todo!()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fn GetUnsafe(&self) -> *const bool {
|
|
25
|
+
todo!()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn SetUnsafe(&self, p: *const _result::Slice, size: u32) {
|
|
29
|
+
todo!()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fn Some(&self, p: &_result::IMy::Object) -> bool {
|
|
33
|
+
todo!()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fn GetIMy(&self) -> _result::IMy::Ref {
|
|
37
|
+
todo!()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fn SetManagedStruct(&self, a: _result::ManagedStruct) {
|
|
41
|
+
todo!()
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const sortedList = require("../sorted_list/module.f.cjs")
|
|
2
|
+
const { genericMerge } = sortedList
|
|
3
|
+
const list = require("../list/module.f.cjs")
|
|
4
|
+
const option = require("../option/module.f.cjs")
|
|
5
|
+
const { cmp } = require('../number/module.f.cjs')
|
|
6
|
+
const operator = require("../function/operator/module.f.cjs")
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @template T
|
|
10
|
+
* @typedef {[T, number]} Entry
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @template T
|
|
15
|
+
* @typedef {sortedList.SortedList<Entry<T>>} RangeMap
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @template T
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* readonly union: operator.Reduce<T>
|
|
22
|
+
* readonly equal: operator.Equal<T>
|
|
23
|
+
* }} Operators
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @template T
|
|
28
|
+
* @typedef {option.Option<Entry<T>>} RangeState
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @template T
|
|
33
|
+
* @typedef {(a: RangeMap<T>) => (b: RangeMap<T>) => RangeMap<T>} RangeMerge
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/** @type {<T>(union: operator.Reduce<T>) => (equal: operator.Equal<T>) => sortedList.ReduceOp<Entry<T>, RangeState<T>>} */
|
|
37
|
+
const reduceOp = union => equal => state => ([aItem, aMax]) => ([bItem, bMax]) => {
|
|
38
|
+
const sign = cmp(aMax)(bMax)
|
|
39
|
+
const min = sign === 1 ? bMax : aMax
|
|
40
|
+
const u = union(aItem)(bItem)
|
|
41
|
+
const newState = state !== undefined && equal(state[0])(u) ? undefined : state
|
|
42
|
+
return [newState, sign, [u, min]]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @type {<T>(equal: operator.Equal<T>) => sortedList.TailReduce<Entry<T>, RangeState<T>>} */
|
|
46
|
+
const tailReduce = equal => state => tail => {
|
|
47
|
+
if (state === undefined) { return tail }
|
|
48
|
+
const tailResult = list.next(tail)
|
|
49
|
+
if (tailResult === undefined) { return [state] }
|
|
50
|
+
if (equal(state[0])(tailResult.first[0])) { return tailResult }
|
|
51
|
+
return { first: state, tail: tailResult }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @type {<T>(op: Operators<T>) => RangeMerge<T>} */
|
|
55
|
+
const merge = ({union, equal}) => genericMerge({reduceOp: reduceOp(union)(equal), tailReduce: tailReduce(equal)})(undefined)
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
/** @readonly */
|
|
59
|
+
merge
|
|
60
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const _ = require('./module.f.cjs')
|
|
2
|
+
const { unsafeCmp } = require('../function/compare/module.f.cjs')
|
|
3
|
+
const json = require('../../json/module.f.cjs')
|
|
4
|
+
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
|
+
const sortedSet = require('../sorted_set/module.f.cjs')
|
|
6
|
+
const { list } = require('../module.f.cjs')
|
|
7
|
+
const operator = require("../function/operator/module.f.cjs")
|
|
8
|
+
|
|
9
|
+
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
10
|
+
const stringify = a => json.stringify(sort)(a)
|
|
11
|
+
|
|
12
|
+
/** @type {_.Operators<sortedSet.SortedSet<string>>} */
|
|
13
|
+
const op = { union: sortedSet.union(unsafeCmp), equal: list.equal(operator.strictEqual) }
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
merge: [
|
|
17
|
+
() => {
|
|
18
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
19
|
+
const a = [[['a'], 1], [['b'], 2]]
|
|
20
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
21
|
+
const b = undefined
|
|
22
|
+
const merged = _.merge(op)(a)(b)
|
|
23
|
+
const result = stringify(list.toArray(merged))
|
|
24
|
+
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
25
|
+
},
|
|
26
|
+
() => {
|
|
27
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
28
|
+
const a = undefined
|
|
29
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
30
|
+
const b = [[['a'], 1], [['b'], 2]]
|
|
31
|
+
const merged = _.merge(op)(a)(b)
|
|
32
|
+
const result = stringify(list.toArray(merged))
|
|
33
|
+
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
34
|
+
},
|
|
35
|
+
() => {
|
|
36
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
37
|
+
const a = [[['a'], 1], [['b'], 2]]
|
|
38
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
39
|
+
const b = [[['a'], 1], [['b'], 2]]
|
|
40
|
+
const merged = _.merge(op)(a)(b)
|
|
41
|
+
const result = stringify(list.toArray(merged))
|
|
42
|
+
if (result !== '[[["a"],1],[["b"],2]]') { throw result }
|
|
43
|
+
},
|
|
44
|
+
() => {
|
|
45
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
46
|
+
const a = [[['a'], 1], [['c'], 3]]
|
|
47
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
48
|
+
const b = [[['b'], 2], [['d'], 4]]
|
|
49
|
+
const merged = _.merge(op)(a)(b)
|
|
50
|
+
const result = stringify(list.toArray(merged))
|
|
51
|
+
if (result !== '[[["a","b"],1],[["b","c"],2],[["c","d"],3],[["d"],4]]') { throw result }
|
|
52
|
+
},
|
|
53
|
+
() => {
|
|
54
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
55
|
+
const a = [[['a'], 1], [['d'], 4]]
|
|
56
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
57
|
+
const b = [[['b'], 2], [['c'], 3]]
|
|
58
|
+
const merged = _.merge(op)(a)(b)
|
|
59
|
+
const result = stringify(list.toArray(merged))
|
|
60
|
+
if (result !== '[[["a","b"],1],[["b","d"],2],[["c","d"],3],[["d"],4]]') { throw result }
|
|
61
|
+
},
|
|
62
|
+
() => {
|
|
63
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
64
|
+
const a = [[['a'], 1], [['b'], 2]]
|
|
65
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
66
|
+
const b = [[['b'], 1], [['a'], 2]]
|
|
67
|
+
const merged = _.merge(op)(a)(b)
|
|
68
|
+
const result = stringify(list.toArray(merged))
|
|
69
|
+
if (result !== '[[["a","b"],2]]') { throw result }
|
|
70
|
+
},
|
|
71
|
+
() => {
|
|
72
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
73
|
+
const a = [[['a'], 1], [['b'], 2], [['a'], 3]]
|
|
74
|
+
/** @type {_.RangeMap<sortedSet.SortedSet<string>>} */
|
|
75
|
+
const b = [[['a'], 5]]
|
|
76
|
+
const merged = _.merge(op)(a)(b)
|
|
77
|
+
const result = stringify(list.toArray(merged))
|
|
78
|
+
if (result !== '[[["a"],1],[["a","b"],2],[["a"],5]]') { throw result }
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -14,11 +14,6 @@ const { identity } = require('../function/module.f.cjs')
|
|
|
14
14
|
* @typedef {(a: T) => (b: T) => compare.Sign} Cmp
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* @template T
|
|
19
|
-
* @typedef {SortedList<[T, number]>} RangeMap
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
17
|
/**
|
|
23
18
|
* @template T
|
|
24
19
|
* @template S
|
|
@@ -51,7 +46,7 @@ const genericMerge = reduce => {
|
|
|
51
46
|
const aResult = next(a)
|
|
52
47
|
if (aResult === undefined) { return tailReduce(state)(b) }
|
|
53
48
|
const bResult = next(b)
|
|
54
|
-
if (bResult === undefined) { return tailReduce(state)(
|
|
49
|
+
if (bResult === undefined) { return tailReduce(state)(aResult) }
|
|
55
50
|
const [first, sign, stateNext] = reduceOp(state)(aResult.first)(bResult.first)
|
|
56
51
|
const aNext = sign === 1 ? a : aResult.tail
|
|
57
52
|
const bNext = sign === -1 ? b : bResult.tail
|