Skip to content

Instantly share code, notes, and snippets.

View vinivendra's full-sized avatar

Vinicius Vendramini vinivendra

View GitHub Profile
@vinivendra
vinivendra / Package.swift
Created December 31, 2020 23:08
SourceKitten example
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Example",
products: [
.executable(name: "example", targets: ["Example"])
],
/////////////////////////////////////////////////////////////////////////////////
// 1: Abra o GitPod
// https://gitpod.io/#https://github.com/vinivendra/gryphon
// 2: Abra o arquivo test.swift, apague o conteúdo dele e cole este comentário:
// // gryphon output: test.kt
// 3: Rode o Gryphon com o seguinte comando:
// ./.build/debug/gryphon test.swift -emit-swiftAST -emit-rawAST -emit-AST -emit-kotlin
@vinivendra
vinivendra / kotlinMeetupSP.swift
Last active June 25, 2020 21:34
Links and code for the Gryphon presentation at Kotlin Meetup SP (June 2020)
// Entre no site abaixo para abrir o GitPod (talvez precise fazer login)
// https://gitpod.io/#https://github.com/vinivendra/Gryphon/
//
// Quando abrir, rode o comando abaixo para desligar alguns avisos do Java
// $ unset JAVA_TOOL_OPTIONS
//
//
//
// Durante os exemplos, use os seguintes comandos para:
// - Traduzir um arquivo:
@vinivendra
vinivendra / Calculator.kt
Last active May 27, 2019 21:08
Kotlin 2 survey snippet
// The full version of this implementation is at bit.ly/Kotlin2Survey
package com.example.kotlincalculator
/**
* Type used to represent error value thrown for invalid Calculator input.
* */
sealed class CalculatorError(override val message: String): Exception(message) {
class NilInput(override val message: String): CalculatorError(message)
// ...
@vinivendra
vinivendra / Calculator.kt
Last active May 27, 2019 21:08
Kotlin 1 survey snippet
// The full version of this implementation is at bit.ly/Kotlin1Survey
package com.example.kotlingryphoncalculator
/// Type used to represent error value thrown for invalid Calculator input.
public sealed class CalculatorError: Exception() {
class NilInput: CalculatorError()
// ...
}
@vinivendra
vinivendra / Calculator.swift
Last active May 27, 2019 21:07
Swift 2 survey snippet
// The full version of this implementation is at bit.ly/Swift2Survey
/*
Implements the logic for a calculator. Performs the addition, substraction,
division, and multiplication operations.
*/
import Foundation
open class Calculator {
@vinivendra
vinivendra / Calculator.swift
Last active May 27, 2019 21:07
Swift 1 survey snippet
// The full version of this implementation is at bit.ly/Swift1Survey
// declaration: package com.example.kotlingryphoncalculator
import Foundation
/// Type used to represent error value thrown for invalid Calculator input.
public enum CalculatorError: Error {
case nilInput
// ...
@vinivendra
vinivendra / Calculator.swift
Last active May 27, 2019 20:04
Survey - Swift 2
/*
Implements the logic for a calculator. Performs the addition, substraction,
division, and multiplication operations.
*/
import Foundation
open class Calculator {
// MARK: - Properties
@vinivendra
vinivendra / Calculator.h
Last active May 21, 2019 21:13
Survey - Objective-C 1
#include "J2ObjC_header.h"
#pragma push_macro("INCLUDE_ALL_ComExampleJavacalculatorCalculator")
#ifdef RESTRICT_ComExampleJavacalculatorCalculator
#define INCLUDE_ALL_ComExampleJavacalculatorCalculator 0
#else
#define INCLUDE_ALL_ComExampleJavacalculatorCalculator 1
#endif
#undef RESTRICT_ComExampleJavacalculatorCalculator
@vinivendra
vinivendra / Calculator.swift
Last active May 27, 2019 19:56
Survey - Swift 1
// declaration: package com.example.kotlingryphoncalculator
import Foundation
/// Type used to represent error value thrown for invalid Calculator input.
public enum CalculatorError: Error {
case invalidCharater
case multipleCharacters
case nilInput