Search in sources :

Example 56 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class Encoder method slotTrait.

public void slotTrait(int traitKind, int name, int slotId, int type, int value, int valueKind, int[] metadata, DataBuffer in) throws DecoderException {
    if (!abcModifierApplicable || !abcModifier.slotTraitName(name, traitKind, in, this)) {
        currentBuffer.writeU32(history.getIndex(IndexHistory.MULTINAME, name));
    }
    TIntArrayList newMetadata = trimMetadata(metadata);
    if (((traitKind >> 4) & TRAIT_FLAG_metadata) != 0 && newMetadata == null) {
        traitKind &= ~(TRAIT_FLAG_metadata << 4);
    }
    currentBuffer.writeU8(traitKind);
    currentBuffer.writeU32(slotId);
    currentBuffer.writeU32(history.getIndex(IndexHistory.MULTINAME, type));
    int kind = -1;
    switch(valueKind) {
        case CONSTANT_Utf8:
            kind = IndexHistory.STRING;
            break;
        case CONSTANT_Integer:
            kind = IndexHistory.INT;
            break;
        case CONSTANT_UInteger:
            kind = IndexHistory.UINT;
            break;
        case CONSTANT_Double:
            kind = IndexHistory.DOUBLE;
            break;
        case CONSTANT_Namespace:
        case CONSTANT_PrivateNamespace:
        case CONSTANT_PackageNamespace:
        case CONSTANT_PackageInternalNs:
        case CONSTANT_ProtectedNamespace:
        case CONSTANT_ExplicitNamespace:
        case CONSTANT_StaticProtectedNs:
            kind = IndexHistory.NS;
            break;
        case CONSTANT_Qname:
        case CONSTANT_QnameA:
        case CONSTANT_Multiname:
        case CONSTANT_MultinameA:
        case CONSTANT_TypeName:
            kind = IndexHistory.MULTINAME;
            break;
        case CONSTANT_Namespace_Set:
            kind = IndexHistory.NS_SET;
            break;
    }
    int newIndex;
    switch(valueKind) {
        case 0:
        case CONSTANT_False:
        case CONSTANT_True:
        case CONSTANT_Null:
            newIndex = value;
            break;
        default:
            {
                if (kind == -1) {
                    throw new DecoderException("writing slotTrait: don't know what constant type it is... " + valueKind + "," + value);
                }
                newIndex = history.getIndex(kind, value);
            }
    }
    currentBuffer.writeU32(newIndex);
    if (value != 0) {
        currentBuffer.writeU8(valueKind);
    }
    encodeMetaData(newMetadata);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 57 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class EntireMovieTranscoder method transcode.

@Override
protected void transcode(boolean writeBounds) throws IOException {
    if (writeBounds) {
        writeMovieBounds();
    }
    TIntArrayList ignoredBytesPositions = null;
    // write movie as 1-frame, frameCount = 1
    buffer.putShort(swfHeaderEnd - 2, (short) 1);
    int initialStartPosition = swfHeaderEnd;
    int fileAttributesFullLength;
    int tagStart;
    int fileLength = buffer.capacity();
    analyze: while ((tagStart = buffer.position()) < buffer.limit()) {
        final int tagCodeAndLength = buffer.getShort();
        final int type = tagCodeAndLength >> 6;
        int length = tagCodeAndLength & 0x3F;
        if (length == 63) {
            length = buffer.getInt();
        }
        switch(type) {
            case TagTypes.End:
                break analyze;
            case TagTypes.FileAttributes:
                fileAttributesFullLength = length + (buffer.position() - tagStart);
                initialStartPosition = tagStart + fileAttributesFullLength;
                break;
            case TagTypes.Metadata:
            case TagTypes.DebugID:
            case TagTypes.EnableDebugger:
            case TagTypes.EnableDebugger2:
            case TagTypes.ScriptLimits:
            case TagTypes.ProductInfo:
            case TagTypes.ExportAssets:
            case TagTypes.SymbolClass:
                if (ignoredBytesPositions == null) {
                    ignoredBytesPositions = new TIntArrayList();
                }
                ignoredBytesPositions.add(tagStart);
                final int fullLength = length + (buffer.position() - tagStart);
                ignoredBytesPositions.add(tagStart + fullLength);
                fileLength -= fullLength;
                break;
        }
        buffer.position(buffer.position() + length);
    }
    final int spriteTagLength = (fileLength - initialStartPosition) + SPRITE_TAG_LENGTH_EXCEPT_CONTROL_TAGS;
    final byte[] symbolOwnClassAbc = getSymbolOwnClassAbc(frameCount);
    fileLength += PARTIAL_HEADER_LENGTH + symbolOwnClassAbc.length + recordHeaderLength(spriteTagLength) + SPRITE_TAG_LENGTH_EXCEPT_CONTROL_TAGS + SwfUtil.getWrapFooterLength() + SYMBOL_CLASS_TAG_FULL_LENGTH;
    writePartialHeader(out, fileLength);
    out.write(data, 0, initialStartPosition);
    buffer.position(0);
    encodeTagHeader(TagTypes.DefineSprite, spriteTagLength);
    buffer.putShort((short) DOCUMENT_SPRITE_ID);
    buffer.putShort(frameCount);
    out.write(data, 0, buffer.position());
    if (ignoredBytesPositions == null) {
        out.write(data, initialStartPosition, data.length - initialStartPosition);
    } else {
        writeSparseBytes(ignoredBytesPositions, initialStartPosition, data.length);
    }
    out.write(symbolOwnClassAbc);
    writeSymbolClass(DOCUMENT_SPRITE_ID);
    SwfUtil.footer(out);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 58 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class MovieSymbolTranscoder method writePlacedObject.

private void writePlacedObject(PlacedObject object) throws IOException {
    final TIntArrayList positions = object.positions;
    if (positions == null) {
        out.write(data, object.tagStart, object.start - object.tagStart);
        // little-endian short new id
        out.write(0xff & object.newId);
        out.write(0xff & (object.newId >> 8));
        out.write(data, object.start + 2, object.length - 2);
    } else {
        buffer.position(0);
        encodeTagHeader(object.tagType, object.actualLength);
        buffer.putShort((short) object.newId);
        out.write(data, 0, buffer.position());
        writeSparseBytes(positions, object.start + 2, object.start + object.length);
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 59 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class DFSTBuilder method getComponents.

@NotNull
public Collection<Collection<Node>> getComponents() {
    final TIntArrayList componentSizes = getSCCs();
    if (componentSizes.isEmpty())
        return Collections.emptyList();
    return new MyCollection<Collection<Node>>(componentSizes.size()) {

        @NotNull
        @Override
        public Iterator<Collection<Node>> iterator() {
            return new MyIterator<Collection<Node>>(componentSizes.size()) {

                private int offset;

                @Override
                protected Collection<Node> get(int i) {
                    final int cSize = componentSizes.get(i);
                    final int cOffset = offset;
                    if (cSize == 0)
                        return Collections.emptyList();
                    offset += cSize;
                    return new MyCollection<Node>(cSize) {

                        @NotNull
                        @Override
                        public Iterator<Node> iterator() {
                            return new MyIterator<Node>(cSize) {

                                @Override
                                public Node get(int i) {
                                    return getNodeByTNumber(cOffset + i);
                                }
                            };
                        }
                    };
                }
            };
        }
    };
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 60 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-community by JetBrains.

the class URLUtil method unescapePercentSequences.

@NotNull
public static String unescapePercentSequences(@NotNull String s) {
    if (s.indexOf('%') == -1) {
        return s;
    }
    StringBuilder decoded = new StringBuilder();
    final int len = s.length();
    int i = 0;
    while (i < len) {
        char c = s.charAt(i);
        if (c == '%') {
            TIntArrayList bytes = new TIntArrayList();
            while (i + 2 < len && s.charAt(i) == '%') {
                final int d1 = decode(s.charAt(i + 1));
                final int d2 = decode(s.charAt(i + 2));
                if (d1 != -1 && d2 != -1) {
                    bytes.add(((d1 & 0xf) << 4 | d2 & 0xf));
                    i += 3;
                } else {
                    break;
                }
            }
            if (!bytes.isEmpty()) {
                final byte[] bytesArray = new byte[bytes.size()];
                for (int j = 0; j < bytes.size(); j++) {
                    bytesArray[j] = (byte) bytes.getQuick(j);
                }
                decoded.append(new String(bytesArray, CharsetToolkit.UTF8_CHARSET));
                continue;
            }
        }
        decoded.append(c);
        i++;
    }
    return decoded.toString();
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2