VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/java/tools/gen-nsError.pl@ 105681

最後變更 在這個檔案從105681是 29095,由 vboxsync 提交於 15 年 前

export more JXPCOM files to OSE

  • 屬性 svn:eol-style 設為 native
檔案大小: 6.6 KB
 
1#! /usr/bin/env perl
2# ***** BEGIN LICENSE BLOCK *****
3# Version: MPL 1.1/GPL 2.0/LGPL 2.1
4#
5# The contents of this file are subject to the Mozilla Public License Version
6# 1.1 (the "License"); you may not use this file except in compliance with
7# the License. You may obtain a copy of the License at
8# http://www.mozilla.org/MPL/
9#
10# Software distributed under the License is distributed on an "AS IS" basis,
11# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12# for the specific language governing rights and limitations under the
13# License.
14#
15# The Original Code is Java XPCOM Bindings.
16#
17# The Initial Developer of the Original Code is
18# Michal Ceresna.
19# Portions created by the Initial Developer are Copyright (C) 2005
20# the Initial Developer. All Rights Reserved.
21#
22# Contributor(s):
23# Michal Ceresna ([email protected])
24# Javier Pedemonte ([email protected])
25#
26# Alternatively, the contents of this file may be used under the terms of
27# either the GNU General Public License Version 2 or later (the "GPL"), or
28# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29# in which case the provisions of the GPL or the LGPL are applicable instead
30# of those above. If you wish to allow use of your version of this file only
31# under the terms of either the GPL or the LGPL, and not to allow others to
32# use your version of this file under the terms of the MPL, indicate your
33# decision by deleting the provisions above and replace them with the notice
34# and other provisions required by the GPL or the LGPL. If you do not delete
35# the provisions above, a recipient may use your version of this file under
36# the terms of any one of the MPL, the GPL or the LGPL.
37#
38# ***** END LICENSE BLOCK *****
39
40# Generates XPCOMError.java from xpcom/base/nsError.h
41#
42# usage: perl gen-nsErrors.pl < <topsrcdir>/xpcom/base/nsError.h > XPCOMError.java
43
44
45print "/* ***** BEGIN LICENSE BLOCK *****\n";
46print " * Version: MPL 1.1/GPL 2.0/LGPL 2.1\n";
47print " *\n";
48print " * The contents of this file are subject to the Mozilla Public License Version\n";
49print " * 1.1 (the \"License\"); you may not use this file except in compliance with\n";
50print " * the License. You may obtain a copy of the License at\n";
51print " * http://www.mozilla.org/MPL/\n";
52print " *\n";
53print " * Software distributed under the License is distributed on an \"AS IS\" basis,\n";
54print " * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\n";
55print " * for the specific language governing rights and limitations under the\n";
56print " * License.\n";
57print " *\n";
58print " * The Original Code is mozilla.org code.\n";
59print " *\n";
60print " * The Initial Developer of the Original Code is\n";
61print " * Netscape Communications Corporation.\n";
62print " * Portions created by the Initial Developer are Copyright (C) 1998\n";
63print " * the Initial Developer. All Rights Reserved.\n";
64print " *\n";
65print " * Contributor(s):\n";
66print " *\n";
67print " * Alternatively, the contents of this file may be used under the terms of\n";
68print " * either of the GNU General Public License Version 2 or later (the \"GPL\"),\n";
69print " * or the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"),\n";
70print " * in which case the provisions of the GPL or the LGPL are applicable instead\n";
71print " * of those above. If you wish to allow use of your version of this file only\n";
72print " * under the terms of either the GPL or the LGPL, and not to allow others to\n";
73print " * use your version of this file under the terms of the MPL, indicate your\n";
74print " * decision by deleting the provisions above and replace them with the notice\n";
75print " * and other provisions required by the GPL or the LGPL. If you do not delete\n";
76print " * the provisions above, a recipient may use your version of this file under\n";
77print " * the terms of any one of the MPL, the GPL or the LGPL.\n";
78print " *\n";
79print " * ***** END LICENSE BLOCK ***** */\n";
80
81print "\n";
82print "package org.mozilla.xpcom;\n";
83print "\n\n";
84
85print "/**\n";
86print " * Mozilla error codes.\n";
87print " *\n";
88print " * THIS FILE GENERATED FROM mozilla/xpcom/base/nsError.h.\n";
89print " * PLEASE SEE THAT FILE FOR FULL DOCUMENTATION.\n";
90print " */\n";
91print "public interface XPCOMError {\n";
92
93while (<STDIN>) {
94 $line = $_;
95
96 if ($prevline) {
97 $_ = $prevline.$_;
98 }
99 if (/(.*)\\$/) {
100 #splitted line
101 $prevline = $1;
102 next;
103 }
104 $prevline = "";
105
106 if (/^\s*#define\s+(NS_[A-Z_]+)\s+(0x)?([0-9a-fA-F]+)\s*$/) {
107 #define NS_ERROR_MODULE_XPCOM 1
108 #define NS_ERROR_MODULE_BASE_OFFSET 0x45
109 print " public static final long $1 = $2$3L;\n";
110 }
111 elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\((NS_[A-Z_]+)\s+\+\s+(0x)?([0-9a-fA-F]+)\s*\)\s*/) {
112 #define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
113 #define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
114 print " public static final long $1 = $2 + $3$4L;\n";
115 }
116 elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+(NS_[A-Z_]+)\s\s*/) {
117 #define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
118 print " public static final long $1 = $2;\n";
119 }
120 elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\(\(nsresult\)\s*(0x)?([0-9a-fA-F]+)L?\)\s*$/) {
121 #define NS_ERROR_BASE ((nsresult) 0xC1F30000)
122 #define NS_ERROR_ABORT ((nsresult) 0x80004004L)
123 print " public static final long $1 = $2$3L;\n";
124 }
125 elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_FAILURE\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
126 #define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
127 $module = $2;
128 $code = $3;
129 print " public static final long $1 = ((NS_ERROR_SEVERITY_ERROR<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
130 }
131 elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_SUCCESS\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
132 #define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 1)
133 $module = $2;
134 $code = $3;
135 print " public static final long $1 = ((NS_ERROR_SEVERITY_SUCCESS<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
136 }
137 elsif (/^\s*\/\*(.*)\*\/\s*$/ && !/^\s*\/\*@[\{\}]\*\/\s*$/ &&
138 !/^\s*\/\*\ -\*- Mode:/) {
139 #single line comment, but not
140 #/*@{*/, /*@}*/,
141 #/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
142 print " /*$1*/\n";
143 }
144 elsif (/^\s*$/) {
145 #empty line, but write only the first
146 #line from a sequence of empty lines
147 if (!$wasEmpty) {
148 print "\n";
149 }
150 $wasEmpty = 1;
151 next;
152 }
153 else {
154 next;
155 }
156
157 $wasEmpty = 0;
158}
159
160print "}\n";
161
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette