55
edits
mNo edit summary |
|||
| Line 11: | Line 11: | ||
# String APIs should be as close to SpiderMonkey string APIs as possible to make ActionMonkey implementation easy. | # String APIs should be as close to SpiderMonkey string APIs as possible to make ActionMonkey implementation easy. | ||
# Preferred access to characters is via a charAt() method that returns 32-bit characters regardless of the underlying implementation. Low level API strXX() are available for direct read-only buffer access if really needed. | # Preferred access to characters is via a charAt() method that returns 32-bit characters regardless of the underlying implementation. Low level API strXX() are available for direct read-only buffer access if really needed. | ||
# Integrators control which width is being used internally. If they only feed 16-bit data, or UTF-8 data with the desired width set to 16 bits, only 16-bit data will be used. There will be a compile-time flag that comments out code that deals with other widths that 16 bits. | |||
=== Tagged instance contents === | === Tagged instance contents === | ||
| Line 51: | Line 52: | ||
Getting a substring also flattens the source string. The substring is an instance that contains a pointer to the source string, and pointer to the start of the source string buffer. The length field contains the string length. This string is already flat, although it contains a reference to another string. It may be desirable to have a separate flattening function for this case, and for the the case of a "super-string" that an in-place concatenating operation created. | Getting a substring also flattens the source string. The substring is an instance that contains a pointer to the source string, and pointer to the start of the source string buffer. The length field contains the string length. This string is already flat, although it contains a reference to another string. It may be desirable to have a separate flattening function for this case, and for the the case of a "super-string" that an in-place concatenating operation created. | ||
When a string is flattened, its two String pointers are replaced with a flat data buffer. The resulting width of the string is determined by the widths of the strings in the tree. Usually, the resulting string width is the widest of all substrings found. If desired (with an #ifdef), substrings could also be analyzed if they are wider than the containing data, if e.g. a 16-bit strings only contains 8-bit characters. This is, of course, a performance hit, but may be desired if memory footprint is important. | When a string is flattened, its two String pointers are replaced with a flat data buffer. The resulting width of the string is determined by the widths of the strings in the tree. Usually, the resulting string width is the widest of all substrings found. If desired (with an #ifdef), substrings could also be analyzed if they are wider than the containing data, if e.g. a 16-bit strings only contains 8-bit characters. This is, of course, a performance hit, but may be desired if memory footprint is important, because flattening the concatenation of a, say, 8-bit string and a 16-bit string may result in a 8-bit string if the flattener is allowed to check the contents of the 16-bit string. | ||
=== Thread safety === | === Thread safety === | ||
edits