Skip to content
This repository was archived by the owner on Jul 25, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/nanCxxImplMethod.def
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ var argStr = args.join(', ');
{{?? isArray(method.idlType) }}
auto value = myself->impl_->{{=methodName}}({{=argStr}});
info.GetReturnValue().Set(static_cast<v8::Local<v8::Array>>(value));
{{?? method.idlType.idlType === 'long long' || method.idlType.idlType === 'unsigned long long' }}
// Primitive types (int, double ...)
auto value = {{=functionCallPrefix}}{{=methodName}}({{=argStr}});
info.GetReturnValue().Set(Nan::New<v8::Number>(value));
{{?? true }}
// Primitive types (int, double ...)
auto value = {{=functionCallPrefix}}{{=methodName}}({{=argStr}});
Expand Down
2 changes: 2 additions & 0 deletions templates/nanCxxImplProperty.def
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ NAN_GETTER({{=className}}::{{=p.name}}Getter) {
} else {
info.GetReturnValue().Set(Nan::Undefined());
}
{{?? p.idlType.idlType === 'long long' || p.idlType.idlType === 'unsigned long long' }}
info.GetReturnValue().Set(Nan::New<v8::Number>(impl_val){{=str}});
{{?? true}}
info.GetReturnValue().Set(Nan::New(impl_val){{=str}});
{{?}}
Expand Down
2 changes: 2 additions & 0 deletions test/primitives/primitives-attributes.widl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ interface PrimitivesAttributes {
attribute unrestricted float vUnrestrictFloat;
attribute double vDouble;
attribute unrestricted double vUnrestrictDouble;
attribute long long vLongLong;
attribute unsigned long long vUnsignedLongLong;
};
2 changes: 2 additions & 0 deletions test/primitives/primitives-param.widl
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ interface PrimitivesParam {
unsigned long addUnsignedLong(unsigned long a, unsigned long b);
DOMString show(DOMString str);
void setvalue(boolean flag,float f,double d,unrestricted float uf,unrestricted double ud);
long long addLongLong(long long a, long long b);
unsigned long long addUnsignedLongLong(unsigned long long a, unsigned long long b);
};

4 changes: 3 additions & 1 deletion test/primitives/primitives_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ PrimitivesAttributes::PrimitivesAttributes()
vShort_(-32768),
vUnsignedShort_(65535),
vLong_(-200000),
vUnsignedLong_(200000) {
vUnsignedLong_(200000),
vLongLong_(0xffffffffffff),
vUnsignedLongLong_(0xffffffffffff) {
}

PrimitivesAttributes::~PrimitivesAttributes() {
Expand Down
28 changes: 28 additions & 0 deletions test/primitives/primitives_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#include <string>

#include "gen/generator_helper.h"
#include "gen/array_helper.h"

class PrimitivesAttributes {
public:
PrimitivesAttributes();

PrimitivesAttributes(const PrimitivesAttributes& rhs);

~PrimitivesAttributes();

PrimitivesAttributes& operator = (const PrimitivesAttributes& rhs);
Expand Down Expand Up @@ -116,6 +119,27 @@ class PrimitivesAttributes {
this->vUnrestrictDouble_ = new_value;
}

int64_t get_vLongLong() const {
return this->vLongLong_;
}

void set_vLongLong(const int64_t& new_value) {
this->vLongLong_ = new_value;
}

uint64_t get_vUnsignedLongLong() const {
return this->vUnsignedLongLong_;
}

void set_vUnsignedLongLong(const uint64_t& new_value) {
this->vUnsignedLongLong_ = new_value;
}

void SetJavaScriptThis(v8::Local<v8::Object> obj) {
// Ignore this if you don't need it
// Typical usage: emit an event on `obj`
}

private:
int8_t vByte_;

Expand All @@ -138,6 +162,10 @@ class PrimitivesAttributes {
double vDouble_;

double vUnrestrictDouble_;

int64_t vLongLong_;

uint64_t vUnsignedLongLong_;
};

#endif // _PRIMITIVESATTRIBUTES_H_
15 changes: 15 additions & 0 deletions test/primitives/primitives_param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
#include "primitives_param.h"

PrimitivesParam::PrimitivesParam() {
// TODO(widl-nan): init your members
}

PrimitivesParam::PrimitivesParam(const PrimitivesParam& rhs) {
// TODO(widl-nan): copy from rhs if you want this behavior
// Or mark ctor = delete in primitives_param.h
}

PrimitivesParam::~PrimitivesParam() {
// TODO(widl-nan): do cleanup if necessary
}

PrimitivesParam& PrimitivesParam::operator =
Expand Down Expand Up @@ -58,3 +65,11 @@ const double& d, const double& uf, const double& ud) {
vUnrestrictDouble_ = ud;
}

int64_t PrimitivesParam::addLongLong(const int64_t& a, const int64_t& b) {
return a + b;
}

uint64_t PrimitivesParam::addUnsignedLongLong(
const uint64_t& a, const uint64_t& b) {
return a + b;
}
7 changes: 7 additions & 0 deletions test/primitives/primitives_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
#include <string>

#include "gen/generator_helper.h"
#include "gen/array_helper.h"

class PrimitivesParam {
public:
PrimitivesParam();

PrimitivesParam(const PrimitivesParam& rhs);

~PrimitivesParam();

PrimitivesParam& operator = (const PrimitivesParam& rhs);
Expand Down Expand Up @@ -85,6 +88,10 @@ class PrimitivesParam {
void setvalue(const bool& flag, const double& f, const double& d,
const double& uf, const double& ud);

int64_t addLongLong(const int64_t& a, const int64_t& b);

uint64_t addUnsignedLongLong(const uint64_t& a, const uint64_t& b);

private:
bool vBoolean_;

Expand Down
3 changes: 3 additions & 0 deletions test/test-primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ describe('widl-nan Unit Test - primitives', function() {
assert.equal(x.vShort, -32768);
assert.equal(x.vUnsignedShort, 65535);
assert.equal(x.vLong, -200000);
assert.equal(x.vLongLong, 281474976710655);
assert.equal(x.vUnsignedLong, 200000);

assert.equal(typeof x.vBoolean, 'boolean');
assert.equal(typeof x.vFloat, 'number');
assert.equal(typeof x.vDouble, 'number');
assert.equal(typeof x.vUnrestrictFloat, 'number');
assert.equal(typeof x.vUnrestrictDouble, 'number');
assert.equal(typeof x.vLongLong, 'number');

x.vBoolean = true;
x.vFloat = 1.0;
Expand All @@ -83,6 +85,7 @@ describe('widl-nan Unit Test - primitives', function() {
assert.equal(y.addShort(-150, -2000), -2150);
assert.equal(y.addUnsignedShort(200, 3000), 3200);
assert.equal(y.addLong(-100000, -30000), -130000);
assert.equal(y.addLongLong(1, 281474976710655), 281474976710656);
assert.equal(y.addUnsignedLong(120000, 240000), 360000);
assert.equal(y.show('DOMString'), 'DOMString');

Expand Down