efront 4.35.5 → 4.35.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/_index.html +41 -41
- package/apps/blank/index.html +20 -20
- package/apps/noice/index.html +42 -42
- package/apps/pay/paypal.jsp +0 -0
- package/apps/pay/wxpay.jsp +32 -0
- package/apps/pivot/dht/rent.html +14 -0
- package/apps/pivot/dht/rent.js +148 -0
- package/apps/pivot/dht/rent.less +46 -0
- package/apps/pivot/home/desktop.xht +0 -0
- package/apps/pivot/menu.yml +6 -1
- package/apps/pivot/shop/goods/list.xht +183 -0
- package/apps/pivot/shop/home.xht +20 -0
- package/apps/pivot/shop/mind/list.xht +1 -0
- package/apps/pivot/shop/order/create.xht +49 -0
- package/apps/pivot/shop/order/list.xht +1 -0
- package/apps/pivot/shop/paypal.jsp +23 -0
- package/apps/pivot/soft/list.html +0 -0
- package/apps/pivot/soft/list.js +9 -0
- package/apps/pivot/soft/list.less +0 -0
- package/apps/pivot//344/270/273/351/241/265.html +42 -42
- package/coms/7z_temp/Java.js +93 -0
- package/coms/7z_temp/LzmaBench.java +392 -0
- package/coms/7z_temp/read-from-java-code.js +28 -0
- package/coms/7z_temp//350/257/264/346/230/216.md +1 -0
- package/coms/basic/JSAM.js +259 -259
- package/coms/basic/JSAM_test.js +3 -5
- package/coms/basic/check.js +42 -42
- package/coms/basic/color.js +696 -696
- package/coms/basic/crc.js +39 -39
- package/coms/basic/getIndexFromOrderedArray.js +39 -39
- package/coms/basic/isObject.js +3 -3
- package/coms/basic/keys.js +4 -4
- package/coms/basic/lazy.js +78 -78
- package/coms/basic/refilm.js +96 -96
- package/coms/basic/saveToOrderedArray.js +11 -11
- package/coms/basic/strings.js +0 -1
- package/coms/basic_/&pget.js +1 -0
- package/coms/basic_/&pset.js +1 -0
- package/coms/basic_/Proxy.js +6 -0
- package/coms/basic_/Reflect.js +55 -0
- package/coms/compile/autoeval.js +24 -5
- package/coms/compile/autoeval_test.js +5 -1
- package/coms/compile/bracket.js +51 -0
- package/coms/compile/bracket_test.js +9 -0
- package/coms/compile/createvm.js +35 -0
- package/coms/compile/createvm_test.js +7 -0
- package/coms/compile/scanner.js +653 -653
- package/coms/compile/scanner2.js +23 -0
- package/coms/docs/getMimeData_test.js +19 -19
- package/coms/docs/md5.js +173 -173
- package/coms/frame/top.less +190 -190
- package/coms/pivot/DB.js +9 -0
- package/coms/pivot/paypal-var.js +1 -0
- package/coms/pivot//345/225/206/345/223/201.js +1 -0
- package/coms/zimoli/AudioContext_test.html +5 -5
- package/coms/zimoli/AudioContext_test.js +92 -92
- package/coms/zimoli/AudioContext_test.less +114 -114
- package/coms/zimoli/alert_test.js +11 -11
- package/coms/zimoli/dispatch.js +50 -50
- package/coms/zimoli/extendTouchEvent.js +8 -8
- package/coms/zimoli/fullscreen.js +52 -52
- package/coms/zimoli/gallery.less +13 -13
- package/coms/zimoli/gallery_test.html +2 -2
- package/coms/zimoli/gallery_test.js +14 -14
- package/coms/zimoli/gallery_test.less +17 -17
- package/coms/zimoli/getChanged.js +7 -7
- package/coms/zimoli/getChanges.js +13 -13
- package/coms/zimoli/lattice.js +109 -109
- package/coms/zimoli/lattice_test.less +23 -23
- package/coms/zimoli/picture.less +71 -71
- package/coms/zimoli/refilm_test.html +41 -41
- package/coms/zimoli/refilm_test.less +102 -102
- package/coms/zimoli/xml.js +131 -131
- package/data/keystore/cross-cert.pem +21 -21
- package/data/keystore/cross-key.pem +27 -27
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/public//346/226/207/344/273/266/347/263/273/347/273/237//344/270/273/351/241/265.jsp +2 -2
- /package/apps/pivot/{tick → ticket}/list.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<script></script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
& {
|
|
3
|
+
height: 100%;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
[head] {
|
|
8
|
+
span {
|
|
9
|
+
vertical-align: top;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[content] {
|
|
14
|
+
display: inline-block;
|
|
15
|
+
padding: 2px 12px;
|
|
16
|
+
border-radius: 3px;
|
|
17
|
+
background: #ddd;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.button {
|
|
21
|
+
padding: 0 16px;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
<div head>
|
|
25
|
+
您正在购买<span -bind="goodsinfo.name"></span>
|
|
26
|
+
</div>
|
|
27
|
+
<div body>
|
|
28
|
+
<field -src="[f,goodsinfo]" readonly -repeat="f in fields"></field>
|
|
29
|
+
</div>
|
|
30
|
+
<div foot>
|
|
31
|
+
<btn @click="pay()">支付</btn>
|
|
32
|
+
</div>
|
|
33
|
+
<script>
|
|
34
|
+
view(this);
|
|
35
|
+
var goodsinfo = Object.assign({}, state.data, arguments[0]);
|
|
36
|
+
var fields = refilm`
|
|
37
|
+
商品id/id gen
|
|
38
|
+
商品名称/name input
|
|
39
|
+
包含/content text
|
|
40
|
+
商品简述/description text
|
|
41
|
+
商品展示/present text
|
|
42
|
+
`;
|
|
43
|
+
fields[fields.length - 1].break = true;
|
|
44
|
+
var btn = button;
|
|
45
|
+
var pay = async function () {
|
|
46
|
+
await data.postURL('shop/paypal/', goodsinfo);
|
|
47
|
+
zimoli.go('/order/list');
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<script></script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script serverside>
|
|
2
|
+
if (req.method !== 'POST') throw i18n`请求方法错误`;
|
|
3
|
+
var info = await readdata(req);
|
|
4
|
+
info = JSON.parse(info);
|
|
5
|
+
info = [].concat(info);
|
|
6
|
+
var list = [];
|
|
7
|
+
var cost = 0;
|
|
8
|
+
var limit = 8796093022207.999;
|
|
9
|
+
if (info.length > 60) throw new Error(i18n`商品数量过多,无法完成交易!`);
|
|
10
|
+
for (var a of info) {
|
|
11
|
+
var data = await db.get("商品", a.id);
|
|
12
|
+
if (!deepEqual(data, a)) throw new Error(i18n`商品信息已变更,请刷新页面后重新购买!`);
|
|
13
|
+
var p = +a.price;
|
|
14
|
+
if (p > limit) throw new Error(i18n`商品金额过大,交易无法进行`);
|
|
15
|
+
cost += p;
|
|
16
|
+
if (cost > limit) throw new Error(i18n`商品总价值过大,交易无法进行`);
|
|
17
|
+
cost = +cost.toFixed(2);
|
|
18
|
+
list.push(a);
|
|
19
|
+
}
|
|
20
|
+
cost = cost.toFixed(2);
|
|
21
|
+
var order = await db.add('订单', { list, cost });
|
|
22
|
+
return order;
|
|
23
|
+
</script>
|
|
File without changes
|
|
File without changes
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--
|
|
3
|
-
http://efront.cc
|
|
4
|
-
-->
|
|
5
|
-
<html lang="zh-CN">
|
|
6
|
-
|
|
7
|
-
<head>
|
|
8
|
-
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
|
9
|
-
<meta charset="utf-8" />
|
|
10
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
11
|
-
<link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
|
|
12
|
-
<meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
|
|
13
|
-
<title>efront 服务器管理工具</title>
|
|
14
|
-
<script deleteoncompile efrontloader>
|
|
15
|
-
// 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
|
|
16
|
-
</script>
|
|
17
|
-
<style>
|
|
18
|
-
html {
|
|
19
|
-
height: 100%;
|
|
20
|
-
font-family: "SF Pro SC", "SF Pro Text", "SF Pro Icons", "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
*,
|
|
24
|
-
::before,
|
|
25
|
-
::after {
|
|
26
|
-
box-sizing: border-box;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
body {
|
|
30
|
-
border: none;
|
|
31
|
-
margin: 0;
|
|
32
|
-
padding: 0;
|
|
33
|
-
height: 100%;
|
|
34
|
-
overflow: hidden;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
37
|
-
</head>
|
|
38
|
-
|
|
39
|
-
<body scroll=no>
|
|
40
|
-
雪下的那么深,下的那么认真..
|
|
41
|
-
</body>
|
|
42
|
-
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<!--
|
|
3
|
+
http://efront.cc
|
|
4
|
+
-->
|
|
5
|
+
<html lang="zh-CN">
|
|
6
|
+
|
|
7
|
+
<head>
|
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
|
9
|
+
<meta charset="utf-8" />
|
|
10
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
11
|
+
<link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
|
|
12
|
+
<meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
|
|
13
|
+
<title>efront 服务器管理工具</title>
|
|
14
|
+
<script deleteoncompile efrontloader>
|
|
15
|
+
// 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
|
|
16
|
+
</script>
|
|
17
|
+
<style>
|
|
18
|
+
html {
|
|
19
|
+
height: 100%;
|
|
20
|
+
font-family: "SF Pro SC", "SF Pro Text", "SF Pro Icons", "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
*,
|
|
24
|
+
::before,
|
|
25
|
+
::after {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
body {
|
|
30
|
+
border: none;
|
|
31
|
+
margin: 0;
|
|
32
|
+
padding: 0;
|
|
33
|
+
height: 100%;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
</head>
|
|
38
|
+
|
|
39
|
+
<body scroll=no>
|
|
40
|
+
雪下的那么深,下的那么认真..
|
|
41
|
+
</body>
|
|
42
|
+
|
|
43
43
|
</html>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
var {
|
|
2
|
+
STRAP,
|
|
3
|
+
SPACE,
|
|
4
|
+
COMMENT,
|
|
5
|
+
SCOPED,
|
|
6
|
+
STAMP,
|
|
7
|
+
EXPRESS,
|
|
8
|
+
skipAssignment,
|
|
9
|
+
createScoped
|
|
10
|
+
} = require("../compile/common");
|
|
11
|
+
var Program = require("../compile/Program");
|
|
12
|
+
var straps = `abstract,assert,boolean,break,byte,case,catch,char,class,const
|
|
13
|
+
continue,default,do,double,else,enum,extends,final,finally,float,for,goto,if,implements,import
|
|
14
|
+
instanceof,int,interface,long,native,new,package,private,protected,public,return,strictfp
|
|
15
|
+
short,static,super,switch,synchronized,this,throw,throws,transient,try,void,volatile,while`.trim().split(/[,\s]+/);
|
|
16
|
+
class Java extends Program {
|
|
17
|
+
straps = straps;
|
|
18
|
+
value_reg = /^(false|true|null)$/;
|
|
19
|
+
transive_reg = /^(new|int|double|float|long|byte|char|const|class|instanceof|interface|return|short|void|throws?|implements|extends|import|abstract)$/;
|
|
20
|
+
strapexp_reg = /^(new|void|class)$/;
|
|
21
|
+
forceend_reg = /^(return|break|continue)$/;
|
|
22
|
+
classstrap_reg = /^class$/;
|
|
23
|
+
}
|
|
24
|
+
var transfrom_function = function (c) {
|
|
25
|
+
return []
|
|
26
|
+
}
|
|
27
|
+
var transfrom_class = function (c) {
|
|
28
|
+
while (c && c.type !== SCOPED) c = c.next;
|
|
29
|
+
var statics = Object.create(null);
|
|
30
|
+
var protos = Object.create(null);
|
|
31
|
+
var o = c.first;
|
|
32
|
+
while (o) {
|
|
33
|
+
var defs = Object.create(null);
|
|
34
|
+
while (o.next && o.type === STRAP && o.next.type !== EXPRESS) {
|
|
35
|
+
defs[o.text] = true;
|
|
36
|
+
o = o.next;
|
|
37
|
+
}
|
|
38
|
+
defs.type = o.text;
|
|
39
|
+
defs.name = o.next.text;
|
|
40
|
+
if (defs.static) {
|
|
41
|
+
statics[defs.name] = defs;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
protos[defs.name] = defs;
|
|
45
|
+
}
|
|
46
|
+
o = o.next;
|
|
47
|
+
if (defs.type === "class") {
|
|
48
|
+
var [body] = transfrom_class(o);
|
|
49
|
+
defs.body = body;
|
|
50
|
+
o = o.next;
|
|
51
|
+
}
|
|
52
|
+
else if (o.type === SCOPED && o.entry === "(") {
|
|
53
|
+
var [body] = transfrom_function(o)
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
o = skipAssignment(o);
|
|
57
|
+
}
|
|
58
|
+
if (o.type === STAMP && o.text === ';') o = o.next;
|
|
59
|
+
}
|
|
60
|
+
console.log(protos, statics)
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
var transform = function (code) {
|
|
64
|
+
for (var cx = 0; cx < code.length; cx++) {
|
|
65
|
+
var c = code[cx];
|
|
66
|
+
if (c.type === SPACE || c.type === COMMENT) continue;
|
|
67
|
+
switch (c.text) {
|
|
68
|
+
case "public":
|
|
69
|
+
case "private":
|
|
70
|
+
case "final":
|
|
71
|
+
case "protected":
|
|
72
|
+
code.splice(cx, 1);
|
|
73
|
+
cx--;
|
|
74
|
+
break;
|
|
75
|
+
case "package":
|
|
76
|
+
c.text = "//" + c.text;
|
|
77
|
+
break;
|
|
78
|
+
case "class":
|
|
79
|
+
transfrom_class(c);
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
// console.log(c);
|
|
83
|
+
// throw new Error("转换失败!");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
Java.prototype.js = function (code) {
|
|
89
|
+
transform(code);
|
|
90
|
+
code.relink();
|
|
91
|
+
return code.toString();
|
|
92
|
+
}
|
|
93
|
+
module.exports = Java;
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
//package SevenZip;
|
|
2
|
+
|
|
3
|
+
import java.io.ByteArrayOutputStream;
|
|
4
|
+
import java.io.ByteArrayInputStream;
|
|
5
|
+
import java.io.IOException;
|
|
6
|
+
|
|
7
|
+
class LzmaBench
|
|
8
|
+
{
|
|
9
|
+
static final int kAdditionalSize = (1 << 21);
|
|
10
|
+
static final int kCompressedAdditionalSize = (1 << 10);
|
|
11
|
+
|
|
12
|
+
static class CRandomGenerator
|
|
13
|
+
{
|
|
14
|
+
int A1;
|
|
15
|
+
int A2;
|
|
16
|
+
public CRandomGenerator() { Init(); }
|
|
17
|
+
public void Init() { A1 = 362436069; A2 = 521288629; }
|
|
18
|
+
public int GetRnd()
|
|
19
|
+
{
|
|
20
|
+
return
|
|
21
|
+
((A1 = 36969 * (A1 & 0xffff) + (A1 >>> 16)) << 16) ^
|
|
22
|
+
((A2 = 18000 * (A2 & 0xffff) + (A2 >>> 16)));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static class CBitRandomGenerator
|
|
27
|
+
{
|
|
28
|
+
CRandomGenerator RG = new CRandomGenerator();
|
|
29
|
+
int Value;
|
|
30
|
+
int NumBits;
|
|
31
|
+
public void Init()
|
|
32
|
+
{
|
|
33
|
+
Value = 0;
|
|
34
|
+
NumBits = 0;
|
|
35
|
+
}
|
|
36
|
+
public int GetRnd(int numBits)
|
|
37
|
+
{
|
|
38
|
+
int result;
|
|
39
|
+
if (NumBits > numBits)
|
|
40
|
+
{
|
|
41
|
+
result = Value & ((1 << numBits) - 1);
|
|
42
|
+
Value >>>= numBits;
|
|
43
|
+
NumBits -= numBits;
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
numBits -= NumBits;
|
|
47
|
+
result = (Value << numBits);
|
|
48
|
+
Value = RG.GetRnd();
|
|
49
|
+
result |= Value & (((int) 1 << numBits) - 1);
|
|
50
|
+
Value >>>= numBits;
|
|
51
|
+
NumBits = 32 - numBits;
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
static class CBenchRandomGenerator
|
|
57
|
+
{
|
|
58
|
+
CBitRandomGenerator RG = new CBitRandomGenerator();
|
|
59
|
+
int Pos;
|
|
60
|
+
int Rep0;
|
|
61
|
+
|
|
62
|
+
public int BufferSize;
|
|
63
|
+
public byte [] Buffer = null;
|
|
64
|
+
|
|
65
|
+
public CBenchRandomGenerator() {}
|
|
66
|
+
public void Set(int bufferSize)
|
|
67
|
+
{
|
|
68
|
+
Buffer = new byte [bufferSize];
|
|
69
|
+
Pos = 0;
|
|
70
|
+
BufferSize = bufferSize;
|
|
71
|
+
}
|
|
72
|
+
int GetRndBit() { return RG.GetRnd(1); }
|
|
73
|
+
int GetLogRandBits(int numBits)
|
|
74
|
+
{
|
|
75
|
+
int len = RG.GetRnd(numBits);
|
|
76
|
+
return RG.GetRnd((int) len);
|
|
77
|
+
}
|
|
78
|
+
int GetOffset()
|
|
79
|
+
{
|
|
80
|
+
if (GetRndBit() == 0)
|
|
81
|
+
return GetLogRandBits(4);
|
|
82
|
+
return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
|
|
83
|
+
}
|
|
84
|
+
int GetLen1() { return RG.GetRnd(1 + (int) RG.GetRnd(2)); }
|
|
85
|
+
int GetLen2() { return RG.GetRnd(2 + (int) RG.GetRnd(2)); }
|
|
86
|
+
public void Generate()
|
|
87
|
+
{
|
|
88
|
+
RG.Init();
|
|
89
|
+
Rep0 = 1;
|
|
90
|
+
while (Pos < BufferSize)
|
|
91
|
+
{
|
|
92
|
+
if (GetRndBit() == 0 || Pos < 1)
|
|
93
|
+
Buffer[Pos++] = (byte)(RG.GetRnd(8));
|
|
94
|
+
else
|
|
95
|
+
{
|
|
96
|
+
int len;
|
|
97
|
+
if (RG.GetRnd(3) == 0)
|
|
98
|
+
len = 1 + GetLen1();
|
|
99
|
+
else
|
|
100
|
+
{
|
|
101
|
+
do
|
|
102
|
+
Rep0 = GetOffset();
|
|
103
|
+
while (Rep0 >= Pos);
|
|
104
|
+
Rep0++;
|
|
105
|
+
len = 2 + GetLen2();
|
|
106
|
+
}
|
|
107
|
+
for (int i = 0; i < len && Pos < BufferSize; i++, Pos++)
|
|
108
|
+
Buffer[Pos] = Buffer[Pos - Rep0];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
static class CrcOutStream extends java.io.OutputStream
|
|
115
|
+
{
|
|
116
|
+
public CRC CRC = new CRC();
|
|
117
|
+
|
|
118
|
+
public void Init()
|
|
119
|
+
{
|
|
120
|
+
CRC.Init();
|
|
121
|
+
}
|
|
122
|
+
public int GetDigest()
|
|
123
|
+
{
|
|
124
|
+
return CRC.GetDigest();
|
|
125
|
+
}
|
|
126
|
+
public void write(byte [] b)
|
|
127
|
+
{
|
|
128
|
+
CRC.Update(b);
|
|
129
|
+
}
|
|
130
|
+
public void write(byte [] b, int off, int len)
|
|
131
|
+
{
|
|
132
|
+
CRC.Update(b, off, len);
|
|
133
|
+
}
|
|
134
|
+
public void write(int b)
|
|
135
|
+
{
|
|
136
|
+
CRC.UpdateByte(b);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
static class MyOutputStream extends java.io.OutputStream
|
|
141
|
+
{
|
|
142
|
+
byte [] _buffer;
|
|
143
|
+
int _size;
|
|
144
|
+
int _pos;
|
|
145
|
+
|
|
146
|
+
public MyOutputStream(byte [] buffer)
|
|
147
|
+
{
|
|
148
|
+
_buffer = buffer;
|
|
149
|
+
_size = _buffer.length;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public void reset()
|
|
153
|
+
{
|
|
154
|
+
_pos = 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public void write(int b) throws IOException
|
|
158
|
+
{
|
|
159
|
+
if (_pos >= _size)
|
|
160
|
+
throw new IOException("Error");
|
|
161
|
+
_buffer[_pos++] = (byte) b;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public int size()
|
|
165
|
+
{
|
|
166
|
+
return _pos;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
static class MyInputStream extends java.io.InputStream
|
|
171
|
+
{
|
|
172
|
+
byte [] _buffer;
|
|
173
|
+
int _size;
|
|
174
|
+
int _pos;
|
|
175
|
+
|
|
176
|
+
public MyInputStream(byte [] buffer, int size)
|
|
177
|
+
{
|
|
178
|
+
_buffer = buffer;
|
|
179
|
+
_size = size;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public void reset()
|
|
183
|
+
{
|
|
184
|
+
_pos = 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public int read()
|
|
188
|
+
{
|
|
189
|
+
if (_pos >= _size)
|
|
190
|
+
return -1;
|
|
191
|
+
return _buffer[_pos++] & 0xFF;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
static class CProgressInfo implements ICodeProgress
|
|
196
|
+
{
|
|
197
|
+
public long ApprovedStart;
|
|
198
|
+
public long InSize;
|
|
199
|
+
public long Time;
|
|
200
|
+
public void Init()
|
|
201
|
+
{ InSize = 0; }
|
|
202
|
+
public void SetProgress(long inSize, long outSize)
|
|
203
|
+
{
|
|
204
|
+
if (inSize >= ApprovedStart && InSize == 0)
|
|
205
|
+
{
|
|
206
|
+
Time = System.currentTimeMillis();
|
|
207
|
+
InSize = inSize;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
static final int kSubBits = 8;
|
|
212
|
+
|
|
213
|
+
static int GetLogSize(int size)
|
|
214
|
+
{
|
|
215
|
+
for (int i = kSubBits; i < 32; i++)
|
|
216
|
+
for (int j = 0; j < (1 << kSubBits); j++)
|
|
217
|
+
if (size <= ((1) << i) + (j << (i - kSubBits)))
|
|
218
|
+
return (i << kSubBits) + j;
|
|
219
|
+
return (32 << kSubBits);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static long MyMultDiv64(long value, long elapsedTime)
|
|
223
|
+
{
|
|
224
|
+
long freq = 1000;// ms
|
|
225
|
+
long elTime = elapsedTime;
|
|
226
|
+
while (freq > 1000000)
|
|
227
|
+
{
|
|
228
|
+
freq >>>= 1;
|
|
229
|
+
elTime >>>= 1;
|
|
230
|
+
}
|
|
231
|
+
if (elTime == 0)
|
|
232
|
+
elTime = 1;
|
|
233
|
+
return value * freq / elTime;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static long GetCompressRating(int dictionarySize, long elapsedTime, long size)
|
|
237
|
+
{
|
|
238
|
+
long t = GetLogSize(dictionarySize) - (18 << kSubBits);
|
|
239
|
+
long numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));
|
|
240
|
+
long numCommands = (long)(size) * numCommandsForOne;
|
|
241
|
+
return MyMultDiv64(numCommands, elapsedTime);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
static long GetDecompressRating(long elapsedTime, long outSize, long inSize)
|
|
245
|
+
{
|
|
246
|
+
long numCommands = inSize * 220 + outSize * 20;
|
|
247
|
+
return MyMultDiv64(numCommands, elapsedTime);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
static long GetTotalRating(
|
|
251
|
+
int dictionarySize,
|
|
252
|
+
long elapsedTimeEn, long sizeEn,
|
|
253
|
+
long elapsedTimeDe,
|
|
254
|
+
long inSizeDe, long outSizeDe)
|
|
255
|
+
{
|
|
256
|
+
return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) +
|
|
257
|
+
GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
static void PrintValue(long v)
|
|
261
|
+
{
|
|
262
|
+
String s = "";
|
|
263
|
+
s += v;
|
|
264
|
+
for (int i = 0; i + s.length() < 6; i++)
|
|
265
|
+
System.out.print(" ");
|
|
266
|
+
System.out.print(s);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static void PrintRating(long rating)
|
|
270
|
+
{
|
|
271
|
+
PrintValue(rating / 1000000);
|
|
272
|
+
System.out.print(" MIPS");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
static void PrintResults(
|
|
276
|
+
int dictionarySize,
|
|
277
|
+
long elapsedTime,
|
|
278
|
+
long size,
|
|
279
|
+
boolean decompressMode, long secondSize)
|
|
280
|
+
{
|
|
281
|
+
long speed = MyMultDiv64(size, elapsedTime);
|
|
282
|
+
PrintValue(speed / 1024);
|
|
283
|
+
System.out.print(" KB/s ");
|
|
284
|
+
long rating;
|
|
285
|
+
if (decompressMode)
|
|
286
|
+
rating = GetDecompressRating(elapsedTime, size, secondSize);
|
|
287
|
+
else
|
|
288
|
+
rating = GetCompressRating(dictionarySize, elapsedTime, size);
|
|
289
|
+
PrintRating(rating);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
static public int LzmaBenchmark(int numIterations, int dictionarySize) throws Exception
|
|
293
|
+
{
|
|
294
|
+
if (numIterations <= 0)
|
|
295
|
+
return 0;
|
|
296
|
+
if (dictionarySize < (1 << 18))
|
|
297
|
+
{
|
|
298
|
+
System.out.println("\nError: dictionary size for benchmark must be >= 18 (256 KB)");
|
|
299
|
+
return 1;
|
|
300
|
+
}
|
|
301
|
+
System.out.print("\n Compressing Decompressing\n\n");
|
|
302
|
+
|
|
303
|
+
SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();
|
|
304
|
+
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
|
|
305
|
+
|
|
306
|
+
if (!encoder.SetDictionarySize(dictionarySize))
|
|
307
|
+
throw new Exception("Incorrect dictionary size");
|
|
308
|
+
|
|
309
|
+
int kBufferSize = dictionarySize + kAdditionalSize;
|
|
310
|
+
int kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
|
|
311
|
+
|
|
312
|
+
ByteArrayOutputStream propStream = new ByteArrayOutputStream();
|
|
313
|
+
encoder.WriteCoderProperties(propStream);
|
|
314
|
+
byte [] propArray = propStream.toByteArray();
|
|
315
|
+
decoder.SetDecoderProperties(propArray);
|
|
316
|
+
|
|
317
|
+
CBenchRandomGenerator rg = new CBenchRandomGenerator();
|
|
318
|
+
|
|
319
|
+
rg.Set(kBufferSize);
|
|
320
|
+
rg.Generate();
|
|
321
|
+
CRC crc = new CRC();
|
|
322
|
+
crc.Init();
|
|
323
|
+
crc.Update(rg.Buffer, 0, rg.BufferSize);
|
|
324
|
+
|
|
325
|
+
CProgressInfo progressInfo = new CProgressInfo();
|
|
326
|
+
progressInfo.ApprovedStart = dictionarySize;
|
|
327
|
+
|
|
328
|
+
long totalBenchSize = 0;
|
|
329
|
+
long totalEncodeTime = 0;
|
|
330
|
+
long totalDecodeTime = 0;
|
|
331
|
+
long totalCompressedSize = 0;
|
|
332
|
+
|
|
333
|
+
MyInputStream inStream = new MyInputStream(rg.Buffer, rg.BufferSize);
|
|
334
|
+
|
|
335
|
+
byte [] compressedBuffer = new byte [kCompressedBufferSize];
|
|
336
|
+
MyOutputStream compressedStream = new MyOutputStream(compressedBuffer);
|
|
337
|
+
CrcOutStream crcOutStream = new CrcOutStream();
|
|
338
|
+
MyInputStream inputCompressedStream = null;
|
|
339
|
+
int compressedSize = 0;
|
|
340
|
+
for (int i = 0; i < numIterations; i++)
|
|
341
|
+
{
|
|
342
|
+
progressInfo.Init();
|
|
343
|
+
inStream.reset();
|
|
344
|
+
compressedStream.reset();
|
|
345
|
+
encoder.Code(inStream, compressedStream, -1, -1, progressInfo);
|
|
346
|
+
long encodeTime = System.currentTimeMillis() - progressInfo.Time;
|
|
347
|
+
|
|
348
|
+
if (i == 0)
|
|
349
|
+
{
|
|
350
|
+
compressedSize = compressedStream.size();
|
|
351
|
+
inputCompressedStream = new MyInputStream(compressedBuffer, compressedSize);
|
|
352
|
+
}
|
|
353
|
+
else if (compressedSize != compressedStream.size())
|
|
354
|
+
throw (new Exception("Encoding error"));
|
|
355
|
+
|
|
356
|
+
if (progressInfo.InSize == 0)
|
|
357
|
+
throw (new Exception("Internal ERROR 1282"));
|
|
358
|
+
|
|
359
|
+
long decodeTime = 0;
|
|
360
|
+
for (int j = 0; j < 2; j++)
|
|
361
|
+
{
|
|
362
|
+
inputCompressedStream.reset();
|
|
363
|
+
crcOutStream.Init();
|
|
364
|
+
|
|
365
|
+
long outSize = kBufferSize;
|
|
366
|
+
long startTime = System.currentTimeMillis();
|
|
367
|
+
if (!decoder.Code(inputCompressedStream, crcOutStream, outSize))
|
|
368
|
+
throw (new Exception("Decoding Error"));;
|
|
369
|
+
decodeTime = System.currentTimeMillis() - startTime;
|
|
370
|
+
if (crcOutStream.GetDigest() != crc.GetDigest())
|
|
371
|
+
throw (new Exception("CRC Error"));
|
|
372
|
+
}
|
|
373
|
+
long benchSize = kBufferSize - (long) progressInfo.InSize;
|
|
374
|
+
PrintResults(dictionarySize, encodeTime, benchSize, false, 0);
|
|
375
|
+
System.out.print(" ");
|
|
376
|
+
PrintResults(dictionarySize, decodeTime, kBufferSize, true, compressedSize);
|
|
377
|
+
System.out.println();
|
|
378
|
+
|
|
379
|
+
totalBenchSize += benchSize;
|
|
380
|
+
totalEncodeTime += encodeTime;
|
|
381
|
+
totalDecodeTime += decodeTime;
|
|
382
|
+
totalCompressedSize += compressedSize;
|
|
383
|
+
}
|
|
384
|
+
System.out.println("---------------------------------------------------");
|
|
385
|
+
PrintResults(dictionarySize, totalEncodeTime, totalBenchSize, false, 0);
|
|
386
|
+
System.out.print(" ");
|
|
387
|
+
PrintResults(dictionarySize, totalDecodeTime,
|
|
388
|
+
kBufferSize * (long) numIterations, true, totalCompressedSize);
|
|
389
|
+
System.out.println(" Average");
|
|
390
|
+
return 0;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var fs = require("fs/promises");
|
|
2
|
+
var fs_ = require("fs");
|
|
3
|
+
var path = require("path");
|
|
4
|
+
var path4java7z = "/work/7-zip/Java/SevenZip";
|
|
5
|
+
var scanner2 = require("../compile/scanner2");
|
|
6
|
+
var path4js7z = __dirname;
|
|
7
|
+
var task = new Task;
|
|
8
|
+
var Java = require('./Java');
|
|
9
|
+
var transform = function (data) {
|
|
10
|
+
var code = scanner2(data, Java);
|
|
11
|
+
return code.toJsString();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
task.open("translate-code", async function ([readpath, writepath]) {
|
|
15
|
+
var stats = await fs.stat(readpath);
|
|
16
|
+
if (stats.isDirectory()) {
|
|
17
|
+
if (!fs_.existsSync(writepath)) await fs.mkdir(writepath);
|
|
18
|
+
var files = await fs.readdir(readpath);
|
|
19
|
+
for (var f of files) task.rest.push([path.join(readpath, f), path.join(writepath, f)]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
var data = await fs.readFile(readpath);
|
|
23
|
+
data = transform(data.toString());
|
|
24
|
+
await fs.writeFile(writepath, data);
|
|
25
|
+
process.exit();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
task.send([path4java7z, path4js7z]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
参考7z源码的java版本重新实现
|