diff --git a/new/GNUbase.mk b/new/GNUbase.mk new file mode 100644 index 00000000..329bfe9d --- /dev/null +++ b/new/GNUbase.mk @@ -0,0 +1,51 @@ +# 22 april 2015 + +OUTBASE = new +OUTDIR = out +OBJDIR = .obj + +xHFILES = \ + ui.h \ + $(baseHFILES) + +OFILES = \ + $(baseCFILES:%.c=$(OBJDIR)/%.o) \ + $(baseMFILES:%.m=$(OBJDIR)/%.o) + +xCFLAGS = \ + -g \ + -Wall -Wextra \ + -Wno-unused-parameter \ + -Wno-switch \ + --std=c99 \ + -fPIC \ + $(CFLAGS) \ + $(baseCFLAGS) + +xLDFLAGS = \ + -g \ + -fPIC \ + $(LDFLAGS) \ + $(baseLDFLAGS) + +OUT = $(OUTDIR)/$(OUTBASE)$(baseSUFFIX) + +$(OUT): $(OFILES) | $(OUTDIR)/.phony + $(CC) -o $(OUT) $(OFILES) $(xLDFLAGS) + +.SECONDEXPANSION: +$(OBJDIR)/%.o: %.c $(xHFILES) | $$(dir $$@).phony + $(CC) -o $@ -c $< $(xCFLAGS) + +# see http://www.cmcrossroads.com/article/making-directories-gnu-make +%/.phony: + mkdir -p $(dir $@) + touch $@ +.PRECIOUS: %/.phony + +ui.h: ui.idl + idl2h -extern _UI_EXTERN < ui.idl > ui.h + +clean: + rm -rf $(OUTDIR) $(OBJDIR) ui.h +.PHONY: clean diff --git a/new/GNUmakefile b/new/GNUmakefile index 3058baab..588bf05d 100644 --- a/new/GNUmakefile +++ b/new/GNUmakefile @@ -1,9 +1,5 @@ # 22 april 2015 -OUTBASE = new -OUTDIR = out -OBJDIR = .obj - # MAME does this so :/ ifeq ($(OS),Windows_NT) OS = windows @@ -20,64 +16,24 @@ endif include $(OS)/GNUmakeinc.mk -HFILES = \ +baseHFILES = \ ui.h \ uipriv.h \ - ui_$(OS).h + ui_$(OS).h \ + $(osHFILES) -OFILES = \ - $(CFILES:%.c=$(OBJDIR)/%.o) \ - $(osCFILES:%.c=$(OBJDIR)/%.o) +baseCFILES = \ + box.c \ + $(osCFILES) -xCFLAGS = \ - -g \ - -Wall -Wextra \ - -Wno-unused-parameter \ - -Wno-switch \ - --std=c99 \ - -fPIC \ - $(CFLAGS) +baseMFILES = $(osMFILES) -xLDFLAGS = \ - -g \ - -fPIC \ - $(LDFLAGS) +baseCFLAGS = $(osCFLAGS) +baseLDFLAGS = -shared $(osLDFLAGS) +baseSUFFIX = $(osLIBSUFFIX) -OUT = $(OUTDIR)/$(OUTBASE)$(osLIBSUFFIX) +include GNUbase.mk -include test/GNUmakeinc.mk - -testOFILES = $(testCFILES:%.c=$(OBJ)/test/%.o) - -TEST = $(OUTDIR)/$(OUTBASE)$(osEXESUFFIX) - -default: $(OUT) -test: $(TEST) -.PHONY: default test - -$(OUT): $(OFILES) dirs - $(CC) -o $(OUT) $(OFILES) -shared $(xLDFLAGS) $(osLDFLAGS) - -$(OBJDIR)/%.o: %.c $(HFILES) $(osHFILES) dirs - $(CC) -o $@ -c $< $(xCFLAGS) $(osCFLAGS) - -$(TEST): $(OUT) $(testOFILES) dirs $(OBJDIR)/test/.phony - $(CC) -o $(TEST) $(testOFILES) $(OUT) $(xLDFLAGS) - -$(OBJDIR)/test/%.o: test/%.c ui.h dirs $(OBJDIR)/test/.phony - $(CC) -o $@ -c $< $(xCFLAGS) - -dirs: $(OBJDIR)/.phony $(OBJDIR)/$(OS)/.phony $(OUTDIR)/.phony -.PHONY: dirs - -# see http://www.cmcrossroads.com/article/making-directories-gnu-make -%/.phony: - mkdir -p $(dir $@) - touch $@ - -ui.h: ui.idl - idl2h -extern _UI_EXTERN < ui.idl > ui.h - -clean: - rm -rf $(OUTDIR) $(OBJDIR) ui.h -.PHONY: clean +test: + $(MAKE) -f GNUmaketest.mk osLIB=$(OUT) osEXESUFFIX=$(osEXESUFFIX) +.PHONY: test diff --git a/new/GNUmaketest.mk b/new/GNUmaketest.mk new file mode 100644 index 00000000..f769d68f --- /dev/null +++ b/new/GNUmaketest.mk @@ -0,0 +1,16 @@ +# 22 april 2015 +# should never be invoked directly, only ever from the main makefile + +include test/GNUmakeinc.mk + +baseHFILES = \ + ui.h \ + $(testHFILES) + +baseCFILES = $(testCFILES) + +baseCFLAGS = $(testCFLAGS) +baseLDFLAGS = $(osLIB) $(testLDFLAGS) +baseSUFFIX = $(osEXESUFFIX) + +include GNUbase.mk diff --git a/new/box.c b/new/box.c index fd4eb14c..0f6f10c8 100644 --- a/new/box.c +++ b/new/box.c @@ -1,4 +1,5 @@ // 7 april 2015 +#include "ui.h" #include "uipriv.h" typedef struct box box; @@ -229,8 +230,8 @@ static void boxShow(uiControl *c) if (!b->containerHid) { for (i = 0; i < b->len; i++) uiControlContainerShow(b->controls[i].c); - if (b->parent != NULL) - uiParentUpdate(b->parent); + if (b->osContainer != NULL) + uiOSContainerUpdate(b->osContainer); } } @@ -242,8 +243,8 @@ static void boxHide(uiControl *c) b->userHid = 1; for (i = 0; i < b->len; i++) uiControlContainerHide(b->controls[i].c); - if (b->parent != NULL) - uiParentUpdate(b->parent); + if (b->osContainer != NULL) + uiOSContainerUpdate(b->osContainer); } static void boxContainerShow(uiControl *c) @@ -255,8 +256,8 @@ static void boxContainerShow(uiControl *c) if (!b->userHid) { for (i = 0; i < b->len; i++) uiControlContainerShow(b->controls[i].c); - if (b->parent != NULL) - uiParentUpdate(b->parent); + if (b->osContainer != NULL) + uiOSContainerUpdate(b->osContainer); } } @@ -268,8 +269,8 @@ static void boxContainerHide(uiControl *c) b->containerHid = 1; for (i = 0; i < b->len; i++) uiControlContainerHide(b->controls[i].c); - if (b->parent != NULL) - uiParentUpdate(b->parent); + if (b->osContainer != NULL) + uiOSContainerUpdate(b->osContainer); } static void boxEnable(uiControl *c) @@ -327,10 +328,10 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy) uiControlSethasParent(c, 1); b->controls[b->len].c = c; b->controls[b->len].stretchy = stretchy; - b->len++; // must be here for parent updates to work + b->len++; // must be here for OS container updates to work if (b->osContainer != NULL) { uiControlSetOSContainer(b->controls[b->len - 1].c, b->osContainer); - uiParentUpdate(b->parent); + uiOSContainerUpdate(b->osContainer); } } @@ -349,7 +350,7 @@ static void boxDelete(uiBox *ss, uintmax_t index) uiControlSetHasParent(removed, 0); if (b->osContainer != NULL) { uiControlSetOSContainer(removed, NULL); - uiParentUpdate(b->parent); + uiOSContainerUpdate(b->osContainer); } } @@ -365,8 +366,8 @@ static void boxSetPadded(uiBox *ss, int padded) box *b = (box *) ss; b->padded = padded; - if (b->parent != NULL) - uiParentUpdate(b->parent); + if (b->osContainer != NULL) + uiOSContainerUpdate(b->osContainer); } uiBox *uiNewHorizontalBox(void) diff --git a/new/test/GNUmakeinc.mk b/new/test/GNUmakeinc.mk new file mode 100644 index 00000000..1d42e09e --- /dev/null +++ b/new/test/GNUmakeinc.mk @@ -0,0 +1,8 @@ +# 22 april 2015 + +testCFILES = \ + test/main.c \ + test/spaced.c + +testHFILES = \ + test/test.h diff --git a/new/test/main.c b/new/test/main.c new file mode 100644 index 00000000..27e712e5 --- /dev/null +++ b/new/test/main.c @@ -0,0 +1,8 @@ +// 22 april 2015 +#include "test.h" + +int main(void) +{ + printf("hello, world %p\n", uiMain); + return 0; +} diff --git a/new/uipriv.h b/new/uipriv.h index e69de29b..4908ccaf 100644 --- a/new/uipriv.h +++ b/new/uipriv.h @@ -0,0 +1,11 @@ +// 6 april 2015 +#include + +extern uiInitOptions options; + +extern void *uiAlloc(size_t, const char *); +#define uiNew(T) ((T *) uiAlloc(sizeof (T), #T )) +extern void *uiRealloc(void *, size_t, const char *); +extern void uiFree(void *); + +extern void complain(const char *, ...);