Hi to all,
        I am trying to (re)write Vala bindings for libcurl.

I started following the instruction in this page
http://live.gnome.org/Vala/Bindings
and using information from this page
http://live.gnome.org/Vala/Manual/GIDL%20metadata%20format

At last I got a libcurl.gi that was close to what I expected and I tried
to write a metadata file to get an usable vapi file. Unfortunately I
have some problems completing the task.

I have attached an example containing some of the problem I am currently
facing. The libcurl.vapi.target is the desired vapi file, while the
libcurl.vapi is obtained from libcurl.gi and libcurl.metadata using
vapigen (0.14).

The main issues are:
1) How can I specify that a method (curl_easy_init) is the constructor
of a class (EasyHandle)?
2) How can I instruct vapigen that a function is a method of a class and
not a static function?
3) How can I instruct vapigen to put a cname attibute where needed (e.g.
for the EasyHandle class or the Code enumeration)?
4) How can I handle an enumeration value with a different prefix from
all the other values (e.g.: the last value in the Code enumeration)?
5) Is there any way I can put a static function in a nested namespace
(e.g.: Curl.Global.init())?

Thank you for your help.

Bests,
        Giulio.
<?xml version="1.0"?>
<api version="1.0">
  <namespace name="Curl">
    <struct name="CURL">
      <method name="easy_cleanup" symbol="curl_easy_cleanup">
	<return-type type="void"/>
	<parameters>
	  <parameter name="curl" type="CURL*"/>
	</parameters>
      </method>
      <method name="easy_getinfo" symbol="curl_easy_getinfo">
	<return-type type="CURLcode"/>
	<parameters>
	  <parameter name="curl" type="CURL*"/>
	  <parameter name="info" type="int"/>
	</parameters>
      </method>
      <method name="easy_init" symbol="curl_easy_init">
	<return-type type="CURL*"/>
      </method>
      <method name="global_init" symbol="curl_global_init">
	<return-type type="CURLcode"/>
	<parameters>
	  <parameter name="flags" type="long"/>
	</parameters>
      </method>
    </struct>
    <enum name="CURLcode">
      <member name="CURLE_OK" value="0"/>
      <member name="CURLE_UNSUPPORTED_PROTOCOL" value="1"/>
      <member name="CURLE_FAILED_INIT" value="2"/>
      <member name="CURL_LAST" value="89"/>
    </enum>
  </namespace>
</api>
Curl cheader_filename="curl/curl.h"
CURL name="EasyHandle" free_function="curl_easy_cleanup"
curl_easy_cleanup name="cleanup"
curl_easy_getinfo name="getinfo" printf_format=1 ellipsis=1
curl_easy_init name="EasyHandle"
CURLcode name="Code" common_prefix="CURLE_"
/* libcurl.vapi generated by vapigen, do not modify. */

namespace Curl {
	[CCode (cheader_filename = "curl/curl.h", free_function = "curl_easy_cleanup")]
	[Compact]
	public class EasyHandle {
		[CCode (cname = "curl_easy_init")]
		public static unowned Curl.EasyHandle EasyHandle ();
		[CCode (cname = "curl_easy_cleanup")]
		public static void cleanup (Curl.EasyHandle curl);
		[CCode (cname = "curl_easy_getinfo")]
		[PrintfFormat]
		public static Curl.Code getinfo (Curl.EasyHandle curl, int info, ...);
		[CCode (cname = "curl_global_init")]
		public static Curl.Code global_init (long flags);
	}
	[CCode (cheader_filename = "curl/curl.h", cprefix = "CURLE_", has_type_id = false)]
	public enum Code {
		OK,
		UNSUPPORTED_PROTOCOL,
		FAILED_INIT,
		AST
	}
}
[CCode (cheader_filename = "curl/curl.h")]
namespace Curl {
        [CCode (cname = "CURL", cprefix = "curl_easy_", cheader_filename = 
"curl/curl.h", free_function = "curl_easy_cleanup")]
        [Compact]
        public class EasyHandle {
                [CCode (cname = "curl_easy_init")]
                public EasyHandle ();
                [CCode (cname = "curl_easy_cleanup")]
                public void cleanup ();
                [CCode (cname = "curl_easy_getinfo")]
                [PrintfFormat]
                public Curl.Code getinfo (int info, ...);
        }
        namespace Global {
                  [CCode (cname = "curl_global_init")]
                  public static Curl.Code init (long flags);
        }
        [CCode (cname = "CURLcode", cheader_filename = "curl/curl.h", cprefix = 
"CURLE_")]
        public enum Code {
                OK,
                UNSUPPORTED_PROTOCOL,
                FAILED_INIT,
                [CCode (cname = "CURL_LAST")]
                LAST
        }
}
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to