ソースコードの管理場所
Revision | bf7bec46486f83bb9997f27d51a3c19cbe047b15 (tree) |
---|---|
Zeit | 2018-02-18 10:04:51 |
Autor | Hironori Kitagawa <h_kitagawa2001@yaho...> |
Commiter | Hironori Kitagawa |
stopped to use module(), which is removed in Lua 5.2.
@@ -3,12 +3,11 @@ | ||
3 | 3 | -- |
4 | 4 | luatexbase.provides_module({ |
5 | 5 | name = 'luatexja.stack', |
6 | - date = '2017/05/05', | |
6 | + date = '2018/02/18', | |
7 | 7 | description = 'LuaTeX-ja stack system', |
8 | 8 | }) |
9 | -module('luatexja.stack', package.seeall) | |
10 | -local err, warn, info, log = luatexbase.errwarinf(_NAME) | |
11 | - | |
9 | +luatexja.stack = {} | |
10 | +local ltjs=luatexja.stack | |
12 | 11 | luatexja.load_module('base'); local ltjb = luatexja.base |
13 | 12 | |
14 | 13 | -------------------------------------------------------------------------------- |
@@ -21,14 +20,14 @@ local STCK = luatexja.userid_table.STCK | ||
21 | 20 | local fastcopy = table.fastcopy |
22 | 21 | local setcount = tex.setcount |
23 | 22 | local scan_int, scan_keyword = token.scan_int, token.scan_keyword |
24 | -hmode = 0 -- dummy | |
23 | +ltjs.hmode = 0 -- dummy | |
25 | 24 | |
26 | -charprop_stack_table={}; | |
27 | -local charprop_stack_table = charprop_stack_table | |
25 | +local charprop_stack_table={}; | |
26 | +ltjs.charprop_stack_table = charprop_stack_table | |
28 | 27 | charprop_stack_table[0]={} |
29 | 28 | |
30 | 29 | |
31 | -function get_stack_level() | |
30 | +local function get_stack_level() | |
32 | 31 | local i = tex.getcount('ltj@@stack') |
33 | 32 | local j = tex.currentgrouplevel |
34 | 33 | if j > tex.getcount('ltj@@group@level') then |
@@ -43,15 +42,16 @@ function get_stack_level() | ||
43 | 42 | charprop_stack_table[i] = fastcopy(charprop_stack_table[i-1]) |
44 | 43 | setcount('ltj@@stack', i) |
45 | 44 | if gd~=0 then tex.globaldefs = gd end |
46 | - if tex.nest[tex.nest.ptr].mode == -hmode then -- rest. hmode のみ | |
45 | + if tex.nest[tex.nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ | |
47 | 46 | local g = node_new(id_whatsit, sid_user) |
48 | 47 | g.user_id=STCK; g.type=100; g.value=j; node.write(g) |
49 | 48 | end |
50 | 49 | end |
51 | 50 | return i |
52 | 51 | end |
52 | +ltjs.get_stack_level = get_stack_level | |
53 | 53 | |
54 | -function set_stack_table(m, p) | |
54 | +local function set_stack_table(m, p) | |
55 | 55 | local i = get_stack_level() |
56 | 56 | charprop_stack_table[i][m] = p |
57 | 57 | if luatexja.isglobal=='global' then |
@@ -60,10 +60,10 @@ function set_stack_table(m, p) | ||
60 | 60 | end |
61 | 61 | end |
62 | 62 | end |
63 | -local set_stack_table = set_stack_table | |
63 | +ltjs.set_stack_table = set_stack_table | |
64 | 64 | |
65 | 65 | -- EXT |
66 | -function set_stack_perchar(m,lb,ub, getter) | |
66 | +function ltjs.set_stack_perchar(m,lb,ub, getter) | |
67 | 67 | local c = scan_int() |
68 | 68 | scan_keyword(',') |
69 | 69 | local p = tonumber((getter or scan_int)()) |
@@ -79,7 +79,7 @@ function set_stack_perchar(m,lb,ub, getter) | ||
79 | 79 | end |
80 | 80 | |
81 | 81 | -- EXT |
82 | -function set_stack_font(m,c,p) | |
82 | +function ltjs.set_stack_font(m,c,p) | |
83 | 83 | if type(c)~='number' or c<0 or c>255 then |
84 | 84 | ltjb.package_error('luatexja', |
85 | 85 | "invalid family number (".. tostring(c) .. ")", |
@@ -91,7 +91,7 @@ function set_stack_font(m,c,p) | ||
91 | 91 | end |
92 | 92 | |
93 | 93 | -- EXT: sp: glue_spec |
94 | -function set_stack_skip(m,sp) | |
94 | +function ltjs.set_stack_skip(m,sp) | |
95 | 95 | local i = get_stack_level() |
96 | 96 | if not sp then return end |
97 | 97 | if not charprop_stack_table[i][m] then |
@@ -116,24 +116,25 @@ end | ||
116 | 116 | |
117 | 117 | -- These three functions are used in ltj-jfmglue.lua. |
118 | 118 | -- list_dir and orig_char_table are used in other lua files. |
119 | -orig_char_table = {} | |
120 | -list_dir = nil -- dummy | |
121 | -table_current_stack = nil -- dummy | |
122 | -function report_stack_level(bsl) | |
123 | - table_current_stack = charprop_stack_table[bsl] | |
119 | +local orig_char_table = {} | |
120 | +ltjs.orig_char_table = orig_char_table | |
121 | +ltjs.list_dir = nil -- dummy | |
122 | +ltjs.table_current_stack = nil -- dummy | |
123 | +function ltjs.report_stack_level(bsl) | |
124 | + ltjs.table_current_stack = charprop_stack_table[bsl] | |
124 | 125 | return bsl |
125 | 126 | end |
126 | -function fast_get_stack_skip(m) | |
127 | - return table_current_stack[m] | |
127 | +function ltjs.fast_get_stack_skip(m) | |
128 | + return ltjs.table_current_stack[m] | |
128 | 129 | or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 } |
129 | 130 | end |
130 | 131 | |
131 | 132 | -- For other situations, use the following instead: |
132 | -function get_stack_skip(m, idx) | |
133 | +function ltjs.get_stack_skip(m, idx) | |
133 | 134 | return charprop_stack_table[idx][m] |
134 | 135 | or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 } |
135 | 136 | end |
136 | -function get_stack_table(mc, d, idx) | |
137 | +function ltjs.get_stack_table(mc, d, idx) | |
137 | 138 | local i = charprop_stack_table[idx][mc] |
138 | 139 | return i or d |
139 | 140 | end |
@@ -1,76 +0,0 @@ | ||
1 | --- | |
2 | --- luatexja/tangle.lua | |
3 | --- | |
4 | -luatexbase.provides_module({ | |
5 | - name = 'luatexja.tangle', | |
6 | - date = '2011/05/14', | |
7 | - description = '', | |
8 | -}) | |
9 | -module('luatexja.tangle', package.seeall) | |
10 | -local err, warn, info, log = luatexbase.errwarinf(_NAME) | |
11 | - | |
12 | ---! ixbase0 からの移植 | |
13 | - | |
14 | -local _DONE, _TEX, _STOP = 0, 1, 2 | |
15 | -local _current_co, _interrupted | |
16 | -local _resume, _check | |
17 | - | |
18 | -local resume_code = | |
19 | - "\\directlua{".._NAME..".resume()}\\relax" | |
20 | - | |
21 | -function execute(func, ...) | |
22 | - if _current_co then | |
23 | - err("tangle is going now") | |
24 | - end | |
25 | - local args = { ... } | |
26 | - local co = coroutine.create(function() | |
27 | - return _DONE, { func(unpack(args)) } | |
28 | - end) | |
29 | - _current_co = co | |
30 | - _interrupted = false | |
31 | - return _check(coroutine.resume(co, ...)) | |
32 | -end | |
33 | - | |
34 | -function resume() | |
35 | - return _resume(false) | |
36 | -end | |
37 | - | |
38 | -function interrupt() | |
39 | - return _resume(true) | |
40 | -end | |
41 | - | |
42 | -function run_tex() | |
43 | - coroutine.yield(_TEX, {}) | |
44 | -end | |
45 | - | |
46 | -function suspend(...) | |
47 | - local intr = coroutine.yield(_STOP, { ... }) | |
48 | - if intr then | |
49 | - _interrupted = true | |
50 | - error("*INTR*") -- this error is caught later | |
51 | - end | |
52 | -end | |
53 | - | |
54 | -function _resume(intr) | |
55 | - if not _current_co then | |
56 | - err("tangle is not going") | |
57 | - end | |
58 | - local co = _current_co | |
59 | - return _check(coroutine.resume(co, intr)) | |
60 | -end | |
61 | - | |
62 | -function _check(costat, tstat, extra) | |
63 | - if not costat then -- error in coroutine | |
64 | - _current_co = nil | |
65 | - if _interrupted then return end | |
66 | - err(tstat) | |
67 | - elseif tstat == _DONE then | |
68 | - _current_co = nil | |
69 | - elseif tstat == _TEX then | |
70 | - tex.print(resume_code) | |
71 | - end | |
72 | - return unpack(extra) | |
73 | -end | |
74 | - | |
75 | --- EOF | |
76 | - |
@@ -3,14 +3,7 @@ require('lualibs') | ||
3 | 3 | tableunpack = table.unpack |
4 | 4 | |
5 | 5 | ------------------------------------------------------------------------ |
6 | --- naming: | |
7 | --- ext_... : called from \directlua{} | |
8 | --- int_... : called from other Lua codes, but not from \directlua{} | |
9 | --- (other) : only called from this file | |
10 | -function luatexja.load_module(name) | |
11 | - require('ltj-' .. name.. '.lua') | |
12 | -end | |
13 | -function luatexja.load_lua(fn) | |
6 | +local function load_lua(fn) | |
14 | 7 | local found = kpse.find_file(fn, 'tex') |
15 | 8 | if not found then |
16 | 9 | tex.error("LuaTeX-ja error: File `" .. fn .. "' not found") |
@@ -19,6 +12,10 @@ function luatexja.load_lua(fn) | ||
19 | 12 | dofile(found) |
20 | 13 | end |
21 | 14 | end |
15 | +luatexja.load_lua = load_lua | |
16 | +function luatexja.load_module(name) | |
17 | + require('ltj-' .. name.. '.lua') | |
18 | +end | |
22 | 19 | |
23 | 20 | do |
24 | 21 | local setfield = node.direct.setfield |
@@ -111,7 +108,7 @@ load_module('pretreat'); local ltjp = luatexja.pretreat | ||
111 | 108 | load_module('setwidth'); local ltjw = luatexja.setwidth |
112 | 109 | load_module('jfmglue'); local ltjj = luatexja.jfmglue -- +1 glue +1 gs +1 attr_list |
113 | 110 | load_module('math'); local ltjm = luatexja.math |
114 | -load_module('tangle'); local ltjb = luatexja.base | |
111 | +load_module('base'); local ltjb = luatexja.base | |
115 | 112 | |
116 | 113 | |
117 | 114 | local attr_jchar_class = luatexbase.attributes['ltj@charclass'] |