Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_evaluated.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Interface afw_value Implementation for evaluated
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw_internal.h"
16 
17 
18 
21  const afw_data_type_t *data_type,
22  const afw_pool_t *p,
23  afw_xctx_t *xctx)
24 {
25  afw_value_evaluated_t *result;
26 
27  result = afw_pool_calloc(p,
28  offsetof(afw_value_evaluated_t, internal) + data_type->c_type_size,
29  xctx);
30  result->inf = data_type->evaluated_value_inf;
31  return result;
32 }
33 
34 
35 /* Create function for an evaluated data type value. */
36 AFW_DEFINE(const afw_value_t *)
38  const void * value,
39  const afw_data_type_t *data_type,
40  const afw_pool_t *p,
41  afw_xctx_t *xctx)
42 {
43  afw_value_evaluated_t *result;
44 
45  if (!data_type) {
46  AFW_THROW_ERROR_Z(general,
47  "afw_value_evaluated_create() called with NULL data type",
48  xctx);
49  }
50  result = afw_pool_calloc(p,
51  offsetof(afw_value_evaluated_t, internal) + data_type->c_type_size,
52  xctx);
53  result->inf = data_type->evaluated_value_inf;
54  memcpy(&result->internal, value, data_type->c_type_size);
55 
56  return (const afw_value_t *)result;
57 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
#define offsetof(type, member)
Definition: afw_common.h:135
#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
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
afw_value_evaluated_allocate(const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for an evaluated data type value.
afw_value_evaluated_create(const void *value, const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for an evaluated data type value.
Interface afw_data_type public struct.
Interface afw_pool public struct.
Struct to access internal of all evaluated values.
Definition: afw_value.h:60
Interface afw_value public struct.
Interface afw_xctx public struct.