-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix js:Function, add support for js motype module loading, LazyPointer
- Loading branch information
Showing
9 changed files
with
152 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import { type Class } from "../utils/global_types.ts"; | |
import { Conjunction, Disjunction, Logical } from "../types/logic.ts"; | ||
import { client_type } from "../utils/constants.ts"; | ||
import { Assertion } from "../types/assertion.ts"; | ||
import { getCallerInfo } from "../utils/caller_metadata.ts"; | ||
|
||
const { Reflect: MetadataReflect } = client_type == 'deno' ? await import("https://deno.land/x/[email protected]/mod.ts") : {Reflect}; | ||
|
||
|
@@ -417,7 +418,17 @@ export class Decorators { | |
else if (params[0] instanceof Type) type = params[0]; | ||
else if (original_class[METADATA]?.[Decorators.FORCE_TYPE]?.constructor) type = original_class[METADATA]?.[Decorators.FORCE_TYPE]?.constructor | ||
else type = Type.get("ext", original_class.name); | ||
|
||
|
||
if (client_type == "deno" && type.namespace !== "std") { | ||
const callerFile = getCallerInfo()?.[2]?.file; | ||
if (!callerFile) { | ||
logger.error("Could not determine JS module URL for type '" + type + "'") | ||
} | ||
else { | ||
type.jsTypeDefModule = callerFile; | ||
} | ||
} | ||
|
||
// return new templated class | ||
return createTemplateClass(original_class, type); | ||
} | ||
|
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,18 @@ | ||
import { Pointer, MinimalJSRef } from "./pointers.ts"; | ||
|
||
export class LazyPointer<T> { | ||
constructor(public id: string) {} | ||
|
||
toString() { | ||
return "Unresolved Pointer ($" + this.id + ")" | ||
} | ||
|
||
onLoad(callback:(val:MinimalJSRef<T>)=>void) { | ||
Pointer.onPointerForIdAdded(this.id, p => callback(Pointer.collapseValue(p) as MinimalJSRef<T>)) | ||
} | ||
|
||
static withVal(val:any, callback:(val:MinimalJSRef<any>)=>void) { | ||
if (val instanceof LazyPointer) val.onLoad(callback); | ||
else callback(val); | ||
} | ||
} |
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