core: add support for class attributes (issue-102) #425

Merged
sb10q merged 3 commits from issue-102 into master 2024-06-25 16:06:34 +08:00
Collaborator

The main changes are as follows:
Class Definition
Created new section for class attributes
Each class retains one copy of immutable attributes

Core
Added support for processing class attributes and their code generation

nac3artiq
Allowed class attributes of classes without __init__ function to be accessed by bypassing the initialization check

The main changes are as follows: **Class Definition** Created new section for class attributes Each class retains one copy of immutable attributes **Core** Added support for processing class attributes and their code generation **nac3artiq** Allowed class attributes of classes without _\_\_init\_\__ function to be accessed by bypassing the initialization check
abdul124 requested review from derppening 2024-06-19 18:18:16 +08:00
derppening requested changes 2024-06-19 18:42:46 +08:00
derppening left a comment
Collaborator

Please run the pre-commit hooks (i.e. cargo clippy and cargo fmt) on each commit so that the apply cargo fmt commit can be dropped.

Please run the pre-commit hooks (i.e. `cargo clippy` and `cargo fmt`) on each commit so that the `apply cargo fmt` commit can be dropped.
@ -1475,3 +1552,3 @@
class_fields_def.drain(..);
class_fields_def.extend(new_child_fields);
class_attribute_def.drain(..);
Collaborator

class_attribute_def.clear()

You can also change the use above for class_fields_def.

`class_attribute_def.clear()` You can also change the use above for `class_fields_def`.
derppening marked this conversation as resolved
abdul124 force-pushed issue-102 from 5bc76583ef to 45708aadda 2024-06-20 10:05:25 +08:00 Compare
Author
Collaborator

Please run the pre-commit hooks (i.e. cargo clippy and cargo fmt) on each commit so that the apply cargo fmt commit can be dropped.

Force pushed to update commit history. Also replaced .drain(..) with .clear() in nac3core/src/toplevel/composer.rs

> Please run the pre-commit hooks (i.e. `cargo clippy` and `cargo fmt`) on each commit so that the `apply cargo fmt` commit can be dropped. Force pushed to update commit history. Also replaced `.drain(..)` with `.clear()` in nac3core/src/toplevel/composer.rs
derppening reviewed 2024-06-20 11:43:15 +08:00
@ -0,0 +4,4 @@
@nac3
class XXX:
ATTR1: KernelInvariant[int32] = 2
Collaborator

Nit: Does Python use all caps in this way?

Nit: Does Python use all caps in this way?
Author
Collaborator

I was using the example given in #102, but I see your point. I will update the file and while I am at it, refactor nac3core/composer to avoid code duplication

I was using the example given in #102, but I see your point. I will update the file and while I am at it, refactor nac3core/composer to avoid code duplication
abdul124 force-pushed issue-102 from 45708aadda to 43991b150b 2024-06-21 10:04:14 +08:00 Compare
abdul124 force-pushed issue-102 from 43991b150b to ad1b4f1b9b 2024-06-21 10:07:45 +08:00 Compare
Author
Collaborator

Revised.

Revised.
Owner

@derppening OK to merge this?

@derppening OK to merge this?
Collaborator

Yes, I think this is ready to be merged.

Yes, I think this is ready to be merged.
sb10q merged commit b0b804051a into master 2024-06-25 16:06:34 +08:00
sb10q deleted branch issue-102 2024-06-25 16:06:34 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#425
No description provided.