📄 typecodeimpl.java
字号:
case TCKind._tk_longlong: _unionLabels[i].insert_longlong(_encap.read_longlong()); break; case TCKind._tk_ulonglong: _unionLabels[i].insert_ulonglong(_encap.read_longlong()); break; // _REVISIT_ figure out long double mapping // case TCKind.tk_longdouble: // _unionLabels[i].insert_longdouble(_encap.getDouble()); // break; case TCKind._tk_wchar: _unionLabels[i].insert_wchar(_encap.read_wchar()); break; default: throw wrapper.invalidComplexTypecode() ; } } _memberNames[i] = _encap.read_string(); _memberTypes[i] = new TypeCodeImpl((ORB)is.orb()); _memberTypes[i].read_value_recursive(_encap); _memberTypes[i].setParent(this); } } break; case TCKind._tk_enum: { // get the repository id setId(_encap.read_string()); // get the name _name = _encap.read_string(); // get the number of members _memberCount = _encap.read_long(); // create arrays for the identifier names _memberNames = new String[_memberCount]; // read off identifier names for (int i=0; i < _memberCount; i++) _memberNames[i] = _encap.read_string(); } break; case TCKind._tk_sequence: { // get the type of the sequence _contentType = new TypeCodeImpl((ORB)is.orb()); _contentType.read_value_recursive(_encap); // get the bound on the length of the sequence _length = _encap.read_long(); } break; case TCKind._tk_array: { // get the type of the array _contentType = new TypeCodeImpl((ORB)is.orb()); _contentType.read_value_recursive(_encap); // get the length of the array _length = _encap.read_long(); } break; case TCKind._tk_alias: case TCKind._tk_value_box: { // get the repository id setId(_encap.read_string()); // get the name _name = _encap.read_string(); // get the type aliased _contentType = new TypeCodeImpl((ORB)is.orb()); _contentType.read_value_recursive(_encap); } break; case TCKind._tk_except: case TCKind._tk_struct: { // get the repository id setId(_encap.read_string()); // get the name _name = _encap.read_string(); // get the number of members _memberCount = _encap.read_long(); // create arrays for the names and types of members _memberNames = new String[_memberCount]; _memberTypes = new TypeCodeImpl[_memberCount]; // read off member names and types for (int i=0; i < _memberCount; i++) { _memberNames[i] = _encap.read_string(); _memberTypes[i] = new TypeCodeImpl((ORB)is.orb()); //if (debug) System.out.println("TypeCode " + _name + // " reading member " + _memberNames[i]); _memberTypes[i].read_value_recursive(_encap); _memberTypes[i].setParent(this); } } break; case TCKind._tk_value: { // get the repository id setId(_encap.read_string()); // get the name _name = _encap.read_string(); // get the type modifier _type_modifier = _encap.read_short(); // get the type aliased _concrete_base = new TypeCodeImpl((ORB)is.orb()); _concrete_base.read_value_recursive(_encap); if (_concrete_base.kind().value() == TCKind._tk_null) { _concrete_base = null; } // get the number of members _memberCount = _encap.read_long(); // create arrays for the names, types and visibility of members _memberNames = new String[_memberCount]; _memberTypes = new TypeCodeImpl[_memberCount]; _memberAccess = new short[_memberCount]; // read off value member visibilities for (int i=0; i < _memberCount; i++) { _memberNames[i] = _encap.read_string(); _memberTypes[i] = new TypeCodeImpl((ORB)is.orb()); //if (debug) System.out.println("TypeCode " + _name + // " reading member " + _memberNames[i]); _memberTypes[i].read_value_recursive(_encap); _memberTypes[i].setParent(this); _memberAccess[i] = _encap.read_short(); } } break; default: throw wrapper.invalidTypecodeKindMarshal() ; } break; } } } public void write_value(OutputStream os) { // Wrap OutputStream into TypeCodeOutputStream. // This test shouldn't be necessary according to the Java language spec. if (os instanceof TypeCodeOutputStream) { this.write_value((TypeCodeOutputStream)os); } else { TypeCodeOutputStream wrapperOutStream = null; if (outBuffer == null) { wrapperOutStream = TypeCodeOutputStream.wrapOutputStream(os); this.write_value(wrapperOutStream); if (cachingEnabled) { // Cache the buffer for repeated writes outBuffer = wrapperOutStream.getTypeCodeBuffer(); //if (outBuffer != null) //System.out.println("Caching outBuffer with length = " + //outBuffer.length + " for id = " + _id); } } else { //System.out.println("Using cached outBuffer: length = " + outBuffer.length + //", id = " + _id); } // Write the first 4 bytes first to trigger alignment. // We know that it is the kind. if (cachingEnabled && outBuffer != null) { os.write_long(_kind); os.write_octet_array(outBuffer, 0, outBuffer.length); } else { //System.out.println("Buffer is empty for " + _id); wrapperOutStream.writeRawBuffer(os, _kind); } } } public void write_value(TypeCodeOutputStream tcos) { // Don't do any work if this is native if (_kind == TCKind._tk_native) throw wrapper.cannotMarshalNative() ; TypeCodeOutputStream topStream = tcos.getTopLevelStream(); //if (debug) tcos.printBuffer(); if (_kind == tk_indirect) { //if (debug) System.out.println("Writing indirection " + _name + "to " + _id); // The encoding used for indirection is the same as that used for recursive , // TypeCodes i.e., a 0xffffffff indirection marker followed by a long offset // (in units of octets) from the beginning of the long offset. int pos = topStream.getPositionForID(_id); int topPos = tcos.getTopLevelPosition(); //if (debug) System.out.println("TypeCodeImpl " + tcos + // " writing indirection " + _id + //" to position " + pos + " at position " + topPos); tcos.writeIndirection(tk_indirect, pos); // All that gets written is _kind and offset. return; } // The original approach changed for 5034649 // topStream.addIDAtPosition(_id, tcos.getTopLevelPosition()); // marshal the kind tcos.write_long(_kind); //if (debug) System.out.println("Writing " + _name + " with id " + _id); // We have to remember the stream and position for EVERY type code // in case some recursive or indirect type code references it. // // Bug fix 5034649: // Do this AFTER the write of the _kind in case the alignment // for the long changes the position. topStream.addIDAtPosition(_id, tcos.getTopLevelPosition()-4); switch (typeTable[_kind]) { case EMPTY: // nothing more to marshal break; case SIMPLE: switch (_kind) { case TCKind._tk_string: case TCKind._tk_wstring: // marshal the bound on string length tcos.write_long(_length); break; case TCKind._tk_fixed: tcos.write_ushort(_digits); tcos.write_short(_scale); break; default: // unknown typecode kind throw wrapper.invalidSimpleTypecode() ; } break; case COMPLEX: { // create an encapsulation TypeCodeOutputStream _encap = tcos.createEncapsulation(tcos.orb()); switch(_kind) { case TCKind._tk_objref: case TCKind._tk_abstract_interface: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); } break; case TCKind._tk_union: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); // discriminant typecode _discriminator.write_value(_encap); // default index _encap.write_long(_defaultIndex); // put the number of members _encap.write_long(_memberCount); // marshal label values, names and types for (int i=0; i < _memberCount; i++) { // for the default case, marshal the zero octet if (i == _defaultIndex) _encap.write_octet(_unionLabels[i].extract_octet()); else { switch (realType(_discriminator).kind().value()) { case TCKind._tk_short: _encap.write_short(_unionLabels[i].extract_short()); break; case TCKind._tk_long: _encap.write_long(_unionLabels[i].extract_long()); break; case TCKind._tk_ushort: _encap.write_short(_unionLabels[i].extract_ushort()); break; case TCKind._tk_ulong: _encap.write_long(_unionLabels[i].extract_ulong()); break; case TCKind._tk_float: _encap.write_float(_unionLabels[i].extract_float()); break; case TCKind._tk_double: _encap.write_double(_unionLabels[i].extract_double()); break; case TCKind._tk_boolean: _encap.write_boolean(_unionLabels[i].extract_boolean()); break; case TCKind._tk_char: _encap.write_char(_unionLabels[i].extract_char()); break; case TCKind._tk_enum: _encap.write_long(_unionLabels[i].extract_long()); break; case TCKind._tk_longlong: _encap.write_longlong(_unionLabels[i].extract_longlong()); break; case TCKind._tk_ulonglong: _encap.write_longlong(_unionLabels[i].extract_ulonglong()); break; // _REVISIT_ figure out long double mapping // case TCKind.tk_longdouble: // _encap.putDouble(_unionLabels[i].extract_longdouble()); // break; case TCKind._tk_wchar: _encap.write_wchar(_unionLabels[i].extract_wchar()); break; default: throw wrapper.invalidComplexTypecode() ; } } _encap.write_string(_memberNames[i]); _memberTypes[i].write_value(_encap); } } break; case TCKind._tk_enum: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); // put the number of members _encap.write_long(_memberCount); // marshal identifier names for (int i=0; i < _memberCount; i++) _encap.write_string(_memberNames[i]); } break; case TCKind._tk_sequence: { // put the type of the sequence lazy_content_type().write_value(_encap); // put the bound on the length of the sequence _encap.write_long(_length); } break; case TCKind._tk_array: { // put the type of the array _contentType.write_value(_encap); // put the length of the array _encap.write_long(_length); } break; case TCKind._tk_alias: case TCKind._tk_value_box: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); // put the type aliased _contentType.write_value(_encap); } break; case TCKind._tk_struct: case TCKind._tk_except: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); // put the number of members _encap.write_long(_memberCount); // marshal member names and types for (int i=0; i < _memberCount; i++) { _encap.write_string(_memberNames[i]); //if (debug) System.out.println("TypeCode " + _name + // " writing member " + _memberNames[i]); _memberTypes[i].write_value(_encap); } } break; case TCKind._tk_value: { // put the repository id _encap.write_string(_id); // put the name _encap.write_string(_name); // put the type modifier _encap.write_short(_type_modifier); // put the type aliased if (_concrete_base == null) { _orb.get_primitive_tc(TCKind._tk_null).write_value(_encap); } else { _concrete_base.write_value(_encap); } // put the number of members _encap.write_long(_memberCount); // marshal member names and types for (int i=0; i < _memberCount; i++) { _encap.write_string(_memberNames[i]); //if (debug) System.out.println("TypeCode " + _name + // " writing member " + _memberNames[i]); _memberTypes[i].write_value(_encap); _encap.write_short(_memberAccess[i]); } } break; default: throw wrapper.invalidTypecodeKindMarshal() ; } // marshal the encapsulation _encap.writeOctetSequenceTo(tcos); break; } } } /** * This is not a copy of the TypeCodeImpl objects, but instead it * copies the value this type code is representing. * See AnyImpl read_value and write_value for usage. * The state of this TypeCodeImpl instance isn't changed, only used * by the Any to do the correct copy. */ protected void copy(org.omg.CORBA.portable.InputStream src, org.omg.CORBA.portable.OutputStream dst) { switch (_kind) { case TCKind._tk_null: case TCKind._tk_void: case TCKind._tk_native: case TCKind._tk_abstract_interface: break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -