From: Colin A. <col...@go...> - 2008-04-21 14:17:23
|
Here is the functional version. It should be straight-forward to change it to a creation procedure. Note that it is liberal on the memory creation of l_bytes, to avoid any resizing of this buffer. utf8_string (a_string: STRING_GENERAL): UC_UTF8_STRING is -- UTF-8 encoded version of `a_string' require a_string_not_void: a_string /= Void local i: INTEGER_32 l_bytes: STRING do create l_bytes.make (a_string.count * 4) from i := 1 until i > a_string.count loop utf8.append_code_to_utf8 (l_bytes, a_string.code (i).as_integer_32) i := i + 1 end create Result.make_from_utf8 (l_bytes) ensure utf8_string_not_void: Result /= Void correct_count: Result.count = a_string.count strings_equal: True -- can't be checked as STRING_GENERAL and UC_STRING lack the facilities (`for_all') end |
From: Eric B. <er...@go...> - 2008-04-21 14:38:53
|
Colin Adams wrote: > Here is the functional version. It should be straight-forward to > change it to a creation procedure. > > Note that it is liberal on the memory creation of l_bytes, to avoid > any resizing of this buffer. In fact having it as creation procedure will allow us to avoid having to create the intermediary object `l_bytes'. After looking at class UC_STRING, I'm wondering whether we should just adapt the routines `make_from_string' and `make_from_substring' so that we can pass a STRING_GENERAL. Perhaps we will have to rename the version of `make_from_string' inherited from STRING. Or add `make_from_string_general', `make_from_substring_general', make `make_from_substring' obsolete (make it call `make_from_substring_general') and modify `make_from_string' to call `make_from_string_general'. I'm not sure what the best naming convention is. -- Eric Bezault mailto:er...@go... http://www.gobosoft.com |
From: Colin A. <col...@go...> - 2008-04-22 19:37:50
|
On 21/04/2008, Eric Bezault <er...@go...> wrote: > In fact having it as creation procedure will allow us to avoid > having to create the intermediary object `l_bytes'. > > After looking at class UC_STRING, I'm wondering whether we should > just adapt the routines `make_from_string' and `make_from_substring' > so that we can pass a STRING_GENERAL. Perhaps we will have to We could do that, as we have the is_string_8 query to choose between the current implementation and the STRING_32 one. > rename the version of `make_from_string' inherited from STRING. > Or add `make_from_string_general', `make_from_substring_general', > make `make_from_substring' obsolete (make it call > `make_from_substring_general') and modify `make_from_string' > to call `make_from_string_general'. I'm not sure what the best > naming convention is. I don't think we need to rename anything. |
From: Eric B. <er...@go...> - 2008-04-22 20:32:31
|
Colin Adams wrote: > On 21/04/2008, Eric Bezault <er...@go...> wrote: >> In fact having it as creation procedure will allow us to avoid >> having to create the intermediary object `l_bytes'. >> >> After looking at class UC_STRING, I'm wondering whether we should >> just adapt the routines `make_from_string' and `make_from_substring' >> so that we can pass a STRING_GENERAL. Perhaps we will have to > > We could do that, as we have the is_string_8 query to choose between > the current implementation and the STRING_32 one. We don't need `is_string_8'. We just need to use STRING_GENERAL.code. >> rename the version of `make_from_string' inherited from STRING. >> Or add `make_from_string_general', `make_from_substring_general', >> make `make_from_substring' obsolete (make it call >> `make_from_substring_general') and modify `make_from_string' >> to call `make_from_string_general'. I'm not sure what the best >> naming convention is. > > I don't think we need to rename anything. We do: `make_from_string' is inherited from STRING with an argument of type STRING. We cannot redefine it to accept an argument of type STRING_GENERAL. -- Eric Bezault mailto:er...@go... http://www.gobosoft.com |
From: Colin A. <col...@go...> - 2008-04-29 08:56:27
|
On 21/04/2008, Eric Bezault <er...@go...> wrote: > After looking at class UC_STRING, I'm wondering whether we should > just adapt the routines `make_from_string' and `make_from_substring' > so that we can pass a STRING_GENERAL. Perhaps we will have to > rename the version of `make_from_string' inherited from STRING. > Or add `make_from_string_general', `make_from_substring_general', > make `make_from_substring' obsolete (make it call > `make_from_substring_general') and modify `make_from_string' > to call `make_from_string_general'. I'm not sure what the best > naming convention is. I think the last suggestion (adding make_from_string_general and changing make_from_string to call make_from_string_general, etc.) is best. |
From: Colin A. <col...@go...> - 2008-05-17 18:37:37
|
2008/4/29 Colin Adams <col...@go...>: > On 21/04/2008, Eric Bezault <er...@go...> wrote: > >> After looking at class UC_STRING, I'm wondering whether we should >> just adapt the routines `make_from_string' and `make_from_substring' >> so that we can pass a STRING_GENERAL. Perhaps we will have to >> rename the version of `make_from_string' inherited from STRING. >> Or add `make_from_string_general', `make_from_substring_general', >> make `make_from_substring' obsolete (make it call >> `make_from_substring_general') and modify `make_from_string' >> to call `make_from_string_general'. I'm not sure what the best >> naming convention is. > > I think the last suggestion (adding make_from_string_general and > changing make_from_string to call make_from_string_general, etc.) is > best. > Shall we do this then? I've just this minute encountered the need for it. |
From: Colin A. <col...@go...> - 2008-05-18 07:09:58
|
I've had a change of heart on this. I've just created READABLE_STRING, as an ancestor of STRING_GENERAL. I've put this into the Gobo version of Free_ELKS, and done test_debug_ge in $GOBO/test. All tests pass. I then did the same thing for ISE 6.2.7.3489, and it looks like all the tests for that will pass to. So later today, I will post these amended classes to the Free ELKS list, (after patching my current efforts towards ST_STRING with the changes, and checking the tests for that pass too), and if they are accepted, then we can have make_from_readable_string instead. 2008/5/17 Colin Adams <col...@go...>: > 2008/4/29 Colin Adams <col...@go...>: >> On 21/04/2008, Eric Bezault <er...@go...> wrote: >> >>> After looking at class UC_STRING, I'm wondering whether we should >>> just adapt the routines `make_from_string' and `make_from_substring' >>> so that we can pass a STRING_GENERAL. Perhaps we will have to >>> rename the version of `make_from_string' inherited from STRING. >>> Or add `make_from_string_general', `make_from_substring_general', >>> make `make_from_substring' obsolete (make it call >>> `make_from_substring_general') and modify `make_from_string' >>> to call `make_from_string_general'. I'm not sure what the best >>> naming convention is. >> >> I think the last suggestion (adding make_from_string_general and >> changing make_from_string to call make_from_string_general, etc.) is >> best. >> > > Shall we do this then? > > I've just this minute encountered the need for it. > |
From: Eric B. <er...@go...> - 2008-05-19 08:17:39
|
Colin Adams wrote: > 2008/4/29 Colin Adams <col...@go...>: >> On 21/04/2008, Eric Bezault <er...@go...> wrote: >> >>> After looking at class UC_STRING, I'm wondering whether we should >>> just adapt the routines `make_from_string' and `make_from_substring' >>> so that we can pass a STRING_GENERAL. Perhaps we will have to >>> rename the version of `make_from_string' inherited from STRING. >>> Or add `make_from_string_general', `make_from_substring_general', >>> make `make_from_substring' obsolete (make it call >>> `make_from_substring_general') and modify `make_from_string' >>> to call `make_from_string_general'. I'm not sure what the best >>> naming convention is. >> I think the last suggestion (adding make_from_string_general and >> changing make_from_string to call make_from_string_general, etc.) is >> best. >> > > Shall we do this then? > > I've just this minute encountered the need for it. I just added `make_from_string_general' in UC_STRING. It should be easy to make it accept READABLE_STRING by just replacing any occurrence of STRING_GENERAL by READABLE_STRING in classes UC_STRING and UC_UTF8_ROUTINES. -- Eric Bezault mailto:er...@go... http://www.gobosoft.com |