ICU-20566 Add missing ICU namespace macros for extra files
ICU now uses namespaces. When trying to use the scrptrun.h header, the
header cannot compile stand-alone as it is inheriting from UObject which
is namespaced now. Add namespace macros to properly inherit.
ICU-20566 Add scrptrun to the extra high level Makefile
The scrptrun project was not being added to the extra portion of the ICU
build. Add it as a sub project so it can always be built.
ICU-20566 Properly namespace the ScriptRun test
The ScriptRun class is now namespaced. Update the test reference.
ICU-20566 Use int instead of void to compile
Clang will complain about having a void main without an int main to
invoke. Change void to int and return 0.
diff --git a/icu4c/source/extra/Makefile.in b/icu4c/source/extra/Makefile.in
index 4dd2818..2e48dba 100644
--- a/icu4c/source/extra/Makefile.in
+++ b/icu4c/source/extra/Makefile.in
@@ -23,7 +23,7 @@
## Files to remove for 'make clean'
CLEANFILES = *~
-SUBDIRS = uconv
+SUBDIRS = scrptrun uconv
## List of phony targets
.PHONY : all all-local all-recursive install install-local \
diff --git a/icu4c/source/extra/scrptrun/scrptrun.cpp b/icu4c/source/extra/scrptrun/scrptrun.cpp
index d36ec61..0a438c3 100644
--- a/icu4c/source/extra/scrptrun/scrptrun.cpp
+++ b/icu4c/source/extra/scrptrun/scrptrun.cpp
@@ -19,6 +19,8 @@
#include "cmemory.h"
#include "scrptrun.h"
+U_NAMESPACE_BEGIN
+
const char ScriptRun::fgClassID=0;
UChar32 ScriptRun::pairedChars[] = {
@@ -201,3 +203,4 @@
return true;
}
+U_NAMESPACE_END
diff --git a/icu4c/source/extra/scrptrun/scrptrun.h b/icu4c/source/extra/scrptrun/scrptrun.h
index 0ef5df2..ac6bfe3 100644
--- a/icu4c/source/extra/scrptrun/scrptrun.h
+++ b/icu4c/source/extra/scrptrun/scrptrun.h
@@ -20,6 +20,8 @@
#include "unicode/uobject.h"
#include "unicode/uscript.h"
+U_NAMESPACE_BEGIN
+
struct ScriptRecord
{
UChar32 startChar;
@@ -152,5 +154,6 @@
reset(start, length);
}
+U_NAMESPACE_END
#endif
diff --git a/icu4c/source/extra/scrptrun/srtest.cpp b/icu4c/source/extra/scrptrun/srtest.cpp
index 5792071..8d59fb9 100644
--- a/icu4c/source/extra/scrptrun/srtest.cpp
+++ b/icu4c/source/extra/scrptrun/srtest.cpp
@@ -27,9 +27,9 @@
int32_t testLength = UPRV_LENGTHOF(testChars);
-void main()
+int main()
{
- ScriptRun scriptRun(testChars, 0, testLength);
+ icu::ScriptRun scriptRun(testChars, 0, testLength);
while (scriptRun.next()) {
int32_t start = scriptRun.getScriptStart();
@@ -38,4 +38,5 @@
printf("Script '%s' from %d to %d.\n", uscript_getName(code), start, end);
}
+ return 0;
}