Skip to content
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

Add support for Class and Object on top of Properties. #3489

Merged
merged 1 commit into from Aug 17, 2023

Conversation

mikeurbach
Copy link
Contributor

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Sending a draft now, thought it isn't quite ready.

Type of Improvement

  • Feature (or new API)
  • API modification
  • API deprecation
  • Backend code generation
  • Performance improvement
  • Bugfix
  • Documentation or website-related
  • Dependency update
  • Internal or build-related (includes code refactoring/cleanup)

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).
  • Rebase: You will rebase the PR onto master and it will be merged with a merge commit.

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.5.x, 3.6.x, or 5.x depending on impact, API modification or big change: 6.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty large discussion topic but I am not a huge fan of the current untyped approach using dynamic. The entire purpose of Definition/Instance was to give this sort of API while maintaining type safety. I really think we should just bite the bullet and make D/I be the intended way of defining and instantiating Classes.

Now I understand that we have some use cases that require an unsafe API for just instantiating classes by name when you certainly are not going to know anything about the actual typed interface. But rather than making the normal API embrace this untyped route, I think we can just implement that particular API directly without having its untyped-ness impact the more typical user API

val inst: DynamicObject = Class.unsafeInstanceFromName("MyClassName"))

Depending on how hard it is to implement D/I for classes, we could punt on implementing it fully and just make Definition[Class] work, then use this unsafe API as the only API to instantiate an object for the short term.

core/src/main/scala/chisel3/properties/Class.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/properties/Class.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/properties/Class.scala Outdated Show resolved Hide resolved
@mikeurbach mikeurbach force-pushed the mikeurbach/properties-classes branch from 858f7ff to 95c97d8 Compare August 16, 2023 01:16
@jackkoenig jackkoenig force-pushed the mikeurbach/properties-classes branch from c27c15a to ba3478e Compare August 16, 2023 21:09
@jackkoenig jackkoenig added the Feature New feature, will be included in release notes label Aug 16, 2023
@mikeurbach mikeurbach marked this pull request as ready for review August 16, 2023 21:41
@mikeurbach mikeurbach added this to the 6.0 milestone Aug 16, 2023
Classes can only be elaborated with Definition. Instantiation via D/I is
not yet supported--current instantiation is via an unsafe "by name" API.
@mikeurbach mikeurbach force-pushed the mikeurbach/properties-classes branch from ba3478e to 7eba073 Compare August 16, 2023 23:19
@mikeurbach mikeurbach enabled auto-merge (squash) August 17, 2023 01:20
@mikeurbach mikeurbach merged commit c72d970 into main Aug 17, 2023
15 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/properties-classes branch August 17, 2023 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants