Skip to content

Commit

Permalink
Merge branch 'development' into queryarrWithParser
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Aug 20, 2024
2 parents b801072 + c49d35e commit 277d571
Show file tree
Hide file tree
Showing 66 changed files with 3,720 additions and 1,595 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ jobs:
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Build & Install
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wnon-virtual-dtor"}
# /tmp/icpx-2d34de0e47/global_vars-header-4390fb.h:25:36: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
# 25 | const char* const kernel_names[] = {
# | ^
# 1 error generated.
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wnon-virtual-dtor -Wno-zero-length-array"}
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
Expand Down Expand Up @@ -68,7 +72,11 @@ jobs:
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Build & Install
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wnon-virtual-dtor"}
# /tmp/icpx-2d34de0e47/global_vars-header-4390fb.h:25:36: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
# 25 | const char* const kernel_names[] = {
# | ^
# 1 error generated.
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wnon-virtual-dtor -Wno-zero-length-array"}
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
Expand Down
50 changes: 50 additions & 0 deletions Docs/sphinx_documentation/source/Basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,56 @@ will become
foo.a = 2
foo.b = 2

Enum Class
----------

.. versionadded:: 24.09
Enum class support in :cpp:`ParmParse`.

AMReX provides a macro :cpp:`AMREX_ENUM` for defining :cpp:`enum class` that
supports reflection. For example,

.. highlight:: c++

::

AMREX_ENUM(MyColor, red, green, blue);

void f ()
{
MyColor color = amrex::getEnum<MyColor>("red"); // MyColor::red
std::string name = amrex::getEnumNameString(MyColor::blue); // "blue"
std::vector<std::string> names = amrex::getEnumNameStrings<MyColor>();
// names = {"red", "green", "blue"};
std::string class_name = amrex::getEnumClassName<MyColor>(); // "MyColor"
}

This allows us to read :cpp:`ParmParse` parameters into enum class objects.

.. highlight:: python

::

color1 = red
color2 = BLue

The following code shows how to query the enumerators.

.. highlight:: c++

::

AMREX_ENUM(MyColor, none, red, green, blue);

void f (MyColor& c1, MyColor& c2)
{
ParmParse pp;
pp.query("color1", c1); // c1 becomes MyColor::red
pp.query_enum_case_insensitive("color2", c2); // c2 becomes MyColor::blue
MyColor default_color; // MyColor::none
pp.query("color3", default_color); // Still MyColor::none
}

Overriding Parameters with Command-Line Arguments
-------------------------------------------------

Expand Down
Loading

0 comments on commit 277d571

Please sign in to comment.