This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi
Can anybody please explain how to use JNA in Rhino Javascript to call C functions from the Javascript code? I read somewhere "JavaScript engine, Rhino is implemented in Java, so there is JNA (https://github.com/twall/jna) to do such task." But in the link - the following code was mentioned to call the printf function from C library -
package com.sun.jna.examples;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/** Simple example of JNA interface mapping and usage. */
public class HelloWorld { // This is the standard, stable way of mapping, which supports extensive
// customization and mapping of Java to native types.
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows()?"msvcrt":"c"),CLibrary.class);
void printf(String format, Object... args); }
public static void main(String[] args)
{ CLibrary.INSTANCE.printf("Hello, World\n");
for (int i=0;i < args.length;i++)
{ CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]); }
}
}
However I cannot understand how to implement this code in CCSV5.3 Rhino console - because Java
program will not be supported here.
Please help.
Thanks in advance
Sohini,
Similar to this thread (http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/270682/946606.aspx#946606), your question is a bit out of scope for this forum. As suggested in the other thread, I'd also look for help on forums that focus on javascript or Rhino.
Thanks
ki