Skip to content

Commit c9f699d

Browse files
committed
Ruby loader classes almost working.
1 parent 2ff6bc4 commit c9f699d

File tree

22 files changed

+399
-166
lines changed

22 files changed

+399
-166
lines changed

source/loader/include/loader/loader_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ LOADER_API loader_impl loader_impl_create(const char *path, const loader_naming_
4242

4343
LOADER_API loader_impl_data loader_impl_get(loader_impl impl);
4444

45+
LOADER_API value loader_impl_get_value(loader_impl impl, const char *name);
46+
4547
LOADER_API loader_impl_interface loader_impl_symbol(loader_impl impl);
4648

4749
LOADER_API loader_naming_tag *loader_impl_tag(loader_impl impl);

source/loader/source/loader.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,7 @@ int loader_get_cb_iterate(set s, set_key key, set_value val, set_cb_iterate_args
598598

599599
loader_get_iterator_args get_args = args;
600600

601-
context ctx = loader_impl_context(impl);
602-
603-
scope sp = context_scope(ctx);
604-
605-
get_args->obj = scope_get(sp, get_args->name);
601+
get_args->obj = loader_impl_get_value(impl, get_args->name);
606602

607603
if (get_args->obj != NULL)
608604
{

source/loader/source/loader_impl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,13 @@ loader_impl_data loader_impl_get(loader_impl impl)
453453
return NULL;
454454
}
455455

456+
value loader_impl_get_value(loader_impl impl, const char *name)
457+
{
458+
context ctx = loader_impl_context(impl);
459+
scope sp = context_scope(ctx);
460+
return scope_get(sp, name);
461+
}
462+
456463
loader_impl_interface loader_impl_symbol(loader_impl impl)
457464
{
458465
if (impl != NULL && impl->singleton != NULL)

source/loaders/java_loader/source/java_loader_impl.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,11 @@ int java_object_interface_create(object obj, object_impl impl)
433433
return 0;
434434
}
435435

436-
value java_object_interface_get(object obj, object_impl impl, attribute attr)
436+
value java_object_interface_get(object obj, object_impl impl, union accessor_type *accessor)
437437
{
438438
(void)obj;
439439

440+
attribute attr = accessor->attr;
440441
const char *key = (const char *)attribute_name(attr);
441442
type fieldType = (type)attribute_type(attr);
442443

@@ -628,11 +629,11 @@ value java_object_interface_get(object obj, object_impl impl, attribute attr)
628629
return NULL;
629630
}
630631

631-
int java_object_interface_set(object obj, object_impl impl, attribute attr, value v)
632+
int java_object_interface_set(object obj, object_impl impl, union accessor_type *accessor, value v)
632633
{
633634
(void)obj;
634-
std::cout << "Obj Set" << std::endl;
635635

636+
attribute attr = accessor->attr;
636637
const char *key = (const char *)attribute_name(attr);
637638
type fieldType = (type)attribute_type(attr);
638639

@@ -955,7 +956,7 @@ object java_class_interface_constructor(klass cls, class_impl impl, const char *
955956
loader_impl_java_class java_cls = static_cast<loader_impl_java_class>(impl);
956957
loader_impl_java_object java_obj = new loader_impl_java_object_type();
957958

958-
object obj = object_create(name, java_obj, &java_object_interface_singleton, cls);
959+
object obj = object_create(name, ACCESSOR_TYPE_STATIC, java_obj, &java_object_interface_singleton, cls);
959960

960961
if (obj == NULL)
961962
return NULL;
@@ -1009,10 +1010,11 @@ object java_class_interface_constructor(klass cls, class_impl impl, const char *
10091010
return obj;
10101011
}
10111012

1012-
value java_class_interface_static_get(klass cls, class_impl impl, attribute attr)
1013+
value java_class_interface_static_get(klass cls, class_impl impl, union accessor_type *accessor)
10131014
{
10141015
(void)cls;
10151016

1017+
attribute attr = accessor->attr;
10161018
const char *key = (const char *)attribute_name(attr);
10171019
type fieldType = (type)attribute_type(attr);
10181020
loader_impl_java_class java_cls = static_cast<loader_impl_java_class>(impl);
@@ -1088,9 +1090,7 @@ value java_class_interface_static_get(klass cls, class_impl impl, attribute attr
10881090
jmethodID mid_getName = java_impl->env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
10891091
jstring name = (jstring)java_impl->env->CallObjectMethod(gotVal, mid_getName);
10901092
const char *cls_name = java_impl->env->GetStringUTFChars(name, NULL);
1091-
context ctx = loader_impl_context(java_cls->impl);
1092-
scope sp = context_scope(ctx);
1093-
value cls_val = (klass)scope_get(sp, cls_name);
1093+
value cls_val = loader_impl_get_value(java_cls->impl, cls_name);
10941094
return value_type_copy(cls_val);
10951095
}
10961096

@@ -1240,9 +1240,7 @@ value java_class_interface_static_get(klass cls, class_impl impl, attribute attr
12401240
jmethodID mid_getName = java_impl->env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
12411241
jstring name = (jstring)java_impl->env->CallObjectMethod(cur_ele, mid_getName);
12421242
const char *cls_name = java_impl->env->GetStringUTFChars(name, NULL);
1243-
context ctx = loader_impl_context(java_cls->impl);
1244-
scope sp = context_scope(ctx);
1245-
value cls_val = (klass)scope_get(sp, cls_name);
1243+
value cls_val = loader_impl_get_value(java_cls->impl, cls_name);
12461244
array_value[i] = value_type_copy(cls_val);
12471245
}
12481246

@@ -1265,10 +1263,11 @@ value java_class_interface_static_get(klass cls, class_impl impl, attribute attr
12651263
return NULL;
12661264
}
12671265

1268-
int java_class_interface_static_set(klass cls, class_impl impl, attribute attr, value v)
1266+
int java_class_interface_static_set(klass cls, class_impl impl, union accessor_type *accessor, value v)
12691267
{
12701268
(void)cls;
12711269

1270+
attribute attr = accessor->attr;
12721271
const char *key = (const char *)attribute_name(attr);
12731272
type fieldType = (type)attribute_type(attr);
12741273
loader_impl_java_class java_cls = static_cast<loader_impl_java_class>(impl);
@@ -1840,7 +1839,7 @@ int java_loader_impl_discover(loader_impl impl, loader_handle handle, context ct
18401839
java_cls->impl = impl;
18411840
java_cls->java_impl = java_impl;
18421841

1843-
klass c = class_create(cls_name, java_cls, &java_class_interface_singleton);
1842+
klass c = class_create(cls_name, ACCESSOR_TYPE_STATIC, java_cls, &java_class_interface_singleton);
18441843

18451844
jmethodID cls_field_array = java_impl->env->GetStaticMethodID(classPtr, "java_bootstrap_discover_fields", "(Ljava/lang/Class;)[Ljava/lang/reflect/Field;");
18461845
if (cls_field_array != nullptr)

source/loaders/py_loader/source/py_loader_impl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,3 +3823,4 @@ int py_loader_impl_destroy(loader_impl impl)
38233823

38243824
return result;
38253825
}
3826+

0 commit comments

Comments
 (0)