Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_object_impl.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Object Implementation Helpers
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 AFW_DEFINE(const afw_utf8_t * const *)
20  const afw_object_t * const *parents, afw_xctx_t *xctx)
21 {
22  afw_size_t count;
23  const afw_object_t * const *c;
24  const afw_utf8_t * *o;
25  const afw_utf8_t * const *result;
26 
27  for (count = 0, c = parents; *c; count++, c++);
28 
29  o = afw_xctx_malloc(
30  sizeof(afw_utf8_t *) * (count + 1), xctx);
31  result = o;
32  for (c = parents; *c; c++, o++) {
33  *o = afw_object_meta_get_path(*c, xctx);
34  if (!*o) {
35  AFW_THROW_ERROR_Z(general, "Path required", xctx);
36  }
37  }
38  *o = NULL;
39 
40  return result;
41 }
42 
43 
44 
45 /*
46  * A general impl of method get_meta for interface afw_object
47  * that can be accessed externally.
48  */
49 AFW_DECLARE(const afw_value_t *)
51  const afw_object_t *instance,
52  const afw_pool_t *p,
53  afw_xctx_t *xctx)
54 {
55  return afw_value_create_object(instance->meta.meta_object,
56  p, xctx);
57 }
58 
59 
60 
61 /*
62  * Implementation of method get_meta for interface afw_object.
63  */
66  const afw_object_t *instance,
67  const afw_pool_t *p,
68  afw_xctx_t *xctx)
69 {
70  return (instance->meta.meta_object)
71  ? afw_value_create_object(instance->meta.meta_object,
72  p, xctx)
73  : NULL;
74 }
AFW_DEFINE(const afw_object_t *)
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Core Internal.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
afw_object_impl_internal_get_meta(const afw_object_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
A general impl of method get_meta for interface afw_object.
const afw_value_t * afw_object_impl_get_meta(const afw_object_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
A general impl of method get_meta for interface afw_object that can be accessed externally.
afw_object_impl_get_parent_paths_from_parents(const afw_object_t *const *parents, afw_xctx_t *xctx)
Get list of parent paths from list of parents.
afw_object_meta_get_path(const afw_object_t *instance, afw_xctx_t *xctx)
Get an object's path.
#define afw_xctx_malloc(size, xctx)
Macro to allocate uncleared memory in xctx's pool.
Definition: afw_xctx.h:209
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
Interface afw_xctx public struct.