Re: [Firebird-devel] Pure C methods for IBatch
> public delegate* unmanaged[Cdecl] FIREBIRD_IStatus*> getStatus; I completely ruled out function pointers because I still support .NET Framework and it's not supported there. But on the second thought this might be a nail in the coffin of .NET Framework support. Thanks for kicking me. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
On 17/01/2022 17:31, Jiří Činčura wrote: >> I suspect you didn't understand well how easy it is. > > I'm all ears. Or actually eyes - I'll be glad to learn some new C#/.NET > interop tricks. > I'd not say it's tricks, certainly not for you. I just see no difficulty in this more than the C approach you have said to be better. class Program { [DllImport("libfbclient.so", CallingConvention = CallingConvention.Cdecl)] public static unsafe extern FIREBIRD_IMaster* fb_get_master_interface(); static unsafe void Main(string[] args) { var master = fb_get_master_interface(); var dispatcher1 = master->vTable->getDispatcher(master); // Or this, to repeat less things var masterVTable = master->vTable; var dispatcher2 = masterVTable->getDispatcher(master); } } With the below declarations (that can be generated automatically if large parts are needed), or similar wrappers (also automatically generated) directly in C# as the .c one. [StructLayout(LayoutKind.Sequential)] unsafe struct FIREBIRD_IMasterVTable { public IntPtr cloopDummy; public UIntPtr version; public delegate* unmanaged[Cdecl] getStatus; public delegate* unmanaged[Cdecl] getDispatcher; // ... /* struct FIREBIRD_IPluginManager* (*getPluginManager)(struct FIREBIRD_IMaster* self); struct FIREBIRD_ITimerControl* (*getTimerControl)(struct FIREBIRD_IMaster* self); struct FIREBIRD_IDtc* (*getDtc)(struct FIREBIRD_IMaster* self); struct FIREBIRD_IAttachment* (*registerAttachment)(struct FIREBIRD_IMaster* self, struct FIREBIRD_IProvider* provider, struct FIREBIRD_IAttachment* attachment); struct FIREBIRD_ITransaction* (*registerTransaction)(struct FIREBIRD_IMaster* self, struct FIREBIRD_IAttachment* attachment, struct FIREBIRD_ITransaction* transaction); struct FIREBIRD_IMetadataBuilder* (*getMetadataBuilder)(struct FIREBIRD_IMaster* self, struct FIREBIRD_IStatus* status, unsigned fieldCount); int (*serverMode)(struct FIREBIRD_IMaster* self, int mode); struct FIREBIRD_IUtil* (*getUtilInterface)(struct FIREBIRD_IMaster* self); struct FIREBIRD_IConfigManager* (*getConfigManager)(struct FIREBIRD_IMaster* self); FB_BOOLEAN (*getProcessExiting)(struct FIREBIRD_IMaster* self); */ } [StructLayout(LayoutKind.Sequential)] unsafe struct FIREBIRD_IMaster { public IntPtr cloopDummy; public FIREBIRD_IMasterVTable* vTable; } [StructLayout(LayoutKind.Sequential)] unsafe struct FIREBIRD_IStatus { // ... } [StructLayout(LayoutKind.Sequential)] unsafe struct FIREBIRD_IProvider { // ... } Adriano Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
> I suspect you didn't understand well how easy it is. I'm all ears. Or actually eyes - I'll be glad to learn some new C#/.NET interop tricks. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
On Mon, Jan 17, 2022 at 4:49 PM Jiří Činčura wrote: > > Similar thing could be done for C#. > > Again, I'm not saying it couldn't be done. > > It's just with simple export I can call it right here, right now (i.e. > https://github.com/FirebirdSQL/NETProvider/blob/master/src/FirebirdSql.Data.FirebirdClient/Client/Native/IFbClient.cs#L83-L85). > It's there, platform supports it, done. :) > > I suspect you didn't understand well how easy it is. Or maybe I didn't understand what you wanted, but... > I don't think we need to talk about it more. > Ok then. Adriano Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
> Similar thing could be done for C#. Again, I'm not saying it couldn't be done. It's just with simple export I can call it right here, right now (i.e. https://github.com/FirebirdSQL/NETProvider/blob/master/src/FirebirdSql.Data.FirebirdClient/Client/Native/IFbClient.cs#L83-L85). It's there, platform supports it, done. :) I don't think we need to talk about it more. Pure C export is not there and will not be added. Hence I'll have to eventually work around it and implement "C++ calling". -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
On 17/01/2022 15:36, Jiří Činčura wrote: >> The "C library" is just another way to call things. >> >> It's binary compatible with the C++ interface. In fact the C++ interface >> is a wrapper around C objects to be multi compiler compatible. > > Sure, I'm not saying it isn't. > > It's just way way harder to do this type of interop from C# compared to > simply calling exported function from fbclient. Something like 11 out of 10 > people will tell you to get/create a wrapper. Which is fine if you own the > code. Not the case here. > >> I don't know how you call fbclient in the .NET code. >> >> But I remember C# can map C DLL with attributes. >> >> So I believe it's possible to map the current fbclient functions >> directly in C# code. > > That expects exports with `extern "C"`. > There is fb_get_master_interface. It's an "extern C" function. And it's the only exported function of the new API. Everything else is in function pointers of structs similar to vtable of C++ classes. For FB/Java I have created Java generator in cloop. Most of this file is auto generated: https://github.com/FirebirdSQL/fbjava/blob/master/src/fbjava-impl/src/main/java/org/firebirdsql/fbjava/impl/FbClientLibrary.java Similar thing could be done for C#. Adriano Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
> The "C library" is just another way to call things. > > It's binary compatible with the C++ interface. In fact the C++ interface > is a wrapper around C objects to be multi compiler compatible. Sure, I'm not saying it isn't. It's just way way harder to do this type of interop from C# compared to simply calling exported function from fbclient. Something like 11 out of 10 people will tell you to get/create a wrapper. Which is fine if you own the code. Not the case here. > I don't know how you call fbclient in the .NET code. > > But I remember C# can map C DLL with attributes. > > So I believe it's possible to map the current fbclient functions > directly in C# code. That expects exports with `extern "C"`. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
On 17/01/2022 11:00, Jiří Činčura wrote: >> Yes - because we can generate pure C OO API in a form I've attached here >> for illustration. > > That would work for me. :) > >> No - we never included it into distribution because currently it's not >> ready for use, some tuning will be needed. Next, you will have to use >> shared library based on .c generated file and serving as a proxy between >> tour program and fbclient. > > I was hoping to have this in fbclient directly. Now it looks like I need to > do basically the same to be able to use batching in Embedded in .NET provider. > The "C library" is just another way to call things. It's binary compatible with the C++ interface. In fact the C++ interface is a wrapper around C objects to be multi compiler compatible. I don't know how you call fbclient in the .NET code. But I remember C# can map C DLL with attributes. So I believe it's possible to map the current fbclient functions directly in C# code. Adriano Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
> Yes - because we can generate pure C OO API in a form I've attached here > for illustration. That would work for me. :) > No - we never included it into distribution because currently it's not > ready for use, some tuning will be needed. Next, you will have to use > shared library based on .c generated file and serving as a proxy between > tour program and fbclient. I was hoping to have this in fbclient directly. Now it looks like I need to do basically the same to be able to use batching in Embedded in .NET provider. -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Pure C methods for IBatch
On 1/17/22 15:02, Jiří Činčura wrote: Hi *, I'm looking at 12.batch_isc.cpp and wondering whether there's a way to do batching using pure C methods [1]. Something like simply calling isc_dsql_prepare instead of IAttachment::prepare. I know I can handle the "this" manually, but that's PIA. :) Yes and no. Yes - because we can generate pure C OO API in a form I've attached here for illustration. No - we never included it into distribution because currently it's not ready for use, some tuning will be needed. Next, you will have to use shared library based on .c generated file and serving as a proxy between tour program and fbclient. FirebirdInterface.7z Description: application/7z-compressed Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
[Firebird-devel] Pure C methods for IBatch
Hi *, I'm looking at 12.batch_isc.cpp and wondering whether there's a way to do batching using pure C methods [1]. Something like simply calling isc_dsql_prepare instead of IAttachment::prepare. I know I can handle the "this" manually, but that's PIA. :) -- Mgr. Jiří Činčura https://www.tabsoverspaces.com/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel