lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r945517 - in /lucene/pylucene/branches/branch_3x/jcc/jcc: cpp.py python.py sources/JObject.h sources/functions.cpp
Date Tue, 18 May 2010 06:33:31 GMT
Author: vajda
Date: Tue May 18 06:33:31 2010
New Revision: 945517

URL: http://svn.apache.org/viewvc?rev=945517&view=rev
Log:
--import functional on windows

Modified:
    lucene/pylucene/branches/branch_3x/jcc/jcc/cpp.py
    lucene/pylucene/branches/branch_3x/jcc/jcc/python.py
    lucene/pylucene/branches/branch_3x/jcc/jcc/sources/JObject.h
    lucene/pylucene/branches/branch_3x/jcc/jcc/sources/functions.cpp

Modified: lucene/pylucene/branches/branch_3x/jcc/jcc/cpp.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/jcc/jcc/cpp.py?rev=945517&r1=945516&r2=945517&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/jcc/jcc/cpp.py (original)
+++ lucene/pylucene/branches/branch_3x/jcc/jcc/cpp.py Tue May 18 06:33:31 2010
@@ -509,8 +509,11 @@ def jcc(args):
             typeset.add(findClass('java/io/Writer'))
             packages.add('java.lang')
 
+        _dll_export = ''
         if moduleName:
             cppdir = os.path.join(output, '_%s' %(moduleName))
+            if shared and sys.platform == 'win32':
+                _dll_export = "_dll_%s " %(moduleName)
         else:
             cppdir = output
 
@@ -550,7 +553,7 @@ def jcc(args):
                 (superCls, constructors, methods, protectedMethods,
                  fields, instanceFields, declares) = \
                     header(env, out_h, cls, typeset, packages, excludes,
-                           generics)
+                           generics, _dll_export)
 
                 if not allInOne:
                     out_cpp = file(fileName + '.cpp', 'w')
@@ -566,7 +569,8 @@ def jcc(args):
                            fields, instanceFields,
                            mappings.get(className), sequences.get(className),
                            renames.get(className),
-                           declares, typeset, moduleName, generics)
+                           declares, typeset, moduleName, generics,
+                           _dll_export)
 
                 line(out_h)
                 line(out_h, 0, '#endif')
@@ -601,7 +605,7 @@ def jcc(args):
                         arch, generics, resources, imports)
 
 
-def header(env, out, cls, typeset, packages, excludes, generics):
+def header(env, out, cls, typeset, packages, excludes, generics, _dll_export):
 
     names = cls.getName().split('.')
     superCls = cls.getSuperclass()
@@ -765,10 +769,11 @@ def header(env, out, cls, typeset, packa
 
     line(out)
     if superClsName == 'JObject':
-        line(out, indent, 'class %s : public JObject {', cppname(names[-1]))
+        line(out, indent, 'class %s%s : public JObject {',
+             _dll_export, cppname(names[-1]))
     else:
-        line(out, indent, 'class %s : public %s {',
-             cppname(names[-1]), '::'.join(cppnames(superNames)))
+        line(out, indent, 'class %s%s : public %s {',
+             _dll_export, cppname(names[-1]), '::'.join(cppnames(superNames)))
         
     line(out, indent, 'public:')
     indent += 1

Modified: lucene/pylucene/branches/branch_3x/jcc/jcc/python.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/jcc/jcc/python.py?rev=945517&r1=945516&r2=945517&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/jcc/jcc/python.py (original)
+++ lucene/pylucene/branches/branch_3x/jcc/jcc/python.py Tue May 18 06:33:31 2010
@@ -541,7 +541,8 @@ def extension(env, out, indent, cls, nam
 
 def python(env, out_h, out, cls, superCls, names, superNames,
            constructors, methods, protectedMethods, fields, instanceFields,
-           mapping, sequence, rename, declares, typeset, moduleName, generics):
+           mapping, sequence, rename, declares, typeset, moduleName, generics,
+           _dll_export):
 
     line(out_h)
     line(out_h, 0, '#include <Python.h>')
@@ -551,7 +552,8 @@ def python(env, out_h, out, cls, superCl
     for name in names[:-1]:
         line(out_h, indent, 'namespace %s {', cppname(name))
         indent += 1
-    line(out_h, indent, 'extern PyTypeObject TYPE_NAME(%s);', names[-1])
+    line(out_h, indent, '%sextern PyTypeObject TYPE_NAME(%s);', 
+         _dll_export, names[-1])
 
     if generics:
         clsParams = getTypeParameters(cls)
@@ -559,7 +561,7 @@ def python(env, out_h, out, cls, superCl
         clsParams = None
 
     line(out_h)
-    line(out_h, indent, 'class t_%s {', names[-1])
+    line(out_h, indent, 'class %st_%s {', _dll_export, names[-1])
     line(out_h, indent, 'public:')
     line(out_h, indent + 1, 'PyObject_HEAD')
     line(out_h, indent + 1, '%s object;', cppname(names[-1]))
@@ -1720,7 +1722,7 @@ def compile(env, jccPath, output, module
         script_args.append('--debug')
         compile_args += DEBUG_CFLAGS
     elif sys.platform == 'win32':
-        pass
+	pass
     elif sys.platform == 'sunos5':
         link_args.append('-Wl,-s')
     else:
@@ -1749,11 +1751,12 @@ def compile(env, jccPath, output, module
         'extra_compile_args': compile_args,
         'extra_link_args': link_args,
         'include_dirs': includes,
-        'sources': sources
+        'sources': sources,
+        'define_macros': []
     }
 
     if generics:
-        args['define_macros'] = [('_java_generics', None)]
+        args['define_macros'] += [('_java_generics', None)]
 
     if shared:
         shlibdir = os.path.dirname(os.path.dirname(_jcc.__file__))
@@ -1770,8 +1773,25 @@ def compile(env, jccPath, output, module
             args['library_dirs'] = [shlibdir]
             args['libraries'] = ['jcc']
         elif sys.platform == 'win32':
-            jcclib = 'jcc%s.lib' %(debug and '_d' or '')
-            args['extra_link_args'] += [os.path.join(shlibdir, 'jcc', jcclib)]
+            _d = debug and '_d' or ''
+            libdir = os.path.join(modulePath, 'lib')
+            if not os.path.exists(libdir):
+                os.mkdir(libdir)
+            extlib = os.path.join('lib', "%s%s.lib" %(extname, _d))
+            package_data.append(extlib)
+            args['extra_link_args'] += [
+                os.path.join(shlibdir, 'jcc', 'jcc%s.lib' %(_d)),
+                "/IMPLIB:%s" %(os.path.join(modulePath, extlib))
+            ]
+            args['libraries'] = [
+                os.path.join(import_.__dir__, 'lib',
+                             '_%s%s' %(import_.__name__, _d))
+                for import_ in imports
+            ]
+            args['define_macros'] += [
+                ("_dll_%s" %(import_.__name__), '_declspec(dllimport)')
+                for import_ in imports
+            ] + [("_dll_%s" %(moduleName), '_declspec(dllexport)')]
         else:
             raise NotImplementedError, "shared mode on %s" %(sys.platform)
 

Modified: lucene/pylucene/branches/branch_3x/jcc/jcc/sources/JObject.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/jcc/jcc/sources/JObject.h?rev=945517&r1=945516&r2=945517&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/jcc/jcc/sources/JObject.h (original)
+++ lucene/pylucene/branches/branch_3x/jcc/jcc/sources/JObject.h Tue May 18 06:33:31 2010
@@ -20,7 +20,7 @@
 #include <stdio.h>
 #include "JCCEnv.h"
 
-class JObject {
+class _DLL_EXPORT JObject {
 public:
     jobject this$;
     int id;  /* zero when this$ is a weak ref */

Modified: lucene/pylucene/branches/branch_3x/jcc/jcc/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/jcc/jcc/sources/functions.cpp?rev=945517&r1=945516&r2=945517&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/jcc/jcc/sources/functions.cpp (original)
+++ lucene/pylucene/branches/branch_3x/jcc/jcc/sources/functions.cpp Tue May 18 06:33:31 2010
@@ -81,7 +81,7 @@ PyObject *findClass(PyObject *self, PyOb
 
         if (cls)
             return t_Class::wrap_Object(Class(cls));
-    } catch (JCCEnv::pythonError e) {
+    } catch (JCCEnv::pythonError) {
         return NULL;
     } catch (JCCEnv::exception e) {
         PyErr_SetJavaError(e.throwable);
@@ -213,7 +213,7 @@ int _parseArgs(PyObject **args, unsigned
                   try {
                       getclassfn initializeClass = va_arg(list, getclassfn);
                       cls = (*initializeClass)();
-                  } catch (JCCEnv::pythonError e) {
+                  } catch (JCCEnv::pythonError) {
                       return -1;
                   } catch (JCCEnv::exception e) {
                       PyErr_SetJavaError(e.throwable);



Mime
View raw message