michael@0: /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.util; michael@0: michael@0: import org.mozilla.gecko.mozglue.JNITarget; michael@0: michael@0: /** michael@0: * NativeJSContainer is a wrapper around the SpiderMonkey JSAPI to make it possible to michael@0: * access Javascript objects in Java. michael@0: * michael@0: * A container must only be used on the thread it is attached to. To use it on another michael@0: * thread, call {@link #clone()} to make a copy, and use the copy on the other thread. michael@0: * When a copy is first used, it becomes attached to the thread using it. michael@0: */ michael@0: @JNITarget michael@0: public final class NativeJSContainer extends NativeJSObject michael@0: { michael@0: private long mNativeObject; michael@0: michael@0: private NativeJSContainer(long nativeObject) { michael@0: mNativeObject = nativeObject; michael@0: } michael@0: michael@0: /** michael@0: * Make a copy of this container for use by another thread. When the copy is first used, michael@0: * it becomes attached to the thread using it. michael@0: */ michael@0: @Override michael@0: public native NativeJSContainer clone(); michael@0: michael@0: /** michael@0: * Dispose all associated native objects. Subsequent use of any objects derived from michael@0: * this container will throw a NullPointerException. michael@0: */ michael@0: public native void dispose(); michael@0: }