* * *

Author Topic: Investigating FPC switch from Oxygene  (Read 850 times)

scottHW

  • Newbie
  • Posts: 3
Investigating FPC switch from Oxygene
« on: May 18, 2018, 04:31:03 pm »
Looking at possibly moving a (large) Android app developed using Oxygene to FPC and wanting to find out what the current state of Android development is via FPC.

I've tried reading the wiki, browsed some of the forum posts, but what I'm trying to see here is the forest, not the trees, so thus far it's been a challenge.

(In one place, in the section labeled 'Debugging', they refer you to Logcat files. Which implies line by line debugging and variable inspection isn't offered, but I suspect (hope) that section is just dated.)

What I'm looking for is just a high level overview of FPC Android development.

As you may know, Oxygene for Android pretty much converts the Pascal code into Java (which is then built into an APK), exposes pretty much all the Android programming APIs and data types (along with some unique Oxygene data types), uses Visual Studio for it's IDE, and offers line by line debugging and variable inspection of the Pascal code while the app runs in an emulator or attached device. It also provides Pascal extensions that mimic Java such as:

Code: Pascal  [Select]
  1. mySpinnerContent := TextView(findViewById(R.id.spinnerToolbar));
  2.                 mySpinnerContent.setOnClickListener(new class View.OnClickListener (onClick := method (v: View)
  3.                         begin
  4.                                 getSetContentAdapter(mMyCustomPopupWindow);
  5.                                 mMyCustomPopupWindow.showAsDropDown(v, 6, kFakeDropdownVerticalOffset);
  6.                         end));

So at a high level, how does FPC Android compare?

And what portability issues might arise?

Thanks in advance...


Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Investigating FPC switch from Oxygene
« Reply #1 on: May 18, 2018, 05:31:38 pm »
And what portability issues might arise?

Portability of what to what?

scottHW

  • Newbie
  • Posts: 3
Re: Investigating FPC switch from Oxygene
« Reply #2 on: May 18, 2018, 05:49:29 pm »
Porting an Oxygene Android app (in Pascal) to FPC Android.

Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Investigating FPC switch from Oxygene
« Reply #3 on: May 18, 2018, 05:55:44 pm »
Porting an Oxygene Android app (in Pascal) to FPC Android.

I would guess that porting it would not be easy. Oxygene Pascal is kind of a superset of the Object Pascal that Delphi and FPC support. You would need to strip out unsupported features and syntax, then tackle the RemObjects-specific stuff.

You could start by taking non-UI parts of your app and putting them into a unit (or, better yet, a dynamic library) and getting that to compile and debugged.

I don't have interest in Android, but I would put as much as possible into a dynamic library and then write a UI in Java or even in Pascal using the FPC JVM compiler. This approach would also provide a gateway to iOS if you want that (ie, money) someday. Use the same library in the iOS version and write the UI in Swift.


scottHW

  • Newbie
  • Posts: 3
Re: Investigating FPC switch from Oxygene
« Reply #4 on: May 18, 2018, 06:19:44 pm »
The productivity of Android development is the primary concern.

The ported code came from (mostly) a Windows FPC code base. I could also revert to some of that, in places.

But consider the example code in the OP. That is Pascal syntax that mimics a common Android / Java syntax to set an OnClick listener. I do wonder how portable that is to FPC.

But again, if the development environment for Android isn't terrible robust, or if debugging only amounts to reading logcat files, it probably is a non-starter. That's the primary question.



Phil

  • Hero Member
  • *****
  • Posts: 2749
Re: Investigating FPC switch from Oxygene
« Reply #5 on: May 18, 2018, 06:33:13 pm »
But consider the example code in the OP. That is Pascal syntax that mimics a common Android / Java syntax to set an OnClick listener. I do wonder how portable that is to FPC.

FPC's JVM compiler does support something like that, providing a way to write Pascal syntax against the Android Java SDK.

I wrote a piece years ago on this. See Figure 3 for an example.

https://macpgmr.github.io/pba/PbaStatus.html

Take a look at what's in /usr/local/share/fpcsrc/rtl/android/jvm/androidr14.pas and .inc. I see, for example, an AWTextView class, declared like this:

  AWTextView = class external 'android.widget' name 'TextView' (AVView, AVViewTreeObserver.InnerOnPreDrawListener)

Probably what you're using in the example code.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus