Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 08c2aeb

Browse files
author
Nicolas Cornu
authored
Clean code for #250 (#421)
* Replace assert(!busy) with nrn_assert nrn_assert is compiled too when in release mode. * Using using instead of typedef
1 parent c034005 commit 08c2aeb

23 files changed

+73
-81
lines changed

coreneuron/gpu/nrn_acc_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void realloc_net_receive_buffer(NrnThread* nt, Memb_list* ml) {
464464
#endif
465465
}
466466

467-
typedef std::pair<int, int> NRB_P;
467+
using NRB_P = std::pair<int, int>;
468468

469469
struct comp {
470470
bool operator()(const NRB_P& a, const NRB_P& b) {

coreneuron/io/global_vars.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ int (*nrn2core_get_global_int_item_)(const char* name);
1616

1717
using namespace std;
1818
namespace coreneuron {
19-
typedef pair<size_t, double*> PSD;
20-
typedef map<string, PSD> N2V;
19+
using PSD = pair<size_t, double*>;
20+
using N2V = map<string, PSD>;
2121

2222
static N2V* n2v;
2323

coreneuron/io/nrn_checkpoint.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ extern int patstimtype;
7171
// nrn_setup.cpp and debugging only information which is retrievable from
7272
// NrnThread and Memb_list. Ideally, this should all go away
7373

74-
typedef struct Memb_list_ckpnt {
74+
struct Memb_list_ckpnt {
7575
// debug only
7676
double* data_not_permuted;
7777
Datum* pdata_not_permuted;
7878
int* nodeindices_not_permuted;
79-
} Memb_list_chkpnt;
79+
};
8080

8181
#endif // CHKPNTDEBUG but another section for it below
8282

83-
typedef struct NrnThreadChkpnt {
83+
struct NrnThreadChkpnt {
8484
int file_id;
8585

8686
#if CHKPNTDEBUG
@@ -109,7 +109,7 @@ typedef struct NrnThreadChkpnt {
109109
int* vecplay_ix;
110110
#endif // CHKPNTDEBUG
111111

112-
} NrnThreadChkpnt;
112+
};
113113

114114
extern NrnThreadChkpnt* nrnthread_chkpnt;
115115
} // namespace coreneuron

coreneuron/io/nrn_filehandler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class FileHandler {
157157
}
158158

159159
/** Defined flag values for parse_array() */
160-
typedef enum parse_action { read, seek } parse_action;
160+
enum parse_action { read, seek };
161161

162162
/** Generic parse function for an array of fixed length.
163163
*

coreneuron/io/nrnsection_mapping.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
namespace coreneuron {
1212

1313
/** type to store every section and associated segments */
14-
typedef std::vector<int> segvec_type;
15-
typedef std::map<int, segvec_type> secseg_map_type;
16-
typedef secseg_map_type::iterator secseg_it_type;
14+
using segvec_type = std::vector<int>;
15+
using secseg_map_type = std::map<int, segvec_type>;
16+
using secseg_it_type = secseg_map_type::iterator;
1717

1818
/** @brief Section to segment mapping
1919
*

coreneuron/mechanism/mech/mod2c_core_thread.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace coreneuron {
3131
* and need to be refactored.
3232
*/
3333

34-
typedef int DIFUN;
35-
typedef int NEWTFUN;
36-
typedef int SPFUN;
37-
typedef int EULFUN;
34+
using DIFUN = int;
35+
using NEWTFUN = int;
36+
using SPFUN = int;
37+
using EULFUN = int;
3838
#pragma acc routine seq
3939
extern int nrn_derivimplicit_steer(int, _threadargsproto_);
4040
#define difun(arg) nrn_derivimplicit_steer(arg, _threadargs_);
@@ -45,28 +45,28 @@ extern int nrn_newton_steer(int, _threadargsproto_);
4545
extern int nrn_euler_steer(int, _threadargsproto_);
4646
#define eulerfun(arg) nrn_euler_steer(arg, _threadargs_);
4747

48-
typedef struct Elm {
48+
struct Elm {
4949
unsigned row; /* Row location */
5050
unsigned col; /* Column location */
5151
double* value; /* The value SOA _cntml_padded of them*/
5252
struct Elm* r_up; /* Link to element in same column */
5353
struct Elm* r_down; /* in solution order */
5454
struct Elm* c_left; /* Link to left element in same row */
5555
struct Elm* c_right; /* in solution order (see getelm) */
56-
} Elm;
56+
};
5757
#define ELM0 (Elm*)0
5858

59-
typedef struct Item {
59+
struct Item {
6060
Elm* elm;
6161
unsigned norder; /* order of a row */
6262
struct Item* next;
6363
struct Item* prev;
64-
} Item;
64+
};
6565
#define ITEM0 (Item*)0
6666

67-
typedef Item List; /* list of mixed items */
67+
using List = Item; /* list of mixed items */
6868

69-
typedef struct SparseObj { /* all the state information */
69+
struct SparseObj { /* all the state information */
7070
Elm** rowst; /* link to first element in row (solution order)*/
7171
Elm** diag; /* link to pivot element in row (solution order)*/
7272
void* elmpool; /* no interthread cache line sharing for elements */
@@ -87,7 +87,7 @@ typedef struct SparseObj { /* all the state information */
8787
List* orderlist; /* list of rows sorted by norder
8888
that haven't been used */
8989
int do_flag;
90-
} SparseObj;
90+
};
9191

9292
#pragma acc routine seq
9393
extern double* _nrn_thread_getelm(SparseObj* so, int row, int col, int _iml);

coreneuron/mechanism/mech/modfile/pattern.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ NET_RECEIVE (w) {LOCAL nst
3232

3333
VERBATIM
3434

35-
typedef struct {
35+
struct Info {
3636
int size;
3737
double* tvec;
3838
int* gidvec;
3939
int index;
40-
} Info;
40+
};
4141

4242
#define INFOCAST Info** ip = (Info**)(&(_p_ptr))
4343

coreneuron/mechanism/mech_mapping.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include "coreneuron/permute/data_layout.hpp"
99

1010
namespace coreneuron {
11-
typedef size_t Offset;
12-
typedef int MechId;
13-
typedef const char* VariableName;
11+
using Offset = size_t;
12+
using MechId = int;
13+
using VariableName = const char*;
1414

1515
struct cmp_str {
1616
bool operator()(char const* a, char const* b) const {
@@ -21,7 +21,7 @@ struct cmp_str {
2121
/*
2222
* Structure that map variable names of mechanisms to their value's location (offset) in memory
2323
*/
24-
typedef std::map<MechId, std::map<VariableName, Offset, cmp_str> > MechNamesMapping;
24+
using MechNamesMapping = std::map<MechId, std::map<VariableName, Offset, cmp_str>>;
2525
static MechNamesMapping mechNamesMapping;
2626

2727
static void set_an_offset(int mech_id, const char* variable_name, int offset) {

coreneuron/mechanism/mech_mapping.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace coreneuron {
2222
struct Memb_list;
2323

24-
typedef const char** SerializedNames;
24+
using SerializedNames = const char**;
2525

2626
// return pointer to value of a variable's mechanism, or nullptr if not found
2727
extern double* get_var_location_from_var_name(int mech_id,

coreneuron/mechanism/mechanism.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ union ThreadDatum {
4949
#endif
5050

5151
/* will go away at some point */
52-
typedef struct Point_process {
52+
struct Point_process {
5353
int _i_instance;
5454
short _type;
5555
short _tid; /* NrnThread id */
56-
} Point_process;
56+
};
5757

5858
struct NetReceiveBuffer_t {
5959
int* _displ; /* _displ_cnt + 1 of these */

0 commit comments

Comments
 (0)