From 97c0fcbbef19012f825cba0fc3f16037322ce84c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 22:24:48 +0000 Subject: We're getting closer and closer, qt4 is more configurable and gets QT flags for you for CXXFLAGS and LDFLAGS, added a bunch more stuff and fixed a strange function input bug. --- src/build.y | 12 +++++++++++- src/context.cpp | 2 ++ src/functionast.cpp | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/build.y b/src/build.y index a6618e4..3e9c8fd 100644 --- a/src/build.y +++ b/src/build.y @@ -188,7 +188,7 @@ value_mods: value_core: variable | literal - | function + | function_no_input | list ; @@ -254,6 +254,16 @@ function: UNDEF '(' { } ; +function_no_input: UNDEF '(' { + bld.xAst.addNode( AstNode::typeNull ); + bld.xAst.addNode( AstNode::typeFunction ); + bld.xAst.openBranch(); + bld.xAst.addNode( AstNode::typeString, $1 ); + } func_params ')' { + bld.xAst.closeNode(); + } + ; + requires: TOK_REQUIRES { bld.xAst.addNode( AstNode::typeRequires ); bld.xAst.openBranch(); diff --git a/src/context.cpp b/src/context.cpp index bc48def..e9330e5 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -232,6 +232,8 @@ Bu::FString Context::expand( const Bu::FString &sInS ) char buf[4096]; sBuf.append( buf, p.read( buf, 4096 ) ); } + sBuf = sBuf.replace("\n", " ").replace("\r", " "); + sBuf.trimBack(' '); sRet.append( sBuf ); } catch(...) { diff --git a/src/functionast.cpp b/src/functionast.cpp index 0d9a938..ceee460 100644 --- a/src/functionast.cpp +++ b/src/functionast.cpp @@ -4,6 +4,9 @@ #include "runner.h" #include "context.h" +#include +using namespace Bu; + FunctionAst::FunctionAst( const AstBranch *pRoot, class Runner *pRunner ) : pRoot( pRoot ), pRunner( pRunner ) @@ -22,9 +25,20 @@ Bu::FString FunctionAst::getName() const return sName; } -Variable FunctionAst::call( Variable &input, VarList /*lParams*/ ) +Variable FunctionAst::call( Variable &input, VarList lParams ) { pContext->pushScope(); + + AstBranch::NodeList::const_iterator vName = + (*(pRoot->getBranchBegin()+1)).begin(); + VarList::iterator vValue = lParams.begin(); + for( ; vName && vValue; vName++, vValue++ ) + { + pContext->addVariable( + dynamic_cast(*vName)->getStrValue(), + *vValue + ); + } pContext->addVariable("INPUT", input ); Variable vRet = pRunner->run( (*(pRoot->getBranchBegin()+2)).begin() ); pContext->popScope(); -- cgit v1.2.3