Commit ad59f157 authored by Philip Chimento's avatar Philip Chimento 🚮 Committed by Philip Chimento

js: Remove deprecated API that is now not public

Now this API is not public anymore, the deprecated functions can be
removed entirely.

https://bugzilla.gnome.org/show_bug.cgi?id=772386
parent f0bbf8fb
......@@ -82,7 +82,6 @@ libgjs_la_SOURCES = \
gjs/jsapi-private.h \
gjs/jsapi-util.cpp \
gjs/jsapi-dynamic-class.cpp \
gjs/jsapi-util-array.cpp \
gjs/jsapi-util-error.cpp \
gjs/jsapi-util-string.cpp \
gjs/mem.cpp \
......
......@@ -41,30 +41,7 @@ _Pragma("clang diagnostic pop")
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
_Pragma("GCC diagnostic pop")
#endif
#include <stdbool.h>
#include <glib.h>
#include "jsapi-util.h"
G_BEGIN_DECLS
#define JSVAL_IS_OBJECT(obj) \
_Pragma("GCC warning \"JSVAL_IS_OBJECT is deprecated. Use JS::Value::isObjectOrNull() instead.\"") \
((obj).isObjectOrNull())
#define JS_GetGlobalObject(cx) \
_Pragma("GCC warning \"JS_GetGlobalObject is deprecated. Use JS_GetGlobalForObject() or JS_GetGlobalForScopeChain() instead.\"") \
gjs_get_global_object(cx)
static bool G_GNUC_UNUSED G_GNUC_DEPRECATED_FOR(JS::NumberValue)
JS_NewNumberValue(JSContext *cx,
double d,
JS::Value *rval)
{
*rval = JS_NumberValue(d);
return rval->isNumber();
}
G_END_DECLS
#endif /* __GJS_COMPAT_H__ */
......@@ -35,20 +35,6 @@
#include <string.h>
#include <math.h>
/*
* This shim was because of a bug in JS_NewObjectForConstructor in JS 1.8.5. It
* attempted to retrieve the JSClass from private fields in the constructor
* function, which failed for our "dynamic classes".
* This function is deprecated.
*/
JSObject *
gjs_new_object_for_constructor(JSContext *context,
JSClass *clasp,
JS::Value *vp)
{
return JS_NewObjectForConstructor(context, clasp, vp);
}
bool
gjs_init_class_dynamic(JSContext *context,
JSObject *in_object,
......
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/*
* Copyright (c) 2008 litl, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <config.h>
#include "jsapi-util.h"
#include "compat.h"
/* Maximum number of elements allowed in a GArray of rooted JS::Values.
* We pre-alloc that amount and then never allow the array to grow,
* or we'd have invalid memory rooted if the internals of GArray decide
* to move the contents to a new memory area
*/
#define ARRAY_MAX_LEN 32
/**
* gjs_rooted_array_new:
*
* Creates an opaque data type that holds JS::Values and keeps
* their location (NOT their value) GC-rooted.
*
* Deprecated: Use JS::AutoValueVector instead.
*
* Returns: an opaque object prepared to hold GC root locations.
**/
GjsRootedArray*
gjs_rooted_array_new()
{
GArray *array;
/* we prealloc ARRAY_MAX_LEN to avoid realloc */
array = g_array_sized_new(false, /* zero-terminated */
false, /* clear */
sizeof(JS::Value), /* element size */
ARRAY_MAX_LEN); /* reserved size */
return (GjsRootedArray*) array;
}
/* typesafe wrapper */
static void
add_root_jsval(JSContext *context,
JS::Value *value_p)
{
JS_BeginRequest(context);
JS_AddValueRoot(context, value_p);
JS_EndRequest(context);
}
/* typesafe wrapper */
static void
remove_root_jsval(JSContext *context,
JS::Value *value_p)
{
JS_BeginRequest(context);
JS_RemoveValueRoot(context, value_p);
JS_EndRequest(context);
}
/**
* gjs_rooted_array_append:
* @context: a #JSContext
* @array: a #GjsRootedArray created by gjs_rooted_array_new()
* @value: a JS::Value
*
* Appends @value to @array, calling JS_AddValueRoot on the location where it's
* stored.
*
* Deprecated: Use JS::AutoValueVector instead.
**/
void
gjs_rooted_array_append(JSContext *context,
GjsRootedArray *array,
JS::Value value)
{
GArray *garray;
g_return_if_fail(context != NULL);
g_return_if_fail(array != NULL);
garray = (GArray*) array;
if (garray->len >= ARRAY_MAX_LEN) {
gjs_throw(context, "Maximum number of values (%d)",
ARRAY_MAX_LEN);
return;
}
g_array_append_val(garray, value);
add_root_jsval(context, & g_array_index(garray, JS::Value, garray->len - 1));
}
/**
* gjs_rooted_array_get:
* @context: a #JSContext
* @array: an array
* @i: element to return
*
* Deprecated: Use JS::AutoValueVector instead.
*
* Returns: value of an element
*/
JS::Value
gjs_rooted_array_get(JSContext *context,
GjsRootedArray *array,
int i)
{
GArray *garray;
g_return_val_if_fail(context != NULL, JS::UndefinedValue());
g_return_val_if_fail(array != NULL, JS::UndefinedValue());
garray = (GArray*) array;
if (i < 0 || i >= (int) garray->len) {
gjs_throw(context, "Index %d is out of range", i);
return JS::UndefinedValue();
}
return g_array_index(garray, JS::Value, i);
}
/**
* gjs_rooted_array_get_data:
* @context: a #JSContext
* @array: an array
*
* Deprecated: Use JS::AutoValueVector instead.
*
* Returns: the rooted JS::Value locations in the array
*/
JS::Value *
gjs_rooted_array_get_data(JSContext *context,
GjsRootedArray *array)
{
GArray *garray;
g_return_val_if_fail(context != NULL, NULL);
g_return_val_if_fail(array != NULL, NULL);
garray = (GArray*) array;
return (JS::Value *) garray->data;
}
/**
* gjs_rooted_array_get_length:
* @context: a #JSContext
* @array: an array
*
* Deprecated: Use JS::AutoValueVector instead.
*
* Returns: number of JS::Value in the rooted array
*/
int
gjs_rooted_array_get_length (JSContext *context,
GjsRootedArray *array)
{
GArray *garray;
g_return_val_if_fail(context != NULL, 0);
g_return_val_if_fail(array != NULL, 0);
garray = (GArray*) array;
return garray->len;
}
/**
* gjs_root_value_locations:
* @context: a #JSContext
* @locations: contiguous locations in memory that store JS::Values (must be
* initialized)
* @n_locations: the number of locations to root
*
* Calls JS_AddValueRoot() on each address in @locations.
*
* Deprecated: Use JS::AutoValueArray or JS::AutoValueVector instead.
**/
void
gjs_root_value_locations(JSContext *context,
JS::Value *locations,
int n_locations)
{
int i;
g_return_if_fail(context != NULL);
g_return_if_fail(locations != NULL);
g_return_if_fail(n_locations >= 0);
JS_BeginRequest(context);
for (i = 0; i < n_locations; i++) {
add_root_jsval(context, ((JS::Value *)locations) + i);
}
JS_EndRequest(context);
}
/**
* gjs_unroot_value_locations:
* @context: a #JSContext
* @locations: contiguous locations in memory that store JS::Values and have
* been added as GC roots
* @n_locations: the number of locations to unroot
*
* Calls JS_RemoveValueRoot() on each address in @locations.
*
* Deprecated: Use JS::AutoValueArray or JS::AutoValueVector instead.
**/
void
gjs_unroot_value_locations(JSContext *context,
JS::Value *locations,
int n_locations)
{
int i;
g_return_if_fail(context != NULL);
g_return_if_fail(locations != NULL);
g_return_if_fail(n_locations >= 0);
JS_BeginRequest(context);
for (i = 0; i < n_locations; i++) {
remove_root_jsval(context, ((JS::Value *)locations) + i);
}
JS_EndRequest(context);
}
/**
* gjs_set_values:
* @context: a #JSContext
* @locations: array of JS::Value
* @n_locations: the number of elements to set
* @initializer: what to set each element to
*
* Assigns initializer to each member of the given array.
*
* Deprecated: Use JS::AutoValueArray or JS::AutoValueVector instead.
**/
void
gjs_set_values(JSContext *context,
JS::Value *locations,
int n_locations,
JS::Value initializer)
{
int i;
g_return_if_fail(context != NULL);
g_return_if_fail(locations != NULL);
g_return_if_fail(n_locations >= 0);
for (i = 0; i < n_locations; i++) {
locations[i] = initializer;
}
}
/**
* gjs_rooted_array_free:
* @context: a #JSContext
* @array: a #GjsRootedArray created with gjs_rooted_array_new()
* @free_segment: whether or not to free and unroot the internal JS::Value array
*
* Frees the memory allocated for the #GjsRootedArray. If @free_segment is
* true the internal memory block allocated for the JS::Value array will
* be freed and unrooted also.
*
* Deprecated: Use JS::AutoValueVector instead.
*
* Returns: the JS::Value array if it was not freed
**/
JS::Value *
gjs_rooted_array_free(JSContext *context,
GjsRootedArray *array,
bool free_segment)
{
GArray *garray;
g_return_val_if_fail(context != NULL, NULL);
g_return_val_if_fail(array != NULL, NULL);
garray = (GArray*) array;
if (free_segment)
gjs_unroot_value_locations(context, (JS::Value *) garray->data, garray->len);
return (JS::Value *) g_array_free(garray, free_segment);
}
......@@ -814,24 +814,6 @@ gjs_get_type_name(JS::Value value)
}
}
/**
* gjs_value_to_int64:
* @context: the Javascript context object
* @val: Javascript value to convert
* @result: location to store the return value
*
* Converts a Javascript value into the nearest 64 bit signed value.
*
* Deprecated: Use JS::ToInt64() instead.
*/
bool
gjs_value_to_int64(JSContext *context,
const JS::Value val,
gint64 *result)
{
return JS::ToInt64(context, val, (int64_t *) result);
}
static bool
gjs_parse_args_valist (JSContext *context,
const char *function_name,
......
......@@ -271,11 +271,6 @@ bool gjs_object_require_property (JSContext *context,
jsid property_name,
JS::Value *value_p);
JSObject *gjs_new_object_for_constructor (JSContext *context,
JSClass *clasp,
JS::Value *vp)
G_GNUC_DEPRECATED_FOR(JS_NewObjectForConstructor);
bool gjs_init_class_dynamic (JSContext *context,
JSObject *in_object,
JSObject *parent_proto,
......@@ -399,11 +394,6 @@ bool gjs_unichar_from_string (JSContext *context,
const char* gjs_get_type_name (JS::Value value);
bool gjs_value_to_int64 (JSContext *context,
const JS::Value val,
gint64 *result)
G_GNUC_DEPRECATED_FOR(JS::ToInt64);
bool gjs_parse_args (JSContext *context,
const char *function_name,
const char *format,
......@@ -417,40 +407,6 @@ bool gjs_parse_call_args (JSContext *context,
JS::CallArgs &args,
...);
GjsRootedArray* gjs_rooted_array_new (void)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector);
void gjs_rooted_array_append (JSContext *context,
GjsRootedArray *array,
JS::Value value)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector::append);
JS::Value gjs_rooted_array_get (JSContext *context,
GjsRootedArray *array,
int i)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector::operator[]);
JS::Value *gjs_rooted_array_get_data (JSContext *context,
GjsRootedArray *array)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector::operator[]);
int gjs_rooted_array_get_length (JSContext *context,
GjsRootedArray *array)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector::length);
JS::Value *gjs_rooted_array_free (JSContext *context,
GjsRootedArray *array,
bool free_segment)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector);
void gjs_set_values (JSContext *context,
JS::Value *locations,
int n_locations,
JS::Value initializer)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector);
void gjs_root_value_locations (JSContext *context,
JS::Value *locations,
int n_locations)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector);
void gjs_unroot_value_locations (JSContext *context,
JS::Value *locations,
int n_locations)
G_GNUC_DEPRECATED_FOR(JS::AutoValueVector);
/* Functions intended for more "internal" use */
void gjs_maybe_gc (JSContext *context);
......
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