forked from github/Toast-PhoneGap-Plugin
Compare commits
2 Commits
master
...
trying-wit
Author | SHA1 | Date | |
---|---|---|---|
![]() |
95fe5ce19b | ||
![]() |
9def9e77f5 |
@ -1,4 +0,0 @@
|
||||
.idea/
|
||||
screenshots/
|
||||
test/
|
||||
issue_template.md
|
19
LICENSE
19
LICENSE
@ -1,19 +0,0 @@
|
||||
[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
197
README.md
197
README.md
@ -1,9 +1,6 @@
|
||||
# PhoneGap Toast plugin
|
||||
|
||||
for Android, iOS, WP8, Windows and BlackBerry by [Eddy Verbruggen](http://www.x-services.nl/phonegap-toast-plugin/796)
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=eddyverbruggen%40gmail%2ecom&lc=US&item_name=cordova%2dplugin%2dtoast¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)
|
||||
If you like this plugin and want to say thanks please send a PR or donation. Both are equally appreciated!
|
||||
for Android, iOS and WP8, by [Eddy Verbruggen](http://www.x-services.nl/phonegap-toast-plugin/796)
|
||||
|
||||
|
||||
<table width="100%">
|
||||
@ -18,13 +15,13 @@ If you like this plugin and want to say thanks please send a PR or donation. Bot
|
||||
1. [Description](#1-description)
|
||||
2. [Screenshots](#2-screenshots)
|
||||
3. [Installation](#3-installation)
|
||||
3. [Automatically (CLI / Plugman)](#automatically-cli--plugman)
|
||||
3. [Manually](#manually)
|
||||
3. [PhoneGap Build](#phonegap-build)
|
||||
3. [Automatically (CLI / Plugman)](#automatically-cli--plugman)
|
||||
3. [Manually](#manually)
|
||||
3. [PhoneGap Build](#phonegap-build)
|
||||
4. [Usage](#4-usage)
|
||||
4. [Styling](#styling)
|
||||
5. [Credits](#5-credits)
|
||||
6. [Changelog](#6-changelog)
|
||||
7. [License](#7-license)
|
||||
|
||||
## 1. Description
|
||||
|
||||
@ -32,15 +29,18 @@ This plugin allows you to show a native Toast (a little text popup) on iOS, Andr
|
||||
It's great for showing a non intrusive native notification which is guaranteed always in the viewport of the browser.
|
||||
* You can choose where to show the Toast: at the top, center or bottom of the screen.
|
||||
* You can choose two durations: short (approx. 2 seconds), or long (approx. 5 seconds), after which the Toast automatically disappears.
|
||||
* Compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman).
|
||||
* Officially supported by [PhoneGap Build](https://build.phonegap.com/plugins).
|
||||
* Minimum iOS version is [6](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues/7).
|
||||
|
||||
Example usages:
|
||||
* "There were validation errors"
|
||||
* "Account created successfully"
|
||||
* "The record was deleted"
|
||||
* "Login successful"
|
||||
* "The battery is almost dead"
|
||||
* "You are now logged out"
|
||||
* "Connection failure, please try again later"
|
||||
* "Created Order #00287
|
||||
|
||||
## 2. Screenshots
|
||||
|
||||
@ -48,18 +48,10 @@ iOS
|
||||
|
||||

|
||||
|
||||
A few styling options
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
Android
|
||||
|
||||

|
||||
|
||||
|
||||
Windows Phone 8
|
||||
|
||||

|
||||
@ -69,21 +61,18 @@ Windows Phone 8
|
||||
### Automatically (CLI / Plugman)
|
||||
Toast is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman), compatible with [PhoneGap 3.0 CLI](http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface_add_features), here's how it works with the CLI (backup your project first!):
|
||||
|
||||
Using the Cordova CLI and the [Cordova Plugin Registry](http://plugins.cordova.io)
|
||||
```
|
||||
$ cordova plugin add cordova-plugin-x-toast
|
||||
$ phonegap local plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
|
||||
```
|
||||
or
|
||||
```
|
||||
$ cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
|
||||
$ cordova prepare
|
||||
```
|
||||
|
||||
Or using the phonegap CLI
|
||||
```
|
||||
$ phonegap local plugin add cordova-plugin-x-toast
|
||||
```
|
||||
|
||||
Toast.js is brought in automatically. There is no need to change or add anything in your html.
|
||||
|
||||
### Manually
|
||||
You'd better use the CLI, but here goes:
|
||||
|
||||
1\. Add the following xml to your `config.xml` in the root directory of your `www` folder:
|
||||
```xml
|
||||
@ -127,18 +116,20 @@ Toast works with PhoneGap build too, but only with PhoneGap 3.0 and up.
|
||||
|
||||
Just add the following xml to your `config.xml` to always use the latest version of this plugin:
|
||||
```xml
|
||||
<gap:plugin name="cordova-plugin-x-toast" source="npm" />
|
||||
<gap:plugin name="nl.x-services.plugins.toast" />
|
||||
```
|
||||
or to use this exact version:
|
||||
```xml
|
||||
<gap:plugin name="nl.x-services.plugins.toast" version="1.0" />
|
||||
```
|
||||
|
||||
Toast.js is brought in automatically. There is no need to change or add anything in your html.
|
||||
|
||||
## 4. Usage
|
||||
|
||||
### Showing a Toast
|
||||
You have two choices to make when showing a Toast: where to show it and for how long.
|
||||
* show(message, duration, position)
|
||||
* duration: 'short', 'long', '3000', 900 (the latter are milliseconds)
|
||||
* position: 'top', 'center', 'bottom'
|
||||
* duration: 'short', 'long'
|
||||
* position: 'top', 'center', 'bottom'
|
||||
|
||||
You can also use any of these convenience methods:
|
||||
* showShortTop(message)
|
||||
@ -155,111 +146,7 @@ You can copy-paste these lines of code for a quick test:
|
||||
<button onclick="window.plugins.toast.show('Hello there!', 'long', 'center', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">Toast show long center</button>
|
||||
```
|
||||
|
||||
#### Tweaking the vertical position
|
||||
Since 2.1.0 you can add pixels to move the toast up or down.
|
||||
Note that `showWithOptions` can be used instead of the functions above, but it's not useful unless you want to pass `addPixelsY`.
|
||||
```js
|
||||
function showBottom() {
|
||||
window.plugins.toast.showWithOptions(
|
||||
{
|
||||
message: "hey there",
|
||||
duration: "short", // which is 2000 ms. "long" is 4000. Or specify the nr of ms yourself.
|
||||
position: "bottom",
|
||||
addPixelsY: -40 // added a negative value to move it up a bit (default 0)
|
||||
},
|
||||
onSuccess, // optional
|
||||
onError // optional
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Hiding a Toast
|
||||
In case you want to hide a Toast manually, call this:
|
||||
```js
|
||||
function hide() {
|
||||
// this function takes an optional success callback, but you can do without just as well
|
||||
window.plugins.toast.hide();
|
||||
}
|
||||
```
|
||||
|
||||
When the toast gets hidden, your success callback will be called (in case you have defined one) with the `event` property equals to `hide` (more details about the callback in the next section).
|
||||
```js
|
||||
|
||||
window.plugins.toast.showWithOptions({
|
||||
message: 'My message',
|
||||
// More config here...
|
||||
},
|
||||
//Success callback
|
||||
function(args) {
|
||||
console.log(args.event);
|
||||
//This will print 'hide'
|
||||
},
|
||||
function(error) {
|
||||
console.error('toast error: ', error);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Receiving a callback when a Toast is tapped
|
||||
On iOS and Android the success handler of your `show` function will be notified (again) when the toast was tapped.
|
||||
|
||||
So the first time the success handler fires is when the toast is shown, and in case the user taps the toast it will be
|
||||
called again. You can distinguish between those events of course:
|
||||
|
||||
```js
|
||||
window.plugins.toast.showWithOptions(
|
||||
{
|
||||
message: "hey there",
|
||||
duration: 1500, // ms
|
||||
position: "bottom",
|
||||
addPixelsY: -40, // (optional) added a negative value to move it up a bit (default 0)
|
||||
data: {'foo':'bar'} // (optional) pass in a JSON object here (it will be sent back in the success callback below)
|
||||
},
|
||||
// implement the success callback
|
||||
function(result) {
|
||||
if (result && result.event) {
|
||||
console.log("The toast was tapped or got hidden, see the value of result.event");
|
||||
console.log("Event: " + result.event); // "touch" when the toast was touched by the user or "hide" when the toast geot hidden
|
||||
console.log("Message: " + result.message); // will be equal to the message you passed in
|
||||
console.log("data.foo: " + result.data.foo); // .. retrieve passed in data here
|
||||
|
||||
if (result.event === 'hide') {
|
||||
console.log("The toast has been shown");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
The success callback is useful when your toast is bound to a notification id in your backend and you have to mark it as `read` when the toast is done, or to update the notifications counter for iOS. The usage of this will be defined by your application logic. Use the `result.data` object to support your specific logic.
|
||||
|
||||
### Styling
|
||||
Since version 2.4.0 you can pass an optional `styling` object to the plugin.
|
||||
The defaults make sure the Toast looks the same as when you would not pass in the `styling` object at all.
|
||||
|
||||
Note that on WP this object is currently ignored.
|
||||
|
||||
```js
|
||||
window.plugins.toast.showWithOptions({
|
||||
message: "hey there",
|
||||
duration: "short", // 2000 ms
|
||||
position: "bottom",
|
||||
styling: {
|
||||
opacity: 0.75, // 0.0 (transparent) to 1.0 (opaque). Default 0.8
|
||||
backgroundColor: '#FF0000', // make sure you use #RRGGBB. Default #333333
|
||||
textColor: '#FFFF00', // Ditto. Default #FFFFFF
|
||||
textSize: 20.5, // Default is approx. 13.
|
||||
cornerRadius: 16, // minimum is 0 (square). iOS default 20, Android default 100
|
||||
horizontalPadding: 20, // iOS default 16, Android default 50
|
||||
verticalPadding: 16 // iOS default 12, Android default 30
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Tip: if you need to pass different values for iOS and Android you can use fi. the device plugin
|
||||
to determine the platform and pass `opacity: isAndroid() ? 0.7 : 0.9`.
|
||||
|
||||
### WP8 quirks
|
||||
### WP8 quircks
|
||||
The WP8 implementation needs a little more work, but it's perfectly useable when you keep this in mind:
|
||||
* You can't show two Toasts simultaneously.
|
||||
* Wait until the first Toast is hidden before the second is shown, otherwise the second one will be hidden quickly.
|
||||
@ -273,18 +160,28 @@ The Android code was entirely created by me.
|
||||
For iOS most credits go to this excellent [Toast for iOS project by Charles Scalesse] (https://github.com/scalessec/Toast).
|
||||
|
||||
## 6. CHANGELOG
|
||||
- 2.7.2: Even better Android compatibility, but you're limited to short and long durations now, on Android.
|
||||
- 2.7.0: [Android P compatibility.](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues/116)
|
||||
- 2.6.2: [iOS view hierarchy fix.](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/pull/112)
|
||||
- 2.6.0: Windows support!
|
||||
- 2.5.2: Multi-line wrapping Toasts are now center aligned.
|
||||
- 2.5.1: You can now specify the `textSize` used in the font for iOS and Android.
|
||||
- 2.5.0: By popular demand: Specify the duration of the Toast on iOS and Android. Pass in `short` (2000ms), `long` (4000ms), or any nr of milliseconds: `900`.
|
||||
- 2.4.2: You can now also set the Toast `opacity` for iOS.
|
||||
- 2.4.1: As an addition to 2.4.0, [Sino](https://github.com/SinoBoeckmann) added the option to change the text color!
|
||||
- 2.4.0: You can now style the Toast with a number of properties. See
|
||||
- 2.3.2: The click event introduced with 2.3.0 did not work with Android 5+.
|
||||
- 2.3.0: The plugin will now report back to JS if Toasts were tapped by the user.
|
||||
- 2.0.1: iOS messages are hidden when another one is shown. [Thanks Richie Min!](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/pull/13)
|
||||
- 2.0: WP8 support
|
||||
- 1.0: initial version supporting Android and iOS
|
||||
2.0: WP8 support
|
||||
|
||||
1.0: initial version supporting Android and iOS
|
||||
|
||||
## 7. License
|
||||
|
||||
[The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
@ -1,42 +0,0 @@
|
||||
### Expected behaviour
|
||||
Tell us what should happen.
|
||||
|
||||
### Actual behaviour
|
||||
Tell us what happens instead. Provide a log message if relevant.
|
||||
|
||||
### I'm seeing this behaviour on
|
||||
_Remove this hint: these checkboxes can be checked like this: [x]_
|
||||
|
||||
- [ ] iOS device
|
||||
- [ ] iOS sim
|
||||
- [ ] Android device
|
||||
- [ ] Android sim
|
||||
|
||||
#### Hardware models
|
||||
Example: Samsung Galaxy S6, iPhone 6s
|
||||
|
||||
#### OS versions
|
||||
Example: Android 4.4.2, iOS 9.2
|
||||
|
||||
### I'm not a dummy, so I've checked these
|
||||
- [ ] It happens on a fresh Cordova CLI project as well.
|
||||
- [ ] I'm waiting for `deviceready` to fire.
|
||||
- [ ] My JavaScript has no errors (`window.onerror` catches nothing).
|
||||
|
||||
### So how can we reproduce this?
|
||||
_Remove this hint: Pick one of these - use the Preview feature of this editor to get a sense which option we like best_
|
||||
|
||||
#### Awesome :star::star::star::star::star:
|
||||
Provide a (link to a) minimal demo app showing the faulty behaviour.
|
||||
|
||||
#### Sweet :star::star::star::star:
|
||||
Provide a concise code sample which can be dropped into a freshly created Cordova CLI app.
|
||||
|
||||
#### Good :star::star::star:
|
||||
Provide your own app and instructions how to reproduce the issue.
|
||||
|
||||
#### Meh :star::star:
|
||||
Provide a code sample with a bunch of magic parameters which I need to interpolate by guessing to reconstruct the actual runtime code.
|
||||
|
||||
#### Worst :poop:
|
||||
Say the source code can't be disclosed and refuse to provide any of the above. Expect this issue to be closed by a bunch of angry aliens :alien::alien::alien::alien::alien: that will hunt you down and :fire: your :computer:. You've been warned. :fire_engine:
|
43
package.json
43
package.json
@ -1,43 +0,0 @@
|
||||
{
|
||||
"name": "cordova-plugin-x-toast",
|
||||
"version": "2.7.3",
|
||||
"description": "This plugin allows you to show a Toast. A Toast is a little non intrusive buttonless popup which automatically disappears.",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-x-toast",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android",
|
||||
"wp8",
|
||||
"windows",
|
||||
"blackberry10"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Toast",
|
||||
"Notification",
|
||||
"Message",
|
||||
"Alert",
|
||||
"ecosystem:cordova",
|
||||
"cordova-ios",
|
||||
"cordova-android",
|
||||
"cordova-wp8",
|
||||
"cordova-windows",
|
||||
"cordova-blackberry10"
|
||||
],
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova",
|
||||
"version": ">=3.0.0"
|
||||
}
|
||||
],
|
||||
"author": "Eddy Verbruggen <eddyverbruggen@gmail.com> (https://github.com/EddyVerbruggen)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin#readme"
|
||||
}
|
35
plugin.xml
35
plugin.xml
@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-x-toast"
|
||||
version="2.7.3">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="nl.x-services.plugins.toast"
|
||||
version="2.0">
|
||||
|
||||
<name>Toast</name>
|
||||
|
||||
@ -10,16 +11,8 @@
|
||||
A Toast is a little non intrusive buttonless popup which automatically disappears.
|
||||
</description>
|
||||
|
||||
<author>Eddy Verbruggen</author>
|
||||
|
||||
<license>MIT</license>
|
||||
|
||||
<keywords>Toast, Notification, Message, Alert</keywords>
|
||||
|
||||
<repo>https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git</repo>
|
||||
|
||||
<issue>https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues</issue>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0"/>
|
||||
</engines>
|
||||
@ -28,6 +21,9 @@
|
||||
<clobbers target="window.plugins.toast" />
|
||||
</js-module>
|
||||
|
||||
<js-module src="test/tests.js" name="tests">
|
||||
</js-module>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
|
||||
@ -68,23 +64,4 @@
|
||||
<source-file src="src/wp8/Toast.cs" />
|
||||
</platform>
|
||||
|
||||
<platform name="blackberry10">
|
||||
<source-file src="src/blackberry10/index.js" target-dir="Toast"/>
|
||||
<lib-file src="src/blackberry10/native/device/libToast.so" arch="device"/>
|
||||
<lib-file src="src/blackberry10/native/simulator/libToast.so" arch="simulator"/>
|
||||
<config-file target="www/config.xml" parent="/widget">
|
||||
<feature name="Toast" value="Toast" />
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/toastProxy.js" name="ToastProxy">
|
||||
<merges target="" />
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Toast" value="Toast" />
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
</plugin>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
@ -1,224 +1,49 @@
|
||||
package nl.xservices.plugins;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.AlignmentSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Toast extends CordovaPlugin {
|
||||
|
||||
private static final String ACTION_SHOW_EVENT = "show";
|
||||
private static final String ACTION_HIDE_EVENT = "hide";
|
||||
|
||||
private static final int GRAVITY_TOP = Gravity.TOP|Gravity.CENTER_HORIZONTAL;
|
||||
private static final int GRAVITY_CENTER = Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL;
|
||||
private static final int GRAVITY_BOTTOM = Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL;
|
||||
|
||||
private static final int BASE_TOP_BOTTOM_OFFSET = 20;
|
||||
|
||||
private android.widget.Toast mostRecentToast;
|
||||
private ViewGroup viewGroup;
|
||||
|
||||
private static final boolean IS_AT_LEAST_JELLY_BEAN = Build.VERSION.SDK_INT >= 16;
|
||||
private static final boolean IS_AT_LEAST_LOLLIPOP = Build.VERSION.SDK_INT >= 21;
|
||||
private static final boolean IS_AT_LEAST_PIE = Build.VERSION.SDK_INT >= 28;
|
||||
private static final boolean IS_AT_LEAST_R = Build.VERSION.SDK_INT >= 30;
|
||||
|
||||
// note that webView.isPaused() is not Xwalk compatible, so tracking it poor-man style
|
||||
private boolean isPaused;
|
||||
|
||||
private String currentMessage;
|
||||
private JSONObject currentData;
|
||||
private static CountDownTimer _timer;
|
||||
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
||||
if (ACTION_HIDE_EVENT.equals(action)) {
|
||||
returnTapEvent("hide", currentMessage, currentData, callbackContext);
|
||||
hide();
|
||||
callbackContext.success();
|
||||
return true;
|
||||
if (ACTION_SHOW_EVENT.equals(action)) {
|
||||
|
||||
} else if (ACTION_SHOW_EVENT.equals(action)) {
|
||||
if (this.isPaused) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final JSONObject options = args.getJSONObject(0);
|
||||
final String msg = options.getString("message");
|
||||
final Spannable message = new SpannableString(msg);
|
||||
message.setSpan(
|
||||
new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER),
|
||||
0,
|
||||
msg.length() - 1,
|
||||
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
||||
final String duration = options.getString("duration");
|
||||
final String position = options.getString("position");
|
||||
final int addPixelsY = options.has("addPixelsY") ? options.getInt("addPixelsY") : 0;
|
||||
final JSONObject data = options.has("data") ? options.getJSONObject("data") : null;
|
||||
final JSONObject styling = options.optJSONObject("styling");
|
||||
|
||||
currentMessage = msg;
|
||||
currentData = data;
|
||||
final String message = args.getString(0);
|
||||
final String duration = args.getString(1);
|
||||
final String position = args.getString(2);
|
||||
|
||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
int hideAfterMs;
|
||||
if ("short".equalsIgnoreCase(duration)) {
|
||||
hideAfterMs = 2000;
|
||||
} else if ("long".equalsIgnoreCase(duration)) {
|
||||
hideAfterMs = 4000;
|
||||
} else {
|
||||
// assuming a number of ms
|
||||
hideAfterMs = Integer.parseInt(duration);
|
||||
}
|
||||
final android.widget.Toast toast = android.widget.Toast.makeText(
|
||||
IS_AT_LEAST_LOLLIPOP ? cordova.getActivity().getWindow().getContext() : cordova.getActivity().getApplicationContext(),
|
||||
message,
|
||||
"short".equalsIgnoreCase(duration) ? android.widget.Toast.LENGTH_SHORT : android.widget.Toast.LENGTH_LONG
|
||||
);
|
||||
android.widget.Toast toast = android.widget.Toast.makeText(webView.getContext(), message, 0);
|
||||
|
||||
if ("top".equals(position)) {
|
||||
toast.setGravity(GRAVITY_TOP, 0, BASE_TOP_BOTTOM_OFFSET + addPixelsY);
|
||||
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 20);
|
||||
} else if ("bottom".equals(position)) {
|
||||
toast.setGravity(GRAVITY_BOTTOM, 0, BASE_TOP_BOTTOM_OFFSET - addPixelsY);
|
||||
toast.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 20);
|
||||
} else if ("center".equals(position)) {
|
||||
toast.setGravity(GRAVITY_CENTER, 0, addPixelsY);
|
||||
toast.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL, 0, 0);
|
||||
} else {
|
||||
callbackContext.error("invalid position. valid options are 'top', 'center' and 'bottom'");
|
||||
return;
|
||||
}
|
||||
|
||||
// if one of the custom layout options have been passed in, draw our own shape
|
||||
// (but disabled on Android >= 11 since custom toast views are deprecated)
|
||||
if (styling != null && IS_AT_LEAST_JELLY_BEAN && !IS_AT_LEAST_R) {
|
||||
|
||||
// the defaults mimic the default toast as close as possible
|
||||
final String backgroundColor = styling.optString("backgroundColor", "#333333");
|
||||
final String textColor = styling.optString("textColor", "#ffffff");
|
||||
final Double textSize = styling.optDouble("textSize", -1);
|
||||
final double opacity = styling.optDouble("opacity", 0.8);
|
||||
final int cornerRadius = styling.optInt("cornerRadius", 100);
|
||||
final int horizontalPadding = styling.optInt("horizontalPadding", 50);
|
||||
final int verticalPadding = styling.optInt("verticalPadding", 30);
|
||||
|
||||
GradientDrawable shape = new GradientDrawable();
|
||||
shape.setCornerRadius(cornerRadius);
|
||||
shape.setAlpha((int)(opacity * 255)); // 0-255, where 0 is an invisible background
|
||||
shape.setColor(Color.parseColor(backgroundColor));
|
||||
toast.getView().setBackground(shape);
|
||||
|
||||
final TextView toastTextView;
|
||||
toastTextView = (TextView) toast.getView().findViewById(android.R.id.message);
|
||||
toastTextView.setTextColor(Color.parseColor(textColor));
|
||||
if (textSize > -1) {
|
||||
toastTextView.setTextSize(textSize.floatValue());
|
||||
}
|
||||
|
||||
toast.getView().setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
|
||||
|
||||
// this gives the toast a very subtle shadow on newer devices
|
||||
if (IS_AT_LEAST_LOLLIPOP) {
|
||||
toast.getView().setElevation(6);
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_AT_LEAST_R) {
|
||||
// On Android >= 11 the 'toast.getView()' will always return null
|
||||
// so no touchListener can be used or mocked
|
||||
// DO NOTHING
|
||||
} else if (IS_AT_LEAST_LOLLIPOP) {
|
||||
// On Android >= 5 you can no longer rely on the 'toast.getView().setOnTouchListener',
|
||||
// so created something funky that compares the Toast position to the tap coordinates.
|
||||
getViewGroup().setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() != MotionEvent.ACTION_DOWN) {
|
||||
return false;
|
||||
}
|
||||
if (mostRecentToast == null || !mostRecentToast.getView().isShown()) {
|
||||
getViewGroup().setOnTouchListener(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
float w = mostRecentToast.getView().getWidth();
|
||||
float startX = (view.getWidth() / 2) - (w / 2);
|
||||
float endX = (view.getWidth() / 2) + (w / 2);
|
||||
|
||||
float startY;
|
||||
float endY;
|
||||
|
||||
float g = mostRecentToast.getGravity();
|
||||
float y = mostRecentToast.getYOffset();
|
||||
float h = mostRecentToast.getView().getHeight();
|
||||
|
||||
if (g == GRAVITY_BOTTOM) {
|
||||
startY = view.getHeight() - y - h;
|
||||
endY = view.getHeight() - y;
|
||||
} else if (g == GRAVITY_CENTER) {
|
||||
startY = (view.getHeight() / 2) + y - (h / 2);
|
||||
endY = (view.getHeight() / 2) + y + (h / 2);
|
||||
} else {
|
||||
// top
|
||||
startY = y;
|
||||
endY = y + h;
|
||||
}
|
||||
|
||||
float tapX = motionEvent.getX();
|
||||
float tapY = motionEvent.getY();
|
||||
|
||||
final boolean tapped = tapX >= startX && tapX <= endX &&
|
||||
tapY >= startY && tapY <= endY;
|
||||
|
||||
return tapped && returnTapEvent("touch", msg, data, callbackContext);
|
||||
}
|
||||
});
|
||||
if ("short".equals(duration)) {
|
||||
toast.setDuration(android.widget.Toast.LENGTH_SHORT);
|
||||
} else if ("long".equals(duration)) {
|
||||
toast.setDuration(android.widget.Toast.LENGTH_LONG);
|
||||
} else {
|
||||
toast.getView().setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return motionEvent.getAction() == MotionEvent.ACTION_DOWN && returnTapEvent("touch", msg, data, callbackContext);
|
||||
}
|
||||
});
|
||||
callbackContext.error("invalid duration. valid options are 'short' and 'long'");
|
||||
return;
|
||||
}
|
||||
// trigger show every 2500 ms for as long as the requested duration
|
||||
_timer = new CountDownTimer(hideAfterMs, 2500) {
|
||||
public void onTick(long millisUntilFinished) {
|
||||
// see https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues/116
|
||||
// and https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues/120
|
||||
// if (!IS_AT_LEAST_PIE) {
|
||||
// toast.show();
|
||||
// }
|
||||
}
|
||||
public void onFinish() {
|
||||
returnTapEvent("hide", msg, data, callbackContext);
|
||||
toast.cancel();
|
||||
}
|
||||
}.start();
|
||||
|
||||
mostRecentToast = toast;
|
||||
toast.show();
|
||||
|
||||
PluginResult pr = new PluginResult(PluginResult.Status.OK);
|
||||
pr.setKeepCallback(true);
|
||||
callbackContext.sendPluginResult(pr);
|
||||
callbackContext.success();
|
||||
}
|
||||
});
|
||||
|
||||
@ -228,47 +53,4 @@ public class Toast extends CordovaPlugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void hide() {
|
||||
if (mostRecentToast != null) {
|
||||
mostRecentToast.cancel();
|
||||
getViewGroup().setOnTouchListener(null);
|
||||
}
|
||||
if (_timer != null) {
|
||||
_timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean returnTapEvent(String eventName, String message, JSONObject data, CallbackContext callbackContext) {
|
||||
final JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("event", eventName);
|
||||
json.put("message", message);
|
||||
json.put("data", data);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
callbackContext.success(json);
|
||||
return true;
|
||||
}
|
||||
|
||||
// lazy init and caching
|
||||
private ViewGroup getViewGroup() {
|
||||
if (viewGroup == null) {
|
||||
viewGroup = (ViewGroup) ((ViewGroup) cordova.getActivity().findViewById(android.R.id.content)).getChildAt(0);
|
||||
}
|
||||
return viewGroup;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onPause(boolean multitasking) {
|
||||
// hide();
|
||||
// this.isPaused = true;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void onResume(boolean multitasking) {
|
||||
// this.isPaused = false;
|
||||
// }
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
var toast,
|
||||
resultObjs = {},
|
||||
threadCallback = null,
|
||||
_utils = require("../../lib/utils");
|
||||
|
||||
module.exports = {
|
||||
|
||||
show: function (success, fail, args, env) {
|
||||
var result = new PluginResult(args, env);
|
||||
resultObjs[result.callbackId] = result;
|
||||
|
||||
var message = JSON.parse(decodeURIComponent(args[0])),
|
||||
duration = JSON.parse(decodeURIComponent(args[1])),
|
||||
position = JSON.parse(decodeURIComponent(args[2]));
|
||||
|
||||
toast.getInstance().show(result.callbackId, {message:message, duration:duration, position:position});
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// JavaScript wrapper for JNEXT plugin for connection
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
JNEXT.Toast = function () {
|
||||
var self = this,
|
||||
hasInstance = false;
|
||||
|
||||
self.getId = function () {
|
||||
return self.m_id;
|
||||
};
|
||||
|
||||
self.init = function () {
|
||||
if (!JNEXT.require("libToast")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.m_id = JNEXT.createObject("libToast.Toast_JS");
|
||||
|
||||
if (self.m_id === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
JNEXT.registerEvents(self);
|
||||
};
|
||||
|
||||
// calls into InvokeMethod(string command) in Toast_JS.cpp
|
||||
self.show = function (callbackId, input) {
|
||||
return JNEXT.invoke(self.m_id, "show " + callbackId + " " + JSON.stringify(input));
|
||||
};
|
||||
|
||||
// Fired by the Event framework (used by asynchronous callbacks)
|
||||
self.onEvent = function (strData) {
|
||||
var arData = strData.split(" "),
|
||||
callbackId = arData[0],
|
||||
result = resultObjs[callbackId],
|
||||
data = arData.slice(1, arData.length).join(" ");
|
||||
|
||||
if (result) {
|
||||
if (callbackId != threadCallback) {
|
||||
result.callbackOk(data, false);
|
||||
delete resultObjs[callbackId];
|
||||
} else {
|
||||
result.callbackOk(data, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ************************
|
||||
// End of methods to edit
|
||||
// ************************
|
||||
self.m_id = "";
|
||||
|
||||
self.getInstance = function () {
|
||||
if (!hasInstance) {
|
||||
hasInstance = true;
|
||||
self.init();
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
toast = new JNEXT.Toast();
|
@ -1,717 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.debug.1877214659">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.debug.1877214659" moduleId="org.eclipse.cdt.core.settings" name="Device-Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Device-Debug"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="" errorParsers="com.qnx.tools.ide.qde.core.QDELinkerErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="com.qnx.qcc.configuration.sharedLib.debug.1877214659" name="Device-Debug" parent="com.qnx.qcc.configuration.sharedLib.debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.debug.1877214659." name="/" resourcePath="">
|
||||
<toolChain errorParsers="" id="com.qnx.qcc.toolChain.sharedLib.debug.191768618" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<option id="com.qnx.qcc.option.cpu.1578303771" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.436831450" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Device-Debug}" errorParsers="" id="com.qnx.nto.606064165" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.qnx.qcc.tool.compiler.1879271926" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.1417199508" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.970212540" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.1460927572" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.2099952700" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtGlobal"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.1666296795" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.1549451068" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.710679926" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="" id="com.qnx.qcc.tool.assembler.646317396" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.1334708386" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.911447541" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="com.qnx.tools.ide.qde.core.QDELinkerErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="com.qnx.qcc.tool.linker.1892404701" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.2066515291" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.935213389" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.2116373961" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1764180006" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.227797113" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="Qt"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.1025464239" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.847297905" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.release.608922875">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.release.608922875" moduleId="org.eclipse.cdt.core.settings" name="Device-Release">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Device-Release"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="" id="com.qnx.qcc.configuration.sharedLib.release.608922875" name="Device-Release" parent="com.qnx.qcc.configuration.sharedLib.release">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.release.608922875." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.release.1688650878" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<option id="com.qnx.qcc.option.cpu.644399334" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.2097864805" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Device-Release}" id="com.qnx.nto.204940733" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.935907476" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.78720761" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.723931478" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.471392157" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.1319958023" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.1396886030" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.qccoptions.330490837" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-frecord-gcc-switches"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.1724498438" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.748752433" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.1895340354" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.1627058060" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.shared.1848469132" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.496307503" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.230783029" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.1387713775" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.1228510357" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.2037393321" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.profile.27502649">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.profile.27502649" moduleId="org.eclipse.cdt.core.settings" name="Device-Profile">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Device-Profile"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=com.qnx.buildType.profile,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="Build for Profiling" id="com.qnx.qcc.configuration.sharedLib.profile.27502649" name="Device-Profile" parent="com.qnx.qcc.configuration.sharedLib.profile">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.profile.27502649." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.profile.942439565" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<option id="com.qnx.qcc.option.cpu.2055455815" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1460803543" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Device-Profile}" id="com.qnx.nto.1317522383" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.445493654" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.1834537273" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.512579134" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.1314888503" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.profile2.1332239682" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.1232257233" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.304610370" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.961519137" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.139374714" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.84035750" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.964262814" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.136780888" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.1881786617" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1401962234" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.profile2.1899497130" name="Build for Profiling (Function Instrumentation) (-lprofiling)" superClass="com.qnx.qcc.option.linker.profile2" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1169741529" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1458539142" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1708860491" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.2086313169" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.802392274" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.2080729816" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.coverage.1806890017">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.coverage.1806890017" moduleId="org.eclipse.cdt.core.settings" name="Device-Coverage">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Device-Coverage"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=com.qnx.buildType.coverage,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="Build with Code Coverage" id="com.qnx.qcc.configuration.sharedLib.coverage.1806890017" name="Device-Coverage" parent="com.qnx.qcc.configuration.sharedLib.coverage">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.coverage.1806890017." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.coverage.1658857194" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<option id="com.qnx.qcc.option.cpu.1201722330" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.403898679" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Device-Coverage}" id="com.qnx.nto.1526448130" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.896107073" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.2016926234" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.571725797" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.2099523193" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.coverage.443259067" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.78227312" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.1756697867" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.879955122" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.129340647" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.1895486171" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.1003882988" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.1882679870" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.1952361067" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1165823345" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.coverage.1180137289" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1237324749" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1646505677" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.565853353" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.152967788" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.224554770" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.779497179" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.debug.193597202">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.debug.193597202" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Simulator-Debug"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="" id="com.qnx.qcc.configuration.sharedLib.debug.193597202" name="Simulator-Debug" parent="com.qnx.qcc.configuration.sharedLib.debug">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.debug.193597202." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.debug.716711966" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.929990965" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Simulator-Debug}" id="com.qnx.nto.9741914" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.138396159" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.1392174570" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.1178007212" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.2041326279" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.1182551175" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.442714629" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.154146404" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.2134230609" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.661085696" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.192626669" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.1605593885" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.1517116070" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1252286694" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1933218302" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.519768360" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1272333045" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.1509711055" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.819355949" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.735761526" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.profile.941124085">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.profile.941124085" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Profile">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Simulator-Profile"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=com.qnx.buildType.profile,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="Build for Profiling" id="com.qnx.qcc.configuration.sharedLib.profile.941124085" name="Simulator-Profile" parent="com.qnx.qcc.configuration.sharedLib.profile">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.profile.941124085." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.profile.2039571511" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.2056186062" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Simulator-Profile}" id="com.qnx.nto.720646111" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.695327139" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.1333895577" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.1510595019" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.2062656374" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.profile2.310135966" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.1331825250" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.106473584" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.1623246779" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.445126053" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.2058477552" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.1334096638" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.1607661608" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.274526163" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1372838850" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.profile2.1428522213" name="Build for Profiling (Function Instrumentation) (-lprofiling)" superClass="com.qnx.qcc.option.linker.profile2" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1357475130" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1309733103" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1422840260" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.203659667" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.318181422" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.1706787374" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.coverage.537092296">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.coverage.537092296" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Coverage">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Toast/public"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Toast/Simulator-Coverage"/>
|
||||
<entry flags="NONE" kind="libraryFile" name="Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=com.qnx.buildType.coverage,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="Build with Code Coverage" id="com.qnx.qcc.configuration.sharedLib.coverage.537092296" name="Simulator-Coverage" parent="com.qnx.qcc.configuration.sharedLib.coverage">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.coverage.537092296." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.sharedLib.coverage.1409700437" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.123435356" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Simulator-Coverage}" id="com.qnx.nto.540805157" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.595727552" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.1993375109" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.1636380900" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.249331101" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.coverage.641010958" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.344574432" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.1921643665" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.453136796" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.622691546" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.1247332096" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.114306263" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.138220427" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.532570526" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1125589493" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.coverage.158579585" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1695519749" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.494101205" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.295270180" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.433937596" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.1536810093" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.493567756" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.release.608922875.1009704567">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.release.608922875.1009704567" moduleId="org.eclipse.cdt.core.settings" name="device">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Cordova-Toast"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Cordova-Toast/device"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="Cordova-Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="" id="com.qnx.qcc.configuration.sharedLib.release.608922875.1009704567" name="device" parent="com.qnx.qcc.configuration.sharedLib.release">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.release.608922875.1009704567." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.2215983" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<option id="com.qnx.qcc.option.cpu.315540759" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1359109141" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Device-Release}" id="com.qnx.nto.938326560" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.242697771" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.553244928" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.2070537906" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.1483355415" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/Qt"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.9625963" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.872099896" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.qccoptions.1015003128" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-frecord-gcc-switches"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.1443568066" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.1996828008" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.116798417" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.871546588" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.shared.915102752" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.1049529253" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${QNX_TARGET}/${CPUVARDIR}/usr/lib""/>
|
||||
<listOptionValue builtIn="false" value=""${QNX_TARGET}/${CPUVARDIR}/usr/lib/qt4/lib""/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.1157664997" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.1316432206" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.1028572887" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.1781914947" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.qnx.qcc.configuration.sharedLib.debug.193597202.362186091">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.configuration.sharedLib.debug.193597202.362186091" moduleId="org.eclipse.cdt.core.settings" name="simulator">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Cordova-Toast"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Cordova-Toast/simulator"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="Cordova-Toast" srcPrefixMapping="" srcRootPath=""/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.qnx.tools.ide.qde.core.QDEBynaryParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" description="" id="com.qnx.qcc.configuration.sharedLib.debug.193597202.362186091" name="simulator" parent="com.qnx.qcc.configuration.sharedLib.debug">
|
||||
<folderInfo id="com.qnx.qcc.configuration.sharedLib.debug.193597202.362186091." name="/" resourcePath="">
|
||||
<toolChain id="com.qnx.qcc.toolChain.688026907" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
|
||||
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.469207190" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/Toast/Simulator-Debug}" id="com.qnx.nto.2029800497" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
|
||||
<tool id="com.qnx.qcc.tool.compiler.1028279123" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
|
||||
<option id="com.qnx.qcc.option.compiler.shared.235893159" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.optlevel.1164238904" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.0" valueType="enumerated"/>
|
||||
<option id="com.qnx.qcc.option.compile.debug.3716470" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.includePath.306305432" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/QtCore"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/qt4/Qt"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/bb/system"/>
|
||||
<listOptionValue builtIn="false" value="${workspace_loc:/${ProjName}/public}"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.compiler.security.1730007887" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.compiler.defines.1526896965" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.compiler.1881183122" superClass="com.qnx.qcc.inputType.compiler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.assembler.312168125" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
|
||||
<option id="com.qnx.qcc.option.assembler.debug.416544277" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
|
||||
<inputType id="com.qnx.qcc.inputType.assembler.1722778407" superClass="com.qnx.qcc.inputType.assembler"/>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.linker.2130364088" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
|
||||
<option id="com.qnx.qcc.option.linker.debug.1332880614" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.shared.1633267255" name="Shared (-shared)" superClass="com.qnx.qcc.option.linker.shared" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraryPaths.565794953" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${QNX_TARGET}/${CPUVARDIR}/usr/lib""/>
|
||||
<listOptionValue builtIn="false" value=""${QNX_TARGET}/${CPUVARDIR}/usr/lib/qt4/lib""/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/lib"/>
|
||||
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/${CPUVARDIR}/usr/lib"/>
|
||||
</option>
|
||||
<option id="com.qnx.qcc.option.linker.security.9141791" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
|
||||
<option id="com.qnx.qcc.option.linker.libraries.220836649" name="Libraries (-l)" superClass="com.qnx.qcc.option.linker.libraries" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="slog2"/>
|
||||
<listOptionValue builtIn="false" value="bbsystem"/>
|
||||
<listOptionValue builtIn="false" value="QtCore"/>
|
||||
</option>
|
||||
<inputType id="com.qnx.qcc.inputType.linker.167117375" superClass="com.qnx.qcc.inputType.linker">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.qnx.qcc.tool.archiver.489682882" name="QCC Archiver" superClass="com.qnx.qcc.tool.archiver"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="public"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="???PROJECT_NAME???.null.138005006" name="???PROJECT_NAME???"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="1">
|
||||
<resource resourceType="PROJECT" workspacePath="/Toast"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.debug.1877214659">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.debug.193597202">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.coverage.1806890017">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.release.608922875">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.coverage.537092296">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.profile.941124085">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.release.608922875.1009704567">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.qnx.qcc.configuration.sharedLib.profile.27502649">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
</cproject>
|
@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Toast</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/Toast/Device-Release}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.qnx.tools.bbt.xml.core.bbtXMLValidationBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
#ifndef JSON_AUTOLINK_H_INCLUDED
|
||||
# define JSON_AUTOLINK_H_INCLUDED
|
||||
|
||||
# include "config.h"
|
||||
|
||||
# ifdef JSON_IN_CPPTL
|
||||
# include <cpptl/cpptl_autolink.h>
|
||||
# endif
|
||||
|
||||
# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL)
|
||||
# define CPPTL_AUTOLINK_NAME "json"
|
||||
# undef CPPTL_AUTOLINK_DLL
|
||||
# ifdef JSON_DLL
|
||||
# define CPPTL_AUTOLINK_DLL
|
||||
# endif
|
||||
# include "autolink.h"
|
||||
# endif
|
||||
|
||||
#endif // JSON_AUTOLINK_H_INCLUDED
|
@ -1,43 +0,0 @@
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
# define JSON_CONFIG_H_INCLUDED
|
||||
|
||||
/// If defined, indicates that json library is embedded in CppTL library.
|
||||
//# define JSON_IN_CPPTL 1
|
||||
|
||||
/// If defined, indicates that json may leverage CppTL library
|
||||
//# define JSON_USE_CPPTL 1
|
||||
/// If defined, indicates that cpptl vector based map should be used instead of std::map
|
||||
/// as Value container.
|
||||
//# define JSON_USE_CPPTL_SMALLMAP 1
|
||||
/// If defined, indicates that Json specific container should be used
|
||||
/// (hash table & simple deque container with customizable allocator).
|
||||
/// THIS FEATURE IS STILL EXPERIMENTAL!
|
||||
//# define JSON_VALUE_USE_INTERNAL_MAP 1
|
||||
/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
|
||||
/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
|
||||
/// as if it was a POD) that may cause some validation tool to report errors.
|
||||
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
|
||||
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
|
||||
|
||||
/// If defined, indicates that Json use exception to report invalid type manipulation
|
||||
/// instead of C assert macro.
|
||||
# define JSON_USE_EXCEPTION 1
|
||||
|
||||
# ifdef JSON_IN_CPPTL
|
||||
# include <cpptl/config.h>
|
||||
# ifndef JSON_USE_CPPTL
|
||||
# define JSON_USE_CPPTL 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef JSON_IN_CPPTL
|
||||
# define JSON_API CPPTL_API
|
||||
# elif defined(JSON_DLL_BUILD)
|
||||
# define JSON_API __declspec(dllexport)
|
||||
# elif defined(JSON_DLL)
|
||||
# define JSON_API __declspec(dllimport)
|
||||
# else
|
||||
# define JSON_API
|
||||
# endif
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
@ -1,42 +0,0 @@
|
||||
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
# define CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
|
||||
# include "forwards.h"
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Configuration passed to reader and writer.
|
||||
* This configuration object can be used to force the Reader or Writer
|
||||
* to behave in a standard conforming way.
|
||||
*/
|
||||
class JSON_API Features
|
||||
{
|
||||
public:
|
||||
/** \brief A configuration that allows all features and assumes all strings are UTF-8.
|
||||
* - C & C++ comments are allowed
|
||||
* - Root object can be any JSON value
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features all();
|
||||
|
||||
/** \brief A configuration that is strictly compatible with the JSON specification.
|
||||
* - Comments are forbidden.
|
||||
* - Root object must be either an array or an object value.
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features strictMode();
|
||||
|
||||
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
||||
*/
|
||||
Features();
|
||||
|
||||
/// \c true if comments are allowed. Default: \c true.
|
||||
bool allowComments_;
|
||||
|
||||
/// \c true if root must be either an array or an object value. Default: \c false.
|
||||
bool strictRoot_;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
@ -1,39 +0,0 @@
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
# define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
# include "config.h"
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
|
||||
// features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||
class ValueAllocator;
|
||||
class ValueMapAllocator;
|
||||
class ValueInternalLink;
|
||||
class ValueInternalArray;
|
||||
class ValueInternalMap;
|
||||
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
@ -1,10 +0,0 @@
|
||||
#ifndef JSON_JSON_H_INCLUDED
|
||||
# define JSON_JSON_H_INCLUDED
|
||||
|
||||
# include "autolink.h"
|
||||
# include "value.h"
|
||||
# include "reader.h"
|
||||
# include "writer.h"
|
||||
# include "features.h"
|
||||
|
||||
#endif // JSON_JSON_H_INCLUDED
|
@ -1,196 +0,0 @@
|
||||
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
||||
# define CPPTL_JSON_READER_H_INCLUDED
|
||||
|
||||
# include "features.h"
|
||||
# include "value.h"
|
||||
# include <deque>
|
||||
# include <stack>
|
||||
# include <string>
|
||||
# include <iostream>
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
|
||||
*
|
||||
*/
|
||||
class JSON_API Reader
|
||||
{
|
||||
public:
|
||||
typedef char Char;
|
||||
typedef const Char *Location;
|
||||
|
||||
/** \brief Constructs a Reader allowing all features
|
||||
* for parsing.
|
||||
*/
|
||||
Reader();
|
||||
|
||||
/** \brief Constructs a Reader allowing the specified feature set
|
||||
* for parsing.
|
||||
*/
|
||||
Reader( const Features &features );
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
|
||||
* \param document UTF-8 encoded string containing the document to read.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing them back during
|
||||
* serialization, \c false to discard comments.
|
||||
* This parameter is ignored if Features::allowComments_
|
||||
* is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an error occurred.
|
||||
*/
|
||||
bool parse( const std::string &document,
|
||||
Value &root,
|
||||
bool collectComments = true );
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
|
||||
* \param document UTF-8 encoded string containing the document to read.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing them back during
|
||||
* serialization, \c false to discard comments.
|
||||
* This parameter is ignored if Features::allowComments_
|
||||
* is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an error occurred.
|
||||
*/
|
||||
bool parse( const char *beginDoc, const char *endDoc,
|
||||
Value &root,
|
||||
bool collectComments = true );
|
||||
|
||||
/// \brief Parse from input stream.
|
||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
||||
bool parse( std::istream &is,
|
||||
Value &root,
|
||||
bool collectComments = true );
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed document.
|
||||
* \return Formatted error message with the list of errors with their location in
|
||||
* the parsed document. An empty string is returned if no error occurred
|
||||
* during parsing.
|
||||
*/
|
||||
std::string getFormatedErrorMessages() const;
|
||||
|
||||
private:
|
||||
enum TokenType
|
||||
{
|
||||
tokenEndOfStream = 0,
|
||||
tokenObjectBegin,
|
||||
tokenObjectEnd,
|
||||
tokenArrayBegin,
|
||||
tokenArrayEnd,
|
||||
tokenString,
|
||||
tokenNumber,
|
||||
tokenTrue,
|
||||
tokenFalse,
|
||||
tokenNull,
|
||||
tokenArraySeparator,
|
||||
tokenMemberSeparator,
|
||||
tokenComment,
|
||||
tokenError
|
||||
};
|
||||
|
||||
class Token
|
||||
{
|
||||
public:
|
||||
TokenType type_;
|
||||
Location start_;
|
||||
Location end_;
|
||||
};
|
||||
|
||||
class ErrorInfo
|
||||
{
|
||||
public:
|
||||
Token token_;
|
||||
std::string message_;
|
||||
Location extra_;
|
||||
};
|
||||
|
||||
typedef std::deque<ErrorInfo> Errors;
|
||||
|
||||
bool expectToken( TokenType type, Token &token, const char *message );
|
||||
bool readToken( Token &token );
|
||||
void skipSpaces();
|
||||
bool match( Location pattern,
|
||||
int patternLength );
|
||||
bool readComment();
|
||||
bool readCStyleComment();
|
||||
bool readCppStyleComment();
|
||||
bool readString();
|
||||
void readNumber();
|
||||
bool readValue();
|
||||
bool readObject( Token &token );
|
||||
bool readArray( Token &token );
|
||||
bool decodeNumber( Token &token );
|
||||
bool decodeString( Token &token );
|
||||
bool decodeString( Token &token, std::string &decoded );
|
||||
bool decodeDouble( Token &token );
|
||||
bool decodeUnicodeCodePoint( Token &token,
|
||||
Location ¤t,
|
||||
Location end,
|
||||
unsigned int &unicode );
|
||||
bool decodeUnicodeEscapeSequence( Token &token,
|
||||
Location ¤t,
|
||||
Location end,
|
||||
unsigned int &unicode );
|
||||
bool addError( const std::string &message,
|
||||
Token &token,
|
||||
Location extra = 0 );
|
||||
bool recoverFromError( TokenType skipUntilToken );
|
||||
bool addErrorAndRecover( const std::string &message,
|
||||
Token &token,
|
||||
TokenType skipUntilToken );
|
||||
void skipUntilSpace();
|
||||
Value ¤tValue();
|
||||
Char getNextChar();
|
||||
void getLocationLineAndColumn( Location location,
|
||||
int &line,
|
||||
int &column ) const;
|
||||
std::string getLocationLineAndColumn( Location location ) const;
|
||||
void addComment( Location begin,
|
||||
Location end,
|
||||
CommentPlacement placement );
|
||||
void skipCommentTokens( Token &token );
|
||||
|
||||
typedef std::stack<Value *> Nodes;
|
||||
Nodes nodes_;
|
||||
Errors errors_;
|
||||
std::string document_;
|
||||
Location begin_;
|
||||
Location end_;
|
||||
Location current_;
|
||||
Location lastValueEnd_;
|
||||
Value *lastValue_;
|
||||
std::string commentsBefore_;
|
||||
Features features_;
|
||||
bool collectComments_;
|
||||
};
|
||||
|
||||
/** \brief Read from 'sin' into 'root'.
|
||||
|
||||
Always keep comments from the input JSON.
|
||||
|
||||
This can be used to read a file into a particular sub-object.
|
||||
For example:
|
||||
\code
|
||||
Json::Value root;
|
||||
cin >> root["dir"]["file"];
|
||||
cout << root;
|
||||
\endcode
|
||||
Result:
|
||||
\verbatim
|
||||
{
|
||||
"dir": {
|
||||
"file": {
|
||||
// The input stream JSON would be nested here.
|
||||
}
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
\throw std::exception on parse error.
|
||||
\see Json::operator<<()
|
||||
*/
|
||||
std::istream& operator>>( std::istream&, Value& );
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // CPPTL_JSON_READER_H_INCLUDED
|
File diff suppressed because it is too large
Load Diff
@ -1,174 +0,0 @@
|
||||
#ifndef JSON_WRITER_H_INCLUDED
|
||||
# define JSON_WRITER_H_INCLUDED
|
||||
|
||||
# include "value.h"
|
||||
# include <vector>
|
||||
# include <string>
|
||||
# include <iostream>
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
|
||||
/** \brief Abstract class for writers.
|
||||
*/
|
||||
class JSON_API Writer
|
||||
{
|
||||
public:
|
||||
virtual ~Writer();
|
||||
|
||||
virtual std::string write( const Value &root ) = 0;
|
||||
};
|
||||
|
||||
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
|
||||
*
|
||||
* The JSON document is written in a single line. It is not intended for 'human' consumption,
|
||||
* but may be usefull to support feature such as RPC where bandwith is limited.
|
||||
* \sa Reader, Value
|
||||
*/
|
||||
class JSON_API FastWriter : public Writer
|
||||
{
|
||||
public:
|
||||
FastWriter();
|
||||
virtual ~FastWriter(){}
|
||||
|
||||
void enableYAMLCompatibility();
|
||||
|
||||
public: // overridden from Writer
|
||||
virtual std::string write( const Value &root );
|
||||
|
||||
private:
|
||||
void writeValue( const Value &value );
|
||||
|
||||
std::string document_;
|
||||
bool yamlCompatiblityEnabled_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value types,
|
||||
* and all the values fit on one lines, then print the array on a single line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their #CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
*/
|
||||
class JSON_API StyledWriter: public Writer
|
||||
{
|
||||
public:
|
||||
StyledWriter();
|
||||
virtual ~StyledWriter(){}
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param root Value to serialize.
|
||||
* \return String containing the JSON document that represents the root value.
|
||||
*/
|
||||
virtual std::string write( const Value &root );
|
||||
|
||||
private:
|
||||
void writeValue( const Value &value );
|
||||
void writeArrayValue( const Value &value );
|
||||
bool isMultineArray( const Value &value );
|
||||
void pushValue( const std::string &value );
|
||||
void writeIndent();
|
||||
void writeWithIndent( const std::string &value );
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue( const Value &root );
|
||||
void writeCommentAfterValueOnSameLine( const Value &root );
|
||||
bool hasCommentForValue( const Value &value );
|
||||
static std::string normalizeEOL( const std::string &text );
|
||||
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
std::string document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
int indentSize_;
|
||||
bool addChildValues_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
|
||||
to a stream rather than to a string.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value types,
|
||||
* and all the values fit on one lines, then print the array on a single line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputed according to their #CommentPlacement.
|
||||
*
|
||||
* \param indentation Each level will be indented by this amount extra.
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
*/
|
||||
class JSON_API StyledStreamWriter
|
||||
{
|
||||
public:
|
||||
StyledStreamWriter( std::string indentation="\t" );
|
||||
~StyledStreamWriter(){}
|
||||
|
||||
public:
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param out Stream to write to. (Can be ostringstream, e.g.)
|
||||
* \param root Value to serialize.
|
||||
* \note There is no point in deriving from Writer, since write() should not return a value.
|
||||
*/
|
||||
void write( std::ostream &out, const Value &root );
|
||||
|
||||
private:
|
||||
void writeValue( const Value &value );
|
||||
void writeArrayValue( const Value &value );
|
||||
bool isMultineArray( const Value &value );
|
||||
void pushValue( const std::string &value );
|
||||
void writeIndent();
|
||||
void writeWithIndent( const std::string &value );
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue( const Value &root );
|
||||
void writeCommentAfterValueOnSameLine( const Value &root );
|
||||
bool hasCommentForValue( const Value &value );
|
||||
static std::string normalizeEOL( const std::string &text );
|
||||
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
std::ostream* document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
std::string indentation_;
|
||||
bool addChildValues_;
|
||||
};
|
||||
|
||||
std::string JSON_API valueToString( Int value );
|
||||
std::string JSON_API valueToString( UInt value );
|
||||
std::string JSON_API valueToString( double value );
|
||||
std::string JSON_API valueToString( bool value );
|
||||
std::string JSON_API valueToQuotedString( const char *value );
|
||||
|
||||
/// \brief Output using the StyledStreamWriter.
|
||||
/// \see Json::operator>>()
|
||||
std::ostream& operator<<( std::ostream&, const Value &root );
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
||||
|
||||
#endif // JSON_WRITER_H_INCLUDED
|
@ -1,125 +0,0 @@
|
||||
#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||
# define JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <assert.h>
|
||||
|
||||
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
|
||||
namespace Json {
|
||||
|
||||
/* Fast memory allocator.
|
||||
*
|
||||
* This memory allocator allocates memory for a batch of object (specified by
|
||||
* the page size, the number of object in each page).
|
||||
*
|
||||
* It does not allow the destruction of a single object. All the allocated objects
|
||||
* can be destroyed at once. The memory can be either released or reused for future
|
||||
* allocation.
|
||||
*
|
||||
* The in-place new operator must be used to construct the object using the pointer
|
||||
* returned by allocate.
|
||||
*/
|
||||
template<typename AllocatedType
|
||||
,const unsigned int objectPerAllocation>
|
||||
class BatchAllocator
|
||||
{
|
||||
public:
|
||||
typedef AllocatedType Type;
|
||||
|
||||
BatchAllocator( unsigned int objectsPerPage = 255 )
|
||||
: freeHead_( 0 )
|
||||
, objectsPerPage_( objectsPerPage )
|
||||
{
|
||||
// printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() );
|
||||
assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space.
|
||||
assert( objectsPerPage >= 16 );
|
||||
batches_ = allocateBatch( 0 ); // allocated a dummy page
|
||||
currentBatch_ = batches_;
|
||||
}
|
||||
|
||||
~BatchAllocator()
|
||||
{
|
||||
for ( BatchInfo *batch = batches_; batch; )
|
||||
{
|
||||
BatchInfo *nextBatch = batch->next_;
|
||||
free( batch );
|
||||
batch = nextBatch;
|
||||
}
|
||||
}
|
||||
|
||||
/// allocate space for an array of objectPerAllocation object.
|
||||
/// @warning it is the responsability of the caller to call objects constructors.
|
||||
AllocatedType *allocate()
|
||||
{
|
||||
if ( freeHead_ ) // returns node from free list.
|
||||
{
|
||||
AllocatedType *object = freeHead_;
|
||||
freeHead_ = *(AllocatedType **)object;
|
||||
return object;
|
||||
}
|
||||
if ( currentBatch_->used_ == currentBatch_->end_ )
|
||||
{
|
||||
currentBatch_ = currentBatch_->next_;
|
||||
while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ )
|
||||
currentBatch_ = currentBatch_->next_;
|
||||
|
||||
if ( !currentBatch_ ) // no free batch found, allocate a new one
|
||||
{
|
||||
currentBatch_ = allocateBatch( objectsPerPage_ );
|
||||
currentBatch_->next_ = batches_; // insert at the head of the list
|
||||
batches_ = currentBatch_;
|
||||
}
|
||||
}
|
||||
AllocatedType *allocated = currentBatch_->used_;
|
||||
currentBatch_->used_ += objectPerAllocation;
|
||||
return allocated;
|
||||
}
|
||||
|
||||
/// Release the object.
|
||||
/// @warning it is the responsability of the caller to actually destruct the object.
|
||||
void release( AllocatedType *object )
|
||||
{
|
||||
assert( object != 0 );
|
||||
*(AllocatedType **)object = freeHead_;
|
||||
freeHead_ = object;
|
||||
}
|
||||
|
||||
private:
|
||||
struct BatchInfo
|
||||
{
|
||||
BatchInfo *next_;
|
||||
AllocatedType *used_;
|
||||
AllocatedType *end_;
|
||||
AllocatedType buffer_[objectPerAllocation];
|
||||
};
|
||||
|
||||
// disabled copy constructor and assignement operator.
|
||||
BatchAllocator( const BatchAllocator & );
|
||||
void operator =( const BatchAllocator &);
|
||||
|
||||
static BatchInfo *allocateBatch( unsigned int objectsPerPage )
|
||||
{
|
||||
const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation
|
||||
+ sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
|
||||
BatchInfo *batch = static_cast<BatchInfo*>( malloc( mallocSize ) );
|
||||
batch->next_ = 0;
|
||||
batch->used_ = batch->buffer_;
|
||||
batch->end_ = batch->buffer_ + objectsPerPage;
|
||||
return batch;
|
||||
}
|
||||
|
||||
BatchInfo *batches_;
|
||||
BatchInfo *currentBatch_;
|
||||
/// Head of a single linked list within the allocated space of freeed object
|
||||
AllocatedType *freeHead_;
|
||||
unsigned int objectsPerPage_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Json
|
||||
|
||||
# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
|
||||
|
||||
#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||
|
@ -1,448 +0,0 @@
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueInternalArray
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueArrayAllocator::~ValueArrayAllocator()
|
||||
{
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class DefaultValueArrayAllocator
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
class DefaultValueArrayAllocator : public ValueArrayAllocator
|
||||
{
|
||||
public: // overridden from ValueArrayAllocator
|
||||
virtual ~DefaultValueArrayAllocator()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ValueInternalArray *newArray()
|
||||
{
|
||||
return new ValueInternalArray();
|
||||
}
|
||||
|
||||
virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
|
||||
{
|
||||
return new ValueInternalArray( other );
|
||||
}
|
||||
|
||||
virtual void destructArray( ValueInternalArray *array )
|
||||
{
|
||||
delete array;
|
||||
}
|
||||
|
||||
virtual void reallocateArrayPageIndex( Value **&indexes,
|
||||
ValueInternalArray::PageIndex &indexCount,
|
||||
ValueInternalArray::PageIndex minNewIndexCount )
|
||||
{
|
||||
ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
|
||||
if ( minNewIndexCount > newIndexCount )
|
||||
newIndexCount = minNewIndexCount;
|
||||
void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
|
||||
if ( !newIndexes )
|
||||
throw std::bad_alloc();
|
||||
indexCount = newIndexCount;
|
||||
indexes = static_cast<Value **>( newIndexes );
|
||||
}
|
||||
virtual void releaseArrayPageIndex( Value **indexes,
|
||||
ValueInternalArray::PageIndex indexCount )
|
||||
{
|
||||
if ( indexes )
|
||||
free( indexes );
|
||||
}
|
||||
|
||||
virtual Value *allocateArrayPage()
|
||||
{
|
||||
return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
|
||||
}
|
||||
|
||||
virtual void releaseArrayPage( Value *value )
|
||||
{
|
||||
if ( value )
|
||||
free( value );
|
||||
}
|
||||
};
|
||||
|
||||
#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
/// @todo make this thread-safe (lock when accessign batch allocator)
|
||||
class DefaultValueArrayAllocator : public ValueArrayAllocator
|
||||
{
|
||||
public: // overridden from ValueArrayAllocator
|
||||
virtual ~DefaultValueArrayAllocator()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ValueInternalArray *newArray()
|
||||
{
|
||||
ValueInternalArray *array = arraysAllocator_.allocate();
|
||||
new (array) ValueInternalArray(); // placement new
|
||||
return array;
|
||||
}
|
||||
|
||||
virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
|
||||
{
|
||||
ValueInternalArray *array = arraysAllocator_.allocate();
|
||||
new (array) ValueInternalArray( other ); // placement new
|
||||
return array;
|
||||
}
|
||||
|
||||
virtual void destructArray( ValueInternalArray *array )
|
||||
{
|
||||
if ( array )
|
||||
{
|
||||
array->~ValueInternalArray();
|
||||
arraysAllocator_.release( array );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void reallocateArrayPageIndex( Value **&indexes,
|
||||
ValueInternalArray::PageIndex &indexCount,
|
||||
ValueInternalArray::PageIndex minNewIndexCount )
|
||||
{
|
||||
ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
|
||||
if ( minNewIndexCount > newIndexCount )
|
||||
newIndexCount = minNewIndexCount;
|
||||
void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
|
||||
if ( !newIndexes )
|
||||
throw std::bad_alloc();
|
||||
indexCount = newIndexCount;
|
||||
indexes = static_cast<Value **>( newIndexes );
|
||||
}
|
||||
virtual void releaseArrayPageIndex( Value **indexes,
|
||||
ValueInternalArray::PageIndex indexCount )
|
||||
{
|
||||
if ( indexes )
|
||||
free( indexes );
|
||||
}
|
||||
|
||||
virtual Value *allocateArrayPage()
|
||||
{
|
||||
return static_cast<Value *>( pagesAllocator_.allocate() );
|
||||
}
|
||||
|
||||
virtual void releaseArrayPage( Value *value )
|
||||
{
|
||||
if ( value )
|
||||
pagesAllocator_.release( value );
|
||||
}
|
||||
private:
|
||||
BatchAllocator<ValueInternalArray,1> arraysAllocator_;
|
||||
BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;
|
||||
};
|
||||
#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
|
||||
static ValueArrayAllocator *&arrayAllocator()
|
||||
{
|
||||
static DefaultValueArrayAllocator defaultAllocator;
|
||||
static ValueArrayAllocator *arrayAllocator = &defaultAllocator;
|
||||
return arrayAllocator;
|
||||
}
|
||||
|
||||
static struct DummyArrayAllocatorInitializer {
|
||||
DummyArrayAllocatorInitializer()
|
||||
{
|
||||
arrayAllocator(); // ensure arrayAllocator() statics are initialized before main().
|
||||
}
|
||||
} dummyArrayAllocatorInitializer;
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueInternalArray
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
ValueInternalArray::equals( const IteratorState &x,
|
||||
const IteratorState &other )
|
||||
{
|
||||
return x.array_ == other.array_
|
||||
&& x.currentItemIndex_ == other.currentItemIndex_
|
||||
&& x.currentPageIndex_ == other.currentPageIndex_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::increment( IteratorState &it )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( it.array_ &&
|
||||
(it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
|
||||
!= it.array_->size_,
|
||||
"ValueInternalArray::increment(): moving iterator beyond end" );
|
||||
++(it.currentItemIndex_);
|
||||
if ( it.currentItemIndex_ == itemsPerPage )
|
||||
{
|
||||
it.currentItemIndex_ = 0;
|
||||
++(it.currentPageIndex_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::decrement( IteratorState &it )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( it.array_ && it.currentPageIndex_ == it.array_->pages_
|
||||
&& it.currentItemIndex_ == 0,
|
||||
"ValueInternalArray::decrement(): moving iterator beyond end" );
|
||||
if ( it.currentItemIndex_ == 0 )
|
||||
{
|
||||
it.currentItemIndex_ = itemsPerPage-1;
|
||||
--(it.currentPageIndex_);
|
||||
}
|
||||
else
|
||||
{
|
||||
--(it.currentItemIndex_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalArray::unsafeDereference( const IteratorState &it )
|
||||
{
|
||||
return (*(it.currentPageIndex_))[it.currentItemIndex_];
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalArray::dereference( const IteratorState &it )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( it.array_ &&
|
||||
(it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
|
||||
< it.array_->size_,
|
||||
"ValueInternalArray::dereference(): dereferencing invalid iterator" );
|
||||
return unsafeDereference( it );
|
||||
}
|
||||
|
||||
void
|
||||
ValueInternalArray::makeBeginIterator( IteratorState &it ) const
|
||||
{
|
||||
it.array_ = const_cast<ValueInternalArray *>( this );
|
||||
it.currentItemIndex_ = 0;
|
||||
it.currentPageIndex_ = pages_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const
|
||||
{
|
||||
it.array_ = const_cast<ValueInternalArray *>( this );
|
||||
it.currentItemIndex_ = index % itemsPerPage;
|
||||
it.currentPageIndex_ = pages_ + index / itemsPerPage;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::makeEndIterator( IteratorState &it ) const
|
||||
{
|
||||
makeIterator( it, size_ );
|
||||
}
|
||||
|
||||
|
||||
ValueInternalArray::ValueInternalArray()
|
||||
: pages_( 0 )
|
||||
, size_( 0 )
|
||||
, pageCount_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ValueInternalArray::ValueInternalArray( const ValueInternalArray &other )
|
||||
: pages_( 0 )
|
||||
, pageCount_( 0 )
|
||||
, size_( other.size_ )
|
||||
{
|
||||
PageIndex minNewPages = other.size_ / itemsPerPage;
|
||||
arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
|
||||
JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages,
|
||||
"ValueInternalArray::reserve(): bad reallocation" );
|
||||
IteratorState itOther;
|
||||
other.makeBeginIterator( itOther );
|
||||
Value *value;
|
||||
for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )
|
||||
{
|
||||
if ( index % itemsPerPage == 0 )
|
||||
{
|
||||
PageIndex pageIndex = index / itemsPerPage;
|
||||
value = arrayAllocator()->allocateArrayPage();
|
||||
pages_[pageIndex] = value;
|
||||
}
|
||||
new (value) Value( dereference( itOther ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ValueInternalArray &
|
||||
ValueInternalArray::operator =( const ValueInternalArray &other )
|
||||
{
|
||||
ValueInternalArray temp( other );
|
||||
swap( temp );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ValueInternalArray::~ValueInternalArray()
|
||||
{
|
||||
// destroy all constructed items
|
||||
IteratorState it;
|
||||
IteratorState itEnd;
|
||||
makeBeginIterator( it);
|
||||
makeEndIterator( itEnd );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
Value *value = &dereference(it);
|
||||
value->~Value();
|
||||
}
|
||||
// release all pages
|
||||
PageIndex lastPageIndex = size_ / itemsPerPage;
|
||||
for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )
|
||||
arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
|
||||
// release pages index
|
||||
arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::swap( ValueInternalArray &other )
|
||||
{
|
||||
Value **tempPages = pages_;
|
||||
pages_ = other.pages_;
|
||||
other.pages_ = tempPages;
|
||||
ArrayIndex tempSize = size_;
|
||||
size_ = other.size_;
|
||||
other.size_ = tempSize;
|
||||
PageIndex tempPageCount = pageCount_;
|
||||
pageCount_ = other.pageCount_;
|
||||
other.pageCount_ = tempPageCount;
|
||||
}
|
||||
|
||||
void
|
||||
ValueInternalArray::clear()
|
||||
{
|
||||
ValueInternalArray dummy;
|
||||
swap( dummy );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::resize( ArrayIndex newSize )
|
||||
{
|
||||
if ( newSize == 0 )
|
||||
clear();
|
||||
else if ( newSize < size_ )
|
||||
{
|
||||
IteratorState it;
|
||||
IteratorState itEnd;
|
||||
makeIterator( it, newSize );
|
||||
makeIterator( itEnd, size_ );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
Value *value = &dereference(it);
|
||||
value->~Value();
|
||||
}
|
||||
PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
|
||||
PageIndex lastPageIndex = size_ / itemsPerPage;
|
||||
for ( ; pageIndex < lastPageIndex; ++pageIndex )
|
||||
arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
|
||||
size_ = newSize;
|
||||
}
|
||||
else if ( newSize > size_ )
|
||||
resolveReference( newSize );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalArray::makeIndexValid( ArrayIndex index )
|
||||
{
|
||||
// Need to enlarge page index ?
|
||||
if ( index >= pageCount_ * itemsPerPage )
|
||||
{
|
||||
PageIndex minNewPages = (index + 1) / itemsPerPage;
|
||||
arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
|
||||
JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, "ValueInternalArray::reserve(): bad reallocation" );
|
||||
}
|
||||
|
||||
// Need to allocate new pages ?
|
||||
ArrayIndex nextPageIndex =
|
||||
(size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage
|
||||
: size_;
|
||||
if ( nextPageIndex <= index )
|
||||
{
|
||||
PageIndex pageIndex = nextPageIndex / itemsPerPage;
|
||||
PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
|
||||
for ( ; pageToAllocate-- > 0; ++pageIndex )
|
||||
pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
|
||||
}
|
||||
|
||||
// Initialize all new entries
|
||||
IteratorState it;
|
||||
IteratorState itEnd;
|
||||
makeIterator( it, size_ );
|
||||
size_ = index + 1;
|
||||
makeIterator( itEnd, size_ );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
Value *value = &dereference(it);
|
||||
new (value) Value(); // Construct a default value using placement new
|
||||
}
|
||||
}
|
||||
|
||||
Value &
|
||||
ValueInternalArray::resolveReference( ArrayIndex index )
|
||||
{
|
||||
if ( index >= size_ )
|
||||
makeIndexValid( index );
|
||||
return pages_[index/itemsPerPage][index%itemsPerPage];
|
||||
}
|
||||
|
||||
Value *
|
||||
ValueInternalArray::find( ArrayIndex index ) const
|
||||
{
|
||||
if ( index >= size_ )
|
||||
return 0;
|
||||
return &(pages_[index/itemsPerPage][index%itemsPerPage]);
|
||||
}
|
||||
|
||||
ValueInternalArray::ArrayIndex
|
||||
ValueInternalArray::size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
int
|
||||
ValueInternalArray::distance( const IteratorState &x, const IteratorState &y )
|
||||
{
|
||||
return indexOf(y) - indexOf(x);
|
||||
}
|
||||
|
||||
|
||||
ValueInternalArray::ArrayIndex
|
||||
ValueInternalArray::indexOf( const IteratorState &iterator )
|
||||
{
|
||||
if ( !iterator.array_ )
|
||||
return ArrayIndex(-1);
|
||||
return ArrayIndex(
|
||||
(iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage
|
||||
+ iterator.currentItemIndex_ );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ValueInternalArray::compare( const ValueInternalArray &other ) const
|
||||
{
|
||||
int sizeDiff( size_ - other.size_ );
|
||||
if ( sizeDiff != 0 )
|
||||
return sizeDiff;
|
||||
|
||||
for ( ArrayIndex index =0; index < size_; ++index )
|
||||
{
|
||||
int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare(
|
||||
other.pages_[index/itemsPerPage][index%itemsPerPage] );
|
||||
if ( diff != 0 )
|
||||
return diff;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,607 +0,0 @@
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueInternalMap
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
/** \internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );
|
||||
* This optimization is used by the fast allocator.
|
||||
*/
|
||||
ValueInternalLink::ValueInternalLink()
|
||||
: previous_( 0 )
|
||||
, next_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
ValueInternalLink::~ValueInternalLink()
|
||||
{
|
||||
for ( int index =0; index < itemPerLink; ++index )
|
||||
{
|
||||
if ( !items_[index].isItemAvailable() )
|
||||
{
|
||||
if ( !items_[index].isMemberNameStatic() )
|
||||
free( keys_[index] );
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ValueMapAllocator::~ValueMapAllocator()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
class DefaultValueMapAllocator : public ValueMapAllocator
|
||||
{
|
||||
public: // overridden from ValueMapAllocator
|
||||
virtual ValueInternalMap *newMap()
|
||||
{
|
||||
return new ValueInternalMap();
|
||||
}
|
||||
|
||||
virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
|
||||
{
|
||||
return new ValueInternalMap( other );
|
||||
}
|
||||
|
||||
virtual void destructMap( ValueInternalMap *map )
|
||||
{
|
||||
delete map;
|
||||
}
|
||||
|
||||
virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
|
||||
{
|
||||
return new ValueInternalLink[size];
|
||||
}
|
||||
|
||||
virtual void releaseMapBuckets( ValueInternalLink *links )
|
||||
{
|
||||
delete [] links;
|
||||
}
|
||||
|
||||
virtual ValueInternalLink *allocateMapLink()
|
||||
{
|
||||
return new ValueInternalLink();
|
||||
}
|
||||
|
||||
virtual void releaseMapLink( ValueInternalLink *link )
|
||||
{
|
||||
delete link;
|
||||
}
|
||||
};
|
||||
#else
|
||||
/// @todo make this thread-safe (lock when accessign batch allocator)
|
||||
class DefaultValueMapAllocator : public ValueMapAllocator
|
||||
{
|
||||
public: // overridden from ValueMapAllocator
|
||||
virtual ValueInternalMap *newMap()
|
||||
{
|
||||
ValueInternalMap *map = mapsAllocator_.allocate();
|
||||
new (map) ValueInternalMap(); // placement new
|
||||
return map;
|
||||
}
|
||||
|
||||
virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
|
||||
{
|
||||
ValueInternalMap *map = mapsAllocator_.allocate();
|
||||
new (map) ValueInternalMap( other ); // placement new
|
||||
return map;
|
||||
}
|
||||
|
||||
virtual void destructMap( ValueInternalMap *map )
|
||||
{
|
||||
if ( map )
|
||||
{
|
||||
map->~ValueInternalMap();
|
||||
mapsAllocator_.release( map );
|
||||
}
|
||||
}
|
||||
|
||||
virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
|
||||
{
|
||||
return new ValueInternalLink[size];
|
||||
}
|
||||
|
||||
virtual void releaseMapBuckets( ValueInternalLink *links )
|
||||
{
|
||||
delete [] links;
|
||||
}
|
||||
|
||||
virtual ValueInternalLink *allocateMapLink()
|
||||
{
|
||||
ValueInternalLink *link = linksAllocator_.allocate();
|
||||
memset( link, 0, sizeof(ValueInternalLink) );
|
||||
return link;
|
||||
}
|
||||
|
||||
virtual void releaseMapLink( ValueInternalLink *link )
|
||||
{
|
||||
link->~ValueInternalLink();
|
||||
linksAllocator_.release( link );
|
||||
}
|
||||
private:
|
||||
BatchAllocator<ValueInternalMap,1> mapsAllocator_;
|
||||
BatchAllocator<ValueInternalLink,1> linksAllocator_;
|
||||
};
|
||||
#endif
|
||||
|
||||
static ValueMapAllocator *&mapAllocator()
|
||||
{
|
||||
static DefaultValueMapAllocator defaultAllocator;
|
||||
static ValueMapAllocator *mapAllocator = &defaultAllocator;
|
||||
return mapAllocator;
|
||||
}
|
||||
|
||||
static struct DummyMapAllocatorInitializer {
|
||||
DummyMapAllocatorInitializer()
|
||||
{
|
||||
mapAllocator(); // ensure mapAllocator() statics are initialized before main().
|
||||
}
|
||||
} dummyMapAllocatorInitializer;
|
||||
|
||||
|
||||
|
||||
// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
|
||||
|
||||
/*
|
||||
use linked list hash map.
|
||||
buckets array is a container.
|
||||
linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
|
||||
value have extra state: valid, available, deleted
|
||||
*/
|
||||
|
||||
|
||||
ValueInternalMap::ValueInternalMap()
|
||||
: buckets_( 0 )
|
||||
, tailLink_( 0 )
|
||||
, bucketsSize_( 0 )
|
||||
, itemCount_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ValueInternalMap::ValueInternalMap( const ValueInternalMap &other )
|
||||
: buckets_( 0 )
|
||||
, tailLink_( 0 )
|
||||
, bucketsSize_( 0 )
|
||||
, itemCount_( 0 )
|
||||
{
|
||||
reserve( other.itemCount_ );
|
||||
IteratorState it;
|
||||
IteratorState itEnd;
|
||||
other.makeBeginIterator( it );
|
||||
other.makeEndIterator( itEnd );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
bool isStatic;
|
||||
const char *memberName = key( it, isStatic );
|
||||
const Value &aValue = value( it );
|
||||
resolveReference(memberName, isStatic) = aValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ValueInternalMap &
|
||||
ValueInternalMap::operator =( const ValueInternalMap &other )
|
||||
{
|
||||
ValueInternalMap dummy( other );
|
||||
swap( dummy );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ValueInternalMap::~ValueInternalMap()
|
||||
{
|
||||
if ( buckets_ )
|
||||
{
|
||||
for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )
|
||||
{
|
||||
ValueInternalLink *link = buckets_[bucketIndex].next_;
|
||||
while ( link )
|
||||
{
|
||||
ValueInternalLink *linkToRelease = link;
|
||||
link = link->next_;
|
||||
mapAllocator()->releaseMapLink( linkToRelease );
|
||||
}
|
||||
}
|
||||
mapAllocator()->releaseMapBuckets( buckets_ );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::swap( ValueInternalMap &other )
|
||||
{
|
||||
ValueInternalLink *tempBuckets = buckets_;
|
||||
buckets_ = other.buckets_;
|
||||
other.buckets_ = tempBuckets;
|
||||
ValueInternalLink *tempTailLink = tailLink_;
|
||||
tailLink_ = other.tailLink_;
|
||||
other.tailLink_ = tempTailLink;
|
||||
BucketIndex tempBucketsSize = bucketsSize_;
|
||||
bucketsSize_ = other.bucketsSize_;
|
||||
other.bucketsSize_ = tempBucketsSize;
|
||||
BucketIndex tempItemCount = itemCount_;
|
||||
itemCount_ = other.itemCount_;
|
||||
other.itemCount_ = tempItemCount;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::clear()
|
||||
{
|
||||
ValueInternalMap dummy;
|
||||
swap( dummy );
|
||||
}
|
||||
|
||||
|
||||
ValueInternalMap::BucketIndex
|
||||
ValueInternalMap::size() const
|
||||
{
|
||||
return itemCount_;
|
||||
}
|
||||
|
||||
bool
|
||||
ValueInternalMap::reserveDelta( BucketIndex growth )
|
||||
{
|
||||
return reserve( itemCount_ + growth );
|
||||
}
|
||||
|
||||
bool
|
||||
ValueInternalMap::reserve( BucketIndex newItemCount )
|
||||
{
|
||||
if ( !buckets_ && newItemCount > 0 )
|
||||
{
|
||||
buckets_ = mapAllocator()->allocateMapBuckets( 1 );
|
||||
bucketsSize_ = 1;
|
||||
tailLink_ = &buckets_[0];
|
||||
}
|
||||
// BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const Value *
|
||||
ValueInternalMap::find( const char *key ) const
|
||||
{
|
||||
if ( !bucketsSize_ )
|
||||
return 0;
|
||||
HashKey hashedKey = hash( key );
|
||||
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||
for ( const ValueInternalLink *current = &buckets_[bucketIndex];
|
||||
current != 0;
|
||||
current = current->next_ )
|
||||
{
|
||||
for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )
|
||||
{
|
||||
if ( current->items_[index].isItemAvailable() )
|
||||
return 0;
|
||||
if ( strcmp( key, current->keys_[index] ) == 0 )
|
||||
return ¤t->items_[index];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Value *
|
||||
ValueInternalMap::find( const char *key )
|
||||
{
|
||||
const ValueInternalMap *constThis = this;
|
||||
return const_cast<Value *>( constThis->find( key ) );
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalMap::resolveReference( const char *key,
|
||||
bool isStatic )
|
||||
{
|
||||
HashKey hashedKey = hash( key );
|
||||
if ( bucketsSize_ )
|
||||
{
|
||||
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||
ValueInternalLink **previous = 0;
|
||||
BucketIndex index;
|
||||
for ( ValueInternalLink *current = &buckets_[bucketIndex];
|
||||
current != 0;
|
||||
previous = ¤t->next_, current = current->next_ )
|
||||
{
|
||||
for ( index=0; index < ValueInternalLink::itemPerLink; ++index )
|
||||
{
|
||||
if ( current->items_[index].isItemAvailable() )
|
||||
return setNewItem( key, isStatic, current, index );
|
||||
if ( strcmp( key, current->keys_[index] ) == 0 )
|
||||
return current->items_[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reserveDelta( 1 );
|
||||
return unsafeAdd( key, isStatic, hashedKey );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::remove( const char *key )
|
||||
{
|
||||
HashKey hashedKey = hash( key );
|
||||
if ( !bucketsSize_ )
|
||||
return;
|
||||
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||
for ( ValueInternalLink *link = &buckets_[bucketIndex];
|
||||
link != 0;
|
||||
link = link->next_ )
|
||||
{
|
||||
BucketIndex index;
|
||||
for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
|
||||
{
|
||||
if ( link->items_[index].isItemAvailable() )
|
||||
return;
|
||||
if ( strcmp( key, link->keys_[index] ) == 0 )
|
||||
{
|
||||
doActualRemove( link, index, bucketIndex );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ValueInternalMap::doActualRemove( ValueInternalLink *link,
|
||||
BucketIndex index,
|
||||
BucketIndex bucketIndex )
|
||||
{
|
||||
// find last item of the bucket and swap it with the 'removed' one.
|
||||
// set removed items flags to 'available'.
|
||||
// if last page only contains 'available' items, then desallocate it (it's empty)
|
||||
ValueInternalLink *&lastLink = getLastLinkInBucket( index );
|
||||
BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
|
||||
for ( ;
|
||||
lastItemIndex < ValueInternalLink::itemPerLink;
|
||||
++lastItemIndex ) // may be optimized with dicotomic search
|
||||
{
|
||||
if ( lastLink->items_[lastItemIndex].isItemAvailable() )
|
||||
break;
|
||||
}
|
||||
|
||||
BucketIndex lastUsedIndex = lastItemIndex - 1;
|
||||
Value *valueToDelete = &link->items_[index];
|
||||
Value *valueToPreserve = &lastLink->items_[lastUsedIndex];
|
||||
if ( valueToDelete != valueToPreserve )
|
||||
valueToDelete->swap( *valueToPreserve );
|
||||
if ( lastUsedIndex == 0 ) // page is now empty
|
||||
{ // remove it from bucket linked list and delete it.
|
||||
ValueInternalLink *linkPreviousToLast = lastLink->previous_;
|
||||
if ( linkPreviousToLast != 0 ) // can not deleted bucket link.
|
||||
{
|
||||
mapAllocator()->releaseMapLink( lastLink );
|
||||
linkPreviousToLast->next_ = 0;
|
||||
lastLink = linkPreviousToLast;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Value dummy;
|
||||
valueToPreserve->swap( dummy ); // restore deleted to default Value.
|
||||
valueToPreserve->setItemUsed( false );
|
||||
}
|
||||
--itemCount_;
|
||||
}
|
||||
|
||||
|
||||
ValueInternalLink *&
|
||||
ValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )
|
||||
{
|
||||
if ( bucketIndex == bucketsSize_ - 1 )
|
||||
return tailLink_;
|
||||
ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;
|
||||
if ( !previous )
|
||||
previous = &buckets_[bucketIndex];
|
||||
return previous;
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalMap::setNewItem( const char *key,
|
||||
bool isStatic,
|
||||
ValueInternalLink *link,
|
||||
BucketIndex index )
|
||||
{
|
||||
char *duplicatedKey = valueAllocator()->makeMemberName( key );
|
||||
++itemCount_;
|
||||
link->keys_[index] = duplicatedKey;
|
||||
link->items_[index].setItemUsed();
|
||||
link->items_[index].setMemberNameIsStatic( isStatic );
|
||||
return link->items_[index]; // items already default constructed.
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalMap::unsafeAdd( const char *key,
|
||||
bool isStatic,
|
||||
HashKey hashedKey )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( bucketsSize_ > 0, "ValueInternalMap::unsafeAdd(): internal logic error." );
|
||||
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||
ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );
|
||||
ValueInternalLink *link = previousLink;
|
||||
BucketIndex index;
|
||||
for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
|
||||
{
|
||||
if ( link->items_[index].isItemAvailable() )
|
||||
break;
|
||||
}
|
||||
if ( index == ValueInternalLink::itemPerLink ) // need to add a new page
|
||||
{
|
||||
ValueInternalLink *newLink = mapAllocator()->allocateMapLink();
|
||||
index = 0;
|
||||
link->next_ = newLink;
|
||||
previousLink = newLink;
|
||||
link = newLink;
|
||||
}
|
||||
return setNewItem( key, isStatic, link, index );
|
||||
}
|
||||
|
||||
|
||||
ValueInternalMap::HashKey
|
||||
ValueInternalMap::hash( const char *key ) const
|
||||
{
|
||||
HashKey hash = 0;
|
||||
while ( *key )
|
||||
hash += *key++ * 37;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ValueInternalMap::compare( const ValueInternalMap &other ) const
|
||||
{
|
||||
int sizeDiff( itemCount_ - other.itemCount_ );
|
||||
if ( sizeDiff != 0 )
|
||||
return sizeDiff;
|
||||
// Strict order guaranty is required. Compare all keys FIRST, then compare values.
|
||||
IteratorState it;
|
||||
IteratorState itEnd;
|
||||
makeBeginIterator( it );
|
||||
makeEndIterator( itEnd );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
if ( !other.find( key( it ) ) )
|
||||
return 1;
|
||||
}
|
||||
|
||||
// All keys are equals, let's compare values
|
||||
makeBeginIterator( it );
|
||||
for ( ; !equals(it,itEnd); increment(it) )
|
||||
{
|
||||
const Value *otherValue = other.find( key( it ) );
|
||||
int valueDiff = value(it).compare( *otherValue );
|
||||
if ( valueDiff != 0 )
|
||||
return valueDiff;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::makeBeginIterator( IteratorState &it ) const
|
||||
{
|
||||
it.map_ = const_cast<ValueInternalMap *>( this );
|
||||
it.bucketIndex_ = 0;
|
||||
it.itemIndex_ = 0;
|
||||
it.link_ = buckets_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::makeEndIterator( IteratorState &it ) const
|
||||
{
|
||||
it.map_ = const_cast<ValueInternalMap *>( this );
|
||||
it.bucketIndex_ = bucketsSize_;
|
||||
it.itemIndex_ = 0;
|
||||
it.link_ = 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ValueInternalMap::equals( const IteratorState &x, const IteratorState &other )
|
||||
{
|
||||
return x.map_ == other.map_
|
||||
&& x.bucketIndex_ == other.bucketIndex_
|
||||
&& x.link_ == other.link_
|
||||
&& x.itemIndex_ == other.itemIndex_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::incrementBucket( IteratorState &iterator )
|
||||
{
|
||||
++iterator.bucketIndex_;
|
||||
JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
|
||||
"ValueInternalMap::increment(): attempting to iterate beyond end." );
|
||||
if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )
|
||||
iterator.link_ = 0;
|
||||
else
|
||||
iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
|
||||
iterator.itemIndex_ = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::increment( IteratorState &iterator )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterator using invalid iterator." );
|
||||
++iterator.itemIndex_;
|
||||
if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.link_ != 0,
|
||||
"ValueInternalMap::increment(): attempting to iterate beyond end." );
|
||||
iterator.link_ = iterator.link_->next_;
|
||||
if ( iterator.link_ == 0 )
|
||||
incrementBucket( iterator );
|
||||
}
|
||||
else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )
|
||||
{
|
||||
incrementBucket( iterator );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueInternalMap::decrement( IteratorState &iterator )
|
||||
{
|
||||
if ( iterator.itemIndex_ == 0 )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterate using invalid iterator." );
|
||||
if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, "Attempting to iterate beyond beginning." );
|
||||
--(iterator.bucketIndex_);
|
||||
}
|
||||
iterator.link_ = iterator.link_->previous_;
|
||||
iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
ValueInternalMap::key( const IteratorState &iterator )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
|
||||
return iterator.link_->keys_[iterator.itemIndex_];
|
||||
}
|
||||
|
||||
const char *
|
||||
ValueInternalMap::key( const IteratorState &iterator, bool &isStatic )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
|
||||
isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
|
||||
return iterator.link_->keys_[iterator.itemIndex_];
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
ValueInternalMap::value( const IteratorState &iterator )
|
||||
{
|
||||
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
|
||||
return iterator.link_->items_[iterator.itemIndex_];
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ValueInternalMap::distance( const IteratorState &x, const IteratorState &y )
|
||||
{
|
||||
int offset = 0;
|
||||
IteratorState it = x;
|
||||
while ( !equals( it, y ) )
|
||||
increment( it );
|
||||
return offset;
|
||||
}
|
@ -1,892 +0,0 @@
|
||||
#include <json/reader.h>
|
||||
#include <json/value.h>
|
||||
#include <utility>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#if _MSC_VER >= 1400 // VC++ 8.0
|
||||
#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated.
|
||||
#endif
|
||||
|
||||
namespace Json {
|
||||
|
||||
// QNX is strict about declaring C symbols in the std namespace.
|
||||
#ifdef __QNXNTO__
|
||||
using std::memcpy;
|
||||
using std::sprintf;
|
||||
using std::sscanf;
|
||||
#endif
|
||||
|
||||
// Implementation of class Features
|
||||
// ////////////////////////////////
|
||||
|
||||
Features::Features()
|
||||
: allowComments_( true )
|
||||
, strictRoot_( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Features
|
||||
Features::all()
|
||||
{
|
||||
return Features();
|
||||
}
|
||||
|
||||
|
||||
Features
|
||||
Features::strictMode()
|
||||
{
|
||||
Features features;
|
||||
features.allowComments_ = false;
|
||||
features.strictRoot_ = true;
|
||||
return features;
|
||||
}
|
||||
|
||||
// Implementation of class Reader
|
||||
// ////////////////////////////////
|
||||
|
||||
|
||||
static inline bool
|
||||
in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4 )
|
||||
{
|
||||
return c == c1 || c == c2 || c == c3 || c == c4;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4, Reader::Char c5 )
|
||||
{
|
||||
return c == c1 || c == c2 || c == c3 || c == c4 || c == c5;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
containsNewLine( Reader::Location begin,
|
||||
Reader::Location end )
|
||||
{
|
||||
for ( ;begin < end; ++begin )
|
||||
if ( *begin == '\n' || *begin == '\r' )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string codePointToUTF8(unsigned int cp)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||
|
||||
if (cp <= 0x7f)
|
||||
{
|
||||
result.resize(1);
|
||||
result[0] = static_cast<char>(cp);
|
||||
}
|
||||
else if (cp <= 0x7FF)
|
||||
{
|
||||
result.resize(2);
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
|
||||
}
|
||||
else if (cp <= 0xFFFF)
|
||||
{
|
||||
result.resize(3);
|
||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
||||
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
||||
}
|
||||
else if (cp <= 0x10FFFF)
|
||||
{
|
||||
result.resize(4);
|
||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
|
||||
result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Class Reader
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Reader::Reader()
|
||||
: features_( Features::all() )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reader::Reader( const Features &features )
|
||||
: features_( features )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::parse( const std::string &document,
|
||||
Value &root,
|
||||
bool collectComments )
|
||||
{
|
||||
document_ = document;
|
||||
const char *begin = document_.c_str();
|
||||
const char *end = begin + document_.length();
|
||||
return parse( begin, end, root, collectComments );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::parse( std::istream& sin,
|
||||
Value &root,
|
||||
bool collectComments )
|
||||
{
|
||||
//std::istream_iterator<char> begin(sin);
|
||||
//std::istream_iterator<char> end;
|
||||
// Those would allow streamed input from a file, if parse() were a
|
||||
// template function.
|
||||
|
||||
// Since std::string is reference-counted, this at least does not
|
||||
// create an extra copy.
|
||||
std::string doc;
|
||||
std::getline(sin, doc, (char)EOF);
|
||||
return parse( doc, root, collectComments );
|
||||
}
|
||||
|
||||
bool
|
||||
Reader::parse( const char *beginDoc, const char *endDoc,
|
||||
Value &root,
|
||||
bool collectComments )
|
||||
{
|
||||
if ( !features_.allowComments_ )
|
||||
{
|
||||
collectComments = false;
|
||||
}
|
||||
|
||||
begin_ = beginDoc;
|
||||
end_ = endDoc;
|
||||
collectComments_ = collectComments;
|
||||
current_ = begin_;
|
||||
lastValueEnd_ = 0;
|
||||
lastValue_ = 0;
|
||||
commentsBefore_ = "";
|
||||
errors_.clear();
|
||||
while ( !nodes_.empty() )
|
||||
nodes_.pop();
|
||||
nodes_.push( &root );
|
||||
|
||||
bool successful = readValue();
|
||||
Token token;
|
||||
skipCommentTokens( token );
|
||||
if ( collectComments_ && !commentsBefore_.empty() )
|
||||
root.setComment( commentsBefore_, commentAfter );
|
||||
if ( features_.strictRoot_ )
|
||||
{
|
||||
if ( !root.isArray() && !root.isObject() )
|
||||
{
|
||||
// Set error location to start of doc, ideally should be first token found in doc
|
||||
token.type_ = tokenError;
|
||||
token.start_ = beginDoc;
|
||||
token.end_ = endDoc;
|
||||
addError( "A valid JSON document must be either an array or an object value.",
|
||||
token );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readValue()
|
||||
{
|
||||
Token token;
|
||||
skipCommentTokens( token );
|
||||
bool successful = true;
|
||||
|
||||
if ( collectComments_ && !commentsBefore_.empty() )
|
||||
{
|
||||
currentValue().setComment( commentsBefore_, commentBefore );
|
||||
commentsBefore_ = "";
|
||||
}
|
||||
|
||||
|
||||
switch ( token.type_ )
|
||||
{
|
||||
case tokenObjectBegin:
|
||||
successful = readObject( token );
|
||||
break;
|
||||
case tokenArrayBegin:
|
||||
successful = readArray( token );
|
||||
break;
|
||||
case tokenNumber:
|
||||
successful = decodeNumber( token );
|
||||
break;
|
||||
case tokenString:
|
||||
successful = decodeString( token );
|
||||
break;
|
||||
case tokenTrue:
|
||||
currentValue() = true;
|
||||
break;
|
||||
case tokenFalse:
|
||||
currentValue() = false;
|
||||
break;
|
||||
case tokenNull:
|
||||
currentValue() = Value();
|
||||
break;
|
||||
default:
|
||||
return addError( "Syntax error: value, object or array expected.", token );
|
||||
}
|
||||
|
||||
if ( collectComments_ )
|
||||
{
|
||||
lastValueEnd_ = current_;
|
||||
lastValue_ = ¤tValue();
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Reader::skipCommentTokens( Token &token )
|
||||
{
|
||||
if ( features_.allowComments_ )
|
||||
{
|
||||
do
|
||||
{
|
||||
readToken( token );
|
||||
}
|
||||
while ( token.type_ == tokenComment );
|
||||
}
|
||||
else
|
||||
{
|
||||
readToken( token );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::expectToken( TokenType type, Token &token, const char *message )
|
||||
{
|
||||
readToken( token );
|
||||
if ( token.type_ != type )
|
||||
return addError( message, token );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readToken( Token &token )
|
||||
{
|
||||
skipSpaces();
|
||||
token.start_ = current_;
|
||||
Char c = getNextChar();
|
||||
bool ok = true;
|
||||
switch ( c )
|
||||
{
|
||||
case '{':
|
||||
token.type_ = tokenObjectBegin;
|
||||
break;
|
||||
case '}':
|
||||
token.type_ = tokenObjectEnd;
|
||||
break;
|
||||
case '[':
|
||||
token.type_ = tokenArrayBegin;
|
||||
break;
|
||||
case ']':
|
||||
token.type_ = tokenArrayEnd;
|
||||
break;
|
||||
case '"':
|
||||
token.type_ = tokenString;
|
||||
ok = readString();
|
||||
break;
|
||||
case '/':
|
||||
token.type_ = tokenComment;
|
||||
ok = readComment();
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '-':
|
||||
token.type_ = tokenNumber;
|
||||
readNumber();
|
||||
break;
|
||||
case 't':
|
||||
token.type_ = tokenTrue;
|
||||
ok = match( "rue", 3 );
|
||||
break;
|
||||
case 'f':
|
||||
token.type_ = tokenFalse;
|
||||
ok = match( "alse", 4 );
|
||||
break;
|
||||
case 'n':
|
||||
token.type_ = tokenNull;
|
||||
ok = match( "ull", 3 );
|
||||
break;
|
||||
case ',':
|
||||
token.type_ = tokenArraySeparator;
|
||||
break;
|
||||
case ':':
|
||||
token.type_ = tokenMemberSeparator;
|
||||
break;
|
||||
case 0:
|
||||
token.type_ = tokenEndOfStream;
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if ( !ok )
|
||||
token.type_ = tokenError;
|
||||
token.end_ = current_;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Reader::skipSpaces()
|
||||
{
|
||||
while ( current_ != end_ )
|
||||
{
|
||||
Char c = *current_;
|
||||
if ( c == ' ' || c == '\t' || c == '\r' || c == '\n' )
|
||||
++current_;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::match( Location pattern,
|
||||
int patternLength )
|
||||
{
|
||||
if ( end_ - current_ < patternLength )
|
||||
return false;
|
||||
int index = patternLength;
|
||||
while ( index-- )
|
||||
if ( current_[index] != pattern[index] )
|
||||
return false;
|
||||
current_ += patternLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readComment()
|
||||
{
|
||||
Location commentBegin = current_ - 1;
|
||||
Char c = getNextChar();
|
||||
bool successful = false;
|
||||
if ( c == '*' )
|
||||
successful = readCStyleComment();
|
||||
else if ( c == '/' )
|
||||
successful = readCppStyleComment();
|
||||
if ( !successful )
|
||||
return false;
|
||||
|
||||
if ( collectComments_ )
|
||||
{
|
||||
CommentPlacement placement = commentBefore;
|
||||
if ( lastValueEnd_ && !containsNewLine( lastValueEnd_, commentBegin ) )
|
||||
{
|
||||
if ( c != '*' || !containsNewLine( commentBegin, current_ ) )
|
||||
placement = commentAfterOnSameLine;
|
||||
}
|
||||
|
||||
addComment( commentBegin, current_, placement );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Reader::addComment( Location begin,
|
||||
Location end,
|
||||
CommentPlacement placement )
|
||||
{
|
||||
assert( collectComments_ );
|
||||
if ( placement == commentAfterOnSameLine )
|
||||
{
|
||||
assert( lastValue_ != 0 );
|
||||
lastValue_->setComment( std::string( begin, end ), placement );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !commentsBefore_.empty() )
|
||||
commentsBefore_ += "\n";
|
||||
commentsBefore_ += std::string( begin, end );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readCStyleComment()
|
||||
{
|
||||
while ( current_ != end_ )
|
||||
{
|
||||
Char c = getNextChar();
|
||||
if ( c == '*' && *current_ == '/' )
|
||||
break;
|
||||
}
|
||||
return getNextChar() == '/';
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readCppStyleComment()
|
||||
{
|
||||
while ( current_ != end_ )
|
||||
{
|
||||
Char c = getNextChar();
|
||||
if ( c == '\r' || c == '\n' )
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Reader::readNumber()
|
||||
{
|
||||
while ( current_ != end_ )
|
||||
{
|
||||
if ( !(*current_ >= '0' && *current_ <= '9') &&
|
||||
!in( *current_, '.', 'e', 'E', '+', '-' ) )
|
||||
break;
|
||||
++current_;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Reader::readString()
|
||||
{
|
||||
Char c = 0;
|
||||
while ( current_ != end_ )
|
||||
{
|
||||
c = getNextChar();
|
||||
if ( c == '\\' )
|
||||
getNextChar();
|
||||
else if ( c == '"' )
|
||||
break;
|
||||
}
|
||||
return c == '"';
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readObject( Token &tokenStart )
|
||||
{
|
||||
Token tokenName;
|
||||
std::string name;
|
||||
currentValue() = Value( objectValue );
|
||||
while ( readToken( tokenName ) )
|
||||
{
|
||||
bool initialTokenOk = true;
|
||||
while ( tokenName.type_ == tokenComment && initialTokenOk )
|
||||
initialTokenOk = readToken( tokenName );
|
||||
if ( !initialTokenOk )
|
||||
break;
|
||||
if ( tokenName.type_ == tokenObjectEnd && name.empty() ) // empty object
|
||||
return true;
|
||||
if ( tokenName.type_ != tokenString )
|
||||
break;
|
||||
|
||||
name = "";
|
||||
if ( !decodeString( tokenName, name ) )
|
||||
return recoverFromError( tokenObjectEnd );
|
||||
|
||||
Token colon;
|
||||
if ( !readToken( colon ) || colon.type_ != tokenMemberSeparator )
|
||||
{
|
||||
return addErrorAndRecover( "Missing ':' after object member name",
|
||||
colon,
|
||||
tokenObjectEnd );
|
||||
}
|
||||
Value &value = currentValue()[ name ];
|
||||
nodes_.push( &value );
|
||||
bool ok = readValue();
|
||||
nodes_.pop();
|
||||
if ( !ok ) // error already set
|
||||
return recoverFromError( tokenObjectEnd );
|
||||
|
||||
Token comma;
|
||||
if ( !readToken( comma )
|
||||
|| ( comma.type_ != tokenObjectEnd &&
|
||||
comma.type_ != tokenArraySeparator &&
|
||||
comma.type_ != tokenComment ) )
|
||||
{
|
||||
return addErrorAndRecover( "Missing ',' or '}' in object declaration",
|
||||
comma,
|
||||
tokenObjectEnd );
|
||||
}
|
||||
bool finalizeTokenOk = true;
|
||||
while ( comma.type_ == tokenComment &&
|
||||
finalizeTokenOk )
|
||||
finalizeTokenOk = readToken( comma );
|
||||
if ( comma.type_ == tokenObjectEnd )
|
||||
return true;
|
||||
}
|
||||
return addErrorAndRecover( "Missing '}' or object member name",
|
||||
tokenName,
|
||||
tokenObjectEnd );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::readArray( Token &tokenStart )
|
||||
{
|
||||
currentValue() = Value( arrayValue );
|
||||
skipSpaces();
|
||||
if ( *current_ == ']' ) // empty array
|
||||
{
|
||||
Token endArray;
|
||||
readToken( endArray );
|
||||
return true;
|
||||
}
|
||||
int index = 0;
|
||||
while ( true )
|
||||
{
|
||||
Value &value = currentValue()[ index++ ];
|
||||
nodes_.push( &value );
|
||||
bool ok = readValue();
|
||||
nodes_.pop();
|
||||
if ( !ok ) // error already set
|
||||
return recoverFromError( tokenArrayEnd );
|
||||
|
||||
Token token;
|
||||
// Accept Comment after last item in the array.
|
||||
ok = readToken( token );
|
||||
while ( token.type_ == tokenComment && ok )
|
||||
{
|
||||
ok = readToken( token );
|
||||
}
|
||||
bool badTokenType = ( token.type_ == tokenArraySeparator &&
|
||||
token.type_ == tokenArrayEnd );
|
||||
if ( !ok || badTokenType )
|
||||
{
|
||||
return addErrorAndRecover( "Missing ',' or ']' in array declaration",
|
||||
token,
|
||||
tokenArrayEnd );
|
||||
}
|
||||
if ( token.type_ == tokenArrayEnd )
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::decodeNumber( Token &token )
|
||||
{
|
||||
bool isDouble = false;
|
||||
for ( Location inspect = token.start_; inspect != token.end_; ++inspect )
|
||||
{
|
||||
isDouble = isDouble
|
||||
|| in( *inspect, '.', 'e', 'E', '+' )
|
||||
|| ( *inspect == '-' && inspect != token.start_ );
|
||||
}
|
||||
if ( isDouble )
|
||||
return decodeDouble( token );
|
||||
Location current = token.start_;
|
||||
bool isNegative = *current == '-';
|
||||
if ( isNegative )
|
||||
++current;
|
||||
Value::UInt threshold = (isNegative ? Value::UInt(-Value::minInt)
|
||||
: Value::maxUInt) / 10;
|
||||
Value::UInt value = 0;
|
||||
while ( current < token.end_ )
|
||||
{
|
||||
Char c = *current++;
|
||||
if ( c < '0' || c > '9' )
|
||||
return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
|
||||
if ( value >= threshold )
|
||||
return decodeDouble( token );
|
||||
value = value * 10 + Value::UInt(c - '0');
|
||||
}
|
||||
if ( isNegative )
|
||||
currentValue() = -Value::Int( value );
|
||||
else if ( value <= Value::UInt(Value::maxInt) )
|
||||
currentValue() = Value::Int( value );
|
||||
else
|
||||
currentValue() = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::decodeDouble( Token &token )
|
||||
{
|
||||
double value = 0;
|
||||
const int bufferSize = 32;
|
||||
int count;
|
||||
int length = int(token.end_ - token.start_);
|
||||
if ( length <= bufferSize )
|
||||
{
|
||||
Char buffer[bufferSize];
|
||||
memcpy( buffer, token.start_, length );
|
||||
buffer[length] = 0;
|
||||
count = sscanf( buffer, "%lf", &value );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string buffer( token.start_, token.end_ );
|
||||
count = sscanf( buffer.c_str(), "%lf", &value );
|
||||
}
|
||||
|
||||
if ( count != 1 )
|
||||
return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
|
||||
currentValue() = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::decodeString( Token &token )
|
||||
{
|
||||
std::string decoded;
|
||||
if ( !decodeString( token, decoded ) )
|
||||
return false;
|
||||
currentValue() = decoded;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::decodeString( Token &token, std::string &decoded )
|
||||
{
|
||||
decoded.reserve( token.end_ - token.start_ - 2 );
|
||||
Location current = token.start_ + 1; // skip '"'
|
||||
Location end = token.end_ - 1; // do not include '"'
|
||||
while ( current != end )
|
||||
{
|
||||
Char c = *current++;
|
||||
if ( c == '"' )
|
||||
break;
|
||||
else if ( c == '\\' )
|
||||
{
|
||||
if ( current == end )
|
||||
return addError( "Empty escape sequence in string", token, current );
|
||||
Char escape = *current++;
|
||||
switch ( escape )
|
||||
{
|
||||
case '"': decoded += '"'; break;
|
||||
case '/': decoded += '/'; break;
|
||||
case '\\': decoded += '\\'; break;
|
||||
case 'b': decoded += '\b'; break;
|
||||
case 'f': decoded += '\f'; break;
|
||||
case 'n': decoded += '\n'; break;
|
||||
case 'r': decoded += '\r'; break;
|
||||
case 't': decoded += '\t'; break;
|
||||
case 'u':
|
||||
{
|
||||
unsigned int unicode;
|
||||
if ( !decodeUnicodeCodePoint( token, current, end, unicode ) )
|
||||
return false;
|
||||
decoded += codePointToUTF8(unicode);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return addError( "Bad escape sequence in string", token, current );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded += c;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Reader::decodeUnicodeCodePoint( Token &token,
|
||||
Location ¤t,
|
||||
Location end,
|
||||
unsigned int &unicode )
|
||||
{
|
||||
|
||||
if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) )
|
||||
return false;
|
||||
if (unicode >= 0xD800 && unicode <= 0xDBFF)
|
||||
{
|
||||
// surrogate pairs
|
||||
if (end - current < 6)
|
||||
return addError( "additional six characters expected to parse unicode surrogate pair.", token, current );
|
||||
unsigned int surrogatePair;
|
||||
if (*(current++) == '\\' && *(current++)== 'u')
|
||||
{
|
||||
if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair ))
|
||||
{
|
||||
unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Reader::decodeUnicodeEscapeSequence( Token &token,
|
||||
Location ¤t,
|
||||
Location end,
|
||||
unsigned int &unicode )
|
||||
{
|
||||
if ( end - current < 4 )
|
||||
return addError( "Bad unicode escape sequence in string: four digits expected.", token, current );
|
||||
unicode = 0;
|
||||
for ( int index =0; index < 4; ++index )
|
||||
{
|
||||
Char c = *current++;
|
||||
unicode *= 16;
|
||||
if ( c >= '0' && c <= '9' )
|
||||
unicode += c - '0';
|
||||
else if ( c >= 'a' && c <= 'f' )
|
||||
unicode += c - 'a' + 10;
|
||||
else if ( c >= 'A' && c <= 'F' )
|
||||
unicode += c - 'A' + 10;
|
||||
else
|
||||
return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::addError( const std::string &message,
|
||||
Token &token,
|
||||
Location extra )
|
||||
{
|
||||
ErrorInfo info;
|
||||
info.token_ = token;
|
||||
info.message_ = message;
|
||||
info.extra_ = extra;
|
||||
errors_.push_back( info );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::recoverFromError( TokenType skipUntilToken )
|
||||
{
|
||||
int errorCount = int(errors_.size());
|
||||
Token skip;
|
||||
while ( true )
|
||||
{
|
||||
if ( !readToken(skip) )
|
||||
errors_.resize( errorCount ); // discard errors caused by recovery
|
||||
if ( skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream )
|
||||
break;
|
||||
}
|
||||
errors_.resize( errorCount );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Reader::addErrorAndRecover( const std::string &message,
|
||||
Token &token,
|
||||
TokenType skipUntilToken )
|
||||
{
|
||||
addError( message, token );
|
||||
return recoverFromError( skipUntilToken );
|
||||
}
|
||||
|
||||
|
||||
Value &
|
||||
Reader::currentValue()
|
||||
{
|
||||
return *(nodes_.top());
|
||||
}
|
||||
|
||||
|
||||
Reader::Char
|
||||
Reader::getNextChar()
|
||||
{
|
||||
if ( current_ == end_ )
|
||||
return 0;
|
||||
return *current_++;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Reader::getLocationLineAndColumn( Location location,
|
||||
int &line,
|
||||
int &column ) const
|
||||
{
|
||||
Location current = begin_;
|
||||
Location lastLineStart = current;
|
||||
line = 0;
|
||||
while ( current < location && current != end_ )
|
||||
{
|
||||
Char c = *current++;
|
||||
if ( c == '\r' )
|
||||
{
|
||||
if ( *current == '\n' )
|
||||
++current;
|
||||
lastLineStart = current;
|
||||
++line;
|
||||
}
|
||||
else if ( c == '\n' )
|
||||
{
|
||||
lastLineStart = current;
|
||||
++line;
|
||||
}
|
||||
}
|
||||
// column & line start at 1
|
||||
column = int(location - lastLineStart) + 1;
|
||||
++line;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
Reader::getLocationLineAndColumn( Location location ) const
|
||||
{
|
||||
int line, column;
|
||||
getLocationLineAndColumn( location, line, column );
|
||||
char buffer[18+16+16+1];
|
||||
sprintf( buffer, "Line %d, Column %d", line, column );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
Reader::getFormatedErrorMessages() const
|
||||
{
|
||||
std::string formattedMessage;
|
||||
for ( Errors::const_iterator itError = errors_.begin();
|
||||
itError != errors_.end();
|
||||
++itError )
|
||||
{
|
||||
const ErrorInfo &error = *itError;
|
||||
formattedMessage += "* " + getLocationLineAndColumn( error.token_.start_ ) + "\n";
|
||||
formattedMessage += " " + error.message_ + "\n";
|
||||
if ( error.extra_ )
|
||||
formattedMessage += "See " + getLocationLineAndColumn( error.extra_ ) + " for detail.\n";
|
||||
}
|
||||
return formattedMessage;
|
||||
}
|
||||
|
||||
|
||||
std::istream& operator>>( std::istream &sin, Value &root )
|
||||
{
|
||||
Json::Reader reader;
|
||||
bool ok = reader.parse(sin, root, true);
|
||||
//JSON_ASSERT( ok );
|
||||
if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
|
||||
return sin;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Json
|
File diff suppressed because it is too large
Load Diff
@ -1,292 +0,0 @@
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueIteratorBase
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueIteratorBase::ValueIteratorBase()
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
: current_()
|
||||
, isNull_( true )
|
||||
{
|
||||
}
|
||||
#else
|
||||
: isArray_( true )
|
||||
, isNull_( true )
|
||||
{
|
||||
iterator_.array_ = ValueInternalArray::IteratorState();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator ¤t )
|
||||
: current_( current )
|
||||
, isNull_( false )
|
||||
{
|
||||
}
|
||||
#else
|
||||
ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )
|
||||
: isArray_( true )
|
||||
{
|
||||
iterator_.array_ = state;
|
||||
}
|
||||
|
||||
|
||||
ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )
|
||||
: isArray_( false )
|
||||
{
|
||||
iterator_.map_ = state;
|
||||
}
|
||||
#endif
|
||||
|
||||
Value &
|
||||
ValueIteratorBase::deref() const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
return current_->second;
|
||||
#else
|
||||
if ( isArray_ )
|
||||
return ValueInternalArray::dereference( iterator_.array_ );
|
||||
return ValueInternalMap::value( iterator_.map_ );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueIteratorBase::increment()
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
++current_;
|
||||
#else
|
||||
if ( isArray_ )
|
||||
ValueInternalArray::increment( iterator_.array_ );
|
||||
ValueInternalMap::increment( iterator_.map_ );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueIteratorBase::decrement()
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
--current_;
|
||||
#else
|
||||
if ( isArray_ )
|
||||
ValueInternalArray::decrement( iterator_.array_ );
|
||||
ValueInternalMap::decrement( iterator_.map_ );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ValueIteratorBase::difference_type
|
||||
ValueIteratorBase::computeDistance( const SelfType &other ) const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
# ifdef JSON_USE_CPPTL_SMALLMAP
|
||||
return current_ - other.current_;
|
||||
# else
|
||||
// Iterator for null value are initialized using the default
|
||||
// constructor, which initialize current_ to the default
|
||||
// std::map::iterator. As begin() and end() are two instance
|
||||
// of the default std::map::iterator, they can not be compared.
|
||||
// To allow this, we handle this comparison specifically.
|
||||
if ( isNull_ && other.isNull_ )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,
|
||||
// which is the one used by default).
|
||||
// Using a portable hand-made version for non random iterator instead:
|
||||
// return difference_type( std::distance( current_, other.current_ ) );
|
||||
difference_type myDistance = 0;
|
||||
for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )
|
||||
{
|
||||
++myDistance;
|
||||
}
|
||||
return myDistance;
|
||||
# endif
|
||||
#else
|
||||
if ( isArray_ )
|
||||
return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
|
||||
return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ValueIteratorBase::isEqual( const SelfType &other ) const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
if ( isNull_ )
|
||||
{
|
||||
return other.isNull_;
|
||||
}
|
||||
return current_ == other.current_;
|
||||
#else
|
||||
if ( isArray_ )
|
||||
return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );
|
||||
return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueIteratorBase::copy( const SelfType &other )
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
current_ = other.current_;
|
||||
#else
|
||||
if ( isArray_ )
|
||||
iterator_.array_ = other.iterator_.array_;
|
||||
iterator_.map_ = other.iterator_.map_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Value
|
||||
ValueIteratorBase::key() const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
const Value::CZString czstring = (*current_).first;
|
||||
if ( czstring.c_str() )
|
||||
{
|
||||
if ( czstring.isStaticString() )
|
||||
return Value( StaticString( czstring.c_str() ) );
|
||||
return Value( czstring.c_str() );
|
||||
}
|
||||
return Value( czstring.index() );
|
||||
#else
|
||||
if ( isArray_ )
|
||||
return Value( ValueInternalArray::indexOf( iterator_.array_ ) );
|
||||
bool isStatic;
|
||||
const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );
|
||||
if ( isStatic )
|
||||
return Value( StaticString( memberName ) );
|
||||
return Value( memberName );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
UInt
|
||||
ValueIteratorBase::index() const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
const Value::CZString czstring = (*current_).first;
|
||||
if ( !czstring.c_str() )
|
||||
return czstring.index();
|
||||
return Value::UInt( -1 );
|
||||
#else
|
||||
if ( isArray_ )
|
||||
return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );
|
||||
return Value::UInt( -1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
ValueIteratorBase::memberName() const
|
||||
{
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
const char *name = (*current_).first.c_str();
|
||||
return name ? name : "";
|
||||
#else
|
||||
if ( !isArray_ )
|
||||
return ValueInternalMap::key( iterator_.map_ );
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueConstIterator
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueConstIterator::ValueConstIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator ¤t )
|
||||
: ValueIteratorBase( current )
|
||||
{
|
||||
}
|
||||
#else
|
||||
ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )
|
||||
: ValueIteratorBase( state )
|
||||
{
|
||||
}
|
||||
|
||||
ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )
|
||||
: ValueIteratorBase( state )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
ValueConstIterator &
|
||||
ValueConstIterator::operator =( const ValueIteratorBase &other )
|
||||
{
|
||||
copy( other );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// class ValueIterator
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
ValueIterator::ValueIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||
ValueIterator::ValueIterator( const Value::ObjectValues::iterator ¤t )
|
||||
: ValueIteratorBase( current )
|
||||
{
|
||||
}
|
||||
#else
|
||||
ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )
|
||||
: ValueIteratorBase( state )
|
||||
{
|
||||
}
|
||||
|
||||
ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )
|
||||
: ValueIteratorBase( state )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
ValueIterator::ValueIterator( const ValueConstIterator &other )
|
||||
: ValueIteratorBase( other )
|
||||
{
|
||||
}
|
||||
|
||||
ValueIterator::ValueIterator( const ValueIterator &other )
|
||||
: ValueIteratorBase( other )
|
||||
{
|
||||
}
|
||||
|
||||
ValueIterator &
|
||||
ValueIterator::operator =( const SelfType &other )
|
||||
{
|
||||
copy( other );
|
||||
return *this;
|
||||
}
|
@ -1,829 +0,0 @@
|
||||
#include <json/writer.h>
|
||||
#include <utility>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#if _MSC_VER >= 1400 // VC++ 8.0
|
||||
#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated.
|
||||
#endif
|
||||
|
||||
namespace Json {
|
||||
|
||||
static bool isControlCharacter(char ch)
|
||||
{
|
||||
return ch > 0 && ch <= 0x1F;
|
||||
}
|
||||
|
||||
static bool containsControlCharacter( const char* str )
|
||||
{
|
||||
while ( *str )
|
||||
{
|
||||
if ( isControlCharacter( *(str++) ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static void uintToString( unsigned int value,
|
||||
char *¤t )
|
||||
{
|
||||
*--current = 0;
|
||||
do
|
||||
{
|
||||
*--current = (value % 10) + '0';
|
||||
value /= 10;
|
||||
}
|
||||
while ( value != 0 );
|
||||
}
|
||||
|
||||
std::string valueToString( Int value )
|
||||
{
|
||||
char buffer[32];
|
||||
char *current = buffer + sizeof(buffer);
|
||||
bool isNegative = value < 0;
|
||||
if ( isNegative )
|
||||
value = -value;
|
||||
uintToString( UInt(value), current );
|
||||
if ( isNegative )
|
||||
*--current = '-';
|
||||
assert( current >= buffer );
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
std::string valueToString( UInt value )
|
||||
{
|
||||
char buffer[32];
|
||||
char *current = buffer + sizeof(buffer);
|
||||
uintToString( value, current );
|
||||
assert( current >= buffer );
|
||||
return current;
|
||||
}
|
||||
|
||||
std::string valueToString( double value )
|
||||
{
|
||||
char buffer[32];
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005 to avoid warning.
|
||||
sprintf_s(buffer, sizeof(buffer), "%#.16g", value);
|
||||
#else
|
||||
sprintf(buffer, "%#.16g", value);
|
||||
#endif
|
||||
char* ch = buffer + strlen(buffer) - 1;
|
||||
if (*ch != '0') return buffer; // nothing to truncate, so save time
|
||||
while(ch > buffer && *ch == '0'){
|
||||
--ch;
|
||||
}
|
||||
char* last_nonzero = ch;
|
||||
while(ch >= buffer){
|
||||
switch(*ch){
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
--ch;
|
||||
continue;
|
||||
case '.':
|
||||
// Truncate zeroes to save bytes in output, but keep one.
|
||||
*(last_nonzero+2) = '\0';
|
||||
return buffer;
|
||||
default:
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
std::string valueToString( bool value )
|
||||
{
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
|
||||
std::string valueToQuotedString( const char *value )
|
||||
{
|
||||
// Not sure how to handle unicode...
|
||||
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value ))
|
||||
return std::string("\"") + value + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to std::string is not efficient, but this should be rare.
|
||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
||||
unsigned maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
|
||||
std::string result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
for (const char* c=value; *c != 0; ++c)
|
||||
{
|
||||
switch(*c)
|
||||
{
|
||||
case '\"':
|
||||
result += "\\\"";
|
||||
break;
|
||||
case '\\':
|
||||
result += "\\\\";
|
||||
break;
|
||||
case '\b':
|
||||
result += "\\b";
|
||||
break;
|
||||
case '\f':
|
||||
result += "\\f";
|
||||
break;
|
||||
case '\n':
|
||||
result += "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
result += "\\r";
|
||||
break;
|
||||
case '\t':
|
||||
result += "\\t";
|
||||
break;
|
||||
//case '/':
|
||||
// Even though \/ is considered a legal escape in JSON, a bare
|
||||
// slash is also legal, so I see no reason to escape it.
|
||||
// (I hope I am not misunderstanding something.
|
||||
// blep notes: actually escaping \/ may be useful in javascript to avoid </
|
||||
// sequence.
|
||||
// Should add a flag to allow this compatibility mode and prevent this
|
||||
// sequence from occurring.
|
||||
default:
|
||||
if ( isControlCharacter( *c ) )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*c);
|
||||
result += oss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += *c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
result += "\"";
|
||||
return result;
|
||||
}
|
||||
|
||||
// Class Writer
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
Writer::~Writer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Class FastWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
FastWriter::FastWriter()
|
||||
: yamlCompatiblityEnabled_( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FastWriter::enableYAMLCompatibility()
|
||||
{
|
||||
yamlCompatiblityEnabled_ = true;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
FastWriter::write( const Value &root )
|
||||
{
|
||||
document_ = "";
|
||||
writeValue( root );
|
||||
document_ += "\n";
|
||||
return document_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FastWriter::writeValue( const Value &value )
|
||||
{
|
||||
switch ( value.type() )
|
||||
{
|
||||
case nullValue:
|
||||
document_ += "null";
|
||||
break;
|
||||
case intValue:
|
||||
document_ += valueToString( value.asInt() );
|
||||
break;
|
||||
case uintValue:
|
||||
document_ += valueToString( value.asUInt() );
|
||||
break;
|
||||
case realValue:
|
||||
document_ += valueToString( value.asDouble() );
|
||||
break;
|
||||
case stringValue:
|
||||
document_ += valueToQuotedString( value.asCString() );
|
||||
break;
|
||||
case booleanValue:
|
||||
document_ += valueToString( value.asBool() );
|
||||
break;
|
||||
case arrayValue:
|
||||
{
|
||||
document_ += "[";
|
||||
int size = value.size();
|
||||
for ( int index =0; index < size; ++index )
|
||||
{
|
||||
if ( index > 0 )
|
||||
document_ += ",";
|
||||
writeValue( value[index] );
|
||||
}
|
||||
document_ += "]";
|
||||
}
|
||||
break;
|
||||
case objectValue:
|
||||
{
|
||||
Value::Members members( value.getMemberNames() );
|
||||
document_ += "{";
|
||||
for ( Value::Members::iterator it = members.begin();
|
||||
it != members.end();
|
||||
++it )
|
||||
{
|
||||
const std::string &name = *it;
|
||||
if ( it != members.begin() )
|
||||
document_ += ",";
|
||||
document_ += valueToQuotedString( name.c_str() );
|
||||
document_ += yamlCompatiblityEnabled_ ? ": "
|
||||
: ":";
|
||||
writeValue( value[name] );
|
||||
}
|
||||
document_ += "}";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Class StyledWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
StyledWriter::StyledWriter()
|
||||
: rightMargin_( 74 )
|
||||
, indentSize_( 3 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
StyledWriter::write( const Value &root )
|
||||
{
|
||||
document_ = "";
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
writeCommentBeforeValue( root );
|
||||
writeValue( root );
|
||||
writeCommentAfterValueOnSameLine( root );
|
||||
document_ += "\n";
|
||||
return document_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeValue( const Value &value )
|
||||
{
|
||||
switch ( value.type() )
|
||||
{
|
||||
case nullValue:
|
||||
pushValue( "null" );
|
||||
break;
|
||||
case intValue:
|
||||
pushValue( valueToString( value.asInt() ) );
|
||||
break;
|
||||
case uintValue:
|
||||
pushValue( valueToString( value.asUInt() ) );
|
||||
break;
|
||||
case realValue:
|
||||
pushValue( valueToString( value.asDouble() ) );
|
||||
break;
|
||||
case stringValue:
|
||||
pushValue( valueToQuotedString( value.asCString() ) );
|
||||
break;
|
||||
case booleanValue:
|
||||
pushValue( valueToString( value.asBool() ) );
|
||||
break;
|
||||
case arrayValue:
|
||||
writeArrayValue( value);
|
||||
break;
|
||||
case objectValue:
|
||||
{
|
||||
Value::Members members( value.getMemberNames() );
|
||||
if ( members.empty() )
|
||||
pushValue( "{}" );
|
||||
else
|
||||
{
|
||||
writeWithIndent( "{" );
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
while ( true )
|
||||
{
|
||||
const std::string &name = *it;
|
||||
const Value &childValue = value[name];
|
||||
writeCommentBeforeValue( childValue );
|
||||
writeWithIndent( valueToQuotedString( name.c_str() ) );
|
||||
document_ += " : ";
|
||||
writeValue( childValue );
|
||||
if ( ++it == members.end() )
|
||||
{
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
break;
|
||||
}
|
||||
document_ += ",";
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
}
|
||||
unindent();
|
||||
writeWithIndent( "}" );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeArrayValue( const Value &value )
|
||||
{
|
||||
unsigned size = value.size();
|
||||
if ( size == 0 )
|
||||
pushValue( "[]" );
|
||||
else
|
||||
{
|
||||
bool isArrayMultiLine = isMultineArray( value );
|
||||
if ( isArrayMultiLine )
|
||||
{
|
||||
writeWithIndent( "[" );
|
||||
indent();
|
||||
bool hasChildValue = !childValues_.empty();
|
||||
unsigned index =0;
|
||||
while ( true )
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
writeCommentBeforeValue( childValue );
|
||||
if ( hasChildValue )
|
||||
writeWithIndent( childValues_[index] );
|
||||
else
|
||||
{
|
||||
writeIndent();
|
||||
writeValue( childValue );
|
||||
}
|
||||
if ( ++index == size )
|
||||
{
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
break;
|
||||
}
|
||||
document_ += ",";
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
}
|
||||
unindent();
|
||||
writeWithIndent( "]" );
|
||||
}
|
||||
else // output on a single line
|
||||
{
|
||||
assert( childValues_.size() == size );
|
||||
document_ += "[ ";
|
||||
for ( unsigned index =0; index < size; ++index )
|
||||
{
|
||||
if ( index > 0 )
|
||||
document_ += ", ";
|
||||
document_ += childValues_[index];
|
||||
}
|
||||
document_ += " ]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StyledWriter::isMultineArray( const Value &value )
|
||||
{
|
||||
int size = value.size();
|
||||
bool isMultiLine = size*3 >= rightMargin_ ;
|
||||
childValues_.clear();
|
||||
for ( int index =0; index < size && !isMultiLine; ++index )
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
isMultiLine = isMultiLine ||
|
||||
( (childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0 );
|
||||
}
|
||||
if ( !isMultiLine ) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve( size );
|
||||
addChildValues_ = true;
|
||||
int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
|
||||
for ( int index =0; index < size && !isMultiLine; ++index )
|
||||
{
|
||||
writeValue( value[index] );
|
||||
lineLength += int( childValues_[index].length() );
|
||||
isMultiLine = isMultiLine && hasCommentForValue( value[index] );
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
}
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::pushValue( const std::string &value )
|
||||
{
|
||||
if ( addChildValues_ )
|
||||
childValues_.push_back( value );
|
||||
else
|
||||
document_ += value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeIndent()
|
||||
{
|
||||
if ( !document_.empty() )
|
||||
{
|
||||
char last = document_[document_.length()-1];
|
||||
if ( last == ' ' ) // already indented
|
||||
return;
|
||||
if ( last != '\n' ) // Comments may add new-line
|
||||
document_ += '\n';
|
||||
}
|
||||
document_ += indentString_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeWithIndent( const std::string &value )
|
||||
{
|
||||
writeIndent();
|
||||
document_ += value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::indent()
|
||||
{
|
||||
indentString_ += std::string( indentSize_, ' ' );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::unindent()
|
||||
{
|
||||
assert( int(indentString_.size()) >= indentSize_ );
|
||||
indentString_.resize( indentString_.size() - indentSize_ );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeCommentBeforeValue( const Value &root )
|
||||
{
|
||||
if ( !root.hasComment( commentBefore ) )
|
||||
return;
|
||||
document_ += normalizeEOL( root.getComment( commentBefore ) );
|
||||
document_ += "\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledWriter::writeCommentAfterValueOnSameLine( const Value &root )
|
||||
{
|
||||
if ( root.hasComment( commentAfterOnSameLine ) )
|
||||
document_ += " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
|
||||
|
||||
if ( root.hasComment( commentAfter ) )
|
||||
{
|
||||
document_ += "\n";
|
||||
document_ += normalizeEOL( root.getComment( commentAfter ) );
|
||||
document_ += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StyledWriter::hasCommentForValue( const Value &value )
|
||||
{
|
||||
return value.hasComment( commentBefore )
|
||||
|| value.hasComment( commentAfterOnSameLine )
|
||||
|| value.hasComment( commentAfter );
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
StyledWriter::normalizeEOL( const std::string &text )
|
||||
{
|
||||
std::string normalized;
|
||||
normalized.reserve( text.length() );
|
||||
const char *begin = text.c_str();
|
||||
const char *end = begin + text.length();
|
||||
const char *current = begin;
|
||||
while ( current != end )
|
||||
{
|
||||
char c = *current++;
|
||||
if ( c == '\r' ) // mac or dos EOL
|
||||
{
|
||||
if ( *current == '\n' ) // convert dos EOL
|
||||
++current;
|
||||
normalized += '\n';
|
||||
}
|
||||
else // handle unix EOL & other char
|
||||
normalized += c;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
|
||||
// Class StyledStreamWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
StyledStreamWriter::StyledStreamWriter( std::string indentation )
|
||||
: document_(NULL)
|
||||
, rightMargin_( 74 )
|
||||
, indentation_( indentation )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::write( std::ostream &out, const Value &root )
|
||||
{
|
||||
document_ = &out;
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
writeCommentBeforeValue( root );
|
||||
writeValue( root );
|
||||
writeCommentAfterValueOnSameLine( root );
|
||||
*document_ << "\n";
|
||||
document_ = NULL; // Forget the stream, for safety.
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeValue( const Value &value )
|
||||
{
|
||||
switch ( value.type() )
|
||||
{
|
||||
case nullValue:
|
||||
pushValue( "null" );
|
||||
break;
|
||||
case intValue:
|
||||
pushValue( valueToString( value.asInt() ) );
|
||||
break;
|
||||
case uintValue:
|
||||
pushValue( valueToString( value.asUInt() ) );
|
||||
break;
|
||||
case realValue:
|
||||
pushValue( valueToString( value.asDouble() ) );
|
||||
break;
|
||||
case stringValue:
|
||||
pushValue( valueToQuotedString( value.asCString() ) );
|
||||
break;
|
||||
case booleanValue:
|
||||
pushValue( valueToString( value.asBool() ) );
|
||||
break;
|
||||
case arrayValue:
|
||||
writeArrayValue( value);
|
||||
break;
|
||||
case objectValue:
|
||||
{
|
||||
Value::Members members( value.getMemberNames() );
|
||||
if ( members.empty() )
|
||||
pushValue( "{}" );
|
||||
else
|
||||
{
|
||||
writeWithIndent( "{" );
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
while ( true )
|
||||
{
|
||||
const std::string &name = *it;
|
||||
const Value &childValue = value[name];
|
||||
writeCommentBeforeValue( childValue );
|
||||
writeWithIndent( valueToQuotedString( name.c_str() ) );
|
||||
*document_ << " : ";
|
||||
writeValue( childValue );
|
||||
if ( ++it == members.end() )
|
||||
{
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
break;
|
||||
}
|
||||
*document_ << ",";
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
}
|
||||
unindent();
|
||||
writeWithIndent( "}" );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeArrayValue( const Value &value )
|
||||
{
|
||||
unsigned size = value.size();
|
||||
if ( size == 0 )
|
||||
pushValue( "[]" );
|
||||
else
|
||||
{
|
||||
bool isArrayMultiLine = isMultineArray( value );
|
||||
if ( isArrayMultiLine )
|
||||
{
|
||||
writeWithIndent( "[" );
|
||||
indent();
|
||||
bool hasChildValue = !childValues_.empty();
|
||||
unsigned index =0;
|
||||
while ( true )
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
writeCommentBeforeValue( childValue );
|
||||
if ( hasChildValue )
|
||||
writeWithIndent( childValues_[index] );
|
||||
else
|
||||
{
|
||||
writeIndent();
|
||||
writeValue( childValue );
|
||||
}
|
||||
if ( ++index == size )
|
||||
{
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
break;
|
||||
}
|
||||
*document_ << ",";
|
||||
writeCommentAfterValueOnSameLine( childValue );
|
||||
}
|
||||
unindent();
|
||||
writeWithIndent( "]" );
|
||||
}
|
||||
else // output on a single line
|
||||
{
|
||||
assert( childValues_.size() == size );
|
||||
*document_ << "[ ";
|
||||
for ( unsigned index =0; index < size; ++index )
|
||||
{
|
||||
if ( index > 0 )
|
||||
*document_ << ", ";
|
||||
*document_ << childValues_[index];
|
||||
}
|
||||
*document_ << " ]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StyledStreamWriter::isMultineArray( const Value &value )
|
||||
{
|
||||
int size = value.size();
|
||||
bool isMultiLine = size*3 >= rightMargin_ ;
|
||||
childValues_.clear();
|
||||
for ( int index =0; index < size && !isMultiLine; ++index )
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
isMultiLine = isMultiLine ||
|
||||
( (childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0 );
|
||||
}
|
||||
if ( !isMultiLine ) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve( size );
|
||||
addChildValues_ = true;
|
||||
int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
|
||||
for ( int index =0; index < size && !isMultiLine; ++index )
|
||||
{
|
||||
writeValue( value[index] );
|
||||
lineLength += int( childValues_[index].length() );
|
||||
isMultiLine = isMultiLine && hasCommentForValue( value[index] );
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
}
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::pushValue( const std::string &value )
|
||||
{
|
||||
if ( addChildValues_ )
|
||||
childValues_.push_back( value );
|
||||
else
|
||||
*document_ << value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeIndent()
|
||||
{
|
||||
/*
|
||||
Some comments in this method would have been nice. ;-)
|
||||
|
||||
if ( !document_.empty() )
|
||||
{
|
||||
char last = document_[document_.length()-1];
|
||||
if ( last == ' ' ) // already indented
|
||||
return;
|
||||
if ( last != '\n' ) // Comments may add new-line
|
||||
*document_ << '\n';
|
||||
}
|
||||
*/
|
||||
*document_ << '\n' << indentString_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeWithIndent( const std::string &value )
|
||||
{
|
||||
writeIndent();
|
||||
*document_ << value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::indent()
|
||||
{
|
||||
indentString_ += indentation_;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::unindent()
|
||||
{
|
||||
assert( indentString_.size() >= indentation_.size() );
|
||||
indentString_.resize( indentString_.size() - indentation_.size() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeCommentBeforeValue( const Value &root )
|
||||
{
|
||||
if ( !root.hasComment( commentBefore ) )
|
||||
return;
|
||||
*document_ << normalizeEOL( root.getComment( commentBefore ) );
|
||||
*document_ << "\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
StyledStreamWriter::writeCommentAfterValueOnSameLine( const Value &root )
|
||||
{
|
||||
if ( root.hasComment( commentAfterOnSameLine ) )
|
||||
*document_ << " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
|
||||
|
||||
if ( root.hasComment( commentAfter ) )
|
||||
{
|
||||
*document_ << "\n";
|
||||
*document_ << normalizeEOL( root.getComment( commentAfter ) );
|
||||
*document_ << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
StyledStreamWriter::hasCommentForValue( const Value &value )
|
||||
{
|
||||
return value.hasComment( commentBefore )
|
||||
|| value.hasComment( commentAfterOnSameLine )
|
||||
|| value.hasComment( commentAfter );
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
StyledStreamWriter::normalizeEOL( const std::string &text )
|
||||
{
|
||||
std::string normalized;
|
||||
normalized.reserve( text.length() );
|
||||
const char *begin = text.c_str();
|
||||
const char *end = begin + text.length();
|
||||
const char *current = begin;
|
||||
while ( current != end )
|
||||
{
|
||||
char c = *current++;
|
||||
if ( c == '\r' ) // mac or dos EOL
|
||||
{
|
||||
if ( *current == '\n' ) // convert dos EOL
|
||||
++current;
|
||||
normalized += '\n';
|
||||
}
|
||||
else // handle unix EOL & other char
|
||||
normalized += c;
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<( std::ostream &sout, const Value &root )
|
||||
{
|
||||
Json::StyledStreamWriter writer;
|
||||
writer.write(sout, root);
|
||||
return sout;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Json
|
@ -1,320 +0,0 @@
|
||||
#include "plugin.h"
|
||||
#include "tokenizer.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
BOOL APIENTRY DllMain( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
SendPluginEv SendPluginEvent;
|
||||
|
||||
string g_GetSysErrMsg( void )
|
||||
{
|
||||
string strError = "Unknown";
|
||||
// Problem loading
|
||||
#ifdef _WINDOWS
|
||||
int nErrorCode = GetLastError();
|
||||
LPTSTR s;
|
||||
if ( ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, nErrorCode, 0, ( LPTSTR ) &s, 0, NULL ) )
|
||||
{
|
||||
strError = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
char szBuf[ 20 ];
|
||||
_snprintf_s( szBuf, _countof(szBuf), 19, "%d", nErrorCode );
|
||||
strError = szBuf;
|
||||
}
|
||||
#else
|
||||
char szError[80];
|
||||
if ( strerror_r( errno, szError, sizeof(szError) ) )
|
||||
{
|
||||
strError = "no description found";
|
||||
}
|
||||
else
|
||||
{
|
||||
strError = szError;
|
||||
}
|
||||
#endif
|
||||
return strError;
|
||||
}
|
||||
|
||||
void g_sleep( unsigned int mseconds )
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
Sleep( mseconds );
|
||||
#else
|
||||
usleep( mseconds * 1000 );
|
||||
#endif
|
||||
}
|
||||
|
||||
string& g_trim( string& str )
|
||||
{
|
||||
// Whitespace characters
|
||||
char whspc[] = " \t\r\n\v\f";
|
||||
|
||||
// Whack off first part
|
||||
size_t pos = str.find_first_not_of( whspc );
|
||||
|
||||
if ( pos != string::npos )
|
||||
str.replace( 0, pos, "" );
|
||||
|
||||
// Whack off trailing stuff
|
||||
pos = str.find_last_not_of( whspc );
|
||||
|
||||
if ( pos != string::npos )
|
||||
str.replace( pos + 1, str.length() - pos, "" );
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void g_tokenize( const string& str, const string& delimiters, vector<string>& tokens )
|
||||
{
|
||||
tokenize( str, tokens, delimiters );
|
||||
}
|
||||
|
||||
char* SetEventFunc( SendPluginEv funcPtr )
|
||||
{
|
||||
static char * szObjList = onGetObjList();
|
||||
SendPluginEvent = funcPtr;
|
||||
return szObjList;
|
||||
}
|
||||
|
||||
|
||||
const int nMAXSIZE = 512;
|
||||
char* g_pszRetVal = NULL;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Map from an object Id to an object instance
|
||||
//-----------------------------------------------------------
|
||||
typedef std::map<string, JSExt*> StringToJExt_T;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Map from a browser context to an id mapping
|
||||
//-----------------------------------------------------------
|
||||
typedef std::map<void*, StringToJExt_T*> VoidToMap_T;
|
||||
|
||||
VoidToMap_T g_context2Map;
|
||||
|
||||
class GlobalSharedModule
|
||||
{
|
||||
|
||||
public:
|
||||
GlobalSharedModule( void )
|
||||
{
|
||||
g_pszRetVal = new char[ nMAXSIZE ];
|
||||
}
|
||||
|
||||
~GlobalSharedModule()
|
||||
{
|
||||
delete [] g_pszRetVal;
|
||||
|
||||
VoidToMap_T::iterator posMaps;
|
||||
|
||||
for ( posMaps = g_context2Map.begin(); posMaps != g_context2Map.end(); ++posMaps )
|
||||
{
|
||||
StringToJExt_T& id2Obj = *posMaps->second;
|
||||
StringToJExt_T::iterator posMap;
|
||||
|
||||
for ( posMap = id2Obj.begin(); posMap != id2Obj.end(); ++posMap )
|
||||
{
|
||||
JSExt* pJSExt = posMap->second;
|
||||
|
||||
if ( pJSExt->CanDelete() )
|
||||
{
|
||||
delete pJSExt;
|
||||
}
|
||||
}
|
||||
|
||||
id2Obj.erase( id2Obj.begin(), id2Obj.end() );
|
||||
}
|
||||
|
||||
g_context2Map.erase( g_context2Map.begin(), g_context2Map.end() );
|
||||
}
|
||||
};
|
||||
|
||||
GlobalSharedModule g_sharedModule;
|
||||
|
||||
char* g_str2global( const string& strRetVal )
|
||||
{
|
||||
int nLen = strRetVal.size();
|
||||
|
||||
if ( nLen >= nMAXSIZE )
|
||||
{
|
||||
delete [] g_pszRetVal;
|
||||
g_pszRetVal = new char[ nLen + 1 ];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// To minimaize the number of memory reallocations, the assumption
|
||||
// is that in most times this will be the case
|
||||
delete [] g_pszRetVal;
|
||||
g_pszRetVal = new char[ nMAXSIZE ];
|
||||
}
|
||||
|
||||
strcpy( g_pszRetVal, strRetVal.c_str() );
|
||||
return g_pszRetVal;
|
||||
}
|
||||
|
||||
bool g_unregisterObject( const string& strObjId, void* pContext )
|
||||
{
|
||||
// Called by the plugin extension implementation
|
||||
// if the extension handles the deletion of its object
|
||||
|
||||
StringToJExt_T * pID2Obj = NULL;
|
||||
|
||||
VoidToMap_T::iterator iter = g_context2Map.find( pContext );
|
||||
|
||||
if ( iter != g_context2Map.end() )
|
||||
{
|
||||
pID2Obj = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
StringToJExt_T& mapID2Obj = *pID2Obj;
|
||||
|
||||
StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
|
||||
|
||||
if ( r == mapID2Obj.end() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mapID2Obj.erase( strObjId );
|
||||
return true;
|
||||
}
|
||||
|
||||
char* InvokeFunction( const char* szCommand, void* pContext )
|
||||
{
|
||||
StringToJExt_T * pID2Obj = NULL;
|
||||
|
||||
VoidToMap_T::iterator iter = g_context2Map.find( pContext );
|
||||
|
||||
if ( iter != g_context2Map.end() )
|
||||
{
|
||||
pID2Obj = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
pID2Obj = new StringToJExt_T;
|
||||
g_context2Map[ pContext ] = pID2Obj;
|
||||
}
|
||||
|
||||
StringToJExt_T& mapID2Obj = *pID2Obj;
|
||||
|
||||
string strFullCommand = szCommand;
|
||||
vector<string> arParams;
|
||||
g_tokenize( strFullCommand, " ", arParams );
|
||||
string strCommand = arParams[ 0 ];
|
||||
string strRetVal = szERROR;
|
||||
|
||||
if ( strCommand == szCREATE )
|
||||
{
|
||||
string strClassName = arParams[ 1 ];
|
||||
string strObjId = arParams[ 2 ];
|
||||
|
||||
StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
|
||||
|
||||
if ( r != mapID2Obj.end() )
|
||||
{
|
||||
strRetVal += strObjId;
|
||||
strRetVal += " :Object already exists.";
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
JSExt* pJSExt = onCreateObject( strClassName, strObjId );
|
||||
|
||||
if ( pJSExt == NULL )
|
||||
{
|
||||
strRetVal += strObjId;
|
||||
strRetVal += " :Unknown object type ";
|
||||
strRetVal += strClassName;
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
pJSExt->m_pContext = pContext;
|
||||
mapID2Obj[ strObjId ] = pJSExt;
|
||||
|
||||
strRetVal = szOK;
|
||||
strRetVal += strObjId;
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
else
|
||||
if ( strCommand == szINVOKE )
|
||||
{
|
||||
string strObjId = arParams[ 1 ];
|
||||
string strMethod = arParams[ 2 ];
|
||||
|
||||
StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
|
||||
|
||||
if ( r == mapID2Obj.end() )
|
||||
{
|
||||
strRetVal += strObjId;
|
||||
strRetVal += " :No object found for id.";
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
JSExt* pJSExt = r->second;
|
||||
|
||||
size_t nLoc = strFullCommand.find( strObjId );
|
||||
|
||||
if ( nLoc == string::npos )
|
||||
{
|
||||
strRetVal += strObjId;
|
||||
strRetVal += " :Internal InvokeMethod error.";
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
if ( strMethod == szDISPOSE )
|
||||
{
|
||||
StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
|
||||
|
||||
if ( r == mapID2Obj.end() )
|
||||
{
|
||||
strRetVal = szERROR;
|
||||
strRetVal += strObjId;
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
JSExt * pJSExt = mapID2Obj[ strObjId ];
|
||||
|
||||
if ( pJSExt->CanDelete() )
|
||||
{
|
||||
delete pJSExt;
|
||||
}
|
||||
|
||||
mapID2Obj.erase( strObjId );
|
||||
strRetVal = szOK;
|
||||
strRetVal += strObjId;
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
size_t nSuffixLoc = nLoc + strObjId.size();
|
||||
string strInvoke = strFullCommand.substr( nSuffixLoc );
|
||||
strInvoke = g_trim( strInvoke );
|
||||
strRetVal = pJSExt->InvokeMethod( strInvoke );
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
strRetVal += " :Unknown command ";
|
||||
strRetVal += strCommand;
|
||||
return g_str2global( strRetVal );
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -1,70 +0,0 @@
|
||||
#ifndef _PLUGIN_H
|
||||
#define _PLUGIN_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unistd.h>
|
||||
//#include "tokenizer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//%% Functions exported by this DLL
|
||||
//%% Should always be only SetEventFunc and InvokeFunction
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// g++ requires extern "C" otherwise the names of SetEventFunc and InvokeFunction
|
||||
// are mangled C++ style. MS Visual Studio doesn't seem to care though.
|
||||
extern "C"
|
||||
{
|
||||
typedef void (*SendPluginEv)( const char* szEvent, void* pContext );
|
||||
char* SetEventFunc(SendPluginEv funcPtr);
|
||||
char* InvokeFunction( const char* szCommand, void* pContext );
|
||||
}
|
||||
|
||||
// JNEXT Framework function of the form:
|
||||
// typedef void (*SendPluginEv)( const char* szEvent );
|
||||
// used to notify JavaScript of an asynchronous event
|
||||
extern SendPluginEv SendPluginEvent;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Constants and methods common to all JNEXT extensions types
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
#define szERROR "Error "
|
||||
#define szOK "Ok "
|
||||
|
||||
#define szDISPOSE "Dispose"
|
||||
#define szINVOKE "InvokeMethod"
|
||||
#define szCREATE "CreateObj"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Utility functions
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
string& g_trim( string& str );
|
||||
void g_tokenize(const string& str,const string& delimiters, vector<string>& tokens);
|
||||
char* g_str2static( const string& strRetVal );
|
||||
void g_sleep( unsigned int mseconds );
|
||||
bool g_unregisterObject( const string& strObjId, void* pContext );
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Abstract extension object
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
class JSExt
|
||||
{
|
||||
public:
|
||||
virtual ~JSExt() {};
|
||||
virtual string InvokeMethod( const string& strCommand ) = 0;
|
||||
virtual bool CanDelete( void ) = 0;
|
||||
virtual void TryDelete( void ) {}
|
||||
public:
|
||||
void* m_pContext;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Callback functions to be implemented by the plugin implementation
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
extern char* onGetObjList( void );
|
||||
extern JSExt* onCreateObject( const string& strClassName, const string& strObjId );
|
||||
|
||||
#endif
|
@ -1,222 +0,0 @@
|
||||
/************************************************************************
|
||||
The zlib/libpng License
|
||||
|
||||
Copyright (c) 2006 Joerg Wiedenmann
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented;
|
||||
you must not claim that you wrote the original software.
|
||||
If you use this software in a product, an acknowledgment
|
||||
in the product documentation would be appreciated but is
|
||||
not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such,
|
||||
and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
created: 2006-01-28
|
||||
filename: tokenizer.cpp
|
||||
author: Jörg Wiedenmann
|
||||
|
||||
purpose: A tokenizer function which provides a very
|
||||
customizable way of breaking up strings.
|
||||
|
||||
history: 2006-01-28, Original version
|
||||
2006-03-04, Fixed a small parsing bug, thanks Elias.
|
||||
*********************************************************************/
|
||||
|
||||
#include "tokenizer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void tokenize ( const string& str, vector<string>& result,
|
||||
const string& delimiters, const string& delimiters_preserve,
|
||||
const string& quote, const string& esc )
|
||||
{
|
||||
// clear the vector
|
||||
if ( false == result.empty() )
|
||||
{
|
||||
result.clear();
|
||||
}
|
||||
|
||||
string::size_type pos = 0; // the current position (char) in the string
|
||||
char ch = 0; // buffer for the current character
|
||||
char delimiter = 0; // the buffer for the delimiter char which
|
||||
// will be added to the tokens if the delimiter
|
||||
// is preserved
|
||||
char current_quote = 0; // the char of the current open quote
|
||||
bool quoted = false; // indicator if there is an open quote
|
||||
string token; // string buffer for the token
|
||||
bool token_complete = false; // indicates if the current token is
|
||||
// read to be added to the result vector
|
||||
string::size_type len = str.length(); // length of the input-string
|
||||
|
||||
// for every char in the input-string
|
||||
while ( len > pos )
|
||||
{
|
||||
// get the character of the string and reset the delimiter buffer
|
||||
ch = str.at(pos);
|
||||
delimiter = 0;
|
||||
|
||||
// assume ch isn't a delimiter
|
||||
bool add_char = true;
|
||||
|
||||
// check ...
|
||||
|
||||
// ... if the delimiter is an escaped character
|
||||
bool escaped = false; // indicates if the next char is protected
|
||||
if ( false == esc.empty() ) // check if esc-chars are provided
|
||||
{
|
||||
if ( string::npos != esc.find_first_of(ch) )
|
||||
{
|
||||
// get the escaped char
|
||||
++pos;
|
||||
if ( pos < len ) // if there are more chars left
|
||||
{
|
||||
// get the next one
|
||||
ch = str.at(pos);
|
||||
|
||||
// add the escaped character to the token
|
||||
add_char = true;
|
||||
}
|
||||
else // cannot get any more characters
|
||||
{
|
||||
// don't add the esc-char
|
||||
add_char = false;
|
||||
}
|
||||
|
||||
// ignore the remaining delimiter checks
|
||||
escaped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ... if the delimiter is a quote
|
||||
if ( false == quote.empty() && false == escaped )
|
||||
{
|
||||
// if quote chars are provided and the char isn't protected
|
||||
if ( string::npos != quote.find_first_of(ch) )
|
||||
{
|
||||
// if not quoted, set state to open quote and set
|
||||
// the quote character
|
||||
if ( false == quoted )
|
||||
{
|
||||
quoted = true;
|
||||
current_quote = ch;
|
||||
|
||||
// don't add the quote-char to the token
|
||||
add_char = false;
|
||||
}
|
||||
else // if quote is open already
|
||||
{
|
||||
// check if it is the matching character to close it
|
||||
if ( current_quote == ch )
|
||||
{
|
||||
// close quote and reset the quote character
|
||||
quoted = false;
|
||||
current_quote = 0;
|
||||
|
||||
// don't add the quote-char to the token
|
||||
add_char = false;
|
||||
}
|
||||
} // else
|
||||
}
|
||||
}
|
||||
|
||||
// ... if the delimiter isn't preserved
|
||||
if ( false == delimiters.empty() && false == escaped &&
|
||||
false == quoted )
|
||||
{
|
||||
// if a delimiter is provided and the char isn't protected by
|
||||
// quote or escape char
|
||||
if ( string::npos != delimiters.find_first_of(ch) )
|
||||
{
|
||||
// if ch is a delimiter and the token string isn't empty
|
||||
// the token is complete
|
||||
if ( false == token.empty() ) // BUGFIX: 2006-03-04
|
||||
{
|
||||
token_complete = true;
|
||||
}
|
||||
|
||||
// don't add the delimiter to the token
|
||||
add_char = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ... if the delimiter is preserved - add it as a token
|
||||
bool add_delimiter = false;
|
||||
if ( false == delimiters_preserve.empty() && false == escaped &&
|
||||
false == quoted )
|
||||
{
|
||||
// if a delimiter which will be preserved is provided and the
|
||||
// char isn't protected by quote or escape char
|
||||
if ( string::npos != delimiters_preserve.find_first_of(ch) )
|
||||
{
|
||||
// if ch is a delimiter and the token string isn't empty
|
||||
// the token is complete
|
||||
if ( false == token.empty() ) // BUGFIX: 2006-03-04
|
||||
{
|
||||
token_complete = true;
|
||||
}
|
||||
|
||||
// don't add the delimiter to the token
|
||||
add_char = false;
|
||||
|
||||
// add the delimiter
|
||||
delimiter = ch;
|
||||
add_delimiter = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// add the character to the token
|
||||
if ( true == add_char )
|
||||
{
|
||||
// add the current char
|
||||
token.push_back( ch );
|
||||
}
|
||||
|
||||
// add the token if it is complete
|
||||
if ( true == token_complete && false == token.empty() )
|
||||
{
|
||||
// add the token string
|
||||
result.push_back( token );
|
||||
|
||||
// clear the contents
|
||||
token.clear();
|
||||
|
||||
// build the next token
|
||||
token_complete = false;
|
||||
}
|
||||
|
||||
// add the delimiter
|
||||
if ( true == add_delimiter )
|
||||
{
|
||||
// the next token is the delimiter
|
||||
string delim_token;
|
||||
delim_token.push_back( delimiter );
|
||||
result.push_back( delim_token );
|
||||
|
||||
// REMOVED: 2006-03-04, Bugfix
|
||||
}
|
||||
|
||||
// repeat for the next character
|
||||
++pos;
|
||||
} // while
|
||||
|
||||
// add the final token
|
||||
if ( false == token.empty() )
|
||||
{
|
||||
result.push_back( token );
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/************************************************************************
|
||||
The zlib/libpng License
|
||||
|
||||
Copyright (c) 2006 Joerg Wiedenmann
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented;
|
||||
you must not claim that you wrote the original software.
|
||||
If you use this software in a product, an acknowledgment
|
||||
in the product documentation would be appreciated but is
|
||||
not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such,
|
||||
and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
created: 2006-01-28
|
||||
filename: tokenizer.cpp
|
||||
author: Jörg Wiedenmann
|
||||
|
||||
purpose: A tokenizer function which provides a very
|
||||
customizable way of breaking up strings.
|
||||
*********************************************************************/
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
// Function to break up a string into tokens
|
||||
//
|
||||
// Parameters:
|
||||
//-----------
|
||||
// str = the input string that will be tokenized
|
||||
// result = the tokens for str
|
||||
// delimiters = the delimiter characters
|
||||
// delimiters preserve = same as above, but the delimiter characters
|
||||
// will be put into the result as a token
|
||||
// quote = characters to protect the enclosed characters
|
||||
// esc = characters to protect a single character
|
||||
//
|
||||
|
||||
void tokenize ( const string& str, vector<string>& result,
|
||||
const string& delimiters, const string& delimiters_preserve = "",
|
||||
const string& quote = "\"", const string& esc = "\\" );
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Logger.hpp"
|
||||
#include "toast_js.hpp"
|
||||
#include <slog2.h>
|
||||
|
||||
namespace webworks {
|
||||
|
||||
Logger::Logger(const char* name, Toast_JS *parent): m_pParent(parent) {
|
||||
buffer_config.buffer_set_name = name;
|
||||
buffer_config.num_buffers = 2;
|
||||
buffer_config.verbosity_level = SLOG2_DEBUG1;
|
||||
|
||||
/* Configure the first buffer, using 7 x 4KB pages. This larger buffer will be used for
|
||||
very chatty logging. Our goal is to have 30-60 seconds of history at any given time,
|
||||
so we will want to log at a rate of around one log line with a string of 16 bytes
|
||||
long every 150 milliseconds.
|
||||
*/
|
||||
|
||||
buffer_config.buffer_config[0].buffer_name = "low_priority";
|
||||
buffer_config.buffer_config[0].num_pages = 7;
|
||||
|
||||
/* Configure the second buffer, which we will use for high level info logging that is very
|
||||
infrequent, but we want a longer history (hours or maybe even over a day or two). This
|
||||
buffer uses 1 x 4KB.
|
||||
*/
|
||||
|
||||
buffer_config.buffer_config[1].buffer_name = "high_priority";
|
||||
buffer_config.buffer_config[1].num_pages = 1;
|
||||
|
||||
/* Register the buffer set. */
|
||||
|
||||
if( -1 == slog2_register( &buffer_config, buffer_handle, 0 ) ) {
|
||||
fprintf( stderr, "Error registering slogger2 buffer!\n" );
|
||||
} else {
|
||||
info("Created slogger2 buffers");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Logger::~Logger() {
|
||||
critical("slogger2 buffers reset");
|
||||
slog2_reset();
|
||||
}
|
||||
|
||||
int Logger::log(slog2_buffer_t buffer, _Uint8t severity, const char* message) {
|
||||
return slog2c(buffer, 0, severity, message);
|
||||
}
|
||||
|
||||
int Logger::debug(const char* message) {
|
||||
return log(lowPriorityBuffer(), SLOG2_DEBUG1, message);
|
||||
}
|
||||
|
||||
int Logger::info(const char* message) {
|
||||
return log(lowPriorityBuffer(), SLOG2_INFO, message);
|
||||
}
|
||||
|
||||
int Logger::notice(const char* message) {
|
||||
return log(lowPriorityBuffer(), SLOG2_NOTICE, message);
|
||||
}
|
||||
|
||||
int Logger::warn(const char* message) {
|
||||
return log(lowPriorityBuffer(), SLOG2_WARNING, message);
|
||||
}
|
||||
|
||||
int Logger::error(const char* message) {
|
||||
return log(hiPriorityBuffer(), SLOG2_ERROR, message);
|
||||
}
|
||||
|
||||
int Logger::critical(const char* message) {
|
||||
return log(hiPriorityBuffer(), SLOG2_CRITICAL, message);
|
||||
}
|
||||
|
||||
int Logger::setVerbosity(_Uint8t verbosity) {
|
||||
return slog2_set_verbosity(buffer_handle[0], verbosity);
|
||||
}
|
||||
|
||||
_Uint8t Logger::getVerbosity() {
|
||||
return slog2_get_verbosity(buffer_handle[0]);
|
||||
}
|
||||
|
||||
slog2_buffer_t Logger::hiPriorityBuffer() {
|
||||
return buffer_handle[1];
|
||||
}
|
||||
|
||||
slog2_buffer_t Logger::lowPriorityBuffer() {
|
||||
return buffer_handle[0];
|
||||
}
|
||||
|
||||
} /* namespace webworks */
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LOGGER_HPP_
|
||||
#define LOGGER_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <slog2.h>
|
||||
|
||||
class Toast_JS;
|
||||
|
||||
namespace webworks {
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
explicit Logger(const char* name, Toast_JS *parent = NULL);
|
||||
virtual ~Logger();
|
||||
int debug(const char* message);
|
||||
int info(const char* message);
|
||||
int notice(const char* message);
|
||||
int warn(const char* message);
|
||||
int error(const char* message);
|
||||
int critical(const char* message);
|
||||
int setVerbosity(_Uint8t verbosity);
|
||||
_Uint8t getVerbosity();
|
||||
slog2_buffer_t hiPriorityBuffer();
|
||||
slog2_buffer_t lowPriorityBuffer();
|
||||
private:
|
||||
Toast_JS *m_pParent;
|
||||
slog2_buffer_set_config_t buffer_config;
|
||||
slog2_buffer_t buffer_handle[2];
|
||||
int log(slog2_buffer_t buffer, _Uint8t severity, const char* message);
|
||||
};
|
||||
|
||||
} /* namespace webworks */
|
||||
#endif /* LOGGER_HPP_ */
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "../public/tokenizer.h"
|
||||
#include "toast_js.hpp"
|
||||
#include "toast_ndk.hpp"
|
||||
|
||||
#include <json/reader.h>
|
||||
#include <json/writer.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
Toast_JS::Toast_JS(const std::string& id) :
|
||||
m_id(id)
|
||||
{
|
||||
m_pLogger = new webworks::Logger("Toast_JS", this);
|
||||
m_pToastController = new webworks::Toast_NDK(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toast_JS destructor.
|
||||
*/
|
||||
Toast_JS::~Toast_JS()
|
||||
{
|
||||
if (m_pToastController)
|
||||
delete m_pToastController;
|
||||
if (m_pLogger)
|
||||
delete m_pLogger;
|
||||
}
|
||||
|
||||
webworks::Logger* Toast_JS::getLog()
|
||||
{
|
||||
return m_pLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the list of objects implemented by this native
|
||||
* extension.
|
||||
*/
|
||||
char* onGetObjList()
|
||||
{
|
||||
static char name[] = "Toast_JS";
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used by JNext to instantiate the Toast_JS object when
|
||||
* an object is created on the JavaScript server side.
|
||||
*/
|
||||
JSExt* onCreateObject(const string& className, const string& id)
|
||||
{
|
||||
if (className == "Toast_JS")
|
||||
{
|
||||
return new Toast_JS(id);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used by JNext to determine if the object can be deleted.
|
||||
*/
|
||||
bool Toast_JS::CanDelete()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* It will be called from JNext JavaScript side with passed string.
|
||||
* This method implements the interface for the JavaScript to native binding
|
||||
* for invoking native code. This method is triggered when JNext.invoke is
|
||||
* called on the JavaScript side with this native objects id.
|
||||
*/
|
||||
string Toast_JS::InvokeMethod(const string& command)
|
||||
{
|
||||
m_pLogger->debug("Toast invoked");
|
||||
// format must be: "command callbackId params"
|
||||
size_t commandIndex = command.find_first_of(" ");
|
||||
std::string strCommand = command.substr(0, commandIndex);
|
||||
size_t callbackIndex = command.find_first_of(" ", commandIndex + 1);
|
||||
std::string callbackId = command.substr(commandIndex + 1, callbackIndex - commandIndex - 1);
|
||||
std::string arg = command.substr(callbackIndex + 1, command.length());
|
||||
m_pLogger->debug(command.c_str());
|
||||
m_pLogger->debug(arg.c_str());
|
||||
|
||||
Json::FastWriter writer;
|
||||
Json::Reader reader;
|
||||
Json::Value root;
|
||||
bool parse = reader.parse(arg, root);
|
||||
|
||||
if (!parse)
|
||||
{
|
||||
m_pLogger->error("Parse Error");
|
||||
Json::Value error;
|
||||
error["result"] = "Cannot parse JSON object";
|
||||
NotifyEvent(callbackId + " error " + writer.write(error));
|
||||
} else
|
||||
{
|
||||
if (strCommand == "show")
|
||||
{
|
||||
m_pToastController->toast(root["message"].asString(), root["duration"].asString(), root["position"].asString(), callbackId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strCommand.append(";");
|
||||
strCommand.append(command);
|
||||
return strCommand;
|
||||
}
|
||||
|
||||
// Notifies JavaScript of an event
|
||||
void Toast_JS::NotifyEvent(const std::string& event)
|
||||
{
|
||||
std::string eventString = m_id + " ";
|
||||
eventString.append(event);
|
||||
SendPluginEvent(eventString.c_str(), m_pContext);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef toast_JS_HPP_
|
||||
#define toast_JS_HPP_
|
||||
|
||||
#include <string>
|
||||
#include "../public/plugin.h"
|
||||
#include "toast_ndk.hpp"
|
||||
#include "Logger.hpp"
|
||||
|
||||
class Toast_JS: public JSExt {
|
||||
|
||||
public:
|
||||
explicit Toast_JS(const std::string& id);
|
||||
virtual ~Toast_JS();
|
||||
virtual bool CanDelete();
|
||||
virtual std::string InvokeMethod(const std::string& command);
|
||||
void NotifyEvent(const std::string& event);
|
||||
webworks::Logger* getLog();
|
||||
private:
|
||||
std::string m_id;
|
||||
// Definition of a pointer to the actual native extension code
|
||||
webworks::Toast_NDK *m_pToastController;
|
||||
webworks::Logger *m_pLogger;
|
||||
};
|
||||
|
||||
#endif /* toast_JS_HPP_ */
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "toast_ndk.hpp"
|
||||
#include "toast_js.hpp"
|
||||
|
||||
#include <bb/system/SystemToast>
|
||||
#include <bb/system/SystemUiPosition>
|
||||
|
||||
using namespace bb::system;
|
||||
|
||||
namespace webworks
|
||||
{
|
||||
|
||||
Toast_NDK::Toast_NDK(Toast_JS *parent) :
|
||||
m_pParent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Toast_NDK::~Toast_NDK()
|
||||
{
|
||||
}
|
||||
|
||||
void Toast_NDK::toast(const std::string& message, const std::string& duration,
|
||||
const std::string& position, const std::string callbackId)
|
||||
{
|
||||
|
||||
SystemToast* m_toast;
|
||||
m_toast = new SystemToast();
|
||||
|
||||
m_toast->setBody(message.c_str());
|
||||
|
||||
if (position == "top")
|
||||
{
|
||||
m_toast->setPosition(SystemUiPosition::TopCenter);
|
||||
} else if (position == "bottom")
|
||||
{
|
||||
m_toast->setPosition(SystemUiPosition::BottomCenter);
|
||||
} else
|
||||
|
||||
{
|
||||
m_toast->setPosition(SystemUiPosition::MiddleCenter);
|
||||
}
|
||||
|
||||
m_toast->show();
|
||||
|
||||
m_pParent->NotifyEvent(callbackId);
|
||||
}
|
||||
|
||||
} /* namespace webworks */
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 BlackBerry Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef toast_NDK_HPP_
|
||||
#define toast_NDK_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <pthread.h>
|
||||
|
||||
class Toast_JS;
|
||||
|
||||
namespace webworks {
|
||||
|
||||
class Toast_NDK {
|
||||
public:
|
||||
explicit Toast_NDK(Toast_JS *parent = NULL);
|
||||
virtual ~Toast_NDK();
|
||||
|
||||
void toast(const std::string& message, const std::string& duration, const std::string& position, const std::string callbackId);
|
||||
|
||||
|
||||
private:
|
||||
Toast_JS *m_pParent;
|
||||
};
|
||||
|
||||
} // namespace webworks
|
||||
|
||||
#endif /* toast_NDK_HPP_ */
|
@ -1,18 +1,14 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
@interface UIView (Toast)
|
||||
|
||||
// each makeToast method creates a view and displays it as toast
|
||||
- (void)makeToast:(NSString *)message;
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)interval position:(id)position;
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position addPixelsY:(int)addPixelsY data:(NSDictionary*)data styling:(NSDictionary*)styling commandDelegate:(id <CDVCommandDelegate>)commandDelegate callbackId:(NSString *)callbackId;
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)interval position:(id)position image:(UIImage *)image;
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)interval position:(id)position title:(NSString *)title;
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)interval position:(id)position title:(NSString *)title image:(UIImage *)image;
|
||||
|
||||
- (void)hideToast;
|
||||
|
||||
// displays toast with an activity spinner
|
||||
- (void)makeToastActivity;
|
||||
- (void)makeToastActivity:(id)position;
|
||||
@ -20,7 +16,6 @@
|
||||
|
||||
// the showToast methods display any view as toast
|
||||
- (void)showToast:(UIView *)toast;
|
||||
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)interval position:(id)point ;
|
||||
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)interval position:(id)point addedPixelsY:(int)addPixelsY;
|
||||
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)interval position:(id)point;
|
||||
|
||||
@end
|
||||
|
@ -12,7 +12,7 @@ static const CGFloat CSToastMaxWidth = 0.8; // 80% of parent vie
|
||||
static const CGFloat CSToastMaxHeight = 0.8; // 80% of parent view height
|
||||
static const CGFloat CSToastHorizontalPadding = 16.0;
|
||||
static const CGFloat CSToastVerticalPadding = 12.0;
|
||||
static const CGFloat CSToastTopBottomOffset = 20.0;
|
||||
static const CGFloat CSToastTopBottomOffset = 10.0;
|
||||
static const CGFloat CSToastCornerRadius = 20.0;
|
||||
static const CGFloat CSToastOpacity = 0.8;
|
||||
static const CGFloat CSToastFontSize = 13.0;
|
||||
@ -46,29 +46,20 @@ static const BOOL CSToastHidesOnTap = YES; // excludes activity
|
||||
static const NSString * CSToastTimerKey = @"CSToastTimerKey";
|
||||
static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey";
|
||||
|
||||
static UIView *prevToast = NULL;
|
||||
|
||||
// doesn't matter these are static
|
||||
static id commandDelegate;
|
||||
static id callbackId;
|
||||
static id msg;
|
||||
static id data;
|
||||
static id styling;
|
||||
|
||||
@interface UIView (ToastPrivate)
|
||||
|
||||
- (void)hideToast:(UIView *)toast;
|
||||
- (void)toastTimerDidFinish:(NSTimer *)timer;
|
||||
- (void)handleToastTapped:(UITapGestureRecognizer *)recognizer;
|
||||
- (CGPoint)centerPointForPosition:(id)position withToast:(UIView *)toast withAddedPixelsY:(int) addPixelsY;
|
||||
- (CGPoint)centerPointForPosition:(id)position withToast:(UIView *)toast;
|
||||
- (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image;
|
||||
- (CGSize)sizeForString:(NSString *)string font:(UIFont *)font constrainedToSize:(CGSize)constrainedSize lineBreakMode:(NSLineBreakMode)lineBreakMode;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation UIView (Toast)
|
||||
|
||||
|
||||
#pragma mark - Toast Methods
|
||||
|
||||
- (void)makeToast:(NSString *)message {
|
||||
@ -77,40 +68,22 @@ static id styling;
|
||||
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position {
|
||||
UIView *toast = [self viewForMessage:message title:nil image:nil];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
}
|
||||
|
||||
- (void)makeToast:(NSString *)message
|
||||
duration:(NSTimeInterval)duration
|
||||
position:(id)position addPixelsY:(int)addPixelsY
|
||||
data:(NSDictionary*)_data
|
||||
styling:(NSDictionary*)_styling
|
||||
commandDelegate:(id <CDVCommandDelegate>)_commandDelegate
|
||||
callbackId:(NSString *)_callbackId {
|
||||
|
||||
commandDelegate = _commandDelegate;
|
||||
callbackId = _callbackId;
|
||||
msg = message;
|
||||
data = _data;
|
||||
styling = _styling;
|
||||
|
||||
UIView *toast = [self viewForMessage:message title:nil image:nil];
|
||||
[self showToast:toast duration:duration position:position addedPixelsY:addPixelsY];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
}
|
||||
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title {
|
||||
UIView *toast = [self viewForMessage:message title:title image:nil];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
}
|
||||
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position image:(UIImage *)image {
|
||||
UIView *toast = [self viewForMessage:message title:nil image:image];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
}
|
||||
|
||||
- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title image:(UIImage *)image {
|
||||
UIView *toast = [self viewForMessage:message title:title image:image];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
[self showToast:toast duration:duration position:position];
|
||||
}
|
||||
|
||||
- (void)showToast:(UIView *)toast {
|
||||
@ -118,56 +91,29 @@ static id styling;
|
||||
}
|
||||
|
||||
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)point {
|
||||
[self showToast:toast duration:CSToastDefaultDuration position:CSToastDefaultPosition addedPixelsY:0];
|
||||
}
|
||||
|
||||
- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)point addedPixelsY:(int) addPixelsY {
|
||||
[self hideToast];
|
||||
prevToast = toast;
|
||||
toast.center = [self centerPointForPosition:point withToast:toast withAddedPixelsY:addPixelsY];
|
||||
toast.center = [self centerPointForPosition:point withToast:toast];
|
||||
toast.alpha = 0.0;
|
||||
|
||||
// note that we changed this to be always true
|
||||
|
||||
if (CSToastHidesOnTap) {
|
||||
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:toast action:@selector(handleToastTapped:)];
|
||||
[toast addGestureRecognizer:recognizer];
|
||||
toast.userInteractionEnabled = YES;
|
||||
toast.exclusiveTouch = YES;
|
||||
}
|
||||
|
||||
// make sure that if InAppBrowser is active, we're still showing Toasts on top of it
|
||||
UIViewController *vc = [self getTopMostViewController];
|
||||
UIView *v = [vc view];
|
||||
[v addSubview:toast];
|
||||
|
||||
NSNumber * opacity = styling[@"opacity"];
|
||||
CGFloat theOpacity = opacity == nil ? CSToastOpacity : [opacity floatValue];
|
||||
|
||||
|
||||
[self addSubview:toast];
|
||||
|
||||
[UIView animateWithDuration:CSToastFadeDuration
|
||||
delay:0.0
|
||||
options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction)
|
||||
animations:^{
|
||||
toast.alpha = theOpacity;
|
||||
toast.alpha = CSToastOpacity;
|
||||
} completion:^(BOOL finished) {
|
||||
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(toastTimerDidFinish:) userInfo:toast repeats:NO];
|
||||
// associate the timer with the toast view
|
||||
objc_setAssociatedObject (toast, &CSToastTimerKey, timer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (UIViewController*) getTopMostViewController {
|
||||
UIViewController *presentingViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
|
||||
while (presentingViewController.presentedViewController != nil) {
|
||||
presentingViewController = presentingViewController.presentedViewController;
|
||||
}
|
||||
return presentingViewController;
|
||||
}
|
||||
|
||||
- (void)hideToast {
|
||||
if (prevToast){
|
||||
[self hideToast:prevToast];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)hideToast:(UIView *)toast {
|
||||
@ -185,31 +131,13 @@ static id styling;
|
||||
|
||||
- (void)toastTimerDidFinish:(NSTimer *)timer {
|
||||
[self hideToast:(UIView *)timer.userInfo];
|
||||
|
||||
// also send an event back to JS
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:msg, @"message", @"hide", @"event", nil];
|
||||
if (data != nil) {
|
||||
[dict setObject:data forKey:@"data"];
|
||||
}
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
||||
[commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||
}
|
||||
|
||||
- (void)handleToastTapped:(UITapGestureRecognizer *)recognizer {
|
||||
NSTimer *timer = (NSTimer *)objc_getAssociatedObject(self, &CSToastTimerKey);
|
||||
[timer invalidate];
|
||||
|
||||
|
||||
[self hideToast:recognizer.view];
|
||||
|
||||
// also send an event back to JS
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:msg, @"message", @"touch", @"event", nil];
|
||||
if (data != nil) {
|
||||
[dict setObject:data forKey:@"data"];
|
||||
}
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
||||
[commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||
}
|
||||
|
||||
#pragma mark - Toast Activity Methods
|
||||
@ -222,31 +150,31 @@ static id styling;
|
||||
// sanity
|
||||
UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey);
|
||||
if (existingActivityView != nil) return;
|
||||
|
||||
|
||||
UIView *activityView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CSToastActivityWidth, CSToastActivityHeight)];
|
||||
activityView.center = [self centerPointForPosition:position withToast:activityView withAddedPixelsY:0];
|
||||
activityView.center = [self centerPointForPosition:position withToast:activityView];
|
||||
activityView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:CSToastOpacity];
|
||||
activityView.alpha = 0.0;
|
||||
activityView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
|
||||
activityView.layer.cornerRadius = CSToastCornerRadius;
|
||||
|
||||
|
||||
if (CSToastDisplayShadow) {
|
||||
activityView.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
activityView.layer.shadowOpacity = CSToastShadowOpacity;
|
||||
activityView.layer.shadowRadius = CSToastShadowRadius;
|
||||
activityView.layer.shadowOffset = CSToastShadowOffset;
|
||||
}
|
||||
|
||||
|
||||
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||||
activityIndicatorView.center = CGPointMake(activityView.bounds.size.width / 2, activityView.bounds.size.height / 2);
|
||||
[activityView addSubview:activityIndicatorView];
|
||||
[activityIndicatorView startAnimating];
|
||||
|
||||
|
||||
// associate the activity view with self
|
||||
objc_setAssociatedObject (self, &CSToastActivityViewKey, activityView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
|
||||
[self addSubview:activityView];
|
||||
|
||||
|
||||
[UIView animateWithDuration:CSToastFadeDuration
|
||||
delay:0.0
|
||||
options:UIViewAnimationOptionCurveEaseOut
|
||||
@ -272,22 +200,22 @@ static id styling;
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
- (CGPoint)centerPointForPosition:(id)point withToast:(UIView *)toast withAddedPixelsY:(int) addPixelsY {
|
||||
- (CGPoint)centerPointForPosition:(id)point withToast:(UIView *)toast {
|
||||
if([point isKindOfClass:[NSString class]]) {
|
||||
// convert string literals @"top", @"bottom", @"center", or any point wrapped in an NSValue object into a CGPoint
|
||||
if([point caseInsensitiveCompare:@"top"] == NSOrderedSame) {
|
||||
return CGPointMake(self.bounds.size.width/2, (toast.frame.size.height / 2) + addPixelsY + CSToastVerticalPadding + CSToastTopBottomOffset);
|
||||
return CGPointMake(self.bounds.size.width/2, (toast.frame.size.height / 2) + CSToastVerticalPadding + CSToastTopBottomOffset);
|
||||
} else if([point caseInsensitiveCompare:@"bottom"] == NSOrderedSame) {
|
||||
return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - CSToastVerticalPadding - CSToastTopBottomOffset + addPixelsY);
|
||||
return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - CSToastVerticalPadding - CSToastTopBottomOffset);
|
||||
} else if([point caseInsensitiveCompare:@"center"] == NSOrderedSame) {
|
||||
return CGPointMake(self.bounds.size.width / 2, (self.bounds.size.height / 2) + addPixelsY);
|
||||
return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
|
||||
}
|
||||
} else if ([point isKindOfClass:[NSValue class]]) {
|
||||
return [point CGPointValue];
|
||||
}
|
||||
|
||||
|
||||
NSLog(@"Warning: Invalid position for toast.");
|
||||
return [self centerPointForPosition:CSToastDefaultPosition withToast:toast withAddedPixelsY:addPixelsY];
|
||||
return [self centerPointForPosition:CSToastDefaultPosition withToast:toast];
|
||||
}
|
||||
|
||||
- (CGSize)sizeForString:(NSString *)string font:(UIFont *)font constrainedToSize:(CGSize)constrainedSize lineBreakMode:(NSLineBreakMode)lineBreakMode {
|
||||
@ -299,10 +227,7 @@ static id styling;
|
||||
return CGSizeMake(ceilf(boundingRect.size.width), ceilf(boundingRect.size.height));
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
return [string sizeWithFont:font constrainedToSize:constrainedSize lineBreakMode:lineBreakMode];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image {
|
||||
@ -317,9 +242,7 @@ static id styling;
|
||||
// create the parent view
|
||||
UIView *wrapperView = [[UIView alloc] init];
|
||||
wrapperView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
|
||||
|
||||
NSNumber * cornerRadius = styling[@"cornerRadius"];
|
||||
wrapperView.layer.cornerRadius = cornerRadius == nil ? CSToastCornerRadius : [cornerRadius floatValue];
|
||||
wrapperView.layer.cornerRadius = CSToastCornerRadius;
|
||||
|
||||
if (CSToastDisplayShadow) {
|
||||
wrapperView.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
@ -328,24 +251,12 @@ static id styling;
|
||||
wrapperView.layer.shadowOffset = CSToastShadowOffset;
|
||||
}
|
||||
|
||||
NSString * backgroundColor = styling[@"backgroundColor"];
|
||||
UIColor *theColor = backgroundColor == nil ? [UIColor blackColor] : [self colorFromHexString:backgroundColor];
|
||||
|
||||
NSNumber * horizontalPadding = styling[@"horizontalPadding"];
|
||||
CGFloat theHorizontalPadding = horizontalPadding == nil ? CSToastHorizontalPadding : [horizontalPadding floatValue];
|
||||
|
||||
NSNumber * verticalPadding = styling[@"verticalPadding"];
|
||||
CGFloat theVerticalPadding = verticalPadding == nil ? CSToastVerticalPadding : [verticalPadding floatValue];
|
||||
wrapperView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:CSToastOpacity];
|
||||
|
||||
NSNumber * textSize = styling[@"textSize"];
|
||||
CGFloat theTextSize = textSize == nil ? CSToastFontSize : [textSize floatValue];
|
||||
|
||||
wrapperView.backgroundColor = theColor;
|
||||
|
||||
if(image != nil) {
|
||||
imageView = [[UIImageView alloc] initWithImage:image];
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
imageView.frame = CGRectMake(theHorizontalPadding, theVerticalPadding, CSToastImageViewWidth, CSToastImageViewHeight);
|
||||
imageView.frame = CGRectMake(CSToastHorizontalPadding, CSToastVerticalPadding, CSToastImageViewWidth, CSToastImageViewHeight);
|
||||
}
|
||||
|
||||
CGFloat imageWidth, imageHeight, imageLeft;
|
||||
@ -354,21 +265,18 @@ static id styling;
|
||||
if(imageView != nil) {
|
||||
imageWidth = imageView.bounds.size.width;
|
||||
imageHeight = imageView.bounds.size.height;
|
||||
imageLeft = theHorizontalPadding;
|
||||
imageLeft = CSToastHorizontalPadding;
|
||||
} else {
|
||||
imageWidth = imageHeight = imageLeft = 0.0;
|
||||
}
|
||||
|
||||
if (title != nil) {
|
||||
NSString * titleLabelTextColor = styling[@"textColor"];
|
||||
UIColor *theTitleLabelTextColor = titleLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:titleLabelTextColor];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.numberOfLines = CSToastMaxTitleLines;
|
||||
titleLabel.font = [UIFont boldSystemFontOfSize:theTextSize];
|
||||
titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize];
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
titleLabel.textColor = theTitleLabelTextColor;
|
||||
titleLabel.textColor = [UIColor whiteColor];
|
||||
titleLabel.backgroundColor = [UIColor clearColor];
|
||||
titleLabel.alpha = 1.0;
|
||||
titleLabel.text = title;
|
||||
@ -380,15 +288,11 @@ static id styling;
|
||||
}
|
||||
|
||||
if (message != nil) {
|
||||
NSString * messageLabelTextColor = styling[@"textColor"];
|
||||
UIColor *theMessageLabelTextColor = messageLabelTextColor == nil ? [UIColor whiteColor] : [self colorFromHexString:messageLabelTextColor];
|
||||
|
||||
messageLabel = [[UILabel alloc] init];
|
||||
messageLabel.numberOfLines = CSToastMaxMessageLines;
|
||||
messageLabel.font = [UIFont systemFontOfSize:theTextSize];
|
||||
messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize];
|
||||
messageLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
messageLabel.textAlignment = NSTextAlignmentCenter;
|
||||
messageLabel.textColor = theMessageLabelTextColor;
|
||||
messageLabel.textColor = [UIColor whiteColor];
|
||||
messageLabel.backgroundColor = [UIColor clearColor];
|
||||
messageLabel.alpha = 1.0;
|
||||
messageLabel.text = message;
|
||||
@ -405,8 +309,8 @@ static id styling;
|
||||
if(titleLabel != nil) {
|
||||
titleWidth = titleLabel.bounds.size.width;
|
||||
titleHeight = titleLabel.bounds.size.height;
|
||||
titleTop = theVerticalPadding;
|
||||
titleLeft = imageLeft + imageWidth + theHorizontalPadding;
|
||||
titleTop = CSToastVerticalPadding;
|
||||
titleLeft = imageLeft + imageWidth + CSToastHorizontalPadding;
|
||||
} else {
|
||||
titleWidth = titleHeight = titleTop = titleLeft = 0.0;
|
||||
}
|
||||
@ -417,8 +321,8 @@ static id styling;
|
||||
if(messageLabel != nil) {
|
||||
messageWidth = messageLabel.bounds.size.width;
|
||||
messageHeight = messageLabel.bounds.size.height;
|
||||
messageLeft = imageLeft + imageWidth + theHorizontalPadding;
|
||||
messageTop = titleTop + titleHeight + theVerticalPadding;
|
||||
messageLeft = imageLeft + imageWidth + CSToastHorizontalPadding;
|
||||
messageTop = titleTop + titleHeight + CSToastVerticalPadding;
|
||||
} else {
|
||||
messageWidth = messageHeight = messageLeft = messageTop = 0.0;
|
||||
}
|
||||
@ -427,8 +331,8 @@ static id styling;
|
||||
CGFloat longerLeft = MAX(titleLeft, messageLeft);
|
||||
|
||||
// wrapper width uses the longerWidth or the image width, whatever is larger. same logic applies to the wrapper height
|
||||
CGFloat wrapperWidth = MAX((imageWidth + (theHorizontalPadding * 2)), (longerLeft + longerWidth + theHorizontalPadding));
|
||||
CGFloat wrapperHeight = MAX((messageTop + messageHeight + theVerticalPadding), (imageHeight + (theVerticalPadding * 2)));
|
||||
CGFloat wrapperWidth = MAX((imageWidth + (CSToastHorizontalPadding * 2)), (longerLeft + longerWidth + CSToastHorizontalPadding));
|
||||
CGFloat wrapperHeight = MAX((messageTop + messageHeight + CSToastVerticalPadding), (imageHeight + (CSToastVerticalPadding * 2)));
|
||||
|
||||
wrapperView.frame = CGRectMake(0.0, 0.0, wrapperWidth, wrapperHeight);
|
||||
|
||||
@ -449,13 +353,4 @@ static id styling;
|
||||
return wrapperView;
|
||||
}
|
||||
|
||||
// Assumes input like "#00FF00" (#RRGGBB)
|
||||
- (UIColor*) colorFromHexString:(NSString*) hexString {
|
||||
unsigned rgbValue = 0;
|
||||
NSScanner *scanner = [NSScanner scannerWithString:hexString];
|
||||
[scanner setScanLocation:1]; // bypass '#' character
|
||||
[scanner scanHexInt:&rgbValue];
|
||||
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 green:((rgbValue & 0xFF00) >> 8) / 255.0 blue:(rgbValue & 0xFF) / 255.0 alpha:1.0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -3,6 +3,5 @@
|
||||
@interface Toast : CDVPlugin
|
||||
|
||||
- (void)show:(CDVInvokedUrlCommand*)command;
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
@ -5,48 +5,32 @@
|
||||
@implementation Toast
|
||||
|
||||
- (void)show:(CDVInvokedUrlCommand*)command {
|
||||
NSDictionary* options = [command argumentAtIndex:0];
|
||||
NSString *message = options[@"message"];
|
||||
NSString *duration = options[@"duration"];
|
||||
NSString *position = options[@"position"];
|
||||
NSDictionary *data = options[@"data"];
|
||||
NSNumber *addPixelsY = options[@"addPixelsY"];
|
||||
NSDictionary *styling = options[@"styling"];
|
||||
|
||||
|
||||
NSString *message = [command.arguments objectAtIndex:0];
|
||||
NSString *duration = [command.arguments objectAtIndex:1];
|
||||
NSString *position = [command.arguments objectAtIndex:2];
|
||||
|
||||
if (![position isEqual: @"top"] && ![position isEqual: @"center"] && ![position isEqual: @"bottom"]) {
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid position. valid options are 'top', 'center' and 'bottom'"];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
[self writeJavascript:[pluginResult toErrorCallbackString:command.callbackId]];
|
||||
return;
|
||||
}
|
||||
|
||||
NSTimeInterval durationMS;
|
||||
if ([duration.lowercaseString isEqualToString: @"short"]) {
|
||||
durationMS = 2000;
|
||||
} else if ([duration.lowercaseString isEqualToString: @"long"]) {
|
||||
durationMS = 4000;
|
||||
} else {
|
||||
durationMS = [duration intValue];
|
||||
}
|
||||
|
||||
[self.webView makeToast:message
|
||||
duration:durationMS / 1000
|
||||
position:position
|
||||
addPixelsY:addPixelsY == nil ? 0 : [addPixelsY intValue]
|
||||
data:data
|
||||
styling:styling
|
||||
commandDelegate:self.commandDelegate
|
||||
callbackId:command.callbackId];
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
pluginResult.keepCallback = [NSNumber numberWithBool:YES];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command {
|
||||
[self.webView hideToast];
|
||||
|
||||
NSInteger durationInt;
|
||||
if ([duration isEqual: @"short"]) {
|
||||
durationInt = 2;
|
||||
} else if ([duration isEqual: @"long"]) {
|
||||
durationInt = 5;
|
||||
} else {
|
||||
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid duration. valid options are 'short' and 'long'"];
|
||||
[self writeJavascript:[pluginResult toErrorCallbackString:command.callbackId]];
|
||||
return;
|
||||
}
|
||||
|
||||
[self.webView makeToast:message duration:durationInt position:position];
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
[self writeJavascript:[pluginResult toSuccessCallbackString:command.callbackId]];
|
||||
}
|
||||
|
||||
@end
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* @author Piotr Smolarski <ph0ndragxdev@gmail.com>
|
||||
*/
|
||||
var toastProxy = {
|
||||
|
||||
lastDisplayedNotification: null,
|
||||
|
||||
show: function(successCallback, errorCallback, options) {
|
||||
var notifications = Windows.UI.Notifications;
|
||||
|
||||
var template = notifications.ToastTemplateType.ToastText01;
|
||||
var toastXml = notifications.ToastNotificationManager.getTemplateContent(template);
|
||||
|
||||
var toastTextElements = toastXml.getElementsByTagName("text");
|
||||
toastTextElements[0].appendChild(toastXml.createTextNode(options[0].message));
|
||||
|
||||
var toastNode = toastXml.selectSingleNode("/toast");
|
||||
toastNode.setAttribute("duration", options[0].duration);
|
||||
|
||||
var toast = new notifications.ToastNotification(toastXml);
|
||||
|
||||
toast.onactivated = function (event) {
|
||||
toastProxy.lastDisplayedNotification = null;
|
||||
successCallback({
|
||||
event: "touch",
|
||||
message: options[0].message,
|
||||
data: options[0].data
|
||||
});
|
||||
};
|
||||
|
||||
toast.ondismissed = function (event) {
|
||||
toastProxy.lastDisplayedNotification = null;
|
||||
successCallback({
|
||||
event: "hide",
|
||||
message: options[0].message,
|
||||
data: options[0].data
|
||||
});
|
||||
};
|
||||
|
||||
toast.onfailed = function(err) {
|
||||
toastProxy.lastDisplayedNotification = null;
|
||||
errorCallback(err);
|
||||
};
|
||||
|
||||
notifications.ToastNotificationManager.createToastNotifier().show(toast);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
if (this.lastDisplayedNotification !== null) {
|
||||
notifications.ToastNotificationManager.createToastNotifier().hide(toast);
|
||||
this.lastDisplayedNotification = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cordova.commandProxy.add("Toast", toastProxy);
|
@ -1,5 +1,3 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@ -28,44 +26,13 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class ToastOptions
|
||||
{
|
||||
[DataMember(IsRequired = true, Name = "message")]
|
||||
public string message { get; set; }
|
||||
|
||||
[DataMember(IsRequired = true, Name = "duration")]
|
||||
public string duration { get; set; }
|
||||
|
||||
[DataMember(IsRequired = true, Name = "position")]
|
||||
public string position { get; set; }
|
||||
|
||||
[DataMember(IsRequired = false, Name = "addPixelsY")]
|
||||
public int addPixelsY { get; set; }
|
||||
}
|
||||
|
||||
public void show(string options)
|
||||
{
|
||||
ToastOptions toastOptions;
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
String jsonOptions = args[0];
|
||||
|
||||
try
|
||||
{
|
||||
toastOptions = JSON.JsonHelper.Deserialize<ToastOptions>(jsonOptions);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
|
||||
return;
|
||||
}
|
||||
|
||||
var message = toastOptions.message;
|
||||
var duration = toastOptions.duration;
|
||||
var position = toastOptions.position;
|
||||
int addPixelsY = toastOptions.addPixelsY;
|
||||
|
||||
string aliasCurrentCommandCallbackId = args[1];
|
||||
var message = args[0];
|
||||
var duration = args[1];
|
||||
var position = args[2];
|
||||
string aliasCurrentCommandCallbackId = args[3];
|
||||
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
@ -108,37 +75,23 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
if ("top".Equals(position))
|
||||
{
|
||||
popup.VerticalAlignment = VerticalAlignment.Top;
|
||||
popup.VerticalOffset = 20 + addPixelsY;
|
||||
popup.VerticalOffset = 20;
|
||||
}
|
||||
else if ("bottom".Equals(position))
|
||||
{
|
||||
popup.VerticalAlignment = VerticalAlignment.Bottom;
|
||||
popup.VerticalOffset = -100 + addPixelsY; // TODO can do better
|
||||
popup.VerticalOffset = -100; // TODO can do better
|
||||
}
|
||||
else if ("center".Equals(position))
|
||||
else // center
|
||||
{
|
||||
popup.VerticalAlignment = VerticalAlignment.Center;
|
||||
popup.VerticalOffset = -50 + addPixelsY; // TODO can do way better
|
||||
}
|
||||
else
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "invalid position. valid options are 'top', 'center' and 'bottom'"));
|
||||
return;
|
||||
}
|
||||
|
||||
int hideDelay = 2500;
|
||||
if ("long".Equals(duration))
|
||||
{
|
||||
hideDelay = 5000;
|
||||
}
|
||||
else if (!"short".Equals(duration))
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "invalid duration. valid options are 'short' and 'long'"));
|
||||
return;
|
||||
popup.VerticalOffset = -50; // TODO can do way better
|
||||
}
|
||||
|
||||
grid.Children.Add(popup);
|
||||
popup.IsOpen = true;
|
||||
|
||||
int hideDelay = "long".Equals(duration) ? 5500 : 2800;
|
||||
this.hidePopup(hideDelay);
|
||||
}
|
||||
}
|
||||
@ -149,21 +102,10 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
});
|
||||
}
|
||||
|
||||
public void hide(string options)
|
||||
{
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (popup != null && popup.IsOpen)
|
||||
{
|
||||
popup.IsOpen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async void hidePopup(int delay)
|
||||
{
|
||||
await Task.Delay(delay);
|
||||
popup.IsOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
exports.defineAutoTests = function() {
|
||||
|
||||
cordova.define("nl.x-services.plugins.toast.tests", function(require, exports, module) { exports.defineAutoTests = function() {
|
||||
|
||||
var fail = function (done) {
|
||||
expect(true).toBe(false);
|
||||
expect(false).toBe(true);
|
||||
done();
|
||||
},
|
||||
succeed = function (done) {
|
||||
expect(true).toBe(true);
|
||||
expect(false).toBe(false);
|
||||
done();
|
||||
};
|
||||
|
||||
@ -20,14 +20,6 @@ exports.defineAutoTests = function() {
|
||||
expect(window.plugins.toast.show).toBeDefined();
|
||||
});
|
||||
|
||||
it("should define showWithOptions", function() {
|
||||
expect(window.plugins.toast.showWithOptions).toBeDefined();
|
||||
});
|
||||
|
||||
it("should define optionsBuilder", function() {
|
||||
expect(window.plugins.toast.optionsBuilder).toBeDefined();
|
||||
});
|
||||
|
||||
it("should define showShortTop", function() {
|
||||
expect(window.plugins.toast.showShortTop).toBeDefined();
|
||||
});
|
||||
@ -55,7 +47,13 @@ exports.defineAutoTests = function() {
|
||||
|
||||
describe('Invalid usage', function () {
|
||||
it("should fail due to an invalid position", function(done) {
|
||||
window.plugins.toast.show('hi', 'short', 'nowhere', fail.bind(null, done), succeed.bind(null, done));
|
||||
window.plugins.toast.show('hi', 'short', 'nowhere', fail.bind(null, done), succeed.bind(null, done));
|
||||
});
|
||||
|
||||
it("should fail due to an invalid duration", function(done) {
|
||||
window.plugins.toast.show('hi', 'medium', 'top', fail.bind(null, done), succeed.bind(null, done));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
60
www/Toast.js
60
www/Toast.js
@ -1,62 +1,8 @@
|
||||
function Toast() {
|
||||
}
|
||||
|
||||
Toast.prototype.optionsBuilder = function () {
|
||||
|
||||
// defaults
|
||||
var message = null;
|
||||
var duration = "short";
|
||||
var position = "center";
|
||||
var addPixelsY = 0;
|
||||
|
||||
return {
|
||||
withMessage: function(m) {
|
||||
message = m.toString();
|
||||
return this;
|
||||
},
|
||||
|
||||
withDuration: function(d) {
|
||||
duration = d.toString();
|
||||
return this;
|
||||
},
|
||||
|
||||
withPosition: function(p) {
|
||||
position = p;
|
||||
return this;
|
||||
},
|
||||
|
||||
withAddPixelsY: function(y) {
|
||||
addPixelsY = y;
|
||||
return this;
|
||||
},
|
||||
|
||||
build: function() {
|
||||
return {
|
||||
message: message,
|
||||
duration: duration,
|
||||
position: position,
|
||||
addPixelsY: addPixelsY
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Toast.prototype.showWithOptions = function (options, successCallback, errorCallback) {
|
||||
options.duration = (options.duration === undefined ? 'long' : options.duration.toString());
|
||||
options.message = options.message.toString();
|
||||
cordova.exec(successCallback, errorCallback, "Toast", "show", [options]);
|
||||
};
|
||||
|
||||
Toast.prototype.show = function (message, duration, position, successCallback, errorCallback) {
|
||||
this.showWithOptions(
|
||||
this.optionsBuilder()
|
||||
.withMessage(message)
|
||||
.withDuration(duration)
|
||||
.withPosition(position)
|
||||
.build(),
|
||||
successCallback,
|
||||
errorCallback);
|
||||
cordova.exec(successCallback, errorCallback, "Toast", "show", [message, duration, position]);
|
||||
};
|
||||
|
||||
Toast.prototype.showShortTop = function (message, successCallback, errorCallback) {
|
||||
@ -83,10 +29,6 @@ Toast.prototype.showLongBottom = function (message, successCallback, errorCallba
|
||||
this.show(message, "long", "bottom", successCallback, errorCallback);
|
||||
};
|
||||
|
||||
Toast.prototype.hide = function (successCallback, errorCallback) {
|
||||
cordova.exec(successCallback, errorCallback, "Toast", "hide", []);
|
||||
};
|
||||
|
||||
Toast.install = function () {
|
||||
if (!window.plugins) {
|
||||
window.plugins = {};
|
||||
|
Loading…
Reference in New Issue
Block a user