[Y-devel] libYc-0.2

Richard Hills richard at playford.net
Fri Feb 27 18:47:10 GMT 2004


hey,
> In object.c, the Y_CreateObjectFromClassName function doesn't take into
> account the class not being found (Y_FindClassID returning 0), or am I
> missing something?

        This is true, there are lots of checks which libYc should do which it
doesn't yet. Will work on this.

> Also are you open to creating some alternative functions for wrapper
> libraries. I'm writing a C# binding for Y (I haven't added myself to the
> Wiki yet) and I'm trying to keep as many C-isms out of my code as
> possible such as the object structs.

        Mmm... I haven't used C#, but are structs really that bad? As far
client apps are converned they are just messing around with pointers,
and they wont have to change internal structure values. In future these
pointers will be typedefed, so it will make no difference.

> At the moment I'm using libY and four of its functions: yInitialise,
> yFinalise, ySend, yReceive. I currently handle 

        Don't use libY - it's a broken design. I started libYc from libY and
regret doing so. It's been removed from the latest versions of Y anyway.

> Here is the listing of functions I'd like to have available to me:
> 
> - int Y_ObjectCreate(int classId)
> // returns the objectId or 0 if unsuccessful
<Snip>
> - char * YObject_InvokeMethod(int objectId, const char *methodName,
> const char *methodArgs, int expectReturn)
> // returns the response's data or null if unsuccessful and methodArgs
> may be null

        I'm not too comfortable about writing special functions in liYc to
accommodate libYc#. From a C app point of view we don't want to touch
ints which represent objects, we'll have an object type instead. If you
want to refer to them by ints I think it better that libYc# contains the
transform layer. I'm more happy to put special "YObject_GetOid" and
"YObject_FindFromOid" functions to help with this layer, but I do not
think there should be, basically, two APIs for libYc.
        The other option, if writing this interface layer is too difficult,
would be to just write all the base functions from scratch in C#. I
don't know C# and so can't say how hard this'd be.

> The last one I'm up in the air about. I'm not sure of the best way to go
> about do listing for events. Here are two ideas:
> 
> (1) char * YSignal_Receive(int objectId)
> // returns the response's data (signalName and signalArgs) and updates
> the objectId -- this method is synchronous and I'll poll it in its own
> thread.
> 
> (2) int YSignal_Receive( <a callback with 3 args> )
> // execute it when the a signal is fired such as:
> "void SignalReceived(int objectId, const char *signalName, const char
> *signalArgs)"
> I'm not sure how to accomplish this... I've never had to pass a C#
> delegate to native code or would I attempt to pass the address as:
> YSignal_Receive(ref mySignalReceivingMethod)

        Signalling is something I'm still thinking about for libYc. You
shouldn't be able to subscribe to signals from libYc, since this just
means the server will send these messages to libYc, and it'll then not
know what to do with them. Instead signals should be "connected" to with
callback functions. Anyway, back to C#...
        As I've said, I don't think writing special libYc functions would be a
good idea. I could instead put a hook into libYc so that when a message
is received a different processMessage() function is called, which can
then call a C# function for that message. You would just have to call
Y_Iterate every so often (where the processMessage() call will soon be
made). However, you will have to keep a list of all the message types
the client app has connected to, and the callback to do once that
message is received.
        Anyway, this is getting rather complex. I'm happy to put some extra
hooks in, but doubling up most of the API seems a bit pointless as we're
trying to reduce the level of code duplication. Hope this helps,

Richard Hills





More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved