Skip to content

Commit

Permalink
Replace uses of the old Value::NewArray method with new ArrayByValue …
Browse files Browse the repository at this point in the history
…type.
  • Loading branch information
cscott committed Nov 3, 2015
1 parent ff075a0 commit f7c7a62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
12 changes: 7 additions & 5 deletions src/node_php_phpobject_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,15 @@ class PhpObject::PhpInvokeMsg : public MessageToPhp {
public:
PhpInvokeMsg(ObjectMapper *m, Nan::Callback *callback, bool is_sync,
objid_t obj, v8::Local<v8::String> method,
const Nan::FunctionCallbackInfo<v8::Value> &info)
const Nan::FunctionCallbackInfo<v8::Value> *info)
: MessageToPhp(m, callback, is_sync), method_(m, method),
argc_(info.Length()), argv_(Value::NewArray(m, info)),
argc_(info->Length()), argv_(),
should_convert_array_to_iterator_(false) {
obj_.SetJsObject(obj);
argv_.SetArrayByValue(argc_, [m, info](uint32_t idx, Value& v) {
v.Set(m, (*info)[idx]);
});
}
~PhpInvokeMsg() override { delete[] argv_; }
inline bool should_convert_array_to_iterator() {
return should_convert_array_to_iterator_;
}
Expand Down Expand Up @@ -803,7 +805,7 @@ class PhpObject::PhpInvokeMsg : public MessageToPhp {
Value obj_;
Value method_;
int argc_;
Value *argv_;
Value argv_;
bool should_convert_array_to_iterator_;
};

Expand All @@ -824,7 +826,7 @@ void PhpObject::MethodThunk_(v8::Local<v8::String> method,
return Nan::ThrowError("Invocation after PHP request has completed.");
}
PhpInvokeMsg msg(channel_, nullptr, true, // Sync call.
id_, method, info);
id_, method, &info);
channel_->SendToPhp(&msg, MessageFlags::SYNC);
THROW_IF_EXCEPTION("PHP exception thrown during method invocation", /* */);
if (msg.retval().IsEmpty()) {
Expand Down
16 changes: 0 additions & 16 deletions src/values.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,6 @@ class Value {
: type_(VALUE_EMPTY), empty_(0) {
Set(m, v TSRMLS_CC);
}
template <typename T>
static Value *NewArray(PhpObjectMapper *m, int argc, T* argv TSRMLS_DC) {
Value *result = new Value[argc];
for (int i = 0; i < argc; i++) {
result[i].Set(m, argv[i] TSRMLS_CC);
}
return result;
}
static Value *NewArray(JsObjectMapper *m,
const Nan::FunctionCallbackInfo<v8::Value> &info) {
Value *result = new Value[info.Length()];
for (int i = 0; i < info.Length(); i++) {
result[i].Set(m, info[i]);
}
return result;
}
void Set(JsObjectMapper *m, v8::Local<v8::Value> v) {
if (v->IsUndefined() || v->IsNull()) {
/* Fall through to the default case. */
Expand Down

0 comments on commit f7c7a62

Please sign in to comment.