python-jpype-0.5.4.2/ 0000775 0001750 0001750 00000000000 11620747357 013636 5 ustar takaki takaki python-jpype-0.5.4.2/PKG-INFO 0000666 0001750 0001750 00000000375 11614231506 014725 0 ustar takaki takaki Metadata-Version: 1.0
Name: JPype
Version: 0.5.4.2
Summary: Python-Java bridge
Home-page: http://jpype.sourceforge.net/
Author: Steve Menard
Author-email: devilwolf@users.sourceforge.net
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
python-jpype-0.5.4.2/README-LINUX.TXT 0000666 0001750 0001750 00000001164 11614007722 016061 0 ustar takaki takaki This release include preliminary support for linux.
In order to compile the source, distribution, you need to make the 2 following changes :
1) in setup.py, change the line 19 to reflect the path to YOUR JDK installation
Also, even if you do install from binary, you have to make the following change after installing.
in the file jpype/_copy.py, at line 33, change to reflect the path to YOUR JDK installation
These two steps are temporary, and should disappear before the 0.3 final.
There is one additional problem with jpype and linux. You can more about it and a solution in the examples/linux directory.
python-jpype-0.5.4.2/test/ 0000775 0001750 0001750 00000000000 11620747357 014615 5 ustar takaki takaki python-jpype-0.5.4.2/test/build.xml 0000666 0001750 0001750 00000000552 11614007722 016426 0 ustar takaki takaki
python-jpype-0.5.4.2/test/sample/ 0000775 0001750 0001750 00000000000 11620747357 016076 5 ustar takaki takaki python-jpype-0.5.4.2/test/sample/big.xml 0000666 0001750 0001750 00000505276 11614007722 017366 0 ustar takaki takaki
python-jpype-0.5.4.2/test/java_dom.py 0000666 0001750 0001750 00000003331 11614007722 016735 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import time
from jpype import *
startJVM(getDefaultJVMPath(), "-ea")
# XML test
Element = JPackage("org").w3c.dom.Element
def output(el, prefix="") :
if not Element.__isinstance__(el) :
return
#print prefix, "<", el.getTagName(),
atts = el.getAttributes()
for i in range(atts.getLength()) :
a = atts.item(i);
#print a.getNodeName(), '="%s"' % a.getNodeValue(),
#print '>'
nl = el.getChildNodes()
for i in range(nl.getLength()) :
output(nl.item(i), prefix+" ")
#print prefix, "", el.getTagName(), ">"
t = time.time()
count = 30
for i in range(count) :
build = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder()
doc = build.parse("d:/darkwolf/jpype/test/sample/big.xml")
el = doc.getDocumentElement()
output(el)
t2 = time.time()
print count, "iterations in", t2-t, "seconds"
shutdownJVM()
python-jpype-0.5.4.2/test/testlucene.py 0000666 0001750 0001750 00000002040 11614007722 017324 0 ustar takaki takaki from jpype import *
startJVM(getDefaultJVMPath(),'-Djava.class.path=c:/tools/lucene-1.4.3/lucene-1.4.3.jar')
QueryParser = JClass("org.apache.lucene.queryParser.QueryParser")
IndexSearcher = JClass("org.apache.lucene.search.IndexSearcher")
IndexReader = JClass("org.apache.lucene.index.IndexReader")
StandardAnalyzer = JClass("org.apache.lucene.analysis.standard.StandardAnalyzer")
FSDirectory = JClass("org.apache.lucene.store.FSDirectory")
IndexWriter = JClass("org.apache.lucene.index.IndexWriter")
SimpleAnalyzer = JClass("org.apache.lucene.analysis.SimpleAnalyzer")
IndexWriter('c:/temp/lucene', SimpleAnalyzer(), True).close()
directory = FSDirectory.getDirectory("c:/temp/lucene",False)
reader = IndexReader.open(directory)
searcher = IndexSearcher(reader)
queryparser = QueryParser.parse("wenger","contents",StandardAnalyzer())
print queryparser.rewrite
print queryparser.rewrite.matchReport(reader)
qp = queryparser.rewrite(reader)
print qp
print searcher.search.matchReport(qp)
hits = searcher.search(qp) python-jpype-0.5.4.2/test/harness/ 0000775 0001750 0001750 00000000000 11620747357 016260 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/ 0000775 0001750 0001750 00000000000 11620747357 017407 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/exc/ 0000775 0001750 0001750 00000000000 11620747357 020166 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/exc/ExceptionTest.java 0000666 0001750 0001750 00000002426 11614007722 023621 0 ustar takaki takaki // *****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.exc;
class ExceptionTest
{
public static void throwRuntime()
{
throw new RuntimeException("Foo");
}
public static void throwIOException() throws java.io.IOException
{
throw new java.io.IOException("Bar");
}
public static boolean delegateThrow(ExceptionThrower th)
{
try
{
th.throwIOException();
}
catch (java.io.IOException ex)
{
return true;
}
catch (Throwable ex)
{
ex.printStackTrace();
}
return false;
}
} python-jpype-0.5.4.2/test/harness/jpype/exc/ExceptionThrower.java 0000666 0001750 0001750 00000001543 11614007722 024333 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.exc;
interface ExceptionThrower
{
void throwIOException() throws java.io.IOException;
} python-jpype-0.5.4.2/test/harness/jpype/xml/ 0000775 0001750 0001750 00000000000 11620747357 020207 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/xml/DelegateHandler.java 0000666 0001750 0001750 00000006357 11614007722 024063 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.xml;
import org.xml.sax.helpers.*;
import org.xml.sax.*;
public class DelegateHandler extends DefaultHandler
{
private EntityResolver er;
private DTDHandler dh;
private ContentHandler ch;
private ErrorHandler eh;
public DelegateHandler(EntityResolver er, DTDHandler dh, ContentHandler ch, ErrorHandler eh)
{
this.er = er;
this.dh = dh;
this.ch = ch;
this.eh = eh;
}
public void characters(char[] ch, int start, int length) throws SAXException
{
if (ch != null)
{
this.ch.characters(ch, start, length);
}
}
public void endDocument() throws SAXException
{
if (ch != null)
{
ch.endDocument();
}
}
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
{
if (ch != null)
{
ch.endElement(namespaceURI, localName, qName);
}
}
public void endPrefixMapping(String prefix) throws SAXException
{
if (ch != null)
{
ch.endPrefixMapping(prefix);
}
}
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
{
if (ch != null)
{
this.ch.ignorableWhitespace(ch, start, length);
}
}
public void processingInstruction(String target, String data) throws SAXException
{
if (ch != null)
{
ch.processingInstruction(target, data);
}
}
public void setDocumentLocator(Locator locator)
{
if (ch != null)
{
ch.setDocumentLocator(locator);
}
}
public void skippedEntity(String name) throws SAXException
{
if (ch != null)
{
ch.skippedEntity(name);
}
}
public void startDocument() throws SAXException
{
if (ch != null)
{
ch.startDocument();
}
}
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
{
if (ch != null)
{
ch.startElement(namespaceURI, localName, qName, atts);
}
}
public void startPrefixMapping(String prefix, String uri) throws SAXException
{
if (ch != null)
{
ch.startPrefixMapping(prefix, uri);
}
}
} python-jpype-0.5.4.2/test/harness/jpype/mro/ 0000775 0001750 0001750 00000000000 11620747357 020204 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/mro/F.java 0000666 0001750 0001750 00000001436 11614007722 021226 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
interface F
{
} python-jpype-0.5.4.2/test/harness/jpype/mro/B.java 0000666 0001750 0001750 00000001453 11614007722 021221 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
interface B extends D, A
{
} python-jpype-0.5.4.2/test/harness/jpype/mro/D.java 0000666 0001750 0001750 00000001436 11614007722 021224 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
interface D
{
} python-jpype-0.5.4.2/test/harness/jpype/mro/E.java 0000666 0001750 0001750 00000001436 11614007722 021225 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
interface E
{
} python-jpype-0.5.4.2/test/harness/jpype/mro/C.java 0000666 0001750 0001750 00000001503 11614007722 021216 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
class C implements A, B
{
public void foo()
{}
} python-jpype-0.5.4.2/test/harness/jpype/mro/A.java 0000666 0001750 0001750 00000001471 11614007722 021220 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.mro;
interface A extends E, F
{
void foo();
} python-jpype-0.5.4.2/test/harness/jpype/rmi/ 0000775 0001750 0001750 00000000000 11620747357 020176 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/rmi/IServer.java 0000666 0001750 0001750 00000001570 11614007722 022411 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.rmi;
import java.rmi.*;
interface IServer extends Remote
{
void callRemote() throws RemoteException;
} python-jpype-0.5.4.2/test/harness/jpype/rmi/ServerImpl.java 0000666 0001750 0001750 00000003432 11614007722 023121 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.rmi;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
class ServerImpl extends UnicastRemoteObject implements IServer
{
public ServerImpl() throws RemoteException
{
super();
}
public void callRemote() throws RemoteException
{
System.out.println("Method has been called!!!!");
}
public static void main(String args[])
{
// Create and install a security manager
// if (System.getSecurityManager() == null) {
// System.setSecurityManager(new RMISecurityManager());
// }
try {
Registry reg = LocateRegistry.createRegistry(2004);
ServerImpl obj = new ServerImpl();
// Bind this object instance to the name "HelloServer"
Naming.rebind("//192.168.100.60:2004/server", obj);
System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
python-jpype-0.5.4.2/test/harness/jpype/ref/ 0000775 0001750 0001750 00000000000 11620747357 020163 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/ref/TestReferenceQeue.java 0000666 0001750 0001750 00000002062 11614007722 024372 0 ustar takaki takaki package jpype.ref;
public class TestReferenceQeue
{
public static void main(String[] args)
{
// final JPypeReferenceQueue queue = new JPypeReferenceQueue();
//
// new Thread(new Runnable() {
//
// public void run()
// {
// queue.startManaging();
// }
//
// }).start();
//
// Object dummy = new Object();
// long dummyAddress = 123456;
//
// JPypeReference ref = new JPypeReference(dummy, queue);
//
// queue.registerRef(ref, dummyAddress);
//
// System.out.println("ref is enqueued? "+ref.isEnqueued());
//
// long start = System.currentTimeMillis();
// dummy = null;
// while (System.currentTimeMillis()-start < 30000 && ! (ref.isEnqueued()))
// {
// System.gc();
// System.out.print(".");
// try
// {
// Thread.sleep(250);
// }
// catch(InterruptedException ex) {}
// }
//
// System.out.println();
// System.out.println("ref is enqueued? "+ref.isEnqueued());
// queue.stop();
}
}
python-jpype-0.5.4.2/test/harness/jpype/objectwrapper/ 0000775 0001750 0001750 00000000000 11620747357 022256 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/objectwrapper/Test1.java 0000666 0001750 0001750 00000002113 11614007722 024104 0 ustar takaki takaki //*****************************************************************************
// Copyright 2004-2008 Steve Menard
//
// 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.
//
//*****************************************************************************
package jpype.objectwrapper;
public class Test1
{
public Test1()
{
}
public int Method1(Number n)
{
return 1;
}
public int Method1(Integer n)
{
return 2;
}
public int Method1(Object n)
{
return 3;
}
public int Method1(String n)
{
return 4;
}
} python-jpype-0.5.4.2/test/harness/jpype/proxy/ 0000775 0001750 0001750 00000000000 11620747357 020570 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/proxy/ITestInterface3.java 0000666 0001750 0001750 00000001550 11614007722 024356 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.proxy;
public interface ITestInterface3 extends ITestInterface2
{
String testMethod2();
} python-jpype-0.5.4.2/test/harness/jpype/proxy/Test3.java 0000666 0001750 0001750 00000003511 11614007722 022423 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.proxy;
public class Test3
{
public static void testProxy(ITestInterface2 itf)
{
System.out.println("Test Method = "+itf.testMethod());
if (itf instanceof ITestInterface3)
{
System.out.println("Test Method2 = "+((ITestInterface3)itf).testMethod2());
}
}
public void testProxyWithThread(final ITestInterface2 itf)
{
Thread t = new Thread(new Runnable() {
public void run()
{
for (int i = 0; i < 10; i++)
{
itf.testMethod();
}
}
});
t.start();
try {
System.out.println("Waiting for thread to finish");
t.join();
System.out.println("Thread has finished");
}
catch(InterruptedException ex)
{
}
}
public void testCallbackWithParameters(ITestInterface2 itf)
{
byte[] vals = { 1, 2, 3, 4};
itf.write(vals , 12, 13);
}
} python-jpype-0.5.4.2/test/harness/jpype/proxy/ITestInterface2.java 0000666 0001750 0001750 00000001603 11614007722 024354 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.proxy;
public interface ITestInterface2
{
int testMethod();
void write(byte[] bytes, int pos, int length);
} python-jpype-0.5.4.2/test/harness/jpype/attr/ 0000775 0001750 0001750 00000000000 11620747357 020361 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/attr/Holder.java 0000666 0001750 0001750 00000001477 11614007722 022440 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.attr;
public class Holder
{
public String f;
} python-jpype-0.5.4.2/test/harness/jpype/attr/Test2.java 0000666 0001750 0001750 00000002156 11614007722 022217 0 ustar takaki takaki //*****************************************************************************
// Copyright 2004-2008 Steve Menard
//
// 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.
//
//*****************************************************************************
package jpype.attr;
public class Test2 extends Test1
{
public Test2()
{
super();
}
public void test2Method()
{
}
public String toString(String foo)
{
return foo;
}
public Test2 delete(String arg1, String arg2)
{
System.out.println("Overloaded test 2 called");
return null;
}
} python-jpype-0.5.4.2/test/harness/jpype/attr/SubHolder.java 0000666 0001750 0001750 00000001531 11614007722 023101 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.attr;
public class SubHolder extends Holder implements java.io.Serializable
{
} python-jpype-0.5.4.2/test/harness/jpype/attr/ClassWithBuffer.java 0000666 0001750 0001750 00000000315 11614007722 024244 0 ustar takaki takaki package jpype.attr;
import java.awt.image.BufferStrategy;
public class ClassWithBuffer
{
public BufferStrategy bufferStrategy;
public void foo() {
System.out.println("foo");
}
}
python-jpype-0.5.4.2/test/harness/jpype/attr/Test1.java 0000666 0001750 0001750 00000004371 11614007722 022217 0 ustar takaki takaki //*****************************************************************************
// Copyright 2004-2008 Steve Menard
//
// 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.
//
//*****************************************************************************
package jpype.attr;
public class Test1
{
private String mBigString;
public Test1()
{
StringBuffer sb = new StringBuffer(4001);
for (int i = 0; i < 4000; i++)
{
sb.append("A");
}
mBigString = sb.toString();
}
public String getBigString()
{
return mBigString;
}
public String toString()
{
return "aaa";
}
public static String[] testStaticString(String s1, String s2)
{
return new String[] { s1, s2};
}
public static String testStaticHolder(Holder h)
{
return h.f;
}
public String[] testString(String s1, String s2)
{
return new String[] { s1, s2};
}
public String[] testStringArray(String[] vals)
{
return vals;
}
public String stringValue = "Foo";
public char charValue = 'a';
public static Object objectValue= new Integer(234);
public static void reset()
{
objectValue= new Integer(234);
}
public Object getSubClass()
{
return new SubHolder();
}
public void callWithClass(Class c)
{
}
public void test1Method()
{
}
public void setByte(byte b)
{
}
public void setShort(short b)
{
}
public void setInt(int b)
{
}
public String callWithSomething(Object obj)
{
return "Object";
}
public String callWithSomething(Class obj)
{
return "Class";
}
public Test1 delete(String arg1, String arg2)
{
System.out.println("Overloaded test 1 called");
return null;
}
} python-jpype-0.5.4.2/test/harness/jpype/numeric/ 0000775 0001750 0001750 00000000000 11620747357 021051 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/numeric/NumericTest.java 0000666 0001750 0001750 00000001617 11614007722 024151 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.numeric;
class NumericTest
{
public static boolean doubleIsTwiceMaxFloat(double d)
{
return d == (Float.MAX_VALUE*2.0);
}
} python-jpype-0.5.4.2/test/harness/jpype/nio/ 0000775 0001750 0001750 00000000000 11620747357 020174 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/nio/NioReceive.java 0000666 0001750 0001750 00000002333 11614007722 023056 0 ustar takaki takaki //*****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.nio;
import java.nio.*;
class NioReceive
{
public static void receiveBuffer(ByteBuffer buffer)
{
System.out.println("Received a buffer of "+buffer.toString());
}
public static void allocSomeMemory()
{
byte[] b = new byte[10000];
}
public static void receiveBufferWithException(ByteBuffer buffer)
{
System.out.println("Received a buffer of "+buffer.toString());
throw new RuntimeException("hello!");
}
} python-jpype-0.5.4.2/test/harness/jpype/array/ 0000775 0001750 0001750 00000000000 11620747357 020525 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/array/Test2.java 0000666 0001750 0001750 00000000262 11614007722 022357 0 ustar takaki takaki package jpype.array;
public class Test2 {
public Object[] getValue()
{
return new Object[0];
}
public Object test(Object o)
{
return null;
}
} python-jpype-0.5.4.2/test/harness/jpype/array/TestArray.java 0000666 0001750 0001750 00000002550 11614007722 023276 0 ustar takaki takaki // *****************************************************************************
//Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.array;
public class TestArray
{
public TestArray()
{
}
public int[] i = {12234,1234,234,1324,424,234,234,142,5,251,242,35,235,62,1235,46,245132,51, 2, 3, 4};
public Object[] getSubClassArray()
{
return new String[] { "aaa", "bbb" };
}
public Object getArrayAsObject()
{
return new String[] { "aaa", "bbb" };
}
public char[] getCharArray()
{
return new char[] { 'a', 'v', 'c', 'd' };
}
public byte[] getByteArray()
{
String s = "avcd";
return s.getBytes();
}
} python-jpype-0.5.4.2/test/harness/jpype/serial/ 0000775 0001750 0001750 00000000000 11620747357 020666 5 ustar takaki takaki python-jpype-0.5.4.2/test/harness/jpype/serial/SerializationTest.java 0000666 0001750 0001750 00000001406 11614007722 025175 0 ustar takaki takaki //Copyright 2004-2008 Steve Menard
//
//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.
//
//*****************************************************************************
package jpype.serial;
public class SerializationTest implements java.io.Serializable
{
} python-jpype-0.5.4.2/test/lists_and_maps.py 0000666 0001750 0001750 00000001225 11614007722 020155 0 ustar takaki takaki from jpype import *
import time
startJVM(getDefaultJVMPath())
#startJVM("c:/tools/jdk1.4.2/jre/bin/server/jvm.dll")
arr = java.util.ArrayList()
# no matching overloads found for this line:
arr.addAll([str(x) for x in xrange(50)])
print arr
hmap = java.util.HashMap()
# no matching overloads found for this line:
hmap.putAll({5:6, 7:8, 'hello':'there'})
print hmap
#for x in xrange(5):
# # this works:
# hmap.put(str(x), str(x))
# # but this doesn't:
# hmap.put(str(x), x)
#
#
## this throws: AttributeError: 'java.util.HashMap' object has no attribute 'iterator'
#for x in hmap:
# print x, hmap[x]
python-jpype-0.5.4.2/test/buf_leak_test3.py 0000666 0001750 0001750 00000002725 11614007722 020055 0 ustar takaki takaki from jpype import *
import time
remote_pack="c:/tools/netbeean-remote-pack"
profiler_options = [
"-agentpath:%s/lib/deployed/jdk15/windows/profilerinterface.dll=%s/lib,5140" % (remote_pack, remote_pack)
]
options = [
#'-verbose:gc',
'-Xmx64m',
'-Djava.class.path=classes'
] #+ profiler_options
cnt = 0
#setUsePythonThreadForDeamon(True)
startJVM(getDefaultJVMPath(), *options)
#startJVM("c:/tools/jdk1.4.2/jre/bin/server/jvm.dll", *options)
class MyStr(str):
def __init__ (self, val):
str.__init__(self, val)
global cnt
cnt += 1
print 'created string', cnt
def __del__(self):
global cnt
cnt -= 1
print 'deleted string', cnt
receive = JClass("jpype.nio.NioReceive")
while True:
# everything runs great with this line uncommented
#p = JString('5' * 1024 * 1024)
# with this line uncommented, the python strings aren't GC'd
p = java.lang.StringBuffer(MyStr('5' * 1024 * 1024))
# with this line uncommented, the JVM throws an OutOfMemoryError (not GC'ing the proxied java objects?),
# but the python strings are being GC'd
#p = java.lang.StringBuffer(JString(MyStr('5' * 1024 * 1024)))
#
# forget the direct buffer for now....
#
buf = nio.convertToDirectBuffer(MyStr('5' * 1024 * 1024 * 5))
try :
receive.receiveBufferWithException(buf)
except :
pass
python-jpype-0.5.4.2/test/stub.py 0000666 0001750 0001750 00000001626 11614007722 016137 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import jpype
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea")
s = jpype.java.lang.String
t = jpype.java.awt.Color
print s
print t
python-jpype-0.5.4.2/test/findjvm.py 0000666 0001750 0001750 00000001571 11614007722 016616 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import jpype, os.path
jvmlib = jpype.getDefaultJVMPath()
print os.path.dirname(os.path.dirname(jvmlib))
python-jpype-0.5.4.2/test/jpypetest/ 0000775 0001750 0001750 00000000000 11620747357 016644 5 ustar takaki takaki python-jpype-0.5.4.2/test/jpypetest/numeric.py 0000666 0001750 0001750 00000003512 11614007722 020647 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import JPackage, java, JFloat
import unittest, common, sys
def suite() :
return unittest.makeSuite(NumericTestCase)
class NumericTestCase(common.JPypeTestCase) :
def testMathAbs(self) :
assert java.lang.Math.abs(-10) == 10
def testDoubleConversion(self) :
f = java.lang.Float.MAX_VALUE * 2
jpype = JPackage("jpype")
assert jpype.numeric.NumericTest.doubleIsTwiceMaxFloat(f)
def testDoubleIsProperlyConverted(self) :
if sys.platform.find("linux") != -1 :
# double comparison on linux is broken ... Nan == 0.0!!!
print java.lang.Double.NaN, " != ", 0.0, " -> ", bool(java.lang.Double.NaN != 0.0), " == -> ", bool(java.lang.Double.NaN == 0.0)
else :
assert java.lang.Double.NEGATIVE_INFINITY != 0.0
assert java.lang.Double.MAX_VALUE != 0.0
assert java.lang.Double.NaN != 0.0
assert java.lang.Double.POSITIVE_INFINITY != 0.0
def testNegativeJFloatWrapper(self):
f = JFloat(-1)
python-jpype-0.5.4.2/test/jpypetest/mro.py 0000666 0001750 0001750 00000001755 11614007722 020011 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import JPackage, java
import unittest, common, sys
def suite() :
return unittest.makeSuite(MroTestCase)
class MroTestCase(common.JPypeTestCase) :
def testMro(self) :
C = JPackage('jpype.mro').C python-jpype-0.5.4.2/test/jpypetest/array.py 0000666 0001750 0001750 00000007061 11614007722 020326 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import jpype
from jpype import JPackage, JArray, JByte, java
import unittest, common
VALUES = (12234,1234,234,1324,424,234,234,142,5,251,242,35,235,62,1235,46,245132,51, 2, 3, 4)
def suite() :
return unittest.makeSuite(ArrayTestCase)
class ArrayTestCase(common.JPypeTestCase) :
def __arrayEquals(self, a1, a2) :
assert len(a1) == len(a2)
for i in range(len(a1)) :
assert a1[i] == a2[i]
def testReadArray(self) :
t = JPackage("jpype").array.TestArray()
assert not isinstance(t, JPackage)
self.__arrayEquals(VALUES, t.i)
assert t.i[0] == VALUES[0]
self.__arrayEquals(VALUES[1:-2], t.i[1:-2])
def testStangeBehavior(self) :
''' Test for stange crash reported in bug #1089302'''
Test2 = jpype.JPackage('jpype.array').Test2
test = Test2()
test.test(test.getValue())
def testWriteArray(self) :
t = JPackage("jpype").array.TestArray()
assert not isinstance(t, JPackage)
t.i[0] = 32
assert t.i[0] == 32
t.i[1:3] = (33, 34)
assert t.i[1] == 33
assert t.i[2] == 34
self.__arrayEquals(t.i[:5], (32, 33, 34 ,1324, 424) )
def testObjectArraySimple(self) :
a = JArray(java.lang.String, 1)(2)
a[1] = "Foo"
assert "Foo" == a[1]
def testByteArraySimple(self) :
a = JArray(JByte)(2)
a[1] = 2
assert a[1] == 2
def testIterateArray(self):
t = JPackage("jpype").array.TestArray()
assert not isinstance(t, JPackage)
for i in t.i :
assert i != 0
def testGetSubclass(self) :
t = JPackage("jpype").array.TestArray()
v = t.getSubClassArray()
assert isinstance(v[0], unicode)
def testGetArrayAsObject(self) :
t = JPackage("jpype").array.TestArray()
v = t.getArrayAsObject()
def testCharArrayAsString(self) :
t = JPackage("jpype").array.TestArray()
v = t.charArray
assert str(v) == 'avcd'
assert unicode(v) == u'avcd'
def testByteArrayAsString(self) :
t = JPackage("jpype").array.TestArray()
v = t.byteArray
assert str(v) == 'avcd'
def testByteArrayIntoVector(self):
ba = jpype.JArray(jpype.JByte)('123')
v = jpype.java.util.Vector(1)
v.add(ba)
assert len(v) == 1
assert v[0] is not None
if __name__ == '__main__' :
import os.path
root = os.path.abspath(os.path.dirname(__file__))
common.CLASSPATH= "%s/../../build/test/java" % root
runner = unittest.TextTestRunner()
runner.run(suite())
python-jpype-0.5.4.2/test/jpypetest/proxy.py 0000666 0001750 0001750 00000005221 11614007722 020365 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import *
import unittest, common
def suite() :
return unittest.makeSuite(ProxyTestCase)
def _testMethod() :
return 32
def _testMethod2() :
return "Fooo!"
class C :
def testMethod(self) :
return 42
def testMethod2(self) :
return "Bar"
def write(self, bytes, start, length) :
print 'aaaaa'
print bytes.__class__, bytes[0]
print start
print length
class ProxyTestCase(common.JPypeTestCase) :
def testProxyWithDict(self) :
d = {
'testMethod' : _testMethod,
'testMethod2' : _testMethod2,
}
itf2 = JPackage("jpype.proxy").ITestInterface3
Test3 = JPackage("jpype.proxy").Test3
proxy = JProxy(itf2, dict=d)
Test3.testProxy(proxy)
def testProxyWithInst(self) :
itf2 = JPackage("jpype.proxy").ITestInterface3
Test3 = JPackage("jpype.proxy").Test3
c = C()
proxy = JProxy(itf2, inst=c)
Test3.testProxy(proxy)
def testProxyWithThread(self) :
itf2 = JPackage("jpype.proxy").ITestInterface3
Test3 = JPackage("jpype.proxy").Test3
c = C()
proxy = JProxy(itf2, inst=c)
t3 = Test3()
t3.testProxyWithThread(proxy)
def testProxyWithArguments(self) :
itf2 = JPackage("jpype.proxy").ITestInterface2
Test3 = JPackage("jpype.proxy").Test3
c = C()
proxy = JProxy(itf2, inst=c)
Test3().testCallbackWithParameters(proxy)
def testProxyWithMultipleInterface(self) :
itf2 = JPackage("jpype.proxy").ITestInterface2
itf3 = JPackage("jpype.proxy").ITestInterface3
Test3 = JPackage("jpype.proxy").Test3
c = C()
proxy = JProxy([itf2,itf3], inst=c)
Test3().testCallbackWithParameters(proxy) python-jpype-0.5.4.2/test/jpypetest/__init__.py 0000666 0001750 0001750 00000001560 11614007722 020745 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
__all__ = ['common', 'array', 'attr', 'objectwrapper', 'proxy', 'numeric', 'exc', 'serial', 'mro'] python-jpype-0.5.4.2/test/jpypetest/attr.py 0000666 0001750 0001750 00000012115 11614007722 020156 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import jpype
from jpype import JString, java, JArray
import unittest
import common
import time
def suite() :
return unittest.makeSuite(AttributeTestCase)
class AttributeTestCase(common.JPypeTestCase) :
def setUp(self) :
common.JPypeTestCase.setUp(self)
self.__jp = self.jpype.attr
def testWithBufferStrategy(self):
j = jpype.JPackage("jpype").attr.ClassWithBuffer
print j
def testCallOverloadedMethodWithCovariance(self):
# This is a JDk5-specific problem.
h = jpype.java.lang.StringBuffer()
h.delete(0, 0)
def testCallStaticString(self) :
h = self.__jp.Test1()
v = h.testString(JString("abcd"), JString("abcde"))
assert v[0] == 'abcd'
assert v[1] == 'abcde'
def testCallStaticUnicodeString(self) :
h = self.__jp.Test1()
v = h.testString(JString(u"abcd"), JString(u"abcde"))
assert v[0] == 'abcd'
assert v[1] == 'abcde'
def testCallString(self) :
v = self.__jp.Test1.testStaticString("a", "b")
assert v[0] == 'a'
assert v[1] == 'b'
def testCallUnicodeString(self) :
v = self.__jp.Test1.testStaticString(u"a", u"b")
assert v[0] == 'a'
assert v[1] == 'b'
def testCallStringWithNone(self) :
v = self.__jp.Test1.testStaticString("a", None)
assert v[0] == 'a'
assert v[1] == None
def testWithHolder(self) :
print 'testWithHolder'
holder = self.__jp.Holder()
holder.f = "ffff"
assert holder.f == "ffff"
self.__jp.Test1.testStaticHolder(holder)
def testWithSubHolder(self) :
h2 = self.__jp.SubHolder()
h2.f = "subholder"
self.__jp.Test1.testStaticHolder(h2)
def testCallWithArray(self) :
h2 = self.__jp.Test1()
StringArray = JArray(JString)
v = StringArray(["Foo", "bar"])
t = self.__jp.Test1()
t.testStringArray(v)
def testGetStaticValue(self) :
assert str(self.__jp.Test1.objectValue) == "234"
def testGetStaticByInstance(self) :
h = self.__jp.Test1()
assert str(h.objectValue) == "234"
def testGetNonStatic(self) :
h = self.__jp.Test1()
assert h.stringValue == "Foo"
def testSetStaticValue(self) :
self.__jp.Test1.objectValue = java.lang.Integer(43)
assert str(self.__jp.Test1.objectValue) == "43"
self.__jp.Test1.reset()
def testSetNonStaticValue(self) :
h = self.__jp.Test1()
h.stringValue="bar"
assert h.stringValue == "bar"
def testReturnSubClass(self) :
h = self.__jp.Test1()
v = h.getSubClass()
assert isinstance(v, self.__jp.SubHolder)
def testCallWithClass(self) :
h = self.__jp.Test1()
h.callWithClass(java.lang.Comparable)
def testCallSuperclassMethod(self) :
h = self.__jp.Test2()
h.test2Method()
h.test1Method()
def testCallWithLong(self) :
h = self.__jp.Test1()
l = long(123)
h.setByte(l)
h.setShort(l)
h.setInt(l)
def testCharAttribute(self) :
h = self.__jp.Test1()
h.charValue = u'b'
print h.charValue
print repr(h.charValue)
assert h.charValue == u'b'
def testGetPrimitiveType(self) :
Integer = jpype.JClass("java.lang.Integer")
intType = Integer.TYPE
def testDifferentiateClassAndObject(self) :
h = self.__jp.Test1()
assert h.callWithSomething(self.__jp.Test1) == u"Class"
assert h.callWithSomething(jpype.JObject(self.__jp.Test1, jpype.java.lang.Object)) == u"Object"
def testToString(self):
h = self.__jp.Test1()
assert str(h) == 'aaa'
def testSuperToString(self):
h = self.__jp.Test2()
print h
assert str(h) == 'aaa'
del h
# def testStringToConversion(self):
# try :
# jpype.ConversionConfig.string = False
# for i in range(1) :
# h = self.__jp.Test1()
#
# start = time.time();
# for j in range(10):
# ts = h.getBigString()
# stop = time.time()
# print ts.__class__, (stop-start), 'ms'
#
# # for comparison ... convert a string to JStrng and back
# s = "".join([" "]*1024*1024*5)
# start = time.time()
# js = JString(s)
# stop = time.time()
# print "converted to JString in", (stop-start), 'ms', len(s)
#
# start = time.time()
# cs = str(JString(s))
# print cs
# print "converted to String in", (stop-start), 'ms', len(cs), cs
# finally :
# jpype.ConversionConfig.string = True
python-jpype-0.5.4.2/test/jpypetest/serial.py 0000666 0001750 0001750 00000003216 11614007722 020465 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import JException, java, JavaException, JProxy, JClass
import unittest, common
import traceback
def suite() :
return unittest.makeSuite(SerializationTestCase)
class SerializationTestCase(common.JPypeTestCase) :
def testSerialize(self) :
o = JClass("jpype.serial.SerializationTest")()
fos = java.io.FileOutputStream("testSerial.dat")
oos = java.io.ObjectOutputStream(fos)
oos.writeObject(o)
oos.flush()
oos.close()
fos.close()
# The following cannto work because JPype has no way to simulate the "caller's ClassLoader"
# def testDeSerialize(self) :
#
# fis = java.io.FileInputStream("testSerial.dat")
# ois = java.io.ObjectInputStream(fis)
#
# o = ois.readObject()
# ois.close()
# fis.close()
python-jpype-0.5.4.2/test/jpypetest/exc.py 0000666 0001750 0001750 00000004636 11614007722 017774 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import JException, java, JavaException, JProxy, JPackage
import unittest, common
import traceback
def throwIOException() :
raise java.io.IOException.PYEXC("Test throw")
def throwByJavaException() :
JPackage('jpype').exc.ExceptionTest.throwIOException()
def suite() :
return unittest.makeSuite(ExceptionTestCase)
class ExceptionTestCase(common.JPypeTestCase) :
def testExceptionThrown(self) :
try :
self.jpype.exc.ExceptionTest.throwRuntime()
assert False
except JavaException, ex :
print 'Caught a Java exception ...'
if ex.javaClass() is java.lang.RuntimeException :
print "Caught the exception", ex.message()
print ex.stacktrace()
else:
assert False
except Exception, ex:
print ex.__class__, isinstance(ex, JavaException)
print ex.__class__.__bases__[0].__bases__[0].__bases__
print JavaException
assert False
print 'if here, everything is fine'
def testExceptionByJavaClass(self) :
try :
self.jpype.exc.ExceptionTest.throwRuntime()
assert False
except JException(java.lang.RuntimeException), ex :
print "Caught the exception", ex.message(), "->", ex.javaClass()
print ex.stacktrace()
except Exception, ex:
print ex
assert False
# def testThrowException(self) :
# d = {"throwIOException" : throwIOException, }
# p = JProxy(self.jpype.exc.ExceptionThrower, dict=d)
#
# assert self.jpype.exc.ExceptionTest.delegateThrow(p)
def testThrowException3(self) :
d = {"throwIOException" : throwByJavaException, }
p = JProxy(self.jpype.exc.ExceptionThrower, dict=d)
assert self.jpype.exc.ExceptionTest.delegateThrow(p)
python-jpype-0.5.4.2/test/jpypetest/objectwrapper.py 0000666 0001750 0001750 00000002473 11614007722 022061 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import *
import unittest, common
def suite() :
return unittest.makeSuite(ObjectWrapperTestCase)
class ObjectWrapperTestCase(common.JPypeTestCase) :
def testCallOverloads(self) :
# build the harness
h = JPackage("jpype.objectwrapper").Test1()
o = java.lang.Integer(1)
assert h.Method1(JObject(o, java.lang.Number)) == 1
assert h.Method1(o) == 2
assert h.Method1(JObject(java.lang.Integer(1), java.lang.Object)) == 3
assert h.Method1(JString("")) == 4
python-jpype-0.5.4.2/test/jpypetest/common.py 0000666 0001750 0001750 00000001767 11614007722 020507 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
from jpype import *
import unittest
CLASSPATH = None
class JPypeTestCase(unittest.TestCase) :
def setUp(self) :
self.jpype = JPackage('jpype')
def tearDown(self) :
pass
python-jpype-0.5.4.2/test/convtest.py 0000666 0001750 0001750 00000006530 11614007722 017026 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import jpype
import array
import time
import os
def generateStringData(aSize):
return ''.join(['a']*aSize)
DATA_SIZE = 5*1024*1024 # 5 MB
def runBaseline(data):
print 'Running baseline test : converting a python string->array.array->JArray(JByte). size = ', len(data)/1024.0, 'kb'
print ' Start time (no optimize) on my machine is 3.56 seconds.'
start = time.time()
#darr = array.array('b', DATA)
arr_cls = jpype.JArray(jpype.JByte)
java_arr = arr_cls(DATA)
end = time.time()
print ' test run in', (end-start), 'seconds.'
def runStringToByteBuffer(data):
print 'Running String conversion to byte buffer. size = ', len(data)/1024.0, 'kb'
start = time.time()
bb = jpype.nio.convertToDirectBuffer(data)
end = time.time()
print ' test run in', (end-start), 'seconds.'
jpype.JPackage("jpype").nio.NioReceive.receiveBuffer(bb)
def runStringToByteArray(data):
print 'Running String conversion to byte array. size = ', len(data)/1024.0, 'kb'
start = time.time()
arr_cls = jpype.JArray(jpype.JByte)
java_arr = arr_cls(data)
end = time.time()
print ' test run in', (end-start), 'seconds.'
root = os.path.abspath(os.path.dirname(__file__))
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Xmx5M", "-verbose:gc", "-Djava.class.path=./classes%s%s%sclasses" % (os.pathsep, root, os.sep))
DELETED = False
class MyStr(str):
def __del__(self):
global DELETED
print 'string got deleted'
DELETED = True
def testStringMemory():
print 'with keeping the data'
data = MyStr('5' * 1024)
print data
buf = jpype.nio.convertToDirectBuffer(data)
# print buf.get()
# print buf.get()
# print buf.get()
print 'now deleting the data'
del data
# print buf.get()
# print buf.get()
# print buf.get()
# print buf.get()
print 'now deleting the buffer itself'
del buf
print 'now waiting for the string to get deleted'
while not DELETED:
time.sleep(1)
print '.',
jpype.JPackage("jpype").nio.NioReceive.allocSomeMemory()
testStringMemory()
#for i in range(1,5) :
# DATA = generateStringData(DATA_SIZE*i)
# runBaseline(DATA)
# runStringToByteBuffer(DATA)
# runStringToByteArray(DATA)
# expressly delete data to test the GC ...
#del DATA
#for i in range(3) :
# print 'GC', i
# jpype.JClass("java.lang.System").gc();
# time.sleep(15)
jpype.shutdownJVM() python-jpype-0.5.4.2/test/testsuite.py 0000666 0001750 0001750 00000003027 11614007722 017210 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import unittest, os, sys, new
from jpypetest import *
import jpype
import os.path
def suite() :
return unittest.TestSuite( (
numeric.suite(),
attr.suite(),
array.suite(),
objectwrapper.suite(),
proxy.suite(),
exc.suite(),
serial.suite(),
mro.suite(),
))
import jpype
def runTest() :
root = os.path.abspath(os.path.dirname(__file__))
print "Running testsuite using JVM", jpype.getDefaultJVMPath()
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Xmx256M", "-Xms64M",
"-Djava.class.path=./classes%s%s%sclasses" % (os.pathsep, root, os.sep))
runner = unittest.TextTestRunner()
runner.run(suite())
s = slice(2, 4)
print s, dir(s)
jpype.shutdownJVM()
if __name__ == '__main__' :
runTest()
python-jpype-0.5.4.2/test/buf_leak_test.py 0000666 0001750 0001750 00000001161 11614007722 017763 0 ustar takaki takaki from jpype import *
import time
remote_pack="c:/tools/netbeean-remote-pack"
profiler_options = [
"-agentpath:%s/lib/deployed/jdk15/windows/profilerinterface.dll=%s/lib,5140" % (remote_pack, remote_pack)
]
options = [
'-verbose:gc',
'-Xmx16m',
] #+ profiler_options
#startJVM(getDefaultJVMPath(), *options)
startJVM("c:/tools/jdk1.4.2/jre/bin/server/jvm.dll", *options)
class MyStr(str):
def __del__(self):
print 'string got deleted'
while True:
buf = java.lang.String('5' * 1024 * 1024 * 5)
buf = nio.convertToDirectBuffer(MyStr('5' * 1024 * 1024))
# time.sleep(1)
python-jpype-0.5.4.2/test/test_awt.py 0000666 0001750 0001750 00000000444 11614007722 017011 0 ustar takaki takaki from jpype import *
import time
def run():
print 'Thread started'
try:
print repr(java.awt.Frame)
javax.swing.JFrame("Test Frame").setVisible(True)
shutdownGuiEnvironment()
except JException, ex :
print ex
startJVM(getDefaultJVMPath())
setupGuiEnvironment(run)
python-jpype-0.5.4.2/test/java_sax.py 0000666 0001750 0001750 00000004233 11614007722 016753 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import time
from jpype import *
import os.path
root = os.path.abspath(os.path.dirname(__file__))
startJVM(getDefaultJVMPath(), "-ea", "-Djava.class.path=%s/classes" % root)
# XML test
Element = JPackage("org").w3c.dom.Element
class ContentHandler(object) :
def characters(self, ch, start, length) :
pass
def endDocument(self) :
pass
def endElement(self, namespaceURI, localName, qName) :
pass
def endPrefixMapping(self, prefix) :
pass
def ignorableWhitespace(self, ch, start, length) :
pass
def processingInstruction(self, target, data) :
pass
def setDocumentLocator(self, locator) :
pass
def skippedEntity(self, name) :
pass
def startDocument(self, ) :
pass
def startElement(self, namespaceURI, localName, qName, atts) :
pass
def startPrefixMapping(self, prefix, uri) :
pass
t = time.time()
count = 30
for i in range(count) :
DelegateHandler = JPackage("jpype.xml").DelegateHandler
dh = DelegateHandler(None, None, JProxy("org.xml.sax.ContentHandler", inst=ContentHandler()), None)
build = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser()
build.parse("d:/darkwolf/jpype/test/sample/big.xml", dh)
t2 = time.time()
print count, "iterations in", t2-t, "seconds"
shutdownJVM()
python-jpype-0.5.4.2/test/python_dom.py 0000666 0001750 0001750 00000002755 11614007722 017346 0 ustar takaki takaki #*****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# 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.
#
#*****************************************************************************
import time
from xml.dom import minidom
def output(el, prefix="") :
if el.nodeType != el.ELEMENT_NODE :
return
#print prefix, "<", el.tagName,
atts = el.attributes
for i in range(atts.length) :
a = atts.item(i);
#print a.nodeName, '="%s"' % a.nodeValue,
#print '>'
nl = el.childNodes
for i in range(nl.length) :
output(nl.item(i), prefix+" ")
#print prefix, "", el.tagName, ">"
t = time.time()
count = 30
for i in range(count) :
doc = minidom.parse("d:/darkwolf/jpype/test/sample/big.xml")
el = doc.documentElement
output(el)
t2 = time.time()
print count, "iterations in", t2-t, "seconds"
python-jpype-0.5.4.2/src/ 0000775 0001750 0001750 00000000000 11620747357 014425 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/ 0000775 0001750 0001750 00000000000 11620747357 015713 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/python/ 0000775 0001750 0001750 00000000000 11620747357 017234 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/python/py_method.cpp 0000666 0001750 0001750 00000025104 11614007722 021720 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
static PyMethodDef methodMethods[] = {
{"getName", &PyJPMethod::getName, METH_VARARGS, ""},
{"isBeanAccessor", &PyJPMethod::isBeanAccessor, METH_VARARGS, ""},
{"isBeanMutator", &PyJPMethod::isBeanMutator, METH_VARARGS, ""},
{"matchReport", &PyJPMethod::matchReport, METH_VARARGS, ""},
{NULL},
};
static PyTypeObject methodClassType =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"JavaMethod", /*tp_name*/
sizeof(PyJPMethod), /*tp_basicsize*/
0, /*tp_itemsize*/
PyJPMethod::__dealloc__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
PyJPMethod::__call__, /*tp_call*/
PyJPMethod::__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
"Java Method", /*tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
methodMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew /* tp_new */
};
// Static methods
void PyJPMethod::initType(PyObject* module)
{
PyType_Ready(&methodClassType);
PyModule_AddObject(module, "_JavaMethod", (PyObject*)&methodClassType);
}
PyJPMethod* PyJPMethod::alloc(JPMethod* m)
{
PyJPMethod* res = PyObject_New(PyJPMethod, &methodClassType);
res->m_Method = m;
return res;
}
PyObject* PyJPMethod::__call__(PyObject* o, PyObject* args, PyObject* kwargs)
{
TRACE_IN("PyJPMethod::__call__");
try {
PyJPMethod* self = (PyJPMethod*)o;
TRACE1(self->m_Method->getName());
JPCleaner cleaner;
//JPyHelper::dumpSequenceRefs(args, "start");
vector vargs;
Py_ssize_t len = JPyObject::length(args);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* obj = JPySequence::getItem(args, i); // return a new ref
HostRef* ref = new HostRef((void*)obj);
cleaner.add(ref);
vargs.push_back(ref);
Py_DECREF(obj); // delete the new ref returned by getItem
}
//JPyHelper::dumpSequenceRefs(args, "middle");
HostRef* res = self->m_Method->invoke(vargs);
//JPyHelper::dumpSequenceRefs(args, "end");
return detachRef(res);
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
void PyJPMethod::__dealloc__(PyObject* o)
{
PyJPMethod* self = (PyJPMethod*)o;
self->ob_type->tp_free(o);
}
PyObject* PyJPMethod::__str__(PyObject* o)
{
PyJPMethod* self = (PyJPMethod*)o;
stringstream sout;
sout << "m_Method->getClassName() << "." << self->m_Method->getName() << ">";
return JPyString::fromString(sout.str().c_str());
}
PyObject* PyJPMethod::isBeanAccessor(PyObject* o, PyObject* arg)
{
try {
PyJPMethod* self = (PyJPMethod*)o;
bool res = self->m_Method->isBeanAccessor();
if (res)
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPMethod::isBeanMutator(PyObject* o, PyObject* arg)
{
try {
PyJPMethod* self = (PyJPMethod*)o;
bool res = self->m_Method->isBeanMutator();
if (res)
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPMethod::getName(PyObject* o, PyObject* arg)
{
try {
PyJPMethod* self = (PyJPMethod*)o;
string name = self->m_Method->getName();
PyObject* res = JPyString::fromString(name.c_str());
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPMethod::matchReport(PyObject* o, PyObject* args)
{
try {
PyJPMethod* self = (PyJPMethod*)o;
JPCleaner cleaner;
vector vargs;
Py_ssize_t len = JPyObject::length(args);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* obj = JPySequence::getItem(args, i);
HostRef* ref = new HostRef((void*)obj);
cleaner.add(ref);
vargs.push_back(ref);
Py_DECREF(obj);
}
string report = self->m_Method->matchReport(vargs);
PyObject* res = JPyString::fromString(report.c_str());
return res;
}
PY_STANDARD_CATCH
return NULL;
}
static PyMethodDef boundMethodMethods[] = {
{"matchReport", &PyJPBoundMethod::matchReport, METH_VARARGS, ""},
{NULL},
};
static PyTypeObject boundMethodClassType =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"JavaBoundMethod", /*tp_name*/
sizeof(PyJPBoundMethod), /*tp_basicsize*/
0, /*tp_itemsize*/
PyJPBoundMethod::__dealloc__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
PyJPBoundMethod::__call__, /*tp_call*/
PyJPBoundMethod::__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
"Java Bound Method", /*tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
boundMethodMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
PyJPBoundMethod::__init__, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew /* tp_new */
};
// Static methods
void PyJPBoundMethod::initType(PyObject* module)
{
PyType_Ready(&boundMethodClassType);
PyModule_AddObject(module, "_JavaBoundMethod", (PyObject*)&boundMethodClassType);
}
int PyJPBoundMethod::__init__(PyObject* o, PyObject* args, PyObject* kwargs)
{
try {
PyJPBoundMethod* self = (PyJPBoundMethod*)o;
PyObject* javaMethod;
PyObject* inst;
JPyArg::parseTuple(args, "OO", &javaMethod, &inst);
Py_INCREF(inst);
Py_INCREF(javaMethod);
self->m_Instance = inst;
self->m_Method = (PyJPMethod*)javaMethod;
return 0;
}
PY_STANDARD_CATCH
return 1;
}
PyObject* PyJPBoundMethod::__call__(PyObject* o, PyObject* args, PyObject* kwargs)
{
TRACE_IN("PyJPBoundMethod::__call__");
try {
PyObject* result=NULL;
{
PyJPBoundMethod* self = (PyJPBoundMethod*)o;
JPCleaner cleaner;
TRACE1(self->m_Method->m_Method->getName());
vector vargs;
Py_ssize_t len = JPyObject::length(args);
HostRef* ref = new HostRef((void*)self->m_Instance);
cleaner.add(ref);
vargs.push_back(ref);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* obj = JPySequence::getItem(args, i); // returns a new ref
ref = new HostRef((void*)obj);
cleaner.add(ref);
vargs.push_back(ref);
Py_DECREF(obj); // remove ref returned by getItem
}
HostRef* res = self->m_Method->m_Method->invoke(vargs);
TRACE2("Call finished, result = ", res);
result = detachRef(res);
TRACE1("Cleaning up");
}
return result;
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
void PyJPBoundMethod::__dealloc__(PyObject* o)
{
TRACE_IN("PyJPBoundMethod::__dealloc__");
PyJPBoundMethod* self = (PyJPBoundMethod*)o;
Py_DECREF(self->m_Instance);
Py_DECREF(self->m_Method);
self->ob_type->tp_free(o);
TRACE1("Method freed");
TRACE_OUT;
}
PyObject* PyJPBoundMethod::__str__(PyObject* o)
{
PyJPBoundMethod* self = (PyJPBoundMethod*)o;
stringstream sout;
sout << "m_Method->m_Method->getClassName() << "." << self->m_Method->m_Method->getName() << ">";
return JPyString::fromString(sout.str().c_str());
}
PyObject* PyJPBoundMethod::matchReport(PyObject* o, PyObject* args)
{
try {
PyJPBoundMethod* self = (PyJPBoundMethod*)o;
cout << "Match report for " << self->m_Method->m_Method->getName() << endl;
vector vargs;
Py_ssize_t len = JPyObject::length(args);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* obj = JPySequence::getItem(args, i);
vargs.push_back(new HostRef((void*)obj));
Py_DECREF(obj);
}
string report = self->m_Method->m_Method->matchReport(vargs);
PyObject* res = JPyString::fromString(report.c_str());
return res;
}
PY_STANDARD_CATCH
return NULL;
}
python-jpype-0.5.4.2/src/native/python/py_field.cpp 0000666 0001750 0001750 00000013716 11614007722 021531 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
static PyMethodDef fieldMethods[] = {
{"getName", &PyJPField::getName, METH_VARARGS, ""},
{"isFinal", &PyJPField::isFinal, METH_VARARGS, ""},
{"isStatic", &PyJPField::isStatic, METH_VARARGS, ""},
{"getStaticAttribute", &PyJPField::getStaticAttribute, METH_VARARGS, ""},
{"setStaticAttribute", &PyJPField::setStaticAttribute, METH_VARARGS, ""},
{"getInstanceAttribute", &PyJPField::getInstanceAttribute, METH_VARARGS, ""},
{"setInstanceAttribute", &PyJPField::setInstanceAttribute, METH_VARARGS, ""},
{NULL},
};
static PyTypeObject fieldClassType =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"JavaField", /*tp_name*/
sizeof(PyJPField), /*tp_basicsize*/
0, /*tp_itemsize*/
PyJPField::__dealloc__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
"Java Field", /*tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
fieldMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew /* tp_new */
};
// Static methods
void PyJPField::initType(PyObject* module)
{
PyType_Ready(&fieldClassType);
PyModule_AddObject(module, "_JavaField", (PyObject*)&fieldClassType);
}
PyJPField* PyJPField::alloc(JPField* m)
{
PyJPField* res = PyObject_New(PyJPField, &fieldClassType);
res->m_Field = m;
return res;
}
void PyJPField::__dealloc__(PyObject* o)
{
PyJPField* self = (PyJPField*)o;
self->ob_type->tp_free(o);
}
PyObject* PyJPField::getName(PyObject* o, PyObject* arg)
{
try {
PyJPField* self = (PyJPField*)o;
string name = self->m_Field->getName();
PyObject* res = JPyString::fromString(name.c_str());
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPField::getStaticAttribute(PyObject* o, PyObject* arg)
{
try {
PyJPField* self = (PyJPField*)o;
HostRef* res = self->m_Field->getStaticAttribute();
PyObject* result = detachRef(res);
return result;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPField::setStaticAttribute(PyObject* o, PyObject* arg)
{
try {
PyJPField* self = (PyJPField*)o;
PyObject* value;
JPyArg::parseTuple(arg, "O", &value);
HostRef v(value);
self->m_Field->setStaticAttribute(&v);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPField::setInstanceAttribute(PyObject* o, PyObject* arg)
{
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
PyObject* jo;
PyObject* value;
JPyArg::parseTuple(arg, "O!O", &PyCObject_Type, &jo, &value);
JPObject* obj = (JPObject*)JPyCObject::asVoidPtr(jo);
HostRef* ref = new HostRef(value);
cleaner.add(ref);
jobject jobj = obj->getObject();
cleaner.addLocal(jobj);
self->m_Field->setAttribute(jobj, ref);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPField::getInstanceAttribute(PyObject* o, PyObject* arg)
{
TRACE_IN("getInstanceAttribute");
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
PyObject* jo;
JPyArg::parseTuple(arg, "O!", &PyCObject_Type, &jo);
JPObject* obj = (JPObject*)JPyCObject::asVoidPtr(jo);
jobject jobj = obj->getObject();
cleaner.addLocal(jobj);
HostRef* res = self->m_Field->getAttribute(jobj);
return detachRef(res);
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
PyObject* PyJPField::isStatic(PyObject* o, PyObject* arg)
{
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
if (self->m_Field->isStatic())
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPField::isFinal(PyObject* o, PyObject* arg)
{
JPCleaner cleaner;
try {
PyJPField* self = (PyJPField*)o;
if (self->m_Field->isFinal())
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
python-jpype-0.5.4.2/src/native/python/py_hostenv.cpp 0000666 0001750 0001750 00000037557 11614007722 022145 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
#define UNWRAP(ref) ((PyObject*)ref->data())
#define GETDESC(ref) string((char*)JPyCObject::getDesc(UNWRAP(ref)))
#define WRAP(ref, t) new HostRef( JPyCObject::fromVoidAndDesc(ref, (void*)t, NULL) )
#define IS_REF(ref, t) JPyCObject::check((PyObject*)ref) && GETDESC(ref) == t
void* PythonHostEnvironment::acquireRef(void* d)
{
Py_XINCREF((PyObject*)d);
return d;
}
void PythonHostEnvironment::releaseRef(void* d)
{
Py_XDECREF((PyObject*)d);
}
bool PythonHostEnvironment::isRefNull(void* d)
{
return d == NULL;
}
string PythonHostEnvironment::describeRef(HostRef* ref)
{
stringstream out;
return out.str();
}
void* PythonHostEnvironment::gotoExternal()
{
PyThreadState *_save;
_save = PyEval_SaveThread();
return (void*)_save;
}
void PythonHostEnvironment::returnExternal(void* state)
{
PyThreadState *_save = (PyThreadState *)state;
PyEval_RestoreThread(_save);
}
void PythonHostEnvironment::setRuntimeException(const char* msg)
{
JPyErr::setString(PyExc_RuntimeError, msg);
}
void PythonHostEnvironment::setAttributeError(const char* msg)
{
JPyErr::setString(PyExc_AttributeError, msg);
}
void PythonHostEnvironment::setTypeError(const char* msg)
{
JPyErr::setString(PyExc_TypeError, msg);
}
void PythonHostEnvironment::raise(const char* msg)
{
RAISE(JPypeException, msg);
}
HostRef* PythonHostEnvironment::getNone()
{
return new HostRef(Py_None);
}
bool PythonHostEnvironment::isNone(HostRef* ref)
{
return UNWRAP(ref) == Py_None;
}
bool PythonHostEnvironment::isBoolean(HostRef* ref)
{
return JPyBoolean::isTrue(UNWRAP(ref)) || JPyBoolean::isFalse(UNWRAP(ref));
}
jboolean PythonHostEnvironment::booleanAsBoolean(HostRef* ref)
{
if (JPyBoolean::isTrue(UNWRAP(ref)))
{
return true;
}
return false;
}
HostRef* PythonHostEnvironment::getTrue()
{
return new HostRef(JPyBoolean::getTrue(), false);
}
HostRef* PythonHostEnvironment::getFalse()
{
return new HostRef(JPyBoolean::getFalse(), false);
}
bool PythonHostEnvironment::isSequence(HostRef* ref)
{
return JPySequence::check(UNWRAP(ref)) && ! JPyString::check(UNWRAP(ref));
}
HostRef* PythonHostEnvironment::newMutableSequence(jsize sz)
{
return new HostRef(JPySequence::newList(sz), false);
}
HostRef* PythonHostEnvironment::newImmutableSequence(jsize sz)
{
return new HostRef(JPySequence::newTuple(sz), false);
}
jsize PythonHostEnvironment::getSequenceLength(HostRef* ref)
{
return (jsize)JPyObject::length(UNWRAP(ref));
}
HostRef* PythonHostEnvironment::getSequenceItem(HostRef* ref, jsize pos)
{
return new HostRef(JPySequence::getItem(UNWRAP(ref), pos), false);
}
void PythonHostEnvironment::setSequenceItem(HostRef* seq, jsize pos, HostRef* val)
{
JPySequence::setItem(UNWRAP(seq), pos, UNWRAP(val));
}
bool PythonHostEnvironment::isInt(HostRef* res)
{
return JPyInt::check(UNWRAP(res));
}
HostRef* PythonHostEnvironment::newInt(jint v)
{
return new HostRef(JPyInt::fromLong(v), false);
}
jint PythonHostEnvironment::intAsInt(HostRef* res)
{
return JPyInt::asLong(UNWRAP(res));
}
bool PythonHostEnvironment::isLong(HostRef* ref)
{
return JPyLong::check(UNWRAP(ref));
}
HostRef* PythonHostEnvironment::newLong(jlong v)
{
TRACE_IN("PythonHostEnvironment::newLong");
return new HostRef(JPyLong::fromLongLong(v), false);
TRACE_OUT;
}
jlong PythonHostEnvironment::longAsLong(HostRef* ref)
{
return JPyLong::asLongLong(UNWRAP(ref));
}
bool PythonHostEnvironment::isFloat(HostRef* ref)
{
return JPyFloat::check(UNWRAP(ref));
}
HostRef* PythonHostEnvironment::newFloat(jdouble v)
{
return new HostRef(JPyFloat::fromDouble(v), false);
}
jdouble PythonHostEnvironment::floatAsDouble(HostRef* ref)
{
return JPyFloat::asDouble(UNWRAP(ref));
}
bool PythonHostEnvironment::isMethod(HostRef* ref)
{
return IS_REF(ref, "JPMethod");
}
HostRef* PythonHostEnvironment::newMethod(JPMethod* m)
{
return WRAP(m, "JPMethod");
}
JPMethod* PythonHostEnvironment::asMethod(HostRef* ref)
{
return (JPMethod*)JPyCObject::asVoidPtr(UNWRAP(ref));
}
bool PythonHostEnvironment::isObject(HostRef* ref)
{
PyObject* obj = UNWRAP(ref);
if (JPyObject::isInstance(obj, m_JavaLangObject))
{
return true;
}
return false;
}
JPObject* PythonHostEnvironment::asObject(HostRef* m)
{
PyObject* obj = (PyObject*)m->data();
if (JPyCObject::check(obj))
{
return (JPObject*)JPyCObject::asVoidPtr(obj);
}
PyObject* javaObject = JPyObject::getAttrString(obj, "__javaobject__");
JPObject* res = (JPObject*)JPyCObject::asVoidPtr(javaObject);
Py_DECREF(javaObject);
return res;
}
HostRef* PythonHostEnvironment::newObject(JPObject* obj)
{
TRACE_IN("PythonHostEnvironment::newObject");
TRACE2("classname", obj->getClass()->getName().getSimpleName());
JPClass* jc = obj->getClass();
JPTypeName name = jc->getName();
PyObject* pyClass = getJavaShadowClass(jc);
PyObject* args = JPySequence::newTuple(2);
PyObject* arg2 = JPySequence::newTuple(1);
JPySequence::setItem(arg2, 0, args);
Py_DECREF(args);
PyObject* joHolder = JPyCObject::fromVoidAndDesc((void*)obj, (void*)"JPObject", &deleteJPObjectDestructor);
JPySequence::setItem(args, 0, m_SpecialConstructorKey);
JPySequence::setItem(args, 1, joHolder);
Py_DECREF(joHolder);
PyObject* res = JPyObject::call(pyClass, arg2, NULL);
Py_DECREF(arg2);
return new HostRef(res, false);
TRACE_OUT;
}
bool PythonHostEnvironment::isClass(HostRef* ref)
{
PyObject* self = UNWRAP(ref);
if (! JPyType::check(self))
{
// If its not a type ... it can;t be a java type
return false;
}
return JPyType::isSubclass(self, m_JavaLangObject);
}
HostRef* PythonHostEnvironment::newClass(JPClass* m)
{
PyJPClass* co = PyJPClass::alloc(m);
PyObject* args = JPySequence::newTuple(1);
JPySequence::setItem(args, 0, (PyObject*)co);
Py_DECREF(co);
PyObject* pyClass = JPyObject::call(m_GetClassMethod, args, NULL);
return new HostRef(pyClass, false);
}
JPClass* PythonHostEnvironment::asClass(HostRef* ref)
{
PyObject* self = UNWRAP(ref);
PyObject* claz = JPyObject::getAttrString(self, "__javaclass__");
PyJPClass* res = (PyJPClass*)claz;
Py_DECREF(claz);
return res->m_Class;
}
bool PythonHostEnvironment::isArrayClass(HostRef* ref)
{
PyObject* self = UNWRAP(ref);
if (! JPyType::check(self))
{
// If its not a type ... it can;t be a java type
return false;
}
return JPyType::isSubclass(self, m_JavaArrayClass);
}
HostRef* PythonHostEnvironment::newArrayClass(JPArrayClass* m)
{
PyObject* args = JPySequence::newTuple(1);
PyObject* cname = JPyString::fromString(m->getName().getSimpleName().c_str());
JPySequence::setItem(args, 0, cname);
Py_DECREF(cname);
PyObject* pyClass = JPyObject::call(m_GetArrayClassMethod, args, NULL);
return new HostRef(pyClass, false);
}
JPArrayClass* PythonHostEnvironment::asArrayClass(HostRef* ref)
{
PyObject* self = UNWRAP(ref);
PyObject* claz = JPyObject::getAttrString(self, "__javaclass__");
JPArrayClass* res = (JPArrayClass*)JPyCObject::asVoidPtr(claz);
Py_DECREF(claz);
return res;
}
bool PythonHostEnvironment::isArray(HostRef* ref)
{
PyObject* obj = UNWRAP(ref);
if (JPyObject::isInstance(obj, m_JavaArrayClass))
{
return true;
}
return false;
}
HostRef* PythonHostEnvironment::newArray(JPArray* m)
{
JPArrayClass* jc = m->getClass();
JPTypeName name = jc->getName();
PyObject* args = JPySequence::newTuple(1);
PyObject* cname = JPyString::fromString(name.getSimpleName().c_str());
JPySequence::setItem(args, 0, cname);
Py_DECREF(cname);
PyObject* pyClass = JPyObject::call(m_GetArrayClassMethod, args, NULL);
Py_DECREF(args);
PyObject* joHolder = JPyCObject::fromVoidAndDesc((void*)m, (void*)"JPArray", &deleteJPArrayDestructor);
args = JPySequence::newTuple(2);
JPySequence::setItem(args, 0, m_SpecialConstructorKey);
JPySequence::setItem(args, 1, joHolder);
Py_DECREF(joHolder);
PyObject* res = JPyObject::call(pyClass, args, NULL);
Py_DECREF(args);
return new HostRef(res, false);
}
JPArray* PythonHostEnvironment::asArray(HostRef* ref)
{
PyObject* obj = UNWRAP(ref);
PyObject* javaObject = JPyObject::getAttrString(obj, "__javaobject__");
JPArray* res = (JPArray*)JPyCObject::asVoidPtr(javaObject);
Py_DECREF(javaObject);
return res;
}
bool PythonHostEnvironment::isWrapper(HostRef* ref)
{
return JPyObject::isInstance(UNWRAP(ref), m_WrapperClass);
}
bool PythonHostEnvironment::isProxy(HostRef* ref)
{
return JPyObject::isInstance(UNWRAP(ref), m_ProxyClass);
}
JPProxy* PythonHostEnvironment::asProxy(HostRef* ref)
{
JPCleaner cleaner;
PyObject* proxy = UNWRAP(ref);
PyObject* jproxy = JPyObject::getAttrString(proxy, "_proxy");
cleaner.add(new HostRef(jproxy, false));
JPProxy* res = (JPProxy*)JPyCObject::asVoidPtr(jproxy);
return res;
}
HostRef* PythonHostEnvironment::getCallableFrom(HostRef* ref, string& name)
{
JPCleaner cleaner;
PyObject* pname = JPyString::fromString(name.c_str());
cleaner.add(new HostRef(pname, false));
PyObject* mname = JPyString::fromString("getCallable");
cleaner.add(new HostRef(mname, false));
PyObject* call = PyObject_CallMethodObjArgs(UNWRAP(ref), mname, pname, NULL);
JPyErr::check();
return new HostRef(call, false);
}
bool PythonHostEnvironment::isString(HostRef* ref)
{
return JPyString::check(UNWRAP(ref));
}
jsize PythonHostEnvironment::getStringLength(HostRef* ref)
{
return (jsize)JPyObject::length(UNWRAP(ref));
}
string PythonHostEnvironment::stringAsString(HostRef* ref)
{
return JPyString::asString(UNWRAP(ref));
}
JCharString PythonHostEnvironment::stringAsJCharString(HostRef* ref)
{
return JPyString::asJCharString(UNWRAP(ref));
}
HostRef* PythonHostEnvironment::newStringFromUnicode(const jchar* v, unsigned int l)
{
TRACE_IN("PythonHostEnvironment::newStringFromUnicode");
return new HostRef(JPyString::fromUnicode(v, l), false);
TRACE_OUT;
}
HostRef* PythonHostEnvironment::newStringFromASCII(const char* v, unsigned int l)
{
return new HostRef(JPyString::fromString(v), false);
}
void* PythonHostEnvironment::prepareCallbackBegin()
{
PyGILState_STATE state = PyGILState_Ensure();;
return (void*)new PyGILState_STATE(state);
}
void PythonHostEnvironment::prepareCallbackFinish(void* state)
{
PyGILState_STATE* state2 = (PyGILState_STATE*)state;
PyGILState_Release(*state2);
delete state2;
}
HostRef* PythonHostEnvironment::callObject(HostRef* c, vector& args)
{
JPCleaner cleaner;
PyObject* pargs = JPySequence::newTuple((int)args.size());
cleaner.add(new HostRef(pargs, false));
for (unsigned int i = 0; i < args.size(); i++)
{
JPySequence::setItem(pargs, i, UNWRAP(args[i]));
}
PyObject* res = JPyObject::call(UNWRAP(c), pargs, NULL);
return new HostRef(res, false);
}
void PythonHostEnvironment::printError()
{
PyErr_Print();
PyErr_Clear();
}
bool PythonHostEnvironment::mapContains(HostRef* mapping, HostRef* key)
{
return JPyDict::contains(UNWRAP(mapping), UNWRAP(key));
}
HostRef* PythonHostEnvironment::getMapItem(HostRef* mapping, HostRef* key)
{
return new HostRef(JPyDict::getItem(UNWRAP(mapping), UNWRAP(key)), false);
}
bool PythonHostEnvironment::objectHasAttribute(HostRef* obj, HostRef* key)
{
return JPyObject::hasAttr(UNWRAP(obj), UNWRAP(key));
}
HostRef* PythonHostEnvironment::getObjectAttribute(HostRef* obj, HostRef* key)
{
return new HostRef(JPyObject::getAttr(UNWRAP(obj), UNWRAP(key)), false);
}
bool PythonHostEnvironment::isJavaException(HostException* ex)
{
PythonException* pe = (PythonException*)ex;
return JPyObject::isSubclass(pe->m_ExceptionClass, m_JavaExceptionClass);
}
HostRef* PythonHostEnvironment::getJavaException(HostException* ex)
{
PythonException* pe = (PythonException*)ex;
PyObject* obj = pe->getJavaException();
PyObject* javaObject = JPyObject::getAttrString(obj, "__javaobject__");
return new HostRef(javaObject, false);
}
void PythonHostEnvironment::clearError()
{
PyErr_Clear();
}
bool PythonHostEnvironment::isWrapper(PyObject* obj)
{
return JPyObject::isInstance(obj, m_WrapperClass);
}
JPTypeName PythonHostEnvironment::getWrapperTypeName(PyObject* obj)
{
PyObject* pyTName = JPyObject::getAttrString(obj, "typeName");
string tname = JPyString::asString(pyTName);
Py_DECREF(pyTName);
return JPTypeName::fromSimple(tname.c_str());
}
jvalue PythonHostEnvironment::getWrapperValue(PyObject* obj)
{
JPTypeName name = getWrapperTypeName(obj);
PyObject* value = JPyObject::getAttrString(obj, "_value");
jvalue* v = (jvalue*)JPyCObject::asVoidPtr(value);
Py_DECREF(value);
if (name.isObjectType())
{
jvalue res;
res.l = JPEnv::getJava()->NewGlobalRef(v->l);
return res;
}
return *v;
}
JPTypeName PythonHostEnvironment::getWrapperTypeName(HostRef* obj)
{
return getWrapperTypeName(UNWRAP(obj));
}
jvalue PythonHostEnvironment::getWrapperValue(HostRef* obj)
{
return getWrapperValue(UNWRAP(obj));
}
PyObject* PythonHostEnvironment::getJavaShadowClass(JPClass* jc)
{
PyJPClass* cls = PyJPClass::alloc(jc);
PyObject* args = JPySequence::newTuple(1);
JPySequence::setItem(args, 0, (PyObject*)cls);
Py_DECREF(cls);
PyObject* res = JPyObject::call(m_GetClassMethod, args, NULL);
Py_DECREF(args);
return res;
}
bool PythonHostEnvironment::isByteString(HostRef* ref)
{
PyObject* obj = UNWRAP(ref);
return JPyString::checkStrict(obj);
}
bool PythonHostEnvironment::isUnicodeString(HostRef* ref)
{
return JPyString::checkUnicode(UNWRAP(ref));
}
void PythonHostEnvironment::getRawByteString(HostRef* obj, char** outBuffer, long& outSize)
{
PyObject* objRef = UNWRAP(obj);
Py_ssize_t tempSize = 0;
JPyString::AsStringAndSize(objRef, outBuffer, &tempSize);
outSize = (long)tempSize;
}
void PythonHostEnvironment::getRawUnicodeString(HostRef* obj, jchar** outBuffer, long& outSize)
{
PyObject* objRef = UNWRAP(obj);
outSize = (long)JPyObject::length(objRef);
*outBuffer = (jchar*)JPyString::AsUnicode(objRef);
}
size_t PythonHostEnvironment::getUnicodeSize()
{
return sizeof(Py_UNICODE);
}
HostRef* PythonHostEnvironment::newStringWrapper(jstring jstr)
{
TRACE_IN("PythonHostEnvironment::newStringWrapper");
jvalue* v = new jvalue;
v->l = jstr;
PyObject* value = JPyCObject::fromVoidAndDesc((void*)v, (void*)"object jvalue", deleteObjectJValueDestructor);
PyObject* args = JPySequence::newTuple(1);
JPySequence::setItem(args, 0, Py_None);
PyObject* res = JPyObject::call(m_StringWrapperClass, args, Py_None);
Py_DECREF(args);
JPyObject::setAttrString(res, "_value", value);
Py_DECREF(value);
HostRef* resRef = new HostRef(res);
Py_DECREF(res);
return resRef;
TRACE_OUT;
}
void PythonHostEnvironment::printReferenceInfo(HostRef* obj)
{
PyObject* pobj = UNWRAP(obj);
cout << "Object info report" << endl;
cout << " obj type " << pobj->ob_type->tp_name << endl;
cout << " Ref count " << (long)pobj->ob_refcnt << endl;
}
void PythonHostEnvironment::deleteJPObjectDestructor(void* data, void* desc)
{
delete (JPObject*)data;
}
python-jpype-0.5.4.2/src/native/python/jpype_module.cpp 0000666 0001750 0001750 00000017044 11614007722 022430 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
PyObject* JPypeModule::startup(PyObject* obj, PyObject* args)
{
TRACE_IN("startup");
try {
PyObject* vmOpt;
PyObject* vmPath;
char ignoreUnrecognized = true;
JPyArg::parseTuple(args, "OO!b|", &vmPath, &PyTuple_Type, &vmOpt, &ignoreUnrecognized);
if (! (JPyString::check(vmPath)))
{
RAISE(JPypeException, "First paramter must be a string or unicode");
}
string cVmPath = JPyString::asString(vmPath);
StringVector args;
for (int i = 0; i < JPyObject::length(vmOpt); i++)
{
PyObject* obj = JPySequence::getItem(vmOpt, i);
if (JPyString::check(obj))
{
// TODO support unicode
string v = JPyString::asString(obj);
args.push_back(v);
}
else if (JPySequence::check(obj))
{
//String name = arg[0];
//Callable value = arg[1];
// TODO complete this for the hooks ....
}
else {
RAISE(JPypeException, "VM Arguments must be string or tuple");
}
}
JPEnv::loadJVM(cVmPath, ignoreUnrecognized, args);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
PyObject* JPypeModule::attach(PyObject* obj, PyObject* args)
{
TRACE_IN("attach");
try {
PyObject* vmPath;
JPyArg::parseTuple(args, "O", &vmPath);
if (! (JPyString::check(vmPath)))
{
RAISE(JPypeException, "First paramter must be a string or unicode");
}
string cVmPath = JPyString::asString(vmPath);
JPEnv::attachJVM(cVmPath);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
TRACE_OUT;
}
PyObject* JPypeModule::dumpJVMStats(PyObject* obj)
{
cerr << "JVM activity report :" << endl;
//cerr << "\tmethod calls : " << methodCalls << endl;
//cerr << "\tstatic method calls : " << staticMethodCalls << endl;
//cerr << "\tconstructor calls : " << constructorCalls << endl;
//cerr << "\tproxy callbacks : " << JProxy::getCallbackCount() << endl;
//cerr << "\tfield gets : " << fieldGets << endl;
//cerr << "\tfield sets : " << fieldSets << endl;
cerr << "\tclasses loaded : " << JPTypeManager::getLoadedClasses() << endl;
Py_INCREF(Py_None);
return Py_None;
}
PyObject* JPypeModule::shutdown(PyObject* obj)
{
TRACE_IN("shutdown");
try {
dumpJVMStats(obj);
JPEnv::getJava()->checkInitialized();
JPTypeManager::flushCache();
if (JPEnv::getJava()->DestroyJavaVM() )
{
RAISE(JPypeException, "Unable to destroy JVM");
}
JPEnv::getJava()->shutdown();
cerr << "JVM has been shutdown" << endl;
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
TRACE_OUT;
}
PyObject* JPypeModule::synchronized(PyObject* obj, PyObject* args)
{
JPCleaner cleaner;
TRACE_IN("synchronized");
try {
PyObject* o;
JPyArg::parseTuple(args, "O!", &PyCObject_Type, &o);
string desc = (char*)JPyCObject::getDesc(o);
jobject obj;
if (desc == "JPObject")
{
JPObject* jpo = (JPObject*)JPyCObject::asVoidPtr(o);
obj = jpo->getObject();
cleaner.addLocal(obj);
}
else if (desc == "JPClass")
{
JPClass* jpo = (JPClass*)JPyCObject::asVoidPtr(o);
obj = jpo->getClass();
cleaner.addLocal(obj);
}
else if (desc == "JPArray")
{
JPArray* jpo = (JPArray*)JPyCObject::asVoidPtr(o);
obj = jpo->getObject();
cleaner.addLocal(obj);
}
else if (desc == "JPArrayClass")
{
JPArrayClass* jpo = (JPArrayClass*)JPyCObject::asVoidPtr(o);
obj = jpo->getClass();
cleaner.addLocal(obj);
}
else if (hostEnv->isWrapper(o) && hostEnv->getWrapperTypeName(o).isObjectType())
{
obj = hostEnv->getWrapperValue(o).l;
cleaner.addLocal(obj);
}
// TODO proxy
else
{
RAISE(JPypeException, "method only accepts object values.");
}
PyJPMonitor* c = PyJPMonitor::alloc(new JPMonitor(obj));
return (PyObject*)c;
}
PY_STANDARD_CATCH;
PyErr_Clear();
Py_INCREF(Py_None);
return Py_None;
TRACE_OUT;
}
PyObject* JPypeModule::isStarted(PyObject* obj)
{
if (JPEnv::isInitialized())
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PyObject* JPypeModule::attachThread(PyObject* obj)
{
try {
JPEnv::attachCurrentThread();
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::detachThread(PyObject* obj)
{
try {
JPEnv::getJava()->DetachCurrentThread();
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::isThreadAttached(PyObject* obj)
{
try {
if (JPEnv::isThreadAttached())
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::raiseJava(PyObject* , PyObject* args)
{
try
{
//PyObject* arg;
//JPyArg::parseTuple(args, "O", &arg);
//JPObject* obj;
//JPCleaner cleaner;
//
//if (JPyCObject::check(arg) && string((char*)JPyCObject::getDesc(arg)) == "JPObject")
//{
// obj = (JPObject*)JPyCObject::asVoidPtr(arg);
//}
//else
//{
// JPyErr::setString(PyExc_TypeError, "You can only throw a subclass of java.lang.Throwable");
// return NULL;
//}
//
//// check if claz is an instance of Throwable
//JPClass* claz = obj->getClass();
//jclass jc = claz->getClass();
//cleaner.add(jc);
//if (! JPJni::isThrowable(jc))
//{
// JPyErr::setString(PyExc_TypeError, "You can only throw a subclass of java.lang.Throwable");
// return NULL;
//}
//
//jobject jobj = obj->getObject();
//cleaner.add(jobj);
//JPEnv::getJava()->Throw((jthrowable)jobj);
//PyJavaException::errorOccurred();
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::attachThreadAsDaemon(PyObject* obj)
{
try {
JPEnv::attachCurrentThreadAsDaemon();
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::startReferenceQueue(PyObject* obj, PyObject* args)
{
try {
int i;
JPyArg::parseTuple(args, "i", &i);
JPJni::startJPypeReferenceQueue(i == 1);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::stopReferenceQueue(PyObject* obj)
{
try {
JPJni::stopJPypeReferenceQueue();
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* JPypeModule::setConvertStringObjects(PyObject* obj, PyObject* args)
{
try {
PyObject* flag;
JPyArg::parseTuple(args, "O", &flag);
if (JPyBoolean::isTrue(flag))
{
JPEnv::getJava()->setConvertStringObjects(true);
}
else
{
JPEnv::getJava()->setConvertStringObjects(false);
}
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH;
return NULL;
}
python-jpype-0.5.4.2/src/native/python/jpype_python.cpp 0000666 0001750 0001750 00000017226 11614007722 022466 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
PythonHostEnvironment* hostEnv;
PyObject* JPypeJavaWrapper::setWrapperClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setWrapperClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaWrapper::setStringWrapperClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setStringWrapperClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaProxy::setProxyClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setProxyClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* convertToJValue(PyObject* self, PyObject* arg)
{
try {
char* tname;
PyObject* value;
JPyArg::parseTuple(arg, "sO", &tname, &value);
JPTypeName name = JPTypeName::fromSimple(tname);
JPType* type = JPTypeManager::getType(name);
HostRef ref(value);
jvalue v = type->convertToJava(&ref);
jvalue* pv = new jvalue();
*pv = v;
PyObject* res;
if (type->isObjectType())
{
res = JPyCObject::fromVoidAndDesc((void*)pv, (void*)"object jvalue", PythonHostEnvironment::deleteObjectJValueDestructor);
}
else
{
res = JPyCObject::fromVoidAndDesc((void*)pv, (void*)"jvalue", PythonHostEnvironment::deleteJValueDestructor);
}
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaProxy::createProxy(PyObject*, PyObject* arg)
{
try {
JPCleaner cleaner;
PyObject* self;
PyObject* intf;
JPyArg::parseTuple(arg, "OO", &self, &intf);
std::vector interfaces;
Py_ssize_t len = JPyObject::length(intf);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* subObj = JPySequence::getItem(intf, i);
cleaner.add(new HostRef(subObj, false));
PyObject* claz = JPyObject::getAttrString(subObj, "__javaclass__");
PyJPClass* c = (PyJPClass*)claz;
jclass jc = c->m_Class->getClass();
cleaner.addLocal(jc);
interfaces.push_back(jc);
}
HostRef ref = HostRef(self);
JPProxy* proxy = new JPProxy(&ref, interfaces);
PyObject* res = JPyCObject::fromVoidAndDesc(proxy, (void*)"jproxy", PythonHostEnvironment::deleteJPProxyDestructor);
return res;
}
PY_STANDARD_CATCH
return NULL;
}
static PyObject* setJavaExceptionClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setJavaExceptionClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
static PyMethodDef jpype_methods[] =
{
{"isStarted", (PyCFunction)&JPypeModule::isStarted, METH_NOARGS, ""},
{"startup", &JPypeModule::startup, METH_VARARGS, ""},
{"attach", &JPypeModule::attach, METH_VARARGS, ""},
{"shutdown", (PyCFunction)&JPypeModule::shutdown, METH_NOARGS, ""},
{"findClass", &JPypeJavaClass::findClass, METH_VARARGS, ""},
{"synchronized", &JPypeModule::synchronized, METH_VARARGS, ""},
{"isThreadAttachedToJVM", (PyCFunction)&JPypeModule::isThreadAttached, METH_NOARGS, ""},
{"attachThreadToJVM", (PyCFunction)&JPypeModule::attachThread, METH_NOARGS, ""},
{"detachThreadFromJVM", (PyCFunction)&JPypeModule::detachThread, METH_NOARGS, ""},
{"dumpJVMStats", (PyCFunction)&JPypeModule::dumpJVMStats, METH_NOARGS, ""},
{"attachThreadAsDaemon", (PyCFunction)&JPypeModule::attachThreadAsDaemon, METH_NOARGS, ""},
{"startReferenceQueue", &JPypeModule::startReferenceQueue, METH_VARARGS, ""},
{"stopReferenceQueue", (PyCFunction)&JPypeModule::stopReferenceQueue, METH_NOARGS, ""},
{"setJavaLangObjectClass", &JPypeJavaClass::setJavaLangObjectClass, METH_VARARGS, ""},
{"setGetClassMethod", &JPypeJavaClass::setGetClassMethod, METH_VARARGS, ""},
{"setSpecialConstructorKey", &JPypeJavaClass::setSpecialConstructorKey, METH_VARARGS, ""},
{"setJavaArrayClass", &JPypeJavaArray::setJavaArrayClass, METH_VARARGS, ""},
{"setGetJavaArrayClassMethod", &JPypeJavaArray::setGetJavaArrayClassMethod, METH_VARARGS, ""},
{"setWrapperClass", &JPypeJavaWrapper::setWrapperClass, METH_VARARGS, ""},
{"setProxyClass", &JPypeJavaProxy::setProxyClass, METH_VARARGS, ""},
{"createProxy", &JPypeJavaProxy::createProxy, METH_VARARGS, ""},
{"setStringWrapperClass", &JPypeJavaWrapper::setStringWrapperClass, METH_VARARGS, ""},
{"convertToJValue", &convertToJValue, METH_VARARGS, ""},
{"findArrayClass", &JPypeJavaArray::findArrayClass, METH_VARARGS, ""},
{"getArrayLength", &JPypeJavaArray::getArrayLength, METH_VARARGS, ""},
{"getArrayItem", &JPypeJavaArray::getArrayItem, METH_VARARGS, ""},
{"setArrayItem", &JPypeJavaArray::setArrayItem, METH_VARARGS, ""},
{"getArraySlice", &JPypeJavaArray::getArraySlice, METH_VARARGS, ""},
{"setArraySlice", &JPypeJavaArray::setArraySlice, METH_VARARGS, ""},
{"setArrayValues", &JPypeJavaArray::setArrayValues, METH_VARARGS, ""},
{"newArray", &JPypeJavaArray::newArray, METH_VARARGS, ""},
{"setJavaExceptionClass", &setJavaExceptionClass, METH_VARARGS, ""},
{"convertToDirectBuffer", &JPypeJavaNio::convertToDirectBuffer, METH_VARARGS, ""},
{"setConvertStringObjects", &JPypeModule::setConvertStringObjects, METH_VARARGS, ""},
// sentinel
{NULL}
};
PyMODINIT_FUNC init_jpype()
{
Py_Initialize();
PyEval_InitThreads();
PyObject* module = Py_InitModule("_jpype", jpype_methods);
Py_INCREF(module);
hostEnv = new PythonHostEnvironment();
JPEnv::init(hostEnv);
PyJPMonitor::initType(module);
PyJPMethod::initType(module);
PyJPBoundMethod::initType(module);
PyJPClass::initType(module);
PyJPField::initType(module);
}
PyObject* detachRef(HostRef* ref)
{
PyObject* data = (PyObject*)ref->data();
Py_XINCREF(data);
ref->release();
return data;
}
void JPypeJavaException::errorOccurred()
{
TRACE_IN("PyJavaException::errorOccurred");
JPCleaner cleaner;
jthrowable th = JPEnv::getJava()->ExceptionOccurred();
cleaner.addLocal(th);
JPEnv::getJava()->ExceptionClear();
jclass ec = JPJni::getClass(th);
JPTypeName tn = JPJni::getName(ec);
JPClass* jpclass = JPTypeManager::findClass(tn);
cleaner.addLocal(ec);
PyObject* jexclass = hostEnv->getJavaShadowClass(jpclass);
HostRef* pyth = hostEnv->newObject(new JPObject(tn, th));
cleaner.add(pyth);
PyObject* args = JPySequence::newTuple(2);
PyObject* arg2 = JPySequence::newTuple(1);
JPySequence::setItem(arg2, 0, args);
Py_DECREF(args);
JPySequence::setItem(args, 0, hostEnv->m_SpecialConstructorKey);
JPySequence::setItem(args, 1, (PyObject*)pyth->data());
PyObject* pyexclass = JPyObject::getAttrString(jexclass, "PYEXC");
Py_DECREF(jexclass);
JPyErr::setObject(pyexclass, arg2);
Py_DECREF(arg2);
Py_DECREF(pyexclass);
TRACE_OUT;
}
python-jpype-0.5.4.2/src/native/python/include/ 0000775 0001750 0001750 00000000000 11620747357 020657 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/python/include/py_monitor.h 0000666 0001750 0001750 00000002170 11614007722 023215 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _PYMONITOR_H_
#define _PYMONITOR_H_
#include "object.h"
struct PyJPMonitor
{
PyObject_HEAD
// Python-visible methods
static void initType(PyObject* module);
static PyJPMonitor* alloc(JPMonitor*);
static void __dealloc__(PyObject* o);
static PyObject* __str__(PyObject* o);
JPMonitor* state;
};
#endif // _PYMONITOR_H_
python-jpype-0.5.4.2/src/native/python/include/jp_runloopstopper.h 0000666 0001750 0001750 00000000603 11614007722 024621 0 ustar takaki takaki #import
@interface JPRunLoopStopper : NSObject
{
BOOL shouldStop;
}
+ currentRunLoopStopper;
- init;
- (BOOL) shouldRun;
+ (void) addRunLoopStopper:(JPRunLoopStopper *) runLoopStopper
toRunLoop:(NSRunLoop *) runLoop;
+ (void) removeRunLoopStopperFromRunLoop:(NSRunLoop *) runLoop;
- (void) stop;
- (void) performStop:(id) sender;
@end
python-jpype-0.5.4.2/src/native/python/include/py_class.h 0000666 0001750 0001750 00000004401 11614007722 022632 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _PYCLASS_H_
#define _PYCLASS_H_
struct PyJPClass
{
//AT's comments on porting:
// 1) Some Unix compilers do not tolerate the semicolumn after PyObject_HEAD
//PyObject_HEAD;
PyObject_HEAD
// Python-visible methods
static void initType(PyObject* module);
static PyJPClass* alloc(JPClass* cls);
static bool check(PyObject* o);
static void __dealloc__(PyObject* o);
static PyObject* getName(PyObject* self, PyObject* arg);
static PyObject* getBaseClass(PyObject* self, PyObject* arg);
static PyObject* getBaseInterfaces(PyObject* self, PyObject* arg);
static PyObject* getClassMethods(PyObject* self, PyObject* arg);
static PyObject* getClassFields(PyObject* self, PyObject* arg);
static PyObject* newClassInstance(PyObject* self, PyObject* arg);
static PyObject* isInterface(PyObject* self, PyObject* arg);
static PyObject* isPrimitive(PyObject* self, PyObject* arg);
static PyObject* isSubclass(PyObject* self, PyObject* arg);
static PyObject* isException(PyObject* self, PyObject* arg);
static PyObject* isArray(PyObject* self, PyObject* arg);
static PyObject* getConstructors(PyObject* self);
static PyObject* getDeclaredConstructors(PyObject* self);
static PyObject* getDeclaredFields(PyObject* self);
static PyObject* getDeclaredMethods(PyObject* self);
static PyObject* getFields(PyObject* self);
static PyObject* getMethods(PyObject* self);
static PyObject* getModifiers(PyObject* self);
JPClass* m_Class;
};
#endif // _PYCLASS_H_
python-jpype-0.5.4.2/src/native/python/include/pythonenv.h 0000666 0001750 0001750 00000016416 11614007722 023060 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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.
*****************************************************************************/
#ifndef _PYTHON_ENV_H_
#define _PYTHON_ENV_H_
#define PY_CHECK(op) op; { \
PyObject* __ex = PyErr_Occurred(); \
if (__ex) { \
throw new PythonException(); \
}\
};
/**
* Exception wrapper for python-generated exceptions
*/
class PythonException : public HostException
{
public :
PythonException();
PythonException(PythonException& ex);
virtual ~PythonException();
bool isJavaException();
PyObject* getJavaException();
public :
PyObject* m_ExceptionClass;
PyObject* m_ExceptionValue;
};
/**
* JPythonEnvHelper
*/
class JPythonEnvHelper
{
};
/**
* JPyErr
*/
class JPyErr : public JPythonEnvHelper
{
public :
static void setString(PyObject*exClass, const char* str);
static void setObject(PyObject*exClass, PyObject* obj);
static void check()
{
PY_CHECK(;);
}
};
/**
* JPyArg
*/
class JPyArg : public JPythonEnvHelper
{
public :
template
static void parseTuple(PyObject* arg, char* pattern, T1 a1)
{
PY_CHECK( PyArg_ParseTuple(arg, pattern, a1) );
}
template
static void parseTuple(PyObject* arg, char* pattern, T1 a1, T2 a2)
{
PY_CHECK( PyArg_ParseTuple(arg, pattern, a1, a2) );
}
template
static void parseTuple(PyObject* arg, char* pattern, T1 a1, T2 a2, T3 a3)
{
PY_CHECK( PyArg_ParseTuple(arg, pattern, a1, a2, a3) );
}
template
static void parseTuple(PyObject* arg, char* pattern, T1 a1, T2 a2, T3 a3, T4 a4)
{
PY_CHECK( PyArg_ParseTuple(arg, pattern, a1, a2, a3, a4)) ;
}
template
static void parseTuple(PyObject* arg, char* pattern, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
PY_CHECK( PyArg_ParseTuple(arg, pattern, a1, a2, a3, a4, a5)) ;
}
private :
static void check_exception();
};
/**
* JPyString
*/
class JPyString : public JPythonEnvHelper
{
public :
static bool check(PyObject* obj);
static bool checkStrict(PyObject*);
static bool checkUnicode(PyObject*);
static string asString(PyObject* obj);
static JCharString asJCharString(PyObject* obj);
static Py_ssize_t AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *);
static Py_UNICODE* AsUnicode(PyObject *obj);
static PyObject* fromUnicode(const jchar*, int);
static PyObject* fromString(const char*);
};
/**
* JPyTuple
*/
class JPySequence : public JPythonEnvHelper
{
public :
static bool check(PyObject* obj);
static PyObject* newTuple(Py_ssize_t ndx);
static PyObject* newList(Py_ssize_t ndx);
static PyObject* getItem(PyObject* tuple, Py_ssize_t ndx);
static void setItem(PyObject* tuple, Py_ssize_t ndx, PyObject* val);
};
/**
* JPyObject
*/
class JPyObject : public JPythonEnvHelper
{
public :
static Py_ssize_t length(PyObject* obj);
static bool hasAttr(PyObject*, PyObject*);
static PyObject* getAttr(PyObject*, PyObject*);
static PyObject* call(PyObject*, PyObject*, PyObject*);
static PyObject* getAttrString(PyObject*, const char*);
static void setAttrString(PyObject*, const char*, PyObject *);
static bool isInstance(PyObject* obj, PyObject* t);
static bool isSubclass(PyObject* obj, PyObject* t);
};
class JPyInt : public JPythonEnvHelper
{
public :
static PyObject* fromLong(long l);
static bool check(PyObject*);
static long asLong(PyObject*);
};
class JPyLong : public JPythonEnvHelper
{
public :
static PyObject* fromLongLong(PY_LONG_LONG l);
static bool check(PyObject*);
static PY_LONG_LONG asLongLong(PyObject*);
};
class JPyBoolean : public JPythonEnvHelper
{
public :
static bool isTrue(PyObject* o)
{
return o == Py_True;
}
static bool isFalse(PyObject* o)
{
return o == Py_False;
}
static PyObject* getTrue();
static PyObject* getFalse();
};
class JPyFloat : public JPythonEnvHelper
{
public :
static PyObject* fromDouble(double l);
static bool check(PyObject*);
static double asDouble(PyObject*);
};
class JPyDict : public JPythonEnvHelper
{
public :
static bool check(PyObject* obj);
static bool contains(PyObject*, PyObject*);
static PyObject* getItem(PyObject*, PyObject*);
static PyObject* getKeys(PyObject*);
static PyObject* copy(PyObject*);
static PyObject* newInstance();
static void setItemString(PyObject*, PyObject*, const char*);
};
class JPyCObject : public JPythonEnvHelper
{
public :
static bool check(PyObject* obj);
static PyObject* fromVoid(void* data, void (*destr)(void *));
static PyObject* fromVoidAndDesc(void* data, void* desc, void (*destr)(void *, void*));
static void* asVoidPtr(PyObject*);
static void* getDesc(PyObject*);
};
class JPyType : public JPythonEnvHelper
{
public :
static bool check(PyObject* obj);
static bool isSubclass(PyObject*, PyObject*);
};
class JPyHelper : public JPythonEnvHelper
{
public :
static void dumpSequenceRefs(PyObject* seq, const char* comment);
};
#undef PY_CHECK
#define PY_STANDARD_CATCH \
catch(JavaException* ex) \
{ \
try { \
JPypeJavaException::errorOccurred(); \
} \
catch(...) \
{ \
JPEnv::getHost()->setRuntimeException("An unknown error occured while handling a Java Exception"); \
}\
delete ex; \
}\
catch(JPypeException* ex)\
{\
try { \
JPEnv::getHost()->setRuntimeException(ex->getMsg()); \
} \
catch(...) \
{ \
JPEnv::getHost()->setRuntimeException("An unknown error occured while handling a JPype Exception"); \
}\
delete ex; \
}\
catch(PythonException* ex) \
{ \
delete ex; \
} \
catch(...) \
{\
JPEnv::getHost()->setRuntimeException("Unknown Exception"); \
} \
#define PY_LOGGING_CATCH \
catch(JavaException* ex) \
{ \
try { \
cout << "Java error occured : " << ex->message << endl; \
JPypeJavaException::errorOccurred(); \
} \
catch(...) \
{ \
JPEnv::getHost()->setRuntimeException("An unknown error occured while handling a Java Exception"); \
}\
delete ex; \
}\
catch(JPypeException* ex)\
{\
try { \
cout << "JPype error occured" << endl; \
JPEnv::getHost()->setRuntimeException(ex->getMsg()); \
} \
catch(...) \
{ \
JPEnv::getHost()->setRuntimeException("An unknown error occured while handling a JPype Exception"); \
}\
delete ex; \
}\
catch(PythonException* ex) \
{ \
cout << "Pyhton error occured" << endl; \
delete ex; \
} \
catch(...) \
{\
cout << "Unknown error occured" << endl; \
JPEnv::getHost()->setRuntimeException("Unknown Exception"); \
} \
#endif // _PYTHON_ENV_H_
python-jpype-0.5.4.2/src/native/python/include/py_hostenv.h 0000666 0001750 0001750 00000014460 11614007722 023221 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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.
*****************************************************************************/
#ifndef _PYHOSTENV_H_
#define _PYHOSTENV_H_
class PythonHostEnvironment : public HostEnvironment
{
public :
PythonHostEnvironment()
{
}
virtual ~PythonHostEnvironment()
{
}
public :
void setJavaLangObjectClass(PyObject* obj)
{
m_JavaLangObject = obj;
}
PyObject* getJavaLangObjectClass()
{
return m_JavaLangObject;
}
void setJavaArrayClass(PyObject* obj)
{
m_JavaArrayClass = obj;
}
void setWrapperClass(PyObject* obj)
{
m_WrapperClass = obj;
}
void setStringWrapperClass(PyObject* obj)
{
m_StringWrapperClass = obj;
}
void setProxyClass(PyObject* obj)
{
m_ProxyClass = obj;
}
void setGetJavaClassMethod(PyObject* obj)
{
m_GetClassMethod = obj;
Py_INCREF(obj);
}
void setGetJavaArrayClassMethod(PyObject* obj)
{
m_GetArrayClassMethod = obj;
Py_INCREF(obj);
}
void setSpecialConstructorKey(PyObject* obj)
{
m_SpecialConstructorKey = obj;
Py_INCREF(obj);
}
PyObject* getSpecialConstructorKey()
{
return m_SpecialConstructorKey;
}
void setJavaExceptionClass(PyObject* obj)
{
m_JavaExceptionClass = obj;
}
static void deleteJPObjectDestructor(void* data, void* desc);
static void deleteJPArrayDestructor(void* data, void* desc)
{
delete (JPArray*)data;
}
static void deleteObjectJValueDestructor(void* data, void* desc)
{
jvalue* pv = (jvalue*)data;
JPEnv::getJava()->DeleteGlobalRef(pv->l);
delete pv;
}
static void deleteJValueDestructor(void* data, void* desc)
{
jvalue* pv = (jvalue*)data;
delete pv;
}
static void deleteJPProxyDestructor(void* data, void* desc)
{
JPProxy* pv = (JPProxy*)data;
delete pv;
}
PyObject* getJavaShadowClass(JPClass* jc);
private :
PyObject* m_JavaLangObject;
PyObject* m_JavaArrayClass;
PyObject* m_WrapperClass;
PyObject* m_StringWrapperClass;
PyObject* m_ProxyClass;
map m_ClassMap;
PyObject* m_GetClassMethod;
PyObject* m_GetArrayClassMethod;
public :
PyObject* m_SpecialConstructorKey;
PyObject* m_JavaExceptionClass;
public :
virtual void* acquireRef(void*);
virtual void releaseRef(void*);
virtual bool isRefNull(void*);
virtual string describeRef(HostRef*);
virtual void* gotoExternal();
virtual void returnExternal(void* state);
virtual void setRuntimeException(const char* msg);
virtual void setAttributeError(const char* msg);
virtual void setTypeError(const char* msg);
virtual void raise(const char* msg);
virtual HostRef* getNone();
virtual bool isNone(HostRef*);
virtual bool isBoolean(HostRef*);
virtual jboolean booleanAsBoolean(HostRef*);
virtual HostRef* getTrue();
virtual HostRef* getFalse();
virtual bool isSequence(HostRef*);
virtual HostRef* newMutableSequence(jsize);
virtual HostRef* newImmutableSequence(jsize);
virtual jsize getSequenceLength(HostRef*);
virtual HostRef* getSequenceItem(HostRef*, jsize);
virtual void setSequenceItem(HostRef*, jsize, HostRef*);
virtual bool isInt(HostRef*);
virtual HostRef* newInt(jint);
virtual jint intAsInt(HostRef*);
virtual bool isLong(HostRef*);
virtual HostRef* newLong(jlong);
virtual jlong longAsLong(HostRef*);
virtual bool isFloat(HostRef*);
virtual HostRef* newFloat(jdouble);
virtual jdouble floatAsDouble(HostRef*);
virtual bool isMethod(HostRef*);
virtual HostRef* newMethod(JPMethod*);
virtual JPMethod* asMethod(HostRef*);
virtual bool isObject(HostRef*);
virtual HostRef* newObject(JPObject*);
virtual JPObject* asObject(HostRef*);
virtual bool isClass(HostRef*);
virtual HostRef* newClass(JPClass*);
virtual JPClass* asClass(HostRef*);
virtual bool isArrayClass(HostRef*);
virtual HostRef* newArrayClass(JPArrayClass*);
virtual JPArrayClass* asArrayClass(HostRef*);
virtual bool isArray(HostRef*);
virtual HostRef* newArray(JPArray*);
virtual JPArray* asArray(HostRef*);
virtual bool isProxy(HostRef*);
virtual JPProxy* asProxy(HostRef*);
virtual HostRef* getCallableFrom(HostRef*, string&);
virtual bool isWrapper(PyObject*) ;
virtual JPTypeName getWrapperTypeName(PyObject*);
virtual jvalue getWrapperValue(PyObject*);
virtual bool isWrapper(HostRef*);
virtual JPTypeName getWrapperTypeName(HostRef*);
virtual jvalue getWrapperValue(HostRef*);
virtual HostRef* newStringWrapper(jstring);
virtual bool isString(HostRef*);
virtual jsize getStringLength(HostRef*);
virtual string stringAsString(HostRef*);
virtual JCharString stringAsJCharString(HostRef*);
virtual HostRef* newStringFromUnicode(const jchar*, unsigned int);
virtual HostRef* newStringFromASCII(const char*, unsigned int);
virtual bool isByteString(HostRef*);
virtual bool isUnicodeString(HostRef* ref);
virtual void getRawByteString(HostRef*, char**, long&);
virtual void getRawUnicodeString(HostRef*, jchar**, long&);
virtual size_t getUnicodeSize();
virtual void* prepareCallbackBegin();
virtual void prepareCallbackFinish(void* state);
virtual HostRef* callObject(HostRef* callable, vector& args);
virtual void printError();
virtual bool mapContains(HostRef* map, HostRef* key);
virtual HostRef* getMapItem(HostRef* map, HostRef* key);
virtual bool objectHasAttribute(HostRef* obj, HostRef* key);
virtual HostRef* getObjectAttribute(HostRef* obj, HostRef* key);
virtual bool isJavaException(HostException*);
virtual HostRef* getJavaException(HostException*);
virtual void clearError();
virtual void printReferenceInfo(HostRef* obj);
};
#endif // _PYHOSTENV_H_
python-jpype-0.5.4.2/src/native/python/include/py_method.h 0000666 0001750 0001750 00000003652 11614007722 023014 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _PYMETHOD_H_
#define _PYMETHOD_H_
struct PyJPMethod
{
PyObject_HEAD
// Python-visible methods
static void initType(PyObject* module);
static PyJPMethod* alloc(JPMethod* mth);
static void __dealloc__(PyObject* o);
static PyObject* __str__(PyObject* o);
static PyObject* __call__(PyObject* self, PyObject* args, PyObject* kwargs);
static PyObject* isBeanMutator(PyObject* self, PyObject* arg);
static PyObject* isBeanAccessor(PyObject* self, PyObject* arg);
static PyObject* getName(PyObject* self, PyObject* arg);
static PyObject* matchReport(PyObject* self, PyObject* arg);
JPMethod* m_Method;
};
struct PyJPBoundMethod
{
PyObject_HEAD
// Python-visible methods
static void initType(PyObject* module);
static int __init__(PyObject* self, PyObject* args, PyObject* kwargs);
static void __dealloc__(PyObject* o);
static PyObject* __str__(PyObject* o);
static PyObject* __call__(PyObject* self, PyObject* args, PyObject* kwargs);
static PyObject* matchReport(PyObject* self, PyObject* arg);
PyObject* m_Instance;
PyJPMethod* m_Method;
};
#endif // _PYMETHOD_H_
python-jpype-0.5.4.2/src/native/python/include/jpype_python.h 0000666 0001750 0001750 00000007542 11614007722 023556 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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.
*****************************************************************************/
#ifndef _JPYPE_PYTHON_H_
#define _JPYPE_PYTHON_H_
// This file defines the _jpype module's interface and initializes it
#include
#include
// TODO figure a better way to do this .. Python dependencies should not be in common code
#include
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
#include "pythonenv.h"
class JPypeModule
{
public :
static PyObject* startup(PyObject* obj, PyObject* args);
static PyObject* attach(PyObject* obj, PyObject* args);
static PyObject* dumpJVMStats(PyObject* obj);
static PyObject* shutdown(PyObject* obj);
static PyObject* synchronized(PyObject* obj, PyObject* args);
static PyObject* isStarted(PyObject* obj);
static PyObject* attachThread(PyObject* obj);
static PyObject* detachThread(PyObject* obj);
static PyObject* isThreadAttached(PyObject* obj);
static PyObject* getJException(PyObject* obj, PyObject* args);
static PyObject* raiseJava(PyObject* obj, PyObject* args);
static PyObject* attachThreadAsDaemon(PyObject* obj);
static PyObject* startReferenceQueue(PyObject* obj, PyObject* args);
static PyObject* stopReferenceQueue(PyObject* obj);
static PyObject* setConvertStringObjects(PyObject* obj, PyObject* args);
};
class JPypeJavaClass
{
public:
static PyObject* findClass(PyObject* obj, PyObject* args);
static PyObject* setJavaLangObjectClass(PyObject* self, PyObject* arg);
static PyObject* setGetClassMethod(PyObject* self, PyObject* arg);
static PyObject* setSpecialConstructorKey(PyObject* self, PyObject* arg);
};
class JPypeJavaProxy
{
public:
static PyObject* setProxyClass(PyObject* self, PyObject* arg);
static PyObject* createProxy(PyObject*, PyObject* arg);
};
class JPypeJavaArray
{
public:
static PyObject* findArrayClass(PyObject* obj, PyObject* args);
static PyObject* getArrayLength(PyObject* self, PyObject* arg);
static PyObject* getArrayItem(PyObject* self, PyObject* arg);
static PyObject* getArraySlice(PyObject* self, PyObject* arg);
static PyObject* setArraySlice(PyObject* self, PyObject* arg);
static PyObject* newArray(PyObject* self, PyObject* arg);
static PyObject* setArrayItem(PyObject* self, PyObject* arg);
static PyObject* setGetJavaArrayClassMethod(PyObject* self, PyObject* arg);
static PyObject* setJavaArrayClass(PyObject* self, PyObject* arg);
static PyObject* setArrayValues(PyObject* self, PyObject* arg);
};
class JPypeJavaNio
{
public:
static PyObject* convertToDirectBuffer(PyObject* self, PyObject* arg);
};
class JPypeJavaWrapper
{
public:
static PyObject* setWrapperClass(PyObject* self, PyObject* arg);
static PyObject* setStringWrapperClass(PyObject* self, PyObject* arg);
};
class JPypeJavaException
{
public:
static void errorOccurred();
};
#include "py_monitor.h"
#include "py_method.h"
#include "py_class.h"
#include "py_field.h"
#include "py_hostenv.h"
extern PythonHostEnvironment* hostEnv;
// Utility method
PyObject* detachRef(HostRef* ref);
#endif // _JPYPE_PYTHON_H_
python-jpype-0.5.4.2/src/native/python/include/jp_cocoatools.h 0000666 0001750 0001750 00000000041 11614007722 023647 0 ustar takaki takaki
void JPRunConsoleEventLoop();
python-jpype-0.5.4.2/src/native/python/include/py_field.h 0000666 0001750 0001750 00000003001 11614007722 022603 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _PYFIELD_H_
#define _PYFIELD_H_
struct PyJPField
{
PyObject_HEAD
// Python-visible methods
static void initType(PyObject* module);
static PyJPField* alloc(JPField* mth);
static void __dealloc__(PyObject* o);
static PyObject* getName(PyObject* self, PyObject* arg);
static PyObject* getStaticAttribute(PyObject* self, PyObject* arg);
static PyObject* setStaticAttribute(PyObject* self, PyObject* arg);
static PyObject* setInstanceAttribute(PyObject* self, PyObject* arg);
static PyObject* getInstanceAttribute(PyObject* self, PyObject* arg);
static PyObject* isStatic(PyObject* self, PyObject* arg);
static PyObject* isFinal(PyObject* self, PyObject* arg);
JPField* m_Field;
};
#endif // _PYFIELD_H_
python-jpype-0.5.4.2/src/native/python/py_class.cpp 0000666 0001750 0001750 00000034053 11614007722 021550 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
static PyMethodDef classMethods[] = {
{"getName", &PyJPClass::getName, METH_VARARGS, ""},
{"getBaseClass", &PyJPClass::getBaseClass, METH_VARARGS, ""},
{"getClassFields", &PyJPClass::getClassFields, METH_VARARGS, ""},
{"getClassMethods", &PyJPClass::getClassMethods, METH_VARARGS, ""},
{"newClassInstance", &PyJPClass::newClassInstance, METH_VARARGS, ""},
{"isInterface", &PyJPClass::isInterface, METH_VARARGS, ""},
{"getBaseInterfaces", &PyJPClass::getBaseInterfaces, METH_VARARGS, ""},
{"isSubclass", &PyJPClass::isSubclass, METH_VARARGS, ""},
{"isPrimitive", &PyJPClass::isPrimitive, METH_VARARGS, ""},
{"isException", &PyJPClass::isException, METH_VARARGS, ""},
{"isArray", &PyJPClass::isArray, METH_VARARGS, ""},
{"getSuperclass",&PyJPClass::getBaseClass, METH_NOARGS, ""},
{"getConstructors", (PyCFunction)&PyJPClass::getConstructors, METH_NOARGS, ""},
{"getDeclaredConstructors", (PyCFunction)&PyJPClass::getDeclaredConstructors, METH_NOARGS, ""},
{"getDeclaredFields", (PyCFunction)&PyJPClass::getDeclaredFields, METH_NOARGS, ""},
{"getDeclaredMethods", (PyCFunction)&PyJPClass::getDeclaredMethods, METH_NOARGS, ""},
{"getFields", (PyCFunction)&PyJPClass::getFields, METH_NOARGS, ""},
{"getMethods", (PyCFunction)&PyJPClass::getMethods, METH_NOARGS, ""},
{"getModifiers", (PyCFunction)&PyJPClass::getModifiers, METH_NOARGS, ""},
{NULL},
};
static PyTypeObject classClassType =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"JavaClass", /*tp_name*/
sizeof(PyJPClass), /*tp_basicsize*/
0, /*tp_itemsize*/
PyJPClass::__dealloc__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
"Java Class", /*tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
classMethods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew /* tp_new */
};
// Static methods
void PyJPClass::initType(PyObject* module)
{
PyType_Ready(&classClassType);
PyModule_AddObject(module, "_JavaClass", (PyObject*)&classClassType);
}
PyJPClass* PyJPClass::alloc(JPClass* cls)
{
PyJPClass* res = PyObject_New(PyJPClass, &classClassType);
res->m_Class = cls;
return res;
}
void PyJPClass::__dealloc__(PyObject* o)
{
TRACE_IN("PyJPClass::__dealloc__");
PyJPClass* self = (PyJPClass*)o;
self->ob_type->tp_free(o);
TRACE_OUT;
}
PyObject* PyJPClass::getName(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
JPTypeName name = self->m_Class->getName();
PyObject* res = JPyString::fromString(name.getSimpleName().c_str());
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::getBaseClass(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
JPClass* base = self->m_Class->getSuperClass();
if (base == NULL)
{
Py_INCREF(Py_None);
return Py_None;
}
PyObject* res = (PyObject*)PyJPClass::alloc(base);
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::getBaseInterfaces(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
vector baseItf = self->m_Class->getInterfaces();
PyObject* result = JPySequence::newTuple((int)baseItf.size());
for (unsigned int i = 0; i < baseItf.size(); i++)
{
JPClass* base = baseItf[i];
PyObject* obj = (PyObject*)PyJPClass::alloc(base);
JPySequence::setItem(result, i, obj);
}
return result;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::getClassFields(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
map staticFields = self->m_Class->getStaticFields();
map instFields = self->m_Class->getInstanceFields();
PyObject* res = JPySequence::newTuple((int)(staticFields.size()+instFields.size()));
int i = 0;
for (map::iterator curStatic = staticFields.begin(); curStatic != staticFields.end(); curStatic ++)
{
PyObject* f = (PyObject*)PyJPField::alloc(curStatic->second);
JPySequence::setItem(res, i, f);
i++;
Py_DECREF(f);
}
for (map::iterator curInst = instFields.begin(); curInst != instFields.end(); curInst ++)
{
PyObject* f = (PyObject*)PyJPField::alloc(curInst->second);
JPySequence::setItem(res, i, f);
i++;
Py_DECREF(f);
}
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::getClassMethods(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
vector methods = self->m_Class->getMethods();
PyObject* res = JPySequence::newTuple((int)methods.size());
int i = 0;
for (vector::iterator curMethod = methods.begin(); curMethod != methods.end(); curMethod ++)
{
JPMethod* mth= *curMethod;
PyJPMethod* methObj = PyJPMethod::alloc(mth);
JPySequence::setItem(res, i, (PyObject*)methObj);
i++;
Py_DECREF(methObj);
}
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::newClassInstance(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
JPCleaner cleaner;
//cout << "Creating a new " << self->m_Class->getName().getSimpleName() << endl;
//JPyHelper::dumpSequenceRefs(arg, "Start");
vector args;
Py_ssize_t len = JPyObject::length(arg);
for (Py_ssize_t i = 0; i < len; i++)
{
PyObject* obj = JPySequence::getItem(arg, i);
HostRef* ref = new HostRef((void*)obj);
cleaner.add(ref);
args.push_back(ref);
Py_DECREF(obj);
}
JPObject* resObject = self->m_Class->newInstance(args);
PyObject* res = JPyCObject::fromVoidAndDesc((void*)resObject, (void*)"JPObject", &PythonHostEnvironment::deleteJPObjectDestructor);
//JPyHelper::dumpSequenceRefs(arg, "End");
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::isInterface(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
if (self->m_Class->isInterface())
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::isSubclass(PyObject* o, PyObject* arg)
{
try {
PyJPClass* self = (PyJPClass*)o;
char* other;
JPyArg::parseTuple(arg, "s", &other);
JPTypeName name = JPTypeName::fromSimple(other);
JPClass* otherClass = JPTypeManager::findClass(name);
if (self->m_Class->isSubclass(otherClass))
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* PyJPClass::isException(PyObject* o, PyObject* args)
{
try
{
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
bool res = JPJni::isThrowable(self->m_Class->getClass());
if (res)
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH;
return NULL;
}
bool PyJPClass::check(PyObject* o)
{
return o->ob_type == &classClassType;
}
PyObject* PyJPClass::getDeclaredMethods(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getDeclaredMethods(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName methodClassName = JPTypeName::fromSimple("java.lang.reflect.Method");
JPClass* methodClass = JPTypeManager::findClass(methodClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = methodClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getConstructors(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getConstructors(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName methodClassName = JPTypeName::fromSimple("java.lang.reflect.Method");
JPClass* methodClass = JPTypeManager::findClass(methodClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = methodClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getDeclaredConstructors(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getDeclaredConstructors(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName methodClassName = JPTypeName::fromSimple("java.lang.reflect.Method");
JPClass* methodClass = JPTypeManager::findClass(methodClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = methodClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getDeclaredFields(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getDeclaredFields(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName fieldClassName = JPTypeName::fromSimple("java.lang.reflect.Field");
JPClass* fieldClass = JPTypeManager::findClass(fieldClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = fieldClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getFields(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getFields(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName fieldClassName = JPTypeName::fromSimple("java.lang.reflect.Field");
JPClass* fieldClass = JPTypeManager::findClass(fieldClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = fieldClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getModifiers(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
long mod = JPJni::getClassModifiers(self->m_Class->getClass());
PyObject* res = JPyLong::fromLongLong(mod);
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::getMethods(PyObject* o)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
vector mth = JPJni::getMethods(self->m_Class->getClass());
PyObject* res = JPySequence::newTuple((int)mth.size());
JPTypeName methodClassName = JPTypeName::fromSimple("java.lang.reflect.Method");
JPClass* methodClass = JPTypeManager::findClass(methodClassName);
for (unsigned int i = 0; i < mth.size(); i++)
{
jvalue v;
v.l = mth[i];
HostRef* ref = methodClass->asHostObject(v);
cleaner.add(ref);
JPySequence::setItem(res, i, (PyObject*)ref->data());
}
return res;
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::isPrimitive(PyObject* o, PyObject* args)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
JPTypeName name = self->m_Class->getName();
if (name.isObjectType())
{
return JPyBoolean::getFalse();
}
return JPyBoolean::getTrue();
}
PY_STANDARD_CATCH;
return NULL;
}
PyObject* PyJPClass::isArray(PyObject* o, PyObject* args)
{
try {
JPCleaner cleaner;
PyJPClass* self = (PyJPClass*)o;
JPTypeName name = self->m_Class->getName();
char c = name.getNativeName()[0];
if (c == '[')
{
return JPyBoolean::getTrue();
}
return JPyBoolean::getFalse();
}
PY_STANDARD_CATCH;
return NULL;
}
python-jpype-0.5.4.2/src/native/python/py_monitor.cpp 0000666 0001750 0001750 00000006163 11614007722 022133 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
static PyMethodDef methods[] = {
{NULL},
};
static PyTypeObject monitorClassType =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"JavaMonitor", /*tp_name*/
sizeof(PyJPMonitor), /*tp_basicsize*/
0, /*tp_itemsize*/
PyJPMonitor::__dealloc__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
PyJPMonitor::__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/
"Java Monitor", /*tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew /* tp_new */
};
// Static methods
void PyJPMonitor::initType(PyObject* module)
{
PyType_Ready(&monitorClassType);
}
PyJPMonitor* PyJPMonitor::alloc(JPMonitor* o)
{
PyJPMonitor* res = PyObject_New(PyJPMonitor, &monitorClassType);
res->state = o;
return res;
}
void PyJPMonitor::__dealloc__(PyObject* o)
{
PyJPMonitor* self = (PyJPMonitor*)o;
delete self->state;
self->ob_type->tp_free(o);
}
PyObject* PyJPMonitor::__str__(PyObject* o)
{
// TODO
JPyErr::setString(PyExc_RuntimeError, "__str__ Not implemented");
return NULL;
}
python-jpype-0.5.4.2/src/native/python/jpype_javanio.cpp 0000666 0001750 0001750 00000003125 11614007722 022565 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve M�nard
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
PyObject* JPypeJavaNio::convertToDirectBuffer(PyObject* self, PyObject* args)
{
TRACE_IN("convertStringToBuffer");
// Use special method defined on the TypeConverter interface ...
PyObject* src;
JPyArg::parseTuple(args, "O", &src);
PyObject* res = NULL;
if (JPyString::checkStrict(src))
{
// converts to byte buffer ...
JPTypeName tname = JPTypeName::fromType(JPTypeName::_byte);
JPType* type = JPTypeManager::getType(tname);
HostRef srcRef(src);
TRACE1("Converting");
HostRef* ref = type->convertToDirectBuffer(&srcRef);
JPEnv::registerRef(ref, &srcRef);
TRACE1("detaching result");
res = detachRef(ref);
}
if (res != NULL)
{
return res;
}
RAISE(JPypeException, "Do not know how to convert to Direct Buffer");
return NULL;
TRACE_OUT;
}
python-jpype-0.5.4.2/src/native/python/pythonenv.cpp 0000666 0001750 0001750 00000023030 11614007722 021756 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
#define PY_CHECK(op) op; { PyObject* __ex = PyErr_Occurred(); if (__ex) { throw new PythonException(); }};
bool JPyString::check(PyObject* obj)
{
return PyString_Check(obj) || PyUnicode_Check(obj);
}
bool JPyString::checkStrict(PyObject* obj)
{
return PyString_Check(obj);
}
bool JPyString::checkUnicode(PyObject* obj)
{
return PyUnicode_Check(obj);
}
Py_UNICODE* JPyString::AsUnicode(PyObject* obj)
{
return PyUnicode_AsUnicode(obj);
}
string JPyString::asString(PyObject* obj)
{
TRACE_IN("JPyString::asString");
PY_CHECK( string res = string(PyString_AsString(obj)) );
return res;
TRACE_OUT;
}
JCharString JPyString::asJCharString(PyObject* obj)
{
PyObject* torelease = NULL;
TRACE_IN("JPyString::asJCharString");
if (PyString_Check(obj))
{
PY_CHECK( obj = PyUnicode_FromObject(obj) );
torelease = obj;
}
Py_UNICODE* val = PyUnicode_AS_UNICODE(obj);
Py_ssize_t length = JPyObject::length(obj);
JCharString res(length);
for (int i = 0; val[i] != 0; i++)
{
res[i] = (jchar)val[i];
}
if (torelease != NULL)
{
Py_DECREF(torelease);
}
return res;
TRACE_OUT;
}
PyObject* JPyString::fromUnicode(const jchar* str, int len)
{
Py_UNICODE* value = new Py_UNICODE[len+1];
value[len] = 0;
for (int i = 0; i < len; i++)
{
value[i] = (Py_UNICODE)str[i];
}
PY_CHECK( PyObject* obj = PyUnicode_FromUnicode(value, len) );
delete value;
return obj;
}
PyObject* JPyString::fromString(const char* str)
{
PY_CHECK( PyObject* obj = PyString_FromString(str) );
return obj;
}
Py_ssize_t JPyString::AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
{
PY_CHECK( Py_ssize_t res = PyString_AsStringAndSize(obj, buffer, length) );
return res;
}
PyObject* JPySequence::newTuple(Py_ssize_t sz)
{
PY_CHECK( PyObject* res = PyTuple_New(sz););
return res;
}
PyObject* JPySequence::newList(Py_ssize_t sz)
{
PY_CHECK( PyObject* res = PyList_New(sz););
return res;
}
void JPySequence::setItem(PyObject* lst, Py_ssize_t ndx, PyObject* val)
{
if (PyList_Check(lst))
{
Py_XINCREF(val);
PY_CHECK( PyList_SetItem(lst, ndx, val) );
}
else if (PyTuple_Check(lst))
{
Py_XINCREF(val);
PY_CHECK( PyTuple_SetItem(lst, ndx, val) );
}
else
{
Py_XINCREF(val);
PY_CHECK( PySequence_SetItem(lst, ndx, val) );
}
}
bool JPySequence::check(PyObject* obj)
{
if (PySequence_Check(obj) || PyList_Check(obj) || PyTuple_Check(obj))
{
return true;
}
return false;
}
PyObject* JPySequence::getItem(PyObject* tuple, Py_ssize_t ndx)
{
PY_CHECK( PyObject* res = PySequence_GetItem(tuple, ndx) );
return res;
}
Py_ssize_t JPyObject::length(PyObject* obj)
{
PY_CHECK( Py_ssize_t res = PyObject_Length(obj) );
return res;
}
bool JPyObject::hasAttr(PyObject* m, PyObject* k)
{
PY_CHECK( int res = PyObject_HasAttr(m, k) );
if (res)
return true;
return false;
}
PyObject* JPyObject::getAttr(PyObject* m, PyObject* k)
{
PY_CHECK( PyObject* res = PyObject_GetAttr(m, k) );
return res;
}
PyObject* JPyObject::getAttrString(PyObject* m, const char* k)
{
PY_CHECK( PyObject* res = PyObject_GetAttrString(m, (char*)k) );
return res;
}
void JPyObject::setAttrString(PyObject* m, const char* k, PyObject *v)
{
PY_CHECK( PyObject_SetAttrString(m, (char*)k, v ) );
}
PyObject* JPyObject::call(PyObject* c, PyObject* a, PyObject* w)
{
PY_CHECK( PyObject* res = PyObject_Call(c, a, w) );
return res;
}
bool JPyObject::isInstance(PyObject* obj, PyObject* t)
{
PY_CHECK( int res = PyObject_IsInstance(obj, t) );
if (res)
{
return true;
}
return false;
}
bool JPyObject::isSubclass(PyObject* obj, PyObject* t)
{
int res = PyObject_IsSubclass(obj, t);
if (res)
{
return true;
}
return false;
}
void JPyErr::setString(PyObject* exClass, const char* str)
{
PyErr_SetString(exClass, str);
}
void JPyErr::setObject(PyObject* exClass, PyObject* str)
{
PyErr_SetObject(exClass, str);
}
PyObject* JPyInt::fromLong(long l)
{
TRACE_IN("JPyInt::fromLong");
PY_CHECK( PyObject* res = PyInt_FromLong(l) );
return res;
TRACE_OUT;
}
bool JPyInt::check(PyObject* obj)
{
return PyInt_Check(obj);
}
long JPyInt::asLong(PyObject* obj)
{
return PyInt_AsLong(obj);
}
PyObject* JPyLong::fromLongLong(PY_LONG_LONG l)
{
TRACE_IN("JPyLong::fromLongLong");
PY_CHECK( PyObject* res = PyLong_FromLongLong(l) );
return res;
TRACE_OUT;
}
bool JPyLong::check(PyObject* obj)
{
return PyLong_Check(obj);
}
PY_LONG_LONG JPyLong::asLongLong(PyObject* obj)
{
return PyLong_AsLongLong(obj);
}
PyObject* JPyFloat::fromDouble(double l)
{
PY_CHECK( PyObject* res = PyFloat_FromDouble(l) );
return res;
}
bool JPyFloat::check(PyObject* obj)
{
return PyFloat_Check(obj);
}
double JPyFloat::asDouble(PyObject* obj)
{
return PyFloat_AsDouble(obj);
}
PyObject* JPyBoolean::getTrue()
{
return PyInt_FromLong(1);
}
PyObject* JPyBoolean::getFalse()
{
return PyInt_FromLong(0);
}
bool JPyDict::contains(PyObject* m, PyObject* k)
{
PY_CHECK( int res = PyMapping_HasKey(m, k) );
if (res)
return true;
return false;
}
PyObject* JPyDict::getItem(PyObject* m, PyObject* k)
{
PY_CHECK( PyObject* res = PyDict_GetItem(m, k) );
Py_XINCREF(res);
return res;
}
bool JPyDict::check(PyObject* obj)
{
return PyDict_Check(obj);
}
PyObject* JPyDict::getKeys(PyObject* m)
{
PY_CHECK( PyObject* res = PyDict_Keys(m) );
return res;
}
PyObject* JPyDict::copy(PyObject* m)
{
PY_CHECK( PyObject* res = PyDict_Copy(m) );
return res;
}
PyObject* JPyDict::newInstance()
{
PY_CHECK( PyObject* res = PyDict_New() );
return res;
}
void JPyDict::setItemString(PyObject* d, PyObject* o, const char* n)
{
PY_CHECK( PyDict_SetItemString(d, n, o) );
}
PythonException::PythonException()
{
TRACE_IN("PythonException::PythonException");
PyObject* traceback;
PyErr_Fetch(&m_ExceptionClass, &m_ExceptionValue, &traceback);
Py_INCREF(m_ExceptionClass);
Py_INCREF(m_ExceptionValue);
PyObject* name = JPyObject::getAttrString(m_ExceptionClass, "__name__");
string ascname = JPyString::asString(name);
TRACE1(ascname);
Py_DECREF(name);
TRACE1(m_ExceptionValue->ob_type->tp_name);
if (JPySequence::check(m_ExceptionValue))
{
}
PyErr_Restore(m_ExceptionClass, m_ExceptionValue, traceback);
TRACE_OUT;
}
PythonException::PythonException(PythonException& ex)
{
m_ExceptionClass = ex.m_ExceptionClass;
Py_INCREF(m_ExceptionClass);
m_ExceptionValue = ex.m_ExceptionValue;
Py_INCREF(m_ExceptionValue);
}
PythonException::~PythonException()
{
Py_XDECREF(m_ExceptionClass);
Py_XDECREF(m_ExceptionValue);
}
PyObject* PythonException::getJavaException()
{
PyObject* retVal = NULL;
// If the exception was caught further down ...
if (JPySequence::check(m_ExceptionValue) && JPyObject::length(m_ExceptionValue) == 1)
{
PyObject* v0 = JPySequence::getItem(m_ExceptionValue, 0);
if (JPySequence::check(v0) && JPyObject::length(v0) == 2)
{
PyObject* v00 = JPySequence::getItem(v0, 0);
PyObject* v01 = JPySequence::getItem(v0, 1);
if (v00 == hostEnv->getSpecialConstructorKey())
{
retVal = v01;
}
else
{
Py_DECREF(v01);
}
Py_DECREF(v00);
}
else
{
Py_DECREF(v0);
}
}
else
{
Py_XINCREF(m_ExceptionValue);
retVal = m_ExceptionValue;
}
return retVal;
}
PyObject* JPyCObject::fromVoid(void* data, void (*destr)(void *))
{
PY_CHECK( PyObject* res = PyCObject_FromVoidPtr(data, destr) );
return res;
}
PyObject* JPyCObject::fromVoidAndDesc(void* data, void* desc, void (*destr)(void *, void*))
{
PY_CHECK( PyObject* res = PyCObject_FromVoidPtrAndDesc(data, desc, destr) );
return res;
}
void* JPyCObject::asVoidPtr(PyObject* obj)
{
PY_CHECK( void* res = PyCObject_AsVoidPtr(obj) );
return res;
}
void* JPyCObject::getDesc(PyObject* obj)
{
PY_CHECK( void* res = PyCObject_GetDesc(obj) );
return res;
}
bool JPyCObject::check(PyObject* obj)
{
return PyCObject_Check(obj);
}
bool JPyType::check(PyObject* obj)
{
return PyType_Check(obj);
}
bool JPyType::isSubclass(PyObject* o1, PyObject* o2)
{
if (PyType_IsSubtype((PyTypeObject*)o1, (PyTypeObject*)o2))
{
return true;
}
return false;
}
void JPyHelper::dumpSequenceRefs(PyObject* seq, const char* comment)
{
cerr << "Dumping sequence state at " << comment << endl;
cerr << " sequence has " << (long)seq->ob_refcnt << " reference(s)" << endl;
Py_ssize_t dx = PySequence_Length(seq);
for (Py_ssize_t i = 0; i < dx; i++)
{
PyObject* el = PySequence_GetItem(seq, i);
Py_XDECREF(el); // PySequence_GetItem return a new ref
cerr << " item[" << (long)i << "] has " << (long)el->ob_refcnt << " references" << endl;
}
}
python-jpype-0.5.4.2/src/native/python/jpype_javaarray.cpp 0000666 0001750 0001750 00000012417 11614007722 023122 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
PyObject* JPypeJavaArray::findArrayClass(PyObject* obj, PyObject* args)
{
try {
char* cname;
JPyArg::parseTuple(args, "s", &cname);
JPTypeName name = JPTypeName::fromSimple(cname);
JPArrayClass* claz = JPTypeManager::findArrayClass(name);
if (claz == NULL)
{
Py_INCREF(Py_None);
return Py_None;
}
PyObject* res = JPyCObject::fromVoidAndDesc((void*)claz, (void*)"jclass", NULL);
return res;
}
PY_STANDARD_CATCH;
PyErr_Clear();
Py_INCREF(Py_None);
return Py_None;
}
PyObject* JPypeJavaArray::setJavaArrayClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setJavaArrayClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::setGetJavaArrayClassMethod(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setGetJavaArrayClassMethod(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::getArrayLength(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
JPyArg::parseTuple(arg, "O!", &PyCObject_Type, &arrayObject);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
int res = a->getLength();
return JPyInt::fromLong(res);
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::getArrayItem(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
int ndx;
JPyArg::parseTuple(arg, "O!i", &PyCObject_Type, &arrayObject, &ndx);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
HostRef* res = a->getItem(ndx);
return detachRef(res);
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::getArraySlice(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
int ndx;
int ndx2;
JPyArg::parseTuple(arg, "O!ii", &PyCObject_Type, &arrayObject, &ndx, &ndx2);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
vector values = a->getRange(ndx, ndx2);
JPCleaner cleaner;
PyObject* res = JPySequence::newList((int)values.size());
for (unsigned int i = 0; i < values.size(); i++)
{
JPySequence::setItem(res, i, (PyObject*)values[i]->data());
cleaner.add(values[i]);
}
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::setArraySlice(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
int ndx = -1;
int ndx2 = -1;
PyObject* val;
JPyArg::parseTuple(arg, "O!iiO", &PyCObject_Type, &arrayObject, &ndx, &ndx2, &val);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
Py_ssize_t len = JPyObject::length(val);
vector values;
JPCleaner cleaner;
for (Py_ssize_t i = 0; i < len; i++)
{
HostRef* v = new HostRef(JPySequence::getItem(val, i), false);
values.push_back(v);
cleaner.add(v);
}
a->setRange(ndx, ndx2, values);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::setArrayItem(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
int ndx;
PyObject* value;
JPyArg::parseTuple(arg, "O!iO", &PyCObject_Type, &arrayObject, &ndx, &value);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
JPCleaner cleaner;
HostRef* v = new HostRef(value);
cleaner.add(v);
a->setItem(ndx, v);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::newArray(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
int sz;
JPyArg::parseTuple(arg, "O!i", &PyCObject_Type, &arrayObject, &sz);
JPArrayClass* a = (JPArrayClass*)JPyCObject::asVoidPtr(arrayObject);
JPArray* v = a->newInstance(sz);
PyObject* res = JPyCObject::fromVoidAndDesc(v, (void*)"JPArray", PythonHostEnvironment::deleteJPArrayDestructor);
return res;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaArray::setArrayValues(PyObject* self, PyObject* arg)
{
try {
PyObject* arrayObject;
PyObject* values;
JPyArg::parseTuple(arg, "O!O", &PyCObject_Type, &arrayObject, &values);
JPArray* a = (JPArray*)JPyCObject::asVoidPtr(arrayObject);
JPArrayClass* arrayClass = a->getClass();
HostRef valuesRef(values);
arrayClass->getComponentType()->setArrayValues((jarray)a->getObject(), &valuesRef);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
python-jpype-0.5.4.2/src/native/python/jpype_javaclass.cpp 0000666 0001750 0001750 00000004214 11614007722 023105 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
PyObject* JPypeJavaClass::setJavaLangObjectClass(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setJavaLangObjectClass(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaClass::setGetClassMethod(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setGetJavaClassMethod(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaClass::setSpecialConstructorKey(PyObject* self, PyObject* arg)
{
try {
PyObject* t;
JPyArg::parseTuple(arg, "O", &t);
hostEnv->setSpecialConstructorKey(t);
Py_INCREF(Py_None);
return Py_None;
}
PY_STANDARD_CATCH
return NULL;
}
PyObject* JPypeJavaClass::findClass(PyObject* obj, PyObject* args)
{
TRACE_IN("JPypeModule::findClass");
try {
char* cname;
JPyArg::parseTuple(args, "s", &cname);
TRACE1(cname);
JPTypeName name = JPTypeName::fromSimple(cname);
JPClass* claz = JPTypeManager::findClass(name);
if (claz == NULL)
{
Py_INCREF(Py_None);
return Py_None;
}
PyObject* res = (PyObject*)PyJPClass::alloc(claz);
return res;
}
PY_STANDARD_CATCH;
PyErr_Clear();
Py_INCREF(Py_None);
return Py_None;
TRACE_OUT;
}
python-jpype-0.5.4.2/src/native/common/ 0000775 0001750 0001750 00000000000 11620747357 017203 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/common/jp_platform_win32.cpp 0000666 0001750 0001750 00000001557 11614007722 023244 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifdef JPYPE_WIN32
void longToHexString(long value, char* outStr)
{
ltoa(value, outStr, 16);
}
#endif
python-jpype-0.5.4.2/src/native/common/jp_arrayclass.cpp 0000666 0001750 0001750 00000011013 11614007722 022526 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
JPArrayClass::JPArrayClass(const JPTypeName& tname, jclass c) :
JPClassBase(tname, c)
{
JPTypeName compname = m_Name.getComponentName();
m_ComponentType = JPTypeManager::getType(compname);
}
JPArrayClass::~JPArrayClass()
{
}
EMatchType JPArrayClass::canConvertToJava(HostRef* o)
{
JPCleaner cleaner;
if (JPEnv::getHost()->isNone(o))
{
return _implicit;
}
if (JPEnv::getHost()->isArray(o))
{
JPArray* a = JPEnv::getHost()->asArray(o);
JPArrayClass* ca = a->getClass();
if (ca == this)
{
return _exact;
}
if (JPEnv::getJava()->IsAssignableFrom(ca->m_Class, m_Class))
{
return _implicit;
}
}
else if (JPEnv::getHost()->isUnicodeString(o) && m_ComponentType->getName().getType() ==JPTypeName::_char)
{
// Strings are also char[]
return _implicit;
}
else if (JPEnv::getHost()->isByteString(o) && m_ComponentType->getName().getType() ==JPTypeName::_byte)
{
// Strings are also char[]
return _implicit;
}
else if (JPEnv::getHost()->isSequence(o))
{
EMatchType match = _implicit;
int length = JPEnv::getHost()->getSequenceLength(o);
for (int i = 0; i < length && match > _none; i++)
{
HostRef* obj = JPEnv::getHost()->getSequenceItem(o, i);
cleaner.add(obj);
EMatchType newMatch = m_ComponentType->canConvertToJava(obj);
if (newMatch < match)
{
match = newMatch;
}
}
return match;
}
return _none;
}
HostRef* JPArrayClass::asHostObject(jvalue val)
{
if (val.l == NULL)
{
return JPEnv::getHost()->getNone();
}
return JPEnv::getHost()->newArray(new JPArray(m_Name, (jarray)val.l));
}
jvalue JPArrayClass::convertToJava(HostRef* obj)
{
JPCleaner cleaner;
jvalue res;
res.l = NULL;
if (JPEnv::getHost()->isArray(obj))
{
JPArray* a = JPEnv::getHost()->asArray(obj);
res = a->getValue();
}
else if (JPEnv::getHost()->isByteString(obj) && m_ComponentType->getName().getType() == JPTypeName::_byte && sizeof(char) == sizeof(jbyte))
{
char* rawData;
long size;
JPEnv::getHost()->getRawByteString(obj, &rawData, size);
jbyteArray array = JPEnv::getJava()->NewByteArray(size);
cleaner.addLocal(array);
res.l = array;
jboolean isCopy;
jbyte* contents = JPEnv::getJava()->GetByteArrayElements(array, &isCopy);
memcpy(contents, rawData, size*sizeof(jbyte));
JPEnv::getJava()->ReleaseByteArrayElements(array, contents, 0);
cleaner.removeLocal(array);
}
else if (JPEnv::getHost()->isUnicodeString(obj) && m_ComponentType->getName().getType() == JPTypeName::_char && JPEnv::getHost()->getUnicodeSize() == sizeof(jchar))
{
jchar* rawData;
long size;
JPEnv::getHost()->getRawUnicodeString(obj, &rawData, size);
jcharArray array = JPEnv::getJava()->NewCharArray(size);
cleaner.addLocal(array);
res.l = array;
jboolean isCopy;
jchar* contents = JPEnv::getJava()->GetCharArrayElements(array, &isCopy);
memcpy(contents, rawData, size*sizeof(jchar));
JPEnv::getJava()->ReleaseCharArrayElements(array, contents, 0);
cleaner.removeLocal(array);
}
else if (JPEnv::getHost()->isSequence(obj))
{
int length = JPEnv::getHost()->getSequenceLength(obj);
jarray array = m_ComponentType->newArrayInstance(length);
cleaner.addLocal(array);
res.l = array;
for (int i = 0; i < length ; i++)
{
HostRef* obj2 = JPEnv::getHost()->getSequenceItem(obj, i);
cleaner.add(obj2);
m_ComponentType->setArrayItem(array, i, obj2);
}
cleaner.removeLocal(array);
}
return res;
}
JPArray* JPArrayClass::newInstance(int length)
{
JPCleaner cleaner;
jarray array = m_ComponentType->newArrayInstance(length);
cleaner.addLocal(array);
JPArray* res = new JPArray(getName(), array);
return res;
}
python-jpype-0.5.4.2/src/native/common/jp_classbase.cpp 0000666 0001750 0001750 00000002101 11614007722 022320 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
JPClassBase::JPClassBase(const JPTypeName& tname, jclass c) :
JPObjectType(JPTypeName::_unknown, JPTypeName::fromType(JPTypeName::_void)),
m_Name(tname)
{
m_Class = (jclass)JPEnv::getJava()->NewGlobalRef(c);
}
JPClassBase::~JPClassBase()
{
JPEnv::getJava()->DeleteGlobalRef(m_Class);
}
python-jpype-0.5.4.2/src/native/common/jp_proxy.cpp 0000666 0001750 0001750 00000017234 11614007722 021556 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
JNIEXPORT jobject JNICALL Java_jpype_JPypeInvocationHandler_hostInvoke(
JNIEnv *env, jclass clazz, jstring name,
jlong hostObj, jobjectArray args,
jobjectArray types, jclass returnType)
{
TRACE_IN("Java_jpype_JPypeInvocationHandler_hostInvoke");
void* callbackState = JPEnv::getHost()->prepareCallbackBegin();
JPCleaner cleaner;
try {
string cname = JPJni::asciiFromJava(name);
HostRef* hostObjRef = (HostRef*)hostObj;
HostRef* callable = JPEnv::getHost()->getCallableFrom(hostObjRef, cname);
cleaner.add(callable);
if (callable == NULL || callable->isNull() || JPEnv::getHost()->isNone(callable))
{
JPEnv::getJava()->ThrowNew(JPJni::s_NoSuchMethodErrorClass, cname.c_str());
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
}
// convert the arguments into a python list
jsize argLen = JPEnv::getJava()->GetArrayLength(types);
vector hostArgs;
std::vector argTypes;
for (jsize j = 0; j < argLen; j++)
{
jclass c = (jclass)JPEnv::getJava()->GetObjectArrayElement(types, j);
cleaner.addLocal(c);
JPTypeName tn = JPJni::getName(c);
argTypes.push_back(tn);
}
for (int i = 0; i < argLen; i++)
{
jobject obj = JPEnv::getJava()->GetObjectArrayElement(args, i);
cleaner.addLocal(obj);
JPTypeName t = argTypes[i];
jvalue v;
v.l = obj;
HostRef* o = JPTypeManager::getType(t)->asHostObjectFromObject(v);
cleaner.add(o);
hostArgs.push_back(o);
}
HostRef* returnValue = JPEnv::getHost()->callObject(callable, hostArgs);
cleaner.add(returnValue);
JPTypeName returnT = JPJni::getName(returnType);
if (returnValue == NULL || returnValue->isNull() || JPEnv::getHost()->isNone(returnValue))
{
if (returnT.getType() != JPTypeName::_void && returnT.getType() < JPTypeName::_object)
{
JPEnv::getJava()->ThrowNew(JPJni::s_RuntimeExceptionClass, "Return value is None when it cannot be");
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
}
}
if (returnT.getType() == JPTypeName::_void)
{
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
}
JPType* rt = JPTypeManager::getType(returnT);
if (rt->canConvertToJava(returnValue) == _none)
{
JPEnv::getJava()->ThrowNew(JPJni::s_RuntimeExceptionClass, "Return value is not compatible with required type.");
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
}
jobject returnObj = rt->convertToJavaObject(returnValue);
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return returnObj;
}
catch(HostException* ex)
{
JPEnv::getHost()->clearError();
if (JPEnv::getHost()->isJavaException(ex))
{
JPCleaner cleaner;
HostRef* javaExcRef = JPEnv::getHost()->getJavaException(ex);
JPObject* javaExc = JPEnv::getHost()->asObject(javaExcRef);
cleaner.add(javaExcRef);
jobject obj = javaExc->getObject();
cleaner.addLocal(obj);
JPEnv::getJava()->Throw((jthrowable)obj);
}
else
{
JPEnv::getJava()->ThrowNew(JPJni::s_RuntimeExceptionClass, "Python exception thrown");
}
}
catch(JavaException*)
{
cerr << "Java exception at " << __FILE__ << ":" << __LINE__ << endl;
}
catch(JPypeException* ex)
{
JPEnv::getJava()->ThrowNew(JPJni::s_RuntimeExceptionClass, ex->getMsg());
}
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
TRACE_OUT;
}
JNIEXPORT jobject JNICALL Java_jpype_ref_JPypeReferenceQueue_removeHostReference(
JNIEnv *env, jclass clazz, jlong hostObj)
{
TRACE_IN("Java_jpype_ref_JPypeReferenceQueue_removeHostReference");
void* callbackState = JPEnv::getHost()->prepareCallbackBegin();
if (hostObj >0)
{
HostRef* hostObjRef = (HostRef*)hostObj;
//JPEnv::getHost()->printReferenceInfo(hostObjRef);
delete hostObjRef;
}
JPEnv::getHost()->prepareCallbackFinish(callbackState);
return NULL;
TRACE_OUT;
}
static jclass handlerClass;
static jclass referenceClass;
static jclass referenceQueueClass;
static jmethodID invocationHandlerConstructorID;
static jfieldID hostObjectID;
void JPProxy::init()
{
TRACE_IN("JPProxy::init");
// build the proxy class ...
jobject cl = JPJni::getSystemClassLoader();
JPCleaner cleaner;
jclass handler = JPEnv::getJava()->DefineClass("jpype/JPypeInvocationHandler", cl, JPypeInvocationHandler, getJPypeInvocationHandlerLength());
handlerClass = (jclass)JPEnv::getJava()->NewGlobalRef(handler);
cleaner.addLocal(handler);
JNINativeMethod method[1];
method[0].name = "hostInvoke";
method[0].signature = "(Ljava/lang/String;J[Ljava/lang/Object;[Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;";
method[0].fnPtr = (void*)&Java_jpype_JPypeInvocationHandler_hostInvoke;
hostObjectID = JPEnv::getJava()->GetFieldID(handler, "hostObject", "J");
invocationHandlerConstructorID = JPEnv::getJava()->GetMethodID(handler, "", "()V");
JPEnv::getJava()->RegisterNatives(handlerClass, method, 1);
// Not quite the right area ... but I;m doing similar here already so let's register the other classes too
jclass reference = JPEnv::getJava()->DefineClass("jpype/ref/JPypeReference", cl, JPypeReference, getJPypeReferenceLength());
jclass referenceQueue = JPEnv::getJava()->DefineClass("jpype/ref/JPypeReferenceQueue", cl, JPypeReferenceQueue, getJPypeReferenceQueueLength());
referenceClass = (jclass)JPEnv::getJava()->NewGlobalRef(reference);
referenceQueueClass = (jclass)JPEnv::getJava()->NewGlobalRef(referenceQueue);
cleaner.addLocal(reference);
cleaner.addLocal(referenceQueue);
JNINativeMethod method2[1];
method2[0].name = "removeHostReference";
method2[0].signature = "(J)V";
method2[0].fnPtr = (void*)&Java_jpype_ref_JPypeReferenceQueue_removeHostReference;
JPEnv::getJava()->RegisterNatives(referenceQueueClass, method2, 1);
TRACE_OUT;
}
JPProxy::JPProxy(HostRef* inst, vector& intf)
{
m_Instance = inst->copy();
jobjectArray ar = JPEnv::getJava()->NewObjectArray((int)intf.size(), JPJni::s_ClassClass, NULL);
m_Interfaces = (jobjectArray)JPEnv::getJava()->NewGlobalRef(ar);
JPEnv::getJava()->DeleteLocalRef(ar);
for (unsigned int i = 0; i < intf.size(); i++)
{
m_InterfaceClasses.push_back((jclass)JPEnv::getJava()->NewGlobalRef(intf[i]));
JPEnv::getJava()->SetObjectArrayElement(m_Interfaces, i, m_InterfaceClasses[i]);
}
m_Handler = JPEnv::getJava()->NewObject(handlerClass, invocationHandlerConstructorID);
JPEnv::getJava()->SetLongField(m_Handler, hostObjectID, (jlong)inst->copy());
}
jobject JPProxy::getProxy()
{
JPCleaner cleaner;
jobject cl = JPJni::getSystemClassLoader();
cleaner.addLocal(cl);
jvalue v[3];
v[0].l = cl;
v[1].l = m_Interfaces;
v[2].l = m_Handler;
jobject res = JPEnv::getJava()->CallStaticObjectMethodA(JPJni::s_ProxyClass, JPJni::s_NewProxyInstanceID, v);
return res;
}
python-jpype-0.5.4.2/src/native/common/jp_monitor.cpp 0000666 0001750 0001750 00000002013 11614007722 022051 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
JPMonitor::JPMonitor(jobject o)
{
JPEnv::getJava()->MonitorEnter(o);
m_Object = JPEnv::getJava()->NewGlobalRef(o);
}
JPMonitor::~JPMonitor()
{
JPEnv::getJava()->MonitorExit(m_Object);
JPEnv::getJava()->DeleteGlobalRef(m_Object);
}
python-jpype-0.5.4.2/src/native/common/jp_array.cpp 0000666 0001750 0001750 00000005451 11614007722 021511 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
JPArray::JPArray(JPTypeName name, jarray inst)
{
m_Class = JPTypeManager::findArrayClass(name);
m_Object = (jarray)JPEnv::getJava()->NewGlobalRef(inst);
}
JPArray::~JPArray()
{
JPEnv::getJava()->DeleteGlobalRef(m_Object);
}
int JPArray::getLength()
{
return JPEnv::getJava()->GetArrayLength(m_Object);
}
vector JPArray::getRange(int start, int stop)
{
TRACE_IN("JPArray::getRange");
JPType* compType = m_Class->getComponentType();
TRACE2("Compoennt type", compType->getName().getSimpleName());
vector res = compType->getArrayRange(m_Object, start, stop-start);
return res;
TRACE_OUT;
}
void JPArray::setRange(int start, int stop, vector& val)
{
JPCleaner cleaner;
JPType* compType = m_Class->getComponentType();
int len = stop-start;
size_t plength = val.size();
if (len != plength)
{
std::stringstream out;
out << "Slice assignment must be of equal lengths : " << len << " != " << plength;
RAISE(JPypeException, out.str());
}
for (size_t i = 0; i < plength; i++)
{
HostRef* v = val[i];
if ( compType->canConvertToJava(v)<= _explicit)
{
RAISE(JPypeException, "Unable to convert.");
}
}
compType->setArrayRange(m_Object, start, stop-start, val);
}
void JPArray::setItem(int ndx, HostRef* val)
{
JPType* compType = m_Class->getComponentType();
if (compType->canConvertToJava(val) <= _explicit)
{
RAISE(JPypeException, "Unable to convert.");
}
compType->setArrayItem(m_Object, ndx, val);
}
HostRef* JPArray::getItem(int ndx)
{
JPType* compType = m_Class->getComponentType();
return compType->getArrayItem(m_Object, ndx);
}
JPType* JPArray::getType()
{
return m_Class;
}
jvalue JPArray::getValue()
{
jvalue val;
val.l = JPEnv::getJava()->NewLocalRef(m_Object);
return val;
}
JCharString JPArray::toString()
{
static const char* value = "Array wrapper";
jchar res[14];
res[13] = 0;
for (int i = 0; value[i] != 0; i++)
{
res[i] = value[i];
}
return res;
}
python-jpype-0.5.4.2/src/native/common/jp_methodoverload.cpp 0000666 0001750 0001750 00000016040 11614007722 023403 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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
JPMethodOverload::JPMethodOverload()
{
m_Method = NULL;
}
JPMethodOverload::JPMethodOverload(const JPMethodOverload& o) :
m_Class(o.m_Class),
m_MethodID(o.m_MethodID),
m_ReturnType(o.m_ReturnType),
m_Arguments(o.m_Arguments),
m_IsStatic(o.m_IsStatic),
m_IsFinal(o.m_IsFinal),
m_IsConstructor(o.m_IsConstructor)
{
m_Method = JPEnv::getJava()->NewGlobalRef(o.m_Method);
}
JPMethodOverload::JPMethodOverload(JPClass* claz, jobject mth)
{
m_Class = claz;
m_Method = JPEnv::getJava()->NewGlobalRef(mth);
// static
m_IsStatic = JPJni::isMemberStatic(mth);
m_IsFinal = JPJni::isMemberStatic(m_Method);
// Method ID
m_MethodID = JPEnv::getJava()->FromReflectedMethod(mth);
m_IsConstructor = JPJni::isConstructor(m_Method);
// return type
if (! m_IsConstructor)
{
m_ReturnType = JPJni::getReturnType(mth);
}
// arguments
m_Arguments = JPJni::getParameterTypes(mth, m_IsConstructor);
// Add the implicit "this" argument
if (! m_IsStatic && ! m_IsConstructor)
{
m_Arguments.insert(m_Arguments.begin(), 1, claz->getName());
}
}
JPMethodOverload::~JPMethodOverload()
{
JPEnv::getJava()->DeleteGlobalRef(m_Method);
}
string JPMethodOverload::getSignature()
{
stringstream res;
res << "(";
for (vector::iterator it = m_Arguments.begin(); it != m_Arguments.end(); it++)
{
res << it->getNativeName();
}
res << ")" ;
return res.str();
}
string JPMethodOverload::getArgumentString()
{
stringstream res;
res << "(";
bool first = true;
for (vector::iterator it = m_Arguments.begin(); it != m_Arguments.end(); it++)
{
if (! first)
{
res << ", ";
}
else
{
first = false;
}
res << it->getSimpleName();
}
res << ")";
return res.str();
}
bool JPMethodOverload::isSameOverload(JPMethodOverload& o)
{
if (isStatic() != o.isStatic())
{
return false;
}
if (m_Arguments.size() != o.m_Arguments.size())
{
return false;
}
TRACE_IN("JPMethodOverload::isSameOverload");
TRACE2("My sig", getSignature());
TRACE2("It's sig", o.getSignature());
int start = 0;
if (! isStatic())
{
start = 1;
}
for (unsigned int i = start; i < m_Arguments.size() && i < o.m_Arguments.size(); i++)
{
JPTypeName mine = m_Arguments[i];
JPTypeName his = o.m_Arguments[i];
string mineSimple = mine.getSimpleName();
string hisSimple = his.getSimpleName();
if (mineSimple != hisSimple)
{
return false;
}
}
return true;
TRACE_OUT;
}
EMatchType JPMethodOverload::matches(bool ignoreFirst, vector& arg)
{
TRACE_IN("JPMethodOverload::matches");
size_t len = arg.size();
if (len != m_Arguments.size())
{
return _none;
}
EMatchType lastMatch = _exact;
for (unsigned int i = 0; i < len; i++)
{
if (i == 0 && ignoreFirst)
{
continue;
}
HostRef* obj = arg[i];
JPType* type = JPTypeManager::getType(m_Arguments[i]);
EMatchType match = type->canConvertToJava(obj);
if (match < _implicit)
{
return _none;
}
if (match < lastMatch)
{
lastMatch = match;
}
}
return lastMatch;
TRACE_OUT;
}
HostRef* JPMethodOverload::invokeStatic(vector& arg)
{
TRACE_IN("JPMethodOverload::invokeStatic");
JPCleaner cleaner;
size_t len = arg.size();
JPMallocCleaner v(len);
JPMallocCleaner types(len);
for (unsigned int i = 0; i < len; i++)
{
HostRef* obj = arg[i];
types[i] = JPTypeManager::getType(m_Arguments[i]);
v[i] = types[i]->convertToJava(obj);
if (types[i]->isObjectType())
{
cleaner.addLocal(v[i].l);
}
}
jclass claz = m_Class->getClass();
cleaner.addLocal(claz);
JPType* retType = JPTypeManager::getType(m_ReturnType);
return retType->invokeStatic(claz, m_MethodID, v.borrow());
TRACE_OUT;
}
HostRef* JPMethodOverload::invokeInstance(vector& args)
{
TRACE_IN("JPMethodOverload::invokeInstance");
HostRef* res;
{
JPCleaner cleaner;
// Arg 0 is "this"
HostRef* self = args[0];
JPObject* selfObj = JPEnv::getHost()->asObject(self);
size_t len = args.size();
JPMallocCleaner v(len-1);
for (unsigned int i = 1; i < len; i++)
{
HostRef* obj = args[i];
JPType* type = JPTypeManager::getType(m_Arguments[i]);
v[i-1] = type->convertToJava(obj);
if (type->isObjectType())
{
cleaner.addLocal(v[i-1].l);
}
}
JPType* retType = JPTypeManager::getType(m_ReturnType);
jobject c = selfObj->getObject();
cleaner.addLocal(c);
jclass clazz = m_Class->getClass();
cleaner.addLocal(clazz);
res = retType->invoke(c, clazz, m_MethodID, v.borrow());
TRACE1("Call finished");
}
TRACE1("Call successfull");
return res;
TRACE_OUT;
}
JPObject* JPMethodOverload::invokeConstructor(jclass claz, vector& arg)
{
TRACE_IN("JPMethodOverload::invokeConstructor");
size_t len = arg.size();
JPCleaner cleaner;
JPMallocCleaner v(len);
for (unsigned int i = 0; i < len; i++)
{
HostRef* obj = arg[i];
// TODO the following can easily be optimized ... or at least cached
JPType* t = JPTypeManager::getType(m_Arguments[i]);
v[i] = t->convertToJava(obj);
if (t->isObjectType())
{
cleaner.addLocal(v[i].l);
}
}
jvalue val;
val.l = JPEnv::getJava()->NewObjectA(claz, m_MethodID, v.borrow());
cleaner.addLocal(val.l);
TRACE1("Object created");
JPTypeName name = JPJni::getName(claz);
return new JPObject(name, val.l);
TRACE_OUT;
}
string JPMethodOverload::matchReport(vector& args)
{
stringstream res;
res << m_ReturnType.getNativeName() << " (";
bool isFirst = true;
for (vector::iterator it = m_Arguments.begin(); it != m_Arguments.end(); it++)
{
if (isFirst && ! isStatic())
{
isFirst = false;
continue;
}
isFirst = false;
res << it->getNativeName();
}
res << ") ==> ";
EMatchType match = matches(! isStatic(), args);
switch(match)
{
case _none :
res << "NONE";
break;
case _explicit :
res << "EXPLICIT";
break;
case _implicit :
res << "IMPLICIT";
break;
case _exact :
res << "EXACT";
break;
default :
res << "UNKNOWN";
break;
}
res << endl;
return res.str();
}
python-jpype-0.5.4.2/src/native/common/jp_objecttypes.cpp 0000666 0001750 0001750 00000023126 11614007722 022725 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
HostRef* JPObjectType::getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType)
{
TRACE_IN("JPObjectType::getStaticValue");
JPCleaner cleaner;
jobject r = JPEnv::getJava()->GetStaticObjectField(c, fid);
cleaner.addLocal(r);
jvalue v;
v.l = r;
JPTypeName name = JPJni::getClassName(v.l);
JPType* type = JPTypeManager::getType(name);
return type->asHostObject(v);
TRACE_OUT;
}
HostRef* JPObjectType::getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType)
{
TRACE_IN("JPObjectType::getInstanceValue");
JPCleaner cleaner;
jobject r = JPEnv::getJava()->GetObjectField(c, fid);
cleaner.addLocal(r);
jvalue v;
v.l = r;
JPTypeName name = JPJni::getClassName(v.l);
JPType* type = JPTypeManager::getType(name);
return type->asHostObject(v);
TRACE_OUT;
}
HostRef* JPObjectType::invokeStatic(jclass claz, jmethodID mth, jvalue* val)
{
TRACE_IN("JPObjectType::invokeStatic");
JPCleaner cleaner;
jobject res = JPEnv::getJava()->CallStaticObjectMethodA(claz, mth, val);
cleaner.addLocal(res);
jvalue v;
v.l = res;
JPTypeName name = JPJni::getClassName(v.l);
JPType* type = JPTypeManager::getType(name);
return type->asHostObject(v);
TRACE_OUT;
}
HostRef* JPObjectType::invoke(jobject claz, jclass clazz, jmethodID mth, jvalue* val)
{
TRACE_IN("JPObjectType::invoke");
JPCleaner cleaner;
jobject res = JPEnv::getJava()->CallNonvirtualObjectMethodA(claz, clazz, mth, val);
cleaner.addLocal(res);
jvalue v;
v.l = res;
JPTypeName name = JPJni::getClassName(v.l);
JPType* type = JPTypeManager::getType(name);
HostRef* ref = type->asHostObject(v);
TRACE1("Successfulyl converted to host reference");
return ref;
TRACE_OUT;
}
void JPObjectType::setStaticValue(jclass c, jfieldID fid, HostRef* obj)
{
TRACE_IN("JPObjectType::setStaticValue");
JPCleaner cleaner;
jobject val = convertToJava(obj).l;
cleaner.addLocal(val);
JPEnv::getJava()->SetStaticObjectField(c, fid, val);
TRACE_OUT;
}
void JPObjectType::setInstanceValue(jobject c, jfieldID fid, HostRef* obj)
{
TRACE_IN("JPObjectType::setInstanceValue");
JPCleaner cleaner;
jobject val = convertToJava(obj).l;
cleaner.addLocal(val);
JPEnv::getJava()->SetObjectField(c, fid, val);
TRACE_OUT;
}
jarray JPObjectType::newArrayInstance(int sz)
{
JPCleaner cleaner;
jclass c = getClass();
cleaner.addLocal(c);
return JPEnv::getJava()->NewObjectArray(sz, c, NULL);
}
vector JPObjectType::getArrayRange(jarray a, int start, int length)
{
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
vector res;
jvalue v;
for (int i = 0; i < length; i++)
{
v.l = JPEnv::getJava()->GetObjectArrayElement(array, i+start);
cleaner.addLocal(v.l);
JPTypeName name = JPJni::getClassName(v.l);
JPType* t = JPTypeManager::getType(name);
HostRef* pv = t->asHostObject(v);
res.push_back(pv);
}
return res;
}
void JPObjectType::setArrayRange(jarray a, int start, int length, vector& vals)
{
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
jvalue v;
for (int i = 0; i < length; i++)
{
HostRef* pv = vals[i];
v = convertToJava(pv);
cleaner.addLocal(v.l);
JPEnv::getJava()->SetObjectArrayElement(array, i+start, v.l);
}
}
void JPObjectType::setArrayItem(jarray a, int ndx, HostRef* val)
{
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
jvalue v = convertToJava(val);
cleaner.addLocal(v.l);
JPEnv::getJava()->SetObjectArrayElement(array, ndx, v.l);
}
HostRef* JPObjectType::getArrayItem(jarray a, int ndx)
{
TRACE_IN("JPObjectType::getArrayItem");
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
jobject obj = JPEnv::getJava()->GetObjectArrayElement(array, ndx);
cleaner.addLocal(obj);
if (obj == NULL)
{
return JPEnv::getHost()->getNone();
}
jvalue v;
v.l = obj;
JPTypeName name = JPJni::getClassName(v.l);
JPType* t = JPTypeManager::getType(name);
return t->asHostObject(v);
TRACE_OUT;
}
jobject JPObjectType::convertToJavaObject(HostRef* obj)
{
jvalue v = convertToJava(obj);
return v.l;
}
HostRef* JPObjectType::asHostObjectFromObject(jvalue val)
{
return asHostObject(val);
}
HostRef* JPObjectType::convertToDirectBuffer(HostRef* src)
{
RAISE(JPypeException, "Unable to convert to Direct Buffer");
}
void JPObjectType::setArrayValues(jarray a, HostRef* values)
{
jobjectArray array = (jobjectArray)a;
JPCleaner cleaner;
try {
bool converted = true;
// Optimize what I can ...
// TODO also optimize array.array ...
if (JPEnv::getHost()->isSequence(values))
{
int len = JPEnv::getHost()->getSequenceLength(values);
for (int i = 0; i < len; i++)
{
HostRef* v = JPEnv::getHost()->getSequenceItem(values, i);
JPEnv::getJava()->SetObjectArrayElement(array, i, convertToJava(v).l);
delete v;
}
converted = true;
}
else
{
RAISE(JPypeException, "Unable to convert to Object array");
}
}
RETHROW_CATCH( ; );
}
//-------------------------------------------------------------------------------
HostRef* JPStringType::asHostObject(jvalue val)
{
TRACE_IN("JPStringType::asHostObject");
if (val.l == NULL)
{
return JPEnv::getHost()->getNone();
}
jstring v = (jstring)val.l;
if (JPEnv::getJava()->getConvertStringObjects())
{
TRACE1(" Performing conversion");
jsize len = JPEnv::getJava()->GetStringLength(v);
jboolean isCopy;
const jchar* str = JPEnv::getJava()->GetStringChars(v, &isCopy);
HostRef* res = JPEnv::getHost()->newStringFromUnicode(str, len);
JPEnv::getJava()->ReleaseStringChars(v, str);
return res;
}
else
{
TRACE1(" Performing wrapping");
HostRef* res = JPEnv::getHost()->newStringWrapper(v);
TRACE1(" Wrapping successfull");
return res;
}
TRACE_OUT;
}
EMatchType JPStringType::canConvertToJava(HostRef* obj)
{
TRACE_IN("JPStringType::canConvertToJava");
JPCleaner cleaner;
if (obj == NULL || JPEnv::getHost()->isNone(obj))
{
return _implicit;
}
if (JPEnv::getHost()->isString(obj))
{
return _exact;
}
if (JPEnv::getHost()->isWrapper(obj))
{
JPTypeName name = JPEnv::getHost()->getWrapperTypeName(obj);
if (name.getType() == JPTypeName::_string)
{
return _exact;
}
}
if (JPEnv::getHost()->isObject(obj))
{
JPObject* o = JPEnv::getHost()->asObject(obj);
JPClass* oc = o->getClass();
if (oc->getName().getSimpleName() == "java.lang.String")
{
return _exact;
}
}
return _none;
TRACE_OUT;
}
jvalue JPStringType::convertToJava(HostRef* obj)
{
TRACE_IN("JPStringType::convertToJava");
JPCleaner cleaner;
jvalue v;
if (JPEnv::getHost()->isNone(obj))
{
v.l = NULL;
return v;
}
if (JPEnv::getHost()->isWrapper(obj))
{
return JPEnv::getHost()->getWrapperValue(obj);
}
if (JPEnv::getHost()->isObject(obj))
{
JPObject* o = JPEnv::getHost()->asObject(obj);
JPClass* oc = o->getClass();
if (oc->getName().getSimpleName() == "java.lang.String")
{
v.l = o->getObject();
return v;
}
}
JCharString wstr = JPEnv::getHost()->stringAsJCharString(obj);
jchar* jstr = new jchar[wstr.length()+1];
jstr[wstr.length()] = 0;
for (size_t i = 0; i < wstr.length(); i++)
{
jstr[i] = (jchar)wstr[i];
}
jstring res = JPEnv::getJava()->NewString(jstr, (jint)wstr.length());
delete jstr;
v.l = res;
return v;
TRACE_OUT;
}
jclass JPStringType::getClass()
{
return (jclass)JPEnv::getJava()->NewGlobalRef(JPJni::s_StringClass);
}
//-------------------------------------------------------------------------------
HostRef* JPClassType::asHostObject(jvalue val)
{
jclass lclass = (jclass)val.l;
JPTypeName name = JPJni::getName(lclass);
JPClass* res = JPTypeManager::findClass(name);
return JPEnv::getHost()->newClass(res);
}
EMatchType JPClassType::canConvertToJava(HostRef* obj)
{
JPCleaner cleaner;
if (JPEnv::getHost()->isNone(obj))
{
return _implicit;
}
if (JPEnv::getHost()->isClass(obj))
{
return _exact;
}
if (JPEnv::getHost()->isWrapper(obj))
{
JPTypeName name = JPEnv::getHost()->getWrapperTypeName(obj);
if (name.getType() == JPTypeName::_class)
{
return _exact;
}
}
return _none;
}
jvalue JPClassType::convertToJava(HostRef* obj)
{
JPCleaner cleaner;
jvalue v;
if (JPEnv::getHost()->isNone(obj))
{
v.l = NULL;
return v;
}
else if (JPEnv::getHost()->isWrapper(obj))
{
v = JPEnv::getHost()->getWrapperValue(obj);
}
else
{
JPClass* w = JPEnv::getHost()->asClass(obj);
jclass lr = w->getClass();
v.l = lr;
}
return v;
}
jclass JPClassType::getClass()
{
return (jclass)JPEnv::getJava()->NewGlobalRef(JPJni::s_ClassClass);
}
python-jpype-0.5.4.2/src/native/common/jp_typename.cpp 0000666 0001750 0001750 00000011147 11614227744 022224 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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
#undef JPYPE_TRACING_INTERNAL
//AT's on porting:
// 1) the original definition of global static object leads to crashing
//on HP-UX platform. Cause: it is suspected to be an undefined order of initialization of static objects
//
// 2) TODO: in any case, use of static objects may impose problems in multi-threaded environment.
//Therefore, they must be guarded with a mutex.
map& GetNativeNamesMap()
{
static map nativeNames;
return nativeNames;
}
map& GetDefinedTypesMap()
{
static map definedTypes;
return definedTypes;
}
map& GetNativeTypesMap()
{
static map nativeTypes;
return nativeTypes;
}
static string convertToNativeClassName(const std::string& str)
{
// simple names are of the form :
// a.c.d.E
// native names are of the form :
// La/c/d/E;
string name = str;
string result = string("L")+name+";";
for (unsigned int j = 0; j < result.length(); j++)
{
if (result[j] == '.')
{
result[j] = '/';
}
}
return result;
}
void JPTypeName::init()
{
GetNativeNamesMap()["void"] = "V";
GetNativeNamesMap()["byte"] = "B";
GetNativeNamesMap()["short"] = "S";
GetNativeNamesMap()["int"] = "I";
GetNativeNamesMap()["long"] = "J";
GetNativeNamesMap()["float"] = "F";
GetNativeNamesMap()["double"] = "D";
GetNativeNamesMap()["boolean"] = "Z";
GetNativeNamesMap()["char"] = "C";
GetDefinedTypesMap()["void"] = _void;
GetDefinedTypesMap()["byte"] = _byte;
GetDefinedTypesMap()["short"] = _short;
GetDefinedTypesMap()["int"] = _int;
GetDefinedTypesMap()["long"] = _long;
GetDefinedTypesMap()["float"] = _float;
GetDefinedTypesMap()["double"] = _double;
GetDefinedTypesMap()["boolean"] = _boolean;
GetDefinedTypesMap()["char"] = _char;
GetDefinedTypesMap()["java.lang.String"] = _string;
GetDefinedTypesMap()["java.lang.Class"] = _class;
for (map::iterator it = GetDefinedTypesMap().begin(); it != GetDefinedTypesMap().end(); ++it)
{
GetNativeTypesMap()[it->second] = it->first;
}
}
JPTypeName JPTypeName::fromType(JPTypeName::ETypes t)
{
return fromSimple(GetNativeTypesMap()[t].c_str());
}
JPTypeName JPTypeName::fromSimple(const char* name)
{
string simple = name;
string componentName = simple;
string nativeComponent;
JPTypeName::ETypes t;
// is it an array?
size_t arrayDimCount = 0;
if (simple.length() > 0 && simple[simple.length()-1] == ']')
{
size_t i = simple.length()-1;
while (simple[i] == ']' || simple[i] == '[')
{
i--;
}
componentName = simple.substr(0, i+1);
arrayDimCount = (simple.length() - componentName.length())/2;
}
map::iterator nativeIt = GetNativeNamesMap().find(componentName);
if (nativeIt == GetNativeNamesMap().end())
{
nativeComponent = convertToNativeClassName(componentName);
}
else
{
nativeComponent = nativeIt->second;
}
string native;
if (arrayDimCount > 0)
{
stringstream str;
for (unsigned int i = 0; i < arrayDimCount; i++)
{
str << "[";
}
str << nativeComponent;
native = str.str();
}
else
{
native = nativeComponent;
}
map::iterator typeIt = GetDefinedTypesMap().find(name);
if (typeIt == GetDefinedTypesMap().end())
{
if (native[0] == '[')
{
t = _array;
}
else
{
t = _object;
}
}
else
{
t = typeIt->second;
}
return JPTypeName(simple, native, t);
}
JPTypeName JPTypeName::getComponentName()
{
if (m_Type != _array)
{
RAISE(JPypeException, "Not an array type");
}
string sname = m_SimpleName.substr(0,m_SimpleName.length()-2);
JPTypeName compName = fromSimple(sname.c_str());
return compName;
}
python-jpype-0.5.4.2/src/native/common/jp_javaenv_autogen.cpp 0000666 0001750 0001750 00000133524 11614007722 023552 0 ustar takaki takaki
/*****************************************************************************
Copyright 2004-2008 Steve Menard
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.
*****************************************************************************/
// This code has been automatically generated ... No not edit
#include
#define JAVA_CHECK(msg) \
if (JPEnv::getJava()->ExceptionCheck()) \
{ \
RAISE(JavaException, msg); \
} \
jbyte JPJavaEnv::GetStaticByteField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jbyte res = env->functions->GetStaticByteField(env, clazz, fid);
JAVA_CHECK("GetStaticByteField");
return res;
}
jbyte JPJavaEnv::GetByteField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jbyte res = env->functions->GetByteField(env, clazz, fid);
JAVA_CHECK("GetByteField");
return res;
}
void JPJavaEnv::SetStaticByteField(jclass clazz, jfieldID fid, jbyte val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticByteField(env, clazz, fid, val);
JAVA_CHECK("SetStaticByteField");
}
void JPJavaEnv::SetByteField(jobject clazz, jfieldID fid, jbyte val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetByteField(env, clazz, fid, val);
JAVA_CHECK("SetByteField");
}
jbyte JPJavaEnv::CallStaticByteMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticByteMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jbyte JPJavaEnv::CallStaticByteMethod(jclass clazz, jmethodID mid)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticByteMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jbyte JPJavaEnv::CallByteMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallByteMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jbyte JPJavaEnv::CallByteMethod(jobject obj, jmethodID mid)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallByteMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jbyte JPJavaEnv::CallNonvirtualByteMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualByteMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jbyte JPJavaEnv::CallNonvirtualByteMethod(jobject obj, jclass claz, jmethodID mid)
{
jbyte res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualByteMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Byte");
return res;
}
jshort JPJavaEnv::GetStaticShortField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jshort res = env->functions->GetStaticShortField(env, clazz, fid);
JAVA_CHECK("GetStaticShortField");
return res;
}
jshort JPJavaEnv::GetShortField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jshort res = env->functions->GetShortField(env, clazz, fid);
JAVA_CHECK("GetShortField");
return res;
}
void JPJavaEnv::SetStaticShortField(jclass clazz, jfieldID fid, jshort val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticShortField(env, clazz, fid, val);
JAVA_CHECK("SetStaticShortField");
}
void JPJavaEnv::SetShortField(jobject clazz, jfieldID fid, jshort val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetShortField(env, clazz, fid, val);
JAVA_CHECK("SetShortField");
}
jshort JPJavaEnv::CallStaticShortMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticShortMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jshort JPJavaEnv::CallStaticShortMethod(jclass clazz, jmethodID mid)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticShortMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jshort JPJavaEnv::CallShortMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallShortMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jshort JPJavaEnv::CallShortMethod(jobject obj, jmethodID mid)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallShortMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jshort JPJavaEnv::CallNonvirtualShortMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualShortMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jshort JPJavaEnv::CallNonvirtualShortMethod(jobject obj, jclass claz, jmethodID mid)
{
jshort res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualShortMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Short");
return res;
}
jint JPJavaEnv::GetStaticIntField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jint res = env->functions->GetStaticIntField(env, clazz, fid);
JAVA_CHECK("GetStaticIntField");
return res;
}
jint JPJavaEnv::GetIntField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jint res = env->functions->GetIntField(env, clazz, fid);
JAVA_CHECK("GetIntField");
return res;
}
void JPJavaEnv::SetStaticIntField(jclass clazz, jfieldID fid, jint val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticIntField(env, clazz, fid, val);
JAVA_CHECK("SetStaticIntField");
}
void JPJavaEnv::SetIntField(jobject clazz, jfieldID fid, jint val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetIntField(env, clazz, fid, val);
JAVA_CHECK("SetIntField");
}
jint JPJavaEnv::CallStaticIntMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticIntMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jint JPJavaEnv::CallStaticIntMethod(jclass clazz, jmethodID mid)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticIntMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jint JPJavaEnv::CallIntMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallIntMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jint JPJavaEnv::CallIntMethod(jobject obj, jmethodID mid)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallIntMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jint JPJavaEnv::CallNonvirtualIntMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualIntMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jint JPJavaEnv::CallNonvirtualIntMethod(jobject obj, jclass claz, jmethodID mid)
{
jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualIntMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Int");
return res;
}
jlong JPJavaEnv::GetStaticLongField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jlong res = env->functions->GetStaticLongField(env, clazz, fid);
JAVA_CHECK("GetStaticLongField");
return res;
}
jlong JPJavaEnv::GetLongField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jlong res = env->functions->GetLongField(env, clazz, fid);
JAVA_CHECK("GetLongField");
return res;
}
void JPJavaEnv::SetStaticLongField(jclass clazz, jfieldID fid, jlong val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticLongField(env, clazz, fid, val);
JAVA_CHECK("SetStaticLongField");
}
void JPJavaEnv::SetLongField(jobject clazz, jfieldID fid, jlong val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetLongField(env, clazz, fid, val);
JAVA_CHECK("SetLongField");
}
jlong JPJavaEnv::CallStaticLongMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticLongMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jlong JPJavaEnv::CallStaticLongMethod(jclass clazz, jmethodID mid)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticLongMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jlong JPJavaEnv::CallLongMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallLongMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jlong JPJavaEnv::CallLongMethod(jobject obj, jmethodID mid)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallLongMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jlong JPJavaEnv::CallNonvirtualLongMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualLongMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jlong JPJavaEnv::CallNonvirtualLongMethod(jobject obj, jclass claz, jmethodID mid)
{
jlong res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualLongMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Long");
return res;
}
jfloat JPJavaEnv::GetStaticFloatField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jfloat res = env->functions->GetStaticFloatField(env, clazz, fid);
JAVA_CHECK("GetStaticFloatField");
return res;
}
jfloat JPJavaEnv::GetFloatField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jfloat res = env->functions->GetFloatField(env, clazz, fid);
JAVA_CHECK("GetFloatField");
return res;
}
void JPJavaEnv::SetStaticFloatField(jclass clazz, jfieldID fid, jfloat val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticFloatField(env, clazz, fid, val);
JAVA_CHECK("SetStaticFloatField");
}
void JPJavaEnv::SetFloatField(jobject clazz, jfieldID fid, jfloat val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetFloatField(env, clazz, fid, val);
JAVA_CHECK("SetFloatField");
}
jfloat JPJavaEnv::CallStaticFloatMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticFloatMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jfloat JPJavaEnv::CallStaticFloatMethod(jclass clazz, jmethodID mid)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticFloatMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jfloat JPJavaEnv::CallFloatMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallFloatMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jfloat JPJavaEnv::CallFloatMethod(jobject obj, jmethodID mid)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallFloatMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jfloat JPJavaEnv::CallNonvirtualFloatMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualFloatMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jfloat JPJavaEnv::CallNonvirtualFloatMethod(jobject obj, jclass claz, jmethodID mid)
{
jfloat res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualFloatMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Float");
return res;
}
jdouble JPJavaEnv::GetStaticDoubleField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jdouble res = env->functions->GetStaticDoubleField(env, clazz, fid);
JAVA_CHECK("GetStaticDoubleField");
return res;
}
jdouble JPJavaEnv::GetDoubleField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jdouble res = env->functions->GetDoubleField(env, clazz, fid);
JAVA_CHECK("GetDoubleField");
return res;
}
void JPJavaEnv::SetStaticDoubleField(jclass clazz, jfieldID fid, jdouble val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticDoubleField(env, clazz, fid, val);
JAVA_CHECK("SetStaticDoubleField");
}
void JPJavaEnv::SetDoubleField(jobject clazz, jfieldID fid, jdouble val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetDoubleField(env, clazz, fid, val);
JAVA_CHECK("SetDoubleField");
}
jdouble JPJavaEnv::CallStaticDoubleMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticDoubleMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jdouble JPJavaEnv::CallStaticDoubleMethod(jclass clazz, jmethodID mid)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticDoubleMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jdouble JPJavaEnv::CallDoubleMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallDoubleMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jdouble JPJavaEnv::CallDoubleMethod(jobject obj, jmethodID mid)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallDoubleMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jdouble JPJavaEnv::CallNonvirtualDoubleMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualDoubleMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jdouble JPJavaEnv::CallNonvirtualDoubleMethod(jobject obj, jclass claz, jmethodID mid)
{
jdouble res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualDoubleMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Double");
return res;
}
jchar JPJavaEnv::GetStaticCharField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jchar res = env->functions->GetStaticCharField(env, clazz, fid);
JAVA_CHECK("GetStaticCharField");
return res;
}
jchar JPJavaEnv::GetCharField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jchar res = env->functions->GetCharField(env, clazz, fid);
JAVA_CHECK("GetCharField");
return res;
}
void JPJavaEnv::SetStaticCharField(jclass clazz, jfieldID fid, jchar val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticCharField(env, clazz, fid, val);
JAVA_CHECK("SetStaticCharField");
}
void JPJavaEnv::SetCharField(jobject clazz, jfieldID fid, jchar val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetCharField(env, clazz, fid, val);
JAVA_CHECK("SetCharField");
}
jchar JPJavaEnv::CallStaticCharMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticCharMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jchar JPJavaEnv::CallStaticCharMethod(jclass clazz, jmethodID mid)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticCharMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jchar JPJavaEnv::CallCharMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallCharMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jchar JPJavaEnv::CallCharMethod(jobject obj, jmethodID mid)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallCharMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jchar JPJavaEnv::CallNonvirtualCharMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualCharMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jchar JPJavaEnv::CallNonvirtualCharMethod(jobject obj, jclass claz, jmethodID mid)
{
jchar res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualCharMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Char");
return res;
}
jboolean JPJavaEnv::GetStaticBooleanField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jboolean res = env->functions->GetStaticBooleanField(env, clazz, fid);
JAVA_CHECK("GetStaticBooleanField");
return res;
}
jboolean JPJavaEnv::GetBooleanField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jboolean res = env->functions->GetBooleanField(env, clazz, fid);
JAVA_CHECK("GetBooleanField");
return res;
}
void JPJavaEnv::SetStaticBooleanField(jclass clazz, jfieldID fid, jboolean val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticBooleanField(env, clazz, fid, val);
JAVA_CHECK("SetStaticBooleanField");
}
void JPJavaEnv::SetBooleanField(jobject clazz, jfieldID fid, jboolean val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetBooleanField(env, clazz, fid, val);
JAVA_CHECK("SetBooleanField");
}
jboolean JPJavaEnv::CallStaticBooleanMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticBooleanMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jboolean JPJavaEnv::CallStaticBooleanMethod(jclass clazz, jmethodID mid)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticBooleanMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jboolean JPJavaEnv::CallBooleanMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallBooleanMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jboolean JPJavaEnv::CallBooleanMethod(jobject obj, jmethodID mid)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallBooleanMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jboolean JPJavaEnv::CallNonvirtualBooleanMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualBooleanMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jboolean JPJavaEnv::CallNonvirtualBooleanMethod(jobject obj, jclass claz, jmethodID mid)
{
jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualBooleanMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Boolean");
return res;
}
jobject JPJavaEnv::GetStaticObjectField(jclass clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jobject res = env->functions->GetStaticObjectField(env, clazz, fid);
JAVA_CHECK("GetStaticObjectField");
return res;
}
jobject JPJavaEnv::GetObjectField(jobject clazz, jfieldID fid)
{
JNIEnv* env = getJNIEnv();
jobject res = env->functions->GetObjectField(env, clazz, fid);
JAVA_CHECK("GetObjectField");
return res;
}
void JPJavaEnv::SetStaticObjectField(jclass clazz, jfieldID fid, jobject val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetStaticObjectField(env, clazz, fid, val);
JAVA_CHECK("SetStaticObjectField");
}
void JPJavaEnv::SetObjectField(jobject clazz, jfieldID fid, jobject val)
{
JNIEnv* env = getJNIEnv();
env->functions->SetObjectField(env, clazz, fid, val);
JAVA_CHECK("SetObjectField");
}
jobject JPJavaEnv::CallStaticObjectMethodA(jclass clazz, jmethodID mid, jvalue* val)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticObjectMethodA(env, clazz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jobject JPJavaEnv::CallStaticObjectMethod(jclass clazz, jmethodID mid)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallStaticObjectMethod(env, clazz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jobject JPJavaEnv::CallObjectMethodA(jobject obj, jmethodID mid, jvalue* val)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallObjectMethodA(env, obj, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jobject JPJavaEnv::CallObjectMethod(jobject obj, jmethodID mid)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallObjectMethod(env, obj, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jobject JPJavaEnv::CallNonvirtualObjectMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualObjectMethodA(env, obj, claz, mid, val);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jobject JPJavaEnv::CallNonvirtualObjectMethod(jobject obj, jclass claz, jmethodID mid)
{
jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->CallNonvirtualObjectMethod(env, obj, claz, mid);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("Object");
return res;
}
jbyteArray JPJavaEnv::NewByteArray(jint len)
{
JNIEnv* env = getJNIEnv();
jbyteArray res = env->functions->NewByteArray(env, len);
JAVA_CHECK("NewByteArray");
return res;
}
void JPJavaEnv::SetByteArrayRegion(jbyteArray array, int start, int len, jbyte* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetByteArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetByteArrayRegion");
}
void JPJavaEnv::GetByteArrayRegion(jbyteArray array, int start, int len, jbyte* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetByteArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetByteArrayRegion");
}
jbyte* JPJavaEnv::GetByteArrayElements(jbyteArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jbyte* res = env->functions->GetByteArrayElements(env, array, isCopy);
JAVA_CHECK("GetByteArrayElements");
return res;
}
void JPJavaEnv::ReleaseByteArrayElements(jbyteArray array, jbyte* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseByteArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseByteArrayElements");
}
jshortArray JPJavaEnv::NewShortArray(jint len)
{
JNIEnv* env = getJNIEnv();
jshortArray res = env->functions->NewShortArray(env, len);
JAVA_CHECK("NewShortArray");
return res;
}
void JPJavaEnv::SetShortArrayRegion(jshortArray array, int start, int len, jshort* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetShortArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetShortArrayRegion");
}
void JPJavaEnv::GetShortArrayRegion(jshortArray array, int start, int len, jshort* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetShortArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetShortArrayRegion");
}
jshort* JPJavaEnv::GetShortArrayElements(jshortArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jshort* res = env->functions->GetShortArrayElements(env, array, isCopy);
JAVA_CHECK("GetShortArrayElements");
return res;
}
void JPJavaEnv::ReleaseShortArrayElements(jshortArray array, jshort* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseShortArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseShortArrayElements");
}
jintArray JPJavaEnv::NewIntArray(jint len)
{
JNIEnv* env = getJNIEnv();
jintArray res = env->functions->NewIntArray(env, len);
JAVA_CHECK("NewIntArray");
return res;
}
void JPJavaEnv::SetIntArrayRegion(jintArray array, int start, int len, jint* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetIntArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetIntArrayRegion");
}
void JPJavaEnv::GetIntArrayRegion(jintArray array, int start, int len, jint* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetIntArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetIntArrayRegion");
}
jint* JPJavaEnv::GetIntArrayElements(jintArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jint* res = env->functions->GetIntArrayElements(env, array, isCopy);
JAVA_CHECK("GetIntArrayElements");
return res;
}
void JPJavaEnv::ReleaseIntArrayElements(jintArray array, jint* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseIntArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseIntArrayElements");
}
jlongArray JPJavaEnv::NewLongArray(jint len)
{
JNIEnv* env = getJNIEnv();
jlongArray res = env->functions->NewLongArray(env, len);
JAVA_CHECK("NewLongArray");
return res;
}
void JPJavaEnv::SetLongArrayRegion(jlongArray array, int start, int len, jlong* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetLongArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetLongArrayRegion");
}
void JPJavaEnv::GetLongArrayRegion(jlongArray array, int start, int len, jlong* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetLongArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetLongArrayRegion");
}
jlong* JPJavaEnv::GetLongArrayElements(jlongArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jlong* res = env->functions->GetLongArrayElements(env, array, isCopy);
JAVA_CHECK("GetLongArrayElements");
return res;
}
void JPJavaEnv::ReleaseLongArrayElements(jlongArray array, jlong* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseLongArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseLongArrayElements");
}
jfloatArray JPJavaEnv::NewFloatArray(jint len)
{
JNIEnv* env = getJNIEnv();
jfloatArray res = env->functions->NewFloatArray(env, len);
JAVA_CHECK("NewFloatArray");
return res;
}
void JPJavaEnv::SetFloatArrayRegion(jfloatArray array, int start, int len, jfloat* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetFloatArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetFloatArrayRegion");
}
void JPJavaEnv::GetFloatArrayRegion(jfloatArray array, int start, int len, jfloat* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetFloatArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetFloatArrayRegion");
}
jfloat* JPJavaEnv::GetFloatArrayElements(jfloatArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jfloat* res = env->functions->GetFloatArrayElements(env, array, isCopy);
JAVA_CHECK("GetFloatArrayElements");
return res;
}
void JPJavaEnv::ReleaseFloatArrayElements(jfloatArray array, jfloat* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseFloatArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseFloatArrayElements");
}
jdoubleArray JPJavaEnv::NewDoubleArray(jint len)
{
JNIEnv* env = getJNIEnv();
jdoubleArray res = env->functions->NewDoubleArray(env, len);
JAVA_CHECK("NewDoubleArray");
return res;
}
void JPJavaEnv::SetDoubleArrayRegion(jdoubleArray array, int start, int len, jdouble* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetDoubleArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetDoubleArrayRegion");
}
void JPJavaEnv::GetDoubleArrayRegion(jdoubleArray array, int start, int len, jdouble* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetDoubleArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetDoubleArrayRegion");
}
jdouble* JPJavaEnv::GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jdouble* res = env->functions->GetDoubleArrayElements(env, array, isCopy);
JAVA_CHECK("GetDoubleArrayElements");
return res;
}
void JPJavaEnv::ReleaseDoubleArrayElements(jdoubleArray array, jdouble* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseDoubleArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseDoubleArrayElements");
}
jcharArray JPJavaEnv::NewCharArray(jint len)
{
JNIEnv* env = getJNIEnv();
jcharArray res = env->functions->NewCharArray(env, len);
JAVA_CHECK("NewCharArray");
return res;
}
void JPJavaEnv::SetCharArrayRegion(jcharArray array, int start, int len, jchar* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetCharArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetCharArrayRegion");
}
void JPJavaEnv::GetCharArrayRegion(jcharArray array, int start, int len, jchar* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetCharArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetCharArrayRegion");
}
jchar* JPJavaEnv::GetCharArrayElements(jcharArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jchar* res = env->functions->GetCharArrayElements(env, array, isCopy);
JAVA_CHECK("GetCharArrayElements");
return res;
}
void JPJavaEnv::ReleaseCharArrayElements(jcharArray array, jchar* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseCharArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseCharArrayElements");
}
jbooleanArray JPJavaEnv::NewBooleanArray(jint len)
{
JNIEnv* env = getJNIEnv();
jbooleanArray res = env->functions->NewBooleanArray(env, len);
JAVA_CHECK("NewBooleanArray");
return res;
}
void JPJavaEnv::SetBooleanArrayRegion(jbooleanArray array, int start, int len, jboolean* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->SetBooleanArrayRegion(env, array, start, len, vals);
JAVA_CHECK("SetBooleanArrayRegion");
}
void JPJavaEnv::GetBooleanArrayRegion(jbooleanArray array, int start, int len, jboolean* vals)
{
JNIEnv* env = getJNIEnv();
env->functions->GetBooleanArrayRegion(env, array, start, len, vals);
JAVA_CHECK("GetBooleanArrayRegion");
}
jboolean* JPJavaEnv::GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy)
{
JNIEnv* env = getJNIEnv();
jboolean* res = env->functions->GetBooleanArrayElements(env, array, isCopy);
JAVA_CHECK("GetBooleanArrayElements");
return res;
}
void JPJavaEnv::ReleaseBooleanArrayElements(jbooleanArray array, jboolean* v, jint mode)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseBooleanArrayElements(env, array, v, mode);
JAVA_CHECK("ReleaseBooleanArrayElements");
}
int JPJavaEnv::MonitorEnter(jobject a0)
{ int res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->MonitorEnter(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("MonitorEnter");
return res;
}
int JPJavaEnv::MonitorExit(jobject a0)
{ int res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->MonitorExit(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("MonitorExit");
return res;
}
jmethodID JPJavaEnv::FromReflectedMethod(jobject a0)
{ jmethodID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->FromReflectedMethod(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("FromReflectedMethod");
return res;
}
jfieldID JPJavaEnv::FromReflectedField(jobject a0)
{ jfieldID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->FromReflectedField(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("FromReflectedField");
return res;
}
jclass JPJavaEnv::FindClass(const char* a0)
{ jclass res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->FindClass(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("FindClass");
return res;
}
jboolean JPJavaEnv::IsInstanceOf(jobject a0, jclass a1)
{ jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->IsInstanceOf(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("IsInstanceOf");
return res;
}
jobjectArray JPJavaEnv::NewObjectArray(int a0, jclass a1, jobject a2)
{ jobjectArray res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->NewObjectArray(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("NewObjectArray");
return res;
}
void JPJavaEnv::SetObjectArrayElement(jobjectArray a0, int a1, jobject a2)
{
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
env->functions->SetObjectArrayElement(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("SetObjectArrayElement");
}
void JPJavaEnv::CallStaticVoidMethodA(jclass a0, jmethodID a1, jvalue* a2)
{
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
env->functions->CallStaticVoidMethodA(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("CallStaticVoidMethodA");
}
void JPJavaEnv::CallVoidMethodA(jobject a0, jmethodID a1, jvalue* a2)
{
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
env->functions->CallVoidMethodA(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("CallVoidMethodA");
}
void JPJavaEnv::CallVoidMethod(jobject a0, jmethodID a1)
{
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
env->functions->CallVoidMethod(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("CallVoidMethod");
}
jboolean JPJavaEnv::IsAssignableFrom(jclass a0, jclass a1)
{ jboolean res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->IsAssignableFrom(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("IsAssignableFrom");
return res;
}
jstring JPJavaEnv::NewString(const jchar* a0, int a1)
{ jstring res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->NewString(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("NewString");
return res;
}
jclass JPJavaEnv::GetSuperclass(jclass a0)
{ jclass res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetSuperclass(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetSuperclass");
return res;
}
const char* JPJavaEnv::GetStringUTFChars(jstring a0, jboolean* a1)
{ const char* res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetStringUTFChars(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetStringUTFChars");
return res;
}
void JPJavaEnv::ReleaseStringUTFChars(jstring a0, const char* a1)
{
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
env->functions->ReleaseStringUTFChars(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("ReleaseStringUTFChars");
}
jsize JPJavaEnv::GetArrayLength(jarray a0)
{ jsize res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetArrayLength(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetArrayLength");
return res;
}
jobject JPJavaEnv::GetObjectArrayElement(jobjectArray a0, int a1)
{ jobject res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetObjectArrayElement(env, a0, a1);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetObjectArrayElement");
return res;
}
jclass JPJavaEnv::GetObjectClass(jobject a0)
{ jclass res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetObjectClass(env, a0);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetObjectClass");
return res;
}
jmethodID JPJavaEnv::GetMethodID(jclass a0, char* a1, char* a2)
{ jmethodID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetMethodID(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetMethodID");
return res;
}
jmethodID JPJavaEnv::GetStaticMethodID(jclass a0, char* a1, char* a2)
{ jmethodID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetStaticMethodID(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetStaticMethodID");
return res;
}
jfieldID JPJavaEnv::GetFieldID(jclass a0, char* a1, char* a2)
{ jfieldID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetFieldID(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetFieldID");
return res;
}
jfieldID JPJavaEnv::GetStaticFieldID(jclass a0, char* a1, char* a2)
{ jfieldID res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->GetStaticFieldID(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("GetStaticFieldID");
return res;
}
const jchar* JPJavaEnv::GetStringChars(jstring a0, jboolean* a1)
{
const jchar* res;
JNIEnv* env = getJNIEnv();
res = env->functions->GetStringChars(env, a0, a1);
JAVA_CHECK("GetStringChars");
return res;
}
void JPJavaEnv::ReleaseStringChars(jstring a0, const jchar* a1)
{
JNIEnv* env = getJNIEnv();
env->functions->ReleaseStringChars(env, a0, a1);
JAVA_CHECK("ReleaseStringChars");
}
jsize JPJavaEnv::GetStringLength(jstring a0)
{
jsize res;
JNIEnv* env = getJNIEnv();
res = env->functions->GetStringLength(env, a0);
JAVA_CHECK("GetStringLength");
return res;
}
jclass JPJavaEnv::DefineClass(const char* a0, jobject a1, const jbyte* a2, jsize a3)
{ jclass res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->DefineClass(env, a0, a1, a2, a3);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("DefineClass");
return res;
}
jint JPJavaEnv::RegisterNatives(jclass a0, const JNINativeMethod* a1, jint a2)
{ jint res;
JNIEnv* env = getJNIEnv();
void* _save = JPEnv::getHost()->gotoExternal();
res = env->functions->RegisterNatives(env, a0, a1, a2);
JPEnv::getHost()->returnExternal(_save);
JAVA_CHECK("RegisterNatives");
return res;
}
python-jpype-0.5.4.2/src/native/common/jp_jniutil.cpp 0000666 0001750 0001750 00000065012 11614007722 022050 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
jclass JPJni::s_ClassClass;
jclass JPJni::s_StringClass;
jclass JPJni::s_NoSuchMethodErrorClass;
jclass JPJni::s_RuntimeExceptionClass;
jclass JPJni::s_ProxyClass;
jmethodID JPJni::s_NewProxyInstanceID;
jlong JPJni::s_minByte;
jlong JPJni::s_maxByte;
jlong JPJni::s_minShort;
jlong JPJni::s_maxShort;
jlong JPJni::s_minInt;
jlong JPJni::s_maxInt;
jfloat JPJni::s_minFloat;
jfloat JPJni::s_maxFloat;
static jclass objectClass;
static jmethodID getClassID;
static jmethodID toStringID;
static jmethodID hashCodeID;
static jmethodID getNameID;
static jmethodID getDeclaredFieldsID;
static jmethodID getDeclaredMethodsID;
static jmethodID getInterfacesID;
static jmethodID getFieldsID;
static jmethodID getMethodsID;
static jmethodID getDeclaredConstructorsID;
static jmethodID getConstructorsID;
static jmethodID isInterfaceID;
static jmethodID getClassModifiersID;
static jclass modifierClass;
static jmethodID isStaticID;
static jmethodID isPublicID;
static jmethodID isAbstractID;
static jmethodID isFinalID;
static jclass classLoaderClass;
static jmethodID getSystemClassLoaderID;
static jclass memberClass;
static jmethodID getModifiersID;
static jmethodID getMemberNameID;
static jclass fieldClass;
static jmethodID getTypeID;
static jclass methodClass;
static jclass constructorClass;
static jmethodID getReturnTypeID;
static jmethodID getParameterTypesID;
static jmethodID getConstructorParameterTypesID;
static jclass throwableClass;
static jmethodID getMessageID;
static jmethodID printStackTraceID;
static jclass stringWriterClass;
static jclass printWriterClass;
static jmethodID stringWriterID;
static jmethodID printWriterID;
static jmethodID flushID;
static jclass numberClass;
static jclass booleanClass;
static jclass charClass;
static jclass byteClass;
static jclass shortClass;
static jclass intClass;
static jclass floatClass;
static jmethodID intValueID;
static jmethodID longValueID;
static jmethodID doubleValueID;
static jmethodID booleanValueID;
static jmethodID charValueID;
static jclass JPypeReferenceClass;
static jmethodID JPypeReferenceConstructorMethod;
static jclass JPypeReferenceQueueClass;
static jmethodID JPypeReferenceQueueConstructorMethod;
static jmethodID JPypeReferenceQueueRegisterMethod;
static jmethodID JPypeReferenceQueueStartMethod;
static jmethodID JPypeReferenceQueueRunMethod;
static jmethodID JPypeReferenceQueueStopMethod;
void JPJni::init()
{
objectClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Object;"));
s_StringClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/String;"));
getClassID = JPEnv::getJava()->GetMethodID(objectClass, "getClass", "()Ljava/lang/Class;");
toStringID = JPEnv::getJava()->GetMethodID(objectClass, "toString", "()Ljava/lang/String;");
hashCodeID = JPEnv::getJava()->GetMethodID(objectClass, "hashCode", "()I");
s_ClassClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Class;"));
getNameID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getName", "()Ljava/lang/String;");
getDeclaredFieldsID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getDeclaredFields", "()[Ljava/lang/reflect/Field;");
getDeclaredMethodsID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getDeclaredMethods", "()[Ljava/lang/reflect/Method;");
getMethodsID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getMethods", "()[Ljava/lang/reflect/Method;");
getDeclaredConstructorsID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getDeclaredConstructors", "()[Ljava/lang/reflect/Constructor;");
getConstructorsID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getConstructors", "()[Ljava/lang/reflect/Constructor;");
isInterfaceID = JPEnv::getJava()->GetMethodID(s_ClassClass, "isInterface", "()Z");
getClassModifiersID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getModifiers", "()I");
getInterfacesID = JPEnv::getJava()->GetMethodID(s_ClassClass, "getInterfaces", "()[Ljava/lang/Class;");
modifierClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Modifier;"));
isStaticID = JPEnv::getJava()->GetStaticMethodID(modifierClass, "isStatic", "(I)Z");
isPublicID = JPEnv::getJava()->GetStaticMethodID(modifierClass, "isPublic", "(I)Z");
isAbstractID = JPEnv::getJava()->GetStaticMethodID(modifierClass, "isAbstract", "(I)Z");
isFinalID = JPEnv::getJava()->GetStaticMethodID(modifierClass, "isFinal", "(I)Z");
classLoaderClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/ClassLoader;"));
getSystemClassLoaderID = JPEnv::getJava()->GetStaticMethodID(classLoaderClass, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
s_NoSuchMethodErrorClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/NoSuchMethodError;") );
s_RuntimeExceptionClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/RuntimeException;") );
s_ProxyClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Proxy;") );
s_NewProxyInstanceID = JPEnv::getJava()->GetStaticMethodID(s_ProxyClass, "newProxyInstance", "(Ljava/lang/ClassLoader;[Ljava/lang/Class;Ljava/lang/reflect/InvocationHandler;)Ljava/lang/Object;");
memberClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Member;"));
getModifiersID = JPEnv::getJava()->GetMethodID(memberClass, "getModifiers", "()I");
getMemberNameID = JPEnv::getJava()->GetMethodID(memberClass, "getName", "()Ljava/lang/String;");
fieldClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Field;"));
getTypeID = JPEnv::getJava()->GetMethodID(fieldClass, "getType", "()Ljava/lang/Class;");
methodClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Method;"));
constructorClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/reflect/Constructor;"));
getReturnTypeID = JPEnv::getJava()->GetMethodID(methodClass, "getReturnType", "()Ljava/lang/Class;");
getParameterTypesID = JPEnv::getJava()->GetMethodID(methodClass, "getParameterTypes", "()[Ljava/lang/Class;");
getConstructorParameterTypesID = JPEnv::getJava()->GetMethodID(constructorClass, "getParameterTypes", "()[Ljava/lang/Class;");
throwableClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Throwable;"));
getMessageID = JPEnv::getJava()->GetMethodID(throwableClass, "getMessage", "()Ljava/lang/String;");
printStackTraceID = JPEnv::getJava()->GetMethodID(throwableClass, "printStackTrace", "(Ljava/io/PrintWriter;)V");
stringWriterClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/io/StringWriter;"));
printWriterClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/io/PrintWriter;"));
stringWriterID = JPEnv::getJava()->GetMethodID(stringWriterClass, "", "()V");
printWriterID = JPEnv::getJava()->GetMethodID(printWriterClass, "", "(Ljava/io/Writer;)V");
flushID = JPEnv::getJava()->GetMethodID(printWriterClass, "flush", "()V");
numberClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Number;"));
booleanClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Boolean;"));
charClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Character;"));
intValueID = JPEnv::getJava()->GetMethodID(numberClass, "intValue", "()I");
longValueID = JPEnv::getJava()->GetMethodID(numberClass, "longValue", "()J");
doubleValueID = JPEnv::getJava()->GetMethodID(numberClass, "doubleValue", "()D");
booleanValueID = JPEnv::getJava()->GetMethodID(booleanClass, "booleanValue", "()Z");
charValueID = JPEnv::getJava()->GetMethodID(charClass, "charValue", "()C");
byteClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Byte;"));
shortClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Short;"));
intClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Integer;"));
floatClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Float;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(byteClass, "MIN_VALUE", "B");
s_minByte = JPEnv::getJava()->GetStaticByteField(byteClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(byteClass, "MAX_VALUE", "B");
s_maxByte = JPEnv::getJava()->GetStaticByteField(byteClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(shortClass, "MIN_VALUE", "S");
s_minShort = JPEnv::getJava()->GetStaticShortField(shortClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(shortClass, "MAX_VALUE", "S");
s_maxShort = JPEnv::getJava()->GetStaticShortField(shortClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(intClass, "MIN_VALUE", "I");
s_minInt = JPEnv::getJava()->GetStaticIntField(intClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(intClass, "MAX_VALUE", "I");
s_maxInt = JPEnv::getJava()->GetStaticIntField(intClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(floatClass, "MIN_VALUE", "F");
s_minFloat = JPEnv::getJava()->GetStaticFloatField(floatClass, fid);
fid = JPEnv::getJava()->GetStaticFieldID(floatClass, "MAX_VALUE", "F");
s_maxFloat = JPEnv::getJava()->GetStaticFloatField(floatClass, fid);
}
string JPJni::asciiFromJava(jstring str)
{
const char* cstr = NULL;
jboolean isCopy;
cstr = JPEnv::getJava()->GetStringUTFChars(str, &isCopy);
int length = JPEnv::getJava()->GetStringLength(str);
string res;
for (int i = 0; i < length; i++)
{
res += (char)cstr[i];
}
JPEnv::getJava()->ReleaseStringUTFChars(str, cstr);
return res;
}
JCharString JPJni::unicodeFromJava(jstring str)
{
const jchar* cstr = NULL;
jboolean isCopy;
cstr = JPEnv::getJava()->GetStringChars(str, &isCopy);
JCharString res = cstr;
JPEnv::getJava()->ReleaseStringChars(str, cstr);
return res;
}
jstring JPJni::javaStringFromJCharString(JCharString& wstr)
{
jstring result = JPEnv::getJava()->NewString(wstr.c_str(), (jint)wstr.length());
return result;
}
JPTypeName JPJni::getClassName(jobject o)
{
if (o == NULL)
{
return JPTypeName::fromSimple("java.lang.Object");
}
JPCleaner cleaner;
jclass c = getClass(o);
cleaner.addLocal(c);
return JPJni::getName(c);
}
jclass JPJni::getClass(jobject o)
{
return (jclass)JPEnv::getJava()->CallObjectMethod(o, getClassID);
}
jstring JPJni::toString(jobject o)
{
jstring str = (jstring)JPEnv::getJava()->CallObjectMethod(o, toStringID);
return str;
}
static string convertToSimpleName(jclass c)
{
JPCleaner cleaner;
jstring jname = (jstring)JPEnv::getJava()->CallObjectMethod(c, getNameID);
cleaner.addLocal(jname);
string name = JPJni::asciiFromJava(jname);
// Class.getName returns something weird for arrays ...
if (name[0] == '[')
{
// perform a little cleanup of the name ...
unsigned int arrayCount = 0;
for (unsigned int i = 0; i < name.length(); i++)
{
if (name[i] == '[')
{
arrayCount++;
}
}
name = name.substr(arrayCount, name.length()-(arrayCount));
// Now, let's convert the "native" part
switch(name[0])
{
case 'B' :
name = "byte";
break;
case 'S' :
name = "short";
break;
case 'I' :
name = "int";
break;
case 'J' :
name = "long";
break;
case 'F' :
name = "float";
break;
case 'D' :
name = "double";
break;
case 'C' :
name = "char";
break;
case 'Z' :
name = "boolean";
break;
case 'L' :
name = name.substr(1, name.length()-2);
for (unsigned int i = 0; i < name.length(); i++)
{
if (name[i] == '/')
{
name[i] = '.';
}
}
break;
}
for (unsigned int j = 0; j < arrayCount; j++)
{
name = name + "[]";
}
}
return name;
}
bool JPJni::isInterface(jclass clazz)
{
jboolean b = JPEnv::getJava()->CallBooleanMethod(clazz, isInterfaceID);
return (b ? true : false);
}
bool JPJni::isAbstract(jclass clazz)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(clazz, getClassModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isAbstractID, &modif);
return (res ? true : false);
}
long JPJni::getClassModifiers(jclass clazz)
{
long res = JPEnv::getJava()->CallIntMethod(clazz, getClassModifiersID);
return res;
}
bool JPJni::isFinal(jclass clazz)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(clazz, getClassModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isFinalID, &modif);
return (res ? true : false);
}
JPTypeName JPJni::getName(jclass clazz)
{
string simpleName = convertToSimpleName(clazz);
return JPTypeName::fromSimple(simpleName.c_str());
}
vector JPJni::getInterfaces(jclass clazz)
{
JPCleaner cleaner;
jobjectArray interfaces = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getInterfacesID);
cleaner.addLocal(interfaces);
int len = JPEnv::getJava()->GetArrayLength(interfaces);
vector res;
for (int i = 0; i < len; i++)
{
jclass c = (jclass)JPEnv::getJava()->GetObjectArrayElement(interfaces, i);
res.push_back(c);
}
return res;
}
vector JPJni::getDeclaredFields(jclass clazz)
{
JPCleaner cleaner;
jobjectArray fields = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getDeclaredFieldsID);
cleaner.addLocal(fields);
int len = JPEnv::getJava()->GetArrayLength(fields);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(fields, i);
res.push_back(c);
}
return res;
}
vector JPJni::getFields(jclass clazz)
{
JPCleaner cleaner;
jobjectArray fields = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getFieldsID);
cleaner.addLocal(fields);
int len = JPEnv::getJava()->GetArrayLength(fields);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(fields, i);
res.push_back(c);
}
return res;
}
vector JPJni::getDeclaredMethods(jclass clazz)
{
JPCleaner cleaner;
jobjectArray methods = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getDeclaredMethodsID);
cleaner.addLocal(methods);
int len = JPEnv::getJava()->GetArrayLength(methods);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(methods, i);
res.push_back(c);
}
return res;
}
vector JPJni::getDeclaredConstructors(jclass clazz)
{
JPCleaner cleaner;
jobjectArray methods = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getDeclaredConstructorsID);
cleaner.addLocal(methods);
int len = JPEnv::getJava()->GetArrayLength(methods);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(methods, i);
res.push_back(c);
}
return res;
}
vector JPJni::getConstructors(jclass clazz)
{
JPCleaner cleaner;
jobjectArray methods = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getConstructorsID);
cleaner.addLocal(methods);
int len = JPEnv::getJava()->GetArrayLength(methods);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(methods, i);
res.push_back(c);
}
return res;
}
vector JPJni::getMethods(jclass clazz)
{
JPCleaner cleaner;
jobjectArray methods = (jobjectArray)JPEnv::getJava()->CallObjectMethod(clazz, getMethodsID);
cleaner.addLocal(methods);
int len = JPEnv::getJava()->GetArrayLength(methods);
vector res;
for (int i = 0; i < len; i++)
{
jobject c = JPEnv::getJava()->GetObjectArrayElement(methods, i);
res.push_back(c);
}
return res;
}
jobject JPJni::getSystemClassLoader()
{
return JPEnv::getJava()->CallStaticObjectMethod(classLoaderClass, getSystemClassLoaderID) ;
}
string JPJni::getMemberName(jobject o)
{
JPCleaner cleaner;
jstring name = (jstring)JPEnv::getJava()->CallObjectMethod(o, getMemberNameID);
cleaner.addLocal(name);
string simpleName = JPJni::asciiFromJava(name);
return simpleName;
}
bool JPJni::isMemberPublic(jobject o)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(o, getModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isPublicID, &modif);
return (res ? true : false);
}
bool JPJni::isMemberStatic(jobject o)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(o, getModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isStaticID, &modif);
return (res ? true : false);
}
bool JPJni::isMemberFinal(jobject o)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(o, getModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isFinalID, &modif);
return (res ? true : false);
}
bool JPJni::isMemberAbstract(jobject o)
{
jvalue modif;
modif.i = JPEnv::getJava()->CallIntMethod(o, getModifiersID);
jboolean res = JPEnv::getJava()->CallStaticBooleanMethodA(modifierClass, isAbstractID, &modif);
return (res ? true : false);
}
jint JPJni::hashCode(jobject obj)
{
jint res = JPEnv::getJava()->CallIntMethod(obj, hashCodeID);
return res;
}
JPTypeName JPJni::getType(jobject fld)
{
TRACE_IN("JPJni::getType");
JPCleaner cleaner;
jclass c = (jclass)JPEnv::getJava()->CallObjectMethod(fld, getTypeID);
cleaner.addLocal(c);
return JPJni::getName(c);
TRACE_OUT;
}
JPTypeName JPJni::getReturnType(jobject o)
{
JPCleaner cleaner;
jclass c = (jclass)JPEnv::getJava()->CallObjectMethod(o, getReturnTypeID);
cleaner.addLocal(c);
return JPJni::getName(c);
}
vector JPJni::getParameterTypes(jobject o, bool isConstructor)
{
JPCleaner cleaner;
vector args;
jobjectArray types ;
if (isConstructor)
{
types = (jobjectArray)JPEnv::getJava()->CallObjectMethod(o, getConstructorParameterTypesID);
}
else
{
types = (jobjectArray)JPEnv::getJava()->CallObjectMethod(o, getParameterTypesID);
}
cleaner.addLocal(types);
int len = JPEnv::getJava()->GetArrayLength(types);
for (int i = 0; i < len; i++)
{
jclass c = (jclass)JPEnv::getJava()->GetObjectArrayElement(types, i);
cleaner.addLocal(c);
JPTypeName name = JPJni::getName(c);
args.push_back(name);
}
return args;
}
bool JPJni::isConstructor(jobject obj)
{
jboolean r = JPEnv::getJava()->IsInstanceOf(obj, constructorClass);
if (r)
{
return true;
}
return false;
}
string JPJni::getStackTrace(jthrowable th)
{
JPCleaner cleaner;
jobject strWriter = JPEnv::getJava()->NewObject(stringWriterClass, stringWriterID);
cleaner.addLocal(strWriter);
jvalue v;
v.l = strWriter;
jobject printWriter = JPEnv::getJava()->NewObjectA(printWriterClass, printWriterID, &v);
cleaner.addLocal(printWriter);
v.l = printWriter;
JPEnv::getJava()->CallVoidMethodA(th, printStackTraceID, &v);
JPEnv::getJava()->CallVoidMethod(printWriter, flushID);
jstring res = JPJni::toString(strWriter);
cleaner.addLocal(res);
return JPJni::asciiFromJava(res);
}
string JPJni::getMessage(jthrowable th)
{
JPCleaner cleaner;
jstring jstr = (jstring)JPEnv::getJava()->CallObjectMethod(th, getMessageID);
cleaner.addLocal(jstr);
return JPJni::asciiFromJava(jstr);
}
bool JPJni::isThrowable(jclass c)
{
jboolean res = JPEnv::getJava()->IsAssignableFrom(c, throwableClass);
if (res)
{
return true;
}
return false;
}
long JPJni::intValue(jobject obj)
{
return JPEnv::getJava()->CallIntMethod(obj, intValueID);
}
jlong JPJni::longValue(jobject obj)
{
return JPEnv::getJava()->CallLongMethod(obj, longValueID);
}
double JPJni::doubleValue(jobject obj)
{
return JPEnv::getJava()->CallDoubleMethod(obj, doubleValueID);
}
bool JPJni::booleanValue(jobject obj)
{
return JPEnv::getJava()->CallBooleanMethod(obj, booleanValueID) ? true : false;
}
jchar JPJni::charValue(jobject obj)
{
return JPEnv::getJava()->CallCharMethod(obj, charValueID);
}
jclass JPJni::getByteClass()
{
jclass byteClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Byte;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(byteClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(byteClass, fid);
JPEnv::getJava()->DeleteLocalRef(byteClass);
return res;
}
jclass JPJni::getShortClass()
{
jclass shortClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Short;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(shortClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(shortClass, fid);
JPEnv::getJava()->DeleteLocalRef(shortClass);
return res;
}
jclass JPJni::getIntegerClass()
{
jclass intClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Integer;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(intClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(intClass, fid);
JPEnv::getJava()->DeleteLocalRef(intClass);
return res;
}
jclass JPJni::getLongClass()
{
jclass longClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Long;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(longClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(longClass, fid);
JPEnv::getJava()->DeleteLocalRef(longClass);
return res;
}
jclass JPJni::getFloatClass()
{
jclass floatClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Float;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(floatClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(floatClass, fid);
JPEnv::getJava()->DeleteLocalRef(floatClass);
return res;
}
jclass JPJni::getDoubleClass()
{
jclass doubleClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Double;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(doubleClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(doubleClass, fid);
JPEnv::getJava()->DeleteLocalRef(doubleClass);
return res;
}
jclass JPJni::getCharacterClass()
{
jclass charClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Character;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(charClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(charClass, fid);
JPEnv::getJava()->DeleteLocalRef(charClass);
return res;
}
jclass JPJni::getBooleanClass()
{
jclass booleanClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Boolean;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(booleanClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(booleanClass, fid);
JPEnv::getJava()->DeleteLocalRef(booleanClass);
return res;
}
jclass JPJni::getVoidClass()
{
jclass voidClass= (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljava/lang/Void;"));
jfieldID fid = JPEnv::getJava()->GetStaticFieldID(voidClass, "TYPE", "Ljava/lang/Class;");
jclass res = (jclass)JPEnv::getJava()->GetStaticObjectField(voidClass, fid);
JPEnv::getJava()->DeleteLocalRef(voidClass);
return res;
}
void JPJni::startJPypeReferenceQueue(bool useJavaThread)
{
JPCleaner cleaner;
JPypeReferenceQueueClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljpype/ref/JPypeReferenceQueue;"));
JPypeReferenceQueueConstructorMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "", "()V");
JPypeReferenceQueueRegisterMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "registerRef", "(Ljpype/ref/JPypeReference;J)V");
JPypeReferenceQueueStartMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "startManaging", "()V");
JPypeReferenceQueueRunMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "run", "()V");
JPypeReferenceQueueStopMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceQueueClass, "stop", "()V");
JPypeReferenceClass = (jclass)JPEnv::getJava()->NewGlobalRef(JPEnv::getJava()->FindClass("Ljpype/ref/JPypeReference;"));
JPypeReferenceConstructorMethod = JPEnv::getJava()->GetMethodID(JPypeReferenceClass, "", "(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V");
jobject obj = JPEnv::getJava()->NewObject(JPypeReferenceQueueClass, JPypeReferenceQueueConstructorMethod);
cleaner.addLocal(obj);
JPEnv::getJava()->setReferenceQueue(obj);
if (useJavaThread)
{
JPEnv::getJava()->CallVoidMethod(obj, JPypeReferenceQueueStartMethod);
}
else
{
JPEnv::getJava()->CallVoidMethod(obj, JPypeReferenceQueueRunMethod);
}
}
void JPJni::stopJPypeReferenceQueue()
{
JPEnv::getJava()->CallVoidMethod(JPEnv::getJava()->getReferenceQueue(), JPypeReferenceQueueStopMethod);
}
void JPJni::registerRef(jobject refQueue, jobject obj, jlong hostRef)
{
TRACE_IN("JPJni::registerRef");
// create the ref ...
jvalue args[2];
args[0].l = obj;
args[1].l = refQueue;
JPCleaner cleaner;
jobject refObj = JPEnv::getJava()->NewObjectA(JPypeReferenceClass, JPypeReferenceConstructorMethod, args);
cleaner.addLocal(refObj);
args[0].l = refObj;
args[1].j = hostRef;
JPEnv::getJava()->CallVoidMethodA(refQueue, JPypeReferenceQueueRegisterMethod, args);
TRACE_OUT;
}
python-jpype-0.5.4.2/src/native/common/jp_object.cpp 0000666 0001750 0001750 00000004755 11614007722 021647 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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
JPObject::JPObject(JPTypeName& c, jobject o)
{
m_Class = JPTypeManager::findClass(c);
m_Object = JPEnv::getJava()->NewGlobalRef(o);
}
JPObject::JPObject(JPClass* c, jobject o)
{
m_Class = c;
m_Object = JPEnv::getJava()->NewGlobalRef(o);
}
JPObject::~JPObject()
{
JPEnv::getJava()->DeleteGlobalRef(m_Object);
}
JCharString JPObject::toString()
{
if (m_Object == NULL)
{
static const char* value = "null";
jchar res[5];
res[4] = 0;
for (int i = 0; value[i] != 0; i++)
{
res[i] = value[i];
}
return res;
}
JPCleaner cleaner;
jstring jval = JPJni::toString(m_Object);
cleaner.addLocal(jval);
JCharString result = JPJni::unicodeFromJava(jval);
return result;
}
HostRef* JPObject::getAttribute(string name)
{
TRACE_IN("JPObject::getAttribute");
TRACE1(name);
JPCleaner cleaner;
// instance fields ...
JPField* fld = m_Class->getInstanceField(name);
if (fld != NULL)
{
return fld->getAttribute(m_Object);
}
// static fields ...
fld = m_Class->getStaticField(name);
if (fld != NULL)
{
return fld->getStaticAttribute();
}
JPEnv::getHost()->setAttributeError(name.c_str());
JPEnv::getHost()->raise("getAttribute");
return NULL; // never reached ...
TRACE_OUT;
}
void JPObject::setAttribute(string name, HostRef* val)
{
// instance fields ...
JPField* fld = m_Class->getInstanceField(name);
if (fld != NULL)
{
fld->setAttribute(m_Object, val);
return;
}
// static fields ...
fld = m_Class->getStaticField(name);
if (fld != NULL)
{
fld->setStaticAttribute(val);
return;
}
JPEnv::getHost()->setAttributeError(name.c_str());
JPEnv::getHost()->raise("setAttribute");
}
python-jpype-0.5.4.2/src/native/common/jp_referencequeue.cpp 0000666 0001750 0001750 00000055311 11614007722 023376 0 ustar takaki takaki #include
jbyte JPypeReferenceQueue[] = {
(jbyte)0xCA,(jbyte)0xFE,(jbyte)0xBA,(jbyte)0xBE,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x2E,(jbyte)0x00,(jbyte)0x62,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1D,(jbyte)0x6A,(jbyte)0x70,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x2F,(jbyte)0x72
,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x4A,(jbyte)0x50,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x51,(jbyte)0x75,(jbyte)0x65
,(jbyte)0x75,(jbyte)0x65,(jbyte)0x07,(jbyte)0x00,(jbyte)0x01,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65
,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x51,(jbyte)0x75,(jbyte)0x65,(jbyte)0x75,(jbyte)0x65,(jbyte)0x07,(jbyte)0x00,(jbyte)0x03,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x12,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x52,(jbyte)0x75,(jbyte)0x6E,(jbyte)0x6E,(jbyte)0x61,(jbyte)0x62,(jbyte)0x6C,(jbyte)0x65
,(jbyte)0x07,(jbyte)0x00,(jbyte)0x05,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x6D,(jbyte)0x48,(jbyte)0x6F,(jbyte)0x73,(jbyte)0x74,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65
,(jbyte)0x73,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x75,(jbyte)0x74,(jbyte)0x69,(jbyte)0x6C,(jbyte)0x2F,(jbyte)0x53,(jbyte)0x65,(jbyte)0x74,(jbyte)0x3B,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x08,(jbyte)0x6D,(jbyte)0x53,(jbyte)0x74,(jbyte)0x6F,(jbyte)0x70,(jbyte)0x70,(jbyte)0x65,(jbyte)0x64,(jbyte)0x01,(jbyte)0x00,(jbyte)0x01,(jbyte)0x5A,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x6D,(jbyte)0x51,(jbyte)0x75
,(jbyte)0x65,(jbyte)0x75,(jbyte)0x65,(jbyte)0x54,(jbyte)0x68,(jbyte)0x72,(jbyte)0x65,(jbyte)0x61,(jbyte)0x64,(jbyte)0x01,(jbyte)0x00,(jbyte)0x12,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61
,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x54,(jbyte)0x68,(jbyte)0x72,(jbyte)0x65,(jbyte)0x61,(jbyte)0x64,(jbyte)0x3B,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x6D,(jbyte)0x51,(jbyte)0x75,(jbyte)0x65,(jbyte)0x75,(jbyte)0x65,(jbyte)0x53
,(jbyte)0x74,(jbyte)0x6F,(jbyte)0x70,(jbyte)0x4D,(jbyte)0x75,(jbyte)0x74,(jbyte)0x65,(jbyte)0x78,(jbyte)0x01,(jbyte)0x00,(jbyte)0x12,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E
,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x4F,(jbyte)0x62,(jbyte)0x6A,(jbyte)0x65,(jbyte)0x63,(jbyte)0x74,(jbyte)0x3B,(jbyte)0x01,(jbyte)0x00,(jbyte)0x06,(jbyte)0x3C,(jbyte)0x69,(jbyte)0x6E,(jbyte)0x69,(jbyte)0x74,(jbyte)0x3E,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x03,(jbyte)0x28,(jbyte)0x29,(jbyte)0x56,(jbyte)0x01,(jbyte)0x00,(jbyte)0x04,(jbyte)0x43,(jbyte)0x6F,(jbyte)0x64,(jbyte)0x65,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x00,(jbyte)0x10,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00
,(jbyte)0x12,(jbyte)0x01,(jbyte)0x00,(jbyte)0x11,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x75,(jbyte)0x74,(jbyte)0x69,(jbyte)0x6C,(jbyte)0x2F,(jbyte)0x48,(jbyte)0x61,(jbyte)0x73,(jbyte)0x68,(jbyte)0x53,(jbyte)0x65
,(jbyte)0x74,(jbyte)0x07,(jbyte)0x00,(jbyte)0x14,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x15,(jbyte)0x00,(jbyte)0x12,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x07,(jbyte)0x00,(jbyte)0x08,(jbyte)0x09,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x17,(jbyte)0x0C
,(jbyte)0x00,(jbyte)0x09,(jbyte)0x00,(jbyte)0x0A,(jbyte)0x09,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x19,(jbyte)0x01,(jbyte)0x00,(jbyte)0x10,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E
,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x4F,(jbyte)0x62,(jbyte)0x6A,(jbyte)0x65,(jbyte)0x63,(jbyte)0x74,(jbyte)0x07,(jbyte)0x00,(jbyte)0x1B,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x1C,(jbyte)0x00,(jbyte)0x12,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x00
,(jbyte)0x0E,(jbyte)0x09,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x1E,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x4C,(jbyte)0x69,(jbyte)0x6E,(jbyte)0x65,(jbyte)0x4E,(jbyte)0x75,(jbyte)0x6D,(jbyte)0x62,(jbyte)0x65,(jbyte)0x72,(jbyte)0x54
,(jbyte)0x61,(jbyte)0x62,(jbyte)0x6C,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x12,(jbyte)0x4C,(jbyte)0x6F,(jbyte)0x63,(jbyte)0x61,(jbyte)0x6C,(jbyte)0x56,(jbyte)0x61,(jbyte)0x72,(jbyte)0x69,(jbyte)0x61,(jbyte)0x62,(jbyte)0x6C,(jbyte)0x65
,(jbyte)0x54,(jbyte)0x61,(jbyte)0x62,(jbyte)0x6C,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x04,(jbyte)0x74,(jbyte)0x68,(jbyte)0x69,(jbyte)0x73,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1F,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x70,(jbyte)0x79,(jbyte)0x70
,(jbyte)0x65,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x4A,(jbyte)0x50,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65
,(jbyte)0x51,(jbyte)0x75,(jbyte)0x65,(jbyte)0x75,(jbyte)0x65,(jbyte)0x3B,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0B,(jbyte)0x72,(jbyte)0x65,(jbyte)0x67,(jbyte)0x69,(jbyte)0x73,(jbyte)0x74,(jbyte)0x65,(jbyte)0x72,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66
,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1E,(jbyte)0x28,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x70,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x4A,(jbyte)0x50,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65
,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x3B,(jbyte)0x4A,(jbyte)0x29,(jbyte)0x56,(jbyte)0x01,(jbyte)0x00,(jbyte)0x18,(jbyte)0x6A,(jbyte)0x70,(jbyte)0x79,(jbyte)0x70
,(jbyte)0x65,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x4A,(jbyte)0x50,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65
,(jbyte)0x07,(jbyte)0x00,(jbyte)0x26,(jbyte)0x01,(jbyte)0x00,(jbyte)0x10,(jbyte)0x73,(jbyte)0x65,(jbyte)0x74,(jbyte)0x48,(jbyte)0x6F,(jbyte)0x73,(jbyte)0x74,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E
,(jbyte)0x63,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x04,(jbyte)0x28,(jbyte)0x4A,(jbyte)0x29,(jbyte)0x56,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x28,(jbyte)0x00,(jbyte)0x29,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x27,(jbyte)0x00,(jbyte)0x2A,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x75,(jbyte)0x74,(jbyte)0x69,(jbyte)0x6C,(jbyte)0x2F,(jbyte)0x53,(jbyte)0x65,(jbyte)0x74,(jbyte)0x07,(jbyte)0x00,(jbyte)0x2C,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x03,(jbyte)0x61,(jbyte)0x64,(jbyte)0x64,(jbyte)0x01,(jbyte)0x00,(jbyte)0x15,(jbyte)0x28,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x4F
,(jbyte)0x62,(jbyte)0x6A,(jbyte)0x65,(jbyte)0x63,(jbyte)0x74,(jbyte)0x3B,(jbyte)0x29,(jbyte)0x5A,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x2E,(jbyte)0x00,(jbyte)0x2F,(jbyte)0x0B,(jbyte)0x00,(jbyte)0x2D,(jbyte)0x00,(jbyte)0x30,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x03,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1A,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x70,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x4A,(jbyte)0x50
,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x3B,(jbyte)0x01,(jbyte)0x00,(jbyte)0x07,(jbyte)0x68,(jbyte)0x6F,(jbyte)0x73,(jbyte)0x74
,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x01,(jbyte)0x00,(jbyte)0x01,(jbyte)0x4A,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x73,(jbyte)0x74,(jbyte)0x61,(jbyte)0x72,(jbyte)0x74,(jbyte)0x4D,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x61,(jbyte)0x67
,(jbyte)0x69,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x01,(jbyte)0x00,(jbyte)0x10,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x54,(jbyte)0x68,(jbyte)0x72,(jbyte)0x65
,(jbyte)0x61,(jbyte)0x64,(jbyte)0x07,(jbyte)0x00,(jbyte)0x37,(jbyte)0x01,(jbyte)0x00,(jbyte)0x17,(jbyte)0x28,(jbyte)0x4C,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F
,(jbyte)0x52,(jbyte)0x75,(jbyte)0x6E,(jbyte)0x6E,(jbyte)0x61,(jbyte)0x62,(jbyte)0x6C,(jbyte)0x65,(jbyte)0x3B,(jbyte)0x29,(jbyte)0x56,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x00,(jbyte)0x39,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x38,(jbyte)0x00
,(jbyte)0x3A,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x0B,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x09,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x3C,(jbyte)0x01,(jbyte)0x00,(jbyte)0x05,(jbyte)0x73,(jbyte)0x74,(jbyte)0x61,(jbyte)0x72,(jbyte)0x74,(jbyte)0x0C
,(jbyte)0x00,(jbyte)0x3E,(jbyte)0x00,(jbyte)0x10,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x38,(jbyte)0x00,(jbyte)0x3F,(jbyte)0x01,(jbyte)0x00,(jbyte)0x03,(jbyte)0x72,(jbyte)0x75,(jbyte)0x6E,(jbyte)0x05,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0xFA,(jbyte)0x01,(jbyte)0x00,(jbyte)0x06,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6D,(jbyte)0x6F,(jbyte)0x76,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1C,(jbyte)0x28,(jbyte)0x4A,(jbyte)0x29,(jbyte)0x4C
,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x72,(jbyte)0x65,(jbyte)0x66,(jbyte)0x2F,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65
,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x3B,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x44,(jbyte)0x00,(jbyte)0x45,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x46,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x44,(jbyte)0x00,(jbyte)0x2F,(jbyte)0x0B
,(jbyte)0x00,(jbyte)0x2D,(jbyte)0x00,(jbyte)0x48,(jbyte)0x01,(jbyte)0x00,(jbyte)0x10,(jbyte)0x67,(jbyte)0x65,(jbyte)0x74,(jbyte)0x48,(jbyte)0x6F,(jbyte)0x73,(jbyte)0x74,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65
,(jbyte)0x6E,(jbyte)0x63,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x03,(jbyte)0x28,(jbyte)0x29,(jbyte)0x4A,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x4A,(jbyte)0x00,(jbyte)0x4B,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x27,(jbyte)0x00,(jbyte)0x4C,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x13,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6D,(jbyte)0x6F,(jbyte)0x76,(jbyte)0x65,(jbyte)0x48,(jbyte)0x6F,(jbyte)0x73,(jbyte)0x74,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63
,(jbyte)0x65,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x4E,(jbyte)0x00,(jbyte)0x29,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x4F,(jbyte)0x05,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF,(jbyte)0xFF
,(jbyte)0x01,(jbyte)0x00,(jbyte)0x09,(jbyte)0x6E,(jbyte)0x6F,(jbyte)0x74,(jbyte)0x69,(jbyte)0x66,(jbyte)0x79,(jbyte)0x41,(jbyte)0x6C,(jbyte)0x6C,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x53,(jbyte)0x00,(jbyte)0x10,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x1C
,(jbyte)0x00,(jbyte)0x54,(jbyte)0x01,(jbyte)0x00,(jbyte)0x1E,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x49,(jbyte)0x6E,(jbyte)0x74,(jbyte)0x65,(jbyte)0x72
,(jbyte)0x72,(jbyte)0x75,(jbyte)0x70,(jbyte)0x74,(jbyte)0x65,(jbyte)0x64,(jbyte)0x45,(jbyte)0x78,(jbyte)0x63,(jbyte)0x65,(jbyte)0x70,(jbyte)0x74,(jbyte)0x69,(jbyte)0x6F,(jbyte)0x6E,(jbyte)0x07,(jbyte)0x00,(jbyte)0x56,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x04,(jbyte)0x73,(jbyte)0x74,(jbyte)0x6F,(jbyte)0x70,(jbyte)0x05,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x13,(jbyte)0x88,(jbyte)0x01,(jbyte)0x00,(jbyte)0x04,(jbyte)0x77,(jbyte)0x61,(jbyte)0x69
,(jbyte)0x74,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x5B,(jbyte)0x00,(jbyte)0x29,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x1C,(jbyte)0x00,(jbyte)0x5C,(jbyte)0x01,(jbyte)0x00,(jbyte)0x02,(jbyte)0x65,(jbyte)0x78,(jbyte)0x01,(jbyte)0x00,(jbyte)0x20,(jbyte)0x4C
,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x2F,(jbyte)0x6C,(jbyte)0x61,(jbyte)0x6E,(jbyte)0x67,(jbyte)0x2F,(jbyte)0x49,(jbyte)0x6E,(jbyte)0x74,(jbyte)0x65,(jbyte)0x72,(jbyte)0x72,(jbyte)0x75,(jbyte)0x70,(jbyte)0x74,(jbyte)0x65
,(jbyte)0x64,(jbyte)0x45,(jbyte)0x78,(jbyte)0x63,(jbyte)0x65,(jbyte)0x70,(jbyte)0x74,(jbyte)0x69,(jbyte)0x6F,(jbyte)0x6E,(jbyte)0x3B,(jbyte)0x01,(jbyte)0x00,(jbyte)0x0A,(jbyte)0x53,(jbyte)0x6F,(jbyte)0x75,(jbyte)0x72,(jbyte)0x63,(jbyte)0x65
,(jbyte)0x46,(jbyte)0x69,(jbyte)0x6C,(jbyte)0x65,(jbyte)0x01,(jbyte)0x00,(jbyte)0x18,(jbyte)0x4A,(jbyte)0x50,(jbyte)0x79,(jbyte)0x70,(jbyte)0x65,(jbyte)0x52,(jbyte)0x65,(jbyte)0x66,(jbyte)0x65,(jbyte)0x72,(jbyte)0x65,(jbyte)0x6E,(jbyte)0x63
,(jbyte)0x65,(jbyte)0x51,(jbyte)0x75,(jbyte)0x65,(jbyte)0x75,(jbyte)0x65,(jbyte)0x2E,(jbyte)0x6A,(jbyte)0x61,(jbyte)0x76,(jbyte)0x61,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x06,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x07,(jbyte)0x00,(jbyte)0x08,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x09,(jbyte)0x00,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00
,(jbyte)0x02,(jbyte)0x00,(jbyte)0x0B,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x00,(jbyte)0x0E,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x06,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00
,(jbyte)0x0F,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x5A,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x20,(jbyte)0x2A
,(jbyte)0xB7,(jbyte)0x00,(jbyte)0x13,(jbyte)0x2A,(jbyte)0xBB,(jbyte)0x00,(jbyte)0x15,(jbyte)0x59,(jbyte)0xB7,(jbyte)0x00,(jbyte)0x16,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x18,(jbyte)0x2A,(jbyte)0x03,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x1A,(jbyte)0x2A
,(jbyte)0xBB,(jbyte)0x00,(jbyte)0x1C,(jbyte)0x59,(jbyte)0xB7,(jbyte)0x00,(jbyte)0x1D,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x1F,(jbyte)0xB1,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00
,(jbyte)0x16,(jbyte)0x00,(jbyte)0x05,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x0F,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x14,(jbyte)0x00,(jbyte)0x13,(jbyte)0x00
,(jbyte)0x1F,(jbyte)0x00,(jbyte)0x0D,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x23,(jbyte)0x00
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x24,(jbyte)0x00,(jbyte)0x25,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x57,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x11,(jbyte)0x2B,(jbyte)0x20,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x2B,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x18,(jbyte)0x2B,(jbyte)0xB9,(jbyte)0x00,(jbyte)0x31,(jbyte)0x02,(jbyte)0x00,(jbyte)0x57,(jbyte)0xB1
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0E,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x18,(jbyte)0x00,(jbyte)0x05,(jbyte)0x00,(jbyte)0x19
,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x1A,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x23
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x32,(jbyte)0x00,(jbyte)0x33,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x34,(jbyte)0x00,(jbyte)0x35
,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x36,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x46,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x14,(jbyte)0x2A,(jbyte)0xBB,(jbyte)0x00,(jbyte)0x38,(jbyte)0x59,(jbyte)0x2A,(jbyte)0xB7,(jbyte)0x00,(jbyte)0x3B,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x3D,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x3D
,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x40,(jbyte)0xB1,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0E,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x23
,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x24,(jbyte)0x00,(jbyte)0x13,(jbyte)0x00,(jbyte)0x25,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x14
,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x23,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x41,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x00,(jbyte)0x01,(jbyte)0x24
,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x04,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x70,(jbyte)0xA7,(jbyte)0x00,(jbyte)0x4D,(jbyte)0x2A,(jbyte)0x14,(jbyte)0x00,(jbyte)0x42,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x47,(jbyte)0xC0,(jbyte)0x00
,(jbyte)0x27,(jbyte)0x4C,(jbyte)0x2B,(jbyte)0xC6,(jbyte)0x00,(jbyte)0x3E,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x18,(jbyte)0x59,(jbyte)0x4D,(jbyte)0xC2,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x18,(jbyte)0x2B,(jbyte)0xB9,(jbyte)0x00
,(jbyte)0x49,(jbyte)0x02,(jbyte)0x00,(jbyte)0x57,(jbyte)0x2C,(jbyte)0xC3,(jbyte)0xA7,(jbyte)0x00,(jbyte)0x06,(jbyte)0x2C,(jbyte)0xC3,(jbyte)0xBF,(jbyte)0x2B,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x4D,(jbyte)0xB8,(jbyte)0x00,(jbyte)0x50,(jbyte)0xA7
,(jbyte)0x00,(jbyte)0x13,(jbyte)0x4E,(jbyte)0xA8,(jbyte)0x00,(jbyte)0x05,(jbyte)0x2D,(jbyte)0xBF,(jbyte)0x4D,(jbyte)0x2B,(jbyte)0x14,(jbyte)0x00,(jbyte)0x51,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x2B,(jbyte)0xA9,(jbyte)0x02,(jbyte)0xA8,(jbyte)0xFF
,(jbyte)0xF6,(jbyte)0xA7,(jbyte)0x00,(jbyte)0x04,(jbyte)0x4C,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x1A,(jbyte)0x99,(jbyte)0xFF,(jbyte)0xB2,(jbyte)0x2A,(jbyte)0x01,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x18,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00
,(jbyte)0x1F,(jbyte)0x59,(jbyte)0x4C,(jbyte)0xC2,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x1F,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x55,(jbyte)0x2B,(jbyte)0xC3,(jbyte)0xA7,(jbyte)0x00,(jbyte)0x06,(jbyte)0x2B,(jbyte)0xC3,(jbyte)0xBF,(jbyte)0xB1
,(jbyte)0x00,(jbyte)0x07,(jbyte)0x00,(jbyte)0x19,(jbyte)0x00,(jbyte)0x26,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x2B,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x2C
,(jbyte)0x00,(jbyte)0x36,(jbyte)0x00,(jbyte)0x36,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x46,(jbyte)0x00,(jbyte)0x49,(jbyte)0x00,(jbyte)0x36,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x4C,(jbyte)0x00,(jbyte)0x4C
,(jbyte)0x00,(jbyte)0x57,(jbyte)0x00,(jbyte)0x60,(jbyte)0x00,(jbyte)0x69,(jbyte)0x00,(jbyte)0x6C,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x6C,(jbyte)0x00,(jbyte)0x6E,(jbyte)0x00,(jbyte)0x6C,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02
,(jbyte)0x00,(jbyte)0x20,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x4E,(jbyte)0x00,(jbyte)0x13,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x2F,(jbyte)0x00,(jbyte)0x0E,(jbyte)0x00,(jbyte)0x30
,(jbyte)0x00,(jbyte)0x12,(jbyte)0x00,(jbyte)0x33,(jbyte)0x00,(jbyte)0x19,(jbyte)0x00,(jbyte)0x35,(jbyte)0x00,(jbyte)0x24,(jbyte)0x00,(jbyte)0x33,(jbyte)0x00,(jbyte)0x2C,(jbyte)0x00,(jbyte)0x39,(jbyte)0x00,(jbyte)0x36,(jbyte)0x00,(jbyte)0x3C
,(jbyte)0x00,(jbyte)0x3A,(jbyte)0x00,(jbyte)0x3E,(jbyte)0x00,(jbyte)0x3C,(jbyte)0x00,(jbyte)0x3C,(jbyte)0x00,(jbyte)0x3D,(jbyte)0x00,(jbyte)0x3D,(jbyte)0x00,(jbyte)0x44,(jbyte)0x00,(jbyte)0x3E,(jbyte)0x00,(jbyte)0x4C,(jbyte)0x00,(jbyte)0x41
,(jbyte)0x00,(jbyte)0x4D,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x54,(jbyte)0x00,(jbyte)0x46,(jbyte)0x00,(jbyte)0x59,(jbyte)0x00,(jbyte)0x48,(jbyte)0x00,(jbyte)0x60,(jbyte)0x00,(jbyte)0x4A,(jbyte)0x00,(jbyte)0x67,(jbyte)0x00,(jbyte)0x48
,(jbyte)0x00,(jbyte)0x6F,(jbyte)0x00,(jbyte)0x4C,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x16,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x70,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x23
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x0E,(jbyte)0x00,(jbyte)0x3E,(jbyte)0x00,(jbyte)0x32,(jbyte)0x00,(jbyte)0x33,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x58,(jbyte)0x00,(jbyte)0x10,(jbyte)0x00,(jbyte)0x01
,(jbyte)0x00,(jbyte)0x11,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x88,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x24,(jbyte)0x2A,(jbyte)0x04,(jbyte)0xB5,(jbyte)0x00,(jbyte)0x1A,(jbyte)0x2A
,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x1F,(jbyte)0x59,(jbyte)0x4C,(jbyte)0xC2,(jbyte)0x2A,(jbyte)0xB4,(jbyte)0x00,(jbyte)0x1F,(jbyte)0x14,(jbyte)0x00,(jbyte)0x59,(jbyte)0xB6,(jbyte)0x00,(jbyte)0x5D,(jbyte)0x2B,(jbyte)0xC3,(jbyte)0xA7,(jbyte)0x00
,(jbyte)0x0B,(jbyte)0x2B,(jbyte)0xC3,(jbyte)0xBF,(jbyte)0xA7,(jbyte)0x00,(jbyte)0x05,(jbyte)0x4C,(jbyte)0xB1,(jbyte)0xB1,(jbyte)0x00,(jbyte)0x03,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x18,(jbyte)0x00,(jbyte)0x1B,(jbyte)0x00,(jbyte)0x00
,(jbyte)0x00,(jbyte)0x1B,(jbyte)0x00,(jbyte)0x1D,(jbyte)0x00,(jbyte)0x1B,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x05,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x57,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x20
,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x1E,(jbyte)0x00,(jbyte)0x07,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x51,(jbyte)0x00,(jbyte)0x05,(jbyte)0x00,(jbyte)0x55,(jbyte)0x00,(jbyte)0x0C,(jbyte)0x00,(jbyte)0x57,(jbyte)0x00,(jbyte)0x16
,(jbyte)0x00,(jbyte)0x55,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x5A,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x5D,(jbyte)0x00,(jbyte)0x23,(jbyte)0x00,(jbyte)0x5F,(jbyte)0x00,(jbyte)0x21,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x16
,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x24,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x23,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x22,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x5E,(jbyte)0x00,(jbyte)0x5F
,(jbyte)0x00,(jbyte)0x01,(jbyte)0x01,(jbyte)0x0A,(jbyte)0x00,(jbyte)0x4E,(jbyte)0x00,(jbyte)0x29,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x01,(jbyte)0x00,(jbyte)0x60,(jbyte)0x00,(jbyte)0x00,(jbyte)0x00,(jbyte)0x02,(jbyte)0x00,(jbyte)0x61
};
jsize getJPypeReferenceQueueLength() { return 1880; }
python-jpype-0.5.4.2/src/native/common/include/ 0000775 0001750 0001750 00000000000 11620747357 020626 5 ustar takaki takaki python-jpype-0.5.4.2/src/native/common/include/jp_reference.h 0000666 0001750 0001750 00000001617 11614007722 023421 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPREFERENCE_H_
#define _JPREFERENCE_H_
extern jbyte JPypeReference[];
jsize getJPypeReferenceLength();
#endif // _JPREFERENCE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_array.h 0000666 0001750 0001750 00000003173 11614007722 022600 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPARRAY_H_
#define _JPARRAY_H_
/**
* Class to wrap Java Class and provide low-level behavior
*/
class JPArray : public JPObjectBase
{
public :
JPArray(JPTypeName name, jarray inst);
virtual~ JPArray();
public :
JPArrayClass* getClass()
{
return m_Class;
}
int getLength();
vector getRange(int start, int stop);
void setRange(int start, int stop, vector& val);
void setItem(int ndx, HostRef*);
HostRef* getItem(int ndx);
void setContent(vector& data)
{
setRange(0, getLength(), data);
}
jobject getObject()
{
return JPEnv::getJava()->NewLocalRef(m_Object);
}
public : // Wrapper
virtual JPType* getType();
virtual jvalue getValue();
virtual JCharString toString();
private :
JPArrayClass* m_Class;
jarray m_Object;
};
#endif // _JPARRAY_H_
python-jpype-0.5.4.2/src/native/common/include/jp_utility.h 0000666 0001750 0001750 00000006351 11614227532 023171 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPYPE_UTILITY_H_
#define _JPYPE_UTILITY_H_
#define RAISE(exClass, msg) { throw new exClass(msg, __FILE__, __LINE__); }
/** Support Exception for JPype-generated exception */
class JPypeException
{
public :
JPypeException(char* msn, const char* f, int l)
{
file=f, line=l;
std::stringstream str;
str << msn << " at " << f << ":" << l;
this->msg = str.str();
}
JPypeException(string msn, const char* f, int l)
{
file=f, line=l;
std::stringstream str;
str << msn << " at " << f << ":" << l;
this->msg = str.str();
}
JPypeException(const JPypeException& ex) : file(ex.file), line(ex.line) { this->msg = ex.msg;}
virtual ~JPypeException() {}
const char* getMsg()
{
return msg.c_str();
}
const char* file;
int line;
private :
string msg;
};
/*
#define STANDARD_CATCH \
catch(JavaException EXCEPTION_PTR ex) \
{ \
JPEnv::getJava()->ExceptionDescribe(); \
JPEnv::getJava()->ExceptionClear(); \
stringstream msg; \
msg << "Java Exception Occured at " << ex EXCEPTION_DEREF file << ":" << ex EXCEPTION_DEREF line << ":" << ex EXCEPTION_DEREF message; \
JPEnv::getHost()->setRuntimeException(msg.str().c_str());\
EXCEPTION_CLEANUP(ex); \
}\
catch(JPypeException EXCEPTION_PTR ex)\
{\
JPEnv::getHost()->setRuntimeException(ex EXCEPTION_DEREF getMsg()); \
EXCEPTION_CLEANUP(ex); \
}\
catch(...) \
{\
JPEnv::getHost()->setRuntimeException("Unknown Exception"); \
} \
*/
#define RETHROW_CATCH(cleanup) \
catch(...) \
{ \
cleanup ; \
throw; \
}
class JPypeTracer
{
private :
string m_Name;
bool m_Error;
public :
JPypeTracer(const char* name) : m_Name(name)
{
traceIn(name);
m_Error = false;
}
virtual ~JPypeTracer()
{
traceOut(m_Name.c_str(), m_Error);
}
void gotError()
{
m_Error = true;
}
template
void trace(T msg)
{
stringstream str;
str << msg;
trace1(m_Name.c_str(), str.str());
}
template
void trace(T msg1, U msg2)
{
stringstream str;
str << msg1 << " " << msg2;
trace1(m_Name.c_str(), str.str());
}
template
void trace(T msg1, U msg2, V msg3)
{
stringstream str;
str << msg1 << " " << msg2 << " " << msg3;
trace1(m_Name.c_str(), str.str());
}
private :
static void traceIn(const char* msg);
static void traceOut(const char* msg, bool error);
static void trace1(const char* name, const string& msg);
};
#endif // _JPYPE_UTILITY_H_
python-jpype-0.5.4.2/src/native/common/include/jp_hostenv.h 0000666 0001750 0001750 00000011765 11614007722 023156 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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.
*****************************************************************************/
#ifndef _JPHOSTENV_H_
#define _JPHOSTENV_H_
class HostRef
{
public :
HostRef(void* data, bool acquire);
HostRef(void* data);
virtual ~HostRef();
public :
HostRef* copy();
void release();
bool isNull();
void* data();
private :
void* m_HostData;
};
// Pre-delcare those required types
class JPArray;
class JPArrayClass;
class JPClass;
class JPMethod;
class JPObject;
class JPProxy;
class HostEnvironment
{
public :
virtual ~HostEnvironment() {}
virtual void* acquireRef(void*) = 0;
virtual void releaseRef(void*) = 0;
virtual bool isRefNull(void*) = 0;
virtual string describeRef(HostRef*) = 0;
virtual void* gotoExternal() = 0;
virtual void returnExternal(void*) = 0;
virtual void setRuntimeException(const char* msg) = 0;
virtual void setAttributeError(const char* msg) = 0;
virtual void setTypeError(const char* msg) = 0;
virtual void raise(const char* msg) = 0;
virtual HostRef* getNone() = 0;
virtual bool isNone(HostRef*) = 0;
virtual bool isBoolean(HostRef*) = 0;
virtual jboolean booleanAsBoolean(HostRef*) = 0;
virtual HostRef* getTrue() = 0;
virtual HostRef* getFalse() = 0;
virtual bool isSequence(HostRef*) = 0;
virtual HostRef* newMutableSequence(jsize) = 0;
virtual HostRef* newImmutableSequence(jsize) = 0;
virtual jsize getSequenceLength(HostRef*) = 0;
virtual HostRef* getSequenceItem(HostRef*, jsize) = 0;
virtual void setSequenceItem(HostRef*, jsize, HostRef*) = 0;
virtual bool isInt(HostRef*) = 0;
virtual HostRef* newInt(jint) = 0;
virtual jint intAsInt(HostRef*) = 0;
virtual bool isLong(HostRef*) = 0;
virtual HostRef* newLong(jlong) = 0;
virtual jlong longAsLong(HostRef*) = 0;
virtual bool isFloat(HostRef*) = 0;
virtual HostRef* newFloat(jdouble) = 0;
virtual jdouble floatAsDouble(HostRef*) = 0;
virtual bool isMethod(HostRef*) = 0;
virtual HostRef* newMethod(JPMethod*) = 0;
virtual JPMethod* asMethod(HostRef*) = 0;
virtual bool isObject(HostRef*) = 0;
virtual JPObject* asObject(HostRef*) = 0;
virtual HostRef* newObject(JPObject*) = 0;
virtual bool isClass(HostRef*) = 0;
virtual HostRef* newClass(JPClass*) = 0;
virtual JPClass* asClass(HostRef*) = 0;
virtual bool isArrayClass(HostRef*) = 0;
virtual HostRef* newArrayClass(JPArrayClass*) = 0;
virtual JPArrayClass* asArrayClass(HostRef*) = 0;
virtual bool isArray(HostRef*) = 0;
virtual HostRef* newArray(JPArray*) = 0;
virtual JPArray* asArray(HostRef*) = 0;
virtual bool isProxy(HostRef*) = 0;
virtual JPProxy* asProxy(HostRef*) = 0;
virtual HostRef* getCallableFrom(HostRef*, string&) = 0;
virtual bool isWrapper(HostRef*) = 0;
virtual JPTypeName getWrapperTypeName(HostRef*) = 0;
virtual jvalue getWrapperValue(HostRef*) = 0;
virtual HostRef* newStringWrapper(jstring) = 0;
virtual bool isString(HostRef*) = 0;
virtual jsize getStringLength(HostRef*) = 0;
virtual string stringAsString(HostRef*) = 0;
virtual JCharString stringAsJCharString(HostRef*) = 0;
virtual HostRef* newStringFromUnicode(const jchar*, unsigned int) = 0;
virtual HostRef* newStringFromASCII(const char*, unsigned int) = 0;
virtual bool isByteString(HostRef*) = 0;
virtual bool isUnicodeString(HostRef*) = 0;
virtual void getRawByteString(HostRef*, char**, long&) = 0;
virtual void getRawUnicodeString(HostRef*, jchar**, long&) = 0;
virtual size_t getUnicodeSize() = 0;
virtual void* prepareCallbackBegin() = 0;
virtual void prepareCallbackFinish(void* state) = 0;
virtual HostRef* callObject(HostRef* callable, vector& args) = 0;
virtual bool mapContains(HostRef* map, HostRef* key) = 0;
virtual HostRef* getMapItem(HostRef* map, HostRef* key) = 0;
virtual bool objectHasAttribute(HostRef* obj, HostRef* key) = 0;
virtual HostRef* getObjectAttribute(HostRef* obj, HostRef* key) = 0;
virtual bool isJavaException(HostException*) = 0;
virtual HostRef* getJavaException(HostException*) = 0;
virtual void printError() = 0;
virtual void clearError() = 0;
virtual void printReferenceInfo(HostRef* obj) = 0;
};
#endif // _JPHOSTENV_H_
python-jpype-0.5.4.2/src/native/common/include/jp_javaenv_autogen.h 0000666 0001750 0001750 00000040417 11614007722 024640 0 ustar takaki takaki
/*****************************************************************************
Copyright 2004-2008 Steve Menard
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.
*****************************************************************************/
// This code has been automatically generated ... No not edit
/** GetStaticByteField */
jbyte GetStaticByteField(jclass clazz, jfieldID fid);
/** GetByteField */
jbyte GetByteField(jobject clazz, jfieldID fid);
/** SetStaticByteField */
void SetStaticByteField(jclass clazz, jfieldID fid, jbyte val);
/** SetByteField */
void SetByteField(jobject clazz, jfieldID fid, jbyte val);
/** CallStaticByteMethodA */
jbyte CallStaticByteMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticByteMethod */
jbyte CallStaticByteMethod(jclass clazz, jmethodID mid);
/** CallByteMethodA */
jbyte CallByteMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallByteMethod */
jbyte CallByteMethod(jobject obj, jmethodID mid);
/** CallByteMethodA */
jbyte CallNonvirtualByteMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallByteMethod */
jbyte CallNonvirtualByteMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticShortField */
jshort GetStaticShortField(jclass clazz, jfieldID fid);
/** GetShortField */
jshort GetShortField(jobject clazz, jfieldID fid);
/** SetStaticShortField */
void SetStaticShortField(jclass clazz, jfieldID fid, jshort val);
/** SetShortField */
void SetShortField(jobject clazz, jfieldID fid, jshort val);
/** CallStaticShortMethodA */
jshort CallStaticShortMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticShortMethod */
jshort CallStaticShortMethod(jclass clazz, jmethodID mid);
/** CallShortMethodA */
jshort CallShortMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallShortMethod */
jshort CallShortMethod(jobject obj, jmethodID mid);
/** CallShortMethodA */
jshort CallNonvirtualShortMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallShortMethod */
jshort CallNonvirtualShortMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticIntField */
jint GetStaticIntField(jclass clazz, jfieldID fid);
/** GetIntField */
jint GetIntField(jobject clazz, jfieldID fid);
/** SetStaticIntField */
void SetStaticIntField(jclass clazz, jfieldID fid, jint val);
/** SetIntField */
void SetIntField(jobject clazz, jfieldID fid, jint val);
/** CallStaticIntMethodA */
jint CallStaticIntMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticIntMethod */
jint CallStaticIntMethod(jclass clazz, jmethodID mid);
/** CallIntMethodA */
jint CallIntMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallIntMethod */
jint CallIntMethod(jobject obj, jmethodID mid);
/** CallIntMethodA */
jint CallNonvirtualIntMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallIntMethod */
jint CallNonvirtualIntMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticLongField */
jlong GetStaticLongField(jclass clazz, jfieldID fid);
/** GetLongField */
jlong GetLongField(jobject clazz, jfieldID fid);
/** SetStaticLongField */
void SetStaticLongField(jclass clazz, jfieldID fid, jlong val);
/** SetLongField */
void SetLongField(jobject clazz, jfieldID fid, jlong val);
/** CallStaticLongMethodA */
jlong CallStaticLongMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticLongMethod */
jlong CallStaticLongMethod(jclass clazz, jmethodID mid);
/** CallLongMethodA */
jlong CallLongMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallLongMethod */
jlong CallLongMethod(jobject obj, jmethodID mid);
/** CallLongMethodA */
jlong CallNonvirtualLongMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallLongMethod */
jlong CallNonvirtualLongMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticFloatField */
jfloat GetStaticFloatField(jclass clazz, jfieldID fid);
/** GetFloatField */
jfloat GetFloatField(jobject clazz, jfieldID fid);
/** SetStaticFloatField */
void SetStaticFloatField(jclass clazz, jfieldID fid, jfloat val);
/** SetFloatField */
void SetFloatField(jobject clazz, jfieldID fid, jfloat val);
/** CallStaticFloatMethodA */
jfloat CallStaticFloatMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticFloatMethod */
jfloat CallStaticFloatMethod(jclass clazz, jmethodID mid);
/** CallFloatMethodA */
jfloat CallFloatMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallFloatMethod */
jfloat CallFloatMethod(jobject obj, jmethodID mid);
/** CallFloatMethodA */
jfloat CallNonvirtualFloatMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallFloatMethod */
jfloat CallNonvirtualFloatMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticDoubleField */
jdouble GetStaticDoubleField(jclass clazz, jfieldID fid);
/** GetDoubleField */
jdouble GetDoubleField(jobject clazz, jfieldID fid);
/** SetStaticDoubleField */
void SetStaticDoubleField(jclass clazz, jfieldID fid, jdouble val);
/** SetDoubleField */
void SetDoubleField(jobject clazz, jfieldID fid, jdouble val);
/** CallStaticDoubleMethodA */
jdouble CallStaticDoubleMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticDoubleMethod */
jdouble CallStaticDoubleMethod(jclass clazz, jmethodID mid);
/** CallDoubleMethodA */
jdouble CallDoubleMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallDoubleMethod */
jdouble CallDoubleMethod(jobject obj, jmethodID mid);
/** CallDoubleMethodA */
jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallDoubleMethod */
jdouble CallNonvirtualDoubleMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticCharField */
jchar GetStaticCharField(jclass clazz, jfieldID fid);
/** GetCharField */
jchar GetCharField(jobject clazz, jfieldID fid);
/** SetStaticCharField */
void SetStaticCharField(jclass clazz, jfieldID fid, jchar val);
/** SetCharField */
void SetCharField(jobject clazz, jfieldID fid, jchar val);
/** CallStaticCharMethodA */
jchar CallStaticCharMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticCharMethod */
jchar CallStaticCharMethod(jclass clazz, jmethodID mid);
/** CallCharMethodA */
jchar CallCharMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallCharMethod */
jchar CallCharMethod(jobject obj, jmethodID mid);
/** CallCharMethodA */
jchar CallNonvirtualCharMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallCharMethod */
jchar CallNonvirtualCharMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticBooleanField */
jboolean GetStaticBooleanField(jclass clazz, jfieldID fid);
/** GetBooleanField */
jboolean GetBooleanField(jobject clazz, jfieldID fid);
/** SetStaticBooleanField */
void SetStaticBooleanField(jclass clazz, jfieldID fid, jboolean val);
/** SetBooleanField */
void SetBooleanField(jobject clazz, jfieldID fid, jboolean val);
/** CallStaticBooleanMethodA */
jboolean CallStaticBooleanMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticBooleanMethod */
jboolean CallStaticBooleanMethod(jclass clazz, jmethodID mid);
/** CallBooleanMethodA */
jboolean CallBooleanMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallBooleanMethod */
jboolean CallBooleanMethod(jobject obj, jmethodID mid);
/** CallBooleanMethodA */
jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallBooleanMethod */
jboolean CallNonvirtualBooleanMethod(jobject obj, jclass claz, jmethodID mid);
/** GetStaticObjectField */
jobject GetStaticObjectField(jclass clazz, jfieldID fid);
/** GetObjectField */
jobject GetObjectField(jobject clazz, jfieldID fid);
/** SetStaticObjectField */
void SetStaticObjectField(jclass clazz, jfieldID fid, jobject val);
/** SetObjectField */
void SetObjectField(jobject clazz, jfieldID fid, jobject val);
/** CallStaticObjectMethodA */
jobject CallStaticObjectMethodA(jclass clazz, jmethodID mid, jvalue* val);
/** CallStaticObjectMethod */
jobject CallStaticObjectMethod(jclass clazz, jmethodID mid);
/** CallObjectMethodA */
jobject CallObjectMethodA(jobject obj, jmethodID mid, jvalue* val);
/** CallObjectMethod */
jobject CallObjectMethod(jobject obj, jmethodID mid);
/** CallObjectMethodA */
jobject CallNonvirtualObjectMethodA(jobject obj, jclass claz, jmethodID mid, jvalue* val);
/** CallObjectMethod */
jobject CallNonvirtualObjectMethod(jobject obj, jclass claz, jmethodID mid);
/** NewByteArray */
jbyteArray NewByteArray(jint len);
/** SetByteArrayRegion */
void SetByteArrayRegion(jbyteArray array, int start, int len, jbyte* vals);
/** GetByteArrayRegion */
void GetByteArrayRegion(jbyteArray array, int start, int len, jbyte* vals);
/** GetByteArrayElements */
jbyte* GetByteArrayElements(jbyteArray array, jboolean* isCopy);
/** ReleaseByteArrayElements */
void ReleaseByteArrayElements(jbyteArray, jbyte* v, jint mode);
/** NewShortArray */
jshortArray NewShortArray(jint len);
/** SetShortArrayRegion */
void SetShortArrayRegion(jshortArray array, int start, int len, jshort* vals);
/** GetShortArrayRegion */
void GetShortArrayRegion(jshortArray array, int start, int len, jshort* vals);
/** GetShortArrayElements */
jshort* GetShortArrayElements(jshortArray array, jboolean* isCopy);
/** ReleaseShortArrayElements */
void ReleaseShortArrayElements(jshortArray, jshort* v, jint mode);
/** NewIntArray */
jintArray NewIntArray(jint len);
/** SetIntArrayRegion */
void SetIntArrayRegion(jintArray array, int start, int len, jint* vals);
/** GetIntArrayRegion */
void GetIntArrayRegion(jintArray array, int start, int len, jint* vals);
/** GetIntArrayElements */
jint* GetIntArrayElements(jintArray array, jboolean* isCopy);
/** ReleaseIntArrayElements */
void ReleaseIntArrayElements(jintArray, jint* v, jint mode);
/** NewLongArray */
jlongArray NewLongArray(jint len);
/** SetLongArrayRegion */
void SetLongArrayRegion(jlongArray array, int start, int len, jlong* vals);
/** GetLongArrayRegion */
void GetLongArrayRegion(jlongArray array, int start, int len, jlong* vals);
/** GetLongArrayElements */
jlong* GetLongArrayElements(jlongArray array, jboolean* isCopy);
/** ReleaseLongArrayElements */
void ReleaseLongArrayElements(jlongArray, jlong* v, jint mode);
/** NewFloatArray */
jfloatArray NewFloatArray(jint len);
/** SetFloatArrayRegion */
void SetFloatArrayRegion(jfloatArray array, int start, int len, jfloat* vals);
/** GetFloatArrayRegion */
void GetFloatArrayRegion(jfloatArray array, int start, int len, jfloat* vals);
/** GetFloatArrayElements */
jfloat* GetFloatArrayElements(jfloatArray array, jboolean* isCopy);
/** ReleaseFloatArrayElements */
void ReleaseFloatArrayElements(jfloatArray, jfloat* v, jint mode);
/** NewDoubleArray */
jdoubleArray NewDoubleArray(jint len);
/** SetDoubleArrayRegion */
void SetDoubleArrayRegion(jdoubleArray array, int start, int len, jdouble* vals);
/** GetDoubleArrayRegion */
void GetDoubleArrayRegion(jdoubleArray array, int start, int len, jdouble* vals);
/** GetDoubleArrayElements */
jdouble* GetDoubleArrayElements(jdoubleArray array, jboolean* isCopy);
/** ReleaseDoubleArrayElements */
void ReleaseDoubleArrayElements(jdoubleArray, jdouble* v, jint mode);
/** NewCharArray */
jcharArray NewCharArray(jint len);
/** SetCharArrayRegion */
void SetCharArrayRegion(jcharArray array, int start, int len, jchar* vals);
/** GetCharArrayRegion */
void GetCharArrayRegion(jcharArray array, int start, int len, jchar* vals);
/** GetCharArrayElements */
jchar* GetCharArrayElements(jcharArray array, jboolean* isCopy);
/** ReleaseCharArrayElements */
void ReleaseCharArrayElements(jcharArray, jchar* v, jint mode);
/** NewBooleanArray */
jbooleanArray NewBooleanArray(jint len);
/** SetBooleanArrayRegion */
void SetBooleanArrayRegion(jbooleanArray array, int start, int len, jboolean* vals);
/** GetBooleanArrayRegion */
void GetBooleanArrayRegion(jbooleanArray array, int start, int len, jboolean* vals);
/** GetBooleanArrayElements */
jboolean* GetBooleanArrayElements(jbooleanArray array, jboolean* isCopy);
/** ReleaseBooleanArrayElements */
void ReleaseBooleanArrayElements(jbooleanArray, jboolean* v, jint mode);
/** MonitorEnter */
int MonitorEnter(jobject a0);
/** MonitorExit */
int MonitorExit(jobject a0);
/** FromReflectedMethod */
jmethodID FromReflectedMethod(jobject a0);
/** FromReflectedField */
jfieldID FromReflectedField(jobject a0);
/** FindClass */
jclass FindClass(const char* a0);
/** IsInstanceOf */
jboolean IsInstanceOf(jobject a0, jclass a1);
/** NewObjectArray */
jobjectArray NewObjectArray(int a0, jclass a1, jobject a2);
/** SetObjectArrayElement */
void SetObjectArrayElement(jobjectArray a0, int a1, jobject a2);
/** CallStaticVoidMethodA */
void CallStaticVoidMethodA(jclass a0, jmethodID a1, jvalue* a2);
/** CallVoidMethodA */
void CallVoidMethodA(jobject a0, jmethodID a1, jvalue* a2);
/** CallVoidMethod */
void CallVoidMethod(jobject a0, jmethodID a1);
/** IsAssignableFrom */
jboolean IsAssignableFrom(jclass a0, jclass a1);
/** NewString */
jstring NewString(const jchar* a0, int a1);
/** GetSuperclass */
jclass GetSuperclass(jclass a0);
/** GetStringUTFChars */
const char* GetStringUTFChars(jstring a0, jboolean* a1);
/** ReleaseStringUTFChars */
void ReleaseStringUTFChars(jstring a0, const char* a1);
/** GetArrayLength */
jsize GetArrayLength(jarray a0);
/** GetObjectArrayElement */
jobject GetObjectArrayElement(jobjectArray a0, int a1);
/** GetObjectClass */
jclass GetObjectClass(jobject a0);
/** GetMethodID */
jmethodID GetMethodID(jclass a0, char* a1, char* a2);
/** GetStaticMethodID */
jmethodID GetStaticMethodID(jclass a0, char* a1, char* a2);
/** GetFieldID */
jfieldID GetFieldID(jclass a0, char* a1, char* a2);
/** GetStaticFieldID */
jfieldID GetStaticFieldID(jclass a0, char* a1, char* a2);
/** GetStringChars */
const jchar* GetStringChars(jstring a0, jboolean* a1);
/** ReleaseStringChars */
void ReleaseStringChars(jstring a0, const jchar* a1);
/** GetStringLength */
jsize GetStringLength(jstring a0);
/** DefineClass */
jclass DefineClass(const char* a0, jobject a1, const jbyte* a2, jsize a3);
/** RegisterNatives */
jint RegisterNatives(jclass a0, const JNINativeMethod* a1, jint a2);
python-jpype-0.5.4.2/src/native/common/include/jp_javaenv.h 0000666 0001750 0001750 00000007020 11614007722 023107 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JAVA_ENV_H_
#define _JAVA_ENV_H_
/**
* Simple exception class to wrap java-sourced exceptions
*/
class JavaException
{
public :
JavaException(const char* msg, const char* f, int l) : file(f), line(l) {message = msg;}
JavaException(JavaException& ex) : file(ex.file), line(ex.line) {message = ex.message;}
virtual ~JavaException() {}
const char* file;
int line;
string message;
};
class HostException
{
public :
HostException() {}
virtual ~HostException() {}
virtual const char* getFile() { return "";}
virtual int getLine() {return 0;}
virtual string getMessage() { return ""; }
};
/**
* the platform adapter's implementation is chosen by the JPYPE_??? macros
*/
class JPPlatformAdapter
{
public :
virtual ~JPPlatformAdapter() {};
virtual void loadLibrary(const char* path) = 0;
virtual void* getSymbol(const char* name)= 0;
};
/**
* Wrap all the needed parts of JNI to provide centralized error detection and dynamic loading
*/
class JPJavaEnv
{
public :
JPJavaEnv(JavaVM* vm)
{
jvm = vm;
convertStringObjects = true;
}
virtual ~JPJavaEnv() {}
private :
static JPPlatformAdapter* GetAdapter();
// static JPPlatformAdapter* adapter;
static jint (JNICALL *CreateJVM_Method)(JavaVM **pvm, void **penv, void *args);
static jint (JNICALL *GetCreatedJVMs_Method)(JavaVM **pvm, jsize size, jsize* nVms);
JavaVM* jvm;
jobject referenceQueue;
bool convertStringObjects;
JNIEnv* getJNIEnv();
public :
static void load(const string& path);
static JPJavaEnv* CreateJavaVM(void* arg);
static JPJavaEnv* GetCreatedJavaVM();
jint AttachCurrentThread();
jint AttachCurrentThreadAsDaemon();
static bool isThreadAttached();
void setConvertStringObjects(bool flag)
{
convertStringObjects = flag;
}
bool getConvertStringObjects()
{
return convertStringObjects;
}
void setReferenceQueue(jobject obj)
{
referenceQueue = NewGlobalRef(obj);
}
jobject getReferenceQueue()
{
return referenceQueue;
}
void shutdown();
void checkInitialized();
int DestroyJavaVM();
jobject NewGlobalRef(jobject obj);
void DeleteGlobalRef(jobject obj);
jobject NewLocalRef(jobject obj);
void DeleteLocalRef(jobject obj);
bool ExceptionCheck();
void ExceptionDescribe();
void ExceptionClear();
jthrowable ExceptionOccurred();
jint DetachCurrentThread();
jint GetEnv(JNIEnv** env);
jint ThrowNew(jclass clazz, const char* msg);
jint Throw(jthrowable th);
jobject NewDirectByteBuffer(void* address, jlong capacity);
/** NewObjectA */
jobject NewObjectA(jclass a0, jmethodID a1, jvalue* a2);
/** NewObject */
jobject NewObject(jclass a0, jmethodID a1);
#include "jp_javaenv_autogen.h"
};
#endif // _JAVA_ENV_H_
python-jpype-0.5.4.2/src/native/common/include/jp_field.h 0000666 0001750 0001750 00000003273 11614007722 022546 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPFIELD_H_
#define _JPFIELD_H_
/**
* Field object
*/
class JPField
{
public :
/**
* default constructor
*/
JPField();
/**
* Create a new field based on class and java.lang.Field object
*/
JPField(JPClass* clazz, jobject fld);
JPField(const JPField&);
/**
* destructor
*/
virtual ~JPField();
public :
bool isStatic();
string getName();
JPTypeName getType()
{
return m_Type;
}
HostRef* getStaticAttribute();
void setStaticAttribute(HostRef* val);
HostRef* getAttribute(jobject inst);
void setAttribute(jobject inst, HostRef* val);
bool isFinal()
{
return m_IsFinal;
}
private :
string m_Name;
JPClass* m_Class;
bool m_IsStatic;
bool m_IsFinal;
jobject m_Field;
jfieldID m_FieldID;
JPTypeName m_Type;
};
#endif // _JPFIELD_H_
python-jpype-0.5.4.2/src/native/common/include/jp_object.h 0000666 0001750 0001750 00000002447 11614007722 022733 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPOBJECT_H_
#define _JPOBJECT_H_
class JPObject : public JPObjectBase
{
public :
JPObject(JPClass* clazz, jobject inst);
JPObject(JPTypeName& clazz, jobject inst);
virtual ~JPObject();
JPClass* getClass()
{
return m_Class;
}
jobject getObject()
{
return JPEnv::getJava()->NewLocalRef(m_Object);
}
JCharString toString();
HostRef* getAttribute(string name);
void setAttribute(string name, HostRef* value);
private :
JPClass* m_Class;
jobject m_Object;
};
#endif // _JPOBJECT_H_
python-jpype-0.5.4.2/src/native/common/include/jp_env.h 0000666 0001750 0001750 00000005545 11614007722 022257 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve M�nard
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.
*****************************************************************************/
#ifndef _JPENV_H_
#define _JPENV_H_
/**
* Simple tample class for managing local java references.
*/
class JPCleaner
{
public :
JPCleaner();
virtual ~JPCleaner();
void addGlobal(jobject r);
void removeGlobal(jobject r);
void addAllGlobal(vector& r);
void addAllGlobal(vector& r);
void removeAllGlobal(vector& r);
void addLocal(jobject r);
void removeLocal(jobject r);
void addAllLocal(vector& r);
void addAllLocal(vector& r);
void removeAllLocal(vector& r);
void add(HostRef* r);
void addAll(vector& r);
void remove(HostRef* r);
void removeAll(vector& r);
private :
vector m_GlobalJavaObjects;
vector m_LocalJavaObjects;
vector m_HostObjects;
};
template
class JPMallocCleaner
{
public :
JPMallocCleaner(size_t size)
{
mData = (T*)malloc(sizeof(T)*size);
}
~JPMallocCleaner()
{
free(mData);
}
T& operator[](size_t ndx)
{
return mData[ndx];
}
T* borrow()
{
return mData;
}
private :
T* mData;
};
class JPEnv
{
public :
/**
* Initialize the JPype subs-system. Does NOT load the JVM
*/
static void init(HostEnvironment* hostEnv);
/**
* Load the JVM
* TODO : add the non-string parameters, for possible callbacks
*/
static void loadJVM(const string& vmPath, char ignoreUnrecognized, const StringVector& args);
static void attachJVM(const string& vmPath);
/**
* Check if the JPype environment has been initialized
*/
static bool isInitialized()
{
return getJava() != NULL && getHost() != NULL;
}
static void attachCurrentThread();
static void attachCurrentThreadAsDaemon();
static bool isThreadAttached();
static JPJavaEnv* getJava()
{
return s_Java;
}
static HostEnvironment* getHost()
{
return s_Host;
}
static void registerRef(HostRef*, HostRef* targetRef);
private :
static void postLoadJVM();
private :
static HostEnvironment* s_Host;
static JPJavaEnv* s_Java;
};
#endif // _JPENV_H_
python-jpype-0.5.4.2/src/native/common/include/jp_jniutil.h 0000666 0001750 0001750 00000011255 11614007722 023140 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPJNIUTIL_H_
#define _JPJNIUTIL_H_
class JPJni
{
public :
static jclass s_ClassClass;
static jclass s_StringClass;
static jclass s_NoSuchMethodErrorClass;
static jclass s_RuntimeExceptionClass;
static jclass s_ProxyClass;
static jmethodID s_NewProxyInstanceID;
static jlong s_minByte;
static jlong s_maxByte;
static jlong s_minShort;
static jlong s_maxShort;
static jlong s_minInt;
static jlong s_maxInt;
static jfloat s_minFloat;
static jfloat s_maxFloat;
public :
static void init();
static void startJPypeReferenceQueue(bool);
static void stopJPypeReferenceQueue();
static void registerRef(jobject refQueue, jobject obj, jlong hostRef);
static string asciiFromJava(jstring str);
static JCharString unicodeFromJava(jstring str);
static jstring javaStringFromJCharString(JCharString& str);
static JPTypeName getClassName(jobject obj);
static jclass getClass(jobject obj);
static jstring toString(jobject obj);
/**
* java.lang.Class.isInterface()
*/
static bool isInterface(jclass);
/**
* java.lang.reflect.Modifier.isAbstract(java.lang.Class.getModifiers()
*/
static bool isAbstract(jclass);
/**
* java.lang.reflect.Modifier.isFinal(java.lang.Class.getModifiers()
*/
static bool isFinal(jclass);
/**
* java.lang.Class.getName()
*/
static JPTypeName getName(jclass);
/**
* java.lang.Class.getInterfaces()
*/
static vector getInterfaces(jclass);
/**
* java.lang.Class.getDeclaredFields()
*/
static vector getDeclaredFields(jclass);
/**
* java.lang.Class.getConstructors()
*/
static vector getConstructors(jclass);
/**
* java.lang.Class.getFields()
*/
static vector getFields(jclass);
/**
* java.lang.Class.getDeclaredMethods()
*/
static vector getDeclaredMethods(jclass);
/**
* java.lang.Class.getDeclaredMethods()
*/
static vector getMethods(jclass);
/**
* java.lang.Class.getDeclaredMethods()
*/
static vector getDeclaredConstructors(jclass);
/**
* java.lang.Class.getModifiers()
*/
static long getClassModifiers(jclass);
static jobject getSystemClassLoader();
/**
* java.lang.reflect.Member.getName()
*/
static string getMemberName(jobject);
/**
* java.lang.reflect.Modifier.isPublic(java.lang.reflect.member.getModifiers())
*/
static bool isMemberPublic(jobject);
/**
* java.lang.reflect.Modifier.isStatic(java.lang.reflect.member.getModifiers())
*/
static bool isMemberStatic(jobject);
/**
* java.lang.reflect.Modifier.isFinal(java.lang.reflect.member.getModifiers())
*/
static bool isMemberFinal(jobject);
/**
* java.lang.reflect.Modifier.isStatic(java.lang.reflect.member.getModifiers())
*/
static bool isMemberAbstract(jobject);
/**
* java.lang.reflect.Field.getType
*/
static JPTypeName getType(jobject fld);
/**
* java.lang.reflect.Method.getReturnType
*/
static JPTypeName getReturnType(jobject);
static jint hashCode(jobject);
/**
* java.lang.reflect.Method.getParameterTypes
*/
static vector getParameterTypes(jobject, bool);
static bool isConstructor(jobject);
static string getStackTrace(jthrowable th);
static string getMessage(jthrowable th);
static bool isThrowable(jclass c);
static long intValue(jobject);
static jlong longValue(jobject);
static double doubleValue(jobject);
static bool booleanValue(jobject);
static jchar charValue(jobject);
static jclass getByteClass();
static jclass getShortClass();
static jclass getIntegerClass();
static jclass getLongClass();
static jclass getFloatClass();
static jclass getDoubleClass();
static jclass getCharacterClass();
static jclass getBooleanClass();
static jclass getVoidClass();
};
#endif // _JPJNIUTIL_H_
python-jpype-0.5.4.2/src/native/common/include/jp_methodoverload.h 0000666 0001750 0001750 00000004045 11614007722 024475 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPMETHODOVERLOAD_H_
#define _JPMETHODOVERLOAD_H_
class JPObject;
class JPMethodOverload
{
public :
JPMethodOverload();
JPMethodOverload(const JPMethodOverload& o);
JPMethodOverload(JPClass* claz, jobject mth);
virtual ~JPMethodOverload();
EMatchType matches(bool ignoreFirst, vector& args) ;
HostRef* invokeInstance(vector& arg);
HostRef* invokeStatic(vector& arg);
JPObject* invokeConstructor(jclass, vector& arg);
public :
string getSignature();
bool isStatic()
{
return m_IsStatic;
}
bool isFinal()
{
return m_IsFinal;
}
JPTypeName getReturnType()
{
return m_ReturnType;
}
unsigned char getArgumentCount()
{
return (unsigned char)m_Arguments.size();
}
string getArgumentString();
bool isSameOverload(JPMethodOverload& o);
string matchReport(vector& args);
private :
JPClass* m_Class;
jobject m_Method;
jmethodID m_MethodID;
JPTypeName m_ReturnType;
vector m_Arguments;
bool m_IsStatic;
bool m_IsFinal;
bool m_IsConstructor;
};
#endif // _JPMETHODOVERLOAD_H_
python-jpype-0.5.4.2/src/native/common/include/jp_arrayclass.h 0000666 0001750 0001750 00000002567 11614007722 023634 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPARRAYCLASS_H_
#define _JPARRAYCLASS_H_
/**
* Class to wrap Java Class and provide low-level behavior
*/
class JPArrayClass : public JPClassBase
{
public :
JPArrayClass(const JPTypeName& tname, jclass c);
virtual~ JPArrayClass();
public : // JPType implementation
virtual HostRef* asHostObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual JPType* getComponentType()
{
return m_ComponentType;
}
JPArray* newInstance(int length);
public :
JPType* m_ComponentType;
};
#endif // _JPARRAYCLASS_H_
python-jpype-0.5.4.2/src/native/common/include/jp_invocationhandler.h 0000666 0001750 0001750 00000001665 11614007722 025175 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPINVOCATIONHANDLER_H_
#define _JPINVOCATIONHANDLER_H_
extern jbyte JPypeInvocationHandler[];
jsize getJPypeInvocationHandlerLength();
#endif // JPINVOCATIONHANDLER_H
python-jpype-0.5.4.2/src/native/common/include/jp_proxy.h 0000666 0001750 0001750 00000003015 11614007722 022636 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPPROXY_H_
#define _JPPROXY_H_
class JPProxy
{
public:
JPProxy(HostRef* inst, vector& intf);
virtual ~JPProxy()
{
if (m_Instance != NULL)
{
m_Instance->release();
}
JPEnv::getJava()->DeleteGlobalRef(m_Handler);
for (unsigned int i = 0; i < m_InterfaceClasses.size(); i++)
{
JPEnv::getJava()->DeleteGlobalRef(m_InterfaceClasses[i]);
}
}
static void init();
vector getInterfaces()
{
return m_InterfaceClasses;
}
// jobject getHandler()
// {
// return JPEnv::getJava()->NewGlobalRef(m_Handler);
// }
jobject getProxy();
private :
vector m_InterfaceClasses;
jobjectArray m_Interfaces;
jobject m_Handler;
HostRef* m_Instance;
};
#endif // JPPROXY_H
python-jpype-0.5.4.2/src/native/common/include/jp_primitivetypes.h 0000666 0001750 0001750 00000032470 11614007722 024561 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPPRIMITIVETYPE_H_
#define _JPPRIMITIVETYPE_H_
class JPPrimitiveType : public JPType
{
protected :
JPPrimitiveType(JPTypeName::ETypes type, bool isObject, JPTypeName objectType)
{
m_Type = JPTypeName::fromType(type);
m_IsObject = isObject;
m_ObjectTypeName = objectType;
}
virtual ~JPPrimitiveType()
{
}
private :
JPTypeName m_Type;
bool m_IsObject;
JPTypeName m_ObjectTypeName;
public :
virtual bool isObjectType()
{
return m_IsObject;
}
virtual JPTypeName getName()
{
return m_Type;
}
virtual JPTypeName getObjectType()
{
return m_ObjectTypeName;
}
virtual jobject convertToJavaObject(HostRef* obj);
};
class JPVoidType : public JPPrimitiveType
{
public :
JPVoidType() : JPPrimitiveType(JPTypeName::_void, false, JPTypeName::fromSimple("java.lang.Void"))
{
}
virtual ~JPVoidType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPByteType : public JPPrimitiveType
{
public :
JPByteType() : JPPrimitiveType(JPTypeName::_byte, false, JPTypeName::fromSimple("java.lang.Byte"))
{
}
virtual ~JPByteType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPShortType : public JPPrimitiveType
{
public :
JPShortType() : JPPrimitiveType(JPTypeName::_short, false, JPTypeName::fromSimple("java.lang.Short"))
{
}
virtual ~JPShortType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPIntType : public JPPrimitiveType
{
public :
JPIntType(): JPPrimitiveType(JPTypeName::_int, false, JPTypeName::fromSimple("java.lang.Integer"))
{
}
virtual ~JPIntType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPLongType : public JPPrimitiveType
{
public :
JPLongType() : JPPrimitiveType(JPTypeName::_long, false, JPTypeName::fromSimple("java.lang.Long"))
{
}
virtual ~JPLongType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPFloatType : public JPPrimitiveType
{
public :
JPFloatType() : JPPrimitiveType(JPTypeName::_float, false, JPTypeName::fromSimple("java.lang.Float"))
{
}
virtual ~JPFloatType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPDoubleType : public JPPrimitiveType
{
public :
JPDoubleType() : JPPrimitiveType(JPTypeName::_double, false, JPTypeName::fromSimple("java.lang.Double"))
{
}
virtual ~JPDoubleType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPCharType : public JPPrimitiveType
{
public :
JPCharType() : JPPrimitiveType(JPTypeName::_char, false, JPTypeName::fromSimple("java.lang.Character"))
{
}
virtual ~JPCharType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
class JPBooleanType : public JPPrimitiveType
{
public :
JPBooleanType() : JPPrimitiveType(JPTypeName::_boolean, false, JPTypeName::fromSimple("java.lang.Boolean"))
{
}
virtual ~JPBooleanType()
{
}
public : // JPType implementation
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObject(jvalue val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
};
#endif // _JPPRIMITIVETYPE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_referencequeue.h 0000666 0001750 0001750 00000001650 11614007722 024463 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPREFERENCEQUEUE_H_
#define _JPREFERENCEQUEUE_H_
extern jbyte JPypeReferenceQueue[];
jsize getJPypeReferenceQueueLength();
#endif // _JPREFERENCEQUEUE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_objectbase.h 0000666 0001750 0001750 00000001651 11614007722 023562 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPOBJECTBASE_H_
#define _JPOBJECTBASE_H_
class JPObjectBase
{
protected :
JPObjectBase() {}
virtual ~JPObjectBase() {}
};
#endif // _JPOBJECTBASE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_platform_win32.h 0000666 0001750 0001750 00000003743 11614007722 024333 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _PLATFORM_WIN32_H_
#define _PLATFORM_WIN32_H_
#include
/**
* Windows-specific platform adapter
*/
class Win32PlatformAdapter : public JPPlatformAdapter
{
private :
HINSTANCE jvmLibrary;
std::string formatMessage(DWORD msgCode)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
msgCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
std::string res = std::string((LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
return res;
}
public :
virtual void loadLibrary(const char* path)
{
jvmLibrary = LoadLibrary(path);
if (jvmLibrary == NULL)
{
std::stringstream msg;
msg << "Unable to load DLL [" << path << "], error = " << formatMessage(GetLastError());
RAISE(JPypeException, msg.str().c_str());
}
}
virtual void* getSymbol(const char* name)
{
void* res = (void*)GetProcAddress(jvmLibrary, name);
if (res == NULL)
{
std::stringstream msg;
msg << "Unable to load symbol [" << name << "], error = " << formatMessage(GetLastError());
RAISE(JPypeException, msg.str().c_str());
}
return res;
}
};
#endif // _PLATFORM_WIN32_H_
python-jpype-0.5.4.2/src/native/common/include/jp_typename.h 0000666 0001750 0001750 00000005071 11614007722 023303 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPTYPENAME_H_
#define _JPTYPENAME_H_
/**
* Enum for all kinds of well-known types.
*/
/**
* Since types have multiple name representation (simple, native) and a type, this class encapsulates it all.
*/
class JPTypeName
{
public:
//AT's comments on porting:
// 1) Originally this ETypes enum was declraed outside of this JPTypeName class.
// This, however, broke compilation on AIX platform because of a conflict with some system headers;
// As a compromise, it was made part of JPTypeName
enum ETypes {
_unknown,
_void,
_byte, _short, _int, _long,
_float, _double,
_char,
_boolean,
_object,
_class,
_string,
_array
};
JPTypeName() :
m_Type(_unknown)
{
}
private :
JPTypeName(string simple, string native, ETypes t):
m_SimpleName(simple),
m_NativeName(native),
m_Type(t)
{
}
public :
/** Copy Constructor */
JPTypeName(const JPTypeName& tn) :
m_SimpleName(tn.m_SimpleName),
m_NativeName(tn.m_NativeName),
m_Type(tn.m_Type)
{
}
/** Destructor */
virtual ~JPTypeName()
{}
public :
/**
* Initialize the cache of type-name to ETypes
*/
static void init();
/** Factory method from a simple, human-readable name */
static JPTypeName fromSimple(const char* name);
static JPTypeName fromType(ETypes t);
string getSimpleName()
{
return m_SimpleName;
}
string getNativeName()
{
return m_NativeName;
}
JPTypeName getComponentName();
ETypes getType()
{
return m_Type;
}
bool isObjectType()
{
return m_Type >= _object;
}
private :
string m_SimpleName;
string m_NativeName;
ETypes m_Type;
};
#endif // _JPTYPENAME_H_
python-jpype-0.5.4.2/src/native/common/include/jp_typemanager.h 0000666 0001750 0001750 00000002777 11614007722 024007 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPTYPE_MANAGER_H_
#define _JPTYPE_MANAGER_H_
/**
* This class will manage the cache of found type, be it primitive types, class types or the "magic" types.
*/
class JPTypeManager
{
public :
/**
* Initialize the type manager caches
*/
static void init();
static JPType* getType(JPTypeName& name);
/**
* The pointer returned is NOT owned by the caller
*/
static JPClass* findClass(JPTypeName&);
/**
* The pointer returned is NOT owned by the caller
*/
static JPArrayClass* findArrayClass(JPTypeName&);
static void flushCache();
static int getLoadedClasses();
public:
};
#endif // _JPCLASS_H_
python-jpype-0.5.4.2/src/native/common/include/jp_class.h 0000666 0001750 0001750 00000005441 11614007722 022567 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPCLASS_H_
#define _JPCLASS_H_
/**
* Class to wrap Java Class and provide low-level behavior
*/
class JPClass : public JPClassBase
{
public :
JPClass(const JPTypeName& tname, jclass c);
virtual~ JPClass();
public :
/**
* Called to fully load base classes and members
*/
void postLoad();
HostRef* getStaticAttribute(string attr_name);
void setStaticAttribute(string attr_name, HostRef* val);
JPObject* newInstance(vector& args);
JPField* getInstanceField(const string& name);
JPField* getStaticField(const string& name);
JPMethod* getMethod(const string& name);
vector getMethods()
{
vector res;
for (map::iterator cur = m_Methods.begin(); cur != m_Methods.end(); cur++)
{
res.push_back(cur->second);
}
return res;
}
jclass getClass()
{
return (jclass)JPEnv::getJava()->NewGlobalRef(m_Class);
}
map& getStaticFields()
{
return m_StaticFields;
}
map& getInstanceFields()
{
return m_InstanceFields;
}
bool isFinal();
bool isAbstract();
bool isInterface()
{
return m_IsInterface;
}
JPClass* getSuperClass();
vector getInterfaces();
bool isSubclass(JPClass*);
string describe();
public : // JPType implementation
virtual HostRef* asHostObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
private :
void loadSuperClass();
void loadSuperInterfaces();
void loadFields();
void loadMethods();
void loadConstructors();
jvalue buildObjectWrapper(HostRef* obj);
private :
bool m_IsInterface;
JPClass* m_SuperClass;
vector m_SuperInterfaces;
map m_StaticFields;
map m_InstanceFields;
map m_Methods;
JPMethod* m_Constructors;
};
#endif // _JPCLASS_H_
python-jpype-0.5.4.2/src/native/common/include/jp_method.h 0000666 0001750 0001750 00000003563 11614007722 022745 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPMETHOD_H_
#define _JPMETHOD_H_
class JPObject;
class JPMethod
{
public :
/**
* Create a new method based on class and a name;
*/
JPMethod(jclass clazz, string name, bool isConstructor);
virtual ~JPMethod()
{
JPEnv::getJava()->DeleteGlobalRef(m_Class);
}
public :
string getName();
string getClassName();
void addOverload(JPClass* clazz, jobject mth);
void addOverloads(JPMethod* o);
bool hasStatic();
size_t getCount()
{
return m_Overloads.size();
}
bool isBeanMutator();
bool isBeanAccessor();
HostRef* invoke(vector&);
HostRef* invokeStatic(vector&);
HostRef* invokeInstance(vector&);
JPObject* invokeConstructor(vector& args);
string describe(string prefix);
string matchReport(vector&);
private :
JPMethodOverload* findOverload(vector& arg, bool needStatic);
jclass m_Class;
string m_Name;
map m_Overloads;
bool m_IsConstructor;
};
#endif // _JPMETHOD_H_
python-jpype-0.5.4.2/src/native/common/include/jp_objecttypes.h 0000666 0001750 0001750 00000006334 11614007722 024017 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPPOBJECTTYPE_H_
#define _JPPOBJECTTYPE_H_
class JPObjectType : public JPType
{
protected :
JPObjectType(JPTypeName::ETypes type, JPTypeName objectType) :
m_Type(JPTypeName::fromType(type)),
m_ObjectTypeName(objectType)
{
}
virtual ~JPObjectType()
{
}
public :
virtual JPTypeName getName()
{
return m_Type;
}
virtual JPTypeName getObjectType()
{
return m_ObjectTypeName;
}
virtual bool isObjectType()
{
return true;
}
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType);
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val);
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType);
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val);
virtual HostRef* asHostObjectFromObject(jvalue val);
virtual jobject convertToJavaObject(HostRef* obj);
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*);
virtual HostRef* invoke(jobject, jclass clazz, jmethodID, jvalue*);
virtual jarray newArrayInstance(int size);
virtual vector getArrayRange(jarray, int start, int length);
virtual void setArrayRange(jarray, int start, int length, vector& vals);
virtual HostRef* getArrayItem(jarray, int ndx);
virtual void setArrayItem(jarray, int ndx, HostRef* val);
virtual void setArrayValues(jarray, HostRef*);
virtual HostRef* convertToDirectBuffer(HostRef* src);
protected :
virtual jclass getClass() = 0;
private :
JPTypeName m_Type;
JPTypeName m_ObjectTypeName;
};
class JPStringType : public JPObjectType
{
public :
JPStringType() : JPObjectType(JPTypeName::_string, JPTypeName::fromSimple("java.lang.String"))
{
}
virtual ~JPStringType()
{
}
protected :
virtual jclass getClass();
public : // JPType implementation
virtual HostRef* asHostObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
};
class JPClassType : public JPObjectType
{
public :
JPClassType() : JPObjectType(JPTypeName::_class, JPTypeName::fromSimple("java.lang.Class"))
{
}
virtual ~JPClassType()
{
}
protected :
virtual jclass getClass();
public : // JPType implementation
virtual HostRef* asHostObject(jvalue val);
virtual EMatchType canConvertToJava(HostRef* obj);
virtual jvalue convertToJava(HostRef* obj);
};
#endif // _JPPOBJECTTYPE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_platform_linux.h 0000666 0001750 0001750 00000003476 11614007722 024533 0 ustar takaki takaki /*****************************************************************************
Copyright 2004-2008 Steve Menard
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.
*****************************************************************************/
#ifndef _PLATFORM_LINUX_H_
#define _PLATFORM_LINUX_H_
//AT's comments on porting:
// this file should be better called jp_platform_unix.h
#if defined(_HPUX) && !defined(_IA64)
#include
#else
#include
#endif // HPUX
class LinuxPlatformAdapter : public JPPlatformAdapter
{
private :
void* jvmLibrary;
public :
virtual void loadLibrary(const char* path)
{
#if defined(_HPUX) && !defined(_IA64)
jvmLibrary = shl_load(path, BIND_DEFERRED|BIND_VERBOSE, 0L);
#else
jvmLibrary = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
#endif // HPUX
if (jvmLibrary == NULL)
{
std::stringstream msg;
msg << "Unable to load DLL [" << path << "], error = " << dlerror();
RAISE(JPypeException, msg.str().c_str());
}
}
virtual void* getSymbol(const char* name)
{
void* res = dlsym(jvmLibrary, name);
if (res == NULL)
{
std::stringstream msg;
msg << "Unable to load symbol [" << name << "], error = " << dlerror();
RAISE(JPypeException, msg.str().c_str());
}
return res;
}
};
#endif // _PLATFORM_LINUX_H_
python-jpype-0.5.4.2/src/native/common/include/jp_classbase.h 0000666 0001750 0001750 00000002535 11614007722 023423 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPCLASS_BASE_H_
#define _JPCLASS_BASE_H_
/**
* Base class for Java Class based types
*/
class JPClassBase : public JPObjectType
{
protected :
JPClassBase(const JPTypeName& tname, jclass c);
virtual ~JPClassBase();
public : // JPType implementation
virtual JPTypeName getName()
{
return m_Name;
}
virtual JPTypeName getObjectType()
{
return m_Name;
}
virtual jclass getClass()
{
return (jclass)JPEnv::getJava()->NewLocalRef(m_Class);
}
protected :
JPTypeName m_Name;
jclass m_Class;
};
#endif // _JPCLASS_BASE_H_
python-jpype-0.5.4.2/src/native/common/include/jp_type.h 0000666 0001750 0001750 00000004623 11614007722 022444 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Ménard
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.
*****************************************************************************/
#ifndef _JPTYPE_H_
#define _JPTYPE_H_
enum EMatchType
{
_none,
_explicit,
_implicit,
_exact
};
/**
* Base class for all JPype Types, be it primitive, class or array
*/
class JPType
{
protected :
JPType()
{
}
virtual ~JPType()
{
}
public :
virtual HostRef* getStaticValue(jclass c, jfieldID fid, JPTypeName& tgtType) = 0 ;
virtual void setStaticValue(jclass c, jfieldID fid, HostRef* val) = 0 ;
virtual HostRef* getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType) = 0 ;
virtual void setInstanceValue(jobject c, jfieldID fid, HostRef* val) = 0 ;
virtual HostRef* asHostObject(jvalue val) = 0 ;
virtual HostRef* asHostObjectFromObject(jvalue val) = 0;
virtual JPTypeName getName() = 0;
virtual EMatchType canConvertToJava(HostRef* obj) = 0;
virtual jvalue convertToJava(HostRef* obj) = 0;
virtual jobject convertToJavaObject(HostRef* obj) = 0;
virtual bool isObjectType() = 0;
virtual JPTypeName getObjectType() = 0;
virtual HostRef* invokeStatic(jclass, jmethodID, jvalue*) = 0;
virtual HostRef* invoke(jobject, jclass, jmethodID, jvalue*) = 0;
virtual jarray newArrayInstance(int size) = 0;
virtual vector getArrayRange(jarray, int start, int length) = 0;
virtual void setArrayRange(jarray, int start, int length, vector& vals) = 0;
virtual HostRef* getArrayItem(jarray, int ndx) = 0;
virtual void setArrayItem(jarray, int ndx, HostRef* val) = 0;
virtual void setArrayValues(jarray, HostRef*) = 0;
virtual HostRef* convertToDirectBuffer(HostRef* src) = 0;
};
#endif // _JPTYPE_H_
python-jpype-0.5.4.2/src/native/common/include/jpype.h 0000666 0001750 0001750 00000006406 11614007722 022122 0 ustar takaki takaki /*****************************************************************************
Copyright 2004 Steve Menard
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.
*****************************************************************************/
#ifndef _JPYPE_H_
#define _JPYPE_H_
// Define this to generate the trace calls
// Define this to make the trace calls do their output. If you change this only the core.cpp needs to be recompiled
//#define JPYPE_TRACING_INTERNAL
#define JPYPE_TRACING_OUTPUT cerr
#define TRACE_IN(n) JPypeTracer _trace(n); try {
#define TRACE_OUT } catch(...) { _trace.gotError(); throw; }
#define TRACE1(m) _trace.trace(m)
#define TRACE2(m,n) _trace.trace(m,n)
#define TRACE3(m,n,o) _trace.trace(m,n,o)
#ifdef WIN32
#define JPYPE_WIN32
#ifndef __GNUC__ // Then this must mean a variant of GCC on win32 ...
#define JPYPE_WIN32_VCPP
#pragma warning (disable:4786)
#else
#endif
#else
#define JPYPE_LINUX
#endif
#include
#ifdef WIN32
#ifdef __GNUC__
// JNICALL causes problem for funtions prototypes .. since I am nto defining any JNI methods there isno need for it
#undef JNICALL
#define JNICALL
#endif
#endif
#include