17 static int set_n(
void *dst) {
21 src = &couple_value->
n;
22 size =
sizeof(couple_value->
n);
23 memcpy(dst, src, size);
28 static int set_item_type(
void *dst) {
34 memcpy(dst, src, size);
39 static int set_n_dof(
void *dst) {
43 src = &couple_value->
n_dof;
44 size =
sizeof(couple_value->
n_dof);
45 memcpy(dst, src, size);
50 static int set_item(
void *dst) {
54 if (couple_value->
n <= 0)
return 0;
56 src = couple_value->
item;
58 size =
sizeof(*couple_value->
item) * couple_value->
n;
60 size =
sizeof(*couple_value->
item) * couple_value->
n;
62 size =
sizeof(*couple_value->
item) * couple_value->
n * 2;
66 memcpy(dst, src, size);
71 static int set_value(
void *dst) {
75 if (couple_value->
n <= 0 && couple_value->
n_dof <= 0)
return 0;
77 src = couple_value->
value;
78 size =
sizeof(*couple_value->
value) * couple_value->
n * couple_value->
n_dof;
79 memcpy(dst, src, size);
85 static int is_alloc_item(
void) {
return couple_value->
item ? 1 : 0; }
87 static int is_alloc_value(
void) {
return couple_value->
value ? 1 : 0; }
93 static struct func_table {
102 {
"hecmw_couple_value",
"n", set_n,
NULL},
103 {
"hecmw_couple_value",
"item_type", set_item_type,
NULL},
104 {
"hecmw_couple_value",
"n_dof", set_n_dof,
NULL},
105 {
"hecmw_couple_value",
"item", set_item, is_alloc_item},
106 {
"hecmw_couple_value",
"value", set_value, is_alloc_value},
109 static const int NFUNC =
sizeof(functions) /
sizeof(functions[0]);
115 for (i = 0; i < NFUNC; i++) {
116 if (strcmp(functions[i].struct_name, struct_name) == 0 &&
117 strcmp(functions[i].var_name, var_name) == 0) {
118 return functions[i].is_allocated_func;
124 static SetFunc get_set_func(
char *struct_name,
char *var_name) {
127 for (i = 0; i < NFUNC; i++) {
128 if (strcmp(functions[i].struct_name, struct_name) == 0 &&
129 strcmp(functions[i].var_name, var_name) == 0) {
130 return functions[i].set_func;
140 couple_value = _couple_value;
152 int *is_allocated,
int *err,
int slen,
160 if (couple_value ==
NULL) {
162 "hecmw_cpl_copy_c2f_isalloc_if(): 'couple_value' is not "
166 if (struct_name ==
NULL) {
168 "hecmw_cpl_copy_c2f_isalloc_if(): 'struct_name' is NULL");
171 if (var_name ==
NULL) {
173 "hecmw_cpl_copy_c2f_isalloc_if(): 'var_name' is NULL");
176 if (is_allocated ==
NULL) {
178 "hecmw_cpl_copy_c2f_isalloc_if(): 'is_allocated' is NULL");
186 if ((func = get_is_allocated_func(sname, vname)) ==
NULL) {
189 "hecmw_cpl_copy_c2f_isalloc_if(): IsAllocatedFunc not found");
203 int *is_allocated,
int *err,
204 int slen,
int vlen) {
210 int *is_allocated,
int *err,
211 int slen,
int vlen) {
217 int *is_allocated,
int *err,
int slen,
226 void *dst,
int *err,
int slen,
int vlen) {
233 if (couple_value ==
NULL) {
236 "hecmw_cpl_copy_c2f_set_if(): 'couple_value' has not initialized yet");
239 if (struct_name ==
NULL) {
241 "hecmw_cpl_copy_c2f_set_if(): 'struct_name' is NULL");
244 if (var_name ==
NULL) {
246 "hecmw_cpl_copy_c2f_set_if(): 'var_name' is NULL");
251 "hecmw_cpl_copy_c2f_set_if(): 'dst' is NULL");
259 if ((func = get_set_func(sname, vname)) ==
NULL) {
261 "hecmw_cpl_copy_c2f_set_if(): SetFunc not found");
265 if ((*func)(dst))
return;
271 void *dst,
int *err,
int slen,
277 void *dst,
int *err,
int slen,
283 void *dst,
int *err,
int slen,
int vlen) {