Permalink
Browse files

idlc, refactor: use GetArgumentValue to convert property.

  • Loading branch information...
xicilion committed Sep 24, 2017
1 parent 8cc0308 commit 7765c2402aef32b0c8741aac890504ef950a8249
@@ -50,7 +50,7 @@ class EventInfo : public EventInfo_base {
return 0;
}
virtual result_t _named_getter(const char* property, int32_t& retVal)
virtual result_t _named_getter(exlib::string property, int32_t& retVal)
{
std::map<exlib::string, VariantEx>::iterator it = m_datas.find(property);
@@ -31,10 +31,10 @@ class HttpCollection : public HttpCollection_base {
virtual result_t set(Map_base* map);
virtual result_t set(exlib::string name, Variant value);
virtual result_t remove(exlib::string name);
virtual result_t _named_getter(const char* property, Variant& retVal);
virtual result_t _named_getter(exlib::string property, Variant& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
virtual result_t _named_setter(const char* property, Variant newVal);
virtual result_t _named_deleter(const char* property, v8::Local<v8::Boolean>& retVal);
virtual result_t _named_setter(exlib::string property, Variant newVal);
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal);
public:
void add(const char* name, int32_t szName, const char* value, int32_t szValue)
@@ -31,10 +31,10 @@ class HttpUploadCollection : public HttpCollection_base {
virtual result_t set(Map_base* map);
virtual result_t set(exlib::string name, Variant value);
virtual result_t remove(exlib::string name);
virtual result_t _named_getter(const char* property, Variant& retVal);
virtual result_t _named_getter(exlib::string property, Variant& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
virtual result_t _named_setter(const char* property, Variant newVal);
virtual result_t _named_deleter(const char* property, v8::Local<v8::Boolean>& retVal);
virtual result_t _named_setter(exlib::string property, Variant newVal);
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal);
void parse(exlib::string& str, const char* boundary);
View
@@ -26,10 +26,10 @@ class Map : public Map_base {
virtual result_t set(exlib::string name, Variant value);
virtual result_t remove(exlib::string name);
virtual result_t isEmpty(bool& retVal);
virtual result_t _named_getter(const char* property, Variant& retVal);
virtual result_t _named_getter(exlib::string property, Variant& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
virtual result_t _named_setter(const char* property, Variant newVal);
virtual result_t _named_deleter(const char* property, v8::Local<v8::Boolean>& retVal);
virtual result_t _named_setter(exlib::string property, Variant newVal);
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal);
public:
template <typename T>
@@ -58,7 +58,7 @@ class MongoCollection : public MongoCollection_base {
virtual result_t dropIndexes(v8::Local<v8::Object>& retVal);
virtual result_t getIndexes(obj_ptr<MongoCursor_base>& retVal);
virtual result_t getCollection(exlib::string name, obj_ptr<MongoCollection_base>& retVal);
virtual result_t _named_getter(const char* property, obj_ptr<MongoCollection_base>& retVal);
virtual result_t _named_getter(exlib::string property, obj_ptr<MongoCollection_base>& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
private:
View
@@ -35,7 +35,7 @@ class MongoDB : public MongoDB_base {
virtual result_t getCollection(exlib::string name, obj_ptr<MongoCollection_base>& retVal);
virtual result_t runCommand(v8::Local<v8::Object> cmd, v8::Local<v8::Object>& retVal);
virtual result_t runCommand(exlib::string cmd, v8::Local<v8::Value> arg, v8::Local<v8::Object>& retVal);
virtual result_t _named_getter(const char* property, obj_ptr<MongoCollection_base>& retVal);
virtual result_t _named_getter(exlib::string property, obj_ptr<MongoCollection_base>& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
virtual result_t get_fs(obj_ptr<GridFS_base>& retVal);
virtual result_t oid(exlib::string hexStr, obj_ptr<MongoID_base>& retVal);
View
@@ -21,7 +21,7 @@ class Stats : public Stats_base {
virtual result_t add(exlib::string key, int32_t value);
virtual result_t reset();
virtual result_t uptime(int32_t& retVal);
virtual result_t _named_getter(const char* property, int32_t& retVal);
virtual result_t _named_getter(exlib::string property, int32_t& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
public:
@@ -25,7 +25,7 @@ class EventInfo_base : public object_base {
virtual result_t get_reason(exlib::string& retVal) = 0;
virtual result_t get_type(exlib::string& retVal) = 0;
virtual result_t get_target(v8::Local<v8::Object>& retVal) = 0;
virtual result_t _named_getter(const char* property, int32_t& retVal) = 0;
virtual result_t _named_getter(exlib::string property, int32_t& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
public:
@@ -128,11 +128,12 @@ inline void EventInfo_base::i_NamedGetter(v8::Local<v8::String> property, const
METHOD_INSTANCE(EventInfo_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -33,10 +33,10 @@ class HttpCollection_base : public object_base {
virtual result_t set(Map_base* map) = 0;
virtual result_t set(exlib::string name, Variant value) = 0;
virtual result_t remove(exlib::string name) = 0;
virtual result_t _named_getter(const char* property, Variant& retVal) = 0;
virtual result_t _named_getter(exlib::string property, Variant& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
virtual result_t _named_setter(const char* property, Variant newVal) = 0;
virtual result_t _named_deleter(const char* property, v8::Local<v8::Boolean>& retVal) = 0;
virtual result_t _named_setter(exlib::string property, Variant newVal) = 0;
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal) = 0;
public:
static void s__new(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -217,11 +217,12 @@ inline void HttpCollection_base::i_NamedGetter(v8::Local<v8::String> property, c
METHOD_INSTANCE(HttpCollection_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -246,11 +247,12 @@ inline void HttpCollection_base::i_NamedSetter(v8::Local<v8::String> property, v
PROPERTY_ENTER();
PROPERTY_VAL(Variant);
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_setter(*k, v0);
hr = pInst->_named_setter(k, v0);
if (hr == CALL_RETURN_NULL)
return;
@@ -264,13 +266,14 @@ inline void HttpCollection_base::i_NamedDeleter(v8::Local<v8::String> property,
METHOD_INSTANCE(HttpCollection_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k)) {
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str())) {
args.GetReturnValue().Set(v8::False(isolate));
return;
}
hr = pInst->_named_deleter(*k, vr);
hr = pInst->_named_deleter(k, vr);
METHOD_RETURN1();
}
}
View
@@ -33,10 +33,10 @@ class Map_base : public object_base {
virtual result_t set(exlib::string name, Variant value) = 0;
virtual result_t remove(exlib::string name) = 0;
virtual result_t isEmpty(bool& retVal) = 0;
virtual result_t _named_getter(const char* property, Variant& retVal) = 0;
virtual result_t _named_getter(exlib::string property, Variant& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
virtual result_t _named_setter(const char* property, Variant newVal) = 0;
virtual result_t _named_deleter(const char* property, v8::Local<v8::Boolean>& retVal) = 0;
virtual result_t _named_setter(exlib::string property, Variant newVal) = 0;
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal) = 0;
public:
template <typename T>
@@ -249,11 +249,12 @@ inline void Map_base::i_NamedGetter(v8::Local<v8::String> property, const v8::Pr
METHOD_INSTANCE(Map_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -278,11 +279,12 @@ inline void Map_base::i_NamedSetter(v8::Local<v8::String> property, v8::Local<v8
PROPERTY_ENTER();
PROPERTY_VAL(Variant);
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_setter(*k, v0);
hr = pInst->_named_setter(k, v0);
if (hr == CALL_RETURN_NULL)
return;
@@ -296,13 +298,14 @@ inline void Map_base::i_NamedDeleter(v8::Local<v8::String> property, const v8::P
METHOD_INSTANCE(Map_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k)) {
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str())) {
args.GetReturnValue().Set(v8::False(isolate));
return;
}
hr = pInst->_named_deleter(*k, vr);
hr = pInst->_named_deleter(k, vr);
METHOD_RETURN1();
}
}
@@ -41,7 +41,7 @@ class MongoCollection_base : public object_base {
virtual result_t dropIndexes(v8::Local<v8::Object>& retVal) = 0;
virtual result_t getIndexes(obj_ptr<MongoCursor_base>& retVal) = 0;
virtual result_t getCollection(exlib::string name, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t _named_getter(const char* property, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t _named_getter(exlib::string property, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
public:
@@ -367,11 +367,12 @@ inline void MongoCollection_base::i_NamedGetter(v8::Local<v8::String> property,
METHOD_INSTANCE(MongoCollection_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -28,7 +28,7 @@ class MongoDB_base : public object_base {
virtual result_t getCollection(exlib::string name, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t runCommand(v8::Local<v8::Object> cmd, v8::Local<v8::Object>& retVal) = 0;
virtual result_t runCommand(exlib::string cmd, v8::Local<v8::Value> arg, v8::Local<v8::Object>& retVal) = 0;
virtual result_t _named_getter(const char* property, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t _named_getter(exlib::string property, obj_ptr<MongoCollection_base>& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
virtual result_t get_fs(obj_ptr<GridFS_base>& retVal) = 0;
virtual result_t oid(exlib::string hexStr, obj_ptr<MongoID_base>& retVal) = 0;
@@ -138,11 +138,12 @@ inline void MongoDB_base::i_NamedGetter(v8::Local<v8::String> property, const v8
METHOD_INSTANCE(MongoDB_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -28,7 +28,7 @@ class Stats_base : public object_base {
virtual result_t add(exlib::string key, int32_t value) = 0;
virtual result_t reset() = 0;
virtual result_t uptime(int32_t& retVal) = 0;
virtual result_t _named_getter(const char* property, int32_t& retVal) = 0;
virtual result_t _named_getter(exlib::string property, int32_t& retVal) = 0;
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal) = 0;
public:
@@ -177,11 +177,12 @@ inline void Stats_base::i_NamedGetter(v8::Local<v8::String> property, const v8::
METHOD_INSTANCE(Stats_base);
PROPERTY_ENTER();
v8::String::Utf8Value k(property);
if (class_info().has(*k))
exlib::string k;
GetArgumentValue(isolate, property, k);
if (class_info().has(k.c_str()))
return;
hr = pInst->_named_getter(*k, vr);
hr = pInst->_named_getter(k, vr);
if (hr == CALL_RETURN_NULL)
return;
@@ -113,7 +113,7 @@ result_t Map::isEmpty(bool& retVal)
return 0;
}
result_t Map::_named_getter(const char* property, Variant& retVal)
result_t Map::_named_getter(exlib::string property, Variant& retVal)
{
return get(property, retVal);
}
@@ -132,12 +132,12 @@ result_t Map::_named_enumerator(v8::Local<v8::Array>& retVal)
return 0;
}
result_t Map::_named_setter(const char* property, Variant newVal)
result_t Map::_named_setter(exlib::string property, Variant newVal)
{
return put(property, newVal);
}
result_t Map::_named_deleter(const char* property,
result_t Map::_named_deleter(exlib::string property,
v8::Local<v8::Boolean>& retVal)
{
return remove(property);
@@ -416,7 +416,7 @@ result_t MongoCollection::getCollection(exlib::string name,
return 0;
}
result_t MongoCollection::_named_getter(const char* property,
result_t MongoCollection::_named_getter(exlib::string property,
obj_ptr<MongoCollection_base>& retVal)
{
return getCollection(property, retVal);
@@ -294,7 +294,7 @@ result_t MongoDB::runCommand(exlib::string cmd, v8::Local<v8::Value> arg,
return bsonHandler(&bbq, retVal);
}
result_t MongoDB::_named_getter(const char* property,
result_t MongoDB::_named_getter(exlib::string property,
obj_ptr<MongoCollection_base>& retVal)
{
return getCollection(property, retVal);
@@ -300,15 +300,15 @@ result_t HttpCollection::remove(exlib::string name)
return 0;
}
result_t HttpCollection::_named_getter(const char* property, Variant& retVal)
result_t HttpCollection::_named_getter(exlib::string property, Variant& retVal)
{
int32_t i;
int32_t n = 0;
Variant v;
v8::Local<v8::Array> a;
for (i = 0; i < m_count; i++)
if (!qstricmp(m_names[i].c_str(), property)) {
if (!qstricmp(m_names[i].c_str(), property.c_str())) {
if (n == 0) {
v = m_values[i];
n = 1;
@@ -349,12 +349,12 @@ result_t HttpCollection::_named_enumerator(v8::Local<v8::Array>& retVal)
return 0;
}
result_t HttpCollection::_named_setter(const char* property, Variant newVal)
result_t HttpCollection::_named_setter(exlib::string property, Variant newVal)
{
return set(property, newVal);
}
result_t HttpCollection::_named_deleter(const char* property,
result_t HttpCollection::_named_deleter(exlib::string property,
v8::Local<v8::Boolean>& retVal)
{
int32_t n = m_count;
Oops, something went wrong.

0 comments on commit 7765c24

Please sign in to comment.