koffi 2.12.5-beta.1 → 2.12.5-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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -123,7 +123,7 @@ node qemu.js info debian_x64
123
123
 
124
124
  First, you must update the code in three steps:
125
125
 
126
- - Change the version numbers in `package.json` (version and stable for stable releases)
126
+ - Change the version number in `package.json`
127
127
  - Add an entry to `CHANGELOG` to summarize the changes since last release
128
128
  - Commit theses changes with the message *Bump Koffi to X.Y.Z*
129
129
 
package/index.d.ts CHANGED
@@ -119,9 +119,13 @@ export function disposable(name: string | null | undefined, type: TypeSpec): IKo
119
119
  export function disposable(name: string | null | undefined, type: TypeSpec, freeFunction: Function): IKoffiCType;
120
120
 
121
121
  export function proto(definition: string): IKoffiCType;
122
+ export function proto(result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
123
+ export function proto(convention: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
122
124
  export function proto(name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
123
125
  export function proto(convention: string, name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
124
126
  /** @deprecated */ export function callback(definition: string): IKoffiCType;
127
+ /** @deprecated */ export function callback(result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
128
+ /** @deprecated */ export function callback(convention: string, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
125
129
  /** @deprecated */ export function callback(name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
126
130
  /** @deprecated */ export function callback(convention: string, name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): IKoffiCType;
127
131
 
package/index.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod3) => function __require() {
4
4
  return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
5
5
  };
6
6
 
7
- // package/src/cnoke/src/tools.js
7
+ // bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "package/src/cnoke/src/tools.js"(exports2, module2) {
9
+ "bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
10
10
  "use strict";
11
11
  var crypto = require("crypto");
12
12
  var fs2 = require("fs");
@@ -397,13 +397,12 @@ var require_tools = __commonJS({
397
397
  }
398
398
  });
399
399
 
400
- // package/src/koffi/package.json
400
+ // bin/Koffi/package/src/koffi/package.json
401
401
  var require_package = __commonJS({
402
- "package/src/koffi/package.json"(exports2, module2) {
402
+ "bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
403
403
  module2.exports = {
404
404
  name: "koffi",
405
- version: "2.12.5-beta.1",
406
- stable: "2.12.4",
405
+ version: "2.12.5-beta.2",
407
406
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
408
407
  keywords: [
409
408
  "foreign",
@@ -444,9 +443,9 @@ var require_package = __commonJS({
444
443
  }
445
444
  });
446
445
 
447
- // package/src/koffi/src/init.js
446
+ // bin/Koffi/package/src/koffi/src/init.js
448
447
  var require_init = __commonJS({
449
- "package/src/koffi/src/init.js"(exports, module) {
448
+ "bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
450
449
  var fs = require("fs");
451
450
  var path = require("path");
452
451
  var util = require("util");
@@ -529,7 +528,7 @@ var require_init = __commonJS({
529
528
  }
530
529
  });
531
530
 
532
- // package/src/koffi/index.js
531
+ // bin/Koffi/package/src/koffi/index.js
533
532
  var { detect: detect2, init: init2 } = require_init();
534
533
  var triplet2 = detect2();
535
534
  var native2 = null;
package/indirect.js CHANGED
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod3) => function __require() {
4
4
  return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports;
5
5
  };
6
6
 
7
- // package/src/cnoke/src/tools.js
7
+ // bin/Koffi/package/src/cnoke/src/tools.js
8
8
  var require_tools = __commonJS({
9
- "package/src/cnoke/src/tools.js"(exports2, module2) {
9
+ "bin/Koffi/package/src/cnoke/src/tools.js"(exports2, module2) {
10
10
  "use strict";
11
11
  var crypto = require("crypto");
12
12
  var fs2 = require("fs");
@@ -397,13 +397,12 @@ var require_tools = __commonJS({
397
397
  }
398
398
  });
399
399
 
400
- // package/src/koffi/package.json
400
+ // bin/Koffi/package/src/koffi/package.json
401
401
  var require_package = __commonJS({
402
- "package/src/koffi/package.json"(exports2, module2) {
402
+ "bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
403
403
  module2.exports = {
404
404
  name: "koffi",
405
- version: "2.12.5-beta.1",
406
- stable: "2.12.4",
405
+ version: "2.12.5-beta.2",
407
406
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
408
407
  keywords: [
409
408
  "foreign",
@@ -444,9 +443,9 @@ var require_package = __commonJS({
444
443
  }
445
444
  });
446
445
 
447
- // package/src/koffi/src/init.js
446
+ // bin/Koffi/package/src/koffi/src/init.js
448
447
  var require_init = __commonJS({
449
- "package/src/koffi/src/init.js"(exports, module) {
448
+ "bin/Koffi/package/src/koffi/src/init.js"(exports, module) {
450
449
  var fs = require("fs");
451
450
  var path = require("path");
452
451
  var util = require("util");
@@ -529,7 +528,7 @@ var require_init = __commonJS({
529
528
  }
530
529
  });
531
530
 
532
- // package/src/koffi/indirect.js
531
+ // bin/Koffi/package/src/koffi/indirect.js
533
532
  var { detect: detect2, init: init2 } = require_init();
534
533
  var triplet2 = detect2();
535
534
  var mod2 = init2(triplet2, null);
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.12.5-beta.1",
4
- "stable": "2.12.4",
3
+ "version": "2.12.5-beta.2",
5
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
5
  "keywords": [
7
6
  "foreign",
@@ -995,6 +995,8 @@ static Napi::Value CreateArrayType(const Napi::CallbackInfo &info)
995
995
 
996
996
  static bool ParseClassicFunction(const Napi::CallbackInfo &info, bool concrete, FunctionInfo *out_func)
997
997
  {
998
+ RG_ASSERT(info.Length() >= 2);
999
+
998
1000
  Napi::Env env = info.Env();
999
1001
  InstanceData *instance = env.GetInstanceData<InstanceData>();
1000
1002
 
@@ -1004,17 +1006,22 @@ static bool ParseClassicFunction(const Napi::CallbackInfo &info, bool concrete,
1004
1006
 
1005
1007
  // Detect optional call convention
1006
1008
  if (name.IsString() && DetectCallConvention(name.Utf8Value().c_str(), &out_func->convention)) {
1007
- if (info.Length() < 4) {
1008
- ThrowError<Napi::TypeError>(env, "Expected 4 arguments, got %1", info.Length());
1009
+ if (info.Length() < 3) {
1010
+ ThrowError<Napi::TypeError>(env, "Expected 3 or 4 arguments, got %1", info.Length());
1009
1011
  return false;
1010
1012
  }
1011
1013
 
1012
1014
  name = info[1u].As<Napi::String>();
1013
1015
  ret = info[2u];
1014
- parameters = info[3u].As<Napi::Array>();
1016
+ parameters = (info.Length() >= 4 ? info[3u] : env.Null()).As<Napi::Array>();
1015
1017
  }
1016
1018
 
1017
- bool named = true;
1019
+ bool named = parameters.IsArray();
1020
+
1021
+ if (!named) {
1022
+ parameters = ret.As<Napi::Array>();
1023
+ ret = name;
1024
+ }
1018
1025
 
1019
1026
  #if defined(_WIN32)
1020
1027
  if (name.IsNumber()) {
@@ -1096,7 +1103,7 @@ static Napi::Value CreateFunctionType(const Napi::CallbackInfo &info)
1096
1103
  FunctionInfo *func = instance->callbacks.AppendDefault();
1097
1104
  RG_DEFER_N(err_guard) { instance->callbacks.RemoveLast(1); };
1098
1105
 
1099
- if (info.Length() >= 3) {
1106
+ if (info.Length() >= 2) {
1100
1107
  if (!ParseClassicFunction(info, false, func))
1101
1108
  return env.Null();
1102
1109
  } else if (info.Length() >= 1) {
@@ -1109,7 +1116,7 @@ static Napi::Value CreateFunctionType(const Napi::CallbackInfo &info)
1109
1116
  if (!ParsePrototype(env, proto.c_str(), false, func))
1110
1117
  return env.Null();
1111
1118
  } else {
1112
- ThrowError<Napi::TypeError>(env, "Expected 1 or 3 arguments, got %1", info.Length());
1119
+ ThrowError<Napi::TypeError>(env, "Expected 1 to 4 arguments, got %1", info.Length());
1113
1120
  return env.Null();
1114
1121
  }
1115
1122
 
@@ -1665,7 +1672,7 @@ static Napi::Value FindLibraryFunction(const Napi::CallbackInfo &info)
1665
1672
 
1666
1673
  func->lib = lib->Ref();
1667
1674
 
1668
- if (info.Length() >= 3) {
1675
+ if (info.Length() >= 2) {
1669
1676
  if (!ParseClassicFunction(info, true, func))
1670
1677
  return env.Null();
1671
1678
  } else if (info.Length() >= 1) {
@@ -1678,7 +1685,7 @@ static Napi::Value FindLibraryFunction(const Napi::CallbackInfo &info)
1678
1685
  if (!ParsePrototype(env, proto.c_str(), true, func))
1679
1686
  return env.Null();
1680
1687
  } else {
1681
- ThrowError<Napi::TypeError>(env, "Expected 1 or 3 arguments, got %1", info.Length());
1688
+ ThrowError<Napi::TypeError>(env, "Expected 1 to 4 arguments, got %1", info.Length());
1682
1689
  return env.Null();
1683
1690
  }
1684
1691
 
@@ -49,7 +49,10 @@ bool PrototypeParser::Parse(const char *str, bool concrete, FunctionInfo *out_fu
49
49
  if (IsIdentifier(tokens[offset])) {
50
50
  Span<const char> tok = tokens[offset++];
51
51
  out_func->name = DuplicateString(tok, &instance->str_alloc).ptr;
52
- } else if (concrete) {
52
+ } else if (!concrete) {
53
+ // Leave anonymous naming responsibility to caller
54
+ out_func->name = nullptr;
55
+ } else {
53
56
  MarkError("Unexpected token '%1', expected identifier", tokens[offset]);
54
57
  return false;
55
58
  }