1 | // |
2 | // (c) Copyright, Moebius Solutions, 2002 |
3 | // |
4 | // All Rights Reserved |
5 | // |
6 | // This material may be reproduced by or for the U. S. Government |
7 | // pursuant to the copyright license under the clause at |
8 | // DFARS 252.227-7013 (OCT 1988). |
9 | // |
10 | package com.moesol.generator; |
11 | |
12 | import java.lang.reflect.*; |
13 | import com.moesol.generator.core.*; |
14 | |
15 | public class JniMethodCallable extends MethodCallable { |
16 | public JniMethodCallable(Method method, int num_me_params) throws ApplyException { |
17 | super(method); |
18 | initParameterTypes(num_me_params); |
19 | } |
20 | private void initParameterTypes(int num_me_params) throws ApplyException { |
21 | Class[] params = m_method.getParameterTypes(); |
22 | if (params.length < num_me_params) { |
23 | throw new ApplyException("JNI method missing me parameter(s): " + getName()); |
24 | } |
25 | parameter_types = new Class[params.length - num_me_params]; |
26 | System.arraycopy(params, num_me_params, parameter_types, 0, parameter_types.length); |
27 | } |
28 | public String getName() { |
29 | return getJniLessName(); |
30 | } |
31 | public Class[] getParameterTypes() { |
32 | return parameter_types; |
33 | } |
34 | private String getJniLessName() { |
35 | if (m_method.getName().startsWith("JNI")) { |
36 | return m_method.getName().substring(3); |
37 | } else { |
38 | return m_method.getName(); |
39 | } |
40 | } |
41 | Class[] parameter_types = null; |
42 | } |