JS:

refactor drill factor to cache field lookups

implement ObjectCodec.decode.bytes


C:

generate encode method
  enocde_objname(ptr, params...) => bytes

  * refactor so that encode always returns bytes used




--- DONE --------------

JS.DONE.

automatic length field. DONE.
assert that direct fields must have fixed sizes. DONE
support {} objects in ObjectCodec. DONE.
drill use fieldnames. DONE.
nullable pointed fields. DONE.
refactor drill to use factory pattern. DONE.
nullable fields in drill. DONE.
check that fields do not overlap... DONE
prevent buffer overflows.
  string out of bounds: DONE
  more tests DONE
test error messages for decoding object with out of bounds fields. DONE
prevent encoding value size that excedes possible representation in length value size. DONE

---
DOCS.DONE.

 - explain data structure. DONE
 - document the actual types not the datastructure I was thinking. DONE
check that the code actually matches the docs. DONE
separate DirectField and PointedField types. DONE
tests for integer encodes? DONE

implement fixed position variable size field. DONE
 - example of only fixed size first. DONE
refactor fpvsfields so that they are not such a hack. DONE

---
C:

C.DONE

C code
- write internal functions to read the types. DONE
- pseudo code to create macros to read object fields. DONE
- write js to generate c inline functions to read particular fields from an object. DONE

- get generated code compiling to wasm. DONE.
- run simplest wasm test. DONE
- generate decoder for array fields. DONE

- use for_each macro. index_of? DONE
- use for_each, but checks string content's equality. DONE
- starting tests for C code... using wasm? DONE

- can shrink allocation (partial free?) DONE
  - short answer: yes, but it may copy to new memory. also it may error.
    hmm, suspect it should never error you reallocate to smaller size

- clean up generated from test code. DONE

- encode via C ***
- get started encoding via C
  - write tests for getNext & decode.bytes
    - fixed size. DONE
    - variable size. DONE
    - single variable size. DONE
    - tidy up tests. DONE
  - refactor handling of end/length on length delimited objects. DONE


  - design handling of parameterized types. DONE.
    - way to use but returning a pointer. DONE
      - returns {type, pointer, length} DONE
      - use any with streaming. DONE
  - review documentation
    - describe
      * any. DONE
      * extentions to AbstractEncoding. DONE

  - rename everything to ltp. DONE
---

evaluate whats needed to port Anarchy to ipd

  - rpc protocol uses ltp.AnyPointer
  - refactor message/rpc (haha, actually the format probably wont change!)
    - move has two string arguments, so that gets relp now
    - FileStream methods get relp because filename isn't last paramater.
    - message.js can stay the same.
    - it would be better if create-protocol had field names.
    - rpc uses encode with an array, not object.
---






  AM I BEING CONSISTENT WITH LENGTH?
    * should it be a length (not including length of the length field)
    * or should it be a relative pointer to end?
    * or just the total length, including length field. note, same as relp->end if it is in 0 position

  - document streaming use.

  - review code to check what to do next.
  - streaming decoder for repeated message
  - streaming decoder with encoded type
  - efficient streaming decoder that reads length field where possible

- more array methods
-   question: should I regenerate array methods for an array field?
-   Question: what methods does Anarchy actually need?
      - Answer: only fs.list needs an array... but maximum number of files in a directory is 2^32 so it should be a stream anyway... if that a stream then _everything_ becomes fixed position. Or a stream.
- way to decode stream of records.
  (if they are fixed size, read each one, else they must have length field)
    - check if they are fixed size.
    - if fixed size, skip that many bytes
    - if has length field, read it, skip bytes
    - if not fixed size but has a single variable size field, use min size + variable size field

- benchmark to compare with bipf
    make schema for package.json, jump into dependencies, search for a particular dep.
    Ha! just realized that bipf does that and only has a single dep.

idea: encode map as array of key:value pairs, but sorted by key length then lexiographically
    reading length is a single read so gonna be much faster than checking each byte.
    on the other hand, unless there are long prefixes it probably doesn't matter so much.


review documentation

and what about checksums?


allow explicitly declared overlaps
any type

