mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-23 03:18:59 +00:00
Change names of qpdf_object_type_e enumerations
They have to be ot_* rather than qpdf_ot_* for compatibility. * Different enumerated types are not assignment-compatible in C++, at least with strict compiler settings * While you can do `constexpr ot_xyz = ::qpdf_ot_xyz` in QPDFObject.hh to make QPDFObject::ot_xyz work, QPDFObject::object_type_e::ot_xyz will only work if the enumerated type names are the same.
This commit is contained in:
parent
cf7b2b5700
commit
d866f48081
@ -47,25 +47,29 @@ enum qpdf_error_code_e
|
|||||||
* qpdf_oh, have a unique type code that has one of the values in the
|
* qpdf_oh, have a unique type code that has one of the values in the
|
||||||
* list below. As new object types are added to qpdf, additional items
|
* list below. As new object types are added to qpdf, additional items
|
||||||
* may be added to the list, so code that switches on these values
|
* may be added to the list, so code that switches on these values
|
||||||
* should take that into consideration.
|
* should take that into consideration. (Maintainer note: it would be
|
||||||
|
* better to call this qpdf_ot_* rather than ot_* to reduce likelihood
|
||||||
|
* of name collision, but since QPDFObject::object_type_e is an alias
|
||||||
|
* to this type, changing the names of the values breaks backward
|
||||||
|
* compatibility.)
|
||||||
*/
|
*/
|
||||||
enum qpdf_object_type_e {
|
enum qpdf_object_type_e {
|
||||||
/* Object types internal to qpdf */
|
/* Object types internal to qpdf */
|
||||||
qpdf_ot_uninitialized,
|
ot_uninitialized,
|
||||||
qpdf_ot_reserved,
|
ot_reserved,
|
||||||
/* Object types that can occur in the main document */
|
/* Object types that can occur in the main document */
|
||||||
qpdf_ot_null,
|
ot_null,
|
||||||
qpdf_ot_boolean,
|
ot_boolean,
|
||||||
qpdf_ot_integer,
|
ot_integer,
|
||||||
qpdf_ot_real,
|
ot_real,
|
||||||
qpdf_ot_string,
|
ot_string,
|
||||||
qpdf_ot_name,
|
ot_name,
|
||||||
qpdf_ot_array,
|
ot_array,
|
||||||
qpdf_ot_dictionary,
|
ot_dictionary,
|
||||||
qpdf_ot_stream,
|
ot_stream,
|
||||||
/* Additional object types that can occur in content streams */
|
/* Additional object types that can occur in content streams */
|
||||||
qpdf_ot_operator,
|
ot_operator,
|
||||||
qpdf_ot_inlineimage,
|
ot_inlineimage,
|
||||||
/* NOTE: if adding to this list, update QPDFObject.hh */
|
/* NOTE: if adding to this list, update QPDFObject.hh */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,19 +48,19 @@ class QPDF_DLL_CLASS QPDFObject
|
|||||||
// QPDFObject::object_type_e but was moved to make it accessible
|
// QPDFObject::object_type_e but was moved to make it accessible
|
||||||
// to the C API. The code below is for backward compatibility.
|
// to the C API. The code below is for backward compatibility.
|
||||||
typedef enum qpdf_object_type_e object_type_e;
|
typedef enum qpdf_object_type_e object_type_e;
|
||||||
static constexpr object_type_e ot_uninitialized = ::qpdf_ot_uninitialized;
|
static constexpr object_type_e ot_uninitialized = ::ot_uninitialized;
|
||||||
static constexpr object_type_e ot_reserved = ::qpdf_ot_reserved;
|
static constexpr object_type_e ot_reserved = ::ot_reserved;
|
||||||
static constexpr object_type_e ot_null = ::qpdf_ot_null;
|
static constexpr object_type_e ot_null = ::ot_null;
|
||||||
static constexpr object_type_e ot_boolean = ::qpdf_ot_boolean;
|
static constexpr object_type_e ot_boolean = ::ot_boolean;
|
||||||
static constexpr object_type_e ot_integer = ::qpdf_ot_integer;
|
static constexpr object_type_e ot_integer = ::ot_integer;
|
||||||
static constexpr object_type_e ot_real = ::qpdf_ot_real;
|
static constexpr object_type_e ot_real = ::ot_real;
|
||||||
static constexpr object_type_e ot_string = ::qpdf_ot_string;
|
static constexpr object_type_e ot_string = ::ot_string;
|
||||||
static constexpr object_type_e ot_name = ::qpdf_ot_name;
|
static constexpr object_type_e ot_name = ::ot_name;
|
||||||
static constexpr object_type_e ot_array = ::qpdf_ot_array;
|
static constexpr object_type_e ot_array = ::ot_array;
|
||||||
static constexpr object_type_e ot_dictionary = ::qpdf_ot_dictionary;
|
static constexpr object_type_e ot_dictionary = ::ot_dictionary;
|
||||||
static constexpr object_type_e ot_stream = ::qpdf_ot_stream;
|
static constexpr object_type_e ot_stream = ::ot_stream;
|
||||||
static constexpr object_type_e ot_operator = ::qpdf_ot_operator;
|
static constexpr object_type_e ot_operator = ::ot_operator;
|
||||||
static constexpr object_type_e ot_inlineimage = ::qpdf_ot_inlineimage;
|
static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
|
||||||
|
|
||||||
virtual ~QPDFObject() {}
|
virtual ~QPDFObject() {}
|
||||||
virtual std::string unparse() = 0;
|
virtual std::string unparse() = 0;
|
||||||
|
@ -1151,7 +1151,7 @@ QPDF_BOOL qpdf_oh_is_number(qpdf_data qpdf, qpdf_oh oh)
|
|||||||
qpdf_object_type_e qpdf_oh_get_type_code(qpdf_data qpdf, qpdf_oh oh)
|
qpdf_object_type_e qpdf_oh_get_type_code(qpdf_data qpdf, qpdf_oh oh)
|
||||||
{
|
{
|
||||||
return do_with_oh<qpdf_object_type_e>(
|
return do_with_oh<qpdf_object_type_e>(
|
||||||
qpdf, oh, return_T<qpdf_object_type_e>(qpdf_ot_uninitialized),
|
qpdf, oh, return_T<qpdf_object_type_e>(ot_uninitialized),
|
||||||
[](QPDFObjectHandle& o) {
|
[](QPDFObjectHandle& o) {
|
||||||
QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_type_code");
|
QTC::TC("qpdf", "qpdf-c called qpdf_oh_get_type_code");
|
||||||
return o.getTypeCode();
|
return o.getTypeCode();
|
||||||
|
@ -537,12 +537,12 @@ static void test24(char const* infile,
|
|||||||
/* Go to the first page and look at all the keys */
|
/* Go to the first page and look at all the keys */
|
||||||
qpdf_oh pages = qpdf_oh_get_key(qpdf, root, "/Pages");
|
qpdf_oh pages = qpdf_oh_get_key(qpdf, root, "/Pages");
|
||||||
assert(qpdf_oh_is_dictionary(qpdf, pages));
|
assert(qpdf_oh_is_dictionary(qpdf, pages));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, pages) == qpdf_ot_dictionary);
|
assert(qpdf_oh_get_type_code(qpdf, pages) == ot_dictionary);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, pages), "dictionary") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, pages), "dictionary") == 0);
|
||||||
assert(qpdf_oh_is_initialized(qpdf, pages));
|
assert(qpdf_oh_is_initialized(qpdf, pages));
|
||||||
qpdf_oh kids = qpdf_oh_get_key(qpdf, pages, "/Kids");
|
qpdf_oh kids = qpdf_oh_get_key(qpdf, pages, "/Kids");
|
||||||
assert(qpdf_oh_is_array(qpdf, kids));
|
assert(qpdf_oh_is_array(qpdf, kids));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, kids) == qpdf_ot_array);
|
assert(qpdf_oh_get_type_code(qpdf, kids) == ot_array);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, kids), "array") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, kids), "array") == 0);
|
||||||
assert(qpdf_oh_get_array_n_items(qpdf, kids) == 1);
|
assert(qpdf_oh_get_array_n_items(qpdf, kids) == 1);
|
||||||
qpdf_oh page1 = qpdf_oh_get_array_item(qpdf, kids, 0);
|
qpdf_oh page1 = qpdf_oh_get_array_item(qpdf, kids, 0);
|
||||||
@ -555,7 +555,7 @@ static void test24(char const* infile,
|
|||||||
/* Inspect the first page */
|
/* Inspect the first page */
|
||||||
qpdf_oh type = qpdf_oh_get_key(qpdf, page1, "/Type");
|
qpdf_oh type = qpdf_oh_get_key(qpdf, page1, "/Type");
|
||||||
assert(qpdf_oh_is_name(qpdf, type));
|
assert(qpdf_oh_is_name(qpdf, type));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, type) == qpdf_ot_name);
|
assert(qpdf_oh_get_type_code(qpdf, type) == ot_name);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, type), "name") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, type), "name") == 0);
|
||||||
assert(strcmp(qpdf_oh_get_name(qpdf, type), "/Page") == 0);
|
assert(strcmp(qpdf_oh_get_name(qpdf, type), "/Page") == 0);
|
||||||
qpdf_oh parent = qpdf_oh_get_key(qpdf, page1, "/Parent");
|
qpdf_oh parent = qpdf_oh_get_key(qpdf, page1, "/Parent");
|
||||||
@ -595,14 +595,14 @@ static void test24(char const* infile,
|
|||||||
/* Look at page contents to exercise stream functions */
|
/* Look at page contents to exercise stream functions */
|
||||||
qpdf_oh contents = qpdf_oh_get_key(qpdf, page1, "/Contents");
|
qpdf_oh contents = qpdf_oh_get_key(qpdf, page1, "/Contents");
|
||||||
assert(qpdf_oh_is_stream(qpdf, contents));
|
assert(qpdf_oh_is_stream(qpdf, contents));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, contents) == qpdf_ot_stream);
|
assert(qpdf_oh_get_type_code(qpdf, contents) == ot_stream);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents), "stream") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents), "stream") == 0);
|
||||||
qpdf_oh contents_dict = qpdf_oh_get_dict(qpdf, contents);
|
qpdf_oh contents_dict = qpdf_oh_get_dict(qpdf, contents);
|
||||||
assert(! qpdf_oh_is_scalar(qpdf, contents));
|
assert(! qpdf_oh_is_scalar(qpdf, contents));
|
||||||
assert(! qpdf_oh_is_scalar(qpdf, contents_dict));
|
assert(! qpdf_oh_is_scalar(qpdf, contents_dict));
|
||||||
qpdf_oh contents_length = qpdf_oh_get_key(qpdf, contents_dict, "/Length");
|
qpdf_oh contents_length = qpdf_oh_get_key(qpdf, contents_dict, "/Length");
|
||||||
assert(qpdf_oh_is_integer(qpdf, contents_length));
|
assert(qpdf_oh_is_integer(qpdf, contents_length));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, contents_length) == qpdf_ot_integer);
|
assert(qpdf_oh_get_type_code(qpdf, contents_length) == ot_integer);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents_length), "integer") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents_length), "integer") == 0);
|
||||||
assert(qpdf_oh_is_scalar(qpdf, contents_length));
|
assert(qpdf_oh_is_scalar(qpdf, contents_length));
|
||||||
assert(qpdf_oh_is_number(qpdf, contents_length));
|
assert(qpdf_oh_is_number(qpdf, contents_length));
|
||||||
@ -643,7 +643,7 @@ static void test24(char const* infile,
|
|||||||
qpdf_oh_release(qpdf, page1);
|
qpdf_oh_release(qpdf, page1);
|
||||||
contents = qpdf_oh_get_key(qpdf, page1, "/Contents");
|
contents = qpdf_oh_get_key(qpdf, page1, "/Contents");
|
||||||
assert(qpdf_oh_is_null(qpdf, contents));
|
assert(qpdf_oh_is_null(qpdf, contents));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, contents) == qpdf_ot_null);
|
assert(qpdf_oh_get_type_code(qpdf, contents) == ot_null);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents), "null") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, contents), "null") == 0);
|
||||||
assert(qpdf_oh_is_array(qpdf, mediabox));
|
assert(qpdf_oh_is_array(qpdf, mediabox));
|
||||||
qpdf_oh_release_all(qpdf);
|
qpdf_oh_release_all(qpdf);
|
||||||
@ -682,18 +682,18 @@ static void test25(char const* infile,
|
|||||||
qpdf_oh p_bool = qpdf_oh_get_array_item(qpdf, parsed, 5);
|
qpdf_oh p_bool = qpdf_oh_get_array_item(qpdf, parsed, 5);
|
||||||
assert(qpdf_oh_is_integer(qpdf, p_int) &&
|
assert(qpdf_oh_is_integer(qpdf, p_int) &&
|
||||||
qpdf_oh_get_int_value_as_int(qpdf, p_int) == 1);
|
qpdf_oh_get_int_value_as_int(qpdf, p_int) == 1);
|
||||||
assert(qpdf_oh_get_type_code(qpdf, p_int) == qpdf_ot_integer);
|
assert(qpdf_oh_get_type_code(qpdf, p_int) == ot_integer);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_int), "integer") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_int), "integer") == 0);
|
||||||
assert(qpdf_oh_is_real(qpdf, p_real) &&
|
assert(qpdf_oh_is_real(qpdf, p_real) &&
|
||||||
(strcmp(qpdf_oh_get_real_value(qpdf, p_real), "2.0") == 0) &&
|
(strcmp(qpdf_oh_get_real_value(qpdf, p_real), "2.0") == 0) &&
|
||||||
qpdf_oh_get_numeric_value(qpdf, p_real) == 2.0);
|
qpdf_oh_get_numeric_value(qpdf, p_real) == 2.0);
|
||||||
assert(qpdf_oh_get_type_code(qpdf, p_real) == qpdf_ot_real);
|
assert(qpdf_oh_get_type_code(qpdf, p_real) == ot_real);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_real), "real") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_real), "real") == 0);
|
||||||
assert(qpdf_oh_is_string(qpdf, p_string) &&
|
assert(qpdf_oh_is_string(qpdf, p_string) &&
|
||||||
(strcmp(qpdf_oh_get_string_value(qpdf, p_string), "3\xf7") == 0) &&
|
(strcmp(qpdf_oh_get_string_value(qpdf, p_string), "3\xf7") == 0) &&
|
||||||
(strcmp(qpdf_oh_get_utf8_value(qpdf, p_string), "3\xc3\xb7") == 0) &&
|
(strcmp(qpdf_oh_get_utf8_value(qpdf, p_string), "3\xc3\xb7") == 0) &&
|
||||||
(strcmp(qpdf_oh_unparse_binary(qpdf, p_string), "<33f7>") == 0));
|
(strcmp(qpdf_oh_unparse_binary(qpdf, p_string), "<33f7>") == 0));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, p_string) == qpdf_ot_string);
|
assert(qpdf_oh_get_type_code(qpdf, p_string) == ot_string);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_string), "string") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_string), "string") == 0);
|
||||||
assert(qpdf_oh_is_dictionary(qpdf, p_dict));
|
assert(qpdf_oh_is_dictionary(qpdf, p_dict));
|
||||||
qpdf_oh p_five = qpdf_oh_get_key(qpdf, p_dict, "/Four");
|
qpdf_oh p_five = qpdf_oh_get_key(qpdf, p_dict, "/Four");
|
||||||
@ -701,11 +701,11 @@ static void test25(char const* infile,
|
|||||||
assert(qpdf_oh_is_or_has_name(
|
assert(qpdf_oh_is_or_has_name(
|
||||||
qpdf, qpdf_oh_get_array_item(qpdf, p_five, 0), "/Five"));
|
qpdf, qpdf_oh_get_array_item(qpdf, p_five, 0), "/Five"));
|
||||||
assert(qpdf_oh_is_null(qpdf, p_null));
|
assert(qpdf_oh_is_null(qpdf, p_null));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, p_null) == qpdf_ot_null);
|
assert(qpdf_oh_get_type_code(qpdf, p_null) == ot_null);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_null), "null") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_null), "null") == 0);
|
||||||
assert(qpdf_oh_is_bool(qpdf, p_bool) &&
|
assert(qpdf_oh_is_bool(qpdf, p_bool) &&
|
||||||
(qpdf_oh_get_bool_value(qpdf, p_bool) == QPDF_TRUE));
|
(qpdf_oh_get_bool_value(qpdf, p_bool) == QPDF_TRUE));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, p_bool) == qpdf_ot_boolean);
|
assert(qpdf_oh_get_type_code(qpdf, p_bool) == ot_boolean);
|
||||||
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_bool), "boolean") == 0);
|
assert(strcmp(qpdf_oh_get_type_name(qpdf, p_bool), "boolean") == 0);
|
||||||
qpdf_oh_erase_item(qpdf, parsed, 4);
|
qpdf_oh_erase_item(qpdf, parsed, 4);
|
||||||
qpdf_oh_insert_item(
|
qpdf_oh_insert_item(
|
||||||
@ -763,7 +763,7 @@ static void test26(char const* infile,
|
|||||||
qpdf_data qpdf2 = qpdf_init();
|
qpdf_data qpdf2 = qpdf_init();
|
||||||
qpdf_oh trailer = qpdf_get_trailer(qpdf2);
|
qpdf_oh trailer = qpdf_get_trailer(qpdf2);
|
||||||
assert(! qpdf_oh_is_initialized(qpdf2, trailer));
|
assert(! qpdf_oh_is_initialized(qpdf2, trailer));
|
||||||
assert(qpdf_oh_get_type_code(qpdf, trailer) == qpdf_ot_uninitialized);
|
assert(qpdf_oh_get_type_code(qpdf, trailer) == ot_uninitialized);
|
||||||
qpdf_cleanup(&qpdf2);
|
qpdf_cleanup(&qpdf2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user