Esempio n. 1
0
File: sfs.c Progetto: awest/racket
Scheme_Object *scheme_sfs_add_clears(Scheme_Object *expr, Scheme_Object *clears, int pre)
{
  int len, i;
  Scheme_Object *loc;
  Scheme_Sequence *s;

  if (SCHEME_NULLP(clears))
    return expr;

  len = scheme_list_length(clears);

  s = scheme_malloc_sequence(len + 1);
  s->so.type = (pre ? scheme_sequence_type : scheme_begin0_sequence_type);
  s->count = len + 1;
  s->array[pre ? len : 0] = expr;

  for (i = 0; i < len; i++) {
    loc = scheme_make_local(scheme_local_type,
                            SCHEME_INT_VAL(SCHEME_CAR(clears)),
                            SCHEME_LOCAL_CLEAR_ON_READ);
    s->array[i + (pre ? 0 : 1)] = loc;
    clears = SCHEME_CDR(clears);    
  }

  return (Scheme_Object *)s;
}
Esempio n. 2
0
GVariant *
scheme_obj_to_gvariant (Scheme_Object *list)
{
 
  GVariant *rvalue;
  Scheme_Object *firstelement;
  int length;
  long i;
  char* rstring;
  double rdouble;

  rvalue = NULL; 
  length = scheme_list_length (list);
  if (length == 0)
    {
      return rvalue ;
    }  
  
  else if (length == 1)
    {
      // Get the first element of the argument
      firstelement = scheme_car (list);
 
      // checking the scheme_type to see whether it is an integer or not
      // Eventually see if we can convert this to a switch statement.
      if (SCHEME_TYPE (firstelement)== scheme_integer_type)
	{
	  // we saved the return value at &i
	  scheme_get_int_val (list,&i);
	  // we concert it to g_variant
          rvalue = g_variant_new ("(i)", i);
	  return rvalue;
	} // if it's an integer
      else if (SCHEME_TYPE (firstelement) == scheme_char_type)
	{
	  //getting the string out of the scheme_object
	  rstring = SCHEME_BYTE_STR_VAL(list);
	  // we will convert it to g_variant
	  rvalue = g_variant_new_string(rstring);
	  return rvalue;
	} // if it's a character
      else if (SCHEME_TYPE (firstelement) == scheme_double_type)
	{
	  //getting the double out of the scheme_object
	  rdouble = scheme_real_to_double(list);
	  // we will convert it to g_variant
	  rvalue = g_variant_new_double(rdouble);
	  return rvalue;
	} // if it's a double
    } // if we have a single element
 
  return rvalue;
} // scheme_obj_to_gvariant
Esempio n. 3
0
/**
 *Translating the scheme_object to gvariant type for the client
 *This step is used on sending input values onto the DBus
 */
GVariant *
scheme_obj_to_gvariant (Scheme_Object *list)
{
  GVariantBuilder *builder;
  GVariant *finalr;
  GVariant *rvalue = NULL;
  Scheme_Object *firstelement;
  int length = 0;
  gint32 i;
  char* rstring;
  double rdouble;
  
  builder = g_variant_builder_new(G_VARIANT_TYPE_TUPLE);
  length = scheme_list_length (list);
  // rvalue = g_new(GVariant *, length);

  if (length == 0)
    {
      //  scheme_signal_error("length 0");
      return rvalue ;
    }  // if
  else{
    while (length != 0)
      {
	// Get the first element of the argument
	firstelement = scheme_car (list);
	list = scheme_cdr(list);
	length = scheme_list_length(list);
	// checking the scheme_type to see whether it is an integer or not
	// Eventually see if we can convert this to a switch statement.
	if (SCHEME_INTP (firstelement))
	  {
	    // we saved the return value at &i
	     i = SCHEME_INT_VAL(firstelement); 
	     rvalue = g_variant_new ("i",i);
	     g_variant_builder_add_value(builder,rvalue);
	    // return rvalue;
	  } // if it's an integer
	else if (SCHEME_BYTE_STRINGP (firstelement)|| SCHEME_CHAR_STRINGP(firstelement))
	  {
	    //scheme_signal_error ("We are in Character");
	    //getting the string out of the scheme_object
	    rstring = SCHEME_BYTE_STR_VAL(list);
	    // we will convert it to g_variant
	    rvalue = g_variant_new ("(&s)", rstring);
            g_variant_builder_add_value(builder, rvalue);
	  } // if it's a character
	else if (SCHEME_TYPE (firstelement) == scheme_double_type)
	  {
	    //getting the double out of the scheme_object
	    rdouble = scheme_real_to_double(list);
	    // we will convert it to g_variant
	    rvalue = g_variant_new_double(rdouble);
	    g_variant_builder_add_value(builder, rvalue);
	  } // if it's a double
      } // while loop
 
    finalr = g_variant_builder_end (builder);
    return finalr;
  } //else
  return finalr;
} // scheme_obj_to_gvariant