Skip to content

Commit

Permalink
Merge pull request #3 from D-Programming-Language/master
Browse files Browse the repository at this point in the history
update my fork
  • Loading branch information
Passw committed Jan 9, 2014
2 parents f523d5c + 3a94d7f commit fddac4a
Show file tree
Hide file tree
Showing 54 changed files with 754 additions and 596 deletions.
19 changes: 14 additions & 5 deletions attribute.dd
Expand Up @@ -28,7 +28,18 @@ $(GNAME Attribute):
$(RELATIVE_LINK2 gshared, $(D __gshared))
$(RELATIVE_LINK2 disable, $(D @disable))
$(RELATIVE_LINK2 property, $(D @property))
$(GLINK Property)

$(GNAME Property):
$(D @) $(GLINK PropertyIdentifier)
$(GLINK UserDefinedAttribute)

$(GNAME PropertyIdentifier):
$(D property)
$(D safe)
$(D trusted)
$(D system)
$(D disable)

$(GNAME DeclarationBlock):
$(GLINK2 module, DeclDef)
Expand Down Expand Up @@ -572,12 +583,10 @@ $(SECTION3 $(LNAME2 uda, User Defined Attributes),
)

$(GRAMMAR
$(GNAME StorageClass):
$(GLINK UserDefinedAttribute)

$(GNAME UserDefinedAttribute):
@(ArgumentList)
@CallExpression
$(D @ $(LPAREN)) $(GLINK2 grammar, ArgumentList) $(D $(RPAREN))
$(D @) $(I Identifier)
$(D @) $(I Identifier) $(D $(LPAREN)) $(GLINK2 grammar, ArgumentList)$(OPT) $(D $(RPAREN))
)
$(P
And looks like:
Expand Down
104 changes: 52 additions & 52 deletions class.dd
Expand Up @@ -25,27 +25,27 @@ $(SPEC_S Classes,

$(GRAMMAR
$(GNAME ClassDeclaration):
$(B class) $(I Identifier) $(GLINK BaseClassList)$(OPT) $(GLINK ClassBody)
$(D class) $(I Identifier) $(GLINK BaseClassList)$(OPT) $(GLINK ClassBody)
$(GLINK2 template, ClassTemplateDeclaration)

$(GNAME BaseClassList):
$(B :) $(GLINK SuperClass)
$(B :) $(GLINK SuperClass) $(B ,) $(GLINK Interfaces)
$(B :) $(GLINK Interfaces)
$(D :) $(GLINK SuperClass)
$(D :) $(GLINK SuperClass) $(D ,) $(GLINK Interfaces)
$(D :) $(GLINK Interfaces)

$(GNAME SuperClass):
$(I Identifier)

$(GNAME Interfaces):
$(GLINK Interface)
$(GLINK Interface) $(B ,) $(I Interfaces)
$(GLINK Interface) $(D ,) $(I Interfaces)

$(GNAME Interface):
$(I Identifier)

$(GNAME ClassBody):
$(B {) $(B })
$(B {) $(GLINK ClassBodyDeclarations) $(B })
$(D {) $(D })
$(D {) $(GLINK ClassBodyDeclarations) $(D })

$(GNAME ClassBodyDeclarations):
$(GLINK ClassBodyDeclaration)
Expand Down Expand Up @@ -150,9 +150,9 @@ void foo(B b) {

$(H3 Field Properties)

$(P The $(B .offsetof) property gives the offset in bytes of the field
$(P The $(D .offsetof) property gives the offset in bytes of the field
from the beginning of the class instantiation.
$(B .offsetof) can only be applied to
$(D .offsetof) can only be applied to
expressions which produce the type of
the field itself, not the class type:
)
Expand All @@ -172,7 +172,7 @@ void test(Foo foo) {

$(H3 Class Properties)

$(P The $(B .tupleof) property returns an $(I ExpressionTuple)
$(P The $(D .tupleof) property returns an $(I ExpressionTuple)
of all the fields
in the class, excluding the hidden fields and the fields in the
base class.
Expand Down Expand Up @@ -256,7 +256,7 @@ $(H3 $(LNAME2 constructors, Constructors))

$(GRAMMAR
$(GNAME Constructor):
$(B this) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
$(D this) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
$(GLINK2 template, TemplatedConstructor)
)

Expand All @@ -282,7 +282,7 @@ $(GNAME Constructor):
This static initialization is done before any constructors are
called.

$(P Constructors are defined with a function name of $(B this)
$(P Constructors are defined with a function name of $(D this)
and having no return value:)

------
Expand All @@ -297,7 +297,7 @@ $(GNAME Constructor):
------

Base class construction is done by calling the base class
constructor by the name $(B super):
constructor by the name $(D super):

------
class A { this(int y) { } }
Expand Down Expand Up @@ -330,9 +330,9 @@ $(GNAME Constructor):
}
------

If no call to constructors via $(B this) or $(B super) appear
If no call to constructors via $(D this) or $(D super) appear
in a constructor, and the base class has a constructor, a call
to $(B super)() is inserted at the beginning of the constructor.
to $(D super)() is inserted at the beginning of the constructor.

$(P If there is no constructor for a class, but there is a constructor
for the base class, a default constructor of the form:)
Expand Down Expand Up @@ -374,7 +374,7 @@ $(GNAME Constructor):
------
)

$(LI It is illegal to refer to $(B this) implicitly or explicitly
$(LI It is illegal to refer to $(D this) implicitly or explicitly
prior to making a constructor call.)

$(LI Constructor calls cannot appear after labels (in order to make
Expand All @@ -391,8 +391,8 @@ $(GNAME Constructor):

$(OL
$(LI Storage is allocated for the object.
If this fails, rather than return $(B null), an
$(B OutOfMemoryError) is thrown.
If this fails, rather than return $(D null), an
$(D OutOfMemoryError) is thrown.
Thus, tedious checks for null references are unnecessary.
)

Expand Down Expand Up @@ -547,7 +547,7 @@ $(H3 $(LNAME2 destructors, Destructors))

$(GRAMMAR
$(GNAME Destructor):
$(B ~ this ( )) $(GLINK2 declaration, MemberFunctionAttributes)$(OPT) $(GLINK2 function, FunctionBody)
$(D ~ this ( )) $(GLINK2 declaration, MemberFunctionAttributes)$(OPT) $(GLINK2 function, FunctionBody)
)

The garbage collector calls the destructor function when the object
Expand Down Expand Up @@ -606,7 +606,7 @@ $(H3 Static Constructors)

$(GRAMMAR
$(GNAME StaticConstructor):
$(B static this ( )) $(GLINK2 function, FunctionBody)
$(D static this ( )) $(GLINK2 function, FunctionBody)
)

$(P
Expand Down Expand Up @@ -685,8 +685,8 @@ class Foo {
)

$(P
The $(B static) in the static constructor declaration is not
an attribute, it must appear immediately before the $(B this):
The $(D static) in the static constructor declaration is not
an attribute, it must appear immediately before the $(D this):
)

------
Expand All @@ -705,7 +705,7 @@ $(H3 Static Destructors)

$(GRAMMAR
$(GNAME StaticDestructor):
$(B static ~ this ( )) $(GLINK2 function, FunctionBody)
$(D static ~ this ( )) $(GLINK2 function, FunctionBody)
)

A static destructor is defined as a special static function with the
Expand All @@ -729,8 +729,8 @@ class Foo {
)

$(P
The $(B static) in the static destructor declaration is not
an attribute, it must appear immediately before the $(B ~this):
The $(D static) in the static destructor declaration is not
an attribute, it must appear immediately before the $(D ~this):
)

------
Expand All @@ -750,7 +750,7 @@ $(H3 Shared Static Constructors)

$(GRAMMAR
$(GNAME SharedStaticConstructor):
$(B shared static this ( )) $(GLINK2 function, FunctionBody)
$(D shared static this ( )) $(GLINK2 function, FunctionBody)
)

$(P Shared static constructors are executed before any $(GLINK StaticConstructor)s,
Expand All @@ -761,7 +761,7 @@ $(H3 Shared Static Destructors)

$(GRAMMAR
$(GNAME SharedStaticDestructor):
$(B shared static ~ this ( )) $(GLINK2 function, FunctionBody)
$(D shared static ~ this ( )) $(GLINK2 function, FunctionBody)
)

$(P Shared static destructors are executed at program termination
Expand All @@ -774,7 +774,7 @@ $(H3 $(LNAME2 invariants, Class Invariants))

$(GRAMMAR
$(GNAME Invariant):
$(B invariant ( )) $(GLINK2 statement, BlockStatement)
$(D invariant ( )) $(GLINK2 statement, BlockStatement)
)

Class invariants are used to specify characteristics of a class that always
Expand All @@ -785,7 +785,7 @@ $(H3 $(LNAME2 allocators, Class Allocators))
$(B Note): Class allocators are deprecated in D2.
$(GRAMMAR
$(GNAME ClassAllocator):
$(B new) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
$(D new) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
)

A class member function of the form:
Expand Down Expand Up @@ -813,11 +813,11 @@ new Foo;
instance.
The allocator must allocate the memory and return it as a
$(D void*).
If the allocator fails, it must not return a $(B null), but
If the allocator fails, it must not return a $(D null), but
must throw an exception.
If there is more than one parameter to the allocator, the
additional arguments are specified within parentheses after
the $(B new) in the $(I NewExpression):
the $(D new) in the $(I NewExpression):

------
class Foo {
Expand Down Expand Up @@ -847,7 +847,7 @@ new(1,2) Foo(a); // calls new(Foo.sizeof,1,2)

$(H3 $(LNAME2 deallocators, Class Deallocators))
$(B Note): Class deallocators and the delete operator are deprecated in D2.
Use the $(B destroy) function to finalize an object by calling its destructor.
Use the $(D destroy) function to finalize an object by calling its destructor.
The memory of the object is $(B not) immediately deallocated, instead the GC
will collect the memory of the object at an undetermined point after finalization:

Expand All @@ -860,7 +860,7 @@ assert(foo.x == int.init); // object is still accessible

$(GRAMMAR
$(GNAME ClassDeallocator):
$(B delete) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
$(D delete) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
)

A class member function of the form:
Expand Down Expand Up @@ -903,7 +903,7 @@ $(H3 $(LNAME2 AliasThis, Alias This))

$(GRAMMAR
$(GNAME AliasThis):
$(B alias) $(I Identifier) $(B this;)
$(D alias) $(I Identifier) $(D this ;)
)

$(P An $(I AliasThis) declaration names a member to subtype.
Expand Down Expand Up @@ -989,7 +989,7 @@ void test() {

$(H3 $(LNAME2 auto, Scope Classes))

A scope class is a class with the $(B scope) attribute, as in:
A scope class is a class with the $(D scope) attribute, as in:

------
scope class Foo { ... }
Expand All @@ -999,7 +999,7 @@ scope class Foo { ... }
from a scope class are also scope.

$(P An scope class reference can only appear as a function local variable.
It must be declared as being $(B scope):)
It must be declared as being $(D scope):)

------
scope class Foo { ... }
Expand Down Expand Up @@ -1052,9 +1052,9 @@ void func() {
}
------

If a nested class has the $(B static) attribute, then it can
If a nested class has the $(D static) attribute, then it can
not access variables of the enclosing scope that are local to the
stack or need a $(B this):
stack or need a $(D this):

------
class Outer {
Expand Down Expand Up @@ -1085,7 +1085,7 @@ void func() {
Non-static nested classes work by containing an extra hidden member
(called the context pointer)
that is the frame pointer of the enclosing function if it is nested
inside a function, or the $(B this) of the enclosing class's instance
inside a function, or the $(D this) of the enclosing class's instance
if it is nested inside a class.

$(P When a non-static nested class is instantiated, the context pointer
Expand Down Expand Up @@ -1137,14 +1137,14 @@ int bar() {
}
---------

$(P Here $(B o) supplies the $(I this) to the outer class
instance of $(B Outer).
$(P Here $(D o) supplies the $(I this) to the outer class
instance of $(D Outer).
)

$(P The property $(B .outer) used in a nested class gives the
$(B this) pointer to its enclosing class. If the enclosing
context is not a class, the $(B .outer) will give the pointer
to it as a $(B void*) type.
$(P The property $(D .outer) used in a nested class gives the
$(D this) pointer to its enclosing class. If the enclosing
context is not a class, the $(D .outer) will give the pointer
to it as a $(D void*) type.
)

----
Expand Down Expand Up @@ -1175,11 +1175,10 @@ $(H3 $(LNAME2 anonymous, Anonymous Nested Classes))

$(GRAMMAR
$(GNAME NewAnonClassExpression):
$(D new) $(GLINK2 expression, AllocatorArguments)$(OPT) $(D class) $(I ClassArguments)$(OPT) $(GLINK SuperClass)$(OPT) $(GLINK Interfaces)$(OPT)
$(GLINK ClassBody)
$(D new) $(GLINK2 expression, AllocatorArguments)$(OPT) $(D class) $(I ClassArguments)$(OPT) $(GLINK SuperClass)$(OPT) $(GLINK Interfaces)$(OPT) $(GLINK ClassBody)

$(GNAME ClassArguments):
$(B $(LPAREN)) $(GLINK2 expression, ArgumentList)$(OPT) $(B $(RPAREN))
$(D $(LPAREN)) $(GLINK2 expression, ArgumentList)$(OPT) $(D $(RPAREN))
)

$(P which is equivalent to:
Expand All @@ -1196,13 +1195,14 @@ $(D new) $(D $(LPAREN))$(I ArgumentList)$(D $(RPAREN)) $(I Identifier) $(D $(LPA
nested class.
)

$(SECTION3 $(LNAME2 ConstClass, Const, Immutable and Shared Classes))
$(P If a $(I ClassDeclaration) has a $(CODE const), $(CODE immutable)
or $(CODE shared) storage class, then it is as if each member of the class
$(SECTION3 $(LNAME2 ConstClass, Const, Immutable and Shared Classes),

$(P If a $(I ClassDeclaration) has a $(D const), $(D immutable)
or $(D shared) storage class, then it is as if each member of the class
was declared with that storage class.
If a base class is const, immutable or shared, then all classes derived
from it are also const, immutable or shared.
)
)
)
)

Expand Down

0 comments on commit fddac4a

Please sign in to comment.