History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg2/java/lang/System_L.b (1 of 18352 files). Show all

Unified · Split

java/pkg2/java/lang/System_L.b+133−0
@@ -0,0 +1,133 @@
1+implement System_L;
2+
3+# javal v1.2 generated file: edit with care
4+
5+include "jni.m";
6+ jni : JNI;
7+ ClassModule,
8+ JString,
9+ JArray,
10+ JArrayI,
11+ JArrayC,
12+ JArrayB,
13+ JArrayS,
14+ JArrayJ,
15+ JArrayF,
16+ JArrayD,
17+ JArrayZ,
18+ JArrayJObject,
19+ JArrayJClass,
20+ JArrayJString,
21+ JClass,
22+ JObject : import jni;
23+
24+#>> extra pre includes here
25+
26+#<<
27+
28+include "System_L.m";
29+
30+#>> extra post includes here
31+include "workdir.m";
32+
33+cast : Cast;
34+system_class : JNI->ClassData; # java.lang.System class data
35+
36+#<<
37+
38+init( jni_p : JNI )
39+{
40+ # save java native inteface mod instance
41+ jni = jni_p;
42+ #>>extra initialization here
43+ system_class = jni->FindClass( "java/lang/System" );
44+ if ( system_class == nil )
45+ jni->InitError( "System_L.init(): failed to find System class" );
46+
47+ # we Cast in this module
48+ cast = jni->CastMod();
49+ #<<
50+}
51+
52+setIn0_rInputStream_V( p0 : JObject)
53+{#>>
54+ Value : import JNI;
55+ val := ref Value.TObject(p0);
56+ jni->SetStaticField( system_class, "in", val );
57+}#<<
58+
59+setOut0_rPrintStream_V( p0 : JObject)
60+{#>>
61+ Value : import JNI;
62+ val := ref Value.TObject(p0);
63+ jni->SetStaticField( system_class, "out", val );
64+}#<<
65+
66+setErr0_rPrintStream_V( p0 : JObject)
67+{#>>
68+ Value : import JNI;
69+ val := ref Value.TObject(p0);
70+ jni->SetStaticField( system_class, "err", val );
71+}#<<
72+
73+currentTimeMillis_J( ) : big
74+{#>>
75+ fd := jni->sys->open("#c/time", jni->sys->OREAD);
76+ if(fd == nil)
77+ return big 0;
78+ buf := array[128] of byte;
79+ n := jni->sys->read(fd, buf, len buf);
80+ if(n < 0)
81+ return big 0;
82+
83+ return ( (big string buf[:n]) / big 1000 );
84+}#<<
85+
86+arraycopy_rObject_I_rObject_I_I_V( p0 : JObject,p1 : int,p2 : JObject,p3 : int,p4 : int)
87+{#>>
88+ jni->jldr->arraycopy( cast->ToJArray(p0), p1, cast->ToJArray(p2), p3, p4 );
89+}#<<
90+
91+identityHashCode_rObject_I( p0 : JObject) : int
92+{#>>
93+ return( jni->IdentityHash(p0) );
94+}#<<
95+
96+GetUserName_rString( ) : JString
97+{#>>
98+ # return the current inferno user
99+ # name as a Java String
100+ #
101+ user_name : string;
102+
103+ fd := jni->sys->open("#c/user", jni->sys->OREAD);
104+ if(fd == nil)
105+ user_name = "unknown";
106+ else {
107+ buf := array[128] of byte;
108+ n := jni->sys->read(fd, buf, len buf);
109+ if(n < 0)
110+ user_name = "unknown";
111+ else
112+ user_name = string buf[:n];
113+ }
114+
115+ # make java string from user name
116+ return( jni->NewString( user_name ) );
117+}#<<
118+
119+GetCWD_rString( ) : JString
120+{#>>
121+ # return the current working directory
122+ # as a Java String
123+ #
124+ # this fct is really only called once so
125+ # just load Workdir right here
126+ wdir := load Workdir Workdir->PATH;
127+ if ( wdir == nil )
128+ jni->InitError( jni->sys->sprint( "java.lang.System: could not load %s: %r", Workdir->PATH ) );
129+
130+ return( jni->NewString( wdir->init() ) );
131+}#<<
132+
133+