Skip to content

Commit

Permalink
Simply attribute getters for complex values
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Oct 23, 2023
1 parent 0bc009c commit 58f9916
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
9 changes: 3 additions & 6 deletions include/openPMD/binding/c/backend/Attributable.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,15 @@ extern "C"
bool openPMD_Attributable_getAttribute_cfloat2(
const openPMD_Attributable *attributable,
const char *key,
float *value_re,
float *value_im);
float *value);
bool openPMD_Attributable_getAttribute_cdouble2(
const openPMD_Attributable *attributable,
const char *key,
double *value_re,
double *value_im);
double *value);
bool openPMD_Attributable_getAttribute_clong_double2(
const openPMD_Attributable *attributable,
const char *key,
long double *value_re,
long double *value_im);
long double *value);
#ifndef __cplusplus
bool openPMD_Attributable_getAttribute_cfloat(
const openPMD_Attributable *attributable,
Expand Down
12 changes: 3 additions & 9 deletions src/binding/c/backend/Attributable.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool openPMD_Attributable_getAttribute_cfloat(
complex float *value)
{
return openPMD_Attributable_getAttribute_cfloat2(
attributable, key, (float *)(void *)value, (float *)(void *)value + 1);
attributable, key, (float *)value);
}

bool openPMD_Attributable_getAttribute_cdouble(
Expand All @@ -38,10 +38,7 @@ bool openPMD_Attributable_getAttribute_cdouble(
complex double *value)
{
return openPMD_Attributable_getAttribute_cdouble2(
attributable,
key,
(double *)(void *)value,
(double *)(void *)value + 1);
attributable, key, (double *)value);
}

bool openPMD_Attributable_getAttribute_clong_double(
Expand All @@ -50,8 +47,5 @@ bool openPMD_Attributable_getAttribute_clong_double(
complex long double *value)
{
return openPMD_Attributable_getAttribute_clong_double2(
attributable,
key,
(long double *)(void *)value,
(long double *)(void *)value + 1);
attributable, key, (long double *)value);
}
7 changes: 3 additions & 4 deletions src/binding/c/backend/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ openPMD_Datatype openPMD_Attributable_attributeDatatype(
bool openPMD_Attributable_getAttribute_##NAME##2( \
const openPMD_Attributable *attributable, \
const char *key, \
TYPE *value_re, \
TYPE *value_im) \
TYPE *value) \
{ \
const auto cxx_attributable = \
(const openPMD::Attributable *)attributable; \
Expand All @@ -102,8 +101,8 @@ openPMD_Datatype openPMD_Attributable_attributeDatatype(
cxx_attribute.getOptional<std::complex<TYPE>>(); \
if (!cxx_value) \
return false; \
*value_re = cxx_value->real(); \
*value_im = cxx_value->imag(); \
value[0] = cxx_value->real(); \
value[1] = cxx_value->imag(); \
return true; \
}

Expand Down

0 comments on commit 58f9916

Please sign in to comment.