11///
2- /// @class functionNode
2+ /// Class: functionNode
33///
4- /// Represents a single function, inside JS, webGL, or openGL.
5- /// This handles the raw state, converted state, etc.
4+ /// [INTERNAL] Represents a single function, inside JS, webGL, or openGL.
5+ ///
6+ /// This handles all the raw state, converted state, etc. Of a single function.
67///
7- /// # JS Related properties
8- ///
9- /// @property {JS Function } jsFunction The JS Function the node represents
10- /// @property {String } jsFunctionString jsFunction.toString()
11- /// @property {[String,...] } paramNames Parameter names of the function
12- /// @property {[String,...] } paramType Shader land parameter type assumption
13- /// @property {Boolean } isRootKernal Special indicator, for kernal function
14- ///
15- /// # Webgl related properties
16- ///
17- /// @property {String } webglFunctionString webgl converted function string
18- ///
19- /// # Code analysis properties (after converting to webgl)
20- ///
21- /// @property {[String,...] } calledFunctions List of all the functions called
22- /// @property {[String,...] } initVariables List of variables initialized in the function
23- /// @property {[String,...] } readVariables List of variables read operations occur
24- /// @property {[String,...] } writeVariables List of variables write operations occur
8+ /// Properties:
9+ /// jsFunction - {JS Function} The JS Function the node represents
10+ /// jsFunctionString - {String} jsFunction.toString()
11+ /// paramNames - {[String,...]} Parameter names of the function
12+ /// paramType - {[String,...]} Shader land parameter type assumption
13+ /// isRootKernal - {Boolean} Special indicator, for kernal function
14+ /// webglFunctionString - {String} webgl converted function string
15+ /// openglFunctionString - {String} opengl converted function string
16+ /// calledFunctions - {[String,...]} List of all the functions called
17+ /// initVariables - {[String,...]} List of variables initialized in the function
18+ /// readVariables - {[String,...]} List of variables read operations occur
19+ /// writeVariables - {[String,...]} List of variables write operations occur
2520///
2621var functionNode = ( function ( ) {
2722
@@ -30,15 +25,15 @@ var functionNode = (function() {
3025 //----------------------------------------------------------------------------------------------------
3126
3227 ///
33- /// @function functionNode
28+ /// Function: functionNode
3429 ///
35- /// [Constructor] Builds the function with the given JS function, and argument type array.
36- /// If argument types are not provided, they are assumed to be "float*"
30+ /// [Constructor] Builds the function with the given JS function, and argument type array.
3731 ///
38- /// @param {String } Function name to assume, if its null, it attempts to extract from the function
39- /// @param {JS Function } JS Function to do conversion
40- /// @param {[String,...] } Parameter type array, assumes "float" if not given
41- /// @param {String } The return type, assumes float
32+ /// Parameters:
33+ /// functionName - {String} -Function name to assume, if its null, it attempts to extract from the function
34+ /// jsFunction - {JS Function} JS Function to do conversion
35+ /// paramTypeArray - {[String,...]} Parameter type array, assumes all parameters are "float" if not given
36+ /// returnType - {String} The return type, assumes "float" if not given
4237 ///
4338 function functionNode ( functionName , jsFunction , paramTypeArray , returnType ) {
4439
@@ -101,22 +96,34 @@ var functionNode = (function() {
10196 //----------------------------------------------------------------------------------------------------
10297
10398 ///
104- /// @function isFunction
99+ /// Function: isFunction
100+ ///
101+ /// [static] Return TRUE, on a JS function
105102 ///
106- /// @param { JS Function } Object to validate if its a function
103+ /// This is 'static' function, not a class function (functionNode.prototype)
107104 ///
108- /// @return {Boolean } TRUE if the object is a JS function
105+ /// Parameters:
106+ /// funcObj - {JS Function} Object to validate if its a function
107+ ///
108+ /// Returns:
109+ /// {Boolean} TRUE if the object is a JS function
109110 ///
110111 function isFunction ( funcObj ) {
111112 return typeof ( funcObj ) === 'function' ;
112113 }
113114
114115 ///
115- /// @function validateStringIsFunction
116+ /// Function: validateStringIsFunction
117+ ///
118+ /// [static] Return TRUE, on a valid JS function string
119+ ///
120+ /// This is 'static' function, not a class function (functionNode.prototype)
116121 ///
117- /// @param {String } String of JS function to validate
122+ /// Parameters:
123+ /// funcStr - {String} String of JS function to validate
118124 ///
119- /// @return {Boolean } TRUE if the string passes basic validation
125+ /// Returns:
126+ /// {Boolean} TRUE if the string passes basic validation
120127 ///
121128 function validateStringIsFunction ( funcStr ) {
122129 if ( funcStr !== null ) {
@@ -129,11 +136,17 @@ var functionNode = (function() {
129136 var ARGUMENT_NAMES = / ( [ ^ \s , ] + ) / g;
130137
131138 ///
132- /// @function getParamNames
139+ /// Function: getParamNames
133140 ///
134- /// @param {String } String of JS function to extract parameter names
135- ///
136- /// @return {[String, ...] } Array representing all the parameter names
141+ /// [static] Return list of parameter names extracted from the JS function string
142+ ///
143+ /// This is 'static' function, not a class function (functionNode.prototype)
144+ ///
145+ /// Parameters:
146+ /// funcStr - {String} String of JS function to validate
147+ ///
148+ /// Returns:
149+ /// {[String, ...]} Array representing all the parameter names
137150 ///
138151 function getParamNames ( func ) {
139152 var fnStr = func . toString ( ) . replace ( STRIP_COMMENTS , '' ) ;
@@ -145,20 +158,26 @@ var functionNode = (function() {
145158
146159 // Passing it to the class object, in case it is needed elsewhere
147160 // Note, support for this is not guranteed across versions.
148- functionNode . _isFunction = isFunction ;
149- functionNode . _validateStringIsFunction = validateStringIsFunction ;
150- functionNode . _getParamNames = getParamNames ;
161+ functionNode . isFunction = isFunction ;
162+ functionNode . validateStringIsFunction = validateStringIsFunction ;
163+ functionNode . getParamNames = getParamNames ;
151164
152165 //
153166 // Core function
154167 //----------------------------------------------------------------------------------------------------
155168
156169 ///
157- /// @function functionNode.getJS_AST
170+ /// Function: getJS_AST
171+ ///
172+ /// Parses the class function JS, and returns its Abstract Syntax Tree object.
173+ ///
174+ /// This is used internally to convert to shader code
158175 ///
159- /// @param {JISON Parser } Parser to use, assumes in scope "parser" if null
176+ /// Parameters:
177+ /// inParser - {JISON Parser} Parser to use, assumes in scope "parser" if null
160178 ///
161- /// @return {AST Object } The function AST Object, note that result is cached under this.jsFunctionAST;
179+ /// Returns:
180+ /// {AST Object} The function AST Object, note that result is cached under this.jsFunctionAST;
162181 ///
163182 functionNode . prototype . getJS_AST = function getJS_AST ( inParser ) {
164183 if ( this . jsFunctionAST ) {
@@ -183,9 +202,12 @@ var functionNode = (function() {
183202 }
184203
185204 ///
186- /// @function functionNode. getWebglString
205+ /// Function: getWebglString
187206 ///
188- /// @return {String } webgl function string, result is cached under this.webglFunctionString
207+ /// Returns the converted webgl shader function equivalent of the JS function
208+ ///
209+ /// Returns:
210+ /// {String} webgl function string, result is cached under this.webglFunctionString
189211 ///
190212 functionNode . prototype . getWebglFunctionString = function getWebglFunctionString ( ) {
191213 if ( this . webglFunctionString ) {
@@ -195,5 +217,18 @@ var functionNode = (function() {
195217 return this . webglFunctionString = functionNode_webgl ( this ) ;
196218 }
197219
220+ ///
221+ /// Function: setWebglString
222+ ///
223+ /// Set the webglFunctionString value, overwriting it
224+ ///
225+ /// Parameters:
226+ /// shaderCode - {String} Shader code string, representing the function
227+ ///
228+ functionNode . prototype . getWebglFunctionString = function getWebglFunctionString ( shaderCode ) {
229+ this . webglFunctionString = shaderCode ;
230+ }
231+
232+
198233 return functionNode ;
199234} ) ( ) ;
0 commit comments