Udated to highest level of void-safety.

Fixed obsolete calls.
This commit is contained in:
2014-02-03 09:52:09 +01:00
parent b7750b9d06
commit cb7c20a0b7
3 changed files with 46 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="json" uuid="4E21C3BD-7951-4C6E-A673-431E762D7414" library_target="json">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="json" uuid="4E21C3BD-7951-4C6E-A673-431E762D7414" library_target="json">
<target name="json">
<root all_classes="true"/>
<file_rule>

View File

@@ -1,8 +1,8 @@
note
description: "A JSON converter for HASH_TABLE [ANY, HASHABLE]"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
date: "$Date: 2014-01-30 15:27:41 +0100 (jeu., 30 janv. 2014) $"
revision: "$Revision: 94128 $"
file: "$HeadURL: $"
class JSON_HASH_TABLE_CONVERTER
@@ -27,34 +27,20 @@ feature -- Access
feature -- Conversion
from_json (j: attached like to_json): like object
local
keys: ARRAY [JSON_STRING]
i: INTEGER
h: detachable HASHABLE
jv: detachable JSON_VALUE
a: detachable ANY
do
keys := j.current_keys
create Result.make (keys.count)
from
i := 1
until
i > keys.count
create Result.make (j.count)
across
j as ic
loop
h ?= json.object (keys [i], Void)
check h /= Void end
jv := j.item (keys [i])
if jv /= Void then
a := json.object (jv, Void)
if a /= Void then
Result.put (a, h)
if attached json.object (ic.item, Void) as l_object then
if attached {HASHABLE} json.object (ic.key, Void) as h then
Result.put (l_object, h)
else
check a_attached: a /= Void end
check key_is_hashable: False end
end
else
check j_has_item: False end
check object_attached: False end
end
i := i + 1
end
end
@@ -62,7 +48,6 @@ feature -- Conversion
local
c: HASH_TABLE_ITERATION_CURSOR [ANY, HASHABLE]
js: JSON_STRING
jv: detachable JSON_VALUE
failed: BOOLEAN
do
create Result.make
@@ -76,8 +61,7 @@ feature -- Conversion
else
create js.make_json (c.key.out)
end
jv := json.value (c.item)
if jv /= Void then
if attached json.value (c.item) as jv then
Result.put (jv, js)
else
failed := True

View File

@@ -475,8 +475,38 @@ feature -- JSON_FROM_FILE
json_value: detachable JSON_VALUE
json_file_from (fn: STRING): detachable STRING
local
f: RAW_FILE
l_path: STRING
test_dir: STRING
i: INTEGER
do
Result := file_reader.read_json_from (test_dir + fn)
test_dir := (create {EXECUTION_ENVIRONMENT}).current_working_directory
test_dir.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
l_path := test_dir + fn
create f.make_with_name (l_path)
if f.exists then
-- Found json file
else
-- before EiffelStudio 7.3 , the current dir of autotest execution was not the parent dir of ecf but something like
-- ..json\test\autotest\test_suite\EIFGENs\test_suite\Testing\execution\TEST_JSON_SUITE.test_json_fail1\..\..\..\..\..\fail1.json
from
i := 5
until
i = 0
loop
test_dir.append_character ('.')
test_dir.append_character ('.')
test_dir.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
i := i - 1
end
l_path := test_dir + fn
end
create f.make_with_name (l_path)
if f.exists then
Result := file_reader.read_json_from (l_path)
end
assert ("File contains json data", Result /= Void)
end
@@ -485,30 +515,9 @@ feature -- JSON_FROM_FILE
create Result.make_parser (a_string)
end
test_dir: STRING
local
i: INTEGER
do
Result := (create {EXECUTION_ENVIRONMENT}).current_working_directory
Result.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
-- The should looks like
-- ..json\test\autotest\test_suite\EIFGENs\test_suite\Testing\execution\TEST_JSON_SUITE.test_json_fail1\..\..\..\..\..\fail1.json
from
i := 5
until
i = 0
loop
Result.append_character ('.')
Result.append_character ('.')
Result.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
i := i - 1
end
-- Result := "/home/jvelilla/work/project/Eiffel/ejson_dev/trunk/test/autotest/test_suite/"
end
invariant
file_reader /= Void
end