Lucifers,
Let's continue the Clownfish API review and have a look at the Blob and
ByteBuf classes.
Blob_compare and ByteBuf_compare can probably go away.
Then I'd like to rework the Mimic method:
void Mimic(ByteBuf *self, Obj *other);
First of all, I'd split it into separate methods for each parameter type:
void Mimic(ByteBuf *self, ByteBuf *other);
void Mimic_Blob(ByteBuf *self, Blob *blob);
void Mimic_String(ByteBuf *self, String *string);
For reasons of symmetry, I'd make the set of Cat methods match the set of
Mimic methods.
void Mimic(ByteBuf *self, ByteBuf *other);
void Mimic_Bytes(ByteBuf *self, const void *bytes, size_t size);
void Mimic_Blob(ByteBuf *self, Blob *blob);
void Mimic_String(ByteBuf *self, String *string);
void Cat(ByteBuf *self, ByteBuf *other);
void Cat_Bytes(ByteBuf *self, const void *bytes, size_t size);
void Cat_Blob(ByteBuf *self, Blob *blob);
void Cat_String(ByteBuf *self, String *string);
Then we should think about whether we need all these methods. The Mimic
methods are essentially just a shortcut for Set_Size(0) followed by Cat. Cat_*
can also be replaced with Cat_Bytes. For example, instead of BB_Mimic(self,
other) one could write:
BB_Set_Size(self, 0);
BB_Cat_Bytes(self, BB_Get_Buf(other), BB_Get_Size(other));
Lucy makes little use of these methods, so it's hard to tell which ones are
the most useful.
Also, I always found the name "Mimic" a bit weird. What about Assign and
Assign_Bytes?
Finally, the ByteBuf class and all of its methods can be made public.
Nick