Re: gforth embedding
Bernd Paysan <[email protected]> Sun, 12 Jul 2020 15:42:18 +0200
| Newsgroups | gmane.comp.lang.forth.gforth |
|---|---|
| Message-ID | <1616241.dfo3ICrBbV@liubei> |
Am Sonntag, 12. Juli 2020, 03:58:27 CEST schrieb Serge Balakshiy via Gforth
discussion and announcements:
> Dear
> Anton Ertl
>
> I have myprog program. This program is written in C. The program has a
> global pointer to all * mypoint. I want to embed gforth in my program. I
> need to write a function in this program
> void p_setpoint( int x, int y, int mode ){
> mypoint->setpoint(x, y, mode);
> push(1);
> }
> static struct primfcn funcs [] = {
> {"0SETPOINT", p_setpoint},
> {NULL, (codeptr) 0}
> };
> void run_gforth_script(){
> …
> // I want to write something like this here
> gforth_primdef(funcs);?????
Use the libcc.fs C bindings to call your C program. You don't need actual
primitives for that. Gerald Wodni's fork of SWIG can parse your .h file, and
generate those bindings for you.
You need to link your program with a switch that it exports dynamic functions
(like a shared library), to make this work.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEERJ1NDqPQRwYnwBjr9y2Uk5MtoGcFAl8LEzsACgkQ9y2Uk5Mt oGcjsg//Xh+3RFQazYdEVe2Nn3XgyKR6lF5Cl9Sjg8pRkAPRYDhfxxcmS6av1iuC wn1NIWM7e0izFLsu1G1Y1KOCycFoyQmQsTneWT7LiYOeGriNql2XCaGaF916AZ+E HVestacszX20StI2B2KXVg/SFzy2NpcBWv1W0p4/viXfEYbv/wJesZFFlznNFgj9 E7gYYqb6Q1r2z7Nzm+GBGG5GoZMJ+i7lGxK7791CazjGkS1v/+YQWmwwb65LCf8Z gT/dKU/eyJaL2nGrfbTi5um5aLd7OelKskIuePEEMeDTqWq3xmDKlYSjqS+Y1OJM sAnmmr6OKd0ZQOUtYAirnZyTADYaFbBGWvQWny+0dDMLDB1iYOzRbxuwl9BhN69x sAM1bSyBE0OyvTxpzieFR+0xpfa4AbIyIBNBea/Fhzz0l7mTzHOpeonceTNMC8jB 9EaSvCaDJ2SoRgEUcw7Ff5loYmg9LiywUyqVrEtZ3tZ3yLCRv27ibXB76cUqqWqs TCBZnG8e3iKqoluDbI3PeLxdn6g306sirt95YVnoh5DTVfW3LVU2QcQlMfJZC1is ohs20JQfSf52Ul6U7DG6Qfu2FNotL8TjfRG4hKRSKXfc457TmaZAQdo+3fwhtgsW fINkTiATDEjTXeMpIe6vOQUoLIIVkqfP2DWSF4hGK2GN2uGMFWc= =rVQG -----END PGP SIGNATURE-----