├── ios
├── build
│ └── .DS_Store
├── README
├── ProximitySensorANE
│ └── ProximitySensorANE-Prefix.pch
├── ProximitySensorANE.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── ProximitySensorANE.h
│ ├── DummyViewController.h
│ ├── DummyViewController.m
│ ├── ProximitySensorANE.m
│ └── project.pbxproj
└── FlashRuntimeExtensions.h
├── bin
├── ProximitySensor.ane
└── ProximitySensorANE.swc
├── android
├── README
├── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ ├── drawable-mdpi
│ │ └── icon.png
│ ├── values
│ │ └── strings.xml
│ └── layout
│ │ └── main.xml
├── default.properties
├── AndroidManifest.xml
├── src
│ └── se
│ │ └── riol
│ │ └── anes
│ │ └── proximitysensor
│ │ ├── ProximitySensorStopFunction.java
│ │ ├── ProximitySensorExtension.java
│ │ ├── ProximitySensorStartFunction.java
│ │ ├── ProximitySensorInitFunction.java
│ │ ├── ProximitySensorEventListener.java
│ │ └── ProximitySensorContext.java
├── gen
│ └── se
│ │ └── riol
│ │ └── anes
│ │ └── proximitysensor
│ │ └── R.java
└── proguard.cfg
├── default
└── src
│ └── se
│ └── riol
│ └── anes
│ └── proximitysensor
│ └── ProximitySensorInterface.as
├── as
└── src
│ └── se
│ └── riol
│ └── anes
│ └── proximitysensor
│ └── ProximitySensorInterface.as
├── extension.xml
└── README.markdown
/ios/build/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/ios/build/.DS_Store
--------------------------------------------------------------------------------
/bin/ProximitySensor.ane:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/bin/ProximitySensor.ane
--------------------------------------------------------------------------------
/bin/ProximitySensorANE.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/bin/ProximitySensorANE.swc
--------------------------------------------------------------------------------
/ios/README:
--------------------------------------------------------------------------------
1 | No build instructions for iOS yet. Please check back shortly or contact the
2 | author for instructions.
3 |
--------------------------------------------------------------------------------
/android/README:
--------------------------------------------------------------------------------
1 | No build instructions for Android yet. Please check back shortly or contact the
2 | author for instructions.
3 |
--------------------------------------------------------------------------------
/android/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/android/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/android/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/android/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/android/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/richardolsson/proximity-sensor-ane/HEAD/android/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World!
4 | ProximityExtension
5 |
6 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE/ProximitySensorANE-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'ProximitySensorANE' target in the 'ProximitySensorANE' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/ProximitySensorANE.h:
--------------------------------------------------------------------------------
1 | //
2 | // ProximitySensorANE.h
3 | // ProximitySensorANE
4 | //
5 | // Created by Richard Olsson on 2011-10-31.
6 | // Copyright 2011 Richard Olsson Web Development AB. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @interface ProximitySensorANE {
13 |
14 | }
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/android/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-8
12 |
--------------------------------------------------------------------------------
/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/android/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorStopFunction.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import com.adobe.fre.FREContext;
4 | import com.adobe.fre.FREFunction;
5 | import com.adobe.fre.FREObject;
6 |
7 | public class ProximitySensorStopFunction implements FREFunction {
8 |
9 | public FREObject call(FREContext context, FREObject[] args) {
10 | ProximitySensorContext psContext = (ProximitySensorContext)context;
11 | psContext.stopListening();
12 | return null;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorExtension.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import com.adobe.fre.FREContext;
4 | import com.adobe.fre.FREExtension;
5 |
6 | public class ProximitySensorExtension implements FREExtension {
7 |
8 | public FREContext createContext(String arg0) {
9 | return new ProximitySensorContext();
10 | }
11 |
12 | public void dispose() {
13 | // TODO Auto-generated method stub
14 |
15 | }
16 |
17 | public void initialize() {
18 | // TODO Auto-generated method stub
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/default/src/se/riol/anes/proximitysensor/ProximitySensorInterface.as:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor
2 | {
3 | import flash.events.EventDispatcher;
4 |
5 | public class ProximitySensorInterface extends EventDispatcher
6 | {
7 | public function ProximitySensorInterface()
8 | {
9 | }
10 |
11 |
12 | public function init() : void
13 | {
14 | trace('dummy prox sensor init');
15 | }
16 |
17 |
18 | public function start() : void
19 | {
20 | trace('dummy prox sensor start');
21 | }
22 |
23 |
24 | public function stop() : void
25 | {
26 | trace('dummy prox sensor stop');
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorStartFunction.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import android.util.Log;
4 |
5 | import com.adobe.fre.FREContext;
6 | import com.adobe.fre.FREFunction;
7 | import com.adobe.fre.FREObject;
8 |
9 | public class ProximitySensorStartFunction implements FREFunction {
10 |
11 | public FREObject call(FREContext context, FREObject[] args) {
12 | Log.d("se.riol.anes.proximitysensor", "ProximitySensorStartFunction.call()");
13 | ProximitySensorContext psContext = (ProximitySensorContext)context;
14 | psContext.startListening();
15 | return null;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/DummyViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // DummyViewController.h
3 | // ProximitySensorANE
4 | //
5 | // Created by Richard Olsson on 2011-10-31.
6 | // Copyright 2011 Richard Olsson Web Development AB. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "FlashRuntimeExtensions.h"
11 |
12 | @interface DummyViewController : UIViewController {
13 |
14 | BOOL inProximity;
15 | FREContext context;
16 | CADisplayLink *displayLink;
17 | }
18 |
19 | - (id) initWithContext: (FREContext)ctx;
20 | - (void) startListening;
21 | - (void) stopListening;
22 | - (void) update;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/android/gen/se/riol/anes/proximitysensor/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package se.riol.anes.proximitysensor;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int icon=0x7f020000;
15 | }
16 | public static final class layout {
17 | public static final int main=0x7f030000;
18 | }
19 | public static final class string {
20 | public static final int app_name=0x7f040001;
21 | public static final int hello=0x7f040000;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorInitFunction.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import android.app.Activity;
4 | import android.hardware.SensorManager;
5 | import android.util.Log;
6 |
7 | import com.adobe.fre.FREContext;
8 | import com.adobe.fre.FREFunction;
9 | import com.adobe.fre.FREObject;
10 |
11 | public class ProximitySensorInitFunction implements FREFunction {
12 |
13 | public FREObject call(FREContext context, FREObject[] args) {
14 | SensorManager sensorManager;
15 | ProximitySensorContext psContext;
16 |
17 | Log.d("se.riol.anes.proximitysensor", "initializing!");
18 |
19 | psContext = (ProximitySensorContext)context;
20 | sensorManager = (SensorManager) psContext.getActivity().getSystemService(Activity.SENSOR_SERVICE);
21 |
22 | psContext.init(sensorManager);
23 | return null;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorEventListener.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import android.hardware.Sensor;
4 | import android.hardware.SensorEvent;
5 | import android.hardware.SensorEventListener;
6 | import android.util.Log;
7 |
8 | public class ProximitySensorEventListener implements SensorEventListener {
9 |
10 | private ProximitySensorContext context;
11 |
12 | public ProximitySensorEventListener(ProximitySensorContext context) {
13 | this.context = context;
14 | }
15 |
16 | public void onAccuracyChanged(Sensor arg0, int arg1) {
17 | // TODO Auto-generated method stub
18 |
19 | }
20 |
21 | public void onSensorChanged(SensorEvent event) {
22 | Log.d("se.riol.proximitysensor", "Got update! "+Float.toString(event.values[0]));
23 | context.dispatchStatusEventAsync("CHANGE", Float.toString((Float)event.values[0]));
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/as/src/se/riol/anes/proximitysensor/ProximitySensorInterface.as:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor
2 | {
3 | import flash.events.EventDispatcher;
4 | import flash.events.StatusEvent;
5 | import flash.external.ExtensionContext;
6 |
7 | public class ProximitySensorInterface extends EventDispatcher
8 | {
9 | private var _context : ExtensionContext;
10 |
11 | public function ProximitySensorInterface()
12 | {
13 | if (!_context) {
14 | _context = ExtensionContext.createExtensionContext("se.riol.anes.proximitysensor", null);
15 | _context.addEventListener(StatusEvent.STATUS, _handleContextStatus);
16 | _context.call('init');
17 | }
18 | }
19 |
20 | public function start() : void
21 | {
22 | if (_context)
23 | _context.call("start");
24 | }
25 |
26 |
27 | public function stop() : void
28 | {
29 | if (_context)
30 | _context.call("stop");
31 | }
32 |
33 |
34 | private function _handleContextStatus(ev : StatusEvent) : void
35 | {
36 | this.dispatchEvent(ev.clone());
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/extension.xml:
--------------------------------------------------------------------------------
1 |
2 | se.riol.anes.proximitysensor
3 | 1
4 |
5 |
6 |
7 | proximitysensor.jar
8 | se.riol.anes.proximitysensor.ProximitySensorExtension
9 | se.riol.anes.proximitysensor.ProximitySensorExtension
10 |
11 |
12 |
13 |
14 |
15 | libProximitySensorANE.a
16 | ANEInitializer
17 | ANEFinalizer
18 |
19 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/android/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/android/src/se/riol/anes/proximitysensor/ProximitySensorContext.java:
--------------------------------------------------------------------------------
1 | package se.riol.anes.proximitysensor;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import android.hardware.Sensor;
7 | import android.hardware.SensorManager;
8 | import android.util.Log;
9 |
10 | import com.adobe.fre.FREContext;
11 | import com.adobe.fre.FREFunction;
12 |
13 | public class ProximitySensorContext extends FREContext {
14 |
15 | private Sensor proximitySensor;
16 | private SensorManager sensorManager;
17 | private ProximitySensorEventListener sensorListener;
18 |
19 |
20 | public void init(SensorManager sensMgr) {
21 | sensorManager = sensMgr;
22 | sensorListener = new ProximitySensorEventListener(this);
23 | proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
24 | }
25 |
26 | @Override
27 | public void dispose() {
28 | // TODO Auto-generated method stub
29 |
30 | }
31 |
32 | public void startListening() {
33 | Log.d("se.riol.anes.proximitysensor", "Start listening");
34 | sensorManager.registerListener(sensorListener, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL);
35 | }
36 |
37 | public void stopListening() {
38 | Log.d("se.riol.anes.proximitysensor", "Stop listening");
39 | sensorManager.unregisterListener(sensorListener);
40 | }
41 |
42 | @Override
43 | public Map getFunctions() {
44 | Map map = new HashMap();
45 |
46 | map.put("init", new ProximitySensorInitFunction());
47 | map.put("start", new ProximitySensorStartFunction());
48 | map.put("stop", new ProximitySensorStopFunction());
49 |
50 | return map;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | This is a so called Native Extension for Adobe AIR 3, which will allow you
2 | to read the output of the proximity sensor on devices which have one.
3 |
4 | Both Android and iOS support is provided, as well as a "default" implementation
5 | which will never dispatch any events (necessary to run app in the simulator
6 | on desktop.)
7 |
8 | The "android" and "ios" folders contain the native libraries for Android (Java)
9 | and iOS (C/ObjC) respectively. The "default" folder contains the dummy AS3
10 | implementation, and the "as" folder contains the AS3 extension interface.
11 |
12 | For more information on Native Extensions, see the page at the following URL:
13 | http://www.adobe.com/devnet/air/native-extensions-for-air.html
14 |
15 | # How to use
16 | In the bin folder you will find both an ANE file and a SWC file. Configure
17 | your tool (e.g. Flash Builder 4.6) to use the ANE file while packaging, and
18 | add the SWC file to your SWC path. That should be enough to set it up.
19 |
20 | The class to use is called `ProximitySensorInterface` and resides in the
21 | `se.riol.anes.proximitysensor` package. It has a `start()` and a `stop()`
22 | method to start and stop proximity sensor polling respectively. When the
23 | sensor detects a change in proximity, a `StatusEvent` is dispatched.
24 |
25 | Here's some very basic sample code, in lieu of a proper example:
26 |
27 | import se.riol.anes.proximitysensor.ProximitySensorInterface;
28 |
29 | var proximity : ProximitySensorInterface;
30 | proximity = new ProximitySensorInterface();
31 | proximity.addEventListener(StatusEvent.STATUS, handleProximity);
32 | proximity.start();
33 |
34 | function handleProximity(ev : StatusEvent) : void
35 | {
36 | trace('proximity: '+ev.level);
37 | }
38 |
39 |
40 | # How to help develop
41 | See README files in the folders for the respective platforms/targets for build
42 | instructions.
43 |
44 |
45 | # TODO:
46 | - Clean up interface (possibly rename main class)
47 | - Replace with better event type than the standard ANE StatusEvent
48 | - Write build instructions for all platforms.
49 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/DummyViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // DummyViewController.m
3 | // ProximitySensorANE
4 | //
5 | // Created by Richard Olsson on 2011-10-31.
6 | // Copyright 2011 Richard Olsson Web Development AB. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "FlashRuntimeExtensions.h"
12 | #import "DummyViewController.h"
13 |
14 |
15 | @implementation DummyViewController
16 |
17 | - (id)initWithContext: (FREContext) ctx
18 | {
19 | self = [super init];
20 | if (self) {
21 | context = ctx;
22 | }
23 |
24 | return self;
25 | }
26 |
27 |
28 | - (void)startListening
29 | {
30 | NSLog(@"enabling proximity sensor");
31 | [UIDevice currentDevice].proximityMonitoringEnabled = YES;
32 | NSLog(@"Enabled!");
33 |
34 | NSLog(@"has display link?");
35 | if (displayLink == Nil) {
36 | NSLog(@"No, creating!");
37 | displayLink = [[UIScreen mainScreen]
38 | displayLinkWithTarget:self selector:@selector(update)];
39 |
40 | NSLog(@"Retaining link");
41 | [displayLink retain];
42 |
43 | NSLog(@"Setting interval");
44 | [displayLink setFrameInterval:4];
45 | }
46 |
47 | NSLog(@"Adding to run loop");
48 | [displayLink addToRunLoop: [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
49 | NSLog(@"Added!");
50 | }
51 |
52 |
53 | - (void)stopListening
54 | {
55 | NSLog(@"Disabling proximity sensor");
56 | [UIDevice currentDevice].proximityMonitoringEnabled = NO;
57 | NSLog(@"Disabled! Now removing from loop.");
58 | [displayLink removeFromRunLoop: [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
59 | NSLog(@"Removed!");
60 | }
61 |
62 | - (void)update
63 | {
64 | BOOL curState = [UIDevice currentDevice].proximityState;
65 |
66 | if (inProximity != curState) {
67 | if (curState) {
68 | NSLog(@"Nearby");
69 | FREDispatchStatusEventAsync(context, (const uint8_t*)"CHANGE", (const uint8_t*)"1");
70 | }
71 | else {
72 | NSLog(@"Far away");
73 | FREDispatchStatusEventAsync(context, (const uint8_t*)"CHANGE", (const uint8_t*)"0");
74 | }
75 | }
76 |
77 | inProximity = curState;
78 | }
79 |
80 |
81 | - (void)dealloc
82 | {
83 | [super dealloc];
84 | }
85 | @end
86 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/ProximitySensorANE.m:
--------------------------------------------------------------------------------
1 | //
2 | // ProximitySensorANE.m
3 | // ProximitySensorANE
4 | //
5 | // Created by Richard Olsson on 2011-10-31.
6 | // Copyright 2011 Richard Olsson Web Development AB. All rights reserved.
7 | //
8 |
9 | #include
10 |
11 | #import
12 |
13 | //#import "ProximitySensorANE.h"
14 | #import "DummyViewController.h"
15 | #import "FlashRuntimeExtensions.h"
16 |
17 |
18 | DummyViewController *dummyController;
19 |
20 |
21 | FREObject ext_init(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
22 | {
23 | dummyController = [[[DummyViewController alloc] retain] initWithContext:ctx];
24 |
25 | return NULL;
26 | }
27 |
28 | FREObject ext_startListening(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
29 | {
30 | [dummyController startListening];
31 |
32 | //TODO: Return something
33 | return NULL;
34 | }
35 |
36 | FREObject ext_stopListening(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
37 | {
38 | [dummyController stopListening];
39 |
40 | //TODO: Return something
41 | return NULL;
42 | }
43 |
44 | void initializeContext(void* extData, const uint8_t* ctxType, FREContext ctx,
45 | uint32_t* numFunctionsToSet, const FRENamedFunction** functionsToSet)
46 | {
47 | *numFunctionsToSet = 3;
48 | FRENamedFunction* funcs = (FRENamedFunction*)malloc(sizeof(FRENamedFunction) * 3);
49 |
50 | funcs[0].name = (const uint8_t*)"init";
51 | funcs[0].functionData = NULL;
52 | funcs[0].function = &ext_init;
53 |
54 | funcs[1].name = (const uint8_t*)"start";
55 | funcs[1].functionData = NULL;
56 | funcs[1].function = &ext_startListening;
57 |
58 | funcs[2].name = (const uint8_t*)"stop";
59 | funcs[2].functionData = NULL;
60 | funcs[2].function = &ext_stopListening;
61 |
62 | *functionsToSet = funcs;
63 | }
64 |
65 |
66 | void finalizeContext(FREContext ctx)
67 | {
68 | if (dummyController) {
69 | [dummyController stopListening];
70 | [dummyController dealloc];
71 | }
72 | }
73 |
74 | void ANEInitializer(void **extDataToSet, FREContextInitializer* ctxInitializerToSet,
75 | FREContextFinalizer* ctxFinalizerToSet)
76 | {
77 |
78 | *extDataToSet = NULL;
79 | *ctxInitializerToSet = &initializeContext;
80 | *ctxFinalizerToSet = &finalizeContext;
81 | }
82 |
83 | void ANEFinalizer(void* extData)
84 | {
85 | // TODO: Clean up
86 | }
87 |
--------------------------------------------------------------------------------
/ios/ProximitySensorANE.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | DF823845145E7FA600CAFA87 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF823844145E7FA600CAFA87 /* Foundation.framework */; };
11 | DF823868145E838700CAFA87 /* ProximitySensorANE.m in Sources */ = {isa = PBXBuildFile; fileRef = DF823866145E838700CAFA87 /* ProximitySensorANE.m */; };
12 | DF82386B145E83D700CAFA87 /* FlashRuntimeExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = DF82386A145E83D700CAFA87 /* FlashRuntimeExtensions.h */; };
13 | DF823874145E98FA00CAFA87 /* DummyViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = DF823872145E98FA00CAFA87 /* DummyViewController.h */; };
14 | DF823875145E98FA00CAFA87 /* DummyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DF823873145E98FA00CAFA87 /* DummyViewController.m */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | DF823841145E7FA600CAFA87 /* libProximitySensorANE.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libProximitySensorANE.a; sourceTree = BUILT_PRODUCTS_DIR; };
19 | DF823844145E7FA600CAFA87 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
20 | DF823848145E7FA600CAFA87 /* ProximitySensorANE-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ProximitySensorANE-Prefix.pch"; sourceTree = ""; };
21 | DF823866145E838700CAFA87 /* ProximitySensorANE.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProximitySensorANE.m; path = ProximitySensorANE.xcodeproj/ProximitySensorANE.m; sourceTree = ""; };
22 | DF82386A145E83D700CAFA87 /* FlashRuntimeExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlashRuntimeExtensions.h; sourceTree = ""; };
23 | DF823872145E98FA00CAFA87 /* DummyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DummyViewController.h; path = ProximitySensorANE.xcodeproj/DummyViewController.h; sourceTree = ""; };
24 | DF823873145E98FA00CAFA87 /* DummyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DummyViewController.m; path = ProximitySensorANE.xcodeproj/DummyViewController.m; sourceTree = ""; wrapsLines = 0; };
25 | /* End PBXFileReference section */
26 |
27 | /* Begin PBXFrameworksBuildPhase section */
28 | DF82383E145E7FA600CAFA87 /* Frameworks */ = {
29 | isa = PBXFrameworksBuildPhase;
30 | buildActionMask = 2147483647;
31 | files = (
32 | DF823845145E7FA600CAFA87 /* Foundation.framework in Frameworks */,
33 | );
34 | runOnlyForDeploymentPostprocessing = 0;
35 | };
36 | /* End PBXFrameworksBuildPhase section */
37 |
38 | /* Begin PBXGroup section */
39 | DF823836145E7FA600CAFA87 = {
40 | isa = PBXGroup;
41 | children = (
42 | DF823872145E98FA00CAFA87 /* DummyViewController.h */,
43 | DF823873145E98FA00CAFA87 /* DummyViewController.m */,
44 | DF823866145E838700CAFA87 /* ProximitySensorANE.m */,
45 | DF823846145E7FA600CAFA87 /* ProximitySensorANE */,
46 | DF823843145E7FA600CAFA87 /* Frameworks */,
47 | DF823842145E7FA600CAFA87 /* Products */,
48 | DF82386A145E83D700CAFA87 /* FlashRuntimeExtensions.h */,
49 | );
50 | sourceTree = "";
51 | };
52 | DF823842145E7FA600CAFA87 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | DF823841145E7FA600CAFA87 /* libProximitySensorANE.a */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | DF823843145E7FA600CAFA87 /* Frameworks */ = {
61 | isa = PBXGroup;
62 | children = (
63 | DF823844145E7FA600CAFA87 /* Foundation.framework */,
64 | );
65 | name = Frameworks;
66 | sourceTree = "";
67 | };
68 | DF823846145E7FA600CAFA87 /* ProximitySensorANE */ = {
69 | isa = PBXGroup;
70 | children = (
71 | DF823847145E7FA600CAFA87 /* Supporting Files */,
72 | );
73 | path = ProximitySensorANE;
74 | sourceTree = "";
75 | };
76 | DF823847145E7FA600CAFA87 /* Supporting Files */ = {
77 | isa = PBXGroup;
78 | children = (
79 | DF823848145E7FA600CAFA87 /* ProximitySensorANE-Prefix.pch */,
80 | );
81 | name = "Supporting Files";
82 | sourceTree = "";
83 | };
84 | /* End PBXGroup section */
85 |
86 | /* Begin PBXHeadersBuildPhase section */
87 | DF82383F145E7FA600CAFA87 /* Headers */ = {
88 | isa = PBXHeadersBuildPhase;
89 | buildActionMask = 2147483647;
90 | files = (
91 | DF82386B145E83D700CAFA87 /* FlashRuntimeExtensions.h in Headers */,
92 | DF823874145E98FA00CAFA87 /* DummyViewController.h in Headers */,
93 | );
94 | runOnlyForDeploymentPostprocessing = 0;
95 | };
96 | /* End PBXHeadersBuildPhase section */
97 |
98 | /* Begin PBXNativeTarget section */
99 | DF823840145E7FA600CAFA87 /* ProximitySensorANE */ = {
100 | isa = PBXNativeTarget;
101 | buildConfigurationList = DF82384B145E7FA600CAFA87 /* Build configuration list for PBXNativeTarget "ProximitySensorANE" */;
102 | buildPhases = (
103 | DF82383D145E7FA600CAFA87 /* Sources */,
104 | DF82383E145E7FA600CAFA87 /* Frameworks */,
105 | DF82383F145E7FA600CAFA87 /* Headers */,
106 | );
107 | buildRules = (
108 | );
109 | dependencies = (
110 | );
111 | name = ProximitySensorANE;
112 | productName = ProximitySensorANE;
113 | productReference = DF823841145E7FA600CAFA87 /* libProximitySensorANE.a */;
114 | productType = "com.apple.product-type.library.static";
115 | };
116 | /* End PBXNativeTarget section */
117 |
118 | /* Begin PBXProject section */
119 | DF823838145E7FA600CAFA87 /* Project object */ = {
120 | isa = PBXProject;
121 | attributes = {
122 | ORGANIZATIONNAME = "Richard Olsson Web Development AB";
123 | };
124 | buildConfigurationList = DF82383B145E7FA600CAFA87 /* Build configuration list for PBXProject "ProximitySensorANE" */;
125 | compatibilityVersion = "Xcode 3.2";
126 | developmentRegion = English;
127 | hasScannedForEncodings = 0;
128 | knownRegions = (
129 | en,
130 | );
131 | mainGroup = DF823836145E7FA600CAFA87;
132 | productRefGroup = DF823842145E7FA600CAFA87 /* Products */;
133 | projectDirPath = "";
134 | projectRoot = "";
135 | targets = (
136 | DF823840145E7FA600CAFA87 /* ProximitySensorANE */,
137 | );
138 | };
139 | /* End PBXProject section */
140 |
141 | /* Begin PBXSourcesBuildPhase section */
142 | DF82383D145E7FA600CAFA87 /* Sources */ = {
143 | isa = PBXSourcesBuildPhase;
144 | buildActionMask = 2147483647;
145 | files = (
146 | DF823868145E838700CAFA87 /* ProximitySensorANE.m in Sources */,
147 | DF823875145E98FA00CAFA87 /* DummyViewController.m in Sources */,
148 | );
149 | runOnlyForDeploymentPostprocessing = 0;
150 | };
151 | /* End PBXSourcesBuildPhase section */
152 |
153 | /* Begin XCBuildConfiguration section */
154 | DF823849145E7FA600CAFA87 /* Debug */ = {
155 | isa = XCBuildConfiguration;
156 | buildSettings = {
157 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
158 | GCC_C_LANGUAGE_STANDARD = gnu99;
159 | GCC_OPTIMIZATION_LEVEL = 0;
160 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
161 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
162 | GCC_VERSION = com.apple.compilers.llvmgcc42;
163 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
164 | GCC_WARN_UNUSED_VARIABLE = YES;
165 | IPHONEOS_DEPLOYMENT_TARGET = 4.3;
166 | SDKROOT = iphoneos;
167 | };
168 | name = Debug;
169 | };
170 | DF82384A145E7FA600CAFA87 /* Release */ = {
171 | isa = XCBuildConfiguration;
172 | buildSettings = {
173 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
174 | GCC_C_LANGUAGE_STANDARD = gnu99;
175 | GCC_VERSION = com.apple.compilers.llvmgcc42;
176 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
177 | GCC_WARN_UNUSED_VARIABLE = YES;
178 | IPHONEOS_DEPLOYMENT_TARGET = 4.3;
179 | SDKROOT = iphoneos;
180 | };
181 | name = Release;
182 | };
183 | DF82384C145E7FA600CAFA87 /* Debug */ = {
184 | isa = XCBuildConfiguration;
185 | buildSettings = {
186 | ALWAYS_SEARCH_USER_PATHS = NO;
187 | DSTROOT = /tmp/ProximitySensorANE.dst;
188 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
189 | GCC_PREFIX_HEADER = "ProximitySensorANE/ProximitySensorANE-Prefix.pch";
190 | OTHER_LDFLAGS = "-ObjC";
191 | PRODUCT_NAME = "$(TARGET_NAME)";
192 | };
193 | name = Debug;
194 | };
195 | DF82384D145E7FA600CAFA87 /* Release */ = {
196 | isa = XCBuildConfiguration;
197 | buildSettings = {
198 | ALWAYS_SEARCH_USER_PATHS = NO;
199 | DSTROOT = /tmp/ProximitySensorANE.dst;
200 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
201 | GCC_PREFIX_HEADER = "ProximitySensorANE/ProximitySensorANE-Prefix.pch";
202 | OTHER_LDFLAGS = "-ObjC";
203 | PRODUCT_NAME = "$(TARGET_NAME)";
204 | };
205 | name = Release;
206 | };
207 | /* End XCBuildConfiguration section */
208 |
209 | /* Begin XCConfigurationList section */
210 | DF82383B145E7FA600CAFA87 /* Build configuration list for PBXProject "ProximitySensorANE" */ = {
211 | isa = XCConfigurationList;
212 | buildConfigurations = (
213 | DF823849145E7FA600CAFA87 /* Debug */,
214 | DF82384A145E7FA600CAFA87 /* Release */,
215 | );
216 | defaultConfigurationIsVisible = 0;
217 | defaultConfigurationName = Release;
218 | };
219 | DF82384B145E7FA600CAFA87 /* Build configuration list for PBXNativeTarget "ProximitySensorANE" */ = {
220 | isa = XCConfigurationList;
221 | buildConfigurations = (
222 | DF82384C145E7FA600CAFA87 /* Debug */,
223 | DF82384D145E7FA600CAFA87 /* Release */,
224 | );
225 | defaultConfigurationIsVisible = 0;
226 | defaultConfigurationName = Release;
227 | };
228 | /* End XCConfigurationList section */
229 | };
230 | rootObject = DF823838145E7FA600CAFA87 /* Project object */;
231 | }
232 |
--------------------------------------------------------------------------------
/ios/FlashRuntimeExtensions.h:
--------------------------------------------------------------------------------
1 | // ADOBE CONFIDENTIAL
2 | //
3 | // Copyright 2011 Adobe Systems Incorporated All Rights Reserved.
4 | //
5 | // NOTICE: All information contained herein is, and remains the property of
6 | // Adobe Systems Incorporated and its suppliers, if any. The intellectual and
7 | // technical concepts contained herein are proprietary to Adobe Systems
8 | // Incorporated and its suppliers and may be covered by U.S. and Foreign
9 | // Patents, patents in process, and are protected by trade secret or copyright
10 | // law. Dissemination of this information or reproduction of this material
11 | // is strictly forbidden unless prior written permission is obtained from
12 | // Adobe Systems Incorporated.
13 |
14 | // AdobePatentID="P969"
15 |
16 | #ifdef WIN32
17 | typedef unsigned __int32 uint32_t;
18 | typedef unsigned __int8 uint8_t;
19 | typedef __int32 int32_t;
20 | #else
21 | #include
22 | #endif
23 |
24 | #ifndef FRNATIVEEXTENSIONS_H_
25 | #define FRNATIVEEXTENSIONS_H_
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | typedef void * FREContext;
32 | typedef void * FREObject;
33 |
34 | /* Initialization *************************************************************/
35 |
36 | /**
37 | * Defines the signature for native calls that can be invoked via an
38 | * instance of the AS ExtensionContext class.
39 | *
40 | * @return The return value corresponds to the return value
41 | * from the AS ExtensionContext class call() method. It defaults to
42 | * FRE_INVALID_OBJECT, which is reported as null in AS.
43 | */
44 |
45 | typedef FREObject (*FREFunction)(
46 | FREContext ctx,
47 | void* functionData,
48 | uint32_t argc,
49 | FREObject argv[]
50 | );
51 |
52 | typedef struct FRENamedFunction_ {
53 | const uint8_t* name;
54 | void* functionData;
55 | FREFunction function;
56 | } FRENamedFunction;
57 |
58 | /**
59 | * Defines the signature for the initializer that is called each time
60 | * a new AS ExtensionContext object is created.
61 | *
62 | * @param extData The extension client data provided to the FREInitializer function as extDataToSet.
63 | *
64 | * @param ctxType Pointer to the contextType string (UTF8) as provided to the AS createExtensionContext call.
65 | *
66 | * @param ctx The FREContext being initialized.
67 | *
68 | * @param numFunctionsToSet The number of elements in the functionsToSet array.
69 | *
70 | * @param functionsToSet A pointer to an array of FRENamedFunction elements.
71 | */
72 |
73 | typedef void (*FREContextInitializer)(
74 | void* extData ,
75 | const uint8_t* ctxType ,
76 | FREContext ctx ,
77 | uint32_t* numFunctionsToSet,
78 | const FRENamedFunction** functionsToSet
79 | );
80 |
81 | /**
82 | * Defines the signature for the finalizer that is called each time
83 | * an ExtensionContext instance is disposed.
84 | */
85 |
86 | typedef void (*FREContextFinalizer)(
87 | FREContext ctx
88 | );
89 |
90 | /**
91 | * The initialization function provided by each extension must conform
92 | * to the following signature.
93 | *
94 | * @param extDataToSet Provided for the extension to store per-extension instance data.
95 | * For example, if the extension creates
96 | * globals per-instance, it can store a pointer to them here.
97 | *
98 | * @param ctxInitializerToSet Must be set to a pointer to a function
99 | * of type FREContextInitializer. Will be invoked whenever
100 | * the ActionScript code creates a new context for this extension.
101 | *
102 | * @param ctxFinalizerToSet Must be set to a pointer to a function
103 | * of type FREContextFinalizer.
104 | */
105 |
106 | typedef void (*FREInitializer)(
107 | void** extDataToSet ,
108 | FREContextInitializer* ctxInitializerToSet,
109 | FREContextFinalizer* ctxFinalizerToSet
110 | );
111 |
112 | /**
113 | * Called iff the extension is unloaded from the process. Extensions
114 | * are not guaranteed to be unloaded; the runtime process may exit without
115 | * doing so.
116 | */
117 |
118 | typedef void (*FREFinalizer)(
119 | void* extData
120 | );
121 |
122 | /* Result Codes ***************************************************************/
123 | /**
124 | * These values must not be changed.
125 | */
126 |
127 | typedef enum {
128 | FRE_OK = 0,
129 | FRE_NO_SUCH_NAME = 1,
130 | FRE_INVALID_OBJECT = 2,
131 | FRE_TYPE_MISMATCH = 3,
132 | FRE_ACTIONSCRIPT_ERROR = 4,
133 | FRE_INVALID_ARGUMENT = 5,
134 | FRE_READ_ONLY = 6,
135 | FRE_WRONG_THREAD = 7,
136 | FRE_ILLEGAL_STATE = 8,
137 | FRE_INSUFFICIENT_MEMORY = 9,
138 | FREResult_ENUMPADDING = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */
139 | } FREResult;
140 |
141 | /* Context Data ************************************************************/
142 |
143 | /**
144 | * @returns FRE_OK
145 | * FRE_WRONG_THREAD
146 | * FRE_INVALID_ARGUMENT If nativeData is null.
147 | */
148 |
149 | FREResult FREGetContextNativeData( FREContext ctx, void** nativeData );
150 |
151 | /**
152 | * @returns FRE_OK
153 | * FRE_INVALID_ARGUMENT
154 | * FRE_WRONG_THREAD
155 | */
156 |
157 | FREResult FRESetContextNativeData( FREContext ctx, void* nativeData );
158 |
159 | /**
160 | * @returns FRE_OK
161 | * FRE_WRONG_THREAD
162 | * FRE_INVALID_ARGUMENT If actionScriptData is null.
163 | */
164 |
165 | FREResult FREGetContextActionScriptData( FREContext ctx, FREObject *actionScriptData );
166 |
167 | /**
168 | * @returns FRE_OK
169 | * FRE_WRONG_THREAD
170 | */
171 |
172 | FREResult FRESetContextActionScriptData( FREContext ctx, FREObject actionScriptData );
173 |
174 | /* Primitive Types ************************************************************/
175 | /**
176 | * These values must not be changed.
177 | */
178 |
179 | typedef enum {
180 | FRE_TYPE_OBJECT = 0,
181 | FRE_TYPE_NUMBER = 1,
182 | FRE_TYPE_STRING = 2,
183 | FRE_TYPE_BYTEARRAY = 3,
184 | FRE_TYPE_ARRAY = 4,
185 | FRE_TYPE_VECTOR = 5,
186 | FRE_TYPE_BITMAPDATA = 6,
187 | FRE_TYPE_BOOLEAN = 7,
188 | FRE_TYPE_NULL = 8,
189 | FREObjectType_ENUMPADDING = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */
190 | } FREObjectType;
191 |
192 | /**
193 | * @returns FRE_OK
194 | * FRE_INVALID_OBJECT
195 | * FRE_WRONG_THREAD
196 | * FRE_INVALID_ARGUMENT If objectType is null.
197 | */
198 |
199 | FREResult FREGetObjectType( FREObject object, FREObjectType *objectType );
200 |
201 | /**
202 | * @return FRE_OK
203 | * FRE_TYPE_MISMATCH
204 | * FRE_INVALID_OBJECT
205 | * FRE_INVALID_ARGUMENT
206 | * FRE_WRONG_THREAD
207 | */
208 |
209 | FREResult FREGetObjectAsInt32 ( FREObject object, int32_t *value );
210 | FREResult FREGetObjectAsUint32( FREObject object, uint32_t *value );
211 | FREResult FREGetObjectAsDouble( FREObject object, double *value );
212 | FREResult FREGetObjectAsBool ( FREObject object, uint32_t *value );
213 |
214 | /**
215 | * @return FRE_OK
216 | * FRE_INVALID_ARGUMENT
217 | * FRE_WRONG_THREAD
218 | */
219 |
220 | FREResult FRENewObjectFromInt32 ( int32_t value, FREObject *object );
221 | FREResult FRENewObjectFromUint32( uint32_t value, FREObject *object );
222 | FREResult FRENewObjectFromDouble( double value, FREObject *object );
223 | FREResult FRENewObjectFromBool ( uint32_t value, FREObject *object );
224 |
225 | /**
226 | * Retrieves a string representation of the object referred to by
227 | * the given object. The referenced string is immutable and valid
228 | * only for duration of the call to a registered function. If the
229 | * caller wishes to keep the the string, they must keep a copy of it.
230 | *
231 | * @param object The string to be retrieved.
232 | *
233 | * @param length The size, in bytes, of the string. Includes the
234 | * null terminator.
235 | *
236 | * @param value A pointer to a possibly temporary copy of the string.
237 | *
238 | * @return FRE_OK
239 | * FRE_TYPE_MISMATCH
240 | * FRE_INVALID_OBJECT
241 | * FRE_INVALID_ARGUMENT
242 | * FRE_WRONG_THREAD
243 | */
244 |
245 | FREResult FREGetObjectAsUTF8(
246 | FREObject object,
247 | uint32_t* length,
248 | const uint8_t** value
249 | );
250 |
251 | /**
252 | * Creates a new String object that contains a copy of the specified
253 | * string.
254 | *
255 | * @param length The length, in bytes, of the original string. Must include
256 | * the null terminator.
257 | *
258 | * @param value A pointer to the original string.
259 | *
260 | * @param object Receives a reference to the new string object.
261 | *
262 | * @return FRE_OK
263 | * FRE_INVALID_ARGUMENT
264 | * FRE_WRONG_THREAD
265 | */
266 |
267 | FREResult FRENewObjectFromUTF8(
268 | uint32_t length,
269 | const uint8_t* value ,
270 | FREObject* object
271 | );
272 |
273 | /* Object Access **************************************************************/
274 |
275 | /**
276 | * @param className UTF8-encoded name of the class being constructed.
277 | *
278 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript
279 | * Error thrown during execution. May be null if the caller does not
280 | * want to receive this handle. If not null and no error occurs, is set an
281 | * invalid handle value.
282 | *
283 | * @return FRE_OK
284 | * FRE_TYPE_MISMATCH
285 | * FRE_INVALID_OBJECT
286 | * FRE_INVALID_ARGUMENT
287 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method.
288 | * In this case, thrownException will be set to the handle of the thrown value.
289 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
290 | * FRE_NO_SUCH_NAME
291 | * FRE_WRONG_THREAD
292 | */
293 |
294 | FREResult FRENewObject(
295 | const uint8_t* className ,
296 | uint32_t argc ,
297 | FREObject argv[] ,
298 | FREObject* object ,
299 | FREObject* thrownException
300 | );
301 |
302 | /**
303 | * @param propertyName UTF8-encoded name of the property being fetched.
304 | *
305 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript
306 | * Error thrown during getting the property. May be null if the caller does not
307 | * want to receive this handle. If not null and no error occurs, is set an
308 | * invalid handle value.
309 | *
310 | * @return FRE_OK
311 | * FRE_TYPE_MISMATCH
312 | * FRE_INVALID_OBJECT
313 | * FRE_INVALID_ARGUMENT
314 | *
315 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property.
316 | * In this case, thrownException will be set to the handle of the thrown value.
317 | *
318 | * FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous
319 | * because the property exists in more than one namespace.
320 | *
321 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
322 | *
323 | * FRE_WRONG_THREAD
324 | */
325 |
326 | FREResult FREGetObjectProperty(
327 | FREObject object ,
328 | const uint8_t* propertyName ,
329 | FREObject* propertyValue ,
330 | FREObject* thrownException
331 | );
332 |
333 | /**
334 | * @param propertyName UTF8-encoded name of the property being set.
335 | *
336 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript
337 | * Error thrown during method execution. May be null if the caller does not
338 | * want to receive this handle. If not null and no error occurs, is set an
339 | * invalid handle value.
340 | *
341 | *
342 | * @return FRE_OK
343 | * FRE_TYPE_MISMATCH
344 | * FRE_INVALID_OBJECT
345 | * FRE_INVALID_ARGUMENT
346 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property.
347 | * In this case, thrownException will be set to the handle of the thrown value.
348 | *
349 | * FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous
350 | * because the property exists in more than one namespace.
351 | *
352 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
353 | *
354 | * FRE_READ_ONLY
355 | * FRE_WRONG_THREAD
356 | */
357 |
358 | FREResult FRESetObjectProperty(
359 | FREObject object ,
360 | const uint8_t* propertyName ,
361 | FREObject propertyValue ,
362 | FREObject* thrownException
363 | );
364 |
365 | /**
366 | * @param methodName UTF8-encoded null-terminated name of the method being invoked.
367 | *
368 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript
369 | * Error thrown during method execution. May be null if the caller does not
370 | * want to receive this handle. If not null and no error occurs, is set an
371 | * invalid handle value.
372 | *
373 | * @return FRE_OK
374 | * FRE_TYPE_MISMATCH
375 | * FRE_INVALID_OBJECT
376 | * FRE_INVALID_ARGUMENT
377 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method.
378 | * In this case, thrownException will be set to the handle of the thrown value.
379 | *
380 | * FRE_NO_SUCH_NAME If the named method doesn't exist, or if the reference is ambiguous
381 | * because the method exists in more than one namespace.
382 | *
383 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released.
384 | *
385 | * FRE_WRONG_THREAD
386 | */
387 |
388 | FREResult FRECallObjectMethod (
389 | FREObject object ,
390 | const uint8_t* methodName ,
391 | uint32_t argc ,
392 | FREObject argv[] ,
393 | FREObject* result ,
394 | FREObject* thrownException
395 | );
396 |
397 | /* BitmapData Access **********************************************************/
398 |
399 | typedef struct {
400 | uint32_t width; /* width of the BitmapData bitmap */
401 | uint32_t height; /* height of the BitmapData bitmap */
402 | uint32_t hasAlpha; /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */
403 | uint32_t isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */
404 | uint32_t lineStride32; /* line stride in number of 32 bit values, typically the same as width */
405 | uint32_t* bits32; /* pointer to the first 32-bit pixel of the bitmap data */
406 | } FREBitmapData;
407 |
408 | typedef struct {
409 | uint32_t width; /* width of the BitmapData bitmap */
410 | uint32_t height; /* height of the BitmapData bitmap */
411 | uint32_t hasAlpha; /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */
412 | uint32_t isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */
413 | uint32_t lineStride32; /* line stride in number of 32 bit values, typically the same as width */
414 | uint32_t isInvertedY; /* if non-zero, last row of pixels starts at bits32, otherwise, first row of pixels starts at bits32. */
415 | uint32_t* bits32; /* pointer to the first 32-bit pixel of the bitmap data */
416 | } FREBitmapData2;
417 |
418 | /**
419 | * Referenced data is valid only for duration of the call
420 | * to a registered function.
421 | *
422 | * @return FRE_OK
423 | * FRE_TYPE_MISMATCH
424 | * FRE_INVALID_OBJECT
425 | * FRE_INVALID_ARGUMENT
426 | * FRE_WRONG_THREAD
427 | * FRE_ILLEGAL_STATE
428 | */
429 |
430 | FREResult FREAcquireBitmapData(
431 | FREObject object ,
432 | FREBitmapData* descriptorToSet
433 | );
434 |
435 | /**
436 | * Referenced data is valid only for duration of the call
437 | * to a registered function.
438 | *
439 | * Use of this API requires that the extension and application must be packaged for
440 | * the 3.1 namespace or later.
441 | *
442 | * @return FRE_OK
443 | * FRE_TYPE_MISMATCH
444 | * FRE_INVALID_OBJECT
445 | * FRE_INVALID_ARGUMENT
446 | * FRE_WRONG_THREAD
447 | * FRE_ILLEGAL_STATE
448 | */
449 |
450 | FREResult FREAcquireBitmapData2(
451 | FREObject object ,
452 | FREBitmapData2* descriptorToSet
453 | );
454 |
455 | /**
456 | * BitmapData must be acquired to call this. Clients must invalidate any region
457 | * they modify in order to notify AIR of the changes. Only invalidated regions
458 | * are redrawn.
459 | *
460 | * @return FRE_OK
461 | * FRE_INVALID_OBJECT
462 | * FRE_WRONG_THREAD
463 | * FRE_ILLEGAL_STATE
464 | * FRE_TYPE_MISMATCH
465 | */
466 |
467 | FREResult FREInvalidateBitmapDataRect(
468 | FREObject object,
469 | uint32_t x ,
470 | uint32_t y ,
471 | uint32_t width ,
472 | uint32_t height
473 | );
474 | /**
475 | * @return FRE_OK
476 | * FRE_WRONG_THREAD
477 | * FRE_ILLEGAL_STATE
478 | * FRE_TYPE_MISMATCH
479 | */
480 |
481 | FREResult FREReleaseBitmapData( FREObject object );
482 |
483 | /**
484 | * Referenced data is valid only for duration of the call
485 | * to a registered function.
486 | *
487 | * @return FRE_OK
488 | * FRE_TYPE_MISMATCH
489 | * FRE_INVALID_OBJECT
490 | * FRE_WRONG_THREAD
491 | */
492 |
493 | /* ByteArray Access ***********************************************************/
494 |
495 | typedef struct {
496 | uint32_t length;
497 | uint8_t* bytes;
498 | } FREByteArray;
499 |
500 | /**
501 | * Referenced data is valid only for duration of the call
502 | * to a registered function.
503 | *
504 | * @return FRE_OK
505 | * FRE_TYPE_MISMATCH
506 | * FRE_INVALID_OBJECT
507 | * FRE_INVALID_ARGUMENT
508 | * FRE_WRONG_THREAD
509 | * FRE_ILLEGAL_STATE
510 | */
511 |
512 | FREResult FREAcquireByteArray(
513 | FREObject object ,
514 | FREByteArray* byteArrayToSet
515 | );
516 |
517 | /**
518 | * @return FRE_OK
519 | * FRE_INVALID_OBJECT
520 | * FRE_ILLEGAL_STATE
521 | * FRE_WRONG_THREAD
522 | */
523 |
524 | FREResult FREReleaseByteArray( FREObject object );
525 |
526 | /* Array and Vector Access ****************************************************/
527 |
528 | /**
529 | * @return FRE_OK
530 | * FRE_INVALID_OBJECT
531 | * FRE_INVALID_ARGUMENT
532 | * FRE_ILLEGAL_STATE
533 | * FRE_TYPE_MISMATCH
534 | * FRE_WRONG_THREAD
535 | */
536 |
537 | FREResult FREGetArrayLength(
538 | FREObject arrayOrVector,
539 | uint32_t* length
540 | );
541 |
542 | /**
543 | * @return FRE_OK
544 | * FRE_INVALID_OBJECT
545 | * FRE_TYPE_MISMATCH
546 | * FRE_ILLEGAL_STATE
547 | * FRE_INVALID_ARGUMENT If length is greater than 2^32.
548 | *
549 | * FRE_READ_ONLY If the handle refers to a Vector
550 | * of fixed size.
551 | *
552 | * FRE_WRONG_THREAD
553 | * FRE_INSUFFICIENT_MEMORY
554 | */
555 |
556 | FREResult FRESetArrayLength(
557 | FREObject arrayOrVector,
558 | uint32_t length
559 | );
560 |
561 | /**
562 | * If an Array is sparse and an element that isn't defined is requested, the
563 | * return value will be FRE_OK but the handle value will be invalid.
564 | *
565 | * @return FRE_OK
566 | * FRE_ILLEGAL_STATE
567 | *
568 | * FRE_INVALID_ARGUMENT If the handle refers to a vector and the index is
569 | * greater than the size of the array.
570 | *
571 | * FRE_INVALID_OBJECT
572 | * FRE_TYPE_MISMATCH
573 | * FRE_WRONG_THREAD
574 | */
575 |
576 | FREResult FREGetArrayElementAt(
577 | FREObject arrayOrVector,
578 | uint32_t index ,
579 | FREObject* value
580 | );
581 |
582 | /**
583 | *
584 | * @return FRE_OK
585 | * FRE_INVALID_OBJECT
586 | * FRE_ILLEGAL_STATE
587 | *
588 | * FRE_TYPE_MISMATCH If an attempt to made to set a value in a Vector
589 | * when the type of the value doesn't match the Vector's item type.
590 | *
591 | * FRE_WRONG_THREAD
592 | */
593 |
594 | FREResult FRESetArrayElementAt(
595 | FREObject arrayOrVector,
596 | uint32_t index ,
597 | FREObject value
598 | );
599 |
600 | /* Callbacks ******************************************************************/
601 |
602 | /**
603 | * Causes a StatusEvent to be dispatched from the associated
604 | * ExtensionContext object.
605 | *
606 | * Dispatch happens asynchronously, even if this is called during
607 | * a call to a registered function.
608 | *
609 | * The ActionScript portion of this extension can listen for that event
610 | * and, upon receipt, query the native portion for details of the event
611 | * that occurred.
612 | *
613 | * This call is thread-safe and may be invoked from any thread. The string
614 | * values are copied before the call returns.
615 | *
616 | * @return FRE_OK In all circumstances, as the referenced object cannot
617 | * necessarily be checked for validity on the invoking thread.
618 | * However, no event will be dispatched if the object is
619 | * invalid or not an EventDispatcher.
620 | * FRE_INVALID_ARGUMENT If code or level is NULL
621 | */
622 |
623 | FREResult FREDispatchStatusEventAsync(
624 | FREContext ctx ,
625 | const uint8_t* code ,
626 | const uint8_t* level
627 | );
628 |
629 | #ifdef __cplusplus
630 | }
631 | #endif
632 |
633 | #endif /* #ifndef _FLASH_RUNTIME_EXTENSIONS_H_ */
634 |
--------------------------------------------------------------------------------