koffi 2.0.0 → 2.1.0-beta.2
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/CMakeLists.txt +2 -9
- package/ChangeLog.md +25 -2
- package/benchmark/atoi_koffi.js +12 -8
- package/benchmark/atoi_napi.js +12 -8
- package/benchmark/atoi_node_ffi.js +11 -10
- package/benchmark/raylib_cc.cc +12 -9
- package/benchmark/raylib_koffi.js +15 -13
- package/benchmark/raylib_node_ffi.js +15 -13
- package/benchmark/raylib_node_raylib.js +14 -11
- package/build/qemu/2.1.0-beta.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.2/koffi_win32_x64.tar.gz +0 -0
- package/doc/benchmarks.md +2 -2
- package/doc/changes.md +23 -19
- package/doc/conf.py +14 -1
- package/doc/dist/doctrees/benchmarks.doctree +0 -0
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/environment.pickle +0 -0
- package/doc/dist/doctrees/functions.doctree +0 -0
- package/doc/dist/doctrees/index.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/functions.md +76 -10
- package/doc/templates/badges.html +4 -0
- package/doc/types.md +157 -161
- package/package.json +2 -2
- package/qemu/qemu.js +1 -1
- package/src/abi_arm32.cc +167 -3
- package/src/abi_arm64.cc +196 -3
- package/src/abi_riscv64.cc +107 -3
- package/src/abi_x64_sysv.cc +114 -4
- package/src/abi_x64_win.cc +113 -3
- package/src/abi_x86.cc +156 -5
- package/src/call.cc +241 -26
- package/src/call.hh +15 -3
- package/src/ffi.cc +123 -34
- package/src/ffi.hh +19 -0
- package/src/index.js +4 -2
- package/src/parser.cc +3 -5
- package/src/util.cc +44 -1
- package/src/util.hh +4 -0
- package/test/async.js +1 -2
- package/test/callbacks.js +2 -3
- package/test/misc.c +21 -1
- package/test/raylib.js +1 -1
- package/test/sqlite.js +7 -7
- package/test/sync.js +30 -4
- package/build/qemu/2.0.0/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.0.0/koffi_win32_x64.tar.gz +0 -0
- package/doc/dist/html/.buildinfo +0 -4
- package/doc/dist/html/_sources/benchmarks.md.txt +0 -137
- package/doc/dist/html/_sources/changes.md.txt +0 -157
- package/doc/dist/html/_sources/contribute.md.txt +0 -127
- package/doc/dist/html/_sources/functions.md.txt +0 -355
- package/doc/dist/html/_sources/index.rst.txt +0 -39
- package/doc/dist/html/_sources/memory.md.txt +0 -32
- package/doc/dist/html/_sources/platforms.md.txt +0 -31
- package/doc/dist/html/_sources/start.md.txt +0 -100
- package/doc/dist/html/_sources/types.md.txt +0 -545
- package/doc/dist/html/_static/_sphinx_javascript_frameworks_compat.js +0 -134
- package/doc/dist/html/_static/basic.css +0 -932
- package/doc/dist/html/_static/bench_linux.png +0 -0
- package/doc/dist/html/_static/bench_windows.png +0 -0
- package/doc/dist/html/_static/custom.css +0 -22
- package/doc/dist/html/_static/debug.css +0 -69
- package/doc/dist/html/_static/doctools.js +0 -264
- package/doc/dist/html/_static/documentation_options.js +0 -14
- package/doc/dist/html/_static/file.png +0 -0
- package/doc/dist/html/_static/jquery-3.6.0.js +0 -10881
- package/doc/dist/html/_static/jquery.js +0 -2
- package/doc/dist/html/_static/language_data.js +0 -199
- package/doc/dist/html/_static/minus.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220623.png +0 -0
- package/doc/dist/html/_static/perf_linux_20220623_2.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623.png +0 -0
- package/doc/dist/html/_static/perf_windows_20220623_2.png +0 -0
- package/doc/dist/html/_static/plus.png +0 -0
- package/doc/dist/html/_static/pygments.css +0 -252
- package/doc/dist/html/_static/scripts/furo-extensions.js +0 -0
- package/doc/dist/html/_static/scripts/furo.js +0 -3
- package/doc/dist/html/_static/scripts/furo.js.LICENSE.txt +0 -7
- package/doc/dist/html/_static/scripts/furo.js.map +0 -1
- package/doc/dist/html/_static/searchtools.js +0 -531
- package/doc/dist/html/_static/skeleton.css +0 -296
- package/doc/dist/html/_static/styles/furo-extensions.css +0 -2
- package/doc/dist/html/_static/styles/furo-extensions.css.map +0 -1
- package/doc/dist/html/_static/styles/furo.css +0 -2
- package/doc/dist/html/_static/styles/furo.css.map +0 -1
- package/doc/dist/html/_static/underscore-1.13.1.js +0 -2042
- package/doc/dist/html/_static/underscore.js +0 -6
- package/doc/dist/html/benchmarks.html +0 -568
- package/doc/dist/html/changes.html +0 -653
- package/doc/dist/html/contribute.html +0 -400
- package/doc/dist/html/functions.html +0 -653
- package/doc/dist/html/genindex.html +0 -250
- package/doc/dist/html/index.html +0 -356
- package/doc/dist/html/memory.html +0 -343
- package/doc/dist/html/objects.inv +0 -0
- package/doc/dist/html/platforms.html +0 -368
- package/doc/dist/html/search.html +0 -258
- package/doc/dist/html/searchindex.js +0 -1
- package/doc/dist/html/start.html +0 -381
- package/doc/dist/html/types.html +0 -1044
package/src/abi_arm32.cc
CHANGED
|
@@ -155,9 +155,13 @@ bool AnalyseFunction(Napi::Env, InstanceData *, FunctionInfo *func)
|
|
|
155
155
|
case PrimitiveKind::Int8:
|
|
156
156
|
case PrimitiveKind::UInt8:
|
|
157
157
|
case PrimitiveKind::Int16:
|
|
158
|
+
case PrimitiveKind::Int16S:
|
|
158
159
|
case PrimitiveKind::UInt16:
|
|
160
|
+
case PrimitiveKind::UInt16S:
|
|
159
161
|
case PrimitiveKind::Int32:
|
|
162
|
+
case PrimitiveKind::Int32S:
|
|
160
163
|
case PrimitiveKind::UInt32:
|
|
164
|
+
case PrimitiveKind::UInt32S:
|
|
161
165
|
case PrimitiveKind::String:
|
|
162
166
|
case PrimitiveKind::String16:
|
|
163
167
|
case PrimitiveKind::Pointer:
|
|
@@ -170,7 +174,9 @@ bool AnalyseFunction(Napi::Env, InstanceData *, FunctionInfo *func)
|
|
|
170
174
|
}
|
|
171
175
|
} break;
|
|
172
176
|
case PrimitiveKind::Int64:
|
|
173
|
-
case PrimitiveKind::
|
|
177
|
+
case PrimitiveKind::Int64S:
|
|
178
|
+
case PrimitiveKind::UInt64:
|
|
179
|
+
case PrimitiveKind::UInt64S: {
|
|
174
180
|
bool realign = gpr_avail % 2;
|
|
175
181
|
int need = 2 + realign;
|
|
176
182
|
|
|
@@ -301,6 +307,17 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
301
307
|
int32_t v = CopyNumber<int32_t>(value);
|
|
302
308
|
*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
303
309
|
} break;
|
|
310
|
+
case PrimitiveKind::Int16S:
|
|
311
|
+
case PrimitiveKind::UInt16S:
|
|
312
|
+
case PrimitiveKind::Int32S: {
|
|
313
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
314
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
int32_t v = ReverseBytes(CopyNumber<int32_t>(value));
|
|
319
|
+
*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
320
|
+
} break;
|
|
304
321
|
case PrimitiveKind::UInt32: {
|
|
305
322
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
306
323
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
@@ -310,6 +327,15 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
310
327
|
uint32_t v = CopyNumber<uint32_t>(value);
|
|
311
328
|
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
312
329
|
} break;
|
|
330
|
+
case PrimitiveKind::UInt32S: {
|
|
331
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
332
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
uint32_t v = ReverseBytes(CopyNumber<uint32_t>(value));
|
|
337
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
338
|
+
} break;
|
|
313
339
|
case PrimitiveKind::Int64: {
|
|
314
340
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
315
341
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
@@ -328,6 +354,24 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
328
354
|
args_ptr += 2;
|
|
329
355
|
}
|
|
330
356
|
} break;
|
|
357
|
+
case PrimitiveKind::Int64S: {
|
|
358
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
359
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
364
|
+
|
|
365
|
+
if (RG_LIKELY(param.gpr_count)) {
|
|
366
|
+
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
367
|
+
*(int64_t *)gpr_ptr = v;
|
|
368
|
+
gpr_ptr += param.gpr_count;
|
|
369
|
+
} else {
|
|
370
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
371
|
+
*(int64_t *)args_ptr = v;
|
|
372
|
+
args_ptr += 2;
|
|
373
|
+
}
|
|
374
|
+
} break;
|
|
331
375
|
case PrimitiveKind::UInt64: {
|
|
332
376
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
333
377
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
@@ -346,6 +390,24 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
346
390
|
args_ptr += 2;
|
|
347
391
|
}
|
|
348
392
|
} break;
|
|
393
|
+
case PrimitiveKind::UInt64S: {
|
|
394
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
395
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
400
|
+
|
|
401
|
+
if (RG_LIKELY(param.gpr_count)) {
|
|
402
|
+
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
403
|
+
*(uint64_t *)gpr_ptr = v;
|
|
404
|
+
gpr_ptr += param.gpr_count;
|
|
405
|
+
} else {
|
|
406
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
407
|
+
*(uint64_t *)args_ptr = v;
|
|
408
|
+
args_ptr += 2;
|
|
409
|
+
}
|
|
410
|
+
} break;
|
|
349
411
|
case PrimitiveKind::String: {
|
|
350
412
|
const char *str;
|
|
351
413
|
if (RG_LIKELY(value.IsString())) {
|
|
@@ -498,14 +560,20 @@ void CallData::Execute()
|
|
|
498
560
|
switch (func->ret.type->primitive) {
|
|
499
561
|
case PrimitiveKind::Void:
|
|
500
562
|
case PrimitiveKind::Bool:
|
|
501
|
-
case PrimitiveKind::Int8:
|
|
563
|
+
case PrimitiveKind::Int8:
|
|
502
564
|
case PrimitiveKind::UInt8:
|
|
503
565
|
case PrimitiveKind::Int16:
|
|
566
|
+
case PrimitiveKind::Int16S:
|
|
504
567
|
case PrimitiveKind::UInt16:
|
|
568
|
+
case PrimitiveKind::UInt16S:
|
|
505
569
|
case PrimitiveKind::Int32:
|
|
570
|
+
case PrimitiveKind::Int32S:
|
|
506
571
|
case PrimitiveKind::UInt32:
|
|
572
|
+
case PrimitiveKind::UInt32S:
|
|
507
573
|
case PrimitiveKind::Int64:
|
|
574
|
+
case PrimitiveKind::Int64S:
|
|
508
575
|
case PrimitiveKind::UInt64:
|
|
576
|
+
case PrimitiveKind::UInt64S:
|
|
509
577
|
case PrimitiveKind::String:
|
|
510
578
|
case PrimitiveKind::String16:
|
|
511
579
|
case PrimitiveKind::Pointer:
|
|
@@ -539,16 +607,22 @@ Napi::Value CallData::Complete()
|
|
|
539
607
|
};
|
|
540
608
|
|
|
541
609
|
switch (func->ret.type->primitive) {
|
|
542
|
-
case PrimitiveKind::Void: return env.
|
|
610
|
+
case PrimitiveKind::Void: return env.Undefined();
|
|
543
611
|
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u32);
|
|
544
612
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
545
613
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
546
614
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
615
|
+
case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
|
|
547
616
|
case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
|
|
617
|
+
case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
|
|
548
618
|
case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
|
|
619
|
+
case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
|
|
549
620
|
case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
|
|
621
|
+
case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
|
|
550
622
|
case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
|
|
623
|
+
case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
|
|
551
624
|
case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
|
|
625
|
+
case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
|
|
552
626
|
case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
|
|
553
627
|
case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
|
|
554
628
|
case PrimitiveKind::Pointer:
|
|
@@ -637,24 +711,52 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
637
711
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
638
712
|
arguments.Append(arg);
|
|
639
713
|
} break;
|
|
714
|
+
case PrimitiveKind::Int16S: {
|
|
715
|
+
int16_t v = *(int16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
716
|
+
double d = (double)ReverseBytes(v);
|
|
717
|
+
|
|
718
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
719
|
+
arguments.Append(arg);
|
|
720
|
+
} break;
|
|
640
721
|
case PrimitiveKind::UInt16: {
|
|
641
722
|
double d = (double)*(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
642
723
|
|
|
643
724
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
644
725
|
arguments.Append(arg);
|
|
645
726
|
} break;
|
|
727
|
+
case PrimitiveKind::UInt16S: {
|
|
728
|
+
uint16_t v = *(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
729
|
+
double d = (double)ReverseBytes(v);
|
|
730
|
+
|
|
731
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
732
|
+
arguments.Append(arg);
|
|
733
|
+
} break;
|
|
646
734
|
case PrimitiveKind::Int32: {
|
|
647
735
|
double d = (double)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
648
736
|
|
|
649
737
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
650
738
|
arguments.Append(arg);
|
|
651
739
|
} break;
|
|
740
|
+
case PrimitiveKind::Int32S: {
|
|
741
|
+
int32_t v = *(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
742
|
+
double d = (double)ReverseBytes(v);
|
|
743
|
+
|
|
744
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
745
|
+
arguments.Append(arg);
|
|
746
|
+
} break;
|
|
652
747
|
case PrimitiveKind::UInt32: {
|
|
653
748
|
double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
654
749
|
|
|
655
750
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
656
751
|
arguments.Append(arg);
|
|
657
752
|
} break;
|
|
753
|
+
case PrimitiveKind::UInt32S: {
|
|
754
|
+
uint32_t v = *(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
755
|
+
double d = (double)ReverseBytes(v);
|
|
756
|
+
|
|
757
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
758
|
+
arguments.Append(arg);
|
|
759
|
+
} break;
|
|
658
760
|
case PrimitiveKind::Int64: {
|
|
659
761
|
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
660
762
|
|
|
@@ -664,6 +766,15 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
664
766
|
Napi::Value arg = NewBigInt(env, v);
|
|
665
767
|
arguments.Append(arg);
|
|
666
768
|
} break;
|
|
769
|
+
case PrimitiveKind::Int64S: {
|
|
770
|
+
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
771
|
+
|
|
772
|
+
int64_t v = *(int64_t *)(param.gpr_count ? gpr_ptr : args_ptr);
|
|
773
|
+
(param.gpr_count ? gpr_ptr : args_ptr) += 2;
|
|
774
|
+
|
|
775
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
776
|
+
arguments.Append(arg);
|
|
777
|
+
} break;
|
|
667
778
|
case PrimitiveKind::UInt64: {
|
|
668
779
|
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
669
780
|
|
|
@@ -673,6 +784,15 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
673
784
|
Napi::Value arg = NewBigInt(env, v);
|
|
674
785
|
arguments.Append(arg);
|
|
675
786
|
} break;
|
|
787
|
+
case PrimitiveKind::UInt64S: {
|
|
788
|
+
gpr_ptr = AlignUp(gpr_ptr, 8);
|
|
789
|
+
|
|
790
|
+
uint64_t v = *(uint64_t *)(param.gpr_count ? gpr_ptr : args_ptr);
|
|
791
|
+
(param.gpr_count ? gpr_ptr : args_ptr) += 2;
|
|
792
|
+
|
|
793
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
794
|
+
arguments.Append(arg);
|
|
795
|
+
} break;
|
|
676
796
|
case PrimitiveKind::String: {
|
|
677
797
|
const char *str = *(const char **)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
678
798
|
|
|
@@ -824,6 +944,17 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
824
944
|
int32_t v = CopyNumber<int32_t>(value);
|
|
825
945
|
out_reg->r0 = (uint32_t)v;
|
|
826
946
|
} break;
|
|
947
|
+
case PrimitiveKind::Int16S:
|
|
948
|
+
case PrimitiveKind::UInt16S:
|
|
949
|
+
case PrimitiveKind::Int32S: {
|
|
950
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
951
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
int32_t v = CopyNumber<int32_t>(value);
|
|
956
|
+
out_reg->r0 = (uint32_t)ReverseBytes(v);
|
|
957
|
+
} break;
|
|
827
958
|
case PrimitiveKind::UInt32: {
|
|
828
959
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
829
960
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
@@ -833,6 +964,15 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
833
964
|
uint32_t v = CopyNumber<uint32_t>(value);
|
|
834
965
|
out_reg->r0 = v;
|
|
835
966
|
} break;
|
|
967
|
+
case PrimitiveKind::UInt32S: {
|
|
968
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
969
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
uint32_t v = CopyNumber<uint32_t>(value);
|
|
974
|
+
out_reg->r0 = ReverseBytes(v);
|
|
975
|
+
} break;
|
|
836
976
|
case PrimitiveKind::Int64: {
|
|
837
977
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
838
978
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
@@ -840,6 +980,18 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
840
980
|
}
|
|
841
981
|
|
|
842
982
|
int64_t v = CopyNumber<int64_t>(value);
|
|
983
|
+
|
|
984
|
+
out_reg->r0 = (uint32_t)(v >> 32);
|
|
985
|
+
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
986
|
+
} break;
|
|
987
|
+
case PrimitiveKind::Int64S: {
|
|
988
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
989
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
994
|
+
|
|
843
995
|
out_reg->r0 = (uint32_t)(v >> 32);
|
|
844
996
|
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
845
997
|
} break;
|
|
@@ -850,6 +1002,18 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
850
1002
|
}
|
|
851
1003
|
|
|
852
1004
|
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1005
|
+
|
|
1006
|
+
out_reg->r0 = (uint32_t)(v >> 32);
|
|
1007
|
+
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
1008
|
+
} break;
|
|
1009
|
+
case PrimitiveKind::UInt64S: {
|
|
1010
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1011
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
1016
|
+
|
|
853
1017
|
out_reg->r0 = (uint32_t)(v >> 32);
|
|
854
1018
|
out_reg->r1 = (uint32_t)((uint64_t)v & 0xFFFFFFFFu);
|
|
855
1019
|
} break;
|
package/src/abi_arm64.cc
CHANGED
|
@@ -151,11 +151,17 @@ bool AnalyseFunction(Napi::Env, InstanceData *, FunctionInfo *func)
|
|
|
151
151
|
case PrimitiveKind::Int8:
|
|
152
152
|
case PrimitiveKind::UInt8:
|
|
153
153
|
case PrimitiveKind::Int16:
|
|
154
|
+
case PrimitiveKind::Int16S:
|
|
154
155
|
case PrimitiveKind::UInt16:
|
|
156
|
+
case PrimitiveKind::UInt16S:
|
|
155
157
|
case PrimitiveKind::Int32:
|
|
158
|
+
case PrimitiveKind::Int32S:
|
|
156
159
|
case PrimitiveKind::UInt32:
|
|
160
|
+
case PrimitiveKind::UInt32S:
|
|
157
161
|
case PrimitiveKind::Int64:
|
|
162
|
+
case PrimitiveKind::Int64S:
|
|
158
163
|
case PrimitiveKind::UInt64:
|
|
164
|
+
case PrimitiveKind::UInt64S:
|
|
159
165
|
case PrimitiveKind::String:
|
|
160
166
|
case PrimitiveKind::String16:
|
|
161
167
|
case PrimitiveKind::Pointer:
|
|
@@ -302,6 +308,30 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
302
308
|
|
|
303
309
|
int64_t v = CopyNumber<int64_t>(value);
|
|
304
310
|
|
|
311
|
+
#ifdef __APPLE__
|
|
312
|
+
if (RG_LIKELY(param.gpr_count)) {
|
|
313
|
+
*(int64_t *)(gpr_ptr++) = v;
|
|
314
|
+
} else {
|
|
315
|
+
args_ptr = AlignUp(args_ptr, param.type->align);
|
|
316
|
+
*(int64_t *)args_ptr = v;
|
|
317
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + param.type->size);
|
|
318
|
+
}
|
|
319
|
+
#else
|
|
320
|
+
*(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
321
|
+
#endif
|
|
322
|
+
} break;
|
|
323
|
+
case PrimitiveKind::Int16S:
|
|
324
|
+
case PrimitiveKind::UInt16S:
|
|
325
|
+
case PrimitiveKind::Int32S:
|
|
326
|
+
case PrimitiveKind::UInt32S:
|
|
327
|
+
case PrimitiveKind::Int64S: {
|
|
328
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
329
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
int64_t v = ReverseBytes(CopyNumber<int64_t>(value));
|
|
334
|
+
|
|
305
335
|
#ifdef __APPLE__
|
|
306
336
|
if (RG_LIKELY(param.gpr_count)) {
|
|
307
337
|
*(int64_t *)(gpr_ptr++) = v;
|
|
@@ -322,6 +352,19 @@ bool CallData::Prepare(const Napi::CallbackInfo &info)
|
|
|
322
352
|
|
|
323
353
|
uint64_t v = CopyNumber<uint64_t>(value);
|
|
324
354
|
|
|
355
|
+
#ifdef __APPLE__
|
|
356
|
+
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
357
|
+
#endif
|
|
358
|
+
*((param.gpr_count ? gpr_ptr : args_ptr)++) = v;
|
|
359
|
+
} break;
|
|
360
|
+
case PrimitiveKind::UInt64S: {
|
|
361
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
362
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for argument %2, expected number", GetValueType(instance, value), param.offset + 1);
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
uint64_t v = ReverseBytes(CopyNumber<uint64_t>(value));
|
|
367
|
+
|
|
325
368
|
#ifdef __APPLE__
|
|
326
369
|
args_ptr = param.gpr_count ? args_ptr : AlignUp(args_ptr, 8);
|
|
327
370
|
#endif
|
|
@@ -519,11 +562,17 @@ void CallData::Execute()
|
|
|
519
562
|
case PrimitiveKind::Int8:
|
|
520
563
|
case PrimitiveKind::UInt8:
|
|
521
564
|
case PrimitiveKind::Int16:
|
|
565
|
+
case PrimitiveKind::Int16S:
|
|
522
566
|
case PrimitiveKind::UInt16:
|
|
567
|
+
case PrimitiveKind::UInt16S:
|
|
523
568
|
case PrimitiveKind::Int32:
|
|
569
|
+
case PrimitiveKind::Int32S:
|
|
524
570
|
case PrimitiveKind::UInt32:
|
|
571
|
+
case PrimitiveKind::UInt32S:
|
|
525
572
|
case PrimitiveKind::Int64:
|
|
573
|
+
case PrimitiveKind::Int64S:
|
|
526
574
|
case PrimitiveKind::UInt64:
|
|
575
|
+
case PrimitiveKind::UInt64S:
|
|
527
576
|
case PrimitiveKind::String:
|
|
528
577
|
case PrimitiveKind::String16:
|
|
529
578
|
case PrimitiveKind::Pointer:
|
|
@@ -560,16 +609,22 @@ Napi::Value CallData::Complete()
|
|
|
560
609
|
};
|
|
561
610
|
|
|
562
611
|
switch (func->ret.type->primitive) {
|
|
563
|
-
case PrimitiveKind::Void: return env.
|
|
612
|
+
case PrimitiveKind::Void: return env.Undefined();
|
|
564
613
|
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u32);
|
|
565
614
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
566
615
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
567
616
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
617
|
+
case PrimitiveKind::Int16S: return Napi::Number::New(env, (double)ReverseBytes(result.i16));
|
|
568
618
|
case PrimitiveKind::UInt16: return Napi::Number::New(env, (double)result.u16);
|
|
619
|
+
case PrimitiveKind::UInt16S: return Napi::Number::New(env, (double)ReverseBytes(result.u16));
|
|
569
620
|
case PrimitiveKind::Int32: return Napi::Number::New(env, (double)result.i32);
|
|
621
|
+
case PrimitiveKind::Int32S: return Napi::Number::New(env, (double)ReverseBytes(result.i32));
|
|
570
622
|
case PrimitiveKind::UInt32: return Napi::Number::New(env, (double)result.u32);
|
|
623
|
+
case PrimitiveKind::UInt32S: return Napi::Number::New(env, (double)ReverseBytes(result.u32));
|
|
571
624
|
case PrimitiveKind::Int64: return NewBigInt(env, result.i64);
|
|
625
|
+
case PrimitiveKind::Int64S: return NewBigInt(env, ReverseBytes(result.i64));
|
|
572
626
|
case PrimitiveKind::UInt64: return NewBigInt(env, result.u64);
|
|
627
|
+
case PrimitiveKind::UInt64S: return NewBigInt(env, ReverseBytes(result.u64));
|
|
573
628
|
case PrimitiveKind::String: return result.ptr ? Napi::String::New(env, (const char *)result.ptr) : env.Null();
|
|
574
629
|
case PrimitiveKind::String16: return result.ptr ? Napi::String::New(env, (const char16_t *)result.ptr) : env.Null();
|
|
575
630
|
case PrimitiveKind::Pointer:
|
|
@@ -703,6 +758,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
703
758
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
704
759
|
arguments.Append(arg);
|
|
705
760
|
} break;
|
|
761
|
+
case PrimitiveKind::Int16S: {
|
|
762
|
+
#ifdef __APPLE__
|
|
763
|
+
double d;
|
|
764
|
+
if (param.gpr_count) {
|
|
765
|
+
int16_t v = *(int16_t *)(gpr_ptr++);
|
|
766
|
+
d = (double)ReverseBytes(v);
|
|
767
|
+
} else {
|
|
768
|
+
args_ptr = AlignUp(args_ptr, 2);
|
|
769
|
+
|
|
770
|
+
int16_t v = *(int16_t *)args_ptr;
|
|
771
|
+
d = (double)ReverseBytes(v);
|
|
772
|
+
|
|
773
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 2);
|
|
774
|
+
}
|
|
775
|
+
#else
|
|
776
|
+
int16_t v = *(int16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
777
|
+
double d = (double)ReverseBytes(v);
|
|
778
|
+
#endif
|
|
779
|
+
|
|
780
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
781
|
+
arguments.Append(arg);
|
|
782
|
+
} break;
|
|
706
783
|
case PrimitiveKind::UInt16: {
|
|
707
784
|
#ifdef __APPLE__
|
|
708
785
|
double d;
|
|
@@ -720,6 +797,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
720
797
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
721
798
|
arguments.Append(arg);
|
|
722
799
|
} break;
|
|
800
|
+
case PrimitiveKind::UInt16S: {
|
|
801
|
+
#ifdef __APPLE__
|
|
802
|
+
double d;
|
|
803
|
+
if (param.gpr_count) {
|
|
804
|
+
uint16_t v = *(uint16_t *)(gpr_ptr++);
|
|
805
|
+
d = (double)ReverseBytes(v);
|
|
806
|
+
} else {
|
|
807
|
+
args_ptr = AlignUp(args_ptr, 2);
|
|
808
|
+
|
|
809
|
+
uint16_t v = *(uint16_t *)args_ptr;
|
|
810
|
+
d = (double)ReverseBytes(v);
|
|
811
|
+
|
|
812
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 2);
|
|
813
|
+
}
|
|
814
|
+
#else
|
|
815
|
+
uint16_t v = *(uint16_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
816
|
+
double d = (double)ReverseBytes(v);
|
|
817
|
+
#endif
|
|
818
|
+
|
|
819
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
820
|
+
arguments.Append(arg);
|
|
821
|
+
} break;
|
|
723
822
|
case PrimitiveKind::Int32: {
|
|
724
823
|
#ifdef __APPLE__
|
|
725
824
|
double d;
|
|
@@ -737,6 +836,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
737
836
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
738
837
|
arguments.Append(arg);
|
|
739
838
|
} break;
|
|
839
|
+
case PrimitiveKind::Int32S: {
|
|
840
|
+
#ifdef __APPLE__
|
|
841
|
+
double d;
|
|
842
|
+
if (param.gpr_count) {
|
|
843
|
+
int32_t v = *(int32_t *)(gpr_ptr++);
|
|
844
|
+
d = (double)ReverseBytes(v);
|
|
845
|
+
} else {
|
|
846
|
+
args_ptr = AlignUp(args_ptr, 4);
|
|
847
|
+
|
|
848
|
+
int32_t v = *(int32_t *)args_ptr;
|
|
849
|
+
d = (double)ReverseBytes(v);
|
|
850
|
+
|
|
851
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 4);
|
|
852
|
+
}
|
|
853
|
+
#else
|
|
854
|
+
int32_t v = *(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
855
|
+
double d = (double)ReverseBytes(v);
|
|
856
|
+
#endif
|
|
857
|
+
|
|
858
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
859
|
+
arguments.Append(arg);
|
|
860
|
+
} break;
|
|
740
861
|
case PrimitiveKind::UInt32: {
|
|
741
862
|
#ifdef __APPLE__
|
|
742
863
|
double d;
|
|
@@ -754,6 +875,28 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
754
875
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
755
876
|
arguments.Append(arg);
|
|
756
877
|
} break;
|
|
878
|
+
case PrimitiveKind::UInt32S: {
|
|
879
|
+
#ifdef __APPLE__
|
|
880
|
+
double d;
|
|
881
|
+
if (param.gpr_count) {
|
|
882
|
+
uint32_t v = *(uint32_t *)(gpr_ptr++);
|
|
883
|
+
d = (double)ReverseBytes(v);
|
|
884
|
+
} else {
|
|
885
|
+
args_ptr = AlignUp(args_ptr, 4);
|
|
886
|
+
|
|
887
|
+
uint32_t v = *(uint32_t *)args_ptr;
|
|
888
|
+
d = (double)ReverseBytes(v);
|
|
889
|
+
|
|
890
|
+
args_ptr = (uint64_t *)((uint8_t *)args_ptr + 4);
|
|
891
|
+
}
|
|
892
|
+
#else
|
|
893
|
+
uint32_t v = *(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
894
|
+
double d = (double)ReverseBytes(v);
|
|
895
|
+
#endif
|
|
896
|
+
|
|
897
|
+
Napi::Value arg = Napi::Number::New(env, d);
|
|
898
|
+
arguments.Append(arg);
|
|
899
|
+
} break;
|
|
757
900
|
case PrimitiveKind::Int64: {
|
|
758
901
|
#ifdef __APPLE__
|
|
759
902
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -764,6 +907,16 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
764
907
|
Napi::Value arg = NewBigInt(env, v);
|
|
765
908
|
arguments.Append(arg);
|
|
766
909
|
} break;
|
|
910
|
+
case PrimitiveKind::Int64S: {
|
|
911
|
+
#ifdef __APPLE__
|
|
912
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
913
|
+
#endif
|
|
914
|
+
|
|
915
|
+
int64_t v = *(int64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
916
|
+
|
|
917
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
918
|
+
arguments.Append(arg);
|
|
919
|
+
} break;
|
|
767
920
|
case PrimitiveKind::UInt64: {
|
|
768
921
|
#ifdef __APPLE__
|
|
769
922
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -774,6 +927,16 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
774
927
|
Napi::Value arg = NewBigInt(env, v);
|
|
775
928
|
arguments.Append(arg);
|
|
776
929
|
} break;
|
|
930
|
+
case PrimitiveKind::UInt64S: {
|
|
931
|
+
#ifdef __APPLE__
|
|
932
|
+
args_ptr = AlignUp(args_ptr, 8);
|
|
933
|
+
#endif
|
|
934
|
+
|
|
935
|
+
uint64_t v = *(uint64_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
936
|
+
|
|
937
|
+
Napi::Value arg = NewBigInt(env, ReverseBytes(v));
|
|
938
|
+
arguments.Append(arg);
|
|
939
|
+
} break;
|
|
777
940
|
case PrimitiveKind::String: {
|
|
778
941
|
#ifdef __APPLE__
|
|
779
942
|
args_ptr = AlignUp(args_ptr, 8);
|
|
@@ -930,8 +1093,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
930
1093
|
case PrimitiveKind::UInt16:
|
|
931
1094
|
case PrimitiveKind::Int32:
|
|
932
1095
|
case PrimitiveKind::UInt32:
|
|
933
|
-
case PrimitiveKind::Int64:
|
|
934
|
-
case PrimitiveKind::UInt64: {
|
|
1096
|
+
case PrimitiveKind::Int64: {
|
|
935
1097
|
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
936
1098
|
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
937
1099
|
return;
|
|
@@ -940,6 +1102,37 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
940
1102
|
int64_t v = CopyNumber<int64_t>(value);
|
|
941
1103
|
out_reg->x0 = (uint64_t)v;
|
|
942
1104
|
} break;
|
|
1105
|
+
case PrimitiveKind::Int16S:
|
|
1106
|
+
case PrimitiveKind::UInt16S:
|
|
1107
|
+
case PrimitiveKind::Int32S:
|
|
1108
|
+
case PrimitiveKind::UInt32S:
|
|
1109
|
+
case PrimitiveKind::Int64S: {
|
|
1110
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1111
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
int64_t v = CopyNumber<int64_t>(value);
|
|
1116
|
+
out_reg->x0 = (uint64_t)ReverseBytes(v);
|
|
1117
|
+
} break;
|
|
1118
|
+
case PrimitiveKind::UInt64: {
|
|
1119
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1120
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1125
|
+
out_reg->x0 = v;
|
|
1126
|
+
} break;
|
|
1127
|
+
case PrimitiveKind::UInt64S: {
|
|
1128
|
+
if (RG_UNLIKELY(!value.IsNumber() && !value.IsBigInt())) {
|
|
1129
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for return value, expected number", GetValueType(instance, value));
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
uint64_t v = CopyNumber<uint64_t>(value);
|
|
1134
|
+
out_reg->x0 = ReverseBytes(v);
|
|
1135
|
+
} break;
|
|
943
1136
|
case PrimitiveKind::String: {
|
|
944
1137
|
const char *str;
|
|
945
1138
|
if (RG_LIKELY(value.IsString())) {
|