|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83855 - in trunk/tools/build/v2: engine/modules util
From: steven_at_[hidden]
Date: 2013-04-11 18:55:26
Author: steven_watanabe
Date: 2013-04-11 18:55:25 EDT (Thu, 11 Apr 2013)
New Revision: 83855
URL: http://svn.boost.org/trac/boost/changeset/83855
Log:
Implement sequence.transform as a native rule.
Text files modified:
trunk/tools/build/v2/engine/modules/sequence.c | 42 +++++++++++++++++++++++++++++++++++++--
trunk/tools/build/v2/util/sequence.jam | 4 +++
2 files changed, 43 insertions(+), 3 deletions(-)
Modified: trunk/tools/build/v2/engine/modules/sequence.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/sequence.c (original)
+++ trunk/tools/build/v2/engine/modules/sequence.c 2013-04-11 18:55:25 EDT (Thu, 11 Apr 2013)
@@ -7,6 +7,8 @@
#include "../native.h"
#include "../object.h"
+#include "../lists.h"
+#include "../compile.h"
#include <stdlib.h>
@@ -52,9 +54,43 @@
return result;
}
+LIST * sequence_transform( FRAME * frame, int flags )
+{
+ LIST * function = lol_get( frame->args, 0 );
+ LIST * sequence = lol_get( frame->args, 1 );
+ LIST * result = L0;
+ OBJECT * function_name = list_front( function );
+ LISTITER args_begin = list_next( list_begin( function ) ), args_end = list_end( function );
+ LISTITER iter = list_begin( sequence ), end = list_end( sequence );
+
+ for ( ; iter != end; iter = list_next( iter ) )
+ {
+ FRAME inner[ 1 ];
+
+ frame_init( inner );
+ inner->prev = frame;
+ inner->prev_user = frame->prev_user;
+ inner->module = frame->prev->module;
+
+ lol_add( inner->args, list_push_back( list_copy_range( function, args_begin, args_end ), object_copy( list_item( iter ) ) ) );
+ result = list_append( result, evaluate_rule( function_name, inner ) );
+
+ frame_free( inner );
+ }
+
+ return result;
+}
+
void init_sequence()
{
- char const * args[] = { "elements", "*", ":", "rank", "*", 0 };
- declare_native_rule( "sequence", "select-highest-ranked", args,
- sequence_select_highest_ranked, 1 );
+ {
+ char const * args[] = { "elements", "*", ":", "rank", "*", 0 };
+ declare_native_rule( "sequence", "select-highest-ranked", args,
+ sequence_select_highest_ranked, 1 );
+ }
+ {
+ char const * args[] = { "function", "+", ":", "sequence", "*", 0 };
+ declare_native_rule( "sequence", "transform", args,
+ sequence_transform, 1 );
+ }
}
Modified: trunk/tools/build/v2/util/sequence.jam
==============================================================================
--- trunk/tools/build/v2/util/sequence.jam (original)
+++ trunk/tools/build/v2/util/sequence.jam 2013-04-11 18:55:25 EDT (Thu, 11 Apr 2013)
@@ -50,6 +50,10 @@
return $(result) ;
}
+if [ HAS_NATIVE_RULE sequence : transform : 1 ]
+{
+ NATIVE_RULE sequence : transform ;
+}
rule reverse ( s * )
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk