summaryrefslogtreecommitdiff
path: root/rtl/java/system.pp
blob: bc2852e2f27757701e191d41191f306dced998db (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2006 by Florian Klaempfl
    member of the Free Pascal development team.

    System unit for embedded systems

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

Unit System;

{$namespace org.freepascal.rtl}

{*****************************************************************************}
                                    interface
{*****************************************************************************}

{$define FPC_IS_SYSTEM}

{$I-,Q-,H-,R-,V-,P+,T+}
{$implicitexceptions off}
{$mode objfpc}
{$modeswitch advancedrecords}

Type
  { Java primitive types }
  jboolean = boolean;
  pjboolean = ^boolean;
  jbyte = shortint;
  pjbyte = ^jbyte;
  jshort = smallint;
  pjshort = ^jshort;
  jint = longint;
  pjint = ^jint;
  jlong = int64;
  pjlong = ^jlong;
  jchar = widechar;
  pjchar = ^jchar;
  jfloat = single;
  pjfloat = ^jfloat;
  jdouble = double;
  pjdouble = ^jdouble;

  Arr1jboolean = array of jboolean;
  Arr1jbyte = array of jbyte;
  Arr1jshort = array of jshort;
  Arr1jint = array of jint;
  Arr1jlong = array of jlong;
  Arr1jchar = array of jchar;
  Arr1jfloat = array of jfloat;
  Arr1jdouble = array of jdouble;

  Arr2jboolean = array of Arr1jboolean;
  Arr2jbyte = array of Arr1jbyte;
  Arr2jshort = array of Arr1jshort;
  Arr2jint = array of Arr1jint;
  Arr2jlong = array of Arr1jlong;
  Arr2jchar = array of Arr1jchar;
  Arr2jfloat = array of Arr1jfloat;
  Arr2jdouble = array of Arr1jdouble;

  Arr3jboolean = array of Arr2jboolean;
  Arr3jbyte = array of Arr2jbyte;
  Arr3jshort = array of Arr2jshort;
  Arr3jint = array of Arr2jint;
  Arr3jlong = array of Arr2jlong;
  Arr3jchar = array of Arr2jchar;
  Arr3jfloat = array of Arr2jfloat;
  Arr3jdouble = array of Arr2jdouble;

const
  maxExitCode = 255;


{ Java base class type }
{$ifdef java}
{$define GOTJAVASYSINCLUDE}
{$i java_sysh.inc}
{$i java_sys.inc}
{$endif}

{$ifdef android}
{$define GOTJAVASYSINCLUDE}
{$i java_sysh_android.inc}
{$i java_sys_android.inc}
{$endif}

{$ifndef GOTJAVASYSINCLUDE}
{$error Missing include file with base Java classes}
{$endif}

  FpcEnumValueObtainable = interface
    function fpcOrdinal: jint;
    function fpcGenericValueOf(__fpc_int: longint): JLEnum;
  end;

{ generic versions are based on FPC/Delphi-style RTTI }
{$define FPC_STR_ENUM_INTERN}

{$i jrech.inc}
{$i jseth.inc}
{$i jpvarh.inc}

{$i jsystemh_types.inc}

{$i jtvarh.inc}
{$i jsstringh.inc}
{$i jdynarrh.inc}
{$i jastringh.inc}
{$i justringh.inc}

{$i jsystemh.inc}
{$i jtconh.inc}


{*****************************************************************************}
                                 implementation
{*****************************************************************************}

function min(a,b : longint) : longint;
  begin
     if a<=b then
       min:=a
     else
       min:=b;
  end;

{$i jtcon.inc}
{$i jtvar.inc}
{$i jsstrings.inc}
{$i jastrings.inc}
{$i justrings.inc}
{$i jrec.inc}
{$i jset.inc}
{$i jpvar.inc}
{$i jdynarr.inc}
{$i jsystem.inc}


{*****************************************************************************
                       Misc. System Dependent Functions
*****************************************************************************}

procedure System_exit;
  begin
    JLRuntime.getRuntime.exit(ExitCode);
  end;


procedure randomize;
  begin
    randseed:=JUCalendar.getInstance.getTimeInMillis;
  end;


type
  CopyOutVarModifiedException = class(JLException)
  end;

procedure fpc_var_copyout_mismatch(line,column: longint); compilerproc;
  var
    linestr,columnstr: unicodestring;
  begin
    str(line,linestr);
    str(column,columnstr);
    raise CopyOutVarModifiedException.create('Var parameter ending at line '+linestr+' column '+columnstr+' in the previous stack frame has been modified to a different value than the returned copyback value');
  end;

{*****************************************************************************
                         SystemUnit Initialization
*****************************************************************************}

begin
 initunicodestringmanager
end.