Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
*.swp
EIFGENs
TESTGEN
ejson_test.h
ejson_test*.c
ejson_test.sh
ejson_test*.o
ejson_test
8 changes: 8 additions & 0 deletions library/gobo/converters/json_ds_hash_table_converter.e
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,25 @@ feature -- Conversion
i: INTEGER
h: HASHABLE
a: ANY
ucs: UC_STRING
do
keys := j.current_keys
create Result.make (keys.count)
create ucs.make_empty
from
i := 1
until
i > keys.count
loop
h ?= json.object (keys [i], void)
check h /= Void end
if attached {STRING_32} h and attached Json.converter_for (ucs) then
h ?= json.object (keys [i], ucs.generator)
end
a := json.object (j.item (keys [i]), Void)
if attached {STRING_32} a and attached Json.converter_for (ucs) then
a := json.object (j.item (keys [i]), ucs.generator)
end
Result.put (a, h)
i := i + 1
end
Expand Down
39 changes: 39 additions & 0 deletions library/gobo/converters/json_uc_string_converter.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
note
description: "JSON UC_STRING converter."
author: "Olivier Ligot"

class
JSON_UC_STRING_CONVERTER

inherit
JSON_CONVERTER

create
make

feature {NONE} -- Initialization

make
do
create object.make (0)
end

feature -- Access

value: JSON_STRING

object: UC_STRING

feature -- Conversion

from_json (j: like value): like object
do
create Result.make_from_string_general (j.unescaped_string_32)
end

to_json (o: like object): like value
do
create Result.make_json_from_string_32 (o.as_string_32)
end

end
17 changes: 11 additions & 6 deletions library/json-safe.ecf
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
<warning name="syntax" enabled="false"/>
<warning name="vjrv" enabled="false"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf" readonly="true"/>
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" excluded_value="ge"/>
</condition>
</library>
<library name="free_elks" location="$GOBO/library/free_elks/library.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" value="ge"/>
</condition>
</library>
<cluster name="json" location=".\" recursive="true">
<file_rule>
<exclude>^/gobo$</exclude>
<exclude>^/kernel$</exclude>
<exclude>^/extras$</exclude>
<exclude>.*/?gobo.*</exclude>
</file_rule>
<cluster name="kernel" location=".\kernel\" recursive="true"/>
<cluster name="extras" location=".\extras\" recursive="true"/>
</cluster>
</target>
</system>
17 changes: 11 additions & 6 deletions library/json.ecf
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@
<warning name="syntax" enabled="false"/>
<warning name="vjrv" enabled="false"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf" readonly="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" excluded_value="ge"/>
</condition>
</library>
<library name="free_elks" location="$GOBO/library/free_elks/library.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" value="ge"/>
</condition>
</library>
<cluster name="json" location=".\" recursive="true">
<file_rule>
<exclude>^/gobo$</exclude>
<exclude>^/kernel$</exclude>
<exclude>^/extras$</exclude>
<exclude>.*/?gobo.*</exclude>
</file_rule>
<cluster name="kernel" location=".\kernel\" recursive="true"/>
<cluster name="extras" location=".\extras\" recursive="true"/>
</cluster>
</target>
</system>
27 changes: 27 additions & 0 deletions library/json_gobo_extension-portable.ecf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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_gobo" uuid="437195AB-8B3C-4238-8998-A932A1423449" library_target="json_gobo">
<target name="json_gobo">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option trace="false" profile="false" debug="false" warning="true" full_class_checking="true" void_safety="none" syntax="standard" namespace="EJSON.Library">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" excluded_value="ge"/>
</condition>
</library>
<library name="free_elks" location="$GOBO/library/free_elks/library.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" value="ge"/>
</condition>
</library>
<library name="json" location="json-safe.ecf" readonly="true"/>
<library name="gobo_kernel" location="$GOBO\library\kernel\library.ecf"/>
<library name="gobo_structure" location="$EIFFEL_LIBRARY\gobo-ecf\ecf\gobo-structure-confident.ecf"/>
<cluster name="json_gobo" location=".\gobo" recursive="true" />
</target>
</system>
12 changes: 11 additions & 1 deletion library/json_gobo_extension.ecf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
</file_rule>
<option trace="false" profile="false" debug="false" warning="true" full_class_checking="true" void_safety="none" syntax="standard" namespace="EJSON.Library">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf" readonly="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" excluded_value="ge"/>
</condition>
</library>
<library name="free_elks" location="$GOBO/library/free_elks/library.ecf" readonly="true">
<condition>
<custom name="GOBO_EIFFEL" value="ge"/>
</condition>
</library>
<library name="json" location="json.ecf" readonly="true"/>
<library name="gobo_kernel" location="$ISE_LIBRARY\library\gobo\gobo_kernel.ecf"/>
<library name="gobo_structure" location="$ISE_LIBRARY\library\gobo\gobo_structure.ecf"/>
<cluster name="json_gobo" location=".\gobo" recursive="true" />
</target>
Expand Down
2 changes: 1 addition & 1 deletion library/kernel/converters/json_hash_table_converter.e
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ feature -- Conversion
jv := j.item (keys [i])
if jv /= Void then
a := json.object (jv, Void)
if a /= Void then
if a /= Void and h /= Void then
Result.put (a, h)
else
check a_attached: a /= Void end
Expand Down
24 changes: 24 additions & 0 deletions test/getest/author.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class AUTHOR

create
make

feature {NONE} -- Initialization

make (a_name: UC_STRING)
do
set_name (a_name)
end

feature -- Access

name: UC_STRING

feature -- Status setting

set_name (a_name: UC_STRING)
do
name := a_name
end

end -- class AUTHOR
40 changes: 40 additions & 0 deletions test/getest/book.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class BOOK

create
make

feature {NONE} -- Initialization

make (a_title: UC_STRING; an_author: AUTHOR; an_isbn: UC_STRING)
do
set_title (a_title)
set_author (an_author)
set_isbn (an_isbn)
end

feature -- Access

title: UC_STRING

isbn: UC_STRING

author: AUTHOR

feature -- Status setting

set_title (a_title: UC_STRING)
do
title := a_title
end

set_author (an_author: AUTHOR)
do
author := an_author
end

set_isbn (an_isbn: UC_STRING)
do
isbn := an_isbn
end

end -- class BOOK
82 changes: 82 additions & 0 deletions test/getest/book_collection.e
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
class BOOK_COLLECTION

create
make

feature {NONE} -- Initialization

make (a_name: UC_STRING)
do
set_name (a_name)
create book_index.make (10)
end

feature -- Access

name: UC_STRING

books: DS_LIST [BOOK]
local
c: DS_HASH_TABLE_CURSOR [DS_LIST [BOOK], UC_STRING]
do
from
create {DS_LINKED_LIST [BOOK]} Result.make
c := book_index.new_cursor
c.start
until
c.after
loop
Result.append_last (c.item)
c.forth
end
end

books_by_author (an_author: UC_STRING): DS_LIST [BOOK]
do
if book_index.has (an_author) then
Result := book_index @ an_author
else
create {DS_LINKED_LIST [BOOK]} Result.make
end
end

feature -- Status setting

set_name (a_name: UC_STRING)
do
name := a_name
end

add_book (a_book: BOOK)
local
l: DS_LIST [BOOK]
do
if book_index.has (a_book.author.name) then
l := book_index @ a_book.author.name
else
create {DS_LINKED_LIST [BOOK]} l.make
book_index.put (l, a_book.author.name)
end
l.put_last (a_book)
end

add_books (book_list: like books)
local
c: DS_LIST_CURSOR [BOOK]
do
from
c := book_list.new_cursor
c.start
until
c.after
loop
add_book (c.item)
c.forth
end
end

feature {NONE} -- Implementation

book_index: DS_HASH_TABLE [DS_LIST [BOOK], UC_STRING]

end -- class BOOK_COLLECTION
11 changes: 11 additions & 0 deletions test/getest/ec_compile.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo Compiling ejson_test (finalized)
ecb -finalize -c_compile -config ejson_test.ecf -batch -clean > NUL 2>&1
IF %ERRORLEVEL% EQU -1 goto ERROR
copy EIFGENs\ejson_test\F_code\ejson_test.exe ejson_test.exe
goto EOF

:ERROR
echo Error occurred during ejson_test compilation
goto EOF

:EOF
5 changes: 5 additions & 0 deletions test/getest/ec_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "ec -finalize -c_compile -config ejson_test.ecf > /dev/null 2>&1"
ec -finalize -c_compile -config ejson_test.ecf > /dev/null 2>&1
cp EIFGENs/ejson_test/F_code/ejson_test .
17 changes: 17 additions & 0 deletions test/getest/ejson_test-win.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Gobo test (getest) configuration file for eJSON

test
ejson_test

default
class ("TEST_[A-Z0-9_]*")
feature ("test_[a-z0-9_]*")
prefix ("X")
testgen ("TESTGEN")
compile ("ec_compile.bat")
execute ("ejson_test.exe")

cluster
test_dir: "."

end
16 changes: 16 additions & 0 deletions test/getest/ejson_test-win.ge
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Gobo test (getest) configuration file for eJSON

test
ejson_test

default
class ("TEST_[A-Z0-9_]*")
feature ("test_[a-z0-9_]*")
prefix ("X")
testgen ("TESTGEN")
compile ("ge_compile.bat")

cluster
test_dir: "."

end
Loading