Hi, I'm working on my first binding for a non-gobject library -- please see gsm0710_p.h.
My current vapi is also attached. I'm struggling with setting the callback pointers now. How should the callbacks in my .vala object be defined so that I can set them via e.g. <callback> var ctx = new Context(); ctx.at_command = <callback> Cheers, Mickey. -- :M:
/**************************************************************************** ** ** Copyright (C) 2000-2008 TROLLTECH ASA. All rights reserved. ** ** This file is part of the Opensource Edition of the Qtopia Toolkit. ** ** This software is licensed under the terms of the GNU General Public ** License (GPL) version 2. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact i...@trolltech.com if any conditions of this licensing are ** not clear to you. ** ** ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #ifndef GSM0710_P_H #define GSM0710_P_H // // W A R N I N G // ------------- // // This file is not part of the Qtopia API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #ifdef __cplusplus extern "C" { #endif #define GSM0710_BUFFER_SIZE 4096 #define GSM0710_DEFAULT_FRAME_SIZE 31 #define GSM0710_MAX_CHANNELS 63 #define GSM0710_MODE_BASIC 0 #define GSM0710_MODE_ADVANCED 1 /* Frame types and subtypes */ #define GSM0710_OPEN_CHANNEL 0x3F #define GSM0710_CLOSE_CHANNEL 0x53 #define GSM0710_DATA 0xEF #define GSM0710_DATA_ALT 0x03 #define GSM0710_STATUS_SET 0xE3 #define GSM0710_STATUS_ACK 0xE1 #define GSM0710_TERMINATE_BYTE1 0xC3 #define GSM0710_TERMINATE_BYTE2 0x01 /* Status flags */ #define GSM0710_FC 0x02 #define GSM0710_DTR 0x04 #define GSM0710_DSR 0x04 #define GSM0710_RTS 0x08 #define GSM0710_CTS 0x08 #define GSM0710_DCD 0x80 struct gsm0710_context { /* GSM 07.10 implementation details */ int mode; int frame_size; int port_speed; int server; char buffer[GSM0710_BUFFER_SIZE]; int buffer_used; unsigned long used_channels[(GSM0710_MAX_CHANNELS + 31) / 32]; const char *reinit_detect; int reinit_detect_len; /* Hooks to other levels */ void *user_data; int fd; int (*at_command)(struct gsm0710_context *ctx, const char *cmd); int (*read)(struct gsm0710_context *ctx, void *data, int len); int (*write)(struct gsm0710_context *ctx, const void *data, int len); void (*deliver_data)(struct gsm0710_context *ctx, int channel, const void *data, int len); void (*deliver_status)(struct gsm0710_context *ctx, int channel, int status); void (*debug_message)(struct gsm0710_context *ctx, const char *msg); void (*open_channel)(struct gsm0710_context *ctx, int channel); void (*close_channel)(struct gsm0710_context *ctx, int channel); void (*terminate)(struct gsm0710_context *ctx); int (*packet_filter)(struct gsm0710_context *ctx, int channel, int type, const char *data, int len); }; void gsm0710_initialize(struct gsm0710_context *ctx); void gsm0710_set_reinit_detect(struct gsm0710_context *ctx, const char *str); int gsm0710_startup(struct gsm0710_context *ctx, int send_cmux); void gsm0710_shutdown(struct gsm0710_context *ctx); int gsm0710_open_channel(struct gsm0710_context *ctx, int channel); void gsm0710_close_channel(struct gsm0710_context *ctx, int channel); int gsm0710_is_channel_open(struct gsm0710_context *ctx, int channel); void gsm0710_ready_read(struct gsm0710_context *ctx); void gsm0710_write_frame(struct gsm0710_context *ctx, int channel, int type, const char *data, int len); void gsm0710_write_data(struct gsm0710_context *ctx, int channel, const void *data, int len); void gsm0710_set_status(struct gsm0710_context *ctx, int channel, int status); int gsm0710_compute_crc(const char *data, int len); #ifdef __cplusplus }; #endif #endif
/* * gsm0710.vapi * * Authored by Michael 'Mickey' Lauer <mla...@vanille-media.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ [CCode (cheader_filename = "gsm0710/gsm0710_p.h")] namespace Gsm0710 { [CCode (cname = "GSM0710StatusType", cprefix="GSM0710_")] public enum StatusType { FC, DTR, DSR, RTS, CTS, DCD } [CCode (cname = "struct gsm0710_context", free_function = "")] [Compact] public class Context { /* Internal */ public int mode; public int frame_size; public int port_speed; public int server; // not mapping char buffer[]; // not mapping int buffer_used; // not mapping unsingedl long used_channels[]; // not mapping const char* reinit_detect; // not mapping int reinit_detect_len; /* Hooks to other levels */ public void* user_data; public int fd; public static delegate int at_command_t( char* command ); public static delegate int read_t( void* data, int len ); public static delegate int write_t( void* data, int len ); public static delegate void deliver_data_t( int channel, void* data, int len ); public static delegate void deliver_status_t( int channel, int status ); public static delegate void debug_message_t( char* msg ); public static delegate void open_channel_t( int channel ); public static delegate void close_channel_t( int channel ); public static delegate void terminate_t(); public static delegate int packet_filter_t( int channel, int type, char* data, int len ); public at_command_t at_command; public read_t read; public write_t write; public deliver_data_t deliver_data; public deliver_status_t deliver_status; public debug_message_t debug_mesage; public open_channel_t open_channel; public close_channel_t close_channel; public terminate_t terminate; public packet_filter_t packet_filter; [CCode (cname = "gsm0710_initialize")] public void initialize(); [CCode (cname = "gsm0710_startup")] public int startup( int send_cmux ); [CCode (cname = "gsm0710_shutdown")] public void shutdown(); [CCode (cname = "gsm0710_open_channel")] public int openChannel( int channel ); [CCode (cname = "gsm0710_close_channel")] public void closeChannel( int channel ); [CCode (cname = "gsm0710_is_channel_open")] public int isChannelOpen( int channel ); [CCode (cname = "gsm0710_ready_read")] public void readyRead(); [CCode (cname = "gsm0710_write_data")] public void writeDataForChannel( int channel, void *data, int len ); [CCode (cname = "gsm0710_set_status")] public void gsm0710_set_status( int channel, int status ); } }
_______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list