diff --git a/.gitignore b/.gitignore index b512c09..6d2223d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +components \ No newline at end of file diff --git a/.scripted b/.scripted index 949006c..8e0b270 100644 --- a/.scripted +++ b/.scripted @@ -6,6 +6,6 @@ } }, "jshint" : { - options: {node: true} + options: {node: true, white:false} } } \ No newline at end of file diff --git a/browser-example/MyClass.js b/browser-example/MyClass.js new file mode 100644 index 0000000..29e1d2b --- /dev/null +++ b/browser-example/MyClass.js @@ -0,0 +1,36 @@ +define([], function(){ +function MyClass (val){ + this.value = val; +} + + +MyClass.prototype = { + + doSomething: function( /*@Default("Default Message")*/msg, /*@Autowired("message")*/msg2, /*@Autowired*/message) { + console.log("default: " +msg ); + console.log("wired: " + this.value ); + console.log("autowired: " +msg2 ); + console.log("autowired(pname): " + message ); + + }, + + + doSomethingElse: function( msg) /*@NotNull*/{ + console.log(msg + " " +this.value); + }, + + doSomethingElseAgain: function( message) /*@Autowired*/{ + console.log("autowired(fn): " + message ); + }, + +}; + + + + + + +return MyClass; +}); + + diff --git a/browser-example/component.json b/browser-example/component.json new file mode 100644 index 0000000..37c6fe6 --- /dev/null +++ b/browser-example/component.json @@ -0,0 +1,13 @@ +{ + + "name": "browser-example", + "version": "0.0.2", + "dependencies": { + "curl": "0.7.3", + "meld": "1.2.0", + "underscore": "1.4.4", + "when": "1.8.1", + "wire": "0.9.1", + "yaap": "0.0.2" + } +} \ No newline at end of file diff --git a/browser-example/index.html b/browser-example/index.html new file mode 100644 index 0000000..c8cd990 --- /dev/null +++ b/browser-example/index.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/browser-example/spec.js b/browser-example/spec.js new file mode 100644 index 0000000..3bd2e19 --- /dev/null +++ b/browser-example/spec.js @@ -0,0 +1,21 @@ +define([], function(){ + + +return { + message: "autowired", + myComponent: { + create: { + module: 'MyClass', + args: "wired" + } + }, + + plugins: [ + //{module: "wire/debug", trace: true}, + {module: "yaap/wire/wireplugin"} + + ] + +} + +}); \ No newline at end of file diff --git a/component.json b/component.json new file mode 100644 index 0000000..aa8e121 --- /dev/null +++ b/component.json @@ -0,0 +1,9 @@ +{ + "name": "yaap", + "version": "0.0.2", + "main": "./yaap/yaap.js", + "repository": { + "type": "git", + "url": "git://github.com/warmuuh/yaap.git" + } +} \ No newline at end of file diff --git a/example/MyClass.js b/node-example/MyClass.js similarity index 100% rename from example/MyClass.js rename to node-example/MyClass.js diff --git a/example/main.js b/node-example/main.js similarity index 75% rename from example/main.js rename to node-example/main.js index f66d7ca..f493d77 100644 --- a/example/main.js +++ b/node-example/main.js @@ -18,7 +18,7 @@ wire({ plugins: [ //{module: "wire/debug", trace: true}, - {module: "../yaap/wire", hookRequire: require} + {module: "../yaap/wire"} ] @@ -26,7 +26,7 @@ wire({ console.log("----- initialized -----"); ctx.myComponent.doSomething(); - ctx.myComponent.doSomethingElseAgain(); + ctx.myComponent.doSomethingElseAgain(); -}, console.error); +}, function(err){console.error(err);}); diff --git a/example/package.json b/node-example/package.json similarity index 100% rename from example/package.json rename to node-example/package.json diff --git a/yaap/package.json b/yaap/package.json index 036d61c..8b302cf 100644 --- a/yaap/package.json +++ b/yaap/package.json @@ -1,6 +1,6 @@ { "name": "yaap", - "version": "0.0.1", + "version": "0.0.2", "description": "yaap", "keywords": [ "javascript", "dependency injection", "AOP", "IOC"], "repository": { diff --git a/yaap/parser/ECMA5Parser.js b/yaap/parser/ECMA5Parser.js index 6d14da3..7096b79 100644 --- a/yaap/parser/ECMA5Parser.js +++ b/yaap/parser/ECMA5Parser.js @@ -1,3 +1,6 @@ +(function(define) { +define([],function(){ + Program.names=['','Program','FunctionBody','FunctionDeclaration','FunctionExpression','FormalParameterList','FormalParameter','','Statement','Block','VariableStatement','VariableDeclaration','VariableDeclarationNoIn','VariableDeclarationListNoIn','EmptyStatement','ExpressionStatement','IfStatement','IterationStatement','DoWhileStatement','WhileStatement','ForInStatement','ForInLeft','ForInVarLeft','ForStatement','ForInit','ForVarInit','ForTest','ForUpdate','ContinueStatement','BreakStatement','ReturnStatement','WithStatement','LabelledStatement','SwitchStatement','CaseClause','DefaultClause','ThrowStatement','TryStatement','Catch','Finally','DebuggerStatement','Expression','ExpressionNoIn','AssignmentExpression','AssignmentExpressionNoIn','AssignmentOperator','ConditionalExpression','ConditionalExpressionNoIn','LogicalOrExpression','LogicalOrExpressionNoIn','LogicalAndExpression','LogicalAndExpressionNoIn','BitwiseOrExpression','BitwiseOrExpressionNoIn','BitwiseXOrExpression','BitwiseXOrExpressionNoIn','BitwiseAndExpression','BitwiseAndExpressionNoIn','EqualityExpression','EqualityExpressionNoIn','EqualityOp','RelationalExpression','RelationalExpressionNoIn','RelationalOp','RelationalOpNoIn','ShiftExpression','ShiftOp','AdditiveExpression','AdditiveOp','MultiplicativeExpression','MultiplicativeOp','UnaryExpression','DeleteExpression','VoidExpression','TypeofExpression','PreIncrementExpression','PreDecrementExpression','UnaryPlusExpression','UnaryMinusExpression','BitwiseNotExpression','LogicalNotExpression','PostfixExpression','PostIncrementOp','PostDecrementOp','LeftHandSideExpression','CallExpression','BracketAccessor','DotAccessor','Arguments','ArgumentList','NewExpression','MemberExpression','PrimaryExpression','ArrayLiteral','ElementList','Elision','ObjectLiteral','PropertyNameAndValueList','PropertyAssignment','PropertyGetter','PropertySetter','PropertyName','PropertySetParameterList','Literal','NullLiteral','BooleanLiteral','NumericLiteral','DecimalLiteral','DecimalIntegerLiteral','DecimalDigit','ExponentPart','SignedInteger','HexIntegerLiteral','DQ','SQ','StringLiteral','RS','DoubleStringCharacter','SingleStringCharacter','LineContinuation','EscapeSequence','CharacterEscapeSequence','SingleEscapeCharacter','NonEscapeCharacter','EscapeCharacter','HexEscapeSequence','UnicodeEscapeSequence','RegularExpressionLiteral','RegularExpressionBody','RegularExpressionFirstChar','RegularExpressionChar','RegularExpressionBackslashSequence','RegularExpressionClass','RegularExpressionClassChar','RegularExpressionFlags','SourceCharacter','WhiteSpace','LF','CR','LS','PS','LineTerminator','LineTerminatorSequence','Comment','MultiLineComment','AnnotationComment','AnnotationFunction','AnnotationName','AnnotationParameterList','AnnotationParameter','MultiLineCommentNoLB','SingleLineComment','S','SnoComment','SnoLB','EOS','EOSnoLB','EOF','ReservedWord','Keyword','FutureReservedWord','Identifier','IdentifierName','IdentifierStart','IdentifierPart','UnicodeLetter','HexDigit','FalseTok','TrueTok','NullTok','BreakTok','ContinueTok','DebuggerTok','InTok','InstanceOfTok','DeleteTok','FunctionTok','NewTok','ThisTok','TypeofTok','VoidTok','IfTok','ElseTok','DoTok','WhileTok','ForTok','VarTok','ReturnTok','CaseTok','DefaultTok','SwitchTok','ThrowTok','CatchTok','FinallyTok','TryTok','WithTok','_'] function Program(out){var eof=false,s='',l=0,S=802816,T,M,F,D,R,tbl=[],x,pos=0,offset=0,buf=[],bufs=[],states=[],posns=[],c,equiv,ds,dp,failed=0,emp=0,emps=[]; equiv=rle_dec([9,0,1,1,1,2,2,1,1,3,18,0,1,1,1,4,1,5,1,0,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,1,15,1,16,1,17,1,18,9,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,4,27,1,28,1,27,17,29,1,30,2,29,1,31,1,32,1,33,1,34,1,35,1,0,1,36,1,37,1,38,1,39,1,40,1,41,1,42,1,43,1,44,1,29,1,45,1,46,1,47,1,48,1,49,1,50,1,29,1,51,1,52,1,53,1,54,1,55,1,56,1,57,1,58,1,59,1,60,1,61,1,62,1,63,6,0,1,1,26,0,1,1,9,0,1,29,10,0,1,29,4,0,1,29,5,0,23,29,1,0,31,29,1,0,458,29,4,0,12,29,14,0,5,29,7,0,1,29,1,0,1,29,17,0,112,64,5,29,1,0,2,29,2,0,4,29,8,0,1,29,1,0,3,29,1,0,1,29,1,0,20,29,1,0,83,29,1,0,139,29,1,0,5,64,2,0,154,29,13,0,38,29,2,0,1,29,7,0,39,29,9,0,45,64,1,0,1,64,1,0,2,64,1,0,2,64,1,0,1,64,8,0,27,29,5,0,3,29,29,0,11,64,6,0,42,29,20,64,1,0,10,64,4,0,2,29,1,64,99,29,1,0,1,29,7,64,2,0,6,64,2,29,2,64,1,0,4,64,2,29,10,64,3,29,2,0,1,29,16,0,1,29,1,64,30,29,27,64,2,0,89,29,11,64,1,29,14,0,10,64,33,29,9,64,2,29,4,0,1,29,262,0,3,64,54,29,2,0,1,64,1,29,16,64,2,0,1,29,4,64,3,0,10,29,2,64,2,0,10,64,1,0,2,29,8,0,5,29,1,0,3,64,1,0,8,29,2,0,2,29,2,0,22,29,1,0,7,29,1,0,1,29,3,0,4,29,2,0,1,64,1,29,7,64,2,0,2,64,2,0,3,64,1,29,8,0,1,64,4,0,2,29,1,0,3,29,2,64,2,0,10,64,2,29,15,0,3,64,1,0,6,29,4,0,2,29,2,0,22,29,1,0,7,29,1,0,2,29,1,0,2,29,1,0,2,29,2,0,1,64,1,0,5,64,4,0,2,64,2,0,3,64,3,0,1,64,7,0,4,29,1,0,1,29,7,0,12,64,3,29,1,64,11,0,3,64,1,0,9,29,1,0,3,29,1,0,22,29,1,0,7,29,1,0,2,29,1,0,5,29,2,0,1,64,1,29,8,64,1,0,3,64,1,0,3,64,2,0,1,29,15,0,2,29,2,64,2,0,10,64,17,0,3,64,1,0,8,29,2,0,2,29,2,0,22,29,1,0,7,29,1,0,2,29,1,0,5,29,2,0,1,64,1,29,7,64,2,0,2,64,2,0,3,64,8,0,2,64,4,0,2,29,1,0,3,29,2,64,2,0,10,64,1,0,1,29,16,0,1,64,1,29,1,0,6,29,3,0,3,29,1,0,4,29,3,0,2,29,1,0,1,29,1,0,2,29,3,0,2,29,3,0,3,29,3,0,12,29,4,0,5,64,3,0,3,64,1,0,4,64,2,0,1,29,6,0,1,64,14,0,10,64,17,0,3,64,1,0,8,29,1,0,3,29,1,0,23,29,1,0,10,29,1,0,5,29,3,0,1,29,7,64,1,0,3,64,1,0,4,64,7,0,2,64,1,0,2,29,6,0,2,29,2,64,2,0,10,64,18,0,2,64,1,0,8,29,1,0,3,29,1,0,23,29,1,0,10,29,1,0,5,29,2,0,1,64,1,29,7,64,1,0,3,64,1,0,4,64,7,0,2,64,7,0,1,29,1,0,2,29,2,64,2,0,10,64,18,0,2,64,1,0,8,29,1,0,3,29,1,0,23,29,1,0,16,29,3,0,1,29,7,64,1,0,3,64,1,0,4,64,9,0,1,64,8,0,2,29,2,64,2,0,10,64,10,0,6,29,2,0,2,64,1,0,18,29,3,0,24,29,1,0,9,29,1,0,1,29,2,0,7,29,3,0,1,64,4,0,6,64,1,0,1,64,1,0,8,64,18,0,2,64,13,0,48,29,1,64,2,29,7,64,5,0,7,29,8,64,1,0,10,64,39,0,2,29,1,0,1,29,2,0,2,29,1,0,1,29,2,0,1,29,6,0,4,29,1,0,7,29,1,0,3,29,1,0,1,29,1,0,1,29,2,0,2,29,1,0,4,29,1,64,2,29,6,64,1,0,2,64,1,29,2,0,5,29,1,0,1,29,1,0,6,64,2,0,10,64,2,0,2,29,34,0,1,29,23,0,2,64,6,0,10,64,11,0,1,64,1,0,1,64,1,0,1,64,4,0,2,64,8,29,1,0,36,29,4,0,20,64,1,0,2,64,4,29,4,0,8,64,1,0,36,64,9,0,1,64,57,0,43,29,20,64,1,29,10,64,6,0,6,29,4,64,4,29,3,64,1,29,3,64,2,29,7,64,3,29,4,64,13,29,12,64,1,29,11,64,6,0,38,29,10,0,43,29,1,0,1,29,3,0,90,29,5,0,68,29,5,0,82,29,6,0,73,29,1,0,4,29,2,0,7,29,1,0,1,29,1,0,4,29,2,0,41,29,1,0,4,29,2,0,33,29,1,0,4,29,2,0,7,29,1,0,1,29,1,0,4,29,2,0,15,29,1,0,57,29,1,0,4,29,2,0,67,29,4,0,1,64,32,0,16,29,16,0,85,29,12,0,620,29,2,0,8,29,9,0,1,1,26,29,5,0,75,29,3,0,3,29,15,0,13,29,1,0,4,29,3,64,11,0,18,29,3,64,11,0,18,29,2,64,12,0,13,29,1,0,3,29,1,0,2,64,12,0,52,29,2,0,30,64,3,0,1,29,4,0,1,29,1,64,2,0,10,64,33,0,3,64,1,1,1,0,10,64,6,0,88,29,8,0,41,29,1,64,1,29,85,0,29,29,3,0,12,64,4,0,12,64,10,0,10,64,30,29,2,0,5,29,11,0,42,29,6,0,17,64,7,29,2,64,6,0,10,64,38,0,23,29,5,64,228,0,5,64,47,29,17,64,7,29,4,0,10,64,17,0,9,64,12,0,3,64,30,29,10,64,3,0,2,29,10,64,70,0,36,29,20,64,8,0,10,64,3,0,3,29,10,64,36,29,130,0,192,29,39,64,23,0,2,64,278,29,2,0,6,29,2,0,38,29,2,0,6,29,2,0,8,29,1,0,1,29,1,0,1,29,1,0,1,29,1,0,31,29,2,0,53,29,1,0,7,29,1,0,1,29,3,0,3,29,1,0,7,29,3,0,4,29,2,0,6,29,4,0,13,29,5,0,3,29,1,0,7,29,3,0,12,1,28,0,1,65,1,66,5,0,1,1,15,0,2,64,19,0,1,64,10,0,1,1,17,0,1,29,13,0,1,29,16,0,5,29,59,0,13,64,4,0,1,64,3,0,12,64,17,0,1,29,4,0,1,29,2,0,10,29,1,0,1,29,3,0,5,29,6,0,1,29,1,0,1,29,1,0,1,29,1,0,4,29,1,0,11,29,2,0,4,29,5,0,5,29,4,0,1,29,17,0,41,29,2679,0,47,29,1,0,47,29,1,0,16,29,1,0,13,29,2,0,101,29,27,0,38,29,10,0,54,29,9,0,1,29,16,0,23,29,9,0,7,29,1,0,7,29,1,0,7,29,1,0,7,29,1,0,7,29,1,0,7,29,1,0,7,29,1,0,7,29,1,0,32,64,47,0,1,29,464,0,1,1,4,0,3,29,25,0,9,29,6,64,1,0,5,29,2,0,5,29,4,0,86,29,2,0,2,64,2,0,3,29,1,0,90,29,1,0,4,29,5,0,41,29,3,0,94,29,17,0,24,29,56,0,16,29,512,0,6582,29,74,0,20932,29,60,0,1165,29,115,0,269,29,3,0,16,29,10,64,2,29,20,0,32,29,2,0,13,29,1,64,12,0,2,64,1,0,25,29,127,0,9,29,2,0,103,29,2,0,2,29,110,0,7,29,1,64,3,29,1,64,4,29,1,64,23,29,5,64,24,0,52,29,12,0,2,64,50,29,17,64,11,0,10,64,38,0,10,64,28,29,8,64,2,0,23,29,13,64,172,0,41,29,14,64,9,0,3,29,1,64,8,29,2,64,2,0,10,64,422,0,11172,29,92,0,2048,67,6400,0,302,29,2,0,59,29,5,0,106,29,38,0,7,29,12,0,5,29,5,0,1,29,1,64,10,29,1,0,13,29,1,0,5,29,1,0,1,29,1,0,2,29,1,0,2,29,1,0,108,29,33,0,363,29,18,0,64,29,2,0,54,29,40,0,12,29,4,0,16,64,16,0,7,64,12,0,2,64,24,0,3,64,32,0,5,29,1,0,135,29,2,0,1,1,16,0,10,64,7,0,26,29,4,0,1,64,1,0,26,29,11,0,89,29,3,0,6,29,2,0,6,29,2,0,6,29,2,0,3,29,35,0]) @@ -52,5 +55,6 @@ S=F[S>>>12]} if(S==2490){R=true;S=states.pop()}else if(S==2491){R=false;S=states.pop()}else R=undefined;}}} function emit(){var x=bufs.length?bufs[0]:buf;if(x.length){out('tree segment',x);if(bufs.length)bufs[0]=[];else buf=[]}} function fail(s){out('fail',pos,s);failed=1}} +return {Program:Program}; -exports.Program = Program; \ No newline at end of file +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/parser/PanPG_util.js b/yaap/parser/PanPG_util.js index 28d3509..b0299a5 100644 --- a/yaap/parser/PanPG_util.js +++ b/yaap/parser/PanPG_util.js @@ -4,8 +4,10 @@ * http://boshi.inimino.org/3box/PanPG/about.html * MIT Licensed */ +"use strict"; +(function(define) { +define([],function() { -;(function(exports){ // (event array (can be partial), [name array], [input string], [state]) → [ascii-art tree, state] // -or- @@ -154,7 +156,9 @@ function treeWalker(dict,result){var p,any,anon,other,fail,except,index,cb=[],st function warn(s){ if(dict.warn)dict.warn(s)}} -exports.showTree=showTree -exports.treeWalker=treeWalker +return { + showTree:showTree, + treeWalker:treeWalker +} -})(typeof exports=='object'?exports:PanPG_util={}); \ No newline at end of file +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/parser/buildparser.js b/yaap/parser/buildparser.js index 27fe617..c22f45b 100644 --- a/yaap/parser/buildparser.js +++ b/yaap/parser/buildparser.js @@ -8,7 +8,7 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; @@ -19,7 +19,7 @@ var grammar = fs.readFileSync("ECMAScript_5.peg").toString(); var parser = pg.generateParser(grammar); -parser = parser + "\nexports.Program = Program;"; +parser = "(function(define) {\ndefine([],function(){\n\n" + parser + "return {Program:Program};\n\n});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));});"; fs.writeFileSync("ECMA5Parser.js", parser); \ No newline at end of file diff --git a/yaap/parser/walker.js b/yaap/parser/walker.js index 53b92fa..0d7a8d7 100644 --- a/yaap/parser/walker.js +++ b/yaap/parser/walker.js @@ -8,14 +8,17 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; - -var _ = require("underscore"); + (function(define) { +define(["underscore"], +function(_) { -var treewalker = module.exports = { + + +return { Program: function(match, children){ return children; }, @@ -94,4 +97,6 @@ var treewalker = module.exports = { //console.log("fn body annotations found: " + JSON.stringify(bodyObj)); } -}; \ No newline at end of file +}; + +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/plugins/DefaultProcessor.js b/yaap/plugins/DefaultProcessor.js index c171573..8eca940 100644 --- a/yaap/plugins/DefaultProcessor.js +++ b/yaap/plugins/DefaultProcessor.js @@ -10,15 +10,15 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; - -var meld = require("meld"); -var _ = require("underscore"); - +(function(define) { +define(["underscore", "meld"], +function(_, meld) { + -module.exports = { +return { annotation: "@Default", processParameter: function(obj, fnObj, param, annotationParams) { @@ -32,3 +32,4 @@ module.exports = { } }; +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/plugins/NotNullProcessor.js b/yaap/plugins/NotNullProcessor.js index 73be3da..e92f5b6 100644 --- a/yaap/plugins/NotNullProcessor.js +++ b/yaap/plugins/NotNullProcessor.js @@ -10,15 +10,16 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; - -var meld = require("meld"); -var _ = require("underscore"); +(function(define) { +define(["underscore", "meld"], +function(_, meld) { + -module.exports = { +return { annotation: "@NotNull", @@ -46,3 +47,4 @@ module.exports = { } }; +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/registry.js b/yaap/registry.js index f34d6d2..d351dfa 100644 --- a/yaap/registry.js +++ b/yaap/registry.js @@ -8,23 +8,27 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; - -var _ = require("underscore"); - +(function(define) { +define(["underscore"], function(_) { var registry = []; -var register = exports.register = function(processors){ - _(processors).each(function(proc){ - registry.push(proc); - }); -}; -var getProcessors = exports.getProcessors = function(annotation){ - return _(registry).where({annotation:annotation}); -}; \ No newline at end of file +return { + getProcessors: function(annotation){ + return _(registry).where({annotation:annotation}); + }, + register: function(processors){ + _(processors).each(function(proc){ + registry.push(proc); + }) + } +} + + +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/wire/plugins/AutowireProcessor.js b/yaap/wire/plugins/AutowireProcessor.js index 7e77217..1a3864d 100644 --- a/yaap/wire/plugins/AutowireProcessor.js +++ b/yaap/wire/plugins/AutowireProcessor.js @@ -5,7 +5,7 @@ * * Autowires parameters of function calls based on a given or the parameter name. * - * needs wire to be in the global configuration object. + * needs wire to be in the configuration object. * * * Licensed under the MIT License at: @@ -13,16 +13,15 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; -var meld = require("meld"); -var _ = require("underscore"); -var when = require("when"); - +(function(define) { +define(["underscore", "when", "meld"], +function(_, when, meld) { -module.exports = { +return { annotation: "@Autowired", processParameter: function(obj, fnObj, param, annotationParams, cfg) { //console.log("@Autowired("+ annotationParams +") attached at parameter: " + param.name); @@ -61,7 +60,8 @@ module.exports = { joinpoint.args[i] = resolvedRefs[i]; return joinpoint.proceed(); }); - }, console.error); + }, function(err){console.error(err);}); } }; +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); \ No newline at end of file diff --git a/yaap/wire/wireplugin.js b/yaap/wire/wireplugin.js index 33ddc11..7da4dea 100644 --- a/yaap/wire/wireplugin.js +++ b/yaap/wire/wireplugin.js @@ -23,24 +23,24 @@ resolver.resolve(); } - - - return { - wire$plugin: function(ready, destroyed, options) { - yaap.register(autowire); - - return { - initialize: annotatesFacet - }; - } - }; - }); - }( - typeof define == 'function' && define.amd ? define : function(deps, factory) { - module.exports = factory.apply(this, deps.map(require)); - })); \ No newline at end of file + return { + wire$plugin: function(ready, destroyed, options) { + + yaap.register(autowire); + + return { + initialize: annotatesFacet + }; + } + }; + + }); +}( +typeof define == 'function' && define.amd ? define : function(deps, factory) { + module.exports = factory.apply(this, deps.map(require)); +})); \ No newline at end of file diff --git a/yaap/yaap.js b/yaap/yaap.js index b247a48..e3c8d02 100644 --- a/yaap/yaap.js +++ b/yaap/yaap.js @@ -8,85 +8,76 @@ * * @author Peter Mucha * - * @version 0.0.1 + * @version 0.0.2 */ "use strict"; -var _ = require("underscore"); - - - -var registry = require("./registry"); -registry.register([ - require("./plugins/NotNullProcessor"), - require("./plugins/DefaultProcessor") -]); - -exports.register = function(processor){ - registry.register([processor]); -}; - - - -var callProcessors = function(obj, fnObj, config){ - //process function-annotations - _(fnObj.annotations).each(function (annotation){ - _(registry.getProcessors(annotation.name)).each(function(processor){ - if (_(processor).has("processFunction")) - processor.processFunction(obj, fnObj, annotation.parameters, config); - else - console.log("Function-annotations are not supported for: " + annotation.name); - }); - - }); - - //process parameter annotations - - _(fnObj.parameters).each(function (parameter){ - _(parameter.annotations).each(function (annotation){ - _(registry.getProcessors(annotation.name)).each(function(processor){ - if (_(processor).has("processParameter")) - processor.processParameter(obj, fnObj, parameter, annotation.parameters, config); - else - console.log("Parameter-annotations are not supported for: " + annotation.name); - }); - - }); - }); +(function(define) { +define(["underscore", "./registry", "./plugins/NotNullProcessor", "./plugins/DefaultProcessor", "wire", './parser/PanPG_util', './parser/ECMA5Parser', "./parser/walker"], +function(_, registry, NotNullProcessor, DefaultProcessor, wire, PanPG_util, es5, walker) { -}; + registry.register([ + NotNullProcessor, + DefaultProcessor + ]); + function callProcessors(obj, fnObj, config) { + //process function-annotations + _(fnObj.annotations).each(function (annotation) { + _(registry.getProcessors(annotation.name)).each(function (processor) { + if (_(processor).has("processFunction")) + processor.processFunction(obj, fnObj, annotation.parameters, config); + else + console.log("Function-annotations are not supported for: " + annotation.name); + }); + + }); + + //process parameter annotations + + _(fnObj.parameters).each(function (parameter){ + _(parameter.annotations).each(function (annotation){ + _(registry.getProcessors(annotation.name)).each(function(processor){ + if (_(processor).has("processParameter")) + processor.processParameter(obj, fnObj, parameter, annotation.parameters, config); + else + console.log("Parameter-annotations are not supported for: " + annotation.name); + }); + + }); + }); + }; -var process = exports.process = function (obj, config){ - var functions = _(obj).functions(); - _(functions).each(function(f){ - - - - - var PanPG_util=require('./parser/PanPG_util'); - var es5 = require('./parser/ECMA5Parser'); + + return { + register: function (processor) { + registry.register([processor]); + }, - var walker = require("./parser/walker"); - - - var source = obj[f].toString(); - var ast = es5.Program(source); + process: function (obj, config){ + var functions = _(obj).functions(); + _(functions).each(function(f){ + + + var source = obj[f].toString(); + var ast = es5.Program(source); - var fnObjs = PanPG_util.treeWalker(walker, ast); + var fnObjs = PanPG_util.treeWalker(walker, ast); - - _(fnObjs).each(function(fnObj){ - fnObj.name = f; - callProcessors(obj, fnObj, config); - }); - }); -}; + + _(fnObjs).each(function(fnObj){ + fnObj.name = f; + callProcessors(obj, fnObj, config); + }); + }); + } + } +});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));});