diff options
| author | Thomas Knudsen <lastname DOT firstname AT gmail DOT com> | 2016-04-07 22:21:21 +0200 |
|---|---|---|
| committer | Thomas Knudsen <lastname DOT firstname AT gmail DOT com> | 2016-04-07 22:21:21 +0200 |
| commit | 2d111097d76ce52fb0ba019b20e02b33abe842ed (patch) | |
| tree | 8e73195c423859bd6926a843167fceeb054bc6ff /src/pj_list.c | |
| parent | 2dc4630e3fb5cabb46a4678109e58aee7ab242d8 (diff) | |
| download | PROJ-2d111097d76ce52fb0ba019b20e02b33abe842ed.tar.gz PROJ-2d111097d76ce52fb0ba019b20e02b33abe842ed.zip | |
pj_list cleanup + added selftest stubs for all projections
The projection list maintained by code in pj_list.c depended on stuff in
projects.h.
This stuff is non-obvious and since it is only used in pj_list.c, it has
been moved from projects.h to pj_list.c (The material moved is based on
some really clever X-macro techniques implemented by numerous
redefinitions of the PROJ_HEAD macro, followed by immediate re-inclusion
of te pj_list.h file).
Also, the self test runner pj_run_selftests has been remodelled, now
depending on a list of self test functions, generated in a similar way
to the projection list, and like the projection list generated by
X-macro techniques in pj_list.c.
For this to work, self test functions need to be available for all
projections. To fulfill this, stubs for all projections not having self
tests already, have been added to PJ_aea.c
Along with the recent build system patches by @kbevers, this first part
of the macro-refactoring project is considered close to finished.
Diffstat (limited to 'src/pj_list.c')
| -rw-r--r-- | src/pj_list.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/pj_list.c b/src/pj_list.c index bb56ade9..a8f171ab 100644 --- a/src/pj_list.c +++ b/src/pj_list.c @@ -1,11 +1,56 @@ /* Projection System: default list of projections ** Use local definition of PJ_LIST_H for subset. */ + #define USE_PJ_LIST_H 1 #include "projects.h" -struct PJ_LIST *pj_get_list_ref() -{ + +#define PASTE(a,b) a##b + +/* Generate prototypes for projection functions */ +#define PROJ_HEAD(id, name) struct PJconsts *pj_##id(struct PJconsts*); +#include "pj_list.h" +#undef PROJ_HEAD + +/* Generate prototypes for projection selftest functions */ +#define PROJ_HEAD(id, name) int PASTE(pj_##id, _selftest) (void); +#include "pj_list.h" +#undef PROJ_HEAD + + +/* Generate extern declarations for description strings */ +#define PROJ_HEAD(id, name) extern char * const pj_s_##id; +#include "pj_list.h" +#undef PROJ_HEAD + + +/* Generate the null-terminated list of projection functions with associated mnemonics and descriptions */ +#define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id}, +struct PJ_LIST pj_list[] = { +#include "pj_list.h" + {0, 0, 0}, + }; +#undef PROJ_HEAD + + +/* Generate the null-terminated list of projection selftest functions with associated mnemonics */ +#define PROJ_HEAD(id, name) {#id, PASTE(pj_##id, _selftest)}, +struct PJ_SELFTEST_LIST pj_selftest_list[] = { +#include "pj_list.h" + {0, 0}, + }; +#undef PROJ_HEAD +#undef PASTE + + +struct PJ_LIST *pj_get_list_ref (void) { return pj_list; } + + +struct PJ_SELFTEST_LIST *pj_get_selftest_list_ref (void) { + return pj_selftest_list; +} + |
