From: Juerg Billeter Date: Thu, 1 May 2008 17:12:01 +0000 (+0000) Subject: Extend types section, based on patch by Phil Housley X-Git-Tag: VALA_0_3_2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fba1d053dcd377c2f50a909898afda00a24d4167;p=thirdparty%2Fvala.git Extend types section, based on patch by Phil Housley 2008-05-01 Juerg Billeter * doc/vala/types.xml: * doc/vala/default.css: * doc/vala/xhtml.xsl: Extend types section, based on patch by Phil Housley svn path=/trunk/; revision=1331 --- diff --git a/ChangeLog b/ChangeLog index cc98fdc5a..5b03e9797 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-01 Jürg Billeter + + * doc/vala/types.xml: + * doc/vala/default.css: + * doc/vala/xhtml.xsl: + + Extend types section, based on patch by Phil Housley + 2008-05-01 Jürg Billeter * vala/valacfgbuilder.vala: diff --git a/doc/vala/default.css b/doc/vala/default.css index 70eeb964e..9294f2653 100644 --- a/doc/vala/default.css +++ b/doc/vala/default.css @@ -8,7 +8,7 @@ h1, h2, h3, h4 { color: #005a9c; } -a { +a:link, a:visited, a:hover, a:active { color: #005a9c; text-decoration: none; } @@ -69,3 +69,8 @@ blockquote { white-space: pre; } +blockquote span.literal { + font-family: monospace; + font-style: normal; + font-weight: bold; +} diff --git a/doc/vala/types.xml b/doc/vala/types.xml index 75a554d3f..bd9ae1b1d 100644 --- a/doc/vala/types.xml +++ b/doc/vala/types.xml @@ -1,15 +1,166 @@
Types -

Vala supports two kinds of data types: value types and reference types. Value types include simple types (e.g. char, int, and float), enum types, and struct types. Reference types include class types, interface types, and array types.

+

Vala supports four kinds of data types: value types, reference types, type parameters, and pointer types. Value types include simple types (e.g. char, int, and float), enum types, and struct types. Reference types include object types, array types, delegate types, and error types. Type parameters are parameters used in generic types.

Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to their data, the latter being known as objects. With reference types, it is possible for two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. With value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.

+
+type: + value-type + reference-type + nullable-type + type-parameter + pointer-type +
Value types -

Documentation

+

Instances of value types are stored directly in variables. They are duplicated whenever assigned to another variable (e.g. passed to a method). For local variables, value types are stored on the stack.

+
+value-type: + struct-type + enum-type + +struct-type: + type-name + integral-type + floating-point-type + bool + +integral-type: + char + uchar + short + ushort + int + uint + long + ulong + size_t + ssize_t + int8 + uint8 + int16 + uint16 + int32 + uint32 + int64 + uint64 + unichar + +floating-point-type: + float + double + +enum-type: + type-name +
+
+ Struct types +

Documentation

+
+
+ Simple types +

Documentation

+
+
+ Integral types +

Documentation

+
+
+ Floating point types +

Documentation

+
+
+ The bool type +

Documentation

+
+
+ Enumeration types +

An enumeration type is a type containing named constants.

+

See enums.

+
Reference types -

Documentation

+

Instances of reference types are always stored on the heap. Variables contain references to them. Assigning to another variable duplicates reference, not object.

+
+reference-type: + object-type + class-type + array-type + delegate-type + error-type + weak-reference-type + +weak-reference-type: + weak object-type + weak class-type + weak array-type + weak delegate-type + weak error-type + +object-type: + type-name + string + +class-type: + type-name . Class + +array-type: + non-array-type [] + non-array-type [ dim-seperators ] + +non-array-type: + value-type + object-type + class-type + delegate-type + error-type + +dim-separators: + , + dim-separators , + +delegate-type: + type-name + +error-type: + type-name +
+
+ Weak reference types +

Documentation

+
+
+ Array types +

An array is a data structure that contains zero or more elements of the same type.

+
+
+ Delegate types +

A delegate is a data structure that refers to a method, and for instance methods, it also refers to the corresponding object instance.

+
+
+ Error types +

Instances of error types represent recoverable runtime errors.

+
+
+
+ Nullable types +

An instance of a nullable type T? can either be a value of type T or null.

+
+nullable-type: + value-type ? + reference-type ? +
+
+
+ Pointer types +

Unlike references, pointers are not tracked by the memory manager. The value of a pointer having type T* represents the address of a variable of type T. The pointer indirection operator * can be used to access this variable. Like a nullable object reference, a pointer can be null. The void* type represents a pointer to an unknown type. As the referent type is unknown, the indirection operator cannot be applied to a pointer of type void*, nor can any arithmetic be performed on such a pointer. However, a pointer of type void* can be cast to any other pointer type (and vice versa) and compared to values of other pointer types.

+
+pointer-type: + type-name * + pointer-type * + void* +
diff --git a/doc/vala/xhtml.xsl b/doc/vala/xhtml.xsl index 006e29048..607fbaccd 100644 --- a/doc/vala/xhtml.xsl +++ b/doc/vala/xhtml.xsl @@ -1,6 +1,7 @@ + @@ -52,7 +53,7 @@
- + @@ -61,11 +62,17 @@

- +

+ + + + +

+
@@ -82,7 +89,19 @@
-
+
+
+ + + + +
+
+ +
+
+ +