nodejs / nodejs/nan

tools/1to2.js fails to generate proper source

Open
#441 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
3.4k
Forks
531
Avg merge
21m
Merged PRs (30d)
1

Description

I'm using NAN-1 with https://github.com/Gottox/child_pty. In https://github.com/Gottox/child_pty/issues/7 it came up, that NAN-2 breaks the build process.

I tried to use the 1to2.js script, but it generates wrong constructs, such as:

-               if(obj->Has(columns))
-                       w->ws_col = obj->Get(columns)->Uint32Value();
-               if(obj->Has(rows))
-                       w->ws_row = obj->Get(rows)->Uint32Value();
+               NanHas(if(obj, columns))
+                       w->ws_col = NanGet(obj, columns)->Uint32Value();
+               NanHas(if(obj, rows))
+                       w->ws_row = NanGet(obj, rows)->Uint32Value();

Furthermore, I'd really like to have a comprehensive migration guide. (https://github.com/nodejs/nan/issues/402)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tools/1to2.js and reproduce the conversion using the NAN-1 example shown in the issue. Check that Has and Get expressions preserve the object and property arguments without inserting if into NanHas; the generated source should match the intended NAN-2 constructs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.