Make recommended changes

- Implicit casting
- Use same_string
This commit is contained in:
YNH Webdev
2013-09-20 20:49:03 +02:00
parent 0a2883e040
commit b5ef1fbbb5
13 changed files with 47 additions and 47 deletions

View File

@@ -33,7 +33,7 @@ feature -- Implementation
loop
if c.item.as_lower.has_substring (input.as_lower) then
create o.make
o.put (create {JSON_STRING}.make_json (c.item), "value")
o.put (create {JSON_STRING}.make_json(c.item), "value")
Result.add (o)
end
end

View File

@@ -26,10 +26,10 @@ feature -- Update event
update
do
if attached on_update_agent as a then
a.call ([])
a.call (Void)
end
if attached on_update_page_agent as a then
a.call ([])
a.call (Void)
end
end
@@ -41,21 +41,21 @@ feature --States
-- Return state which contains the current html and if there is an event handle attached
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (page), create {JSON_STRING}.make_json ("page"))
Result.put (create {JSON_NUMBER}.make_integer (page_size), create {JSON_STRING}.make_json ("page_size"))
Result.put (create {JSON_NUMBER}.make_integer (row_count), create {JSON_STRING}.make_json ("row_count"))
Result.put (create {JSON_NUMBER}.make_integer (page), "page")
Result.put (create {JSON_NUMBER}.make_integer (page_size), "page_size")
Result.put (create {JSON_NUMBER}.make_integer (row_count), "row_count")
end
set_state (new_state: JSON_OBJECT)
do
Precursor (new_state)
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page")) as new_page then
if attached {JSON_NUMBER} new_state.item ("page") as new_page then
page := new_page.item.to_integer
end
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page_size")) as new_page_size then
if attached {JSON_NUMBER} new_state.item ("page_size") as new_page_size then
page_size := new_page_size.item.to_integer
end
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("row_count")) as new_row_count then
if attached {JSON_NUMBER} new_state.item ("row_count") as new_row_count then
row_count := new_row_count.item.to_integer
end
end

View File

@@ -40,12 +40,12 @@ feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
if Current.control_name.is_equal (cname) then
if event.is_equal ("next") then
if Current.control_name.same_string (cname) then
if event.same_string ("next") then
datasource.set_page (datasource.page + 1)
elseif event.is_equal ("prev") then
elseif event.same_string ("prev") then
datasource.set_page (datasource.page - 1)
elseif event.is_equal ("goto") then
elseif event.same_string ("goto") then
if attached event_parameter as p and then attached p.to_integer as i then
datasource.set_page (i)
end

View File

@@ -40,7 +40,7 @@ feature -- State
state: JSON_OBJECT
do
Result := Precursor {WSF_INPUT_CONTROL}
Result.put (create {JSON_STRING}.make_json (template), create {JSON_STRING}.make_json ("template"))
Result.put (create {JSON_STRING}.make_json (template), "template")
end
feature -- Callback
@@ -48,8 +48,8 @@ feature -- Callback
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
if cname.is_equal (control_name) and event.is_equal ("autocomplete") then
state_changes.put (create_json_list.item ([text]), create {JSON_STRING}.make_json ("suggestions"))
if cname.same_string (control_name) and event.same_string ("autocomplete") then
state_changes.put (create_json_list.item ([text]), "suggestions")
end
end

View File

@@ -28,7 +28,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
set_state (new_state: JSON_OBJECT)
-- Restore text from json
do
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("text")) as new_text then
if attached {JSON_STRING} new_state.item ("text") as new_text then
text := new_text.unescaped_string_32
end
end
@@ -37,8 +37,8 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
-- Return state which contains the current text and if there is an event handle attached
do
create Result.make
Result.put (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
Result.put (create {JSON_STRING}.make_json (text), "text")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
end
feature --EVENT HANDLING
@@ -51,9 +51,9 @@ feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
if Current.control_name.is_equal (cname) and attached change_event as cevent then
if event.is_equal ("change") then
cevent.call ([])
if Current.control_name.same_string (cname) and attached change_event as cevent then
if event.same_string ("change") then
cevent.call (Void)
end
end
end
@@ -67,9 +67,9 @@ feature -- Implementation
set_text (t: STRING)
do
if not t.is_equal (text) then
if not t.same_string (text) then
text := t
state_changes.replace (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
end
end

View File

@@ -33,7 +33,7 @@ feature -- State handling
set_state (new_state: JSON_OBJECT)
do
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("progress")) as new_progress then
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
progress := new_progress.item.to_integer
end
end
@@ -48,8 +48,8 @@ feature -- Event handling
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
if cname.is_equal (control_name) and event.is_equal ("progress_fetch") then
state_changes.put (create {JSON_NUMBER}.make_integer (progress_value), create {JSON_STRING}.make_json ("progress"))
if cname.same_string (control_name) and event.same_string ("progress_fetch") then
state_changes.put (create {JSON_NUMBER}.make_integer (progress_value), "progress")
end
end
@@ -71,7 +71,7 @@ feature --Change progress
no_progress_source: not (attached progress_source)
do
progress := p
state_changes.put (create {JSON_NUMBER}.make_integer (progress), create {JSON_STRING}.make_json ("progress"))
state_changes.put (create {JSON_NUMBER}.make_integer (progress), "progress")
end
feature

View File

@@ -37,7 +37,7 @@ feature
state: JSON_OBJECT
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (max), create {JSON_STRING}.make_json ("max"))
Result.put (create {JSON_NUMBER}.make_integer (max), "max")
end
max: INTEGER

View File

@@ -37,7 +37,7 @@ feature
state: JSON_OBJECT
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (min), create {JSON_STRING}.make_json ("min"))
Result.put (create {JSON_NUMBER}.make_integer (min), "min")
end
min: INTEGER

View File

@@ -42,9 +42,9 @@ feature
state: JSON_OBJECT
do
create Result.make
Result.put (create {JSON_STRING}.make_json ("WSF_REGEXP_VALIDATOR"), create {JSON_STRING}.make_json ("name"))
Result.put (create {JSON_STRING}.make_json (regexp_string), create {JSON_STRING}.make_json ("expression"))
Result.put (create {JSON_STRING}.make_json (error), create {JSON_STRING}.make_json ("error"))
Result.put (create {JSON_STRING}.make_json ("WSF_REGEXP_VALIDATOR"), "name")
Result.put (create {JSON_STRING}.make_json (regexp_string), "expression")
Result.put (create {JSON_STRING}.make_json (error), "error")
end
regexp_string: STRING

View File

@@ -19,8 +19,8 @@ feature
state: JSON_OBJECT
do
create Result.make
Result.put (create {JSON_STRING}.make_json (generator), create {JSON_STRING}.make_json ("name"))
Result.put (create {JSON_STRING}.make_json (error), create {JSON_STRING}.make_json ("error"))
Result.put (create {JSON_STRING}.make_json (generator), "name")
Result.put (create {JSON_STRING}.make_json (error), "error")
end
is_valid (input: G): BOOLEAN

View File

@@ -29,7 +29,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
set_state (new_state: JSON_OBJECT)
-- Restore text from json
do
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("text")) as new_text then
if attached {JSON_STRING} new_state.item ("text") as new_text then
text := new_text.unescaped_string_32
end
end
@@ -38,8 +38,8 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
-- Return state which contains the current text and if there is an event handle attached
do
create Result.make
Result.put (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), create {JSON_STRING}.make_json ("callback_click"))
Result.put (create {JSON_STRING}.make_json (text), "text")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), "callback_click")
end
feature --EVENT HANDLING
@@ -52,8 +52,8 @@ feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
if Current.control_name.is_equal (cname) and attached click_event as cevent then
cevent.call ([])
if Current.control_name.same_string (cname) and attached click_event as cevent then
cevent.call (Void)
end
end
@@ -66,9 +66,9 @@ feature
set_text (t: STRING)
do
if not t.is_equal (text) then
if not t.same_string (text) then
text := t
state_changes.replace (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
end
end

View File

@@ -128,7 +128,7 @@ feature -- Validation
set_error (e: STRING)
do
error := e
state_changes.replace (create {JSON_STRING}.make_json (e), create {JSON_STRING}.make_json ("error"))
state_changes.replace (create {JSON_STRING}.make_json (e), "error")
end
validate

View File

@@ -27,7 +27,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
set_state (new_state: JSON_OBJECT)
-- Restore html from json
do
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("html")) as new_html then
if attached {JSON_STRING} new_state.item ("html") as new_html then
html := new_html.unescaped_string_32
end
end
@@ -36,7 +36,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
-- Return state which contains the current html and if there is an event handle attached
do
create Result.make
Result.put (create {JSON_STRING}.make_json (html), create {JSON_STRING}.make_json ("html"))
Result.put (create {JSON_STRING}.make_json (html), "html")
end
feature --EVENT HANDLING
@@ -54,9 +54,9 @@ feature -- Implementation
set_html (t: STRING)
do
if not t.is_equal (html) then
if not t.same_string (html) then
html := t
state_changes.replace (create {JSON_STRING}.make_json (html), create {JSON_STRING}.make_json ("html"))
state_changes.replace (create {JSON_STRING}.make_json (html), "html")
end
end