-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support awaiting JS
Promise
in Kotlin and Swift (#355)
* feat: Support passing `Promise` to Kotlin * feat: Add `onResolvedListener` * feat: Add `.then`, `.catch` and `.await` to Promise! * feat: Use `await` * feat: Use `Throwable` instead of `String` for error on Android * Update Promise.kt * chore: Remove unused `reject(string)` function now * Update Promise.hpp * Update Promise.hpp * feat: Implement `awaitPromise(..)` on iOS * feat: Add `RuntimeError` and `.toCpp` to Swift * fix: Fix duplicate symbol in `RuntimeError` * feat: Add `ErrorType` * feat: Add `const&` funcs to `Promise` for Swift * feat: Add `dependencies` to SwiftCxxBridge * fix: `error` type * feat: Add `RuntimeError.from(std.exception)` * feat: Add `getFunctionCopy()` to `SwiftClosure` * fix: Account for `Promise<void>` resolver * fix: Fix `UnsafeMutableRawPointer` being nullable (wrong type) * nitrogen * clean * Update HybridTestObjectSwiftKotlinSpecCxx.swift * feat: Add actual Promise listeners!! * fix: Add `addOnResolvedListenerCopy` func for some cases * chore: Format * fix: Make `getFunctionCopy()` const * feat: Support `Promise<void>` from JS! * feat: Add `awaitAndGet` and `awaitAndGetComplex` promise tests * feat: Test both new functions * Slap a good ol' `mutex` on `Promise` * fix: Fix `Promise<void>` never resolving because args count was `1` (`undefined`) * fix: Fix Android wrong return type * Update HybridTestObjectCpp.cpp
- Loading branch information
Showing
34 changed files
with
1,005 additions
and
69 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { Language } from '../../getPlatformSpecs.js' | ||
import { type SourceFile, type SourceImport } from '../SourceFile.js' | ||
import type { Type, TypeKind } from './Type.js' | ||
|
||
export class ErrorType implements Type { | ||
constructor() {} | ||
|
||
get canBePassedByReference(): boolean { | ||
// It's a exception<..>, pass by reference. | ||
return true | ||
} | ||
get kind(): TypeKind { | ||
return 'error' | ||
} | ||
|
||
getCode(language: Language): string { | ||
switch (language) { | ||
case 'c++': | ||
return `std::exception` | ||
case 'swift': | ||
return `std.exception` | ||
case 'kotlin': | ||
return `Throwable` | ||
default: | ||
throw new Error( | ||
`Language ${language} is not yet supported for ThrowableType!` | ||
) | ||
} | ||
} | ||
getExtraFiles(): SourceFile[] { | ||
return [] | ||
} | ||
getRequiredImports(): SourceImport[] { | ||
return [ | ||
{ | ||
language: 'c++', | ||
name: 'exception', | ||
space: 'system', | ||
}, | ||
] | ||
} | ||
} |
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
Oops, something went wrong.