// a.ts
import { B } from "./B";
export class A {
createB(): B {
return new B();
}
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
val a = 3 | |
fun aaa() { | |
val x = object { | |
val b = 4 | |
fun bbb() { | |
println(b) // thisはobject | |
println(a) // thisはA | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CopyImageYv12(const ImageFormat & format, | |
const uint8_t * src, int src_stride, | |
uint8_t * dest, int dest_stride) | |
{ | |
CopyImageRows(format.height(), src, src_stride, dest, dest_stride, &src, &dest); | |
CopyImageRows(format.height() / 2, src, src_stride / 2, dest, dest_stride / 2, &src, &dest); | |
CopyImageRows(format.height() / 2, src, src_stride / 2, dest, dest_stride / 2, &src, &dest); | |
} | |
void CopyImageNv12(const ImageFormat & format, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace sptt { | |
template <typename F> | |
struct FuncTrait : | |
public FuncTrait<decltype(&F::operator())> {}; | |
template <typename F, typename R, typename ...Args> | |
struct FuncTrait<R (F::*)(Args...) const> : | |
public FuncTrait<R (F::*)(Args...)> {}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol A { | |
func po() | |
} | |
protocol B : A { | |
} | |
protocol Base { | |
var module: A { get } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func dump(_ p: UnsafeRawPointer, _ size: Int) { | |
let addr = unsafeBitCast(p, to: UInt64.self) | |
let p = p.bindMemory(to: UInt8.self, capacity: size) | |
for i in 0..<size { | |
if i % 8 == 0 { | |
if i != 0 { | |
print() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let str = "abcαβγあいう😀" | |
print(str.unicodeScalars.map { $0.value } | |
.map { String(format: "0x%02x", $0) } | |
.joined(separator: ", ")) | |
print(str.utf8.map { String(format: "0x%02x", $0) } | |
.joined(separator: ", ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript | |
// https://ja.wikipedia.org/wiki/UTF-8 | |
// https://ja.wikipedia.org/wiki/UTF-16 | |
export function unicodesToUtf8(array: number[]): number[] { | |
const ret: number[] = []; | |
for (let uc of array) { | |
if (uc < 0x80) { | |
ret.push(uc); | |
continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// staticメソッド制約 | |
protocol Creatable { | |
static func create() -> Self | |
} | |
// 既存の型にその制約を適用 | |
extension Int : Creatable { | |
static func create() -> Int { | |
return 3 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol PA { | |
func paStr() -> [String] | |
} | |
protocol PB { | |
func pbStr() -> String | |
} | |
protocol PX : PA, PB { | |
} |