1# Copyright 2018 Steven Watanabe 2# Distributed under the Boost Software License, Version 1.0. 3# (See accompanying file LICENSE_1_0.txt or copy at 4# http://www.boost.org/LICENSE_1_0.txt) 5 6# Named parameters are represented as a list which has the 7# argument name as the first element and the value as the 8# remaining elements. This function sorts the parameters 9# into the correct variables and removes the parameter names. 10# 11# Example:: 12# 13# rule exe ( name : sources * : requirements * ) 14# { 15# param.handle-named-params sources requirements ; 16# # At this point $(sources) is test.cpp 17# } 18# exe test : requirements <link>shared : sources test.cpp ; 19# 20rule handle-named-params ( parameter-names * ) 21{ 22 module [ CALLER_MODULE ] 23 { 24 # Uglify the variable names, because we're executing in an unknown module. 25 local found-8bef5c096d06a1b0 ; 26 local tmp-8bef5c096d06a1b0.$(1) ; 27 for local v-8bef5c096d06a1b0 in $(1) 28 { 29 if $($(v-8bef5c096d06a1b0)[1]) && $($(v-8bef5c096d06a1b0)[1]) in $(1) 30 { 31 if $(tmp-8bef5c096d06a1b0.$($(v-8bef5c096d06a1b0)[1])) 32 { 33 import errors ; 34 errors.error Parameter '$($(v-8bef5c096d06a1b0)[1])' passed more than once. ; 35 } 36 found-8bef5c096d06a1b0 = true ; 37 tmp-8bef5c096d06a1b0.$($(v-8bef5c096d06a1b0)[1]) = $($(v-8bef5c096d06a1b0)[2-]) ; 38 } 39 else if $($(v-8bef5c096d06a1b0))-is-defined 40 { 41 if $(found-8bef5c096d06a1b0) 42 { 43 import errors ; 44 errors.error "Positional arguments must appear first." ; 45 } 46 tmp-8bef5c096d06a1b0.$(v-8bef5c096d06a1b0) = $($(v-8bef5c096d06a1b0)) ; 47 } 48 } 49 for local v-8bef5c096d06a1b0 in $(1) 50 { 51 $(v-8bef5c096d06a1b0) = $(tmp-8bef5c096d06a1b0.$(v-8bef5c096d06a1b0)) ; 52 } 53 } 54} 55