1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <jni.h>
#include "JCCEnv.h"
#include "java/lang/Object.h"
#include "java/lang/Class.h"
#include "java/lang/String.h"
#include "java/lang/Throwable.h"
#include "java/io/PrintWriter.h"
namespace java {
namespace lang {
enum {
mid_printStackTrace_0,
mid_printStackTrace_1,
mid_getMessage,
max_mid
};
Class *Throwable::class$ = NULL;
jmethodID *Throwable::_mids = NULL;
jclass Throwable::initializeClass(bool getOnly)
{
if (getOnly)
return (jclass) (class$ == NULL ? NULL : class$->this$);
if (!class$)
{
jclass cls = env->findClass("java/lang/Throwable");
_mids = new jmethodID[max_mid];
_mids[mid_printStackTrace_0] =
env->getMethodID(cls, "printStackTrace",
"()V");
_mids[mid_printStackTrace_1] =
env->getMethodID(cls, "printStackTrace",
"(Ljava/io/PrintWriter;)V");
_mids[mid_getMessage] =
env->getMethodID(cls, "getMessage",
"()Ljava/lang/String;");
class$ = (Class *) new JObject(cls);
}
return (jclass) class$->this$;
}
void Throwable::printStackTrace() const
{
env->callVoidMethod(this$, _mids[mid_printStackTrace_0]);
}
void Throwable::printStackTrace(java::io::PrintWriter writer) const
{
env->callVoidMethod(this$, _mids[mid_printStackTrace_1],
writer.this$);
}
String Throwable::getMessage() const
{
return String(env->callObjectMethod(this$, _mids[mid_getMessage]));
}
}
}
#include "structmember.h"
#include "functions.h"
#include "macros.h"
namespace java {
namespace lang {
static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
PyObject *args);
static PyMethodDef t_Throwable__methods_[] = {
DECLARE_METHOD(t_Throwable, printStackTrace, METH_VARARGS),
{ NULL, NULL, 0, NULL }
};
static PyType_Slot PY_TYPE_SLOTS(Throwable)[] = {
{ Py_tp_methods, t_Throwable__methods_ },
{ Py_tp_init, (void *) abstract_init },
{ 0, 0 }
};
static PyType_Def *PY_TYPE_BASES(Throwable)[] = {
&PY_TYPE_DEF(Object),
NULL
};
DEFINE_TYPE(Throwable, t_Throwable, Throwable);
static PyObject *t_Throwable_printStackTrace(t_Throwable *self,
PyObject *args)
{
switch (PyTuple_Size(args)) {
case 0:
OBJ_CALL(self->object.printStackTrace());
Py_RETURN_NONE;
case 1:
{
java::io::PrintWriter writer((jobject) NULL);
if (!parseArgs(args, "j", java::io::PrintWriter::class$,
&writer))
{
OBJ_CALL(self->object.printStackTrace(writer));
Py_RETURN_NONE;
}
}
default:
PyErr_SetString(PyExc_ValueError, "invalid args");
return NULL;
}
}
}
}
|