Esempio n. 1
0
/*! \brief Get a smob for a schematic object.
 * \ingroup guile_c_iface
 * \par Function Description
 * Create a new smob representing \a object.
 *
 * \warning The returned smob is initially marked as owned by the C
 *   code. If it should be permitted to be garbage-collected, you
 *   should set the garbage-collectable flag by calling:
 *
 * \code
 *   SCM x = edascm_from_object (object);
 *   edascm_c_set_gc (x, 1);
 * \endcode
 *
 * \note We currently have to bake a TOPLEVEL pointer into the smob,
 * so that if the object becomes garbage-collectable we can obtain a
 * TOPLEVEL to use for deleting the smob without accessing the
 * TOPLEVEL fluid and potentially causing a race condition (see bug
 * 909358).
 *
 * \param object #OBJECT to create a smob for.
 * \return a smob representing \a object.
 */
SCM
edascm_from_object (OBJECT *object)
{
  SCM smob;
  TOPLEVEL *toplevel = edascm_c_current_toplevel ();

  SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel);
  SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT);

  /* Set weak references */
  s_object_weak_ref (object, smob_weakref_notify, smob);
  s_toplevel_weak_ref (toplevel, smob_weakref2_notify, smob);

  return smob;
}
Esempio n. 2
0
/*! \brief Get a smob for a schematic object.
 * \ingroup guile_c_iface
 * \par Function Description
 * Create a new smob representing \a object.
 *
 * \warning The returned smob is initially marked as owned by the C
 *   code. If it should be permitted to be garbage-collected, you
 *   should set the garbage-collectable flag by calling:
 *
 * \code
 *   SCM x = edascm_from_object (object);
 *   edascm_c_set_gc (x, 1);
 * \endcode
 *
 * \note We currently have to bake a TOPLEVEL pointer into the smob,
 * so that if the object becomes garbage-collectable we can obtain a
 * TOPLEVEL to use for deleting the smob without accessing the
 * TOPLEVEL fluid and potentially causing a race condition (see bug
 * 909358).
 *
 * \param object #OBJECT to create a smob for.
 * \return a smob representing \a object.
 */
SCM
edascm_from_object (OBJECT *object)
{
  SCM smob = smob_cache_lookup (object);

  if (EDASCM_OBJECTP (smob)) {
    return smob;
  }

  TOPLEVEL *toplevel = edascm_c_current_toplevel ();

  SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel);
  SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT);

  /* Set weak references */
  s_object_weak_ref (object, smob_weakref2_notify,
                     unpack_as_pointer (smob));

  smob_cache_add (object, smob);

  return smob;
}
Esempio n. 3
0
/* still highly temp and doesn't work right */
SCM g_get_toplevel_attribute(SCM scm_wanted_attrib)
{
  const GList *p_iter;
  PAGE *p_current;
  char *wanted_attrib;
  char *attrib_value = NULL;
  SCM scm_return_value;
  TOPLEVEL *toplevel = edascm_c_current_toplevel ();

  SCM_ASSERT(scm_is_string (scm_wanted_attrib),
             scm_wanted_attrib, SCM_ARG1, "gnetlist:get-toplevel-attribute");

  wanted_attrib = scm_to_utf8_string (scm_wanted_attrib);

  for (p_iter = geda_list_get_glist (toplevel->pages); p_iter != NULL;
       p_iter = g_list_next (p_iter)) {
    p_current = p_iter->data;

    /* only look for first occurrance of the attribute on each page */
    attrib_value =
      o_attrib_search_floating_attribs_by_name (s_page_objects (p_current),
                                                wanted_attrib, 0);

    /* Stop when we find the first one */
    if (attrib_value != NULL)
      break;
  }

  free (wanted_attrib);

  if (attrib_value != NULL) {
    scm_return_value = scm_from_utf8_string (attrib_value);
    g_free (attrib_value);
  } else {
    scm_return_value = scm_from_utf8_string ("not found");
  }

  return (scm_return_value);
}
Esempio n. 4
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
SCM g_funcs_postscript(SCM scm_filename)
{
  char *filename;
  TOPLEVEL *toplevel = edascm_c_current_toplevel ();

  SCM_ASSERT (scm_is_string (scm_filename), scm_filename,
              SCM_ARG1, "gschem-postscript");

  if (output_filename) {
    if (f_print_file (toplevel, toplevel->page_current,
                      output_filename))
      return SCM_BOOL_F;
  } else  {
    filename = scm_to_utf8_string(scm_filename);
    if (f_print_file (toplevel, toplevel->page_current, filename)) {
      free(filename);
      return SCM_BOOL_F;
    }
    free(filename);
  }
  
  return SCM_BOOL_T;
}
Esempio n. 5
0
SCM_SYMBOL (edascm_string_format_sym , "string-format");

/*! \brief Get a of open pages.
 * \par Function Description
 * Retrieves a Scheme list of currently-opened pages.
 *
 * \note Scheme API: Implements the %active-pages procedure of the
 * (geda core page) module.
 *
 * \return a Scheme list of #PAGE smobs.
 */
SCM_DEFINE (active_pages, "%active-pages", 0, 0, 0,
            (), "Retrieve a list of currently-opened pages")
{
    TOPLEVEL *toplevel = edascm_c_current_toplevel ();
    SCM lst = SCM_EOL;
    SCM rlst;
    GList *page_list = geda_list_get_glist (toplevel->pages);

    while (page_list != NULL) {
        lst = scm_cons (edascm_from_page (page_list->data), lst);
        page_list = g_list_next (page_list);
    }

    rlst = scm_reverse (lst);
    scm_remember_upto_here_1 (lst);
    return rlst;
}

/*! \brief Create a new page.
Esempio n. 6
0
 * Creates a new, empty complex object, with the given \a basename and
 * with all other parameters set to default values.  It is initially set
 * to be embedded.
 *
 * \note Scheme API: Implements the %make-complex procedure in the
 * (geda core complex) module.
 *
 * \return a newly-created complex object.
 */
SCM_DEFINE (make_complex, "%make-complex", 1, 0, 0,
            (SCM basename_s), "Create a new complex object.")
{
  SCM_ASSERT (scm_is_string (basename_s), basename_s, SCM_ARG1, s_make_complex);

  char *tmp = scm_to_utf8_string (basename_s);
  OBJECT *obj = o_complex_new_embedded (edascm_c_current_toplevel (),
                                        OBJ_COMPLEX, DEFAULT_COLOR, 0, 0, 0,
                                        FALSE, tmp, TRUE);
  free (tmp);

  SCM result = edascm_from_object (obj);

  /* At the moment, the only pointer to the object is owned by the
   * smob. */
  edascm_c_set_gc (result, TRUE);

  return result;
}

/*! \brief Instantiate a complex object from the component library.
 * \par Function Description
Esempio n. 7
0
    /* Initialise the hashtable which contains the visit
       count. N.b. no free functions are required. */
    visit_table = g_hash_table_new (g_direct_hash,
                                    g_direct_equal);
}

SCM_DEFINE (traverse, "%traverse", 1, 0, 0,
            (SCM netlist_mode), "Traverse hierarchy.")
{
  TOPLEVEL *pr_current;
  GList *iter;
  PAGE *p_current;

  s_traverse_init ();

  pr_current = edascm_c_current_toplevel ();

  for ( iter = geda_list_get_glist( pr_current->pages );
        iter != NULL;
        iter = g_list_next( iter ) ) {

    p_current = (PAGE *)iter->data;

    /* only traverse pages which are toplevel, ie not underneath */
    if (p_current->page_control == 0) {
      pr_current->page_current = p_current;
      s_traverse_sheet (pr_current, s_page_objects (p_current), NULL);
    }
  }

  /* now that all the sheets have been read, go through and do the */