How to cast an array to an string array?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- backend
Research direction
Start by comparing wrapper.cc and index.js with the linked array_buffer_to_native example, focusing on how the N-API array is passed into native code. Check whether the repository contains another string-array example. Done means providing or documenting a working example for the shown char** use case.
Written by the indexing model from the issue text.
Description
I'm trying to wrap a C function that receives a char** as parameter but I can't seem to cast it properly. Do I have to iterate over the array and recreate an array on c? I was following this array buffer to native example but I'm stuck. Can someone give me a hint or point me to an example that uses strings and array?
// index.js
const addon = require('./node/addon')
addon.start(4, [
'-in',
'str1',
'-out',
'str3'
])
// wrapper.cc
Napi::Value start(const Napi::CallbackInfo &info)
{
Napi::Env env = info.Env();
Napi::Number bufferSize = info[0].As<Napi::Number>();
Napi::Array buffer = info[1].As<Napi::Array>();
// how would you make this work?
char **stringArray= reinterpret_cast<char **>(buffer);
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 602
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodejs/node-addon-examples
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 38/100
nodejs/node-addon-examples#585 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
nodejs/node-addon-examples#530 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
nodejs/node-addon-examples#445 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 32/100
nodejs/node-addon-examples#444 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
nodejs/node-addon-examples#381 ·
All issues in nodejs/node-addon-examples
Similar issues
-
Website Doc Typo Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
autowarefoundation/autoware_universe#13413 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
automated-analysis bug memory-safety
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100