Git Product home page Git Product logo

Comments (7)

dpa99c avatar dpa99c commented on August 20, 2024

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.

ibby89 avatar ibby89 commented on August 20, 2024

from cordova-plugin-hello-c.

dpa99c avatar dpa99c commented on August 20, 2024

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.

ibby89 avatar ibby89 commented on August 20, 2024

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.

ibby89 avatar ibby89 commented on August 20, 2024

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.

dpa99c avatar dpa99c commented on August 20, 2024

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:

Hope this helps

from cordova-plugin-hello-c.

ibby89 avatar ibby89 commented on August 20, 2024

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:

  1. Define the sum in the Shared C Library, inlcuding declaring the input variable
  2. Make the input variable and sum output available to the Objective-C plugin layer (for iOS)
  3. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.