Skip to content

Commit b399a9b

Browse files
committed
Work in progress.
1 parent 4d21a73 commit b399a9b

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

source/loaders/c_loader/source/c_loader_impl.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ class c_loader_pointer_type : public c_loader_type_impl
530530
// TODO: This may be too tricky to implement because it is impossible to reconstruct the pointer from the type
531531
// easily, as C does not mantain the true memory layout, pointers can be arrays or single elements and we cannot know
532532
// We should review this carefully
533+
(void)arg_ptr;
533534
#if 0
534535
CXType type_iterator = cx_type;
535536
value prev_value = value_create_ptr(NULL);
@@ -743,7 +744,7 @@ function_return function_c_interface_invoke(function func, function_impl impl, f
743744
for (size_t args_count = 0; args_count < args_size; ++args_count)
744745
{
745746
type t = signature_get_type(s, args_count);
746-
type_impl impl_type = type_derived(t);
747+
/* type_impl impl_type = type_derived(t); */
747748
type_id id = type_index(t);
748749
type_id value_id = value_type_id((value)args[args_count]);
749750

@@ -769,7 +770,10 @@ function_return function_c_interface_invoke(function func, function_impl impl, f
769770

770771
closures.push_back(closure);
771772
}
773+
#if 0
772774
else if (id == TYPE_STRING || (id == TYPE_PTR && impl_type != nullptr))
775+
#endif
776+
else if (id == TYPE_STRING)
773777
{
774778
/* String requires to be pointer to a string and
775779
Pointer requires to be pointer to pointer */
@@ -832,7 +836,7 @@ function_return function_c_interface_invoke(function func, function_impl impl, f
832836
for (size_t args_count = 0; args_count < args_size; ++args_count)
833837
{
834838
type t = signature_get_type(s, args_count);
835-
type_impl impl_type = type_derived(t);
839+
/* type_impl impl_type = type_derived(t); */
836840
type_id id = type_index(t);
837841

838842
/* This is very tricky, if the type was a pointer to pointer, if it
@@ -846,21 +850,24 @@ function_return function_c_interface_invoke(function func, function_impl impl, f
846850
highly unsafe if we mix types because we will use the type info of the
847851
underlaying type in order to recreate it, in this example, a string
848852
*/
853+
#if 0
849854
if (id == TYPE_PTR && impl_type != nullptr)
850855
{
851856
// TODO: This may be too tricky to implement because it is impossible to reconstruct the pointer from the type
852857
// easily, as C does not mantain the true memory layout, pointers can be arrays or single elements and we cannot know
853858
// We should review this carefully
854-
#if 0
859+
#if 0
855860
/* Reconstruct the pointer value from the type info */
856861
c_loader_pointer_type *pointer_type = static_cast<c_loader_pointer_type *>(impl_type);
857862

858863
void *arg_value = pointer_type->to_value(value_to_ptr(c_function->values[args_count]));
859-
#endif
864+
#endif
860865

861866
value_type_destroy(c_function->values[args_count]);
862867
}
863-
else if (id == TYPE_STRING)
868+
else
869+
#endif
870+
if (id == TYPE_STRING)
864871
{
865872
/* Clear the pointer to string allocated before */
866873
value_type_destroy(c_function->values[args_count]);

source/scripts/c/loadtest/source/loadtest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "loadtest.h"
2+
#include <iostream>
23
#include <vector>
34

45
long call_cpp_func(void)
@@ -23,6 +24,9 @@ int pair_list_init(pair_list **t)
2324
(*t)->pairs[i].d = (double)(((double)i) * 1.0);
2425
}
2526

27+
std::cout << "pair_list_init: " << t << std::endl;
28+
std::cout << "pair_list_init: *(" << *t << ")" << std::endl;
29+
2630
return 0;
2731
}
2832

source/scripts/c/loadtest/source/loadtest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
extern "C" {
1212
#endif
1313

14-
#include <cstdint>
14+
#include <stdint.h>
1515

1616
typedef struct
1717
{

source/tests/metacall_c_lib_test/source/metacall_c_lib_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ TEST_F(metacall_c_lib_test, DefaultConstructor)
5151

5252
ret = metacallv("pair_list_init", args_init);
5353

54+
std::cout << "args_init: " << args_init[0] << std::endl;
55+
std::cout << "args_init: *(" << pair_list << ")" << std::endl;
56+
5457
EXPECT_NE((void *)NULL, (void *)ret);
5558

5659
EXPECT_EQ((enum metacall_value_id)metacall_value_id(ret), (enum metacall_value_id)METACALL_INT);

0 commit comments

Comments
 (0)