Using JNA in Rhino Javascript [message #1062991] |
Tue, 11 June 2013 16:13 |
Sohini Chatterjee Messages: 1 Registered: June 2013 |
Junior Member |
|
|
Hi
I am using CCSv5.3 for a certain project. 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 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.08193 seconds