File: InlineJavaPerlObject.java

package info (click to toggle)
libinline-java-perl 0.67-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 716 kB
  • sloc: perl: 3,817; java: 2,621; makefile: 35; sh: 1
file content (74 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package org.perl.inline.java ;


/*
	InlineJavaPerlObject
*/
public class InlineJavaPerlObject extends InlineJavaPerlCaller {
	private int id = 0 ;
	private String pkg = null ;


	/* 
		Creates a Perl Object by calling 
			pkg->new(args) ;
	*/
	public InlineJavaPerlObject(String _pkg, Object args[]) throws InlineJavaPerlException, InlineJavaException {
		pkg = _pkg ;
		InlineJavaPerlObject stub = (InlineJavaPerlObject)CallPerlStaticMethod(pkg, "new", args, getClass()) ;
		id = stub.GetId() ;
		stub.id = 0 ;
	}


	/*
		This is just a stub for already existing objects
	*/
	InlineJavaPerlObject(String _pkg, int _id) throws InlineJavaException {
		pkg = _pkg ;
		id = _id ;
	}


	int GetId(){
		return id ;
	}


	public String GetPkg(){
		return pkg ;
	}


	public Object InvokeMethod(String name, Object args[]) throws InlineJavaPerlException, InlineJavaException {
		return InvokeMethod(name, args, null) ;
	}


	public Object InvokeMethod(String name, Object args[], Class cast) throws InlineJavaPerlException, InlineJavaException {
		return CallPerlMethod(this, name, args, cast) ;
	}


	public void Dispose() throws InlineJavaPerlException, InlineJavaException {
		Dispose(false) ;
	}


	protected void Dispose(boolean gc) throws InlineJavaPerlException, InlineJavaException {
		if (id != 0){
			CallPerlSub("Inline::Java::Callback::java_finalize", new Object [] {Integer.valueOf(id), Boolean.valueOf(gc)}) ;
		}
	}

	/* unavoidable due to Perl reference-count behaviour */
	@SuppressWarnings("deprecation")
	protected void finalize() throws Throwable {
		try {
			Dispose(true) ;
		}
		finally {
			super.finalize() ;
		}
	}
}