pike.git/
lib/
master.pike.in
Branch:
Tag:
Non-build tags
All tags
No tags
2007-06-13
2007-06-13 14:25:30 by Martin Bähr <mbaehr@email.archlab.tuwien.ac.at>
b73c65ebbe76df6208abe3152081e08f14907005 (
47
lines) (+
29
/-
18
)
[
Show
|
Annotate
]
Branch:
7.9
cache source in compile_string() only if enabled.
Rev: lib/master.pike.in:1.396
6:
// Pike is distributed under GPL, LGPL and MPL. See the file COPYING // for more information. //
-
// $Id: master.pike.in,v 1.
395
2007/06/13
13
:
30
:
51
mbaehr Exp $
+
// $Id: master.pike.in,v 1.
396
2007/06/13
14
:
25:
30 mbaehr Exp $
#pike __REAL_VERSION__ //#pragma strict_types
362:
compat_minor, p, o);
-
cache
_source
(
ret
,
source
)
;
+
if (source_
cache
)
+
source
_
cache[
ret
]
=
source;
return ret; }
602:
//! name @expr{"/master"@}, and the program containing the @[main] //! function under @expr{"/main"@}. mapping(string:program|NoValue) programs=(["/master":this_program]);
-
mapping(program:
mapping|
object) documentation = ([]);
+
mapping(program:object) documentation = ([]);
+
mapping(program:string) source_cache;
mapping (program:object|NoValue) objects=([ this_program : this,
756:
return 0; }
-
//! Used to capture the source from programs being compiled to allow later
-
//! extraction of documentation
-
static void cache_source(mixed ret, string source)
-
{
-
if (documentation && !documentation[ret])
-
documentation[ret] = ([ "source":source ]);
-
}
-
+
//! Find the files in which @[mod] is defined, as they may be hidden away in //! joinnodes and dirnodes //!
792:
return files; }
+
//! Enable caching of sources from compile_string()
+
void enable_source_cache()
+
{
+
source_cache = ([]);
+
}
+
//! Show documentation for the item @[obj] //! //! @param obj
804:
object doc_extractor = main_resolv("Tools.AutoDoc.PikeExtractor.extractClass"); string child; program prog;
-
string fname;
+
if (programp(obj)) prog = obj;
821:
prog = object_program(obj->module); }
-
fname = Builtin()->program_defined(prog);
+
-
if (
doc_extractor && (
!documentation[prog]
||
!documentation[prog]->
doc)
)
+
if (!documentation[prog]
&&
doc
_extractor
)
{
-
documentation[prog]
=
(
[
"doc":doc
_
extractor(documentation
[prog]
->
source
||
master_read_file(
fname
)
||""
, sprintf("%O", prog))
])
;
+
string source;
+
if (!source_cache || !source_cache
[prog]
)
+
source
=
master_read_file
(
Builtin()->program_defined(prog));
+
else
+
source = source_cache
[
prog];
+
if
(
source)
+
{
+
catch
+
{
+
documentation[prog]
= doc
_
extractor
(
source
, sprintf("%O", prog))
;
+
}
;
+
//FIXME: handle this error somehow
}
-
+
}
-
if (documentation[prog]
&& documentation[prog]->doc
)
+
if (documentation[prog])
{ if (child)
-
return documentation[prog]->
doc->
findObject(child);
+
return documentation[prog]->findObject(child);
else
-
return documentation[prog]
->doc
;
+
return documentation[prog];
} }