mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
Minor stylistic Boost Build code changes.
[SVN r45023]
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
#
|
||||
# The __init__ rule is the constructor, and sets member variables.
|
||||
#
|
||||
# New instances are created by invoking [ new <class> <args...> ]::
|
||||
# New instances are created by invoking [ new <class> <args...> ]:
|
||||
#
|
||||
# local x = [ new myclass foo ] ; # x is a new myclass object
|
||||
# assert.result foo : [ $(x).method1 ] ; # $(x).method1 returns "foo"
|
||||
@@ -49,18 +49,18 @@
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# All methods operate virtually, replacing behavior in the base
|
||||
# classes. For example::
|
||||
# All methods operate virtually, replacing behavior in the base classes. For
|
||||
# example::
|
||||
#
|
||||
# local y = [ new derived foo ] ; # y is a new derived object
|
||||
# assert.result fooXXX : [ $(y).method1 ] ; # $(y).method1 returns "foo"
|
||||
# local y = [ new derived foo ] ; # y is a new derived object
|
||||
# assert.result fooXXX : [ $(y).method1 ] ; # $(y).method1 returns "foo"
|
||||
#
|
||||
# Each class instance is its own core Jam module. All instance
|
||||
# attributes and methods are accessible without additional
|
||||
# qualification from within the class instance. All rules imported in
|
||||
# class declaration, or visible in base classses are also visible.
|
||||
# Base methods are available in qualified form: base-name.method-name.
|
||||
# By convention, attribute names are prefixed with "self.".
|
||||
# Each class instance is its own core Jam module. All instance attributes and
|
||||
# methods are accessible without additional qualification from within the class
|
||||
# instance. All rules imported in class declaration, or visible in base classses
|
||||
# are also visible. Base methods are available in qualified form:
|
||||
# base-name.method-name. By convention, attribute names are prefixed with
|
||||
# "self.".
|
||||
|
||||
import numbers ;
|
||||
import errors : * ;
|
||||
@@ -113,6 +113,7 @@ rule bases ( class )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rule is-derived ( class : bases + )
|
||||
{
|
||||
#local all = $(class) $(bases) ;
|
||||
@@ -141,13 +142,15 @@ rule is-derived ( class : bases + )
|
||||
return $(found) ;
|
||||
}
|
||||
|
||||
|
||||
# Returns true if the 'value' is a class instance.
|
||||
rule is-instance ( value # The value to check
|
||||
)
|
||||
#
|
||||
rule is-instance ( value )
|
||||
{
|
||||
return [ MATCH "^(object\\()[^@]+\\)@.*" : $(value) ] ;
|
||||
}
|
||||
|
||||
|
||||
# Check if the given value is of the given type.
|
||||
#
|
||||
rule is-a (
|
||||
@@ -161,6 +164,7 @@ rule is-a (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local rule typecheck ( x )
|
||||
{
|
||||
local class-name = [ MATCH "^\\[(.*)\\]$" : [ BACKTRACE 1 ] ] ;
|
||||
@@ -170,14 +174,14 @@ local rule typecheck ( x )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local rule __test__ ( )
|
||||
{
|
||||
import "class" : * ;
|
||||
import assert ;
|
||||
import errors : * ;
|
||||
|
||||
# This will be the construction function for a class called
|
||||
# 'myclass'
|
||||
# This will be the construction function for a class called 'myclass'.
|
||||
class myclass
|
||||
{
|
||||
import assert : nonempty-variable ;
|
||||
@@ -277,15 +281,13 @@ local rule __test__ ( )
|
||||
return $(z) ;
|
||||
}
|
||||
|
||||
# Check that 'assert.equal' visible in base class is visible
|
||||
# here.
|
||||
# Check that 'assert.equal' visible in base class is visible here.
|
||||
rule invariant2 ( )
|
||||
{
|
||||
assert.equal 2 : 2 ;
|
||||
}
|
||||
|
||||
# Check that 'nonempty-variable' visible in base class is
|
||||
# visible here.
|
||||
# Check that 'nonempty-variable' visible in base class is visible here.
|
||||
rule invariant3 ( )
|
||||
{
|
||||
local v = 10 ;
|
||||
@@ -336,11 +338,10 @@ local rule __test__ ( )
|
||||
expect_derived2 $(d) ;
|
||||
expect_derived2 $(e) ;
|
||||
|
||||
# argument checking is set up to call exit(1) directly on
|
||||
# failure, and we can't hijack that with try, so we'd better
|
||||
# not do this test by default. We could fix this by having
|
||||
# errors look up and invoke the EXIT rule instead; EXIT can be
|
||||
# hijacked (;-)
|
||||
# Argument checking is set up to call exit(1) directly on failure, and we
|
||||
# can't hijack that with try, so we'd better not do this test by default.
|
||||
# We could fix this by having errors look up and invoke the EXIT rule
|
||||
# instead; EXIT can be hijacked (;-)
|
||||
if --fail-typecheck in [ modules.peek : ARGV ]
|
||||
{
|
||||
try ;
|
||||
@@ -385,7 +386,7 @@ local rule __test__ ( )
|
||||
$(b).invariant2 ;
|
||||
$(b).invariant3 ;
|
||||
|
||||
# Check that the __class__ attribute is getting properly set.
|
||||
# Check that the __class__ attribute is getting properly set.
|
||||
assert.result myclass : $(a).get-class ;
|
||||
assert.result derived1 : $(b).get-class ;
|
||||
assert.result $(a) : $(a).get-instance ;
|
||||
|
||||
Reference in New Issue
Block a user