If I want to create my simple type, how can I access its value from the type method?
For example:
[IntegerType (rank = 6, signed = true, width = 32)]
[SimpleType]
[CCode (has_type_id = false)]
struct foo_t {
public string say_hello(){
return(@"Hello from new foo_t type");
}
public int x10(){
return this.value * 10;
}
}
Here this.value
throws an error The name 'value' does not exist
.
say_hello
works fine.
The answer was extremely simple, there is no hidden value
field, just this
is the current value.
[IntegerType (rank = 6, signed = true, width = 32)]
[SimpleType]
[CCode (has_type_id = false)]
struct foo_t {
public int x10(){
return this * 10;
}
}
void main () {
foo_t foo = 5;
prin(foo.x10());
}
[Print]
inline void prin (string str) {
stdout.printf (str + "\n");
}
Works fine!