@@ -293,10 +293,14 @@ Depending on the command line options passed, this will generate one of these tw
293293
294294``` c
295295// --no-sig-flattening passed, the usual single out parameter is used
296- extern void my_example_string_getter_get_string_by_index (uint32_t index, my_example_string_getter_result_string_error_t * ret);
296+ extern void
297+ my_example_string_getter_get_string_by_index (
298+ uint32_t index, my_example_string_getter_result_string_error_t *ret);
297299
298300// Flag not passed, the return value is flattened
299- extern bool my_example_string_getter_get_string_by_index(uint32_t index, string_getter_user_string_t * ret, my_example_string_getter_error_t * err);
301+ extern bool
302+ my_example_string_getter_get_string_by_index(
303+ uint32_t index, string_getter_user_string_t * ret, my_example_string_getter_error_t * err);
300304```
301305
302306A helper function is generated to free variants:
@@ -439,18 +443,28 @@ typedef struct cat_example_registry_api_borrow_cat_t {
439443} cat_example_registry_api_borrow_cat_t ;
440444
441445// Functions to call the methods of the cat resource
442- extern void cat_example_registry_api_method_cat_get_name (cat_example_registry_api_borrow_cat_t self, adoption_authority_string_t * ret);
443- extern void cat_example_registry_api_method_cat_get_nicknames(cat_example_registry_api_borrow_cat_t self, adoption_authority_list_string_t * ret);
446+ extern void
447+ cat_example_registry_api_method_cat_get_name (
448+ cat_example_registry_api_borrow_cat_t self, adoption_authority_string_t *ret);
449+ extern void
450+ cat_example_registry_api_method_cat_get_nicknames(
451+ cat_example_registry_api_borrow_cat_t self, adoption_authority_list_string_t * ret);
444452
445453// Drop an owning handle to a cat
446- extern void cat_example_registry_api_cat_drop_own(cat_example_registry_api_own_cat_t handle);
454+ extern void
455+ cat_example_registry_api_cat_drop_own(
456+ cat_example_registry_api_own_cat_t handle);
447457
448458// Drop a borrowing handle to a cat
449459// Only generated if autodropping borrows is turned off (described below)
450- extern void cat_example_registry_api_cat_drop_borrow(cat_example_registry_api_borrow_cat_t handle);
460+ extern void
461+ cat_example_registry_api_cat_drop_borrow(
462+ cat_example_registry_api_borrow_cat_t handle);
451463
452464// Retrieve a borrowing handle to a cat from an owning handle
453- extern cat_example_registry_api_borrow_cat_t cat_example_registry_api_borrow_cat(cat_example_registry_api_own_cat_t handle);
465+ extern cat_example_registry_api_borrow_cat_t
466+ cat_example_registry_api_borrow_cat(
467+ cat_example_registry_api_own_cat_t handle);
454468
455469```
456470
@@ -535,25 +549,37 @@ typedef struct exports_cat_example_registry_api_own_cat_t {
535549} exports_cat_example_registry_api_own_cat_t;
536550
537551// The internal representation of the resource - must be implemented by the exporting component
538- typedef struct exports_cat_example_registry_api_cat_t exports_cat_example_registry_api_cat_t;
552+ typedef struct exports_cat_example_registry_api_cat_t
553+ exports_cat_example_registry_api_cat_t;
539554
540555// Borrows are represented as a pointer to the internal representation rather than an opaque handle
541- typedef exports_cat_example_registry_api_cat_t* exports_cat_example_registry_api_borrow_cat_t;
556+ typedef exports_cat_example_registry_api_cat_t*
557+ exports_cat_example_registry_api_borrow_cat_t;
542558
543559// Declarations for the resource methods that the exporting component must implement
544- void exports_cat_example_registry_api_method_cat_get_name(exports_cat_example_registry_api_borrow_cat_t self, registry_string_t *ret);
545- void exports_cat_example_registry_api_method_cat_get_nicknames(exports_cat_example_registry_api_borrow_cat_t self, registry_list_string_t *ret);
560+ void exports_cat_example_registry_api_method_cat_get_name(
561+ exports_cat_example_registry_api_borrow_cat_t self, registry_string_t *ret);
562+ void exports_cat_example_registry_api_method_cat_get_nicknames(
563+ exports_cat_example_registry_api_borrow_cat_t self, registry_list_string_t *ret);
546564
547565// Drop an owning handle to a cat
548- extern void exports_cat_example_registry_api_cat_drop_own(exports_cat_example_registry_api_own_cat_t handle);
566+ extern void
567+ exports_cat_example_registry_api_cat_drop_own(
568+ exports_cat_example_registry_api_own_cat_t handle);
549569
550570// Create an owning opaque handle to a cat from an internal representation
551- extern exports_cat_example_registry_api_own_cat_t exports_cat_example_registry_api_cat_new(exports_cat_example_registry_api_cat_t *rep);
571+ extern exports_cat_example_registry_api_own_cat_t
572+ exports_cat_example_registry_api_cat_new(
573+ exports_cat_example_registry_api_cat_t *rep);
574+
552575// Get the internal representation of a cat from an owning opaque handle
553- extern exports_cat_example_registry_api_cat_t* exports_cat_example_registry_api_cat_rep(exports_cat_example_registry_api_own_cat_t handle);
576+ extern exports_cat_example_registry_api_cat_t*
577+ exports_cat_example_registry_api_cat_rep(
578+ exports_cat_example_registry_api_own_cat_t handle);
554579
555580// Destroy a cat resource - must be implemented by the exporting component
556- void exports_cat_example_registry_api_cat_destructor(exports_cat_example_registry_api_cat_t *rep);
581+ void exports_cat_example_registry_api_cat_destructor(
582+ exports_cat_example_registry_api_cat_t *rep);
557583```
558584
559585Here are possible implementations for the functions and type that must be implemented by the component:
@@ -593,7 +619,7 @@ void exports_cat_example_registry_api_method_cat_get_nicknames(
593619}
594620```
595621
596- A component may _borrow_ or _own_ an exported resource. This is communicated in WIT by whether the resource type is wrapped in `borrow<...>` or not. The exporting component is responsible for dropping any owning references to resources that it creates through calls to `*_new` using the generated `*_drop_own` function. Components never need to drop borrowing handles to resources that they export.
622+ A component may _borrow_ or _own_ an exported resource. This is communicated in WIT by whether the resource type is wrapped in `borrow<...>` or not. The exporting component is responsible for dropping any owning references to resources that it creates through calls to `*_new` using the generated `*_drop_own` function. Components must not drop borrowing handles to resources that they export.
597623
598624The implementations of the destructor and the `cat` methods would be the same as the above example. Here are possible implementations of the other functions:
599625
0 commit comments