summaryrefslogtreecommitdiff
path: root/Source/FusionDale/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FusionDale/src/core')
-rwxr-xr-xSource/FusionDale/src/core/Makefile.am26
-rwxr-xr-xSource/FusionDale/src/core/Makefile.in509
-rwxr-xr-xSource/FusionDale/src/core/dale_core.c578
-rwxr-xr-xSource/FusionDale/src/core/dale_core.h72
-rwxr-xr-xSource/FusionDale/src/core/dale_types.h38
-rwxr-xr-xSource/FusionDale/src/core/messenger.c305
-rwxr-xr-xSource/FusionDale/src/core/messenger.h160
-rwxr-xr-xSource/FusionDale/src/core/messenger_port.c939
-rwxr-xr-xSource/FusionDale/src/core/messenger_port.h137
9 files changed, 2764 insertions, 0 deletions
diff --git a/Source/FusionDale/src/core/Makefile.am b/Source/FusionDale/src/core/Makefile.am
new file mode 100755
index 0000000..40d4753
--- /dev/null
+++ b/Source/FusionDale/src/core/Makefile.am
@@ -0,0 +1,26 @@
+## Makefile.am for FusionDale/src/core
+
+INCLUDES = \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ $(FUSION_CFLAGS)
+
+AM_CPPFLAGS = \
+ -DMODULEDIR=\"${RUNTIME_SYSROOT}@MODULEDIR@\"
+
+noinst_LTLIBRARIES = \
+ libfusiondalecore.la
+
+coreincludedir = @INCLUDEDIR@/core
+
+coreinclude_HEADERS = \
+ dale_core.h \
+ dale_types.h \
+ messenger.h \
+ messenger_port.h
+
+libfusiondalecore_la_SOURCES = \
+ dale_core.c \
+ messenger.c \
+ messenger_port.c
diff --git a/Source/FusionDale/src/core/Makefile.in b/Source/FusionDale/src/core/Makefile.in
new file mode 100755
index 0000000..b958396
--- /dev/null
+++ b/Source/FusionDale/src/core/Makefile.in
@@ -0,0 +1,509 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/core
+DIST_COMMON = $(coreinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libfusiondalecore_la_LIBADD =
+am_libfusiondalecore_la_OBJECTS = dale_core.lo messenger.lo \
+ messenger_port.lo
+libfusiondalecore_la_OBJECTS = $(am_libfusiondalecore_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libfusiondalecore_la_SOURCES)
+DIST_SOURCES = $(libfusiondalecore_la_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(coreincludedir)"
+coreincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(coreinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FUSIONDALE_BINARY_AGE = @FUSIONDALE_BINARY_AGE@
+FUSIONDALE_INTERFACE_AGE = @FUSIONDALE_INTERFACE_AGE@
+FUSIONDALE_MAJOR_VERSION = @FUSIONDALE_MAJOR_VERSION@
+FUSIONDALE_MICRO_VERSION = @FUSIONDALE_MICRO_VERSION@
+FUSIONDALE_MINOR_VERSION = @FUSIONDALE_MINOR_VERSION@
+FUSIONDALE_VERSION = @FUSIONDALE_VERSION@
+FUSION_CFLAGS = @FUSION_CFLAGS@
+FUSION_LIBS = @FUSION_LIBS@
+GREP = @GREP@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ $(FUSION_CFLAGS)
+
+AM_CPPFLAGS = \
+ -DMODULEDIR=\"${RUNTIME_SYSROOT}@MODULEDIR@\"
+
+noinst_LTLIBRARIES = \
+ libfusiondalecore.la
+
+coreincludedir = @INCLUDEDIR@/core
+coreinclude_HEADERS = \
+ dale_core.h \
+ dale_types.h \
+ messenger.h \
+ messenger_port.h
+
+libfusiondalecore_la_SOURCES = \
+ dale_core.c \
+ messenger.c \
+ messenger_port.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/core/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/core/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libfusiondalecore.la: $(libfusiondalecore_la_OBJECTS) $(libfusiondalecore_la_DEPENDENCIES)
+ $(LINK) $(libfusiondalecore_la_OBJECTS) $(libfusiondalecore_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dale_core.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/messenger.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/messenger_port.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-coreincludeHEADERS: $(coreinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(coreincludedir)" || $(MKDIR_P) "$(DESTDIR)$(coreincludedir)"
+ @list='$(coreinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(coreincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(coreincludedir)/$$f'"; \
+ $(coreincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(coreincludedir)/$$f"; \
+ done
+
+uninstall-coreincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(coreinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(coreincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(coreincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(coreincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-coreincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-coreincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-coreincludeHEADERS install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-coreincludeHEADERS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Source/FusionDale/src/core/dale_core.c b/Source/FusionDale/src/core/dale_core.c
new file mode 100755
index 0000000..792faac
--- /dev/null
+++ b/Source/FusionDale/src/core/dale_core.c
@@ -0,0 +1,578 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include <pthread.h>
+
+#include <direct/debug.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/signals.h>
+#include <direct/util.h>
+
+#include <fusion/arena.h>
+#include <fusion/build.h>
+#include <fusion/conf.h>
+#include <fusion/fusion.h>
+#include <fusion/shmalloc.h>
+#include <fusion/object.h>
+
+#include <core/dale_core.h>
+#include <core/messenger.h>
+#include <core/messenger_port.h>
+
+#include <misc/dale_config.h>
+
+
+#define FUSIONDALE_CORE_ABI 1
+
+D_DEBUG_DOMAIN( Dale_Core, "FusionDale/Core", "FusionDale Core" );
+
+/**********************************************************************************************************************/
+
+struct __FD_CoreDaleShared {
+ int magic;
+
+ FusionObjectPool *messenger_pool;
+ FusionObjectPool *messenger_port_pool;
+
+ FusionSHMPoolShared *shmpool;
+};
+
+struct __FD_CoreDale {
+ int magic;
+
+ int refs;
+
+ int fusion_id;
+
+ FusionWorld *world;
+ FusionArena *arena;
+
+ CoreDaleShared *shared;
+
+ bool master;
+
+ DirectSignalHandler *signal_handler;
+};
+
+/**********************************************************************************************************************/
+
+static DirectSignalHandlerResult fd_core_signal_handler( int num,
+ void *addr,
+ void *ctx );
+
+/**********************************************************************************************************************/
+
+static int fd_core_arena_initialize( FusionArena *arena,
+ void *ctx );
+static int fd_core_arena_join ( FusionArena *arena,
+ void *ctx );
+static int fd_core_arena_leave ( FusionArena *arena,
+ void *ctx,
+ bool emergency);
+static int fd_core_arena_shutdown ( FusionArena *arena,
+ void *ctx,
+ bool emergency);
+
+/**********************************************************************************************************************/
+
+static CoreDale *core_dale = NULL;
+static pthread_mutex_t core_dale_lock = PTHREAD_MUTEX_INITIALIZER;
+
+DirectResult
+fd_core_create( CoreDale **ret_core )
+{
+ int ret;
+ CoreDale *core = NULL;
+
+ D_ASSERT( ret_core != NULL );
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ /* Lock the core singleton mutex. */
+ pthread_mutex_lock( &core_dale_lock );
+
+ /* Core already created? */
+ if (core_dale) {
+ /* Increase its references. */
+ core_dale->refs++;
+
+ /* Return the core. */
+ *ret_core = core_dale;
+
+ /* Unlock the core singleton mutex. */
+ pthread_mutex_unlock( &core_dale_lock );
+
+ return DR_OK;
+ }
+
+ /* Allocate local core structure. */
+ core = D_CALLOC( 1, sizeof(CoreDale) );
+ if (!core) {
+ ret = D_OOM();
+ goto error;
+ }
+
+ ret = fusion_enter( fusiondale_config->session, FUSIONDALE_CORE_ABI,
+ fusiondale_config->force_slave ? FER_SLAVE : FER_ANY, &core->world );
+ if (ret)
+ goto error;
+
+ core->fusion_id = fusion_id( core->world );
+
+ fusiondale_config->session = fusion_world_index( core->world );
+
+#if FUSION_BUILD_MULTI
+ D_DEBUG_AT( Dale_Core, " -> world %d, fusion id %d\n", fusiondale_config->session, core->fusion_id );
+#endif
+
+ /* Initialize the references. */
+ core->refs = 1;
+
+ direct_signal_handler_add( -1, fd_core_signal_handler, core, &core->signal_handler );
+
+ D_MAGIC_SET( core, CoreDale );
+
+ /* Enter the FusionDale core arena. */
+ if (fusion_arena_enter( core->world, "FusionDale/Core",
+ fd_core_arena_initialize, fd_core_arena_join,
+ core, &core->arena, &ret ) || ret)
+ {
+ D_MAGIC_CLEAR( core );
+ ret = ret ? : DR_FUSION;
+ goto error;
+ }
+
+ /* Return the core and store the singleton. */
+ *ret_core = core_dale = core;
+
+ /* Unlock the core singleton mutex. */
+ pthread_mutex_unlock( &core_dale_lock );
+
+ return DR_OK;
+
+
+error:
+ if (core) {
+ if (core->world) {
+ direct_signal_handler_remove( core->signal_handler );
+ fusion_exit( core->world, false );
+ }
+
+ D_FREE( core );
+ }
+
+ pthread_mutex_unlock( &core_dale_lock );
+
+ return ret;
+}
+
+DirectResult
+fd_core_destroy( CoreDale *core, bool emergency )
+{
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core == core_dale );
+
+ D_DEBUG_AT( Dale_Core, "%s( %p, %semergency )\n", __FUNCTION__, core, emergency ? "" : "no " );
+
+ /* Lock the core singleton mutex. */
+ if (!emergency)
+ pthread_mutex_lock( &core_dale_lock );
+
+ /* Decrement and check references. */
+ if (!emergency && --core->refs) {
+ /* Unlock the core singleton mutex. */
+ pthread_mutex_unlock( &core_dale_lock );
+
+ return DR_OK;
+ }
+
+ direct_signal_handler_remove( core->signal_handler );
+
+ /* Exit the FusionDale core arena. */
+ if (fusion_arena_exit( core->arena, fd_core_arena_shutdown,
+ core->master ? NULL : fd_core_arena_leave,
+ core, emergency, NULL ) == DR_BUSY)
+ {
+ if (core->master) {
+ if (emergency) {
+ fusion_kill( core->world, 0, SIGKILL, 1000 );
+ }
+ else {
+ fusion_kill( core->world, 0, SIGTERM, 5000 );
+ fusion_kill( core->world, 0, SIGKILL, 2000 );
+ }
+ }
+
+ while (fusion_arena_exit( core->arena, fd_core_arena_shutdown,
+ core->master ? NULL : fd_core_arena_leave,
+ core, emergency, NULL ) == DR_BUSY)
+ {
+ D_ONCE( "waiting for FusionDale slaves to terminate" );
+ usleep( 100000 );
+ }
+ }
+
+ fusion_exit( core->world, emergency );
+
+ D_MAGIC_CLEAR( core );
+
+ /* Deallocate local core structure. */
+ D_FREE( core );
+
+ /* Clear the singleton. */
+ core_dale = NULL;
+
+ /* Unlock the core singleton mutex. */
+ if (!emergency)
+ pthread_mutex_unlock( &core_dale_lock );
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+CoreMessenger *
+fd_core_create_messenger( CoreDale *core )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->messenger_pool != NULL );
+
+ /* Create a new object in the messenger pool. */
+ return (CoreMessenger*) fusion_object_create( core->shared->messenger_pool, core->world );
+}
+
+CoreMessengerPort *
+fd_core_create_messenger_port( CoreDale *core )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->messenger_port_pool != NULL );
+
+ /* Create a new object in the messenger port pool. */
+ return (CoreMessengerPort*) fusion_object_create( core->shared->messenger_port_pool, core->world );
+}
+
+/**********************************************************************************************************************/
+
+DirectResult
+fd_core_enum_messengers( CoreDale *core,
+ FusionObjectCallback callback,
+ void *ctx )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->messenger_pool != NULL );
+
+ /* Enumerate objects in the messenger pool. */
+ return fusion_object_pool_enum( core->shared->messenger_pool, callback, ctx );
+}
+
+DirectResult
+fd_core_enum_messenger_ports( CoreDale *core,
+ FusionObjectCallback callback,
+ void *ctx )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->messenger_port_pool != NULL );
+
+ /* Enumerate objects in the messenger port pool. */
+ return fusion_object_pool_enum( core->shared->messenger_port_pool, callback, ctx );
+}
+
+DirectResult
+fd_core_get_messenger( CoreDale *core,
+ FusionObjectID object_id,
+ CoreMessenger **ret_messenger )
+{
+ DirectResult ret;
+ FusionObject *object;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->messenger_port_pool != NULL );
+
+ D_ASSERT( ret_messenger != NULL );
+
+ /* Enumerate objects in the messenger port pool. */
+ ret = fusion_object_get( core->shared->messenger_pool, object_id, &object );
+ if (ret)
+ return ret;
+
+ D_MAGIC_ASSERT( (CoreMessenger*) object, CoreMessenger );
+
+ *ret_messenger = (CoreMessenger*) object;
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+FusionWorld *
+fd_core_world( CoreDale *core )
+{
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->world != NULL );
+
+ return core->world;
+}
+
+FusionSHMPoolShared *
+fd_core_shmpool( CoreDale *core )
+{
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core->shared->shmpool != NULL );
+
+ return core->shared->shmpool;
+}
+
+/**********************************************************************************************************************/
+
+static DirectSignalHandlerResult
+fd_core_signal_handler( int num, void *addr, void *ctx )
+{
+ CoreDale *core = (CoreDale*) ctx;
+
+ D_DEBUG_AT( Dale_Core, "%s( %d, %p, %p )\n", __FUNCTION__, num, addr, ctx );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+ D_ASSERT( core == core_dale );
+
+ fd_core_destroy( core, true );
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+static DirectResult
+fd_core_initialize( CoreDale *core )
+{
+ CoreDaleShared *shared = core->shared;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* create a pool for messenger (port) objects */
+ shared->messenger_pool = fd_messenger_pool_create( core->world );
+ shared->messenger_port_pool = fd_messenger_port_pool_create( core->world );
+
+ return DR_OK;
+}
+
+static DirectResult
+fd_core_join( CoreDale *core )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* really nothing to be done here, yet ;) */
+
+ return DR_OK;
+}
+
+static DirectResult
+fd_core_leave( CoreDale *core )
+{
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* really nothing to be done here, yet ;) */
+
+ return DR_OK;
+}
+
+static DirectResult
+fd_core_shutdown( CoreDale *core )
+{
+ CoreDaleShared *shared;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+ D_ASSERT( core->shared != NULL );
+
+ shared = core->shared;
+
+ D_ASSERT( shared->messenger_pool != NULL );
+
+ /* destroy messenger port object pool */
+ fusion_object_pool_destroy( shared->messenger_port_pool, core->world );
+
+ /* destroy messenger object pool */
+ fusion_object_pool_destroy( shared->messenger_pool, core->world );
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+static int
+fd_core_arena_initialize( FusionArena *arena,
+ void *ctx )
+{
+ DirectResult ret;
+ CoreDale *core = ctx;
+ CoreDaleShared *shared;
+ FusionSHMPoolShared *pool;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* Create the shared memory pool first! */
+ ret = fusion_shm_pool_create( core->world, "FusionDale Main Pool", 0x1000000,
+ fusion_config->debugshm, &pool );
+ if (ret)
+ return ret;
+
+ /* Allocate shared structure in the new pool. */
+ shared = SHCALLOC( pool, 1, sizeof(CoreDaleShared) );
+ if (!shared) {
+ fusion_shm_pool_destroy( core->world, pool );
+ return D_OOSHM();
+ }
+
+ core->shared = shared;
+ core->master = true;
+
+ shared->shmpool = pool;
+
+ /* Initialize. */
+ ret = fd_core_initialize( core );
+ if (ret) {
+ SHFREE( pool, shared );
+ fusion_shm_pool_destroy( core->world, pool );
+ return ret;
+ }
+
+ /* Register shared data. */
+ fusion_arena_add_shared_field( arena, "Core/Shared", shared );
+
+ return DR_OK;
+}
+
+static int
+fd_core_arena_shutdown( FusionArena *arena,
+ void *ctx,
+ bool emergency)
+{
+ DirectResult ret;
+ CoreDale *core = ctx;
+ CoreDaleShared *shared;
+ FusionSHMPoolShared *pool;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ shared = core->shared;
+
+ pool = shared->shmpool;
+
+ if (!core->master) {
+ D_DEBUG( "FusionDale/Core: Refusing shutdown in slave.\n" );
+ return fd_core_leave( core );
+ }
+
+ /* Shutdown. */
+ ret = fd_core_shutdown( core );
+ if (ret)
+ return ret;
+
+ SHFREE( pool, shared );
+
+ fusion_dbg_print_memleaks( pool );
+
+ fusion_shm_pool_destroy( core->world, pool );
+
+ return DR_OK;
+}
+
+static int
+fd_core_arena_join( FusionArena *arena,
+ void *ctx )
+{
+ DirectResult ret;
+ CoreDale *core = ctx;
+ CoreDaleShared *shared;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* Get shared data. */
+ if (fusion_arena_get_shared_field( arena, "Core/Shared", (void*)&shared ))
+ return DR_FUSION;
+
+ core->shared = shared;
+
+ /* Join. */
+ ret = fd_core_join( core );
+ if (ret)
+ return ret;
+
+ return DR_OK;
+}
+
+static int
+fd_core_arena_leave( FusionArena *arena,
+ void *ctx,
+ bool emergency)
+{
+ DirectResult ret;
+ CoreDale *core = ctx;
+
+ D_DEBUG_AT( Dale_Core, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( core, CoreDale );
+
+ /* Leave. */
+ ret = fd_core_leave( core );
+ if (ret)
+ return ret;
+
+ return DR_OK;
+}
+
diff --git a/Source/FusionDale/src/core/dale_core.h b/Source/FusionDale/src/core/dale_core.h
new file mode 100755
index 0000000..e4ed3dd
--- /dev/null
+++ b/Source/FusionDale/src/core/dale_core.h
@@ -0,0 +1,72 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __FUSIONDALE_CORE_H__
+#define __FUSIONDALE_CORE_H__
+
+#include <fusiondale.h>
+
+#include <fusion/object.h>
+
+#include <core/dale_types.h>
+
+/*
+ * Core initialization and deinitialization
+ */
+DirectResult fd_core_create ( CoreDale **ret_core );
+DirectResult fd_core_destroy( CoreDale *core, bool emergency );
+
+/*
+ * Object creation
+ */
+CoreMessenger *fd_core_create_messenger ( CoreDale *core );
+CoreMessengerPort *fd_core_create_messenger_port( CoreDale *core );
+
+/*
+ * Object enumeration
+ */
+DirectResult fd_core_enum_messengers ( CoreDale *core,
+ FusionObjectCallback callback,
+ void *ctx );
+
+DirectResult fd_core_enum_messenger_ports( CoreDale *core,
+ FusionObjectCallback callback,
+ void *ctx );
+
+DirectResult fd_core_get_messenger ( CoreDale *core,
+ FusionObjectID object_id,
+ CoreMessenger **ret_messenger );
+
+
+/*
+ * Returns the Fusion World of the sound core.
+ */
+FusionWorld *fd_core_world( CoreDale *core );
+
+/*
+ * Returns the Fusion Shared Memory Pool of the sound core.
+ */
+FusionSHMPoolShared *fd_core_shmpool( CoreDale *core );
+
+
+#endif
diff --git a/Source/FusionDale/src/core/dale_types.h b/Source/FusionDale/src/core/dale_types.h
new file mode 100755
index 0000000..60efde4
--- /dev/null
+++ b/Source/FusionDale/src/core/dale_types.h
@@ -0,0 +1,38 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __FUSIONDALE__CORE__DALE_TYPES_H__
+#define __FUSIONDALE__CORE__DALE_TYPES_H__
+
+typedef struct __FD_CoreDale CoreDale;
+typedef struct __FD_CoreDaleShared CoreDaleShared;
+
+typedef struct __FD_CoreMessenger CoreMessenger;
+typedef struct __FD_CoreMessengerPort CoreMessengerPort;
+
+typedef struct __FD_CoreMessengerEvent CoreMessengerEvent;
+typedef struct __FD_CoreMessengerDispatch CoreMessengerDispatch;
+typedef struct __FD_CoreMessengerListener CoreMessengerListener;
+
+#endif
+
diff --git a/Source/FusionDale/src/core/messenger.c b/Source/FusionDale/src/core/messenger.c
new file mode 100755
index 0000000..adae677
--- /dev/null
+++ b/Source/FusionDale/src/core/messenger.c
@@ -0,0 +1,305 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <direct/debug.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <fusion/hash.h>
+#include <fusion/lock.h>
+#include <fusion/shmalloc.h>
+
+#include <core/dale_core.h>
+#include <core/messenger.h>
+#include <core/messenger_port.h>
+
+D_DEBUG_DOMAIN( DC_Mess, "Core/Messenger", "FusionDale Core Messenger" );
+
+/**********************************************************************************************************************/
+
+static void fd_messenger_notify( CoreMessenger *messenger,
+ CoreMessengerNotificationFlags flags,
+ CoreMessengerDispatch *dispatch );
+
+/**********************************************************************************************************************/
+
+static const ReactionFunc fd_messenger_globals[] = {
+/* 0 */ _fd_messenger_port_messenger_listener,
+ NULL
+};
+
+static void
+messenger_destructor( FusionObject *object, bool zombie, void *ctx )
+{
+ CoreMessenger *messenger = (CoreMessenger*) object;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ D_DEBUG_AT( DC_Mess, "%s( %p [%lu] )%s\n", __FUNCTION__, messenger, object->id, zombie ? " ZOMBIE!" : "" );
+
+ fusion_skirmish_destroy( &messenger->lock );
+
+ D_ASSERT( fusion_hash_size( messenger->hash ) == 0 );
+
+ fusion_hash_destroy( messenger->hash );
+
+ D_MAGIC_CLEAR( messenger );
+
+ fusion_object_destroy( object );
+}
+
+FusionObjectPool *
+fd_messenger_pool_create( const FusionWorld *world )
+{
+ return fusion_object_pool_create( "Messenger", sizeof(CoreMessenger),
+ sizeof(CoreMessengerNotification),
+ messenger_destructor, NULL, world );
+}
+
+/**********************************************************************************************************************/
+
+DirectResult
+fd_messenger_create( CoreDale *core,
+ CoreMessenger **ret_messenger )
+{
+ DirectResult ret;
+ CoreMessenger *messenger;
+
+ D_ASSERT( core != NULL );
+ D_ASSERT( ret_messenger != NULL );
+
+ D_DEBUG_AT( DC_Mess, "%s( %p )\n", __FUNCTION__, core );
+
+ /* Create messenger object. */
+ messenger = fd_core_create_messenger( core );
+ if (!messenger)
+ return DR_FUSION;
+
+ /* Initialize private data. */
+ messenger->shmpool = fd_core_shmpool( core );
+
+ /* Initialize lock. */
+ ret = fusion_skirmish_init( &messenger->lock, "Messenger", fd_core_world(core) );
+ if (ret)
+ goto error;
+
+ /* Initialize hash. */
+ ret = fusion_hash_create( messenger->shmpool, HASH_STRING, HASH_PTR, 11, &messenger->hash );
+ if (ret) {
+ D_DERROR( ret, "Core/Messenger: fusion_hash_create() failed!\n" );
+ goto error_hash;
+ }
+
+ /* Activate messenger object. */
+ fusion_object_activate( &messenger->object );
+
+ D_MAGIC_SET( messenger, CoreMessenger );
+
+ /* Return messenger object. */
+ *ret_messenger = messenger;
+
+ return DR_OK;
+
+
+error_hash:
+ fusion_skirmish_destroy( &messenger->lock );
+
+error:
+ fusion_object_destroy( &messenger->object );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_create_event( CoreMessenger *messenger,
+ const char *name,
+ CoreMessengerEvent **ret_event )
+{
+ DirectResult ret;
+ CoreMessengerEvent *event;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_ASSERT( name != NULL );
+ D_ASSERT( ret_event != NULL );
+
+ /* Allocate event structure. */
+ event = SHCALLOC( messenger->shmpool, 1, sizeof(CoreMessengerEvent) );
+ if (!event)
+ return D_OOSHM();
+
+ /* Set back pointer. */
+ event->messenger = messenger;
+
+ /* Initialize event data. */
+ event->id = ++messenger->last_event;
+ event->name = SHSTRDUP( messenger->shmpool, name );
+
+ if (!event->name) {
+ ret = D_OOSHM();
+ goto error;
+ }
+
+ /* Insert event into hash table. */
+ ret = fusion_hash_insert( messenger->hash, event->name, event );
+ if (ret)
+ goto error;
+
+ /* Set magic. */
+ D_MAGIC_SET( event, CoreMessengerEvent );
+
+ /* Return new event. */
+ *ret_event = event;
+
+ return DR_OK;
+
+
+error:
+ if (event->name)
+ SHFREE( messenger->shmpool, event->name );
+
+ SHFREE( messenger->shmpool, event );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_destroy_event( CoreMessenger *messenger,
+ CoreMessengerEvent *event )
+{
+ DirectResult ret;
+ void *old_key;
+ void *old_value;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ /* Remove event from hash table. */
+ ret = fusion_hash_remove( messenger->hash, event->name, &old_key, &old_value );
+ if (ret) {
+ D_BUG( "event '%s' [%lu] not found", event->name, event->id );
+ return ret;
+ }
+
+ D_ASSERT( old_key == event->name );
+ D_ASSERT( old_value == event );
+
+ D_ASSERT( event->name != NULL );
+
+ SHFREE( messenger->shmpool, event->name );
+
+ D_MAGIC_CLEAR( event );
+
+ SHFREE( messenger->shmpool, event );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_lookup_event( CoreMessenger *messenger,
+ const char *name,
+ CoreMessengerEvent **ret_event )
+{
+ CoreMessengerEvent *event;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_ASSERT( name != NULL );
+
+ /* Lookup event in hash table. */
+ event = fusion_hash_lookup( messenger->hash, name );
+ if (!event)
+ return DR_ITEMNOTFOUND;
+
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ /* Can be NULL to just check for event existence. */
+ if (ret_event)
+ *ret_event = event;
+
+ return DR_OK;
+}
+
+DirectResult
+fd_messenger_dispatch_event( CoreMessenger *messenger,
+ CoreMessengerEvent *event,
+ int param,
+ void *data_ptr,
+ unsigned int data_size )
+{
+ CoreMessengerDispatch *dispatch;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+ D_ASSERT( event->id != FDM_EVENT_ID_NONE );
+ D_ASSERT( data_ptr != NULL || data_size == 0 );
+
+ /* Allocate dispatch structure. */
+ dispatch = SHCALLOC( messenger->shmpool, 1, sizeof(CoreMessengerDispatch) );
+ if (!dispatch)
+ return D_OOSHM();
+
+ /* Initialize dispatch structure. */
+ dispatch->event_id = event->id;
+ dispatch->param = param;
+ dispatch->data = data_ptr;
+ dispatch->data_size = data_size;
+
+ D_MAGIC_SET( dispatch, CoreMessengerDispatch );
+
+ direct_list_append( &event->dispatches, &dispatch->link );
+
+ fd_messenger_notify( messenger, CMNF_DISPATCH, dispatch );
+
+ if (!dispatch->count) {
+ direct_list_remove( &event->dispatches, &dispatch->link );
+
+ D_MAGIC_CLEAR( dispatch );
+
+ SHFREE( messenger->shmpool, dispatch );
+ }
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+static void
+fd_messenger_notify( CoreMessenger *messenger,
+ CoreMessengerNotificationFlags flags,
+ CoreMessengerDispatch *dispatch )
+{
+ CoreMessengerNotification notification;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_FLAGS_ASSERT( flags, CMNF_ALL );
+
+ D_DEBUG_AT( DC_Mess, "%s( %p [%lu], 0x%08x )\n", __FUNCTION__, messenger, messenger->object.id, flags );
+
+ notification.flags = flags;
+ notification.messenger = messenger;
+ notification.dispatch = dispatch;
+
+ fd_messenger_dispatch( messenger, &notification, fd_messenger_globals );
+}
+
diff --git a/Source/FusionDale/src/core/messenger.h b/Source/FusionDale/src/core/messenger.h
new file mode 100755
index 0000000..b960680
--- /dev/null
+++ b/Source/FusionDale/src/core/messenger.h
@@ -0,0 +1,160 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __FUSIONDALE_CORE_MESSENGER_H__
+#define __FUSIONDALE_CORE_MESSENGER_H__
+
+#include <fusiondale.h>
+
+#include <fusion/object.h>
+
+#include <core/dale_types.h>
+
+
+typedef enum {
+ CMNF_NONE = 0x00000000,
+
+ CMNF_DISPATCH = 0x00000001,
+
+ CMNF_ALL = 0x00000001
+} CoreMessengerNotificationFlags;
+
+typedef struct {
+ CoreMessengerNotificationFlags flags;
+ CoreMessenger *messenger;
+
+ CoreMessengerDispatch *dispatch;
+} CoreMessengerNotification;
+
+struct __FD_CoreMessenger {
+ FusionObject object;
+
+ int magic;
+
+ FusionSHMPoolShared *shmpool;
+
+ FusionSkirmish lock;
+ FusionHash *hash;
+ FDMessengerEventID last_event;
+};
+
+struct __FD_CoreMessengerEvent {
+ int magic;
+
+ CoreMessenger *messenger;
+
+ FDMessengerEventID id;
+ char *name;
+// unsigned int nodes;
+ DirectLink *nodes;
+
+ DirectLink *dispatches;
+};
+
+struct __FD_CoreMessengerDispatch {
+ DirectLink link;
+
+ int magic;
+
+ int count;
+
+ FDMessengerEventID event_id;
+
+ int param;
+ void *data;
+ unsigned int data_size;
+};
+
+/*
+ * Creates a pool of messenger objects.
+ */
+FusionObjectPool *fd_messenger_pool_create( const FusionWorld *world );
+
+/*
+ * Generates fd_messenger_ref(), fd_messenger_attach() etc.
+ */
+FUSION_OBJECT_METHODS( CoreMessenger, fd_messenger )
+
+
+
+/*
+ * Creation
+ */
+
+DirectResult fd_messenger_create( CoreDale *core,
+ CoreMessenger **ret_messenger );
+
+/*
+ * Events
+ */
+
+DirectResult fd_messenger_create_event ( CoreMessenger *messenger,
+ const char *name,
+ CoreMessengerEvent **ret_event );
+
+DirectResult fd_messenger_destroy_event( CoreMessenger *messenger,
+ CoreMessengerEvent *event );
+
+DirectResult fd_messenger_lookup_event ( CoreMessenger *messenger,
+ const char *name,
+ CoreMessengerEvent **ret_event );
+
+/*
+ * Dispatch
+ */
+
+DirectResult fd_messenger_dispatch_event( CoreMessenger *messenger,
+ CoreMessengerEvent *event,
+ int param,
+ void *data_ptr,
+ unsigned int data_size );
+
+/*
+ * Locking
+ */
+
+static inline DirectResult
+fd_messenger_lock( CoreMessenger *messenger )
+{
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ return fusion_skirmish_prevail( &messenger->lock );
+}
+
+static inline DirectResult
+fd_messenger_unlock( CoreMessenger *messenger )
+{
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ return fusion_skirmish_dismiss( &messenger->lock );
+}
+
+/*
+ * Global reactions
+ */
+typedef enum {
+ FD_MESSENGER_PORT_MESSENGER_LISTENER
+} FD_MESSENGER_GLOBALS;
+
+
+#endif
diff --git a/Source/FusionDale/src/core/messenger_port.c b/Source/FusionDale/src/core/messenger_port.c
new file mode 100755
index 0000000..41d7fe6
--- /dev/null
+++ b/Source/FusionDale/src/core/messenger_port.c
@@ -0,0 +1,939 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <direct/debug.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <fusion/hash.h>
+#include <fusion/lock.h>
+#include <fusion/shmalloc.h>
+
+#include <core/dale_core.h>
+#include <core/messenger.h>
+#include <core/messenger_port.h>
+
+D_DEBUG_DOMAIN( DC_MPort, "Core/MessngPort", "FusionDale Core Messenger Port" );
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ DirectLink link;
+
+ int magic;
+
+ CoreMessengerPort *port;
+
+ CoreMessengerEvent *event;
+ unsigned int count; /* number of registrations */
+
+ DirectLink *listeners;
+
+ CoreMessengerDispatch *next_dispatch;
+} EventNode;
+
+typedef struct {
+ DirectLink link;
+
+ int magic;
+
+ EventNode *node;
+
+ FDMessengerEventCallback callback;
+ void *context;
+
+ FDMessengerListenerID id;
+
+ Reaction reaction;
+} EventListener;
+
+/**********************************************************************************************************************/
+
+static void fd_messenger_port_notify( CoreMessengerPort *port,
+ CoreMessengerPortNotificationFlags flags,
+ CoreMessengerDispatch *dispatch );
+
+/**********************************************************************************************************************/
+
+static ReactionResult fd_messenger_port_reaction( const void *msg_data,
+ void *ctx );
+
+/**********************************************************************************************************************/
+
+static void
+purge_node( CoreMessengerPort *port,
+ EventNode *node )
+{
+ DirectResult ret;
+ DirectLink *next;
+ void *old_value;
+ CoreMessenger *messenger;
+ CoreMessengerEvent *event;
+ EventListener *listener;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_MAGIC_ASSERT( node, EventNode );
+ D_MAGIC_ASSERT( node->event, CoreMessengerEvent );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ event = node->event;
+
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ /* Remove event node from hash table. FIXME: 2nd lookup */
+ ret = fusion_hash_remove( port->nodes, (void*) node->event->id, NULL, &old_value );
+ if (ret)
+ D_BUG( "node for event id %lu not found", node->event->id );
+ else
+ D_ASSERT( old_value == node );
+
+ D_ASSUME( node->count > 0 );
+
+ if (node->count > 0) {
+ ret = fd_messenger_lock( messenger );
+ if (ret == DR_OK) {
+ CoreMessengerDispatch *dispatch;
+
+ /* Clear pending dispatches. */
+ direct_list_foreach_safe( dispatch, next, node->next_dispatch ) {
+ D_MAGIC_ASSERT( dispatch, CoreMessengerDispatch );
+
+ if (!--dispatch->count) {
+ if (dispatch->data)
+ SHFREE( messenger->shmpool, dispatch->data );
+
+ D_ASSUME( event->dispatches == &dispatch->link );
+
+ direct_list_remove( &event->dispatches, &dispatch->link );
+
+ D_MAGIC_CLEAR( dispatch );
+
+ SHFREE( messenger->shmpool, dispatch );
+ }
+ }
+
+ direct_list_remove( &event->nodes, &node->link );
+
+ /* Decrease registration counter. */
+ if (!/*--*/event->nodes)
+ fd_messenger_destroy_event( messenger, event );
+
+ fd_messenger_unlock( messenger );
+ }
+ else
+ D_BUG( "could not lock messenger" );
+
+ /* Clear listeners. */
+ direct_list_foreach_safe( listener, next, node->listeners ) {
+ D_MAGIC_ASSERT( listener, EventListener );
+
+ /* Remove listener from hash table. */
+ ret = fusion_hash_remove( port->listeners, (void*) listener->id, NULL, &old_value );
+ if (ret)
+ D_BUG( "listener id %lu not found", listener->id );
+ else
+ D_ASSERT( old_value == listener );
+
+ D_MAGIC_CLEAR( listener );
+
+ SHFREE( messenger->shmpool, listener );
+ }
+ }
+
+ D_MAGIC_CLEAR( node );
+
+ SHFREE( messenger->shmpool, node );
+}
+
+/**********************************************************************************************************************/
+
+static bool
+node_iterator( FusionHash *hash,
+ void *key,
+ void *value,
+ void *ctx )
+{
+ EventNode *node = value;
+ CoreMessengerPort *port = ctx;
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+
+ purge_node( port, node );
+
+ return false;
+}
+
+static void
+messenger_port_destructor( FusionObject *object, bool zombie, void *ctx )
+{
+ CoreMessengerPort *port = (CoreMessengerPort*) object;
+ CoreMessenger *messenger;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+
+ D_DEBUG_AT( DC_MPort, "%s( %p [%lu] )%s\n", __FUNCTION__, port, object->id, zombie ? " ZOMBIE!" : "" );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ fd_messenger_detach_global( messenger, &port->reaction );
+
+ fusion_hash_iterate( port->nodes, node_iterator, port );
+
+ D_ASSUME( fusion_hash_size( port->nodes ) == 0 );
+ fusion_hash_destroy( port->nodes );
+
+ D_ASSUME( fusion_hash_size( port->listeners ) == 0 );
+ fusion_hash_destroy( port->listeners );
+
+ fd_messenger_unlink( &port->messenger );
+
+ D_MAGIC_CLEAR( port );
+
+ fusion_object_destroy( object );
+}
+
+FusionObjectPool *
+fd_messenger_port_pool_create( const FusionWorld *world )
+{
+ return fusion_object_pool_create( "Messenger Port", sizeof(CoreMessengerPort),
+ sizeof(CoreMessengerPortNotification),
+ messenger_port_destructor, NULL, world );
+}
+
+/**********************************************************************************************************************/
+
+DirectResult
+fd_messenger_port_create( CoreDale *core,
+ CoreMessenger *messenger,
+ CoreMessengerPort **ret_port )
+{
+ DirectResult ret;
+ CoreMessengerPort *port;
+
+ D_ASSERT( core != NULL );
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_ASSERT( ret_port != NULL );
+
+ D_DEBUG_AT( DC_MPort, "%s( %p )\n", __FUNCTION__, core );
+
+ /* Create messenger port object. */
+ port = fd_core_create_messenger_port( core );
+ if (!port)
+ return DR_FUSION;
+
+ /* Set back pointer. */
+ ret = fd_messenger_link( &port->messenger, messenger );
+ if (ret)
+ goto error;
+
+ /* Initialize lock. */
+ port->lock = &messenger->lock;
+
+ /* Initialize event node hash. */
+ ret = fusion_hash_create( messenger->shmpool, HASH_INT, HASH_PTR, 11, &port->nodes );
+ if (ret) {
+ D_DERROR( ret, "Core/MessngPort: fusion_hash_create() failed!\n" );
+ goto error_hash;
+ }
+
+ /* Initialize listener hash. */
+ ret = fusion_hash_create( messenger->shmpool, HASH_INT, HASH_PTR, 11, &port->listeners );
+ if (ret) {
+ D_DERROR( ret, "Core/MessngPort: fusion_hash_create() failed!\n" );
+ goto error_hash2;
+ }
+
+ fusion_reactor_set_lock( port->object.reactor, port->lock );
+ fusion_reactor_direct( port->object.reactor, false );
+
+ /* Attach global reaction to process all events. */
+ ret = fd_messenger_attach_global( messenger, FD_MESSENGER_PORT_MESSENGER_LISTENER, port, &port->reaction );
+ if (ret)
+ goto error_attach_global;
+
+ /* Attach to the port to receive events that we listen to. */
+ ret = fd_messenger_port_attach( port, fd_messenger_port_reaction, port, &port->local_reaction );
+ if (ret)
+ goto error_attach;
+
+ /* Activate messenger port object. */
+ fusion_object_activate( &port->object );
+
+ D_MAGIC_SET( port, CoreMessengerPort );
+
+ /* Return messenger port object. */
+ *ret_port = port;
+
+ return DR_OK;
+
+
+error_attach:
+ fd_messenger_detach_global( messenger, &port->reaction );
+
+error_attach_global:
+ fusion_hash_destroy( port->listeners );
+
+error_hash2:
+ fusion_hash_destroy( port->nodes );
+
+error_hash:
+ fd_messenger_unlink( &port->messenger );
+
+error:
+ fusion_object_destroy( &port->object );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_port_add_event( CoreMessengerPort *port,
+ CoreMessengerEvent *event )
+{
+ DirectResult ret;
+ EventNode *node;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Try to lookup existing event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) event->id );
+ if (node) {
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ /* Increase node counter. */
+ node->count++;
+ }
+ else {
+ CoreMessenger *messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Allocate node. */
+ node = SHCALLOC( messenger->shmpool, 1, sizeof(EventNode) );
+ if (!node) {
+ ret = D_OOSHM();
+ goto error;
+ }
+
+ /* Initialize node. */
+ node->port = port;
+ node->event = event;
+ node->count = 1;
+
+ /* Insert node into hash table. */
+ ret = fusion_hash_insert( port->nodes, (void*) event->id, node );
+ if (ret) {
+ SHFREE( messenger->shmpool, node );
+ goto error;
+ }
+
+ D_MAGIC_SET( node, EventNode );
+
+ direct_list_append( &event->nodes, &node->link );
+
+ /* Increase event's node counter. */
+ //event->nodes++;
+ }
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return DR_OK;
+
+
+error:
+ fusion_skirmish_dismiss( port->lock );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_port_remove_event( CoreMessengerPort *port,
+ FDMessengerEventID event_id )
+{
+ DirectResult ret;
+ EventNode *node;
+ CoreMessenger *messenger;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_ASSERT( event_id != FDM_EVENT_ID_NONE );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Lookup our event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) event_id );
+ if (node) {
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ if (node->count > 1)
+ node->count--;
+ else
+ purge_node( port, node );
+ }
+ else
+ D_BUG( "node for event id %lu not found", event_id );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return DR_OK;
+}
+
+DirectResult
+fd_messenger_port_add_listener( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ FDMessengerEventCallback callback,
+ void *context,
+ FDMessengerListenerID *ret_id )
+{
+ DirectResult ret;
+ CoreMessenger *messenger;
+ EventNode *node;
+ EventListener *listener = NULL;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_ASSERT( event_id != FDM_EVENT_ID_NONE );
+ D_ASSERT( callback != NULL );
+ D_ASSERT( ret_id != NULL );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Lookup our event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) event_id );
+ if (node) {
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ /* Allocate listener struct. */
+ listener = SHCALLOC( messenger->shmpool, 1, sizeof(EventListener) );
+ if (!listener) {
+ ret = D_OOSHM();
+ goto error;
+ }
+
+ /* Initialize listener. */
+ listener->node = node;
+ listener->callback = callback;
+ listener->context = context;
+ listener->id = ++port->last_listener;
+
+ /* Insert listener into hash table. */
+ ret = fusion_hash_insert( port->listeners, (void*) listener->id, listener );
+ if (ret)
+ goto error;
+
+ D_MAGIC_SET( listener, EventListener );
+
+ /* Append listener to event node. */
+ direct_list_append( &node->listeners, &listener->link );
+
+ *ret_id = listener->id;
+ }
+ else
+ D_BUG( "node for event id %lu not found", event_id );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return DR_OK;
+
+
+error:
+ if (listener)
+ SHFREE( messenger->shmpool, listener );
+
+ fusion_skirmish_dismiss( port->lock );
+
+ return ret;
+}
+
+DirectResult
+fd_messenger_port_remove_listener( CoreMessengerPort *port,
+ FDMessengerListenerID listener_id )
+{
+ DirectResult ret;
+ void *old_value;
+ EventNode *node;
+ EventListener *listener;
+ CoreMessenger *messenger;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_ASSERT( listener_id != FDM_LISTENER_ID_NONE );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Remove listener from hash table. */
+ ret = fusion_hash_remove( port->listeners, (void*) listener_id, NULL, &old_value );
+ if (ret) {
+ D_BUG( "listener id %lu not found", listener_id );
+ fusion_skirmish_dismiss( port->lock );
+ return ret;
+ }
+
+ listener = old_value;
+
+ D_MAGIC_ASSERT( listener, EventListener );
+
+ node = listener->node;
+
+ D_MAGIC_ASSERT( node, EventNode );
+
+ /* Remove listener from event node. */
+ direct_list_remove( &node->listeners, &listener->link );
+
+ D_MAGIC_CLEAR( listener );
+
+ SHFREE( messenger->shmpool, listener );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return DR_OK;
+}
+
+DirectResult
+fd_messenger_port_enum_listeners( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ CoreMPListenerCallback callback,
+ void *context )
+{
+ DirectResult ret;
+ EventNode *node;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_ASSERT( event_id != FDM_EVENT_ID_NONE );
+ D_ASSERT( callback != NULL );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Lookup our event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) event_id );
+ if (node) {
+ EventListener *listener;
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ /* Loop through listeners for the event. */
+ direct_list_foreach( listener, node->listeners ) {
+ D_MAGIC_ASSERT( listener, EventListener );
+ D_ASSERT( listener->callback != NULL );
+
+ /* Pass each listener and its context to the enumeration callback. */
+ if (callback( port, listener->callback, listener->context, context ) == DENUM_CANCEL)
+ break;
+ }
+ }
+ else
+ D_BUG( "node for event id %lu not found", event_id );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+DirectResult
+fd_messenger_event_dispatch( CoreMessengerEvent *event,
+ int param,
+ void *data_ptr,
+ unsigned int data_size )
+{
+ CoreMessenger *messenger;
+ CoreMessengerDispatch *dispatch;
+ EventNode *node;
+ bool dispatched = false;
+
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+ D_ASSERT( event->id != FDM_EVENT_ID_NONE );
+ D_ASSERT( data_ptr != NULL || data_size == 0 );
+
+ messenger = event->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Allocate dispatch structure. */
+ dispatch = SHCALLOC( messenger->shmpool, 1, sizeof(CoreMessengerDispatch) );
+ if (!dispatch)
+ return D_OOSHM();
+
+ /* Initialize dispatch structure. */
+ dispatch->event_id = event->id;
+ dispatch->param = param;
+ dispatch->data = data_ptr;
+ dispatch->data_size = data_size;
+
+ D_MAGIC_SET( dispatch, CoreMessengerDispatch );
+
+ direct_list_append( &event->dispatches, &dispatch->link );
+
+ /* we need to determine the number of listeners first */
+ direct_list_foreach( node, event->nodes ) {
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+ D_ASSERT( node->event == event );
+
+ if (node->listeners) {
+ dispatch->count++;
+ }
+ }
+
+
+ direct_list_foreach( node, event->nodes ) {
+ CoreMessengerPort *port;
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+ D_ASSERT( node->event == event );
+
+ port = node->port;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+
+ /* Lock port. */
+ fusion_skirmish_prevail( port->lock );
+
+ if (node->listeners) {
+// dispatch->count++;
+
+ if (!node->next_dispatch)
+ node->next_dispatch = dispatch;
+
+ /* Dispatch event to reaction in the port's process. */
+ fd_messenger_port_notify( node->port, CMPNF_EVENT, dispatch );
+
+ dispatched = true;
+ }
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+ }
+
+
+
+ if (!dispatched) {
+ direct_list_remove( &event->dispatches, &dispatch->link );
+
+ D_MAGIC_CLEAR( dispatch );
+
+ SHFREE( messenger->shmpool, dispatch );
+ }
+
+ return DR_OK;
+}
+
+DirectResult
+fd_messenger_port_send_event( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ int param,
+ void *data_ptr,
+ unsigned int data_size )
+{
+ DirectResult ret;
+ EventNode *node;
+ CoreMessenger *messenger;
+ CoreMessengerEvent *event;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_ASSERT( event_id != FDM_EVENT_ID_NONE );
+ D_ASSERT( data_ptr != NULL || data_size == 0 );
+
+ messenger = port->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return ret;
+
+ /* Lookup our event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) event_id );
+ if (!node) {
+ D_BUG( "node for event id %lu not found", event_id );
+ fusion_skirmish_dismiss( port->lock );
+ return DR_BUG;
+ }
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ event = node->event;
+
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ ret = fd_messenger_event_dispatch( event, param, data_ptr, data_size );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static ReactionResult
+fd_messenger_port_reaction( const void *msg_data,
+ void *ctx )
+{
+ DirectResult ret;
+ const CoreMessengerPortNotification *notification = msg_data;
+ CoreMessengerPort *port = ctx;
+ EventNode *node;
+ EventListener *listener;
+ CoreMessenger *messenger;
+ CoreMessengerDispatch *dispatch;
+ CoreMessengerEvent *event;
+
+ D_ASSERT( notification != NULL );
+ D_ASSERT( notification->event_id != FDM_EVENT_ID_NONE );
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_MAGIC_ASSERT( port->messenger, CoreMessenger );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret) {
+ D_BUG( "could not lock port" );
+ return RS_REMOVE;
+ }
+
+ /* Lookup our event node. */
+ node = fusion_hash_lookup( port->nodes, (void*) notification->event_id );
+ if (!node) {
+ /* Probably purged while the message was pending. */
+ D_WARN( "node for event id %lu not found", notification->event_id );
+ fusion_skirmish_dismiss( port->lock );
+ return RS_OK;
+ }
+
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ event = node->event;
+
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+
+ messenger = event->messenger;
+
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+
+ D_ASSERT( node->next_dispatch == notification->dispatch );
+
+ dispatch = node->next_dispatch;
+
+ D_MAGIC_ASSERT( dispatch, CoreMessengerDispatch );
+ D_ASSERT( direct_list_contains_element_EXPENSIVE( event->dispatches, &dispatch->link ) );
+
+ /* Loop through listeners for the event. */
+ direct_list_foreach( listener, node->listeners ) {
+ D_MAGIC_ASSERT( listener, EventListener );
+ D_ASSERT( listener->callback != NULL );
+
+ /* Call each listener. */
+ listener->callback( dispatch->event_id, dispatch->param, dispatch->data,
+ dispatch->data_size, listener->context );
+ }
+
+ /* FIXME: Temporarily increase counter to avoid intermittent purge after the following unlock. */
+ node->count++;
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+
+ /* Lock messenger. (has to happen without the port being locked!) */
+ ret = fd_messenger_lock( messenger );
+ if (ret) {
+ D_BUG( "could not lock messenger" );
+ return RS_REMOVE;
+ }
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret) {
+ D_BUG( "could not lock port" );
+ fd_messenger_unlock( messenger );
+ return RS_REMOVE;
+ }
+
+ /* FIXME: Due to the lock break, some might fail if port has been destroyed.
+ Probably remove this whole thing and use a reference counter per dispatch. */
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+ D_MAGIC_ASSERT( event, CoreMessengerEvent );
+ D_MAGIC_ASSERT( messenger, CoreMessenger );
+ D_MAGIC_ASSERT( dispatch, CoreMessengerDispatch );
+ D_ASSERT( direct_list_contains_element_EXPENSIVE( event->dispatches, &dispatch->link ) );
+
+ node->next_dispatch = (CoreMessengerDispatch*) dispatch->link.next;
+
+ if (node->count > 1) {
+ node->count--;
+
+ if (!--dispatch->count) {
+ if (dispatch->data)
+ SHFREE( messenger->shmpool, dispatch->data );
+
+ D_ASSUME( event->dispatches == &dispatch->link );
+
+ direct_list_remove( &event->dispatches, &dispatch->link );
+
+ D_MAGIC_CLEAR( dispatch );
+
+ SHFREE( messenger->shmpool, dispatch );
+ }
+ }
+ else
+ purge_node( port, node );
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ /* Unlock messenger. */
+ fd_messenger_unlock( messenger );
+
+ return RS_OK;
+}
+
+/**********************************************************************************************************************/
+
+static void
+fd_messenger_port_notify( CoreMessengerPort *port,
+ CoreMessengerPortNotificationFlags flags,
+ CoreMessengerDispatch *dispatch )
+{
+ CoreMessengerPortNotification notification;
+
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+ D_FLAGS_ASSERT( flags, CMNF_ALL );
+
+ D_DEBUG_AT( DC_MPort, "%s( %p [%lu], 0x%08x )\n", __FUNCTION__, port, port->object.id, flags );
+
+ D_ASSERT( flags == CMPNF_EVENT );
+
+ notification.flags = flags;
+ notification.port = port;
+ notification.event_id = dispatch->event_id;
+ notification.param = dispatch->param;
+ notification.data = dispatch->data;
+ notification.data_size = dispatch->data_size;
+ notification.dispatch = dispatch;
+
+ fd_messenger_port_dispatch( port, &notification, NULL /* no globals so far */ );
+}
+
+/**********************************************************************************************************************/
+
+ReactionResult
+_fd_messenger_port_messenger_listener( const void *msg_data,
+ void *ctx )
+{
+ const CoreMessengerNotification *notification = msg_data;
+ CoreMessengerPort *port = ctx;
+ CoreMessengerDispatch *dispatch;
+ EventNode *node;
+ DirectResult ret;
+
+ D_ASSERT( notification != NULL );
+ D_MAGIC_ASSERT( port, CoreMessengerPort );
+
+ D_ASSERT( notification->flags == CMNF_DISPATCH );
+
+ dispatch = notification->dispatch;
+
+ D_MAGIC_ASSERT( dispatch, CoreMessengerDispatch );
+
+ /* Lock port. */
+ ret = fusion_skirmish_prevail( port->lock );
+ if (ret)
+ return RS_REMOVE;
+
+ /* Lookup event node to check if port has any listeners for this event.
+ TODO: Could be optimized by linking nodes into event and dispatch directly,
+ i.e. without this global reaction, but requires different locking. */
+ node = fusion_hash_lookup( port->nodes, (void*) dispatch->event_id );
+ if (node) {
+ D_MAGIC_ASSERT( node, EventNode );
+ D_ASSERT( node->count > 0 );
+
+ if (node->listeners) {
+ dispatch->count++;
+
+ if (!node->next_dispatch)
+ node->next_dispatch = dispatch;
+
+ /* Dispatch event to reaction in the port's process. */
+ fd_messenger_port_notify( port, CMPNF_EVENT, dispatch );
+ }
+ }
+
+ /* Unlock port. */
+ fusion_skirmish_dismiss( port->lock );
+
+ return RS_OK;
+}
+
diff --git a/Source/FusionDale/src/core/messenger_port.h b/Source/FusionDale/src/core/messenger_port.h
new file mode 100755
index 0000000..56a111e
--- /dev/null
+++ b/Source/FusionDale/src/core/messenger_port.h
@@ -0,0 +1,137 @@
+/*
+ (c) Copyright 2006-2007 directfb.org
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __FUSIONDALE_CORE_MESSENGER_PORT_H__
+#define __FUSIONDALE_CORE_MESSENGER_PORT_H__
+
+#include <fusiondale.h>
+
+#include <fusion/object.h>
+#include <fusion/reactor.h>
+
+#include <core/dale_types.h>
+
+
+typedef enum {
+ CMPNF_NONE = 0x00000000,
+
+ CMPNF_EVENT = 0x00000001,
+
+ CMPNF_ALL = 0x00000001
+} CoreMessengerPortNotificationFlags;
+
+typedef struct {
+ CoreMessengerPortNotificationFlags flags;
+ CoreMessengerPort *port;
+
+ FDMessengerEventID event_id;
+ int param;
+ void *data;
+ unsigned int data_size;
+
+ CoreMessengerDispatch *dispatch; /* for integrity check with node's next_dispatch */
+} CoreMessengerPortNotification;
+
+struct __FD_CoreMessengerPort {
+ FusionObject object;
+
+ int magic;
+
+ CoreMessenger *messenger;
+
+ FusionSkirmish *lock;
+
+ FusionHash *nodes;
+ FusionHash *listeners;
+
+ FDMessengerEventID last_listener;
+
+ GlobalReaction reaction;
+ Reaction local_reaction;
+};
+
+typedef DirectEnumerationResult (*CoreMPListenerCallback)( CoreMessengerPort *port,
+ FDMessengerEventCallback listener,
+ void *listener_context,
+ void *context );
+
+/*
+ * Creates a pool of messenger port objects.
+ */
+FusionObjectPool *fd_messenger_port_pool_create( const FusionWorld *world );
+
+/*
+ * Generates fd_messenger_port_ref(), fd_messenger_port_attach() etc.
+ */
+FUSION_OBJECT_METHODS( CoreMessengerPort, fd_messenger_port )
+
+
+/*
+ * Creation
+ */
+
+DirectResult fd_messenger_port_create( CoreDale *core,
+ CoreMessenger *messenger,
+ CoreMessengerPort **ret_port );
+
+/*
+ * Events
+ */
+
+DirectResult fd_messenger_port_add_event ( CoreMessengerPort *port,
+ CoreMessengerEvent *event );
+
+DirectResult fd_messenger_port_remove_event( CoreMessengerPort *port,
+ FDMessengerEventID event_id );
+
+DirectResult fd_messenger_port_send_event ( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ int param,
+ void *data_ptr,
+ unsigned int data_size );
+
+/*
+ * Listeners
+ */
+
+DirectResult fd_messenger_port_add_listener ( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ FDMessengerEventCallback callback,
+ void *context,
+ FDMessengerListenerID *ret_id );
+
+DirectResult fd_messenger_port_remove_listener( CoreMessengerPort *port,
+ FDMessengerListenerID listener_id );
+
+DirectResult fd_messenger_port_enum_listeners ( CoreMessengerPort *port,
+ FDMessengerEventID event_id,
+ CoreMPListenerCallback callback,
+ void *context );
+
+/*
+ * Global reactions
+ */
+ReactionResult _fd_messenger_port_messenger_listener( const void *msg_data,
+ void *ctx );
+
+#endif