Ejemplo n.º 1
0
/*
 * Returns a list with coords of the ends of  the given pin <B>object</B>.
The list is ( (x0 y0) (x1 y1) ), where the beginning is at (x0,y0) and the end at (x1,y1).
The active connection end of the pin is the beginning, so this function cares about the whichend property of the pin object. If whichend is 1, then it has to reverse the ends.
 */
SCM g_get_pin_ends(SCM object)
{
    TOPLEVEL *toplevel;
    OBJECT *o_current;
    SCM coord1 = SCM_EOL;
    SCM coord2 = SCM_EOL;
    SCM coords = SCM_EOL;

    /* Get toplevel and o_current */
    SCM_ASSERT (g_get_data_from_object_smob (object, &toplevel, &o_current),
                object, SCM_ARG1, "get-pin-ends");

    /* Check that it is a pin object */
    SCM_ASSERT (o_current != NULL,
                object, SCM_ARG1, "get-pin-ends");
    SCM_ASSERT (o_current->type == OBJ_PIN,
                object, SCM_ARG1, "get-pin-ends");
    SCM_ASSERT (o_current->line != NULL,
                object, SCM_ARG1, "get-pin-ends");

    coord1 = scm_cons(scm_from_int(o_current->line->x[0]),
                      scm_from_int(o_current->line->y[0]));
    coord2 = scm_cons(scm_from_int(o_current->line->x[1]),
                      scm_from_int(o_current->line->y[1]));
    if (o_current->whichend == 0) {
        coords = scm_cons(coord1, scm_list(coord2));
    } else {
        coords = scm_cons(coord2, scm_list(coord1));
    }

    return coords;
}
Ejemplo n.º 2
0
ScmObj
ut_compile(ScmObj exp)
{
  ScmObj compile = SCM_OBJ_INIT, args = SCM_OBJ_INIT, val = SCM_OBJ_INIT;
  int r;

  SCM_REFSTK_INIT_REG(&exp,
                      &compile, &args, &val);

  r = scm_cached_global_var_ref(SCM_CACHED_GV_COMPILE, SCM_CSETTER_L(compile));
  if (r < 0) return SCM_OBJ_NULL;

  if (scm_obj_null_p(compile)) {
    scm_error("unbound variable: compile", 0);
    return SCM_OBJ_NULL;
  }

  args = scm_make_compiler(SCM_OBJ_NULL);
  if (scm_obj_null_p(args)) return SCM_OBJ_NULL;

  args = scm_list(2, exp, args);
  if (scm_obj_null_p(args)) return SCM_OBJ_NULL;

  val = scm_vm_apply(scm_current_vm(), compile, args);
  if (scm_obj_null_p(val)) return SCM_OBJ_NULL;

  return scm_vector_ref(val, 0);
}
Ejemplo n.º 3
0
static void
make_module(const char *n)
{
  module = name = undef;

  name = scm_make_symbol_from_cstr(n, SCM_ENC_ASCII);
  name = scm_list(1, name);
  module = scm_make_module(name);
}
Ejemplo n.º 4
0
static void
find_module(const char *n)
{
  module = name = undef;

  name = scm_make_symbol_from_cstr(n, SCM_ENC_ASCII);
  name = scm_list(1, name);
  TEST_ASSERT_EQUAL_INT(0, scm_find_module(name, SCM_CSETTER_L(module)));
}