1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

Bug 319186: Marshalling char16_t and char32_t.

This commit is contained in:
Markus Schorn 2010-07-19 12:59:11 +00:00
parent 11f72ba1e9
commit adef5a84f7
4 changed files with 55 additions and 33 deletions

View file

@ -16,6 +16,7 @@ import java.util.regex.Pattern;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
@ -1269,4 +1270,21 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
getBindingFromASTName("f255", 0); getBindingFromASTName("f255", 0);
getBindingFromASTName("f256", 0); getBindingFromASTName("f256", 0);
} }
// void f(char16_t x);
// void f(char32_t x);
// void test() {
// char16_t c16;
// char32_t c32;
// f(c16); f(c32);
// }
public void testChar16_Bug319186() throws Exception {
IFunction f= getBindingFromASTName("f(c16)", 1);
assertEquals("char16_t", ASTTypeUtil.getType(f.getType().getParameterTypes()[0]));
f= getBindingFromASTName("f(c32)", 1);
assertEquals("char32_t", ASTTypeUtil.getType(f.getType().getParameterTypes()[0]));
}
} }

View file

@ -159,25 +159,26 @@ public class CBasicType implements ICBasicType, ISerializableType {
} }
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.BASIC_TYPE; final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
int kind= getKind().ordinal() * ITypeMarshalBuffer.FLAG1; final int modifiers= getModifiers();
assert kind < ITypeMarshalBuffer.FLAG4; if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
firstByte |= kind; buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
int modifiers= getModifiers();
if (modifiers != 0) {
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) modifiers);
} else { } else {
buffer.putByte((byte) firstByte); buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) kind);
buffer.putByte((byte) modifiers);
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1; final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0;
int modifiers= 0; int modifiers= 0;
if (((firstByte & ITypeMarshalBuffer.FLAG4) != 0)) { int kind;
if (dense) {
kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
} else {
kind= buffer.getByte();
modifiers= buffer.getByte(); modifiers= buffer.getByte();
} }
return new CBasicType(Kind.values()[kind], modifiers); return new CBasicType(Kind.values()[kind], modifiers);

View file

@ -185,25 +185,26 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
} }
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.BASIC_TYPE; final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
int kind= getKind().ordinal() * ITypeMarshalBuffer.FLAG1; final int modifiers= getModifiers();
assert kind < ITypeMarshalBuffer.FLAG4; if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
firstByte |= kind; buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
int modifiers= getModifiers();
if (modifiers != 0) {
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) modifiers);
} else { } else {
buffer.putByte((byte) firstByte); buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) kind);
buffer.putByte((byte) modifiers);
} }
} }
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1; final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0;
int modifiers= 0; int modifiers= 0;
if (((firstByte & ITypeMarshalBuffer.FLAG4) != 0)) { int kind;
if (dense) {
kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
} else {
kind= buffer.getByte();
modifiers= buffer.getByte(); modifiers= buffer.getByte();
} }
return new CPPBasicType(Kind.values()[kind], modifiers); return new CPPBasicType(Kind.values()[kind], modifiers);

View file

@ -194,13 +194,15 @@ public class PDOM extends PlatformObject implements IPDOM {
* 96.0 - storing pack expansions in the template parameter map, bug 294730. * 96.0 - storing pack expansions in the template parameter map, bug 294730.
* 97.0 - storing file contents hash in PDOMFile, bug 302083. * 97.0 - storing file contents hash in PDOMFile, bug 302083.
* #98.0# - strongly typed enums, bug 305975. <<CDT 7.0.0>> * #98.0# - strongly typed enums, bug 305975. <<CDT 7.0.0>>
* 99.0 - correct marshalling of basic types, bug 319186.
* *
* CDT 8.0 development (versions not supported on the 7.0.x branch) * CDT 8.0 development (versions not supported on the 7.0.x branch)
* 110.0 - update index on encoding change, bug 317435. * 110.0 - update index on encoding change, bug 317435.
* 111.0 - correct marshalling of basic types, bug 319186.
*/ */
private static final int MIN_SUPPORTED_VERSION= version(110, 0); private static final int MIN_SUPPORTED_VERSION= version(111, 0);
private static final int MAX_SUPPORTED_VERSION= version(110, Short.MAX_VALUE); private static final int MAX_SUPPORTED_VERSION= version(111, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(110, 0); private static final int DEFAULT_VERSION = version(111, 0);
private static int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;