webmcp
annotate framework/env/convert/to_human.lua @ 11:d76a8857ba62
Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
| author | jbe/bsw |
|---|---|
| date | Fri Feb 12 18:40:22 2010 +0100 (2010-02-12) |
| parents | 9fdfb27f8e67 |
| children |
| rev | line source |
|---|---|
| jbe/bsw@0 | 1 function convert.to_human(value, typ) |
| jbe/bsw@0 | 2 if value == nil then return "" end -- TODO: is this correct? |
| jbe/bsw@0 | 3 if typ and not atom.has_type(value, typ) then |
| jbe/bsw@0 | 4 error("The value passed to convert.to_human(...) has not the specified type.") |
| jbe/bsw@0 | 5 end |
| jbe/bsw@0 | 6 local type_symbol |
| jbe/bsw@0 | 7 local value_type = type(value) |
| jbe/bsw@0 | 8 if value_type ~= "table" and value_type ~= "userdata" then |
| jbe/bsw@0 | 9 type_symbol = value_type |
| jbe/bsw@0 | 10 else |
| jbe/bsw@0 | 11 type_symbol = convert._type_symbol_mappings[getmetatable(value)] |
| jbe/bsw@0 | 12 end |
| jbe/bsw@0 | 13 if not type_symbol then |
| jbe/bsw@0 | 14 error("Unrecognized type reference occurred in convert.to_human(...).") |
| jbe/bsw@0 | 15 end |
| jbe/bsw@0 | 16 local converter = convert["_from_" .. type_symbol .. "_to_human"] |
| jbe/bsw@0 | 17 if not converter then |
| jbe/bsw@0 | 18 error("Type reference in convert.from_human(...) could be recognized, but the converter function is not existent.") |
| jbe/bsw@0 | 19 end |
| jbe/bsw@0 | 20 return converter(value) |
| jbe/bsw@0 | 21 end |