PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/tags/jsdoc_toolkit-2.2.1/jsdoc-toolkit/app/frame/Reflection.js

http://jsdoc-toolkit.googlecode.com/
JavaScript | 26 lines | 22 code | 3 blank | 1 comment | 6 complexity | 14075d115109486506e3ad50abb28ed8 MD5 | raw file
 1/**@constructor*/
 2function Reflection(obj) {
 3	this.obj = obj;
 4}
 5
 6Reflection.prototype.getConstructorName = function() {
 7	if (this.obj.constructor.name) return this.obj.constructor.name;
 8	var src = this.obj.constructor.toSource();
 9	var name = src.substring(name.indexOf("function")+8, src.indexOf('(')).replace(/ /g,'');
10	return name;
11}
12
13Reflection.prototype.getMethod = function(name) {
14	for (var p in this.obj) {
15		if (p == name && typeof(this.obj[p]) == "function") return this.obj[p];
16	}
17	return null;
18}
19
20Reflection.prototype.getParameterNames = function() {
21	var src = this.obj.toSource();
22	src = src.substring(
23		src.indexOf("(", 8)+1, src.indexOf(")")
24	);
25	return src.split(/, ?/);
26}