Skip to content

Tweaks to API suggested on EPS #25

Description

@mhdawson
  • Version: All
  • Platform: ALL
  • Subsystem: API

Suggestions from Ben on nodejs/node-eps#20 (comment)

  1. 00X-ABI-Stable-Module-API.md
+
+### Types
+```C
+typedef struct napi_env__ *napi_env;
@bnoordhuis
bnoordhuis 5 hours ago Node.js Foundation member

Using typedef'd pointers has the issue that they will silently decay to void* when used in a void* context. Can be avoided by wrapping the pointer in a struct, like so:

typedef struct napi_value { struct napi_value *v; } napi_value;

  1. 00X-ABI-Stable-Module-API.md
+
+struct napi_method_descriptor {
+  napi_callback callback;
+  char* utf8name;
@bnoordhuis
bnoordhuis 5 hours ago Node.js Foundation member

const char*?
  1. 00X-ABI-Stable-Module-API.md
+NODE_EXTERN int napi_get_string_length(napi_env e, napi_value v);
+NODE_EXTERN int napi_get_string_utf8_length(napi_env e, napi_value v);
+NODE_EXTERN int napi_get_string_utf8(napi_env e, napi_value v,
+                                     char* buf, int bufsize);
@bnoordhuis
bnoordhuis 5 hours ago Node.js Foundation member

Why int instead of size_t?

  1. 00X-ABI-Stable-Module-API.md
+// Methods to support error handling
+NODE_EXTERN void napi_throw(napi_env e, napi_value error);
+NODE_EXTERN void napi_throw_error(napi_env e, char* msg);
+NODE_EXTERN void napi_throw_type_error(napi_env e, char* msg);
@bnoordhuis
bnoordhuis 5 hours ago Node.js Foundation member

const char*

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo