Skip to content

Commit

Permalink
add recommended changes by @satoshiotomakan
Browse files Browse the repository at this point in the history
  • Loading branch information
lamafab committed May 10, 2023
1 parent 5253977 commit 5a74076
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 15 deletions.
6 changes: 6 additions & 0 deletions codegen-v2/src/codegen/swift/render.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

use super::{inits::process_deinits, *};

#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion codegen-v2/src/codegen/swift/templates/WalletCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ FOUNDATION_EXPORT const unsigned char WalletCoreVersionString[];
#include "TWTHORChainSwap.h"
#include "TWTezosMessageSigner.h"
#include "TWTransactionCompiler.h"
#include "TWTronMessageSigner.h"
#include "TWTronMessageSigner.h"
3 changes: 2 additions & 1 deletion codegen-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn current_year() -> u64 {
.duration_since(UNIX_EPOCH)
.expect("System's time is set before the start of the Unix epoch");

// 31556952 seconds in a year
// One Gregorian calendar year has 365.2425 days,
// respectively 31556952 seconds.
1970 + (seconds_since_epoch.as_secs() / 31556952)
}
16 changes: 9 additions & 7 deletions codegen-v2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ fn main() -> Result<()> {
fn generate_swift_bindings() -> Result<()> {
// NOTE: The paths will be configurable, eventually.
const OUT_DIR: &str = "bindings/";
const IN_DIR: &str = "src/codegen/swift/templates";

std::fs::create_dir_all(OUT_DIR)?;

let struct_t = read_to_string("src/codegen/swift/templates/struct.hbs")?;
let enum_t = read_to_string("src/codegen/swift/templates/enum.hbs")?;
let ext_t = read_to_string("src/codegen/swift/templates/extension.hbs")?;
let proto_t = read_to_string("src/codegen/swift/templates/proto.hbs")?;
let part_init_t = read_to_string("src/codegen/swift/templates/partial_init.hbs")?;
let part_func_t = read_to_string("src/codegen/swift/templates/partial_func.hbs")?;
let part_prop_t = read_to_string("src/codegen/swift/templates/partial_prop.hbs")?;
let struct_t = read_to_string(&format!("{IN_DIR}/struct.hbs"))?;
let enum_t = read_to_string(&format!("{IN_DIR}/enum.hbs"))?;
let ext_t = read_to_string(&format!("{IN_DIR}/extension.hbs"))?;
let proto_t = read_to_string(&format!("{IN_DIR}/proto.hbs"))?;
let part_init_t = read_to_string(&format!("{IN_DIR}/partial_init.hbs"))?;
let part_func_t = read_to_string(&format!("{IN_DIR}/partial_func.hbs"))?;
let part_prop_t = read_to_string(&format!("{IN_DIR}/partial_prop.hbs"))?;

// Read the manifest dir, generate bindings for each entry.
let file_infos = parse_dir("manifest/")?;
Expand Down
6 changes: 6 additions & 0 deletions codegen-v2/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

use crate::codegen::swift::{render_to_strings, RenderIntput};
use crate::manifest::parse_str;

Expand Down
2 changes: 1 addition & 1 deletion codegen-v2/src/tests/samples/class.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ properties:
variant: bool
is_constant: true
is_nullable: false
is_pointer: true
is_pointer: true
2 changes: 1 addition & 1 deletion codegen-v2/src/tests/samples/non-associated.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ properties:
variant: bool
is_constant: true
is_nullable: false
is_pointer: true
is_pointer: true
2 changes: 1 addition & 1 deletion codegen-v2/src/tests/samples/optional.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ properties:
value: SomeEnum
is_constant: true
is_nullable: true
is_pointer: true
is_pointer: true
2 changes: 1 addition & 1 deletion codegen-v2/src/tests/samples/private_class.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ properties:
variant: bool
is_constant: true
is_nullable: false
is_pointer: true
is_pointer: true
2 changes: 1 addition & 1 deletion codegen-v2/src/tests/samples/struct.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ properties:
variant: bool
is_constant: true
is_nullable: false
is_pointer: true
is_pointer: true
2 changes: 1 addition & 1 deletion swift/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: aac2324ba35cdd5631cb37618cd483887bab9cfd

COCOAPODS: 1.12.1
COCOAPODS: 1.11.3

0 comments on commit 5a74076

Please sign in to comment.