NEURON
hoc_oop.cpp File Reference
#include <../../nrnconf.h>
#include <cstdlib>
#include <vector>
#include "utils/formatting.hpp"
#include "classreg.h"
#include "neuronapi.h"
#include "hocstr.h"
#include "parse.hpp"
#include "hocparse.h"
#include "code.h"
#include "cabcode.h"
#include "hocassrt.h"
#include "hoclist.h"
#include "nrn_ansi.h"
#include "nrnmpi.h"
#include "nrnpy.h"
#include "nrnfilewrap.h"
#include "ocfunc.h"
#include "section.h"
#include "nrniv_mf.h"

Go to the source code of this file.

Classes

union  Templatedatum
 
struct  guard_t
 

Macros

#define PDEBUG   0
 
#define PUBLIC_TYPE   1
 
#define EXTERNAL_TYPE   2
 
#define NTEMPLATESTACK   20
 
#define pushtemplatesym(arg)
 
#define pushtemplatesymlist(arg)
 
#define pushtemplatei(arg)
 
#define pushtemplateodata(arg)
 
#define pushtemplateo(arg)
 
#define OBJ_STACK_SIZE   10
 
#define objectpath   hoc_objectpath_impl
 
#define pathprepend   hoc_path_prepend
 

Functions

struct Sectionnrn_sec_pop ()
 
static void call_constructor (Object *, Symbol *, int)
 
static void free_objectdata (Objectdata *, cTemplate *)
 
void hoc_install_hoc_obj (void)
 
Objecthoc_obj_get (int i)
 
void hoc_obj_set (int i, Object *obj)
 
char * hoc_object_name (Object *ob)
 
size_t hoc_total_array (Symbol *s)
 
size_t hoc_total_array_data (const Symbol *s, Objectdata *obd)
 
void hoc_push_current_object (void)
 
Objectdatahoc_objectdata_save (void)
 
Objectdatahoc_objectdata_restore (Objectdata *obdsav)
 
void hoc_obvar_declare (Symbol *sym, int type, int pmes)
 
static Templatedatumpoptemplate (void)
 
static void chktemplate (void)
 
void hoc_object_push (void)
 
void hoc_object_pushed (void)
 
void hoc_object_pop (void)
 
int hoc_resize_toplevel (int more)
 
void hoc_install_object_data_index (Symbol *sp)
 
int hoc_obj_run (const char *cmd, Object *ob)
 Brief explanation of hoc_obj_run. More...
 
void hoc_exec_cmd (void)
 
double hoc_call_objfunc (Symbol *s, int narg, Object *ob)
 
void hoc_oop_initaftererror (void)
 
void oc_save_hoc_oop (Object **a1, Objectdata **a2, int *a4, Symlist **a5)
 
void oc_restore_hoc_oop (Object **a1, Objectdata **a2, int *a4, Symlist **a5)
 
Objecthoc_new_object (Symbol *symtemp, void *v)
 
void hoc_new_object_asgn (Object **obp, Symbol *st, void *v)
 
Object ** hoc_temp_objvar (Symbol *symtemp, void *v)
 
Objecthoc_newobj1 (Symbol *sym, int narg)
 
void hoc_newobj_arg (void)
 
void hoc_newobj_ret (void)
 
void hoc_newobj (void)
 
Objectnrn_get_gui_redirect_obj ()
 
void hoc_call_ob_proc (Object *ob, Symbol *sym, int narg)
 
static void call_ob_iter (Object *ob, Symbol *sym, int narg)
 
void hoc_objvardecl (void)
 
void hoc_cmp_otype (void)
 
void hoc_known_type (void)
 
void hoc_objectvar (void)
 
void hoc_objectarg (void)
 
void hoc_constobject (void)
 
Objecthoc_name2obj (const char *name, int index)
 
void hoc_object_id (void)
 
static void range_suffix (Symbol *sym, int nindex, int narg)
 
void connect_obsec_syntax (void)
 
void hoc_object_component ()
 
void hoc_object_eval (void)
 
void hoc_ob_pointer (void)
 
void hoc_asgn_obj_to_str (void)
 
void hoc_object_asgn ()
 
Symbolhoc_which_template (Symbol *s)
 
void hoc_begintemplate (Symbol *t1)
 
void hoc_endtemplate (Symbol *t)
 
void class2oc_base (const char *name, ctor_f *cons, dtor_f *destruct, Member_func *m, Member_ret_obj_func *mobjret, Member_ret_str_func *strret)
 
void class2oc (const char *name, ctor_f *cons, dtor_f *destruct, Member_func *m, Member_ret_obj_func *mobjret, Member_ret_str_func *strret)
 
Symbolhoc_decl (Symbol *s)
 
void hoc_add_publiclist (Symbol *s)
 
void hoc_external_var (Symbol *s)
 
void hoc_ob_check (int type)
 
void hoc_free_allobjects (cTemplate *ctemplate, Symlist *sl, Objectdata *data)
 
void pathprepend (char *path, const char *name, const char *indx)
 
int objectpath (Object *ob, Object *oblook, char *path, int depth)
 
char * hoc_object_pathname (Object *ob)
 
void hoc_obj_ref (Object *obj)
 
void hoc_dec_refcount (Object **pobj)
 
void hoc_obj_unref (Object *obj)
 
static void hoc_allobjects1 (Symlist *sl, int nspace)
 
static void hoc_allobjects2 (Symbol *s, int nspace)
 
void hoc_allobjects (void)
 
static void hoc_list_allobjref (Symlist *, Objectdata *, int)
 
void hoc_allobjectvars (void)
 
void check_obj_type (Object *obj, const char *type_name)
 
int is_obj_type (Object *obj, const char *type_name)
 
void * nrn_opaque_obj2pyobj (Object *ho)
 
static void hoc_object_binary_op_helper (const char *method_name)
 
static void hoc_object_number_binary_op_helper (const char *method_name)
 
static void hoc_number_object_binary_op_helper (const char *method_name)
 
void hoc_object_add ()
 
void hoc_object_sub ()
 
void hoc_object_mul ()
 
void hoc_object_div ()
 
void hoc_object_pow ()
 
static bool hoc_object_comparison_setup (Object **&obj1_ptr, Object **&obj2_ptr, Object *&obj1, Object *&obj2, const char *method_name, bool is_equality)
 
static void hoc_object_comparison_call (Object **obj1_ptr, Object **obj2_ptr, Object *obj1, Symbol *method_sym)
 
static void hoc_object_comparison_fallback (Object **obj1_ptr, Object **obj2_ptr, bool is_equality)
 
void hoc_object_eq ()
 
void hoc_object_ne ()
 
void hoc_object_add_number ()
 
void hoc_number_add_object ()
 
void hoc_object_sub_number ()
 
void hoc_number_sub_object ()
 
void hoc_object_mul_number ()
 
void hoc_number_mul_object ()
 
void hoc_object_div_number ()
 
void hoc_number_div_object ()
 
void hoc_object_pow_number ()
 
void hoc_number_pow_object ()
 

Variables

Symbolnrnpy_pyobj_sym_ {}
 
int section_object_seen
 
static int connect_obsec_
 
std::vector< const char * > py_exposed_classes {}
 
int hoc_print_first_instance = 1
 
int hoc_max_builtin_class_id = -1
 
static Symbolhoc_obj_
 
int(* nrnpy_call_obj_method )(Object *obj, const char *method, Object *obj2) = nullptr
 
int(* nrnpy_call_obj_method_double )(Object *obj, const char *method, double value) = nullptr
 
static int icntobjectdata = 0
 
Objecthoc_thisobject
 
Objectdatahoc_objectdata = (Objectdata*) 0
 
Objectdatahoc_top_level_data
 
static int icnttoplevel
 
int hoc_in_template = 0
 
static Templatedatum templatestack [NTEMPLATESTACK]
 
static Templatedatumtemplatestackp = templatestack
 
static Objectobj_stack_ [OBJ_STACK_SIZE+1]
 
static int obj_stack_loc
 
static Objectgui_redirect_obj_
 
static int template_id
 
constexpr std::size_t hoc_object_pathname_bufsize = 512
 

Macro Definition Documentation

◆ EXTERNAL_TYPE

#define EXTERNAL_TYPE   2

Definition at line 34 of file hoc_oop.cpp.

◆ NTEMPLATESTACK

#define NTEMPLATESTACK   20

Definition at line 200 of file hoc_oop.cpp.

◆ OBJ_STACK_SIZE

#define OBJ_STACK_SIZE   10

Definition at line 237 of file hoc_oop.cpp.

◆ objectpath

#define objectpath   hoc_objectpath_impl

Definition at line 1777 of file hoc_oop.cpp.

◆ pathprepend

#define pathprepend   hoc_path_prepend

Definition at line 1778 of file hoc_oop.cpp.

◆ PDEBUG

#define PDEBUG   0

Definition at line 24 of file hoc_oop.cpp.

◆ PUBLIC_TYPE

#define PUBLIC_TYPE   1

Definition at line 33 of file hoc_oop.cpp.

◆ pushtemplatei

#define pushtemplatei (   arg)
Value:
(templatestackp++)->i = arg
#define i
Definition: md1redef.h:19
static Templatedatum * templatestackp
Definition: hoc_oop.cpp:202
static void chktemplate(void)
Definition: hoc_oop.cpp:227

Definition at line 217 of file hoc_oop.cpp.

◆ pushtemplateo

#define pushtemplateo (   arg)
Value:
(templatestackp++)->o = arg

Definition at line 223 of file hoc_oop.cpp.

◆ pushtemplateodata

#define pushtemplateodata (   arg)
Value:
(templatestackp++)->odata = arg

Definition at line 220 of file hoc_oop.cpp.

◆ pushtemplatesym

#define pushtemplatesym (   arg)
Value:
(templatestackp++)->sym = arg

Definition at line 211 of file hoc_oop.cpp.

◆ pushtemplatesymlist

#define pushtemplatesymlist (   arg)
Value:
#define symlist
Definition: cabcode.cpp:49

Definition at line 214 of file hoc_oop.cpp.

Function Documentation

◆ call_constructor()

static void call_constructor ( Object ob,
Symbol sym,
int  narg 
)
static

Definition at line 614 of file hoc_oop.cpp.

◆ call_ob_iter()

static void call_ob_iter ( Object ob,
Symbol sym,
int  narg 
)
static

Definition at line 726 of file hoc_oop.cpp.

◆ chktemplate()

static void chktemplate ( void  )
static

Definition at line 227 of file hoc_oop.cpp.

◆ class2oc()

void class2oc ( const char *  name,
ctor_f cons,
dtor_f destruct,
Member_func m,
Member_ret_obj_func mobjret,
Member_ret_str_func strret 
)

Definition at line 1636 of file hoc_oop.cpp.

◆ class2oc_base()

void class2oc_base ( const char *  name,
ctor_f cons,
dtor_f destruct,
Member_func m,
Member_ret_obj_func mobjret,
Member_ret_str_func strret 
)

Definition at line 1588 of file hoc_oop.cpp.

◆ connect_obsec_syntax()

void connect_obsec_syntax ( void  )

Definition at line 974 of file hoc_oop.cpp.

◆ free_objectdata()

static void free_objectdata ( Objectdata od,
cTemplate ctemplate 
)
static

Definition at line 1937 of file hoc_oop.cpp.

◆ hoc_add_publiclist()

void hoc_add_publiclist ( Symbol s)

Definition at line 1661 of file hoc_oop.cpp.

◆ hoc_allobjects()

void hoc_allobjects ( void  )

Definition at line 1997 of file hoc_oop.cpp.

◆ hoc_allobjects1()

void hoc_allobjects1 ( Symlist sl,
int  nspace 
)
static

Definition at line 2016 of file hoc_oop.cpp.

◆ hoc_allobjects2()

void hoc_allobjects2 ( Symbol s,
int  nspace 
)
static

Definition at line 2038 of file hoc_oop.cpp.

◆ hoc_allobjectvars()

void hoc_allobjectvars ( void  )

Definition at line 2057 of file hoc_oop.cpp.

◆ hoc_asgn_obj_to_str()

void hoc_asgn_obj_to_str ( void  )

Definition at line 1397 of file hoc_oop.cpp.

◆ hoc_begintemplate()

void hoc_begintemplate ( Symbol t1)

Definition at line 1515 of file hoc_oop.cpp.

◆ hoc_cmp_otype()

void hoc_cmp_otype ( void  )

Definition at line 789 of file hoc_oop.cpp.

◆ hoc_constobject()

void hoc_constobject ( void  )

Definition at line 845 of file hoc_oop.cpp.

◆ hoc_decl()

Symbol* hoc_decl ( Symbol s)

Definition at line 1646 of file hoc_oop.cpp.

◆ hoc_endtemplate()

void hoc_endtemplate ( Symbol t)

Definition at line 1553 of file hoc_oop.cpp.

◆ hoc_exec_cmd()

void hoc_exec_cmd ( void  )

Definition at line 354 of file hoc_oop.cpp.

◆ hoc_external_var()

void hoc_external_var ( Symbol s)

Definition at line 1673 of file hoc_oop.cpp.

◆ hoc_install_hoc_obj()

void hoc_install_hoc_obj ( void  )

Definition at line 49 of file hoc_oop.cpp.

◆ hoc_known_type()

void hoc_known_type ( void  )

Definition at line 793 of file hoc_oop.cpp.

◆ hoc_list_allobjref()

static void hoc_list_allobjref ( Symlist sl,
Objectdata data,
int  depth 
)
static

Definition at line 2063 of file hoc_oop.cpp.

◆ hoc_newobj()

void hoc_newobj ( void  )

Definition at line 591 of file hoc_oop.cpp.

◆ hoc_newobj1()

Object* hoc_newobj1 ( Symbol sym,
int  narg 
)

Definition at line 502 of file hoc_oop.cpp.

◆ hoc_newobj_arg()

void hoc_newobj_arg ( void  )

Definition at line 576 of file hoc_oop.cpp.

◆ hoc_newobj_ret()

void hoc_newobj_ret ( void  )

Definition at line 587 of file hoc_oop.cpp.

◆ hoc_number_add_object()

void hoc_number_add_object ( void  )

Definition at line 2375 of file hoc_oop.cpp.

◆ hoc_number_div_object()

void hoc_number_div_object ( void  )

Definition at line 2399 of file hoc_oop.cpp.

◆ hoc_number_mul_object()

void hoc_number_mul_object ( void  )

Definition at line 2391 of file hoc_oop.cpp.

◆ hoc_number_object_binary_op_helper()

static void hoc_number_object_binary_op_helper ( const char *  method_name)
static

Definition at line 2205 of file hoc_oop.cpp.

◆ hoc_number_pow_object()

void hoc_number_pow_object ( void  )

Definition at line 2407 of file hoc_oop.cpp.

◆ hoc_number_sub_object()

void hoc_number_sub_object ( void  )

Definition at line 2383 of file hoc_oop.cpp.

◆ hoc_ob_check()

void hoc_ob_check ( int  type)

Definition at line 1711 of file hoc_oop.cpp.

◆ hoc_ob_pointer()

void hoc_ob_pointer ( void  )

Definition at line 1373 of file hoc_oop.cpp.

◆ hoc_object_add()

void hoc_object_add ( void  )

Definition at line 2237 of file hoc_oop.cpp.

◆ hoc_object_add_number()

void hoc_object_add_number ( void  )

Definition at line 2371 of file hoc_oop.cpp.

◆ hoc_object_asgn()

void hoc_object_asgn ( void  )

Definition at line 1404 of file hoc_oop.cpp.

◆ hoc_object_binary_op_helper()

static void hoc_object_binary_op_helper ( const char *  method_name)
static

Definition at line 2135 of file hoc_oop.cpp.

◆ hoc_object_comparison_call()

static void hoc_object_comparison_call ( Object **  obj1_ptr,
Object **  obj2_ptr,
Object obj1,
Symbol method_sym 
)
static

Definition at line 2295 of file hoc_oop.cpp.

◆ hoc_object_comparison_fallback()

static void hoc_object_comparison_fallback ( Object **  obj1_ptr,
Object **  obj2_ptr,
bool  is_equality 
)
static

Definition at line 2306 of file hoc_oop.cpp.

◆ hoc_object_comparison_setup()

static bool hoc_object_comparison_setup ( Object **&  obj1_ptr,
Object **&  obj2_ptr,
Object *&  obj1,
Object *&  obj2,
const char *  method_name,
bool  is_equality 
)
static

Definition at line 2261 of file hoc_oop.cpp.

◆ hoc_object_component()

void hoc_object_component ( void  )

Definition at line 982 of file hoc_oop.cpp.

◆ hoc_object_div()

void hoc_object_div ( void  )

Definition at line 2249 of file hoc_oop.cpp.

◆ hoc_object_div_number()

void hoc_object_div_number ( void  )

Definition at line 2395 of file hoc_oop.cpp.

◆ hoc_object_eq()

void hoc_object_eq ( void  )

Definition at line 2314 of file hoc_oop.cpp.

◆ hoc_object_eval()

void hoc_object_eval ( void  )

Definition at line 1346 of file hoc_oop.cpp.

◆ hoc_object_id()

void hoc_object_id ( void  )

Definition at line 889 of file hoc_oop.cpp.

◆ hoc_object_mul()

void hoc_object_mul ( void  )

Definition at line 2245 of file hoc_oop.cpp.

◆ hoc_object_mul_number()

void hoc_object_mul_number ( void  )

Definition at line 2387 of file hoc_oop.cpp.

◆ hoc_object_ne()

void hoc_object_ne ( void  )

Definition at line 2336 of file hoc_oop.cpp.

◆ hoc_object_number_binary_op_helper()

static void hoc_object_number_binary_op_helper ( const char *  method_name)
static

Definition at line 2172 of file hoc_oop.cpp.

◆ hoc_object_pop()

void hoc_object_pop ( void  )

Definition at line 271 of file hoc_oop.cpp.

◆ hoc_object_pow()

void hoc_object_pow ( void  )

Definition at line 2253 of file hoc_oop.cpp.

◆ hoc_object_pow_number()

void hoc_object_pow_number ( void  )

Definition at line 2403 of file hoc_oop.cpp.

◆ hoc_object_push()

void hoc_object_push ( void  )

Definition at line 241 of file hoc_oop.cpp.

◆ hoc_object_pushed()

void hoc_object_pushed ( void  )

Definition at line 263 of file hoc_oop.cpp.

◆ hoc_object_sub()

void hoc_object_sub ( void  )

Definition at line 2241 of file hoc_oop.cpp.

◆ hoc_object_sub_number()

void hoc_object_sub_number ( void  )

Definition at line 2379 of file hoc_oop.cpp.

◆ hoc_objectarg()

void hoc_objectarg ( void  )

Definition at line 830 of file hoc_oop.cpp.

◆ hoc_objectdata_restore()

Objectdata* hoc_objectdata_restore ( Objectdata obdsav)

Definition at line 147 of file hoc_oop.cpp.

◆ hoc_objectdata_save()

Objectdata* hoc_objectdata_save ( void  )

Definition at line 137 of file hoc_oop.cpp.

◆ hoc_objectvar()

void hoc_objectvar ( void  )

Definition at line 797 of file hoc_oop.cpp.

◆ hoc_objvardecl()

void hoc_objvardecl ( void  )

Definition at line 756 of file hoc_oop.cpp.

◆ hoc_obvar_declare()

void hoc_obvar_declare ( Symbol sym,
int  type,
int  pmes 
)

Definition at line 156 of file hoc_oop.cpp.

◆ hoc_push_current_object()

void hoc_push_current_object ( void  )

Definition at line 133 of file hoc_oop.cpp.

◆ hoc_resize_toplevel()

int hoc_resize_toplevel ( int  more)

Definition at line 290 of file hoc_oop.cpp.

◆ hoc_which_template()

Symbol* hoc_which_template ( Symbol s)

Definition at line 1497 of file hoc_oop.cpp.

◆ nrn_get_gui_redirect_obj()

Object* nrn_get_gui_redirect_obj ( )

Definition at line 649 of file hoc_oop.cpp.

◆ nrn_sec_pop()

struct Section* nrn_sec_pop ( )

Definition at line 753 of file cabcode.cpp.

◆ objectpath()

int objectpath ( Object ob,
Object oblook,
char *  path,
int  depth 
)

Definition at line 1791 of file hoc_oop.cpp.

◆ oc_restore_hoc_oop()

void oc_restore_hoc_oop ( Object **  a1,
Objectdata **  a2,
int *  a4,
Symlist **  a5 
)

Definition at line 444 of file hoc_oop.cpp.

◆ oc_save_hoc_oop()

void oc_save_hoc_oop ( Object **  a1,
Objectdata **  a2,
int *  a4,
Symlist **  a5 
)

Definition at line 428 of file hoc_oop.cpp.

◆ pathprepend()

void pathprepend ( char *  path,
const char *  name,
const char *  indx 
)

Definition at line 1781 of file hoc_oop.cpp.

◆ poptemplate()

static Templatedatum* poptemplate ( void  )
static

Definition at line 204 of file hoc_oop.cpp.

◆ range_suffix()

static void range_suffix ( Symbol sym,
int  nindex,
int  narg 
)
static

Definition at line 906 of file hoc_oop.cpp.

Variable Documentation

◆ connect_obsec_

int connect_obsec_
static

Definition at line 31 of file hoc_oop.cpp.

◆ gui_redirect_obj_

Object* gui_redirect_obj_
static

Definition at line 648 of file hoc_oop.cpp.

◆ hoc_in_template

int hoc_in_template = 0

Definition at line 130 of file hoc_oop.cpp.

◆ hoc_max_builtin_class_id

int hoc_max_builtin_class_id = -1

Definition at line 41 of file hoc_oop.cpp.

◆ hoc_obj_

Symbol* hoc_obj_
static

Definition at line 43 of file hoc_oop.cpp.

◆ hoc_object_pathname_bufsize

constexpr std::size_t hoc_object_pathname_bufsize = 512
constexpr

Definition at line 1780 of file hoc_oop.cpp.

◆ hoc_print_first_instance

int hoc_print_first_instance = 1

Definition at line 40 of file hoc_oop.cpp.

◆ hoc_thisobject

Object* hoc_thisobject

Definition at line 126 of file hoc_oop.cpp.

◆ hoc_top_level_data

Objectdata* hoc_top_level_data

Definition at line 128 of file hoc_oop.cpp.

◆ icntobjectdata

int icntobjectdata = 0
static

Definition at line 125 of file hoc_oop.cpp.

◆ icnttoplevel

int icnttoplevel
static

Definition at line 129 of file hoc_oop.cpp.

◆ nrnpy_call_obj_method

int(* nrnpy_call_obj_method) (Object *obj, const char *method, Object *obj2) ( Object obj,
const char *  method,
Object obj2 
) = nullptr

Definition at line 45 of file hoc_oop.cpp.

◆ nrnpy_call_obj_method_double

int(* nrnpy_call_obj_method_double) (Object *obj, const char *method, double value) ( Object obj,
const char *  method,
double  value 
) = nullptr

Definition at line 46 of file hoc_oop.cpp.

◆ nrnpy_pyobj_sym_

Symbol* nrnpy_pyobj_sym_ {}

Definition at line 26 of file hoc_oop.cpp.

◆ obj_stack_

Object* obj_stack_[OBJ_STACK_SIZE+1]
static

Definition at line 238 of file hoc_oop.cpp.

◆ obj_stack_loc

int obj_stack_loc
static

Definition at line 239 of file hoc_oop.cpp.

◆ py_exposed_classes

std::vector<const char*> py_exposed_classes {}

Definition at line 38 of file hoc_oop.cpp.

◆ section_object_seen

int section_object_seen

Definition at line 29 of file hoc_oop.cpp.

◆ template_id

int template_id
static

Definition at line 1513 of file hoc_oop.cpp.

◆ templatestack

Templatedatum templatestack[NTEMPLATESTACK]
static

Definition at line 201 of file hoc_oop.cpp.

◆ templatestackp

Templatedatum* templatestackp = templatestack
static

Definition at line 202 of file hoc_oop.cpp.