Hi all,
Right now I'm trying to write a function that, given an arbitrary number of
arguments as D types concerts them into intermediate types that will be pasrd
to the JNI. For example, given a char[], it will use the JNI to construct the
relevant java.lang.string, and pass back the jobject.
The problem is that I can't define two tuples in the function template. For
example, I can't write a function:
void dTypesToJavaTypes(InTypes..., OutTypes...)(InTypes inVars, out OutTypes
outVars)
The number of in parameters will always be the same as the number of out
parameters, and all the types should be known at compile-time, and though I'd
rather not force the caller to know the out types, there's probably no way
around that. Any suggestions? Maybe an out tuple and in varargs?

Hi all,
Right now I'm trying to write a function that, given an arbitrary
number of arguments as D types concerts them into intermediate types
that will be pasrd to the JNI. For example, given a char[], it will
use the JNI to construct the relevant java.lang.string, and pass back
the jobject.
The problem is that I can't define two tuples in the function
template. For example, I can't write a function:
void dTypesToJavaTypes(InTypes..., OutTypes...)(InTypes inVars, out
OutTypes outVars)
The number of in parameters will always be the same as the number of
out parameters, and all the types should be known at compile-time, and
though I'd rather not force the caller to know the out types, there's
probably no way around that. Any suggestions? Maybe an out tuple and
in varargs?

Hi all,
Right now I'm trying to write a function that, given an arbitrary
number of arguments as D types concerts them into intermediate types
that will be pasrd to the JNI. For example, given a char[], it will
use the JNI to construct the relevant java.lang.string, and pass back
the jobject.
The problem is that I can't define two tuples in the function
template. For example, I can't write a function:
void dTypesToJavaTypes(InTypes..., OutTypes...)(InTypes inVars, out
OutTypes outVars)
The number of in parameters will always be the same as the number of
out parameters, and all the types should be known at compile-time, and
though I'd rather not force the caller to know the out types, there's
probably no way around that. Any suggestions? Maybe an out tuple and
in varargs?

The only other way I can think of doing it would be to make a template
that, given the D type expands to the JNI type. So...
template jniType(T)
{
static if( is( T == char[] ) )
alias javaString jniType;
else // ...
}
Then you need a template to apply this to a tuple...
template jniTypes(T, Ts...)
{
alias Tuple!(jniType!(T), jniTypes!(Ts)) jniTypes;
}
And now you can do this:
void dTypesToJavaTypes(InTypes...)(InTypes inVars,
out jniTypes!(InTypes) outVars)
{
// Do stuff
}
It's messy, but the nice thing is that it makes your templates easier to
use.
That said, if you can get away with it, I'd go with BCS' approach. :)
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/