Comments (7)
If the algorithm is written in C, you have 2 options:
- If you have the C source code, you could rewrite the same algorithm in JS and process it in the Ionic app Webview - no C required
- If you don't have the C source code or performance is an issue, then you'll need to pass the raw data to the C library and have it return the result. To do this, you'd need a plugin similar to this one which could pass the input data to the C code and return result to the Ionic app's JS layer.
from cordova-plugin-hello-c.
from cordova-plugin-hello-c.
The compilation is done offline: you'd cross-compile your C code into a static library that is built into the app and called by your plugin code at runtime.
Any runtime lag would be due to the passing through the various layers of code to get your result, i.e. JS -> Java (Android) / Objective-c (iOS) -> C library -> Java (Android) / Objective-c (iOS) -> JS
however in my experience, this presents very little lag (in the order of ~5 to 10ms)
from cordova-plugin-hello-c.
It's a bit of an overwhelming prospect, especially as a novice, but I will try my hand at it and see where I can get.
from cordova-plugin-hello-c.
Dave, would it be possible to let me know how to make the input method available in my application? I can import the plugin into my app but I do not know what methods are available (the structure is quite extensive!).
My thanks.
from cordova-plugin-hello-c.
If you look in the test project code, you can see how this test plugin's methods are called and then trace the calls through the various layers of the plugin.
For example:
- the plugin's
hello()
method is called by the test app project - this invokes the plugin's JS API function which in turn calls down to the native code
- On Android, this calls the
execute()
Java method withaction="hello"
which calls down to the Java component of the JNI (Java-Native Interface) layer which is a Java class defining the interface to the C component of the JNI layer which finally calls the function in the cross-platform shared C library - On iOS, the JS API function calls down to the Objective-C plugin layer which is able to directly call the cross-platform shared C library because iOS is C-based.
Hope this helps
from cordova-plugin-hello-c.
This is very very helpful, thank you very much.
So, if I were to modify the Shared Library to compute a simple sum where one of the inputs to the sum is a user-inputted value and have it display the result, I would:
- Define the sum in the Shared C Library, inlcuding declaring the input variable
- Make the input variable and sum output available to the Objective-C plugin layer (for iOS)
- Make the input variable and sum output available to the Android JNI layer and the Java Component of the JNI layer, which should then be called by execute(...hello)
I will do some testing on device today and see if I can make a small application such as the one described above. I think if I am successful, then I will be much more confident that I could take the project.
from cordova-plugin-hello-c.
Related Issues (14)
- Failed to restore plugin HOT 5
- Error initializing Cordova: Class not found HOT 9
- Class Not Found HOT 1
- iOS 10 is the maximum deployment target for 32-bit targets HOT 2
- How can I use structs? HOT 2
- Help Needed
- Dlib Library HOT 1
- compile-android.cmd error
- Android.mk not found HOT 9
- Help C++ HOT 1
- cordova platform 7.x problems HOT 2
- Problems when run on cordova-android@7 HOT 13
- compile-android problem HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-hello-c.