NEURON
oc2iv.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 
3 #include <stdio.h>
4 #include "oc2iv.h"
5 #include "ocpointer.h"
6 
7 #include "parse.hpp"
10 extern Object* hoc_thisobject;
11 extern Symlist* hoc_symlist;
12 
13 char* Oc2IV::object_str(const char* name, Object* ob) {
14  if (ob && ob->ctemplate->constructor) {
15  if (is_obj_type(ob, "Pointer") && strcmp(name, "s") == 0) {
16  return ((OcPointer*) (ob->u.this_pointer))->s_;
17  }
18  } else {
19  return *object_pstr(name, ob);
20  }
21  return 0;
22 }
23 
24 char** Oc2IV::object_pstr(const char* name, Object* ob) {
25  Objectdata* od;
26  Symlist* sl;
27  if (ob) {
28  if (ob->ctemplate->constructor) {
29  return NULL;
30  } else {
31  od = ob->u.dataspace;
32  sl = ob->ctemplate->symtable;
33  }
34  } else {
35  od = hoc_top_level_data;
37  }
38  Symbol* sym = hoc_table_lookup(name, sl);
39  if (sym && sym->type == STRING) {
40  return ::object_pstr(sym, od);
41  } else {
42  return 0;
43  }
44 }
45 
47  restored_ = true;
48  save();
49 }
51  restore();
52 }
54  if (restored_ == true) {
56  obdsav_ = NULL;
57  } else {
59  }
65  restored_ = false;
66  }
67 }
68 
69 extern int hoc_in_template;
70 
72  if (restored_ == false) {
73  if (obdsav_ || hoc_in_template) {
75  } else {
77  }
80  restored_ = true;
81  }
82 }
#define STRING
Definition: bbslsrv.cpp:9
static char ** object_pstr(const char *symname, Object *=NULL)
Definition: oc2iv.cpp:24
static char * object_str(const char *symname, Object *=NULL)
Definition: oc2iv.cpp:13
virtual ~ParseTopLevel()
Definition: oc2iv.cpp:50
Object * obsav_
Definition: oc2iv.h:105
Objectdata * obdsav_
Definition: oc2iv.h:104
Symlist * symsav_
Definition: oc2iv.h:106
void save()
Definition: oc2iv.cpp:53
void restore()
Definition: oc2iv.cpp:71
bool restored_
Definition: oc2iv.h:107
ParseTopLevel()
Definition: oc2iv.cpp:46
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:48
Objectdata * hoc_objectdata
Definition: hoc_oop.cpp:122
int is_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2110
const char * name
Definition: init.cpp:16
int hoc_in_template
Definition: hoc_oop.cpp:125
Symlist * hoc_top_level_symlist
Definition: symdir.cpp:16
Symlist * hoc_symlist
Definition: symbol.cpp:34
Objectdata * hoc_top_level_data
Definition: hoc_oop.cpp:123
Object * hoc_thisobject
Definition: hoc_oop.cpp:121
char ** object_pstr(Symbol *sym, Objectdata *od)
Definition: oc2iv.h:76
#define NULL
Definition: spdefs.h:105
Definition: hocdec.h:173
void * this_pointer
Definition: hocdec.h:178
Objectdata * dataspace
Definition: hocdec.h:177
cTemplate * ctemplate
Definition: hocdec.h:180
union Object::@47 u
Definition: model.h:47
short type
Definition: model.h:48
Definition: hocdec.h:75
Symlist * symtable
Definition: hocdec.h:148
void *(* constructor)(struct Object *)
Definition: hocdec.h:158