Re: [Vala] A few newbie's questions
- From: Giulio Paci <giuliopaci gmail com>
- To: Sandino Flores Moreno <tigrux gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] A few newbie's questions
- Date: Fri, 04 Feb 2011 00:33:49 +0100
Hi Sandino,
thank you for your very quick reply,
Il 03/02/2011 23:23, Sandino Flores Moreno ha scritto:
On Thu, Feb 3, 2011 at 3:27 PM, Giulio Paci <giuliopaci gmail com> wrote:
1) I tried to create a gstreamer plugin following the Gstreamer Plugin
Writer's Guide
(http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html).
I was able to create the plugin, but I was not able to create it using
vala alone, because I was not able to insert in the generated C output
this code:
#include <glib.h>
#include <gst/gst.h>
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"my_filter",
"My filter plugin",
plugin_init,
VERSION,
"LGPL",
"GStreamer",
"http://gstreamer.net/"
)
At last I decided it was not a big issue to put this code in a C file,
but is there any way to directly inject C code in vala?
Regarding question 1:
==================
Check the next source code:
https://github.com/tigrux/gst-plugin-omap4videodecbin/blob/master/gst/gstomap4videodecbin.vala
There you can see a line like these:
public const Gst.PluginDesc gst_plugin_desc = {
...
}
That's what you are missing in your gstreamer plugin.
This is very close to what I wanted.
What I'm still missing is the possibility to use PACKAGE and VERSION
macros.
2) I tried to read a file, one line at time, using the FileStream
object, but I was not able to get the desired result with the current
API, because I needed the whole line (EOL inclusive), while read_line()
removes it. The work around of adding a new line to each line does not
allow to know if the last character of the file was a new line or not.
Is there any way to (easily) read a file including the EOL character?
Regarding question 2:
==================
Use the method FileStream.gets which corresponds to fgets.
public unowned string FileStream.gets (char[] s);
From the man page of fgets:
gets() reads a line from stdin into the buffer pointed to by s until
either a terminating newline or EOF, which it replaces with '\0'. No
check for buffer overrun is performed (see BUGS below).
gets() reads a line from stdin into the buffer pointed to by s until
either a terminating newline or EOF, which it replaces with '\0'. No
check for buffer overrun is performed (see BUGS below).
This sounds exactly what I need. As I need to have valid utf-8
characters, do I have to perform any check for the last returned bytes
(if the line is longer than the char array) or does FileStream.gets
guarantee that the last returned character is valid?
By the way, Is there a better documentation than
http://www.valadoc.org/glib-2.0/GLib.FileStream.html? By reading it I
avoided even trying FileStream.gets as I thought it was just some sort
of gets and not fgets.
Bests,
Giulio.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]