[pyicu-dev] [PATCH] Add correct namespace declarations everywhere

Steven R. Loomis srl at icu-project.org
Tue Sep 11 12:35:26 PDT 2007


Fredrik,
  My mistake. I looked at your patch as adding icu:: -  I had  
forgotten that icu:: was already being used in pyicu.

  Now I understand why it had to be added to 'some things'.

Then, my alternate proposal is to not use icu:: anywhere, but to use  
U_USING_NAMESPACE  for your situation.

What I should have said was - not that your patch breaks, but that  
the use of "icu::" will break.

With the following patch I was able to build with - 
DU_USING_ICU_NAMESPACE=0 against 3.8d2



Index: common.h
===================================================================
--- common.h    (revision 78)
+++ common.h    (working copy)
@@ -85,7 +85,10 @@
#include <unicode/ucsdet.h>
#include <unicode/uidna.h>
+/* use the icu namespace, in case it was not already used */
+U_NAMESPACE_USE
+
/* lifted from ustrenum.h */
U_NAMESPACE_BEGIN


-s

On 11 Set 2007, at 12:10, Fredrik Roubert wrote:

> On 9/11/07, Steven R. Loomis <srl at icu-project.org> wrote:
>
>> the namespace could b e icu or icu_3_8 depending on what the  
>> rename settings
>> are, so I would not use icu:: statically
>
> Let's take a look at the very first change in my namespace patch (all
> changes are similiar). In revision 78 of locale.cpp it looks like
> this:
>
>
> static PyObject *t_locale_getAvailableLocales(PyTypeObject *type)
> {
>     int count;
>     const icu::Locale *locales = icu::Locale::getAvailableLocales 
> (count);
>     PyObject *dict = PyDict_New();
>
>     for (int32_t i = 0; i < count; i++) {
>         Locale *locale = (Locale *) locales + i;
>         PyObject *obj = wrap_Locale(locale, 0);
>         PyDict_SetItemString(dict, locale->getName(), obj);
> 	Py_DECREF(obj);
>     }
>
>     return dict;
> }
>
>
> As you can see, on the first line where Locale is referenced it is
> prefixed with icu:: and on the second line where it's referenced it is
> not prefixed. When I first saw this, I just assumed it to be a typo
> that had been left there just because no-one noticed before. So I
> created this patch that adds icu:: (consistent with the rest of the
> code) to all places where I found it to be missing.
>
> Why are you opposing this change? Are you quite sure that there is a
> good reason to keep the code like it is above?
>
> -- 
> Fredrik Roubert
> roubert at google.com



More information about the pyicu-dev mailing list