Skip to content

Commit

Permalink
util, feat: support util._extend.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Sep 25, 2017
1 parent f97d881 commit d93ca53
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fibjs/include/ifs/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class util_base : public object_base {
static result_t values(v8::Local<v8::Value> v, v8::Local<v8::Array>& retVal);
static result_t clone(v8::Local<v8::Value> v, v8::Local<v8::Value>& retVal);
static result_t extend(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Value>& retVal);
static result_t _extend(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Value>& retVal);
static result_t pick(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Object>& retVal);
static result_t omit(v8::Local<v8::Value> v, OptArgs keys, v8::Local<v8::Object>& retVal);
static result_t first(v8::Local<v8::Value> v, v8::Local<v8::Value>& retVal);
Expand Down Expand Up @@ -123,6 +124,7 @@ class util_base : public object_base {
static void s_values(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_clone(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_extend(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s__extend(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_pick(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_omit(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_first(const v8::FunctionCallbackInfo<v8::Value>& args);
Expand Down Expand Up @@ -183,6 +185,7 @@ inline ClassInfo& util_base::class_info()
{ "values", s_values, true },
{ "clone", s_clone, true },
{ "extend", s_extend, true },
{ "_extend", s__extend, true },
{ "pick", s_pick, true },
{ "omit", s_omit, true },
{ "first", s_first, true },
Expand Down Expand Up @@ -719,6 +722,22 @@ inline void util_base::s_extend(const v8::FunctionCallbackInfo<v8::Value>& args)
METHOD_RETURN();
}

inline void util_base::s__extend(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Local<v8::Value> vr;

METHOD_ENTER();

METHOD_OVER(-1, 1);

ARG(v8::Local<v8::Value>, 0);
ARG_LIST(1);

hr = _extend(v0, v1, vr);

METHOD_RETURN();
}

inline void util_base::s_pick(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Local<v8::Object> vr;
Expand Down
6 changes: 6 additions & 0 deletions fibjs/src/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ result_t util_base::extend(v8::Local<v8::Value> v, OptArgs objs,
return 0;
}

result_t util_base::_extend(v8::Local<v8::Value> v, OptArgs objs,
v8::Local<v8::Value>& retVal)
{
return extend(v, objs, retVal);
}

result_t util_base::pick(v8::Local<v8::Value> v, OptArgs objs,
v8::Local<v8::Object>& retVal)
{
Expand Down
8 changes: 8 additions & 0 deletions idl/zh-cn/util.idl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ module util
*/
static Value extend(Value v, ...objs);

/*! @brief 将一个或者多个对象的键值扩展到指定对象,是 extend 的别名

@param v 指定要扩展的对象
@param objs 指定一个或者多个用于扩展的对象
@return 返回扩展的结果
*/
static Value _extend(Value v, ...objs);

/*! @brief 返回一个object副本,只过滤出指定键的属性值

@param v 指定要过滤的对象
Expand Down

0 comments on commit d93ca53

Please sign in to comment.