diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-05-29 21:26:27 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-05-29 21:26:27 -0700 |
commit | 6a99f56239d5e9f04188ca96f1c3058ebaf13a72 (patch) | |
tree | 7f992e9779f79ee8a4322336f4aadf7b4bd29ae1 | |
parent | 43cffaaba00e44c5b30934087a712f0c152dc7ab (diff) |
libstage: expose struct stage_t size publiclypublic-size
The existing stage.h has been renamed to stage-public.h, and stage.h
is now generated as part of the build.
The generated stage.h now declares a padded struct stage_t after
including the original stage.h as stage-public.h.
The real struct stage_t has moved out of stage.c into stage-private.h,
which is very similar to the generated stage.h but declares a the real
struct stage_t instaed of the padded one. The internal code while
building libstage.a simply includes stage-private.h to get the real
struct and everything from stage-public.h.
My main annoyance with this approach is it leaves stage.h and
libstage.a in @top_builddir@/src, but stage-public.h at
@top_srcdir@/src. I generally use this library in a vendored form,
without performing any `make install` step. Currently, when I use it,
my outer autotools project vendoring this library adds
-I@top_srcdir@/libstage/src to get the headers, and it looks like it
will need to *add* -I@top_builddir@/libstage/src to get the generated
stage.h while keeping the -I@top_srcdir@/libstage/src for
stage-public.h.
Sigh, there's probably a simple way to make the build simply copy
the stage-public.h to @top_builddir@/src. I made some experiments
with that, and at least when using the same filename, it seemed to
get confused because the file existed in @top_srcdir@/src despite
being in BUILT_SOURCES and CLEANFILES, and it tended to clobber
the copy in @top_srcdir@/src. Leaving that as a TODO for a future
day.
-rw-r--r-- | src/Makefile.am | 13 | ||||
-rw-r--r-- | src/stage-private.h | 23 | ||||
-rw-r--r-- | src/stage-public.h (renamed from src/stage.h) | 4 | ||||
-rw-r--r-- | src/stage.c | 20 |
4 files changed, 38 insertions, 22 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index de38d5f..400a0fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,14 @@ noinst_LIBRARIES = libstage.a -libstage_a_SOURCES = ../include/dll_h/dll.h stage.c stage.h +noinst_PROGRAMS = stage-header + +libstage_a_SOURCES = ../include/dll_h/dll.h stage-private.h stage-public.h stage.c libstage_a_CPPFLAGS = -I@top_srcdir@/include + +stage_header_SOURCES = ../include/dll_h/dll.h stage-private.h stage-header.c +stage_header_CPPFLAGS = -I@top_srcdir@/include + +BUILT_SOURCES = stage.h +CLEANFILES = stage.h + +stage.h: Makefile stage-header + @top_builddir@/src/stage-header >$@ diff --git a/src/stage-private.h b/src/stage-private.h new file mode 100644 index 0000000..ac045a4 --- /dev/null +++ b/src/stage-private.h @@ -0,0 +1,23 @@ +#ifndef _STAGE_PRIVATE_H +#define _STAGE_PRIVATE_H + +#include <dll_h/dll.h> + +#include "stage-public.h" + +struct stage_t { + stage_t *parent; /* NULL when root stage */ + dll_t layer; /* node on parent->layers[layer] when parent != NULL */ + dll_t layers[STAGE_LAYERS_MAX]; + char name[STAGE_NAME_MAX]; + float alpha; /* alpha for the stage */ + unsigned active:1; /* stage is active */ + unsigned locked:1; /* stage is locked */ + unsigned dirty:1; /* stage is dirty (since last render) */ + unsigned allocated:1; /* stage is allocated by libstage, needs freeing. */ + + const stage_ops_t *ops; /* ops for operating on this stage's object */ + void *object; /* this stage's object */ +}; + +#endif diff --git a/src/stage.h b/src/stage-public.h index 40f2057..d7bd4fe 100644 --- a/src/stage.h +++ b/src/stage-public.h @@ -14,8 +14,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _STAGE_H -#define _STAGE_H +#ifndef _STAGE_PUBLIC_H +#define _STAGE_PUBLIC_H #define STAGE_NAME_MAX 16 #define STAGE_LAYERS_MAX 10 diff --git a/src/stage.c b/src/stage.c index a714f1f..106186e 100644 --- a/src/stage.c +++ b/src/stage.c @@ -18,25 +18,7 @@ #include <stdlib.h> #include <string.h> -#include <dll_h/dll.h> - -#include "stage.h" - - -struct stage_t { - stage_t *parent; /* NULL when root stage */ - dll_t layer; /* node on parent->layers[layer] when parent != NULL */ - dll_t layers[STAGE_LAYERS_MAX]; - char name[STAGE_NAME_MAX]; - float alpha; /* alpha for the stage */ - unsigned active:1; /* stage is active */ - unsigned locked:1; /* stage is locked */ - unsigned dirty:1; /* stage is dirty (since last render) */ - unsigned allocated:1; /* stage is allocated by libstage, needs freeing. */ - - const stage_ops_t *ops; /* ops for operating on this stage's object */ - void *object; /* this stage's object */ -}; +#include "stage-private.h" /* minimally initialize a stage to carry an object */ |