[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: g_smob.nw



  User: cnieves 
  Date: 06/02/25 10:01:01

  Modified:    .        g_smob.nw s_color.nw
  Log:
  Added some text autoplacing hooks and related functions.
  
  
  
  
  Revision  Changes    Path
  1.10      +224 -6    eda/geda/devel/libgeda/noweb/g_smob.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_smob.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/g_smob.nw,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- g_smob.nw	14 Feb 2005 02:17:36 -0000	1.9
  +++ g_smob.nw	25 Feb 2006 15:01:01 -0000	1.10
  @@ -19,6 +19,16 @@
   <<g_smob.c : g_set_attrib_value_internal()>>
   <<g_smob.c : g_init_attrib_smob()>>
   
  +<<g_smob.c : g_free_object_smob()>>
  +<<g_smob.c : g_print_object_smob()>>
  +<<g_smob.c : g_make_object_smob()>>
  +<<g_smob.c : g_get_object_attributes()>>
  +<<g_smob.c : g_init_object_smob()>>
  +/*
  +<<g_smob.c : g_get_object_from_object_smob()>>
  +<<g_smob.c : g_get_toplevel_from_object_smob()>>
  +*/
  +<<g_smob.c : g_get_data_from_object_smob()>>
   @ 
   
   
  @@ -73,6 +83,7 @@
   
   <<g_smob.c : global variables>>=
   static long attrib_smob_tag;
  +static long object_smob_tag;
   
   @ %def attrib_smob_tag
   
  @@ -80,6 +91,7 @@
   @section Function @code{g_free_attrib_smob()}
   
   @defun g_free_attrib_smob attrib_smob
  +Free the memory allocated by the [[attribute smob]] and returns its size.
   @end defun
   
   <<g_smob.c : g_free_attrib_smob()>>=
  @@ -100,6 +112,7 @@
   @section Function @code{g_print_attrib_smob()}
   
   @defun g_print_attrib_smob attrib_smob port pstate
  +This function prints the given [[attribute smob]] to the [[port]]. It just prints a string showing it is an attribute and its string.
   @end defun
   
   <<g_smob.c : g_print_attrib_smob()>>=
  @@ -109,9 +122,6 @@
     struct st_attrib_smob *attribute = 
     (struct st_attrib_smob *)SCM_CDR(attrib_smob);
   
  -  /* I don't think this is valid, because C does not support this sort
  -   * of evaluation, it will eval ALL the statements unlike pascal which
  -   * will stop after the first FALSE -Ales */	
     if (attribute &&
         attribute->attribute &&
         attribute->attribute->object &&
  @@ -133,6 +143,7 @@
   @section Function @code{g_make_attrib_smob()}
   
   @defun g_make_attrib_smob curr_w curr_attr
  +Creates and returns a new attribute smob, based on the given TOPLEVEL [[curr_w]] and attribute [[curr_attr]].
   @end defun
   
   <<g_smob.c : g_make_attrib_smob()>>=
  @@ -158,6 +169,7 @@
   @section Function @code{g_get_attrib_name_value()}
   
   @defun g_get_attrib_name_value attrib_smob
  +Returns a list with the name and value of the given [[attribute smob]].
   @end defun
   
   <<g_smob.c : g_get_attrib_name_value()>>=
  @@ -169,9 +181,8 @@
     char *value = NULL;
     SCM returned = SCM_EOL;
   
  -
     SCM_ASSERT ( SCM_NIMP(attrib_smob) && 
  -               (SCM_CAR(attrib_smob) == attrib_smob_tag),
  +               ((long) SCM_CAR(attrib_smob) == attrib_smob_tag),
                  attrib_smob, SCM_ARG1, "get-attribute-name-value");
   
     attribute = (struct st_attrib_smob *)SCM_CDR(attrib_smob);
  @@ -197,6 +208,8 @@
   @section Function @code{g_set_attrib_value_internal()}
   
   @defun g_set_attrib_value_internal attrib_smob scm_value world o_attrib new_string
  +The return value is always SCM_UNDEFINED.
  +This function puts into a [[new string]] the [[attrib smob]] name and the new [[scm_value]] (attribute=value format). It also returns the [[TOPLEVEL]] and [[OBJECT]] pointers.
   @end defun
   
   <<g_smob.c : g_set_attrib_value_internal()>>=
  @@ -210,7 +223,7 @@
     char *old_value = NULL;
   
     SCM_ASSERT ( SCM_NIMP(attrib_smob) && 
  -               (SCM_CAR(attrib_smob) == attrib_smob_tag),
  +               ((long) SCM_CAR(attrib_smob) == attrib_smob_tag),
                  attrib_smob, SCM_ARG1, "set-attribute-value!");
     SCM_ASSERT ( SCM_NIMP(scm_value) && SCM_STRINGP(scm_value),
                  scm_value, SCM_ARG2, "set-attribute-value!");
  @@ -245,6 +258,7 @@
   @section Function @code{g_init_attrib_smob()}
   
   @defun g_init_attrib_smob
  +Initialize the framework to support an attrib smob.
   @end defun
   
   <<g_smob.c : g_init_attrib_smob()>>=
  @@ -263,3 +277,207 @@
   }
   
   @ %def g_init_attrib_smob
  +
  +
  +
  +@section Function @code{g_free_attrib_smob()}
  +
  +@defun g_free_object_smob object_smob
  +Free the memory allocated by the [[object smob]] and returns its size.
  +@end defun
  +
  +<<g_smob.c : g_free_object_smob()>>=
  +static scm_sizet
  +g_free_object_smob(SCM object_smob)
  +{
  +  struct st_object_smob *object = 
  +  (struct st_object_smob *)SCM_CDR(object_smob);
  +  scm_sizet size = sizeof(struct st_object_smob);
  +
  +  free(object);
  +  return size;
  +}
  +
  +@ %def g_free_object_smob
  +
  +@section Function @code{g_print_object_smob()}
  +
  +@defun g_print_object_smob object_smob port pstate
  +This function prints the given [[object smob]] to the [[port]]. It just prints a string showing it is an object and the object name.
  +@end defun
  +
  +<<g_smob.c : g_print_object_smob()>>=
  +static int
  +g_print_object_smob(SCM object_smob, SCM port, scm_print_state *pstate)
  +{
  +  struct st_object_smob *object = 
  +  (struct st_object_smob *)SCM_CDR(object_smob);
  +
  +  if (object &&
  +      object->object &&
  +      object->object->name) {
  +    scm_puts("#<object ", port);
  +    scm_display (scm_makfrom0str (object->object->name),
  +                 port);
  +    scm_puts(">", port);
  +  }
  +	
  +  /* non-zero means success */
  +  return 1;
  +}
  +
  +@ %def g_print_object_smob
  +
  +@section Function @code{g_make_object_smob()}
  +
  +@defun g_make_object_smob curr_w curr_attr
  +Creates and returns an [[object smob]] from the given TOPLEVEL\'s [[curr_w]] and [[object]] pointers.
  +@end defun
  +
  +<<g_smob.c : g_make_object_smob()>>=
  +/* Creates an object smob */
  +SCM
  +g_make_object_smob(TOPLEVEL *curr_w, OBJECT *object)
  +{
  +  struct st_object_smob *smob_object;
  +
  +  smob_object = (struct st_object_smob *)
  +    scm_must_malloc(sizeof(struct st_object_smob), "object");
  +
  +  smob_object->world  = curr_w;
  +  smob_object->object = object;
  +
  +  /* Assumes Guile version >= 1.3.2 */
  +  SCM_RETURN_NEWSMOB(object_smob_tag, smob_object);
  +}
  +
  +@ %def g_make_object_smob
  +
  +
  +@section Function @code{g_get_object_attributes()}
  +
  +@defun g_get_object_attributes object_smob
  +This function returns a list with all the attributes of the given [[object smob]].
  +@end defun
  +
  +<<g_smob.c : g_get_object_attributes()>>=
  +SCM
  +g_get_object_attributes(SCM object_smob)
  +{
  +  TOPLEVEL *w_current;
  +  struct st_object_smob *object;
  +  SCM returned = SCM_EOL;
  +
  +  SCM_ASSERT ( SCM_NIMP(object_smob) && 
  +               ((long) SCM_CAR(object_smob) == object_smob_tag),
  +               object_smob, SCM_ARG1, "get-object-attributes");
  +
  +  object = (struct st_object_smob *)SCM_CDR(object_smob);
  +
  +  if (object &&
  +      object->object) {
  +    ATTRIB *pointer;
  +    
  +    pointer = object->object->attribs;
  +    w_current = object->world;
  +    while (pointer != NULL) {
  +      if (pointer->object &&
  +	  pointer->object->text) {
  +	returned = scm_cons (g_make_attrib_smob (w_current, pointer), returned);
  +      }
  +      pointer = pointer->next;
  +    }     
  +  }
  +
  +  return returned;
  +}
  +
  +@ %def g_get_object_attributes
  +
  +
  +@section Function @code{g_init_object_smob()}
  +
  +@defun g_init_object_smob
  +Initialize the framework to support an object smob.
  +@end defun
  +
  +<<g_smob.c : g_init_object_smob()>>=
  +void
  +g_init_object_smob(void)
  +{
  +
  +  object_smob_tag = scm_make_smob_type("object", sizeof (struct st_object_smob));
  +  scm_set_smob_mark(object_smob_tag, 0);
  +  scm_set_smob_free(object_smob_tag, g_free_object_smob);
  +  scm_set_smob_print(object_smob_tag, g_print_object_smob);
  +
  +  scm_c_define_gsubr("get-object-attributes", 1, 0, 0, g_get_object_attributes);
  +
  +  return;
  +}
  +
  +@ %def g_init_object_smob
  +
  +@section Function @code{g_free_attrib_smob()}
  +
  +@defun g_get_object_from_object_smob object_smob
  +Gets the [[object]] data from the [[object smob]].
  +@end defun
  +
  +<<g_smob.c : g_get_object_from_object_smob()>>=
  +OBJECT *
  +g_get_object_from_object_smob(SCM object_smob)
  +{
  +  
  +  SCM_ASSERT ( SCM_NIMP(object_smob) && 
  +               (SCM_CAR(object_smob) == object_smob_tag),
  +               object_smob, SCM_ARG1, "get_object_from_object_smob");
  +  return ((OBJECT *) (((struct st_object_smob *)SCM_CDR(object_smob))->object));
  +}
  +
  +@ %def g_get_object_from_object_smob
  +
  +@defun g_get_object_from_object_smob object_smob
  +@end defun
  +
  +<<g_smob.c : g_get_toplevel_from_object_smob()>>=
  +TOPLEVEL *
  +g_get_toplevel_from_object_smob(SCM object_smob)
  +{
  +  
  +  SCM_ASSERT ( SCM_NIMP(object_smob) && 
  +               (SCM_CAR(object_smob) == object_smob_tag),
  +               object_smob, SCM_ARG1, "get_toplevel_from_object_smob");
  +  return ((TOPLEVEL *) (((struct st_object_smob *)SCM_CDR(object_smob))->world));
  +}
  +
  +@ %def g_get_toplevel_from_object_smob
  +
  +@defun g_get_data_from_object_smob object_smob
  +This function gets the [[toplevel]] and [[object]] data stored in an [[object_smob]].
  +It returns FALSE if the smob is not an object smob, and TRUE otherwise.
  +The pointers [[toplevel]] and [[object]] are used to return the data. If any of them is NULL, then it is just ignored.
  +@end defun
  +
  +<<g_smob.c : g_get_data_from_object_smob()>>=
  +gboolean
  +g_get_data_from_object_smob(SCM object_smob, TOPLEVEL **toplevel, 
  +                            OBJECT **object)
  +{
  +  
  +  if ( (!SCM_NIMP(object_smob)) || 
  +       ((long) SCM_CAR(object_smob) != object_smob_tag) ) {
  +    return(FALSE);
  +  }
  +  if (toplevel != NULL) {
  +    *toplevel = (TOPLEVEL *) 
  +    (((struct st_object_smob *)SCM_CDR(object_smob))->world);
  +  }
  +  if (object != NULL) {
  +    *object = (OBJECT *) 
  +    (((struct st_object_smob *)SCM_CDR(object_smob))->object);
  +  }
  +  return (TRUE);
  +}
  +
  +@ %def g_get_data_from_object_smob
  
  
  
  1.7       +32 -1     eda/geda/devel/libgeda/noweb/s_color.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: s_color.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/s_color.nw,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- s_color.nw	4 Feb 2005 22:37:06 -0000	1.6
  +++ s_color.nw	25 Feb 2006 15:01:01 -0000	1.7
  @@ -19,7 +19,7 @@
   <<s_color.c : s_color_image_int()>>
   <<s_color.c : s_color_gdcolor_init()>>
   <<s_color.c : s_color_get_name()>>
  -
  +<<s_color.c : s_color_get_index()>>
   @
   
   
  @@ -300,3 +300,34 @@
   
   @ %def s_color_get_name
   
  +
  +@section Function @code{s_color_get_index()}
  +
  +@defun s_color_get_index string
  +Returns the index of the given color name. 
  +Returns -1 if not found.
  +@end defun
  +
  +<<s_color.c : s_color_get_index()>>=
  +int
  +s_color_get_index(char *string)
  +{
  +  int index;
  +
  +  if (string == NULL) {
  +    return(-1);
  +  }
  +
  +  for (index = 0; index < MAX_COLORS; index++) {
  +    if (strcasecmp(string, colors[index].color_name) == 0) {
  +      return (index); 
  +    }
  +  }
  +
  +  /* If the color was not found, return -1 */
  +  return (-1);
  +
  +}
  +
  +
  +@ %def s_color_get_int