Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First implementation of nqp::buildnativecall.
  • Loading branch information
arnsholt committed Sep 8, 2013
1 parent 7e305ec commit 0e2ce95
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/NativeCallOps.java
@@ -1,7 +1,11 @@
package org.perl6.nqp.runtime;

import com.sun.jna.NativeLibrary;

import org.perl6.nqp.sixmodel.SixModelObject;

import org.perl6.nqp.sixmodel.reprs.NativeCallInstance;

public final class NativeCallOps {
public static long init() {
/* Nothing to do here. The REPRs are all registered over in
Expand All @@ -10,10 +14,33 @@ public static long init() {
}

public static long build(SixModelObject target, String libname, String symbol, String convention, SixModelObject arguments, SixModelObject returns) {
NativeCallInstance call = getNativeCallInstance(target);

/* Load the library and locate the symbol. */
/* TODO: Error handling! */
NativeLibrary library = NativeLibrary.getInstance(libname);
call.entry_point = library.getFunction(symbol);

/* TODO: Set the calling convention. */

/* Set up the argument types. */

return 1L;
}

public static SixModelObject call(SixModelObject returns, SixModelObject call, SixModelObject arguments) {
return null;
}

private static NativeCallInstance getNativeCallInstance(SixModelObject target) {
NativeCallInstance call;
if (target instanceof NativeCallInstance) {
call = (NativeCallInstance) target;
}
else {
/* TODO: Handle box target stuff here. */
call = null;
}
return call;
}
}
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import com.sun.jna.Function;

import org.perl6.nqp.sixmodel.SixModelObject;

public class NativeCallInstance extends SixModelObject {
Expand All @@ -26,4 +28,6 @@ public class NativeCallInstance extends SixModelObject {
public static final byte ARG_NO_FREE_STR = 0;
public static final byte ARG_FREE_STR = 1;
public static final byte ARG_FREE_STR_MASK = 1;

public Function entry_point;
}

0 comments on commit 0e2ce95

Please sign in to comment.