How to structure a hybrid (native+lua) plugin?

I know how to develop a native plugin and also create stubs for non-supported platforms. I would like to know how can I structure a hybrid plugin which would be composed of both native code + lua code.

The lua side would be basically used to perform some operations on the returned data from the native side in order to create a standard response for all platforms. I would do that in the lua side so I can use a unique code for both iOS and Android and also take advantage of the easiness of Lua.

A simple example would be a barcode plugin that returns the supported barcode format for the platform.

iOS uses the following value for EAN13 barcode:  “org.gs1.EAN-13”  while android uses “EAN_13”.

So, my lua code would have something like this:

local dicStandardFormatsToSystemFormats ={ ["UPC\_A"] = { android="UPC\_A", ios="org.iso.Aztec" }, ["UPC\_E"] = { android="UPC\_E", ios="org.gs1.UPC-E" }, ["EAN\_8"] = { android="EAN\_8", ios="org.gs1.EAN-8" }, ["EAN\_13"] = { android="EAN\_13", ios="org.gs1.EAN-13" }, ["CODE\_39"] = { android="CODE\_39", ios="org.iso.Code39" }, ["CODE\_39\_MOD\_43"] = { android="CODE\_39\_MOD\_43", ios="org.iso.Code39Mod43" }, ["CODE\_93"] = { android="CODE\_93", ios="com.intermec.Code93" }, ["CODE\_128"] = { android="CODE\_128", ios="org.iso.Code128" }, ["ITF"] = { android="ITF", ios="org.ansi.Interleaved2of5" }, -- ITF = "Inteleaved Two of Five" (i Two out of every five bars or spaces are wide (hence exactly 2 of 5)) ["ITF\_14"] = { android=nil, ios="org.gs1.ITF14" }, -- it is the ITF but with 14 digits ["RSS\_14"] = { android="RSS\_14", ios=nil }, ["RSS\_EXPANDED"] = { android="RSS\_EXPANDED", ios=nil }, ["PDF\_417"] = { android="PDF\_417", ios="org.iso.PDF417" }, ["DATA\_MATRIX"] = { android="DATA\_MATRIX", ios="org.iso.DataMatrix" }, ["QR\_CODE"] = { android="QR\_CODE", ios="org.iso.QRCode" }, }

So, direct to the question: Where should have that lua code in order to have it working together with the native plugin so I can package everything into a Corona plugin to submit to the marketplace? Is it inside the stub?

anyone?

I’ll need to ask Engineering if this is at all possible. I’m unaware of any hybrid plugins.

Rob

Thanks Rob.

You can think of the lua code being just a wrapper around the native plugin.  I was wondering if I could have the lua code as the stub, but then I would need to have a way to “requre” my native plugin (.a, .jar) from the stub, which I don’t think if it is possible.

Currently, under Enterprise environment, I just create a wrapper called “plugin-barcode.lua” which is the one that I require from my main.lua.  The “plugin-barcode.lua” acts as a fake plugin if I am in the Simulator environment, or just require the “plugin.barcode” if I am on a device.

I was wondering if I could replicate that under a Corona Plugin package.

The Plugin Dev Guide has a Hybrid (Lua + Native) section, but it is not very clear how to implement in the iOS/Android environment.

Rob, I was wondering, what if I create 2 plugins? One would be the pure native (and that I could leave in the store as hidden) and other as a pure Lua plugin (which basically works as my wrapper - loading the native plugin as dependency). Do you think that could work?

I need to hear from Engineering.

Rob