• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1769 (tree)
日時2011-11-12 21:22:41
作者kbinani

ログメッセージ

[luavsq] クラス名とメソッド名の~IDを~Idにリファクタ

変更サマリ

  • delete: luavsq/trunk/ID.lua
  • delete: luavsq/trunk/IDType.lua
  • delete: luavsq/trunk/test/IDTypeTest.lua
  • delete: luavsq/trunk/test/IDTest.lua

差分

--- luavsq/trunk/ID.lua (revision 1768)
+++ luavsq/trunk/ID.lua (nonexistent)
@@ -1,242 +0,0 @@
1---[[
2- Id.lua
3- Copyright © 2011 kbinani
4-
5- This file is part of luavsq.
6-
7- luavsq is free software; you can redistribute it and/or
8- modify it under the terms of the BSD License.
9-
10- luavsq is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13-]]
14-
15-if( nil == luavsq )then
16- luavsq = {};
17-end
18-
19-if( nil == luavsq.Id )then
20-
21- ---
22- -- メタテキストに埋め込まれるIDを表すクラス。
23- luavsq.Id = {};
24-
25- function luavsq.Id.new( ... )
26- local this = {};
27- local arguments = { ... };
28- this.value = -1;
29- this.iconHandleIndex = 0;
30- this.lyricHandleIndex = 0;
31- this.vibratoHandleIndex = 0;
32- this.noteHeadHandleIndex = 0;
33- this.type = luavsq.IdType.Note;
34-
35- ---
36- -- [IconHandle]
37- this.iconHandle = nil;
38- this._length = 0;
39- this.note = 0;
40- this.dynamics = 0;
41- this.pmBendDepth = 0;
42- this.pmBendLength = 0;
43- this.pmbPortamentoUse = 0;
44- this.demDecGainRate = 0;
45- this.demAccent = 0;
46-
47- ---
48- -- [LyricHandle]
49- this.lyricHandle = nil;
50-
51- ---
52- -- [VibratoHandle]
53- this.vibratoHandle = nil;
54-
55- this.vibratoDelay = 0;
56-
57- ---
58- -- [NoteHeadHandle]
59- this.noteHeadHandle = nil;
60-
61- this.pMeanOnsetFirstNote = 10;
62- this.vMeanNoteTransition = 12;
63- this.d4mean = 24;
64- this.pMeanEndingNote = 12;
65-
66- ---
67- -- [IconDynamicsHandle]
68- this.iconDynamicsHandle = nil;
69-
70- ---
71- -- @param value (number)
72- -- @return (luavsq.Id)
73- function this:_init_1( value )
74- self.value = value;
75- end
76-
77- --[[
78- -- テキストファイルからのコンストラクタ
79- -- @param sr [TextStream] 読み込み対象
80- -- @param value [int]
81- -- @param last_line [ByRef<string>] 読み込んだ最後の行が返されます
82- -- @return (luavsq.Id)
83- function this:_init_3( sr, value, last_line )
84- local spl;
85- self.value = value;
86- self.type = luavsq.IdType.Unknown;
87- self.iconHandleIndex = -2;
88- self.lyricHandleIndex = -1;
89- self.vibratoHandleIndex = -1;
90- self.noteHeadHandleIndex = -1;
91- self:setLength( 0 );
92- self.note = 0;
93- self.dynamics = 64;
94- self.pmBendDepth = 8;
95- self.pmBendLength = 0;
96- self.pmbPortamentoUse = 0;
97- self.demDecGainRate = 50;
98- self.demAccent = 50;
99- self.vibratoDelay = 0;
100- last_line.value = sr:readLine();
101- while( last_line.value:find( "[" ) ~= 0 )do
102- spl = luavsq.Util.split( last_line.value, '=' );
103- local search = spl[1];
104- if( search == "Type" )then
105- if( spl[2] == "Anote" )then
106- self.type = luavsq.IdType.Anote;
107- elseif( spl[2] == "Singer" )then
108- self.type = luavsq.IdType.Singer;
109- elseif( spl[2] == "Aicon" )then
110- self.type = luavsq.IdType.Aicon;
111- else
112- self.type = luavsq.IdType.Unknown;
113- end
114- elseif( search == "Length" )then
115- self:setLength( tonumber( spl[2], 10 ) );
116- elseif( search == "Note#" )then
117- self.note = tonumber( spl[2], 10 );
118- elseif( search == "Dynamics" )then
119- self.dynamics = tonumber( spl[2], 10 );
120- elseif( search == "PMBendDepth" )then
121- self.pmBendDepth = tonumber( spl[2], 10 );
122- elseif( search == "PMBendLength" )then
123- self.pmBendLength = tonumber( spl[2], 10 );
124- elseif( search == "DEMdecGainRate" )then
125- self.demDecGainRate = tonumber( spl[2], 10 );
126- elseif( search == "DEMaccent" )then
127- self.demAccent = tonumber( spl[2], 10 );
128- elseif( search == "LyricHandle" )then
129- self.lyricHandleIndex = luavsq.Handle.getHandleIndexFromString( spl[2] );
130- elseif( search == "IconHandle" )then
131- self.iconHandleIndex = luavsq.Handle.getHandleIndexFromString( spl[2] );
132- elseif( search == "VibratoHandle" )then
133- self.vibratoHandleIndex = luavsq.Handle.getHandleIndexFromString( spl[2] );
134- elseif( search == "VibratoDelay" )then
135- self.vibratoDelay = tonumber( spl[2], 10 );
136- elseif( search == "PMbPortamentoUse" )then
137- self.pmbPortamentoUse = tonumber( spl[2], 10 );
138- elseif( search == "NoteHeadHandle" )then
139- self.noteHeadHandleIndex = luavsq.Handle.getHandleIndexFromString( spl[2] );
140- end
141- if( not sr:ready() )then
142- break;
143- end
144- last_line.value = sr:readLine();
145- end
146- end]]
147-
148- ---
149- -- @return [int]
150- function this:getLength()
151- return self._length;
152- end
153-
154- ---
155- -- @param value [int]
156- -- @return [void]
157- function this:setLength( value )
158- self._length = value;
159- end
160-
161- ---
162- -- このインスタンスの簡易コピーを取得します。
163- -- @return [object] このインスタンスの簡易コピー
164- function this:clone()
165- local result = luavsq.Id.new( self.value );
166- result.type = self.type;
167- if( self.iconHandle ~= nil )then
168- result.iconHandle = self.iconHandle:clone();
169- end
170- result:setLength( self:getLength() );
171- result.note = self.note;
172- result.dynamics = self.dynamics;
173- result.pmBendDepth = self.pmBendDepth;
174- result.pmBendLength = self.pmBendLength;
175- result.pmbPortamentoUse = self.pmbPortamentoUse;
176- result.demDecGainRate = self.demDecGainRate;
177- result.demAccent = self.demAccent;
178- result.d4mean = self.d4mean;
179- result.pMeanOnsetFirstNote = self.pMeanOnsetFirstNote;
180- result.vMeanNoteTransition = self.vMeanNoteTransition;
181- result.pMeanEndingNote = self.pMeanEndingNote;
182- if( self.lyricHandle ~= nil )then
183- result.lyricHandle = self.lyricHandle:clone();
184- end
185- if( self.vibratoHandle ~= nil )then
186- result.vibratoHandle = self.vibratoHandle:clone();
187- end
188- result.vibratoDelay = self.vibratoDelay;
189- if( self.noteHeadHandle ~= nil )then
190- result.noteHeadHandle = self.noteHeadHandle:clone();
191- end
192- if( self.iconDynamicsHandle ~= nil )then
193- result.iconDynamicsHandle = self.iconDynamicsHandle:clone();
194- end
195- return result;
196- end
197-
198- --[[
199- -- @return [string]
200- function this:toString()
201- local ret = "{Type=" .. self.type;
202- if( self.type == luavsq.IdType.Anote )then
203- ret = ret .. ", Length=" .. self:getLength();
204- ret = ret .. ", Note#=" .. self.note;
205- ret = ret .. ", Dynamics=" .. self.dynamics;
206- ret = ret .. ", PMBendDepth=" .. self.pmBendDepth;
207- ret = ret .. ", PMBendLength=" .. self.pmBendLength;
208- ret = ret .. ", PMbPortamentoUse=" .. self.pmbPortamentoUse;
209- ret = ret .. ", DEMdecGainRate=" .. self.demDecGainRate;
210- ret = ret .. ", DEMaccent=" .. self.demAccent;
211- if( self.lyricHandle ~= nil )then
212- ret = ret .. ", LyricHandle=h#" .. string.format( "%04d", self.lyricHandleIndex );
213- end
214- if( self.vibratoHandle ~= nil )then
215- ret = ret .. ", VibratoHandle=h#" .. string.format( "%04d", self.vibratoHandleIndex );
216- ret = ret .. ", VibratoDelay=" .. self.vibratoDelay;
217- end
218- elseif( self.type == luavsq.IdType.Singer )then
219- ret = ret .. ", IconHandle=h#" .. string.format( "%04d", self.iconHandleIndex );
220- end
221- ret = ret .. "}";
222- return ret;
223- end]]
224-
225- if( #arguments == 1 )then
226- this:_init_1( arguments[1] );
227- elseif( #arguments == 3 )then
228- this:_init_3( arguments[1], arguments[2], arguments[3] );
229- end
230-
231- return this;
232- end
233-
234- function luavsq.Id.getEOS()
235- return luavsq.Id.new();
236- end
237-
238- ---
239- -- ミリ秒で表した、音符の最大長さ
240- luavsq.Id.MAX_NOTE_MILLISEC_LENGTH = 16383;
241-
242-end
--- luavsq/trunk/IDType.lua (revision 1768)
+++ luavsq/trunk/IDType.lua (nonexistent)
@@ -1,40 +0,0 @@
1---[[
2- IdType.lua
3- Copyright © 2011 kbinani
4-
5- This file is part of luavsq.
6-
7- luavsq is free software; you can redistribute it and/or
8- modify it under the terms of the BSD License.
9-
10- luavsq is distributed in the hope that it will be useful,
11- but WITHOUT ANY WARRANTY; without even the implied warranty of
12- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13-]]
14-
15-if( nil == luavsq )then
16- luavsq = {};
17-end
18-
19-if( nil == luavsq.IdType )then
20-
21- luavsq.IdType = {};
22-
23- luavsq.IdType.Singer = 0;
24- luavsq.IdType.Anote = 1;
25- luavsq.IdType.Aicon = 2;
26- luavsq.IdType.Unknown = -1;
27-
28- function luavsq.IdType.toString( value )
29- if( value == luavsq.IdType.Singer )then
30- return "Singer";
31- elseif( value == luavsq.IdType.Anote )then
32- return "Anote";
33- elseif( value == luavsq.IdType.Aicon )then
34- return "Aicon";
35- else
36- return "Unknown";
37- end
38- end
39-
40-end
--- luavsq/trunk/test/IDTypeTest.lua (revision 1768)
+++ luavsq/trunk/test/IDTypeTest.lua (nonexistent)
@@ -1,10 +0,0 @@
1-dofile( "./test_bootstrap.lua" );
2-module( "enhanced", package.seeall, lunit.testcase );
3-
4-function testToString()
5- assert_equal( "Singer", luavsq.IdType.toString( luavsq.IdType.Singer ) );
6- assert_equal( "Anote", luavsq.IdType.toString( luavsq.IdType.Anote ) );
7- assert_equal( "Aicon", luavsq.IdType.toString( luavsq.IdType.Aicon ) );
8- assert_equal( "Unknown", luavsq.IdType.toString( luavsq.IdType.Unknown ) );
9- assert_equal( "Unknown", luavsq.IdType.toString( nil ) );
10-end
--- luavsq/trunk/test/IDTest.lua (revision 1768)
+++ luavsq/trunk/test/IDTest.lua (nonexistent)
@@ -1,103 +0,0 @@
1-dofile( "./test_bootstrap.lua" );
2-module( "enhanced", package.seeall, lunit.testcase );
3-
4-function testConstructWithValue()
5- local id = luavsq.Id.new( 1 );
6- assert_equal( 1, id.value );
7- assert_equal( 0, id.iconHandleIndex );
8- assert_equal( 0, id.lyricHandleIndex );
9- assert_equal( 0, id.vibratoHandleIndex );
10- assert_equal( 0, id.noteHeadHandleIndex );
11- assert_equal( luavsq.IdType.Note, id.type );
12- assert_nil( id.iconHandle );
13- assert_equal( 0, id.note );
14- assert_equal( 0, id.dynamics );
15- assert_equal( 0, id.pmBendDepth );
16- assert_equal( 0, id.pmBendLength );
17- assert_equal( 0, id.pmbPortamentoUse );
18- assert_equal( 0, id.demDecGainRate );
19- assert_equal( 0, id.demAccent );
20- assert_nil( id.lyricHandle );
21- assert_nil( id.vibratoHandle );
22- assert_equal( 0, id.vibratoDelay );
23- assert_nil( id.noteHeadHandle );
24- assert_equal( 10, id.pMeanOnsetFirstNote );
25- assert_equal( 12, id.vMeanNoteTransition );
26- assert_equal( 24, id.d4mean );
27- assert_equal( 12, id.pMeanEndingNote );
28- assert_nil( id.iconDynamicsHandle );
29-end
30-
31-function testConstructFromStream()
32--- fail();
33-end
34-
35-function testGetterAndSetterLength()
36- local id = luavsq.Id.new( 0 );
37- local expected = 997586;
38- assert_not_equal( expected, id:getLength() );
39- id:setLength( expected );
40- assert_equal( expected, id:getLength() );
41-end
42-
43-function testClone()
44- local id = luavsq.Id.new( 0 );
45- id.value = 1;
46- id.type = luavsq.IdType.Note;
47- id.note = 6;
48- id.dynamics = 7;
49- id.pmBendDepth = 8;
50- id.pmBendLength = 9;
51- id.pmbPortamentoUse = 10;
52- id.demDecGainRate = 11;
53- id.demAccent = 12;
54- id.vibratoDelay = 13;
55- id.pMeanOnsetFirstNote = 14;
56- id.vMeanNoteTransition = 15;
57- id.d4mean = 16;
58- id.pMeanEndingNote = 17;
59- assert_nil( id.iconHandle );
60- assert_nil( id.lyricHandle );
61- assert_nil( id.vibratoHandle );
62- assert_nil( id.noteHeadHandle );
63- assert_nil( id.iconDynamicsHandle );
64-
65- local copy = id:clone();
66- assert_equal( 1, copy.value );
67- assert_equal( luavsq.IdType.Note, copy.type );
68- assert_equal( 6, copy.note );
69- assert_equal( 7, copy.dynamics );
70- assert_equal( 8, copy.pmBendDepth );
71- assert_equal( 9, copy.pmBendLength );
72- assert_equal( 10, copy.pmbPortamentoUse );
73- assert_equal( 11, copy.demDecGainRate );
74- assert_equal( 12, copy.demAccent );
75- assert_equal( 13, copy.vibratoDelay );
76- assert_equal( 14, copy.pMeanOnsetFirstNote );
77- assert_equal( 15, copy.vMeanNoteTransition );
78- assert_equal( 16, copy.d4mean );
79- assert_equal( 17, copy.pMeanEndingNote );
80-
81- local iconHandle = luavsq.IconHandle.new();
82- iconHandle.caption = "foo";
83- id.iconHandle = iconHandle;
84- local lyricHandle = luavsq.LyricHandle.new();
85- lyricHandle.index = 102;
86- id.lyricHandle = lyricHandle;
87- local vibratoHandle = luavsq.VibratoHandle.new();
88- vibratoHandle.iconId = "aho";
89- id.vibratoHandle = vibratoHandle;
90- local noteHeadHandle = luavsq.NoteHeadHandle.new();
91- noteHeadHandle.ids = "baka";
92- id.noteHeadHandle = noteHeadHandle;
93- local iconDynamicsHandle = luavsq.IconDynamicsHandle.new();
94- iconDynamicsHandle:setStartDyn( 183635 );
95- id.iconDynamicsHandle = iconDynamicsHandle;
96-
97- copy = id:clone();
98- assert_equal( "foo", copy.iconHandle.caption );
99- assert_equal( 102, copy.lyricHandle.index );
100- assert_equal( "aho", copy.vibratoHandle.iconId );
101- assert_equal( "baka", copy.noteHeadHandle.ids );
102- assert_equal( 183635, copy.iconDynamicsHandle:getStartDyn() );
103-end
旧リポジトリブラウザで表示