-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix calling get_attribute_names
on committed datatype
#84
Changes from 4 commits
792da15
edf3cb8
9745d0e
717efad
be0920e
a97e5f3
327f6c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -504,6 +504,8 @@ enum OBJECT_TYPE { | |
REGION_REFERENCE = 'RegionReference', | ||
} | ||
|
||
export type getReturnTypes = Dataset | Group | BrokenSoftLink | ExternalLink | Datatype | Reference | RegionReference; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the term There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used |
||
|
||
export class BrokenSoftLink { | ||
// only used for broken links... | ||
target: string; | ||
|
@@ -523,20 +525,6 @@ export class ExternalLink { | |
} | ||
} | ||
|
||
export class Datatype { | ||
file_id: bigint; | ||
path: string; | ||
type: OBJECT_TYPE = OBJECT_TYPE.DATATYPE | ||
constructor(file_id: bigint, path: string) { | ||
this.file_id = file_id; | ||
this.path = path; | ||
} | ||
|
||
get metadata() { | ||
return Module.get_datatype_metadata(this.file_id, this.path); | ||
} | ||
} | ||
|
||
export class Reference { | ||
ref_data: Uint8Array; | ||
constructor(ref_data: Uint8Array) { | ||
|
@@ -677,14 +665,27 @@ abstract class HasAttrs { | |
return new Reference(ref_data); | ||
} | ||
|
||
dereference(ref: Reference | RegionReference) { | ||
dereference(ref: Reference | RegionReference): DatasetRegion | getReturnTypes | null { | ||
const is_region = (ref instanceof RegionReference); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be cleaner to override this method in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const name = Module.get_referenced_name(this.file_id, ref.ref_data, !is_region); | ||
const target = this.root.get(name); | ||
return (is_region) ? new DatasetRegion(target as Dataset, ref) : target; | ||
} | ||
} | ||
|
||
export class Datatype extends HasAttrs { | ||
constructor(file_id: bigint, path: string) { | ||
super(); | ||
this.file_id = file_id; | ||
this.path = path; | ||
this.type = OBJECT_TYPE.DATATYPE; | ||
} | ||
|
||
get metadata() { | ||
return Module.get_datatype_metadata(this.file_id, this.path); | ||
} | ||
} | ||
|
||
export class Group extends HasAttrs { | ||
constructor(file_id: bigint, path: string) { | ||
super(); | ||
|
@@ -723,7 +724,7 @@ export class Group extends HasAttrs { | |
return Module.get_external_link(this.file_id, obj_path); | ||
} | ||
|
||
get(obj_name: string) { | ||
get(obj_name: string): getReturnTypes | null { | ||
let fullpath = (/^\//.test(obj_name)) ? obj_name : this.path + "/" + obj_name; | ||
fullpath = normalizePath(fullpath); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a tuple should work and be more accurate:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is generated by the typescript compiler directly, not by me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, because you changed the return type of
Group#get
. I think we can "fix" it by defining the return type explicitly onGroup#items
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done