Enlightenment CVS committal Author : mej Project : eterm Module : libast
Dir : eterm/libast/include/libast Modified Files: Makefile.am obj.h str.h types.h.in Added Files: mbuff.h Log Message: Tue Dec 14 17:51:20 2004 Michael Jennings (mej) More work from my vacation. Turned the string class into both an interface and an implementation, and created a new multipurpose buffer class (untested) for arbitrary text/binary data. (Think "strings with embedded newlines" if that helps.) Now, if someone were so inclined, (s)he could create a LibAST implementation of the "str" interface based on glib strings, or QStrings, or whatever with almost no changes to the code using the libast string API (once the function calls like spif_str_new() are replaced with macro calls like SPIF_STR_NEW()). A UTF-8-based string implementation is forthcoming. ---------------------------------------------------------------------- =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- Makefile.am 23 Feb 2004 21:47:28 -0000 1.16 +++ Makefile.am 15 Dec 2004 00:00:21 -0000 1.17 @@ -1,13 +1,13 @@ # $Id: Makefile.am,v 1.6 2001/09/22 16:25:29 mej Exp $ EXTRA_HEADERS = array.h avl_tree.h dlinked_list.h iterator_if.h \ -linked_list.h list_if.h map_if.h obj.h objpair.h regexp.h socket.h \ -str.h sysdefs.h tok.h types.h url.h vector_if.h +linked_list.h list_if.h map_if.h mbuff.h obj.h objpair.h regexp.h \ +socket.h str.h sysdefs.h tok.h types.h url.h vector_if.h install-exec-hook: $(mkinstalldirs) $(DESTDIR)$(includedir)/$(PACKAGE) for i in $(EXTRA_HEADERS) ; do \ - $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/$(PACKAGE)/ ; \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/$(PACKAGE)/ ; \ done EXTRA_DIST = $(EXTRA_HEADERS) sysdefs.h.in types.h.in =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/obj.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- obj.h 16 Jul 2004 23:22:18 -0000 1.29 +++ obj.h 15 Dec 2004 00:00:21 -0000 1.30 @@ -33,8 +33,8 @@ * manipulating basic generic objects. * * @author Michael Jennings <[EMAIL PROTECTED]> - * $Revision: 1.29 $ - * $Date: 2004/07/16 23:22:18 $ + * $Revision: 1.30 $ + * $Date: 2004/12/15 00:00:21 $ */ /[EMAIL PROTECTED]/ @@ -385,7 +385,7 @@ * @see @link DOXGRP_OBJ LibAST Object Infrastructure @endlink, SPIF_OBJ_ISNULL(), SPIF_OBJ_CLASS(), * SPIF_CLASS_VAR(), SPIF_OBJ_CHECK_TYPE() */ -#define SPIF_OBJ_IS_TYPE(o, type) ((!SPIF_OBJ_ISNULL(o)) && (SPIF_OBJ_CLASS(o) == SPIF_CLASS_VAR(type))) +#define SPIF_OBJ_IS_TYPE(o, type) ((!SPIF_OBJ_ISNULL(o)) && (SPIF_OBJ_CLASS(o) == SPIF_CLASS(SPIF_CLASS_VAR(type)))) /** * Provide debugging assertion that an object is of a given type. =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/str.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- str.h 10 Mar 2004 22:07:31 -0000 1.19 +++ str.h 15 Dec 2004 00:00:21 -0000 1.20 @@ -24,9 +24,12 @@ #ifndef _LIBAST_STR_H_ #define _LIBAST_STR_H_ -#define SPIF_STR(obj) ((spif_str_t) (obj)) -#define SPIF_OBJ_IS_STR(obj) (SPIF_OBJ_IS_TYPE(obj, str)) -#define SPIF_STR_ISNULL(s) SPIF_OBJ_ISNULL(SPIF_OBJ(s)) +#define SPIF_STR(obj) ((spif_str_t) (obj)) +#define SPIF_STR_CLASS(o) (SPIF_CAST(strclass) SPIF_OBJ_CLASS(o)) +#define SPIF_OBJ_IS_STR(o) (SPIF_OBJ_IS_TYPE(o, str)) +#define SPIF_STR_ISNULL(s) SPIF_OBJ_ISNULL(SPIF_OBJ(s)) +#define SPIF_STRCLASS_VAR(type) spif_ ## type ## _strclass +#define SPIF_STR_CALL_METHOD(o, meth) SPIF_STR_CLASS(o)->meth #define SPIF_STR_NEW(type) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->noo()) #define SPIF_STR_INIT(obj) SPIF_OBJ_INIT(obj) @@ -37,10 +40,50 @@ #define SPIF_STR_DUP(obj) SPIF_OBJ_DUP(obj) #define SPIF_STR_TYPE(obj) SPIF_OBJ_TYPE(obj) -#define SPIF_STR_STR(obj) (SPIF_CONST_CAST(charptr) ((SPIF_STR_ISNULL(obj)) \ - ? (SPIF_CAST(charptr) "") \ - : (SPIF_STR(obj)->s))) -typedef spif_int32_t spif_stridx_t; +#define SPIF_STR_NEW_FROM_PTR(type, p) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->new_from_ptr)(p)) +#define SPIF_STR_NEW_FROM_BUFF(type, b, s) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->new_from_buff)(b, s)) +#define SPIF_STR_NEW_FROM_FP(type, fp) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->new_from_fp)(fp)) +#define SPIF_STR_NEW_FROM_FD(type, fd) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->new_from_fd)(fd)) +#define SPIF_STR_NEW_FROM_NUM(type, num) SPIF_STR((SPIF_CLASS(SPIF_CLASS_VAR(type)))->new_from_num)(num)) +#define SPIF_STR_INIT_FROM_PTR(o, p) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), init_from_ptr)(o, p)) +#define SPIF_STR_INIT_FROM_BUFF(o, b, s) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), init_from_buff)(o, b, s)) +#define SPIF_STR_INIT_FROM_FP(o, fp) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), init_from_fp)(o, fp)) +#define SPIF_STR_INIT_FROM_FD(o, fd) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), init_from_fd)(o, fd)) +#define SPIF_STR_INIT_FROM_NUM(o, num) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), init_from_num)(o, num)) +#define SPIF_STR_APPEND(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), append)(o, x)) +#define SPIF_STR_APPEND_CHAR(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), append_char)(o, x)) +#define SPIF_STR_APPEND_FROM_PTR(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), append_from_ptr)(o, x)) +#define SPIF_STR_CASECMP(o, x) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), casecmp)(o, x)) +#define SPIF_STR_CASECMP_WITH_PTR(o, x) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), casecmp_with_ptr)(o, x)) +#define SPIF_STR_CLEAR(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), clear)(o, x)) +#define SPIF_STR_CMP(o, x) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), cmp)(o, x)) +#define SPIF_STR_CMP_WITH_PTR(o, x) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), cmp_with_ptr)(o, x)) +#define SPIF_STR_DOWNCASE(o) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), downcase)(o)) +#define SPIF_STR_FIND(o, x) SPIF_CAST(stridx) (SPIF_STR_CALL_METHOD((o), find)(o, x)) +#define SPIF_STR_FIND_FROM_PTR(o, x) SPIF_CAST(stridx) (SPIF_STR_CALL_METHOD((o), find_from_ptr)(o, x)) +#define SPIF_STR_INDEX(o, x) SPIF_CAST(stridx) (SPIF_STR_CALL_METHOD((o), index)(o, x)) +#define SPIF_STR_NCASECMP(o, x, n) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), ncasecmp)(o, x, n)) +#define SPIF_STR_NCASECMP_WITH_PTR(o, x, n) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), ncasecmp_with_ptr)(o, x, n)) +#define SPIF_STR_NCMP(o, x, n) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), ncmp)(o, x, n)) +#define SPIF_STR_NCMP_WITH_PTR(o, x, n) SPIF_CAST(cmp) (SPIF_STR_CALL_METHOD((o), ncmp_with_ptr)(o, x, n)) +#define SPIF_STR_PREPEND(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), prepend)(o, x)) +#define SPIF_STR_PREPEND_CHAR(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), prepend_char)(o, x)) +#define SPIF_STR_PREPEND_FROM_PTR(o, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), prepend_from_ptr)(o, x)) +#define SPIF_STR_REVERSE(o) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), reverse)(o)) +#define SPIF_STR_RINDEX(o, x) SPIF_CAST(stridx) (SPIF_STR_CALL_METHOD((o), rindex)(o, x)) +#define SPIF_STR_SPLICE(o, n1, n2, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), splice)(o, n1, n2, x)) +#define SPIF_STR_SPLICE_FROM_PTR(o, n1, n2, x) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), splice_from_ptr)(o, n1, n2, x)) +#define SPIF_STR_SUBSTR(o, n1, n2) SPIF_CAST(str) (SPIF_STR_CALL_METHOD((o), substr)(o, n1, n2)) +#define SPIF_STR_SUBSTR_TO_PTR(o, n1, n2) SPIF_CAST(charptr) (SPIF_STR_CALL_METHOD((o), substr_to_ptr)(o, n1, n2)) +#define SPIF_STR_TO_FLOAT(o) SPIF_CAST_C(double) (SPIF_STR_CALL_METHOD((o), to_float)(o)) +#define SPIF_STR_TO_NUM(o, x) SPIF_CAST_C(size_t) (SPIF_STR_CALL_METHOD((o), to_num)(o, x)) +#define SPIF_STR_TRIM(o) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), trim)(o)) +#define SPIF_STR_UPCASE(o) SPIF_CAST(bool) (SPIF_STR_CALL_METHOD((o), upcase)(o)) + +#define SPIF_STR_STR(obj) (SPIF_CONST_CAST(charptr) ((SPIF_STR_ISNULL(obj)) \ + ? (SPIF_CAST(charptr) "") \ + : (SPIF_STR(obj)->s))) +typedef spif_int64_t spif_stridx_t; SPIF_DECL_OBJ(str) { SPIF_DECL_PARENT_TYPE(obj); @@ -49,7 +92,52 @@ SPIF_DECL_PROPERTY_C(spif_stridx_t, len); }; +SPIF_DECL_OBJ(strclass) { + SPIF_DECL_PARENT_TYPE(class); + + spif_func_t new_from_ptr; + spif_func_t new_from_buff; + spif_func_t new_from_fp; + spif_func_t new_from_fd; + spif_func_t new_from_num; + spif_func_t init_from_ptr; + spif_func_t init_from_buff; + spif_func_t init_from_fp; + spif_func_t init_from_fd; + spif_func_t init_from_num; + spif_func_t append; + spif_func_t append_char; + spif_func_t append_from_ptr; + spif_func_t casecmp; + spif_func_t casecmp_with_ptr; + spif_func_t clear; + spif_func_t cmp; + spif_func_t cmp_with_ptr; + spif_func_t downcase; + spif_func_t find; + spif_func_t find_from_ptr; + spif_func_t index; + spif_func_t ncasecmp; + spif_func_t ncasecmp_with_ptr; + spif_func_t ncmp; + spif_func_t ncmp_with_ptr; + spif_func_t prepend; + spif_func_t prepend_char; + spif_func_t prepend_from_ptr; + spif_func_t reverse; + spif_func_t rindex; + spif_func_t splice; + spif_func_t splice_from_ptr; + spif_func_t substr; + spif_func_t substr_to_ptr; + spif_func_t to_float; + spif_func_t to_num; + spif_func_t trim; + spif_func_t upcase; +}; + extern spif_class_t SPIF_CLASS_VAR(str); +extern spif_strclass_t SPIF_STRCLASS_VAR(str); extern spif_str_t spif_str_new(void); extern spif_str_t spif_str_new_from_ptr(spif_charptr_t); extern spif_str_t spif_str_new_from_buff(spif_charptr_t, spif_stridx_t); =================================================================== RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/types.h.in,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- types.h.in 22 Jul 2004 02:49:50 -0000 1.21 +++ types.h.in 15 Dec 2004 00:00:21 -0000 1.22 @@ -580,6 +580,15 @@ typedef spif_char_t *spif_charptr_t; /** + * A pointer to a byte of data. + * + * A pointer to a byte of data. + * + * @see @link DOXGRP_TYPES Portable Data Types @endlink + */ +typedef spif_uint8_t *spif_byteptr_t; + +/** * A generic, untyped pointer. * * A generic, untyped pointer. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs