On 13/09/12 23:58, Francisco Lopes wrote:
Some days ago I've created a topic
<https://groups.google.com/d/topic/vim_dev/F2z5I9tayKY/discussion> about
using libffi for an enhanced native call interface.
I've changed my mind all the way about how to build a native call
interface for VIM, right
now I'm changing VIM sources to implement it as I'm thinking, some
comments at this stage
would be good.
Goals:
Make VIM able to call and be called, efficiently, from native
libraries built as VIM plugins.
Non Goals:
Make VIM able to call any native function.
Make VIM automatically marshal VIM types to C types.
I started thinking of using libffi to do something as python ctypes for
VIM but I thought it was not
a good idea because:
Too much complexity for marshaling VIM types to C equivalents.
Marshaling is not efficient.
If there going be limitations at which functions are able to be
called from VIM, why expend time on this.
What I, myself, really want is build efficient plugins for VIM in
C, not being able to call any function.
So this is about a interface to call VIM crafted plugins, exporting
specific prototypes to be called from VIM
with not overhead.
How I'm building this:
*libload*
function to load a library from path/name and return a *Libhandle*.
*libfunc*
function to get a *Libfunc* from a *Libhandle* and function name.
*libcall* / *libcallex* / *call* (not decided yet which one to use)
function to call a *Libfunc *passing a raw VIM List of raw VIM
types as arguments and returning a raw
VIM type.
*libinit*
function initialize a VIM library from a *Libhandle*. This
function will try to call an exported initialization
function from the library:
void vim( void *(*vim_get)(char *name) )
If the function exist, the library should use the given
*vim_get* function to ask for VIM functions and settings
by name.
The functions exposed by this function should be an API to
allow the library to deal with raw VIM types
without overhead and without internal implementation knowledge.
Beyond dealing with VIM types
it should export functions for VIM evaluation from strings and
maybe other stuff.
This API should be documented and may be extended over time.
To have *libload* and *libfunc*, I needed a way to represent library
handles and function pointers. No VIM type
can represent that well, so I started by extending VIM variables to
become yet more two types, *Libhandle* and
*Libfunc*. These types only show up in the context of these functions.
Variables of these types can only be assigned,
compared (==, !=) and used in the *empty* function to check for nullity.
Right now I've extend VIM variables, I'm implementing the functions, the
hard part will be to define and implement
what the vim_get callback will return.
Any comments please?
Regards
---
Francisco Lopes
See also
:help libcall()
:help libcallnr()
about already implemented possibilities.
Best regards,
Tony.
--
ARTHUR: Shut up! Will you shut up!
DENNIS: Ah, now we see the violence inherent in the system.
ARTHUR: Shut up!
DENNIS: Oh! Come and see the violence inherent in the system!
HELP! HELP! I'm being repressed!
The Quest for the Holy Grail (Monty
Python)
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php