Try returns
This commit is contained in:
parent
83645a48fa
commit
1ceebeb5c7
|
|
@ -328,8 +328,6 @@ const wasmPlugin = ({ production }: WasmLoaderConfig = {}): BunPlugin => {
|
||||||
'-I', include,
|
'-I', include,
|
||||||
];
|
];
|
||||||
|
|
||||||
const std = args.path.endsWith('.cpp') ? STD_CPP : STD_C;
|
|
||||||
|
|
||||||
const inputObjPath = path.resolve(distDir, inputBasename + '.o');
|
const inputObjPath = path.resolve(distDir, inputBasename + '.o');
|
||||||
const libCObjDir = path.resolve(distDir, 'lib.c');
|
const libCObjDir = path.resolve(distDir, 'lib.c');
|
||||||
const libCppObjDir = path.resolve(distDir, 'lib.cpp');
|
const libCppObjDir = path.resolve(distDir, 'lib.cpp');
|
||||||
|
|
@ -341,6 +339,8 @@ const wasmPlugin = ({ production }: WasmLoaderConfig = {}): BunPlugin => {
|
||||||
Array.fromAsync(libCppGlob.scan()),
|
Array.fromAsync(libCppGlob.scan()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const std = args.path.endsWith('.cpp') ? STD_CPP : STD_C;
|
||||||
|
|
||||||
const [, libCObjs, libCppObjs] = await Promise.all([
|
const [, libCObjs, libCppObjs] = await Promise.all([
|
||||||
(async () => {
|
(async () => {
|
||||||
const compilationFlags = [...flags, ...std];
|
const compilationFlags = [...flags, ...std];
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <js.h>
|
#include <js.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
class bit {
|
class bit {
|
||||||
|
|
@ -86,6 +88,10 @@ JS_EXPORT void awoo() {
|
||||||
std::cout << "rand = " << rand() << "\narc4 = " << arc4random() << std::endl;
|
std::cout << "rand = " << rand() << "\narc4 = " << arc4random() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_EXPORT_AS(something) void anything(void (*cb)()) {
|
auto autofunc(auto a) requires std::is_integral_v<decltype(a)> {
|
||||||
cb();
|
return a + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_EXPORT_AS(something) auto anything(uint8_t (*cb)()) {
|
||||||
|
return autofunc(cb());
|
||||||
|
}
|
||||||
|
|
@ -3,5 +3,8 @@ import awoo from './awoo.cpp';
|
||||||
export default function main() {
|
export default function main() {
|
||||||
console.log(awoo)
|
console.log(awoo)
|
||||||
awoo.awoo();
|
awoo.awoo();
|
||||||
awoo.something(() => console.log('called'));
|
console.log(awoo.something(() => {
|
||||||
|
console.log('called');
|
||||||
|
return 42;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue