[asterisk-commits] dlee: branch dlee/jansson r378904 - in /team/dlee/jansson: include/asterisk/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 21:25:14 CST 2013


Author: dlee
Date: Wed Jan  9 21:25:10 2013
New Revision: 378904

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378904
Log:
Rename suggestions from review

Modified:
    team/dlee/jansson/include/asterisk/json.h
    team/dlee/jansson/res/res_json.c
    team/dlee/jansson/tests/test_json.c

Modified: team/dlee/jansson/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/jansson/include/asterisk/json.h?view=diff&rev=378904&r1=378903&r2=378904
==============================================================================
--- team/dlee/jansson/include/asterisk/json.h (original)
+++ team/dlee/jansson/include/asterisk/json.h Wed Jan  9 21:25:10 2013
@@ -49,12 +49,12 @@
  * \brief Increase refcount on \a value.
  * \return The given \a value.
  */
-struct ast_json *ast_json_incref(struct ast_json *value);
+struct ast_json *ast_json_ref(struct ast_json *value);
 
 /*!
  * \brief Decrease refcount on \a value. If refcount reaches zero, \a value is freed.
  */
-void ast_json_decref(struct ast_json *value);
+void ast_json_unref(struct ast_json *value);
 
 /*!@}*/
 
@@ -133,12 +133,12 @@
  *
  * \return Newly constructed string element, or \c NULL on failure.
  */
-struct ast_json *ast_json_string(const char *value);
+struct ast_json *ast_json_string_create(const char *value);
 
 /*!
  * \brief Returns the string value of \a string, or \c NULL if it's not a JSON string.
  */
-const char *ast_json_string_value(const struct ast_json *string);
+const char *ast_json_string_get(const struct ast_json *string);
 
 /*!
  * \brief Changes the string value of \a string to \a value.
@@ -170,14 +170,14 @@
  *
  * \return Newly allocated integer, or \c NULL if allocation fails.
  */
-struct ast_json *ast_json_integer(intmax_t value);
+struct ast_json *ast_json_integer_create(intmax_t value);
 
 /*!
  * \brief Get the value from \a integer.
  *
  * \return integer value, or 0 for non-integers.
  */
-intmax_t ast_json_integer_value(const struct ast_json *integer);
+intmax_t ast_json_integer_get(const struct ast_json *integer);
 
 /*!
  * \brief Sets the value of \a integer.
@@ -195,7 +195,7 @@
  *
  * \return Newly allocated array, or \c NULL if allocation fails.
  */
-struct ast_json *ast_json_array(void);
+struct ast_json *ast_json_array_create(void);
 
 /*!
  * \brief Returns the size of \a array, or 0 if argument is not an array.
@@ -205,7 +205,7 @@
 /*!
  * \brief Returns the element in the \a index position from the \a array.
  *
- * The returned element is a borrowed reference; use ast_json_incref() to safely keep a
+ * The returned element is a borrowed reference; use ast_json_ref() to safely keep a
  * pointer to it.
  *
  * \return The specified element, or \c NULL if \a array not an array or \a index is out
@@ -216,7 +216,7 @@
 /*!
  * \brief Changes the \a index element in \a array to \a value.
  *
- * The array steals the \a value reference; use ast_json_incref() to safely keep a pointer
+ * The array steals the \a value reference; use ast_json_ref() to safely keep a pointer
  * to it.
  *
  * \return 0 on success, or -1 on failure.
@@ -226,7 +226,7 @@
 /*!
  * \brief Appends \a value to \a array.
  *
- * The array steals the \a value reference; use ast_json_incref() to safely keep a pointer
+ * The array steals the \a value reference; use ast_json_ref() to safely keep a pointer
  * to it.
  *
  * \return 0 on success, or -1 on failure.
@@ -236,7 +236,7 @@
 /*!
  * \brief Inserts \a value into \a array at position \a index.
  *
- * The array steals the \a value reference; use ast_json_incref() to safely keep a pointer
+ * The array steals the \a value reference; use ast_json_ref() to safely keep a pointer
  * to it.
  *
  * \return 0 on success, or -1 on failure.
@@ -260,7 +260,7 @@
 /*!
  * \brief Appends all elements from \a tail to \a array.
  *
- * The \a tail argument is left alone, so ast_json_decref() it when you are done with it.
+ * The \a tail argument is left alone, so ast_json_unref() it when you are done with it.
  *
  * \return 0 on success, or -1 on failure.
  */
@@ -275,7 +275,7 @@
  *
  * \return Newly allocated object, or \c NULL if allocation fails.
  */
-struct ast_json *ast_json_object(void);
+struct ast_json *ast_json_object_create(void);
 
 /*!
  * \brief Returns the size of \a object, or 0 if it's not a JSON object.
@@ -290,7 +290,7 @@
 /*!
  * \brief Sets the value of \a key to \a value in \a object.
  *
- * The object steals the \a value reference; use ast_json_incref() to safely keep a pointer
+ * The object steals the \a value reference; use ast_json_ref() to safely keep a pointer
  * to it.
  *
  * \return 0 on success, or -1 on error.
@@ -315,7 +315,7 @@
  * \brief Updates the elements of \a object with all of the elements \a other, overwriting
  * existing keys and adding new ones.
  *
- * The \a other argument is left alone, so ast_json_decref() it when you are done with it.
+ * The \a other argument is left alone, so ast_json_unref() it when you are done with it.
  *
  * \return 0 on success, or -1 on error.
  */
@@ -325,7 +325,7 @@
  * \brief Updates the elements of \a object with the elements of \a other, only
  * overwriting existing keys.
  *
- * The \a other argument is left alone, so ast_json_decref() it when you are done with it.
+ * The \a other argument is left alone, so ast_json_unref() it when you are done with it.
  *
  * \return 0 on success, or -1 on error.
  */
@@ -335,7 +335,7 @@
  * \brief Updates the elements of \a object with the elements of \a other, only adding new
  * ones, not changing existing values.
  *
- * The \a other argument is left alone, so ast_json_decref() it when you are done with it.
+ * The \a other argument is left alone, so ast_json_unref() it when you are done with it.
  *
  * \return 0 on success, or -1 on error.
  */
@@ -374,7 +374,7 @@
 /*!
  * \brief Returns value from \a iter.
  *
- * The returned element is a borrowed reference; use ast_json_incref() to safely
+ * The returned element is a borrowed reference; use ast_json_ref() to safely
  * keep a pointer to it.
  */
 struct ast_json *ast_json_object_iter_value(struct ast_json_iter *iter);
@@ -382,7 +382,7 @@
 /*!
  * \brief Sets the value in \a object at \a iter to \a value.
  *
- * The array steals the value reference; use ast_json_incref() to safely keep a
+ * The array steals the value reference; use ast_json_ref() to safely keep a
  * pointer to it.
  *
  * \return 0 on success, or -1 on error.
@@ -398,21 +398,21 @@
  *
  * Returned string must be freed by calling ast_free().
  */
-char *ast_json_dumps(struct ast_json *root);
+char *ast_json_dump_string(struct ast_json *root);
 
 /*!
  * \brief Writes JSON representation of \a root to \a output.
  *
  * \return 0 on success, or -1 on error.
  */
-int ast_json_dumpf(struct ast_json *root, FILE *output);
+int ast_json_dump_file(struct ast_json *root, FILE *output);
 
 /*!
  * \brief Writes JSON representation of \a root to a file at \a path.
  *
  * \return 0 on success, or -1 on error.
  */
-int ast_json_dump_file(struct ast_json *root, const char *path);
+int ast_json_dump_new_file(struct ast_json *root, const char *path);
 
 #define AST_JSON_ERROR_TEXT_LENGTH    160
 #define AST_JSON_ERROR_SOURCE_LENGTH   80
@@ -440,7 +440,7 @@
  *
  * \return Parsed JSON element, or \c NULL on error.
  */
-struct ast_json *ast_json_loads(const char *input, struct ast_json_error *error);
+struct ast_json *ast_json_load_string(const char *input, struct ast_json_error *error);
 
 /*!
  * \brief Parses \a buffer with length \a buflen into a JSON object or array.
@@ -449,7 +449,7 @@
  *
  * \return Parsed JSON element, or \c NULL on error.
  */
-struct ast_json *ast_json_loadb(const char *buffer, size_t buflen, struct ast_json_error *error);
+struct ast_json *ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error);
 
 /*!
  * \brief Parses \a input into JSON object or array.
@@ -458,7 +458,7 @@
  *
  * \return Parsed JSON element, or \c NULL on error.
  */
-struct ast_json *ast_json_loadf(FILE *input, struct ast_json_error *error);
+struct ast_json *ast_json_load_file(FILE *input, struct ast_json_error *error);
 
 /*!
  * \brief Parses file at \a path into JSON object or array.
@@ -467,7 +467,7 @@
  *
  * \return Parsed JSON element, or \c NULL on error.
  */
-struct ast_json *ast_json_load_file(const char *path, struct ast_json_error *error);
+struct ast_json *ast_json_load_new_file(const char *path, struct ast_json_error *error);
 
 /*!
  * \brief Helper for creating complex JSON values.

Modified: team/dlee/jansson/res/res_json.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/jansson/res/res_json.c?view=diff&rev=378904&r1=378903&r2=378904
==============================================================================
--- team/dlee/jansson/res/res_json.c (original)
+++ team/dlee/jansson/res/res_json.c Wed Jan  9 21:25:10 2013
@@ -60,13 +60,13 @@
 	json_set_alloc_funcs(malloc_fn, free_fn);
 }
 
-struct ast_json *ast_json_incref(struct ast_json *json)
+struct ast_json *ast_json_ref(struct ast_json *json)
 {
 	json_incref((json_t *)json);
 	return json;
 }
 
-void ast_json_decref(struct ast_json *json)
+void ast_json_unref(struct ast_json *json)
 {
 	json_decref((json_t *)json);
 }
@@ -127,12 +127,12 @@
 	return json_is_null((const json_t *)json);
 }
 
-struct ast_json *ast_json_string(const char *value)
+struct ast_json *ast_json_string_create(const char *value)
 {
 	return (struct ast_json *)json_string(value);
 }
 
-const char *ast_json_string_value(const struct ast_json *string)
+const char *ast_json_string_get(const struct ast_json *string)
 {
 	return json_string_value((json_t *)string);
 }
@@ -167,12 +167,12 @@
 	return (struct ast_json *)ret;
 }
 
-struct ast_json *ast_json_integer(intmax_t value)
+struct ast_json *ast_json_integer_create(intmax_t value)
 {
 	return (struct ast_json *)json_integer(value);
 }
 
-intmax_t ast_json_integer_value(const struct ast_json *integer)
+intmax_t ast_json_integer_get(const struct ast_json *integer)
 {
 	return json_integer_value((json_t *)integer);
 }
@@ -188,7 +188,7 @@
 	return json_equal((json_t *)lhs, (json_t *)rhs);
 }
 
-struct ast_json *ast_json_array(void)
+struct ast_json *ast_json_array_create(void)
 {
 	return (struct ast_json *)json_array();
 }
@@ -225,7 +225,7 @@
 	return json_array_extend((json_t *)array, (json_t *)tail);
 }
 
-struct ast_json *ast_json_object(void)
+struct ast_json *ast_json_object_create(void)
 {
 	return (struct ast_json *)json_object();
 }
@@ -340,18 +340,18 @@
 	return flags;
 }
 
-char *ast_json_dumps(struct ast_json *root)
+char *ast_json_dump_string(struct ast_json *root)
 {
 	return json_dumps((json_t *)root, dump_flags());
 }
-int ast_json_dumpf(struct ast_json *root, FILE *output)
+int ast_json_dump_file(struct ast_json *root, FILE *output)
 {
 	if (root && output) {
 		return json_dumpf((json_t *)root, output, dump_flags());
 	}
 	return -1;
 }
-int ast_json_dump_file(struct ast_json *root, const char *path)
+int ast_json_dump_new_file(struct ast_json *root, const char *path)
 {
 	return json_dump_file((json_t *)root, path, dump_flags());
 }
@@ -382,7 +382,7 @@
 	}
 }
 
-struct ast_json *ast_json_loads(const char *input, struct ast_json_error *error)
+struct ast_json *ast_json_load_string(const char *input, struct ast_json_error *error)
 {
 	json_error_t jansson_error = {};
 	struct ast_json *r = NULL;
@@ -394,14 +394,14 @@
 	}
 	return r;
 }
-struct ast_json *ast_json_loadb(const char *buffer, size_t buflen, struct ast_json_error *error)
+struct ast_json *ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error)
 {
 	json_error_t jansson_error = {};
 	struct ast_json *r = (struct ast_json *)json_loadb(buffer, buflen, 0, &jansson_error);
 	copy_error(error, &jansson_error);
 	return r;
 }
-struct ast_json *ast_json_loadf(FILE *input, struct ast_json_error *error)
+struct ast_json *ast_json_load_file(FILE *input, struct ast_json_error *error)
 {
 	json_error_t jansson_error = {};
 	struct ast_json *r = NULL;
@@ -413,7 +413,7 @@
 	}
 	return r;
 }
-struct ast_json *ast_json_load_file(const char *path, struct ast_json_error *error)
+struct ast_json *ast_json_load_new_file(const char *path, struct ast_json_error *error)
 {
 	json_error_t jansson_error = {};
 	struct ast_json *r = (struct ast_json *)json_load_file(path, 0, &jansson_error);

Modified: team/dlee/jansson/tests/test_json.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/jansson/tests/test_json.c?view=diff&rev=378904&r1=378903&r2=378904
==============================================================================
--- team/dlee/jansson/tests/test_json.c (original)
+++ team/dlee/jansson/tests/test_json.c Wed Jan  9 21:25:10 2013
@@ -90,11 +90,11 @@
 	 * decent backtrace if a free() fails.
 	 */
 	void clean_vars(void) {
-		ast_json_decref(uut);
-		ast_json_decref(expected);
-		ast_json_decref(tail);
-		ast_json_decref(merge);
-		ast_json_decref(inner_child);
+		ast_json_unref(uut);
+		ast_json_unref(expected);
+		ast_json_unref(tail);
+		ast_json_unref(merge);
+		ast_json_unref(inner_child);
 		uut = expected = tail = merge = inner_child = NULL;
 		iter = NULL;
 		uut_res = count = 0;
@@ -132,8 +132,8 @@
 	ast_json_set_alloc_funcs(json_debug_malloc, json_debug_free);
 
 	/* incref and decref should be NULL safe */
-	ast_json_incref(NULL);
-	ast_json_decref(NULL);
+	ast_json_ref(NULL);
+	ast_json_unref(NULL);
 	CLEAN_VARS();
 	CLEAN_VARS();
 
@@ -188,31 +188,31 @@
 	ast_test_check(res, !ast_json_is_true(NULL));
 
 	/* Basic string tests */
-	uut = ast_json_string("Hello, json");
+	uut = ast_json_string_create("Hello, json");
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, AST_JSON_STRING == ast_json_typeof(uut));
-	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_value(uut)));
+	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_get(uut)));
 
 	uut_res = ast_json_string_set(uut, NULL);
 	ast_test_check(res, -1 == uut_res);
-	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_value(uut)));
+	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_get(uut)));
 
 	uut_res = ast_json_string_set(uut, "Not UTF-8 - \xff");
 	ast_test_check(res, -1 == uut_res);
-	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_value(uut)));
+	ast_test_check(res, 0 == strcmp("Hello, json", ast_json_string_get(uut)));
 
 	uut_res = ast_json_string_set(uut, "Is UTF-8 - \xE2\x98\xBA");
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, 0 == strcmp("Is UTF-8 - \xE2\x98\xBA", ast_json_string_value(uut)));
+	ast_test_check(res, 0 == strcmp("Is UTF-8 - \xE2\x98\xBA", ast_json_string_get(uut)));
 
 	uut_res = ast_json_string_set(uut, "Goodbye, json");
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, 0 == strcmp("Goodbye, json", ast_json_string_value(uut)));
+	ast_test_check(res, 0 == strcmp("Goodbye, json", ast_json_string_get(uut)));
 	CLEAN_VARS();
 
 	/* formatted string */
 	uut = ast_json_stringf("Hello, %s", "json");
-	expected = ast_json_string("Hello, json");
+	expected = ast_json_string_create("Hello, json");
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, ast_json_equal(expected, uut));
 	CLEAN_VARS();
@@ -223,7 +223,7 @@
 	CLEAN_VARS();
 
 	/* NULL string */
-	uut = ast_json_string(NULL);
+	uut = ast_json_string_create(NULL);
 	ast_test_check(res, NULL == uut);
 	CLEAN_VARS();
 
@@ -233,71 +233,71 @@
 	CLEAN_VARS();
 
 	/* NULL JSON strings */
-	ast_test_check(res, NULL == ast_json_string(NULL));
-	ast_test_check(res, NULL == ast_json_string_value(NULL));
+	ast_test_check(res, NULL == ast_json_string_create(NULL));
+	ast_test_check(res, NULL == ast_json_string_get(NULL));
 	ast_test_check(res, -1 == ast_json_string_set(NULL, "not null"));
 
 	/* string_value from non-string elements should return NULL */
-	ast_test_check(res, NULL == ast_json_string_value(ast_json_null()));
-	ast_test_check(res, NULL == ast_json_string_value(ast_json_false()));
-	ast_test_check(res, NULL == ast_json_string_value(ast_json_true()));
+	ast_test_check(res, NULL == ast_json_string_get(ast_json_null()));
+	ast_test_check(res, NULL == ast_json_string_get(ast_json_false()));
+	ast_test_check(res, NULL == ast_json_string_get(ast_json_true()));
 
 	/* Integer tests */
-	uut = ast_json_integer(0);
+	uut = ast_json_integer_create(0);
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, AST_JSON_INTEGER == ast_json_typeof(uut));
-	ast_test_check(res, 0 == ast_json_integer_value(uut));
+	ast_test_check(res, 0 == ast_json_integer_get(uut));
 
 	uut_res = ast_json_integer_set(uut, 1);
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, 1 == ast_json_integer_value(uut));
+	ast_test_check(res, 1 == ast_json_integer_get(uut));
 
 	uut_res = ast_json_integer_set(uut, -1);
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, -1 == ast_json_integer_value(uut));
+	ast_test_check(res, -1 == ast_json_integer_get(uut));
 
 	uut_res = ast_json_integer_set(uut, LLONG_MAX);
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, LLONG_MAX == ast_json_integer_value(uut));
+	ast_test_check(res, LLONG_MAX == ast_json_integer_get(uut));
 
 	uut_res = ast_json_integer_set(uut, LLONG_MIN);
 	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, LLONG_MIN == ast_json_integer_value(uut));
+	ast_test_check(res, LLONG_MIN == ast_json_integer_get(uut));
 	CLEAN_VARS();
 
 	/* Non-ints return 0 integer value */
-	ast_test_check(res, 0 == ast_json_integer_value(ast_json_null()));
-	ast_test_check(res, 0 == ast_json_integer_value(ast_json_true()));
-	ast_test_check(res, 0 == ast_json_integer_value(ast_json_false()));
+	ast_test_check(res, 0 == ast_json_integer_get(ast_json_null()));
+	ast_test_check(res, 0 == ast_json_integer_get(ast_json_true()));
+	ast_test_check(res, 0 == ast_json_integer_get(ast_json_false()));
 
 	/* JSON NULL integers */
-	ast_test_check(res, 0 == ast_json_integer_value(NULL));
+	ast_test_check(res, 0 == ast_json_integer_get(NULL));
 	ast_test_check(res, -1 == ast_json_integer_set(NULL, 911));
 	ast_test_check(res, 0 == ast_json_array_size(NULL));
 
 	/* No magical parsing of strings into ints */
-	uut = ast_json_string("314");
-	ast_test_check(res, 0 == ast_json_integer_value(uut));
+	uut = ast_json_string_create("314");
+	ast_test_check(res, 0 == ast_json_integer_get(uut));
 	CLEAN_VARS();
 
 	/* Or vice-versa */
-	uut = ast_json_integer(314);
-	ast_test_check(res, NULL == ast_json_string_value(uut));
+	uut = ast_json_integer_create(314);
+	ast_test_check(res, NULL == ast_json_string_get(uut));
 	CLEAN_VARS();
 
 	/* array creation */
-	uut = ast_json_array();
+	uut = ast_json_array_create();
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, AST_JSON_ARRAY == ast_json_typeof(uut));
 	ast_test_check(res, 0 == ast_json_array_size(uut));
 	CLEAN_VARS();
 
 	/* array append */
-	uut = ast_json_array();
-	uut_res = ast_json_array_append(uut, ast_json_string("one"));
+	uut = ast_json_array_create();
+	uut_res = ast_json_array_append(uut, ast_json_string_create("one"));
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 1 == ast_json_array_size(uut));
-	ast_test_check(res, 0 == strcmp("one", ast_json_string_value(ast_json_array_get(uut, 0))));
+	ast_test_check(res, 0 == strcmp("one", ast_json_string_get(ast_json_array_get(uut, 0))));
 	/* index out of range */
 	ast_test_check(res, NULL == ast_json_array_get(uut, 1));
 	ast_test_check(res, NULL == ast_json_array_get(uut, -1));
@@ -305,59 +305,59 @@
 
 	/* array insert */
 	uut = ast_json_pack("[s]", "one");
-	uut_res = ast_json_array_insert(uut, 0, ast_json_string("zero"));
+	uut_res = ast_json_array_insert(uut, 0, ast_json_string_create("zero"));
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 2 == ast_json_array_size(uut));
-	ast_test_check(res, 0 == strcmp("zero", ast_json_string_value(ast_json_array_get(uut, 0))));
-	ast_test_check(res, 0 == strcmp("one", ast_json_string_value(ast_json_array_get(uut, 1))));
+	ast_test_check(res, 0 == strcmp("zero", ast_json_string_get(ast_json_array_get(uut, 0))));
+	ast_test_check(res, 0 == strcmp("one", ast_json_string_get(ast_json_array_get(uut, 1))));
 	CLEAN_VARS();
 
 	/* array set */
 	uut = ast_json_pack("[s, s]", "zero", "one");
-	uut_res = ast_json_array_set(uut, 1, ast_json_integer(1));
+	uut_res = ast_json_array_set(uut, 1, ast_json_integer_create(1));
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 2 == ast_json_array_size(uut));
-	ast_test_check(res, 0 == strcmp("zero", ast_json_string_value(ast_json_array_get(uut, 0))));
-	ast_test_check(res, 1 == ast_json_integer_value(ast_json_array_get(uut, 1)));
+	ast_test_check(res, 0 == strcmp("zero", ast_json_string_get(ast_json_array_get(uut, 0))));
+	ast_test_check(res, 1 == ast_json_integer_get(ast_json_array_get(uut, 1)));
 	CLEAN_VARS();
 
 	/* array remove */
-	uut = ast_json_array();
-	uut_res = ast_json_array_append(uut, ast_json_string("zero"));
-	uut_res = ast_json_array_append(uut, ast_json_integer(1));
+	uut = ast_json_array_create();
+	uut_res = ast_json_array_append(uut, ast_json_string_create("zero"));
+	uut_res = ast_json_array_append(uut, ast_json_integer_create(1));
 	uut_res = ast_json_array_remove(uut, 0);
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 1 == ast_json_array_size(uut));
-	ast_test_check(res, 1 == ast_json_integer_value(ast_json_array_get(uut, 0)));
+	ast_test_check(res, 1 == ast_json_integer_get(ast_json_array_get(uut, 0)));
 	CLEAN_VARS();
 
 	/* array clear */
-	uut = ast_json_array();
-	uut_res = ast_json_array_append(uut, ast_json_string("zero"));
-	uut_res = ast_json_array_append(uut, ast_json_integer(1));
+	uut = ast_json_array_create();
+	uut_res = ast_json_array_append(uut, ast_json_string_create("zero"));
+	uut_res = ast_json_array_append(uut, ast_json_integer_create(1));
 	uut_res = ast_json_array_clear(uut);
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 0 == ast_json_array_size(uut));
 	CLEAN_VARS();
 
 	/* array extending */
-	expected = ast_json_array();
-	ast_json_array_append(expected, ast_json_string("a"));
-	ast_json_array_append(expected, ast_json_string("b"));
-	ast_json_array_append(expected, ast_json_string("c"));
-	ast_json_array_append(expected, ast_json_integer(1));
-	ast_json_array_append(expected, ast_json_integer(2));
-	ast_json_array_append(expected, ast_json_integer(3));
-
-	uut = ast_json_array();
-	ast_json_array_append(uut, ast_json_string("a"));
-	ast_json_array_append(uut, ast_json_string("b"));
-	ast_json_array_append(uut, ast_json_string("c"));
-
-	tail = ast_json_array();
-	ast_json_array_append(tail, ast_json_integer(1));
-	ast_json_array_append(tail, ast_json_integer(2));
-	ast_json_array_append(tail, ast_json_integer(3));
+	expected = ast_json_array_create();
+	ast_json_array_append(expected, ast_json_string_create("a"));
+	ast_json_array_append(expected, ast_json_string_create("b"));
+	ast_json_array_append(expected, ast_json_string_create("c"));
+	ast_json_array_append(expected, ast_json_integer_create(1));
+	ast_json_array_append(expected, ast_json_integer_create(2));
+	ast_json_array_append(expected, ast_json_integer_create(3));
+
+	uut = ast_json_array_create();
+	ast_json_array_append(uut, ast_json_string_create("a"));
+	ast_json_array_append(uut, ast_json_string_create("b"));
+	ast_json_array_append(uut, ast_json_string_create("c"));
+
+	tail = ast_json_array_create();
+	ast_json_array_append(tail, ast_json_integer_create(1));
+	ast_json_array_append(tail, ast_json_integer_create(2));
+	ast_json_array_append(tail, ast_json_integer_create(3));
 
 	uut_res = ast_json_array_extend(uut, tail);
 	ast_test_check(res, 0 == uut_res);
@@ -374,14 +374,14 @@
 	ast_test_check(res, -1 == ast_json_array_insert(NULL, 0, ast_json_null()));
 	ast_test_check(res, -1 == ast_json_array_remove(NULL, 0));
 	ast_test_check(res, -1 == ast_json_array_clear(NULL));
-	uut = ast_json_array();
+	uut = ast_json_array_create();
 	ast_test_check(res, -1 == ast_json_array_extend(uut, NULL));
 	ast_test_check(res, -1 == ast_json_array_extend(NULL, uut));
 	ast_test_check(res, -1 == ast_json_array_extend(NULL, NULL));
 	CLEAN_VARS();
 
 	/* object allocation */
-	uut = ast_json_object();
+	uut = ast_json_object_create();
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, AST_JSON_OBJECT == ast_json_typeof(uut));
 	ast_test_check(res, 0 == ast_json_object_size(uut));
@@ -389,12 +389,12 @@
 
 	/* object set */
 	expected = ast_json_pack("{s: i, s: i, s: i}", "one", 1, "two", 2, "three", 3);
-	uut = ast_json_object();
-	uut_res = ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_test_check(res, 0 == uut_res);
-	uut_res = ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_test_check(res, 0 == uut_res);
-	uut_res = ast_json_object_set(uut, "three", ast_json_integer(3));
+	uut = ast_json_object_create();
+	uut_res = ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_test_check(res, 0 == uut_res);
+	uut_res = ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_test_check(res, 0 == uut_res);
+	uut_res = ast_json_object_set(uut, "three", ast_json_integer_create(3));
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, ast_json_equal(expected, uut));
 	ast_test_check(res, NULL == ast_json_object_get(uut, "dne"));
@@ -402,22 +402,22 @@
 
 	/* object set existing */
 	uut = ast_json_pack("{s: i, s: i, s: i}", "one", 1, "two", 2, "three", 3);
-	uut_res = ast_json_object_set(uut, "two", ast_json_integer(-2));
-	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, -2 == ast_json_integer_value(ast_json_object_get(uut, "two")));
+	uut_res = ast_json_object_set(uut, "two", ast_json_integer_create(-2));
+	ast_test_check(res, 0 == uut_res);
+	ast_test_check(res, -2 == ast_json_integer_get(ast_json_object_get(uut, "two")));
 	CLEAN_VARS();
 
 	/* object get */
 	uut = ast_json_pack("{s: i, s: i, s: i}", "one", 1, "two", 2, "three", 3);
-	ast_test_check(res, 2 == ast_json_integer_value(ast_json_object_get(uut, "two")));
+	ast_test_check(res, 2 == ast_json_integer_get(ast_json_object_get(uut, "two")));
 	ast_test_check(res, NULL == ast_json_object_get(uut, "dne"));
 	ast_test_check(res, NULL == ast_json_object_get(uut, NULL));
 	CLEAN_VARS();
 
 	/* object del */
-	expected = ast_json_object();
-	uut = ast_json_object();
-	uut_res = ast_json_object_set(uut, "one", ast_json_integer(1));
+	expected = ast_json_object_create();
+	uut = ast_json_object_create();
+	uut_res = ast_json_object_set(uut, "one", ast_json_integer_create(1));
 	uut_res = ast_json_object_del(uut, "one");
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, ast_json_equal(expected, uut));
@@ -426,32 +426,32 @@
 	CLEAN_VARS();
 
 	/* object clear */
-	uut = ast_json_object();
-	ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_json_object_set(uut, "three", ast_json_integer(3));
+	uut = ast_json_object_create();
+	ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_json_object_set(uut, "three", ast_json_integer_create(3));
 	uut_res = ast_json_object_clear(uut);
 	ast_test_check(res, 0 == uut_res);
 	ast_test_check(res, 0 == ast_json_object_size(uut));
 	CLEAN_VARS();
 
 	/* object merging - all */
-	uut = ast_json_object();
-	ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_json_object_set(uut, "three", ast_json_integer(3));
-
-	merge = ast_json_object();
-	ast_json_object_set(merge, "three", ast_json_integer(-3));
-	ast_json_object_set(merge, "four", ast_json_integer(-4));
-	ast_json_object_set(merge, "five", ast_json_integer(-5));
-
-	expected = ast_json_object();
-	ast_json_object_set(expected, "one", ast_json_integer(1));
-	ast_json_object_set(expected, "two", ast_json_integer(2));
-	ast_json_object_set(expected, "three", ast_json_integer(-3));
-	ast_json_object_set(expected, "four", ast_json_integer(-4));
-	ast_json_object_set(expected, "five", ast_json_integer(-5));
+	uut = ast_json_object_create();
+	ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_json_object_set(uut, "three", ast_json_integer_create(3));
+
+	merge = ast_json_object_create();
+	ast_json_object_set(merge, "three", ast_json_integer_create(-3));
+	ast_json_object_set(merge, "four", ast_json_integer_create(-4));
+	ast_json_object_set(merge, "five", ast_json_integer_create(-5));
+
+	expected = ast_json_object_create();
+	ast_json_object_set(expected, "one", ast_json_integer_create(1));
+	ast_json_object_set(expected, "two", ast_json_integer_create(2));
+	ast_json_object_set(expected, "three", ast_json_integer_create(-3));
+	ast_json_object_set(expected, "four", ast_json_integer_create(-4));
+	ast_json_object_set(expected, "five", ast_json_integer_create(-5));
 
 	uut_res = ast_json_object_update(uut, merge);
 	ast_test_check(res, 0 == uut_res);
@@ -461,20 +461,20 @@
 	CLEAN_VARS();
 
 	/* object merging - existing */
-	uut = ast_json_object();
-	ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_json_object_set(uut, "three", ast_json_integer(3));
-
-	merge = ast_json_object();
-	ast_json_object_set(merge, "three", ast_json_integer(-3));
-	ast_json_object_set(merge, "four", ast_json_integer(-4));
-	ast_json_object_set(merge, "five", ast_json_integer(-5));
-
-	expected = ast_json_object();
-	ast_json_object_set(expected, "one", ast_json_integer(1));
-	ast_json_object_set(expected, "two", ast_json_integer(2));
-	ast_json_object_set(expected, "three", ast_json_integer(-3));
+	uut = ast_json_object_create();
+	ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_json_object_set(uut, "three", ast_json_integer_create(3));
+
+	merge = ast_json_object_create();
+	ast_json_object_set(merge, "three", ast_json_integer_create(-3));
+	ast_json_object_set(merge, "four", ast_json_integer_create(-4));
+	ast_json_object_set(merge, "five", ast_json_integer_create(-5));
+
+	expected = ast_json_object_create();
+	ast_json_object_set(expected, "one", ast_json_integer_create(1));
+	ast_json_object_set(expected, "two", ast_json_integer_create(2));
+	ast_json_object_set(expected, "three", ast_json_integer_create(-3));
 
 	uut_res = ast_json_object_update_existing(uut, merge);
 	ast_test_check(res, 0 == uut_res);
@@ -484,22 +484,22 @@
 	CLEAN_VARS();
 
 	/* object merging - missing */
-	uut = ast_json_object();
-	ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_json_object_set(uut, "three", ast_json_integer(3));
-
-	merge = ast_json_object();
-	ast_json_object_set(merge, "three", ast_json_integer(-3));
-	ast_json_object_set(merge, "four", ast_json_integer(-4));
-	ast_json_object_set(merge, "five", ast_json_integer(-5));
-
-	expected = ast_json_object();
-	ast_json_object_set(expected, "one", ast_json_integer(1));
-	ast_json_object_set(expected, "two", ast_json_integer(2));
-	ast_json_object_set(expected, "three", ast_json_integer(3));
-	ast_json_object_set(expected, "four", ast_json_integer(-4));
-	ast_json_object_set(expected, "five", ast_json_integer(-5));
+	uut = ast_json_object_create();
+	ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_json_object_set(uut, "three", ast_json_integer_create(3));
+
+	merge = ast_json_object_create();
+	ast_json_object_set(merge, "three", ast_json_integer_create(-3));
+	ast_json_object_set(merge, "four", ast_json_integer_create(-4));
+	ast_json_object_set(merge, "five", ast_json_integer_create(-5));
+
+	expected = ast_json_object_create();
+	ast_json_object_set(expected, "one", ast_json_integer_create(1));
+	ast_json_object_set(expected, "two", ast_json_integer_create(2));
+	ast_json_object_set(expected, "three", ast_json_integer_create(3));
+	ast_json_object_set(expected, "four", ast_json_integer_create(-4));
+	ast_json_object_set(expected, "five", ast_json_integer_create(-5));
 
 	uut_res = ast_json_object_update_missing(uut, merge);
 	ast_test_check(res, 0 == uut_res);
@@ -514,7 +514,7 @@
 	ast_test_check(res, -1 == ast_json_object_set(NULL, "not null", ast_json_null()));
 	ast_test_check(res, -1 == ast_json_object_del(NULL, "not null"));
 	ast_test_check(res, -1 == ast_json_object_clear(NULL));
-	uut = ast_json_object();
+	uut = ast_json_object_create();
 	ast_test_check(res, -1 == ast_json_object_update(NULL, uut));
 	ast_test_check(res, -1 == ast_json_object_update(uut, NULL));
 	ast_test_check(res, -1 == ast_json_object_update(NULL, NULL));
@@ -527,27 +527,27 @@
 	CLEAN_VARS();
 
 	/* Object iterator testing */
-	uut = ast_json_object();
-	ast_json_object_set(uut, "one", ast_json_integer(1));
-	ast_json_object_set(uut, "two", ast_json_integer(2));
-	ast_json_object_set(uut, "three", ast_json_integer(3));
-	ast_json_object_set(uut, "four", ast_json_integer(4));
-	ast_json_object_set(uut, "five", ast_json_integer(5));
+	uut = ast_json_object_create();
+	ast_json_object_set(uut, "one", ast_json_integer_create(1));
+	ast_json_object_set(uut, "two", ast_json_integer_create(2));
+	ast_json_object_set(uut, "three", ast_json_integer_create(3));
+	ast_json_object_set(uut, "four", ast_json_integer_create(4));
+	ast_json_object_set(uut, "five", ast_json_integer_create(5));
 
 	/* Iterate through the object; be aware that order isn't specified */
 	iter = ast_json_object_iter(uut);
 	ast_test_check(res, NULL != iter);
 	while (NULL != iter) {
 		if (0 == strcmp("one", ast_json_object_iter_key(iter))) {
-			ast_test_check(res, 1 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+			ast_test_check(res, 1 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 		} else if (0 == strcmp("two", ast_json_object_iter_key(iter))) {
-			ast_test_check(res, 2 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+			ast_test_check(res, 2 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 		} else if (0 == strcmp("three", ast_json_object_iter_key(iter))) {
-			ast_test_check(res, 3 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+			ast_test_check(res, 3 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 		} else if (0 == strcmp("four", ast_json_object_iter_key(iter))) {
-			ast_test_check(res, 4 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+			ast_test_check(res, 4 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 		} else if (0 == strcmp("five", ast_json_object_iter_key(iter))) {
-			ast_test_check(res, 5 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+			ast_test_check(res, 5 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 		} else {
 			/* Unexpected key */
 			ast_test_check(res, 0);
@@ -564,17 +564,17 @@
 	/* iterator specific key */
 	iter = ast_json_object_iter_at(uut, "three");
 	ast_test_check(res, NULL != iter);
-	ast_test_check(res, 3 == ast_json_integer_value(ast_json_object_iter_value(iter)));
+	ast_test_check(res, 3 == ast_json_integer_get(ast_json_object_iter_value(iter)));
 
 	/* set via iter */
 	iter = ast_json_object_iter_at(uut, "three");
-	uut_res = ast_json_object_iter_set(uut, iter, ast_json_integer(-3));
-	ast_test_check(res, 0 == uut_res);
-	ast_test_check(res, -3 == ast_json_integer_value(ast_json_object_get(uut, "three")));
+	uut_res = ast_json_object_iter_set(uut, iter, ast_json_integer_create(-3));
+	ast_test_check(res, 0 == uut_res);
+	ast_test_check(res, -3 == ast_json_integer_get(ast_json_object_get(uut, "three")));
 	CLEAN_VARS();
 
 	/* iterator NULL tests */
-	uut = ast_json_object();
+	uut = ast_json_object_create();
 	ast_test_check(res, NULL == ast_json_object_iter(NULL));
 	ast_test_check(res, NULL == ast_json_object_iter_at(NULL, "not null"));
 	ast_test_check(res, NULL == ast_json_object_iter_next(NULL, NULL));
@@ -586,23 +586,23 @@
 	CLEAN_VARS();
 
 	/* dump/load string */
-	expected = ast_json_object();
-	ast_json_object_set(expected, "one", ast_json_integer(1));
-	str = ast_json_dumps(expected);
+	expected = ast_json_object_create();
+	ast_json_object_set(expected, "one", ast_json_integer_create(1));
+	str = ast_json_dump_string(expected);
 	ast_test_check(res, NULL != str);
-	uut = ast_json_loads(str, NULL);
+	uut = ast_json_load_string(str, NULL);
 	ast_test_check(res, NULL != uut);
 	ast_test_check(res, ast_json_equal(expected, uut));
 	CLEAN_VARS();
 
 	/* dumps NULL */
-	ast_test_check(res, NULL == ast_json_dumps(NULL));
+	ast_test_check(res, NULL == ast_json_dump_string(NULL));
 
 	/* load buffer */
 	str = "{ \"one\": 1 } trailing garbage";
-	uut = ast_json_loads(str, NULL);
+	uut = ast_json_load_string(str, NULL);
 	ast_test_check(res, NULL == uut);
-	uut = ast_json_loadb(str, strlen("{ \"one\": 1 }"), NULL);
+	uut = ast_json_load_buf(str, strlen("{ \"one\": 1 }"), NULL);
 	ast_test_check(res, NULL != uut);
 	str = NULL;
 	CLEAN_VARS();
@@ -611,57 +611,57 @@
 	expected = ast_json_pack("{ s: i }", "one", 1);
 	filename = tempnam(NULL, "ast-json");
 	file = fopen(filename, "w");
-	uut_res = ast_json_dumpf(expected, file);
+	uut_res = ast_json_dump_file(expected, file);
 	ast_test_check(res, 0 == uut_res);
 	fclose(file);
 	file = fopen(filename, "r");
-	uut = ast_json_loadf(file, NULL);
+	uut = ast_json_load_file(file, NULL);
 	ast_test_check(res, ast_json_equal(expected, uut));
 	CLEAN_VARS();
 
 	/* dump/load filename */
 	expected = ast_json_pack("{ s: i }", "one", 1);
 	filename = tempnam(NULL, "ast-json");
-	uut_res = ast_json_dump_file(expected, filename);
-	ast_test_check(res, 0 == uut_res);
-	uut = ast_json_load_file(filename, NULL);
+	uut_res = ast_json_dump_new_file(expected, filename);
+	ast_test_check(res, 0 == uut_res);
+	uut = ast_json_load_new_file(filename, NULL);
 	ast_test_check(res, ast_json_equal(expected, uut));
 	CLEAN_VARS();
 
 	/* dump/load NULL tests */
-	uut = ast_json_loads("{ \"one\": 1 }", NULL);
+	uut = ast_json_load_string("{ \"one\": 1 }", NULL);
 	ast_test_check(res, NULL != uut);
 	filename = tempnam(NULL, "ast-json");
 	file = fopen(filename, "w");
-	ast_test_check(res, NULL == ast_json_dumps(NULL));
-	ast_test_check(res, -1 == ast_json_dumpf(NULL, file));
-	ast_test_check(res, -1 == ast_json_dumpf(uut, NULL));
-	ast_test_check(res, -1 == ast_json_dumpf(NULL, NULL));
+	ast_test_check(res, NULL == ast_json_dump_string(NULL));
+	ast_test_check(res, -1 == ast_json_dump_file(NULL, file));
 	ast_test_check(res, -1 == ast_json_dump_file(uut, NULL));
-	ast_test_check(res, -1 == ast_json_dump_file(NULL, filename));
 	ast_test_check(res, -1 == ast_json_dump_file(NULL, NULL));
-	ast_test_check(res, NULL == ast_json_loads(NULL, NULL));
-	ast_test_check(res, NULL == ast_json_loadb(NULL, 0, NULL));
-	ast_test_check(res, NULL == ast_json_loadf(NULL, NULL));
+	ast_test_check(res, -1 == ast_json_dump_new_file(uut, NULL));
+	ast_test_check(res, -1 == ast_json_dump_new_file(NULL, filename));
+	ast_test_check(res, -1 == ast_json_dump_new_file(NULL, NULL));
+	ast_test_check(res, NULL == ast_json_load_string(NULL, NULL));
+	ast_test_check(res, NULL == ast_json_load_buf(NULL, 0, NULL));
 	ast_test_check(res, NULL == ast_json_load_file(NULL, NULL));
+	ast_test_check(res, NULL == ast_json_load_new_file(NULL, NULL));
 	CLEAN_VARS();
 
 	/* parse errors */
-	ast_test_check(res, NULL == ast_json_loads("'singleton'", NULL));
-	ast_test_check(res, NULL == ast_json_loads("{ no value }", NULL));
-	ast_test_check(res, NULL == ast_json_loads("{ 'no': 'curly' ", NULL));
-	ast_test_check(res, NULL == ast_json_loads("[ 'no', 'square'", NULL));
-	ast_test_check(res, NULL == ast_json_loads("{ 1: 'int key' }", NULL));
-	ast_test_check(res, NULL == ast_json_loads("", NULL));

[... 62 lines stripped ...]



More information about the asterisk-commits mailing list