Enlightenment CVS committal
Author : mej
Project : eterm
Module : libast
Dir : eterm/libast/include/libast
Modified Files:
array.h avl_tree.h dlinked_list.h iterator_if.h linked_list.h
list_if.h obj.h regexp.h socket.h str.h tok.h types.h.in url.h
vector_if.h
Log Message:
Thu Oct 30 18:12:35 2003 Michael Jennings (mej)
Added support for object "properties." A property is a member
variable with corresponding get/set methods.
I'll probably flesh this out more as I use it more.
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/array.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- array.h 19 Feb 2003 21:10:20 -0000 1.6
+++ array.h 30 Oct 2003 23:13:53 -0000 1.7
@@ -30,7 +30,7 @@
#define SPIF_ARRAY_ISNULL(o) (SPIF_ARRAY(o) == SPIF_NULL_TYPE(array))
#define SPIF_OBJ_IS_ARRAY(o) (SPIF_OBJ_IS_TYPE((o), array))
-SPIF_DEFINE_OBJ(array) {
+SPIF_DECL_OBJ(array) {
SPIF_DECL_PARENT_TYPE(obj);
size_t len;
spif_obj_t *items;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/avl_tree.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- avl_tree.h 3 Jul 2003 19:27:46 -0000 1.3
+++ avl_tree.h 30 Oct 2003 23:13:53 -0000 1.4
@@ -35,13 +35,13 @@
#define SPIF_AVL_TREE_NODE_ISNULL(o) (SPIF_AVL_TREE_NODE(o) ==
SPIF_NULL_TYPE(avl_tree_node))
#define SPIF_OBJ_IS_AVL_TREE_NODE(o) (SPIF_OBJ_IS_TYPE((o), avl_tree_node))
-SPIF_DEFINE_OBJ(avl_tree_node) {
+SPIF_DECL_OBJ(avl_tree_node) {
spif_obj_t data;
spif_int8_t balance;
spif_avl_tree_node_t left, right;
};
-SPIF_DEFINE_OBJ(avl_tree) {
+SPIF_DECL_OBJ(avl_tree) {
SPIF_DECL_PARENT_TYPE(obj);
size_t len;
spif_avl_tree_node_t root;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/dlinked_list.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- dlinked_list.h 3 Jul 2003 19:27:46 -0000 1.6
+++ dlinked_list.h 30 Oct 2003 23:13:53 -0000 1.7
@@ -31,12 +31,12 @@
#define SPIF_DLINKED_LIST_ITEM_ISNULL(o) (SPIF_DLINKED_LIST_ITEM(o) ==
SPIF_NULL_TYPE(dlinked_list_item))
#define SPIF_OBJ_IS_DLINKED_LIST_ITEM(o) (SPIF_OBJ_IS_TYPE((o),
dlinked_list_item))
-SPIF_DEFINE_OBJ(dlinked_list_item) {
+SPIF_DECL_OBJ(dlinked_list_item) {
spif_obj_t data;
spif_dlinked_list_item_t prev, next;
};
-SPIF_DEFINE_OBJ(dlinked_list) {
+SPIF_DECL_OBJ(dlinked_list) {
SPIF_DECL_PARENT_TYPE(obj);
size_t len;
spif_dlinked_list_item_t head, tail;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/iterator_if.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- iterator_if.h 20 Feb 2003 05:44:45 -0000 1.1
+++ iterator_if.h 30 Oct 2003 23:13:53 -0000 1.2
@@ -59,7 +59,7 @@
typedef spif_obj_t spif_iterator_t;
-SPIF_DEFINE_OBJ(iteratorclass) {
+SPIF_DECL_OBJ(iteratorclass) {
SPIF_DECL_PARENT_TYPE(class);
spif_func_t has_next;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/linked_list.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- linked_list.h 3 Jul 2003 19:27:46 -0000 1.7
+++ linked_list.h 30 Oct 2003 23:13:53 -0000 1.8
@@ -35,12 +35,12 @@
#define SPIF_LINKED_LIST_ITEM_ISNULL(o) (SPIF_LINKED_LIST_ITEM(o) ==
SPIF_NULL_TYPE(linked_list_item))
#define SPIF_OBJ_IS_LINKED_LIST_ITEM(o) (SPIF_OBJ_IS_TYPE((o),
linked_list_item))
-SPIF_DEFINE_OBJ(linked_list_item) {
+SPIF_DECL_OBJ(linked_list_item) {
spif_obj_t data;
spif_linked_list_item_t next;
};
-SPIF_DEFINE_OBJ(linked_list) {
+SPIF_DECL_OBJ(linked_list) {
SPIF_DECL_PARENT_TYPE(obj);
size_t len;
spif_linked_list_item_t head;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/list_if.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- list_if.h 19 Feb 2003 21:10:25 -0000 1.9
+++ list_if.h 30 Oct 2003 23:13:53 -0000 1.10
@@ -72,7 +72,7 @@
typedef spif_obj_t spif_list_t;
-SPIF_DEFINE_OBJ(listclass) {
+SPIF_DECL_OBJ(listclass) {
SPIF_DECL_PARENT_TYPE(class);
spif_func_t append;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/obj.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- obj.h 9 Jul 2003 23:49:47 -0000 1.18
+++ obj.h 30 Oct 2003 23:13:53 -0000 1.19
@@ -45,19 +45,19 @@
* help prevent its direct use. Obviously the translation is plainly
* visible, so those sufficiently determined to do it the Wrong Way
* still can. This macro is not used directly, but rather as part of
- * the SPIF_DEFINE_OBJ() macro (see below), which is in turn used to
+ * the SPIF_DECL_OBJ() macro (see below), which is in turn used to
* define object types.
*
* @param t The object type as a non-quoted string (e.g., obj).
* @return The @c struct keyword followed by the structure name for
* the specified object type.
*
- * @see DOXGRP_OBJ, SPIF_DEFINE_OBJ(), SPIF_DEFINE_TYPE()
+ * @see DOXGRP_OBJ, SPIF_DECL_OBJ(), SPIF_DECL_TYPE()
*/
-#define SPIF_DECL_OBJ_STRUCT(t) struct spif_ ## t ## _t_struct
+#define SPIF_DECL_OBJ_STRUCT(t) struct spif_ ## t ## _t_struct
/**
- * Define an object type based on the structure definition immediately
+ * Declare an object type based on the structure definition immediately
* following.
*
* This macro simplifies the creation of a new class by adding the
@@ -71,17 +71,17 @@
* @param t The object type as a non-quoted string (e.g., obj).
* @return An appropriate @c typedef and @c struct introducer.
*
- * @see DOXGRP_OBJ, SPIF_DEFINE_TYPE(), SPIF_DECL_OBJ_STRUCT()
+ * @see DOXGRP_OBJ, SPIF_DECL_TYPE(), SPIF_DECL_OBJ_STRUCT()
*/
-#define SPIF_DEFINE_OBJ(t) SPIF_DEFINE_TYPE(t,
SPIF_DECL_OBJ_STRUCT(t)); SPIF_DECL_OBJ_STRUCT(t)
+#define SPIF_DECL_OBJ(t) SPIF_DECL_TYPE(t, SPIF_DECL_OBJ_STRUCT(t));
SPIF_DECL_OBJ_STRUCT(t)
/**
* Declare the parent type of an object being defined.
*
* This macro is used to declare that a particular object type (e.g.,
* obj) is the parent type of an object which is being defined via
- * SPIF_DEFINE_OBJ(). The call to this macro should @em immediately
+ * SPIF_DECL_OBJ(). The call to this macro should @em immediately
* follow the opening brace (which, in turn, immediately follows the
- * call to SPIF_DEFINE_OBJ()). Declaring the parent type allows for
+ * call to SPIF_DECL_OBJ()). Declaring the parent type allows for
* safe typecasting of any object of the current type to its parent
* type (or any parent type in its "family tree"). At minimum, any
* true object must at @em least be derived from the @c obj type so
@@ -91,7 +91,7 @@
*
* @see DOXGRP_OBJ, SPIF_CONST_TYPE()
*/
-#define SPIF_DECL_PARENT_TYPE(t) SPIF_CONST_TYPE(t) parent
+#define SPIF_DECL_PARENT_TYPE(t) SPIF_CONST_TYPE(t) parent
/**
* Declare the class variable for objects of a given type.
@@ -106,7 +106,117 @@
*
* @see DOXGRP_OBJ
*/
-#define SPIF_CLASS_VAR(type) spif_ ## type ## _class
+#define SPIF_CLASS_VAR(type) spif_ ## type ## _class
+
+/**
+ * Declare a "property" of an object.
+ *
+ * This macro is used when declaring a class to specify that a
+ * particular class object is a "property." A "property" is an object
+ * member which has public get/set methods of the same name.
+ *
+ * @param type The type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ
+ */
+#define SPIF_DECL_PROPERTY(type, name) SPIF_TYPE(type) name
+
+/**
+ * Declare a "property" of an object.
+ *
+ * This macro is identical to SPIF_DECL_PROPERTY(), except that a
+ * native C type is used.
+ *
+ * @param type The C type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ, SPIF_DECL_PROPERTY()
+ */
+#define SPIF_DECL_PROPERTY_C(type, name) type name
+
+/**
+ * Declare the get/set methods of a "property" of an object.
+ *
+ * This macro is used to prototype the get/set methods of an object
+ * property.
+ *
+ * @param otype The type of the object.
+ * @param vtype The type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ
+ */
+#define SPIF_DECL_PROPERTY_FUNC(otype, vtype, name) \
+ extern SPIF_TYPE(vtype) spif_ ## otype ## _get_ ## name (SPIF_TYPE(otype)); \
+ extern SPIF_TYPE(bool) spif_ ## otype ## _set_ ## name (SPIF_TYPE(otype),
SPIF_TYPE(vtype))
+
+/**
+ * Declare the get/set methods of a "property" of an object.
+ *
+ * This macro is identical to SPIF_DECL_PROPERTY_FUNC(), except that a
+ * native C type is used.
+ *
+ * @param otype The type of the object.
+ * @param vtype The C type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ, SPIF_DECL_PROPERTY_FUNC()
+ */
+#define SPIF_DECL_PROPERTY_FUNC_C(otype, vtype, name) \
+ extern vtype spif_ ## otype ## _get_ ## name (SPIF_TYPE(otype)); \
+ extern SPIF_TYPE(bool) spif_ ## otype ## _set_ ## name (SPIF_TYPE(otype), vtype)
+
+/**
+ * Define the get/set methods of a "property" of an object.
+ *
+ * This macro is used to define (i.e., create, i.e. insert the code
+ * for) the get/set methods of an object property.
+ *
+ * @param otype The type of the object.
+ * @param vtype The type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ
+ */
+#define SPIF_DEFINE_PROPERTY_FUNC(otype, vtype, name) \
+ SPIF_TYPE(vtype) spif_ ## otype ## _get_ ## name (SPIF_TYPE(otype) self) \
+ { return ((SPIF_OBJ_IS_TYPE(self, otype)) ? (self-> ## name) :
(SPIF_NULL_TYPE(vtype))); } \
+ SPIF_TYPE(bool) spif_ ## otype ## _set_ ## name (SPIF_TYPE(otype) self,
SPIF_TYPE(vtype) new_ ## name) \
+ { \
+ if (!SPIF_OBJ_IS_TYPE(self, otype)) { \
+ return FALSE; \
+ } \
+ if (!SPIF_OBJ_ISNULL(self-> ## name)) { \
+ SPIF_OBJ_DEL(self-> ## name); \
+ } \
+ self-> ## name = new_ ## name; \
+ return TRUE; \
+ }
+
+/**
+ * Define the get/set methods of a "property" of an object.
+ *
+ * This macro is used to define (i.e., create, i.e. insert the code
+ * for) the get/set methods of an object property.
+ *
+ * @param otype The type of the object.
+ * @param vtype The C type of the property variable.
+ * @param name The name of the property.
+ *
+ * @see DOXGRP_OBJ, SPIF_DEFINE_PROPERTY_FUNC()
+ */
+#define SPIF_DEFINE_PROPERTY_FUNC_C(otype, vtype, name) \
+ vtype spif_ ## otype ## _get_ ## name (SPIF_TYPE(otype) self) \
+ { return ((SPIF_OBJ_IS_TYPE(self, otype)) ? (self->name) :
(SPIF_NULL_TYPE_C(vtype))); } \
+ SPIF_TYPE(bool) spif_ ## otype ## _set_ ## name (SPIF_TYPE(otype) self, vtype new_
## name) \
+ { \
+ if (!SPIF_OBJ_IS_TYPE(self, otype)) { \
+ return FALSE; \
+ } \
+ self->name = new_ ## name; \
+ return TRUE; \
+ }
/[EMAIL PROTECTED]/
/[EMAIL PROTECTED]/
@@ -530,7 +640,7 @@
*
* This class contains the object class structure.
*/
-SPIF_DEFINE_OBJ(class) {
+SPIF_DECL_OBJ(class) {
/** Text representation of class name. */
spif_classname_t classname;
@@ -548,8 +658,8 @@
/* An obj is the most basic object type. It contains simply a pointer to
the class name (a const char * so you can test it with ==). */
-SPIF_DEFINE_OBJ(obj) {
- spif_class_t cls;
+SPIF_DECL_OBJ(obj) {
+ spif_class_t cls;
};
/[EMAIL PROTECTED]/
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/regexp.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- regexp.h 19 Feb 2003 21:10:27 -0000 1.3
+++ regexp.h 30 Oct 2003 23:13:53 -0000 1.4
@@ -42,7 +42,7 @@
#define SPIF_REGEXP_DUP(obj) SPIF_OBJ_DUP(obj)
#define SPIF_REGEXP_TYPE(obj) SPIF_OBJ_TYPE(obj)
-SPIF_DEFINE_OBJ(regexp) {
+SPIF_DECL_OBJ(regexp) {
SPIF_DECL_PARENT_TYPE(str);
spif_ptr_t data;
int flags;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/socket.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- socket.h 19 Feb 2003 21:10:28 -0000 1.9
+++ socket.h 30 Oct 2003 23:13:53 -0000 1.10
@@ -68,7 +68,7 @@
#include <libast/url.h>
-SPIF_DEFINE_OBJ(socket) {
+SPIF_DECL_OBJ(socket) {
SPIF_DECL_PARENT_TYPE(obj);
spif_sockfd_t fd;
spif_sockfamily_t fam;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/str.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- str.h 30 Oct 2003 21:04:05 -0000 1.14
+++ str.h 30 Oct 2003 23:13:53 -0000 1.15
@@ -41,10 +41,11 @@
? (SPIF_CAST(charptr)
"") \
: (SPIF_STR(obj)->s)))
-SPIF_DEFINE_OBJ(str) {
+SPIF_DECL_OBJ(str) {
SPIF_DECL_PARENT_TYPE(obj);
spif_charptr_t s;
- size_t mem, len;
+ SPIF_DECL_PROPERTY_C(size_t, size);
+ SPIF_DECL_PROPERTY_C(size_t, len);
};
extern spif_class_t SPIF_CLASS_VAR(str);
@@ -87,10 +88,8 @@
extern spif_bool_t spif_str_splice(spif_str_t, size_t, size_t, spif_str_t);
extern spif_bool_t spif_str_splice_from_ptr(spif_str_t, size_t, size_t,
spif_charptr_t);
extern spif_bool_t spif_str_reverse(spif_str_t);
-extern size_t spif_str_get_size(spif_str_t);
-extern spif_bool_t spif_str_set_size(spif_str_t, size_t);
-extern size_t spif_str_get_len(spif_str_t);
-extern spif_bool_t spif_str_set_len(spif_str_t, size_t);
+SPIF_DECL_PROPERTY_FUNC_C(str, size_t, size);
+SPIF_DECL_PROPERTY_FUNC_C(str, size_t, len);
extern spif_str_t spif_str_show(spif_str_t, spif_charptr_t, spif_str_t, size_t);
extern spif_classname_t spif_str_type(spif_str_t);
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/tok.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- tok.h 19 Feb 2003 21:10:29 -0000 1.8
+++ tok.h 30 Oct 2003 23:13:53 -0000 1.9
@@ -48,7 +48,7 @@
/* An tok object is a string tokenizer */
-SPIF_DEFINE_OBJ(tok) {
+SPIF_DECL_OBJ(tok) {
SPIF_DECL_PARENT_TYPE(obj);
spif_str_t src;
spif_char_t quote, dquote, escape;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/types.h.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- types.h.in 9 Jul 2003 23:49:47 -0000 1.10
+++ types.h.in 30 Oct 2003 23:13:53 -0000 1.11
@@ -141,7 +141,7 @@
*
* @see DOXGRP_TYPES
*/
-#define SPIF_DEFINE_TYPE(t, u) typedef u SPIF_CONST_TYPE(t); typedef
SPIF_CONST_TYPE(t) * SPIF_TYPE(t)
+#define SPIF_DECL_TYPE(t, u) typedef u SPIF_CONST_TYPE(t); typedef
SPIF_CONST_TYPE(t) * SPIF_TYPE(t)
/[EMAIL PROTECTED]/
/[EMAIL PROTECTED]/
@@ -315,7 +315,7 @@
*
* @see DOXGRP_TYPES, SPIF_CAST_C()
*/
-#define SPIF_NULL_CTYPE(type) (SPIF_CAST_C(type) (NULL))
+#define SPIF_NULL_TYPE_C(type) (SPIF_CAST_C(type) (NULL))
/**
* Returns a string representing a NULL value of the specified base
@@ -347,7 +347,7 @@
*
* @see DOXGRP_TYPES
*/
-#define SPIF_NULLSTR_CTYPE(type) "{ ((" #type ") NULL) }"
+#define SPIF_NULLSTR_TYPE_C(type) "{ ((" #type ") NULL) }"
/[EMAIL PROTECTED]/
/[EMAIL PROTECTED]/
@@ -591,7 +591,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(sockaddr, struct sockaddr);
+SPIF_DECL_TYPE(sockaddr, struct sockaddr);
/**
* A socket address for the IPv4 protocol family.
@@ -602,7 +602,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(ipsockaddr, struct sockaddr_in);
+SPIF_DECL_TYPE(ipsockaddr, struct sockaddr_in);
/**
* A socket address for the UNIX protocol family.
@@ -613,7 +613,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(unixsockaddr, struct sockaddr_un);
+SPIF_DECL_TYPE(unixsockaddr, struct sockaddr_un);
/**
* An IPv4 address.
@@ -623,7 +623,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(ipaddr, struct in_addr);
+SPIF_DECL_TYPE(ipaddr, struct in_addr);
/**
* Host information.
@@ -633,7 +633,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(hostinfo, struct hostent);
+SPIF_DECL_TYPE(hostinfo, struct hostent);
/**
* Protocol information.
@@ -643,7 +643,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(protoinfo, struct protoent);
+SPIF_DECL_TYPE(protoinfo, struct protoent);
/**
* Service information.
@@ -653,7 +653,7 @@
*
* @see DOXGRP_TYPES
*/
-SPIF_DEFINE_TYPE(servinfo, struct servent);
+SPIF_DECL_TYPE(servinfo, struct servent);
/**
* The file descriptor for a socket.
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/url.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- url.h 19 Feb 2003 21:10:30 -0000 1.6
+++ url.h 30 Oct 2003 23:13:53 -0000 1.7
@@ -44,7 +44,7 @@
#define SPIF_URL_TYPE(o) SPIF_OBJ_TYPE(o)
-SPIF_DEFINE_OBJ(url) {
+SPIF_DECL_OBJ(url) {
SPIF_DECL_PARENT_TYPE(str);
spif_str_t proto;
spif_str_t user, passwd;
===================================================================
RCS file: /cvsroot/enlightenment/eterm/libast/include/libast/vector_if.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- vector_if.h 19 Feb 2003 21:10:30 -0000 1.2
+++ vector_if.h 30 Oct 2003 23:13:53 -0000 1.3
@@ -65,7 +65,7 @@
typedef spif_obj_t spif_vector_t;
-SPIF_DEFINE_OBJ(vectorclass) {
+SPIF_DECL_OBJ(vectorclass) {
SPIF_DECL_PARENT_TYPE(class);
spif_func_t contains;
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs