www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17038] New: support for std.uni store / load trie entry table

https://issues.dlang.org/show_bug.cgi?id=17038

          Issue ID: 17038
           Summary: support for std.uni store / load trie entry table
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: remi.thebault gmail.com

Use case:
  - efficiently map a dchar to some unicode properties not supported in std.uni

example of workflow:
 - in a separate program:
    1. build a AA of the required mapping
    2. build a std.uni.Trie out of this AA (e.g. using std.uni.codepointTrie)
    3. store the trie entry tables in a generated D module

 - in the application/library code:
    4. rebuild the Trie from the entry tables.

Steps 1 to 3 are already supported by std.uni, though not documented (I had to
dive into std.uni code to understand how it must be done).

Step 4 is currently not directly feasible as the Trie ctor that take the entry
tables is private.

I could workaround by copying the following 'TrieEntry' struct and 'asTrie'
function in my own code (which still happen to call the private ctor, but both
dmd and ldc seem to accept it somehow)

struct TrieEntry(T...)
{
    size_t[] offsets;
    size_t[] sizes;
    size_t[] data;
}

 safe pure nothrow auto asTrie(T...)(in TrieEntry!T e)
{
    return const(CodepointTrie!T)(e.offsets, e.sizes, e.data);
}

--
Dec 28 2016