Skip to content
Permalink
Browse files

core, feat: get Utf8values using ToString.

  • Loading branch information...
xicilion committed Sep 10, 2018
1 parent 246e968 commit 74ebf679521b9cf724ba1a7f62edfb9a34af29e6
@@ -34,7 +34,7 @@ class NObject : public object_base {

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
add(*v8::String::Utf8Value(k), m->Get(k));
add(ToCString(v8::String::Utf8Value(k)), m->Get(k));
}

return 0;
@@ -186,7 +186,7 @@ class JSTrigger {
v8::Local<v8::Value> v = m->Get(k);

if (v->IsFunction())
(this->*fn)(*v8::String::Utf8Value(k),
(this->*fn)(ToCString(v8::String::Utf8Value(k)),
v8::Local<v8::Function>::Cast(v), retVal);
else
return CHECK_ERROR(CALL_E_BADVARTYPE);
@@ -378,7 +378,7 @@ class object_base : public obj_base {

exlib::string strError = "Property \'";

strError += *v8::String::Utf8Value(property);
strError += ToCString(v8::String::Utf8Value(property));
strError += "\' is read-only.";
isolate->m_isolate->ThrowException(
isolate->NewString(strError));
@@ -433,8 +433,10 @@ class ValueHolder : public object_base {

class RootModule {
public:
RootModule() : m_next(NULL)
{}
RootModule()
: m_next(NULL)
{
}

public:
void install()
@@ -193,7 +193,7 @@ exlib::string GetException(TryCatch& try_catch, result_t hr, bool repl)
if (message.IsEmpty() || message->IsUndefined() || name.IsEmpty() || name->IsUndefined()) {
// Not an error object. Just print as-is.
v8::String::Utf8Value message(err);
strError.append(*message ? *message : "<toString() threw exception>");
strError.append(ToCString(message));
strError.append("\n");
} else {
v8::String::Utf8Value message_string(isolate->m_isolate, message);
@@ -241,7 +241,7 @@ result_t CheckConfig(v8::Local<v8::Object> opts, const char** keys)
const char** p = keys;

while (p[0]) {
if (!qstrcmp(*k, p[0]))
if (!qstrcmp(ToCString(k), p[0]))
break;
p++;
}
@@ -76,7 +76,7 @@ exlib::string traceInfo(v8::Isolate* isolate, int32_t deep, void* entry_fp, void
bFirst = false;

v8::String::Utf8Value funcname(v8::Utils::ToLocal(summ.FunctionName()));
if (**funcname) {
if (*funcname) {
strBuffer.append(*funcname);
strBuffer.append(" (", 2);
}
@@ -190,7 +190,7 @@ result_t X509Req::parseString(v8::Local<v8::Value> v, const X509Cert::_name* pNa

if (!IsEmpty(v)) {
v8::String::Utf8Value str(v);
const char* ptr = *str;
const char* ptr = ToCString(str);

if (!ptr)
return CHECK_ERROR(_ssl::setError(MBEDTLS_ERR_MPI_BAD_INPUT_DATA));
@@ -61,7 +61,7 @@ void encodeValue(Isolate* isolate, bson* bb, const char* name, v8::Local<v8::Val

*p = 0;

bson_append_regex(bb, name, *v8::String::Utf8Value(src), flgStr);
bson_append_regex(bb, name, ToCString(v8::String::Utf8Value(src)), flgStr);
} else if (element->IsObject()) {
{
obj_ptr<Int64> num = (Int64*)Int64_base::getInstance(element);
@@ -18,9 +18,8 @@ size_t HttpCollection::size()
size_t sz = 0;
int32_t i;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];
sz += _pair.first.length() + _pair.second.length() + 4;
}

@@ -46,7 +45,7 @@ size_t HttpCollection::getData(char* buf, size_t sz)
int32_t i;

for (i = 0; i < m_count; i++) {
pair &_pair = m_map[i];
pair& _pair = m_map[i];
exlib::string& n = _pair.first;
exlib::string& v = _pair.second;

@@ -199,9 +198,8 @@ result_t HttpCollection::first(exlib::string name, Variant& retVal)
{
int32_t i;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str())) {
retVal = _pair.second;
@@ -219,9 +217,8 @@ result_t HttpCollection::all(exlib::string name, obj_ptr<NArray>& retVal)

list = new NArray();

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str()))
list->append(_pair.second);
@@ -251,7 +248,7 @@ result_t HttpCollection::add(v8::Local<v8::Object> map)

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
add(*v8::String::Utf8Value(k), map->Get(k));
add(ToCString(v8::String::Utf8Value(k)), map->Get(k));
}

return 0;
@@ -262,9 +259,8 @@ result_t HttpCollection::set(exlib::string name, Variant value)
int32_t i;
bool bFound = false;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str())) {
exlib::string s;
@@ -280,9 +276,8 @@ result_t HttpCollection::set(exlib::string name, Variant value)
if (bFound) {
int32_t p = ++i;

for (; i < m_count; i++)
{
pair &_pair = m_map[i];
for (; i < m_count; i++) {
pair& _pair = m_map[i];

if (qstricmp(_pair.first.c_str(), name.c_str())) {
if (i != p)
@@ -307,7 +302,7 @@ result_t HttpCollection::set(v8::Local<v8::Object> map)

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
set(*v8::String::Utf8Value(k), map->Get(k));
set(ToCString(v8::String::Utf8Value(k)), map->Get(k));
}

return 0;
@@ -318,9 +313,8 @@ result_t HttpCollection::remove(exlib::string name)
int32_t i;
int32_t p = 0;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (qstricmp(_pair.first.c_str(), name.c_str())) {
if (i != p)
@@ -342,9 +336,8 @@ result_t HttpCollection::_named_getter(exlib::string property, Variant& retVal)
Variant v;
v8::Local<v8::Array> a;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), property.c_str())) {
if (n == 0) {
@@ -129,7 +129,7 @@ result_t HttpFileHandler::set_mimes(v8::Local<v8::Object> mimes)
if (hr < 0)
return CHECK_ERROR(hr);

m_mimes.insert(std::pair<exlib::string, exlib::string>(*v8::String::Utf8Value(ks), v));
m_mimes.insert(std::pair<exlib::string, exlib::string>(ToCString(v8::String::Utf8Value(ks)), v));
}

return 0;
@@ -232,9 +232,8 @@ result_t HttpUploadCollection::first(exlib::string name, Variant& retVal)
{
int32_t i;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str())) {
retVal = _pair.second;
@@ -252,9 +251,8 @@ result_t HttpUploadCollection::all(exlib::string name, obj_ptr<NArray>& retVal)

list = new NArray();

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str()))
list->append(_pair.second);
@@ -280,7 +278,7 @@ result_t HttpUploadCollection::add(v8::Local<v8::Object> map)

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
add(*v8::String::Utf8Value(k), map->Get(k));
add(ToCString(v8::String::Utf8Value(k)), map->Get(k));
}

return 0;
@@ -291,9 +289,8 @@ result_t HttpUploadCollection::set(exlib::string name, Variant value)
int32_t i;
bool bFound = false;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (!qstricmp(_pair.first.c_str(), name.c_str())) {
_pair.second = value;
@@ -305,9 +302,8 @@ result_t HttpUploadCollection::set(exlib::string name, Variant value)
if (bFound) {
int32_t p = ++i;

for (; i < m_count; i++)
{
pair &_pair = m_map[i];
for (; i < m_count; i++) {
pair& _pair = m_map[i];

if (qstricmp(_pair.first.c_str(), name.c_str())) {
if (i != p)
@@ -332,7 +328,7 @@ result_t HttpUploadCollection::set(v8::Local<v8::Object> map)

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
set(*v8::String::Utf8Value(k), map->Get(k));
set(ToCString(v8::String::Utf8Value(k)), map->Get(k));
}

return 0;
@@ -343,9 +339,8 @@ result_t HttpUploadCollection::remove(exlib::string name)
int32_t i;
int32_t p = 0;

for (i = 0; i < m_count; i++)
{
pair &_pair = m_map[i];
for (i = 0; i < m_count; i++) {
pair& _pair = m_map[i];

if (qstricmp(_pair.first.c_str(), name.c_str())) {
if (i != p)
@@ -133,7 +133,7 @@ result_t Routing::_append(exlib::string method, v8::Local<v8::Object> map,
if (hr < 0)
return hr;

append(method, *v8::String::Utf8Value(k), hdlr, r);
append(method, ToCString(v8::String::Utf8Value(k)), hdlr, r);
}

retVal = this;
@@ -426,7 +426,7 @@ bool getString(Isolate* isolate, v8::Local<v8::Object>& args,
v8::Local<v8::Value> v = args->Get(isolate->NewString(key));

if (!v.IsEmpty() && (v->IsString() || v->IsStringObject())) {
retVal = *v8::String::Utf8Value(v);
retVal = ToCString(v8::String::Utf8Value(v));
return true;
}

@@ -838,7 +838,7 @@ result_t Url::set_query(v8::Local<v8::Value> newVal)
{
if (!newVal.IsEmpty()) {
if (newVal->IsString() || newVal->IsStringObject()) {
m_query = *v8::String::Utf8Value(newVal);
m_query = ToCString(v8::String::Utf8Value(newVal));

if (m_queryParsed) {
m_queryParsed = new HttpCollection();
@@ -150,7 +150,7 @@ result_t SandBox::add(v8::Local<v8::Object> mods)

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
hr = add(*v8::String::Utf8Value(k), mods->Get(k));
hr = add(ToCString(v8::String::Utf8Value(k)), mods->Get(k));
if (hr < 0)
return hr;
}
@@ -36,7 +36,7 @@ void _resolve(const v8::FunctionCallbackInfo<v8::Value>& args)
_mod->Get(NewString(isolate, "_sbox")));

exlib::string strPath;
path_base::dirname(*v8::String::Utf8Value(path), strPath);
path_base::dirname(ToCString(v8::String::Utf8Value(path)), strPath);

exlib::string v;
hr = sbox->resolve(id, strPath, v);
@@ -77,7 +77,7 @@ void _require(const v8::FunctionCallbackInfo<v8::Value>& args)
_mod->Get(NewString(isolate, "_sbox")));

exlib::string strPath;
path_base::dirname(*v8::String::Utf8Value(path), strPath);
path_base::dirname(ToCString(v8::String::Utf8Value(path)), strPath);

v8::Local<v8::Value> v;
hr = sbox->run_module(id, strPath, v);
@@ -129,7 +129,7 @@ void _run(const v8::FunctionCallbackInfo<v8::Value>& args)

exlib::string strPath;

path_base::dirname(*v8::String::Utf8Value(path), strPath);
path_base::dirname(ToCString(v8::String::Utf8Value(path)), strPath);
if (strPath.length()) {
resolvePath(strPath, id);
id = strPath;
@@ -202,7 +202,7 @@ result_t SandBox::Context::repl(v8::Local<v8::Array> cmds, Stream_base* out)
script = v8::Script::Compile(isolate->NewString(buf), strFname);
if (script.IsEmpty()) {
v8::String::Utf8Value exception(try_catch.Exception());
if (*exception && qstrcmp(*exception, "SyntaxError: Unexpected end of input")) {
if (*exception && qstrcmp(ToCString(exception), "SyntaxError: Unexpected end of input")) {
buf.clear();
ReportException(try_catch, 0, true);
}
@@ -116,7 +116,7 @@ result_t SandBox::resolvePackage(v8::Local<v8::Object> mods, exlib::string& fnam
if (!main->IsString() && !main->IsStringObject())
return CHECK_ERROR(Runtime::setError("SandBox: Invalid package.json"));

resolvePath(fname, *v8::String::Utf8Value(main));
resolvePath(fname, ToCString(v8::String::Utf8Value(main)));
path_base::normalize(fname, fname);

hr = resolveFile(mods, fname, data, retVal);
@@ -734,7 +734,7 @@ result_t deep_has_prop(v8::Local<v8::Value> object, v8::Local<v8::Value> prop,
v8::String::Utf8Value s(prop);
const char *p, *p1;

p = *s;
p = ToCString(s);
while ((p1 = qstrchr(p, '.')) != NULL) {
object = v->Get(isolate->NewString(p, (int32_t)(p1 - p)));

@@ -836,7 +836,7 @@ result_t deep_has_val(v8::Local<v8::Value> object, v8::Local<v8::Value> prop,
v8::String::Utf8Value s(prop);
const char *p, *p1;

p = *s;
p = ToCString(s);
while ((p1 = qstrchr(p, '.')) != NULL) {
object = v->Get(isolate->NewString(p, (int32_t)(p1 - p)));

@@ -173,7 +173,7 @@ inline result_t _map(LruCache* o, v8::Local<v8::Object> m,

for (i = 0; i < len; i++) {
v8::Local<v8::Value> k = ks->Get(i);
(o->*fn)(*v8::String::Utf8Value(k), m->Get(k));
(o->*fn)(ToCString(v8::String::Utf8Value(k)), m->Get(k));
}

return 0;
@@ -281,7 +281,7 @@ result_t util_base::omit(v8::Local<v8::Value> v, OptArgs keys,
for (i = 0; i < len; i++) {
v8::Local<v8::Value> key = keys1->Get(i);

if (_map.find(*v8::String::Utf8Value(key)) == _map.end())
if (_map.find(ToCString(v8::String::Utf8Value(key))) == _map.end())
obj1->Set(key, obj->Get(key));
}

Oops, something went wrong.

0 comments on commit 74ebf67

Please sign in to comment.
You can’t perform that action at this time.