r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Red] Red language group

Dockimbel
6-Nov-2011
[3685x3]
what is basically the difference of cdecl or stdcall?


See this wikipedia page for some basic info about calling conventions: 
http://en.wikipedia.org/wiki/X86_calling_conventions


Respectively - when wrapping API stuff, how do I know which one to 
use? 


When you're wrapping an API, you should find out how the library 
was compiled, and infer from that what calling convention is required. 
Most of C libs are using cdecl, while the Windows win32 API uses 
stdcall.
13.6.2: yes, it's a typo.
Typo fixed.
Pekr
6-Nov-2011
[3688]
small typos:

Similary, it is also possible to modify the c-string's bytes
  .... "similarly"
alias names should end with a exclamation mark
  .....  "an exclamation"
The stdcall attribut is also accepted
  ....  "attribute"


But - those are really small typos, you can probably spend your valuable 
time elsewhere :-)
Dockimbel
6-Nov-2011
[3689]
Thanks for reporting them. I will fix them now, that's just a couple 
minute work.
Pekr
6-Nov-2011
[3690]
btw: why was 'declare word used instead of 'make? Will there be 'make 
in a RED level, so you wanted to keep the difference?
Dockimbel
6-Nov-2011
[3691x3]
`make` implies a dynamic creation (at run-time), while these are 
static value declarations (at compile-time). There was a debate about 
that on the Red ML, see the thread for more info.
Right, `make` at Red level will have the same meaning as in REBOL.
BTW, there's no memory manager at Red/System level, so that you can't 
"make" a value, you can only declare it at compile-time. If you need 
dynamic values at run-time, you will need to use malloc/free wrappers 
provided by the Red/System runtime library.
BrianH
6-Nov-2011
[3694x2]
The NDK compiles C/C++ to fat binaries native code, not Dalvik. The 
native code interfaces with Dlvik code through JNI standard ABI. 
If you make Red compile to the JNI calling conventions, to will be 
much easier than rigging up a TCP control interface.
The NDK supports compiling to 3 different native formats right now 
- two ARM platforms, and x86. You can create an APK that supports 
one or more of these platforms. The binaries are packaged into an 
archive, with the binaries of different platforms put into subdirectories 
in that archive. When an APK is installed, only the binaries for 
the supported platform(s) are loaded.
Dockimbel
6-Nov-2011
[3696]
Using a JNI interface is my plan, but it requires to be able to generate 
Red/System shared libraries. I was mentioning the TCP option, as 
it could be done right now.
BrianH
6-Nov-2011
[3697]
If you are making a native compiler for Android, integrating with 
the NDK is the best way to go. Unless what you are making is a compiler 
that runs *on* Android devices, which would be great; then you would 
make the libraries for that compiler integrate with the NDK.
Dockimbel
6-Nov-2011
[3698]
Does the NDK provide access to all the GUI framework?
BrianH
6-Nov-2011
[3699]
Yes. Though some levels of access require more recent versions of 
Android. Fully native apps require 2.3 or above.
Dockimbel
6-Nov-2011
[3700]
That's very good news.
BrianH
6-Nov-2011
[3701x4]
Most Android phones run 2.2 or below, so that good is a bit limited.
I would personally appreciate it if you supported 2.2, as that is 
the last version that my phone model currently has been upgraded 
to. It would be a good idea to look up the stats for which percentages 
of Android phones are running which versions. I haven't seen a 1.5 
phone in over a year, but my gf's phone won't be upgraded past 1.6 
(I need to get her a new phone).
We did a lot of research into the NDK for the R3 project. I was really 
interested in how an Android host program would be structured, how 
the Android application model would map to the R3 model. Hint: Android 
doesn't really have applications at all.
In a lot of ways, Android reminds me of the Oberon System. You don't 
install apps, you install system services, that for some of the types 
of services provide a UI, and for other types of services provide 
an API or task execution model.
Dockimbel
6-Nov-2011
[3705]
I will probably go for 2.1 or 2.2 as minimal system requirement.
BrianH
6-Nov-2011
[3706x2]
Go for 2.0, and you'll cover almost everything. Certain Red facilities 
could require more recent versions, but between 2.0 and 2.2 there 
were mostly just features added, as far as native code is concerned. 
If you support pre-2.3, you might as well set the baseline as far 
back as 2.0.
There are a lot of people still waiting for their manufacturers to 
provide upgrades from 2.1 to 2.2, so 2.1 support is a good idea. 
The main thing added in 2.2 was the Dalvik JIT compiler, and that 
doesn't really affect native code that much. The NDK docs have a 
pretty good changelog that tells you what was added in each version.
Dockimbel
6-Nov-2011
[3708x2]
Yeah, I know the issue, I own an HTC Bravo stuck at 2.2.
I could go 2.3 with a custom ROM but I would loose HTC Sense UI.
BrianH
6-Nov-2011
[3710]
The new x86 support is pretty interesting. I have an old netbook 
I barely use now, which I could install Android on for experimentation. 
Don't forget x86 with your Android support :)
Dockimbel
6-Nov-2011
[3711]
Well, Android x86 is basically Linux x86, so you should be able to 
already run Red/System binaries on it.
BrianH
6-Nov-2011
[3712x3]
Never mind about the 2.0, even the NDK site lists it an an "other 
platform". I can't remember the last time I saw someone still stuck 
on 2.0.
Integrating with the Android non-application model is the most interesting 
point of running Android on that machine. If I wanted to run Linux 
binaries on it, I could keep Ubuntu on it.
Are you sticking to the ARM5 stuff, or integrating the ARM7 extensions
Dockimbel
6-Nov-2011
[3715x2]
Having fully access to the whole Android framework from Red is the 
goal. Running Linux binaries is the just the first experimental step.
I will stick with ARMv5 until we rewritte Red/System in Red and add 
a code optimizer. Such optimizer will be able to generate v6 and 
v7 specific code when required.
BrianH
6-Nov-2011
[3717]
Android lets you bundle seperate binaries for ARM5 and ARM7 support 
in the same APK. Which binaries get loaded depends on which level 
the phone supports, though if there's no ARM7 binary the ARM7 phone 
can run an ARM5 binary. If you want to do the progressive use of 
ARM7 features if ARM7 is available, it's best to let the APK do it 
for you. I don't think that there are any ARM6 devices for Android, 
especially since the NDK doesn't support them, but if you want to 
add ARM6 support for other platforms then cool.
Dockimbel
6-Nov-2011
[3718]
Well, I am not doing the ARM port only for Android, I target also 
iOS and some embedded boards (like e.g. the Raspberry Pi).
BrianH
6-Nov-2011
[3719]
Never mind about what I said about ARM6. Apparently some devices 
were ARM6 but claiming to be ARM7. Progressive support for ARM6 and 
maybe even ARM7 might be a good idea to add to the ARM5 binaries.
Pekr
6-Nov-2011
[3720]
BrianH: forget the phones of the past. Noone should care about "most 
phones running 2.2 or below". The release cycle is really fast. I 
would not care for pre 2.3 devices at all, just believe me ....
Dockimbel
6-Nov-2011
[3721]
http://developer.android.com/resources/dashboard/platform-versions.html

2.1: 10.7%
2.2: 40.7%
2.3: 43.9%
Pekr
6-Nov-2011
[3722]
Anything else is big waste of time. Just recently, there are two 
top Android phones - Samsung Galaxy SII and HTC Sensation. Both 2.3.4. 
Those are going to be upgraded to ICS. Before you finish the job, 
pre 2.3 falls into absolute irrelevancy, no matter how many tens 
of millions devices out there you claim.
Kaj
6-Nov-2011
[3723]
Because only supporting the latest Windows version has worked so 
well for REBOL?
Ryan
6-Nov-2011
[3724]
Not supporting phones was part of what killed rebols momentum, imo. 
Being the first alternative is hugely more valuable position than 
being a late coming alternative.
Pekr
6-Nov-2011
[3725]
Kaj - you should know, what you are talking about ...
Kaj
6-Nov-2011
[3726]
Whether I know what I'm talking about or not makes no difference 
in what people think of me
Pekr
7-Nov-2011
[3727]
I think nothing bad of you :-) For me, it is easy - you can't compare 
PC world, which I would assign 3+ years of lifecycle easily, with 
mobile world. In mobile world, I would say it is 2- lifecycle, or 
even shorter. If each day 300K of Android phones is activated, then 
I would pretty much decide to start supporting the almost latest 
models, which is - 2.3. Even my girlfriend HTC Wildfire S, which 
was published on 15.2.2011, is 2.3 version. Before Doc finishes the 
product, it will be old, and unsupported phone by its vendor. Of 
course, it depends upon the featureset you are going to support - 
if supporting pre 2.3 is a no brainer, why not. But - if 2.3 contains 
some real anhancements you want to utilise,then based upon the above 
usagedata, forget at least pre 2.2 ...
BrianH
7-Nov-2011
[3728x2]
Pekr, the top Android phones are the ones people already own, not 
the ones they haven't bought yet. And most of the ones they already 
own (in my country) are bought with 2-year contracts, not qualifying 
for a hardware upgrade until after that, and aren't able to be upgraded 
very much in software because that would compete with new phone purchases. 
It's good to see 2.2 adoption so high though. I am stuck on 2.2, 
btw.
Kaj, when has REBOL only supported the latest version of Windows? 
Even R3 doesn't support features in Windows newer than Win2k.
Kaj
7-Nov-2011
[3730x2]
I thought Petr was exaggerating, so I responded in style :-)
I do think that in practice, REBOL has usually been a Windows-only 
technology. Especially because its biggest draw is the easy GUI, 
and this is not (R3) or not well (R2) supported on anything but Windows. 
And because it still pretends to be cross-platform, there are even 
serious deployment problems on Windows
BrianH
7-Nov-2011
[3732x2]
Though to be fair, most of the deployment problems on Windows (for 
R2) come from it using the registry in a Win9x style.
We're getting a little off-topic here though. Go Red!
Kaj
7-Nov-2011
[3734]
Yes, my response was imperfect in that REBOL doesn't support the 
latest Windows well :-/