-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from rycont/support-async-ffi-0.2.x
Support async ffi 0.2.x
- Loading branch information
Showing
56 changed files
with
332 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
import { yaksok } from '@yaksok-ts/core' | ||
import { QuickJS } from '@yaksok-ts/quickjs' | ||
import { yaksok, type ValueType } from '@yaksok-ts/core' | ||
|
||
const quickJS = new QuickJS() | ||
await quickJS.init() | ||
|
||
const code = ` | ||
번역(QuickJS), (최소)와 (최대) 사이의 랜덤한 수 | ||
*** | ||
return Math.floor(Math.random() * (최대 - 최소 + 1)) + 최소 | ||
*** | ||
(1)와 (10) 사이의 랜덤한 수 보여주기 | ||
` | ||
|
||
function runFFI( | ||
runtime: string, | ||
code: string, | ||
params: Record<string, ValueType>, | ||
) { | ||
if (runtime !== 'QuickJS') { | ||
throw new Error(`Unknown runtime: ${runtime}`) | ||
} | ||
const quickJS = new QuickJS({ | ||
prompt: () => { | ||
return '10' | ||
}, | ||
}) | ||
|
||
const result = quickJS.run(code, params) | ||
|
||
if (!result) { | ||
throw new Error('Result is null') | ||
} | ||
|
||
return result | ||
} | ||
await quickJS.init() | ||
|
||
yaksok(code, { runFFI }) | ||
await yaksok({ | ||
아두이노: ` | ||
약속, 이름 | ||
결과: "아두이노" / 2 | ||
`, | ||
main: '(@아두이노 이름) 보여주기', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.