Example #1
0
_public_ int sd_bus_match_signal_async(
                sd_bus *bus,
                sd_bus_slot **ret,
                const char *sender,
                const char *path,
                const char *interface,
                const char *member,
                sd_bus_message_handler_t callback,
                sd_bus_message_handler_t install_callback,
                void *userdata) {

        const char *expression;

        assert_return(bus, -EINVAL);
        assert_return(bus = bus_resolve(bus), -ENOPKG);
        assert_return(!bus_pid_changed(bus), -ECHILD);
        assert_return(!sender || service_name_is_valid(sender), -EINVAL);
        assert_return(!path || object_path_is_valid(path), -EINVAL);
        assert_return(!interface || interface_name_is_valid(interface), -EINVAL);
        assert_return(!member || member_name_is_valid(member), -EINVAL);

        expression = make_expression(sender, path, interface, member);

        return sd_bus_add_match_async(bus, ret, expression, callback, install_callback, userdata);
}
Example #2
0
/* concurrent assignment   (a,b,c:=c-b,a-c,b-a)
** NR: number of variables   3
** ALIST: list of variables  a,b,c
** ELIST: expression leaving values on the stack c-b,a-c,b-a
*/
Expression *assign_expression(int nr, Argument *alist, Expression *elist)
{
    /* assignment is a special operator */
    Type *tlist;
    Type ct;
    int i;
    Expression *e1;
    if ((i=left_on_stack(elist)) != nr) return 0;
    tlist = type_of_expression(elist);
    for (i=0; i<nr; i++) {
	ct = get_type(alist[i]);
	if (IsConst(ct)) {
	    fprintf(stderr, "Unable to make assignments to constants.\n");
	    return 0;
	}
	if (!get_operator(tlist[i], OPASSIGN, NoRefType(ct))) {
	    fprintf(stderr, "Assignment not defined for %s:=%s.\n",
		    lookup_typename(ct), lookup_typename(tlist[i]));
	    return 0;
	}
    }
    i=nr;
    while (i) {
	i--;
	e1=make_expression(alist[i]);
	e1=combine_expression(elist, e1, OPASSIGN);
	if (!e1) return 0;
	elist=e1;
    }
    return elist;
}
Example #3
0
Expression *expression_call(Symbol *function, Expression *arguments)
{
  debug("Creating expression call for %s Type: %d", symbol_to_string(function), function->type->code);

  if ((function->type->code != TYPE_FUNCTION) && (function->type->code != TYPE_PROCEDURE))
    die("Symbol %s isn't a function or procedure", symbol_to_string(function));

  Expression *alt;
  Symbol *result = NULL;//If this is a function, it returns a value
  Tac *code;
  Tac *temp;

  if ((function->type->code == TYPE_FUNCTION) && (function->external == NULL))
    {
      //Create symbol for result, and declare variable
      result = make_temp();
      code = make_tac(TAC_VARIABLE, result, NULL, NULL);
    }
  else
    {
      code = make_tac(TAC_NOP, NULL, NULL, NULL);
    }

  //Connect up rest of arguments
  alt = arguments;
  while (alt != NULL)
    {
      code = join_tac(code, alt->tac);

      alt = alt->next;
    }

  //Generate argument instructions
  while (arguments != NULL)
    {
      temp = make_tac(TAC_ARG, arguments->result, NULL, NULL);
      temp->prev = code;
      code = temp;

      alt = arguments->next;
      free(arguments);
      arguments = alt;
    }

  //temp = make_label_tac(TAC_CALL, function->label, result);
  temp = make_tac(TAC_CALL, result, function, NULL);
  temp->prev = code;
  code = temp;

  return make_expression(NULL, result, code);
}
Example #4
0
/* callback -- set bs->exp to the expressions for a class in the dict */
static int exp_cb(void *user_data, int argc, char **argv, char **colName)
{
	cbdata* bs = user_data;

	assert(2 == argc, "Bad column count");
	assert(argv[0], "NULL column value");

	bs->exp = make_expression(bs->dict, argv[0]);

	if (bs->exp)
		bs->exp->cost = atof(argv[1]);

	return 0;
}
Example #5
0
static Exp * make_expression(Dictionary dict, const char *exp_str)
{
	Exp* e;
	Exp* and;
	Exp* rest;
	E_list *ell, *elr;

	char *constr = NULL;
	const char * p = exp_str;
	const char * con_start = NULL;

	/* search for the start of a conector */
	while (*p && (lg_isspace(*p) || '&' == *p)) p++;
	con_start = p;

	if (0 == *p) return NULL;

	/* search for the end of a conector */
	while (*p && (isalnum(*p) || '*' == *p)) p++;
		
	/* Connectors always end with a + or - */
	assert (('+' == *p) || ('-' == *p),
			"Missing direction character in connector string: %s", con_start);

	/* Create an expression to hold the connector */
	e = (Exp *) xalloc(sizeof(Exp));
	e->dir = *p;
	e->type = CONNECTOR_type;
	e->cost = 0.0;
	if ('@' == *con_start)
	{
		constr = strndup(con_start+1, p-con_start-1);
		e->multi = true;
	}
	else
	{
		constr = strndup(con_start, p-con_start);
		e->multi = false;
	}

	/* We have to use the string set, mostly because copy_Exp
	 * in build_disjuncts fails to copy the string ...
	 */
	e->u.string = string_set_add(constr, dict->string_set);
	free(constr);

	rest = make_expression(dict, ++p);
	if (NULL == rest)
		return e;

	/* Join it all together with an AND node */
	and = (Exp *) xalloc(sizeof(Exp));
	and->type = AND_type;
	and->cost = 0.0;
	and->u.l = ell = (E_list *) xalloc(sizeof(E_list));
	ell->next = elr = (E_list *) xalloc(sizeof(E_list));
	elr->next = NULL;

	ell->e = e;
	elr->e = rest;

	return and;
}
 expression bound_expr() { return bound_var ? make_expression(var == bound_var->var) : value_to_expression(true); }