Better alignas and swift example formatting fixes.
GitOrigin-RevId: f13cb9754b0f91975710662d30c87563de4d7641
This commit is contained in:
parent
35179d5b15
commit
72df55fb2d
@ -7,8 +7,8 @@ class TdClient {
|
|||||||
let tdlibMainLoop = DispatchQueue(label: "TDLib")
|
let tdlibMainLoop = DispatchQueue(label: "TDLib")
|
||||||
let tdlibQueryQueue = DispatchQueue(label: "TDLibQuery")
|
let tdlibQueryQueue = DispatchQueue(label: "TDLibQuery")
|
||||||
var queryF = Dictionary<Int64, (Dictionary<String,Any>)->()>()
|
var queryF = Dictionary<Int64, (Dictionary<String,Any>)->()>()
|
||||||
var updateF : ((Dictionary<String,Any>)->())?
|
var updateF: ((Dictionary<String,Any>)->())?
|
||||||
var queryId : Int64 = 0
|
var queryId: Int64 = 0
|
||||||
|
|
||||||
func queryAsync(query: [String: Any], f: ((Dictionary<String,Any>)->())? = nil) {
|
func queryAsync(query: [String: Any], f: ((Dictionary<String,Any>)->())? = nil) {
|
||||||
tdlibQueryQueue.async {
|
tdlibQueryQueue.async {
|
||||||
@ -33,7 +33,6 @@ class TdClient {
|
|||||||
}
|
}
|
||||||
semaphore.wait()
|
semaphore.wait()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -48,7 +47,7 @@ class TdClient {
|
|||||||
tdlibMainLoop.async { [weak self] in
|
tdlibMainLoop.async { [weak self] in
|
||||||
while (true) {
|
while (true) {
|
||||||
if let s = self {
|
if let s = self {
|
||||||
if let res = td_json_client_receive(s.client,10) {
|
if let res = td_json_client_receive(s.client, 10) {
|
||||||
let event = String(cString: res)
|
let event = String(cString: res)
|
||||||
s.queryResultAsync(event)
|
s.queryResultAsync(event)
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ func myReadLine() -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAuthorizationState(authState : Dictionary<String, Any>) {
|
func updateAuthorizationState(authState: Dictionary<String, Any>) {
|
||||||
switch(authState["@type"] as! String) {
|
switch(authState["@type"] as! String) {
|
||||||
case "authorizationStateWaitTdlibParameters":
|
case "authorizationStateWaitTdlibParameters":
|
||||||
client.queryAsync(query:[
|
client.queryAsync(query:[
|
||||||
@ -125,12 +124,12 @@ func updateAuthorizationState(authState : Dictionary<String, Any>) {
|
|||||||
client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthError)
|
client.queryAsync(query:["@type":"setAuthenticationPhoneNumber", "phone_number":phone], f:checkAuthError)
|
||||||
|
|
||||||
case "authorizationStateWaitCode":
|
case "authorizationStateWaitCode":
|
||||||
var first_name : String = ""
|
var first_name: String = ""
|
||||||
var last_name: String = ""
|
var last_name: String = ""
|
||||||
var code : String = ""
|
var code: String = ""
|
||||||
if let is_registered = authState["is_registered"] as? Bool, is_registered {
|
if let is_registered = authState["is_registered"] as? Bool, is_registered {
|
||||||
} else {
|
} else {
|
||||||
print("Enter your first name : ")
|
print("Enter your first name: ")
|
||||||
first_name = myReadLine()
|
first_name = myReadLine()
|
||||||
print("Enter your last name: ")
|
print("Enter your last name: ")
|
||||||
last_name = myReadLine()
|
last_name = myReadLine()
|
||||||
@ -169,5 +168,3 @@ client.run {
|
|||||||
while true {
|
while true {
|
||||||
sleep(1)
|
sleep(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
alignas(128) const unsigned char TlParser::empty_data[sizeof(UInt256)] = {}; // static zero-initialized
|
alignas(4) const unsigned char TlParser::empty_data[sizeof(UInt256)] = {}; // static zero-initialized
|
||||||
|
|
||||||
void TlParser::set_error(const string &error_message) {
|
void TlParser::set_error(const string &error_message) {
|
||||||
if (error.empty()) {
|
if (error.empty()) {
|
||||||
|
@ -33,7 +33,7 @@ class TlParser {
|
|||||||
static constexpr size_t SMALL_DATA_ARRAY_SIZE = 6;
|
static constexpr size_t SMALL_DATA_ARRAY_SIZE = 6;
|
||||||
std::array<int32, SMALL_DATA_ARRAY_SIZE> small_data_array;
|
std::array<int32, SMALL_DATA_ARRAY_SIZE> small_data_array;
|
||||||
|
|
||||||
static const unsigned char empty_data[sizeof(UInt256)];
|
alignas(4) static const unsigned char empty_data[sizeof(UInt256)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TlParser(Slice slice) {
|
explicit TlParser(Slice slice) {
|
||||||
|
Reference in New Issue
Block a user