Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
42c4f92d
提交
42c4f92d
authored
7月 12, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documentation / cleanup
上级
e4842f9d
全部展开
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
529 行增加
和
149 行删除
+529
-149
ClassObj.java
h2/src/tools/org/h2/java/ClassObj.java
+31
-1
Expr.java
h2/src/tools/org/h2/java/Expr.java
+168
-78
JavaParser.java
h2/src/tools/org/h2/java/JavaParser.java
+47
-25
Statement.java
h2/src/tools/org/h2/java/Statement.java
+206
-31
Test.java
h2/src/tools/org/h2/java/Test.java
+3
-2
TestApp.java
h2/src/tools/org/h2/java/TestApp.java
+27
-2
PrintStream.java
h2/src/tools/org/h2/java/io/PrintStream.java
+1
-1
Integer.java
h2/src/tools/org/h2/java/lang/Integer.java
+7
-1
Long.java
h2/src/tools/org/h2/java/lang/Long.java
+7
-1
String.java
h2/src/tools/org/h2/java/lang/String.java
+28
-3
System.java
h2/src/tools/org/h2/java/lang/System.java
+4
-4
没有找到文件。
h2/src/tools/org/h2/java/ClassObj.java
浏览文件 @
42c4f92d
...
@@ -372,6 +372,11 @@ class Type {
...
@@ -372,6 +372,11 @@ class Type {
return
asString
();
return
asString
();
}
}
/**
* Get the C++ code.
*
* @return the C++ code
*/
public
String
asString
()
{
public
String
asString
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
arrayLevel
;
i
++)
{
for
(
int
i
=
0
;
i
<
arrayLevel
;
i
++)
{
...
@@ -392,11 +397,15 @@ class Type {
...
@@ -392,11 +397,15 @@ class Type {
}
}
}
}
for
(
int
i
=
0
;
i
<
arrayLevel
;
i
++)
{
for
(
int
i
=
0
;
i
<
arrayLevel
;
i
++)
{
buff
.
append
(
" >"
);
if
(
refCount
)
{
if
(
refCount
)
{
buff
.
append
(
" >"
);
buff
.
append
(
" >"
);
}
else
{
if
(!
classObj
.
isPrimitive
)
{
buff
.
append
(
"*"
);
}
}
}
}
buff
.
append
(
" >"
);
}
if
(!
refCount
)
{
if
(!
refCount
)
{
if
(
isObject
())
{
if
(
isObject
())
{
buff
.
append
(
"*"
);
buff
.
append
(
"*"
);
...
@@ -417,5 +426,26 @@ class Type {
...
@@ -417,5 +426,26 @@ class Type {
return
false
;
return
false
;
}
}
/**
* Get the default value, for primitive types (0 usually).
*
* @param context the context
* @return the expression
*/
public
Expr
getDefaultValue
(
JavaParser
context
)
{
if
(
classObj
.
isPrimitive
)
{
LiteralExpr
literal
=
new
LiteralExpr
(
context
,
classObj
.
className
);
literal
.
literal
=
"0"
;
CastExpr
cast
=
new
CastExpr
();
cast
.
type
=
this
;
cast
.
expr
=
literal
;
cast
.
type
=
this
;
return
cast
;
}
LiteralExpr
literal
=
new
LiteralExpr
(
context
,
classObj
.
className
);
literal
.
literal
=
"null"
;
return
literal
;
}
}
}
h2/src/tools/org/h2/java/Expr.java
浏览文件 @
42c4f92d
差异被折叠。
点击展开。
h2/src/tools/org/h2/java/JavaParser.java
浏览文件 @
42c4f92d
...
@@ -22,7 +22,15 @@ import org.h2.util.New;
...
@@ -22,7 +22,15 @@ import org.h2.util.New;
*/
*/
public
class
JavaParser
{
public
class
JavaParser
{
public
static
final
boolean
REF_COUNT
=
true
;
/**
* Whether ref-counting is used.
*/
public
static
final
boolean
REF_COUNT
=
false
;
/**
* Whether ref-counting is used for constants.
*/
public
static
final
boolean
REF_COUNT_STATIC
=
false
;
private
static
final
HashMap
<
String
,
ClassObj
>
BUILT_IN_CLASSES
=
New
.
hashMap
();
private
static
final
HashMap
<
String
,
ClassObj
>
BUILT_IN_CLASSES
=
New
.
hashMap
();
...
@@ -245,6 +253,12 @@ public class JavaParser {
...
@@ -245,6 +253,12 @@ public class JavaParser {
return
c
;
return
c
;
}
}
/**
* Get the class for a built-in type.
*
* @param type the type
* @return the class or null if not found
*/
static
ClassObj
getBuiltInClass
(
String
type
)
{
static
ClassObj
getBuiltInClass
(
String
type
)
{
return
BUILT_IN_CLASSES
.
get
(
type
);
return
BUILT_IN_CLASSES
.
get
(
type
);
}
}
...
@@ -386,6 +400,8 @@ public class JavaParser {
...
@@ -386,6 +400,8 @@ public class JavaParser {
}
else
{
}
else
{
field
.
value
=
readExpr
();
field
.
value
=
readExpr
();
}
}
}
else
{
field
.
value
=
field
.
type
.
getDefaultValue
(
this
);
}
}
read
(
";"
);
read
(
";"
);
if
(
isStatic
)
{
if
(
isStatic
)
{
...
@@ -495,8 +511,8 @@ public class JavaParser {
...
@@ -495,8 +511,8 @@ public class JavaParser {
while
(
source
.
charAt
(
current
.
index
)
!=
'\n'
)
{
while
(
source
.
charAt
(
current
.
index
)
!=
'\n'
)
{
current
.
index
++;
current
.
index
++;
}
}
St
atementNative
stat
=
new
StatementNative
();
St
ring
s
=
source
.
substring
(
start
,
current
.
index
).
trim
();
stat
.
code
=
source
.
substring
(
start
,
current
.
index
).
trim
(
);
StatementNative
stat
=
new
StatementNative
(
s
);
read
();
read
();
return
isC
?
stat
:
null
;
return
isC
?
stat
:
null
;
}
else
if
(
readIf
(
"/*"
))
{
}
else
if
(
readIf
(
"/*"
))
{
...
@@ -505,8 +521,8 @@ public class JavaParser {
...
@@ -505,8 +521,8 @@ public class JavaParser {
while
(
source
.
charAt
(
current
.
index
)
!=
'*'
||
source
.
charAt
(
current
.
index
+
1
)
!=
'/'
)
{
while
(
source
.
charAt
(
current
.
index
)
!=
'*'
||
source
.
charAt
(
current
.
index
+
1
)
!=
'/'
)
{
current
.
index
++;
current
.
index
++;
}
}
St
atementNative
stat
=
new
StatementNative
();
St
ring
s
=
source
.
substring
(
start
,
current
.
index
).
trim
();
stat
.
code
=
source
.
substring
(
start
,
current
.
index
).
trim
(
);
StatementNative
stat
=
new
StatementNative
(
s
);
current
.
index
+=
2
;
current
.
index
+=
2
;
read
();
read
();
return
isC
?
stat
:
null
;
return
isC
?
stat
:
null
;
...
@@ -554,16 +570,16 @@ public class JavaParser {
...
@@ -554,16 +570,16 @@ public class JavaParser {
read
(
";"
);
read
(
";"
);
return
new
ContinueStatement
();
return
new
ContinueStatement
();
}
else
if
(
readIf
(
"switch"
))
{
}
else
if
(
readIf
(
"switch"
))
{
SwitchStatement
switchStat
=
new
SwitchStatement
();
read
(
"("
);
read
(
"("
);
switchStat
.
expr
=
readExpr
(
);
SwitchStatement
switchStat
=
new
SwitchStatement
(
readExpr
()
);
read
(
")"
);
read
(
")"
);
read
(
"{"
);
read
(
"{"
);
while
(
true
)
{
while
(
true
)
{
if
(
readIf
(
"default"
))
{
if
(
readIf
(
"default"
))
{
read
(
":"
);
read
(
":"
);
StatementBlock
block
=
new
StatementBlock
();
StatementBlock
block
=
new
StatementBlock
();
switchStat
.
defaultBlock
=
block
;
switchStat
.
setDefaultBlock
(
block
)
;
while
(
true
)
{
while
(
true
)
{
block
.
instructions
.
add
(
readStatement
());
block
.
instructions
.
add
(
readStatement
());
if
(
current
.
token
.
equals
(
"case"
)
||
current
.
token
.
equals
(
"default"
)
||
current
.
token
.
equals
(
"}"
))
{
if
(
current
.
token
.
equals
(
"case"
)
||
current
.
token
.
equals
(
"default"
)
||
current
.
token
.
equals
(
"}"
))
{
...
@@ -571,7 +587,7 @@ public class JavaParser {
...
@@ -571,7 +587,7 @@ public class JavaParser {
}
}
}
}
}
else
if
(
readIf
(
"case"
))
{
}
else
if
(
readIf
(
"case"
))
{
switchStat
.
cases
.
add
(
readExpr
()
);
Expr
expr
=
readExpr
(
);
read
(
":"
);
read
(
":"
);
StatementBlock
block
=
new
StatementBlock
();
StatementBlock
block
=
new
StatementBlock
();
while
(
true
)
{
while
(
true
)
{
...
@@ -580,7 +596,7 @@ public class JavaParser {
...
@@ -580,7 +596,7 @@ public class JavaParser {
break
;
break
;
}
}
}
}
switchStat
.
blocks
.
add
(
block
);
switchStat
.
addCase
(
expr
,
block
);
}
else
if
(
readIf
(
"}"
))
{
}
else
if
(
readIf
(
"}"
))
{
break
;
break
;
}
}
...
@@ -654,8 +670,7 @@ public class JavaParser {
...
@@ -654,8 +670,7 @@ public class JavaParser {
f
.
type
=
dec
.
type
;
f
.
type
=
dec
.
type
;
f
.
name
=
varName
;
f
.
name
=
varName
;
localVars
.
put
(
varName
,
f
);
localVars
.
put
(
varName
,
f
);
dec
.
variables
.
add
(
varName
);
dec
.
addVariable
(
varName
,
value
);
dec
.
values
.
add
(
value
);
if
(
readIf
(
";"
))
{
if
(
readIf
(
";"
))
{
break
;
break
;
}
}
...
@@ -666,8 +681,7 @@ public class JavaParser {
...
@@ -666,8 +681,7 @@ public class JavaParser {
current
=
start
;
current
=
start
;
// ExprStatement
// ExprStatement
}
}
ExprStatement
stat
=
new
ExprStatement
();
ExprStatement
stat
=
new
ExprStatement
(
readExpr
());
stat
.
expr
=
readExpr
();
read
(
";"
);
read
(
";"
);
return
stat
;
return
stat
;
}
}
...
@@ -992,7 +1006,7 @@ public class JavaParser {
...
@@ -992,7 +1006,7 @@ public class JavaParser {
if
(
ch
>=
'a'
&&
ch
<=
'z'
)
{
if
(
ch
>=
'a'
&&
ch
<=
'z'
)
{
// don't use Character.toUpperCase
// don't use Character.toUpperCase
// to avoid locale problems
// to avoid locale problems
// (the uppercase of
i isn't always I
)
// (the uppercase of
'i' is not always 'I'
)
buff
.
append
((
char
)
(
ch
+
'A'
-
'a'
));
buff
.
append
((
char
)
(
ch
+
'A'
-
'a'
));
}
else
if
(
ch
>=
'A'
&&
ch
<=
'Z'
)
{
}
else
if
(
ch
>=
'A'
&&
ch
<=
'Z'
)
{
buff
.
append
(
ch
);
buff
.
append
(
ch
);
...
@@ -1026,7 +1040,7 @@ public class JavaParser {
...
@@ -1026,7 +1040,7 @@ public class JavaParser {
private
Expr
readExpr5
()
{
private
Expr
readExpr5
()
{
if
(
readIf
(
"new"
))
{
if
(
readIf
(
"new"
))
{
NewExpr
expr
=
new
NewExpr
(
this
);
NewExpr
expr
=
new
NewExpr
();
String
typeName
=
readTypeOrIdentifier
();
String
typeName
=
readTypeOrIdentifier
();
expr
.
classObj
=
getClass
(
typeName
);
expr
.
classObj
=
getClass
(
typeName
);
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
...
@@ -1550,7 +1564,12 @@ public class JavaParser {
...
@@ -1550,7 +1564,12 @@ public class JavaParser {
*/
*/
void
writeHeader
(
PrintWriter
out
)
{
void
writeHeader
(
PrintWriter
out
)
{
for
(
Statement
s
:
nativeHeaders
)
{
for
(
Statement
s
:
nativeHeaders
)
{
out
.
println
(
s
);
out
.
println
(
s
.
asString
());
}
if
(
JavaParser
.
REF_COUNT_STATIC
)
{
out
.
println
(
"#define STRING(s) STRING_REF(s)"
);
}
else
{
out
.
println
(
"#define STRING(s) STRING_PTR(s)"
);
}
}
out
.
println
();
out
.
println
();
for
(
ClassObj
c
:
classes
.
values
())
{
for
(
ClassObj
c
:
classes
.
values
())
{
...
@@ -1603,9 +1622,6 @@ public class JavaParser {
...
@@ -1603,9 +1622,6 @@ public class JavaParser {
for
(
FieldObj
f
:
c
.
instanceFields
.
values
())
{
for
(
FieldObj
f
:
c
.
instanceFields
.
values
())
{
out
.
print
(
" "
);
out
.
print
(
" "
);
out
.
print
(
f
.
type
.
asString
()
+
" "
+
f
.
name
);
out
.
print
(
f
.
type
.
asString
()
+
" "
+
f
.
name
);
if
(
f
.
value
!=
null
)
{
out
.
print
(
" = "
+
f
.
value
);
}
out
.
println
(
";"
);
out
.
println
(
";"
);
}
}
out
.
println
(
"public:"
);
out
.
println
(
"public:"
);
...
@@ -1640,7 +1656,7 @@ public class JavaParser {
...
@@ -1640,7 +1656,7 @@ public class JavaParser {
Collections
.
sort
(
constantNames
);
Collections
.
sort
(
constantNames
);
for
(
String
c
:
constantNames
)
{
for
(
String
c
:
constantNames
)
{
String
s
=
stringConstantToStringMap
.
get
(
c
);
String
s
=
stringConstantToStringMap
.
get
(
c
);
if
(
JavaParser
.
REF_COUNT
)
{
if
(
JavaParser
.
REF_COUNT
_STATIC
)
{
out
.
println
(
"ptr<java_lang_String> "
+
c
+
" = STRING(L\""
+
s
+
"\");"
);
out
.
println
(
"ptr<java_lang_String> "
+
c
+
" = STRING(L\""
+
s
+
"\");"
);
}
else
{
}
else
{
out
.
println
(
"java_lang_String* "
+
c
+
" = STRING(L\""
+
s
+
"\");"
);
out
.
println
(
"java_lang_String* "
+
c
+
" = STRING(L\""
+
s
+
"\");"
);
...
@@ -1655,9 +1671,9 @@ public class JavaParser {
...
@@ -1655,9 +1671,9 @@ public class JavaParser {
*/
*/
void
writeSource
(
PrintWriter
out
)
{
void
writeSource
(
PrintWriter
out
)
{
for
(
ClassObj
c
:
classes
.
values
())
{
for
(
ClassObj
c
:
classes
.
values
())
{
out
.
println
(
"/* "
+
c
.
className
+
"
.cpp
*/"
);
out
.
println
(
"/* "
+
c
.
className
+
" */"
);
for
(
Statement
s
:
c
.
nativeCode
)
{
for
(
Statement
s
:
c
.
nativeCode
)
{
out
.
println
(
s
);
out
.
println
(
s
.
asString
()
);
}
}
for
(
FieldObj
f
:
c
.
staticFields
.
values
())
{
for
(
FieldObj
f
:
c
.
staticFields
.
values
())
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
@@ -1694,10 +1710,16 @@ public class JavaParser {
...
@@ -1694,10 +1710,16 @@ public class JavaParser {
}
}
out
.
println
(
") {"
);
out
.
println
(
") {"
);
if
(
m
.
isConstructor
)
{
if
(
m
.
isConstructor
)
{
// TODO
for
(
FieldObj
f
:
c
.
instanceFields
.
values
())
{
out
.
print
(
" "
);
out
.
print
(
"this->"
+
f
.
name
);
out
.
print
(
" = "
+
f
.
value
.
asString
());
out
.
println
(
";"
);
}
}
}
if
(
m
.
block
!=
null
)
{
if
(
m
.
block
!=
null
)
{
out
.
print
(
m
.
block
.
toString
());
m
.
block
.
setMethod
(
m
);
out
.
print
(
m
.
block
.
asString
());
}
}
out
.
println
(
"}"
);
out
.
println
(
"}"
);
out
.
println
();
out
.
println
();
...
...
h2/src/tools/org/h2/java/Statement.java
浏览文件 @
42c4f92d
差异被折叠。
点击展开。
h2/src/tools/org/h2/java/Test.java
浏览文件 @
42c4f92d
...
@@ -30,11 +30,12 @@ public class Test extends TestBase {
...
@@ -30,11 +30,12 @@ public class Test extends TestBase {
// chmod +x test
// chmod +x test
// ./test
// ./test
// TODO initialize fields
// include files:
// include files:
// /usr/include/c++/4.2.1/tr1/stdio.h
// /usr/include/c++/4.2.1/tr1/stdio.h
// /usr/include/stdio.h
// /usr/include/stdio.h
// inttypes.h
// TODO initialize fields
// not supported yet:
// not supported yet:
// exceptions
// exceptions
...
...
h2/src/tools/org/h2/java/TestApp.java
浏览文件 @
42c4f92d
...
@@ -26,8 +26,33 @@ int main(int argc, char** argv) {
...
@@ -26,8 +26,33 @@ int main(int argc, char** argv) {
* @param args the command line arguments
* @param args the command line arguments
*/
*/
public
static
void
main
(
String
...
args
)
{
public
static
void
main
(
String
...
args
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
String
[]
list
=
new
String
[
1000
];
System
.
out
.
println
(
"Hello "
+
i
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
list
[
i
]
=
"Hello "
+
i
;
}
// time:29244000 mac g++ -O3 without array bound checks
// time:30673000 mac java
// time:32449000 mac g++ -O3
// time:69692000 mac g++ -O3 ref counted
// time:1200000000 raspberry g++ -O3
// time:1720000000 raspberry g++ -O3 ref counted
// time:1980469000 raspberry java IcedTea6 1.8.13 Cacao VM
// time:12962645810 raspberry java IcedTea6 1.8.13 Zero VM
// java -XXaltjvm=cacao
for
(
int
k
=
0
;
k
<
4
;
k
++)
{
long
t
=
System
.
nanoTime
();
long
h
=
0
;
for
(
int
j
=
0
;
j
<
10000
;
j
++)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
String
s
=
list
[
i
];
h
=
(
h
*
7
)
^
s
.
hashCode
();
}
}
System
.
out
.
println
(
"hash: "
+
h
);
t
=
System
.
nanoTime
()
-
t
;
System
.
out
.
println
(
"time:"
+
t
);
}
}
}
}
...
...
h2/src/tools/org/h2/java/io/PrintStream.java
浏览文件 @
42c4f92d
...
@@ -18,7 +18,7 @@ public class PrintStream {
...
@@ -18,7 +18,7 @@ public class PrintStream {
*/
*/
public
void
println
(
String
s
)
{
public
void
println
(
String
s
)
{
// c: int x = s->chars->length();
// c: int x = s->chars->length();
// c: printf("%.*S\n", x, s->chars->get
Data
());
// c: printf("%.*S\n", x, s->chars->get
Pointer
());
}
}
}
}
h2/src/tools/org/h2/java/lang/Integer.java
浏览文件 @
42c4f92d
...
@@ -11,8 +11,14 @@ package org.h2.java.lang;
...
@@ -11,8 +11,14 @@ package org.h2.java.lang;
*/
*/
public
class
Integer
{
public
class
Integer
{
/**
* The smallest possible value.
*/
public
static
final
int
MIN_VALUE
=
1
<<
31
;
public
static
final
int
MIN_VALUE
=
1
<<
31
;
/**
* The largest possible value.
*/
public
static
final
int
MAX_VALUE
=
(
int
)
((
1L
<<
31
)
-
1
);
public
static
final
int
MAX_VALUE
=
(
int
)
((
1L
<<
31
)
-
1
);
/**
/**
...
@@ -23,7 +29,7 @@ public class Integer {
...
@@ -23,7 +29,7 @@ public class Integer {
*/
*/
public
static
String
toString
(
int
x
)
{
public
static
String
toString
(
int
x
)
{
// c: wchar_t ch[20];
// c: wchar_t ch[20];
// c: swprintf(ch, 20, L"%
d"
, x);
// c: swprintf(ch, 20, L"%
" PRId32
, x);
// c: return STRING(ch);
// c: return STRING(ch);
// c: return;
// c: return;
if
(
x
==
MIN_VALUE
)
{
if
(
x
==
MIN_VALUE
)
{
...
...
h2/src/tools/org/h2/java/lang/Long.java
浏览文件 @
42c4f92d
...
@@ -12,8 +12,14 @@ package org.h2.java.lang;
...
@@ -12,8 +12,14 @@ package org.h2.java.lang;
*/
*/
public
class
Long
{
public
class
Long
{
/**
* The smallest possible value.
*/
public
static
final
long
MIN_VALUE
=
1L
<<
63
;
public
static
final
long
MIN_VALUE
=
1L
<<
63
;
/**
* The largest possible value.
*/
public
static
final
long
MAX_VALUE
=
(
1L
<<
63
)
-
1
;
public
static
final
long
MAX_VALUE
=
(
1L
<<
63
)
-
1
;
/**
/**
...
@@ -24,7 +30,7 @@ public class Long {
...
@@ -24,7 +30,7 @@ public class Long {
*/
*/
public
static
String
toString
(
long
x
)
{
public
static
String
toString
(
long
x
)
{
// c: wchar_t ch[30];
// c: wchar_t ch[30];
// c: swprintf(ch, 30, L"%
ld"
, x);
// c: swprintf(ch, 30, L"%
" PRId64
, x);
// c: return STRING(ch);
// c: return STRING(ch);
// c: return;
// c: return;
if
(
x
==
MIN_VALUE
)
{
if
(
x
==
MIN_VALUE
)
{
...
...
h2/src/tools/org/h2/java/lang/String.java
浏览文件 @
42c4f92d
...
@@ -14,8 +14,11 @@ import org.h2.java.Local;
...
@@ -14,8 +14,11 @@ import org.h2.java.Local;
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wchar.h>
#include <stdint.h>
#include <stdint.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#define jvoid void
#define jvoid void
#define jboolean int8_t
#define jboolean int8_t
...
@@ -31,9 +34,12 @@ import org.h2.java.Local;
...
@@ -31,9 +34,12 @@ import org.h2.java.Local;
#define false 0
#define false 0
#define null 0
#define null 0
#define STRING(s) ptr<java_lang_String>(new java_lang_String(ptr< array<jchar> >(new array<jchar>(s, (jint) wcslen(s)))));
#define STRING_REF(s) ptr<java_lang_String> \
(new java_lang_String(ptr< array<jchar> > \
(new array<jchar>(s, (jint) wcslen(s)))));
// #define STRING(s) new java_lang_String(new array<jchar>(s, (jint) wcslen(s)));
#define STRING_PTR(s) new java_lang_String \
(new array<jchar>(s, (jint) wcslen(s)));
class RefBase {
class RefBase {
protected:
protected:
...
@@ -86,6 +92,9 @@ public:
...
@@ -86,6 +92,9 @@ public:
T& operator*() {
T& operator*() {
return *pointer;
return *pointer;
}
}
T* getPointer() {
return pointer;
}
T* operator->() {
T* operator->() {
return pointer;
return pointer;
}
}
...
@@ -112,7 +121,7 @@ public:
...
@@ -112,7 +121,7 @@ public:
~array() {
~array() {
delete[] data;
delete[] data;
}
}
T* get
Data
() {
T* get
Pointer
() {
return data;
return data;
}
}
jint length() {
jint length() {
...
@@ -180,15 +189,31 @@ public class String {
...
@@ -180,15 +189,31 @@ public class String {
return
chars
.
length
;
return
chars
.
length
;
}
}
/**
* The toString method.
*
* @return the string
*/
public
String
toStringMethod
()
{
public
String
toStringMethod
()
{
return
this
;
return
this
;
}
}
/**
* Get the java.lang.String.
*
* @return the string
*/
@Ignore
@Ignore
public
java
.
lang
.
String
asString
()
{
public
java
.
lang
.
String
asString
()
{
return
new
java
.
lang
.
String
(
chars
);
return
new
java
.
lang
.
String
(
chars
);
}
}
/**
* Wrap a java.lang.String.
*
* @param x the string
* @return the object
*/
@Ignore
@Ignore
public
static
String
wrap
(
java
.
lang
.
String
x
)
{
public
static
String
wrap
(
java
.
lang
.
String
x
)
{
return
new
String
(
x
.
toCharArray
());
return
new
String
(
x
.
toCharArray
());
...
...
h2/src/tools/org/h2/java/lang/System.java
浏览文件 @
42c4f92d
...
@@ -30,8 +30,8 @@ public class System {
...
@@ -30,8 +30,8 @@ public class System {
*/
*/
public
static
void
arraycopy
(
char
[]
src
,
int
srcPos
,
char
[]
dest
,
int
destPos
,
int
length
)
{
public
static
void
arraycopy
(
char
[]
src
,
int
srcPos
,
char
[]
dest
,
int
destPos
,
int
length
)
{
/* c:
/* c:
memmove(((jchar*)dest->get
Data
()) + destPos,
memmove(((jchar*)dest->get
Pointer
()) + destPos,
((jchar*)src->get
Data
()) + srcPos, sizeof(jchar) * length);
((jchar*)src->get
Pointer
()) + srcPos, sizeof(jchar) * length);
*/
*/
// c: return;
// c: return;
java
.
lang
.
System
.
arraycopy
(
src
,
srcPos
,
dest
,
destPos
,
length
);
java
.
lang
.
System
.
arraycopy
(
src
,
srcPos
,
dest
,
destPos
,
length
);
...
@@ -49,8 +49,8 @@ public class System {
...
@@ -49,8 +49,8 @@ public class System {
*/
*/
public
static
void
arraycopy
(
byte
[]
src
,
int
srcPos
,
byte
[]
dest
,
int
destPos
,
int
length
)
{
public
static
void
arraycopy
(
byte
[]
src
,
int
srcPos
,
byte
[]
dest
,
int
destPos
,
int
length
)
{
/* c:
/* c:
memmove(((jbyte*)dest->get
Data
()) + destPos,
memmove(((jbyte*)dest->get
Pointer
()) + destPos,
((jbyte*)src->get
Data
()) + srcPos, sizeof(jbyte) * length);
((jbyte*)src->get
Pointer
()) + srcPos, sizeof(jbyte) * length);
*/
*/
// c: return;
// c: return;
java
.
lang
.
System
.
arraycopy
(
src
,
srcPos
,
dest
,
destPos
,
length
);
java
.
lang
.
System
.
arraycopy
(
src
,
srcPos
,
dest
,
destPos
,
length
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论