Permalink
Browse files

less fail wrt frames; let the plugin be compiled with iphone-gcc too

  • Loading branch information...
1 parent a41bcdd commit b4041a7f2b30176bcac79c024c1e0322ff160f67 Mobile User committed Jul 10, 2010
@@ -9,16 +9,16 @@
#import <UIKit/UIKit.h>
#define IOSFC_BUILDING_IOSFC
#include "IOSurface.h"
-@class Server;
+@class FServer;
@interface FlashViewController : UIViewController {
IOSurfaceRef sfc;
CGImageRef oldContents;
int rpcfd;
- Server *server;
+ FServer *server;
CGDataProviderRef provider;
}
-@property (retain) Server *server;
+@property (retain) FServer *server;
- (void)useSurface:(IOSurfaceRef)sfc;
- (void)displaySyncInRect:(CGRect *)rect;
- (CGSize)movieSize;
@@ -32,7 +32,7 @@ - (void)loadView {
- (void)clicked:(id)sender {
[self.server teardown];
- self.server = [[[Server alloc] initWithDelegate:self] autorelease];
+ self.server = [[[FServer alloc] initWithDelegate:self] autorelease];
rpcfd = ((FlashView *)self.view).rpcfd = self.server.rpc_fd;
CGSize size = [self movieSize];
set_movie_size(rpcfd, size.width, size.height);
@@ -22,10 +22,10 @@
IOSurfaceRef sfc;
int rpcfd;
- Server *server;
+ FServer *server;
}
-@property (retain) Server *server;
+@property (retain) FServer *server;
- (void)useSurface:(IOSurfaceRef)sfc;
- (void)displaySyncInRect:(CGRect *)rect;
@@ -50,7 +50,7 @@ - (void)webPlugInStart {
if(!on) { started = YES; return; }
NSLog(@"webPlugInStart");
[self webPlugInStop];
- self.server = [[[Server alloc] initWithDelegate:self] autorelease];
+ self.server = [[[FServer alloc] initWithDelegate:self] autorelease];
rpcfd = self.server.rpc_fd;
[self setSizeIfNecessary];
}
@@ -96,7 +96,7 @@ - (id)initWithArguments:(NSDictionary *)arguments_ {
if(w && h) {
int w_ = [w intValue];
int h_ = [h intValue];
- self.frame = CGRectMake (self.frame.origin.x, self.frame.origin.y, [w floatValue], [h floatValue]);
+ //self.frame = CGRectMake (self.frame.origin.x, self.frame.origin.y, [w floatValue], [h floatValue]);
if(w_ < 30 || h_ < 30) {
on = YES;
return self;
@@ -114,6 +114,9 @@ - (id)initWithArguments:(NSDictionary *)arguments_ {
[initialButton addTarget:self action:@selector(initialDown) forControlEvents:UIControlEventTouchDown];
[initialButton addTarget:self action:@selector(initialUp) forControlEvents:UIControlEventTouchUpOutside];
[self addSubview:initialButton];
+ self.autoresizesSubviews = YES;
+ initialButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+
//self.contentMode = UIViewContentModeRedraw;
//self.backgroundColor = [UIColor grayColor];
}
@@ -123,12 +126,13 @@ - (id)initWithArguments:(NSDictionary *)arguments_ {
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
// For some reason, the frame is constantly fluctating to +/-1 height.
- oldFrame = frame;
- oldFrameValid = YES;
if(oldFrameValid && fabsf(frame.size.height - oldFrame.size.height) < 1.5
&& fabsf(frame.size.width - oldFrame.size.width) < 1.5) {
+ // NSLog(@"Ignoring frame changae to %fx%f", frame.size.width, frame.size.height);
return;
}
+ oldFrame = frame;
+ oldFrameValid = YES;
NSLog(@"Frame changed (now %fx%f)", frame.size.width, frame.size.height);
[self setSizeIfNecessary];
initialButton.frame = self.bounds;
View
@@ -1,7 +1,7 @@
#pragma once
#import <Foundation/Foundation.h>
-@interface Server : NSObject {
+@interface FServer : NSObject {
id delegate;
CFRunLoopSourceRef serv_source;
int serv_fd;
View
@@ -0,0 +1,9 @@
+include ../../env.mk
+Plugin.dylib: PluginFlashView.o server.o food_rpc2.o
+ $(GCC) -dynamiclib -o $@ $^ -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework UIKit -framework IOSurface
+%.o: ../Classes/%.[cm]
+ $(GCC) -std=gnu99 -c -o $@ $< -I../Classes -I.. -Dstream_t=int
+%.o: ../%.[cm]
+ $(GCC) -std=gnu99 -c -o $@ $< -I../Classes -I.. -Dstream_t=int
+clean:
+ rm -f *.o Plugin.dylib
View
@@ -29,7 +29,7 @@
// C and Obj-C threading don't really play very well together.
static NSMutableDictionary *servers;
-static Server *get_server(int rpc_fd) {
+static FServer *get_server(int rpc_fd) {
return [servers objectForKey:[NSNumber numberWithInt:rpc_fd]];
}
/*@interface WebUndefined
@@ -112,12 +112,12 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection_ {
}
@end
-@implementation Server
+@implementation FServer
static void error(int rpc_fd, int err) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str;
if(err == 0) {
str = [NSString stringWithFormat:@"Unexpected error"];
@@ -203,36 +203,36 @@ - (void)dealloc {
}
int set_sekrit(int rpc_fd, void *sekrit_, size_t sekrit_len) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSLog(@"sekrit: %s", sekrit_);
if(!self->sekrit) self->sekrit = sekrit_;
return 0;
}
int abort_msg(int rpc_fd, void *message, size_t message_len) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str = [[[NSString alloc] initWithBytes:message length:message_len encoding:NSUTF8StringEncoding] autorelease];
[self dieWithError:str];
return 0;
}
int use_surface(int rpc_fd, int surface) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
IOSurfaceRef sfc = IOSurfaceLookup(surface);
if(!sfc) return 1;
[self->delegate performSelector:@selector(useSurface:) withObject:(id)sfc];
return 0;
}
int display_sync(int rpc_fd, int l, int t, int r, int b) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
CGRect rect = CGRectMake(l, t, r-l, b-t);
[self->delegate performSelector:@selector(displaySyncInRect:) withObject:(id)&rect];
return 0;
}
int new_post_connection(int rpc_fd, stream_t stream, void *url, size_t url_len, void *target, size_t target_len, bool isfile, void *buf, size_t buf_len, void **url_abs, size_t *url_abs_len) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str = [[[NSString alloc] initWithBytes:url length:url_len encoding:NSUTF8StringEncoding] autorelease];
NSURL *nsurl = [NSURL URLWithString:str relativeToURL:[self->delegate baseURL]];
@@ -257,7 +257,7 @@ int new_post_connection(int rpc_fd, stream_t stream, void *url, size_t url_len,
}
int new_get_connection(int rpc_fd, stream_t stream, void *url, size_t url_len, void *target, size_t target_len, void **url_abs, size_t *url_abs_len) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str = [[[NSString alloc] initWithBytes:url length:url_len encoding:NSUTF8StringEncoding] autorelease];
NSURL *nsurl = [NSURL URLWithString:str relativeToURL:[self->delegate baseURL]];
if(target_len > 0) {
@@ -297,7 +297,7 @@ int new_get_connection(int rpc_fd, stream_t stream, void *url, size_t url_len, v
int get_parameters(int rpc_fd, void **params, size_t *params_len, int *params_count) {
NSLog(@"GET_PARAMETERS");
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSDictionary *dict = [self->delegate performSelector:@selector(paramsDict)];
*params_count = [dict count];
@@ -335,7 +335,7 @@ - (id)objectForName:(int)name {
}
int get_string_value(int rpc_fd, int obj, bool *valid, void **value, size_t *value_len) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str = [self objectForName:obj];
NSLog(@"get_string_value %@", str);
if([str isKindOfClass:[NSString class]]) {
@@ -351,7 +351,7 @@ int get_string_value(int rpc_fd, int obj, bool *valid, void **value, size_t *val
}
int get_object_property(int rpc_fd, int obj, void *property, size_t property_len, int *obj2) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
if(![self->delegate performSelector:@selector(isOn)]) return 1;
NSString *str = [[NSString alloc] initWithBytes:property length:property_len encoding:NSUTF8StringEncoding];
id base = [self objectForName:obj];
@@ -364,20 +364,20 @@ int get_object_property(int rpc_fd, int obj, void *property, size_t property_len
}
int get_string_object(int rpc_fd, void *string, size_t string_len, int *obj2) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
*obj2 = [self nameForObject:[[[NSString alloc] initWithBytes:string length:string_len encoding:NSUTF8StringEncoding] autorelease]];
return 0;
}
int get_int_object(int rpc_fd, int theint, int *obj2) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
*obj2 = [self nameForObject:[NSNumber numberWithInt:theint]];
return 0;
}
int invoke_object_property(int rpc_fd, int obj, void *property, size_t property_len, void *args, size_t args_len, int *obj2) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
if(![self->delegate performSelector:@selector(isOn)]) return 1;
NSString *str = [[NSString alloc] initWithBytes:property length:property_len encoding:NSUTF8StringEncoding];
free(property);
@@ -412,7 +412,7 @@ int invoke_object_property(int rpc_fd, int obj, void *property, size_t property_
int get_window_object(int rpc_fd, int *obj) {
NSLog(@"Getting window object");
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
if(![self->delegate performSelector:@selector(isOn)]) return 1;
id windowObject = [self->delegate performSelector:@selector(getWindowObject)]; // windowScriptObject
*obj = [self nameForObject:windowObject];
@@ -421,7 +421,7 @@ int get_window_object(int rpc_fd, int *obj) {
}
int evaluate_web_script(int rpc_fd, void *script, size_t script_len, int *obj) {
- Server *self = get_server(rpc_fd);
+ FServer *self = get_server(rpc_fd);
NSString *str = [[NSString alloc] initWithBytes:script length:script_len encoding:NSUTF8StringEncoding];
id resultObject = [self->delegate performSelector:@selector(evaluateWebScript:) withObject:str];
*obj = [self nameForObject:resultObject];
View
2 env.mk
@@ -1,7 +1,7 @@
ifeq "$(shell arch)" "arm"
export IPHONE_GCC = 1
SDK := /var/sdk
-XSTUFF := --sysroot $(SDK)
+XSTUFF := --sysroot $(SDK) -F$(SDK)/System/Library/Frameworks -F$(SDK)/System/Library/PrivateFrameworks
GCC := gcc $(XSTUFF)
GXX := g++ $(XSTUFF)
else

0 comments on commit b4041a7

Please sign in to comment.