PikeFramework

[ Start > PikeDevel > PikeFramework ] [ Edit this Page | Show Page Versions | Show Raw Source ]


The following commands can be used to generate a program that uses the Pike framework:

gcc -c itest.m -o itest.o
gcc itest.o -o itest -framework Pike -framework Foundation

Here's an example of using the framework to embed a Pike interpreter within your application:

#import <Pike/OCPikeInterpreter.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSString.h>

int main() { id i; struct svalue * sv;

// required for console mode objective c applications NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];

// these 3 lines set up and start the interpreter. i = [OCPikeInterpreter sharedInterpreter]; [i setMaster: @"/usr/local/pike/7.7.30/lib/master.pike"]; [i startInterpreter];

// ok, now that we have things set up, let's use it. // first, an example of calling pike c level apis directly. f_version(0); printf("%s&#110;", Pike_sp[-1].u.string->str); pop_stack();

// next, we'll demonstrate one of the convenience functions available sv = [i evalString: @"1+2"]; printf("type: %d, value: %d&#110;", sv->type, sv->u.integer); free_svalue(sv);

// finally, we clean up. [i stopInterpreter]; [innerPool release]; return 0; }

The following commands can be used in conjunction with Pike.framework to generate a Bundle that when loaded, fires up a Pike interpreter. I plan on using this in conjunction with the Public.ObjectiveC module to produce bundles that load up like a standard Objective-C bundle, but in which all of the classes are written completely in Pike.

Things that need to be done to achieve this:

1. A Universal Build of Pike.framework would be nice

  1. Bundling Public.ObjectiveC in Pike.framework
  2. Extending the OC_Bundle.m template to add the bundle's Resource directory to the Pike program path, and fire up Public.ObjectiveC.

    I expect #1 to be relatively simple to knock out: build Pike under PPC and Intel and then use lipo to build fat files for the Pike executable and any .so files.

    Number 2 and 3 are probably another evening's worth of work, I'd guess. So, not a whole lot of work to be expended before we can do all kinds of crazy stuff with Pike!

gcc -c ctest.m -o ctest.o
gcc ctest.o -o TestBundle -framework Pike -framework Foundation -flat_namespace -bundle -Wl,-U,_environ
cp TestBundle TestBundle.bundle/Contents/MacOS/

Powered by PikeWiki2

 
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University