Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use decimal128 for properties in a class inheriting from GLib.Object #14

Open
jtrees opened this issue Feb 12, 2020 · 4 comments
Open
Labels

Comments

@jtrees
Copy link

jtrees commented Feb 12, 2020

It seems decimal128 can't be used for properties in classes inheriting from GLib.Object.

Failing Code

public class Foo : GLib.Object {
    public Numeric.decimal128 bar {
        get { return 0; }
    }
}

Error Output

numeric-glib-1.0.vapi:131.2-131.25: error: The type `Numeric.decimal128` doesn't declare a GValue set function
	public struct decimal128

Working Code

public class Foo {
    public Numeric.decimal128 bar {
        get { return 0; }
    }
}
@arteymix
Copy link
Owner

It's a boxed type, so it should work. It might be missing CCode attributes in the VAPI.

@arteymix
Copy link
Owner

We have to set set_value_function to g_boxed_set_value. However, they are declared as value types, which means we need to tell Vala to use a reference. I'll figure this out.

@arteymix arteymix added the bug label Feb 13, 2020
@arteymix
Copy link
Owner

arteymix commented Feb 13, 2020

It turns out to be more complicated than I expected because Vala view those types as value-type so it does not take a reference or indirect a pointer around GValue get/set calls.

For types that fit in a pointer (8 bytes or less), we can do a very nice trick of storing the value in the boxed pointer.

For 80 and 128 bit types, it's going to be trickier because we can't make a copy without leaking memory. I think it can be done with some macro tricks.

I'll add numeric_value_get_{type} and numeric_value_set_{type} definitions to mimic GValue API but for numeric types.

@arteymix
Copy link
Owner

I still want to address the memory leak and the pointer optimization.

@arteymix arteymix reopened this Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants