8
8
* feature that's normally disabled.
9
9
* ----------------------------------------------------------------------------- */
11
char cvsroot_browser_cxx[] = "$Header: /cvsroot/swig/SWIG/Source/Modules/browser.cxx,v 1.7 2006/03/06 22:50:56 wsfulton Exp $";
11
char cvsroot_browser_cxx[] = "$Header: /cvsroot/swig/SWIG/Source/Modules/browser.cxx,v 1.9 2006/11/15 23:45:47 wsfulton Exp $";
13
13
#include "swigmod.h"
18
} static FILE *out = 0;
21
19
static Node *view_top = 0;
23
class Browser : public Dispatcher {
21
class Browser:public Dispatcher {
24
22
void show_checkbox(Node *t, Node *n) {
26
if (Getmeta(n,"visible")) {
24
if (Getmeta(n, "visible")) {
30
Printf(out,"<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n,n);
28
Printf(out, "<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n, n);
32
Printf(out,"<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n,n);
30
Printf(out, "<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n, n);
35
33
void show_attributes(Node *obj) {
36
if (!Getmeta(obj,"visible")) return;
34
if (!Getmeta(obj, "visible"))
37
36
String *os = NewString("");
43
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
44
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
45
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
42
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
43
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
47
} else if (Cmp(k,"parms") == 0) {
45
} else if (Cmp(k, "parms") == 0) {
48
46
String *o = NewString("");
49
Printf(o,"%s", ParmList_protostr(Getattr(obj,k)));
50
Replaceall(o,"&","&");
51
Replaceall(o,"<","<");
52
Replaceall(o,">",">");
53
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj,k), k, o);
47
Printf(o, "%s", ParmList_protostr(Getattr(obj, k)));
48
Replaceall(o, "&", "&");
49
Replaceall(o, "<", "<");
50
Replaceall(o, ">", ">");
51
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
58
if (DohIsString(Getattr(obj,k))) {
59
o = Str(Getattr(obj,k));
56
if (DohIsString(Getattr(obj, k))) {
57
o = Str(Getattr(obj, k));
63
Replaceall(o,"&","&");
64
Replaceall(o,"<","<");
65
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj,k), k, o, trunc);
61
Replaceall(o, "&", "&");
62
Replaceall(o, "<", "<");
63
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
68
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
66
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
73
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
71
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
78
76
virtual int emit_one(Node *n) {
79
77
char *tag = Char(nodeType(n));
80
78
char *file = Char(Getfile(n));
81
int line = Getline(n);
82
char *name = GetChar(n,"name");
79
int line = Getline(n);
80
char *name = GetChar(n, "name");
84
82
show_checkbox(view_top, n);
85
Printf(out,"<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
83
Printf(out, "<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
87
Printf(out," (%s)", name);
85
Printf(out, " (%s)", name);
89
Printf(out,". %s:%d\n", file, line);
87
Printf(out, ". %s:%d\n", file, line);
91
89
Dispatcher::emit_one(n);
94
92
virtual int emit_children(Node *n) {
95
if (Getmeta(n,"visible")) {
96
Printf(out,"<blockquote>\n");
93
if (Getmeta(n, "visible")) {
94
Printf(out, "<blockquote>\n");
97
95
Dispatcher::emit_children(n);
98
Printf(out,"</blockquote>\n");
96
Printf(out, "</blockquote>\n");
179
177
static void display(FILE *f, Node *n) {
180
178
/* Print standard HTML header */
182
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
183
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
184
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
185
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
180
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
181
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
182
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
183
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
186
184
if (n != tree_top) {
187
Printf(f," [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
185
Printf(f, " [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
189
Printf(f," [ <a href=\"symbol.html\">Symbols</a> ]");
190
Printf(f,"<br><hr><p>\n");
187
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
188
Printf(f, "<br><hr><p>\n");
194
192
browse->emit_one(n);
196
194
/* Print standard footer */
197
Printf(f,"<br><hr></BODY></HTML>\n");
195
Printf(f, "<br><hr></BODY></HTML>\n");
232
Setmeta(n,"visible","1");
230
Setmeta(n, "visible", "1");
237
235
void raw_data(FILE *out, Node *obj) {
239
238
if (DohIsMapping(obj)) {
242
241
String *os = NewString("");
243
Printf(os,"Hash {\n");
242
Printf(os, "Hash {\n");
248
247
const char *trunc = "";
249
if (DohIsString(Getattr(obj,k))) {
250
o = Str(Getattr(obj,k));
248
if (DohIsString(Getattr(obj, k))) {
249
o = Str(Getattr(obj, k));
251
250
if (Len(o) > 70) {
254
Replaceall(o,"<","<");
255
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj,k), k, o, trunc);
253
Replaceall(o, "<", "<");
254
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
258
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
257
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
263
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
262
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
265
264
} else if (DohIsString(obj)) {
266
265
String *o = Str(obj);
267
Replaceall(o,"<","<");
268
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(o));
266
Replaceall(o, "<", "<");
267
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(o));
270
269
} else if (DohIsSequence(obj)) {
272
271
String *os = NewString("");
273
Printf(os,"List [\n");
272
Printf(os, "List [\n");
274
273
for (i = 0; i < Len(obj); i++) {
275
DOH *o = Getitem(obj,i);
274
DOH *o = Getitem(obj, i);
276
275
const char *trunc = "";
277
276
if (DohIsString(o)) {
278
277
String *s = Str(o);
279
278
if (Len(s) > 70) {
282
Replaceall(o,"<","<");
283
Printf(os," <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o,i,s, trunc);
281
Replaceall(o, "<", "<");
282
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
286
Printf(os," <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
285
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
290
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
289
Printf(out, "<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
297
296
if (!swill_getargs("p(n)", &n)) {
300
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
301
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
302
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
303
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
304
Printf(f,"<br><hr><p>\n");
299
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
300
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
301
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
302
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
303
Printf(f, "<br><hr><p>\n");
308
307
/* Print standard footer */
309
Printf(f,"<br><hr></BODY></HTML>\n");
308
Printf(f, "<br><hr></BODY></HTML>\n");
312
311
void symbol_handler(FILE *f) {
316
Printf(f,"<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", PACKAGE_VERSION);
317
Printf(f,"<b>SWIG-%s</b><br>\n", PACKAGE_VERSION);
318
Printf(f,"[ <a href=\"exit.html\">Exit</a> ]");
319
Printf(f," [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
320
Printf(f," [ <a href=\"symbol.html\">Symbols</a> ]");
321
Printf(f,"<br><hr><p>\n");
315
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
316
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
317
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
318
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
319
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
320
Printf(f, "<br><hr><p>\n");
323
322
if (!swill_getargs("p(sym)|s(name)", &sym, &name)) {
324
323
sym = Swig_symbol_getscope("");
328
Printf(f,"No symbol table specified!\n");
327
Printf(f, "No symbol table specified!\n");
332
331
String *q = Swig_symbol_qualifiedscopename(sym);
334
Printf(f,"<b>Symbol table: :: (global)</b><br>\n");
333
Printf(f, "<b>Symbol table: :: (global)</b><br>\n");
336
Printf(f,"<b>Symbol table: %s</b><br>\n", q);
335
Printf(f, "<b>Symbol table: %s</b><br>\n", q);
341
fprintf(f,"<p><form action=\"symbol.html\" method=GET>\n");
342
fprintf(f,"Symbol lookup: <input type=text name=name size=40></input><br>\n");
343
fprintf(f,"<input type=hidden name=sym value=\"0x%x\">\n", sym);
344
fprintf(f,"Submit : <input type=submit></input>\n");
345
fprintf(f,"</form>");
340
fprintf(f, "<p><form action=\"symbol.html\" method=GET>\n");
341
fprintf(f, "Symbol lookup: <input type=text name=name size=40></input><br>\n");
342
fprintf(f, "<input type=hidden name=sym value=\"0x%x\">\n", sym);
343
fprintf(f, "Submit : <input type=submit></input>\n");
344
fprintf(f, "</form>");
348
Node *n = Swig_symbol_clookup(name,sym);
349
Printf(f,"Symbol '%s':\n", name);
350
Printf(f,"<blockquote>\n");
347
Node *n = Swig_symbol_clookup(name, sym);
348
Printf(f, "Symbol '%s':\n", name);
349
Printf(f, "<blockquote>\n");
352
Printf(f,"Not defined!\n");
351
Printf(f, "Not defined!\n");
356
Printf(f,"</blockquote>\n");
355
Printf(f, "</blockquote>\n");
359
Printf(f,"<p><b>Nested scopes</b><br>\n");
360
Printf(f,"<blockquote><pre>\n");
358
Printf(f, "<p><b>Nested scopes</b><br>\n");
359
Printf(f, "<blockquote><pre>\n");
363
362
h = firstChild(sym);
365
Printf(f,"<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h,"name"));
364
Printf(f, "<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h, "name"));
366
365
h = nextSibling(h);
369
Printf(f,"</pre></blockquote>\n");
371
Printf(f,"<p><b>Symbol table contents</b></br>\n");
372
raw_data(f,Getattr(sym,"symtab"));
373
Printf(f,"<br><hr></BODY></HTML>\n");
368
Printf(f, "</pre></blockquote>\n");
370
Printf(f, "<p><b>Symbol table contents</b></br>\n");
371
raw_data(f, Getattr(sym, "symtab"));
372
Printf(f, "<br><hr></BODY></HTML>\n");
379
Swig_browser(Node *top, int port) {
377
void Swig_browser(Node *top, int port) {
380
378
#ifdef SWIG_SWILL
382
380
browser_exit = 0;
384
382
/* Initialize the server */
385
383
sport = swill_init(port);
387
Printf(stderr,"Couldn't open socket on port %d. Sorry.\n", port);
385
Printf(stderr, "Couldn't open socket on port %d. Sorry.\n", port);
390
388
browse = new Browser();
391
Setmeta(top,"visible","1");
389
Setmeta(top, "visible", "1");
394
Printf(stderr,"SWIG: Tree browser listening on port %d\n", sport);
392
Printf(stderr, "SWIG: Tree browser listening on port %d\n", sport);
396
swill_handle("exit.html", exit_handler,0);
394
swill_handle("exit.html", exit_handler, 0);
397
395
swill_handle("index.html", node_handler, 0);
398
swill_handle("hide.html", hide_handler,0);
399
swill_handle("show.html", show_handler,0);
400
swill_handle("data.html", data_handler,0);
396
swill_handle("hide.html", hide_handler, 0);
397
swill_handle("show.html", show_handler, 0);
398
swill_handle("data.html", data_handler, 0);
401
399
swill_handle("symbol.html", symbol_handler, 0);
402
400
swill_netscape("index.html");
404
402
while (!browser_exit) {
407
Printf(stderr,"Browser terminated.\n");
405
Printf(stderr, "Browser terminated.\n");