-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for VS2013 #65
Conversation
/cc @jasongin @boingoing |
I'm still investigating test failures that I'm seeing in Travis with node-chakracore, but all other legs complete successfully. |
napi.h
Outdated
#define NAPI_HAS_CONSTEXPR 1 | ||
#endif | ||
|
||
// VS2015 RTM has bugs with constexpr, so require min of VS2015 Update 3 (known good version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this comment to reference the char16_t literal issue.
test/function.cc
Outdated
@@ -62,7 +62,7 @@ Value CallWithVector(const CallbackInfo& info) { | |||
Value CallWithReceiverAndArgs(const CallbackInfo& info) { | |||
Function func = info[0].As<Function>(); | |||
Value receiver = info[1]; | |||
return func.Call(receiver, { info[2], info[3], info[4] }); | |||
return func.Call(receiver, { static_cast<napi_value>(info[2]), static_cast<napi_value>(info[3]), static_cast<napi_value>(info[4]) }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Wrap lines at 100 cols.
(There is no linter set up yet...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there specific guidelines for how to wrap lines? I looked through the existing code and didn't see enough forced wraps to draw solid conclusions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific guidelines.
napi-inl.h
Outdated
napi_status status = napi_create_reference(_env, value, 1, &_ref); | ||
|
||
// TODO - What's the right way to handle errors in the constructor without | ||
// being able to throw exceptions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
napi_fatal_error()
... but it doesn't exist yet. :)
napi-inl.h
Outdated
|
||
napi_value value = other.Value(); | ||
if (value != nullptr) { | ||
napi_status status = napi_create_reference(_env, value, 1, &_ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always creating a strong reference, even if other
was a weak reference. I guess it's OK since this should only ever be called by the Error
class which is always strong. At least add a comment explaining that is the purpose of this constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming tests pass on all targeted compilers/platforms.
@jasongin The CI is clean now, but I'm running into a test failure with VS2013 (now that the tests actually run). I'll pick this up again tomorrow and figure out why the test is failing.
EDIT: It turns out that VS2013 has some behavioral differences from the other compilers with regard to temporary objects created in constructor calls. In this case we take the string, extract the |
@jasongin @boingoing I have resolved all build and test issues, is there anything else I should be testing with? |
VS2013 issues * No constexpr support - Conditionally use constexpr if the compiler supports it - Updated tests to use a macro for this purpose * Requires copy constructor support for base classes of thrown objects - Added a protected copy constructor to ObjectReference and Reference<T> * Incorrect overload resolution for std::initializer_list - Used explicit types to invoke the correct overload * No literal support for char16_t - Added macro to convert the text properly * Lambdas are unable to capture function non-pointers - Updated the typedef to create a function pointer * Short lifetime for temporary objects passed to constructors - Updated the tests to create the objects and pass them to the constructor. This is closer to how they would be used anyway General improvements * Added console.log output to the test runner to make it more clear when and where tests are failing
Everything is passing now locally building in VS2013 and VS2015 and the CI is green for all legs. |
PropertyDescriptor::Value(std::string("enumerableValue"), trueValue, napi_enumerable), | ||
PropertyDescriptor::Value(std::string("configurableValue"), trueValue, napi_configurable), | ||
PropertyDescriptor::Function(std::string("function"), TestFunction), | ||
PropertyDescriptor::Accessor(str1, TestGetter), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfortunate, and seems likely to confuse many people (if they are using VS 2013). The way I wanted this to work for the most common case is you should be able to just pass in a string literal:
PropertyDescriptor::Accessor("readonlyAccessor", TestGetter),
Did you try that? I'd assume the behavior is the same as the explicit call to std::string()
, but I'm not sure.
If that doesn't work, then I think it would be best to add overloads of each of those methods that accept a const char*
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasongin there is already an overload for const char *, that's what the other leg of the conditional tests. It just gets chained to for the std::string constructor. Does that resolve your concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry I didn't look at the broader context in this file! Yes, that resolves my concerns then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to do something better for the temporary std::string
issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
napi-inl.h
Outdated
@@ -2697,11 +2716,11 @@ inline FunctionReference& AsyncWorker::Callback() { | |||
} | |||
|
|||
inline void AsyncWorker::OnOK() { | |||
_callback.MakeCallback(_receiver.Value(), {}); | |||
_callback.MakeCallback(_receiver.Value(), {{}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double-curly syntax is weird. Can you add a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been changed in the latest revision. This actually had side-effects that I encountered during testing.
@jasongin As far as I'm concerned this is ready to land, feel free to land it at your convenience. |
VS2013 issues
Reference
constructor. This is closer to how they would be used anyway
General improvements
when and where tests are failing