Thread overview
Is it possible to translate this API's C headers?
Sep 17, 2018
spikespaz
Sep 17, 2018
Mike Parker
Sep 17, 2018
Kagamin
Sep 17, 2018
Jonathan M Davis
Sep 18, 2018
Atila Neves
Sep 18, 2018
Kagamin
Sep 19, 2018
Jonathan M Davis
Sep 18, 2018
Guillaume Piolat
September 17, 2018
There is a project that I wish to use from D (https://ultralig.ht).

It's Electron, but with forked WebKit and the samples are very, very fast.

This is a great compromise between wanting to have a very custom interface and not wanting to use the slow Electron/Sciter/Awesomium/WebView.

I am having trouble porting the C headers though. Firstly, I barely know C at all, especially not enough to do this. The extent of my C knowledge is terminal TicTacToe game I made three years ago.

I tried using all of the conversion tools under the "Interfacing with C" page of the wiki, but I'm getting import errors. Probably because the paths are all using "<>", expecting an include path from the compiler. I tried to solve this by refractoring the imports to use relative quoted paths.

But even when I fixed that, I kept hitting miscellaneous problems with MSVC, LLVM, and every other dependency under the sun those conversion tools needed. So I figured that Windows was just a crappy ecosystem, and tried it on Linux. No easier.

So now I'm here, a C noob, really wanting to use Adam's great project from the D language. The only barrier is my lack of knowledge in C. And I definitely do not have the means to port these headers by hand.

Could one of you give me pointers about how to go about this? I have the dynamic link libraries, the static libraries, and the header includes.

https://github.com/ultralight-ux/ultralight
https://github.com/ultralight-ux/ultralight-0.9-api
September 17, 2018
On Monday, 17 September 2018 at 03:16:33 UTC, spikespaz wrote:
> There is a project that I wish to use from D (https://ultralig.ht).
>
> It's Electron, but with forked WebKit and the samples are very, very fast.
>
> This is a great compromise between wanting to have a very custom interface and not wanting to use the slow Electron/Sciter/Awesomium/WebView.
>
> I am having trouble porting the C headers though. Firstly, I barely know C at all, especially not enough to do this. The extent of my C knowledge is terminal TicTacToe game I made three years ago.
>
> I tried using all of the conversion tools under the "Interfacing with C" page of the wiki, but I'm getting import errors. Probably because the paths are all using "<>", expecting an include path from the compiler. I tried to solve this by refractoring the imports to use relative quoted paths.
>
> But even when I fixed that, I kept hitting miscellaneous problems with MSVC, LLVM, and every other dependency under the sun those conversion tools needed. So I figured that Windows was just a crappy ecosystem, and tried it on Linux. No easier.
>
> So now I'm here, a C noob, really wanting to use Adam's great project from the D language. The only barrier is my lack of knowledge in C. And I definitely do not have the means to port these headers by hand.
>
> Could one of you give me pointers about how to go about this? I have the dynamic link libraries, the static libraries, and the header includes.
>
> https://github.com/ultralight-ux/ultralight
> https://github.com/ultralight-ux/ultralight-0.9-api

FYI, those are C++ headers, not C. The page you read will get you part of the way there, but the Interfacing to C++ page would be more relevant:

https://dlang.org/spec/cpp_interface.html

Of course, if you don't know C++ that will only get you so far. If these were C headers, I'd just go ahead and translate them myself, but C++ headers will require a higher time investment from me because I'm not up to speed on the current state of D's C++ interface. There are people here who are more well informed who might be able to help, but it's going to require more than a few tips in a forum post.
September 17, 2018
try dpp https://github.com/atilaneves/dpp
September 17, 2018
On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via Digitalmars-d-learn wrote:
> try dpp https://github.com/atilaneves/dpp

Since according to Mike's post, it's C++ code, dpp wouldn't help, because it currently only supports C and not C++.

- Jonathan M Davis



September 18, 2018
On Monday, 17 September 2018 at 03:16:33 UTC, spikespaz wrote:
> Could one of you give me pointers about how to go about this? I have the dynamic link libraries, the static libraries, and the header includes.

Every other language other than C++ will have the same problem as you interacting with this library, so you could follow this plan.

Step 1
Chime in https://github.com/ultralight-ux/ultralight/issues/15 and wait until it is implemented: everyone will need this since its a C++ library hence unusable from any other language

Step 2
Ask for binary releases in dynlib form, or build them yourselves.

Step 3
Implement a BindBC or Derelict library
September 18, 2018
On Monday, 17 September 2018 at 19:13:06 UTC, Jonathan M Davis wrote:
> On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via Digitalmars-d-learn wrote:
>> try dpp https://github.com/atilaneves/dpp
>
> Since according to Mike's post, it's C++ code, dpp wouldn't help, because it currently only supports C and not C++.
>
> - Jonathan M Davis

It does C++ as well, just not all (or even close at this point) of it. I doubt it'd work on any real C++ codebase right now, but who knows. It definitely won't if any of the headers use the standard library, which is likely to happen.

It turns out that parsing C++ is a lot of work. Who knew? :P
September 18, 2018
On Tuesday, 18 September 2018 at 13:39:40 UTC, Atila Neves wrote:
> It does C++ as well, just not all (or even close at this point) of it. I doubt it'd work on any real C++ codebase right now, but who knows. It definitely won't if any of the headers use the standard library, which is likely to happen.

It doesn't look like that, https://github.com/ultralight-ux/ultralight-0.9-api/blob/master/include/Ultralight/Vector.h - this is probably the most complex code there.
September 19, 2018
On Tuesday, September 18, 2018 7:39:40 AM MDT Atila Neves via Digitalmars-d- learn wrote:
> On Monday, 17 September 2018 at 19:13:06 UTC, Jonathan M Davis
>
> wrote:
> > On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via
> >
> > Digitalmars-d-learn wrote:
> >> try dpp https://github.com/atilaneves/dpp
> >
> > Since according to Mike's post, it's C++ code, dpp wouldn't help, because it currently only supports C and not C++.
> >
> > - Jonathan M Davis
>
> It does C++ as well, just not all (or even close at this point) of it. I doubt it'd work on any real C++ codebase right now, but who knows. It definitely won't if any of the headers use the standard library, which is likely to happen.

Well, the repo claims that it currently only does C - hence why I said that it will only do C (though even if it partially supports C++, odds are it's not enough to matter unless you know what you're doing - which the OP clearly doesn't, since they don't know C/C++).

> It turns out that parsing C++ is a lot of work. Who knew? :P

Yeah...

- Jonathan M Davis