diff --git a/bugs.txt b/bugs.txt index 1a2b26187..c2b476e7c 100644 --- a/bugs.txt +++ b/bugs.txt @@ -3,6 +3,8 @@ Known bugs - With 4:3 screen aspect ratio the on-screen buttons are not shown on the inactive part of screen. +- Put video at the center of the screen with 4:3 aspect ratio option + - Calling SDL_SetVideoMode() with SDL 1.3 several times makes it crash. - Calling SDL_Init()/SDL_Quit() several times will make SDL 1.2 crash. @@ -11,15 +13,13 @@ Known bugs - 32-bpp color mode does not work with SW video surface, 24-bpp and 32-bpp mode does not work with SDL_HWSURFACE. +- Option SdlVideoResizeKeepAspect has no effect + Requested features ================== -- Support for resuming download of partially-downloaded files. - - Perform a check for free space available on SD card before writing there, and write to the internal storage if SD card is unplugged. -- Force SW video mode from AndroidAppSettings.cfg, ignore SDL_HWSURFACE if app does not explicitly support it. - - Split Settings.java into several files - Show/hide screen controls with longpress on Text Edit button. diff --git a/build.sh b/build.sh index 35cd40f3a..e15231af4 100755 --- a/build.sh +++ b/build.sh @@ -3,6 +3,13 @@ install_apk=false run_apk=false +sign_apk=false +build_release=false + +if [ "$#" -gt 0 -a "$1" = "-s" ]; then + shift + sign_apk=true +fi if [ "$#" -gt 0 -a "$1" = "-i" ]; then shift @@ -15,7 +22,12 @@ if [ "$#" -gt 0 -a "$1" = "-r" ]; then run_apk=true fi -[ -e local.properties ] || { +if [ "$#" -gt 0 -a "$1" = "release" ]; then + shift + build_release=true +fi + +[ -e project/local.properties ] || { android update project -p project || exit 1 rm -f project/src/Globals.java } @@ -23,14 +35,16 @@ fi # export PATH=$PATH:~/src/endless_space/android-ndk-r7 NDKBUILDPATH=$PATH export `grep "AppFullName=" AndroidAppSettings.cfg` -if ( grep "package $AppFullName;" project/src/Globals.java > /dev/null && \ +if ( grep "package $AppFullName;" project/src/Globals.java > /dev/null 2>&1 && \ [ "`readlink AndroidAppSettings.cfg`" -ot "project/src/Globals.java" ] && \ - [ -z "`find project/java/* project/AndroidManifestTemplate.xml -cnewer project/src/Globals.java`" ] && \ - [ -z "`find project/jni/application/src/AndroidData/* -cnewer project/src/Globals.java`" ] ) ; then true ; else + [ -z "`find project/java/* project/AndroidManifestTemplate.xml -cnewer project/src/Globals.java`" ] ) ; then true ; else ./changeAppSettings.sh -a sleep 1 touch project/src/Globals.java fi +if $build_release ; then + sed -i 's/android:debuggable="true"/android:debuggable="false"/g' project/AndroidManifest.xml +fi MYARCH=linux-x86 NCPU=4 @@ -51,31 +65,39 @@ rm -r -f project/bin/* # New Android SDK introduced some lame-ass optimizations ./AndroidPreBuild.sh || { echo "AndroidPreBuild.sh returned with error" ; exit 1 ; } cd ../../../.. } + cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU nice -n19 ndk-build -j$NCPU V=1 && \ - { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \ - echo Stripping libapplication.so by hand && \ - rm obj/local/armeabi/libapplication.so && \ - cp jni/application/src/libapplication.so obj/local/armeabi/ && \ - cp jni/application/src/libapplication.so libs/armeabi/ && \ - `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \ - || true ; } && \ - { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \ - grep "MultiABI=y" ../AndroidAppSettings.cfg > /dev/null && \ - echo Stripping libapplication-armeabi-v7a.so by hand && \ - rm obj/local/armeabi-v7a/libapplication.so && \ - cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \ - cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \ - `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so \ - || true ; } && \ - cd .. && ./copyAssets.sh && cd project && \ - ant debug && \ - $install_apk && [ -n "`adb devices | tail -n +2`" ] && \ - { cd bin && adb install -r MainActivity-debug.apk | grep 'Failure' && \ - adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; true ; } && \ - $run_apk && { - ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" - RUN_APK="adb shell am start -n $ActivityName" - echo "Running $ActivityName on the USB-connected device:" - echo "$RUN_APK" - eval $RUN_APK - } + { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \ + echo Stripping libapplication.so by hand && \ + rm obj/local/armeabi/libapplication.so && \ + cp jni/application/src/libapplication.so obj/local/armeabi/ && \ + cp jni/application/src/libapplication.so libs/armeabi/ && \ + `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \ + || true ; } && \ + { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \ + grep "MultiABI=y" ../AndroidAppSettings.cfg > /dev/null && \ + echo Stripping libapplication-armeabi-v7a.so by hand && \ + rm obj/local/armeabi-v7a/libapplication.so && \ + cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \ + cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \ + `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so \ + || true ; } && \ + cd .. && ./copyAssets.sh && cd project && \ + { if $build_release ; then \ + ant release || exit 1 ; \ + jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -sigalg MD5withRSA -digestalg SHA1 bin/MainActivity-release-unsigned.apk androiddebugkey || exit 1 ; \ + zipalign 4 bin/MainActivity-release-unsigned.apk bin/MainActivity-debug.apk ; \ + else \ + ant debug ; \ + fi ; } && \ + { if $sign_apk; then cd .. && ./sign.sh && cd project ; else true ; fi ; } && \ + $install_apk && [ -n "`adb devices | tail -n +2`" ] && \ + { cd bin && adb install -r MainActivity-debug.apk | grep 'Failure' && \ + adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; true ; } && \ + $run_apk && { \ + ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" ; \ + RUN_APK="adb shell am start -n $ActivityName" ; \ + echo "Running $ActivityName on the USB-connected device:" ; \ + echo "$RUN_APK" ; \ + eval $RUN_APK ; \ + } diff --git a/changeAppSettings.sh b/changeAppSettings.sh index 4d18832bd..fb52f35fe 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -630,7 +630,7 @@ fi if [ -z "$AUTO" -o -z "$MinimumScreenSize" ]; then echo echo "Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens" -echo -n "Minimum screen size that application supports: (s)mall / (n)ormal / (l)arge ($MinimumScreenSize): " +echo -n "Minimum screen size that application supports: (s)mall / (m)edium / (l)arge ($MinimumScreenSize): " read var if [ -n "$var" ] ; then MinimumScreenSize="$var" @@ -662,6 +662,7 @@ echo CompatibilityHacksStaticInit=$CompatibilityHacksStaticInit >> AndroidAppSet echo CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputEmulatesHwKeyboard >> AndroidAppSettings.cfg echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg echo CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize >> AndroidAppSettings.cfg +echo CompatibilityHacksAdditionalPreloadedSharedLibraries=\"$CompatibilityHacksAdditionalPreloadedSharedLibraries\" >> AndroidAppSettings.cfg echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg @@ -879,7 +880,7 @@ fi LibrariesToLoad="\\\"sdl-$LibSdlVersion\\\"" StaticLibraries=`grep 'APP_AVAILABLE_STATIC_LIBS' project/jni/SettingsTemplate.mk | sed 's/.*=\(.*\)/\1/'` -for lib in $CompiledLibraries; do +for lib in $CompiledLibraries $CompatibilityHacksAdditionalPreloadedSharedLibraries; do process=true for lib1 in $StaticLibraries; do if [ "$lib" = "$lib1" ]; then process=false; fi diff --git a/createSourceArchive.sh b/createSourceArchive.sh index ce3421304..6e152b1a5 100755 --- a/createSourceArchive.sh +++ b/createSourceArchive.sh @@ -8,7 +8,7 @@ APPVER=`grep AppVersionName AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tar -c -z --exclude-vcs --exclude="*.o" --exclude="*.d" --exclude="*.dep" \ -f $APPNAME-$APPVER-src.tar.gz \ `git ls-files --exclude-standard | grep -v '^project/jni/application/.*'` \ -`find project/jni/application -maxdepth 1 -type f` \ +`find project/jni/application -maxdepth 1 -type f -o -type l` \ project/jni/application/src \ project/jni/application/`readlink project/jni/application/src` \ project/AndroidManifest.xml project/src diff --git a/project/java/GLSurfaceView_SDL.java b/project/java/GLSurfaceView_SDL.java index 09bdc0c72..a0c6c4cba 100644 --- a/project/java/GLSurfaceView_SDL.java +++ b/project/java/GLSurfaceView_SDL.java @@ -674,6 +674,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call String cfglog = ""; int idx = 0; int selectidx = -1; + + Log.v("SDL", "Desired GL config: " + "R" + mRedSize + "G" + mGreenSize + "B" + mBlueSize + "A" + mAlphaSize + " depth " + mDepthSize + " stencil " + mStencilSize + " type " + (mIsGles2 ? "GLES2" : "GLES")); for(EGLConfig config : configs) { if ( config == null ) continue; @@ -699,12 +701,16 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize); + int dist2 = distance; if( (d > 0) != (mDepthSize > 0) ) - distance += (d > 0) ? 5 : 1; // Small penalty if we don't need zbuffer but it is present - if( (s > 0) == (mStencilSize > 0) ) - distance += (s > 0) ? 5 : 1; + distance += (mDepthSize > 0) ? 5 : 1; // Small penalty if we don't need zbuffer but it is present + int dist3 = distance; + if( (s > 0) != (mStencilSize > 0) ) + distance += (mStencilSize > 0) ? 5 : 1; + int dist4 = distance; if( (rendertype & desiredtype) == 0 ) distance += 5; + int dist5 = distance; if( caveat == EGL10.EGL_SLOW_CONFIG ) distance += 4; if( caveat == EGL10.EGL_NON_CONFORMANT_CONFIG ) // dunno what that means, probably R and B channels swapped @@ -726,7 +732,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call caveat == EGL10.EGL_NON_CONFORMANT_CONFIG ? "non-conformant" : String.valueOf(caveat))); cfgcur += " nr " + nativeRender; - cfgcur += " pos " + distance; + cfgcur += " pos " + distance + " (" + dist2 + "," + dist3 + "," + dist4 + "," + dist5 + ")"; Log.v("SDL", "GL config " + idx + ": " + cfgcur); if (distance < closestDistance) { closestDistance = distance; @@ -890,6 +896,14 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call /* * Create an EGL surface we can render into. */ + /* + // This does not have any effect on Galaxy Note + int [] attribList = new int[4]; + attribList[0] = mEgl.EGL_RENDER_BUFFER; + attribList[1] = mEgl.EGL_SINGLE_BUFFER; + attribList[2] = mEgl.EGL_NONE; + attribList[3] = mEgl.EGL_NONE; + */ mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay, mEglConfig, holder, null); diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 5d3375b0b..90b26f20e 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -72,6 +72,7 @@ import android.os.Message; import java.util.concurrent.Semaphore; import android.content.pm.ActivityInfo; import android.view.Display; +import android.text.InputType; public class MainActivity extends Activity { @@ -293,8 +294,10 @@ public class MainActivity extends Activity _tv = null; _inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); _videoLayout = new FrameLayout(this); + SetLayerType.get().setLayerType(_videoLayout); setContentView(_videoLayout); mGLView = new DemoGLSurfaceView(this); + SetLayerType.get().setLayerType(mGLView); _videoLayout.addView(mGLView); mGLView.setFocusableInTouchMode(true); mGLView.setFocusable(true); @@ -418,13 +421,35 @@ public class MainActivity extends Activity _parent.hideScreenKeyboard(); return true; } - if ((sendBackspace && event.getAction() == KeyEvent.ACTION_UP) && (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR)) + if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR) { - synchronized(textInput) { - DemoRenderer.nativeTextInput( 8, 0 ); // Send backspace to native code + if (sendBackspace && event.getAction() == KeyEvent.ACTION_UP) + { + synchronized(textInput) { + DemoRenderer.nativeTextInput( 8, 0 ); // Send backspace to native code + } + } + // EditText deletes two characters at a time, here's a hacky fix + if (event.getAction() == KeyEvent.ACTION_DOWN && (event.getFlags() | KeyEvent.FLAG_SOFT_KEYBOARD) != 0) + { + EditText t = (EditText) v; + int start = t.getSelectionStart(); //get cursor starting position + int end = t.getSelectionEnd(); //get cursor ending position + if ( start < 0 ) + return true; + if ( end < 0 || end == start ) + { + start --; + if ( start < 0 ) + return true; + end = start + 1; + } + t.setText(t.getText().toString().substring(0, start) + t.getText().toString().substring(end)); + t.setSelection(start); + return true; } - return false; // and proceed to delete text in keyboard input field } + //System.out.println("Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction()); return false; } }; @@ -433,7 +458,8 @@ public class MainActivity extends Activity _screenKeyboard.setOnKeyListener(new simpleKeyListener(this, sendBackspace)); _screenKeyboard.setHint(R.string.text_edit_click_here); _screenKeyboard.setText(oldText); - _screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false)); + //_screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false)); + _screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); _screenKeyboard.setFocusableInTouchMode(true); _screenKeyboard.setFocusable(true); _screenKeyboard.requestFocus(); @@ -812,15 +838,18 @@ public class MainActivity extends Activity } // ----- VCMI hack ----- + String [] binaryZipNames = { "binaries-" + android.os.Build.CPU_ABI + ".zip", "binaries.zip" }; + for(String binaryZip: binaryZipNames) + { try { - //System.out.println("libSDL: Extracting binaries"); + System.out.println("libSDL: Trying to extract binaries from assets " + binaryZip); InputStream in = null; try { for( int i = 0; ; i++ ) { - InputStream in2 = getAssets().open("binaries.zip" + String.format("%02d", i)); + InputStream in2 = getAssets().open(binaryZip + String.format("%02d", i)); if( in == null ) in = in2; else @@ -832,7 +861,7 @@ public class MainActivity extends Activity try { if( in == null ) - in = getAssets().open("binaries.zip"); + in = getAssets().open(binaryZip); } catch( IOException eee ) {} } @@ -911,6 +940,7 @@ public class MainActivity extends Activity { //System.out.println("libSDL: Error: " + eee.toString()); } + } // ----- VCMI hack ----- }; @@ -1029,3 +1059,38 @@ abstract class DimSystemStatusBar } } } + +abstract class SetLayerType +{ + public static SetLayerType get() + { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) + return SetLayerTypeHoneycomb.Holder.sInstance; + else + return SetLayerTypeDummy.Holder.sInstance; + } + public abstract void setLayerType(final View view); + + private static class SetLayerTypeHoneycomb extends SetLayerType + { + private static class Holder + { + private static final SetLayerTypeHoneycomb sInstance = new SetLayerTypeHoneycomb(); + } + public void setLayerType(final View view) + { + view.setLayerType(android.view.View.LAYER_TYPE_NONE, null); + //view.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null); + } + } + private static class SetLayerTypeDummy extends SetLayerType + { + private static class Holder + { + private static final SetLayerTypeDummy sInstance = new SetLayerTypeDummy(); + } + public void setLayerType(final View view) + { + } + } +} diff --git a/project/java/Settings.java b/project/java/Settings.java index 0b1f25bfd..11e30a543 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -66,6 +66,7 @@ import android.app.AlarmManager; import android.util.DisplayMetrics; import android.net.Uri; import java.util.concurrent.Semaphore; +import android.graphics.Color; // TODO: too much code here, split into multiple files, possibly auto-generated menus? class Settings @@ -299,23 +300,25 @@ class Settings Globals.BrokenLibCMessageShown = settingsFile.readBoolean(); Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt(); int cfgVersion = settingsFile.readInt(); + + settingsLoaded = true; + + System.out.println("libSDL: Settings.Load(): loaded settings successfully"); + settingsFile.close(); + System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion()); - if( cfgVersion < p.getApplicationVersion() ) + if( cfgVersion != p.getApplicationVersion() ) { DeleteFilesOnUpgrade(); if( Globals.ResetSdlConfigForThisVersion ) { System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file"); // Delete settings file, and restart the application - settingsFile.close(); DeleteSdlConfigOnUpgradeAndRestart(p); } + Save(p); } - - settingsLoaded = true; - System.out.println("libSDL: Settings.Load(): loaded settings successfully"); - settingsFile.close(); return; } catch( FileNotFoundException e ) { @@ -627,7 +630,7 @@ class Settings { Globals.DownloadToSdcard = (item != 0); Globals.DataDir = Globals.DownloadToSdcard ? - Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() : + SdcardAppPath.getPath(p) : p.getFilesDir().getAbsolutePath(); goBack(p); } @@ -2192,8 +2195,10 @@ class Settings { MainActivity p; FrameLayout layout = null; - ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length]; + ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length]; Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length]; + ImageView boundary = null; + Bitmap boundaryBmp = null; int currentButton = 0; int buttons[] = { R.drawable.dpad, @@ -2211,7 +2216,27 @@ class Settings p = _p; layout = new FrameLayout(p); p.getVideoLayout().addView(layout); + boundary = new ImageView(p); + boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); + boundary.setScaleType(ImageView.ScaleType.MATRIX); + boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle ); + boundary.setImageBitmap(boundaryBmp); + layout.addView(boundary); currentButton = 0; + if( Globals.TouchscreenKeyboardTheme == 2 ) + { + int buttons2[] = { + R.drawable.sun_dpad, + R.drawable.sun_keyboard, + R.drawable.sun_b1, + R.drawable.sun_b2, + R.drawable.sun_b3, + R.drawable.sun_b4, + R.drawable.sun_b5, + R.drawable.sun_b6 + }; + buttons = buttons2; + } setupButton(true); } @@ -2238,11 +2263,28 @@ class Settings if( imgs[currentButton] == null ) { imgs[currentButton] = new ImageView(p); - imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); + imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX); bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] ); imgs[currentButton].setImageBitmap(bmps[currentButton]); layout.addView(imgs[currentButton]); + boundary.bringToFront(); + } + if( Globals.ScreenKbControlsLayout[currentButton][0] == Globals.ScreenKbControlsLayout[currentButton][2] || + Globals.ScreenKbControlsLayout[currentButton][1] == Globals.ScreenKbControlsLayout[currentButton][3] ) + { + int displayX = 800; + int displayY = 480; + try { + DisplayMetrics dm = new DisplayMetrics(); + p.getWindowManager().getDefaultDisplay().getMetrics(dm); + displayX = dm.widthPixels; + displayY = dm.heightPixels; + } catch (Exception eeeee) {} + Globals.ScreenKbControlsLayout[currentButton][0] = displayX / 2 - displayX / 6; + Globals.ScreenKbControlsLayout[currentButton][2] = displayX / 2 + displayX / 6; + Globals.ScreenKbControlsLayout[currentButton][1] = displayY / 2 - displayY / 4; + Globals.ScreenKbControlsLayout[currentButton][3] = displayY / 2 + displayY / 4; } Matrix m = new Matrix(); RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight()); @@ -2250,11 +2292,15 @@ class Settings Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]); m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); imgs[currentButton].setImageMatrix(m); + m = new Matrix(); + src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight()); + m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); + boundary.setImageMatrix(m); } public void onTouchEvent(final MotionEvent ev) { - if(Globals.ScreenKbControlsLayout.length >= currentButton) + if(currentButton >= Globals.ScreenKbControlsLayout.length) { setupButton(false); return; @@ -2284,6 +2330,10 @@ class Settings Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]); m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); imgs[currentButton].setImageMatrix(m); + m = new Matrix(); + src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight()); + m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); + boundary.setImageMatrix(m); if( ev.getAction() == MotionEvent.ACTION_UP ) setupButton(false); diff --git a/project/jni/Application.mk b/project/jni/Application.mk index 2703fbab3..67c270a22 100644 --- a/project/jni/Application.mk +++ b/project/jni/Application.mk @@ -2,7 +2,7 @@ APP_PROJECT_PATH := $(call my-dir)/.. APP_STL := gnustl_static APP_CFLAGS := -O3 -DNDEBUG -g # arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources -APP_PLATFORM := android-9 # Android 2.3.0 or newer, includes EGL headers +APP_PLATFORM := android-14 # Android 4.0, it should be backward compatible to previous versions include jni/Settings.mk diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index 6961c56e0..c09e6df42 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -15,7 +15,7 @@ SdlVideoResize=y SdlVideoResizeKeepAspect=n CompatibilityHacks=n CompatibilityHacksStaticInit=n -CompatibilityHacksTextInputEmulatesHwKeyboard=y +CompatibilityHacksTextInputEmulatesHwKeyboard=n CompatibilityHacksPreventAudioChopping=n CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=y @@ -29,13 +29,13 @@ AppUsesAccelerometer=y AppUsesMultitouch=y NonBlockingSwapBuffers=n RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE" -AppTouchscreenKeyboardKeysAmount=0 +AppTouchscreenKeyboardKeysAmount=6 AppTouchscreenKeyboardKeysAmountAutoFire=0 RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9" StartupMenuButtonTimeout=3000 HiddenMenuOptions='OptionalDownloadConfig' FirstStartMenuOptions='' -MultiABI=n +MultiABI=y AppMinimumRAM=0 AppVersionCode=101 AppVersionName="1.01" diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index a416d38f3..2c78f8011 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -14,8 +14,9 @@ #include #include -#include "SDL.h" -#include "SDL_image.h" +#include +#include +#include #define fprintf(X, ...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__) #define printf(...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__) @@ -438,9 +439,11 @@ int main(int argc, char* argv[]) struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS]; int accel[2], screenjoy[2]; SDL_Surface *mouse[4]; + int screenKeyboardShown = 0; SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); + SDL_EnableUNICODE(1); atexit(SDL_Quit); @@ -632,7 +635,7 @@ int main(int argc, char* argv[]) { if(evt.type == SDL_KEYUP || evt.type == SDL_KEYDOWN) { - __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %d scancode %d mod %d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode); + __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, SDL_GetKeyName(evt.key.keysym.sym), (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode); if(evt.key.keysym.sym == SDLK_ESCAPE) return 0; } @@ -671,6 +674,11 @@ int main(int argc, char* argv[]) touchPointers[evt.jball.ball].y = evt.jball.yrel; } } + if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL)) + { + __android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen keyboard shown: %d -> %d", screenKeyboardShown, SDL_IsScreenKeyboardShown(NULL)); + screenKeyboardShown = SDL_IsScreenKeyboardShown(NULL); + } /* Animate */ x_speed = 500.0 * sin(t * 0.37); diff --git a/project/jni/application/commandergenius/AndroidAppSettings.cfg b/project/jni/application/commandergenius/AndroidAppSettings.cfg index 7ada9c184..1b64257bb 100644 --- a/project/jni/application/commandergenius/AndroidAppSettings.cfg +++ b/project/jni/application/commandergenius/AndroidAppSettings.cfg @@ -17,7 +17,7 @@ CompatibilityHacks=n CompatibilityHacksStaticInit=n CompatibilityHacksTextInputEmulatesHwKeyboard=n CompatibilityHacksPreventAudioChopping=n -CompatibilityHacksAppIgnoresAudioBufferSize= +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=n AppNeedsTwoButtonMouse=n ShowMouseCursor=n @@ -37,8 +37,8 @@ HiddenMenuOptions='' FirstStartMenuOptions='' MultiABI=n AppMinimumRAM=32 -AppVersionCode=100005 -AppVersionName="1.0 RC-5" +AppVersionCode=100011 +AppVersionName="1.0 Release" ResetSdlConfigForThisVersion=n DeleteFilesOnUpgrade="%" CompiledLibraries="tremor ogg" diff --git a/project/jni/application/commandergenius/AndroidData/keen1.zip b/project/jni/application/commandergenius/AndroidData/keen1.zip deleted file mode 100644 index 6134b4a4e..000000000 Binary files a/project/jni/application/commandergenius/AndroidData/keen1.zip and /dev/null differ diff --git a/project/jni/application/commandergenius/AndroidData/keen4.zip b/project/jni/application/commandergenius/AndroidData/keen4.zip deleted file mode 100644 index 3a769226e..000000000 Binary files a/project/jni/application/commandergenius/AndroidData/keen4.zip and /dev/null differ diff --git a/project/jni/application/commandergenius/AndroidData/keen7.zip b/project/jni/application/commandergenius/AndroidData/keen7.zip deleted file mode 100644 index d76ba7b1a..000000000 Binary files a/project/jni/application/commandergenius/AndroidData/keen7.zip and /dev/null differ diff --git a/project/jni/application/freetype-config b/project/jni/application/freetype-config index a8f68bc27..f411ae5a5 100755 --- a/project/jni/application/freetype-config +++ b/project/jni/application/freetype-config @@ -13,10 +13,10 @@ LOCAL_PATH=`dirname $0` LOCAL_PATH=`cd $LOCAL_PATH && pwd` prefix=$LOCAL_PATH/../freetype -exec_prefix=$LOCAL_PATH/../../obj/local/armeabi +#exec_prefix=$LOCAL_PATH/../../obj/local/armeabi # Breaks armeabi-v7a build exec_prefix_set=no includedir=${prefix}/include -libdir=${exec_prefix}/lib +#libdir=${exec_prefix}/lib enable_shared= wl=-Wl, hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' @@ -146,7 +146,7 @@ if test "$echo_libs" = "yes" ; then fi libs="-lfreetype " if test "$libdir" != "/usr/lib" && test "$libdir" != "/usr/lib64"; then - echo -L$libdir $rpath $libs + echo $rpath $libs #-L$libdir else echo $libs fi diff --git a/project/jni/application/gemrb/AndroidAppSettings.cfg b/project/jni/application/gemrb/AndroidAppSettings.cfg index 3d2f633df..f36d324ce 100644 --- a/project/jni/application/gemrb/AndroidAppSettings.cfg +++ b/project/jni/application/gemrb/AndroidAppSettings.cfg @@ -14,6 +14,10 @@ SwVideoMode=y SdlVideoResize=y SdlVideoResizeKeepAspect=y CompatibilityHacks=n +CompatibilityHacksStaticInit=n +CompatibilityHacksTextInputEmulatesHwKeyboard=n +CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=y AppNeedsTwoButtonMouse=y ShowMouseCursor=n @@ -21,7 +25,7 @@ ForceRelativeMouseMode=n AppNeedsArrowKeys=n AppNeedsTextInput=y AppUsesJoystick=n -AppHandlesJoystickSensitivity=n +AppUsesAccelerometer=n AppUsesMultitouch=n NonBlockingSwapBuffers=n RedefinedKeys="LCTRL c NO_REMAP NO_REMAP e" @@ -32,9 +36,11 @@ StartupMenuButtonTimeout=2000 HiddenMenuOptions='' FirstStartMenuOptions='' MultiABI=y +AppMinimumRAM=0 AppVersionCode=0701 AppVersionName="0.7.0.1" ResetSdlConfigForThisVersion=y +DeleteFilesOnUpgrade="%" CompiledLibraries="sdl_mixer sdl_ttf ogg vorbis openal png python" CustomBuildScript=n AppCflags='-fexceptions -finline-functions -O3 -DSTATIC_LINK=Yes -DHAVE_SNPRINTF' @@ -42,3 +48,7 @@ AppLdflags='' AppSubdirsBuild='gemrb/gemrb/*' AppCmdline='GemRB' ReadmeText='^You may press "Home" now - the data will be downloaded in background' +MinimumScreenSize=m +AdmobPublisherId=n +AdmobTestDeviceId= +AdmobBannerSize= diff --git a/project/jni/application/openarena/AndroidAppSettings.cfg b/project/jni/application/openarena/AndroidAppSettings.cfg index cbee5e740..f663b7649 100644 --- a/project/jni/application/openarena/AndroidAppSettings.cfg +++ b/project/jni/application/openarena/AndroidAppSettings.cfg @@ -5,10 +5,10 @@ AppName="OpenArena" AppFullName=ws.openarena.sdl ScreenOrientation=h InhibitSuspend=n -AppDataDownloadUrl="!Game data|:baseoa/pak0.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak0.pk3/download^!Game data|:baseoa/pak1-maps.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak1-maps.pk3/download^!Game data|:baseoa/pak2-players-mature.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak2-players-mature.pk3/download^!Game data|:baseoa/pak2-players.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak2-players.pk3/download^!Game data|:baseoa/pak4-textures.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak4-textures.pk3/download^!Game data|:baseoa/pak5-TA.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak5-TA.pk3/download^!Game data|:baseoa/pak6-misc.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-misc.pk3/download^!Game data|:baseoa/pak6-patch085.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-patch085.pk3/download^!Game data|:baseoa/pak6-patch088.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-patch088.pk3/download^!Game data|:baseoa/skn-arachna-forlorna.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/skn-arachna-forlorna.pk3/download^!Game logic|:baseoa/pak7-android.pk3:vm.zip" +AppDataDownloadUrl="!Game data|:baseoa/pak0.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak0.pk3/download^!Game data|:baseoa/pak1-maps.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak1-maps.pk3/download^!Game data|:baseoa/pak2-players-mature.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak2-players-mature.pk3/download^!Game data|:baseoa/pak2-players.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak2-players.pk3/download^!Game data|:baseoa/pak4-textures.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak4-textures.pk3/download^!Game data|:baseoa/pak5-TA.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak5-TA.pk3/download^!Game data|:baseoa/pak6-misc.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-misc.pk3/download^!Game data|:baseoa/pak6-patch085.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-patch085.pk3/download^!Game data|:baseoa/pak6-patch088.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/pak6-patch088.pk3/download^!Game data|:baseoa/skn-arachna-forlorna.pk3:http://sourceforge.net/projects/libsdl-android/files/OpenArena/0.8.8/skn-arachna-forlorna.pk3/download^!Game logic|:baseoa/pak7-android.pk3:pak7-android.pk3" VideoDepthBpp=24 NeedDepthBuffer=y -NeedStencilBuffer=y +NeedStencilBuffer=n NeedGles2=n SwVideoMode=n SdlVideoResize=y @@ -25,21 +25,21 @@ ForceRelativeMouseMode=n AppNeedsArrowKeys=y AppNeedsTextInput=y AppUsesJoystick=y -AppUsesAccelerometer=y +AppUsesAccelerometer=n AppUsesMultitouch=y NonBlockingSwapBuffers=n RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE" -AppTouchscreenKeyboardKeysAmount=3 +AppTouchscreenKeyboardKeysAmount=5 AppTouchscreenKeyboardKeysAmountAutoFire=0 -RedefinedKeysScreenKb="SLASH BACKSPACE TAB RETURN UNKNOWN UNKNOWN UNKNOWN UNKNOWN UNKNOWN UNKNOWN" +RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN" StartupMenuButtonTimeout=3000 HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig' FirstStartMenuOptions='' MultiABI=y -AppMinimumRAM=350 -AppVersionCode=08804 -AppVersionName="0.8.8.04" -ResetSdlConfigForThisVersion=y +AppMinimumRAM=300 +AppVersionCode=08818 +AppVersionName="0.8.8.18" +ResetSdlConfigForThisVersion=n DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag" CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg" CustomBuildScript=y diff --git a/project/jni/application/openarena/AndroidBuild.sh b/project/jni/application/openarena/AndroidBuild.sh index 18255f993..0aaacfeed 100755 --- a/project/jni/application/openarena/AndroidBuild.sh +++ b/project/jni/application/openarena/AndroidBuild.sh @@ -3,16 +3,19 @@ LOCAL_PATH=`dirname $0` LOCAL_PATH=`cd $LOCAL_PATH && pwd` -[ "$1" = "armeabi" ] && ( -mkdir -p AndroidData -[ -e libapplication.so ] || ln -s libapplication-armeabi.so libapplication.so -make -j8 -C vm BUILD_MISSIONPACK=0 || exit 1 -cd vm/build/release-linux-`uname -m`/baseq3 -rm -f ../../../../AndroidData/binaries.zip ../../../../AndroidData/vm.zip -zip -r ../../../../AndroidData/vm.zip vm -cd ../../../android -zip ../../AndroidData/vm.zip * -) +if [ "$1" = "armeabi" ]; then ( + mkdir -p AndroidData + [ -e libapplication.so ] || ln -s libapplication-armeabi.so libapplication.so + make -j8 -C vm BUILD_MISSIONPACK=0 || exit 1 + cd vm/build/release-linux-`uname -m`/baseq3 + #rm -f ../../../../AndroidData/binaries.zip ../../../../AndroidData/pak7-android.pk3 + zip -r ../../../../AndroidData/pak7-android.pk3 vm + cd ../../../android + zip -r ../../AndroidData/pak7-android.pk3 * + ln -sf ../engine/misc/quake3-tango.png ../../AndroidData/logo.png + exit 0 +) || exit 1 +fi env NO_SHARED_LIBS=1 BUILD_EXECUTABLE=1 V=1 ../setEnvironment-armeabi.sh make -C vm -j8 PLATFORM=android ARCH=$1 USE_LOCAL_HEADERS=0 BUILD_MISSIONPACK=0 || exit 1 diff --git a/project/jni/application/openarena/engine b/project/jni/application/openarena/engine index f298c6ef3..d005816c5 160000 --- a/project/jni/application/openarena/engine +++ b/project/jni/application/openarena/engine @@ -1 +1 @@ -Subproject commit f298c6ef3eaf5f1756ce3439ef1974ee5bb140fc +Subproject commit d005816c5b89a577f9127203dc31f7365a565edf diff --git a/project/jni/application/openarena/oa-reupload-vm.sh b/project/jni/application/openarena/oa-reupload-vm.sh index ee9faa0ce..58e4829ae 100755 --- a/project/jni/application/openarena/oa-reupload-vm.sh +++ b/project/jni/application/openarena/oa-reupload-vm.sh @@ -1,2 +1,3 @@ #!/bin/sh adb shell rm /sdcard/Android/data/ws.openarena.sdl/files/libsdl-DownloadFinished-10.flag +adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena diff --git a/project/jni/application/openarena/vm b/project/jni/application/openarena/vm index 4a39bfea3..3546f88fc 160000 --- a/project/jni/application/openarena/vm +++ b/project/jni/application/openarena/vm @@ -1 +1 @@ -Subproject commit 4a39bfea3fa1250fb19a674bcbec4d0cfbfb8d50 +Subproject commit 3546f88fcf261df1322d8a47d517446e87ed5fc4 diff --git a/project/jni/application/openttd/AndroidAppSettings.cfg b/project/jni/application/openttd/AndroidAppSettings.cfg index b63ad949d..7bf0af636 100644 --- a/project/jni/application/openttd/AndroidAppSettings.cfg +++ b/project/jni/application/openttd/AndroidAppSettings.cfg @@ -17,6 +17,7 @@ CompatibilityHacks=n CompatibilityHacksStaticInit=n CompatibilityHacksTextInputEmulatesHwKeyboard=n CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=y AppNeedsTwoButtonMouse=y ShowMouseCursor=n diff --git a/project/jni/application/pachi/AndroidAppSettings.cfg b/project/jni/application/pachi/AndroidAppSettings.cfg index 3ab564891..a5055b48c 100644 --- a/project/jni/application/pachi/AndroidAppSettings.cfg +++ b/project/jni/application/pachi/AndroidAppSettings.cfg @@ -1,34 +1,54 @@ # The application settings for Android libSDL port -AppSettingVersion=16 +AppSettingVersion=17 LibSdlVersion=1.2 AppName="Pachi el marciano" AppFullName=net.sourceforge.dragontech.pachi ScreenOrientation=h InhibitSuspend=n AppDataDownloadUrl="Game data is 30 Mb|http://sourceforge.net/projects/libsdl-android/files/Pachi/pachi.zip/download" +VideoDepthBpp=16 +NeedDepthBuffer=n +NeedStencilBuffer=n +NeedGles2=n +SwVideoMode=y SdlVideoResize=y SdlVideoResizeKeepAspect=n -NeedDepthBuffer=n +CompatibilityHacks=n +CompatibilityHacksStaticInit=n +CompatibilityHacksTextInputEmulatesHwKeyboard=n +CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=n AppNeedsTwoButtonMouse=n +ShowMouseCursor=n +ForceRelativeMouseMode=n AppNeedsArrowKeys=y AppNeedsTextInput=y AppUsesJoystick=n -AppHandlesJoystickSensitivity=n +AppUsesAccelerometer=n AppUsesMultitouch=n NonBlockingSwapBuffers=n RedefinedKeys="SPACE RETURN" AppTouchscreenKeyboardKeysAmount=1 AppTouchscreenKeyboardKeysAmountAutoFire=0 RedefinedKeysScreenKb="SPACE RETURN" +StartupMenuButtonTimeout=3000 +HiddenMenuOptions='' +FirstStartMenuOptions='' MultiABI=n -AppVersionCode=104 -AppVersionName="1.04" +AppMinimumRAM=0 +AppVersionCode=106 +AppVersionName="1.06" +ResetSdlConfigForThisVersion=y +DeleteFilesOnUpgrade="%" CompiledLibraries="sdl_mixer" CustomBuildScript=n AppCflags='-O2 -finline-functions -Wno-write-strings' AppLdflags='' AppSubdirsBuild='' -AppUseCrystaXToolchain=n AppCmdline='' ReadmeText='^You may press "Home" now - the data will be downloaded in background' +MinimumScreenSize=n +AdmobPublisherId=n +AdmobTestDeviceId= +AdmobBannerSize= diff --git a/project/jni/application/sdl-config b/project/jni/application/sdl-config index 8aceb646f..2f5847e24 100755 --- a/project/jni/application/sdl-config +++ b/project/jni/application/sdl-config @@ -4,7 +4,7 @@ LOCAL_PATH=`dirname $0` LOCAL_PATH=`cd $LOCAL_PATH && pwd` prefix=$LOCAL_PATH/../sdl-1.2 -exec_prefix=$LOCAL_PATH/../../obj/local/armeabi +#exec_prefix=$LOCAL_PATH/../../obj/local/armeabi # Breaks armeabi-v7a build exec_prefix_set=no #usage="\ @@ -50,11 +50,11 @@ while test $# -gt 0; do echo -I${prefix}/include -D_GNU_SOURCE=1 -D_REENTRANT ;; --libs) - echo -L${exec_prefix} -lsdl-1.2 + echo -lsdl-1.2 #-L${exec_prefix} ;; --static-libs) # --libs|--static-libs) - echo -L${exec_prefix} -lsdl-1.2 + echo -lsdl-1.2 #-L${exec_prefix} ;; *) echo "${usage}" 1>&2 diff --git a/project/jni/application/setEnvironment-armeabi-v7a.sh b/project/jni/application/setEnvironment-armeabi-v7a.sh index 3effe667c..f30f15112 100755 --- a/project/jni/application/setEnvironment-armeabi-v7a.sh +++ b/project/jni/application/setEnvironment-armeabi-v7a.sh @@ -21,7 +21,7 @@ NDK=`readlink -f $NDK` #echo NDK $NDK GCCPREFIX=arm-linux-androideabi GCCVER=4.6 -PLATFORMVER=android-8 +PLATFORMVER=android-14 LOCAL_PATH=`dirname $0` LOCAL_PATH=`cd $LOCAL_PATH && pwd` ARCH=armeabi-v7a @@ -44,10 +44,10 @@ MISSING_INCLUDE= MISSING_LIB= CFLAGS="\ --fpic -ffunction-sections -funwind-tables \ --D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi \ --march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \ --DANDROID -Wa,--noexecstack -g -O2 -DNDEBUG -g \ +-fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \ +-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb \ +-Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \ +-DANDROID -O2 -g -finline-functions -Wa,--noexecstack \ -isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include \ -isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \ -isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \ @@ -55,30 +55,33 @@ CFLAGS="\ `echo $APP_MODULES | sed \"s@\([-a-zA-Z0-9_.]\+\)@-isystem$LOCAL_PATH/../\1/include@g\"` \ $MISSING_INCLUDE $CFLAGS" -SHARED="-shared -Wl,-soname,libapplication.so" + +if [ -z "$SHARED_LIBRARY_NAME" ]; then + SHARED_LIBRARY_NAME=libapplication.so +fi +UNRESOLVED="-Wl,--no-undefined" +SHARED="-shared -Wl,-soname,$SHARED_LIBRARY_NAME" if [ -n "$BUILD_EXECUTABLE" ]; then - SHARED= + SHARED="-Wl,--gc-sections -Wl,-z,nocopyreloc" fi if [ -n "$NO_SHARED_LIBS" ]; then APP_SHARED_LIBS= fi +if [ -n "$ALLOW_UNRESOLVED_SYMBOLS" ]; then + UNRESOLVED= +fi LDFLAGS="\ $SHARED \ --sysroot=$NDK/platforms/$PLATFORMVER/arch-arm \ +-L$LOCAL_PATH/../../obj/local/$ARCH \ `echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/$ARCH/lib\1.so@g\"` \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libc.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libm.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libGLESv1_CM.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libdl.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/liblog.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libz.so \ +-L$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib \ +-lc -lm -lGLESv1_CM -ldl -llog -lz \ -L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH \ -lgnustl_static \ --L$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib \ --L$LOCAL_PATH/../../obj/local/$ARCH \ --Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack \ --Wl,-rpath-link=$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib -lsupc++ \ +-no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 $UNRESOLVED -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \ +-lsupc++ \ $MISSING_LIB $LDFLAGS" #echo env CFLAGS=\""$CFLAGS"\" LDFLAGS=\""$LDFLAGS"\" "$@" diff --git a/project/jni/application/setEnvironment.sh b/project/jni/application/setEnvironment.sh index 6303ec185..d4606bf42 100755 --- a/project/jni/application/setEnvironment.sh +++ b/project/jni/application/setEnvironment.sh @@ -21,7 +21,7 @@ NDK=`readlink -f $NDK` #echo NDK $NDK GCCPREFIX=arm-linux-androideabi GCCVER=4.6 -PLATFORMVER=android-8 +PLATFORMVER=android-14 LOCAL_PATH=`dirname $0` if which realpath > /dev/null ; then LOCAL_PATH=`realpath $LOCAL_PATH` @@ -48,41 +48,43 @@ MISSING_INCLUDE= MISSING_LIB= CFLAGS="\ --fpic -ffunction-sections -funwind-tables -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi \ --march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \ --isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include -Wa,--noexecstack \ --DANDROID \ --DNDEBUG -O2 -g \ +-fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \ +-no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb \ +-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \ +-DANDROID -DNDEBUG -O2 -g -finline-functions -Wa,--noexecstack \ +-isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include \ -isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \ -isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \ -isystem$LOCAL_PATH/../sdl-1.2/include \ `echo $APP_MODULES | sed \"s@\([-a-zA-Z0-9_.]\+\)@-isystem$LOCAL_PATH/../\1/include@g\"` \ $MISSING_INCLUDE $CFLAGS" -SHARED="-shared -Wl,-soname,libapplication.so" +if [ -z "$SHARED_LIBRARY_NAME" ]; then + SHARED_LIBRARY_NAME=libapplication.so +fi +UNRESOLVED="-Wl,--no-undefined" +SHARED="-shared -Wl,-soname,$SHARED_LIBRARY_NAME" if [ -n "$BUILD_EXECUTABLE" ]; then - SHARED= + SHARED="-Wl,--gc-sections -Wl,-z,nocopyreloc" fi if [ -n "$NO_SHARED_LIBS" ]; then APP_SHARED_LIBS= fi - +if [ -n "$ALLOW_UNRESOLVED_SYMBOLS" ]; then + UNRESOLVED= +fi LDFLAGS="\ $SHARED \ --sysroot=$NDK/platforms/$PLATFORMVER/arch-arm \ +-L$LOCAL_PATH/../../obj/local/$ARCH \ `echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/$ARCH/lib\1.so@g\"` \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libc.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libm.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libGLESv1_CM.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libdl.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/liblog.so \ -$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libz.so \ +-L$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib \ +-lc -lm -lGLESv1_CM -ldl -llog -lz \ -L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH \ -lgnustl_static \ --L$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib \ --L$LOCAL_PATH/../../obj/local/$ARCH -Wl,--no-undefined -Wl,-z,noexecstack \ --Wl,-rpath-link=$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib -lsupc++ \ +-no-canonical-prefixes $UNRESOLVED -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \ +-lsupc++ \ $MISSING_LIB $LDFLAGS" #echo env CFLAGS=\""$CFLAGS"\" LDFLAGS=\""$LDFLAGS"\" "$@" diff --git a/project/jni/application/teeworlds/AndroidAppSettings.cfg b/project/jni/application/teeworlds/AndroidAppSettings.cfg index d65bd2bb2..b9c7d075b 100644 --- a/project/jni/application/teeworlds/AndroidAppSettings.cfg +++ b/project/jni/application/teeworlds/AndroidAppSettings.cfg @@ -16,14 +16,16 @@ SdlVideoResizeKeepAspect=n CompatibilityHacks=n CompatibilityHacksStaticInit=n CompatibilityHacksTextInputEmulatesHwKeyboard=n +CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=y AppNeedsTwoButtonMouse=n ShowMouseCursor=n ForceRelativeMouseMode=n -AppNeedsArrowKeys=n -AppNeedsTextInput=n +AppNeedsArrowKeys=y +AppNeedsTextInput=y AppUsesJoystick=y -AppUsesAccelerometer=y +AppUsesAccelerometer=n AppUsesMultitouch=n NonBlockingSwapBuffers=n RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP" @@ -34,6 +36,7 @@ StartupMenuButtonTimeout=3000 HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig' FirstStartMenuOptions='' MultiABI=n +AppMinimumRAM=0 AppVersionCode=06108 AppVersionName="0.6.1.08" ResetSdlConfigForThisVersion=y diff --git a/project/jni/application/teeworlds/readme.txt b/project/jni/application/teeworlds/readme.txt new file mode 100644 index 000000000..376eb3b83 --- /dev/null +++ b/project/jni/application/teeworlds/readme.txt @@ -0,0 +1,11 @@ +Quick compilation guide for Debian/Ubuntu (Windows is not supported, MacOsX should be okay though): +Download SDL Git repo from https://github.com/pelya/commandergenius, +install latest Android SDK, Android NDK r8b or newer, and "ant" tool (sudo apt-get install ant), +then launch commands: + git submodule update --init project/jni/application/teeworlds/src + rm project/jni/application/src # ignore the error + ln -s teeworlds project/jni/application/src + ./changeAppSettings.sh -a + android update project -p project + ./build.sh +That should do it. diff --git a/project/jni/application/test-advertisements/AndroidAppSettings.cfg b/project/jni/application/test-advertisements/AndroidAppSettings.cfg index 892dfa4dc..a250e3c7a 100644 --- a/project/jni/application/test-advertisements/AndroidAppSettings.cfg +++ b/project/jni/application/test-advertisements/AndroidAppSettings.cfg @@ -16,6 +16,8 @@ SdlVideoResizeKeepAspect=n CompatibilityHacks=n CompatibilityHacksStaticInit=n CompatibilityHacksTextInputEmulatesHwKeyboard=n +CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n AppUsesMouse=y AppNeedsTwoButtonMouse=y ShowMouseCursor=n @@ -34,6 +36,7 @@ StartupMenuButtonTimeout=500 HiddenMenuOptions='OptionalDownloadConfig' FirstStartMenuOptions='' MultiABI=n +AppMinimumRAM=0 AppVersionCode=101 AppVersionName="1.01" ResetSdlConfigForThisVersion=n diff --git a/project/jni/application/test-advertisements/ballfield.cpp b/project/jni/application/test-advertisements/ballfield.cpp index 843d47283..9283bb863 100644 --- a/project/jni/application/test-advertisements/ballfield.cpp +++ b/project/jni/application/test-advertisements/ballfield.cpp @@ -579,18 +579,6 @@ int main(int argc, char* argv[]) } } - if(adSize.w == 0 || adSize.h == 0) - SDL_ANDROID_GetAdvertisementParams(NULL, &adSize); - int adX = abs(x_offs / 100) % (physicalW - adSize.w); - int adY = abs(y_offs / 80) % (physicalH - adSize.h); - SDL_ANDROID_SetAdvertisementPosition(adX, adY); - SDL_Rect adRect; - adRect.x = adX * SCREEN_W / physicalW; - adRect.w = adSize.w * SCREEN_W / physicalW; - adRect.y = adY * SCREEN_H / physicalH; - adRect.h = adSize.h * SCREEN_H / physicalH; - SDL_FillRect(screen, &adRect, 0xff0); - print_num(screen, font, screen->w-37, screen->h-12, fps); ++fps_count; @@ -607,6 +595,7 @@ int main(int argc, char* argv[]) SDL_FillRect(screen, &r, 0xaaaaaa); print_num(screen, font, r.x, r.y, i+1); } + int adX, adY; int mx, my; int b = SDL_GetMouseState(&mx, &my); //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse buttons: %d", b); @@ -620,7 +609,26 @@ int main(int argc, char* argv[]) color |= 0x1f0; if( b & SDL_BUTTON_MMASK ) color |= 0x0f; + + adX = mx * physicalW / SCREEN_W - adSize.w - 10; + adY = my * physicalH / SCREEN_H - adSize.h - 10; + SDL_ANDROID_SetAdvertisementPosition(adX, adY); } + else + { + if(adSize.w == 0 || adSize.h == 0) + SDL_ANDROID_GetAdvertisementParams(NULL, &adSize); + adX = abs(x_offs / 100) % (physicalW - adSize.w); + adY = abs(y_offs / 80) % (physicalH - adSize.h); + SDL_ANDROID_SetAdvertisementPosition(adX, adY); + } + SDL_Rect adRect; + adRect.x = adX * SCREEN_W / physicalW; + adRect.w = adSize.w * SCREEN_W / physicalW; + adRect.y = adY * SCREEN_H / physicalH; + adRect.h = adSize.h * SCREEN_H / physicalH; + SDL_FillRect(screen, &adRect, 0xff0); + r.x = mx; r.y = my; r.w = 30; diff --git a/project/jni/application/vcmi-r2387/.gitignore b/project/jni/application/vcmi-r2387/.gitignore new file mode 100644 index 000000000..11ed32df9 --- /dev/null +++ b/project/jni/application/vcmi-r2387/.gitignore @@ -0,0 +1,10 @@ +libvcmi.so +libvcmi.a +AI +Scripting +debug +out +vcmiserver +vcmiserver.zip +build.log +AndroidData/binaries.zip diff --git a/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg b/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg new file mode 100644 index 000000000..6d3cc6b9f --- /dev/null +++ b/project/jni/application/vcmi-r2387/AndroidAppSettings.cfg @@ -0,0 +1,55 @@ +# The application settings for Android libSDL port +AppSettingVersion=17 +LibSdlVersion=1.2 +AppName="VCMI" +AppFullName=eu.vcmi +ScreenOrientation=h +InhibitSuspend=n +AppDataDownloadUrl="!Data files|data1.zip^!Data files|data2.zip^!Data files|data3.zip^" +VideoDepthBpp=16 +NeedDepthBuffer=n +NeedStencilBuffer=n +NeedGles2=n +SwVideoMode=y +SdlVideoResize=y +SdlVideoResizeKeepAspect=n +CompatibilityHacks=y +CompatibilityHacksStaticInit=n +CompatibilityHacksTextInputEmulatesHwKeyboard=n +CompatibilityHacksPreventAudioChopping=n +CompatibilityHacksAppIgnoresAudioBufferSize=n +CompatibilityHacksAdditionalPreloadedSharedLibraries="vcmi" +AppUsesMouse=y +AppNeedsTwoButtonMouse=y +ShowMouseCursor=n +ForceRelativeMouseMode=n +AppNeedsArrowKeys=n +AppNeedsTextInput=y +AppUsesJoystick=n +AppUsesAccelerometer=n +AppUsesMultitouch=n +NonBlockingSwapBuffers=n +RedefinedKeys="LALT RETURN NO_REMAP NO_REMAP E" +AppTouchscreenKeyboardKeysAmount=0 +AppTouchscreenKeyboardKeysAmountAutoFire=0 +RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" +StartupMenuButtonTimeout=3000 +HiddenMenuOptions='OptionalDownloadConfig' +FirstStartMenuOptions='' +MultiABI=y +AppMinimumRAM=64 +AppVersionCode=08605 +AppVersionName="0.86.05" +ResetSdlConfigForThisVersion=y +DeleteFilesOnUpgrade="libsdl-DownloadFinished-0.flag libsdl-DownloadFinished-1.flag libsdl-DownloadFinished-2.flag libsdl-DownloadFinished-3.flag libsdl-DownloadFinished-4.flag libsdl-DownloadFinished-5.flag" +CompiledLibraries="mad sdl_mixer sdl_image sdl_ttf avutil avcore avcodec avformat swscale boost_program_options boost_filesystem boost_iostreams boost_system boost_thread android" +CustomBuildScript=y +AppCflags='' +AppLdflags='' +AppSubdirsBuild='' +AppCmdline='' +ReadmeText='^You may press "Home" now - the data will be downloaded in background' +MinimumScreenSize=s +AdmobPublisherId=n +AdmobTestDeviceId= +AdmobBannerSize= diff --git a/project/jni/application/vcmi-r2387/AndroidBuild.sh b/project/jni/application/vcmi-r2387/AndroidBuild.sh new file mode 100755 index 000000000..d42619359 --- /dev/null +++ b/project/jni/application/vcmi-r2387/AndroidBuild.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# For some reason I'm getting errors with "make -j4" +make -k ARCH=$1 || exit 1 +[ -f libapplication-$1.so ] || exit 1 +[ -e libapplication.so ] || ln -s libapplication-armeabi.so libapplication.so +exit 0 diff --git a/project/jni/application/vcmi-r2387/AndroidData/data1.zip b/project/jni/application/vcmi-r2387/AndroidData/data1.zip new file mode 100644 index 000000000..be8147f11 Binary files /dev/null and b/project/jni/application/vcmi-r2387/AndroidData/data1.zip differ diff --git a/project/jni/application/vcmi-r2387/AndroidData/data2.zip b/project/jni/application/vcmi-r2387/AndroidData/data2.zip new file mode 100644 index 000000000..54bfa22a4 Binary files /dev/null and b/project/jni/application/vcmi-r2387/AndroidData/data2.zip differ diff --git a/project/jni/application/vcmi-r2387/AndroidData/data3.zip b/project/jni/application/vcmi-r2387/AndroidData/data3.zip new file mode 100644 index 000000000..2f275aeb7 Binary files /dev/null and b/project/jni/application/vcmi-r2387/AndroidData/data3.zip differ diff --git a/project/jni/application/vcmi-r2387/Makefile b/project/jni/application/vcmi-r2387/Makefile new file mode 100644 index 000000000..9a8cd2c02 --- /dev/null +++ b/project/jni/application/vcmi-r2387/Makefile @@ -0,0 +1,99 @@ +ifeq ($(ARCH),) +ARCH:=armeabi +endif + +$(shell mkdir -p $(ARCH)/AI debug/$(ARCH)/AI $(ARCH)/Scripting debug/$(ARCH)/Scripting \ + $(ARCH)/out/vcmi/lib $(ARCH)/out/vcmi/server $(ARCH)/out/vcmi/AI/StupidAI \ + $(ARCH)/out/vcmi/AI/GeniusAI $(ARCH)/out/vcmi/client $(ARCH)/out/vcmi/Scripting/ERM) + +LOCAL_PATH:=$(shell dirname $0) +LOCAL_PATH:=`cd $LOCAL_PATH && pwd` + +SOURCES_LIB:=$(wildcard vcmi/lib/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp) +OBJS_LIB:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_LIB)) + +SOURCES_SERVER:=$(wildcard vcmi/server/*.cpp) +OBJS_SERVER:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_SERVER)) + +SOURCES_STUPIDAI:=$(wildcard vcmi/AI/StupidAI/*.cpp) +OBJS_STUPIDAI:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_STUPIDAI)) + +SOURCES_GENIUSAI:=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp)) +OBJS_GENIUSAI:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_GENIUSAI)) + +SOURCES_ERM:=$(wildcard vcmi/Scripting/ERM/*.cpp) +OBJS_ERM:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_ERM)) + +SOURCES_CLIENT:=$(wildcard vcmi/client/*.cpp vcmi/CCallback.cpp) +OBJS_CLIENT:=$(patsubst %.cpp, $(ARCH)/out/%.o, $(SOURCES_CLIENT)) + +all: AndroidData/binaries-$(ARCH).zip libapplication-$(ARCH).so + +AndroidData/binaries-$(ARCH).zip: $(ARCH)/vcmiserver $(ARCH)/AI/libGeniusAI.so $(ARCH)/AI/libStupidAI.so $(ARCH)/Scripting/libvcmiERM.so # $(ARCH)/libvcmi.so + rm -f $@ + cd $(ARCH) && zip -r ../$@ $(foreach F, $^, $(patsubst $(ARCH)/%,%,$(F))) + +$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): $(ARCH)/out/%.o: %.cpp + ../setEnvironment-$(ARCH).sh sh -c \ + "\$$CXX \ + -c \$$CXXFLAGS -Ivcmi -Ivcmi/lib \ + -DDATA_DIR=\\\"/sdcard/Android/data/eu.vcmi/files\\\" \ + -DBIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \ + -DLIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \ + -DWITH_AVCODEC_DECODE_VIDEO2=1 \ + -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress \ + $< -o $@" +# -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address + +#ALLOW_UNRESOLVED_SYMBOLS=1 +LINK_LIB= \ + env NO_SHARED_LIBS=1 SHARED_LIBRARY_NAME=`basename $@` ../setEnvironment-$(ARCH).sh sh -c \ + "echo SHARED_LIBRARY_NAME \$$SHARED_LIBRARY_NAME && \$$CXX \ + -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ + \$$LDFLAGS -L$(ARCH) \ + -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread && \ + cp $@ debug/$@ && \ + \$$STRIP --strip-unneeded $@" + +#$(ARCH)/libvcmi.a: $(OBJS_LIB) +# ar rcs $@ $^ + +$(ARCH)/libvcmi.so: $(OBJS_LIB) + $(LINK_LIB) + +-lvcmi: $(ARCH)/libvcmi.so + cp -f $^ ../../../libs/$^ + +.PHONY: -lvcmi + +$(ARCH)/AI/libGeniusAI.so: $(OBJS_GENIUSAI) -lvcmi + $(LINK_LIB) + +$(ARCH)/AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi + $(LINK_LIB) + +$(ARCH)/Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi + $(LINK_LIB) + +$(ARCH)/vcmiserver: $(OBJS_SERVER) -lvcmi + env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment-$(ARCH).sh sh -c \ + "\$$CXX \ + -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ + \$$LDFLAGS -L$(ARCH) -Wl,-rpath,/data/data/eu.vcmi/lib \ + -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread && \ + cp $@ debug/$@ && \ + \$$STRIP --strip-unneeded $@" + +libapplication-$(ARCH).so: $(OBJS_CLIENT) -lvcmi + env ../setEnvironment-$(ARCH).sh sh -c \ + "\$$CXX \ + -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ \ + \$$LDFLAGS -L$(ARCH) \ + -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lboost_program_options && \ + cp $@ debug/$@" +# No need to strip, it's done inside build.sh script + +clean: + rm -rf armeabi* debug AndroidData/binaries-*.zip libapplication*.so + +.PHONY: clean diff --git a/project/jni/application/vcmi-r2387/icon.png b/project/jni/application/vcmi-r2387/icon.png new file mode 100644 index 000000000..970b73138 Binary files /dev/null and b/project/jni/application/vcmi-r2387/icon.png differ diff --git a/project/jni/application/vcmi-r2387/readme.txt b/project/jni/application/vcmi-r2387/readme.txt new file mode 100644 index 000000000..4de332a52 --- /dev/null +++ b/project/jni/application/vcmi-r2387/readme.txt @@ -0,0 +1,14 @@ +Quick compilation guide: +Download my GIT repo from https://github.com/pelya/commandergenius, +then install Android SDK from http://developer.android.com, +NDK r8d from http://crystax.net/ and "ant" tool, then launch commands + android update project -p project + rm project/jni/application/src + ln -s vcmi project/jni/application/src + echo > project/jni/application/vcmi/libvcmi.so +then download VCMI revision 2387 into the dir project/jni/application/vcmi/vcmi +(or create a symlink to it if you already have downloaded it), then apply patch vcmi-android.diff, +then launch build.sh. + +To run it you should have complete installation of Heroes 3: Wake of Gods on your SD card on your device, +in the directory Android/data/eu.vcmi/files diff --git a/project/jni/application/vcmi-r2387/vcmi b/project/jni/application/vcmi-r2387/vcmi new file mode 120000 index 000000000..bb55c5f92 --- /dev/null +++ b/project/jni/application/vcmi-r2387/vcmi @@ -0,0 +1 @@ +../../../../../vcmi \ No newline at end of file diff --git a/project/jni/application/vcmi-r2387/vcmi-android.diff b/project/jni/application/vcmi-r2387/vcmi-android.diff new file mode 100644 index 000000000..c0a866d9b --- /dev/null +++ b/project/jni/application/vcmi-r2387/vcmi-android.diff @@ -0,0 +1,1590 @@ +Index: Scripting/ERM/ERMParser.cpp +=================================================================== +--- Scripting/ERM/ERMParser.cpp (revision 2387) ++++ Scripting/ERM/ERMParser.cpp (working copy) +@@ -2,7 +2,7 @@ + #include + //To make compilation with older boost versions possible + //Don't know exact version - 1.46 works while 1.42 not +-#if BOOST_VERSION >= 104600 ++#if BOOST_VERSION >= 104500 + + #include + #include +Index: AI/GeniusAI/neuralNetwork.cpp +=================================================================== +--- AI/GeniusAI/neuralNetwork.cpp (revision 2387) ++++ AI/GeniusAI/neuralNetwork.cpp (working copy) +@@ -14,9 +14,9 @@ + static bool in = 0; + if(!in) + { +- float x = (rand()+1)/float(RAND_MAX+1); ++ float x = (rand())/float(RAND_MAX); + float f = sqrtf( - 2.0f * log(x) ); +- x = (rand()+1)/float(RAND_MAX+1); ++ x = (rand())/float(RAND_MAX); + kept = f * cosf( 2.0f * M_PI * x ); + in = true; + return f * sinf( 2.0f * M_PI * x ); +Index: AI/GeniusAI/CGeniusAI.cpp +=================================================================== +--- AI/GeniusAI/CGeniusAI.cpp (revision 2387) ++++ AI/GeniusAI/CGeniusAI.cpp (working copy) +@@ -1393,6 +1393,7 @@ + } + + ++#ifndef ANDROID + //WTF?!? why is this needed?!?!?! + BattleAction CGlobalAI::activeStack( const CStack * stack ) + { +@@ -1400,4 +1401,5 @@ + ba.stackNumber = stack->ID; + return ba; + } ++#endif + +Index: lib/Interprocess.h +=================================================================== +--- lib/Interprocess.h (revision 2387) ++++ lib/Interprocess.h (working copy) +@@ -1,3 +1,4 @@ ++/* + #include + #include + #include +@@ -2,2 +3,3 @@ + #include ++*/ + +@@ -13,6 +15,7 @@ + * + */ + ++/* + struct ServerReady + { + bool ready; +@@ -51,4 +54,48 @@ + delete mr; + boost::interprocess::shared_memory_object::remove("vcmi_memory"); + } +-}; +\ No newline at end of file ++}; ++*/ ++ ++#include ++#ifdef WIN32 ++#include ++#else ++#include ++#endif ++#include "VCMIDirs.h" ++ ++#define SERVER_READY_FILENAME "/VcmiServerReadyFlag.lock" ++ ++void clearServerReady() ++{ ++ unlink((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str()); ++} ++ ++void waitServerReady() ++{ ++ while(true) ++ { ++ FILE * ff = fopen((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str(), "r"); ++ if(ff) ++ { ++ fclose(ff); ++ clearServerReady(); ++ break; ++ } ++#ifdef WIN32 ++ Sleep(200); ++#else ++ usleep(200000); ++#endif ++ } ++} ++ ++void notifyServerReady() ++{ ++ FILE * ff = fopen((GVCMIDirs.UserPath + SERVER_READY_FILENAME).c_str(), "w"); ++ if(!ff) ++ return; ++ fwrite("1", 1, 1, ff); ++ fclose(ff); ++} +Index: lib/CLodHandler.cpp +=================================================================== +--- lib/CLodHandler.cpp (revision 2387) ++++ lib/CLodHandler.cpp (working copy) +@@ -87,13 +87,15 @@ + Entry ourEntry = *en_it; + + if(length) *length = ourEntry.realSize; ++ enum { SAFETY_MARGIN = 4096 }; // VCMI functions tend to read past the array end, crashing at random + mutex->lock(); + + unsigned char * outp; + if (ourEntry.offset<0) //file is in the sprites/ folder; no compression + { + int result; +- outp = new unsigned char[ourEntry.realSize]; ++ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; ++ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); + FILE * f = fopen((myDir + "/" + ourEntry.realName).c_str(), "rb"); + if (f) + { +@@ -109,16 +111,21 @@ + delete[] outp; + return NULL; + } +- else ++ else ++ { ++ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; + return outp; ++ } + } + else if (ourEntry.size==0) //file is not compressed + { +- outp = new unsigned char[ourEntry.realSize]; ++ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; ++ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); + + LOD.seekg(ourEntry.offset, std::ios::beg); + LOD.read((char*)outp, ourEntry.realSize); + mutex->unlock(); ++ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; + return outp; + } + else //we will decompress file +@@ -131,7 +138,12 @@ + infs2(outp, ourEntry.size, ourEntry.realSize, decomp); + mutex->unlock(); + delete[] outp; +- return decomp; ++ outp = new unsigned char[ourEntry.realSize+SAFETY_MARGIN]; ++ memset(outp+ourEntry.realSize, 0, SAFETY_MARGIN); ++ memcpy(outp, decomp, ourEntry.realSize); ++ delete [] decomp; ++ //tlog0 << "Loaded file: " << fname << " size " << ourEntry.realSize << " ptr " << (void *)outp << " safety " << (int)SAFETY_MARGIN << std::endl; ++ return outp; + } + return NULL; + } +Index: lib/CGameInterface.cpp +=================================================================== +--- lib/CGameInterface.cpp (revision 2387) ++++ lib/CGameInterface.cpp (working copy) +@@ -26,6 +26,7 @@ + rett * ret=NULL; + rett*(*getAI)(); + void(*getName)(char*); ++ const char * errorMsg = NULL; + + #ifdef _WIN32 + HINSTANCE dll = LoadLibraryA(dllname.c_str()); +@@ -36,6 +37,7 @@ + } + #else + void *dll = dlopen(dllname.c_str(), RTLD_LOCAL | RTLD_LAZY); ++ errorMsg = dlerror(); + if (dll) + { + getName = (void(*)(char*))dlsym(dll,"GetAiName"); +@@ -44,13 +46,14 @@ + #endif + if (!dll) + { +- tlog1 << "Cannot open dynamic library ("<before(*b); ++ // Comparing pointers is bad bad practice, because type_info pointers to the same types ++ // are different inside shared library and the executable that links to that library ++ return strcmp(a->name(), b->name()) > 0; + } + }; + +Index: client/CCreatureAnimation.cpp +=================================================================== +--- client/CCreatureAnimation.cpp (revision 2387) ++++ client/CCreatureAnimation.cpp (working copy) +@@ -37,15 +37,23 @@ + } + } + ++#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ ++ if( lodLength < (S) ) \ ++ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ ++ (S) - lodLength << " bytes, fname " << fname << " size " << lodLength << std::endl; } ++#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) ++ + CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), once(false) + { +- FDef = spriteh->giveFile(name, FILE_ANIMATION); //load main file ++ FDef = spriteh->giveFile(name, FILE_ANIMATION, &lodLength); //load main file ++ fname = name; + + //init anim data + int i,j, totalInBlock; + + defName=name; + i = 0; ++ CHECK_LOD_MEM_BLOCK_SIZE(i+0x310); + DEFType = readNormalNr<4>(i,FDef); i+=4; + fullWidth = readNormalNr<4>(i,FDef); i+=4; + fullHeight = readNormalNr<4>(i,FDef); i+=4; +@@ -64,6 +72,7 @@ + totalEntries=0; + for (int z=0; z frameIDs; + int group = readNormalNr<4>(i,FDef); i+=4; //block ID + totalInBlock = readNormalNr<4>(i,FDef); i+=4; +@@ -76,6 +85,7 @@ + /*int unknown2 = readNormalNr<4>(i,FDef);*/ i+=4; //TODO use me + /*int unknown3 = readNormalNr<4>(i,FDef);*/ i+=4; //TODO use me + i+=13*totalInBlock; //ommiting names ++ CHECK_LOD_MEM_BLOCK_SIZE(i+totalInBlock*4); + for (j=0; j(i,FDef); i+=4; +@@ -173,6 +183,7 @@ + unsigned char SegmentType, SegmentLength; + + i = BaseOffset = SEntries[SIndex].offset; ++ CHECK_LOD_MEM_BLOCK_SIZE(i+32); + /*int prSize = readNormalNr<4>(i, FDef);*/ i += 4; //TODO use me + int defType2 = readNormalNr<4>(i, FDef); i += 4; + FullWidth = readNormalNr<4>(i, FDef); i += 4; +@@ -194,11 +205,12 @@ + { + ftcp += FullWidth * TopMargin; + } +- int *RLEntries = (int*)(FDef + BaseOffset); ++ unsigned char *RLEntries = (FDef + BaseOffset); + BaseOffset += sizeof(int) * SpriteHeight; + for (int i = 0; i < SpriteHeight; i++) + { +- BaseOffset = BaseOffsetor + RLEntries[i]; ++ CHECK_LOD_MEM_BLOCK_SIZE(RLEntries+i*4-FDef); ++ BaseOffset = BaseOffsetor + read_unaligned_u32(RLEntries+i*4); + if (LeftMargin > 0) + { + ftcp += LeftMargin; +@@ -213,6 +225,7 @@ + + do + { ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+2); + SegmentType = FDef[BaseOffset++]; + SegmentLength = FDef[BaseOffset++]; + +@@ -227,6 +240,8 @@ + { + if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB && destRect->y <= yB && destRect->y + destRect->h > yB)) + { ++ if(SegmentType == 0xff) ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+k+1); + const ui8 colorNr = SegmentType == 0xff ? FDef[BaseOffset+k] : SegmentType; + putPixel(dest, xB, yB, palette[colorNr], colorNr, yellowBorder, blueBorder, aCountMod); + } +Index: client/CSndHandler.cpp +=================================================================== +--- client/CSndHandler.cpp (revision 2387) ++++ client/CSndHandler.cpp (working copy) +@@ -151,16 +151,17 @@ + } + + const char *data = mfile->data(); +- unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); +- struct soundEntry *se = (struct soundEntry *)&data[4]; ++ unsigned int numFiles = SDL_SwapLE32(read_unaligned_u32(&data[0])); ++ struct soundEntry se; + +- for (unsigned int i=0; ifilename; +- entry.offset = SDL_SwapLE32(se->offset); +- entry.size = SDL_SwapLE32(se->size); ++ entry.name = se.filename; ++ entry.offset = SDL_SwapLE32(se.offset); ++ entry.size = SDL_SwapLE32(se.size); + entry.data = mfile->data() + entry.offset; + + entries.push_back(entry); +@@ -186,24 +187,26 @@ + return; + } + const unsigned char *data = (const unsigned char *)mfile->data(); +- unsigned int numFiles = SDL_SwapLE32(*(Uint32 *)&data[0]); +- struct videoEntry *ve = (struct videoEntry *)&data[4]; ++ unsigned int numFiles = SDL_SwapLE32(read_unaligned_u32(&data[0])); ++ struct videoEntry ve; + +- for (unsigned int i=0; ifilename; +- entry.offset = SDL_SwapLE32(ve->offset); ++ entry.name = ve.filename; ++ entry.offset = SDL_SwapLE32(ve.offset); + entry.name.erase(entry.name.find_last_of('.')); + + // There is no size, so check where the next file is + if (i == numFiles - 1) { + entry.size = mfile->size() - entry.offset; + } else { +- struct videoEntry *ve_next = ve+1; ++ struct videoEntry ve_next; ++ memcpy(&ve_next, &data[4+(i+1)*sizeof(ve)], sizeof(ve)); + +- entry.size = SDL_SwapLE32(ve_next->offset) - entry.offset; ++ entry.size = SDL_SwapLE32(ve_next.offset) - entry.offset; + } + entry.data = mfile->data() + entry.offset; + +Index: client/CAnimation.cpp +=================================================================== +--- client/CAnimation.cpp (revision 2387) ++++ client/CAnimation.cpp (working copy) +@@ -46,6 +46,8 @@ + ~SDLImageLoader(); + }; + ++// It's buggy, disabled for Android build ++/* + class CompImageLoader + { + CompImage * image; +@@ -69,11 +71,18 @@ + CompImageLoader(CompImage * Img); + ~CompImageLoader(); + }; +- ++*/ + /************************************************************************* + * DefFile, class used for def loading * + *************************************************************************/ + ++ ++#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ ++ if( lodLength < (S) ) \ ++ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ ++ (S) - lodLength << " bytes, fname " << fname << " size " << lodLength << std::endl; } ++#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) ++ + CDefFile::CDefFile(std::string Name): + data(NULL), + palette(NULL) +@@ -91,15 +100,18 @@ + { 0, 0, 0, 192} // 75% - shadow border below selection + }; + +- data = spriteh->giveFile(Name, FILE_ANIMATION); ++ fname = Name; ++ data = spriteh->giveFile(Name, FILE_ANIMATION, &lodLength); + palette = new SDL_Color[256]; + int it = 0; + ++ CHECK_LOD_MEM_BLOCK_SIZE(it+4); + unsigned int type = readNormalNr(data, it); + it+=4; + //int width = readNormalNr(data, it); it+=4;//not used + //int height = readNormalNr(data, it); it+=4; + it+=8; ++ CHECK_LOD_MEM_BLOCK_SIZE(it+4); + unsigned int totalBlocks = readNormalNr(data, it); + it+=4; + +@@ -117,6 +129,7 @@ + + for (unsigned int i=0; isecond[frame]; + +- const SSpriteDef sd = * reinterpret_cast(FDef); ++ SSpriteDef sd; ++ CHECK_LOD_MEM_BLOCK_SIZE((FDef-data)+sizeof(sd)); ++ memcpy(&sd, FDef, sizeof(sd)); + SSpriteDef sprite; + + //sprite.size = SDL_SwapLE32(sd.size);//unused +@@ -170,6 +186,7 @@ + //pixel data is not compressed, copy data to surface + for (unsigned int i=0; i(FDef+currentOffset); ++ const unsigned char * RWEntriesLoc = FDef+currentOffset; + currentOffset += sizeof(ui32) * sprite.height; + + for (unsigned int i=0; isurf->pixels + image->surf->h*image->surf->pitch >= position + size ) + { + memcpy((void *)position, data, size); + position += size; +@@ -323,7 +357,7 @@ + + inline void SDLImageLoader::Load(size_t size, ui8 color) + { +- if (size) ++ if (size && (ui8 *)image->surf->pixels + image->surf->h*image->surf->pitch >= position + size) + { + memset((void *)position, color, size); + position += size; +@@ -345,6 +379,7 @@ + + //////////////////////////////////////////////////////////////////////////////// + ++/* + CompImageLoader::CompImageLoader(CompImage * Img): + image(Img), + position(NULL), +@@ -518,6 +553,7 @@ + image->surf = newPtr; + } + ++*/ + /************************************************************************* + * Classes for images, support loading from file and drawing on surface * + *************************************************************************/ +@@ -625,6 +661,8 @@ + SDL_FreeSurface(surf); + } + ++// Buggy, disabled for Android ++/* + CompImage::CompImage(const CDefFile *data, size_t frame, size_t group): + surf(NULL), + line(NULL), +@@ -845,6 +883,7 @@ + delete [] line; + delete [] palette; + } ++*/ + + /************************************************************************* + * CAnimation for animations handling, can load part of file if needed * +@@ -889,9 +928,11 @@ + //try to get image from def + if (source[group][frame].getType() == JsonNode::DATA_NULL) + { ++ /* + if (compressed) + images[group][frame] = new CompImage(file, frame, group); + else ++ */ + images[group][frame] = new SDLImage(file, frame, group); + } + else //load from separate file +Index: client/Client.h +=================================================================== +--- client/Client.h (revision 2387) ++++ client/Client.h (working copy) +@@ -43,7 +43,7 @@ + public: + timeHandler th; + boost::thread *serverThread; //thread that called system to run server +- SharedMem *shared; //interprocess memory (for waiting for server) ++ //SharedMem *shared; //interprocess memory (for waiting for server) + bool verbose; //whether to print log msgs + std::string port; //port number in text form + +Index: client/SDL_Extensions.cpp +=================================================================== +--- client/SDL_Extensions.cpp (revision 2387) ++++ client/SDL_Extensions.cpp (working copy) +@@ -119,8 +119,8 @@ + if(incrementPtr == -1) + ptr -= 2; + +- Uint16 * const px = (Uint16*)ptr; +- *px = (B>>3) + ((G>>2) << 5) + ((R>>3) << 11); //drop least significant bits of 24 bpp encoded color ++ Uint16 px = (B>>3) + ((G>>2) << 5) + ((R>>3) << 11); //drop least significant bits of 24 bpp encoded color ++ memcpy(ptr, &px, sizeof(px)); + + if(incrementPtr == 1) + ptr += 2; //bpp +@@ -150,9 +150,9 @@ + const int rmask = 0xF800, gmask = 0x7E0, bmask = 0x1F; + const int rshift = 11, gshift = 5, bshift = 0; + +- const Uint8 r5 = (*((Uint16 *)ptr) & rmask) >> rshift, +- b5 = (*((Uint16 *)ptr) & bmask) >> bshift, +- g5 = (*((Uint16 *)ptr) & gmask) >> gshift; ++ const Uint8 r5 = (read_unaligned_u16(ptr) & rmask) >> rshift, ++ b5 = (read_unaligned_u16(ptr) & bmask) >> bshift, ++ g5 = (read_unaligned_u16(ptr) & gmask) >> gshift; + + const Uint32 r8 = (r5 << (8 - rbit)) | (r5 >> (2*rbit - 8)), + g8 = (g5 << (8 - gbit)) | (g5 >> (2*gbit - 8)), +@@ -649,7 +649,7 @@ + return *p; + + case 2: +- return *(Uint16 *)p; ++ return read_unaligned_u16(p); + + case 3: + /* +@@ -661,7 +661,7 @@ + //#endif + + case 4: +- return *(Uint32 *)p; ++ return read_unaligned_u32(p); + + default: + return 0; // shouldn't happen, but avoids warnings +Index: client/CAnimation.h +=================================================================== +--- client/CAnimation.h (revision 2387) ++++ client/CAnimation.h (working copy) +@@ -47,6 +47,8 @@ + std::map > offset; + + unsigned char * data; ++ int lodLength; ++ std::string fname; + SDL_Color * palette; + + public: +@@ -125,6 +127,8 @@ + * 2nd byte = size of segment + * raw data (if any) + */ ++// Buggy, disabled for Android ++/* + class CompImage : public IImage + { + //x,y - margins, w,h - sprite size +@@ -158,8 +162,8 @@ + + friend class CompImageLoader; + }; ++*/ + +- + /// Class for handling animation + class CAnimation + { +Index: client/GUIBase.cpp +=================================================================== +--- client/GUIBase.cpp (revision 2387) ++++ client/GUIBase.cpp (working copy) +@@ -11,6 +11,7 @@ + #include "../CThreadHelper.h" + #include "CConfigHandler.h" + #include ++ + + /* + * GUIBase.cpp, part of VCMI engine +@@ -365,6 +366,26 @@ + } + } HANDLE_EXCEPTION + } ++ ++void CGuiHandler::loopInitFromMainThread() ++{ ++ setThreadName(-1, "CGuiHandler::run"); ++ CCS->curh->centerCursor(); ++ mainFPSmng->init(); // resets internal clock, needed for FPS manager ++} ++ ++bool CGuiHandler::loopFromMainThread() ++{ ++ if(terminate) ++ return false; ++ if(curInt) ++ curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment ++ ++ mainFPSmng->framerateDelay(); // holds a constant FPS ++ return true; ++} ++ ++ + + CGuiHandler::CGuiHandler() + :lastClick(-500, -500) +Index: client/CCreatureAnimation.h +=================================================================== +--- client/CCreatureAnimation.h (revision 2387) ++++ client/CCreatureAnimation.h (working copy) +@@ -66,6 +66,8 @@ + int curFrame, internalFrame; //number of currently displayed frame + unsigned int frames; //number of frames + CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1]) ++ int lodLength; ++ std::string fname; + + template + int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next +Index: client/Client.cpp +=================================================================== +--- client/Client.cpp (revision 2387) ++++ client/Client.cpp (working copy) +@@ -41,7 +41,7 @@ + #include "../lib/RegisterTypes.cpp" + + extern std::string NAME; +-namespace intpr = boost::interprocess; ++//namespace intpr = boost::interprocess; + + /* + * Client.cpp, part of VCMI engine +@@ -476,9 +476,9 @@ + + void CClient::handlePack( CPack * pack ) + { +- CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier +- if(apply) ++ if(applier->apps.find(typeList.getTypeID(pack)) != applier->apps.end()) + { ++ CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier + apply->applyOnClBefore(this,pack); + tlog5 << "\tMade first apply on cl\n"; + gs->apply(pack); +@@ -639,18 +639,22 @@ + startServer(); + + th.update(); ++ /* + intpr::scoped_lock slock(shared->sr->mutex); + while(!shared->sr->ready) + { + shared->sr->cond.wait(slock); + } ++ */ ++ tlog0 << "Waiting for server..." << std::endl; ++ waitServerReady(); + if(verbose) + tlog0 << "Waiting for server: " << th.getDif() << std::endl; + } + + CConnection * CServerHandler::connectToServer() + { +- if(!shared->sr->ready) ++ if(!serverThread) + waitForServer(); + + th.update(); +@@ -665,27 +669,31 @@ + CServerHandler::CServerHandler(bool runServer /*= false*/) + { + serverThread = NULL; +- shared = NULL; ++ //shared = NULL; + port = boost::lexical_cast(conf.cc.port); + verbose = false; + ++ /* + boost::interprocess::shared_memory_object::remove("vcmi_memory"); //if the application has previously crashed, the memory may not have been removed. to avoid problems - try to destroy it + try + { + shared = new SharedMem(); + } HANDLE_EXCEPTIONC(tlog1 << "Cannot open interprocess memory: ";) ++ */ + } + + CServerHandler::~CServerHandler() + { +- delete shared; ++ //delete shared; + delete serverThread; //detaches, not kills thread + } + + void CServerHandler::callServer() + { ++ clearServerReady(); + setThreadName(-1, "CServerHandler::callServer"); +- std::string comm = std::string(BIN_DIR PATH_SEPARATOR SERVER_NAME " ") + port + " > server_log.txt"; ++ std::string comm = std::string("LD_LIBRARY_PATH=" LIB_DIR "/../lib " BIN_DIR PATH_SEPARATOR SERVER_NAME " ") + port + " > server_log.txt"; ++ tlog0 << "Invoking VCMI server : " << comm << std::endl; + std::system(comm.c_str()); + tlog0 << "Server finished\n"; + } +Index: client/CMT.cpp +=================================================================== +--- client/CMT.cpp (revision 2387) ++++ client/CMT.cpp (working copy) +@@ -92,8 +92,10 @@ + void dispose(); + void playIntro(); + static void listenForEvents(); ++static bool loopListenForEvents(bool block); + void requestChangingResolution(); + void startGame(StartInfo * options, CConnection *serv = NULL); ++ + + #ifndef _WIN32 + #ifndef _GNU_SOURCE +@@ -128,6 +130,7 @@ + GDefaultOptions.settingsChanged(); + } + } ++ + THC tlog0<<"\tLoading default system settings: "<musich->setVolume(GDefaultOptions.musicVolume); + tlog0<<"\tInitializing sound: "<(CGI)->setFromLib(); +@@ -154,7 +158,9 @@ + CCS->curh->show(); + tlog0<<"Screen handler: "<loadHeroAnims(); + tlog0<<"\tMain graphics: "<start(); + atexit(dispose); + tlog0 <<"Creating console and logfile: "<playerInfos[1].color = 1; + startGame(si); + } ++ // Drawing and running event loop from non-main thread does not work at all on Andorid and crashes often on Linux ++#if defined(ANDROID) || defined(LINUX) ++ GH.loopInitFromMainThread(); ++ while( GH.loopFromMainThread() ) ++ { ++ while( loopListenForEvents(false) ); ++ } ++#else + mainGUIThread = new boost::thread(&CGuiHandler::run, boost::ref(GH)); + listenForEvents(); ++#endif + + return 0; + } +@@ -561,10 +585,12 @@ + tlog2 << "Warning: SDL says that " << bpp << "bpp is wrong and suggests " << suggestedBpp << std::endl; + } + ++#ifndef ANDROID + if(screen) //screen has been already initialized + SDL_QuitSubSystem(SDL_INIT_VIDEO); + + SDL_InitSubSystem(SDL_INIT_VIDEO); ++#endif + + if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == NULL) + { +@@ -609,14 +635,27 @@ + setResolution = true; + } + ++ + static void listenForEvents() + { +- while(1) //main SDL events loop +- { ++ while(loopListenForEvents(true)); //main SDL events loop ++} ++ ++static bool loopListenForEvents(bool block) ++{ + SDL_Event *ev = new SDL_Event(); + + //tlog0 << "Waiting... "; +- int ret = SDL_WaitEvent(ev); ++ int ret = 1; ++ if( block ) ++ ret = SDL_WaitEvent(ev); ++ else ++ { ++ if(!SDL_PollEvent(ev)) { ++ delete ev; ++ return false; ++ } ++ } + //tlog0 << "got " << (int)ev->type; + if (ret == 0 || (ev->type==SDL_QUIT) || + (ev->type == SDL_KEYDOWN && ev->key.keysym.sym==SDLK_F4 && (ev->key.keysym.mod & KMOD_ALT))) +@@ -635,7 +674,7 @@ + SDL_Delay(750); + SDL_Quit(); + tlog0 << "Ending...\n"; +- break; ++ return false; + } + else if(LOCPLINT && ev->type == SDL_KEYDOWN && ev->key.keysym.sym==SDLK_F4) + { +@@ -644,7 +683,7 @@ + setScreenRes(conf.cc.screenx, conf.cc.screeny, conf.cc.bpp, full); + GH.totalRedraw(); + delete ev; +- continue; ++ return true; + } + else if(ev->type == SDL_USEREVENT) + { +@@ -674,7 +713,7 @@ + } + + delete ev; +- continue; ++ return true; + } + + //tlog0 << " pushing "; +@@ -682,7 +721,7 @@ + events.push(ev); + eventsM.unlock(); + //tlog0 << " done\n"; +- } ++ return true; + } + + void startGame(StartInfo * options, CConnection *serv/* = NULL*/) +@@ -742,3 +781,4 @@ + ev.user.code = 1; + SDL_PushEvent(&ev); + } ++ +Index: client/GUIBase.h +=================================================================== +--- client/GUIBase.h (revision 2387) ++++ client/GUIBase.h (working copy) +@@ -558,6 +558,8 @@ + CGuiHandler(); + ~CGuiHandler(); + void run(); // holds the main loop for the whole program after initialization and manages the update/rendering system ++ void loopInitFromMainThread(); ++ bool loopFromMainThread(); + + void totalRedraw(); //forces total redraw (using showAll), sets a flag, method gets called at the end of the rendering + void simpleRedraw(); //update only top interface and draw background from buffer, sets a flag, method gets called at the end of the rendering +Index: client/CDefHandler.cpp +=================================================================== +--- client/CDefHandler.cpp (revision 2387) ++++ client/CDefHandler.cpp (working copy) +@@ -50,10 +50,19 @@ + SDL_FreeSurface(ourImages[i].bitmap); + } + +-void CDefHandler::openFromMemory(unsigned char *table, const std::string & name) ++#define CHECK_LOD_MEM_BLOCK_SIZE1(S, FF, F, L) { \ ++ if( lodLength < (S) ) \ ++ tlog1<<"ERROR in " << FF << " " << F << ":" << L << ": reading past the end of LOD mem block by " << \ ++ (S) - lodLength << " bytes, fname " << name << " size " << lodLength << std::endl; } ++#define CHECK_LOD_MEM_BLOCK_SIZE(S) CHECK_LOD_MEM_BLOCK_SIZE1(S, __FUNCTION__, __FILE__, __LINE__) ++ ++void CDefHandler::openFromMemory(unsigned char *table, const std::string & name, int lodLength) + { ++ //tlog0<<"openFromMemory ptr " << (void *)table <(table); ++ SDefEntry de; ++ memcpy(&de, table, sizeof(de)); + unsigned char *p; + + defName = name; +@@ -61,6 +70,8 @@ + width = SDL_SwapLE32(de.width); + height = SDL_SwapLE32(de.height); + unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks); ++ ++ //tlog0<<"openFromMemory w " << width << " h " << height << " totalBlocks " << totalBlocks <(&de); ++ p = table; + p += sizeof(de); +- ++ + int totalEntries=0; + for (unsigned int z=0; z(p); ++ //tlog0<<"Megadebug 443 - read size " << p - table <(FDef + BaseOffset); ++ SSpriteDef sd; ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + sizeof(sd)); ++ ++ memcpy(&sd, FDef + BaseOffset, sizeof(sd)); + + prSize = SDL_SwapLE32(sd.prSize); //TODO use me + defType2 = SDL_SwapLE32(sd.defType2); +@@ -170,12 +206,14 @@ + if (add==4) + add=0; + ++ //tlog0<<"getSprite: 11: SDL_CreateRGBSurface " << FullWidth << ":" << FullHeight << std::endl; + ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0); + //int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str())); + + BaseOffset += sizeof(SSpriteDef); + int BaseOffsetor = BaseOffset; + ++ //tlog0<<"getSprite: 12: set palette" << std::endl; + for(int i=0; i<256; ++i) + { + SDL_Color pr; +@@ -188,6 +226,7 @@ + + int ftcp=0; + ++ //tlog0<<"getSprite: 13" << std::endl; + // If there's a margin anywhere, just blank out the whole surface. + if (TopMargin > 0 || BottomMargin > 0 || LeftMargin > 0 || RightMargin > 0) { + memset( reinterpret_cast(ret->pixels), 0, FullHeight*FullWidth); +@@ -197,6 +236,7 @@ + if (TopMargin > 0) + ftcp += TopMargin*(FullWidth+add); + ++ //tlog0<<"getSprite: 14: defType2 " << defType2 << std::endl; + switch(defType2) + { + case 0: +@@ -206,7 +246,10 @@ + if (LeftMargin>0) + ftcp += LeftMargin; + +- memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth); ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + SpriteWidth); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SpriteWidth) ++ else ++ memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], SpriteWidth); + ftcp += SpriteWidth; + BaseOffset += SpriteWidth; + +@@ -218,11 +261,12 @@ + + case 1: + { +- const unsigned int * RWEntriesLoc = reinterpret_cast(FDef+BaseOffset); ++ unsigned int RWEntriesLoc = BaseOffset; + BaseOffset += sizeof(int) * SpriteHeight; + for (unsigned int i=0;i0) + ftcp += LeftMargin; + +@@ -230,18 +274,25 @@ + do + { + unsigned int SegmentLength; ++ ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + 4); + + SegmentType=FDef[BaseOffset++]; + SegmentLength=FDef[BaseOffset++] + 1; +- ++ + if (SegmentType==0xFF) + { +- memcpy(reinterpret_cast(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength); ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + SegmentLength); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SegmentLength) ++ else ++ memcpy(reinterpret_cast(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength); + BaseOffset+=SegmentLength; + } + else + { +- memset(reinterpret_cast(ret->pixels)+ftcp, SegmentType, SegmentLength); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + SegmentLength) ++ else ++ memset(reinterpret_cast(ret->pixels)+ftcp, SegmentType, SegmentLength); + } + ftcp += SegmentLength; + TotalRowLength += SegmentLength; +@@ -260,6 +311,7 @@ + + case 2: + { ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffsetor+2); + BaseOffset = BaseOffsetor + SDL_SwapLE16(read_unaligned_u16(FDef + BaseOffsetor)); + + for (unsigned int i=0;i(ret->pixels)+ftcp, &FDef[BaseOffset], value); ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + value); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + value) ++ else ++ memcpy(reinterpret_cast(ret->pixels)+ftcp, &FDef[BaseOffset], value); + ftcp += value; + BaseOffset += value; + } + else + { +- memset(reinterpret_cast(ret->pixels)+ftcp, code, value); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + value) ++ else ++ memset(reinterpret_cast(ret->pixels)+ftcp, code, value); + ftcp += value; + } + TotalRowLength+=value; +@@ -304,6 +362,7 @@ + { + for (unsigned int i=0;i0) + ftcp += LeftMargin; +@@ -312,6 +371,7 @@ + + do + { ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset+1); + SegmentType=FDef[BaseOffset++]; + unsigned char code = SegmentType / 32; + unsigned char value = (SegmentType & 31) + 1; +@@ -321,13 +381,18 @@ + + if(code==7) + { +- memcpy((ui8*)ret->pixels + ftcp, FDef + BaseOffset, len); ++ CHECK_LOD_MEM_BLOCK_SIZE(BaseOffset + len); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + len) ++ else ++ memcpy((ui8*)ret->pixels + ftcp, FDef + BaseOffset, len); + ftcp += len; + BaseOffset += len; + } + else + { +- memset((ui8*)ret->pixels + ftcp, code, len); ++ CHECK_OUTBUF_MEM_BLOCK_SIZE(ftcp + len) ++ else ++ memset((ui8*)ret->pixels + ftcp, code, len); + ftcp += len; + } + TotalRowLength+=( LeftMargin>=0 ? value : value+LeftMargin ); +@@ -345,6 +410,7 @@ + break; + + default: ++ tlog1<<"getSprite: Unknown sprite format."<< std::endl; + throw std::string("Unknown sprite format."); + break; + } +@@ -365,11 +431,15 @@ + + CDefHandler * CDefHandler::giveDef(const std::string & defName) + { +- unsigned char * data = spriteh->giveFile(defName, FILE_ANIMATION); +- if(!data) +- throw "bad def name!"; ++ //tlog0<<"giveDef " << defName <giveFile(defName, FILE_ANIMATION, &lodLength); ++ if(!data) { ++ tlog0<<"Bad def name: " << defName <openFromMemory(data, defName); ++ nh->openFromMemory(data, defName, lodLength); + delete [] data; + return nh; + } +Index: client/Graphics.cpp +=================================================================== +--- client/Graphics.cpp (revision 2387) ++++ client/Graphics.cpp (working copy) +@@ -315,8 +315,15 @@ + tasks += GET_SURFACE(backgroundsm[id], b["bg120"].String()); + } + ++#ifdef ANDROID ++ // For debug make it single-threaded ++ for(int i=0;iourImages.size(); ++y) + { +@@ -508,13 +515,20 @@ + pr[3].first = &Graphics::flags4; + pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"), + ("AF05.DEF"),("AF06.DEF"),("AF07.DEF"); ++#ifdef ANDROID ++ // We ain't no need any filthy multithreading ++ for(int g=0; g<4; g++) ++ { ++ loadHeroFlags(pr[g],true); ++ } ++#else + boost::thread_group grupa; + for(int g=3; g>=0; --g) + { + grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[g]),true)); + } + grupa.join_all(); +- tlog0 << "Loading and transforming heroes' flags: "<() || !isAllowedArrangePack((ArrangeStacks*)pack)) && // for dialogs like garrison + states[getCurrentPlayer()].queries.size()) + { ++ tlog0<<__FUNCTION__ << " at " << __FILE__ << ":" << __LINE__ << std::endl; + complain("Answer the query before attempting any further actions!"); + PackageApplied applied; + applied.result = false; +@@ -650,6 +651,7 @@ + else if(apply) + { + bool result = apply->applyOnGH(this,&c,pack); ++ tlog0<<__FUNCTION__ << " at " << __FILE__ << ":" << __LINE__ << std::endl; + tlog5 << "Message successfully applied (result=" << result << ")!\n"; + + //send confirmation that we've applied the package +@@ -1833,7 +1835,7 @@ + iw.player = h1->tempOwner; + iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarLevel, 0)); + +- iw.text.addTxt(MetaString::GENERAL_TXT, 139);//"%s, who has studied magic extensively, ++ iw.text.addTxt(MetaString::GENERAL_TXT, 139);//%s, who has studied magic extensively, + iw.text.addReplacement(h1->name); + + if (cs2.spells.size())//if found new spell - apply +Index: server/CVCMIServer.cpp +=================================================================== +--- server/CVCMIServer.cpp (revision 2387) ++++ server/CVCMIServer.cpp (working copy) +@@ -29,7 +29,7 @@ + using namespace boost; + using namespace boost::asio; + using namespace boost::asio::ip; +-namespace intpr = boost::interprocess; ++//namespace intpr = boost::interprocess; + bool end2 = false; + int port = 3030; + VCMIDirs GVCMIDirs; +@@ -379,6 +379,7 @@ + + void CVCMIServer::start() + { ++ /* + ServerReady *sr = NULL; + intpr::mapped_region *mr; + try +@@ -395,13 +396,17 @@ + mr = new intpr::mapped_region(smo,intpr::read_write); + sr = new(mr->get_address())ServerReady(); + } ++ */ ++ notifyServerReady(); + + boost::system::error_code error; + tlog0<<"Listening for connections at port " << acceptor->local_endpoint().port() << std::endl; + tcp::socket * s = new tcp::socket(acceptor->get_io_service()); + boost::thread acc(boost::bind(vaccept,acceptor,s,&error)); ++ /* + sr->setToTrueAndNotify(); + delete mr; ++ */ + + acc.join(); + if (error) +Index: server/stdafx.h +=================================================================== +--- server/stdafx.h (revision 2387) ++++ server/stdafx.h (working copy) +@@ -15,8 +15,8 @@ + #include "../global.h" + + #include +-#include +-#include ++//#include ++//#include + #include + #include + #include +Index: global.h +=================================================================== +--- global.h (revision 2387) ++++ global.h (working copy) +@@ -4,6 +4,7 @@ + #include + #include + #include //std::find ++#include //memcpy + #include //std::find + #include + #include +@@ -725,29 +726,21 @@ + } + + +-#if defined(linux) && defined(sparc) +-/* SPARC does not support unaligned memory access. Let gcc know when +- * to emit the right code. */ +-struct unaligned_Uint16 { ui16 val __attribute__(( packed )); }; +-struct unaligned_Uint32 { ui32 val __attribute__(( packed )); }; + + static inline ui16 read_unaligned_u16(const void *p) + { +- const struct unaligned_Uint16 *v = (const struct unaligned_Uint16 *)p; +- return v->val; ++ ui16 out; ++ memcpy(&out, p, sizeof(out)); ++ return out; + } + + static inline ui32 read_unaligned_u32(const void *p) + { +- const struct unaligned_Uint32 *v = (const struct unaligned_Uint32 *)p; +- return v->val; ++ ui32 out; ++ memcpy(&out, p, sizeof(out)); ++ return out; + } + +-#else +-#define read_unaligned_u16(p) (* reinterpret_cast(p)) +-#define read_unaligned_u32(p) (* reinterpret_cast(p)) +-#endif +- + //for explicit overrides + #ifdef _MSC_VER + #define OVERRIDE override diff --git a/project/jni/application/vcmi/AndroidAppSettings.cfg b/project/jni/application/vcmi/AndroidAppSettings.cfg index 4b9487bc7..bae2d7996 100644 --- a/project/jni/application/vcmi/AndroidAppSettings.cfg +++ b/project/jni/application/vcmi/AndroidAppSettings.cfg @@ -37,13 +37,13 @@ HiddenMenuOptions='KeyboardConfigMainMenu AudioConfig OptionalDownloadConfig' FirstStartMenuOptions='' MultiABI=n AppMinimumRAM=64 -AppVersionCode=08604 -AppVersionName="0.86.04" +AppVersionCode=09000 +AppVersionName="0.90.00" ResetSdlConfigForThisVersion=y DeleteFilesOnUpgrade="" CompiledLibraries="mad sdl_mixer sdl_image sdl_ttf avutil avcore avcodec avformat swscale boost_program_options boost_filesystem boost_iostreams boost_system boost_thread vcmi android" -CustomBuildScript=n -AppCflags='-DDATA_DIR=\"/sdcard/app-data/eu.vcmi\" -DBIN_DIR=\"/data/data/eu.vcmi/files\" -DLIB_DIR=\"/data/data/eu.vcmi/files\" -DWITH_AVCODEC_DECODE_VIDEO2=1 -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress' +CustomBuildScript=y +AppCflags='-DM_DATA_DIR=\"/sdcard/app-data/eu.vcmi\" -DM_BIN_DIR=\"/data/data/eu.vcmi/files\" -DM_LIB_DIR=\"/data/data/eu.vcmi/files\" -DWITH_AVCODEC_DECODE_VIDEO2=1 -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress' AppLdflags='-lz -Ljni/application/vcmi -lvcmi' AppSubdirsBuild='vcmi/client vcmi/CCallback.cpp' AppCmdline='' diff --git a/project/jni/application/vcmi/AndroidData/vcmiserver0 b/project/jni/application/vcmi/AndroidData/vcmiserver0 deleted file mode 100644 index 2b754e668..000000000 Binary files a/project/jni/application/vcmi/AndroidData/vcmiserver0 and /dev/null differ diff --git a/project/jni/application/vcmi/AndroidData/vcmiserver1 b/project/jni/application/vcmi/AndroidData/vcmiserver1 deleted file mode 100644 index 04f6f22ab..000000000 Binary files a/project/jni/application/vcmi/AndroidData/vcmiserver1 and /dev/null differ diff --git a/project/jni/application/vcmi/Makefile b/project/jni/application/vcmi/Makefile index c6eae09b9..a3b0bf155 100644 --- a/project/jni/application/vcmi/Makefile +++ b/project/jni/application/vcmi/Makefile @@ -7,7 +7,7 @@ $(shell rm -f ../../../obj/local/armeabi/libvcmi.so) LOCAL_PATH=$(shell dirname $0) LOCAL_PATH=`cd $LOCAL_PATH && pwd` -GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r5'),arm-linux-androideabi,arm-eabi) +GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r8'),arm-linux-androideabi,arm-eabi) SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/lib/Filesystem/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp) OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB)) @@ -39,7 +39,10 @@ OBJS_VCAI=$(patsubst %.cpp, out/%.o, $(SOURCES_VCAI)) SOURCES_ERM=$(wildcard vcmi/Scripting/ERM/*.cpp) OBJS_ERM=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM)) -all: AndroidData/binaries.zip +SOURCES_CLIENT=$(wildcard vcmi/client/*.cpp vcmi/CCallback.cpp) +OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT)) + +all: AndroidData/binaries.zip libapplication.so AndroidData/binaries.zip: vcmiserver AI/libGeniusAI.so AI/libStupidAI.so Scripting/libvcmiERM.so rm -f $@ @@ -48,10 +51,10 @@ AndroidData/binaries.zip: vcmiserver AI/libGeniusAI.so AI/libStupidAI.so Scripti $(OBJS_SERVER) $(OBJS_LIB) $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp ../setEnvironment.sh sh -c \ "$(GCC_PREFIX)-g++ \ - -c \$$CXXFLAGS -Ivcmi -Ivcmi/lib \ - -DDATA_DIR=\\\"/sdcard/app-data/eu.vcmi\\\" \ - -DBIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \ - -DLIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \ + -c \$$CXXFLAGS -Ivcmi -std=c++11 -Ivcmi/lib \ + -DM_DATA_DIR=\\\"/sdcard/app-data/eu.vcmi\\\" \ + -DM_BIN_DIR=\\\"/data/data/eu.vcmi/files\\\" \ + -DM_LIB_DIR=\\\"/data/data/eu.vcmi/files\\\" \ -DWITH_AVCODEC_DECODE_VIDEO2=1 \ -Wstrict-aliasing -Wcast-align -Wpointer-arith -Waddress \ $< -o $@" @@ -87,6 +90,11 @@ Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi libvcmi.so: $(OBJS_LIB) $(LINK_LIB) +libapplication.so: $(OBJS_CLIENT) libvcmi.so + env BUILD_EXECUTABLE=1 ../setEnvironment.sh sh -c \ + "$(GCC_PREFIX)-g++ $^ -o $@ \ + \$$LDFLAGS -L. -lvcmi -lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread" + clean: rm -rf out debug *.so vcmiserver* AndroidData/vcmiserver* libapplication.so AI Scripting diff --git a/project/jni/boost/Android.mk b/project/jni/boost/Android.mk index 0cb944d6e..35122b1d4 100644 --- a/project/jni/boost/Android.mk +++ b/project/jni/boost/Android.mk @@ -7,18 +7,7 @@ ifneq ($(LOCAL_MODULE),boost) LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -ifneq ($(NDK_R5_TOOLCHAIN),) -LOCAL_SRC_FILES := lib/arm-linux-androideabi-4.4.3/lib$(LOCAL_MODULE).a +LOCAL_SRC_FILES := lib/arm-linux-androideabi-4.6/lib$(LOCAL_MODULE).a include $(PREBUILT_STATIC_LIBRARY) -else -LOCAL_SRC_FILES := dummy.c -include $(BUILD_STATIC_LIBRARY) -$(abspath $(LOCAL_PATH)/../../obj/local/armeabi/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib/arm-eabi-4.4.0/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB - cp -f $< $@ -$(abspath $(LOCAL_PATH)/../../obj/local/armeabi-v7a/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib/arm-eabi-4.4.0/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB - cp -f $< $@ -.PHONY: OVERRIDE_CUSTOM_LIB -OVERRIDE_CUSTOM_LIB: -endif endif diff --git a/project/jni/boost/dummy.c b/project/jni/boost/dummy.c deleted file mode 100644 index 824cda3cc..000000000 --- a/project/jni/boost/dummy.c +++ /dev/null @@ -1,7 +0,0 @@ - -int -SDL_main(int argc, char *argv[]) -{ - return 0; -} - diff --git a/project/jni/boost/include/boost/accumulators/accumulators_fwd.hpp b/project/jni/boost/include/boost/accumulators/accumulators_fwd.hpp index d5ca5c295..9986a537b 100644 --- a/project/jni/boost/include/boost/accumulators/accumulators_fwd.hpp +++ b/project/jni/boost/include/boost/accumulators/accumulators_fwd.hpp @@ -48,6 +48,9 @@ # define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T) #endif +#define BOOST_ACCUMULATORS_GCC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + namespace boost { namespace accumulators { diff --git a/project/jni/boost/include/boost/accumulators/numeric/functional.hpp b/project/jni/boost/include/boost/accumulators/numeric/functional.hpp index 9d955dbbd..34cd91bdc 100644 --- a/project/jni/boost/include/boost/accumulators/numeric/functional.hpp +++ b/project/jni/boost/include/boost/accumulators/numeric/functional.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -277,6 +278,8 @@ namespace boost { namespace numeric struct as_min_base : std::unary_function::type> { + BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); + typename remove_const::type operator ()(Arg &) const { return (std::numeric_limits::type>::min)(); @@ -287,6 +290,8 @@ namespace boost { namespace numeric struct as_min_base >::type> : std::unary_function::type> { + BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); + typename remove_const::type operator ()(Arg &) const { return -(std::numeric_limits::type>::max)(); @@ -297,6 +302,8 @@ namespace boost { namespace numeric struct as_max_base : std::unary_function::type> { + BOOST_STATIC_ASSERT(std::numeric_limits::type>::is_specialized); + typename remove_const::type operator ()(Arg &) const { return (std::numeric_limits::type>::max)(); diff --git a/project/jni/boost/include/boost/accumulators/statistics.hpp b/project/jni/boost/include/boost/accumulators/statistics.hpp index 6f505c8d9..1d136e58e 100644 --- a/project/jni/boost/include/boost/accumulators/statistics.hpp +++ b/project/jni/boost/include/boost/accumulators/statistics.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/project/jni/boost/include/boost/accumulators/statistics/sum_kahan.hpp b/project/jni/boost/include/boost/accumulators/statistics/sum_kahan.hpp new file mode 100644 index 000000000..97ade18da --- /dev/null +++ b/project/jni/boost/include/boost/accumulators/statistics/sum_kahan.hpp @@ -0,0 +1,188 @@ +/////////////////////////////////////////////////////////////////////////////// +// sum_kahan.hpp +// +// Copyright 2010 Gaetano Mendola, 2011 Simon West. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010 +#define BOOST_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010 + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace accumulators +{ + +namespace impl +{ + +#if _MSC_VER > 1400 +# pragma float_control(push) +# pragma float_control(precise, on) +#endif + +template +struct sum_kahan_impl + : accumulator_base +{ + typedef Sample result_type; + + //////////////////////////////////////////////////////////////////////////// + // sum_kahan_impl + /** + @brief Kahan summation algorithm + + The Kahan summation algorithm reduces the numerical error obtained with standard + sequential sum. + + */ + template + sum_kahan_impl(Args const & args) + : sum(args[parameter::keyword::get() | Sample()]), + compensation(boost::numeric_cast(0.0)) + { + } + + template + void +#if BOOST_ACCUMULATORS_GCC_VERSION > 40305 + __attribute__((__optimize__("no-associative-math"))) +#endif + operator ()(Args const & args) + { + const Sample myTmp1 = args[parameter::keyword::get()] - this->compensation; + const Sample myTmp2 = this->sum + myTmp1; + this->compensation = (myTmp2 - this->sum) - myTmp1; + this->sum = myTmp2; + } + + result_type result(dont_care) const + { + return this->sum; + } + +private: + Sample sum; + Sample compensation; +}; + +#if _MSC_VER > 1400 +# pragma float_control(pop) +#endif + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::sum_kahan +// tag::sum_of_weights_kahan +// tag::sum_of_variates_kahan +// +namespace tag +{ + + struct sum_kahan + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef impl::sum_kahan_impl< mpl::_1, tag::sample > impl; + }; + + struct sum_of_weights_kahan + : depends_on<> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::sum_kahan_impl impl; + }; + + template + struct sum_of_variates_kahan + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always > impl; + }; + +} // namespace tag + +/////////////////////////////////////////////////////////////////////////////// +// extract::sum_kahan +// extract::sum_of_weights_kahan +// extract::sum_of_variates_kahan +// +namespace extract +{ + extractor const sum_kahan = {}; + extractor const sum_of_weights_kahan = {}; + extractor const sum_of_variates_kahan = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_kahan) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights_kahan) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates_kahan) +} // namespace extract + +using extract::sum_kahan; +using extract::sum_of_weights_kahan; +using extract::sum_of_variates_kahan; + +// sum(kahan) -> sum_kahan +template<> +struct as_feature +{ + typedef tag::sum_kahan type; +}; + +// sum_of_weights(kahan) -> sum_of_weights_kahan +template<> +struct as_feature +{ + typedef tag::sum_of_weights_kahan type; +}; + +// So that sum_kahan can be automatically substituted with +// weighted_sum_kahan when the weight parameter is non-void. +template<> +struct as_weighted_feature +{ + typedef tag::weighted_sum_kahan type; +}; + +template<> +struct feature_of + : feature_of +{}; + +// for the purposes of feature-based dependency resolution, +// sum_kahan provides the same feature as sum +template<> +struct feature_of + : feature_of +{ +}; + +// for the purposes of feature-based dependency resolution, +// sum_of_weights_kahan provides the same feature as sum_of_weights +template<> +struct feature_of + : feature_of +{ +}; + +template +struct feature_of > + : feature_of +{ +}; + +}} // namespace boost::accumulators + +#endif + diff --git a/project/jni/boost/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp b/project/jni/boost/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp index 4e0d4efa5..5dc84f476 100644 --- a/project/jni/boost/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp +++ b/project/jni/boost/include/boost/accumulators/statistics/weighted_p_square_quantile.hpp @@ -8,6 +8,7 @@ #ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 #define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 +#include #include #include #include diff --git a/project/jni/boost/include/boost/accumulators/statistics/weighted_sum_kahan.hpp b/project/jni/boost/include/boost/accumulators/statistics/weighted_sum_kahan.hpp new file mode 100644 index 000000000..fbb0303ac --- /dev/null +++ b/project/jni/boost/include/boost/accumulators/statistics/weighted_sum_kahan.hpp @@ -0,0 +1,138 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_sum_kahan.hpp +// +// Copyright 2011 Simon West. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace accumulators +{ + +namespace impl +{ +#if _MSC_VER > 1400 +# pragma float_control(push) +# pragma float_control(precise, on) +#endif + + /////////////////////////////////////////////////////////////////////////////// + // weighted_sum_kahan_impl + template + struct weighted_sum_kahan_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies::result_type weighted_sample; + + // for boost::result_of + typedef weighted_sample result_type; + + template + weighted_sum_kahan_impl(Args const &args) + : weighted_sum_( + args[parameter::keyword::get() | Sample()] * numeric::one::value), + compensation(boost::numeric_cast(0.0)) + { + } + + template + void +#if BOOST_ACCUMULATORS_GCC_VERSION > 40305 + __attribute__((__optimize__("no-associative-math"))) +#endif + operator ()(Args const &args) + { + const weighted_sample myTmp1 = args[parameter::keyword::get()] * args[weight] - this->compensation; + const weighted_sample myTmp2 = this->weighted_sum_ + myTmp1; + this->compensation = (myTmp2 - this->weighted_sum_) - myTmp1; + this->weighted_sum_ = myTmp2; + + } + + result_type result(dont_care) const + { + return this->weighted_sum_; + } + + private: + weighted_sample weighted_sum_; + weighted_sample compensation; + }; + +#if _MSC_VER > 1400 +# pragma float_control(pop) +#endif + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_sum_kahan +// tag::weighted_sum_of_variates_kahan +// +namespace tag +{ + struct weighted_sum_kahan + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_sum_kahan_impl impl; + }; + + template + struct weighted_sum_of_variates_kahan + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_sum_kahan_impl impl; + }; + +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_sum_kahan +// extract::weighted_sum_of_variates_kahan +// +namespace extract +{ + extractor const weighted_sum_kahan = {}; + extractor const weighted_sum_of_variates_kahan = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_kahan) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_of_variates_kahan) +} + +using extract::weighted_sum_kahan; +using extract::weighted_sum_of_variates_kahan; + +// weighted_sum(kahan) -> weighted_sum_kahan +template<> +struct as_feature +{ + typedef tag::weighted_sum_kahan type; +}; + +template +struct feature_of > + : feature_of +{ +}; + +}} // namespace boost::accumulators + +#endif diff --git a/project/jni/boost/include/boost/accumulators/statistics_fwd.hpp b/project/jni/boost/include/boost/accumulators/statistics_fwd.hpp index 196814b68..61904f30b 100644 --- a/project/jni/boost/include/boost/accumulators/statistics_fwd.hpp +++ b/project/jni/boost/include/boost/accumulators/statistics_fwd.hpp @@ -109,6 +109,10 @@ namespace tag struct sum_of_weights; template struct sum_of_variates; + struct sum_kahan; + struct sum_of_weights_kahan; + template + struct sum_of_variates_kahan; template struct tail; template @@ -263,6 +267,9 @@ namespace impl template struct sum_impl; + template + struct sum_kahan_impl; + template struct tail_impl; @@ -338,6 +345,9 @@ namespace impl template struct weighted_sum_impl; + template + struct weighted_sum_kahan_impl; + template struct non_coherent_weighted_tail_mean_impl; @@ -414,6 +424,9 @@ struct quadratic {}; struct regular {}; struct for_median {}; +// modifier for sum_kahan, sum_of_weights_kahan, sum_of_variates_kahan, weighted_sum_kahan +struct kahan {}; + }} // namespace boost::accumulators #endif diff --git a/project/jni/boost/include/boost/algorithm/string/detail/case_conv.hpp b/project/jni/boost/include/boost/algorithm/string/detail/case_conv.hpp index 5b0064fd1..42621c74f 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/case_conv.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/case_conv.hpp @@ -15,6 +15,8 @@ #include #include +#include + namespace boost { namespace algorithm { namespace detail { @@ -37,7 +39,7 @@ namespace boost { CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::tolower( Ch); + return std::tolower( static_cast::type> ( Ch )); #else return std::tolower( Ch, *m_Loc ); #endif @@ -57,7 +59,7 @@ namespace boost { CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper( Ch); + return std::toupper( static_cast::type> ( Ch )); #else return std::toupper( Ch, *m_Loc ); #endif diff --git a/project/jni/boost/include/boost/algorithm/string/detail/classification.hpp b/project/jni/boost/include/boost/algorithm/string/detail/classification.hpp index fb4395573..704d9d20f 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/classification.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/classification.hpp @@ -126,7 +126,7 @@ namespace boost { } // Use fixed storage - ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); } // Destructor @@ -206,7 +206,7 @@ namespace boost { } // Copy the data - ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); return *this; } diff --git a/project/jni/boost/include/boost/algorithm/string/detail/find_format.hpp b/project/jni/boost/include/boost/algorithm/string/detail/find_format.hpp index 7f5f780b6..8b9ad4276 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/find_format.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/find_format.hpp @@ -74,17 +74,17 @@ namespace boost { const InputT& Input, FormatterT Formatter, const FindResultT& FindResult ) - { + { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_copy_impl2( - Output, - Input, - Formatter, - FindResult, - Formatter(FindResult) ); + return ::boost::algorithm::detail::find_format_copy_impl2( + Output, + Input, + Formatter, + FindResult, + Formatter(FindResult) ); } else { return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); - } + } } @@ -137,14 +137,14 @@ namespace boost { const FindResultT& FindResult) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_copy_impl2( - Input, - Formatter, - FindResult, - Formatter(FindResult) ); + return ::boost::algorithm::detail::find_format_copy_impl2( + Input, + Formatter, + FindResult, + Formatter(FindResult) ); } else { return Input; - } + } } // replace implementation ----------------------------------------------------// @@ -189,12 +189,12 @@ namespace boost { const FindResultT& FindResult) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - ::boost::algorithm::detail::find_format_impl2( - Input, - Formatter, - FindResult, - Formatter(FindResult) ); - } + ::boost::algorithm::detail::find_format_impl2( + Input, + Formatter, + FindResult, + Formatter(FindResult) ); + } } } // namespace detail diff --git a/project/jni/boost/include/boost/algorithm/string/detail/find_format_all.hpp b/project/jni/boost/include/boost/algorithm/string/detail/find_format_all.hpp index 0f184a318..978710c95 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/find_format_all.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/find_format_all.hpp @@ -84,18 +84,18 @@ namespace boost { FinderT Finder, FormatterT Formatter, const FindResultT& FindResult ) - { + { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_all_copy_impl2( - Output, - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); + return ::boost::algorithm::detail::find_format_all_copy_impl2( + Output, + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); } else { return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); - } + } } // find_format_all_copy implementation ----------------------------------------------// @@ -161,15 +161,15 @@ namespace boost { const FindResultT& FindResult) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - return ::boost::algorithm::detail::find_format_all_copy_impl2( - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); + return ::boost::algorithm::detail::find_format_all_copy_impl2( + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); } else { return Input; - } + } } // find_format_all implementation ------------------------------------------------// @@ -257,13 +257,13 @@ namespace boost { FindResultT FindResult) { if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { - ::boost::algorithm::detail::find_format_all_impl2( - Input, - Finder, - Formatter, - FindResult, - Formatter(FindResult) ); - } + ::boost::algorithm::detail::find_format_all_impl2( + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); + } } } // namespace detail diff --git a/project/jni/boost/include/boost/algorithm/string/detail/find_format_store.hpp b/project/jni/boost/include/boost/algorithm/string/detail/find_format_store.hpp index 4872c5a99..e8bd84a6f 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/find_format_store.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/find_format_store.hpp @@ -53,7 +53,7 @@ namespace boost { { iterator_range::operator=(FindResult); if( !this->empty() ) { - m_FormatResult=m_Formatter(FindResult); + m_FormatResult=m_Formatter(FindResult); } return *this; diff --git a/project/jni/boost/include/boost/algorithm/string/detail/formatter.hpp b/project/jni/boost/include/boost/algorithm/string/detail/formatter.hpp index bd6a78029..8e7b727e7 100644 --- a/project/jni/boost/include/boost/algorithm/string/detail/formatter.hpp +++ b/project/jni/boost/include/boost/algorithm/string/detail/formatter.hpp @@ -87,6 +87,31 @@ namespace boost { } }; +// dissect format functor ----------------------------------------------------// + + // dissect format functor + template + struct dissect_formatF + { + public: + // Construction + dissect_formatF(FinderT Finder) : + m_Finder(Finder) {} + + // Operation + template + inline iterator_range< + BOOST_STRING_TYPENAME range_const_iterator::type> + operator()(const RangeT& Replace) const + { + return m_Finder(::boost::begin(Replace), ::boost::end(Replace)); + } + + private: + FinderT m_Finder; + }; + + } // namespace detail } // namespace algorithm } // namespace boost diff --git a/project/jni/boost/include/boost/algorithm/string/find_iterator.hpp b/project/jni/boost/include/boost/algorithm/string/find_iterator.hpp index 72696c748..b72ba7c78 100644 --- a/project/jni/boost/include/boost/algorithm/string/find_iterator.hpp +++ b/project/jni/boost/include/boost/algorithm/string/find_iterator.hpp @@ -259,7 +259,11 @@ namespace boost { m_End(End), m_bEof(false) { - increment(); + // force the correct behavior for empty sequences and yield at least one token + if(Begin!=End) + { + increment(); + } } //! Constructor /*! @@ -278,7 +282,11 @@ namespace boost { m_Next=::boost::begin(lit_col); m_End=::boost::end(lit_col); - increment(); + // force the correct behavior for empty sequences and yield at least one token + if(m_Next!=m_End) + { + increment(); + } } diff --git a/project/jni/boost/include/boost/algorithm/string/formatter.hpp b/project/jni/boost/include/boost/algorithm/string/formatter.hpp index 50006df10..ab5921e73 100644 --- a/project/jni/boost/include/boost/algorithm/string/formatter.hpp +++ b/project/jni/boost/include/boost/algorithm/string/formatter.hpp @@ -36,7 +36,7 @@ namespace boost { //! Constant formatter /*! - Construct the \c const_formatter. Const formatter always returns + Constructs a \c const_formatter. Const formatter always returns the same value, regardless of the parameter. \param Format A predefined value used as a result for formating @@ -55,7 +55,7 @@ namespace boost { //! Identity formatter /*! - Construct the \c identity_formatter. Identity formatter always returns + Constructs an \c identity_formatter. Identity formatter always returns the parameter. \return An instance of the \c identity_formatter object. @@ -73,7 +73,7 @@ namespace boost { //! Empty formatter /*! - Construct the \c empty_formatter. Empty formatter always returns an empty + Constructs an \c empty_formatter. Empty formatter always returns an empty sequence. \param Input container used to select a correct value_type for the @@ -89,6 +89,22 @@ namespace boost { BOOST_STRING_TYPENAME range_value::type>(); } + //! Empty formatter + /*! + Constructs a \c dissect_formatter. Dissect formatter uses a specified finder + to extract a portion of the formatted sequence. The first finder's match is returned + as a result + + \param Finder a finder used to select a portion of the formated sequence + \return An instance of the \c dissect_formatter object. + */ + template + inline detail::dissect_formatF< FinderT > + dissect_formatter(const FinderT& Finder) + { + return detail::dissect_formatF(Finder); + } + } // namespace algorithm @@ -96,6 +112,7 @@ namespace boost { using algorithm::const_formatter; using algorithm::identity_formatter; using algorithm::empty_formatter; + using algorithm::dissect_formatter; } // namespace boost diff --git a/project/jni/boost/include/boost/algorithm/string/trim_all.hpp b/project/jni/boost/include/boost/algorithm/string/trim_all.hpp new file mode 100644 index 000000000..70fd0412e --- /dev/null +++ b/project/jni/boost/include/boost/algorithm/string/trim_all.hpp @@ -0,0 +1,217 @@ +// Boost string_algo library trim.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_TRIM_ALL_HPP +#define BOOST_STRING_TRIM_ALL_HPP + +#include + +#include +#include +#include +#include +#include +#include + +/*! \file + Defines trim_all algorithms. + + Just like \c trim, \c trim_all removes all trailing and leading spaces from a + sequence (string). In addition, spaces in the middle of the sequence are truncated + to just one character. Space is recognized using given locales. + + \c trim_fill acts as trim_all, but the spaces in the middle are replaces with + a user-define sequence of character. + + Parametric (\c _if) variants use a predicate (functor) to select which characters + are to be trimmed.. + Functions take a selection predicate as a parameter, which is used to determine + whether a character is a space. Common predicates are provided in classification.hpp header. + +*/ + +namespace boost { + namespace algorithm { + + // multi line trim ----------------------------------------------- // + + //! Trim All - parametric + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The result is a trimmed copy of the input + + \param Input An input sequence + \param IsSpace An unary predicate identifying spaces + \return A trimmed copy of the input + */ + template + inline SequenceT trim_all_copy_if(const SequenceT& Input, PredicateT IsSpace) + { + return + ::boost::find_format_all_copy( + ::boost::trim_copy_if(Input, IsSpace), + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::dissect_formatter(::boost::head_finder(1))); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The input sequence is modified in-place. + + \param Input An input sequence + \param IsSpace An unary predicate identifying spaces + */ + template + inline void trim_all_if(SequenceT& Input, PredicateT IsSpace) + { + ::boost::trim_if(Input, IsSpace); + ::boost::find_format_all( + Input, + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::dissect_formatter(::boost::head_finder(1))); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template + inline SequenceT trim_all_copy(const SequenceT& Input, const std::locale& Loc =std::locale()) + { + return trim_all_copy_if(Input, ::boost::is_space(Loc)); + } + + + //! Trim All + /*! + Remove all leading and trailing spaces from the input and + compress all other spaces to a single character. + The input sequence is modified in-place. + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template + inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale()) + { + trim_all_if(Input, ::boost::is_space(Loc)); + } + + + //! Trim Fill - parametric + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param IsSpace An unary predicate identifying spaces + \return A trimmed copy of the input + */ + template + inline SequenceT trim_fill_copy_if(const SequenceT& Input, const RangeT& Fill, PredicateT IsSpace) + { + return + ::boost::find_format_all_copy( + ::boost::trim_copy_if(Input, IsSpace), + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::const_formatter(::boost::as_literal(Fill))); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The input sequence is modified in-place. + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param IsSpace An unary predicate identifying spaces + */ + template + inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace) + { + ::boost::trim_if(Input, IsSpace); + ::boost::find_format_all( + Input, + ::boost::token_finder(IsSpace, ::boost::token_compress_on), + ::boost::const_formatter(::boost::as_literal(Fill))); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template + inline SequenceT trim_fill_copy(const SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale()) + { + return trim_fill_copy_if(Input, Fill, ::boost::is_space(Loc)); + } + + + //! Trim Fill + /*! + Remove all leading and trailing spaces from the input and + replace all every block of consecutive spaces with a fill string + defined by user. + The input sequence is modified in-place. + + \param Input An input sequence + \param Fill A string used to fill the inner spaces + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + */ + template + inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale()) + { + trim_fill_if(Input, Fill, ::boost::is_space(Loc)); + } + + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::trim_all; + using algorithm::trim_all_if; + using algorithm::trim_all_copy; + using algorithm::trim_all_copy_if; + using algorithm::trim_fill; + using algorithm::trim_fill_if; + using algorithm::trim_fill_copy; + using algorithm::trim_fill_copy_if; + +} // namespace boost + +#endif // BOOST_STRING_TRIM_ALL_HPP diff --git a/project/jni/boost/include/boost/archive/archive_exception.hpp b/project/jni/boost/include/boost/archive/archive_exception.hpp index 242f75288..b5f33f685 100644 --- a/project/jni/boost/include/boost/archive/archive_exception.hpp +++ b/project/jni/boost/include/boost/archive/archive_exception.hpp @@ -17,7 +17,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include diff --git a/project/jni/boost/include/boost/archive/basic_archive.hpp b/project/jni/boost/include/boost/archive/basic_archive.hpp index b6769dddb..d40848520 100644 --- a/project/jni/boost/include/boost/archive/basic_archive.hpp +++ b/project/jni/boost/include/boost/archive/basic_archive.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include #include // size_t #include @@ -44,7 +44,7 @@ private: public: library_version_type(): t(0) {}; explicit library_version_type(const unsigned int & t_) : t(t_){ - assert(t_ <= boost::integer_traits::const_max); + BOOST_ASSERT(t_ <= boost::integer_traits::const_max); } library_version_type(const library_version_type & t_) : t(t_.t) @@ -80,7 +80,7 @@ public: // should be private - but MPI fails if it's not!!! version_type(): t(0) {}; explicit version_type(const unsigned int & t_) : t(t_){ - assert(t_ <= boost::integer_traits::const_max); + BOOST_ASSERT(t_ <= boost::integer_traits::const_max); } version_type(const version_type & t_) : t(t_.t) @@ -113,10 +113,10 @@ public: // should be private - but then can't use BOOST_STRONG_TYPE below class_id_type() : t(0) {}; explicit class_id_type(const int t_) : t(t_){ - assert(t_ <= boost::integer_traits::const_max); + BOOST_ASSERT(t_ <= boost::integer_traits::const_max); } explicit class_id_type(const std::size_t t_) : t(t_){ - // assert(t_ <= boost::integer_traits::const_max); + // BOOST_ASSERT(t_ <= boost::integer_traits::const_max); } class_id_type(const class_id_type & t_) : t(t_.t) @@ -151,7 +151,7 @@ private: public: object_id_type(): t(0) {}; explicit object_id_type(const unsigned int & t_) : t(t_){ - assert(t_ <= boost::integer_traits::const_max); + BOOST_ASSERT(t_ <= boost::integer_traits::const_max); } object_id_type(const object_id_type & t_) : t(t_.t) @@ -254,7 +254,7 @@ BOOST_ARCHIVE_SIGNATURE(); #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \ class D : public T { \ public: \ - explicit D(const T t) : T(t){} \ + explicit D(const T tt) : T(tt){} \ }; \ /**/ diff --git a/project/jni/boost/include/boost/archive/basic_binary_iarchive.hpp b/project/jni/boost/include/boost/archive/basic_binary_iarchive.hpp index 956739555..d851dab4d 100644 --- a/project/jni/boost/include/boost/archive/basic_binary_iarchive.hpp +++ b/project/jni/boost/include/boost/archive/basic_binary_iarchive.hpp @@ -72,7 +72,6 @@ public: // include these to trap a change in binary format which // isn't specifically handled - BOOST_STATIC_ASSERT(sizeof(tracking_type) == sizeof(bool)); // upto 32K classes BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t)); BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t)); @@ -83,6 +82,19 @@ public: // binary files don't include the optional information void load_override(class_id_optional_type & /* t */, int){} + void load_override(tracking_type & t, int /*version*/){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(6) < lvt){ + int_least8_t x=0; + * this->This() >> x; + t = boost::archive::tracking_type(x); + } + else{ + bool x=0; + * this->This() >> x; + t = boost::archive::tracking_type(x); + } + } void load_override(class_id_type & t, int version){ library_version_type lvt = this->get_library_version(); if(boost::archive::library_version_type(7) < lvt){ @@ -134,10 +146,23 @@ public: } else if(boost::archive::library_version_type(6) < lvt){ + uint_least8_t x=0; + * this->This() >> x; + t = boost::archive::version_type(x); + } + else + if(boost::archive::library_version_type(5) < lvt){ uint_least16_t x=0; * this->This() >> x; t = boost::archive::version_type(x); } + else + if(boost::archive::library_version_type(2) < lvt){ + // upto 255 versions + unsigned char x=0; + * this->This() >> x; + t = version_type(x); + } else{ unsigned int x=0; * this->This() >> x; @@ -147,7 +172,8 @@ public: void load_override(boost::serialization::item_version_type & t, int version){ library_version_type lvt = this->get_library_version(); - if(boost::archive::library_version_type(7) < lvt){ +// if(boost::archive::library_version_type(7) < lvt){ + if(boost::archive::library_version_type(6) < lvt){ this->detail_common_iarchive::load_override(t, version); } else diff --git a/project/jni/boost/include/boost/archive/basic_binary_iprimitive.hpp b/project/jni/boost/include/boost/archive/basic_binary_iprimitive.hpp index a5b6bd4aa..fc27123de 100644 --- a/project/jni/boost/include/boost/archive/basic_binary_iprimitive.hpp +++ b/project/jni/boost/include/boost/archive/basic_binary_iprimitive.hpp @@ -28,7 +28,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include // std::memcpy #include // std::size_t @@ -95,7 +95,7 @@ public: void load(bool & t){ load_binary(& t, sizeof(t)); int i = t; - assert(0 == i || 1 == i); + BOOST_ASSERT(0 == i || 1 == i); (void)i; // warning suppression for release builds. } BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) @@ -151,7 +151,7 @@ basic_binary_iprimitive::load_binary( std::size_t count ){ // note: an optimizer should eliminate the following for char files - assert( + BOOST_ASSERT( static_cast(count / sizeof(Elem)) <= boost::integer_traits::const_max ); @@ -165,7 +165,7 @@ basic_binary_iprimitive::load_binary( archive_exception(archive_exception::input_stream_error) ); // note: an optimizer should eliminate the following for char files - assert(count % sizeof(Elem) <= boost::integer_traits::const_max); + BOOST_ASSERT(count % sizeof(Elem) <= boost::integer_traits::const_max); s = static_cast(count % sizeof(Elem)); if(0 < s){ // if(is.fail()) diff --git a/project/jni/boost/include/boost/archive/basic_binary_oarchive.hpp b/project/jni/boost/include/boost/archive/basic_binary_oarchive.hpp index 5321bf0b6..01622b9f3 100644 --- a/project/jni/boost/include/boost/archive/basic_binary_oarchive.hpp +++ b/project/jni/boost/include/boost/archive/basic_binary_oarchive.hpp @@ -23,7 +23,7 @@ // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE // ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON -#include +#include #include #include #include diff --git a/project/jni/boost/include/boost/archive/basic_binary_oprimitive.hpp b/project/jni/boost/include/boost/archive/basic_binary_oprimitive.hpp index fb0485881..53e44e4fa 100644 --- a/project/jni/boost/include/boost/archive/basic_binary_oprimitive.hpp +++ b/project/jni/boost/include/boost/archive/basic_binary_oprimitive.hpp @@ -24,7 +24,7 @@ // ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON #include -#include +#include #include #include // basic_streambuf #include @@ -88,7 +88,7 @@ public: // trap usage of invalid uninitialized boolean which would // otherwise crash on load. void save(const bool t){ - assert(0 == static_cast(t) || 1 == static_cast(t)); + BOOST_ASSERT(0 == static_cast(t) || 1 == static_cast(t)); save_binary(& t, sizeof(t)); } BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) @@ -146,7 +146,7 @@ basic_binary_oprimitive::save_binary( const void *address, std::size_t count ){ - //assert( + //BOOST_ASSERT( // static_cast((std::numeric_limits::max)()) >= count //); // note: if the following assertions fail @@ -160,7 +160,7 @@ basic_binary_oprimitive::save_binary( // figure number of elements to output - round up count = ( count + sizeof(Elem) - 1) / sizeof(Elem); - assert(count <= std::size_t(boost::integer_traits::const_max)); + BOOST_ASSERT(count <= std::size_t(boost::integer_traits::const_max)); std::streamsize scount = m_sb.sputn( static_cast(address), static_cast(count) @@ -173,7 +173,7 @@ basic_binary_oprimitive::save_binary( // static_cast(address), // count //); - //assert(os.good()); + //BOOST_ASSERT(os.good()); } } //namespace boost diff --git a/project/jni/boost/include/boost/archive/basic_text_iprimitive.hpp b/project/jni/boost/include/boost/archive/basic_text_iprimitive.hpp index 67ba7db3e..b927ec91a 100644 --- a/project/jni/boost/include/boost/archive/basic_text_iprimitive.hpp +++ b/project/jni/boost/include/boost/archive/basic_text_iprimitive.hpp @@ -24,7 +24,7 @@ // in such cases. So we can't use basic_ostream but rather // use two template parameters -#include +#include #include #include // size_t diff --git a/project/jni/boost/include/boost/archive/basic_text_oarchive.hpp b/project/jni/boost/include/boost/archive/basic_text_oarchive.hpp index f6ec53420..dd10f6598 100644 --- a/project/jni/boost/include/boost/archive/basic_text_oarchive.hpp +++ b/project/jni/boost/include/boost/archive/basic_text_oarchive.hpp @@ -24,7 +24,7 @@ // in such cases. So we can't use basic_ostream but rather // use two template parameters -#include +#include #include #include #include diff --git a/project/jni/boost/include/boost/archive/basic_text_oprimitive.hpp b/project/jni/boost/include/boost/archive/basic_text_oprimitive.hpp index c0e884aa0..06885ad35 100644 --- a/project/jni/boost/include/boost/archive/basic_text_oprimitive.hpp +++ b/project/jni/boost/include/boost/archive/basic_text_oprimitive.hpp @@ -27,7 +27,7 @@ #include #include #include // isnan -#include +#include #include // size_t #include @@ -97,7 +97,7 @@ public: void save(const bool t){ // trap usage of invalid uninitialized boolean which would // otherwise crash on load. - assert(0 == static_cast(t) || 1 == static_cast(t)); + BOOST_ASSERT(0 == static_cast(t) || 1 == static_cast(t)); if(os.fail()) boost::serialization::throw_exception( archive_exception(archive_exception::output_stream_error) diff --git a/project/jni/boost/include/boost/archive/detail/basic_serializer.hpp b/project/jni/boost/include/boost/archive/detail/basic_serializer.hpp index ab2ffe9d0..5dbd88652 100644 --- a/project/jni/boost/include/boost/archive/detail/basic_serializer.hpp +++ b/project/jni/boost/include/boost/archive/detail/basic_serializer.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // NULL #include @@ -42,7 +42,7 @@ protected: ) : m_eti(& eti) { - assert(NULL != & eti); + BOOST_ASSERT(NULL != & eti); } public: inline bool diff --git a/project/jni/boost/include/boost/archive/detail/oserializer.hpp b/project/jni/boost/include/boost/archive/detail/oserializer.hpp index e676f6365..7d2694d77 100644 --- a/project/jni/boost/include/boost/archive/detail/oserializer.hpp +++ b/project/jni/boost/include/boost/archive/detail/oserializer.hpp @@ -22,7 +22,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // NULL #include @@ -186,7 +186,7 @@ BOOST_DLLEXPORT void pointer_oserializer::save_object_ptr( basic_oarchive & ar, const void * x ) const { - assert(NULL != x); + BOOST_ASSERT(NULL != x); // make sure call is routed through the highest interface that might // be specialized by the user. T * t = static_cast(const_cast(x)); @@ -384,7 +384,7 @@ struct save_pointer_type { // retrieve the true type of the object pointed to // if this assertion fails its an error in this library - assert(NULL != this_type); + BOOST_ASSERT(NULL != this_type); const boost::serialization::extended_type_info * true_type = i.get_derived_extended_type_info(t); @@ -433,12 +433,12 @@ struct save_pointer_type { archive_serializer_map >::get_const_instance().find(*true_type) ); - assert(NULL != bpos); + BOOST_ASSERT(NULL != bpos); if(NULL == bpos) boost::serialization::throw_exception( archive_exception( archive_exception::unregistered_class, - bpos->get_debug_info() + "derived class not registered or exported" ) ); ar.save_pointer(vp, bpos); diff --git a/project/jni/boost/include/boost/archive/impl/basic_binary_iarchive.ipp b/project/jni/boost/include/boost/archive/impl/basic_binary_iarchive.ipp index a9757b30d..8ea39f700 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_binary_iarchive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_binary_iarchive.ipp @@ -8,7 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include diff --git a/project/jni/boost/include/boost/archive/impl/basic_binary_iprimitive.ipp b/project/jni/boost/include/boost/archive/impl/basic_binary_iprimitive.ipp index f60957132..e0f5c2ea1 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_binary_iprimitive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_binary_iprimitive.ipp @@ -8,7 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // size_t, NULL #include // memcpy diff --git a/project/jni/boost/include/boost/archive/impl/basic_binary_oarchive.ipp b/project/jni/boost/include/boost/archive/impl/basic_binary_oarchive.ipp index cd12c4c6a..dec2cd77a 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_binary_oarchive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_binary_oarchive.ipp @@ -8,7 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include diff --git a/project/jni/boost/include/boost/archive/impl/basic_text_iprimitive.ipp b/project/jni/boost/include/boost/archive/impl/basic_text_iprimitive.ipp index 581dbfb33..ad6a6d58d 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_text_iprimitive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_text_iprimitive.ipp @@ -63,7 +63,7 @@ basic_text_iprimitive::load_binary( if(0 == count) return; - assert( + BOOST_ASSERT( static_cast((std::numeric_limits::max)()) > (count + sizeof(CharType) - 1)/sizeof(CharType) ); diff --git a/project/jni/boost/include/boost/archive/impl/basic_text_oarchive.ipp b/project/jni/boost/include/boost/archive/impl/basic_text_oarchive.ipp index fb8d18e4a..34e6995ce 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_text_oarchive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_text_oarchive.ipp @@ -8,7 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include // for BOOST_DEDUCED_TYPENAME @@ -32,7 +32,7 @@ basic_text_oarchive::newtoken() { switch(delimiter){ default: - assert(false); + BOOST_ASSERT(false); break; case eol: this->This()->put('\n'); diff --git a/project/jni/boost/include/boost/archive/impl/basic_xml_grammar.hpp b/project/jni/boost/include/boost/archive/impl/basic_xml_grammar.hpp index ca6182e5d..807ed0722 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_xml_grammar.hpp +++ b/project/jni/boost/include/boost/archive/impl/basic_xml_grammar.hpp @@ -55,26 +55,8 @@ # pragma warning (disable : 4786) // too long name, harmless warning #endif -//#define BOOST_SPIRIT_DEBUG -#include - -// the following hack is to evade a bogus error generated by using the -// word "arg" when bind.hpp has been included -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) -#define arg xarg -#endif - -// spirit stuff -#if (defined __BORLANDC__) && (__BORLANDC__ < 0x593) \ - || (defined _MSC_VER) && (_MSC_VER <= 1300) -#include -#else +#include #include -#endif - -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) -#undef arg -#endif #include #include @@ -97,12 +79,12 @@ public: private: typedef BOOST_DEDUCED_TYPENAME std::basic_istream IStream; typedef BOOST_DEDUCED_TYPENAME std::basic_string StringType; - typedef BOOST_DEDUCED_TYPENAME boost::spirit::chset chset_t; - typedef BOOST_DEDUCED_TYPENAME boost::spirit::chlit chlit_t; - typedef BOOST_DEDUCED_TYPENAME boost::spirit::scanner< + typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chset chset_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chlit chlit_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::scanner< BOOST_DEDUCED_TYPENAME std::basic_string::iterator > scanner_t; - typedef BOOST_DEDUCED_TYPENAME boost::spirit::rule rule_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::rule rule_t; // Start grammar definition rule_t Reference, diff --git a/project/jni/boost/include/boost/archive/impl/basic_xml_iarchive.ipp b/project/jni/boost/include/boost/archive/impl/basic_xml_iarchive.ipp index 9528c4ad6..52dfde1a2 100644 --- a/project/jni/boost/include/boost/archive/impl/basic_xml_iarchive.ipp +++ b/project/jni/boost/include/boost/archive/impl/basic_xml_iarchive.ipp @@ -8,7 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // NULL #include diff --git a/project/jni/boost/include/boost/archive/impl/xml_wiarchive_impl.ipp b/project/jni/boost/include/boost/archive/impl/xml_wiarchive_impl.ipp index 58498dbe1..9dde66c87 100644 --- a/project/jni/boost/include/boost/archive/impl/xml_wiarchive_impl.ipp +++ b/project/jni/boost/include/boost/archive/impl/xml_wiarchive_impl.ipp @@ -20,7 +20,7 @@ namespace std{ #include // msvc 6.0 needs this to suppress warnings #ifndef BOOST_NO_STD_WSTREAMBUF -#include +#include #include #include // Dinkumware and RogueWave diff --git a/project/jni/boost/include/boost/archive/iterators/base64_exception.hpp b/project/jni/boost/include/boost/archive/iterators/base64_exception.hpp index eb2d2e1ba..81ad28ed8 100644 --- a/project/jni/boost/include/boost/archive/iterators/base64_exception.hpp +++ b/project/jni/boost/include/boost/archive/iterators/base64_exception.hpp @@ -20,7 +20,7 @@ #ifndef BOOST_NO_EXCEPTIONS #include -#include +#include namespace boost { namespace archive { @@ -53,7 +53,7 @@ public: msg = "attempt to decode a value not in base64 char set"; break; default: - assert(false); + BOOST_ASSERT(false); break; } return msg; diff --git a/project/jni/boost/include/boost/archive/iterators/base64_from_binary.hpp b/project/jni/boost/include/boost/archive/iterators/base64_from_binary.hpp index 4e6023a8f..ecb916a06 100644 --- a/project/jni/boost/include/boost/archive/iterators/base64_from_binary.hpp +++ b/project/jni/boost/include/boost/archive/iterators/base64_from_binary.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // size_t #include // for BOOST_DEDUCED_TYPENAME @@ -49,7 +49,7 @@ struct from_6_bit { "abcdefghijklmnopqrstuvwxyz" "0123456789" "+/"; - assert(t < 64); + BOOST_ASSERT(t < 64); return lookup_table[static_cast(t)]; } }; diff --git a/project/jni/boost/include/boost/archive/iterators/binary_from_base64.hpp b/project/jni/boost/include/boost/archive/iterators/binary_from_base64.hpp index d14439f1c..60f23f397 100644 --- a/project/jni/boost/include/boost/archive/iterators/binary_from_base64.hpp +++ b/project/jni/boost/include/boost/archive/iterators/binary_from_base64.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME #include @@ -39,7 +39,7 @@ template struct to_6_bit { typedef CharType result_type; CharType operator()(CharType t) const{ - const char lookup_table[] = { + const signed char lookup_table[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, diff --git a/project/jni/boost/include/boost/archive/iterators/dataflow.hpp b/project/jni/boost/include/boost/archive/iterators/dataflow.hpp index 795848240..1623b67b7 100644 --- a/project/jni/boost/include/boost/archive/iterators/dataflow.hpp +++ b/project/jni/boost/include/boost/archive/iterators/dataflow.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME @@ -47,7 +47,7 @@ struct tri_state { } m_state; // convert to bool operator bool (){ - assert(is_indeterminant != m_state); + BOOST_ASSERT(is_indeterminant != m_state); return is_true == m_state ? true : false; } // assign from bool diff --git a/project/jni/boost/include/boost/archive/iterators/dataflow_exception.hpp b/project/jni/boost/include/boost/archive/iterators/dataflow_exception.hpp index 765661e47..1d655a1e4 100644 --- a/project/jni/boost/include/boost/archive/iterators/dataflow_exception.hpp +++ b/project/jni/boost/include/boost/archive/iterators/dataflow_exception.hpp @@ -21,7 +21,7 @@ #include #endif //BOOST_NO_EXCEPTIONS -#include +#include namespace boost { namespace archive { @@ -66,7 +66,7 @@ public: msg = "invalid multbyte/wide char conversion"; break; default: - assert(false); + BOOST_ASSERT(false); break; } return msg; diff --git a/project/jni/boost/include/boost/archive/iterators/escape.hpp b/project/jni/boost/include/boost/archive/iterators/escape.hpp index b11d1a672..bb527d439 100644 --- a/project/jni/boost/include/boost/archive/iterators/escape.hpp +++ b/project/jni/boost/include/boost/archive/iterators/escape.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // NULL #include // for BOOST_DEDUCED_TYPENAME diff --git a/project/jni/boost/include/boost/archive/iterators/insert_linebreaks.hpp b/project/jni/boost/include/boost/archive/iterators/insert_linebreaks.hpp index 09b13e5b4..5f826cacc 100644 --- a/project/jni/boost/include/boost/archive/iterators/insert_linebreaks.hpp +++ b/project/jni/boost/include/boost/archive/iterators/insert_linebreaks.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME #if defined(BOOST_NO_STDC_NAMESPACE) diff --git a/project/jni/boost/include/boost/archive/iterators/mb_from_wchar.hpp b/project/jni/boost/include/boost/archive/iterators/mb_from_wchar.hpp index 4b34c0fa0..d8f8a129f 100644 --- a/project/jni/boost/include/boost/archive/iterators/mb_from_wchar.hpp +++ b/project/jni/boost/include/boost/archive/iterators/mb_from_wchar.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // size_t #include // for wctomb() @@ -90,9 +90,9 @@ class mb_from_wchar #else m_bend = std::wctomb(m_buffer, value); #endif - assert(-1 != m_bend); - assert((std::size_t)m_bend <= sizeof(m_buffer)); - assert(m_bend > 0); + BOOST_ASSERT(-1 != m_bend); + BOOST_ASSERT((std::size_t)m_bend <= sizeof(m_buffer)); + BOOST_ASSERT(m_bend > 0); m_bnext = 0; } diff --git a/project/jni/boost/include/boost/archive/iterators/remove_whitespace.hpp b/project/jni/boost/include/boost/archive/iterators/remove_whitespace.hpp index 2ccc37308..a8e109298 100644 --- a/project/jni/boost/include/boost/archive/iterators/remove_whitespace.hpp +++ b/project/jni/boost/include/boost/archive/iterators/remove_whitespace.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME diff --git a/project/jni/boost/include/boost/archive/iterators/transform_width.hpp b/project/jni/boost/include/boost/archive/iterators/transform_width.hpp index 7ffc06d13..6e2c52663 100644 --- a/project/jni/boost/include/boost/archive/iterators/transform_width.hpp +++ b/project/jni/boost/include/boost/archive/iterators/transform_width.hpp @@ -24,6 +24,8 @@ // character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters // or 3 8 bit characters +#include + #include // for BOOST_DEDUCED_TYPENAME & PTFO #include diff --git a/project/jni/boost/include/boost/archive/iterators/unescape.hpp b/project/jni/boost/include/boost/archive/iterators/unescape.hpp index f437c388e..9cbd3161c 100644 --- a/project/jni/boost/include/boost/archive/iterators/unescape.hpp +++ b/project/jni/boost/include/boost/archive/iterators/unescape.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME #include diff --git a/project/jni/boost/include/boost/archive/iterators/wchar_from_mb.hpp b/project/jni/boost/include/boost/archive/iterators/wchar_from_mb.hpp index 12e7d57e7..4da81215f 100644 --- a/project/jni/boost/include/boost/archive/iterators/wchar_from_mb.hpp +++ b/project/jni/boost/include/boost/archive/iterators/wchar_from_mb.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include #include // size_t #include // mblen diff --git a/project/jni/boost/include/boost/archive/iterators/xml_escape.hpp b/project/jni/boost/include/boost/archive/iterators/xml_escape.hpp index fd40c020f..eadb96e8b 100644 --- a/project/jni/boost/include/boost/archive/iterators/xml_escape.hpp +++ b/project/jni/boost/include/boost/archive/iterators/xml_escape.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME #include diff --git a/project/jni/boost/include/boost/archive/iterators/xml_unescape.hpp b/project/jni/boost/include/boost/archive/iterators/xml_unescape.hpp index 375e7d29f..3295adb39 100644 --- a/project/jni/boost/include/boost/archive/iterators/xml_unescape.hpp +++ b/project/jni/boost/include/boost/archive/iterators/xml_unescape.hpp @@ -16,7 +16,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // for BOOST_DEDUCED_TYPENAME diff --git a/project/jni/boost/include/boost/archive/iterators/xml_unescape_exception.hpp b/project/jni/boost/include/boost/archive/iterators/xml_unescape_exception.hpp index a14173734..259d2ba26 100644 --- a/project/jni/boost/include/boost/archive/iterators/xml_unescape_exception.hpp +++ b/project/jni/boost/include/boost/archive/iterators/xml_unescape_exception.hpp @@ -20,7 +20,7 @@ #ifndef BOOST_NO_EXCEPTIONS #include -#include +#include namespace boost { namespace archive { diff --git a/project/jni/boost/include/boost/archive/text_iarchive.hpp b/project/jni/boost/include/boost/archive/text_iarchive.hpp index 6e601058b..298928b3e 100644 --- a/project/jni/boost/include/boost/archive/text_iarchive.hpp +++ b/project/jni/boost/include/boost/archive/text_iarchive.hpp @@ -87,7 +87,8 @@ protected: init(); BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) text_iarchive_impl(std::istream & is, unsigned int flags); - BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + // don't import inline definitions! leave this as a reminder. + //BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) ~text_iarchive_impl(){}; }; diff --git a/project/jni/boost/include/boost/archive/text_oarchive.hpp b/project/jni/boost/include/boost/archive/text_oarchive.hpp index 183a76737..2100d539e 100644 --- a/project/jni/boost/include/boost/archive/text_oarchive.hpp +++ b/project/jni/boost/include/boost/archive/text_oarchive.hpp @@ -80,7 +80,8 @@ protected: #endif BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) text_oarchive_impl(std::ostream & os, unsigned int flags); - BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + // don't import inline definitions! leave this as a reminder. + //BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) ~text_oarchive_impl(){}; public: BOOST_ARCHIVE_DECL(void) diff --git a/project/jni/boost/include/boost/archive/tmpdir.hpp b/project/jni/boost/include/boost/archive/tmpdir.hpp index f962e1160..9e6ada4ce 100644 --- a/project/jni/boost/include/boost/archive/tmpdir.hpp +++ b/project/jni/boost/include/boost/archive/tmpdir.hpp @@ -18,7 +18,7 @@ #include // getenv #include // NULL -//#include +//#include #include #ifdef BOOST_NO_STDC_NAMESPACE @@ -38,7 +38,7 @@ inline const char * tmpdir(){ if(NULL == dirname) dirname = std::getenv("TEMP"); if(NULL == dirname){ - //assert(false); // no temp directory found + //BOOST_ASSERT(false); // no temp directory found dirname = "."; } return dirname; diff --git a/project/jni/boost/include/boost/archive/xml_archive_exception.hpp b/project/jni/boost/include/boost/archive/xml_archive_exception.hpp index c8d65e011..48e6cb329 100644 --- a/project/jni/boost/include/boost/archive/xml_archive_exception.hpp +++ b/project/jni/boost/include/boost/archive/xml_archive_exception.hpp @@ -17,7 +17,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include -#include +#include #include #include diff --git a/project/jni/boost/include/boost/archive/xml_wiarchive.hpp b/project/jni/boost/include/boost/archive/xml_wiarchive.hpp index 09552cef7..59ebbb5e7 100644 --- a/project/jni/boost/include/boost/archive/xml_wiarchive.hpp +++ b/project/jni/boost/include/boost/archive/xml_wiarchive.hpp @@ -126,8 +126,7 @@ public: } // namespace boost #ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4511 4512) +# pragma warning(pop) #endif #include // pops abi_suffix.hpp pragmas diff --git a/project/jni/boost/include/boost/array.hpp b/project/jni/boost/include/boost/array.hpp index 7df277147..ffb504bdb 100644 --- a/project/jni/boost/include/boost/array.hpp +++ b/project/jni/boost/include/boost/array.hpp @@ -13,6 +13,7 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * + * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility. * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See or Trac issue #3168 * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) @@ -69,10 +70,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return elems; } - const_iterator begin() const { return elems; } - iterator end() { return elems+N; } - const_iterator end() const { return elems+N; } + iterator begin() { return elems; } + const_iterator begin() const { return elems; } + const_iterator cbegin() const { return elems; } + + iterator end() { return elems+N; } + const_iterator end() const { return elems+N; } + const_iterator cend() const { return elems+N; } // reverse iterator support #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -99,10 +103,17 @@ namespace boost { const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } // operator[] reference operator[](size_type i) @@ -200,10 +211,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } - const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } - iterator end() { return begin(); } - const_iterator end() const { return begin(); } + iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } + const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + + iterator end() { return begin(); } + const_iterator end() const { return begin(); } + const_iterator cend() const { return cbegin(); } // reverse iterator support #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -230,10 +244,17 @@ namespace boost { const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } // operator[] reference operator[](size_type /*i*/) @@ -301,7 +322,7 @@ namespace boost { static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e); -#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) +#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__)) // // We need to return something here to keep // some compilers happy: however we will never @@ -346,7 +367,34 @@ namespace boost { x.swap(y); } - // Specific for boost::array: simply returns its elems data member. +#if defined(__SUNPRO_CC) +// Trac ticket #4757; the Sun Solaris compiler can't handle +// syntax like 'T(&get_c_array(boost::array& arg))[N]' +// +// We can't just use this for all compilers, because the +// borland compilers can't handle this form. + namespace detail { + template struct c_array + { + typedef T type[N]; + }; + } + + // Specific for boost::array: simply returns its elems data member. + template + typename detail::c_array::type& get_c_array(boost::array& arg) + { + return arg.elems; + } + + // Specific for boost::array: simply returns its elems data member. + template + typename const detail::c_array::type& get_c_array(const boost::array& arg) + { + return arg.elems; + } +#else +// Specific for boost::array: simply returns its elems data member. template T(&get_c_array(boost::array& arg))[N] { @@ -359,7 +407,8 @@ namespace boost { { return arg.elems; } - +#endif + #if 0 // Overload for std::array, assuming that std::array will have // explicit conversion functions as discussed at the WG21 meeting diff --git a/project/jni/boost/include/boost/asio.hpp b/project/jni/boost/include/boost/asio.hpp index f94e0d657..8205c5509 100644 --- a/project/jni/boost/include/boost/asio.hpp +++ b/project/jni/boost/include/boost/asio.hpp @@ -2,7 +2,7 @@ // asio.hpp // ~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -21,12 +21,15 @@ #include #include #include +#include #include +#include #include #include #include #include #include +#include #include #include #include @@ -36,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -76,9 +80,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include #include @@ -86,9 +93,14 @@ #include #include #include +#include +#include #include +#include #include #include +#include +#include #include #include #include diff --git a/project/jni/boost/include/boost/asio/basic_datagram_socket.hpp b/project/jni/boost/include/boost/asio/basic_datagram_socket.hpp index 527280999..a773315cb 100644 --- a/project/jni/boost/include/boost/asio/basic_datagram_socket.hpp +++ b/project/jni/boost/include/boost/asio/basic_datagram_socket.hpp @@ -2,7 +2,7 @@ // basic_datagram_socket.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -42,8 +43,12 @@ class basic_datagram_socket : public basic_socket { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename DatagramSocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename DatagramSocketService::native_type native_type; + typedef typename DatagramSocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -121,12 +126,48 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_datagram_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_socket( io_service, protocol, native_socket) { } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_datagram_socket from another. + /** + * This constructor moves a datagram socket from one object to another. + * + * @param other The other basic_datagram_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_datagram_socket(io_service&) constructor. + */ + basic_datagram_socket(basic_datagram_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other)) + { + } + + /// Move-assign a basic_datagram_socket from another. + /** + * This assignment operator moves a datagram socket from one object to + * another. + * + * @param other The other basic_datagram_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_datagram_socket(io_service&) constructor. + */ + basic_datagram_socket& operator=(basic_datagram_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Send some data on a connected socket. /** * This function is used to send data on the datagram socket. The function @@ -153,8 +194,9 @@ public: std::size_t send(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -180,9 +222,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -207,7 +249,8 @@ public: std::size_t send(const ConstBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, flags, ec); + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous send on a connected socket. @@ -247,9 +290,15 @@ public: * std::vector. */ template - void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + void async_send(const ConstBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send on a connected socket. @@ -283,9 +332,15 @@ public: */ template void async_send(const ConstBufferSequence& buffers, - socket_base::message_flags flags, WriteHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Send a datagram to the specified endpoint. @@ -318,9 +373,9 @@ public: const endpoint_type& destination) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -345,9 +400,9 @@ public: const endpoint_type& destination, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -372,7 +427,7 @@ public: const endpoint_type& destination, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send_to(this->implementation, + return this->get_service().send_to(this->get_implementation(), buffers, destination, flags, ec); } @@ -415,10 +470,15 @@ public: */ template void async_send_to(const ConstBufferSequence& buffers, - const endpoint_type& destination, WriteHandler handler) + const endpoint_type& destination, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, 0, - handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send. @@ -451,10 +511,14 @@ public: template void async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, - flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Receive some data on a connected socket. @@ -485,9 +549,9 @@ public: std::size_t receive(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -514,9 +578,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -542,7 +606,8 @@ public: std::size_t receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, flags, ec); + return this->get_service().receive( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous receive on a connected socket. @@ -582,9 +647,15 @@ public: * std::vector. */ template - void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + void async_receive(const MutableBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive on a connected socket. @@ -617,9 +688,15 @@ public: */ template void async_receive(const MutableBufferSequence& buffers, - socket_base::message_flags flags, ReadHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Receive a datagram with the endpoint of the sender. @@ -653,9 +730,9 @@ public: endpoint_type& sender_endpoint) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -680,9 +757,9 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -707,8 +784,8 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive_from(this->implementation, buffers, - sender_endpoint, flags, ec); + return this->get_service().receive_from(this->get_implementation(), + buffers, sender_endpoint, flags, ec); } /// Start an asynchronous receive. @@ -749,10 +826,15 @@ public: */ template void async_receive_from(const MutableBufferSequence& buffers, - endpoint_type& sender_endpoint, ReadHandler handler) + endpoint_type& sender_endpoint, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive. @@ -787,10 +869,14 @@ public: template void async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/project/jni/boost/include/boost/asio/basic_deadline_timer.hpp b/project/jni/boost/include/boost/asio/basic_deadline_timer.hpp index dc471e293..6baeb7ad7 100644 --- a/project/jni/boost/include/boost/asio/basic_deadline_timer.hpp +++ b/project/jni/boost/include/boost/asio/basic_deadline_timer.hpp @@ -2,7 +2,7 @@ // basic_deadline_timer.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -161,7 +162,7 @@ public: { boost::system::error_code ec; this->service.expires_at(this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_at"); } /// Constructor to set a particular expiry time relative to now. @@ -180,7 +181,7 @@ public: { boost::system::error_code ec; this->service.expires_from_now(this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_from_now"); } /// Cancel any asynchronous operations that are waiting on the timer. @@ -209,7 +210,7 @@ public: { boost::system::error_code ec; std::size_t s = this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "cancel"); return s; } @@ -240,6 +241,67 @@ public: return this->service.cancel(this->implementation, ec); } + /// Cancels one asynchronous operation that is waiting on the timer. + /** + * This function forces the completion of one pending asynchronous wait + * operation against the timer. Handlers are cancelled in FIFO order. The + * handler for the cancelled operation will be invoked with the + * boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @return The number of asynchronous operations that were cancelled. That is, + * either 0 or 1. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If the timer has already expired when cancel_one() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel_one() + { + boost::system::error_code ec; + std::size_t s = this->service.cancel_one(this->implementation, ec); + boost::asio::detail::throw_error(ec, "cancel_one"); + return s; + } + + /// Cancels one asynchronous operation that is waiting on the timer. + /** + * This function forces the completion of one pending asynchronous wait + * operation against the timer. Handlers are cancelled in FIFO order. The + * handler for the cancelled operation will be invoked with the + * boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of asynchronous operations that were cancelled. That is, + * either 0 or 1. + * + * @note If the timer has already expired when cancel_one() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel_one(boost::system::error_code& ec) + { + return this->service.cancel_one(this->implementation, ec); + } + /// Get the timer's expiry time as an absolute time. /** * This function may be used to obtain the timer's current expiry time. @@ -277,7 +339,7 @@ public: boost::system::error_code ec; std::size_t s = this->service.expires_at( this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_at"); return s; } @@ -346,7 +408,7 @@ public: boost::system::error_code ec; std::size_t s = this->service.expires_from_now( this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_from_now"); return s; } @@ -390,7 +452,7 @@ public: { boost::system::error_code ec; this->service.wait(this->implementation, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "wait"); } /// Perform a blocking wait on the timer. @@ -430,9 +492,14 @@ public: * boost::asio::io_service::post(). */ template - void async_wait(WaitHandler handler) + void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler) { - this->service.async_wait(this->implementation, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WaitHandler. + BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check; + + this->service.async_wait(this->implementation, + BOOST_ASIO_MOVE_CAST(WaitHandler)(handler)); } }; diff --git a/project/jni/boost/include/boost/asio/basic_io_object.hpp b/project/jni/boost/include/boost/asio/basic_io_object.hpp index 414f36563..046433595 100644 --- a/project/jni/boost/include/boost/asio/basic_io_object.hpp +++ b/project/jni/boost/include/boost/asio/basic_io_object.hpp @@ -2,7 +2,7 @@ // basic_io_object.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include -#include #include #include @@ -24,10 +23,42 @@ namespace boost { namespace asio { +#if defined(BOOST_ASIO_HAS_MOVE) +namespace detail +{ + // Type trait used to determine whether a service supports move. + template + class service_has_move + { + private: + typedef IoObjectService service_type; + typedef typename service_type::implementation_type implementation_type; + + template + static auto eval(T* t, U* u) -> decltype(t->move_construct(*u, *u), char()); + static char (&eval(...))[2]; + + public: + static const bool value = + sizeof(service_has_move::eval( + static_cast(0), + static_cast(0))) == 1; + }; +} +#endif // defined(BOOST_ASIO_HAS_MOVE) + /// Base class for all I/O objects. +/** + * @note All I/O objects are non-copyable. However, when using C++0x, certain + * I/O objects do support move construction and move assignment. + */ +#if !defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) template +#else +template ::value> +#endif class basic_io_object - : private noncopyable { public: /// The type of the service that will be used to provide I/O operations. @@ -36,20 +67,6 @@ public: /// The underlying implementation type of I/O object. typedef typename service_type::implementation_type implementation_type; - /// (Deprecated: use get_io_service().) Get the io_service associated with - /// the object. - /** - * This function may be used to obtain the io_service object that the I/O - * object uses to dispatch handlers for asynchronous operations. - * - * @return A reference to the io_service object that the I/O object will use - * to dispatch handlers. Ownership is not transferred to the caller. - */ - boost::asio::io_service& io_service() - { - return service.get_io_service(); - } - /// Get the io_service associated with the object. /** * This function may be used to obtain the io_service object that the I/O @@ -67,7 +84,7 @@ protected: /// Construct a basic_io_object. /** * Performs: - * @code service.construct(implementation); @endcode + * @code get_service().construct(get_implementation()); @endcode */ explicit basic_io_object(boost::asio::io_service& io_service) : service(boost::asio::use_service(io_service)) @@ -75,23 +92,148 @@ protected: service.construct(implementation); } +#if defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_io_object. + /** + * Performs: + * @code get_service().move_construct( + * get_implementation(), other.get_implementation()); @endcode + * + * @note Available only for services that support movability, + */ + basic_io_object(basic_io_object&& other); + + /// Move-assign a basic_io_object. + /** + * Performs: + * @code get_service().move_assign(get_implementation(), + * other.get_service(), other.get_implementation()); @endcode + * + * @note Available only for services that support movability, + */ + basic_io_object& operator=(basic_io_object&& other); +#endif // defined(GENERATING_DOCUMENTATION) + /// Protected destructor to prevent deletion through this type. /** * Performs: - * @code service.destroy(implementation); @endcode + * @code get_service().destroy(get_implementation()); @endcode */ ~basic_io_object() { service.destroy(implementation); } - /// The service associated with the I/O object. + /// Get the service associated with the I/O object. + service_type& get_service() + { + return service; + } + + /// Get the service associated with the I/O object. + const service_type& get_service() const + { + return service; + } + + /// (Deprecated: Use get_service().) The service associated with the I/O + /// object. + /** + * @note Available only for services that do not support movability. + */ service_type& service; - /// The underlying implementation of the I/O object. + /// Get the underlying implementation of the I/O object. + implementation_type& get_implementation() + { + return implementation; + } + + /// Get the underlying implementation of the I/O object. + const implementation_type& get_implementation() const + { + return implementation; + } + + /// (Deprecated: Use get_implementation().) The underlying implementation of + /// the I/O object. implementation_type implementation; + +private: + basic_io_object(const basic_io_object&); + basic_io_object& operator=(const basic_io_object&); }; +#if defined(BOOST_ASIO_HAS_MOVE) +// Specialisation for movable objects. +template +class basic_io_object +{ +public: + typedef IoObjectService service_type; + typedef typename service_type::implementation_type implementation_type; + + boost::asio::io_service& get_io_service() + { + return service_->get_io_service(); + } + +protected: + explicit basic_io_object(boost::asio::io_service& io_service) + : service_(&boost::asio::use_service(io_service)) + { + service_->construct(implementation); + } + + basic_io_object(basic_io_object&& other) + : service_(&other.get_service()) + { + service_->move_construct(implementation, other.implementation); + } + + ~basic_io_object() + { + service_->destroy(implementation); + } + + basic_io_object& operator=(basic_io_object&& other) + { + service_->move_assign(implementation, + *other.service_, other.implementation); + service_ = other.service_; + return *this; + } + + service_type& get_service() + { + return *service_; + } + + const service_type& get_service() const + { + return *service_; + } + + implementation_type& get_implementation() + { + return implementation; + } + + const implementation_type& get_implementation() const + { + return implementation; + } + + implementation_type implementation; + +private: + basic_io_object(const basic_io_object&); + void operator=(const basic_io_object&); + + IoObjectService* service_; +}; +#endif // defined(BOOST_ASIO_HAS_MOVE) + } // namespace asio } // namespace boost diff --git a/project/jni/boost/include/boost/asio/basic_raw_socket.hpp b/project/jni/boost/include/boost/asio/basic_raw_socket.hpp index 0b877deec..90f66c00c 100644 --- a/project/jni/boost/include/boost/asio/basic_raw_socket.hpp +++ b/project/jni/boost/include/boost/asio/basic_raw_socket.hpp @@ -2,7 +2,7 @@ // basic_raw_socket.hpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,12 @@ class basic_raw_socket : public basic_socket { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename RawSocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename RawSocketService::native_type native_type; + typedef typename RawSocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -121,12 +126,47 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_raw_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_socket( io_service, protocol, native_socket) { } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_raw_socket from another. + /** + * This constructor moves a raw socket from one object to another. + * + * @param other The other basic_raw_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_raw_socket(io_service&) constructor. + */ + basic_raw_socket(basic_raw_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other)) + { + } + + /// Move-assign a basic_raw_socket from another. + /** + * This assignment operator moves a raw socket from one object to another. + * + * @param other The other basic_raw_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_raw_socket(io_service&) constructor. + */ + basic_raw_socket& operator=(basic_raw_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Send some data on a connected socket. /** * This function is used to send data on the raw socket. The function call @@ -152,8 +192,9 @@ public: std::size_t send(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -178,9 +219,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -204,7 +245,8 @@ public: std::size_t send(const ConstBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, flags, ec); + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous send on a connected socket. @@ -243,9 +285,15 @@ public: * std::vector. */ template - void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + void async_send(const ConstBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send on a connected socket. @@ -278,9 +326,15 @@ public: */ template void async_send(const ConstBufferSequence& buffers, - socket_base::message_flags flags, WriteHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Send raw data to the specified endpoint. @@ -313,9 +367,9 @@ public: const endpoint_type& destination) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -340,9 +394,9 @@ public: const endpoint_type& destination, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -367,7 +421,7 @@ public: const endpoint_type& destination, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send_to(this->implementation, + return this->get_service().send_to(this->get_implementation(), buffers, destination, flags, ec); } @@ -410,10 +464,15 @@ public: */ template void async_send_to(const ConstBufferSequence& buffers, - const endpoint_type& destination, WriteHandler handler) + const endpoint_type& destination, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, 0, - handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send. @@ -446,10 +505,14 @@ public: template void async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, - flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Receive some data on a connected socket. @@ -480,9 +543,9 @@ public: std::size_t receive(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -509,9 +572,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -537,7 +600,8 @@ public: std::size_t receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, flags, ec); + return this->get_service().receive( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous receive on a connected socket. @@ -577,9 +641,15 @@ public: * std::vector. */ template - void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + void async_receive(const MutableBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive on a connected socket. @@ -612,9 +682,15 @@ public: */ template void async_receive(const MutableBufferSequence& buffers, - socket_base::message_flags flags, ReadHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Receive raw data with the endpoint of the sender. @@ -648,9 +724,9 @@ public: endpoint_type& sender_endpoint) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -675,9 +751,9 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -702,8 +778,8 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive_from(this->implementation, buffers, - sender_endpoint, flags, ec); + return this->get_service().receive_from(this->get_implementation(), + buffers, sender_endpoint, flags, ec); } /// Start an asynchronous receive. @@ -744,10 +820,15 @@ public: */ template void async_receive_from(const MutableBufferSequence& buffers, - endpoint_type& sender_endpoint, ReadHandler handler) + endpoint_type& sender_endpoint, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive. @@ -782,10 +863,14 @@ public: template void async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/project/jni/boost/include/boost/asio/basic_seq_packet_socket.hpp b/project/jni/boost/include/boost/asio/basic_seq_packet_socket.hpp new file mode 100644 index 000000000..a638c7173 --- /dev/null +++ b/project/jni/boost/include/boost/asio/basic_seq_packet_socket.hpp @@ -0,0 +1,514 @@ +// +// basic_seq_packet_socket.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP +#define BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { + +/// Provides sequenced packet socket functionality. +/** + * The basic_seq_packet_socket class template provides asynchronous and blocking + * sequenced packet socket functionality. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template > +class basic_seq_packet_socket + : public basic_socket +{ +public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename SeqPacketSocketService::native_handle_type native_type; + + /// The native representation of a socket. + typedef typename SeqPacketSocketService::native_handle_type + native_handle_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_seq_packet_socket without opening it. + /** + * This constructor creates a sequenced packet socket without opening it. The + * socket needs to be opened and then connected or accepted before data can + * be sent or received on it. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + */ + explicit basic_seq_packet_socket(boost::asio::io_service& io_service) + : basic_socket(io_service) + { + } + + /// Construct and open a basic_seq_packet_socket. + /** + * This constructor creates and opens a sequenced_packet socket. The socket + * needs to be connected or accepted before data can be sent or received on + * it. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_socket(io_service, protocol) + { + } + + /// Construct a basic_seq_packet_socket, opening it and binding it to the + /// given local endpoint. + /** + * This constructor creates a sequenced packet socket and automatically opens + * it bound to the specified endpoint on the local machine. The protocol used + * is the protocol associated with the given endpoint. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param endpoint An endpoint on the local machine to which the sequenced + * packet socket will be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_socket(io_service, endpoint) + { + } + + /// Construct a basic_seq_packet_socket on an existing native socket. + /** + * This constructor creates a sequenced packet socket object to hold an + * existing native socket. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket The new underlying socket implementation. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_handle_type& native_socket) + : basic_socket( + io_service, protocol, native_socket) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_seq_packet_socket from another. + /** + * This constructor moves a sequenced packet socket from one object to + * another. + * + * @param other The other basic_seq_packet_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_seq_packet_socket(io_service&) constructor. + */ + basic_seq_packet_socket(basic_seq_packet_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other)) + { + } + + /// Move-assign a basic_seq_packet_socket from another. + /** + * This assignment operator moves a sequenced packet socket from one object to + * another. + * + * @param other The other basic_seq_packet_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_seq_packet_socket(io_service&) constructor. + */ + basic_seq_packet_socket& operator=(basic_seq_packet_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + + /// Send some data on the socket. + /** + * This function is used to send data on the sequenced packet socket. The + * function call will block until the data has been sent successfully, or an + * until error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.send(boost::asio::buffer(data, size), 0); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); + return s; + } + + /// Send some data on the socket. + /** + * This function is used to send data on the sequenced packet socket. The + * function call will block the data has been sent successfully, or an until + * error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. Returns 0 if an error occurred. + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref write function if you need to ensure that all data + * is written before the blocking operation completes. + */ + template + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send data on the sequenced packet + * socket. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), 0, handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size), out_flags); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags& out_flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, out_flags, ec); + boost::asio::detail::throw_error(ec, "receive"); + return s; + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size), 0, out_flags); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, in_flags, out_flags, ec); + boost::asio::detail::throw_error(ec, "receive"); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. Returns 0 if an error occurred. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags, boost::system::error_code& ec) + { + return this->get_service().receive(this->get_implementation(), + buffers, in_flags, out_flags, ec); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the sequenced + * packet socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param out_flags Once the asynchronous operation completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. The caller must guarantee that the referenced + * variable remains valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), out_flags, handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags& out_flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), buffers, + 0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the sequenced + * data socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags Once the asynchronous operation completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. The caller must guarantee that the referenced + * variable remains valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive( + * boost::asio::buffer(data, size), + * 0, out_flags, handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), buffers, + in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); + } +}; + +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP diff --git a/project/jni/boost/include/boost/asio/basic_serial_port.hpp b/project/jni/boost/include/boost/asio/basic_serial_port.hpp index 4936c9c25..31ee95524 100644 --- a/project/jni/boost/include/boost/asio/basic_serial_port.hpp +++ b/project/jni/boost/include/boost/asio/basic_serial_port.hpp @@ -2,7 +2,7 @@ // basic_serial_port.hpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -48,8 +49,12 @@ class basic_serial_port public serial_port_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// serial port. + typedef typename SerialPortService::native_handle_type native_type; + /// The native representation of a serial port. - typedef typename SerialPortService::native_type native_type; + typedef typename SerialPortService::native_handle_type native_handle_type; /// A basic_serial_port is always the lowest layer. typedef basic_serial_port lowest_layer_type; @@ -82,8 +87,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct and open a basic_serial_port. @@ -102,8 +107,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct a basic_serial_port on an existing native serial port. @@ -119,14 +124,50 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_serial_port(boost::asio::io_service& io_service, - const native_type& native_serial_port) + const native_handle_type& native_serial_port) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, native_serial_port, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + native_serial_port, ec); + boost::asio::detail::throw_error(ec, "assign"); } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_serial_port from another. + /** + * This constructor moves a serial port from one object to another. + * + * @param other The other basic_serial_port object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_serial_port(io_service&) constructor. + */ + basic_serial_port(basic_serial_port&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_serial_port)(other)) + { + } + + /// Move-assign a basic_serial_port from another. + /** + * This assignment operator moves a serial port from one object to another. + * + * @param other The other basic_serial_port object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_serial_port(io_service&) constructor. + */ + basic_serial_port& operator=(basic_serial_port&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_serial_port)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Get a reference to the lowest layer. /** * This function returns a reference to the lowest layer in a stack of @@ -166,8 +207,8 @@ public: void open(const std::string& device) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the serial port using the specified device name. @@ -182,7 +223,7 @@ public: boost::system::error_code open(const std::string& device, boost::system::error_code& ec) { - return this->service.open(this->implementation, device, ec); + return this->get_service().open(this->get_implementation(), device, ec); } /// Assign an existing native serial port to the serial port. @@ -193,11 +234,12 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const native_type& native_serial_port) + void assign(const native_handle_type& native_serial_port) { boost::system::error_code ec; - this->service.assign(this->implementation, native_serial_port, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + native_serial_port, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assign an existing native serial port to the serial port. @@ -208,16 +250,17 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code assign(const native_type& native_serial_port, + boost::system::error_code assign(const native_handle_type& native_serial_port, boost::system::error_code& ec) { - return this->service.assign(this->implementation, native_serial_port, ec); + return this->get_service().assign(this->get_implementation(), + native_serial_port, ec); } /// Determine whether the serial port is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Close the serial port. @@ -231,8 +274,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the serial port. @@ -245,7 +288,19 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); + } + + /// (Deprecated: Use native_handle().) Get the native serial port + /// representation. + /** + * This function may be used to obtain the underlying representation of the + * serial port. This is intended to allow access to native serial port + * functionality that is not otherwise provided. + */ + native_type native() + { + return this->get_service().native_handle(this->get_implementation()); } /// Get the native serial port representation. @@ -254,9 +309,9 @@ public: * serial port. This is intended to allow access to native serial port * functionality that is not otherwise provided. */ - native_type native() + native_handle_type native_handle() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the serial port. @@ -270,8 +325,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the serial port. @@ -284,7 +339,7 @@ public: */ boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Send a break sequence to the serial port. @@ -297,8 +352,8 @@ public: void send_break() { boost::system::error_code ec; - this->service.send_break(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().send_break(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "send_break"); } /// Send a break sequence to the serial port. @@ -310,7 +365,7 @@ public: */ boost::system::error_code send_break(boost::system::error_code& ec) { - return this->service.send_break(this->implementation, ec); + return this->get_service().send_break(this->get_implementation(), ec); } /// Set an option on the serial port. @@ -332,8 +387,8 @@ public: void set_option(const SettableSerialPortOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the serial port. @@ -355,7 +410,8 @@ public: boost::system::error_code set_option(const SettableSerialPortOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the serial port. @@ -378,8 +434,8 @@ public: void get_option(GettableSerialPortOption& option) { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the serial port. @@ -402,7 +458,8 @@ public: boost::system::error_code get_option(GettableSerialPortOption& option, boost::system::error_code& ec) { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); } /// Write some data to the serial port. @@ -436,8 +493,9 @@ public: std::size_t write_some(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.write_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().write_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "write_some"); return s; } @@ -461,7 +519,8 @@ public: std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.write_some(this->implementation, buffers, ec); + return this->get_service().write_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous write. @@ -501,9 +560,14 @@ public: */ template void async_write_some(const ConstBufferSequence& buffers, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_write_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_write_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Read some data from the serial port. @@ -538,8 +602,9 @@ public: std::size_t read_some(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.read_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().read_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "read_some"); return s; } @@ -564,7 +629,8 @@ public: std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.read_some(this->implementation, buffers, ec); + return this->get_service().read_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous read. @@ -605,9 +671,14 @@ public: */ template void async_read_some(const MutableBufferSequence& buffers, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_read_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_read_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/project/jni/boost/include/boost/asio/basic_signal_set.hpp b/project/jni/boost/include/boost/asio/basic_signal_set.hpp new file mode 100644 index 000000000..ddbef8793 --- /dev/null +++ b/project/jni/boost/include/boost/asio/basic_signal_set.hpp @@ -0,0 +1,384 @@ +// +// basic_signal_set.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SIGNAL_SET_HPP +#define BOOST_ASIO_BASIC_SIGNAL_SET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { + +/// Provides signal functionality. +/** + * The basic_signal_set class template provides the ability to perform an + * asynchronous wait for one or more signals to occur. + * + * Most applications will use the boost::asio::signal_set typedef. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Example + * Performing an asynchronous wait: + * @code + * void handler( + * const boost::system::error_code& error, + * int signal_number) + * { + * if (!error) + * { + * // A signal occurred. + * } + * } + * + * ... + * + * // Construct a signal set registered for process termination. + * boost::asio::signal_set signals(io_service, SIGINT, SIGTERM); + * + * // Start an asynchronous wait for one of the signals to occur. + * signals.async_wait(handler); + * @endcode + * + * @par Queueing of signal notifications + * + * If a signal is registered with a signal_set, and the signal occurs when + * there are no waiting handlers, then the signal notification is queued. The + * next async_wait operation on that signal_set will dequeue the notification. + * If multiple notifications are queued, subsequent async_wait operations + * dequeue them one at a time. Signal notifications are dequeued in order of + * ascending signal number. + * + * If a signal number is removed from a signal_set (using the @c remove or @c + * erase member functions) then any queued notifications for that signal are + * discarded. + * + * @par Multiple registration of signals + * + * The same signal number may be registered with different signal_set objects. + * When the signal occurs, one handler is called for each signal_set object. + * + * Note that multiple registration only works for signals that are registered + * using Asio. The application must not also register a signal handler using + * functions such as @c signal() or @c sigaction(). + * + * @par Signal masking on POSIX platforms + * + * POSIX allows signals to be blocked using functions such as @c sigprocmask() + * and @c pthread_sigmask(). For signals to be delivered, programs must ensure + * that any signals registered using signal_set objects are unblocked in at + * least one thread. + */ +template +class basic_signal_set + : public basic_io_object +{ +public: + /// Construct a signal set without adding any signals. + /** + * This constructor creates a signal set without registering for any signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + */ + explicit basic_signal_set(boost::asio::io_service& io_service) + : basic_io_object(io_service) + { + } + + /// Construct a signal set and add one signal. + /** + * This constructor creates a signal set and registers for one signal. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Construct a signal set and add two signals. + /** + * This constructor creates a signal set and registers for two signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The first signal number to be added. + * + * @param signal_number_2 The second signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); + * signals.add(signal_number_2); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1, + int signal_number_2) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_2, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Construct a signal set and add three signals. + /** + * This constructor creates a signal set and registers for three signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The first signal number to be added. + * + * @param signal_number_2 The second signal number to be added. + * + * @param signal_number_3 The third signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); + * signals.add(signal_number_2); + * signals.add(signal_number_3); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1, + int signal_number_2, int signal_number_3) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_2, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_3, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Add a signal to a signal_set. + /** + * This function adds the specified signal to the set. It has no effect if the + * signal is already in the set. + * + * @param signal_number The signal to be added to the set. + * + * @throws boost::system::system_error Thrown on failure. + */ + void add(int signal_number) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Add a signal to a signal_set. + /** + * This function adds the specified signal to the set. It has no effect if the + * signal is already in the set. + * + * @param signal_number The signal to be added to the set. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code add(int signal_number, + boost::system::error_code& ec) + { + return this->service.add(this->implementation, signal_number, ec); + } + + /// Remove a signal from a signal_set. + /** + * This function removes the specified signal from the set. It has no effect + * if the signal is not in the set. + * + * @param signal_number The signal to be removed from the set. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note Removes any notifications that have been queued for the specified + * signal number. + */ + void remove(int signal_number) + { + boost::system::error_code ec; + this->service.remove(this->implementation, signal_number, ec); + boost::asio::detail::throw_error(ec, "remove"); + } + + /// Remove a signal from a signal_set. + /** + * This function removes the specified signal from the set. It has no effect + * if the signal is not in the set. + * + * @param signal_number The signal to be removed from the set. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note Removes any notifications that have been queued for the specified + * signal number. + */ + boost::system::error_code remove(int signal_number, + boost::system::error_code& ec) + { + return this->service.remove(this->implementation, signal_number, ec); + } + + /// Remove all signals from a signal_set. + /** + * This function removes all signals from the set. It has no effect if the set + * is already empty. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note Removes all queued notifications. + */ + void clear() + { + boost::system::error_code ec; + this->service.clear(this->implementation, ec); + boost::asio::detail::throw_error(ec, "clear"); + } + + /// Remove all signals from a signal_set. + /** + * This function removes all signals from the set. It has no effect if the set + * is already empty. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note Removes all queued notifications. + */ + boost::system::error_code clear(boost::system::error_code& ec) + { + return this->service.clear(this->implementation, ec); + } + + /// Cancel all operations associated with the signal set. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the signal set. The handler for each cancelled + * operation will be invoked with the boost::asio::error::operation_aborted + * error code. + * + * Cancellation does not alter the set of registered signals. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If a registered signal occurred before cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + void cancel() + { + boost::system::error_code ec; + this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec, "cancel"); + } + + /// Cancel all operations associated with the signal set. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the signal set. The handler for each cancelled + * operation will be invoked with the boost::asio::error::operation_aborted + * error code. + * + * Cancellation does not alter the set of registered signals. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note If a registered signal occurred before cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + boost::system::error_code cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Start an asynchronous operation to wait for a signal to be delivered. + /** + * This function may be used to initiate an asynchronous wait against the + * signal set. It always returns immediately. + * + * For each call to async_wait(), the supplied handler will be called exactly + * once. The handler will be called when: + * + * @li One of the registered signals in the signal set occurs; or + * + * @li The signal set was cancelled, in which case the handler is passed the + * error code boost::asio::error::operation_aborted. + * + * @param handler The handler to be called when the signal occurs. Copies + * will be made of the handler as required. The function signature of the + * handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * int signal_number // Indicates which signal occurred. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template + void async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a SignalHandler. + BOOST_ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check; + + this->service.async_wait(this->implementation, + BOOST_ASIO_MOVE_CAST(SignalHandler)(handler)); + } +}; + +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_BASIC_SIGNAL_SET_HPP diff --git a/project/jni/boost/include/boost/asio/basic_socket.hpp b/project/jni/boost/include/boost/asio/basic_socket.hpp index 50a0c4777..c9e2045bf 100644 --- a/project/jni/boost/include/boost/asio/basic_socket.hpp +++ b/project/jni/boost/include/boost/asio/basic_socket.hpp @@ -2,7 +2,7 @@ // basic_socket.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -41,8 +42,12 @@ class basic_socket public socket_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename SocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename SocketService::native_type native_type; + typedef typename SocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -81,8 +86,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct a basic_socket, opening it and binding it to the given local @@ -105,10 +110,11 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + const protocol_type protocol = endpoint.protocol(); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Construct a basic_socket on an existing native socket. @@ -125,14 +131,50 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_socket, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_socket, ec); + boost::asio::detail::throw_error(ec, "assign"); } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_socket from another. + /** + * This constructor moves a socket from one object to another. + * + * @param other The other basic_socket object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket(io_service&) constructor. + */ + basic_socket(basic_socket&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_socket)(other)) + { + } + + /// Move-assign a basic_socket from another. + /** + * This assignment operator moves a socket from one object to another. + * + * @param other The other basic_socket object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket(io_service&) constructor. + */ + basic_socket& operator=(basic_socket&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Get a reference to the lowest layer. /** * This function returns a reference to the lowest layer in a stack of @@ -178,8 +220,8 @@ public: void open(const protocol_type& protocol = protocol_type()) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the socket using the specified protocol. @@ -204,7 +246,7 @@ public: boost::system::error_code open(const protocol_type& protocol, boost::system::error_code& ec) { - return this->service.open(this->implementation, protocol, ec); + return this->get_service().open(this->get_implementation(), protocol, ec); } /// Assign an existing native socket to the socket. @@ -217,11 +259,13 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const protocol_type& protocol, const native_type& native_socket) + void assign(const protocol_type& protocol, + const native_handle_type& native_socket) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_socket, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_socket, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assign an existing native socket to the socket. @@ -235,16 +279,16 @@ public: * @param ec Set to indicate what error occurred, if any. */ boost::system::error_code assign(const protocol_type& protocol, - const native_type& native_socket, boost::system::error_code& ec) + const native_handle_type& native_socket, boost::system::error_code& ec) { - return this->service.assign(this->implementation, + return this->get_service().assign(this->get_implementation(), protocol, native_socket, ec); } /// Determine whether the socket is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Close the socket. @@ -253,7 +297,8 @@ public: * or connect operations will be cancelled immediately, and will complete * with the boost::asio::error::operation_aborted error. * - * @throws boost::system::system_error Thrown on failure. + * @throws boost::system::system_error Thrown on failure. Note that, even if + * the function indicates an error, the underlying descriptor is closed. * * @note For portable behaviour with respect to graceful closure of a * connected socket, call shutdown() before closing the socket. @@ -261,8 +306,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the socket. @@ -271,7 +316,8 @@ public: * or connect operations will be cancelled immediately, and will complete * with the boost::asio::error::operation_aborted error. * - * @param ec Set to indicate what error occurred, if any. + * @param ec Set to indicate what error occurred, if any. Note that, even if + * the function indicates an error, the underlying descriptor is closed. * * @par Example * @code @@ -290,7 +336,18 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); + } + + /// (Deprecated: Use native_handle().) Get the native socket representation. + /** + * This function may be used to obtain the underlying representation of the + * socket. This is intended to allow access to native socket functionality + * that is not otherwise provided. + */ + native_type native() + { + return this->get_service().native_handle(this->get_implementation()); } /// Get the native socket representation. @@ -299,9 +356,9 @@ public: * socket. This is intended to allow access to native socket functionality * that is not otherwise provided. */ - native_type native() + native_handle_type native_handle() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the socket. @@ -348,8 +405,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the socket. @@ -395,7 +452,7 @@ public: #endif boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Determine whether the socket is at the out-of-band data mark. @@ -411,8 +468,8 @@ public: bool at_mark() const { boost::system::error_code ec; - bool b = this->service.at_mark(this->implementation, ec); - boost::asio::detail::throw_error(ec); + bool b = this->get_service().at_mark(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "at_mark"); return b; } @@ -428,7 +485,7 @@ public: */ bool at_mark(boost::system::error_code& ec) const { - return this->service.at_mark(this->implementation, ec); + return this->get_service().at_mark(this->get_implementation(), ec); } /// Determine the number of bytes available for reading. @@ -444,8 +501,9 @@ public: std::size_t available() const { boost::system::error_code ec; - std::size_t s = this->service.available(this->implementation, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().available( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "available"); return s; } @@ -461,7 +519,7 @@ public: */ std::size_t available(boost::system::error_code& ec) const { - return this->service.available(this->implementation, ec); + return this->get_service().available(this->get_implementation(), ec); } /// Bind the socket to the given local endpoint. @@ -485,8 +543,8 @@ public: void bind(const endpoint_type& endpoint) { boost::system::error_code ec; - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Bind the socket to the given local endpoint. @@ -515,7 +573,7 @@ public: boost::system::error_code bind(const endpoint_type& endpoint, boost::system::error_code& ec) { - return this->service.bind(this->implementation, endpoint, ec); + return this->get_service().bind(this->get_implementation(), endpoint, ec); } /// Connect the socket to the specified endpoint. @@ -546,11 +604,12 @@ public: boost::system::error_code ec; if (!is_open()) { - this->service.open(this->implementation, peer_endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), + peer_endpoint.protocol(), ec); + boost::asio::detail::throw_error(ec, "connect"); } - this->service.connect(this->implementation, peer_endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().connect(this->get_implementation(), peer_endpoint, ec); + boost::asio::detail::throw_error(ec, "connect"); } /// Connect the socket to the specified endpoint. @@ -586,14 +645,15 @@ public: { if (!is_open()) { - if (this->service.open(this->implementation, + if (this->get_service().open(this->get_implementation(), peer_endpoint.protocol(), ec)) { return ec; } } - return this->service.connect(this->implementation, peer_endpoint, ec); + return this->get_service().connect( + this->get_implementation(), peer_endpoint, ec); } /// Start an asynchronous connect. @@ -638,21 +698,28 @@ public: * @endcode */ template - void async_connect(const endpoint_type& peer_endpoint, ConnectHandler handler) + void async_connect(const endpoint_type& peer_endpoint, + BOOST_ASIO_MOVE_ARG(ConnectHandler) handler) { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ConnectHandler. + BOOST_ASIO_CONNECT_HANDLER_CHECK(ConnectHandler, handler) type_check; + if (!is_open()) { boost::system::error_code ec; - if (this->service.open(this->implementation, - peer_endpoint.protocol(), ec)) + const protocol_type protocol = peer_endpoint.protocol(); + if (this->get_service().open(this->get_implementation(), protocol, ec)) { this->get_io_service().post( - boost::asio::detail::bind_handler(handler, ec)); + boost::asio::detail::bind_handler( + BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler), ec)); return; } } - this->service.async_connect(this->implementation, peer_endpoint, handler); + this->get_service().async_connect(this->get_implementation(), + peer_endpoint, BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler)); } /// Set an option on the socket. @@ -693,8 +760,8 @@ public: void set_option(const SettableSocketOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the socket. @@ -740,7 +807,8 @@ public: boost::system::error_code set_option(const SettableSocketOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the socket. @@ -782,8 +850,8 @@ public: void get_option(GettableSocketOption& option) const { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the socket. @@ -830,7 +898,8 @@ public: boost::system::error_code get_option(GettableSocketOption& option, boost::system::error_code& ec) const { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); } /// Perform an IO control command on the socket. @@ -859,8 +928,8 @@ public: void io_control(IoControlCommand& command) { boost::system::error_code ec; - this->service.io_control(this->implementation, command, ec); - boost::asio::detail::throw_error(ec); + this->get_service().io_control(this->get_implementation(), command, ec); + boost::asio::detail::throw_error(ec, "io_control"); } /// Perform an IO control command on the socket. @@ -894,7 +963,338 @@ public: boost::system::error_code io_control(IoControlCommand& command, boost::system::error_code& ec) { - return this->service.io_control(this->implementation, command, ec); + return this->get_service().io_control( + this->get_implementation(), command, ec); + } + + /// Gets the non-blocking mode of the socket. + /** + * @returns @c true if the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + bool non_blocking() const + { + return this->get_service().non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the socket. + /** + * @param mode If @c true, the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + void non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().non_blocking(this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "non_blocking"); + } + + /// Sets the non-blocking mode of the socket. + /** + * @param mode If @c true, the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + boost::system::error_code non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().non_blocking( + this->get_implementation(), mode, ec); + } + + /// Gets the non-blocking mode of the native socket implementation. + /** + * This function is used to retrieve the non-blocking mode of the underlying + * native socket. This mode has no effect on the behaviour of the socket + * object's synchronous operations. + * + * @returns @c true if the underlying socket is in non-blocking mode and + * direct system calls may fail with boost::asio::error::would_block (or the + * equivalent system error). + * + * @note The current non-blocking mode is cached by the socket object. + * Consequently, the return value may be incorrect if the non-blocking mode + * was set directly on the native socket. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + bool native_non_blocking() const + { + return this->get_service().native_non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the native socket implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native socket. It has no effect on the behaviour of the socket object's + * synchronous operations. + * + * @param mode If @c true, the underlying socket is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @throws boost::system::system_error Thrown on failure. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + void native_non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "native_non_blocking"); + } + + /// Sets the non-blocking mode of the native socket implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native socket. It has no effect on the behaviour of the socket object's + * synchronous operations. + * + * @param mode If @c true, the underlying socket is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @param ec Set to indicate what error occurred, if any. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + boost::system::error_code native_non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); } /// Get the local endpoint of the socket. @@ -915,8 +1315,9 @@ public: endpoint_type local_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.local_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().local_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "local_endpoint"); return ep; } @@ -943,7 +1344,7 @@ public: */ endpoint_type local_endpoint(boost::system::error_code& ec) const { - return this->service.local_endpoint(this->implementation, ec); + return this->get_service().local_endpoint(this->get_implementation(), ec); } /// Get the remote endpoint of the socket. @@ -964,8 +1365,9 @@ public: endpoint_type remote_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.remote_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().remote_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "remote_endpoint"); return ep; } @@ -992,7 +1394,7 @@ public: */ endpoint_type remote_endpoint(boost::system::error_code& ec) const { - return this->service.remote_endpoint(this->implementation, ec); + return this->get_service().remote_endpoint(this->get_implementation(), ec); } /// Disable sends or receives on the socket. @@ -1015,8 +1417,8 @@ public: void shutdown(shutdown_type what) { boost::system::error_code ec; - this->service.shutdown(this->implementation, what, ec); - boost::asio::detail::throw_error(ec); + this->get_service().shutdown(this->get_implementation(), what, ec); + boost::asio::detail::throw_error(ec, "shutdown"); } /// Disable sends or receives on the socket. @@ -1044,7 +1446,7 @@ public: boost::system::error_code shutdown(shutdown_type what, boost::system::error_code& ec) { - return this->service.shutdown(this->implementation, what, ec); + return this->get_service().shutdown(this->get_implementation(), what, ec); } protected: diff --git a/project/jni/boost/include/boost/asio/basic_socket_acceptor.hpp b/project/jni/boost/include/boost/asio/basic_socket_acceptor.hpp index 5192df73e..5a3b0f7e4 100644 --- a/project/jni/boost/include/boost/asio/basic_socket_acceptor.hpp +++ b/project/jni/boost/include/boost/asio/basic_socket_acceptor.hpp @@ -2,7 +2,7 @@ // basic_socket_acceptor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -55,8 +56,12 @@ class basic_socket_acceptor public socket_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of an + /// acceptor. + typedef typename SocketAcceptorService::native_handle_type native_type; + /// The native representation of an acceptor. - typedef typename SocketAcceptorService::native_type native_type; + typedef typename SocketAcceptorService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -96,8 +101,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct an acceptor opened on the given endpoint. @@ -132,19 +137,20 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); + const protocol_type protocol = endpoint.protocol(); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); if (reuse_addr) { - this->service.set_option(this->implementation, + this->get_service().set_option(this->get_implementation(), socket_base::reuse_address(true), ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "set_option"); } - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); - this->service.listen(this->implementation, + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); + this->get_service().listen(this->get_implementation(), socket_base::max_connections, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "listen"); } /// Construct a basic_socket_acceptor on an existing native acceptor. @@ -163,14 +169,50 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_socket_acceptor(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_acceptor) + const protocol_type& protocol, const native_handle_type& native_acceptor) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_acceptor, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec, "assign"); } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_socket_acceptor from another. + /** + * This constructor moves an acceptor from one object to another. + * + * @param other The other basic_socket_acceptor object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket_acceptor(io_service&) constructor. + */ + basic_socket_acceptor(basic_socket_acceptor&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other)) + { + } + + /// Move-assign a basic_socket_acceptor from another. + /** + * This assignment operator moves an acceptor from one object to another. + * + * @param other The other basic_socket_acceptor object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket_acceptor(io_service&) constructor. + */ + basic_socket_acceptor& operator=(basic_socket_acceptor&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Open the acceptor using the specified protocol. /** * This function opens the socket acceptor so that it will use the specified @@ -189,8 +231,8 @@ public: void open(const protocol_type& protocol = protocol_type()) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the acceptor using the specified protocol. @@ -216,7 +258,7 @@ public: boost::system::error_code open(const protocol_type& protocol, boost::system::error_code& ec) { - return this->service.open(this->implementation, protocol, ec); + return this->get_service().open(this->get_implementation(), protocol, ec); } /// Assigns an existing native acceptor to the acceptor. @@ -229,11 +271,13 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const protocol_type& protocol, const native_type& native_acceptor) + void assign(const protocol_type& protocol, + const native_handle_type& native_acceptor) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_acceptor, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assigns an existing native acceptor to the acceptor. @@ -247,16 +291,16 @@ public: * @param ec Set to indicate what error occurred, if any. */ boost::system::error_code assign(const protocol_type& protocol, - const native_type& native_acceptor, boost::system::error_code& ec) + const native_handle_type& native_acceptor, boost::system::error_code& ec) { - return this->service.assign(this->implementation, + return this->get_service().assign(this->get_implementation(), protocol, native_acceptor, ec); } /// Determine whether the acceptor is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Bind the acceptor to the given local endpoint. @@ -279,8 +323,8 @@ public: void bind(const endpoint_type& endpoint) { boost::system::error_code ec; - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Bind the acceptor to the given local endpoint. @@ -308,7 +352,7 @@ public: boost::system::error_code bind(const endpoint_type& endpoint, boost::system::error_code& ec) { - return this->service.bind(this->implementation, endpoint, ec); + return this->get_service().bind(this->get_implementation(), endpoint, ec); } /// Place the acceptor into the state where it will listen for new @@ -324,8 +368,8 @@ public: void listen(int backlog = socket_base::max_connections) { boost::system::error_code ec; - this->service.listen(this->implementation, backlog, ec); - boost::asio::detail::throw_error(ec); + this->get_service().listen(this->get_implementation(), backlog, ec); + boost::asio::detail::throw_error(ec, "listen"); } /// Place the acceptor into the state where it will listen for new @@ -352,7 +396,7 @@ public: */ boost::system::error_code listen(int backlog, boost::system::error_code& ec) { - return this->service.listen(this->implementation, backlog, ec); + return this->get_service().listen(this->get_implementation(), backlog, ec); } /// Close the acceptor. @@ -368,8 +412,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the acceptor. @@ -396,7 +440,18 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); + } + + /// (Deprecated: Use native_handle().) Get the native acceptor representation. + /** + * This function may be used to obtain the underlying representation of the + * acceptor. This is intended to allow access to native acceptor functionality + * that is not otherwise provided. + */ + native_type native() + { + return this->get_service().native_handle(this->get_implementation()); } /// Get the native acceptor representation. @@ -405,9 +460,9 @@ public: * acceptor. This is intended to allow access to native acceptor functionality * that is not otherwise provided. */ - native_type native() + native_handle_type native_handle() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the acceptor. @@ -421,8 +476,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the acceptor. @@ -435,7 +490,7 @@ public: */ boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Set an option on the acceptor. @@ -463,8 +518,8 @@ public: void set_option(const SettableSocketOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the acceptor. @@ -497,7 +552,8 @@ public: boost::system::error_code set_option(const SettableSocketOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the acceptor. @@ -526,8 +582,8 @@ public: void get_option(GettableSocketOption& option) { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the acceptor. @@ -561,7 +617,189 @@ public: boost::system::error_code get_option(GettableSocketOption& option, boost::system::error_code& ec) { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); + } + + /// Perform an IO control command on the acceptor. + /** + * This function is used to execute an IO control command on the acceptor. + * + * @param command The IO control command to be performed on the acceptor. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::non_blocking_io command(true); + * socket.io_control(command); + * @endcode + */ + template + void io_control(IoControlCommand& command) + { + boost::system::error_code ec; + this->get_service().io_control(this->get_implementation(), command, ec); + boost::asio::detail::throw_error(ec, "io_control"); + } + + /// Perform an IO control command on the acceptor. + /** + * This function is used to execute an IO control command on the acceptor. + * + * @param command The IO control command to be performed on the acceptor. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::non_blocking_io command(true); + * boost::system::error_code ec; + * socket.io_control(command, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template + boost::system::error_code io_control(IoControlCommand& command, + boost::system::error_code& ec) + { + return this->get_service().io_control( + this->get_implementation(), command, ec); + } + + /// Gets the non-blocking mode of the acceptor. + /** + * @returns @c true if the acceptor's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + bool non_blocking() const + { + return this->get_service().non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the acceptor. + /** + * @param mode If @c true, the acceptor's synchronous operations will fail + * with boost::asio::error::would_block if they are unable to perform the + * requested operation immediately. If @c false, synchronous operations will + * block until complete. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + void non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().non_blocking(this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "non_blocking"); + } + + /// Sets the non-blocking mode of the acceptor. + /** + * @param mode If @c true, the acceptor's synchronous operations will fail + * with boost::asio::error::would_block if they are unable to perform the + * requested operation immediately. If @c false, synchronous operations will + * block until complete. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + boost::system::error_code non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().non_blocking( + this->get_implementation(), mode, ec); + } + + /// Gets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to retrieve the non-blocking mode of the underlying + * native acceptor. This mode has no effect on the behaviour of the acceptor + * object's synchronous operations. + * + * @returns @c true if the underlying acceptor is in non-blocking mode and + * direct system calls may fail with boost::asio::error::would_block (or the + * equivalent system error). + * + * @note The current non-blocking mode is cached by the acceptor object. + * Consequently, the return value may be incorrect if the non-blocking mode + * was set directly on the native acceptor. + */ + bool native_non_blocking() const + { + return this->get_service().native_non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native acceptor. It has no effect on the behaviour of the acceptor object's + * synchronous operations. + * + * @param mode If @c true, the underlying acceptor is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @throws boost::system::system_error Thrown on failure. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + */ + void native_non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "native_non_blocking"); + } + + /// Sets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native acceptor. It has no effect on the behaviour of the acceptor object's + * synchronous operations. + * + * @param mode If @c true, the underlying acceptor is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @param ec Set to indicate what error occurred, if any. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + */ + boost::system::error_code native_non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); } /// Get the local endpoint of the acceptor. @@ -582,8 +820,9 @@ public: endpoint_type local_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.local_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().local_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "local_endpoint"); return ep; } @@ -611,7 +850,7 @@ public: */ endpoint_type local_endpoint(boost::system::error_code& ec) const { - return this->service.local_endpoint(this->implementation, ec); + return this->get_service().local_endpoint(this->get_implementation(), ec); } /// Accept a new connection. @@ -636,8 +875,8 @@ public: void accept(basic_socket& peer) { boost::system::error_code ec; - this->service.accept(this->implementation, peer, 0, ec); - boost::asio::detail::throw_error(ec); + this->get_service().accept(this->get_implementation(), peer, 0, ec); + boost::asio::detail::throw_error(ec, "accept"); } /// Accept a new connection. @@ -668,7 +907,7 @@ public: basic_socket& peer, boost::system::error_code& ec) { - return this->service.accept(this->implementation, peer, 0, ec); + return this->get_service().accept(this->get_implementation(), peer, 0, ec); } /// Start an asynchronous accept. @@ -711,9 +950,14 @@ public: */ template void async_accept(basic_socket& peer, - AcceptHandler handler) + BOOST_ASIO_MOVE_ARG(AcceptHandler) handler) { - this->service.async_accept(this->implementation, peer, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a AcceptHandler. + BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check; + + this->get_service().async_accept(this->get_implementation(), + peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler)); } /// Accept a new connection and obtain the endpoint of the peer @@ -744,8 +988,9 @@ public: endpoint_type& peer_endpoint) { boost::system::error_code ec; - this->service.accept(this->implementation, peer, &peer_endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().accept(this->get_implementation(), + peer, &peer_endpoint, ec); + boost::asio::detail::throw_error(ec, "accept"); } /// Accept a new connection and obtain the endpoint of the peer @@ -781,7 +1026,8 @@ public: basic_socket& peer, endpoint_type& peer_endpoint, boost::system::error_code& ec) { - return this->service.accept(this->implementation, peer, &peer_endpoint, ec); + return this->get_service().accept( + this->get_implementation(), peer, &peer_endpoint, ec); } /// Start an asynchronous accept. @@ -812,10 +1058,14 @@ public: */ template void async_accept(basic_socket& peer, - endpoint_type& peer_endpoint, AcceptHandler handler) + endpoint_type& peer_endpoint, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler) { - this->service.async_accept(this->implementation, - peer, &peer_endpoint, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a AcceptHandler. + BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check; + + this->get_service().async_accept(this->get_implementation(), peer, + &peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler)); } }; diff --git a/project/jni/boost/include/boost/asio/basic_socket_iostream.hpp b/project/jni/boost/include/boost/asio/basic_socket_iostream.hpp index a8cea4fec..93d1fcd17 100644 --- a/project/jni/boost/include/boost/asio/basic_socket_iostream.hpp +++ b/project/jni/boost/include/boost/asio/basic_socket_iostream.hpp @@ -2,7 +2,7 @@ // basic_socket_iostream.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,34 +19,39 @@ #if !defined(BOOST_NO_IOSTREAM) -#include -#include -#include -#include #include #include #include -#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) -#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5 -#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) +#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) + +# include +# include +# include +# include + +# if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) +# define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5 +# endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) // A macro that should expand to: // template // explicit basic_socket_iostream(T1 x1, ..., Tn xn) // : basic_iostream(&this->boost::base_from_member< -// basic_socket_streambuf >::member) +// basic_socket_streambuf >::member) // { // if (rdbuf()->connect(x1, ..., xn) == 0) // this->setstate(std::ios_base::failbit); // } // This macro should only persist within this file. -#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \ +# define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \ template \ explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ : std::basic_iostream(&this->boost::base_from_member< \ - basic_socket_streambuf >::member) \ + basic_socket_streambuf >::member) \ { \ tie(this); \ if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \ @@ -63,7 +68,7 @@ // } // This macro should only persist within this file. -#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \ +# define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \ template \ void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ { \ @@ -72,6 +77,8 @@ } \ /**/ +#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) + #include namespace boost { @@ -79,17 +86,31 @@ namespace asio { /// Iostream interface for a socket. template > + typename StreamSocketService = stream_socket_service, + typename Time = boost::posix_time::ptime, + typename TimeTraits = boost::asio::time_traits