How to create a PHP module with Vala programming language?

This new language, called Vala, which is said to be C # -like and possibly simpler than C ++ or C, compiles in C on Linux with the GCC compiler.

Sounds great. Now I want to use it to create a PHP extension module so that slow PHP code can be made into Vala and imported into PHP as a function.

How to do it in Vala? Is it possible?

+4
source share
3 answers

You need to use or write (if it does not exist) a VAPI file for the C library that you should use. It's quite simple, you just need to look at existing examples: http://live.gnome.org/Vala/Bindings or just: http://git.gnome.org/browse/vala/tree/vapi

+2
source

I donโ€™t know Valu, but if you can call native code, declare C structures and pass them as pointers to the specified native code and define functions that use C calling conventions, this should be possible. But in C / C ++ this will be easier to do.

Edit: his homepage says

valac creates C source and source files from Vala source files, as if you wrote your library or application directly in C. Using the Vala library from C application will not look different than using any other GObject-based library. There will not be a vala runtime library, and applications can distribute the generated C code with their archive files, so there are no additional runtime or build time dependencies for users.

So, although this is not final, I would say that you probably can.

+2
source

I created a simple example using Vala library from other languages:

https://github.com/antono/vala-object

Bindings for the vala library generated automatically by the GOobject self-examining function.

https://live.gnome.org/GObjectIntrospection

Use gobject-for-php and get bindings for free!

https://github.com/indeyets/gobject-for-php

+2
source

Source: https://habr.com/ru/post/1309835/


All Articles