Commit dbaa77e6 authored by Chad Versace's avatar Chad Versace

core: Rename functions s/wcore_attrib_list/wcore_attrib_list32/

When designing the original Waffle 1.0 API, I made a mistake when
I chose to declare attribute lists as arrays of int32_t. Instead, they
should have been arrays of intptr_t.

A new public function, waffle_window_create2, will have a `const
intptr_t attrib_list[]` parameter. Therefore waffle needs intptr_t
variants of the wcore_attrib_list functions.

This patch makes room for the new intptr_t wcore_attrib_list functions
by renaming the old ones.
Signed-off-by: default avatarChad Versace <chad.versace@intel.com>
Tested-by: Emil Velikov <emil.l.velikov@gmail.com> (msvc/wgl)
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
parent 0542811c
......@@ -33,7 +33,7 @@ waffle_attrib_list_length(const int32_t attrib_list[])
{
wcore_error_reset();
return wcore_attrib_list_length(attrib_list);
return wcore_attrib_list32_length(attrib_list);
}
WAFFLE_API bool
......@@ -43,7 +43,7 @@ waffle_attrib_list_get(
int32_t *value)
{
wcore_error_reset();
return wcore_attrib_list_get(attrib_list, key, value);
return wcore_attrib_list32_get(attrib_list, key, value);
}
WAFFLE_API bool
......@@ -54,7 +54,7 @@ waffle_attrib_list_get_with_default(
int32_t default_value)
{
wcore_error_reset();
return wcore_attrib_list_get_with_default(attrib_list, key, value,
return wcore_attrib_list32_get_with_default(attrib_list, key, value,
default_value);
}
......@@ -65,5 +65,5 @@ waffle_attrib_list_update(
int32_t value)
{
wcore_error_reset();
return wcore_attrib_list_update(attrib_list, key, value);
return wcore_attrib_list32_update(attrib_list, key, value);
}
......@@ -30,7 +30,7 @@
#include <stddef.h>
int32_t
wcore_attrib_list_length(const int32_t attrib_list[])
wcore_attrib_list32_length(const int32_t attrib_list[])
{
const int32_t *i = attrib_list;
......@@ -44,7 +44,7 @@ wcore_attrib_list_length(const int32_t attrib_list[])
}
bool
wcore_attrib_list_get(
wcore_attrib_list32_get(
const int32_t *attrib_list,
int32_t key,
int32_t *value)
......@@ -64,13 +64,13 @@ wcore_attrib_list_get(
}
bool
wcore_attrib_list_get_with_default(
wcore_attrib_list32_get_with_default(
const int32_t attrib_list[],
int32_t key,
int32_t *value,
int32_t default_value)
{
if (wcore_attrib_list_get(attrib_list, key, value)) {
if (wcore_attrib_list32_get(attrib_list, key, value)) {
return true;
}
else {
......@@ -80,7 +80,7 @@ wcore_attrib_list_get_with_default(
}
bool
wcore_attrib_list_update(
wcore_attrib_list32_update(
int32_t *attrib_list,
int32_t key,
int32_t value)
......
......@@ -29,23 +29,23 @@
#include <stdint.h>
int32_t
wcore_attrib_list_length(const int32_t attrib_list[]);
wcore_attrib_list32_length(const int32_t attrib_list[]);
bool
wcore_attrib_list_get(
wcore_attrib_list32_get(
const int32_t *attrib_list,
int32_t key,
int32_t *value);
bool
wcore_attrib_list_get_with_default(
wcore_attrib_list32_get_with_default(
const int32_t attrib_list[],
int32_t key,
int32_t *value,
int32_t default_value);
bool
wcore_attrib_list_update(
wcore_attrib_list32_update(
int32_t *attrib_list,
int32_t key,
int32_t value);
......@@ -33,25 +33,25 @@
#include "wcore_attrib_list.h"
static void
test_wcore_attrib_list_get_null(void **state) {
test_wcore_attrib_list32_get_null(void **state) {
int32_t *attrib_list = NULL;
int32_t key = 0;
int32_t value;
assert_false(wcore_attrib_list_get(attrib_list, key, &value));
assert_false(wcore_attrib_list32_get(attrib_list, key, &value));
}
static void
test_wcore_attrib_list_get_empty(void **state) {
test_wcore_attrib_list32_get_empty(void **state) {
int32_t attrib_list[] = { 0 };
int32_t key = 0;
int32_t value;
assert_false(wcore_attrib_list_get(attrib_list, key, &value));
assert_false(wcore_attrib_list32_get(attrib_list, key, &value));
}
static void
test_wcore_attrib_list_get_missing_value(void **state) {
test_wcore_attrib_list32_get_missing_value(void **state) {
int32_t attrib_list[] = {
1, 11,
0,
......@@ -59,11 +59,11 @@ test_wcore_attrib_list_get_missing_value(void **state) {
int32_t key = 2;
int32_t value;
assert_false(wcore_attrib_list_get(attrib_list, key, &value));
assert_false(wcore_attrib_list32_get(attrib_list, key, &value));
}
static void
test_wcore_attrib_list_get_trailing_items(void **state) {
test_wcore_attrib_list32_get_trailing_items(void **state) {
int32_t attrib_list[] = {
1, 11,
0,
......@@ -72,23 +72,23 @@ test_wcore_attrib_list_get_trailing_items(void **state) {
int32_t key = 2;
int32_t value;
assert_false(wcore_attrib_list_get(attrib_list, key, &value));
assert_false(wcore_attrib_list32_get(attrib_list, key, &value));
}
static void
test_wcore_attrib_list_get_value_not_modified_if_not_found(void **state) {
test_wcore_attrib_list32_get_value_not_modified_if_not_found(void **state) {
int32_t attrib_list[] = {
1, 11,
0,
};
int32_t value = 17;
assert_false(wcore_attrib_list_get(attrib_list, 2, &value));
assert_false(wcore_attrib_list32_get(attrib_list, 2, &value));
assert_int_equal(value, 17);
}
static void
test_wcore_attrib_list_get_key_is_first(void **state) {
test_wcore_attrib_list32_get_key_is_first(void **state) {
int32_t attrib_list[] = {
1, 11,
2, 22,
......@@ -98,12 +98,12 @@ test_wcore_attrib_list_get_key_is_first(void **state) {
int32_t key = 1;
int32_t value;
assert_true(wcore_attrib_list_get(attrib_list, key, &value));
assert_true(wcore_attrib_list32_get(attrib_list, key, &value));
assert_int_equal(value, 11);
}
static void
test_wcore_attrib_list_get_key_is_last(void **state) {
test_wcore_attrib_list32_get_key_is_last(void **state) {
int32_t attrib_list[] = {
1, 11,
2, 22,
......@@ -113,52 +113,52 @@ test_wcore_attrib_list_get_key_is_last(void **state) {
int32_t key = 3;
int32_t value;
assert_true(wcore_attrib_list_get(attrib_list, key, &value));
assert_true(wcore_attrib_list32_get(attrib_list, key, &value));
assert_int_equal(value, 33);
}
static void
test_wcore_attrib_list_length_null(void **state) {
test_wcore_attrib_list32_length_null(void **state) {
int32_t *attrib_list = NULL;
assert_int_equal(wcore_attrib_list_length(attrib_list), 0);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 0);
}
static void
test_wcore_attrib_list_length_is_0(void **state) {
test_wcore_attrib_list32_length_is_0(void **state) {
int32_t attrib_list[] = {0};
assert_int_equal(wcore_attrib_list_length(attrib_list), 0);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 0);
}
static void
test_wcore_attrib_list_length_is_1(void **state) {
test_wcore_attrib_list32_length_is_1(void **state) {
int32_t attrib_list[] = {
1, 1,
0,
};
assert_int_equal(wcore_attrib_list_length(attrib_list), 1);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 1);
}
static void
test_wcore_attrib_list_length_is_2(void **state) {
test_wcore_attrib_list32_length_is_2(void **state) {
int32_t attrib_list[] = {
1, 1,
2, 2,
0,
};
assert_int_equal(wcore_attrib_list_length(attrib_list), 2);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 2);
}
static void
test_wcore_attrib_list_length_is_37(void **state) {
test_wcore_attrib_list32_length_is_37(void **state) {
int32_t attrib_list[75];
memset(attrib_list, 0xff, 74 * sizeof(int32_t));
attrib_list[74] = 0;
assert_int_equal(wcore_attrib_list_length(attrib_list), 37);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 37);
}
static void
test_wcore_attrib_list_length_trailing_items(void **state) {
test_wcore_attrib_list32_length_trailing_items(void **state) {
int32_t attrib_list[] = {
1, 1,
2, 2,
......@@ -169,23 +169,23 @@ test_wcore_attrib_list_length_trailing_items(void **state) {
0,
};
assert_int_equal(wcore_attrib_list_length(attrib_list), 3);
assert_int_equal(wcore_attrib_list32_length(attrib_list), 3);
}
static void
test_wcore_attrib_list_update_null(void **state) {
test_wcore_attrib_list32_update_null(void **state) {
int32_t *attrib_list = NULL;
assert_false(wcore_attrib_list_update(attrib_list, 7, 7));
assert_false(wcore_attrib_list32_update(attrib_list, 7, 7));
}
static void
test_wcore_attrib_list_update_empty_list(void **state) {
test_wcore_attrib_list32_update_empty_list(void **state) {
int32_t attrib_list[] = {0};
assert_false(wcore_attrib_list_update(attrib_list, 7, 7));
assert_false(wcore_attrib_list32_update(attrib_list, 7, 7));
}
static void
test_wcore_attrib_list_update_at_0(void **state) {
test_wcore_attrib_list32_update_at_0(void **state) {
int32_t v;
int32_t attrib_list[] = {
10, 10,
......@@ -194,13 +194,13 @@ test_wcore_attrib_list_update_at_0(void **state) {
0,
};
assert_true(wcore_attrib_list_update(attrib_list, 10, 99));
assert_true(wcore_attrib_list_get(attrib_list, 10, &v));
assert_true(wcore_attrib_list32_update(attrib_list, 10, 99));
assert_true(wcore_attrib_list32_get(attrib_list, 10, &v));
assert_int_equal(v, 99);
}
static void
test_wcore_attrib_list_update_at_1(void **state) {
test_wcore_attrib_list32_update_at_1(void **state) {
int32_t v;
int32_t attrib_list[] = {
10, 10,
......@@ -209,13 +209,13 @@ test_wcore_attrib_list_update_at_1(void **state) {
0,
};
assert_true(wcore_attrib_list_update(attrib_list, 20, 99));
assert_true(wcore_attrib_list_get(attrib_list, 20, &v));
assert_true(wcore_attrib_list32_update(attrib_list, 20, 99));
assert_true(wcore_attrib_list32_get(attrib_list, 20, &v));
assert_int_equal(v, 99);
}
static void
test_wcore_attrib_list_update_missing_key(void **state) {
test_wcore_attrib_list32_update_missing_key(void **state) {
int32_t attrib_list[] = {
10, 10,
20, 20,
......@@ -223,30 +223,30 @@ test_wcore_attrib_list_update_missing_key(void **state) {
0,
};
assert_false(wcore_attrib_list_update(attrib_list, 50, 99));
assert_false(wcore_attrib_list32_update(attrib_list, 50, 99));
}
int
main(void) {
const UnitTest tests[] = {
unit_test(test_wcore_attrib_list_get_null),
unit_test(test_wcore_attrib_list_get_empty),
unit_test(test_wcore_attrib_list_get_missing_value),
unit_test(test_wcore_attrib_list_get_trailing_items),
unit_test(test_wcore_attrib_list_get_value_not_modified_if_not_found),
unit_test(test_wcore_attrib_list_get_key_is_first),
unit_test(test_wcore_attrib_list_get_key_is_last),
unit_test(test_wcore_attrib_list_length_null),
unit_test(test_wcore_attrib_list_length_is_0),
unit_test(test_wcore_attrib_list_length_is_1),
unit_test(test_wcore_attrib_list_length_is_2),
unit_test(test_wcore_attrib_list_length_is_37),
unit_test(test_wcore_attrib_list_length_trailing_items),
unit_test(test_wcore_attrib_list_update_null),
unit_test(test_wcore_attrib_list_update_empty_list),
unit_test(test_wcore_attrib_list_update_at_0),
unit_test(test_wcore_attrib_list_update_at_1),
unit_test(test_wcore_attrib_list_update_missing_key),
unit_test(test_wcore_attrib_list32_get_null),
unit_test(test_wcore_attrib_list32_get_empty),
unit_test(test_wcore_attrib_list32_get_missing_value),
unit_test(test_wcore_attrib_list32_get_trailing_items),
unit_test(test_wcore_attrib_list32_get_value_not_modified_if_not_found),
unit_test(test_wcore_attrib_list32_get_key_is_first),
unit_test(test_wcore_attrib_list32_get_key_is_last),
unit_test(test_wcore_attrib_list32_length_null),
unit_test(test_wcore_attrib_list32_length_is_0),
unit_test(test_wcore_attrib_list32_length_is_1),
unit_test(test_wcore_attrib_list32_length_is_2),
unit_test(test_wcore_attrib_list32_length_is_37),
unit_test(test_wcore_attrib_list32_length_trailing_items),
unit_test(test_wcore_attrib_list32_update_null),
unit_test(test_wcore_attrib_list32_update_empty_list),
unit_test(test_wcore_attrib_list32_update_at_0),
unit_test(test_wcore_attrib_list32_update_at_1),
unit_test(test_wcore_attrib_list32_update_missing_key),
};
return run_tests(tests);
......
......@@ -84,7 +84,7 @@ parse_bool(const int32_t attrib_list[],
{
int32_t raw_value;
wcore_attrib_list_get_with_default(attrib_list, attrib_name,
wcore_attrib_list32_get_with_default(attrib_list, attrib_name,
&raw_value, default_value);
if (raw_value == WAFFLE_DONT_CARE) {
......@@ -108,7 +108,7 @@ parse_context_api(struct wcore_config_attrs *attrs,
{
bool found;
found = wcore_attrib_list_get(attrib_list,
found = wcore_attrib_list32_get(attrib_list,
WAFFLE_CONTEXT_API, &attrs->context_api);
if (!found) {
wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
......@@ -163,11 +163,11 @@ static bool
parse_context_version(struct wcore_config_attrs *attrs,
const int32_t attrib_list[])
{
wcore_attrib_list_get_with_default(attrib_list,
wcore_attrib_list32_get_with_default(attrib_list,
WAFFLE_CONTEXT_MAJOR_VERSION,
&attrs->context_major_version,
attrs->context_major_version);
wcore_attrib_list_get_with_default(attrib_list,
wcore_attrib_list32_get_with_default(attrib_list,
WAFFLE_CONTEXT_MINOR_VERSION,
&attrs->context_minor_version,
attrs->context_minor_version);
......@@ -260,7 +260,7 @@ static bool
parse_context_profile(struct wcore_config_attrs *attrs,
const int32_t attrib_list[])
{
wcore_attrib_list_get_with_default(attrib_list,
wcore_attrib_list32_get_with_default(attrib_list,
WAFFLE_CONTEXT_PROFILE,
&attrs->context_profile,
attrs->context_profile);
......
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