Lines Matching defs:out
235 def out(format, *args, **kwargs):
240 # def out(format, *args, new_line=True)
275 out("")
276 out("/* invokes a handler with a '%s' DBus signature */", signature)
277 out("static int invoke_%s_method(struct sbus_request *dbus_req, void *function_ptr);", signature)
280 out("")
281 out("/* invokes a handler with a '%s' DBus signature */", signature)
282 out("static int invoke_%s_method(struct sbus_request *dbus_req, void *function_ptr)", signature)
283 out("{")
287 out(" %s *arg_%d;", arg.dbus_type, i)
288 out(" int len_%d;", i)
290 out(" %s arg_%d;", arg.dbus_type, i)
291 out(" int (*handler)(struct sbus_request *, void *%s) = function_ptr;", method_arg_types(args))
292 out("")
293 out(" if (!sbus_request_parse_or_finish(dbus_req,")
297 out(" DBUS_TYPE_ARRAY, %s, &arg_%d, &len_%d,",
300 out(" %s, &arg_%d,", arg.dbus_constant, i)
301 out(" DBUS_TYPE_INVALID)) {")
302 out(" return EOK; /* request handled */")
303 out(" }")
304 out("")
306 out(" return (handler)(dbus_req, dbus_req->intf->handler_data", new_line=False)
309 out(",\n arg_%d", i, new_line=False)
311 out(",\n len_%d", i, new_line=False)
312 out(");")
313 out("}")
318 out(" %s *%sprop_val;", prop.sssd_type, prefix)
319 out(" int %sprop_len;", prefix)
320 out(" %s *%sout_val;", prop.dbus_type, prefix)
322 out(" %s %sprop_val;", prop.sssd_type, prefix)
323 out(" %s %sout_val;", prop.dbus_type, prefix)
327 out(" %s", prop.getter_signature("%shandler" % prefix), new_line=False)
328 out(";")
348 out("")
349 out("int %s_finish(struct sbus_request *req%s)",
351 out("{")
355 out(" %s cast_%s = arg_%s;", arg.dbus_type, arg.c_name(), arg.c_name())
357 out(" return sbus_request_return_and_finish(req,")
359 out(" ", new_line=False)
361 out("DBUS_TYPE_ARRAY, %s, &arg_%s, len_%s,",
364 out("%s, &cast_%s,", arg.dbus_constant, arg.c_name())
366 out("%s, &arg_%s,", arg.dbus_constant, arg.c_name())
367 out(" DBUS_TYPE_INVALID);")
368 out("}")
373 out(" %s *%s", arg.dbus_type, arg.c_name())
374 out(" int %s__len", arg.c_name())
376 out(" %s %s;", arg.dbus_type, arg.c_name())
380 out("")
381 out("/* arguments for %s.%s */", parent.iface.name, parent.name)
382 out("const struct sbus_arg_meta %s%s[] = {", parent.fq_c_name(), suffix)
384 out(" { \"%s\", \"%s\" },", arg.name, arg.type)
385 out(" { NULL, }")
386 out("};")
398 out("")
399 out("/* methods for %s */", iface.name)
400 out("const struct sbus_method_meta %s__methods[] = {", iface.c_name())
402 out(" {")
403 out(" \"%s\", /* name */", meth.name)
405 out(" %s__in,", meth.fq_c_name())
407 out(" NULL, /* no in_args */")
409 out(" %s__out,", meth.fq_c_name())
411 out(" NULL, /* no out_args */")
412 out(" offsetof(struct %s, %s),", iface.c_name(), meth.c_name())
414 out(" NULL, /* no invoker */")
416 out(" invoke_%s_method,", meth.in_signature())
417 out(" },")
418 out(" { NULL, }")
419 out("};")
426 out("")
427 out("/* signals for %s */", iface.name)
428 out("const struct sbus_signal_meta %s__signals[] = {", iface.c_name())
430 out(" {")
431 out(" \"%s\", /* name */", sig.name)
433 out(" %s__args", sig.fq_c_name())
435 out(" NULL, /* no args */")
436 out(" },")
437 out(" { NULL, }")
438 out("};")
441 out("")
442 out("/* property info for %s */", iface.name)
444 out("const struct sbus_property_meta %s__properties[] = {", iface.c_name())
446 out(" {")
447 out(" \"%s\", /* name */", prop.name)
448 out(" \"%s\", /* type */", prop.type)
450 out(" SBUS_PROPERTY_READABLE | SBUS_PROPERTY_WRITABLE,")
452 out(" SBUS_PROPERTY_READABLE,")
454 out(" SBUS_PROPERTY_WRITABLE,")
458 out(" offsetof(struct %s, %s),", iface.c_name(), prop.getter_name())
459 out(" %s,", prop.getter_invoker_name())
461 out(" 0, /* not readable */")
462 out(" NULL, /* no invoker */")
463 out(" 0, /* not writable */")
464 out(" NULL, /* no invoker */")
465 out(" },")
466 out(" { NULL, }")
467 out("};")
470 out("")
471 out("/* interface info for %s */", iface.name)
472 out("extern const struct sbus_interface_meta %s_meta;", iface.c_name())
475 out("")
476 out("/* interface info for %s */", iface.name)
477 out("const struct sbus_interface_meta %s_meta = {", iface.c_name())
478 out(" \"%s\", /* name */", iface.name)
480 out(" %s__methods,", iface.c_name())
482 out(" NULL, /* no methods */")
484 out(" %s__signals,", iface.c_name())
486 out(" NULL, /* no signals */")
488 out(" %s__properties,", iface.c_name())
490 out(" NULL, /* no properties */")
491 out(" sbus_invoke_get_all, /* GetAll invoker */")
492 out("};")
497 out("/* The following definitions are auto-generated from %s */", basename)
498 out("")
500 out("#include <stddef.h>")
501 out("")
502 out("#include \"dbus/dbus-protocol.h\"")
503 out("#include \"util/util_errors.h\"")
504 out("#include \"sbus/sssd_dbus.h\"")
505 out("#include \"sbus/sssd_dbus_meta.h\"")
506 out("#include \"sbus/sssd_dbus_invokers.h\"")
508 out("#include \"%s\"", os.path.basename(include_header))
534 out("")
535 out("/* finish function for %s */", meth.name)
536 out("int %s_finish(struct sbus_request *req%s);",
540 out("")
541 out("/* vtable for %s */", iface.name)
542 out("struct %s {", iface.c_name())
543 out(" struct sbus_vtable vtable; /* derive from sbus_vtable */")
547 out(" %s;", method_function_pointer(meth, meth.c_name(), with_names=True))
549 out(" %s;", property_handlers(prop))
551 out("};")
554 out("")
555 out("/* constants for %s */", iface.name)
556 out("#define %s \"%s\"", iface.c_name().upper(), iface.name)
558 out("#define %s \"%s\"", meth.fq_c_name().upper(), meth.name)
560 out("#define %s \"%s\"", sig.fq_c_name().upper(), sig.name)
562 out("#define %s \"%s\"", prop.fq_c_name().upper(), prop.name)
568 out("/* The following declarations are auto-generated from %s */", basename)
569 out("")
570 out("#ifndef %s", guard)
571 out("#define %s", guard)
572 out("")
573 out("#include \"sbus/sssd_dbus.h\"")
574 out("#include \"sbus/sssd_dbus_meta.h\"")
576 out("")
577 out("/* ------------------------------------------------------------------------")
578 out(" * DBus Constants")
579 out(" *")
580 out(" * Various constants of interface and method names mostly for use by clients")
581 out(" */")
586 out("")
587 out("/* ------------------------------------------------------------------------")
588 out(" * DBus handlers")
589 out(" *")
590 out(" * These structures are filled in by implementors of the different")
591 out(" * dbus interfaces to handle method calls.")
592 out(" *")
593 out(" * Handler functions of type sbus_msg_handler_fn accept raw messages,")
594 out(" * other handlers are typed appropriately. If a handler that is")
595 out(" * set to NULL is invoked it will result in a")
596 out(" * org.freedesktop.DBus.Error.NotSupported error for the caller.")
597 out(" *")
598 out(" * Handlers have a matching xxx_finish() function (unless the method has")
599 out(" * accepts raw messages). These finish functions the")
600 out(" * sbus_request_return_and_finish() with the appropriate arguments to")
601 out(" * construct a valid reply. Once a finish function has been called, the")
602 out(" * @dbus_req it was called with is freed and no longer valid.")
603 out(" */")
611 out("")
612 out("/* ------------------------------------------------------------------------")
613 out(" * DBus Interface Metadata")
614 out(" *")
615 out(" * These structure definitions are filled in with the information about")
616 out(" * the interfaces, methods, properties and so on.")
617 out(" *")
618 out(" * The actual definitions are found in the accompanying C file next")
619 out(" * to this header.")
620 out(" */")
625 out("")
626 out("#endif /* %s */", guard)
740 elif direction == 'out':