incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lkue...@apache.org
Subject svn commit: r529064 - /incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/
Date Sun, 15 Apr 2007 20:36:49 GMT
Author: lkuehne
Date: Sun Apr 15 13:36:48 2007
New Revision: 529064

URL: http://svn.apache.org/viewvc?view=rev&rev=529064
Log:
YOKO-320: added package o.a.y.tools.idlpreprocessor

Added:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
  (with props)
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html
  (with props)

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * @author lk
+ * 
+ */
+public class DefaultIncludeResolver implements IncludeResolver {
+
+    private final File[] userIdlDirs;
+
+    public DefaultIncludeResolver(File... userIdlDirs) {
+        for (final File dir : userIdlDirs) {
+            if (!dir.isDirectory()) {
+                throw new IllegalArgumentException("not a directory: " + dir.getAbsoluteFile());
+            }
+        }
+        this.userIdlDirs = userIdlDirs;
+    }
+
+    /**
+     * @see IncludeResolver#findSystemInclude(java.lang.String)
+     */
+    public URL findSystemInclude(String spec) {
+        throw new UnsupportedOperationException("system includes not currently implemented");
+    }
+
+    /**
+     * @see IncludeResolver#findUserInclude(java.lang.String)
+     */
+    public URL findUserInclude(String spec) {
+        
+        for (final File searchDir : userIdlDirs) {
+
+            URI searchDirURI = searchDir.toURI();
+            try {
+                // offload slash vs backslash to URL machinery
+                URL searchDirURL = searchDirURI.toURL();
+                final URL url = new URL(searchDirURL, spec);
+                if (true || false) // TODO: if "file in URL exists"
+                {
+                    return url;
+                }
+            } catch (MalformedURLException e) {
+                final PreprocessingException preprocessingException = new PreprocessingException(
+                        "Unable to resolve user include '" + spec + "' in '" + userIdlDirs
+ "'", null, 0);
+                preprocessingException.initCause(e);
+                throw preprocessingException;
+            }
+        }
+
+        throw new PreprocessingException("unable to resolve " + spec, null, 0);
+    }
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefaultIncludeResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A registry for #define preprocessor instructions that allows tracking whether a symbol
is defined or not.
+ */
+public class DefineState {
+
+    Map<String, String> defines = new HashMap<String, String>();
+
+    public DefineState(Map<String, String> initialDefines) {
+        if (initialDefines != null) {
+            defines.putAll(initialDefines);
+        }
+    }
+
+    public void define(String symbol, String value) {
+        defines.put(symbol, value);
+    }
+
+    public boolean isDefined(String symbol) {
+        return defines.containsKey(symbol);
+    }
+
+    public String getValue(String symbol) {
+        return defines.get(symbol);
+    }
+
+    public void undefine(String symbol) {
+        defines.remove(symbol);
+    }
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/DefineState.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,308 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Stack;
+
+/**
+ * A Reader that implements the #include functionality of the preprocessor.
+ * Starting from one URL, it generates one stream of characters by tracking
+ * #defines and following #includes accordingly.
+ * 
+ * <p>
+ * This reader augments the stream with
+ * <a href="http://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Preprocessor-Output.html">
+ * location information</a> when the source URL is switched.
+ * This improves error reporting (with correct file and linenumber information) in the
+ * subsequent compilation steps like IDL parsing and also allows the implentation
+ * of code generation options like the -emitAll flag in the JDK idlj tool.
+ * </p>
+ */
+public final class IdlPreprocessorReader extends Reader {
+
+    /**
+     * Maximum depth of {@link #includeStack} to prevent infinite recursion.
+     */
+    private static final int MAX_INCLUDE_DEPTH = 64;
+
+    /**
+     * GNU standard preprocessor output flag for signalling a new file.
+     * 
+     * @see http://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Preprocessor-Output.html
+     */
+    private static final char PUSH = '1';
+
+    /**
+     * GNU standard preprocessor output flag for signalling returning to a file.
+     * 
+     * @see http://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Preprocessor-Output.html
+     */
+    private static final char POP = '2';
+
+    private static final String LF = System.getProperty("line.separator");
+
+    private final IncludeResolver includeResolver;
+
+    private final Stack<IncludeStackEntry> includeStack = new Stack<IncludeStackEntry>();
+
+    /**
+     * Stack of Booleans, corresponding to nested 'if' preprocessor directives.
+     * The top of the stack signals whether the current idl code is skipped.
+     * 
+     * @see #skips()
+     */
+    private final Stack<Boolean> ifStack = new Stack<Boolean>();
+
+    private final DefineState defineState;
+
+    private final StringBuilder buf = new StringBuilder();
+
+    private int readPos = 0;
+
+    /**
+     * Creates a new IncludeReader.
+     * 
+     * @param startURL
+     * @param startLocation
+     * @param includeResolver
+     * @param defineState
+     * @throws IOException
+     */
+    public IdlPreprocessorReader(URL startURL, String startLocation, IncludeResolver includeResolver,
DefineState defineState)
+            throws IOException {
+        this.includeResolver = includeResolver;
+        this.defineState = defineState;
+        pushInclude(startURL, startLocation);
+        fillBuffer();
+    }
+
+    /**
+     * @param url
+     * @throws IOException
+     */
+    private void pushInclude(URL url, String location) throws IOException {
+        final IncludeStackEntry includeStackEntry = new IncludeStackEntry(url, location);
+        includeStack.push(includeStackEntry);
+        final int lineNumber = getReader().getLineNumber();
+        signalFileChange(location, lineNumber, PUSH);
+    }
+
+    /**
+     * @see Reader#close()
+     */
+    public void close() throws IOException {
+        buf.setLength(0);
+    }
+
+    /**
+     * @see Reader#read(char[], int, int)
+     */
+    public int read(char[] cbuf, int off, int len) throws IOException {
+
+        final int buflen = buf.length();
+        if (readPos >= buflen) {
+            return -1;
+        }
+
+        int numCharsRead = Math.min(len, buflen - readPos);
+        buf.getChars(readPos, readPos + numCharsRead, cbuf, off);
+        readPos += numCharsRead;
+        return numCharsRead;
+    }
+
+    public int read() throws IOException {
+
+        if (buf.length() == 0) {
+            return -1;
+        } else {
+            char c = buf.charAt(readPos++);
+            return c;
+        }
+    }
+
+    private void fillBuffer() throws IOException {
+        while (!includeStack.isEmpty()) {
+            LineNumberReader reader = getReader();
+            String line = reader.readLine();
+
+            if (line == null) {
+                popInclude();
+                continue;
+            }
+
+            if (!line.startsWith("#")) {
+                if (!skips()) {
+                    buf.append(line);
+                    buf.append(LF);
+                }
+                continue;
+            }
+
+            final IncludeStackEntry ise = includeStack.peek();
+            final int lineNo = reader.getLineNumber();
+
+            if (line.startsWith("#include")) {
+                handleInclude(line, lineNo, ise);
+            } else if (line.startsWith("#ifndef")) {
+                handleIfndef(line);
+            } else if (line.startsWith("#ifdef")) {
+                handleIfdef(line);
+            } else if (line.trim().equals("#endif")) {
+                handleEndif(lineNo, ise);
+            } else if (line.trim().equals("#else")) {
+                handleElse(lineNo, ise);
+            } else if (line.startsWith("#define")) {
+                handleDefine(line);
+            } else {
+                throw new PreprocessingException("unknown preprocessor instruction", ise.getURL(),
lineNo);
+            }
+            buf.append(LF);
+        }
+    }
+
+    /**
+     * TODO: support multiline definitions, functions, etc. 
+     */
+    private void handleDefine(String line) {
+        if (skips()) {
+            return;
+        }
+        String def = line.substring("#define".length()).trim();
+        int idx = def.indexOf(' ');
+        if (idx == -1) {
+            defineState.define(def, null);
+        } else {
+            String symbol = def.substring(0, idx);
+            String value = def.substring(idx + 1).trim();
+            defineState.define(symbol, value);
+        }
+    }
+
+    private void handleElse(int lineNo, final IncludeStackEntry ise) {
+        if (ifStack.isEmpty()) {
+            throw new PreprocessingException("unexpected #endif", ise.getURL(), lineNo);
+        }
+        Boolean top = ifStack.pop();
+        ifStack.push(Boolean.valueOf(!top.booleanValue()));
+    }
+
+    private void handleEndif(int lineNo, final IncludeStackEntry ise) {
+        if (ifStack.isEmpty()) {
+            throw new PreprocessingException("unexpected #endif", ise.getURL(), lineNo);
+        }
+        ifStack.pop();
+    }
+
+    private void handleIfdef(String line) {
+        String symbol = line.substring("#ifdef".length()).trim();
+        boolean isDefined = defineState.isDefined(symbol);
+        registerIf(!isDefined);
+    }
+
+    private void handleIfndef(String line) {
+        String symbol = line.substring("#ifndef".length()).trim();
+        boolean isDefined = defineState.isDefined(symbol);
+        registerIf(isDefined);
+    }
+
+    private void handleInclude(String line, int lineNo, final IncludeStackEntry ise) throws
IOException {
+        
+        if (skips()) {
+            return;
+        }
+
+        if (includeStack.size() >= MAX_INCLUDE_DEPTH) {
+            throw new PreprocessingException("more than " + MAX_INCLUDE_DEPTH
+                    + " nested #includes - assuming infinite recursion, aborting", ise.getURL(),
lineNo);
+        }
+
+        String arg = line.replaceFirst("#include", "").trim();
+        if (arg.length() == 0) {
+
+            throw new PreprocessingException("#include without an argument", ise.getURL(),
lineNo);
+        }
+
+        char first = arg.charAt(0);
+        final int lastIdx = arg.length() - 1;
+        char last = arg.charAt(lastIdx);
+        if (arg.length() < 3 || !(first == '<' && last == '>') &&
!(first == '"' && last == '"')) {
+            throw new PreprocessingException(
+                    "argument for '#include' must be enclosed in '< >' or '\" \"'",
ise.getURL(), lineNo);
+        }
+        String spec = arg.substring(1, lastIdx);
+        URL include = (first == '<') ? includeResolver.findSystemInclude(spec) : includeResolver.findUserInclude(spec);
+
+        if (include == null) {
+            throw new PreprocessingException("unable to resolve include '" + spec + "'",
ise.getURL(),
+                    lineNo);
+        }
+        pushInclude(include, spec);
+    }
+
+    /**
+     * 
+     */
+    private void popInclude() throws IOException {
+        final IncludeStackEntry poppedStackEntry = includeStack.pop();
+        try {
+            if (includeStack.size() > 0) {
+                final LineNumberReader reader = getReader();
+                final int lineNumber = reader.getLineNumber();
+                final String location = poppedStackEntry.getLocation();
+                signalFileChange(location, lineNumber, POP);
+            }
+        }
+        finally {
+            poppedStackEntry.getReader().close();
+        }
+    }
+
+    private boolean skips() {
+        if (ifStack.isEmpty()) {
+            return false;
+        }
+
+        Boolean top = ifStack.peek();
+        return top.booleanValue();
+    }
+
+    private void registerIf(boolean skip) {
+        ifStack.push(Boolean.valueOf(skip));
+    }
+
+    private LineNumberReader getReader() {
+        IncludeStackEntry topOfStack = includeStack.peek();
+        return topOfStack.getReader();
+    }
+
+    /**
+     * Creates GNU standard preprocessor flag for signalling a file change.
+     * 
+     * @see http://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Preprocessor-Output.html
+     */
+    private void signalFileChange(String location, int lineNumber, char flag) {
+        buf.append("# ").append(lineNumber).append(' ').append(location).append(' ').append(flag).append(LF);
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.net.URL;
+
+public interface IncludeResolver {
+
+    public abstract URL findSystemInclude(String spec);
+
+    public abstract URL findUserInclude(String spec);
+
+}
\ No newline at end of file

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.net.URL;
+
+/**
+ * Provides information about a file that
+ */
+class IncludeStackEntry {
+    private final URL url;
+
+    private LineNumberReader reader;
+
+    private final String location;
+
+    IncludeStackEntry(URL url, String location) throws IOException {
+        this.url = url;
+        this.location = location;
+        this.reader = new LineNumberReader(new InputStreamReader(url.openStream(), "ISO-8859-1"));
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public URL getURL() {
+        return url;
+    }
+
+    public LineNumberReader getReader() {
+        return reader;
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/IncludeStackEntry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.tools.idlpreprocessor;
+
+import java.net.URL;
+
+public final class PreprocessingException extends RuntimeException {
+
+    private final int line;
+
+    private final URL url;
+
+    public PreprocessingException(String message, URL url, int line, Throwable cause)
+    {
+        super(message, cause);
+        this.url = url;
+        this.line = line;
+    }
+    
+    public PreprocessingException(String message, URL url, int line) {
+        this(message, url, line, null);
+    }
+
+    public String toString() {
+        return super.toString() + " at line " + line + " in " + url;
+    }
+
+    public int getLine() {
+        return line;
+    }
+
+    public URL getUrl() {
+        return url;
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/PreprocessingException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html?view=auto&rev=529064
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html
(added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html
Sun Apr 15 13:36:48 2007
@@ -0,0 +1,11 @@
+<html>
+<body>
+The preprocessor resolves IDL preprocessor instructions like define, ifdef, include, etc.
+The central class in this package is the IdlPreprocessorReader.
+Current limitations:
+<ul>
+<li>No code replacement will take place for nonempty definitions</li>
+<li>Does not handle multiline definitions</li>
+</ul>
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/idlpreprocessor/package.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message