396N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 157N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 157N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 157N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 157N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Licensed Materials - Property of IBM 0N/A * Copyright IBM Corp. 1998 1999 All Rights Reserved 0N/A * IDLNames provides static utility methods to perform the IDL 0N/A * name mappings specified in Chapter 5 of the Java Language 0N/A * to IDL specification. 0N/A * @author Bryan Atsatt 0N/A * Used to convert ascii to hex. 396N/A // Legal IDL Identifier characters (1 = legal). Note 396N/A // that '.' (2E) is marked as legal even though it is 396N/A // not legal in IDL. This allows us to treat a fully 396N/A // qualified Java name with '.' package separators 396N/A // uniformly, and is safe because that is the only 396N/A // legal use of '.' in a Java name. 396N/A // 0 1 2 3 4 5 6 7 8 9 a b c d e f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// 00-0f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// 10-1f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
// 20-2f 396N/A 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
// 30-3f 396N/A 0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
// 40-4f 396N/A 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
1,
// 50-5f 396N/A 0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
// 60-6f 396N/A 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
// 70-7f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// 80-8f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// 90-9f 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// a0-af 396N/A 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
// b0-bf 396N/A 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
// c0-cf 396N/A 0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0,
1,
// d0-df 396N/A 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
// e0-ef 396N/A 0,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
0,
0,
1,
// f0-ff 0N/A //_____________________________________________________________________ 0N/A // Public Interfaces 0N/A //_____________________________________________________________________ 0N/A * Convert a name. The nameContext argument MUST be pre-filled with 0N/A * all names from the appropriate context (e.g. all the method names 0N/A * in a given class). The names must not have had any IDL conversions 0N/A * Section 28.3.2.7 (member and method names only) 0N/A // Check namesCache... 0N/A // 28.3.2.7 Case sensitive member names. 0N/A // Note: This must be done before any of 0N/A // the other conversions! 0N/A // 28.3.2.3 Leading underscores... 0N/A // 28.3.2.2 IDL keywords (NOTE: must be done 0N/A // after leading underscore conversion because 0N/A // the mangling for IDL keywords creates a 0N/A // leading underscore!)... 0N/A // 28.3.2.4 Illegal IDL identifier characters... 0N/A // Add to namesCache... 0N/A * Convert names with illegal IDL identifier characters. 0N/A // First, replace any escape sequences... 0N/A // Now see if we have any remaining illegal characters (see 396N/A // IDL_IDENTIFIER_CHARS array)... 0N/A // We gotta convert. Have we already started? 0N/A // No, so get set up... 0N/A // Convert the character into the IDL escape syntax... 0N/A * Convert names which collide with IDL keywords. 0N/A * Convert names which have leading underscores 0N/A * Convert a type name. 0N/A * Section 28.3.2.7 (class or interface names only) 0N/A * Throws exception if fails 28.3.2.7. 0N/A // Get the type and package name... 0N/A // Check namesCache... 0N/A // 28.3.2.5 Inner classes... 0N/A // 28.3.2.4 Illegal identifier characters... 0N/A // 28.3.2.7 Case sensitive class or interface names... 0N/A // Run it through the name checks... 0N/A // Add it to the namesCache... 0N/A * Convert an Exception name. 0N/A * Section 28.3.7.2 (see ValueType) 0N/A// d.11315 Incorrectly mangled exception names 0N/A // Remove "Exception" and append "Ex". Strip leading underscore 0N/A // in case the idlName is exactly "_Exception"... 0N/A * Convert a qualified Identifier into an array of IDL names. 0N/A * Section 28.3.2.1 (see CompoundType) 0N/A * Throws exception if fails 28.3.2.7. 0N/A // Extract the qualifier... 0N/A // 28.3.2.7 Case sensitive module names. 0N/A // Now walk them and fill our array (backwards)... 0N/A // Check namesCache... 0N/A // 28.3.2.4 Illegal identifier characters... 0N/A // Run it through the name checks... 0N/A // Add it to the namesCache... 0N/A // If it is supposed to be "boxed", prepend 0N/A // IDL_BOXEDIDL_MODULE... 0N/A * Get an array name with the specified dimensions. 0N/A * Section 28.3.6 (see ArrayType) 0N/A // Prefix with seq<n>_... 0N/A // Add the type name. We need to map any spaces in the 0N/A // And we're done... 0N/A * Get an array module names. 0N/A // Does the type have a module? 0N/A // Nope, so just use the sequence module... 0N/A // Yes, so gotta concatenate... 0N/A // First make sure it is not a constructor... 0N/A // Now check exceptions. It may not throw any checked 0N/A // exception other than RemoteException or one of its 0N/A // If this is a ValueType, it is ok to not have any exceptions, 0N/A // otherwise this method does not qualify... 0N/A // It's a getter if name starts with "get" and it has no arguments 0N/A // and a return type that is not void... 0N/A // It's a getter if name starts with "is" and it has no arguments 0N/A // and a boolean return type... 0N/A // It's a setter if name starts with "set" and it has 1 argument 0N/A // and a void return type... 0N/A // Strip the prefixes off of the attribute names... 0N/A // Now, we need to look at all the IS attributes to see 0N/A // if there is a corresponding getter or setter which has 0N/A // a different return type. If so, mark it as not an 0N/A // attribute. Do this before checking for invalid setters... 0N/A // We have matching getter or setter. Do the types match? 0N/A // No, so forget this guy as an attribute... 0N/A // Now, we need to look at all the setters to see if there 0N/A // is a corresponding getter. If not, it is not a setter. 0N/A // If there is, change the getter type to _RW and set the 0N/A // First look for is-getters, then for getters. 0N/A // This is preferred for boolean attributes. 0N/A // Yep, is the return type of the getter the same 0N/A // as the argument type of the setter? 0N/A // continue looking for another getter 0N/A // continue looking for an is-getter 0N/A // We have both, a boolean is-getter and a boolean getter. 0N/A // Use the is-getter and drop the getter. 0N/A // We have a matching getter. Change it to a read-write type... 0N/A // Now set the pair index for both the getter and the setter... 0N/A // We found a better matching is-getter. 0N/A // Forget this other getter as an attribute. 0N/A // We only have one getter. 0N/A // We have a matching getter. Change it to a read-write type... 0N/A // Now set the pair index for both the getter and the setter... 0N/A // We only have one is-getter. 0N/A // We have a matching getter. Change it to a read-write type... 0N/A // Now set the pair index for both the getter and the setter... 0N/A // We did not find a matching getter. 0N/A // Forget this setter as an attribute. 0N/A // Finally, do the case conversion and set the 0N/A // attribute kinds for each method... 0N/A // Is the first character upper case? 0N/A // Yes, is the second? 0N/A // No, so convert the first character to lower case... 0N/A * Set all the method names in a given class. 0N/A * Section 28.3.2.7 (see CompoundType) 0N/A // This method implements the following name mangling sequence: 0N/A // 1. If methods belong to a Remote interface, identify 0N/A // those which qualify as an attribute under 28.3.4.3. 0N/A // Those that do are referred to as 'attributes' below; 0N/A // those that do not are referred to as 'methods'. 0N/A // 2. Apply the 28.3.4.3 manglings, except "__", to all 0N/A // 3. Apply all 28.3 manglings, except 28.3.2.7, to all names. 0N/A // 4. Apply 28.3.2.7 manglings to all method names. 0N/A // 5. Compare each attribute name to each method name. For 0N/A // any which compare equal, append "__" to the attribute 0N/A // 6. Compare each name (attribute and method) to all others. 0N/A // If any compare equal, throw an Exception with the 0N/A // conflicting name as the message. 0N/A // Make an array of all the method names... 0N/A // Are we dealing with a RemoteType, AbstractType, or ValueType? 0N/A // Yes, so we must do the 28.3.4.3 attribute mapping. First, get 0N/A // the initial attribute kind of each method... 0N/A // Now set the attribute kind for each method and do the 0N/A // 28.3.4.3 name mangling... 0N/A // Make and populate a new context from our names array... 0N/A // Apply the appropriate 28.3 manglings to all the names... 0N/A // Now do the 28.3.2.7 mangling for method name collisions... 0N/A // Do this in two passes so that we don't change one during 0N/A // the detection of collisions and then miss a real one... 0N/A // Now do the same mangling for constructor name collisions... 0N/A // Now do the 28.3.4.3 mangling for attribute name collisions... 0N/A // If this is an attribute name, does it collide with a method? 0N/A // Yes, so add double underscore... 0N/A // Do the same mangling for any constructors which collide with 0N/A // Is this a constructor which collides with a method? 0N/A // Yes, so add double underscore... 0N/A // Now see if we have a collision with the container name (28.3.2.9). 0N/A // Do not add underscore to attributes. 0N/A // Otherwise getFoo will turn into _get_foo_. 0N/A // Now see if we have any collisions (28.3.2.9). If we do, 0N/A // it's an error. Note: a get/set pair does not collide. 0N/A // Does it collide with any other name? 0N/A // Ok. We have unique names. Create the appropriate 'wire' name 0N/A // for each and set as the 'idl' name. If it is an attribute, also 0N/A // set the attribute name... 0N/A // Do we need to mangle it? 0N/A // Yes, so add arguments... 0N/A // Add the separator... 0N/A // Get the fully qualified IDL name, without the "::" 0N/A // Replace any occurances of "::_" with "_" to 0N/A // undo any IDL keyword mangling and do next step 0N/A // at the same time... 0N/A // Replace any occurances of "::" with "_"... 0N/A // Replace any occurances of " " with "_"... 0N/A // Add the argument type name... 0N/A // Remove any IDL keyword mangling... 0N/A // Scan all methods looking for a match... 0N/A // Yes, so ignore it... 0N/A // No, so we have a collision... 0N/A // Scan all methods looking for a match... 0N/A // We have a collision... 0N/A * Set all the member names in a given class. 0N/A * Section 28.3.2.7 (see CompoundType) 0N/A // Make and populate a new context... 0N/A // Now set all the idl names... 0N/A // First see if we have a collision with the container name (28.3.2.9). 0N/A // REVISIT - How is this different than line 788 0N/A // Check for collisions between member names... 0N/A // Now check for collisions between member names and 0N/A // Collision, so append "_" to member name... 0N/A * Get the name for the specified type code. 0N/A * Section 28.3..3 (see PrimitiveType) 0N/A * Section 28.3.5.10 (see SpecialClassType) 0N/A * Section 28.3.4.1 (see SpecialInterfaceType) 0N/A * Section 28.3.10.1 (see SpecialInterfaceType) 0N/A * Section 28.3.10.2 (see SpecialClassType) 0N/A * Create a qualified name. 0N/A * Replace substrings 0N/A * @param source The source string. 0N/A * @param match The string to search for within the source string. 0N/A * @param replace The replacement for any matching components. 0N/A // We have at least one match, so gotta do the 0N/A // Grab the last piece, if any... 0N/A // No matches, just return the source... 0N/A * Get an IDL style repository id for 0N/A //_____________________________________________________________________ 0N/A // Internal Interfaces 0N/A //_____________________________________________________________________ 0N/A * Convert a type or module name. 0N/A // 28.3.2.3 Leading underscores... 0N/A // 28.3.2.2 IDL keywords (NOTE: must be done 0N/A // after leading underscore conversion because 0N/A // the mangling for IDL keywords creates a 0N/A // leading underscore!)...