Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove typedef from nrnpython #3242

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 21 additions & 33 deletions src/nrnpython/grids.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,15 @@ and Flux_pair structs and their respective functions
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct Hybrid_data {
struct Hybrid_data {
long num_1d_indices;
long* indices1d;
long* num_3d_indices_per_1d_seg;
long* indices3d;
double* rates;
double* volumes1d;
double* volumes3d;
} Hybrid_data;

typedef struct Flux_pair {
double* flux; // Value of flux
int grid_index; // Location in grid
} Flux;
};

struct Concentration_Pair {
neuron::container::data_handle<double> destination; /* memory loc to transfer concentration to
Expand All @@ -58,38 +53,31 @@ struct Current_Triple {
double scale_factor;
};

typedef void (*ReactionRate)(double**,
double**,
double**,
double*,
double*,
double*,
double*,
double**,
double);
typedef void (*ECSReactionRate)(double*, double*, double*, double*);
typedef struct Reaction {
struct Reaction* next;
ECSReactionRate reaction;
using ReactionRate =
void(double**, double**, double**, double*, double*, double*, double*, double**, double);
using ECSReactionRate = void(double*, double*, double*, double*);
struct Reaction {
Reaction* next;
ECSReactionRate* reaction;
unsigned int num_species_involved;
unsigned int num_params_involved;
double** species_states;
unsigned char* subregion;
unsigned int region_size;
uint64_t* mc3d_indices_offsets;
double** mc3d_mults;
} Reaction;
};

typedef struct {
struct AdiLineData {
double* copyFrom;
long copyTo;
} AdiLineData;
};

typedef struct {
struct BoundaryConditions {
/*TODO: Support for mixed boundaries and by edge (maybe even by voxel)*/
unsigned char type;
double value;
} BoundaryConditions;
};

class Grid_node {
public:
Expand Down Expand Up @@ -237,7 +225,7 @@ class ECS_Grid_node: public Grid_node {
double* set_rxd_currents(int, int*, PyHocObject**);
};

typedef struct ECSAdiDirection {
struct ECSAdiDirection {
void (*ecs_dg_adi_dir)(ECS_Grid_node*,
const double,
const int,
Expand All @@ -248,16 +236,16 @@ typedef struct ECSAdiDirection {
double* states_in;
double* states_out;
int line_size;
} ECSAdiDirection;
};

typedef struct ECSAdiGridData {
struct ECSAdiGridData {
int start, stop;
double* state;
ECS_Grid_node* g;
int sizej;
ECSAdiDirection* ecs_adi_dir;
double* scratchpad;
} ECSAdiGridData;
};

class ICS_Grid_node: public Grid_node {
public:
Expand Down Expand Up @@ -335,7 +323,7 @@ class ICS_Grid_node: public Grid_node {
double* set_rxd_currents(int, int*, PyHocObject**);
};

typedef struct ICSAdiDirection {
struct ICSAdiDirection {
void (*ics_dg_adi_dir)(ICS_Grid_node* g,
int,
int,
Expand All @@ -357,10 +345,10 @@ typedef struct ICSAdiDirection {
double dc;
double* dcgrid;
double d;
} ICSAdiDirection;
};


typedef struct ICSAdiGridData {
struct ICSAdiGridData {
// Start and stop node indices for lines
int line_start, line_stop;
// Where to start in the ordered_nodes array
Expand All @@ -374,7 +362,7 @@ typedef struct ICSAdiGridData {
double* diag;
double* u_diag;
// double* deltas;
} ICSAdiGridData;
};

/***** GLOBALS *******************************************************************/
extern double* dt_ptr; // Universal ∆t
Expand Down
4 changes: 2 additions & 2 deletions src/nrnpython/hoccontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extern Symlist* hoc_symlist;
hc_restore_(hc_); \
}

typedef struct HocContext {
struct HocContext {
Object* obj;
Objectdata* obd;
Symlist* sl;
} HocContext;
};

static HocContext* hc_save_and_set_to_top_(HocContext* hc) {
hc->obj = hoc_thisobject;
Expand Down
4 changes: 2 additions & 2 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ PyTypeObject* hocobject_type;

static PyObject* hocobj_call(PyHocObject* self, PyObject* args, PyObject* kwrds);

typedef struct {
struct hocclass {
PyTypeObject head;
Symbol* sym;
} hocclass;
};

static int hocclass_init(hocclass* cls, PyObject* args, PyObject* kwds) {
if (PyType_Type.tp_init((PyObject*) cls, args, kwds) < 0) {
Expand Down
40 changes: 20 additions & 20 deletions src/nrnpython/nrnpy_nrn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,69 +44,69 @@ extern int hocobj_pushargs(PyObject*, std::vector<char*>&);
extern void hocobj_pushargs_free_strings(std::vector<char*>&);


typedef struct {
struct NPyAllSegOfSecIter {
PyObject_HEAD
NPySecObj* pysec_;
int allseg_iter_;
} NPyAllSegOfSecIter;
};

typedef struct {
struct NPySegOfSecIter {
PyObject_HEAD
NPySecObj* pysec_;
int seg_iter_;
} NPySegOfSecIter;
};

typedef struct {
struct NPySegObj {
PyObject_HEAD
NPySecObj* pysec_;
double x_;
} NPySegObj;
};

typedef struct {
struct NPyMechObj {
PyObject_HEAD
NPySegObj* pyseg_;
Prop* prop_;
// Following cannot be initialized when NPyMechObj allocated by Python. See new_pymechobj
// wrapper.
neuron::container::non_owning_identifier_without_container prop_id_;
int type_;
} NPyMechObj;
};

typedef struct {
struct NPyMechOfSegIter {
PyObject_HEAD
NPyMechObj* pymech_;
} NPyMechOfSegIter;
};

typedef struct {
struct NPyMechFunc {
PyObject_HEAD
NPyMechObj* pymech_;
NPyDirectMechFunc* f_;
} NPyMechFunc;
};

typedef struct {
struct NPyVarOfMechIter {
PyObject_HEAD
NPyMechObj* pymech_;
Symbol* msym_;
int i_;
} NPyVarOfMechIter;
};

typedef struct {
struct NPyRVItr {
PyObject_HEAD
NPyMechObj* pymech_;
int index_;
} NPyRVItr;
};

typedef struct {
struct NPyRangeVar {
PyObject_HEAD
NPyMechObj* pymech_;
Symbol* sym_;
int isptr_;
int attr_from_sec_; // so section.xraxial[0] = e assigns to all segments.
} NPyRangeVar;
};

typedef struct {
struct NPyOpaquePointer {
PyObject_HEAD
} NPyOpaquePointer;
};

PyTypeObject* psection_type;
static PyTypeObject* pallseg_of_sec_iter_type;
Expand Down
12 changes: 6 additions & 6 deletions src/nrnpython/rxd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
extern double* t_ptr;


fptr _setup, _initialize, _setup_matrices, _setup_units;
fptr *_setup, *_initialize, *_setup_matrices, *_setup_units;
extern NrnThread* nrn_threads;

/*intracellular diffusion*/
Expand Down Expand Up @@ -474,20 +474,20 @@
}
}

extern "C" NRN_EXPORT void set_setup(const fptr setup_fn) {
extern "C" NRN_EXPORT void set_setup(const fptr* setup_fn) {

Check warning on line 477 in src/nrnpython/rxd.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNMODL_SANITIZERS=undefinedundefined)

'const' qualifier on function type 'fptr' (aka 'void ()') has no effect [-Wignored-qualifiers]
_setup = setup_fn;
}

extern "C" NRN_EXPORT void set_initialize(const fptr initialize_fn) {
extern "C" NRN_EXPORT void set_initialize(const fptr* initialize_fn) {

Check warning on line 481 in src/nrnpython/rxd.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNMODL_SANITIZERS=undefinedundefined)

'const' qualifier on function type 'fptr' (aka 'void ()') has no effect [-Wignored-qualifiers]
_initialize = initialize_fn;
set_num_threads(NUM_THREADS);
}

extern "C" NRN_EXPORT void set_setup_matrices(fptr setup_matrices) {
extern "C" NRN_EXPORT void set_setup_matrices(fptr* setup_matrices) {
_setup_matrices = setup_matrices;
}

extern "C" NRN_EXPORT void set_setup_units(fptr setup_units) {
extern "C" NRN_EXPORT void set_setup_units(fptr* setup_units) {
_setup_units = setup_units;
}

Expand Down Expand Up @@ -861,7 +861,7 @@
int nmult,
double* mult,
PyHocObject** vptrs,
ReactionRate f) {
1uc marked this conversation as resolved.
Show resolved Hide resolved
ReactionRate* f) {
int i, j, k, idx, ecs_id, ecs_index, ecs_offset;
unsigned char counted;
Grid_node* g;
Expand Down
32 changes: 16 additions & 16 deletions src/nrnpython/rxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
#define SPECIES_ABSENT -1
#define PREFETCH 4

typedef void (*fptr)(void);
using fptr = void(void);

// @olupton 2022-09-16: deleted a declaration of OcPtrVector that did not match
// the one in ocptrvector.h

typedef struct {
struct ReactSet {
Reaction* reaction;
int idx;
} ReactSet;
};

typedef struct {
struct ReactGridData {
ReactSet* onset;
ReactSet* offset;
} ReactGridData;
};


typedef struct {
struct CurrentData {
Grid_node* g;
int onset, offset;
double* val;
} CurrentData;
};


typedef struct SpeciesIndexList {
struct SpeciesIndexList {
int id;
double atolscale;
int* indices;
int length;
struct SpeciesIndexList* next;
} SpeciesIndexList;
};

typedef struct ICSReactions {
ReactionRate reaction;
struct ICSReactions {
ReactionRate* reaction;
int num_species;
int num_regions;
int num_params;
Expand All @@ -63,23 +63,23 @@ typedef struct ICSReactions {
int* mc_flux_idx;
double** vptrs;
struct ICSReactions* next;
} ICSReactions;
};

typedef struct TaskList {
struct TaskList {
void* (*task)(void*);
void* args;
void* result;
struct TaskList* next;
} TaskList;
};

typedef struct TaskQueue {
struct TaskQueue {
std::condition_variable task_cond, waiting_cond;
std::mutex task_mutex, waiting_mutex;
std::vector<bool> exit;
int length{};
struct TaskList* first;
struct TaskList* last;
} TaskQueue;
};

extern "C" void set_num_threads(const int);
void _fadvance(void);
Expand Down
Loading