api_get_body (public)
api_get_body proc_name
Defined in packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl
This function returns the body of a Tcl proc or an XOTcl method.
- Parameters:
- proc_name (required)
- the name spec of the proc
- Returns:
- body of the specified proc
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_api_browser_api_get_body
Source code: # # In case the proc_name contains magic chars, these have to be # escaped for Tcl commands expecting a pattern (e.g. "info procs") # regsub -all -- {([?*])} $proc_name {\\\1} proc_name_pattern if {[namespace which ::xo::api] ne "" && [regexp {^(.*) (inst)?proc (.*)$} $proc_name match obj prefix method]} { set method [lindex $proc_name end] if {[regexp {^(.*) (.*)$} $obj match scope obj]} { if {[::xo::api scope_eval $scope ::nsf::is object $obj]} { set body [::xo::api get_method_body $scope ::$obj $prefix $method] set isNx [::xo::api scope_eval $scope ::nsf::directdispatch ::$obj ::nsf::methods::object::info::hastype ::nx::Class] } } else { if {[::nsf::is object $obj]} { set body [::xo::api get_method_body "" ::$obj $prefix $method] set isNx [::nsf::directdispatch ::$obj ::nsf::methods::object::info::hastype ::nx::Class] } } if {[info exists body]} { # # Beautify source code: delete the leading indent. # First check, if we have a nonempty indent... # set lines [split $body \n] set firstNonEmptyLine "" foreach line $lines { if {[regexp {^(\s+)\S} $line . indent]} { break } } # # if we have some indent, remove it from the lines. # if {[info exists indent]} { set body [ns_trim -prefix $indent $body] } if {$isNx} { set doc [::xo::api get_doc_block $body body] } return $body } } elseif {[namespace which ::xo::api] ne "" && [regexp {^([^ ]+) (Class|Object) (.*)$} $proc_name . thread kind obj]} { return [::xo::api get_object_source $thread $obj] } elseif {[namespace which ::xo::api] ne "" && [regexp {(Class|Object) (.*)$} $proc_name . kind obj]} { return [::xo::api get_object_source "" $obj] } elseif {[info procs $proc_name_pattern] ne ""} { return [info body $proc_name] } elseif {[info procs ::nsf::procs::$proc_name_pattern] ne ""} { return [::nx::Object info method body ::nsf::procs::$proc_name] } else { return $proc_name }XQL Not present: Generic, PostgreSQL, Oracle