Skip to content

Commit 24de18b

Browse files
committed
some ancient stuff
1 parent 440cc2e commit 24de18b

File tree

6 files changed

+40
-21
lines changed

6 files changed

+40
-21
lines changed

annotations/src/main/java/com/google/j2objc/annotations/Library.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
/**
99
* The Library to which the annotated class belongs to
1010
*/
11-
public String value();
11+
String value();
12+
13+
boolean useQuotes() default false;
1214
}

jre_emul/Classes/java/lang/reflect/Method.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
@interface JavaLangReflectMethod : ExecutableMember {
3838
BOOL isStatic_;
3939
IOSClass *returnType_;
40-
NSInvocation *invocation_;
4140
}
4241

4342
+ (instancetype)methodWithMethodSignature:(NSMethodSignature *)methodSignature

jre_emul/Classes/java/lang/reflect/Method.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,26 @@ - (id)invokeWithId:(id)object
163163
@"wrong number of arguments"]);
164164
}
165165

166-
if (!invocation_) {
167-
invocation_ =
168-
[NSInvocation invocationWithMethodSignature:methodSignature_];
166+
NSInvocation *invocation;
167+
invocation =
168+
[NSInvocation invocationWithMethodSignature:methodSignature_];
169169
#if ! __has_feature(objc_arc)
170-
[invocation_ retain];
170+
[invocation retain];
171171
#endif
172-
[invocation_ setSelector:selector_];
173-
}
172+
[invocation setSelector:selector_];
173+
174174
for (jint i = 0; i < nArgs; i++) {
175175
J2ObjcRawValue arg;
176176
if (![paramTypes->buffer_[i] __unboxValue:arguments->buffer_[i] toRawValue:&arg]) {
177177
@throw AUTORELEASE([[JavaLangIllegalArgumentException alloc] initWithNSString:
178178
@"argument type mismatch"]);
179179
}
180-
[invocation_ setArgument:&arg atIndex:i + SKIPPED_ARGUMENTS];
180+
[invocation setArgument:&arg atIndex:i + SKIPPED_ARGUMENTS];
181181
}
182182
if (object == nil || [object isKindOfClass:[IOSClass class]]) {
183-
[invocation_ setTarget:class_.objcClass];
183+
[invocation setTarget:class_.objcClass];
184184
} else {
185-
[invocation_ setTarget:object];
185+
[invocation setTarget:object];
186186
}
187187

188188
IOSClass *declaringClass = [self getDeclaringClass];
@@ -194,15 +194,15 @@ - (id)invokeWithId:(id)object
194194
// change the object's type to the superclass.
195195
Class originalClass = object_setClass(object, declaringClass.objcClass);
196196
@try {
197-
[invocation_ invoke];
197+
[invocation invoke];
198198
}
199199
@catch (JavaLangThrowable *t) {
200200
exception = t;
201201
}
202202
object_setClass(object, originalClass);
203203
} else {
204204
@try {
205-
[invocation_ invoke];
205+
[invocation invoke];
206206
}
207207
@catch (JavaLangThrowable *t) {
208208
exception = t;
@@ -218,7 +218,7 @@ - (id)invokeWithId:(id)object
218218
return nil;
219219
}
220220
J2ObjcRawValue returnValue;
221-
[invocation_ getReturnValue:&returnValue];
221+
[invocation getReturnValue:&returnValue];
222222
return [returnType __boxValue:&returnValue];
223223
}
224224

@@ -277,7 +277,6 @@ - (NSUInteger)hash {
277277

278278
#if ! __has_feature(objc_arc)
279279
- (void)dealloc {
280-
[invocation_ release];
281280
[returnType_ release];
282281
[super dealloc];
283282
}

translator/src/main/java/com/google/devtools/j2objc/types/Import.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ public class Import implements Comparable<Import> {
9191
"org.xmlpull",
9292
"sun.misc",
9393
});
94+
private final boolean useQuotes;
9495

9596
private Import(ITypeBinding type) {
96-
this(type, false, null);
97+
this(type, false, null, false);
9798
}
9899

99-
private Import(ITypeBinding type, boolean isFoundation, String foundationName) {
100+
private Import(ITypeBinding type, boolean isFoundation, String foundationName, boolean useQuotes) {
100101
this.type = type;
101102
this.typeName = NameTable.getFullName(type);
102103
ITypeBinding mainType = type;
@@ -110,6 +111,7 @@ private Import(ITypeBinding type, boolean isFoundation, String foundationName) {
110111
this.importFileName = getImportFileName(mainType) + ".h";
111112
}
112113
this.isFoundation = isFoundation;
114+
this.useQuotes = useQuotes;
113115
}
114116

115117
public ITypeBinding getType() {
@@ -215,7 +217,11 @@ public String toString() {
215217

216218
public String getIncludeStatement() {
217219
if (isFoundation) {
218-
return String.format("#import <%s>", importFileName);
220+
if (useQuotes) {
221+
return String.format("#import \"%s\"", importFileName);
222+
} else {
223+
return String.format("#import <%s>", importFileName);
224+
}
219225
} else {
220226
return String.format("#include \"%s\"", getImportFileName());
221227
}
@@ -243,7 +249,7 @@ public static void addImports(ITypeBinding binding, Collection<Import> imports)
243249
// this is to include the original header file
244250
imports.add(new Import(binding));
245251
// this is to include the framework header
246-
imports.add(new Import(binding, true, libName));
252+
imports.add(new Import(binding, true, libName, BindingUtil.extractLibraryUseQuotes(binding)));
247253
}
248254
if (BindingUtil.isAdapter(binding)) {
249255
return;

translator/src/main/java/com/google/devtools/j2objc/util/BindingUtil.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,19 @@ public static String extractLibraryName(ITypeBinding binding) {
497497
}
498498
}
499499

500+
public static boolean extractLibraryUseQuotes(ITypeBinding binding) {
501+
if (binding == null) {
502+
return false;
503+
} else {
504+
IAnnotationBinding annotation = BindingUtil.getAnnotation(binding, Library.class);
505+
if (annotation != null) {
506+
return (Boolean) BindingUtil.getAnnotationValue(annotation, "useQuotes");
507+
} else {
508+
return false;
509+
}
510+
}
511+
}
512+
500513
public static boolean isAdapter(ITypeBinding binding) {
501514
if (binding == null) {
502515
return false;

translator/src/test/java/com/google/devtools/j2objc/SmallTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ public class SmallTests {
143143
MappedNativeMethodRemoverTest.class,
144144
};
145145

146-
private static final Class<?>[] smallTestClasses = smallTestClassesPrime;
147-
// private static final Class<?>[] smallTestClasses = {MappedNativeMethodRemoverTest.class};
146+
// private static final Class<?>[] smallTestClasses = smallTestClassesPrime;
147+
private static final Class<?>[] smallTestClasses = {J2ObjCTest.class};
148148

149149
public static Test suite() {
150150
return new TestSuite(smallTestClasses);

0 commit comments

Comments
 (0)