Page 1 of 1

Jsdoc and object

PostPosted: Sun Jun 16, 2013 3:35 pm
by Hans Nieuwenhuis
Hi,

I am trying to get all the jsdoc into my solution.
I do not understand the following issue :

I create a new object and then call a function from that
Code: Select all
var circle1
circle1 = new scopes.sw2013.circle(10,'circle1')
var Area = circle1.getArea()


No jsdoc warnings

No I use a form variable for circle1 ( media)
Code: Select all
forms.tst1.circle1 = new scopes.sw2013.circle(10,'circle1')
var Area = forms.tst1.circle1.getArea()


now the second line gives a jsdoc warning
the method getArea is undefined for object circle1

How can I get rid of this warning ?

Re: Jsdoc and object

PostPosted: Mon Jun 17, 2013 12:15 pm
by patrick
You need to type you form variable. Something like

@type {scopes.sw2013.circle}

Re: Jsdoc and object

PostPosted: Mon Jun 17, 2013 9:37 pm
by Hans Nieuwenhuis
Thanks Patrick,

Tried this, but no change

Re: Jsdoc and object

PostPosted: Tue Jun 18, 2013 12:12 am
by mboegem
what does your circle class look like?

Re: Jsdoc and object

PostPosted: Tue Jun 18, 2013 7:15 am
by Hans Nieuwenhuis
It is just an example, but I want to use this object stuff in my solutions

Code: Select all
/**
* @constructor
* @param {Number} radius
* @param {String} name
* @properties={typeid:24,uuid:"8C416079-AE2E-41D8-A5A3-199B2B018791"}
*/
function circle(radius,name) {

   /**
    * Internal Radius
    * @private // not really needed
    * @type {Number}
    */
   var r=radius   // this.r maakt het mofgelujk om in de aanroep circle2.r=40 te gebruiken maar dat breekt encapsolution
   /**
    * Internal Name
    * @private // not really needed
    * @type {String}
    */
   var cname=name
   
   /**
    * Listeners array
    * @type {Array<Function>}
    */
   var listeners = new Array();
   
   /**
    * set the name of the object
    * @public
    * @return {String}
    */
   this.getName = function(){
      return name
   }

   /**
    * get omtrek
    * @public
    * @return {Number}
    */   
   this.getArea = function(){
      return Math.PI*Math.pow(r,2);
   }
   
   /**
    * get circumference
    * @public
    * @return {Number}
    */
   this.getCircumfrence = function(){
      return 2*Math.PI*r;
   }
   
   /**
    * get radius
    * @public
    * @return {Number}
    */
   this.getRadius = function(){
      return r;
   }
   
   /**
    * @public
    * @param {Number} newValue
    */
   this.setRadius = function(newValue){
      var oldValue = r;
      r = newValue;
      for (var i in listeners){
         listeners[i].apply(this,[cname,oldValue,newValue]); //apply or call
      }
   }
   
   /**
    * @public
    * @param {Function} listener
    */
   this.addChangeListener = function(listener){
      listeners.push(listener)
   }
}