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 vtable to ExternalValue #64

Closed
wants to merge 3 commits into from
Closed

Add vtable to ExternalValue #64

wants to merge 3 commits into from

Conversation

llogiq
Copy link

@llogiq llogiq commented Jun 3, 2021

This is not finished yet, but shows the broad direction to take.

@llogiq
Copy link
Author

llogiq commented Jun 9, 2021

I now appear to have a problem because the types don't add up.

---- koto_tests::io stdout ----
thread 'koto_tests::io' panicked at 'Error while running test 'reading_a_file': File.read_to_string: Expected File instance as first argument
 --- ../../koto/tests/io.koto - 14:30
    |
 14 |     assert_eq contents, file.read_to_string()
    |                              ^^^^^^^^^^^^^^^^', src/koto/tests/koto_tests.rs:22:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- koto_tests::threads stdout ----
thread 'koto_tests::threads' panicked at 'Error while running test 'spawn_4_threads_and_join': iterator.each: Thread.join: Expected Thread instance as first argument
 --- ../../koto/tests/threads.koto - 20:19
    |
 20 |       .each |t| t.join()
    |                   ^^^^^^
 --- ../../koto/tests/threads.koto - 21:8
    |
 21 |       .to_tuple()
    |        ^^^^^^^^^^', src/koto/tests/koto_tests.rs:22:21

any pointers where to look next?

@irh
Copy link
Contributor

irh commented Jun 10, 2021

These functions are expecting a Map that contains an ExternalDataId key with the ExternalValue as the associated value.

In the File case, file_fn is a helper that wraps get_external_instance, which pulls the ExternalValue out of the Map and then downcasts it to the expected type. You'll need to adapt get_external_instance (or add a new helper) to match this approach of having methods on an ExternalValue, I guess the only thing you need to do is the downcasting?

@llogiq
Copy link
Author

llogiq commented Jun 10, 2021

Thank you, that is very helpful!

@llogiq llogiq changed the title WIP: Add vtable to ExternalValue Add vtable to ExternalValue Jun 11, 2021
@llogiq
Copy link
Author

llogiq commented Jun 11, 2021

Now this has a test of using an external value, and it actually works! 🎉

@irh
Copy link
Contributor

irh commented Jun 11, 2021

Nice, congrats! Did you see my post on #65 with an outline of the direction that I think should be taken here? I'd be curious to hear your thoughts.

@irh
Copy link
Contributor

irh commented Aug 9, 2021

Closed in favour of #73

@irh irh closed this Aug 9, 2021
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.

None yet

2 participants