1
0
Fork 0

Try returns

This commit is contained in:
Pabloader 2026-05-21 20:34:32 +00:00
parent 83645a48fa
commit 1ceebeb5c7
3 changed files with 14 additions and 5 deletions

View File

@ -328,8 +328,6 @@ const wasmPlugin = ({ production }: WasmLoaderConfig = {}): BunPlugin => {
'-I', include,
];
const std = args.path.endsWith('.cpp') ? STD_CPP : STD_C;
const inputObjPath = path.resolve(distDir, inputBasename + '.o');
const libCObjDir = path.resolve(distDir, 'lib.c');
const libCppObjDir = path.resolve(distDir, 'lib.cpp');
@ -341,6 +339,8 @@ const wasmPlugin = ({ production }: WasmLoaderConfig = {}): BunPlugin => {
Array.fromAsync(libCppGlob.scan()),
]);
const std = args.path.endsWith('.cpp') ? STD_CPP : STD_C;
const [, libCObjs, libCppObjs] = await Promise.all([
(async () => {
const compilationFlags = [...flags, ...std];

View File

@ -1,9 +1,11 @@
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <js.h>
#include <stdlib.h>
#include <string>
#include <type_traits>
#include <utility>
class bit {
@ -86,6 +88,10 @@ JS_EXPORT void awoo() {
std::cout << "rand = " << rand() << "\narc4 = " << arc4random() << std::endl;
}
JS_EXPORT_AS(something) void anything(void (*cb)()) {
cb();
auto autofunc(auto a) requires std::is_integral_v<decltype(a)> {
return a + 1;
}
JS_EXPORT_AS(something) auto anything(uint8_t (*cb)()) {
return autofunc(cb());
}

View File

@ -3,5 +3,8 @@ import awoo from './awoo.cpp';
export default function main() {
console.log(awoo)
awoo.awoo();
awoo.something(() => console.log('called'));
console.log(awoo.something(() => {
console.log('called');
return 42;
}));
}