summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2020-08-11 16:13:55 +0100
committerRobin Watts <Robin.Watts@artifex.com>2020-08-11 16:14:36 +0100
commitfbe65ad97b583611ad854941927aa4b5a6642c55 (patch)
tree2a554c690bd46889bd384d518e0b988522211d78
parent4a98669de4caf9ac9598ba28633979c78f31d884 (diff)
downloadghostpdl-fbe65ad97b583611ad854941927aa4b5a6642c55.tar.gz
Swap order of arguments in gsapi_set_param/gsapi_get_param.
This should play nicer with python.
-rw-r--r--demos/c/api_test.c33
-rw-r--r--doc/API.htm8
-rw-r--r--doc/GPDL.htm2
-rw-r--r--pcl/pl/plapi.c4
-rw-r--r--pcl/pl/plapi.h4
-rw-r--r--psi/iapi.c4
-rw-r--r--psi/iapi.h6
-rw-r--r--psi/imainarg.c2
8 files changed, 38 insertions, 25 deletions
diff --git a/demos/c/api_test.c b/demos/c/api_test.c
index 249339093..780f70df3 100644
--- a/demos/c/api_test.c
+++ b/demos/c/api_test.c
@@ -863,14 +863,14 @@ list_params(void *instance)
while ((code = gsapi_enumerate_params(instance, &iter, &key, &type)) == 0) {
printf("Key=%s, type=%s: ", key, type >= 0 && type <= 9 ? types[type] : "invalid");
- code = gsapi_get_param(instance, gs_spt_parsed, key, NULL);
+ code = gsapi_get_param(instance, key, NULL, gs_spt_parsed);
if (code < 0)
break;
if (code > sizeof(buffer)) {
printf("<overly long value>\n");
continue;
}
- code = gsapi_get_param(instance, gs_spt_parsed, key, buffer);
+ code = gsapi_get_param(instance, key, buffer, gs_spt_parsed);
if (code < 0)
break;
printf("%s\n", buffer);
@@ -889,6 +889,7 @@ param_test(const char *dev, char *outfile)
/* Construct the argc/argv to pass to ghostscript. */
int argc = 0;
char *argv[10];
+ int i;
sprintf(devtext, "-sDEVICE=%s", dev);
argv[argc++] = "gpdl";
@@ -903,7 +904,7 @@ param_test(const char *dev, char *outfile)
goto failearly;
}
- code = gsapi_set_param(instance, gs_spt_parsed, "Foo", "0");
+ code = gsapi_set_param(instance, "Foo", "0", gs_spt_parsed);
if (code < 0) {
printf("Got error from early param setting.\n");
goto fail;
@@ -923,20 +924,20 @@ param_test(const char *dev, char *outfile)
goto fail;
}
- code = gsapi_set_param(instance, gs_spt_parsed | gs_spt_more_to_come, "Bar", "1");
+ code = gsapi_set_param(instance, "Bar", "1", gs_spt_parsed | gs_spt_more_to_come);
if (code < 0) {
printf("Error %d in gsapi_set_param\n", code);
goto fail;
}
- code = gsapi_set_param(instance, gs_spt_parsed, "Baz", "<</Test[0 1 2.3]/Charm(>>)/Vixen<01234567>/Scented/Ephemeral>>");
+ code = gsapi_set_param(instance, "Baz", "<</Test[0 1 2.3]/Charm(>>)/Vixen<01234567>/Scented/Ephemeral>>", gs_spt_parsed);
if (code < 0) {
printf("Error %d in gsapi_set_param\n", code);
goto fail;
}
/* This should fail, as /Baz is not an expected error. */
- code = gsapi_get_param(instance, gs_spt_parsed, "Baz", buffer);
+ code = gsapi_get_param(instance, "Baz", buffer, gs_spt_parsed);
if (code == -1) {
printf("Got expected error gsapi_get_param\n");
} else {
@@ -944,13 +945,25 @@ param_test(const char *dev, char *outfile)
goto fail;
}
- code = gsapi_set_param(instance, gs_spt_parsed, "GrayImageDict", "<</QFactor 0.1 /Blend 0/HSamples [1 1 1 1] /VSamples [ 1 1 1 1 ] /Foo[/A/B/C/D/E] /Bar (123) /Baz <0123> /Sp#20ce /D#7fl>>");
+ code = gsapi_set_param(instance, "foo", (void *)"32", gs_spt_int);
if (code < 0) {
printf("Error %d in gsapi_set_param\n", code);
goto fail;
}
- code = gsapi_get_param(instance, gs_spt_parsed, "GrayImageDict", NULL);
+ code = gsapi_get_param(instance, "foo", (void *)&i, gs_spt_int);
+ if (code < 0) {
+ printf("Error %d in gsapi_set_param\n", code);
+ goto fail;
+ }
+
+ code = gsapi_set_param(instance, "GrayImageDict", "<</QFactor 0.1 /Blend 0/HSamples [1 1 1 1] /VSamples [ 1 1 1 1 ] /Foo[/A/B/C/D/E] /Bar (123) /Baz <0123> /Sp#20ce /D#7fl>>", gs_spt_parsed);
+ if (code < 0) {
+ printf("Error %d in gsapi_set_param\n", code);
+ goto fail;
+ }
+
+ code = gsapi_get_param(instance, "GrayImageDict", NULL, gs_spt_parsed);
if (code < 0) {
printf("Error %d in gsapi_get_param\n", code);
goto fail;
@@ -958,7 +971,7 @@ param_test(const char *dev, char *outfile)
len = code;
buffer[len-1] = 98;
buffer[len] = 99;
- code = gsapi_get_param(instance, gs_spt_parsed, "GrayImageDict", buffer);
+ code = gsapi_get_param(instance, "GrayImageDict", buffer, gs_spt_parsed);
if (code < 0) {
printf("Error %d in gsapi_get_param\n", code);
goto fail;
@@ -1028,7 +1041,7 @@ res_change_test(const char *dev, char *outfile)
goto fail;
}
- code = gsapi_set_param(instance, gs_spt_parsed, "HWResolution", "[200 200]");
+ code = gsapi_set_param(instance, "HWResolution", "[200 200]", gs_spt_parsed);
if (code < 0) {
printf("Error %d in gsapi_set_param\n", code);
goto fail;
diff --git a/doc/API.htm b/doc/API.htm
index 972362c44..9ca23c617 100644
--- a/doc/API.htm
+++ b/doc/API.htm
@@ -267,12 +267,12 @@ int
<li><code>
int
-<a href="#set_param">gsapi_set_param</a>(void *instance, gs_set_param_type type, const char *param, const void *value);
+<a href="#set_param">gsapi_set_param</a>(void *instance, const char *param, const void *value, gs_set_param_type type);
</code></li>
<li><code>
-int
-<a href="#get_param">gsapi_get_param</a>(void *instance, gs_set_param_type type, const char *param, const void *value);
+ int
+ <a href="#get_param">gsapi_get_param</a>(void *instance, const char *param, const void *value, gs_set_param_type type);
</code></li>
<li><code>
@@ -1622,7 +1622,7 @@ return <code>max(200, 200*(bandheight/200))</code>. If the function
returns 0, then the existing value will be used unchanged.</p>
<p>Any size rectangle can be chosen with any size bandheight,
so ultimately the value chosen here will not matter much. It
-may make some small difference in speed in some cases.</p>
+may make some small difference in speed in some cases.</p>
<h3><a name="display_rectangle_request"></a>display_rectangle_request</h3>
<pre>int (*display_rectangle_request)(void *handle, void *device,
diff --git a/doc/GPDL.htm b/doc/GPDL.htm
index 36d256bee..d8fca2ea3 100644
--- a/doc/GPDL.htm
+++ b/doc/GPDL.htm
@@ -257,7 +257,7 @@ applies both to API calls and uses of the executable.</p>
<p>GhostPDL does not support the <code>-_</code>, <code>-+</code>,
<code>-@</code>, <code>-B</code>, <code>-F</code>, <code>-M</code>,
-<code>-N</code>, <code>-p</code>, <code>-u</code>, and <code>-X</code>
+<code>-N</code>, <code>-P</code>, <code>-u</code>, and <code>-X</code>
switches that Ghostscript does.
<p>GhostPDL supports a few switches that the Ghostscript executable
diff --git a/pcl/pl/plapi.c b/pcl/pl/plapi.c
index 145a4cb31..2ea322c83 100644
--- a/pcl/pl/plapi.c
+++ b/pcl/pl/plapi.c
@@ -378,7 +378,7 @@ gsapi_run_string(void *lib, const char *str,
}
GSDLLEXPORT int GSDLLAPI
-gsapi_set_param(void *lib, gs_set_param_type type, const char *param, const void *value)
+gsapi_set_param(void *lib, const char *param, const void *value, gs_set_param_type type)
{
gs_lib_ctx_t *ctx = (gs_lib_ctx_t *)lib;
if (lib == NULL)
@@ -387,7 +387,7 @@ gsapi_set_param(void *lib, gs_set_param_type type, const char *param, const void
}
GSDLLEXPORT int GSDLLAPI
-gsapi_get_param(void *lib, gs_set_param_type type, const char *param, void *value)
+gsapi_get_param(void *lib, const char *param, void *value, gs_set_param_type type)
{
gs_lib_ctx_t *ctx = (gs_lib_ctx_t *)lib;
if (lib == NULL)
diff --git a/pcl/pl/plapi.h b/pcl/pl/plapi.h
index 8070b50b6..e0f311932 100644
--- a/pcl/pl/plapi.h
+++ b/pcl/pl/plapi.h
@@ -339,7 +339,7 @@ typedef enum {
/* gs_spt_parsed allows for a string such as "<< /Foo 0 /Bar true >>" or
* "[ 1 2 3 ]" etc to be used so more complex parameters can be set. */
-GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, gs_set_param_type type, const char *param, const void *value);
+GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, const char *param, const void *value, gs_set_param_type type);
/* Called to get a value. value points to storage of the appropriate
* type. If value is passed as NULL on entry, then the return code is
@@ -349,7 +349,7 @@ GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, gs_set_param_type type,
* terminated string. (nul terminator is included in the count - hence
* an empty string requires 1 byte storage). Returns gs_error_undefined
* (-21) if not found. */
-GSDLLEXPORT int GSDLLAPI gsapi_get_param(void *instance, gs_set_param_type type, const char *param, void *value);
+GSDLLEXPORT int GSDLLAPI gsapi_get_param(void *instance, const char *param, void *value, gs_set_param_type type);
/* Enumerator to list all the parameters.
* Caller defines void *iter = NULL, and calls with &iter.
diff --git a/psi/iapi.c b/psi/iapi.c
index 605c1921b..2bbf0f053 100644
--- a/psi/iapi.c
+++ b/psi/iapi.c
@@ -402,7 +402,7 @@ gsapi_exit(void *instance)
}
GSDLLEXPORT int GSDLLAPI
-gsapi_set_param(void *lib, gs_set_param_type type, const char *param, const void *value)
+gsapi_set_param(void *lib, const char *param, const void *value, gs_set_param_type type)
{
int code = 0;
gs_param_string str_value;
@@ -508,7 +508,7 @@ gsapi_set_param(void *lib, gs_set_param_type type, const char *param, const void
}
GSDLLEXPORT int GSDLLAPI
-gsapi_get_param(void *lib, gs_set_param_type type, const char *param, void *value)
+gsapi_get_param(void *lib, const char *param, void *value, gs_set_param_type type)
{
int code = 0;
gs_param_string str_value;
diff --git a/psi/iapi.h b/psi/iapi.h
index 671cf9085..3ba84e27c 100644
--- a/psi/iapi.h
+++ b/psi/iapi.h
@@ -397,7 +397,7 @@ typedef enum {
/* gs_spt_parsed allows for a string such as "<< /Foo 0 /Bar true >>" or
* "[ 1 2 3 ]" etc to be used so more complex parameters can be set. */
-GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, gs_set_param_type type, const char *param, const void *value);
+GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, const char *param, const void *value, gs_set_param_type type);
/* Called to get a value. value points to storage of the appropriate
* type. If value is passed as NULL on entry, then the return code is
@@ -407,7 +407,7 @@ GSDLLEXPORT int GSDLLAPI gsapi_set_param(void *instance, gs_set_param_type type,
* terminated string. (nul terminator is included in the count - hence
* an empty string requires 1 byte storage). Returns gs_error_undefined
* (-21) if not found. */
-GSDLLEXPORT int GSDLLAPI gsapi_get_param(void *instance, gs_set_param_type type, const char *param, void *value);
+GSDLLEXPORT int GSDLLAPI gsapi_get_param(void *instance, const char *param, void *value, gs_set_param_type type);
/* Enumerator to list all the parameters.
* Caller defines void *iter = NULL, and calls with &iter.
@@ -553,7 +553,7 @@ typedef int (GSDLLAPIPTR PFN_gsapi_run_fileW)(void *instance,
const wchar_t *file_name, int user_errors, int *pexit_code);
#endif
typedef int (GSDLLAPIPTR PFN_gsapi_exit)(void *instance);
-typedef int (GSDLLAPIPTR PFN_gsapi_set_param)(void *instance, gs_set_param_type type, const char *param, const void *value);
+typedef int (GSDLLAPIPTR PFN_gsapi_set_param)(void *instance, const char *param, const void *value, gs_set_param_type type);
typedef int (GSDLLAPIPTR PFN_gsapi_add_control_path)(void *instance, int type, const char *path);
typedef int (GSDLLAPIPTR PFN_gsapi_remove_control_path)(void *instance, int type, const char *path);
diff --git a/psi/imainarg.c b/psi/imainarg.c
index d2932a5b9..30ee6cca0 100644
--- a/psi/imainarg.c
+++ b/psi/imainarg.c
@@ -948,7 +948,7 @@ run_stdin:
/* Slightly uncomfortable calling back up to a higher
* level, but we'll live with it. */
code = gsapi_set_param(gs_lib_ctx_get_interp_instance(minst->heap),
- gs_spt_parsed, adef, eqp);
+ adef, eqp, gs_spt_parsed);
if (code < 0) {
arg_free((char *)adef, minst->heap);
return code;