-
Notifications
You must be signed in to change notification settings - Fork 29
/
Util.java
683 lines (575 loc) · 23.7 KB
/
Util.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
package org.andengine.extension.scripting.generator.util;
import java.io.File;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import org.andengine.extension.scripting.generator.util.adt.io.GenCppClassFileWriter.GenCppClassHeaderFileSegment;
import com.thoughtworks.paranamer.BytecodeReadingParanamer;
/**
* (c) Zynga 2012
*
* @author Nicolas Gramlich <ngramlich@zynga.com>
* @since 15:10:42 - 21.03.2012
*/
public class Util {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private final String mGenJavaClassSuffix;
private final String mGenCppClassSuffix;
private final List<String> mGenMethodsInclude;
private final List<String> mGenClassesExclude;
// ===========================================================
// Constructors
// ===========================================================
public Util(final String pGenJavaClassSuffix, final String pGenCppClassSuffix, final List<String> pGenMethodsInclude, final List<String> pGenClassesExclude) {
this.mGenJavaClassSuffix = pGenJavaClassSuffix;
this.mGenCppClassSuffix = pGenCppClassSuffix;
this.mGenMethodsInclude = pGenMethodsInclude;
this.mGenClassesExclude = pGenClassesExclude;
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
public File getInJavaClassSourceFile(final File pInJavaRoot, final String pFullyQualifiedClassName) {
return new File(pInJavaRoot, pFullyQualifiedClassName.replace('.', File.separatorChar) + ".java");
}
public File getInJavaClassFile(final File pInJavaBinRootClasses, final String pFullyQualifiedClassName) {
return new File(pInJavaBinRootClasses, pFullyQualifiedClassName.replace('.', File.separatorChar) + ".class");
}
public File getGenJavaClassSourceFile(final File pGenJavaRoot, final Class<?> pClass) {
return new File(pGenJavaRoot, this.getGenJavaClassFullyQualifiedName(pClass).replace('.', File.separatorChar) + this.mGenJavaClassSuffix + ".java");
}
public File getGenCppClassSourceFile(final File pGenCppRoot, final Class<?> pClass) {
return new File(pGenCppRoot, pClass.getName().replace('.', File.separatorChar) + this.mGenCppClassSuffix + ".cpp");
}
public File getGenCppClassHeaderFile(final File pGenCppRoot, final Class<?> pClass) {
return new File(pGenCppRoot, pClass.getName().replace('.', File.separatorChar) + this.mGenCppClassSuffix + ".h");
}
public String getGenCppClassInclude(final Class<?> pClass) {
return this.getGenCppClassInclude(pClass, false);
}
public String getGenCppClassInclude(final Class<?> pClass, final boolean pIgnoreSuffix) {
return "#include \"src/" + this.getGenCppFullyQualifiedClassName(pClass, pIgnoreSuffix) + ".h\"";
}
public String getGenCppFullyQualifiedClassName(final Class<?> pClass) {
return this.getGenCppFullyQualifiedClassName(pClass, false);
}
public String getGenCppFullyQualifiedClassName(final Class<?> pClass, final boolean pIgnoreSuffix) {
return pClass.getName().replace('.', '/').replace('&', '/') + ((pIgnoreSuffix) ? "" : this.mGenCppClassSuffix);
}
public String getGenJavaClassImport(final Class<?> pClass) {
if(pClass.isArray()) {
return this.getGenJavaClassImport(pClass.getComponentType());
} else {
return "import " + pClass.getName().replace('$', '.') + ";";
}
}
public String getVisibilityModifiersAsString(final AccessibleObject pAccessibleObject) {
if(pAccessibleObject instanceof Constructor<?>) {
return this.getModifiersAsString(((Constructor<?>)pAccessibleObject).getModifiers());
} else if(pAccessibleObject instanceof Method) {
return this.getModifiersAsString((((Method)pAccessibleObject)).getModifiers());
} else {
throw new IllegalArgumentException();
}
}
public String getGenJavaClassName(final Class<?> pClass) {
return pClass.getSimpleName() + this.mGenJavaClassSuffix;
}
public String getGenCppClassName(final Class<?> pClass) {
return pClass.getSimpleName() + this.mGenCppClassSuffix;
}
public String getGenCppStaticClassMemberName(final Class<?> pClass) {
return this.getGenCppStaticClassMemberName(pClass, false);
}
public String getGenCppStaticClassMemberName(final Class<?> pClass, final boolean pIgnoreSuffix) {
return "s" + pClass.getSimpleName() + ((pIgnoreSuffix) ? "" : this.mGenCppClassSuffix) + "Class";
}
public String getGenJavaClassFullyQualifiedName(final Class<?> pClass) {
return pClass.getName().replace("org.andengine", "org.andengine.extension.scripting");
}
public String getGenJavaClassPackageName(final Class<?> pClass) {
return pClass.getPackage().getName().replace("org.andengine", "org.andengine.extension.scripting");
}
public String getJavaNativeMethodName(final Method pMethod) {
return this.getJavaNativeMethodName(pMethod.getName());
}
public String getJavaNativeMethodName(final String pMethodName) {
return "native" + this.capitalizeFirstCharacter(pMethodName);
}
public String getJNIExportMethodName(final Class<?> pClass, final Method pMethod) {
return this.getJNIExportMethodName(pClass, pMethod.getName());
}
public String getJNIExportMethodName(final Class<?> pClass, final String pMethodName) {
return "Java_" + this.getGenJavaClassPackageName(pClass).replace('.', '_') + "_" + this.getGenJavaClassName(pClass) + "_" + this.getJavaNativeMethodName(pMethodName);
}
public String capitalizeFirstCharacter(final String pString) {
return Character.toUpperCase(pString.charAt(0)) + pString.substring(1, pString.length());
}
public String uncapitalizeFirstCharacter(final String pString) {
return Character.toLowerCase(pString.charAt(0)) + pString.substring(1, pString.length());
}
public String getModifiersAsString(final int pModifiers) {
final StringBuilder modifiersBuilder = new StringBuilder();
if(Modifier.isPublic(pModifiers)) {
modifiersBuilder.append("public");
} else if(Modifier.isProtected(pModifiers)) {
modifiersBuilder.append("protetcted");
} else if(Modifier.isPrivate(pModifiers)) {
modifiersBuilder.append("private");
}
return modifiersBuilder.toString();
}
public String getJavaMethodParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getJavaMethodParamatersAsString(parameterTypes, parameterNames);
}
public String getJavaMethodParamatersAsString(final Class<?>[] pParameterTypes, final String[] pParameterNames) {
if(pParameterTypes.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterTypes.length; i++) {
final String parameterName = pParameterNames[i];
// TODO Add import, when name != simplename.
// final String parameterTypeName = parameterType.getName();
final String parameterTypeName = pParameterTypes[i].getSimpleName();
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append("final").append(' ').append(parameterTypeName).append(' ').append(parameterName);
}
return stringBuilder.toString();
}
public String getJavaMethodCallParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getJavaMethodCallParamatersAsString(parameterNames);
}
public String getJavaMethodCallParamatersAsString(final String[] pParameterNames) {
if(pParameterNames.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterNames.length; i++) {
final String parameterName = pParameterNames[i];
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append(parameterName);
}
return stringBuilder.toString();
}
public String getJNIExportMethodHeaderParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
return this.getJNIExportMethodHeaderParamatersAsString(parameterTypes);
}
public String getJNIExportMethodHeaderParamatersAsString(final Class<?>[] pParameterTypes) {
final StringBuilder stringBuilder = new StringBuilder("JNIEnv*, jobject, jlong");
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterTypeName = this.getJNIParameterTypeName(parameterType);
stringBuilder.append(", ").append(parameterTypeName);
}
return stringBuilder.toString();
}
public String getGenCppMethodHeaderParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
return this.getGenCppMethodHeaderParamatersAsString(parameterTypes);
}
public String getGenCppMethodHeaderParamatersAsString(final Class<?>[] pParameterTypes) {
if(pParameterTypes.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterTypeName = this.getGenCppParameterTypeName(parameterType);
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append(parameterTypeName);
}
return stringBuilder.toString();
}
public String getGenCppMethodParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getGenCppMethodParamatersAsString(parameterTypes, parameterNames);
}
public String getGenCppMethodParamatersAsString(final Class<?>[] pParameterTypes, final String[] pParameterNames) {
if(pParameterTypes.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterTypeName = this.getGenCppParameterTypeName(parameterType);
final String parameterName;
if(this.isPrimitiveType(parameterType)) {
parameterName = pParameterNames[i];
} else {
parameterName = pParameterNames[i] + this.mGenCppClassSuffix;
}
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append(parameterTypeName).append(' ').append(parameterName);
}
return stringBuilder.toString();
}
public String getGenCppMethodCallParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getGenCppMethodCallParamatersAsString(parameterTypes, parameterNames);
}
public String getGenCppMethodCallParamatersAsString(final Class<?>[] pParameterTypes, final String[] pParameterNames) {
if(pParameterTypes.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterName;
if(this.isPrimitiveType(parameterType)) {
parameterName = pParameterNames[i];
} else {
parameterName = this.getGenCppLocalVariableParameterName(pParameterNames[i], true);
}
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append(parameterName);
}
return stringBuilder.toString();
}
public String getGenCppLocalVariableParameterName(final String pParameterName) {
return this.getGenCppLocalVariableParameterName(pParameterName, false);
}
public String getGenCppLocalVariableParameterName(final String pParameterName, final boolean pAddressify) {
return ((pAddressify) ? "&" : "") + this.uncapitalizeFirstCharacter((pParameterName + this.mGenCppClassSuffix).substring(1));
}
public String getJNIMethodCallParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getJNIMethodCallParamatersAsString(parameterTypes, parameterNames);
}
public String getJNIMethodCallParamatersAsString(final Class<?>[] pParameterTypes, final String[] pParameterNames) {
if(pParameterTypes.length == 0) {
return null;
}
final StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterName;
if(this.isPrimitiveType(parameterType)) {
parameterName = pParameterNames[i];
} else {
parameterName = pParameterNames[i] + this.mGenCppClassSuffix + "->unwrap()";
}
if(i == 0) {
stringBuilder.append("");
} else {
stringBuilder.append(", ");
}
stringBuilder.append(parameterName);
}
return stringBuilder.toString();
}
public String getJNIExportMethodParamatersAsString(final AccessibleObject pAccessibleObject) throws IllegalArgumentException {
final Class<?>[] parameterTypes = this.getParameterTypes(pAccessibleObject);
final String[] parameterNames = this.getParameterNames(pAccessibleObject);
return this.getJNIExportMethodParamatersAsString(parameterTypes, parameterNames);
}
public String getJNIExportMethodParamatersAsString(final Class<?>[] pParameterTypes, final String[] pParameterNames) {
final StringBuilder stringBuilder = new StringBuilder("JNIEnv* pJNIEnv, jobject pJObject, jlong pAddress");
for(int i = 0; i < pParameterTypes.length; i++) {
final Class<?> parameterType = pParameterTypes[i];
final String parameterTypeName = this.getJNIParameterTypeName(parameterType);
final String parameterName = pParameterNames[i];
stringBuilder.append(", ").append(parameterTypeName).append(' ').append(parameterName);
}
return stringBuilder.toString();
}
public String getGenCppStaticMethodIDFieldName(final Method pMethod) {
final Class<?>[] parameterTypes = pMethod.getParameterTypes();
final StringBuilder signatureBuilder = new StringBuilder("sMethod__" + this.capitalizeFirstCharacter(pMethod.getName()));
if(parameterTypes.length > 0) {
signatureBuilder.append("__");
for(final Class<?> parameteType : parameterTypes) {
final String jniMethodSignatureType = this.getJNIMethodSignatureType(parameteType).replace("L", "__").replace('/', '_').replace(";", "__");
signatureBuilder.append(jniMethodSignatureType);
}
}
return signatureBuilder.toString();
}
public String getGenCppStaticMethodIDFieldName(final Constructor<?> pConstructor) {
final Class<?>[] parameterTypes = pConstructor.getParameterTypes();
final StringBuilder signatureBuilder = new StringBuilder("sConstructor");
if(parameterTypes.length > 0) {
signatureBuilder.append("__");
for(final Class<?> parameteType : parameterTypes) {
final String jniMethodSignatureType = this.getJNIMethodSignatureType(parameteType).replace("L", "__").replace('/', '_').replace(";", "__");
signatureBuilder.append(jniMethodSignatureType);
}
}
return signatureBuilder.toString();
}
public GenCppClassHeaderFileSegment getGenCppClassHeaderFileSegmentByVisibilityModifier(final int modifiers) {
if(Modifier.isPublic(modifiers)) {
return GenCppClassHeaderFileSegment.METHODS_PUBLIC;
} else if(Modifier.isProtected(modifiers)) {
return GenCppClassHeaderFileSegment.METHODS_PROTECTED;
} else {
throw new IllegalArgumentException();
}
}
public String getJNIParameterTypeName(final Class<?> parameterType) {
final String parameterTypeName;
if(parameterType == Byte.TYPE) {
parameterTypeName = "jbyte";
} else if(parameterType == Character.TYPE) {
parameterTypeName = "jchar";
} else if(parameterType == Short.TYPE) {
parameterTypeName = "jshort";
} else if(parameterType == Integer.TYPE) {
parameterTypeName = "jint";
} else if(parameterType == Long.TYPE) {
parameterTypeName = "jlong";
} else if(parameterType == Float.TYPE) {
parameterTypeName = "jfloat";
} else if(parameterType == Double.TYPE) {
parameterTypeName = "jdouble";
} else {
parameterTypeName = "jobject";
}
return parameterTypeName;
}
public String getJNIMethodSignature(final Constructor<?> pConstructor) {
final Class<?>[] parameterTypes = pConstructor.getParameterTypes();
final Class<?>[] expandedParameterTypes = new Class<?>[parameterTypes.length + 1];
System.arraycopy(parameterTypes, 0, expandedParameterTypes, 1, parameterTypes.length);
expandedParameterTypes[0] = Long.TYPE;
return this.getJNIMethodSignature(expandedParameterTypes, Void.TYPE);
}
public String getJNIMethodSignature(final Method pMethod) {
return this.getJNIMethodSignature(pMethod.getParameterTypes(), pMethod.getReturnType());
}
public String getJNIMethodSignature(final Class<?>[] pParameterTypes, final Class<?> pReturnType) {
final StringBuilder signatureBuilder = new StringBuilder();
signatureBuilder.append("(");
for(final Class<?> parameteType : pParameterTypes) {
signatureBuilder.append(this.getJNIMethodSignatureType(parameteType));
}
signatureBuilder.append(")");
signatureBuilder.append(this.getJNIMethodSignatureType(pReturnType));
return signatureBuilder.toString();
}
public String getJNIMethodSignatureType(final Class<?> pType) {
if(pType.isArray()) {
return "[" + this.getJNIMethodSignatureType(pType.getComponentType());
}
if(pType == Void.TYPE) {
return "V";
} else if(pType == Boolean.TYPE) {
return "Z";
} else if(pType == Byte.TYPE) {
return "B";
} else if(pType == Character.TYPE) {
return "C";
} else if(pType == Short.TYPE) {
return "S";
} else if(pType == Integer.TYPE) {
return "I";
} else if(pType == Long.TYPE) {
return "J";
} else if(pType == Float.TYPE) {
return "F";
} else if(pType == Double.TYPE) {
return "D";
} else {
return "L" + pType.getName().replace('.', '/') + ";";
}
}
public String getJNICallXYZMethodName(final Class<?> pType) {
if(pType == Void.TYPE) {
return "CallVoidMethod";
} else if(pType == Boolean.TYPE) {
return "CallBooleanMethod";
} else if(pType == Byte.TYPE) {
return "CallByteMethod";
} else if(pType == Character.TYPE) {
return "CallCharMethod";
} else if(pType == Short.TYPE) {
return "CallShortMethod";
} else if(pType == Integer.TYPE) {
return "CallIntMethod";
} else if(pType == Long.TYPE) {
return "CallLongMethod";
} else if(pType == Float.TYPE) {
return "CallFloatMethod";
} else if(pType == Double.TYPE) {
return "CallDoubleMethod";
} else if(pType == String.class) {
return "CallStringMethod";
} else {
return "CallObjectMethod";
}
}
public String getGenCppParameterTypeName(final Class<?> pParameterType) {
return this.getGenCppParameterTypeName(pParameterType, true);
}
public String getGenCppParameterTypeName(final Class<?> pParameterType, final boolean pPointerObjects) {
if(pParameterType.isArray()) {
final Class<?> componentType = pParameterType.getComponentType();
if(componentType == Boolean.TYPE) {
return "jbooleanArray";
} else if(componentType == Byte.TYPE) {
return "jbyteArray";
} else if(componentType == Character.TYPE) {
return "jcharArray";
} else if(componentType == Short.TYPE) {
return "jshortArray";
} else if(componentType == Integer.TYPE) {
return "jintArray";
} else if(componentType == Long.TYPE) {
return "jlongArray";
} else if(componentType == Float.TYPE) {
return "jfloatArray";
} else if(componentType == Double.TYPE) {
return "jdoubleArray";
} else if(componentType == String.class) {
return "jstringArray";
} else if(componentType == Object.class) {
return "jobjectArray";
} else {
throw new IllegalArgumentException();
}
} else {
if(pParameterType == Void.TYPE) {
return "void";
} else if(pParameterType == Boolean.TYPE) {
return "jboolean";
} else if(pParameterType == Byte.TYPE) {
return "jbyte";
} else if(pParameterType == Character.TYPE) {
return "jchar";
} else if(pParameterType == Short.TYPE) {
return "jshort";
} else if(pParameterType == Integer.TYPE) {
return "jint";
} else if(pParameterType == Long.TYPE) {
return "jlong";
} else if(pParameterType == Float.TYPE) {
return "jfloat";
} else if(pParameterType == Double.TYPE) {
return "jdouble";
} else if(pParameterType == String.class) {
return "jstring";
} else if(pParameterType == Object.class) {
return "jobject";
} else {
// TODO Add import, when name != simplename.
if(pPointerObjects) {
return pParameterType.getSimpleName() + this.mGenCppClassSuffix + "*";
} else {
return pParameterType.getSimpleName() + this.mGenCppClassSuffix;
}
}
}
}
public boolean isPrimitiveType(final Class<?> pType) {
return this.isPrimitiveType(pType, true);
}
public boolean isPrimitiveType(final Class<?> pType, final boolean pAllowArray) {
if(pType.isArray()) {
if(pAllowArray) {
return this.isPrimitiveType(pType.getComponentType());
} else {
return false;
}
} else {
if(pType == Void.TYPE) {
return true;
} else if(pType == Boolean.TYPE) {
return true;
} else if(pType == Byte.TYPE) {
return true;
} else if(pType == Character.TYPE) {
return true;
} else if(pType == Short.TYPE) {
return true;
} else if(pType == Integer.TYPE) {
return true;
} else if(pType == Long.TYPE) {
return true;
} else if(pType == Float.TYPE) {
return true;
} else if(pType == Double.TYPE) {
return true;
} else if(pType == String.class) {
return true;
} else if(pType == Object.class) {
return true;
} else {
return false;
}
}
}
public String[] getParameterNames(final AccessibleObject pAccessibleObject) {
final BytecodeReadingParanamer bytecodeReadingParanamer = new BytecodeReadingParanamer();
return bytecodeReadingParanamer.lookupParameterNames(pAccessibleObject);
}
public Class<?>[] getParameterTypes(final AccessibleObject pAccessibleObject) {
if(pAccessibleObject instanceof Constructor<?>) {
return ((Constructor<?>)pAccessibleObject).getParameterTypes();
} else if(pAccessibleObject instanceof Method) {
return ((Method)pAccessibleObject).getParameterTypes();
} else {
throw new IllegalArgumentException();
}
}
public boolean isGenMethodIncluded(final Method pMethod) {
final String methodName = pMethod.getName();
for(final String genMethodInclude : this.mGenMethodsInclude) {
if(genMethodInclude.equals(methodName)) {
return true;
}
}
return false;
}
public boolean isGenClassIncluded(final Class<?> pClass) {
final String className = pClass.getName();
for(final String genClassExclude : this.mGenClassesExclude) {
if(genClassExclude.equals(className)) {
return false;
}
}
return true;
}
// ===========================================================
// Methods
// ===========================================================
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}