functionalscript 0.0.458 → 0.0.460

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.
@@ -65,7 +65,7 @@ const cpp = name => lib => {
65
65
 
66
66
  /** @type {(m: types.Method) => text.Item} */
67
67
  const method = ([name, paramArray]) =>
68
- `virtual ${cppResult(paramArray)} COM_STDCALL ${name}(${join(', ')(mapParam(paramList(paramArray)))}) = 0;`
68
+ `virtual ${cppResult(paramArray)} COM_STDCALL ${name}(${join(', ')(mapParam(paramList(paramArray)))}) noexcept = 0;`
69
69
 
70
70
  const mapMethod = map(method)
71
71
 
@@ -21,13 +21,13 @@ const f = () =>
21
21
  ' };\n' +
22
22
  ' struct IMy: ::com::IUnknown\n' +
23
23
  ' {\n' +
24
- ' virtual Slice COM_STDCALL GetSlice() = 0;\n' +
25
- ' virtual void COM_STDCALL SetSlice(Slice slice) = 0;\n' +
26
- ' virtual ::com::BOOL* COM_STDCALL GetUnsafe() = 0;\n' +
27
- ' virtual void COM_STDCALL SetUnsafe(Slice* p, uint32_t size) = 0;\n' +
28
- ' virtual ::com::BOOL COM_STDCALL Some(IMy& p) = 0;\n' +
29
- ' virtual ::com::ref<IMy> COM_STDCALL GetIMy() = 0;\n' +
30
- ' virtual void COM_STDCALL SetManagedStruct(ManagedStruct a) = 0;\n' +
24
+ ' virtual Slice COM_STDCALL GetSlice() noexcept = 0;\n' +
25
+ ' virtual void COM_STDCALL SetSlice(Slice slice) noexcept = 0;\n' +
26
+ ' virtual ::com::BOOL* COM_STDCALL GetUnsafe() noexcept = 0;\n' +
27
+ ' virtual void COM_STDCALL SetUnsafe(Slice* p, uint32_t size) noexcept = 0;\n' +
28
+ ' virtual ::com::BOOL COM_STDCALL Some(IMy& p) noexcept = 0;\n' +
29
+ ' virtual ::com::ref<IMy> COM_STDCALL GetIMy() noexcept = 0;\n' +
30
+ ' virtual void COM_STDCALL SetManagedStruct(ManagedStruct a) noexcept = 0;\n' +
31
31
  ' };\n' +
32
32
  '}'
33
33
  if (cpp !== e) { throw cpp }
@@ -1,11 +1,12 @@
1
1
  const { writeFileSync } = require('node:fs')
2
2
  const { execSync } = require('node:child_process')
3
- const { platform } = require('node:process')
3
+ const { platform, exit } = require('node:process')
4
4
  const build = require('./build.f.cjs')
5
5
  const { cpp, cs, rust } = build
6
6
  const { join } = require('../../types/string/module.f.cjs')
7
7
  const { log, error } = console
8
8
  const { bold, reset } = require('../../text/sgr/module.f.cjs')
9
+ const { list } = require('../../types/module.f.cjs')
9
10
 
10
11
  const nodeJs = {
11
12
  dirname: __dirname,
@@ -17,16 +18,19 @@ const run = f => {
17
18
  const { file: { name, content }, line } = f(nodeJs)
18
19
  log(`${bold}writing: ${name}${reset}`)
19
20
  writeFileSync(name, content)
20
- const cmd = join(' ')(line)
21
- log(`${bold}running: ${cmd}${reset}`)
22
- try {
23
- log(execSync(cmd).toString())
24
- } catch (e) {
25
- // @ts-ignore
26
- error(e.output.toString())
21
+ for (const i of list.iterable(line)) {
22
+ const cmd = join(' ')(i)
23
+ log(`${bold}running: ${cmd}${reset}`)
24
+ try {
25
+ log(execSync(cmd).toString())
26
+ } catch (e) {
27
+ // @ts-ignore
28
+ error(e.output.toString())
29
+ exit(-1)
30
+ }
27
31
  }
28
32
  }
29
33
 
30
34
  run(cpp)
31
- run(cs)
32
35
  run(rust)
36
+ run(cs)
@@ -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: list.List<string>
37
+ * readonly line: list.List<list.List<string>>
38
38
  * }} Output
39
39
  */
40
40
 
@@ -52,26 +52,39 @@ const flags = platform => {
52
52
  }
53
53
  }
54
54
 
55
+ /** @type {(platform: Platform) => (name: string) => string} */
56
+ const output = platform => name => {
57
+ switch (platform) {
58
+ case 'win32': return `${name}.dll`
59
+ case 'darwin': return `lib${name}.dylib`
60
+ default: return `lib${name}.so`
61
+ }
62
+ }
63
+
55
64
  /** @type {Func} */
56
65
  const cpp = ({dirname, platform}) => ({
57
66
  file: {
58
67
  name: `${dirname}/cpp/_result.hpp`,
59
68
  content: cppContent,
60
69
  },
61
- line: flat([
62
- ['clang'],
63
- flags(platform),
64
- [`${dirname}/cpp/main.cpp`]]
65
- ),
70
+ line: [
71
+ flat([
72
+ ['clang', '-shared', '-o', output(platform)('main')],
73
+ flags(platform),
74
+ [`${dirname}/cpp/main.cpp`]]
75
+ ),
76
+ ],
66
77
  })
67
78
 
79
+
68
80
  /** @type {Func} */
69
81
  const cs = ({dirname}) => ({
70
82
  file: {
71
83
  name: `${dirname}/cs/_result.cs`,
72
84
  content: csContent,
73
85
  },
74
- line: ['dotnet', 'build', `${dirname}/cs/cs.csproj`],
86
+ line: [
87
+ ['dotnet', 'run', '--project', `${dirname}/cs/cs.csproj`]],
75
88
  })
76
89
 
77
90
  /** @type {Func} */
@@ -80,7 +93,7 @@ const rust = ({dirname}) => ({
80
93
  name: `${dirname}/rust/src/_result.rs`,
81
94
  content: rustContent,
82
95
  },
83
- line: ['cargo', 'build']
96
+ line: [['cargo', 'build']]
84
97
  })
85
98
 
86
99
  module.exports = {
@@ -1,9 +1,2 @@
1
1
  #include "../../cpp/com.hpp"
2
2
  #include "_result.hpp"
3
-
4
- #include <iostream>
5
-
6
- int main()
7
- {
8
- std::cout << "Hello world!" << std::endl;
9
- }
@@ -1,2 +1,8 @@
1
- // See https://aka.ms/new-console-template for more information
1
+ using System.Runtime.InteropServices;
2
+
3
+ [DllImport("testrust")]
4
+ static extern int get();
5
+
6
+ // See https://aka.ms/new-console-template for more information
2
7
  Console.WriteLine("Hello, World!");
8
+ Console.WriteLine(get());
@@ -8,4 +8,8 @@
8
8
  <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
9
9
  </PropertyGroup>
10
10
 
11
+ <ItemGroup>
12
+ <None Include="../../../target/debug/*testrust.*" CopyToOutputDirectory="PreserveNewest"/>
13
+ </ItemGroup>
14
+
11
15
  </Project>
@@ -41,3 +41,6 @@ impl _result::IMy::Ex for nanocom::CObject<My> {
41
41
  todo!()
42
42
  }
43
43
  }
44
+
45
+ #[no_mangle]
46
+ pub extern "C" fn get() -> i32 { 42 }
package/fsm/README.md CHANGED
@@ -39,16 +39,75 @@ const idNext = byteSet.union(idBegin)(digit)
39
39
  const dot = byteSet('.')
40
40
 
41
41
  const grammar = [
42
- ['init', digit, 'int'],
42
+ ['', digit, 'int'],
43
43
  ['int', digit, 'int'],
44
44
  //
45
- ['init', digit, 'floatBegin'],
45
+ ['', digit, 'floatBegin'],
46
46
  ['floatBegin', digit, 'floatBegin'],
47
47
  ['floatBegin', dot, 'floatDot'],
48
48
  ['floatDot', digit, 'float'],
49
49
  ['float', digit, 'float'],
50
50
  //
51
- ['init', idBegin, 'id'],
51
+ ['', idBegin, 'id'],
52
52
  ['id', idNext, 'id'],
53
53
  ]
54
54
  ```
55
+
56
+ ```js
57
+ const result = {
58
+ "['']": {
59
+ digit: "['floatBegin','int']",
60
+ idBegin: "['id']"
61
+ },
62
+ "['floatBegin','int']": {
63
+ digit: "['floatBegin','int']",
64
+ dot: "['floatDot']",
65
+ },
66
+ "['floatDot']": {
67
+ digit: "['float']"
68
+ },
69
+ "['float']": {
70
+ digit: "['float']"
71
+ },
72
+ "['id']": {
73
+ idNext: "['id']"
74
+ }
75
+ }
76
+ ```
77
+
78
+ ```js
79
+ const result = [
80
+ { // 0
81
+ digit: 1,
82
+ idBegin: 4
83
+ },
84
+ { // 1
85
+ digit: 1,
86
+ dot: 2,
87
+ },
88
+ { // 2
89
+ digit: 3
90
+ },
91
+ { // 3
92
+ digit: 3
93
+ },
94
+ { // 4
95
+ idNext: 4
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## How to Add a Property # 1
101
+
102
+ ```js
103
+ const a = { x: 5, y: 6 }
104
+ const b = { ...a, z: 7 }
105
+ ```
106
+
107
+ ## How to Add a Property # 2
108
+
109
+ ```js
110
+ const map = reauire('./types/map/module.f.js')
111
+ const a = map.fromEntries(Object.entries({ x: 5, y: 6 }))
112
+ const b = map.setReplace('z')(7)(a)
113
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.458",
3
+ "version": "0.0.460",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {