Subject: [gjs/wip/ptomato/mozjs38: 10/17] WIP - Adapt to
new mozilla::Maybe API



commit e95df708a591874ca2fd59de33ce0ebc0e0b4a31
Author: Philip Chimento <[email protected]>
Date: Wed Jan 11 23:18:42 2017 -0800

WIP - Adapt to new mozilla::Maybe API

This needs some more looking at, I'm not sure what the most idiomatic use
is.

gi/function.cpp | 15 +++++++--------
gi/gerror.cpp | 7 +++----
gjs/stack.cpp | 10 +++++-----
3 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 8105370..4deb18a 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1009,7 +1009,7 @@ gjs_invoke_c_function(JSContext
*context,
did_throw_gerror = false;
}

- if (!js_rval.empty())
+ if (js_rval)
js_rval.ref().setUndefined();

/* Only process return values if the function didn't throw */
@@ -1039,7 +1039,7 @@ gjs_invoke_c_function(JSContext
*context,
&arg_type_info,

&out_arg_cvalues[array_length_pos],
true);
- if (!arg_failed && !js_rval.empty()) {
+ if (!arg_failed && js_rval) {
arg_failed = !gjs_value_from_explicit_array(context,

return_values[next_rval],
&return_info,
@@ -1055,7 +1055,7 @@ gjs_invoke_c_function(JSContext
*context,
&return_gargument))
failed = true;
} else {
- if (!js_rval.empty())
+ if (js_rval)
arg_failed = !gjs_value_from_g_argument(context,

return_values[next_rval],
&return_info,
&return_gargument,
@@ -1172,7 +1172,7 @@ release:

array_length_pos = g_type_info_get_array_length(&arg_type_info);

- if (!js_rval.empty()) {
+ if (js_rval) {
if (array_length_pos >= 0) {
GIArgInfo array_length_arg;
GITypeInfo array_length_type_info;
@@ -1266,7 +1266,7 @@ release:
* on its own, otherwise return a JavaScript array with
* [return value, out arg 1, out arg 2, ...]
*/
- if (!js_rval.empty()) {
+ if (js_rval) {
if (function->js_out_argc == 1) {
js_rval.ref().set(return_values[0]);
} else {
@@ -1316,8 +1316,7 @@ function_call(JSContext *context,
return true; /* we are the prototype, or have the wrong class */

/* COMPAT: mozilla::Maybe gains a much more usable API in future versions
*/
- mozilla::Maybe<JS::MutableHandleValue> m_retval;
- m_retval.construct(&retval);
+ mozilla::Maybe<JS::MutableHandleValue>
m_retval(mozilla::Some<JS::MutableHandleValue>(&retval));
success = gjs_invoke_c_function(context, priv, object, js_argv, m_retval,
NULL);
if (success)
@@ -1767,7 +1766,7 @@ gjs_invoke_c_function_uncached(JSContext
*context,

/* COMPAT: mozilla::Maybe gains a much more usable API in future versions */
mozilla::Maybe<JS::MutableHandleValue> m_rval;
- m_rval.construct(rval);
+ m_rval.emplace(rval);
result = gjs_invoke_c_function(context, &function, obj, args, m_rval, NULL);
uninit_cached_function_data (&function);
return result;
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
index 1ac7d9e..3d5ac43 100644
--- a/gi/gerror.cpp
+++ b/gi/gerror.cpp
@@ -401,10 +401,9 @@ define_error_properties(JSContext *context,
{
JS::RootedValue stack(context), fileName(context), lineNumber(context);
/* COMPAT: mozilla::Maybe gains a much more usable API in future versions
*/
- mozilla::Maybe<JS::MutableHandleValue> m_stack, m_file, m_line;
- m_stack.construct(&stack);
- m_file.construct(&fileName);
- m_line.construct(&lineNumber);
+ auto m_stack = mozilla::Some<JS::MutableHandleValue>(&stack);
+ auto m_file = mozilla::Some<JS::MutableHandleValue>(&fileName);
+ auto m_line = mozilla::Some<JS::MutableHandleValue>(&lineNumber);

if (!gjs_context_get_frame_info(context, m_stack, m_file, m_line))
return;
diff --git a/gjs/stack.cpp b/gjs/stack.cpp
index 7dba9b1..45ef4fd 100644
--- a/gjs/stack.cpp
+++ b/gjs/stack.cpp
@@ -66,17 +66,17 @@ gjs_context_get_frame_info(JSContext
*context,
JS::RootedObject err_obj(context, JS_New(context, constructor,
JS::HandleValueArray::empty()));

- if (!stack.empty() &&
+ if (stack &&
!gjs_object_get_property_const(context, err_obj, GJS_STRING_STACK,
stack.ref()))
return false;

- if (!fileName.empty() &&
+ if (fileName &&
!gjs_object_get_property_const(context, err_obj, GJS_STRING_FILENAME,
fileName.ref()))
return false;

- if (!lineNumber.empty() &&
+ if (lineNumber &&
!gjs_object_get_property_const(context, err_obj,
GJS_STRING_LINE_NUMBER,
lineNumber.ref()))
return false;
@@ -95,8 +95,8 @@ gjs_context_print_stack_stderr(GjsContext *context)

/* Stderr is locale encoding, so we use string_to_filename here */
/* COMPAT: mozilla::Maybe gains a much more usable API in future versions
*/
- mozilla::Maybe<JS::MutableHandleValue> m_stack, m_file, m_line;
- m_stack.construct(&v_stack);
+ mozilla::Maybe<JS::MutableHandleValue>
m_stack(mozilla::Some<JS::MutableHandleValue>(&v_stack)),
+ m_file, m_line;
if (!gjs_context_get_frame_info(cx, m_stack, m_file, m_line) ||
!gjs_string_to_filename(cx, v_stack, &stack)) {
g_printerr("No stack trace available\n");
_______________________________________________
commits-list mailing list (read only)
https://mail.gnome.org/mailman/listinfo/commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.



Programming list archiving by: Enterprise Git Hosting