wirispluginengine 3.62.0.1322 → 7.14.0.1422
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.
- checksums.yaml +4 -4
- data/Rakefile +34 -34
- data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
- data/app/controllers/wirispluginengine/application_controller.rb +84 -75
- data/app/helpers/wirispluginengine/application_helper.rb +4 -4
- data/config/routes.rb +4 -4
- data/lib/com/wiris/common/WInteger.rb +52 -51
- data/lib/com/wiris/plugin/api/Cas.rb +5 -5
- data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
- data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
- data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
- data/lib/com/wiris/plugin/api/Editor.rb +5 -5
- data/lib/com/wiris/plugin/api/Filter.rb +5 -5
- data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
- data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
- data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
- data/lib/com/wiris/plugin/api/Render.rb +5 -5
- data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
- data/lib/com/wiris/plugin/api/Test.rb +5 -5
- data/lib/com/wiris/plugin/api/TextService.rb +5 -5
- data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
- data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
- data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
- data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
- data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
- data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
- data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
- data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
- data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
- data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
- data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
- data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
- data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
- data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
- data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
- data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
- data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
- data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
- data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
- data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
- data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
- data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
- data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
- data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
- data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
- data/lib/com/wiris/util/json/JSon.rb +505 -493
- data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
- data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
- data/lib/com/wiris/util/json/StringParser.rb +57 -56
- data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Cache.rb +8 -0
- data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
- data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
- data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
- data/lib/com/wiris/util/sys/IniFile.rb +132 -131
- data/lib/com/wiris/util/sys/Lock.rb +8 -0
- data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
- data/lib/com/wiris/util/sys/Store.rb +126 -101
- data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
- data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
- data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
- data/lib/com/wiris/util/type/Arrays.rb +275 -0
- data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
- data/lib/com/wiris/util/type/Comparator.rb +8 -0
- data/lib/com/wiris/util/type/DataUtils.rb +24 -0
- data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
- data/lib/com/wiris/util/type/HashCache.rb +43 -0
- data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
- data/lib/com/wiris/util/type/Queue.rb +31 -0
- data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
- data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
- data/lib/com/wiris/util/type/SortedHash.rb +45 -0
- data/lib/com/wiris/util/type/Stack.rb +31 -0
- data/lib/com/wiris/util/type/StringUtils.rb +56 -0
- data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
- data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
- data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
- data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
- data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
- data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
- data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
- data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
- data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
- data/lib/com/wiris/util/xml/WEntities.rb +11 -9
- data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
- data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
- data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
- data/lib/loader.rb +15 -12
- data/lib/src-generic/Array.rb +22 -22
- data/lib/src-generic/ArrayInt.rb +31 -31
- data/lib/src-generic/Base64.rb +14 -14
- data/lib/src-generic/BaseCode.rb +93 -93
- data/lib/src-generic/Boolean.rb +27 -0
- data/lib/src-generic/Bytes.rb +50 -50
- data/lib/src-generic/BytesInput.rb +37 -37
- data/lib/src-generic/EReg.rb +55 -55
- data/lib/src-generic/File.rb +35 -35
- data/lib/src-generic/FileLock.rb +26 -26
- data/lib/src-generic/FileSystem.rb +37 -37
- data/lib/src-generic/Hash.rb +42 -42
- data/lib/src-generic/Http.rb +111 -107
- data/lib/src-generic/HttpRequest.rb +25 -25
- data/lib/src-generic/HttpResponse.rb +70 -70
- data/lib/src-generic/Iterator.rb +20 -19
- data/lib/src-generic/Math.rb +14 -14
- data/lib/src-generic/Md5.rb +8 -8
- data/lib/src-generic/Md5Tools.rb +11 -11
- data/lib/src-generic/PropertiesTools.rb +32 -32
- data/lib/src-generic/Reflect.rb +16 -16
- data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
- data/lib/src-generic/Serializer.rb +84 -84
- data/lib/src-generic/Std.rb +74 -74
- data/lib/src-generic/Storage.rb +152 -152
- data/lib/src-generic/StringBuf.rb +40 -40
- data/lib/src-generic/StringTools.rb +44 -46
- data/lib/src-generic/Timer.rb +6 -6
- data/lib/src-generic/Type.rb +18 -18
- data/lib/src-generic/TypeTools.rb +31 -31
- data/lib/src-generic/Unserializer.rb +72 -72
- data/lib/src-generic/Utf8.rb +26 -26
- data/lib/src-generic/Xml.rb +199 -198
- data/lib/src-generic/extended/Integer.rb +5 -5
- data/lib/src-generic/extended/Math.rb +6 -6
- data/lib/src-generic/extended/Properties.rb +11 -11
- data/lib/src-generic/extended/String.rb +38 -38
- data/lib/src-generic/settings/PlatformSettings.rb +18 -18
- data/lib/src-generic/system/HttpProxy.rb +23 -0
- data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
- data/lib/wirispluginengine.rb +5 -5
- data/lib/wirispluginengine/engine.rb +5 -5
- data/lib/wirispluginengine/integration/cleancache.rb +8 -8
- data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
- data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
- data/lib/wirispluginengine/integration/createimage.rb +7 -7
- data/lib/wirispluginengine/integration/getmathml.rb +18 -18
- data/lib/wirispluginengine/integration/resource.rb +8 -8
- data/lib/wirispluginengine/integration/service.rb +5 -5
- data/lib/wirispluginengine/integration/showimage.rb +28 -21
- data/lib/wirispluginengine/integration/test.rb +5 -5
- data/lib/wirispluginengine/integration/testfilter.rb +10 -0
- data/lib/wirispluginengine/version.rb +2 -2
- data/resources/VERSION +1 -1
- data/resources/WEB-INF/web.xml +25 -0
- data/resources/WIRISplugins.js +3809 -0
- data/resources/default-configuration.ini +47 -45
- data/resources/tech.txt +1 -1
- data/resources/wirisplugin.css +43 -42
- metadata +40 -4
- data/configuration.ini.dist +0 -104
data/lib/loader.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
module Wiris
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
module Wiris
|
2
|
+
p "Loadin MathType for Ruby..."
|
3
|
+
if !defined?(Quizzesproxy)
|
4
|
+
Dir[File.dirname(__FILE__) + '/src-generic/**/*.rb'].each {|file| require file}
|
5
|
+
Dir[File.dirname(__FILE__) + '/src-generic/**/*/*.rb'].each {|file| require file}
|
6
|
+
else
|
7
|
+
require "require_all"
|
8
|
+
require 'src-generic/RubyConfigurationUpdater.rb'
|
9
|
+
require_all File.dirname(__FILE__) + '/com/wiris/util/sys'
|
10
|
+
require_all File.dirname(__FILE__) + '/com/wiris/common'
|
11
|
+
end
|
12
|
+
|
13
|
+
p "MathType for Ruby loaded."
|
14
|
+
|
15
|
+
end
|
data/lib/src-generic/Array.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
module Wiris
|
2
|
-
class Array < Array
|
3
|
-
def iterator
|
4
|
-
return Iterator.new(self)
|
5
|
-
end
|
6
|
-
|
7
|
-
def get(i)
|
8
|
-
return self[i]
|
9
|
-
end
|
10
|
-
|
11
|
-
def _(i, e=nil)
|
12
|
-
if e.nil?
|
13
|
-
return get(i)
|
14
|
-
else
|
15
|
-
self[i] = e
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def contains_(key)
|
20
|
-
return self.include? key
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module Wiris
|
2
|
+
class Array < Array
|
3
|
+
def iterator
|
4
|
+
return Iterator.new(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(i)
|
8
|
+
return self[i]
|
9
|
+
end
|
10
|
+
|
11
|
+
def _(i, e=nil)
|
12
|
+
if e.nil?
|
13
|
+
return get(i)
|
14
|
+
else
|
15
|
+
self[i] = e
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def contains_(key)
|
20
|
+
return self.include? key
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
data/lib/src-generic/ArrayInt.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
module Wiris
|
2
|
-
class ArrayInt < ::Array
|
3
|
-
def sort()
|
4
|
-
for i in 1..length()
|
5
|
-
j = i
|
6
|
-
b = get(i)
|
7
|
-
while ((j>0) && get(j-1) > b)
|
8
|
-
insert(j,get(j-1))
|
9
|
-
j -=1
|
10
|
-
end
|
11
|
-
insert(j, b)
|
12
|
-
i += 1
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def splice(i, len)
|
17
|
-
na = slice!(i, len)
|
18
|
-
end
|
19
|
-
|
20
|
-
def get(i)
|
21
|
-
return self[i]
|
22
|
-
end
|
23
|
-
|
24
|
-
def _(i, e=nil)
|
25
|
-
if e.nil?
|
26
|
-
return get(i)
|
27
|
-
else
|
28
|
-
self[i] = e
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
module Wiris
|
2
|
+
class ArrayInt < ::Array
|
3
|
+
def sort()
|
4
|
+
for i in 1..length()
|
5
|
+
j = i
|
6
|
+
b = get(i)
|
7
|
+
while ((j>0) && get(j-1) > b)
|
8
|
+
insert(j,get(j-1))
|
9
|
+
j -=1
|
10
|
+
end
|
11
|
+
insert(j, b)
|
12
|
+
i += 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def splice(i, len)
|
17
|
+
na = slice!(i, len)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(i)
|
21
|
+
return self[i]
|
22
|
+
end
|
23
|
+
|
24
|
+
def _(i, e=nil)
|
25
|
+
if e.nil?
|
26
|
+
return get(i)
|
27
|
+
else
|
28
|
+
self[i] = e
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
32
|
end
|
data/lib/src-generic/Base64.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module Wiris
|
4
|
-
class Base64
|
5
|
-
def initialize()
|
6
|
-
end
|
7
|
-
def encodeBytes(b)
|
8
|
-
#Using '::' to call Base64 module out of the Wiris module scope.
|
9
|
-
return Bytes.ofString(::Base64::strict_encode64(b.toString()))
|
10
|
-
end
|
11
|
-
|
12
|
-
def decodeBytes(b)
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Wiris
|
4
|
+
class Base64
|
5
|
+
def initialize()
|
6
|
+
end
|
7
|
+
def encodeBytes(b)
|
8
|
+
#Using '::' to call Base64 module out of the Wiris module scope.
|
9
|
+
return Bytes.ofString(::Base64::strict_encode64(b.toString()))
|
10
|
+
end
|
11
|
+
|
12
|
+
def decodeBytes(b)
|
13
|
+
end
|
14
|
+
end
|
15
15
|
end
|
data/lib/src-generic/BaseCode.rb
CHANGED
@@ -1,94 +1,94 @@
|
|
1
|
-
module Wiris
|
2
|
-
class BaseCode
|
3
|
-
@bytes
|
4
|
-
@nbits
|
5
|
-
@tbl = nil
|
6
|
-
@charSet
|
7
|
-
@base
|
8
|
-
|
9
|
-
def initialize(base)
|
10
|
-
@base = base
|
11
|
-
@charSet = base.toString()
|
12
|
-
n = base.length()
|
13
|
-
@nbits = 0
|
14
|
-
while(n>1)
|
15
|
-
@nbits+=1
|
16
|
-
n = n / 2
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def initTable()
|
21
|
-
@tbl = []
|
22
|
-
|
23
|
-
|
24
|
-
for i in 0..255
|
25
|
-
@tbl[i] = -1
|
26
|
-
i+=1
|
27
|
-
end
|
28
|
-
|
29
|
-
i = 0
|
30
|
-
for i in 0..@base.length()
|
31
|
-
if !@base.get(i).nil?
|
32
|
-
@tbl[@base.get(i)] = i
|
33
|
-
end
|
34
|
-
i+=1
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def decodeBytes(b)
|
40
|
-
if @tbl.nil?
|
41
|
-
initTable()
|
42
|
-
end
|
43
|
-
|
44
|
-
bitsize = b.length() * @nbits
|
45
|
-
size = bitsize/8
|
46
|
-
o = []
|
47
|
-
buf = 0
|
48
|
-
curbits = 0
|
49
|
-
pin = 0
|
50
|
-
pout = 0
|
51
|
-
while (pout < size)
|
52
|
-
while (curbits < 8)
|
53
|
-
curbits += @nbits
|
54
|
-
buf <<= @nbits
|
55
|
-
i = @tbl[b.get(pin)]
|
56
|
-
pin+=1
|
57
|
-
buf |= i
|
58
|
-
end
|
59
|
-
curbits -= 8
|
60
|
-
o[pout] = ((buf >> curbits) & 0xFF)
|
61
|
-
pout += 1;
|
62
|
-
end
|
63
|
-
|
64
|
-
return Bytes.ofData(o)
|
65
|
-
end
|
66
|
-
|
67
|
-
def encodeBytes(b)
|
68
|
-
bas = @base
|
69
|
-
size = (b.length()*8)/@nbits
|
70
|
-
o = []
|
71
|
-
buf = 0
|
72
|
-
curbits = 0
|
73
|
-
mask = (1 << @nbits) -1
|
74
|
-
pin = 0
|
75
|
-
pout = 0
|
76
|
-
while (pout < size)
|
77
|
-
while (curbits < @nbits)
|
78
|
-
curbits += 8
|
79
|
-
buf <<= 8
|
80
|
-
buf |= b.get(pin)
|
81
|
-
pin +=1
|
82
|
-
end
|
83
|
-
curbits -= @nbits
|
84
|
-
o[pout] = bas.get((buf >> curbits) & mask)
|
85
|
-
pout+=1
|
86
|
-
end
|
87
|
-
if (curbits > 0)
|
88
|
-
o[pout] = bas.get((buf << (@nbits - curbits)) & mask)
|
89
|
-
pout +=1
|
90
|
-
end
|
91
|
-
return Bytes.ofData(o)
|
92
|
-
end
|
93
|
-
end
|
1
|
+
module Wiris
|
2
|
+
class BaseCode
|
3
|
+
@bytes
|
4
|
+
@nbits
|
5
|
+
@tbl = nil
|
6
|
+
@charSet
|
7
|
+
@base
|
8
|
+
|
9
|
+
def initialize(base)
|
10
|
+
@base = base
|
11
|
+
@charSet = base.toString()
|
12
|
+
n = base.length()
|
13
|
+
@nbits = 0
|
14
|
+
while(n>1)
|
15
|
+
@nbits+=1
|
16
|
+
n = n / 2
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initTable()
|
21
|
+
@tbl = []
|
22
|
+
|
23
|
+
|
24
|
+
for i in 0..255
|
25
|
+
@tbl[i] = -1
|
26
|
+
i+=1
|
27
|
+
end
|
28
|
+
|
29
|
+
i = 0
|
30
|
+
for i in 0..@base.length()
|
31
|
+
if !@base.get(i).nil?
|
32
|
+
@tbl[@base.get(i)] = i
|
33
|
+
end
|
34
|
+
i+=1
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def decodeBytes(b)
|
40
|
+
if @tbl.nil?
|
41
|
+
initTable()
|
42
|
+
end
|
43
|
+
|
44
|
+
bitsize = b.length() * @nbits
|
45
|
+
size = bitsize/8
|
46
|
+
o = []
|
47
|
+
buf = 0
|
48
|
+
curbits = 0
|
49
|
+
pin = 0
|
50
|
+
pout = 0
|
51
|
+
while (pout < size)
|
52
|
+
while (curbits < 8)
|
53
|
+
curbits += @nbits
|
54
|
+
buf <<= @nbits
|
55
|
+
i = @tbl[b.get(pin)]
|
56
|
+
pin+=1
|
57
|
+
buf |= i
|
58
|
+
end
|
59
|
+
curbits -= 8
|
60
|
+
o[pout] = ((buf >> curbits) & 0xFF)
|
61
|
+
pout += 1;
|
62
|
+
end
|
63
|
+
|
64
|
+
return Bytes.ofData(o)
|
65
|
+
end
|
66
|
+
|
67
|
+
def encodeBytes(b)
|
68
|
+
bas = @base
|
69
|
+
size = (b.length()*8)/@nbits
|
70
|
+
o = []
|
71
|
+
buf = 0
|
72
|
+
curbits = 0
|
73
|
+
mask = (1 << @nbits) -1
|
74
|
+
pin = 0
|
75
|
+
pout = 0
|
76
|
+
while (pout < size)
|
77
|
+
while (curbits < @nbits)
|
78
|
+
curbits += 8
|
79
|
+
buf <<= 8
|
80
|
+
buf |= b.get(pin)
|
81
|
+
pin +=1
|
82
|
+
end
|
83
|
+
curbits -= @nbits
|
84
|
+
o[pout] = bas.get((buf >> curbits) & mask)
|
85
|
+
pout+=1
|
86
|
+
end
|
87
|
+
if (curbits > 0)
|
88
|
+
o[pout] = bas.get((buf << (@nbits - curbits)) & mask)
|
89
|
+
pout +=1
|
90
|
+
end
|
91
|
+
return Bytes.ofData(o)
|
92
|
+
end
|
93
|
+
end
|
94
94
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Wiris
|
2
|
+
class Boolean
|
3
|
+
|
4
|
+
@boolean
|
5
|
+
def boolean=(boolean)
|
6
|
+
@boolean=boolean
|
7
|
+
end
|
8
|
+
def boolean
|
9
|
+
@boolean
|
10
|
+
end
|
11
|
+
def initialize(boolean)
|
12
|
+
@boolean = boolean
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.valueOf(boolean)
|
16
|
+
return Boolean.new(boolean)
|
17
|
+
end
|
18
|
+
|
19
|
+
def booleanValue()
|
20
|
+
return boolean
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
data/lib/src-generic/Bytes.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
# This class encapsulates the data structure of an array of bytes. Depending
|
2
|
-
# on the platform the actual byte array ca be a String, an array of integers,
|
3
|
-
# or the best choice everywhere.
|
4
|
-
# It is encouraged to use this structure specially for input/output
|
5
|
-
# operations where large byte arrays have to be handled.
|
6
|
-
|
7
|
-
module Wiris
|
8
|
-
class Bytes
|
9
|
-
def bytes=(bytes)
|
10
|
-
@bytes=bytes
|
11
|
-
end
|
12
|
-
def bytes
|
13
|
-
@bytes
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(bytes)
|
17
|
-
@bytes = bytes
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
def self.ofString(s)
|
22
|
-
return Bytes.new(s.force_encoding("ISO-8859-1").bytes.to_a)
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.ofData(data)
|
26
|
-
return Bytes.new(data)
|
27
|
-
end
|
28
|
-
|
29
|
-
def getData()
|
30
|
-
return @bytes
|
31
|
-
end
|
32
|
-
|
33
|
-
def get(index)
|
34
|
-
return @bytes[index]
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.alloc(int)
|
38
|
-
return []
|
39
|
-
end
|
40
|
-
|
41
|
-
def length()
|
42
|
-
return @bytes.length
|
43
|
-
end
|
44
|
-
|
45
|
-
def toString()
|
46
|
-
return @bytes.pack('c*').force_encoding("ISO-8859-1")
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# This class encapsulates the data structure of an array of bytes. Depending
|
2
|
+
# on the platform the actual byte array ca be a String, an array of integers,
|
3
|
+
# or the best choice everywhere.
|
4
|
+
# It is encouraged to use this structure specially for input/output
|
5
|
+
# operations where large byte arrays have to be handled.
|
6
|
+
|
7
|
+
module Wiris
|
8
|
+
class Bytes
|
9
|
+
def bytes=(bytes)
|
10
|
+
@bytes=bytes
|
11
|
+
end
|
12
|
+
def bytes
|
13
|
+
@bytes
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(bytes)
|
17
|
+
@bytes = bytes
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def self.ofString(s)
|
22
|
+
return Bytes.new(s.force_encoding("ISO-8859-1").bytes.to_a)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.ofData(data)
|
26
|
+
return Bytes.new(data)
|
27
|
+
end
|
28
|
+
|
29
|
+
def getData()
|
30
|
+
return @bytes
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(index)
|
34
|
+
return @bytes[index]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.alloc(int)
|
38
|
+
return []
|
39
|
+
end
|
40
|
+
|
41
|
+
def length()
|
42
|
+
return @bytes.length
|
43
|
+
end
|
44
|
+
|
45
|
+
def toString()
|
46
|
+
return @bytes.pack('c*').force_encoding("ISO-8859-1")
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|