You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-commits@lucene.apache.org by va...@apache.org on 2012/06/26 04:33:23 UTC
svn commit: r1353805 - in /lucene/pylucene/trunk/jcc: CHANGES jcc/cpp.py
jcc/sources/jcc.cpp
Author: vajda
Date: Tue Jun 26 02:33:22 2012
New Revision: 1353805
URL: http://svn.apache.org/viewvc?rev=1353805&view=rev
Log:
- added support for initVM's vmargs to be a [list, of, args], PYLUCENE-19
Modified:
lucene/pylucene/trunk/jcc/CHANGES
lucene/pylucene/trunk/jcc/jcc/cpp.py
lucene/pylucene/trunk/jcc/jcc/sources/jcc.cpp
Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=1353805&r1=1353804&r2=1353805&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Tue Jun 26 02:33:22 2012
@@ -1,6 +1,7 @@
Version 2.13 ->
--------------------
- fixed class initialization race bug PYLUCENE-17 (with Patrick J. McNerthney)
+ - added support for initVM's vmargs to be a [list, of, args], PYLUCENE-19
-
Version 2.12 -> 2.13
Modified: lucene/pylucene/trunk/jcc/jcc/cpp.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/cpp.py?rev=1353805&r1=1353804&r2=1353805&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/cpp.py (original)
+++ lucene/pylucene/trunk/jcc/jcc/cpp.py Tue Jun 26 02:33:22 2012
@@ -508,7 +508,7 @@ def jcc(args):
vmargs.append('-Djava.library.path=' + os.pathsep.join(libpath))
initvm_args['maxstack'] = '512k'
- initvm_args['vmargs'] = ' '.join(vmargs)
+ initvm_args['vmargs'] = vmargs
env = initVM(os.pathsep.join(classpath) or None, **initvm_args)
Modified: lucene/pylucene/trunk/jcc/jcc/sources/jcc.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/jcc.cpp?rev=1353805&r1=1353804&r2=1353805&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/jcc.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/jcc.cpp Tue Jun 26 02:33:22 2012
@@ -351,9 +351,9 @@ _DLL_EXPORT PyObject *initVM(PyObject *s
};
char *classpath = NULL;
char *initialheap = NULL, *maxheap = NULL, *maxstack = NULL;
- char *vmargs = NULL;
+ PyObject *vmargs = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzz", kwnames,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzO", kwnames,
&classpath,
&initialheap, &maxheap, &maxstack,
&vmargs))
@@ -431,18 +431,18 @@ _DLL_EXPORT PyObject *initVM(PyObject *s
if (maxstack)
add_option("-Xss", maxstack, &vm_options[nOptions++]);
- if (vmargs)
+ if (vmargs != NULL && PyString_Check(vmargs))
{
#ifdef _MSC_VER
- char *buf = _strdup(vmargs);
+ char *buf = _strdup(PyString_AS_STRING(vmargs));
#else
- char *buf = strdup(vmargs);
+ char *buf = strdup(PyString_AS_STRING(vmargs));
#endif
char *sep = ",";
char *option;
- for (option = strtok(buf, sep); option; option = strtok(NULL, sep))
- {
+ for (option = strtok(buf, sep); option != NULL;
+ option = strtok(NULL, sep)) {
if (nOptions < sizeof(vm_options) / sizeof(JavaVMOption))
add_option("", option, &vm_options[nOptions++]);
else
@@ -450,13 +450,58 @@ _DLL_EXPORT PyObject *initVM(PyObject *s
free(buf);
for (unsigned int i = 0; i < nOptions; i++)
delete vm_options[i].optionString;
- PyErr_Format(PyExc_ValueError, "Too many options (> %d)",
- nOptions);
+ PyErr_Format(PyExc_ValueError,
+ "Too many options (> %d)", nOptions);
return NULL;
}
}
free(buf);
}
+ else if (vmargs != NULL && PySequence_Check(vmargs))
+ {
+ PyObject *fast =
+ PySequence_Fast(vmargs, "error converting vmargs to a tuple");
+
+ if (fast == NULL)
+ return NULL;
+
+ for (int i = 0; i < PySequence_Fast_GET_SIZE(fast); ++i) {
+ PyObject *arg = PySequence_Fast_GET_ITEM(fast, i);
+
+ if (PyString_Check(arg))
+ {
+ char *option = PyString_AS_STRING(arg);
+
+ if (nOptions < sizeof(vm_options) / sizeof(JavaVMOption))
+ add_option("", option, &vm_options[nOptions++]);
+ else
+ {
+ for (unsigned int i = 0; i < nOptions; i++)
+ delete vm_options[i].optionString;
+ PyErr_Format(PyExc_ValueError,
+ "Too many options (> %d)", nOptions);
+ return NULL;
+ }
+ }
+ else
+ {
+ for (unsigned int i = 0; i < nOptions; i++)
+ delete vm_options[i].optionString;
+ PyErr_Format(PyExc_TypeError,
+ "vmargs arg %d is not a string", i);
+ Py_DECREF(fast);
+ return NULL;
+ }
+ }
+
+ Py_DECREF(fast);
+ }
+ else if (vmargs != NULL)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "vmargs is not a string or sequence");
+ return NULL;
+ }
//vm_options[nOptions++].optionString = "-verbose:gc";
//vm_options[nOptions++].optionString = "-Xcheck:jni";