< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/tree/FunctionTree.java

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package com.sun.tools.jextract.tree;
  24 
  25 import java.foreign.layout.Function;
  26 import java.util.Collections;
  27 import java.util.List;
  28 import java.util.ArrayList;
  29 import jdk.internal.clang.Cursor;
  30 import jdk.internal.clang.Type;
  31 
  32 public class FunctionTree extends Tree {
  33     public FunctionTree(Cursor c) {
  34         super(c);









  35     }
  36 
  37     @Override
  38     public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
  39         return visitor.visitFunction(this, data);
  40     }
  41 
  42     public boolean isVariadic() {
  43         return type().isVariadic();
  44     }
  45 
  46     public List<Type> paramTypes() {
  47         Type t = type();
  48         int numParams = t.numberOfArgs();
  49         List<Type> res = new ArrayList<>(numParams);
  50         for (int i = 0; i < numParams; i++) {
  51             res.add(t.argType(i));
  52         }
  53         return Collections.unmodifiableList(res);
  54     }




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package com.sun.tools.jextract.tree;
  24 
  25 import java.foreign.layout.Function;
  26 import java.util.Collections;
  27 import java.util.List;
  28 import java.util.ArrayList;
  29 import jdk.internal.clang.Cursor;
  30 import jdk.internal.clang.Type;
  31 
  32 public class FunctionTree extends Tree {
  33     FunctionTree(Cursor c) {
  34         this(c, c.spelling());
  35     }
  36 
  37     private FunctionTree(Cursor c, String name) {
  38         super(c, name);
  39     }
  40 
  41     @Override
  42     public FunctionTree withName(String newName) {
  43         return name().equals(newName)? this : new FunctionTree(cursor(), newName);
  44     }
  45 
  46     @Override
  47     public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
  48         return visitor.visitFunction(this, data);
  49     }
  50 
  51     public boolean isVariadic() {
  52         return type().isVariadic();
  53     }
  54 
  55     public List<Type> paramTypes() {
  56         Type t = type();
  57         int numParams = t.numberOfArgs();
  58         List<Type> res = new ArrayList<>(numParams);
  59         for (int i = 0; i < numParams; i++) {
  60             res.add(t.argType(i));
  61         }
  62         return Collections.unmodifiableList(res);
  63     }


< prev index next >