On Sat, 26 Feb 2011, Andi Vajda wrote:

On Sat, 26 Feb 2011, Bill Janssen wrote:

Think I've found an issue.  The class
com.parc.goodstuff.simple.HelloWorldService extends
simple.http.load.BasicService, and my JCC (2.7) chokes on it thusly:

build/_PPD/com/parc/goodstuff/simple/HelloWorld/HelloWorldService.h: At global scope: build/_PPD/com/parc/goodstuff/simple/HelloWorld/HelloWorldService.h:22: error: ?com::parc::goodstuff::simple::http? has not been declared

Looks like namespace confusion.  Toplevel 'simple' clashes with the
package 'com.parc.goodstuff.simple'.  Shouldn't line 22 say something
like

class HelloWorldService : public ::simple::http::load::BasicService {

instead of

        class HelloWorldService : public simple::http::load::BasicService {

Quite likely, yes. The fix should be simple enough, albeit a bit of a pain to implement. Everywhere jcc uses '::' to join names together, in cpp.py and python.py, that code should be replaced with something that also prepends '::'. And, for consistency's sake, all hardcoded :: paths for system java classes should also use this syntax.

I attached a patch that should fix this. PyLucene 3.1 builds and passes its tests. Can you please try this and verify that it solves the problem you found ?

Thanks !

Andi..
Index: jcc/python.py
===================================================================
--- jcc/python.py       (revision 1066936)
+++ jcc/python.py       (working copy)
@@ -16,7 +16,7 @@
 from itertools import izip
 
 from cpp import PRIMITIVES, INDENT, HALF_INDENT
-from cpp import cppname, cppnames, typename, findClass
+from cpp import cppname, cppnames, fullname, typename, findClass
 from cpp import line, signature, find_method, split_pkg, sort
 from cpp import Modifier, Class, Method
 from config import INCLUDES, CFLAGS, DEBUG_CFLAGS, LFLAGS, IMPLIB_LFLAGS, \
@@ -141,7 +141,7 @@
             return ''
         if is_boxed(clsName):
             clsNames = clsName.split('.')
-            return ', &%s::PY_TYPE(%s)' %('::'.join(cppnames(clsNames[:-1])), 
cppname(clsNames[-1]))
+            return ', &%s::PY_TYPE(%s)' %(fullname(cppnames(clsNames[:-1])), 
cppname(clsNames[-1]))
         return ', %s::initializeClass' %(typename(cls, current, False))
 
     def callarg(cls, i):
@@ -288,7 +288,7 @@
             for clsArg in getActualTypeArguments(genericRT):
                 if Class.instance_(clsArg):
                     clsNames = Class.cast_(clsArg).getName().split('.')
-                    clsArg = '&%s::PY_TYPE(%s)' 
%('::'.join(cppnames(clsNames[:-1])), cppname(clsNames[-1]))
+                    clsArg = '&%s::PY_TYPE(%s)' 
%(fullname(cppnames(clsNames[:-1])), cppname(clsNames[-1]))
                     clsArgs.append(clsArg)
                 elif TypeVariable.instance_(clsArg):
                     gd = TypeVariable.cast_(clsArg).getGenericDeclaration()
@@ -371,7 +371,7 @@
     name = cppname(name)
     if Modifier.isStatic(modifiers):
         line(out, indent, 'OBJ_CALL(%s%s::%s(%s));',
-             result, '::'.join(cppnames(names)), name,
+             result, fullname(cppnames(names)), name,
              ', '.join(['a%d' %(i) for i in xrange(count)]))
     else:
         line(out, indent, 'OBJ_CALL(%sself->object.%s(%s));',
@@ -911,7 +911,7 @@
         if nextExt:
             tp_iternext = 'get_extension_next'
         else:
-            tp_iternext = '((PyObject *(*)(java::util::t_Iterator *)) 
get_%siterator_next<java::util::t_Iterator,%s%st_%s>)' %(clsParams and 
'generic_' or '', ns, sep, n)
+            tp_iternext = '((PyObject *(*)(::java::util::t_Iterator *)) 
get_%siterator_next< ::java::util::t_Iterator,%s%st_%s >)' %(clsParams and 
'generic_' or '', ns, sep, n)
     elif nextElementMethod and enumeration.isAssignableFrom(cls):
         tp_iter = 'PyObject_SelfIter'
         returnName = typename(nextElementMethod.getReturnType(), cls, False)
@@ -919,7 +919,7 @@
         if nextElementExt:
             tp_iternext = 'get_extension_nextElement'
         else:
-            tp_iternext = '((PyObject *(*)(java::util::t_Enumeration *)) 
get_%senumeration_next<java::util::t_Enumeration,%s%st_%s>)' %(clsParams and 
'generic_' or '', ns, sep, n)
+            tp_iternext = '((PyObject *(*)(::java::util::t_Enumeration *)) 
get_%senumeration_next< ::java::util::t_Enumeration,%s%st_%s >)' %(clsParams 
and 'generic_' or '', ns, sep, n)
     elif nextMethod:
         tp_iter = 'PyObject_SelfIter'
         returnName = typename(nextMethod.getReturnType(), cls, False)
@@ -987,7 +987,7 @@
         tp_as_sequence = '0'
 
     if len(superNames) > 1:
-        base = '::'.join(('::'.join(cppnames(superNames[:-1])), 
superNames[-1]))
+        base = '::'.join((fullname(cppnames(superNames[:-1])), superNames[-1]))
     else:
         base = superNames[-1]
     line(out)
Index: jcc/cpp.py
===================================================================
--- jcc/cpp.py  (revision 1066936)
+++ jcc/cpp.py  (working copy)
@@ -111,14 +111,16 @@
     return [cppname(name) for name in names]
 
 
+def fullname(names):
+
+    return "::%s" %('::'.join(names))
+
+
 def typename(cls, current, const):
 
     if cls.isArray():
         componentType = cls.getComponentType()
-        if componentType.isArray():
-            name = 'JArray< %s >' %(typename(componentType, current, False))
-        else:
-            name = 'JArray<%s>' %(typename(componentType, current, False))
+        name = 'JArray< %s >' %(typename(componentType, current, False))
 
     elif cls.isPrimitive():
         name = cls.getName()
@@ -130,7 +132,7 @@
         name = cppname(cls.getName().split('.')[-1])
 
     else:
-        name = '::'.join([cppname(name) for name in cls.getName().split('.')])
+        name = fullname([cppname(name) for name in cls.getName().split('.')])
 
     if const:
         return "const %s&" %(name)
@@ -786,7 +788,7 @@
              _dll_export, cppname(names[-1]))
     else:
         line(out, indent, 'class %s%s : public %s {',
-             _dll_export, cppname(names[-1]), '::'.join(cppnames(superNames)))
+             _dll_export, cppname(names[-1]), fullname(cppnames(superNames)))
         
     line(out, indent, 'public:')
     indent += 1
@@ -814,7 +816,7 @@
         line(out, indent, '};')
 
     line(out)
-    line(out, indent, 'static java::lang::Class *class$;');
+    line(out, indent, 'static ::java::lang::Class *class$;');
     line(out, indent, 'static jmethodID *mids$;');
     if instanceFields:
         line(out, indent, 'static jfieldID *fids$;');
@@ -822,13 +824,13 @@
     line(out)
 
     line(out, indent, 'explicit %s(jobject obj) : %s(obj) {',
-         cppname(names[-1]), '::'.join(cppnames(superNames)))
+         cppname(names[-1]), fullname(cppnames(superNames)))
     line(out, indent + 1, 'if (obj != NULL)');
     line(out, indent + 2, 'initializeClass();')
     line(out, indent, '}')
     line(out, indent, '%s(const %s& obj) : %s(obj) {}',
          cppname(names[-1]), cppname(names[-1]),
-         '::'.join(cppnames(superNames)))
+         fullname(cppnames(superNames)))
 
     if fields:
         line(out)
@@ -916,7 +918,7 @@
         indent += 1
 
     line(out)
-    line(out, indent, 'java::lang::Class *%s::class$ = NULL;',
+    line(out, indent, '::java::lang::Class *%s::class$ = NULL;',
          cppname(names[-1]))
     line(out, indent, 'jmethodID *%s::mids$ = NULL;', cppname(names[-1]))
     if instanceFields:
@@ -980,7 +982,7 @@
                  fieldName, fieldName, signature(field))
 
     line(out)
-    line(out, indent + 2, 'class$ = (java::lang::Class *) new JObject(cls);')
+    line(out, indent + 2, 'class$ = (::java::lang::Class *) new JObject(cls);')
 
     if fields:
         line(out, indent + 2, 'cls = (jclass) class$->this$;')
@@ -1010,7 +1012,7 @@
 
         line(out, indent, "%s::%s(%s) : %s(env->newObject(initializeClass, 
&mids$, mid_init$_%s%s)) {}",
              cppname(names[-1]), cppname(names[-1]), decls,
-             '::'.join(cppnames(superNames)),
+             fullname(cppnames(superNames)),
              env.strhash(sig), args)
 
     for method in methods:
@@ -1036,7 +1038,7 @@
             isStatic = False
             if superMethod is not None:
                 qualifier = 'Nonvirtual'
-                this = 'this$, (jclass) %s::class$->this$' 
%('::'.join(cppnames(superNames)))
+                this = 'this$, (jclass) %s::class$->this$' 
%(fullname(cppnames(superNames)))
                 declaringClass = superMethod.getDeclaringClass()
                 midns = '%s::' %(typename(declaringClass, cls, False))
             else:

Reply via email to