NEURON
oc2iv.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 
3 #include <stdio.h>
4 #include "InterViews/resource.h"
5 #include "oc2iv.h"
6 #include "ocpointer.h"
7 
8 #include "parse.hpp"
11 extern Object* hoc_thisobject;
12 extern Symlist* hoc_symlist;
13 
14 char* Oc2IV::object_str(const char* name, Object* ob) {
15  if (ob && ob->ctemplate->constructor) {
16  if (is_obj_type(ob, "Pointer") && strcmp(name, "s") == 0) {
17  return ((OcPointer*)(ob->u.this_pointer))->s_;
18  }
19  }else{
20  return *object_pstr(name, ob);
21  }
22  return 0;
23 }
24 
25 char** Oc2IV::object_pstr(const char* name, Object* ob) {
26  Objectdata* od;
27  Symlist* sl;
28  if (ob) {
29  if (ob->ctemplate->constructor) {
30  return NULL;
31  }else{
32  od = ob->u.dataspace;
33  sl = ob->ctemplate->symtable;
34  }
35  }else{
36  od = hoc_top_level_data;
38  }
39  Symbol* sym = hoc_table_lookup(name, sl);
40  if (sym && sym->type == STRING) {
41  return ::object_pstr(sym, od);
42  }else{
43  return 0;
44  }
45 }
46 
48  restored_ = true;
49  save();
50 }
52  restore();
53 }
55  if (restored_ == true) {
56  if (hoc_objectdata == hoc_top_level_data) {
57  obdsav_ = NULL;
58  }else{
59  obdsav_ = hoc_objectdata;
60  }
61  obsav_ = hoc_thisobject;
62  symsav_ = hoc_symlist;
64  hoc_thisobject = NULL;
65  hoc_symlist = hoc_top_level_symlist;
66  restored_ = false;
67  }
68 }
69 
70 extern int hoc_in_template;
71 
73  if (restored_ == false) {
74  if (obdsav_ || hoc_in_template) {
75  hoc_objectdata = obdsav_;
76  }else{
78  }
79  hoc_thisobject = obsav_;
80  hoc_symlist = symsav_;
81  restored_ = true;
82  }
83 }
84 
Definition: hocdec.h:84
static char * object_str(const char *symname, Object *=NULL)
Definition: oc2iv.cpp:14
short type
Definition: model.h:58
int hoc_in_template
Definition: hoc_oop.cpp:136
void * this_pointer
Definition: hocdec.h:231
virtual ~ParseTopLevel()
Definition: oc2iv.cpp:51
Symlist * hoc_top_level_symlist
Definition: symbol.cpp:41
sl
Definition: seclist.cpp:186
ParseTopLevel()
Definition: oc2iv.cpp:47
static char ** object_pstr(const char *symname, Object *=NULL)
Definition: oc2iv.cpp:25
Objectdata * hoc_objectdata
Definition: hoc_oop.cpp:133
Objectdata * dataspace
Definition: hocdec.h:230
#define STRING
Definition: bbslsrv.cpp:9
Object * hoc_thisobject
Definition: hoc_oop.cpp:132
void restore()
Definition: oc2iv.cpp:72
Definition: model.h:57
static double restore(void *v)
Symlist * hoc_symlist
char * name
Definition: init.cpp:16
Objectdata * hoc_top_level_data
Definition: hoc_oop.cpp:134
static double save(void *v)
Definition: ocbox.cpp:340
Definition: hocdec.h:226
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:60
char ** object_pstr(Symbol *sym, Objectdata *od)
Definition: oc2iv.h:45
int is_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2223
void save()
Definition: oc2iv.cpp:54
union Object::@54 u
return NULL
Definition: cabcode.cpp:461