PikeFramework

[ Start > PikeDevel > PikeFramework ] [ Edit this Page | Viewing Version 2 ]


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; }


Powered by PikeWiki2

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