Skip to content

Commit

Permalink
Remove all $(V2 ...) macro calls
Browse files Browse the repository at this point in the history
  • Loading branch information
leandro-lucarella-sociomantic committed Feb 5, 2013
1 parent ae8f839 commit ddc9a8c
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 3,465 deletions.
60 changes: 4 additions & 56 deletions abi.dd
Expand Up @@ -89,7 +89,7 @@ $(TR $(TD $(I ptrsize)...) $(TD  ) $(TD vptr's for any interfaces implement

$(TABLE2 Virtual Function Pointer Table Layout,
$(TR $(TH size) $(TH contents))
$(TR $(TD $(I ptrsize)) $(TD pointer to instance of $(V1 ClassInfo)$(V2 TypeInfo)))
$(TR $(TD $(I ptrsize)) $(TD pointer to instance of ClassInfo))
$(TR $(TD $(I ptrsize)...) $(TD pointers to virtual member functions))
)

Expand Down Expand Up @@ -152,12 +152,6 @@ $(SECTION3 Interfaces,
that they were declared.
This matches the COM object layout used by Windows.
)
$(V2
$(P A C++ interface differs from a regular interface in that
it matches the layout of a C++ class using single inheritance
on the target machine.
)
)
)

$(SECTION3 Arrays,
Expand Down Expand Up @@ -194,9 +188,6 @@ $(SECTION3 Associative Arrays,
defined type.
$(V1 The current implementation is contained in and defined by
$(PHOBOSSRC internal/aaA.d).)
$(V2 The current implementation is contained in and defined by
$(DRUNTIMESRC rt/aaA.d).)
)
)

$(SECTION3 Reference Types,
Expand Down Expand Up @@ -394,8 +385,7 @@ $(I Type):
$(I Immutable)
$(I Wild)
$(I TypeArray)
$(V2 $(I TypeNewArray)
) $(I TypeStaticArray)
$(I TypeStaticArray)
$(I TypeAssocArray)
$(I TypePointer)
$(I TypeFunction)
Expand Down Expand Up @@ -445,9 +435,6 @@ $(I Wild):
$(I TypeArray):
$(B A) $(I Type)

$(V2 $(I TypeNewArray):
$(B Ne) $(I Type)
)
$(I TypeStaticArray):
$(B G) $(I Number) $(I Type)

Expand All @@ -458,7 +445,7 @@ $(I TypePointer):
$(B P) $(I Type)

$(I TypeFunction):
$(I CallConvention) $(V2 $(I FuncAttrs) )$(I Arguments) $(I ArgClose) $(I Type)
$(I CallConvention) $(I Arguments) $(I ArgClose) $(I Type)

$(I CallConvention):
$(B F) $(GREEN // D)
Expand All @@ -467,49 +454,12 @@ $(I CallConvention):
$(B V) $(GREEN // Pascal)
$(B R) $(GREEN // C++)

$(V2 $(I FuncAttrs):
$(I FuncAttr)
$(I FuncAttr) $(I FuncAttrs)

$(I FuncAttr):
$(I empty)
$(I FuncAttrPure)
$(I FuncAttrNothrow)
$(I FuncAttrProperty)
$(I FuncAttrRef)
$(I FuncAttrTrusted)
$(I FuncAttrSafe)

$(I FuncAttrPure):
$(B Na)

$(I FuncAttrNothrow):
$(B Nb)

$(I FuncAttrRef):
$(B Nc)

$(I FuncAttrProperty):
$(B Nd)

$(I FuncAttrTrusted):
$(B Ne)

$(I FuncAttrSafe):
$(B Nf)
)

$(I Arguments):
$(I Argument)
$(I Argument) $(I Arguments)

$(I Argument:)
$(V2
$(I Argument2)
$(B M) $(I Argument2) $(GREEN // scope)

$(I Argument2:)
) $(I Type)
$(I Type)
$(B J) $(I Type) $(GREEN // out)
$(B K) $(I Type) $(GREEN // ref)
$(B L) $(I Type) $(GREEN // lazy)
Expand Down Expand Up @@ -667,8 +617,6 @@ $(SECTION4 Return Value,
the future; it's there for backwards compatibility with
an earlier implementation of AA's.)

$(V2 $(LI References are returned as pointers in EAX.))

$(LI Delegates are returned with the pointer to the function
in EDX and the context pointer in EAX.)

Expand Down
97 changes: 7 additions & 90 deletions arrays.dd
Expand Up @@ -58,12 +58,7 @@ $(V1
and cannot be returned from functions.
)
)
$(V2
$(P Static arrays are value types. Unlike in C and D version 1,
static arrays are passed to functions by value.
Static arrays can also be returned by functions.
)
)


<h3>$(LNAME2 dynamic-arrays, Dynamic Arrays)</h3>

Expand Down Expand Up @@ -428,12 +423,6 @@ $(V1
The symbol $(B $) can also be so used.
)
)
$(V2
$(P Within the [ ] of a static or a dynamic array,
the symbol $(B $)
represents the length of the array.
)
)

---------
int[4] foo;
Expand All @@ -452,11 +441,7 @@ bar[0]+length // 'length' is not defined, out of scope of [ ]

bar[$(B length)-1] // retrieves last element of the array
)
$(V2 p[0 .. $(DOLLAR)] // '$' is not defined, since p is not an array
bar[0]+$(DOLLAR) // '$' is not defined, out of scope of [ ]

bar[$(B $(DOLLAR))-1] // retrieves last element of the array
)
---------

<h2>$(LNAME2 array-properties, Array Properties)</h2>
Expand All @@ -470,10 +455,6 @@ bar[$(B $(DOLLAR))-1] // retrieves last element of the array
$(TD $(B .init))
$(V1 $(TD returns the default initializer for the element type.)
)
$(V2 $(TD Returns an array literal with each element of the literal being the $(B .init)
property of the array element type.
)
)
)

$(TR
Expand Down Expand Up @@ -604,9 +585,7 @@ $(V1
$(D int opCmp(S)) or
$(D int opCmp(S*)).
)
$(V2
$(D int opCmp(ref const S) const).
)

The type $(D S) is the type of the struct or union.
This function will determine the sort ordering.
)
Expand Down Expand Up @@ -656,9 +635,6 @@ array = array[0..7];
array in place to avoid extra copying.
$(V1 It will always do a copy if the new size is larger and the array
was not allocated via the new operator or a previous resize operation.)
$(V2 It will always do a copy if the new size is larger and the array
was not allocated via the new operator or resizing in place would
overwrite valid data in the array.)
)

$(V1 $(P This means that if there is an array slice immediately following the
Expand All @@ -685,42 +661,10 @@ a.length = 25; // may or may not do a copy
a[3] = 'z'; // may or may not affect b[3] which still overlaps
// the old a[3]
---------
)

$(V2
For example:

---------
char[] a = new char[20];
char[] b = a[0..10];
char[] c = a[10..20];
char[] d = a;

b.length = 15; // always reallocates because extending in place would
// overwrite other data in a.
b[11] = 'x'; // a[11] and c[1] are not affected

d.length = 1;
d.length = 20; // also reallocates, because doing this will overwrite a and
// c

c.length = 12; // may reallocate in place if space allows, because nothing
// was allocated after c.
c[5] = 'y'; // may affect contents of a, but not b or d because those
// were reallocated.

a.length = 25; // This always reallocates because if c extended in place,
// then extending a would overwrite c. If c didn't
// reallocate in place, it means there was not enough space,
// which will still be true for a.
a[15] = 'z'; // does not affect c, because either a or c has reallocated.
---------
)

$(P To guarantee copying behavior, use the .dup property to ensure
a unique array that can be resized. $(V2 Also, one may use the phobos
$(D .capacity) property to determine how many elements can be appended
to the array without reallocating.)
a unique array that can be resized.
)

$(P These issues also apply to appending arrays with the ~= operator.
Expand All @@ -738,7 +682,7 @@ while (1) {
c = getinput();
if (!c)
break;
$(V2 ++array.length;)$(V1 array.length = array.length + 1;)
$(V1 array.length = array.length + 1;)
array[array.length - 1] = c;
}
---------
Expand All @@ -755,7 +699,7 @@ for (i = 0; ; i++) {
if (!c)
break;
if (i == array.length)
$(V2 array.length *= 2;)$(V1 array.length = array.length * 2;)
$(V1 array.length = array.length * 2;)
array[i] = c;
}
array.length = i;
Expand All @@ -767,9 +711,6 @@ array.length = i;
input from the console - it's unlikely to be longer than 80.
)

$(V2 $(P Also, you may wish to utilize the phobos $(D reserve)
function to pre-allocate array data to use with the append operator.))

<h3>$(LNAME2 func-as-property, Functions as Array Properties)</h3>

$(P If the first parameter to a function is an array, the
Expand All @@ -788,7 +729,7 @@ array.foo(3); // means the same thing

$(P It is an error to index an array with an index that is less than
0 or greater than or equal to the array length. If an index is
out of bounds, $(V1 an ArrayBoundsError)$(V2 a RangeError) exception is
out of bounds, $(V1 an ArrayBoundsError) exception is
raised if detected at runtime, and an error if detected at compile
time. A program may not rely on array bounds checking happening, for
example, the following program is incorrect:
Expand Down Expand Up @@ -904,26 +845,7 @@ string str;
string str1 = "abc";
---------
)
$(V2
---------
char[] str1 = "abc"; // error, "abc" is not mutable
char[] str2 = "abc".dup; // ok, make mutable copy
immutable(char)[] str3 = "abc"; // ok
immutable(char)[] str4 = str1; // error, str4 is not mutable
immutable(char)[] str5 = str1.idup; // ok, make immutable copy
---------

$(P The name $(CODE string) is aliased to $(CODE immutable(char)[]),
so the above declarations could be equivalently written as:
)
---------
char[] str1 = "abc"; // error, "abc" is not mutable
char[] str2 = "abc".dup; // ok, make mutable copy
string str3 = "abc"; // ok
string str4 = str1; // error, str4 is not mutable
string str5 = str1.idup; // ok, make immutable copy
---------
)
$(P $(CODE char[]) strings are in UTF-8 format.
$(CODE wchar[]) strings are in UTF-16 format.
$(CODE dchar[]) strings are in UTF-32 format.
Expand Down Expand Up @@ -978,10 +900,7 @@ $(V1
cast(wchar [])"abc" // this is an array of wchar characters
"abc"w // so is this
)
$(V2
cast(immutable(wchar) [])"abc" // this is an array of wchar characters
"abc"w // so is this
)

---------

$(P String literals that do not have a postfix character and that
Expand Down Expand Up @@ -1069,7 +988,6 @@ writefln("the string is '%s'", str);
$(UL
$(LI $(D $(I T)[]))
$(V1 $(LI $(D $(I U)[])))
$(V2 $(LI $(D const($(I U))[])))
$(LI $(D void[]))
)

Expand All @@ -1079,7 +997,6 @@ writefln("the string is '%s'", str);

$(UL
$(V1 $(LI $(D $(I U)[])))
$(V2 $(LI $(D const($(I U))[])))
$(LI $(D void[]))
)

Expand Down

0 comments on commit ddc9a8c

Please sign in to comment.