This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 8f1119173340bf301ace2875aef7e6648d39c889
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:50:59 2026 -0600
eolian_cxx: the part accessors are defined inline
The definitions of the typed part accessors (owner.inner() answering
the part's own wrapper type) in the generated implementation header
were not inline, so under EFL_CXXPERIMENTAL any program with two
translation units including the same header got multiple definitions at
link time.
The test builds two translation units from the same generated headers
and does not link without the change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/eolian_cxx/grammar/part_implementation.hpp | 2 +-
src/tests/eolian_cxx/eolian_cxx_suite.cc | 1 +
src/tests/eolian_cxx/eolian_cxx_suite.h | 1 +
src/tests/eolian_cxx/eolian_cxx_test_parts.cc | 67 ++++++++++++++++++++++
.../eolian_cxx/eolian_cxx_test_parts_second.cc | 28 +++++++++
src/tests/eolian_cxx/meson.build | 6 ++
src/tests/eolian_cxx/parts_inner.c | 12 ++++
src/tests/eolian_cxx/parts_inner.eo | 4 ++
src/tests/eolian_cxx/parts_owner.c | 37 ++++++++++++
src/tests/eolian_cxx/parts_owner.eo | 11 ++++
10 files changed, 168 insertions(+), 1 deletion(-)
diff --git a/src/lib/eolian_cxx/grammar/part_implementation.hpp b/src/lib/eolian_cxx/grammar/part_implementation.hpp
index 2e9f91e7e5..d597876813 100644
--- a/src/lib/eolian_cxx/grammar/part_implementation.hpp
+++ b/src/lib/eolian_cxx/grammar/part_implementation.hpp
@@ -39,7 +39,7 @@ struct part_implementation_generator
if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, ctx))
return false;
- if(!as_generator("::efl::eolian::return_traits<::" << *(string << "::"))
+ if(!as_generator("inline ::efl::eolian::return_traits<::" << *(string << "::"))
.generate(sink, part.klass.namespaces, add_lower_case_context(ctx)))
return false;
// FIXME: part_def can't depend on klass_def so C type is not known :(
diff --git a/src/tests/eolian_cxx/eolian_cxx_suite.cc b/src/tests/eolian_cxx/eolian_cxx_suite.cc
index ad850e6e04..cbf2e6fb74 100644
--- a/src/tests/eolian_cxx/eolian_cxx_suite.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_suite.cc
@@ -23,6 +23,7 @@
static const Efl_Test_Case etc[] = {
{ "Eolian-Cxx Parsing", eolian_cxx_test_parse },
{ "Eolian-Cxx Wrapper", eolian_cxx_test_wrapper },
+ { "Eolian-Cxx Parts", eolian_cxx_test_parts },
{ "Eolian-Cxx Generation", eolian_cxx_test_generate },
{ "Eolian-Cxx Address_of", eolian_cxx_test_address_of },
{ "Eolian-Cxx Inheritance", eolian_cxx_test_inheritance },
diff --git a/src/tests/eolian_cxx/eolian_cxx_suite.h b/src/tests/eolian_cxx/eolian_cxx_suite.h
index 943b2a621f..ce603da416 100644
--- a/src/tests/eolian_cxx/eolian_cxx_suite.h
+++ b/src/tests/eolian_cxx/eolian_cxx_suite.h
@@ -5,6 +5,7 @@
#include "../efl_check.h"
void eolian_cxx_test_parse(TCase* tc);
void eolian_cxx_test_wrapper(TCase* tc);
+void eolian_cxx_test_parts(TCase* tc);
void eolian_cxx_test_generate(TCase* tc);
void eolian_cxx_test_address_of(TCase* tc);
void eolian_cxx_test_inheritance(TCase* tc);
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_parts.cc b/src/tests/eolian_cxx/eolian_cxx_test_parts.cc
new file mode 100644
index 0000000000..e5eba6a005
--- /dev/null
+++ b/src/tests/eolian_cxx/eolian_cxx_test_parts.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2026 by its authors. See AUTHORS.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* The typed part accessors are defined in the generated implementation header,
+ * which two translation units of this suite include: they have to be inline or
+ * the suite does not link. */
+#define EFL_CXXPERIMENTAL
+
+#define EFL_PART_PROTECTED
+#include <Eo.h>
+#include <Eina.h>
+#include <Efl.h>
+#include <Ecore.h>
+
+#define EOLIANCXXTEST_API
+#define EOLIANCXXTEST_API_WEAK
+
+#include <parts_inner.eo.hh>
+#include <parts_inner.eo.impl.hh>
+#include <parts_owner.eo.hh>
+#include <parts_owner.eo.impl.hh>
+
+#include "eolian_cxx_suite.h"
+
+/* Defined in eolian_cxx_test_parts_second.cc, which includes the same headers. */
+bool eolian_cxx_test_parts_second(::parts::Owner& owner);
+
+EFL_START_TEST(eolian_cxx_test_parts_typed_accessor)
+{
+ efl::eo::eo_init init;
+
+ ::parts::Owner owner(efl::eo::instantiate);
+ fail_if(owner._eo_ptr() == nullptr);
+
+ {
+ /* The accessor answers with the part's own wrapper type. */
+ ::parts::Inner inner = owner.inner();
+ fail_if(inner._eo_ptr() == nullptr);
+ fail_if(!efl_isa(inner._eo_ptr(), PARTS_INNER_CLASS));
+ }
+
+ /* The same accessor, from the other translation unit. */
+ fail_if(!eolian_cxx_test_parts_second(owner));
+}
+EFL_END_TEST
+
+void
+eolian_cxx_test_parts(TCase* tc)
+{
+ tcase_add_test(tc, eolian_cxx_test_parts_typed_accessor);
+}
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_parts_second.cc b/src/tests/eolian_cxx/eolian_cxx_test_parts_second.cc
new file mode 100644
index 0000000000..9fa5113aa8
--- /dev/null
+++ b/src/tests/eolian_cxx/eolian_cxx_test_parts_second.cc
@@ -0,0 +1,28 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define EFL_CXXPERIMENTAL
+
+#define EFL_PART_PROTECTED
+#include <Eo.h>
+#include <Eina.h>
+#include <Efl.h>
+#include <Ecore.h>
+
+#define EOLIANCXXTEST_API
+#define EOLIANCXXTEST_API_WEAK
+
+#include <parts_inner.eo.hh>
+#include <parts_inner.eo.impl.hh>
+#include <parts_owner.eo.hh>
+#include <parts_owner.eo.impl.hh>
+
+/* A second translation unit including the generated implementation headers:
+ * with non-inline part accessors the suite does not link. */
+bool
+eolian_cxx_test_parts_second(::parts::Owner& owner)
+{
+ ::parts::Inner inner = owner.inner();
+ return inner._eo_ptr() && efl_isa(inner._eo_ptr(), PARTS_INNER_CLASS);
+}
diff --git a/src/tests/eolian_cxx/meson.build b/src/tests/eolian_cxx/meson.build
index b4c5434323..96bbfacdd6 100644
--- a/src/tests/eolian_cxx/meson.build
+++ b/src/tests/eolian_cxx/meson.build
@@ -9,6 +9,10 @@ eolian_cxx_suite_src = files([
'eolian_cxx_test_binding.cc',
'eolian_cxx_test_address_of.cc',
'eolian_cxx_test_wrapper.cc',
+ 'eolian_cxx_test_parts.cc',
+ 'eolian_cxx_test_parts_second.cc',
+ 'parts_inner.c',
+ 'parts_owner.c',
'simple.c',
'name_name.c',
'name_name_cxx.cc',
@@ -38,6 +42,8 @@ pub_eo_files = [
'generic_interface.eo',
'name1_name2_type_generation.eo',
'name_name.eo',
+ 'parts_inner.eo',
+ 'parts_owner.eo',
'ns_name.eo',
'ns_name_other.eo',
'simple.eo'
diff --git a/src/tests/eolian_cxx/parts_inner.c b/src/tests/eolian_cxx/parts_inner.c
new file mode 100644
index 0000000000..b8e9090497
--- /dev/null
+++ b/src/tests/eolian_cxx/parts_inner.c
@@ -0,0 +1,12 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Eo.h>
+
+#define EOLIANCXXTEST_API
+#define EOLIANCXXTEST_API_WEAK
+
+#include "parts_inner.eo.h"
+
+#include "parts_inner.eo.c"
diff --git a/src/tests/eolian_cxx/parts_inner.eo b/src/tests/eolian_cxx/parts_inner.eo
new file mode 100644
index 0000000000..ce8744709f
--- /dev/null
+++ b/src/tests/eolian_cxx/parts_inner.eo
@@ -0,0 +1,4 @@
+class Parts.Inner extends Efl.Object {
+ [[A part proxy for the C++ part accessor test. @since 1.66]]
+ data: null;
+}
diff --git a/src/tests/eolian_cxx/parts_owner.c b/src/tests/eolian_cxx/parts_owner.c
new file mode 100644
index 0000000000..2920d7d52e
--- /dev/null
+++ b/src/tests/eolian_cxx/parts_owner.c
@@ -0,0 +1,37 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+
+#define EFL_PART_PROTECTED
+#include <Efl.h>
+
+#define EOLIANCXXTEST_API
+#define EOLIANCXXTEST_API_WEAK
+
+#include "parts_inner.eo.h"
+#include "parts_owner.eo.h"
+
+struct _Parts_Owner_Data
+{
+ int unused;
+};
+typedef struct _Parts_Owner_Data Parts_Owner_Data;
+
+#define MY_CLASS PARTS_OWNER_CLASS
+
+static Eo *_parts_owner_efl_object_constructor(Eo *obj, Parts_Owner_Data *pd EINA_UNUSED)
+{
+ return efl_constructor(efl_super(obj, MY_CLASS));
+}
+
+static Eo *_parts_owner_efl_part_part_get(const Eo *obj, Parts_Owner_Data *pd EINA_UNUSED, const char *name)
+{
+ if (!name || strcmp(name, "inner")) return NULL;
+ /* Not parented to the owner: the C++ accessor adopts what it gets, so the
+ * wrapper must own the only reference, and frees it when it goes. */
+ return efl_add_ref(PARTS_INNER_CLASS, NULL);
+}
+
+#include "parts_owner.eo.c"
diff --git a/src/tests/eolian_cxx/parts_owner.eo b/src/tests/eolian_cxx/parts_owner.eo
new file mode 100644
index 0000000000..c0e2fba52c
--- /dev/null
+++ b/src/tests/eolian_cxx/parts_owner.eo
@@ -0,0 +1,11 @@
+class Parts.Owner extends Efl.Object implements Efl.Part {
+ [[An object that declares a part, for the C++ part accessor test. @since 1.66]]
+ data: Parts_Owner_Data;
+ parts {
+ inner: Parts.Inner; [[The only part.]]
+ }
+ implements {
+ Efl.Object.constructor;
+ Efl.Part.part_get;
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.