November 13, 2012
Iain Buclaw <ibuclaw@ubuntu.com> writes:
>
> Doesn't Apple forbid any language except Objective-C ?  Or is that a misguided fallacy of mine? (Objective D, anyone? :-)

I think it once was so, but no longer.

http://stackoverflow.com/questions/3949995/what-programming-languages-can-one-use-to-develop-iphone-ipod-touch-and-ipad-i
November 13, 2012
On 2012-11-13 00:45, Iain Buclaw wrote:

> Doesn't Apple forbid any language except Objective-C ?  Or is that a
> misguided fallacy of mine? (Objective D, anyone? :-)

We actually do need Objective-D if we're going to run D on iOS. Fortunately we already have something, although it's not finished and it's getting old:

http://michelf.ca/projects/d-objc

This project makes it so much easier to interact with Objective-C. Which is needed on Mac OS X and iOS when you want to have a GUI.

-- 
/Jacob Carlborg
November 13, 2012
On 13 November 2012 01:19, Bernard Helyer <b.helyer@gmail.com> wrote:
> On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote:
> (Objective D, anyone? :-)
>
>
> Too far man. D:
>

Far out man. :o)


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
November 16, 2012
Dan Olson <zans.is.for.cans@yahoo.com> writes:

> Dan Olson <zans.is.for.cans@yahoo.com> writes:
>
>> Johannes Pfau <nospam@example.com> writes:
>>>
>>> _Dmodule_ref?
>>> You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But
>>> IIRC you have to compile with -nophoboslib to make it work)
>>> It's used by the runtime/compiler to setup the ModuleInfos but you
>>> don't have to initialize it, it just needs to be declared.
>>
>> I might try that.  It will give me a warm+fuzy before I get all of libgdruntime built.  It would just be a simple "Hello D" to the console using puts().
>
> Ok, that gave me an arm object file with simple D code.  I linked in to an iphone app.  When I run, module init code get called (yeah) but soon tries a move from an bad address.  Probably my own doing with my port of arm-darwin.  I'll look through Timo post, see if it is related.  Later this week I will compare my toolchain's D assembler output with a D arm-eabi chain, see what's up.

Well, I got some time to work on this again. More progress, although a baby step. D compiled code running in an iphone.

Looks like my modified gcc-4.8 -fPIC assembler output is not correct, but it (and PIE) is the default for an iphone toolchain. So for now I turn off PIC and then can compile and execute a simple D module that needs no druntime support or emutls.

That's it for now.  I include some of the details below if anyone is interested in following this.

ncc is an alias to a freshly built xgcc as I work on the gcc build:

# My latest gcc-4.8 for arm-darwin
alias ncc='/Users/dan/projects/gdc/ios-arm-obj/./gcc/xgcc -B/Users/dan/projects/gdc/ios-arm-obj/./gcc/ -B/usr/local/gdc-iosim/arm-apple-darwin/bin/ -B/usr/local/gdc-iosim/arm-apple-darwin/lib/ -isystem /usr/local/gdc-iosim/arm-apple-darwin/include -isystem /usr/local/gdc-iosim/arm-apple-darwin/sys-include --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk'

Build a .o (I have some warnings to look at):

$ ncc -O2 -fno-pic -I ~/projects/gdc/devnew/libphobos/libdruntime -c dhello.d
cc1d: warning: command line option '-fno-builtin-strcat' is valid for C/C++/ObjC/ObjC++ but not for D
cc1d: warning: command line option '-fno-builtin-strcpy' is valid for C/C++/ObjC/ObjC++ but not for D
cc1d: warning: this target does not support '-fsection-anchors'

The linker complains about not being able to use PIE (because I am cheating with -fno-pic). Also, link complains about CPU_SUBTYPE_ARM_ALL subtype is deprecated, so I need to look into that.

---- dhello.d ----

extern (C)
{
    __gshared void* _Dmodule_ref;

    int puts(const(char) *str);
    int write(int fd, const(void*) buf, int len);
}

extern(C) int dhello()
{
    puts("dhello is puts()ing this message");
    realDfunc();
    return 2012;
}

// shared, otherwise need emutls
shared string s = "A message from a D string\n";

void realDfunc()
{
    // need druntime support
    //auto m = s ~ "\n";

    foreach (c; s)
    {
        write(1, &c, 1);
    }
}


--- D output from my iphone (on xcode gdb console) ----

dhello is puts()ing this message
A message from a D string

dhello() returned 2012
November 16, 2012
On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote:
> Doesn't Apple forbid any language except Objective-C ?  Or is that a
> misguided fallacy of mine? (Objective D, anyone? :-)

As XCode natively supports C++ and that MonoTouch gays sells their "C# for iOS" fine Apple doesn't "forbid any language except Objective-C".

--
Денис В. Шеломовский
Denis V. Shelomovskij
November 16, 2012
On 2012-11-16 18:44, Denis V. Shelomovskij wrote:

> As XCode natively supports C++ and that MonoTouch gays sells their "C#
> for iOS" fine Apple doesn't "forbid any language except Objective-C".

Xcode has had support for C++ long before iPhone was developed. Originally the only allowed C, C++, Objective-C, HTML and JavaScript. Now they've removed that constraint and allows other languages.

-- 
/Jacob Carlborg
1 2
Next ›   Last »