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

[DRAFT] Scoreboards: Canonical implementation #85

Closed
wants to merge 8 commits into from

Conversation

ninovanhooff
Copy link
Collaborator

An alternative to #82.

In #82 the data returned from the playdate API is mapped to plain Nim objects, after which the C struct is free'd immediately.

The approach in this PR is more in line with the other APIs that we already offer. It wraps the c-struct and registers a destroy function to free it when the wrapper goes out of scope.
The procs for value, rank and player are unsafe to use. Users should first check whether score is nil before use.

I'm in favor of abandoning this one and continuing with #82, but I'm open to completing this one if both @Nycto and @samdze prefer it

@ninovanhooff ninovanhooff changed the title Scoreboards: Canonical implementation [DRAFT] Scoreboards: Canonical implementation Oct 22, 2024
@ninovanhooff
Copy link
Collaborator Author

ninovanhooff commented Oct 23, 2024

How to convert an SDKArray to a seq?

Couldn't quite figure out how to do it based on usages in sprite.nim, since userdata is used there.

image

In the debugger we can see that the Raw c-type (this.resource) has the correct data.

Our cArray object has the correct length, but the pointers seem invalid

var i = 0
for scr in cArray:
result[i] = PDScore(resource: scr)
i *= 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No clue why this is *= and not +=. Copied from sprite.nim

@ninovanhooff ninovanhooff requested a review from samdze October 23, 2024 21:27
@ninovanhooff
Copy link
Collaborator Author

I propose to abandon this in favor of #82

@Nycto
Copy link
Collaborator

Nycto commented Oct 24, 2024

I propose to abandon this in favor of #82

I'm fine with that.

@ninovanhooff ninovanhooff deleted the scoreboards-raw branch October 24, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants