X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fswig%2Fmelted.i;h=9f874c89d607a1e116c01b3fb095378e804c42dc;hb=2e52de54cf0de8e2767e48dc0504cd0eb59281ec;hp=e261d1d2acbc215d0452b659cd36d8b452ecca75;hpb=27f0329aa8f434794f1f18e018fc3221e58b77a4;p=melted diff --git a/src/swig/melted.i b/src/swig/melted.i index e261d1d..9f874c8 100644 --- a/src/swig/melted.i +++ b/src/swig/melted.i @@ -1,6 +1,6 @@ /** * melted.i - Swig Bindings for melted++ - * Copyright (C) 2004-2005 Charles Yates + * Copyright (C) 2004-2009 Charles Yates * Author: Charles Yates * * This program is free software; you can redistribute it and/or modify @@ -23,7 +23,9 @@ %array_class(unsigned char, unsignedCharArray); %{ -#include +#include +#include +#include %} /** These methods return objects which should be gc'd. @@ -31,6 +33,7 @@ namespace Mlt { %newobject Melted::execute( char * ); +%newobject Melted::received( char *, char * ); %newobject Melted::push( char *, Service & ); %newobject Melted::unit( int ); } @@ -38,5 +41,67 @@ namespace Mlt { /** Classes to wrap. */ -%include +%include %include + +#if defined(SWIGRUBY) + +%{ + +static void ruby_listener( mlt_properties owner, void *object ); + +class RubyListener +{ + private: + VALUE callback; + Mlt::Event *event; + + public: + RubyListener( Mlt::Properties &properties, char *id, VALUE callback ) : + callback( callback ) + { + event = properties.listen( id, this, ( mlt_listener )ruby_listener ); + } + + ~RubyListener( ) + { + delete event; + } + + void mark( ) + { + ((void (*)(VALUE))(rb_gc_mark))( callback ); + } + + void doit( ) + { + ID method = rb_intern( "call" ); + rb_funcall( callback, method, 0 ); + } +}; + +static void ruby_listener( mlt_properties owner, void *object ) +{ + RubyListener *o = static_cast< RubyListener * >( object ); + o->doit( ); +} + +void markRubyListener( void* p ) +{ + RubyListener *o = static_cast( p ); + o->mark( ); +} + +%} + +// Ruby wrapper +%rename( Listener ) RubyListener; +%markfunc RubyListener "markRubyListener"; + +class RubyListener +{ + public: + RubyListener( Mlt::Properties &properties, char *id, VALUE callback ); +}; + +#endif