Merge branch 'master' into devs/hermet/lottie

This commit is contained in:
Hermet Park 2019-03-27 13:46:09 +09:00
commit 39003ec344
483 changed files with 3461 additions and 2376 deletions

View File

@ -44,7 +44,8 @@ if [ "$BUILDSYSTEM" = "ninja" ] ; then
export CFLAGS="-I/usr/local/opt/openssl/include -frewrite-includes $CFLAGS"
export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
LIBFFI_VER=$(brew list --versions libffi|head -n1|cut -d' ' -f2)
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:/usr/local/Cellar/libffi/$LIBFFI_VER/lib/pkgconfig"
mkdir build && meson build -Decore-imf-loaders-disabler=scim,ibus -Dx11=false -Davahi=false -Dbindings=luajit -Deeze=false -Dsystemd=false -Dnls=false -Dcocoa=true -Demotion-loaders-disabler=gstreamer,gstreamer1,libvlc,xine
fi
else
@ -146,7 +147,8 @@ else
export CFLAGS="-I/usr/local/opt/openssl/include -frewrite-includes $CFLAGS"
export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
LIBFFI_VER=$(brew list --versions libffi|head -n1|cut -d' ' -f2)
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:/usr/local/Cellar/libffi/$LIBFFI_VER/lib/pkgconfig"
# Normal build test of all targets
rm -f ~/.ccache/ccache.conf

View File

@ -2,5 +2,5 @@
brew update
brew unlink python
brew install gettext check bullet dbus fontconfig freetype fribidi gst-plugins-good gstreamer luajit openssl webp libsndfile glib libspectre libraw librsvg poppler lz4 pulseaudio ccache ninja python3
brew install gettext check bullet dbus fontconfig freetype fribidi gst-plugins-good gstreamer luajit openssl webp libsndfile glib libspectre libraw librsvg poppler lz4 pulseaudio ccache ninja python3 libffi
pip3 install meson

View File

@ -1,9 +1,8 @@
#!/bin/bash
#!/bin/bash +e
set -o pipefail
export TEST_VAR=1
if ! ./configure $@ | tee -a configlog ; then
if ! ./configure $@ 2>&1 | tee -a configlog ; then
if grep -q 'configure: error: changes in the environment can compromise the build' configlog ; then
echo "clearing config.cache and retrying..."
rm -f configlog config.cache

37
NEWS
View File

@ -35,9 +35,22 @@ Features:
* efl_ui_relative_layout: introduce new relative container (T5487)
* eolian: introduce typed slice types
* eolian: add support for inlist structs
* eolian: remove support for inlist/inarray
Fixes:
* build: fix rpath for binaries which use ecore-x dependencies
* elm/genlist: remove conditional in _calc_job for verifying show_item code (T6368)
* elementary image: don't calc size using empty ones.
* evas image: fix screen flickering issue at partial + image preloading
* edje_cc: change .mo file write location to be relative to the .edj file
* theme: add programs for deferred naviframe push/pop signals
* edje: unset internal _need_imf flag on shutdown
* elm_panel: return instead of EINA_SAFETY_ON_FALSE_RETURN (T7265)
* build: fix evas static build of gl engines
* ecore/main: only update loop_time during loop iteration if the change is monotonic
* evas gl: fix missing map texture target.
* elm_code: fix crash on backspace and selection delete. (T7259)
* ecore_wl2_dmabuf: Link with ecore_wl2 (T7327)
* ecore_wl2_dmabuf: Depend on ecore_wl2 (T7327)
* efl selection manager - avoid multiple selection get callbacks for req
@ -91,6 +104,30 @@ Fixes:
* ecore drm2 - work around kms/drm bug seemingly when no flip event comes
* elm textpath: reduces differences between actual pos and modified pos
* elm_map: Make more robust elm_map (T7443)
* Fix leak in elm atspi
* eina_file: set errno on open fail for win32 build
* evas-gl-drm: Fix issue of rotation not actually rotating (T7690)
* solve neon rotation issue by moving to the tiled rotator
* eo: Fix missing varags cleanup (CID1399080)
* efl_core_command_line: Fix logically dead code (CID1399106)
* efl_ui_widget_common: Fix potential resource leak (CID1399088)
* efl_ui_selection_manager: Fix unchecked return value (CID1399092)
* evas_device: Fix dereferencing null pointer (CID1399091)
* efl_ui_stack: Fix dereference null return value (CID1399082)
* efl_ui_datepicker: Fix uninitialized scalar value (CID1397006)
* efl_ui_grid: Fix dereferencing null pointer (CID1397000)
* ecore_con: Fix dereferencing of null pointer (CID1396990)
* elm_atspi_bridge: Fix resource leak (CID1399429)
* efl_ui_win: Fix dereference null return value (CID1399428)
* efl_ui_win: Fix dereference null return (CID1399427)
* efl_ui_win: Fix dereference null return (CID1399426)
* efl_ui_win: Fix dereference null return value (CID1399425)
* efreet: Fix resource leak (CID1399090)
* efl_ui_text: Fix resource leak (CID1396998)
* eldbus: Fix dereference after null check (CID1399422)
* efl_ui_focus_manager_calc: Fix resource leaks (CID1396984, CID1396965)
* elm_focus_legacy: Fix resource leaks (CID1399096, CID1399095)
* eldbus: Fix resource leak (CID1399097)
Changes since 1.20.0:
---------------------

View File

@ -1,5 +1,5 @@
EFL_VERSION([1], [22], [0], [release])
AC_INIT([efl], [efl_version-alpha1], [enlightenment-devel@lists.sourceforge.net])
AC_INIT([efl], [efl_version-beta2], [enlightenment-devel@lists.sourceforge.net])
AC_PREREQ([2.60])
AC_CONFIG_SRCDIR([configure.ac])
@ -28,7 +28,6 @@ CXXFLAGS="${CXXFLAGS} -Wno-shadow" # No shadow warnings
#### Apply configuring with legacy api's only, eo api's or both.
EFL_API_LEGACY_DEF="#define EFL_NOLEGACY_API_SUPPORT"
EFL_API_EO_DEF="#define EFL_EO_API_SUPPORT"
efl_api="both"
#### For the moment the Eo EFL API is not ready you need to explicitly optin.
@ -43,22 +42,15 @@ AC_ARG_WITH([api],
case "$efl_api" in
eo)
EFL_API_LEGACY_DEF="#define EFL_NOLEGACY_API_SUPPORT"
EFL_API_EO_DEF="#define EFL_EO_API_SUPPORT"
CFOPT_WARNING="xyes"
;;
legacy)
legacy|both)
EFL_API_LEGACY_DEF=""
EFL_API_EO_DEF=""
;;
both)
EFL_API_LEGACY_DEF=""
EFL_API_EO_DEF="#define EFL_EO_API_SUPPORT"
;;
*) AC_MSG_ERROR([Invalid api (${efl_api}): must be eo, legacy or both]) ;;
esac
AC_SUBST(EFL_API_LEGACY_DEF)
AC_SUBST(EFL_API_EO_DEF)
#### Additional options to configure
@ -147,6 +139,20 @@ case "${build_tests}" in
;;
esac
install_eo_files="no"
AC_ARG_ENABLE([install-eo-files],
[AS_HELP_STRING([--enable-install-eo-files],[Enable installing eo files. @<:@default=disabled@:>@])],
[
if test "x${enableval}" = "xyes" ; then
install_eo_files="yes"
else
install_eo_files="no"
fi
],
[install_eo_files="no"])
AM_CONDITIONAL([INSTALL_EO_FILES], [test "${install_eo_files}" = "yes"])
AC_ARG_WITH([ecore-con-http-test-url],
[AS_HELP_STRING([--with-ecore-con-http-test-url=http://username:password@example.com],[Url of http server for testing with username and password])],[ECORE_CON_HTTP_TEST_URL=${withval}][AC_DEFINE_UNQUOTED([ECORE_CON_HTTP_TEST_URL],["$withval"],[Http url for testing])])

View File

@ -1,5 +1,6 @@
/* simple layout to pack our scrolling content into an elm_layout */
group { name: "elm/code/layout/default";
alias: "efl/code/layout";
data {
item: "font.name" "Mono";
item: "font.size" "10";

View File

@ -1,6 +1,8 @@
apiRules:
- exclude:
uidRegex: ^.*NativeInherit
- exclude:
uidRegex: ^.*Concrete
- include:
uidRegex: ^Efl
- include:

View File

@ -57,6 +57,41 @@ def prep_eet_data_file_descriptor_02():
f2.write(b"Simulation2")
return [f1.name, f2.name, "union", "5", "Example-Simulation"]
def prep_ecore_getopt_example():
return ["string-1", "120", "apple", "none-optional-arg"]
def prep_eio_file_copy():
f1 = tempfile.NamedTemporaryFile(delete=False)
f1.write(b"Simulation")
return [f1.name, "/tmp/eio_dst_file"]
def prep_eio_file_ls():
return ["/tmp/"]
def prep_edje_color_class():
return ["beta", "red", "green", "blue"]
def prep_ecore_con_url_headers_example():
return ["GET", "www.enlightenment.org"]
def prep_ecore_con_url_download_example():
return ["www.enlightenment.org"]
def prep_ecore_con_url_cookies_example():
return ["www.enlightenment.org"]
def prep_ecore_con_client_example():
return ["enlightenment.org", "80"]
def prep_ecore_con_lookup_example():
return ["enlightenment.org"]
def prep_ecore_con_server_example():
return ["enlightenment.org", "1234"]
def prep_ecore_con_client_simple_example():
return ["enlightenment.org", "80"]
example_preparation = {
"eina_file_02" : prep_eina_file_02,
"eina_xattr_01" : prep_eina_xattr_01,
@ -66,6 +101,17 @@ example_preparation = {
"eet-data-simple" : prep_eet_data_simple,
"eet-data-file_descriptor_01" : prep_eet_data_file_descriptor_01,
"eet-data-file_descriptor_02" : prep_eet_data_file_descriptor_02,
"ecore_getopt_example" : prep_ecore_getopt_example,
"eio_file_copy" : prep_eio_file_copy,
"eio_file_ls" : prep_eio_file_ls,
"edje-color-class" : prep_edje_color_class,
"ecore_con_url_headers_example" : prep_ecore_con_url_headers_example,
"ecore_con_url_download_example" : prep_ecore_con_url_download_example,
"ecore_con_url_cookies_example" : prep_ecore_con_url_cookies_example,
"ecore_con_client_example" : prep_ecore_con_client_example,
"ecore_con_lookup_example" : prep_ecore_con_lookup_example,
"ecore_con_server_example" : prep_ecore_con_server_example,
"ecore_con_client_simple_example" : prep_ecore_con_client_simple_example,
}
#
@ -105,7 +151,14 @@ def simulate_example(example):
args = []
if os.path.basename(example) in example_preparation:
args = example_preparation[os.path.basename(example)]()
run = subprocess.Popen([G.builddir + "/" + example] + args,
#meson changed behaviour from 0.49 to 0.50 so we need this:
if os.path.isabs(example):
example_dir = example
else:
example_dir = os.path.join(G.builddir, example)
run = subprocess.Popen([example_dir] + args,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
)
@ -119,10 +172,18 @@ def simulate_example(example):
else:
return (example, True if b'ERR' in outs or b'ERR' in errs else False, run.poll())
#meson changed behaviour from 0.49 to 0.50 so we need this:
def meson_fetch_filename(filename_object):
if isinstance(filename_object, str):
return filename_object
else:
return filename_object[0]
parser = argparse.ArgumentParser(description='Run the examples of efl')
parser.add_argument('builddir', metavar='build', help='the path where to find the meson build directory')
G = parser.parse_args()
#Run meson to fetch all examples
meson_introspect = subprocess.Popen(["meson", "introspect", G.builddir, "--targets"],
@ -131,7 +192,7 @@ meson_introspect = subprocess.Popen(["meson", "introspect", G.builddir, "--targe
)
meson_introspect.poll()
build_targets = json.loads(meson_introspect.stdout.read())
examples = [b["filename"] for b in build_targets if "examples" in b["filename"] and b["type"] == "executable"]
examples = [meson_fetch_filename(b["filename"]) for b in build_targets if "examples" in meson_fetch_filename(b["filename"]) and b["type"] == "executable"]
state = State(len(examples))
#simulate all examples in parallel with up to 5 runners
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:

View File

@ -43,7 +43,6 @@ header_checks = [
'sys/wait.h',
'sys/resource.h',
'sys/times.h',
'dirent.h',
'longinfo.h',
'exotic.h',
'ieeefp.h',
@ -106,7 +105,6 @@ function_checks = [
#FIXME strlcpy is detected by meson but drops at compilation time
# ['strlcpy', ['string.h']],
['siginfo_t', ['signal.h']],
['strerror_r', ['string.h']],
['pthread_getcpuclockid', ['pthread.h', 'time.h']],
['timerfd_create', ['sys/timerfd.h']],
['kevent', ['sys/types.h', 'sys/event.h', 'sys/time.h']],

View File

@ -97,7 +97,6 @@ add_global_arguments(dev_cflags, language: 'cpp')
foreach lang : ['c', 'objc', 'cpp']
add_global_arguments('-DHAVE_CONFIG_H=1', language: lang)
add_global_arguments('-D_GNU_SOURCE=1', language: lang)
add_global_arguments('-DEFL_EO_API_SUPPORT=1', language: lang)
add_global_arguments('-DEFL_BETA_API_SUPPORT=1', language: lang)
add_global_arguments('-DNEED_RUN_IN_TREE=1', language: lang)
add_global_arguments('-DEFL_BUILD=1', language: lang)
@ -121,6 +120,7 @@ foreach lang : ['c', 'objc', 'cpp']
else
error('Version of targetted Windows incorrect')
endif
add_global_arguments('-D__USE_MINGW_ANSI_STDIO', language: lang)
endif
endforeach
@ -422,9 +422,12 @@ if get_option('eolian-bootstrap') == false
subdir(join_paths('src', 'generic', 'emotion'))
bindings = get_option('bindings')
bindings_order = ['luajit', 'cxx', 'mono']
foreach binding : bindings
subdir(join_paths('src', 'bindings', binding))
foreach binding : bindings_order
if bindings.contains(binding)
subdir(join_paths('src', 'bindings', binding))
endif
endforeach
subdir(join_paths('src', 'edje_external'))
@ -467,7 +470,6 @@ efl_config_h.set('EFL_VERSION_MICRO', version_micro)
efl_config_h.set('EFL_BUILD_ID', get_option('build-id'))
#FIXME placeholder
efl_config_h.set('EFL_API_EO_DEF', '#define EFL_API_EO_DEF "FIXME NOT IMPLEMENTED"')
efl_config_h.set('EFL_API_LEGACY_DEF', '#define EFL_API_LEGACY_DEF "FIXME NOT IMPLEMENTED"')
configure_file(

7
meson/meson_csharp_docs.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# Installer script needed to install documentation xml file
# as meson's library() call can't track files other than the generated
# efl_mono.dll
cp $1 $2

View File

@ -366,3 +366,9 @@ option('eolian-bootstrap',
value : false,
description : 'Only build efl up to eolian_gen and install eina libeolian and eolian_gen, usefull for cross compiles'
)
option('install-eo-files',
type: 'boolean',
value: false,
description : 'Set this to false to not install any eo file'
)

View File

@ -74,8 +74,10 @@ BUILT_SOURCES += \
$(ecore_priv_c) \
$(ecore_priv_h)
if INSTALL_EO_FILES
ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
ecoreeolianfiles_DATA = $(ecore_eolian_files_public) lib/ecore/efl_loop_timer.eo
endif
ecore_legacy_eo_c = \
lib/ecore/ecore_exe_eo.c \

View File

@ -20,11 +20,13 @@ BUILT_SOURCES += \
$(ecore_audio_eolian_c) \
$(ecore_audio_eolian_h)
if INSTALL_EO_FILES
ecore_audioeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
ecore_audioeolianfiles_DATA = $(ecore_audio_eolian_files)
endif
EXTRA_DIST2 += \
${ecore_audioeolianfiles_DATA}
$(ecore_audio_eolian_files)
lib_LTLIBRARIES += lib/ecore_audio/libecore_audio.la

View File

@ -56,13 +56,16 @@ BUILT_SOURCES += \
$(ecore_con_eolian_c) \
$(ecore_con_eolian_h)
if INSTALL_EO_FILES
ecoreconeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
ecoreconeolianfiles_DATA = \
$(ecore_con_eolian_files) \
$(ecore_con_eolian_type_files)
endif
EXTRA_DIST2 += \
${ecoreconeolianfiles_DATA}
$(ecore_con_eolian_files) \
$(ecore_con_eolian_type_files)
lib_LTLIBRARIES += lib/ecore_con/libecore_con.la

View File

@ -58,10 +58,12 @@ BUILT_SOURCES += \
$(ector_eolian_c) \
$(ector_eolian_h)
if INSTALL_EO_FILES
ectoreolianfilesdir = $(datadir)/eolian/include/ector-@VMAJ@
ectoreolianfiles_DATA = $(ector_eolian_files) $(ector_eolian_type_files)
endif
EXTRA_DIST2 += $(ectoreolianfiles_DATA) \
EXTRA_DIST2 += $(ector_eolian_files) $(ector_eolian_type_files) \
lib/ector/Ector.h \
lib/ector/ector_util.h \
lib/ector/ector_surface.h \

View File

@ -35,15 +35,19 @@ BUILT_SOURCES += \
$(edje_eolian_priv_c) \
$(edje_eolian_priv_h)
if INSTALL_EO_FILES
edjeeolianfilesdir = $(datadir)/eolian/include/edje-@VMAJ@
edjeeolianfiles_DATA = \
$(edje_eolian_files) \
$(edje_eolian_type_files)
$(edje_eolian_files) \
$(edje_eolian_type_files)
endif
noinst_DATA += $(edje_eolian_priv_c) $(edje_eolian_priv_h)
EXTRA_DIST2 += ${edjeeolianfiles_DATA} \
$(edje_eolian_priv_files)
EXTRA_DIST2 += \
$(edje_eolian_files) \
$(edje_eolian_type_files) \
$(edje_eolian_priv_files)
lib_LTLIBRARIES += lib/edje/libedje.la

View File

@ -111,8 +111,10 @@ EXTRA_DIST2 += \
$(efl_eolian_files) \
$(efl_eolian_type_files)
if INSTALL_EO_FILES
efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@
efleolianfiles_DATA = $(efl_eolian_files) $(efl_eolian_type_files)
endif
lib_LTLIBRARIES += lib/efl/libefl.la

View File

@ -65,7 +65,8 @@ lib_efl_mono_libefl_mono_dll_sources = \
efl_mono_test_files = \
tests/efl_mono/dummy_test_object.eo \
tests/efl_mono/dummy_test_iface.eo \
tests/efl_mono/dummy_another_iface.eo \
tests/efl_mono/dummy_inherit_iface.eo \
tests/efl_mono/dummy_inherit_helper.eo \
tests/efl_mono/dummy_child.eo \
tests/efl_mono/dummy_part_holder.eo \
tests/efl_mono/dummy_numberwrapper.eo \
@ -83,31 +84,34 @@ bin_PROGRAMS += bin/eolian_mono/eolian_mono
bin_eolian_mono_eolian_mono_SOURCES = \
bin/eolian_mono/eolian_mono.cc \
bin/eolian_mono/eolian/mono/documentation.hh \
bin/eolian_mono/eolian/mono/type.hh \
bin/eolian_mono/eolian/mono/marshall_annotation.hh \
bin/eolian_mono/eolian/mono/alias_definition.hh \
bin/eolian_mono/eolian/mono/async_function_definition.hh \
bin/eolian_mono/eolian/mono/function_pointer.hh \
bin/eolian_mono/eolian/mono/function_definition.hh \
bin/eolian_mono/eolian/mono/name_helpers.hh \
bin/eolian_mono/eolian/mono/function_declaration.hh \
bin/eolian_mono/eolian/mono/helpers.hh \
bin/eolian_mono/eolian/mono/function_helpers.hh \
bin/eolian_mono/eolian/mono/marshall_type_impl.hh \
bin/eolian_mono/eolian/mono/function_registration.hh \
bin/eolian_mono/eolian/mono/blacklist.hh \
bin/eolian_mono/eolian/mono/documentation.hh \
bin/eolian_mono/eolian/mono/enum_definition.hh \
bin/eolian_mono/eolian/mono/struct_definition.hh \
bin/eolian_mono/eolian/mono/part_definition.hh \
bin/eolian_mono/eolian/mono/struct_fields.hh \
bin/eolian_mono/eolian/mono/parameter.hh \
bin/eolian_mono/eolian/mono/variable_definition.hh \
bin/eolian_mono/eolian/mono/utils.hh \
bin/eolian_mono/eolian/mono/using_decl.hh \
bin/eolian_mono/eolian/mono/marshall_type.hh \
bin/eolian_mono/eolian/mono/klass.hh \
bin/eolian_mono/eolian/mono/type_impl.hh \
bin/eolian_mono/eolian/mono/events.hh \
bin/eolian_mono/eolian/mono/generation_contexts.hh
bin/eolian_mono/eolian/mono/function_declaration.hh \
bin/eolian_mono/eolian/mono/function_definition.hh \
bin/eolian_mono/eolian/mono/function_helpers.hh \
bin/eolian_mono/eolian/mono/function_pointer.hh \
bin/eolian_mono/eolian/mono/function_registration.hh \
bin/eolian_mono/eolian/mono/generation_contexts.hh \
bin/eolian_mono/eolian/mono/helpers.hh \
bin/eolian_mono/eolian/mono/klass.hh \
bin/eolian_mono/eolian/mono/logging.hh \
bin/eolian_mono/eolian/mono/marshall_annotation.hh \
bin/eolian_mono/eolian/mono/marshall_type.hh \
bin/eolian_mono/eolian/mono/marshall_type_impl.hh \
bin/eolian_mono/eolian/mono/name_helpers.hh \
bin/eolian_mono/eolian/mono/parameter.hh \
bin/eolian_mono/eolian/mono/part_definition.hh \
bin/eolian_mono/eolian/mono/struct_definition.hh \
bin/eolian_mono/eolian/mono/struct_fields.hh \
bin/eolian_mono/eolian/mono/type.hh \
bin/eolian_mono/eolian/mono/type_impl.hh \
bin/eolian_mono/eolian/mono/using_decl.hh \
bin/eolian_mono/eolian/mono/utils.hh \
bin/eolian_mono/eolian/mono/variable_definition.hh
bin_eolian_mono_eolian_mono_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/eolian_cxx/ \
@ -407,8 +411,6 @@ tests/efl_mono/libefl_mono_native_test.c: \
tests/efl_mono/dummy_test_object.eo.c \
tests/efl_mono/dummy_test_iface.eo.h \
tests/efl_mono/dummy_test_iface.eo.c \
tests/efl_mono/dummy_another_iface.eo.h \
tests/efl_mono/dummy_another_iface.eo.c \
tests/efl_mono/dummy_child.eo.h \
tests/efl_mono/dummy_child.eo.c \
tests/efl_mono/dummy_part_holder.eo.h \
@ -423,7 +425,6 @@ tests/efl_mono/libefl_mono_native_test.c: \
# Intermediate C Sharp test DLL
efl_mono_test_eolian_mono_files = tests/efl_mono/dummy_test_object.eo.cs \
tests/efl_mono/dummy_test_iface.eo.cs \
tests/efl_mono/dummy_another_iface.eo.cs \
tests/efl_mono/dummy_child.eo.cs \
tests/efl_mono/dummy_part_holder.eo.cs \
tests/efl_mono/dummy_numberwrapper.eo.cs \
@ -481,6 +482,7 @@ tests_efl_mono_efl_mono_SOURCES = \
tests/efl_mono/Events.cs \
tests/efl_mono/FunctionPointers.cs \
tests/efl_mono/FunctionPointerMarshalling.cs \
tests/efl_mono/Inheritance.cs \
tests/efl_mono/Parts.cs \
tests/efl_mono/Promises.cs \
tests/efl_mono/Strbuf.cs \

View File

@ -11,11 +11,13 @@ eio_eolian_c = $(eio_eolian_files:%.eo=%.eo.c)
BUILT_SOURCES += $(eio_eolian_c) $(eio_eolian_h)
if INSTALL_EO_FILES
eioeolianfilesdir = $(datadir)/eolian/include/eio-@VMAJ@
eioeolianfiles_DATA = $(eio_eolian_files)
endif
lib_LTLIBRARIES += lib/eio/libeio.la
EXTRA_DIST2 += $(eioeolianfiles_DATA)
EXTRA_DIST2 += $(eio_eolian_files)
installed_eiomainheadersdir = $(includedir)/eio-@VMAJ@

View File

@ -21,12 +21,16 @@ BUILT_SOURCES += \
$(eldbus_eolian_c) \
$(eldbus_eolian_h)
if INSTALL_EO_FILES
eldbuseolianfilesdir = $(datadir)/eolian/include/eldbus-@VMAJ@
eldbuseolianfiles_DATA = $(eldbus_eolian_files) \
$(eldbus_eolian_type_files)
eldbuseolianfiles_DATA = \
$(eldbus_eolian_files) \
$(eldbus_eolian_type_files)
endif
EXTRA_DIST2 += \
${eldbuseolianfiles_DATA}
$(eldbus_eolian_files) \
$(eldbus_eolian_type_files)
lib_LTLIBRARIES += lib/eldbus/libeldbus.la

View File

@ -144,8 +144,6 @@ elm_public_eolian_files += \
lib/elementary/efl_ui_progressbar_legacy_part.eo \
lib/elementary/elm_multibuttonentry_part.eo \
lib/elementary/elm_interface_scrollable.eo \
lib/elementary/elm_atspi_bridge.eo \
lib/elementary/elm_atspi_app_object.eo \
lib/elementary/efl_ui_image_zoomable_pan.eo \
$(NULL)
@ -220,8 +218,10 @@ BUILT_SOURCES += \
$(elm_legacy_eolian_eo_h) \
$(elm_legacy_eolian_legacy_h)
if INSTALL_EO_FILES
elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
elementaryeolianfiles_DATA = $(elm_public_eolian_files) $(elm_eolian_type_files)
endif
noinst_DATA += $(elm_legacy_eolian_eo_h)
@ -255,6 +255,9 @@ lib/elementary/elm_access_eo.c \
lib/elementary/elm_access_eo.legacy.c \
lib/elementary/elm_actionslider_eo.c \
lib/elementary/elm_actionslider_eo.legacy.c \
lib/elementary/elm_atspi_app_object_eo.c \
lib/elementary/elm_atspi_bridge_eo.c \
lib/elementary/elm_atspi_bridge_eo.legacy.c \
lib/elementary/elm_box_eo.c \
lib/elementary/elm_box_eo.legacy.c \
lib/elementary/elm_bubble_eo.c \
@ -433,6 +436,8 @@ lib/elementary/efl_ui_win_legacy_eo.legacy.h \
lib/elementary/efl_ui_win_socket_legacy_eo.legacy.h \
lib/elementary/elm_access_eo.legacy.h \
lib/elementary/elm_actionslider_eo.legacy.h \
lib/elementary/elm_atspi_app_object_eo.legacy.h \
lib/elementary/elm_atspi_bridge_eo.legacy.h \
lib/elementary/elm_box_eo.legacy.h \
lib/elementary/elm_bubble_eo.legacy.h \
lib/elementary/elm_calendar_eo.legacy.h \
@ -540,6 +545,8 @@ lib/elementary/efl_ui_win_legacy_eo.h \
lib/elementary/efl_ui_win_socket_legacy_eo.h \
lib/elementary/elm_access_eo.h \
lib/elementary/elm_actionslider_eo.h \
lib/elementary/elm_atspi_app_object_eo.h \
lib/elementary/elm_atspi_bridge_eo.h \
lib/elementary/elm_box_eo.h \
lib/elementary/elm_bubble_eo.h \
lib/elementary/elm_calendar_eo.h \
@ -629,7 +636,7 @@ lib/elementary/elm_widget_clipper.h \
$(NULL)
EXTRA_DIST2 += ${elementaryeolianfiles_DATA} $(elm_legacy_eolian_files) $(elm_private_eolian_files) $(elm_legacy_eo_files) $(elm_legacy_eo_headers_priv)
EXTRA_DIST2 += $(elm_public_eolian_files) $(elm_eolian_type_files) $(elm_legacy_eolian_files) $(elm_private_eolian_files) $(elm_legacy_eo_files) $(elm_legacy_eo_headers_priv)
lib_LTLIBRARIES += lib/elementary/libelementary.la
@ -643,7 +650,6 @@ includesdir = $(includedir)/elementary-@VMAJ@
includesunstable_HEADERS = \
lib/elementary/efl_ui_animation_view_private.h \
lib/elementary/elm_gen_common.h \
lib/elementary/elm_atspi_bridge.h \
lib/elementary/efl_access_object.h \
lib/elementary/efl_access_text.h \
lib/elementary/efl_access_widget_action.h \
@ -804,6 +810,7 @@ includesub_HEADERS = \
lib/elementary/efl_ui_animation_view.eo.legacy.h \
lib/elementary/elm_app.h \
lib/elementary/elm_atspi_app_object.h \
lib/elementary/elm_atspi_bridge.h \
lib/elementary/elm_authors.h \
lib/elementary/elm_bg.h \
lib/elementary/elm_bg_legacy.h \
@ -1408,6 +1415,7 @@ bin/elementary/test_tooltip.c \
bin/elementary/test_transit.c \
bin/elementary/test_transit_bezier.c \
bin/elementary/test_ui_box.c \
bin/elementary/test_ui_box_stack.c \
bin/elementary/test_ui_clock.c \
bin/elementary/test_ui_table.c \
bin/elementary/test_ui_popup.c \
@ -1940,6 +1948,7 @@ tests_elementary_efl_ui_suite_SOURCES = \
tests/elementary/efl_ui_test_focus_sub.c \
tests/elementary/efl_ui_test_box.c \
tests/elementary/efl_ui_test_box_flow.c \
tests/elementary/efl_ui_test_box_stack.c \
tests/elementary/efl_ui_test_table.c \
tests/elementary/efl_ui_test_relative_layout.c \
tests/elementary/efl_ui_test_grid.c \

View File

@ -9,14 +9,14 @@ emotion_eolian_h = $(emotion_eolian_files:%.eo=%.eo.h)
BUILT_SOURCES += \
$(emotion_eolian_c) \
$(emotion_eolian_h)
if INSTALL_EO_FILES
emotioneolianfilesdir = $(datadir)/eolian/include/emotion-@VMAJ@
emotioneolianfiles_DATA = \
$(emotion_eolian_files)
endif
EXTRA_DIST2 += \
lib/emotion/efl_canvas_video_eo.legacy.c \
${emotioneolianfiles_DATA}
${emotion_eolian_files}
lib_LTLIBRARIES += \
lib/emotion/libemotion.la

View File

@ -51,13 +51,15 @@ lib_eo_libeo_dbg_la_LDFLAGS = $(lib_eo_libeo_la_LDFLAGS)
bin_SCRIPTS += scripts/eo/eo_debug
######
if INSTALL_EO_FILES
eoeolianfilesdir = $(datadir)/eolian/include/eo-@VMAJ@
eoeolianfiles_DATA = \
$(eo_eolian_files) \
lib/eo/eina_types.eot # We don't generate .c/.h on purpose
EXTRA_DIST2 += ${eoeolianfiles_DATA}
endif
EXTRA_DIST2 += \
$(eo_eolian_files) \
lib/eo/eina_types.eot
### Unit tests

View File

@ -99,6 +99,7 @@ tests/eolian_cxx/eolian_cxx_test_documentation.cc \
tests/eolian_cxx/eolian_cxx_test_cyclic.cc \
tests/eolian_cxx/complex.c \
tests/eolian_cxx/complex_cxx.cc \
tests/eolian_cxx/beta_class.eo \
tests/eolian_cxx/eolian_cxx_suite.h
if HAVE_AM_16

View File

@ -111,9 +111,10 @@ BUILT_SOURCES += \
$(evas_eolian_c) \
$(evas_eolian_h)
if INSTALL_EO_FILES
evaseolianfilesdir = $(datadir)/eolian/include/evas-@VMAJ@
evaseolianfiles_DATA = $(evas_eolian_files)
endif
evas_legacy_eo_h = \
lib/evas/canvas/efl_canvas_event_grabber_eo.legacy.h \
@ -169,7 +170,7 @@ lib/evas/canvas/evas_textgrid_eo.legacy.c
EXTRA_DIST2 += \
$(evaseolianfiles_DATA) \
$(evas_eolian_files) \
$(evas_eolian_internal_files) \
$(evas_legacy_eo_c)

View File

@ -3,7 +3,6 @@
#endif
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#include <Eet.h>
#include <Ecore.h>
#include <Ecore_Con.h>

View File

@ -21,7 +21,6 @@
#endif
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#include <fcntl.h>
#include "eina_debug_private.h"

View File

@ -134,6 +134,7 @@ elementary_test_src = [
'test_transit.c',
'test_transit_bezier.c',
'test_ui_box.c',
'test_ui_box_stack.c',
'test_ui_clock.c',
'test_ui_table.c',
'test_ui_popup.c',

View File

@ -29,8 +29,8 @@ void test_box_horiz(void *data, Evas_Object *obj, void *event_info);
void test_box_homo(void *data, Evas_Object *obj, void *event_info);
void test_box_transition(void *data, Evas_Object *obj, void *event_info);
void test_box_align(void *data, Evas_Object *obj, void *event_info);
void test_box_stack(void *data, Evas_Object *obj, void *event_info);
void test_ui_box(void *data, Evas_Object *obj, void *event_info);
void test_ui_box_stack(void *data, Evas_Object *obj, void *event_info);
void test_button(void *data, Evas_Object *obj, void *event_info);
void test_ui_button(void *data, Evas_Object *obj, void *event_info);
void test_cnp(void *data, Evas_Object *obj, void *event_info);
@ -826,7 +826,6 @@ add_tests:
ADD_TEST(NULL, "Containers", "Box Homogeneous", test_box_homo);
ADD_TEST(NULL, "Containers", "Box Transition", test_box_transition);
ADD_TEST(NULL, "Containers", "Box Align", test_box_align);
ADD_TEST(NULL, "Containers", "Box Stack", test_box_stack);
ADD_TEST(NULL, "Containers", "Table", test_table);
ADD_TEST(NULL, "Containers", "Table Homogeneous", test_table2);
ADD_TEST(NULL, "Containers", "Table 3", test_table3);
@ -841,6 +840,7 @@ add_tests:
//------------------------------//
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Box", test_ui_box);
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Box_Stack", test_ui_box_stack);
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table", test_ui_table);
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table (Linear API)", test_ui_table_linear);
ADD_TEST_EO(NULL, "Containers", "Efl.Ui.Table_Static", test_ui_table_static);

View File

@ -882,44 +882,3 @@ test_box_align(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_resize(win, 300, 400);
evas_object_show(win);
}
void
test_box_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *bx, *o;
char buf[PATH_MAX];
win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
efl_text_set(efl_added, "Efl.Ui.Box_Stack"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_gfx_color_set(efl_part(win, "background"), 24, 24, 64, 255);
/* stacked box, with items in the center-bottom. its default weight makes
* the window resizable */
bx = efl_add(EFL_UI_BOX_STACK_CLASS, win,
efl_pack_align_set(efl_added, 0.5, 1.0));
efl_content_set(win, bx);
/* stretched rectangle */
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
efl_gfx_color_set(efl_added, 0, 64, 128, 255));
efl_pack(bx, o);
/* rectangle with a max size */
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
efl_gfx_color_set(efl_added, 64, 128, 64, 255),
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(128, 20)));
efl_pack(bx, o);
/* image with a forced min size */
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
o = efl_add(EFL_UI_IMAGE_CLASS, win,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(64, 64)),
efl_file_set(efl_added, buf),
efl_file_load(efl_added));
efl_pack(bx, o);
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 300));
}

View File

@ -1,8 +1,6 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Efl_Ui.h>
#include <Elementary.h>
#include <Efl_Ui.h>
#include <Elementary.h>
@ -430,6 +428,7 @@ _init_gl(Evas_Object *obj)
{
GLData *gld = evas_object_data_get(obj, "gld");
gld->glapi = elm_glview_gl_api_get(obj);
printf("GL_VERSION: %s\n", gld->glapi->glGetString(GL_VERSION));
fflush(stdout);
@ -632,7 +631,7 @@ _test_glview_do(Evas_GL_Context_Version version)
if (!(gld = calloc(1, sizeof(GLData)))) return;
gldata_init(gld);
#if 0
#if 1
// add a Z-depth buffer to the window and try to use GL
Eina_Stringshare *accel;
accel = eina_stringshare_add(elm_config_accel_preference_get());
@ -686,7 +685,6 @@ _test_glview_do(Evas_GL_Context_Version version)
// Animator and other vars
ani = ecore_animator_add(_anim, gl);
gld->glapi = elm_glview_gl_api_get(gl);
evas_object_data_set(gl, "ani", ani);
evas_object_data_set(gl, "gld", gld);
evas_object_event_callback_add(gl, EVAS_CALLBACK_DEL, _del, gl);
@ -731,6 +729,7 @@ _test_glview_do(Evas_GL_Context_Version version)
evas_object_smart_callback_add(bt, "clicked", _on_done, win);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
void

View File

@ -673,6 +673,7 @@ _init_gl(Evas_Object *obj)
{
GLData *gld = evas_object_data_get(obj, "gld");
if (!gld) return;
gld->glapi = elm_glview_gl_api_get(obj);
gears_init(gld);
}
@ -841,10 +842,18 @@ test_glview_manygears(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
if (!(gld = calloc(1, sizeof(GLData)))) return;
gldata_init(gld);
// add a Z-depth buffer to the window and try to use GL
Eina_Stringshare *accel;
accel = eina_stringshare_add(elm_config_accel_preference_get());
elm_config_accel_preference_set("gl:depth");
// new window - do the usual and give it a name, title and delete handler
win = elm_win_util_standard_add("glview_manygears", "GLView Many Gears");
elm_win_autodel_set(win, EINA_TRUE);
// restore previous accel preference
elm_config_accel_preference_set(accel);
eina_stringshare_del(accel);
// add an image bg
bg = elm_bg_add(win);
@ -892,7 +901,6 @@ test_glview_manygears(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
// Add animator for rendering
ani = ecore_animator_add(_anim, gl);
gld->glapi = elm_glview_gl_api_get(gl);
evas_object_data_set(gl, "ani", ani);
evas_object_data_set(gl, "gld", gld);
evas_object_event_callback_add(gl, EVAS_CALLBACK_DEL, _del, gl);

View File

@ -121,6 +121,7 @@ static void
_init_gl(Evas_Object *obj)
{
GL_Data *gld = evas_object_data_get(obj, "gld");
gld->glapi = elm_glview_gl_api_get(obj);
Evas_GL_API *gl = gld->glapi;
GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f,
-0.5f, -0.5f, 0.0f,
@ -232,10 +233,19 @@ test_glview_simple(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
if (!(gld = calloc(1, sizeof(GL_Data)))) return;
// add a Z-depth buffer to the window and try to use GL
Eina_Stringshare *accel;
accel = eina_stringshare_add(elm_config_accel_preference_get());
elm_config_accel_preference_set("gl:depth");
win = elm_win_util_standard_add("glview-simple", "GLView Simple");
elm_win_autodel_set(win, EINA_TRUE);
evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _win_free_cb, gld);
// restore previous accel preference
elm_config_accel_preference_set(accel);
eina_stringshare_del(accel);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
@ -259,7 +269,6 @@ test_glview_simple(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
elm_object_focus_set(gl, EINA_TRUE);
ani = ecore_animator_add(_anim, gl);
gld->glapi = elm_glview_gl_api_get(gl);
evas_object_data_set(gl, "gld", gld);
evas_object_event_callback_add(gl, EVAS_CALLBACK_DEL, _gl_del_cb, ani);
}

View File

@ -0,0 +1,44 @@
#include "test.h"
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
void
test_ui_box_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *bx, *o;
char buf[PATH_MAX];
win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
efl_text_set(efl_added, "Efl.Ui.Box_Stack"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_gfx_color_set(efl_part(win, "background"), 24, 24, 64, 255);
bx = efl_add(EFL_UI_BOX_STACK_CLASS, win);
efl_content_set(win, bx);
/* stretched rectangle */
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
efl_gfx_color_set(efl_added, 0, 64, 128, 255));
efl_pack(bx, o);
/* rectangle with a max size */
o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
efl_gfx_color_set(efl_added, 64, 128, 64, 255),
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(128, 20)),
efl_gfx_hint_align_set(efl_added, 0.5, 1.0));
efl_pack(bx, o);
/* image with a forced min size */
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
o = efl_add(EFL_UI_IMAGE_CLASS, win,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(64, 64)),
efl_file_set(efl_added, buf),
efl_file_load(efl_added));
efl_pack(bx, o);
efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 300));
}

View File

@ -89,6 +89,7 @@ content_add(Eo *parent, char *text)
page = efl_add(EFL_UI_LAYOUT_CLASS, parent,
efl_file_set(efl_added, buf),
efl_file_key_set(efl_added, "page_layout"),
efl_file_load(efl_added),
efl_text_set(efl_part(efl_added, "text"), text),
efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE));
@ -398,6 +399,7 @@ _unpack_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
int index = efl_ui_pager_current_page_get(tab_pager);
Eo *tab_page = efl_pack_content_get(tab_pager, index);
efl_pack_unpack(tab_pager, tab_page);
efl_del(tab_page);
}
static void
@ -446,6 +448,7 @@ _unpack_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
btn = efl_add(EFL_UI_BUTTON_CLASS, box,
efl_text_set(efl_added, "Clear"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _clear_btn_cb, tab_pager),
efl_ui_widget_disabled_set(efl_added, EINA_TRUE), //Soon to be implemented
efl_pack_end(box, efl_added));
/* Unpack */
@ -458,6 +461,7 @@ _unpack_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
btn = efl_add(EFL_UI_BUTTON_CLASS, box,
efl_text_set(efl_added, "Unpack All"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _unpack_all_btn_cb, tab_pager),
efl_ui_widget_disabled_set(efl_added, EINA_TRUE), //Soon to be implemented
efl_pack_end(box, efl_added));
in_box = efl_add(EFL_UI_BOX_CLASS, box,
@ -478,6 +482,7 @@ _unpack_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
efl_text_set(efl_added, "Unpack At"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _unpack_at_btn_cb, tsd),
efl_event_callback_add(efl_added, EFL_EVENT_DEL, _unpack_at_btn_del_cb, tsd),
efl_ui_widget_disabled_set(efl_added, EINA_TRUE), //Soon to be implemented
efl_pack_end(in_box, efl_added));
}

View File

@ -545,7 +545,7 @@ append_cb(void *data, const Efl_Event *ev EINA_UNUSED)
efl_gfx_hint_fill_set(o, EINA_FALSE, EINA_FALSE);
efl_event_callback_add(o, EFL_UI_EVENT_CLICKED, remove_cb, NULL);
elm_object_tooltip_text_set(o, "Click to unpack");
efl_pack_end(table, o);
efl_pack(table, o);
efl_gfx_entity_visible_set(o, 1);
}

View File

@ -1028,6 +1028,7 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Hash *refh)
eina_strbuf_append(buf, " return efl_class_functions_set(klass, opsp, ropsp);\n");
eina_strbuf_free(ops);
eina_strbuf_free(refls);
eina_strbuf_append(buf, "}\n\n");

View File

@ -52,7 +52,7 @@ inline bool is_function_blacklisted(std::string const& c_name)
}
template<typename Context>
inline bool is_function_blacklisted(attributes::function_def const& func, Context context)
inline bool is_function_blacklisted(attributes::function_def const& func, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
auto c_name = func.c_name;
@ -80,7 +80,7 @@ inline bool is_struct_blacklisted(std::string const& full_name)
}
template <typename Context>
inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context context)
inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
if (struct_.is_beta && !options.want_beta)
@ -91,7 +91,7 @@ inline bool is_struct_blacklisted(attributes::struct_def const& struct_, Context
// Struct as type_def is for places where the struct is used as a struct field or parameter/return.
template <typename Context>
inline bool is_struct_blacklisted(attributes::type_def const& struct_, Context context)
inline bool is_struct_blacklisted(attributes::type_def const& struct_, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
if (struct_.is_beta && !options.want_beta)
@ -115,11 +115,11 @@ inline bool is_property_blacklisted(std::string const& name)
{
return name == "Efl.Input.Key.Key"
|| name == "Efl.Input.Hold.Hold"
|| name == "Efl.Text.Text";
|| name == "Efl.IText.Text";
}
template<typename Context>
inline bool is_property_blacklisted(attributes::property_def const& property, Context context)
inline bool is_property_blacklisted(attributes::property_def const& property, Context const& context)
{
auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property);
@ -133,7 +133,23 @@ inline bool is_property_blacklisted(attributes::property_def const& property, Co
}
template<typename Context>
inline bool is_class_blacklisted(attributes::klass_def const& cls, Context context)
inline bool is_property_blacklisted(attributes::property_def const& property,
attributes::klass_def const& implementing_class,
Context const& context)
{
std::string property_name = name_helpers::property_managed_name(property);
std::string klass_name = name_helpers::klass_concrete_or_interface_name(implementing_class);
// This property wrapper is invalidated as it would clash with the implementing
// class constructor. CS
if (property_name == klass_name)
return true;
return is_property_blacklisted(property, context);
}
template<typename Context>
inline bool is_class_blacklisted(attributes::klass_def const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
@ -141,7 +157,7 @@ inline bool is_class_blacklisted(attributes::klass_def const& cls, Context conte
}
template<typename Context>
inline bool is_class_blacklisted(attributes::klass_name const& cls, Context context)
inline bool is_class_blacklisted(attributes::klass_name const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
@ -150,7 +166,7 @@ inline bool is_class_blacklisted(attributes::klass_name const& cls, Context cont
template<typename Context>
inline bool is_event_blacklisted(attributes::event_def const& evt, Context context)
inline bool is_event_blacklisted(attributes::event_def const& evt, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);

View File

@ -37,6 +37,24 @@ struct documentation_generator
return n;
}
// Gets the eolian ref for the given class, prepending I for interfaces.
static std::string object_ref_conversion(const Eolian_Object *cls)
{
auto klass_type = ::eolian_class_type_get((const Eolian_Class *)cls);
auto full_eolian_name = name_helpers::managed_namespace(::eolian_object_name_get(cls));
if (klass_type == EOLIAN_CLASS_MIXIN || klass_type == EOLIAN_CLASS_INTERFACE)
{
size_t pos = full_eolian_name.rfind(".");
if (pos == std::string::npos)
pos = 0;
else
pos++;
full_eolian_name.insert(pos, "I");
}
return full_eolian_name;
}
// Turns a function name from EO convention to EFL# convention.
// The name_tail parameter is the last 4 chars of the original string, which
// could be ".set" or ".get" and in this case they are ignored by Eolian.
@ -45,7 +63,7 @@ struct documentation_generator
{
::Eolian_Function_Type ftype = ::eolian_function_type_get(function);
const char* eo_name = ::eolian_function_name_get(function);
std::string name = name_helpers::managed_namespace(::eolian_object_name_get(klass));
std::string name = object_ref_conversion(klass);
switch(ftype)
{
case ::EOLIAN_METHOD:
@ -123,7 +141,7 @@ struct documentation_generator
if (blacklist::is_struct_blacklisted(ref)) return "";
break;
case ::EOLIAN_OBJECT_EVENT:
ref = name_helpers::managed_namespace(::eolian_object_name_get(data));
ref = object_ref_conversion(data);
ref += ".";
ref += name_helpers::managed_event_name(::eolian_object_name_get(data2));
break;
@ -151,6 +169,9 @@ struct documentation_generator
// If the reference cannot be resolved, just return an empty string and
// it won't be converted into a <see> tag.
break;
case ::EOLIAN_OBJECT_CLASS:
ref = object_ref_conversion(data);
break;
default:
ref = name_helpers::managed_namespace(::eolian_object_name_get(data));
break;
@ -355,7 +376,10 @@ struct documentation_generator
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::documentation_def const& doc, Context const& context) const
{
return generate_tag_summary(sink, doc.full_text, context);
std::string str = doc.full_text;
if (!doc.since.empty())
str += "\n(Since EFL " + doc.since + ")";
return generate_tag_summary(sink, str, context);
}
template<typename OutputIterator, typename Context>

View File

@ -179,7 +179,7 @@ struct event_definition_generator
bool is_inherited_event;
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::event_def const& evt, Context context) const
bool generate(OutputIterator sink, attributes::event_def const& evt, Context const& context) const
{
if (blacklist::is_event_blacklisted(evt, context))
return true;
@ -262,7 +262,7 @@ struct event_definition_generator
if (!generate_event_trigger(sink, wrapper_evt_name, wrapper_args_type, wrapper_args_template, context))
return false;
// Store the delegate for this event in this instance. This is initialized in register_event_proxies()
// Store the delegate for this event in this instance. This is initialized in RegisterEventProxies()
// We can't initialize them directly here as they depend on the member methods being valid (i.e.
// the constructor being called).
if (!as_generator(scope_tab << "Efl.EventCb evt_" << wrapper_evt_name << "_delegate;\n").generate(sink, attributes::unused, context))
@ -270,7 +270,7 @@ struct event_definition_generator
// Callback to be given to C's callback_priority_add
if (!as_generator(
scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref Efl.Event_StructInternal evt)\n"
scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << event_args
<< scope_tab << scope_tab << "try {\n"
@ -291,7 +291,7 @@ struct event_definition_generator
, std::string const& event_name
, std::string const& event_args_type
, std::string const& event_template_args
, Context context) const
, Context const& context) const
{
auto delegate_type = "EventHandler" + event_template_args;
if (!as_generator(
@ -311,7 +311,7 @@ struct event_definition_generator
}
template<typename OutputIterator, typename Context>
bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context context) const
bool generate_event_add_remove(OutputIterator sink, attributes::event_def const &evt, const std::string& event_name, Context const& context) const
{
std::string upper_c_name = utils::to_uppercase(evt.c_name);
auto unit = (const Eolian_Unit*) context_find_tag<eolian_state_context>(context).state;
@ -322,7 +322,7 @@ struct event_definition_generator
<< scope_tab << scope_tab << "add {\n"
<< scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(" << library_name << ", key, this.evt_" << event_name << "_delegate)) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (AddNativeEventHandler(" << library_name << ", key, this.evt_" << event_name << "_delegate)) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.AddHandler(" << event_name << "Key , value);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error adding proxy for event {key}\");\n"
@ -331,7 +331,7 @@ struct event_definition_generator
<< scope_tab << scope_tab << "remove {\n"
<< scope_tab << scope_tab << scope_tab << "lock (eventLock) {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << event_name << "_delegate)) { \n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "if (RemoveNativeEventHandler(key, this.evt_" << event_name << "_delegate)) { \n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eventHandlers.RemoveHandler(" << event_name << "Key , value);\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "} else\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "Eina.Log.Error($\"Error removing proxy for event {key}\");\n"

View File

@ -107,7 +107,7 @@ struct native_function_definition_generator
<< scope_tab << scope_tab << "if(wrapper != null) {\n"
<< scope_tab << scope_tab << scope_tab << eolian_mono::native_function_definition_preamble()
<< scope_tab << scope_tab << scope_tab << "try {\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "")
<< scope_tab << scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "")
<< (f.is_static ? "" : "((") << klass_cast_name << (f.is_static ? "." : ")wrapper).") << string
<< "(" << (native_argument_invocation % ", ") << ");\n"
<< scope_tab << scope_tab << scope_tab << "} catch (Exception e) {\n"
@ -116,7 +116,7 @@ struct native_function_definition_generator
<< scope_tab << scope_tab << scope_tab << "}\n"
<< eolian_mono::native_function_definition_epilogue(*klass)
<< scope_tab << scope_tab << "} else {\n"
<< scope_tab << scope_tab << scope_tab << (return_type != " void" ? "return " : "") << string
<< scope_tab << scope_tab << scope_tab << (return_type != "void" ? "return " : "") << string
<< "_ptr.Value.Delegate(" << self << ((!f.is_static && f.parameters.size() > 0) ? ", " : "") << (argument % ", ") << ");\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
@ -217,9 +217,9 @@ struct native_function_definition_parameterized
struct property_wrapper_definition_generator
{
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
bool generate(OutputIterator sink, attributes::property_def const& property, Context const& context) const
{
if (blacklist::is_property_blacklisted(property, context))
if (blacklist::is_property_blacklisted(property, *implementing_klass, context))
return true;
bool interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
@ -281,7 +281,19 @@ struct property_wrapper_definition_generator
return true;
}
attributes::klass_def const* implementing_klass;
};
struct property_wrapper_definition_parameterized
{
property_wrapper_definition_generator operator()(attributes::klass_def const& klass) const
{
return {&klass};
}
} const property_wrapper_definition;
property_wrapper_definition_generator as_generator(property_wrapper_definition_parameterized)
{
return {};
}
}
@ -294,6 +306,8 @@ struct is_eager_generator< ::eolian_mono::native_function_definition_generator>
template <>
struct is_eager_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {};
template <>
struct is_eager_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {};
template <>
struct is_generator< ::eolian_mono::function_definition_generator> : std::true_type {};
template <>
struct is_generator< ::eolian_mono::native_function_definition_generator> : std::true_type {};
@ -301,6 +315,8 @@ template <>
struct is_generator< ::eolian_mono::function_definition_parameterized> : std::true_type {};
template <>
struct is_generator< ::eolian_mono::property_wrapper_definition_generator> : std::true_type {};
template <>
struct is_generator< ::eolian_mono::property_wrapper_definition_parameterized> : std::true_type {};
namespace type_traits {
template <>
@ -314,6 +330,8 @@ struct attributes_needed< ::eolian_mono::native_function_definition_generator> :
template <>
struct attributes_needed< ::eolian_mono::property_wrapper_definition_generator> : std::integral_constant<int, 1> {};
template <>
struct attributes_needed< ::eolian_mono::property_wrapper_definition_parameterized> : std::integral_constant<int, 1> {};
}
} } }

View File

@ -15,7 +15,7 @@ namespace eolian_mono {
// Blacklist structs that require some kind of manual binding.
template <typename Context>
static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context context)
static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context const& context)
{
std::string name = name_helpers::function_ptr_full_eolian_name(func);
@ -89,7 +89,7 @@ struct function_pointer {
<< scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
<< native_function_definition_preamble
<< scope_tab << scope_tab << "try {\n"
<< scope_tab << scope_tab << scope_tab << (return_type != " void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
<< scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
<< scope_tab << scope_tab << "} catch (Exception e) {\n"
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"

View File

@ -38,7 +38,7 @@ struct function_registration_generator
if(!as_generator(
scope_tab << scope_tab << "if (" << f.c_name << "_static_delegate == null)\n"
<< scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" <<
<< scope_tab << scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" <<
escape_keyword(f.name) << ");\n"
).generate(sink, attributes::unused, context))
return false;

View File

@ -1,6 +1,9 @@
#ifndef EOLIAN_MONO_GENERATION_CONTEXTS_HH
#define EOLIAN_MONO_GENERATION_CONTEXTS_HH
#include "grammar/context.hpp"
#include "grammar/indentation.hpp"
namespace eolian_mono {
struct class_context
@ -19,6 +22,33 @@ struct class_context
wrapper_kind current_wrapper_kind;
};
struct indentation_context
{
constexpr indentation_context(indentation_context const& other) = default;
constexpr indentation_context(efl::eolian::grammar::scope_tab_generator indent)
: indent(indent)
{}
constexpr indentation_context(int n)
: indent(n)
{}
constexpr indentation_context(int n, int m)
: indent(n, m)
{}
efl::eolian::grammar::scope_tab_generator indent;
};
template <typename Context>
inline constexpr efl::eolian::grammar::scope_tab_generator const& current_indentation(Context const& context)
{
return efl::eolian::grammar::context_find_tag<indentation_context>(context).indent;
}
template <typename Context>
inline constexpr Context change_indentation(efl::eolian::grammar::scope_tab_generator const& indent, Context const& context)
{
return efl::eolian::grammar::context_replace_tag(indentation_context(indent), context);
}
struct library_context
{
std::string library_name;

View File

@ -103,7 +103,7 @@ std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfa
// Returns the set of interfaces implemented by this type that haven't been implemented
// by a regular parent class.
template<typename Context>
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context context)
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context const& context)
{
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;

View File

@ -177,7 +177,7 @@ struct klass
).generate(sink, p, iface_cxt))
return false;
if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, iface_cxt))
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, cls.properties, iface_cxt))
return false;
// End of interface declaration
@ -237,7 +237,7 @@ struct klass
<< scope_tab << "public " << concrete_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << (root ? "handle = raw;\n" : "")
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << scope_tab << "RegisterEventProxies();\n"
<< scope_tab << "}\n"
)
.generate(sink, attributes::unused, concrete_cxt))
@ -272,16 +272,25 @@ struct klass
return false;
// Property wrappers
if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, concrete_cxt))
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, cls.properties, concrete_cxt))
return false;
for (auto&& klass : helpers::non_implemented_interfaces(cls, concrete_cxt))
{
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, concrete_cxt))
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, c.properties, concrete_cxt))
return false;
}
// Copied from nativeinherit class, used when setting up providers.
if(!as_generator(
scope_tab << "private static IntPtr GetEflClassStatic()\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "return " << name_helpers::klass_get_full_name(cls) << "();\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, concrete_cxt))
return false;
if(!as_generator("}\n").generate(sink, attributes::unused, concrete_cxt)) return false;
}
@ -344,13 +353,13 @@ struct klass
return false;
// Property wrappers
if (!as_generator(*(property_wrapper_definition)).generate(sink, cls.properties, inherit_cxt))
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, cls.properties, inherit_cxt))
return false;
for (auto&& klass : helpers::non_implemented_interfaces(cls, inherit_cxt))
{
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
if (!as_generator(*(property_wrapper_definition)).generate(sink, c.properties, inherit_cxt))
if (!as_generator(*(property_wrapper_definition(cls))).generate(sink, c.properties, inherit_cxt))
return false;
}
@ -446,18 +455,6 @@ struct klass
std::string native_inherit_full_name = name_helpers::klass_full_native_inherit_name(cls);
auto inherit_name = name_helpers::klass_concrete_name(cls);
// The klass field is static but there is no problem if multiple C# classes inherit from this generated one
// as it is just a simple wrapper, forwarding the Eo calls either to the user API (where C#'s virtual method
// resolution kicks in) or to the base implementation (efl_super).
if (is_inherit)
{
if(!as_generator(
scope_tab << "public " << (root ? "" : "new ") << "static System.IntPtr klass = System.IntPtr.Zero;\n"
<< scope_tab << "public " << (root ? "" : "new ") << "static " << native_inherit_full_name << " nativeInherit = new " << native_inherit_full_name << "();\n"
).generate(sink, attributes::unused, context))
return false;
}
std::string raw_klass_modifier;
if (!root)
raw_klass_modifier = "override ";
@ -540,7 +537,7 @@ struct klass
<< scope_tab << "public " << inherit_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << (root ? "handle = raw;\n" : "")
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << scope_tab << "RegisterEventProxies();\n"
<< scope_tab << "}\n"
).generate(sink, std::make_tuple(constructors, constructors, constructors), context))
return false;
@ -566,7 +563,7 @@ struct klass
<< scope_tab << scope_tab << scope_tab << "actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(base_klass, ((object)this).GetType());\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << scope_tab << "handle = Efl.Eo.Globals.instantiate_start(actual_klass, parent);\n"
<< scope_tab << scope_tab << "register_event_proxies();\n"
<< scope_tab << scope_tab << "RegisterEventProxies();\n"
<< scope_tab << "}\n"
<< scope_tab << "protected void FinishInstantiation()\n"
@ -635,7 +632,8 @@ struct klass
// Event proxy registration
if (!as_generator(
scope_tab << (is_inherit_context(context) || !root ? "protected " : "") << virtual_modifier << "void register_event_proxies()\n"
scope_tab << "///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>\n"
<< scope_tab << (is_inherit_context(context) || !root ? "protected " : "") << virtual_modifier << "void RegisterEventProxies()\n"
<< scope_tab << "{\n"
)
.generate(sink, NULL, context))
@ -644,7 +642,7 @@ struct klass
// Generate event registrations here
if (!root)
if (!as_generator(scope_tab << scope_tab << "base.register_event_proxies();\n").generate(sink, NULL, context))
if (!as_generator(scope_tab << scope_tab << "base.RegisterEventProxies();\n").generate(sink, NULL, context))
return false;
// Assigning the delegates
@ -689,7 +687,12 @@ struct klass
// Callback registration functions
if (!as_generator(
scope_tab << visibility << "bool add_cpp_event_handler(string lib, string key, Efl.EventCb evt_delegate) {\n"
scope_tab << "///<summary>Adds a new event handler, registering it to the native event. For internal use only.</summary>\n"
<< scope_tab << "///<param name=\"lib\">The name of the native library definining the event.</param>\n"
<< scope_tab << "///<param name=\"key\">The name of the native event.</param>\n"
<< scope_tab << "///<param name=\"evt_delegate\">The delegate to be called on event raising.</param>\n"
<< scope_tab << "///<returns>True if the delegate was successfully registered.</returns>\n"
<< scope_tab << visibility << "bool AddNativeEventHandler(string lib, string key, Efl.EventCb evt_delegate) {\n"
<< scope_tab << scope_tab << "int event_count = 0;\n"
<< scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
<< scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"
@ -711,7 +714,11 @@ struct klass
<< scope_tab << scope_tab << "event_cb_count[key]++;\n"
<< scope_tab << scope_tab << "return true;\n"
<< scope_tab << "}\n"
<< scope_tab << visibility << "bool remove_cpp_event_handler(string key, Efl.EventCb evt_delegate) {\n"
<< scope_tab << "///<summary>Removes the given event handler for the given event. For internal use only.</summary>\n"
<< scope_tab << "///<param name=\"key\">The name of the native event.</param>\n"
<< scope_tab << "///<param name=\"evt_delegate\">The delegate to be removed.</param>\n"
<< scope_tab << "///<returns>True if the delegate was successfully registered.</returns>\n"
<< scope_tab << visibility << "bool RemoveNativeEventHandler(string key, Efl.EventCb evt_delegate) {\n"
<< scope_tab << scope_tab << "int event_count = 0;\n"
<< scope_tab << scope_tab << "if (!event_cb_count.TryGetValue(key, out event_count))\n"
<< scope_tab << scope_tab << scope_tab << "event_cb_count[key] = event_count;\n"

View File

@ -46,55 +46,55 @@ struct marshall_type_visitor_generate
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"string", false, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"mstring", true, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"mstring", false, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"stringshare", true, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"stringshare", false, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"strbuf", nullptr, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " Eina.Strbuf");
return replace_base_type(r, "Eina.Strbuf");
}}
, {"Binbuf", true, [&]
{
regular_type_def r = regular;
r.base_type = " System.IntPtr";
r.base_type = "System.IntPtr";
r.namespaces.clear();
return r;
}}
, {"Binbuf", false, [&]
{
regular_type_def r = regular;
r.base_type = " System.IntPtr";
r.base_type = "System.IntPtr";
r.namespaces.clear();
return r;
}}
@ -103,9 +103,9 @@ struct marshall_type_visitor_generate
regular_type_def r = regular;
r.namespaces.clear();
if (is_ptr)
r.base_type = " Eina.Value";
r.base_type = "Eina.Value";
else
r.base_type = " Eina.ValueNative";
r.base_type = "Eina.ValueNative";
return r;
}}
, {"any_value", false, [&]
@ -113,23 +113,23 @@ struct marshall_type_visitor_generate
regular_type_def r = regular;
r.namespaces.clear();
if (is_ptr)
r.base_type = " Eina.Value";
r.base_type = "Eina.Value";
else
r.base_type = " Eina.ValueNative";
r.base_type = "Eina.ValueNative";
return r;
}}
, {"any_value_ptr", true, [&]
{
regular_type_def r = regular;
r.namespaces.clear();
r.base_type = " Eina.Value";
r.base_type = "Eina.Value";
return r;
}}
, {"any_value_ptr", false, [&]
{
regular_type_def r = regular;
r.namespaces.clear();
r.base_type = " Eina.Value";
r.base_type = "Eina.Value";
return r;
}}
, {"void", nullptr, [&]
@ -137,9 +137,9 @@ struct marshall_type_visitor_generate
regular_type_def r = regular;
r.namespaces.clear();
if (is_out) // @inout too
r.base_type = " System.IntPtr";
r.base_type = "System.IntPtr";
else
r.base_type = " void";
r.base_type = "void";
return r;
}}
};
@ -147,8 +147,8 @@ struct marshall_type_visitor_generate
if (regular.is_struct() && !blacklist::is_struct_blacklisted(regular) && !(bool)(regular.base_qualifier & qualifier_info::is_own))
{
if ((is_out || is_return) && is_ptr)
return as_generator(" System.IntPtr").generate(sink, attributes::unused, *context);
return as_generator(string << "_StructInternal")
return as_generator("System.IntPtr").generate(sink, attributes::unused, *context);
return as_generator(string << ".NativeStruct")
.generate(sink, name_helpers::type_full_managed_name(regular), *context);
}
else if (eina::optional<bool> b = call_match
@ -161,7 +161,7 @@ struct marshall_type_visitor_generate
}
, [&] (attributes::type_def::variant_type const& v)
{
return v.visit(*this); // we want to keep is_out info
return v.visit(visitor_regular_type_def_printer<OutputIterator, Context>{sink, context}); // we want to keep is_out info
}))
{
return *b;
@ -169,7 +169,7 @@ struct marshall_type_visitor_generate
else if (is_ptr && helpers::need_pointer_conversion(&regular))
{
regular_type_def r = regular;
r.base_type = " System.IntPtr";
r.base_type = "System.IntPtr";
r.namespaces.clear();
return visitor_generate<OutputIterator, Context>{sink, context, c_type, is_out, is_return, is_ptr}(r);
}
@ -196,27 +196,27 @@ struct marshall_type_visitor_generate
{
{"array", nullptr, nullptr, [&]
{
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
return regular_type_def{"System.IntPtr", complex.outer.base_qualifier, {}};
}
}
,{"list", nullptr, nullptr, [&]
{
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
return regular_type_def{"System.IntPtr", complex.outer.base_qualifier, {}};
}
}
,{"hash", nullptr, nullptr, [&]
{
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
return regular_type_def{"System.IntPtr", complex.outer.base_qualifier, {}};
}
}
,{"iterator", nullptr, nullptr, [&]
{
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
return regular_type_def{"System.IntPtr", complex.outer.base_qualifier, {}};
}
}
,{"accessor", nullptr, nullptr, [&]
{
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
return regular_type_def{"System.IntPtr", complex.outer.base_qualifier, {}};
}
}
};

View File

@ -278,7 +278,11 @@ struct klass_interface_name_generator
template <typename T>
std::string operator()(T const& klass) const
{
return utils::remove_all(klass.eolian_name, '_');
std::string name = utils::remove_all(klass.eolian_name, '_');
if (klass.type == attributes::class_type::mixin || klass.type == attributes::class_type::interface_)
return "I" + name;
else
return name;
}
template <typename OutputIterator, typename Attr, typename Context>
@ -306,10 +310,23 @@ struct klass_full_interface_name_generator
template<typename T>
inline std::string klass_concrete_name(T const& klass)
{
std::string name = utils::remove_all(klass.eolian_name, '_');
if (klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_)
return name;
return name + "Concrete";
if (klass.type == attributes::class_type::mixin || klass.type == attributes::class_type::interface_)
return klass_interface_name(klass) + "Concrete";
return utils::remove_all(klass.eolian_name, '_');
}
template<typename T>
inline std::string klass_concrete_or_interface_name(T const& klass)
{
switch(klass.type)
{
case attributes::class_type::abstract_:
case attributes::class_type::regular:
return klass_concrete_name(klass);
default:
return klass_interface_name(klass);
}
}
struct klass_full_concrete_name_generator
@ -408,7 +425,7 @@ inline std::string managed_event_name(std::string const& name)
inline std::string managed_event_args_short_name(attributes::event_def const& evt)
{
std::string ret;
ret = klass_interface_name(evt.klass);
ret = klass_concrete_or_interface_name(evt.klass);
return ret + name_helpers::managed_event_name(evt.name) + "_Args";
}
@ -425,7 +442,7 @@ inline std::string translate_inherited_event_name(const attributes::event_def &e
// Open/close namespaces
template<typename OutputIterator, typename Context>
bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, Context context)
bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, Context const& context)
{
std::transform(namespaces.begin(), namespaces.end(), namespaces.begin(), managed_namespace);
@ -434,7 +451,7 @@ bool open_namespaces(OutputIterator sink, std::vector<std::string> namespaces, C
}
template<typename OutputIterator, typename Context>
bool close_namespaces(OutputIterator sink, std::vector<std::string> const& namespaces, Context context)
bool close_namespaces(OutputIterator sink, std::vector<std::string> const& namespaces, Context const& context)
{
auto close_namespace = *(lit("} ")) << "\n";
return as_generator(close_namespace).generate(sink, namespaces, context);

View File

@ -580,8 +580,8 @@ struct native_convert_in_variable_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
"var " << string << " = " << type << "_StructConversion.ToManaged(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
type << " " << string << " = " << escape_keyword(param.param_name) << ";\n"
).generate(sink, std::make_tuple(param.type, in_variable_name(param.param_name)), context);
}
else if (param.type.c_type == "Eina_Binbuf *" || param.type.c_type == "const Eina_Binbuf *")
{
@ -647,8 +647,8 @@ struct convert_in_variable_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
"var " << string << " = " << type << "_StructConversion.ToInternal(" << escape_keyword(param.param_name) << ");\n"
).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
marshall_type << " " << string << " = " << escape_keyword(param.param_name) << ";\n"
).generate(sink, std::make_tuple(param.type, in_variable_name(param.param_name)), context);
}
else if (param.type.c_type == "Eina_Binbuf *" || param.type.c_type == "const Eina_Binbuf *")
{
@ -899,8 +899,8 @@ struct convert_out_assign_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
string << " = " << type << "_StructConversion.ToManaged(" << out_variable_name(param.param_name) << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type), context);
string << " = " << out_variable_name(param.param_name) << ";\n"
).generate(sink, escape_keyword(param.param_name), context);
}
else if (param_is_acceptable(param, "Eina_Binbuf *", WANT_OWN, WANT_OUT)
|| param_is_acceptable(param, "Eina_Binbuf *", !WANT_OWN, WANT_OUT)
@ -978,8 +978,8 @@ struct native_convert_in_ptr_assign_generator
if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && helpers::need_struct_conversion(regular))
{
return as_generator(
string << " = " << type << "_StructConversion.ToInternal(" << in_variable_name(param.param_name) << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type), context);
string << " = " << in_variable_name(param.param_name) << ";\n"
).generate(sink, escape_keyword(param.param_name), context);
}
return true;
@ -995,8 +995,8 @@ struct convert_in_ptr_assign_generator
if (param_should_use_in_var(param, true) && param.type.is_ptr && !param.type.has_own && helpers::need_struct_conversion(regular))
{
return as_generator(
string << " = " << type << "_StructConversion.ToManaged(" << in_variable_name(param.param_name) << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type), context);
string << " = " << in_variable_name(param.param_name) << ";\n"
).generate(sink, escape_keyword(param.param_name), context);
}
return true;
@ -1033,8 +1033,8 @@ struct convert_return_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
"return " << type << "_StructConversion.ToManaged(_ret_var);\n"
).generate(sink, ret_type, context);
"return _ret_var;\n"
).generate(sink, nullptr, context);
}
else if (ret_type.c_type == "Eina_Binbuf *" || ret_type.c_type == "const Eina_Binbuf *")
{
@ -1101,8 +1101,8 @@ struct native_convert_out_assign_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
string << " = " << type << "_StructConversion.ToInternal(" << string << ");\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
string << " = " << string << ";\n"
).generate(sink, std::make_tuple(escape_keyword(param.param_name), out_variable_name(param.param_name)), context);
}
else if (param_is_acceptable(param, "Eina_Stringshare *", !WANT_OWN, WANT_OUT))
{
@ -1240,8 +1240,8 @@ struct native_convert_return_generator
else if (helpers::need_struct_conversion(regular))
{
return as_generator(
"return " << type << "_StructConversion.ToInternal(_ret_var);\n"
).generate(sink, ret_type, context);
"return _ret_var;\n"
).generate(sink, nullptr, context);
}
else if (ret_type.c_type == "const char *")
{
@ -1452,7 +1452,7 @@ struct constructor_parameter_name_parameterized
struct constructor_param_generator
{
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context context) const
bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context const& context) const
{
auto params = ctor.function.parameters;
@ -1471,7 +1471,7 @@ struct constructor_param_generator
struct constructor_invocation_generator
{
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context context) const
bool generate(OutputIterator sink, attributes::constructor_def const& ctor, Context const& context) const
{
auto params = ctor.function.parameters;
if (!as_generator(

View File

@ -27,7 +27,7 @@ struct part_definition_generator
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "get\n"
<< scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << "Efl.Object obj = Efl.PartNativeInherit.efl_part_get_ptr.Value.Delegate(NativeHandle, \"" << part.name << "\");\n"
<< scope_tab << scope_tab << scope_tab << "Efl.Object obj = Efl.IPartNativeInherit.efl_part_get_ptr.Value.Delegate(NativeHandle, \"" << part.name << "\");\n"
<< scope_tab << scope_tab << scope_tab << "return " << part_klass_name << ".static_cast(obj);\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"

View File

@ -21,96 +21,260 @@ inline std::string binding_struct_name(attributes::struct_def const& struct_)
return name_helpers::typedecl_managed_name(struct_);
}
inline std::string binding_struct_internal_name(attributes::struct_def const& struct_)
inline std::string struct_internal_decl_name()
{
return binding_struct_name(struct_) + "_StructInternal";
return "NativeStruct";
}
struct struct_definition_generator
inline std::string binding_struct_internal_name(attributes::struct_def const& struct_)
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
{
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "struct_definition_generator: " << struct_.cxx_name << std::endl;
if(!as_generator(documentation).generate(sink, struct_, context))
return false;
if(!as_generator
(
"[StructLayout(LayoutKind.Sequential)]\n"
"public struct " << string << "\n{\n"
)
.generate(sink, binding_struct_name(struct_), context))
return false;
return binding_struct_name(struct_) + "." + struct_internal_decl_name();
}
// iterate struct fields
for (auto const& field : struct_.fields)
{
auto field_name = field.name;
field_name[0] = std::toupper(field_name[0]); // Hack to allow 'static' as a field name
if (!as_generator
(
documentation(1)
<< scope_tab(1) << "public " << type << " " << string << ";\n"
)
.generate(sink, std::make_tuple(field, field.type, name_helpers::to_field_name(field.name)), context))
return false;
}
// Conversors generation //
auto struct_name = binding_struct_name(struct_);
struct to_internal_field_convert_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
{
auto const& indent = current_indentation(context);
auto field_name = name_helpers::to_field_name(field.name);
// FIXME Replace need_struct_conversion(regular) with need_struct_conversion(type)
auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type);
auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type);
auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type);
// Check whether this is an extern struct without declared fields in .eo file and generate a
// placeholder field if positive.
// Mono's JIT is picky when generating function pointer for delegates with empty structs, leading to
// those 'mini-amd64.c condition fields not met' crashes.
if (struct_.fields.size() == 0)
{
if (!as_generator("///<summary>Placeholder field</summary>\npublic IntPtr field;\n").generate(sink, nullptr, context))
if (klass)
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else
{
// Constructor with default parameters for easy struct initialization
if(!as_generator(
scope_tab << "///<summary>Constructor for " << string << ".</summary>\n"
<< scope_tab << "public " << string << "(\n"
<< ((scope_tab << scope_tab << field_argument_default) % ",\n")
<< scope_tab << ")\n"
<< scope_tab << "{\n"
<< *(scope_tab << scope_tab << field_argument_assignment << ";\n")
<< scope_tab << "}\n")
.generate(sink, std::make_tuple(struct_name, struct_name, struct_.fields, struct_.fields), context))
return false;
}
}
else if ((complex && (complex->outer.base_type == "array"
|| complex->outer.base_type == "list"
|| complex->outer.base_type == "iterator"
|| complex->outer.base_type == "hash"))
|| field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
{
// Always assumes pointer
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".Handle;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (helpers::need_struct_conversion(regular))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring"))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = Eina.MemoryNative.StrDup(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (regular && regular->base_type == "stringshare")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = Eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Slice" || field.type.c_type == "const Eina_Slice"
|| field.type.c_type == "Eina_Rw_Slice" || field.type.c_type == "const Eina_Rw_Slice")
{
if (!as_generator(
"\n" <<
indent << scope_tab << scope_tab << "_internal_struct." << field_name << ".Len = _external_struct." << field_name << ".Len;\n" <<
indent << scope_tab << scope_tab << "_internal_struct." << field_name << ".Mem = _external_struct." << field_name << ".Mem;\n")
.generate(sink, attributes::unused, context))
return false;
}
else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".GetNative();\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "bool")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << " ? (byte)1 : (byte)0;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "char")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = (byte)_external_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else // primitives and enums
{
if (!as_generator(
indent << scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
return true;
}
} const to_internal_field_convert {};
if(!as_generator(
"public static implicit operator " << struct_name << "(IntPtr ptr)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "var tmp = (" << struct_name << "_StructInternal)Marshal.PtrToStructure(ptr, typeof(" << struct_name << "_StructInternal));\n"
<< scope_tab << scope_tab << "return " << struct_name << "_StructConversion.ToManaged(tmp);\n"
<< scope_tab << "}\n"
).generate(sink, attributes::unused, context))
return false;
struct to_external_field_convert_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
{
auto const& indent = current_indentation(context);
auto field_name = name_helpers::to_field_name(field.name);
auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type);
auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type);
auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type);
if (klass)
{
auto interface_name = name_helpers::klass_full_interface_name(*klass);
auto concrete_name = name_helpers::klass_full_concrete_name(*klass);
if (!as_generator(
"\n"
<< indent << scope_tab << scope_tab << "_external_struct." << string
<< " = (" << concrete_name << ") System.Activator.CreateInstance(typeof("
<< concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n"
<< indent << scope_tab << scope_tab << "Efl.Eo.Globals.efl_ref(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (complex && (complex->outer.base_type == "array"
|| complex->outer.base_type == "list"
|| complex->outer.base_type == "iterator"))
{
// Always assumes pointer
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false, false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (complex && complex->outer.base_type == "hash")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false, false, false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (helpers::need_struct_conversion(regular))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare"))
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Slice" || field.type.c_type == "const Eina_Slice"
|| field.type.c_type == "Eina_Rw_Slice" || field.type.c_type == "const Eina_Rw_Slice")
{
if (!as_generator(
"\n" <<
indent << scope_tab << scope_tab << "_external_struct." << field_name << ".Len = _internal_struct." << field_name << ".Len;\n" <<
indent << scope_tab << scope_tab << "_external_struct." << field_name << ".Mem = _internal_struct." << field_name << ".Mem;\n")
.generate(sink, attributes::unused, context))
return false;
}
else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ");\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ", Eina.Ownership.Unmanaged);\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "bool")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << " != 0;\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "char")
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = (char)_internal_struct." << string << ";\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else // primitives and enums
{
if (!as_generator(
indent << scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
return true;
}
} const to_external_field_convert {};
if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false;
return true;
}
} const struct_definition {};
// Internal Struct //
struct struct_internal_definition_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
{
auto const& indent = current_indentation(context);
if (!as_generator
(
"///<summary>Internal wrapper for struct " << string << ".</summary>\n"
"[StructLayout(LayoutKind.Sequential)]\n"
"public struct " << string << "\n{\n"
indent << "///<summary>Internal wrapper for struct " << string << ".</summary>\n"
<< indent << "[StructLayout(LayoutKind.Sequential)]\n"
<< indent << "public struct " << string << "\n"
<< indent << "{\n"
)
.generate(sink, std::make_tuple<>(binding_struct_name(struct_), binding_struct_internal_name(struct_)), context))
.generate(sink, std::make_tuple<>(binding_struct_name(struct_), struct_internal_decl_name()), context))
return false;
// iterate struct fields
@ -126,29 +290,29 @@ struct struct_internal_definition_generator
|| regular->base_type == "stringshare"
|| regular->base_type == "any_value_ptr")))
{
if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
<< "public System.IntPtr " << field_name << ";\n")
if (!as_generator(indent << scope_tab << "///<summary>Internal wrapper for field " << field_name << "</summary>\n"
<< indent << scope_tab << "public System.IntPtr " << field_name << ";\n")
.generate(sink, nullptr, context))
return false;
}
else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
&& regular->base_type == "bool")
{
if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
"public System.Byte " << field_name << ";\n")
if (!as_generator(indent << scope_tab << "///<summary>Internal wrapper for field " << field_name << "</summary>\n"
<< indent << scope_tab << "public System.Byte " << field_name << ";\n")
.generate(sink, nullptr, context))
return false;
}
else if (regular && !(regular->base_qualifier & efl::eolian::grammar::attributes::qualifier_info::is_ref)
&& regular->base_type == "char")
{
if (!as_generator("///<summary>Internal wrapper for field " << field_name << "</summary>\n"
"public System.Byte " << field_name << ";\n")
if (!as_generator(indent << scope_tab << "///<summary>Internal wrapper for field " << field_name << "</summary>\n"
<< indent << scope_tab << "public System.Byte " << field_name << ";\n")
.generate(sink, nullptr, context))
return false;
}
else if (!as_generator(scope_tab << eolian_mono::marshall_annotation(false) << "\n"
<< scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
else if (!as_generator(indent << scope_tab << eolian_mono::marshall_annotation(false) << "\n"
<< indent << scope_tab << "public " << eolian_mono::marshall_type(false) << " " << string << ";\n")
.generate(sink, std::make_tuple(field.type, field.type, field_name), context))
return false;
}
@ -159,286 +323,20 @@ struct struct_internal_definition_generator
// those 'mini-amd64.c condition fields not met' crashes.
if (struct_.fields.size() == 0)
{
if (!as_generator("internal IntPtr field;\n").generate(sink, nullptr, context))
if (!as_generator(indent << scope_tab << "internal IntPtr field;\n").generate(sink, nullptr, context))
return false;
}
auto external_name = binding_struct_name(struct_);
auto internal_name = binding_struct_internal_name(struct_);
if(!as_generator(
scope_tab << "///<summary>Implicit conversion to the internal/marshalling representation.</summary>\n"
<< scope_tab << "public static implicit operator " << string << "(" << string << " struct_)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "return " << string << "_StructConversion.ToManaged(struct_);\n"
<< scope_tab << "}\n"
<< scope_tab << "///<summary>Implicit conversion to the managed representation.</summary>\n"
<< scope_tab << "public static implicit operator " << string << "(" << string << " struct_)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "return " << string << "_StructConversion.ToInternal(struct_);\n"
<< scope_tab << "}\n"
).generate(sink, std::make_tuple(external_name, internal_name, external_name,
internal_name, external_name, external_name), context))
return false;
if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false;
return true;
}
} const struct_internal_definition {};
// Conversors generation //
struct to_internal_field_convert_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
{
auto field_name = name_helpers::to_field_name(field.name);
// FIXME Replace need_struct_conversion(regular) with need_struct_conversion(type)
auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type);
auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type);
auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type);
if (klass)
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if ((complex && (complex->outer.base_type == "array"
|| complex->outer.base_type == "list"
|| complex->outer.base_type == "iterator"
|| complex->outer.base_type == "hash"))
|| field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
{
// Always assumes pointer
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".Handle;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = Eina.PrimitiveConversion.ManagedToPointerAlloc(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (helpers::need_struct_conversion(regular))
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = " << type << "_StructConversion.ToInternal(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring"))
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = Eina.MemoryNative.StrDup(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (regular && regular->base_type == "stringshare")
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = Eina.Stringshare.eina_stringshare_add(_external_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Slice" || field.type.c_type == "const Eina_Slice"
|| field.type.c_type == "Eina_Rw_Slice" || field.type.c_type == "const Eina_Rw_Slice")
{
if (!as_generator(
"\n" <<
scope_tab << scope_tab << "_internal_struct." << field_name << ".Len = _external_struct." << field_name << ".Len;\n" <<
scope_tab << scope_tab << "_internal_struct." << field_name << ".Mem = _external_struct." << field_name << ".Mem;\n\n")
.generate(sink, attributes::unused, context))
return false;
}
else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".GetNative();\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ".NativeHandle;\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "bool")
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << " ? (byte)1 : (byte)0;\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "char")
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = (byte)_external_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else // primitives and enums
{
if (!as_generator(
scope_tab << scope_tab << "_internal_struct." << string << " = _external_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
return true;
}
} const to_internal_field_convert {};
struct to_external_field_convert_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_field_def const& field, Context const& context) const
{
auto field_name = name_helpers::to_field_name(field.name);
auto regular = efl::eina::get<attributes::regular_type_def>(&field.type.original_type);
auto klass = efl::eina::get<attributes::klass_name>(&field.type.original_type);
auto complex = efl::eina::get<attributes::complex_type_def>(&field.type.original_type);
if (klass)
{
auto interface_name = name_helpers::klass_full_interface_name(*klass);
auto concrete_name = name_helpers::klass_full_concrete_name(*klass);
if (!as_generator(
"\n"
<< scope_tab << scope_tab << "_external_struct." << string
<< " = (" << concrete_name << ") System.Activator.CreateInstance(typeof("
<< concrete_name << "), new System.Object[] {_internal_struct." << string << "});\n"
<< scope_tab << scope_tab << "Efl.Eo.Globals.efl_ref(_internal_struct." << string << ");\n\n")
.generate(sink, std::make_tuple(field_name, field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Binbuf *" || field.type.c_type == "const Eina_Binbuf *")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (complex && (complex->outer.base_type == "array"
|| complex->outer.base_type == "list"
|| complex->outer.base_type == "iterator"))
{
// Always assumes pointer
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false, false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (complex && complex->outer.base_type == "hash")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false, false, false);\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = Eina.PrimitiveConversion.PointerToManaged<" << type << ">(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (helpers::need_struct_conversion(regular))
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = " << type << "_StructConversion.ToManaged(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field.type, field_name), context))
return false;
}
else if (regular && (regular->base_type == "string" || regular->base_type == "mstring" || regular->base_type == "stringshare"))
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = Eina.StringConversion.NativeUtf8ToManagedString(_internal_struct." << string << ");\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Slice" || field.type.c_type == "const Eina_Slice"
|| field.type.c_type == "Eina_Rw_Slice" || field.type.c_type == "const Eina_Rw_Slice")
{
if (!as_generator(
"\n" <<
scope_tab << scope_tab << "_external_struct." << field_name << ".Len = _internal_struct." << field_name << ".Len;\n" <<
scope_tab << scope_tab << "_external_struct." << field_name << ".Mem = _internal_struct." << field_name << ".Mem;\n\n")
.generate(sink, attributes::unused, context))
return false;
}
else if (field.type.c_type == "Eina_Value" || field.type.c_type == "const Eina_Value")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ");\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (field.type.c_type == "Eina_Value *" || field.type.c_type == "const Eina_Value *")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = new Eina.Value(_internal_struct." << string << ", Eina.Ownership.Unmanaged);\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "bool")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << " != 0;\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else if (!field.type.is_ptr && regular && regular->base_type == "char")
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = (char)_internal_struct." << string << ";\n"
).generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
else // primitives and enums
{
if (!as_generator(
scope_tab << scope_tab << "_external_struct." << string << " = _internal_struct." << string << ";\n")
.generate(sink, std::make_tuple(field_name, field_name), context))
return false;
}
return true;
}
} const to_external_field_convert {};
struct struct_binding_conversion_functions_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
{
// Open conversion class
if (!as_generator
(
"/// <summary>Conversion class for struct " << name_helpers::typedecl_managed_name(struct_) << "</summary>\n"
"public static class " << name_helpers::typedecl_managed_name(struct_) << "_StructConversion\n{\n"
)
.generate(sink, nullptr, context))
return false;
// to internal
if (!as_generator
(
scope_tab << "internal static " << string << " ToInternal(" << string << " _external_struct)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "var _internal_struct = new " << string << "();\n\n"
)
.generate(sink, std::make_tuple(binding_struct_internal_name(struct_)
, binding_struct_name(struct_)
, binding_struct_internal_name(struct_)
), context))
if (!as_generator(
indent << scope_tab << "///<summary>Implicit conversion to the internal/marshalling representation.</summary>\n"
<< indent << scope_tab << "public static implicit operator " << string << "(" << string << " _external_struct)\n"
<< indent << scope_tab << "{\n"
<< indent << scope_tab << scope_tab << "var _internal_struct = new " << string << "();\n"
).generate(sink, std::make_tuple(internal_name, external_name, internal_name), context))
return false;
for (auto const& field : struct_.fields)
@ -447,26 +345,17 @@ struct struct_binding_conversion_functions_generator
return false;
}
if (!as_generator
(
"\n"
<< scope_tab << scope_tab << "return _internal_struct;\n"
<< scope_tab << "}\n\n"
)
.generate(sink, attributes::unused, context))
if (!as_generator(indent << scope_tab << scope_tab << "return _internal_struct;\n"
<< indent << scope_tab << "}\n\n").generate(sink, nullptr, context))
return false;
// to external
if (!as_generator
(
scope_tab << "internal static " << string << " ToManaged(" << string << " _internal_struct)\n"
<< scope_tab << "{\n"
<< scope_tab << scope_tab << "var _external_struct = new " << string << "();\n\n"
)
.generate(sink, std::make_tuple(binding_struct_name(struct_)
, binding_struct_internal_name(struct_)
, binding_struct_name(struct_)
), context))
// to managed
if (!as_generator(
indent << scope_tab << "///<summary>Implicit conversion to the managed representation.</summary>\n"
<< indent << scope_tab << "public static implicit operator " << string << "(" << string << " _internal_struct)\n"
<< indent << scope_tab << "{\n"
<< indent << scope_tab << scope_tab << "var _external_struct = new " << string << "();\n"
).generate(sink, std::make_tuple(external_name, internal_name, external_name), context))
return false;
for (auto const& field : struct_.fields)
@ -475,22 +364,95 @@ struct struct_binding_conversion_functions_generator
return false;
}
if (!as_generator
(
"\n"
<< scope_tab << scope_tab << "return _external_struct;\n"
<< scope_tab << "}\n\n"
)
.generate(sink, attributes::unused, context))
if (!as_generator(indent << scope_tab << scope_tab << "return _external_struct;\n"
<< indent << scope_tab << "}\n\n").generate(sink, nullptr, context))
return false;
// Close conversion class
if (!as_generator("}\n").generate(sink, attributes::unused, context))
return false;
// close internal class
if(!as_generator(indent << "}\n\n").generate(sink, attributes::unused, context)) return false;
return true;
}
} const struct_binding_conversion_functions {};
} const struct_internal_definition {};
// Managed Struct //
struct struct_definition_generator
{
template <typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
{
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "struct_definition_generator: " << struct_.cxx_name << std::endl;
auto const& indent = current_indentation(context);
if(!as_generator(documentation).generate(sink, struct_, context))
return false;
if(!as_generator
(
indent << "[StructLayout(LayoutKind.Sequential)]\n"
<< indent << "public struct " << string << "\n"
<< indent << "{\n"
)
.generate(sink, binding_struct_name(struct_), context))
return false;
// iterate struct fields
for (auto const& field : struct_.fields)
{
auto field_name = field.name;
field_name[0] = std::toupper(field_name[0]); // Hack to allow 'static' as a field name
if (!as_generator
(
indent << scope_tab << documentation
<< indent << scope_tab << "public " << type << " " << string << ";\n"
)
.generate(sink, std::make_tuple(field, field.type, name_helpers::to_field_name(field.name)), context))
return false;
}
auto struct_name = binding_struct_name(struct_);
// Check whether this is an extern struct without declared fields in .eo file and generate a
// placeholder field if positive.
// Mono's JIT is picky when generating function pointer for delegates with empty structs, leading to
// those 'mini-amd64.c condition fields not met' crashes.
if (struct_.fields.size() == 0)
{
if (!as_generator(indent << scope_tab << "///<summary>Placeholder field</summary>\n"
<< indent << scope_tab << "public IntPtr field;\n").generate(sink, nullptr, context))
return false;
}
else
{
// Constructor with default parameters for easy struct initialization
if(!as_generator(
indent << scope_tab << "///<summary>Constructor for " << string << ".</summary>\n"
<< indent << scope_tab << "public " << string << "(\n"
<< ((indent << scope_tab << scope_tab << field_argument_default) % ",\n")
<< indent << scope_tab << ")\n"
<< indent << scope_tab << "{\n"
<< *(indent << scope_tab << scope_tab << field_argument_assignment << ";\n")
<< indent << scope_tab << "}\n\n")
.generate(sink, std::make_tuple(struct_name, struct_name, struct_.fields, struct_.fields), context))
return false;
}
if(!as_generator(
indent << scope_tab << "public static implicit operator " << struct_name << "(IntPtr ptr)\n"
<< indent << scope_tab << "{\n"
<< indent << scope_tab << scope_tab << "var tmp = (" << struct_name << ".NativeStruct)Marshal.PtrToStructure(ptr, typeof(" << struct_name << ".NativeStruct));\n"
<< indent << scope_tab << scope_tab << "return tmp;\n"
<< indent << scope_tab << "}\n\n"
).generate(sink, attributes::unused, context))
return false;
if (!struct_internal_definition.generate(sink, struct_, change_indentation(indent.inc(), context)))
return false;
if(!as_generator(indent << "}\n\n").generate(sink, attributes::unused, context)) return false;
return true;
}
} const struct_definition {};
struct struct_entities_generator
{
@ -506,12 +468,6 @@ struct struct_entities_generator
if (!struct_definition.generate(sink, struct_, context))
return false;
if (!struct_internal_definition.generate(sink, struct_, context))
return false;
if (!struct_binding_conversion_functions.generate(sink, struct_, context))
return false;
return name_helpers::close_namespaces(sink, struct_.namespaces, context);
}
@ -541,11 +497,6 @@ struct is_eager_generator< ::eolian_mono::to_external_field_convert_generator> :
template <>
struct is_generator< ::eolian_mono::to_external_field_convert_generator> : std::true_type {};
template <>
struct is_eager_generator< ::eolian_mono::struct_binding_conversion_functions_generator> : std::true_type {};
template <>
struct is_generator< ::eolian_mono::struct_binding_conversion_functions_generator> : std::true_type {};
template <>
struct is_eager_generator< ::eolian_mono::struct_entities_generator> : std::true_type {};
template <>
@ -564,9 +515,6 @@ struct attributes_needed< ::eolian_mono::to_internal_field_convert_generator> :
template <>
struct attributes_needed< ::eolian_mono::to_external_field_convert_generator> : std::integral_constant<int, 1> {};
template <>
struct attributes_needed< ::eolian_mono::struct_binding_conversion_functions_generator> : std::integral_constant<int, 1> {};
template <>
struct attributes_needed< ::eolian_mono::struct_entities_generator> : std::integral_constant<int, 1> {};
}

View File

@ -26,10 +26,10 @@ attributes::regular_type_def replace_base_integer(attributes::regular_type_def v
bool s = std::is_signed<T>::value;
switch (sizeof(T))
{
case 1: return s ? replace_base_type(v, " sbyte") : replace_base_type(v, " byte");
case 2: return s ? replace_base_type(v, " short") : replace_base_type(v, " ushort");
case 4: return s ? replace_base_type(v, " int") : replace_base_type(v, " uint");
case 8: return s ? replace_base_type(v, " long") : replace_base_type(v, " ulong");
case 1: return s ? replace_base_type(v, "sbyte") : replace_base_type(v, "byte");
case 2: return s ? replace_base_type(v, "short") : replace_base_type(v, "ushort");
case 4: return s ? replace_base_type(v, "int") : replace_base_type(v, "uint");
case 8: return s ? replace_base_type(v, "long") : replace_base_type(v, "ulong");
default: return v;
}
}
@ -40,10 +40,10 @@ attributes::regular_type_def replace_base_opt_integer(attributes::regular_type_d
bool s = std::is_signed<T>::value;
switch (sizeof(T))
{
case 1: return s ? replace_base_type(v, " sbyte?") : replace_base_type(v, " byte?");
case 2: return s ? replace_base_type(v, " short?") : replace_base_type(v, " ushort?");
case 4: return s ? replace_base_type(v, " int?") : replace_base_type(v, " uint?");
case 8: return s ? replace_base_type(v, " long?") : replace_base_type(v, " ulong?");
case 1: return s ? replace_base_type(v, "sbyte?") : replace_base_type(v, "byte?");
case 2: return s ? replace_base_type(v, "short?") : replace_base_type(v, "ushort?");
case 4: return s ? replace_base_type(v, "int?") : replace_base_type(v, "uint?");
case 8: return s ? replace_base_type(v, "long?") : replace_base_type(v, "ulong?");
default: return v;
}
}
@ -67,7 +67,28 @@ eina::optional<bool> call_match(Array const (&array)[N], F f, A a)
}
return {nullptr};
}
template <typename OutputIterator, typename Context>
struct visitor_regular_type_def_printer
{
typedef visitor_regular_type_def_printer visitor_type;
typedef bool result_type;
mutable OutputIterator sink;
Context const* context;
bool operator()(grammar::attributes::regular_type_def const &regular) const
{
return as_generator(string).generate(sink, name_helpers::type_full_managed_name(regular), *context);
}
template<typename T>
bool operator()(T const&) const
{
return true;
}
};
template <typename OutputIterator, typename Context>
struct visitor_generate
{
@ -94,110 +115,110 @@ struct visitor_generate
const optional_match_table[] =
{
// signed primitives
{"byte", nullptr, [&] { return replace_base_type(regular, " sbyte?"); }}
, {"float", nullptr, [&] { return replace_base_type(regular, " float?"); }}
, {"double", nullptr, [&] { return replace_base_type(regular, " double?"); }}
, {"bool", nullptr, [&] { return replace_base_type(regular, " bool?"); }}
{"byte", nullptr, [&] { return replace_base_type(regular, "sbyte?"); }}
, {"float", nullptr, [&] { return replace_base_type(regular, "float?"); }}
, {"double", nullptr, [&] { return replace_base_type(regular, "double?"); }}
, {"bool", nullptr, [&] { return replace_base_type(regular, "bool?"); }}
, {"short", nullptr, [&] { return replace_base_opt_integer<short>(regular); }}
, {"int", nullptr, [&] { return replace_base_opt_integer<int>(regular); }}
, {"long", nullptr, [&] { return replace_base_opt_integer<long>(regular); }}
, {"llong", nullptr, [&] { return replace_base_opt_integer<long long>(regular); }}
, {"int8", nullptr, [&] { return replace_base_type(regular, " sbyte?"); }}
, {"int16", nullptr, [&] { return replace_base_type(regular, " short?"); }}
, {"int32", nullptr, [&] { return replace_base_type(regular, " int?"); }}
, {"int64", nullptr, [&] { return replace_base_type(regular, " long?"); }}
, {"int8", nullptr, [&] { return replace_base_type(regular, "sbyte?"); }}
, {"int16", nullptr, [&] { return replace_base_type(regular, "short?"); }}
, {"int32", nullptr, [&] { return replace_base_type(regular, "int?"); }}
, {"int64", nullptr, [&] { return replace_base_type(regular, "long?"); }}
, {"ssize", nullptr, [&] { return replace_base_opt_integer<ssize_t>(regular); }}
// unsigned primitives
, {"ubyte", nullptr, [&] { return replace_base_type(regular, " byte?"); }}
, {"ubyte", nullptr, [&] { return replace_base_type(regular, "byte?"); }}
, {"ushort", nullptr, [&] { return replace_base_opt_integer<unsigned short>(regular); }}
, {"uint", nullptr, [&] { return replace_base_opt_integer<unsigned int>(regular); }}
, {"ulong", nullptr, [&] { return replace_base_opt_integer<unsigned long>(regular); }}
, {"ullong", nullptr, [&] { return replace_base_opt_integer<unsigned long long>(regular); }}
, {"uint8", nullptr, [&] { return replace_base_type(regular, " byte?"); }}
, {"uint16", nullptr, [&] { return replace_base_type(regular, " ushort?"); }}
, {"uint32", nullptr, [&] { return replace_base_type(regular, " uint?"); }}
, {"uint64", nullptr, [&] { return replace_base_type(regular, " ulong?"); }}
, {"uint8", nullptr, [&] { return replace_base_type(regular, "byte?"); }}
, {"uint16", nullptr, [&] { return replace_base_type(regular, "ushort?"); }}
, {"uint32", nullptr, [&] { return replace_base_type(regular, "uint?"); }}
, {"uint64", nullptr, [&] { return replace_base_type(regular, "ulong?"); }}
, {"size", nullptr, [&] { return replace_base_opt_integer<size_t>(regular); }}
, {"ptrdiff", nullptr, [&] { return replace_base_opt_integer<ptrdiff_t>(regular); }}
, {"intptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr?"); }}
, {"uintptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr?"); }}
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr?"); }}
, {"intptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
, {"uintptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
};
struct match
const match_table[] =
{
// signed primitives
{"byte", nullptr, [&] { return replace_base_type(regular, " sbyte"); }}
{"byte", nullptr, [&] { return replace_base_type(regular, "sbyte"); }}
, {"short", nullptr, [&] { return replace_base_integer<short>(regular); }}
, {"int", nullptr, [&] { return replace_base_integer<int>(regular); }}
, {"long", nullptr, [&] { return replace_base_integer<long>(regular); }}
, {"llong", nullptr, [&] { return replace_base_integer<long long>(regular); }}
, {"int8", nullptr, [&] { return replace_base_type(regular, " sbyte"); }}
, {"int16", nullptr, [&] { return replace_base_type(regular, " short"); }}
, {"int32", nullptr, [&] { return replace_base_type(regular, " int"); }}
, {"int64", nullptr, [&] { return replace_base_type(regular, " long"); }}
, {"int8", nullptr, [&] { return replace_base_type(regular, "sbyte"); }}
, {"int16", nullptr, [&] { return replace_base_type(regular, "short"); }}
, {"int32", nullptr, [&] { return replace_base_type(regular, "int"); }}
, {"int64", nullptr, [&] { return replace_base_type(regular, "long"); }}
, {"ssize", nullptr, [&] { return replace_base_integer<ssize_t>(regular); }}
// unsigned primitives
, {"ubyte", nullptr, [&] { return replace_base_type(regular, " byte"); }}
, {"ubyte", nullptr, [&] { return replace_base_type(regular, "byte"); }}
, {"ushort", nullptr, [&] { return replace_base_integer<unsigned short>(regular); }}
, {"uint", nullptr, [&] { return replace_base_integer<unsigned int>(regular); }}
, {"ulong", nullptr, [&] { return replace_base_integer<unsigned long>(regular); }}
, {"ullong", nullptr, [&] { return replace_base_integer<unsigned long long>(regular); }}
, {"uint8", nullptr, [&] { return replace_base_type(regular, " byte"); }}
, {"uint16", nullptr, [&] { return replace_base_type(regular, " ushort"); }}
, {"uint32", nullptr, [&] { return replace_base_type(regular, " uint"); }}
, {"uint64", nullptr, [&] { return replace_base_type(regular, " ulong"); }}
, {"uint8", nullptr, [&] { return replace_base_type(regular, "byte"); }}
, {"uint16", nullptr, [&] { return replace_base_type(regular, "ushort"); }}
, {"uint32", nullptr, [&] { return replace_base_type(regular, "uint"); }}
, {"uint64", nullptr, [&] { return replace_base_type(regular, "ulong"); }}
, {"size", nullptr, [&] { return replace_base_integer<size_t>(regular); }}
, {"ptrdiff", nullptr, [&] { return replace_base_integer<ptrdiff_t>(regular); }}
, {"intptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }}
, {"uintptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }}
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, " System.IntPtr"); }}
, {"intptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
, {"uintptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
, {"void", nullptr, [&]
{
regular_type_def r = regular;
r.namespaces.clear();
if (is_out) // @inout too
r.base_type = " System.IntPtr";
r.base_type = "System.IntPtr";
else
r.base_type = " void";
r.base_type = "void";
return r;
}}
, {"Eina.Error", nullptr, [&] // Eina.Error
{
return regular_type_def{" Eina.Error", regular.base_qualifier, {}};
return regular_type_def{"Eina.Error", regular.base_qualifier, {}};
}} // TODO
, {"string", nullptr, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"mstring", nullptr, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"stringshare", nullptr, [&]
{
regular_type_def r = regular;
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
return replace_base_type(r, " System.String");
return replace_base_type(r, "System.String");
}}
, {"strbuf", nullptr, [&]
{
return regular_type_def{" Eina.Strbuf", regular.base_qualifier, {}};
return regular_type_def{"Eina.Strbuf", regular.base_qualifier, {}};
}}
, {"any_value", true, [&]
{ return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
}}
, {"any_value", false, [&]
{ return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
}}
, {"any_value_ptr", nullptr, [&]
{ return regular_type_def{" Eina.Value", regular.base_qualifier, {}};
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
}} // FIXME add proper support for any_value_ptr
};
std::string full_type_name = name_helpers::type_full_eolian_name(regular);
@ -234,7 +255,7 @@ struct visitor_generate
}
, [&] (attributes::type_def::variant_type const& v)
{
return v.visit(*this); // we want to keep is_out info
return v.visit(visitor_regular_type_def_printer<OutputIterator, Context>{sink, context}); // we want to keep is_out info
}))
{
return *b;

View File

@ -28,7 +28,7 @@ namespace eolian_mono {
struct constant_definition_generator
{
template<typename OutputIterator, typename Context>
bool generate(OutputIterator sink, attributes::variable_def constant, Context context) const
bool generate(OutputIterator sink, attributes::variable_def constant, Context const& context) const
{
// Open partial class
if (!name_helpers::open_namespaces(sink, constant.namespaces, context))

View File

@ -140,15 +140,16 @@ run(options_type const& opts)
throw std::runtime_error("Failed to generate file preamble");
}
auto lib_context = efl::eolian::grammar::context_add_tag(eolian_mono::library_context{opts.dllimport,
opts.v_major,
opts.v_minor,
opts.references_map},
efl::eolian::grammar::context_null());
using efl::eolian::grammar::context_add_tag;
auto options_context = efl::eolian::grammar::context_add_tag(eolian_mono::options_context{opts.want_beta}, lib_context);
auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, options_context);
auto context = context_add_tag(eolian_mono::indentation_context{0},
context_add_tag(eolian_mono::eolian_state_context{opts.state},
context_add_tag(eolian_mono::options_context{opts.want_beta},
context_add_tag(eolian_mono::library_context{opts.dllimport,
opts.v_major,
opts.v_minor,
opts.references_map},
efl::eolian::grammar::context_null()))));
EINA_ITERATOR_FOREACH(aliases, tp)
{

View File

@ -30,7 +30,7 @@ foreach lib : cxx_sublibs
'-DNEED_RUN_IN_TREE=1'
]
dir_package_include = join_paths(dir_include, package_version_name)
dir_package_include = package_version_name
dir_package_modules = join_paths(dir_lib, package_name, 'modules')
cxx_generator_target = []
cxx_header_src = []

View File

@ -36,22 +36,17 @@ static class UnsafeNativeMethods {
}
}
public enum Components {
Basic,
Ui
}
public static class All {
private static bool InitializedUi = false;
public static void Init(Efl.Components components=Components.Basic) {
public static void Init(Efl.Csharp.Components components=Efl.Csharp.Components.Basic) {
Eina.Config.Init();
Efl.Eo.Config.Init();
ecore_init();
evas_init();
eldbus.Config.Init();
if (components == Components.Ui) {
if (components == Efl.Csharp.Components.Ui) {
Efl.Ui.Config.Init();
InitializedUi = true;
}

View File

@ -3,19 +3,13 @@ using System.Runtime.InteropServices;
using System.Threading;
using static Efl.UnsafeNativeMethods;
static class UnsafeNativeMethods {
[DllImport(efl.Libs.Ecore)] public static extern void ecore_init();
[DllImport(efl.Libs.Ecore)] public static extern void ecore_shutdown();
[DllImport(efl.Libs.Elementary)] public static extern int elm_init(int argc, IntPtr argv);
[DllImport(efl.Libs.Elementary)] public static extern void elm_policy_set(int policy, int policy_detail);
[DllImport(efl.Libs.Elementary)] public static extern void elm_shutdown();
[DllImport(efl.Libs.Elementary)] public static extern void elm_exit();
}
namespace Efl {
namespace Csharp {
///<summary>The components to be initialized.</summary>
public enum Components {
///<summary>Basic components: Eina, Eo, Ecore, Evas and DBus.</summary>
Basic,
///<summary>The same components of <see cref="Efl.Csharp.Components.Basic"/> and the Elementary widget toolkit.</summary>
Ui,
}
/// <summary>

View File

@ -27,6 +27,7 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
private Ownership Ownership { get; set; }
// FIXME Part of the implicit EFL Container interface. Need to make it explicit.
///<summary>Whether this wrapper owns the native accessor.</summary>
public bool Own
{
get
@ -40,12 +41,18 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
}
/// <summary>Create a new accessor wrapping the given pointer.</summary>
/// <param name="handle">The native handle to be wrapped.</param>
/// <param name="owner">Whether this wrapper owns the native accessor.</param>
public Accessor(IntPtr handle, Ownership owner=Ownership.Managed)
{
Handle = handle;
Ownership = owner;
}
/// <summary>Create a new accessor wrapping the given pointer.</summary>
/// <param name="handle">The native handle to be wrapped.</param>
/// <param name="own">Whether this wrapper owns the native accessor.</param>
/// <param name="ownContent">For compatibility with other EFL# containers. Ignored in acessors.</param>
public Accessor(IntPtr handle, bool own, bool ownContent=false)
: this(handle, own ? Ownership.Managed : Ownership.Unmanaged)
{
@ -57,6 +64,9 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
Dispose(true);
}
/// <summary>Disposes of this wrapper, releasing the native accessor if owned.</summary>
/// <param name="disposing">True if this was called from <see cref="Dispose()"/> public method. False if
/// called from the C# finalizer.</param>
protected virtual void Dispose(bool disposing)
{
if (Ownership == Ownership.Managed && Handle != IntPtr.Zero)
@ -66,17 +76,23 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
}
}
/// <summary>Finalizer to be called from the Garbage Collector.</summary>
~Accessor()
{
Dispose(false);
}
public virtual T Convert(IntPtr data)
/// <summary>Convert the native data into managed. This is used when returning the data through a
/// <see cref="System.Collections.Generic.IEnumerator&lt;T&gt;"/>.</summary>
/// <param name="data">The data to be converted</param>
/// <returns>The managed data representing <c>data</c>.</returns>
protected virtual T Convert(IntPtr data)
{
return NativeToManaged<T>(data);
}
/// <summary>Returns an enumerator that iterates throught this accessor.</summary>
/// <returns>An enumerator to walk through the acessor items.</returns>
public IEnumerator<T> GetEnumerator()
{
if (Handle == IntPtr.Zero)
@ -105,19 +121,38 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
}
}
///<summary>Accessor for Inlists.</summary>
public class AccessorInList<T> : Accessor<T>
{
/// <summary>Create a new accessor wrapping the given pointer.</summary>
/// <param name="handle">The native handle to be wrapped.</param>
/// <param name="own">Whether this wrapper owns the native accessor.</param>
public AccessorInList(IntPtr handle, Ownership own): base(handle, own) {}
public override T Convert(IntPtr data)
/// <summary>Convert the native data into managed. This is used when returning the data through a
/// <see cref="System.Collections.Generic.IEnumerator&lt;T&gt;"/>.</summary>
/// <param name="data">The data to be converted</param>
/// <returns>The managed data representing <c>data</c>.</returns>
protected override T Convert(IntPtr data)
{
return NativeToManagedInlistNode<T>(data);
}
}
///<summary>Accessor for Inarrays.</summary>
public class AccessorInArray<T> : Accessor<T>
{
/// <summary>Create a new accessor wrapping the given pointer.</summary>
/// <param name="handle">The native handle to be wrapped.</param>
/// <param name="own">Whether this wrapper owns the native accessor.</param>
public AccessorInArray(IntPtr handle, Ownership own): base(handle, own) {}
public override T Convert(IntPtr data)
/// <summary>Convert the native data into managed. This is used when returning the data through a
/// <see cref="System.Collections.Generic.IEnumerator&lt;T&gt;"/>.</summary>
/// <param name="data">The data to be converted</param>
/// <returns>The managed data representing <c>data</c>.</returns>
protected override T Convert(IntPtr data)
{
return NativeToManagedInplace<T>(data);
}

View File

@ -129,6 +129,9 @@ public class Promise : IDisposable
Dispose(false);
}
/// <summary>Disposes of this wrapper, rejecting the native promise with <see cref="Eina.Error.ECANCELED"/></summary>
/// <param name="disposing">True if this was called from <see cref="Dispose()"/> public method. False if
/// called from the C# finalizer.</param>
protected virtual void Dispose(bool disposing)
{
if (Handle != IntPtr.Zero)
@ -190,7 +193,7 @@ public class Future
/// </summary>
public delegate Eina.Value ResolvedCb(Eina.Value value);
public IntPtr Handle { get; internal set; }
internal IntPtr Handle;
/// <summary>
/// Creates a Future from a native pointer.
@ -317,14 +320,23 @@ public class Future
}
}
/// <summary>Custom marshaler to convert between managed and native <see cref="Eina.Future"/>.
/// Internal usage in generated code.</summary>
public class FutureMarshaler : ICustomMarshaler
{
///<summary>Wrap the native future with a managed wrapper.</summary>
///<param name="pNativeData">Handle to the native future.</param>
///<returns>An <see cref="Eina.Future"/> wrapping the native future.</returns>
public object MarshalNativeToManaged(IntPtr pNativeData)
{
return new Future(pNativeData);
}
///<summary>Extracts the native future from a managed wrapper.</summary>
///<param name="managedObj">The managed wrapper. If it is not an <see cref="Eina.Future"/>, the value returned
///is <see cref="System.IntPtr.Zero"/>.</param>
///<returns>A <see cref="System.IntPtr"/> pointing to the native future.</returns>
public IntPtr MarshalManagedToNative(object managedObj)
{
Future f = managedObj as Future;
@ -333,20 +345,27 @@ public class FutureMarshaler : ICustomMarshaler
return f.Handle;
}
///<summary>Not implemented. The code receiving the native data is in charge of releasing it.</summary>
///<param name="pNativeData">The native pointer to be released.</param>
public void CleanUpNativeData(IntPtr pNativeData) { }
///<summary>Not implemented. The runtime takes care of releasing it.</summary>
///<param name="managedObj">The managed object to be cleaned.</param>
public void CleanUpManagedData(object managedObj) { }
///<summary>Size of the native data size returned</summary>
///<returns>The size of the data.</returns>
public int GetNativeDataSize()
{
return -1;
}
///<summary>Gets an instance of this marshaller.</summary>
///<param name="cookie">A name that could be used to customize the returned marshaller. Currently not used.</param>
///<returns>The <see cref="Eina.FutureMarshaler"/> instance that will marshall the data.</returns>
public static ICustomMarshaler GetInstance(string cookie) {
if (marshaler == null)
{
marshaler = new FutureMarshaler();
}
return marshaler;
}

View File

@ -3,8 +3,17 @@ using System.Runtime.InteropServices;
namespace Efl { namespace Eo {
///<summary>Class to load functions pointers from a native module.
///
///This class has a platform-dependent implementation on whether it
///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix
///(dlopen/dlsym).</summary>
public partial class FunctionInterop
{
///<summary>Loads a function pointer from the given module.</summary>
///<param name="moduleName">The name of the module containing the function.</param>
///<param name="functionName">The name of the function to search for.</param>
///<returns>A function pointer that can be used with delegates.</returns>
public static IntPtr LoadFunctionPointer(string moduleName, string functionName)
{
NativeModule module = new NativeModule(moduleName);
@ -13,6 +22,10 @@ public partial class FunctionInterop
Eina.Log.Debug($"searching {module.Module} for{functionName}, result {s}");
return s;
}
///<summary>Loads a function pointer from the default module.</summary>
///<param name="functionName">The name of the function to search for.</param>
///<returns>A function pointer that can be used with delegates.</returns>
public static IntPtr LoadFunctionPointer(string functionName)
{
Eina.Log.Debug($"searching {null} for {functionName}");
@ -21,8 +34,14 @@ public partial class FunctionInterop
return s;
}
}
public class FunctionWrapper<T>
///<summary>Wraps a native function in a portable manner.
///
///This is intended as a workaround DllImport limitations when switching between mono and dotnet.
///
///The parameter T must be a delegate.
///</summary>
public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate?
{
private Lazy<FunctionLoadResult<T>> loadResult;
#pragma warning disable 0414
@ -42,12 +61,18 @@ public class FunctionWrapper<T>
return new FunctionLoadResult<T>(Marshal.GetDelegateForFunctionPointer<T>(funcptr));
}
}
///<summary>Creates a wrapper for the given function of the given module.</summary>
///<param name="moduleName">The name of the module containing the function.</param>
///<param name="functionName">The name of the function to search for.</param>
public FunctionWrapper(string moduleName, string functionName)
: this (new NativeModule(moduleName), functionName)
{
}
///<summary>Creates a wrapper for the given function of the given module.</summary>
///<param name="module">The module wrapper containing the function.</param>
///<param name="functionName">The name of the function to search for.</param>
public FunctionWrapper(NativeModule module, string functionName)
{
this.module = module;
@ -58,6 +83,8 @@ public class FunctionWrapper<T>
});
}
///<summary>Retrieves the result of function load.</summary>
///<returns>The load result.</returns>
public FunctionLoadResult<T> Value
{
get
@ -67,12 +94,26 @@ public class FunctionWrapper<T>
}
}
public enum FunctionLoadResultKind { Success, LibraryNotFound, FunctionNotFound }
///<summary>The outcome of the function load process.</summary>
public enum FunctionLoadResultKind {
///<summary>Function was loaded successfully.</summary>
Success,
///<summary>Library was not found.</summary>
LibraryNotFound,
///<summary>Function symbol was not found in the given module.</summary>
FunctionNotFound
}
///<summary>Represents the result of loading a function pointer.</summary>
public class FunctionLoadResult<T>
{
///<summary>The status of the load.</summary>
public FunctionLoadResultKind Kind;
public T _Delegate;
private T _Delegate;
///<summary>The delegate wrapping the loaded function pointer.
///
///Throws InvalidOperationException if trying to access while not loaded.</summary>
public T Delegate
{
get {
@ -82,10 +123,15 @@ public class FunctionLoadResult<T>
}
}
///<summary>Creates a new load result of the given kind.</summary>
///<param name="kind">The outcome of the load process.</param>
public FunctionLoadResult(FunctionLoadResultKind kind)
{
this.Kind = kind;
}
///<summary>Creates a new load result with the given delegate.</summary>
///<param name="Delegate">The delegate wrapping the native function.</param>
public FunctionLoadResult(T Delegate)
{
this._Delegate = Delegate;
@ -93,5 +139,4 @@ public class FunctionLoadResult<T>
}
}
} }

View File

@ -6,8 +6,12 @@ namespace Efl { namespace Eo {
public partial class FunctionInterop
{
[DllImport(efl.Libs.Libdl)]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
private static extern IntPtr dlsym(IntPtr handle, string symbol);
///<summary>Loads a function pointer from the given module.</summary>
///<param name="nativeLibraryHandle">The module containing the function.</param>
///<param name="functionName">The name of the function to search for.</param>
///<returns>A function pointer that can be used with delegates.</returns>
public static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
{
Eina.Log.Debug("searching {nativeLibraryHandle} for {functionName}");
@ -17,5 +21,4 @@ public partial class FunctionInterop
}
}
} }

View File

@ -2,10 +2,13 @@ using System;
namespace Efl { namespace Eo {
///<summary>Wraps a native module that was opened with dlopen/LoadLibrary.</summary>
public partial class NativeModule : IDisposable
{
private Lazy<IntPtr> module;
///<summary>Lazily tries to load the module with the given name.</summary>
///<param name="libName">The name of the module to load.</param>
public NativeModule(string libName)
{
module = new Lazy<IntPtr>
@ -15,6 +18,7 @@ public partial class NativeModule : IDisposable
});
}
///<summary>The module that was loaded.</summary>
public IntPtr Module
{
get
@ -23,6 +27,7 @@ public partial class NativeModule : IDisposable
}
}
///<summary>Unload and released the handle to the wrapped module.</summary>
public void Dispose()
{
UnloadLibrary(module.Value);

View File

@ -5,21 +5,45 @@ namespace Efl { namespace Eo {
public partial class NativeModule
{
public const int RTLD_NOW = 0x002;
private const int RTLD_NOW = 0x002;
// Currently we are using GLOBAL due to issues
// with the way evas modules are built.
public const int RTLD_GLOBAL = 0x100;
private const int RTLD_GLOBAL = 0x100;
[DllImport(efl.Libs.Libdl)]
public static extern IntPtr dlopen(string fileName, int flag);
private static extern IntPtr dlopen(string fileName, int flag);
[DllImport(efl.Libs.Libdl)]
public static extern int dlclose(IntPtr handle);
private static extern int dlclose(IntPtr handle);
///<summary>Closes the library handle.</summary>
///<param name="handle">The handle to the library.</param>
public static void UnloadLibrary(IntPtr handle)
{
dlclose(handle);
}
///<summary>Loads the given library.
///
///It attempts to load using the following list of names based on the <c>filename</c>
///parameter:
///
///<list type="bullet">
///<item>
///<description><c>filename</c></description>
///</item>
///<item>
///<description><c>libfilename</c></description>
///</item>
///<item>
///<description><c>filename.so</c></description>
///</item>
///<item>
///<description><c>libfilename.so</c></description>
///</item>
///</list>
///</summary>
///<param name="filename">The name to search for.</param>
///<returns>The loaded library handle or <see cref="System.IntPtr.Zero"/> on failure.</returns>
public static IntPtr LoadLibrary(string filename)
{
Eina.Log.Debug($"Loading library {filename}");

View File

@ -12,6 +12,21 @@ using EoG = Efl.Eo.Globals;
namespace Efl { namespace Eo {
public class Globals {
/// <summary>Represents the type of the native Efl_Class.</summary>
public enum EflClassType {
/// <summary>Regular EFL classes.</summary>
Regular = 0,
/// <summary>Non-instantiable efl classes (i.e. Abstracts).</summary>
RegularNoInstant,
/// <summary>Interface types.</summary>
Interface,
/// <summary>Mixins types.</summary>
Mixin,
/// <summary>Invalid class type.</summary>
Invalid
}
[return: MarshalAs(UnmanagedType.U1)]
public delegate bool efl_object_init_delegate();
public static FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr =
@ -155,6 +170,7 @@ public class Globals {
[DllImport(efl.Libs.Eo)] public static extern IntPtr efl_super(IntPtr obj, IntPtr klass);
public delegate IntPtr efl_class_get_delegate(IntPtr obj);
[DllImport(efl.Libs.Eo)] public static extern IntPtr efl_class_get(IntPtr obj);
[DllImport(efl.Libs.Eo)] public static extern EflClassType efl_class_type_get(IntPtr klass);
public delegate IntPtr dlerror_delegate();
[DllImport(efl.Libs.Evil)] public static extern IntPtr dlerror();
@ -180,10 +196,6 @@ public class Globals {
IntPtr desc,
Efl.EventCb cb,
System.IntPtr data);
public delegate IntPtr
efl_object_legacy_only_event_description_get_delegate([MarshalAs(UnmanagedType.LPStr)] String name);
[DllImport(efl.Libs.Eo)] public static extern IntPtr
efl_object_legacy_only_event_description_get([MarshalAs(UnmanagedType.LPStr)] String name);
public const int RTLD_NOW = 2;
@ -546,6 +558,15 @@ public static class ClassRegister
string name = Eina.StringConversion.NativeUtf8ToManagedString(namePtr)
.Replace("_", ""); // Convert Efl C name to C# name
var klass_type = Efl.Eo.Globals.efl_class_type_get(klass);
// When converting to managed, interfaces and mixins gets the 'I' prefix.
if (klass_type == Efl.Eo.Globals.EflClassType.Interface || klass_type == Efl.Eo.Globals.EflClassType.Mixin)
{
var pos = name.LastIndexOf(".");
name = name.Insert(pos + 1, "I"); // -1 if not found, inserts at 0 normally
}
var curr_asm = typeof(IWrapper).Assembly;
t = curr_asm.GetType(name);
if (t == null)
@ -613,19 +634,34 @@ public static class ClassRegister
{
for (System.Type t = objectType.BaseType; t != null; t = t.BaseType)
{
var method = t.GetMethod("GetEflClassStatic",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
if (method != null)
return (IntPtr) method.Invoke(null, null);
var ptr = GetNativeKlassPtr(t);
if (ptr != IntPtr.Zero)
return ptr;
}
throw new System.InvalidOperationException($"Class '{objectType.FullName}' is not an Efl object");
}
private static IntPtr GetNativeKlassPtr(System.Type objectType)
{
if (objectType == null)
return IntPtr.Zero;
if (objectType.IsInterface)
{
// Try to get the *Concrete class
var assembly = objectType.Assembly;
objectType = assembly.GetType(objectType.FullName + "Concrete");
if (objectType == null)
return IntPtr.Zero;
}
var method = objectType.GetMethod("GetEflClassStatic",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
return (IntPtr) method?.Invoke(null, null);
if (method == null)
return IntPtr.Zero;
return (IntPtr) (method.Invoke(null, null));
}
public static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType)

View File

@ -104,7 +104,7 @@ public struct EventDescription {
}
};
public delegate void EventCb(System.IntPtr data, ref Event_StructInternal evt);
public delegate void EventCb(System.IntPtr data, ref Event.NativeStruct evt);
[StructLayout(LayoutKind.Sequential)]
public struct TextCursorCursor {

View File

@ -62,7 +62,6 @@ blacklisted_files = [
'efl_vg_root_node.eo',
'efl_vg_shape.eo.cs',
'efl_io_buffer.eo',
'efl_io_positioner.eo',
'efl_io_queue.eo',
'efl_io_sizer.eo',
'efl_io_closer_fd.eo',
@ -156,13 +155,20 @@ if get_option('mono-beta')
extra_cs_args += '-d:EFL_BETA'
endif
efl_mono_install_dir = join_paths(dir_lib, 'efl-mono-'+version_major)
efl_mono_xml_doc = join_paths(meson.current_build_dir(), 'efl_mono.xml')
efl_mono = library('efl_mono',
mono_generator_target + mono_files + [efl_src],
install : true,
install_dir : join_paths(dir_lib, 'efl-mono-'+version_major),
cs_args : extra_cs_args
install_dir : efl_mono_install_dir,
cs_args : extra_cs_args + ['-doc:' + efl_mono_xml_doc]
)
meson.add_install_script(join_paths(meson.source_root(), 'meson', 'meson_csharp_docs.sh'),
efl_mono_xml_doc,
efl_mono_install_dir)
efl_mono_test_suite_path=join_paths(meson.current_build_dir())
pkgconfig.generate(

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#include <Efl.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#include <Efl.h>

View File

@ -1,5 +1,4 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <stdio.h>
#include <string.h>

View File

@ -1,5 +1,4 @@
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

View File

@ -1,5 +1,4 @@
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <stdio.h>
#include <string.h>

View File

@ -19,6 +19,11 @@
#define PACKAGE_DATA_DIR "."
#endif
#ifndef PACKAGE_SOURCE_DATA_DIR
#define PACKAGE_SOURCE_DATA_DIR "."
#endif
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Edje.h>
@ -36,7 +41,7 @@ int
main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
{
const char *edje_file = PACKAGE_DATA_DIR"/swallow.edj";
const char *img_file = PACKAGE_DATA_DIR"/bubble.png";
const char *img_file = PACKAGE_SOURCE_DATA_DIR"/bubble.png";
Ecore_Evas *ee;
Evas *evas;
Evas_Object *bg;

View File

@ -42,7 +42,8 @@ edc_files = [
'table.edc',
'text.edc',
'textblock-hyphen.edc',
'toggle_using_filter.edc'
'toggle_using_filter.edc',
'multisense.edc',
]
if (get_option('physics'))
@ -130,6 +131,7 @@ foreach edje_example : edje_examples
executable(edje_example,
[edje_example + '.c'] + themes,
dependencies: [edje, ecore_evas],
c_args: ['-DPACKAGE_DATA_DIR="'+ meson.current_build_dir()+'"',]
c_args: ['-DPACKAGE_DATA_DIR="'+ meson.current_build_dir()+'"',
'-DPACKAGE_SOURCE_DATA_DIR="'+ meson.current_source_dir()+'"',]
)
endforeach

View File

@ -11,7 +11,7 @@ elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
win.text_set("Window Background");
win.autohide_set(true);
win.size_set({320,320});
win.background().color_set(139, 69, 19, 255);
//win.background().color_set(139, 69, 19, 255);
// Clean exit
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

View File

@ -6,7 +6,6 @@
# include "elementary_config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Efl.h>

View File

@ -4,7 +4,6 @@
#include "elementary_config.h"
#else
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -5,7 +5,6 @@
# include "elementary_config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>
@ -126,8 +125,8 @@ elm_main(int argc EINA_UNUSED, char **argv)
priv_d.list = list = efl_add(EFL_UI_LIST_CLASS, wbox);
efl_gfx_hint_weight_set(list, EFL_GFX_HINT_EXPAND, 0.9);
efl_event_callback_add(list, EFL_UI_EVENT_SELECTABLE_SELECTED, _list_selected, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_SELECTABLE_UNSELECTED, _list_unselected, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_ITEM_SELECTED, _list_selected, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_ITEM_UNSELECTED, _list_unselected, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_PRESSED, _list_pressed, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_UNPRESSED, _list_unpressed, NULL);
efl_event_callback_add(list, EFL_UI_EVENT_LONGPRESSED, _list_longpressed, NULL);

View File

@ -4,7 +4,6 @@
# include "elementary_config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -4,7 +4,6 @@
# include "config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -4,7 +4,6 @@
# include "config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED

View File

@ -4,7 +4,6 @@
#include "elementary_config.h"
#else
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -4,7 +4,6 @@
#include "elementary_config.h"
#else
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -2,7 +2,6 @@
//gcc -g efl_ui_scroller_example.c -o efl_ui_scroller_example `pkg-config --cflags --libs elementary`
#define EFL_BETA_API_SUPPORT
#define EFL_EO_API_SUPPORT
#include <Efl_Ui.h>
#include <Elementary.h>

View File

@ -3,7 +3,6 @@
* gcc -o efl_ui_theme_example_01 efl_ui_theme_example_01.c `pkg-config --cflags --libs elementary`
*/
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#define EFL_UI_WIDGET_PROTECTED
#include <Efl_Ui.h>

View File

@ -3,7 +3,6 @@
* gcc -o efl_ui_theme_example_02 efl_ui_theme_example_02.c `pkg-config --cflags --libs elementary`
*/
#define EFL_BETA_API_SUPPORT 1
#define EFL_EO_API_SUPPORT 1
#define EFL_UI_WIDGET_PROTECTED
#include <Efl_Ui.h>

View File

@ -1,6 +1,3 @@
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

View File

@ -8,9 +8,6 @@
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#include <Eo.h>
#include <Evas.h>

View File

@ -5,9 +5,6 @@
* Compile with:
* gcc -o evas3d_scene_on_button_example evas3d_scene_on_button_example.c -g `pkg-config --libs --cflags evas ecore eo elementary`
*/
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

View File

@ -4,7 +4,6 @@
# include "config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Elementary.h>

View File

@ -5,7 +5,6 @@
# include "config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Elementary.h>

View File

@ -87,7 +87,7 @@ elm_main(int argc EINA_UNUSED,
Elm_Object_Item *gg_it;
unsigned int i;
Elm_Gengrid_Item_Class gic;
Elm_Gengrid_Item_Class gic = { 0 };
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_app_info_set(elm_main, "elementary", "images");

View File

@ -134,7 +134,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
evas_object_smart_callback_add(o, "clicked", _btn_click_cb, NULL);
if (!strncmp(elm_config_preferred_engine_get(), "shot", 4))
if (eina_streq(getenv("ELM_ENGINE"), "shot"))
ecore_timer_add(0.1, _screenshot_hack_cb, o);
evas_object_resize(win, 400, 400);

View File

@ -4,7 +4,6 @@
# include "config.h"
#else
# define EFL_BETA_API_SUPPORT 1
# define EFL_EO_API_SUPPORT 1
#endif
#include <Efl_Ui.h>

View File

@ -1,8 +1,5 @@
//Compile with:
//gcc -o location_example_01 location_example_01.c -g `pkg-config --cflags --libs elementary elocation`
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

View File

@ -148,7 +148,7 @@ endforeach
codegen = custom_target('elementary_codegen_examples',
depends : themes,
depends : [themes, elementary_codegen],
input : themes[0],
output : ['codegen_example_generated.c', 'codegen_example_generated.h'],
command : elementary_codegen_exe + ['-p=codegen_example', '@INPUT@', 'elm/example/mylayout/default', '@OUTPUT0@', '@OUTPUT1@'],

View File

@ -1,6 +1,3 @@
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

View File

@ -30,9 +30,6 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif
@ -47,7 +44,6 @@
#include "graphical_struct.h"
#define CONVERT 20
#define WIDTH 1000
#define HEIGHT 600
@ -56,13 +52,6 @@ Graphical globalGraphical;
/*Variable for fps*/
int fps_frames = 0;
void _clear_buf(char *buf)
{
int i;
for (i = 0; i < CONVERT; i++)
buf[i] = '\0';
}
Eina_Slstr * _value_int_to_char(int value, const char *description)
{
if (description)

View File

@ -1,6 +1,3 @@
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

View File

@ -14,9 +14,6 @@
* edje_cc sphere_hunter.edc
* gcc -o evas_3d_sphere_hunter evas_3d_sphere_hunter.c -g `pkg-config --libs --cflags evas ecore elementary eina eo` -lm
*/
#ifndef EFL_EO_API_SUPPORT
# define EFL_EO_API_SUPPORT
#endif
#ifndef EFL_BETA_API_SUPPORT
# define EFL_BETA_API_SUPPORT
#endif

Some files were not shown because too many files have changed in this diff Show More