Permalink
Browse files

core, refactor: remove equals from object to Buffer and Int64.

  • Loading branch information...
xicilion committed Nov 1, 2017
1 parent d811350 commit a1ef84dd74cb1c6e4c6acd7278e6db58d1d91cf4
View
@@ -105,6 +105,7 @@ class Buffer_base : public object_base {
virtual result_t slice(int32_t start, obj_ptr<Buffer_base>& retVal) = 0;
virtual result_t slice(int32_t start, int32_t end, obj_ptr<Buffer_base>& retVal) = 0;
virtual result_t reverse(obj_ptr<Buffer_base>& retVal) = 0;
virtual result_t equals(object_base* expected, bool& retVal) = 0;
virtual result_t hex(exlib::string& retVal) = 0;
virtual result_t base64(exlib::string& retVal) = 0;
virtual result_t keys(v8::Local<v8::Object>& retVal) = 0;
@@ -181,6 +182,7 @@ class Buffer_base : public object_base {
static void s_writeDoubleBE(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_slice(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_reverse(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_equals(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_hex(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_base64(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_keys(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -254,6 +256,7 @@ inline ClassInfo& Buffer_base::class_info()
{ "writeDoubleBE", s_writeDoubleBE, false },
{ "slice", s_slice, false },
{ "reverse", s_reverse, false },
{ "equals", s_equals, false },
{ "hex", s_hex, false },
{ "base64", s_base64, false },
{ "keys", s_keys, false },
@@ -1522,6 +1525,23 @@ inline void Buffer_base::s_reverse(const v8::FunctionCallbackInfo<v8::Value>& ar
METHOD_RETURN();
}
inline void Buffer_base::s_equals(const v8::FunctionCallbackInfo<v8::Value>& args)
{
bool vr;
METHOD_NAME("Buffer.equals");
METHOD_INSTANCE(Buffer_base);
METHOD_ENTER();
METHOD_OVER(1, 1);
ARG(obj_ptr<object_base>, 0);
hr = pInst->equals(v0, vr);
METHOD_RETURN();
}
inline void Buffer_base::s_hex(const v8::FunctionCallbackInfo<v8::Value>& args)
{
exlib::string vr;
View
@@ -39,6 +39,7 @@ class Int64_base : public object_base {
virtual result_t sub(Int64_base* num, obj_ptr<Int64_base>& retVal) = 0;
virtual result_t multi(Int64_base* num, obj_ptr<Int64_base>& retVal) = 0;
virtual result_t div(Int64_base* num, obj_ptr<Int64_base>& retVal) = 0;
virtual result_t equals(object_base* expected, bool& retVal) = 0;
virtual result_t toNumber(double& retVal) = 0;
virtual result_t toString(int32_t base, exlib::string& retVal) = 0;
@@ -62,6 +63,7 @@ class Int64_base : public object_base {
static void s_sub(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_multi(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_div(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_equals(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toNumber(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toString(const v8::FunctionCallbackInfo<v8::Value>& args);
};
@@ -81,6 +83,7 @@ inline ClassInfo& Int64_base::class_info()
{ "sub", s_sub, false },
{ "multi", s_multi, false },
{ "div", s_div, false },
{ "equals", s_equals, false },
{ "toNumber", s_toNumber, false },
{ "toString", s_toString, false }
};
@@ -363,6 +366,23 @@ inline void Int64_base::s_div(const v8::FunctionCallbackInfo<v8::Value>& args)
METHOD_RETURN();
}
inline void Int64_base::s_equals(const v8::FunctionCallbackInfo<v8::Value>& args)
{
bool vr;
METHOD_NAME("Int64.equals");
METHOD_INSTANCE(Int64_base);
METHOD_ENTER();
METHOD_OVER(1, 1);
ARG(obj_ptr<object_base>, 0);
hr = pInst->equals(v0, vr);
METHOD_RETURN();
}
inline void Int64_base::s_toNumber(const v8::FunctionCallbackInfo<v8::Value>& args)
{
double vr;
View
@@ -22,7 +22,6 @@ class object_base {
public:
// object_base
virtual result_t dispose() = 0;
virtual result_t equals(object_base* expected, bool& retVal) = 0;
virtual result_t toString(exlib::string& retVal) = 0;
virtual result_t toJSON(exlib::string key, v8::Local<v8::Value>& retVal) = 0;
@@ -39,7 +38,6 @@ class object_base {
public:
static void s_dispose(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_equals(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toString(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
};
@@ -50,7 +48,6 @@ inline ClassInfo& object_base::class_info()
{
static ClassData::ClassMethod s_method[] = {
{ "dispose", s_dispose, false },
{ "equals", s_equals, false },
{ "toString", s_toString, false },
{ "toJSON", s_toJSON, false }
};
@@ -78,23 +75,6 @@ inline void object_base::s_dispose(const v8::FunctionCallbackInfo<v8::Value>& ar
METHOD_VOID();
}
inline void object_base::s_equals(const v8::FunctionCallbackInfo<v8::Value>& args)
{
bool vr;
METHOD_NAME("object.equals");
METHOD_INSTANCE(object_base);
METHOD_ENTER();
METHOD_OVER(1, 1);
ARG(obj_ptr<object_base>, 0);
hr = pInst->equals(v0, vr);
METHOD_RETURN();
}
inline void object_base::s_toString(const v8::FunctionCallbackInfo<v8::Value>& args)
{
exlib::string vr;
View
@@ -422,7 +422,6 @@ class object_base : public obj_base {
private:
static void s_dispose(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_equals(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toString(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_toJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
};
@@ -476,13 +475,13 @@ inline ClassInfo& object_base::class_info()
{
static ClassData::ClassMethod s_method[] = {
{ "dispose", s_dispose },
{ "equals", s_equals, false },
{ "toString", s_toString },
{ "toJSON", s_toJSON }
};
static ClassData s_cd = {
"object", false, NULL, NULL, 4, s_method, 0,
"object", false, NULL, NULL,
ARRAYSIZE(s_method), s_method, 0,
NULL, 0, NULL, NULL, NULL, NULL
};
@@ -503,23 +502,6 @@ inline void object_base::s_dispose(const v8::FunctionCallbackInfo<v8::Value>& ar
METHOD_VOID();
}
inline void object_base::s_equals(const v8::FunctionCallbackInfo<v8::Value>& args)
{
bool vr;
METHOD_NAME("object.equals");
METHOD_INSTANCE(object_base);
METHOD_ENTER();
METHOD_OVER(1, 1);
ARG(obj_ptr<object_base>, 0);
hr = pInst->equals(v0, vr);
METHOD_RETURN();
}
inline void object_base::s_toString(const v8::FunctionCallbackInfo<v8::Value>& args)
{
exlib::string vr;
View
@@ -574,6 +574,12 @@ interface Buffer : object
*/
Buffer reverse();
/*! @brief 比较当前对象与给定的对象是否相等
@param expected 制定比较的目标对象
@return 返回对象比较的结果
*/
Boolean equals(object expected);
/*! @brief 使用 16 进制编码缓存对象内容
@return 返回编码字符串
*/
View
@@ -95,6 +95,12 @@ interface Int64 : object
*/
Int64 div(Int64 num);
/*! @brief 比较当前对象与给定的对象是否相等
@param expected 制定比较的目标对象
@return 返回对象比较的结果
*/
Boolean equals(object expected);
/*! @brief 转换成数字类型
@return 返回转换后的数字
*/
View
@@ -4,12 +4,6 @@ interface object
/*! @brief 强制回收对象,调用此方法后,对象资源将立即释放*/
dispose();
/*! @brief 比较当前对象与给定的对象是否相等
@param expected 制定比较的目标对象
@return 返回对象比较的结果
*/
Boolean equals(object expected);
/*! @brief 返回对象的字符串表示,一般返回 "[Native Object]",对象可以根据自己的特性重新实现
@return 返回对象的字符串表示
*/

0 comments on commit a1ef84d

Please sign in to comment.