Apply pretty print tool.

Apply on each class in test suite and library.
This commit is contained in:
Conaclos
2014-07-04 17:59:05 +02:00
parent 361773101e
commit 20e704604a
33 changed files with 2005 additions and 1983 deletions

View File

@@ -5,20 +5,22 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
class JSON_ARRAYED_LIST_CONVERTER
class
JSON_ARRAYED_LIST_CONVERTER
inherit
JSON_LIST_CONVERTER
JSON_LIST_CONVERTER
redefine
object
end
create
make
make
feature -- Access
object: ARRAYED_LIST [detachable ANY]
object: ARRAYED_LIST [detachable ANY]
feature {NONE} -- Factory

View File

@@ -5,32 +5,34 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
deferred class JSON_CONVERTER
deferred class
JSON_CONVERTER
inherit
SHARED_EJSON
SHARED_EJSON
feature -- Access
object: ANY
-- Eiffel object
deferred
end
object: ANY
-- Eiffel object
deferred
end
feature -- Conversion
from_json (j: attached like to_json): detachable like object
-- Convert from JSON value.
from_json (j: attached like to_json): detachable like object
-- Convert from JSON value.
-- Returns Void if unable to convert
deferred
end
deferred
end
to_json (o: like object): detachable JSON_VALUE
-- Convert to JSON value
deferred
end
to_json (o: like object): detachable JSON_VALUE
-- Convert to JSON value
deferred
end
invariant
has_eiffel_object: object /= Void -- An empty object must be created at creation time!
has_eiffel_object: object /= Void -- An empty object must be created at creation time!
end

View File

@@ -1,76 +1,82 @@
note
description: "A JSON converter for HASH_TABLE [ANY, HASHABLE]"
author: "Paul Cohen"
description: "A JSON converter for HASH_TABLE [ANY, HASHABLE]"
author: "Paul Cohen"
date: "$Date: 2014-01-30 15:27:41 +0100 (jeu., 30 janv. 2014) $"
revision: "$Revision: 94128 $"
file: "$HeadURL: $"
file: "$HeadURL: $"
class JSON_HASH_TABLE_CONVERTER
class
JSON_HASH_TABLE_CONVERTER
inherit
JSON_CONVERTER
JSON_CONVERTER
create
make
make
feature {NONE} -- Initialization
make
do
create object.make (0)
end
make
do
create object.make (0)
end
feature -- Access
object: HASH_TABLE [ANY, HASHABLE]
object: HASH_TABLE [ANY, HASHABLE]
feature -- Conversion
from_json (j: attached like to_json): like object
do
create Result.make (j.count)
across
j as ic
loop
if attached json.object (ic.item, Void) as l_object then
from_json (j: attached like to_json): like object
do
create Result.make (j.count)
across
j as ic
loop
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 key_is_hashable: False end
check
key_is_hashable: False
end
end
else
check object_attached: False end
end
end
end
else
check
object_attached: False
end
end
end
end
to_json (o: like object): detachable JSON_OBJECT
local
c: HASH_TABLE_ITERATION_CURSOR [ANY, HASHABLE]
js: JSON_STRING
failed: BOOLEAN
do
create Result.make
from
c := o.new_cursor
until
c.after
loop
if attached {JSON_STRING} json.value (c.key) as l_key then
js := l_key
else
create js.make_json (c.key.out)
end
if attached json.value (c.item) as jv then
Result.put (jv, js)
else
failed := True
end
c.forth
end
if failed then
Result := Void
end
end
to_json (o: like object): detachable JSON_OBJECT
local
c: HASH_TABLE_ITERATION_CURSOR [ANY, HASHABLE]
js: JSON_STRING
failed: BOOLEAN
do
create Result.make
from
c := o.new_cursor
until
c.after
loop
if attached {JSON_STRING} json.value (c.key) as l_key then
js := l_key
else
create js.make_json (c.key.out)
end
if attached json.value (c.item) as jv then
Result.put (jv, js)
else
failed := True
end
c.forth
end
if failed then
Result := Void
end
end
end -- class JSON_HASH_TABLE_CONVERTER

View File

@@ -5,20 +5,22 @@ note
revision: "$Revision$"
file: "$HeadURL: $"
class JSON_LINKED_LIST_CONVERTER
class
JSON_LINKED_LIST_CONVERTER
inherit
JSON_LIST_CONVERTER
JSON_LIST_CONVERTER
redefine
object
end
create
make
make
feature -- Access
object: LINKED_LIST [detachable ANY]
object: LINKED_LIST [detachable ANY]
feature {NONE} -- Factory

View File

@@ -1,25 +1,27 @@
note
description: "A JSON converter for LIST [ANY]"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
file: "$HeadURL: $"
description: "A JSON converter for LIST [ANY]"
author: "Paul Cohen"
date: "$Date$"
revision: "$Revision$"
file: "$HeadURL: $"
deferred class JSON_LIST_CONVERTER
deferred class
JSON_LIST_CONVERTER
inherit
JSON_CONVERTER
JSON_CONVERTER
feature {NONE} -- Initialization
make
make
do
object := new_object (0)
end
end
feature -- Access
object: LIST [detachable ANY]
object: LIST [detachable ANY]
feature {NONE} -- Factory
@@ -31,44 +33,44 @@ feature {NONE} -- Factory
feature -- Conversion
from_json (j: attached like to_json): detachable like object
local
i: INTEGER
do
Result := new_object (j.count)
from
i := 1
until
i > j.count
loop
Result.extend (json.object (j [i], Void))
i := i + 1
end
end
from_json (j: attached like to_json): detachable like object
local
i: INTEGER
do
Result := new_object (j.count)
from
i := 1
until
i > j.count
loop
Result.extend (json.object (j [i], Void))
i := i + 1
end
end
to_json (o: like object): detachable JSON_ARRAY
local
c: ITERATION_CURSOR [detachable ANY]
jv: detachable JSON_VALUE
to_json (o: like object): detachable JSON_ARRAY
local
c: ITERATION_CURSOR [detachable ANY]
jv: detachable JSON_VALUE
failed: BOOLEAN
do
create Result.make_array
from
c := o.new_cursor
until
c.after
loop
jv := json.value (c.item)
if jv /= Void then
Result.add (jv)
else
do
create Result.make_array
from
c := o.new_cursor
until
c.after
loop
jv := json.value (c.item)
if jv /= Void then
Result.add (jv)
else
failed := True
end
end
c.forth
end
end
if failed then
Result := Void
end
end
end
end -- class JSON_ARRAYED_LIST_CONVERTER