 //
 
 import Foundation
+
+protocol UnpackedType {}
+
+extension NSString: UnpackedType {}
+extension Bool: UnpackedType {}
+extension Int: UnpackedType {}
+extension Double: UnpackedType {}
 
 extension String {
     subscript (from:Int, to:Int) -> String {

        for _ in 0..<max(n,1) {
            
            var bytes : [UInt8] = []

            if c != "x" {
                o = objectsQueue.removeFirst()
            }

        }
        
        var o : AnyObject = 0
        
        if c == "s" {
            o = objectsQueue.removeFirst()
            
            guard let stringData = (o as! String).dataUsingEncoding(stringEncoding) else { assertionFailure(); return NSData() }
            var bytes = stringData.bytesArray()
            
            let expectedSize = max(1, n)
            
            // pad ...
            while bytes.count < expectedSize { bytes.append(0x00) }
            
            // ... or trunk
            if bytes.count > expectedSize { bytes = Array(bytes[0..<expectedSize]) }
            
            assert(bytes.count == expectedSize)
            
            if isBigEndian { bytes = bytes.reverse() }
            let data = NSData(bytes)
            mutableData.appendData(data)
            
            n = 0
            continue
        }
