diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-02-27 12:39:52 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-03-22 14:58:18 +0100 |
commit | 8d6283fd202e650e80470a544442d384d10a0b7e (patch) | |
tree | a0f76ac4ae13e718e3a710d22e4e8fcd9a6e22a4 /source/pdf/pdf-object.c | |
parent | fcba4e1afa05d3d2b57378246140ed613c029042 (diff) | |
download | mupdf-8d6283fd202e650e80470a544442d384d10a0b7e.tar.xz |
Add pdf_dict_put_dict family of functions.
pdf_dict_put_dict creates a new empty dictionary, inserts it
into the parent dictionary, and returns a borrowed reference to it.
These functions should simplify document creation by removing the
need to wrap creation with try/catch for reference counting cleanup.
Diffstat (limited to 'source/pdf/pdf-object.c')
-rw-r--r-- | source/pdf/pdf-object.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index b7ba2e7a..9b1ef7b5 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -2225,6 +2225,20 @@ void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const fz_ pdf_dict_put_drop(ctx, dict, key, pdf_new_matrix(ctx, NULL, x)); } +pdf_obj *pdf_dict_put_array(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial) +{ + pdf_obj *obj = pdf_new_array(ctx, pdf_get_bound_document(ctx, dict), initial); + pdf_dict_put_drop(ctx, dict, key, obj); + return obj; +} + +pdf_obj *pdf_dict_put_dict(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial) +{ + pdf_obj *obj = pdf_new_dict(ctx, pdf_get_bound_document(ctx, dict), initial); + pdf_dict_put_drop(ctx, dict, key, obj); + return obj; +} + void pdf_array_push_bool(fz_context *ctx, pdf_obj *array, int x) { pdf_array_push_drop(ctx, array, pdf_new_bool(ctx, NULL, x)); @@ -2254,3 +2268,17 @@ void pdf_array_push_text_string(fz_context *ctx, pdf_obj *array, const char *x) { pdf_array_push_drop(ctx, array, pdf_new_text_string(ctx, NULL, x)); } + +pdf_obj *pdf_array_push_array(fz_context *ctx, pdf_obj *array, int initial) +{ + pdf_obj *obj = pdf_new_array(ctx, pdf_get_bound_document(ctx, array), initial); + pdf_array_push_drop(ctx, array, obj); + return obj; +} + +pdf_obj *pdf_array_push_dict(fz_context *ctx, pdf_obj *array, int initial) +{ + pdf_obj *obj = pdf_new_dict(ctx, pdf_get_bound_document(ctx, array), initial); + pdf_array_push_drop(ctx, array, obj); + return obj; +} |