1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28
29 import java.io.OutputStream;
30 import java.io.PrintWriter;
31 import java.util.ArrayList;
32 import java.util.HashSet;
33 import java.util.List;
34
35 import java.util.Set;
36 import javax.lang.model.element.Element;
37 import javax.lang.model.element.ExecutableElement;
38 import javax.lang.model.element.Modifier;
39 import javax.lang.model.element.Name;
40 import javax.lang.model.element.TypeElement;
41 import javax.lang.model.element.VariableElement;
42 import javax.lang.model.type.ArrayType;
43 import javax.lang.model.type.PrimitiveType;
44 import javax.lang.model.type.TypeKind;
45 import javax.lang.model.type.TypeMirror;
46 import javax.lang.model.type.TypeVisitor;
47 import javax.lang.model.util.ElementFilter;
48 import javax.lang.model.util.SimpleTypeVisitor7;
49
50 /*
51 * <p><b>This is NOT part of any supported API.
52 * If you write code that depends on this, you do so at your own
53 * risk. This code and its internal interfaces are subject to change
54 * or deletion without notice.</b></p>
55 *
56 * @author Sucheta Dambalkar(Revised)
57 */
58 public class LLNI extends Gen {
59
60 protected final char innerDelim = '$'; /* For inner classes */
61 protected Set<String> doneHandleTypes;
62 List<VariableElement> fields;
63 List<ExecutableElement> methods;
64 private boolean doubleAlign;
65 private int padFieldNum = 0;
66
67 LLNI(boolean doubleAlign, Util util) {
68 super(util);
611 default:
612 throw new Error(t.getKind() + " " + t); // FIXME
613 }
614
615 return res;
616 }
617
618 protected final String cRcvrDecl(Element field, String cname) {
619 return (field.getModifiers().contains(Modifier.STATIC) ? "jclass" : "jobject");
620 }
621
622 protected String maskName(String s) {
623 return "LLNI_mask(" + s + ")";
624 }
625
626 protected String llniFieldName(VariableElement field) {
627 return maskName(field.getSimpleName().toString());
628 }
629
630 protected final boolean isLongOrDouble(TypeMirror t) {
631 TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor7<Boolean,Void>() {
632 public Boolean defaultAction(TypeMirror t, Void p){
633 return false;
634 }
635 public Boolean visitArray(ArrayType t, Void p) {
636 return visit(t.getComponentType(), p);
637 }
638 public Boolean visitPrimitive(PrimitiveType t, Void p) {
639 TypeKind tk = t.getKind();
640 return (tk == TypeKind.LONG || tk == TypeKind.DOUBLE);
641 }
642 };
643 return v.visit(t, null);
644 }
645
646 /* Do unicode to ansi C identifier conversion.
647 %%% This may not be right, but should be called more often. */
648 protected final String nameToIdentifier(String name) {
649 int len = name.length();
650 StringBuffer buf = new StringBuffer(len);
651 for (int i = 0; i < len; i++) {
|
1 /*
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28
29 import java.io.OutputStream;
30 import java.io.PrintWriter;
31 import java.util.ArrayList;
32 import java.util.HashSet;
33 import java.util.List;
34
35 import java.util.Set;
36 import javax.lang.model.element.Element;
37 import javax.lang.model.element.ExecutableElement;
38 import javax.lang.model.element.Modifier;
39 import javax.lang.model.element.Name;
40 import javax.lang.model.element.TypeElement;
41 import javax.lang.model.element.VariableElement;
42 import javax.lang.model.type.ArrayType;
43 import javax.lang.model.type.PrimitiveType;
44 import javax.lang.model.type.TypeKind;
45 import javax.lang.model.type.TypeMirror;
46 import javax.lang.model.type.TypeVisitor;
47 import javax.lang.model.util.ElementFilter;
48 import javax.lang.model.util.SimpleTypeVisitor8;
49
50 /*
51 * <p><b>This is NOT part of any supported API.
52 * If you write code that depends on this, you do so at your own
53 * risk. This code and its internal interfaces are subject to change
54 * or deletion without notice.</b></p>
55 *
56 * @author Sucheta Dambalkar(Revised)
57 */
58 public class LLNI extends Gen {
59
60 protected final char innerDelim = '$'; /* For inner classes */
61 protected Set<String> doneHandleTypes;
62 List<VariableElement> fields;
63 List<ExecutableElement> methods;
64 private boolean doubleAlign;
65 private int padFieldNum = 0;
66
67 LLNI(boolean doubleAlign, Util util) {
68 super(util);
611 default:
612 throw new Error(t.getKind() + " " + t); // FIXME
613 }
614
615 return res;
616 }
617
618 protected final String cRcvrDecl(Element field, String cname) {
619 return (field.getModifiers().contains(Modifier.STATIC) ? "jclass" : "jobject");
620 }
621
622 protected String maskName(String s) {
623 return "LLNI_mask(" + s + ")";
624 }
625
626 protected String llniFieldName(VariableElement field) {
627 return maskName(field.getSimpleName().toString());
628 }
629
630 protected final boolean isLongOrDouble(TypeMirror t) {
631 TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor8<Boolean,Void>() {
632 public Boolean defaultAction(TypeMirror t, Void p){
633 return false;
634 }
635 public Boolean visitArray(ArrayType t, Void p) {
636 return visit(t.getComponentType(), p);
637 }
638 public Boolean visitPrimitive(PrimitiveType t, Void p) {
639 TypeKind tk = t.getKind();
640 return (tk == TypeKind.LONG || tk == TypeKind.DOUBLE);
641 }
642 };
643 return v.visit(t, null);
644 }
645
646 /* Do unicode to ansi C identifier conversion.
647 %%% This may not be right, but should be called more often. */
648 protected final String nameToIdentifier(String name) {
649 int len = name.length();
650 StringBuffer buf = new StringBuffer(len);
651 for (int i = 0; i < len; i++) {
|