Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce tizen_interop package #1

Merged
merged 10 commits into from Aug 9, 2021
Merged

Introduce tizen_interop package #1

merged 10 commits into from Aug 9, 2021

Conversation

WonyoungChoi
Copy link
Contributor

@WonyoungChoi WonyoungChoi commented Jul 30, 2021

context: flutter-tizen/flutter-tizen#129

This tizen_interop package provides Dart bindings and utility functions for using Tizen native APIs.

Example for using Interop

import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:tizen_interop/4.0/wearable/tizen.dart';

String? getApplicationName() {
    String? appName;
    using((Arena arena) {
      Pointer<Pointer<Int8>> namePtr = arena();
      tizen.app_get_name(namePtr);
      appName = namePtr.value.toDartString();
      malloc.free(namePtr.value);
    });
    return appName;
}

LICENSE Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/4.0/wearable/tizen.dart Outdated Show resolved Hide resolved
packages/symgen/lib/src/config.dart Outdated Show resolved Hide resolved
packages/symgen/lib/src/config.dart Outdated Show resolved Hide resolved
packages/symgen/lib/src/generator.dart Outdated Show resolved Hide resolved
packages/symgen/lib/src/generator.dart Outdated Show resolved Hide resolved
pubspec.yaml Outdated Show resolved Hide resolved
packages/symgen/lib/src/config.dart Outdated Show resolved Hide resolved
WonyoungChoi and others added 5 commits July 30, 2021 16:38
Co-authored-by: Swift Kim <swift.kim@samsung.com>
Co-authored-by: Swift Kim <swift.kim@samsung.com>
Co-authored-by: Swift Kim <swift.kim@samsung.com>
Co-authored-by: Swift Kim <swift.kim@samsung.com>
@swift-kim
Copy link
Member

Some warnings were generated while running build.sh.

Running in Directory: '/home/swift/Git/tizen_interop'
[WARNING]: Prefer adding Key '[description]' to your config.
Input Headers: [configs/4.0/wearable/entrypoints.h]
[SEVERE] : Header configs/4.0/wearable/entrypoints.h: Total errors/warnings: 1.
[SEVERE] :     ./rootstraps/wearable-4.0-device.core/usr/include/pthread.h:743:12: warning: declaration of built-in function '__sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>. [Semantic Issue]
[WARNING]: Removed All Struct Members from camera_preview_data_s(camera_preview_data_s), struct member has an unsupported type.
[WARNING]: Removed All Struct Members from calendar_time_s(calendar_time_s), struct member has an unsupported type.
[WARNING]: Skipped Function 'calendar_filter_add_caltime', Incomplete struct pass/return by value not supported.
[WARNING]: Skipped Function 'calendar_record_set_caltime', Incomplete struct pass/return by value not supported.
[WARNING]: Generated declaration '_watch_time_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_activity_handle_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_activity_data_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_gesture_handle_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_gesture_data_s' start's with '_' and therefore will be private.
...
...

Is this normal?

@WonyoungChoi
Copy link
Contributor Author

@swift-kim I think underscore warnings are not issues because they are not public apis. But others should be checked more.

@WonyoungChoi
Copy link
Contributor Author

Some warnings were generated while running build.sh.

Running in Directory: '/home/swift/Git/tizen_interop'
[WARNING]: Prefer adding Key '[description]' to your config.
Input Headers: [configs/4.0/wearable/entrypoints.h]
[SEVERE] : Header configs/4.0/wearable/entrypoints.h: Total errors/warnings: 1.
[SEVERE] :     ./rootstraps/wearable-4.0-device.core/usr/include/pthread.h:743:12: warning: declaration of built-in function '__sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>. [Semantic Issue]
[WARNING]: Removed All Struct Members from camera_preview_data_s(camera_preview_data_s), struct member has an unsupported type.
[WARNING]: Removed All Struct Members from calendar_time_s(calendar_time_s), struct member has an unsupported type.
[WARNING]: Skipped Function 'calendar_filter_add_caltime', Incomplete struct pass/return by value not supported.
[WARNING]: Skipped Function 'calendar_record_set_caltime', Incomplete struct pass/return by value not supported.
[WARNING]: Generated declaration '_watch_time_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_activity_handle_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_activity_data_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_gesture_handle_s' start's with '_' and therefore will be private.
[WARNING]: Generated declaration '_gesture_data_s' start's with '_' and therefore will be private.
...
...

Is this normal?

if the union is used in a struct, ffigen 3.0.0 can't generate the Dart code. but it will be resolved in next release version of ffigen.
ref: dart-lang/native#358

@bwikbs
Copy link
Member

bwikbs commented Aug 4, 2021

Wow! Found this just now! I am very interested in this subject! 👍

Although it's very early stage, but.. I've question.
This is for tizen dart api right? If so, do you have a idea how building dart interface too?
When we reviewed FFI before, we gave up because It is not easy to get users to use the output of FFI. And we didn't know how to make tizen dart api interface either.
So, if you have any rough ideas for next step, I'd love to know that!

@WonyoungChoi
Copy link
Contributor Author

@bwikbs Thank you for your interest. 😃
As you mentioned, the output of ffigen is not easy for end-user to use. In particular, pointer handling is not kind because there is no finalizer in dart-lang...
The project is designed to open up a minimal way to use the Tizen Native API, although it is inconvenient to use. It can also help create a new dart interfaces.
And.. I plan to add more utilities to make it easier to use the ffigen's output..

@bwikbs
Copy link
Member

bwikbs commented Aug 4, 2021

@WonyoungChoi Thanks for letting me know!

I plan to add more utilities to make it easier to use the ffigen's output..

Can you share roughly what you are planning? Maybe I'll get some inspiration from your plans 😄

@bwikbs
Copy link
Member

bwikbs commented Aug 4, 2021

Oh, one more thing.. 😄 (just curious,after it came out..)
What do you think of the challenging task to introduce rest api or grpc? Or build another meta-data for this propose.

@swift-kim
Copy link
Member

@WonyoungChoi Have you taken a look at the issue regarding __sigsetjmp in the above?

Otherwise the change looks good to me.

@WonyoungChoi
Copy link
Contributor Author

WonyoungChoi commented Aug 5, 2021

@WonyoungChoi Thanks for letting me know!

I plan to add more utilities to make it easier to use the ffigen's output..

Can you share roughly what you are planning? Maybe I'll get some inspiration from your plans 😄

Well.. first of all, I'm looking for a more comfortable way to use the c style string. For now, the following procedure is required to receive a string value from the native function.

Pointer<Pointer<Int8>> ppString = malloc();
final ret = tizen.some_native_function(ppString);
final dartStr = ppString.value.toDartString();
malloc.free(ppString.value);
malloc.free(ppString);

And I will make a small app by using this interop APIs to find out what we need more.

@WonyoungChoi
Copy link
Contributor Author

WonyoungChoi commented Aug 5, 2021

@WonyoungChoi Have you taken a look at the issue regarding __sigsetjmp in the above?

Otherwise the change looks good to me.

Could you explain it in more detail? I can't find a issue related __sigsetjmp().

@WonyoungChoi
Copy link
Contributor Author

Oh, one more thing.. 😄 (just curious,after it came out..)
What do you think of the challenging task to introduce rest api or grpc? Or build another meta-data for this propose.

Sorry, I can't understand the exact point of the part you mentioned. But I found https://github.com/grpc/grpc-dart..

@swift-kim
Copy link
Member

Could you explain it in more detail? I can't find a issue related __sigsetjmp().

@WonyoungChoi You can just search for the text in this page.

@bbrto21
Copy link

bbrto21 commented Aug 6, 2021

Q. Does the tool create the files below? Why do we need to include these?

  • generated_bindings.dart
  • generated_symbols.dart

@WonyoungChoi
Copy link
Contributor Author

Could you explain it in more detail? I can't find a issue related __sigsetjmp().

@WonyoungChoi You can just search for the text in this page.

Oh. I missed that :( Because there is no __sigsetjmp() errors in my log after build.sh. Could you try again?

@WonyoungChoi
Copy link
Contributor Author

Q. Does the tool create the files below? Why do we need to include these?

  • generated_bindings.dart
  • generated_symbols.dart

Yes these files are generated by tools, but they should be included into the package. Of course, they can be generated every time the package is published.
I think it's easier to use these files being managed in git. the build.sh only needs to be used to update these files.

@bwikbs
Copy link
Member

bwikbs commented Aug 6, 2021

Sorry, I can't understand the exact point of the part you mentioned. But I found https://github.com/grpc/grpc-dart..

It's not a big deal. I was asking if you've ever thought about how to build a tizen interface with other general-purpose technologies and binding dart from that. (In fact, there is a rumor from vd and I was asking you heard or knew anything about that 😄 )

@swift-kim
Copy link
Member

@WonyoungChoi The error is still reproducible, but I could suppress the error by adding -Wno-incomplete-setjmp-declaration to ffigen.yaml's compiler-opts:.

@WonyoungChoi
Copy link
Contributor Author

WonyoungChoi commented Aug 6, 2021

@WonyoungChoi The error is still reproducible, but I could suppress the error by adding -Wno-incomplete-setjmp-declaration to ffigen.yaml's compiler-opts:.

@swift-kim Thank you for finding the useful option! It seems to be related to the "clang/llvm" environment. anyway I don't think it is not a problem because the pthread.h is not a target of ffigen. I will add that option to ffigen.yaml file also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants