Commit 82783461 authored by Jürg Billeter's avatar Jürg Billeter

glib-2.0: Return char instead of unichar from string element access

Use string.get_char () to retrieve unichar.
parent afd78dbc
......@@ -397,8 +397,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
List<Expression> indices = expr.get_indices ();
int rank = indices.size;
var container_type = expr.container.value_type.data_type;
var ccontainer = (CCodeExpression) expr.container.ccodenode;
var cindex = (CCodeExpression) indices[0].ccodenode;
if (expr.container.symbol_reference is ArrayLengthField) {
......@@ -411,16 +409,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
} else {
Report.error (expr.source_reference, "only integer literals supported as index");
}
} else if (container_type == string_type.data_type) {
// should be moved to a different module
// access to unichar in a string
var coffset = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, ccontainer, cindex);
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_utf8_get_char"));
ccall.add_argument (coffset);
expr.ccodenode = ccall;
} else {
// access to element in an array
for (int i = 1; i < rank; i++) {
......
......@@ -144,14 +144,6 @@ public class Vala.ElementAccess : Expression {
}
} else if (pointer_type != null && !pointer_type.base_type.is_reference_type_or_type_parameter ()) {
value_type = pointer_type.base_type.copy ();
} else if (analyzer.context.profile == Profile.GOBJECT && container_type == analyzer.string_type.data_type) {
if (get_indices ().size != 1) {
error = true;
Report.error (source_reference, "Element access with more than one dimension is not supported for strings");
return false;
}
value_type = analyzer.unichar_type;
} else if (analyzer.context.profile == Profile.DOVA && container_type == analyzer.tuple_type.data_type) {
if (get_indices ().size != 1) {
error = true;
......
......@@ -964,6 +964,10 @@ public class string {
[CCode (cname = "g_strnfill")]
public static string nfill (size_t length, char fill_char);
public char get (long index) {
return ((char*) this)[index];
}
[CCode (cname = "g_utf8_next_char")]
public unowned string next_char ();
[CCode (cname = "g_utf8_get_char")]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment