[libinline-java-perl] 234/398: 0.40

Jonas Smedegaard dr at jones.dk
Thu Feb 26 11:43:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.55
in repository libinline-java-perl.

commit 85865bba71d4834381fcd8b27979343b33aa93f5
Author: patrick_leb <>
Date:   Thu Jul 10 13:35:05 2003 +0000

    0.40
---
 CHANGES                              |  3 +++
 Java.pm                              | 41 +++++++++++++++++++++++++++++++-----
 Java/Protocol.pm                     |  4 ++--
 Java/sources/InlineJavaProtocol.java | 11 +++++-----
 README                               |  3 +++
 t/02_primitives.t                    |  3 ++-
 t/08_study.t                         | 23 ++++++++++++++++++--
 7 files changed, 73 insertions(+), 15 deletions(-)

diff --git a/CHANGES b/CHANGES
index a422f31..25dda70 100644
--- a/CHANGES
+++ b/CHANGES
@@ -17,12 +17,15 @@ Revision history for Perl extension Inline::Java
             available has remained 7890.
       Note: The default port for SHARED_JVM mode is now 7891.
     - SHARED_JVM mode now calls release_JVM() automatically.
+    - UTF8 support
     - User code can now be a public class and (optionally) inside a package.
     - Callback classes have changed.
       Note: These classes are now in the org.perl.inline.java package.
       Note: PerlException has been renamed InlineJavaPerlException.
       Note: If you presently use callbacks, your code may now no longer compile.
             You will need to apply the changes listed above to fix it.
+    - study_classes now returns the package in which the studied classes
+	  have been put.
     - Many bug fixes and documentation corrections.
 
 0.33  Mon Jun 17 13:50:14 EDT 2002
diff --git a/Java.pm b/Java.pm
index 53a91ac..98f253c 100644
--- a/Java.pm
+++ b/Java.pm
@@ -641,6 +641,9 @@ sub bind_jdat {
 		$class_name =~ s/^(.*)::// ;
 
 		my $java_class = $d->{classes}->{$class}->{java_class} ;
+		if (Inline::Java::known_to_perl($o->get_api('pkg'), $java_class)){
+			next ;
+		}
 
 		my $colon = ":" ;
 		my $dash = "-" ;
@@ -993,13 +996,41 @@ sub cast {
 sub study_classes {
 	my $classes = shift ;
 
-	Inline::Java::debug(2, "selecting random module to house studied classes...") ;
+	# Here we will look to find an Inline object that is in the same 
+	# package as the caller. That way the classes can be used directly
+	# without having to use symbolic references.
+	my ($cur_pkg) = caller() ;
+	my $o = undef ;
+	foreach (@INLINES){
+		my $i = $_ ;
+		my $pkg = $i->get_api('pkg') ;
+		if ($pkg eq $cur_pkg){
+			$o = $i ;
+			last ;
+		}
+	}
+
+	my $no_pkg = 1 ;
+	if (! defined($o)){
+		srand() ;
+		$o = @INLINES[int(rand(@INLINES))] ;
+		$no_pkg = 0 ;
+	}
+
+	$o->_study($classes, 0) ;
 
-	# Select a random Inline object to be responsible for these classes
-	srand() ;
-	my $o = @INLINES[int(rand(@INLINES))] ;
+	my $pkg = undef ;
+	if ($no_pkg){
+		return $pkg ;
+	}
+	else{
+		my $pkg = $o->get_api('pkg') ;
+		if (! $pkg){
+			$pkg = "main" ;
+		}
+	}
 
-	return $o->_study($classes, 0) ;
+	return $pkg ;
 }
 
 
diff --git a/Java/Protocol.pm b/Java/Protocol.pm
index c287367..552acfa 100644
--- a/Java/Protocol.pm
+++ b/Java/Protocol.pm
@@ -410,14 +410,14 @@ sub DeserializeObject {
 sub encode {
 	my $s = shift ;
 
-	return join(".", unpack("C*", $s)) ;
+	return join(".", unpack("U*", $s)) ;
 }
 
 
 sub decode {
 	my $s = shift ;
 
-	return pack("C*", split(/\./, $s)) ;
+	return pack("U*", split(/\./, $s)) ;
 }
 
 
diff --git a/Java/sources/InlineJavaProtocol.java b/Java/sources/InlineJavaProtocol.java
index 28cdd16..0a4c45f 100644
--- a/Java/sources/InlineJavaProtocol.java
+++ b/Java/sources/InlineJavaProtocol.java
@@ -611,8 +611,8 @@ class InlineJavaProtocol {
 		StringBuffer sb = new StringBuffer() ;
 		while (st.hasMoreTokens()){
 			String ss = st.nextToken() ; 
-			byte b[] = {(byte)Integer.parseInt(ss)} ;
-			sb.append(new String(b)) ;
+			char c = (char)Integer.parseInt(ss) ;
+			sb.append(new String(new char [] {c})) ;
 		}
 	
 		return sb.toString() ;
@@ -620,13 +620,14 @@ class InlineJavaProtocol {
 
 
 	String Encode(String s){
-		byte b[] = s.getBytes() ;
+		char c[] = new char[s.length()] ;
+		s.getChars(0, c.length, c, 0) ;
 		StringBuffer sb = new StringBuffer() ;
-		for (int i = 0 ; i < b.length ; i++){
+		for (int i = 0 ; i < c.length ; i++){
 			if (i > 0){
 				sb.append(".") ;
 			}
-			sb.append(String.valueOf(b[i])) ;
+			sb.append((int)c[i]) ;
 		}
 
 		return sb.toString() ;
diff --git a/README b/README
index e19c073..e7281f7 100644
--- a/README
+++ b/README
@@ -86,12 +86,15 @@ Inline::Java version 0.40 is a major upgrade that includes:
         available has remained 7890.
   Note: The default port for SHARED_JVM mode is now 7891.
 + SHARED_JVM mode now calls release_JVM() automatically.
++ UTF8 support
 + User code can now be a public class and (optionally) inside a package.
 + Callback classes have changed.
   Note: These classes are now in the org.perl.inline.java package.
   Note: PerlException has been renamed InlineJavaPerlException.
   Note: If you presently use callbacks, your code may now no longer compile.
         You will need to apply the changes listed above to fix it.
++ study_classes now returns the package in which the studied classes
+  have been put.
 + Many bug fixes and documentation corrections.
 
 Inline::Java version 0.33 is a minor upgrade that includes:
diff --git a/t/02_primitives.t b/t/02_primitives.t
index ea39c70..038846e 100644
--- a/t/02_primitives.t
+++ b/t/02_primitives.t
@@ -10,7 +10,7 @@ use Inline (
 
 
 BEGIN {
-	plan(tests => 108) ;
+	plan(tests => 109) ;
 }
 
 
@@ -143,6 +143,7 @@ my $t = new types2() ;
 	ok($t->_String(undef), undef) ;
 	ok($t->_String(0), "0") ;
 	ok($t->_String("string"), 'string') ;
+	ok($t->_String("\x{263A}"), "\x{263A}") ;
 
 	my $str = "\r\n&&&\r\n\ntre gfd gf$$ b F D&a;t% R f &p;vf\r\r" ;
 	ok($t->_String($str), $str) ;
diff --git a/t/08_study.t b/t/08_study.t
index 860885d..11f0c22 100644
--- a/t/08_study.t
+++ b/t/08_study.t
@@ -10,6 +10,7 @@ use Inline Config =>
 use Inline(
 	Java => 'DATA',
 ) ;
+
 # There once was a bug with importing code twice.
 use Inline(
 	Java => 'STUDY',
@@ -23,18 +24,36 @@ use Inline(
 	STUDY => ['t.types'],
 	CLASSPATH => '.',
 ) ;
+
+
+package toto ;
+
+use Inline(
+	Java => 'STUDY',
+	AUTOSTUDY => 1,
+	STUDY => ['t.types'],
+	CLASSPATH => '.',
+) ;
+
+
+package study ;
+
 use Inline::Java qw(study_classes) ;
 
 
 
 BEGIN {
-	plan(tests => 9) ;
+	plan(tests => 10) ;
 }
 
-study_classes([
+my $pkg = study_classes([
 	't.no_const'
 ]) ;
 
+# There is a 'use Inline Java' somewhere in the current 
+# package, so we can call the classes directly.
+ok(! defined($pkg)) ;
+
 my $t = new study::t::types() ;
 
 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git



More information about the Pkg-perl-cvs-commits mailing list