< prev index next >

make/jdk/src/classes/build/tools/x11wrappergen/WrapperGenerator.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 1107,1117 **** e.printStackTrace(); } } public void writeJavaWrapperClass(String outputDir) { - // (new File(outputDir, package_path)).mkdirs(); try { for (Enumeration e = symbolTable.elements() ; e.hasMoreElements() ;) { BaseType tp = (BaseType) e.nextElement(); if (tp instanceof StructType) { StructType st = (StructType) tp; --- 1107,1116 ----
*** 1124,1144 **** catch (Exception e) { e.printStackTrace(); } } - public void writeNativeSizer(String file) { int type; int i=0; int j=0; BaseType tp; StructType stp; Enumeration eo; - try { FileOutputStream fs = new FileOutputStream(file); PrintWriter pw = new PrintWriter(fs); --- 1123,1141 ----
*** 1156,1166 **** pw.println(" unsigned long decorations;\n"); pw.println(" long inputMode;\n"); pw.println(" unsigned long status;\n"); pw.println("} PropMwmHints;\n"); - pw.println("\n\nint main(){"); j=0; for ( eo = symbolTable.elements() ; eo.hasMoreElements() ;) { tp = (BaseType) eo.nextElement(); if (tp instanceof StructType) --- 1153,1162 ----
*** 1180,1190 **** pw.println("printf(\"ptr\t%d\\n\",(int)sizeof(void *));"); pw.println("printf(\"Bool\t%d\\n\",(int)sizeof(Bool));"); pw.println("printf(\"Atom\t%d\\n\",(int)sizeof(Atom));"); pw.println("printf(\"Window\t%d\\n\",(int)sizeof(Window));"); - for (eo = symbolTable.elements() ; eo.hasMoreElements() ;) { tp = (BaseType) eo.nextElement(); if (tp instanceof StructType) --- 1176,1185 ----
*** 1232,1242 **** symbolTable.put("pointer", new AtomicType(AtomicType.TYPE_PTR, "", "pointer")); symbolTable.put("longlong", new AtomicType(AtomicType.TYPE_LONG_LONG, "", "longlong")); symbolTable.put("Atom", new AtomicType(AtomicType.TYPE_ATOM, "", "Atom")); symbolTable.put("ulong", new AtomicType(AtomicType.TYPE_ULONG, "", "ulong")); } ! public WrapperGenerator(String outputDir, String xlibFilename) { initTypes(); try { BufferedReader in = new BufferedReader(new FileReader(xlibFilename)); String line; String splits[]; --- 1227,1238 ---- symbolTable.put("pointer", new AtomicType(AtomicType.TYPE_PTR, "", "pointer")); symbolTable.put("longlong", new AtomicType(AtomicType.TYPE_LONG_LONG, "", "longlong")); symbolTable.put("Atom", new AtomicType(AtomicType.TYPE_ATOM, "", "Atom")); symbolTable.put("ulong", new AtomicType(AtomicType.TYPE_ULONG, "", "ulong")); } ! ! public WrapperGenerator(String xlibFilename) { initTypes(); try { BufferedReader in = new BufferedReader(new FileReader(xlibFilename)); String line; String splits[];
*** 1301,1368 **** in.close(); } catch (Exception e) { e.printStackTrace(); } - - } - private void makeSizer(String outputDir) { - if (wide) { - sizerFileName = "sizer.64.c"; - } else { - sizerFileName = "sizer.32.c"; } ! File fp = new File(outputDir, sizerFileName); writeNativeSizer(fp.getAbsolutePath()); } ! private boolean readSizeInfo(String sizeInfo) { try { - File f = new File(sizeInfo+".32"); boolean res = true; ! FileInputStream fis = null; ! if (f.exists()) { ! fis = new FileInputStream(f); ! res = readSizeInfo(fis, false); ! fis.close(); ! } ! f = new File(sizeInfo+".64"); ! if (f.exists()) { ! fis = new FileInputStream(f); ! res &= readSizeInfo(fis, true); fis.close(); - } return res; } catch (Exception e) { e.printStackTrace(); return false; } } ! private void startGeneration(String outputDir, String sizeInfo) { ! if (readSizeInfo(sizeInfo)) { writeJavaWrapperClass(outputDir); } else { System.out.println("Error calculating offsets"); } } public static void main(String[] args) { - if (args.length < 4) { ! System.out.println("Usage:\nWrapperGenerator <output_dir> <xlibtypes.txt> <action> [<platform> | <sizes info file>]"); ! System.out.println("Where <action>: gen, sizer"); ! System.out.println(" <platform>: 32, 64"); System.exit(1); } ! WrapperGenerator xparser = new WrapperGenerator(args[0], args[1]); ! if (args[2].equals("sizer")) { xparser.wide = args[3].equals("64"); ! xparser.makeSizer(args[0]); ! } else if (args[2].equals("gen")) { ! xparser.startGeneration(args[0], args[3]); } } - } --- 1297,1351 ---- in.close(); } catch (Exception e) { e.printStackTrace(); } } ! ! private void makeSizer(String sizerFileName) { ! File fp = new File(sizerFileName); writeNativeSizer(fp.getAbsolutePath()); } ! ! private boolean readFileSizeInfo(String filename, boolean wide) { try { boolean res = true; ! FileInputStream fis = new FileInputStream(filename); ! res = readSizeInfo(fis, wide); fis.close(); return res; } catch (Exception e) { e.printStackTrace(); return false; } } ! private void startGeneration(String outputDir, String filename, boolean wide) { ! if (readFileSizeInfo(filename, wide)) { writeJavaWrapperClass(outputDir); } else { System.out.println("Error calculating offsets"); } } public static void main(String[] args) { if (args.length < 4) { ! System.out.println("Usage:\nWrapperGenerator gen_java <output_dir> <xlibtypes.txt> <sizes-*.txt> <platform>"); ! System.out.println(" or"); ! System.out.println("WrapperGenerator gen_c_source <output_file> <xlibtypes.txt> <platform>"); ! System.out.println("Where <platform>: 32, 64"); ! System.exit(1); } ! WrapperGenerator xparser = new WrapperGenerator(args[2]); ! if (args[0].equals("gen_c_source")) { xparser.wide = args[3].equals("64"); ! xparser.makeSizer(args[1]); ! } else if (args[0].equals("gen_java")) { ! boolean wide = args[4].equals("64"); ! xparser.startGeneration(args[1], args[3], wide); } } }
< prev index next >