All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.python.modules._bytecodetools Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

The newest version!
package org.python.modules;

import org.python.core.BytecodeNotification;
import org.python.core.PyObject;
import org.python.core.Py;

/**
 * BytecodeTools provides tools for generated JVM bytecode.
 * 

* This module supports registering a python callback function * to be notified when new bytecode is loaded. * see also core/BytecodeNotification.java */ public class _bytecodetools { public static final String __doc__ = "Provides utilities for generated bytecode.\n"; public static final String __name__ = "BytecodeTools"; static class _Callback implements BytecodeNotification.Callback { PyObject callback; public _Callback(PyObject callback) { this.callback = callback; } public void notify(String name, byte[] bytes, Class c) { callback.__call__(Py.java2py(name), Py.java2py(bytes), Py.java2py(c)); } public int hashCode() { return callback.hashCode(); } public boolean equals(Object other) { if (!(other instanceof _Callback)) return false; _Callback that = (_Callback) other; return callback.equals(that.callback); } } /** * Registers a python callback function that will be notified on bytecode loading. * * @param callback a Python callback function */ public static void register(final PyObject callback) { BytecodeNotification.register(new _Callback(callback)); } /** * Unregisters a python callback function. * * @param callback a Python callback function */ public static boolean unregister(final PyObject callback) { return BytecodeNotification.unregister(new _Callback(callback)); } /** * Clears all the registered callbacks. */ public static void clear() { BytecodeNotification.clear(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy