Commit graph

89 commits

Author SHA1 Message Date
2c99251b27 Add support for returning a pre-existing foreign object from a foreign method
This is potentially subject to change in the near
future. This commit adds support for returning
an instance (currently wrapped in ForeignObject<>)
of a foreign object that is already instantiated.
The object returned this way simply gets selected
by handle into slot 0 of C Wren.
Conversely, returning just a naked object causes
wrenpp to make a Wren-accessible copy of it.
2024-05-28 08:25:19 +02:00
d2a1187ad5 Some fixes
Build fix in foreign_object.hpp
Wrong assert when a module contains
more than one class, dynafunc_maker.cpp
2024-05-26 20:36:31 +02:00
05298b6111 Add support for object parameters to Wren calls 2024-05-25 01:47:51 +02:00
0636fd2249 Buildfix but only tested on amd64 2024-05-24 12:41:39 +02:00
6ad20e5051 Call meson.override_dependency() 2022-06-06 16:10:25 +02:00
576452a8ac Build fix for aarch64
But there is a bug in meson currently that makes it so that
neon is never detected on aarch64 so the generic crc32
implementation is always chosen. Not a big deal right now.
It will fix itself once meson fixes their bug.
2022-06-03 20:41:00 +02:00
730f4f45ef Tidy up hardware crc32 implementations 2022-06-03 15:54:45 +02:00
9566553856 Extract crc32 code into a separate static lib
Following what's been suggested on IRC libera.chat #mesonbuild,
this is so that the -march=generic+crc option only applies to
the code it should apply to and not to the entire code base.
2022-06-03 11:25:48 +02:00
d71229fc07 Create meson build file in src 2022-06-03 11:07:35 +02:00
f4b3600ee5 Possible build fix for aarch64 2022-06-03 10:52:26 +02:00
b3ecb69ec0 Keeping crc around, but cleaning up a bit
Crc is used as an optimisation for operator==, which is legit.
Either way, the struct's size would still be 16 even without
the crc (the variable would just became an always 0 "reserved").
Crc's use is limited to here anyways, so for now it's not
harming anyone.
2022-06-03 10:27:28 +02:00
09530e15c9 Use a better ID for identifying classes.
Upon testing (and reading), getting the address of a static
is safe even across .so boundaries. Moreover it doesn't incur
into the risk of collisions, unlike hashes, and also works
with different classes with the same name (for example from
two different unnamed namespaces). At this point the crc32
stuff is pretty much redundant, I'll try to remove it next.
2022-06-03 09:39:43 +02:00
616381516b New helper function for abort_fiber + message 2022-05-25 11:56:53 +02:00
b0422b73d6 Remove dummy 0, store the crc32 there 2022-05-24 16:38:34 +02:00
e8db08931a Add equality operators 2022-05-24 16:07:16 +02:00
e97c7bad10 Improve runtime crc32 code
Only check for sse4.2 once and store the best
crc32 implementation available into a static
function pointer.
Also other minor improvements.
2022-05-24 13:39:45 +02:00
e200288d06 Build fix, runtime_crc32c() should be in namespace detail 2022-05-24 13:21:56 +02:00
6a47be250f Replace crc32 implementation
This is a properly constexpr version for modern c++. Also
added a fast runtime version of it.
2022-05-23 04:19:54 +02:00
addb48822f Refactor so that make_method_bindable also accepts free functions now 2022-05-19 19:22:20 +02:00
1fa6d62f17 Add support for registering foreign methods that return foreign objects
Still a bit work in progress but functioning
2022-05-18 18:48:18 +02:00
41692eb0bc Fix for aarch64 2022-05-17 01:33:51 +02:00
eadd25b827 Foreign function callbacks now receive a ModuleAndName parameter too.
This commit breaks the ARM64 version, I will fix it next.

Lots going on here. DynafuncMaker got updated to store strings
to back the ModuleAndName objects that get hardcoded in the
assembly glue function.
ModuleAndName is not a typedef to a tuple anymore, because I
discovered that tuples suck. They get always pushed on the stack
when passed as parameter, instead the new implementation gets
passed into 2 registers being it a standard layout type.

dhandy::bt::string got updated so it can be used as a literal
value for non-type template parameters, which allowed for a
really easy to use `wren::MN<>` helper. Code now fully requires
c++20.
2022-05-17 01:06:36 +02:00
ce7be396d2 Improve error reporting 2022-05-15 20:17:07 +02:00
692393285d Fix memory leaks 2022-05-15 19:19:56 +02:00
abbb3b3818 Clean up include directory structure 2022-05-15 15:41:00 +02:00
9921e59a6b Add support for foreign constructor overload
Make vm_fun.hpp fun again by moving setters/getters
into a separate header.
Add new make_overloaded_foreign_class(), but code is still
untested and it's a work in progress at this point.
Interface will change.
2022-05-15 15:35:25 +02:00
036dd57524 Allow chaining calls to add_class_maker() 2022-05-14 18:06:35 +02:00
258237cbf3 Implement ClassManager
Very similar to CallbackManager in its functioning.
2022-05-14 17:06:25 +02:00
74670f4683 Extract consecutive strings logic into a separate class
This is going to be also used in the upcoming ClassManager class.
It also makes FullSignatureOwning less cluttered.
2022-05-14 16:20:50 +02:00
d985ebc417 Fix assert due to typo 2022-05-12 23:53:15 +02:00
c2089568f3 Bugfixes and improvements, simplify examples 2022-04-29 18:35:46 +02:00
fa0183a3bf Implement CallbackManager
With it users don't have to provide a foreign_method_fn()
function anymore, it's become optional.
2022-04-29 18:16:57 +02:00
5d6575f328 Add make_foreign_object() overload
It's only available when users define WRENPP_WITH_NAME_GUESSING
and it automatically retrieves the class name of T using
new code in guess_class_name.hpp. Only tested on gcc so far.
Microsoft compiler doesn't seem to understand consteval keyword.
2022-04-29 12:34:01 +02:00
10e3c9adac Correctly manage the case of string=nil if wreng_string_t is string_view 2022-04-29 12:34:01 +02:00
31ba3af348 Update copyright year 2022-04-28 22:56:11 +02:00
6f4b0ce094 Pass string_view instead of const char* to callback functions 2022-04-28 22:55:22 +02:00
f84234cede Remove redundant const 2022-04-25 01:30:22 +02:00
30746aec19 Revert "Add ret to avoid data being "executed""
This reverts commit 1713a22ef4.
2022-04-25 00:41:02 +02:00
1713a22ef4 Add ret to avoid data being "executed" 2022-04-24 22:07:39 +02:00
e157607df6 Update copyright year on recently modified files 2022-04-24 03:43:19 +02:00
7a821fcd2c Add support for aarch64 2022-04-24 03:41:14 +02:00
1a01a016f2 Remove unnecessary function 2022-04-22 22:38:19 +02:00
f749b7fb18 call() will fail earlier when object for call doesn't exist 2022-04-22 22:04:09 +02:00
0255edb8be Update wren to latest and fix build 2022-04-22 22:02:59 +02:00
839dbccfb1 Assert that there is at least one slot allocated 2022-04-22 10:36:35 +02:00
cfc8bb89f8 Add convenience variable_ensure_slot 2021-02-12 14:43:25 +01:00
52d9210400 Include vector size in mem usage count 2021-02-12 14:43:25 +01:00
dc10c38a3f Add reset() method 2021-02-12 14:43:25 +01:00
719a57d3e8 Add lib name to config header 2021-02-10 23:14:13 +01:00
3c318d6771 Add a very simple test program
Not quite a unit test, it looks more like an example
but still something.
2021-02-02 14:04:27 +01:00