<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Native function calling</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>Recent changes to Native function calling</description><atom:link href="https://sourceforge.net/p/v1-script/wiki/Native%20function%20calling/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 05 Sep 2023 12:16:05 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/v1-script/wiki/Native%20function%20calling/feed" rel="self" type="application/rss+xml"/><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v22
+++ v23
@@ -28,7 +28,7 @@

 Function/Arguments   |  Return | Description
 --------------------- |---------------- | ---------- 
-**call**    (number *module*, string *function*, array *paramDef* \[, mixed *arg1* ... \])    | mixed  | Call a native *function* of a *module* loaded with dl() function. The array *paramDef* defines the parameters and return code of native funtion:&lt;br/&gt; **\[\[ 'type of param1' ... 'type of param N' ], 'type of return' ]**
+**call**    (number *module*, string *function*, array *paramDef* \[, mixed *arg1* ... \])    | mixed  | Call a native *function* of a *module* loaded with dl() function. The array *paramDef* defines the parameters and return code of native funtion:&lt;br/&gt; **\[\[ 'type of param1' ... 'type of param N' ], 'type of return' ]**&lt;br/&gt;For better performance it is recommended to give the parameter definition as string in following format: 'abc:x' where a, b, c are parameter types and x is the return type.  


 **Types** and corresponding C datatypes:
@@ -81,7 +81,7 @@
   global hDLLKernel32;
   dst = "";
   resize (dst, strlen(src)*2+2); // Make enough buffer for wide char string
-  size = call (hDLLKernel32, "MultiByteToWideChar", [["i","i", "s", "i", 'r','i'], "i"],  65001, 0, src, -1, dst, strlen(src)+1);
+  size = call (hDLLKernel32, "MultiByteToWideChar", "iisiri:i",  65001, 0, src, -1, dst, strlen(src)+1);
   if (size&amp;gt;0)
     resize (dst, size*2);  // Resize to correct length (byte aligned)
   return dst;
@@ -89,7 +89,7 @@

 function MessageBox (text, topic="Info") {
     global hDLLUser32;
-    call (hDLLUser32, "MessageBoxW", [["p","s", "s", "i"], "i"], null, MultiByteToWideChar(text), MultiByteToWideChar (topic), 0|0x00000030);
+    call (hDLLUser32, "MessageBoxW", "pssi:i", null, MultiByteToWideChar(text), MultiByteToWideChar (topic), 0|0x00000030);
 }

 if (hDLLKernel32) {
@@ -129,7 +129,7 @@
 }

 /* Give a native function the callback pointer */
-call (hDLL, "nativeFunction", [["p", "s"], "i"], dlsym (null, "callbackA1"), "Argument");
+call (hDLL, "nativeFunction", "ps:i", dlsym (null, "callbackA1"), "Argument");

 /* Following callback functions are possible to call with __cdecl calling conversion */
 function callbackA1 (arg1) {
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Tue, 05 Sep 2023 12:16:05 -0000</pubDate><guid>https://sourceforge.netc7ca1c63441678f7cd96d54723924325cd5c6feb</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v21
+++ v22
@@ -58,7 +58,7 @@
 /* Call the native function which is defined as:
  int compress (void *destBuf, int *destLen, const char* srcBuf, int sourceLen);
  dst and len are reference parameters and filled with binary data by native function. */
-ret = call (module, "compress", [['r', 'r', 's', 'i'], 'i'], dst, len, src, strlen(src));
+ret = call (module, "compress", "rrsi:i", dst, len, src, strlen(src));
 if (ret===0) {
   /* Parse the binary length and truncate destination string */
   len = binparse (len,7);
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Tue, 05 Sep 2023 12:13:46 -0000</pubDate><guid>https://sourceforge.neta18986d8e04f83362eaa0603ca0a9f5f39074aa5</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v20
+++ v21
@@ -98,7 +98,7 @@
 ?&amp;gt;
 ~~~

-** Working with callbacks **
+** Working with callbacks**

 There are 8 callback functions, which can be referenced by dlsym() to get the pointer address for a native function.

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Tue, 05 Sep 2023 12:12:53 -0000</pubDate><guid>https://sourceforge.netbeeaa8685a8e36aa92a4d8c35d33680004a005ad</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v19
+++ v20
@@ -5,7 +5,6 @@
 ** Load dynamic link library **

 ~~~
-:::script
 &lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Tue, 05 Sep 2023 12:12:01 -0000</pubDate><guid>https://sourceforge.net7de7740eb6b1fcb2fbac8ec5536da5a06bbcf2ae</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v18
+++ v19
@@ -118,15 +118,15 @@
 */

 function callbackA1 (arg1) {
-  // Cast the argument to const char* and V1 string
+  /* Cast the argument to const char* and V1 string */
   s = memat (binformat (param1));
   print (s);

-  // Cast the argument to int and V1 number
+  /* Cast the argument to int and V1 number */
   i = binparse (binformat (arg1), 7, 0, 1);  
   print (i);

-  // Cast the argument to double and V1 number
+  /* Cast the argument to double and V1 number */
   d = binparse (binformat (arg1), 6);  
   print (d);

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:08:48 -0000</pubDate><guid>https://sourceforge.netaf0d05fa1e479f35034fcea3fa3e32858bacde76</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v17
+++ v18
@@ -63,7 +63,7 @@
  dst and len are reference parameters and filled with binary data by native function. */
 ret = call (module, "compress", [['r', 'r', 's', 'i'], 'i'], dst, len, src, strlen(src));
 if (ret===0) {
-  // Parse the binary length and truncate destination string
+  /* Parse the binary length and truncate destination string */
   len = binparse (len,7);
   resize (dst, len);

@@ -87,7 +87,7 @@
   resize (dst, strlen(src)*2+2); // Make enough buffer for wide char string
   size = call (hDLLKernel32, "MultiByteToWideChar", [["i","i", "s", "i", 'r','i'], "i"],  65001, 0, src, -1, dst, strlen(src)+1);
   if (size&amp;gt;0)
-    resize (dst, size*2);  /* Resize to correct length (byte aligned) */
+    resize (dst, size*2);  // Resize to correct length (byte aligned)
   return dst;
 }

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:07:36 -0000</pubDate><guid>https://sourceforge.netacaf5fd2aadf53c1b548d157c06a31f786b5575e</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v16
+++ v17
@@ -51,16 +51,16 @@
 0)
-    resize (dst, size*2);  // Resize to correct length (byte aligned)
+    resize (dst, size*2);  /* Resize to correct length (byte aligned) */
   return dst;
 }

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:06:40 -0000</pubDate><guid>https://sourceforge.netb987ef6290c7977626544c45301ea45163a50e70</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v15
+++ v16
@@ -1,11 +1,11 @@
-## Native function calling
-~~~
+### Native function calling

 V1 can call native functions of dynamic libraries (.dll, .so).

 ** Load dynamic link library **

 ~~~
+:::script
 
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:05:35 -0000</pubDate><guid>https://sourceforge.net071e4db44322750bed94fbe9bc995ca5610b59d8</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v14
+++ v15
@@ -6,7 +6,6 @@
 ** Load dynamic link library **

 ~~~
-:::script
 
 ~~~
@@ -48,7 +46,6 @@


 ~~~
-:::script
 
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:04:01 -0000</pubDate><guid>https://sourceforge.net9419d6edcb40418a0198ac175a19b8e10188c126</guid></item><item><title>Native function calling modified by Kalle</title><link>https://sourceforge.net/p/v1-script/wiki/Native%2520function%2520calling/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v13
+++ v14
@@ -5,12 +5,11 @@

 ** Load dynamic link library **

-
-
+~~~
 :::script
 
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kalle</dc:creator><pubDate>Sat, 19 Dec 2020 14:02:42 -0000</pubDate><guid>https://sourceforge.net8a00402fd213209d48210a7cb561a4fc68a2d463</guid></item></channel></rss>