You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module_json: give AbacusJson a read-only document view and pass general_info its inputs, removing the last access hack in the module
para_json_test.cpp needed `#define private public` for two independent reasons.
Both are now addressed by real interfaces rather than by a friend declaration.
1) It read the private static `AbacusJson::doc` in 84 places to inspect what
add_json() had produced, and reset it in 5 more. AbacusJson gains two public
members next to the existing allocator():
static const rapidjson::Document& document(); // read-only view
static void reset(); // start a fresh empty object
All 84 reads are const (HasMember, operator[], Get*/Is*), so the const view is
sufficient and the document cannot be mutated through it. The 5 resets were
`doc.SetObject()` twice and `doc.Parse("{}")` three times; both leave an empty
object, and add_json() itself already calls SetObject() when the document is
not an object, so reset() covers both.
2) It populated a local `Parameter` -- whose `input` and `sys` members are
private -- only to hand it to gen_general_info(). That function read six
values from it, so it now takes them directly:
void gen_general_info(const Input_para& inp,
const std::time_t start_time,
const std::string& stru_file);
This follows the precedent set by gen_init(ucell, param.inp) in the same
module. Its one caller, create_Json() in para_json.cpp, already receives
`Parameter&` as an argument, so the call site reads no global state; the test
now builds a plain `Input_para` (a struct with public members) and passes the
time and structure path as values.
general_info.h consequently drops its `parameter.h` include in favour of a
forward declaration of Input_para, again matching init_info.h.
Also deletes a commented-out duplicate of the add_json block in
general_info.cpp that still referred to the removed `param`.
No assertion or expected value changed. This target only builds under
ENABLE_RAPIDJSON, which the local build box cannot provide (rapidjson is not
installed and cannot be fetched), so it is verified by CI.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments