1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +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 org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -1269,4 +1270,21 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
getBindingFromASTName("f255", 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,27 +159,28 @@ public class CBasicType implements ICBasicType, ISerializableType {
}
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.BASIC_TYPE;
int kind= getKind().ordinal() * ITypeMarshalBuffer.FLAG1;
assert kind < ITypeMarshalBuffer.FLAG4;
firstByte |= kind;
int modifiers= getModifiers();
if (modifiers != 0) {
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) modifiers);
final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
final int modifiers= getModifiers();
if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} 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 {
int kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 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();
}
}
return new CBasicType(Kind.values()[kind], modifiers);
}

View file

@ -185,27 +185,28 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
}
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= ITypeMarshalBuffer.BASIC_TYPE;
int kind= getKind().ordinal() * ITypeMarshalBuffer.FLAG1;
assert kind < ITypeMarshalBuffer.FLAG4;
firstByte |= kind;
int modifiers= getModifiers();
if (modifiers != 0) {
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG4));
buffer.putByte((byte) modifiers);
final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
final int modifiers= getModifiers();
if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} 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 {
int kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 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();
}
}
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.
* 97.0 - storing file contents hash in PDOMFile, bug 302083.
* #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)
* 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 MAX_SUPPORTED_VERSION= version(110, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(110, 0);
private static final int MIN_SUPPORTED_VERSION= version(111, 0);
private static final int MAX_SUPPORTED_VERSION= version(111, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(111, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;