55# https://www.bfgroup.xyz/b2/LICENSE.txt)
66
77import "class" : new ;
8- import feature ;
98import indirect ;
109import path ;
1110import project ;
1211import property ;
13- import sequence ;
14- import set ;
15- import option ;
12+ import set : difference : set.difference ;
1613import args ;
1714
1815# Class for storing a set of properties.
@@ -29,19 +26,16 @@ import args ;
2926# It is possible to get a list of properties belonging to each category as
3027# well as a list of properties with a specific attribute.
3128#
32- # Several operations, like and refine and as-path are provided. They all use
29+ # Several operations, like refine and as-path are provided. They all use
3330# caching whenever possible.
3431#
3532class property-set
3633{
37- import errors ;
3834 import feature ;
39- import modules ;
40- import path ;
35+ import path : join : path.join ;
4136 import property ;
4237 import property-set ;
43- import set ;
44- import sequence ;
38+ import sequence : transform : sequence.transform ;
4539
4640 rule __init__ ( raw-properties * )
4741 {
@@ -51,6 +45,7 @@ class property-set
5145 {
5246 if ! $(p:G)
5347 {
48+ import errors ;
5449 errors.error "Invalid property: '$(p)'" ;
5550 }
5651 }
@@ -319,21 +314,8 @@ class property-set
319314
320315 # Returns all values of 'feature'.
321316 #
322- rule get ( feature )
323- {
324- if ! $(self.map-built)
325- {
326- # For each feature, create a member var and assign all values to it.
327- # Since all regular member vars start with 'self', there will be no
328- # conflicts between names.
329- self.map-built = true ;
330- for local v in $(self.raw)
331- {
332- $(v:G) += $(v:G=) ;
333- }
334- }
335- return $($(feature)) ;
336- }
317+ # rule get ( feature )
318+ NATIVE_RULE class@property-set : get ;
337319
338320 # Returns true if the property-set contains all the
339321 # specified properties.
@@ -349,13 +331,8 @@ class property-set
349331 # Returns true if the property-set has values for
350332 # all the specified features
351333 #
352- rule contains-features ( features * )
353- {
354- if $(features) in $(self.raw:G)
355- {
356- return true ;
357- }
358- }
334+ # rule contains-features ( features * )
335+ NATIVE_RULE class@property-set : contains-features ;
359336
360337 # private
361338
@@ -429,7 +406,9 @@ class property-set
429406 # characters as well, e.g. free or indirect properties. Indirect
430407 # properties for example contain a full Jamfile path in their value
431408 # which on Windows file systems contains ':' as the drive separator.
432- if ( [ MATCH "(:)" : $(p:G=) ] && ! ( free in [ feature.attributes $(p:G) ] ) ) || $(p:G) = <conditional>
409+ if ( [ MATCH "(:)" : $(p:G=) ]
410+ && ! ( free in [ feature.attributes $(p:G) ] )
411+ ) || $(p:G) = <conditional>
433412 {
434413 self.conditional += $(p) ;
435414 }
@@ -442,34 +421,11 @@ class property-set
442421 }
443422}
444423
445- # Creates a new 'property-set' instance for the given raw properties or returns
446- # an already existing ones.
447- #
448- rule create ( raw-properties * )
449- {
450- raw-properties = [ sequence.unique
451- [ sequence.insertion-sort $(raw-properties) ] ] ;
452-
453- local key = $(raw-properties:J=-:E=) ;
454-
455- if ! $(.ps.$(key))
456- {
457- .ps.$(key) = [ new property-set $(raw-properties) ] ;
458- }
459- return $(.ps.$(key)) ;
460- }
424+ # Creates a new 'property-set' instance for the given raw properties
425+ # or returns an already existing ones.
426+ # rule create ( raw-properties * )
461427NATIVE_RULE property-set : create ;
462428
463- if [ HAS_NATIVE_RULE class@property-set : get : 1 ]
464- {
465- NATIVE_RULE class@property-set : get ;
466- }
467-
468- if [ HAS_NATIVE_RULE class@property-set : contains-features : 1 ]
469- {
470- NATIVE_RULE class@property-set : contains-features ;
471- }
472-
473429# Creates a new 'property-set' instance after checking that all properties are
474430# valid and converting implicit properties into gristed form.
475431#
@@ -486,7 +442,10 @@ rule create-with-validation ( raw-properties * )
486442rule create-from-user-input ( raw-properties * : jamfile-module location )
487443{
488444 local project-id = [ project.attribute $(jamfile-module) id ] ;
489- project-id ?= [ path.root $(location) [ path.pwd ] ] ;
445+ if ! $(project-id)
446+ {
447+ project-id = [ path.root $(location) [ path.pwd ] ] ;
448+ }
490449 return [ property-set.create [ property.translate $(raw-properties)
491450 : $(project-id) : $(location) : $(jamfile-module) ] ] ;
492451}
0 commit comments