Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosuke-furukawa/10090089 to your computer and use it in GitHub Desktop.
Save yosuke-furukawa/10090089 to your computer and use it in GitHub Desktop.
#include <node.h>
#include <nan.h>

using namespace v8;

NAN_METHOD(Method) {
  NanScope();

  v8::Handle<v8::Object> buffer = args[0]->ToObject();  
  bool hasIndexed = buffer->HasIndexedPropertiesInExternalArrayData();

  // print buffer has indexed properties or not.
  printf("hasINDEXED = %d\n", hasIndexed);
  NanReturnValue(NanSymbol("world"));
}

void init(Handle<Object> exports) {
  exports->Set(NanSymbol("hello"),
      FunctionTemplate::New(Method)->GetFunction());
}

NODE_MODULE(addon, init)
var addon = require('./build/Release/addon');

var f64a = new Uint32Array(8);

// hasIndexed is true in v0.11, v0.10
addon.hello(f64a);

// hasIndexed is false in v0.11, but v0.10 is true...
// addon.hello(f64a.buffer);

module.exports = addon;
@yosuke-furukawa
Copy link
Author

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