Commit 3ce20324 authored by Philip Chimento's avatar Philip Chimento 🚮 Committed by Philip Chimento

libgjs: Remove unused API

This removes API that was previously public, now private, and is not used
anywhere inside libgjs.

https://bugzilla.gnome.org/show_bug.cgi?id=772386
parent 0b9f7027
......@@ -83,8 +83,6 @@ EXTRA_DIST += \
$(srcdir)/test/gjs-test-coverage/loadedJSFromResource.js \
$(NULL)
## -rdynamic makes backtraces work
gjs_tests_LDFLAGS = -rdynamic
gjs_tests_LDADD = \
libgjs.la \
$(GJSTESTS_LIBS)
......
......@@ -60,7 +60,7 @@ libgjs_la_CPPFLAGS = \
libgjs_la_LDFLAGS = \
-export-symbols-regex "^[^_]" -version-info 0:0:0 \
-no-undefined \
-rdynamic
$(NULL)
libgjs_la_LIBADD = \
$(GJS_LIBS)
......
......@@ -133,8 +133,6 @@ AC_SUBST([READLINE_LIBS])
# End of readline checks: restore LIBS
LIBS=$LIBS_no_readline
AC_CHECK_FUNCS([backtrace])
AC_ARG_ENABLE(installed_tests,
[AS_HELP_STRING([--enable-installed-tests],
[Install test programs @<:@default: no@:>@])])
......
......@@ -79,7 +79,7 @@ _gjs_flags_value_is_valid(JSContext *context,
return true;
}
bool
static bool
_gjs_enum_value_is_valid(JSContext *context,
GIEnumInfo *enum_info,
gint64 value)
......
......@@ -102,10 +102,6 @@ bool _gjs_flags_value_is_valid (JSContext *context,
GType gtype,
gint64 value);
bool _gjs_enum_value_is_valid (JSContext *context,
GIEnumInfo *enum_info,
gint64 value);
gint64 _gjs_enum_from_int (GIEnumInfo *enum_info,
int int_value);
......
......@@ -44,8 +44,7 @@ typedef GIStructInfo GIBoxedInfo;
void gjs_define_boxed_class (JSContext *context,
JSObject *in_object,
GIBoxedInfo *info);
JSObject* gjs_lookup_boxed_prototype (JSContext *context,
GIBoxedInfo *info);
void* gjs_c_struct_from_boxed (JSContext *context,
JS::HandleObject obj);
JSObject* gjs_boxed_from_c_struct (JSContext *context,
......
......@@ -36,30 +36,6 @@
#include "enumeration.h"
JSObject*
gjs_lookup_enumeration(JSContext *context,
GIEnumInfo *info)
{
JSObject *in_object;
const char *enum_name;
JS::Value value;
in_object = gjs_lookup_namespace_object(context, (GIBaseInfo*) info);
if (G_UNLIKELY (!in_object))
return NULL;
enum_name = g_base_info_get_name((GIBaseInfo*) info);
if (!JS_GetProperty(context, in_object, enum_name, &value))
return NULL;
if (G_UNLIKELY (!value.isObject()))
return NULL;
return &value.toObject();
}
static bool
gjs_define_enum_value(JSContext *context,
JSObject *in_object,
......
......@@ -42,8 +42,6 @@ bool gjs_define_enum_static_methods (JSContext *context,
bool gjs_define_enumeration (JSContext *context,
JSObject *in_object,
GIEnumInfo *info);
JSObject* gjs_lookup_enumeration (JSContext *context,
GIEnumInfo *info);
G_END_DECLS
......
......@@ -81,8 +81,6 @@ bool gjs_invoke_constructor_from_c(JSContext *context,
JS::Value *argv,
GArgument *rvalue);
void gjs_init_cinvoke_profiling (void);
G_END_DECLS
#endif /* __GJS_FUNCTION_H__ */
......@@ -821,14 +821,6 @@ gjs_g_fundamental_from_object(JSContext *context,
return priv->gfundamental;
}
bool
gjs_typecheck_is_fundamental(JSContext *context,
JS::HandleObject object,
bool throw_error)
{
return do_base_typecheck(context, object, throw_error);
}
bool
gjs_typecheck_fundamental(JSContext *context,
JS::HandleObject object,
......
......@@ -53,9 +53,6 @@ bool gjs_typecheck_fundamental(JSContext *context,
GType expected_gtype,
bool throw_error);
bool gjs_typecheck_is_fundamental (JSContext *context,
JSObject *object,
bool throw_error);
void* gjs_fundamental_ref (JSContext *context,
void *fobj);
void gjs_fundamental_unref (JSContext *context,
......
......@@ -32,11 +32,6 @@
G_BEGIN_DECLS
JS::Value gjs_gtype_create_proto (JSContext *context,
JSObject *module,
const char *proto_name,
JSObject *parent);
JSObject * gjs_gtype_create_gtype_wrapper (JSContext *context,
GType gtype);
......
......@@ -172,7 +172,7 @@ JSFunctionSpec gjs_keep_alive_proto_funcs[] = {
JS_FS_END
};
JSObject*
static JSObject *
gjs_keep_alive_new(JSContext *context)
{
KeepAlive *priv;
......
......@@ -54,7 +54,6 @@ typedef void (* GjsUnrootedFunc) (JSObject *obj,
void *data);
JSObject* gjs_keep_alive_new (JSContext *context);
void gjs_keep_alive_add_child (JSObject *keep_alive,
GjsUnrootedFunc notify,
JSObject *child,
......
......@@ -43,8 +43,7 @@ JSObject* gjs_lookup_namespace_object (JSContext *context,
GIBaseInfo *info);
JSObject* gjs_lookup_namespace_object_by_name (JSContext *context,
jsid name);
JSObject* gjs_lookup_function_object (JSContext *context,
GIFunctionInfo *info);
JSObject * gjs_lookup_generic_constructor (JSContext *context,
GIBaseInfo *info);
JSObject * gjs_lookup_generic_prototype (JSContext *context,
......
......@@ -761,31 +761,6 @@ gjs_byte_array_from_byte_array (JSContext *context,
return object;
}
JSObject *
gjs_byte_array_from_bytes (JSContext *context,
GBytes *bytes)
{
ByteArrayInstance *priv;
g_return_val_if_fail(context != NULL, NULL);
g_return_val_if_fail(bytes != NULL, NULL);
JS::RootedObject object(context,
JS_NewObject(context, &gjs_byte_array_class,
byte_array_get_prototype(context), NULL));
if (!object) {
gjs_throw(context, "failed to create byte array");
return NULL;
}
priv = g_slice_new0(ByteArrayInstance);
g_assert(priv_from_js(context, object) == NULL);
JS_SetPrivate(object, priv);
priv->bytes = g_bytes_ref (bytes);
return object;
}
GBytes *
gjs_byte_array_get_bytes (JSContext *context,
JS::HandleObject object)
......
......@@ -39,8 +39,6 @@ bool gjs_define_byte_array_stuff (JSContext *context,
JSObject * gjs_byte_array_from_byte_array (JSContext *context,
GByteArray *array);
JSObject * gjs_byte_array_from_bytes (JSContext *context,
GBytes *bytes);
GByteArray *gjs_byte_array_get_byte_array(JSContext *context,
JS::HandleObject object);
......
......@@ -26,8 +26,6 @@
G_BEGIN_DECLS
GArray * gjs_fetch_statistics_from_js(GjsCoverage *coverage,
char **covered_paths);
GBytes * gjs_serialize_statistics(GjsCoverage *coverage);
JSString * gjs_deserialize_cache_to_object(GjsCoverage *coverage,
......
......@@ -1107,7 +1107,7 @@ gjs_deserialize_cache_to_object(GjsCoverage *coverage,
return gjs_deserialize_cache_to_object_for_compartment(context, global_object, cache_data);
}
GArray *
static GArray *
gjs_fetch_statistics_from_js(GjsCoverage *coverage,
gchar **coverage_files)
{
......
......@@ -301,6 +301,45 @@ gjs_string_readable (JSContext *context,
return g_string_free(buf, false);
}
static char *
_gjs_g_utf8_make_valid (const char *name)
{
GString *string;
const char *remainder, *invalid;
int remaining_bytes, valid_bytes;
g_return_val_if_fail (name != NULL, NULL);
string = NULL;
remainder = name;
remaining_bytes = strlen (name);
while (remaining_bytes != 0) {
if (g_utf8_validate (remainder, remaining_bytes, &invalid))
break;
valid_bytes = invalid - remainder;
if (string == NULL)
string = g_string_sized_new (remaining_bytes);
g_string_append_len (string, remainder, valid_bytes);
/* append U+FFFD REPLACEMENT CHARACTER */
g_string_append (string, "\357\277\275");
remaining_bytes -= valid_bytes + 1;
remainder = invalid + 1;
}
if (string == NULL)
return g_strdup (name);
g_string_append (string, remainder);
g_assert (g_utf8_validate (string->str, -1, NULL));
return g_string_free (string, false);
}
/**
* gjs_value_debug_string:
* @context:
......@@ -369,105 +408,6 @@ gjs_value_debug_string(JSContext *context,
return debugstr;
}
void
gjs_log_object_props(JSContext *context,
JSObject *obj,
GjsDebugTopic topic,
const char *prefix)
{
JSObject *props_iter;
jsid prop_id;
JS_BeginRequest(context);
props_iter = JS_NewPropertyIterator(context, obj);
if (props_iter == NULL) {
gjs_log_exception(context);
goto done;
}
prop_id = JSID_VOID;
if (!JS_NextProperty(context, props_iter, &prop_id))
goto done;
while (!JSID_IS_VOID(prop_id)) {
JS::Value propval;
char *debugstr;
char *name = NULL;
if (!JS_GetPropertyById(context, obj, prop_id, &propval))
goto next;
if (!gjs_get_string_id(context, prop_id, &name))
goto next;
debugstr = gjs_value_debug_string(context, propval);
gjs_debug(topic,
"%s%s = '%s'",
prefix, name,
debugstr);
g_free(debugstr);
next:
g_free(name);
prop_id = JSID_VOID;
if (!JS_NextProperty(context, props_iter, &prop_id))
break;
}
done:
JS_EndRequest(context);
}
void
gjs_explain_scope(JSContext *context,
const char *title)
{
JSObject *global;
JSObject *parent;
GString *chain;
char *debugstr;
gjs_debug(GJS_DEBUG_SCOPE,
"=== %s ===",
title);
JS_BeginRequest(context);
gjs_debug(GJS_DEBUG_SCOPE,
" Context: %p %s",
context,
"");
global = gjs_get_global_object(context);
debugstr = gjs_value_debug_string(context, JS::ObjectOrNullValue(global));
gjs_debug(GJS_DEBUG_SCOPE,
" Global: %p %s",
global, debugstr);
g_free(debugstr);
parent = JS_GetGlobalForScopeChain(context);
chain = g_string_new(NULL);
while (parent != NULL) {
char *debug;
debug = gjs_value_debug_string(context, JS::ObjectOrNullValue(parent));
if (chain->len > 0)
g_string_append(chain, ", ");
g_string_append_printf(chain, "%p %s",
parent, debug);
g_free(debug);
parent = JS_GetParent(parent);
}
gjs_debug(GJS_DEBUG_SCOPE,
" Chain: %s",
chain->str);
g_string_free(chain, true);
JS_EndRequest(context);
}
static char *
utf8_exception_from_non_gerror_value(JSContext *cx,
JS::Value exc)
......@@ -586,9 +526,8 @@ gjs_log_exception_full(JSContext *context,
return true;
}
static bool
log_and_maybe_keep_exception(JSContext *context,
bool keep)
bool
gjs_log_exception(JSContext *context)
{
bool retval = false;
......@@ -602,12 +541,6 @@ log_and_maybe_keep_exception(JSContext *context,
gjs_log_exception_full(context, exc, NULL);
/* We clear above and then set it back so any exceptions
* from the logging process don't overwrite the original
*/
if (keep)
JS_SetPendingException(context, exc);
retval = true;
out:
......@@ -616,18 +549,6 @@ log_and_maybe_keep_exception(JSContext *context,
return retval;
}
bool
gjs_log_exception(JSContext *context)
{
return log_and_maybe_keep_exception(context, false);
}
bool
gjs_log_and_keep_exception(JSContext *context)
{
return log_and_maybe_keep_exception(context, true);
}
static void
try_to_chain_stack_trace(JSContext *src_context,
JSContext *dst_context,
......@@ -755,42 +676,6 @@ log_prop(JSContext *context,
return true;
}
bool
gjs_get_prop_verbose_stub(JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p)
{
return log_prop(context, obj, id, value_p, "get");
}
bool
gjs_set_prop_verbose_stub(JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p)
{
return log_prop(context, obj, id, value_p, "set");
}
bool
gjs_add_prop_verbose_stub(JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p)
{
return log_prop(context, obj, id, value_p, "add");
}
bool
gjs_delete_prop_verbose_stub(JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p)
{
return log_prop(context, obj, id, value_p, "delete");
}
/* get a debug string for type tag in JS::Value */
const char*
gjs_get_type_name(JS::Value value)
......
......@@ -356,23 +356,14 @@ void gjs_throw_g_error (JSContext *context,
GError *error);
bool gjs_log_exception (JSContext *context);
bool gjs_log_and_keep_exception (JSContext *context);
bool gjs_move_exception (JSContext *src_context,
JSContext *dest_context);
bool gjs_log_exception_full (JSContext *context,
JS::Value exc,
JSString *message);
#ifdef __GJS_UTIL_LOG_H__
void gjs_log_object_props (JSContext *context,
JSObject *obj,
GjsDebugTopic topic,
const char *prefix);
#endif
char* gjs_value_debug_string (JSContext *context,
JS::Value value);
void gjs_explain_scope (JSContext *context,
const char *title);
bool gjs_call_function_value(JSContext *context,
JSObject *obj,
......@@ -385,22 +376,6 @@ void gjs_error_reporter (JSContext *context,
const char *message,
JSErrorReport *report);
JSObject* gjs_get_global_object (JSContext *cx);
bool gjs_get_prop_verbose_stub (JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p);
bool gjs_set_prop_verbose_stub (JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p);
bool gjs_add_prop_verbose_stub (JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p);
bool gjs_delete_prop_verbose_stub (JSContext *context,
JSObject *obj,
JS::Value id,
JS::Value *value_p);
JSBool gjs_string_to_utf8 (JSContext *context,
const JS::Value string_val,
......
......@@ -153,7 +153,7 @@ gjs_console_readline(JSContext *cx, char **bufp, FILE *file, const char *prompt)
}
#endif
bool
static bool
gjs_console_interact(JSContext *context,
unsigned argc,
JS::Value *vp)
......
......@@ -32,9 +32,6 @@ G_BEGIN_DECLS
bool gjs_define_console_stuff (JSContext *context,
JSObject **module_out);
bool gjs_console_interact (JSContext *context,
unsigned argc,
JS::Value *vp);
G_END_DECLS
......
......@@ -26,9 +26,6 @@
#include "crash.h"
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
......@@ -39,63 +36,6 @@
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_BACKTRACE
static void
unbuffered_write_stderr(const char *s)
{
size_t len;
len = strlen(s);
write(STDERR_FILENO, s, len);
}
static void
gjs_print_maps(void)
{
int fd;
fd = open("/proc/self/maps", O_RDONLY);
if (fd != -1) {
char buf[128];
size_t n;
while ((n = read(fd, buf, sizeof(buf))) > 0) {
write(STDERR_FILENO, buf, n);
}
(void)close(fd);
unbuffered_write_stderr("\n");
}
}
#endif
/* this only works if we build with -rdynamic */
void
gjs_print_backtrace(void)
{
#ifdef HAVE_BACKTRACE
void *bt[500];
int bt_size;
char buf[128];
bt_size = backtrace(bt, 500);
/* Avoid dynamic allocations since we may in SIGSEGV signal handler, so use
* backtrace_symbols_fd */
unbuffered_write_stderr("\n");
backtrace_symbols_fd(bt, bt_size, STDERR_FILENO);
unbuffered_write_stderr("\n");
sprintf(buf, "backtrace pid %lu\n\n", (gulong) getpid());
unbuffered_write_stderr(buf);
/* best effort attempt to extract shared library relocations so that
* mapping backtrace addresses to symbols is possible after the fact */
gjs_print_maps();
#endif
}
/* Fork a process that waits the given time then
* sends us ABRT
*/
......
......@@ -27,7 +27,6 @@
G_BEGIN_DECLS
void gjs_print_backtrace (void);
void gjs_crash_after_timeout (int seconds);
G_END_DECLS
......
......@@ -46,11 +46,10 @@ get_first_one_predicate(void *key,
return true;
}
static bool
remove_or_steal_one(GHashTable *hash,
void **key_p,
void **value_p,
bool steal)
bool
gjs_g_hash_table_steal_one(GHashTable *hash,
void **key_p,
void **value_p)
{
StoreOneData sod;
......@@ -66,30 +65,11 @@ remove_or_steal_one(GHashTable *hash,
if (value_p)
*value_p = sod.value;
if (steal)
g_hash_table_steal(hash, sod.key);
else
g_hash_table_remove(hash, sod.key);
g_hash_table_steal(hash, sod.key);
return sod.value != NULL;
}
bool
gjs_g_hash_table_remove_one(GHashTable *hash,
void **key_p,
void **value_p)
{
return remove_or_steal_one(hash, key_p, value_p, false);
}
bool
gjs_g_hash_table_steal_one(GHashTable *hash,
void **key_p,
void **value_p)
{
return remove_or_steal_one(hash, key_p, value_p, true);
}
/** gjs_g_strv_concat:
*
* Concate an array of string arrays to one string array. The strings in each
......@@ -126,43 +106,3 @@ gjs_g_strv_concat(char ***strv_array, int len)
return (char**)g_ptr_array_free(array, false);
}
gchar *
_gjs_g_utf8_make_valid (const gchar *name)
{
GString *string;
const gchar *remainder, *invalid;
gint remaining_bytes, valid_bytes;
g_return_val_if_fail (name != NULL, NULL);
string = NULL;
remainder = name;
remaining_bytes = strlen (name);
while (remaining_bytes != 0)
{
if (g_utf8_validate (remainder, remaining_bytes, &invalid))
break;
valid_bytes = invalid - remainder;
if (string == NULL)
string = g_string_sized_new (remaining_bytes);
g_string_append_len (string, remainder, valid_bytes);
/* append U+FFFD REPLACEMENT CHARACTER */
g_string_append (string, "\357\277\275");
remaining_bytes -= valid_bytes + 1;
remainder = invalid + 1;
}
if (string == NULL)
return g_strdup (name);
g_string_append (string, remainder);
g_assert (g_utf8_validate (string->str, -1, NULL));
return g_string_free (string, false);
}
......@@ -28,11 +28,6 @@
G_BEGIN_DECLS
gchar * _gjs_g_utf8_make_valid (const gchar *name);
bool gjs_g_hash_table_remove_one (GHashTable *hash,
void **key_p,
void **value_p);
bool gjs_g_hash_table_steal_one (GHashTable *hash,
void **key_p,
void **value_p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment