Inquiry with file node-addon-examples/5_function_factory/node_0.12/addon.cc

Open
#99 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, node.js
Domain
devtools

Research direction

Start with node-addon-examples/5_function_factory/node_0.12/addon.cc and review how the function factory example supplies its callback. The issue does not define a concrete repository change or a done condition; first determine whether the example or its documentation should explain using a private C++ member function, then identify an appropriate example or documentation test if one exists.

Written by the indexing model from the issue text.

Description

Hi, anyone reading this,

The file node-addon-examples/5_function_factory/node_0.12/addon.cc contains a function factory, that's all well and good, but when I do something similiar, instead of using a global function, I'm using an instance function, (sorry, bad C++ vocab, I'm only new...) a function that's a private member of a class, and I want to use that as the function body, where the example uses

void MyFunction(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = Isolate::GetCurrent();
  HandleScope scope(isolate);
  args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello world"));
}

as the body. The issue is I get an error when doing this, the error is as follows: error C3867: 'Class::SampleFunction': non-standard syntax; use '&' to create a pointer to member and I have no idea what to do about it.

Dominant language
C++
Stars
2.6k
Forks
602
PR merge metrics
No merged PRs in 30d

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.

More from nodejs/node-addon-examples

All issues in nodejs/node-addon-examples

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.