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/src-generic/Math.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class Math
|
|
3
|
-
def self.round(f)
|
|
4
|
-
return f.round
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def self.random()
|
|
8
|
-
return Random::rand()
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.floor(f)
|
|
12
|
-
return f.floor
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class Math
|
|
3
|
+
def self.round(f)
|
|
4
|
+
return f.round
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.random()
|
|
8
|
+
return Random::rand()
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.floor(f)
|
|
12
|
+
return f.floor
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
15
|
end
|
data/lib/src-generic/Md5.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require 'digest/md5'
|
|
2
|
-
module Wiris
|
|
3
|
-
class Md5
|
|
4
|
-
def self.encode(content)
|
|
5
|
-
return Digest::MD5.hexdigest(content)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
end
|
|
1
|
+
require 'digest/md5'
|
|
2
|
+
module Wiris
|
|
3
|
+
class Md5
|
|
4
|
+
def self.encode(content)
|
|
5
|
+
return Digest::MD5.hexdigest(content)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
data/lib/src-generic/Md5Tools.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class Md5Tools
|
|
3
|
-
def self.encodeString(content)
|
|
4
|
-
return Md5::encode(content)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def self.encodeBytes(bytes)
|
|
8
|
-
bytes = bytes.getData()
|
|
9
|
-
return Md5::encode(bytes.pack('c*'))
|
|
10
|
-
end
|
|
11
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class Md5Tools
|
|
3
|
+
def self.encodeString(content)
|
|
4
|
+
return Md5::encode(content)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.encodeBytes(bytes)
|
|
8
|
+
bytes = bytes.getData()
|
|
9
|
+
return Md5::encode(bytes.pack('c*'))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
12
|
end
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class PropertiesTools
|
|
3
|
-
def self.getProperty(prop, key, dflt=nil)
|
|
4
|
-
if (!prop[key].nil?)
|
|
5
|
-
return prop[key]
|
|
6
|
-
else
|
|
7
|
-
return dflt
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.setProperty(prop, key, value)
|
|
12
|
-
prop[key] = value
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.newProperties()
|
|
16
|
-
return Hash.new()
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.toProperties(hashString)
|
|
20
|
-
p = Hash.new()
|
|
21
|
-
keys = hashString.keys()
|
|
22
|
-
while keys.hasNext()
|
|
23
|
-
key = keys.next()
|
|
24
|
-
p[key] = hashString.get(key)
|
|
25
|
-
end
|
|
26
|
-
return p
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.fromProperties(prop)
|
|
30
|
-
return prop
|
|
31
|
-
end
|
|
32
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class PropertiesTools
|
|
3
|
+
def self.getProperty(prop, key, dflt=nil)
|
|
4
|
+
if (!prop[key].nil?)
|
|
5
|
+
return prop[key]
|
|
6
|
+
else
|
|
7
|
+
return dflt
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.setProperty(prop, key, value)
|
|
12
|
+
prop[key] = value
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.newProperties()
|
|
16
|
+
return Hash.new()
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.toProperties(hashString)
|
|
20
|
+
p = Hash.new()
|
|
21
|
+
keys = hashString.keys()
|
|
22
|
+
while keys.hasNext()
|
|
23
|
+
key = keys.next()
|
|
24
|
+
p[key] = hashString.get(key)
|
|
25
|
+
end
|
|
26
|
+
return p
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.fromProperties(prop)
|
|
30
|
+
return prop
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
33
|
end
|
data/lib/src-generic/Reflect.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class Reflect
|
|
3
|
-
def self.field(obj, field)
|
|
4
|
-
begin
|
|
5
|
-
cls = Module::const_get(obj.name)
|
|
6
|
-
return cls.class_variable_get(("@@" + field).to_sym)
|
|
7
|
-
end
|
|
8
|
-
rescue NameError
|
|
9
|
-
return nil
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.setField(obj, field, value)
|
|
13
|
-
cls = Module::const_get(obj.name)
|
|
14
|
-
cls.class_variable_set(("@@" + field), value)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class Reflect
|
|
3
|
+
def self.field(obj, field)
|
|
4
|
+
begin
|
|
5
|
+
cls = Module::const_get(obj.name)
|
|
6
|
+
return cls.class_variable_get(("@@" + field).to_sym)
|
|
7
|
+
end
|
|
8
|
+
rescue NameError
|
|
9
|
+
return nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.setField(obj, field, value)
|
|
13
|
+
cls = Module::const_get(obj.name)
|
|
14
|
+
cls.class_variable_set(("@@" + field), value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
17
|
end
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
module WirisPlugin
|
|
2
|
-
class RubyConfigurationUpdater
|
|
3
|
-
include Wiris
|
|
4
|
-
def request
|
|
5
|
-
@request
|
|
6
|
-
end
|
|
7
|
-
def request=(request)
|
|
8
|
-
@request=request
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def init(obj)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def updateConfiguration(configuration)
|
|
15
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CACHE_FOLDER, nil)
|
|
16
|
-
if v.nil?
|
|
17
|
-
configuration[ConfigurationKeys::CACHE_FOLDER] = File.dirname(__FILE__) + "/../../cache"
|
|
18
|
-
end
|
|
19
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::FORMULA_FOLDER, nil)
|
|
20
|
-
if v.nil?
|
|
21
|
-
configuration[ConfigurationKeys::FORMULA_FOLDER] = File.dirname(__FILE__) + "/../../formulas"
|
|
22
|
-
end
|
|
23
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::SHOWIMAGE_PATH, nil)
|
|
24
|
-
if v.nil?
|
|
25
|
-
configuration[ConfigurationKeys::SHOWIMAGE_PATH] = "wirispluginengine/integration/showimage?formula="
|
|
26
|
-
end
|
|
27
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CLEAN_CACHE_PATH, nil)
|
|
28
|
-
if v.nil?
|
|
29
|
-
configuration[ConfigurationKeys::CLEAN_CACHE_PATH] = "cleancache"
|
|
30
|
-
end
|
|
31
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::RESOURCE_PATH, nil)
|
|
32
|
-
if v.nil?
|
|
33
|
-
configuration[ConfigurationKeys::RESOURCE_PATH] = "resource"
|
|
34
|
-
end
|
|
35
|
-
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CONFIGURATION_PATH, nil)
|
|
36
|
-
if v.nil?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
module WirisPlugin
|
|
2
|
+
class RubyConfigurationUpdater
|
|
3
|
+
include Wiris
|
|
4
|
+
def request
|
|
5
|
+
@request
|
|
6
|
+
end
|
|
7
|
+
def request=(request)
|
|
8
|
+
@request=request
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def init(obj)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def updateConfiguration(configuration)
|
|
15
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CACHE_FOLDER, nil)
|
|
16
|
+
if v.nil?
|
|
17
|
+
configuration[ConfigurationKeys::CACHE_FOLDER] = File.dirname(__FILE__) + "/../../cache"
|
|
18
|
+
end
|
|
19
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::FORMULA_FOLDER, nil)
|
|
20
|
+
if v.nil?
|
|
21
|
+
configuration[ConfigurationKeys::FORMULA_FOLDER] = File.dirname(__FILE__) + "/../../formulas"
|
|
22
|
+
end
|
|
23
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::SHOWIMAGE_PATH, nil)
|
|
24
|
+
if v.nil?
|
|
25
|
+
configuration[ConfigurationKeys::SHOWIMAGE_PATH] = "wirispluginengine/integration/showimage?formula="
|
|
26
|
+
end
|
|
27
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CLEAN_CACHE_PATH, nil)
|
|
28
|
+
if v.nil?
|
|
29
|
+
configuration[ConfigurationKeys::CLEAN_CACHE_PATH] = "cleancache"
|
|
30
|
+
end
|
|
31
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::RESOURCE_PATH, nil)
|
|
32
|
+
if v.nil?
|
|
33
|
+
configuration[ConfigurationKeys::RESOURCE_PATH] = "resource"
|
|
34
|
+
end
|
|
35
|
+
v =PropertiesTools::getProperty(configuration, ConfigurationKeys::CONFIGURATION_PATH, nil)
|
|
36
|
+
if v.nil?
|
|
37
|
+
if File.file?(Rails.root.join('vendor', 'wiris', 'configuration.ini'))
|
|
38
|
+
configuration[ConfigurationKeys::CONFIGURATION_PATH] = Rails.root.join('vendor', 'wiris').to_s
|
|
39
|
+
else
|
|
40
|
+
configuration[ConfigurationKeys::CONFIGURATION_PATH] = File.dirname(__FILE__) + "/../../"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
v = PropertiesTools::getProperty(configuration, ConfigurationKeys::REFERER, nil)
|
|
44
|
+
if v.nil?
|
|
45
|
+
configuration[ConfigurationKeys::REFERER] = request.original_url
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class Serializer
|
|
3
|
-
def buf
|
|
4
|
-
@buf
|
|
5
|
-
end
|
|
6
|
-
def initialize()
|
|
7
|
-
@buf = StringBuf.new()
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
# a : array
|
|
12
|
-
# b : hash
|
|
13
|
-
# c : class
|
|
14
|
-
# d : Float
|
|
15
|
-
# e : reserved (float exp)
|
|
16
|
-
# f : false
|
|
17
|
-
# g : object end
|
|
18
|
-
# h : array/list/hash end
|
|
19
|
-
# i : Int
|
|
20
|
-
# j : enum (by index)
|
|
21
|
-
# k : NaN
|
|
22
|
-
# l : list
|
|
23
|
-
# m : -Inf
|
|
24
|
-
# n : null
|
|
25
|
-
# o : object
|
|
26
|
-
# p : +Inf
|
|
27
|
-
# q : inthash
|
|
28
|
-
# r : reference
|
|
29
|
-
# s : bytes (base64)
|
|
30
|
-
# t : true
|
|
31
|
-
# u : array nulls
|
|
32
|
-
# v : date
|
|
33
|
-
# w : enum
|
|
34
|
-
# x : exceptiona
|
|
35
|
-
# y : urlencoded string
|
|
36
|
-
# z : zero
|
|
37
|
-
# C : custom
|
|
38
|
-
|
|
39
|
-
def serialize(o)
|
|
40
|
-
c = Type.getClass(o)
|
|
41
|
-
if (c == Type.resolveClass(Array).to_s)
|
|
42
|
-
buf.add("a")
|
|
43
|
-
v = o
|
|
44
|
-
ucount = 0
|
|
45
|
-
l = v.length()
|
|
46
|
-
for i in 0..l
|
|
47
|
-
if (v._(i) == nil)
|
|
48
|
-
ucount += 1
|
|
49
|
-
else
|
|
50
|
-
if (ucount > 0)
|
|
51
|
-
if (ucount == 1)
|
|
52
|
-
buf.add("n")
|
|
53
|
-
else
|
|
54
|
-
buf.add("u")
|
|
55
|
-
buf.add("" + ucount.to_s)
|
|
56
|
-
end
|
|
57
|
-
ucount = 0
|
|
58
|
-
end
|
|
59
|
-
serialize(v._(i))
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
buf.add("h")
|
|
63
|
-
elsif (o.is_a? Integer)
|
|
64
|
-
if (o == 0)
|
|
65
|
-
buf.add("z")
|
|
66
|
-
else
|
|
67
|
-
buf.add("i")
|
|
68
|
-
buf.add("" + o.to_s)
|
|
69
|
-
end
|
|
70
|
-
else
|
|
71
|
-
raise Exception, "Object class not implemented: "+ c
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def toString()
|
|
76
|
-
return buf.toString()
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def self.run(o)
|
|
80
|
-
s = Serializer.new()
|
|
81
|
-
s.serialize(o)
|
|
82
|
-
return s.toString()
|
|
83
|
-
end
|
|
84
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class Serializer
|
|
3
|
+
def buf
|
|
4
|
+
@buf
|
|
5
|
+
end
|
|
6
|
+
def initialize()
|
|
7
|
+
@buf = StringBuf.new()
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# a : array
|
|
12
|
+
# b : hash
|
|
13
|
+
# c : class
|
|
14
|
+
# d : Float
|
|
15
|
+
# e : reserved (float exp)
|
|
16
|
+
# f : false
|
|
17
|
+
# g : object end
|
|
18
|
+
# h : array/list/hash end
|
|
19
|
+
# i : Int
|
|
20
|
+
# j : enum (by index)
|
|
21
|
+
# k : NaN
|
|
22
|
+
# l : list
|
|
23
|
+
# m : -Inf
|
|
24
|
+
# n : null
|
|
25
|
+
# o : object
|
|
26
|
+
# p : +Inf
|
|
27
|
+
# q : inthash
|
|
28
|
+
# r : reference
|
|
29
|
+
# s : bytes (base64)
|
|
30
|
+
# t : true
|
|
31
|
+
# u : array nulls
|
|
32
|
+
# v : date
|
|
33
|
+
# w : enum
|
|
34
|
+
# x : exceptiona
|
|
35
|
+
# y : urlencoded string
|
|
36
|
+
# z : zero
|
|
37
|
+
# C : custom
|
|
38
|
+
|
|
39
|
+
def serialize(o)
|
|
40
|
+
c = Type.getClass(o)
|
|
41
|
+
if (c == Type.resolveClass(Array).to_s)
|
|
42
|
+
buf.add("a")
|
|
43
|
+
v = o
|
|
44
|
+
ucount = 0
|
|
45
|
+
l = v.length()
|
|
46
|
+
for i in 0..l
|
|
47
|
+
if (v._(i) == nil)
|
|
48
|
+
ucount += 1
|
|
49
|
+
else
|
|
50
|
+
if (ucount > 0)
|
|
51
|
+
if (ucount == 1)
|
|
52
|
+
buf.add("n")
|
|
53
|
+
else
|
|
54
|
+
buf.add("u")
|
|
55
|
+
buf.add("" + ucount.to_s)
|
|
56
|
+
end
|
|
57
|
+
ucount = 0
|
|
58
|
+
end
|
|
59
|
+
serialize(v._(i))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
buf.add("h")
|
|
63
|
+
elsif (o.is_a? Integer)
|
|
64
|
+
if (o == 0)
|
|
65
|
+
buf.add("z")
|
|
66
|
+
else
|
|
67
|
+
buf.add("i")
|
|
68
|
+
buf.add("" + o.to_s)
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
raise Exception, "Object class not implemented: "+ c
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def toString()
|
|
76
|
+
return buf.toString()
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.run(o)
|
|
80
|
+
s = Serializer.new()
|
|
81
|
+
s.serialize(o)
|
|
82
|
+
return s.toString()
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
85
|
end
|
data/lib/src-generic/Std.rb
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
module Wiris
|
|
2
|
-
class Std
|
|
3
|
-
def self.trace(s)
|
|
4
|
-
puts s
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def self.is(o, cls)
|
|
8
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.substr(text, x0, length=-1)
|
|
12
|
-
if length==-1
|
|
13
|
-
text[x0..text.length]
|
|
14
|
-
else
|
|
15
|
-
text[x0,length] # Strings starts at 0
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def split(text, delimitator)
|
|
20
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.parseInt(number)
|
|
24
|
-
return Integer(number)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.parseFloat(number)
|
|
28
|
-
return Float(number)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# @deprecated
|
|
32
|
-
def parseDouble(number)
|
|
33
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.fromCharCode(c)
|
|
37
|
-
return c.chr(Encoding::UTF_8)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.charCodeAt(str, i)
|
|
41
|
-
return str[i].ord
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def copyInto(array, cs)
|
|
45
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def exit(n)
|
|
49
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def random(x)
|
|
53
|
-
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def self.split(str, delimitator)
|
|
57
|
-
arr = Array.new()
|
|
58
|
-
str.split(delimitator).each {|x| arr.push(x)}
|
|
59
|
-
return arr
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
@@random = nil
|
|
63
|
-
def self.random=(random)
|
|
64
|
-
@@random=random
|
|
65
|
-
end
|
|
66
|
-
def self.random(x)
|
|
67
|
-
if @@random == nil
|
|
68
|
-
@@random = Random.new()
|
|
69
|
-
end
|
|
70
|
-
return @@random.rand(x)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
end
|
|
1
|
+
module Wiris
|
|
2
|
+
class Std
|
|
3
|
+
def self.trace(s)
|
|
4
|
+
puts s
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.is(o, cls)
|
|
8
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.substr(text, x0, length=-1)
|
|
12
|
+
if length==-1
|
|
13
|
+
text[x0..text.length]
|
|
14
|
+
else
|
|
15
|
+
text[x0,length] # Strings starts at 0
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def split(text, delimitator)
|
|
20
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.parseInt(number)
|
|
24
|
+
return Integer(number)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.parseFloat(number)
|
|
28
|
+
return Float(number)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @deprecated
|
|
32
|
+
def parseDouble(number)
|
|
33
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.fromCharCode(c)
|
|
37
|
+
return c.chr(Encoding::UTF_8)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.charCodeAt(str, i)
|
|
41
|
+
return str[i].ord
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def copyInto(array, cs)
|
|
45
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def exit(n)
|
|
49
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def random(x)
|
|
53
|
+
raise Exception,'Error: '+ __callee__.to_s + ' method not defined'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.split(str, delimitator)
|
|
57
|
+
arr = Array.new()
|
|
58
|
+
str.split(delimitator).each {|x| arr.push(x)}
|
|
59
|
+
return arr
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@@random = nil
|
|
63
|
+
def self.random=(random)
|
|
64
|
+
@@random=random
|
|
65
|
+
end
|
|
66
|
+
def self.random(x)
|
|
67
|
+
if @@random == nil
|
|
68
|
+
@@random = Random.new()
|
|
69
|
+
end
|
|
70
|
+
return @@random.rand(x)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|