Skip to content

Commit

Permalink
Builder is now only used when there are properties. Added support for…
Browse files Browse the repository at this point in the history
… returning bytes for readPad. xkb.xml had a reply with duplicate fields. Renamed on of the nKeyAliases to nKeyAliases2.
  • Loading branch information
moaxcp committed Oct 30, 2021
1 parent a0a7d39 commit c9c8904
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ abstract class JavaClass implements JavaType {
}

void addHeaderStatements(MethodSpec.Builder builder) {
builder.addStatement('$T $L = $T.builder()', builderClassName, 'javaBuilder', className)
if(!properties.isEmpty()) {
builder.addStatement('$T $L = $T.builder()', builderClassName, 'javaBuilder', className)
}
}

void addReadStatements(MethodSpec.Builder methodBuilder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public interface X11Input {

List<Integer> readFd(int length) throws IOException;

default void readPad(int length) throws IOException {
readByte(length);
}
byte[] readPad(int length) throws IOException;

default void readPadAlign(int forLength) throws IOException {
readPad(XObject.getSizeForPadAlign(forLength));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ public List<Integer> readFd(int length) throws IOException {
return readInt32(length);
}

@Override
public byte[] readPad(int length) throws IOException {
byte[] bytes = new byte[length];
int read = in.read(bytes);
int sum = read;
while(read != -1 && sum < length) {
read = in.read(bytes, sum, length - sum);
sum += read;
}
if(read == -1) {
throw new IOException("could not read " + length + " bytes for pad");
}
return bytes;
}

@Override
public int available() throws IOException {
return in.available();
Expand Down
2 changes: 1 addition & 1 deletion src/main/xcbXmls/xkb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ authorization from the authors.
<field name="nShapes" type="CARD16" />
<field name="nSections" type="CARD16" />
<field name="nDoodads" type="CARD16" />
<field name="nKeyAliases" type="CARD16" />
<field name="nKeyAliases2" type="CARD16" />
<field name="baseColorNdx" type="CARD8" />
<field name="labelColorNdx" type="CARD8" />
<field name="labelFont" type="CountedString16" />
Expand Down

0 comments on commit c9c8904

Please sign in to comment.