diff --git a/DEPS b/DEPS index 8f66a4264755e..bbc8a01c48126 100644 --- a/DEPS +++ b/DEPS @@ -145,9 +145,6 @@ deps = { # build. Eventually, we'll manage these dependencies together with Fuchsia # and not have to specific specific hashes. - 'src/third_party/tonic': - Var('fuchsia_git') + '/tonic' + '@' + '1a8ed9be2e2b56b32e888266d6db465d36012df4', - 'src/third_party/benchmark': Var('fuchsia_git') + '/third_party/benchmark' + '@' + 'a779ffce872b4c811beef482e18bd0b63626aa42', diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index bc0989b5991f9..cb29952e3d5a4 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -6,6 +6,7 @@ USED LICENSES: ==================================================================================================== LIBRARY: engine +LIBRARY: tonic LIBRARY: txt ORIGIN: ../../../flutter/LICENSE TYPE: LicenseType.bsd @@ -1122,6 +1123,66 @@ FILE: ../../../flutter/shell/version/version.cc FILE: ../../../flutter/shell/version/version.h FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart FILE: ../../../flutter/sky/tools/roll/patches/chromium/android_build.patch +FILE: ../../../flutter/third_party/tonic/common/build_config.h +FILE: ../../../flutter/third_party/tonic/common/log.cc +FILE: ../../../flutter/third_party/tonic/common/log.h +FILE: ../../../flutter/third_party/tonic/common/macros.h +FILE: ../../../flutter/third_party/tonic/converter/dart_converter.cc +FILE: ../../../flutter/third_party/tonic/converter/dart_converter.h +FILE: ../../../flutter/third_party/tonic/dart_args.h +FILE: ../../../flutter/third_party/tonic/dart_binding_macros.h +FILE: ../../../flutter/third_party/tonic/dart_class_library.cc +FILE: ../../../flutter/third_party/tonic/dart_class_library.h +FILE: ../../../flutter/third_party/tonic/dart_class_provider.cc +FILE: ../../../flutter/third_party/tonic/dart_class_provider.h +FILE: ../../../flutter/third_party/tonic/dart_library_natives.cc +FILE: ../../../flutter/third_party/tonic/dart_library_natives.h +FILE: ../../../flutter/third_party/tonic/dart_list.cc +FILE: ../../../flutter/third_party/tonic/dart_list.h +FILE: ../../../flutter/third_party/tonic/dart_message_handler.cc +FILE: ../../../flutter/third_party/tonic/dart_message_handler.h +FILE: ../../../flutter/third_party/tonic/dart_microtask_queue.cc +FILE: ../../../flutter/third_party/tonic/dart_microtask_queue.h +FILE: ../../../flutter/third_party/tonic/dart_persistent_value.cc +FILE: ../../../flutter/third_party/tonic/dart_persistent_value.h +FILE: ../../../flutter/third_party/tonic/dart_state.cc +FILE: ../../../flutter/third_party/tonic/dart_state.h +FILE: ../../../flutter/third_party/tonic/dart_wrappable.cc +FILE: ../../../flutter/third_party/tonic/dart_wrappable.h +FILE: ../../../flutter/third_party/tonic/dart_wrapper_info.h +FILE: ../../../flutter/third_party/tonic/file_loader/file_loader.cc +FILE: ../../../flutter/third_party/tonic/file_loader/file_loader.h +FILE: ../../../flutter/third_party/tonic/file_loader/file_loader_fuchsia.cc +FILE: ../../../flutter/third_party/tonic/file_loader/file_loader_posix.cc +FILE: ../../../flutter/third_party/tonic/file_loader/file_loader_win.cc +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/eintr_wrapper.h +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/file.cc +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/file.h +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/path.h +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/path_posix.cc +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/path_win.cc +FILE: ../../../flutter/third_party/tonic/filesystem/filesystem/portable_unistd.h +FILE: ../../../flutter/third_party/tonic/logging/dart_error.cc +FILE: ../../../flutter/third_party/tonic/logging/dart_error.h +FILE: ../../../flutter/third_party/tonic/logging/dart_invoke.cc +FILE: ../../../flutter/third_party/tonic/logging/dart_invoke.h +FILE: ../../../flutter/third_party/tonic/parsers/packages_map.cc +FILE: ../../../flutter/third_party/tonic/parsers/packages_map.h +FILE: ../../../flutter/third_party/tonic/platform/platform_utils.h +FILE: ../../../flutter/third_party/tonic/platform/platform_utils_posix.cc +FILE: ../../../flutter/third_party/tonic/platform/platform_utils_win.cc +FILE: ../../../flutter/third_party/tonic/scopes/dart_api_scope.h +FILE: ../../../flutter/third_party/tonic/scopes/dart_isolate_scope.cc +FILE: ../../../flutter/third_party/tonic/scopes/dart_isolate_scope.h +FILE: ../../../flutter/third_party/tonic/typed_data/dart_byte_data.cc +FILE: ../../../flutter/third_party/tonic/typed_data/dart_byte_data.h +FILE: ../../../flutter/third_party/tonic/typed_data/float32_list.h +FILE: ../../../flutter/third_party/tonic/typed_data/float64_list.h +FILE: ../../../flutter/third_party/tonic/typed_data/int32_list.h +FILE: ../../../flutter/third_party/tonic/typed_data/typed_list.cc +FILE: ../../../flutter/third_party/tonic/typed_data/typed_list.h +FILE: ../../../flutter/third_party/tonic/typed_data/uint16_list.h +FILE: ../../../flutter/third_party/tonic/typed_data/uint8_list.h FILE: ../../../flutter/third_party/txt/src/txt/platform.cc FILE: ../../../flutter/third_party/txt/src/txt/platform.h FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc diff --git a/ci/licenses_golden/licenses_fuchsia b/ci/licenses_golden/licenses_fuchsia index a477ff58757cc..f323d171f7fc3 100644 --- a/ci/licenses_golden/licenses_fuchsia +++ b/ci/licenses_golden/licenses_fuchsia @@ -6,6 +6,150 @@ UNUSED LICENSES: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USED LICENSES: +==================================================================================================== +LIBRARY: fuchsia_sdk +ORIGIN: ../../../flutter/third_party/tonic/LICENSE +TYPE: LicenseType.bsd +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/assert.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/boot/netboot.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/compiler.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/driver/binding.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/errors.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/i2c.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/audio.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/hid.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/hub.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/ums.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/listnode.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/pixelformat.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/processargs.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/status.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/debug.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/exception.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/log.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/object.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/pci.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/port.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/profile.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/resource.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/types.h +FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/types.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/assert.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/boot/netboot.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/compiler.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/driver/binding.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/errors.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/i2c.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/audio.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/hid.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/hub.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/ums.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/listnode.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/pixelformat.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/processargs.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/status.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/debug.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/exception.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/log.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/object.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/pci.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/port.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/profile.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/resource.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/types.h +FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/types.h +FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface.dart +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.fonts/font_provider.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.math/math.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media.playback/problem.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media.playback/seeking_reader.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media/audio.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/basemgr/base_shell.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/basemgr/user_provider.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/module/module_context.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/module/module_controller.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/session/focus.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/session/session_shell.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_controller.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_info.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_provider.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.net.oldhttp/url_body.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/component_controller.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/environment.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/environment_controller.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/launcher.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/loader.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/runner.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.tracing.provider/provider.fidl +FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.ui.policy/presenter.fidl +FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/fdio.h +FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/io.h +FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/vfs.h +FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/watcher.h +FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/include/lib/media/cpp/timeline_function.h +FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/include/lib/media/cpp/timeline_rate.h +FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/timeline_function.cc +FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/timeline_rate.cc +FILE: ../../../fuchsia/sdk/linux/pkg/sync/include/lib/sync/completion.h +FILE: ../../../fuchsia/sdk/linux/pkg/sys_cpp/include/lib/sys/cpp/termination_reason.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/channel.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/event.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/eventpair.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/channel.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/event.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/eventpair.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/job.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/object.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/object_traits.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/port.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/process.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/socket.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/task.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/thread.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/time.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/vmar.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/vmo.h +FILE: ../../../fuchsia/sdk/linux/pkg/zx/job.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/port.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/process.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/socket.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/thread.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/vmar.cc +FILE: ../../../fuchsia/sdk/linux/pkg/zx/vmo.cc +---------------------------------------------------------------------------------------------------- +Copyright 2016 The Fuchsia Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +==================================================================================================== + ==================================================================================================== LIBRARY: fuchsia_sdk ORIGIN: ../../../fuchsia/sdk/linux/COPYRIGHT.musl @@ -3227,150 +3371,6 @@ distribution. contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - -==================================================================================================== -LIBRARY: fuchsia_sdk -ORIGIN: ../../../third_party/tonic/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/assert.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/boot/netboot.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/compiler.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/driver/binding.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/errors.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/i2c.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/audio.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/hid.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/hub.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/hw/usb/ums.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/listnode.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/pixelformat.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/processargs.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/status.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/debug.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/exception.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/log.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/object.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/pci.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/port.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/profile.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/resource.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/syscalls/types.h -FILE: ../../../fuchsia/sdk/linux/arch/arm64/sysroot/include/zircon/types.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/assert.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/boot/netboot.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/compiler.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/driver/binding.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/errors.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/i2c.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/audio.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/hid.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/hub.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/hw/usb/ums.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/listnode.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/pixelformat.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/processargs.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/status.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/debug.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/exception.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/log.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/object.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/pci.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/port.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/profile.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/resource.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/syscalls/types.h -FILE: ../../../fuchsia/sdk/linux/arch/x64/sysroot/include/zircon/types.h -FILE: ../../../fuchsia/sdk/linux/dart/fidl/lib/src/interface.dart -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.fonts/font_provider.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.math/math.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media.playback/problem.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media.playback/seeking_reader.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.media/audio.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/basemgr/base_shell.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/basemgr/user_provider.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/module/module_context.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/module/module_controller.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/session/focus.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/session/session_shell.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_controller.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_info.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.modular/story/story_provider.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.net.oldhttp/url_body.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/component_controller.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/environment.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/environment_controller.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/launcher.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/loader.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.sys/runner.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.tracing.provider/provider.fidl -FILE: ../../../fuchsia/sdk/linux/fidl/fuchsia.ui.policy/presenter.fidl -FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/fdio.h -FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/io.h -FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/vfs.h -FILE: ../../../fuchsia/sdk/linux/pkg/fdio/include/lib/fdio/watcher.h -FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/include/lib/media/cpp/timeline_function.h -FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/include/lib/media/cpp/timeline_rate.h -FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/timeline_function.cc -FILE: ../../../fuchsia/sdk/linux/pkg/media_cpp_no_converters/timeline_rate.cc -FILE: ../../../fuchsia/sdk/linux/pkg/sync/include/lib/sync/completion.h -FILE: ../../../fuchsia/sdk/linux/pkg/sys_cpp/include/lib/sys/cpp/termination_reason.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/channel.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/event.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/eventpair.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/channel.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/event.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/eventpair.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/job.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/object.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/object_traits.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/port.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/process.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/socket.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/task.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/thread.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/time.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/vmar.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/include/lib/zx/vmo.h -FILE: ../../../fuchsia/sdk/linux/pkg/zx/job.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/port.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/process.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/socket.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/thread.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/vmar.cc -FILE: ../../../fuchsia/sdk/linux/pkg/zx/vmo.cc ----------------------------------------------------------------------------------------------------- -Copyright 2016 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index 7863937412956..6804f454850f1 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: d35b19eb9daf521e4c322dfe55a63a04 +Signature: e936724fefea8314b39c29cf43df4d3c UNUSED LICENSES: @@ -1054,45 +1054,6 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================================================== -==================================================================================================== -LIBRARY: angle -LIBRARY: tonic -ORIGIN: ../../../fuchsia/sdk/linux/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl.c -FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl.h -FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl_backend.h -FILE: ../../../third_party/tonic/typed_data/typed_list.cc ----------------------------------------------------------------------------------------------------- -Copyright 2019 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - ==================================================================================================== LIBRARY: angle LIBRARY: vulkan-validation-layers @@ -1570,6 +1531,43 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================================================== +==================================================================================================== +LIBRARY: angle +ORIGIN: ../../../fuchsia/sdk/linux/LICENSE +TYPE: LicenseType.bsd +FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl.c +FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl.h +FILE: ../../../third_party/angle/src/common/fuchsia_egl/fuchsia_egl_backend.h +---------------------------------------------------------------------------------------------------- +Copyright 2019 The Fuchsia Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +==================================================================================================== + ==================================================================================================== LIBRARY: angle ORIGIN: ../../../third_party/angle/LICENSE @@ -22311,201 +22309,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================================================== -==================================================================================================== -LIBRARY: tonic -ORIGIN: ../../../third_party/tonic/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../third_party/tonic/common/build_config.h -FILE: ../../../third_party/tonic/converter/dart_converter.cc -FILE: ../../../third_party/tonic/converter/dart_converter.h -FILE: ../../../third_party/tonic/dart_message_handler.cc -FILE: ../../../third_party/tonic/dart_message_handler.h -FILE: ../../../third_party/tonic/dart_microtask_queue.cc -FILE: ../../../third_party/tonic/dart_microtask_queue.h -FILE: ../../../third_party/tonic/file_loader/file_loader.cc -FILE: ../../../third_party/tonic/file_loader/file_loader.h -FILE: ../../../third_party/tonic/filesystem/filesystem/eintr_wrapper.h -FILE: ../../../third_party/tonic/filesystem/filesystem/file.cc -FILE: ../../../third_party/tonic/filesystem/filesystem/file.h -FILE: ../../../third_party/tonic/filesystem/filesystem/path.h -FILE: ../../../third_party/tonic/filesystem/filesystem/path_posix.cc -FILE: ../../../third_party/tonic/logging/dart_error.cc -FILE: ../../../third_party/tonic/logging/dart_error.h -FILE: ../../../third_party/tonic/logging/dart_invoke.cc -FILE: ../../../third_party/tonic/logging/dart_invoke.h -FILE: ../../../third_party/tonic/parsers/packages_map.cc -FILE: ../../../third_party/tonic/parsers/packages_map.h -FILE: ../../../third_party/tonic/scopes/dart_api_scope.h -FILE: ../../../third_party/tonic/scopes/dart_isolate_scope.cc -FILE: ../../../third_party/tonic/scopes/dart_isolate_scope.h -FILE: ../../../third_party/tonic/typed_data/dart_byte_data.h -FILE: ../../../third_party/tonic/typed_data/int32_list.h -FILE: ../../../third_party/tonic/typed_data/typed_list.h -FILE: ../../../third_party/tonic/typed_data/uint16_list.h -FILE: ../../../third_party/tonic/typed_data/uint8_list.h ----------------------------------------------------------------------------------------------------- -Copyright 2016 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - -==================================================================================================== -LIBRARY: tonic -ORIGIN: ../../../third_party/tonic/common/log.cc + ../../../third_party/tonic/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../third_party/tonic/common/log.cc -FILE: ../../../third_party/tonic/common/log.h -FILE: ../../../third_party/tonic/common/macros.h ----------------------------------------------------------------------------------------------------- -Copyright 2018 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - -==================================================================================================== -LIBRARY: tonic -ORIGIN: ../../../third_party/tonic/file_loader/file_loader_fuchsia.cc + ../../../third_party/tonic/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../third_party/tonic/dart_list.cc -FILE: ../../../third_party/tonic/dart_list.h -FILE: ../../../third_party/tonic/file_loader/file_loader_fuchsia.cc -FILE: ../../../third_party/tonic/file_loader/file_loader_posix.cc -FILE: ../../../third_party/tonic/file_loader/file_loader_win.cc -FILE: ../../../third_party/tonic/filesystem/filesystem/path_win.cc -FILE: ../../../third_party/tonic/filesystem/filesystem/portable_unistd.h -FILE: ../../../third_party/tonic/platform/platform_utils.h -FILE: ../../../third_party/tonic/platform/platform_utils_posix.cc -FILE: ../../../third_party/tonic/platform/platform_utils_win.cc ----------------------------------------------------------------------------------------------------- -Copyright 2017 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - -==================================================================================================== -LIBRARY: tonic -ORIGIN: ../../../third_party/tonic/typed_data/dart_byte_data.cc + ../../../third_party/tonic/LICENSE -TYPE: LicenseType.bsd -FILE: ../../../third_party/tonic/dart_args.h -FILE: ../../../third_party/tonic/dart_binding_macros.h -FILE: ../../../third_party/tonic/dart_class_library.cc -FILE: ../../../third_party/tonic/dart_class_library.h -FILE: ../../../third_party/tonic/dart_class_provider.cc -FILE: ../../../third_party/tonic/dart_class_provider.h -FILE: ../../../third_party/tonic/dart_library_natives.cc -FILE: ../../../third_party/tonic/dart_library_natives.h -FILE: ../../../third_party/tonic/dart_persistent_value.cc -FILE: ../../../third_party/tonic/dart_persistent_value.h -FILE: ../../../third_party/tonic/dart_state.cc -FILE: ../../../third_party/tonic/dart_state.h -FILE: ../../../third_party/tonic/dart_wrappable.cc -FILE: ../../../third_party/tonic/dart_wrappable.h -FILE: ../../../third_party/tonic/dart_wrapper_info.h -FILE: ../../../third_party/tonic/typed_data/dart_byte_data.cc -FILE: ../../../third_party/tonic/typed_data/float32_list.h -FILE: ../../../third_party/tonic/typed_data/float64_list.h ----------------------------------------------------------------------------------------------------- -Copyright 2015 The Fuchsia Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -==================================================================================================== - ==================================================================================================== LIBRARY: trace_event ORIGIN: ../../../third_party/angle/src/third_party/trace_event/trace_event.h + ../../../LICENSE @@ -23521,4 +23324,4 @@ freely, subject to the following restrictions: misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ==================================================================================================== -Total license count: 369 +Total license count: 365 diff --git a/fml/dart/BUILD.gn b/fml/dart/BUILD.gn index c6b3883955e81..4fa59932b73b5 100644 --- a/fml/dart/BUILD.gn +++ b/fml/dart/BUILD.gn @@ -14,6 +14,6 @@ source_set("dart") { public_deps = [ "$flutter_root/fml", "$flutter_root/runtime:libdart", - "//third_party/tonic", + "$flutter_root/third_party/tonic", ] } diff --git a/lib/io/BUILD.gn b/lib/io/BUILD.gn index 56c37705ef659..82ab55824f133 100644 --- a/lib/io/BUILD.gn +++ b/lib/io/BUILD.gn @@ -9,9 +9,9 @@ source_set("io") { ] deps = [ + "$flutter_root/third_party/tonic", "//third_party/dart/runtime:dart_api", "//third_party/dart/runtime/bin:dart_io_api", - "//third_party/tonic", ] configs += [ "//third_party/dart/runtime:dart_config" ] diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index 475cf60d01dac..2e6dc2bc92f57 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -117,10 +117,10 @@ source_set("ui") { "$flutter_root/flow", "$flutter_root/fml", "$flutter_root/runtime:test_font", + "$flutter_root/third_party/tonic", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/rapidjson", "//third_party/skia", - "//third_party/tonic", ] public_deps = [ diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 391653ed1539c..7b9fb56b400db 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -79,11 +79,11 @@ source_set("runtime") { "$flutter_root/fml", "$flutter_root/lib/io", "$flutter_root/lib/ui", + "$flutter_root/third_party/tonic", "$flutter_root/third_party/txt", "//third_party/dart/runtime:dart_api", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/skia", - "//third_party/tonic", ] # On Windows the engine finds the Dart snapshot data through symbols @@ -146,8 +146,8 @@ source_set("runtime_unittests_common") { "$flutter_root/lib/snapshot", "$flutter_root/shell/common", "$flutter_root/testing:dart", + "$flutter_root/third_party/tonic", "//third_party/skia", - "//third_party/tonic", ] } diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 3dc6e37f72341..77628e5f25f49 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -111,9 +111,9 @@ source_set("common") { public_deps = [ "$flutter_root/shell/version", + "$flutter_root/third_party/tonic", "$flutter_root/third_party/txt", "//third_party/rapidjson", - "//third_party/tonic", ] public_configs = [ "$flutter_root:config" ] @@ -135,8 +135,8 @@ template("shell_host_executable") { "$flutter_root/lib/snapshot", "$flutter_root/runtime", "$flutter_root/runtime:libdart", + "$flutter_root/third_party/tonic", "//third_party/skia", - "//third_party/tonic", ] public_configs = [ "$flutter_root:export_dynamic_symbols" ] diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 539b4d48cc045..56ad152e109d6 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -64,9 +64,9 @@ template("embedder_source_set") { "$flutter_root/lib/ui", "$flutter_root/runtime:libdart", "$flutter_root/shell/common", + "$flutter_root/third_party/tonic", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/skia", - "//third_party/tonic", ] public_configs += [ "$flutter_root:config" ] @@ -135,9 +135,9 @@ if (current_toolchain == host_toolchain) { "$flutter_root/testing:dart", "$flutter_root/testing:opengl", "$flutter_root/testing:skia", + "$flutter_root/third_party/tonic", "//third_party/dart/runtime/bin:elf_loader", "//third_party/skia", - "//third_party/tonic", ] } } diff --git a/shell/platform/fuchsia/dart-pkg/fuchsia/BUILD.gn b/shell/platform/fuchsia/dart-pkg/fuchsia/BUILD.gn index 96ee6bc04f076..36c37f3b8a4d8 100644 --- a/shell/platform/fuchsia/dart-pkg/fuchsia/BUILD.gn +++ b/shell/platform/fuchsia/dart-pkg/fuchsia/BUILD.gn @@ -22,10 +22,10 @@ source_set("sdk_ext") { deps = [ "$flutter_root/fml", + "$flutter_root/third_party/tonic", "$fuchsia_sdk_root/fidl:fuchsia.sys", "$fuchsia_sdk_root/pkg:async-cpp", "../zircon", - "//third_party/tonic", ] public_configs = [ ":sdk_ext_config" ] diff --git a/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn b/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn index dc43d91abbd3f..3c06d3f39c260 100644 --- a/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn +++ b/shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn @@ -23,11 +23,11 @@ source_set("zircon") { ] deps = [ + "$flutter_root/third_party/tonic", "$fuchsia_sdk_root/pkg:async-cpp", "$fuchsia_sdk_root/pkg:async-loop-cpp", "$fuchsia_sdk_root/pkg:fdio", "$fuchsia_sdk_root/pkg:zx", "//flutter/fml", - "//third_party/tonic", ] } diff --git a/shell/platform/fuchsia/dart_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/BUILD.gn index caff5a6667400..18f8976a5c37f 100644 --- a/shell/platform/fuchsia/dart_runner/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/BUILD.gn @@ -67,7 +67,7 @@ template("runner") { "$fuchsia_sdk_root/pkg:trace", "$fuchsia_sdk_root/pkg:trace-provider-so", "$fuchsia_sdk_root/pkg:vfs_cpp", - "//third_party/tonic", + "$flutter_root/third_party/tonic", ] + dart_deps + extra_deps } } diff --git a/shell/platform/fuchsia/flutter/engine_flutter_runner.gni b/shell/platform/fuchsia/flutter/engine_flutter_runner.gni index 3105bded8b50d..7bff2c855d7c8 100644 --- a/shell/platform/fuchsia/flutter/engine_flutter_runner.gni +++ b/shell/platform/fuchsia/flutter/engine_flutter_runner.gni @@ -125,7 +125,7 @@ template("flutter_runner") { "$fuchsia_sdk_root/pkg:vfs_cpp", "$fuchsia_sdk_root/pkg:zx", "//third_party/skia", - "//third_party/tonic", + "$flutter_root/third_party/tonic", ] + fuchsia_deps + flutter_deps + extra_deps # The flags below are needed so that Dart's CPU profiler can walk the diff --git a/shell/platform/fuchsia/flutter/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/platform_view_unittest.cc index a66e261f11130..11d563dfca774 100644 --- a/shell/platform/fuchsia/flutter/platform_view_unittest.cc +++ b/shell/platform/fuchsia/flutter/platform_view_unittest.cc @@ -17,7 +17,7 @@ #include "flutter/lib/ui/window/platform_message.h" #include "flutter/lib/ui/window/window.h" #include "fuchsia/ui/views/cpp/fidl.h" -#include "googletest/googletest/include/gtest/gtest.h" +#include "gtest/gtest.h" namespace flutter_runner_test::flutter_runner_a11y_test { diff --git a/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn b/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn index 928af158ea885..210fda1d19ee5 100644 --- a/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn +++ b/shell/platform/fuchsia/runtime/dart/utils/BUILD.gn @@ -43,7 +43,7 @@ template("make_utils") { "$fuchsia_sdk_root/pkg:trace", "$fuchsia_sdk_root/pkg:vfs_cpp", "$fuchsia_sdk_root/pkg:zx", - "//third_party/tonic", + "$flutter_root/third_party/tonic", ] public_configs = [ ":utils_config" ] diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn index 9b3bced2c268f..5829cd8f7deb5 100644 --- a/shell/testing/BUILD.gn +++ b/shell/testing/BUILD.gn @@ -22,10 +22,10 @@ executable("testing") { "$flutter_root/fml", "$flutter_root/lib/snapshot", "$flutter_root/shell/common", + "$flutter_root/third_party/tonic", "//third_party/dart/runtime:libdart_jit", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/skia", - "//third_party/tonic", ] if (is_fuchsia) { diff --git a/testing/BUILD.gn b/testing/BUILD.gn index 8bf9d7bc3922f..ad83d23e63fbf 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn @@ -46,7 +46,7 @@ source_set("dart") { public_deps = [ ":testing", "$flutter_root/runtime:libdart", - "//third_party/tonic", + "$flutter_root/third_party/tonic", ] } diff --git a/third_party/tonic/.clang-format b/third_party/tonic/.clang-format new file mode 100644 index 0000000000000..6fdf1dc888cb6 --- /dev/null +++ b/third_party/tonic/.clang-format @@ -0,0 +1,8 @@ +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Chromium +# This defaults to 'Auto'. Explicitly set it for a while, so that +# 'vector >' in existing files gets formatted to +# 'vector>'. ('Auto' means that clang-format will only use +# 'int>>' if the file already contains at least one such instance.) +Standard: Cpp11 diff --git a/third_party/tonic/AUTHORS b/third_party/tonic/AUTHORS new file mode 100644 index 0000000000000..4c6155877e153 --- /dev/null +++ b/third_party/tonic/AUTHORS @@ -0,0 +1,9 @@ +# This is the list of Fuchsia Authors. + +# Names should be added to this file as one of +# Organization's name +# Individual's name +# Individual's name + +Google Inc. +The Chromium Authors diff --git a/third_party/tonic/BUILD.gn b/third_party/tonic/BUILD.gn new file mode 100644 index 0000000000000..b51517a63948f --- /dev/null +++ b/third_party/tonic/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config("config") { + include_dirs = [ + "$flutter_root/third_party", + "$flutter_root", + ] +} + +source_set("tonic") { + sources = [ + "dart_args.h", + "dart_binding_macros.h", + "dart_class_library.cc", + "dart_class_library.h", + "dart_class_provider.cc", + "dart_class_provider.h", + "dart_library_natives.cc", + "dart_library_natives.h", + "dart_list.cc", + "dart_list.h", + "dart_message_handler.cc", + "dart_message_handler.h", + "dart_microtask_queue.cc", + "dart_microtask_queue.h", + "dart_persistent_value.cc", + "dart_persistent_value.h", + "dart_state.cc", + "dart_state.h", + "dart_wrappable.cc", + "dart_wrappable.h", + "dart_wrapper_info.h", + ] + + public_deps = [ + "common", + "converter", + "file_loader", + "logging", + "platform", + "scopes", + "typed_data", + "//third_party/dart/runtime:dart_api", + ] + + public_configs = [ ":config" ] +} diff --git a/third_party/tonic/PATENTS b/third_party/tonic/PATENTS new file mode 100644 index 0000000000000..2746e78d1beff --- /dev/null +++ b/third_party/tonic/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Fuchsia project. + +Google hereby grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this +section) patent license to make, have made, use, offer to sell, sell, +import, transfer, and otherwise run, modify and propagate the contents +of this implementation of Fuchsia, where such license applies only to +those patent claims, both currently owned by Google and acquired in +the future, licensable by Google that are necessarily infringed by +this implementation. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute +or order or agree to the institution of patent litigation or any other +patent enforcement activity against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that this +implementation of Fuchsia constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of +Fuchsia shall terminate as of the date such litigation is filed. diff --git a/third_party/tonic/README.md b/third_party/tonic/README.md new file mode 100644 index 0000000000000..f4889e3254664 --- /dev/null +++ b/third_party/tonic/README.md @@ -0,0 +1,3 @@ +# Tonic + +A collection of C++ utilities for working with the DartVM API. diff --git a/third_party/tonic/common/BUILD.gn b/third_party/tonic/common/BUILD.gn new file mode 100644 index 0000000000000..2af823348c554 --- /dev/null +++ b/third_party/tonic/common/BUILD.gn @@ -0,0 +1,16 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("common") { + visibility = [ "../*" ] + + public_configs = [ "../:config" ] + + sources = [ + "build_config.h", + "log.cc", + "log.h", + "macros.h", + ] +} diff --git a/third_party/tonic/common/build_config.h b/third_party/tonic/common/build_config.h new file mode 100644 index 0000000000000..365808a1a78ed --- /dev/null +++ b/third_party/tonic/common/build_config.h @@ -0,0 +1,110 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file adds defines about the platform we're currently building on. +// Operating System: +// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) / +// OS_NACL (NACL_SFI or NACL_NONSFI) / OS_NACL_SFI / OS_NACL_NONSFI +// Compiler: +// COMPILER_MSVC / COMPILER_GCC +// Processor: +// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64) +// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS + +#ifndef TONIC_COMMON_BUILD_CONFIG_H_ +#define TONIC_COMMON_BUILD_CONFIG_H_ + +#if defined(__Fuchsia__) +#define OS_FUCHSIA 1 +#elif defined(ANDROID) +#define OS_ANDROID 1 +#elif defined(__APPLE__) +// only include TargetConditions after testing ANDROID as some android builds +// on mac don't have this header available and it's not needed unless the target +// is really mac/ios. +#include +#define OS_MACOSX 1 +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#define OS_IOS 1 +#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#elif defined(__linux__) +#define OS_LINUX 1 +// include a system header to pull in features.h for glibc/uclibc macros. +#include +#if defined(__GLIBC__) && !defined(__UCLIBC__) +// we really are using glibc, not uClibc pretending to be glibc +#define LIBC_GLIBC 1 +#endif +#elif defined(_WIN32) +#define OS_WIN 1 +#elif defined(__FreeBSD__) +#define OS_FREEBSD 1 +#elif defined(__OpenBSD__) +#define OS_OPENBSD 1 +#elif defined(__sun) +#define OS_SOLARIS 1 +#elif defined(__QNXNTO__) +#define OS_QNX 1 +#else +#error Please add support for your platform in tonic/common/build_config.h +#endif + +// For access to standard BSD features, use OS_BSD instead of a +// more specific macro. +#if defined(OS_FREEBSD) || defined(OS_OPENBSD) +#define OS_BSD 1 +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ + defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ + defined(OS_NACL) || defined(OS_QNX) +#define OS_POSIX 1 +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(_M_IX86) || defined(__i386__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARMEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__aarch64__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARM64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__pnacl__) +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__MIPSEL__) +#if defined(__LP64__) +#define ARCH_CPU_MIPS64_FAMILY 1 +#define ARCH_CPU_MIPS64EL 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#else +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPSEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#endif +#else +#error Please add support for your architecture in build/build_config.h +#endif + +#endif // TONIC_COMMON_BUILD_CONFIG_H_ diff --git a/third_party/tonic/common/log.cc b/third_party/tonic/common/log.cc new file mode 100644 index 0000000000000..b1dfd4a015d2f --- /dev/null +++ b/third_party/tonic/common/log.cc @@ -0,0 +1,48 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/common/log.h" + +#include +#include +#include + +namespace tonic { + +namespace { + +std::function log_handler; + +} // namespace + +void Log(const char* format, ...) { + va_list ap; + va_start(ap, format); + int result = vsnprintf(nullptr, 0, format, ap); + va_end(ap); + + if (result < 0) + return; + + int size = result + 1; + std::unique_ptr message(new char[size]); + va_start(ap, format); + result = vsnprintf(message.get(), size, format, ap); + va_end(ap); + + if (result < 0) + return; + + if (log_handler) { + log_handler(message.get()); + } else { + printf("%s\n", message.get()); + } +} + +void SetLogHandler(std::function handler) { + log_handler = handler; +} + +} // namespace tonic diff --git a/third_party/tonic/common/log.h b/third_party/tonic/common/log.h new file mode 100644 index 0000000000000..71ad6e4507092 --- /dev/null +++ b/third_party/tonic/common/log.h @@ -0,0 +1,18 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TONIC_COMMON_LOG_H_ +#define TONIC_COMMON_LOG_H_ + +#include + +namespace tonic { + +void Log(const char* format, ...); + +void SetLogHandler(std::function handler); + +} // namespace tonic + +#endif // TONIC_COMMON_LOG_H_ diff --git a/third_party/tonic/common/macros.h b/third_party/tonic/common/macros.h new file mode 100644 index 0000000000000..2f383c9b2d36e --- /dev/null +++ b/third_party/tonic/common/macros.h @@ -0,0 +1,37 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TONIC_COMMON_MACROS_H_ +#define TONIC_COMMON_MACROS_H_ + +#include +#include +#include + +#include "tonic/common/log.h" + +#define TONIC_DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete; + +#define TONIC_DISALLOW_ASSIGN(TypeName) \ + void operator=(const TypeName&) = delete; + +#define TONIC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TONIC_DISALLOW_COPY(TypeName) \ + TONIC_DISALLOW_ASSIGN(TypeName) + +#define TONIC_CHECK(condition) \ + { \ + if (!(condition)) { \ + tonic::Log("assertion failed " #condition); \ + abort(); \ + } \ + } + +#ifndef NDEBUG +#define TONIC_DCHECK TONIC_CHECK +#else // NDEBUG +#define TONIC_DCHECK (void) +#endif // NDEBUG + +#endif // TONIC_COMMON_MACROS_H_ diff --git a/third_party/tonic/converter/BUILD.gn b/third_party/tonic/converter/BUILD.gn new file mode 100644 index 0000000000000..cb4c64b88d807 --- /dev/null +++ b/third_party/tonic/converter/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("converter") { + visibility = [ "../*" ] + + configs += [ "../:config" ] + + sources = [ + "dart_converter.cc", + "dart_converter.h", + ] + + deps = [ + "../common", + ] + + public_deps = [ + "//third_party/dart/runtime:dart_api", + ] +} diff --git a/third_party/tonic/converter/dart_converter.cc b/third_party/tonic/converter/dart_converter.cc new file mode 100644 index 0000000000000..73ce9b6363207 --- /dev/null +++ b/third_party/tonic/converter/dart_converter.cc @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/converter/dart_converter.h" + +// This file exists to ensure dart_converter.h doesn't miss any dependencies. diff --git a/third_party/tonic/converter/dart_converter.h b/third_party/tonic/converter/dart_converter.h new file mode 100644 index 0000000000000..6693615a2d98d --- /dev/null +++ b/third_party/tonic/converter/dart_converter.h @@ -0,0 +1,396 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_CONVERTER_TONIC_DART_CONVERTER_H_ +#define LIB_CONVERTER_TONIC_DART_CONVERTER_H_ + +#include +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/common/macros.h" + +namespace tonic { + +// DartConvert converts types back and forth from Sky to Dart. The template +// parameter |T| determines what kind of type conversion to perform. +template +struct DartConverter {}; + +// This is to work around the fact that typedefs do not create new types. If you +// have a typedef, and want it to use a different converter, specialize this +// template and override the types here. +// Ex: +// typedef int ColorType; // Want to use a different converter. +// class ColorConverterType {}; // Dummy type. +// template<> struct DartConvertType { +// using ConverterType = ColorConverterType; +// using ValueType = ColorType; +// }; +template +struct DartConverterTypes { + using ConverterType = T; + using ValueType = T; +}; + +//////////////////////////////////////////////////////////////////////////////// +// Boolean + +template <> +struct DartConverter { + static Dart_Handle ToDart(bool val) { return Dart_NewBoolean(val); } + + static void SetReturnValue(Dart_NativeArguments args, bool val) { + Dart_SetBooleanReturnValue(args, val); + } + + static bool FromDart(Dart_Handle handle) { + bool result = 0; + Dart_BooleanValue(handle, &result); + return result; + } + + static bool FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + bool result = false; + Dart_GetNativeBooleanArgument(args, index, &result); + return result; + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Numbers + +template +struct DartConverterInteger { + static Dart_Handle ToDart(T val) { return Dart_NewInteger(val); } + + static void SetReturnValue(Dart_NativeArguments args, T val) { + Dart_SetIntegerReturnValue(args, val); + } + + static T FromDart(Dart_Handle handle) { + int64_t result = 0; + Dart_IntegerToInt64(handle, &result); + return static_cast(result); + } + + static T FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + int64_t result = 0; + Dart_GetNativeIntegerArgument(args, index, &result); + return static_cast(result); + } +}; + +template <> +struct DartConverter : public DartConverterInteger {}; + +template <> +struct DartConverter : public DartConverterInteger {}; + +template <> +struct DartConverter : public DartConverterInteger {}; + +template <> +struct DartConverter : public DartConverterInteger {}; + +template <> +struct DartConverter + : public DartConverterInteger {}; + +template <> +struct DartConverter { + // TODO(abarth): The Dart VM API doesn't yet have an entry-point for + // an unsigned 64-bit type. We will need to add a Dart API for + // constructing an integer from uint64_t. + // + // (In the meantime, we have asserts below to check that we're never + // converting values that have the 64th bit set.) + + static Dart_Handle ToDart(unsigned long long val) { + TONIC_DCHECK(val <= 0x7fffffffffffffffLL); + return Dart_NewInteger(static_cast(val)); + } + + static void SetReturnValue(Dart_NativeArguments args, + unsigned long long val) { + TONIC_DCHECK(val <= 0x7fffffffffffffffLL); + Dart_SetIntegerReturnValue(args, val); + } + + static unsigned long long FromDart(Dart_Handle handle) { + int64_t result = 0; + Dart_IntegerToInt64(handle, &result); + return result; + } + + static unsigned long long FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + int64_t result = 0; + Dart_GetNativeIntegerArgument(args, index, &result); + return result; + } +}; + +template +struct DartConverterFloatingPoint { + static Dart_Handle ToDart(T val) { return Dart_NewDouble(val); } + + static void SetReturnValue(Dart_NativeArguments args, T val) { + Dart_SetDoubleReturnValue(args, val); + } + + static T FromDart(Dart_Handle handle) { + double result = 0; + Dart_DoubleValue(handle, &result); + return result; + } + + static T FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + double result = 0; + Dart_GetNativeDoubleArgument(args, index, &result); + return result; + } +}; + +template <> +struct DartConverter : public DartConverterFloatingPoint {}; + +template <> +struct DartConverter : public DartConverterFloatingPoint {}; + +//////////////////////////////////////////////////////////////////////////////// +// Enum Classes + +template +struct DartConverter::value>::type> { + static Dart_Handle ToDart(T val) { + return Dart_NewInteger( + static_cast::type>(val)); + } + + static void SetReturnValue(Dart_NativeArguments args, T val) { + Dart_SetIntegerReturnValue( + args, static_cast::type>(val)); + } + + static T FromDart(Dart_Handle handle) { + int64_t result = 0; + Dart_IntegerToInt64(handle, &result); + return static_cast(result); + } + + static T FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + int64_t result = 0; + Dart_GetNativeIntegerArgument(args, index, &result); + return static_cast(result); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Strings + +template <> +struct DartConverter { + static Dart_Handle ToDart(const std::string& val) { + return Dart_NewStringFromUTF8(reinterpret_cast(val.data()), + val.length()); + } + + static void SetReturnValue(Dart_NativeArguments args, + const std::string& val) { + Dart_SetReturnValue(args, ToDart(val)); + } + + static std::string FromDart(Dart_Handle handle) { + uint8_t* data = nullptr; + intptr_t length = 0; + if (Dart_IsError(Dart_StringToUTF8(handle, &data, &length))) + return std::string(); + return std::string(reinterpret_cast(data), length); + } + + static std::string FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + return FromDart(Dart_GetNativeArgument(args, index)); + } +}; + +template <> +struct DartConverter { + static Dart_Handle ToDart(const std::u16string& val) { + return Dart_NewStringFromUTF16( + reinterpret_cast(val.data()), val.length()); + } + + static void SetReturnValue(Dart_NativeArguments args, + const std::u16string& val) { + Dart_SetReturnValue(args, ToDart(val)); + } + + static std::u16string FromDart(Dart_Handle handle) { + intptr_t length = 0; + Dart_StringLength(handle, &length); + std::vector data(length); + Dart_StringToUTF16(handle, data.data(), &length); + return std::u16string(reinterpret_cast(data.data()), length); + } + + static std::u16string FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + return FromDart(Dart_GetNativeArgument(args, index)); + } +}; + +template <> +struct DartConverter { + static Dart_Handle ToDart(const char* val) { + return Dart_NewStringFromCString(val); + } + + static void SetReturnValue(Dart_NativeArguments args, const char* val) { + Dart_SetReturnValue(args, ToDart(val)); + } + + static const char* FromDart(Dart_Handle handle) { + const char* result = nullptr; + Dart_StringToCString(handle, &result); + return result; + } + + static const char* FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + return FromDart(Dart_GetNativeArgument(args, index)); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Collections + +template +struct DartListFactory { + static Dart_Handle NewList(intptr_t length) { return Dart_NewList(length); } +}; + +template <> +struct DartListFactory { + static Dart_Handle NewList(intptr_t length) { + return Dart_NewListOf(Dart_CoreType_String, length); + } +}; + +template +struct DartConverter> { + using ValueType = typename DartConverterTypes::ValueType; + using ConverterType = typename DartConverterTypes::ConverterType; + + static Dart_Handle ToDart(const std::vector& val) { + Dart_Handle list = DartListFactory::NewList(val.size()); + if (Dart_IsError(list)) + return list; + for (size_t i = 0; i < val.size(); i++) { + Dart_Handle result = + Dart_ListSetAt(list, i, DartConverter::ToDart(val[i])); + if (Dart_IsError(result)) + return result; + } + return list; + } + + static void SetReturnValue(Dart_NativeArguments args, + const std::vector& val) { + Dart_SetReturnValue(args, ToDart(val)); + } + + static std::vector FromDart(Dart_Handle handle) { + std::vector result; + + if (!Dart_IsList(handle)) + return result; + + intptr_t length = 0; + Dart_ListLength(handle, &length); + + if (length == 0) + return result; + + result.reserve(length); + + std::vector items(length); + Dart_Handle items_result = + Dart_ListGetRange(handle, 0, length, items.data()); + TONIC_DCHECK(!Dart_IsError(items_result)); + + for (intptr_t i = 0; i < length; ++i) { + TONIC_DCHECK(items[i]); + result.push_back(DartConverter::FromDart(items[i])); + } + return result; + } + + static std::vector FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + return FromDart(Dart_GetNativeArgument(args, index)); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Dart_Handle + +template <> +struct DartConverter { + static Dart_Handle ToDart(Dart_Handle val) { return val; } + + static void SetReturnValue(Dart_NativeArguments args, Dart_Handle val) { + Dart_SetReturnValue(args, val); + } + + static Dart_Handle FromDart(Dart_Handle handle) { return handle; } + + static Dart_Handle FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + return Dart_GetNativeArgument(args, index); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Convience wrappers using type inference + +template +Dart_Handle ToDart(const T& object) { + return DartConverter::ToDart(object); +} + +//////////////////////////////////////////////////////////////////////////////// +// std::string support + +inline Dart_Handle StdStringToDart(const std::string& val) { + return DartConverter::ToDart(val); +} + +inline std::string StdStringFromDart(Dart_Handle handle) { + return DartConverter::FromDart(handle); +} + +// Alias Dart_NewStringFromCString for less typing. +inline Dart_Handle ToDart(const char* val) { + return Dart_NewStringFromCString(val); +} + +} // namespace tonic + +#endif // LIB_CONVERTER_TONIC_DART_CONVERTER_H_ diff --git a/third_party/tonic/dart_args.h b/third_party/tonic/dart_args.h new file mode 100644 index 0000000000000..3d6f9ddd5908a --- /dev/null +++ b/third_party/tonic/dart_args.h @@ -0,0 +1,234 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_ARGS_H_ +#define LIB_TONIC_DART_ARGS_H_ + +#include +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/converter/dart_converter.h" +#include "tonic/dart_wrappable.h" + +namespace tonic { + +class DartArgIterator { + public: + DartArgIterator(Dart_NativeArguments args, int start_index = 1) + : args_(args), index_(start_index), had_exception_(false) {} + + template + T GetNext() { + if (had_exception_) + return T(); + Dart_Handle exception = nullptr; + T arg = DartConverter::FromArguments(args_, index_++, exception); + if (exception) { + had_exception_ = true; + Dart_ThrowException(exception); + } + return arg; + } + + bool had_exception() const { return had_exception_; } + + Dart_NativeArguments args() const { return args_; } + + private: + Dart_NativeArguments args_; + int index_; + bool had_exception_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartArgIterator); +}; + +// Classes for generating and storing an argument pack of integer indices +// (based on well-known "indices trick", see: http://goo.gl/bKKojn): +template +struct IndicesHolder {}; + +template +struct IndicesGenerator { + using type = typename IndicesGenerator::type; +}; + +template +struct IndicesGenerator<0, indices...> { + using type = IndicesHolder; +}; + +template +class IndicesForSignature {}; + +template +struct IndicesForSignature { + static const size_t count = sizeof...(ArgTypes); + using type = typename IndicesGenerator::type; +}; + +template +struct IndicesForSignature { + static const size_t count = sizeof...(ArgTypes); + using type = typename IndicesGenerator::type; +}; + +template +struct IndicesForSignature { + static const size_t count = sizeof...(ArgTypes); + using type = typename IndicesGenerator::type; +}; + +template +struct DartArgHolder { + using ValueType = typename std::remove_const< + typename std::remove_reference::type>::type; + + ValueType value; + + explicit DartArgHolder(DartArgIterator* it) + : value(it->GetNext()) {} +}; + +template +void DartReturn(T result, Dart_NativeArguments args) { + DartConverter::SetReturnValue(args, std::move(result)); +} + +template +class DartDispatcher {}; + +template +struct DartDispatcher, void (*)(ArgTypes...)> + : public DartArgHolder... { + using FunctionPtr = void (*)(ArgTypes...); + + DartArgIterator* it_; + + explicit DartDispatcher(DartArgIterator* it) + : DartArgHolder(it)..., it_(it) {} + + void Dispatch(FunctionPtr func) { + (*func)(DartArgHolder::value...); + } +}; + +template +struct DartDispatcher, ResultType (*)(ArgTypes...)> + : public DartArgHolder... { + using FunctionPtr = ResultType (*)(ArgTypes...); + using CtorResultType = ResultType; + + DartArgIterator* it_; + + explicit DartDispatcher(DartArgIterator* it) + : DartArgHolder(it)..., it_(it) {} + + void Dispatch(FunctionPtr func) { + DartReturn((*func)(DartArgHolder::value...), + it_->args()); + } + + ResultType DispatchCtor(FunctionPtr func) { + return (*func)(DartArgHolder::value...); + } +}; + +template +struct DartDispatcher, void (C::*)(ArgTypes...)> + : public DartArgHolder... { + using FunctionPtr = void (C::*)(ArgTypes...); + + DartArgIterator* it_; + + explicit DartDispatcher(DartArgIterator* it) + : DartArgHolder(it)..., it_(it) {} + + void Dispatch(FunctionPtr func) { + (GetReceiver(it_->args())->*func)( + DartArgHolder::value...); + } +}; + +template +struct DartDispatcher, + ReturnType (C::*)(ArgTypes...) const> + : public DartArgHolder... { + using FunctionPtr = ReturnType (C::*)(ArgTypes...) const; + + DartArgIterator* it_; + + explicit DartDispatcher(DartArgIterator* it) + : DartArgHolder(it)..., it_(it) {} + + void Dispatch(FunctionPtr func) { + DartReturn((GetReceiver(it_->args())->*func)( + DartArgHolder::value...), + it_->args()); + } +}; + +template +struct DartDispatcher, ResultType (C::*)(ArgTypes...)> + : public DartArgHolder... { + using FunctionPtr = ResultType (C::*)(ArgTypes...); + + DartArgIterator* it_; + + explicit DartDispatcher(DartArgIterator* it) + : DartArgHolder(it)..., it_(it) {} + + void Dispatch(FunctionPtr func) { + DartReturn((GetReceiver(it_->args())->*func)( + DartArgHolder::value...), + it_->args()); + } +}; + +template +void DartCall(Sig func, Dart_NativeArguments args) { + DartArgIterator it(args); + using Indices = typename IndicesForSignature::type; + DartDispatcher decoder(&it); + if (it.had_exception()) + return; + decoder.Dispatch(func); +} + +template +void DartCallStatic(Sig func, Dart_NativeArguments args) { + DartArgIterator it(args, 0); + using Indices = typename IndicesForSignature::type; + DartDispatcher decoder(&it); + if (it.had_exception()) + return; + decoder.Dispatch(func); +} + +template +void DartCallConstructor(Sig func, Dart_NativeArguments args) { + DartArgIterator it(args); + using Indices = typename IndicesForSignature::type; + using Wrappable = typename DartDispatcher::CtorResultType; + Wrappable wrappable; + { + DartDispatcher decoder(&it); + if (it.had_exception()) + return; + wrappable = decoder.DispatchCtor(func); + } + wrappable->AssociateWithDartWrapper(args); +} + +} // namespace tonic + +#endif // LIB_TONIC_DART_ARGS_H_ diff --git a/third_party/tonic/dart_binding_macros.h b/third_party/tonic/dart_binding_macros.h new file mode 100644 index 0000000000000..a54c6d2b1a708 --- /dev/null +++ b/third_party/tonic/dart_binding_macros.h @@ -0,0 +1,36 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_BINDING_MACROS_H_ +#define LIB_TONIC_DART_BINDING_MACROS_H_ + +#include "tonic/dart_args.h" + +#define DART_NATIVE_CALLBACK(CLASS, METHOD) \ + static void CLASS##_##METHOD(Dart_NativeArguments args) { \ + tonic::DartCall(&CLASS::METHOD, args); \ + } + +#define DART_NATIVE_CALLBACK_STATIC(CLASS, METHOD) \ + static void CLASS##_##METHOD(Dart_NativeArguments args) { \ + tonic::DartCallStatic(&CLASS::METHOD, args); \ + } + +#define DART_REGISTER_NATIVE(CLASS, METHOD) \ + {#CLASS "_" #METHOD, CLASS##_##METHOD, \ + tonic::IndicesForSignature::count + 1, true}, + +#define DART_REGISTER_NATIVE_STATIC(CLASS, METHOD) \ + { \ +#CLASS "_" #METHOD, CLASS##_##METHOD, \ + tonic::IndicesForSignature < decltype(&CLASS::METHOD)> ::count, true \ + } + +#define DART_BIND_ALL(CLASS, FOR_EACH) \ + FOR_EACH(DART_NATIVE_CALLBACK) \ + void CLASS::RegisterNatives(tonic::DartLibraryNatives* natives) { \ + natives->Register({FOR_EACH(DART_REGISTER_NATIVE)}); \ + } + +#endif // LIB_TONIC_DART_BINDING_MACROS_H_ diff --git a/third_party/tonic/dart_class_library.cc b/third_party/tonic/dart_class_library.cc new file mode 100644 index 0000000000000..80201bba51a89 --- /dev/null +++ b/third_party/tonic/dart_class_library.cc @@ -0,0 +1,55 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_class_library.h" + +#include "tonic/common/macros.h" +#include "tonic/dart_wrapper_info.h" + +namespace tonic { + +DartClassLibrary::DartClassLibrary() {} + +DartClassLibrary::~DartClassLibrary() { + // Note that we don't need to delete these persistent handles because this + // object lives as long as the isolate. The handles will get deleted when the + // isolate dies. +} + +Dart_PersistentHandle DartClassLibrary::GetClass(const DartWrapperInfo& info) { + const auto& result = info_cache_.insert(std::make_pair(&info, nullptr)); + if (!result.second) { + // Already present, return value. + return result.first->second; + } + return GetAndCacheClass(info.library_name, info.interface_name, + &result.first->second); +} + +Dart_PersistentHandle DartClassLibrary::GetClass( + const std::string& library_name, + const std::string& interface_name) { + auto key = std::make_pair(library_name, interface_name); + const auto& result = name_cache_.insert(std::make_pair(key, nullptr)); + if (!result.second) { + // Already present, return value. + return result.first->second; + } + return GetAndCacheClass(library_name.c_str(), interface_name.c_str(), + &result.first->second); +} + +Dart_PersistentHandle DartClassLibrary::GetAndCacheClass( + const char* library_name, + const char* interface_name, + Dart_PersistentHandle* cache_slot) { + auto it = providers_.find(library_name); + TONIC_DCHECK(it != providers_.end()); + + Dart_Handle class_handle = it->second->GetClassByName(interface_name); + *cache_slot = Dart_NewPersistentHandle(class_handle); + return *cache_slot; +} + +} // namespace tonic diff --git a/third_party/tonic/dart_class_library.h b/third_party/tonic/dart_class_library.h new file mode 100644 index 0000000000000..34a426b7a7c50 --- /dev/null +++ b/third_party/tonic/dart_class_library.h @@ -0,0 +1,60 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_CLASS_LIBRARY_H_ +#define LIB_TONIC_DART_CLASS_LIBRARY_H_ + +#include +#include +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/dart_class_provider.h" + +namespace tonic { +struct DartWrapperInfo; + +class DartClassLibrary { + public: + explicit DartClassLibrary(); + ~DartClassLibrary(); + + void add_provider(const std::string& library_name, + std::unique_ptr provider) { + providers_.insert(std::make_pair(library_name, std::move(provider))); + } + + Dart_PersistentHandle GetClass(const DartWrapperInfo& info); + Dart_PersistentHandle GetClass(const std::string& library_name, + const std::string& interface_name); + + private: + Dart_PersistentHandle GetAndCacheClass(const char* library_name, + const char* interface_name, + Dart_PersistentHandle* cache_slot); + + // TODO(abarth): Move this class somewhere more general. + // We should also use a more reasonable hash function, such as described in + // http://www.boost.org/doc/libs/1_35_0/doc/html/boost/hash_combine_id241013.html + struct PairHasher { + template + std::size_t operator()(const std::pair& pair) const { + return std::hash()(pair.first) + 37 * std::hash()(pair.second); + } + }; + + std::unordered_map> + providers_; + std::unordered_map info_cache_; + std::unordered_map, + Dart_PersistentHandle, + PairHasher> + name_cache_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartClassLibrary); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_CLASS_LIBRARY_H_ diff --git a/third_party/tonic/dart_class_provider.cc b/third_party/tonic/dart_class_provider.cc new file mode 100644 index 0000000000000..2d9ca00642fbd --- /dev/null +++ b/third_party/tonic/dart_class_provider.cc @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_class_provider.h" + +#include "tonic/converter/dart_converter.h" +#include "tonic/dart_state.h" +#include "tonic/logging/dart_error.h" + +namespace tonic { + +DartClassProvider::DartClassProvider(DartState* dart_state, + const char* class_name) { + library_.Set(dart_state, Dart_LookupLibrary(ToDart(class_name))); +} + +DartClassProvider::~DartClassProvider() {} + +Dart_Handle DartClassProvider::GetClassByName(const char* class_name) { + Dart_Handle name_handle = ToDart(class_name); + Dart_Handle class_handle = + Dart_GetType(library_.value(), name_handle, 0, nullptr); + TONIC_DCHECK(!Dart_IsError(class_handle)); + return class_handle; +} + +} // namespace tonic diff --git a/third_party/tonic/dart_class_provider.h b/third_party/tonic/dart_class_provider.h new file mode 100644 index 0000000000000..92606f7103a17 --- /dev/null +++ b/third_party/tonic/dart_class_provider.h @@ -0,0 +1,29 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_CLASS_PROVIDER_H_ +#define LIB_TONIC_DART_CLASS_PROVIDER_H_ + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/dart_persistent_value.h" + +namespace tonic { +class DartState; + +class DartClassProvider { + public: + DartClassProvider(DartState* dart_state, const char* library_name); + ~DartClassProvider(); + + Dart_Handle GetClassByName(const char* class_name); + + private: + DartPersistentValue library_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartClassProvider); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_CLASS_PROVIDER_H_ diff --git a/third_party/tonic/dart_library_natives.cc b/third_party/tonic/dart_library_natives.cc new file mode 100644 index 0000000000000..244da63a0958a --- /dev/null +++ b/third_party/tonic/dart_library_natives.cc @@ -0,0 +1,45 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_library_natives.h" + +#include "tonic/converter/dart_converter.h" + +namespace tonic { + +DartLibraryNatives::DartLibraryNatives() {} + +DartLibraryNatives::~DartLibraryNatives() {} + +void DartLibraryNatives::Register(std::initializer_list entries) { + for (const Entry& entry : entries) { + symbols_.emplace(entry.native_function, entry.symbol); + entries_.emplace(entry.symbol, entry); + } +} + +Dart_NativeFunction DartLibraryNatives::GetNativeFunction( + Dart_Handle name, + int argument_count, + bool* auto_setup_scope) { + std::string name_string = StdStringFromDart(name); + auto it = entries_.find(name_string); + if (it == entries_.end()) + return nullptr; + const Entry& entry = it->second; + if (entry.argument_count != argument_count) + return nullptr; + *auto_setup_scope = entry.auto_setup_scope; + return entry.native_function; +} + +const uint8_t* DartLibraryNatives::GetSymbol( + Dart_NativeFunction native_function) { + auto it = symbols_.find(native_function); + if (it == symbols_.end()) + return nullptr; + return reinterpret_cast(it->second); +} + +} // namespace tonic diff --git a/third_party/tonic/dart_library_natives.h b/third_party/tonic/dart_library_natives.h new file mode 100644 index 0000000000000..d10837894d854 --- /dev/null +++ b/third_party/tonic/dart_library_natives.h @@ -0,0 +1,45 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_LIBRARY_NATIVES_H_ +#define LIB_TONIC_DART_LIBRARY_NATIVES_H_ + +#include +#include +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/common/macros.h" + +namespace tonic { + +class DartLibraryNatives { + public: + DartLibraryNatives(); + ~DartLibraryNatives(); + + struct Entry { + const char* symbol; + Dart_NativeFunction native_function; + int argument_count; + bool auto_setup_scope; + }; + + void Register(std::initializer_list entries); + + Dart_NativeFunction GetNativeFunction(Dart_Handle name, + int argument_count, + bool* auto_setup_scope); + const uint8_t* GetSymbol(Dart_NativeFunction native_function); + + private: + std::unordered_map entries_; + std::unordered_map symbols_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartLibraryNatives); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_LIBRARY_NATIVES_H_ diff --git a/third_party/tonic/dart_list.cc b/third_party/tonic/dart_list.cc new file mode 100644 index 0000000000000..095b45ade5364 --- /dev/null +++ b/third_party/tonic/dart_list.cc @@ -0,0 +1,50 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_list.h" + +#include "tonic/logging/dart_error.h" + +namespace tonic { + +DartList::DartList(Dart_Handle dart_handle) : dart_handle_(dart_handle) { + TONIC_DCHECK(Dart_IsList(dart_handle_)); + + intptr_t length; + is_valid_ = !LogIfError(Dart_ListLength(dart_handle_, &length)); + size_ = length; +} + +DartList::DartList() { + dart_handle_ = Dart_Null(); + size_ = 0; + is_valid_ = false; +} + +DartList::DartList(DartList&& other) + : dart_handle_(other.dart_handle_), + size_(other.size_), + is_valid_(other.is_valid_) { + other.dart_handle_ = nullptr; + other.size_ = 0; + other.is_valid_ = false; +} + +void DartList::Set(size_t index, Dart_Handle value) { + LogIfError(Dart_ListSetAt(dart_handle_, index, value)); +} + +DartList DartConverter::FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + Dart_Handle list = Dart_GetNativeArgument(args, index); + if (LogIfError(list) || !Dart_IsList(list)) { + exception = Dart_NewApiError("Invalid Argument"); + return DartList(); + } + + return DartList(list); +} + +} // namespace tonic diff --git a/third_party/tonic/dart_list.h b/third_party/tonic/dart_list.h new file mode 100644 index 0000000000000..fbfc152d90fa2 --- /dev/null +++ b/third_party/tonic/dart_list.h @@ -0,0 +1,59 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_LIST_H_ +#define LIB_TONIC_DART_LIST_H_ + +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/converter/dart_converter.h" + +namespace tonic { + +class DartList { + public: + DartList(DartList&& other); + + void Set(size_t index, Dart_Handle value); + Dart_Handle Get(size_t index); + + template + void Set(size_t index, T value) { + Set(index, DartConverter::ToDart(value)); + } + + template + T Get(size_t index) { + return DartConverter::FromDart(Get(index)); + } + + Dart_Handle dart_handle() const { return dart_handle_; } + size_t size() const { return size_; } + bool is_valid() const { return is_valid_; } + + explicit operator bool() const { return is_valid_; } + + private: + explicit DartList(Dart_Handle list); + friend struct DartConverter; + + DartList(); + Dart_Handle dart_handle_; + size_t size_; + bool is_valid_; + + DartList(const DartList& other) = delete; +}; + +template <> +struct DartConverter { + static DartList FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_LIST_H_ diff --git a/third_party/tonic/dart_message_handler.cc b/third_party/tonic/dart_message_handler.cc new file mode 100644 index 0000000000000..4119d54ec34c1 --- /dev/null +++ b/third_party/tonic/dart_message_handler.cc @@ -0,0 +1,149 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_message_handler.h" + +#include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/dart/runtime/include/dart_native_api.h" +#include "third_party/dart/runtime/include/dart_tools_api.h" +#include "tonic/common/macros.h" +#include "tonic/dart_state.h" +#include "tonic/logging/dart_error.h" + +namespace tonic { + +DartMessageHandler::DartMessageHandler() + : handled_first_message_(false), + isolate_exited_(false), + isolate_had_uncaught_exception_error_(false), + isolate_had_fatal_error_(false), + isolate_last_error_(kNoError), + task_dispatcher_(nullptr) {} + +DartMessageHandler::~DartMessageHandler() { + task_dispatcher_ = nullptr; +} + +void DartMessageHandler::Initialize(TaskDispatcher dispatcher) { + // Only can be called once. + TONIC_CHECK(!task_dispatcher_ && dispatcher); + task_dispatcher_ = dispatcher; + Dart_SetMessageNotifyCallback(MessageNotifyCallback); +} + +void DartMessageHandler::OnMessage(DartState* dart_state) { + auto task_dispatcher_ = dart_state->message_handler().task_dispatcher_; + + // Schedule a task to run on the message loop thread. + auto weak_dart_state = dart_state->GetWeakPtr(); + task_dispatcher_([weak_dart_state]() { + if (auto dart_state = weak_dart_state.lock()) { + dart_state->message_handler().OnHandleMessage(dart_state.get()); + } + }); +} + +void DartMessageHandler::UnhandledError(Dart_Handle error) { + TONIC_DCHECK(Dart_CurrentIsolate()); + TONIC_DCHECK(Dart_IsError(error)); + + isolate_last_error_ = GetErrorHandleType(error); + // Remember that we had an uncaught exception error. + isolate_had_uncaught_exception_error_ = true; + if (Dart_IsFatalError(error)) { + isolate_had_fatal_error_ = true; + // Stop handling messages. + Dart_SetMessageNotifyCallback(nullptr); + // Shut down the isolate. + Dart_ShutdownIsolate(); + } +} + +void DartMessageHandler::OnHandleMessage(DartState* dart_state) { + if (isolate_had_fatal_error_) { + // Don't handle any more messages. + return; + } + + DartIsolateScope scope(dart_state->isolate()); + DartApiScope dart_api_scope; + Dart_Handle result = Dart_Null(); + bool error = false; + + // On the first message, check if we should pause on isolate start. + if (!handled_first_message()) { + set_handled_first_message(true); + if (Dart_ShouldPauseOnStart()) { + // Mark that we are paused on isolate start. + Dart_SetPausedOnStart(true); + } + } + + if (Dart_IsPausedOnStart()) { + // We are paused on isolate start. Only handle service messages until we are + // requested to resume. + if (Dart_HasServiceMessages()) { + bool resume = Dart_HandleServiceMessages(); + if (!resume) { + return; + } + Dart_SetPausedOnStart(false); + // We've resumed, handle normal messages that are in the queue. + result = Dart_HandleMessage(); + error = LogIfError(result); + dart_state->MessageEpilogue(result); + if (!Dart_CurrentIsolate()) { + isolate_exited_ = true; + return; + } + } + } else if (Dart_IsPausedOnExit()) { + // We are paused on isolate exit. Only handle service messages until we are + // requested to resume. + if (Dart_HasServiceMessages()) { + bool resume = Dart_HandleServiceMessages(); + if (!resume) { + return; + } + Dart_SetPausedOnExit(false); + } + } else { + // We are processing messages normally. + result = Dart_HandleMessage(); + // If the Dart program has set a return code, then it is intending to shut + // down by way of a fatal error, and so there is no need to emit a log + // message. + if (dart_state->has_set_return_code() && Dart_IsError(result) && + Dart_IsFatalError(result)) { + error = true; + } else { + error = LogIfError(result); + } + dart_state->MessageEpilogue(result); + if (!Dart_CurrentIsolate()) { + isolate_exited_ = true; + return; + } + } + + if (error) { + UnhandledError(result); + } else if (!Dart_HasLivePorts()) { + // The isolate has no live ports and would like to exit. + if (!Dart_IsPausedOnExit() && Dart_ShouldPauseOnExit()) { + // Mark that we are paused on exit. + Dart_SetPausedOnExit(true); + } else { + isolate_exited_ = true; + } + } +} + +void DartMessageHandler::MessageNotifyCallback(Dart_Isolate dest_isolate) { + auto dart_state = DartState::From(dest_isolate); + TONIC_CHECK(dart_state); + dart_state->message_handler().OnMessage(dart_state); +} + +} // namespace tonic diff --git a/third_party/tonic/dart_message_handler.h b/third_party/tonic/dart_message_handler.h new file mode 100644 index 0000000000000..5017ad5fee348 --- /dev/null +++ b/third_party/tonic/dart_message_handler.h @@ -0,0 +1,66 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_MESSAGE_HANDLER_H_ +#define LIB_TONIC_DART_MESSAGE_HANDLER_H_ + +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/logging/dart_error.h" + +namespace tonic { +class DartState; + +class DartMessageHandler { + public: + using TaskDispatcher = std::function)>; + + DartMessageHandler(); + + ~DartMessageHandler(); + + // Messages for the current isolate will be scheduled on |runner|. + void Initialize(TaskDispatcher dispatcher); + + // Handle an unhandled error. If the error is fatal then shut down the + // isolate. The message handler's isolate must be the current isolate. + void UnhandledError(Dart_Handle error); + + // Did the isolate exit? + bool isolate_exited() const { return isolate_exited_; } + + // Did the isolate have an uncaught exception error? + bool isolate_had_uncaught_exception_error() const { + return isolate_had_uncaught_exception_error_; + } + + DartErrorHandleType isolate_last_error() const { return isolate_last_error_; } + + protected: + // Called from an unknown thread for each message. + void OnMessage(DartState* dart_state); + // By default, called on the task runner's thread for each message. + void OnHandleMessage(DartState* dart_state); + + bool handled_first_message() const { return handled_first_message_; } + + void set_handled_first_message(bool handled_first_message) { + handled_first_message_ = handled_first_message; + } + + bool handled_first_message_; + bool isolate_exited_; + bool isolate_had_uncaught_exception_error_; + bool isolate_had_fatal_error_; + DartErrorHandleType isolate_last_error_; + TaskDispatcher task_dispatcher_; + + private: + static void MessageNotifyCallback(Dart_Isolate dest_isolate); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_MESSAGE_HANDLER_H_ diff --git a/third_party/tonic/dart_microtask_queue.cc b/third_party/tonic/dart_microtask_queue.cc new file mode 100644 index 0000000000000..ef89e732de79f --- /dev/null +++ b/third_party/tonic/dart_microtask_queue.cc @@ -0,0 +1,107 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_microtask_queue.h" + +#include "tonic/common/build_config.h" +#include "tonic/dart_state.h" +#include "tonic/logging/dart_invoke.h" + +#ifdef OS_IOS +#include +#endif + +namespace tonic { +namespace { + +#ifdef OS_IOS +// iOS doesn't support the thread_local keyword. + +pthread_key_t g_queue_key; +pthread_once_t g_queue_key_once = PTHREAD_ONCE_INIT; + +void MakeKey() { + pthread_key_create(&g_queue_key, nullptr); +} + +void SetQueue(DartMicrotaskQueue* queue) { + pthread_once(&g_queue_key_once, MakeKey); + pthread_setspecific(g_queue_key, queue); +} + +DartMicrotaskQueue* GetQueue() { + return static_cast( + pthread_getspecific(g_queue_key)); +} + +#else + +thread_local DartMicrotaskQueue* g_queue = nullptr; + +void SetQueue(DartMicrotaskQueue* queue) { + g_queue = queue; +} + +DartMicrotaskQueue* GetQueue() { + return g_queue; +} + +#endif + +} // namespace + +DartMicrotaskQueue::DartMicrotaskQueue() : last_error_(kNoError) {} + +DartMicrotaskQueue::~DartMicrotaskQueue() = default; + +void DartMicrotaskQueue::StartForCurrentThread() { + SetQueue(new DartMicrotaskQueue()); +} + +DartMicrotaskQueue* DartMicrotaskQueue::GetForCurrentThread() { + return GetQueue(); +} + +void DartMicrotaskQueue::ScheduleMicrotask(Dart_Handle callback) { + queue_.emplace_back(DartState::Current(), callback); +} + +void DartMicrotaskQueue::RunMicrotasks() { + while (!queue_.empty()) { + MicrotaskQueue local; + std::swap(queue_, local); + for (const auto& callback : local) { + if (auto dart_state = callback.dart_state().lock()) { + DartState::Scope dart_scope(dart_state.get()); + Dart_Handle result = Dart_InvokeClosure(callback.value(), 0, nullptr); + // If the Dart program has set a return code, then it is intending to + // shut down by way of a fatal error, and so there is no need to emit a + // log message. + if (!dart_state->has_set_return_code() || !Dart_IsError(result) || + !Dart_IsFatalError(result)) { + LogIfError(result); + } + DartErrorHandleType error = GetErrorHandleType(result); + if (error != kNoError) { + last_error_ = error; + } + dart_state->MessageEpilogue(result); + if (!Dart_CurrentIsolate()) + return; + } + } + } +} + +void DartMicrotaskQueue::Destroy() { + TONIC_DCHECK(this == GetForCurrentThread()); + SetQueue(nullptr); + delete this; +} + +DartErrorHandleType DartMicrotaskQueue::GetLastError() { + return last_error_; +} + +} // namespace tonic diff --git a/third_party/tonic/dart_microtask_queue.h b/third_party/tonic/dart_microtask_queue.h new file mode 100644 index 0000000000000..0b05ebcd0dcee --- /dev/null +++ b/third_party/tonic/dart_microtask_queue.h @@ -0,0 +1,42 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_MICROTASK_QUEUE_H_ +#define LIB_TONIC_DART_MICROTASK_QUEUE_H_ + +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/dart_persistent_value.h" +#include "tonic/logging/dart_error.h" + +namespace tonic { + +class DartMicrotaskQueue { + public: + DartMicrotaskQueue(); + ~DartMicrotaskQueue(); + + static void StartForCurrentThread(); + + static DartMicrotaskQueue* GetForCurrentThread(); + + void ScheduleMicrotask(Dart_Handle callback); + void RunMicrotasks(); + void Destroy(); + + bool HasMicrotasks() const { return !queue_.empty(); } + + DartErrorHandleType GetLastError(); + + private: + typedef std::vector MicrotaskQueue; + + DartErrorHandleType last_error_; + MicrotaskQueue queue_; +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_MICROTASK_QUEUE_H_ diff --git a/third_party/tonic/dart_persistent_value.cc b/third_party/tonic/dart_persistent_value.cc new file mode 100644 index 0000000000000..9ed6f70f35322 --- /dev/null +++ b/third_party/tonic/dart_persistent_value.cc @@ -0,0 +1,63 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_persistent_value.h" + +#include "tonic/dart_state.h" +#include "tonic/scopes/dart_isolate_scope.h" + +namespace tonic { + +DartPersistentValue::DartPersistentValue() : value_(nullptr) {} + +DartPersistentValue::DartPersistentValue(DartPersistentValue&& other) + : dart_state_(other.dart_state_), value_(other.value_) { + other.dart_state_.reset(); + other.value_ = nullptr; +} + +DartPersistentValue::DartPersistentValue(DartState* dart_state, + Dart_Handle value) + : value_(nullptr) { + Set(dart_state, value); +} + +DartPersistentValue::~DartPersistentValue() { + Clear(); +} + +void DartPersistentValue::Set(DartState* dart_state, Dart_Handle value) { + TONIC_DCHECK(is_empty()); + dart_state_ = dart_state->GetWeakPtr(); + value_ = Dart_NewPersistentHandle(value); +} + +void DartPersistentValue::Clear() { + if (!value_) { + return; + } + + auto dart_state = dart_state_.lock(); + if (!dart_state) { + return; + } + + DartIsolateScope scope(dart_state->isolate()); + Dart_DeletePersistentHandle(value_); + dart_state_.reset(); + value_ = nullptr; +} + +Dart_Handle DartPersistentValue::Get() { + if (!value_) + return nullptr; + return Dart_HandleFromPersistent(value_); +} + +Dart_Handle DartPersistentValue::Release() { + Dart_Handle local = Get(); + Clear(); + return local; +} +} // namespace tonic diff --git a/third_party/tonic/dart_persistent_value.h b/third_party/tonic/dart_persistent_value.h new file mode 100644 index 0000000000000..c2bc7852a510b --- /dev/null +++ b/third_party/tonic/dart_persistent_value.h @@ -0,0 +1,46 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_PERSISTENT_VALUE_H_ +#define LIB_TONIC_DART_PERSISTENT_VALUE_H_ + +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/common/macros.h" + +namespace tonic { +class DartState; + +// DartPersistentValue is a bookkeeping class to help pair calls to +// Dart_NewPersistentHandle with Dart_DeletePersistentHandle. Consider using +// this class instead of holding a Dart_PersistentHandle directly so that you +// don't leak the Dart_PersistentHandle. +class DartPersistentValue { + public: + DartPersistentValue(); + DartPersistentValue(DartPersistentValue&& other); + DartPersistentValue(DartState* dart_state, Dart_Handle value); + ~DartPersistentValue(); + + Dart_PersistentHandle value() const { return value_; } + bool is_empty() const { return !value_; } + + void Set(DartState* dart_state, Dart_Handle value); + void Clear(); + Dart_Handle Get(); + Dart_Handle Release(); + + const std::weak_ptr& dart_state() const { return dart_state_; } + + private: + std::weak_ptr dart_state_; + Dart_PersistentHandle value_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartPersistentValue); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_PERSISTENT_VALUE_H_ diff --git a/third_party/tonic/dart_state.cc b/third_party/tonic/dart_state.cc new file mode 100644 index 0000000000000..a3430d87004d2 --- /dev/null +++ b/third_party/tonic/dart_state.cc @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_state.h" + +#include "tonic/converter/dart_converter.h" +#include "tonic/dart_class_library.h" +#include "tonic/dart_message_handler.h" +#include "tonic/file_loader/file_loader.h" + +namespace tonic { + +DartState::Scope::Scope(DartState* dart_state) + : scope_(dart_state->isolate()) {} + +DartState::Scope::Scope(std::shared_ptr dart_state) + : scope_(dart_state->isolate()) {} + +DartState::Scope::~Scope() {} + +DartState::DartState(int dirfd, + std::function message_epilogue) + : isolate_(nullptr), + class_library_(new DartClassLibrary), + message_handler_(new DartMessageHandler()), + file_loader_(new FileLoader(dirfd)), + message_epilogue_(message_epilogue), + has_set_return_code_(false) {} + +DartState::~DartState() {} + +void DartState::SetIsolate(Dart_Isolate isolate) { + isolate_ = isolate; + if (!isolate_) + return; + DidSetIsolate(); +} + +DartState* DartState::From(Dart_Isolate isolate) { + auto isolate_data = + static_cast*>(Dart_IsolateData(isolate)); + return isolate_data->get(); +} + +DartState* DartState::Current() { + auto isolate_data = + static_cast*>(Dart_CurrentIsolateData()); + return isolate_data->get(); +} + +std::weak_ptr DartState::GetWeakPtr() { + return shared_from_this(); +} + +void DartState::SetReturnCode(uint32_t return_code) { + if (set_return_code_callback_) { + set_return_code_callback_(return_code); + } + has_set_return_code_ = true; +} + +void DartState::SetReturnCodeCallback(std::function callback) { + set_return_code_callback_ = callback; +} + +void DartState::DidSetIsolate() {} + +Dart_Handle DartState::HandleLibraryTag(Dart_LibraryTag tag, + Dart_Handle library, + Dart_Handle url) { + return Current()->file_loader().HandleLibraryTag(tag, library, url); +} + +} // namespace tonic diff --git a/third_party/tonic/dart_state.h b/third_party/tonic/dart_state.h new file mode 100644 index 0000000000000..d2c6e03cb7cc9 --- /dev/null +++ b/third_party/tonic/dart_state.h @@ -0,0 +1,86 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_STATE_H_ +#define LIB_TONIC_DART_STATE_H_ + +#include +#include + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/common/macros.h" +#include "tonic/dart_persistent_value.h" +#include "tonic/scopes/dart_api_scope.h" +#include "tonic/scopes/dart_isolate_scope.h" + +namespace tonic { +class DartClassLibrary; +class DartMessageHandler; +class FileLoader; + +// DartState represents the state associated with a given Dart isolate. The +// lifetime of this object is controlled by the DartVM. If you want to hold a +// reference to a DartState instance, please hold a std::weak_ptr. +// +// DartState is analogous to gin::PerIsolateData and JSC::ExecState. +class DartState : public std::enable_shared_from_this { + public: + class Scope { + public: + explicit Scope(DartState* dart_state); + explicit Scope(std::shared_ptr dart_state); + ~Scope(); + + private: + DartIsolateScope scope_; + DartApiScope api_scope_; + }; + + DartState(int dirfd = -1, + std::function message_epilogue = nullptr); + virtual ~DartState(); + + static DartState* From(Dart_Isolate isolate); + static DartState* Current(); + + std::weak_ptr GetWeakPtr(); + + Dart_Isolate isolate() { return isolate_; } + void SetIsolate(Dart_Isolate isolate); + + DartClassLibrary& class_library() { return *class_library_; } + DartMessageHandler& message_handler() { return *message_handler_; } + FileLoader& file_loader() { return *file_loader_; } + + void MessageEpilogue(Dart_Handle message_result) { + if (message_epilogue_) { + message_epilogue_(message_result); + } + } + void SetReturnCode(uint32_t return_code); + void SetReturnCodeCallback(std::function callback); + bool has_set_return_code() const { return has_set_return_code_; } + + virtual void DidSetIsolate(); + + static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, + Dart_Handle library, + Dart_Handle url); + + private: + Dart_Isolate isolate_; + std::unique_ptr class_library_; + std::unique_ptr message_handler_; + std::unique_ptr file_loader_; + std::function message_epilogue_; + std::function set_return_code_callback_; + bool has_set_return_code_; + + protected: + TONIC_DISALLOW_COPY_AND_ASSIGN(DartState); +}; + +} // namespace tonic + +#endif // LIB_TONIC_DART_STATE_H_ diff --git a/third_party/tonic/dart_wrappable.cc b/third_party/tonic/dart_wrappable.cc new file mode 100644 index 0000000000000..96b5e44ed80fd --- /dev/null +++ b/third_party/tonic/dart_wrappable.cc @@ -0,0 +1,116 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tonic/dart_wrappable.h" + +#include "tonic/dart_class_library.h" +#include "tonic/dart_state.h" +#include "tonic/dart_wrapper_info.h" +#include "tonic/logging/dart_error.h" + +namespace tonic { + +DartWrappable::~DartWrappable() { + TONIC_CHECK(!dart_wrapper_); +} + +Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) { + TONIC_DCHECK(!dart_wrapper_); + const DartWrapperInfo& info = GetDartWrapperInfo(); + + Dart_PersistentHandle type = dart_state->class_library().GetClass(info); + TONIC_DCHECK(!LogIfError(type)); + + intptr_t native_fields[kNumberOfNativeFields]; + native_fields[kPeerIndex] = reinterpret_cast(this); + native_fields[kWrapperInfoIndex] = reinterpret_cast(&info); + Dart_Handle wrapper = + Dart_AllocateWithNativeFields(type, kNumberOfNativeFields, native_fields); + TONIC_DCHECK(!LogIfError(wrapper)); + + this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper. + dart_wrapper_ = Dart_NewWeakPersistentHandle( + wrapper, this, GetAllocationSize(), &FinalizeDartWrapper); + + return wrapper; +} + +void DartWrappable::AssociateWithDartWrapper(Dart_NativeArguments args) { + TONIC_DCHECK(!dart_wrapper_); + + Dart_Handle wrapper = Dart_GetNativeArgument(args, 0); + TONIC_CHECK(!LogIfError(wrapper)); + + intptr_t native_fields[kNumberOfNativeFields]; + TONIC_CHECK(!LogIfError(Dart_GetNativeFieldsOfArgument( + args, 0, kNumberOfNativeFields, native_fields))); + TONIC_CHECK(!native_fields[kPeerIndex]); + TONIC_CHECK(!native_fields[kWrapperInfoIndex]); + + const DartWrapperInfo& info = GetDartWrapperInfo(); + TONIC_CHECK(!LogIfError(Dart_SetNativeInstanceField( + wrapper, kPeerIndex, reinterpret_cast(this)))); + TONIC_CHECK(!LogIfError(Dart_SetNativeInstanceField( + wrapper, kWrapperInfoIndex, reinterpret_cast(&info)))); + + this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper. + dart_wrapper_ = Dart_NewWeakPersistentHandle( + wrapper, this, GetAllocationSize(), &FinalizeDartWrapper); +} + +void DartWrappable::ClearDartWrapper() { + TONIC_DCHECK(dart_wrapper_); + Dart_Handle wrapper = Dart_HandleFromWeakPersistent(dart_wrapper_); + TONIC_CHECK(!LogIfError(Dart_SetNativeInstanceField(wrapper, kPeerIndex, 0))); + TONIC_CHECK( + !LogIfError(Dart_SetNativeInstanceField(wrapper, kWrapperInfoIndex, 0))); + Dart_DeleteWeakPersistentHandle(Dart_CurrentIsolate(), dart_wrapper_); + dart_wrapper_ = nullptr; + this->ReleaseDartWrappableReference(); +} + +void DartWrappable::FinalizeDartWrapper(void* isolate_callback_data, + Dart_WeakPersistentHandle wrapper, + void* peer) { + DartWrappable* wrappable = reinterpret_cast(peer); + wrappable->dart_wrapper_ = nullptr; + wrappable->ReleaseDartWrappableReference(); // Balanced in CreateDartWrapper. +} + +size_t DartWrappable::GetAllocationSize() { + return GetDartWrapperInfo().size_in_bytes; +} + +Dart_PersistentHandle DartWrappable::GetTypeForWrapper( + tonic::DartState* dart_state, + const tonic::DartWrapperInfo& wrapper_info) { + return dart_state->class_library().GetClass(wrapper_info); +} + +DartWrappable* DartConverterWrappable::FromDart(Dart_Handle handle) { + intptr_t peer = 0; + Dart_Handle result = + Dart_GetNativeInstanceField(handle, DartWrappable::kPeerIndex, &peer); + if (Dart_IsError(result)) + return nullptr; + return reinterpret_cast(peer); +} + +DartWrappable* DartConverterWrappable::FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception) { + intptr_t native_fields[DartWrappable::kNumberOfNativeFields]; + Dart_Handle result = Dart_GetNativeFieldsOfArgument( + args, index, DartWrappable::kNumberOfNativeFields, native_fields); + if (Dart_IsError(result)) { + exception = Dart_NewStringFromCString(DartError::kInvalidArgument); + return nullptr; + } + if (!native_fields[DartWrappable::kPeerIndex]) + return nullptr; + return reinterpret_cast( + native_fields[DartWrappable::kPeerIndex]); +} + +} // namespace tonic diff --git a/third_party/tonic/dart_wrappable.h b/third_party/tonic/dart_wrappable.h new file mode 100644 index 0000000000000..d6823c1ef92bc --- /dev/null +++ b/third_party/tonic/dart_wrappable.h @@ -0,0 +1,190 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIB_TONIC_DART_WRAPPABLE_H_ +#define LIB_TONIC_DART_WRAPPABLE_H_ + +#include "third_party/dart/runtime/include/dart_api.h" +#include "tonic/common/macros.h" +#include "tonic/converter/dart_converter.h" +#include "tonic/dart_state.h" +#include "tonic/dart_wrapper_info.h" +#include "tonic/logging/dart_error.h" + +#include + +namespace tonic { + +// DartWrappable is a base class that you can inherit from in order to be +// exposed to Dart code as an interface. +class DartWrappable { + public: + enum DartNativeFields { + kPeerIndex, // Must be first to work with Dart_GetNativeReceiver. + kWrapperInfoIndex, + kNumberOfNativeFields, + }; + + DartWrappable() : dart_wrapper_(nullptr) {} + + // Subclasses that wish to expose a new interface must override this function + // and provide information about their wrapper. There is no need to call your + // base class's implementation of this function. + // Implement using IMPLEMENT_WRAPPERTYPEINFO macro + virtual const DartWrapperInfo& GetDartWrapperInfo() const = 0; + + // Override this to customize the object size reported to the Dart garbage + // collector. + // Implement using IMPLEMENT_WRAPPERTYPEINFO macro + virtual size_t GetAllocationSize(); + + virtual void RetainDartWrappableReference() const = 0; + + virtual void ReleaseDartWrappableReference() const = 0; + + Dart_Handle CreateDartWrapper(DartState* dart_state); + void AssociateWithDartWrapper(Dart_NativeArguments args); + void ClearDartWrapper(); // Warning: Might delete this. + Dart_WeakPersistentHandle dart_wrapper() const { return dart_wrapper_; } + + protected: + virtual ~DartWrappable(); + + static Dart_PersistentHandle GetTypeForWrapper( + tonic::DartState* dart_state, + const tonic::DartWrapperInfo& wrapper_info); + + private: + static void FinalizeDartWrapper(void* isolate_callback_data, + Dart_WeakPersistentHandle wrapper, + void* peer); + + Dart_WeakPersistentHandle dart_wrapper_; + + TONIC_DISALLOW_COPY_AND_ASSIGN(DartWrappable); +}; + +#define DEFINE_WRAPPERTYPEINFO() \ + public: \ + const tonic::DartWrapperInfo& GetDartWrapperInfo() const override { \ + return dart_wrapper_info_; \ + } \ + static Dart_PersistentHandle GetDartType(tonic::DartState* dart_state) { \ + return GetTypeForWrapper(dart_state, dart_wrapper_info_); \ + } \ + \ + private: \ + static const tonic::DartWrapperInfo& dart_wrapper_info_ + +#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName) \ + static const tonic::DartWrapperInfo \ + kDartWrapperInfo_##LibraryName_##ClassName = { \ + #LibraryName, \ + #ClassName, \ + sizeof(ClassName), \ + }; \ + const tonic::DartWrapperInfo& ClassName::dart_wrapper_info_ = \ + kDartWrapperInfo_##LibraryName_##ClassName; + +struct DartConverterWrappable { + static DartWrappable* FromDart(Dart_Handle handle); + static DartWrappable* FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception); +}; + +template +struct DartConverter< + T*, + typename std::enable_if< + std::is_convertible::value>::type> { + static Dart_Handle ToDart(DartWrappable* val) { + if (!val) + return Dart_Null(); + if (Dart_WeakPersistentHandle wrapper = val->dart_wrapper()) + return Dart_HandleFromWeakPersistent(wrapper); + return val->CreateDartWrapper(DartState::Current()); + } + + static void SetReturnValue(Dart_NativeArguments args, + DartWrappable* val, + bool auto_scope = true) { + if (!val) + Dart_SetReturnValue(args, Dart_Null()); + else if (Dart_WeakPersistentHandle wrapper = val->dart_wrapper()) + Dart_SetWeakHandleReturnValue(args, wrapper); + else + Dart_SetReturnValue(args, val->CreateDartWrapper(DartState::Current())); + } + + static T* FromDart(Dart_Handle handle) { + // TODO(abarth): We're missing a type check. + return static_cast(DartConverterWrappable::FromDart(handle)); + } + + static T* FromArguments(Dart_NativeArguments args, + int index, + Dart_Handle& exception, + bool auto_scope = true) { + // TODO(abarth): We're missing a type check. + return static_cast( + DartConverterWrappable::FromArguments(args, index, exception)); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// Support for generic smart pointers that have a "get" method that returns a +// pointer to a type that is Dart convertible as well as a constructor that +// adopts a raw pointer to that type. + +template