Re: [Vala] embedding c code snippet in vala source.



Jürg Billeter пишет:
On Fri, 2008-08-22 at 05:09 -0400, Yu Feng wrote:
On Fri, 2008-08-22 at 10:44 +0200, Jürg Billeter wrote:
Maybe I'm just missing an interesting use case, however, I currently
fail to see where the snippet approach makes it more comfortable to
write or use bindings. Can you provide examples where you think that it
makes more sense to handle it in a snippet instead of the compiler code?
I'm not convinced by the g_strv_length example as this would clutter the
bindings too much, in my opinion.
Again it is for rare cases. I am thinking hard to make the snipples
working well, and I'll collect more cases later. I don't expect there to
be much though. Should it be much fewer than [NoArrayLength] stuff.

Ok, as you agree that the null-terminated arrays should be handled, your
g_strv_length example is not a real use case for the snippet support.
Can you provide a concrete example where you think it makes more sense
to use a CCode snippet than anything else?

Another case - utf8-compatible replacement for g_strndup()

You can see 15 bugs in vala-0.3.5 sources only...

[avl localhost vala-0.3.5]$ find -name "*.vala" | xargs grep -E '\.ndup' | wc -l
15
[avl localhost vala-0.3.5]$ find -name "*.vala" | xargs grep -E '\.ndup'
./vala/valastringliteral.vala: var noquotes = value.offset (1).ndup ((uint) (value.len () - 2)); ./vala/valaparser.vala: return ((string) tokens[last_index].begin.pos).ndup ((tokens[last_index].end.pos - tokens[last_index].begin.pos)); ./vala/valageniescanner.vala: push_comment (((string) begin).ndup ((long) (current - begin)), line == 1); ./vala/valageniescanner.vala: push_comment (((string) begin).ndup ((long) (current - begin)), begin_line == 1); ./vala/valaintegerliteral.vala: number = number.ndup (number.size () - 1); ./vala/valaintegerliteral.vala: number = number.ndup (number.size () - 1); ./vala/valagenieparser.vala: return ((string) tokens[last_index].begin.pos).ndup ((tokens[last_index].end.pos - tokens[last_index].begin.pos)); ./vala/valagenieparser.vala: var st = s_exp.value.ndup (len-1); ./vala/valascanner.vala: push_comment (((string) begin).ndup ((long) (current - begin)), line == 1); ./vala/valascanner.vala: push_comment (((string) begin).ndup ((long) (current - begin)), begin_line == 1); ./vapigen/valagidlparser.vala: string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.size () - ".gi".size ())); ./vapigen/valagidlparser.vala: common_prefix = common_prefix.ndup (common_prefix.size () - 1); ./vapigen/valagidlparser.vala: common_prefix = common_prefix.ndup (common_prefix.size () - 1); ./vapigen/valagidlparser.vala: common_prefix = common_prefix.ndup (common_prefix.size () - 1); ./vapigen/valagidlparser.vala: return s.offset (1).ndup (s.size () - 2);



glib not have g_utf8_strndup(), but have g_utf8_strncpy()

We must wrapped this function.

1) Create own separate library for 3 lines C-code only? Develop, create projects, maintain, build rpms and srpms for various distros and arch)?

2) Create C-file and include via extern in all own vala projects?


BTW: I found a way to kill the vast number static wrappers in DBus
dynamic methods. File a new bug?

Sure.

Cheers,
Jürg

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]