From 144e4c137c060a1d08dd3eefbf8bcb8fdbb4296a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 30 Jun 2006 14:42:58 +0000 Subject: [PATCH] ICU-5118 Local Service Hook X-SVN-Rev: 19782 --- icu4c/source/common/Makefile.in | 21 ++++++++++++++++++--- icu4c/source/common/localsvc.h | 25 +++++++++++++++++++++++++ icu4c/source/common/rbbi.cpp | 5 +++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 icu4c/source/common/localsvc.h diff --git a/icu4c/source/common/Makefile.in b/icu4c/source/common/Makefile.in index 9b651dfc31e..666373cf160 100644 --- a/icu4c/source/common/Makefile.in +++ b/icu4c/source/common/Makefile.in @@ -19,8 +19,12 @@ include $(top_builddir)/icudefs.mk ## Build directory information subdir = common +# for service hook +LOCALSVC_CPP=localsvc.cpp +SVC_HOOK_INC=$(top_builddir)/common/svchook.mk + ## Extra files to remove for 'make clean' -CLEANFILES = *~ $(DEPS) $(IMPORT_LIB) $(MIDDLE_IMPORT_LIB) $(FINAL_IMPORT_LIB) +CLEANFILES = *~ $(DEPS) $(IMPORT_LIB) $(MIDDLE_IMPORT_LIB) $(FINAL_IMPORT_LIB) $(SVC_HOOK_INC) ## Target information @@ -90,6 +94,9 @@ DEPS = $(OBJECTS:.o=.d) -include Makefile.local +-include $(SVC_HOOK_INC) + + ## List of phony targets .PHONY : all all-local install install-local clean clean-local \ distclean distclean-local install-library install-headers dist \ @@ -134,6 +141,14 @@ ifneq ($(MIDDLE_IMPORT_LIB),$(FINAL_IMPORT_LIB)) endif endif +$(SVC_HOOK_INC): + @echo generating $@ + @-test -f $(top_srcdir)/common/$(LOCALSVC_CPP) && ( echo "have $(LOCALSVC_CPP) - U_LOCAL_SERVICE_HOOK=1" ; \ + echo 'CPPFLAGS +=-DU_LOCAL_SERVICE_HOOK=1' > $@ ; \ + echo 'OBJECTS += $(LOCALSVC_CPP:%.cpp=%.o)' >> $@ \ + ) ; true + @echo "# Autogenerated by Makefile" >> $@ + install-headers: $(MKINSTALLDIRS) $(DESTDIR)$(includedir)/unicode @for file in $(HEADERS); do \ @@ -148,11 +163,11 @@ clean-local: $(RMV) $(OBJECTS) $(STATIC_OBJECTS) $(ALL_TARGETS) $(SO_VERSION_DATA) distclean-local: clean-local - $(RMV) Makefile icucfg.h unicode/platform.h + $(RMV) Makefile icucfg.h unicode/platform.h $(SVC_HOOK_INC) check-local: -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(SVC_HOOK_INC) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/icu4c/source/common/localsvc.h b/icu4c/source/common/localsvc.h new file mode 100644 index 00000000000..67e5a8455ae --- /dev/null +++ b/icu4c/source/common/localsvc.h @@ -0,0 +1,25 @@ +/* +*************************************************************************** +* Copyright (C) 2006 International Business Machines Corporation * +* and others. All rights reserved. * +*************************************************************************** +*/ + +#ifndef LOCALSVC_H +#define LOCALSVC_H + +#include "unicode/utypes.h" + +#if U_LOCAL_SERVICE_HOOK +/** + * Prototype for user-supplied service hook. This function is expected to return + * a type of factory object specific to the requested service. + * + * @param what service-specific string identifying the specific user hook + * @param status error status + * @return a service-specific hook, or NULL on failure. + */ +U_CAPI void* uprv_svc_hook(const char *what, UErrorCode *status); +#endif + +#endif diff --git a/icu4c/source/common/rbbi.cpp b/icu4c/source/common/rbbi.cpp index cddf525bfb2..902c8a2bf67 100644 --- a/icu4c/source/common/rbbi.cpp +++ b/icu4c/source/common/rbbi.cpp @@ -30,6 +30,11 @@ #include "uassert.h" #include "uvector.h" +// if U_LOCAL_SERVICE_HOOK is defined, then localsvc.cpp is expected to be included. +#if U_LOCAL_SERVICE_HOOK +#include "localsvc.h" +#endif + U_NAMESPACE_BEGIN