Commit 419972da authored by Jérémy Lal's avatar Jérémy Lal

Imported Upstream version 1.3.0

parent 53fd9054
......@@ -4,13 +4,8 @@
NODE_VERSIONS="\
master \
v0.11.13 \
v0.11.10 \
v0.11.9 \
v0.11.8 \
v0.11.7 \
v0.11.6 \
v0.11.5 \
v0.11.4 \
v0.10.30 \
v0.10.29 \
v0.10.28 \
v0.10.26 \
v0.10.25 \
......@@ -20,18 +15,16 @@ NODE_VERSIONS="\
v0.10.21 \
v0.10.20 \
v0.10.19 \
v0.10.18 \
v0.8.28 \
v0.8.27 \
v0.8.26 \
v0.8.25 \
v0.8.24 \
v0.8.23 \
v0.8.22 \
"
OUTPUT_PREFIX="nan-"
TEST_CMD="\
cd /dnt/test/ && \
npm install && \
node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild && \
node_modules/.bin/tap --gc js/*-test.js; \
TEST_CMD=" \
cd /dnt/ && \
npm install && \
node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild --directory test && \
node_modules/.bin/tap --gc test/js/*-test.js \
"
language: node_js
env:
- NODE_VERSION="0.6"
- NODE_VERSION="0.8"
- NODE_VERSION="0.10.25"
- NODE_VERSION="0.10.26"
- NODE_VERSION="0.10.27"
- NODE_VERSION="0.10.28"
- NODE_VERSION="0.10.29"
- NODE_VERSION="0.10.30"
- NODE_VERSION="0.11.13"
node_js:
- "0.10"
......@@ -13,12 +12,15 @@ notifications:
email:
- rod@vagg.org
before_install:
- npm install npm
- mv node_modules npm
- npm/.bin/npm --version
- npm/.bin/npm install
- rm -rf ~/.nvm
- curl https://raw.github.com/creationix/nvm/master/install.sh | sh
- git clone https://github.com/creationix/nvm.git ~/.nvm
- source ~/.nvm/nvm.sh
- nvm install $NODE_VERSION
- node --version
- npm --version
- cd test
- npm install
script: npm test
- node_modules/.bin/node-gyp rebuild --directory test
install:
script: tap --gc test/js/*-test.js
# NAN ChangeLog
### Version 1.3.0: current Node unstable: 0.11.13, Node stable: 0.10.30
**1.3.0 Aug 2 2014**
- Added NanNew<v8::String, std::string>(std::string)
- Added NanNew<v8::String, std::string&>(std::string&)
- Added NanAsciiString helper class
- Added NanUtf8String helper class
- Added NanUcs2String helper class
- Deprecated NanRawString()
- Deprecated NanCString()
- Added NanGetIsolateData(v8::Isolate *isolate)
- Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value>* argv)
- Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::String> symbol, int argc, v8::Handle<v8::Value>* argv)
- Added NanMakeCallback(v8::Handle<v8::Object> target, const char* method, int argc, v8::Handle<v8::Value>* argv)
- Added NanSetTemplate(v8::Handle<v8::Template> templ, v8::Handle<v8::String> name , v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
- Added NanSetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
- Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, const char *name, v8::Handle<v8::Data> value)
- Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
**1.2.0 Jun 5 2014**
- Add NanSetPrototypeTemplate
- Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class,
introduced _NanWeakCallbackDispatcher
- Removed -Wno-unused-local-typedefs from test builds
- Made test builds Windows compatible ('Sleep()')
**1.1.2 May 28 2014**
- Release to fix more stuff-ups in 1.1.1
**1.1.1 May 28 2014**
- Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0
**1.1.0 May 25 2014**
- Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead
- Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]),
(uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*,
v8::String::ExternalAsciiStringResource*
- Deprecate NanSymbol()
- Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker
**1.0.0 May 4 2014**
- Heavy API changes for V8 3.25 / Node 0.11.13
- Use cpplint.py
- Removed NanInitPersistent
- Removed NanPersistentToLocal
- Removed NanFromV8String
- Removed NanMakeWeak
- Removed NanNewLocal
- Removed NAN_WEAK_CALLBACK_OBJECT
- Removed NAN_WEAK_CALLBACK_DATA
- Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions
- Introduce NanUndefined, NanNull, NanTrue and NanFalse
- Introduce NanEscapableScope and NanEscapeScope
- Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node)
- Introduce NanMakeCallback for node::MakeCallback
- Introduce NanSetTemplate
- Introduce NanGetCurrentContext
- Introduce NanCompileScript and NanRunScript
- Introduce NanAdjustExternalMemory
- Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback
- Introduce NanGetHeapStatistics
- Rename NanAsyncWorker#SavePersistent() to SaveToPersistent()
**0.8.0 Jan 9 2014**
- NanDispose -> NanDisposePersistent, deprecate NanDispose
- Extract _NAN_*_RETURN_TYPE, pull up NAN_*()
**0.7.1 Jan 9 2014**
- Fixes to work against debug builds of Node
- Safer NanPersistentToLocal (avoid reinterpret_cast)
- Speed up common NanRawString case by only extracting flattened string when necessary
**0.7.0 Dec 17 2013**
- New no-arg form of NanCallback() constructor.
- NanCallback#Call takes Handle rather than Local
- Removed deprecated NanCallback#Run method, use NanCallback#Call instead
- Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS
- Restore (unofficial) Node 0.6 compatibility at NanCallback#Call()
- Introduce NanRawString() for char* (or appropriate void*) from v8::String
(replacement for NanFromV8String)
- Introduce NanCString() for null-terminated char* from v8::String
**0.6.0 Nov 21 2013**
- Introduce NanNewLocal<T>(v8::Handle<T> value) for use in place of
v8::Local<T>::New(...) since v8 started requiring isolate in Node 0.11.9
**0.5.2 Nov 16 2013**
- Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public
**0.5.1 Nov 12 2013**
- Use node::MakeCallback() instead of direct v8::Function::Call()
**0.5.0 Nov 11 2013**
- Added @TooTallNate as collaborator
- New, much simpler, "include_dirs" for binding.gyp
- Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros
**0.4.4 Nov 2 2013**
- Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+
**0.4.3 Nov 2 2013**
- Include node_object_wrap.h, removed from node.h for Node 0.11.8.
**0.4.2 Nov 2 2013**
- Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for
Node 0.11.8 release.
**0.4.1 Sep 16 2013**
- Added explicit `#include <uv.h>` as it was removed from node.h for v0.11.8
**0.4.0 Sep 2 2013**
- Added NAN_INLINE and NAN_DEPRECATED and made use of them
- Added NanError, NanTypeError and NanRangeError
- Cleaned up code
**0.3.2 Aug 30 2013**
- Fix missing scope declaration in GetFromPersistent() and SaveToPersistent
in NanAsyncWorker
**0.3.1 Aug 20 2013**
- fix "not all control paths return a value" compile warning on some platforms
**0.3.0 Aug 19 2013**
- Made NAN work with NPM
- Lots of fixes to NanFromV8String, pulling in features from new Node core
- Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API
- Added optional error number argument for NanThrowError()
- Added NanInitPersistent()
- Added NanReturnNull() and NanReturnEmptyString()
- Added NanLocker and NanUnlocker
- Added missing scopes
- Made sure to clear disposed Persistent handles
- Changed NanAsyncWorker to allocate error messages on the heap
- Changed NanThrowError(Local<Value>) to NanThrowError(Handle<Value>)
- Fixed leak in NanAsyncWorker when errmsg is used
**0.2.2 Aug 5 2013**
- Fixed usage of undefined variable with node::BASE64 in NanFromV8String()
**0.2.1 Aug 5 2013**
- Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for
NanFromV8String()
**0.2.0 Aug 5 2013**
- Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR,
NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY
- Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS,
_NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS,
_NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS,
_NAN_PROPERTY_QUERY_ARGS
- Added NanGetInternalFieldPointer, NanSetInternalFieldPointer
- Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT,
NAN_WEAK_CALLBACK_DATA, NanMakeWeak
- Renamed THROW_ERROR to _NAN_THROW_ERROR
- Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*)
- Added NanBufferUse(char*, uint32_t)
- Added NanNewContextHandle(v8::ExtensionConfiguration*,
v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
- Fixed broken NanCallback#GetFunction()
- Added optional encoding and size arguments to NanFromV8String()
- Added NanGetPointerSafe() and NanSetPointerSafe()
- Added initial test suite (to be expanded)
- Allow NanUInt32OptionValue to convert any Number object
**0.1.0 Jul 21 2013**
- Added `NAN_GETTER`, `NAN_SETTER`
- Added `NanThrowError` with single Local<Value> argument
- Added `NanNewBufferHandle` with single uint32_t argument
- Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)`
- Added `Local<Function> NanCallback#GetFunction()`
- Added `NanCallback#Call(int, Local<Value>[])`
- Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call
This diff is collapsed.
# http://www.appveyor.com/docs/appveyor-yml
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "0.8"
- nodejs_version: "0.10"
- nodejs_version: "0.11"
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node 0.STABLE.latest
- npm install npm
- move node_modules npm
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
# Typical npm stuff.
- npm/.bin/npm install
- npm/.bin/npm run rebuild-tests
# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
- cmd: npm test
# Don't actually build.
build: off
# Set build version format here instead of in the admin panel.
version: "{build}"
......@@ -22,17 +22,34 @@ See https://en.wikipedia.org/wiki/File:Pi_30K.gif
for a visualization of how this works.
*/
inline int randall(unsigned int *p_seed) {
// windows has thread safe rand()
#ifdef _WIN32
return rand(); // NOLINT(runtime/threadsafe_fn)
#else
return rand_r(p_seed);
#endif
}
double Estimate (int points) {
int i = points;
int inside = 0;
unsigned int randseed = 1;
#ifdef _WIN32
srand(randseed);
#endif
// unique seed for each run, for threaded use
unsigned int seed = rand_r(&randseed);
unsigned int seed = randall(&randseed);
#ifdef _WIN32
srand(seed);
#endif
while (i-- > 0) {
// rand_r() is used to avoid thread locking
double x = rand_r(&seed) / static_cast<double>(RAND_MAX);
double y = rand_r(&seed) / static_cast<double>(RAND_MAX);
double x = randall(&seed) / static_cast<double>(RAND_MAX);
double y = randall(&seed) / static_cast<double>(RAND_MAX);
// x & y and now values between 0 and 1
// now do a pythagorean diagonal calculation
......
This diff is collapsed.
{
"name": "nan",
"version": "1.2.0",
"version": "1.3.0",
"description": "Native Abstractions for Node.js: C++ header for Node 0.8->0.12 compatibility",
"main": "include_dirs.js",
"repository": {
"type": "git",
"url": "git://github.com/rvagg/nan.git"
},
"scripts": {
"test": "tap --gc test/js/*-test.js",
"rebuild-tests": "node-gyp rebuild --directory test"
},
"contributors": [
"Rod Vagg <r@va.gg> (https://github.com/rvagg)",
"Benjamin Byholm <bbyholm@abo.fi> (https://github.com/kkoopa/)",
......@@ -15,5 +19,11 @@
"Brett Lawson <brett19@gmail.com> (https://github.com/brett19)",
"Ben Noordhuis <info@bnoordhuis.nl> (https://github.com/bnoordhuis)"
],
"devDependencies": {
"bindings": "~1.2.1",
"node-gyp": "~1.0.1",
"tap": "~0.4.12",
"xtend": "~4.0.0"
},
"license": "MIT"
}
......@@ -117,4 +117,18 @@
"<!(node -e \"require('..')\")"
]
}
, {
"target_name" : "makecallback"
, "sources" : [ "cpp/makecallback.cpp" ]
, "include_dirs": [
"<!(node -e \"require('..')\")"
]
}
, {
"target_name" : "isolatedata"
, "sources" : [ "cpp/isolatedata.cpp" ]
, "include_dirs": [
"<!(node -e \"require('..')\")"
]
}
]}
/**********************************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2014 NAN contributors
*
* MIT +no-false-attribs License <https://github.com/rvagg/nan/blob/master/LICENSE>
**********************************************************************************/
#include <nan.h>
struct Dummy {
int value;
};
NAN_METHOD(SetAndGet) {
NanScope();
Dummy *d0 = new Dummy;
Dummy *d1 = NULL;
v8::Isolate *isolate = v8::Isolate::GetCurrent();
NanSetIsolateData<Dummy>(isolate, d0);
d1 = NanGetIsolateData<Dummy>(isolate);
delete d1;
NanReturnValue(NanNew<v8::Boolean>(d0 == d1));
}
void Init (v8::Handle<v8::Object> target) {
target->Set(
NanNew<v8::String>("setAndGet")
, NanNew<v8::FunctionTemplate>(SetAndGet)->GetFunction()
);
}
NODE_MODULE(isolatedata, Init)
/**********************************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2014 NAN contributors
*
* MIT +no-false-attribs License <https://github.com/rvagg/nan/blob/master/LICENSE>
**********************************************************************************/
#include <nan.h>
class MyObject : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
private:
MyObject();
~MyObject();
static NAN_METHOD(New);
static NAN_METHOD(CallEmit);
static v8::Persistent<v8::Function> constructor;
};
v8::Persistent<v8::Function> MyObject::constructor;
MyObject::MyObject() {
}
MyObject::~MyObject() {
}
void MyObject::Init(v8::Handle<v8::Object> exports) {
NanScope();
// Prepare constructor template
v8::Local<v8::FunctionTemplate> tpl = NanNew<v8::FunctionTemplate>(New);
tpl->SetClassName(NanNew<v8::String>("MyObject"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_PROTOTYPE_METHOD(tpl, "call_emit", CallEmit);
NanAssignPersistent<v8::Function>(constructor, tpl->GetFunction());
exports->Set(NanNew<v8::String>("MyObject"), tpl->GetFunction());
}
NAN_METHOD(MyObject::New) {
NanScope();
if (args.IsConstructCall()) {
MyObject* obj = new MyObject();
obj->Wrap(args.This());
NanReturnValue(args.This());
}
else {
v8::Local<v8::Function> cons = NanNew<v8::Function>(constructor);
NanReturnValue(cons->NewInstance());
}
}
NAN_METHOD(MyObject::CallEmit) {
NanScope();
v8::Handle<v8::Value> argv[1] = {
NanNew("event"), // event name
};
NanMakeCallback(args.This(), "emit", 1, argv);
NanReturnUndefined();
}
void Init(v8::Handle<v8::Object> exports) {
MyObject::Init(exports);
}
NODE_MODULE(makecallback, Init)
......@@ -10,8 +10,6 @@
NAN_METHOD(ReturnString) {
NanScope();
char *buf = NanCString(args[0], NULL);
v8::Local<v8::String> s = NanNew<v8::String>(buf);
delete[] buf;
v8::Local<v8::String> s = NanNew<v8::String>(*NanUtf8String(args[0]));
NanReturnValue(s);
}
......@@ -7,6 +7,7 @@
**********************************************************************************/
#include <nan.h>
#include <string>
static int magic = 1337;
......@@ -59,7 +60,13 @@ NAN_METHOD(NewLatin1String) {
NAN_METHOD(NewUcs2String) {
NanScope();
uint16_t s[] = {'s', 't', 'r', 0xef, 'n', 'g', '\0'};
const uint16_t s[] = {'s', 't', 'r', 0xef, 'n', 'g', '\0'};
NanReturnValue(NanNew(s));
}
NAN_METHOD(NewStdString) {
NanScope();
const std::string s = "strïng";
NanReturnValue(NanNew<v8::String>(s));
}
......@@ -178,6 +185,10 @@ void Init(v8::Handle<v8::Object> target) {
NanNew<v8::String>("newUcs2String")
, NanNew<v8::FunctionTemplate>(NewUcs2String)->GetFunction()
);
target->Set(
NanNew<v8::String>("newStdString")
, NanNew<v8::FunctionTemplate>(NewStdString)->GetFunction()
);
target->Set(
NanNew<v8::String>("newRegExp")
, NanNew<v8::FunctionTemplate>(NewRegExp)->GetFunction()
......
......@@ -37,7 +37,14 @@ void MyObject::Init(v8::Handle<v8::Object> exports) {
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
NanSetPrototypeTemplate(tpl, "test", NanNew<v8::String>("a prototype property"));
NanSetPrototypeTemplate(tpl, "prototypeProp", NanNew<v8::String>("a prototype property"));
// Instance
NanSetInstanceTemplate(tpl, "instanceProp", NanNew<v8::String>("an instance property"));
// PropertyAttributes
NanSetInstanceTemplate(tpl, NanNew<v8::String>("none"), NanNew<v8::String>("none"), v8::None);
NanSetInstanceTemplate(tpl, NanNew<v8::String>("readOnly"), NanNew<v8::String>("readOnly"), v8::ReadOnly);
NanSetInstanceTemplate(tpl, NanNew<v8::String>("dontEnum"), NanNew<v8::String>("dontEnum"), v8::DontEnum);
NanSetInstanceTemplate(tpl, NanNew<v8::String>("dontDelete"), NanNew<v8::String>("dontDelete"), v8::DontDelete);
NanAssignPersistent<v8::Function>(constructor, tpl->GetFunction());
exports->Set(NanNew<v8::String>("MyObject"), tpl->GetFunction());
......
......@@ -7,7 +7,7 @@
**********************************************************************************/
#include <nan.h>
#include <string>
#include <cstring>
class SetterGetter : public node::ObjectWrap {
public:
......@@ -21,9 +21,9 @@ class SetterGetter : public node::ObjectWrap {
SetterGetter();
std::string log;
std::string prop1;
std::string prop2;
char log[1024];
char prop1[256];
char prop2[256];
};
static v8::Persistent<v8::FunctionTemplate> settergetter_constructor;
......@@ -34,7 +34,10 @@ NAN_METHOD(CreateNew) {
}
SetterGetter::SetterGetter() {
prop1.assign("this is property 1");
log[0] = '\0';
strncpy(prop1, "this is property 1", sizeof (prop1) - 1);
prop1[sizeof (prop1) - 1] = '\0';
prop2[0] = '\0';
}
void SetterGetter::Init(v8::Handle<v8::Object> target) {
......@@ -69,7 +72,11 @@ NAN_METHOD(SetterGetter::New) {
NanScope();
SetterGetter* settergetter = new SetterGetter();
settergetter->log.append("New()\n");
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, "New()\n"
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
settergetter->Wrap(args.This());
NanReturnValue(args.This());
......@@ -80,11 +87,23 @@ NAN_GETTER(SetterGetter::GetProp1) {
SetterGetter* settergetter =
node::ObjectWrap::Unwrap<SetterGetter>(args.This());
settergetter->log.append("Prop1:GETTER(");
settergetter->log.append(settergetter->prop1);
settergetter->log.append(")\n");
NanReturnValue(NanNew<v8::String>(settergetter->prop1.c_str()));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, "Prop1:GETTER("
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, settergetter->prop1
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, ")\n"
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
NanReturnValue(NanNew(settergetter->prop1));
}
NAN_GETTER(SetterGetter::GetProp2) {
......@@ -92,22 +111,50 @@ NAN_GETTER(SetterGetter::GetProp2) {
SetterGetter* settergetter =
node::ObjectWrap::Unwrap<SetterGetter>(args.This());
settergetter->log.append("Prop2:GETTER(");
settergetter->log.append(settergetter->prop2);
settergetter->log.append(")\n");
NanReturnValue(NanNew<v8::String>(settergetter->prop2.c_str()));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, "Prop2:GETTER("
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, settergetter->prop2
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, ")\n"
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
NanReturnValue(NanNew(settergetter->prop2));
}
NAN_SETTER(SetterGetter::SetProp2) {
NanScope();
SetterGetter* settergetter =
node::ObjectWrap::Unwrap<SetterGetter>(args.This());
settergetter->prop2.assign(NanCString(value, NULL));
settergetter->log.append("Prop2:SETTER(");
settergetter->log.append(settergetter->prop2);
settergetter->log.append(")\n");
node::ObjectWrap::Unwrap<SetterGetter>(args.This());
strncpy(
settergetter->prop2
, *NanUtf8String(value)
, sizeof (settergetter->prop2));
settergetter->prop2[sizeof (settergetter->prop2) - 1] = '\0';
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, "Prop2:SETTER("
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, settergetter->prop2
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
assert(strlen(settergetter->log) < sizeof (settergetter->log));
strncat(
settergetter->log
, ")\n"
, sizeof (settergetter->log) - 1 - strlen(settergetter->log));
}
NAN_METHOD(SetterGetter::Log) {
......@@ -116,7 +163,7 @@ NAN_METHOD(SetterGetter::Log) {
SetterGetter* settergetter =
node::ObjectWrap::Unwrap<SetterGetter>(args.This());
NanReturnValue(NanNew<v8::String>(settergetter->log.c_str()));
NanReturnValue(NanNew(settergetter->log));
}
NODE_MODULE(settergetter, SetterGetter::Init)
......@@ -8,165 +8,87 @@
#include <nan.h>
NAN_METHOD(ReturnString) {
NAN_METHOD(ReturnAsciiString) {
NanScope();
Nan::Encoding enc = Nan::UTF8;
size_t bc;
int flags = v8::String::HINT_MANY_WRITES_EXPECTED
| v8::String::NO_NULL_TERMINATION;
if (args[1]->IsUint32()) {
enc = (Nan::Encoding</