pro mg_object::help
compile_opt strictarr
help, self, /objects
end
function mg_object::toString
compile_opt strictarr
help, self, output=output
tokens = strsplit(output, /extract)
return, string(tokens[3])
end
function mg_object::_getClassInfo, classname, output=output, $
function_start=functionStart
compile_opt strictarr, hidden
result = [classname, string(replicate(byte('='), strlen(classname)))]
functions_line = where(stregex(output, '^Compiled Functions:$', /boolean))
matchesClassname = stregex(output, '^' + classname, /boolean)
ind = where(matchesClassname, nMethods)
for m = 0L, nMethods - 1L do begin
line = output[ind[m]]
tokens = strsplit(line, /extract, count=ntokens)
args_decl = ''
for a = 1L, ntokens - 1L do begin
if (a eq 1L && tokens[a] eq 'self') then continue
if (stregex(tokens[a], '[A-Z_$]+', /boolean)) then begin
args_decl += string(args_decl eq '' ? '' : ', ', tokens[a], tokens[a], $
format='(%"%s%s=%s")')
endif else begin
args_decl += string(args_decl eq '' ? '' : ', ', tokens[a], $
format='(%"%s%s")')
endelse
endfor
method_name = strlowcase(tokens[0])
if (ind[m] gt functions_line[0]) then begin
decl = string(method_name, args_decl, format='(%"function %s(%s)")')
endif else begin
decl = string(method_name, args_decl eq '' ? '' : ',', args_decl, $
format='(%"pro %s%s %s")')
endelse
result = [result, decl]
endfor
parents = obj_class(classname, /superclass)
if (parents[0] ne '') then begin
for p = 0L, n_elements(parents) - 1L do begin
result = [result, '', self->_getClassInfo(parents[p], $
output=output, $
function_start=functionStart)]
endfor
endif
return, result
end
function mg_object::_overloadHelp, varname
compile_opt strictarr
help, /routines, output=output
functionStart = (where(strmatch(output, 'Compiled Functions:')))[0]
methodLines = self->_getClassInfo(obj_class(self), $
output=output, $
function_start=functionStart)
return, methodLines
end
pro mg_object__define
compile_opt strictarr
define = { mg_object, inherits IDL_Object }
end