178 String className = c.flatName().toString();
179 Location outLocn;
180 if (multiModuleMode) {
181 ModuleSymbol msym = c.owner.kind == MDL ? (ModuleSymbol) c.owner : c.packge().modle;
182 outLocn = fileManager.getLocationForModule(StandardLocation.NATIVE_HEADER_OUTPUT, msym.name.toString());
183 } else {
184 outLocn = StandardLocation.NATIVE_HEADER_OUTPUT;
185 }
186 FileObject outFile
187 = fileManager.getFileForOutput(outLocn,
188 "", className.replaceAll("[.$]", "_") + ".h", null);
189 PrintWriter out = new PrintWriter(outFile.openWriter());
190 try {
191 write(out, c);
192 if (verbose)
193 log.printVerbose("wrote.file", outFile.getName());
194 out.close();
195 out = null;
196 } finally {
197 if (out != null) {
198 // if we are propogating an exception, delete the file
199 out.close();
200 outFile.delete();
201 outFile = null;
202 }
203 }
204 return outFile; // may be null if write failed
205 }
206
207 public void write(PrintWriter out, ClassSymbol sym) throws IOException {
208 lazyInit();
209 try {
210 String cname = encode(sym.fullname, EncoderType.CLASS);
211 fileTop(out);
212 includes(out);
213 guardBegin(out, cname);
214 cppGuardBegin(out);
215
216 writeStatics(out, sym);
217 writeMethods(out, sym, cname);
218
|
178 String className = c.flatName().toString();
179 Location outLocn;
180 if (multiModuleMode) {
181 ModuleSymbol msym = c.owner.kind == MDL ? (ModuleSymbol) c.owner : c.packge().modle;
182 outLocn = fileManager.getLocationForModule(StandardLocation.NATIVE_HEADER_OUTPUT, msym.name.toString());
183 } else {
184 outLocn = StandardLocation.NATIVE_HEADER_OUTPUT;
185 }
186 FileObject outFile
187 = fileManager.getFileForOutput(outLocn,
188 "", className.replaceAll("[.$]", "_") + ".h", null);
189 PrintWriter out = new PrintWriter(outFile.openWriter());
190 try {
191 write(out, c);
192 if (verbose)
193 log.printVerbose("wrote.file", outFile.getName());
194 out.close();
195 out = null;
196 } finally {
197 if (out != null) {
198 // if we are propagating an exception, delete the file
199 out.close();
200 outFile.delete();
201 outFile = null;
202 }
203 }
204 return outFile; // may be null if write failed
205 }
206
207 public void write(PrintWriter out, ClassSymbol sym) throws IOException {
208 lazyInit();
209 try {
210 String cname = encode(sym.fullname, EncoderType.CLASS);
211 fileTop(out);
212 includes(out);
213 guardBegin(out, cname);
214 cppGuardBegin(out);
215
216 writeStatics(out, sym);
217 writeMethods(out, sym, cname);
218
|