aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules2
-rw-r--r--.qmake.conf2
-rw-r--r--examples/quick/delegatechooser/delegatechooser.pro8
-rw-r--r--examples/quick/delegatechooser/delegatechooser.qml145
-rw-r--r--examples/quick/delegatechooser/main.cpp (renamed from examples/quick/demos/maroon/main.cpp)6
-rw-r--r--examples/quick/delegatechooser/qml.qrc5
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.pro19
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.qml173
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.qmlproject16
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.qrc12
-rw-r--r--examples/quick/demos/calqlatr/content/Button.qml104
-rw-r--r--examples/quick/demos/calqlatr/content/Display.qml203
-rw-r--r--examples/quick/demos/calqlatr/content/NumberPad.qml81
-rw-r--r--examples/quick/demos/calqlatr/content/calculator.js161
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-edge-left.pngbin12401 -> 0 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-edge-right.pngbin12967 -> 0 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-grip.pngbin298 -> 0 bytes
-rw-r--r--examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.pngbin37120 -> 0 bytes
-rw-r--r--examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc195
-rw-r--r--examples/quick/demos/calqlatr/main.cpp51
-rw-r--r--examples/quick/demos/clocks/clocks.pro14
-rw-r--r--examples/quick/demos/clocks/clocks.qml98
-rw-r--r--examples/quick/demos/clocks/clocks.qmlproject8
-rw-r--r--examples/quick/demos/clocks/clocks.qrc15
-rw-r--r--examples/quick/demos/clocks/content/Clock.qml150
-rw-r--r--examples/quick/demos/clocks/content/arrow.pngbin692 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/background.pngbin46895 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/center.pngbin765 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/clock-night.pngbin23359 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/clock.pngbin20653 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/hour.pngbin518 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/minute.pngbin528 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/quit.pngbin583 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/content/second.pngbin231 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.pngbin23332 -> 0 bytes
-rw-r--r--examples/quick/demos/clocks/doc/src/clocks.qdoc127
-rw-r--r--examples/quick/demos/clocks/main.cpp51
-rw-r--r--examples/quick/demos/demos.pro11
-rw-r--r--examples/quick/demos/maroon/content/BuildButton.qml100
-rw-r--r--examples/quick/demos/maroon/content/GameCanvas.qml250
-rw-r--r--examples/quick/demos/maroon/content/GameOverScreen.qml125
-rw-r--r--examples/quick/demos/maroon/content/InfoBar.qml94
-rw-r--r--examples/quick/demos/maroon/content/NewGameScreen.qml121
-rw-r--r--examples/quick/demos/maroon/content/SoundEffect.qml62
-rw-r--r--examples/quick/demos/maroon/content/audio/bomb-action.wavbin20972 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/catch-action.wavbin13274 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/catch.wavbin8638 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/currency.wavbin15790 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/factory-action.wavbin4936 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/melee-action.wavbin17798 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/projectile-action.wavbin2562 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/shooter-action.wavbin27554 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/background.pngbin5802 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb-action.pngbin23974 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb-idle.pngbin12238 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb.pngbin4067 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/button-help.pngbin8916 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/button-play.pngbin13945 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/catch-action.pngbin6760 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/catch.pngbin4771 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/cloud.pngbin3398 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/currency.pngbin1889 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-bomb.pngbin3751 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-factory.pngbin3946 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-melee.pngbin4392 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-pointer.pngbin911 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-shooter.pngbin3737 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog.pngbin3362 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory-action.pngbin22440 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory-idle.pngbin12729 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory.pngbin4138 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/grid.pngbin2830 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/help.pngbin38255 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/lifes.pngbin1675 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo-bubble.pngbin7706 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo-fish.pngbin3477 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo.pngbin18332 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee-action.pngbin7797 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee-idle.pngbin22832 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee.pngbin4046 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/mob-idle.pngbin6181 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/mob.pngbin2391 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/points.pngbin1561 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/projectile-action.pngbin6257 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/projectile.pngbin801 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/scores.pngbin1535 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter-action.pngbin18121 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter-idle.pngbin11929 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter.pngbin4137 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/sunlight.pngbin248412 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-1.pngbin2777 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-2.pngbin4959 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-3.pngbin5063 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-blank.pngbin1326 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-gameover.pngbin1515 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-go.pngbin4230 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/wave.pngbin2763 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/content/logic.js274
-rw-r--r--examples/quick/demos/maroon/content/mobs/MobBase.qml272
-rw-r--r--examples/quick/demos/maroon/content/towers/Bomb.qml143
-rw-r--r--examples/quick/demos/maroon/content/towers/Factory.qml124
-rw-r--r--examples/quick/demos/maroon/content/towers/Ranged.qml138
-rw-r--r--examples/quick/demos/maroon/content/towers/TowerBase.qml82
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.pngbin73390 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.pngbin58609 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-3.jpgbin25541 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-4.jpgbin79678 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-5.jpgbin27911 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-6.jpgbin59198 -> 0 bytes
-rw-r--r--examples/quick/demos/maroon/doc/src/maroon.qdoc889
-rw-r--r--examples/quick/demos/maroon/maroon.pro9
-rw-r--r--examples/quick/demos/maroon/maroon.qml245
-rw-r--r--examples/quick/demos/maroon/maroon.qmlproject16
-rw-r--r--examples/quick/demos/maroon/maroon.qrc71
-rw-r--r--examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.pngbin47271 -> 0 bytes
-rw-r--r--examples/quick/demos/photosurface/doc/src/photosurface.qdoc157
-rw-r--r--examples/quick/demos/photosurface/main.cpp139
-rw-r--r--examples/quick/demos/photosurface/photosurface.pro13
-rw-r--r--examples/quick/demos/photosurface/photosurface.qml286
-rw-r--r--examples/quick/demos/photosurface/photosurface.qmlproject20
-rw-r--r--examples/quick/demos/photosurface/photosurface.qrc6
-rw-r--r--examples/quick/demos/photosurface/resources/folder.pngbin5851 -> 0 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/icon.pngbin35894 -> 0 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.icnsbin47407 -> 0 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.icobin38623 -> 0 bytes
-rw-r--r--examples/quick/demos/photosurface/resources/photosurface.rc32
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml157
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml59
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml81
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml94
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml198
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml66
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml100
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.pngbin371 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.pngbin1564 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.pngbin8477 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js27
-rw-r--r--examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.pngbin70963 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc326
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_de.qmbin310 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_de.ts35
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_en.qmbin23 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_en.ts4
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.qmbin247 -> 0 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.ts35
-rw-r--r--examples/quick/demos/photoviewer/main.qml139
-rw-r--r--examples/quick/demos/photoviewer/photoviewer.pro20
-rw-r--r--examples/quick/demos/photoviewer/qml.qrc20
-rw-r--r--examples/quick/demos/rssnews/content/BusyIndicator.qml64
-rw-r--r--examples/quick/demos/rssnews/content/NewsDelegate.qml140
-rw-r--r--examples/quick/demos/rssnews/content/RssFeeds.qml66
-rw-r--r--examples/quick/demos/rssnews/content/ScrollBar.qml126
-rw-r--r--examples/quick/demos/rssnews/content/images/Asia.jpgbin10578 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Business.jpgbin17276 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Entertainment.jpgbin15433 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Europe.jpgbin15872 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Health.jpgbin16015 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Politics.jpgbin16401 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Science.jpgbin9496 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Sports.jpgbin9281 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Technology.jpgbin22290 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/TopStories.jpgbin8067 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/USNational.jpgbin9635 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/World.jpgbin15128 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/btn_close.pngbin328 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/busy.pngbin1564 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/scrollbar.pngbin79 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.pngbin56830 -> 0 bytes
-rw-r--r--examples/quick/demos/rssnews/doc/src/rssnews.qdoc372
-rw-r--r--examples/quick/demos/rssnews/main.cpp51
-rw-r--r--examples/quick/demos/rssnews/rssnews.pro13
-rw-r--r--examples/quick/demos/rssnews/rssnews.qml169
-rw-r--r--examples/quick/demos/rssnews/rssnews.qmlproject16
-rw-r--r--examples/quick/demos/rssnews/rssnews.qrc25
-rw-r--r--examples/quick/demos/samegame/content/Block.qml124
-rw-r--r--examples/quick/demos/samegame/content/BlockEmitter.qml67
-rw-r--r--examples/quick/demos/samegame/content/Button.qml80
-rw-r--r--examples/quick/demos/samegame/content/GameArea.qml238
-rw-r--r--examples/quick/demos/samegame/content/LogoAnimation.qml112
-rw-r--r--examples/quick/demos/samegame/content/PaintEmitter.qml108
-rw-r--r--examples/quick/demos/samegame/content/PrimaryPack.qml132
-rw-r--r--examples/quick/demos/samegame/content/PuzzleBlock.qml121
-rw-r--r--examples/quick/demos/samegame/content/SamegameText.qml59
-rw-r--r--examples/quick/demos/samegame/content/SimpleBlock.qml118
-rw-r--r--examples/quick/demos/samegame/content/SmokeText.qml93
-rw-r--r--examples/quick/demos/samegame/content/gfx/background-puzzle.pngbin86666 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/background.pngbin101018 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bar.pngbin10970 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/blue-puzzle.pngbin2219 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/blue.pngbin1018 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bubble-highscore.pngbin2276 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bubble-puzzle.pngbin2811 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-1.pngbin2728 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-2.pngbin3378 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-3.pngbin1423 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-4.pngbin2096 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-new.pngbin3662 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-menu.pngbin2391 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-puzzle-next.pngbin3658 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-quit.pngbin2100 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/green-puzzle.pngbin2271 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/green.pngbin1024 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-fail.pngbin6549 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-ok.pngbin7190 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-time.pngbin1159 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-a.pngbin1814 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-e.pngbin1725 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-g.pngbin1765 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-m.pngbin1743 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-s.pngbin1791 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo.pngbin3608 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-brick.pngbin861 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-paint.pngbin714 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-smoke.pngbin5409 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/red-puzzle.pngbin2218 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/red.pngbin1018 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-highscore-new.pngbin6767 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-highscore.pngbin3179 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-no-winner.pngbin6321 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1-go.pngbin5395 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1-won.pngbin5618 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1.pngbin1751 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2-go.pngbin5874 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2-won.pngbin6177 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2.pngbin2381 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/yellow-puzzle.pngbin2239 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/yellow.pngbin1008 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/content/levels/TemplateBase.qml80
-rw-r--r--examples/quick/demos/samegame/content/levels/level0.qml69
-rw-r--r--examples/quick/demos/samegame/content/levels/level1.qml69
-rw-r--r--examples/quick/demos/samegame/content/levels/level2.qml71
-rw-r--r--examples/quick/demos/samegame/content/levels/level3.qml70
-rw-r--r--examples/quick/demos/samegame/content/levels/level4.qml68
-rw-r--r--examples/quick/demos/samegame/content/levels/level5.qml69
-rw-r--r--examples/quick/demos/samegame/content/levels/level6.qml70
-rw-r--r--examples/quick/demos/samegame/content/levels/level7.qml68
-rw-r--r--examples/quick/demos/samegame/content/levels/level8.qml69
-rw-r--r--examples/quick/demos/samegame/content/levels/level9.qml72
-rw-r--r--examples/quick/demos/samegame/content/qmldir13
-rw-r--r--examples/quick/demos/samegame/content/samegame.js590
-rw-r--r--examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.pngbin97978 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.pngbin134892 -> 0 bytes
-rw-r--r--examples/quick/demos/samegame/doc/src/samegame.qdoc47
-rw-r--r--examples/quick/demos/samegame/main.cpp51
-rw-r--r--examples/quick/demos/samegame/samegame.pro8
-rw-r--r--examples/quick/demos/samegame/samegame.qml382
-rw-r--r--examples/quick/demos/samegame/samegame.qmlproject16
-rw-r--r--examples/quick/demos/samegame/samegame.qrc73
-rw-r--r--examples/quick/demos/stocqt/content/Button.qml74
-rw-r--r--examples/quick/demos/stocqt/content/CheckBox.qml86
-rw-r--r--examples/quick/demos/stocqt/content/Settings.qml56
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml400
-rw-r--r--examples/quick/demos/stocqt/content/StockInfo.qml130
-rw-r--r--examples/quick/demos/stocqt/content/StockListDelegate.qml163
-rw-r--r--examples/quick/demos/stocqt/content/StockListModel.qml130
-rw-r--r--examples/quick/demos/stocqt/content/StockModel.qml148
-rw-r--r--examples/quick/demos/stocqt/content/StockSettingsPanel.qml163
-rw-r--r--examples/quick/demos/stocqt/content/StockView.qml110
-rw-r--r--examples/quick/demos/stocqt/content/data/AAPL.csv147
-rw-r--r--examples/quick/demos/stocqt/content/data/ADSK.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/AMD.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/AMZN.csv147
-rw-r--r--examples/quick/demos/stocqt/content/data/CSCO.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/EA.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/EBAY.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/FB.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/GOOG.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/GOOGL.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/INTC.csv147
-rw-r--r--examples/quick/demos/stocqt/content/data/MSFT.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/NCLH.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/NFLX.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/NTAP.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/NVDA.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/PYPL.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/QCOM.csv147
-rw-r--r--examples/quick/demos/stocqt/content/data/TSLA.csv148
-rw-r--r--examples/quick/demos/stocqt/content/data/TXN.csv148
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-left-arrow.pngbin358 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel-touch.pngbin4767 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel.pngbin36223 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/content/qmldir12
-rw-r--r--examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.pngbin27425 -> 0 bytes
-rw-r--r--examples/quick/demos/stocqt/doc/src/stocqt.qdoc85
-rw-r--r--examples/quick/demos/stocqt/main.cpp51
-rw-r--r--examples/quick/demos/stocqt/stocqt.pro9
-rw-r--r--examples/quick/demos/stocqt/stocqt.qmlproject16
-rw-r--r--examples/quick/demos/stocqt/stocqt.qrc42
-rw-r--r--examples/quick/demos/tweetsearch/content/FlipBar.qml183
-rw-r--r--examples/quick/demos/tweetsearch/content/LineInput.qml108
-rw-r--r--examples/quick/demos/tweetsearch/content/ListFooter.qml164
-rw-r--r--examples/quick/demos/tweetsearch/content/ListHeader.qml91
-rw-r--r--examples/quick/demos/tweetsearch/content/SearchDelegate.qml135
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetDelegate.qml199
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetsModel.qml135
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/anonymous.pngbin1788 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.pngbin11079 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-clear.pngbin1166 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-loading.pngbin1542 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-refresh.pngbin1202 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-search.pngbin1284 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/tweetsearch.js62
-rw-r--r--examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.pngbin15837 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.pngbin90622 -> 0 bytes
-rw-r--r--examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc79
-rw-r--r--examples/quick/demos/tweetsearch/main.cpp51
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.pro13
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qml142
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qmlproject16
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qrc19
-rw-r--r--examples/quick/draganddrop/views/gridview.qml40
-rw-r--r--examples/quick/imageelements/animatedimage.qml3
-rw-r--r--examples/quick/quick.pro5
-rw-r--r--examples/quick/shapes/content/tapableTriangle.qml5
-rw-r--r--examples/quick/shapes/content/tiger.qml5
-rw-r--r--examples/quick/tableview/gameoflife/doc/images/gameoflife.pngbin0 -> 47006 bytes
-rw-r--r--examples/quick/tableview/gameoflife/doc/src/gameoflife.qdoc113
-rw-r--r--examples/quick/tableview/gameoflife/gameoflife.pro16
-rw-r--r--examples/quick/tableview/gameoflife/gameoflifemodel.cpp214
-rw-r--r--examples/quick/tableview/gameoflife/gameoflifemodel.h (renamed from examples/quick/views/parallax/content/Smiley.qml)78
-rw-r--r--examples/quick/tableview/gameoflife/gosperglidergun.cells9
-rw-r--r--examples/quick/tableview/gameoflife/main.cpp (renamed from examples/quick/demos/samegame/content/Settings.qml)32
-rw-r--r--examples/quick/tableview/gameoflife/main.qml (renamed from examples/quick/views/parallax/content/ParallaxView.qml)143
-rw-r--r--examples/quick/tableview/pixelator/doc/images/qt-pixelator.pngbin0 -> 23771 bytes
-rw-r--r--examples/quick/tableview/pixelator/doc/src/pixelator.qdoc95
-rw-r--r--examples/quick/tableview/pixelator/imagemodel.cpp (renamed from examples/quick/demos/rssnews/content/CategoryDelegate.qml)91
-rw-r--r--examples/quick/tableview/pixelator/imagemodel.h (renamed from examples/quick/demos/maroon/content/towers/Melee.qml)68
-rw-r--r--examples/quick/tableview/pixelator/main.cpp (renamed from examples/quick/demos/photoviewer/main.cpp)21
-rw-r--r--examples/quick/tableview/pixelator/main.qml (renamed from examples/quick/demos/stocqt/stocqt.qml)103
-rw-r--r--examples/quick/tableview/pixelator/pixelator.pro11
-rw-r--r--examples/quick/tableview/pixelator/qt.pngbin0 -> 3858 bytes
-rw-r--r--examples/quick/tableview/tableview.pro5
-rw-r--r--examples/quick/threading/doc/src/threading.qdoc4
-rw-r--r--examples/quick/threading/threadedlistmodel/dataloader.mjs (renamed from examples/quick/threading/threadedlistmodel/dataloader.js)0
-rw-r--r--examples/quick/threading/threadedlistmodel/timedisplay.qml2
-rw-r--r--examples/quick/threading/threading.qrc4
-rw-r--r--examples/quick/threading/workerscript/workerscript.mjs (renamed from examples/quick/threading/workerscript/workerscript.js)0
-rw-r--r--examples/quick/threading/workerscript/workerscript.qml2
-rw-r--r--examples/quick/views/parallax/content/Clock.qml150
-rw-r--r--examples/quick/views/parallax/content/QuitButton.qml62
-rw-r--r--examples/quick/views/parallax/content/background.pngbin46895 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/center.pngbin765 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/clock-night.pngbin23359 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/clock.pngbin20653 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/hour.pngbin518 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/minute.pngbin528 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/background.jpgbin209814 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/face-smile.pngbin15408 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/home-page.pngbin2936 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/home-page.svg445
-rw-r--r--examples/quick/views/parallax/content/pics/shadow.pngbin349 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/yast-joystick.pngbin2723 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/pics/yast-wol.pngbin3769 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/quit.pngbin583 -> 0 bytes
-rw-r--r--examples/quick/views/parallax/content/second.pngbin231 -> 0 bytes
-rw-r--r--examples/quick/views/views.qrc20
-rw-r--r--examples/quick/window/window.qml2
-rw-r--r--qtdeclarative.doxy2466
-rw-r--r--src/3rdparty/masm/assembler/ARM64Assembler.h24
-rw-r--r--src/3rdparty/masm/assembler/ARMAssembler.cpp444
-rw-r--r--src/3rdparty/masm/assembler/ARMAssembler.h1129
-rw-r--r--src/3rdparty/masm/assembler/AbstractMacroAssembler.h11
-rw-r--r--src/3rdparty/masm/assembler/AssemblerBuffer.h2
-rw-r--r--src/3rdparty/masm/assembler/LinkBuffer.cpp17
-rw-r--r--src/3rdparty/masm/assembler/LinkBuffer.h38
-rw-r--r--src/3rdparty/masm/assembler/MacroAssembler.h18
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerARM.cpp99
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerARM.h1386
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerARM64.h23
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerARMv7.h13
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h9
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerMIPS.h14
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerSH4.h2293
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerX86.h5
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerX86Common.h32
-rw-r--r--src/3rdparty/masm/assembler/MacroAssemblerX86_64.h20
-rw-r--r--src/3rdparty/masm/assembler/SH4Assembler.h2152
-rw-r--r--src/3rdparty/masm/assembler/X86Assembler.h33
-rw-r--r--src/3rdparty/masm/masm-defs.pri1
-rw-r--r--src/3rdparty/masm/masm.pri14
-rw-r--r--src/3rdparty/masm/qt_attribution.json2
-rw-r--r--src/3rdparty/masm/stubs/ExecutableAllocator.h4
-rw-r--r--src/3rdparty/masm/stubs/Options.h2
-rw-r--r--src/3rdparty/masm/stubs/SuperSampler.h50
-rw-r--r--src/3rdparty/masm/stubs/WTFStubs.cpp6
-rw-r--r--src/3rdparty/masm/stubs/runtime/ConcurrentJSLock.h53
-rw-r--r--src/3rdparty/masm/stubs/runtime/RegExpKey.h46
-rw-r--r--src/3rdparty/masm/stubs/runtime/VM.h50
-rw-r--r--src/3rdparty/masm/stubs/wtf/HashMap.h58
-rw-r--r--src/3rdparty/masm/stubs/wtf/HashSet.h67
-rw-r--r--src/3rdparty/masm/stubs/wtf/Optional.h83
-rw-r--r--src/3rdparty/masm/stubs/wtf/PassRefPtr.h14
-rw-r--r--src/3rdparty/masm/stubs/wtf/Vector.h7
-rw-r--r--src/3rdparty/masm/stubs/wtf/text/CString.h4
-rw-r--r--src/3rdparty/masm/stubs/wtf/text/StringBuilder.h52
-rw-r--r--src/3rdparty/masm/stubs/wtf/text/WTFString.h15
-rw-r--r--src/3rdparty/masm/stubs/wtf/unicode/Unicode.h30
-rw-r--r--src/3rdparty/masm/stubs/wtf/unicode/utypes.h1
-rw-r--r--src/3rdparty/masm/stubs/yarr/YarrUnicodeProperties.cpp70
-rw-r--r--src/3rdparty/masm/wtf/Assertions.h2
-rw-r--r--src/3rdparty/masm/wtf/FilePrintStream.cpp11
-rw-r--r--src/3rdparty/masm/wtf/FilePrintStream.h9
-rw-r--r--src/3rdparty/masm/wtf/OSAllocatorPosix.cpp87
-rw-r--r--src/3rdparty/masm/wtf/Platform.h12
-rw-r--r--src/3rdparty/masm/wtf/PrintStream.h17
-rw-r--r--src/3rdparty/masm/wtf/StdLibExtras.h5
-rw-r--r--src/3rdparty/masm/wtf/VMTags.h8
-rw-r--r--src/3rdparty/masm/yarr/Yarr.h36
-rw-r--r--src/3rdparty/masm/yarr/YarrCanonicalize.h143
-rw-r--r--src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.cpp823
-rw-r--r--src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.js304
-rw-r--r--src/3rdparty/masm/yarr/YarrCanonicalizeUnicode.cpp591
-rw-r--r--src/3rdparty/masm/yarr/YarrErrorCode.cpp96
-rw-r--r--src/3rdparty/masm/yarr/YarrErrorCode.h65
-rw-r--r--src/3rdparty/masm/yarr/YarrInterpreter.cpp877
-rw-r--r--src/3rdparty/masm/yarr/YarrInterpreter.h100
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.cpp1655
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.h122
-rw-r--r--src/3rdparty/masm/yarr/YarrParser.h549
-rw-r--r--src/3rdparty/masm/yarr/YarrPattern.cpp962
-rw-r--r--src/3rdparty/masm/yarr/YarrPattern.h350
-rw-r--r--src/3rdparty/masm/yarr/YarrSyntaxChecker.cpp15
-rw-r--r--src/3rdparty/masm/yarr/YarrSyntaxChecker.h11
-rw-r--r--src/3rdparty/masm/yarr/YarrUnicodeProperties.h (renamed from src/3rdparty/masm/assembler/MacroAssemblerSH4.cpp)37
-rw-r--r--src/3rdparty/masm/yarr/create_regex_tables (renamed from src/3rdparty/masm/create_regex_tables)31
-rw-r--r--src/3rdparty/masm/yarr/generateYarrCanonicalizeUnicode204
-rw-r--r--src/3rdparty/masm/yarr/yarr.pri5
-rw-r--r--src/imports/builtins/builtins.qmltypes6
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.pro2
-rw-r--r--src/imports/folderlistmodel/plugin.cpp9
-rw-r--r--src/imports/folderlistmodel/plugins.qmltypes4
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp18
-rw-r--r--src/imports/handlers/handlers.pro11
-rw-r--r--src/imports/handlers/plugins.qmltypes308
-rw-r--r--src/imports/handlers/qmldir5
-rw-r--r--src/imports/imports.pro12
-rw-r--r--src/imports/labsmodels/labsmodels.pro11
-rw-r--r--src/imports/labsmodels/plugin.cpp (renamed from src/imports/handlers/plugin.cpp)38
-rw-r--r--src/imports/labsmodels/plugins.qmltypes41
-rw-r--r--src/imports/labsmodels/qmldir3
-rw-r--r--src/imports/layouts/plugin.cpp8
-rw-r--r--src/imports/layouts/plugins.qmltypes4
-rw-r--r--src/imports/localstorage/dependencies.json2
-rw-r--r--src/imports/localstorage/localstorage.pro2
-rw-r--r--src/imports/localstorage/plugin.cpp60
-rw-r--r--src/imports/localstorage/plugins.qmltypes2
-rw-r--r--src/imports/models/dependencies.json2
-rw-r--r--src/imports/models/plugin.cpp17
-rw-r--r--src/imports/models/plugins.qmltypes2
-rw-r--r--src/imports/particles/plugin.cpp9
-rw-r--r--src/imports/particles/plugins.qmltypes4
-rw-r--r--src/imports/qtqml/plugins.qmltypes20
-rw-r--r--src/imports/qtqml/qtqml.pro4
-rw-r--r--src/imports/qtquick2/dependencies.json2
-rw-r--r--src/imports/qtquick2/plugin.cpp9
-rw-r--r--src/imports/qtquick2/plugins.qmltypes414
-rw-r--r--src/imports/qtquick2/qtquick2.pro2
-rw-r--r--src/imports/settings/dependencies.json2
-rw-r--r--src/imports/settings/plugin.cpp10
-rw-r--r--src/imports/settings/plugins.qmltypes29
-rw-r--r--src/imports/settings/qqmlsettings.cpp71
-rw-r--r--src/imports/settings/qqmlsettings_p.h7
-rw-r--r--src/imports/settings/settings.pro2
-rw-r--r--src/imports/shapes/plugin.cpp17
-rw-r--r--src/imports/shapes/plugins.qmltypes4
-rw-r--r--src/imports/shapes/shapes.pro26
-rw-r--r--src/imports/sharedimage/plugins.qmltypes2
-rw-r--r--src/imports/statemachine/dependencies.json2
-rw-r--r--src/imports/statemachine/plugin.cpp9
-rw-r--r--src/imports/statemachine/plugins.qmltypes2
-rw-r--r--src/imports/statemachine/signaltransition.cpp6
-rw-r--r--src/imports/statemachine/signaltransition.h4
-rw-r--r--src/imports/testlib/TestCase.qml18
-rw-r--r--src/imports/testlib/main.cpp9
-rw-r--r--src/imports/testlib/plugins.qmltypes4
-rw-r--r--src/imports/window/plugin.cpp17
-rw-r--r--src/imports/window/plugins.qmltypes4
-rw-r--r--src/imports/xmllistmodel/plugin.cpp9
-rw-r--r--src/imports/xmllistmodel/plugins.qmltypes4
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp40
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel_p.h2
-rw-r--r--src/imports/xmllistmodel/xmllistmodel.pro3
-rw-r--r--src/particles/qquickcustomaffector.cpp2
-rw-r--r--src/particles/qquickparticleemitter.cpp2
-rw-r--r--src/particles/qquicktrailemitter.cpp2
-rw-r--r--src/particles/qquickv4particledata.cpp4
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp79
-rw-r--r--src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h3
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp142
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h19
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp21
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h16
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp280
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h24
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp28
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro29
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.cpp213
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h100
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp443
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.h136
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.cpp195
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h116
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp472
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.h154
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.cpp113
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.h (renamed from src/quick/scenegraph/compressedtexture/qsgtexturefilehandler_p.h)46
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.cpp195
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.h113
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json3
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp50
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.h (renamed from src/quick/scenegraph/compressedtexture/qsgktxhandler_p.h)31
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp19
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h3
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp17
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h1
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp20
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h3
-rw-r--r--src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp52
-rw-r--r--src/plugins/qmltooling/qmltooling.pro9
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp14
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h2
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp5
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h2
-rw-r--r--src/qml/animations/qanimationgroupjob_p.h2
-rw-r--r--src/qml/animations/qanimationjobutil_p.h2
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob_p.h2
-rw-r--r--src/qml/animations/qparallelanimationgroupjob_p.h2
-rw-r--r--src/qml/animations/qpauseanimationjob_p.h2
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob_p.h2
-rw-r--r--src/qml/compiler/compiler.pri6
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp348
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h25
-rw-r--r--src/qml/compiler/qqmlpropertycachecreator_p.h28
-rw-r--r--src/qml/compiler/qqmlpropertyvalidator.cpp60
-rw-r--r--src/qml/compiler/qqmlpropertyvalidator_p.h5
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp70
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h3
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp50
-rw-r--r--src/qml/compiler/qv4bytecodegenerator_p.h79
-rw-r--r--src/qml/compiler/qv4bytecodehandler.cpp551
-rw-r--r--src/qml/compiler/qv4bytecodehandler_p.h115
-rw-r--r--src/qml/compiler/qv4codegen.cpp2240
-rw-r--r--src/qml/compiler/qv4codegen_p.h133
-rw-r--r--src/qml/compiler/qv4compilationunitmapper_unix.cpp16
-rw-r--r--src/qml/compiler/qv4compilationunitmapper_win.cpp26
-rw-r--r--src/qml/compiler/qv4compileddata.cpp595
-rw-r--r--src/qml/compiler/qv4compileddata_p.h433
-rw-r--r--src/qml/compiler/qv4compiler.cpp337
-rw-r--r--src/qml/compiler/qv4compiler_p.h22
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp341
-rw-r--r--src/qml/compiler/qv4compilercontext_p.h161
-rw-r--r--src/qml/compiler/qv4compilercontrolflow_p.h421
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp713
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions_p.h59
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp179
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h240
-rw-r--r--src/qml/compiler/qv4jssimplifier.cpp384
-rw-r--r--src/qml/compiler/qv4jssimplifier_p.h154
-rw-r--r--src/qml/configure.json68
-rw-r--r--src/qml/debugger/qqmlabstractprofileradapter_p.h6
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp2
-rw-r--r--src/qml/debugger/qqmlprofiler.cpp9
-rw-r--r--src/qml/debugger/qqmlprofiler_p.h2
-rw-r--r--src/qml/doc/images/cpp-qml-integration-flowchart.odgbin16080 -> 15028 bytes
-rw-r--r--src/qml/doc/images/cpp-qml-integration-flowchart.pngbin113781 -> 80498 bytes
-rw-r--r--src/qml/doc/images/objectmodel.png (renamed from src/qml/doc/images/visualitemmodel.png)bin347 -> 347 bytes
-rw-r--r--src/qml/doc/snippets/delegatemodel/delegatemodel.qml (renamed from src/qml/doc/snippets/delegatemodel/visualdatamodel.qml)0
-rw-r--r--src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp (renamed from src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/main.cpp)0
-rw-r--r--src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml (renamed from src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/view.qml)0
-rw-r--r--src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml (renamed from src/qml/doc/snippets/delegatemodel/visualdatagroup.qml)0
-rw-r--r--src/qml/doc/snippets/qml/workerscript/script.mjs (renamed from src/qml/doc/snippets/qml/workerscript/script.js)0
-rw-r--r--src/qml/doc/snippets/qml/workerscript/workerscript.qml2
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc45
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc3
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc46
-rw-r--r--src/qml/doc/src/qmltypereference.qdoc14
-rw-r--r--src/qml/doc/src/qtqml.qdoc9
-rw-r--r--src/qml/doc/src/statemachine.qdoc14
-rw-r--r--src/qml/jit/jit.pri12
-rw-r--r--src/qml/jit/qv4assemblercommon.cpp343
-rw-r--r--src/qml/jit/qv4assemblercommon_p.h697
-rw-r--r--src/qml/jit/qv4baselineassembler.cpp (renamed from src/qml/jit/qv4assembler.cpp)1234
-rw-r--r--src/qml/jit/qv4baselineassembler_p.h (renamed from src/qml/jit/qv4assembler_p.h)51
-rw-r--r--src/qml/jit/qv4baselinejit.cpp1000
-rw-r--r--src/qml/jit/qv4baselinejit_p.h (renamed from src/qml/jit/qv4jit_p.h)124
-rw-r--r--src/qml/jit/qv4jit.cpp1328
-rw-r--r--src/qml/jit/qv4jithelpers.cpp168
-rw-r--r--src/qml/jit/qv4jithelpers_p.h91
-rw-r--r--src/qml/jsapi/qjsengine.cpp185
-rw-r--r--src/qml/jsapi/qjsengine.h4
-rw-r--r--src/qml/jsapi/qjsvalue.cpp42
-rw-r--r--src/qml/jsapi/qjsvalue_p.h2
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp132
-rw-r--r--src/qml/jsapi/qjsvalueiterator_p.h16
-rw-r--r--src/qml/jsruntime/jsruntime.pri49
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp249
-rw-r--r--src/qml/jsruntime/qv4argumentsobject_p.h85
-rw-r--r--src/qml/jsruntime/qv4arraybuffer.cpp143
-rw-r--r--src/qml/jsruntime/qv4arraybuffer_p.h83
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp105
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h34
-rw-r--r--src/qml/jsruntime/qv4arrayiterator.cpp106
-rw-r--r--src/qml/jsruntime/qv4arrayiterator_p.h106
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp685
-rw-r--r--src/qml/jsruntime/qv4arrayobject_p.h16
-rw-r--r--src/qml/jsruntime/qv4atomics.cpp257
-rw-r--r--src/qml/jsruntime/qv4atomics_p.h91
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4booleanobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4context.cpp221
-rw-r--r--src/qml/jsruntime/qv4context_p.h96
-rw-r--r--src/qml/jsruntime/qv4dataview.cpp218
-rw-r--r--src/qml/jsruntime/qv4dataview_p.h6
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp206
-rw-r--r--src/qml/jsruntime/qv4dateobject_p.h9
-rw-r--r--src/qml/jsruntime/qv4engine.cpp806
-rw-r--r--src/qml/jsruntime/qv4engine_p.h206
-rw-r--r--src/qml/jsruntime/qv4enginebase_p.h24
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp78
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h77
-rw-r--r--src/qml/jsruntime/qv4estable.cpp199
-rw-r--r--src/qml/jsruntime/qv4estable_p.h89
-rw-r--r--src/qml/jsruntime/qv4function.cpp52
-rw-r--r--src/qml/jsruntime/qv4function_p.h25
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp421
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h162
-rw-r--r--src/qml/jsruntime/qv4generatorobject.cpp251
-rw-r--r--src/qml/jsruntime/qv4generatorobject_p.h151
-rw-r--r--src/qml/jsruntime/qv4global_p.h43
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp15
-rw-r--r--src/qml/jsruntime/qv4globalobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4identifier.cpp86
-rw-r--r--src/qml/jsruntime/qv4identifier_p.h48
-rw-r--r--src/qml/jsruntime/qv4identifiertable.cpp191
-rw-r--r--src/qml/jsruntime/qv4identifiertable_p.h54
-rw-r--r--src/qml/jsruntime/qv4include.cpp22
-rw-r--r--src/qml/jsruntime/qv4internalclass.cpp671
-rw-r--r--src/qml/jsruntime/qv4internalclass_p.h362
-rw-r--r--src/qml/jsruntime/qv4iterator.cpp64
-rw-r--r--src/qml/jsruntime/qv4iterator_p.h82
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h11
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp36
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp139
-rw-r--r--src/qml/jsruntime/qv4lookup_p.h52
-rw-r--r--src/qml/jsruntime/qv4managed.cpp66
-rw-r--r--src/qml/jsruntime/qv4managed_p.h128
-rw-r--r--src/qml/jsruntime/qv4mapiterator.cpp107
-rw-r--r--src/qml/jsruntime/qv4mapiterator_p.h104
-rw-r--r--src/qml/jsruntime/qv4mapobject.cpp379
-rw-r--r--src/qml/jsruntime/qv4mapobject_p.h145
-rw-r--r--src/qml/jsruntime/qv4math_p.h12
-rw-r--r--src/qml/jsruntime/qv4mathobject.cpp261
-rw-r--r--src/qml/jsruntime/qv4mathobject_p.h16
-rw-r--r--src/qml/jsruntime/qv4memberdata.cpp5
-rw-r--r--src/qml/jsruntime/qv4memberdata_p.h12
-rw-r--r--src/qml/jsruntime/qv4module.cpp237
-rw-r--r--src/qml/jsruntime/qv4module_p.h95
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp70
-rw-r--r--src/qml/jsruntime/qv4numberobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4object.cpp1194
-rw-r--r--src/qml/jsruntime/qv4object_p.h303
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp199
-rw-r--r--src/qml/jsruntime/qv4objectiterator_p.h89
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp356
-rw-r--r--src/qml/jsruntime/qv4objectproto_p.h26
-rw-r--r--src/qml/jsruntime/qv4persistent.cpp18
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp9
-rw-r--r--src/qml/jsruntime/qv4profiling_p.h2
-rw-r--r--src/qml/jsruntime/qv4property_p.h71
-rw-r--r--src/qml/jsruntime/qv4propertykey.cpp109
-rw-r--r--src/qml/jsruntime/qv4propertykey_p.h154
-rw-r--r--src/qml/jsruntime/qv4proxy.cpp782
-rw-r--r--src/qml/jsruntime/qv4proxy_p.h144
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp128
-rw-r--r--src/qml/jsruntime/qv4qmlcontext_p.h9
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp168
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h22
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp285
-rw-r--r--src/qml/jsruntime/qv4reflect_p.h89
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp116
-rw-r--r--src/qml/jsruntime/qv4regexp_p.h45
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp729
-rw-r--r--src/qml/jsruntime/qv4regexpobject_p.h55
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp1024
-rw-r--r--src/qml/jsruntime/qv4runtime_p.h1
-rw-r--r--src/qml/jsruntime/qv4runtimeapi_p.h40
-rw-r--r--src/qml/jsruntime/qv4runtimecodegen.cpp9
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h118
-rw-r--r--src/qml/jsruntime/qv4script.cpp38
-rw-r--r--src/qml/jsruntime/qv4script_p.h17
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp111
-rw-r--r--src/qml/jsruntime/qv4sequenceobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp30
-rw-r--r--src/qml/jsruntime/qv4setiterator.cpp98
-rw-r--r--src/qml/jsruntime/qv4setiterator_p.h103
-rw-r--r--src/qml/jsruntime/qv4setobject.cpp323
-rw-r--r--src/qml/jsruntime/qv4setobject_p.h144
-rw-r--r--src/qml/jsruntime/qv4sparsearray.cpp2
-rw-r--r--src/qml/jsruntime/qv4sparsearray_p.h3
-rw-r--r--src/qml/jsruntime/qv4stackframe.cpp74
-rw-r--r--src/qml/jsruntime/qv4stackframe_p.h217
-rw-r--r--src/qml/jsruntime/qv4string.cpp34
-rw-r--r--src/qml/jsruntime/qv4string_p.h122
-rw-r--r--src/qml/jsruntime/qv4stringiterator.cpp95
-rw-r--r--src/qml/jsruntime/qv4stringiterator_p.h103
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp471
-rw-r--r--src/qml/jsruntime/qv4stringobject_p.h23
-rw-r--r--src/qml/jsruntime/qv4symbol.cpp187
-rw-r--r--src/qml/jsruntime/qv4symbol_p.h126
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp1434
-rw-r--r--src/qml/jsruntime/qv4typedarray_p.h125
-rw-r--r--src/qml/jsruntime/qv4util_p.h20
-rw-r--r--src/qml/jsruntime/qv4value.cpp56
-rw-r--r--src/qml/jsruntime/qv4value_p.h310
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4variantobject_p.h3
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp531
-rw-r--r--src/qml/jsruntime/qv4vme_moth_p.h9
-rw-r--r--src/qml/jsruntime/qv4vtable_p.h226
-rw-r--r--src/qml/memory/qv4heap_p.h99
-rw-r--r--src/qml/memory/qv4mm.cpp135
-rw-r--r--src/qml/memory/qv4mm_p.h233
-rw-r--r--src/qml/parser/parser.pri16
-rw-r--r--src/qml/parser/qqmljs.g4856
-rw-r--r--src/qml/parser/qqmljsast.cpp645
-rw-r--r--src/qml/parser/qqmljsast_p.h1306
-rw-r--r--src/qml/parser/qqmljsastfwd_p.h45
-rw-r--r--src/qml/parser/qqmljsastvisitor_p.h106
-rw-r--r--src/qml/parser/qqmljsengine_p.cpp7
-rw-r--r--src/qml/parser/qqmljsengine_p.h28
-rw-r--r--src/qml/parser/qqmljsgrammar.cpp1167
-rw-r--r--src/qml/parser/qqmljsgrammar_p.h215
-rw-r--r--src/qml/parser/qqmljskeywords_p.h131
-rw-r--r--src/qml/parser/qqmljslexer.cpp768
-rw-r--r--src/qml/parser/qqmljslexer_p.h92
-rw-r--r--src/qml/parser/qqmljsmemorypool_p.h15
-rw-r--r--src/qml/parser/qqmljsparser.cpp2010
-rw-r--r--src/qml/parser/qqmljsparser_p.h258
-rw-r--r--src/qml/qml.pro4
-rw-r--r--src/qml/qml/ftw/ftw.pri3
-rw-r--r--src/qml/qml/ftw/qflagpointer_p.h8
-rw-r--r--src/qml/qml/ftw/qqmlrefcount_p.h20
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp10
-rw-r--r--src/qml/qml/qml.pri21
-rw-r--r--src/qml/qml/qqml.h34
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp4
-rw-r--r--src/qml/qml/qqmlbinding.cpp15
-rw-r--r--src/qml/qml/qqmlbinding_p.h3
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp54
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h6
-rw-r--r--src/qml/qml/qqmlcomponent.cpp59
-rw-r--r--src/qml/qml/qqmlcomponent.h1
-rw-r--r--src/qml/qml/qqmlcomponent_p.h9
-rw-r--r--src/qml/qml/qqmlcontext.cpp2
-rw-r--r--src/qml/qml/qqmlcustomparser_p.h4
-rw-r--r--src/qml/qml/qqmldata_p.h2
-rw-r--r--src/qml/qml/qqmldelayedcallqueue.cpp4
-rw-r--r--src/qml/qml/qqmldirparser.cpp11
-rw-r--r--src/qml/qml/qqmldirparser_p.h3
-rw-r--r--src/qml/qml/qqmlengine.cpp131
-rw-r--r--src/qml/qml/qqmlengine.h16
-rw-r--r--src/qml/qml/qqmlengine_p.h4
-rw-r--r--src/qml/qml/qqmlerror.cpp2
-rw-r--r--src/qml/qml/qqmlexpression.cpp2
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp2
-rw-r--r--src/qml/qml/qqmlguard_p.h28
-rw-r--r--src/qml/qml/qqmlimport.cpp36
-rw-r--r--src/qml/qml/qqmlimport_p.h4
-rw-r--r--src/qml/qml/qqmlincubator.cpp3
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp10
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h17
-rw-r--r--src/qml/qml/qqmllist.cpp5
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp89
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h7
-rw-r--r--src/qml/qml/qqmllocale.cpp12
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp36
-rw-r--r--src/qml/qml/qqmlloggingcategory_p.h13
-rw-r--r--src/qml/qml/qqmlmetatype.cpp144
-rw-r--r--src/qml/qml/qqmlmetatype_p.h7
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp135
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h6
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp122
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h5
-rw-r--r--src/qml/qml/qqmlparserstatus.cpp2
-rw-r--r--src/qml/qml/qqmlprivate.h10
-rw-r--r--src/qml/qml/qqmlproperty.cpp4
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp10
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h6
-rw-r--r--src/qml/qml/qqmltypeloader.cpp363
-rw-r--r--src/qml/qml/qqmltypeloader_p.h45
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp90
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h16
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp60
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp86
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h11
-rw-r--r--src/qml/qml/qqmlvme_p.h4
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp20
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h6
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp176
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h4
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp60
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h11
-rw-r--r--src/qml/qml/v8/qv4domerrors.cpp34
-rw-r--r--src/qml/qml/v8/qv4domerrors_p.h2
-rw-r--r--src/qml/qml/v8/qv4sqlerrors.cpp16
-rw-r--r--src/qml/qml/v8/qv8engine.cpp39
-rw-r--r--src/qml/qml/v8/qv8engine_p.h10
-rw-r--r--src/qml/qtqmlglobal.h1
-rw-r--r--src/qml/qtqmlglobal_p.h2
-rw-r--r--src/qml/types/qqmlconnections.cpp13
-rw-r--r--src/qml/types/qqmlconnections_p.h6
-rw-r--r--src/qml/types/qqmldelegatecomponent.cpp298
-rw-r--r--src/qml/types/qqmldelegatecomponent_p.h155
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp443
-rw-r--r--src/qml/types/qqmldelegatemodel_p.h4
-rw-r--r--src/qml/types/qqmldelegatemodel_p_p.h31
-rw-r--r--src/qml/types/qqmllistmodel.cpp266
-rw-r--r--src/qml/types/qqmllistmodel_p.h12
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h42
-rw-r--r--src/qml/types/qqmllistmodelworkeragent_p.h2
-rw-r--r--src/qml/types/qqmlmodelsmodule.cpp14
-rw-r--r--src/qml/types/qqmlmodelsmodule_p.h1
-rw-r--r--src/qml/types/qqmlobjectmodel.cpp19
-rw-r--r--src/qml/types/qqmlobjectmodel_p.h2
-rw-r--r--src/qml/types/qqmltableinstancemodel.cpp542
-rw-r--r--src/qml/types/qqmltableinstancemodel_p.h160
-rw-r--r--src/qml/types/qqmltimer_p.h2
-rw-r--r--src/qml/types/qquickworkerscript.cpp295
-rw-r--r--src/qml/types/types.pri39
-rw-r--r--src/qml/util/qqmladaptormodel.cpp228
-rw-r--r--src/qml/util/qqmladaptormodel_p.h28
-rw-r--r--src/qml/util/qqmllistaccessor.cpp21
-rw-r--r--src/qml/util/qqmllistcompositor.cpp2
-rw-r--r--src/qml/util/qqmlpropertymap.cpp4
-rw-r--r--src/qmldebug/qmldebug.pro3
-rw-r--r--src/qmldebug/qqmldebugclient.cpp5
-rw-r--r--src/qmldebug/qqmldebugclient_p.h5
-rw-r--r--src/qmldebug/qqmldebugconnection.cpp4
-rw-r--r--src/qmldebug/qqmldebugmessageclient.cpp5
-rw-r--r--src/qmldebug/qqmldebugmessageclient_p.h5
-rw-r--r--src/qmldebug/qqmlenginecontrolclient.cpp6
-rw-r--r--src/qmldebug/qqmlpreviewclient.cpp139
-rw-r--r--src/qmldebug/qqmlpreviewclient_p.h111
-rw-r--r--src/qmldebug/qqmlpreviewclient_p_p.h (renamed from src/qml/qml/ftw/qdeferredcleanup_p.h)28
-rw-r--r--src/qmldebug/qqmlprofilerclient.cpp7
-rw-r--r--src/qmldebug/qqmlprofilerclient_p.h2
-rw-r--r--src/qmldebug/qqmlprofilerclient_p_p.h3
-rw-r--r--src/qmldevtools/qmldevtools.pro2
-rw-r--r--src/qmltest/doc/src/qtquicktest-index.qdoc8
-rw-r--r--src/qmltest/qtestoptions_p.h6
-rw-r--r--src/qmltest/quicktest.cpp37
-rw-r--r--src/qmltest/quicktestevent.cpp6
-rw-r--r--src/qmltest/quicktestevent_p.h2
-rw-r--r--src/qmltest/quicktestresult.cpp14
-rw-r--r--src/qmltest/quicktestresult_p.h2
-rw-r--r--src/quick/configure.json12
-rw-r--r--src/quick/designer/qqmldesignermetaobject.cpp4
-rw-r--r--src/quick/designer/qquickdesignercustomparserobject.cpp4
-rw-r--r--src/quick/designer/qquickdesignercustomparserobject_p.h4
-rw-r--r--src/quick/doc/images/9BcAYDlpuT8.jpgbin0 -> 8788 bytes
-rw-r--r--src/quick/doc/images/pointDistanceThreshold.pngbin8661 -> 0 bytes
-rw-r--r--src/quick/doc/images/pointerHandlerMargin.pngbin0 -> 11410 bytes
-rw-r--r--src/quick/doc/images/pointerHandlerMargin.svg (renamed from src/quick/doc/images/pointDistanceThreshold.svg)46
-rw-r--r--src/quick/doc/images/qml-item-canvas-lineDash.pngbin0 -> 6254 bytes
-rw-r--r--src/quick/doc/qtquick.qdocconf4
-rw-r--r--src/quick/doc/snippets/pointerHandlers/dragHandler.qml3
-rw-r--r--src/quick/doc/snippets/pointerHandlers/dragHandlerDifferentTarget.qml9
-rw-r--r--src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml11
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pinchHandler.qml3
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml3
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml3
-rw-r--r--src/quick/doc/snippets/pointerHandlers/pointHandler.qml3
-rw-r--r--src/quick/doc/snippets/qml/pathview/pathview.qml4
-rw-r--r--src/quick/doc/snippets/qml/rectangle/rectangle-gradient.qml12
-rw-r--r--src/quick/doc/snippets/qml/tableview/reusabledelegate.qml (renamed from examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml)40
-rw-r--r--src/quick/doc/snippets/qml/tableview/tablemodel.cpp103
-rw-r--r--src/quick/doc/snippets/qml/tableview/tablemodel.qml (renamed from examples/quick/demos/samegame/content/MenuEmitter.qml)32
-rw-r--r--src/quick/doc/snippets/qml/tableview/tableviewwithheader.qml (renamed from examples/quick/demos/stocqt/content/+windows/Settings.qml)20
-rw-r--r--src/quick/doc/snippets/qml/tableview/tableviewwithprovider.qml (renamed from src/quick/doc/snippets/qml/models/visual-model-and-view.qml)31
-rw-r--r--src/quick/doc/snippets/qml/transition-reversible.qml14
-rw-r--r--src/quick/doc/src/concepts/effects/particles.qdoc18
-rw-r--r--src/quick/doc/src/concepts/input/mouse.qdoc25
-rw-r--r--src/quick/doc/src/concepts/input/topic.qdoc30
-rw-r--r--src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc (renamed from src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers-index.qdoc)41
-rw-r--r--src/quick/doc/src/concepts/layouts/qtquicklayouts.qdoc8
-rw-r--r--src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc7
-rw-r--r--src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc6
-rw-r--r--src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers.qdoc44
-rw-r--r--src/quick/doc/src/concepts/positioning/righttoleft.qdoc4
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc8
-rw-r--r--src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc12
-rw-r--r--src/quick/doc/src/qmltypereference.qdoc21
-rw-r--r--src/quick/handlers/handlers.pri11
-rw-r--r--src/quick/handlers/qquickdragaxis.cpp75
-rw-r--r--src/quick/handlers/qquickdragaxis_p.h87
-rw-r--r--src/quick/handlers/qquickdraghandler.cpp243
-rw-r--r--src/quick/handlers/qquickdraghandler_p.h53
-rw-r--r--src/quick/handlers/qquickhandlerpoint.cpp352
-rw-r--r--src/quick/handlers/qquickhandlerpoint_p.h121
-rw-r--r--src/quick/handlers/qquickhandlersmodule.cpp106
-rw-r--r--src/quick/handlers/qquickhoverhandler.cpp106
-rw-r--r--src/quick/handlers/qquickhoverhandler_p.h91
-rw-r--r--src/quick/handlers/qquickmultipointhandler.cpp198
-rw-r--r--src/quick/handlers/qquickmultipointhandler_p.h24
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp242
-rw-r--r--src/quick/handlers/qquickpinchhandler_p.h66
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler.cpp112
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler_p.h29
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler_p_p.h75
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp243
-rw-r--r--src/quick/handlers/qquickpointerhandler_p.h44
-rw-r--r--src/quick/handlers/qquickpointerhandler_p_p.h84
-rw-r--r--src/quick/handlers/qquickpointhandler.cpp23
-rw-r--r--src/quick/handlers/qquickpointhandler_p.h3
-rw-r--r--src/quick/handlers/qquicksinglepointhandler.cpp327
-rw-r--r--src/quick/handlers/qquicksinglepointhandler_p.h71
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp99
-rw-r--r--src/quick/handlers/qquicktaphandler_p.h25
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp192
-rw-r--r--src/quick/items/context2d/qquickcontext2d_p.h5
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp26
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h14
-rw-r--r--src/quick/items/items.pri10
-rw-r--r--src/quick/items/qquickanchors_p.h1
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp11
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h2
-rw-r--r--src/quick/items/qquickevents.cpp214
-rw-r--r--src/quick/items/qquickevents_p_p.h183
-rw-r--r--src/quick/items/qquickflickable.cpp104
-rw-r--r--src/quick/items/qquickflickable_p.h18
-rw-r--r--src/quick/items/qquickflickable_p_p.h2
-rw-r--r--src/quick/items/qquickgridview.cpp21
-rw-r--r--src/quick/items/qquickitem.cpp45
-rw-r--r--src/quick/items/qquickitem.h1
-rw-r--r--src/quick/items/qquickitem_p.h24
-rw-r--r--src/quick/items/qquickitemsmodule.cpp48
-rw-r--r--src/quick/items/qquickitemview.cpp112
-rw-r--r--src/quick/items/qquickitemview_p_p.h37
-rw-r--r--src/quick/items/qquickitemviewfxitem.cpp165
-rw-r--r--src/quick/items/qquickitemviewfxitem_p_p.h108
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp2
-rw-r--r--src/quick/items/qquicklistview.cpp18
-rw-r--r--src/quick/items/qquickloader.cpp19
-rw-r--r--src/quick/items/qquickloader_p_p.h3
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp3
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h4
-rw-r--r--src/quick/items/qquickpainteditem.h1
-rw-r--r--src/quick/items/qquickpositioners.cpp24
-rw-r--r--src/quick/items/qquickrectangle.cpp121
-rw-r--r--src/quick/items/qquickrectangle_p.h17
-rw-r--r--src/quick/items/qquickrectangle_p_p.h2
-rw-r--r--src/quick/items/qquickrendercontrol.cpp3
-rw-r--r--src/quick/items/qquickscalegrid.cpp4
-rw-r--r--src/quick/items/qquickscalegrid_p_p.h12
-rw-r--r--src/quick/items/qquickscreen.cpp40
-rw-r--r--src/quick/items/qquickshadereffectmesh.cpp5
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h7
-rw-r--r--src/quick/items/qquickspriteengine_p.h2
-rw-r--r--src/quick/items/qquicktableview.cpp2024
-rw-r--r--src/quick/items/qquicktableview_p.h173
-rw-r--r--src/quick/items/qquicktableview_p_p.h387
-rw-r--r--src/quick/items/qquicktext.cpp51
-rw-r--r--src/quick/items/qquicktext_p.h10
-rw-r--r--src/quick/items/qquicktext_p_p.h1
-rw-r--r--src/quick/items/qquickwindow.cpp229
-rw-r--r--src/quick/items/qquickwindow.h1
-rw-r--r--src/quick/items/qquickwindow_p.h10
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp5
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h1
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp34
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp12
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h4
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp4
-rw-r--r--src/quick/scenegraph/adaptations/software/software.pri13
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp14
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp79
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h31
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgktxhandler.cpp186
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp118
-rw-r--r--src/quick/scenegraph/coreapi/qsgabstractrenderer.h1
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp27
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h19
-rw-r--r--src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp225
-rw-r--r--src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h2
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp7
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp295
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h4
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp3
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp2
-rw-r--r--src/quick/scenegraph/scenegraph.pri18
-rw-r--r--src/quick/scenegraph/util/qsgareaallocator.cpp144
-rw-r--r--src/quick/scenegraph/util/qsgareaallocator_p.h4
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture.cpp25
-rw-r--r--src/quick/scenegraph/util/qsgengine.h1
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp13
-rw-r--r--src/quick/scenegraph/util/qsgtexturereader.cpp61
-rw-r--r--src/quick/scenegraph/util/qsgtexturereader_p.h8
-rw-r--r--src/quick/util/qquickanimation.cpp22
-rw-r--r--src/quick/util/qquickanimation_p.h1
-rw-r--r--src/quick/util/qquickglobal.cpp2
-rw-r--r--src/quick/util/qquickimageprovider.cpp7
-rw-r--r--src/quick/util/qquickimageprovider.h6
-rw-r--r--src/quick/util/qquickimageprovider_p.h (renamed from src/quick/scenegraph/compressedtexture/qsgpkmhandler_p.h)22
-rw-r--r--src/quick/util/qquickpixmapcache.cpp19
-rw-r--r--src/quick/util/qquickprofiler.cpp3
-rw-r--r--src/quick/util/qquickprofiler_p.h2
-rw-r--r--src/quick/util/qquickpropertychanges.cpp38
-rw-r--r--src/quick/util/qquickpropertychanges_p.h6
-rw-r--r--src/quick/util/qquickstate.cpp2
-rw-r--r--src/quick/util/qquickstate_p_p.h4
-rw-r--r--src/quick/util/qquicksvgparser.cpp3
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp59
-rw-r--r--src/quick/util/qquickutilmodule.cpp3
-rw-r--r--src/quick/util/util.pri1
-rw-r--r--src/quickshapes/qquicknvprfunctions.cpp (renamed from src/imports/shapes/qquicknvprfunctions.cpp)0
-rw-r--r--src/quickshapes/qquicknvprfunctions_p.h (renamed from src/imports/shapes/qquicknvprfunctions_p.h)1
-rw-r--r--src/quickshapes/qquicknvprfunctions_p_p.h (renamed from src/imports/shapes/qquicknvprfunctions_p_p.h)3
-rw-r--r--src/quickshapes/qquickshape.cpp (renamed from src/imports/shapes/qquickshape.cpp)41
-rw-r--r--src/quickshapes/qquickshape_p.h (renamed from src/imports/shapes/qquickshape_p.h)15
-rw-r--r--src/quickshapes/qquickshape_p_p.h (renamed from src/imports/shapes/qquickshape_p_p.h)7
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp (renamed from src/imports/shapes/qquickshapegenericrenderer.cpp)18
-rw-r--r--src/quickshapes/qquickshapegenericrenderer_p.h (renamed from src/imports/shapes/qquickshapegenericrenderer_p.h)3
-rw-r--r--src/quickshapes/qquickshapenvprrenderer.cpp (renamed from src/imports/shapes/qquickshapenvprrenderer.cpp)0
-rw-r--r--src/quickshapes/qquickshapenvprrenderer_p.h (renamed from src/imports/shapes/qquickshapenvprrenderer_p.h)5
-rw-r--r--src/quickshapes/qquickshapesglobal.h56
-rw-r--r--src/quickshapes/qquickshapesglobal_p.h (renamed from src/quick/handlers/qquickhandlersmodule_p.h)17
-rw-r--r--src/quickshapes/qquickshapesoftwarerenderer.cpp (renamed from src/imports/shapes/qquickshapesoftwarerenderer.cpp)0
-rw-r--r--src/quickshapes/qquickshapesoftwarerenderer_p.h (renamed from src/imports/shapes/qquickshapesoftwarerenderer_p.h)3
-rw-r--r--src/quickshapes/qtquickshapes.qrc (renamed from src/imports/shapes/qtquickshapesplugin.qrc)0
-rw-r--r--src/quickshapes/quickshapes.pro33
-rw-r--r--src/quickshapes/shaders/blit.frag (renamed from src/imports/shapes/shaders/blit.frag)0
-rw-r--r--src/quickshapes/shaders/blit.vert (renamed from src/imports/shapes/shaders/blit.vert)0
-rw-r--r--src/quickshapes/shaders/blit_core.frag (renamed from src/imports/shapes/shaders/blit_core.frag)0
-rw-r--r--src/quickshapes/shaders/blit_core.vert (renamed from src/imports/shapes/shaders/blit_core.vert)0
-rw-r--r--src/quickshapes/shaders/conicalgradient.frag (renamed from src/imports/shapes/shaders/conicalgradient.frag)0
-rw-r--r--src/quickshapes/shaders/conicalgradient.vert (renamed from src/imports/shapes/shaders/conicalgradient.vert)0
-rw-r--r--src/quickshapes/shaders/conicalgradient_core.frag (renamed from src/imports/shapes/shaders/conicalgradient_core.frag)0
-rw-r--r--src/quickshapes/shaders/conicalgradient_core.vert (renamed from src/imports/shapes/shaders/conicalgradient_core.vert)0
-rw-r--r--src/quickshapes/shaders/lineargradient.frag (renamed from src/imports/shapes/shaders/lineargradient.frag)0
-rw-r--r--src/quickshapes/shaders/lineargradient.vert (renamed from src/imports/shapes/shaders/lineargradient.vert)0
-rw-r--r--src/quickshapes/shaders/lineargradient_core.frag (renamed from src/imports/shapes/shaders/lineargradient_core.frag)0
-rw-r--r--src/quickshapes/shaders/lineargradient_core.vert (renamed from src/imports/shapes/shaders/lineargradient_core.vert)0
-rw-r--r--src/quickshapes/shaders/radialgradient.frag (renamed from src/imports/shapes/shaders/radialgradient.frag)0
-rw-r--r--src/quickshapes/shaders/radialgradient.vert (renamed from src/imports/shapes/shaders/radialgradient.vert)0
-rw-r--r--src/quickshapes/shaders/radialgradient_core.frag (renamed from src/imports/shapes/shaders/radialgradient_core.frag)0
-rw-r--r--src/quickshapes/shaders/radialgradient_core.vert (renamed from src/imports/shapes/shaders/radialgradient_core.vert)0
-rw-r--r--src/src.pro18
-rw-r--r--sync.profile4
-rw-r--r--tests/auto/guiapplauncher/demos.txt8
-rw-r--r--tests/auto/qml/debugger/debugger.pro8
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp9
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/breakpointRelocation.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/changeBreakpoint.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/condition.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/condition.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/createComponent.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/encodeQmlScope.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/encodeQmlScope.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/exception.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/exception.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/loadjsfile.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/oncompleted.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/quit.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/quit.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/stepAction.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.js (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.js)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/timer.qml (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/timer.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro26
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro24
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.pro12
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp)279
-rw-r--r--tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.cpp (renamed from tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.cpp)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.pro9
-rw-r--r--tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp4
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/broken.qml31
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/i18n/qml_fr_FR.qm0
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/qtquick2.qml71
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/window.qml44
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/window1.qml43
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/window2.qml43
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/data/zoom.qml51
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/qqmlpreview.pro24
-rw-r--r--tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp365
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/quit.qml40
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp48
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp81
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp105
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h31
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugprocess.cpp8
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugprocess_p.h4
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp1
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.h3
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations1058
-rw-r--r--tests/auto/qml/ecmascripttests/ecmascripttests.pro15
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/main.cpp114
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/qjstest.pro13
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp852
-rw-r--r--tests/auto/qml/ecmascripttests/qjstest/test262runner.h132
m---------tests/auto/qml/ecmascripttests/test2620
-rwxr-xr-xtests/auto/qml/ecmascripttests/test262.py91
-rw-r--r--tests/auto/qml/ecmascripttests/testcase.pro15
-rw-r--r--tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp48
-rw-r--r--tests/auto/qml/qjsengine/modulewithlexicals.mjs9
-rw-r--r--tests/auto/qml/qjsengine/qjsengine.pro1
-rw-r--r--tests/auto/qml/qjsengine/testmodule.mjs6
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp242
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp4
-rw-r--r--tests/auto/qml/qml.pro4
-rw-r--r--tests/auto/qml/qmlcachegen/jsmoduleimport.qml6
-rw-r--r--tests/auto/qml/qmlcachegen/qmlcachegen.pro2
-rw-r--r--tests/auto/qml/qmlcachegen/script.mjs4
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp146
-rw-r--r--tests/auto/qml/qmldiskcache/importmodule.qml5
-rw-r--r--tests/auto/qml/qmldiskcache/module.mjs2
-rw-r--r--tests/auto/qml/qmldiskcache/qmldiskcache.pro2
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp172
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp3
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp24
-rw-r--r--tests/auto/qml/qqmlconsole/data/categorized_logging.qml14
-rw-r--r--tests/auto/qml/qqmlconsole/data/logging.qml2
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp24
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml16
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.js7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.qml15
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/ScriptAPI.js (renamed from tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/qmldir (renamed from tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/ScriptAPI.js (renamed from tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/qmldir (renamed from tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/removeBindingsWithNoDependencies.qml9
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp413
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp117
-rw-r--r--tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.1.mjs4
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.1.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.2.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.3.indirect.mjs4
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.3.mjs4
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJsModule.3.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/API.mjs4
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/qmldir1
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.4.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml10
-rw-r--r--tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml11
-rw-r--r--tests/auto/qml/qqmllanguage/data/singletonTest18.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp21
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h40
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp135
-rw-r--r--tests/auto/qml/qqmllistmodel/data/dynamicroles.qml21
-rw-r--r--tests/auto/qml/qqmllistmodel/data/qtbug38907.qml25
-rw-r--r--tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp111
-rw-r--r--tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp2
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp82
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp6
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp2
-rw-r--r--tests/auto/qml/qqmlpropertymap/data/PropertyMapSubType.qml9
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp22
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp10
-rw-r--r--tests/auto/qml/qqmltranslation/data/translationChange.qml8
-rw-r--r--tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp16
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp2
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp4
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.qml13
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp3
-rw-r--r--tests/auto/qml/qquickworkerscript/data/messagehandler.mjs4
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_global.js5
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_global2.js6
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_module.mjs5
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_global.qml5
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_global2.qml5
-rw-r--r--tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp64
-rw-r--r--tests/auto/qml/qv4identifiertable/qv4identifiertable.pro8
-rw-r--r--tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp363
-rw-r--r--tests/auto/qml/qv4mm/tst_qv4mm.cpp11
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp245
-rw-r--r--tests/auto/qmltest/listview/data/MultiDelegate.qml106
-rw-r--r--tests/auto/qmltest/listview/data/MultiDelegate2.qml (renamed from examples/quick/demos/stocqt/content/Banner.qml)85
-rw-r--r--tests/auto/qmltest/listview/data/logo.pngbin0 -> 1478 bytes
-rw-r--r--tests/auto/qmltest/listview/listview.pro1
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml51
-rw-r--r--tests/auto/qmltest/rectangle/tst_rectangle.qml23
-rw-r--r--tests/auto/qmltest/shadersource/BLACKLIST2
-rw-r--r--tests/auto/quick/drawingmodes/tst_drawingmodes.cpp4
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp4
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/data/GrooveDragSlider.qml122
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/data/KnobDragSlider.qml (renamed from tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml)19
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml22
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp159
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml5
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp80
-rw-r--r--tests/auto/quick/pointerhandlers/pointerhandlers.pro6
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml10
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/reparenting.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/simpleTapAndDragHandlers.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp152
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml164
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/qquickhoverhandler.pro15
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp234
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml69
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/data/threeFingers.qml59
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/data/transformedPinchHandler.qml53
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/qquickpinchhandler.pro16
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp692
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp99
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/data/pointTracker.qml57
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/qquickpointhandler.pro15
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp267
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml3
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp23
-rw-r--r--tests/auto/quick/propertyrequirements/propertyrequirements.pro7
-rw-r--r--tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp203
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/infiniteLoops.qml38
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp33
-rw-r--r--tests/auto/quick/qquickanimations/data/finished.qml95
-rw-r--r--tests/auto/quick/qquickanimations/data/replacingTransitions.qml51
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp111
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_line.qml91
-rw-r--r--tests/auto/quick/qquickdesignersupport/data/TestComponent.qml4
-rw-r--r--tests/auto/quick/qquickdesignersupport/data/test.qml4
-rw-r--r--tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp8
-rw-r--r--tests/auto/quick/qquickflickable/BLACKLIST15
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp83
-rw-r--r--tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp4
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp31
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp65
-rw-r--r--tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop.qml13
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp17
-rw-r--r--tests/auto/quick/qquicklistview/data/setpositiononlayout.qml (renamed from examples/quick/demos/stocqt/content/StockListView.qml)57
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml18
-rw-r--r--tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml63
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp117
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp4
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/mouse.qml9
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp53
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp8
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp2
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp16
-rw-r--r--tests/auto/quick/qquickrectangle/data/gradient-preset.qml16
-rw-r--r--tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp28
-rw-r--r--tests/auto/quick/qquickrepeater/data/ownership.qml4
-rw-r--r--tests/auto/quick/qquickrepeater/data/package.qml35
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp94
-rw-r--r--tests/auto/quick/qquickshape/qquickshape.pro24
-rw-r--r--tests/auto/quick/qquickshape/tst_qquickshape.cpp6
-rw-r--r--tests/auto/quick/qquicktableview/data/alternatingrowheightcolumnwidth.qml76
-rw-r--r--tests/auto/quick/qquicktableview/data/asyncloader.qml56
-rw-r--r--tests/auto/quick/qquicktableview/data/asyncplain.qml96
-rw-r--r--tests/auto/quick/qquicktableview/data/changemodelfromdelegate.qml97
-rw-r--r--tests/auto/quick/qquicktableview/data/changemodelordelegateduringupdate.qml81
-rw-r--r--tests/auto/quick/qquicktableview/data/checkrowandcolumnnotchanged.qml94
-rw-r--r--tests/auto/quick/qquicktableview/data/contentwidthheight.qml80
-rw-r--r--tests/auto/quick/qquicktableview/data/countingtableview.qml98
-rw-r--r--tests/auto/quick/qquicktableview/data/delegatewithanchors.qml65
-rw-r--r--tests/auto/quick/qquicktableview/data/forcelayout.qml76
-rw-r--r--tests/auto/quick/qquicktableview/data/plaintableview.qml86
-rw-r--r--tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml83
-rw-r--r--tests/auto/quick/qquicktableview/data/setcontentpos.qml69
-rw-r--r--tests/auto/quick/qquicktableview/data/tableviewdefaultspacing.qml61
-rw-r--r--tests/auto/quick/qquicktableview/data/tableviewfocus.qml77
-rw-r--r--tests/auto/quick/qquicktableview/data/tableviewimplicitsize.qml64
-rw-r--r--tests/auto/quick/qquicktableview/data/usechooserwithoutdefault.qml64
-rw-r--r--tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml78
-rw-r--r--tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml78
-rw-r--r--tests/auto/quick/qquicktableview/qquicktableview.pro14
-rw-r--r--tests/auto/quick/qquicktableview/testmodel.h154
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp1968
-rw-r--r--tests/auto/quick/qquicktext/data/implicitSizeChangeRewrap.qml27
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp47
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp5
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp2
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp51
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp13
-rw-r--r--tests/auto/quick/quick.pro4
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp8
-rw-r--r--tests/auto/quick/shared/viewtestutil.h3
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp114
-rw-r--r--tests/auto/quicktest/quicktest.pro3
-rw-r--r--tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.cpp29
-rw-r--r--tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.pro11
-rw-r--r--tests/auto/quicktest/testfiltering/quicktestmain/tst_first.qml38
-rw-r--r--tests/auto/quicktest/testfiltering/quicktestmain/tst_second.qml38
-rw-r--r--tests/auto/quicktest/testfiltering/test/test.pro5
-rw-r--r--tests/auto/quicktest/testfiltering/testfiltering.pro4
-rw-r--r--tests/auto/quicktest/testfiltering/tst_testfiltering.cpp135
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp4
-rw-r--r--tests/auto/toolsupport/tst_toolsupport.cpp2
-rw-r--r--tests/manual/mousearea/main.qml3
-rw-r--r--tests/manual/pointer/content/CheckBox.qml4
-rw-r--r--tests/manual/pointer/content/FakeFlickable.qml5
-rw-r--r--tests/manual/pointer/content/FlashAnimation.qml2
-rw-r--r--tests/manual/pointer/content/MomentumAnimation.qml2
-rw-r--r--tests/manual/pointer/content/MouseAreaButton.qml4
-rw-r--r--tests/manual/pointer/content/MouseAreaSlider.qml2
-rw-r--r--tests/manual/pointer/content/MouseFeedbackSprite.qml3
-rw-r--r--tests/manual/pointer/content/MptaButton.qml4
-rw-r--r--tests/manual/pointer/content/MultiButton.qml4
-rw-r--r--tests/manual/pointer/content/ScrollBar.qml3
-rw-r--r--tests/manual/pointer/content/Slider.qml3
-rw-r--r--tests/manual/pointer/content/TapHandlerButton.qml5
-rw-r--r--tests/manual/pointer/content/TextBox.qml3
-rw-r--r--tests/manual/pointer/content/TouchpointFeedbackSprite.qml3
-rw-r--r--tests/manual/pointer/fakeFlickable.qml3
-rw-r--r--tests/manual/pointer/flickableWithHandlers.qml3
-rw-r--r--tests/manual/pointer/flingAnimation.qml9
-rw-r--r--tests/manual/pointer/joystick.qml3
-rw-r--r--tests/manual/pointer/main.qml6
-rw-r--r--tests/manual/pointer/map.qml35
-rw-r--r--tests/manual/pointer/map2.qml3
-rw-r--r--tests/manual/pointer/mixer.qml3
-rw-r--r--tests/manual/pointer/multibuttons.qml6
-rw-r--r--tests/manual/pointer/photosurface.qml3
-rw-r--r--tests/manual/pointer/pinchDragFlingMPTA.qml5
-rw-r--r--tests/manual/pointer/pinchHandler.qml9
-rw-r--r--tests/manual/pointer/pointerDrag.qml3
-rw-r--r--tests/manual/pointer/qml.qrc1
-rw-r--r--tests/manual/pointer/sidebar.qml185
-rw-r--r--tests/manual/pointer/singlePointHandlerProperties.qml38
-rw-r--r--tests/manual/pointer/tapHandler.qml37
-rw-r--r--tests/manual/pointer/tapWithModifiers.qml3
-rw-r--r--tests/manual/qmlplugindump/qmlplugindump.pro2
-rw-r--r--tests/manual/qmlplugindump/tst_qmlplugindump.cpp11
-rw-r--r--tests/manual/tableview/abstracttablemodel/Button.qml60
-rw-r--r--tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro10
-rw-r--r--tests/manual/tableview/abstracttablemodel/main.cpp256
-rw-r--r--tests/manual/tableview/abstracttablemodel/main.qml136
-rw-r--r--tests/manual/tableview/listmodel/listmodel.pro10
-rw-r--r--tests/manual/tableview/listmodel/main.cpp52
-rw-r--r--tests/manual/tableview/listmodel/main.qml85
-rw-r--r--tests/manual/tableview/storagemodel/main.cpp56
-rw-r--r--tests/manual/tableview/storagemodel/main.qml74
-rw-r--r--tests/manual/tableview/storagemodel/storagemodel.cpp226
-rw-r--r--tests/manual/tableview/storagemodel/storagemodel.h (renamed from examples/quick/views/parallax/parallax.qml)69
-rw-r--r--tests/manual/tableview/storagemodel/storagemodel.pro11
-rw-r--r--tests/manual/tableview/tableview.pro4
-rw-r--r--tests/manual/touch/flicktext.qml8
-rw-r--r--tools/qml/main.cpp13
-rw-r--r--tools/qml/qml.pro2
-rw-r--r--tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in (renamed from tools/qmlcachegen/Qt5QuickCompilerConfig.cmake)37
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp163
-rw-r--r--tools/qmlcachegen/qmlcachegen.pro16
-rw-r--r--tools/qmlcachegen/qtquickcompiler.prf5
-rw-r--r--tools/qmlcachegen/resourcefilemapper.cpp2
-rw-r--r--tools/qmlcachegen/resourcefilter.cpp4
-rw-r--r--tools/qmljs/qmljs.cpp63
-rw-r--r--tools/qmlmin/main.cpp104
-rw-r--r--tools/qmlplugindump/main.cpp18
-rw-r--r--tools/qmlpreview/main.cpp36
-rw-r--r--tools/qmlpreview/qmlpreview.pro13
-rw-r--r--tools/qmlpreview/qmlpreviewapplication.cpp266
-rw-r--r--tools/qmlpreview/qmlpreviewapplication.h83
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp6
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.cpp4
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h2
-rw-r--r--tools/qmlscene/main.cpp12
-rw-r--r--tools/tools.pro24
1386 files changed, 68460 insertions, 50454 deletions
diff --git a/.gitmodules b/.gitmodules
index e6e5650150..e93f38f128 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
[submodule "tests/auto/qml/ecmascripttests/test262"]
path = tests/auto/qml/ecmascripttests/test262
url = ../qtdeclarative-testsuites.git
- branch = snapshot-20150317-8f6a508-based
+ branch = snapshot-20180312-3c69133-based
diff --git a/.qmake.conf b/.qmake.conf
index 56c0f31a82..81caa27c53 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.11.2
+MODULE_VERSION = 5.12.0
diff --git a/examples/quick/delegatechooser/delegatechooser.pro b/examples/quick/delegatechooser/delegatechooser.pro
new file mode 100644
index 0000000000..f06864ba89
--- /dev/null
+++ b/examples/quick/delegatechooser/delegatechooser.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+QT += quick qml
+
+SOURCES += main.cpp
+RESOURCES += qml.qrc ../shared/shared.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/delegatechooser
+INSTALLS += target
diff --git a/examples/quick/delegatechooser/delegatechooser.qml b/examples/quick/delegatechooser/delegatechooser.qml
new file mode 100644
index 0000000000..afb8518abf
--- /dev/null
+++ b/examples/quick/delegatechooser/delegatechooser.qml
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQml.Models 2.12
+import QtQuick.Layouts 1.12
+import Qt.labs.qmlmodels 1.0
+
+Rectangle {
+ visible: true
+ width: 640
+ height: 640
+
+ ListModel {
+ id: listModel
+ ListElement { dataType: "rect"; color: "green" }
+ ListElement { dataType: "image"; source: "../shared/images/qt-logo.png" }
+ ListElement { dataType: "rect"; color: "green" }
+ ListElement { dataType: "image"; source: "../shared/images/qt-logo.png" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ }
+
+ ListModel {
+ id: listModel2
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "green" }
+ ListElement { dataType: "image"; source: "../shared/images/qt-logo.png" }
+ ListElement { dataType: "rect"; color: "green" }
+ ListElement { dataType: "image"; source: "../shared/images/qt-logo.png" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "rect"; color: "lightsteelblue" }
+ ListElement { dataType: "rect"; color: "fuchsia" }
+ ListElement { dataType: "rect"; color: "lime" }
+ }
+
+ DelegateChooser {
+ id: fancyDelegate
+ role: "dataType"
+ DelegateChoice {
+ roleValue: "rect"
+ delegate: DelegateChooser {
+ DelegateChoice {
+ row: 0
+ Rectangle {
+ width: parent.width
+ height: 50
+ color: "red"
+ border.color: "black"
+ border.width: 1
+ }
+ }
+ DelegateChoice {
+ Rectangle {
+ width: parent.width
+ height: 50
+ color: model.color
+ border.color: "black"
+ border.width: 1
+ }
+ }
+ }
+ }
+ DelegateChoice {
+ roleValue: "image"
+ delegate: Image {
+ width: parent.width
+ height: 100
+ source: model.source
+ fillMode: Image.PreserveAspectFit
+ }
+ }
+ }
+
+ Item {
+ anchors.fill: parent
+ id: ite
+ RowLayout {
+ ListView {
+ Layout.preferredHeight: ite.height
+ Layout.preferredWidth: ite.width * 0.5
+ model: listModel
+ delegate: fancyDelegate
+ }
+ ListView {
+ Layout.preferredHeight: ite.height
+ Layout.preferredWidth: ite.width * 0.5
+ model: listModel2
+ delegate: fancyDelegate
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/maroon/main.cpp b/examples/quick/delegatechooser/main.cpp
index f6590fc32e..5df9207e24 100644
--- a/examples/quick/demos/maroon/main.cpp
+++ b/examples/quick/delegatechooser/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -47,5 +47,5 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/maroon/maroon)
+#include "../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(delegatechooser)
diff --git a/examples/quick/delegatechooser/qml.qrc b/examples/quick/delegatechooser/qml.qrc
new file mode 100644
index 0000000000..0788f84c64
--- /dev/null
+++ b/examples/quick/delegatechooser/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>delegatechooser.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/demos/calqlatr/calqlatr.pro b/examples/quick/demos/calqlatr/calqlatr.pro
deleted file mode 100644
index 20543c08da..0000000000
--- a/examples/quick/demos/calqlatr/calqlatr.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-SOURCES += main.cpp
-
-RESOURCES += calqlatr.qrc \
- ../../shared/shared.qrc
-
-OTHER_FILES = calqlatr.qml \
- content/Button.qml \
- content/Display.qml \
- content/NumberPad.qml \
- content/calculator.js \
- content/images/paper-edge-left.png \
- content/images/paper-edge-right.png \
- content/images/paper-grip.png
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/calqlatr
-INSTALLS += target
diff --git a/examples/quick/demos/calqlatr/calqlatr.qml b/examples/quick/demos/calqlatr/calqlatr.qml
deleted file mode 100644
index 769513b7bd..0000000000
--- a/examples/quick/demos/calqlatr/calqlatr.qml
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content"
-import "content/calculator.js" as CalcEngine
-
-
-Rectangle {
- id: window
- width: 320
- height: 480
- focus: true
- color: "#272822"
-
- onWidthChanged: controller.reload()
- onHeightChanged: controller.reload()
-
- function operatorPressed(operator) {
- CalcEngine.operatorPressed(operator)
- numPad.buttonPressed()
- }
- function digitPressed(digit) {
- CalcEngine.digitPressed(digit)
- numPad.buttonPressed()
- }
- function isButtonDisabled(op) {
- return CalcEngine.disabled(op)
- }
-
- Item {
- id: pad
- width: 180
- NumberPad { id: numPad; y: 10; anchors.horizontalCenter: parent.horizontalCenter }
- }
-
- AnimationController {
- id: controller
- animation: ParallelAnimation {
- id: anim
- NumberAnimation { target: display; property: "x"; duration: 400; from: -16; to: window.width - display.width; easing.type: Easing.InOutQuad }
- NumberAnimation { target: pad; property: "x"; duration: 400; from: window.width - pad.width; to: 0; easing.type: Easing.InOutQuad }
- SequentialAnimation {
- NumberAnimation { target: pad; property: "scale"; duration: 200; from: 1; to: 0.97; easing.type: Easing.InOutQuad }
- NumberAnimation { target: pad; property: "scale"; duration: 200; from: 0.97; to: 1; easing.type: Easing.InOutQuad }
- }
- }
- }
-
- Keys.onPressed: {
- if (event.key == Qt.Key_0)
- digitPressed("0")
- else if (event.key == Qt.Key_1)
- digitPressed("1")
- else if (event.key == Qt.Key_2)
- digitPressed("2")
- else if (event.key == Qt.Key_3)
- digitPressed("3")
- else if (event.key == Qt.Key_4)
- digitPressed("4")
- else if (event.key == Qt.Key_5)
- digitPressed("5")
- else if (event.key == Qt.Key_6)
- digitPressed("6")
- else if (event.key == Qt.Key_7)
- digitPressed("7")
- else if (event.key == Qt.Key_8)
- digitPressed("8")
- else if (event.key == Qt.Key_9)
- digitPressed("9")
- else if (event.key == Qt.Key_Plus)
- operatorPressed("+")
- else if (event.key == Qt.Key_Minus)
- operatorPressed("−")
- else if (event.key == Qt.Key_Asterisk)
- operatorPressed("×")
- else if (event.key == Qt.Key_Slash)
- operatorPressed("÷")
- else if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)
- operatorPressed("=")
- else if (event.key == Qt.Key_Comma || event.key == Qt.Key_Period)
- digitPressed(".")
- else if (event.key == Qt.Key_Backspace)
- operatorPressed("backspace")
- }
-
- Display {
- id: display
- x: -16
- width: window.width - pad.width
- height: parent.height
-
- MouseArea {
- id: mouseInput
- property real startX: 0
- property real oldP: 0
- property bool rewind: false
-
- anchors {
- bottom: parent.bottom
- left: parent.left
- right: parent.right
- }
- height: 50
- onPositionChanged: {
- var reverse = startX > window.width / 2
- var mx = mapToItem(window, mouseInput.mouseX, mouseInput.mouseY).x
- var p = Math.abs((mx - startX) / (window.width - display.width))
- if (p < oldP)
- rewind = reverse ? false : true
- else
- rewind = reverse ? true : false
- controller.progress = reverse ? 1 - p : p
- oldP = p
- }
- onPressed: startX = mapToItem(window, mouseInput.mouseX, mouseInput.mouseY).x
- onReleased: {
- if (rewind)
- controller.completeToBeginning()
- else
- controller.completeToEnd()
- }
- }
- }
-
-}
diff --git a/examples/quick/demos/calqlatr/calqlatr.qmlproject b/examples/quick/demos/calqlatr/calqlatr.qmlproject
deleted file mode 100644
index ce2d59d310..0000000000
--- a/examples/quick/demos/calqlatr/calqlatr.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "calqlatr.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/calqlatr/calqlatr.qrc b/examples/quick/demos/calqlatr/calqlatr.qrc
deleted file mode 100644
index 7483304e02..0000000000
--- a/examples/quick/demos/calqlatr/calqlatr.qrc
+++ /dev/null
@@ -1,12 +0,0 @@
-<RCC>
- <qresource prefix="/demos/calqlatr">
- <file>calqlatr.qml</file>
- <file>content/Button.qml</file>
- <file>content/calculator.js</file>
- <file>content/Display.qml</file>
- <file>content/NumberPad.qml</file>
- <file>content/images/paper-edge-left.png</file>
- <file>content/images/paper-edge-right.png</file>
- <file>content/images/paper-grip.png</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/calqlatr/content/Button.qml b/examples/quick/demos/calqlatr/content/Button.qml
deleted file mode 100644
index 5279596ef1..0000000000
--- a/examples/quick/demos/calqlatr/content/Button.qml
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: button
- property alias text: textItem.text
- property color color: "#eceeea"
-
- property bool operator: false
- property bool dimmable: false
- property bool dimmed: false
-
- width: 30
- height: 50
-
- Text {
- id: textItem
- font.pixelSize: 48
- wrapMode: Text.WordWrap
- lineHeight: 0.75
- color: (dimmable && dimmed) ? Qt.darker(button.color) : button.color
- Behavior on color { ColorAnimation { duration: 120; easing.type: Easing.OutElastic} }
- states: [
- State {
- name: "pressed"
- when: mouse.pressed && !dimmed
- PropertyChanges {
- target: textItem
- color: Qt.lighter(button.color)
- }
- }
- ]
- }
-
- MouseArea {
- id: mouse
- anchors.fill: parent
- anchors.margins: -5
- onClicked: {
- if (operator)
- window.operatorPressed(parent.text)
- else
- window.digitPressed(parent.text)
- }
- }
-
- function updateDimmed() {
- dimmed = window.isButtonDisabled(button.text)
- }
-
- Component.onCompleted: {
- numPad.buttonPressed.connect(updateDimmed)
- updateDimmed()
- }
-}
diff --git a/examples/quick/demos/calqlatr/content/Display.qml b/examples/quick/demos/calqlatr/content/Display.qml
deleted file mode 100644
index 9ddd64d251..0000000000
--- a/examples/quick/demos/calqlatr/content/Display.qml
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-
-Item {
- id: display
- property real fontSize: Math.floor(Screen.pixelDensity * 5.0)
- property bool enteringDigits: false
- property int maxDigits: (width / fontSize) + 1
- property string displayedOperand
- property string errorString: qsTr("ERROR")
- property bool isError: displayedOperand === errorString
-
- function displayOperator(operator)
- {
- listView.model.append({ "operator": operator, "operand": "" })
- enteringDigits = true
- listView.positionViewAtEnd()
- }
-
- function newLine(operator, operand)
- {
- displayedOperand = displayNumber(operand)
- listView.model.append({ "operator": operator, "operand": displayedOperand })
- enteringDigits = false
- listView.positionViewAtEnd()
- }
-
- function appendDigit(digit)
- {
- if (!enteringDigits)
- listView.model.append({ "operator": "", "operand": "" })
- var i = listView.model.count - 1;
- listView.model.get(i).operand = listView.model.get(i).operand + digit;
- enteringDigits = true
- listView.positionViewAtEnd()
- }
-
- function setDigit(digit)
- {
- var i = listView.model.count - 1;
- listView.model.get(i).operand = digit;
- listView.positionViewAtEnd()
- }
-
- function clear()
- {
- displayedOperand = ""
- if (enteringDigits) {
- var i = listView.model.count - 1
- if (i >= 0)
- listView.model.remove(i)
- enteringDigits = false
- }
- }
-
- // Returns a string representation of a number that fits in
- // display.maxDigits characters, trying to keep as much precision
- // as possible. If the number cannot be displayed, returns an
- // error string.
- function displayNumber(num) {
- if (typeof(num) != "number")
- return errorString;
-
- var intNum = parseInt(num);
- var intLen = intNum.toString().length;
-
- // Do not count the minus sign as a digit
- var maxLen = num < 0 ? maxDigits + 1 : maxDigits;
-
- if (num.toString().length <= maxLen) {
- if (isFinite(num))
- return num.toString();
- return errorString;
- }
-
- // Integer part of the number is too long - try
- // an exponential notation
- if (intNum == num || intLen > maxLen - 3) {
- var expVal = num.toExponential(maxDigits - 6).toString();
- if (expVal.length <= maxLen)
- return expVal;
- }
-
- // Try a float presentation with fixed number of digits
- var floatStr = parseFloat(num).toFixed(maxDigits - intLen - 1).toString();
- if (floatStr.length <= maxLen)
- return floatStr;
-
- return errorString;
- }
-
- Item {
- id: theItem
- width: parent.width + 32
- height: parent.height
-
- Rectangle {
- id: rect
- x: 16
- color: "white"
- height: parent.height
- width: display.width - 16
- }
- Image {
- anchors.right: rect.left
- source: "images/paper-edge-left.png"
- height: parent.height
- fillMode: Image.TileVertically
- }
- Image {
- anchors.left: rect.right
- source: "images/paper-edge-right.png"
- height: parent.height
- fillMode: Image.TileVertically
- }
-
- Image {
- id: grip
- source: "images/paper-grip.png"
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 20
- }
-
- ListView {
- id: listView
- x: 16; y: 30
- width: display.width
- height: display.height - 50 - y
- delegate: Item {
- height: display.fontSize * 1.1
- width: parent.width
- Text {
- id: operator
- x: 6
- font.pixelSize: display.fontSize
- color: "#6da43d"
- text: model.operator
- }
- Text {
- id: operand
- font.pixelSize: display.fontSize
- anchors.right: parent.right
- anchors.rightMargin: 22
- text: model.operand
- }
- }
- model: ListModel { }
- }
-
- }
-
-}
diff --git a/examples/quick/demos/calqlatr/content/NumberPad.qml b/examples/quick/demos/calqlatr/content/NumberPad.qml
deleted file mode 100644
index 9936116fa1..0000000000
--- a/examples/quick/demos/calqlatr/content/NumberPad.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Grid {
- columns: 3
- columnSpacing: 32
- rowSpacing: 16
-
- signal buttonPressed
-
- Button { text: "7" }
- Button { text: "8" }
- Button { text: "9" }
- Button { text: "4" }
- Button { text: "5" }
- Button { text: "6" }
- Button { text: "1" }
- Button { text: "2" }
- Button { text: "3" }
- Button { text: "0" }
- Button { text: "."; dimmable: true }
- Button { text: " " }
- Button { text: "±"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "−"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "+"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "√"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "÷"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "×"; color: "#6da43d"; operator: true; dimmable: true }
- Button { text: "C"; color: "#6da43d"; operator: true }
- Button { text: " "; color: "#6da43d"; operator: true }
- Button { text: "="; color: "#6da43d"; operator: true; dimmable: true }
-}
diff --git a/examples/quick/demos/calqlatr/content/calculator.js b/examples/quick/demos/calqlatr/content/calculator.js
deleted file mode 100644
index 37eb752191..0000000000
--- a/examples/quick/demos/calqlatr/content/calculator.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-var curVal = 0
-var memory = 0
-var lastOp = ""
-var previousOperator = ""
-var digits = ""
-
-function disabled(op) {
- if (digits == "" && !((op >= "0" && op <= "9") || op == "."))
- return true
- else if (op == '=' && previousOperator.length != 1)
- return true
- else if (op == "." && digits.toString().search(/\./) != -1) {
- return true
- } else if (op == "√" && digits.toString().search(/-/) != -1) {
- return true
- } else {
- return false
- }
-}
-
-function digitPressed(op)
-{
- if (disabled(op))
- return
- if (digits.toString().length >= display.maxDigits)
- return
- if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
- digits = digits + op.toString()
- display.appendDigit(op.toString())
- } else {
- digits = op
- display.appendDigit(op.toString())
- }
- lastOp = op
-}
-
-function operatorPressed(op)
-{
- if (disabled(op))
- return
- lastOp = op
-
- if (op == "±") {
- digits = Number(digits.valueOf() * -1)
- display.setDigit(display.displayNumber(digits))
- return
- }
-
- if (previousOperator == "+") {
- digits = Number(digits.valueOf()) + Number(curVal.valueOf())
- } else if (previousOperator == "−") {
- digits = Number(curVal.valueOf()) - Number(digits.valueOf())
- } else if (previousOperator == "×") {
- digits = Number(curVal) * Number(digits.valueOf())
- } else if (previousOperator == "÷") {
- digits = Number(curVal) / Number(digits.valueOf())
- }
-
- if (op == "+" || op == "−" || op == "×" || op == "÷") {
- previousOperator = op
- curVal = digits.valueOf()
- digits = ""
- display.displayOperator(previousOperator)
- return
- }
-
- if (op == "=") {
- display.newLine("=", digits.valueOf())
- }
-
- curVal = 0
- previousOperator = ""
-
- if (op == "1/x") {
- digits = (1 / digits.valueOf()).toString()
- } else if (op == "x^2") {
- digits = (digits.valueOf() * digits.valueOf()).toString()
- } else if (op == "Abs") {
- digits = (Math.abs(digits.valueOf())).toString()
- } else if (op == "Int") {
- digits = (Math.floor(digits.valueOf())).toString()
- } else if (op == "√") {
- digits = Number(Math.sqrt(digits.valueOf()))
- display.newLine("√", digits.valueOf())
- } else if (op == "mc") {
- memory = 0;
- } else if (op == "m+") {
- memory += digits.valueOf()
- } else if (op == "mr") {
- digits = memory.toString()
- } else if (op == "m-") {
- memory = digits.valueOf()
- } else if (op == "backspace") {
- digits = digits.toString().slice(0, -1)
- display.clear()
- display.appendDigit(digits)
- } else if (op == "Off") {
- Qt.quit();
- }
-
- // Reset the state on 'C' operator or after
- // an error occurred
- if (op == "C" || display.isError) {
- display.clear()
- curVal = 0
- memory = 0
- lastOp = ""
- digits = ""
- }
-}
-
diff --git a/examples/quick/demos/calqlatr/content/images/paper-edge-left.png b/examples/quick/demos/calqlatr/content/images/paper-edge-left.png
deleted file mode 100644
index ca29a3ae10..0000000000
--- a/examples/quick/demos/calqlatr/content/images/paper-edge-left.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/paper-edge-right.png b/examples/quick/demos/calqlatr/content/images/paper-edge-right.png
deleted file mode 100644
index 7c2da7b930..0000000000
--- a/examples/quick/demos/calqlatr/content/images/paper-edge-right.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/paper-grip.png b/examples/quick/demos/calqlatr/content/images/paper-grip.png
deleted file mode 100644
index 953c408bca..0000000000
--- a/examples/quick/demos/calqlatr/content/images/paper-grip.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png b/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png
deleted file mode 100644
index af67f63dd1..0000000000
--- a/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc
deleted file mode 100644
index 02503fe3b9..0000000000
--- a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Calqlatr
- \ingroup qtquickdemos
- \example demos/calqlatr
- \brief A QML app designed for portrait devices that uses custom components,
- animated with AnimationController, and JavaScript for the application logic.
- \image qtquick-demo-calqlatr.png
-
- \e{Calqlatr} demonstrates various QML and \l{Qt Quick} features, such as
- displaying custom components and using animation to move the components
- around in the application view. The application logic is implemented in
- JavaScript and the appearance is implemented in QML.
-
- \include examples-run.qdocinc
-
- \section1 Displaying Custom Components
-
- In the Calqlatr application, we use the following custom types that are
- each defined in a separate .qml file:
-
- \list
- \li Button.qml
- \li Display.qml
- \li NumberPad.qml
- \endlist
-
- To use the custom types, we add an import statement to the main QML file,
- calqlatr.qml that imports the folder called \c content where the types are
- located:
-
- \code
- import "content"
- \endcode
-
- We can then display custom components by adding the component types to
- any QML file. For example, we use the NumberPad type in calqlatr.qml to
- create the number pad of the calculator. We place the type inside an
- \l{Item} QML type, which is the base type for all visual items in Qt Quick:
-
- \quotefromfile demos/calqlatr/calqlatr.qml
- \skipto Item
- \printuntil }
- \printuntil }
-
- Further, we use the Button type in the \c NumberPad type to create the
- calculator buttons. Button.qml specifies the basic properties for a
- button that we can modify for each button instance in NumberPad.qml. For the
- digit and separator buttons, we additionally specify the text property using
- the property alias \c text that we define in Button.qml.
-
- For the operator buttons, we also specify another color (green) using the
- property alias \c color and set the operator property to \c true. We use
- the operator property in functions that perform the calculations.
-
- We place the buttons inside a \l{Grid} QML type to position them in a grid:
-
- \quotefromfile demos/calqlatr/content/NumberPad.qml
- \skipto Grid
- \printuntil /^\}/
-
- Some of the buttons also have a \c dimmable property set, meaning that they
- can be visually disabled (dimmed) whenever the calculator engine does not
- accept input from that button. As an example, the button for square root
- operator is dimmed for negative values.
-
- \section1 Animating Components
-
- We use the Display type to display calculations. In Display.qml, we use
- images to make the display component look like a slip of paper that contains
- a grip. Users can drag the grip to move the display from left to right.
-
- When users release the grip, the AnimationController QML type that we define
- in the calqlatr.qml file finishes running the controlled animation in either
- a forwards or a backwards direction. To run the animation, we call either
- completeToEnd() or completeToBeginning(), depending on the direction. We do
- this in the MouseArea's \c onReleased signal handler, where \c controller
- is the id of our AnimationController:
-
- \quotefromfile demos/calqlatr/calqlatr.qml
- \skipto MouseArea
- \printuntil {
- \dots 12
- \skipto onReleased
- \printuntil }
- \printuntil }
-
- Unlike other QML animation types, AnimationController is not driven by
- internal timers but by explicitly setting its progress property to a
- value between \c 0.0 and \c 1.0.
-
- Inside the AnimationController, we run two NumberAnimation instances in
- parallel to move the number pad and the display components simultaneously to
- the opposite sides of the view. In addition, we run a SequentialAnimation
- instance to scale the number pad during the transition, giving the animation
- some depth.
-
- \quotefromfile demos/calqlatr/calqlatr.qml
- \skipto AnimationController
- \printuntil 1; easing.type
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use the easing curve of the type \c Easing.InOutQuad to accelerate the
- motion until halfway and then decelerate it.
-
- In Button.qml, the text colors of the number pad buttons are also animated.
-
- \quotefromfile demos/calqlatr/content/Button.qml
- \skipto Text
- \printuntil id:
- \dots 8
- \skipto color:
- \printuntil ]
- \printuntil }
-
- We use \l {QtQml::Qt::darker()}{Qt.darker()} to darken the color when the
- button is dimmed, and \l {QtQml::Qt::lighter()}{Qt.lighter()} to \e {light up}
- the button when pressed. The latter is done in a separate \l [QML] {State}
- {state} called \e "pressed", which activates when the \c pressed
- property of the button's MouseArea is set.
-
- The color changes are animated by defining a \l Behavior on the \c color
- property.
-
- In order to dynamically change the \c dimmed property of all the buttons
- of the \c NumberPad, we connect its \c buttonPressed signal to the
- \c Button's \c updateDimmed() function in Button.qml:
-
- \quotefromfile demos/calqlatr/content/Button.qml
- \skipto function updateDimmed() {
- \printuntil buttonPressed.connect
- \printuntil }
-
- This way, when a button is pressed, all buttons on the \c NumPad
- receive a \c buttonPressed signal and are activated or deactivated
- according to the state of the calculator engine.
-
- \section1 Performing Calculations
-
- The calculator.js file defines our calculator engine. It contains variables
- to store the calculator state, and functions that are called when the
- user presses the digit and operator buttons. To use the engine, we
- import calculator.js in the calqlatr.qml file as \c CalcEngine:
-
- \code
- import "content/calculator.js" as CalcEngine
- \endcode
-
- Importing the engine creates a new instance of it. Therefore, we only do it
- in the main QML file, \c calqlatr.qml. The root item defined in this file
- contains helper functions that allow other types to access the calculator
- engine:
-
- \quotefromfile demos/calqlatr/calqlatr.qml
- \skipto operatorPressed
- \printuntil CalcEngine.disabled
- \printuntil }
-
- When users press a digit, the text from the digit appears on the
- display. When they press an operator, the appropriate calculation is
- performed, and the result can be displayed using the equals (=) operator.
- The clear (C) operator resets the calculator engine.
-
- \section1 List of Files
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/calqlatr/main.cpp b/examples/quick/demos/calqlatr/main.cpp
deleted file mode 100644
index bc6e591e98..0000000000
--- a/examples/quick/demos/calqlatr/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/calqlatr/calqlatr)
diff --git a/examples/quick/demos/clocks/clocks.pro b/examples/quick/demos/clocks/clocks.pro
deleted file mode 100644
index 21d3f7f971..0000000000
--- a/examples/quick/demos/clocks/clocks.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-
-SOURCES += main.cpp
-RESOURCES += clocks.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/clocks
-INSTALLS += target
-
-OTHER_FILES += \
- clocks.qml \
- content/Clock.qml \
- content/*.png
diff --git a/examples/quick/demos/clocks/clocks.qml b/examples/quick/demos/clocks/clocks.qml
deleted file mode 100644
index 5224e29a38..0000000000
--- a/examples/quick/demos/clocks/clocks.qml
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content" as Content
-
-Rectangle {
- id: root
- width: 640; height: 320
- color: "#646464"
-
- ListView {
- id: clockview
- anchors.fill: parent
- orientation: ListView.Horizontal
- cacheBuffer: 2000
- snapMode: ListView.SnapOneItem
- highlightRangeMode: ListView.ApplyRange
-
- delegate: Content.Clock { city: cityName; shift: timeShift }
- model: ListModel {
- ListElement { cityName: "New York"; timeShift: -4 }
- ListElement { cityName: "London"; timeShift: 0 }
- ListElement { cityName: "Oslo"; timeShift: 1 }
- ListElement { cityName: "Mumbai"; timeShift: 5.5 }
- ListElement { cityName: "Tokyo"; timeShift: 9 }
- ListElement { cityName: "Brisbane"; timeShift: 10 }
- ListElement { cityName: "Los Angeles"; timeShift: -8 }
- }
- }
-
- Image {
- anchors.left: parent.left
- anchors.bottom: parent.bottom
- anchors.margins: 10
- source: "content/arrow.png"
- rotation: -90
- opacity: clockview.atXBeginning ? 0 : 0.5
- Behavior on opacity { NumberAnimation { duration: 500 } }
- }
-
- Image {
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.margins: 10
- source: "content/arrow.png"
- rotation: 90
- opacity: clockview.atXEnd ? 0 : 0.5
- Behavior on opacity { NumberAnimation { duration: 500 } }
- }
-}
diff --git a/examples/quick/demos/clocks/clocks.qmlproject b/examples/quick/demos/clocks/clocks.qmlproject
deleted file mode 100644
index b15654600e..0000000000
--- a/examples/quick/demos/clocks/clocks.qmlproject
+++ /dev/null
@@ -1,8 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "clocks.qml"
- QmlFiles { directory: "." }
- JavaScriptFiles { directory: "." }
- ImageFiles { directory: "." }
-}
diff --git a/examples/quick/demos/clocks/clocks.qrc b/examples/quick/demos/clocks/clocks.qrc
deleted file mode 100644
index eaff4729ae..0000000000
--- a/examples/quick/demos/clocks/clocks.qrc
+++ /dev/null
@@ -1,15 +0,0 @@
-<RCC>
- <qresource prefix="/demos/clocks">
- <file>clocks.qml</file>
- <file>content/arrow.png</file>
- <file>content/background.png</file>
- <file>content/center.png</file>
- <file>content/clock-night.png</file>
- <file>content/clock.png</file>
- <file>content/Clock.qml</file>
- <file>content/hour.png</file>
- <file>content/minute.png</file>
- <file>content/quit.png</file>
- <file>content/second.png</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/clocks/content/Clock.qml b/examples/quick/demos/clocks/content/Clock.qml
deleted file mode 100644
index 542333d13d..0000000000
--- a/examples/quick/demos/clocks/content/Clock.qml
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id : clock
- width: {
- if (ListView.view && ListView.view.width >= 200)
- return ListView.view.width / Math.floor(ListView.view.width / 200.0);
- else
- return 200;
- }
-
- height: {
- if (ListView.view && ListView.view.height >= 240)
- return ListView.view.height;
- else
- return 240;
- }
-
- property alias city: cityLabel.text
- property int hours
- property int minutes
- property int seconds
- property real shift
- property bool night: false
- property bool internationalTime: true //Unset for local time
-
- function timeChanged() {
- var date = new Date;
- hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
- night = ( hours < 7 || hours > 19 )
- minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
- seconds = date.getUTCSeconds();
- }
-
- Timer {
- interval: 100; running: true; repeat: true;
- onTriggered: clock.timeChanged()
- }
-
- Item {
- anchors.centerIn: parent
- width: 200; height: 240
-
- Image { id: background; source: "clock.png"; visible: clock.night == false }
- Image { source: "clock-night.png"; visible: clock.night == true }
-
-
- Image {
- x: 92.5; y: 27
- source: "hour.png"
- transform: Rotation {
- id: hourRotation
- origin.x: 7.5; origin.y: 73;
- angle: (clock.hours * 30) + (clock.minutes * 0.5)
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- x: 93.5; y: 17
- source: "minute.png"
- transform: Rotation {
- id: minuteRotation
- origin.x: 6.5; origin.y: 83;
- angle: clock.minutes * 6
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- x: 97.5; y: 20
- source: "second.png"
- transform: Rotation {
- id: secondRotation
- origin.x: 2.5; origin.y: 80;
- angle: clock.seconds * 6
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- anchors.centerIn: background; source: "center.png"
- }
-
- Text {
- id: cityLabel
- y: 210; anchors.horizontalCenter: parent.horizontalCenter
- color: "white"
- font.family: "Helvetica"
- font.bold: true; font.pixelSize: 16
- style: Text.Raised; styleColor: "black"
- }
- }
-}
diff --git a/examples/quick/demos/clocks/content/arrow.png b/examples/quick/demos/clocks/content/arrow.png
deleted file mode 100644
index e437312217..0000000000
--- a/examples/quick/demos/clocks/content/arrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/background.png b/examples/quick/demos/clocks/content/background.png
deleted file mode 100644
index a885950862..0000000000
--- a/examples/quick/demos/clocks/content/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/center.png b/examples/quick/demos/clocks/content/center.png
deleted file mode 100644
index 7fbd802a44..0000000000
--- a/examples/quick/demos/clocks/content/center.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/clock-night.png b/examples/quick/demos/clocks/content/clock-night.png
deleted file mode 100644
index cc7151a397..0000000000
--- a/examples/quick/demos/clocks/content/clock-night.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/clock.png b/examples/quick/demos/clocks/content/clock.png
deleted file mode 100644
index 462edacc0e..0000000000
--- a/examples/quick/demos/clocks/content/clock.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/hour.png b/examples/quick/demos/clocks/content/hour.png
deleted file mode 100644
index 9f33fc5d48..0000000000
--- a/examples/quick/demos/clocks/content/hour.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/minute.png b/examples/quick/demos/clocks/content/minute.png
deleted file mode 100644
index e2f216c897..0000000000
--- a/examples/quick/demos/clocks/content/minute.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/quit.png b/examples/quick/demos/clocks/content/quit.png
deleted file mode 100644
index b822057d4e..0000000000
--- a/examples/quick/demos/clocks/content/quit.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/content/second.png b/examples/quick/demos/clocks/content/second.png
deleted file mode 100644
index d95d99e83d..0000000000
--- a/examples/quick/demos/clocks/content/second.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png b/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png
deleted file mode 100644
index 7269e8780d..0000000000
--- a/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/clocks/doc/src/clocks.qdoc b/examples/quick/demos/clocks/doc/src/clocks.qdoc
deleted file mode 100644
index a4bf1a1f82..0000000000
--- a/examples/quick/demos/clocks/doc/src/clocks.qdoc
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Clocks
- \ingroup qtquickdemos
- \example demos/clocks
- \brief A QML clock application that demonstrates using a ListView type to
- display data generated by a ListModel and a SpringAnimation type to animate
- images.
- \image qtquick-demo-clocks-small.png
-
- \e Clocks demonstrates using a ListView type to display data generated by a
- ListModel. The delegate used by the model is specified as a custom QML type
- that is specified in the Clock.qml file.
-
- JavaScript methods are used to fetch the current time in several cities in
- different time zones and QML types are used to display the time on a clock
- face with animated clock hands.
-
- \include examples-run.qdocinc
-
- \section1 Displaying Data Generated by List Models
-
- In the clocks.qml file, we use a \l Rectangle type to create the application
- main window:
-
- \quotefromfile demos/clocks/clocks.qml
- \skipto Rectangle
- \printuntil color
-
- We use a ListView type to display a list of the items provided by a
- ListModel type:
-
- \printuntil Los Angeles
- \printuntil }
- \printuntil }
-
- List elements are defined like other QML types except that they contain a
- collection of \e role definitions instead of properties. Roles both define
- how the data is accessed and include the data itself.
-
- For each list element, we use the \c cityName role to specify the name of a
- city and the \c timeShift role to specify a time zone as a positive or
- negative offset from UTC (coordinated universal time).
-
- The Clock custom type is used as the ListView's \c delegate, defining the
- visual appearance of list items. To use the Clock type, we add an import
- statement that imports the folder called \c content where the type is
- located:
-
- \quotefromfile demos/clocks/clocks.qml
- \skipto content
- \printuntil "
-
- We use an \l Image type to display arrows that indicate whether users can
- flick the view to see more clocks on the left or right:
-
- \quotefromfile demos/clocks/clocks.qml
- \skipto Image
- \printuntil /^\}/
-
- We use the \c opacity property to hide the arrows when the list view is
- located at the beginning or end of the x axis.
-
- In Clock.qml, we define a \c timeChanged() function in which we use
- methods from the JavaScript \c Date object to fetch the current time in
- UTC and to adjust it to the correct time zone:
-
- \quotefromfile demos/clocks/content/Clock.qml
- \skipto timeChanged
- \printuntil }
-
- We use a \l Timer type to update the time at intervals of 100 milliseconds:
-
- \printuntil }
-
- We use \l Image types within an \l Item type to display the time on an
- analog clock face. Different images are used for daytime and nighttime
- hours:
-
- \printuntil clock-night.png
-
- A \l Rotation transform applied to \l Image types provides a way to rotate
- the clock hands. The \c origin property holds the point that stays fixed
- relative to the parent as the rest of the item rotates. The \c angle
- property determines the angle to rotate the hands in degrees clockwise.
-
- \printuntil center.png
- \printuntil }
-
- We use a \l Behavior type on the \c angle property to apply a
- SpringAnimation when the time changes. The \c spring and \c damping
- properties enable the spring-like motion of the clock hands, and a
- \c modulus of \c 360 makes the animation target values wrap around at a
- full circle.
-
- We use a \l Text type to display the city name below the clock:
-
- \printuntil }
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/clocks/main.cpp b/examples/quick/demos/clocks/main.cpp
deleted file mode 100644
index 5d5b0ca64d..0000000000
--- a/examples/quick/demos/clocks/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/clocks/clocks)
diff --git a/examples/quick/demos/demos.pro b/examples/quick/demos/demos.pro
deleted file mode 100644
index 0644b81a22..0000000000
--- a/examples/quick/demos/demos.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = samegame \
- calqlatr \
- clocks \
- tweetsearch \
- maroon \
- photosurface \
- stocqt
-
-qtHaveModule(xmlpatterns): SUBDIRS += rssnews photoviewer
-
diff --git a/examples/quick/demos/maroon/content/BuildButton.qml b/examples/quick/demos/maroon/content/BuildButton.qml
deleted file mode 100644
index 09d37746f1..0000000000
--- a/examples/quick/demos/maroon/content/BuildButton.qml
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "logic.js" as Logic
-
-Item {
- id: container
- width: 64
- height: 64
- property alias source: img.source
- property int index
- property int row: 0
- property int col: 0
- property int towerType
- property bool canBuild: true
- property Item gameCanvas: parent.parent.parent
- signal clicked()
-
- Image {
- id: img
- opacity: (canBuild && gameCanvas.coins >= Logic.towerData[towerType-1].cost) ? 1.0 : 0.4
- }
- Text {
- anchors.right: parent.right
- font.pointSize: 14
- font.bold: true
- color: "#ffffff"
- text: Logic.towerData[towerType - 1].cost
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- Logic.buildTower(towerType, col, row)
- container.clicked()
- }
- }
- Image {
- visible: col == index && row != 0
- source: "gfx/dialog-pointer.png"
- anchors.top: parent.bottom
- anchors.topMargin: 4
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Image {
- visible: col == index && row == 0
- source: "gfx/dialog-pointer.png"
- rotation: 180
- anchors.bottom: parent.top
- anchors.bottomMargin: 6
- anchors.horizontalCenter: parent.horizontalCenter
- }
-}
diff --git a/examples/quick/demos/maroon/content/GameCanvas.qml b/examples/quick/demos/maroon/content/GameCanvas.qml
deleted file mode 100644
index 0c6772dc98..0000000000
--- a/examples/quick/demos/maroon/content/GameCanvas.qml
+++ /dev/null
@@ -1,250 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "logic.js" as Logic
-import "towers" as Towers
-
-Item {
- id: grid
-
- property int squareSize: 64
- property int rows: 6
- property int cols: 4
- property Item canvas: grid
- property int score: 0
- property int coins: 100
- property int lives: 3
- property int waveNumber: 0
- property int waveProgress: 0
- property var towers
- property var mobs
- property bool gameRunning: false
- property bool gameOver: false
- property bool errored: false
- property string errorString: ""
-
- width: cols * squareSize
- height: rows * squareSize
-
- function freshState() {
- lives = 3
- coins = 100
- score = 0
- waveNumber = 0
- waveProgress = 0
- gameOver = false
- gameRunning = false
- towerMenu.shown = false
- helpButton.comeBack();
- }
-
- Text {
- id: errorText // Mostly for debug purposes
- text: errorString
- visible: errored
- color: "red"
- font.pixelSize: 18
- wrapMode: Text.WordWrap
- width: parent.width / 1.2
- height: parent.height / 1.2
- anchors.centerIn: parent
- z: 1000
- }
-
- Timer {
- interval: 16
- running: true
- repeat: true
- onTriggered: Logic.tick()
- }
-
- MouseArea {
- id: ma
- anchors.fill: parent
- onClicked: {
- if (towerMenu.visible)
- towerMenu.finish()
- else
- towerMenu.open(mouse.x, mouse.y)
- }
- }
-
- Image {
- id: towerMenu
- visible: false
- z: 1500
- scale: 0.9
- opacity: 0.7
- property int dragDistance: 16
- property int targetRow: 0
- property int targetCol: 0
- property bool shown: false
- property bool towerExists: false
-
- function finish() {
- shown = false
- }
-
- function open(xp,yp) {
- if (!grid.gameRunning)
- return
- targetRow = Logic.row(yp)
- targetCol = Logic.col(xp)
- if (targetRow == 0)
- towerMenu.y = (targetRow + 1) * grid.squareSize
- else
- towerMenu.y = (targetRow - 1) * grid.squareSize
- towerExists = (grid.towers[Logic.towerIdx(targetCol, targetRow)] != null)
- shown = true
- helpButton.goAway();
- }
-
- states: State {
- name: "shown"; when: towerMenu.shown && !grid.gameOver
- PropertyChanges { target: towerMenu; visible: true; scale: 1; opacity: 1 }
- }
-
- transitions: Transition {
- PropertyAction { property: "visible" }
- NumberAnimation { properties: "opacity,scale"; duration: 500; easing.type: Easing.OutElastic }
- }
-
- x: -32
- source: "gfx/dialog.png"
- Row {
- id: buttonRow
- height: 100
- anchors.centerIn: parent
- spacing: 8
- BuildButton {
- row: towerMenu.targetRow; col: towerMenu.targetCol
- anchors.verticalCenter: parent.verticalCenter
- towerType: 1; index: 0
- canBuild: !towerMenu.towerExists
- source: "gfx/dialog-melee.png"
- onClicked: towerMenu.finish()
- }
- BuildButton {
- row: towerMenu.targetRow; col: towerMenu.targetCol
- anchors.verticalCenter: parent.verticalCenter
- towerType: 2; index: 1
- canBuild: !towerMenu.towerExists
- source: "gfx/dialog-shooter.png"
- onClicked: towerMenu.finish()
- }
- BuildButton {
- row: towerMenu.targetRow; col: towerMenu.targetCol
- anchors.verticalCenter: parent.verticalCenter
- towerType: 3; index: 2
- canBuild: !towerMenu.towerExists
- source: "gfx/dialog-bomb.png"
- onClicked: towerMenu.finish()
- }
- BuildButton {
- row: towerMenu.targetRow; col: towerMenu.targetCol
- anchors.verticalCenter: parent.verticalCenter
- towerType: 4; index: 3
- canBuild: !towerMenu.towerExists
- source: "gfx/dialog-factory.png"
- onClicked: towerMenu.finish()
- }
- }
- }
-
-
- Keys.onPressed: { // Cheat Codes while Testing
- if (event.key == Qt.Key_Up && (event.modifiers & Qt.ShiftModifier))
- grid.coins += 10;
- if (event.key == Qt.Key_Left && (event.modifiers & Qt.ShiftModifier))
- grid.lives += 1;
- if (event.key == Qt.Key_Down && (event.modifiers & Qt.ShiftModifier))
- Logic.gameState.waveProgress += 1000;
- if (event.key == Qt.Key_Right && (event.modifiers & Qt.ShiftModifier))
- Logic.endGame();
- }
-
- Image {
- id: helpButton
- z: 1010
- source: "gfx/button-help.png"
- function goAway() {
- helpMA.enabled = false;
- helpButton.opacity = 0;
- }
- function comeBack() {
- helpMA.enabled = true;
- helpButton.opacity = 1;
- }
- Behavior on opacity { NumberAnimation {} }
- MouseArea {
- id: helpMA
- anchors.fill: parent
- onClicked: {helpImage.visible = true; helpButton.visible = false;}
- }
-
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 0
- }
-
- Image {
- id: helpImage
- z: 1010
- source: "gfx/help.png"
- anchors.fill: parent
- visible: false
- MouseArea {
- anchors.fill: parent
- onClicked: helpImage.visible = false;
- }
- }
-
-}
diff --git a/examples/quick/demos/maroon/content/GameOverScreen.qml b/examples/quick/demos/maroon/content/GameOverScreen.qml
deleted file mode 100644
index 6de3b13bad..0000000000
--- a/examples/quick/demos/maroon/content/GameOverScreen.qml
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "logic.js" as Logic
-
-Item {
- id: gameOverScreen
- width: 320
- height: 400
- property GameCanvas gameCanvas
-
- Image {
- id: img
- source: "gfx/text-gameover.png"
- anchors.centerIn: parent
- }
-
- ParticleSystem {
- anchors.fill: parent
- ImageParticle {
- id: cloud
- source: "gfx/cloud.png"
- alphaVariation: 0.25
- opacity: 0.25
- }
-
- Wander {
- xVariance: 100;
- pace: 1;
- }
-
- Emitter {
- id: cloudLeft
- width: 160
- height: 160
- anchors.right: parent.left
- emitRate: 0.5
- lifeSpan: 12000
- velocity: PointDirection{ x: 64; xVariation: 2; yVariation: 2 }
- size: 160
- }
-
- Emitter {
- id: cloudRight
- width: 160
- height: 160
- anchors.left: parent.right
- emitRate: 0.5
- lifeSpan: 12000
- velocity: PointDirection{ x: -64; xVariation: 2; yVariation: 2 }
- size: 160
- }
- }
-
-
- Text {
- visible: gameCanvas != undefined
- text: "You saved " + gameCanvas.score + " fishes!"
- anchors.top: img.bottom
- anchors.topMargin: 12
- anchors.horizontalCenter: parent.horizontalCenter
- font.bold: true
- color: "#000000"
- opacity: 0.5
- }
-
- Image {
- source: "gfx/button-play.png"
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 0
- MouseArea {
- anchors.fill: parent
- onClicked: gameCanvas.gameOver = false//This will actually trigger the state change in main.qml
- }
- }
-}
diff --git a/examples/quick/demos/maroon/content/InfoBar.qml b/examples/quick/demos/maroon/content/InfoBar.qml
deleted file mode 100644
index 8176b1a37e..0000000000
--- a/examples/quick/demos/maroon/content/InfoBar.qml
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- height: childrenRect.height
-
- // Display the number of lives
- Row {
- anchors.left: parent.left
- anchors.leftMargin: 10
- spacing: 5
- Repeater {
- id: rep
- model: Math.min(10, canvas.lives)
- delegate: Image { source: "gfx/lifes.png" }
- }
- }
-
- // Display the number of fishes saved
- Row {
- anchors.right: points.left
- anchors.rightMargin: 20
- spacing: 5
- Image { source: "gfx/scores.png" }
- Text {
- text: canvas.score
- font.bold: true
- }
- }
-
- // Display the number of coins
- Row {
- id: points
- anchors.right: parent.right
- anchors.rightMargin: 10
- spacing: 5
- Image { source: "gfx/points.png" }
- Text {
- id: pointsLabel
- text: canvas.coins
- font.bold: true
- }
- }
-}
-
diff --git a/examples/quick/demos/maroon/content/NewGameScreen.qml b/examples/quick/demos/maroon/content/NewGameScreen.qml
deleted file mode 100644
index d87e6b36f7..0000000000
--- a/examples/quick/demos/maroon/content/NewGameScreen.qml
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-// This is the first screen.
-// It shows the logo and emit a startButtonClicked signal
-// when the user press the "PLAY" button.
-
-Item {
- id: newGameScreen
- width: 320
- height: 480
-
- signal startButtonClicked
-
- Image {
- source: "gfx/logo.png"
- anchors.top: parent.top
- anchors.topMargin: 60
- }
-
- Image {
- source: "gfx/logo-fish.png"
- anchors.top: parent.top
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x + 148; to: x + 25; duration: 2000; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x + 25; to: x + 148; duration: 1600; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on anchors.topMargin {
- loops: Animation.Infinite
- NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad }
- NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad }
- }
- }
-
- Image {
- source: "gfx/logo-bubble.png"
- anchors.top: parent.top
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x + 140; to: x + 40; duration: 2000; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x + 40; to: x + 140; duration: 1600; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on anchors.topMargin {
- loops: Animation.Infinite
- NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad }
- NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on width {
- loops: Animation.Infinite
- NumberAnimation { from: 140; to: 160; duration: 1000; easing.type: Easing.InOutQuad }
- NumberAnimation { from: 160; to: 140; duration: 800; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on height {
- loops: Animation.Infinite
- NumberAnimation { from: 150; to: 140; duration: 800; easing.type: Easing.InOutQuad }
- NumberAnimation { from: 140; to: 150; duration: 1000; easing.type: Easing.InOutQuad }
- }
- }
-
- Image {
- source: "gfx/button-play.png"
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 60
- MouseArea {
- anchors.fill: parent
- onClicked: newGameScreen.startButtonClicked()
- }
- }
-}
diff --git a/examples/quick/demos/maroon/content/SoundEffect.qml b/examples/quick/demos/maroon/content/SoundEffect.qml
deleted file mode 100644
index 35a68eb5e0..0000000000
--- a/examples/quick/demos/maroon/content/SoundEffect.qml
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-//Proxies a SoundEffect if QtMultimedia is installed
-Item {
- id: container
- property QtObject effect: Qt.createQmlObject("import QtMultimedia 5.0; SoundEffect{ source: '" + container.source + "'; muted: Qt.application.state != Qt.ApplicationActive }", container);
- property url source: ""
- onSourceChanged: if (effect != null) effect.source = source;
- function play() {
- if (effect != null)
- effect.play();
- }
-}
diff --git a/examples/quick/demos/maroon/content/audio/bomb-action.wav b/examples/quick/demos/maroon/content/audio/bomb-action.wav
deleted file mode 100644
index b334dc1e5b..0000000000
--- a/examples/quick/demos/maroon/content/audio/bomb-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/catch-action.wav b/examples/quick/demos/maroon/content/audio/catch-action.wav
deleted file mode 100644
index 3e22124abf..0000000000
--- a/examples/quick/demos/maroon/content/audio/catch-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/catch.wav b/examples/quick/demos/maroon/content/audio/catch.wav
deleted file mode 100644
index d3eade87f8..0000000000
--- a/examples/quick/demos/maroon/content/audio/catch.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/currency.wav b/examples/quick/demos/maroon/content/audio/currency.wav
deleted file mode 100644
index 0d9ef2c200..0000000000
--- a/examples/quick/demos/maroon/content/audio/currency.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/factory-action.wav b/examples/quick/demos/maroon/content/audio/factory-action.wav
deleted file mode 100644
index a2ace6c221..0000000000
--- a/examples/quick/demos/maroon/content/audio/factory-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/melee-action.wav b/examples/quick/demos/maroon/content/audio/melee-action.wav
deleted file mode 100644
index d325af4700..0000000000
--- a/examples/quick/demos/maroon/content/audio/melee-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/projectile-action.wav b/examples/quick/demos/maroon/content/audio/projectile-action.wav
deleted file mode 100644
index 4e2284fceb..0000000000
--- a/examples/quick/demos/maroon/content/audio/projectile-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/shooter-action.wav b/examples/quick/demos/maroon/content/audio/shooter-action.wav
deleted file mode 100644
index 3e12b9419a..0000000000
--- a/examples/quick/demos/maroon/content/audio/shooter-action.wav
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/background.png b/examples/quick/demos/maroon/content/gfx/background.png
deleted file mode 100644
index d548b9314e..0000000000
--- a/examples/quick/demos/maroon/content/gfx/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb-action.png b/examples/quick/demos/maroon/content/gfx/bomb-action.png
deleted file mode 100644
index 42da5d789f..0000000000
--- a/examples/quick/demos/maroon/content/gfx/bomb-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb-idle.png b/examples/quick/demos/maroon/content/gfx/bomb-idle.png
deleted file mode 100644
index 3bd62e261d..0000000000
--- a/examples/quick/demos/maroon/content/gfx/bomb-idle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb.png b/examples/quick/demos/maroon/content/gfx/bomb.png
deleted file mode 100644
index 380da7d1a5..0000000000
--- a/examples/quick/demos/maroon/content/gfx/bomb.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/button-help.png b/examples/quick/demos/maroon/content/gfx/button-help.png
deleted file mode 100644
index aecebc1275..0000000000
--- a/examples/quick/demos/maroon/content/gfx/button-help.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/button-play.png b/examples/quick/demos/maroon/content/gfx/button-play.png
deleted file mode 100644
index 6cdad6c845..0000000000
--- a/examples/quick/demos/maroon/content/gfx/button-play.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/catch-action.png b/examples/quick/demos/maroon/content/gfx/catch-action.png
deleted file mode 100644
index 78ca9fe1cc..0000000000
--- a/examples/quick/demos/maroon/content/gfx/catch-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/catch.png b/examples/quick/demos/maroon/content/gfx/catch.png
deleted file mode 100644
index b7620fe3de..0000000000
--- a/examples/quick/demos/maroon/content/gfx/catch.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/cloud.png b/examples/quick/demos/maroon/content/gfx/cloud.png
deleted file mode 100644
index d7c35f8555..0000000000
--- a/examples/quick/demos/maroon/content/gfx/cloud.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/currency.png b/examples/quick/demos/maroon/content/gfx/currency.png
deleted file mode 100644
index 1571341f6c..0000000000
--- a/examples/quick/demos/maroon/content/gfx/currency.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-bomb.png b/examples/quick/demos/maroon/content/gfx/dialog-bomb.png
deleted file mode 100644
index 708d916ad7..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog-bomb.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-factory.png b/examples/quick/demos/maroon/content/gfx/dialog-factory.png
deleted file mode 100644
index d2e2a48e31..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog-factory.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-melee.png b/examples/quick/demos/maroon/content/gfx/dialog-melee.png
deleted file mode 100644
index 069d18d477..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog-melee.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-pointer.png b/examples/quick/demos/maroon/content/gfx/dialog-pointer.png
deleted file mode 100644
index 9b51a090f9..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog-pointer.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-shooter.png b/examples/quick/demos/maroon/content/gfx/dialog-shooter.png
deleted file mode 100644
index af980caabd..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog-shooter.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog.png b/examples/quick/demos/maroon/content/gfx/dialog.png
deleted file mode 100644
index d528ba78d1..0000000000
--- a/examples/quick/demos/maroon/content/gfx/dialog.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory-action.png b/examples/quick/demos/maroon/content/gfx/factory-action.png
deleted file mode 100644
index 8981678267..0000000000
--- a/examples/quick/demos/maroon/content/gfx/factory-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory-idle.png b/examples/quick/demos/maroon/content/gfx/factory-idle.png
deleted file mode 100644
index a145582c8f..0000000000
--- a/examples/quick/demos/maroon/content/gfx/factory-idle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory.png b/examples/quick/demos/maroon/content/gfx/factory.png
deleted file mode 100644
index bfb9f3fb79..0000000000
--- a/examples/quick/demos/maroon/content/gfx/factory.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/grid.png b/examples/quick/demos/maroon/content/gfx/grid.png
deleted file mode 100644
index b59555247a..0000000000
--- a/examples/quick/demos/maroon/content/gfx/grid.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/help.png b/examples/quick/demos/maroon/content/gfx/help.png
deleted file mode 100644
index 4654e4c69b..0000000000
--- a/examples/quick/demos/maroon/content/gfx/help.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/lifes.png b/examples/quick/demos/maroon/content/gfx/lifes.png
deleted file mode 100644
index 135310b38c..0000000000
--- a/examples/quick/demos/maroon/content/gfx/lifes.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo-bubble.png b/examples/quick/demos/maroon/content/gfx/logo-bubble.png
deleted file mode 100644
index 136151caff..0000000000
--- a/examples/quick/demos/maroon/content/gfx/logo-bubble.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo-fish.png b/examples/quick/demos/maroon/content/gfx/logo-fish.png
deleted file mode 100644
index c41833a0c9..0000000000
--- a/examples/quick/demos/maroon/content/gfx/logo-fish.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo.png b/examples/quick/demos/maroon/content/gfx/logo.png
deleted file mode 100644
index 787ac99ce8..0000000000
--- a/examples/quick/demos/maroon/content/gfx/logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee-action.png b/examples/quick/demos/maroon/content/gfx/melee-action.png
deleted file mode 100644
index c53873bfcc..0000000000
--- a/examples/quick/demos/maroon/content/gfx/melee-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee-idle.png b/examples/quick/demos/maroon/content/gfx/melee-idle.png
deleted file mode 100644
index 621d9dff54..0000000000
--- a/examples/quick/demos/maroon/content/gfx/melee-idle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee.png b/examples/quick/demos/maroon/content/gfx/melee.png
deleted file mode 100644
index ab240151f3..0000000000
--- a/examples/quick/demos/maroon/content/gfx/melee.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/mob-idle.png b/examples/quick/demos/maroon/content/gfx/mob-idle.png
deleted file mode 100644
index dedacc7866..0000000000
--- a/examples/quick/demos/maroon/content/gfx/mob-idle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/mob.png b/examples/quick/demos/maroon/content/gfx/mob.png
deleted file mode 100644
index 7569c3525a..0000000000
--- a/examples/quick/demos/maroon/content/gfx/mob.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/points.png b/examples/quick/demos/maroon/content/gfx/points.png
deleted file mode 100644
index 1d2386dbe7..0000000000
--- a/examples/quick/demos/maroon/content/gfx/points.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/projectile-action.png b/examples/quick/demos/maroon/content/gfx/projectile-action.png
deleted file mode 100644
index aa2e650aeb..0000000000
--- a/examples/quick/demos/maroon/content/gfx/projectile-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/projectile.png b/examples/quick/demos/maroon/content/gfx/projectile.png
deleted file mode 100644
index c25a0c3890..0000000000
--- a/examples/quick/demos/maroon/content/gfx/projectile.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/scores.png b/examples/quick/demos/maroon/content/gfx/scores.png
deleted file mode 100644
index af757fe64a..0000000000
--- a/examples/quick/demos/maroon/content/gfx/scores.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter-action.png b/examples/quick/demos/maroon/content/gfx/shooter-action.png
deleted file mode 100644
index 08e7e300ca..0000000000
--- a/examples/quick/demos/maroon/content/gfx/shooter-action.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter-idle.png b/examples/quick/demos/maroon/content/gfx/shooter-idle.png
deleted file mode 100644
index 663098d3b0..0000000000
--- a/examples/quick/demos/maroon/content/gfx/shooter-idle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter.png b/examples/quick/demos/maroon/content/gfx/shooter.png
deleted file mode 100644
index d44401e055..0000000000
--- a/examples/quick/demos/maroon/content/gfx/shooter.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/sunlight.png b/examples/quick/demos/maroon/content/gfx/sunlight.png
deleted file mode 100644
index d1c7042117..0000000000
--- a/examples/quick/demos/maroon/content/gfx/sunlight.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-1.png b/examples/quick/demos/maroon/content/gfx/text-1.png
deleted file mode 100644
index 3ea399cc90..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-2.png b/examples/quick/demos/maroon/content/gfx/text-2.png
deleted file mode 100644
index 934a481f3b..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-3.png b/examples/quick/demos/maroon/content/gfx/text-3.png
deleted file mode 100644
index 47523f55b8..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-3.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-blank.png b/examples/quick/demos/maroon/content/gfx/text-blank.png
deleted file mode 100644
index 4a687b24dc..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-blank.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-gameover.png b/examples/quick/demos/maroon/content/gfx/text-gameover.png
deleted file mode 100644
index 4f53ef0b29..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-gameover.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-go.png b/examples/quick/demos/maroon/content/gfx/text-go.png
deleted file mode 100644
index bfc26f71fc..0000000000
--- a/examples/quick/demos/maroon/content/gfx/text-go.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/wave.png b/examples/quick/demos/maroon/content/gfx/wave.png
deleted file mode 100644
index f97426c4e7..0000000000
--- a/examples/quick/demos/maroon/content/gfx/wave.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/content/logic.js b/examples/quick/demos/maroon/content/logic.js
deleted file mode 100644
index 3830b5ad63..0000000000
--- a/examples/quick/demos/maroon/content/logic.js
+++ /dev/null
@@ -1,274 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-.pragma library // Shared game state
-.import QtQuick 2.0 as QQ
-
-// Game Stuff
-var gameState // Local reference
-function getGameState() { return gameState; }
-
-var towerData = [ // Name and cost, stats are in the delegate per instance
- { "name": "Melee", "cost": 20 },
- { "name": "Ranged", "cost": 50 },
- { "name": "Bomb", "cost": 75 },
- { "name": "Factory", "cost": 25 }
-]
-
-var waveBaseData = [300, 290, 280, 270, 220, 180, 160, 80, 80, 80, 30, 30, 30, 30];
-var waveData = [];
-
-var towerComponents = new Array(towerData.length);
-var mobComponent = Qt.createComponent("mobs/MobBase.qml");
-
-function endGame()
-{
- gameState.gameRunning = false;
- gameState.gameOver = true;
- for (var i = 0; i < gameState.cols; i++) {
- for (var j = 0; j < gameState.rows; j++) {
- if (gameState.towers[towerIdx(i, j)]) {
- gameState.towers[towerIdx(i, j)].destroy();
- gameState.towers[towerIdx(i, j)] = null;
- }
- }
- for (var j in gameState.mobs[i])
- gameState.mobs[i][j].destroy();
- gameState.mobs[i].splice(0,gameState.mobs[i].length); //Leaves queue reusable
- }
-}
-
-function startGame(gameCanvas)
-{
- waveData = new Array();
- for (var i in waveBaseData)
- waveData[i] = waveBaseData[i];
- gameState.freshState();
- for (var i = 0; i < gameCanvas.cols; i++) {
- for (var j = 0; j < gameCanvas.rows; j++)
- gameState.towers[towerIdx(i, j)] = null;
- gameState.mobs[i] = new Array();
- }
- gameState.towers[towerIdx(0, 0)] = newTower(3, 0, 0);//Start with a starfish in the corner
- gameState.gameRunning = true;
- gameState.gameOver = false;
-}
-
-function newGameState(gameCanvas)
-{
- for (var i = 0; i < towerComponents.length; i++) {
- towerComponents[i] = Qt.createComponent("towers/" + towerData[i].name + ".qml");
- if (towerComponents[i].status == QQ.Component.Error) {
- gameCanvas.errored = true;
- gameCanvas.errorString += "Loading Tower " + towerData[i].name + "\n" + (towerComponents[i].errorString());
- console.log(towerComponents[i].errorString());
- }
- }
- gameState = gameCanvas;
- gameState.freshState();
- gameState.towers = new Array(gameCanvas.rows * gameCanvas.cols);
- gameState.mobs = new Array(gameCanvas.cols);
- return gameState;
-}
-
-function row(y)
-{
- return Math.floor(y / gameState.squareSize);
-}
-
-function col(x)
-{
- return Math.floor(x / gameState.squareSize);
-}
-
-function towerIdx(x, y)
-{
- return y + (x * gameState.rows);
-}
-
-function newMob(col)
-{
- var ret = mobComponent.createObject(gameState.canvas,
- { "col" : col,
- "speed" : (Math.min(2.0, 0.10 * (gameState.waveNumber + 1))),
- "y" : gameState.canvas.height });
- gameState.mobs[col].push(ret);
- return ret;
-}
-
-function newTower(type, row, col)
-{
- var ret = towerComponents[type].createObject(gameState.canvas);
- ret.row = row;
- ret.col = col;
- ret.fireCounter = ret.rof;
- ret.spawn();
- return ret;
-}
-
-function buildTower(type, x, y)
-{
- if (gameState.towers[towerIdx(x,y)] != null) {
- if (type <= 0) {
- gameState.towers[towerIdx(x,y)].sell();
- gameState.towers[towerIdx(x,y)] = null;
- }
- } else {
- if (gameState.coins < towerData[type - 1].cost)
- return;
- gameState.towers[towerIdx(x, y)] = newTower(type - 1, y, x);
- gameState.coins -= towerData[type - 1].cost;
- }
-}
-
-function killMob(col, mob)
-{
- if (!mob)
- return;
- var idx = gameState.mobs[col].indexOf(mob);
- if (idx == -1 || !mob.hp)
- return;
- mob.hp = 0;
- mob.die();
- gameState.mobs[col].splice(idx,1);
-}
-
-function killTower(row, col)
-{
- var tower = gameState.towers[towerIdx(col, row)];
- if (!tower)
- return;
- tower.hp = 0;
- tower.die();
- gameState.towers[towerIdx(col, row)] = null;
-}
-
-function tick()
-{
- if (!gameState.gameRunning)
- return;
-
- // Spawn
- gameState.waveProgress += 1;
- var i = gameState.waveProgress;
- var j = 0;
- while (i > 0 && j < waveData.length)
- i -= waveData[j++];
- if ( i == 0 ) // Spawn a mob
- newMob(Math.floor(Math.random() * gameState.cols));
- if ( j == waveData.length ) { // Next Wave
- gameState.waveNumber += 1;
- gameState.waveProgress = 0;
- var waveModifier = 10; // Constant governing how much faster the next wave is to spawn (not fish speed)
- for (var k in waveData ) // Slightly faster
- if (waveData[k] > waveModifier)
- waveData[k] -= waveModifier;
- }
-
- // Towers Attack
- for (var j in gameState.towers) {
- var tower = gameState.towers[j];
- if (tower == null)
- continue;
- if (tower.fireCounter > 0) {
- tower.fireCounter -= 1;
- continue;
- }
- var column = tower.col;
- for (var k in gameState.mobs[column]) {
- var conflict = gameState.mobs[column][k];
- if (conflict.y <= gameState.canvas.height && conflict.y + conflict.height > tower.y
- && conflict.y - ((tower.row + 1) * gameState.squareSize) < gameState.squareSize * tower.range) { // In Range
- tower.fire();
- tower.fireCounter = tower.rof;
- conflict.hit(tower.damage);
- }
- }
-
- // Income
- if (tower.income) {
- gameState.coins += tower.income;
- tower.fire();
- tower.fireCounter = tower.rof;
- }
- }
-
- // Mobs move
- for (var i = 0; i < gameState.cols; i++) {
- for (var j = 0; j < gameState.mobs[i].length; j++) {
- var mob = gameState.mobs[i][j];
- var newPos = gameState.mobs[i][j].y - gameState.mobs[i][j].speed;
- if (newPos < 0) {
- gameState.lives -= 1;
- killMob(i, mob);
- if (gameState.lives <= 0)
- endGame();
- continue;
- }
- var conflict = gameState.towers[towerIdx(i, row(newPos))];
- if (conflict != null) {
- if (mob.y < conflict.y + gameState.squareSize)
- gameState.mobs[i][j].y += gameState.mobs[i][j].speed * 10; // Moved inside tower, now hurry back out
- if (mob.fireCounter > 0) {
- mob.fireCounter--;
- } else {
- gameState.mobs[i][j].fire();
- conflict.hp -= mob.damage;
- if (conflict.hp <= 0)
- killTower(conflict.row, conflict.col);
- mob.fireCounter = mob.rof;
- }
- } else {
- gameState.mobs[i][j].y = newPos;
- }
- }
- }
-
-}
diff --git a/examples/quick/demos/maroon/content/mobs/MobBase.qml b/examples/quick/demos/maroon/content/mobs/MobBase.qml
deleted file mode 100644
index 584623fa77..0000000000
--- a/examples/quick/demos/maroon/content/mobs/MobBase.qml
+++ /dev/null
@@ -1,272 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "../logic.js" as Logic
-import ".."
-
-Item {
- id: container
- property string name: "Fish"
- property int col: 0
- property real hp: 3
- property real damage: 1
- property real speed: 0.25
- property int rof: 30 //In ticks
- property int fireCounter: 0
- property bool dying: false
- width: parent ? parent.squareSize : 0
- height: parent ? parent.squareSize : 0
- x: col * width
- z: 1001
- function fire() { }
-
- function die() {
- if (dying)
- return;
- dying = true;
- bubble.jumpTo("burst");
- if (fishSprite.currentSprite == "front")
- fishSprite.jumpTo(Math.random() > 0.5 ? "left" : "right" );
- fishSwim.start();
- Logic.gameState.score += 1;
- killedSound.play();
- bubble.scale = 0.9
- destroy(350);
- }
-
- function inked() {
- if (hp > 0)
- ink.jumpTo("dirty");
- }
-
- function hit(dmg) {
- hp -= dmg;
-
- if (hp <= 0)
- Logic.killMob(col, container);
- }
-
- Component.onCompleted: spawnSound.play()
-
- SoundEffect {
- id: spawnSound
- source: "../audio/catch.wav"
- }
- SoundEffect {
- id: killedSound
- source: "../audio/catch-action.wav"
- }
-
- SpriteSequence {
- id: fishSprite
- width: 64
- height: 64
- interpolate: false
- goalSprite: ""
-
- Sprite {
- name: "left"
- source: "../gfx/mob-idle.png"
- frameWidth: 64
- frameHeight: 64
- frameCount: 1
- frameDuration: 800
- frameDurationVariation: 400
- to: { "front" : 1 }
- }
-
- Sprite {
- name: "front"
- source: "../gfx/mob-idle.png"
- frameCount: 1
- frameX: 64
- frameWidth: 64
- frameHeight: 64
- frameDuration: 800
- frameDurationVariation: 400
- to: { "left" : 1, "right" : 1 }
- }
-
- Sprite {
- name: "right"
- source: "../gfx/mob-idle.png"
- frameCount: 1
- frameX: 128
- frameWidth: 64
- frameHeight: 64
- frameDuration: 800
- frameDurationVariation: 400
- to: { "front" : 1 }
- }
-
-
- Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
- name: "dummy"
- source: "../gfx/melee-idle.png"
- frameCount: 8
- frameWidth: 64
- frameHeight: 64
- frameX: 0
- frameDuration: 200
- }
-
- NumberAnimation on x {
- id: fishSwim
- running: false
- property bool goingLeft: fishSprite.currentSprite == "right"
- to: goingLeft ? -360 : 360
- duration: 300
- }
- }
-
- SpriteSequence {
- id: bubble
- width: 64
- height: 64
- scale: 0.4 + (0.2 * hp)
- interpolate: false
- goalSprite: ""
-
- Behavior on scale {
- NumberAnimation { duration: 150; easing.type: Easing.OutBack }
- }
-
- Sprite {
- name: "big"
- source: "../gfx/catch.png"
- frameCount: 1
- to: { "burst" : 0 }
- }
-
- Sprite {
- name: "burst"
- source: "../gfx/catch-action.png"
- frameCount: 3
- frameX: 64
- frameDuration: 200
- }
-
- Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
- name: "dummy"
- source: "../gfx/melee-idle.png"
- frameCount: 8
- frameWidth: 64
- frameHeight: 64
- frameX: 0
- frameDuration: 200
- }
- SequentialAnimation on width {
- loops: Animation.Infinite
- NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad }
- NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on height {
- loops: Animation.Infinite
- NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad }
- NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad }
- }
- }
-
- SpriteSequence {
- id: ink
- width: 64
- height: 64
- scale: bubble.scale
- goalSprite: ""
-
- Sprite {
- name: "clean"
- source: "../gfx/projectile-action.png"
- frameCount: 1
- frameX: 0
- frameWidth: 64
- frameHeight: 64
- }
- Sprite {
- name: "dirty"
- source: "../gfx/projectile-action.png"
- frameCount: 3
- frameX: 64
- frameWidth: 64
- frameHeight: 64
- frameDuration: 150
- to: {"clean":1}
- }
-
- Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
- name: "dummy"
- source: "../gfx/melee-idle.png"
- frameCount: 8
- frameWidth: 64
- frameHeight: 64
- frameX: 0
- frameDuration: 200
- }
- SequentialAnimation on width {
- loops: Animation.Infinite
- NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad }
- NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on height {
- loops: Animation.Infinite
- NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad }
- NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad }
- }
-
- }
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x; to: x - 5; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x - 5; to: x; duration: 900; easing.type: Easing.InOutQuad }
- }
-}
-
diff --git a/examples/quick/demos/maroon/content/towers/Bomb.qml b/examples/quick/demos/maroon/content/towers/Bomb.qml
deleted file mode 100644
index e33d71d2e0..0000000000
--- a/examples/quick/demos/maroon/content/towers/Bomb.qml
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "../logic.js" as Logic
-import ".."
-
-TowerBase {
- id: container
- hp: 10
- range: 0.4
- rof: 10
- property real detonationRange: 2.5
-
- function fire() {
- sound.play()
- sprite.jumpTo("shoot")
- animDelay.start()
- }
-
- function finishFire() {
- var sCol = Math.max(0, col - 1)
- var eCol = Math.min(Logic.gameState.cols - 1, col + 1)
- var killList = new Array()
- for (var i = sCol; i <= eCol; i++) {
- for (var j = 0; j < Logic.gameState.mobs[i].length; j++)
- if (Math.abs(Logic.gameState.mobs[i][j].y - container.y) < Logic.gameState.squareSize * detonationRange)
- killList.push(Logic.gameState.mobs[i][j])
- while (killList.length > 0)
- Logic.killMob(i, killList.pop())
- }
- Logic.killTower(row, col);
- }
-
- Timer {
- id: animDelay
- running: false
- interval: shootState.frameCount * shootState.frameDuration
- onTriggered: finishFire()
- }
-
- function die()
- {
- destroy() // No blink, because we usually meant to die
- }
-
- SoundEffect {
- id: sound
- source: "../audio/bomb-action.wav"
- }
-
- SpriteSequence {
- id: sprite
- width: 64
- height: 64
- interpolate: false
- goalSprite: ""
-
- Sprite {
- name: "idle"
- source: "../gfx/bomb-idle.png"
- frameCount: 4
- frameDuration: 800
- }
-
- Sprite {
- id: shootState
- name: "shoot"
- source: "../gfx/bomb-action.png"
- frameCount: 6
- frameDuration: 155
- to: { "dying" : 1 } // So that if it takes a frame to clean up, it is on the last frame of the explosion
- }
-
- Sprite {
- name: "dying"
- source: "../gfx/bomb-action.png"
- frameCount: 1
- frameX: 64 * 5
- frameWidth: 64
- frameHeight: 64
- frameDuration: 155
- }
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad }
- }
- }
-}
diff --git a/examples/quick/demos/maroon/content/towers/Factory.qml b/examples/quick/demos/maroon/content/towers/Factory.qml
deleted file mode 100644
index 6b688e051a..0000000000
--- a/examples/quick/demos/maroon/content/towers/Factory.qml
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "../logic.js" as Logic
-import ".."
-
-TowerBase {
- id: container
- rof: 160
- income: 5
- SpriteSequence {
- id: sprite
- width: 64
- height: 64
- interpolate: false
- goalSprite: ""
-
- Sprite {
- name: "idle"
- source: "../gfx/factory-idle.png"
- frameCount: 4
- frameDuration: 200
- }
-
- Sprite {
- name: "action"
- source: "../gfx/factory-action.png"
- frameCount: 4
- frameDuration: 90
- to: { "idle" : 1 }
- }
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
- }
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad }
- }
- }
-
- SoundEffect {
- id: actionSound
- source: "../audio/factory-action.wav"
- }
-
- function fire() {
- actionSound.play()
- sprite.jumpTo("action")
- coinLaunch.start()
- }
-
- function spawn() {
- coin.target = Logic.gameState.mapToItem(container, 240, -32)
- }
-
- Image {
- id: coin
- property var target: { "x" : 0, "y" : 0 }
- source: "../gfx/currency.png"
- visible: false
- }
-
- SequentialAnimation {
- id: coinLaunch
- PropertyAction { target: coin; property: "visible"; value: true }
- ParallelAnimation {
- NumberAnimation { target: coin; property: "x"; from: 16; to: coin.target.x }
- NumberAnimation { target: coin; property: "y"; from: 16; to: coin.target.y }
- }
- PropertyAction { target: coin; property: "visible"; value: false }
- }
-}
diff --git a/examples/quick/demos/maroon/content/towers/Ranged.qml b/examples/quick/demos/maroon/content/towers/Ranged.qml
deleted file mode 100644
index 2c1f5d1343..0000000000
--- a/examples/quick/demos/maroon/content/towers/Ranged.qml
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "../logic.js" as Logic
-import ".."
-
-TowerBase {
- id: container
- hp: 2
- range: 6
- damage: 0 // By projectile
- rof: 40
- income: 0
- property var targetMob
- property real realDamage: 1
- function fire() {
- proj.x = 32 - proj.width / 2
- proj.y = 0
- targetMob = Logic.gameState.mobs[col][0]
- projAnim.to = targetMob.y - container.y -10
- projAnim.start()
- shootSound.play()
- sprite.jumpTo("shoot")
- }
-
- Image {
- id: proj
- y: 1000
- SequentialAnimation on y {
- id: projAnim
- running: false
- property real to: 1000
- SmoothedAnimation {
- to: projAnim.to
- velocity: 400
- }
- ScriptAction {
- script: {
- if (targetMob && targetMob.hit) {
- targetMob.hit(realDamage)
- targetMob.inked()
- projSound.play()
- }
- }
- }
- PropertyAction {
- value: 1000;
- }
- }
- source: "../gfx/projectile.png"
- }
-
- SoundEffect {
- id: shootSound
- source: "../audio/shooter-action.wav"
- }
- SoundEffect {
- id: projSound
- source: "../audio/projectile-action.wav"
- }
-
- SpriteSequence {
- id: sprite
- width: 64
- height: 64
- interpolate: false
- goalSprite: ""
-
- Sprite {
- name: "idle"
- source: "../gfx/shooter-idle.png"
- frameCount: 4
- frameDuration: 250
- }
-
- Sprite {
- name: "shoot"
- source: "../gfx/shooter-action.png"
- frameCount: 5
- frameDuration: 90
- to: { "idle" : 1 }
- }
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- NumberAnimation { from: x; to: x - 4; duration: 900; easing.type: Easing.InOutQuad }
- NumberAnimation { from: x - 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
- }
- }
-}
diff --git a/examples/quick/demos/maroon/content/towers/TowerBase.qml b/examples/quick/demos/maroon/content/towers/TowerBase.qml
deleted file mode 100644
index be37d732e4..0000000000
--- a/examples/quick/demos/maroon/content/towers/TowerBase.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- property real hp: 1
- property real range: 0
- property real damage: 0
- property int rof: 100
- property int fireCounter: 0
- property int income: 0
- property int row: 0
- property int col: 0
-
- width: parent ? parent.squareSize : 0
- height: parent ? parent.squareSize : 0
- //This is how it is placed on the gameboard, do not modify/animate the X/Y/Z of a TowerBase please
- x: col * width
- y: row * height
- z: 1000
-
- function fire() { }
- function spawn() { } //After all game properties are set
- function die() { stdDeath.start(); destroy(1000); }
- function sell() { destroy(); }
-
- SequentialAnimation on opacity {
- id: stdDeath
- running: false
- loops: 2
- NumberAnimation { from: 1; to: 0; }
- NumberAnimation { from: 0; to: 1; }
- }
-}
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png
deleted file mode 100644
index 6d41179c23..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png
deleted file mode 100644
index 2b5c238c82..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-3.jpg b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-3.jpg
deleted file mode 100644
index a83e282d5f..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-3.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-4.jpg b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-4.jpg
deleted file mode 100644
index 8a6063b7c7..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-4.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-5.jpg b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-5.jpg
deleted file mode 100644
index e3e4a2ec89..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-5.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-6.jpg b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-6.jpg
deleted file mode 100644
index ad6b4bf156..0000000000
--- a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-6.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/maroon/doc/src/maroon.qdoc b/examples/quick/demos/maroon/doc/src/maroon.qdoc
deleted file mode 100644
index e6f0a25238..0000000000
--- a/examples/quick/demos/maroon/doc/src/maroon.qdoc
+++ /dev/null
@@ -1,889 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Maroon in Trouble
- \ingroup qtquickdemos
- \example demos/maroon
- \brief A Qt Quick game for touch devices that uses SpriteSequence,
- ParticleSystem, Emitter, and Wander types to animate objects and the SoundEffect type to
- play sound effects.
-
- \image qtquick-demo-maroon-med-2.png
-
- \e{Maroon in Trouble} demonstrates QML features that are useful when
- developing games:
-
- \list
- \li Using custom QML types to create different screens for
- different stages of the game.
- \li Using the \l Item and \l Image types to construct a game background.
- \li Using the SequentialAnimation, NumberAnimation, ParticleSystem,
- \l Emitter, and \l Wander types to animate background objects.
- \li Using the \l Timer and \l Repeater types to display a countdown
- sequence before starting the game.
- \li Using a custom QML type with custom properties to construct a game
- board.
- \li Using the SpriteSequence and \l Sprite types to add animated objects
- to the game board.
- \li Using a custom QML type that uses the \l Image type with some custom
- properties to add a menu where the players can buy objects.
- \li Using custom properties with private functions to keep track of game
- statistics and a custom QML type to display them to the players.
- \li Using the \l State type with JavaScript functions to manage game
- states.
- \li Using the \l SoundEffect type to play individual sound effects
- depending on the object type and the action applied to the object.
- \li Using signal handlers to specify keyboard shortcuts for some game
- actions.
- \li Using resource files to package game resources for deployment and
- delivery.
- \endlist
-
- \include examples-run.qdocinc
-
- \section1 Adding Screens
-
- In the Maroon in Trouble app, we use the following custom types that
- are each defined in a separate .qml file to create the game screens:
-
- \list
- \li NewGameScreen.qml
- \li GameCanvas.qml
- \li GameOverScreen.qml
- \endlist
-
- To use the custom types, we add an import statement to the main QML file,
- maroon.qml that imports the folder called \c content where the types are
- located:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto content
- \printuntil "
-
- We use the screen types at different stages of the game. The NewGameScreen
- type is used to create the screen that appears when the players start the
- app. In NewGameScreen.qml, we use an \l{Image} type to create a New Game
- button that the players can press to start a new game.
-
- \image qtquick-demo-maroon-med-1.png
-
- Tapping the button initiates a countdown timer that triggers the creation
- of the game canvas by using the GameCanvas type. Another \l{Timer} type
- spawns mobs of fish inside bubbles that the players must free before they
- reach the surface. The players can tap on the screen to open a menu where
- they can buy different types of weapons (melee, ranged, and bombs) to burst
- the bubbles.
-
- \image qtquick-demo-maroon-med-2.png
-
- When the game finishes, a screen created by using the GameOverScreen type
- appears. On this screen, the players can see their score and start a new
- game.
-
- \image qtquick-demo-maroon-med-3.jpg
-
- The screens are all created on the same background and use some of the same
- images and animations.
-
- \section1 Constructing the Background
-
- In the maroon.qml file, we use an \l{Item} type with the id \c root and a
- fixed width and height to create a main window for the game:
-
- \skipto Item
- \printuntil passedSplash
-
- We declare two custom properties for the root item, \c gameState and
- \c passedSplash that we will use later to manage game states.
-
- We use an \l{Image} item to display the game background image:
-
- \printuntil anchors.bottom
-
- We want to be able to load the background image only once at app startup
- and still use different scenes for the game screens. Therefore,
- background.png is three times the length of the root item and displays a
- scene that stretches from the bottom of sea to the sky above the horizon.
-
- We use the \c anchors.bottom property to anchor the background image to the
- bottom of the \l{Column} layout that we use to position the screens:
-
- \skipto Column
- \printuntil GameOverScreen
-
- We set a negative value for the \c y property to set the first scene at the
- bottom of the sea. We calculate the position by subtracting the height of
- a screen from the \c height property.
-
- Within the column layout, we use an \l{Item} type to add objects to the
- background. Within the item, we use \l{Row} layout objects to position
- \l{Image} objects that display waves on the game canvas and the game over
- screen:
-
- \printuntil }
- \printuntil }
- \dots
- \skipto Row
- \printuntil }
- \printuntil }
-
- The second row of waves is positioned on the y axis with a slight offset to
- the first row. We also use the \c opacity property to make the waves appear
- lighter in color than the first two waves, which gives the background some
- depth.
-
- We use \l{Image} objects to also display sunlight on the new game screen and
- on the game canvas:
-
- \skipto Image
- \printuntil anchors
- \dots
- \skipto Image
- \printuntil anchors
-
- We set the \c opacity property of the images to \c 0.02 and \c 0.04 to give
- some depth to the rays of sunshine. We use the \c y property to position the
- images at fixed locations on the y axis and the
- \c {anchors.horizontalCenter} property to center them horizontally in
- relation to their parent.
-
- We use an \l {Image} type to display an image that adds a deepening shadow
- to the background:
-
- \skipto Image
- \printuntil }
-
- We set the \c opacity property of the image to \c 0.5 to make the background
- visible behind the shadow.
-
- To make the background more interesting, we animate some of the objects we
- added to it.
-
- \section1 Animating Background Objects
-
- We use NumberAnimation to move the waves horizontally across the screen in
- opposite directions and SequentialAnimation with NumberAnimation to move
- them up and down.
-
- We apply the number animation to the \c x property of \c wave as a property
- value source to animate the x value from its current value to the
- \c -(wave.width), over 16 seconds. We set the \c loops property to
- \c {Animation.Infinite} to repeat the animation indefinitely:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto wave.width
- \printuntil }
-
- We apply the sequential animation to the \c y property of the image as a
- property value source to animate the y value. We use one number animation
- to animate the image from the y position of two below the value of y to two
- above it, over 1600 milliseconds. We use another number animation to
- subsequently animate the image in the opposite direction, again over 1600
- milliseconds. The animation is repeated indefinitely:
-
- \skipto SequentialAnimation
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use the easing curve of the type \c {Easing.InOutQuad} for a quintic
- (t^5) function to accelerate the motion until halfway and then decelerate
- it.
-
- We use sequential animation and number animation to animate \c wave2
- similarly to \c wave, but in the opposite direction:
-
- \skipto SequentialAnimation
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use sequential animation to rotate the rays of sunlight in degrees
- clockwise around an origin point that we set to \c {Item.Top} in the
- \c transformOrigin property. The animation is repeated indefinitely:
-
- \skipto transformOrigin
- \printuntil to: -10
- \printuntil }
-
- We use one number animation to rotate the image from \c -10 degrees to
- \c 10 degrees over 8 seconds and another to subsequently rotate it from
- \c 10 degrees to \c -10 degrees over the same duration.
-
- We use the easing curve of the type \c {Easing.InOutSine} for a sinusoidal
- (sin(t)) function to accelerate the motion until halfway and then decelerate
- it.
-
- We use sequential animation and number animation to animate another
- sunlight.png image similarly, but in the opposite direction:
-
- \skipto transformOrigin
- \printuntil to: 10
- \printuntil }
-
- For examples of using SequentialAnimation and NumberAnimation on the \c x
- and \c y properties and the \c width and \c height properties, see
- NewGameScreen.qml.
-
- \section1 Emitting Particles
-
- In addition to animation, we use particles to generate motion on the game
- screens. We use the ParticleSystem QML type in maroon.qml to make bubbles
- appear at the bottom of the new game screen and game canvas and slowly float
- towards the top on varying trajectories.
-
- To use the ParticleSystem type, we must import \l{Qt Quick Particles QML Types}:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto Particles
- \printuntil 0
-
- To have the particles appear on the game background, we place the
- ParticleSystem type within the \l{Image} type that displays the game
- background:
-
- \skipto Image
- \printuntil anchors.fill
-
- In the ParticleSystem, we use an \l{Emitter} type to emit particles from the
- location of the emitter at the rate of two per second with the life span of
- 15 seconds:
-
- \skipto Emitter
- \printuntil sizeVariation
- \printuntil }
-
- The \c acceleration property uses the PointDirection type to
- specify random variation of the x and y coordinates, so that the bubbles
- appear inside a rectangular area around the emitter that is anchored to the
- bottom of the image.
-
- The \c size property sets the base size of the particles at the beginning of
- their life to 24 pixels and the \c sizeVariation property randomly increases
- or decreases the particle size by up to 16 pixels, so that we get bubbles in
- different sizes.
-
- As emitters have no visualization, we use the ImageParticle type to render
- the catch.png image at the particle location:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto ImageParticle
- \printuntil }
-
- A \l{Wander} type applies a random trajectory to the particles, so that the
- bubbles follow random routes from the bottom to the top.
-
- \printuntil }
-
- For another example of using the ParticleSystem type, see the
- GameOverScreen.qml file, where an ImageParticle type is used to make clouds
- move across the sky.
-
- \section1 Using Timers
-
- \image qtquick-demo-maroon-med-4.jpg
-
- In maroon.qml, we use the \l{Timer} type with a \l{Repeater} type to display
- a countdown sequence before using another timer to start a new game. Both
- timers are started simultaneously in the \c "gameOn" state, that is when the
- players tap the New Game button and \c passedSplash is \c true. This is
- explained in more detail in \l{Managing Game States}.
-
- We use the \c countdownTimer to display the countdown sequence:
-
- \skipto Timer
- \printuntil }
-
- The \c onTriggered signal handler is called when the timer is triggered to
- increment the value of the \c countdown custom property.
-
- We set the \c repeat property to \c true to specify that the timer is
- triggered at the interval of 1 second as long as the value of \c countdown
- is less than 5.
-
- The \c countdown property is defined in the root item with an initial value
- of \c 10, so that \c countdownTimer is not running by default:
-
- \skipto countdown:
- \printuntil 10
-
- Each time the timer is triggered, an image from the countdown sequence is
- displayed. We use a \l{Repeater} type to instantiate the \l{Image} delegate
- in the context of the repeater's parent, \c canvasArea item, seeded with
- data from the \c model:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto Repeater
- \printuntil scale
- \printuntil }
- \printuntil }
- \printuntil }
- \printuntil }
-
- We scale the images from \c 0.0 to \c 1.0 and use the \c visible property to
- hide the images for the previous steps as the countdown progresses. We also
- raise the opacity of the image that matches the current countdown step,
- keeping the others nearly transparent.
-
- By animating the changes in the \c opacity and \c scale properties using a
- \l Behavior type, we achieve a countdown sequence where numbers zoom in
- towards the players.
-
- \section1 Constructing the Game Board
-
- To construct the game board, we use the GameCanvas custom type that is
- defined in GameCanvas.qml.
-
- In maroon.qml, we use the GameCanvas type to display the game canvas
- at the position of 32 on the x axis and 20 pixels from the bottom of
- its parent item, \c canvasArea:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto GameCanvas
- \printuntil }
-
- We set the \c focus property to \c true to give \c canvas active focus on
- startup.
-
- In GameCanvas.qml, we use an \l Item type and define custom properties for
- it to create a grid of equally sized squares divided to 4 columns on 6 rows:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto Item
- \printuntil canvas
-
- We use the custom properties to set the \c width and \c height of the
- \c grid item as the amount of columns and rows multiplied by square size:
-
- \skipto width
- \printuntil height
-
- We use an \l{Image} type with a MouseArea type to display a help button
- that the players can tap to view an image that contains instructions for
- playing the game:
-
- \skipuntil endGame
- \skipto Image
- \printuntil bottomMargin
- \printuntil }
-
- We declare the \c goAway() private function to disable the mouse area and
- make the image fully transparent and a \c comeBack() function to enable the
- mouse area and make the button fully opaque. We use a \l {Behavior} type on
- the \c opacity property to apply the default number animation when the value
- of \c opacity changes.
-
- When the players tap the help button, the \c onClicked signal handler is
- called to hide the help button by setting the \c {helpButton.visible}
- property to \c false and to show the help image by setting the
- \c {helpImage.visible} property to \c false.
-
- \image qtquick-demo-maroon-med-6.jpg
-
- We use anchoring to position the help button at the bottom center of the
- game canvas.
-
- We use another \l{Image} type to display the help image:
-
- \printuntil }
- \printuntil }
-
- To hide the help image when the players tap it, the \c onClicked signal
- handler within the MouseArea type is called to set the \c{helpImage.visible}
- property to \c true.
-
- To ensure that the images are placed on top when they are visible, we set
- a high value for their \c z property.
-
- The following sections describe how to use timers to add animated objects to
- the game board and how to create a menu dialog from which the players can
- add more objects to it.
-
- \section1 Animating Objects on the Game Board
-
- We use sprite animation to animate objects on the game board. The Qt Quick
- \l{Sprite Animations}{sprite engine} is a stochastic state machine combined
- with the ability to chop up images containing multiple frames of an
- animation.
-
- \section2 Spawning Fish
-
- We use a \l{Timer} element with the \c tick() function in GameCanvas.qml to
- spawn mobs of fish in waves at an increasing rate, starting at 16
- milliseconds:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto Timer
- \printuntil }
-
- We use the MobBase custom type that is defined in MobBase.qml to
- animate mobs of fish that swim inside bubbles. We use an \l{Item} type with
- custom properties and private functions to create the fish and the bubbles
- and to define the actions that can be applied to them:
-
- \quotefromfile demos/maroon/content/mobs/MobBase.qml
- \skipto Item
- \printuntil }
- \dots
-
- We use a SpriteSequence type to animate the fish:
-
- \skipto SpriteSequence
- \printuntil goalSprite
-
- The SpriteSequence type renders and controls a list of animations
- defined by \l{Sprite} types:
-
- \skipto Sprite {
- \printuntil name: "right"
- \printuntil }
- \printuntil }
-
- In the \c fishSprite sprite sequence, each sprite defines one frame within
- the mob-idle.png file, which shows a fish facing right, front, and left:
-
- \image ../../content/gfx/mob-idle.png
-
- We use the \c frameWidth, \c frameHeight, and \c frameX properties to
- determine that the first 64x64-pixel square of the image is framed in the
- \c "left" sprite, the second in the \c "front" sprite, and the third in the
- \c "right" sprite. For each sprite, the \c frameCount property is set to
- \c 1 to specify that the sprite contains one frame.
-
- We use the \c frameDuration and \c frameDurationVariation properties to
- specify that the duration of an animation can vary from \c 400 to \c 1200
- milliseconds.
-
- The \c to property specifies that the sprites have weighted transitions to
- other sprites. The \c "left" and \c "right" sprites always transfer to the
- \c "front" sprite. When the \c "front" animation finishes, the sprite engine
- chooses \c "left" or \c "right" randomly, but at roughly equal proportions,
- because they both have the weight \c 1.
-
- When the fish are set free, we want them to swim away in the direction they
- are facing until they get off the screen. If they were facing front, we use
- the \c jumpTo method with the JavaScript \c {Math.random()} method in the
- \c die() private function to randomly jump to the \c "left" or \c "right"
- sprite:
-
- \quotefromfile demos/maroon/content/mobs/MobBase.qml
- \skipto die()
- \printuntil }
-
- We then use the \c start() function to run a NumberAnimation that applies a
- number animation to the x value from its current value to \c -360 or \c 360,
- depending on whether the \c goingLeft custom property is \c true, in 300
- milliseconds:
-
- \skipto NumberAnimation
- \printuntil }
-
- \section2 Bursting Bubbles
-
- We use another SpriteSequence to animate the bubbles so that they
- become smaller and finally burst when they are attacked by a shooter or
- a melee. For this effect, we set the value of the \c scale property to
- decrease by \c 0.2 each time the custom \c hp property changes:
-
- \skipto SpriteSequence
- \printuntil goalSprite
-
- We use a \l{Behavior} type to apply a NumberAnimation when the value of
- \c scale changes. We use the \c{Easing.OutBack} easing type for a back
- (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out curve that
- decelerates the motion to zero velocity in 150 milliseconds:
-
- \skipto Behavior
- \printuntil }
- \printuntil }
-
- The SpriteSequence consist of two sprites that display different images. The
- first sprite, \c "big", uses the catch.png image to display an empty bubble:
-
- \skipto Sprite
- \printuntil }
- \printuntil }
-
- We set the \c to property to \c "burst" with the weight \c 0 to make the
- second sprite, \c "burst", a valid goal for the \c jumpTo method that we use
- in the \c die() private function to jump directly to the \c "burst" sprite
- without playing the first sprite.
-
- In the \c "burst" sprite, we set the \c frameCount property to \c 3 and the
- \c frameX property to \c 64 to specify that the animation starts at pixel
- location 64 and loads each frame for the duration of 200 milliseconds.
-
- \skipto Sprite
- \printuntil }
-
- Within the SpriteSequence, we use SequentialAnimation with NumberAnimation
- to animate the transitions between the frames. To create a pulsating effect
- on the bubbles, we apply a sequential animation on the \c width property
- with two number animations to first increase the bubble width from
- \c{* 1} to \c{* 1.1} over 800 milliseconds and then bring it back over 1
- second:
-
- \skipto SequentialAnimation
- \printuntil }
- \printuntil }
- \printuntil }
-
- Similarly, we increase the bubble height from \c{* 1} to \c{* 1.15} over
- 1200 milliseconds and then bring it back over 1 second:
-
- \skipto SequentialAnimation
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use yet another SpriteSequence to display the effect of squid ink on the
- bubbles. For more examples of using sprite sequences, see the QML files in
- the \c towers directory.
-
- \section1 Adding Dialogs
-
- \image qtquick-demo-maroon-med-5.jpg
-
- In GameCanvas.qml, we use an \l{Image} type with some custom properties to
- create a menu where the players can buy tower objects:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto Image
- \printuntil towerExists
-
- We set the \c visible property to \c false to hide the menu by default. The
- \c z property is set to 1500 to ensure that the menu is displayed in front
- of all other items when it is visible.
-
- We use a MouseArea type to open or close the menu when players tap on the
- canvas:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto MouseArea
- \printuntil }
- \printuntil }
-
- We set the \c anchors.fill property to \c parent to allow the players to tap
- anywhere on the game canvas. We use a condition in the \c onClicked
- signal handler to call the \c {finish()} function if the menu is visible
- and the \c {open()} function otherwise.
-
- The \c {finish()} function hides the menu by setting the \c shown custom
- property to \c false:
-
- \skipto finish
- \printuntil }
-
- The \c {open()} function displays the menu at the x and y position of the
- mouse pointer:
-
- \printuntil }
-
- If \c gameRunning is \c true, we call the JavaScript \c row() function to
- calculate the value of the \c targetRow custom property and the \c col()
- function to calculate the value of the \c targetCol custom property. If
- the value of \c targetRow equals \c 0, the y position is set to one square
- above the mouse pointer. Otherwise, it is set to one square below the mouse
- pointer.
-
- We use the \c towerIdx() function to set the value of the \c towerExists
- custom property.
-
- We set the \c shown custom property to \c true to show the menu and call the
- \c {helpButton.goAway()} function to hide the help button when the menu
- opens.
-
- We use states and transitions to display the menu when the \c shown
- property is \c true and the \c gameOver property is \c false:
-
- \printuntil OutElastic
- \printuntil }
-
- To set the visibility of the menu to \c "visible" without animating the
- property change, we use a PropertyAction type. We do want to animate the
- changes in opacity and scale, though, so we use number animation to
- animate the value of the \c scale property from \c 0.9 to \c 1 and the
- value of \c opacity property from \c 0.7 to \c 1, over 500 milliseconds.
- We use the \c {Easing.outElastic} easing type for an elastic (exponentially
- decaying sine wave) function easing curve that decelerates from zero
- velocity.
-
- To construct the menu, we use a BuildButton custom type that is defined in
- BuildButton.qml. In GameCanvas.qml, we create one build button for each
- tower object that the players can buy and position them in a \l{Row} layout
- in front of the menu background image, dialog.png:
-
- \printuntil dialog-factory.png
- \printuntil }
- \printuntil }
- \printuntil }
-
- For each build button, we set the values of \c towerType and \c index custom
- properties that we define in BuildButton.qml.
-
- We use the \c canBuild custom property to prevent players from adding tower
- objects in locations where tower objects already exist.
-
- We use the \c source property to display the image for the tower type.
-
- The \c onClicked signal handler is called to execute the \c finish()
- function that closes the menu when the players tap an enabled build button.
-
- Build buttons are enabled when the players have enough coins to buy the
- tower objects. We use an \l {Image} type in BuildButton.qml to display
- images on the buttons:
-
- \quotefromfile demos/maroon/content/BuildButton.qml
- \skipto Image
- \printuntil }
-
- We use the \c opacity property to make the buttons appear enabled. If
- \c canBuild is \c true and the value of the \c gameCanvas.coins property
- is larger than or equal to the cost of a tower object, the images are fully
- opaque, otherwise their opacity is set to \c 0.4.
-
- We use a \l{Text} type to display the cost of each tower item, as specified
- by the \c towerData variable, depending on \c towerType:
-
- \skipto Text
- \printuntil }
-
- To display a pointer on the screen at the position where the tower object
- will be added, we use the \l {Image} type. We use the \c visible property
- to determine whether the dialog-pointer.png image should be positioned below
- or above the menu. When the value of the \c col property equals the \c index
- and the value or the \c row property is not \c 0, we anchor the image to the
- bottom of its parent, BuildButton.
-
- When the value or the \c row property is \c 0, we anchor the image to the
- top of BuildButton to position the pointer above the menu and use the
- \c rotation property to rotate it by 180 degrees, so that it points upwards:
-
- \skipto Image
- \printuntil }
- \printuntil }
-
- \section1 Keeping Track of Game Statistics
-
- To keep track of the game statistics, we use the InfoBar custom type (that
- is defined in InfoBar.qml) in maroon.qml:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto InfoBar
- \printuntil }
-
- We use the \c {anchors.bottom} and \c {anchors.bottomMargin} properties to
- position the info bar at 6 points from the top of the game canvas. We bind
- the \c width property of the info bar to that of its parent.
-
- In InfoBar.qml, we use an \l{Item} type to create the info bar. Within it,
- we use a \l{Row} layout type to display the number of lives the players have
- left, the number of fish that have been saved, and the amount of coins that
- are available for use.
-
- We use the \c anchors property to position the rows in relationship to their
- parent and to each other. In the first \l{Row} object, we use the
- \c {anchors.left} and \c {anchors.leftMargin} properties to position the
- heart icons at 10 points from the left border of the parent item:
-
- \quotefromfile demos/maroon/content/InfoBar.qml
- \skipto Item
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use a \l{Repeater} type with a \c model and a \c delegate to display as
- many hearts as the players have lives left. We use the \c spacing property
- to leave 5 pixels between the displayed icons.
-
- In the second \l{Row} object, we use the \c {anchors.right} and
- \c {anchors.rightMargin} properties to position the number of fish saved at
- 20 points left of the third \l{Row} object that displays the number of coins
- available (and has the id \c points):
-
- \skipto Row
- \printuntil /^\}/
-
- In these objects, we set spacing to 5 pixels to separate the icons from the
- numbers that we display by using a \l{Text} type.
-
- In GameCanvas.qml, we define custom properties to hold the game statistics:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto score
- \printuntil lives
-
- We declare the \c freshState() function to set the initial game statistics
- when a new game starts:
-
- \skipto freshState()
- \printuntil }
-
- We use the \c {Logic.gameState.score} variable in the \c die() function
- that we declare in MobBase.qml to increase the score by one when the players
- set a fish free:
-
- \quotefromfile demos/maroon/content/mobs/MobBase.qml
- \skipto score
- \printuntil ;
-
- \section1 Managing Game States
-
- In maroon.qml, we use a \l{State} type and JavaScript to switch between
- screens according to the game state. The logic.js file contains definitions
- for the functions. To use the functions in a QML file, we import logic.js as
- the \c Logic namespace in that file:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto logic.js
- \printuntil Logic
-
- The base state displays the new game screen when the application starts.
- In addition, we call the Component.onCompleted signal handler to initialize
- a new game:
-
- \skipto newGameState
- \printuntil ;
-
- In NewGameScreen.qml we use the \c onClicked signal handler to emit the
- \c startButtonClicked() signal when the players tap the New Game button:
-
- \quotefromfile demos/maroon/content/NewGameScreen.qml
- \skipto to: 150
- \skipto Image
- \printuntil }
-
- In maroon.qml, we use the \c onStartButtonClicked signal handler to set the
- \c passedSplash property of the \c root item to \c true:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto NewGameScreen
- \printuntil }
-
- We then use the \c passedSplash property in the \c when property of the
- \c gameOn state to trigger the \c gameStarter timer:
-
- \skipto State {
- \printuntil gameStarter
- \printuntil }
-
- We also switch to the \c "gameOn" state and move to the y position
- \c {-(height - 960)} to display the game canvas.
-
- In the \c gameStarter \l{Timer} object we use the \c onTriggered signal
- handler to call the \c startGame() function that starts a new game:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto property int
- \skipto Timer
- \printuntil }
-
- The game continues until \c gameState.gameOver is set to \c true and
- \c gameState.gameRunning is set to \c false by calling the \c endGame()
- function when the value of the \c gameState.lives property becomes less
- than or equal to \c 0.
-
- In GameOverScreen.qml, we use a MouseArea type and an \c onClicked signal
- handler within an \l{Image} type to return to the game canvas when the
- players tap the New Game button:
-
- \quotefromfile demos/maroon/content/GameOverScreen.qml
- \skipto opacity: 0.5
- \skipto Image
- \printuntil }
- \printuntil }
-
- The \c onClicked signal handler triggers a state change in maroon.qml to
- display the game canvas:
-
- \quotefromfile demos/maroon/maroon.qml
- \skipto target: gameStarter
- \skipto State
- \printuntil }
- \printuntil }
-
- \section1 Playing Sound Effects
-
- The app can play sound effects if the \l{Qt Multimedia} module is installed.
- In the SoundEffect.qml file, we proxy a SoundEffect type:
-
- \quotefromfile demos/maroon/content/SoundEffect.qml
- \skipto Item
- \printuntil }
- \printuntil }
-
- We add the \c qtHaveModule() qmake command to the app .pro file, maroon.pro,
- to check whether the \l{Qt Multimedia} module is present:
-
- \quotefromfile demos/maroon/maroon.pro
- \skipto QT
- \printuntil multimedia
-
- In each QML file that defines a custom type used on the game canvas, we
- use a SoundEffect type to specify the audio file to play for that type
- of objects. For example, in Bomb.qml, we specify the sound that a bomb
- makes when it explodes:
-
- \quotefromfile demos/maroon/content/towers/Bomb.qml
- \skipto SoundEffect
- \printuntil }
-
- To play the sound effect when a bomb explodes, we call the \c sound.play()
- function that we declare as a member of the private \c fire() function
- within the TowerBase custom type:
-
- \quotefromfile demos/maroon/content/towers/Bomb.qml
- \skipto fire()
- \printuntil }
-
- For more examples of playing sound effects, see the QML files in the
- \c towers directory and MobBase.qml.
-
- \section1 Adding Keyboard Shortcuts
-
- This is a touch example, so you should not really need to handle key
- presses. However, we do not want you to have to spend more time playing the
- game than you want to while testing it, so we use the \c {Keys.onPressed}
- signal handler to specify keyboard shortcuts. You can press Shift+Up to
- increment the values of the \c coins property to add coins, Shift+Left to
- increment the value of \c lives, Shift+Down to increment the value of the
- \c waveProgress property to spawn mobs of fish faster, and Shift+Right to
- call the \c endGame() function to quit the game:
-
- \quotefromfile demos/maroon/content/GameCanvas.qml
- \skipto Keys
- \printuntil }
-
- \section1 Packaging Resources for Deployment
-
- To be able to run the app on mobile devices, we package all QML, JavaScript,
- image, and sound files into a Qt resource file (.qrc). For more information,
- see \l{The Qt Resource System}.
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/maroon/maroon.pro b/examples/quick/demos/maroon/maroon.pro
deleted file mode 100644
index ada16d047a..0000000000
--- a/examples/quick/demos/maroon/maroon.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-qtHaveModule(multimedia): QT += multimedia
-SOURCES += main.cpp
-RESOURCES += maroon.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/maroon
-INSTALLS += target
diff --git a/examples/quick/demos/maroon/maroon.qml b/examples/quick/demos/maroon/maroon.qml
deleted file mode 100644
index d05ef57b64..0000000000
--- a/examples/quick/demos/maroon/maroon.qml
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content"
-import "content/logic.js" as Logic
-
-Item {
- id: root
- width: 320
- height: 480
- property var gameState
- property bool passedSplash: false
-
- Image {
- source:"content/gfx/background.png"
- anchors.bottom: view.bottom
-
- ParticleSystem {
- id: particles
- anchors.fill: parent
-
- ImageParticle {
- id: bubble
- anchors.fill: parent
- source: "content/gfx/catch.png"
- opacity: 0.25
- }
-
- Wander {
- xVariance: 25;
- pace: 25;
- }
-
- Emitter {
- width: parent.width
- height: 150
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 3
- startTime: 15000
-
- emitRate: 2
- lifeSpan: 15000
-
- acceleration: PointDirection{ y: -6; xVariation: 2; yVariation: 2 }
-
- size: 24
- sizeVariation: 16
- }
- }
- }
-
- Column {
- id: view
- y: -(height - 480)
- width: 320
-
- GameOverScreen { gameCanvas: canvas }
-
- Item {
- id: canvasArea
- width: 320
- height: 480
-
- Row {
- height: childrenRect.height
- Image {
- id: wave
- y: 30
- source:"content/gfx/wave.png"
- }
- Image {
- y: 30
- source:"content/gfx/wave.png"
- }
- NumberAnimation on x { from: 0; to: -(wave.width); duration: 16000; loops: Animation.Infinite }
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
- NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
- }
- }
-
- Row {
- opacity: 0.5
- Image {
- id: wave2
- y: 25
- source: "content/gfx/wave.png"
- }
- Image {
- y: 25
- source: "content/gfx/wave.png"
- }
- NumberAnimation on x { from: -(wave2.width); to: 0; duration: 32000; loops: Animation.Infinite }
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
- NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
- }
- }
-
- Image {
- source: "content/gfx/sunlight.png"
- opacity: 0.02
- y: 0
- anchors.horizontalCenter: parent.horizontalCenter
- transformOrigin: Item.Top
- SequentialAnimation on rotation {
- loops: Animation.Infinite
- NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
- NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
- }
- }
-
- Image {
- source: "content/gfx/sunlight.png"
- opacity: 0.04
- y: 20
- anchors.horizontalCenter: parent.horizontalCenter
- transformOrigin: Item.Top
- SequentialAnimation on rotation {
- loops: Animation.Infinite
- NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
- NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
- }
- }
-
- Image {
- source: "content/gfx/grid.png"
- opacity: 0.5
- }
-
- GameCanvas {
- id: canvas
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 20
- x: 32
- focus: true
- }
-
- InfoBar { anchors.bottom: canvas.top; anchors.bottomMargin: 6; width: parent.width }
-
- //3..2..1..go
- Timer {
- id: countdownTimer
- interval: 1000
- running: root.countdown < 5
- repeat: true
- onTriggered: root.countdown++
- }
- Repeater {
- model: ["content/gfx/text-blank.png", "content/gfx/text-3.png", "content/gfx/text-2.png", "content/gfx/text-1.png", "content/gfx/text-go.png"]
- delegate: Image {
- visible: root.countdown <= index
- opacity: root.countdown == index ? 0.5 : 0.1
- scale: root.countdown >= index ? 1.0 : 0.0
- source: modelData
- Behavior on opacity { NumberAnimation {} }
- Behavior on scale { NumberAnimation {} }
- }
- }
- }
-
- NewGameScreen {
- onStartButtonClicked: root.passedSplash = true
- }
- }
-
- property int countdown: 10
- Timer {
- id: gameStarter
- interval: 4000
- running: false
- repeat: false
- onTriggered: Logic.startGame(canvas);
- }
-
- states: [
- State {
- name: "gameOn"; when: gameState.gameOver == false && passedSplash
- PropertyChanges { target: view; y: -(height - 960) }
- StateChangeScript { script: root.countdown = 0; }
- PropertyChanges { target: gameStarter; running: true }
- },
- State {
- name: "gameOver"; when: gameState.gameOver == true
- PropertyChanges { target: view; y: 0 }
- }
- ]
-
- transitions: Transition {
- NumberAnimation { properties: "x,y"; duration: 1200; easing.type: Easing.OutQuad }
- }
-
- Component.onCompleted: gameState = Logic.newGameState(canvas);
-}
diff --git a/examples/quick/demos/maroon/maroon.qmlproject b/examples/quick/demos/maroon/maroon.qmlproject
deleted file mode 100644
index 752666114f..0000000000
--- a/examples/quick/demos/maroon/maroon.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "maroon.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/maroon/maroon.qrc b/examples/quick/demos/maroon/maroon.qrc
deleted file mode 100644
index 52c2a4e513..0000000000
--- a/examples/quick/demos/maroon/maroon.qrc
+++ /dev/null
@@ -1,71 +0,0 @@
-<RCC>
- <qresource prefix="/demos/maroon">
- <file>maroon.qml</file>
- <file>content/BuildButton.qml</file>
- <file>content/GameCanvas.qml</file>
- <file>content/GameOverScreen.qml</file>
- <file>content/InfoBar.qml</file>
- <file>content/logic.js</file>
- <file>content/NewGameScreen.qml</file>
- <file>content/SoundEffect.qml</file>
- <file>content/audio/bomb-action.wav</file>
- <file>content/audio/catch-action.wav</file>
- <file>content/audio/catch.wav</file>
- <file>content/audio/currency.wav</file>
- <file>content/audio/factory-action.wav</file>
- <file>content/audio/melee-action.wav</file>
- <file>content/audio/projectile-action.wav</file>
- <file>content/audio/shooter-action.wav</file>
- <file>content/gfx/background.png</file>
- <file>content/gfx/bomb-action.png</file>
- <file>content/gfx/bomb-idle.png</file>
- <file>content/gfx/bomb.png</file>
- <file>content/gfx/button-help.png</file>
- <file>content/gfx/button-play.png</file>
- <file>content/gfx/catch-action.png</file>
- <file>content/gfx/catch.png</file>
- <file>content/gfx/cloud.png</file>
- <file>content/gfx/currency.png</file>
- <file>content/gfx/dialog-bomb.png</file>
- <file>content/gfx/dialog-factory.png</file>
- <file>content/gfx/dialog-melee.png</file>
- <file>content/gfx/dialog-pointer.png</file>
- <file>content/gfx/dialog-shooter.png</file>
- <file>content/gfx/dialog.png</file>
- <file>content/gfx/factory-action.png</file>
- <file>content/gfx/factory-idle.png</file>
- <file>content/gfx/factory.png</file>
- <file>content/gfx/grid.png</file>
- <file>content/gfx/help.png</file>
- <file>content/gfx/lifes.png</file>
- <file>content/gfx/logo-bubble.png</file>
- <file>content/gfx/logo-fish.png</file>
- <file>content/gfx/logo.png</file>
- <file>content/gfx/melee-action.png</file>
- <file>content/gfx/melee-idle.png</file>
- <file>content/gfx/melee.png</file>
- <file>content/gfx/mob-idle.png</file>
- <file>content/gfx/mob.png</file>
- <file>content/gfx/points.png</file>
- <file>content/gfx/projectile-action.png</file>
- <file>content/gfx/projectile.png</file>
- <file>content/gfx/scores.png</file>
- <file>content/gfx/shooter-action.png</file>
- <file>content/gfx/shooter-idle.png</file>
- <file>content/gfx/shooter.png</file>
- <file>content/gfx/sunlight.png</file>
- <file>content/gfx/text-1.png</file>
- <file>content/gfx/text-2.png</file>
- <file>content/gfx/text-3.png</file>
- <file>content/gfx/text-blank.png</file>
- <file>content/gfx/text-gameover.png</file>
- <file>content/gfx/text-go.png</file>
- <file>content/gfx/wave.png</file>
- <file>content/mobs/MobBase.qml</file>
- <file>content/towers/Bomb.qml</file>
- <file>content/towers/Factory.qml</file>
- <file>content/towers/Melee.qml</file>
- <file>content/towers/Ranged.qml</file>
- <file>content/towers/TowerBase.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png b/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png
deleted file mode 100644
index a0cd823999..0000000000
--- a/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photosurface/doc/src/photosurface.qdoc b/examples/quick/demos/photosurface/doc/src/photosurface.qdoc
deleted file mode 100644
index dd1b2fe79f..0000000000
--- a/examples/quick/demos/photosurface/doc/src/photosurface.qdoc
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Photo Surface
- \ingroup qtquickdemos
- \example demos/photosurface
- \brief A QML app for touch devices that uses a Repeater with a
- FolderListModel to access content in a folder, and a PinchArea that contains
- a MouseArea to handle pinch gestures on the fetched content.
- \image qtquick-demo-photosurface-small.png
-
- \e{Photo Surface} demonstrates how to use a \l{Repeater} with a
- FolderListModel and a FileDialog to access images from a folder selected
- by a user and how to handle dragging, rotation and pinch zooming within the
- same item using a \l PinchArea that contains a \l MouseArea.
-
- All the app code is contained in one QML file, photosurface.qml. Inline
- JavaScript code is used to place, rotate, and scale images on the photo
- surface.
-
- \include examples-run.qdocinc
-
- \section1 Creating the Main Window
-
- To create the main window for the Photo Surface app, we use the \l{Window}
- QML type as the root item. It automatically sets up the window for use with
- \l{Qt Quick} graphical types:
-
- \quotefromfile demos/photosurface/photosurface.qml
- \skipto Window {
- \printuntil currentFrame
-
- To use the \l{Window} type, we must import it:
-
- \code
- import QtQuick.Window 2.1
- \endcode
-
- \section1 Accessing Folder Contents
-
- We use a \l{Repeater} QML type together with the FolderListModel to display
- GIF, JPG, and PNG images located in a folder:
-
- \quotefromfile demos/photosurface/photosurface.qml
- \skipto Repeater
- \printuntil }
-
- To use the FolderListModel type, we must import it:
-
- \code
- import Qt.labs.folderlistmodel 1.0
- \endcode
-
- We use a FileDialog to enable users to select the folder that contains
- the images:
-
- \quotefromfile demos/photosurface/photosurface.qml
- \skipto FileDialog
- \printuntil }
-
- To use the FileDialog type, we must import \l{Qt Quick Dialogs}:
-
- \code
- import QtQuick.Dialogs 1.0
- \endcode
-
- We use the \c {fileDialog.open()} function to open the file dialog when the
- app starts:
-
- \code
- Component.onCompleted: fileDialog.open()
- \endcode
-
- Users can also click the file dialog icon to open the file dialog. We use
- an \l{Image} QML type to display the icon. Inside the \l{Image} type, we
- use a MouseArea with the \c onClicked signal handler to call the
- \c {fileDialog.open()} function:
-
- \quotefromfile demos/photosurface/photosurface.qml
- \skipuntil Image {
- \skipto Image {
- \printuntil }
- \printuntil }
-
- \section1 Displaying Images on the Photo Surface
-
- We use a \l{Rectangle} as a delegate for a \l{Repeater} to provide a frame
- for each image that the FolderListModel finds in the selected folder. We use
- JavaScript \c Math() methods to place the frames randomly on the photo
- surface and to rotate them at random angles, as well as to scale the images:
-
- \quotefromfile demos/photosurface/photosurface.qml
- \skipto Rectangle
- \printuntil Component.onCompleted
- \printuntil }
-
- \section1 Handling Pinch Gestures
-
- We use a PinchArea that contains a MouseArea in the photo frames to handle
- dragging, rotation and pinch zooming of the frame:
-
- \skipto PinchArea
- \printuntil onPinchStarted
-
- We use the \c pinch group property to control how the photo frames react to
- pinch gestures. The \c pinch.target sets \c photoFrame as the item to
- manipulate. The rotation properties specify that the frames can be rotated
- at all angles and the scale properties specify that they can be scaled
- between \c 0.1 and \c 10.
-
- In the MouseArea's \c onPressed signal handler, we raise the selected photo
- frame to the top by increasing the value of its \c z property. The root item
- stores the z value of the top-most frame. The border color of the photo
- frame is controlled in the \c onEntered signal handler to highlight the
- selected image:
-
- \skipto MouseArea
- \printuntil onEntered
-
- To enable you to test the example on the desktop, we use the MouseArea's
- \c onWheel signal handler to simulate pinch gestures by using a mouse:
-
- \printuntil photoFrame.scale
- \printuntil }
- \printuntil }
-
- The \c onWheel signal handler is called in response to mouse wheel gestures.
- Use the vertical wheel to zoom and Ctrl and the vertical wheel to rotate
- frames. If the mouse has a horizontal wheel, use it to rotate frames.
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/photosurface/main.cpp b/examples/quick/demos/photosurface/main.cpp
deleted file mode 100644
index d1522bd09c..0000000000
--- a/examples/quick/demos/photosurface/main.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifdef QT_WIDGETS_LIB
-#include <QtWidgets/QApplication>
-#else
-#include <QtGui/QGuiApplication>
-#endif
-#include <QtQml/QQmlApplicationEngine>
-#include <QtQml/QQmlContext>
-#include <QtQuick/QQuickWindow>
-#include <QtGui/QImageReader>
-#include <QtCore/QCommandLineParser>
-#include <QtCore/QCommandLineOption>
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QMimeDatabase>
-#include <QtCore/QStandardPaths>
-#include <QtCore/QUrl>
-
-static QStringList imageNameFilters()
-{
- QStringList result;
- QMimeDatabase mimeDatabase;
- const auto supportedMimeTypes = QImageReader::supportedMimeTypes();
- for (const QByteArray &m : supportedMimeTypes) {
- const auto suffixes = mimeDatabase.mimeTypeForName(m).suffixes();
- for (const QString &suffix : suffixes)
- result.append(QLatin1String("*.") + suffix);
- }
- return result;
-}
-
-int main(int argc, char* argv[])
-{
- // The reason to use QApplication is that QWidget-based dialogs
- // are the native dialogs on Qt-based platforms like KDE,
- // but they cannot be instantiated if this is a QGuiApplication.
-#ifdef QT_WIDGETS_LIB
- QApplication app(argc, argv);
-#else
- QGuiApplication app(argc, argv);
-#endif
- QQuickWindow::setDefaultAlphaBuffer(true);
-
- QCoreApplication::setApplicationName(QStringLiteral("Photosurface"));
- QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
- QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
- QCommandLineParser parser;
- parser.setApplicationDescription(QStringLiteral("Qt Quick Demo - Photo Surface"));
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument(QStringLiteral("directory"),
- QStringLiteral("The image directory or URL to show."));
- parser.process(app);
-
- QUrl initialUrl;
- if (!parser.positionalArguments().isEmpty()) {
- initialUrl = QUrl::fromUserInput(parser.positionalArguments().first(),
- QDir::currentPath(), QUrl::AssumeLocalFile);
- if (!initialUrl.isValid()) {
- qWarning().nospace() << "Invalid argument: \""
- << parser.positionalArguments().first() << "\": " << initialUrl.errorString();
- return 1;
- }
- }
-
- const QStringList nameFilters = imageNameFilters();
-
- QQmlApplicationEngine engine;
- QQmlContext *context = engine.rootContext();
-
- QUrl picturesLocationUrl = QUrl::fromLocalFile(QDir::homePath());
- const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
- if (!picturesLocations.isEmpty()) {
- picturesLocationUrl = QUrl::fromLocalFile(picturesLocations.first());
- if (initialUrl.isEmpty()
- && !QDir(picturesLocations.first()).entryInfoList(nameFilters, QDir::Files).isEmpty()) {
- initialUrl = picturesLocationUrl;
- }
- }
-
- context->setContextProperty(QStringLiteral("contextPicturesLocation"), picturesLocationUrl);
- context->setContextProperty(QStringLiteral("contextInitialUrl"), initialUrl);
- context->setContextProperty(QStringLiteral("contextImageNameFilters"), nameFilters);
-
- engine.load(QUrl("qrc:///photosurface.qml"));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
diff --git a/examples/quick/demos/photosurface/photosurface.pro b/examples/quick/demos/photosurface/photosurface.pro
deleted file mode 100644
index 5e5b0f0815..0000000000
--- a/examples/quick/demos/photosurface/photosurface.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-qtHaveModule(widgets): QT += widgets
-SOURCES += main.cpp
-RESOURCES += photosurface.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/photosurface
-INSTALLS += target
-ICON = resources/icon.png
-macx: ICON = resources/photosurface.icns
-win32: RC_FILE = resources/photosurface.rc
-
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml
deleted file mode 100644
index 5d1445d776..0000000000
--- a/examples/quick/demos/photosurface/photosurface.qml
+++ /dev/null
@@ -1,286 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Dialogs 1.0
-import QtQuick.Window 2.1
-import Qt.labs.folderlistmodel 1.0
-
-Window {
- id: root
- visible: true
- width: 1024; height: 600
- color: "black"
- property int highestZ: 0
- property real defaultSize: 200
- property var currentFrame: undefined
- property real surfaceViewportRatio: 1.5
-
- FileDialog {
- id: fileDialog
- title: "Choose a folder with some images"
- selectFolder: true
- folder: picturesLocation
- onAccepted: folderModel.folder = fileUrl + "/"
- }
-
- Flickable {
- id: flick
- anchors.fill: parent
- contentWidth: width * surfaceViewportRatio
- contentHeight: height * surfaceViewportRatio
- Repeater {
- model: FolderListModel {
- id: folderModel
- objectName: "folderModel"
- showDirs: false
- nameFilters: imageNameFilters
- }
- Rectangle {
- id: photoFrame
- width: image.width * (1 + 0.10 * image.height / image.width)
- height: image.height * 1.10
- scale: defaultSize / Math.max(image.sourceSize.width, image.sourceSize.height)
- Behavior on scale { NumberAnimation { duration: 200 } }
- Behavior on x { NumberAnimation { duration: 200 } }
- Behavior on y { NumberAnimation { duration: 200 } }
- border.color: "black"
- border.width: 2
- smooth: true
- antialiasing: true
- Component.onCompleted: {
- x = Math.random() * root.width - width / 2
- y = Math.random() * root.height - height / 2
- rotation = Math.random() * 13 - 6
- }
- Image {
- id: image
- anchors.centerIn: parent
- fillMode: Image.PreserveAspectFit
- source: folderModel.folder + fileName
- antialiasing: true
- }
- PinchArea {
- anchors.fill: parent
- pinch.target: photoFrame
- pinch.minimumRotation: -360
- pinch.maximumRotation: 360
- pinch.minimumScale: 0.1
- pinch.maximumScale: 10
- pinch.dragAxis: Pinch.XAndYAxis
- onPinchStarted: setFrameColor();
- property real zRestore: 0
- onSmartZoom: {
- if (pinch.scale > 0) {
- photoFrame.rotation = 0;
- photoFrame.scale = Math.min(root.width, root.height) / Math.max(image.sourceSize.width, image.sourceSize.height) * 0.85
- photoFrame.x = flick.contentX + (flick.width - photoFrame.width) / 2
- photoFrame.y = flick.contentY + (flick.height - photoFrame.height) / 2
- zRestore = photoFrame.z
- photoFrame.z = ++root.highestZ;
- } else {
- photoFrame.rotation = pinch.previousAngle
- photoFrame.scale = pinch.previousScale
- photoFrame.x = pinch.previousCenter.x - photoFrame.width / 2
- photoFrame.y = pinch.previousCenter.y - photoFrame.height / 2
- photoFrame.z = zRestore
- --root.highestZ
- }
- }
-
- MouseArea {
- id: dragArea
- hoverEnabled: true
- anchors.fill: parent
- drag.target: photoFrame
- scrollGestureEnabled: false // 2-finger-flick gesture should pass through to the Flickable
- onPressed: {
- photoFrame.z = ++root.highestZ;
- parent.setFrameColor();
- }
- onEntered: parent.setFrameColor();
- onWheel: {
- if (wheel.modifiers & Qt.ControlModifier) {
- photoFrame.rotation += wheel.angleDelta.y / 120 * 5;
- if (Math.abs(photoFrame.rotation) < 4)
- photoFrame.rotation = 0;
- } else {
- photoFrame.rotation += wheel.angleDelta.x / 120;
- if (Math.abs(photoFrame.rotation) < 0.6)
- photoFrame.rotation = 0;
- var scaleBefore = photoFrame.scale;
- photoFrame.scale += photoFrame.scale * wheel.angleDelta.y / 120 / 10;
- }
- }
- }
- function setFrameColor() {
- if (currentFrame)
- currentFrame.border.color = "black";
- currentFrame = photoFrame;
- currentFrame.border.color = "red";
- }
- }
- }
- }
- }
-
- Rectangle {
- id: verticalScrollDecorator
- anchors.right: parent.right
- anchors.margins: 2
- color: "cyan"
- border.color: "black"
- border.width: 1
- width: 5
- radius: 2
- antialiasing: true
- height: flick.height * (flick.height / flick.contentHeight) - (width - anchors.margins) * 2
- y: (flick.contentY - flick.originY) * (flick.height / flick.contentHeight)
- NumberAnimation on opacity { id: vfade; to: 0; duration: 500 }
- onYChanged: { opacity = 1.0; scrollFadeTimer.restart() }
- }
-
- Rectangle {
- id: horizontalScrollDecorator
- anchors.bottom: parent.bottom
- anchors.margins: 2
- color: "cyan"
- border.color: "black"
- border.width: 1
- height: 5
- radius: 2
- antialiasing: true
- width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2
- x: (flick.contentX - flick.originY) * (flick.width / flick.contentWidth)
- NumberAnimation on opacity { id: hfade; to: 0; duration: 500 }
- onXChanged: { opacity = 1.0; scrollFadeTimer.restart() }
- }
-
- Timer { id: scrollFadeTimer; interval: 1000; onTriggered: { hfade.start(); vfade.start() } }
-
- Image {
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.margins: 10
- source: "resources/folder.png"
- MouseArea {
- anchors.fill: parent
- anchors.margins: -10
- onClicked: fileDialog.open()
- hoverEnabled: true
- onPositionChanged: {
- tooltip.visible = false
- hoverTimer.start()
- }
- onExited: {
- tooltip.visible = false
- hoverTimer.stop()
- }
- Timer {
- id: hoverTimer
- interval: 1000
- onTriggered: {
- tooltip.x = parent.mouseX
- tooltip.y = parent.mouseY
- tooltip.visible = true
- }
- }
- Rectangle {
- id: tooltip
- border.color: "black"
- color: "beige"
- width: tooltipText.implicitWidth + 8
- height: tooltipText.implicitHeight + 8
- visible: false
- Text {
- id: tooltipText
- anchors.centerIn: parent
- text: "Open an image directory (" + openShortcut.sequenceString + ")"
- }
- }
- }
- Shortcut {
- id: openShortcut
- sequence: StandardKey.Open
- onActivated: fileDialog.open()
- }
- }
-
- Text {
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 10
- color: "darkgrey"
- wrapMode: Text.WordWrap
- font.pointSize: 8
- text: "On a touchscreen: use two fingers to zoom and rotate, one finger to drag\n" +
- "With a mouse: drag normally, use the vertical wheel to zoom, horizontal wheel to rotate, or hold Ctrl while using the vertical wheel to rotate"
- }
-
- Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() }
-
- Component.onCompleted: {
- if (typeof contextInitialUrl !== 'undefined') {
- // Launched from C++ with context properties set.
- imageNameFilters = contextImageNameFilters;
- picturesLocation = contextPicturesLocation;
- if (contextInitialUrl == "")
- fileDialog.open();
- else
- folderModel.folder = contextInitialUrl + "/";
- } else {
- // Launched via QML viewer without context properties set.
- fileDialog.open();
- }
- }
-
- property var imageNameFilters : ["*.png", "*.jpg", "*.gif"];
- property string picturesLocation : "";
-}
diff --git a/examples/quick/demos/photosurface/photosurface.qmlproject b/examples/quick/demos/photosurface/photosurface.qmlproject
deleted file mode 100644
index ae2065f59c..0000000000
--- a/examples/quick/demos/photosurface/photosurface.qmlproject
+++ /dev/null
@@ -1,20 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "photosurface.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
- Files {
- filter: "*.ts"
- directory: "i18n"
- }
-}
diff --git a/examples/quick/demos/photosurface/photosurface.qrc b/examples/quick/demos/photosurface/photosurface.qrc
deleted file mode 100644
index f8fafbb1ff..0000000000
--- a/examples/quick/demos/photosurface/photosurface.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>photosurface.qml</file>
- <file>resources/folder.png</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/photosurface/resources/folder.png b/examples/quick/demos/photosurface/resources/folder.png
deleted file mode 100644
index 2aec3b6ebf..0000000000
--- a/examples/quick/demos/photosurface/resources/folder.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/icon.png b/examples/quick/demos/photosurface/resources/icon.png
deleted file mode 100644
index f8ff553fcb..0000000000
--- a/examples/quick/demos/photosurface/resources/icon.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.icns b/examples/quick/demos/photosurface/resources/photosurface.icns
deleted file mode 100644
index c69ec41c4e..0000000000
--- a/examples/quick/demos/photosurface/resources/photosurface.icns
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.ico b/examples/quick/demos/photosurface/resources/photosurface.ico
deleted file mode 100644
index 03bb7ee367..0000000000
--- a/examples/quick/demos/photosurface/resources/photosurface.ico
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photosurface/resources/photosurface.rc b/examples/quick/demos/photosurface/resources/photosurface.rc
deleted file mode 100644
index 3267bd033f..0000000000
--- a/examples/quick/demos/photosurface/resources/photosurface.rc
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "winver.h"
-
-IDI_ICON1 ICON DISCARDABLE "photosurface.ico"
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,0
- PRODUCTVERSION 1,0,0,0
- FILEFLAGS 0x0L
- FILEFLAGSMASK 0x3fL
- FILEOS 0x00040004L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000004b0"
- BEGIN
- VALUE "CompanyName", "The Qt Company Ltd"
- VALUE "FileDescription", "Photo Surface Demo"
- VALUE "FileVersion", "1.0.0.0"
- VALUE "LegalCopyright", "Copyright (C) 2015 The Qt Company Ltd."
- VALUE "InternalName", "photosurface"
- VALUE "OriginalFilename", "photosurface.exe"
- VALUE "ProductName", "Photo Surface Demo"
- VALUE "ProductVersion", "1.0.0.0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0, 1200
- END
-END
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
deleted file mode 100644
index ea72302d74..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.XmlListModel 2.0
-import QtQml.Models 2.1
-
-Component {
- id: albumDelegate
- Package {
-
- Item {
- Package.name: 'browser'
- GridView {
- id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
- x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
- onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
- }
- }
-
- Item {
- Package.name: 'fullscreen'
- ListView {
- id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
- width: mainWindow.width; height: mainWindow.height; interactive: false
- onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
- highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
- }
- }
-
- Item {
- Package.name: 'album'
- id: albumWrapper; width: 210; height: 220
-
- DelegateModel {
- id: visualModel; delegate: PhotoDelegate { }
- model: RssModel { id: rssModel; tags: tag }
- }
-
- BusyIndicator {
- id: busyIndicator
- anchors { centerIn: parent; verticalCenterOffset: -20 }
- on: rssModel.status != XmlListModel.Ready
- }
-
- PathView {
- id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
- visible: !busyIndicator.visible
- anchors.centerIn: parent; anchors.verticalCenterOffset: -30
- path: Path {
- PathAttribute { name: 'z'; value: 9999.0 }
- PathLine { x: 1; y: 1 }
- PathAttribute { name: 'z'; value: 0.0 }
- }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
- }
-
- Tag {
- anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
- frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
- onTagChanged: rssModel.tags = tag
- onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
- }
-
- states: [
- State {
- name: 'inGrid'
- PropertyChanges { target: photosGridView; interactive: true }
- PropertyChanges { target: albumsShade; opacity: 1 }
- PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
- },
- State {
- name: 'fullscreen'; extend: 'inGrid'
- PropertyChanges { target: photosGridView; interactive: false }
- PropertyChanges { target: photosListView; interactive: true }
- PropertyChanges { target: photosShade; opacity: 1 }
- PropertyChanges { target: backButton; y: -backButton.height - 8 }
- }
- ]
-
- GridView.onAdd: NumberAnimation {
- target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
- }
- GridView.onRemove: SequentialAnimation {
- PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
- NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
- PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
- }
-
- transitions: [
- Transition {
- from: '*'; to: 'inGrid'
- SequentialAnimation {
- NumberAnimation { properties: 'opacity'; duration: 250 }
- PauseAnimation { duration: 350 }
- NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
- }
- },
- Transition {
- from: 'inGrid'; to: '*'
- NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
- }
- ]
- }
- }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
deleted file mode 100644
index 836abdf6a9..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Image {
- id: container
- property bool on: false
-
- source: "images/busy.png"; visible: container.on
- NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml
deleted file mode 100644
index cd575f6d99..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: container
-
- property alias label: labelText.text
- property color tint: "transparent"
- signal clicked
-
- width: labelText.width + 70 ; height: labelText.height + 18
-
- BorderImage {
- anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
- source: 'images/box-shadow.png'
- border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
- }
-
- Image { anchors.fill: parent; source: "images/cardboard.png"; antialiasing: true }
-
- Rectangle {
- anchors.fill: container; color: container.tint; visible: container.tint != ""
- opacity: 0.25
- }
-
- Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent }
-
- MouseArea {
- anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
- onClicked: container.clicked()
- }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml
deleted file mode 100644
index 35df4107eb..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: container
-
- property string label
- signal clicked
-
- width: textInput.width + 70 ; height: textInput.height + 18
-
- BorderImage {
- anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
- source: 'images/box-shadow.png';
- border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
- }
-
- Image { anchors.fill: parent; source: "images/cardboard.png"; antialiasing: true }
-
- TextInput {
- id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent
- Keys.onReturnPressed: {
- container.label = textInput.text
- container.focus = true
- }
- Keys.onEnterPressed: {
- container.label = textInput.text
- container.focus = true
- }
- Keys.onEscapePressed: {
- textInput.text = container.label
- container.focus = true
- }
- }
-
- Rectangle {
- anchors.fill: container; border.color: "steelblue"; border.width: 4
- color: "transparent"; visible: textInput.focus; antialiasing: true
- }
-
- MouseArea {
- anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
- onClicked: { textInput.forceActiveFocus(); Qt.inputMethod.show(); }
- }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
deleted file mode 100644
index 2dcfc6158e..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "script/script.js" as Script
-
-Package {
- Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
- Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 }
- Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 }
-
- Item {
- width: 160; height: 153
-
- Item {
- id: photoWrapper
-
- property double randomAngle: Math.random() * (2 * 6 + 1) - 6
- property double randomAngle2: Math.random() * (2 * 6 + 1) - 6
-
- x: 0; y: 0; width: 140; height: 133
- z: stackItem.PathView.z; rotation: photoWrapper.randomAngle
-
- BorderImage {
- anchors {
- fill: originalImage.status == Image.Ready ? border : placeHolder
- leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8
- }
- source: 'images/box-shadow.png'
- border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
- }
- Rectangle {
- id: placeHolder
-
- property int w: Script.getWidth(content)
- property int h: Script.getHeight(content)
- property double s: Script.calculateScale(w, h, photoWrapper.width)
-
- color: 'white'; anchors.centerIn: parent; antialiasing: true
- width: w * s; height: h * s; visible: originalImage.status != Image.Ready
- Rectangle {
- color: "#878787"; antialiasing: true
- anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
- }
- }
- Rectangle {
- id: border; color: 'white'; anchors.centerIn: parent; antialiasing: true
- width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6
- visible: !placeHolder.visible
- }
- BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
- Image {
- id: originalImage; antialiasing: true;
- source: "http://" + Script.getImagePath(content); cache: false
- fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
- }
- Image {
- id: hqImage; antialiasing: true; source: ""; visible: false; cache: false
- fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
- }
- Binding {
- target: mainWindow; property: "downloadProgress"; value: hqImage.progress
- when: listItem.ListView.isCurrentItem
- }
- Binding {
- target: mainWindow; property: "imageLoading"
- value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem
- }
- MouseArea {
- width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage
- onClicked: {
- if (albumWrapper.state == 'inGrid') {
- gridItem.GridView.view.currentIndex = index;
- albumWrapper.state = 'fullscreen'
- } else {
- gridItem.GridView.view.currentIndex = index;
- albumWrapper.state = 'inGrid'
- }
- }
- }
-
- states: [
- State {
- name: 'stacked'; when: albumWrapper.state == ''
- ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 }
- PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 }
- },
- State {
- name: 'inGrid'; when: albumWrapper.state == 'inGrid'
- ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 }
- },
- State {
- name: 'fullscreen'; when: albumWrapper.state == 'fullscreen'
- ParentChange {
- target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0
- width: mainWindow.width; height: mainWindow.height
- }
- PropertyChanges { target: border; opacity: 0 }
- PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true }
- }
- ]
-
- transitions: [
- Transition {
- from: 'stacked'; to: 'inGrid'
- SequentialAnimation {
- PauseAnimation { duration: 10 * index }
- ParentAnimation {
- target: photoWrapper; via: foreground
- NumberAnimation {
- target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart'
- }
- }
- }
- },
- Transition {
- from: 'inGrid'; to: 'stacked'
- ParentAnimation {
- target: photoWrapper; via: foreground
- NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' }
- }
- },
- Transition {
- from: 'inGrid'; to: 'fullscreen'
- SequentialAnimation {
- PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 }
- ParentAnimation {
- target: photoWrapper; via: foreground
- NumberAnimation {
- targets: [ photoWrapper, border ]
- properties: 'x,y,width,height,opacity,rotation'
- duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
- }
- }
- }
- },
- Transition {
- from: 'fullscreen'; to: 'inGrid'
- ParentAnimation {
- target: photoWrapper; via: foreground
- NumberAnimation {
- targets: [ photoWrapper, border ]
- properties: 'x,y,width,height,rotation,opacity'
- duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
- }
- }
- }
- ]
- }
- }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml
deleted file mode 100644
index 5808090250..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.XmlListModel 2.0
-
-XmlListModel {
- property string tags : ""
-
- function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
-
- source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
- query: "/feed/entry"
- namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
-
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "content"; query: "content/string()" }
- XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml
deleted file mode 100644
index aff9f6fb3b..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Flipable {
- id: flipable
-
- property alias frontLabel: frontButton.label
- property alias backLabel: backButton.label
-
- property int angle: 0
- property int randomAngle: Math.random() * (2 * 6 + 1) - 6
- property bool flipped: false
-
- signal frontClicked
- signal backClicked
- signal tagChanged(string tag)
-
- front: EditableButton {
- id: frontButton; rotation: flipable.randomAngle
- anchors { centerIn: parent; verticalCenterOffset: -20 }
- onClicked: flipable.frontClicked()
- onLabelChanged: flipable.tagChanged(label)
- }
-
- back: Button {
- id: backButton; tint: "red"; rotation: flipable.randomAngle
- anchors { centerIn: parent; verticalCenterOffset: -20 }
- onClicked: flipable.backClicked()
- }
-
- transform: Rotation {
- origin.x: flipable.width / 2; origin.y: flipable.height / 2
- axis.x: 0; axis.y: 1; axis.z: 0
- angle: flipable.angle
- }
-
- states: State {
- name: "back"; when: flipable.flipped
- PropertyChanges { target: flipable; angle: 180 }
- }
-
- transitions: Transition {
- ParallelAnimation {
- NumberAnimation { properties: "angle"; duration: 400 }
- SequentialAnimation {
- NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 }
- NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 }
- }
- }
- }
-}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
deleted file mode 100644
index 23c011d0ff..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png
deleted file mode 100644
index fc65122d26..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png
deleted file mode 100644
index a8a9c6079d..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js b/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js
deleted file mode 100644
index e8ef93a847..0000000000
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js
+++ /dev/null
@@ -1,27 +0,0 @@
-.pragma library
-
-function getWidth(string) {
- return (string.match(/width=\"([0-9]+)\"/))[1]
-}
-
-function getHeight(string) {
- return (string.match(/height=\"([0-9]+)\"/))[1]
-}
-
-function getImagePath(string) {
- var pattern = /src=\"http:\/\/(\S+)\"/
- return (string.match(pattern))[1]
-}
-
-function calculateScale(width, height, cellSize) {
- var widthScale = (cellSize * 1.0) / width
- var heightScale = (cellSize * 1.0) / height
- var scale = 0
-
- if (widthScale <= heightScale) {
- scale = widthScale;
- } else if (heightScale < widthScale) {
- scale = heightScale;
- }
- return scale;
-}
diff --git a/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png b/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png
deleted file mode 100644
index 3809d2b45d..0000000000
--- a/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc b/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc
deleted file mode 100644
index da9029f817..0000000000
--- a/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc
+++ /dev/null
@@ -1,326 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Photo Viewer
- \ingroup qtquickdemos
- \example demos/photoviewer
- \brief A QML photo viewer that that uses XmlListModel and XmlRole to
- download Flickr feeds, and Package to display the photos in different views.
-
- \image qtquick-demo-photoviewer-small.png
-
- \e{Photo Viewer} demonstrates the following \l{Qt Quick} features:
-
- \list
- \li Using custom types to create screens and screen controls.
- \li Using Qt Quick Controls to create an application window.
- \li Using the \l Package type with a \l DelegateModel to provide
- delegates with a shared context to multiple views.
- \li Using XML list models to download Flickr feeds.
- \li Using the \l Flipable type to create labels with different text on
- the front and back.
- \li Using the PathView, \l Path, PathAttribute, and PathLine types to
- lay out photos on a path.
- \li Providing feedback to users while data is loading.
- \li Localizing applications.
- \endlist
-
- \include examples-run.qdocinc
-
- \section1 Using Custom Types
-
- In the Photo Viewer app, we use the following custom types that are each
- defined in a separate .qml file:
-
- \list
- \li \c AlbumDelegate.qml
- \li \c BusyIndicator.qml
- \li \c Button.qml
- \li \c EditableButton.qml
- \li \c PhotoDelegate.qml
- \li \c ProgressBar.qml
- \li \c RssModel.qml
- \li \c Tag.qml
- \endlist
-
- To use the custom types, we add an import statement to the main QML file,
- main.qml, that imports the folder called \c PhotoViewerCore where the types
- are located:
-
- \quotefromfile demos/photoviewer/main.qml
- \skipto PhotoViewerCore
- \printuntil "
-
- \section1 Creating the Main Window
-
- In main.qml, we use the ApplicationWindow Qt Quick Control to create the app
- main window:
-
- \printuntil visible
-
- We use a ListModel type with \l ListElement types to display photo albums:
-
- \skipto ListModel
- \printuntil Prague
- \printuntil }
-
- List elements are defined like other QML types except that they contain a
- collection of \e role definitions instead of properties. Roles both define
- how the data is accessed and include the data itself. For each list element,
- we use the \c tag role to specify the photos to download.
-
- A DelegateModel type is used together with the \l Package type to provide
- delegates to multiple views. The \c model property holds the model providing
- data for the delegate model and the \c delegate property specifies the
- template defining each item instantiated by a view:
-
- \printuntil DelegateModel
-
- We use a GridView type to lay out the albums as a grid:
-
- \printuntil }
-
- The \c model property references the package name \c album that we specify
- in AlbumDelegate.qml. We use the \l Package type to allow the photos to move
- between different views. The \l Package contains the named items \c browser,
- \c fullscreen, and \c album:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
- \skipto Package
- \printuntil albumWrapper
-
- The named items are used as the delegates by the views that reference the
- special DelegateModel::parts property to select the model that provides
- the chosen delegate.
-
- We use a ListView type to lay out albums in other views:
-
- \quotefromfile demos/photoviewer/main.qml
- \skipto ListView
- \printuntil }
- \skipto ListView
- \printuntil }
-
- \section1 Displaying Photos
-
- We use the PhotoDelegate custom type that is specified in PhotoDelegate.qml
- to display photos. We use a \l Package type to lay out the photos either in
- a stack, list, or a grid:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
- \skipto Package
- \printuntil gridItem
-
- The photos are rotated at random angles by using the \c Math.random()
- JavaScript method:
-
- \printuntil stackItem
-
- We use a BorderImage type to create borders for the images:
-
- \printuntil border.left
- \printuntil }
-
- \section1 Downloading Flickr Feeds
-
- In AlbumDelegate.qml, we use the DelegateModel to provide the
- PhotoDelegate delegate to the RssModel model:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
- \skipto DelegateModel
- \printuntil RssModel
- \printuntil }
-
- In RssModel.qml, we use an XmlListModel type as a data source for
- \l Package objects to download photos from the selected feeds:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/RssModel.qml
- \skipto XmlListModel
- \printuntil encodeTags
-
- We use the \c tags custom property to specify which photos to download. The
- \c encodeTags custom function uses the \c encodeURIComponent JavaScript
- method to ensure that the requests to the server are correctly formatted.
-
- We use the \c source property to fetch photos that have the specified tags
- attached from public Flickr feeds:
-
- \printuntil namespaceDeclarations
-
- The \c query property specifies that the XmlListModel generates a model item
- for each feed entry.
-
- The \c namespaceDeclarations property specifies that the requested document
- uses the namespace \c{http://www.w3.org/2005/Atom}, which is declared as the
- default namespace.
-
- We use the XmlRole type to specify the model item attributes. Each model
- item has the \c title, \c content, and \c hq attributes that match the
- values of the corresponding feed entry:
-
- \printuntil hq
-
- \section1 Creating Flipable Labels
-
- When users select the \b Edit button, the album labels are flipped from
- their front side to their back side and the text on them changes from album
- name to \b Remove.
-
- In AlbumDelegate.qml, we use the Tag custom type to specify the text to
- display on the front and back sides of album labels:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
- \skipto Tag
- \printuntil onBackClicked
- \printuntil }
-
- The \c onTagChanged signal handler is used to change the tag based on
- which the model is populated. The \c onBackClicked signal handler is used to
- remove the album.
-
- In Tag.qml, we use a \l Flipable type with custom properties and signals to
- create the labels:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/Tag.qml
- \skipto Flipable
- \printuntil tagChanged
-
- The \c front property holds the EditableButton custom type that enables
- users to edit the label text:
-
- \printuntil onLabelChanged
- \printuntil }
-
- The \c back property holds the \c Button custom type that is used to remove
- the album:
-
- \printuntil onClicked
- \printuntil }
-
- \section1 Laying Out Photos on a Path
-
- In AlbumDelegate.qml, we use a PathView type to lay out the photos provided
- by the \c visualModel.parts.stack model on a path that has the form of a
- stack:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
- \skipto PathView
- \printuntil 0.0
- \printuntil }
- \printuntil }
-
- The \c path property holds the \l Path type that defines the path used by
- the PathView. The PathAttribute types are used to set a range of
- \c 0 to \c 9999 for the \c z attribute. This way, the path creates a stack
- of album photos. Because each PhotoDelegate is slightly rotated at a random
- angle, this results in a realistic-looking stack of photos.
-
- \section1 Providing Feedback to Users
-
- We use a busy indicator and a progress bar to indicate activity while
- Flickr feeds and photos are being loaded.
-
- In AlbumDelegate.qml, we use the \c BusyIndicator custom type and the
- \c on custom property to display a rotating image while the Flickr feed is
- being loaded:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
- \skipto BusyIndicator
- \printuntil rssModel
- \printuntil }
-
- In PhotoDelegate.qml, we use them to indicate activity while a photo is
- being loaded:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
- \skipto BusyIndicator
- \printuntil }
-
- We define the \c BusyIndicator type in \c BusyIndicator.qml. We use an
- \l Image type to display an image and apply a NumberAnimation to its
- \c rotation property to rotate the image in an infinite loop:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
- \skipto Image
- \printuntil }
- \printuntil }
-
- In your apps, you can also use the BusyIndicator type from the
- \l {Qt Quick Controls} module.
-
- In main.qml, we use the \c ProgressBar custom type to indicate progress
- while a high quality version of a photo is being opened on full screen:
-
- \quotefromfile demos/photoviewer/main.qml
- \skipto ProgressBar
- \printuntil }
-
- We define the \c ProgressBar type in \c ProgressBar.qml. We use a
- \l Rectangle type to create the progress bar and apply a NumberAnimation to
- its \c opacity property to change the color of the bar from black to white
- as data loading proceeds:
-
- \quotefromfile demos/photoviewer/PhotoViewerCore/ProgressBar.qml
- \skipto Item
- \printuntil /^\}/
-
- In your apps, you can also use the ProgressBar type from the
- \l {Qt Quick Controls} module.
-
- \section1 Localizing Applications
-
- The example application is translated into German and French. The translated
- strings are loaded at runtime according to the current locale.
-
- We use a \l Column type in main.qml to position buttons for adding and
- editing albums and exiting the application:
-
- \quotefromfile demos/photoviewer/main.qml
- \skipto Column
- \printuntil quit()
- \printuntil }
- \printuntil }
-
- We use the \l[QML]{Qt::}{qsTr()} command to mark the button labels translatable.
-
- We use the \c lupdate() tool to generate the translation source files and
- the \c lrelease() tool to convert the translated strings to the QM files used
- by the application at runtime. These files are stored in the \c i18n
- directory.
-
- To make the application aware of the translations, we add code to the
- \c main() function in the main.cpp file. The code creates a \l QTranslator
- object, loads a translation according to the current locale at runtime, and
- installs the translator object into the application:
-
- \quotefromfile demos/photoviewer/main.cpp
- \skipto main
- \printuntil app.installTranslator
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/photoviewer/i18n/qml_de.qm b/examples/quick/demos/photoviewer/i18n/qml_de.qm
deleted file mode 100644
index 8186e7309f..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_de.qm
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_de.ts b/examples/quick/demos/photoviewer/i18n/qml_de.ts
deleted file mode 100644
index c36f169c6a..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_de.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="de_DE">
-<context>
- <name>AlbumDelegate</name>
- <message>
- <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="111"/>
- <source>Remove</source>
- <translation>Entfernen</translation>
- </message>
-</context>
-<context>
- <name>main</name>
- <message>
- <location filename="../main.qml" line="93"/>
- <source>Add</source>
- <translation>Zufügen</translation>
- </message>
- <message>
- <location filename="../main.qml" line="102"/>
- <source>Edit</source>
- <translation>Bearbeiten</translation>
- </message>
- <message>
- <location filename="../main.qml" line="107"/>
- <source>Quit</source>
- <translation>Verlassen</translation>
- </message>
- <message>
- <location filename="../main.qml" line="122"/>
- <source>Back</source>
- <translation>Zurück</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/quick/demos/photoviewer/i18n/qml_en.qm b/examples/quick/demos/photoviewer/i18n/qml_en.qm
deleted file mode 100644
index 9dad8dffce..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_en.qm
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_en.ts b/examples/quick/demos/photoviewer/i18n/qml_en.ts
deleted file mode 100644
index 5315a75526..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_en.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="en">
-</TS>
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.qm b/examples/quick/demos/photoviewer/i18n/qml_fr.qm
deleted file mode 100644
index e4257d4073..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_fr.qm
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.ts b/examples/quick/demos/photoviewer/i18n/qml_fr.ts
deleted file mode 100644
index 353082569a..0000000000
--- a/examples/quick/demos/photoviewer/i18n/qml_fr.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="fr_FR">
-<context>
- <name>AlbumDelegate</name>
- <message>
- <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="111"/>
- <source>Remove</source>
- <translation>Supprimer</translation>
- </message>
-</context>
-<context>
- <name>main</name>
- <message>
- <location filename="../main.qml" line="93"/>
- <source>Add</source>
- <translation>Ajouter</translation>
- </message>
- <message>
- <location filename="../main.qml" line="102"/>
- <source>Edit</source>
- <translation>Éditer</translation>
- </message>
- <message>
- <location filename="../main.qml" line="107"/>
- <source>Quit</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../main.qml" line="122"/>
- <source>Back</source>
- <translation>Retour</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/quick/demos/photoviewer/main.qml b/examples/quick/demos/photoviewer/main.qml
deleted file mode 100644
index 2e2b8e4ee2..0000000000
--- a/examples/quick/demos/photoviewer/main.qml
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-import QtQuick.Controls 1.1
-import QtQml.Models 2.1
-import "PhotoViewerCore"
-
-ApplicationWindow {
- id: mainWindow
-
- visible: true
-
- Rectangle {
- focus: true
-
- Keys.onBackPressed: {
- event.accepted = true
- backButton.clicked()
- }
- }
-
- property real downloadProgress: 0
- property bool imageLoading: false
- property bool editMode: false
-
- width: 800; height: 480; color: "#d5d6d8"
-
- ListModel {
- id: photosModel
- ListElement { tag: "Flowers" }
- ListElement { tag: "Wildlife" }
- ListElement { tag: "Prague" }
- }
-
- DelegateModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
-
- GridView {
- id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
- model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
- }
-
- Column {
- spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
- Button {
- id: newButton; label: qsTr("Add"); rotation: 3
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- mainWindow.editMode = false
- photosModel.append( { tag: "" } )
- albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
- }
- }
- Button {
- id: deleteButton; label: qsTr("Edit"); rotation: -2;
- onClicked: mainWindow.editMode = !mainWindow.editMode
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Button {
- id: quitButton; label: qsTr("Quit"); rotation: -2;
- onClicked: Qt.quit()
- anchors.horizontalCenter: parent.horizontalCenter
- }
- }
-
- Rectangle {
- id: albumsShade; color: mainWindow.color
- width: parent.width; height: parent.height; opacity: 0.0
- }
-
- ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false }
-
- Button {
- id: backButton
- label: qsTr("Back")
- rotation: 3
- x: parent.width - backButton.width - 6
- y: -backButton.height - 8
- visible: Qt.platform.os !== "android"
- }
-
- Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
-
- ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false }
-
- Item { id: foreground; anchors.fill: parent }
-
- ProgressBar {
- progress: mainWindow.downloadProgress; width: parent.width; height: 4
- anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0
- }
-}
diff --git a/examples/quick/demos/photoviewer/photoviewer.pro b/examples/quick/demos/photoviewer/photoviewer.pro
deleted file mode 100644
index 885b81b4ad..0000000000
--- a/examples/quick/demos/photoviewer/photoviewer.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick xmlpatterns
-
-SOURCES += main.cpp
-
-lupdate_only{
-SOURCES = *.qml \
- PhotoViewerCore/*.qml \
- PhotoViewerCore/script/*.js
-}
-
-TRANSLATIONS += i18n/qml_en.ts \
- i18n/qml_fr.ts \
- i18n/qml_de.ts
-
-RESOURCES += qml.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/photoviewer
-INSTALLS += target
diff --git a/examples/quick/demos/photoviewer/qml.qrc b/examples/quick/demos/photoviewer/qml.qrc
deleted file mode 100644
index 49f0b27e50..0000000000
--- a/examples/quick/demos/photoviewer/qml.qrc
+++ /dev/null
@@ -1,20 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- <file>PhotoViewerCore/AlbumDelegate.qml</file>
- <file>PhotoViewerCore/BusyIndicator.qml</file>
- <file>PhotoViewerCore/Button.qml</file>
- <file>PhotoViewerCore/EditableButton.qml</file>
- <file>PhotoViewerCore/PhotoDelegate.qml</file>
- <file>PhotoViewerCore/ProgressBar.qml</file>
- <file>PhotoViewerCore/RssModel.qml</file>
- <file>PhotoViewerCore/Tag.qml</file>
- <file>PhotoViewerCore/images/box-shadow.png</file>
- <file>PhotoViewerCore/images/busy.png</file>
- <file>PhotoViewerCore/images/cardboard.png</file>
- <file>PhotoViewerCore/script/script.js</file>
- <file>i18n/qml_fr.qm</file>
- <file>i18n/qml_de.qm</file>
- <file>i18n/qml_en.qm</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/rssnews/content/BusyIndicator.qml b/examples/quick/demos/rssnews/content/BusyIndicator.qml
deleted file mode 100644
index 44b796bdfe..0000000000
--- a/examples/quick/demos/rssnews/content/BusyIndicator.qml
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-
-Image {
- id: container
-
- source: "images/busy.png";
-
- NumberAnimation on rotation {
- running: container.visible
- from: 0; to: 360;
- loops: Animation.Infinite;
- duration: 1200
- }
-}
diff --git a/examples/quick/demos/rssnews/content/NewsDelegate.qml b/examples/quick/demos/rssnews/content/NewsDelegate.qml
deleted file mode 100644
index ed0c2bd977..0000000000
--- a/examples/quick/demos/rssnews/content/NewsDelegate.qml
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-
-Column {
- id: delegate
- width: delegate.ListView.view.width
- spacing: 8
-
- // Returns a string representing how long ago an event occurred
- function timeSinceEvent(pubDate) {
- var result = pubDate;
-
- // We need to modify the pubDate read from the RSS feed
- // so the JavaScript Date object can interpret it
- var d = pubDate.replace(',','').split(' ');
- if (d.length != 6)
- return result;
-
- var date = new Date([d[0], d[2], d[1], d[3], d[4], 'GMT' + d[5]].join(' '));
-
- if (!isNaN(date.getDate())) {
- var age = new Date() - date;
- var minutes = Math.floor(Number(age) / 60000);
- if (minutes < 1440) {
- if (minutes < 2)
- result = qsTr("Just now");
- else if (minutes < 60)
- result = '' + minutes + ' ' + qsTr("minutes ago")
- else if (minutes < 120)
- result = qsTr("1 hour ago");
- else
- result = '' + Math.floor(minutes/60) + ' ' + qsTr("hours ago");
- }
- else {
- result = date.toDateString();
- }
- }
- return result;
- }
-
- Item { height: 8; width: delegate.width }
-
- Row {
- width: parent.width
- spacing: 8
-
- Column {
- Item {
- width: 4
- height: titleText.font.pixelSize / 4
- }
-
- Image {
- id: titleImage
- source: image
- }
- }
-
- Text {
- id: titleText
-
- text: title
- width: delegate.width - titleImage.width
- wrapMode: Text.WordWrap
- font.pixelSize: 26
- font.bold: true
- }
- }
-
- Text {
- width: delegate.width
- font.pixelSize: 12
- textFormat: Text.RichText
- font.italic: true
- text: timeSinceEvent(pubDate) + " (<a href=\"" + link + "\">Link</a>)"
- onLinkActivated: {
- Qt.openUrlExternally(link)
- }
- }
-
- Text {
- id: descriptionText
-
- text: description
- width: parent.width
- wrapMode: Text.WordWrap
- font.pixelSize: 14
- textFormat: Text.StyledText
- horizontalAlignment: Qt.AlignLeft
- }
-}
diff --git a/examples/quick/demos/rssnews/content/RssFeeds.qml b/examples/quick/demos/rssnews/content/RssFeeds.qml
deleted file mode 100644
index 46a6c875c8..0000000000
--- a/examples/quick/demos/rssnews/content/RssFeeds.qml
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-
-ListModel {
- ListElement { name: "Top Stories"; feed: "news.yahoo.com/rss/topstories"; image: "images/TopStories.jpg" }
- ListElement { name: "World"; feed: "news.yahoo.com/rss/world"; image: "images/World.jpg" }
- ListElement { name: "Europe"; feed: "news.yahoo.com/rss/europe"; image: "images/Europe.jpg" }
- ListElement { name: "Asia"; feed: "news.yahoo.com/rss/asia"; image: "images/Asia.jpg" }
- ListElement { name: "U.S. National"; feed: "news.yahoo.com/rss/us"; image: "images/USNational.jpg" }
- ListElement { name: "Politics"; feed: "news.yahoo.com/rss/politics"; image: "images/Politics.jpg" }
- ListElement { name: "Business"; feed: "news.yahoo.com/rss/business"; image: "images/Business.jpg" }
- ListElement { name: "Technology"; feed: "news.yahoo.com/rss/tech"; image: "images/Technology.jpg" }
- ListElement { name: "Entertainment"; feed: "news.yahoo.com/rss/entertainment"; image: "images/Entertainment.jpg" }
- ListElement { name: "Health"; feed: "news.yahoo.com/rss/health"; image: "images/Health.jpg" }
- ListElement { name: "Science"; feed: "news.yahoo.com/rss/science"; image: "images/Science.jpg" }
- ListElement { name: "Sports"; feed: "news.yahoo.com/rss/sports"; image: "images/Sports.jpg" }
-}
diff --git a/examples/quick/demos/rssnews/content/ScrollBar.qml b/examples/quick/demos/rssnews/content/ScrollBar.qml
deleted file mode 100644
index bd774188c8..0000000000
--- a/examples/quick/demos/rssnews/content/ScrollBar.qml
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-
-Item {
- id: container
-
- property variant scrollArea
- property int orientation: Qt.Vertical
-
- opacity: 0
-
- function position()
- {
- var ny = 0;
- if (container.orientation == Qt.Vertical)
- ny = scrollArea.visibleArea.yPosition * container.height;
- else
- ny = scrollArea.visibleArea.xPosition * container.width;
-
- if (ny > 2)
- return ny;
- else
- return 2;
- }
-
- function size()
- {
- var nh, ny;
-
- if (container.orientation == Qt.Vertical)
- nh = scrollArea.visibleArea.heightRatio * container.height;
- else
- nh = scrollArea.visibleArea.widthRatio * container.width;
-
- if (container.orientation == Qt.Vertical)
- ny = scrollArea.visibleArea.yPosition * container.height;
- else
- ny = scrollArea.visibleArea.xPosition * container.width;
-
- if (ny > 3) {
- var t;
- if (container.orientation == Qt.Vertical)
- t = Math.ceil(container.height - 3 - ny);
- else
- t = Math.ceil(container.width - 3 - ny);
- if (nh > t)
- return t;
- else
- return nh;
- } else
- return nh + ny;
- }
-
- Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
-
- BorderImage {
- source: "images/scrollbar.png"
- border { left: 1; right: 1; top: 1; bottom: 1 }
- x: container.orientation == Qt.Vertical ? 2 : position()
- y: container.orientation == Qt.Vertical ? position() : 2
- width: container.orientation == Qt.Vertical ? container.width - 4 : size()
- height: container.orientation == Qt.Vertical ? size() : container.height - 4
- }
-
- states: State {
- name: "visible"
- when: container.orientation == Qt.Vertical ?
- scrollArea.movingVertically :
- scrollArea.movingHorizontally
- PropertyChanges { target: container; opacity: 1.0 }
- }
-
- transitions: Transition {
- from: "visible"; to: ""
- NumberAnimation { properties: "opacity"; duration: 600 }
- }
-}
diff --git a/examples/quick/demos/rssnews/content/images/Asia.jpg b/examples/quick/demos/rssnews/content/images/Asia.jpg
deleted file mode 100644
index a609557a08..0000000000
--- a/examples/quick/demos/rssnews/content/images/Asia.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Business.jpg b/examples/quick/demos/rssnews/content/images/Business.jpg
deleted file mode 100644
index b2c1d92138..0000000000
--- a/examples/quick/demos/rssnews/content/images/Business.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Entertainment.jpg b/examples/quick/demos/rssnews/content/images/Entertainment.jpg
deleted file mode 100644
index 2c69fc04d7..0000000000
--- a/examples/quick/demos/rssnews/content/images/Entertainment.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Europe.jpg b/examples/quick/demos/rssnews/content/images/Europe.jpg
deleted file mode 100644
index bf524e13d0..0000000000
--- a/examples/quick/demos/rssnews/content/images/Europe.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Health.jpg b/examples/quick/demos/rssnews/content/images/Health.jpg
deleted file mode 100644
index 0e8c71f0c9..0000000000
--- a/examples/quick/demos/rssnews/content/images/Health.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Politics.jpg b/examples/quick/demos/rssnews/content/images/Politics.jpg
deleted file mode 100644
index 0b1800c97e..0000000000
--- a/examples/quick/demos/rssnews/content/images/Politics.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Science.jpg b/examples/quick/demos/rssnews/content/images/Science.jpg
deleted file mode 100644
index 7faccbbb97..0000000000
--- a/examples/quick/demos/rssnews/content/images/Science.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Sports.jpg b/examples/quick/demos/rssnews/content/images/Sports.jpg
deleted file mode 100644
index 0ab3bd3ce7..0000000000
--- a/examples/quick/demos/rssnews/content/images/Sports.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Technology.jpg b/examples/quick/demos/rssnews/content/images/Technology.jpg
deleted file mode 100644
index db553028fb..0000000000
--- a/examples/quick/demos/rssnews/content/images/Technology.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/TopStories.jpg b/examples/quick/demos/rssnews/content/images/TopStories.jpg
deleted file mode 100644
index e35bd67f20..0000000000
--- a/examples/quick/demos/rssnews/content/images/TopStories.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/USNational.jpg b/examples/quick/demos/rssnews/content/images/USNational.jpg
deleted file mode 100644
index 82c78228c1..0000000000
--- a/examples/quick/demos/rssnews/content/images/USNational.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/World.jpg b/examples/quick/demos/rssnews/content/images/World.jpg
deleted file mode 100644
index 7a0a806fd4..0000000000
--- a/examples/quick/demos/rssnews/content/images/World.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/btn_close.png b/examples/quick/demos/rssnews/content/images/btn_close.png
deleted file mode 100644
index 1a3dc44380..0000000000
--- a/examples/quick/demos/rssnews/content/images/btn_close.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/busy.png b/examples/quick/demos/rssnews/content/images/busy.png
deleted file mode 100644
index fc65122d26..0000000000
--- a/examples/quick/demos/rssnews/content/images/busy.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/scrollbar.png b/examples/quick/demos/rssnews/content/images/scrollbar.png
deleted file mode 100644
index c2425dd0df..0000000000
--- a/examples/quick/demos/rssnews/content/images/scrollbar.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png b/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png
deleted file mode 100644
index 9d324ceb70..0000000000
--- a/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/rssnews/doc/src/rssnews.qdoc b/examples/quick/demos/rssnews/doc/src/rssnews.qdoc
deleted file mode 100644
index 4ba874cd70..0000000000
--- a/examples/quick/demos/rssnews/doc/src/rssnews.qdoc
+++ /dev/null
@@ -1,372 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - RSS News
- \ingroup qtquickdemos
- \example demos/rssnews
- \brief A QML RSS news reader that uses XmlListModel and XmlRole to download
- XML data, ListModel and ListElement to create a category list, and ListView
- to display the data.
-
- \image qtquick-demo-rssnews-small.png
-
- \e{RSS News} demonstrates the following \l{Qt Quick} features:
-
- \list
- \li Using custom types to create screens and screen controls.
- \li Using list models and list elements to represent data.
- \li Using XML list models to download XML data.
- \li Using list views to display data.
- \li Using the \l Component type to create a footer for the news item
- list view.
- \li Using the \l Image type to create a button for closing the app.
- \endlist
-
- \include examples-run.qdocinc
-
- \section1 Using Custom Types
-
- In the RSS News app, we use the following custom types that are each defined
- in a separate .qml file:
-
- \list
- \li \c BusyIndicator.qml
- \li \c CategoryDelegate.qml
- \li \c NewsDelegate.qml
- \li \c RssFeeds.qml
- \li \c ScrollBar.qml
- \endlist
-
- To use the custom types, we add an import statement to the main QML file,
- rssnews.qml that imports the folder called \c content where the types are
- located:
-
- \quotefromfile demos/rssnews/rssnews.qml
- \skipto content
- \printuntil "
-
- \section1 Creating the Main Window
-
- In rssnews.qml, we use a \l{Rectangle} type with custom properties to create
- the app main window:
-
- \printuntil isPortrait
-
- We will use the custom properties later for loading XML data and for
- adjusting the screen layout depending on its orientation.
-
- \section1 Creating a Category List
-
- In rssnews.qml, we use the RssFeeds custom type that we specify in
- RssFeeds.qml to create a list of feed categories:
-
- \skipto RssFeeds
- \printuntil }
-
- In RssFeeds.qml, we use a ListModel type with a ListElement type to
- create a category list where list elements represent feed categories:
-
- \quotefromfile demos/rssnews/content/RssFeeds.qml
- \skipto ListModel
- \printuntil /^\}/
-
- List elements are defined like other QML types except that they contain a
- collection of \e role definitions instead of properties. Roles both define
- how the data is accessed and include the data itself.
-
- For each list element, we use the \c name role to specify the category name,
- the \c feed role to specify the URL to load the data from, and the \c image
- role to display an image for the category.
-
- In rssnews.qml, we use a ListView type to display the category list:
-
- \quotefromfile demos/rssnews/rssnews.qml
- \skipto ListView
- \printuntil }
- \printuntil }
-
- To lay out the category list horizontally at the top of the window in
- portrait orientation and vertically on the left side in landscape
- orientation, we use the \c orientation property. Based on the orientation,
- we bind either the width or the height of the list to a fixed value
- (\c itemWidth).
-
- We use the \c anchors.top property to position the list view at the top of
- the screen in both orientations.
-
- We use the \c model property to load XML data from the \c rssFeeds model,
- and \c CategoryDelegate as the delegate to instantiate each item in the
- list.
-
- \section1 Creating List Elements
-
- In CategoryDelegate.qml, we use the \l Rectangle type with custom properties
- to create list elements:
-
- \quotefromfile demos/rssnews/content/CategoryDelegate.qml
- \skipto Rectangle
- \printuntil selected
-
- We set the \c selected property to the \c ListView.isCurrentItem attached
- property to specify that \c selected is \c true if \c delegate is the
- current item.
-
- We use the \l Image type \c source property to display the image, centered
- in the delegate, specified for the list element by the \c image role in the
- \c rssFeeds list model:
-
- \skipto Image
- \printuntil }
-
- We use a \l Text type to add titles to list elements:
-
- \printuntil Behavior
- \printuntil }
-
- We use the \c anchors property to position the title at the top of the list
- element, with a 20-pixel margin. We use \c font properties to adjust font
- size and text formatting.
-
- We use the \c color property to brighten the text and to scale it slightly
- larger when the list item is the current item. By applying a \l Behavior to
- the property, we animate the actions of selecting and deselecting list
- items.
-
- We use a MouseArea type to download XML data when users tap a category list
- element:
-
- \skipto MouseArea
- \printuntil }
- \printuntil }
-
- The \c anchors.fill property is set to \c delegate to enable users to tap
- anywhere within the list element.
-
- We use the \c onClicked signal handler to load the XML data for the category
- list. If the tapped category is already current, the \c reload() function
- is called to reload the data.
-
- \section1 Downloading XML Data
-
- In rssnews.qml, we use an XmlListModel type as a data source for ListView
- elements to display news items in the selected category:
-
- \quotefromfile demos/rssnews/rssnews.qml
- \skipto XmlListModel {
- \printuntil namespaceDeclarations
-
- We use the \c source property and the \c window.currentFeed custom property
- to fetch news items for the selected category.
-
- The \c query property specifies that the XmlListModel generates a model item
- for each \c <item> in the XML document.
-
- We use the XmlRole type to specify the model item attributes. Each model
- item has the \c title, \c description, \c image, \c link, and \c pubDate
- attributes that match the values of the corresponding \c <item> in the XML
- document:
-
- \printuntil pubDate
- \printuntil }
-
- We use the \c feedModel model in a ListView type to display the data:
-
- \skipuntil ScrollBar
- \skipto ListView
- \printuntil }
- \printuntil }
-
- To list the news items below the category list in portrait orientation and
- to its right in landscape orientation, we use the \c isPortrait custom
- property to anchor the top of the news items list to the left of \c window
- and bottom of \c categories in portrait orientation and to the right of
- \c categories and bottom of \c window in landscape orientation.
-
- We use the \c anchors.bottom property to anchor the bottom of the list view
- to the bottom of the window in both orientations.
-
- In portrait orientation, we clip the painting of the news items to the
- bounding rectangle of the list view to avoid graphical artifacts when news
- items are scrolled over other items. In landscape, this is not required,
- because the list spans the entire screen vertically.
-
- We use the \c model property to load XML data from the \c feedModel model,
- and use \c NewsDelegate as the delegate to instantiate each item in the
- list.
-
- In NewsDelegate.qml, we use a \l Column type to lay out the XML data:
-
- \quotefromfile demos/rssnews/content/NewsDelegate.qml
- \skipto Column
- \printuntil spacing
-
- Within the column, we use a \l Row and another column to position images and
- title text:
-
- \skipto Row
- \printuntil font.bold
- \printuntil }
- \printuntil }
-
- We generate a textual representation of how long ago the item was posted
- using the \c timeSinceEvent() JavaScript function:
-
- \printuntil }
- \printuntil }
-
- We use the \c onLinkActivated signal handler to open the URL in an external
- browser when users select the link.
-
- \section1 Providing Feedback to Users
-
- In CategoryDelegate.qml, we use the \c BusyIndicator custom type to indicate
- activity while the XML data is being loaded:
-
- \quotefromfile demos/rssnews/content/CategoryDelegate.qml
- \skipto BusyIndicator
- \printuntil }
-
- We use the \c scale property to reduce the indicator size to \c 0.8. We bind
- the \c visible property to the \c isCurrentItem attached property of the
- \c delegate list view and \c loading property of the main window to display
- the indicator image when a category list item is the current item and XML
- data is being loaded.
-
- We define the \c BusyIndicator type in \c BusyIndicator.qml. We use an
- \l Image type to display an image and apply a NumberAnimation to its
- \c rotation property to rotate the image in an infinite loop:
-
- \quotefromfile demos/rssnews/content/BusyIndicator.qml
- \skipto Image
- \printuntil }
- \printuntil }
-
- In your apps, you can also use the BusyIndicator type from the
- \l {Qt Quick Controls} module.
-
- \section1 Creating Scroll Bars
-
- In rssnews.qml, we use our own custom \c ScrollBar type to create scroll
- bars in the category and news item list views. In your apps, you can also
- use the ScrollView type from the \l {Qt Quick Controls} module.
-
- First, we create a scroll bar in the category list view. We bind the
- \c orientation property to the \c isPortrait property and to the
- \c Horizontal value of the \c Qt::Orientation enum type to display a
- horizontal scroll bar in portrait orientation and to the \c Vertical value
- to display a vertical scroll bar in landscape orientation:
-
- \quotefromfile demos/rssnews/rssnews.qml
- \skipto ScrollBar
- \printuntil }
-
- Same as with the \c categories list view, we adjust the width and height of
- the scroll bar based on the \c isPortrait property.
-
- We use the \c scrollArea property to display the scroll bar in the
- \c categories list view.
-
- We use the \c anchors.right property to anchor the scroll bar to the right
- side of the category list.
-
- \skipto ScrollBar
- \printuntil }
-
- Second, we create another scroll bar in the news item list view. We want a
- vertical scroll bar to appear on the right side of the view regardless of
- screen orientation, so we can set the \c width property to \c 8 and bind the
- \c anchors.right property to the \c window.right property. We use the
- \c anchors.top property to anchor the scroll bar top to the bottom of the
- category list in portrait orientation and to the top of the news item list
- in landscape orientation. We use the \c anchors.bottom property to anchor
- the scroll bar bottom to the list view bottom in both orientations.
-
- We define the \c ScrollBar type in \c ScrollBar.qml. We use an \l Item type
- with custom properties to create a container for the scroll bar:
-
- \quotefromfile demos/rssnews/content/ScrollBar.qml
- \skipto Item
- \printuntil opacity
-
- We use a BorderImage type to display the scroll bar thumb at the x and y
- position that we calculate by using the \c position() function:
-
- \skipto BorderImage
- \printuntil height
- \printuntil }
-
- We use the \c size function to calculate the thumb width and height
- depending on the screen orientation.
-
- We use \c states to make the scroll bar visible when the users move the
- scroll area:
-
- \printuntil }
- \printuntil }
-
- We use \c transitions to apply a NumberAnimation to the \c "opacity"
- property when the state changes from "visible" to the default state:
-
- \printuntil /^\}/
-
- \section1 Creating Footers
-
- In rssnews.qml, we use a \l Component type with a \l Rectangle type to
- create a footer for the news list view:
-
- \quotefromfile demos/rssnews/rssnews.qml
- \skipto Component
- \printuntil }
- \printuntil }
- \printuntil }
-
- We bind the \c width of the footer to the width of the component and the
- \c height to the of close button to align them when no news items are
- displayed.
-
- \section1 Creating Buttons
-
- In rssnews.qml, we use an \l Image type to create a simple push button that
- users can tap to close the app:
-
- \printuntil Qt.quit()
- \printuntil }
- \printuntil }
- \printuntil }
-
- We use \c anchors to position the close button in the top right corner of
- the news list view, with 4-pixel margins. Because the close button overlaps
- the category list in portrait orientation, we animate the \c opacity
- property to make the button almost fully transparent when users are
- scrolling the category list.
-
- We use the \c onClicked signal handler within a MouseArea to call the
- \c quit() function when users select the close button.
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/rssnews/main.cpp b/examples/quick/demos/rssnews/main.cpp
deleted file mode 100644
index a0d621bbb6..0000000000
--- a/examples/quick/demos/rssnews/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/rssnews/rssnews)
diff --git a/examples/quick/demos/rssnews/rssnews.pro b/examples/quick/demos/rssnews/rssnews.pro
deleted file mode 100644
index c67c5a6558..0000000000
--- a/examples/quick/demos/rssnews/rssnews.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-
-QT += quick qml xml xmlpatterns
-SOURCES += main.cpp
-RESOURCES += rssnews.qrc
-
-OTHER_FILES = rssnews.qml \
- content/*.qml \
- content/*.js \
- content/images/*
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/rssnews
-INSTALLS += target
diff --git a/examples/quick/demos/rssnews/rssnews.qml b/examples/quick/demos/rssnews/rssnews.qml
deleted file mode 100644
index 263154f956..0000000000
--- a/examples/quick/demos/rssnews/rssnews.qml
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.2
-import QtQuick.XmlListModel 2.0
-import QtQuick.Window 2.1
-import "./content"
-
-Rectangle {
- id: window
-
- width: 800
- height: 480
-
- property string currentFeed: rssFeeds.get(0).feed
- property bool loading: feedModel.status === XmlListModel.Loading
- property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation
-
- onLoadingChanged: {
- if (feedModel.status == XmlListModel.Ready)
- list.positionViewAtBeginning()
- }
-
- RssFeeds { id: rssFeeds }
-
- XmlListModel {
- id: feedModel
-
- source: "http://" + window.currentFeed
- query: "/rss/channel/item[child::media:content]"
- namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
-
- XmlRole { name: "title"; query: "title/string()" }
- // Remove any links from the description
- XmlRole { name: "description"; query: "fn:replace(description/string(), '\&lt;a href=.*\/a\&gt;', '')" }
- XmlRole { name: "image"; query: "media:content/@url/string()" }
- XmlRole { name: "link"; query: "link/string()" }
- XmlRole { name: "pubDate"; query: "pubDate/string()" }
- }
-
- ListView {
- id: categories
- property int itemWidth: 190
-
- width: isPortrait ? parent.width : itemWidth
- height: isPortrait ? itemWidth : parent.height
- orientation: isPortrait ? ListView.Horizontal : ListView.Vertical
- anchors.top: parent.top
- model: rssFeeds
- delegate: CategoryDelegate { itemSize: categories.itemWidth }
- spacing: 3
- }
-
- ScrollBar {
- id: listScrollBar
-
- orientation: isPortrait ? Qt.Horizontal : Qt.Vertical
- height: isPortrait ? 8 : categories.height;
- width: isPortrait ? categories.width : 8
- scrollArea: categories;
- anchors.right: categories.right
- }
-
- ListView {
- id: list
-
- anchors.left: isPortrait ? window.left : categories.right
- anchors.right: closeButton.left
- anchors.top: isPortrait ? categories.bottom : window.top
- anchors.bottom: window.bottom
- anchors.leftMargin: 30
- anchors.rightMargin: 4
- clip: isPortrait
- model: feedModel
- footer: footerText
- delegate: NewsDelegate {}
- }
-
- ScrollBar {
- scrollArea: list
- width: 8
- anchors.right: window.right
- anchors.top: isPortrait ? categories.bottom : window.top
- anchors.bottom: window.bottom
- }
-
- Component {
- id: footerText
-
- Rectangle {
- width: parent.width
- height: closeButton.height
- color: "lightgray"
-
- Text {
- text: "RSS Feed from Yahoo News"
- anchors.centerIn: parent
- font.pixelSize: 14
- }
- }
- }
-
- Image {
- id: closeButton
- source: "content/images/btn_close.png"
- scale: 0.8
- anchors.top: parent.top
- anchors.right: parent.right
- anchors.margins: 4
- opacity: (isPortrait && categories.moving) ? 0.2 : 1.0
- Behavior on opacity {
- NumberAnimation { duration: 300; easing.type: Easing.OutSine }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- Qt.quit()
- }
- }
- }
-}
diff --git a/examples/quick/demos/rssnews/rssnews.qmlproject b/examples/quick/demos/rssnews/rssnews.qmlproject
deleted file mode 100644
index 5becbdaed0..0000000000
--- a/examples/quick/demos/rssnews/rssnews.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "rssnews.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/rssnews/rssnews.qrc b/examples/quick/demos/rssnews/rssnews.qrc
deleted file mode 100644
index 1208d44fd7..0000000000
--- a/examples/quick/demos/rssnews/rssnews.qrc
+++ /dev/null
@@ -1,25 +0,0 @@
-<RCC>
- <qresource prefix="/demos/rssnews">
- <file>rssnews.qml</file>
- <file>content/BusyIndicator.qml</file>
- <file>content/CategoryDelegate.qml</file>
- <file>content/NewsDelegate.qml</file>
- <file>content/RssFeeds.qml</file>
- <file>content/ScrollBar.qml</file>
- <file>content/images/btn_close.png</file>
- <file>content/images/Business.jpg</file>
- <file>content/images/busy.png</file>
- <file>content/images/Entertainment.jpg</file>
- <file>content/images/Europe.jpg</file>
- <file>content/images/Health.jpg</file>
- <file>content/images/Asia.jpg</file>
- <file>content/images/Politics.jpg</file>
- <file>content/images/Science.jpg</file>
- <file>content/images/scrollbar.png</file>
- <file>content/images/Sports.jpg</file>
- <file>content/images/Technology.jpg</file>
- <file>content/images/TopStories.jpg</file>
- <file>content/images/USNational.jpg</file>
- <file>content/images/World.jpg</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/samegame/content/Block.qml b/examples/quick/demos/samegame/content/Block.qml
deleted file mode 100644
index 5c6e584e37..0000000000
--- a/examples/quick/demos/samegame/content/Block.qml
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: block
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property ParticleSystem particleSystem
-
- Behavior on x {
- enabled: spawned;
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
- Behavior on y {
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
-
- Image {
- id: img
- source: {
- if (type == 0){
- "gfx/red.png";
- } else if (type == 1) {
- "gfx/blue.png";
- } else if (type == 2) {
- "gfx/green.png";
- } else {
- "gfx/yellow.png";
- }
- }
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- anchors.fill: parent
- }
-
- //Foreground particles
- BlockEmitter {
- id: particles
- system: particleSystem
- group: {
- if (type == 0){
- "red";
- } else if (type == 1) {
- "blue";
- } else if (type == 2) {
- "green";
- } else {
- "yellow";
- }
- }
- anchors.fill: parent
- }
-
- //Paint particles on the background
- PaintEmitter {
- id: particles2
- system: particleSystem
- }
-
- states: [
- State {
- name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
-
- State {
- name: "DeathState"; when: dying == true
- StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
- PropertyChanges { target: img; opacity: 0 }
- StateChangeScript { script: block.destroy(1000); }
- }
- ]
-}
diff --git a/examples/quick/demos/samegame/content/BlockEmitter.qml b/examples/quick/demos/samegame/content/BlockEmitter.qml
deleted file mode 100644
index cbcc5df99f..0000000000
--- a/examples/quick/demos/samegame/content/BlockEmitter.qml
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-// Needed for singletons QTBUG-34418
-import "."
-
-Emitter {
- property Item block: parent
- velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40}
- acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;}
- shape: EllipseShape{fill:true}
- enabled: false;
- lifeSpan: 700; lifeSpanVariation: 100
- emitRate: 1000
- maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
- size: Settings.blockSize * 0.85
- endSize: Settings.blockSize * 0.85 /2
-}
diff --git a/examples/quick/demos/samegame/content/Button.qml b/examples/quick/demos/samegame/content/Button.qml
deleted file mode 100644
index baaa7c73b0..0000000000
--- a/examples/quick/demos/samegame/content/Button.qml
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- property alias imgSrc: image.source
- property alias system: emitter.system
- property alias group: emitter.group
- signal clicked
- property bool rotatedButton: false
-
- width: image.width
- height: image.sourceSize.height
- Image {
- id: image
- height: parent.height
- width: height/sourceSize.height * sourceSize.width
-
- anchors.horizontalCenter: parent.horizontalCenter
- rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
- MenuEmitter {
- id: emitter
- anchors.fill: parent
- //shape: MaskShape {source: image.source}
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {parent.clicked(); emitter.burst(400);}
- }
-}
diff --git a/examples/quick/demos/samegame/content/GameArea.qml b/examples/quick/demos/samegame/content/GameArea.qml
deleted file mode 100644
index 0f51fcf002..0000000000
--- a/examples/quick/demos/samegame/content/GameArea.qml
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "samegame.js" as Logic
-import "."
-
-Item {
- id: gameCanvas
- property bool gameOver: true
- property int score: 0
- property int highScore: 0
- property int moves: 0
- property string mode: ""
- property ParticleSystem ps: particleSystem
- //For easy theming
- property alias backgroundVisible: bg.visible
- property string background: "gfx/background.png"
- property string blockFile: "Block.qml"
- property int blockSize: Settings.blockSize
- onBlockFileChanged: Logic.changeBlock(blockFile);
- property alias particlePack: auxLoader.source
- //For multiplayer
- property int score2: 0
- property int curTurn: 1
- property bool autoTurnChange: false
- signal swapPlayers
- property bool swapping: false
- //onSwapPlayers: if (autoTurnChange) Logic.turnChange();//Now implemented below
- //For puzzle
- property url level
- property bool puzzleWon: false
- signal puzzleLost //Since root is tracking the puzzle progress
- function showPuzzleEnd (won) {
- if (won) {
- smokeParticle.color = Qt.rgba(0,1,0,0);
- puzzleWin.play();
- } else {
- smokeParticle.color = Qt.rgba(1,0,0,0);
- puzzleFail.play();
- puzzleLost();
- }
- }
- function showPuzzleGoal (str) {
- puzzleTextBubble.opacity = 1;
- puzzleTextLabel.text = str;
- }
- Image {
- id: bg
- z: -1
- anchors.fill: parent
- source: background;
- fillMode: Image.PreserveAspectCrop
- }
-
- MouseArea {
- anchors.fill: parent; onClicked: {
- if (puzzleTextBubble.opacity == 1) {
- puzzleTextBubble.opacity = 0;
- Logic.finishLoadingMap();
- } else if (!swapping) {
- Logic.handleClick(mouse.x,mouse.y);
- }
- }
- }
-
- Image {
- id: highScoreTextBubble
- opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
- Behavior on opacity { NumberAnimation {} }
- anchors.centerIn: parent
- z: 10
- source: "gfx/bubble-highscore.png"
- Image {
- anchors.centerIn: parent
- source: "gfx/text-highscore-new.png"
- rotation: -10
- }
- }
-
- Image {
- id: puzzleTextBubble
- anchors.centerIn: parent
- opacity: 0
- Behavior on opacity { NumberAnimation {} }
- z: 10
- source: "gfx/bubble-puzzle.png"
- Connections {
- target: gameCanvas
- onModeChanged: if (mode != "puzzle" && puzzleTextBubble.opacity > 0) puzzleTextBubble.opacity = 0;
- }
- Text {
- id: puzzleTextLabel
- width: parent.width - 24
- anchors.centerIn: parent
- horizontalAlignment: Text.AlignHCenter
- color: "white"
- font.pixelSize: 24
- font.bold: true
- wrapMode: Text.WordWrap
- }
- }
- onModeChanged: {
- p1WonImg.opacity = 0;
- p2WonImg.opacity = 0;
- }
- SmokeText { id: puzzleWin; source: "gfx/icon-ok.png"; system: particleSystem }
- SmokeText { id: puzzleFail; source: "gfx/icon-fail.png"; system: particleSystem }
-
- onSwapPlayers: {
- smokeParticle.color = "yellow"
- Logic.turnChange();
- if (curTurn == 1) {
- p1Text.play();
- } else {
- p2Text.play();
- }
- clickDelay.running = true;
- }
- SequentialAnimation {
- id: clickDelay
- ScriptAction { script: gameCanvas.swapping = true; }
- PauseAnimation { duration: 750 }
- ScriptAction { script: gameCanvas.swapping = false; }
- }
-
- SmokeText {
- id: p1Text; source: "gfx/text-p1-go.png";
- system: particleSystem; playerNum: 1
- opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
- }
-
- SmokeText {
- id: p2Text; source: "gfx/text-p2-go.png";
- system: particleSystem; playerNum: 2
- opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
- }
-
- onGameOverChanged: {
- if (gameCanvas.mode == "multiplayer") {
- if (gameCanvas.score >= gameCanvas.score2) {
- p1WonImg.opacity = 1;
- } else {
- p2WonImg.opacity = 1;
- }
- }
- }
- Image {
- id: p1WonImg
- source: "gfx/text-p1-won.png"
- anchors.centerIn: parent
- opacity: 0
- Behavior on opacity { NumberAnimation {} }
- z: 10
- }
- Image {
- id: p2WonImg
- source: "gfx/text-p2-won.png"
- anchors.centerIn: parent
- opacity: 0
- Behavior on opacity { NumberAnimation {} }
- z: 10
- }
-
- ParticleSystem{
- id: particleSystem;
- anchors.fill: parent
- z: 5
- ImageParticle {
- id: smokeParticle
- groups: ["smoke"]
- source: "gfx/particle-smoke.png"
- alpha: 0.1
- alphaVariation: 0.1
- color: "yellow"
- }
- Loader {
- id: auxLoader
- anchors.fill: parent
- source: "PrimaryPack.qml"
- onItemChanged: {
- if (item && "particleSystem" in item)
- item.particleSystem = particleSystem
- if (item && "gameArea" in item)
- item.gameArea = gameCanvas
- }
- }
- }
-}
-
diff --git a/examples/quick/demos/samegame/content/LogoAnimation.qml b/examples/quick/demos/samegame/content/LogoAnimation.qml
deleted file mode 100644
index fd89ea8167..0000000000
--- a/examples/quick/demos/samegame/content/LogoAnimation.qml
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container //Positioned where the 48x48 S/G should be
- property alias running: mainAnim.running
- property ParticleSystem particleSystem
- property int dur: 500
- signal boomTime
- Image {
- id: s1
- source: "gfx/logo-s.png"
- y: 0
- }
- Image {
- id: g1
- source: "gfx/logo-g.png"
- y: -128
- }
- Column {
- Repeater {
- model: 2
- Item {
- width: 48
- height: 48
- BlockEmitter {
- id: emitter
- anchors.fill: parent
- group: "red"
- system: particleSystem
- Connections {
- target: container
- onBoomTime: emitter.pulse(100);
- }
- }
- }
- }
- }
- SequentialAnimation {
- id: mainAnim
- running: true
- loops: -1
- PropertyAction { target: g1; property: "y"; value: -128}
- PropertyAction { target: g1; property: "opacity"; value: 1}
- PropertyAction { target: s1; property: "y"; value: 0}
- PropertyAction { target: s1; property: "opacity"; value: 1}
- NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur}
- ParallelAnimation {
- NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur}
- NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur }
- }
- PauseAnimation { duration: dur }
- ScriptAction { script: container.boomTime(); }
- ParallelAnimation {
- NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur }
- NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur }
- }
- PropertyAction { target: s1; property: "y"; value: -128}
- PropertyAction { target: s1; property: "opacity"; value: 1}
- NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2}
- }
-}
diff --git a/examples/quick/demos/samegame/content/PaintEmitter.qml b/examples/quick/demos/samegame/content/PaintEmitter.qml
deleted file mode 100644
index dd67c966a2..0000000000
--- a/examples/quick/demos/samegame/content/PaintEmitter.qml
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "."
-
-Emitter {
- property Item block: parent
- anchors.fill: parent
- shape: EllipseShape { fill: true }
- group: {
- if (block.type == 0){
- "redspots";
- } else if (block.type == 1) {
- "bluespots";
- } else if (block.type == 2) {
- "greenspots";
- } else {
- "yellowspots";
- }
- }
- size: Settings.blockSize * 2
- endSize: Settings.blockSize/2
- lifeSpan: 30000
- enabled: false
- emitRate: 60
- maximumEmitted: 60
- velocity: PointDirection{ y: 4; yVariation: 4 }
- /* Possibly better, but dependent on gerrit change,28212
- property real mainIntensity: 0.8
- property real subIntensity: 0.1
- property real colorVariation: 0.005
- onEmitParticles: {//One group, many colors, for better stacking
- for (var i=0; i<particles.length; i++) {
- var particle = particles[i];
- if (block.type == 0) {
- particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- } else if (block.type == 1) {
- particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- } else if (block.type == 2) {
- particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- } else if (block.type == 3) {
- particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- } else {
- particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
- }
- }
- }
- */
-}
diff --git a/examples/quick/demos/samegame/content/PrimaryPack.qml b/examples/quick/demos/samegame/content/PrimaryPack.qml
deleted file mode 100644
index 0e3b77087c..0000000000
--- a/examples/quick/demos/samegame/content/PrimaryPack.qml
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property ParticleSystem particleSystem
- property GameArea gameArea
- onGameAreaChanged: bgstacker.parent = gameArea;//Move to direct child of game canvas
- Item {
- id: bgstacker
- z: 0
- ImageParticle {
- groups: ["yellowspots"]
- color: Qt.darker("yellow");//Actually want desaturated...
- system: particleSystem
- source: "gfx/particle-paint.png"
- colorVariation: 0.2
- alpha: 0.2
- entryEffect: ImageParticle.None
- }
- ImageParticle {
- groups: ["redspots"]
- system: particleSystem
- color: Qt.darker("red");//Actually want desaturated...
- source: "gfx/particle-paint.png"
- colorVariation: 0.2
- alpha: 0.2
- entryEffect: ImageParticle.None
- }
- ImageParticle {
- groups: ["greenspots"]
- system: particleSystem
- color: Qt.darker("green");//Actually want desaturated...
- source: "gfx/particle-paint.png"
- colorVariation: 0.2
- alpha: 0.2
- entryEffect: ImageParticle.None
- }
- ImageParticle {
- groups: ["bluespots"]
- system: particleSystem
- color: Qt.darker("blue");//Actually want desaturated...
- source: "gfx/particle-paint.png"
- colorVariation: 0.2
- alpha: 0.2
- entryEffect: ImageParticle.None
- }
- }
- ImageParticle {
- groups: ["yellow"]
- system: particleSystem
- color: Qt.darker("yellow");//Actually want desaturated...
- source: "gfx/particle-brick.png"
- colorVariation: 0.4
- alpha: 0.1
- }
- ImageParticle {
- groups: ["red"]
- system: particleSystem
- color: Qt.darker("red");//Actually want desaturated...
- source: "gfx/particle-brick.png"
- colorVariation: 0.4
- alpha: 0.1
- }
- ImageParticle {
- groups: ["green"]
- system: particleSystem
- color: Qt.darker("green");//Actually want desaturated...
- source: "gfx/particle-brick.png"
- colorVariation: 0.4
- alpha: 0.1
- }
- ImageParticle {
- groups: ["blue"]
- system: particleSystem
- color: Qt.darker("blue");//Actually want desaturated...
- source: "gfx/particle-brick.png"
- colorVariation: 0.4
- alpha: 0.1
- }
-}
diff --git a/examples/quick/demos/samegame/content/PuzzleBlock.qml b/examples/quick/demos/samegame/content/PuzzleBlock.qml
deleted file mode 100644
index f65b79d516..0000000000
--- a/examples/quick/demos/samegame/content/PuzzleBlock.qml
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: block
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property ParticleSystem particleSystem
-
- Behavior on x {
- enabled: spawned;
- NumberAnimation{ easing.type: Easing.OutBounce }
- }
- Behavior on y {
- NumberAnimation{ easing.type: Easing.InQuad }
- }
-
- Image {
- id: img
- source: {
- if (type == 0){
- "gfx/red-puzzle.png";
- } else if (type == 1) {
- "gfx/blue-puzzle.png";
- } else if (type == 2) {
- "gfx/green-puzzle.png";
- } else {
- "gfx/yellow-puzzle.png";
- }
- }
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- anchors.centerIn: parent
- anchors.verticalCenterOffset: -4
- anchors.horizontalCenterOffset: 4
- }
-
- //Foreground particles
- BlockEmitter {
- id: particles
- system: particleSystem
- group: {
- if (type == 0){
- "red";
- } else if (type == 1) {
- "blue";
- } else if (type == 2) {
- "green";
- } else {
- "yellow";
- }
- }
- anchors.fill: parent
- }
-
- states: [
- State {
- name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
-
- State {
- name: "DeathState"; when: dying == true
- PropertyChanges { target: img; scale: 2 }
- StateChangeScript { script: particles.pulse(200); }
- PropertyChanges { target: img; opacity: 0 }
- StateChangeScript { script: block.destroy(1000); }
- }
- ]
-}
diff --git a/examples/quick/demos/samegame/content/SamegameText.qml b/examples/quick/demos/samegame/content/SamegameText.qml
deleted file mode 100644
index c69272bad3..0000000000
--- a/examples/quick/demos/samegame/content/SamegameText.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2012 Research In Motion
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "."
-
-Text {
- font.pixelSize: Settings.fontPixelSize;
- color: "white";
- textFormat: Text.StyledText;
- Behavior on opacity { NumberAnimation {} }
-}
diff --git a/examples/quick/demos/samegame/content/SimpleBlock.qml b/examples/quick/demos/samegame/content/SimpleBlock.qml
deleted file mode 100644
index eb2c458d4f..0000000000
--- a/examples/quick/demos/samegame/content/SimpleBlock.qml
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: block
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property ParticleSystem particleSystem
-
- Behavior on x {
- enabled: spawned;
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
- Behavior on y {
- SpringAnimation{ spring: 2; damping: 0.2 }
- }
-
- Image {
- id: img
- source: {
- if (type == 0){
- "gfx/red.png";
- } else if (type == 1) {
- "gfx/blue.png";
- } else if (type == 2) {
- "gfx/green.png";
- } else {
- "gfx/yellow.png";
- }
- }
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- anchors.fill: parent
- }
-
- //Foreground particles
- BlockEmitter {
- id: particles
- system: particleSystem
- group: {
- if (type == 0){
- "red";
- } else if (type == 1) {
- "blue";
- } else if (type == 2) {
- "green";
- } else {
- "yellow";
- }
- }
- anchors.fill: parent
- }
-
- states: [
- State {
- name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
-
- State {
- name: "DeathState"; when: dying == true
- StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); } }
- PropertyChanges { target: img; opacity: 0 }
- StateChangeScript { script: block.destroy(1000); }
- }
- ]
-}
diff --git a/examples/quick/demos/samegame/content/SmokeText.qml b/examples/quick/demos/samegame/content/SmokeText.qml
deleted file mode 100644
index 1fc72010db..0000000000
--- a/examples/quick/demos/samegame/content/SmokeText.qml
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- z: 10
- property alias source: img.source
- property alias system: emitter.system
- property int playerNum: 1
- function play() {
- anim.running = true;
- }
- anchors.centerIn: parent
- Image {
- opacity: 0
- id: img
- anchors.centerIn: parent
- rotation: playerNum == 1 ? -8 : -5
- Emitter {
- id: emitter
- group: "smoke"
- anchors.fill: parent
- shape: MaskShape { source: img.source }
- enabled: false
- emitRate: 1000
- lifeSpan: 600
- size: 64
- endSize: 32
- velocity: AngleDirection { angleVariation: 360; magnitudeVariation: 160 }
- }
- }
- SequentialAnimation {
- id: anim
- running: false
- PauseAnimation { duration: 500}
- ParallelAnimation {
- NumberAnimation { target: img; property: "opacity"; from: 0.1; to: 1.0 }
- NumberAnimation { target: img; property: "scale"; from: 0.1; to: 1.0 }
- }
- PauseAnimation { duration: 250}
- ScriptAction { script: emitter.pulse(100); }
- NumberAnimation { target: img; property: "opacity"; from: 1.0; to: 0.0 }
- }
-}
diff --git a/examples/quick/demos/samegame/content/gfx/background-puzzle.png b/examples/quick/demos/samegame/content/gfx/background-puzzle.png
deleted file mode 100644
index c2eca5f5dc..0000000000
--- a/examples/quick/demos/samegame/content/gfx/background-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/background.png b/examples/quick/demos/samegame/content/gfx/background.png
deleted file mode 100644
index 60f57b650f..0000000000
--- a/examples/quick/demos/samegame/content/gfx/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bar.png b/examples/quick/demos/samegame/content/gfx/bar.png
deleted file mode 100644
index 4953cd6221..0000000000
--- a/examples/quick/demos/samegame/content/gfx/bar.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/blue-puzzle.png b/examples/quick/demos/samegame/content/gfx/blue-puzzle.png
deleted file mode 100644
index e550d5935b..0000000000
--- a/examples/quick/demos/samegame/content/gfx/blue-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/blue.png b/examples/quick/demos/samegame/content/gfx/blue.png
deleted file mode 100644
index b8161c0f70..0000000000
--- a/examples/quick/demos/samegame/content/gfx/blue.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bubble-highscore.png b/examples/quick/demos/samegame/content/gfx/bubble-highscore.png
deleted file mode 100644
index c4e38df824..0000000000
--- a/examples/quick/demos/samegame/content/gfx/bubble-highscore.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png b/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png
deleted file mode 100644
index 278556bc8d..0000000000
--- a/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-1.png b/examples/quick/demos/samegame/content/gfx/but-game-1.png
deleted file mode 100644
index 3343b7ff13..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-game-1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-2.png b/examples/quick/demos/samegame/content/gfx/but-game-2.png
deleted file mode 100644
index afba106962..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-game-2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-3.png b/examples/quick/demos/samegame/content/gfx/but-game-3.png
deleted file mode 100644
index adea77a687..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-game-3.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-4.png b/examples/quick/demos/samegame/content/gfx/but-game-4.png
deleted file mode 100644
index 18c922ba45..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-game-4.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-new.png b/examples/quick/demos/samegame/content/gfx/but-game-new.png
deleted file mode 100644
index 257e182585..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-game-new.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-menu.png b/examples/quick/demos/samegame/content/gfx/but-menu.png
deleted file mode 100644
index 8440e87759..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-menu.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png b/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png
deleted file mode 100644
index 7e3ed417d0..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-quit.png b/examples/quick/demos/samegame/content/gfx/but-quit.png
deleted file mode 100644
index 95c77ced94..0000000000
--- a/examples/quick/demos/samegame/content/gfx/but-quit.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/green-puzzle.png b/examples/quick/demos/samegame/content/gfx/green-puzzle.png
deleted file mode 100644
index 581f76fd8d..0000000000
--- a/examples/quick/demos/samegame/content/gfx/green-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/green.png b/examples/quick/demos/samegame/content/gfx/green.png
deleted file mode 100644
index da4cca5e7f..0000000000
--- a/examples/quick/demos/samegame/content/gfx/green.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-fail.png b/examples/quick/demos/samegame/content/gfx/icon-fail.png
deleted file mode 100644
index 40726118a9..0000000000
--- a/examples/quick/demos/samegame/content/gfx/icon-fail.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-ok.png b/examples/quick/demos/samegame/content/gfx/icon-ok.png
deleted file mode 100644
index 15a8442e94..0000000000
--- a/examples/quick/demos/samegame/content/gfx/icon-ok.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-time.png b/examples/quick/demos/samegame/content/gfx/icon-time.png
deleted file mode 100644
index 9490e49e90..0000000000
--- a/examples/quick/demos/samegame/content/gfx/icon-time.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-a.png b/examples/quick/demos/samegame/content/gfx/logo-a.png
deleted file mode 100644
index 20c20ba480..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo-a.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-e.png b/examples/quick/demos/samegame/content/gfx/logo-e.png
deleted file mode 100644
index dd663f114a..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo-e.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-g.png b/examples/quick/demos/samegame/content/gfx/logo-g.png
deleted file mode 100644
index a319bf9ffa..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo-g.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-m.png b/examples/quick/demos/samegame/content/gfx/logo-m.png
deleted file mode 100644
index 6a029b3267..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo-m.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-s.png b/examples/quick/demos/samegame/content/gfx/logo-s.png
deleted file mode 100644
index 963b17546a..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo-s.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo.png b/examples/quick/demos/samegame/content/gfx/logo.png
deleted file mode 100644
index e900eddb2f..0000000000
--- a/examples/quick/demos/samegame/content/gfx/logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-brick.png b/examples/quick/demos/samegame/content/gfx/particle-brick.png
deleted file mode 100644
index 5c83896d22..0000000000
--- a/examples/quick/demos/samegame/content/gfx/particle-brick.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-paint.png b/examples/quick/demos/samegame/content/gfx/particle-paint.png
deleted file mode 100644
index 9bd0a2a13f..0000000000
--- a/examples/quick/demos/samegame/content/gfx/particle-paint.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-smoke.png b/examples/quick/demos/samegame/content/gfx/particle-smoke.png
deleted file mode 100644
index b27f954a79..0000000000
--- a/examples/quick/demos/samegame/content/gfx/particle-smoke.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/red-puzzle.png b/examples/quick/demos/samegame/content/gfx/red-puzzle.png
deleted file mode 100644
index 9ceb17e4d0..0000000000
--- a/examples/quick/demos/samegame/content/gfx/red-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/red.png b/examples/quick/demos/samegame/content/gfx/red.png
deleted file mode 100644
index 681810fe3b..0000000000
--- a/examples/quick/demos/samegame/content/gfx/red.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-highscore-new.png b/examples/quick/demos/samegame/content/gfx/text-highscore-new.png
deleted file mode 100644
index 50f7fcd0f6..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-highscore-new.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-highscore.png b/examples/quick/demos/samegame/content/gfx/text-highscore.png
deleted file mode 100644
index 7198c277b8..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-highscore.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-no-winner.png b/examples/quick/demos/samegame/content/gfx/text-no-winner.png
deleted file mode 100644
index b4a6685111..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-no-winner.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1-go.png b/examples/quick/demos/samegame/content/gfx/text-p1-go.png
deleted file mode 100644
index c7bd2a5e75..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p1-go.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1-won.png b/examples/quick/demos/samegame/content/gfx/text-p1-won.png
deleted file mode 100644
index 41c2eb7c98..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p1-won.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1.png b/examples/quick/demos/samegame/content/gfx/text-p1.png
deleted file mode 100644
index b59c87b977..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2-go.png b/examples/quick/demos/samegame/content/gfx/text-p2-go.png
deleted file mode 100644
index f03cd93afa..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p2-go.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2-won.png b/examples/quick/demos/samegame/content/gfx/text-p2-won.png
deleted file mode 100644
index 116b7f2e7a..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p2-won.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2.png b/examples/quick/demos/samegame/content/gfx/text-p2.png
deleted file mode 100644
index d4f2bc7335..0000000000
--- a/examples/quick/demos/samegame/content/gfx/text-p2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png b/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png
deleted file mode 100644
index 66044c81b4..0000000000
--- a/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/yellow.png b/examples/quick/demos/samegame/content/gfx/yellow.png
deleted file mode 100644
index 6bc5d385e3..0000000000
--- a/examples/quick/demos/samegame/content/gfx/yellow.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/content/levels/TemplateBase.qml b/examples/quick/demos/samegame/content/levels/TemplateBase.qml
deleted file mode 100644
index 6501f277eb..0000000000
--- a/examples/quick/demos/samegame/content/levels/TemplateBase.qml
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle{
- id: control
- property int scoreTarget: -1
- property int timeTarget: -1
- property int moveTarget: -1
- property bool mustClear: true
- property string goalText: "Clear the level..."
-
- property var startingGrid //If this isn't an array of ints, we will refuse to load the level.
- /* Ints are 0-4. If not enough ints are there it will be prepadded with 0s to fill the grid
- (which ruins everything if you have the wrong number of rows).
- 0 - No block
- 1 - Red
- 2 - Blue
- 3 - Green
- 4 - Yellow
- Ideas for future colors, but not supported in this version:
- 5 - Purple
- 6 - Cyan
- 7 - Gray
- 8 - Black
- 9 - White
- */
-
- width: 320
- height: 416
- color: "white" //TODO: Theme support for both setting themes per level, and seeing it in the control!
-}
diff --git a/examples/quick/demos/samegame/content/levels/level0.qml b/examples/quick/demos/samegame/content/levels/level0.qml
deleted file mode 100644
index 3c09b1f3d3..0000000000
--- a/examples/quick/demos/samegame/content/levels/level0.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- moveTarget: 3
- goalText: "1 of 10<br><br>Clear in three moves..."
- startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ,
- 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 1 ,
- 0 , 0 , 0 , 1 , 1 , 3 , 3 , 3 , 3 , 3 ,
- 0 , 1 , 1 , 3 , 3 , 3 , 1 , 3 , 1 , 1 ,
- 1 , 2 , 3 , 3 , 1 , 1 , 3 , 3 , 3 , 3 ,
- 1 , 3 , 3 , 2 , 3 , 3 , 3 , 3 , 1 , 1 ,
- 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level1.qml b/examples/quick/demos/samegame/content/levels/level1.qml
deleted file mode 100644
index 29ad09cf0e..0000000000
--- a/examples/quick/demos/samegame/content/levels/level1.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- timeTarget: 10
- goalText: "2 of 10<br><br>Clear in 10 seconds..."
- startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 1 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 2 ,
- 1 , 2 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 ,
- 2 , 2 , 1 , 3 , 3 , 3 , 1 , 1 , 1 , 2 ,
- 2 , 1 , 1 , 1 , 3 , 3 , 3 , 1 , 2 , 2 ,
- 1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 2 , 1 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level2.qml b/examples/quick/demos/samegame/content/levels/level2.qml
deleted file mode 100644
index 830776223c..0000000000
--- a/examples/quick/demos/samegame/content/levels/level2.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- scoreTarget: 1200
- timeTarget: 60
- goalText: "3 of 10<br><br>Score over 1200 points in one minute..."
- mustClear: false
- startingGrid: [ 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 3 , 3 ,
- 1 , 3 , 3 , 2 , 3 , 3 , 1 , 1 , 3 , 1 ,
- 3 , 1 , 3 , 3 , 2 , 3 , 3 , 3 , 1 , 2 ,
- 3 , 2 , 2 , 1 , 3 , 3 , 2 , 1 , 1 , 2 ,
- 3 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 3 , 1 ,
- 2 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , 3 , 2 ,
- 3 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 2 , 1 ,
- 1 , 2 , 2 , 3 , 2 , 3 , 3 , 3 , 1 , 1 ,
- 1 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 1 ,
- 3 , 3 , 2 , 1 , 2 , 2 , 1 , 1 , 1 , 3 ,
- 2 , 1 , 3 , 2 , 3 , 2 , 3 , 2 , 2 , 1 ,
- 1 , 3 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 2 ,
- 1 , 2 , 2 , 2 , 1 , 1 , 2 , 3 , 1 , 2 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level3.qml b/examples/quick/demos/samegame/content/levels/level3.qml
deleted file mode 100644
index 91b03a1658..0000000000
--- a/examples/quick/demos/samegame/content/levels/level3.qml
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- scoreTarget: 3000
- timeTarget: 60
- goalText: "4 of 10<br>Clear the board with over 3000 points in under a minute..."
- startingGrid: [ 3 , 3 , 1 , 1 , 1 , 2 , 2 , 4 , 3 , 3 ,
- 4 , 3 , 1 , 4 , 2 , 2 , 2 , 4 , 3 , 4 ,
- 4 , 3 , 3 , 4 , 1 , 1 , 3 , 3 , 4 , 4 ,
- 3 , 3 , 3 , 3 , 3 , 1 , 3 , 2 , 2 , 4 ,
- 4 , 4 , 3 , 4 , 3 , 1 , 4 , 4 , 4 , 4 ,
- 4 , 4 , 3 , 4 , 1 , 1 , 4 , 4 , 3 , 3 ,
- 4 , 2 , 2 , 2 , 2 , 2 , 4 , 4 , 4 , 1 ,
- 4 , 4 , 2 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ,
- 4 , 4 , 2 , 4 , 2 , 2 , 1 , 4 , 4 , 1 ,
- 4 , 1 , 1 , 4 , 3 , 3 , 4 , 2 , 4 , 1 ,
- 4 , 1 , 1 , 2 , 3 , 3 , 4 , 2 , 2 , 1 ,
- 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 2 , 1 ,
- 4 , 1 , 1 , 2 , 2 , 3 , 4 , 3 , 4 , 4 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level4.qml b/examples/quick/demos/samegame/content/levels/level4.qml
deleted file mode 100644
index 589d386845..0000000000
--- a/examples/quick/demos/samegame/content/levels/level4.qml
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- goalText: "5 of 10<br><br>Clear the level..."
- startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
- 1 , 3 , 2 , 1 , 1 , 1 , 1 , 3 , 2 , 3 ,
- 1 , 2 , 3 , 1 , 3 , 2 , 2 , 1 , 1 , 2 ,
- 3 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 ,
- 2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 3 ,
- 1 , 3 , 3 , 1 , 2 , 1 , 2 , 1 , 3 , 3 ,
- 1 , 3 , 2 , 2 , 2 , 1 , 1 , 3 , 2 , 3 ,
- 1 , 1 , 3 , 2 , 3 , 3 , 2 , 1 , 1 , 1 ,
- 1 , 2 , 2 , 3 , 2 , 2 , 1 , 3 , 1 , 3 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level5.qml b/examples/quick/demos/samegame/content/levels/level5.qml
deleted file mode 100644
index 78ee6eb355..0000000000
--- a/examples/quick/demos/samegame/content/levels/level5.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- moveTarget: 4
- goalText: "6 of 10<br><br>Clear in four or less moves..."
- startingGrid: [ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
- 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
- 4 , 2 , 4 , 4 , 4 , 3 , 2 , 3 , 4 , 4 ,
- 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
- 4 , 4 , 4 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
- 4 , 2 , 2 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
- 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
- 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
- 4 , 3 , 3 , 3 , 4 , 2 , 4 , 4 , 4 , 3 ,
- 4 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
- 4 , 3 , 4 , 3 , 4 , 2 , 4 , 4 , 4 , 4 ,
- 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
- 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level6.qml b/examples/quick/demos/samegame/content/levels/level6.qml
deleted file mode 100644
index 3e56808dc7..0000000000
--- a/examples/quick/demos/samegame/content/levels/level6.qml
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- moveTarget: 20
- timeTarget: 40
- goalText: "7 of 10<br><br>Clear with 20 moves in 40 seconds (or better)."
- startingGrid: [ 1 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 ,
- 2 , 1 , 2 , 3 , 3 , 1 , 3 , 1 , 1 , 3 ,
- 3 , 1 , 1 , 1 , 2 , 2 , 3 , 2 , 3 , 1 ,
- 1 , 3 , 1 , 1 , 3 , 1 , 1 , 1 , 2 , 3 ,
- 2 , 1 , 1 , 1 , 3 , 2 , 3 , 3 , 2 , 3 ,
- 3 , 3 , 3 , 3 , 2 , 2 , 3 , 1 , 3 , 2 ,
- 2 , 2 , 3 , 2 , 2 , 3 , 2 , 2 , 2 , 2 ,
- 1 , 2 , 1 , 2 , 1 , 3 , 2 , 3 , 2 , 3 ,
- 1 , 1 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 2 ,
- 3 , 3 , 2 , 2 , 2 , 2 , 3 , 1 , 3 , 1 ,
- 1 , 2 , 3 , 3 , 3 , 1 , 3 , 2 , 1 , 2 ,
- 1 , 2 , 1 , 1 , 2 , 3 , 1 , 2 , 1 , 3 ,
- 3 , 1 , 2 , 2 , 1 , 3 , 3 , 1 , 3 , 2 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level7.qml b/examples/quick/demos/samegame/content/levels/level7.qml
deleted file mode 100644
index 2e412a0c79..0000000000
--- a/examples/quick/demos/samegame/content/levels/level7.qml
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- goalText: "8 of 10<br><br>Clear the grid."
- startingGrid: [ 2 , 4 , 3 , 2 , 3 , 2 , 3 , 3 , 4 , 3 ,
- 2 , 2 , 3 , 3 , 1 , 4 , 3 , 3 , 3 , 2 ,
- 1 , 4 , 2 , 3 , 4 , 3 , 3 , 1 , 1 , 1 ,
- 2 , 1 , 2 , 4 , 4 , 2 , 2 , 3 , 2 , 1 ,
- 3 , 4 , 4 , 1 , 3 , 2 , 4 , 2 , 1 , 1 ,
- 2 , 2 , 3 , 1 , 2 , 4 , 1 , 2 , 1 , 2 ,
- 1 , 2 , 3 , 2 , 4 , 4 , 3 , 1 , 1 , 2 ,
- 4 , 4 , 2 , 1 , 2 , 4 , 2 , 2 , 4 , 3 ,
- 4 , 2 , 4 , 1 , 3 , 4 , 1 , 4 , 2 , 4 ,
- 4 , 3 , 4 , 1 , 4 , 3 , 1 , 3 , 1 , 1 ,
- 3 , 3 , 2 , 3 , 2 , 4 , 1 , 2 , 4 , 4 ,
- 3 , 4 , 2 , 2 , 4 , 3 , 4 , 1 , 3 , 2 ,
- 4 , 3 , 3 , 4 , 2 , 4 , 1 , 2 , 3 , 2 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level8.qml b/examples/quick/demos/samegame/content/levels/level8.qml
deleted file mode 100644
index 18daa76286..0000000000
--- a/examples/quick/demos/samegame/content/levels/level8.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- scoreTarget: 1000
- goalText: "9 of 10<br><br>Score over 1000 points"
- startingGrid: [ 1 , 4 , 4 , 3 , 2 , 1 , 4 , 2 , 4 , 2 ,
- 2 , 3 , 4 , 4 , 1 , 1 , 1 , 4 , 4 , 4 ,
- 1 , 3 , 1 , 2 , 2 , 1 , 2 , 1 , 4 , 2 ,
- 4 , 3 , 4 , 2 , 1 , 4 , 1 , 2 , 2 , 3 ,
- 3 , 4 , 2 , 4 , 4 , 3 , 2 , 2 , 2 , 1 ,
- 4 , 4 , 3 , 2 , 4 , 4 , 2 , 1 , 1 , 1 ,
- 1 , 2 , 1 , 3 , 4 , 1 , 1 , 3 , 2 , 3 ,
- 3 , 4 , 2 , 2 , 1 , 3 , 2 , 2 , 4 , 2 ,
- 2 , 4 , 1 , 2 , 2 , 4 , 3 , 3 , 3 , 1 ,
- 1 , 2 , 2 , 4 , 1 , 2 , 2 , 3 , 3 , 3 ,
- 4 , 4 , 1 , 4 , 3 , 1 , 3 , 3 , 3 , 4 ,
- 1 , 2 , 4 , 1 , 2 , 1 , 1 , 4 , 2 , 1 ,
- 1 , 2 , 3 , 4 , 2 , 4 , 4 , 2 , 1 , 3 ]
-}
diff --git a/examples/quick/demos/samegame/content/levels/level9.qml b/examples/quick/demos/samegame/content/levels/level9.qml
deleted file mode 100644
index 38d6673189..0000000000
--- a/examples/quick/demos/samegame/content/levels/level9.qml
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-TemplateBase{
- scoreTarget: 2000
- timeTarget: 60
- moveTarget: 20
- mustClear: false
- goalText: "10 of 10<br><br>Score 2000 in one minute with less than 20 moves!"
- startingGrid: [ 3 , 2 , 3 , 1 , 3 , 3 , 4 , 1 , 3 , 3 ,
- 2 , 3 , 2 , 1 , 1 , 2 , 2 , 2 , 4 , 1 ,
- 2 , 4 , 4 , 4 , 3 , 1 , 4 , 4 , 4 , 1 ,
- 3 , 1 , 3 , 4 , 4 , 2 , 2 , 2 , 2 , 3 ,
- 2 , 1 , 4 , 4 , 3 , 3 , 1 , 1 , 3 , 2 ,
- 3 , 2 , 1 , 4 , 3 , 4 , 1 , 3 , 4 , 2 ,
- 3 , 3 , 1 , 4 , 4 , 4 , 2 , 1 , 2 , 3 ,
- 2 , 3 , 4 , 3 , 4 , 1 , 1 , 3 , 2 , 4 ,
- 4 , 4 , 1 , 2 , 4 , 3 , 2 , 2 , 2 , 4 ,
- 1 , 4 , 2 , 2 , 1 , 1 , 2 , 1 , 1 , 4 ,
- 1 , 4 , 3 , 3 , 3 , 1 , 3 , 4 , 4 , 2 ,
- 3 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 2 , 1 ,
- 3 , 3 , 4 , 3 , 1 , 1 , 1 , 4 , 4 , 3 ]
-}
diff --git a/examples/quick/demos/samegame/content/qmldir b/examples/quick/demos/samegame/content/qmldir
deleted file mode 100644
index 3b552ec1f1..0000000000
--- a/examples/quick/demos/samegame/content/qmldir
+++ /dev/null
@@ -1,13 +0,0 @@
-singleton Settings 1.0 Settings.qml
-Block 1.0 Block.qml
-BlockEmitter 1.0 BlockEmitter.qml
-Button 1.0 Button.qml
-GameArea 1.0 GameArea.qml
-LogoAnimation 1.0 LogoAnimation.qml
-MenuEmitter 1.0 MenuEmitter.qml
-PaintEmitter 1.0 PaintEmitter.qml
-PrimaryPack 1.0 PrimaryPack.qml
-PuzzleBlock 1.0 PuzzleBlock.qml
-SamegameText 1.0 SamegameText.qml
-SimpleBlock 1.0 SimpleBlock.qml
-SmokeText 1.0 SmokeText.qml
diff --git a/examples/quick/demos/samegame/content/samegame.js b/examples/quick/demos/samegame/content/samegame.js
deleted file mode 100644
index 0e2cd4ea5b..0000000000
--- a/examples/quick/demos/samegame/content/samegame.js
+++ /dev/null
@@ -1,590 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/* This script file handles the game logic */
-.pragma library
-.import QtQuick.LocalStorage 2.0 as Sql
-
-var maxColumn = 10;
-var maxRow = 13;
-var types = 3;
-var maxIndex = maxColumn*maxRow;
-var board = new Array(maxIndex);
-var blockSrc = "Block.qml";
-var gameDuration;
-var component = Qt.createComponent(blockSrc);
-var gameCanvas;
-var betweenTurns = false;
-
-var puzzleLevel = null;
-var puzzlePath = "";
-
-var gameMode = "arcade"; //Set in new game, then tweaks behaviour of other functions
-var gameOver = false;
-
-function changeBlock(src)
-{
- blockSrc = src;
- component = Qt.createComponent(blockSrc);
-}
-
-// Index function used instead of a 2D array
-function index(column, row)
-{
- return column + row * maxColumn;
-}
-
-function timeStr(msecs)
-{
- var secs = Math.floor(msecs/1000);
- var m = Math.floor(secs/60);
- var ret = "" + m + "m " + (secs%60) + "s";
- return ret;
-}
-
-function cleanUp()
-{
- if (gameCanvas == undefined)
- return;
- // Delete blocks from previous game
- for (var i = 0; i < maxIndex; i++) {
- if (board[i] != null)
- board[i].destroy();
- board[i] = null;
- }
- if (puzzleLevel != null){
- puzzleLevel.destroy();
- puzzleLevel = null;
- }
- gameCanvas.mode = ""
-}
-
-function startNewGame(gc, mode, map)
-{
- gameCanvas = gc;
- if (mode == undefined)
- gameMode = "arcade";
- else
- gameMode = mode;
- gameOver = false;
-
- cleanUp();
-
- gc.gameOver = false;
- gc.mode = gameMode;
- // Calculate board size
- maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
- maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
- maxIndex = maxRow * maxColumn;
- if (gameMode == "arcade") //Needs to be after board sizing
- getHighScore();
-
-
- // Initialize Board
- board = new Array(maxIndex);
- gameCanvas.score = 0;
- gameCanvas.score2 = 0;
- gameCanvas.moves = 0;
- gameCanvas.curTurn = 1;
- if (gameMode == "puzzle")
- loadMap(map);
- else//Note that we load them in reverse order for correct visual stacking
- for (var column = maxColumn - 1; column >= 0; column--)
- for (var row = maxRow - 1; row >= 0; row--)
- createBlock(column, row);
- if (gameMode == "puzzle")
- getLevelHistory();//Needs to be after map load
- gameDuration = new Date();
-}
-
-var fillFound; // Set after a floodFill call to the number of blocks found
-var floodBoard; // Set to 1 if the floodFill reaches off that node
-
-// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
-function handleClick(x,y)
-{
- if (betweenTurns || gameOver || gameCanvas == undefined)
- return;
- var column = Math.floor(x/gameCanvas.blockSize);
- var row = Math.floor(y/gameCanvas.blockSize);
- if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
- return;
- if (board[index(column, row)] == null)
- return;
- // If it's a valid block, remove it and all connected (does nothing if it's not connected)
- floodFill(column,row, -1);
- if (fillFound <= 0)
- return;
- if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
- gameCanvas.score2 += (fillFound - 1) * (fillFound - 1);
- else
- gameCanvas.score += (fillFound - 1) * (fillFound - 1);
- if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
- shuffleUp();
- else
- shuffleDown();
- gameCanvas.moves += 1;
- if (gameMode == "endless")
- refill();
- else if (gameMode != "multiplayer")
- victoryCheck();
- if (gameMode == "multiplayer" && !gc.gameOver){
- betweenTurns = true;
- gameCanvas.swapPlayers();//signal, animate and call turnChange() when ready
- }
-}
-
-function floodFill(column,row,type)
-{
- if (board[index(column, row)] == null)
- return;
- var first = false;
- if (type == -1) {
- first = true;
- type = board[index(column,row)].type;
-
- // Flood fill initialization
- fillFound = 0;
- floodBoard = new Array(maxIndex);
- }
- if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
- return;
- if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
- return;
- floodBoard[index(column, row)] = 1;
- floodFill(column + 1, row, type);
- floodFill(column - 1, row, type);
- floodFill(column, row + 1, type);
- floodFill(column, row - 1, type);
- if (first == true && fillFound == 0)
- return; // Can't remove single blocks
- board[index(column, row)].dying = true;
- board[index(column, row)] = null;
- fillFound += 1;
-}
-
-function shuffleDown()
-{
- // Fall down
- for (var column = 0; column < maxColumn; column++) {
- var fallDist = 0;
- for (var row = maxRow - 1; row >= 0; row--) {
- if (board[index(column,row)] == null) {
- fallDist += 1;
- } else {
- if (fallDist > 0) {
- var obj = board[index(column, row)];
- obj.y = (row + fallDist) * gameCanvas.blockSize;
- board[index(column, row + fallDist)] = obj;
- board[index(column, row)] = null;
- }
- }
- }
- }
- // Fall to the left
- fallDist = 0;
- for (column = 0; column < maxColumn; column++) {
- if (board[index(column, maxRow - 1)] == null) {
- fallDist += 1;
- } else {
- if (fallDist > 0) {
- for (row = 0; row < maxRow; row++) {
- obj = board[index(column, row)];
- if (obj == null)
- continue;
- obj.x = (column - fallDist) * gameCanvas.blockSize;
- board[index(column - fallDist,row)] = obj;
- board[index(column, row)] = null;
- }
- }
- }
- }
-}
-
-
-function shuffleUp()
-{
- // Fall up
- for (var column = 0; column < maxColumn; column++) {
- var fallDist = 0;
- for (var row = 0; row < maxRow; row++) {
- if (board[index(column,row)] == null) {
- fallDist += 1;
- } else {
- if (fallDist > 0) {
- var obj = board[index(column, row)];
- obj.y = (row - fallDist) * gameCanvas.blockSize;
- board[index(column, row - fallDist)] = obj;
- board[index(column, row)] = null;
- }
- }
- }
- }
- // Fall to the left (or should it be right, so as to be left for P2?)
- fallDist = 0;
- for (column = 0; column < maxColumn; column++) {
- if (board[index(column, 0)] == null) {
- fallDist += 1;
- } else {
- if (fallDist > 0) {
- for (row = 0; row < maxRow; row++) {
- obj = board[index(column, row)];
- if (obj == null)
- continue;
- obj.x = (column - fallDist) * gameCanvas.blockSize;
- board[index(column - fallDist,row)] = obj;
- board[index(column, row)] = null;
- }
- }
- }
- }
-}
-
-function turnChange()//called by ui outside
-{
- betweenTurns = false;
- if (gameCanvas.curTurn == 1){
- shuffleUp();
- gameCanvas.curTurn = 2;
- victoryCheck();
- }else{
- shuffleDown();
- gameCanvas.curTurn = 1;
- victoryCheck();
- }
-}
-
-function refill()
-{
- for (var column = 0; column < maxColumn; column++) {
- for (var row = 0; row < maxRow; row++) {
- if (board[index(column, row)] == null)
- createBlock(column, row);
- }
- }
-}
-
-function victoryCheck()
-{
- // Awards bonuses for no blocks left
- var deservesBonus = true;
- if (board[index(0,maxRow - 1)] != null || board[index(0,0)] != null)
- deservesBonus = false;
- // Checks for game over
- if (deservesBonus){
- if (gameCanvas.curTurn = 1)
- gameCanvas.score += 1000;
- else
- gameCanvas.score2 += 1000;
- }
- gameOver = deservesBonus;
- if (gameCanvas.curTurn == 1){
- if (!(floodMoveCheck(0, maxRow - 1, -1)))
- gameOver = true;
- }else{
- if (!(floodMoveCheck(0, 0, -1, true)))
- gameOver = true;
- }
- if (gameMode == "puzzle"){
- puzzleVictoryCheck(deservesBonus);//Takes it from here
- return;
- }
- if (gameOver) {
- var winnerScore = Math.max(gameCanvas.score, gameCanvas.score2);
- if (gameMode == "multiplayer"){
- gameCanvas.score = winnerScore;
- saveHighScore(gameCanvas.score2);
- }
- saveHighScore(gameCanvas.score);
- gameDuration = new Date() - gameDuration;
- gameCanvas.gameOver = true;
- }
-}
-
-// Only floods up and right, to see if it can find adjacent same-typed blocks
-function floodMoveCheck(column, row, type, goDownInstead)
-{
- if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
- return false;
- if (board[index(column, row)] == null)
- return false;
- var myType = board[index(column, row)].type;
- if (type == myType)
- return true;
- if (goDownInstead)
- return floodMoveCheck(column + 1, row, myType, goDownInstead) ||
- floodMoveCheck(column, row + 1, myType, goDownInstead);
- else
- return floodMoveCheck(column + 1, row, myType) ||
- floodMoveCheck(column, row - 1, myType);
-}
-
-function createBlock(column,row,type)
-{
- // Note that we don't wait for the component to become ready. This will
- // only work if the block QML is a local file. Otherwise the component will
- // not be ready immediately. There is a statusChanged signal on the
- // component you could use if you want to wait to load remote files.
- if (component.status == 1){
- if (type == undefined)
- type = Math.floor(Math.random() * types);
- if (type < 0 || type > 4) {
- console.log("Invalid type requested");//TODO: Is this triggered by custom levels much?
- return;
- }
- var dynamicObject = component.createObject(gameCanvas,
- {"type": type,
- "x": column*gameCanvas.blockSize,
- "y": -1*gameCanvas.blockSize,
- "width": gameCanvas.blockSize,
- "height": gameCanvas.blockSize,
- "particleSystem": gameCanvas.ps});
- if (dynamicObject == null){
- console.log("error creating block");
- console.log(component.errorString());
- return false;
- }
- dynamicObject.y = row*gameCanvas.blockSize;
- dynamicObject.spawned = true;
-
- board[index(column,row)] = dynamicObject;
- }else{
- console.log("error loading block component");
- console.log(component.errorString());
- return false;
- }
- return true;
-}
-
-function showPuzzleError(str)
-{
- //TODO: Nice user visible UI?
- console.log(str);
-}
-
-function loadMap(map)
-{
- puzzlePath = map;
- var levelComp = Qt.createComponent(puzzlePath);
- if (levelComp.status != 1){
- console.log("Error loading level");
- showPuzzleError(levelComp.errorString());
- return;
- }
- puzzleLevel = levelComp.createObject();
- if (puzzleLevel == null || !puzzleLevel.startingGrid instanceof Array) {
- showPuzzleError("Bugger!");
- return;
- }
- gameCanvas.showPuzzleGoal(puzzleLevel.goalText);
- //showPuzzleGoal should call finishLoadingMap as the next thing it does, before handling more events
-}
-
-function finishLoadingMap()
-{
- for (var i in puzzleLevel.startingGrid)
- if (! (puzzleLevel.startingGrid[i] >= 0 && puzzleLevel.startingGrid[i] <= 9) )
- puzzleLevel.startingGrid[i] = 0;
- //TODO: Don't allow loading larger levels, leads to cheating
- while (puzzleLevel.startingGrid.length > maxIndex) puzzleLevel.startingGrid.shift();
- while (puzzleLevel.startingGrid.length < maxIndex) puzzleLevel.startingGrid.unshift(0);
- for (var i in puzzleLevel.startingGrid)
- if (puzzleLevel.startingGrid[i] > 0)
- createBlock(i % maxColumn, Math.floor(i / maxColumn), puzzleLevel.startingGrid[i] - 1);
-
- //### Experimental feature - allow levels to contain arbitrary QML scenes as well!
- //while (puzzleLevel.children.length)
- // puzzleLevel.children[0].parent = gameCanvas;
- gameDuration = new Date(); //Don't start until we finish loading
-}
-
-function puzzleVictoryCheck(clearedAll)//gameOver has also been set if no more moves
-{
- var won = true;
- var soFar = new Date() - gameDuration;
- if (puzzleLevel.scoreTarget != -1 && gameCanvas.score < puzzleLevel.scoreTarget){
- won = false;
- } if (puzzleLevel.scoreTarget != -1 && gameCanvas.score >= puzzleLevel.scoreTarget && !puzzleLevel.mustClear){
- gameOver = true;
- } if (puzzleLevel.timeTarget != -1 && soFar/1000.0 > puzzleLevel.timeTarget){
- gameOver = true;
- } if (puzzleLevel.moveTarget != -1 && gameCanvas.moves >= puzzleLevel.moveTarget){
- gameOver = true;
- } if (puzzleLevel.mustClear && gameOver && !clearedAll) {
- won = false;
- }
-
- if (gameOver) {
- gameCanvas.gameOver = true;
- gameCanvas.showPuzzleEnd(won);
-
- if (won) {
- // Store progress
- saveLevelHistory();
- }
- }
-}
-
-function getHighScore()
-{
- var db = Sql.LocalStorage.openDatabaseSync(
- "SameGame",
- "2.0",
- "SameGame Local Data",
- 100
- );
- db.transaction(
- function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
- // Only show results for the current grid size
- var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
- + maxColumn + "x" + maxRow + '" AND game = "' + gameMode + '" ORDER BY score desc');
- if (rs.rows.length > 0)
- gameCanvas.highScore = rs.rows.item(0).score;
- else
- gameCanvas.highScore = 0;
- }
- );
-}
-
-function saveHighScore(score)
-{
- // Offline storage
- var db = Sql.LocalStorage.openDatabaseSync(
- "SameGame",
- "2.0",
- "SameGame Local Data",
- 100
- );
- var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
- var data = [
- gameMode,
- score,
- maxColumn + "x" + maxRow,
- Math.floor(gameDuration / 1000)
- ];
- if (score >= gameCanvas.highScore)//Update UI field
- gameCanvas.highScore = score;
-
- db.transaction(
- function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
- tx.executeSql(dataStr, data);
- }
- );
-}
-
-function getLevelHistory()
-{
- var db = Sql.LocalStorage.openDatabaseSync(
- "SameGame",
- "2.0",
- "SameGame Local Data",
- 100
- );
- db.transaction(
- function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
- var rs = tx.executeSql('SELECT * FROM Puzzle WHERE level = "' + puzzlePath + '" ORDER BY score desc');
- if (rs.rows.length > 0) {
- gameCanvas.puzzleWon = true;
- gameCanvas.highScore = rs.rows.item(0).score;
- } else {
- gameCanvas.puzzleWon = false;
- gameCanvas.highScore = 0;
- }
- }
- );
-}
-
-function saveLevelHistory()
-{
- var db = Sql.LocalStorage.openDatabaseSync(
- "SameGame",
- "2.0",
- "SameGame Local Data",
- 100
- );
- var dataStr = "INSERT INTO Puzzle VALUES(?, ?, ?, ?)";
- var data = [
- puzzlePath,
- gameCanvas.score,
- gameCanvas.moves,
- Math.floor(gameDuration / 1000)
- ];
- gameCanvas.puzzleWon = true;
-
- db.transaction(
- function(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
- tx.executeSql(dataStr, data);
- }
- );
-}
-
-function nuke() //For "Debug mode"
-{
- for (var row = 1; row <= 5; row++) {
- for (var col = 0; col < 5; col++) {
- if (board[index(col, maxRow - row)] != null) {
- board[index(col, maxRow - row)].dying = true;
- board[index(col, maxRow - row)] = null;
- }
- }
- }
- if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
- shuffleUp();
- else
- shuffleDown();
- if (gameMode == "endless")
- refill();
- else
- victoryCheck();
-}
diff --git a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png
deleted file mode 100644
index b13a62d540..0000000000
--- a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png
deleted file mode 100644
index ca9e8368b1..0000000000
--- a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/samegame/doc/src/samegame.qdoc b/examples/quick/demos/samegame/doc/src/samegame.qdoc
deleted file mode 100644
index 25d0376c8e..0000000000
--- a/examples/quick/demos/samegame/doc/src/samegame.qdoc
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Same Game
- \ingroup qtquickdemos
- \example demos/samegame
- \brief A QML implementation of the popular puzzle game by Kuniaki Moribe.
-
- \e{Same Game} demonstrates a QML game with custom types and logic written in
- JavaScript. The game uses various \l{Qt Quick} features such as
- particles, animation, and loading images.
-
- \image qtquick-demo-samegame-med-1.png
- \image qtquick-demo-samegame-med-2.png
-
- For more details about different parts of the example, see
- \l{QML Advanced Tutorial}.
-
- \include examples-run.qdocinc
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/samegame/main.cpp b/examples/quick/demos/samegame/main.cpp
deleted file mode 100644
index d2ccd84cf6..0000000000
--- a/examples/quick/demos/samegame/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/samegame/samegame)
diff --git a/examples/quick/demos/samegame/samegame.pro b/examples/quick/demos/samegame/samegame.pro
deleted file mode 100644
index 7b680490ad..0000000000
--- a/examples/quick/demos/samegame/samegame.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick sql
-SOURCES += main.cpp
-RESOURCES += samegame.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/samegame
-INSTALLS += target
diff --git a/examples/quick/demos/samegame/samegame.qml b/examples/quick/demos/samegame/samegame.qml
deleted file mode 100644
index 6045c512f9..0000000000
--- a/examples/quick/demos/samegame/samegame.qml
+++ /dev/null
@@ -1,382 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content/samegame.js" as Logic
-import "content"
-
-Rectangle {
- id: root
- width: Settings.screenWidth; height: Settings.screenHeight
- property int acc: 0
-
-
- function loadPuzzle() {
- if (gameCanvas.mode != "")
- Logic.cleanUp();
- Logic.startNewGame(gameCanvas,"puzzle","levels/level"+acc+".qml")
- }
- function nextPuzzle() {
- acc = (acc + 1) % 10;
- loadPuzzle();
- }
- Timer {
- id: gameOverTimer
- interval: 1500
- running : gameCanvas.gameOver && gameCanvas.mode == "puzzle" //mode will be reset by cleanUp();
- repeat : false
- onTriggered: {
- Logic.cleanUp();
- nextPuzzle();
- }
- }
-
- Image {
- source: "content/gfx/background.png"
- anchors.fill: parent
- }
-
- GameArea {
- id: gameCanvas
- z: 1
- y: Settings.headerHeight
-
- width: parent.width
- height: parent.height - Settings.headerHeight - Settings.footerHeight
-
- backgroundVisible: root.state == "in-game"
- onModeChanged: if (gameCanvas.mode != "puzzle") puzzleWon = false; //UI has stricter constraints on this variable than the game does
- Age {
- groups: ["redspots", "greenspots", "bluespots", "yellowspots"]
- enabled: root.state == ""
- system: gameCanvas.ps
- }
-
- onPuzzleLost: acc--;//So that nextPuzzle() reloads the current one
-
- }
-
- Item {
- id: menu
- z: 2
- width: parent.width;
- anchors.top: parent.top
- anchors.bottom: bottomBar.top
-
- LogoAnimation {
- x: 64
- y: Settings.headerHeight
- particleSystem: gameCanvas.ps
- running: root.state == ""
- }
- Row {
- x: 112
- y: 20
- Image { source: "content/gfx/logo-a.png" }
- Image { source: "content/gfx/logo-m.png" }
- Image { source: "content/gfx/logo-e.png" }
- }
-
- Column {
- y: 100 + 40
- spacing: Settings.menuButtonSpacing
- width: parent.width
- height: parent.height - (140 + Settings.footerHeight)
-
- Button {
- width: root.width
- rotatedButton: true
- imgSrc: "content/gfx/but-game-1.png"
- onClicked: {
- if (root.state == "in-game")
- return //Prevent double clicking
- root.state = "in-game"
- gameCanvas.blockFile = "Block.qml"
- gameCanvas.background = "gfx/background.png"
- arcadeTimer.start();
- }
- //Emitted particles don't fade out, because ImageParticle is on the GameArea
- system: gameCanvas.ps
- group: "green"
- Timer {
- id: arcadeTimer
- interval: Settings.menuDelay
- running : false
- repeat : false
- onTriggered: Logic.startNewGame(gameCanvas)
- }
- }
-
- Button {
- width: root.width
- rotatedButton: true
- imgSrc: "content/gfx/but-game-2.png"
- onClicked: {
- if (root.state == "in-game")
- return
- root.state = "in-game"
- gameCanvas.blockFile = "Block.qml"
- gameCanvas.background = "gfx/background.png"
- twopTimer.start();
- }
- system: gameCanvas.ps
- group: "green"
- Timer {
- id: twopTimer
- interval: Settings.menuDelay
- running : false
- repeat : false
- onTriggered: Logic.startNewGame(gameCanvas, "multiplayer")
- }
- }
-
- Button {
- width: root.width
- rotatedButton: true
- imgSrc: "content/gfx/but-game-3.png"
- onClicked: {
- if (root.state == "in-game")
- return
- root.state = "in-game"
- gameCanvas.blockFile = "SimpleBlock.qml"
- gameCanvas.background = "gfx/background.png"
- endlessTimer.start();
- }
- system: gameCanvas.ps
- group: "blue"
- Timer {
- id: endlessTimer
- interval: Settings.menuDelay
- running : false
- repeat : false
- onTriggered: Logic.startNewGame(gameCanvas, "endless")
- }
- }
-
- Button {
- width: root.width
- rotatedButton: true
- imgSrc: "content/gfx/but-game-4.png"
- group: "yellow"
- onClicked: {
- if (root.state == "in-game")
- return
- root.state = "in-game"
- gameCanvas.blockFile = "PuzzleBlock.qml"
- gameCanvas.background = "gfx/background.png"
- puzzleTimer.start();
- }
- Timer {
- id: puzzleTimer
- interval: Settings.menuDelay
- running : false
- repeat : false
- onTriggered: loadPuzzle();
- }
- system: gameCanvas.ps
- }
- }
- }
-
- Image {
- id: scoreBar
- source: "content/gfx/bar.png"
- width: parent.width
- z: 6
- y: -Settings.headerHeight
- height: Settings.headerHeight
- Behavior on opacity { NumberAnimation {} }
- SamegameText {
- id: arcadeScore
- anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
- text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
- font.pixelSize: Settings.fontPixelSize
- textFormat: Text.StyledText
- color: "white"
- opacity: gameCanvas.mode == "arcade" ? 1 : 0
- Behavior on opacity { NumberAnimation {} }
- }
- SamegameText {
- id: arcadeHighScore
- anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
- text: '<font color="#f7d303">Highscore:</font> ' + gameCanvas.highScore
- opacity: gameCanvas.mode == "arcade" ? 1 : 0
- }
- SamegameText {
- id: p1Score
- anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
- text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
- opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
- }
- SamegameText {
- id: p2Score
- anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
- text: '<font color="#f7d303">P2:</font> ' + gameCanvas.score2
- opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
- rotation: 180
- }
- SamegameText {
- id: puzzleMoves
- anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
- text: '<font color="#f7d303">Moves:</font> ' + gameCanvas.moves
- opacity: gameCanvas.mode == "puzzle" ? 1 : 0
- }
- SamegameText {
- Image {
- source: "content/gfx/icon-time.png"
- x: -20
- }
- id: puzzleTime
- anchors { topMargin: 3; top: parent.top; horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 20}
- text: "00:00"
- opacity: gameCanvas.mode == "puzzle" ? 1 : 0
- Timer {
- interval: 1000
- repeat: true
- running: gameCanvas.mode == "puzzle" && !gameCanvas.gameOver
- onTriggered: {
- var elapsed = Math.floor((new Date() - Logic.gameDuration)/ 1000.0);
- var mins = Math.floor(elapsed/60.0);
- var secs = (elapsed % 60);
- puzzleTime.text = (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
- }
- }
- }
- SamegameText {
- id: puzzleScore
- anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
- text: '<font color="#f7d303">Score:</font> ' + gameCanvas.score
- opacity: gameCanvas.mode == "puzzle" ? 1 : 0
- }
- }
-
- Image {
- id: bottomBar
- width: parent.width
- height: Settings.footerHeight
- source: "content/gfx/bar.png"
- y: parent.height - Settings.footerHeight;
- z: 2
- Button {
- id: quitButton
- height: Settings.toolButtonHeight
- imgSrc: "content/gfx/but-quit.png"
- onClicked: {Qt.quit(); }
- anchors { left: parent.left; verticalCenter: parent.verticalCenter; leftMargin: 11 }
- }
- Button {
- id: menuButton
- height: Settings.toolButtonHeight
- imgSrc: "content/gfx/but-menu.png"
- visible: (root.state == "in-game");
- onClicked: {root.state = ""; Logic.cleanUp(); gameCanvas.mode = ""}
- anchors { left: quitButton.right; verticalCenter: parent.verticalCenter; leftMargin: 0 }
- }
- Button {
- id: againButton
- height: Settings.toolButtonHeight
- imgSrc: "content/gfx/but-game-new.png"
- visible: (root.state == "in-game");
- opacity: gameCanvas.gameOver && (gameCanvas.mode == "arcade" || gameCanvas.mode == "multiplayer")
- Behavior on opacity{ NumberAnimation {} }
- onClicked: {if (gameCanvas.gameOver) { Logic.startNewGame(gameCanvas, gameCanvas.mode);}}
- anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
- }
- Button {
- id: nextButton
- height: Settings.toolButtonHeight
- imgSrc: "content/gfx/but-puzzle-next.png"
- visible: (root.state == "in-game") && gameCanvas.mode == "puzzle" && gameCanvas.puzzleWon
- opacity: gameCanvas.puzzleWon ? 1 : 0
- Behavior on opacity{ NumberAnimation {} }
- onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();}
- anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
- }
- }
-
- Connections {
- target: root
- onStateChanged: stateChangeAnim.running = true
- }
- SequentialAnimation {
- id: stateChangeAnim
- ParallelAnimation {
- NumberAnimation { target: bottomBar; property: "y"; to: root.height; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
- NumberAnimation { target: scoreBar; property: "y"; to: -Settings.headerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
- }
- ParallelAnimation {
- NumberAnimation { target: bottomBar; property: "y"; to: root.height - Settings.footerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
- NumberAnimation { target: scoreBar; property: "y"; to: root.state == "" ? -Settings.headerHeight : 0; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
- }
- }
-
- states: [
- State {
- name: "in-game"
- PropertyChanges {
- target: menu
- opacity: 0
- visible: false
- }
- }
- ]
-
- transitions: [
- Transition {
- NumberAnimation {properties: "x,y,opacity"}
- }
- ]
-
- //"Debug mode"
- focus: true
- Keys.onAsteriskPressed: Logic.nuke();
- Keys.onSpacePressed: gameCanvas.puzzleWon = true;
-}
diff --git a/examples/quick/demos/samegame/samegame.qmlproject b/examples/quick/demos/samegame/samegame.qmlproject
deleted file mode 100644
index 42ffacf4f8..0000000000
--- a/examples/quick/demos/samegame/samegame.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "samegame.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/samegame/samegame.qrc b/examples/quick/demos/samegame/samegame.qrc
deleted file mode 100644
index 348ee109f9..0000000000
--- a/examples/quick/demos/samegame/samegame.qrc
+++ /dev/null
@@ -1,73 +0,0 @@
-<RCC>
- <qresource prefix="/demos/samegame">
- <file>samegame.qml</file>
- <file>content/qmldir</file>
- <file>content/Settings.qml</file>
- <file>content/gfx/text-p1-won.png</file>
- <file>content/gfx/background-puzzle.png</file>
- <file>content/gfx/background.png</file>
- <file>content/gfx/bar.png</file>
- <file>content/gfx/blue-puzzle.png</file>
- <file>content/gfx/blue.png</file>
- <file>content/gfx/bubble-highscore.png</file>
- <file>content/gfx/bubble-puzzle.png</file>
- <file>content/gfx/but-game-1.png</file>
- <file>content/gfx/but-game-2.png</file>
- <file>content/gfx/but-game-3.png</file>
- <file>content/gfx/but-game-4.png</file>
- <file>content/gfx/but-game-new.png</file>
- <file>content/gfx/but-menu.png</file>
- <file>content/gfx/but-puzzle-next.png</file>
- <file>content/gfx/but-quit.png</file>
- <file>content/gfx/green-puzzle.png</file>
- <file>content/gfx/green.png</file>
- <file>content/gfx/icon-fail.png</file>
- <file>content/gfx/icon-ok.png</file>
- <file>content/gfx/icon-time.png</file>
- <file>content/gfx/logo-a.png</file>
- <file>content/gfx/logo-e.png</file>
- <file>content/gfx/logo-g.png</file>
- <file>content/gfx/logo-m.png</file>
- <file>content/gfx/logo-s.png</file>
- <file>content/gfx/logo.png</file>
- <file>content/gfx/particle-brick.png</file>
- <file>content/gfx/particle-paint.png</file>
- <file>content/gfx/particle-smoke.png</file>
- <file>content/gfx/red-puzzle.png</file>
- <file>content/gfx/red.png</file>
- <file>content/gfx/text-highscore-new.png</file>
- <file>content/gfx/text-highscore.png</file>
- <file>content/gfx/text-no-winner.png</file>
- <file>content/gfx/text-p1-go.png</file>
- <file>content/gfx/text-p1.png</file>
- <file>content/gfx/text-p2-go.png</file>
- <file>content/gfx/text-p2-won.png</file>
- <file>content/gfx/text-p2.png</file>
- <file>content/gfx/yellow-puzzle.png</file>
- <file>content/gfx/yellow.png</file>
- <file>content/levels/level0.qml</file>
- <file>content/levels/level1.qml</file>
- <file>content/levels/level2.qml</file>
- <file>content/levels/level3.qml</file>
- <file>content/levels/level4.qml</file>
- <file>content/levels/level5.qml</file>
- <file>content/levels/level6.qml</file>
- <file>content/levels/level7.qml</file>
- <file>content/levels/level8.qml</file>
- <file>content/levels/level9.qml</file>
- <file>content/levels/TemplateBase.qml</file>
- <file>content/SamegameText.qml</file>
- <file>content/SimpleBlock.qml</file>
- <file>content/Block.qml</file>
- <file>content/BlockEmitter.qml</file>
- <file>content/Button.qml</file>
- <file>content/GameArea.qml</file>
- <file>content/LogoAnimation.qml</file>
- <file>content/MenuEmitter.qml</file>
- <file>content/PaintEmitter.qml</file>
- <file>content/PrimaryPack.qml</file>
- <file>content/PuzzleBlock.qml</file>
- <file>content/samegame.js</file>
- <file>content/SmokeText.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/stocqt/content/Button.qml b/examples/quick/demos/stocqt/content/Button.qml
deleted file mode 100644
index ed9b4ed491..0000000000
--- a/examples/quick/demos/stocqt/content/Button.qml
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "."
-
-Rectangle {
- id: button
- signal clicked
- property alias text: txt.text
- property bool buttonEnabled: false
- width: Math.max(64, txt.width + 16)
- height: 32
- color: "transparent"
- MouseArea {
- anchors.fill: parent
- onClicked: button.clicked()
- }
- Text {
- anchors.centerIn: parent
- font.family: Settings.fontFamily
- font.pointSize: 19
- font.weight: Font.DemiBold
- color: button.buttonEnabled ? "#000000" : "#14aaff"
- id: txt
- }
-}
diff --git a/examples/quick/demos/stocqt/content/CheckBox.qml b/examples/quick/demos/stocqt/content/CheckBox.qml
deleted file mode 100644
index 9f9138963b..0000000000
--- a/examples/quick/demos/stocqt/content/CheckBox.qml
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Research In Motion.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: button
- property bool buttonEnabled: true
- width: 30
- height: 30
- x: 5
- MouseArea {
- id: mouse
- anchors.fill: parent
- onClicked: {
- if (buttonEnabled)
- buttonEnabled = false;
- else
- buttonEnabled = true;
- }
- }
- Rectangle {
- id: checkbox
- width: 30
- height: 30
- border.color: "#999999"
- border.width: 1
- antialiasing: true
- radius: 2
- color: "transparent"
- Rectangle {
- anchors.fill: parent
- anchors.margins: 5
- antialiasing: true
- radius: 1
- color: mouse.pressed || buttonEnabled ? "#999999" : "transparent"
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/Settings.qml b/examples/quick/demos/stocqt/content/Settings.qml
deleted file mode 100644
index 9c7c59ed70..0000000000
--- a/examples/quick/demos/stocqt/content/Settings.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-pragma Singleton
-import QtQml 2.0
-
-QtObject {
- property string fontFamily: "Open Sans"
-}
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
deleted file mode 100644
index 0af06a8d54..0000000000
--- a/examples/quick/demos/stocqt/content/StockChart.qml
+++ /dev/null
@@ -1,400 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Layouts 1.1
-import "."
-
-Rectangle {
- id: chart
-
- property var stockModel: null
- property var startDate: new Date()
- property var endDate: new Date()
- property string activeChart: "week"
- property var settings
- property int gridSize: 4
- property real gridStep: gridSize ? (canvas.width - canvas.tickMargin) / gridSize : canvas.xGridStep
-
- function update() {
- endDate = new Date(stockModel.newest);
- if (chart.activeChart === "month") {
- chart.startDate = new Date(stockModel.newest.getFullYear(),
- stockModel.newest.getMonth() - 1,
- stockModel.newest.getDate());
- gridSize = 4;
- }
- else if (chart.activeChart === "quarter") {
- chart.startDate = new Date(stockModel.newest.getFullYear(),
- stockModel.newest.getMonth() - 3,
- stockModel.newest.getDate());
- gridSize = 3;
- }
- else if (chart.activeChart === "halfyear") {
- chart.startDate = new Date(stockModel.newest.getFullYear(),
- stockModel.newest.getMonth() - 6,
- stockModel.newest.getDate());
- gridSize = 6;
- }
- else {
- chart.startDate = new Date(stockModel.newest.getFullYear(),
- stockModel.newest.getMonth(),
- stockModel.newest.getDate() - 7);
- gridSize = 0;
- }
-
- canvas.requestPaint();
- }
-
- GridLayout {
- anchors.fill: parent
- columns: 6
- rows: 3
- columnSpacing: 4
- Button {
- id: weekButton
- text: "Week"
- buttonEnabled: chart.activeChart === "week"
- onClicked: {
- chart.activeChart = "week";
- chart.update();
- }
- }
-
- Button {
- id: monthButton
- text: "Month"
- buttonEnabled: chart.activeChart === "month"
- onClicked: {
- chart.activeChart = "month";
- chart.update();
- }
- }
-
- Button {
- id: quarterlyButton
- text: "3 Months"
- buttonEnabled: chart.activeChart === "quarter"
- onClicked: {
- chart.activeChart = "quarter";
- chart.update();
- }
- }
-
- Button {
- id: halfYearlyButton
- text: "6 Months"
- buttonEnabled: chart.activeChart === "halfyear"
- onClicked: {
- chart.activeChart = "halfyear";
- chart.update();
- }
- }
-
- Canvas {
- id: canvas
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.columnSpan: 6
- // Uncomment below lines to use OpenGL hardware accelerated rendering.
- // See Canvas documentation for available options.
- // renderTarget: Canvas.FramebufferObject
- // renderStrategy: Canvas.Threaded
-
- property int pixelSkip: 1
- property int numPoints: 1
- property int tickMargin: 34
-
- property real xGridStep: (canvas.width - tickMargin) / numPoints
- property real yGridOffset: canvas.height / 26
- property real yGridStep: canvas.height / 12
-
- function drawBackground(ctx) {
- ctx.save();
- ctx.fillStyle = "#ffffff";
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- ctx.strokeStyle = "#d7d7d7";
- ctx.beginPath();
- // Horizontal grid lines
- for (var i = 0; i < 12; i++) {
- ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
- }
-
- // Vertical grid lines
- var height = 35 * canvas.height / 36;
- var yOffset = canvas.height - height;
- var xOffset = 0;
- for (i = 0; i < chart.gridSize; i++) {
- ctx.moveTo(xOffset + i * chart.gridStep, yOffset);
- ctx.lineTo(xOffset + i * chart.gridStep, height);
- }
- ctx.stroke();
-
- // Right ticks
- ctx.strokeStyle = "#666666";
- ctx.beginPath();
- var xStart = canvas.width - tickMargin;
- ctx.moveTo(xStart, 0);
- ctx.lineTo(xStart, canvas.height);
- for (i = 0; i < 12; i++) {
- ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
- }
- ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep);
- ctx.closePath();
- ctx.stroke();
-
- ctx.restore();
- }
-
- // Returns a shortened, readable version of the potentially
- // large volume number.
- function volumeToString(value) {
- if (value < 1000)
- return value;
- var exponent = parseInt(Math.log(value) / Math.log(1000));
- var shortVal = parseFloat(parseFloat(value) / Math.pow(1000, exponent)).toFixed(1);
-
- // Drop the decimal point on 3-digit values to make it fit
- if (shortVal >= 100.0) {
- shortVal = parseFloat(shortVal).toFixed(0);
- }
- return shortVal + "KMBTG".charAt(exponent - 1);
- }
-
- function drawScales(ctx, high, low, vol)
- {
- ctx.save();
- ctx.strokeStyle = "#888888";
- ctx.font = "10px Open Sans"
-
- ctx.beginPath();
-
- // prices on y-axis
- var x = canvas.width - tickMargin + 3;
- var priceStep = (high - low) / 9.0;
- for (var i = 0; i < 10; i += 2) {
- var price = parseFloat(high - i * priceStep).toFixed(1);
- ctx.text(price, x, canvas.yGridOffset + i * yGridStep - 2);
- }
-
- // volume scale
- for (i = 0; i < 3; i++) {
- var volume = volumeToString(vol - (i * (vol/3)));
- ctx.text(volume, x, canvas.yGridOffset + (i + 9) * yGridStep + 10);
- }
-
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
-
- function drawPrice(ctx, from, to, color, price, points, highest, lowest)
- {
- ctx.save();
- ctx.globalAlpha = 0.7;
- ctx.strokeStyle = color;
-
- ctx.lineWidth = numPoints > 200 ? 1 : 3
-
- ctx.beginPath();
-
- var end = points.length;
-
- var range = highest - lowest;
- if (range == 0) {
- range = 1;
- }
-
- for (var i = 0; i < end; i += pixelSkip) {
- var x = points[i].x;
- var y = points[i][price];
- var h = 9 * yGridStep;
-
- y = h * (lowest - y)/range + h + yGridOffset;
-
- if (i == 0) {
- ctx.moveTo(x, y);
- } else {
- ctx.lineTo(x, y);
- }
- }
- ctx.stroke();
- ctx.restore();
- }
-
- function drawVolume(ctx, from, to, color, price, points, highest)
- {
- ctx.save();
- ctx.fillStyle = color;
- ctx.globalAlpha = 0.8;
- ctx.lineWidth = 0;
- ctx.beginPath();
-
- var end = points.length;
- var margin = 0;
-
- if (chart.activeChart === "month" || chart.activeChart === "week") {
- margin = 8;
- ctx.shadowOffsetX = 4;
- ctx.shadowBlur = 3.5;
- ctx.shadowColor = Qt.darker(color);
- }
-
- // To match the volume graph with price grid, skip drawing the initial
- // volume of the first day on chart.
- for (var i = 1; i < end; i += pixelSkip) {
- var x = points[i - 1].x;
- var y = points[i][price];
- y = canvas.height * (y / highest);
- y = 3 * y / 12;
- ctx.fillRect(x, canvas.height - y + yGridOffset,
- canvas.xGridStep - margin, y);
- }
-
- ctx.stroke();
- ctx.restore();
- }
-
- function drawError(ctx, msg)
- {
- ctx.save();
- ctx.strokeStyle = "#888888";
- ctx.font = "24px Open Sans"
- ctx.textAlign = "center"
- ctx.shadowOffsetX = 4;
- ctx.shadowOffsetY = 4;
- ctx.shadowBlur = 1.5;
- ctx.shadowColor = "#aaaaaa";
- ctx.beginPath();
-
- ctx.fillText(msg, (canvas.width - tickMargin) / 2,
- (canvas.height - yGridOffset - yGridStep) / 2);
-
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
-
- onPaint: {
- numPoints = stockModel.indexOf(chart.startDate);
- if (chart.gridSize == 0)
- chart.gridSize = numPoints
-
- var ctx = canvas.getContext("2d");
- ctx.globalCompositeOperation = "source-over";
- ctx.lineWidth = 1;
-
- drawBackground(ctx);
-
- if (!stockModel.ready) {
- drawError(ctx, "No data available.");
- return;
- }
-
- var highestPrice = 0;
- var highestVolume = 0;
- var lowestPrice = -1;
- var points = [];
- for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) {
- var price = stockModel.get(i);
- if (parseFloat(highestPrice) < parseFloat(price.high))
- highestPrice = price.high;
- if (parseInt(highestVolume, 10) < parseInt(price.volume, 10))
- highestVolume = price.volume;
- if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low))
- lowestPrice = price.low;
- points.push({
- x: j * xGridStep,
- open: price.open,
- close: price.close,
- high: price.high,
- low: price.low,
- volume: price.volume
- });
- }
-
- if (settings.drawHighPrice)
- drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice);
- if (settings.drawLowPrice)
- drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice);
- if (settings.drawOpenPrice)
- drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice);
- if (settings.drawClosePrice)
- drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice);
-
- drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume);
- drawScales(ctx, highestPrice, lowestPrice, highestVolume);
- }
- }
-
-
- Text {
- id: fromDate
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 8
- Layout.alignment: Qt.AlignLeft
- text: "| " + startDate.toDateString()
- }
- Text {
- id: toDate
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 8
- Layout.alignment: Qt.AlignRight
- Layout.rightMargin: canvas.tickMargin
- Layout.columnSpan: 5
- text: endDate.toDateString() + " |"
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml
deleted file mode 100644
index e18f34e83c..0000000000
--- a/examples/quick/demos/stocqt/content/StockInfo.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Layouts 1.1
-import "."
-
-Rectangle {
- id: root
- color: "transparent"
-
- property var stock: null
-
- GridLayout {
- id: stockInfoLayout
- anchors.fill: parent
- columns: 2
- rows: 3
- rowSpacing: 4
-
- Text {
- id: stockIdText
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 28
- font.weight: Font.DemiBold
- text: root.stock.stockId
- Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
- Layout.leftMargin: 10
- }
-
- Text {
- id: price
- color: "#6d6d6d"
- font.family: Settings.fontFamily
- font.pointSize: 28
- font.weight: Font.DemiBold
- text: parseFloat(root.stock.stockPrice).toFixed(2);
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
- Layout.leftMargin: 5
- }
-
- Text {
- id: stockNameText
- color: "#0c0c0c"
- font.family: Settings.fontFamily
- font.pointSize: 16
- elide: Text.ElideRight
- maximumLineCount: 3
- wrapMode: Text.WordWrap
- text: root.stock.stockName
- Layout.leftMargin: 10
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignLeft
- }
-
-
- Text {
- id: priceChange
- Layout.alignment: Qt.AlignLeft | Qt.AlignTop
- Layout.leftMargin: 10
- color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- text: parseFloat(root.stock.stockPriceChanged).toFixed(2);
- }
-
- Text {
- id: priceChangePercentage
- Layout.alignment: Qt.AlignLeft | Qt.AlignTop
- color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- font.weight: Font.DemiBold
- Layout.fillWidth: true
- text: "(" +
- parseFloat(root.stock.stockPriceChanged /
- (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) +
- "%)"
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/StockListDelegate.qml b/examples/quick/demos/stocqt/content/StockListDelegate.qml
deleted file mode 100644
index 8a4a8f6922..0000000000
--- a/examples/quick/demos/stocqt/content/StockListDelegate.qml
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.5
-import QtQuick.Layouts 1.1
-import "."
-
-Rectangle {
- height: 102
- width: parent.width
- color: "transparent"
- MouseArea {
- anchors.fill: parent;
- onClicked: {
- if (view.currentIndex == index)
- mainRect.currentIndex = 1;
- else
- view.currentIndex = index;
- }
- }
- GridLayout {
- id: stockGrid
- columns: 3
- rows: 2
- anchors.fill: parent
-
- Text {
- id: stockIdText
- Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
- Layout.leftMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.weight: Font.Bold
- verticalAlignment: Text.AlignVCenter
- text: stockId
- }
-
- Text {
- id: stockValueText
- Layout.preferredWidth: 100
- Layout.alignment: Qt.AlignRight | Qt.AlignBottom
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.bold: true
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: value
- }
- Text {
- id: stockValueChangeText
- Layout.preferredWidth: 135
- Layout.rightMargin: 10
- Layout.alignment: Qt.AlignRight | Qt.AlignBottom
- color: "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.bold: true
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: change
- onTextChanged: {
- if (parseFloat(text) >= 0.0)
- color = "#328930";
- else
- color = "#d40000";
- }
- }
- Text {
- id: stockNameText
- Layout.preferredWidth: 300
- Layout.leftMargin: 10
- Layout.alignment: Qt.AlignLeft | Qt.AlignTop
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 16
- font.bold: false
- elide: Text.ElideRight
- maximumLineCount: 1
- verticalAlignment: Text.AlignVCenter
- text: name
- }
-
- Item {Layout.fillWidth: true }
-
- Text {
- id: stockValueChangePercentageText
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignRight | Qt.AlignTop
- Layout.rightMargin: 10
- color: "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- font.bold: false
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: changePercentage
- onTextChanged: {
- if (parseFloat(text) >= 0.0)
- color = "#328930";
- else
- color = "#d40000";
- }
- }
- }
-
- Rectangle {
- id: endingLine
- anchors.top: stockGrid.bottom
- height: 1
- width: parent.width
- color: "#d7d7d7"
- }
-}
-
diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml
deleted file mode 100644
index 2f697f5644..0000000000
--- a/examples/quick/demos/stocqt/content/StockListModel.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-
-ListModel {
- id: stocks
-
- // pre-fetch data for all entries
- Component.onCompleted: {
- for (var idx = 0; idx < count; ++idx) {
- getCloseValue(idx)
- }
- }
-
- function getCloseValue(index) {
-
- var endDate = new Date(); // today
- var startDate = new Date();
- endDate.setDate(startDate.getDate() - 1);
- startDate.setDate(endDate.getDate() - 7);
-
- var req = "data/" + get(index).stockId + ".csv"
-
- var xhr = new XMLHttpRequest;
-
- xhr.open("GET", req, true);
-
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
- var records = xhr.responseText.split('\n');
- var unknown = "n/a";
- set(index, {"value": unknown, "change": unknown, "changePercentage": unknown});
- if (records.length > 0 && xhr.status == 200) {
- var r = records[1].split(',');
- var today = parseFloat(r[4]);
-
- if (!isNaN(today))
- setProperty(index, "value", today.toFixed(2));
- if (records.length > 2) {
- r = records[2].split(',');
- var yesterday = parseFloat(r[4]);
- var change = today - yesterday;
-
- if (change >= 0.0)
- setProperty(index, "change", "+" + change.toFixed(2));
- else
- setProperty(index, "change", change.toFixed(2));
-
- var changePercentage = (change / yesterday) * 100.0;
- if (changePercentage >= 0.0)
- setProperty(index, "changePercentage", "+" + changePercentage.toFixed(2) + "%");
- else
- setProperty(index, "changePercentage", changePercentage.toFixed(2) + "%");
- }
- }
- }
- }
- xhr.send()
- }
- // Uncomment to test invalid entries
- // ListElement {name: "The Qt Company"; stockId: "TQTC"; value: "999.0"; change: "0.0"; changePercentage: "0.0"}
-
- // Offline data downloaded using the url, https://www.quandl.com/api/v3/datasets/WIKI/<stockId>.csv.
- ListElement {name: "Advanced Micro Devices Inc."; stockId: "AMD"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Amazon.com Inc."; stockId: "AMZN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Apple Inc."; stockId: "AAPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Autodesk Inc."; stockId: "ADSK"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Cisco Systems Inc."; stockId: "CSCO"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "eBay Inc."; stockId: "EBAY"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Electronic Arts Inc."; stockId: "EA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Intel Corp."; stockId: "INTC"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Microsoft Corp."; stockId: "MSFT"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "NetApp Inc."; stockId: "NTAP"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Netflix Inc."; stockId: "NFLX"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Norwegian Cruise Line Holdings Ltd."; stockId: "NCLH"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "NVIDIA Corp."; stockId: "NVDA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "PayPal Holdings Inc."; stockId: "PYPL"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "QUALCOMM Inc."; stockId: "QCOM"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Tesla Motors Inc."; stockId: "TSLA"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Texas Instruments Inc."; stockId: "TXN"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
- ListElement {name: "Facebook Inc."; stockId: "FB"; value: "0.0"; change: "0.0"; changePercentage: "0.0"}
-}
-
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml
deleted file mode 100644
index 9e3a815c11..0000000000
--- a/examples/quick/demos/stocqt/content/StockModel.qml
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-ListModel {
- id: model
- property string stockId: ""
- property string stockName: ""
- property var newest
- property var oldest
- property bool ready: false
- property real stockPrice: 0.0
- property real stockPriceChanged: 0.0
-
- signal dataReady
-
- function indexOf(date) {
- if (model.count == 0)
- return -1;
-
- if (newest <= date)
- date = new Date(newest.getYear(),
- newest.getMonth(),
- newest.getDate() - 7);
-
- if (oldest >= date)
- return model.count - 1;
-
- var currDiff = 0;
- var bestDiff = Math.abs(date.getTime() - newest.getTime());
- var retval = 0;
- for (var i = 0; i < model.count; i++) {
- var d = new Date(model.get(i).date);
- currDiff = Math.abs(d.getTime() - date.getTime());
- if (currDiff < bestDiff) {
- bestDiff = currDiff;
- retval = i + 1;
- }
- if (currDiff > bestDiff)
- return retval;
- }
- return -1;
- }
-
- function createStockPrice(r) {
- return {
- "date": r[0],
- "open":r[1],
- "high":r[2],
- "low":r[3],
- "close":r[4],
- "volume":r[5],
- };
- }
-
- function updateStock() {
- if (stockId === "")
- return;
-
- var startDate = new Date(2011, 4, 25);
- var endDate = new Date(); //today
-
- var req = "data/" + stockId + ".csv"
- if (!req)
- return;
-
- var xhr = new XMLHttpRequest;
-
- xhr.open("GET", req, true);
-
- model.ready = false;
- model.clear();
- var i = 1; //skip the first line
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
- var records = xhr.responseText.split('\n');
- for (;i < records.length; i++ ) {
- var r = records[i].split(',');
- if (r.length >= 6)
- model.append(createStockPrice(r));
- }
-
- if (xhr.readyState === XMLHttpRequest.DONE) {
- if (model.count > 0) {
- model.ready = true;
- model.stockPrice = model.get(0).close;
- model.stockPriceChanged = model.count > 1 ? (Math.round((model.stockPrice - model.get(1).close) * 100) / 100) : 0;
- newest = new Date(model.get(0).date);
- oldest = new Date(model.get(model.count - 1).date);
- } else {
- model.stockPrice = 0;
- model.stockPriceChanged = 0;
- }
- model.dataReady(); // emit signal - model.ready indicates whether the data is valid
- }
- }
- }
- xhr.send()
- }
-}
diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
deleted file mode 100644
index 48a77d8495..0000000000
--- a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Layouts 1.1
-import "."
-
-Rectangle {
- id: root
- color: "transparent"
-
- property bool drawOpenPrice: false
- property bool drawClosePrice: false
- property bool drawHighPrice: true
- property bool drawLowPrice: true
-
- property string openColor: "#face20"
- property string closeColor: "#14aaff"
- property string highColor: "#80c342"
- property string lowColor: "#f30000"
- property string volumeColor: "#14aaff"
-
- GridLayout {
- id: settingsGrid
- rows: 5
- columns: 3
- rowSpacing: 4
- anchors.fill: parent
-
- Item {
- Layout.fillHeight: true
- Layout.columnSpan: 3
- }
-
- Text {
- id: openText
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Open"
- Layout.leftMargin: 10
- }
- Rectangle {
- Layout.preferredHeight: 4
- Layout.preferredWidth: 114
- color: openColor
- }
- CheckBox {
- id: openButton
- buttonEnabled: false
- onButtonEnabledChanged: drawOpenPrice = buttonEnabled
- Layout.rightMargin: 10
- }
-
- Text {
- id: closeText
- Layout.leftMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Close"
- }
- Rectangle {
- Layout.preferredHeight: 4
- Layout.preferredWidth: 114
- color: closeColor
- }
- CheckBox {
- id: closeButton
- buttonEnabled: false
- onButtonEnabledChanged: drawClosePrice = buttonEnabled
- Layout.rightMargin: 10
- }
-
- Text {
- id: highText
- Layout.leftMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "High"
- }
- Rectangle {
- Layout.preferredHeight: 4
- Layout.preferredWidth: 114
- color: highColor
- }
- CheckBox {
- id: highButton
- buttonEnabled: true
- onButtonEnabledChanged: drawHighPrice = buttonEnabled
- Layout.rightMargin: 10
- }
-
- Text {
- id: lowText
- Layout.leftMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Low"
- }
- Rectangle {
- Layout.preferredHeight: 4
- Layout.preferredWidth: 114
- color: lowColor
- }
-
- CheckBox {
- id: lowButton
- buttonEnabled: true
- onButtonEnabledChanged: drawLowPrice = buttonEnabled
- Layout.rightMargin: 10
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml
deleted file mode 100644
index f966f06b18..0000000000
--- a/examples/quick/demos/stocqt/content/StockView.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.1
-import QtQuick.Layouts 1.1
-
-Rectangle {
- id: root
- width: 320
- height: 480
- color: "transparent"
-
- property var stock: null
- property var stocklist: null
- signal settingsClicked
-
- function update() {
- chart.update()
- }
-
- Rectangle {
- id: mainRect
- color: "transparent"
- anchors.fill: parent
-
- GridLayout {
- anchors.fill: parent
- rows: 2
- columns: Screen.primaryOrientation === Qt.PortraitOrientation ? 1 : 2
-
- StockInfo {
- id: stockInfo
- Layout.alignment: Qt.AlignTop
- Layout.preferredWidth: 400
- Layout.preferredHeight: 160
- stock: root.stock
- }
-
- StockChart {
- id: chart
- Layout.alignment: Qt.AlignRight
- Layout.margins: 5
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.rowSpan: 2
- stockModel: root.stock
- settings: settingsPanel
- }
- StockSettingsPanel {
- id: settingsPanel
- Layout.alignment: Qt.AlignBottom
- Layout.fillHeight: true
- Layout.preferredWidth: 400
- Layout.bottomMargin: 5
- onDrawOpenPriceChanged: root.update()
- onDrawClosePriceChanged: root.update();
- onDrawHighPriceChanged: root.update();
- onDrawLowPriceChanged: root.update();
- }
- }
- }
-}
diff --git a/examples/quick/demos/stocqt/content/data/AAPL.csv b/examples/quick/demos/stocqt/content/data/AAPL.csv
deleted file mode 100644
index de56baa19a..0000000000
--- a/examples/quick/demos/stocqt/content/data/AAPL.csv
+++ /dev/null
@@ -1,147 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,170.52,170.59,169.22,169.23,25643711.0,0.0,1.0,170.52,170.59,169.22,169.23,25643711.0
-2017-12-28,171.0,171.85,170.48,171.08,15997739.0,0.0,1.0,171.0,171.85,170.48,171.08,15997739.0
-2017-12-27,170.1,170.78,169.71,170.6,21672062.0,0.0,1.0,170.1,170.78,169.71,170.6,21672062.0
-2017-12-26,170.8,171.47,169.679,170.57,32968167.0,0.0,1.0,170.8,171.47,169.679,170.57,32968167.0
-2017-12-22,174.68,175.424,174.5,175.01,16052615.0,0.0,1.0,174.68,175.424,174.5,175.01,16052615.0
-2017-12-21,174.17,176.02,174.1,175.01,20356826.0,0.0,1.0,174.17,176.02,174.1,175.01,20356826.0
-2017-12-20,174.87,175.42,173.25,174.35,23000392.0,0.0,1.0,174.87,175.42,173.25,174.35,23000392.0
-2017-12-19,175.03,175.39,174.09,174.54,27078872.0,0.0,1.0,175.03,175.39,174.09,174.54,27078872.0
-2017-12-18,174.88,177.2,174.86,176.42,28831533.0,0.0,1.0,174.88,177.2,174.86,176.42,28831533.0
-2017-12-15,173.63,174.17,172.46,173.87,37054632.0,0.0,1.0,173.63,174.17,172.46,173.87,37054632.0
-2017-12-14,172.4,173.13,171.65,172.22,20219307.0,0.0,1.0,172.4,173.13,171.65,172.22,20219307.0
-2017-12-13,172.5,173.54,172.0,172.27,23142242.0,0.0,1.0,172.5,173.54,172.0,172.27,23142242.0
-2017-12-12,172.15,172.39,171.461,171.7,18945457.0,0.0,1.0,172.15,172.39,171.461,171.7,18945457.0
-2017-12-11,169.2,172.89,168.79,172.67,33092051.0,0.0,1.0,169.2,172.89,168.79,172.67,33092051.0
-2017-12-08,170.49,171.0,168.82,169.37,23096872.0,0.0,1.0,170.49,171.0,168.82,169.37,23096872.0
-2017-12-07,169.03,170.44,168.91,169.452,24469613.0,0.0,1.0,169.03,170.44,168.91,169.452,24469613.0
-2017-12-06,167.5,170.2047,166.46,169.01,28224357.0,0.0,1.0,167.5,170.2047,166.46,169.01,28224357.0
-2017-12-05,169.06,171.52,168.4,169.64,27008428.0,0.0,1.0,169.06,171.52,168.4,169.64,27008428.0
-2017-12-04,172.48,172.62,169.63,169.8,32115052.0,0.0,1.0,172.48,172.62,169.63,169.8,32115052.0
-2017-12-01,169.95,171.67,168.5,171.05,39590080.0,0.0,1.0,169.95,171.67,168.5,171.05,39590080.0
-2017-11-30,170.43,172.14,168.44,171.85,40172368.0,0.0,1.0,170.43,172.14,168.44,171.85,40172368.0
-2017-11-29,172.63,172.92,167.16,169.48,40788324.0,0.0,1.0,172.63,172.92,167.16,169.48,40788324.0
-2017-11-28,174.3,174.87,171.86,173.07,25468442.0,0.0,1.0,174.3,174.87,171.86,173.07,25468442.0
-2017-11-27,175.05,175.08,173.34,174.09,20536313.0,0.0,1.0,175.05,175.08,173.34,174.09,20536313.0
-2017-11-24,175.1,175.5,174.6459,174.97,14026519.0,0.0,1.0,175.1,175.5,174.6459,174.97,14026519.0
-2017-11-22,173.36,175.0,173.05,174.96,24997274.0,0.0,1.0,173.36,175.0,173.05,174.96,24997274.0
-2017-11-21,170.78,173.7,170.78,173.14,24875471.0,0.0,1.0,170.78,173.7,170.78,173.14,24875471.0
-2017-11-20,170.29,170.56,169.56,169.98,15974387.0,0.0,1.0,170.29,170.56,169.56,169.98,15974387.0
-2017-11-17,171.04,171.39,169.64,170.15,21665811.0,0.0,1.0,171.04,171.39,169.64,170.15,21665811.0
-2017-11-16,171.18,171.87,170.3,171.1,23497326.0,0.0,1.0,171.18,171.87,170.3,171.1,23497326.0
-2017-11-15,169.97,170.3197,168.38,169.08,28702351.0,0.0,1.0,169.97,170.3197,168.38,169.08,28702351.0
-2017-11-14,173.04,173.48,171.18,171.34,23588451.0,0.0,1.0,173.04,173.48,171.18,171.34,23588451.0
-2017-11-13,173.5,174.5,173.4,173.97,16828025.0,0.0,1.0,173.5,174.5,173.4,173.97,16828025.0
-2017-11-10,175.11,175.38,174.27,174.67,25061183.0,0.0,1.0,175.11,175.38,174.27,174.67,25061183.0
-2017-11-09,175.11,176.095,173.14,175.88,28636531.0,0.0,1.0,175.11,176.095,173.14,175.88,28636531.0
-2017-11-07,173.91,175.25,173.6,174.81,23910914.0,0.0,1.0,173.91,175.25,173.6,174.81,23910914.0
-2017-11-06,172.365,174.99,171.72,174.25,34242566.0,0.0,1.0,172.365,174.99,171.72,174.25,34242566.0
-2017-11-03,174.0,174.26,171.12,172.5,58683826.0,0.0,1.0,174.0,174.26,171.12,172.5,58683826.0
-2017-11-02,167.64,168.5,165.28,168.11,32710040.0,0.0,1.0,167.64,168.5,165.28,168.11,32710040.0
-2017-11-01,169.87,169.94,165.61,166.89,33100847.0,0.0,1.0,169.87,169.94,165.61,166.89,33100847.0
-2017-10-31,167.9,169.6499,166.94,169.04,35474672.0,0.0,1.0,167.9,169.6499,166.94,169.04,35474672.0
-2017-10-30,163.89,168.07,163.72,166.72,43923292.0,0.0,1.0,163.89,168.07,163.72,166.72,43923292.0
-2017-10-27,159.29,163.6,158.7,163.05,43904150.0,0.0,1.0,159.29,163.6,158.7,163.05,43904150.0
-2017-10-26,157.23,157.8295,156.78,157.41,16751691.0,0.0,1.0,157.23,157.8295,156.78,157.41,16751691.0
-2017-10-25,156.91,157.55,155.27,156.405,20126554.0,0.0,1.0,156.91,157.55,155.27,156.405,20126554.0
-2017-10-24,156.29,157.42,156.2,157.1,17137731.0,0.0,1.0,156.29,157.42,156.2,157.1,17137731.0
-2017-10-23,156.89,157.69,155.5,156.17,21654461.0,0.0,1.0,156.89,157.69,155.5,156.17,21654461.0
-2017-10-20,156.61,157.75,155.96,156.16,23612246.0,0.0,1.0,156.61,157.75,155.96,156.16,23612246.0
-2017-10-19,156.75,157.08,155.02,155.98,42111326.0,0.0,1.0,156.75,157.08,155.02,155.98,42111326.0
-2017-10-18,160.42,160.71,159.6,159.76,16158659.0,0.0,1.0,160.42,160.71,159.6,159.76,16158659.0
-2017-10-17,159.78,160.87,159.23,160.47,18816438.0,0.0,1.0,159.78,160.87,159.23,160.47,18816438.0
-2017-10-16,157.9,160.0,157.65,159.88,23894630.0,0.0,1.0,157.9,160.0,157.65,159.88,23894630.0
-2017-10-13,156.73,157.28,156.41,156.99,16287608.0,0.0,1.0,156.73,157.28,156.41,156.99,16287608.0
-2017-10-12,156.35,157.37,155.7299,156.0,16045720.0,0.0,1.0,156.35,157.37,155.7299,156.0,16045720.0
-2017-10-11,155.97,156.98,155.75,156.55,16607693.0,0.0,1.0,155.97,156.98,155.75,156.55,16607693.0
-2017-10-10,156.055,158.0,155.1,155.9,15456331.0,0.0,1.0,156.055,158.0,155.1,155.9,15456331.0
-2017-10-09,155.81,156.73,155.485,155.84,16200129.0,0.0,1.0,155.81,156.73,155.485,155.84,16200129.0
-2017-10-06,154.97,155.49,154.56,155.3,16423749.0,0.0,1.0,154.97,155.49,154.56,155.3,16423749.0
-2017-10-05,154.18,155.44,154.05,155.39,21032800.0,0.0,1.0,154.18,155.44,154.05,155.39,21032800.0
-2017-10-04,153.63,153.86,152.46,153.4508,19844177.0,0.0,1.0,153.63,153.86,152.46,153.4508,19844177.0
-2017-10-03,154.01,155.09,153.91,154.48,16146388.0,0.0,1.0,154.01,155.09,153.91,154.48,16146388.0
-2017-10-02,154.26,154.45,152.72,153.81,18524860.0,0.0,1.0,154.26,154.45,152.72,153.81,18524860.0
-2017-09-29,153.21,154.13,152.0,154.12,25856530.0,0.0,1.0,153.21,154.13,152.0,154.12,25856530.0
-2017-09-28,153.89,154.28,152.7,153.28,21896592.0,0.0,1.0,153.89,154.28,152.7,153.28,21896592.0
-2017-09-27,153.8,154.7189,153.54,154.23,24959552.0,0.0,1.0,153.8,154.7189,153.54,154.23,24959552.0
-2017-09-26,151.78,153.92,151.69,153.14,35470985.0,0.0,1.0,151.78,153.92,151.69,153.14,35470985.0
-2017-09-25,149.99,151.83,149.16,150.55,43922334.0,0.0,1.0,149.99,151.83,149.16,150.55,43922334.0
-2017-09-22,152.02,152.27,150.56,151.89,46114424.0,0.0,1.0,152.02,152.27,150.56,151.89,46114424.0
-2017-09-21,155.8,155.8,152.75,153.39,36643382.0,0.0,1.0,155.8,155.8,152.75,153.39,36643382.0
-2017-09-20,157.9,158.26,153.83,156.07,51693239.0,0.0,1.0,157.9,158.26,153.83,156.07,51693239.0
-2017-09-19,159.51,159.77,158.44,158.73,20347352.0,0.0,1.0,159.51,159.77,158.44,158.73,20347352.0
-2017-09-18,160.11,160.5,157.995,158.67,27939718.0,0.0,1.0,160.11,160.5,157.995,158.67,27939718.0
-2017-09-15,158.47,160.97,158.0,159.88,48203642.0,0.0,1.0,158.47,160.97,158.0,159.88,48203642.0
-2017-09-14,158.99,159.4,158.09,158.28,23073646.0,0.0,1.0,158.99,159.4,158.09,158.28,23073646.0
-2017-09-13,159.87,159.96,157.91,159.65,44393752.0,0.0,1.0,159.87,159.96,157.91,159.65,44393752.0
-2017-09-12,162.61,163.96,158.77,160.82,71139119.0,0.0,1.0,162.61,163.96,158.77,160.82,71139119.0
-2017-09-11,160.5,162.05,159.89,161.5,31028926.0,0.0,1.0,160.5,162.05,159.89,161.5,31028926.0
-2017-09-08,160.86,161.15,158.53,158.63,28183159.0,0.0,1.0,160.86,161.15,158.53,158.63,28183159.0
-2017-09-07,162.09,162.24,160.36,161.26,21722995.0,0.0,1.0,162.09,162.24,160.36,161.26,21722995.0
-2017-09-06,162.71,162.99,160.52,161.91,21179047.0,0.0,1.0,162.71,162.99,160.52,161.91,21179047.0
-2017-09-05,163.75,164.25,160.56,162.08,29317054.0,0.0,1.0,163.75,164.25,160.56,162.08,29317054.0
-2017-09-01,164.8,164.94,163.63,164.05,16508568.0,0.0,1.0,164.8,164.94,163.63,164.05,16508568.0
-2017-08-31,163.64,164.52,163.48,164.0,26412439.0,0.0,1.0,163.64,164.52,163.48,164.0,26412439.0
-2017-08-30,163.8,163.89,162.61,163.35,26973946.0,0.0,1.0,163.8,163.89,162.61,163.35,26973946.0
-2017-08-29,160.1,163.12,160.0,162.91,29307862.0,0.0,1.0,160.1,163.12,160.0,162.91,29307862.0
-2017-08-28,160.14,162.0,159.93,161.47,25279674.0,0.0,1.0,160.14,162.0,159.93,161.47,25279674.0
-2017-08-25,159.65,160.56,159.27,159.86,25015218.0,0.0,1.0,159.65,160.56,159.27,159.86,25015218.0
-2017-08-24,160.43,160.74,158.55,159.27,19029621.0,0.0,1.0,160.43,160.74,158.55,159.27,19029621.0
-2017-08-23,159.07,160.47,158.88,159.98,19198189.0,0.0,1.0,159.07,160.47,158.88,159.98,19198189.0
-2017-08-22,158.23,160.0,158.02,159.78,21297812.0,0.0,1.0,158.23,160.0,158.02,159.78,21297812.0
-2017-08-21,157.5,157.89,155.1101,157.21,26145653.0,0.0,1.0,157.5,157.89,155.1101,157.21,26145653.0
-2017-08-18,157.86,159.5,156.72,157.5,27012525.0,0.0,1.0,157.86,159.5,156.72,157.5,27012525.0
-2017-08-17,160.52,160.71,157.84,157.87,26925694.0,0.0,1.0,160.52,160.71,157.84,157.87,26925694.0
-2017-08-16,161.94,162.51,160.15,160.95,27321761.0,0.0,1.0,161.94,162.51,160.15,160.95,27321761.0
-2017-08-15,160.66,162.195,160.14,161.6,27936774.0,0.0,1.0,160.66,162.195,160.14,161.6,27936774.0
-2017-08-14,159.32,160.21,158.75,159.85,21754810.0,0.0,1.0,159.32,160.21,158.75,159.85,21754810.0
-2017-08-11,156.6,158.5728,156.07,157.48,25943187.0,0.0,1.0,156.6,158.5728,156.07,157.48,25943187.0
-2017-08-10,159.9,160.0,154.63,155.27,39081017.0,0.63,1.0,159.9,160.0,154.63,155.27,39081017.0
-2017-08-09,159.26,161.27,159.11,161.06,25640394.0,0.0,1.0,158.61642206543,160.61829955099,158.46702822322,160.40914817191,25640394.0
-2017-08-08,158.6,161.83,158.27,160.08,35775675.0,0.0,1.0,157.95908915972,161.1760365619,157.63042270686,159.43310840282,35775675.0
-2017-08-04,156.07,157.4,155.69,156.39,20349532.0,0.0,1.0,155.43931302117,156.76393842207,155.06084862091,155.75801988454,20349532.0
-2017-08-03,157.05,157.21,155.02,155.57,26000738.0,0.0,1.0,156.41535279025,156.57470622194,154.39355612572,154.94133354715,26000738.0
-2017-08-02,159.28,159.75,156.16,157.14,69222793.0,0.0,1.0,158.63634124439,159.10444194997,155.52894932649,156.50498909557,69222793.0
-2017-08-01,149.1,150.22,148.41,150.05,24725526.0,0.0,1.0,148.4974791533,149.61295317511,147.81026747915,149.44364015394,24725526.0
-2017-07-31,149.9,150.33,148.13,148.85,19422655.0,0.0,1.0,149.29424631174,149.7225086594,147.5313989737,148.24848941629,19422655.0
-2017-07-28,149.89,150.23,149.19,149.5,16832947.0,0.0,1.0,149.28428672226,149.62291276459,148.58711545863,148.89586273252,16832947.0
-2017-07-27,153.75,153.99,147.3,150.56,32175875.0,0.0,1.0,153.12868826171,153.36771840924,146.70475304682,149.95157921745,32175875.0
-2017-07-26,153.35,153.93,153.06,153.46,15172136.0,0.0,1.0,152.73030468249,153.30796087235,152.44147658756,152.83986016677,15172136.0
-2017-07-25,151.8,153.84,151.8,152.74,18612649.0,0.0,1.0,151.18656831302,153.21832456703,151.18656831302,152.12276972418,18612649.0
-2017-07-24,150.58,152.44,149.9,152.09,21122730.0,0.0,1.0,149.97149839641,151.82398203977,149.29424631174,151.47539640795,21122730.0
-2017-07-21,149.99,150.44,148.88,150.27,24671002.0,0.0,1.0,149.38388261706,149.83206414368,148.27836818473,149.66275112251,24671002.0
-2017-07-20,151.5,151.74,150.19,150.34,17053326.0,0.0,1.0,150.88778062861,151.12681077614,149.58307440667,149.73246824888,17053326.0
-2017-07-19,150.48,151.42,149.95,151.02,20615419.0,0.0,1.0,149.8719025016,150.80810391276,149.34404425914,150.40972033355,20615419.0
-2017-07-18,149.2,150.13,148.67,150.08,17713795.0,0.0,1.0,148.59707504811,149.52331686979,148.06921680564,149.47351892239,17713795.0
-2017-07-17,148.82,150.9,148.57,149.56,23243713.0,0.0,1.0,148.21861064785,150.29020525978,147.96962091084,148.9556202694,23243713.0
-2017-07-14,147.97,149.33,147.33,149.04,19961788.0,0.0,1.0,147.37204554201,148.72654971135,146.73463181527,148.43772161642,19961788.0
-2017-07-13,145.5,148.49,145.44,147.77,24922788.0,0.0,1.0,144.91202694035,147.889944195,144.85226940346,147.17285375241,24922788.0
-2017-07-12,145.87,146.18,144.82,145.74,23617964.0,0.0,1.0,145.28053175112,145.58927902502,144.23477485568,145.15105708788,23617964.0
-2017-07-11,144.73,145.85,144.38,145.53,18311156.0,0.0,1.0,144.14513855035,145.26061257216,143.79655291854,144.94190570879,18311156.0
-2017-07-10,144.11,145.95,143.37,145.06,21030466.0,0.0,1.0,143.52764400257,145.36020846697,142.79063438101,144.47380500321,21030466.0
-2017-07-07,142.9,144.75,142.9,144.18,18505351.0,0.0,1.0,142.32253367543,144.16505772931,142.32253367543,143.59736112893,18505351.0
-2017-07-06,143.02,143.5,142.41,142.73,23374374.0,0.0,1.0,142.4420487492,142.92010904426,141.83451379089,142.15322065427,23374374.0
-2017-07-05,143.69,144.79,142.7237,144.09,20758795.0,0.0,1.0,143.10934124439,144.20489608724,142.14694611289,143.5077248236,20758795.0
-2017-07-03,144.88,145.3001,143.1,143.5,14276812.0,0.0,1.0,144.29453239256,144.71293474663,142.52172546504,142.92010904426,14276812.0
-2017-06-30,144.45,144.96,143.78,144.02,22328979.0,0.0,1.0,143.8662700449,144.3742091084,143.19897754971,143.43800769724,22328979.0
-2017-06-29,144.71,145.13,142.28,143.68,31116980.0,0.0,1.0,144.12521937139,144.54352212957,141.70503912765,143.09938165491,31116980.0
-2017-06-28,144.49,146.11,143.1601,145.83,21915939.0,0.0,1.0,143.90610840282,145.51956189865,142.58158259782,145.2406933932,21915939.0
-2017-06-27,145.01,146.16,143.62,143.74,24423643.0,0.0,1.0,144.4240070558,145.56935984606,143.03962411802,143.15913919179,24423643.0
-2017-06-26,147.17,148.28,145.38,145.82,25524661.0,0.0,1.0,146.57527838358,147.68079281591,144.79251186658,145.23073380372,25524661.0
-2017-06-23,145.13,147.16,145.11,146.35,25997976.0,0.0,1.0,144.54352212957,146.5653187941,144.52360295061,145.75859204618,25997976.0
-2017-06-22,145.77,146.7,145.1199,145.63,18673365.0,0.0,1.0,145.18093585632,146.107177678,144.5334629442,145.04150160359,18673365.0
-2017-06-21,145.52,146.0693,144.61,145.87,21064679.0,0.0,1.0,144.93194611931,145.47902636947,144.02562347659,145.28053175112,21064679.0
-2017-06-20,146.87,146.87,144.94,145.01,24572170.0,0.0,1.0,146.27649069917,146.27649069917,144.35428992944,144.4240070558,24572170.0
-2017-06-19,143.66,146.74,143.66,146.34,31449132.0,0.0,1.0,143.07946247595,146.14701603592,143.07946247595,145.7486324567,31449132.0
-2017-06-16,143.78,144.5,142.2,142.27,49180748.0,0.0,1.0,143.19897754971,143.9160679923,141.6253624118,141.69507953817,49180748.0
-2017-06-15,143.32,144.4798,142.21,144.29,31348832.0,0.0,1.0,142.74083643361,143.89594962155,141.63532200128,143.70691661321,31348832.0
-2017-06-14,147.5,147.5,143.84,145.16,31224203.0,0.0,1.0,146.90394483643,146.90394483643,143.25873508659,144.57340089801,31224203.0
-2017-06-13,147.16,147.45,145.15,146.59,33749154.0,0.0,1.0,146.5653187941,146.85414688903,144.56344130853,145.99762219371,33749154.0
-2017-06-12,145.74,146.09,142.51,145.32,71563614.0,0.0,1.0,145.15105708788,145.49964271969,141.9341096857,144.7327543297,71563614.0
-2017-06-09,155.19,155.19,146.02,148.98,64176149.0,0.0,1.0,154.56286914689,154.56286914689,145.42992559333,148.37796407954,64176149.0
-2017-06-08,155.25,155.54,154.4,154.99,20771367.0,0.0,1.0,154.62262668377,154.9114547787,153.77606157793,154.36367735728,20771367.0
-2017-06-07,155.02,155.98,154.48,155.37,20678772.0,0.0,1.0,154.39355612572,155.34967671584,153.85573829378,154.74214175754,20678772.0
-2017-06-06,153.9,155.81,153.78,154.45,26249630.0,0.0,1.0,153.27808210391,155.18036369468,153.15856703015,153.82585952534,26249630.0
-2017-06-05,154.34,154.45,153.46,153.93,24803858.0,0.0,1.0,153.71630404105,153.82585952534,152.83986016677,153.30796087235,24803858.0
-2017-06-02,153.58,155.45,152.89,155.45,27285861.0,0.0,1.0,152.95937524054,154.82181847338,152.27216356639,154.82181847338,27285861.0
-2017-06-01,153.17,153.33,152.22,153.18,16180143.0,0.0,1.0,152.55103207184,152.71038550353,151.6048710712,152.56099166132,16180143.0
diff --git a/examples/quick/demos/stocqt/content/data/ADSK.csv b/examples/quick/demos/stocqt/content/data/ADSK.csv
deleted file mode 100644
index 704fa3f32a..0000000000
--- a/examples/quick/demos/stocqt/content/data/ADSK.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,105.04,105.65,104.5301,104.83,1042328.0,0.0,1.0,105.04,105.65,104.5301,104.83,1042328.0
-2017-12-28,104.66,105.22,104.2,105.07,860725.0,0.0,1.0,104.66,105.22,104.2,105.07,860725.0
-2017-12-27,103.97,105.199,103.48,104.58,959904.0,0.0,1.0,103.97,105.199,103.48,104.58,959904.0
-2017-12-26,103.45,104.15,103.19,103.8,1307823.0,0.0,1.0,103.45,104.15,103.19,103.8,1307823.0
-2017-12-22,104.85,104.85,103.78,103.89,1411598.0,0.0,1.0,104.85,104.85,103.78,103.89,1411598.0
-2017-12-21,105.58,105.6699,103.65,104.43,3901415.0,0.0,1.0,105.58,105.6699,103.65,104.43,3901415.0
-2017-12-20,106.02,106.02,104.19,105.03,2502489.0,0.0,1.0,106.02,106.02,104.19,105.03,2502489.0
-2017-12-19,107.24,107.84,105.37,105.39,1807167.0,0.0,1.0,107.24,107.84,105.37,105.39,1807167.0
-2017-12-18,108.66,109.43,107.28,107.48,2305840.0,0.0,1.0,108.66,109.43,107.28,107.48,2305840.0
-2017-12-15,106.55,108.93,106.47,108.4,2434779.0,0.0,1.0,106.55,108.93,106.47,108.4,2434779.0
-2017-12-14,105.95,107.12,105.95,106.25,1479116.0,0.0,1.0,105.95,107.12,105.95,106.25,1479116.0
-2017-12-13,107.03,107.89,105.51,106.02,1924569.0,0.0,1.0,107.03,107.89,105.51,106.02,1924569.0
-2017-12-12,106.32,107.98,105.58,106.33,1987461.0,0.0,1.0,106.32,107.98,105.58,106.33,1987461.0
-2017-12-11,106.87,107.95,106.15,106.83,2270028.0,0.0,1.0,106.87,107.95,106.15,106.83,2270028.0
-2017-12-08,109.6,110.17,106.69,107.16,3094512.0,0.0,1.0,109.6,110.17,106.69,107.16,3094512.0
-2017-12-07,106.2,110.18,106.0,109.61,3028608.0,0.0,1.0,106.2,110.18,106.0,109.61,3028608.0
-2017-12-06,105.73,107.83,105.73,106.92,1678616.0,0.0,1.0,105.73,107.83,105.73,106.92,1678616.0
-2017-12-05,107.91,109.49,106.55,106.59,2983741.0,0.0,1.0,107.91,109.49,106.55,106.59,2983741.0
-2017-12-04,108.0,108.69,105.16,107.95,3940444.0,0.0,1.0,108.0,108.69,105.16,107.95,3940444.0
-2017-12-01,108.81,110.12,106.29,107.06,4905374.0,0.0,1.0,108.81,110.12,106.29,107.06,4905374.0
-2017-11-30,109.64,111.579,106.54,109.7,8408815.0,0.0,1.0,109.64,111.579,106.54,109.7,8408815.0
-2017-11-29,114.03,114.46,106.2,109.34,19333560.0,0.0,1.0,114.03,114.46,106.2,109.34,19333560.0
-2017-11-28,130.76,131.1,127.49,129.95,3683510.0,0.0,1.0,130.76,131.1,127.49,129.95,3683510.0
-2017-11-27,130.19,130.92,129.26,130.24,2248835.0,0.0,1.0,130.19,130.92,129.26,130.24,2248835.0
-2017-11-24,127.74,129.54,127.65,129.5,1013550.0,0.0,1.0,127.74,129.54,127.65,129.5,1013550.0
-2017-11-22,128.01,128.685,126.835,127.77,1467080.0,0.0,1.0,128.01,128.685,126.835,127.77,1467080.0
-2017-11-21,127.13,128.17,126.97,127.71,1567056.0,0.0,1.0,127.13,128.17,126.97,127.71,1567056.0
-2017-11-20,127.51,128.28,126.11,126.28,1711322.0,0.0,1.0,127.51,128.28,126.11,126.28,1711322.0
-2017-11-17,127.49,127.92,125.87,127.49,1458953.0,0.0,1.0,127.49,127.92,125.87,127.49,1458953.0
-2017-11-16,124.79,127.0,124.64,127.0,1525137.0,0.0,1.0,124.79,127.0,124.64,127.0,1525137.0
-2017-11-15,123.87,125.01,122.44,124.02,1439532.0,0.0,1.0,123.87,125.01,122.44,124.02,1439532.0
-2017-11-14,124.4,124.82,123.16,123.87,1221703.0,0.0,1.0,124.4,124.82,123.16,123.87,1221703.0
-2017-11-13,124.34,125.02,122.685,124.64,1132264.0,0.0,1.0,124.34,125.02,122.685,124.64,1132264.0
-2017-11-10,121.95,123.32,121.31,123.11,929375.0,0.0,1.0,121.95,123.32,121.31,123.11,929375.0
-2017-11-09,122.9,123.09,120.01,122.4,1455225.0,0.0,1.0,122.9,123.09,120.01,122.4,1455225.0
-2017-11-07,124.26,124.54,122.61,123.4,803631.0,0.0,1.0,124.26,124.54,122.61,123.4,803631.0
-2017-11-06,125.0,125.09,123.19,123.82,994672.0,0.0,1.0,125.0,125.09,123.19,123.82,994672.0
-2017-11-03,124.5,125.5,124.1101,124.85,1308745.0,0.0,1.0,124.5,125.5,124.1101,124.85,1308745.0
-2017-11-02,125.5,125.65,123.51,124.72,1732421.0,0.0,1.0,125.5,125.65,123.51,124.72,1732421.0
-2017-11-01,125.63,126.44,123.4,124.78,1612432.0,0.0,1.0,125.63,126.44,123.4,124.78,1612432.0
-2017-10-31,124.28,125.01,123.42,124.96,1836559.0,0.0,1.0,124.28,125.01,123.42,124.96,1836559.0
-2017-10-30,123.04,124.28,121.9,123.91,1606533.0,0.0,1.0,123.04,124.28,121.9,123.91,1606533.0
-2017-10-27,121.61,123.97,121.4,123.58,1503302.0,0.0,1.0,121.61,123.97,121.4,123.58,1503302.0
-2017-10-26,120.21,121.95,119.46,121.35,893806.0,0.0,1.0,120.21,121.95,119.46,121.35,893806.0
-2017-10-25,119.0,120.25,118.05,119.94,1064033.0,0.0,1.0,119.0,120.25,118.05,119.94,1064033.0
-2017-10-24,118.96,119.61,117.9,119.29,1306666.0,0.0,1.0,118.96,119.61,117.9,119.29,1306666.0
-2017-10-23,120.99,121.72,118.73,118.99,1484003.0,0.0,1.0,120.99,121.72,118.73,118.99,1484003.0
-2017-10-20,119.98,121.88,119.7,120.81,1570159.0,0.0,1.0,119.98,121.88,119.7,120.81,1570159.0
-2017-10-19,119.0,119.32,117.57,119.29,1087574.0,0.0,1.0,119.0,119.32,117.57,119.29,1087574.0
-2017-10-18,118.5,118.86,117.7834,118.54,998575.0,0.0,1.0,118.5,118.86,117.7834,118.54,998575.0
-2017-10-17,119.35,119.7599,118.06,118.72,1179973.0,0.0,1.0,119.35,119.7599,118.06,118.72,1179973.0
-2017-10-16,119.69,119.97,118.67,119.2,1176704.0,0.0,1.0,119.69,119.97,118.67,119.2,1176704.0
-2017-10-13,119.77,119.77,118.4498,119.63,1226925.0,0.0,1.0,119.77,119.77,118.4498,119.63,1226925.0
-2017-10-12,118.55,119.84,118.51,118.99,1226381.0,0.0,1.0,118.55,119.84,118.51,118.99,1226381.0
-2017-10-11,117.02,118.66,116.93,118.57,1072510.0,0.0,1.0,117.02,118.66,116.93,118.57,1072510.0
-2017-10-10,117.22,117.53,116.32,117.05,916721.0,0.0,1.0,117.22,117.53,116.32,117.05,916721.0
-2017-10-09,116.8,117.52,116.64,117.14,847005.0,0.0,1.0,116.8,117.52,116.64,117.14,847005.0
-2017-10-06,116.18,117.61,115.81,116.96,1718039.0,0.0,1.0,116.18,117.61,115.81,116.96,1718039.0
-2017-10-05,114.5,116.83,113.9,116.54,1578348.0,0.0,1.0,114.5,116.83,113.9,116.54,1578348.0
-2017-10-04,113.79,114.07,112.35,114.05,1120483.0,0.0,1.0,113.79,114.07,112.35,114.05,1120483.0
-2017-10-03,112.39,113.73,111.67,113.63,1039855.0,0.0,1.0,112.39,113.73,111.67,113.63,1039855.0
-2017-10-02,110.6915,113.76,110.68,112.47,1957433.0,0.0,1.0,110.6915,113.76,110.68,112.47,1957433.0
-2017-09-29,111.25,112.76,111.0,112.26,2013739.0,0.0,1.0,111.25,112.76,111.0,112.26,2013739.0
-2017-09-28,111.4,111.96,110.52,111.45,1335191.0,0.0,1.0,111.4,111.96,110.52,111.45,1335191.0
-2017-09-27,110.21,113.47,110.21,111.96,1717796.0,0.0,1.0,110.21,113.47,110.21,111.96,1717796.0
-2017-09-26,110.59,111.38,108.83,110.61,1579054.0,0.0,1.0,110.59,111.38,108.83,110.61,1579054.0
-2017-09-25,111.67,111.83,108.65,109.82,2015979.0,0.0,1.0,111.67,111.83,108.65,109.82,2015979.0
-2017-09-22,111.68,112.82,111.64,111.78,944731.0,0.0,1.0,111.68,112.82,111.64,111.78,944731.0
-2017-09-21,112.82,113.0,111.37,112.29,1148893.0,0.0,1.0,112.82,113.0,111.37,112.29,1148893.0
-2017-09-20,113.07,113.339,111.35,112.73,1686485.0,0.0,1.0,113.07,113.339,111.35,112.73,1686485.0
-2017-09-19,113.77,114.06,112.97,113.08,1945388.0,0.0,1.0,113.77,114.06,112.97,113.08,1945388.0
-2017-09-18,113.74,114.66,112.87,113.84,2020868.0,0.0,1.0,113.74,114.66,112.87,113.84,2020868.0
-2017-09-15,115.62,115.62,113.88,114.3,6185403.0,0.0,1.0,115.62,115.62,113.88,114.3,6185403.0
-2017-09-14,115.62,116.14,114.5,115.48,1625113.0,0.0,1.0,115.62,116.14,114.5,115.48,1625113.0
-2017-09-13,116.04,116.5,115.25,116.18,1269826.0,0.0,1.0,116.04,116.5,115.25,116.18,1269826.0
-2017-09-12,116.35,116.99,114.98,116.16,1523756.0,0.0,1.0,116.35,116.99,114.98,116.16,1523756.0
-2017-09-11,112.98,117.125,112.22,116.48,2279670.0,0.0,1.0,112.98,117.125,112.22,116.48,2279670.0
-2017-09-08,114.17,115.72,114.1,114.44,2650236.0,0.0,1.0,114.17,115.72,114.1,114.44,2650236.0
-2017-09-07,114.14,114.465,113.19,114.05,1705693.0,0.0,1.0,114.14,114.465,113.19,114.05,1705693.0
-2017-09-06,114.4,114.78,112.65,113.79,2328344.0,0.0,1.0,114.4,114.78,112.65,113.79,2328344.0
-2017-09-05,113.46,114.81,112.52,113.77,3089055.0,0.0,1.0,113.46,114.81,112.52,113.77,3089055.0
-2017-09-01,114.63,115.62,113.65,113.71,1521113.0,0.0,1.0,114.63,115.62,113.65,113.71,1521113.0
-2017-08-31,113.63,114.7,112.815,114.46,1442442.0,0.0,1.0,113.63,114.7,112.815,114.46,1442442.0
-2017-08-30,111.27,113.67,110.61,113.29,1439951.0,0.0,1.0,111.27,113.67,110.61,113.29,1439951.0
-2017-08-29,109.65,111.895,109.25,111.27,1798166.0,0.0,1.0,109.65,111.895,109.25,111.27,1798166.0
-2017-08-28,115.06,115.14,110.01,111.48,3591870.0,0.0,1.0,115.06,115.14,110.01,111.48,3591870.0
-2017-08-25,115.0,119.73,113.54,114.97,7085626.0,0.0,1.0,115.0,119.73,113.54,114.97,7085626.0
-2017-08-24,110.58,111.25,109.04,110.61,2948237.0,0.0,1.0,110.58,111.25,109.04,110.61,2948237.0
-2017-08-23,110.91,111.34,110.05,110.65,1631213.0,0.0,1.0,110.91,111.34,110.05,110.65,1631213.0
-2017-08-22,110.31,112.235,109.77,111.01,1705576.0,0.0,1.0,110.31,112.235,109.77,111.01,1705576.0
-2017-08-21,108.37,110.3,108.37,109.75,1265606.0,0.0,1.0,108.37,110.3,108.37,109.75,1265606.0
-2017-08-18,107.86,110.1,107.19,108.56,1145061.0,0.0,1.0,107.86,110.1,107.19,108.56,1145061.0
-2017-08-17,110.07,110.82,107.73,107.89,1715092.0,0.0,1.0,110.07,110.82,107.73,107.89,1715092.0
-2017-08-16,110.36,110.93,109.36,110.49,1312081.0,0.0,1.0,110.36,110.93,109.36,110.49,1312081.0
-2017-08-15,109.02,110.1,108.12,109.8,1258345.0,0.0,1.0,109.02,110.1,108.12,109.8,1258345.0
-2017-08-14,109.2,110.0,108.01,108.9,1634486.0,0.0,1.0,109.2,110.0,108.01,108.9,1634486.0
-2017-08-11,105.75,108.7577,105.1,108.01,1422869.0,0.0,1.0,105.75,108.7577,105.1,108.01,1422869.0
-2017-08-10,106.56,107.54,104.77,104.98,1842203.0,0.0,1.0,106.56,107.54,104.77,104.98,1842203.0
-2017-08-09,107.69,107.96,106.54,107.45,1115478.0,0.0,1.0,107.69,107.96,106.54,107.45,1115478.0
-2017-08-08,109.38,110.27,108.0,108.35,1080202.0,0.0,1.0,109.38,110.27,108.0,108.35,1080202.0
-2017-08-07,108.67,111.0,108.4,109.82,1491115.0,0.0,1.0,108.67,111.0,108.4,109.82,1491115.0
-2017-08-04,108.35,109.04,107.56,108.39,1481357.0,0.0,1.0,108.35,109.04,107.56,108.39,1481357.0
-2017-08-03,107.95,108.5,105.6,107.88,2249989.0,0.0,1.0,107.95,108.5,105.6,107.88,2249989.0
-2017-08-02,111.08,111.38,107.28,109.13,1756009.0,0.0,1.0,111.08,111.38,107.28,109.13,1756009.0
-2017-08-01,111.27,112.59,111.1,111.38,1304376.0,0.0,1.0,111.27,112.59,111.1,111.38,1304376.0
-2017-07-31,111.65,112.315,109.78,110.79,1356552.0,0.0,1.0,111.65,112.315,109.78,110.79,1356552.0
-2017-07-28,110.6,112.2754,110.3326,111.5,939043.0,0.0,1.0,110.6,112.2754,110.3326,111.5,939043.0
-2017-07-27,114.97,115.25,109.32,111.52,2357620.0,0.0,1.0,114.97,115.25,109.32,111.52,2357620.0
-2017-07-26,112.5,114.1,112.41,114.08,1882057.0,0.0,1.0,112.5,114.1,112.41,114.08,1882057.0
-2017-07-25,110.91,112.4,110.2,112.26,1337115.0,0.0,1.0,110.91,112.4,110.2,112.26,1337115.0
-2017-07-24,109.59,110.89,109.335,110.81,1050047.0,0.0,1.0,109.59,110.89,109.335,110.81,1050047.0
-2017-07-21,109.41,110.54,109.08,109.75,1100700.0,0.0,1.0,109.41,110.54,109.08,109.75,1100700.0
-2017-07-20,109.72,110.5,108.88,109.91,1259425.0,0.0,1.0,109.72,110.5,108.88,109.91,1259425.0
-2017-07-19,108.5,110.5,108.47,110.25,2034611.0,0.0,1.0,108.5,110.5,108.47,110.25,2034611.0
-2017-07-18,106.67,107.85,106.23,107.7,862647.0,0.0,1.0,106.67,107.85,106.23,107.7,862647.0
-2017-07-17,108.9,109.0,106.56,106.94,1175554.0,0.0,1.0,108.9,109.0,106.56,106.94,1175554.0
-2017-07-14,107.46,108.91,107.01,108.74,1479526.0,0.0,1.0,107.46,108.91,107.01,108.74,1479526.0
-2017-07-13,107.49,108.5,106.38,107.07,1411266.0,0.0,1.0,107.49,108.5,106.38,107.07,1411266.0
-2017-07-12,105.61,107.08,104.76,106.68,2612888.0,0.0,1.0,105.61,107.08,104.76,106.68,2612888.0
-2017-07-11,103.47,104.73,102.98,104.3,1450669.0,0.0,1.0,103.47,104.73,102.98,104.3,1450669.0
-2017-07-10,103.33,104.185,102.38,103.74,1191783.0,0.0,1.0,103.33,104.185,102.38,103.74,1191783.0
-2017-07-07,102.29,104.28,102.29,103.32,1666452.0,0.0,1.0,102.29,104.28,102.29,103.32,1666452.0
-2017-07-06,101.59,103.11,100.794,102.05,2593456.0,0.0,1.0,101.59,103.11,100.794,102.05,2593456.0
-2017-07-05,99.37,103.04,99.22,102.6,2759895.0,0.0,1.0,99.37,103.04,99.22,102.6,2759895.0
-2017-07-03,101.32,101.82,99.32,99.36,1454229.0,0.0,1.0,101.32,101.82,99.32,99.36,1454229.0
-2017-06-30,102.32,102.37,100.75,100.82,1659031.0,0.0,1.0,102.32,102.37,100.75,100.82,1659031.0
-2017-06-29,103.57,103.8105,100.0,101.39,2333399.0,0.0,1.0,103.57,103.8105,100.0,101.39,2333399.0
-2017-06-28,103.69,104.86,101.54,104.28,1640245.0,0.0,1.0,103.69,104.86,101.54,104.28,1640245.0
-2017-06-27,105.58,106.45,102.5,102.92,2215375.0,0.0,1.0,105.58,106.45,102.5,102.92,2215375.0
-2017-06-26,107.76,109.07,105.31,106.12,1870235.0,0.0,1.0,107.76,109.07,105.31,106.12,1870235.0
-2017-06-23,106.4,108.76,105.3,107.71,3598155.0,0.0,1.0,106.4,108.76,105.3,107.71,3598155.0
-2017-06-22,105.72,107.26,104.55,106.78,2327303.0,0.0,1.0,105.72,107.26,104.55,106.78,2327303.0
-2017-06-21,105.88,106.56,104.82,105.69,2641503.0,0.0,1.0,105.88,106.56,104.82,105.69,2641503.0
-2017-06-20,106.01,107.11,104.3,104.93,1946595.0,0.0,1.0,106.01,107.11,104.3,104.93,1946595.0
-2017-06-19,105.6,106.7,105.16,106.16,2432063.0,0.0,1.0,105.6,106.7,105.16,106.16,2432063.0
-2017-06-16,105.5,105.92,103.63,104.88,2536983.0,0.0,1.0,105.5,105.92,103.63,104.88,2536983.0
-2017-06-15,104.77,106.04,103.48,105.58,1740903.0,0.0,1.0,104.77,106.04,103.48,105.58,1740903.0
-2017-06-14,108.52,108.65,105.0232,106.2,1953219.0,0.0,1.0,108.52,108.65,105.0232,106.2,1953219.0
-2017-06-13,107.6,108.24,105.17,107.55,2257865.0,0.0,1.0,107.6,108.24,105.17,107.55,2257865.0
-2017-06-12,104.21,108.62,100.7,107.44,5005477.0,0.0,1.0,104.21,108.62,100.7,107.44,5005477.0
-2017-06-09,111.16,111.6999,103.62,105.95,3011163.0,0.0,1.0,111.16,111.6999,103.62,105.95,3011163.0
-2017-06-08,111.51,111.95,110.2,111.12,2006959.0,0.0,1.0,111.51,111.95,110.2,111.12,2006959.0
-2017-06-07,111.38,112.08,110.6,111.17,2010213.0,0.0,1.0,111.38,112.08,110.6,111.17,2010213.0
-2017-06-06,110.4,112.27,110.19,111.45,1505270.0,0.0,1.0,110.4,112.27,110.19,111.45,1505270.0
-2017-06-05,112.74,113.14,110.23,110.88,3933494.0,0.0,1.0,112.74,113.14,110.23,110.88,3933494.0
-2017-06-02,113.78,113.88,111.76,112.91,2213075.0,0.0,1.0,113.78,113.88,111.76,112.91,2213075.0
-2017-06-01,111.72,113.12,110.94,113.03,2318445.0,0.0,1.0,111.72,113.12,110.94,113.03,2318445.0
diff --git a/examples/quick/demos/stocqt/content/data/AMD.csv b/examples/quick/demos/stocqt/content/data/AMD.csv
deleted file mode 100644
index 62c33c6faa..0000000000
--- a/examples/quick/demos/stocqt/content/data/AMD.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,10.57,10.58,10.27,10.28,26321111.0,0.0,1.0,10.57,10.58,10.27,10.28,26321111.0
-2017-12-28,10.57,10.64,10.43,10.55,18345480.0,0.0,1.0,10.57,10.64,10.43,10.55,18345480.0
-2017-12-27,10.45,10.74,10.4,10.53,22780900.0,0.0,1.0,10.45,10.74,10.4,10.53,22780900.0
-2017-12-26,10.38,10.579,10.34,10.46,20362897.0,0.0,1.0,10.38,10.579,10.34,10.46,20362897.0
-2017-12-22,10.75,10.77,10.2,10.54,50572874.0,0.0,1.0,10.75,10.77,10.2,10.54,50572874.0
-2017-12-21,10.98,11.0793,10.87,10.89,21645217.0,0.0,1.0,10.98,11.0793,10.87,10.89,21645217.0
-2017-12-20,11.1,11.18,10.8,10.98,31053753.0,0.0,1.0,11.1,11.18,10.8,10.98,31053753.0
-2017-12-19,11.0,11.19,10.87,10.95,43445290.0,0.0,1.0,11.0,11.19,10.87,10.95,43445290.0
-2017-12-18,10.6,11.0,10.51,10.98,62789226.0,0.0,1.0,10.6,11.0,10.51,10.98,62789226.0
-2017-12-15,10.13,10.32,10.02,10.3,42459234.0,0.0,1.0,10.13,10.32,10.02,10.3,42459234.0
-2017-12-14,10.1,10.17,9.96,10.13,26491754.0,0.0,1.0,10.1,10.17,9.96,10.13,26491754.0
-2017-12-13,9.97,10.21,9.95,10.11,41201508.0,0.0,1.0,9.97,10.21,9.95,10.11,41201508.0
-2017-12-12,10.13,10.14,9.88,9.9,35843064.0,0.0,1.0,10.13,10.14,9.88,9.9,35843064.0
-2017-12-11,9.97,10.16,9.96,10.16,29359732.0,0.0,1.0,9.97,10.16,9.96,10.16,29359732.0
-2017-12-08,10.15,10.2,9.92,9.94,34582737.0,0.0,1.0,10.15,10.2,9.92,9.94,34582737.0
-2017-12-07,10.0705,10.19,9.95,10.04,32273896.0,0.0,1.0,10.0705,10.19,9.95,10.04,32273896.0
-2017-12-06,9.9,10.05,9.71,10.0,38351614.0,0.0,1.0,9.9,10.05,9.71,10.0,38351614.0
-2017-12-05,9.89,10.34,9.7,9.91,66840417.0,0.0,1.0,9.89,10.34,9.7,9.91,66840417.0
-2017-12-04,10.85,10.86,9.82,10.03,95608827.0,0.0,1.0,10.85,10.86,9.82,10.03,95608827.0
-2017-12-01,10.81,10.97,10.53,10.7201,41932685.0,0.0,1.0,10.81,10.97,10.53,10.7201,41932685.0
-2017-11-30,10.87,11.03,10.76,10.89,42311007.0,0.0,1.0,10.87,11.03,10.76,10.89,42311007.0
-2017-11-29,11.08,11.17,10.73,10.825,63028757.0,0.0,1.0,11.08,11.17,10.73,10.825,63028757.0
-2017-11-28,11.45,11.54,11.0,11.17,65088197.0,0.0,1.0,11.45,11.54,11.0,11.17,65088197.0
-2017-11-27,11.34,11.74,11.3358,11.55,41565129.0,0.0,1.0,11.34,11.74,11.3358,11.55,41565129.0
-2017-11-24,11.38,11.42,11.3,11.38,11033178.0,0.0,1.0,11.38,11.42,11.3,11.38,11033178.0
-2017-11-22,11.41,11.49,11.3,11.37,23686100.0,0.0,1.0,11.41,11.49,11.3,11.37,23686100.0
-2017-11-21,11.421,11.49,11.24,11.4,31469531.0,0.0,1.0,11.421,11.49,11.24,11.4,31469531.0
-2017-11-20,11.47,11.505,11.19,11.34,35827552.0,0.0,1.0,11.47,11.505,11.19,11.34,35827552.0
-2017-11-17,11.3,11.75,11.28,11.38,56245136.0,0.0,1.0,11.3,11.75,11.28,11.38,56245136.0
-2017-11-16,11.13,11.32,11.13,11.25,30814936.0,0.0,1.0,11.13,11.32,11.13,11.25,30814936.0
-2017-11-15,11.01,11.13,10.77,11.07,33326871.0,0.0,1.0,11.01,11.13,10.77,11.07,33326871.0
-2017-11-14,11.03,11.26,11.0,11.12,36254723.0,0.0,1.0,11.03,11.26,11.0,11.12,36254723.0
-2017-11-13,11.18,11.2,10.92,11.09,53925999.0,0.0,1.0,11.18,11.2,10.92,11.09,53925999.0
-2017-11-10,11.22,11.43,11.115,11.26,50022529.0,0.0,1.0,11.22,11.43,11.115,11.26,50022529.0
-2017-11-09,11.25,11.35,11.03,11.12,75698460.0,0.0,1.0,11.25,11.35,11.03,11.12,75698460.0
-2017-11-07,11.94,12.27,11.92,12.05,66232713.0,0.0,1.0,11.94,12.27,11.92,12.05,66232713.0
-2017-11-06,12.04,12.09,11.64,11.93,95719936.0,0.0,1.0,12.04,12.09,11.64,11.93,95719936.0
-2017-11-03,10.95,11.13,10.82,11.12,43989491.0,0.0,1.0,10.95,11.13,10.82,11.12,43989491.0
-2017-11-02,10.87,10.99,10.66,10.85,47509725.0,0.0,1.0,10.87,10.99,10.66,10.85,47509725.0
-2017-11-01,11.25,11.29,10.72,10.8,66416610.0,0.0,1.0,11.25,11.29,10.72,10.8,66416610.0
-2017-10-31,10.76,11.31,10.69,10.985,78118243.0,0.0,1.0,10.76,11.31,10.69,10.985,78118243.0
-2017-10-30,11.255,11.42,10.65,10.89,136725037.0,0.0,1.0,11.255,11.42,10.65,10.89,136725037.0
-2017-10-27,12.17,12.19,11.35,11.84,115163241.0,0.0,1.0,12.17,12.19,11.35,11.84,115163241.0
-2017-10-26,12.45,12.46,12.0,12.005,86725366.0,0.0,1.0,12.45,12.46,12.0,12.005,86725366.0
-2017-10-25,12.95,13.13,12.29,12.33,165686209.0,0.0,1.0,12.95,13.13,12.29,12.33,165686209.0
-2017-10-24,14.2,14.36,14.15,14.25,60340437.0,0.0,1.0,14.2,14.36,14.15,14.25,60340437.0
-2017-10-23,13.94,14.19,13.8999,14.1,49438627.0,0.0,1.0,13.94,14.19,13.8999,14.1,49438627.0
-2017-10-20,14.03,14.09,13.8,13.81,31624215.0,0.0,1.0,14.03,14.09,13.8,13.81,31624215.0
-2017-10-19,13.85,14.04,13.69,13.95,33600243.0,0.0,1.0,13.85,14.04,13.69,13.95,33600243.0
-2017-10-18,14.2,14.279,13.76,14.07,38868463.0,0.0,1.0,14.2,14.279,13.76,14.07,38868463.0
-2017-10-17,14.24,14.345,14.135,14.16,28695155.0,0.0,1.0,14.24,14.345,14.135,14.16,28695155.0
-2017-10-16,14.25,14.35,14.12,14.26,33684147.0,0.0,1.0,14.25,14.35,14.12,14.26,33684147.0
-2017-10-13,14.32,14.41,14.12,14.22,37160693.0,0.0,1.0,14.32,14.41,14.12,14.22,37160693.0
-2017-10-12,13.85,14.37,13.81,14.2,69313327.0,0.0,1.0,13.85,14.37,13.81,14.2,69313327.0
-2017-10-11,13.62,13.96,13.61,13.88,38017847.0,0.0,1.0,13.62,13.96,13.61,13.88,38017847.0
-2017-10-10,13.72,13.79,13.44,13.7,43046193.0,0.0,1.0,13.72,13.79,13.44,13.7,43046193.0
-2017-10-09,13.26,13.83,13.26,13.47,53748724.0,0.0,1.0,13.26,13.83,13.26,13.47,53748724.0
-2017-10-06,13.22,13.39,13.18,13.23,27939491.0,0.0,1.0,13.22,13.39,13.18,13.23,27939491.0
-2017-10-05,13.38,13.46,13.21,13.34,34409933.0,0.0,1.0,13.38,13.46,13.21,13.34,34409933.0
-2017-10-04,13.31,13.5,13.15,13.31,41814144.0,0.0,1.0,13.31,13.5,13.15,13.31,41814144.0
-2017-10-03,12.73,13.48,12.7,13.42,84656340.0,0.0,1.0,12.73,13.48,12.7,13.42,84656340.0
-2017-10-02,12.8,12.85,12.62,12.71,34256219.0,0.0,1.0,12.8,12.85,12.62,12.71,34256219.0
-2017-09-29,12.765,12.82,12.6,12.75,33358815.0,0.0,1.0,12.765,12.82,12.6,12.75,33358815.0
-2017-09-28,12.76,12.84,12.55,12.74,35439338.0,0.0,1.0,12.76,12.84,12.55,12.74,35439338.0
-2017-09-27,12.65,12.87,12.5,12.74,59391214.0,0.0,1.0,12.65,12.87,12.5,12.74,59391214.0
-2017-09-26,12.85,12.93,12.43,12.45,67417625.0,0.0,1.0,12.85,12.93,12.43,12.45,67417625.0
-2017-09-25,13.25,13.28,12.49,12.61,83429167.0,0.0,1.0,13.25,13.28,12.49,12.61,83429167.0
-2017-09-22,13.2,13.4,13.12,13.3,49752570.0,0.0,1.0,13.2,13.4,13.12,13.3,49752570.0
-2017-09-21,14.0,14.24,13.32,13.41,164802839.0,0.0,1.0,14.0,14.24,13.32,13.41,164802839.0
-2017-09-20,13.07,13.8,12.8,13.76,82385985.0,0.0,1.0,13.07,13.8,12.8,13.76,82385985.0
-2017-09-19,13.25,13.29,12.88,13.12,64693928.0,0.0,1.0,13.25,13.29,12.88,13.12,64693928.0
-2017-09-18,12.77,13.3,12.74,13.08,82647358.0,0.0,1.0,12.77,13.3,12.74,13.08,82647358.0
-2017-09-15,12.33,12.66,12.31,12.52,49576344.0,0.0,1.0,12.33,12.66,12.31,12.52,49576344.0
-2017-09-14,12.15,12.46,12.11,12.26,36903301.0,0.0,1.0,12.15,12.46,12.11,12.26,36903301.0
-2017-09-13,12.22,12.36,12.12,12.22,36978783.0,0.0,1.0,12.22,12.36,12.12,12.22,36978783.0
-2017-09-12,12.66,12.68,12.213,12.3,54029549.0,0.0,1.0,12.66,12.68,12.213,12.3,54029549.0
-2017-09-11,12.46,12.74,12.4001,12.55,42904404.0,0.0,1.0,12.46,12.74,12.4001,12.55,42904404.0
-2017-09-08,12.5712,12.61,12.035,12.25,60503832.0,0.0,1.0,12.5712,12.61,12.035,12.25,60503832.0
-2017-09-07,12.84,12.94,12.6,12.63,35467788.0,0.0,1.0,12.84,12.94,12.6,12.63,35467788.0
-2017-09-06,13.02,13.08,12.75,12.85,33828656.0,0.0,1.0,13.02,13.08,12.75,12.85,33828656.0
-2017-09-05,12.88,13.18,12.65,12.92,51359359.0,0.0,1.0,12.88,13.18,12.65,12.92,51359359.0
-2017-09-01,13.12,13.485,13.04,13.19,52901453.0,0.0,1.0,13.12,13.485,13.04,13.19,52901453.0
-2017-08-31,12.82,13.16,12.79,13.0,51056961.0,0.0,1.0,12.82,13.16,12.79,13.0,51056961.0
-2017-08-30,12.19,12.68,12.16,12.67,43434380.0,0.0,1.0,12.19,12.68,12.16,12.67,43434380.0
-2017-08-29,12.0,12.18,11.93,12.15,33290113.0,0.0,1.0,12.0,12.18,11.93,12.15,33290113.0
-2017-08-28,12.53,12.55,12.16,12.23,35078317.0,0.0,1.0,12.53,12.55,12.16,12.23,35078317.0
-2017-08-25,12.51,12.57,12.25,12.425,29543318.0,0.0,1.0,12.51,12.57,12.25,12.425,29543318.0
-2017-08-24,12.69,12.71,12.39,12.505,37056907.0,0.0,1.0,12.69,12.71,12.39,12.505,37056907.0
-2017-08-23,12.0,12.535,11.95,12.48,43429439.0,0.0,1.0,12.0,12.535,11.95,12.48,43429439.0
-2017-08-22,12.2,12.33,12.1,12.175,38705808.0,0.0,1.0,12.2,12.33,12.1,12.175,38705808.0
-2017-08-21,12.42,12.42,11.86,12.05,58620489.0,0.0,1.0,12.42,12.42,11.86,12.05,58620489.0
-2017-08-18,12.43,12.555,12.25,12.376,37172947.0,0.0,1.0,12.43,12.555,12.25,12.376,37172947.0
-2017-08-17,12.46,12.65,12.32,12.34,46960411.0,0.0,1.0,12.46,12.65,12.32,12.34,46960411.0
-2017-08-16,13.17,13.19,12.52,12.63,64171662.0,0.0,1.0,13.17,13.19,12.52,12.63,64171662.0
-2017-08-15,13.01,13.14,12.75,13.02,57447725.0,0.0,1.0,13.01,13.14,12.75,13.02,57447725.0
-2017-08-14,12.58,12.845,12.58,12.76,63873137.0,0.0,1.0,12.58,12.845,12.58,12.76,63873137.0
-2017-08-11,12.04,12.39,11.88,12.23,63319050.0,0.0,1.0,12.04,12.39,11.88,12.23,63319050.0
-2017-08-10,12.7,12.92,12.11,12.12,80131441.0,0.0,1.0,12.7,12.92,12.11,12.12,80131441.0
-2017-08-09,12.76,12.89,12.54,12.83,58571682.0,0.0,1.0,12.76,12.89,12.54,12.83,58571682.0
-2017-08-08,13.48,13.55,13.08,13.11,46548040.0,0.0,1.0,13.48,13.55,13.08,13.11,46548040.0
-2017-08-07,13.33,13.57,13.27,13.43,57203474.0,0.0,1.0,13.33,13.57,13.27,13.43,57203474.0
-2017-08-04,13.2,13.36,13.02,13.12,63954775.0,0.0,1.0,13.2,13.36,13.02,13.12,63954775.0
-2017-08-03,13.42,13.52,13.08,13.24,51720273.0,0.0,1.0,13.42,13.52,13.08,13.24,51720273.0
-2017-08-02,13.81,13.93,13.12,13.37,67062121.0,0.0,1.0,13.81,13.93,13.12,13.37,67062121.0
-2017-08-01,13.72,13.86,13.45,13.71,48273874.0,0.0,1.0,13.72,13.86,13.45,13.71,48273874.0
-2017-07-31,14.09,14.22,13.47,13.61,68653763.0,0.0,1.0,14.09,14.22,13.47,13.61,68653763.0
-2017-07-28,13.845,14.1,13.68,13.95,66352470.0,0.0,1.0,13.845,14.1,13.68,13.95,66352470.0
-2017-07-27,14.99,15.04,13.7,14.12,129095996.0,0.0,1.0,14.99,15.04,13.7,14.12,129095996.0
-2017-07-26,15.13,15.65,14.4,14.76,234655935.0,0.0,1.0,15.13,15.65,14.4,14.76,234655935.0
-2017-07-25,14.2895,14.32,13.87,14.11,76089789.0,0.0,1.0,14.2895,14.32,13.87,14.11,76089789.0
-2017-07-24,14.0,14.44,13.97,14.16,70306709.0,0.0,1.0,14.0,14.44,13.97,14.16,70306709.0
-2017-07-21,13.7,14.05,13.62,13.88,50836269.0,0.0,1.0,13.7,14.05,13.62,13.88,50836269.0
-2017-07-20,13.61,13.89,13.45,13.8,47328081.0,0.0,1.0,13.61,13.89,13.45,13.8,47328081.0
-2017-07-19,13.62,13.74,13.41,13.55,51511044.0,0.0,1.0,13.62,13.74,13.41,13.55,51511044.0
-2017-07-18,13.29,13.53,13.15,13.48,77823247.0,0.0,1.0,13.29,13.53,13.15,13.48,77823247.0
-2017-07-17,14.03,14.12,13.51,13.8,70594469.0,0.0,1.0,14.03,14.12,13.51,13.8,70594469.0
-2017-07-14,13.46,13.93,13.32,13.92,81515312.0,0.0,1.0,13.46,13.93,13.32,13.92,81515312.0
-2017-07-13,14.33,14.49,13.43,13.53,110860494.0,0.0,1.0,14.33,14.49,13.43,13.53,110860494.0
-2017-07-12,14.17,14.39,13.96,14.29,78011028.0,0.0,1.0,14.17,14.39,13.96,14.29,78011028.0
-2017-07-11,13.77,14.099,13.62,13.89,70760527.0,0.0,1.0,13.77,14.099,13.62,13.89,70760527.0
-2017-07-10,13.61,13.88,13.27,13.81,77940920.0,0.0,1.0,13.61,13.88,13.27,13.81,77940920.0
-2017-07-07,13.27,13.745,13.18,13.36,88021133.0,0.0,1.0,13.27,13.745,13.18,13.36,88021133.0
-2017-07-06,12.94,13.32,12.665,13.02,88418322.0,0.0,1.0,12.94,13.32,12.665,13.02,88418322.0
-2017-07-05,12.36,13.21,12.32,13.19,98729984.0,0.0,1.0,12.36,13.21,12.32,13.19,98729984.0
-2017-07-03,12.57,12.73,12.13,12.15,39888247.0,0.0,1.0,12.57,12.73,12.13,12.15,39888247.0
-2017-06-30,12.57,12.83,12.36,12.48,58976478.0,0.0,1.0,12.57,12.83,12.36,12.48,58976478.0
-2017-06-29,13.06,13.15,12.45,12.6,86658774.0,0.0,1.0,13.06,13.15,12.45,12.6,86658774.0
-2017-06-28,13.65,13.7,13.09,13.23,84591176.0,0.0,1.0,13.65,13.7,13.09,13.23,84591176.0
-2017-06-27,13.76,14.04,13.37,13.395,88742270.0,0.0,1.0,13.76,14.04,13.37,13.395,88742270.0
-2017-06-26,14.39,14.49,13.84,14.08,100078492.0,0.0,1.0,14.39,14.49,13.84,14.08,100078492.0
-2017-06-23,14.15,14.67,13.9,14.15,151603584.0,0.0,1.0,14.15,14.67,13.9,14.15,151603584.0
-2017-06-22,14.1,14.5,13.56,14.3708,147959418.0,0.0,1.0,14.1,14.5,13.56,14.3708,147959418.0
-2017-06-21,13.36,14.01,13.13,13.98,187161633.0,0.0,1.0,13.36,14.01,13.13,13.98,187161633.0
-2017-06-20,12.19,12.93,12.18,12.64,116319537.0,0.0,1.0,12.19,12.93,12.18,12.64,116319537.0
-2017-06-19,11.63,12.12,11.62,11.93,61268773.0,0.0,1.0,11.63,12.12,11.62,11.93,61268773.0
-2017-06-16,11.66,11.83,11.28,11.44,58774371.0,0.0,1.0,11.66,11.83,11.28,11.44,58774371.0
-2017-06-15,11.34,11.58,11.21,11.5,60332254.0,0.0,1.0,11.34,11.58,11.21,11.5,60332254.0
-2017-06-14,11.91,12.05,11.65,11.76,51454208.0,0.0,1.0,11.91,12.05,11.65,11.76,51454208.0
-2017-06-13,12.33,12.48,11.67,11.96,86585397.0,0.0,1.0,12.33,12.48,11.67,11.96,86585397.0
-2017-06-12,11.75,12.35,11.47,12.085,123725528.0,0.0,1.0,11.75,12.35,11.47,12.085,123725528.0
-2017-06-09,13.1,13.4,11.63,12.28,165174160.0,0.0,1.0,13.1,13.4,11.63,12.28,165174160.0
-2017-06-08,12.81,12.91,12.4,12.9,87201152.0,0.0,1.0,12.81,12.91,12.4,12.9,87201152.0
-2017-06-07,12.42,12.96,12.2348,12.38,149171943.0,0.0,1.0,12.42,12.96,12.2348,12.38,149171943.0
-2017-06-06,11.27,12.24,11.24,12.02,113010266.0,0.0,1.0,11.27,12.24,11.24,12.02,113010266.0
-2017-06-05,10.84,11.34,10.8,11.24,64357671.0,0.0,1.0,10.84,11.34,10.8,11.24,64357671.0
-2017-06-02,10.93,10.96,10.565,10.9,42838855.0,0.0,1.0,10.93,10.96,10.565,10.9,42838855.0
-2017-06-01,11.25,11.285,10.81,10.93,47175511.0,0.0,1.0,11.25,11.285,10.81,10.93,47175511.0
diff --git a/examples/quick/demos/stocqt/content/data/AMZN.csv b/examples/quick/demos/stocqt/content/data/AMZN.csv
deleted file mode 100644
index f6fea4d2c8..0000000000
--- a/examples/quick/demos/stocqt/content/data/AMZN.csv
+++ /dev/null
@@ -1,147 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,1182.35,1184.0,1167.5,1169.47,2625283.0,0.0,1.0,1182.35,1184.0,1167.5,1169.47,2625283.0
-2017-12-28,1189.0,1190.1,1184.38,1186.1,1803460.0,0.0,1.0,1189.0,1190.1,1184.38,1186.1,1803460.0
-2017-12-27,1179.91,1187.29,1175.61,1182.26,1779382.0,0.0,1.0,1179.91,1187.29,1175.61,1182.26,1779382.0
-2017-12-26,1168.36,1178.32,1160.55,1176.76,1964871.0,0.0,1.0,1168.36,1178.32,1160.55,1176.76,1964871.0
-2017-12-22,1172.08,1174.62,1167.83,1168.36,1553997.0,0.0,1.0,1172.08,1174.62,1167.83,1168.36,1553997.0
-2017-12-21,1175.9,1179.17,1167.64,1174.76,2042448.0,0.0,1.0,1175.9,1179.17,1167.64,1174.76,2042448.0
-2017-12-20,1190.5,1191.0,1176.0,1177.62,2318916.0,0.0,1.0,1190.5,1191.0,1176.0,1177.62,2318916.0
-2017-12-19,1189.15,1192.97,1179.14,1187.38,2555235.0,0.0,1.0,1189.15,1192.97,1179.14,1187.38,2555235.0
-2017-12-18,1187.37,1194.78,1180.91,1190.58,2767271.0,0.0,1.0,1187.37,1194.78,1180.91,1190.58,2767271.0
-2017-12-15,1179.03,1182.75,1169.33,1179.14,4539895.0,0.0,1.0,1179.03,1182.75,1169.33,1179.14,4539895.0
-2017-12-14,1163.71,1177.93,1162.45,1174.26,3069993.0,0.0,1.0,1163.71,1177.93,1162.45,1174.26,3069993.0
-2017-12-13,1170.0,1170.87,1160.27,1164.13,2555053.0,0.0,1.0,1170.0,1170.87,1160.27,1164.13,2555053.0
-2017-12-12,1166.51,1173.6,1161.61,1165.08,2197697.0,0.0,1.0,1166.51,1173.6,1161.61,1165.08,2197697.0
-2017-12-11,1164.6,1169.9,1157.0,1168.92,2257922.0,0.0,1.0,1164.6,1169.9,1157.0,1168.92,2257922.0
-2017-12-08,1170.4,1172.79,1157.1,1162.0,2957785.0,0.0,1.0,1170.4,1172.79,1157.1,1162.0,2957785.0
-2017-12-07,1156.59,1163.19,1151.0,1159.79,2408323.0,0.0,1.0,1156.59,1163.19,1151.0,1159.79,2408323.0
-2017-12-06,1137.99,1155.89,1136.08,1152.35,2756730.0,0.0,1.0,1137.99,1155.89,1136.08,1152.35,2756730.0
-2017-12-05,1128.26,1159.27,1124.74,1141.57,4033184.0,0.0,1.0,1128.26,1159.27,1124.74,1141.57,4033184.0
-2017-12-04,1173.85,1175.2,1128.0,1133.95,5872358.0,0.0,1.0,1173.85,1175.2,1128.0,1133.95,5872358.0
-2017-12-01,1172.05,1179.65,1152.0,1162.35,4070722.0,0.0,1.0,1172.05,1179.65,1152.0,1162.35,4070722.0
-2017-11-30,1167.1,1178.57,1160.0,1176.75,4406535.0,0.0,1.0,1167.1,1178.57,1160.0,1176.75,4406535.0
-2017-11-29,1194.8,1194.8,1145.19,1161.27,9179567.0,0.0,1.0,1194.8,1194.8,1145.19,1161.27,9179567.0
-2017-11-28,1204.88,1205.34,1188.52,1193.6,4463476.0,0.0,1.0,1204.88,1205.34,1188.52,1193.6,4463476.0
-2017-11-27,1202.66,1213.41,1191.15,1195.83,6701343.0,0.0,1.0,1202.66,1213.41,1191.15,1195.83,6701343.0
-2017-11-24,1160.7,1186.84,1160.7,1186.0,3526582.0,0.0,1.0,1160.7,1186.84,1160.7,1186.0,3526582.0
-2017-11-22,1141.0,1160.27,1141.0,1156.16,3516336.0,0.0,1.0,1141.0,1160.27,1141.0,1156.16,3516336.0
-2017-11-21,1132.86,1140.0,1128.2,1139.49,2449503.0,0.0,1.0,1132.86,1140.0,1128.2,1139.49,2449503.0
-2017-11-20,1129.77,1133.42,1122.55,1126.31,2134381.0,0.0,1.0,1129.77,1133.42,1122.55,1126.31,2134381.0
-2017-11-17,1138.28,1138.8,1125.81,1129.88,2333554.0,0.0,1.0,1138.28,1138.8,1125.81,1129.88,2333554.0
-2017-11-16,1130.16,1138.16,1130.05,1137.29,2190456.0,0.0,1.0,1130.16,1138.16,1130.05,1137.29,2190456.0
-2017-11-15,1127.01,1131.75,1121.63,1126.69,3897230.0,0.0,1.0,1127.01,1131.75,1121.63,1126.69,3897230.0
-2017-11-14,1130.11,1138.0,1123.89,1136.84,3042295.0,0.0,1.0,1130.11,1138.0,1123.89,1136.84,3042295.0
-2017-11-13,1123.0,1139.9,1122.34,1129.17,2897563.0,0.0,1.0,1123.0,1139.9,1122.34,1129.17,2897563.0
-2017-11-10,1126.1,1131.75,1124.06,1125.35,2162985.0,0.0,1.0,1126.1,1131.75,1124.06,1125.35,2162985.0
-2017-11-09,1125.96,1129.62,1115.77,1129.13,3661411.0,0.0,1.0,1125.96,1129.62,1115.77,1129.13,3661411.0
-2017-11-07,1124.74,1130.6,1117.5,1123.17,2623474.0,0.0,1.0,1124.74,1130.6,1117.5,1123.17,2623474.0
-2017-11-06,1109.15,1125.41,1108.77,1120.66,3313857.0,0.0,1.0,1109.15,1125.41,1108.77,1120.66,3313857.0
-2017-11-03,1091.15,1112.68,1088.52,1111.6,3685172.0,0.0,1.0,1091.15,1112.68,1088.52,1111.6,3685172.0
-2017-11-02,1097.81,1101.94,1086.87,1094.22,3658748.0,0.0,1.0,1097.81,1101.94,1086.87,1094.22,3658748.0
-2017-11-01,1105.4,1108.97,1096.74,1103.68,3723680.0,0.0,1.0,1105.4,1108.97,1096.74,1103.68,3723680.0
-2017-10-31,1109.0,1110.54,1101.12,1105.28,3428461.0,0.0,1.0,1109.0,1110.54,1101.12,1105.28,3428461.0
-2017-10-30,1095.01,1122.79,1093.56,1110.85,6516639.0,0.0,1.0,1095.01,1122.79,1093.56,1110.85,6516639.0
-2017-10-27,1058.14,1105.58,1050.55,1100.95,16360527.0,0.0,1.0,1058.14,1105.58,1050.55,1100.95,16360527.0
-2017-10-26,980.33,982.9,968.55,972.43,3670282.0,0.0,1.0,980.33,982.9,968.55,972.43,3670282.0
-2017-10-25,978.0,984.44,966.24,972.91,2969295.0,0.0,1.0,978.0,984.44,966.24,972.91,2969295.0
-2017-10-24,969.0,979.85,965.0,975.9,2666782.0,0.0,1.0,969.0,979.85,965.0,975.9,2666782.0
-2017-10-23,986.73,986.775,962.5,966.3,3465469.0,0.0,1.0,986.73,986.775,962.5,966.3,3465469.0
-2017-10-20,993.53,994.62,982.0,982.91,2294145.0,0.0,1.0,993.53,994.62,982.0,982.91,2294145.0
-2017-10-19,990.0,991.05,980.24,986.61,3040066.0,0.0,1.0,990.0,991.05,980.24,986.61,3040066.0
-2017-10-18,1009.27,1022.31,996.55,997.0,2477357.0,0.0,1.0,1009.27,1022.31,996.55,997.0,2477357.0
-2017-10-17,1005.59,1011.47,1004.38,1009.13,2307075.0,0.0,1.0,1005.59,1011.47,1004.38,1009.13,2307075.0
-2017-10-16,1008.44,1009.57,1001.04,1006.34,1991556.0,0.0,1.0,1008.44,1009.57,1001.04,1006.34,1991556.0
-2017-10-13,1007.0,1007.77,1001.03,1002.94,2399403.0,0.0,1.0,1007.0,1007.77,1001.03,1002.94,2399403.0
-2017-10-12,996.81,1008.44,992.4,1000.93,4056172.0,0.0,1.0,996.81,1008.44,992.4,1000.93,4056172.0
-2017-10-11,991.27,995.5,986.695,995.0,2310872.0,0.0,1.0,991.27,995.5,986.695,995.0,2310872.0
-2017-10-10,996.67,997.95,980.099,987.2,3062820.0,0.0,1.0,996.67,997.95,980.099,987.2,3062820.0
-2017-10-09,993.24,998.5,987.5,990.99,2927994.0,0.0,1.0,993.24,998.5,987.5,990.99,2927994.0
-2017-10-06,975.64,995.75,975.64,989.58,3719840.0,0.0,1.0,975.64,995.75,975.64,989.58,3719840.0
-2017-10-05,970.0,981.51,969.64,980.85,3119487.0,0.0,1.0,970.0,981.51,969.64,980.85,3119487.0
-2017-10-04,954.21,967.79,954.05,965.45,2460721.0,0.0,1.0,954.21,967.79,954.05,965.45,2460721.0
-2017-10-03,958.0,963.69,950.37,957.1,2643484.0,0.0,1.0,958.0,963.69,950.37,957.1,2643484.0
-2017-10-02,964.0,967.305,952.1201,959.19,2415846.0,0.0,1.0,964.0,967.305,952.1201,959.19,2415846.0
-2017-09-29,960.11,964.83,958.375,961.35,2411643.0,0.0,1.0,960.11,964.83,958.375,961.35,2411643.0
-2017-09-28,951.86,959.7,950.101,956.4,2512567.0,0.0,1.0,951.86,959.7,950.101,956.4,2512567.0
-2017-09-27,948.0,955.3,943.3,950.87,3111263.0,0.0,1.0,948.0,955.3,943.3,950.87,3111263.0
-2017-09-26,945.49,948.63,931.75,938.6,3464183.0,0.0,1.0,945.49,948.63,931.75,938.6,3464183.0
-2017-09-25,949.31,949.42,932.89,939.79,5065542.0,0.0,1.0,949.31,949.42,932.89,939.79,5065542.0
-2017-09-22,961.01,965.61,954.42,955.1,2602418.0,0.0,1.0,961.01,965.61,954.42,955.1,2602418.0
-2017-09-21,971.31,971.7,962.02,964.65,2252940.0,0.0,1.0,971.31,971.7,962.02,964.65,2252940.0
-2017-09-20,971.79,974.81,962.1626,973.21,2727355.0,0.0,1.0,971.79,974.81,962.1626,973.21,2727355.0
-2017-09-19,977.25,978.24,967.46,969.86,2614059.0,0.0,1.0,977.25,978.24,967.46,969.86,2614059.0
-2017-09-18,990.4,992.7922,968.17,974.19,3376772.0,0.0,1.0,990.4,992.7922,968.17,974.19,3376772.0
-2017-09-15,993.01,996.25,984.03,986.79,3697742.0,0.0,1.0,993.01,996.25,984.03,986.79,3697742.0
-2017-09-14,996.8,998.56,987.74,992.21,3788472.0,0.0,1.0,996.8,998.56,987.74,992.21,3788472.0
-2017-09-13,983.97,1000.0,979.42,999.6,3314978.0,0.0,1.0,983.97,1000.0,979.42,999.6,3314978.0
-2017-09-12,983.27,984.6718,975.517,982.58,2444699.0,0.0,1.0,983.27,984.6718,975.517,982.58,2444699.0
-2017-09-11,974.46,981.94,974.22,977.96,2134582.0,0.0,1.0,974.46,981.94,974.22,977.96,2134582.0
-2017-09-08,979.1,979.88,963.47,965.9,2578269.0,0.0,1.0,979.1,979.88,963.47,965.9,2578269.0
-2017-09-07,974.0,980.59,972.55,979.47,2536000.0,0.0,1.0,974.0,980.59,972.55,979.47,2536000.0
-2017-09-06,968.32,971.84,960.6,967.8,2106605.0,0.0,1.0,968.32,971.84,960.6,967.8,2106605.0
-2017-09-05,975.4,976.7699,960.37,965.27,2875228.0,0.0,1.0,975.4,976.7699,960.37,965.27,2875228.0
-2017-09-01,984.2,984.5,976.875,978.25,2423132.0,0.0,1.0,984.2,984.5,976.875,978.25,2423132.0
-2017-08-31,974.7,981.0,972.76,980.6,3280945.0,0.0,1.0,974.7,981.0,972.76,980.6,3280945.0
-2017-08-30,958.44,969.41,956.9062,967.59,2860718.0,0.0,1.0,958.44,969.41,956.9062,967.59,2860718.0
-2017-08-29,940.0,956.0,936.33,954.06,2853972.0,0.0,1.0,940.0,956.0,936.33,954.06,2853972.0
-2017-08-28,946.54,953.0,942.25,946.02,2529087.0,0.0,1.0,946.54,953.0,942.25,946.02,2529087.0
-2017-08-25,956.0,957.621,944.1,945.26,3292776.0,0.0,1.0,956.0,957.621,944.1,945.26,3292776.0
-2017-08-24,957.42,959.0,941.14,952.45,5086748.0,0.0,1.0,957.42,959.0,941.14,952.45,5086748.0
-2017-08-23,959.38,962.0,954.2,958.0,2590245.0,0.0,1.0,959.38,962.0,954.2,958.0,2590245.0
-2017-08-22,955.52,967.93,955.495,966.9,2718261.0,0.0,1.0,955.52,967.93,955.495,966.9,2718261.0
-2017-08-21,957.57,961.2,945.46,953.29,3008450.0,0.0,1.0,957.57,961.2,945.46,953.29,3008450.0
-2017-08-18,961.4,965.43,954.65,958.47,3248677.0,0.0,1.0,961.4,965.43,954.65,958.47,3248677.0
-2017-08-17,977.84,977.84,960.32,960.57,3396045.0,0.0,1.0,977.84,977.84,960.32,960.57,3396045.0
-2017-08-16,981.65,986.4605,973.22,978.18,3096051.0,0.0,1.0,981.65,986.4605,973.22,978.18,3096051.0
-2017-08-15,988.9,991.74,982.0,982.74,2513139.0,0.0,1.0,988.9,991.74,982.0,982.74,2513139.0
-2017-08-14,978.41,985.5,976.19,983.3,3008007.0,0.0,1.0,978.41,985.5,976.19,983.3,3008007.0
-2017-08-11,960.0,970.39,951.38,967.99,3431423.0,0.0,1.0,960.0,970.39,951.38,967.99,3431423.0
-2017-08-10,976.295,979.86,954.68,956.92,5560388.0,0.0,1.0,976.295,979.86,954.68,956.92,5560388.0
-2017-08-09,982.6,988.0,975.27,982.01,3434077.0,0.0,1.0,982.6,988.0,975.27,982.01,3434077.0
-2017-08-08,994.35,996.28,985.79,989.84,2847527.0,0.0,1.0,994.35,996.28,985.79,989.84,2847527.0
-2017-08-04,989.68,991.672,982.0,987.58,2704026.0,0.0,1.0,989.68,991.672,982.0,987.58,2704026.0
-2017-08-03,999.47,999.5,984.59,986.92,3203134.0,0.0,1.0,999.47,999.5,984.59,986.92,3203134.0
-2017-08-02,1001.77,1003.21,981.73,995.89,4017780.0,0.0,1.0,1001.77,1003.21,981.73,995.89,4017780.0
-2017-08-01,996.11,1006.4,991.58,996.19,4421395.0,0.0,1.0,996.11,1006.4,991.58,996.19,4421395.0
-2017-07-31,1019.05,1019.05,987.02,987.78,7246638.0,0.0,1.0,1019.05,1019.05,987.02,987.78,7246638.0
-2017-07-28,1012.14,1032.85,1001.0,1020.04,7624498.0,0.0,1.0,1012.14,1032.85,1001.0,1020.04,7624498.0
-2017-07-27,1069.55,1083.31,1040.18,1046.0,9905158.0,0.0,1.0,1069.55,1083.31,1040.18,1046.0,9905158.0
-2017-07-26,1043.2,1053.2,1043.2,1052.8,2828980.0,0.0,1.0,1043.2,1053.2,1043.2,1052.8,2828980.0
-2017-07-25,1038.05,1043.33,1032.48,1039.87,2432328.0,0.0,1.0,1038.05,1043.33,1032.48,1039.87,2432328.0
-2017-07-24,1028.34,1043.01,1027.43,1038.95,3212499.0,0.0,1.0,1028.34,1043.01,1027.43,1038.95,3212499.0
-2017-07-21,1021.28,1026.1,1011.0,1025.67,2677517.0,0.0,1.0,1021.28,1026.1,1011.0,1025.67,2677517.0
-2017-07-20,1031.59,1034.97,1022.52,1028.7,2964341.0,0.0,1.0,1031.59,1034.97,1022.52,1028.7,2964341.0
-2017-07-19,1025.0,1031.59,1022.5,1026.87,2936902.0,0.0,1.0,1025.0,1031.59,1022.5,1026.87,2936902.0
-2017-07-18,1006.0,1026.03,1004.0,1024.38,3957892.0,0.0,1.0,1006.0,1026.03,1004.0,1024.38,3957892.0
-2017-07-17,1004.69,1014.75,1003.81,1010.04,3636801.0,0.0,1.0,1004.69,1014.75,1003.81,1010.04,3636801.0
-2017-07-14,1002.4,1004.45,996.89,1001.81,2066362.0,0.0,1.0,1002.4,1004.45,996.89,1001.81,2066362.0
-2017-07-13,1004.62,1006.88,995.9,999.855,2864533.0,0.0,1.0,1004.62,1006.88,995.9,999.855,2864533.0
-2017-07-12,1000.65,1008.55,998.1,1006.51,3491988.0,0.0,1.0,1000.65,1008.55,998.1,1006.51,3491988.0
-2017-07-11,993.0,995.99,983.72,994.13,2947479.0,0.0,1.0,993.0,995.99,983.72,994.13,2947479.0
-2017-07-10,985.0,999.4392,983.5,996.47,3462884.0,0.0,1.0,985.0,999.4392,983.5,996.47,3462884.0
-2017-07-07,969.55,980.11,969.14,978.76,2582645.0,0.0,1.0,969.55,980.11,969.14,978.76,2582645.0
-2017-07-06,964.66,974.4,959.02,965.14,3229378.0,0.0,1.0,964.66,974.4,959.02,965.14,3229378.0
-2017-07-05,961.53,975.0,955.25,971.4,3587645.0,0.0,1.0,961.53,975.0,955.25,971.4,3587645.0
-2017-07-03,972.79,974.49,951.0001,953.66,2908267.0,0.0,1.0,972.79,974.49,951.0001,953.66,2908267.0
-2017-06-30,980.12,983.47,967.61,968.0,3309138.0,0.0,1.0,980.12,983.47,967.61,968.0,3309138.0
-2017-06-29,979.0,987.56,965.25,975.93,4246765.0,0.0,1.0,979.0,987.56,965.25,975.93,4246765.0
-2017-06-28,978.55,990.68,969.21,990.33,3708638.0,0.0,1.0,978.55,990.68,969.21,990.33,3708638.0
-2017-06-27,990.69,998.8,976.0,976.78,3735360.0,0.0,1.0,990.69,998.8,976.0,976.78,3735360.0
-2017-06-26,1008.5,1009.8,992.0,993.98,3347195.0,0.0,1.0,1008.5,1009.8,992.0,993.98,3347195.0
-2017-06-23,1002.54,1004.62,998.02,1003.74,2645973.0,0.0,1.0,1002.54,1004.62,998.02,1003.74,2645973.0
-2017-06-22,1002.23,1006.96,997.2,1001.3,2221035.0,0.0,1.0,1002.23,1006.96,997.2,1001.3,2221035.0
-2017-06-21,998.7,1002.72,992.6518,1002.23,2892563.0,0.0,1.0,998.7,1002.72,992.6518,1002.23,2892563.0
-2017-06-20,998.0,1004.88,992.02,992.59,4040990.0,0.0,1.0,998.0,1004.88,992.02,992.59,4040990.0
-2017-06-19,1017.0,1017.0,989.9,995.17,4967600.0,0.0,1.0,1017.0,1017.0,989.9,995.17,4967600.0
-2017-06-16,996.0,999.75,982.0,987.71,11314754.0,0.0,1.0,996.0,999.75,982.0,987.71,11314754.0
-2017-06-15,958.7,965.73,950.86,964.17,5202147.0,0.0,1.0,958.7,965.73,950.86,964.17,5202147.0
-2017-06-14,988.59,990.34,966.71,976.47,3943670.0,0.0,1.0,988.59,990.34,966.71,976.47,3943670.0
-2017-06-13,977.99,984.5,966.1,980.79,4533933.0,0.0,1.0,977.99,984.5,966.1,980.79,4533933.0
-2017-06-12,967.0,975.95,945.0,964.83,9393802.0,0.0,1.0,967.0,975.95,945.0,964.83,9393802.0
-2017-06-09,1012.5,1012.99,927.0,978.31,7548854.0,0.0,1.0,1012.5,1012.99,927.0,978.31,7548854.0
-2017-06-08,1012.06,1013.61,1006.11,1009.94,2724408.0,0.0,1.0,1012.06,1013.61,1006.11,1009.94,2724408.0
-2017-06-07,1005.95,1010.25,1002.0,1010.07,2779551.0,0.0,1.0,1005.95,1010.25,1002.0,1010.07,2779551.0
-2017-06-06,1012.0,1016.5,1001.25,1002.97,3298378.0,0.0,1.0,1012.0,1016.5,1001.25,1002.97,3298378.0
-2017-06-05,1007.23,1013.21,1003.51,1011.34,2676857.0,0.0,1.0,1007.23,1013.21,1003.51,1011.34,2676857.0
-2017-06-02,998.99,1008.48,995.67,1006.73,3714954.0,0.0,1.0,998.99,1008.48,995.67,1006.73,3714954.0
-2017-06-01,998.59,998.99,991.37,995.95,2384298.0,0.0,1.0,998.59,998.99,991.37,995.95,2384298.0
diff --git a/examples/quick/demos/stocqt/content/data/CSCO.csv b/examples/quick/demos/stocqt/content/data/CSCO.csv
deleted file mode 100644
index 0c4b9b05c9..0000000000
--- a/examples/quick/demos/stocqt/content/data/CSCO.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,38.41,38.62,38.3,38.3,12359455.0,0.0,1.0,38.41,38.62,38.3,38.3,12359455.0
-2017-12-28,38.73,38.73,38.45,38.59,8662664.0,0.0,1.0,38.73,38.73,38.45,38.59,8662664.0
-2017-12-27,38.54,38.65,38.45,38.56,10262927.0,0.0,1.0,38.54,38.65,38.45,38.56,10262927.0
-2017-12-26,38.55,38.68,38.36,38.48,8148042.0,0.0,1.0,38.55,38.68,38.36,38.48,8148042.0
-2017-12-22,38.52,38.74,38.47,38.55,11120656.0,0.0,1.0,38.52,38.74,38.47,38.55,11120656.0
-2017-12-21,38.88,38.995,38.49,38.53,16188471.0,0.0,1.0,38.88,38.995,38.49,38.53,16188471.0
-2017-12-20,38.49,38.8,38.21,38.74,18701741.0,0.0,1.0,38.49,38.8,38.21,38.74,18701741.0
-2017-12-19,38.66,38.86,38.28,38.3,18478762.0,0.0,1.0,38.66,38.86,38.28,38.3,18478762.0
-2017-12-18,38.48,38.89,38.3,38.48,21036306.0,0.0,1.0,38.48,38.89,38.3,38.48,21036306.0
-2017-12-15,38.01,38.28,37.7,38.19,36491640.0,0.0,1.0,38.01,38.28,37.7,38.19,36491640.0
-2017-12-14,38.2,38.27,37.855,37.9,16556403.0,0.0,1.0,38.2,38.27,37.855,37.9,16556403.0
-2017-12-13,38.09,38.37,38.0,38.15,19934529.0,0.0,1.0,38.09,38.37,38.0,38.15,19934529.0
-2017-12-12,37.79,38.1,37.56,37.91,16451320.0,0.0,1.0,37.79,38.1,37.56,37.91,16451320.0
-2017-12-11,37.59,38.04,37.57,37.96,15619388.0,0.0,1.0,37.59,38.04,37.57,37.96,15619388.0
-2017-12-08,37.59,37.69,37.42,37.61,13777371.0,0.0,1.0,37.59,37.69,37.42,37.61,13777371.0
-2017-12-07,37.26,37.78,37.26,37.4,15189086.0,0.0,1.0,37.26,37.78,37.26,37.4,15189086.0
-2017-12-06,37.37,37.72,37.25,37.41,16312845.0,0.0,1.0,37.37,37.72,37.25,37.41,16312845.0
-2017-12-05,37.74,37.82,37.17,37.31,22743474.0,0.0,1.0,37.74,37.82,37.17,37.31,22743474.0
-2017-12-04,37.81,37.99,37.54,37.72,29006129.0,0.0,1.0,37.81,37.99,37.54,37.72,29006129.0
-2017-12-01,37.09,37.66,36.73,37.6,26851147.0,0.0,1.0,37.09,37.66,36.73,37.6,26851147.0
-2017-11-30,37.62,37.8,37.3,37.3,28692862.0,0.0,1.0,37.62,37.8,37.3,37.3,28692862.0
-2017-11-29,37.75,38.025,37.23,37.48,36640805.0,0.0,1.0,37.75,38.025,37.23,37.48,36640805.0
-2017-11-28,37.0,37.8,36.98,37.73,30097816.0,0.0,1.0,37.0,37.8,36.98,37.73,30097816.0
-2017-11-27,36.51,37.09,36.5,36.87,20667352.0,0.0,1.0,36.51,37.09,36.5,36.87,20667352.0
-2017-11-24,36.41,36.57,36.32,36.49,6155294.0,0.0,1.0,36.41,36.57,36.32,36.49,6155294.0
-2017-11-22,36.7,36.715,36.36,36.45,16650130.0,0.0,1.0,36.7,36.715,36.36,36.45,16650130.0
-2017-11-21,36.75,36.97,36.58,36.65,23986203.0,0.0,1.0,36.75,36.97,36.58,36.65,23986203.0
-2017-11-20,35.93,36.54,35.93,36.5,26376364.0,0.0,1.0,35.93,36.54,35.93,36.5,26376364.0
-2017-11-17,35.9,36.32,35.81,35.9,27106406.0,0.0,1.0,35.9,36.32,35.81,35.9,27106406.0
-2017-11-16,36.04,36.67,35.83,35.88,59861205.0,0.0,1.0,36.04,36.67,35.83,35.88,59861205.0
-2017-11-15,33.97,34.31,33.75,34.11,27797071.0,0.0,1.0,33.97,34.31,33.75,34.11,27797071.0
-2017-11-14,33.86,34.16,33.8,34.04,15540925.0,0.0,1.0,33.86,34.16,33.8,34.04,15540925.0
-2017-11-13,33.86,34.21,33.83,33.95,15608341.0,0.0,1.0,33.86,34.21,33.83,33.95,15608341.0
-2017-11-10,34.06,34.09,33.67,33.99,19003147.0,0.0,1.0,34.06,34.09,33.67,33.99,19003147.0
-2017-11-09,34.29,34.32,33.871,34.05,16266161.0,0.0,1.0,34.29,34.32,33.871,34.05,16266161.0
-2017-11-07,34.32,34.48,34.2147,34.4,10980008.0,0.0,1.0,34.32,34.48,34.2147,34.4,10980008.0
-2017-11-06,34.37,34.56,34.26,34.41,12725467.0,0.0,1.0,34.37,34.56,34.26,34.41,12725467.0
-2017-11-03,34.28,34.49,34.0269,34.47,13293171.0,0.0,1.0,34.28,34.49,34.0269,34.47,13293171.0
-2017-11-02,34.55,34.64,34.16,34.21,19647242.0,0.0,1.0,34.55,34.64,34.16,34.21,19647242.0
-2017-11-01,34.29,34.75,34.28,34.62,21831973.0,0.0,1.0,34.29,34.75,34.28,34.62,21831973.0
-2017-10-31,33.98,34.24,33.96,34.15,13544441.0,0.0,1.0,33.98,34.24,33.96,34.15,13544441.0
-2017-10-30,34.32,34.38,33.8244,34.04,18241531.0,0.0,1.0,34.32,34.38,33.8244,34.04,18241531.0
-2017-10-27,34.15,34.62,34.09,34.43,20237956.0,0.0,1.0,34.15,34.62,34.09,34.43,20237956.0
-2017-10-26,34.41,34.51,34.07,34.27,14541155.0,0.0,1.0,34.41,34.51,34.07,34.27,14541155.0
-2017-10-25,34.73,34.73,34.163,34.3,17012218.0,0.0,1.0,34.73,34.73,34.163,34.3,17012218.0
-2017-10-24,34.4,34.675,34.25,34.58,15273905.0,0.0,1.0,34.4,34.675,34.25,34.58,15273905.0
-2017-10-23,34.45,34.68,34.27,34.35,22490134.0,0.0,1.0,34.45,34.68,34.27,34.35,22490134.0
-2017-10-20,34.02,34.39,34.01,34.25,24055347.0,0.0,1.0,34.02,34.39,34.01,34.25,24055347.0
-2017-10-19,33.51,33.89,33.45,33.75,12928532.0,0.0,1.0,33.51,33.89,33.45,33.75,12928532.0
-2017-10-18,33.72,33.75,33.44,33.55,9739887.0,0.0,1.0,33.72,33.75,33.44,33.55,9739887.0
-2017-10-17,33.59,33.67,33.46,33.6,8633089.0,0.0,1.0,33.59,33.67,33.46,33.6,8633089.0
-2017-10-16,33.6,33.64,33.47,33.54,10469019.0,0.0,1.0,33.6,33.64,33.47,33.54,10469019.0
-2017-10-13,33.4,33.57,33.323,33.47,13451108.0,0.0,1.0,33.4,33.57,33.323,33.47,13451108.0
-2017-10-12,33.26,33.46,33.17,33.26,17811160.0,0.0,1.0,33.26,33.46,33.17,33.26,17811160.0
-2017-10-11,33.38,33.63,33.25,33.59,12353462.0,0.0,1.0,33.38,33.63,33.25,33.59,12353462.0
-2017-10-10,33.88,33.91,33.47,33.55,17978700.0,0.0,1.0,33.88,33.91,33.47,33.55,17978700.0
-2017-10-09,33.77,33.89,33.61,33.76,8684822.0,0.0,1.0,33.77,33.89,33.61,33.76,8684822.0
-2017-10-06,33.65,33.78,33.5247,33.75,13438950.0,0.0,1.0,33.65,33.78,33.5247,33.75,13438950.0
-2017-10-05,33.58,33.67,33.41,33.59,14301206.0,0.0,1.0,33.58,33.67,33.41,33.59,14301206.0
-2017-10-04,33.53,33.56,33.29,33.44,14606016.0,0.29,1.0,33.53,33.56,33.29,33.44,14606016.0
-2017-10-03,33.72,33.9,33.61,33.85,13159079.0,0.0,1.0,33.430085976875,33.608538393122,33.321031722502,33.558968277498,13159079.0
-2017-10-02,33.61,33.77,33.52,33.75,16443224.0,0.0,1.0,33.321031722502,33.479656092499,33.231805514379,33.45982804625,16443224.0
-2017-09-29,33.31,33.67,33.24,33.63,14419404.0,0.0,1.0,33.023611028758,33.380515861251,32.954212866884,33.340859768752,14419404.0
-2017-09-28,33.22,33.46,33.22,33.35,14689819.0,0.0,1.0,32.934384820634,33.17232137563,32.934384820634,33.063267121257,14689819.0
-2017-09-27,33.78,33.92,33.3037,33.48,21687593.0,0.0,1.0,33.489570115624,33.628366439371,33.017365194189,33.19214942188,21687593.0
-2017-09-26,33.76,34.1,33.67,33.76,25835270.0,0.0,1.0,33.469742069374,33.806818855618,33.380515861251,33.469742069374,25835270.0
-2017-09-25,33.31,33.84,33.2,33.72,30475969.0,0.0,1.0,33.023611028758,33.549054254373,32.914556774385,33.430085976875,30475969.0
-2017-09-22,32.66,33.53,32.64,33.37,27904695.0,0.0,1.0,32.379199525645,33.241719537504,32.359371479395,33.083095167507,27904695.0
-2017-09-21,32.72,32.9,32.5,32.7,19762651.0,0.0,1.0,32.438683664394,32.61713608064,32.220575155648,32.418855618144,19762651.0
-2017-09-20,32.55,32.75,32.39,32.6,18701702.0,0.0,1.0,32.270145271272,32.468425733768,32.111520901275,32.319715386896,18701702.0
-2017-09-19,32.46,32.65,32.395,32.49,12424056.0,0.0,1.0,32.180919063149,32.36928550252,32.116477912837,32.210661132523,12424056.0
-2017-09-18,32.43,32.66,32.26,32.52,17035443.0,0.0,1.0,32.151176993774,32.379199525645,31.982638600652,32.240403201897,17035443.0
-2017-09-15,32.2,32.5,32.12,32.44,27708447.0,0.0,1.0,31.923154461903,32.220575155648,31.843842276905,32.161091016899,27708447.0
-2017-09-14,31.91,32.22,31.91,32.19,17711003.0,0.0,1.0,31.635647791284,31.942982508153,31.635647791284,31.913240438779,17711003.0
-2017-09-13,32.34,32.39,31.96,32.18,21872095.0,0.0,1.0,32.061950785651,32.111520901275,31.685217906908,31.903326415654,21872095.0
-2017-09-12,32.3,32.47,32.19,32.41,18510454.0,0.0,1.0,32.022294693151,32.190833086273,31.913240438779,32.131348947524,18510454.0
-2017-09-11,31.71,32.3,31.67,32.205,21365590.0,0.0,1.0,31.437367328787,32.022294693151,31.397711236288,31.928111473466,21365590.0
-2017-09-08,31.68,31.78,31.46,31.48,15115756.0,0.0,1.0,31.407625259413,31.506765490661,31.189516750667,31.209344796917,15115756.0
-2017-09-07,31.96,31.97,31.74,31.76,14611809.0,0.0,1.0,31.685217906908,31.695131930033,31.467109398162,31.486937444412,14611809.0
-2017-09-06,31.75,31.91,31.63,31.87,16380030.0,0.0,1.0,31.477023421287,31.635647791284,31.358055143789,31.595991698784,16380030.0
-2017-09-05,32.15,32.245,31.455,31.62,24327663.0,0.0,1.0,31.873584346279,31.967767565965,31.184559739105,31.348141120664,24327663.0
-2017-09-01,32.22,32.345,32.03,32.32,14661162.0,0.0,1.0,31.942982508153,32.066907797213,31.754616068782,32.042122739401,14661162.0
-2017-08-31,32.1,32.34,31.99,32.21,27138172.0,0.0,1.0,31.824014230655,32.061950785651,31.714959976282,31.933068485028,27138172.0
-2017-08-30,31.47,32.2,31.42,31.99,23028578.0,0.0,1.0,31.199430773792,31.923154461903,31.149860658168,31.714959976282,23028578.0
-2017-08-29,31.26,31.6299,31.19,31.48,16192694.0,0.0,1.0,30.991236288171,31.357956003558,30.921838126297,31.209344796917,16192694.0
-2017-08-28,31.6,31.66,31.41,31.54,12747867.0,0.0,1.0,31.328313074414,31.387797213163,31.139946635043,31.268828935666,12747867.0
-2017-08-25,31.39,31.8,31.36,31.44,19351094.0,0.0,1.0,31.120118588793,31.526593536911,31.090376519419,31.169688704417,19351094.0
-2017-08-24,30.95,31.4,30.9,31.24,21867401.0,0.0,1.0,30.683901571302,31.130032611918,30.634331455677,30.971408241921,21867401.0
-2017-08-23,31.21,31.4,30.91,30.92,22269978.0,0.0,1.0,30.941666172547,31.130032611918,30.644245478802,30.654159501927,22269978.0
-2017-08-22,30.85,31.33,30.75,31.27,24438367.0,0.0,1.0,30.584761340053,31.060634450044,30.485621108805,31.001150311296,24438367.0
-2017-08-21,30.37,30.795,30.36,30.68,24025228.0,0.0,1.0,30.108888230062,30.530234212867,30.098974206937,30.416222946932,24025228.0
-2017-08-18,31.0,31.06,30.36,30.37,34622147.0,0.0,1.0,30.733471686926,30.792955825674,30.098974206937,30.108888230062,34622147.0
-2017-08-17,31.49,31.77,30.85,31.04,51557052.0,0.0,1.0,31.219258820042,31.496851467536,30.584761340053,30.773127779425,51557052.0
-2017-08-16,32.1,32.4652,32.06,32.34,27088237.0,0.0,1.0,31.824014230655,32.186074355173,31.784358138156,32.061950785651,27088237.0
-2017-08-15,31.85,32.21,31.84,32.09,24406258.0,0.0,1.0,31.576163652535,31.933068485028,31.56624962941,31.81410020753,24406258.0
-2017-08-14,31.69,31.89,31.56,31.84,21605411.0,0.0,1.0,31.417539282538,31.615819745034,31.288656981915,31.56624962941,21605411.0
-2017-08-11,31.23,31.545,31.04,31.47,20521935.0,0.0,1.0,30.961494218796,31.273785947228,30.773127779425,31.199430773792,20521935.0
-2017-08-10,31.56,31.56,31.0,31.0,22748854.0,0.0,1.0,31.288656981915,31.288656981915,30.733471686926,30.733471686926,22748854.0
-2017-08-09,31.55,31.675,31.36,31.62,15931711.0,0.0,1.0,31.27874295879,31.402668247851,31.090376519419,31.348141120664,15931711.0
-2017-08-08,31.75,32.0,31.6,31.67,13632423.0,0.0,1.0,31.477023421287,31.724873999407,31.328313074414,31.397711236288,13632423.0
-2017-08-07,31.79,31.8799,31.69,31.84,11730203.0,0.0,1.0,31.516679513786,31.605806581678,31.417539282538,31.56624962941,11730203.0
-2017-08-04,31.67,31.91,31.58,31.8,16322686.0,0.0,1.0,31.397711236288,31.635647791284,31.308485028165,31.526593536911,16322686.0
-2017-08-03,31.59,31.72,31.43,31.56,13884046.0,0.0,1.0,31.31839905129,31.447281351912,31.159774681293,31.288656981915,13884046.0
-2017-08-02,31.57,31.57,31.25,31.52,15797711.0,0.0,1.0,31.29857100504,31.29857100504,30.981322265046,31.249000889416,15797711.0
-2017-08-01,31.59,31.66,31.43,31.65,12727298.0,0.0,1.0,31.31839905129,31.387797213163,31.159774681293,31.377883190039,12727298.0
-2017-07-31,31.54,31.59,31.37,31.45,18534978.0,0.0,1.0,31.268828935666,31.31839905129,31.100290542544,31.179602727542,18534978.0
-2017-07-28,31.45,31.6,31.26,31.52,15509841.0,0.0,1.0,31.179602727542,31.328313074414,30.991236288171,31.249000889416,15509841.0
-2017-07-27,31.73,31.7502,31.21,31.57,21224338.0,0.0,1.0,31.457195375037,31.477221701749,30.941666172547,31.29857100504,21224338.0
-2017-07-26,32.12,32.225,31.51,31.66,21472799.0,0.0,1.0,31.843842276905,31.947939519715,31.239086866291,31.387797213163,21472799.0
-2017-07-25,31.9,32.25,31.88,32.12,14848920.0,0.0,1.0,31.625733768159,31.972724577527,31.605905721909,31.843842276905,14848920.0
-2017-07-24,31.86,31.925,31.66,31.86,15232167.0,0.0,1.0,31.58607767566,31.650518825971,31.387797213163,31.58607767566,15232167.0
-2017-07-21,31.86,32.03,31.705,31.84,13271427.0,0.0,1.0,31.58607767566,31.754616068782,31.432410317225,31.56624962941,13271427.0
-2017-07-20,31.91,32.05,31.76,31.86,15917114.0,0.0,1.0,31.635647791284,31.774444115031,31.486937444412,31.58607767566,15917114.0
-2017-07-19,31.51,32.05,31.46,31.9,21369697.0,0.0,1.0,31.239086866291,31.774444115031,31.189516750667,31.625733768159,21369697.0
-2017-07-18,31.41,31.51,31.17,31.51,15366450.0,0.0,1.0,31.139946635043,31.239086866291,30.902010080047,31.239086866291,15366450.0
-2017-07-17,31.5,31.635,31.45,31.5,16012951.0,0.0,1.0,31.229172843166,31.363012155351,31.179602727542,31.229172843166,16012951.0
-2017-07-14,31.37,31.45,31.27,31.42,13261554.0,0.0,1.0,31.100290542544,31.179602727542,31.001150311296,31.149860658168,13261554.0
-2017-07-13,31.26,31.28,31.08,31.27,15870454.0,0.0,1.0,30.991236288171,31.01106433442,30.812783871924,31.001150311296,15870454.0
-2017-07-12,31.25,31.44,31.145,31.16,18428809.0,0.0,1.0,30.981322265046,31.169688704417,30.877225022235,30.892096056923,18428809.0
-2017-07-11,31.05,31.12,30.86,31.09,12253478.0,0.0,1.0,30.78304180255,30.852439964423,30.594675363178,30.822697895049,12253478.0
-2017-07-10,30.88,31.09,30.82,30.98,15193572.0,0.0,1.0,30.614503409428,30.822697895049,30.555019270679,30.713643640676,15193572.0
-2017-07-07,30.76,31.07,30.75,30.9,15221015.0,0.0,1.0,30.49553513193,30.802869848799,30.485621108805,30.634331455677,15221015.0
-2017-07-06,30.99,31.02,30.67,30.725,20456451.0,0.0,1.0,30.723557663801,30.753299733175,30.406308923807,30.460836050993,20456451.0
-2017-07-05,30.85,31.27,30.73,31.11,23391894.0,0.29,1.0,30.584761340053,31.001150311296,30.465793062556,30.842525941299,23391894.0
-2017-07-03,31.09,31.64,31.03,31.33,14111474.0,0.0,1.0,30.538029666082,31.078264993079,30.479094903137,30.773768717863,14111474.0
-2017-06-30,31.79,31.79,31.3,31.3,22981379.0,0.0,1.0,31.225601900442,31.225601900442,30.74430133639,30.74430133639,22981379.0
-2017-06-29,31.79,32.025,31.25,31.41,26891695.0,0.0,1.0,31.225601900442,31.456429721977,30.695189033936,30.852348401789,26891695.0
-2017-06-28,31.78,32.275,31.76,32.08,17587686.0,0.0,1.0,31.215779439951,31.701991234249,31.196134518969,31.510453254677,17587686.0
-2017-06-27,32.09,32.26,31.76,31.76,23092594.0,0.0,1.0,31.520275715168,31.687257543512,31.196134518969,31.196134518969,23092594.0
-2017-06-26,32.22,32.5,32.18,32.24,21409287.0,0.0,1.0,31.647967701549,31.922996595293,31.608677859586,31.667612622531,21409287.0
-2017-06-23,31.85,32.3,31.75,32.1,23006424.0,0.0,1.0,31.284536663387,31.726547385476,31.186312058479,31.530098175659,23006424.0
-2017-06-22,31.91,32.0,31.7,31.85,19194637.0,0.0,1.0,31.343471426332,31.43187357075,31.137199756024,31.284536663387,19194637.0
-2017-06-21,31.73,31.87,31.51,31.84,20103067.0,0.0,1.0,31.166667137497,31.304181584369,30.950573006698,31.274714202896,20103067.0
-2017-06-20,31.94,32.16,31.84,31.85,17859664.0,0.0,1.0,31.372938807805,31.589032938604,31.274714202896,31.284536663387,17859664.0
-2017-06-19,31.77,32.02,31.581,31.99,16753701.0,0.0,1.0,31.20595697946,31.451518491732,31.020312476183,31.422051110259,16753701.0
-2017-06-16,31.61,31.64,31.2,31.6201,33785850.0,0.0,1.0,31.048797611607,31.078264993079,30.646076731481,31.058718296702,33785850.0
-2017-06-15,31.25,31.64,31.22,31.5801,19110962.0,0.0,1.0,30.695189033936,31.078264993079,30.665721652463,31.019428454739,19110962.0
-2017-06-14,31.87,31.97,31.33,31.6,24850713.0,0.0,1.0,31.304181584369,31.402406189278,30.773768717863,31.038975151116,24850713.0
-2017-06-13,31.3,31.8,31.28,31.7,27251001.0,0.0,1.0,30.74430133639,31.235424360933,30.724656415408,31.137199756024,27251001.0
-2017-06-12,31.34,31.64,31.15,31.245,24330382.0,0.0,1.0,30.783591178353,31.078264993079,30.596964429027,30.69027780369,24330382.0
-2017-06-09,31.64,31.83,31.085,31.37,25031675.0,0.0,1.0,31.078264993079,31.264891742406,30.533118435836,30.813058559826,25031675.0
-2017-06-08,31.53,31.81,31.52,31.615,19877271.0,0.0,1.0,30.97021792768,31.245246821424,30.960395467189,31.053708841852,19877271.0
-2017-06-07,31.61,31.72,31.44,31.61,14417549.0,0.0,1.0,31.048797611607,31.156844677006,30.881815783262,31.048797611607,14417549.0
-2017-06-06,31.75,31.76,31.5,31.56,15987734.0,0.0,1.0,31.186312058479,31.196134518969,30.940750546207,30.999685309152,15987734.0
-2017-06-05,32.05,32.05,31.57,31.76,15581429.0,0.0,1.0,31.480985873204,31.480985873204,31.009507769643,31.196134518969,15581429.0
-2017-06-02,31.93,32.06,31.68,31.98,19978713.0,0.0,1.0,31.363116347314,31.490808333695,31.117554835043,31.412228649768,19978713.0
-2017-06-01,31.52,31.82,31.47,31.82,15397418.0,0.0,1.0,30.960395467189,31.255069281915,30.911283164735,31.255069281915,15397418.0
diff --git a/examples/quick/demos/stocqt/content/data/EA.csv b/examples/quick/demos/stocqt/content/data/EA.csv
deleted file mode 100644
index ad6a60fc7b..0000000000
--- a/examples/quick/demos/stocqt/content/data/EA.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,105.29,105.68,104.39,105.06,2033331.0,0.0,1.0,105.29,105.68,104.39,105.06,2033331.0
-2017-12-28,105.29,105.55,104.55,105.31,1431096.0,0.0,1.0,105.29,105.55,104.55,105.31,1431096.0
-2017-12-27,105.4,106.44,104.58,105.23,2427713.0,0.0,1.0,105.4,106.44,104.58,105.23,2427713.0
-2017-12-26,105.66,106.02,104.65,105.06,1685265.0,0.0,1.0,105.66,106.02,104.65,105.06,1685265.0
-2017-12-22,108.31,108.31,105.675,106.02,2401349.0,0.0,1.0,108.31,108.31,105.675,106.02,2401349.0
-2017-12-21,107.88,108.735,107.78,107.97,2784216.0,0.0,1.0,107.88,108.735,107.78,107.97,2784216.0
-2017-12-20,107.5,108.87,107.15,108.45,2642416.0,0.0,1.0,107.5,108.87,107.15,108.45,2642416.0
-2017-12-19,107.42,107.7558,106.69,107.0,1985332.0,0.0,1.0,107.42,107.7558,106.69,107.0,1985332.0
-2017-12-18,109.89,110.0,106.56,107.34,4241871.0,0.0,1.0,109.89,110.0,106.56,107.34,4241871.0
-2017-12-15,107.77,109.68,106.63,109.28,5755867.0,0.0,1.0,107.77,109.68,106.63,109.28,5755867.0
-2017-12-14,105.2,107.62,104.7,106.42,2580582.0,0.0,1.0,105.2,107.62,104.7,106.42,2580582.0
-2017-12-13,107.71,108.31,105.22,105.54,3730504.0,0.0,1.0,107.71,108.31,105.22,105.54,3730504.0
-2017-12-12,108.0,108.92,107.02,107.66,3512468.0,0.0,1.0,108.0,108.92,107.02,107.66,3512468.0
-2017-12-11,105.61,108.16,105.0,107.92,3271833.0,0.0,1.0,105.61,108.16,105.0,107.92,3271833.0
-2017-12-08,104.49,106.4,104.42,105.27,3194502.0,0.0,1.0,104.49,106.4,104.42,105.27,3194502.0
-2017-12-07,103.23,105.6,102.75,104.37,3486643.0,0.0,1.0,103.23,105.6,102.75,104.37,3486643.0
-2017-12-06,102.96,103.92,100.41,103.18,4441608.0,0.0,1.0,102.96,103.92,100.41,103.18,4441608.0
-2017-12-05,100.55,105.1926,99.63,103.38,4454836.0,0.0,1.0,100.55,105.1926,99.63,103.38,4454836.0
-2017-12-04,105.53,105.875,100.68,100.83,6476227.0,0.0,1.0,105.53,105.875,100.68,100.83,6476227.0
-2017-12-01,105.86,106.87,103.95,106.02,3810130.0,0.0,1.0,105.86,106.87,103.95,106.02,3810130.0
-2017-11-30,106.11,106.5,105.06,106.35,5338599.0,0.0,1.0,106.11,106.5,105.06,106.35,5338599.0
-2017-11-29,109.21,109.39,104.95,105.49,5484734.0,0.0,1.0,109.21,109.39,104.95,105.49,5484734.0
-2017-11-28,106.99,110.52,106.74,109.47,5362601.0,0.0,1.0,106.99,110.52,106.74,109.47,5362601.0
-2017-11-27,107.86,108.285,106.79,106.99,2398540.0,0.0,1.0,107.86,108.285,106.79,106.99,2398540.0
-2017-11-24,107.66,108.58,107.59,107.94,1306290.0,0.0,1.0,107.66,108.58,107.59,107.94,1306290.0
-2017-11-22,108.04,108.44,106.61,107.32,2512190.0,0.0,1.0,108.04,108.44,106.61,107.32,2512190.0
-2017-11-21,107.78,108.7699,107.54,107.71,3089096.0,0.0,1.0,107.78,108.7699,107.54,107.71,3089096.0
-2017-11-20,108.28,108.45,106.75,107.64,5948591.0,0.0,1.0,108.28,108.45,106.75,107.64,5948591.0
-2017-11-17,108.99,109.55,107.5,108.82,8476713.0,0.0,1.0,108.99,109.55,107.5,108.82,8476713.0
-2017-11-16,111.85,113.13,111.21,111.6,2308873.0,0.0,1.0,111.85,113.13,111.21,111.6,2308873.0
-2017-11-15,112.72,112.87,110.52,111.48,2483272.0,0.0,1.0,112.72,112.87,110.52,111.48,2483272.0
-2017-11-14,110.6,113.9,110.39,112.27,3554816.0,0.0,1.0,110.6,113.9,110.39,112.27,3554816.0
-2017-11-13,112.0,113.24,111.19,112.01,3157879.0,0.0,1.0,112.0,113.24,111.19,112.01,3157879.0
-2017-11-10,111.26,112.83,110.82,112.75,2515313.0,0.0,1.0,111.26,112.83,110.82,112.75,2515313.0
-2017-11-09,112.99,113.3,110.94,111.89,3331403.0,0.0,1.0,112.99,113.3,110.94,111.89,3331403.0
-2017-11-07,112.29,112.72,110.08,111.7,2671700.0,0.0,1.0,112.29,112.72,110.08,111.7,2671700.0
-2017-11-06,112.99,113.5,110.76,112.46,3571671.0,0.0,1.0,112.99,113.5,110.76,112.46,3571671.0
-2017-11-03,113.47,113.76,112.57,113.2,2859092.0,0.0,1.0,113.47,113.76,112.57,113.2,2859092.0
-2017-11-02,114.35,114.52,112.6,112.69,3405672.0,0.0,1.0,114.35,114.52,112.6,112.69,3405672.0
-2017-11-01,116.0,116.6,111.28,114.47,9639100.0,0.0,1.0,116.0,116.6,111.28,114.47,9639100.0
-2017-10-31,118.125,119.84,116.37,119.6,4762517.0,0.0,1.0,118.125,119.84,116.37,119.6,4762517.0
-2017-10-30,117.13,117.77,116.64,117.58,2599653.0,0.0,1.0,117.13,117.77,116.64,117.58,2599653.0
-2017-10-27,116.83,117.55,115.41,116.89,2883562.0,0.0,1.0,116.83,117.55,115.41,116.89,2883562.0
-2017-10-26,115.07,117.06,115.02,115.83,2443955.0,0.0,1.0,115.07,117.06,115.02,115.83,2443955.0
-2017-10-25,113.2,114.88,112.59,114.56,2963441.0,0.0,1.0,113.2,114.88,112.59,114.56,2963441.0
-2017-10-24,113.68,114.72,112.763,113.39,1847039.0,0.0,1.0,113.68,114.72,112.763,113.39,1847039.0
-2017-10-23,113.81,114.43,112.73,113.68,2060904.0,0.0,1.0,113.81,114.43,112.73,113.68,2060904.0
-2017-10-20,113.6,114.28,113.15,113.62,1921562.0,0.0,1.0,113.6,114.28,113.15,113.62,1921562.0
-2017-10-19,112.0,113.08,111.12,113.07,3023265.0,0.0,1.0,112.0,113.08,111.12,113.07,3023265.0
-2017-10-18,113.41,113.75,110.31,113.16,9671971.0,0.0,1.0,113.41,113.75,110.31,113.16,9671971.0
-2017-10-17,117.2,118.15,115.63,115.98,3116041.0,0.0,1.0,117.2,118.15,115.63,115.98,3116041.0
-2017-10-16,118.81,119.0,117.05,117.48,2581184.0,0.0,1.0,118.81,119.0,117.05,117.48,2581184.0
-2017-10-13,117.76,118.92,117.55,118.62,1883150.0,0.0,1.0,117.76,118.92,117.55,118.62,1883150.0
-2017-10-12,115.97,117.78,115.7701,117.14,2031131.0,0.0,1.0,115.97,117.78,115.7701,117.14,2031131.0
-2017-10-11,117.33,118.0,115.52,116.05,2917782.0,0.0,1.0,117.33,118.0,115.52,116.05,2917782.0
-2017-10-10,119.03,119.49,116.71,117.82,1511975.0,0.0,1.0,119.03,119.49,116.71,117.82,1511975.0
-2017-10-09,119.24,119.3,117.67,118.62,1513237.0,0.0,1.0,119.24,119.3,117.67,118.62,1513237.0
-2017-10-06,119.03,120.29,118.44,120.09,1503375.0,0.0,1.0,119.03,120.29,118.44,120.09,1503375.0
-2017-10-05,118.63,119.75,117.93,119.52,1430493.0,0.0,1.0,118.63,119.75,117.93,119.52,1430493.0
-2017-10-04,117.52,118.75,116.41,118.56,1587004.0,0.0,1.0,117.52,118.75,116.41,118.56,1587004.0
-2017-10-03,117.92,118.1,116.76,117.96,1227392.0,0.0,1.0,117.92,118.1,116.76,117.96,1227392.0
-2017-10-02,118.89,119.72,116.94,117.95,1822193.0,0.0,1.0,118.89,119.72,116.94,117.95,1822193.0
-2017-09-29,116.71,118.17,116.3,118.06,1730832.0,0.0,1.0,116.71,118.17,116.3,118.06,1730832.0
-2017-09-28,115.82,116.79,115.24,116.61,1395076.0,0.0,1.0,115.82,116.79,115.24,116.61,1395076.0
-2017-09-27,115.4,116.65,115.4,115.97,1728987.0,0.0,1.0,115.4,116.65,115.4,115.97,1728987.0
-2017-09-26,114.5,114.67,112.833,113.92,2886349.0,0.0,1.0,114.5,114.67,112.833,113.92,2886349.0
-2017-09-25,118.05,118.29,112.85,114.2,4019941.0,0.0,1.0,118.05,118.29,112.85,114.2,4019941.0
-2017-09-22,117.46,120.18,117.15,118.5,2074145.0,0.0,1.0,117.46,120.18,117.15,118.5,2074145.0
-2017-09-21,120.49,120.49,117.82,118.02,1857324.0,0.0,1.0,120.49,120.49,117.82,118.02,1857324.0
-2017-09-20,120.77,121.4,118.74,120.34,2290740.0,0.0,1.0,120.77,121.4,118.74,120.34,2290740.0
-2017-09-19,120.25,121.2,119.37,120.21,2147853.0,0.0,1.0,120.25,121.2,119.37,120.21,2147853.0
-2017-09-18,119.5,120.87,119.5,119.96,2562195.0,0.0,1.0,119.5,120.87,119.5,119.96,2562195.0
-2017-09-15,119.29,119.915,117.75,119.42,3161686.0,0.0,1.0,119.29,119.915,117.75,119.42,3161686.0
-2017-09-14,118.74,119.66,117.71,119.19,2453409.0,0.0,1.0,118.74,119.66,117.71,119.19,2453409.0
-2017-09-13,119.86,120.45,119.0,119.6,2468517.0,0.0,1.0,119.86,120.45,119.0,119.6,2468517.0
-2017-09-12,121.61,122.125,118.675,120.41,2568453.0,0.0,1.0,121.61,122.125,118.675,120.41,2568453.0
-2017-09-11,119.88,121.35,119.28,121.19,2184608.0,0.0,1.0,119.88,121.35,119.28,121.19,2184608.0
-2017-09-08,119.99,120.16,117.71,118.28,2334882.0,0.0,1.0,119.99,120.16,117.71,118.28,2334882.0
-2017-09-07,117.2,119.1,116.59,118.93,1717120.0,0.0,1.0,117.2,119.1,116.59,118.93,1717120.0
-2017-09-06,118.77,119.15,116.47,117.0,1711537.0,0.0,1.0,118.77,119.15,116.47,117.0,1711537.0
-2017-09-05,118.8,119.3,116.32,118.21,2269814.0,0.0,1.0,118.8,119.3,116.32,118.21,2269814.0
-2017-09-01,121.27,121.77,118.51,119.31,2696421.0,0.0,1.0,121.27,121.77,118.51,119.31,2696421.0
-2017-08-31,122.0,122.79,120.94,121.5,2580446.0,0.0,1.0,122.0,122.79,120.94,121.5,2580446.0
-2017-08-30,119.42,122.08,119.065,121.97,2097613.0,0.0,1.0,119.42,122.08,119.065,121.97,2097613.0
-2017-08-29,117.47,119.43,117.2201,119.23,1223068.0,0.0,1.0,117.47,119.43,117.2201,119.23,1223068.0
-2017-08-28,117.52,119.04,116.95,118.73,1756217.0,0.0,1.0,117.52,119.04,116.95,118.73,1756217.0
-2017-08-25,118.19,118.71,115.71,116.93,2155476.0,0.0,1.0,118.19,118.71,115.71,116.93,2155476.0
-2017-08-24,118.49,118.92,116.0,117.82,1303354.0,0.0,1.0,118.49,118.92,116.0,117.82,1303354.0
-2017-08-23,118.65,119.37,117.55,118.18,1235965.0,0.0,1.0,118.65,119.37,117.55,118.18,1235965.0
-2017-08-22,117.28,120.45,117.22,119.03,2476188.0,0.0,1.0,117.28,120.45,117.22,119.03,2476188.0
-2017-08-21,116.85,117.4,116.12,116.84,1479440.0,0.0,1.0,116.85,117.4,116.12,116.84,1479440.0
-2017-08-18,116.0,117.84,115.46,116.88,1906661.0,0.0,1.0,116.0,117.84,115.46,116.88,1906661.0
-2017-08-17,119.19,119.4745,116.46,116.47,1755405.0,0.0,1.0,119.19,119.4745,116.46,116.47,1755405.0
-2017-08-16,117.49,119.59,117.03,119.25,2039136.0,0.0,1.0,117.49,119.59,117.03,119.25,2039136.0
-2017-08-15,117.23,117.62,116.58,117.43,1036988.0,0.0,1.0,117.23,117.62,116.58,117.43,1036988.0
-2017-08-14,116.71,118.0,116.4,117.11,2858947.0,0.0,1.0,116.71,118.0,116.4,117.11,2858947.0
-2017-08-11,113.74,115.98,113.51,115.45,1541337.0,0.0,1.0,113.74,115.98,113.51,115.45,1541337.0
-2017-08-10,115.41,115.715,113.69,113.99,2591680.0,0.0,1.0,115.41,115.715,113.69,113.99,2591680.0
-2017-08-09,115.55,116.84,114.75,116.11,1572284.0,0.0,1.0,115.55,116.84,114.75,116.11,1572284.0
-2017-08-08,116.5,117.13,116.02,116.5,1298672.0,0.0,1.0,116.5,117.13,116.02,116.5,1298672.0
-2017-08-07,117.6,117.96,116.49,116.96,1878689.0,0.0,1.0,117.6,117.96,116.49,116.96,1878689.0
-2017-08-04,119.15,119.18,116.9,117.22,2329950.0,0.0,1.0,119.15,119.18,116.9,117.22,2329950.0
-2017-08-03,117.38,119.23,116.98,118.85,2807213.0,0.0,1.0,117.38,119.23,116.98,118.85,2807213.0
-2017-08-02,117.11,117.42,113.83,116.83,3035692.0,0.0,1.0,117.11,117.42,113.83,116.83,3035692.0
-2017-08-01,117.57,117.65,116.44,116.92,2434299.0,0.0,1.0,117.57,117.65,116.44,116.92,2434299.0
-2017-07-31,119.05,119.25,116.5,116.74,2874265.0,0.0,1.0,119.05,119.25,116.5,116.74,2874265.0
-2017-07-28,114.0,118.75,113.5,118.25,4996998.0,0.0,1.0,114.0,118.75,113.5,118.25,4996998.0
-2017-07-27,119.01,120.25,116.06,117.6,8804997.0,0.0,1.0,119.01,120.25,116.06,117.6,8804997.0
-2017-07-26,115.46,118.11,115.19,118.0,4476211.0,0.0,1.0,115.46,118.11,115.19,118.0,4476211.0
-2017-07-25,113.97,114.52,113.31,113.66,2731441.0,0.0,1.0,113.97,114.52,113.31,113.66,2731441.0
-2017-07-24,112.22,113.97,112.22,113.75,2719644.0,0.0,1.0,112.22,113.97,112.22,113.75,2719644.0
-2017-07-21,111.5,112.91,111.27,112.22,2412908.0,0.0,1.0,111.5,112.91,111.27,112.22,2412908.0
-2017-07-20,111.61,112.18,110.38,111.97,2137684.0,0.0,1.0,111.61,112.18,110.38,111.97,2137684.0
-2017-07-19,110.43,111.65,109.81,111.58,2306302.0,0.0,1.0,110.43,111.65,109.81,111.58,2306302.0
-2017-07-18,110.0,110.93,109.48,110.28,1902014.0,0.0,1.0,110.0,110.93,109.48,110.28,1902014.0
-2017-07-17,109.02,110.43,108.715,109.44,1600888.0,0.0,1.0,109.02,110.43,108.715,109.44,1600888.0
-2017-07-14,109.61,110.34,108.75,108.99,1319830.0,0.0,1.0,109.61,110.34,108.75,108.99,1319830.0
-2017-07-13,110.83,111.61,108.92,108.98,1705243.0,0.0,1.0,110.83,111.61,108.92,108.98,1705243.0
-2017-07-12,109.5,110.9,109.05,110.68,1929711.0,0.0,1.0,109.5,110.9,109.05,110.68,1929711.0
-2017-07-11,107.63,109.71,107.1001,108.42,2254636.0,0.0,1.0,107.63,109.71,107.1001,108.42,2254636.0
-2017-07-10,107.84,108.69,107.01,107.84,1829832.0,0.0,1.0,107.84,108.69,107.01,107.84,1829832.0
-2017-07-07,106.28,108.47,105.54,107.45,2113210.0,0.0,1.0,106.28,108.47,105.54,107.45,2113210.0
-2017-07-06,106.06,107.12,105.5,105.75,2418406.0,0.0,1.0,106.06,107.12,105.5,105.75,2418406.0
-2017-07-05,105.95,107.31,105.35,106.76,2790438.0,0.0,1.0,105.95,107.31,105.35,106.76,2790438.0
-2017-07-03,106.51,107.0,105.21,105.42,1656433.0,0.0,1.0,106.51,107.0,105.21,105.42,1656433.0
-2017-06-30,107.1,107.56,105.65,105.72,3193822.0,0.0,1.0,107.1,107.56,105.65,105.72,3193822.0
-2017-06-29,108.16,108.72,105.47,106.68,3801546.0,0.0,1.0,108.16,108.72,105.47,106.68,3801546.0
-2017-06-28,108.7,109.2,106.74,108.81,3666366.0,0.0,1.0,108.7,109.2,106.74,108.81,3666366.0
-2017-06-27,111.35,111.93,108.13,108.32,3051541.0,0.0,1.0,111.35,111.93,108.13,108.32,3051541.0
-2017-06-26,111.0,112.64,110.375,111.86,2433287.0,0.0,1.0,111.0,112.64,110.375,111.86,2433287.0
-2017-06-23,112.51,112.95,110.77,110.83,5488299.0,0.0,1.0,112.51,112.95,110.77,110.83,5488299.0
-2017-06-22,113.51,113.52,111.36,112.62,2233674.0,0.0,1.0,113.51,113.52,111.36,112.62,2233674.0
-2017-06-21,114.33,114.69,111.83,113.17,3048981.0,0.0,1.0,114.33,114.69,111.83,113.17,3048981.0
-2017-06-20,113.43,115.12,113.29,113.47,2694325.0,0.0,1.0,113.43,115.12,113.29,113.47,2694325.0
-2017-06-19,111.18,113.86,111.18,113.65,2863975.0,0.0,1.0,111.18,113.86,111.18,113.65,2863975.0
-2017-06-16,110.72,112.51,110.07,110.51,9457081.0,0.0,1.0,110.72,112.51,110.07,110.51,9457081.0
-2017-06-15,108.24,111.03,107.32,110.53,3062302.0,0.0,1.0,108.24,111.03,107.32,110.53,3062302.0
-2017-06-14,110.16,111.11,108.68,110.02,2161626.0,0.0,1.0,110.16,111.11,108.68,110.02,2161626.0
-2017-06-13,110.33,110.96,108.08,109.98,2727219.0,0.0,1.0,110.33,110.96,108.08,109.98,2727219.0
-2017-06-12,109.3,111.175,105.54,108.9,5802602.0,0.0,1.0,109.3,111.175,105.54,108.9,5802602.0
-2017-06-09,114.84,115.36,107.03,110.46,5712259.0,0.0,1.0,114.84,115.36,107.03,110.46,5712259.0
-2017-06-08,116.04,116.04,113.24,114.29,3268285.0,0.0,1.0,116.04,116.04,113.24,114.29,3268285.0
-2017-06-07,114.84,115.54,114.23,115.37,2466012.0,0.0,1.0,114.84,115.54,114.23,115.37,2466012.0
-2017-06-06,114.54,115.39,113.59,113.69,2492255.0,0.0,1.0,114.54,115.39,113.59,113.69,2492255.0
-2017-06-05,114.68,115.13,114.19,114.69,1858473.0,0.0,1.0,114.68,115.13,114.19,114.69,1858473.0
-2017-06-02,113.85,114.54,113.2,114.52,1867350.0,0.0,1.0,113.85,114.54,113.2,114.52,1867350.0
-2017-06-01,113.96,114.94,113.175,113.87,2226980.0,0.0,1.0,113.96,114.94,113.175,113.87,2226980.0
diff --git a/examples/quick/demos/stocqt/content/data/EBAY.csv b/examples/quick/demos/stocqt/content/data/EBAY.csv
deleted file mode 100644
index 9254489791..0000000000
--- a/examples/quick/demos/stocqt/content/data/EBAY.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,37.82,38.03,37.65,37.74,4476821.0,0.0,1.0,37.82,38.03,37.65,37.74,4476821.0
-2017-12-28,37.46,37.93,37.4501,37.92,3379374.0,0.0,1.0,37.46,37.93,37.4501,37.92,3379374.0
-2017-12-27,38.07,38.08,37.56,37.61,4091574.0,0.0,1.0,38.07,38.08,37.56,37.61,4091574.0
-2017-12-26,37.79,38.01,37.605,37.94,4493535.0,0.0,1.0,37.79,38.01,37.605,37.94,4493535.0
-2017-12-22,37.69,37.905,37.53,37.76,7145144.0,0.0,1.0,37.69,37.905,37.53,37.76,7145144.0
-2017-12-21,38.11,38.24,37.77,37.81,9594664.0,0.0,1.0,38.11,38.24,37.77,37.81,9594664.0
-2017-12-20,37.87,38.1,37.745,37.93,6480341.0,0.0,1.0,37.87,38.1,37.745,37.93,6480341.0
-2017-12-19,38.15,38.23,37.72,37.82,7711342.0,0.0,1.0,38.15,38.23,37.72,37.82,7711342.0
-2017-12-18,38.5,38.66,38.12,38.18,7566184.0,0.0,1.0,38.5,38.66,38.12,38.18,7566184.0
-2017-12-15,37.72,38.42,37.39,38.37,12791334.0,0.0,1.0,37.72,38.42,37.39,38.37,12791334.0
-2017-12-14,37.41,37.77,37.41,37.6,5346581.0,0.0,1.0,37.41,37.77,37.41,37.6,5346581.0
-2017-12-13,37.46,37.64,37.33,37.4,5742256.0,0.0,1.0,37.46,37.64,37.33,37.4,5742256.0
-2017-12-12,37.44,37.49,37.1,37.44,6223963.0,0.0,1.0,37.44,37.49,37.1,37.44,6223963.0
-2017-12-11,37.51,37.69,37.32,37.52,6245593.0,0.0,1.0,37.51,37.69,37.32,37.52,6245593.0
-2017-12-08,37.25,37.99,37.16,37.65,12217992.0,0.0,1.0,37.25,37.99,37.16,37.65,12217992.0
-2017-12-07,36.72,37.15,36.5,36.85,7364150.0,0.0,1.0,36.72,37.15,36.5,36.85,7364150.0
-2017-12-06,36.64,36.91,36.36,36.83,8813063.0,0.0,1.0,36.64,36.91,36.36,36.83,8813063.0
-2017-12-05,35.94,37.19,35.75,36.81,18630500.0,0.0,1.0,35.94,37.19,35.75,36.81,18630500.0
-2017-12-04,35.58,36.08,35.38,35.7,11046784.0,0.0,1.0,35.58,36.08,35.38,35.7,11046784.0
-2017-12-01,34.38,35.25,34.31,35.2,11236547.0,0.0,1.0,34.38,35.25,34.31,35.2,11236547.0
-2017-11-30,34.48,35.19,34.4612,34.67,16173978.0,0.0,1.0,34.48,35.19,34.4612,34.67,16173978.0
-2017-11-29,35.42,35.45,33.945,34.38,21446119.0,0.0,1.0,35.42,35.45,33.945,34.38,21446119.0
-2017-11-28,35.99,36.2,35.42,35.5,10191191.0,0.0,1.0,35.99,36.2,35.42,35.5,10191191.0
-2017-11-27,35.88,36.2,35.7905,35.99,6981252.0,0.0,1.0,35.88,36.2,35.7905,35.99,6981252.0
-2017-11-24,36.07,36.11,35.7,35.84,3123070.0,0.0,1.0,36.07,36.11,35.7,35.84,3123070.0
-2017-11-22,36.05,36.195,35.84,35.94,4563054.0,0.0,1.0,36.05,36.195,35.84,35.94,4563054.0
-2017-11-21,35.72,36.11,35.56,35.96,5807385.0,0.0,1.0,35.72,36.11,35.56,35.96,5807385.0
-2017-11-20,35.62,35.97,35.42,35.53,5964478.0,0.0,1.0,35.62,35.97,35.42,35.53,5964478.0
-2017-11-17,35.64,35.71,35.31,35.58,7458295.0,0.0,1.0,35.64,35.71,35.31,35.58,7458295.0
-2017-11-16,35.37,35.815,35.32,35.62,7632669.0,0.0,1.0,35.37,35.815,35.32,35.62,7632669.0
-2017-11-15,35.03,35.47,34.79,35.3,7871444.0,0.0,1.0,35.03,35.47,34.79,35.3,7871444.0
-2017-11-14,35.71,35.79,35.18,35.22,10858859.0,0.0,1.0,35.71,35.79,35.18,35.22,10858859.0
-2017-11-13,35.7,36.1,35.32,35.85,7047371.0,0.0,1.0,35.7,36.1,35.32,35.85,7047371.0
-2017-11-10,35.51,36.045,35.34,35.97,8276878.0,0.0,1.0,35.51,36.045,35.34,35.97,8276878.0
-2017-11-09,36.26,36.36,35.21,35.69,16766871.0,0.0,1.0,36.26,36.36,35.21,35.69,16766871.0
-2017-11-07,37.6,37.6,37.1,37.41,5564092.0,0.0,1.0,37.6,37.6,37.1,37.41,5564092.0
-2017-11-06,37.38,37.61,37.3,37.37,4338972.0,0.0,1.0,37.38,37.61,37.3,37.37,4338972.0
-2017-11-03,37.44,37.545,37.11,37.5,5708840.0,0.0,1.0,37.44,37.545,37.11,37.5,5708840.0
-2017-11-02,37.49,37.5,36.995,37.4,5341879.0,0.0,1.0,37.49,37.5,36.995,37.4,5341879.0
-2017-11-01,37.85,38.09,37.435,37.54,7052554.0,0.0,1.0,37.85,38.09,37.435,37.54,7052554.0
-2017-10-31,37.11,37.68,37.02,37.64,6678430.0,0.0,1.0,37.11,37.68,37.02,37.64,6678430.0
-2017-10-30,36.86,37.13,36.74,37.0,7988838.0,0.0,1.0,36.86,37.13,36.74,37.0,7988838.0
-2017-10-27,37.07,37.36,36.635,36.8,10660803.0,0.0,1.0,37.07,37.36,36.635,36.8,10660803.0
-2017-10-26,36.74,37.24,36.72,36.9,7622668.0,0.0,1.0,36.74,37.24,36.72,36.9,7622668.0
-2017-10-25,36.66,36.92,36.45,36.68,7839488.0,0.0,1.0,36.66,36.92,36.45,36.68,7839488.0
-2017-10-24,36.51,37.03,36.51,36.74,8439952.0,0.0,1.0,36.51,37.03,36.51,36.74,8439952.0
-2017-10-23,37.66,37.85,36.74,36.83,10318056.0,0.0,1.0,37.66,37.85,36.74,36.83,10318056.0
-2017-10-20,37.34,37.86,37.3,37.61,14821200.0,0.0,1.0,37.34,37.86,37.3,37.61,14821200.0
-2017-10-19,36.48,37.49,36.19,37.29,28992713.0,0.0,1.0,36.48,37.49,36.19,37.29,28992713.0
-2017-10-18,37.68,38.22,37.54,37.97,13424086.0,0.0,1.0,37.68,38.22,37.54,37.97,13424086.0
-2017-10-17,37.76,37.84,37.42,37.49,11904108.0,0.0,1.0,37.76,37.84,37.42,37.49,11904108.0
-2017-10-16,38.29,38.5,37.725,37.77,8645585.0,0.0,1.0,38.29,38.5,37.725,37.77,8645585.0
-2017-10-13,38.35,38.53,38.16,38.35,9392998.0,0.0,1.0,38.35,38.53,38.16,38.35,9392998.0
-2017-10-12,38.31,38.5,38.055,38.09,10020870.0,0.0,1.0,38.31,38.5,38.055,38.09,10020870.0
-2017-10-11,38.85,38.98,38.17,38.31,10841024.0,0.0,1.0,38.85,38.98,38.17,38.31,10841024.0
-2017-10-10,39.02,39.275,38.77,38.84,5998658.0,0.0,1.0,39.02,39.275,38.77,38.84,5998658.0
-2017-10-09,38.8,39.265,38.8,38.99,4982743.0,0.0,1.0,38.8,39.265,38.8,38.99,4982743.0
-2017-10-06,39.05,39.08,38.67,38.81,6947721.0,0.0,1.0,39.05,39.08,38.67,38.81,6947721.0
-2017-10-05,38.76,39.035,38.675,38.99,5155812.0,0.0,1.0,38.76,39.035,38.675,38.99,5155812.0
-2017-10-04,38.8,38.83,38.5,38.66,5590600.0,0.0,1.0,38.8,38.83,38.5,38.66,5590600.0
-2017-10-03,38.78,39.05,38.485,38.71,5103669.0,0.0,1.0,38.78,39.05,38.485,38.71,5103669.0
-2017-10-02,38.51,38.78,38.37,38.73,7220120.0,0.0,1.0,38.51,38.78,38.37,38.73,7220120.0
-2017-09-29,37.73,38.6,37.71,38.46,9573477.0,0.0,1.0,37.73,38.6,37.71,38.46,9573477.0
-2017-09-28,37.44,37.96,37.44,37.73,7683377.0,0.0,1.0,37.44,37.96,37.44,37.73,7683377.0
-2017-09-27,38.03,38.29,37.76,38.05,9331736.0,0.0,1.0,38.03,38.29,37.76,38.05,9331736.0
-2017-09-26,37.85,38.19,37.75,37.85,5348200.0,0.0,1.0,37.85,38.19,37.75,37.85,5348200.0
-2017-09-25,38.22,38.31,37.54,37.78,7053896.0,0.0,1.0,38.22,38.31,37.54,37.78,7053896.0
-2017-09-22,38.13,38.31,38.05,38.29,4851365.0,0.0,1.0,38.13,38.31,38.05,38.29,4851365.0
-2017-09-21,38.55,38.67,38.19,38.25,5673772.0,0.0,1.0,38.55,38.67,38.19,38.25,5673772.0
-2017-09-20,38.67,38.87,38.21,38.54,5703686.0,0.0,1.0,38.67,38.87,38.21,38.54,5703686.0
-2017-09-19,38.5,38.75,38.32,38.59,5131286.0,0.0,1.0,38.5,38.75,38.32,38.59,5131286.0
-2017-09-18,38.3,38.665,38.18,38.39,5127823.0,0.0,1.0,38.3,38.665,38.18,38.39,5127823.0
-2017-09-15,38.27,38.865,38.07,38.4,10869179.0,0.0,1.0,38.27,38.865,38.07,38.4,10869179.0
-2017-09-14,38.24,38.585,38.13,38.31,6478656.0,0.0,1.0,38.24,38.585,38.13,38.31,6478656.0
-2017-09-13,38.0,38.5,38.0,38.27,4960915.0,0.0,1.0,38.0,38.5,38.0,38.27,4960915.0
-2017-09-12,38.07,38.3,37.98,38.18,4170327.0,0.0,1.0,38.07,38.3,37.98,38.18,4170327.0
-2017-09-11,38.04,38.26,38.0,38.09,5945142.0,0.0,1.0,38.04,38.26,38.0,38.09,5945142.0
-2017-09-08,38.04,38.3,37.725,37.79,9052735.0,0.0,1.0,38.04,38.3,37.725,37.79,9052735.0
-2017-09-07,36.95,38.19,36.84,38.01,13980230.0,0.0,1.0,36.95,38.19,36.84,38.01,13980230.0
-2017-09-06,36.08,36.98,36.08,36.76,12653446.0,0.0,1.0,36.08,36.98,36.08,36.76,12653446.0
-2017-09-05,36.19,36.48,35.77,36.09,6296438.0,0.0,1.0,36.19,36.48,35.77,36.09,6296438.0
-2017-09-01,36.2,36.58,36.14,36.35,5037396.0,0.0,1.0,36.2,36.58,36.14,36.35,5037396.0
-2017-08-31,35.85,36.32,35.821,36.13,8522717.0,0.0,1.0,35.85,36.32,35.821,36.13,8522717.0
-2017-08-30,35.14,35.955,35.1,35.69,8205167.0,0.0,1.0,35.14,35.955,35.1,35.69,8205167.0
-2017-08-29,34.48,35.315,34.42,35.2,7089389.0,0.0,1.0,34.48,35.315,34.42,35.2,7089389.0
-2017-08-28,34.75,34.9,34.66,34.81,5005834.0,0.0,1.0,34.75,34.9,34.66,34.81,5005834.0
-2017-08-25,34.98,35.07,34.56,34.68,6720164.0,0.0,1.0,34.98,35.07,34.56,34.68,6720164.0
-2017-08-24,34.86,35.04,34.51,34.88,5638387.0,0.0,1.0,34.86,35.04,34.51,34.88,5638387.0
-2017-08-23,34.62,34.98,34.51,34.89,6295975.0,0.0,1.0,34.62,34.98,34.51,34.89,6295975.0
-2017-08-22,34.37,34.81,34.31,34.81,6144284.0,0.0,1.0,34.37,34.81,34.31,34.81,6144284.0
-2017-08-21,35.13,35.13,34.09,34.24,7592681.0,0.0,1.0,35.13,35.13,34.09,34.24,7592681.0
-2017-08-18,34.83,35.14,34.75,34.79,8521640.0,0.0,1.0,34.83,35.14,34.75,34.79,8521640.0
-2017-08-17,35.5,35.5,34.8,34.85,6290987.0,0.0,1.0,35.5,35.5,34.8,34.85,6290987.0
-2017-08-16,35.23,35.48,35.07,35.36,3809705.0,0.0,1.0,35.23,35.48,35.07,35.36,3809705.0
-2017-08-15,35.24,35.42,35.12,35.25,4487094.0,0.0,1.0,35.24,35.42,35.12,35.25,4487094.0
-2017-08-14,35.44,35.45,34.88,35.2,6932178.0,0.0,1.0,35.44,35.45,34.88,35.2,6932178.0
-2017-08-11,35.16,35.32,34.76,35.05,7688311.0,0.0,1.0,35.16,35.32,34.76,35.05,7688311.0
-2017-08-10,35.95,35.9845,34.88,35.0,12151126.0,0.0,1.0,35.95,35.9845,34.88,35.0,12151126.0
-2017-08-09,36.13,36.225,35.72,36.08,7540671.0,0.0,1.0,36.13,36.225,35.72,36.08,7540671.0
-2017-08-08,35.96,36.64,35.89,36.36,9441402.0,0.0,1.0,35.96,36.64,35.89,36.36,9441402.0
-2017-08-07,35.61,36.15,35.38,36.11,5309161.0,0.0,1.0,35.61,36.15,35.38,36.11,5309161.0
-2017-08-04,35.86,35.86,35.55,35.62,5036090.0,0.0,1.0,35.86,35.86,35.55,35.62,5036090.0
-2017-08-03,35.97,35.98,35.57,35.71,5592728.0,0.0,1.0,35.97,35.98,35.57,35.71,5592728.0
-2017-08-02,35.69,35.95,35.42,35.9,6395959.0,0.0,1.0,35.69,35.95,35.42,35.9,6395959.0
-2017-08-01,35.82,36.02,35.75,35.91,4598532.0,0.0,1.0,35.82,36.02,35.75,35.91,4598532.0
-2017-07-31,36.09,36.13,35.65,35.73,6117033.0,0.0,1.0,36.09,36.13,35.65,35.73,6117033.0
-2017-07-28,36.08,36.21,35.73,35.94,7097225.0,0.0,1.0,36.08,36.21,35.73,35.94,7097225.0
-2017-07-27,37.09,37.265,35.54,36.17,15261765.0,0.0,1.0,37.09,37.265,35.54,36.17,15261765.0
-2017-07-26,36.36,37.07,36.36,37.04,10987896.0,0.0,1.0,36.36,37.07,36.36,37.04,10987896.0
-2017-07-25,36.33,36.485,36.06,36.32,6191010.0,0.0,1.0,36.33,36.485,36.06,36.32,6191010.0
-2017-07-24,36.45,36.73,36.22,36.39,9661599.0,0.0,1.0,36.45,36.73,36.22,36.39,9661599.0
-2017-07-21,36.2,36.9,36.05,36.61,22131224.0,0.0,1.0,36.2,36.9,36.05,36.61,22131224.0
-2017-07-20,37.17,37.48,37.0,37.18,13467628.0,0.0,1.0,37.17,37.48,37.0,37.18,13467628.0
-2017-07-19,36.95,37.26,36.645,37.08,8510278.0,0.0,1.0,36.95,37.26,36.645,37.08,8510278.0
-2017-07-18,36.94,36.94,36.57,36.8,12755207.0,0.0,1.0,36.94,36.94,36.57,36.8,12755207.0
-2017-07-17,37.03,37.17,36.57,37.05,8151725.0,0.0,1.0,37.03,37.17,36.57,37.05,8151725.0
-2017-07-14,36.91,37.2,36.83,37.08,9654192.0,0.0,1.0,36.91,37.2,36.83,37.08,9654192.0
-2017-07-13,36.61,37.13,36.26,36.5,12877614.0,0.0,1.0,36.61,37.13,36.26,36.5,12877614.0
-2017-07-12,35.53,36.2,35.53,36.03,13411174.0,0.0,1.0,35.53,36.2,35.53,36.03,13411174.0
-2017-07-11,34.97,35.45,34.89,35.19,8306962.0,0.0,1.0,34.97,35.45,34.89,35.19,8306962.0
-2017-07-10,34.31,35.14,34.28,35.04,8695234.0,0.0,1.0,34.31,35.14,34.28,35.04,8695234.0
-2017-07-07,34.02,34.55,34.01,34.23,6747508.0,0.0,1.0,34.02,34.55,34.01,34.23,6747508.0
-2017-07-06,34.39,34.5,33.95,34.03,8551358.0,0.0,1.0,34.39,34.5,33.95,34.03,8551358.0
-2017-07-05,34.73,34.86,34.505,34.72,7381884.0,0.0,1.0,34.73,34.86,34.505,34.72,7381884.0
-2017-07-03,35.15,35.305,34.55,34.6,4517402.0,0.0,1.0,35.15,35.305,34.55,34.6,4517402.0
-2017-06-30,34.78,35.07,34.52,34.92,10561065.0,0.0,1.0,34.78,35.07,34.52,34.92,10561065.0
-2017-06-29,35.3,35.3,34.09,34.51,8166989.0,0.0,1.0,35.3,35.3,34.09,34.51,8166989.0
-2017-06-28,35.0,35.33,34.615,35.31,4791632.0,0.0,1.0,35.0,35.33,34.615,35.31,4791632.0
-2017-06-27,35.0,35.32,34.85,34.91,8598433.0,0.0,1.0,35.0,35.32,34.85,34.91,8598433.0
-2017-06-26,35.89,35.97,35.0,35.09,6634019.0,0.0,1.0,35.89,35.97,35.0,35.09,6634019.0
-2017-06-23,35.12,35.735,34.96,35.58,8872359.0,0.0,1.0,35.12,35.735,34.96,35.58,8872359.0
-2017-06-22,34.99,35.285,34.84,35.12,5120718.0,0.0,1.0,34.99,35.285,34.84,35.12,5120718.0
-2017-06-21,35.0,35.12,34.75,34.96,5400949.0,0.0,1.0,35.0,35.12,34.75,34.96,5400949.0
-2017-06-20,34.74,35.34,34.74,34.93,10506559.0,0.0,1.0,34.74,35.34,34.74,34.93,10506559.0
-2017-06-19,34.12,34.99,34.0,34.9,5760279.0,0.0,1.0,34.12,34.99,34.0,34.9,5760279.0
-2017-06-16,33.92,34.32,33.91,33.96,9640312.0,0.0,1.0,33.92,34.32,33.91,33.96,9640312.0
-2017-06-15,34.26,34.29,33.89,34.09,5344405.0,0.0,1.0,34.26,34.29,33.89,34.09,5344405.0
-2017-06-14,34.63,34.73,34.11,34.5,6371265.0,0.0,1.0,34.63,34.73,34.11,34.5,6371265.0
-2017-06-13,34.21,34.55,34.08,34.47,7302410.0,0.0,1.0,34.21,34.55,34.08,34.47,7302410.0
-2017-06-12,34.7,34.77,33.975,34.15,12807616.0,0.0,1.0,34.7,34.77,33.975,34.15,12807616.0
-2017-06-09,36.25,36.5,34.69,34.94,10974043.0,0.0,1.0,36.25,36.5,34.69,34.94,10974043.0
-2017-06-08,36.07,36.315,35.865,36.14,8767604.0,0.0,1.0,36.07,36.315,35.865,36.14,8767604.0
-2017-06-07,35.65,35.87,35.56,35.77,5280007.0,0.0,1.0,35.65,35.87,35.56,35.77,5280007.0
-2017-06-06,35.41,35.805,35.35,35.47,5463513.0,0.0,1.0,35.41,35.805,35.35,35.47,5463513.0
-2017-06-05,36.02,36.02,35.39,35.55,5946671.0,0.0,1.0,36.02,36.02,35.39,35.55,5946671.0
-2017-06-02,34.92,35.44,34.61,35.32,6843000.0,0.0,1.0,34.92,35.44,34.61,35.32,6843000.0
-2017-06-01,34.44,34.89,34.2,34.79,6463818.0,0.0,1.0,34.44,34.89,34.2,34.79,6463818.0
diff --git a/examples/quick/demos/stocqt/content/data/FB.csv b/examples/quick/demos/stocqt/content/data/FB.csv
deleted file mode 100644
index d9ebf9eeba..0000000000
--- a/examples/quick/demos/stocqt/content/data/FB.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,178.0,178.85,176.46,176.46,10028758.0,0.0,1.0,178.0,178.85,176.46,176.46,10028758.0
-2017-12-28,177.95,178.9367,177.68,177.92,11008996.0,0.0,1.0,177.95,178.9367,177.68,177.92,11008996.0
-2017-12-27,176.55,178.44,176.26,177.62,9296258.0,0.0,1.0,176.55,178.44,176.26,177.62,9296258.0
-2017-12-26,176.63,177.0,174.67,175.99,8726829.0,0.0,1.0,176.63,177.0,174.67,175.99,8726829.0
-2017-12-22,177.14,177.53,176.23,177.2,8462491.0,0.0,1.0,177.14,177.53,176.23,177.2,8462491.0
-2017-12-21,177.94,178.68,177.05,177.45,11050969.0,0.0,1.0,177.94,178.68,177.05,177.45,11050969.0
-2017-12-20,179.81,179.81,177.36,177.89,11754823.0,0.0,1.0,179.81,179.81,177.36,177.89,11754823.0
-2017-12-19,179.95,180.08,178.22,179.51,14769239.0,0.0,1.0,179.95,180.08,178.22,179.51,14769239.0
-2017-12-18,181.01,181.3,179.75,180.82,17014337.0,0.0,1.0,181.01,181.3,179.75,180.82,17014337.0
-2017-12-15,179.02,180.4934,178.36,180.18,26225100.0,0.0,1.0,179.02,180.4934,178.36,180.18,26225100.0
-2017-12-14,178.29,180.3601,177.68,178.39,13393757.0,0.0,1.0,178.29,180.3601,177.68,178.39,13393757.0
-2017-12-13,177.3,179.16,177.25,178.3,14406776.0,0.0,1.0,177.3,179.16,177.25,178.3,14406776.0
-2017-12-12,178.6,179.18,176.6,176.96,16675275.0,0.0,1.0,178.6,179.18,176.6,176.96,16675275.0
-2017-12-11,179.3,180.22,178.8,179.04,12630207.0,0.0,1.0,179.3,180.22,178.8,179.04,12630207.0
-2017-12-08,181.53,182.28,178.7401,179.0,19377310.0,0.0,1.0,181.53,182.28,178.7401,179.0,19377310.0
-2017-12-07,175.8,180.39,175.8,180.14,19588217.0,0.0,1.0,175.8,180.39,175.8,180.14,19588217.0
-2017-12-06,172.5,176.77,171.9,176.06,20059293.0,0.0,1.0,172.5,176.77,171.9,176.06,20059293.0
-2017-12-05,170.45,175.38,169.01,172.83,20028656.0,0.0,1.0,170.45,175.38,169.01,172.83,20028656.0
-2017-12-04,176.29,176.57,170.79,171.47,24184006.0,0.0,1.0,176.29,176.57,170.79,171.47,24184006.0
-2017-12-01,176.03,177.48,172.34,175.1,19824531.0,0.0,1.0,176.03,177.48,172.34,175.1,19824531.0
-2017-11-30,176.85,178.275,175.2,177.18,24613431.0,0.0,1.0,176.85,178.275,175.2,177.18,24613431.0
-2017-11-29,181.89,181.97,174.0,175.13,41651953.0,0.0,1.0,181.89,181.97,174.0,175.13,41651953.0
-2017-11-28,183.51,184.25,182.09,182.42,13761926.0,0.0,1.0,183.51,184.25,182.09,182.42,13761926.0
-2017-11-27,182.56,183.73,181.99,183.03,12249740.0,0.0,1.0,182.56,183.73,181.99,183.03,12249740.0
-2017-11-24,180.4,183.15,180.29,182.78,9426010.0,0.0,1.0,180.4,183.15,180.29,182.78,9426010.0
-2017-11-22,181.3,181.73,180.44,180.87,10238140.0,0.0,1.0,181.3,181.73,180.44,180.87,10238140.0
-2017-11-21,179.15,181.89,178.99,181.86,14409305.0,0.0,1.0,179.15,181.89,178.99,181.86,14409305.0
-2017-11-20,178.87,179.5,178.1,178.74,9476502.0,0.0,1.0,178.87,179.5,178.1,178.74,9476502.0
-2017-11-17,179.3,179.98,178.9,179.0,12722802.0,0.0,1.0,179.3,179.98,178.9,179.0,12722802.0
-2017-11-16,178.76,179.83,178.5,179.59,14655982.0,0.0,1.0,178.76,179.83,178.5,179.59,14655982.0
-2017-11-15,176.66,178.57,176.4,177.95,10131051.0,0.0,1.0,176.66,178.57,176.4,177.95,10131051.0
-2017-11-14,178.13,178.97,177.18,178.07,9465112.0,0.0,1.0,178.13,178.97,177.18,178.07,9465112.0
-2017-11-13,177.5,179.04,177.3,178.77,9431449.0,0.0,1.0,177.5,179.04,177.3,178.77,9431449.0
-2017-11-10,178.35,179.0999,177.96,178.46,10933405.0,0.0,1.0,178.35,179.0999,177.96,178.46,10933405.0
-2017-11-09,178.31,179.4,177.09,179.3,12460345.0,0.0,1.0,178.31,179.4,177.09,179.3,12460345.0
-2017-11-07,180.5,180.7478,178.96,180.25,12679885.0,0.0,1.0,180.5,180.7478,178.96,180.25,12679885.0
-2017-11-06,178.56,180.45,178.31,180.17,13065077.0,0.0,1.0,178.56,180.45,178.31,180.17,13065077.0
-2017-11-03,179.29,179.86,176.71,178.92,17572587.0,0.0,1.0,179.29,179.86,176.71,178.92,17572587.0
-2017-11-02,180.63,181.94,177.34,178.92,35119841.0,0.0,1.0,180.63,181.94,177.34,178.92,35119841.0
-2017-11-01,182.36,182.9,180.57,182.66,28922959.0,0.0,1.0,182.36,182.9,180.57,182.66,28922959.0
-2017-10-31,180.57,180.8,178.94,180.06,19766043.0,0.0,1.0,180.57,180.8,178.94,180.06,19766043.0
-2017-10-30,179.26,180.69,177.61,179.87,24179258.0,0.0,1.0,179.26,180.69,177.61,179.87,24179258.0
-2017-10-27,174.15,178.21,173.9,177.88,29867490.0,0.0,1.0,174.15,178.21,173.9,177.88,29867490.0
-2017-10-26,171.38,172.285,170.39,170.63,10932929.0,0.0,1.0,171.38,172.285,170.39,170.63,10932929.0
-2017-10-25,171.9,172.25,168.89,170.6,15095603.0,0.0,1.0,171.9,172.25,168.89,170.6,15095603.0
-2017-10-24,172.3,173.24,171.5,171.8,11629341.0,0.0,1.0,172.3,173.24,171.5,171.8,11629341.0
-2017-10-23,175.2,175.34,171.25,171.27,13622072.0,0.0,1.0,175.2,175.34,171.25,171.27,13622072.0
-2017-10-20,175.5,175.88,174.63,174.98,11861307.0,0.0,1.0,175.5,175.88,174.63,174.98,11861307.0
-2017-10-19,174.93,176.03,172.63,174.56,13602869.0,0.0,1.0,174.93,176.03,172.63,174.56,13602869.0
-2017-10-18,176.65,176.74,175.75,176.03,12655492.0,0.0,1.0,176.65,176.74,175.75,176.03,12655492.0
-2017-10-17,174.71,176.13,174.36,176.11,15381990.0,0.0,1.0,174.71,176.13,174.36,176.11,15381990.0
-2017-10-16,174.49,175.0,174.06,174.52,11225293.0,0.0,1.0,174.49,175.0,174.06,174.52,11225293.0
-2017-10-13,173.45,174.65,173.2,173.74,13305724.0,0.0,1.0,173.45,174.65,173.2,173.74,13305724.0
-2017-10-12,172.61,173.85,172.29,172.55,10312488.0,0.0,1.0,172.61,173.85,172.29,172.55,10312488.0
-2017-10-11,171.95,172.78,171.4,172.74,11023310.0,0.0,1.0,171.95,172.78,171.4,172.74,11023310.0
-2017-10-10,173.0,173.2,170.8,171.59,11231234.0,0.0,1.0,173.0,173.2,170.8,171.59,11231234.0
-2017-10-09,172.7,174.88,172.0,172.5,14472612.0,0.0,1.0,172.7,174.88,172.0,172.5,14472612.0
-2017-10-06,170.25,172.37,169.75,172.23,12670089.0,0.0,1.0,170.25,172.37,169.75,172.23,12670089.0
-2017-10-05,169.18,171.31,168.6,171.24,14013869.0,0.0,1.0,169.18,171.31,168.6,171.24,14013869.0
-2017-10-04,169.83,170.67,168.29,168.42,11829323.0,0.0,1.0,169.83,170.67,168.29,168.42,11829323.0
-2017-10-03,169.3,170.73,169.2,169.96,8054219.0,0.0,1.0,169.3,170.73,169.2,169.96,8054219.0
-2017-10-02,171.39,171.87,168.75,169.47,13104304.0,0.0,1.0,171.39,171.87,168.75,169.47,13104304.0
-2017-09-29,168.83,171.66,168.81,170.81,15114619.0,0.0,1.0,168.83,171.66,168.81,170.81,15114619.0
-2017-09-28,167.94,169.0696,167.16,168.73,12084865.0,0.0,1.0,167.94,169.0696,167.16,168.73,12084865.0
-2017-09-27,165.9,168.34,165.57,167.68,18963276.0,0.0,1.0,165.9,168.34,165.57,167.68,18963276.0
-2017-09-26,164.5,165.5,162.78,164.21,22866403.0,0.0,1.0,164.5,165.5,162.78,164.21,22866403.0
-2017-09-25,169.24,169.3,161.56,162.87,40538994.0,0.0,1.0,169.24,169.3,161.56,162.87,40538994.0
-2017-09-22,170.21,171.73,169.22,170.54,11835708.0,0.0,1.0,170.21,171.73,169.22,170.54,11835708.0
-2017-09-21,171.69,172.27,170.01,171.11,11054545.0,0.0,1.0,171.69,172.27,170.01,171.11,11054545.0
-2017-09-20,172.5,173.05,170.7,172.17,11899057.0,0.0,1.0,172.5,173.05,170.7,172.17,11899057.0
-2017-09-19,170.62,172.56,170.36,172.52,12911661.0,0.0,1.0,170.62,172.56,170.36,172.52,12911661.0
-2017-09-18,171.99,172.07,169.34,170.01,12785437.0,0.0,1.0,171.99,172.07,169.34,170.01,12785437.0
-2017-09-15,170.88,172.34,170.26,171.58,15468473.0,0.0,1.0,170.88,172.34,170.26,171.58,15468473.0
-2017-09-14,172.26,172.28,170.5,170.96,15496424.0,0.0,1.0,172.26,172.28,170.5,170.96,15496424.0
-2017-09-13,173.01,173.17,172.06,173.05,8908633.0,0.0,1.0,173.01,173.17,172.06,173.05,8908633.0
-2017-09-12,173.76,174.0,171.75,172.96,11051768.0,0.0,1.0,173.76,174.0,171.75,172.96,11051768.0
-2017-09-11,172.4,173.89,172.2,173.51,12183568.0,0.0,1.0,172.4,173.89,172.2,173.51,12183568.0
-2017-09-08,173.09,173.49,170.8,170.95,10936358.0,0.0,1.0,173.09,173.49,170.8,170.95,10936358.0
-2017-09-07,171.94,173.3067,170.27,173.21,17922494.0,0.0,1.0,171.94,173.3067,170.27,173.21,17922494.0
-2017-09-06,170.91,172.48,169.57,172.09,13659317.0,0.0,1.0,170.91,172.48,169.57,172.09,13659317.0
-2017-09-05,171.27,172.3875,169.55,170.72,13175866.0,0.0,1.0,171.27,172.3875,169.55,170.72,13175866.0
-2017-09-01,172.4,172.915,171.31,172.02,11614185.0,0.0,1.0,172.4,172.915,171.31,172.02,11614185.0
-2017-08-31,170.4,172.145,170.06,172.0,16873901.0,0.0,1.0,170.4,172.145,170.06,172.0,16873901.0
-2017-08-30,168.17,170.18,167.63,169.92,10850005.0,0.0,1.0,168.17,170.18,167.63,169.92,10850005.0
-2017-08-29,165.25,168.425,165.0,168.05,10992617.0,0.0,1.0,165.25,168.425,165.0,168.05,10992617.0
-2017-08-28,166.91,167.7,166.33,167.24,8360380.0,0.0,1.0,166.91,167.7,166.33,167.24,8360380.0
-2017-08-25,167.86,168.38,166.18,166.32,12391910.0,0.0,1.0,167.86,168.38,166.18,166.32,12391910.0
-2017-08-24,168.88,169.29,166.41,167.74,13552865.0,0.0,1.0,168.88,169.29,166.41,167.74,13552865.0
-2017-08-23,168.84,169.36,168.2,168.71,9756817.0,0.0,1.0,168.84,169.36,168.2,168.71,9756817.0
-2017-08-22,168.28,169.87,167.15,169.64,11333260.0,0.0,1.0,168.28,169.87,167.15,169.64,11333260.0
-2017-08-21,167.16,168.0,165.82,167.78,11880823.0,0.0,1.0,167.16,168.0,165.82,167.78,11880823.0
-2017-08-18,166.84,168.67,166.21,167.41,14933261.0,0.0,1.0,166.84,168.67,166.21,167.41,14933261.0
-2017-08-17,169.34,169.86,166.85,166.91,16791591.0,0.0,1.0,169.34,169.86,166.85,166.91,16791591.0
-2017-08-16,171.25,171.38,169.24,170.0,15580549.0,0.0,1.0,171.25,171.38,169.24,170.0,15580549.0
-2017-08-15,171.49,171.5,170.01,171.0,8621787.0,0.0,1.0,171.49,171.5,170.01,171.0,8621787.0
-2017-08-14,170.09,171.08,169.29,170.75,12786286.0,0.0,1.0,170.09,171.08,169.29,170.75,12786286.0
-2017-08-11,167.95,168.82,166.85,168.08,13664032.0,0.0,1.0,167.95,168.82,166.85,168.08,13664032.0
-2017-08-10,170.06,170.59,166.85,167.4,20353485.0,0.0,1.0,170.06,170.59,166.85,167.4,20353485.0
-2017-08-09,169.98,171.45,169.56,171.18,10597084.0,0.0,1.0,169.98,171.45,169.56,171.18,10597084.0
-2017-08-08,171.88,173.05,170.62,171.23,13813683.0,0.0,1.0,171.88,173.05,170.62,171.23,13813683.0
-2017-08-07,169.95,172.06,169.66,171.98,12504157.0,0.0,1.0,169.95,172.06,169.66,171.98,12504157.0
-2017-08-04,168.97,170.06,168.69,169.62,10360774.0,0.0,1.0,168.97,170.06,168.69,169.62,10360774.0
-2017-08-03,169.3,169.7,168.25,168.59,10316246.0,0.0,1.0,169.3,169.7,168.25,168.59,10316246.0
-2017-08-02,170.3,170.55,166.91,169.25,17061845.0,0.0,1.0,170.3,170.55,166.91,169.25,17061845.0
-2017-08-01,169.82,170.47,169.05,169.86,14051379.0,0.0,1.0,169.82,170.47,169.05,169.86,14051379.0
-2017-07-31,172.0,172.72,168.55,169.25,25157896.0,0.0,1.0,172.0,172.72,168.55,169.25,25157896.0
-2017-07-28,169.07,173.43,169.05,172.45,24036502.0,0.0,1.0,169.07,173.43,169.05,172.45,24036502.0
-2017-07-27,174.7,175.49,167.5,170.44,68065163.0,0.0,1.0,174.7,175.49,167.5,170.44,68065163.0
-2017-07-26,166.01,166.01,164.1,165.61,24081060.0,0.0,1.0,166.01,166.01,164.1,165.61,24081060.0
-2017-07-25,165.01,165.54,163.8619,165.28,15164613.0,0.0,1.0,165.01,165.54,163.8619,165.28,15164613.0
-2017-07-24,164.64,166.17,164.31,166.0,16595460.0,0.0,1.0,164.64,166.17,164.31,166.0,16595460.0
-2017-07-21,164.16,165.05,163.75,164.43,14494667.0,0.0,1.0,164.16,165.05,163.75,164.43,14494667.0
-2017-07-20,164.8,165.0,162.81,164.53,18293111.0,0.0,1.0,164.8,165.0,162.81,164.53,18293111.0
-2017-07-19,163.59,165.7,163.17,164.14,25915988.0,0.0,1.0,163.59,165.7,163.17,164.14,25915988.0
-2017-07-18,159.66,163.73,159.42,162.86,23621711.0,0.0,1.0,159.66,163.73,159.42,162.86,23621711.0
-2017-07-17,160.25,160.78,158.81,159.73,12567935.0,0.0,1.0,160.25,160.78,158.81,159.73,12567935.0
-2017-07-14,160.13,160.32,159.3254,159.97,16172560.0,0.0,1.0,160.13,160.32,159.3254,159.97,16172560.0
-2017-07-13,158.74,159.78,158.4227,159.26,13839891.0,0.0,1.0,158.74,159.78,158.4227,159.26,13839891.0
-2017-07-12,156.49,159.16,156.2,158.9,22483868.0,0.0,1.0,156.49,159.16,156.2,158.9,22483868.0
-2017-07-11,153.37,155.4225,152.91,155.27,13208251.0,0.0,1.0,153.37,155.4225,152.91,155.27,13208251.0
-2017-07-10,151.69,153.98,151.51,153.5,13296447.0,0.0,1.0,151.69,153.98,151.51,153.5,13296447.0
-2017-07-07,149.25,151.99,149.19,151.44,13229352.0,0.0,1.0,149.25,151.99,149.19,151.44,13229352.0
-2017-07-06,149.03,150.04,148.0,148.82,14788811.0,0.0,1.0,149.03,150.04,148.0,148.82,14788811.0
-2017-07-05,149.0,150.85,148.13,150.34,14037692.0,0.0,1.0,149.0,150.85,148.13,150.34,14037692.0
-2017-07-03,151.72,152.15,147.8,148.43,13860113.0,0.0,1.0,151.72,152.15,147.8,148.43,13860113.0
-2017-06-30,151.9,151.92,150.06,150.98,14540013.0,0.0,1.0,151.9,151.92,150.06,150.98,14540013.0
-2017-06-29,152.28,152.5,148.9175,151.04,23771610.0,0.0,1.0,152.28,152.5,148.9175,151.04,23771610.0
-2017-06-28,150.92,153.47,149.86,153.24,16621566.0,0.0,1.0,150.92,153.47,149.86,153.24,16621566.0
-2017-06-27,152.84,153.31,150.39,150.58,19274022.0,0.0,1.0,152.84,153.31,150.39,150.58,19274022.0
-2017-06-26,156.25,156.5,153.1954,153.59,17934289.0,0.0,1.0,156.25,156.5,153.1954,153.59,17934289.0
-2017-06-23,152.72,155.2,152.65,155.07,16192249.0,0.0,1.0,152.72,155.2,152.65,155.07,16192249.0
-2017-06-22,153.01,154.55,152.91,153.4,12783958.0,0.0,1.0,153.01,154.55,152.91,153.4,12783958.0
-2017-06-21,152.36,154.08,151.88,153.91,14760242.0,0.0,1.0,152.36,154.08,151.88,153.91,14760242.0
-2017-06-20,152.88,153.84,152.21,152.25,14557895.0,0.0,1.0,152.88,153.84,152.21,152.25,14557895.0
-2017-06-19,151.71,153.57,151.71,152.87,18678807.0,0.0,1.0,151.71,153.57,151.71,152.87,18678807.0
-2017-06-16,149.59,150.83,148.6,150.64,22169800.0,0.0,1.0,149.59,150.83,148.6,150.64,22169800.0
-2017-06-15,147.67,150.0366,146.3747,149.8,18877305.0,0.0,1.0,147.67,150.0366,146.3747,149.8,18877305.0
-2017-06-14,151.26,152.4,149.05,150.25,20552981.0,0.0,1.0,151.26,152.4,149.05,150.25,20552981.0
-2017-06-13,150.15,151.18,148.9,150.68,20316202.0,0.0,1.0,150.15,151.18,148.9,150.68,20316202.0
-2017-06-12,148.17,149.195,144.56,148.44,33238543.0,0.0,1.0,148.17,149.195,144.56,148.44,33238543.0
-2017-06-09,154.77,155.59,146.61,149.63,35256368.0,0.0,1.0,154.77,155.59,146.61,149.63,35256368.0
-2017-06-08,154.08,154.73,153.1,154.71,17539521.0,0.0,1.0,154.08,154.73,153.1,154.71,17539521.0
-2017-06-07,153.27,153.75,152.34,153.12,11822136.0,0.0,1.0,153.27,153.75,152.34,153.12,11822136.0
-2017-06-06,153.41,154.52,152.48,152.81,13291727.0,0.0,1.0,153.41,154.52,152.48,152.81,13291727.0
-2017-06-05,153.64,154.7088,153.41,153.63,12279871.0,0.0,1.0,153.64,154.7088,153.41,153.63,12279871.0
-2017-06-02,151.85,153.63,151.3,153.61,16787255.0,0.0,1.0,151.85,153.63,151.3,153.61,16787255.0
-2017-06-01,151.75,152.29,150.3,151.53,14459173.0,0.0,1.0,151.75,152.29,150.3,151.53,14459173.0
diff --git a/examples/quick/demos/stocqt/content/data/GOOG.csv b/examples/quick/demos/stocqt/content/data/GOOG.csv
deleted file mode 100644
index bde72eafe9..0000000000
--- a/examples/quick/demos/stocqt/content/data/GOOG.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,1046.72,1049.7,1044.9,1046.4,867943.0,0.0,1.0,1046.72,1049.7,1044.9,1046.4,867943.0
-2017-12-28,1051.6,1054.75,1044.77,1048.14,829623.0,0.0,1.0,1051.6,1054.75,1044.77,1048.14,829623.0
-2017-12-27,1057.39,1058.37,1048.05,1049.37,1214775.0,0.0,1.0,1057.39,1058.37,1048.05,1049.37,1214775.0
-2017-12-26,1058.07,1060.12,1050.2,1056.74,756324.0,0.0,1.0,1058.07,1060.12,1050.2,1056.74,756324.0
-2017-12-22,1061.11,1064.2,1059.44,1060.12,734566.0,0.0,1.0,1061.11,1064.2,1059.44,1060.12,734566.0
-2017-12-21,1064.95,1069.33,1061.79,1063.63,974594.0,0.0,1.0,1064.95,1069.33,1061.79,1063.63,974594.0
-2017-12-20,1071.78,1073.38,1061.52,1064.95,1266115.0,0.0,1.0,1071.78,1073.38,1061.52,1064.95,1266115.0
-2017-12-19,1075.2,1076.84,1063.55,1070.68,1254615.0,0.0,1.0,1075.2,1076.84,1063.55,1070.68,1254615.0
-2017-12-18,1066.08,1078.49,1062.0,1077.14,1531522.0,0.0,1.0,1066.08,1078.49,1062.0,1077.14,1531522.0
-2017-12-15,1054.61,1067.62,1049.5,1064.19,3142760.0,0.0,1.0,1054.61,1067.62,1049.5,1064.19,3142760.0
-2017-12-14,1045.0,1058.5,1043.11,1049.15,1545616.0,0.0,1.0,1045.0,1058.5,1043.11,1049.15,1545616.0
-2017-12-13,1046.12,1046.66,1038.38,1040.61,1207286.0,0.0,1.0,1046.12,1046.66,1038.38,1040.61,1207286.0
-2017-12-12,1039.63,1050.31,1033.69,1040.48,1269883.0,0.0,1.0,1039.63,1050.31,1033.69,1040.48,1269883.0
-2017-12-11,1035.5,1043.8,1032.05,1041.1,1119052.0,0.0,1.0,1035.5,1043.8,1032.05,1041.1,1119052.0
-2017-12-08,1037.49,1042.05,1032.52,1037.05,1277894.0,0.0,1.0,1037.49,1042.05,1032.52,1037.05,1277894.0
-2017-12-07,1020.43,1034.24,1018.07,1030.93,1387107.0,0.0,1.0,1020.43,1034.24,1018.07,1030.93,1387107.0
-2017-12-06,1001.5,1024.97,1001.14,1018.38,1254837.0,0.0,1.0,1001.5,1024.97,1001.14,1018.38,1254837.0
-2017-12-05,995.94,1020.61,988.28,1005.15,2023376.0,0.0,1.0,995.94,1020.61,988.28,1005.15,2023376.0
-2017-12-04,1012.66,1016.1,995.57,998.68,1891408.0,0.0,1.0,1012.66,1016.1,995.57,998.68,1891408.0
-2017-12-01,1015.8,1022.49,1002.02,1010.17,1895786.0,0.0,1.0,1015.8,1022.49,1002.02,1010.17,1895786.0
-2017-11-30,1022.37,1028.49,1015.0,1021.41,1684292.0,0.0,1.0,1022.37,1028.49,1015.0,1021.41,1684292.0
-2017-11-29,1042.68,1044.08,1015.65,1021.66,2414465.0,0.0,1.0,1042.68,1044.08,1015.65,1021.66,2414465.0
-2017-11-28,1055.09,1062.38,1040.0,1047.41,1341000.0,0.0,1.0,1055.09,1062.38,1040.0,1047.41,1341000.0
-2017-11-27,1040.0,1055.46,1038.44,1054.21,1284354.0,0.0,1.0,1040.0,1055.46,1038.44,1054.21,1284354.0
-2017-11-24,1035.87,1043.18,1035.0,1040.61,536958.0,0.0,1.0,1035.87,1043.18,1035.0,1040.61,536958.0
-2017-11-22,1035.0,1039.71,1031.43,1035.96,716661.0,0.0,1.0,1035.0,1039.71,1031.43,1035.96,716661.0
-2017-11-21,1023.31,1035.11,1022.66,1034.49,1083715.0,0.0,1.0,1023.31,1035.11,1022.66,1034.49,1083715.0
-2017-11-20,1020.26,1022.61,1017.5,1018.38,894844.0,0.0,1.0,1020.26,1022.61,1017.5,1018.38,894844.0
-2017-11-17,1034.01,1034.42,1017.75,1019.09,1350144.0,0.0,1.0,1034.01,1034.42,1017.75,1019.09,1350144.0
-2017-11-16,1022.52,1035.92,1022.52,1032.5,1117578.0,0.0,1.0,1022.52,1035.92,1022.52,1032.5,1117578.0
-2017-11-15,1019.21,1024.09,1015.42,1020.91,859951.0,0.0,1.0,1019.21,1024.09,1015.42,1020.91,859951.0
-2017-11-14,1022.59,1026.81,1014.15,1026.0,947273.0,0.0,1.0,1022.59,1026.81,1014.15,1026.0,947273.0
-2017-11-13,1023.42,1031.58,1022.57,1025.75,878969.0,0.0,1.0,1023.42,1031.58,1022.57,1025.75,878969.0
-2017-11-10,1026.46,1030.76,1025.28,1028.07,719227.0,0.0,1.0,1026.46,1030.76,1025.28,1028.07,719227.0
-2017-11-09,1033.99,1033.99,1019.67,1031.26,1236903.0,0.0,1.0,1033.99,1033.99,1019.67,1031.26,1236903.0
-2017-11-07,1027.27,1033.97,1025.13,1033.33,1089887.0,0.0,1.0,1027.27,1033.97,1025.13,1033.33,1089887.0
-2017-11-06,1028.99,1034.87,1025.0,1025.9,1119131.0,0.0,1.0,1028.99,1034.87,1025.0,1025.9,1119131.0
-2017-11-03,1022.11,1032.65,1020.31,1032.48,1058037.0,0.0,1.0,1022.11,1032.65,1020.31,1032.48,1058037.0
-2017-11-02,1021.76,1028.09,1013.01,1025.58,1008190.0,0.0,1.0,1021.76,1028.09,1013.01,1025.58,1008190.0
-2017-11-01,1017.21,1029.67,1016.95,1025.5,1360900.0,0.0,1.0,1017.21,1029.67,1016.95,1025.5,1360900.0
-2017-10-31,1015.22,1024.0,1010.42,1016.64,1324961.0,0.0,1.0,1015.22,1024.0,1010.42,1016.64,1324961.0
-2017-10-30,1014.0,1024.97,1007.5,1017.11,2074619.0,0.0,1.0,1014.0,1024.97,1007.5,1017.11,2074619.0
-2017-10-27,1009.19,1048.39,1008.2,1019.27,5125791.0,0.0,1.0,1009.19,1048.39,1008.2,1019.27,5125791.0
-2017-10-26,980.0,987.6,972.2,972.56,1660850.0,0.0,1.0,980.0,987.6,972.2,972.56,1660850.0
-2017-10-25,968.37,976.09,960.5201,973.33,1162606.0,0.0,1.0,968.37,976.09,960.5201,973.33,1162606.0
-2017-10-24,970.0,972.23,961.0,970.54,1155231.0,0.0,1.0,970.0,972.23,961.0,970.54,1155231.0
-2017-10-23,989.52,989.52,966.12,968.45,1431886.0,0.0,1.0,989.52,989.52,966.12,968.45,1431886.0
-2017-10-20,989.44,991.0,984.58,988.2,1120038.0,0.0,1.0,989.44,991.0,984.58,988.2,1120038.0
-2017-10-19,986.0,988.88,978.39,984.45,1282755.0,0.0,1.0,986.0,988.88,978.39,984.45,1282755.0
-2017-10-18,991.77,996.72,986.9747,992.81,1022521.0,0.0,1.0,991.77,996.72,986.9747,992.81,1022521.0
-2017-10-17,990.29,996.44,988.59,992.18,1266399.0,0.0,1.0,990.29,996.44,988.59,992.18,1266399.0
-2017-10-16,992.1,993.9065,984.0,992.0,900751.0,0.0,1.0,992.1,993.9065,984.0,992.0,900751.0
-2017-10-13,992.0,997.21,989.0,989.68,1143907.0,0.0,1.0,992.0,997.21,989.0,989.68,1143907.0
-2017-10-12,987.45,994.12,985.0,987.83,1259082.0,0.0,1.0,987.45,994.12,985.0,987.83,1259082.0
-2017-10-11,973.72,990.71,972.25,989.25,1663731.0,0.0,1.0,973.72,990.71,972.25,989.25,1663731.0
-2017-10-10,980.0,981.57,966.0801,972.6,956419.0,0.0,1.0,980.0,981.57,966.0801,972.6,956419.0
-2017-10-09,980.0,985.425,976.11,977.0,886700.0,0.0,1.0,980.0,985.425,976.11,977.0,886700.0
-2017-10-06,966.7,979.46,963.36,978.89,1142699.0,0.0,1.0,966.7,979.46,963.36,978.89,1142699.0
-2017-10-05,955.49,970.91,955.18,969.96,1202101.0,0.0,1.0,955.49,970.91,955.18,969.96,1202101.0
-2017-10-04,957.0,960.39,950.69,951.68,881380.0,0.0,1.0,957.0,960.39,950.69,951.68,881380.0
-2017-10-03,954.0,958.0,949.14,957.79,881562.0,0.0,1.0,954.0,958.0,949.14,957.79,881562.0
-2017-10-02,959.98,962.54,947.84,953.27,1222026.0,0.0,1.0,959.98,962.54,947.84,953.27,1222026.0
-2017-09-29,952.0,959.7864,951.51,959.11,1533133.0,0.0,1.0,952.0,959.7864,951.51,959.11,1533133.0
-2017-09-28,941.36,950.69,940.55,949.5,959648.0,0.0,1.0,941.36,950.69,940.55,949.5,959648.0
-2017-09-27,927.74,949.9,927.74,944.49,2202959.0,0.0,1.0,927.74,949.9,927.74,944.49,2202959.0
-2017-09-26,923.72,930.82,921.14,924.86,1652848.0,0.0,1.0,923.72,930.82,921.14,924.86,1652848.0
-2017-09-25,925.45,926.4,909.7,920.97,1822881.0,0.0,1.0,925.45,926.4,909.7,920.97,1822881.0
-2017-09-22,927.75,934.73,926.48,928.53,1038551.0,0.0,1.0,927.75,934.73,926.48,928.53,1038551.0
-2017-09-21,933.0,936.53,923.83,932.45,1207656.0,0.0,1.0,933.0,936.53,923.83,932.45,1207656.0
-2017-09-20,922.98,933.88,922.0,931.58,1518166.0,0.0,1.0,922.98,933.88,922.0,931.58,1518166.0
-2017-09-19,917.42,922.4199,912.55,921.81,902415.0,0.0,1.0,917.42,922.4199,912.55,921.81,902415.0
-2017-09-18,920.01,922.08,910.6,915.0,1263456.0,0.0,1.0,920.01,922.08,910.6,915.0,1263456.0
-2017-09-15,924.66,926.49,916.36,920.29,2475031.0,0.0,1.0,924.66,926.49,916.36,920.29,2475031.0
-2017-09-14,931.25,932.77,924.0,925.11,1389012.0,0.0,1.0,931.25,932.77,924.0,925.11,1389012.0
-2017-09-13,930.66,937.25,929.86,935.09,1066051.0,0.0,1.0,930.66,937.25,929.86,935.09,1066051.0
-2017-09-12,932.59,933.48,923.861,932.07,1120449.0,0.0,1.0,932.59,933.48,923.861,932.07,1120449.0
-2017-09-11,934.25,938.38,926.92,929.08,1247138.0,0.0,1.0,934.25,938.38,926.92,929.08,1247138.0
-2017-09-08,936.49,936.99,924.88,926.5,993832.0,0.0,1.0,936.49,936.99,924.88,926.5,993832.0
-2017-09-07,931.73,936.41,923.62,935.95,1200257.0,0.0,1.0,931.73,936.41,923.62,935.95,1200257.0
-2017-09-06,930.15,930.915,919.27,927.81,1468808.0,0.0,1.0,930.15,930.915,919.27,927.81,1468808.0
-2017-09-05,933.08,937.0,921.96,928.45,1202163.0,0.0,1.0,933.08,937.0,921.96,928.45,1202163.0
-2017-09-01,941.13,942.48,935.15,937.34,913404.0,0.0,1.0,941.13,942.48,935.15,937.34,913404.0
-2017-08-31,931.76,941.98,931.76,939.33,1553301.0,0.0,1.0,931.76,941.98,931.76,939.33,1553301.0
-2017-08-30,920.05,930.819,919.65,929.57,1282093.0,0.0,1.0,920.05,930.819,919.65,929.57,1282093.0
-2017-08-29,905.1,923.33,905.0,921.29,1180160.0,0.0,1.0,905.1,923.33,905.0,921.29,1180160.0
-2017-08-28,916.0,919.245,911.87,913.81,1072467.0,0.0,1.0,916.0,919.245,911.87,913.81,1072467.0
-2017-08-25,923.49,925.555,915.5,915.89,1040693.0,0.0,1.0,923.49,925.555,915.5,915.89,1040693.0
-2017-08-24,928.66,930.84,915.5,921.28,1218875.0,0.0,1.0,928.66,930.84,915.5,921.28,1218875.0
-2017-08-23,921.93,929.93,919.36,927.0,1077809.0,0.0,1.0,921.93,929.93,919.36,927.0,1077809.0
-2017-08-22,912.72,925.86,911.4751,924.69,1145571.0,0.0,1.0,912.72,925.86,911.4751,924.69,1145571.0
-2017-08-21,910.0,913.0,903.4,906.66,932903.0,0.0,1.0,910.0,913.0,903.4,906.66,932903.0
-2017-08-18,910.31,915.275,907.1543,910.67,1333572.0,0.0,1.0,910.31,915.275,907.1543,910.67,1333572.0
-2017-08-17,925.78,926.86,910.98,910.98,1218963.0,0.0,1.0,925.78,926.86,910.98,910.98,1218963.0
-2017-08-16,925.29,932.7,923.445,926.96,988604.0,0.0,1.0,925.29,932.7,923.445,926.96,988604.0
-2017-08-15,924.23,926.5499,919.82,922.22,873070.0,0.0,1.0,924.23,926.5499,919.82,922.22,873070.0
-2017-08-14,922.53,924.668,918.19,922.67,1047828.0,0.0,1.0,922.53,924.668,918.19,922.67,1047828.0
-2017-08-11,907.97,917.78,905.58,914.39,1190458.0,0.0,1.0,907.97,917.78,905.58,914.39,1190458.0
-2017-08-10,917.55,919.26,906.13,907.24,1722296.0,0.0,1.0,917.55,919.26,906.13,907.24,1722296.0
-2017-08-09,920.61,925.98,917.2501,922.9,1169431.0,0.0,1.0,920.61,925.98,917.2501,922.9,1169431.0
-2017-08-08,927.09,935.814,925.6095,926.79,1039394.0,0.0,1.0,927.09,935.814,925.6095,926.79,1039394.0
-2017-08-07,929.06,931.7,926.5,929.36,1012296.0,0.0,1.0,929.06,931.7,926.5,929.36,1012296.0
-2017-08-04,926.75,930.3068,923.03,927.96,1019159.0,0.0,1.0,926.75,930.3068,923.03,927.96,1019159.0
-2017-08-03,930.34,932.24,922.24,923.65,1179126.0,0.0,1.0,930.34,932.24,922.24,923.65,1179126.0
-2017-08-02,928.61,932.6,916.68,930.39,1816343.0,0.0,1.0,928.61,932.6,916.68,930.39,1816343.0
-2017-08-01,932.38,937.447,929.26,930.83,1211553.0,0.0,1.0,932.38,937.447,929.26,930.83,1211553.0
-2017-07-31,941.89,943.59,926.04,930.5,1952716.0,0.0,1.0,941.89,943.59,926.04,930.5,1952716.0
-2017-07-28,929.4,943.83,927.5,941.53,1775076.0,0.0,1.0,929.4,943.83,927.5,941.53,1775076.0
-2017-07-27,951.78,951.78,920.0,934.09,3095263.0,0.0,1.0,951.78,951.78,920.0,934.09,3095263.0
-2017-07-26,954.68,955.0,942.2788,947.8,2056013.0,0.0,1.0,954.68,955.0,942.2788,947.8,2056013.0
-2017-07-25,953.81,959.7,945.4,950.7,4626086.0,0.0,1.0,953.81,959.7,945.4,950.7,4626086.0
-2017-07-24,972.22,986.2,970.77,980.34,2634669.0,0.0,1.0,972.22,986.2,970.77,980.34,2634669.0
-2017-07-21,962.25,973.23,960.15,972.92,1665103.0,0.0,1.0,962.25,973.23,960.15,972.92,1665103.0
-2017-07-20,975.0,975.9,961.51,968.15,1577103.0,0.0,1.0,975.0,975.9,961.51,968.15,1577103.0
-2017-07-19,967.84,973.04,964.03,970.89,1212814.0,0.0,1.0,967.84,973.04,964.03,970.89,1212814.0
-2017-07-18,953.0,968.04,950.6,965.4,1131130.0,0.0,1.0,953.0,968.04,950.6,965.4,1131130.0
-2017-07-17,957.0,960.74,949.2407,953.42,1141026.0,0.0,1.0,957.0,960.74,949.2407,953.42,1141026.0
-2017-07-14,952.0,956.91,948.005,955.99,1017632.0,0.0,1.0,952.0,956.91,948.005,955.99,1017632.0
-2017-07-13,946.29,954.45,943.01,947.16,1291782.0,0.0,1.0,946.29,954.45,943.01,947.16,1291782.0
-2017-07-12,938.68,946.3,934.47,943.83,1505982.0,0.0,1.0,938.68,946.3,934.47,943.83,1505982.0
-2017-07-11,929.54,931.43,922.0,930.09,1093281.0,0.0,1.0,929.54,931.43,922.0,930.09,1093281.0
-2017-07-10,921.77,930.38,919.59,928.8,1189085.0,0.0,1.0,921.77,930.38,919.59,928.8,1189085.0
-2017-07-07,908.85,921.54,908.85,918.59,1588034.0,0.0,1.0,908.85,921.54,908.85,918.59,1588034.0
-2017-07-06,904.12,914.9444,899.7,906.69,1409533.0,0.0,1.0,904.12,914.9444,899.7,906.69,1409533.0
-2017-07-05,901.76,914.51,898.5,911.94,1743497.0,0.0,1.0,901.76,914.51,898.5,911.94,1743497.0
-2017-07-03,912.18,913.94,894.79,898.7,1710189.0,0.0,1.0,912.18,913.94,894.79,898.7,1710189.0
-2017-06-30,926.05,926.05,908.31,908.73,2035931.0,0.0,1.0,926.05,926.05,908.31,908.73,2035931.0
-2017-06-29,929.92,931.26,910.62,917.79,3248393.0,0.0,1.0,929.92,931.26,910.62,917.79,3248393.0
-2017-06-28,929.0,942.75,916.0,940.49,2712222.0,0.0,1.0,929.0,942.75,916.0,940.49,2712222.0
-2017-06-27,942.46,948.29,926.85,927.33,2553771.0,0.0,1.0,942.46,948.29,926.85,927.33,2553771.0
-2017-06-26,969.9,973.31,950.79,952.27,1581031.0,0.0,1.0,969.9,973.31,950.79,952.27,1581031.0
-2017-06-23,956.83,966.0,954.2,965.59,1394008.0,0.0,1.0,956.83,966.0,954.2,965.59,1394008.0
-2017-06-22,958.7,960.72,954.55,957.09,940373.0,0.0,1.0,958.7,960.72,954.55,957.09,940373.0
-2017-06-21,953.64,960.1,950.76,959.45,1192342.0,0.0,1.0,953.64,960.1,950.76,959.45,1192342.0
-2017-06-20,957.52,961.62,950.01,950.63,1111840.0,0.0,1.0,957.52,961.62,950.01,950.63,1111840.0
-2017-06-19,949.96,959.99,949.05,957.37,1494191.0,0.0,1.0,949.96,959.99,949.05,957.37,1494191.0
-2017-06-16,940.0,942.04,931.595,939.78,2921393.0,0.0,1.0,940.0,942.04,931.595,939.78,2921393.0
-2017-06-15,933.97,943.339,924.44,942.31,2055953.0,0.0,1.0,933.97,943.339,924.44,942.31,2055953.0
-2017-06-14,959.92,961.15,942.25,950.76,1477033.0,0.0,1.0,959.92,961.15,942.25,950.76,1477033.0
-2017-06-13,951.91,959.98,944.09,953.4,1995350.0,0.0,1.0,951.91,959.98,944.09,953.4,1995350.0
-2017-06-12,939.56,949.355,915.2328,942.9,3731589.0,0.0,1.0,939.56,949.355,915.2328,942.9,3731589.0
-2017-06-09,984.5,984.5,935.63,949.83,3270248.0,0.0,1.0,984.5,984.5,935.63,949.83,3270248.0
-2017-06-08,982.35,984.57,977.2,983.41,1451232.0,0.0,1.0,982.35,984.57,977.2,983.41,1451232.0
-2017-06-07,979.65,984.15,975.77,981.08,1429834.0,0.0,1.0,979.65,984.15,975.77,981.08,1429834.0
-2017-06-06,983.16,988.25,975.14,976.57,1796904.0,0.0,1.0,983.16,988.25,975.14,976.57,1796904.0
-2017-06-05,976.55,986.91,975.1,983.68,1221971.0,0.0,1.0,976.55,986.91,975.1,983.68,1221971.0
-2017-06-02,969.46,975.88,966.0,975.6,1717212.0,0.0,1.0,969.46,975.88,966.0,975.6,1717212.0
-2017-06-01,968.95,971.5,960.01,966.95,1403200.0,0.0,1.0,968.95,971.5,960.01,966.95,1403200.0
diff --git a/examples/quick/demos/stocqt/content/data/GOOGL.csv b/examples/quick/demos/stocqt/content/data/GOOGL.csv
deleted file mode 100644
index 883f78e5f5..0000000000
--- a/examples/quick/demos/stocqt/content/data/GOOGL.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,1055.49,1058.05,1052.7,1053.4,1156357.0,0.0,1.0,1055.49,1058.05,1052.7,1053.4,1156357.0
-2017-12-28,1062.25,1064.84,1053.38,1055.95,982285.0,0.0,1.0,1062.25,1064.84,1053.38,1055.95,982285.0
-2017-12-27,1066.6,1068.27,1058.38,1060.2,1027634.0,0.0,1.0,1066.6,1068.27,1058.38,1060.2,1027634.0
-2017-12-26,1068.64,1068.86,1058.64,1065.85,914574.0,0.0,1.0,1068.64,1068.86,1058.64,1065.85,914574.0
-2017-12-22,1070.0,1071.72,1067.64,1068.86,860800.0,0.0,1.0,1070.0,1071.72,1067.64,1068.86,860800.0
-2017-12-21,1075.39,1077.52,1069.0,1070.85,1211012.0,0.0,1.0,1075.39,1077.52,1069.0,1070.85,1211012.0
-2017-12-20,1080.92,1081.23,1068.6,1073.56,1429035.0,0.0,1.0,1080.92,1081.23,1068.6,1073.56,1429035.0
-2017-12-19,1083.02,1084.97,1072.27,1079.78,1287930.0,0.0,1.0,1083.02,1084.97,1072.27,1079.78,1287930.0
-2017-12-18,1076.45,1086.49,1070.37,1085.09,1482768.0,0.0,1.0,1076.45,1086.49,1070.37,1085.09,1482768.0
-2017-12-15,1063.78,1075.25,1060.09,1072.0,3080738.0,0.0,1.0,1063.78,1075.25,1060.09,1072.0,3080738.0
-2017-12-14,1055.49,1067.08,1053.6,1057.47,1531504.0,0.0,1.0,1055.49,1067.08,1053.6,1057.47,1531504.0
-2017-12-13,1052.08,1055.48,1046.58,1051.39,1369580.0,0.0,1.0,1052.08,1055.48,1046.58,1051.39,1369580.0
-2017-12-12,1050.0,1062.5,1044.87,1048.77,1684977.0,0.0,1.0,1050.0,1062.5,1044.87,1048.77,1684977.0
-2017-12-11,1051.11,1056.0,1044.12,1051.97,1096997.0,0.0,1.0,1051.11,1056.0,1044.12,1051.97,1096997.0
-2017-12-08,1051.81,1056.42,1045.86,1049.38,1479665.0,0.0,1.0,1051.81,1056.42,1045.86,1049.38,1479665.0
-2017-12-07,1036.07,1048.92,1035.36,1044.57,1437448.0,0.0,1.0,1036.07,1048.92,1035.36,1044.57,1437448.0
-2017-12-06,1016.52,1039.58,1015.31,1032.72,1369276.0,0.0,1.0,1016.52,1039.58,1015.31,1032.72,1369276.0
-2017-12-05,1010.99,1036.68,1002.32,1019.6,1927802.0,0.0,1.0,1010.99,1036.68,1002.32,1019.6,1927802.0
-2017-12-04,1027.8,1031.34,1009.22,1011.87,1896325.0,0.0,1.0,1027.8,1031.34,1009.22,1011.87,1896325.0
-2017-12-01,1030.41,1037.24,1016.9,1025.07,1850541.0,0.0,1.0,1030.41,1037.24,1016.9,1025.07,1850541.0
-2017-11-30,1039.94,1044.14,1030.07,1036.17,2190379.0,0.0,1.0,1039.94,1044.14,1030.07,1036.17,2190379.0
-2017-11-29,1056.18,1058.77,1029.65,1037.38,2737664.0,0.0,1.0,1056.18,1058.77,1029.65,1037.38,2737664.0
-2017-11-28,1073.99,1080.0,1054.54,1063.29,1694098.0,0.0,1.0,1073.99,1080.0,1054.54,1063.29,1694098.0
-2017-11-27,1058.57,1073.04,1054.77,1072.01,1708195.0,0.0,1.0,1058.57,1073.04,1054.77,1072.01,1708195.0
-2017-11-24,1054.39,1060.07,1051.92,1056.52,825342.0,0.0,1.0,1054.39,1060.07,1051.92,1056.52,825342.0
-2017-11-22,1051.16,1055.43,1047.25,1051.92,721498.0,0.0,1.0,1051.16,1055.43,1047.25,1051.92,721498.0
-2017-11-21,1040.04,1050.39,1039.14,1050.3,1075568.0,0.0,1.0,1040.04,1050.39,1039.14,1050.3,1075568.0
-2017-11-20,1036.0,1038.7,1032.68,1034.66,850423.0,0.0,1.0,1036.0,1038.7,1032.68,1034.66,850423.0
-2017-11-17,1049.8,1051.0,1033.73,1035.89,1286044.0,0.0,1.0,1049.8,1051.0,1033.73,1035.89,1286044.0
-2017-11-16,1038.75,1051.76,1038.0,1048.47,1125995.0,0.0,1.0,1038.75,1051.76,1038.0,1048.47,1125995.0
-2017-11-15,1035.0,1039.63,1030.76,1036.41,900695.0,0.0,1.0,1035.0,1039.63,1030.76,1036.41,900695.0
-2017-11-14,1037.72,1042.3,1029.33,1041.64,982782.0,0.0,1.0,1037.72,1042.3,1029.33,1041.64,982782.0
-2017-11-13,1040.8,1048.74,1039.26,1041.2,914852.0,0.0,1.0,1040.8,1048.74,1039.26,1041.2,914852.0
-2017-11-10,1043.87,1046.63,1041.22,1044.15,955500.0,0.0,1.0,1043.87,1046.63,1041.22,1044.15,955500.0
-2017-11-09,1048.0,1050.88,1035.85,1047.72,1776722.0,0.0,1.0,1048.0,1050.88,1035.85,1047.72,1776722.0
-2017-11-07,1049.65,1053.41,1043.0,1052.39,1254965.0,0.0,1.0,1049.65,1053.41,1043.0,1052.39,1254965.0
-2017-11-06,1049.1,1052.59,1042.0,1042.68,897897.0,0.0,1.0,1049.1,1052.59,1042.0,1042.68,897897.0
-2017-11-03,1042.75,1050.66,1037.65,1049.99,1370874.0,0.0,1.0,1042.75,1050.66,1037.65,1049.99,1370874.0
-2017-11-02,1039.99,1045.52,1028.66,1042.97,1233333.0,0.0,1.0,1039.99,1045.52,1028.66,1042.97,1233333.0
-2017-11-01,1036.32,1047.86,1034.0,1042.6,2105729.0,0.0,1.0,1036.32,1047.86,1034.0,1042.6,2105729.0
-2017-10-31,1033.0,1041.0,1026.3,1033.04,1490660.0,0.0,1.0,1033.0,1041.0,1026.3,1033.04,1490660.0
-2017-10-30,1029.16,1039.83,1022.33,1033.13,2245352.0,0.0,1.0,1029.16,1039.83,1022.33,1033.13,2245352.0
-2017-10-27,1030.99,1063.62,1026.85,1033.67,5139945.0,0.0,1.0,1030.99,1063.62,1026.85,1033.67,5139945.0
-2017-10-26,998.47,1006.51,990.47,991.42,1827682.0,0.0,1.0,998.47,1006.51,990.47,991.42,1827682.0
-2017-10-25,986.27,994.43,977.722,991.46,1368042.0,0.0,1.0,986.27,994.43,977.722,991.46,1368042.0
-2017-10-24,986.5,989.26,977.08,988.49,1416283.0,0.0,1.0,986.5,989.26,977.08,988.49,1416283.0
-2017-10-23,1005.18,1005.79,983.1,985.54,1623580.0,0.0,1.0,1005.18,1005.79,983.1,985.54,1623580.0
-2017-10-20,1007.05,1008.65,1002.27,1005.07,1568454.0,0.0,1.0,1007.05,1008.65,1002.27,1005.07,1568454.0
-2017-10-19,1004.75,1007.32,997.3,1001.84,1677021.0,0.0,1.0,1004.75,1007.32,997.3,1001.84,1677021.0
-2017-10-18,1011.05,1016.31,1005.32,1012.74,1270218.0,0.0,1.0,1011.05,1016.31,1005.32,1012.74,1270218.0
-2017-10-17,1007.44,1014.56,1006.05,1011.0,991412.0,0.0,1.0,1007.44,1014.56,1006.05,1011.0,991412.0
-2017-10-16,1009.63,1012.0,1001.52,1009.35,1066744.0,0.0,1.0,1009.63,1012.0,1001.52,1009.35,1066744.0
-2017-10-13,1009.11,1014.76,1007.06,1007.87,1308881.0,0.0,1.0,1009.11,1014.76,1007.06,1007.87,1308881.0
-2017-10-12,1003.84,1011.54,1001.1,1005.65,1521137.0,0.0,1.0,1003.84,1011.54,1001.1,1005.65,1521137.0
-2017-10-11,989.04,1007.56,987.94,1005.65,1748443.0,0.0,1.0,989.04,1007.56,987.94,1005.65,1748443.0
-2017-10-10,995.3,997.47,981.11,987.8,1158864.0,0.0,1.0,995.3,997.47,981.11,987.8,1158864.0
-2017-10-09,995.0,1000.46,991.5,992.31,1151035.0,0.0,1.0,995.0,1000.46,991.5,992.31,1151035.0
-2017-10-06,980.0,994.26,978.51,993.64,1490744.0,0.0,1.0,980.0,994.26,978.51,993.64,1490744.0
-2017-10-05,972.79,986.5085,970.27,985.19,1627255.0,0.0,1.0,972.79,986.5085,970.27,985.19,1627255.0
-2017-10-04,971.76,974.4,965.61,966.78,896531.0,0.0,1.0,971.76,974.4,965.61,966.78,896531.0
-2017-10-03,967.56,972.44,962.705,972.08,1080312.0,0.0,1.0,967.56,972.44,962.705,972.08,1080312.0
-2017-10-02,975.65,977.74,961.95,967.47,1466444.0,0.0,1.0,975.65,977.74,961.95,967.47,1466444.0
-2017-09-29,966.0,975.81,966.0,973.72,1906445.0,0.0,1.0,966.0,975.81,966.0,973.72,1906445.0
-2017-09-28,956.25,966.18,955.55,964.81,1347750.0,0.0,1.0,956.25,966.18,955.55,964.81,1347750.0
-2017-09-27,942.74,965.43,941.95,959.9,2313498.0,0.0,1.0,942.74,965.43,941.95,959.9,2313498.0
-2017-09-26,936.69,944.08,935.12,937.43,1618182.0,0.0,1.0,936.69,944.08,935.12,937.43,1618182.0
-2017-09-25,939.45,939.75,924.5101,934.28,1847436.0,0.0,1.0,939.45,939.75,924.5101,934.28,1847436.0
-2017-09-22,942.77,950.0,940.835,943.26,1067617.0,0.0,1.0,942.77,950.0,940.835,943.26,1067617.0
-2017-09-21,948.13,952.8,939.38,947.55,1302726.0,0.0,1.0,948.13,952.8,939.38,947.55,1302726.0
-2017-09-20,937.73,950.0,937.5,947.54,1896919.0,0.0,1.0,937.73,950.0,937.5,947.54,1896919.0
-2017-09-19,933.41,937.94,926.66,936.86,1217430.0,0.0,1.0,933.41,937.94,926.66,936.86,1217430.0
-2017-09-18,935.01,936.86,925.4,929.75,1445532.0,0.0,1.0,935.01,936.86,925.4,929.75,1445532.0
-2017-09-15,940.09,941.75,931.25,935.29,1940047.0,0.0,1.0,940.09,941.75,931.25,935.29,1940047.0
-2017-09-14,946.0,948.03,938.356,940.13,1415168.0,0.0,1.0,946.0,948.03,938.356,940.13,1415168.0
-2017-09-13,945.5,952.85,944.74,950.44,1092849.0,0.0,1.0,945.5,952.85,944.74,950.44,1092849.0
-2017-09-12,946.92,948.085,937.5,946.65,1245767.0,0.0,1.0,946.92,948.085,937.5,946.65,1245767.0
-2017-09-11,947.2,952.68,941.0,943.29,1317796.0,0.0,1.0,947.2,952.68,941.0,943.29,1317796.0
-2017-09-08,949.7,950.7,940.01,941.41,996449.0,0.0,1.0,949.7,950.7,940.01,941.41,996449.0
-2017-09-07,944.25,950.4965,937.53,949.89,1103286.0,0.0,1.0,944.25,950.4965,937.53,949.89,1103286.0
-2017-09-06,943.87,944.5,932.68,942.02,1375952.0,0.0,1.0,943.87,944.5,932.68,942.02,1375952.0
-2017-09-05,946.86,951.3854,935.6,941.48,1455058.0,0.0,1.0,946.86,951.3854,935.6,941.48,1455058.0
-2017-09-01,957.47,958.33,950.28,951.99,1034769.0,0.0,1.0,957.47,958.33,950.28,951.99,1034769.0
-2017-08-31,946.3,957.195,946.25,955.24,1672387.0,0.0,1.0,946.3,957.195,946.25,955.24,1672387.0
-2017-08-30,935.67,945.86,934.05,943.63,1112814.0,0.0,1.0,935.67,945.86,934.05,943.63,1112814.0
-2017-08-29,919.95,938.19,919.31,935.75,1144834.0,0.0,1.0,919.95,938.19,919.31,935.75,1144834.0
-2017-08-28,931.88,934.85,926.11,928.13,1025199.0,0.0,1.0,931.88,934.85,926.11,928.13,1025199.0
-2017-08-25,939.21,940.73,930.1,930.5,1169101.0,0.0,1.0,939.21,940.73,930.1,930.5,1169101.0
-2017-08-24,943.71,946.31,930.74,936.89,1249098.0,0.0,1.0,943.71,946.31,930.74,936.89,1249098.0
-2017-08-23,937.0,945.425,935.24,942.58,1126487.0,0.0,1.0,937.0,945.425,935.24,942.58,1126487.0
-2017-08-22,926.96,941.9617,926.17,940.4,1711377.0,0.0,1.0,926.96,941.9617,926.17,940.4,1711377.0
-2017-08-21,925.77,928.25,918.6,920.87,1292624.0,0.0,1.0,925.77,928.25,918.6,920.87,1292624.0
-2017-08-18,926.98,931.02,923.45,926.18,1327288.0,0.0,1.0,926.98,931.02,923.45,926.18,1327288.0
-2017-08-17,942.95,943.81,927.64,927.66,1653779.0,0.0,1.0,942.95,943.81,927.64,927.66,1653779.0
-2017-08-16,941.25,949.9,940.0391,944.27,1329301.0,0.0,1.0,941.25,949.9,940.0391,944.27,1329301.0
-2017-08-15,941.03,943.07,936.64,938.08,1006064.0,0.0,1.0,941.03,943.07,936.64,938.08,1006064.0
-2017-08-14,939.07,941.04,934.485,938.93,1140212.0,0.0,1.0,939.07,941.04,934.485,938.93,1140212.0
-2017-08-11,923.71,933.36,921.22,930.09,1589808.0,0.0,1.0,923.71,933.36,921.22,930.09,1589808.0
-2017-08-10,935.0,936.3,921.7768,923.59,2657279.0,0.0,1.0,935.0,936.3,921.7768,923.59,2657279.0
-2017-08-09,938.45,943.76,933.92,940.08,1360604.0,0.0,1.0,938.45,943.76,933.92,940.08,1360604.0
-2017-08-08,944.29,952.49,942.48,944.19,1438418.0,0.0,1.0,944.29,952.49,942.48,944.19,1438418.0
-2017-08-07,947.52,948.96,943.5,945.75,1405132.0,0.0,1.0,947.52,948.96,943.5,945.75,1405132.0
-2017-08-04,943.95,947.54,939.795,945.79,1192871.0,0.0,1.0,943.95,947.54,939.795,945.79,1192871.0
-2017-08-03,949.1,950.0,939.44,940.3,1028591.0,0.0,1.0,949.1,950.0,939.44,940.3,1028591.0
-2017-08-02,948.37,949.1,932.521,947.64,2019979.0,0.0,1.0,948.37,949.1,932.521,947.64,2019979.0
-2017-08-01,947.81,954.49,944.96,946.56,1205799.0,0.0,1.0,947.81,954.49,944.96,946.56,1205799.0
-2017-07-31,960.0,961.1925,941.725,945.5,2268160.0,0.0,1.0,960.0,961.1925,941.725,945.5,2268160.0
-2017-07-28,947.99,961.79,945.31,958.33,1795477.0,0.0,1.0,947.99,961.79,945.31,958.33,1795477.0
-2017-07-27,969.18,969.52,937.06,952.51,3685905.0,0.0,1.0,969.18,969.52,937.06,952.51,3685905.0
-2017-07-26,972.78,973.95,960.23,965.31,2166225.0,0.0,1.0,972.78,973.95,960.23,965.31,2166225.0
-2017-07-25,970.7,976.73,963.8,969.03,5793414.0,0.0,1.0,970.7,976.73,963.8,969.03,5793414.0
-2017-07-24,994.1,1006.19,990.2728,998.31,3053176.0,0.0,1.0,994.1,1006.19,990.2728,998.31,3053176.0
-2017-07-21,989.0,995.11,984.17,993.84,1412108.0,0.0,1.0,989.0,995.11,984.17,993.84,1412108.0
-2017-07-20,997.0,998.68,984.62,992.19,1410290.0,0.0,1.0,997.0,998.68,984.62,992.19,1410290.0
-2017-07-19,990.01,995.6,987.01,992.77,1392709.0,0.0,1.0,990.01,995.6,987.01,992.77,1392709.0
-2017-07-18,973.36,990.85,972.04,986.95,1398920.0,0.0,1.0,973.36,990.85,972.04,986.95,1398920.0
-2017-07-17,976.32,983.35,970.8,975.96,1644618.0,0.0,1.0,976.32,983.35,970.8,975.96,1644618.0
-2017-07-14,974.0,977.54,970.15,976.91,1048240.0,0.0,1.0,974.0,977.54,970.15,976.91,1048240.0
-2017-07-13,970.8,978.7,964.8,968.7175,1519987.0,0.0,1.0,970.8,978.7,964.8,968.7175,1519987.0
-2017-07-12,960.86,969.63,957.04,967.66,1589548.0,0.0,1.0,960.86,969.63,957.04,967.66,1589548.0
-2017-07-11,950.52,954.89,945.12,953.53,1444540.0,0.0,1.0,950.52,954.89,945.12,953.53,1444540.0
-2017-07-10,941.95,953.13,941.95,951.0,1409850.0,0.0,1.0,941.95,953.13,941.95,951.0,1409850.0
-2017-07-07,930.985,944.66,929.79,940.81,1614080.0,0.0,1.0,930.985,944.66,929.79,940.81,1614080.0
-2017-07-06,925.0,936.14,919.85,927.69,1941822.0,0.0,1.0,925.0,936.14,919.85,927.69,1941822.0
-2017-07-05,924.2,936.29,918.6305,932.26,2054927.0,0.0,1.0,924.2,936.29,918.6305,932.26,2054927.0
-2017-07-03,933.22,934.24,915.31,919.46,1694587.0,0.0,1.0,933.22,934.24,915.31,919.46,1694587.0
-2017-06-30,943.99,944.9995,929.61,929.68,2185444.0,0.0,1.0,943.99,944.9995,929.61,929.68,2185444.0
-2017-06-29,951.35,951.66,929.6,937.82,3182331.0,0.0,1.0,951.35,951.66,929.6,937.82,3182331.0
-2017-06-28,950.66,963.24,936.16,961.01,2713366.0,0.0,1.0,950.66,963.24,936.16,961.01,2713366.0
-2017-06-27,961.6,967.22,947.09,948.09,2428048.0,0.0,1.0,961.6,967.22,947.09,948.09,2428048.0
-2017-06-26,990.0,993.99,970.33,972.09,1505655.0,0.0,1.0,990.0,993.99,970.33,972.09,1505655.0
-2017-06-23,975.5,986.62,974.46,986.09,1439728.0,0.0,1.0,975.5,986.62,974.46,986.09,1439728.0
-2017-06-22,976.87,980.5,973.3148,976.62,940086.0,0.0,1.0,976.87,980.5,973.3148,976.62,940086.0
-2017-06-21,970.79,979.67,969.16,978.59,1141315.0,0.0,1.0,970.79,979.67,969.16,978.59,1141315.0
-2017-06-20,975.31,980.79,968.2,968.99,1273013.0,0.0,1.0,975.31,980.79,968.2,968.99,1273013.0
-2017-06-19,969.65,979.3,968.2,975.22,1449343.0,0.0,1.0,969.65,979.3,968.2,975.22,1449343.0
-2017-06-16,957.91,959.95,948.7,958.62,2484914.0,0.0,1.0,957.91,959.95,948.7,958.62,2484914.0
-2017-06-15,948.02,960.6775,940.37,960.18,2349212.0,0.0,1.0,948.02,960.6775,940.37,960.18,2349212.0
-2017-06-14,975.5,979.7,959.5103,967.93,1489046.0,0.0,1.0,975.5,979.7,959.5103,967.93,1489046.0
-2017-06-13,972.04,977.91,962.01,970.5,1992456.0,0.0,1.0,972.04,977.91,962.01,970.5,1992456.0
-2017-06-12,958.72,968.0,936.795,961.81,4167184.0,0.0,1.0,958.72,968.0,936.795,961.81,4167184.0
-2017-06-09,1005.49,1005.5,953.37,970.12,3613964.0,0.0,1.0,1005.49,1005.5,953.37,970.12,3613964.0
-2017-06-08,1004.23,1005.6,996.62,1004.28,1657881.0,0.0,1.0,1004.23,1005.6,996.62,1004.28,1657881.0
-2017-06-07,998.82,1003.91,995.81,1001.59,1348198.0,0.0,1.0,998.82,1003.91,995.81,1001.59,1348198.0
-2017-06-06,1003.31,1008.61,994.8,996.68,1517356.0,0.0,1.0,1003.31,1008.61,994.8,996.68,1517356.0
-2017-06-05,997.89,1007.4,995.45,1003.88,1353264.0,0.0,1.0,997.89,1007.4,995.45,1003.88,1353264.0
-2017-06-02,988.59,996.48,987.07,996.12,1719720.0,0.0,1.0,988.59,996.48,987.07,996.12,1719720.0
-2017-06-01,990.96,993.14,981.29,988.29,1295552.0,0.0,1.0,990.96,993.14,981.29,988.29,1295552.0
diff --git a/examples/quick/demos/stocqt/content/data/INTC.csv b/examples/quick/demos/stocqt/content/data/INTC.csv
deleted file mode 100644
index 9e762ffb43..0000000000
--- a/examples/quick/demos/stocqt/content/data/INTC.csv
+++ /dev/null
@@ -1,147 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,46.21,46.49,46.09,46.16,17136416.0,0.0,1.0,46.21,46.49,46.09,46.16,17136416.0
-2017-12-28,46.36,46.36,45.95,46.22,9279766.0,0.0,1.0,46.36,46.36,45.95,46.22,9279766.0
-2017-12-27,46.11,46.36,46.0,46.11,12412977.0,0.0,1.0,46.11,46.36,46.0,46.11,12412977.0
-2017-12-26,46.28,46.47,45.95,46.08,15477747.0,0.0,1.0,46.28,46.47,45.95,46.08,15477747.0
-2017-12-22,46.33,47.02,46.02,46.7,33404280.0,0.0,1.0,46.33,47.02,46.02,46.7,33404280.0
-2017-12-21,47.54,47.59,46.56,46.76,42113273.0,0.0,1.0,47.54,47.59,46.56,46.76,42113273.0
-2017-12-20,47.47,47.64,46.66,47.56,39536777.0,0.0,1.0,47.47,47.64,46.66,47.56,39536777.0
-2017-12-19,46.3,47.26,45.89,47.04,39973826.0,0.0,1.0,46.3,47.26,45.89,47.04,39973826.0
-2017-12-18,45.15,46.35,45.04,46.26,49305190.0,0.0,1.0,45.15,46.35,45.04,46.26,49305190.0
-2017-12-15,43.4,44.84,43.07,44.56,44377039.0,0.0,1.0,43.4,44.84,43.07,44.56,44377039.0
-2017-12-14,43.43,43.57,43.015,43.26,18871565.0,0.0,1.0,43.43,43.57,43.015,43.26,18871565.0
-2017-12-13,43.65,43.66,43.24,43.34,21055298.0,0.0,1.0,43.65,43.66,43.24,43.34,21055298.0
-2017-12-12,43.47,43.62,43.08,43.33,15571482.0,0.0,1.0,43.47,43.62,43.08,43.33,15571482.0
-2017-12-11,43.28,43.78,43.25,43.66,18840783.0,0.0,1.0,43.28,43.78,43.25,43.66,18840783.0
-2017-12-08,43.35,43.58,43.11,43.35,22833083.0,0.0,1.0,43.35,43.58,43.11,43.35,22833083.0
-2017-12-07,43.46,43.6,42.78,43.08,31193561.0,0.0,1.0,43.46,43.6,42.78,43.08,31193561.0
-2017-12-06,43.14,43.72,42.67,43.45,24497550.0,0.0,1.0,43.14,43.72,42.67,43.45,24497550.0
-2017-12-05,44.6,44.9,43.23,43.44,30112131.0,0.0,1.0,44.6,44.9,43.23,43.44,30112131.0
-2017-12-04,45.02,45.3,44.33,44.49,26829460.0,0.0,1.0,45.02,45.3,44.33,44.49,26829460.0
-2017-12-01,44.73,44.84,43.53,44.68,26393385.0,0.0,1.0,44.73,44.84,43.53,44.68,26393385.0
-2017-11-30,44.36,45.2,44.33,44.84,32735416.0,0.0,1.0,44.36,45.2,44.33,44.84,32735416.0
-2017-11-29,44.85,45.09,43.77,43.95,26246867.0,0.0,1.0,44.85,45.09,43.77,43.95,26246867.0
-2017-11-28,44.65,44.84,44.32,44.73,19084500.0,0.0,1.0,44.65,44.84,44.32,44.73,19084500.0
-2017-11-27,44.42,44.61,44.2736,44.49,17187942.0,0.0,1.0,44.42,44.61,44.2736,44.49,17187942.0
-2017-11-24,44.55,44.775,44.43,44.75,6465615.0,0.0,1.0,44.55,44.775,44.43,44.75,6465615.0
-2017-11-22,44.94,44.95,44.535,44.65,19191241.0,0.0,1.0,44.94,44.95,44.535,44.65,19191241.0
-2017-11-21,44.72,45.22,44.71,44.94,20730988.0,0.0,1.0,44.72,45.22,44.71,44.94,20730988.0
-2017-11-20,44.73,45.115,44.5,44.62,22162614.0,0.0,1.0,44.73,45.115,44.5,44.62,22162614.0
-2017-11-17,45.5,45.62,44.62,44.63,62637555.0,0.0,1.0,45.5,45.62,44.62,44.63,62637555.0
-2017-11-16,45.63,46.07,45.46,45.65,21446297.0,0.0,1.0,45.63,46.07,45.46,45.65,21446297.0
-2017-11-15,45.39,45.805,45.1725,45.46,16781344.0,0.0,1.0,45.39,45.805,45.1725,45.46,16781344.0
-2017-11-14,45.7,45.92,45.32,45.86,20747874.0,0.0,1.0,45.7,45.92,45.32,45.86,20747874.0
-2017-11-13,45.26,45.94,45.25,45.75,18923183.0,0.0,1.0,45.26,45.94,45.25,45.75,18923183.0
-2017-11-10,46.04,46.09,45.38,45.58,23953470.0,0.0,1.0,46.04,46.09,45.38,45.58,23953470.0
-2017-11-09,46.05,46.39,45.65,46.3,24830309.0,0.0,1.0,46.05,46.39,45.65,46.3,24830309.0
-2017-11-07,46.7,47.09,46.39,46.78,23074092.0,0.0,1.0,46.7,47.09,46.39,46.78,23074092.0
-2017-11-06,46.6,46.74,46.09,46.7,31865449.0,0.273,1.0,46.329167819811,46.468354160901,45.822131862985,46.428586634875,31865449.0
-2017-11-03,47.2,47.3,45.6,46.34,38647115.0,0.0,1.0,46.652955722779,46.751796730667,45.071499596583,45.802923054949,38647115.0
-2017-11-02,46.61,47.23,46.213,47.1,37260192.0,0.0,1.0,46.069793776245,46.682608025146,45.677394974932,46.554114714892,37260192.0
-2017-11-01,45.97,46.71,45.59,46.71,47077781.0,0.0,1.0,45.437211325766,46.168634784132,45.061615495795,46.168634784132,47077781.0
-2017-10-31,45.2,45.8,44.65,45.49,46206973.0,0.0,1.0,44.676135565035,45.269181612358,44.132510021655,44.962774487908,46206973.0
-2017-10-30,44.48,45.19,43.88,44.37,46012316.0,0.0,1.0,43.964480308246,44.666251464246,43.371434260923,43.85575519957,46012316.0
-2017-10-27,43.3,45.0,43.1,44.4,88413551.0,0.0,1.0,42.798156415177,44.47845354926,42.600474399402,43.885407501937,88413551.0
-2017-10-26,40.91,41.575,40.71,41.35,35618913.0,0.0,1.0,40.435856326672,41.093149029122,40.238174310897,40.870756761376,35618913.0
-2017-10-25,40.89,41.055,40.49,40.78,23079947.0,0.0,1.0,40.416088125094,40.579175788108,40.020724093545,40.307363016418,23079947.0
-2017-10-24,41.0,41.05,40.72,40.95,18616857.0,0.0,1.0,40.52481323377,40.574233737714,40.248058411686,40.475392729827,18616857.0
-2017-10-23,40.55,41.04,40.395,40.83,28306520.0,0.0,1.0,40.080028698278,40.564349636925,39.926825136052,40.356783520362,28306520.0
-2017-10-20,40.33,40.45,40.1,40.43,17556315.0,0.0,1.0,39.862578480926,39.98118769039,39.635244162785,39.961419488813,17556315.0
-2017-10-19,39.88,40.33,39.83,40.09,18541779.0,0.0,1.0,39.417793945433,39.862578480926,39.368373441489,39.625360061996,18541779.0
-2017-10-18,39.8,40.29,39.6,40.25,20592939.0,0.0,1.0,39.338721139123,39.823042077771,39.141039123349,39.783505674616,20592939.0
-2017-10-17,39.56,39.865,39.37,39.79,15300505.0,0.0,1.0,39.101502720194,39.40296779425,38.913704805208,39.328837038335,15300505.0
-2017-10-16,39.71,39.79,39.44,39.76,12448746.0,0.0,1.0,39.249764232025,39.328837038335,38.982893510729,39.299184735968,12448746.0
-2017-10-13,39.44,39.81,39.28,39.67,16611521.0,0.0,1.0,38.982893510729,39.348605239912,38.82474789811,39.21022782887,16611521.0
-2017-10-12,39.35,39.39,38.98,39.19,18236204.0,0.0,1.0,38.893936603631,38.933473006786,38.528224874448,38.735790991011,18236204.0
-2017-10-11,39.48,39.67,39.06,39.3,30452182.0,0.0,1.0,39.022429913884,39.21022782887,38.607297680758,38.844516099687,30452182.0
-2017-10-10,39.93,39.95,39.38,39.65,29838331.0,0.0,1.0,39.467214449377,39.486982650954,38.923588905997,39.190459627292,29838331.0
-2017-10-09,39.68,39.88,39.52,39.86,18372360.0,0.0,1.0,39.220111929659,39.417793945433,39.061966317039,39.398025743856,18372360.0
-2017-10-06,39.6,39.89,39.42,39.63,18063051.0,0.0,1.0,39.141039123349,39.427678046222,38.963125309152,39.170691425715,18063051.0
-2017-10-05,39.5,39.65,39.21,39.53,17588371.0,0.0,1.0,39.042198115462,39.190459627292,38.755559192589,39.071850417828,17588371.0
-2017-10-04,39.39,39.4,38.8606,39.34,27900633.0,0.0,1.0,38.933473006786,38.943357107574,38.410208711031,38.884052502842,27900633.0
-2017-10-03,38.95,39.7,38.95,39.38,33266885.0,0.0,1.0,38.498572572082,39.239880131236,38.498572572082,38.923588905997,33266885.0
-2017-10-02,38.12,39.09,38.08,39.04,36985170.0,0.0,1.0,37.678192206618,38.636949983124,37.638655803463,38.58752947918,36985170.0
-2017-09-29,37.84,38.15,37.7,38.08,22617651.0,0.0,1.0,37.401437384533,37.707844508984,37.263059973491,37.638655803463,22617651.0
-2017-09-28,37.32,37.88,37.29,37.83,20601061.0,0.0,1.0,36.88746414352,37.440973787688,36.857811841153,37.391553283745,20601061.0
-2017-09-27,37.62,37.69,37.1,37.54,25457387.0,0.0,1.0,37.183987167181,37.253175872702,36.670013926168,37.104914360872,25457387.0
-2017-09-26,37.21,37.64,37.0,37.47,29198356.0,0.0,1.0,36.778739034844,37.203755368759,36.57117291828,37.035725655351,29198356.0
-2017-09-25,37.05,37.23,36.85,37.16,22158905.0,0.0,1.0,36.620593422224,36.798507236421,36.42291140645,36.7293185309,22158905.0
-2017-09-22,36.95,37.22,36.95,37.18,20928369.0,0.0,1.0,36.521752414337,36.788623135632,36.521752414337,36.749086732477,20928369.0
-2017-09-21,36.99,37.27,36.85,37.2,20175216.0,0.0,1.0,36.561288817492,36.838043639576,36.42291140645,36.768854934055,20175216.0
-2017-09-20,37.23,37.29,36.655,37.07,23127098.0,0.0,1.0,36.798507236421,36.857811841153,36.230171441069,36.640361623802,23127098.0
-2017-09-19,37.2,37.295,37.02,37.23,21823446.0,0.0,1.0,36.768854934055,36.862753891548,36.590941119858,36.798507236421,21823446.0
-2017-09-18,37.0,37.33,36.8,37.0,19083499.0,0.0,1.0,36.57117291828,36.897348244308,36.373490902506,36.57117291828,19083499.0
-2017-09-15,36.55,37.08,36.22,37.0,32109972.0,0.0,1.0,36.126388382788,36.65024572459,35.80021305676,36.57117291828,32109972.0
-2017-09-14,36.19,36.695,36.16,36.48,17902903.0,0.0,1.0,35.770560754394,36.269707844224,35.740908452028,36.057199677267,17902903.0
-2017-09-13,36.0,36.4,35.97,36.33,15069601.0,0.0,1.0,35.582762839408,35.978126870957,35.553110537042,35.908938165436,15069601.0
-2017-09-12,35.88,36.34,35.74,36.09,19061818.0,0.0,1.0,35.464153629943,35.918822266225,35.325776218901,35.671719746507,19061818.0
-2017-09-11,35.49,36.0,35.14,35.77,18895979.0,0.0,1.0,35.078673699183,35.582762839408,34.732730171578,35.355428521267,18895979.0
-2017-09-08,35.42,35.54,35.08,35.19,13881093.0,0.0,1.0,35.009484993662,35.128094203127,34.673425566845,34.782150675521,13881093.0
-2017-09-07,35.88,35.95,35.33,35.54,16045217.0,0.0,1.0,35.464153629943,35.533342335464,34.920528086563,35.128094203127,16045217.0
-2017-09-06,35.22,35.94,35.11,35.76,26811090.0,0.0,1.0,34.811802977888,35.523458234676,34.703077869212,35.345544420479,26811090.0
-2017-09-05,35.02,35.33,34.93,35.02,18665229.0,0.0,1.0,34.614120962113,34.920528086563,34.525164055014,34.614120962113,18665229.0
-2017-09-01,35.24,35.39,35.07,35.085,12713069.0,0.0,1.0,34.831571179465,34.979832691296,34.663541466057,34.67836761724,12713069.0
-2017-08-31,34.94,35.18,34.87,35.07,15959145.0,0.0,1.0,34.535048155803,34.772266574733,34.465859450282,34.663541466057,15959145.0
-2017-08-30,34.75,34.96,34.63,34.89,18230633.0,0.0,1.0,34.347250240817,34.554816357381,34.228641031353,34.48562765186,18230633.0
-2017-08-29,34.51,34.75,34.455,34.73,15605382.0,0.0,1.0,34.110031821888,34.347250240817,34.05566926755,34.32748203924,15605382.0
-2017-08-28,34.78,34.8,34.59,34.65,20463229.0,0.0,1.0,34.376902543184,34.396670744761,34.189104628198,34.24840923293,20463229.0
-2017-08-25,34.82,34.93,34.58,34.67,14126663.0,0.0,1.0,34.416438946339,34.525164055014,34.179220527409,34.268177434508,14126663.0
-2017-08-24,34.7,34.89,34.55,34.71,13495890.0,0.0,1.0,34.297829736874,34.48562765186,34.149568225043,34.307713837663,13495890.0
-2017-08-23,34.54,34.81,34.38,34.66,19439392.0,0.0,1.0,34.139684124254,34.40655484555,33.981538511635,34.258293333719,19439392.0
-2017-08-22,35.02,35.19,34.62,34.65,25496798.0,0.0,1.0,34.614120962113,34.782150675521,34.218756930564,34.24840923293,25496798.0
-2017-08-21,35.09,35.28,34.7,34.92,25642017.0,0.0,1.0,34.683309667634,34.87110758262,34.297829736874,34.515279954226,25642017.0
-2017-08-18,35.29,35.31,34.99,35.01,15556756.0,0.0,1.0,34.880991683409,34.900759884986,34.584468659747,34.604236861324,15556756.0
-2017-08-17,35.6,35.68,35.17,35.17,18464078.0,0.0,1.0,35.187398807859,35.266471614169,34.762382473944,34.762382473944,18464078.0
-2017-08-16,35.98,36.07,35.56,35.82,21319536.0,0.0,1.0,35.562994637831,35.651951544929,35.147862404704,35.404849025211,21319536.0
-2017-08-15,36.3,36.32,35.815,36.0,20630421.0,0.0,1.0,35.87928586307,35.899054064647,35.399906974817,35.582762839408,20630421.0
-2017-08-14,36.12,36.47,36.08,36.34,16255600.0,0.0,1.0,35.701372048873,36.047315576478,35.661835645718,35.918822266225,16255600.0
-2017-08-11,36.26,36.4,35.79,35.87,18697159.0,0.0,1.0,35.839749459915,35.978126870957,35.375196722845,35.454269529155,18697159.0
-2017-08-10,36.4,36.56,36.11,36.12,22414962.0,0.0,1.0,35.978126870957,36.136272483577,35.691487948084,35.701372048873,22414962.0
-2017-08-09,36.28,36.66,36.02,36.59,22596679.0,0.0,1.0,35.859517661492,36.235113491464,35.602531040985,36.165924785943,22596679.0
-2017-08-08,36.37,36.7,36.3,36.41,21067835.0,0.0,1.0,35.948474568591,36.274649894619,35.87928586307,35.988010971746,21067835.0
-2017-08-04,36.45,36.56,36.1,36.3,20312844.0,0.0,1.0,36.027547374901,36.136272483577,35.681603847295,35.87928586307,20312844.0
-2017-08-03,36.55,36.59,36.15,36.49,26377878.0,0.273,1.0,36.126388382788,36.165924785943,35.731024351239,36.067083778056,26377878.0
-2017-08-02,36.33,36.67,36.055,36.64,34502824.0,0.0,1.0,35.642280381273,35.975844249416,35.372486076158,35.946412143404,34502824.0
-2017-08-01,35.66,36.43,35.57,36.35,37556349.0,0.0,1.0,34.984963346992,35.740387401316,34.896667028954,35.661901785282,37556349.0
-2017-07-31,35.47,35.74,35.32,35.47,26748090.0,0.0,1.0,34.798560008912,35.063448963025,34.651399478849,34.798560008912,26748090.0
-2017-07-28,35.13,35.86,35.0,35.31,35538732.0,0.0,1.0,34.464996140769,35.181177387076,34.337457014714,34.641588776845,35538732.0
-2017-07-27,34.78,35.25,34.67,34.97,39239149.0,0.0,1.0,34.121621570622,34.582724564819,34.013703848576,34.308024908702,39239149.0
-2017-07-26,34.7,34.97,34.59,34.75,15400452.0,0.0,1.0,34.043135954588,34.308024908702,33.935218232542,34.092189464609,15400452.0
-2017-07-25,34.55,34.735,34.4,34.67,17569006.0,0.0,1.0,33.895975424525,34.077473411603,33.748814894462,34.013703848576,17569006.0
-2017-07-24,34.73,34.8,34.38,34.5,15114242.0,0.0,1.0,34.072568060601,34.14124297463,33.729193490454,33.846921914504,15114242.0
-2017-07-21,34.54,34.82,34.395,34.73,21682999.0,0.0,1.0,33.886164722521,34.160864378639,33.74390954346,34.072568060601,21682999.0
-2017-07-20,34.54,34.84,34.475,34.75,16643270.0,0.0,1.0,33.886164722521,34.180485782647,33.822395159494,34.092189464609,16643270.0
-2017-07-19,34.68,34.68,34.46,34.56,15923372.0,0.0,1.0,34.02351455058,34.02351455058,33.807679106487,33.905786126529,15923372.0
-2017-07-18,34.43,34.58,34.25,34.53,14031968.0,0.0,1.0,33.778247000475,33.925407530538,33.601654364399,33.876354020517,14031968.0
-2017-07-17,34.74,34.74,34.36,34.47,20910434.0,0.0,1.0,34.082378762605,34.082378762605,33.709572086445,33.817489808492,20910434.0
-2017-07-14,34.48,34.71,34.265,34.68,16039785.0,0.0,1.0,33.827300510496,34.052946656592,33.616370417405,34.02351455058,16039785.0
-2017-07-13,34.33,34.4,34.12,34.24,14978889.0,0.0,1.0,33.680139980433,33.748814894462,33.474115238344,33.591843662395,14978889.0
-2017-07-12,34.28,34.39,33.94,34.25,23430086.0,0.0,1.0,33.631086470412,33.739004192458,33.297522602269,33.601654364399,23430086.0
-2017-07-11,33.64,33.93,33.4311,33.92,24800985.0,0.0,1.0,33.003201542143,33.287711900264,32.798255977275,33.27790119826,24800985.0
-2017-07-10,33.25,33.74,33.23,33.65,26781949.0,0.0,1.0,32.620584163979,33.101308562185,32.60096275997,33.013012244147,26781949.0
-2017-07-07,33.7,34.12,33.7,33.88,17702383.0,0.0,1.0,33.062065754168,33.474115238344,33.062065754168,33.238658390243,17702383.0
-2017-07-06,34.12,34.29,33.56,33.63,20161025.0,0.0,1.0,33.474115238344,33.640897172416,32.924715926109,32.993390840138,20161025.0
-2017-07-05,33.52,34.43,33.485,34.34,29307289.0,0.0,1.0,32.885473118092,33.778247000475,32.851135661077,33.689950682437,29307289.0
-2017-07-03,33.51,34.03,33.43,33.46,12676069.0,0.0,1.0,32.875662416088,33.385818920307,32.797176800054,32.826608906067,12676069.0
-2017-06-30,33.87,33.93,33.535,33.74,23636451.0,0.0,1.0,33.228847688239,33.287711900264,32.900189171098,33.101308562185,23636451.0
-2017-06-29,33.92,34.1,33.34,33.54,24613002.0,0.0,1.0,33.27790119826,33.454493834336,32.708880482016,32.905094522101,24613002.0
-2017-06-28,33.77,34.24,33.74,34.2,25777730.0,0.0,1.0,33.130740668197,33.591843662395,33.101308562185,33.552600854378,25777730.0
-2017-06-27,34.0,34.145,33.65,33.65,26891930.0,0.0,1.0,33.356386814294,33.498641993355,33.013012244147,33.013012244147,26891930.0
-2017-06-26,34.26,34.51,34.03,34.07,18379220.0,0.0,1.0,33.611465066403,33.856732616508,33.385818920307,33.425061728323,18379220.0
-2017-06-23,34.21,34.55,34.095,34.19,24381873.0,0.0,1.0,33.562411556382,33.895975424525,33.449588483334,33.542790152374,24381873.0
-2017-06-22,34.56,34.63,34.29,34.36,23744016.0,0.0,1.0,33.905786126529,33.974461040559,33.640897172416,33.709572086445,23744016.0
-2017-06-21,34.33,34.6,34.09,34.58,26338267.0,0.0,1.0,33.680139980433,33.945028934546,33.444683132332,33.925407530538,26338267.0
-2017-06-20,35.45,35.45,34.84,34.86,21024240.0,0.0,1.0,34.778938604904,34.778938604904,34.180485782647,34.200107186655,21024240.0
-2017-06-19,35.61,35.61,35.32,35.51,20336817.0,0.0,1.0,34.935909836971,34.935909836971,34.651399478849,34.837802816929,20336817.0
-2017-06-16,35.28,35.33,35.01,35.21,28353654.0,0.0,1.0,34.612156670832,34.661210180853,34.347267716719,34.543481756803,28353654.0
-2017-06-15,35.21,35.48,35.14,35.31,19954738.0,0.0,1.0,34.543481756803,34.808370710916,34.474806842773,34.641588776845,19954738.0
-2017-06-14,35.99,36.05,35.22,35.53,19001268.0,0.0,1.0,35.308716513131,35.367580725156,34.553292458807,34.857424220937,19001268.0
-2017-06-13,35.68,35.95,35.53,35.88,20398500.0,0.0,1.0,35.004584751,35.269473705114,34.857424220937,35.200798791084,20398500.0
-2017-06-12,35.59,36.01,35.41,35.73,27374877.0,0.0,1.0,34.916288432962,35.328337917139,34.739695796887,35.053638261021,27374877.0
-2017-06-09,36.5,36.56,35.31,35.71,32858966.0,0.0,1.0,35.809062315345,35.86792652737,34.641588776845,35.034016857013,32858966.0
-2017-06-08,36.34,36.53,36.16,36.48,16202388.0,0.0,1.0,35.652091083278,35.838494421358,35.475498447202,35.789440911337,16202388.0
-2017-06-07,36.13,36.57,36.1,36.26,16521287.0,0.0,1.0,35.446066341189,35.877737229374,35.416634235177,35.573605467244,16521287.0
-2017-06-06,36.16,36.45,35.98,36.13,18153646.0,0.0,1.0,35.475498447202,35.760008805324,35.298905811126,35.446066341189,18153646.0
-2017-06-05,36.3,36.5,36.2,36.34,11288983.0,0.0,1.0,35.612848275261,35.809062315345,35.514741255219,35.652091083278,11288983.0
-2017-06-02,36.27,36.33,36.0,36.32,18902927.0,0.0,1.0,35.583416169248,35.642280381273,35.318527215135,35.632469679269,18902927.0
-2017-06-01,36.12,36.13,35.8,36.12,17288864.0,0.0,1.0,35.436255639185,35.446066341189,35.122313175051,35.436255639185,17288864.0
diff --git a/examples/quick/demos/stocqt/content/data/MSFT.csv b/examples/quick/demos/stocqt/content/data/MSFT.csv
deleted file mode 100644
index 056639e4c2..0000000000
--- a/examples/quick/demos/stocqt/content/data/MSFT.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,85.63,86.05,85.5,85.54,18162779.0,0.0,1.0,85.63,86.05,85.5,85.54,18162779.0
-2017-12-28,85.9,85.93,85.55,85.72,9872795.0,0.0,1.0,85.9,85.93,85.55,85.72,9872795.0
-2017-12-27,85.65,85.98,85.215,85.71,13000828.0,0.0,1.0,85.65,85.98,85.215,85.71,13000828.0
-2017-12-26,85.31,85.5346,85.03,85.4,9737412.0,0.0,1.0,85.31,85.5346,85.03,85.4,9737412.0
-2017-12-22,85.4,85.63,84.92,85.51,14033977.0,0.0,1.0,85.4,85.63,84.92,85.51,14033977.0
-2017-12-21,86.05,86.1,85.4,85.5,16638402.0,0.0,1.0,86.05,86.1,85.4,85.5,16638402.0
-2017-12-20,86.2,86.3,84.71,85.52,23425009.0,0.0,1.0,86.2,86.3,84.71,85.52,23425009.0
-2017-12-19,86.35,86.35,85.27,85.83,23241979.0,0.0,1.0,86.35,86.35,85.27,85.83,23241979.0
-2017-12-18,87.12,87.4999,86.23,86.38,21551076.0,0.0,1.0,87.12,87.4999,86.23,86.38,21551076.0
-2017-12-15,85.26,87.09,84.88,86.85,52430167.0,0.0,1.0,85.26,87.09,84.88,86.85,52430167.0
-2017-12-14,85.43,85.8739,84.53,84.69,19080106.0,0.0,1.0,85.43,85.8739,84.53,84.69,19080106.0
-2017-12-13,85.74,86.0,85.17,85.35,21307911.0,0.0,1.0,85.74,86.0,85.17,85.35,21307911.0
-2017-12-12,85.31,86.05,85.08,85.58,23534946.0,0.0,1.0,85.31,86.05,85.08,85.58,23534946.0
-2017-12-11,84.29,85.37,84.12,85.23,19909119.0,0.0,1.0,84.29,85.37,84.12,85.23,19909119.0
-2017-12-08,83.63,84.58,83.33,84.16,23825056.0,0.0,1.0,83.63,84.58,83.33,84.16,23825056.0
-2017-12-07,82.54,82.8,82.0,82.49,20378114.0,0.0,1.0,82.54,82.8,82.0,82.49,20378114.0
-2017-12-06,81.55,83.14,81.43,82.78,24821403.0,0.0,1.0,81.55,83.14,81.43,82.78,24821403.0
-2017-12-05,81.34,82.68,80.9801,81.59,25512120.0,0.0,1.0,81.34,82.68,80.9801,81.59,25512120.0
-2017-12-04,84.42,84.4299,80.7,81.08,37977732.0,0.0,1.0,84.42,84.4299,80.7,81.08,37977732.0
-2017-12-01,83.6,84.81,83.22,84.26,29113662.0,0.0,1.0,83.6,84.81,83.22,84.26,29113662.0
-2017-11-30,83.51,84.52,83.34,84.17,32074914.0,0.0,1.0,83.51,84.52,83.34,84.17,32074914.0
-2017-11-29,84.71,84.9172,83.175,83.34,26401761.0,0.0,1.0,84.71,84.9172,83.175,83.34,26401761.0
-2017-11-28,84.07,85.06,84.02,84.88,21162639.0,0.0,1.0,84.07,85.06,84.02,84.88,21162639.0
-2017-11-27,83.31,83.98,83.3,83.87,17603760.0,0.0,1.0,83.31,83.98,83.3,83.87,17603760.0
-2017-11-24,83.01,83.43,82.78,83.26,7425503.0,0.0,1.0,83.01,83.43,82.78,83.26,7425503.0
-2017-11-22,83.83,83.9,83.04,83.11,20213704.0,0.0,1.0,83.83,83.9,83.04,83.11,20213704.0
-2017-11-21,82.74,83.84,82.74,83.72,21033981.0,0.0,1.0,82.74,83.84,82.74,83.72,21033981.0
-2017-11-20,82.4,82.59,82.25,82.53,16072495.0,0.0,1.0,82.4,82.59,82.25,82.53,16072495.0
-2017-11-17,83.12,83.12,82.24,82.4,21715498.0,0.0,1.0,83.12,83.12,82.24,82.4,21715498.0
-2017-11-16,83.1,83.42,82.94,83.2,20659209.0,0.0,1.0,83.1,83.42,82.94,83.2,20659209.0
-2017-11-15,83.47,83.69,82.69,82.98,19097333.0,0.42,1.0,83.47,83.69,82.69,82.98,19097333.0
-2017-11-14,83.5,84.1,82.98,84.05,18604034.0,0.0,1.0,83.079496402878,83.676474820144,82.562115107914,83.626726618705,18604034.0
-2017-11-13,83.66,83.94,83.46,83.93,14080820.0,0.0,1.0,83.238690647482,83.51728057554,83.039697841727,83.507330935252,14080820.0
-2017-11-10,83.79,84.095,83.23,83.87,19340435.0,0.0,1.0,83.368035971223,83.6715,82.810856115108,83.447633093525,19340435.0
-2017-11-09,84.11,84.27,82.9,84.09,20924172.0,0.0,1.0,83.686424460432,83.845618705036,82.482517985612,83.666525179856,20924172.0
-2017-11-07,84.77,84.9,83.93,84.27,17152583.0,0.0,1.0,84.343100719424,84.472446043165,83.507330935252,83.845618705036,17152583.0
-2017-11-06,84.2,84.7,84.0825,84.47,19039847.0,0.0,1.0,83.775971223022,84.27345323741,83.65906294964,84.044611510791,19039847.0
-2017-11-03,84.08,84.54,83.4,84.14,17569120.0,0.0,1.0,83.656575539568,84.114258992806,82.98,83.716273381295,17569120.0
-2017-11-02,83.35,84.46,83.12,84.05,23822964.0,0.0,1.0,82.930251798561,84.034661870504,82.701410071942,83.626726618705,23822964.0
-2017-11-01,83.68,83.76,82.88,83.18,22039635.0,0.0,1.0,83.258589928058,83.33818705036,82.462618705036,82.761107913669,22039635.0
-2017-10-31,84.36,84.36,83.11,83.18,26728947.0,0.0,1.0,83.935165467626,83.935165467626,82.691460431655,82.761107913669,26728947.0
-2017-10-30,83.7,84.325,83.105,83.89,31291801.0,0.0,1.0,83.278489208633,83.900341726619,82.686485611511,83.467532374101,31291801.0
-2017-10-27,84.37,86.2,83.61,83.81,70877350.0,0.0,1.0,83.945115107914,85.765899280576,83.188942446043,83.387935251799,70877350.0
-2017-10-26,79.2,79.42,78.75,78.76,29181652.0,0.0,1.0,78.801151079137,79.020043165468,78.353417266187,78.363366906475,29181652.0
-2017-10-25,78.58,79.1,78.01,78.63,19714512.0,0.0,1.0,78.184273381295,78.701654676259,77.617143884892,78.234021582734,19714512.0
-2017-10-24,78.9,79.2,78.46,78.86,16613928.0,0.0,1.0,78.502661870504,78.801151079137,78.064877697842,78.462863309353,16613928.0
-2017-10-23,78.99,79.34,78.76,78.83,20479731.0,0.0,1.0,78.592208633094,78.940446043165,78.363366906475,78.433014388489,20479731.0
-2017-10-20,78.32,78.97,78.22,78.81,22517092.0,0.0,1.0,77.925582733813,78.572309352518,77.826086330935,78.413115107914,22517092.0
-2017-10-19,77.57,77.93,77.35,77.91,14982129.0,0.0,1.0,77.17935971223,77.53754676259,76.960467625899,77.517647482014,14982129.0
-2017-10-18,77.67,77.85,77.37,77.61,13147124.0,0.0,1.0,77.278856115108,77.457949640288,76.980366906475,77.219158273381,13147124.0
-2017-10-17,77.47,77.62,77.25,77.59,15953665.0,0.0,1.0,77.079863309353,77.229107913669,76.860971223022,77.199258992806,15953665.0
-2017-10-16,77.42,77.81,77.35,77.65,12331147.0,0.0,1.0,77.030115107914,77.418151079137,76.960467625899,77.258956834532,12331147.0
-2017-10-13,77.59,77.87,77.29,77.49,15250772.0,0.0,1.0,77.199258992806,77.477848920863,76.900769784173,77.099762589928,15250772.0
-2017-10-12,76.49,77.29,76.37,77.12,16778148.0,0.0,1.0,76.104798561151,76.900769784173,75.985402877698,76.731625899281,16778148.0
-2017-10-11,76.36,76.46,75.95,76.42,14780652.0,0.0,1.0,75.97545323741,76.074949640288,75.567517985612,76.035151079137,14780652.0
-2017-10-10,76.33,76.63,76.14,76.29,13734627.0,0.0,1.0,75.945604316547,76.24409352518,75.756561151079,75.905805755396,13734627.0
-2017-10-09,75.97,76.55,75.86,76.29,11364275.0,0.0,1.0,75.587417266187,76.164496402878,75.477971223022,75.905805755396,11364275.0
-2017-10-06,75.67,76.03,75.54,76.0,13692791.0,0.0,1.0,75.288928057554,75.647115107914,75.159582733813,75.61726618705,13692791.0
-2017-10-05,75.22,76.12,74.96,75.97,20656238.0,0.0,1.0,74.841194244604,75.736661870504,74.582503597122,75.587417266187,20656238.0
-2017-10-04,74.0,74.72,73.71,74.69,13287346.0,0.0,1.0,73.627338129496,74.343712230216,73.338798561151,74.313863309353,13287346.0
-2017-10-03,74.67,74.88,74.195,74.26,11935853.0,0.0,1.0,74.293964028777,74.50290647482,73.821356115108,73.886028776978,11935853.0
-2017-10-02,74.71,75.01,74.295,74.61,15210338.0,0.0,1.0,74.333762589928,74.632251798561,73.920852517986,74.23426618705,15210338.0
-2017-09-29,73.94,74.535,73.88,74.49,16700435.0,0.0,1.0,73.56764028777,74.159643884892,73.507942446043,74.114870503597,16700435.0
-2017-09-28,73.54,73.97,73.31,73.87,10814063.0,0.0,1.0,73.169654676259,73.597489208633,72.94081294964,73.497992805755,10814063.0
-2017-09-27,73.55,74.17,73.17,73.85,18934048.0,0.0,1.0,73.179604316547,73.796482014388,72.801517985612,73.47809352518,18934048.0
-2017-09-26,73.67,73.81,72.99,73.26,17105469.0,0.0,1.0,73.299,73.438294964029,72.622424460432,72.891064748201,17105469.0
-2017-09-25,74.09,74.25,72.92,73.26,23502422.0,0.0,1.0,73.716884892086,73.876079136691,72.552776978417,72.891064748201,23502422.0
-2017-09-22,73.99,74.51,73.85,74.41,13969937.0,0.0,1.0,73.617388489209,74.134769784173,73.47809352518,74.035273381295,13969937.0
-2017-09-21,75.11,75.24,74.11,74.21,19038998.0,0.0,1.0,74.731748201439,74.86109352518,73.736784172662,73.83628057554,19038998.0
-2017-09-20,75.35,75.55,74.31,74.94,20415084.0,0.0,1.0,74.970539568345,75.169532374101,73.935776978417,74.562604316547,20415084.0
-2017-09-19,75.21,75.71,75.01,75.44,15606870.0,0.0,1.0,74.831244604317,75.328726618705,74.632251798561,75.060086330935,15606870.0
-2017-09-18,75.23,75.97,75.04,75.16,22730355.0,0.0,1.0,74.851143884892,75.587417266187,74.662100719424,74.781496402878,22730355.0
-2017-09-15,74.83,75.39,74.07,75.31,37901927.0,0.0,1.0,74.453158273381,75.010338129496,73.696985611511,74.930741007194,37901927.0
-2017-09-14,75.0,75.49,74.52,74.77,15373384.0,0.0,1.0,74.622302158273,75.109834532374,74.14471942446,74.393460431655,15373384.0
-2017-09-13,74.93,75.23,74.55,75.21,12998629.0,0.0,1.0,74.552654676259,74.851143884892,74.174568345324,74.831244604317,12998629.0
-2017-09-12,74.76,75.24,74.37,74.68,14003880.0,0.0,1.0,74.383510791367,74.86109352518,73.995474820144,74.303913669065,14003880.0
-2017-09-11,74.31,74.945,74.31,74.76,17428067.0,0.0,1.0,73.935776978417,74.567579136691,73.935776978417,74.383510791367,17428067.0
-2017-09-08,74.33,74.44,73.84,73.98,14474383.0,0.0,1.0,73.955676258993,74.065122302158,73.468143884892,73.607438848921,14474383.0
-2017-09-07,73.68,74.6,73.6,74.34,17165518.0,0.0,1.0,73.308949640288,74.224316546763,73.229352517986,73.965625899281,17165518.0
-2017-09-06,73.74,74.04,73.35,73.4,15945136.0,0.0,1.0,73.368647482014,73.667136690647,72.980611510791,73.03035971223,15945136.0
-2017-09-05,73.34,73.89,72.98,73.61,21432599.0,0.0,1.0,72.970661870504,73.517892086331,72.612474820144,73.239302158273,21432599.0
-2017-09-01,74.71,74.74,73.64,73.94,21593192.0,0.0,1.0,74.333762589928,74.363611510791,73.269151079137,73.56764028777,21593192.0
-2017-08-31,74.03,74.96,73.8,74.77,26688077.0,0.0,1.0,73.65718705036,74.582503597122,73.428345323741,74.393460431655,26688077.0
-2017-08-30,73.01,74.2099,72.8293,74.01,16826094.0,0.0,1.0,72.642323741007,73.836181079137,72.462533741007,73.637287769784,16826094.0
-2017-08-29,72.25,73.16,72.05,73.05,11325418.0,0.0,1.0,71.886151079137,72.791568345324,71.687158273381,72.682122302158,11325418.0
-2017-08-28,73.06,73.09,72.55,72.83,14112777.0,0.0,1.0,72.692071942446,72.721920863309,72.18464028777,72.463230215827,14112777.0
-2017-08-25,72.86,73.35,72.48,72.82,12574503.0,0.0,1.0,72.493079136691,72.980611510791,72.114992805755,72.45328057554,12574503.0
-2017-08-24,72.74,72.86,72.07,72.69,15980144.0,0.0,1.0,72.373683453237,72.493079136691,71.707057553957,72.323935251799,15980144.0
-2017-08-23,72.96,73.15,72.53,72.72,13586784.0,0.0,1.0,72.592575539568,72.781618705036,72.164741007194,72.353784172662,13586784.0
-2017-08-22,72.35,73.24,72.35,73.16,14183146.0,0.0,1.0,71.985647482014,72.871165467626,71.985647482014,72.791568345324,14183146.0
-2017-08-21,72.47,72.48,71.7,72.15,17656716.0,0.0,1.0,72.105043165468,72.114992805755,71.338920863309,71.786654676259,17656716.0
-2017-08-18,72.27,72.84,71.93,72.49,18215276.0,0.0,1.0,71.906050359712,72.473179856115,71.567762589928,72.124942446043,18215276.0
-2017-08-17,73.58,73.87,72.4,72.4,21834250.0,0.0,1.0,73.20945323741,73.497992805755,72.035395683453,72.035395683453,21834250.0
-2017-08-16,73.34,74.1,73.17,73.65,17814317.0,0.0,1.0,72.970661870504,73.726834532374,72.801517985612,73.279100719424,17814317.0
-2017-08-15,73.59,73.59,73.04,73.22,17791179.0,0.39,1.0,73.219402877698,73.219402877698,72.672172661871,72.85126618705,17791179.0
-2017-08-14,73.06,73.72,72.95,73.59,19756773.0,0.0,1.0,72.306935302621,72.960132363936,72.198069125735,72.831472336707,19756773.0
-2017-08-11,71.61,72.7,71.28,72.5,21121250.0,0.0,1.0,70.87188115276,71.950645996448,70.545282622102,71.752707493019,21121250.0
-2017-08-10,71.9,72.19,71.35,71.41,23153711.0,0.0,1.0,71.158891982732,71.445902812704,70.614561098302,70.673942649331,23153711.0
-2017-08-09,72.25,72.51,72.05,72.47,20401071.0,0.0,1.0,71.505284363733,71.762604418191,71.307345860304,71.723016717505,20401071.0
-2017-08-08,72.09,73.13,71.75,72.79,21446993.0,0.0,1.0,71.34693356099,72.376213778821,71.01043810516,72.039718322991,21446993.0
-2017-08-07,72.8,72.9,72.26,72.4,18582345.0,0.0,1.0,72.049615248163,72.148584499877,71.515181288904,71.653738241305,18582345.0
-2017-08-04,72.4,73.04,72.24,72.68,22412719.0,0.0,1.0,71.653738241305,72.287141452278,71.495387438562,71.930852146105,22412719.0
-2017-08-03,72.19,72.44,71.845,72.15,17937522.0,0.0,1.0,71.445902812704,71.693325941991,71.104458894289,71.406315112019,17937522.0
-2017-08-02,72.55,72.56,71.445,72.26,26405096.0,0.0,1.0,71.802192118877,71.812089044048,70.708581887431,71.515181288904,26405096.0
-2017-08-01,73.1,73.42,72.49,72.58,19060885.0,0.0,1.0,72.346523003306,72.663224608793,71.742810567848,71.831882894391,19060885.0
-2017-07-31,73.3,73.44,72.41,72.72,23151962.0,0.0,1.0,72.544461506735,72.683018459136,71.663635166476,71.970439846791,23151962.0
-2017-07-28,72.67,73.31,72.54,73.04,17472880.0,0.0,1.0,71.920955220934,72.554358431907,71.792295193705,72.287141452278,17472880.0
-2017-07-27,73.76,74.42,72.32,73.16,35518251.0,0.0,1.0,72.999720064622,73.652917125938,71.574562839933,72.405904554335,35518251.0
-2017-07-26,74.34,74.38,73.81,74.05,15850344.0,0.0,1.0,73.573741724566,73.613329425252,73.049204690479,73.286730894594,15850344.0
-2017-07-25,73.8,74.31,73.5,74.19,21522189.0,0.0,1.0,73.039307765308,73.544050949052,72.742400010164,73.425287846995,21522189.0
-2017-07-24,73.53,73.75,73.13,73.6,20836422.0,0.0,1.0,72.772090785679,72.989823139451,72.376213778821,72.841369261879,20836422.0
-2017-07-21,73.45,74.29,73.17,73.79,45302930.0,0.0,1.0,72.692915384307,73.524257098709,72.415801479507,73.029410840136,45302930.0
-2017-07-20,74.18,74.3,73.28,74.24,34174677.0,0.0,1.0,73.415390921823,73.53415402388,72.524667656392,73.474772472852,34174677.0
-2017-07-19,73.5,74.04,73.45,73.86,21769229.0,0.0,1.0,72.742400010164,73.276833969423,72.692915384307,73.098689316337,21769229.0
-2017-07-18,73.09,73.39,72.66,73.3,26150272.0,0.0,1.0,72.336626078135,72.633533833278,71.911058295763,72.544461506735,26150272.0
-2017-07-17,72.8,73.45,72.72,73.35,21481069.0,0.0,1.0,72.049615248163,72.692915384307,71.970439846791,72.593946132593,21481069.0
-2017-07-14,72.24,73.27,71.96,72.78,25689303.0,0.0,1.0,71.495387438562,72.514770731221,71.218273533761,72.02982139782,25689303.0
-2017-07-13,71.5,72.0399,71.31,71.77,20149208.0,0.0,1.0,70.763014975874,71.297349965881,70.574973397617,71.030231955503,20149208.0
-2017-07-12,70.69,71.28,70.55,71.15,17382861.0,0.0,1.0,69.961364036987,70.545282622102,69.822807084586,70.416622594873,17382861.0
-2017-07-11,70.0,70.68,69.75,69.99,16880205.0,0.0,1.0,69.278476200157,69.951467111815,69.03105307087,69.268579274985,16880205.0
-2017-07-10,69.46,70.25,69.2,69.98,14903400.0,0.0,1.0,68.744042240898,69.525899329443,68.486722186441,69.258682349814,14903400.0
-2017-07-07,68.7,69.84,68.7,69.46,15897154.0,0.0,1.0,67.991875927868,69.120125397413,67.991875927868,68.744042240898,15897154.0
-2017-07-06,68.27,68.78,68.12,68.57,20776555.0,0.0,1.0,67.566308145496,68.07105132924,67.417854267924,67.863215900639,20776555.0
-2017-07-05,68.255,69.44,68.22,69.08,20174523.0,0.0,1.0,67.551462757738,68.724248390555,67.516823519638,68.367959084383,20174523.0
-2017-07-03,69.33,69.6,68.02,68.17,16164331.0,0.0,1.0,68.615382213669,68.882599193299,67.318885016209,67.467338893781,16164331.0
-2017-06-30,68.78,69.38,68.74,68.93,23039328.0,0.0,1.0,68.07105132924,68.664866839527,68.031463628554,68.219505206811,23039328.0
-2017-06-29,69.38,69.49,68.09,68.49,28231562.0,0.0,1.0,68.664866839527,68.773733016413,67.388163492409,67.784040499267,28231562.0
-2017-06-28,69.21,69.841,68.79,69.8,25226070.0,0.0,1.0,68.496619111612,69.12111508993,68.080948254411,69.080537696728,25226070.0
-2017-06-27,70.11,70.18,69.18,69.21,24862560.0,0.0,1.0,69.387342377043,69.456620853243,68.466928336098,68.496619111612,24862560.0
-2017-06-26,71.4,71.71,70.445,70.53,19308122.0,0.0,1.0,70.66404572416,70.970850404475,69.718889370286,69.803013234243,19308122.0
-2017-06-23,70.09,71.25,69.92,71.21,23176418.0,0.0,1.0,69.3675485267,70.515591846588,69.199300798785,70.476004145902,23176418.0
-2017-06-22,70.54,70.59,69.71,70.26,22222851.0,0.0,1.0,69.812910159415,69.862394785272,68.991465370184,69.535796254614,22222851.0
-2017-06-21,70.21,70.62,69.94,70.27,19190623.0,0.0,1.0,69.486311628757,69.892085560787,69.219094649128,69.545693179786,19190623.0
-2017-06-20,70.82,70.87,69.87,69.91,20775590.0,0.0,1.0,70.090024064216,70.139508690073,69.149816172928,69.189403873614,20775590.0
-2017-06-19,70.5,70.945,70.35,70.87,23146852.0,0.0,1.0,69.773322458729,70.213735628859,69.624868581157,70.139508690073,23146852.0
-2017-06-16,69.73,70.0252,69.22,70.0,46911637.0,0.0,1.0,69.011259220527,69.303416451589,68.506516036783,69.278476200157,46911637.0
-2017-06-15,69.27,70.21,68.8,69.9,25701569.0,0.0,1.0,68.556000662641,69.486311628757,68.090845179582,69.179506948442,25701569.0
-2017-06-14,70.91,71.1,69.43,70.27,25271276.0,0.0,1.0,70.179096390759,70.367137969016,68.714351465384,69.545693179786,25271276.0
-2017-06-13,70.02,70.82,69.96,70.65,24815455.0,0.0,1.0,69.298270050499,70.090024064216,69.238888499471,69.921776336301,24815455.0
-2017-06-12,69.25,69.94,68.13,69.78,47363986.0,0.0,1.0,68.536206812298,69.219094649128,67.427751193095,69.060743846385,47363986.0
-2017-06-09,72.035,72.08,68.59,70.32,48619420.0,0.0,1.0,71.292500472547,71.337036635818,67.883009750982,69.595177805643,48619420.0
-2017-06-08,72.51,72.52,71.5,71.945,23982410.0,0.0,1.0,71.762604418191,71.772501343362,70.763014975874,71.203428146004,23982410.0
-2017-06-07,72.635,72.77,71.95,72.39,21895156.0,0.0,1.0,71.886315982834,72.019924472648,71.20837660859,71.643841316133,21895156.0
-2017-06-06,72.3,72.62,72.27,72.52,31220057.0,0.0,1.0,71.55476898959,71.871470595077,71.525078214076,71.772501343362,31220057.0
-2017-06-05,71.97,72.89,71.81,72.28,29507429.0,0.0,1.0,71.228170458932,72.138687574706,71.069819656189,71.534975139247,29507429.0
-2017-06-02,70.44,71.86,70.24,71.76,34586054.0,0.0,1.0,69.7139409077,71.119304282046,69.516002404271,71.020335030332,34586054.0
-2017-06-01,70.24,70.61,69.451,70.1,21066468.0,0.0,1.0,69.516002404271,69.882188635615,68.735135008244,69.377445451871,21066468.0
diff --git a/examples/quick/demos/stocqt/content/data/NCLH.csv b/examples/quick/demos/stocqt/content/data/NCLH.csv
deleted file mode 100644
index 3827fd20ad..0000000000
--- a/examples/quick/demos/stocqt/content/data/NCLH.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,53.45,53.96,53.2,53.25,889909.0,0.0,1.0,53.45,53.96,53.2,53.25,889909.0
-2017-12-28,54.01,54.03,53.34,53.61,1186989.0,0.0,1.0,54.01,54.03,53.34,53.61,1186989.0
-2017-12-27,53.95,54.19,53.7,54.0,792700.0,0.0,1.0,53.95,54.19,53.7,54.0,792700.0
-2017-12-26,53.93,54.25,53.65,53.73,906947.0,0.0,1.0,53.93,54.25,53.65,53.73,906947.0
-2017-12-22,54.325,54.47,53.72,54.03,1251857.0,0.0,1.0,54.325,54.47,53.72,54.03,1251857.0
-2017-12-21,54.9,55.31,54.01,54.14,1346967.0,0.0,1.0,54.9,55.31,54.01,54.14,1346967.0
-2017-12-20,55.74,56.41,54.74,54.82,1797666.0,0.0,1.0,55.74,56.41,54.74,54.82,1797666.0
-2017-12-19,55.14,56.05,55.02,55.59,1592622.0,0.0,1.0,55.14,56.05,55.02,55.59,1592622.0
-2017-12-18,54.51,55.355,54.5,54.98,2094664.0,0.0,1.0,54.51,55.355,54.5,54.98,2094664.0
-2017-12-15,53.14,54.3,52.58,54.0,6275489.0,0.0,1.0,53.14,54.3,52.58,54.0,6275489.0
-2017-12-14,53.16,53.46,52.7,52.81,1433280.0,0.0,1.0,53.16,53.46,52.7,52.81,1433280.0
-2017-12-13,53.93,53.93,53.09,53.16,1222815.0,0.0,1.0,53.93,53.93,53.09,53.16,1222815.0
-2017-12-12,54.64,54.64,53.55,53.65,1640536.0,0.0,1.0,54.64,54.64,53.55,53.65,1640536.0
-2017-12-11,54.75,55.37,54.33,54.72,1492003.0,0.0,1.0,54.75,55.37,54.33,54.72,1492003.0
-2017-12-08,54.74,55.57,54.36,55.03,1249849.0,0.0,1.0,54.74,55.57,54.36,55.03,1249849.0
-2017-12-07,54.5,54.62,54.08,54.34,1093747.0,0.0,1.0,54.5,54.62,54.08,54.34,1093747.0
-2017-12-06,54.49,54.8,53.7,54.31,1161732.0,0.0,1.0,54.49,54.8,53.7,54.31,1161732.0
-2017-12-05,55.53,55.67,54.265,54.33,938087.0,0.0,1.0,55.53,55.67,54.265,54.33,938087.0
-2017-12-04,55.68,56.84,55.3,55.41,2507341.0,0.0,1.0,55.68,56.84,55.3,55.41,2507341.0
-2017-12-01,53.94,54.91,53.675,54.81,1314538.0,0.0,1.0,53.94,54.91,53.675,54.81,1314538.0
-2017-11-30,54.0,54.69,52.36,54.16,3452181.0,0.0,1.0,54.0,54.69,52.36,54.16,3452181.0
-2017-11-29,55.48,56.21,55.12,55.29,1637536.0,0.0,1.0,55.48,56.21,55.12,55.29,1637536.0
-2017-11-28,55.62,55.83,54.92,55.31,1759104.0,0.0,1.0,55.62,55.83,54.92,55.31,1759104.0
-2017-11-27,55.55,56.03,55.47,55.61,1224822.0,0.0,1.0,55.55,56.03,55.47,55.61,1224822.0
-2017-11-24,55.41,55.74,55.01,55.5,550824.0,0.0,1.0,55.41,55.74,55.01,55.5,550824.0
-2017-11-22,55.42,56.0,55.11,55.31,1270402.0,0.0,1.0,55.42,56.0,55.11,55.31,1270402.0
-2017-11-21,54.93,55.88,54.8,55.48,2014071.0,0.0,1.0,54.93,55.88,54.8,55.48,2014071.0
-2017-11-20,54.78,55.09,54.28,54.69,2306354.0,0.0,1.0,54.78,55.09,54.28,54.69,2306354.0
-2017-11-17,54.12,54.9,53.69,54.84,3943455.0,0.0,1.0,54.12,54.9,53.69,54.84,3943455.0
-2017-11-16,53.85,54.3,53.5,53.97,6186166.0,0.0,1.0,53.85,54.3,53.5,53.97,6186166.0
-2017-11-15,55.09,55.19,54.58,55.07,1345399.0,0.0,1.0,55.09,55.19,54.58,55.07,1345399.0
-2017-11-14,55.08,55.22,54.1,55.1,1301048.0,0.0,1.0,55.08,55.22,54.1,55.1,1301048.0
-2017-11-13,54.91,55.34,54.65,55.27,1717783.0,0.0,1.0,54.91,55.34,54.65,55.27,1717783.0
-2017-11-10,55.75,56.06,54.07,55.23,2272543.0,0.0,1.0,55.75,56.06,54.07,55.23,2272543.0
-2017-11-09,55.74,58.27,55.29,56.89,3115303.0,0.0,1.0,55.74,58.27,55.29,56.89,3115303.0
-2017-11-07,56.55,57.37,54.97,55.36,1793433.0,0.0,1.0,56.55,57.37,54.97,55.36,1793433.0
-2017-11-06,55.0,56.12,54.905,55.26,1518782.0,0.0,1.0,55.0,56.12,54.905,55.26,1518782.0
-2017-11-03,54.91,55.09,54.53,55.03,922980.0,0.0,1.0,54.91,55.09,54.53,55.03,922980.0
-2017-11-02,54.27,55.17,54.205,54.91,2134024.0,0.0,1.0,54.27,55.17,54.205,54.91,2134024.0
-2017-11-01,56.06,56.1,54.04,54.2,2246546.0,0.0,1.0,56.06,56.1,54.04,54.2,2246546.0
-2017-10-31,54.82,55.98,54.715,55.75,1441239.0,0.0,1.0,54.82,55.98,54.715,55.75,1441239.0
-2017-10-30,55.29,55.67,54.67,54.8,972388.0,0.0,1.0,55.29,55.67,54.67,54.8,972388.0
-2017-10-27,54.8,56.28,54.49,55.64,2308873.0,0.0,1.0,54.8,56.28,54.49,55.64,2308873.0
-2017-10-26,54.8,55.25,54.53,54.92,1373500.0,0.0,1.0,54.8,55.25,54.53,54.92,1373500.0
-2017-10-25,54.67,55.19,54.38,54.79,2407822.0,0.0,1.0,54.67,55.19,54.38,54.79,2407822.0
-2017-10-24,53.63,54.78,53.5,54.66,2467749.0,0.0,1.0,53.63,54.78,53.5,54.66,2467749.0
-2017-10-23,53.76,54.1014,53.531,53.72,1984765.0,0.0,1.0,53.76,54.1014,53.531,53.72,1984765.0
-2017-10-20,54.87,54.94,53.45,53.73,3459633.0,0.0,1.0,54.87,54.94,53.45,53.73,3459633.0
-2017-10-19,56.4,56.52,53.8,54.17,7936900.0,0.0,1.0,56.4,56.52,53.8,54.17,7936900.0
-2017-10-18,58.45,58.45,57.13,57.47,4187580.0,0.0,1.0,58.45,58.45,57.13,57.47,4187580.0
-2017-10-17,58.69,59.0,58.44,58.61,2360423.0,0.0,1.0,58.69,59.0,58.44,58.61,2360423.0
-2017-10-16,58.83,59.15,58.4,58.92,2088445.0,0.0,1.0,58.83,59.15,58.4,58.92,2088445.0
-2017-10-13,59.43,59.6,58.22,58.74,3925398.0,0.0,1.0,59.43,59.6,58.22,58.74,3925398.0
-2017-10-12,58.56,59.3,58.43,58.86,29345290.0,0.0,1.0,58.56,59.3,58.43,58.86,29345290.0
-2017-10-11,59.15,59.42,58.58,58.8,2721843.0,0.0,1.0,59.15,59.42,58.58,58.8,2721843.0
-2017-10-10,59.19,59.535,58.985,59.16,2658838.0,0.0,1.0,59.19,59.535,58.985,59.16,2658838.0
-2017-10-09,58.75,59.66,58.71,58.89,2211669.0,0.0,1.0,58.75,59.66,58.71,58.89,2211669.0
-2017-10-06,58.25,59.4,58.25,58.84,3026934.0,0.0,1.0,58.25,59.4,58.25,58.84,3026934.0
-2017-10-05,58.01,58.54,57.53,58.41,7767820.0,0.0,1.0,58.01,58.54,57.53,58.41,7767820.0
-2017-10-04,54.58,56.2,54.53,55.98,1566581.0,0.0,1.0,54.58,56.2,54.53,55.98,1566581.0
-2017-10-03,54.46,55.11,54.03,54.73,1212466.0,0.0,1.0,54.46,55.11,54.03,54.73,1212466.0
-2017-10-02,53.94,54.53,53.6,54.42,1111899.0,0.0,1.0,53.94,54.53,53.6,54.42,1111899.0
-2017-09-29,53.46,54.15,52.44,54.05,2508346.0,0.0,1.0,53.46,54.15,52.44,54.05,2508346.0
-2017-09-28,52.52,53.93,51.99,53.65,2527667.0,0.0,1.0,52.52,53.93,51.99,53.65,2527667.0
-2017-09-27,54.99,55.04,52.74,52.83,1960663.0,0.0,1.0,54.99,55.04,52.74,52.83,1960663.0
-2017-09-26,54.46,55.68,54.26,54.89,2549545.0,0.0,1.0,54.46,55.68,54.26,54.89,2549545.0
-2017-09-25,53.74,54.11,53.23,53.6,1422751.0,0.0,1.0,53.74,54.11,53.23,53.6,1422751.0
-2017-09-22,54.09,54.81,53.75,54.02,1392579.0,0.0,1.0,54.09,54.81,53.75,54.02,1392579.0
-2017-09-21,54.54,54.83,53.95,54.4,1231315.0,0.0,1.0,54.54,54.83,53.95,54.4,1231315.0
-2017-09-20,55.36,55.42,53.71,54.36,2204298.0,0.0,1.0,55.36,55.42,53.71,54.36,2204298.0
-2017-09-19,56.27,56.27,55.29,55.46,1504249.0,0.0,1.0,56.27,56.27,55.29,55.46,1504249.0
-2017-09-18,56.7,57.21,56.28,56.35,1455687.0,0.0,1.0,56.7,57.21,56.28,56.35,1455687.0
-2017-09-15,56.55,56.74,55.28,56.74,3808399.0,0.0,1.0,56.55,56.74,55.28,56.74,3808399.0
-2017-09-14,57.35,58.58,57.25,57.72,1354813.0,0.0,1.0,57.35,58.58,57.25,57.72,1354813.0
-2017-09-13,56.94,57.84,56.75,57.79,1399743.0,0.0,1.0,56.94,57.84,56.75,57.79,1399743.0
-2017-09-12,56.92,57.22,56.41,57.2,1019670.0,0.0,1.0,56.92,57.22,56.41,57.2,1019670.0
-2017-09-11,56.19,58.2,56.0,56.65,2870913.0,0.0,1.0,56.19,58.2,56.0,56.65,2870913.0
-2017-09-08,55.84,56.98,55.01,55.12,1537947.0,0.0,1.0,55.84,56.98,55.01,55.12,1537947.0
-2017-09-07,57.0,57.43,55.77,55.86,1642298.0,0.0,1.0,57.0,57.43,55.77,55.86,1642298.0
-2017-09-06,56.53,57.17,55.91,57.12,1961468.0,0.0,1.0,56.53,57.17,55.91,57.12,1961468.0
-2017-09-05,58.51,58.54,55.3,56.69,2810897.0,0.0,1.0,58.51,58.54,55.3,56.69,2810897.0
-2017-09-01,59.62,60.0,58.48,58.54,1159890.0,0.0,1.0,59.62,60.0,58.48,58.54,1159890.0
-2017-08-31,58.42,59.5,58.41,59.46,1792821.0,0.0,1.0,58.42,59.5,58.41,59.46,1792821.0
-2017-08-30,57.53,58.8,57.25,58.22,1430195.0,0.0,1.0,57.53,58.8,57.25,58.22,1430195.0
-2017-08-29,57.43,57.74,56.47,57.64,1532747.0,0.0,1.0,57.43,57.74,56.47,57.64,1532747.0
-2017-08-28,57.98,58.03,57.48,57.88,878613.0,0.0,1.0,57.98,58.03,57.48,57.88,878613.0
-2017-08-25,57.99,58.0,57.58,57.72,1934962.0,0.0,1.0,57.99,58.0,57.58,57.72,1934962.0
-2017-08-24,57.33,57.905,57.29,57.73,1495111.0,0.0,1.0,57.33,57.905,57.29,57.73,1495111.0
-2017-08-23,56.53,57.91,56.53,57.15,1903662.0,0.0,1.0,56.53,57.91,56.53,57.15,1903662.0
-2017-08-22,56.01,57.03,56.01,56.9,1072763.0,0.0,1.0,56.01,57.03,56.01,56.9,1072763.0
-2017-08-21,55.81,56.15,55.59,55.86,980583.0,0.0,1.0,55.81,56.15,55.59,55.86,980583.0
-2017-08-18,56.33,56.33,55.26,55.78,1424778.0,0.0,1.0,56.33,56.33,55.26,55.78,1424778.0
-2017-08-17,57.98,58.07,56.01,56.18,2067539.0,0.0,1.0,57.98,58.07,56.01,56.18,2067539.0
-2017-08-16,57.8,58.41,57.44,57.9,1434593.0,0.0,1.0,57.8,58.41,57.44,57.9,1434593.0
-2017-08-15,57.61,58.56,57.22,57.45,2822548.0,0.0,1.0,57.61,58.56,57.22,57.45,2822548.0
-2017-08-14,57.14,57.83,57.01,57.46,2619908.0,0.0,1.0,57.14,57.83,57.01,57.46,2619908.0
-2017-08-11,54.75,57.17,54.15,56.77,12874815.0,0.0,1.0,54.75,57.17,54.15,56.77,12874815.0
-2017-08-10,58.04,58.16,56.9,57.07,1656606.0,0.0,1.0,58.04,58.16,56.9,57.07,1656606.0
-2017-08-09,58.88,58.99,58.05,58.36,2075241.0,0.0,1.0,58.88,58.99,58.05,58.36,2075241.0
-2017-08-08,59.05,61.48,58.85,59.42,5341341.0,0.0,1.0,59.05,61.48,58.85,59.42,5341341.0
-2017-08-07,57.15,57.62,56.49,56.65,2833326.0,0.0,1.0,57.15,57.62,56.49,56.65,2833326.0
-2017-08-04,56.47,57.48,56.27,56.9,1265045.0,0.0,1.0,56.47,57.48,56.27,56.9,1265045.0
-2017-08-03,55.77,56.96,55.77,56.25,1152770.0,0.0,1.0,55.77,56.96,55.77,56.25,1152770.0
-2017-08-02,56.89,57.25,55.45,55.84,1255978.0,0.0,1.0,56.89,57.25,55.45,55.84,1255978.0
-2017-08-01,56.49,57.25,56.15,56.91,2486095.0,0.0,1.0,56.49,57.25,56.15,56.91,2486095.0
-2017-07-31,55.45,55.73,54.975,55.07,886281.0,0.0,1.0,55.45,55.73,54.975,55.07,886281.0
-2017-07-28,54.71,55.26,54.39,55.21,983892.0,0.0,1.0,54.71,55.26,54.39,55.21,983892.0
-2017-07-27,55.7,55.85,54.29,55.11,1201890.0,0.0,1.0,55.7,55.85,54.29,55.11,1201890.0
-2017-07-26,56.0,56.01,55.2,55.65,631774.0,0.0,1.0,56.0,56.01,55.2,55.65,631774.0
-2017-07-25,55.9,56.36,55.43,55.75,998410.0,0.0,1.0,55.9,56.36,55.43,55.75,998410.0
-2017-07-24,55.3,55.77,55.04,55.73,1082025.0,0.0,1.0,55.3,55.77,55.04,55.73,1082025.0
-2017-07-21,54.9,55.23,54.7645,55.07,658226.0,0.0,1.0,54.9,55.23,54.7645,55.07,658226.0
-2017-07-20,54.53,55.33,54.33,55.05,972645.0,0.0,1.0,54.53,55.33,54.33,55.05,972645.0
-2017-07-19,54.27,54.51,54.09,54.38,688376.0,0.0,1.0,54.27,54.51,54.09,54.38,688376.0
-2017-07-18,54.22,54.44,53.71,54.18,620018.0,0.0,1.0,54.22,54.44,53.71,54.18,620018.0
-2017-07-17,53.51,54.45,53.16,54.13,1062125.0,0.0,1.0,53.51,54.45,53.16,54.13,1062125.0
-2017-07-14,54.43,54.48,53.4,53.47,923880.0,0.0,1.0,54.43,54.48,53.4,53.47,923880.0
-2017-07-13,54.12,54.49,53.65,54.24,1061017.0,0.0,1.0,54.12,54.49,53.65,54.24,1061017.0
-2017-07-12,54.32,54.64,53.58,54.09,1174740.0,0.0,1.0,54.32,54.64,53.58,54.09,1174740.0
-2017-07-11,53.79,54.3,53.4,53.96,780957.0,0.0,1.0,53.79,54.3,53.4,53.96,780957.0
-2017-07-10,54.53,55.09,53.663,54.03,1253838.0,0.0,1.0,54.53,55.09,53.663,54.03,1253838.0
-2017-07-07,54.2,55.04,54.2,54.68,950235.0,0.0,1.0,54.2,55.04,54.2,54.68,950235.0
-2017-07-06,55.06,55.06,53.925,54.06,1550796.0,0.0,1.0,55.06,55.06,53.925,54.06,1550796.0
-2017-07-05,54.52,55.75,54.495,55.41,973694.0,0.0,1.0,54.52,55.75,54.495,55.41,973694.0
-2017-07-03,54.63,55.21,54.38,54.55,496186.0,0.0,1.0,54.63,55.21,54.38,54.55,496186.0
-2017-06-30,54.96,55.0,54.27,54.29,1025663.0,0.0,1.0,54.96,55.0,54.27,54.29,1025663.0
-2017-06-29,55.16,55.33,54.08,54.42,844905.0,0.0,1.0,55.16,55.33,54.08,54.42,844905.0
-2017-06-28,54.18,55.73,54.18,55.28,1012373.0,0.0,1.0,54.18,55.73,54.18,55.28,1012373.0
-2017-06-27,55.01,55.29,53.84,53.86,1517157.0,0.0,1.0,55.01,55.29,53.84,53.86,1517157.0
-2017-06-26,54.82,56.12,54.82,55.31,1225716.0,0.0,1.0,54.82,56.12,54.82,55.31,1225716.0
-2017-06-23,55.57,55.87,54.74,54.81,2188845.0,0.0,1.0,55.57,55.87,54.74,54.81,2188845.0
-2017-06-22,55.01,56.26,54.9,55.46,2613554.0,0.0,1.0,55.01,56.26,54.9,55.46,2613554.0
-2017-06-21,53.24,55.23,53.2,54.9,2426566.0,0.0,1.0,53.24,55.23,53.2,54.9,2426566.0
-2017-06-20,53.51,53.92,52.95,53.1,1059158.0,0.0,1.0,53.51,53.92,52.95,53.1,1059158.0
-2017-06-19,53.2,53.84,53.06,53.63,1036571.0,0.0,1.0,53.2,53.84,53.06,53.63,1036571.0
-2017-06-16,52.71,53.01,52.09,52.9,2348629.0,0.0,1.0,52.71,53.01,52.09,52.9,2348629.0
-2017-06-15,51.61,52.95,51.61,52.91,1146075.0,0.0,1.0,51.61,52.95,51.61,52.91,1146075.0
-2017-06-14,51.99,52.74,51.7,52.17,1432854.0,0.0,1.0,51.99,52.74,51.7,52.17,1432854.0
-2017-06-13,50.78,52.23,50.77,51.84,1457083.0,0.0,1.0,50.78,52.23,50.77,51.84,1457083.0
-2017-06-12,50.98,51.26,49.52,50.42,2050208.0,0.0,1.0,50.98,51.26,49.52,50.42,2050208.0
-2017-06-09,51.97,52.31,50.8,51.13,2214803.0,0.0,1.0,51.97,52.31,50.8,51.13,2214803.0
-2017-06-08,50.93,52.1,50.68,51.79,2046748.0,0.0,1.0,50.93,52.1,50.68,51.79,2046748.0
-2017-06-07,50.08,50.81,49.75,50.79,1934974.0,0.0,1.0,50.08,50.81,49.75,50.79,1934974.0
-2017-06-06,50.0,50.6,49.66,49.72,2199861.0,0.0,1.0,50.0,50.6,49.66,49.72,2199861.0
-2017-06-05,51.17,51.17,50.07,50.31,1580004.0,0.0,1.0,51.17,51.17,50.07,50.31,1580004.0
-2017-06-02,51.16,51.64,50.97,51.16,1166461.0,0.0,1.0,51.16,51.64,50.97,51.16,1166461.0
-2017-06-01,50.23,51.1,49.98,50.93,1713508.0,0.0,1.0,50.23,51.1,49.98,50.93,1713508.0
diff --git a/examples/quick/demos/stocqt/content/data/NFLX.csv b/examples/quick/demos/stocqt/content/data/NFLX.csv
deleted file mode 100644
index d7a667843c..0000000000
--- a/examples/quick/demos/stocqt/content/data/NFLX.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,192.51,193.95,191.22,191.96,5158845.0,0.0,1.0,192.51,193.95,191.22,191.96,5158845.0
-2017-12-28,187.18,194.49,186.85,192.71,10080261.0,0.0,1.0,187.18,194.49,186.85,192.71,10080261.0
-2017-12-27,187.8,188.1,185.22,186.24,3932094.0,0.0,1.0,187.8,188.1,185.22,186.24,3932094.0
-2017-12-26,189.78,189.94,186.4,187.76,3032707.0,0.0,1.0,189.78,189.94,186.4,187.76,3032707.0
-2017-12-22,188.33,190.95,186.8,189.94,3760922.0,0.0,1.0,188.33,190.95,186.8,189.94,3760922.0
-2017-12-21,189.44,190.95,187.58,188.62,3522551.0,0.0,1.0,189.44,190.95,187.58,188.62,3522551.0
-2017-12-20,187.94,189.11,185.26,188.82,5814609.0,0.0,1.0,187.94,189.11,185.26,188.82,5814609.0
-2017-12-19,190.18,190.2981,185.75,187.02,6526555.0,0.0,1.0,190.18,190.2981,185.75,187.02,6526555.0
-2017-12-18,191.2,191.65,188.9,190.42,4944337.0,0.0,1.0,191.2,191.65,188.9,190.42,4944337.0
-2017-12-15,189.61,191.43,188.01,190.12,7048874.0,0.0,1.0,189.61,191.43,188.01,190.12,7048874.0
-2017-12-14,187.98,192.64,187.2,189.56,7677048.0,0.0,1.0,187.98,192.64,187.2,189.56,7677048.0
-2017-12-13,186.1,188.69,185.41,187.86,4653749.0,0.0,1.0,186.1,188.69,185.41,187.86,4653749.0
-2017-12-12,186.01,187.85,184.8183,185.73,4135595.0,0.0,1.0,186.01,187.85,184.8183,185.73,4135595.0
-2017-12-11,187.85,189.42,185.91,186.22,5131319.0,0.0,1.0,187.85,189.42,185.91,186.22,5131319.0
-2017-12-08,186.5,189.42,186.3,188.54,4909440.0,0.0,1.0,186.5,189.42,186.3,188.54,4909440.0
-2017-12-07,185.71,187.34,183.22,185.2,4543492.0,0.0,1.0,185.71,187.34,183.22,185.2,4543492.0
-2017-12-06,183.38,186.4844,182.88,185.3,5006257.0,0.0,1.0,183.38,186.4844,182.88,185.3,5006257.0
-2017-12-05,183.5,188.14,181.19,184.21,5547802.0,0.0,1.0,183.5,188.14,181.19,184.21,5547802.0
-2017-12-04,189.36,189.72,178.38,184.04,9137873.0,0.0,1.0,189.36,189.72,178.38,184.04,9137873.0
-2017-12-01,186.99,189.8,185.0,186.82,6163366.0,0.0,1.0,186.99,189.8,185.0,186.82,6163366.0
-2017-11-30,190.31,190.86,186.68,187.58,6499326.0,0.0,1.0,190.31,190.86,186.68,187.58,6499326.0
-2017-11-29,198.91,199.029,184.32,188.15,13905339.0,0.0,1.0,198.91,199.029,184.32,188.15,13905339.0
-2017-11-28,195.34,199.68,194.01,199.18,6942358.0,0.0,1.0,195.34,199.68,194.01,199.18,6942358.0
-2017-11-27,195.56,195.85,194.0,195.05,3186677.0,0.0,1.0,195.56,195.85,194.0,195.05,3186677.0
-2017-11-24,196.65,196.9,195.33,195.75,2160300.0,0.0,1.0,196.65,196.9,195.33,195.75,2160300.0
-2017-11-22,196.58,196.75,193.63,196.32,5879771.0,0.0,1.0,196.58,196.75,193.63,196.32,5879771.0
-2017-11-21,195.04,197.52,194.971,196.23,4598017.0,0.0,1.0,195.04,197.52,194.971,196.23,4598017.0
-2017-11-20,193.3,194.32,191.9,194.1,3727412.0,0.0,1.0,193.3,194.32,191.9,194.1,3727412.0
-2017-11-17,195.74,195.95,192.65,193.2,3753775.0,0.0,1.0,195.74,195.95,192.65,193.2,3753775.0
-2017-11-16,194.33,197.7,193.75,195.51,5655042.0,0.0,1.0,194.33,197.7,193.75,195.51,5655042.0
-2017-11-15,194.54,195.42,191.53,192.12,4162712.0,0.0,1.0,194.54,195.42,191.53,192.12,4162712.0
-2017-11-14,193.64,195.88,193.0,195.71,3408535.0,0.0,1.0,193.64,195.88,193.0,195.71,3408535.0
-2017-11-13,191.12,196.05,191.0,195.08,4598005.0,0.0,1.0,191.12,196.05,191.0,195.08,4598005.0
-2017-11-10,191.61,192.59,189.5,192.02,6609739.0,0.0,1.0,191.61,192.59,189.5,192.02,6609739.0
-2017-11-09,194.46,194.49,190.81,193.9,5839579.0,0.0,1.0,194.46,194.49,190.81,193.9,5839579.0
-2017-11-07,200.0,200.61,194.8,195.89,6413310.0,0.0,1.0,200.0,200.61,194.8,195.89,6413310.0
-2017-11-06,200.0,202.48,198.09,200.13,5834857.0,0.0,1.0,200.0,202.48,198.09,200.13,5834857.0
-2017-11-03,199.8,200.55,197.99,200.01,3643216.0,0.0,1.0,199.8,200.55,197.99,200.01,3643216.0
-2017-11-02,197.45,199.44,197.0901,199.32,3578289.0,0.0,1.0,197.45,199.44,197.0901,199.32,3578289.0
-2017-11-01,197.24,199.199,196.0,198.0,4983343.0,0.0,1.0,197.24,199.199,196.0,198.0,4983343.0
-2017-10-31,198.21,198.59,195.218,196.43,5437925.0,0.0,1.0,198.21,198.59,195.218,196.43,5437925.0
-2017-10-30,199.62,201.099,197.0721,198.37,5412277.0,0.0,1.0,199.62,201.099,197.0721,198.37,5412277.0
-2017-10-27,197.2,200.65,196.22,199.54,8088364.0,0.0,1.0,197.2,200.65,196.22,199.54,8088364.0
-2017-10-26,194.66,197.61,194.08,195.21,5101258.0,0.0,1.0,194.66,197.61,194.08,195.21,5101258.0
-2017-10-25,195.38,197.055,193.01,193.77,5231713.0,0.0,1.0,195.38,197.055,193.01,193.77,5231713.0
-2017-10-24,192.75,196.735,191.4,196.02,6985460.0,0.0,1.0,192.75,196.735,191.4,196.02,6985460.0
-2017-10-23,194.17,194.8999,191.0346,192.47,6952997.0,0.0,1.0,194.17,194.8999,191.0346,192.47,6952997.0
-2017-10-20,195.9,196.38,193.77,194.16,5907121.0,0.0,1.0,195.9,196.38,193.77,194.16,5907121.0
-2017-10-19,193.01,195.25,191.16,195.13,7007447.0,0.0,1.0,193.01,195.25,191.16,195.13,7007447.0
-2017-10-18,199.99,200.01,194.25,195.54,11133883.0,0.0,1.0,199.99,200.01,194.25,195.54,11133883.0
-2017-10-17,200.11,204.38,197.77,199.48,23819054.0,0.0,1.0,200.11,204.38,197.77,199.48,23819054.0
-2017-10-16,201.95,202.83,197.86,202.68,18103086.0,0.0,1.0,201.95,202.83,197.86,202.68,18103086.0
-2017-10-13,199.7,200.8199,197.1866,199.49,11929816.0,0.0,1.0,199.7,200.8199,197.1866,199.49,11929816.0
-2017-10-12,196.75,198.62,194.71,195.86,7723224.0,0.0,1.0,196.75,198.62,194.71,195.86,7723224.0
-2017-10-11,195.57,196.2199,193.81,194.95,5544715.0,0.0,1.0,195.57,196.2199,193.81,194.95,5544715.0
-2017-10-10,197.85,198.3,192.1,195.08,6179012.0,0.0,1.0,197.85,198.3,192.1,195.08,6179012.0
-2017-10-09,199.1,199.4,196.56,196.87,6912140.0,0.0,1.0,199.1,199.4,196.56,196.87,6912140.0
-2017-10-06,194.3,198.92,192.05,198.02,15096222.0,0.0,1.0,194.3,198.92,192.05,198.02,15096222.0
-2017-10-05,185.65,194.49,184.49,194.39,19270032.0,0.0,1.0,185.65,194.49,184.49,194.39,19270032.0
-2017-10-04,181.41,186.7,181.25,184.45,9170855.0,0.0,1.0,181.41,186.7,181.25,184.45,9170855.0
-2017-10-03,177.65,179.7,177.55,179.19,3903112.0,0.0,1.0,177.65,179.7,177.55,179.19,3903112.0
-2017-10-02,182.11,182.8,176.58,177.01,7316345.0,0.0,1.0,182.11,182.8,176.58,177.01,7316345.0
-2017-09-29,180.73,182.9,180.65,181.35,4193999.0,0.0,1.0,180.73,182.9,180.65,181.35,4193999.0
-2017-09-28,181.25,181.95,179.36,180.7,4064507.0,0.0,1.0,181.25,181.95,179.36,180.7,4064507.0
-2017-09-27,181.01,183.34,180.7,181.97,4963152.0,0.0,1.0,181.01,183.34,180.7,181.97,4963152.0
-2017-09-26,180.7,180.95,176.55,179.38,5572599.0,0.0,1.0,180.7,180.95,176.55,179.38,5572599.0
-2017-09-25,186.46,186.55,177.7,178.55,9322531.0,0.0,1.0,186.46,186.55,177.7,178.55,9322531.0
-2017-09-22,188.4,189.85,186.39,187.35,5420227.0,0.0,1.0,188.4,189.85,186.39,187.35,5420227.0
-2017-09-21,185.82,189.95,184.51,188.78,7113489.0,0.0,1.0,185.82,189.95,184.51,188.78,7113489.0
-2017-09-20,186.1,186.5,183.2,185.51,4473036.0,0.0,1.0,186.1,186.5,183.2,185.51,4473036.0
-2017-09-19,184.98,186.23,184.17,185.68,4951465.0,0.0,1.0,184.98,186.23,184.17,185.68,4951465.0
-2017-09-18,183.61,185.45,182.73,184.62,5318130.0,0.0,1.0,183.61,185.45,182.73,184.62,5318130.0
-2017-09-15,182.73,184.93,181.43,182.1,5442089.0,0.0,1.0,182.73,184.93,181.43,182.1,5442089.0
-2017-09-14,183.25,185.2882,182.07,182.63,4469985.0,0.0,1.0,183.25,185.2882,182.07,182.63,4469985.0
-2017-09-13,184.07,184.4995,182.55,183.64,4303277.0,0.0,1.0,184.07,184.4995,182.55,183.64,4303277.0
-2017-09-12,182.55,185.33,180.6435,185.15,6606688.0,0.0,1.0,182.55,185.33,180.6435,185.15,6606688.0
-2017-09-11,178.1,182.47,178.03,181.74,5936476.0,0.0,1.0,178.1,182.47,178.03,181.74,5936476.0
-2017-09-08,178.45,180.39,176.25,176.42,4577777.0,0.0,1.0,178.45,180.39,176.25,176.42,4577777.0
-2017-09-07,178.8,180.35,177.1,179.0,5938152.0,0.0,1.0,178.8,180.35,177.1,179.0,5938152.0
-2017-09-06,175.25,179.46,173.73,179.25,8695383.0,0.0,1.0,175.25,179.46,173.73,179.25,8695383.0
-2017-09-05,173.4,175.88,172.44,174.52,4580903.0,0.0,1.0,173.4,175.88,172.44,174.52,4580903.0
-2017-09-01,175.55,176.48,173.92,174.74,3781453.0,0.0,1.0,175.55,176.48,173.92,174.74,3781453.0
-2017-08-31,175.45,176.24,173.86,174.71,6886143.0,0.0,1.0,175.45,176.24,173.86,174.71,6886143.0
-2017-08-30,169.5,174.85,169.37,174.69,7985196.0,0.0,1.0,169.5,174.85,169.37,174.69,7985196.0
-2017-08-29,165.0,169.68,164.73,168.81,4573282.0,0.0,1.0,165.0,169.68,164.73,168.81,4573282.0
-2017-08-28,166.43,168.67,165.6,167.12,3619575.0,0.0,1.0,166.43,168.67,165.6,167.12,3619575.0
-2017-08-25,168.58,168.75,165.5,165.95,4045626.0,0.0,1.0,168.58,168.75,165.5,165.95,4045626.0
-2017-08-24,169.86,171.2363,166.15,168.13,5270931.0,0.0,1.0,169.86,171.2363,166.15,168.13,5270931.0
-2017-08-23,168.35,169.64,166.7,169.06,4616656.0,0.0,1.0,168.35,169.64,166.7,169.06,4616656.0
-2017-08-22,167.76,169.93,167.04,169.34,4857816.0,0.0,1.0,167.76,169.93,167.04,169.34,4857816.0
-2017-08-21,166.91,168.99,164.23,166.76,6303314.0,0.0,1.0,166.91,168.99,164.23,166.76,6303314.0
-2017-08-18,165.95,169.97,165.8,166.54,7363750.0,0.0,1.0,165.95,169.97,165.8,166.54,7363750.0
-2017-08-17,169.23,170.58,165.72,166.09,5161920.0,0.0,1.0,169.23,170.58,165.72,166.09,5161920.0
-2017-08-16,167.5,170.5,166.25,169.98,6916579.0,0.0,1.0,167.5,170.5,166.25,169.98,6916579.0
-2017-08-15,171.53,171.88,168.25,168.5,5470271.0,0.0,1.0,171.53,171.88,168.25,168.5,5470271.0
-2017-08-14,169.8,172.45,168.8,171.0,7377962.0,0.0,1.0,169.8,172.45,168.8,171.0,7377962.0
-2017-08-11,169.86,172.58,169.0,171.4,4972045.0,0.0,1.0,169.86,172.58,169.0,171.4,4972045.0
-2017-08-10,174.03,174.45,167.6,169.14,9539473.0,0.0,1.0,174.03,174.45,167.6,169.14,9539473.0
-2017-08-09,171.43,175.96,170.01,175.78,9573608.0,0.0,1.0,171.43,175.96,170.01,175.78,9573608.0
-2017-08-08,181.37,181.91,177.45,178.36,4806525.0,0.0,1.0,181.37,181.91,177.45,178.36,4806525.0
-2017-08-07,181.0,182.27,179.1,181.33,4470746.0,0.0,1.0,181.0,182.27,179.1,181.33,4470746.0
-2017-08-04,179.6,181.0,178.5,180.27,4446148.0,0.0,1.0,179.6,181.0,178.5,180.27,4446148.0
-2017-08-03,180.53,181.2248,178.02,179.23,4596187.0,0.0,1.0,180.53,181.2248,178.02,179.23,4596187.0
-2017-08-02,182.22,182.57,177.8149,180.74,5713517.0,0.0,1.0,182.22,182.57,177.8149,180.74,5713517.0
-2017-08-01,182.49,184.62,181.43,182.03,5003248.0,0.0,1.0,182.49,184.62,181.43,182.03,5003248.0
-2017-07-31,184.26,184.9738,180.65,181.66,4776740.0,0.0,1.0,184.26,184.9738,180.65,181.66,4776740.0
-2017-07-28,182.0,185.03,181.18,184.04,6166404.0,0.0,1.0,182.0,185.03,181.18,184.04,6166404.0
-2017-07-27,189.89,190.0,179.38,182.68,11013995.0,0.0,1.0,189.89,190.0,179.38,182.68,11013995.0
-2017-07-26,187.7,189.7043,187.51,189.08,4354866.0,0.0,1.0,187.7,189.7043,187.51,189.08,4354866.0
-2017-07-25,187.79,188.66,185.81,186.97,5357533.0,0.0,1.0,187.79,188.66,185.81,186.97,5357533.0
-2017-07-24,188.685,190.25,187.01,187.91,8646192.0,0.0,1.0,188.685,190.25,187.01,187.91,8646192.0
-2017-07-21,182.72,191.5,182.71,188.54,9215232.0,0.0,1.0,182.72,191.5,182.71,188.54,9215232.0
-2017-07-20,183.84,185.92,182.7,183.6,7688768.0,0.0,1.0,183.84,185.92,182.7,183.6,7688768.0
-2017-07-19,182.97,187.17,181.75,183.86,17149580.0,0.0,1.0,182.97,187.17,181.75,183.86,17149580.0
-2017-07-18,176.12,185.0,174.24,183.6,40126110.0,0.0,1.0,176.12,185.0,174.24,183.6,40126110.0
-2017-07-17,162.91,163.55,160.0201,161.7,12299024.0,0.0,1.0,162.91,163.55,160.0201,161.7,12299024.0
-2017-07-14,159.3,161.35,157.97,161.12,5412128.0,0.0,1.0,159.3,161.35,157.97,161.12,5412128.0
-2017-07-13,158.51,160.13,156.98,158.17,6666000.0,0.0,1.0,158.51,160.13,156.98,158.17,6666000.0
-2017-07-12,155.77,158.8,155.77,158.75,8095303.0,0.0,1.0,155.77,158.8,155.77,158.75,8095303.0
-2017-07-11,152.37,155.23,151.55,154.33,4824579.0,0.0,1.0,152.37,155.23,151.55,154.33,4824579.0
-2017-07-10,150.34,153.23,149.65,152.67,5113353.0,0.0,1.0,150.34,153.23,149.65,152.67,5113353.0
-2017-07-07,146.65,150.75,146.65,150.18,5490809.0,0.0,1.0,146.65,150.75,146.65,150.18,5490809.0
-2017-07-06,146.13,147.27,144.25,146.25,5253871.0,0.0,1.0,146.13,147.27,144.25,146.25,5253871.0
-2017-07-05,146.58,148.26,145.58,147.61,4469163.0,0.0,1.0,146.58,148.26,145.58,147.61,4469163.0
-2017-07-03,149.8,150.45,145.8,146.17,3907790.0,0.0,1.0,149.8,150.45,145.8,146.17,3907790.0
-2017-06-30,149.76,150.71,148.42,149.41,5164844.0,0.0,1.0,149.76,150.71,148.42,149.41,5164844.0
-2017-06-29,152.82,152.82,148.0,150.09,7106930.0,0.0,1.0,152.82,152.82,148.0,150.09,7106930.0
-2017-06-28,151.64,154.2,150.12,153.41,5522740.0,0.0,1.0,151.64,154.2,150.12,153.41,5522740.0
-2017-06-27,156.62,156.9775,150.7197,151.03,7386827.0,0.0,1.0,156.62,156.9775,150.7197,151.03,7386827.0
-2017-06-26,158.78,159.97,156.56,157.5,5951060.0,0.0,1.0,158.78,159.97,156.56,157.5,5951060.0
-2017-06-23,155.01,158.19,153.76,158.03,6086644.0,0.0,1.0,155.01,158.19,153.76,158.03,6086644.0
-2017-06-22,155.13,155.2,153.7,154.89,3735995.0,0.0,1.0,155.13,155.2,153.7,154.89,3735995.0
-2017-06-21,152.5,155.38,152.26,155.03,5783436.0,0.0,1.0,152.5,155.38,152.26,155.03,5783436.0
-2017-06-20,153.68,154.5,151.4,152.05,4850911.0,0.0,1.0,153.68,154.5,151.4,152.05,4850911.0
-2017-06-19,154.29,155.58,152.41,153.4,6461866.0,0.0,1.0,154.29,155.58,152.41,153.4,6461866.0
-2017-06-16,151.45,153.53,150.39,152.38,6751799.0,0.0,1.0,151.45,153.53,150.39,152.38,6751799.0
-2017-06-15,149.44,152.56,147.3,151.76,6976720.0,0.0,1.0,149.44,152.56,147.3,151.76,6976720.0
-2017-06-14,154.34,155.615,150.28,152.2,6364572.0,0.0,1.0,154.34,155.615,150.28,152.2,6364572.0
-2017-06-13,154.38,155.68,150.13,152.72,8379437.0,0.0,1.0,154.38,155.68,150.13,152.72,8379437.0
-2017-06-12,155.3,155.53,148.31,151.44,14045559.0,0.0,1.0,155.3,155.53,148.31,151.44,14045559.0
-2017-06-09,166.27,166.27,154.5,158.03,10255110.0,0.0,1.0,166.27,166.27,154.5,158.03,10255110.0
-2017-06-08,166.12,166.87,164.84,165.88,3666393.0,0.0,1.0,166.12,166.87,164.84,165.88,3666393.0
-2017-06-07,165.6,166.4,164.4086,165.61,3285592.0,0.0,1.0,165.6,166.4,164.4086,165.61,3285592.0
-2017-06-06,164.95,166.82,164.51,165.17,4325459.0,0.0,1.0,164.95,166.82,164.51,165.17,4325459.0
-2017-06-05,165.49,165.5,163.43,165.06,3830296.0,0.0,1.0,165.49,165.5,163.43,165.06,3830296.0
-2017-06-02,163.42,165.36,162.8,165.18,4217679.0,0.0,1.0,163.42,165.36,162.8,165.18,4217679.0
-2017-06-01,163.52,163.9316,161.7,162.99,3869808.0,0.0,1.0,163.52,163.9316,161.7,162.99,3869808.0
diff --git a/examples/quick/demos/stocqt/content/data/NTAP.csv b/examples/quick/demos/stocqt/content/data/NTAP.csv
deleted file mode 100644
index dcceae9ac7..0000000000
--- a/examples/quick/demos/stocqt/content/data/NTAP.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,55.8,55.94,55.26,55.32,1287431.0,0.0,1.0,55.8,55.94,55.26,55.32,1287431.0
-2017-12-28,56.25,56.45,55.39,55.8,904513.0,0.0,1.0,56.25,56.45,55.39,55.8,904513.0
-2017-12-27,55.9,56.19,55.76,56.15,961107.0,0.0,1.0,55.9,56.19,55.76,56.15,961107.0
-2017-12-26,56.2,56.3,55.64,55.86,875796.0,0.0,1.0,56.2,56.3,55.64,55.86,875796.0
-2017-12-22,56.19,56.49,56.16,56.3,1019859.0,0.0,1.0,56.19,56.49,56.16,56.3,1019859.0
-2017-12-21,57.09,57.17,56.13,56.21,2342109.0,0.0,1.0,57.09,57.17,56.13,56.21,2342109.0
-2017-12-20,58.42,58.44,56.88,57.04,1872565.0,0.0,1.0,58.42,58.44,56.88,57.04,1872565.0
-2017-12-19,57.71,58.125,57.47,57.91,3065092.0,0.0,1.0,57.71,58.125,57.47,57.91,3065092.0
-2017-12-18,57.76,58.13,57.43,57.73,2009903.0,0.0,1.0,57.76,58.13,57.43,57.73,2009903.0
-2017-12-15,57.29,57.88,57.26,57.27,4421855.0,0.0,1.0,57.29,57.88,57.26,57.27,4421855.0
-2017-12-14,57.89,58.16,57.25,57.37,2368380.0,0.0,1.0,57.89,58.16,57.25,57.37,2368380.0
-2017-12-13,57.95,58.32,57.71,57.78,2930515.0,0.0,1.0,57.95,58.32,57.71,57.78,2930515.0
-2017-12-12,58.67,58.82,57.76,57.8,2540225.0,0.0,1.0,58.67,58.82,57.76,57.8,2540225.0
-2017-12-11,58.09,58.99,58.0,58.58,2795677.0,0.0,1.0,58.09,58.99,58.0,58.58,2795677.0
-2017-12-08,57.9,58.63,57.475,58.26,3376794.0,0.0,1.0,57.9,58.63,57.475,58.26,3376794.0
-2017-12-07,57.21,57.82,56.72,57.53,2822878.0,0.0,1.0,57.21,57.82,56.72,57.53,2822878.0
-2017-12-06,56.14,57.275,55.92,57.21,3139341.0,0.0,1.0,56.14,57.275,55.92,57.21,3139341.0
-2017-12-05,55.97,56.56,55.62,56.14,2585323.0,0.0,1.0,55.97,56.56,55.62,56.14,2585323.0
-2017-12-04,56.72,58.11,55.92,55.93,4249052.0,0.0,1.0,56.72,58.11,55.92,55.93,4249052.0
-2017-12-01,55.59,56.51,54.93,56.41,4054006.0,0.0,1.0,55.59,56.51,54.93,56.41,4054006.0
-2017-11-30,56.79,57.75,56.5,56.51,4294760.0,0.0,1.0,56.79,57.75,56.5,56.51,4294760.0
-2017-11-29,56.67,57.18,56.08,56.23,2628942.0,0.0,1.0,56.67,57.18,56.08,56.23,2628942.0
-2017-11-28,56.15,56.91,56.08,56.8,2472780.0,0.0,1.0,56.15,56.91,56.08,56.8,2472780.0
-2017-11-27,56.0,56.32,55.205,56.23,2818463.0,0.0,1.0,56.0,56.32,55.205,56.23,2818463.0
-2017-11-24,56.1,56.55,56.0,56.41,1533554.0,0.0,1.0,56.1,56.55,56.0,56.41,1533554.0
-2017-11-22,55.0,56.1,54.69,56.05,2732890.0,0.0,1.0,55.0,56.1,54.69,56.05,2732890.0
-2017-11-21,54.55,55.5,54.44,55.08,3438391.0,0.0,1.0,54.55,55.5,54.44,55.08,3438391.0
-2017-11-20,52.5,54.81,52.46,54.73,4364375.0,0.0,1.0,52.5,54.81,52.46,54.73,4364375.0
-2017-11-17,53.03,54.72,52.5,52.95,5601447.0,0.0,1.0,53.03,54.72,52.5,52.95,5601447.0
-2017-11-16,51.41,53.89,51.31,53.11,12798497.0,0.0,1.0,51.41,53.89,51.31,53.11,12798497.0
-2017-11-15,45.45,46.09,45.24,45.82,3834732.0,0.0,1.0,45.45,46.09,45.24,45.82,3834732.0
-2017-11-14,45.95,46.14,45.59,45.62,2122392.0,0.0,1.0,45.95,46.14,45.59,45.62,2122392.0
-2017-11-13,46.21,46.62,45.93,46.0,2314390.0,0.0,1.0,46.21,46.62,45.93,46.0,2314390.0
-2017-11-10,46.19,46.7,46.1,46.34,1641852.0,0.0,1.0,46.19,46.7,46.1,46.34,1641852.0
-2017-11-09,46.15,47.2,45.93,46.3,3559622.0,0.0,1.0,46.15,47.2,45.93,46.3,3559622.0
-2017-11-07,45.0,45.07,44.41,44.65,1904133.0,0.0,1.0,45.0,45.07,44.41,44.65,1904133.0
-2017-11-06,44.07,45.12,44.02,45.005,2541032.0,0.0,1.0,44.07,45.12,44.02,45.005,2541032.0
-2017-11-03,44.39,44.485,43.91,44.24,2055137.0,0.0,1.0,44.39,44.485,43.91,44.24,2055137.0
-2017-11-02,44.55,44.605,43.94,44.25,2109252.0,0.0,1.0,44.55,44.605,43.94,44.25,2109252.0
-2017-11-01,44.74,44.9,44.4,44.53,1937032.0,0.0,1.0,44.74,44.9,44.4,44.53,1937032.0
-2017-10-31,43.71,44.57,43.56,44.42,2462916.0,0.0,1.0,43.71,44.57,43.56,44.42,2462916.0
-2017-10-30,43.74,43.95,43.24,43.52,2050846.0,0.0,1.0,43.74,43.95,43.24,43.52,2050846.0
-2017-10-27,44.52,44.52,43.86,44.01,1818983.0,0.0,1.0,44.52,44.52,43.86,44.01,1818983.0
-2017-10-26,43.92,44.675,43.82,44.42,1567088.0,0.0,1.0,43.92,44.675,43.82,44.42,1567088.0
-2017-10-25,44.66,44.66,43.665,43.71,3428810.0,0.0,1.0,44.66,44.66,43.665,43.71,3428810.0
-2017-10-24,44.7,45.03,44.65,44.82,2477689.0,0.0,1.0,44.7,45.03,44.65,44.82,2477689.0
-2017-10-23,44.92,45.14,44.66,44.74,2719135.0,0.0,1.0,44.92,45.14,44.66,44.74,2719135.0
-2017-10-20,44.57,45.03,44.39,44.56,2540716.0,0.0,1.0,44.57,45.03,44.39,44.56,2540716.0
-2017-10-19,44.37,44.505,43.91,44.26,2253612.0,0.0,1.0,44.37,44.505,43.91,44.26,2253612.0
-2017-10-18,44.32,44.64,44.08,44.62,2523179.0,0.0,1.0,44.32,44.64,44.08,44.62,2523179.0
-2017-10-17,43.29,44.11,43.29,44.08,1760179.0,0.0,1.0,43.29,44.11,43.29,44.08,1760179.0
-2017-10-16,43.83,43.939,43.65,43.72,1433772.0,0.0,1.0,43.83,43.939,43.65,43.72,1433772.0
-2017-10-13,43.65,44.22,43.615,43.63,1840650.0,0.0,1.0,43.65,44.22,43.615,43.63,1840650.0
-2017-10-12,43.38,43.59,42.99,43.42,3223379.0,0.0,1.0,43.38,43.59,42.99,43.42,3223379.0
-2017-10-11,43.54,43.9399,43.29,43.51,1654470.0,0.0,1.0,43.54,43.9399,43.29,43.51,1654470.0
-2017-10-10,44.36,44.52,43.57,43.66,3930121.0,0.0,1.0,44.36,44.52,43.57,43.66,3930121.0
-2017-10-09,44.42,44.815,44.25,44.37,2039538.0,0.0,1.0,44.42,44.815,44.25,44.37,2039538.0
-2017-10-06,44.34,44.63,44.05,44.43,1778991.0,0.0,1.0,44.34,44.63,44.05,44.43,1778991.0
-2017-10-05,44.28,44.565,44.17,44.55,2957479.0,0.2,1.0,44.28,44.565,44.17,44.55,2957479.0
-2017-10-04,44.19,44.54,44.17,44.46,2875404.0,0.0,1.0,43.992502793296,44.340938547486,43.972592178771,44.261296089385,2875404.0
-2017-10-03,44.07,44.52,43.75,44.39,2905694.0,0.0,1.0,43.873039106145,44.321027932961,43.554469273743,44.191608938547,2905694.0
-2017-10-02,43.89,44.1,43.71,44.0,3186168.0,0.0,1.0,43.693843575419,43.902905027933,43.514648044693,43.803351955307,3186168.0
-2017-09-29,43.7,43.975,43.39,43.76,1866218.0,0.0,1.0,43.50469273743,43.778463687151,43.196078212291,43.564424581006,1866218.0
-2017-09-28,43.95,44.045,43.52,43.84,2195811.0,0.0,1.0,43.753575418994,43.848150837989,43.325497206704,43.644067039106,2195811.0
-2017-09-27,43.98,44.47,43.56,44.17,2566121.0,0.0,1.0,43.783441340782,44.271251396648,43.365318435754,43.972592178771,2566121.0
-2017-09-26,43.0,43.82,42.875,43.76,3262283.0,0.0,1.0,42.80782122905,43.624156424581,42.683379888268,43.564424581006,3262283.0
-2017-09-25,42.17,43.085,42.11,42.7,2486787.0,0.0,1.0,41.981530726257,42.892441340782,41.921798882682,42.509162011173,2486787.0
-2017-09-22,41.77,42.6,41.7,42.55,1820422.0,0.0,1.0,41.583318435754,42.409608938547,41.513631284916,42.359832402235,1820422.0
-2017-09-21,41.75,42.04,41.64,41.86,2621389.0,0.0,1.0,41.563407821229,41.852111731844,41.453899441341,41.672916201117,2621389.0
-2017-09-20,41.72,41.91,41.22,41.7,2878107.0,0.0,1.0,41.533541899441,41.72269273743,41.035776536313,41.513631284916,2878107.0
-2017-09-19,41.79,42.32,41.3,41.71,5252863.0,0.0,1.0,41.603229050279,42.130860335196,41.115418994413,41.523586592179,5252863.0
-2017-09-18,41.04,41.16,40.51,40.63,2686167.0,0.0,1.0,40.856581005587,40.976044692737,40.32894972067,40.448413407821,2686167.0
-2017-09-15,40.72,41.06,40.33,41.03,3537425.0,0.0,1.0,40.538011173184,40.876491620112,40.149754189944,40.846625698324,3537425.0
-2017-09-14,40.17,40.69,39.95,40.65,2799617.0,0.0,1.0,39.990469273743,40.508145251397,39.771452513966,40.468324022346,2799617.0
-2017-09-13,39.82,40.54,39.55,40.28,3019737.0,0.0,1.0,39.642033519553,40.358815642458,39.373240223464,40.099977653631,3019737.0
-2017-09-12,39.62,40.24,39.16,39.93,4031681.0,0.0,1.0,39.442927374302,40.060156424581,38.984983240223,39.751541899441,4031681.0
-2017-09-11,38.91,39.56,38.8,39.46,2798378.0,0.0,1.0,38.736100558659,39.383195530726,38.626592178771,39.283642458101,2798378.0
-2017-09-08,38.61,38.835,38.3799,38.63,2715485.0,0.0,1.0,38.437441340782,38.66143575419,38.20836972067,38.457351955307,2715485.0
-2017-09-07,38.9,38.9,38.12,38.69,2541004.0,0.0,1.0,38.726145251397,38.726145251397,37.949631284916,38.517083798883,2541004.0
-2017-09-06,38.09,38.97,37.855,38.85,3720730.0,0.0,1.0,37.919765363128,38.795832402235,37.685815642458,38.676368715084,3720730.0
-2017-09-05,38.49,38.74,37.55,37.98,2318304.0,0.0,1.0,38.317977653631,38.566860335196,37.38217877095,37.81025698324,2318304.0
-2017-09-01,38.82,38.9,38.56,38.65,1784904.0,0.0,1.0,38.646502793296,38.726145251397,38.387664804469,38.477262569832,1784904.0
-2017-08-31,38.46,38.6975,38.07,38.66,2576968.0,0.0,1.0,38.288111731844,38.52455027933,37.899854748603,38.487217877095,2576968.0
-2017-08-30,37.98,38.26,37.84,38.22,1625130.0,0.0,1.0,37.81025698324,38.089005586592,37.670882681564,38.049184357542,1625130.0
-2017-08-29,37.92,38.315,37.89,38.03,1437800.0,0.0,1.0,37.750525139665,38.143759776536,37.720659217877,37.860033519553,1437800.0
-2017-08-28,38.73,38.81,38.18,38.34,1448478.0,0.0,1.0,38.556905027933,38.636547486034,38.009363128492,38.168648044693,1448478.0
-2017-08-25,38.97,38.99,38.52,38.54,1868152.0,0.0,1.0,38.795832402235,38.81574301676,38.347843575419,38.367754189944,1868152.0
-2017-08-24,38.76,38.93,38.51,38.81,2128753.0,0.0,1.0,38.586770949721,38.756011173184,38.337888268156,38.636547486034,2128753.0
-2017-08-23,38.49,38.95,38.35,38.6792,2625700.0,0.0,1.0,38.317977653631,38.775921787709,38.178603351955,38.506332067039,2625700.0
-2017-08-22,39.17,39.21,38.59,38.7,3834442.0,0.0,1.0,38.994938547486,39.034759776536,38.417530726257,38.527039106145,3834442.0
-2017-08-21,39.76,39.87,38.51,38.95,4371303.0,0.0,1.0,39.582301675978,39.691810055866,38.337888268156,38.775921787709,4371303.0
-2017-08-18,39.62,39.87,39.26,39.35,4934878.0,0.0,1.0,39.442927374302,39.691810055866,39.084536312849,39.174134078212,4934878.0
-2017-08-17,40.37,41.49,39.475,39.56,11599368.0,0.0,1.0,40.189575418994,41.304569832402,39.298575418994,39.383195530726,11599368.0
-2017-08-16,42.0,42.549,42.0,42.41,3481046.0,0.0,1.0,41.812290502793,42.358836871508,41.812290502793,42.220458100559,3481046.0
-2017-08-15,42.96,43.05,41.97,41.97,3781136.0,0.0,1.0,42.768,42.857597765363,41.782424581006,41.782424581006,3781136.0
-2017-08-14,42.37,42.53,41.75,42.03,3763330.0,0.0,1.0,42.180636871508,42.339921787709,41.563407821229,41.842156424581,3763330.0
-2017-08-11,41.44,41.85,41.23,41.49,1407483.0,0.0,1.0,41.254793296089,41.662960893855,41.045731843575,41.304569832402,1407483.0
-2017-08-10,42.01,42.23,41.23,41.29,2117207.0,0.0,1.0,41.822245810056,42.041262569832,41.045731843575,41.105463687151,2117207.0
-2017-08-09,42.49,42.61,42.18,42.24,1538691.0,0.0,1.0,42.300100558659,42.41956424581,41.99148603352,42.051217877095,1538691.0
-2017-08-08,42.66,43.16,42.52,42.69,1901300.0,0.0,1.0,42.469340782123,42.967106145251,42.329966480447,42.499206703911,1901300.0
-2017-08-07,42.83,42.8843,42.44,42.74,1611901.0,0.0,1.0,42.638581005587,42.692638324022,42.250324022346,42.548983240223,1611901.0
-2017-08-04,43.07,43.11,42.61,42.74,1871097.0,0.0,1.0,42.877508379888,42.917329608939,42.41956424581,42.548983240223,1871097.0
-2017-08-03,43.34,43.34,42.74,42.91,2350321.0,0.0,1.0,43.146301675978,43.146301675978,42.548983240223,42.718223463687,2350321.0
-2017-08-02,43.65,43.79,43.04,43.41,1460145.0,0.0,1.0,43.454916201117,43.594290502793,42.847642458101,43.215988826816,1460145.0
-2017-08-01,43.72,43.83,43.16,43.55,2576291.0,0.0,1.0,43.524603351955,43.634111731844,42.967106145251,43.355363128492,2576291.0
-2017-07-31,43.67,43.82,43.11,43.42,2360992.0,0.0,1.0,43.474826815642,43.624156424581,42.917329608939,43.225944134078,2360992.0
-2017-07-28,43.66,43.86,43.09,43.49,2581751.0,0.0,1.0,43.46487150838,43.663977653631,42.897418994413,43.295631284916,2581751.0
-2017-07-27,44.32,44.97,43.65,44.0197,4149229.0,0.0,1.0,44.121921787709,44.769016759777,43.454916201117,43.822963910615,4149229.0
-2017-07-26,44.87,44.87,44.025,44.36,3272594.0,0.0,1.0,44.669463687151,44.669463687151,43.828240223464,44.16174301676,3272594.0
-2017-07-25,44.58,44.94,44.21,44.76,3495184.0,0.0,1.0,44.380759776536,44.739150837989,44.012413407821,44.559955307263,3495184.0
-2017-07-24,44.4,45.23,44.4,44.86,2877601.0,0.0,1.0,44.20156424581,45.027854748603,44.20156424581,44.659508379888,2877601.0
-2017-07-21,44.56,45.24,44.18,44.76,4496318.0,0.0,1.0,44.360849162011,45.037810055866,43.982547486034,44.559955307263,4496318.0
-2017-07-20,44.18,44.69,44.09,44.6,3563323.0,0.0,1.0,43.982547486034,44.490268156425,43.89294972067,44.400670391061,3563323.0
-2017-07-19,43.88,44.5299,43.83,44.16,3618018.0,0.0,1.0,43.683888268156,44.330883687151,43.634111731844,43.962636871508,3618018.0
-2017-07-18,43.25,43.88,43.18,43.77,3030714.0,0.0,1.0,43.056703910615,43.683888268156,42.987016759777,43.574379888268,3030714.0
-2017-07-17,43.2,43.76,43.0,43.62,5253442.0,0.0,1.0,43.006927374302,43.564424581006,42.80782122905,43.42505027933,5253442.0
-2017-07-14,42.04,43.9,42.0,43.64,8405233.0,0.0,1.0,41.852111731844,43.703798882682,41.812290502793,43.444960893855,8405233.0
-2017-07-13,40.17,41.5,40.04,41.38,3940472.0,0.0,1.0,39.990469273743,41.314525139665,39.86105027933,41.195061452514,3940472.0
-2017-07-12,39.45,40.19,39.1701,40.17,2597317.0,0.0,1.0,39.273687150838,40.010379888268,38.995038100559,39.990469273743,2597317.0
-2017-07-11,38.55,39.11,38.51,39.07,2155200.0,0.0,1.0,38.377709497207,38.935206703911,38.337888268156,38.89538547486,2155200.0
-2017-07-10,38.5,38.91,38.35,38.57,2273543.0,0.0,1.0,38.327932960894,38.736100558659,38.178603351955,38.397620111732,2273543.0
-2017-07-07,38.44,38.83,38.32,38.64,1883863.0,0.0,1.0,38.268201117318,38.656458100559,38.148737430168,38.46730726257,1883863.0
-2017-07-06,39.33,39.39,38.2,38.3,2510853.0,0.0,1.0,39.154223463687,39.213955307263,38.029273743017,38.128826815642,2510853.0
-2017-07-05,39.55,40.25,39.475,39.66,2484571.0,0.2,1.0,39.373240223464,40.070111731844,39.298575418994,39.482748603352,2484571.0
-2017-07-03,40.44,40.5,39.53,39.57,1568751.0,0.0,1.0,40.057259245348,40.116691380726,39.155871858768,39.195493282354,1568751.0
-2017-06-30,40.18,40.38,39.73,40.05,3859273.0,0.0,1.0,39.799719992039,39.997827109969,39.353978976698,39.670950365385,3859273.0
-2017-06-29,40.28,40.38,39.55,40.1,3177050.0,0.0,1.0,39.898773551004,39.997827109969,39.175682570561,39.720477144867,3177050.0
-2017-06-28,39.8,40.59,39.6,40.41,2635603.0,0.0,1.0,39.423316467973,40.205839583795,39.225209350044,40.027543177658,2635603.0
-2017-06-27,40.14,40.35,39.62,39.63,2705421.0,0.0,1.0,39.760098568453,39.968111042279,39.245020061837,39.254925417733,2705421.0
-2017-06-26,39.87,40.515,39.87,40.29,3251780.0,0.0,1.0,39.492653959248,40.131549414571,39.492653959248,39.9086789069,3251780.0
-2017-06-23,39.13,40.07,39.01,39.87,4505252.0,0.0,1.0,38.759657622909,39.690761077178,38.640793352152,39.492653959248,4505252.0
-2017-06-22,38.59,39.36,38.58,39.11,3042690.0,0.0,1.0,38.2247684045,38.987480808528,38.214863048603,38.739846911116,3042690.0
-2017-06-21,38.36,38.86,38.3501,38.61,2462900.0,0.0,1.0,37.996945218881,38.492213013704,37.987138916543,38.244579116292,2462900.0
-2017-06-20,38.27,38.65,38.25,38.26,2206944.0,0.0,1.0,37.907797015812,38.284200539878,37.887986304019,37.897891659916,2206944.0
-2017-06-19,38.17,38.495,38.04,38.42,2487716.0,0.0,1.0,37.808743456848,38.130667523483,37.679973830193,38.056377354259,2487716.0
-2017-06-16,37.94,38.11,37.78,37.98,2238387.0,0.0,1.0,37.580920271229,37.749311321469,37.422434576885,37.620541694815,2238387.0
-2017-06-15,37.72,38.1,37.43,37.97,2208659.0,0.0,1.0,37.363002441506,37.739405965572,37.075747120508,37.610636338918,2208659.0
-2017-06-14,38.94,39.01,37.78,38.1,2849570.0,0.0,1.0,38.571455860876,38.640793352152,37.422434576885,37.739405965572,2849570.0
-2017-06-13,38.95,39.37,38.7,38.93,2827824.0,0.0,1.0,38.581361216773,38.997386164425,38.333727319361,38.56155050498,2827824.0
-2017-06-12,39.14,39.66,38.65,38.86,4222954.0,0.0,1.0,38.769562978806,39.284641485422,38.284200539878,38.492213013704,4222954.0
-2017-06-09,39.87,40.395,39.13,39.52,2961902.0,0.0,1.0,39.492653959248,40.012685143813,38.759657622909,39.145966502872,2961902.0
-2017-06-08,39.21,40.12,39.09,40.01,3552505.0,0.0,1.0,38.838900470081,39.74028785666,38.720036199323,39.631328941799,3552505.0
-2017-06-07,38.86,39.57,38.71,39.27,2414656.0,0.0,1.0,38.492213013704,39.195493282354,38.343632675257,38.89833260546,2414656.0
-2017-06-06,38.7,39.23,38.67,38.7,2459220.0,0.0,1.0,38.333727319361,38.858711181874,38.304011251671,38.333727319361,2459220.0
-2017-06-05,39.19,39.7,38.95,38.98,2387428.0,0.0,1.0,38.819089758288,39.324262909008,38.581361216773,38.611077284462,2387428.0
-2017-06-02,39.51,39.75,39.24,39.41,3121583.0,0.0,1.0,39.136061146975,39.373789688491,38.86861653777,39.037007588011,3121583.0
-2017-06-01,39.85,40.25,39.54,39.61,3933108.0,0.0,1.0,39.472843247455,39.869057483314,39.165777214665,39.23511470594,3933108.0
diff --git a/examples/quick/demos/stocqt/content/data/NVDA.csv b/examples/quick/demos/stocqt/content/data/NVDA.csv
deleted file mode 100644
index c37a25ae5b..0000000000
--- a/examples/quick/demos/stocqt/content/data/NVDA.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,198.46,198.46,193.5,193.5,6896330.0,0.0,1.0,198.46,198.46,193.5,193.5,6896330.0
-2017-12-28,198.13,199.38,197.1514,197.4,5978211.0,0.0,1.0,198.13,199.38,197.1514,197.4,5978211.0
-2017-12-27,196.9,199.97,196.31,197.17,8097374.0,0.0,1.0,196.9,199.97,196.31,197.17,8097374.0
-2017-12-26,193.03,197.75,191.82,197.44,8821296.0,0.0,1.0,193.03,197.75,191.82,197.44,8821296.0
-2017-12-22,194.4,195.65,191.25,195.27,11613423.0,0.0,1.0,194.4,195.65,191.25,195.27,11613423.0
-2017-12-21,196.94,197.95,195.55,195.89,7458634.0,0.0,1.0,196.94,197.95,195.55,195.89,7458634.0
-2017-12-20,197.7,198.07,194.55,196.8,7185318.0,0.0,1.0,197.7,198.07,194.55,196.8,7185318.0
-2017-12-19,197.52,197.73,194.96,196.11,9217358.0,0.0,1.0,197.52,197.73,194.96,196.11,9217358.0
-2017-12-18,193.2,198.02,192.0,197.9,11730697.0,0.0,1.0,193.2,198.02,192.0,197.9,11730697.0
-2017-12-15,188.251,192.38,185.62,191.56,16090200.0,0.0,1.0,188.251,192.38,185.62,191.56,16090200.0
-2017-12-14,185.92,189.34,184.6,186.47,10871746.0,0.0,1.0,185.92,189.34,184.6,186.47,10871746.0
-2017-12-13,192.5,192.55,185.88,186.18,13744496.0,0.0,1.0,192.5,192.55,185.88,186.18,13744496.0
-2017-12-12,192.9,193.84,189.89,190.84,11296559.0,0.0,1.0,192.9,193.84,189.89,190.84,11296559.0
-2017-12-11,192.06,194.78,191.42,194.66,9106693.0,0.0,1.0,192.06,194.78,191.42,194.66,9106693.0
-2017-12-08,194.01,194.78,191.15,191.49,11483868.0,0.0,1.0,194.01,194.78,191.15,191.49,11483868.0
-2017-12-07,191.96,193.6,190.12,191.99,13190983.0,0.0,1.0,191.96,193.6,190.12,191.99,13190983.0
-2017-12-06,185.7,190.14,184.84,189.26,11464458.0,0.0,1.0,185.7,190.14,184.84,189.26,11464458.0
-2017-12-05,182.4,192.7,180.58,187.74,24480558.0,0.0,1.0,182.4,192.7,180.58,187.74,24480558.0
-2017-12-04,200.05,200.3,184.5,186.66,27080405.0,0.0,1.0,200.05,200.3,184.5,186.66,27080405.0
-2017-12-01,199.31,200.13,192.47,197.68,16352946.0,0.0,1.0,199.31,200.13,192.47,197.68,16352946.0
-2017-11-30,199.2,202.68,196.65,200.71,20144301.0,0.0,1.0,199.2,202.68,196.65,200.71,20144301.0
-2017-11-29,210.01,210.1226,191.23,196.42,34731979.0,0.0,1.0,210.01,210.1226,191.23,196.42,34731979.0
-2017-11-28,214.35,214.73,208.24,210.71,12677148.0,0.0,1.0,214.35,214.73,208.24,210.71,12677148.0
-2017-11-27,217.31,217.36,214.01,214.14,10477983.0,0.0,1.0,217.31,217.36,214.01,214.14,10477983.0
-2017-11-24,215.59,217.0,214.6,216.96,4517982.0,0.0,1.0,215.59,217.0,214.6,216.96,4517982.0
-2017-11-22,217.0,217.0,213.61,214.93,8766814.0,0.0,1.0,217.0,217.0,213.61,214.93,8766814.0
-2017-11-21,215.69,216.52,214.4,216.05,9858634.0,0.0,1.0,215.69,216.52,214.4,216.05,9858634.0
-2017-11-20,211.99,214.57,210.5,214.08,9828414.0,0.0,1.0,211.99,214.57,210.5,214.08,9828414.0
-2017-11-17,213.92,215.35,210.75,211.36,12702474.0,0.0,1.0,213.92,215.35,210.75,211.36,12702474.0
-2017-11-16,212.98,214.2,211.25,211.61,9947915.0,0.0,1.0,212.98,214.2,211.25,211.61,9947915.0
-2017-11-15,211.95,212.0,207.8,209.98,12427082.0,0.0,1.0,211.95,212.0,207.8,209.98,12427082.0
-2017-11-14,213.0,214.8,211.23,214.18,13101484.0,0.0,1.0,213.0,214.8,211.23,214.18,13101484.0
-2017-11-13,216.14,217.17,212.01,212.63,14398431.0,0.0,1.0,216.14,217.17,212.01,212.63,14398431.0
-2017-11-10,213.08,218.67,211.63,216.14,31197127.0,0.0,1.0,213.08,218.67,211.63,216.14,31197127.0
-2017-11-09,205.27,206.33,200.37,205.32,20123846.0,0.0,1.0,205.27,206.33,200.37,205.32,20123846.0
-2017-11-07,210.55,212.9,210.0556,212.03,10580672.0,0.0,1.0,210.55,212.9,210.0556,212.03,10580672.0
-2017-11-06,207.2,209.98,206.7,209.63,9693716.0,0.0,1.0,207.2,209.98,206.7,209.63,9693716.0
-2017-11-03,207.2,208.69,205.341,208.69,8777981.0,0.0,1.0,207.2,208.69,205.341,208.69,8777981.0
-2017-11-02,206.0,207.81,203.65,205.94,8480413.0,0.0,1.0,206.0,207.81,203.65,205.94,8480413.0
-2017-11-01,209.35,209.97,204.6,207.2,12385654.0,0.0,1.0,209.35,209.97,204.6,207.2,12385654.0
-2017-10-31,205.13,207.89,204.9,206.81,10179802.0,0.0,1.0,205.13,207.89,204.9,206.81,10179802.0
-2017-10-30,201.86,206.0899,201.22,203.84,12522329.0,0.0,1.0,201.86,206.0899,201.22,203.84,12522329.0
-2017-10-27,197.8,201.87,196.75,201.86,14174171.0,0.0,1.0,197.8,201.87,196.75,201.86,14174171.0
-2017-10-26,194.78,196.16,193.81,195.69,7892651.0,0.0,1.0,194.78,196.16,193.81,195.69,7892651.0
-2017-10-25,197.08,199.22,191.17,193.66,20588601.0,0.0,1.0,197.08,199.22,191.17,193.66,20588601.0
-2017-10-24,196.99,198.75,195.94,198.68,9820462.0,0.0,1.0,196.99,198.75,195.94,198.68,9820462.0
-2017-10-23,197.78,198.85,195.8,196.62,10592416.0,0.0,1.0,197.78,198.85,195.8,196.62,10592416.0
-2017-10-20,198.49,199.59,196.54,196.9,11006029.0,0.0,1.0,198.49,199.59,196.54,196.9,11006029.0
-2017-10-19,194.44,198.0,192.4501,197.8,14156573.0,0.0,1.0,194.44,198.0,192.4501,197.8,14156573.0
-2017-10-18,198.11,198.14,193.32,197.58,14066925.0,0.0,1.0,198.11,198.14,193.32,197.58,14066925.0
-2017-10-17,197.09,198.9,196.35,197.75,11482547.0,0.0,1.0,197.09,198.9,196.35,197.75,11482547.0
-2017-10-16,195.8,198.048,193.24,197.93,14279032.0,0.0,1.0,195.8,198.048,193.24,197.93,14279032.0
-2017-10-13,193.55,195.0,191.65,194.59,15626525.0,0.0,1.0,193.55,195.0,191.65,194.59,15626525.0
-2017-10-12,191.08,193.09,189.9301,191.03,13036890.0,0.0,1.0,191.08,193.09,189.9301,191.03,13036890.0
-2017-10-11,189.6,191.0,187.74,190.94,13051762.0,0.0,1.0,189.6,191.0,187.74,190.94,13051762.0
-2017-10-10,191.43,192.95,187.26,188.88,24261445.0,0.0,1.0,191.43,192.95,187.26,188.88,24261445.0
-2017-10-09,182.79,186.73,182.03,185.39,13986610.0,0.0,1.0,182.79,186.73,182.03,185.39,13986610.0
-2017-10-06,179.65,181.84,179.0,181.3,7911087.0,0.0,1.0,179.65,181.84,179.0,181.3,7911087.0
-2017-10-05,181.86,182.0,179.56,180.77,10830438.0,0.0,1.0,181.86,182.0,179.56,180.77,10830438.0
-2017-10-04,179.62,181.77,178.14,180.87,10621386.0,0.0,1.0,179.62,181.77,178.14,180.87,10621386.0
-2017-10-03,179.25,180.58,177.58,179.37,9678430.0,0.0,1.0,179.25,180.58,177.58,179.37,9678430.0
-2017-10-02,180.8,181.98,177.0,179.0,12475560.0,0.0,1.0,180.8,181.98,177.0,179.0,12475560.0
-2017-09-29,179.08,179.73,177.25,178.77,14936876.0,0.0,1.0,179.08,179.73,177.25,178.77,14936876.0
-2017-09-28,176.02,176.18,173.76,175.68,10801464.0,0.0,1.0,176.02,176.18,173.76,175.68,10801464.0
-2017-09-27,175.62,176.27,172.75,175.73,17602299.0,0.0,1.0,175.62,176.27,172.75,175.73,17602299.0
-2017-09-26,176.45,178.68,170.35,171.96,27542805.0,0.0,1.0,176.45,178.68,170.35,171.96,27542805.0
-2017-09-25,177.75,177.8,170.16,171.0,21628235.0,0.0,1.0,177.75,177.8,170.16,171.0,21628235.0
-2017-09-22,180.3,182.31,178.6,179.0,12196947.0,0.0,1.0,180.3,182.31,178.6,179.0,12196947.0
-2017-09-21,181.64,182.7,177.61,180.7799,26631321.0,0.0,1.0,181.64,182.7,177.61,180.7799,26631321.0
-2017-09-20,187.5,189.42,184.21,185.84,16435216.0,0.0,1.0,187.5,189.42,184.21,185.84,16435216.0
-2017-09-19,185.51,189.85,184.615,187.35,21631434.0,0.0,1.0,185.51,189.85,184.615,187.35,21631434.0
-2017-09-18,185.14,191.2,184.86,187.55,41601951.0,0.0,1.0,185.14,191.2,184.86,187.55,41601951.0
-2017-09-15,172.86,180.11,172.65,180.11,33338633.0,0.0,1.0,172.86,180.11,172.65,180.11,33338633.0
-2017-09-14,168.79,172.56,167.8,169.4,12728431.0,0.0,1.0,168.79,172.56,167.8,169.4,12728431.0
-2017-09-13,168.59,171.54,167.28,170.37,14340105.0,0.0,1.0,168.59,171.54,167.28,170.37,14340105.0
-2017-09-12,170.0,170.0,166.97,169.61,10155905.0,0.0,1.0,170.0,170.0,166.97,169.61,10155905.0
-2017-09-11,165.54,169.4325,165.32,169.0,13934287.0,0.0,1.0,165.54,169.4325,165.32,169.0,13934287.0
-2017-09-08,166.11,166.71,162.71,163.69,12365074.0,0.0,1.0,166.11,166.71,162.71,163.69,12365074.0
-2017-09-07,166.49,167.89,164.95,166.58,8731886.0,0.0,1.0,166.49,167.89,164.95,166.58,8731886.0
-2017-09-06,167.24,167.8,164.4,165.81,9800559.0,0.0,1.0,167.24,167.8,164.4,165.81,9800559.0
-2017-09-05,168.38,168.5843,163.5625,165.91,17358768.0,0.0,1.0,168.38,168.5843,163.5625,165.91,17358768.0
-2017-09-01,169.95,171.9,169.6,170.46,11017001.0,0.0,1.0,169.95,171.9,169.6,170.46,11017001.0
-2017-08-31,166.5,169.6,166.2,169.44,15022660.0,0.0,1.0,166.5,169.6,166.2,169.44,15022660.0
-2017-08-30,165.5,166.13,164.27,165.68,9469680.0,0.0,1.0,165.5,166.13,164.27,165.68,9469680.0
-2017-08-29,162.59,165.58,162.261,164.7,7992338.0,0.0,1.0,162.59,165.58,162.261,164.7,7992338.0
-2017-08-28,164.58,165.1,162.33,164.97,9568908.0,0.0,1.0,164.58,165.1,162.33,164.97,9568908.0
-2017-08-25,166.17,166.58,163.55,163.81,8753208.0,0.0,1.0,166.17,166.58,163.55,163.81,8753208.0
-2017-08-24,167.1,167.28,164.12,165.19,11592997.0,0.0,1.0,167.1,167.28,164.12,165.19,11592997.0
-2017-08-23,161.2,166.25,160.85,165.8,14421053.0,0.0,1.0,161.2,166.25,160.85,165.8,14421053.0
-2017-08-22,160.49,162.79,159.71,162.51,11084658.0,0.14,1.0,160.49,162.79,159.71,162.51,11084658.0
-2017-08-21,162.49,162.95,157.37,159.12,15203637.0,0.0,1.0,162.35013771903,162.80974177682,157.23454472794,158.98303842607,15203637.0
-2017-08-18,163.67,164.36,159.64,161.5,14883408.0,0.0,1.0,163.52912204119,164.21852812788,159.50259083923,161.36098985552,14883408.0
-2017-08-17,164.81,165.5,161.38,161.47,12937916.0,0.0,1.0,164.66814079311,165.3575468798,161.24109314479,161.33101567784,12937916.0
-2017-08-16,167.59,168.54,163.84,165.15,14788247.0,0.0,1.0,167.44574792499,168.39493021826,163.69897571472,165.00784814018,14788247.0
-2017-08-15,168.61,169.67,165.59,166.98,18980198.0,0.0,1.0,168.46486996619,169.52395757762,165.44746941285,166.83627297879,18980198.0
-2017-08-14,159.67,168.55,159.2,168.4,31674266.0,0.0,1.0,159.53256501691,168.40492161082,159.06296956655,168.25505072241,31674266.0
-2017-08-11,157.14,159.0,152.91,155.95,37272782.0,0.0,1.0,157.00474269905,158.86314171534,152.77838364587,155.81576698432,37272782.0
-2017-08-10,172.16,172.66,164.33,164.74,26065538.0,0.0,1.0,172.01181432524,172.51138395327,164.1885539502,164.59820104519,26065538.0
-2017-08-09,168.43,172.21,167.67,172.11,13060514.0,0.0,1.0,168.28502490009,172.06177128804,167.52567906548,171.96185736243,13060514.0
-2017-08-08,173.89,174.56,168.71,170.3,18632853.0,0.0,1.0,173.74032523824,174.40974853981,168.56478389179,170.15341530895,18632853.0
-2017-08-07,168.39,172.37,168.0,172.25,17743004.0,0.0,1.0,168.24505932985,172.22163356901,167.85539501998,172.10173685828,17743004.0
-2017-08-04,167.4,170.07,166.48,167.21,14653397.0,0.0,1.0,167.25591146634,169.92361328005,166.33670335075,167.06607500769,14653397.0
-2017-08-03,164.37,166.63,163.68,166.48,10926536.0,0.0,1.0,164.22851952044,166.48657423916,163.53911343375,166.33670335075,10926536.0
-2017-08-02,165.75,165.91,161.27,164.39,11565556.0,0.0,1.0,165.60733169382,165.76719397479,161.13118782662,164.24850230556,11565556.0
-2017-08-01,162.125,164.56,161.0,164.49,10606575.0,0.0,1.0,161.98545189056,164.4183559791,160.86142022748,164.34841623117,10606575.0
-2017-07-31,164.94,166.4,160.62,162.51,13800261.0,0.0,1.0,164.7980288964,166.25677221027,160.48174731018,162.37012050415,13800261.0
-2017-07-28,160.29,165.38,159.28,164.39,12776296.0,0.0,1.0,160.15203135567,165.23765016907,159.14290070704,164.24850230556,12776296.0
-2017-07-27,168.27,168.74,157.56,161.74,18888931.0,0.0,1.0,168.12516261912,168.59475806947,157.4243811866,161.60078327698,18888931.0
-2017-07-26,167.68,169.927,165.85,167.26,15755026.0,0.0,1.0,167.53567045804,169.78073636643,165.70724561943,167.11603197049,15755026.0
-2017-07-25,165.22,165.93,163.581,165.35,12002860.0,0.0,1.0,165.0777878881,165.78717675991,163.4401986474,165.20767599139,12002860.0
-2017-07-24,168.39,168.78,165.72,166.15,15868676.0,0.0,1.0,168.24505932985,168.63472363972,165.57735751614,166.00698739625,15868676.0
-2017-07-21,166.67,169.3,166.09,168.1,15886110.0,0.0,1.0,166.52653980941,169.15427605287,165.94703904089,167.95530894559,15886110.0
-2017-07-20,165.93,167.51,163.9121,167.48,17258237.0,0.0,1.0,165.78717675991,167.36581678451,163.77101365509,167.33584260682,17258237.0
-2017-07-19,166.33,167.4,164.61,165.1,17014089.0,0.0,1.0,166.18683246234,167.25591146634,164.4683129419,164.95789117737,17014089.0
-2017-07-18,161.78,166.55,161.3,165.96,19123179.0,0.0,1.0,161.64074884722,166.40664309868,161.1611620043,165.8171509376,19123179.0
-2017-07-17,166.33,167.5,161.75,164.25,22936328.0,0.0,1.0,166.18683246234,167.35582539195,161.61077466954,164.10862280971,22936328.0
-2017-07-14,161.29,165.01,161.01,164.95,23349534.0,0.0,1.0,161.15117061174,164.86796864433,160.87141162004,164.80802028896,23349534.0
-2017-07-13,163.0,166.3,158.75,160.63,34123997.0,0.0,1.0,162.85969873962,166.15685828466,158.61335690132,160.49173870274,34123997.0
-2017-07-12,158.3,163.0,156.56,162.51,28283476.0,0.0,1.0,158.16374423609,162.85969873962,156.42524193053,162.37012050415,28283476.0
-2017-07-11,153.85,156.19,152.15,155.88,18744156.0,0.0,1.0,153.71757454657,156.05556040578,152.01903781125,155.7458272364,18744156.0
-2017-07-10,149.74,154.0,148.6842,153.7,23720137.0,0.0,1.0,149.61111220412,153.86744543498,148.55622097756,153.56770365816,23720137.0
-2017-07-07,145.78,147.5,144.85,146.76,16258515.0,0.0,1.0,145.65452075008,147.37304027052,144.72532124193,146.63367722103,16258515.0
-2017-07-06,141.87,145.3799,139.76,143.48,18383056.0,0.0,1.0,141.74788625884,145.25476513372,139.63970242853,143.35650046111,18383056.0
-2017-07-05,141.9,144.22,141.13,143.05,20226442.0,0.0,1.0,141.77786043652,144.09586351061,141.00852320935,142.926870581,20226442.0
-2017-07-03,145.05,145.6537,138.58,139.33,17722284.0,0.0,1.0,144.92514909314,145.52832946204,138.46071810636,139.21007254842,17722284.0
-2017-06-30,147.38,147.93,143.5,144.56,17992137.0,0.0,1.0,147.25314355979,147.80267015063,143.37648324623,144.43557085767,17992137.0
-2017-06-29,150.6,150.72,144.08,146.68,26334702.0,0.0,1.0,150.47037196434,150.59026867507,143.95598401476,146.55374608054,26334702.0
-2017-06-28,149.32,151.94,145.75,151.75,24660291.0,0.0,1.0,149.19147371657,151.80921856748,145.62454657239,151.61938210882,24660291.0
-2017-06-27,151.44,151.79,146.35,146.58,24850612.0,0.0,1.0,151.30964893944,151.65934767907,146.22403012604,146.45383215493,24850612.0
-2017-06-26,155.16,156.6,148.33,152.15,26418557.0,0.0,1.0,155.02644697203,156.46520750077,148.20232585306,152.01903781125,26418557.0
-2017-06-23,158.68,159.32,153.22,154.11,24565502.0,0.0,1.0,158.5434171534,159.18286627728,153.08811681525,153.97735075315,24565502.0
-2017-06-22,159.8,160.34,157.4,158.37,11596308.0,0.0,1.0,159.6624531202,160.20198831848,157.26451890563,158.23368398401,11596308.0
-2017-06-21,158.21,159.62,155.7,159.47,16945632.0,0.0,1.0,158.07382170304,159.4826080541,155.5659821703,159.33273716569,16945632.0
-2017-06-20,159.03,161.74,156.92,157.09,27169647.0,0.0,1.0,158.89311589302,161.60078327698,156.78493206271,156.95478573624,27169647.0
-2017-06-19,153.41,157.53,153.26,157.32,19260255.0,0.0,1.0,153.2779532739,157.39440700891,153.12808238549,157.18458776514,19260255.0
-2017-06-16,152.76,154.7,150.24,151.62,22554327.0,0.0,1.0,152.62851275745,154.56684291423,150.11068183215,151.48949400553,22554327.0
-2017-06-15,146.96,153.6,146.5,152.37,23883179.0,0.0,1.0,146.83350507224,153.46778973255,146.37390101445,152.23884844759,23883179.0
-2017-06-14,151.52,154.06,148.5,151.72,29431459.0,0.0,1.0,151.38958007993,153.92739379035,148.37217952659,151.58940793114,29431459.0
-2017-06-13,154.4,154.77,145.65,151.4,41488612.0,0.0,1.0,154.26710113741,154.63678266216,145.52463264679,151.2696833692,41488612.0
-2017-06-12,145.88,151.7,142.11,149.97,41793262.0,0.0,1.0,145.75443467568,151.56942514602,141.9876796803,149.84091423302,41793262.0
-2017-06-09,164.74,168.5,142.75,149.6,91979374.0,0.0,1.0,164.59820104519,168.35496464802,142.62712880418,149.47123270827,91979374.0
-2017-06-08,153.46,160.0,151.79,159.952,28475455.0,0.0,1.0,153.3279102367,159.86228097141,151.65934767907,159.81432228712,28475455.0
-2017-06-07,148.33,149.88,147.7,149.12,15057318.0,0.0,1.0,148.20232585306,149.75099169997,147.57286812173,148.99164586536,15057318.0
-2017-06-06,147.82,149.69,146.8,147.34,18743334.0,0.0,1.0,147.69276483246,149.56115524132,146.67364279127,147.21317798955,18743334.0
-2017-06-05,142.98,148.53,142.51,148.01,20311623.0,0.0,1.0,142.85693083308,148.40215370427,142.38733538272,147.88260129112,20311623.0
-2017-06-02,144.24,145.3,143.4,143.64,12140804.0,0.0,1.0,144.11584629573,145.17493390716,143.27656932063,143.51636274208,12140804.0
-2017-06-01,144.99,145.03,142.52,144.2499,12462061.0,0.0,1.0,144.86520073778,144.90516630802,142.39732677528,144.12573777436,12462061.0
diff --git a/examples/quick/demos/stocqt/content/data/PYPL.csv b/examples/quick/demos/stocqt/content/data/PYPL.csv
deleted file mode 100644
index 53034c65d2..0000000000
--- a/examples/quick/demos/stocqt/content/data/PYPL.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,73.92,74.53,73.58,73.62,4396182.0,0.0,1.0,73.92,74.53,73.58,73.62,4396182.0
-2017-12-28,74.96,75.0,73.86,74.17,3363964.0,0.0,1.0,74.96,75.0,73.86,74.17,3363964.0
-2017-12-27,74.25,74.93,74.0,74.59,4226467.0,0.0,1.0,74.25,74.93,74.0,74.59,4226467.0
-2017-12-26,73.29,74.34,72.63,74.27,4683371.0,0.0,1.0,73.29,74.34,72.63,74.27,4683371.0
-2017-12-22,73.8,74.04,72.9,73.89,3570969.0,0.0,1.0,73.8,74.04,72.9,73.89,3570969.0
-2017-12-21,74.19,74.47,73.8,74.02,4556474.0,0.0,1.0,74.19,74.47,73.8,74.02,4556474.0
-2017-12-20,74.64,74.9,73.76,74.0,5964055.0,0.0,1.0,74.64,74.9,73.76,74.0,5964055.0
-2017-12-19,75.39,75.39,73.91,74.5,7430435.0,0.0,1.0,75.39,75.39,73.91,74.5,7430435.0
-2017-12-18,76.3,76.35,75.2,75.32,8034166.0,0.0,1.0,76.3,76.35,75.2,75.32,8034166.0
-2017-12-15,74.82,75.87,73.51,75.65,10935788.0,0.0,1.0,74.82,75.87,73.51,75.65,10935788.0
-2017-12-14,74.5,75.53,74.2,74.26,7453419.0,0.0,1.0,74.5,75.53,74.2,74.26,7453419.0
-2017-12-13,74.08,75.42,73.77,74.09,7037486.0,0.0,1.0,74.08,75.42,73.77,74.09,7037486.0
-2017-12-12,73.45,74.31,73.0,73.62,5947690.0,0.0,1.0,73.45,74.31,73.0,73.62,5947690.0
-2017-12-11,72.96,73.68,72.56,73.29,5786918.0,0.0,1.0,72.96,73.68,72.56,73.29,5786918.0
-2017-12-08,74.71,74.71,72.6,72.91,8130594.0,0.0,1.0,74.71,74.71,72.6,72.91,8130594.0
-2017-12-07,73.25,74.069,73.25,73.69,7547591.0,0.0,1.0,73.25,74.069,73.25,73.69,7547591.0
-2017-12-06,70.89,73.2,70.83,73.14,9188317.0,0.0,1.0,70.89,73.2,70.83,73.14,9188317.0
-2017-12-05,69.81,72.75,69.61,71.2,15818651.0,0.0,1.0,69.81,72.75,69.61,71.2,15818651.0
-2017-12-04,75.59,75.7439,68.61,70.97,26157704.0,0.0,1.0,75.59,75.7439,68.61,70.97,26157704.0
-2017-12-01,75.22,76.44,74.26,75.2999,13310272.0,0.0,1.0,75.22,76.44,74.26,75.2999,13310272.0
-2017-11-30,73.77,75.87,73.54,75.73,15737916.0,0.0,1.0,73.77,75.87,73.54,75.73,15737916.0
-2017-11-29,77.95,77.98,71.67,73.25,24981118.0,0.0,1.0,77.95,77.98,71.67,73.25,24981118.0
-2017-11-28,77.95,78.23,77.2435,77.79,8570920.0,0.0,1.0,77.95,78.23,77.2435,77.79,8570920.0
-2017-11-27,78.63,79.385,77.71,77.84,6745449.0,0.0,1.0,78.63,79.385,77.71,77.84,6745449.0
-2017-11-24,77.81,78.9,77.7,78.57,4305618.0,0.0,1.0,77.81,78.9,77.7,78.57,4305618.0
-2017-11-22,77.9,77.99,76.62,77.57,7975445.0,0.0,1.0,77.9,77.99,76.62,77.57,7975445.0
-2017-11-21,77.09,78.43,76.85,77.77,10283504.0,0.0,1.0,77.09,78.43,76.85,77.77,10283504.0
-2017-11-20,76.6,77.32,75.88,76.01,6799610.0,0.0,1.0,76.6,77.32,75.88,76.01,6799610.0
-2017-11-17,78.01,78.01,75.8,76.38,11771514.0,0.0,1.0,78.01,78.01,75.8,76.38,11771514.0
-2017-11-16,75.5,77.94,75.28,77.7,12154083.0,0.0,1.0,75.5,77.94,75.28,77.7,12154083.0
-2017-11-15,74.3,74.4,73.1853,73.43,5780290.0,0.0,1.0,74.3,74.4,73.1853,73.43,5780290.0
-2017-11-14,74.1,74.82,73.62,74.49,5426087.0,0.0,1.0,74.1,74.82,73.62,74.49,5426087.0
-2017-11-13,73.61,74.29,73.34,74.03,5821794.0,0.0,1.0,73.61,74.29,73.34,74.03,5821794.0
-2017-11-10,73.77,74.14,73.56,73.99,5703206.0,0.0,1.0,73.77,74.14,73.56,73.99,5703206.0
-2017-11-09,74.02,74.2,72.41,74.1,8526645.0,0.0,1.0,74.02,74.2,72.41,74.1,8526645.0
-2017-11-07,75.17,75.45,74.19,74.41,6855004.0,0.0,1.0,75.17,75.45,74.19,74.41,6855004.0
-2017-11-06,73.72,74.76,73.42,74.74,10052359.0,0.0,1.0,73.72,74.76,73.42,74.74,10052359.0
-2017-11-03,72.37,73.41,71.94,73.39,6714105.0,0.0,1.0,72.37,73.41,71.94,73.39,6714105.0
-2017-11-02,72.46,72.7755,72.01,72.25,4518557.0,0.0,1.0,72.46,72.7755,72.01,72.25,4518557.0
-2017-11-01,72.78,72.99,71.69,72.38,6576235.0,0.0,1.0,72.78,72.99,71.69,72.38,6576235.0
-2017-10-31,71.34,72.74,71.11,72.56,7478157.0,0.0,1.0,71.34,72.74,71.11,72.56,7478157.0
-2017-10-30,71.45,71.54,70.53,71.15,6911407.0,0.0,1.0,71.45,71.54,70.53,71.15,6911407.0
-2017-10-27,71.72,71.79,70.58,71.06,9192172.0,0.0,1.0,71.72,71.79,70.58,71.06,9192172.0
-2017-10-26,71.46,72.07,71.04,71.34,7967791.0,0.0,1.0,71.46,72.07,71.04,71.34,7967791.0
-2017-10-25,69.94,71.42,69.85,71.02,11908785.0,0.0,1.0,69.94,71.42,69.85,71.02,11908785.0
-2017-10-24,69.73,70.565,69.67,70.21,12057648.0,0.0,1.0,69.73,70.565,69.67,70.21,12057648.0
-2017-10-23,71.02,71.33,69.55,69.8,12004583.0,0.0,1.0,71.02,71.33,69.55,69.8,12004583.0
-2017-10-20,71.33,71.73,69.69,70.97,33976887.0,0.0,1.0,71.33,71.73,69.69,70.97,33976887.0
-2017-10-19,67.3,67.45,66.16,67.25,11645310.0,0.0,1.0,67.3,67.45,66.16,67.25,11645310.0
-2017-10-18,67.4,67.5,67.0,67.26,7866118.0,0.0,1.0,67.4,67.5,67.0,67.26,7866118.0
-2017-10-17,67.65,67.67,66.35,66.67,10630805.0,0.0,1.0,67.65,67.67,66.35,66.67,10630805.0
-2017-10-16,69.04,69.2,67.28,67.31,9449837.0,0.0,1.0,69.04,69.2,67.28,67.31,9449837.0
-2017-10-13,69.49,69.61,68.0,68.66,8596855.0,0.0,1.0,69.49,69.61,68.0,68.66,8596855.0
-2017-10-12,68.02,68.98,67.8048,68.86,8607233.0,0.0,1.0,68.02,68.98,67.8048,68.86,8607233.0
-2017-10-11,67.25,68.42,66.98,67.78,11918941.0,0.0,1.0,67.25,68.42,66.98,67.78,11918941.0
-2017-10-10,66.6,66.67,65.79,66.04,5795772.0,0.0,1.0,66.6,66.67,65.79,66.04,5795772.0
-2017-10-09,66.2,66.55,65.9,66.23,5511409.0,0.0,1.0,66.2,66.55,65.9,66.23,5511409.0
-2017-10-06,66.0,66.41,65.79,66.05,6102894.0,0.0,1.0,66.0,66.41,65.79,66.05,6102894.0
-2017-10-05,64.38,66.0,64.22,65.82,6918222.0,0.0,1.0,64.38,66.0,64.22,65.82,6918222.0
-2017-10-04,64.3,64.3,63.69,64.01,4399565.0,0.0,1.0,64.3,64.3,63.69,64.01,4399565.0
-2017-10-03,64.51,64.51,63.7607,64.22,5614020.0,0.0,1.0,64.51,64.51,63.7607,64.22,5614020.0
-2017-10-02,64.5,65.12,64.1,64.18,5141673.0,0.0,1.0,64.5,65.12,64.1,64.18,5141673.0
-2017-09-29,63.86,64.17,63.5,64.03,6706995.0,0.0,1.0,63.86,64.17,63.5,64.03,6706995.0
-2017-09-28,63.62,64.055,63.11,63.93,3982117.0,0.0,1.0,63.62,64.055,63.11,63.93,3982117.0
-2017-09-27,63.41,63.75,63.1601,63.33,6807674.0,0.0,1.0,63.41,63.75,63.1601,63.33,6807674.0
-2017-09-26,63.71,63.7623,62.84,62.94,8084916.0,0.0,1.0,63.71,63.7623,62.84,62.94,8084916.0
-2017-09-25,65.0,65.0,62.365,63.5,13088161.0,0.0,1.0,65.0,65.0,62.365,63.5,13088161.0
-2017-09-22,64.33,65.24,64.11,65.08,6539011.0,0.0,1.0,64.33,65.24,64.11,65.08,6539011.0
-2017-09-21,64.67,64.95,63.905,64.63,6539750.0,0.0,1.0,64.67,64.95,63.905,64.63,6539750.0
-2017-09-20,63.99,64.87,63.83,64.74,11704012.0,0.0,1.0,63.99,64.87,63.83,64.74,11704012.0
-2017-09-19,63.01,63.925,62.96,63.83,7646245.0,0.0,1.0,63.01,63.925,62.96,63.83,7646245.0
-2017-09-18,62.62,63.5299,62.52,62.92,7561354.0,0.0,1.0,62.62,63.5299,62.52,62.92,7561354.0
-2017-09-15,62.27,62.8,61.96,62.5,9561717.0,0.0,1.0,62.27,62.8,61.96,62.5,9561717.0
-2017-09-14,62.04,62.37,61.71,62.24,5657030.0,0.0,1.0,62.04,62.37,61.71,62.24,5657030.0
-2017-09-13,62.47,62.75,61.58,62.04,6113877.0,0.0,1.0,62.47,62.75,61.58,62.04,6113877.0
-2017-09-12,62.95,63.12,62.15,62.56,6199885.0,0.0,1.0,62.95,63.12,62.15,62.56,6199885.0
-2017-09-11,61.73,63.26,61.62,62.64,8162604.0,0.0,1.0,61.73,63.26,61.62,62.64,8162604.0
-2017-09-08,61.94,62.0,61.1,61.13,4876488.0,0.0,1.0,61.94,62.0,61.1,61.13,4876488.0
-2017-09-07,61.33,62.13,61.28,62.0,4962951.0,0.0,1.0,61.33,62.13,61.28,62.0,4962951.0
-2017-09-06,61.74,61.99,60.9,61.24,5217668.0,0.0,1.0,61.74,61.99,60.9,61.24,5217668.0
-2017-09-05,61.26,61.75,60.58,61.27,5696603.0,0.0,1.0,61.26,61.75,60.58,61.27,5696603.0
-2017-09-01,61.98,62.23,61.3831,61.46,3389772.0,0.0,1.0,61.98,62.23,61.3831,61.46,3389772.0
-2017-08-31,62.0,62.029,61.17,61.68,6088973.0,0.0,1.0,62.0,62.029,61.17,61.68,6088973.0
-2017-08-30,61.05,61.86,60.89,61.77,5613393.0,0.0,1.0,61.05,61.86,60.89,61.77,5613393.0
-2017-08-29,59.82,61.16,59.63,61.01,4330268.0,0.0,1.0,59.82,61.16,59.63,61.01,4330268.0
-2017-08-28,60.31,60.53,59.81,60.53,4616049.0,0.0,1.0,60.31,60.53,59.81,60.53,4616049.0
-2017-08-25,60.33,60.58,59.61,59.97,4006421.0,0.0,1.0,60.33,60.58,59.61,59.97,4006421.0
-2017-08-24,60.22,60.43,59.11,60.0,3787878.0,0.0,1.0,60.22,60.43,59.11,60.0,3787878.0
-2017-08-23,60.3,60.51,59.82,60.04,4511679.0,0.0,1.0,60.3,60.51,59.82,60.04,4511679.0
-2017-08-22,59.72,61.0,59.44,60.84,5782471.0,0.0,1.0,59.72,61.0,59.44,60.84,5782471.0
-2017-08-21,59.33,59.65,58.755,59.4,4206531.0,0.0,1.0,59.33,59.65,58.755,59.4,4206531.0
-2017-08-18,59.36,59.82,58.94,59.44,4594653.0,0.0,1.0,59.36,59.82,58.94,59.44,4594653.0
-2017-08-17,60.15,60.28,59.29,59.29,6537123.0,0.0,1.0,60.15,60.28,59.29,59.29,6537123.0
-2017-08-16,59.95,60.7,59.6,60.29,5679048.0,0.0,1.0,59.95,60.7,59.6,60.29,5679048.0
-2017-08-15,59.3,59.98,59.23,59.69,6419599.0,0.0,1.0,59.3,59.98,59.23,59.69,6419599.0
-2017-08-14,58.61,59.2763,58.271,59.06,7127903.0,0.0,1.0,58.61,59.2763,58.271,59.06,7127903.0
-2017-08-11,57.85,58.25,57.58,58.04,6891359.0,0.0,1.0,57.85,58.25,57.58,58.04,6891359.0
-2017-08-10,59.24,59.37,57.81,58.02,9341375.0,0.0,1.0,59.24,59.37,57.81,58.02,9341375.0
-2017-08-09,58.97,59.73,58.59,59.67,5991127.0,0.0,1.0,58.97,59.73,58.59,59.67,5991127.0
-2017-08-08,59.61,59.88,59.25,59.48,5960460.0,0.0,1.0,59.61,59.88,59.25,59.48,5960460.0
-2017-08-07,59.18,59.64,58.84,59.62,5875028.0,0.0,1.0,59.18,59.64,58.84,59.62,5875028.0
-2017-08-04,58.62,58.93,58.32,58.86,6118655.0,0.0,1.0,58.62,58.93,58.32,58.86,6118655.0
-2017-08-03,59.16,59.28,58.36,58.42,6104372.0,0.0,1.0,59.16,59.28,58.36,58.42,6104372.0
-2017-08-02,59.67,59.71,58.44,59.12,6486312.0,0.0,1.0,59.67,59.71,58.44,59.12,6486312.0
-2017-08-01,59.0,59.39,58.79,59.34,8950112.0,0.0,1.0,59.0,59.39,58.79,59.34,8950112.0
-2017-07-31,59.37,59.64,58.52,58.55,7307044.0,0.0,1.0,59.37,59.64,58.52,58.55,7307044.0
-2017-07-28,59.8,60.71,59.04,59.2,10684806.0,0.0,1.0,59.8,60.71,59.04,59.2,10684806.0
-2017-07-27,61.0,61.3,57.6921,60.15,22678000.0,0.0,1.0,61.0,61.3,57.6921,60.15,22678000.0
-2017-07-26,58.48,58.94,57.9,58.79,12794748.0,0.0,1.0,58.48,58.94,57.9,58.79,12794748.0
-2017-07-25,58.73,58.83,58.19,58.26,7859354.0,0.0,1.0,58.73,58.83,58.19,58.26,7859354.0
-2017-07-24,58.9,59.07,58.34,58.58,6373567.0,0.0,1.0,58.9,59.07,58.34,58.58,6373567.0
-2017-07-21,59.0,59.33,58.59,58.67,7486133.0,0.0,1.0,59.0,59.33,58.59,58.67,7486133.0
-2017-07-20,58.75,59.38,58.43,59.09,7990391.0,0.0,1.0,58.75,59.38,58.43,59.09,7990391.0
-2017-07-19,58.31,58.62,57.55,58.35,9624663.0,0.0,1.0,58.31,58.62,57.55,58.35,9624663.0
-2017-07-18,57.5,58.96,57.31,58.96,9436755.0,0.0,1.0,57.5,58.96,57.31,58.96,9436755.0
-2017-07-17,57.53,57.6,57.02,57.58,5604480.0,0.0,1.0,57.53,57.6,57.02,57.58,5604480.0
-2017-07-14,58.14,58.63,56.915,57.16,11651935.0,0.0,1.0,58.14,58.63,56.915,57.16,11651935.0
-2017-07-13,57.3,57.91,56.8,57.9,14687917.0,0.0,1.0,57.3,57.91,56.8,57.9,14687917.0
-2017-07-12,56.6,57.445,55.55,56.55,17345098.0,0.0,1.0,56.6,57.445,55.55,56.55,17345098.0
-2017-07-11,54.92,55.2,54.33,54.76,8865099.0,0.0,1.0,54.92,55.2,54.33,54.76,8865099.0
-2017-07-10,54.91,55.42,54.7,54.96,9916785.0,0.0,1.0,54.91,55.42,54.7,54.96,9916785.0
-2017-07-07,53.7,54.48,53.52,53.97,4805962.0,0.0,1.0,53.7,54.48,53.52,53.97,4805962.0
-2017-07-06,54.22,54.3506,53.15,53.47,7289275.0,0.0,1.0,54.22,54.3506,53.15,53.47,7289275.0
-2017-07-05,53.0,54.75,52.94,54.61,9638570.0,0.0,1.0,53.0,54.75,52.94,54.61,9638570.0
-2017-07-03,54.14,54.33,52.83,52.87,4831590.0,0.0,1.0,54.14,54.33,52.83,52.87,4831590.0
-2017-06-30,53.6,54.25,53.29,53.67,7611077.0,0.0,1.0,53.6,54.25,53.29,53.67,7611077.0
-2017-06-29,53.81,54.1,52.52,53.42,11162726.0,0.0,1.0,53.81,54.1,52.52,53.42,11162726.0
-2017-06-28,52.75,54.44,52.65,54.39,7894816.0,0.0,1.0,52.75,54.44,52.65,54.39,7894816.0
-2017-06-27,53.6,53.79,52.64,52.73,7680978.0,0.0,1.0,53.6,53.79,52.64,52.73,7680978.0
-2017-06-26,54.44,55.1,53.65,53.74,4728731.0,0.0,1.0,54.44,55.1,53.65,53.74,4728731.0
-2017-06-23,53.82,54.53,53.69,54.34,5954697.0,0.0,1.0,53.82,54.53,53.69,54.34,5954697.0
-2017-06-22,53.71,53.951,52.86,53.87,9631525.0,0.0,1.0,53.71,53.951,52.86,53.87,9631525.0
-2017-06-21,52.99,53.58,52.61,53.54,7992648.0,0.0,1.0,52.99,53.58,52.61,53.54,7992648.0
-2017-06-20,52.84,53.23,52.43,52.52,4522851.0,0.0,1.0,52.84,53.23,52.43,52.52,4522851.0
-2017-06-19,52.28,53.0,52.1101,52.93,5276661.0,0.0,1.0,52.28,53.0,52.1101,52.93,5276661.0
-2017-06-16,52.04,52.16,51.58,51.84,10792581.0,0.0,1.0,52.04,52.16,51.58,51.84,10792581.0
-2017-06-15,51.44,52.38,50.83,52.29,9945649.0,0.0,1.0,51.44,52.38,50.83,52.29,9945649.0
-2017-06-14,52.0,52.505,51.535,51.9,7114891.0,0.0,1.0,52.0,52.505,51.535,51.9,7114891.0
-2017-06-13,52.29,52.485,51.7,52.04,10119801.0,0.0,1.0,52.29,52.485,51.7,52.04,10119801.0
-2017-06-12,52.81,52.9,51.43,52.16,15724406.0,0.0,1.0,52.81,52.9,51.43,52.16,15724406.0
-2017-06-09,54.65,55.14,52.85,53.4,10524856.0,0.0,1.0,54.65,55.14,52.85,53.4,10524856.0
-2017-06-08,54.03,54.43,53.45,54.39,6251592.0,0.0,1.0,54.03,54.43,53.45,54.39,6251592.0
-2017-06-07,53.3,53.94,53.26,53.85,6282623.0,0.0,1.0,53.3,53.94,53.26,53.85,6282623.0
-2017-06-06,53.75,53.8,53.16,53.4,6212080.0,0.0,1.0,53.75,53.8,53.16,53.4,6212080.0
-2017-06-05,53.77,54.07,53.59,53.8,9119908.0,0.0,1.0,53.77,54.07,53.59,53.8,9119908.0
-2017-06-02,53.44,53.64,53.08,53.52,9019731.0,0.0,1.0,53.44,53.64,53.08,53.52,9019731.0
-2017-06-01,52.48,53.39,52.475,53.16,13878328.0,0.0,1.0,52.48,53.39,52.475,53.16,13878328.0
diff --git a/examples/quick/demos/stocqt/content/data/QCOM.csv b/examples/quick/demos/stocqt/content/data/QCOM.csv
deleted file mode 100644
index 0067fe307b..0000000000
--- a/examples/quick/demos/stocqt/content/data/QCOM.csv
+++ /dev/null
@@ -1,147 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,64.36,64.65,64.0,64.02,4553732.0,0.0,1.0,64.36,64.65,64.0,64.02,4553732.0
-2017-12-28,64.69,64.73,64.35,64.38,2371094.0,0.0,1.0,64.69,64.73,64.35,64.38,2371094.0
-2017-12-27,64.32,64.64,64.18,64.54,4821727.0,0.0,1.0,64.32,64.64,64.18,64.54,4821727.0
-2017-12-26,64.49,64.94,64.2,64.3,4185772.0,0.0,1.0,64.49,64.94,64.2,64.3,4185772.0
-2017-12-22,64.31,64.98,64.3,64.73,4386678.0,0.0,1.0,64.31,64.98,64.3,64.73,4386678.0
-2017-12-21,64.75,64.9604,64.34,64.39,5349137.0,0.0,1.0,64.75,64.9604,64.34,64.39,5349137.0
-2017-12-20,64.56,65.17,64.33,64.6,6919901.0,0.0,1.0,64.56,65.17,64.33,64.6,6919901.0
-2017-12-19,65.11,65.48,64.43,64.5,6906151.0,0.0,1.0,65.11,65.48,64.43,64.5,6906151.0
-2017-12-18,64.93,65.46,64.8,65.38,7092422.0,0.0,1.0,64.93,65.46,64.8,65.38,7092422.0
-2017-12-15,65.33,65.42,64.5,64.76,14158271.0,0.0,1.0,65.33,65.42,64.5,64.76,14158271.0
-2017-12-14,64.86,65.17,64.545,64.7,7012732.0,0.0,1.0,64.86,65.17,64.545,64.7,7012732.0
-2017-12-13,64.98,65.425,64.83,64.9,6431073.0,0.0,1.0,64.98,65.425,64.83,64.9,6431073.0
-2017-12-12,64.88,65.11,64.55,64.86,5559918.0,0.0,1.0,64.88,65.11,64.55,64.86,5559918.0
-2017-12-11,64.06,65.2631,64.0,65.18,11846177.0,0.0,1.0,64.06,65.2631,64.0,65.18,11846177.0
-2017-12-08,65.6,65.6,63.88,64.24,9170240.0,0.0,1.0,65.6,65.6,63.88,64.24,9170240.0
-2017-12-07,65.21,65.55,64.77,65.23,6068240.0,0.0,1.0,65.21,65.55,64.77,65.23,6068240.0
-2017-12-06,64.64,65.68,64.36,64.98,6907606.0,0.0,1.0,64.64,65.68,64.36,64.98,6907606.0
-2017-12-05,64.85,65.03,64.4,64.69,9492637.0,0.0,1.0,64.85,65.03,64.4,64.69,9492637.0
-2017-12-04,65.6,65.7,63.8,64.56,17057274.0,0.0,1.0,65.6,65.7,63.8,64.56,17057274.0
-2017-12-01,65.2,66.12,64.6,65.49,15286995.0,0.0,1.0,65.2,66.12,64.6,65.49,15286995.0
-2017-11-30,66.51,67.1,65.72,66.34,14675004.0,0.0,1.0,66.51,67.1,65.72,66.34,14675004.0
-2017-11-29,68.1,68.2,66.03,66.52,16841361.0,0.0,1.0,68.1,68.2,66.03,66.52,16841361.0
-2017-11-28,67.59,68.41,67.22,68.38,12641308.0,0.57,1.0,67.59,68.41,67.22,68.38,12641308.0
-2017-11-27,68.6,68.92,68.04,68.14,20112979.0,0.0,1.0,68.032893401015,68.350248005801,67.47752284264,67.576696156635,20112979.0
-2017-11-24,68.51,69.28,68.45,68.91,9233010.0,0.0,1.0,67.943637418419,68.707271936186,67.884133430022,68.340330674402,9233010.0
-2017-11-22,66.37,68.26,66.24,68.13,15165652.0,0.0,1.0,65.821328498912,67.69570413343,65.692403190718,67.566778825236,15165652.0
-2017-11-21,65.35,66.93,65.27,66.67,11062010.0,0.0,1.0,64.809760696157,66.376699057288,64.73042204496,66.118848440899,11062010.0
-2017-11-20,66.18,66.85,65.95,66.47,9677801.0,0.0,1.0,65.632899202321,66.297360406091,65.404800580131,65.920501812908,9677801.0
-2017-11-17,66.37,66.95,66.0,66.72,12134512.0,0.0,1.0,65.821328498912,66.396533720087,65.454387237128,66.168435097897,12134512.0
-2017-11-16,65.77,66.54,65.43,66.11,12142331.0,0.0,1.0,65.226288614938,65.989923132705,64.889099347353,65.563477882524,12142331.0
-2017-11-15,65.55,66.4838,65.24,65.61,10531408.0,0.0,1.0,65.008107324148,65.934187730239,64.700670050761,65.067611312545,10531408.0
-2017-11-14,66.16,66.8,65.55,66.0,13970519.0,0.0,1.0,65.613064539521,66.247773749094,65.008107324148,65.454387237128,13970519.0
-2017-11-13,64.96,66.82,64.75,66.49,24327595.0,0.0,1.0,64.422984771574,66.267608411893,64.214720812183,65.940336475707,24327595.0
-2017-11-10,64.36,65.1,63.92,64.57,9597929.0,0.0,1.0,63.8279448876,64.561827411168,63.391582306019,64.036208846991,9597929.0
-2017-11-09,64.91,65.33,63.93,64.6,15600914.0,0.0,1.0,64.373398114576,64.789926033358,63.401499637418,64.065960841189,15600914.0
-2017-11-07,62.52,64.16,62.45,64.1,23249338.0,0.0,1.0,62.00315591008,63.629598259608,61.933734590283,63.570094271211,23249338.0
-2017-11-06,64.54,65.33,62.15,62.52,58620899.0,0.0,1.0,64.006456852792,64.789926033358,61.636214648296,62.00315591008,58620899.0
-2017-11-03,54.76,64.99,54.21,61.81,78515925.0,0.0,1.0,54.307306744017,64.452736765772,53.761853517041,61.299025380711,78515925.0
-2017-11-02,53.6,55.68,53.6,54.84,17115009.0,0.0,1.0,53.156896301668,55.219701232777,53.156896301668,54.386645395214,17115009.0
-2017-11-01,51.47,53.49,50.51,53.46,14923803.0,0.0,1.0,51.044504713561,53.047805656273,50.092440899202,53.018053662074,14923803.0
-2017-10-31,52.26,52.49,50.02,51.01,28432806.0,0.0,1.0,51.827973894126,52.056072516316,49.606491660624,50.588307469181,28432806.0
-2017-10-30,54.16,54.77,54.08,54.66,6986348.0,0.0,1.0,53.712266860044,54.317224075417,53.632928208847,54.208133430022,6986348.0
-2017-10-27,53.7,54.7,53.36,54.57,8637328.0,0.0,1.0,53.256069615664,54.24780275562,52.918880348078,54.118877447426,8637328.0
-2017-10-26,54.1,54.39,53.665,53.8,5227877.0,0.0,1.0,53.652762871646,53.940365482234,53.221358955765,53.355242929659,5227877.0
-2017-10-25,53.98,54.43,53.475,53.84,7352176.0,0.0,1.0,53.533754894851,53.980034807832,53.032929659173,53.394912255257,7352176.0
-2017-10-24,53.44,54.44,53.4,54.25,10450810.0,0.0,1.0,52.998218999275,53.989952139231,52.958549673677,53.80152284264,10450810.0
-2017-10-23,52.3,53.78,52.13,53.39,9698032.0,0.0,1.0,51.867643219724,53.33540826686,51.699048585932,52.948632342277,9698032.0
-2017-10-20,52.51,52.59,51.94,52.02,8405771.0,0.0,1.0,52.075907179115,52.155245830312,51.51061928934,51.589957940537,8405771.0
-2017-10-19,52.03,52.4,52.01,52.29,6657536.0,0.0,1.0,51.599875271936,51.96681653372,51.580040609137,51.857725888325,6657536.0
-2017-10-18,52.54,52.67,52.02,52.21,5928735.0,0.0,1.0,52.105659173314,52.234584481508,51.589957940537,51.778387237128,5928735.0
-2017-10-17,52.32,52.44,51.8501,52.41,7456659.0,0.0,1.0,51.887477882524,52.006485859318,51.421462480058,51.97673386512,7456659.0
-2017-10-16,52.98,53.0,52.3101,52.38,5749880.0,0.0,1.0,52.542021754895,52.561856417694,51.877659724438,51.946981870921,5749880.0
-2017-10-13,53.38,53.38,52.74,52.82,6293816.0,0.0,1.0,52.938715010877,52.938715010877,52.304005801305,52.383344452502,6293816.0
-2017-10-12,53.88,54.175,52.96,53.0,7000530.0,0.0,1.0,53.434581580856,53.727142857143,52.522187092096,52.561856417694,7000530.0
-2017-10-11,53.79,54.38,53.66,54.12,8679167.0,0.0,1.0,53.34532559826,53.930448150834,53.216400290065,53.672597534445,8679167.0
-2017-10-10,52.95,53.9,52.9,53.87,8701455.0,0.0,1.0,52.512269760696,53.454416243655,52.462683103698,53.424664249456,8701455.0
-2017-10-09,52.68,52.9799,52.38,52.88,5803730.0,0.0,1.0,52.244501812908,52.541922581581,51.946981870921,52.442848440899,5803730.0
-2017-10-06,52.16,52.63,52.16,52.49,4780961.0,0.0,1.0,51.728800580131,52.19491515591,51.728800580131,52.056072516316,4780961.0
-2017-10-05,52.17,52.43,51.96,52.35,5144244.0,0.0,1.0,51.73871791153,51.996568527919,51.530453952139,51.917229876722,5144244.0
-2017-10-04,51.93,52.12,51.67,51.96,4521452.0,0.0,1.0,51.500701957941,51.689131254532,51.242851341552,51.530453952139,4521452.0
-2017-10-03,51.99,52.22,51.65,52.02,4176210.0,0.0,1.0,51.560205946338,51.788304568528,51.223016678753,51.589957940537,4176210.0
-2017-10-02,52.09,52.16,51.7,51.88,4363679.0,0.0,1.0,51.659379260334,51.728800580131,51.272603335751,51.451115300943,4363679.0
-2017-09-29,51.91,52.0447,51.62,51.84,5159612.0,0.0,1.0,51.480867295141,51.614453749094,51.193264684554,51.411445975344,5159612.0
-2017-09-28,51.38,52.04,51.31,51.75,5671994.0,0.0,1.0,50.955248730964,51.609792603336,50.885827411168,51.322189992748,5671994.0
-2017-09-27,51.43,51.61,51.1526,51.55,8122353.0,0.0,1.0,51.004835387962,51.183347353154,50.729728614938,51.123843364757,8122353.0
-2017-09-26,51.75,51.87,50.85,51.13,9148913.0,0.0,1.0,51.322189992748,51.441197969543,50.429630166788,50.707315445975,9148913.0
-2017-09-25,51.9,52.285,51.61,51.63,7931316.0,0.0,1.0,51.470949963742,51.852767222625,51.183347353154,51.203182015954,7931316.0
-2017-09-22,51.82,52.23,51.78,52.09,4077699.0,0.0,1.0,51.391611312545,51.798221899927,51.351941986947,51.659379260334,4077699.0
-2017-09-21,51.86,52.2,51.71,52.03,5192113.0,0.0,1.0,51.431280638144,51.768469905729,51.28252066715,51.599875271936,5192113.0
-2017-09-20,52.43,52.52,51.48,51.98,8273935.0,0.0,1.0,51.996568527919,52.085824510515,51.05442204496,51.550288614938,8273935.0
-2017-09-19,52.4,52.5,52.06,52.3,4897549.0,0.0,1.0,51.96681653372,52.065989847716,51.629627266135,51.867643219724,4897549.0
-2017-09-18,52.24,52.37,51.955,52.25,5951635.0,0.0,1.0,51.808139231327,51.937064539521,51.525495286439,51.818056562727,5951635.0
-2017-09-15,51.95,52.29,51.44,52.19,12717688.0,0.0,1.0,51.52053662074,51.857725888325,51.014752719362,51.758552574329,12717688.0
-2017-09-14,50.97,51.59,50.67,51.48,7677860.0,0.0,1.0,50.548638143582,51.163512690355,50.251118201595,51.05442204496,7677860.0
-2017-09-13,50.8,51.1054,50.72,51.01,6147412.0,0.0,1.0,50.38004350979,50.682918810732,50.300704858593,50.588307469181,6147412.0
-2017-09-12,50.6,51.07,50.52,50.9,4444021.0,0.0,1.0,50.181696881798,50.647811457578,50.102358230602,50.479216823785,4444021.0
-2017-09-11,49.94,50.67,49.91,50.57,7137370.0,0.0,1.0,49.527153009427,50.251118201595,49.497401015228,50.1519448876,7137370.0
-2017-09-08,50.35,50.45,48.92,49.64,12445202.0,0.0,1.0,49.933763596809,50.032936910805,48.515585206672,49.22963306744,12445202.0
-2017-09-07,50.56,50.69,50.25,50.38,8214389.0,0.0,1.0,50.1420275562,50.270952864394,49.834590282814,49.963515591008,8214389.0
-2017-09-06,50.19,50.77,49.83,50.45,16009190.0,0.0,1.0,49.775086294416,50.350291515591,49.418062364032,50.032936910805,16009190.0
-2017-09-05,51.86,51.9,49.83,50.03,17850640.0,0.0,1.0,51.431280638144,51.470949963742,49.418062364032,49.616408992023,17850640.0
-2017-09-01,52.53,52.77,51.925,52.05,5250026.0,0.0,1.0,52.095741841914,52.333757795504,51.495743292241,51.619709934735,5250026.0
-2017-08-31,52.26,52.59,52.12,52.27,7907278.0,0.0,1.0,51.827973894126,52.155245830312,51.689131254532,51.837891225526,7907278.0
-2017-08-30,51.75,52.286,51.56,52.12,4806103.0,0.0,1.0,51.322189992748,51.853758955765,51.133760696157,51.689131254532,4806103.0
-2017-08-29,51.31,51.86,51.28,51.81,4896218.0,0.0,1.0,50.885827411168,51.431280638144,50.856075416969,51.381693981146,4896218.0
-2017-08-28,51.77,51.81,51.46,51.81,4441742.0,0.57,1.0,51.342024655548,51.381693981146,51.034587382161,51.381693981146,4441742.0
-2017-08-25,52.78,52.8545,52.02,52.03,8502179.0,0.0,1.0,51.774070414755,51.847150525515,51.028555190897,51.038364601738,8502179.0
-2017-08-24,52.37,52.71,52.26,52.49,5972821.0,0.0,1.0,51.371884570306,51.705404538873,51.263981051063,51.489597500388,5972821.0
-2017-08-23,52.3,52.405,51.78,52.23,5046782.0,0.0,1.0,51.303218694424,51.406217508246,50.793129330732,51.234552818542,5046782.0
-2017-08-22,52.21,52.62,52.21,52.35,4350136.0,0.0,1.0,51.214933996862,51.617119841311,51.214933996862,51.352265748625,4350136.0
-2017-08-21,52.0,52.08,51.5,51.98,5185851.0,0.0,1.0,51.008936369217,51.087411655939,50.518465827205,50.989317547536,5185851.0
-2017-08-18,52.26,52.415,51.9,51.92,6642109.0,0.0,1.0,51.263981051063,51.416026919087,50.910842260815,50.930461082495,6642109.0
-2017-08-17,53.19,53.41,52.27,52.27,6087867.0,0.0,1.0,52.176256259205,52.39206329769,51.273790461903,51.273790461903,6087867.0
-2017-08-16,54.06,54.1,53.255,53.31,7034292.0,0.0,1.0,53.029675002305,53.068912645666,52.240017429666,52.293969189288,7034292.0
-2017-08-15,53.66,54.08,53.35,53.87,7562385.0,0.0,1.0,52.637298568696,53.049293823986,52.333206832648,52.843296196341,7562385.0
-2017-08-14,53.04,53.64,52.91,53.55,7558235.0,0.0,1.0,52.029115096601,52.617679747015,51.901592755678,52.529395049453,7558235.0
-2017-08-11,52.39,53.13,52.29,52.72,5835863.0,0.0,1.0,51.391503391986,52.117399794163,51.293409283584,51.715213949714,5835863.0
-2017-08-10,52.54,52.75,52.11,52.34,9578948.0,0.0,1.0,51.53864455459,51.744642182234,51.116839888459,51.342456337785,9578948.0
-2017-08-09,52.05,52.8,52.0,52.77,7039352.0,0.0,1.0,51.057983423418,51.793689236436,51.008936369217,51.764261003915,7039352.0
-2017-08-08,52.55,53.33,52.21,52.29,8779415.0,0.0,1.0,51.54845396543,52.313588010968,51.214933996862,51.293409283584,8779415.0
-2017-08-04,53.0,53.0,52.51,52.62,8645879.0,0.0,1.0,51.98987745324,51.98987745324,51.509216322069,51.617119841311,8645879.0
-2017-08-03,53.16,53.3399,52.75,52.95,8481098.0,0.0,1.0,52.146828026684,52.3232993277,51.744642182234,51.940830399039,8481098.0
-2017-08-02,53.295,53.3885,52.78,53.17,19324507.0,0.0,1.0,52.279255073027,52.370973064383,51.774070414755,52.156637437524,19324507.0
-2017-08-01,53.3,53.43,52.91,53.41,7480549.0,0.0,1.0,52.284159778447,52.41168211937,51.901592755678,52.39206329769,7480549.0
-2017-07-31,53.1,53.295,52.75,53.19,10641489.0,0.0,1.0,52.087971561643,52.279255073027,51.744642182234,52.176256259205,10641489.0
-2017-07-28,52.27,52.9865,52.27,52.88,6534345.0,0.0,1.0,51.273790461903,51.976634748606,51.273790461903,51.872164523157,6534345.0
-2017-07-27,53.08,53.37,52.23,52.49,13964311.0,0.0,1.0,52.068352739962,52.352825654329,51.234552818542,51.489597500388,13964311.0
-2017-07-26,53.29,53.35,52.74,53.14,7492633.0,0.0,1.0,52.274350367607,52.333206832648,51.734832771394,52.127209205004,7492633.0
-2017-07-25,53.2,53.65,53.07,53.27,7060158.0,0.0,1.0,52.186065670045,52.627489157855,52.058543329122,52.254731545927,7060158.0
-2017-07-24,53.75,53.88,53.09,53.22,8739769.0,0.0,1.0,52.725583266258,52.853105607181,52.078162150802,52.205684491725,8739769.0
-2017-07-21,53.66,54.0,53.37,53.84,11963407.0,0.0,1.0,52.637298568696,52.970818537264,52.352825654329,52.81386796382,11963407.0
-2017-07-20,55.11,55.43,53.46,53.97,35647961.0,0.0,1.0,54.05966314053,54.373564287417,52.441110351891,52.941390304743,35647961.0
-2017-07-19,56.46,56.9399,56.01,56.78,7437353.0,0.0,1.0,55.383933603961,55.854687230184,54.942510116151,55.697834750849,7437353.0
-2017-07-18,56.34,56.38,56.0,56.29,7329551.0,0.0,1.0,55.266220673878,55.305458317239,54.93270070531,55.217173619677,7329551.0
-2017-07-17,56.73,56.92,56.39,56.45,5067322.0,0.0,1.0,55.648787696648,55.835166502612,55.31526772808,55.374124193121,5067322.0
-2017-07-14,56.5,56.93,56.15,56.81,4365609.0,0.0,1.0,55.423171247322,55.844975913452,55.079841867914,55.727262983369,4365609.0
-2017-07-13,56.38,56.52,56.17,56.23,5884064.0,0.0,1.0,55.305458317239,55.442790069003,55.099460689594,55.158317154636,5884064.0
-2017-07-12,55.79,56.31,55.72,56.2,6082481.0,0.0,1.0,54.726703077666,55.236792441358,54.658037201784,55.128888922115,6082481.0
-2017-07-11,55.63,55.63,55.02,55.33,6009448.0,0.0,1.0,54.569752504222,54.569752504222,53.971378442968,54.275470179015,6009448.0
-2017-07-10,55.37,55.885,55.19,55.64,4973557.0,0.0,1.0,54.314707822376,54.819892480648,54.138138427252,54.579561915062,4973557.0
-2017-07-07,55.04,55.73,54.87,55.35,5156330.0,0.0,1.0,53.990997264648,54.667846612624,53.824237280364,54.295089000695,5156330.0
-2017-07-06,55.02,55.23,54.735,54.79,5557013.0,0.0,1.0,53.971378442968,54.177376070612,53.691810234021,53.745761993642,5557013.0
-2017-07-05,55.01,55.56,54.78,55.45,6624023.0,0.0,1.0,53.961569032127,54.50108662834,53.735952582802,54.393183109098,6624023.0
-2017-07-03,55.53,56.02,54.92,54.95,4379566.0,0.0,1.0,54.471658395819,54.952319526991,53.873284334565,53.902712567086,4379566.0
-2017-06-30,55.6,55.63,55.03,55.22,8596198.0,0.0,1.0,54.540324271701,54.569752504222,53.981187853808,54.167566659772,8596198.0
-2017-06-29,55.93,55.93,54.55,55.08,8333137.0,0.0,1.0,54.864034829429,54.864034829429,53.510336133477,54.030234908009,8333137.0
-2017-06-28,55.4,56.32,55.18,56.16,7231216.0,0.0,1.0,54.344136054896,55.246601852198,54.128329016411,55.089651278754,7231216.0
-2017-06-27,56.29,56.33,55.41,55.43,6734074.0,0.0,1.0,55.217173619677,55.256411263038,54.353945465737,54.373564287417,6734074.0
-2017-06-26,57.09,57.6892,56.21,56.56,7255489.0,0.0,1.0,56.001926486896,56.589706384443,55.138698332955,55.482027712364,7255489.0
-2017-06-23,56.64,57.4365,56.57,56.91,8660612.0,0.0,1.0,55.560502999085,56.34182257251,55.491837123204,55.825357091772,8660612.0
-2017-06-22,56.24,56.745,56.06,56.47,5512097.0,0.0,1.0,55.168126565476,55.663501812908,54.991557170352,55.393743014801,5512097.0
-2017-06-21,56.79,56.84,56.12,56.33,8189893.0,0.0,1.0,55.707644161689,55.75669121589,55.050413635393,55.256411263038,8189893.0
-2017-06-20,57.46,57.61,56.51,56.79,8087133.0,0.0,1.0,56.364874687985,56.512015850588,55.432980658162,55.707644161689,8087133.0
-2017-06-19,56.96,57.66,56.91,57.61,6909034.0,0.0,1.0,55.874404145973,56.561062904789,55.825357091772,56.512015850588,6909034.0
-2017-06-16,56.98,57.01,56.35,56.82,13536039.0,0.0,1.0,55.894022967653,55.923451200174,55.276030084719,55.73707239421,13536039.0
-2017-06-15,56.42,57.17,56.4,56.93,5371464.0,0.0,1.0,55.3446959606,56.080401773618,55.32507713892,55.844975913452,5371464.0
-2017-06-14,57.7,57.97,56.67,57.01,6702810.0,0.0,1.0,56.60030054815,56.865154640837,55.589931231606,55.923451200174,6702810.0
-2017-06-13,57.95,58.065,57.5,57.54,6971106.0,0.0,1.0,56.845535819156,56.958344043819,56.404112331346,56.443349974707,6971106.0
-2017-06-12,56.52,57.675,56.48,57.49,9871291.0,0.0,1.0,55.442790069003,56.57577702105,55.403552425642,56.394302920505,9871291.0
-2017-06-09,58.37,58.49,56.74,57.05,13572264.0,0.0,1.0,57.257531074446,57.375244004529,55.658597107488,55.962688843535,13572264.0
-2017-06-08,57.77,58.15,57.61,58.12,10134415.0,0.0,1.0,56.668966424032,57.041724035961,56.512015850588,57.01229580344,10134415.0
-2017-06-07,58.3,58.49,57.13,57.53,9967746.0,0.0,1.0,57.188865198564,57.375244004529,56.041164130257,56.433540563866,9967746.0
-2017-06-06,58.6,58.91,58.18,58.2,7808482.0,0.0,1.0,57.483147523771,57.787239259819,57.071152268481,57.090771090162,7808482.0
-2017-06-05,58.5,59.05,58.48,58.85,7655063.0,0.0,1.0,57.385053415369,57.924571011582,57.365434593689,57.728382794777,7655063.0
-2017-06-02,58.89,58.96,58.35,58.58,9461824.0,0.0,1.0,57.767620438138,57.83628631402,57.237912252765,57.463528702091,9461824.0
-2017-06-01,57.45,58.65,57.35,58.62,11116224.0,0.0,1.0,56.355065277144,57.532194577972,56.256971168742,57.502766345452,11116224.0
diff --git a/examples/quick/demos/stocqt/content/data/TSLA.csv b/examples/quick/demos/stocqt/content/data/TSLA.csv
deleted file mode 100644
index c1343441d8..0000000000
--- a/examples/quick/demos/stocqt/content/data/TSLA.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,316.18,316.41,310.0,311.35,3727621.0,0.0,1.0,316.18,316.41,310.0,311.35,3727621.0
-2017-12-28,311.75,315.82,309.54,315.36,4294689.0,0.0,1.0,311.75,315.82,309.54,315.36,4294689.0
-2017-12-27,316.0,317.68,310.75,311.64,4645441.0,0.0,1.0,316.0,317.68,310.75,311.64,4645441.0
-2017-12-26,323.83,323.94,316.58,317.29,4321909.0,0.0,1.0,323.83,323.94,316.58,317.29,4321909.0
-2017-12-22,329.51,330.9214,324.82,325.2,4186131.0,0.0,1.0,329.51,330.9214,324.82,325.2,4186131.0
-2017-12-21,329.59,333.74,327.21,331.66,4344701.0,0.0,1.0,329.59,333.74,327.21,331.66,4344701.0
-2017-12-20,332.69,333.1,325.04,328.98,5937684.0,0.0,1.0,332.69,333.1,325.04,328.98,5937684.0
-2017-12-19,340.26,341.4925,330.3,331.1,6792009.0,0.0,1.0,340.26,341.4925,330.3,331.1,6792009.0
-2017-12-18,344.9,346.73,337.58,338.87,5441450.0,0.0,1.0,344.9,346.73,337.58,338.87,5441450.0
-2017-12-15,342.04,343.9,335.76,343.45,6832071.0,0.0,1.0,342.04,343.9,335.76,343.45,6832071.0
-2017-12-14,341.01,347.44,336.9,337.89,5744750.0,0.0,1.0,341.01,347.44,336.9,337.89,5744750.0
-2017-12-13,340.93,344.22,336.5,339.03,6189204.0,0.0,1.0,340.93,344.22,336.5,339.03,6189204.0
-2017-12-12,330.45,341.44,330.03,341.03,8648534.0,0.0,1.0,330.45,341.44,330.03,341.03,8648534.0
-2017-12-11,314.63,329.01,313.75,328.91,7867288.0,0.0,1.0,314.63,329.01,313.75,328.91,7867288.0
-2017-12-08,314.6,316.98,311.26,315.13,3442898.0,0.0,1.0,314.6,316.98,311.26,315.13,3442898.0
-2017-12-07,312.0,318.6341,311.05,311.24,4705140.0,0.0,1.0,312.0,318.6341,311.05,311.24,4705140.0
-2017-12-06,300.1,313.39,300.0,313.26,7160938.0,0.0,1.0,300.1,313.39,300.0,313.26,7160938.0
-2017-12-05,302.0,308.0,301.0,303.7,4628462.0,0.0,1.0,302.0,308.0,301.0,303.7,4628462.0
-2017-12-04,306.5,308.265,300.61,305.2,5811205.0,0.0,1.0,306.5,308.265,300.61,305.2,5811205.0
-2017-12-01,305.44,310.32,305.05,306.53,4256030.0,0.0,1.0,305.44,310.32,305.05,306.53,4256030.0
-2017-11-30,308.56,310.7,304.54,308.85,4288221.0,0.0,1.0,308.56,310.7,304.54,308.85,4288221.0
-2017-11-29,317.3,318.0,301.23,307.54,8732941.0,0.0,1.0,317.3,318.0,301.23,307.54,8732941.0
-2017-11-28,316.36,320.0,313.92,317.55,4916555.0,0.0,1.0,316.36,320.0,313.92,317.55,4916555.0
-2017-11-27,313.25,317.34,309.51,316.81,4524921.0,0.0,1.0,313.25,317.34,309.51,316.81,4524921.0
-2017-11-24,313.79,316.41,311.0,315.55,3242220.0,0.0,1.0,313.79,316.41,311.0,315.55,3242220.0
-2017-11-22,316.77,317.42,311.84,312.6,4890091.0,0.0,1.0,316.77,317.42,311.84,312.6,4890091.0
-2017-11-21,310.86,318.23,308.71,317.81,7230570.0,0.0,1.0,310.86,318.23,308.71,317.81,7230570.0
-2017-11-20,313.79,315.5,304.75,308.74,8220759.0,0.0,1.0,313.79,315.5,304.75,308.74,8220759.0
-2017-11-17,325.67,326.67,313.15,315.05,13682753.0,0.0,1.0,325.67,326.67,313.15,315.05,13682753.0
-2017-11-16,313.99,318.14,311.3,312.5,5757709.0,0.0,1.0,313.99,318.14,311.3,312.5,5757709.0
-2017-11-15,306.01,312.49,301.5,311.3,5909055.0,0.0,1.0,306.01,312.49,301.5,311.3,5909055.0
-2017-11-14,315.0,316.35,306.9,308.7,5641615.0,0.0,1.0,315.0,316.35,306.9,308.7,5641615.0
-2017-11-13,300.13,316.8,299.11,315.4,7536669.0,0.0,1.0,300.13,316.8,299.11,315.4,7536669.0
-2017-11-10,302.5,308.36,301.85,302.99,4600097.0,0.0,1.0,302.5,308.36,301.85,302.99,4600097.0
-2017-11-09,302.5,304.46,296.3,302.99,5419497.0,0.0,1.0,302.5,304.46,296.3,302.99,5419497.0
-2017-11-07,301.02,306.5,300.03,306.05,5209573.0,0.0,1.0,301.02,306.5,300.03,306.05,5209573.0
-2017-11-06,307.0,307.5,299.01,302.78,6463227.0,0.0,1.0,307.0,307.5,299.01,302.78,6463227.0
-2017-11-03,299.5,306.25,295.13,306.09,8835157.0,0.0,1.0,299.5,306.25,295.13,306.09,8835157.0
-2017-11-02,300.13,308.69,292.63,299.26,19731322.0,0.0,1.0,300.13,308.69,292.63,299.26,19731322.0
-2017-11-01,332.25,332.6089,320.26,321.08,7028856.0,0.0,1.0,332.25,332.6089,320.26,321.08,7028856.0
-2017-10-31,320.23,331.95,320.18,331.53,5532647.0,0.0,1.0,320.23,331.95,320.18,331.53,5532647.0
-2017-10-30,319.18,323.78,317.25,320.08,4236029.0,0.0,1.0,319.18,323.78,317.25,320.08,4236029.0
-2017-10-27,319.75,324.59,316.66,320.87,6942493.0,0.0,1.0,319.75,324.59,316.66,320.87,6942493.0
-2017-10-26,327.78,330.23,323.2,326.17,4980316.0,0.0,1.0,327.78,330.23,323.2,326.17,4980316.0
-2017-10-25,336.7,337.5,323.56,325.84,8547764.0,0.0,1.0,336.7,337.5,323.56,325.84,8547764.0
-2017-10-24,338.8,342.8,336.16,337.34,4463807.0,0.0,1.0,338.8,342.8,336.16,337.34,4463807.0
-2017-10-23,349.88,349.95,336.25,337.02,5715817.0,0.0,1.0,349.88,349.95,336.25,337.02,5715817.0
-2017-10-20,352.69,354.55,344.34,345.1,4888221.0,0.0,1.0,352.69,354.55,344.34,345.1,4888221.0
-2017-10-19,355.56,357.1465,348.2,351.81,5032884.0,0.0,1.0,355.56,357.1465,348.2,351.81,5032884.0
-2017-10-18,355.97,363.0,354.13,359.65,4898808.0,0.0,1.0,355.97,363.0,354.13,359.65,4898808.0
-2017-10-17,350.91,356.22,350.07,355.75,3280670.0,0.0,1.0,350.91,356.22,350.07,355.75,3280670.0
-2017-10-16,353.76,354.48,347.16,350.6,5353262.0,0.0,1.0,353.76,354.48,347.16,350.6,5353262.0
-2017-10-13,356.98,358.49,353.68,355.57,3528413.0,0.0,1.0,356.98,358.49,353.68,355.57,3528413.0
-2017-10-12,352.95,359.78,352.64,355.68,4047318.0,0.0,1.0,352.95,359.78,352.64,355.68,4047318.0
-2017-10-11,353.89,357.6,351.15,354.6,4476769.0,0.0,1.0,353.89,357.6,351.15,354.6,4476769.0
-2017-10-10,346.8,355.63,345.5305,355.59,6914972.0,0.0,1.0,346.8,355.63,345.5305,355.59,6914972.0
-2017-10-09,349.65,351.75,342.67,342.94,7406324.0,0.0,1.0,349.65,351.75,342.67,342.94,7406324.0
-2017-10-06,353.1,360.0992,352.25,356.88,4171789.0,0.0,1.0,353.1,360.0992,352.25,356.88,4171789.0
-2017-10-05,356.0,357.435,351.35,355.33,4102286.0,0.0,1.0,356.0,357.435,351.35,355.33,4102286.0
-2017-10-04,351.25,358.62,349.6,355.01,8120353.0,0.0,1.0,351.25,358.62,349.6,355.01,8120353.0
-2017-10-03,335.9,348.55,331.28,348.14,9981885.0,0.0,1.0,335.9,348.55,331.28,348.14,9981885.0
-2017-10-02,342.52,343.7,335.51,341.53,4901453.0,0.0,1.0,342.52,343.7,335.51,341.53,4901453.0
-2017-09-29,341.86,344.68,338.601,341.1,5062297.0,0.0,1.0,341.86,344.68,338.601,341.1,5062297.0
-2017-09-28,339.88,342.75,335.4,339.6,5279310.0,0.0,1.0,339.88,342.75,335.4,339.6,5279310.0
-2017-09-27,349.9,351.489,340.5,340.97,6010631.0,0.0,1.0,349.9,351.489,340.5,340.97,6010631.0
-2017-09-26,350.93,351.24,340.9,345.25,7126550.0,0.0,1.0,350.93,351.24,340.9,345.25,7126550.0
-2017-09-25,353.15,357.469,342.88,344.99,7542161.0,0.0,1.0,353.15,357.469,342.88,344.99,7542161.0
-2017-09-22,366.49,369.8999,350.88,351.09,8105653.0,0.0,1.0,366.49,369.8999,350.88,351.09,8105653.0
-2017-09-21,374.9,376.83,364.51,366.48,4605428.0,0.0,1.0,374.9,376.83,364.51,366.48,4605428.0
-2017-09-20,373.0,378.249,371.07,373.91,4892872.0,0.0,1.0,373.0,378.249,371.07,373.91,4892872.0
-2017-09-19,380.0,382.39,373.57,375.1,6256035.0,0.0,1.0,380.0,382.39,373.57,375.1,6256035.0
-2017-09-18,380.25,389.61,377.68,385.0,7149295.0,0.0,1.0,380.25,389.61,377.68,385.0,7149295.0
-2017-09-15,374.51,380.0,372.7,379.81,5338678.0,0.0,1.0,374.51,380.0,372.7,379.81,5338678.0
-2017-09-14,364.33,377.96,362.63,377.64,7141663.0,0.0,1.0,364.33,377.96,362.63,377.64,7141663.0
-2017-09-13,363.82,368.07,359.59,366.23,4161382.0,0.0,1.0,363.82,368.07,359.59,366.23,4161382.0
-2017-09-12,364.49,368.76,360.4,362.75,5929289.0,0.0,1.0,364.49,368.76,360.4,362.75,5929289.0
-2017-09-11,351.35,363.71,350.0,363.69,7610309.0,0.0,1.0,351.35,363.71,350.0,363.69,7610309.0
-2017-09-08,348.99,349.78,342.3,343.4,3248803.0,0.0,1.0,348.99,349.78,342.3,343.4,3248803.0
-2017-09-07,345.98,352.48,343.45,350.61,4219997.0,0.0,1.0,345.98,352.48,343.45,350.61,4219997.0
-2017-09-06,349.5,350.979,341.56,344.53,4058983.0,0.0,1.0,349.5,350.979,341.56,344.53,4058983.0
-2017-09-05,353.8,355.49,345.89,349.59,3813862.0,0.0,1.0,353.8,355.49,345.89,349.59,3813862.0
-2017-09-01,356.12,357.59,353.6902,355.4,3028578.0,0.0,1.0,356.12,357.59,353.6902,355.4,3028578.0
-2017-08-31,353.55,358.44,352.82,355.9,4019065.0,0.0,1.0,353.55,358.44,352.82,355.9,4019065.0
-2017-08-30,349.67,353.47,347.0,353.18,3390055.0,0.0,1.0,349.67,353.47,347.0,353.18,3390055.0
-2017-08-29,339.48,349.05,338.75,347.36,4032825.0,0.0,1.0,339.48,349.05,338.75,347.36,4032825.0
-2017-08-28,347.28,347.35,339.72,345.66,3718108.0,0.0,1.0,347.28,347.35,339.72,345.66,3718108.0
-2017-08-25,354.24,355.69,347.3,348.05,3461744.0,0.0,1.0,354.24,355.69,347.3,348.05,3461744.0
-2017-08-24,352.52,356.66,349.74,352.93,4540652.0,0.0,1.0,352.52,356.66,349.74,352.93,4540652.0
-2017-08-23,338.99,353.49,338.3041,352.77,4914201.0,0.0,1.0,338.99,353.49,338.3041,352.77,4914201.0
-2017-08-22,341.13,342.24,337.3725,341.35,4288367.0,0.0,1.0,341.13,342.24,337.3725,341.35,4288367.0
-2017-08-21,345.82,345.82,331.85,337.86,6458812.0,0.0,1.0,345.82,345.82,331.85,337.86,6458812.0
-2017-08-18,352.91,354.0,345.8,347.46,5335793.0,0.0,1.0,352.91,354.0,345.8,347.46,5335793.0
-2017-08-17,361.21,363.3,351.59,351.92,4969222.0,0.0,1.0,361.21,363.3,351.59,351.92,4969222.0
-2017-08-16,363.0,366.5,362.52,362.91,3328576.0,0.0,1.0,363.0,366.5,362.52,362.91,3328576.0
-2017-08-15,365.2,365.49,359.37,362.33,3048074.0,0.0,1.0,365.2,365.49,359.37,362.33,3048074.0
-2017-08-14,364.63,367.66,362.6,363.8,4461215.0,0.0,1.0,364.63,367.66,362.6,363.8,4461215.0
-2017-08-11,356.97,361.26,353.62,357.715,4318835.0,0.0,1.0,356.97,361.26,353.62,357.715,4318835.0
-2017-08-10,361.6,366.6504,354.66,355.13,7035192.0,0.0,1.0,361.6,366.6504,354.66,355.13,7035192.0
-2017-08-09,361.0,370.0,358.95,363.525,6847245.0,0.0,1.0,361.0,370.0,358.95,363.525,6847245.0
-2017-08-08,357.53,368.58,357.4,365.22,7363033.0,0.0,1.0,357.53,368.58,357.4,365.22,7363033.0
-2017-08-07,357.35,359.48,352.75,355.17,6265570.0,0.0,1.0,357.35,359.48,352.75,355.17,6265570.0
-2017-08-04,347.0,357.27,343.3,356.91,9151520.0,0.0,1.0,347.0,357.27,343.3,356.91,9151520.0
-2017-08-03,345.33,350.0,343.15,347.09,13448583.0,0.0,1.0,345.33,350.0,343.15,347.09,13448583.0
-2017-08-02,318.94,327.12,311.22,325.89,9911432.0,0.0,1.0,318.94,327.12,311.22,325.89,9911432.0
-2017-08-01,323.0,324.45,316.13,319.57,8247544.0,0.0,1.0,323.0,324.45,316.13,319.57,8247544.0
-2017-07-31,335.5,341.49,321.04,323.47,8499335.0,0.0,1.0,335.5,341.49,321.04,323.47,8499335.0
-2017-07-28,336.89,339.6,332.51,335.07,4841257.0,0.0,1.0,336.89,339.6,332.51,335.07,4841257.0
-2017-07-27,346.0,347.5,326.29,334.46,8259202.0,0.0,1.0,346.0,347.5,326.29,334.46,8259202.0
-2017-07-26,340.36,345.5,338.12,343.85,4750198.0,0.0,1.0,340.36,345.5,338.12,343.85,4750198.0
-2017-07-25,345.0,345.6,334.15,339.6,6958889.0,0.0,1.0,345.0,345.6,334.15,339.6,6958889.0
-2017-07-24,330.24,343.399,330.01,342.52,8552012.0,0.0,1.0,330.24,343.399,330.01,342.52,8552012.0
-2017-07-21,329.46,331.2575,325.8,328.4,4826383.0,0.0,1.0,329.46,331.2575,325.8,328.4,4826383.0
-2017-07-20,326.9,330.22,324.2,329.92,5098707.0,0.0,1.0,326.9,330.22,324.2,329.92,5098707.0
-2017-07-19,328.23,331.65,323.2193,325.26,6300735.0,0.0,1.0,328.23,331.65,323.2193,325.26,6300735.0
-2017-07-18,317.5,329.13,315.66,328.24,6326961.0,0.0,1.0,317.5,329.13,315.66,328.24,6326961.0
-2017-07-17,325.54,327.1,313.45,319.57,9784200.0,0.0,1.0,325.54,327.1,313.45,319.57,9784200.0
-2017-07-14,323.19,328.42,321.22,327.78,5590393.0,0.0,1.0,323.19,328.42,321.22,327.78,5590393.0
-2017-07-13,330.11,331.6,319.97,323.41,8540442.0,0.0,1.0,330.11,331.6,319.97,323.41,8540442.0
-2017-07-12,330.4,333.1,324.5,329.52,10297839.0,0.0,1.0,330.4,333.1,324.5,329.52,10297839.0
-2017-07-11,316.0,327.28,314.3,327.22,11400054.0,0.0,1.0,316.0,327.28,314.3,327.22,11400054.0
-2017-07-10,312.9,317.94,303.13,316.05,13702080.0,0.0,1.0,312.9,317.94,303.13,316.05,13702080.0
-2017-07-07,313.5,317.0,307.38,313.22,14053750.0,0.0,1.0,313.5,317.0,307.38,313.22,14053750.0
-2017-07-06,317.26,320.7899,306.3,308.89,19189195.0,0.0,1.0,317.26,320.7899,306.3,308.89,19189195.0
-2017-07-05,347.2,347.24,326.33,327.09,16883496.0,0.0,1.0,347.2,347.24,326.33,327.09,16883496.0
-2017-07-03,370.24,371.35,351.5,352.62,6297330.0,0.0,1.0,370.24,371.35,351.5,352.62,6297330.0
-2017-06-30,363.71,366.7674,359.6187,361.61,5759458.0,0.0,1.0,363.71,366.7674,359.6187,361.61,5759458.0
-2017-06-29,370.61,371.0,354.1,360.75,8180408.0,0.0,1.0,370.61,371.0,354.1,360.75,8180408.0
-2017-06-28,366.68,371.74,362.52,371.24,6245040.0,0.0,1.0,366.68,371.74,362.52,371.24,6245040.0
-2017-06-27,376.4,376.4,362.02,362.37,6884529.0,0.0,1.0,376.4,376.4,362.02,362.37,6884529.0
-2017-06-26,386.69,386.95,373.1,377.49,6575285.0,0.0,1.0,386.69,386.95,373.1,377.49,6575285.0
-2017-06-23,382.45,386.99,379.345,383.45,6176578.0,0.0,1.0,382.45,386.99,379.345,383.45,6176578.0
-2017-06-22,377.99,385.0,373.57,382.61,7485677.0,0.0,1.0,377.99,385.0,373.57,382.61,7485677.0
-2017-06-21,374.35,376.99,368.02,376.4,4900356.0,0.0,1.0,374.35,376.99,368.02,376.4,4900356.0
-2017-06-20,376.67,378.88,369.73,372.24,7396357.0,0.0,1.0,376.67,378.88,369.73,372.24,7396357.0
-2017-06-19,375.0,376.7,367.8,369.8,6392331.0,0.0,1.0,375.0,376.7,367.8,369.8,6392331.0
-2017-06-16,377.975,378.01,370.1,371.4,6259666.0,0.0,1.0,377.975,378.01,370.1,371.4,6259666.0
-2017-06-15,372.5,375.46,366.49,375.34,10371559.0,0.0,1.0,372.5,375.46,366.49,375.34,10371559.0
-2017-06-14,381.085,384.25,376.31,380.66,12731997.0,0.0,1.0,381.085,384.25,376.31,380.66,12731997.0
-2017-06-13,367.62,376.0,366.61,375.95,11693404.0,0.0,1.0,367.62,376.0,366.61,375.95,11693404.0
-2017-06-12,357.99,364.5,350.62,359.01,10476833.0,0.0,1.0,357.99,364.5,350.62,359.01,10476833.0
-2017-06-09,374.42,376.87,354.8,357.32,17160231.0,0.0,1.0,374.42,376.87,354.8,357.32,17160231.0
-2017-06-08,363.75,371.9,360.22,370.0,8975028.0,0.0,1.0,363.75,371.9,360.22,370.0,8975028.0
-2017-06-07,356.34,360.5,355.14,359.65,9287888.0,0.0,1.0,356.34,360.5,355.14,359.65,9287888.0
-2017-06-06,344.7,359.4929,339.97,352.85,10951473.0,0.0,1.0,344.7,359.4929,339.97,352.85,10951473.0
-2017-06-05,338.5,348.44,334.21,347.32,6737855.0,0.0,1.0,338.5,348.44,334.21,347.32,6737855.0
-2017-06-02,339.77,342.88,335.93,339.85,5570256.0,0.0,1.0,339.77,342.88,335.93,339.85,5570256.0
-2017-06-01,344.0,344.88,337.29,340.37,7580447.0,0.0,1.0,344.0,344.88,337.29,340.37,7580447.0
diff --git a/examples/quick/demos/stocqt/content/data/TXN.csv b/examples/quick/demos/stocqt/content/data/TXN.csv
deleted file mode 100644
index d42c304e8f..0000000000
--- a/examples/quick/demos/stocqt/content/data/TXN.csv
+++ /dev/null
@@ -1,148 +0,0 @@
-Date,Open,High,Low,Close,Volume,Ex-Dividend,Split Ratio,Adj. Open,Adj. High,Adj. Low,Adj. Close,Adj. Volume
-2017-12-29,104.58,105.08,104.42,104.44,2767863.0,0.0,1.0,104.58,105.08,104.42,104.44,2767863.0
-2017-12-28,104.92,104.92,104.2194,104.82,1632350.0,0.0,1.0,104.92,104.92,104.2194,104.82,1632350.0
-2017-12-27,104.42,104.9,103.98,104.53,1699287.0,0.0,1.0,104.42,104.9,103.98,104.53,1699287.0
-2017-12-26,103.58,104.19,103.06,104.15,1468127.0,0.0,1.0,103.58,104.19,103.06,104.15,1468127.0
-2017-12-22,104.0,104.34,103.64,104.13,3022033.0,0.0,1.0,104.0,104.34,103.64,104.13,3022033.0
-2017-12-21,105.16,105.33,104.0055,104.07,4505720.0,0.0,1.0,105.16,105.33,104.0055,104.07,4505720.0
-2017-12-20,104.9,105.15,103.48,104.8,5433234.0,0.0,1.0,104.9,105.15,103.48,104.8,5433234.0
-2017-12-19,103.19,104.3,103.08,104.1,5133128.0,0.0,1.0,103.19,104.3,103.08,104.1,5133128.0
-2017-12-18,102.1,103.37,101.65,103.27,5494703.0,0.0,1.0,102.1,103.37,101.65,103.27,5494703.0
-2017-12-15,101.28,101.6,100.07,101.22,7773336.0,0.0,1.0,101.28,101.6,100.07,101.22,7773336.0
-2017-12-14,98.96,100.537,98.78,100.25,6802423.0,0.0,1.0,98.96,100.537,98.78,100.25,6802423.0
-2017-12-13,98.97,99.18,98.21,98.86,5151351.0,0.0,1.0,98.97,99.18,98.21,98.86,5151351.0
-2017-12-12,98.7,99.19,98.23,98.43,5766972.0,0.0,1.0,98.7,99.19,98.23,98.43,5766972.0
-2017-12-11,98.07,98.88,97.77,98.83,5137163.0,0.0,1.0,98.07,98.88,97.77,98.83,5137163.0
-2017-12-08,98.92,99.31,97.78,98.02,5282589.0,0.0,1.0,98.92,99.31,97.78,98.02,5282589.0
-2017-12-07,97.32,98.14,96.94,97.78,4195838.0,0.0,1.0,97.32,98.14,96.94,97.78,4195838.0
-2017-12-06,96.25,97.45,95.87,97.02,4438627.0,0.0,1.0,96.25,97.45,95.87,97.02,4438627.0
-2017-12-05,95.98,98.72,95.36,96.9,4759253.0,0.0,1.0,95.98,98.72,95.36,96.9,4759253.0
-2017-12-04,97.54,97.88,95.27,95.97,4891987.0,0.0,1.0,97.54,97.88,95.27,95.97,4891987.0
-2017-12-01,96.54,97.41,94.72,97.18,4925917.0,0.0,1.0,96.54,97.41,94.72,97.18,4925917.0
-2017-11-30,97.38,98.47,96.7,97.29,7195996.0,0.0,1.0,97.38,98.47,96.7,97.29,7195996.0
-2017-11-29,99.73,99.79,96.45,96.88,5408821.0,0.0,1.0,99.73,99.79,96.45,96.88,5408821.0
-2017-11-28,99.09,99.73,98.62,99.48,3010642.0,0.0,1.0,99.09,99.73,98.62,99.48,3010642.0
-2017-11-27,98.95,99.25,98.61,98.63,2900573.0,0.0,1.0,98.95,99.25,98.61,98.63,2900573.0
-2017-11-24,98.2,99.33,98.19,99.3,1288450.0,0.0,1.0,98.2,99.33,98.19,99.3,1288450.0
-2017-11-22,99.15,99.35,98.07,98.08,2109870.0,0.0,1.0,99.15,99.35,98.07,98.08,2109870.0
-2017-11-21,98.75,99.65,98.65,99.19,3668182.0,0.0,1.0,98.75,99.65,98.65,99.19,3668182.0
-2017-11-20,97.81,98.92,97.8,98.28,2912436.0,0.0,1.0,97.81,98.92,97.8,98.28,2912436.0
-2017-11-17,98.56,98.56,97.61,97.74,3694813.0,0.0,1.0,98.56,98.56,97.61,97.74,3694813.0
-2017-11-16,97.07,98.63,97.05,98.32,3531463.0,0.0,1.0,97.07,98.63,97.05,98.32,3531463.0
-2017-11-15,96.62,98.03,96.28,96.77,3332930.0,0.0,1.0,96.62,98.03,96.28,96.77,3332930.0
-2017-11-14,96.7,97.23,96.35,96.96,2727637.0,0.0,1.0,96.7,97.23,96.35,96.96,2727637.0
-2017-11-13,96.4,97.29,96.35,97.03,2158456.0,0.0,1.0,96.4,97.29,96.35,97.03,2158456.0
-2017-11-10,96.67,97.05,96.4,96.94,3093870.0,0.0,1.0,96.67,97.05,96.4,96.94,3093870.0
-2017-11-09,97.6,98.03,95.63,97.05,4180900.0,0.0,1.0,97.6,98.03,95.63,97.05,4180900.0
-2017-11-07,98.55,99.05,98.28,98.4,3883582.0,0.0,1.0,98.55,99.05,98.28,98.4,3883582.0
-2017-11-06,97.82,98.67,97.67,98.54,4261980.0,0.0,1.0,97.82,98.67,97.67,98.54,4261980.0
-2017-11-03,97.0,98.0,96.34,97.98,3329584.0,0.0,1.0,97.0,98.0,96.34,97.98,3329584.0
-2017-11-02,96.25,96.88,95.6,96.79,3274438.0,0.0,1.0,96.25,96.88,95.6,96.79,3274438.0
-2017-11-01,96.97,97.25,95.77,96.35,3826516.0,0.0,1.0,96.97,97.25,95.77,96.35,3826516.0
-2017-10-31,96.28,97.04,96.18,96.69,3747495.0,0.0,1.0,96.28,97.04,96.18,96.69,3747495.0
-2017-10-30,96.68,97.13,95.92,96.06,4914536.0,0.62,1.0,96.68,97.13,95.92,96.06,4914536.0
-2017-10-27,95.94,97.56,95.71,97.5,5534015.0,0.0,1.0,95.324745552338,96.934356640463,95.096220521307,96.874741414977,5534015.0
-2017-10-26,96.44,96.9399,95.84,96.17,5481993.0,0.0,1.0,95.821539098055,96.318233285064,95.225386843194,95.553270583368,5481993.0
-2017-10-25,95.0,96.7,94.16,95.82,6805958.0,0.0,1.0,94.390773686388,96.079871741829,93.556160529582,95.205515101365,6805958.0
-2017-10-24,96.3,96.62,95.46,96.44,7521218.0,0.0,1.0,95.682436905254,96.000384774514,94.847823748448,95.821539098055,7521218.0
-2017-10-23,96.0,96.7399,95.44,96.21,7248578.0,0.0,1.0,95.384360777824,96.119515866777,94.82795200662,95.593014067025,7248578.0
-2017-10-20,94.05,95.4,94.0,95.18,4775490.0,0.0,1.0,93.446865949524,94.788208522962,93.397186594952,94.569619362847,4775490.0
-2017-10-19,92.97,93.64,92.57,93.45,3890390.0,0.0,1.0,92.373791890774,93.039495242036,91.976357054199,92.850713694663,3890390.0
-2017-10-18,94.26,94.29,93.2,93.43,3528482.0,0.0,1.0,93.655519238726,93.685326851469,92.602316921804,92.830841952834,3528482.0
-2017-10-17,94.17,94.31,93.54,94.27,3136049.0,0.0,1.0,93.566096400496,93.705198593297,92.940136532892,93.66545510964,3136049.0
-2017-10-16,94.21,94.41,93.67,94.23,3109004.0,0.0,1.0,93.605839884154,93.804557302441,93.069302854779,93.625711625983,3109004.0
-2017-10-13,93.09,93.73,92.8,93.59,2666130.0,0.0,1.0,92.493022341746,93.128918080265,92.20488208523,92.989815887464,2666130.0
-2017-10-12,92.88,93.31,92.59,92.62,3415763.0,0.0,1.0,92.284369052544,92.711611501862,91.996228796028,92.026036408771,3415763.0
-2017-10-11,91.99,92.92,91.72,92.87,2996950.0,0.0,1.0,91.400076541167,92.324112536202,91.131808026479,92.27443318163,2996950.0
-2017-10-10,91.97,92.41,91.465,92.38,2805769.0,0.0,1.0,91.380204799338,91.81738311957,90.878443318163,91.787575506827,2805769.0
-2017-10-09,91.61,91.86,91.31,91.57,1636340.0,0.0,1.0,91.022513446421,91.27091021928,90.72443731899,90.982769962764,1636340.0
-2017-10-06,90.74,91.54,90.74,91.35,2300990.0,0.0,1.0,90.158092676872,90.952962350021,90.158092676872,90.764180802648,2300990.0
-2017-10-05,90.55,91.3,90.11,91.14,3105380.0,0.0,1.0,89.969311129499,90.714501448076,89.532132809268,90.555527513446,3105380.0
-2017-10-04,89.9,90.56,89.58,90.49,3781466.0,0.0,1.0,89.323479520066,89.979247000414,89.005531650807,89.909695904013,3781466.0
-2017-10-03,89.65,90.24,89.5,89.94,2330174.0,0.0,1.0,89.075082747207,89.661299131154,88.926044683492,89.363223003724,2330174.0
-2017-10-02,89.88,90.24,89.31,89.65,3134142.0,0.0,1.0,89.303607778237,89.661299131154,88.737263136119,89.075082747207,3134142.0
-2017-09-29,89.77,89.89,89.09,89.64,3144262.0,0.0,1.0,89.19431319818,89.313543649152,88.518673976003,89.065146876293,3144262.0
-2017-09-28,88.44,89.66,88.35,89.65,5054134.0,0.0,1.0,87.87284236657,89.085018618122,87.783419528341,89.075082747207,5054134.0
-2017-09-27,88.48,89.15,87.85,88.81,3611592.0,0.0,1.0,87.912585850228,88.578289201489,87.286625982623,88.240469590401,3611592.0
-2017-09-26,87.99,88.29,87.45,87.7,2961476.0,0.0,1.0,87.425728175424,87.723804302855,86.889191146049,87.137587918908,2961476.0
-2017-09-25,87.65,88.08,86.9188,87.5,5475113.0,0.0,1.0,87.087908564336,87.515151013653,86.361397683078,86.938870500621,5475113.0
-2017-09-22,86.59,88.45,86.5,88.27,6374309.0,0.0,1.0,86.034706247414,87.882778237484,85.945283409185,87.703932561026,6374309.0
-2017-09-21,86.02,86.59,85.67,86.05,3979462.0,0.0,1.0,85.468361605296,86.034706247414,85.120606123293,85.498169218039,3979462.0
-2017-09-20,87.0,87.0,84.48,85.83,4829104.0,0.0,1.0,86.442076954903,86.442076954903,83.938237484485,85.279580057923,4829104.0
-2017-09-19,86.37,87.24,85.64,86.81,3924755.0,0.0,1.0,85.816117087298,86.680537856847,85.09079851055,86.25329540753,3924755.0
-2017-09-18,85.0,86.47,84.89,86.14,5296505.0,0.0,1.0,84.454902772031,85.915475796442,84.345608191974,85.587592056268,5296505.0
-2017-09-15,83.14,85.03,82.87,84.84,9419782.0,0.0,1.0,82.606830781961,84.484710384775,82.338562267273,84.295928837402,9419782.0
-2017-09-14,82.4,83.67,82.4,83.29,3482781.0,0.0,1.0,81.871576334299,83.133431940422,81.871576334299,82.755868845676,3482781.0
-2017-09-13,82.84,82.94,82.28,82.7,2531515.0,0.0,1.0,82.30875465453,82.408113363674,81.752345883326,82.169652461729,2531515.0
-2017-09-12,82.34,82.95,82.155,82.89,4559914.0,0.0,1.0,81.811961108813,82.418049234588,81.628147496897,82.358434009102,4559914.0
-2017-09-11,81.9,82.73,81.81,82.22,3810169.0,0.0,1.0,81.374782788581,82.199460074472,81.285359950352,81.69273065784,3810169.0
-2017-09-08,81.98,82.035,81.25,81.38,2423569.0,0.0,1.0,81.454269755896,81.508917045925,80.728951179148,80.858117501034,2423569.0
-2017-09-07,82.45,83.99,81.79,82.0,3568251.0,0.0,1.0,81.921255688871,83.451379809681,81.265488208523,81.474141497724,3568251.0
-2017-09-06,82.24,82.37,81.59,82.07,3627993.0,0.0,1.0,81.712602399669,81.841768721556,81.066770790236,81.543692594125,3627993.0
-2017-09-05,82.32,82.49,81.27,81.85,3665925.0,0.0,1.0,81.792089366984,81.960999172528,80.748822920976,81.325103434009,3665925.0
-2017-09-01,82.74,83.1137,82.38,82.54,2644706.0,0.0,1.0,82.209395945387,82.580699441456,81.85170459247,82.0106785271,2644706.0
-2017-08-31,82.44,82.95,82.13,82.82,4301382.0,0.0,1.0,81.911319817956,82.418049234588,81.603307819611,82.288882912702,4301382.0
-2017-08-30,81.21,82.41,81.1,82.31,4353457.0,0.0,1.0,80.68920769549,81.881512205213,80.579913115432,81.78215349607,4353457.0
-2017-08-29,80.08,81.25,80.03,81.03,3677615.0,0.0,1.0,79.566454282168,80.728951179148,79.516774927596,80.510362019032,3677615.0
-2017-08-28,81.44,81.66,80.58,80.76,3042730.0,0.0,1.0,80.91773272652,81.136321886636,80.063247827886,80.242093504344,3042730.0
-2017-08-25,81.58,81.9,80.94,80.98,2560280.0,0.0,1.0,81.056834919321,81.374782788581,80.420939180803,80.46068266446,2560280.0
-2017-08-24,81.16,81.495,80.82,81.25,3312832.0,0.0,1.0,80.639528340918,80.972380016549,80.30170872983,80.728951179148,3312832.0
-2017-08-23,80.24,81.12,80.07,80.89,4039288.0,0.0,1.0,79.725428216798,80.599784857261,79.556518411254,80.371259826231,4039288.0
-2017-08-22,80.34,81.13,80.06,80.75,4302975.0,0.0,1.0,79.824786925941,80.609720728175,79.546582540339,80.23215763343,4302975.0
-2017-08-21,80.14,80.24,79.6,79.89,3167966.0,0.0,1.0,79.626069507654,79.725428216798,79.089532478279,79.377672734795,3167966.0
-2017-08-18,80.09,80.69,79.94,79.97,3605319.0,0.0,1.0,79.576390153082,80.172542407944,79.427352089367,79.45715970211,3605319.0
-2017-08-17,81.95,82.16,80.09,80.15,4036391.0,0.0,1.0,81.424462143153,81.633115432354,79.576390153082,79.636005378568,4036391.0
-2017-08-16,82.42,82.66,81.95,82.46,3171387.0,0.0,1.0,81.891448076127,82.129908978072,81.424462143153,81.931191559785,3171387.0
-2017-08-15,82.07,82.31,81.69,81.95,3597596.0,0.0,1.0,81.543692594125,81.78215349607,81.166129499379,81.424462143153,3597596.0
-2017-08-14,81.48,82.21,81.2031,82.05,3449064.0,0.0,1.0,80.957476210178,81.682794786926,80.682351944559,81.523820852296,3449064.0
-2017-08-11,80.58,81.34,80.43,80.89,3348656.0,0.0,1.0,80.063247827886,80.818374017377,79.91420976417,80.371259826231,3348656.0
-2017-08-10,81.8,82.0,80.28,80.36,4260051.0,0.0,1.0,81.275424079437,81.474141497724,79.765171700455,79.84465866777,4260051.0
-2017-08-09,81.97,82.31,81.38,82.28,4083335.0,0.0,1.0,81.444333884981,81.78215349607,80.858117501034,81.752345883326,4083335.0
-2017-08-08,81.99,83.69,81.89,82.45,6995231.0,0.0,1.0,81.46420562681,83.153303682251,81.364846917667,81.921255688871,6995231.0
-2017-08-07,81.44,82.2,81.44,82.17,2808616.0,0.0,1.0,80.91773272652,81.672858916012,80.91773272652,81.643051303269,2808616.0
-2017-08-04,81.63,81.96,81.25,81.43,2293905.0,0.0,1.0,81.106514273893,81.434398014067,80.728951179148,80.907796855606,2293905.0
-2017-08-03,81.3,81.73,80.965,81.36,2704547.0,0.0,1.0,80.778630533719,81.205872983037,80.445778858089,80.838245759206,2704547.0
-2017-08-02,82.01,82.01,80.64,81.31,3121636.0,0.0,1.0,81.484077368639,81.484077368639,80.122863053372,80.788566404634,3121636.0
-2017-08-01,81.6,81.84,81.02,81.71,3243303.0,0.0,1.0,81.07670666115,81.315167563095,80.500426148117,81.186001241208,3243303.0
-2017-07-31,80.83,81.66,80.78,81.38,5780471.0,0.0,1.0,80.311644600745,81.136321886636,80.261965246173,80.858117501034,5780471.0
-2017-07-28,80.42,81.04,80.05,80.71,5188380.0,0.0,1.0,79.904273893256,80.520297889946,79.536646669425,80.192414149772,5188380.0
-2017-07-27,82.125,82.53,80.09,80.97,6842762.0,0.5,1.0,81.598339884154,82.000742656185,79.576390153082,80.450746793546,6842762.0
-2017-07-26,83.0,84.24,81.96,82.55,6633813.0,0.0,1.0,81.9616053009,83.186091934311,80.934616511587,81.517235151678,6633813.0
-2017-07-25,81.05,81.93,80.58,81.39,6302456.0,0.0,1.0,80.036001320939,80.904991834972,79.571881387307,80.371747655906,6302456.0
-2017-07-24,81.86,81.8673,80.6,80.92,4333751.0,0.0,1.0,80.835867589538,80.843076260847,79.591631171717,79.907627722275,4333751.0
-2017-07-21,81.46,82.0,81.0,81.7,4396691.0,0.0,1.0,80.440871901341,80.974116080407,79.986626859914,80.677869314259,4396691.0
-2017-07-20,82.2,82.81,81.8621,82.69,3719865.0,0.0,1.0,81.171613924505,81.773982349006,80.837941316901,81.655483642547,3719865.0
-2017-07-19,82.49,82.7,81.86,82.16,3065398.0,0.0,1.0,81.457985798448,81.665358534752,80.835867589538,81.132114355686,3065398.0
-2017-07-18,81.5,82.205,81.15,82.16,2713549.0,0.0,1.0,80.480371470161,81.176551370608,80.134750242988,81.132114355686,2713549.0
-2017-07-17,81.82,82.0,81.48,81.66,2955424.0,0.0,1.0,80.796368020718,80.974116080407,80.460621685751,80.638369745439,2955424.0
-2017-07-14,80.95,82.11,80.8481,82.0,3597113.0,0.0,1.0,79.937252398889,81.082739894661,79.836627247321,80.974116080407,3597113.0
-2017-07-13,80.41,80.98,80.265,80.54,3323859.0,0.0,1.0,79.404008219823,79.966877075504,79.260822282852,79.532381818487,3323859.0
-2017-07-12,79.46,80.54,79.46,80.52,3839369.0,0.0,1.0,78.465893460355,79.532381818487,78.465893460355,79.512632034078,3839369.0
-2017-07-11,78.78,79.145,78.28,79.04,2673057.0,0.0,1.0,77.79440079042,78.1548343559,77.300656180174,78.051147987748,2673057.0
-2017-07-10,78.43,79.09,77.925,78.78,3266394.0,0.0,1.0,77.448779563248,78.100522448773,76.950097506899,77.79440079042,3266394.0
-2017-07-07,77.31,78.66,77.31,78.48,5215579.0,0.0,1.0,76.342791636296,77.675902083961,76.342791636296,77.498154024272,5215579.0
-2017-07-06,76.19,77.69,76.19,76.86,4998196.0,0.0,1.0,75.236803709344,76.718037540083,75.236803709344,75.898421487074,4998196.0
-2017-07-05,76.63,77.51,76.24,76.91,6552479.0,0.0,1.0,75.671298966361,76.540289480394,75.286178170369,75.947795948099,6552479.0
-2017-07-03,77.45,77.635,76.4,76.41,3493669.0,0.0,1.0,76.481040127165,76.663725632956,75.444176445647,75.454051337852,3493669.0
-2017-06-30,77.69,77.69,76.61,76.93,4618555.0,0.0,1.0,76.718037540083,76.718037540083,75.651549181951,75.967545732509,4618555.0
-2017-06-29,77.5,77.93,75.9199,76.9,6526856.0,0.0,1.0,76.530414588189,76.955034953001,74.970082870889,75.937921055894,6526856.0
-2017-06-28,77.61,78.21,76.95,78.06,6338112.0,0.0,1.0,76.639038402444,77.231531934739,75.987295516918,77.083408551665,6338112.0
-2017-06-27,78.0,78.27,76.94,76.95,5697074.0,0.0,1.0,77.024159198436,77.290781287969,75.977420624713,75.987295516918,5697074.0
-2017-06-26,80.04,80.09,78.24,78.31,4881033.0,0.0,1.0,79.038637208241,79.088011669266,77.261156611354,77.330280856789,4881033.0
-2017-06-23,79.06,80.02,78.64,79.58,3608764.0,0.0,1.0,78.070897772158,79.018887423831,77.656152299551,78.584392166814,3608764.0
-2017-06-22,79.95,80.05,78.95,79.05,3306610.0,0.0,1.0,78.949763178397,79.048512100446,77.962273957904,78.061022879953,3306610.0
-2017-06-21,79.7,79.92,79.23,79.67,4256147.0,0.0,1.0,78.702890873274,78.920138501782,78.238770939642,78.673266196659,4256147.0
-2017-06-20,81.16,81.23,79.54,79.57,3789428.0,0.0,1.0,80.144625135193,80.213749380627,78.544892597995,78.574517274609,3789428.0
-2017-06-19,80.37,81.45,80.28,81.42,3479332.0,0.0,1.0,79.364508651004,80.430997009136,79.275634621159,80.401372332521,3479332.0
-2017-06-16,79.85,80.23,79.02,79.7,5945383.0,0.0,1.0,78.851014256347,79.226260160135,78.031398203338,78.702890873274,5945383.0
-2017-06-15,79.35,80.4,79.22,80.08,3024056.0,0.0,1.0,78.357269646101,79.394133327618,78.228896047437,79.078136777061,3024056.0
-2017-06-14,81.26,81.49,79.44,80.16,3919507.0,0.0,1.0,80.243374057242,80.470496577956,78.446143675945,79.1571359147,3919507.0
-2017-06-13,81.41,81.8,80.6,80.98,4274125.0,0.0,1.0,80.391497440316,80.776618236308,79.591631171717,79.966877075504,4274125.0
-2017-06-12,79.82,81.32,79.6678,81.05,6724786.0,0.0,1.0,78.821389579733,80.302623410472,78.671093720374,80.036001320939,6724786.0
-2017-06-09,84.23,84.65,79.94,80.9,6785300.0,0.0,1.0,83.176217042106,83.590962514713,78.939888286192,79.887877937865,6785300.0
-2017-06-08,83.2,84.36,82.62,84.34,4332428.0,0.0,1.0,82.159103144998,83.30459064077,81.586359397112,83.28484085636,4332428.0
-2017-06-07,82.8,83.43,82.29,82.89,3705908.0,0.0,1.0,81.764107456801,82.386225665712,81.26048795435,81.852981486645,3705908.0
-2017-06-06,81.65,82.875,81.51,82.22,3222387.0,0.0,1.0,80.628494853234,81.838169148338,80.490246362365,81.191363708915,3222387.0
-2017-06-05,81.66,82.38,81.66,81.885,2467546.0,0.0,1.0,80.638369745439,81.349361984194,80.638369745439,80.86055482005,2467546.0
-2017-06-02,81.96,81.97,80.86,81.63,4714171.0,0.0,1.0,80.934616511587,80.944491403792,79.848378369045,80.608745068825,4714171.0
-2017-06-01,82.61,82.8642,81.215,81.49,4292961.0,0.0,1.0,81.576484504907,81.827504264757,80.19893704232,80.470496577956,4292961.0
diff --git a/examples/quick/demos/stocqt/content/images/icon-left-arrow.png b/examples/quick/demos/stocqt/content/images/icon-left-arrow.png
deleted file mode 100644
index 926938cadd..0000000000
--- a/examples/quick/demos/stocqt/content/images/icon-left-arrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel-touch.png b/examples/quick/demos/stocqt/content/images/wheel-touch.png
deleted file mode 100644
index 11c8120ada..0000000000
--- a/examples/quick/demos/stocqt/content/images/wheel-touch.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel.png b/examples/quick/demos/stocqt/content/images/wheel.png
deleted file mode 100644
index 470a675b35..0000000000
--- a/examples/quick/demos/stocqt/content/images/wheel.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/qmldir b/examples/quick/demos/stocqt/content/qmldir
deleted file mode 100644
index 77f5ed3c56..0000000000
--- a/examples/quick/demos/stocqt/content/qmldir
+++ /dev/null
@@ -1,12 +0,0 @@
-singleton Settings 1.0 Settings.qml
-Button 1.0 Button.qml
-CheckBox 1.0 CheckBox.qml
-StockChart 1.0 StockChart.qml
-StockInfo 1.0 StockInfo.qml
-StockListModel 1.0 StockListModel.qml
-StockListView 1.0 StockListView.qml
-StockModel 1.0 StockModel.qml
-StockSettingsPanel 1.0 StockSettingsPanel.qml
-StockView 1.0 StockView.qml
-StockListDelegate 1.0 StockListDelegate.qml
-Banner 1.0 Banner.qml
diff --git a/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png b/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png
deleted file mode 100644
index 38e279d60d..0000000000
--- a/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/stocqt/doc/src/stocqt.qdoc b/examples/quick/demos/stocqt/doc/src/stocqt.qdoc
deleted file mode 100644
index e324cf63b5..0000000000
--- a/examples/quick/demos/stocqt/doc/src/stocqt.qdoc
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - StocQt
- \ingroup qtquickdemos
- \example demos/stocqt
- \brief A configurable stock chart for the NASDAQ-100.
- \borderedimage qtquick-demo-stocqt.png
-
- The \e{StocQt} application presents a trend chart for the first stock in
- the list of NASDAQ-100 stocks. It allows the user to choose another stock
- from the list, and fetches the required data from the offline dataset
- using \c XMLHttpRequest.
-
- The application uses several custom types such as Button, CheckBox,
- StockChart, StockInfo, StockView, and so on. These types are used to
- present the stock data in a readable form and also let the user customize
- the trend chart. For example, the user can choose to view the weekly,
- monthly, quarterly, or half yearly trends in the stock price.
-
- The application uses the ObjectModel type to access the two visual data
- models that it depends on.
-
- \quotefromfile demos/stocqt/stocqt.qml
- \skipto ListView
- \printuntil id
- \dots 8
- \skipto model
- \printuntil StockView
- \printuntil }
- \printuntil }
- \printuntil }
-
- The StockListView model is a static data model listing the
- NASDAQ-100 stocks with basic information such as stockId, name, value,
- change, and so on. This data model is used by the application if the
- user wants to choose another stock from the list.
-
- StockView is a complex data model that presents a trend chart for the
- selected stock. It uses another custom type, StockChart, which presents
- the graphical trend of the stock price using a Canvas. This data model
- is used for most of the time during the lifetime of the application.
-
- \quotefromfile demos/stocqt/content/StockChart.qml
- \skipto Rectangle
- \printuntil id
- \dots
- \skipto Canvas
- \printuntil id
- \dots 8
- \skipto onPaint
- \printuntil /^\}$/
-
- To understand the application better, browse through its code using
- Qt Creator.
-
- \include examples-run.qdocinc
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/stocqt/main.cpp b/examples/quick/demos/stocqt/main.cpp
deleted file mode 100644
index 6031e28105..0000000000
--- a/examples/quick/demos/stocqt/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/stocqt/stocqt)
diff --git a/examples/quick/demos/stocqt/stocqt.pro b/examples/quick/demos/stocqt/stocqt.pro
deleted file mode 100644
index 0e89a30050..0000000000
--- a/examples/quick/demos/stocqt/stocqt.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TEMPLATE = app
-
-QT += qml quick
-SOURCES += main.cpp
-RESOURCES += stocqt.qrc
-OTHER_FILES += *.qml content/*.qml content/images/*.png
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
-INSTALLS += target
diff --git a/examples/quick/demos/stocqt/stocqt.qmlproject b/examples/quick/demos/stocqt/stocqt.qmlproject
deleted file mode 100644
index 11ab78418a..0000000000
--- a/examples/quick/demos/stocqt/stocqt.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "stocqt.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/stocqt/stocqt.qrc b/examples/quick/demos/stocqt/stocqt.qrc
deleted file mode 100644
index a1c3b25494..0000000000
--- a/examples/quick/demos/stocqt/stocqt.qrc
+++ /dev/null
@@ -1,42 +0,0 @@
-<RCC>
- <qresource prefix="/demos/stocqt">
- <file>stocqt.qml</file>
- <file>content/qmldir</file>
- <file>content/Button.qml</file>
- <file>content/CheckBox.qml</file>
- <file>content/StockChart.qml</file>
- <file>content/StockListModel.qml</file>
- <file>content/StockListView.qml</file>
- <file>content/StockModel.qml</file>
- <file>content/StockView.qml</file>
- <file>content/images/wheel-touch.png</file>
- <file>content/images/wheel.png</file>
- <file>content/images/icon-left-arrow.png</file>
- <file>content/StockSettingsPanel.qml</file>
- <file>content/StockInfo.qml</file>
- <file>content/Settings.qml</file>
- <file>content/+windows/Settings.qml</file>
- <file>content/StockListDelegate.qml</file>
- <file>content/Banner.qml</file>
- <file>content/data/AAPL.csv</file>
- <file>content/data/ADSK.csv</file>
- <file>content/data/AMZN.csv</file>
- <file>content/data/AMD.csv</file>
- <file>content/data/CSCO.csv</file>
- <file>content/data/FB.csv</file>
- <file>content/data/GOOG.csv</file>
- <file>content/data/GOOGL.csv</file>
- <file>content/data/MSFT.csv</file>
- <file>content/data/NCLH.csv</file>
- <file>content/data/NFLX.csv</file>
- <file>content/data/TXN.csv</file>
- <file>content/data/EA.csv</file>
- <file>content/data/EBAY.csv</file>
- <file>content/data/PYPL.csv</file>
- <file>content/data/INTC.csv</file>
- <file>content/data/NTAP.csv</file>
- <file>content/data/QCOM.csv</file>
- <file>content/data/NVDA.csv</file>
- <file>content/data/TSLA.csv</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/demos/tweetsearch/content/FlipBar.qml b/examples/quick/demos/tweetsearch/content/FlipBar.qml
deleted file mode 100644
index 608f5cc08b..0000000000
--- a/examples/quick/demos/tweetsearch/content/FlipBar.qml
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: container
- property int animDuration: 300
- property Item front: Item {}
- property Item back: Item {}
- property real factor: 0.1 // amount the edges fold in for the 3D effect
- property alias delta: effect.delta
- property Item cur: frontShown ? front : back
- property Item noncur: frontShown ? back : front
-
- function swap() {
- var tmp = front;
- front = back;
- back = tmp;
- resync();
- }
-
- width: cur.width
- height: cur.height
- onFrontChanged: resync();
- onBackChanged: resync();
-
- function resync() {//TODO: Are the items ever actually visible?
- back.parent = container;
- front.parent = container;
- frontShown ? back.visible = false : front.visible = false;
- }
-
- property bool frontShown: true
-
- onFrontShownChanged: {
- back.visible = !frontShown
- front.visible = frontShown
- }
-
- function flipUp(start) {
- effect.visible = true;
- effect.sourceA = effect.source1
- effect.sourceB = effect.source2
- if (start == undefined)
- start = 1.0;
- deltaAnim.from = start;
- deltaAnim.to = 0.0
- dAnim.start();
- frontShown = false;
- }
-
- function flipDown(start) {
- effect.visible = true;
- effect.sourceA = effect.source1
- effect.sourceB = effect.source2
- if (start == undefined)
- start = 0.0;
- deltaAnim.from = start;
- deltaAnim.to = 1.0
- dAnim.start();
- frontShown = true;
- }
-
- ShaderEffect {
- id: effect
- width: cur.width
- height: cur.height
- property real factor: container.factor * width
- property real delta: 1.0
-
- mesh: GridMesh { resolution: Qt.size(8,2) }
-
- SequentialAnimation on delta {
- id: dAnim
- running: false
- NumberAnimation {
- id: deltaAnim
- duration: animDuration//expose anim
- }
- }
-
- property variant sourceA: source1
- property variant sourceB: source1
- property variant source1: ShaderEffectSource {
- sourceItem: front
- hideSource: effect.visible
- }
-
- property variant source2: ShaderEffectSource {
- sourceItem: back
- hideSource: effect.visible
- }
-
- fragmentShader: "
- uniform lowp float qt_Opacity;
- uniform sampler2D sourceA;
- uniform sampler2D sourceB;
- uniform highp float delta;
- varying highp vec2 qt_TexCoord0;
- void main() {
- highp vec4 tex = vec4(qt_TexCoord0.x, qt_TexCoord0.y * 2.0, qt_TexCoord0.x, (qt_TexCoord0.y-0.5) * 2.0);
- highp float shade = clamp(delta*2.0, 0.5, 1.0);
- highp vec4 col;
- if (qt_TexCoord0.y < 0.5) {
- col = texture2D(sourceA, tex.xy) * (shade);
- } else {
- col = texture2D(sourceB, tex.zw) * (1.5 - shade);
- col.w = 1.0;
- }
- gl_FragColor = col * qt_Opacity;
- }
- "
- property real h: height
- vertexShader: "
- uniform highp float delta;
- uniform highp float factor;
- uniform highp float h;
- uniform highp mat4 qt_Matrix;
- attribute highp vec4 qt_Vertex;
- attribute highp vec2 qt_MultiTexCoord0;
- varying highp vec2 qt_TexCoord0;
- void main() {
- highp vec4 pos = qt_Vertex;
- if (qt_MultiTexCoord0.y == 0.0)
- pos.x += factor * (1. - delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
- else if (qt_MultiTexCoord0.y == 1.0)
- pos.x += factor * (delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
- else
- pos.y = delta * h;
- gl_Position = qt_Matrix * pos;
- qt_TexCoord0 = qt_MultiTexCoord0;
- }"
-
- }
-}
diff --git a/examples/quick/demos/tweetsearch/content/LineInput.qml b/examples/quick/demos/tweetsearch/content/LineInput.qml
deleted file mode 100644
index 1ef8fd9f5c..0000000000
--- a/examples/quick/demos/tweetsearch/content/LineInput.qml
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-FocusScope {
- id: wrapper
-
- property alias text: input.text
- property alias hint: hint.text
- property alias prefix: prefix.text
-
- signal accepted
-
- Rectangle {
- anchors.fill: parent
- border.color: "#707070"
- color: "#c1c1c1"
- radius: 4
-
- Text {
- id: hint
- anchors { fill: parent; leftMargin: 14 }
- verticalAlignment: Text.AlignVCenter
- text: "Enter word"
- font.pixelSize: 18
- color: "#707070"
- opacity: input.displayText.length ? 0 : 1
- }
-
- Text {
- id: prefix
- anchors { left: parent.left; leftMargin: 14; verticalCenter: parent.verticalCenter }
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 18
- color: "#707070"
- opacity: !hint.opacity
- }
-
- TextInput {
- id: input
- focus: true
- anchors { left: prefix.right; right: parent.right; top: parent.top; bottom: parent.bottom }
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: 18
- color: "#707070"
- onAccepted: wrapper.accepted()
- }
-
- Image {
- source: "resources/icon-search.png"
- anchors.right: parent.right
- anchors.rightMargin: 12
- anchors.verticalCenter: parent.verticalCenter
- MouseArea {
- anchors { fill: parent; margins: -10 }
- onClicked: wrapper.accepted()
- }
- }
- }
-}
diff --git a/examples/quick/demos/tweetsearch/content/ListFooter.qml b/examples/quick/demos/tweetsearch/content/ListFooter.qml
deleted file mode 100644
index b84496d4c1..0000000000
--- a/examples/quick/demos/tweetsearch/content/ListFooter.qml
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- color: "#d6d6d6"
- width: parent.width
- height: childrenRect.height
- z: 2
- Connections {
- target: mainListView
- onAutoSearch: {
- if (type == 'tag') {
- tagSearch.open()
- tagSearch.searchText = str
- } else if (type == 'user'){
- userSearch.open()
- userSearch.searchText = str
- } else {
- wordSearch.open()
- wordSearch.searchText = str
- }
- }
- }
-
- Column {
- width: parent.width
-
- SearchDelegate {
- id: wordSearch
- label: "Search word..."
- placeHolder: "Enter word"
- onHasOpened: {
- tagSearch.close()
- userSearch.close()
- }
- onOk: {
- mainListView.positionViewAtBeginning()
- mainListView.clear()
- tweetsModel.from = ""
- tweetsModel.phrase = searchText
- }
- }
-
- SearchDelegate {
- id: userSearch
- label: "From user..."
- placeHolder: "@username"
- prefix: "@"
- onHasOpened:{
- tagSearch.close()
- wordSearch.close()
- }
- onOk: {
- mainListView.positionViewAtBeginning()
- mainListView.clear()
- tweetsModel.phrase = ""
- tweetsModel.from = searchText
- }
- }
-
- SearchDelegate {
- id: tagSearch
- label: "Search hashtag..."
- placeHolder: "#hashtag"
- prefix: "#"
- onHasOpened:{
- userSearch.close()
- wordSearch.close()
- }
- onOk: {
- mainListView.positionViewAtBeginning()
- mainListView.clear()
- tweetsModel.from = ""
- tweetsModel.phrase = "#" + searchText
- }
- }
-
- SpriteSequence {
- id: sprite
- anchors.horizontalCenter: parent.horizontalCenter
- width: 320
- height: 300
- running: true
- interpolate: false
- Sprite {
- name: "bird"
- source: "resources/bird-anim-sprites.png"
- frameCount: 1
- frameRate: 1
- frameWidth: 320
- frameHeight: 300
- to: { "bird":10, "trill":1, "blink":1 }
- }
- Sprite {
- name: "trill"
- source: "resources/bird-anim-sprites.png"
- frameCount: 5
- frameRate: 3
- frameWidth: 320
- frameHeight: 300
- to: {"bird":1}
- }
- Sprite {
- name: "blink"
- source: "resources/bird-anim-sprites.png"
- frameCount: 1
- frameRate: 3
- frameWidth: 320
- frameHeight: 300
- frameX: 1600
- to: {"bird":1}
- }
- }
- }
-}
diff --git a/examples/quick/demos/tweetsearch/content/ListHeader.qml b/examples/quick/demos/tweetsearch/content/ListHeader.qml
deleted file mode 100644
index 8c4facf34b..0000000000
--- a/examples/quick/demos/tweetsearch/content/ListHeader.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- height: 60
- width: parent.width
-
- property bool refresh: state == "pulled" ? true : false
-
- Row {
- spacing: 6
- height: childrenRect.height
- anchors.centerIn: parent
-
- Image {
- id: arrow
- source: "resources/icon-refresh.png"
- transformOrigin: Item.Center
- Behavior on rotation { NumberAnimation { duration: 200 } }
- }
-
- Text {
- id: label
- anchors.verticalCenter: arrow.verticalCenter
- text: "Pull to refresh... "
- font.pixelSize: 18
- color: "#999999"
- }
- }
-
- states: [
- State {
- name: "base"; when: mainListView.contentY >= -120
- PropertyChanges { target: arrow; rotation: 180 }
- },
- State {
- name: "pulled"; when: mainListView.contentY < -120
- PropertyChanges { target: label; text: "Release to refresh..." }
- PropertyChanges { target: arrow; rotation: 0 }
- }
- ]
-}
diff --git a/examples/quick/demos/tweetsearch/content/SearchDelegate.qml b/examples/quick/demos/tweetsearch/content/SearchDelegate.qml
deleted file mode 100644
index 082653657a..0000000000
--- a/examples/quick/demos/tweetsearch/content/SearchDelegate.qml
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-FlipBar {
- id: flipBar
- animDuration: 250
- property string label: ""
- property string placeHolder: ""
- property alias searchText: lineInput.text
- property alias prefix: lineInput.prefix
- property bool opened: false
- signal ok
- signal hasOpened
-
- height: 60
- width: parent.width
-
- function open() {
- flipBar.flipUp()
- flipBar.opened = true
- lineInput.forceActiveFocus()
- flipBar.hasOpened()
- }
-
- function close() {
- if (opened) {
- flipBar.flipDown()
- flipBar.opened = false
- }
- }
-
- front: Rectangle {
- height: 60
- width: parent.width
- color: "#999999"
-
- Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
- Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- if (!flipBar.opened)
- open()
- else if (!lineInput.activeFocus)
- lineInput.forceActiveFocus()
- else
- close()
- }
- }
-
- Text {
- text: flipBar.label
- anchors { left: parent.left; leftMargin: 20 }
- anchors.verticalCenter: parent.verticalCenter
- font.pixelSize: 18
- color: "#ffffff"
- }
- }
-
- back: FocusScope {
- height: 60
- width: parent.width
- Rectangle {
- anchors.fill: parent
- color: "#999999"
-
- Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
- Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
-
- LineInput {
- id: lineInput
- hint: flipBar.placeHolder
- focus: flipBar.opened
- anchors { fill: parent; margins: 6 }
- onAccepted: {
- if (Qt.inputMethod.visible)
- Qt.inputMethod.hide()
- flipBar.ok()
- }
- }
- }
- }
-
-}
diff --git a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
deleted file mode 100644
index b8953314f1..0000000000
--- a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "tweetsearch.js" as Helper
-
-Item {
- id: container
- property real hm: 1.0
- property int appear: -1
- property real startRotation: 1
-
- onAppearChanged: {
- container.startRotation = 0.5
- flipBar.animDuration = appear;
- delayedAnim.start();
- }
-
- SequentialAnimation {
- id: delayedAnim
- PauseAnimation { duration: 50 }
- ScriptAction { script: flipBar.flipDown(startRotation); }
- }
-
- width: 320
- height: flipBar.height * hm
-
- FlipBar {
- id: flipBar
-
- property bool flipped: false
- delta: startRotation
-
- anchors.bottom: parent.bottom
- width: container.ListView.view ? container.ListView.view.width : 0
- height: Math.max(72, tweet.y + tweet.height + 10)
-
- front: Rectangle {
- width: container.ListView.view ? container.ListView.view.width : 0
- height: Math.max(72, tweet.y + tweet.height + 10)
- color: "#2699bf"
-
- Rectangle { color: "#33ccff"; width: parent.width; height: 1 }
- Rectangle { color: "#1a6680"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
-
- Image {
- id: placeHolder
- source: "resources/anonymous.png"
- x: 10; y: 9
- visible: avatar.status != Image.Ready
- }
-
- Image {
- id: avatar
- source: model.userImage
- anchors.fill: placeHolder
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- flipBar.flipUp()
- flipBar.flipped = true
- }
- }
- }
-
- Text {
- id: name
- text: model.name
- anchors { left: avatar.right; leftMargin: 10; top: avatar.top; topMargin: -3 }
- font.pixelSize: 12
- font.bold: true
- color: "white"
- linkColor: "white"
- }
-
- Text {
- id: tweet
- text: model.statusText
- anchors { left: avatar.right; leftMargin: 10; top: name.bottom; topMargin: 0; right: parent.right; rightMargin: 10 }
- wrapMode: Text.WordWrap
- font.pixelSize: 12
- font.bold: false
- color: "#adebff"
- linkColor: "white"
- onLinkActivated: {
- var tag = link.split("https://twitter.com/search?q=%23")
- var user = link.split("https://twitter.com/")
- if (tag[1] != undefined) {
- mainListView.positionViewAtBeginning()
- mainListView.clear()
- mainListView.autoSearch('tag', tag[1])
- tweetsModel.from = ""
- tweetsModel.phrase = "#" + tag[1]
- } else if (user[1] != undefined) {
- mainListView.positionViewAtBeginning()
- mainListView.clear()
- mainListView.autoSearch('user', user[1])
- tweetsModel.phrase = ""
- tweetsModel.from = user[1]
- } else
- Qt.openUrlExternally(link)
- }
- }
- }
-
- back: Rectangle {
- width: container.ListView.view ? container.ListView.view.width : 0
- height: Math.max(72, tweet.y + tweet.height + 10)
- color: "#be4a25"
-
- Rectangle { color: "#ff6633"; width: parent.width; height: 1 }
- Rectangle { color: "#80341a"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
-
- Image {
- id: avatar2
- source: model.userImage
- anchors.right: parent.right
- anchors.rightMargin: 10
- y: 9
- MouseArea {
- anchors.fill: parent
- onClicked: {
- flipBar.flipDown()
- flipBar.flipped = false
- }
- }
- }
-
- Text {
- id: username
- text: model.twitterName
- x: 10; anchors { top: avatar2.top; topMargin: -3 }
- font.pixelSize: 12
- font.bold: true
- color: "white"
- linkColor: "white"
- }
-
- Text {
- text: model.source + "<br>" + Helper.formatDate(model.published) + "<br>" + model.uri
- x: 10; anchors { top: username.bottom; topMargin: 0 }
- wrapMode: Text.WordWrap
- font.pixelSize: 12
- font.bold: false
- color: "#ffc2ad"
- linkColor: "white"
- onLinkActivated: Qt.openUrlExternally(link);
- }
- }
- }
-}
diff --git a/examples/quick/demos/tweetsearch/content/TweetsModel.qml b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
deleted file mode 100644
index 492f85be76..0000000000
--- a/examples/quick/demos/tweetsearch/content/TweetsModel.qml
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "tweetsearch.js" as Helper
-
-Item {
- id: wrapper
-
- // Insert valid consumer key and secret tokens below
- // See https://dev.twitter.com/apps
-//! [auth tokens]
- property string consumerKey : ""
- property string consumerSecret : ""
-//! [auth tokens]
- property string bearerToken : ""
-
- property variant model: tweets
- property string from : ""
- property string phrase : ""
-
- property int status: XMLHttpRequest.UNSENT
- property bool isLoading: status === XMLHttpRequest.LOADING
- property bool wasLoading: false
- signal isLoaded
-
- ListModel { id: tweets }
-
- function encodePhrase(x) { return encodeURIComponent(x); }
-
- function reload() {
- tweets.clear()
-
- if (from == "" && phrase == "")
- return;
-
-//! [requesting]
- var req = new XMLHttpRequest;
- req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from +
- "&count=10&q=" + encodePhrase(phrase));
- req.setRequestHeader("Authorization", "Bearer " + bearerToken);
- req.onreadystatechange = function() {
- status = req.readyState;
- if (status === XMLHttpRequest.DONE) {
- var objectArray = JSON.parse(req.responseText);
- if (objectArray.errors !== undefined)
- console.log("Error fetching tweets: " + objectArray.errors[0].message)
- else {
- for (var key in objectArray.statuses) {
- var jsonObject = objectArray.statuses[key];
- tweets.append(jsonObject);
- }
- }
- if (wasLoading == true)
- wrapper.isLoaded()
- }
- wasLoading = (status === XMLHttpRequest.LOADING);
- }
- req.send();
-//! [requesting]
- }
-
- onPhraseChanged: reload();
- onFromChanged: reload();
-
- Component.onCompleted: {
- if (consumerKey === "" || consumerSecret == "") {
- bearerToken = encodeURIComponent(Helper.demoToken())
- return;
- }
-
- var authReq = new XMLHttpRequest;
- authReq.open("POST", "https://api.twitter.com/oauth2/token");
- authReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
- authReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(consumerKey + ":" + consumerSecret));
- authReq.onreadystatechange = function() {
- if (authReq.readyState === XMLHttpRequest.DONE) {
- var jsonResponse = JSON.parse(authReq.responseText);
- if (jsonResponse.errors !== undefined)
- console.log("Authentication error: " + jsonResponse.errors[0].message)
- else
- bearerToken = jsonResponse.access_token;
- }
- }
- authReq.send("grant_type=client_credentials");
- }
-
-}
diff --git a/examples/quick/demos/tweetsearch/content/resources/anonymous.png b/examples/quick/demos/tweetsearch/content/resources/anonymous.png
deleted file mode 100644
index 88fba26e90..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/anonymous.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png b/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png
deleted file mode 100644
index 4e8d7e6116..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-clear.png b/examples/quick/demos/tweetsearch/content/resources/icon-clear.png
deleted file mode 100644
index 75672f64c7..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/icon-clear.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-loading.png b/examples/quick/demos/tweetsearch/content/resources/icon-loading.png
deleted file mode 100644
index 8dbff8b70f..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/icon-loading.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png b/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png
deleted file mode 100644
index b639a638fe..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-search.png b/examples/quick/demos/tweetsearch/content/resources/icon-search.png
deleted file mode 100644
index e41935a6c1..0000000000
--- a/examples/quick/demos/tweetsearch/content/resources/icon-search.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/tweetsearch.js b/examples/quick/demos/tweetsearch/content/tweetsearch.js
deleted file mode 100644
index 42a76c99fc..0000000000
--- a/examples/quick/demos/tweetsearch/content/tweetsearch.js
+++ /dev/null
@@ -1,62 +0,0 @@
-.pragma library
-
-function formatDate(date)
-{
- var da = new Date(date)
- return da.toDateString()
-}
-
-function demoToken()
-{
- var a = new Array(22).join('A')
- return a + String.fromCharCode(0x44, 0x69, 0x4a, 0x52, 0x51, 0x41, 0x41, 0x41, 0x41,
- 0x41, 0x41, 0x74, 0x2b, 0x72, 0x6a, 0x6c, 0x2b, 0x71,
- 0x6d, 0x7a, 0x30, 0x72, 0x63, 0x79, 0x2b, 0x42, 0x62,
- 0x75, 0x58, 0x42, 0x42, 0x73, 0x72, 0x55, 0x48, 0x47,
- 0x45, 0x67, 0x3d, 0x71, 0x30, 0x45, 0x4b, 0x32, 0x61,
- 0x57, 0x71, 0x51, 0x4d, 0x62, 0x31, 0x35, 0x67, 0x43,
- 0x5a, 0x4e, 0x77, 0x5a, 0x6f, 0x39, 0x79, 0x71, 0x61,
- 0x65, 0x30, 0x68, 0x70, 0x65, 0x32, 0x46, 0x44, 0x73,
- 0x53, 0x39, 0x32, 0x57, 0x41, 0x75, 0x30, 0x67)
-}
-
-function linkForEntity(entity)
-{
- return (entity.url ? entity.url :
- (entity.screen_name ? 'https://twitter.com/' + entity.screen_name :
- 'https://twitter.com/search?q=%23' + entity.text))
-}
-
-function textForEntity(entity)
-{
- return (entity.display_url ? entity.display_url :
- (entity.screen_name ? entity.screen_name : entity.text))
-}
-
-function insertLinks(text, entities)
-{
- if (typeof text !== 'string')
- return "";
-
- if (!entities)
- return text;
-
- // Add all links (urls, usernames and hashtags) to an array and sort them in
- // descending order of appearance in text
- var links = []
- if (entities.urls)
- links = entities.urls.concat(entities.hashtags, entities.user_mentions)
- else if (entities.url)
- links = entities.url.urls
-
- links.sort(function(a, b) { return b.indices[0] - a.indices[0] })
-
- for (var i = 0; i < links.length; i++) {
- var offset = links[i].url ? 0 : 1
- text = text.substring(0, links[i].indices[0] + offset) +
- '<a href=\"' + linkForEntity(links[i]) + '\">' +
- textForEntity(links[i]) + '</a>' +
- text.substring(links[i].indices[1])
- }
- return text.replace(/\n/g, '<br>');
-}
diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png
deleted file mode 100644
index 14ac8a1751..0000000000
--- a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png
deleted file mode 100644
index 9eff191a47..0000000000
--- a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
deleted file mode 100644
index 4145ccfc14..0000000000
--- a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \title Qt Quick Demo - Tweet Search
- \ingroup qtquickdemos
- \example demos/tweetsearch
- \brief A Twitter search client with 3D effects.
- \image qtquick-demo-tweetsearch-med-1.png
- \image qtquick-demo-tweetsearch-med-2.png
-
- \e{Tweet Search} is a QML application that searches items posted to Twitter
- service using a number of query parameters. Search can be done for tweets
- from a specified user, a hashtag, or a search phrase.
-
- The search result is a list of items showing the contents of the
- tweet as well as the name and image of the user who posted it.
- Hashtags, names and links in the content are clickable. Clicking
- on the image will flip the item to reveal more information.
-
- \include examples-run.qdocinc
-
- Tweet Search uses Twitter API v1.1 for running seaches.
-
- \section1 Request Authentication
-
- Each request must be authenticated on behalf of the application.
- For demonstration purposes, the application uses a hard-coded
- token for identifying itself to the Twitter service. However, this
- token is subject to rate limits for the number of requests as well
- as possible expiration.
-
- If you are having authentication or rate limit problems running the
- demo, obtain a set of application-specific tokens (consumer
- key and consumer secret) by registering a new application on
- \l{https://dev.twitter.com/apps}.
-
- Type in the two token values in \e {TweetsModel.qml}:
-
- \snippet demos/tweetsearch/content/TweetsModel.qml auth tokens
-
- Rebuild and run the demo.
-
- \section1 JSON Parsing
-
- Search results are returned in JSON (JavaScript Object Notation)
- format. \c TweetsModel uses an \l XMLHTTPRequest object to send
- an HTTP GET request, and calls JSON.parse() on the returned text
- string to convert it to a JavaScript object. Each object
- representing a tweet is then added to a \l ListModel:
-
- \snippet demos/tweetsearch/content/TweetsModel.qml requesting
-
- \sa {QML Applications}
-*/
diff --git a/examples/quick/demos/tweetsearch/main.cpp b/examples/quick/demos/tweetsearch/main.cpp
deleted file mode 100644
index fe612eaa1e..0000000000
--- a/examples/quick/demos/tweetsearch/main.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(demos/tweetsearch/tweetsearch)
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.pro b/examples/quick/demos/tweetsearch/tweetsearch.pro
deleted file mode 100644
index 27c34bac5d..0000000000
--- a/examples/quick/demos/tweetsearch/tweetsearch.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-
-QT += quick qml
-SOURCES += main.cpp
-RESOURCES += tweetsearch.qrc
-
-OTHER_FILES = tweetsearch.qml \
- content/*.qml \
- content/*.js \
- content/resources/*
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch
-INSTALLS += target
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qml b/examples/quick/demos/tweetsearch/tweetsearch.qml
deleted file mode 100644
index 40e258d79e..0000000000
--- a/examples/quick/demos/tweetsearch/tweetsearch.qml
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content"
-import "content/tweetsearch.js" as Helper
-
-Rectangle {
- id: main
- width: 320
- height: 480
- color: "#d6d6d6"
-
- property int inAnimDur: 250
- property int counter: 0
- property alias isLoading: tweetsModel.isLoading
- property var idx
- property var ids
-
- Component.onCompleted: ids = new Array()
-
- function idInModel(id)
- {
- for (var j = 0; j < ids.length; j++)
- if (ids[j] === id)
- return 1
- return 0
- }
-
- TweetsModel {
- id: tweetsModel
- onIsLoaded: {
- console.debug("Reload")
- idx = new Array()
- for (var i = 0; i < tweetsModel.model.count; i++) {
- var id = tweetsModel.model.get(i).id
- if (!idInModel(id))
- idx.push(i)
- }
- console.debug(idx.length + " new tweets")
- main.counter = idx.length
- }
- }
-
- Timer {
- id: timer
- interval: 500; running: main.counter; repeat: true
- onTriggered: {
- main.counter--;
- var id = tweetsModel.model.get(idx[main.counter]).id
- var item = tweetsModel.model.get(main.counter)
- mainListView.add( { "statusText": Helper.insertLinks(item.text, item.entities),
- "twitterName": item.user.screen_name,
- "name" : item.user.name,
- "userImage": item.user.profile_image_url,
- "source": item.source,
- "id": id,
- "uri": Helper.insertLinks(item.user.url, item.user.entities),
- "published": item.created_at } );
- ids.push(id)
- }
- }
-
- ListView {
- id: mainListView
- anchors.fill: parent
- delegate: TweetDelegate { }
- model: ListModel { id: finalModel }
-
- add: Transition {
- NumberAnimation { property: "hm"; from: 0; to: 1.0; duration: 300; easing.type: Easing.OutQuad }
- PropertyAction { property: "appear"; value: 250 }
- }
-
- onDragEnded: if (header.refresh) { tweetsModel.reload() }
-
- ListHeader {
- id: header
- y: -mainListView.contentY - height
- }
-
- footer: ListFooter { }
-
- function clear() {
- ids = new Array()
- model.clear()
- }
-
- function add(obj) {
- model.insert(0, obj)
- }
-
- signal autoSearch(string type, string str) // To communicate with Footer instance
- }
-}
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qmlproject b/examples/quick/demos/tweetsearch/tweetsearch.qmlproject
deleted file mode 100644
index 5a0f31117b..0000000000
--- a/examples/quick/demos/tweetsearch/tweetsearch.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.1
-
-Project {
- mainFile: "tweetsearch.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qrc b/examples/quick/demos/tweetsearch/tweetsearch.qrc
deleted file mode 100644
index b23c3c5537..0000000000
--- a/examples/quick/demos/tweetsearch/tweetsearch.qrc
+++ /dev/null
@@ -1,19 +0,0 @@
-<RCC>
- <qresource prefix="/demos/tweetsearch">
- <file>tweetsearch.qml</file>
- <file>content/FlipBar.qml</file>
- <file>content/LineInput.qml</file>
- <file>content/ListFooter.qml</file>
- <file>content/ListHeader.qml</file>
- <file>content/SearchDelegate.qml</file>
- <file>content/TweetDelegate.qml</file>
- <file>content/tweetsearch.js</file>
- <file>content/TweetsModel.qml</file>
- <file>content/resources/anonymous.png</file>
- <file>content/resources/bird-anim-sprites.png</file>
- <file>content/resources/icon-clear.png</file>
- <file>content/resources/icon-loading.png</file>
- <file>content/resources/icon-refresh.png</file>
- <file>content/resources/icon-search.png</file>
- </qresource>
-</RCC>
diff --git a/examples/quick/draganddrop/views/gridview.qml b/examples/quick/draganddrop/views/gridview.qml
index d436b19832..6c5bcef729 100644
--- a/examples/quick/draganddrop/views/gridview.qml
+++ b/examples/quick/draganddrop/views/gridview.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
import QtQml.Models 2.1
GridView {
@@ -92,26 +92,38 @@ GridView {
ListElement { color: "teal" }
}
//! [1]
- delegate: MouseArea {
+ delegate: DropArea {
id: delegateRoot
- property int visualIndex: DelegateModel.itemsIndex
-
width: 80; height: 80
- drag.target: icon
+
+ onEntered: visualModel.items.move(drag.source.visualIndex, icon.visualIndex)
+ property int visualIndex: DelegateModel.itemsIndex
+ Binding { target: icon; property: "visualIndex"; value: visualIndex }
Rectangle {
id: icon
+ property int visualIndex: 0
width: 72; height: 72
anchors {
horizontalCenter: parent.horizontalCenter;
verticalCenter: parent.verticalCenter
}
- color: model.color
radius: 3
+ color: model.color
+
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ text: parent.visualIndex
+ }
+
+ DragHandler {
+ id: dragHandler
+ }
- Drag.active: delegateRoot.drag.active
- Drag.source: delegateRoot
+ Drag.active: dragHandler.active
+ Drag.source: icon
Drag.hotSpot.x: 36
Drag.hotSpot.y: 36
@@ -124,19 +136,13 @@ GridView {
}
AnchorChanges {
- target: icon;
- anchors.horizontalCenter: undefined;
+ target: icon
+ anchors.horizontalCenter: undefined
anchors.verticalCenter: undefined
}
}
]
}
-
- DropArea {
- anchors { fill: parent; margins: 15 }
-
- onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex)
- }
}
//! [1]
}
diff --git a/examples/quick/imageelements/animatedimage.qml b/examples/quick/imageelements/animatedimage.qml
index 0a119d0aba..04bc38fe95 100644
--- a/examples/quick/imageelements/animatedimage.qml
+++ b/examples/quick/imageelements/animatedimage.qml
@@ -47,8 +47,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.11
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "../shared" as Examples
Column {
diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro
index ef51d98d44..0bb90e737b 100644
--- a/examples/quick/quick.pro
+++ b/examples/quick/quick.pro
@@ -10,6 +10,7 @@ SUBDIRS = quick-accessibility \
localstorage \
models \
views \
+ tableview \
mousearea \
positioners \
righttoleft \
@@ -24,8 +25,8 @@ SUBDIRS = quick-accessibility \
imageresponseprovider \
window \
particles \
- shapes \
- demos
+ delegatechooser \
+ shapes
#OpenGL Support Required
qtConfig(opengl(es1|es2)?) {
diff --git a/examples/quick/shapes/content/tapableTriangle.qml b/examples/quick/shapes/content/tapableTriangle.qml
index be48e23876..22ed577bcb 100644
--- a/examples/quick/shapes/content/tapableTriangle.qml
+++ b/examples/quick/shapes/content/tapableTriangle.qml
@@ -48,9 +48,8 @@
**
****************************************************************************/
-import QtQuick 2.11
-import QtQuick.Shapes 1.11
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
+import QtQuick.Shapes 1.12
Rectangle {
width: 120
diff --git a/examples/quick/shapes/content/tiger.qml b/examples/quick/shapes/content/tiger.qml
index 7fa6ca2706..317ec88b31 100644
--- a/examples/quick/shapes/content/tiger.qml
+++ b/examples/quick/shapes/content/tiger.qml
@@ -48,9 +48,8 @@
**
****************************************************************************/
-import QtQuick 2.11
-import QtQuick.Shapes 1.11
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
+import QtQuick.Shapes 1.12
Shape {
asynchronous: true
diff --git a/examples/quick/tableview/gameoflife/doc/images/gameoflife.png b/examples/quick/tableview/gameoflife/doc/images/gameoflife.png
new file mode 100644
index 0000000000..252dda2e11
--- /dev/null
+++ b/examples/quick/tableview/gameoflife/doc/images/gameoflife.png
Binary files differ
diff --git a/examples/quick/tableview/gameoflife/doc/src/gameoflife.qdoc b/examples/quick/tableview/gameoflife/doc/src/gameoflife.qdoc
new file mode 100644
index 0000000000..b2391d43ba
--- /dev/null
+++ b/examples/quick/tableview/gameoflife/doc/src/gameoflife.qdoc
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \title Qt Quick TableView examples - Conway’s Game of Life
+ \example gameoflife
+ \brief The \e{Conway’s Game of Life} example shows how the QML TableView
+ type can be used to display a C++ model that the user can pan around.
+
+ \image gameoflife.png
+ \ingroup qtquickexamples
+
+ \include examples-run.qdocinc
+
+ \section1 The QML User Interface
+
+ \snippet tableview/gameoflife/main.qml tableview
+ The example uses the TableView component to display a grid of cells. Each
+ of these cells is drawn on the screen by the TableView’s delegate, which is
+ a Rectangle QML component. We read the cell’s value and we change it
+ using \c{model.value} when the user clicks it.
+
+ \snippet tableview/gameoflife/main.qml scroll
+ When the application starts, the TableView is scrolled to its center
+ by using its \c{contentX} and \c{contentY} properties to update the scroll
+ position, and the \c{contentWidth} and \c{contentHeight} to compute where
+ the view should be scrolled to.
+
+ \snippet tableview/gameoflife/main.qml model
+ The model that we use is a custom C++ class that we register
+ in the QML system:
+ \snippet tableview/gameoflife/main.cpp registertype
+
+ \section1 The C++ Model
+
+ \snippet tableview/gameoflife/gameoflifemodel.h modelclass
+ The \c{GameOfLifeModel} class extends QAbstractTableModel so it can be
+ used as the model of our TableView component. Therefore, it needs to
+ implement some functions so the TableView component can interact with
+ the model. As you can see in the \c private part of the class, the model
+ uses a fixed-size array to store the current state of all the cells.
+
+ \snippet tableview/gameoflife/gameoflifemodel.cpp modelsize
+ Here, the \c rowCount and \c columnCount methods are implemented so
+ the TableView component can know the size of the table. It simply returns
+ the values of the \c width and \c height constants.
+
+ \snippet tableview/gameoflife/gameoflifemodel.cpp read
+ This method is called when the TableView component requests some data from
+ the model. In our example, we only have one piece of data by cell: whether
+ it is alive or not. This information is represented by the \c CellRole value
+ of the \c Roles enum in our C++ code; this corresponds to the \c value
+ property in the QML code (the link between these two is made by the
+ \c{roleNames()} function of our C++ class).
+
+ The \c GameOfLifeModel class can identify which cell was the data requested
+ from with the \c index parameter, which is a QModelIndex that contains
+ a row and a column.
+
+ \section1 Updating the Data
+
+ \snippet tableview/gameoflife/gameoflifemodel.cpp write
+ The \c setData method is called when a property’s value is set from the
+ QML interface: in our example, it toggles a cell’s state when it is clicked.
+ In the same way as the \c{data()} function does, this method receives an
+ \c index and a \c role parameter. Additionally, the new value is passed
+ as a QVariant, that we convert to a boolean using the \c toBool function.
+
+ When we update the internal state of our model object, we need to emit a
+ \c dataChanged signal to tell the TableView component that it needs to update the
+ displayed data. In this case, only the cell that was clicked is affected, thus
+ the range of the table that has to be updated begins and ends at the cell’s index.
+
+ \snippet tableview/gameoflife/gameoflifemodel.cpp update
+ This function can be called directly from the QML code, because it contains the
+ Q_INVOKABLE macro in its definition. It plays an iteration of the game, either when
+ the user clicks the \e{Next} button or when the Timer emits a \c{triggered()} signal.
+
+ Following the \e{Conway’s Game of Life} rules, a new state is computed for each
+ cell depending on the current state of its neighbors. When the new state has
+ been computed for the whole grid, it replaces the current state and a
+ \e dataChanged signal is emitted for the whole table.
+
+ \snippet tableview/gameoflife/gameoflifemodel.cpp loader
+ When the application opens, a pattern is loaded to demonstrate how
+ \e{Conway’s Game of Life} works. These two functions load the file where
+ the pattern is stored and parse it. As in the \c nextStep function, a
+ \c dataChanged signal is emitted for the whole table once the pattern
+ has been fully loaded.
+*/
diff --git a/examples/quick/tableview/gameoflife/gameoflife.pro b/examples/quick/tableview/gameoflife/gameoflife.pro
new file mode 100644
index 0000000000..98050b0d79
--- /dev/null
+++ b/examples/quick/tableview/gameoflife/gameoflife.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += \
+ main.cpp \
+ gameoflifemodel.cpp
+
+RESOURCES += \
+ main.qml \
+ gosperglidergun.cells
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/tableview/gameoflife
+INSTALLS += target
+
+HEADERS += \
+ gameoflifemodel.h
diff --git a/examples/quick/tableview/gameoflife/gameoflifemodel.cpp b/examples/quick/tableview/gameoflife/gameoflifemodel.cpp
new file mode 100644
index 0000000000..32765f87a8
--- /dev/null
+++ b/examples/quick/tableview/gameoflife/gameoflifemodel.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "gameoflifemodel.h"
+#include <QFile>
+#include <QTextStream>
+#include <QRect>
+
+GameOfLifeModel::GameOfLifeModel(QObject *parent)
+ : QAbstractTableModel(parent)
+{
+ clear();
+}
+
+//! [modelsize]
+int GameOfLifeModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ return height;
+}
+
+int GameOfLifeModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ return width;
+}
+//! [modelsize]
+
+//! [read]
+QVariant GameOfLifeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || role != CellRole)
+ return QVariant();
+
+ return QVariant(m_currentState[cellIndex({index.column(), index.row()})]);
+}
+//! [read]
+
+//! [write]
+bool GameOfLifeModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (role != CellRole || data(index, role) == value)
+ return false;
+
+ m_currentState[cellIndex({index.column(), index.row()})] = value.toBool();
+ emit dataChanged(index, index, {role});
+
+ return true;
+}
+//! [write]
+
+Qt::ItemFlags GameOfLifeModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::NoItemFlags;
+
+ return Qt::ItemIsEditable;
+}
+
+//! [update]
+void GameOfLifeModel::nextStep()
+{
+ StateContainer newValues;
+
+ for (std::size_t i = 0; i < size; ++i) {
+ bool currentState = m_currentState[i];
+
+ int cellNeighborsCount = this->cellNeighborsCount(cellCoordinatesFromIndex(static_cast<int>(i)));
+
+ newValues[i] = currentState == true
+ ? cellNeighborsCount == 2 || cellNeighborsCount == 3
+ : cellNeighborsCount == 3;
+ }
+
+ m_currentState = std::move(newValues);
+
+ emit dataChanged(index(0, 0), index(height - 1, width - 1), {CellRole});
+}
+//! [update]
+
+//! [loader]
+bool GameOfLifeModel::loadFile(const QString &fileName)
+{
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly))
+ return false;
+
+ QTextStream in(&file);
+ loadPattern(in.readAll());
+
+ return true;
+}
+
+void GameOfLifeModel::loadPattern(const QString &plainText)
+{
+ clear();
+
+ QStringList rows = plainText.split("\n");
+ QSize patternSize(0, rows.count());
+ for (QString row : rows) {
+ if (row.size() > patternSize.width())
+ patternSize.setWidth(row.size());
+ }
+
+ QPoint patternLocation((width - patternSize.width()) / 2, (height - patternSize.height()) / 2);
+
+ for (int y = 0; y < patternSize.height(); ++y) {
+ const QString line = rows[y];
+
+ for (int x = 0; x < line.length(); ++x) {
+ QPoint cellPosition(x + patternLocation.x(), y + patternLocation.y());
+ m_currentState[cellIndex(cellPosition)] = line[x] == 'O';
+ }
+ }
+
+ emit dataChanged(index(0, 0), index(height - 1, width - 1), {CellRole});
+}
+//! [loader]
+
+void GameOfLifeModel::clear()
+{
+ m_currentState.fill(false);
+ emit dataChanged(index(0, 0), index(height - 1, width - 1), {CellRole});
+}
+
+int GameOfLifeModel::cellNeighborsCount(const QPoint &cellCoordinates) const
+{
+ int count = 0;
+
+ for (int x = -1; x <= 1; ++x) {
+ for (int y = -1; y <= 1; ++y) {
+ if (x == 0 && y == 0)
+ continue;
+
+ const QPoint neighborPosition { cellCoordinates.x() + x, cellCoordinates.y() + y };
+ if (!areCellCoordinatesValid(neighborPosition))
+ continue;
+
+ if (m_currentState[cellIndex(neighborPosition)])
+ ++count;
+
+ if (count > 3)
+ return count;
+ }
+ }
+
+ return count;
+}
+
+bool GameOfLifeModel::areCellCoordinatesValid(const QPoint &coordinates)
+{
+ return QRect(0, 0, width, height).contains(coordinates);
+}
+
+QPoint GameOfLifeModel::cellCoordinatesFromIndex(int cellIndex)
+{
+ return {cellIndex % width, cellIndex / width};
+}
+
+std::size_t GameOfLifeModel::cellIndex(const QPoint &coordinates)
+{
+ return std::size_t(coordinates.y() * width + coordinates.x());
+}
diff --git a/examples/quick/views/parallax/content/Smiley.qml b/examples/quick/tableview/gameoflife/gameoflifemodel.h
index 63c3d1cd90..3ea1469861 100644
--- a/examples/quick/views/parallax/content/Smiley.qml
+++ b/examples/quick/tableview/gameoflife/gameoflifemodel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,47 +48,59 @@
**
****************************************************************************/
-import QtQuick 2.0
+#ifndef GAMEOFLIFEMODEL_H
+#define GAMEOFLIFEMODEL_H
-// This is taken from the declarative animation/basics/property-animation.qml
-// example
+#include <array>
+#include <QAbstractTableModel>
+#include <QPoint>
-Item {
- id: window
- width: 320; height: 480
+//! [modelclass]
+class GameOfLifeModel : public QAbstractTableModel
+{
+ Q_OBJECT
- Image {
- anchors.horizontalCenter: parent.horizontalCenter
- y: smiley.minHeight + 58
- source: "pics/shadow.png"
+ Q_ENUMS(Roles)
+public:
+ enum Roles {
+ CellRole
+ };
- scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ QHash<int, QByteArray> roleNames() const override {
+ return {
+ { CellRole, "value" }
+ };
}
- Image {
- id: smiley
- property int maxHeight: window.height / 3
- property int minHeight: 2 * window.height / 3
+ explicit GameOfLifeModel(QObject *parent = nullptr);
- anchors.horizontalCenter: parent.horizontalCenter
- y: minHeight
- source: "pics/face-smile.png"
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
- SequentialAnimation on y {
- loops: Animation.Infinite
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole) override;
- NumberAnimation {
- from: smiley.minHeight; to: smiley.maxHeight
- easing.type: Easing.OutExpo; duration: 300
- }
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
- NumberAnimation {
- from: smiley.maxHeight; to: smiley.minHeight
- easing.type: Easing.OutBounce; duration: 1000
- }
+ Q_INVOKABLE void nextStep();
+ Q_INVOKABLE bool loadFile(const QString &fileName);
+ Q_INVOKABLE void loadPattern(const QString &plainText);
+ Q_INVOKABLE void clear();
- PauseAnimation { duration: 500 }
- }
- }
-}
+private:
+ static constexpr int width = 256;
+ static constexpr int height = 256;
+ static constexpr int size = width * height;
+
+ using StateContainer = std::array<bool, size>;
+ StateContainer m_currentState;
+
+ int cellNeighborsCount(const QPoint &cellCoordinates) const;
+ static bool areCellCoordinatesValid(const QPoint &coordinates);
+ static QPoint cellCoordinatesFromIndex(int cellIndex);
+ static std::size_t cellIndex(const QPoint &coordinates);
+};
+//! [modelclass]
+#endif // GAMEOFLIFEMODEL_H
diff --git a/examples/quick/tableview/gameoflife/gosperglidergun.cells b/examples/quick/tableview/gameoflife/gosperglidergun.cells
new file mode 100644
index 0000000000..50aaadf3d5
--- /dev/null
+++ b/examples/quick/tableview/gameoflife/gosperglidergun.cells
@@ -0,0 +1,9 @@
+........................O
+......................O.O
+............OO......OO............OO
+...........O...O....OO............OO
+OO........O.....O...OO
+OO........O...O.OO....O.O
+..........O.....O.......O
+...........O...O
+............OO
diff --git a/examples/quick/demos/samegame/content/Settings.qml b/examples/quick/tableview/gameoflife/main.cpp
index 2892198b27..5101880b06 100644
--- a/examples/quick/demos/samegame/content/Settings.qml
+++ b/examples/quick/tableview/gameoflife/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,23 +48,23 @@
**
****************************************************************************/
-pragma Singleton
-import QtQml 2.0
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <gameoflifemodel.h>
-QtObject {
- property int screenHeight: 480
- property int screenWidth: 320
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+ QQmlApplicationEngine engine;
- property int menuDelay: 500
+ //! [registertype]
+ qmlRegisterType<GameOfLifeModel>("GameOfLifeModel", 1, 0, "GameOfLifeModel");
+ //! [registertype]
- property int headerHeight: 20 // 70 on BB10
- property int footerHeight: 44 // 100 on BB10
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
- property int fontPixelSize: 14 // 55 on BB10
-
- property int blockSize: 32 // 64 on BB10
-
- property int toolButtonHeight: 32 // 64 on BB10
-
- property int menuButtonSpacing: 0 // 15 on BB10
+ return app.exec();
}
diff --git a/examples/quick/views/parallax/content/ParallaxView.qml b/examples/quick/tableview/gameoflife/main.qml
index 0d289669f2..90be69b9c0 100644
--- a/examples/quick/views/parallax/content/ParallaxView.qml
+++ b/examples/quick/tableview/gameoflife/main.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,86 +48,107 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtQml.Models 2.1
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import GameOfLifeModel 1.0
-Item {
+ApplicationWindow {
id: root
+ visible: true
+ width: 760
+ height: 810
+ minimumWidth: 475
+ minimumHeight: 300
+
+ color: "#09102B"
+ title: qsTr("Conway’s Game of Life")
+
+ //! [tableview]
+ TableView {
+ id: tableView
+ anchors.fill: parent
- property alias background: background.source
- property int currentIndex: 0
- default property alias content: visualModel.children
+ rowSpacing: 1
+ columnSpacing: 1
- Image {
- id: background
- fillMode: Image.TileHorizontally
- x: -list.contentX / 2
- width: Math.max(list.contentWidth, parent.width)
- }
+ ScrollBar.horizontal: ScrollBar {}
+ ScrollBar.vertical: ScrollBar {}
- ListView {
- id: list
- anchors.fill: parent
+ delegate: Rectangle {
+ id: cell
+ implicitWidth: 15
+ implicitHeight: 15
- currentIndex: root.currentIndex
- onCurrentIndexChanged: root.currentIndex = currentIndex
+ color: model.value ? "#f3f3f4" : "#b5b7bf"
- orientation: Qt.Horizontal
- boundsBehavior: Flickable.DragOverBounds
- model: ObjectModel { id: visualModel }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: model.value = !model.value
+ }
+ }
+ //! [tableview]
+
+ //! [model]
+ model: GameOfLifeModel {
+ id: gameOfLifeModel
+ }
+ //! [model]
- highlightRangeMode: ListView.StrictlyEnforceRange
- snapMode: ListView.SnapOneItem
+ //! [scroll]
+ contentX: (contentWidth - width) / 2;
+ contentY: (contentHeight - height) / 2;
+ //! [scroll]
}
- ListView {
- id: selector
+ footer: Rectangle {
+ signal nextStep
+ id: footer
height: 50
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.min(count * 50, parent.width - 20)
- interactive: width == parent.width - 20
- orientation: Qt.Horizontal
-
- currentIndex: root.currentIndex
- onCurrentIndexChanged: root.currentIndex = currentIndex
-
- model: visualModel.children
- delegate: Item {
- width: 50; height: 50
- id: delegateRoot
-
- Image {
- id: image
- source: modelData.icon
- scale: 0.8
+ color: "#F3F3F4"
+
+ RowLayout {
+ anchors.centerIn: parent
+
+ //! [next]
+ Button {
+ text: qsTr("Next")
+ onClicked: gameOfLifeModel.nextStep()
}
+ //! [next]
- MouseArea {
- anchors.fill: parent
- onClicked: { root.currentIndex = index }
+ Item {
+ width: 50
}
- states: State {
- name: "Selected"
- when: delegateRoot.ListView.isCurrentItem == true
- PropertyChanges {
- target: image
- scale: 1
- y: -5
- }
+ Slider {
+ id: slider
+ x: 245
+ y: 17
+ from: 0
+ to: 1
+ value: 0.9
}
- transitions: Transition {
- NumberAnimation { properties: "scale,y" }
+
+ Button {
+ text: timer.running ? "❙❙" : "▶️"
+ onClicked: timer.running = !timer.running
}
}
- Rectangle {
- color: "#60FFFFFF"
- x: -10; y: -10; z: -1
- width: parent.width + 20; height: parent.height + 20
- radius: 10
+ Timer {
+ id: timer
+ interval: 1000 - (980 * slider.value)
+ running: true
+ repeat: true
+
+ onTriggered: gameOfLifeModel.nextStep()
}
}
+
+ Component.onCompleted: {
+ gameOfLifeModel.loadFile(":/gosperglidergun.cells");
+ }
}
diff --git a/examples/quick/tableview/pixelator/doc/images/qt-pixelator.png b/examples/quick/tableview/pixelator/doc/images/qt-pixelator.png
new file mode 100644
index 0000000000..a6c4a3b40b
--- /dev/null
+++ b/examples/quick/tableview/pixelator/doc/images/qt-pixelator.png
Binary files differ
diff --git a/examples/quick/tableview/pixelator/doc/src/pixelator.qdoc b/examples/quick/tableview/pixelator/doc/src/pixelator.qdoc
new file mode 100644
index 0000000000..4f8d519060
--- /dev/null
+++ b/examples/quick/tableview/pixelator/doc/src/pixelator.qdoc
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \title Qt Quick TableViews examples - Pixelator
+ \example pixelator
+ \brief The Pixelator example shows how a QML TableView and a delegate
+ can be used for custom table models.
+
+ \image qt-pixelator.png
+ \ingroup qtquickexamples
+
+ \include examples-run.qdocinc
+
+ \snippet pixelator/imagemodel.h model
+
+ We only require a simple, read-only table model. Thus, we need to implement
+ functions to indicate the dimensions of the image and supply data to the
+ TableView.
+ We use the \l{Qt property system}{Qt Property System} and a source property
+ as \c QString to set the path of the image.
+
+ \snippet pixelator/imagemodel.cpp setsource
+
+ Here we load the image when the source path is set.
+ When the source path has changed, we need to call \c beginResetModel() before.
+ After the image has been loaded, we need to call \c endResetModel().
+
+ \snippet pixelator/imagemodel.cpp rowcolcount
+
+ The row and column count is set to image height and width, respectively.
+
+ \snippet pixelator/imagemodel.cpp data
+
+ This overloaded function allows us to access the pixel data from the image.
+ When we call this function with the display role, we return the pixel's
+ gray value.
+
+ \snippet pixelator/main.cpp registertype
+
+ We need to register our model in the QML type system to be able to use it
+ from the QML side.
+
+ \snippet pixelator/main.qml pixelcomponent
+
+ Each pixel in the \c TableView is displayed via a delegate component.
+ It contains an item that has an implicit height and width defining the
+ cell size of the table.
+ It also has a property for the gray value of the pixel that is retrieved
+ from the model.
+
+ \snippet pixelator/main.qml rectshape
+
+ Inside the \c Item, there is a rounded \c Rectangle with the size and
+ radius according to the pixel's gray value.
+
+ \snippet pixelator/main.qml interaction
+
+ For a little bit of interaction, we place a \c MouseArea inside the \c Item
+ and change the Rectangle's color on mouse over.
+
+ \snippet pixelator/main.qml animation
+
+ The \c Rectangle also has a short color animation to fade between the
+ colors when it is changed.
+
+ \snippet pixelator/main.qml tableview
+
+ The \c TableView spans over the whole window and has an instance of our
+ custom \c ImageModel attached.
+
+*/
diff --git a/examples/quick/demos/rssnews/content/CategoryDelegate.qml b/examples/quick/tableview/pixelator/imagemodel.cpp
index c76bc78aca..827204bc06 100644
--- a/examples/quick/demos/rssnews/content/CategoryDelegate.qml
+++ b/examples/quick/tableview/pixelator/imagemodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,52 +48,61 @@
**
****************************************************************************/
-import QtQuick 2.2
+#include "imagemodel.h"
-Rectangle {
- id: delegate
+ImageModel::ImageModel(QObject *parent)
+ : QAbstractTableModel(parent)
+{
+}
- property bool selected: ListView.isCurrentItem
- property real itemSize
- width: itemSize
- height: itemSize
+QString ImageModel::source() const
+{
+ return m_source;
+}
- Image {
- anchors.centerIn: parent
- source: image
- }
+//! [setsource]
+void ImageModel::setSource(const QString &source)
+{
+ if (m_source == source)
+ return;
- Text {
- id: titleText
+ beginResetModel();
+ m_source = source;
+ m_image.load(m_source);
+ endResetModel();
+}
+//! [setsource]
- anchors {
- left: parent.left; leftMargin: 20
- right: parent.right; rightMargin: 20
- top: parent.top; topMargin: 20
- }
+//! [rowcolcount]
+int ImageModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ return m_image.height();
+}
+
+int ImageModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ return m_image.width();
+}
+//! [rowcolcount]
- font { pixelSize: 18; bold: true }
- text: name
- color: selected ? "#ffffff" : "#ebebdd"
- scale: selected ? 1.15 : 1.0
- Behavior on color { ColorAnimation { duration: 150 } }
- Behavior on scale { PropertyAnimation { duration: 300 } }
- }
- BusyIndicator {
- scale: 0.8
- visible: delegate.ListView.isCurrentItem && window.loading
- anchors.centerIn: parent
- }
+//! [data]
+QVariant ImageModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || role != Qt::DisplayRole)
+ return QVariant();
+ return qGray(m_image.pixel(index.column(), index.row()));
+}
+//! [data]
- MouseArea {
- anchors.fill: delegate
- onClicked: {
- delegate.ListView.view.currentIndex = index
- if (window.currentFeed == feed)
- feedModel.reload()
- else
- window.currentFeed = feed
- }
- }
+QVariant ImageModel::headerData(int /* section */, Qt::Orientation /* orientation */,
+ int role) const
+{
+ if (role == Qt::SizeHintRole)
+ return QSize(1, 1);
+ return QVariant();
}
diff --git a/examples/quick/demos/maroon/content/towers/Melee.qml b/examples/quick/tableview/pixelator/imagemodel.h
index f83bd4c525..bf0ec90da4 100644
--- a/examples/quick/demos/maroon/content/towers/Melee.qml
+++ b/examples/quick/tableview/pixelator/imagemodel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,46 +48,38 @@
**
****************************************************************************/
-import QtQuick 2.0
-import ".."
+#ifndef IMAGEMODEL_H
+#define IMAGEMODEL_H
-TowerBase {
- hp: 4
- range: 0.1
- damage: 1
- rof: 40
- income: 0
+#include <QAbstractTableModel>
+#include <QImage>
- SpriteSequence {
- id: sprite
- width: 64
- height: 64
- interpolate: false
- goalSprite: ""
+//! [model]
+class ImageModel : public QAbstractTableModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
+public:
+ ImageModel(QObject *parent = nullptr);
- Sprite {
- name: "idle"
- source: "../gfx/melee-idle.png"
- frameCount: 8
- frameDuration: 250
- }
+ QString source() const;
+ void setSource(const QString &source);
- Sprite {
- name: "shoot"
- source: "../gfx/melee-action.png"
- frameCount: 2
- frameDuration: 200
- to: { "idle" : 1 }
- }
- }
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
- function fire() {
- shootSound.play()
- sprite.jumpTo("shoot")
- }
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
- SoundEffect {
- id: shootSound
- source: "../audio/melee-action.wav"
- }
-}
+ QVariant headerData(int /* section */, Qt::Orientation /* orientation */,
+ int role) const override;
+
+signals:
+ void sourceChanged();
+
+private:
+ QString m_source;
+ QImage m_image;
+};
+//! [model]
+
+#endif // IMAGEMODEL_H
diff --git a/examples/quick/demos/photoviewer/main.cpp b/examples/quick/tableview/pixelator/main.cpp
index 6276bd61a5..c57039556a 100644
--- a/examples/quick/demos/photoviewer/main.cpp
+++ b/examples/quick/tableview/pixelator/main.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtQml module of the Qt Toolkit.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -50,19 +50,22 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
-#include <QTranslator>
-#include <QDebug>
+
+#include "imagemodel.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- QTranslator qtTranslator;
- qtTranslator.load(QLocale(), "qml", "_", ":/i18n/");
- app.installTranslator(&qtTranslator);
-
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
+
+ //! [registertype]
+ qmlRegisterType<ImageModel>("ImageModel", 1, 0, "ImageModel");
+ //! [registertype]
+
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
return app.exec();
}
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/tableview/pixelator/main.qml
index 1657003e53..38a25f439f 100644
--- a/examples/quick/demos/stocqt/stocqt.qml
+++ b/examples/quick/tableview/pixelator/main.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,63 +48,70 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtQml.Models 2.1
-import QtQuick.Layouts 1.1
-import "./content"
+import QtQuick 2.12
-Rectangle {
- id: mainRect
- width: 1000
- height: 700
+import QtQuick.Window 2.12
- property alias currentIndex: root.currentIndex
+import ImageModel 1.0
- ColumnLayout {
- anchors.fill: parent
+Window {
+ visible: true
+ width: 900
+ height: 900
+ title: qsTr("TableView Pixelator")
- Banner {
- id: banner
- Layout.fillWidth: true
- }
+ //! [pixelcomponent]
+ Component {
+ id: pixelDelegate
- ListView {
- id: root
- Layout.fillHeight: true
- Layout.fillWidth: true
- snapMode: ListView.SnapOneItem
- highlightRangeMode: ListView.StrictlyEnforceRange
- highlightMoveDuration: 250
- focus: false
- orientation: ListView.Horizontal
- boundsBehavior: Flickable.StopAtBounds
+ Item {
+ readonly property real gray: model.display / 255.0
+ readonly property real size: 16
- StockModel {
- id: stock
- stockId: listView.currentStockId
- stockName: listView.currentStockName
- onStockIdChanged: stock.updateStock();
- onDataReady: {
- root.currentIndex = 1
- stockView.update()
- }
- }
+ implicitWidth: size
+ implicitHeight: size
+ //! [pixelcomponent]
- model: ObjectModel {
- StockListView {
- id: listView
- width: root.width
- height: root.height
- }
+ //! [rectshape]
+ Rectangle {
+ id: rect
+ anchors.centerIn: parent
+ color: "#09102b"
+ radius: size - gray * size
+ implicitWidth: radius
+ implicitHeight: radius
+ //! [rectshape]
- StockView {
- id: stockView
- width: root.width
- height: root.height
- stocklist: listView
- stock: stock
+ //! [animation]
+ ColorAnimation on color {
+ id: colorAnimation
+ running: false
+ to: "#41cd52"
+ duration: 1500
}
+ //! [animation]
+ }
+
+ //! [interaction]
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: rect.color = "#cecfd5"
+ onExited: colorAnimation.start()
}
+ //! [interaction]
+ }
+ }
+
+ //! [tableview]
+ TableView {
+ id: tableView
+ anchors.fill: parent
+ model: ImageModel {
+ source: ":/qt.png"
}
+
+ delegate: pixelDelegate
}
+ //! [tableview]
}
diff --git a/examples/quick/tableview/pixelator/pixelator.pro b/examples/quick/tableview/pixelator/pixelator.pro
new file mode 100644
index 0000000000..6c863cb304
--- /dev/null
+++ b/examples/quick/tableview/pixelator/pixelator.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+
+QT += quick qml
+HEADERS += imagemodel.h
+SOURCES += main.cpp \
+ imagemodel.cpp
+
+RESOURCES += qt.png main.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/tableview/pixelator
+INSTALLS += target
diff --git a/examples/quick/tableview/pixelator/qt.png b/examples/quick/tableview/pixelator/qt.png
new file mode 100644
index 0000000000..e3301c4a02
--- /dev/null
+++ b/examples/quick/tableview/pixelator/qt.png
Binary files differ
diff --git a/examples/quick/tableview/tableview.pro b/examples/quick/tableview/tableview.pro
new file mode 100644
index 0000000000..4177ef91fb
--- /dev/null
+++ b/examples/quick/tableview/tableview.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ gameoflife \
+ pixelator
diff --git a/examples/quick/threading/doc/src/threading.qdoc b/examples/quick/threading/doc/src/threading.qdoc
index bbda638f07..f5e5139916 100644
--- a/examples/quick/threading/doc/src/threading.qdoc
+++ b/examples/quick/threading/doc/src/threading.qdoc
@@ -45,7 +45,7 @@
Inside the worker thread, the ListModel is synchronized once the data is
finished loading:
- \snippet threading/threadedlistmodel/dataloader.js 0
+ \snippet threading/threadedlistmodel/dataloader.mjs 0
\section1 WorkerScript
@@ -60,7 +60,7 @@
\snippet threading/workerscript/workerscript.qml 0
The workerscript then is free to take a really long time to calculate it:
- \snippet threading/workerscript/workerscript.js 0
+ \snippet threading/workerscript/workerscript.mjs 0
When it's done, the result returns to the main scene via the WorkerScript
type:
diff --git a/examples/quick/threading/threadedlistmodel/dataloader.js b/examples/quick/threading/threadedlistmodel/dataloader.mjs
index 86a4424dbc..86a4424dbc 100644
--- a/examples/quick/threading/threadedlistmodel/dataloader.js
+++ b/examples/quick/threading/threadedlistmodel/dataloader.mjs
diff --git a/examples/quick/threading/threadedlistmodel/timedisplay.qml b/examples/quick/threading/threadedlistmodel/timedisplay.qml
index cafb1be02e..5ad901c676 100644
--- a/examples/quick/threading/threadedlistmodel/timedisplay.qml
+++ b/examples/quick/threading/threadedlistmodel/timedisplay.qml
@@ -66,7 +66,7 @@ Rectangle {
WorkerScript {
id: worker
- source: "dataloader.js"
+ source: "dataloader.mjs"
}
// ![0]
diff --git a/examples/quick/threading/threading.qrc b/examples/quick/threading/threading.qrc
index 6d15b7ef71..5dc6dff443 100644
--- a/examples/quick/threading/threading.qrc
+++ b/examples/quick/threading/threading.qrc
@@ -2,9 +2,9 @@
<qresource prefix="/threading">
<file>threading.qml</file>
<file>threadedlistmodel/timedisplay.qml</file>
- <file>threadedlistmodel/dataloader.js</file>
+ <file>threadedlistmodel/dataloader.mjs</file>
<file>workerscript/Spinner.qml</file>
- <file>workerscript/workerscript.js</file>
+ <file>workerscript/workerscript.mjs</file>
<file>workerscript/workerscript.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/threading/workerscript/workerscript.js b/examples/quick/threading/workerscript/workerscript.mjs
index 9953958086..9953958086 100644
--- a/examples/quick/threading/workerscript/workerscript.js
+++ b/examples/quick/threading/workerscript/workerscript.mjs
diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml
index 6c279d4a46..735cc8d1f1 100644
--- a/examples/quick/threading/workerscript/workerscript.qml
+++ b/examples/quick/threading/workerscript/workerscript.qml
@@ -56,7 +56,7 @@ Rectangle {
//! [1]
WorkerScript {
id: myWorker
- source: "workerscript.js"
+ source: "workerscript.mjs"
onMessage: {
if (messageObject.row == rowSpinner.value && messageObject.column == columnSpinner.value){ //Not an old result
diff --git a/examples/quick/views/parallax/content/Clock.qml b/examples/quick/views/parallax/content/Clock.qml
deleted file mode 100644
index 542333d13d..0000000000
--- a/examples/quick/views/parallax/content/Clock.qml
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id : clock
- width: {
- if (ListView.view && ListView.view.width >= 200)
- return ListView.view.width / Math.floor(ListView.view.width / 200.0);
- else
- return 200;
- }
-
- height: {
- if (ListView.view && ListView.view.height >= 240)
- return ListView.view.height;
- else
- return 240;
- }
-
- property alias city: cityLabel.text
- property int hours
- property int minutes
- property int seconds
- property real shift
- property bool night: false
- property bool internationalTime: true //Unset for local time
-
- function timeChanged() {
- var date = new Date;
- hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
- night = ( hours < 7 || hours > 19 )
- minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
- seconds = date.getUTCSeconds();
- }
-
- Timer {
- interval: 100; running: true; repeat: true;
- onTriggered: clock.timeChanged()
- }
-
- Item {
- anchors.centerIn: parent
- width: 200; height: 240
-
- Image { id: background; source: "clock.png"; visible: clock.night == false }
- Image { source: "clock-night.png"; visible: clock.night == true }
-
-
- Image {
- x: 92.5; y: 27
- source: "hour.png"
- transform: Rotation {
- id: hourRotation
- origin.x: 7.5; origin.y: 73;
- angle: (clock.hours * 30) + (clock.minutes * 0.5)
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- x: 93.5; y: 17
- source: "minute.png"
- transform: Rotation {
- id: minuteRotation
- origin.x: 6.5; origin.y: 83;
- angle: clock.minutes * 6
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- x: 97.5; y: 20
- source: "second.png"
- transform: Rotation {
- id: secondRotation
- origin.x: 2.5; origin.y: 80;
- angle: clock.seconds * 6
- Behavior on angle {
- SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
- }
- }
- }
-
- Image {
- anchors.centerIn: background; source: "center.png"
- }
-
- Text {
- id: cityLabel
- y: 210; anchors.horizontalCenter: parent.horizontalCenter
- color: "white"
- font.family: "Helvetica"
- font.bold: true; font.pixelSize: 16
- style: Text.Raised; styleColor: "black"
- }
- }
-}
diff --git a/examples/quick/views/parallax/content/QuitButton.qml b/examples/quick/views/parallax/content/QuitButton.qml
deleted file mode 100644
index 8f3b91ce62..0000000000
--- a/examples/quick/views/parallax/content/QuitButton.qml
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-Image {
- source: "quit.png"
- scale: quitMouse.pressed ? 0.8 : 1.0
- smooth: quitMouse.pressed
- MouseArea {
- id: quitMouse
- anchors.fill: parent
- anchors.margins: -10
- onClicked: Qt.quit()
- }
-}
diff --git a/examples/quick/views/parallax/content/background.png b/examples/quick/views/parallax/content/background.png
deleted file mode 100644
index a885950862..0000000000
--- a/examples/quick/views/parallax/content/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/center.png b/examples/quick/views/parallax/content/center.png
deleted file mode 100644
index 7fbd802a44..0000000000
--- a/examples/quick/views/parallax/content/center.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/clock-night.png b/examples/quick/views/parallax/content/clock-night.png
deleted file mode 100644
index cc7151a397..0000000000
--- a/examples/quick/views/parallax/content/clock-night.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/clock.png b/examples/quick/views/parallax/content/clock.png
deleted file mode 100644
index 462edacc0e..0000000000
--- a/examples/quick/views/parallax/content/clock.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/hour.png b/examples/quick/views/parallax/content/hour.png
deleted file mode 100644
index 9f33fc5d48..0000000000
--- a/examples/quick/views/parallax/content/hour.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/minute.png b/examples/quick/views/parallax/content/minute.png
deleted file mode 100644
index e2f216c897..0000000000
--- a/examples/quick/views/parallax/content/minute.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/background.jpg b/examples/quick/views/parallax/content/pics/background.jpg
deleted file mode 100644
index 61cca2f138..0000000000
--- a/examples/quick/views/parallax/content/pics/background.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/face-smile.png b/examples/quick/views/parallax/content/pics/face-smile.png
deleted file mode 100644
index 3d66d72578..0000000000
--- a/examples/quick/views/parallax/content/pics/face-smile.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/home-page.png b/examples/quick/views/parallax/content/pics/home-page.png
deleted file mode 100644
index 01c17b0bbf..0000000000
--- a/examples/quick/views/parallax/content/pics/home-page.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/home-page.svg b/examples/quick/views/parallax/content/pics/home-page.svg
deleted file mode 100644
index 4f16958844..0000000000
--- a/examples/quick/views/parallax/content/pics/home-page.svg
+++ /dev/null
@@ -1,445 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="48"
- height="48"
- overflow="visible"
- enable-background="new 0 0 128 129.396"
- xml:space="preserve"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- sodipodi:docname="go-home.svg"
- sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions"
- version="1.0"
- inkscape:export-filename="/home/tigert/My Downloads/go-home.png"
- inkscape:export-xdpi="90.000000"
- inkscape:export-ydpi="90.000000"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
- id="metadata367"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><cc:license
- rdf:resource="http://creativecommons.org/licenses/publicdomain/" /><dc:title>Go Home</dc:title><dc:creator><cc:Agent><dc:title>Jakub Steiner</dc:title></cc:Agent></dc:creator><dc:source>http://jimmac.musichall.cz</dc:source><dc:subject><rdf:Bag><rdf:li>home</rdf:li><rdf:li>return</rdf:li><rdf:li>go</rdf:li><rdf:li>default</rdf:li><rdf:li>user</rdf:li><rdf:li>directory</rdf:li></rdf:Bag></dc:subject><dc:contributor><cc:Agent><dc:title>Tuomas Kuosmanen</dc:title></cc:Agent></dc:contributor></cc:Work><cc:License
- rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits
- rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
- rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:permits
- rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /></cc:License></rdf:RDF></metadata><defs
- id="defs365"><inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 24 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="48 : 24 : 1"
- inkscape:persp3d-origin="24 : 16 : 1"
- id="perspective92" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient5060"
- id="radialGradient5031"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
- cx="605.71429"
- cy="486.64789"
- fx="605.71429"
- fy="486.64789"
- r="117.14286" /><linearGradient
- inkscape:collect="always"
- id="linearGradient5060"><stop
- style="stop-color:black;stop-opacity:1;"
- offset="0"
- id="stop5062" /><stop
- style="stop-color:black;stop-opacity:0;"
- offset="1"
- id="stop5064" /></linearGradient><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient5060"
- id="radialGradient5029"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
- cx="605.71429"
- cy="486.64789"
- fx="605.71429"
- fy="486.64789"
- r="117.14286" /><linearGradient
- id="linearGradient5048"><stop
- style="stop-color:black;stop-opacity:0;"
- offset="0"
- id="stop5050" /><stop
- id="stop5056"
- offset="0.5"
- style="stop-color:black;stop-opacity:1;" /><stop
- style="stop-color:black;stop-opacity:0;"
- offset="1"
- id="stop5052" /></linearGradient><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient5048"
- id="linearGradient5027"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
- x1="302.85715"
- y1="366.64789"
- x2="302.85715"
- y2="609.50507" /><linearGradient
- id="linearGradient2406"><stop
- style="stop-color:#7c7e79;stop-opacity:1;"
- offset="0"
- id="stop2408" /><stop
- id="stop2414"
- offset="0.1724138"
- style="stop-color:#848681;stop-opacity:1;" /><stop
- style="stop-color:#898c86;stop-opacity:1;"
- offset="1"
- id="stop2410" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2390"><stop
- style="stop-color:#919191;stop-opacity:1;"
- offset="0"
- id="stop2392" /><stop
- style="stop-color:#919191;stop-opacity:0;"
- offset="1"
- id="stop2394" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2378"><stop
- style="stop-color:#575757;stop-opacity:1;"
- offset="0"
- id="stop2380" /><stop
- style="stop-color:#575757;stop-opacity:0;"
- offset="1"
- id="stop2382" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2368"><stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="0"
- id="stop2370" /><stop
- style="stop-color:#ffffff;stop-opacity:0;"
- offset="1"
- id="stop2372" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2349"><stop
- style="stop-color:#000000;stop-opacity:1;"
- offset="0"
- id="stop2351" /><stop
- style="stop-color:#000000;stop-opacity:0;"
- offset="1"
- id="stop2353" /></linearGradient><linearGradient
- id="linearGradient2341"><stop
- id="stop2343"
- offset="0"
- style="stop-color:#000000;stop-opacity:1;" /><stop
- id="stop2345"
- offset="1"
- style="stop-color:#000000;stop-opacity:0;" /></linearGradient><linearGradient
- id="linearGradient2329"><stop
- style="stop-color:#000000;stop-opacity:0.18556701;"
- offset="0"
- id="stop2331" /><stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="1"
- id="stop2333" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2319"><stop
- style="stop-color:#000000;stop-opacity:1;"
- offset="0"
- id="stop2321" /><stop
- style="stop-color:#000000;stop-opacity:0;"
- offset="1"
- id="stop2323" /></linearGradient><linearGradient
- id="linearGradient2307"><stop
- style="stop-color:#edd400;stop-opacity:1;"
- offset="0"
- id="stop2309" /><stop
- style="stop-color:#998800;stop-opacity:1;"
- offset="1"
- id="stop2311" /></linearGradient><linearGradient
- inkscape:collect="always"
- id="linearGradient2299"><stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="0"
- id="stop2301" /><stop
- style="stop-color:#ffffff;stop-opacity:0;"
- offset="1"
- id="stop2303" /></linearGradient><linearGradient
- id="XMLID_2_"
- gradientUnits="userSpaceOnUse"
- x1="80.223602"
- y1="117.5205"
- x2="48.046001"
- y2="59.7995"
- gradientTransform="matrix(0.314683,0.000000,0.000000,0.314683,4.128264,3.742874)">
- <stop
- offset="0"
- style="stop-color:#CCCCCC"
- id="stop17" />
- <stop
- offset="0.9831"
- style="stop-color:#FFFFFF"
- id="stop19" />
- <midPointStop
- offset="0"
- style="stop-color:#CCCCCC"
- id="midPointStop48" />
- <midPointStop
- offset="0.5"
- style="stop-color:#CCCCCC"
- id="midPointStop50" />
- <midPointStop
- offset="0.9831"
- style="stop-color:#FFFFFF"
- id="midPointStop52" />
- </linearGradient><linearGradient
- inkscape:collect="always"
- xlink:href="#XMLID_2_"
- id="linearGradient1514"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.336922,0.000000,0.000000,0.166888,17.98288,15.46151)"
- x1="52.006104"
- y1="166.1331"
- x2="14.049017"
- y2="-42.218513" /><linearGradient
- id="XMLID_39_"
- gradientUnits="userSpaceOnUse"
- x1="64.387703"
- y1="65.124001"
- x2="64.387703"
- y2="35.569"
- gradientTransform="matrix(0.354101,0.000000,0.000000,0.354101,1.638679,-8.364921e-2)">
- <stop
- offset="0"
- style="stop-color:#FFFFFF"
- id="stop336" />
- <stop
- offset="0.8539"
- style="stop-color:#FF6200"
- id="stop338" />
- <stop
- offset="1"
- style="stop-color:#F25D00"
- id="stop340" />
- <midPointStop
- offset="0"
- style="stop-color:#FFFFFF"
- id="midPointStop335" />
- <midPointStop
- offset="0.5"
- style="stop-color:#FFFFFF"
- id="midPointStop337" />
- <midPointStop
- offset="0.8539"
- style="stop-color:#FF6200"
- id="midPointStop339" />
- <midPointStop
- offset="0.5"
- style="stop-color:#FF6200"
- id="midPointStop341" />
- <midPointStop
- offset="1"
- style="stop-color:#F25D00"
- id="midPointStop343" />
- </linearGradient><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2299"
- id="radialGradient2305"
- cx="7.5326638"
- cy="24.202574"
- fx="7.5326638"
- fy="24.202574"
- r="8.2452128"
- gradientTransform="matrix(4.100086,-1.627292e-17,2.125447e-14,4.201322,-25.41506,-78.53967)"
- gradientUnits="userSpaceOnUse" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2307"
- id="radialGradient2313"
- cx="19.985598"
- cy="36.77816"
- fx="19.985598"
- fy="36.77816"
- r="1.0821035"
- gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.565787)"
- gradientUnits="userSpaceOnUse" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2319"
- id="radialGradient2325"
- cx="20.443665"
- cy="37.425829"
- fx="20.443665"
- fy="37.425829"
- r="1.0821035"
- gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.731106)"
- gradientUnits="userSpaceOnUse" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2329"
- id="linearGradient2335"
- x1="17.602522"
- y1="26.057423"
- x2="17.682528"
- y2="32.654099"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.898789,0,0,1.071914,0.478025,-2.080838)" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2341"
- id="radialGradient2339"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(4.100086,1.627292e-17,2.125447e-14,-4.201322,-5.198109,105.3535)"
- cx="11.68129"
- cy="19.554111"
- fx="11.68129"
- fy="19.554111"
- r="8.2452126" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2349"
- id="radialGradient2355"
- cx="24.023088"
- cy="40.56913"
- fx="24.023088"
- fy="40.56913"
- r="16.28684"
- gradientTransform="matrix(1.000000,0.000000,0.000000,0.431250,1.157278e-15,23.07369)"
- gradientUnits="userSpaceOnUse" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2368"
- id="radialGradient2374"
- cx="29.913452"
- cy="30.442923"
- fx="29.913452"
- fy="30.442923"
- r="4.0018832"
- gradientTransform="matrix(3.751495,-2.191984e-22,1.723265e-22,3.147818,-82.00907,-65.70704)"
- gradientUnits="userSpaceOnUse" /><radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2378"
- id="radialGradient2384"
- cx="24.195112"
- cy="10.577631"
- fx="24.195112"
- fy="10.577631"
- r="15.242914"
- gradientTransform="matrix(1.125263,-3.585417e-8,4.269819e-8,1.340059,-3.006704,1.355395)"
- gradientUnits="userSpaceOnUse" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2390"
- id="linearGradient2396"
- x1="30.603519"
- y1="37.337803"
- x2="30.603519"
- y2="36.112415"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1.263867,0,0,0.859794,-6.499556,8.390924)" /><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient2406"
- id="linearGradient2412"
- x1="17.850183"
- y1="28.939463"
- x2="19.040216"
- y2="41.03223"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.888785,0,0,1.08932,2.41099,-1.524336)" /></defs><sodipodi:namedview
- inkscape:cy="-2.3755359"
- inkscape:cx="25.234802"
- inkscape:zoom="1"
- inkscape:window-height="691"
- inkscape:window-width="872"
- inkscape:pageshadow="2"
- inkscape:pageopacity="0.0"
- borderopacity="0.21568627"
- bordercolor="#666666"
- pagecolor="#ffffff"
- id="base"
- inkscape:showpageshadow="false"
- inkscape:window-x="466"
- inkscape:window-y="157"
- inkscape:current-layer="svg2"
- fill="#555753"
- showgrid="false"
- stroke="#a40000"
- showguides="true"
- inkscape:guide-bbox="true" />
- <g
- style="display:inline"
- id="g5022"
- transform="matrix(2.158196e-2,0,0,1.859457e-2,43.12251,41.63767)"><rect
- y="-150.69685"
- x="-1559.2523"
- height="478.35718"
- width="1339.6335"
- id="rect4173"
- style="opacity:0.40206185;color:black;fill:url(#linearGradient5027);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
- sodipodi:nodetypes="cccc"
- id="path5058"
- d="M -219.61876,-150.68038 C -219.61876,-150.68038 -219.61876,327.65041 -219.61876,327.65041 C -76.744594,328.55086 125.78146,220.48075 125.78138,88.454235 C 125.78138,-43.572302 -33.655436,-150.68036 -219.61876,-150.68038 z "
- style="opacity:0.40206185;color:black;fill:url(#radialGradient5029);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
- style="opacity:0.40206185;color:black;fill:url(#radialGradient5031);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M -1559.2523,-150.68038 C -1559.2523,-150.68038 -1559.2523,327.65041 -1559.2523,327.65041 C -1702.1265,328.55086 -1904.6525,220.48075 -1904.6525,88.454235 C -1904.6525,-43.572302 -1745.2157,-150.68036 -1559.2523,-150.68038 z "
- id="path5018"
- sodipodi:nodetypes="cccc" /></g><path
- style="color:#000000;fill:url(#linearGradient1514);fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:1.0000006;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M 21.619576,8.1833733 L 27.577035,8.1833733 C 28.416767,8.1833733 41.46351,23.618701 41.46351,24.524032 L 41.019989,43.020777 C 41.019989,43.92611 40.343959,44.654954 39.504227,44.654954 L 8.0469496,44.654954 C 7.2072167,44.654954 6.5311871,43.92611 6.5311871,43.020777 L 6.5876651,24.524032 C 6.5876651,23.618701 20.779844,8.1833733 21.619576,8.1833733 z "
- id="rect1512"
- sodipodi:nodetypes="ccccccccc" /><path
- style="fill:none"
- id="path5"
- d="M 46.963575,45.735573 L 1.6386762,45.735573 L 1.6386762,0.41067554 L 46.963575,0.41067554 L 46.963575,45.735573 z " /><path
- style="fill:url(#linearGradient2335);fill-opacity:1;fill-rule:evenodd"
- id="path2327"
- d="M 23,29 L 22.954256,44.090942 L 11.111465,44.090942 L 11,29 L 23,29 z "
- clip-rule="evenodd"
- sodipodi:nodetypes="ccccc" /><path
- sodipodi:nodetypes="ccccccccc"
- id="path2357"
- d="M 21.780459,9.405584 L 27.339556,9.405584 C 28.123138,9.405584 40.340425,23.805172 40.340425,24.649756 L 39.993267,42.862067 C 39.993267,43.321326 39.84953,43.515532 39.480892,43.515532 L 8.0936894,43.529812 C 7.7250517,43.529812 7.5097258,43.449894 7.5097258,43.076262 L 7.7250676,24.649756 C 7.7250676,23.805172 20.99688,9.405584 21.780459,9.405584 z "
- style="opacity:0.3125;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.00000012;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
- clip-rule="evenodd"
- d="M 7.2075295,27.943053 L 7.1532728,30.538247 L 25.521437,17.358993 L 40.807832,28.513421 L 40.879142,28.201707 L 24.508686,12.297576 L 7.2075295,27.943053 z "
- id="path23"
- style="opacity:0.2;fill:url(#radialGradient2384);fill-opacity:1;fill-rule:evenodd"
- sodipodi:nodetypes="ccccccc" /><path
- clip-rule="evenodd"
- d="M 22,30 L 22,44.090942 L 12.188971,44.090942 L 12,30 L 22,30 z "
- id="path188"
- style="fill:url(#linearGradient2412);fill-opacity:1;fill-rule:evenodd"
- sodipodi:nodetypes="ccccc" /><path
- style="opacity:0.40909089;fill:url(#radialGradient2325);fill-opacity:1;fill-rule:evenodd"
- id="path2315"
- d="M 19.576856,36.44767 C 20.249646,36.44767 20.793472,36.922275 20.793472,37.506177 C 20.793472,38.095988 20.249646,38.574532 19.576856,38.574532 C 18.904584,38.574532 18.35817,38.095988 18.35817,37.506177 C 18.358685,36.922275 18.904584,36.44767 19.576856,36.44767 z "
- clip-rule="evenodd" /><path
- clip-rule="evenodd"
- d="M 19.462314,35.932229 C 20.135103,35.932229 20.678929,36.406834 20.678929,36.990736 C 20.678929,37.580545 20.135103,38.059089 19.462314,38.059089 C 18.790041,38.059089 18.243627,37.580545 18.243627,36.990736 C 18.244142,36.406834 18.790041,35.932229 19.462314,35.932229 z "
- id="path217"
- style="fill:url(#radialGradient2313);fill-opacity:1;fill-rule:evenodd" /><path
- d="M 24.447748,11.559337 L 43.374808,28.729205 L 43.869487,29.121196 L 44.273163,28.949811 L 43.900293,28.188138 L 43.622679,27.964702 L 24.447748,12.392396 L 5.0582327,28.135731 L 4.8206309,28.279851 L 4.603921,28.986637 L 5.0373408,29.115885 L 5.4218948,28.807462 L 24.447748,11.559337 z "
- id="path342"
- style="fill:url(#XMLID_39_)"
- sodipodi:nodetypes="ccccccccccccc" /><path
- style="fill:#ef2929;stroke:#a40000"
- id="path362"
- d="M 24.330168,2.2713382 L 2.4484294,20.372675 L 1.8237005,27.538603 L 3.8236367,29.602926 C 3.8236367,29.602926 24.231018,12.445641 24.44773,12.274963 L 44.08027,29.818223 L 45.978694,27.494226 L 44.362903,20.382852 L 24.44773,2.1668788 L 24.330168,2.2713382 z "
- sodipodi:nodetypes="cccccccccc" />
-<path
- style="opacity:0.40909089;color:#000000;fill:url(#radialGradient2305);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M 2.8413446,20.613129 L 2.5497894,27.236494 L 24.369219,8.980075 L 24.298891,3.0867443 L 2.8413446,20.613129 z "
- id="path1536"
- sodipodi:nodetypes="ccccc" /><path
- sodipodi:nodetypes="ccccc"
- id="path2337"
- d="M 24.483763,8.7509884 L 24.583223,2.9098867 L 43.912186,20.56184 L 45.403998,27.062652 L 24.483763,8.7509884 z "
- style="opacity:0.13636367;color:#000000;fill:url(#radialGradient2339);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
- style="opacity:0.31818183;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99999934;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M 27.102228,27.719824 L 36.142223,27.719824 C 36.912818,27.719824 37.53319,28.340194 37.53319,29.110791 L 37.525229,38.190012 C 37.525229,38.960608 36.928907,39.455981 36.158311,39.455981 L 27.102228,39.455981 C 26.331631,39.455981 25.711261,38.835608 25.711261,38.065012 L 25.711261,29.110791 C 25.711261,28.340194 26.331631,27.719824 27.102228,27.719824 z "
- id="rect2361"
- sodipodi:nodetypes="ccccccccc" /><rect
- style="opacity:1;color:#000000;fill:#3465a4;fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:0.9999994;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- id="rect3263"
- width="10.001333"
- height="9.9624557"
- x="26.507767"
- y="28.514256"
- rx="0.38128215"
- ry="0.38128215" /><path
- style="opacity:0.39772728;color:#000000;fill:url(#radialGradient2374);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
- d="M 27.107118,34.408261 C 30.725101,34.739438 32.634842,32.962557 35.97527,32.855521 L 36,29.00603 L 27.088388,29 L 27.107118,34.408261 z "
- id="rect2363"
- sodipodi:nodetypes="ccccc" /></svg> \ No newline at end of file
diff --git a/examples/quick/views/parallax/content/pics/shadow.png b/examples/quick/views/parallax/content/pics/shadow.png
deleted file mode 100644
index 2dd494f6c6..0000000000
--- a/examples/quick/views/parallax/content/pics/shadow.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/yast-joystick.png b/examples/quick/views/parallax/content/pics/yast-joystick.png
deleted file mode 100644
index 858cea0301..0000000000
--- a/examples/quick/views/parallax/content/pics/yast-joystick.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/pics/yast-wol.png b/examples/quick/views/parallax/content/pics/yast-wol.png
deleted file mode 100644
index 7712180a3b..0000000000
--- a/examples/quick/views/parallax/content/pics/yast-wol.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/quit.png b/examples/quick/views/parallax/content/quit.png
deleted file mode 100644
index b822057d4e..0000000000
--- a/examples/quick/views/parallax/content/quit.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/parallax/content/second.png b/examples/quick/views/parallax/content/second.png
deleted file mode 100644
index d95d99e83d..0000000000
--- a/examples/quick/views/parallax/content/second.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/views/views.qrc b/examples/quick/views/views.qrc
index 52abb68659..547dbea992 100644
--- a/examples/quick/views/views.qrc
+++ b/examples/quick/views/views.qrc
@@ -33,26 +33,6 @@
<file>listview/content/pics/vegetable-soup.jpg</file>
<file>package/Delegate.qml</file>
<file>package/view.qml</file>
- <file>parallax/parallax.qml</file>
- <file>parallax/content/Smiley.qml</file>
- <file>parallax/content/background.png</file>
- <file>parallax/content/center.png</file>
- <file>parallax/content/clock-night.png</file>
- <file>parallax/content/clock.png</file>
- <file>parallax/content/Clock.qml</file>
- <file>parallax/content/hour.png</file>
- <file>parallax/content/minute.png</file>
- <file>parallax/content/ParallaxView.qml</file>
- <file>parallax/content/quit.png</file>
- <file>parallax/content/QuitButton.qml</file>
- <file>parallax/content/second.png</file>
- <file>parallax/content/pics/background.jpg</file>
- <file>parallax/content/pics/face-smile.png</file>
- <file>parallax/content/pics/home-page.png</file>
- <file>parallax/content/pics/home-page.svg</file>
- <file>parallax/content/pics/shadow.png</file>
- <file>parallax/content/pics/yast-joystick.png</file>
- <file>parallax/content/pics/yast-wol.png</file>
<file>pathview/pathview-example.qml</file>
<file>pathview/pics/AddressBook_48.png</file>
<file>pathview/pics/AudioPlayer_48.png</file>
diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml
index a1223da866..2ee7fb6e09 100644
--- a/examples/quick/window/window.qml
+++ b/examples/quick/window/window.qml
@@ -187,7 +187,7 @@ QtObject {
anchors.margins: defaultSpacing
text: "X"
width: 30
- onClicked: testWindow.visible = false
+ onClicked: testWindow.close()
}
}
}
diff --git a/qtdeclarative.doxy b/qtdeclarative.doxy
new file mode 100644
index 0000000000..ce21e34d3d
--- /dev/null
+++ b/qtdeclarative.doxy
@@ -0,0 +1,2466 @@
+# Doxyfile 1.8.14
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME = QtDeclarative
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER = 5.12
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF = "The QML engine and Qt Quick"
+
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
+
+PROJECT_LOGO = tests/testapplications/qsgimage/qt-logo.png
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = ../qtdeclarative-doc
+
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF = YES
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines (in the resulting output). You can put ^^ in the value part of an
+# alias to insert a newline as if a physical newline was in the original file.
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT = YES
+
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 0.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS = 0
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE = 1
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO, these declarations will be
+# included in the documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS = YES
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = YES
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER = "function git_filter { LC_ALL=C git ls-files -s $1 | awk '{print $2}'; }; git_filter"
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC = NO
+
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE = doxygen.log
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
+
+INPUT = src
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
+# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.
+
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS = *moc_* \
+ *c++test*
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE =
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see https://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX = NO
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE = 151
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT = 46
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP = NO
+
+# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
+# documentation will contain a main index with vertical navigation menus that
+# are dynamically created via Javascript. If disabled, the navigation index will
+# consists of multiple levels of tabs that are statically embedded in every HTML
+# page. Disable this option to support browsers that do not have Javascript,
+# like the Qt help browser.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_MENUS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS = YES
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: https://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND = YES
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP = YES
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE = qtdeclarative.qch
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW = YES
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH = 250
+
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# https://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER =
+
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE = plain
+
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF = YES
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS = YES
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE =
+
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
+# the structure of the code including all documentation. Note that this feature
+# is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS = YES
+
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: NO.
+
+HAVE_DOT = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK = YES
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS = NO
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH = YES
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH = /usr/bin
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH =
+
+# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
+# configuration file for plantuml.
+
+PLANTUML_CFG_FILE =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP = YES
diff --git a/src/3rdparty/masm/assembler/ARM64Assembler.h b/src/3rdparty/masm/assembler/ARM64Assembler.h
index 1787e921e8..fcf2e485e8 100644
--- a/src/3rdparty/masm/assembler/ARM64Assembler.h
+++ b/src/3rdparty/masm/assembler/ARM64Assembler.h
@@ -1980,6 +1980,13 @@ public:
}
template<int datasize>
+ ALWAYS_INLINE void stp(RegisterID rt, RegisterID rt2, RegisterID rn, unsigned pimm = 0)
+ {
+ CHECK_DATASIZE();
+ insn(loadStoreRegisterPairOffset(MEMPAIROPSIZE_INT(datasize), false, MemOp_STORE, pimm, rn, rt, rt2));
+ }
+
+ template<int datasize>
ALWAYS_INLINE void str(RegisterID rt, RegisterID rn, RegisterID rm)
{
str<datasize>(rt, rn, rm, UXTX, 0);
@@ -3701,6 +3708,23 @@ private:
}
// 'V' means vector
+ ALWAYS_INLINE static int loadStoreRegisterPairOffset(MemPairOpSize size, bool V, MemOp opc, int immediate, RegisterID rn, FPRegisterID rt, FPRegisterID rt2)
+ {
+ ASSERT(size < 3);
+ ASSERT(opc == (opc & 1)); // Only load or store, load signed 64 is handled via size.
+ ASSERT(V || (size != MemPairOp_LoadSigned_32) || (opc == MemOp_LOAD)); // There isn't an integer store signed.
+ unsigned immedShiftAmount = memPairOffsetShift(V, size);
+ int imm7 = immediate >> immedShiftAmount;
+ ASSERT((imm7 << immedShiftAmount) == immediate && isInt7(imm7));
+ return (0x29000000 | size << 30 | V << 26 | opc << 22 | (imm7 & 0x7f) << 15 | rt2 << 10 | xOrSp(rn) << 5 | rt);
+ }
+
+ ALWAYS_INLINE static int loadStoreRegisterPairOffset(MemPairOpSize size, bool V, MemOp opc, int immediate, RegisterID rn, RegisterID rt, RegisterID rt2)
+ {
+ return loadStoreRegisterPairOffset(size, V, opc, immediate, rn, xOrZrAsFPR(rt), xOrZrAsFPR(rt2));
+ }
+
+ // 'V' means vector
// 'S' means shift rm
ALWAYS_INLINE static int loadStoreRegisterRegisterOffset(MemOpSize size, bool V, MemOp opc, RegisterID rm, ExtendType option, bool S, RegisterID rn, FPRegisterID rt)
{
diff --git a/src/3rdparty/masm/assembler/ARMAssembler.cpp b/src/3rdparty/masm/assembler/ARMAssembler.cpp
deleted file mode 100644
index 6912d1ea39..0000000000
--- a/src/3rdparty/masm/assembler/ARMAssembler.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright (C) 2009 University of Szeged
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#include "ARMAssembler.h"
-
-namespace JSC {
-
-// Patching helpers
-
-void ARMAssembler::patchConstantPoolLoad(void* loadAddr, void* constPoolAddr)
-{
- ARMWord *ldr = reinterpret_cast<ARMWord*>(loadAddr);
- ARMWord diff = reinterpret_cast<ARMWord*>(constPoolAddr) - ldr;
- ARMWord index = (*ldr & 0xfff) >> 1;
-
- ASSERT(diff >= 1);
- if (diff >= 2 || index > 0) {
- diff = (diff + index - 2) * sizeof(ARMWord);
- ASSERT(diff <= 0xfff);
- *ldr = (*ldr & ~0xfff) | diff;
- } else
- *ldr = (*ldr & ~(0xfff | ARMAssembler::DataTransferUp)) | sizeof(ARMWord);
-}
-
-// Handle immediates
-
-ARMWord ARMAssembler::getOp2(ARMWord imm)
-{
- int rol;
-
- if (imm <= 0xff)
- return Op2Immediate | imm;
-
- if ((imm & 0xff000000) == 0) {
- imm <<= 8;
- rol = 8;
- }
- else {
- imm = (imm << 24) | (imm >> 8);
- rol = 0;
- }
-
- if ((imm & 0xff000000) == 0) {
- imm <<= 8;
- rol += 4;
- }
-
- if ((imm & 0xf0000000) == 0) {
- imm <<= 4;
- rol += 2;
- }
-
- if ((imm & 0xc0000000) == 0) {
- imm <<= 2;
- rol += 1;
- }
-
- if ((imm & 0x00ffffff) == 0)
- return Op2Immediate | (imm >> 24) | (rol << 8);
-
- return InvalidImmediate;
-}
-
-int ARMAssembler::genInt(int reg, ARMWord imm, bool positive)
-{
- // Step1: Search a non-immediate part
- ARMWord mask;
- ARMWord imm1;
- ARMWord imm2;
- int rol;
-
- mask = 0xff000000;
- rol = 8;
- while(1) {
- if ((imm & mask) == 0) {
- imm = (imm << rol) | (imm >> (32 - rol));
- rol = 4 + (rol >> 1);
- break;
- }
- rol += 2;
- mask >>= 2;
- if (mask & 0x3) {
- // rol 8
- imm = (imm << 8) | (imm >> 24);
- mask = 0xff00;
- rol = 24;
- while (1) {
- if ((imm & mask) == 0) {
- imm = (imm << rol) | (imm >> (32 - rol));
- rol = (rol >> 1) - 8;
- break;
- }
- rol += 2;
- mask >>= 2;
- if (mask & 0x3)
- return 0;
- }
- break;
- }
- }
-
- ASSERT((imm & 0xff) == 0);
-
- if ((imm & 0xff000000) == 0) {
- imm1 = Op2Immediate | ((imm >> 16) & 0xff) | (((rol + 4) & 0xf) << 8);
- imm2 = Op2Immediate | ((imm >> 8) & 0xff) | (((rol + 8) & 0xf) << 8);
- } else if (imm & 0xc0000000) {
- imm1 = Op2Immediate | ((imm >> 24) & 0xff) | ((rol & 0xf) << 8);
- imm <<= 8;
- rol += 4;
-
- if ((imm & 0xff000000) == 0) {
- imm <<= 8;
- rol += 4;
- }
-
- if ((imm & 0xf0000000) == 0) {
- imm <<= 4;
- rol += 2;
- }
-
- if ((imm & 0xc0000000) == 0) {
- imm <<= 2;
- rol += 1;
- }
-
- if ((imm & 0x00ffffff) == 0)
- imm2 = Op2Immediate | (imm >> 24) | ((rol & 0xf) << 8);
- else
- return 0;
- } else {
- if ((imm & 0xf0000000) == 0) {
- imm <<= 4;
- rol += 2;
- }
-
- if ((imm & 0xc0000000) == 0) {
- imm <<= 2;
- rol += 1;
- }
-
- imm1 = Op2Immediate | ((imm >> 24) & 0xff) | ((rol & 0xf) << 8);
- imm <<= 8;
- rol += 4;
-
- if ((imm & 0xf0000000) == 0) {
- imm <<= 4;
- rol += 2;
- }
-
- if ((imm & 0xc0000000) == 0) {
- imm <<= 2;
- rol += 1;
- }
-
- if ((imm & 0x00ffffff) == 0)
- imm2 = Op2Immediate | (imm >> 24) | ((rol & 0xf) << 8);
- else
- return 0;
- }
-
- if (positive) {
- mov(reg, imm1);
- orr(reg, reg, imm2);
- } else {
- mvn(reg, imm1);
- bic(reg, reg, imm2);
- }
-
- return 1;
-}
-
-ARMWord ARMAssembler::getImm(ARMWord imm, int tmpReg, bool invert)
-{
- ARMWord tmp;
-
- // Do it by 1 instruction
- tmp = getOp2(imm);
- if (tmp != InvalidImmediate)
- return tmp;
-
- tmp = getOp2(~imm);
- if (tmp != InvalidImmediate) {
- if (invert)
- return tmp | Op2InvertedImmediate;
- mvn(tmpReg, tmp);
- return tmpReg;
- }
-
- return encodeComplexImm(imm, tmpReg);
-}
-
-void ARMAssembler::moveImm(ARMWord imm, int dest)
-{
- ARMWord tmp;
-
- // Do it by 1 instruction
- tmp = getOp2(imm);
- if (tmp != InvalidImmediate) {
- mov(dest, tmp);
- return;
- }
-
- tmp = getOp2(~imm);
- if (tmp != InvalidImmediate) {
- mvn(dest, tmp);
- return;
- }
-
- encodeComplexImm(imm, dest);
-}
-
-ARMWord ARMAssembler::encodeComplexImm(ARMWord imm, int dest)
-{
-#if WTF_ARM_ARCH_AT_LEAST(7)
- ARMWord tmp = getImm16Op2(imm);
- if (tmp != InvalidImmediate) {
- movw(dest, tmp);
- return dest;
- }
- movw(dest, getImm16Op2(imm & 0xffff));
- movt(dest, getImm16Op2(imm >> 16));
- return dest;
-#else
- // Do it by 2 instruction
- if (genInt(dest, imm, true))
- return dest;
- if (genInt(dest, ~imm, false))
- return dest;
-
- ldrImmediate(dest, imm);
- return dest;
-#endif
-}
-
-// Memory load/store helpers
-
-void ARMAssembler::dataTransfer32(DataTransferTypeA transferType, RegisterID srcDst, RegisterID base, int32_t offset)
-{
- if (offset >= 0) {
- if (offset <= 0xfff)
- dtrUp(transferType, srcDst, base, offset);
- else if (offset <= 0xfffff) {
- add(ARMRegisters::S0, base, Op2Immediate | (offset >> 12) | (10 << 8));
- dtrUp(transferType, srcDst, ARMRegisters::S0, (offset & 0xfff));
- } else {
- moveImm(offset, ARMRegisters::S0);
- dtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
- }
- } else {
- if (offset >= -0xfff)
- dtrDown(transferType, srcDst, base, -offset);
- else if (offset >= -0xfffff) {
- sub(ARMRegisters::S0, base, Op2Immediate | (-offset >> 12) | (10 << 8));
- dtrDown(transferType, srcDst, ARMRegisters::S0, (-offset & 0xfff));
- } else {
- moveImm(offset, ARMRegisters::S0);
- dtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
- }
- }
-}
-
-void ARMAssembler::baseIndexTransfer32(DataTransferTypeA transferType, RegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset)
-{
- ASSERT(scale >= 0 && scale <= 3);
- ARMWord op2 = lsl(index, scale);
-
- if (!offset) {
- dtrUpRegister(transferType, srcDst, base, op2);
- return;
- }
-
- if (offset <= 0xfffff && offset >= -0xfffff) {
- add(ARMRegisters::S0, base, op2);
- dataTransfer32(transferType, srcDst, ARMRegisters::S0, offset);
- return;
- }
-
- moveImm(offset, ARMRegisters::S0);
- add(ARMRegisters::S0, ARMRegisters::S0, op2);
- dtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
-}
-
-void ARMAssembler::dataTransfer16(DataTransferTypeB transferType, RegisterID srcDst, RegisterID base, int32_t offset)
-{
- if (offset >= 0) {
- if (offset <= 0xff)
- halfDtrUp(transferType, srcDst, base, getOp2Half(offset));
- else if (offset <= 0xffff) {
- add(ARMRegisters::S0, base, Op2Immediate | (offset >> 8) | (12 << 8));
- halfDtrUp(transferType, srcDst, ARMRegisters::S0, getOp2Half(offset & 0xff));
- } else {
- moveImm(offset, ARMRegisters::S0);
- halfDtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
- }
- } else {
- if (offset >= -0xff)
- halfDtrDown(transferType, srcDst, base, getOp2Half(-offset));
- else if (offset >= -0xffff) {
- sub(ARMRegisters::S0, base, Op2Immediate | (-offset >> 8) | (12 << 8));
- halfDtrDown(transferType, srcDst, ARMRegisters::S0, getOp2Half(-offset & 0xff));
- } else {
- moveImm(offset, ARMRegisters::S0);
- halfDtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
- }
- }
-}
-
-void ARMAssembler::baseIndexTransfer16(DataTransferTypeB transferType, RegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset)
-{
- if (!scale && !offset) {
- halfDtrUpRegister(transferType, srcDst, base, index);
- return;
- }
-
- ARMWord op2 = lsl(index, scale);
-
- if (offset <= 0xffff && offset >= -0xffff) {
- add(ARMRegisters::S0, base, op2);
- dataTransfer16(transferType, srcDst, ARMRegisters::S0, offset);
- return;
- }
-
- moveImm(offset, ARMRegisters::S0);
- add(ARMRegisters::S0, ARMRegisters::S0, op2);
- halfDtrUpRegister(transferType, srcDst, base, ARMRegisters::S0);
-}
-
-void ARMAssembler::dataTransferFloat(DataTransferTypeFloat transferType, FPRegisterID srcDst, RegisterID base, int32_t offset)
-{
- // VFP cannot directly access memory that is not four-byte-aligned
- if (!(offset & 0x3)) {
- if (offset <= 0x3ff && offset >= 0) {
- doubleDtrUp(transferType, srcDst, base, offset >> 2);
- return;
- }
- if (offset <= 0x3ffff && offset >= 0) {
- add(ARMRegisters::S0, base, Op2Immediate | (offset >> 10) | (11 << 8));
- doubleDtrUp(transferType, srcDst, ARMRegisters::S0, (offset >> 2) & 0xff);
- return;
- }
- offset = -offset;
-
- if (offset <= 0x3ff && offset >= 0) {
- doubleDtrDown(transferType, srcDst, base, offset >> 2);
- return;
- }
- if (offset <= 0x3ffff && offset >= 0) {
- sub(ARMRegisters::S0, base, Op2Immediate | (offset >> 10) | (11 << 8));
- doubleDtrDown(transferType, srcDst, ARMRegisters::S0, (offset >> 2) & 0xff);
- return;
- }
- offset = -offset;
- }
-
- moveImm(offset, ARMRegisters::S0);
- add(ARMRegisters::S0, ARMRegisters::S0, base);
- doubleDtrUp(transferType, srcDst, ARMRegisters::S0, 0);
-}
-
-void ARMAssembler::baseIndexTransferFloat(DataTransferTypeFloat transferType, FPRegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset)
-{
- add(ARMRegisters::S1, base, lsl(index, scale));
- dataTransferFloat(transferType, srcDst, ARMRegisters::S1, offset);
-}
-
-PassRefPtr<ExecutableMemoryHandle> ARMAssembler::executableCopy(JSGlobalData& globalData, void* ownerUID, JITCompilationEffort effort)
-{
- // 64-bit alignment is required for next constant pool and JIT code as well
- m_buffer.flushWithoutBarrier(true);
- if (!m_buffer.isAligned(8))
- bkpt(0);
-
- RefPtr<ExecutableMemoryHandle> result = m_buffer.executableCopy(globalData, ownerUID, effort);
- char* data = reinterpret_cast<char*>(result->start());
-
- for (Jumps::Iterator iter = m_jumps.begin(); iter != m_jumps.end(); ++iter) {
- // The last bit is set if the constant must be placed on constant pool.
- int pos = (iter->m_offset) & (~0x1);
- ARMWord* ldrAddr = reinterpret_cast_ptr<ARMWord*>(data + pos);
- ARMWord* addr = getLdrImmAddress(ldrAddr);
- if (*addr != InvalidBranchTarget) {
- if (!(iter->m_offset & 1)) {
- intptr_t difference = reinterpret_cast_ptr<ARMWord*>(data + *addr) - (ldrAddr + DefaultPrefetchOffset);
-
- if ((difference <= MaximumBranchOffsetDistance && difference >= MinimumBranchOffsetDistance)) {
- *ldrAddr = B | getConditionalField(*ldrAddr) | (difference & BranchOffsetMask);
- continue;
- }
- }
- *addr = reinterpret_cast<ARMWord>(data + *addr);
- }
- }
-
- return result;
-}
-
-#if OS(LINUX) && COMPILER(RVCT)
-
-__asm void ARMAssembler::cacheFlush(void* code, size_t size)
-{
- ARM
- push {r7}
- add r1, r1, r0
- mov r7, #0xf0000
- add r7, r7, #0x2
- mov r2, #0x0
- svc #0x0
- pop {r7}
- bx lr
-}
-
-#endif
-
-} // namespace JSC
-
-#endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
diff --git a/src/3rdparty/masm/assembler/ARMAssembler.h b/src/3rdparty/masm/assembler/ARMAssembler.h
deleted file mode 100644
index 16cc25d4db..0000000000
--- a/src/3rdparty/masm/assembler/ARMAssembler.h
+++ /dev/null
@@ -1,1129 +0,0 @@
-/*
- * Copyright (C) 2009, 2010 University of Szeged
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ARMAssembler_h
-#define ARMAssembler_h
-
-#if ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#include "AssemblerBufferWithConstantPool.h"
-#include "JITCompilationEffort.h"
-#include <wtf/Assertions.h>
-namespace JSC {
-
- typedef uint32_t ARMWord;
-
- namespace ARMRegisters {
- typedef enum {
- r0 = 0,
- r1,
- r2,
- r3,
- r4,
- r5,
- r6, S0 = r6,
- r7,
- r8,
- r9,
- r10,
- r11,
- r12, S1 = r12,
- r13, sp = r13,
- r14, lr = r14,
- r15, pc = r15
- } RegisterID;
-
- typedef enum {
- d0,
- d1,
- d2,
- d3,
- d4,
- d5,
- d6,
- d7, SD0 = d7, /* Same as thumb assembler. */
- d8,
- d9,
- d10,
- d11,
- d12,
- d13,
- d14,
- d15,
- d16,
- d17,
- d18,
- d19,
- d20,
- d21,
- d22,
- d23,
- d24,
- d25,
- d26,
- d27,
- d28,
- d29,
- d30,
- d31
- } FPRegisterID;
-
- } // namespace ARMRegisters
-
- class ARMAssembler {
- public:
- typedef ARMRegisters::RegisterID RegisterID;
- typedef ARMRegisters::FPRegisterID FPRegisterID;
- typedef AssemblerBufferWithConstantPool<2048, 4, 4, ARMAssembler> ARMBuffer;
- typedef SegmentedVector<AssemblerLabel, 64> Jumps;
-
- ARMAssembler()
- : m_indexOfTailOfLastWatchpoint(1)
- {
- }
-
- // ARM conditional constants
- typedef enum {
- EQ = 0x00000000, // Zero
- NE = 0x10000000, // Non-zero
- CS = 0x20000000,
- CC = 0x30000000,
- MI = 0x40000000,
- PL = 0x50000000,
- VS = 0x60000000,
- VC = 0x70000000,
- HI = 0x80000000,
- LS = 0x90000000,
- GE = 0xa0000000,
- LT = 0xb0000000,
- GT = 0xc0000000,
- LE = 0xd0000000,
- AL = 0xe0000000
- } Condition;
-
- // ARM instruction constants
- enum {
- AND = (0x0 << 21),
- EOR = (0x1 << 21),
- SUB = (0x2 << 21),
- RSB = (0x3 << 21),
- ADD = (0x4 << 21),
- ADC = (0x5 << 21),
- SBC = (0x6 << 21),
- RSC = (0x7 << 21),
- TST = (0x8 << 21),
- TEQ = (0x9 << 21),
- CMP = (0xa << 21),
- CMN = (0xb << 21),
- ORR = (0xc << 21),
- MOV = (0xd << 21),
- BIC = (0xe << 21),
- MVN = (0xf << 21),
- MUL = 0x00000090,
- MULL = 0x00c00090,
- VMOV_F64 = 0x0eb00b40,
- VADD_F64 = 0x0e300b00,
- VDIV_F64 = 0x0e800b00,
- VSUB_F64 = 0x0e300b40,
- VMUL_F64 = 0x0e200b00,
- VCMP_F64 = 0x0eb40b40,
- VSQRT_F64 = 0x0eb10bc0,
- VABS_F64 = 0x0eb00bc0,
- VNEG_F64 = 0x0eb10b40,
- STMDB = 0x09200000,
- LDMIA = 0x08b00000,
- B = 0x0a000000,
- BL = 0x0b000000,
- BX = 0x012fff10,
- VMOV_VFP64 = 0x0c400a10,
- VMOV_ARM64 = 0x0c500a10,
- VMOV_VFP32 = 0x0e000a10,
- VMOV_ARM32 = 0x0e100a10,
- VCVT_F64_S32 = 0x0eb80bc0,
- VCVT_S32_F64 = 0x0ebd0b40,
- VCVT_U32_F64 = 0x0ebc0b40,
- VCVT_F32_F64 = 0x0eb70bc0,
- VCVT_F64_F32 = 0x0eb70ac0,
- VMRS_APSR = 0x0ef1fa10,
- CLZ = 0x016f0f10,
- BKPT = 0xe1200070,
- BLX = 0x012fff30,
-#if WTF_ARM_ARCH_AT_LEAST(7)
- MOVW = 0x03000000,
- MOVT = 0x03400000,
-#endif
- NOP = 0xe1a00000,
- };
-
- enum {
- Op2Immediate = (1 << 25),
- ImmediateForHalfWordTransfer = (1 << 22),
- Op2InvertedImmediate = (1 << 26),
- SetConditionalCodes = (1 << 20),
- Op2IsRegisterArgument = (1 << 25),
- // Data transfer flags.
- DataTransferUp = (1 << 23),
- DataTransferWriteBack = (1 << 21),
- DataTransferPostUpdate = (1 << 24),
- DataTransferLoad = (1 << 20),
- ByteDataTransfer = (1 << 22),
- };
-
- enum DataTransferTypeA {
- LoadUint32 = 0x05000000 | DataTransferLoad,
- LoadUint8 = 0x05400000 | DataTransferLoad,
- StoreUint32 = 0x05000000,
- StoreUint8 = 0x05400000,
- };
-
- enum DataTransferTypeB {
- LoadUint16 = 0x010000b0 | DataTransferLoad,
- LoadInt16 = 0x010000f0 | DataTransferLoad,
- LoadInt8 = 0x010000d0 | DataTransferLoad,
- StoreUint16 = 0x010000b0,
- };
-
- enum DataTransferTypeFloat {
- LoadFloat = 0x0d000a00 | DataTransferLoad,
- LoadDouble = 0x0d000b00 | DataTransferLoad,
- StoreFloat = 0x0d000a00,
- StoreDouble = 0x0d000b00,
- };
-
- // Masks of ARM instructions
- enum {
- BranchOffsetMask = 0x00ffffff,
- ConditionalFieldMask = 0xf0000000,
- DataTransferOffsetMask = 0xfff,
- };
-
- enum {
- MinimumBranchOffsetDistance = -0x00800000,
- MaximumBranchOffsetDistance = 0x007fffff,
- };
-
- enum {
- padForAlign8 = 0x00,
- padForAlign16 = 0x0000,
- padForAlign32 = 0xe12fff7f // 'bkpt 0xffff' instruction.
- };
-
- static const ARMWord InvalidImmediate = 0xf0000000;
- static const ARMWord InvalidBranchTarget = 0xffffffff;
- static const int DefaultPrefetchOffset = 2;
-
- static const ARMWord BlxInstructionMask = 0x012fff30;
- static const ARMWord LdrOrAddInstructionMask = 0x0ff00000;
- static const ARMWord LdrPcImmediateInstructionMask = 0x0f7f0000;
-
- static const ARMWord AddImmediateInstruction = 0x02800000;
- static const ARMWord BlxInstruction = 0x012fff30;
- static const ARMWord LdrImmediateInstruction = 0x05900000;
- static const ARMWord LdrPcImmediateInstruction = 0x051f0000;
-
- // Instruction formating
-
- void emitInstruction(ARMWord op, int rd, int rn, ARMWord op2)
- {
- ASSERT(((op2 & ~Op2Immediate) <= 0xfff) || (((op2 & ~ImmediateForHalfWordTransfer) <= 0xfff)));
- m_buffer.putInt(op | RN(rn) | RD(rd) | op2);
- }
-
- void emitDoublePrecisionInstruction(ARMWord op, int dd, int dn, int dm)
- {
- ASSERT((dd >= 0 && dd <= 31) && (dn >= 0 && dn <= 31) && (dm >= 0 && dm <= 31));
- m_buffer.putInt(op | ((dd & 0xf) << 12) | ((dd & 0x10) << (22 - 4))
- | ((dn & 0xf) << 16) | ((dn & 0x10) << (7 - 4))
- | (dm & 0xf) | ((dm & 0x10) << (5 - 4)));
- }
-
- void emitSinglePrecisionInstruction(ARMWord op, int sd, int sn, int sm)
- {
- ASSERT((sd >= 0 && sd <= 31) && (sn >= 0 && sn <= 31) && (sm >= 0 && sm <= 31));
- m_buffer.putInt(op | ((sd >> 1) << 12) | ((sd & 0x1) << 22)
- | ((sn >> 1) << 16) | ((sn & 0x1) << 7)
- | (sm >> 1) | ((sm & 0x1) << 5));
- }
-
- void bitAnd(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | AND, rd, rn, op2);
- }
-
- void bitAnds(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | AND | SetConditionalCodes, rd, rn, op2);
- }
-
- void eor(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | EOR, rd, rn, op2);
- }
-
- void eors(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | EOR | SetConditionalCodes, rd, rn, op2);
- }
-
- void sub(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | SUB, rd, rn, op2);
- }
-
- void subs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | SUB | SetConditionalCodes, rd, rn, op2);
- }
-
- void rsb(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | RSB, rd, rn, op2);
- }
-
- void rsbs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | RSB | SetConditionalCodes, rd, rn, op2);
- }
-
- void add(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ADD, rd, rn, op2);
- }
-
- void adds(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ADD | SetConditionalCodes, rd, rn, op2);
- }
-
- void adc(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ADC, rd, rn, op2);
- }
-
- void adcs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ADC | SetConditionalCodes, rd, rn, op2);
- }
-
- void sbc(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | SBC, rd, rn, op2);
- }
-
- void sbcs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | SBC | SetConditionalCodes, rd, rn, op2);
- }
-
- void rsc(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | RSC, rd, rn, op2);
- }
-
- void rscs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | RSC | SetConditionalCodes, rd, rn, op2);
- }
-
- void tst(int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | TST | SetConditionalCodes, 0, rn, op2);
- }
-
- void teq(int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | TEQ | SetConditionalCodes, 0, rn, op2);
- }
-
- void cmp(int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | CMP | SetConditionalCodes, 0, rn, op2);
- }
-
- void cmn(int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | CMN | SetConditionalCodes, 0, rn, op2);
- }
-
- void orr(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ORR, rd, rn, op2);
- }
-
- void orrs(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | ORR | SetConditionalCodes, rd, rn, op2);
- }
-
- void mov(int rd, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | MOV, rd, ARMRegisters::r0, op2);
- }
-
-#if WTF_ARM_ARCH_AT_LEAST(7)
- void movw(int rd, ARMWord op2, Condition cc = AL)
- {
- ASSERT((op2 | 0xf0fff) == 0xf0fff);
- m_buffer.putInt(toARMWord(cc) | MOVW | RD(rd) | op2);
- }
-
- void movt(int rd, ARMWord op2, Condition cc = AL)
- {
- ASSERT((op2 | 0xf0fff) == 0xf0fff);
- m_buffer.putInt(toARMWord(cc) | MOVT | RD(rd) | op2);
- }
-#endif
-
- void movs(int rd, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | MOV | SetConditionalCodes, rd, ARMRegisters::r0, op2);
- }
-
- void bic(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | BIC, rd, rn, op2);
- }
-
- void bics(int rd, int rn, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | BIC | SetConditionalCodes, rd, rn, op2);
- }
-
- void mvn(int rd, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | MVN, rd, ARMRegisters::r0, op2);
- }
-
- void mvns(int rd, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | MVN | SetConditionalCodes, rd, ARMRegisters::r0, op2);
- }
-
- void mul(int rd, int rn, int rm, Condition cc = AL)
- {
- m_buffer.putInt(toARMWord(cc) | MUL | RN(rd) | RS(rn) | RM(rm));
- }
-
- void muls(int rd, int rn, int rm, Condition cc = AL)
- {
- m_buffer.putInt(toARMWord(cc) | MUL | SetConditionalCodes | RN(rd) | RS(rn) | RM(rm));
- }
-
- void mull(int rdhi, int rdlo, int rn, int rm, Condition cc = AL)
- {
- m_buffer.putInt(toARMWord(cc) | MULL | RN(rdhi) | RD(rdlo) | RS(rn) | RM(rm));
- }
-
- void vmov_f64(int dd, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VMOV_F64, dd, 0, dm);
- }
-
- void vadd_f64(int dd, int dn, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VADD_F64, dd, dn, dm);
- }
-
- void vdiv_f64(int dd, int dn, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VDIV_F64, dd, dn, dm);
- }
-
- void vsub_f64(int dd, int dn, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VSUB_F64, dd, dn, dm);
- }
-
- void vmul_f64(int dd, int dn, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VMUL_F64, dd, dn, dm);
- }
-
- void vcmp_f64(int dd, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VCMP_F64, dd, 0, dm);
- }
-
- void vsqrt_f64(int dd, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VSQRT_F64, dd, 0, dm);
- }
-
- void vabs_f64(int dd, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VABS_F64, dd, 0, dm);
- }
-
- void vneg_f64(int dd, int dm, Condition cc = AL)
- {
- emitDoublePrecisionInstruction(toARMWord(cc) | VNEG_F64, dd, 0, dm);
- }
-
- void ldrImmediate(int rd, ARMWord imm, Condition cc = AL)
- {
- m_buffer.putIntWithConstantInt(toARMWord(cc) | LoadUint32 | DataTransferUp | RN(ARMRegisters::pc) | RD(rd), imm, true);
- }
-
- void ldrUniqueImmediate(int rd, ARMWord imm, Condition cc = AL)
- {
- m_buffer.putIntWithConstantInt(toARMWord(cc) | LoadUint32 | DataTransferUp | RN(ARMRegisters::pc) | RD(rd), imm);
- }
-
- void dtrUp(DataTransferTypeA transferType, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType | DataTransferUp, rd, rb, op2);
- }
-
- void dtrUpRegister(DataTransferTypeA transferType, int rd, int rb, int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType | DataTransferUp | Op2IsRegisterArgument, rd, rb, rm);
- }
-
- void dtrDown(DataTransferTypeA transferType, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType, rd, rb, op2);
- }
-
- void dtrDownRegister(DataTransferTypeA transferType, int rd, int rb, int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType | Op2IsRegisterArgument, rd, rb, rm);
- }
-
- void halfDtrUp(DataTransferTypeB transferType, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType | DataTransferUp, rd, rb, op2);
- }
-
- void halfDtrUpRegister(DataTransferTypeB transferType, int rd, int rn, int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType | DataTransferUp, rd, rn, rm);
- }
-
- void halfDtrDown(DataTransferTypeB transferType, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType, rd, rb, op2);
- }
-
- void halfDtrDownRegister(DataTransferTypeB transferType, int rd, int rn, int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | transferType, rd, rn, rm);
- }
-
- void doubleDtrUp(DataTransferTypeFloat type, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- ASSERT(op2 <= 0xff && rd <= 15);
- /* Only d0-d15 and s0, s2, s4 ... s30 are supported. */
- m_buffer.putInt(toARMWord(cc) | DataTransferUp | type | (rd << 12) | RN(rb) | op2);
- }
-
- void doubleDtrDown(DataTransferTypeFloat type, int rd, int rb, ARMWord op2, Condition cc = AL)
- {
- ASSERT(op2 <= 0xff && rd <= 15);
- /* Only d0-d15 and s0, s2, s4 ... s30 are supported. */
- m_buffer.putInt(toARMWord(cc) | type | (rd << 12) | RN(rb) | op2);
- }
-
- void push(int reg, Condition cc = AL)
- {
- ASSERT(ARMWord(reg) <= 0xf);
- m_buffer.putInt(toARMWord(cc) | StoreUint32 | DataTransferWriteBack | RN(ARMRegisters::sp) | RD(reg) | 0x4);
- }
-
- void pop(int reg, Condition cc = AL)
- {
- ASSERT(ARMWord(reg) <= 0xf);
- m_buffer.putInt(toARMWord(cc) | (LoadUint32 ^ DataTransferPostUpdate) | DataTransferUp | RN(ARMRegisters::sp) | RD(reg) | 0x4);
- }
-
- inline void poke(int reg, Condition cc = AL)
- {
- dtrDown(StoreUint32, ARMRegisters::sp, 0, reg, cc);
- }
-
- inline void peek(int reg, Condition cc = AL)
- {
- dtrUp(LoadUint32, reg, ARMRegisters::sp, 0, cc);
- }
-
- void vmov_vfp64(int sm, int rt, int rt2, Condition cc = AL)
- {
- ASSERT(rt != rt2);
- m_buffer.putInt(toARMWord(cc) | VMOV_VFP64 | RN(rt2) | RD(rt) | (sm & 0xf) | ((sm & 0x10) << (5 - 4)));
- }
-
- void vmov_arm64(int rt, int rt2, int sm, Condition cc = AL)
- {
- ASSERT(rt != rt2);
- m_buffer.putInt(toARMWord(cc) | VMOV_ARM64 | RN(rt2) | RD(rt) | (sm & 0xf) | ((sm & 0x10) << (5 - 4)));
- }
-
- void vmov_vfp32(int sn, int rt, Condition cc = AL)
- {
- ASSERT(rt <= 15);
- emitSinglePrecisionInstruction(toARMWord(cc) | VMOV_VFP32, rt << 1, sn, 0);
- }
-
- void vmov_arm32(int rt, int sn, Condition cc = AL)
- {
- ASSERT(rt <= 15);
- emitSinglePrecisionInstruction(toARMWord(cc) | VMOV_ARM32, rt << 1, sn, 0);
- }
-
- void vcvt_f64_s32(int dd, int sm, Condition cc = AL)
- {
- ASSERT(!(sm & 0x1)); // sm must be divisible by 2
- emitDoublePrecisionInstruction(toARMWord(cc) | VCVT_F64_S32, dd, 0, (sm >> 1));
- }
-
- void vcvt_s32_f64(int sd, int dm, Condition cc = AL)
- {
- ASSERT(!(sd & 0x1)); // sd must be divisible by 2
- emitDoublePrecisionInstruction(toARMWord(cc) | VCVT_S32_F64, (sd >> 1), 0, dm);
- }
-
- void vcvt_u32_f64(int sd, int dm, Condition cc = AL)
- {
- ASSERT(!(sd & 0x1)); // sd must be divisible by 2
- emitDoublePrecisionInstruction(toARMWord(cc) | VCVT_U32_F64, (sd >> 1), 0, dm);
- }
-
- void vcvt_f64_f32(int dd, int sm, Condition cc = AL)
- {
- ASSERT(dd <= 15 && sm <= 15);
- emitDoublePrecisionInstruction(toARMWord(cc) | VCVT_F64_F32, dd, 0, sm);
- }
-
- void vcvt_f32_f64(int dd, int sm, Condition cc = AL)
- {
- ASSERT(dd <= 15 && sm <= 15);
- emitDoublePrecisionInstruction(toARMWord(cc) | VCVT_F32_F64, dd, 0, sm);
- }
-
- void vmrs_apsr(Condition cc = AL)
- {
- m_buffer.putInt(toARMWord(cc) | VMRS_APSR);
- }
-
- void clz(int rd, int rm, Condition cc = AL)
- {
- m_buffer.putInt(toARMWord(cc) | CLZ | RD(rd) | RM(rm));
- }
-
- void bkpt(ARMWord value)
- {
- m_buffer.putInt(BKPT | ((value & 0xff0) << 4) | (value & 0xf));
- }
-
- void nop()
- {
- m_buffer.putInt(NOP);
- }
-
- void bx(int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | BX, 0, 0, RM(rm));
- }
-
- AssemblerLabel blx(int rm, Condition cc = AL)
- {
- emitInstruction(toARMWord(cc) | BLX, 0, 0, RM(rm));
- return m_buffer.label();
- }
-
- static ARMWord lsl(int reg, ARMWord value)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(value <= 0x1f);
- return reg | (value << 7) | 0x00;
- }
-
- static ARMWord lsr(int reg, ARMWord value)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(value <= 0x1f);
- return reg | (value << 7) | 0x20;
- }
-
- static ARMWord asr(int reg, ARMWord value)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(value <= 0x1f);
- return reg | (value << 7) | 0x40;
- }
-
- static ARMWord lslRegister(int reg, int shiftReg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(shiftReg <= ARMRegisters::pc);
- return reg | (shiftReg << 8) | 0x10;
- }
-
- static ARMWord lsrRegister(int reg, int shiftReg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(shiftReg <= ARMRegisters::pc);
- return reg | (shiftReg << 8) | 0x30;
- }
-
- static ARMWord asrRegister(int reg, int shiftReg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- ASSERT(shiftReg <= ARMRegisters::pc);
- return reg | (shiftReg << 8) | 0x50;
- }
-
- // General helpers
-
- size_t codeSize() const
- {
- return m_buffer.codeSize();
- }
-
- void ensureSpace(int insnSpace, int constSpace)
- {
- m_buffer.ensureSpace(insnSpace, constSpace);
- }
-
- int sizeOfConstantPool()
- {
- return m_buffer.sizeOfConstantPool();
- }
-
- AssemblerLabel labelIgnoringWatchpoints()
- {
- m_buffer.ensureSpaceForAnyInstruction();
- return m_buffer.label();
- }
-
- AssemblerLabel labelForWatchpoint()
- {
- m_buffer.ensureSpaceForAnyInstruction(maxJumpReplacementSize() / sizeof(ARMWord));
- AssemblerLabel result = m_buffer.label();
- if (result.m_offset != (m_indexOfTailOfLastWatchpoint - maxJumpReplacementSize()))
- result = label();
- m_indexOfTailOfLastWatchpoint = result.m_offset + maxJumpReplacementSize();
- return label();
- }
-
- AssemblerLabel label()
- {
- AssemblerLabel result = labelIgnoringWatchpoints();
- while (result.m_offset + 1 < m_indexOfTailOfLastWatchpoint) {
- nop();
- // The available number of instructions are ensured by labelForWatchpoint.
- result = m_buffer.label();
- }
- return result;
- }
-
- AssemblerLabel align(int alignment)
- {
- while (!m_buffer.isAligned(alignment))
- mov(ARMRegisters::r0, ARMRegisters::r0);
-
- return label();
- }
-
- AssemblerLabel loadBranchTarget(int rd, Condition cc = AL, int useConstantPool = 0)
- {
- ensureSpace(sizeof(ARMWord), sizeof(ARMWord));
- m_jumps.append(m_buffer.codeSize() | (useConstantPool & 0x1));
- ldrUniqueImmediate(rd, InvalidBranchTarget, cc);
- return m_buffer.label();
- }
-
- AssemblerLabel jmp(Condition cc = AL, int useConstantPool = 0)
- {
- return loadBranchTarget(ARMRegisters::pc, cc, useConstantPool);
- }
-
- PassRefPtr<ExecutableMemoryHandle> executableCopy(JSGlobalData&, void* ownerUID, JITCompilationEffort);
-
- unsigned debugOffset() { return m_buffer.debugOffset(); }
-
- // DFG assembly helpers for moving data between fp and registers.
- void vmov(RegisterID rd1, RegisterID rd2, FPRegisterID rn)
- {
- vmov_arm64(rd1, rd2, rn);
- }
-
- void vmov(FPRegisterID rd, RegisterID rn1, RegisterID rn2)
- {
- vmov_vfp64(rd, rn1, rn2);
- }
-
- // Patching helpers
-
- static ARMWord* getLdrImmAddress(ARMWord* insn)
- {
- // Check for call
- if ((*insn & LdrPcImmediateInstructionMask) != LdrPcImmediateInstruction) {
- // Must be BLX
- ASSERT((*insn & BlxInstructionMask) == BlxInstruction);
- insn--;
- }
-
- // Must be an ldr ..., [pc +/- imm]
- ASSERT((*insn & LdrPcImmediateInstructionMask) == LdrPcImmediateInstruction);
-
- ARMWord addr = reinterpret_cast<ARMWord>(insn) + DefaultPrefetchOffset * sizeof(ARMWord);
- if (*insn & DataTransferUp)
- return reinterpret_cast<ARMWord*>(addr + (*insn & DataTransferOffsetMask));
- return reinterpret_cast<ARMWord*>(addr - (*insn & DataTransferOffsetMask));
- }
-
- static ARMWord* getLdrImmAddressOnPool(ARMWord* insn, uint32_t* constPool)
- {
- // Must be an ldr ..., [pc +/- imm]
- ASSERT((*insn & LdrPcImmediateInstructionMask) == LdrPcImmediateInstruction);
-
- if (*insn & 0x1)
- return reinterpret_cast<ARMWord*>(constPool + ((*insn & DataTransferOffsetMask) >> 1));
- return getLdrImmAddress(insn);
- }
-
- static void patchPointerInternal(intptr_t from, void* to)
- {
- ARMWord* insn = reinterpret_cast<ARMWord*>(from);
- ARMWord* addr = getLdrImmAddress(insn);
- *addr = reinterpret_cast<ARMWord>(to);
- }
-
- static ARMWord patchConstantPoolLoad(ARMWord load, ARMWord value)
- {
- value = (value << 1) + 1;
- ASSERT(!(value & ~DataTransferOffsetMask));
- return (load & ~DataTransferOffsetMask) | value;
- }
-
- static void patchConstantPoolLoad(void* loadAddr, void* constPoolAddr);
-
- // Read pointers
- static void* readPointer(void* from)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(from);
- ARMWord* address = getLdrImmAddress(instruction);
- return *reinterpret_cast<void**>(address);
- }
-
- // Patch pointers
-
- static void linkPointer(void* code, AssemblerLabel from, void* to)
- {
- patchPointerInternal(reinterpret_cast<intptr_t>(code) + from.m_offset, to);
- }
-
- static void repatchInt32(void* where, int32_t to)
- {
- patchPointerInternal(reinterpret_cast<intptr_t>(where), reinterpret_cast<void*>(to));
- }
-
- static void repatchCompact(void* where, int32_t value)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(where);
- ASSERT((*instruction & 0x0f700000) == LoadUint32);
- if (value >= 0)
- *instruction = (*instruction & 0xff7ff000) | DataTransferUp | value;
- else
- *instruction = (*instruction & 0xff7ff000) | -value;
- cacheFlush(instruction, sizeof(ARMWord));
- }
-
- static void repatchPointer(void* from, void* to)
- {
- patchPointerInternal(reinterpret_cast<intptr_t>(from), to);
- }
-
- // Linkers
- static intptr_t getAbsoluteJumpAddress(void* base, int offset = 0)
- {
- return reinterpret_cast<intptr_t>(base) + offset - sizeof(ARMWord);
- }
-
- void linkJump(AssemblerLabel from, AssemblerLabel to)
- {
- ARMWord* insn = reinterpret_cast<ARMWord*>(getAbsoluteJumpAddress(m_buffer.data(), from.m_offset));
- ARMWord* addr = getLdrImmAddressOnPool(insn, m_buffer.poolAddress());
- *addr = toARMWord(to.m_offset);
- }
-
- static void linkJump(void* code, AssemblerLabel from, void* to)
- {
- patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to);
- }
-
- static void relinkJump(void* from, void* to)
- {
- patchPointerInternal(getAbsoluteJumpAddress(from), to);
- }
-
- static void linkCall(void* code, AssemblerLabel from, void* to)
- {
- patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to);
- }
-
- static void relinkCall(void* from, void* to)
- {
- patchPointerInternal(getAbsoluteJumpAddress(from), to);
- }
-
- static void* readCallTarget(void* from)
- {
- return reinterpret_cast<void*>(readPointer(reinterpret_cast<void*>(getAbsoluteJumpAddress(from))));
- }
-
- static void replaceWithJump(void* instructionStart, void* to)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(instructionStart);
- intptr_t difference = reinterpret_cast<intptr_t>(to) - (reinterpret_cast<intptr_t>(instruction) + DefaultPrefetchOffset * sizeof(ARMWord));
-
- if (!(difference & 1)) {
- difference >>= 2;
- if ((difference <= MaximumBranchOffsetDistance && difference >= MinimumBranchOffsetDistance)) {
- // Direct branch.
- instruction[0] = B | AL | (difference & BranchOffsetMask);
- cacheFlush(instruction, sizeof(ARMWord));
- return;
- }
- }
-
- // Load target.
- instruction[0] = LoadUint32 | AL | RN(ARMRegisters::pc) | RD(ARMRegisters::pc) | 4;
- instruction[1] = reinterpret_cast<ARMWord>(to);
- cacheFlush(instruction, sizeof(ARMWord) * 2);
- }
-
- static ptrdiff_t maxJumpReplacementSize()
- {
- return sizeof(ARMWord) * 2;
- }
-
- static void replaceWithLoad(void* instructionStart)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(instructionStart);
- cacheFlush(instruction, sizeof(ARMWord));
-
- ASSERT((*instruction & LdrOrAddInstructionMask) == AddImmediateInstruction || (*instruction & LdrOrAddInstructionMask) == LdrImmediateInstruction);
- if ((*instruction & LdrOrAddInstructionMask) == AddImmediateInstruction) {
- *instruction = (*instruction & ~LdrOrAddInstructionMask) | LdrImmediateInstruction;
- cacheFlush(instruction, sizeof(ARMWord));
- }
- }
-
- static void replaceWithAddressComputation(void* instructionStart)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(instructionStart);
- cacheFlush(instruction, sizeof(ARMWord));
-
- ASSERT((*instruction & LdrOrAddInstructionMask) == AddImmediateInstruction || (*instruction & LdrOrAddInstructionMask) == LdrImmediateInstruction);
- if ((*instruction & LdrOrAddInstructionMask) == LdrImmediateInstruction) {
- *instruction = (*instruction & ~LdrOrAddInstructionMask) | AddImmediateInstruction;
- cacheFlush(instruction, sizeof(ARMWord));
- }
- }
-
- static void revertBranchPtrWithPatch(void* instructionStart, RegisterID rn, ARMWord imm)
- {
- ARMWord* instruction = reinterpret_cast<ARMWord*>(instructionStart);
-
- ASSERT((instruction[2] & LdrPcImmediateInstructionMask) == LdrPcImmediateInstruction);
- instruction[0] = toARMWord(AL) | ((instruction[2] & 0x0fff0fff) + sizeof(ARMWord)) | RD(ARMRegisters::S1);
- *getLdrImmAddress(instruction) = imm;
- instruction[1] = toARMWord(AL) | CMP | SetConditionalCodes | RN(rn) | RM(ARMRegisters::S1);
- cacheFlush(instruction, 2 * sizeof(ARMWord));
- }
-
- // Address operations
-
- static void* getRelocatedAddress(void* code, AssemblerLabel label)
- {
- return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset);
- }
-
- // Address differences
-
- static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
- {
- return b.m_offset - a.m_offset;
- }
-
- static unsigned getCallReturnOffset(AssemblerLabel call)
- {
- return call.m_offset;
- }
-
- // Handle immediates
-
- static ARMWord getOp2(ARMWord imm);
-
- // Fast case if imm is known to be between 0 and 0xff
- static ARMWord getOp2Byte(ARMWord imm)
- {
- ASSERT(imm <= 0xff);
- return Op2Immediate | imm;
- }
-
- static ARMWord getOp2Half(ARMWord imm)
- {
- ASSERT(imm <= 0xff);
- return ImmediateForHalfWordTransfer | (imm & 0x0f) | ((imm & 0xf0) << 4);
- }
-
-#if WTF_ARM_ARCH_AT_LEAST(7)
- static ARMWord getImm16Op2(ARMWord imm)
- {
- if (imm <= 0xffff)
- return (imm & 0xf000) << 4 | (imm & 0xfff);
- return InvalidImmediate;
- }
-#endif
- ARMWord getImm(ARMWord imm, int tmpReg, bool invert = false);
- void moveImm(ARMWord imm, int dest);
- ARMWord encodeComplexImm(ARMWord imm, int dest);
-
- // Memory load/store helpers
-
- void dataTransfer32(DataTransferTypeA, RegisterID srcDst, RegisterID base, int32_t offset);
- void baseIndexTransfer32(DataTransferTypeA, RegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset);
- void dataTransfer16(DataTransferTypeB, RegisterID srcDst, RegisterID base, int32_t offset);
- void baseIndexTransfer16(DataTransferTypeB, RegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset);
- void dataTransferFloat(DataTransferTypeFloat, FPRegisterID srcDst, RegisterID base, int32_t offset);
- void baseIndexTransferFloat(DataTransferTypeFloat, FPRegisterID srcDst, RegisterID base, RegisterID index, int scale, int32_t offset);
-
- // Constant pool hnadlers
-
- static ARMWord placeConstantPoolBarrier(int offset)
- {
- offset = (offset - sizeof(ARMWord)) >> 2;
- ASSERT((offset <= MaximumBranchOffsetDistance && offset >= MinimumBranchOffsetDistance));
- return AL | B | (offset & BranchOffsetMask);
- }
-
-#if OS(LINUX) && COMPILER(GCC)
- static inline void linuxPageFlush(uintptr_t begin, uintptr_t end)
- {
- asm volatile(
- "push {r7}\n"
- "mov r0, %0\n"
- "mov r1, %1\n"
- "mov r7, #0xf0000\n"
- "add r7, r7, #0x2\n"
- "mov r2, #0x0\n"
- "svc 0x0\n"
- "pop {r7}\n"
- :
- : "r" (begin), "r" (end)
- : "r0", "r1", "r2");
- }
-#endif
-
-#if OS(LINUX) && COMPILER(RVCT)
- static __asm void cacheFlush(void* code, size_t);
-#else
- static void cacheFlush(void* code, size_t size)
- {
-#if OS(LINUX) && COMPILER(GCC)
- size_t page = pageSize();
- uintptr_t current = reinterpret_cast<uintptr_t>(code);
- uintptr_t end = current + size;
- uintptr_t firstPageEnd = (current & ~(page - 1)) + page;
-
- if (end <= firstPageEnd) {
- linuxPageFlush(current, end);
- return;
- }
-
- linuxPageFlush(current, firstPageEnd);
-
- for (current = firstPageEnd; current + page < end; current += page)
- linuxPageFlush(current, current + page);
-
- linuxPageFlush(current, end);
-#elif OS(WINCE)
- CacheRangeFlush(code, size, CACHE_SYNC_ALL);
-#elif OS(QNX) && ENABLE(ASSEMBLER_WX_EXCLUSIVE)
- UNUSED_PARAM(code);
- UNUSED_PARAM(size);
-#elif OS(QNX)
- msync(code, size, MS_INVALIDATE_ICACHE);
-#else
-#error "The cacheFlush support is missing on this platform."
-#endif
- }
-#endif
-
- private:
- static ARMWord RM(int reg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- return reg;
- }
-
- static ARMWord RS(int reg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- return reg << 8;
- }
-
- static ARMWord RD(int reg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- return reg << 12;
- }
-
- static ARMWord RN(int reg)
- {
- ASSERT(reg <= ARMRegisters::pc);
- return reg << 16;
- }
-
- static ARMWord getConditionalField(ARMWord i)
- {
- return i & ConditionalFieldMask;
- }
-
- static ARMWord toARMWord(Condition cc)
- {
- return static_cast<ARMWord>(cc);
- }
-
- static ARMWord toARMWord(uint32_t u)
- {
- return static_cast<ARMWord>(u);
- }
-
- int genInt(int reg, ARMWord imm, bool positive);
-
- ARMBuffer m_buffer;
- Jumps m_jumps;
- uint32_t m_indexOfTailOfLastWatchpoint;
- };
-
-} // namespace JSC
-
-#endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#endif // ARMAssembler_h
diff --git a/src/3rdparty/masm/assembler/AbstractMacroAssembler.h b/src/3rdparty/masm/assembler/AbstractMacroAssembler.h
index 1076384900..d0c1c4613e 100644
--- a/src/3rdparty/masm/assembler/AbstractMacroAssembler.h
+++ b/src/3rdparty/masm/assembler/AbstractMacroAssembler.h
@@ -563,12 +563,6 @@ public:
{
ASSERT((type == ARM64Assembler::JumpTestBit) || (type == ARM64Assembler::JumpTestBitFixedSize));
}
-#elif CPU(SH4)
- Jump(AssemblerLabel jmp, SH4Assembler::JumpType type = SH4Assembler::JumpFar)
- : m_label(jmp)
- , m_type(type)
- {
- }
#else
Jump(AssemblerLabel jmp)
: m_label(jmp)
@@ -598,8 +592,6 @@ public:
masm->m_assembler.linkJump(m_label, masm->m_assembler.label(), m_type, m_condition, m_bitNumber, m_compareRegister);
else
masm->m_assembler.linkJump(m_label, masm->m_assembler.label(), m_type, m_condition);
-#elif CPU(SH4)
- masm->m_assembler.linkJump(m_label, masm->m_assembler.label(), m_type);
#else
masm->m_assembler.linkJump(m_label, masm->m_assembler.label());
#endif
@@ -640,9 +632,6 @@ public:
unsigned m_bitNumber;
ARM64Assembler::RegisterID m_compareRegister;
#endif
-#if CPU(SH4)
- SH4Assembler::JumpType m_type;
-#endif
};
#endif
diff --git a/src/3rdparty/masm/assembler/AssemblerBuffer.h b/src/3rdparty/masm/assembler/AssemblerBuffer.h
index 277ec1043c..45874235b6 100644
--- a/src/3rdparty/masm/assembler/AssemblerBuffer.h
+++ b/src/3rdparty/masm/assembler/AssemblerBuffer.h
@@ -102,7 +102,7 @@ namespace JSC {
void putIntegralUnchecked(IntegralType value)
{
ASSERT(isAvailable(sizeof(IntegralType)));
- *reinterpret_cast_ptr<IntegralType*>(m_buffer + m_index) = value;
+ memcpy(m_buffer + m_index, &value, sizeof(IntegralType));
m_index += sizeof(IntegralType);
}
diff --git a/src/3rdparty/masm/assembler/LinkBuffer.cpp b/src/3rdparty/masm/assembler/LinkBuffer.cpp
index 74c278135b..44a11706c9 100644
--- a/src/3rdparty/masm/assembler/LinkBuffer.cpp
+++ b/src/3rdparty/masm/assembler/LinkBuffer.cpp
@@ -75,23 +75,6 @@ void LinkBuffer::dumpCode(void* code, size_t size)
for (unsigned i = 0; i < tsize; i++)
dataLogF("\t.short\t0x%x\n", tcode[i]);
-#elif CPU(ARM_TRADITIONAL)
- // gcc -c jit.s
- // objdump -D jit.o
- static unsigned codeCount = 0;
- unsigned int* tcode = static_cast<unsigned int*>(code);
- size_t tsize = size / sizeof(unsigned int);
- char nameBuf[128];
- snprintf(nameBuf, sizeof(nameBuf), "_jsc_jit%u", codeCount++);
- dataLogF("\t.globl\t%s\n"
- "\t.align 4\n"
- "\t.code 32\n"
- "\t.text\n"
- "# %p\n"
- "%s:\n", nameBuf, code, nameBuf);
-
- for (unsigned i = 0; i < tsize; i++)
- dataLogF("\t.long\t0x%x\n", tcode[i]);
#endif
}
#endif
diff --git a/src/3rdparty/masm/assembler/LinkBuffer.h b/src/3rdparty/masm/assembler/LinkBuffer.h
index bfd0e402ca..c79b0663c8 100644
--- a/src/3rdparty/masm/assembler/LinkBuffer.h
+++ b/src/3rdparty/masm/assembler/LinkBuffer.h
@@ -26,6 +26,8 @@
#ifndef LinkBuffer_h
#define LinkBuffer_h
+#include <Platform.h>
+
#if ENABLE(ASSEMBLER)
#define DUMP_LINK_STATISTICS 0
@@ -66,7 +68,7 @@ struct DefaultExecutableOffsetCalculator {
//
template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator>
class LinkBufferBase {
- WTF_MAKE_NONCOPYABLE(LinkBufferBase);
+ WTF_MAKE_NONCOPYABLE(LinkBufferBase)
typedef MacroAssemblerCodeRef CodeRef;
typedef MacroAssemblerCodePtr CodePtr;
typedef typename MacroAssembler::Label Label;
@@ -209,7 +211,7 @@ public:
// displaying disassembly.
inline CodeRef finalizeCodeWithoutDisassembly();
- inline CodeRef finalizeCodeWithDisassembly(const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
+ inline CodeRef finalizeCodeWithDisassembly(const char *jitKind, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4);
CodePtr trampolineAt(Label label)
{
@@ -263,9 +265,9 @@ protected:
#endif
};
-#define FINALIZE_CODE_IF(condition, linkBufferReference, dataLogFArgumentsForHeading) \
+#define FINALIZE_CODE_IF(condition, linkBufferReference, jitKind, dataLogFArgumentsForHeading) \
(UNLIKELY((condition)) \
- ? ((linkBufferReference).finalizeCodeWithDisassembly dataLogFArgumentsForHeading) \
+ ? ((linkBufferReference).finalizeCodeWithDisassembly (jitKind, dataLogFArgumentsForHeading)) \
: (linkBufferReference).finalizeCodeWithoutDisassembly())
// Use this to finalize code, like so:
@@ -284,11 +286,11 @@ protected:
// Note that the dataLogFArgumentsForHeading are only evaluated when showDisassembly
// is true, so you can hide expensive disassembly-only computations inside there.
-#define FINALIZE_CODE(linkBufferReference, dataLogFArgumentsForHeading) \
- FINALIZE_CODE_IF(Options::showDisassembly(), linkBufferReference, dataLogFArgumentsForHeading)
+#define FINALIZE_CODE(linkBufferReference, jitKind, dataLogFArgumentsForHeading) \
+ FINALIZE_CODE_IF(Options::showDisassembly(), linkBufferReference, jitKind, dataLogFArgumentsForHeading)
-#define FINALIZE_DFG_CODE(linkBufferReference, dataLogFArgumentsForHeading) \
- FINALIZE_CODE_IF((Options::showDisassembly() || Options::showDFGDisassembly()), linkBufferReference, dataLogFArgumentsForHeading)
+#define FINALIZE_DFG_CODE(linkBufferReference, jitKind, dataLogFArgumentsForHeading) \
+ FINALIZE_CODE_IF((Options::showDisassembly() || Options::showDFGDisassembly()), linkBufferReference, jitKind, dataLogFArgumentsForHeading)
template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator>
@@ -300,13 +302,13 @@ inline typename LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::Code
}
template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator>
-inline typename LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::CodeRef LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::finalizeCodeWithDisassembly(const char* format, ...)
+inline typename LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::CodeRef LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::finalizeCodeWithDisassembly(const char *jitKind, const char* format, ...)
{
ASSERT(Options::showDisassembly() || Options::showDFGDisassembly());
CodeRef result = finalizeCodeWithoutDisassembly();
- dataLogF("Generated JIT code for ");
+ dataLogF("Generated %s code for ", jitKind);
va_list argList;
va_start(argList, format);
WTF::dataLogFV(format, argList);
@@ -350,8 +352,8 @@ inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::performF
#endif
ASSERT(m_size <= INT_MAX);
- ExecutableAllocator::makeExecutable(code(), static_cast<int>(m_size));
MacroAssembler::cacheFlush(code(), m_size);
+ ExecutableAllocator::makeExecutable(code(), static_cast<int>(m_size));
}
template <typename MacroAssembler>
@@ -418,8 +420,8 @@ inline void BranchCompactingLinkBuffer<MacroAssembler>::performFinalization()
this->m_completed = true;
#endif
- ExecutableAllocator::makeExecutable(code(), m_initialSize);
MacroAssembler::cacheFlush(code(), m_size);
+ ExecutableAllocator::makeExecutable(code(), m_initialSize);
}
template <typename MacroAssembler>
@@ -518,6 +520,18 @@ public:
#endif
+#if CPU(ARM_THUMB2)
+typedef LinkBuffer<MacroAssembler<MacroAssemblerARMv7>> DefaultLinkBuffer;
+#elif CPU(ARM64)
+typedef LinkBuffer<MacroAssembler<MacroAssemblerARM64>> DefaultLinkBuffer;
+#elif CPU(MIPS)
+typedef LinkBuffer<MacroAssembler<MacroAssemblerMIPS>> DefaultLinkBuffer;
+#elif CPU(X86)
+typedef LinkBuffer<MacroAssembler<MacroAssemblerX86>> DefaultLinkBuffer;
+#elif CPU(X86_64)
+typedef LinkBuffer<MacroAssembler<MacroAssemblerX86_64>> DefaultLinkBuffer;
+#endif
+
} // namespace JSC
#endif // ENABLE(ASSEMBLER)
diff --git a/src/3rdparty/masm/assembler/MacroAssembler.h b/src/3rdparty/masm/assembler/MacroAssembler.h
index 20ddcadae1..b442a81bd0 100644
--- a/src/3rdparty/masm/assembler/MacroAssembler.h
+++ b/src/3rdparty/masm/assembler/MacroAssembler.h
@@ -39,10 +39,6 @@ namespace JSC { typedef MacroAssemblerARMv7 MacroAssemblerBase; };
#elif CPU(ARM64)
namespace JSC { typedef MacroAssemblerARM64 MacroAssemblerBase; };
-#elif CPU(ARM_TRADITIONAL)
-#include "MacroAssemblerARM.h"
-namespace JSC { typedef MacroAssemblerARM MacroAssemblerBase; };
-
#elif CPU(MIPS)
#include "MacroAssemblerMIPS.h"
namespace JSC {
@@ -57,12 +53,6 @@ namespace JSC { typedef MacroAssemblerX86 MacroAssemblerBase; };
#include "MacroAssemblerX86_64.h"
namespace JSC { typedef MacroAssemblerX86_64 MacroAssemblerBase; };
-#elif CPU(SH4)
-#include "MacroAssemblerSH4.h"
-namespace JSC {
-typedef MacroAssemblerSH4 MacroAssemblerBase;
-};
-
#else
#error "The MacroAssembler is not supported on this platform."
#endif
@@ -805,7 +795,7 @@ public:
Jump branchPtr(RelationalCondition cond, RegisterID left, RegisterID right)
{
- return branch64(cond, left, right);
+ return this->branch64(cond, left, right);
}
Jump branchPtr(RelationalCondition cond, RegisterID left, TrustedImmPtr right)
@@ -840,7 +830,7 @@ public:
Jump branchTestPtr(ResultCondition cond, RegisterID reg, TrustedImm32 mask = TrustedImm32(-1))
{
- return branchTest64(cond, reg, mask);
+ return this->branchTest64(cond, reg, mask);
}
Jump branchTestPtr(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
@@ -1489,16 +1479,12 @@ public:
typedef MacroAssembler<MacroAssemblerARMv7> DefaultMacroAssembler;
#elif CPU(ARM64)
typedef MacroAssembler<MacroAssemblerARM64> DefaultMacroAssembler;
-#elif CPU(ARM_TRADITIONAL)
-typedef MacroAssembler<MacroAssemblerARM> DefaultMacroAssembler;
#elif CPU(MIPS)
typedef MacroAssembler<MacroAssemblerMIPS> DefaultMacroAssembler;
#elif CPU(X86)
typedef MacroAssembler<MacroAssemblerX86> DefaultMacroAssembler;
#elif CPU(X86_64)
typedef MacroAssembler<MacroAssemblerX86_64> DefaultMacroAssembler;
-#elif CPU(SH4)
-typedef JSC::MacroAssemblerSH4 DefaultMacroAssembler;
#endif
} // namespace JSC
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARM.cpp b/src/3rdparty/masm/assembler/MacroAssemblerARM.cpp
deleted file mode 100644
index 3ca9c7da80..0000000000
--- a/src/3rdparty/masm/assembler/MacroAssemblerARM.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2009 University of Szeged
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#include "MacroAssemblerARM.h"
-
-#if OS(LINUX)
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <elf.h>
-#define HWCAP_VFP (1 << 6)
-#endif
-
-namespace JSC {
-
-static bool isVFPPresent()
-{
-#if OS(LINUX)
- int fd = open("/proc/self/auxv", O_RDONLY);
- if (fd > 0) {
- Elf32_auxv_t aux;
- while (read(fd, &aux, sizeof(Elf32_auxv_t))) {
- if (aux.a_type == AT_HWCAP) {
- close(fd);
- return aux.a_un.a_val & HWCAP_VFP;
- }
- }
- close(fd);
- }
-#endif
-
-#if (COMPILER(RVCT) && defined(__TARGET_FPU_VFP)) || (COMPILER(GCC) && defined(__VFP_FP__))
- return true;
-#else
- return false;
-#endif
-}
-
-const bool MacroAssemblerARM::s_isVFPPresent = isVFPPresent();
-
-#if CPU(ARMV5_OR_LOWER)
-/* On ARMv5 and below, natural alignment is required. */
-void MacroAssemblerARM::load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest)
-{
- ARMWord op2;
-
- ASSERT(address.scale >= 0 && address.scale <= 3);
- op2 = m_assembler.lsl(address.index, static_cast<int>(address.scale));
-
- if (address.offset >= 0 && address.offset + 0x2 <= 0xff) {
- m_assembler.add(ARMRegisters::S0, address.base, op2);
- m_assembler.halfDtrUp(ARMAssembler::LoadUint16, dest, ARMRegisters::S0, ARMAssembler::getOp2Half(address.offset));
- m_assembler.halfDtrUp(ARMAssembler::LoadUint16, ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Half(address.offset + 0x2));
- } else if (address.offset < 0 && address.offset >= -0xff) {
- m_assembler.add(ARMRegisters::S0, address.base, op2);
- m_assembler.halfDtrDown(ARMAssembler::LoadUint16, dest, ARMRegisters::S0, ARMAssembler::getOp2Half(-address.offset));
- m_assembler.halfDtrDown(ARMAssembler::LoadUint16, ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Half(-address.offset - 0x2));
- } else {
- m_assembler.moveImm(address.offset, ARMRegisters::S0);
- m_assembler.add(ARMRegisters::S0, ARMRegisters::S0, op2);
- m_assembler.halfDtrUpRegister(ARMAssembler::LoadUint16, dest, address.base, ARMRegisters::S0);
- m_assembler.add(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::Op2Immediate | 0x2);
- m_assembler.halfDtrUpRegister(ARMAssembler::LoadUint16, ARMRegisters::S0, address.base, ARMRegisters::S0);
- }
- m_assembler.orr(dest, dest, m_assembler.lsl(ARMRegisters::S0, 16));
-}
-#endif
-
-}
-
-#endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARM.h b/src/3rdparty/masm/assembler/MacroAssemblerARM.h
deleted file mode 100644
index 268fe5fe73..0000000000
--- a/src/3rdparty/masm/assembler/MacroAssemblerARM.h
+++ /dev/null
@@ -1,1386 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc.
- * Copyright (C) 2009, 2010 University of Szeged
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MacroAssemblerARM_h
-#define MacroAssemblerARM_h
-
-#if ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#include "ARMAssembler.h"
-#include "AbstractMacroAssembler.h"
-
-namespace JSC {
-
-class MacroAssemblerARM : public AbstractMacroAssembler<ARMAssembler> {
- static const int DoubleConditionMask = 0x0f;
- static const int DoubleConditionBitSpecial = 0x10;
- COMPILE_ASSERT(!(DoubleConditionBitSpecial & DoubleConditionMask), DoubleConditionBitSpecial_should_not_interfere_with_ARMAssembler_Condition_codes);
-public:
- typedef ARMRegisters::FPRegisterID FPRegisterID;
-
- enum RelationalCondition {
- Equal = ARMAssembler::EQ,
- NotEqual = ARMAssembler::NE,
- Above = ARMAssembler::HI,
- AboveOrEqual = ARMAssembler::CS,
- Below = ARMAssembler::CC,
- BelowOrEqual = ARMAssembler::LS,
- GreaterThan = ARMAssembler::GT,
- GreaterThanOrEqual = ARMAssembler::GE,
- LessThan = ARMAssembler::LT,
- LessThanOrEqual = ARMAssembler::LE
- };
-
- enum ResultCondition {
- Overflow = ARMAssembler::VS,
- Signed = ARMAssembler::MI,
- Zero = ARMAssembler::EQ,
- NonZero = ARMAssembler::NE
- };
-
- enum DoubleCondition {
- // These conditions will only evaluate to true if the comparison is ordered - i.e. neither operand is NaN.
- DoubleEqual = ARMAssembler::EQ,
- DoubleNotEqual = ARMAssembler::NE | DoubleConditionBitSpecial,
- DoubleGreaterThan = ARMAssembler::GT,
- DoubleGreaterThanOrEqual = ARMAssembler::GE,
- DoubleLessThan = ARMAssembler::CC,
- DoubleLessThanOrEqual = ARMAssembler::LS,
- // If either operand is NaN, these conditions always evaluate to true.
- DoubleEqualOrUnordered = ARMAssembler::EQ | DoubleConditionBitSpecial,
- DoubleNotEqualOrUnordered = ARMAssembler::NE,
- DoubleGreaterThanOrUnordered = ARMAssembler::HI,
- DoubleGreaterThanOrEqualOrUnordered = ARMAssembler::CS,
- DoubleLessThanOrUnordered = ARMAssembler::LT,
- DoubleLessThanOrEqualOrUnordered = ARMAssembler::LE,
- };
-
- static const RegisterID stackPointerRegister = ARMRegisters::sp;
- static const RegisterID linkRegister = ARMRegisters::lr;
-
- static const Scale ScalePtr = TimesFour;
-
- void add32(RegisterID src, RegisterID dest)
- {
- m_assembler.adds(dest, dest, src);
- }
-
- void add32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- m_assembler.adds(dest, op1, op2);
- }
-
- void add32(TrustedImm32 imm, Address address)
- {
- load32(address, ARMRegisters::S1);
- add32(imm, ARMRegisters::S1);
- store32(ARMRegisters::S1, address);
- }
-
- void add32(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.adds(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void add32(AbsoluteAddress src, RegisterID dest)
- {
- move(TrustedImmPtr(src.m_ptr), ARMRegisters::S1);
- m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S1, ARMRegisters::S1, 0);
- add32(ARMRegisters::S1, dest);
- }
-
- void add32(Address src, RegisterID dest)
- {
- load32(src, ARMRegisters::S1);
- add32(ARMRegisters::S1, dest);
- }
-
- void add32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.adds(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void and32(RegisterID src, RegisterID dest)
- {
- m_assembler.bitAnds(dest, dest, src);
- }
-
- void and32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- m_assembler.bitAnds(dest, op1, op2);
- }
-
- void and32(TrustedImm32 imm, RegisterID dest)
- {
- ARMWord w = m_assembler.getImm(imm.m_value, ARMRegisters::S0, true);
- if (w & ARMAssembler::Op2InvertedImmediate)
- m_assembler.bics(dest, dest, w & ~ARMAssembler::Op2InvertedImmediate);
- else
- m_assembler.bitAnds(dest, dest, w);
- }
-
- void and32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- ARMWord w = m_assembler.getImm(imm.m_value, ARMRegisters::S0, true);
- if (w & ARMAssembler::Op2InvertedImmediate)
- m_assembler.bics(dest, src, w & ~ARMAssembler::Op2InvertedImmediate);
- else
- m_assembler.bitAnds(dest, src, w);
- }
-
- void and32(Address src, RegisterID dest)
- {
- load32(src, ARMRegisters::S1);
- and32(ARMRegisters::S1, dest);
- }
-
- void lshift32(RegisterID shiftAmount, RegisterID dest)
- {
- lshift32(dest, shiftAmount, dest);
- }
-
- void lshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest)
- {
- ARMWord w = ARMAssembler::getOp2Byte(0x1f);
- m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w);
-
- m_assembler.movs(dest, m_assembler.lslRegister(src, ARMRegisters::S0));
- }
-
- void lshift32(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.movs(dest, m_assembler.lsl(dest, imm.m_value & 0x1f));
- }
-
- void lshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.movs(dest, m_assembler.lsl(src, imm.m_value & 0x1f));
- }
-
- void mul32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- if (op2 == dest) {
- if (op1 == dest) {
- move(op2, ARMRegisters::S0);
- op2 = ARMRegisters::S0;
- } else {
- // Swap the operands.
- RegisterID tmp = op1;
- op1 = op2;
- op2 = tmp;
- }
- }
- m_assembler.muls(dest, op1, op2);
- }
-
- void mul32(RegisterID src, RegisterID dest)
- {
- mul32(src, dest, dest);
- }
-
- void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- move(imm, ARMRegisters::S0);
- m_assembler.muls(dest, src, ARMRegisters::S0);
- }
-
- void neg32(RegisterID srcDest)
- {
- m_assembler.rsbs(srcDest, srcDest, ARMAssembler::getOp2Byte(0));
- }
-
- void or32(RegisterID src, RegisterID dest)
- {
- m_assembler.orrs(dest, dest, src);
- }
-
- void or32(RegisterID src, AbsoluteAddress dest)
- {
- move(TrustedImmPtr(dest.m_ptr), ARMRegisters::S0);
- load32(Address(ARMRegisters::S0), ARMRegisters::S1);
- or32(src, ARMRegisters::S1);
- store32(ARMRegisters::S1, ARMRegisters::S0);
- }
-
- void or32(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.orrs(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void or32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- m_assembler.orrs(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void or32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- m_assembler.orrs(dest, op1, op2);
- }
-
- void rshift32(RegisterID shiftAmount, RegisterID dest)
- {
- rshift32(dest, shiftAmount, dest);
- }
-
- void rshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest)
- {
- ARMWord w = ARMAssembler::getOp2Byte(0x1f);
- m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w);
-
- m_assembler.movs(dest, m_assembler.asrRegister(src, ARMRegisters::S0));
- }
-
- void rshift32(TrustedImm32 imm, RegisterID dest)
- {
- rshift32(dest, imm, dest);
- }
-
- void rshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.movs(dest, m_assembler.asr(src, imm.m_value & 0x1f));
- }
-
- void urshift32(RegisterID shiftAmount, RegisterID dest)
- {
- urshift32(dest, shiftAmount, dest);
- }
-
- void urshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest)
- {
- ARMWord w = ARMAssembler::getOp2Byte(0x1f);
- m_assembler.bitAnd(ARMRegisters::S0, shiftAmount, w);
-
- m_assembler.movs(dest, m_assembler.lsrRegister(src, ARMRegisters::S0));
- }
-
- void urshift32(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.movs(dest, m_assembler.lsr(dest, imm.m_value & 0x1f));
- }
-
- void urshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.movs(dest, m_assembler.lsr(src, imm.m_value & 0x1f));
- }
-
- void sub32(RegisterID src, RegisterID dest)
- {
- m_assembler.subs(dest, dest, src);
- }
-
- void sub32(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.subs(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void sub32(TrustedImm32 imm, Address address)
- {
- load32(address, ARMRegisters::S1);
- sub32(imm, ARMRegisters::S1);
- store32(ARMRegisters::S1, address);
- }
-
- void sub32(Address src, RegisterID dest)
- {
- load32(src, ARMRegisters::S1);
- sub32(ARMRegisters::S1, dest);
- }
-
- void sub32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.subs(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void xor32(RegisterID src, RegisterID dest)
- {
- m_assembler.eors(dest, dest, src);
- }
-
- void xor32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- m_assembler.eors(dest, op1, op2);
- }
-
- void xor32(TrustedImm32 imm, RegisterID dest)
- {
- if (imm.m_value == -1)
- m_assembler.mvns(dest, dest);
- else
- m_assembler.eors(dest, dest, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void xor32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- if (imm.m_value == -1)
- m_assembler.mvns(dest, src);
- else
- m_assembler.eors(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void countLeadingZeros32(RegisterID src, RegisterID dest)
- {
-#if WTF_ARM_ARCH_AT_LEAST(5)
- m_assembler.clz(dest, src);
-#else
- UNUSED_PARAM(src);
- UNUSED_PARAM(dest);
- RELEASE_ASSERT_NOT_REACHED();
-#endif
- }
-
- void load8(ImplicitAddress address, RegisterID dest)
- {
- m_assembler.dataTransfer32(ARMAssembler::LoadUint8, dest, address.base, address.offset);
- }
-
- void load8(BaseIndex address, RegisterID dest)
- {
- m_assembler.baseIndexTransfer32(ARMAssembler::LoadUint8, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void load8Signed(BaseIndex address, RegisterID dest)
- {
- m_assembler.baseIndexTransfer16(ARMAssembler::LoadInt8, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void load16(ImplicitAddress address, RegisterID dest)
- {
- m_assembler.dataTransfer16(ARMAssembler::LoadUint16, dest, address.base, address.offset);
- }
-
- void load16(BaseIndex address, RegisterID dest)
- {
- m_assembler.baseIndexTransfer16(ARMAssembler::LoadUint16, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void load16Signed(BaseIndex address, RegisterID dest)
- {
- m_assembler.baseIndexTransfer16(ARMAssembler::LoadInt16, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void load32(ImplicitAddress address, RegisterID dest)
- {
- m_assembler.dataTransfer32(ARMAssembler::LoadUint32, dest, address.base, address.offset);
- }
-
- void load32(BaseIndex address, RegisterID dest)
- {
- m_assembler.baseIndexTransfer32(ARMAssembler::LoadUint32, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
-#if CPU(ARMV5_OR_LOWER)
- void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest);
-#else
- void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest)
- {
- load32(address, dest);
- }
-#endif
-
- void load16Unaligned(BaseIndex address, RegisterID dest)
- {
- load16(address, dest);
- }
-
- ConvertibleLoadLabel convertibleLoadPtr(Address address, RegisterID dest)
- {
- ConvertibleLoadLabel result(this);
- ASSERT(address.offset >= 0 && address.offset <= 255);
- m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, address.base, address.offset);
- return result;
- }
-
- DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest)
- {
- DataLabel32 dataLabel(this);
- m_assembler.ldrUniqueImmediate(ARMRegisters::S0, 0);
- m_assembler.dtrUpRegister(ARMAssembler::LoadUint32, dest, address.base, ARMRegisters::S0);
- return dataLabel;
- }
-
- static bool isCompactPtrAlignedAddressOffset(ptrdiff_t value)
- {
- return value >= -4095 && value <= 4095;
- }
-
- DataLabelCompact load32WithCompactAddressOffsetPatch(Address address, RegisterID dest)
- {
- DataLabelCompact dataLabel(this);
- ASSERT(isCompactPtrAlignedAddressOffset(address.offset));
- if (address.offset >= 0)
- m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, address.base, address.offset);
- else
- m_assembler.dtrDown(ARMAssembler::LoadUint32, dest, address.base, address.offset);
- return dataLabel;
- }
-
- DataLabel32 store32WithAddressOffsetPatch(RegisterID src, Address address)
- {
- DataLabel32 dataLabel(this);
- m_assembler.ldrUniqueImmediate(ARMRegisters::S0, 0);
- m_assembler.dtrUpRegister(ARMAssembler::StoreUint32, src, address.base, ARMRegisters::S0);
- return dataLabel;
- }
-
- void store8(RegisterID src, BaseIndex address)
- {
- m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint8, src, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void store8(TrustedImm32 imm, const void* address)
- {
- move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0);
- move(imm, ARMRegisters::S1);
- m_assembler.dtrUp(ARMAssembler::StoreUint8, ARMRegisters::S1, ARMRegisters::S0, 0);
- }
-
- void store16(RegisterID src, BaseIndex address)
- {
- m_assembler.baseIndexTransfer16(ARMAssembler::StoreUint16, src, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void store32(RegisterID src, ImplicitAddress address)
- {
- m_assembler.dataTransfer32(ARMAssembler::StoreUint32, src, address.base, address.offset);
- }
-
- void store32(RegisterID src, BaseIndex address)
- {
- m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint32, src, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void store32(TrustedImm32 imm, ImplicitAddress address)
- {
- move(imm, ARMRegisters::S1);
- store32(ARMRegisters::S1, address);
- }
-
- void store32(TrustedImm32 imm, BaseIndex address)
- {
- move(imm, ARMRegisters::S1);
- m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint32, ARMRegisters::S1, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void store32(RegisterID src, const void* address)
- {
- m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address));
- m_assembler.dtrUp(ARMAssembler::StoreUint32, src, ARMRegisters::S0, 0);
- }
-
- void store32(TrustedImm32 imm, const void* address)
- {
- m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address));
- m_assembler.moveImm(imm.m_value, ARMRegisters::S1);
- m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S1, ARMRegisters::S0, 0);
- }
-
- void pop(RegisterID dest)
- {
- m_assembler.pop(dest);
- }
-
- void push(RegisterID src)
- {
- m_assembler.push(src);
- }
-
- void push(Address address)
- {
- load32(address, ARMRegisters::S1);
- push(ARMRegisters::S1);
- }
-
- void push(TrustedImm32 imm)
- {
- move(imm, ARMRegisters::S0);
- push(ARMRegisters::S0);
- }
-
- void move(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.moveImm(imm.m_value, dest);
- }
-
- void move(RegisterID src, RegisterID dest)
- {
- if (src != dest)
- m_assembler.mov(dest, src);
- }
-
- void move(TrustedImmPtr imm, RegisterID dest)
- {
- move(TrustedImm32(imm), dest);
- }
-
- void swap(RegisterID reg1, RegisterID reg2)
- {
- move(reg1, ARMRegisters::S0);
- move(reg2, reg1);
- move(ARMRegisters::S0, reg2);
- }
-
- void signExtend32ToPtr(RegisterID src, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
- }
-
- void zeroExtend32ToPtr(RegisterID src, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
- }
-
- Jump branch8(RelationalCondition cond, Address left, TrustedImm32 right)
- {
- load8(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch8(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- ASSERT(!(right.m_value & 0xFFFFFF00));
- load8(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, RegisterID right, int useConstantPool = 0)
- {
- m_assembler.cmp(left, right);
- return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool));
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, TrustedImm32 right, int useConstantPool = 0)
- {
- internalCompare32(left, right);
- return Jump(m_assembler.jmp(ARMCondition(cond), useConstantPool));
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, Address right)
- {
- load32(right, ARMRegisters::S1);
- return branch32(cond, left, ARMRegisters::S1);
- }
-
- Jump branch32(RelationalCondition cond, Address left, RegisterID right)
- {
- load32(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch32(RelationalCondition cond, Address left, TrustedImm32 right)
- {
- load32(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch32(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- load32(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch32WithUnalignedHalfWords(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- load32WithUnalignedHalfWords(left, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branchTest8(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
- {
- load8(address, ARMRegisters::S1);
- return branchTest32(cond, ARMRegisters::S1, mask);
- }
-
- Jump branchTest8(ResultCondition cond, AbsoluteAddress address, TrustedImm32 mask = TrustedImm32(-1))
- {
- move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1);
- load8(Address(ARMRegisters::S1), ARMRegisters::S1);
- return branchTest32(cond, ARMRegisters::S1, mask);
- }
-
- Jump branchTest32(ResultCondition cond, RegisterID reg, RegisterID mask)
- {
- ASSERT((cond == Zero) || (cond == NonZero));
- m_assembler.tst(reg, mask);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchTest32(ResultCondition cond, RegisterID reg, TrustedImm32 mask = TrustedImm32(-1))
- {
- ASSERT((cond == Zero) || (cond == NonZero));
- ARMWord w = m_assembler.getImm(mask.m_value, ARMRegisters::S0, true);
- if (w & ARMAssembler::Op2InvertedImmediate)
- m_assembler.bics(ARMRegisters::S0, reg, w & ~ARMAssembler::Op2InvertedImmediate);
- else
- m_assembler.tst(reg, w);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchTest32(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
- {
- load32(address, ARMRegisters::S1);
- return branchTest32(cond, ARMRegisters::S1, mask);
- }
-
- Jump branchTest32(ResultCondition cond, BaseIndex address, TrustedImm32 mask = TrustedImm32(-1))
- {
- load32(address, ARMRegisters::S1);
- return branchTest32(cond, ARMRegisters::S1, mask);
- }
-
- Jump jump()
- {
- return Jump(m_assembler.jmp());
- }
-
- void jump(RegisterID target)
- {
- m_assembler.bx(target);
- }
-
- void jump(Address address)
- {
- load32(address, ARMRegisters::pc);
- }
-
- void jump(AbsoluteAddress address)
- {
- move(TrustedImmPtr(address.m_ptr), ARMRegisters::S0);
- load32(Address(ARMRegisters::S0, 0), ARMRegisters::pc);
- }
-
- void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2)
- {
- m_assembler.vmov(dest1, dest2, src);
- }
-
- void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID)
- {
- m_assembler.vmov(dest, src1, src2);
- }
-
- Jump branchAdd32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- add32(src, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchAdd32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- add32(op1, op2, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- add32(imm, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchAdd32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- add32(src, imm, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- add32(imm, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- void mull32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- if (op2 == dest) {
- if (op1 == dest) {
- move(op2, ARMRegisters::S0);
- op2 = ARMRegisters::S0;
- } else {
- // Swap the operands.
- RegisterID tmp = op1;
- op1 = op2;
- op2 = tmp;
- }
- }
- m_assembler.mull(ARMRegisters::S1, dest, op1, op2);
- m_assembler.cmp(ARMRegisters::S1, m_assembler.asr(dest, 31));
- }
-
- Jump branchMul32(ResultCondition cond, RegisterID src1, RegisterID src2, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- if (cond == Overflow) {
- mull32(src1, src2, dest);
- cond = NonZero;
- }
- else
- mul32(src1, src2, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchMul32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- return branchMul32(cond, src, dest, dest);
- }
-
- Jump branchMul32(ResultCondition cond, TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- if (cond == Overflow) {
- move(imm, ARMRegisters::S0);
- mull32(ARMRegisters::S0, src, dest);
- cond = NonZero;
- }
- else
- mul32(imm, src, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- sub32(src, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchSub32(ResultCondition cond, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- sub32(imm, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- sub32(src, imm, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- m_assembler.subs(dest, op1, op2);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchNeg32(ResultCondition cond, RegisterID srcDest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
- neg32(srcDest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- Jump branchOr32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Signed) || (cond == Zero) || (cond == NonZero));
- or32(src, dest);
- return Jump(m_assembler.jmp(ARMCondition(cond)));
- }
-
- PatchableJump patchableBranch32(RelationalCondition cond, RegisterID reg, TrustedImm32 imm)
- {
- internalCompare32(reg, imm);
- Jump jump(m_assembler.loadBranchTarget(ARMRegisters::S1, ARMCondition(cond), true));
- m_assembler.bx(ARMRegisters::S1, ARMCondition(cond));
- return PatchableJump(jump);
- }
-
- void breakpoint()
- {
- m_assembler.bkpt(0);
- }
-
- Call nearCall()
- {
- m_assembler.loadBranchTarget(ARMRegisters::S1, ARMAssembler::AL, true);
- return Call(m_assembler.blx(ARMRegisters::S1), Call::LinkableNear);
- }
-
- Call call(RegisterID target)
- {
- return Call(m_assembler.blx(target), Call::None);
- }
-
- void call(Address address)
- {
- call32(address.base, address.offset);
- }
-
- void ret()
- {
- m_assembler.bx(linkRegister);
- }
-
- void compare32(RelationalCondition cond, RegisterID left, RegisterID right, RegisterID dest)
- {
- m_assembler.cmp(left, right);
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(0));
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond));
- }
-
- void compare32(RelationalCondition cond, RegisterID left, TrustedImm32 right, RegisterID dest)
- {
- m_assembler.cmp(left, m_assembler.getImm(right.m_value, ARMRegisters::S0));
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(0));
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond));
- }
-
- void compare8(RelationalCondition cond, Address left, TrustedImm32 right, RegisterID dest)
- {
- load8(left, ARMRegisters::S1);
- compare32(cond, ARMRegisters::S1, right, dest);
- }
-
- void test32(ResultCondition cond, RegisterID reg, TrustedImm32 mask, RegisterID dest)
- {
- if (mask.m_value == -1)
- m_assembler.cmp(0, reg);
- else
- m_assembler.tst(reg, m_assembler.getImm(mask.m_value, ARMRegisters::S0));
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(0));
- m_assembler.mov(dest, ARMAssembler::getOp2Byte(1), ARMCondition(cond));
- }
-
- void test32(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest)
- {
- load32(address, ARMRegisters::S1);
- test32(cond, ARMRegisters::S1, mask, dest);
- }
-
- void test8(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest)
- {
- load8(address, ARMRegisters::S1);
- test32(cond, ARMRegisters::S1, mask, dest);
- }
-
- void add32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- m_assembler.add(dest, src, m_assembler.getImm(imm.m_value, ARMRegisters::S0));
- }
-
- void add32(TrustedImm32 imm, AbsoluteAddress address)
- {
- load32(address.m_ptr, ARMRegisters::S1);
- add32(imm, ARMRegisters::S1);
- store32(ARMRegisters::S1, address.m_ptr);
- }
-
- void add64(TrustedImm32 imm, AbsoluteAddress address)
- {
- ARMWord tmp;
-
- move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1);
- m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S0, ARMRegisters::S1, 0);
-
- if ((tmp = ARMAssembler::getOp2(imm.m_value)) != ARMAssembler::InvalidImmediate)
- m_assembler.adds(ARMRegisters::S0, ARMRegisters::S0, tmp);
- else if ((tmp = ARMAssembler::getOp2(-imm.m_value)) != ARMAssembler::InvalidImmediate)
- m_assembler.subs(ARMRegisters::S0, ARMRegisters::S0, tmp);
- else {
- m_assembler.adds(ARMRegisters::S0, ARMRegisters::S0, m_assembler.getImm(imm.m_value, ARMRegisters::S1));
- move(TrustedImmPtr(address.m_ptr), ARMRegisters::S1);
- }
- m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S0, ARMRegisters::S1, 0);
-
- m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S0, ARMRegisters::S1, sizeof(ARMWord));
- if (imm.m_value >= 0)
- m_assembler.adc(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(0));
- else
- m_assembler.sbc(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(0));
- m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S0, ARMRegisters::S1, sizeof(ARMWord));
- }
-
- void sub32(TrustedImm32 imm, AbsoluteAddress address)
- {
- load32(address.m_ptr, ARMRegisters::S1);
- sub32(imm, ARMRegisters::S1);
- store32(ARMRegisters::S1, address.m_ptr);
- }
-
- void load32(const void* address, RegisterID dest)
- {
- m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast<ARMWord>(address));
- m_assembler.dtrUp(ARMAssembler::LoadUint32, dest, ARMRegisters::S0, 0);
- }
-
- Jump branch32(RelationalCondition cond, AbsoluteAddress left, RegisterID right)
- {
- load32(left.m_ptr, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- Jump branch32(RelationalCondition cond, AbsoluteAddress left, TrustedImm32 right)
- {
- load32(left.m_ptr, ARMRegisters::S1);
- return branch32(cond, ARMRegisters::S1, right);
- }
-
- void relativeTableJump(RegisterID index, int scale)
- {
- ASSERT(scale >= 0 && scale <= 31);
- m_assembler.add(ARMRegisters::pc, ARMRegisters::pc, m_assembler.lsl(index, scale));
-
- // NOP the default prefetching
- m_assembler.mov(ARMRegisters::r0, ARMRegisters::r0);
- }
-
- Call call()
- {
- ensureSpace(2 * sizeof(ARMWord), sizeof(ARMWord));
- m_assembler.loadBranchTarget(ARMRegisters::S1, ARMAssembler::AL, true);
- return Call(m_assembler.blx(ARMRegisters::S1), Call::Linkable);
- }
-
- Call tailRecursiveCall()
- {
- return Call::fromTailJump(jump());
- }
-
- Call makeTailRecursiveCall(Jump oldJump)
- {
- return Call::fromTailJump(oldJump);
- }
-
- DataLabelPtr moveWithPatch(TrustedImmPtr initialValue, RegisterID dest)
- {
- DataLabelPtr dataLabel(this);
- m_assembler.ldrUniqueImmediate(dest, reinterpret_cast<ARMWord>(initialValue.m_value));
- return dataLabel;
- }
-
- Jump branchPtrWithPatch(RelationalCondition cond, RegisterID left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0))
- {
- ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord));
- dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S1);
- Jump jump = branch32(cond, left, ARMRegisters::S1, true);
- return jump;
- }
-
- Jump branchPtrWithPatch(RelationalCondition cond, Address left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0))
- {
- load32(left, ARMRegisters::S1);
- ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord));
- dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S0);
- Jump jump = branch32(cond, ARMRegisters::S0, ARMRegisters::S1, true);
- return jump;
- }
-
- DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, ImplicitAddress address)
- {
- DataLabelPtr dataLabel = moveWithPatch(initialValue, ARMRegisters::S1);
- store32(ARMRegisters::S1, address);
- return dataLabel;
- }
-
- DataLabelPtr storePtrWithPatch(ImplicitAddress address)
- {
- return storePtrWithPatch(TrustedImmPtr(0), address);
- }
-
- // Floating point operators
- static bool supportsFloatingPoint()
- {
- return s_isVFPPresent;
- }
-
- static bool supportsFloatingPointTruncate()
- {
- return false;
- }
-
- static bool supportsFloatingPointSqrt()
- {
- return s_isVFPPresent;
- }
- static bool supportsFloatingPointAbs() { return false; }
-
- void loadFloat(BaseIndex address, FPRegisterID dest)
- {
- m_assembler.baseIndexTransferFloat(ARMAssembler::LoadFloat, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void loadDouble(ImplicitAddress address, FPRegisterID dest)
- {
- m_assembler.dataTransferFloat(ARMAssembler::LoadDouble, dest, address.base, address.offset);
- }
-
- void loadDouble(BaseIndex address, FPRegisterID dest)
- {
- m_assembler.baseIndexTransferFloat(ARMAssembler::LoadDouble, dest, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void loadDouble(const void* address, FPRegisterID dest)
- {
- move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0);
- m_assembler.doubleDtrUp(ARMAssembler::LoadDouble, dest, ARMRegisters::S0, 0);
- }
-
- void storeFloat(FPRegisterID src, BaseIndex address)
- {
- m_assembler.baseIndexTransferFloat(ARMAssembler::StoreFloat, src, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void storeDouble(FPRegisterID src, ImplicitAddress address)
- {
- m_assembler.dataTransferFloat(ARMAssembler::StoreDouble, src, address.base, address.offset);
- }
-
- void storeDouble(FPRegisterID src, BaseIndex address)
- {
- m_assembler.baseIndexTransferFloat(ARMAssembler::StoreDouble, src, address.base, address.index, static_cast<int>(address.scale), address.offset);
- }
-
- void storeDouble(FPRegisterID src, const void* address)
- {
- move(TrustedImm32(reinterpret_cast<ARMWord>(address)), ARMRegisters::S0);
- m_assembler.dataTransferFloat(ARMAssembler::StoreDouble, src, ARMRegisters::S0, 0);
- }
-
- void moveDouble(FPRegisterID src, FPRegisterID dest)
- {
- if (src != dest)
- m_assembler.vmov_f64(dest, src);
- }
-
- void addDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vadd_f64(dest, dest, src);
- }
-
- void addDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest)
- {
- m_assembler.vadd_f64(dest, op1, op2);
- }
-
- void addDouble(Address src, FPRegisterID dest)
- {
- loadDouble(src, ARMRegisters::SD0);
- addDouble(ARMRegisters::SD0, dest);
- }
-
- void addDouble(AbsoluteAddress address, FPRegisterID dest)
- {
- loadDouble(address.m_ptr, ARMRegisters::SD0);
- addDouble(ARMRegisters::SD0, dest);
- }
-
- void divDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vdiv_f64(dest, dest, src);
- }
-
- void divDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest)
- {
- m_assembler.vdiv_f64(dest, op1, op2);
- }
-
- void divDouble(Address src, FPRegisterID dest)
- {
- RELEASE_ASSERT_NOT_REACHED(); // Untested
- loadDouble(src, ARMRegisters::SD0);
- divDouble(ARMRegisters::SD0, dest);
- }
-
- void subDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vsub_f64(dest, dest, src);
- }
-
- void subDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest)
- {
- m_assembler.vsub_f64(dest, op1, op2);
- }
-
- void subDouble(Address src, FPRegisterID dest)
- {
- loadDouble(src, ARMRegisters::SD0);
- subDouble(ARMRegisters::SD0, dest);
- }
-
- void mulDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vmul_f64(dest, dest, src);
- }
-
- void mulDouble(Address src, FPRegisterID dest)
- {
- loadDouble(src, ARMRegisters::SD0);
- mulDouble(ARMRegisters::SD0, dest);
- }
-
- void mulDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest)
- {
- m_assembler.vmul_f64(dest, op1, op2);
- }
-
- void sqrtDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vsqrt_f64(dest, src);
- }
-
- void absDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vabs_f64(dest, src);
- }
-
- void negateDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.vneg_f64(dest, src);
- }
-
- void convertInt32ToDouble(RegisterID src, FPRegisterID dest)
- {
- m_assembler.vmov_vfp32(dest << 1, src);
- m_assembler.vcvt_f64_s32(dest, dest << 1);
- }
-
- void convertInt32ToDouble(Address src, FPRegisterID dest)
- {
- load32(src, ARMRegisters::S1);
- convertInt32ToDouble(ARMRegisters::S1, dest);
- }
-
- void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest)
- {
- move(TrustedImmPtr(src.m_ptr), ARMRegisters::S1);
- load32(Address(ARMRegisters::S1), ARMRegisters::S1);
- convertInt32ToDouble(ARMRegisters::S1, dest);
- }
-
- void convertFloatToDouble(FPRegisterID src, FPRegisterID dst)
- {
- m_assembler.vcvt_f64_f32(dst, src);
- }
-
- void convertDoubleToFloat(FPRegisterID src, FPRegisterID dst)
- {
- m_assembler.vcvt_f32_f64(dst, src);
- }
-
- Jump branchDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right)
- {
- m_assembler.vcmp_f64(left, right);
- m_assembler.vmrs_apsr();
- if (cond & DoubleConditionBitSpecial)
- m_assembler.cmp(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::VS);
- return Jump(m_assembler.jmp(static_cast<ARMAssembler::Condition>(cond & ~DoubleConditionMask)));
- }
-
- // Truncates 'src' to an integer, and places the resulting 'dest'.
- // If the result is not representable as a 32 bit value, branch.
- // May also branch for some values that are representable in 32 bits
- // (specifically, in this case, INT_MIN).
- enum BranchTruncateType { BranchIfTruncateFailed, BranchIfTruncateSuccessful };
- Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed)
- {
- truncateDoubleToInt32(src, dest);
-
- m_assembler.add(ARMRegisters::S0, dest, ARMAssembler::getOp2Byte(1));
- m_assembler.bic(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(1));
-
- ARMWord w = ARMAssembler::getOp2(0x80000000);
- ASSERT(w != ARMAssembler::InvalidImmediate);
- m_assembler.cmp(ARMRegisters::S0, w);
- return Jump(m_assembler.jmp(branchType == BranchIfTruncateFailed ? ARMAssembler::EQ : ARMAssembler::NE));
- }
-
- Jump branchTruncateDoubleToUint32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed)
- {
- truncateDoubleToUint32(src, dest);
-
- m_assembler.add(ARMRegisters::S0, dest, ARMAssembler::getOp2Byte(1));
- m_assembler.bic(ARMRegisters::S0, ARMRegisters::S0, ARMAssembler::getOp2Byte(1));
-
- m_assembler.cmp(ARMRegisters::S0, ARMAssembler::getOp2Byte(0));
- return Jump(m_assembler.jmp(branchType == BranchIfTruncateFailed ? ARMAssembler::EQ : ARMAssembler::NE));
- }
-
- // Result is undefined if the value is outside of the integer range.
- void truncateDoubleToInt32(FPRegisterID src, RegisterID dest)
- {
- m_assembler.vcvt_s32_f64(ARMRegisters::SD0 << 1, src);
- m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1);
- }
-
- void truncateDoubleToUint32(FPRegisterID src, RegisterID dest)
- {
- m_assembler.vcvt_u32_f64(ARMRegisters::SD0 << 1, src);
- m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1);
- }
-
- // Convert 'src' to an integer, and places the resulting 'dest'.
- // If the result is not representable as a 32 bit value, branch.
- // May also branch for some values that are representable in 32 bits
- // (specifically, in this case, 0).
- void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID)
- {
- m_assembler.vcvt_s32_f64(ARMRegisters::SD0 << 1, src);
- m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1);
-
- // Convert the integer result back to float & compare to the original value - if not equal or unordered (NaN) then jump.
- m_assembler.vcvt_f64_s32(ARMRegisters::SD0, ARMRegisters::SD0 << 1);
- failureCases.append(branchDouble(DoubleNotEqualOrUnordered, src, ARMRegisters::SD0));
-
- // If the result is zero, it might have been -0.0, and 0.0 equals to -0.0
- failureCases.append(branchTest32(Zero, dest));
- }
-
- Jump branchDoubleNonZero(FPRegisterID reg, FPRegisterID scratch)
- {
- m_assembler.mov(ARMRegisters::S0, ARMAssembler::getOp2Byte(0));
- convertInt32ToDouble(ARMRegisters::S0, scratch);
- return branchDouble(DoubleNotEqual, reg, scratch);
- }
-
- Jump branchDoubleZeroOrNaN(FPRegisterID reg, FPRegisterID scratch)
- {
- m_assembler.mov(ARMRegisters::S0, ARMAssembler::getOp2Byte(0));
- convertInt32ToDouble(ARMRegisters::S0, scratch);
- return branchDouble(DoubleEqualOrUnordered, reg, scratch);
- }
-
- // Invert a relational condition, e.g. == becomes !=, < becomes >=, etc.
- static RelationalCondition invert(RelationalCondition cond)
- {
- ASSERT((static_cast<uint32_t>(cond & 0x0fffffff)) == 0 && static_cast<uint32_t>(cond) < static_cast<uint32_t>(ARMAssembler::AL));
- return static_cast<RelationalCondition>(cond ^ 0x10000000);
- }
-
- void nop()
- {
- m_assembler.nop();
- }
-
- static FunctionPtr readCallTarget(CodeLocationCall call)
- {
- return FunctionPtr(reinterpret_cast<void(*)()>(ARMAssembler::readCallTarget(call.dataLocation())));
- }
-
- static void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination)
- {
- ARMAssembler::replaceWithJump(instructionStart.dataLocation(), destination.dataLocation());
- }
-
- static ptrdiff_t maxJumpReplacementSize()
- {
- ARMAssembler::maxJumpReplacementSize();
- return 0;
- }
-
- static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; }
-
- static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr)
- {
- UNREACHABLE_FOR_PLATFORM();
- return CodeLocationLabel();
- }
-
- static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
- {
- return label.labelAtOffset(0);
- }
-
- static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue)
- {
- ARMAssembler::revertBranchPtrWithPatch(instructionStart.dataLocation(), reg, reinterpret_cast<uintptr_t>(initialValue) & 0xffff);
- }
-
- static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel, Address, void*)
- {
- UNREACHABLE_FOR_PLATFORM();
- }
-
-protected:
- ARMAssembler::Condition ARMCondition(RelationalCondition cond)
- {
- return static_cast<ARMAssembler::Condition>(cond);
- }
-
- ARMAssembler::Condition ARMCondition(ResultCondition cond)
- {
- return static_cast<ARMAssembler::Condition>(cond);
- }
-
- void ensureSpace(int insnSpace, int constSpace)
- {
- m_assembler.ensureSpace(insnSpace, constSpace);
- }
-
- int sizeOfConstantPool()
- {
- return m_assembler.sizeOfConstantPool();
- }
-
- void call32(RegisterID base, int32_t offset)
- {
- load32(Address(base, offset), ARMRegisters::S1);
- m_assembler.blx(ARMRegisters::S1);
- }
-
-private:
- template <typename, template <typename> class> friend class LinkBufferBase;
- friend class RepatchBuffer;
-
- void internalCompare32(RegisterID left, TrustedImm32 right)
- {
- ARMWord tmp = (static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value);
- if (tmp != ARMAssembler::InvalidImmediate)
- m_assembler.cmn(left, tmp);
- else
- m_assembler.cmp(left, m_assembler.getImm(right.m_value, ARMRegisters::S0));
- }
-
- static void linkCall(void* code, Call call, FunctionPtr function)
- {
- ARMAssembler::linkCall(code, call.m_label, function.value());
- }
-
- static void repatchCall(CodeLocationCall call, CodeLocationLabel destination)
- {
- ARMAssembler::relinkCall(call.dataLocation(), destination.executableAddress());
- }
-
- static void repatchCall(CodeLocationCall call, FunctionPtr destination)
- {
- ARMAssembler::relinkCall(call.dataLocation(), destination.executableAddress());
- }
-
- static const bool s_isVFPPresent;
-};
-
-}
-
-#endif // ENABLE(ASSEMBLER) && CPU(ARM_TRADITIONAL)
-
-#endif // MacroAssemblerARM_h
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARM64.h b/src/3rdparty/masm/assembler/MacroAssemblerARM64.h
index ba0d7e93f8..e5a704292d 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerARM64.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerARM64.h
@@ -1126,6 +1126,11 @@ public:
m_assembler.ldrh(dest, address.base, memoryTempRegister);
}
+ void load16Unaligned(ImplicitAddress address, RegisterID dest)
+ {
+ load16(address, dest);
+ }
+
void load16Unaligned(BaseIndex address, RegisterID dest)
{
load16(address, dest);
@@ -1283,6 +1288,16 @@ public:
return label;
}
+ void storePair64(RegisterID src1, RegisterID src2, RegisterID dest)
+ {
+ storePair64(src1, src2, dest, TrustedImm32(0));
+ }
+
+ void storePair64(RegisterID src1, RegisterID src2, RegisterID dest, TrustedImm32 offset)
+ {
+ m_assembler.stp<64>(src1, src2, dest, offset.m_value);
+ }
+
void store32(RegisterID src, ImplicitAddress address)
{
if (tryStoreWithOffset<32>(src, address.base, address.offset))
@@ -1420,6 +1435,14 @@ public:
store8(dataTempRegister, address);
}
+ void getEffectiveAddress(BaseIndex address, RegisterID dest)
+ {
+ m_assembler.add<64>(dest, address.base, address.index, ARM64Assembler::LSL, address.scale);
+ if (address.offset)
+ add64(TrustedImm32(address.offset), dest);
+ }
+
+
// Floating-point operations:
static bool supportsFloatingPoint() { return true; }
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h b/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h
index d91122d4a1..99801a0e3b 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h
@@ -255,6 +255,14 @@ public:
store32(dataTempRegister, address.m_ptr);
}
+ void getEffectiveAddress(BaseIndex address, RegisterID dest)
+ {
+ m_assembler.lsl(addressTempRegister, address.index, static_cast<int>(address.scale));
+ m_assembler.add(dest, address.base, addressTempRegister);
+ if (address.offset)
+ add32(TrustedImm32(address.offset), dest);
+ }
+
void add64(TrustedImm32 imm, AbsoluteAddress address)
{
move(TrustedImmPtr(address.m_ptr), addressTempRegister);
@@ -680,6 +688,11 @@ public:
load32(setupArmAddress(address), dest);
}
+ void load16Unaligned(ImplicitAddress address, RegisterID dest)
+ {
+ load16(setupArmAddress(address), dest);
+ }
+
void load16Unaligned(BaseIndex address, RegisterID dest)
{
load16(setupArmAddress(address), dest);
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h b/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h
index e3c77d99e6..a7e78ad78f 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h
@@ -27,6 +27,7 @@
#define MacroAssemblerCodeRef_h
#include "Disassembler.h"
+#include <wtf/Platform.h>
#include "ExecutableAllocator.h"
#include "LLIntData.h"
#include <wtf/DataLog.h>
@@ -141,6 +142,8 @@ public:
ASSERT_VALID_CODE_POINTER(m_value);
}
+ inline FunctionPtr(MacroAssemblerCodePtr ptr);
+
// MSVC doesn't seem to treat functions with different calling conventions as
// different types; these methods already defined for fastcall, below.
#if CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS)
@@ -327,6 +330,12 @@ private:
void* m_value;
};
+
+FunctionPtr::FunctionPtr(MacroAssemblerCodePtr ptr)
+ : m_value(ptr.executableAddress())
+{
+}
+
// MacroAssemblerCodeRef:
//
// A reference to a section of JIT generated code. A CodeRef consists of a
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h b/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h
index f2ad6a4470..07f0ec623f 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h
@@ -27,6 +27,8 @@
#ifndef MacroAssemblerMIPS_h
#define MacroAssemblerMIPS_h
+#include <Platform.h>
+
#if ENABLE(ASSEMBLER) && CPU(MIPS)
#include "AbstractMacroAssembler.h"
@@ -268,6 +270,18 @@ public:
m_assembler.sw(dataTempRegister, addrTempRegister, 4);
}
+ void getEffectiveAddress(BaseIndex address, RegisterID dest)
+ {
+ if (!address.scale && !m_fixedWidth)
+ m_assembler.addu(dest, address.index, address.base);
+ else {
+ m_assembler.sll(addrTempRegister, address.index, address.scale);
+ m_assembler.addu(dest, addrTempRegister, address.base);
+ }
+ if (address.offset)
+ add32(TrustedImm32(address.offset), dest);
+ }
+
void and32(Address src, RegisterID dest)
{
load32(src, dataTempRegister);
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerSH4.h b/src/3rdparty/masm/assembler/MacroAssemblerSH4.h
deleted file mode 100644
index 1e5a3113bb..0000000000
--- a/src/3rdparty/masm/assembler/MacroAssemblerSH4.h
+++ /dev/null
@@ -1,2293 +0,0 @@
-/*
- * Copyright (C) 2009-2011 STMicroelectronics. All rights reserved.
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef MacroAssemblerSH4_h
-#define MacroAssemblerSH4_h
-
-#if ENABLE(ASSEMBLER) && CPU(SH4)
-
-#include "SH4Assembler.h"
-#include "AbstractMacroAssembler.h"
-#include <wtf/Assertions.h>
-
-namespace JSC {
-
-class MacroAssemblerSH4 : public AbstractMacroAssembler<SH4Assembler> {
-public:
- typedef SH4Assembler::FPRegisterID FPRegisterID;
-
- static const Scale ScalePtr = TimesFour;
- static const FPRegisterID fscratch = SH4Registers::fr10;
- static const RegisterID stackPointerRegister = SH4Registers::sp;
- static const RegisterID linkRegister = SH4Registers::pr;
- static const RegisterID scratchReg3 = SH4Registers::r13;
-
- static const int MaximumCompactPtrAlignedAddressOffset = 60;
-
- static bool isCompactPtrAlignedAddressOffset(ptrdiff_t value)
- {
- return (value >= 0) && (value <= MaximumCompactPtrAlignedAddressOffset);
- }
-
- enum RelationalCondition {
- Equal = SH4Assembler::EQ,
- NotEqual = SH4Assembler::NE,
- Above = SH4Assembler::HI,
- AboveOrEqual = SH4Assembler::HS,
- Below = SH4Assembler::LI,
- BelowOrEqual = SH4Assembler::LS,
- GreaterThan = SH4Assembler::GT,
- GreaterThanOrEqual = SH4Assembler::GE,
- LessThan = SH4Assembler::LT,
- LessThanOrEqual = SH4Assembler::LE
- };
-
- enum ResultCondition {
- Overflow = SH4Assembler::OF,
- Signed = SH4Assembler::SI,
- Zero = SH4Assembler::EQ,
- NonZero = SH4Assembler::NE
- };
-
- enum DoubleCondition {
- // These conditions will only evaluate to true if the comparison is ordered - i.e. neither operand is NaN.
- DoubleEqual = SH4Assembler::EQ,
- DoubleNotEqual = SH4Assembler::NE,
- DoubleGreaterThan = SH4Assembler::GT,
- DoubleGreaterThanOrEqual = SH4Assembler::GE,
- DoubleLessThan = SH4Assembler::LT,
- DoubleLessThanOrEqual = SH4Assembler::LE,
- // If either operand is NaN, these conditions always evaluate to true.
- DoubleEqualOrUnordered = SH4Assembler::EQU,
- DoubleNotEqualOrUnordered = SH4Assembler::NEU,
- DoubleGreaterThanOrUnordered = SH4Assembler::GTU,
- DoubleGreaterThanOrEqualOrUnordered = SH4Assembler::GEU,
- DoubleLessThanOrUnordered = SH4Assembler::LTU,
- DoubleLessThanOrEqualOrUnordered = SH4Assembler::LEU,
- };
-
- RegisterID claimScratch()
- {
- return m_assembler.claimScratch();
- }
-
- void releaseScratch(RegisterID reg)
- {
- m_assembler.releaseScratch(reg);
- }
-
- // Integer arithmetic operations
-
- void add32(RegisterID src, RegisterID dest)
- {
- m_assembler.addlRegReg(src, dest);
- }
-
- void add32(TrustedImm32 imm, RegisterID dest)
- {
- if (m_assembler.isImmediate(imm.m_value)) {
- m_assembler.addlImm8r(imm.m_value, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm.m_value, scr);
- m_assembler.addlRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void add32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- if (src != dest)
- m_assembler.movlRegReg(src, dest);
- add32(imm, dest);
- }
-
- void add32(TrustedImm32 imm, Address address)
- {
- RegisterID scr = claimScratch();
- load32(address, scr);
- add32(imm, scr);
- store32(scr, address);
- releaseScratch(scr);
- }
-
- void add32(Address src, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- load32(src, scr);
- m_assembler.addlRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void add32(AbsoluteAddress src, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- load32(src.m_ptr, scr);
- m_assembler.addlRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void and32(RegisterID src, RegisterID dest)
- {
- m_assembler.andlRegReg(src, dest);
- }
-
- void and32(TrustedImm32 imm, RegisterID dest)
- {
- if ((imm.m_value <= 255) && (imm.m_value >= 0) && (dest == SH4Registers::r0)) {
- m_assembler.andlImm8r(imm.m_value, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((imm.m_value), scr);
- m_assembler.andlRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void and32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- if (src != dest) {
- move(imm, dest);
- and32(src, dest);
- return;
- }
-
- and32(imm, dest);
- }
-
- void lshift32(RegisterID shiftamount, RegisterID dest)
- {
- if (shiftamount == SH4Registers::r0)
- m_assembler.andlImm8r(0x1f, shiftamount);
- else {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(0x1f, scr);
- m_assembler.andlRegReg(scr, shiftamount);
- releaseScratch(scr);
- }
- m_assembler.shllRegReg(dest, shiftamount);
- }
-
- void rshift32(int imm, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(-imm, scr);
- m_assembler.shaRegReg(dest, scr);
- releaseScratch(scr);
- }
-
- void lshift32(TrustedImm32 imm, RegisterID dest)
- {
- if (!imm.m_value)
- return;
-
- if ((imm.m_value == 1) || (imm.m_value == 2) || (imm.m_value == 8) || (imm.m_value == 16)) {
- m_assembler.shllImm8r(imm.m_value, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((imm.m_value & 0x1f) , scr);
- m_assembler.shllRegReg(dest, scr);
- releaseScratch(scr);
- }
-
- void lshift32(RegisterID src, TrustedImm32 shiftamount, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
-
- lshift32(shiftamount, dest);
- }
-
- void mul32(RegisterID src, RegisterID dest)
- {
- m_assembler.imullRegReg(src, dest);
- m_assembler.stsmacl(dest);
- }
-
- void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- move(imm, scr);
- if (src != dest)
- move(src, dest);
- mul32(scr, dest);
- releaseScratch(scr);
- }
-
- void or32(RegisterID src, RegisterID dest)
- {
- m_assembler.orlRegReg(src, dest);
- }
-
- void or32(TrustedImm32 imm, RegisterID dest)
- {
- if ((imm.m_value <= 255) && (imm.m_value >= 0) && (dest == SH4Registers::r0)) {
- m_assembler.orlImm8r(imm.m_value, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm.m_value, scr);
- m_assembler.orlRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void or32(RegisterID op1, RegisterID op2, RegisterID dest)
- {
- if (op1 == op2)
- move(op1, dest);
- else if (op1 == dest)
- or32(op2, dest);
- else {
- move(op2, dest);
- or32(op1, dest);
- }
- }
-
-
-void or32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- if (src != dest) {
- move(imm, dest);
- or32(src, dest);
- return;
- }
-
- or32(imm, dest);
- }
-
- void xor32(TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- if (src != dest) {
- move(imm, dest);
- xor32(src, dest);
- return;
- }
-
- xor32(imm, dest);
- }
-
- void rshift32(RegisterID shiftamount, RegisterID dest)
- {
- if (shiftamount == SH4Registers::r0)
- m_assembler.andlImm8r(0x1f, shiftamount);
- else {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(0x1f, scr);
- m_assembler.andlRegReg(scr, shiftamount);
- releaseScratch(scr);
- }
- m_assembler.neg(shiftamount, shiftamount);
- m_assembler.shaRegReg(dest, shiftamount);
- }
-
- void rshift32(TrustedImm32 imm, RegisterID dest)
- {
- if (imm.m_value & 0x1f)
- rshift32(imm.m_value & 0x1f, dest);
- }
-
- void rshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
- rshift32(imm, dest);
- }
-
- void sub32(RegisterID src, RegisterID dest)
- {
- m_assembler.sublRegReg(src, dest);
- }
-
- void sub32(TrustedImm32 imm, AbsoluteAddress address, RegisterID scratchReg)
- {
- RegisterID result = claimScratch();
-
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scratchReg);
- m_assembler.movlMemReg(scratchReg, result);
-
- if (m_assembler.isImmediate(-imm.m_value))
- m_assembler.addlImm8r(-imm.m_value, result);
- else {
- m_assembler.loadConstant(imm.m_value, scratchReg3);
- m_assembler.sublRegReg(scratchReg3, result);
- }
-
- store32(result, scratchReg);
- releaseScratch(result);
- }
-
- void sub32(TrustedImm32 imm, AbsoluteAddress address)
- {
- RegisterID result = claimScratch();
- RegisterID scratchReg = claimScratch();
-
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scratchReg);
- m_assembler.movlMemReg(scratchReg, result);
-
- if (m_assembler.isImmediate(-imm.m_value))
- m_assembler.addlImm8r(-imm.m_value, result);
- else {
- m_assembler.loadConstant(imm.m_value, scratchReg3);
- m_assembler.sublRegReg(scratchReg3, result);
- }
-
- store32(result, scratchReg);
- releaseScratch(result);
- releaseScratch(scratchReg);
- }
-
- void add32(TrustedImm32 imm, AbsoluteAddress address, RegisterID scratchReg)
- {
- RegisterID result = claimScratch();
-
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scratchReg);
- m_assembler.movlMemReg(scratchReg, result);
-
- if (m_assembler.isImmediate(imm.m_value))
- m_assembler.addlImm8r(imm.m_value, result);
- else {
- m_assembler.loadConstant(imm.m_value, scratchReg3);
- m_assembler.addlRegReg(scratchReg3, result);
- }
-
- store32(result, scratchReg);
- releaseScratch(result);
- }
-
- void add32(TrustedImm32 imm, AbsoluteAddress address)
- {
- RegisterID result = claimScratch();
- RegisterID scratchReg = claimScratch();
-
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scratchReg);
- m_assembler.movlMemReg(scratchReg, result);
-
- if (m_assembler.isImmediate(imm.m_value))
- m_assembler.addlImm8r(imm.m_value, result);
- else {
- m_assembler.loadConstant(imm.m_value, scratchReg3);
- m_assembler.addlRegReg(scratchReg3, result);
- }
-
- store32(result, scratchReg);
- releaseScratch(result);
- releaseScratch(scratchReg);
- }
-
- void add64(TrustedImm32 imm, AbsoluteAddress address)
- {
- RegisterID scr1 = claimScratch();
- RegisterID scr2 = claimScratch();
-
- // Add 32-bit LSB first.
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scr1);
- m_assembler.movlMemReg(scr1, scr1); // scr1 = 32-bit LSB of int64 @ address
- m_assembler.loadConstant(imm.m_value, scr2);
- m_assembler.clrt();
- m_assembler.addclRegReg(scr1, scr2);
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr), scr1);
- m_assembler.movlRegMem(scr2, scr1); // Update address with 32-bit LSB result.
-
- // Then add 32-bit MSB.
- m_assembler.addlImm8r(4, scr1);
- m_assembler.movlMemReg(scr1, scr1); // scr1 = 32-bit MSB of int64 @ address
- m_assembler.movt(scr2);
- if (imm.m_value < 0)
- m_assembler.addlImm8r(-1, scr2); // Sign extend imm value if needed.
- m_assembler.addvlRegReg(scr2, scr1);
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address.m_ptr) + 4, scr2);
- m_assembler.movlRegMem(scr1, scr2); // Update (address + 4) with 32-bit MSB result.
-
- releaseScratch(scr2);
- releaseScratch(scr1);
- }
-
- void sub32(TrustedImm32 imm, RegisterID dest)
- {
- if (m_assembler.isImmediate(-imm.m_value)) {
- m_assembler.addlImm8r(-imm.m_value, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm.m_value, scr);
- m_assembler.sublRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void sub32(Address src, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- load32(src, scr);
- m_assembler.sublRegReg(scr, dest);
- releaseScratch(scr);
- }
-
- void xor32(RegisterID src, RegisterID dest)
- {
- m_assembler.xorlRegReg(src, dest);
- }
-
- void xor32(TrustedImm32 imm, RegisterID srcDest)
- {
- if (imm.m_value == -1) {
- m_assembler.notlReg(srcDest, srcDest);
- return;
- }
-
- if ((srcDest != SH4Registers::r0) || (imm.m_value > 255) || (imm.m_value < 0)) {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((imm.m_value), scr);
- m_assembler.xorlRegReg(scr, srcDest);
- releaseScratch(scr);
- return;
- }
-
- m_assembler.xorlImm8r(imm.m_value, srcDest);
- }
-
- void compare32(int imm, RegisterID dst, RelationalCondition cond)
- {
- if (((cond == Equal) || (cond == NotEqual)) && (dst == SH4Registers::r0) && m_assembler.isImmediate(imm)) {
- m_assembler.cmpEqImmR0(imm, dst);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm, scr);
- m_assembler.cmplRegReg(scr, dst, SH4Condition(cond));
- releaseScratch(scr);
- }
-
- void compare32(int offset, RegisterID base, RegisterID left, RelationalCondition cond)
- {
- RegisterID scr = claimScratch();
- if (!offset) {
- m_assembler.movlMemReg(base, scr);
- m_assembler.cmplRegReg(scr, left, SH4Condition(cond));
- releaseScratch(scr);
- return;
- }
-
- if ((offset < 0) || (offset >= 64)) {
- m_assembler.loadConstant(offset, scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlMemReg(scr, scr);
- m_assembler.cmplRegReg(scr, left, SH4Condition(cond));
- releaseScratch(scr);
- return;
- }
-
- m_assembler.movlMemReg(offset >> 2, base, scr);
- m_assembler.cmplRegReg(scr, left, SH4Condition(cond));
- releaseScratch(scr);
- }
-
- void testImm(int imm, int offset, RegisterID base)
- {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
-
- if ((offset < 0) || (offset >= 64)) {
- m_assembler.loadConstant(offset, scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlMemReg(scr, scr);
- } else if (offset)
- m_assembler.movlMemReg(offset >> 2, base, scr);
- else
- m_assembler.movlMemReg(base, scr);
- if (m_assembler.isImmediate(imm))
- m_assembler.movImm8(imm, scr1);
- else
- m_assembler.loadConstant(imm, scr1);
-
- m_assembler.testlRegReg(scr, scr1);
- releaseScratch(scr);
- releaseScratch(scr1);
- }
-
- void testlImm(int imm, RegisterID dst)
- {
- if ((dst == SH4Registers::r0) && (imm <= 255) && (imm >= 0)) {
- m_assembler.testlImm8r(imm, dst);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm, scr);
- m_assembler.testlRegReg(scr, dst);
- releaseScratch(scr);
- }
-
- void compare32(RegisterID right, int offset, RegisterID base, RelationalCondition cond)
- {
- if (!offset) {
- RegisterID scr = claimScratch();
- m_assembler.movlMemReg(base, scr);
- m_assembler.cmplRegReg(right, scr, SH4Condition(cond));
- releaseScratch(scr);
- return;
- }
-
- if ((offset < 0) || (offset >= 64)) {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(offset, scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlMemReg(scr, scr);
- m_assembler.cmplRegReg(right, scr, SH4Condition(cond));
- releaseScratch(scr);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.movlMemReg(offset >> 2, base, scr);
- m_assembler.cmplRegReg(right, scr, SH4Condition(cond));
- releaseScratch(scr);
- }
-
- void compare32(int imm, int offset, RegisterID base, RelationalCondition cond)
- {
- if (!offset) {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- m_assembler.movlMemReg(base, scr);
- m_assembler.loadConstant(imm, scr1);
- m_assembler.cmplRegReg(scr1, scr, SH4Condition(cond));
- releaseScratch(scr1);
- releaseScratch(scr);
- return;
- }
-
- if ((offset < 0) || (offset >= 64)) {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- m_assembler.loadConstant(offset, scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlMemReg(scr, scr);
- m_assembler.loadConstant(imm, scr1);
- m_assembler.cmplRegReg(scr1, scr, SH4Condition(cond));
- releaseScratch(scr1);
- releaseScratch(scr);
- return;
- }
-
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- m_assembler.movlMemReg(offset >> 2, base, scr);
- m_assembler.loadConstant(imm, scr1);
- m_assembler.cmplRegReg(scr1, scr, SH4Condition(cond));
- releaseScratch(scr1);
- releaseScratch(scr);
- }
-
- // Memory access operation
-
- void load32(ImplicitAddress address, RegisterID dest)
- {
- load32(address.base, address.offset, dest);
- }
-
- void load8(ImplicitAddress address, RegisterID dest)
- {
- load8(address.base, address.offset, dest);
- }
-
- void load8(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- load8(scr, address.offset, dest);
- releaseScratch(scr);
- }
-
- void load8Signed(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- load8Signed(scr, address.offset, dest);
- releaseScratch(scr);
- }
-
- void load32(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- load32(scr, address.offset, dest);
- releaseScratch(scr);
- }
-
- void load32(const void* address, RegisterID dest)
- {
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(const_cast<void*>(address)), dest);
- m_assembler.movlMemReg(dest, dest);
- }
-
- void load32(RegisterID base, int offset, RegisterID dest)
- {
- if (!offset) {
- m_assembler.movlMemReg(base, dest);
- return;
- }
-
- if ((offset >= 0) && (offset < 64)) {
- m_assembler.movlMemReg(offset >> 2, base, dest);
- return;
- }
-
- if ((dest == SH4Registers::r0) && (dest != base)) {
- m_assembler.loadConstant((offset), dest);
- m_assembler.movlR0mr(base, dest);
- return;
- }
-
- RegisterID scr;
- if (dest == base)
- scr = claimScratch();
- else
- scr = dest;
- m_assembler.loadConstant((offset), scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlMemReg(scr, dest);
-
- if (dest == base)
- releaseScratch(scr);
- }
-
- void load8Signed(RegisterID base, int offset, RegisterID dest)
- {
- if (!offset) {
- m_assembler.movbMemReg(base, dest);
- return;
- }
-
- if ((offset > 0) && (offset < 64) && (dest == SH4Registers::r0)) {
- m_assembler.movbMemReg(offset, base, dest);
- return;
- }
-
- if (base != dest) {
- m_assembler.loadConstant((offset), dest);
- m_assembler.addlRegReg(base, dest);
- m_assembler.movbMemReg(dest, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((offset), scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movbMemReg(scr, dest);
- releaseScratch(scr);
- }
-
- void load8(RegisterID base, int offset, RegisterID dest)
- {
- if (!offset) {
- m_assembler.movbMemReg(base, dest);
- m_assembler.extub(dest, dest);
- return;
- }
-
- if ((offset > 0) && (offset < 64) && (dest == SH4Registers::r0)) {
- m_assembler.movbMemReg(offset, base, dest);
- m_assembler.extub(dest, dest);
- return;
- }
-
- if (base != dest) {
- m_assembler.loadConstant((offset), dest);
- m_assembler.addlRegReg(base, dest);
- m_assembler.movbMemReg(dest, dest);
- m_assembler.extub(dest, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((offset), scr);
- m_assembler.addlRegReg(base, scr);
- m_assembler.movbMemReg(scr, dest);
- m_assembler.extub(dest, dest);
- releaseScratch(scr);
- }
-
- void load32(RegisterID r0, RegisterID src, RegisterID dst)
- {
- ASSERT(r0 == SH4Registers::r0);
- m_assembler.movlR0mr(src, dst);
- }
-
- void load32(RegisterID src, RegisterID dst)
- {
- m_assembler.movlMemReg(src, dst);
- }
-
- void load16(ImplicitAddress address, RegisterID dest)
- {
- if (!address.offset) {
- m_assembler.movwMemReg(address.base, dest);
- extuw(dest, dest);
- return;
- }
-
- if ((address.offset > 0) && (address.offset < 64) && (dest == SH4Registers::r0)) {
- m_assembler.movwMemReg(address.offset, address.base, dest);
- extuw(dest, dest);
- return;
- }
-
- if (address.base != dest) {
- m_assembler.loadConstant((address.offset), dest);
- m_assembler.addlRegReg(address.base, dest);
- m_assembler.movwMemReg(dest, dest);
- extuw(dest, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- m_assembler.loadConstant((address.offset), scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movwMemReg(scr, dest);
- extuw(dest, dest);
- releaseScratch(scr);
- }
-
- void load16Unaligned(BaseIndex address, RegisterID dest)
- {
-
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
-
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- add32(address.base, scr);
- load8(scr, scr1);
- add32(TrustedImm32(1), scr);
- load8(scr, dest);
- m_assembler.shllImm8r(8, dest);
- or32(scr1, dest);
-
- releaseScratch(scr);
- releaseScratch(scr1);
- }
-
- void load16(RegisterID src, RegisterID dest)
- {
- m_assembler.movwMemReg(src, dest);
- extuw(dest, dest);
- }
-
- void load16Signed(RegisterID src, RegisterID dest)
- {
- m_assembler.movwMemReg(src, dest);
- }
-
- void load16(RegisterID r0, RegisterID src, RegisterID dest)
- {
- ASSERT(r0 == SH4Registers::r0);
- m_assembler.movwR0mr(src, dest);
- extuw(dest, dest);
- }
-
- void load16Signed(RegisterID r0, RegisterID src, RegisterID dest)
- {
- ASSERT(r0 == SH4Registers::r0);
- m_assembler.movwR0mr(src, dest);
- }
-
- void load16(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
-
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
- if (address.base == SH4Registers::r0)
- load16(address.base, scr, dest);
- else {
- add32(address.base, scr);
- load16(scr, dest);
- }
-
- releaseScratch(scr);
- }
-
- void load16Signed(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
-
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
- if (address.base == SH4Registers::r0)
- load16Signed(address.base, scr, dest);
- else {
- add32(address.base, scr);
- load16Signed(scr, dest);
- }
-
- releaseScratch(scr);
- }
-
- void store8(RegisterID src, BaseIndex address)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
-
- m_assembler.movbRegMem(src, scr);
-
- releaseScratch(scr);
- }
-
- void store16(RegisterID src, BaseIndex address)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
-
- m_assembler.movwRegMem(src, scr);
-
- releaseScratch(scr);
- }
-
- void store32(RegisterID src, ImplicitAddress address)
- {
- RegisterID scr = claimScratch();
- store32(src, address.offset, address.base, scr);
- releaseScratch(scr);
- }
-
- void store32(RegisterID src, int offset, RegisterID base, RegisterID scr)
- {
- if (!offset) {
- m_assembler.movlRegMem(src, base);
- return;
- }
-
- if ((offset >=0) && (offset < 64)) {
- m_assembler.movlRegMem(src, offset >> 2, base);
- return;
- }
-
- m_assembler.loadConstant((offset), scr);
- if (scr == SH4Registers::r0) {
- m_assembler.movlRegMemr0(src, base);
- return;
- }
-
- m_assembler.addlRegReg(base, scr);
- m_assembler.movlRegMem(src, scr);
- }
-
- void store32(RegisterID src, RegisterID offset, RegisterID base)
- {
- ASSERT(offset == SH4Registers::r0);
- m_assembler.movlRegMemr0(src, base);
- }
-
- void store32(RegisterID src, RegisterID dst)
- {
- m_assembler.movlRegMem(src, dst);
- }
-
- void store32(TrustedImm32 imm, ImplicitAddress address)
- {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- m_assembler.loadConstant((imm.m_value), scr);
- store32(scr, address.offset, address.base, scr1);
- releaseScratch(scr);
- releaseScratch(scr1);
- }
-
- void store32(RegisterID src, BaseIndex address)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- store32(src, Address(scr, address.offset));
-
- releaseScratch(scr);
- }
-
- void store32(TrustedImm32 imm, void* address)
- {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- m_assembler.loadConstant((imm.m_value), scr);
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address), scr1);
- m_assembler.movlRegMem(scr, scr1);
- releaseScratch(scr);
- releaseScratch(scr1);
- }
-
- void store32(RegisterID src, void* address)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address), scr);
- m_assembler.movlRegMem(src, scr);
- releaseScratch(scr);
- }
-
- DataLabel32 load32WithAddressOffsetPatch(Address address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- DataLabel32 label(this);
- m_assembler.loadConstantUnReusable(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movlMemReg(scr, dest);
- releaseScratch(scr);
- return label;
- }
-
- DataLabel32 store32WithAddressOffsetPatch(RegisterID src, Address address)
- {
- RegisterID scr = claimScratch();
- DataLabel32 label(this);
- m_assembler.loadConstantUnReusable(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movlRegMem(src, scr);
- releaseScratch(scr);
- return label;
- }
-
- DataLabelCompact load32WithCompactAddressOffsetPatch(Address address, RegisterID dest)
- {
- DataLabelCompact dataLabel(this);
- ASSERT(address.offset <= MaximumCompactPtrAlignedAddressOffset);
- ASSERT(address.offset >= 0);
- m_assembler.movlMemRegCompact(address.offset >> 2, address.base, dest);
- return dataLabel;
- }
-
- ConvertibleLoadLabel convertibleLoadPtr(Address address, RegisterID dest)
- {
- ConvertibleLoadLabel result(this);
-
- RegisterID scr = claimScratch();
- m_assembler.movImm8(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movlMemReg(scr, dest);
- releaseScratch(scr);
-
- return result;
- }
-
- // Floating-point operations
-
- static bool supportsFloatingPoint() { return true; }
- static bool supportsFloatingPointTruncate() { return true; }
- static bool supportsFloatingPointSqrt() { return true; }
- static bool supportsFloatingPointAbs() { return false; }
-
- void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2)
- {
- m_assembler.fldsfpul((FPRegisterID)(src + 1));
- m_assembler.stsfpulReg(dest1);
- m_assembler.fldsfpul(src);
- m_assembler.stsfpulReg(dest2);
- }
-
- void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID scratch)
- {
- UNUSED_PARAM(scratch);
- m_assembler.ldsrmfpul(src1);
- m_assembler.fstsfpul((FPRegisterID)(dest + 1));
- m_assembler.ldsrmfpul(src2);
- m_assembler.fstsfpul(dest);
- }
-
- void loadFloat(BaseIndex address, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- m_assembler.fmovsReadrm(scr, dest);
- releaseScratch(scr);
- }
-
- void loadDouble(BaseIndex address, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- m_assembler.fmovsReadrminc(scr, (FPRegisterID)(dest + 1));
- m_assembler.fmovsReadrm(scr, dest);
- releaseScratch(scr);
- }
-
- void loadDouble(ImplicitAddress address, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
-
- m_assembler.loadConstant(address.offset, scr);
- if (address.base == SH4Registers::r0) {
- m_assembler.fmovsReadr0r(scr, (FPRegisterID)(dest + 1));
- m_assembler.addlImm8r(4, scr);
- m_assembler.fmovsReadr0r(scr, dest);
- releaseScratch(scr);
- return;
- }
-
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.fmovsReadrminc(scr, (FPRegisterID)(dest + 1));
- m_assembler.fmovsReadrm(scr, dest);
- releaseScratch(scr);
- }
-
- void loadDouble(const void* address, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(address), scr);
- m_assembler.fmovsReadrminc(scr, (FPRegisterID)(dest + 1));
- m_assembler.fmovsReadrm(scr, dest);
- releaseScratch(scr);
- }
-
- void storeFloat(FPRegisterID src, BaseIndex address)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- m_assembler.fmovsWriterm(src, scr);
-
- releaseScratch(scr);
- }
-
- void storeDouble(FPRegisterID src, ImplicitAddress address)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.fmovsWriterm((FPRegisterID)(src + 1), scr);
- m_assembler.addlImm8r(4, scr);
- m_assembler.fmovsWriterm(src, scr);
- releaseScratch(scr);
- }
-
- void storeDouble(FPRegisterID src, BaseIndex address)
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- m_assembler.fmovsWriterm((FPRegisterID)(src + 1), scr);
- m_assembler.addlImm8r(4, scr);
- m_assembler.fmovsWriterm(src, scr);
-
- releaseScratch(scr);
- }
-
- void addDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest)
- {
- if (op1 == dest)
- m_assembler.daddRegReg(op2, dest);
- else {
- m_assembler.dmovRegReg(op1, dest);
- m_assembler.daddRegReg(op2, dest);
- }
- }
-
- void addDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.daddRegReg(src, dest);
- }
-
- void addDouble(AbsoluteAddress address, FPRegisterID dest)
- {
- loadDouble(address.m_ptr, fscratch);
- addDouble(fscratch, dest);
- }
-
- void addDouble(Address address, FPRegisterID dest)
- {
- loadDouble(address, fscratch);
- addDouble(fscratch, dest);
- }
-
- void subDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.dsubRegReg(src, dest);
- }
-
- void subDouble(Address address, FPRegisterID dest)
- {
- loadDouble(address, fscratch);
- subDouble(fscratch, dest);
- }
-
- void mulDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.dmulRegReg(src, dest);
- }
-
- void mulDouble(Address address, FPRegisterID dest)
- {
- loadDouble(address, fscratch);
- mulDouble(fscratch, dest);
- }
-
- void divDouble(FPRegisterID src, FPRegisterID dest)
- {
- m_assembler.ddivRegReg(src, dest);
- }
-
- void convertFloatToDouble(FPRegisterID src, FPRegisterID dst)
- {
- m_assembler.fldsfpul(src);
- m_assembler.dcnvsd(dst);
- }
-
- void convertDoubleToFloat(FPRegisterID src, FPRegisterID dst)
- {
- m_assembler.dcnvds(src);
- m_assembler.fstsfpul(dst);
- }
-
- void convertInt32ToDouble(RegisterID src, FPRegisterID dest)
- {
- m_assembler.ldsrmfpul(src);
- m_assembler.floatfpulDreg(dest);
- }
-
- void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(src.m_ptr), scr);
- convertInt32ToDouble(scr, dest);
- releaseScratch(scr);
- }
-
- void convertInt32ToDouble(Address src, FPRegisterID dest)
- {
- RegisterID scr = claimScratch();
- load32(src, scr);
- convertInt32ToDouble(scr, dest);
- releaseScratch(scr);
- }
-
- void load32WithUnalignedHalfWords(BaseIndex address, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- RegisterID scr1 = claimScratch();
- Jump m_jump;
- JumpList end;
-
- if (dest != SH4Registers::r0)
- move(SH4Registers::r0, scr1);
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
-
- if (address.offset)
- add32(TrustedImm32(address.offset), scr);
-
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 68, sizeof(uint32_t));
- move(scr, SH4Registers::r0);
- m_assembler.andlImm8r(0x3, SH4Registers::r0);
- m_assembler.cmpEqImmR0(0x0, SH4Registers::r0);
- m_jump = Jump(m_assembler.jne(), SH4Assembler::JumpNear);
- if (dest != SH4Registers::r0)
- move(scr1, SH4Registers::r0);
-
- load32(scr, dest);
- end.append(Jump(m_assembler.bra(), SH4Assembler::JumpNear));
- m_assembler.nop();
- m_jump.link(this);
- m_assembler.andlImm8r(0x1, SH4Registers::r0);
- m_assembler.cmpEqImmR0(0x0, SH4Registers::r0);
-
- if (dest != SH4Registers::r0)
- move(scr1, SH4Registers::r0);
-
- m_jump = Jump(m_assembler.jne(), SH4Assembler::JumpNear);
- load16(scr, scr1);
- add32(TrustedImm32(2), scr);
- load16(scr, dest);
- m_assembler.shllImm8r(16, dest);
- or32(scr1, dest);
- end.append(Jump(m_assembler.bra(), SH4Assembler::JumpNear));
- m_assembler.nop();
- m_jump.link(this);
- load8(scr, scr1);
- add32(TrustedImm32(1), scr);
- load16(scr, dest);
- m_assembler.shllImm8r(8, dest);
- or32(dest, scr1);
- add32(TrustedImm32(2), scr);
- load8(scr, dest);
- m_assembler.shllImm8r(8, dest);
- m_assembler.shllImm8r(16, dest);
- or32(scr1, dest);
- end.link(this);
-
- releaseScratch(scr);
- releaseScratch(scr1);
- }
-
- Jump branch32WithUnalignedHalfWords(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- RegisterID scr = scratchReg3;
- load32WithUnalignedHalfWords(left, scr);
- if (((cond == Equal) || (cond == NotEqual)) && !right.m_value)
- m_assembler.testlRegReg(scr, scr);
- else
- compare32(right.m_value, scr, cond);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchDoubleNonZero(FPRegisterID reg, FPRegisterID scratch)
- {
- m_assembler.movImm8(0, scratchReg3);
- convertInt32ToDouble(scratchReg3, scratch);
- return branchDouble(DoubleNotEqual, reg, scratch);
- }
-
- Jump branchDoubleZeroOrNaN(FPRegisterID reg, FPRegisterID scratch)
- {
- m_assembler.movImm8(0, scratchReg3);
- convertInt32ToDouble(scratchReg3, scratch);
- return branchDouble(DoubleEqualOrUnordered, reg, scratch);
- }
-
- Jump branchDouble(DoubleCondition cond, FPRegisterID left, FPRegisterID right)
- {
- if (cond == DoubleEqual) {
- m_assembler.dcmppeq(right, left);
- return branchTrue();
- }
-
- if (cond == DoubleNotEqual) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppeq(right, left);
- releaseScratch(scr);
- Jump m_jump = branchFalse();
- end.link(this);
- return m_jump;
- }
-
- if (cond == DoubleGreaterThan) {
- m_assembler.dcmppgt(right, left);
- return branchTrue();
- }
-
- if (cond == DoubleGreaterThanOrEqual) {
- m_assembler.dcmppgt(left, right);
- return branchFalse();
- }
-
- if (cond == DoubleLessThan) {
- m_assembler.dcmppgt(left, right);
- return branchTrue();
- }
-
- if (cond == DoubleLessThanOrEqual) {
- m_assembler.dcmppgt(right, left);
- return branchFalse();
- }
-
- if (cond == DoubleEqualOrUnordered) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppeq(left, right);
- Jump m_jump = Jump(m_assembler.je());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- if (cond == DoubleGreaterThanOrUnordered) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppgt(right, left);
- Jump m_jump = Jump(m_assembler.je());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- if (cond == DoubleGreaterThanOrEqualOrUnordered) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppgt(left, right);
- Jump m_jump = Jump(m_assembler.jne());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- if (cond == DoubleLessThanOrUnordered) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppgt(left, right);
- Jump m_jump = Jump(m_assembler.je());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- if (cond == DoubleLessThanOrEqualOrUnordered) {
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppgt(right, left);
- Jump m_jump = Jump(m_assembler.jne());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- ASSERT(cond == DoubleNotEqualOrUnordered);
- RegisterID scr = claimScratch();
- JumpList end;
- m_assembler.loadConstant(0x7fbfffff, scratchReg3);
- m_assembler.dcnvds(right);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 22, sizeof(uint32_t));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcnvds(left);
- m_assembler.stsfpulReg(scr);
- m_assembler.cmplRegReg(scratchReg3, scr, SH4Condition(Equal));
- end.append(Jump(m_assembler.je(), SH4Assembler::JumpNear));
- m_assembler.dcmppeq(right, left);
- Jump m_jump = Jump(m_assembler.jne());
- end.link(this);
- m_assembler.extraInstrForBranch(scr);
- releaseScratch(scr);
- return m_jump;
- }
-
- Jump branchTrue()
- {
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 6, sizeof(uint32_t));
- Jump m_jump = Jump(m_assembler.je());
- m_assembler.extraInstrForBranch(scratchReg3);
- return m_jump;
- }
-
- Jump branchFalse()
- {
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 6, sizeof(uint32_t));
- Jump m_jump = Jump(m_assembler.jne());
- m_assembler.extraInstrForBranch(scratchReg3);
- return m_jump;
- }
-
- Jump branch32(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- RegisterID scr = claimScratch();
- move(left.index, scr);
- lshift32(TrustedImm32(left.scale), scr);
- add32(left.base, scr);
- load32(scr, left.offset, scr);
- compare32(right.m_value, scr, cond);
- releaseScratch(scr);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- void sqrtDouble(FPRegisterID src, FPRegisterID dest)
- {
- if (dest != src)
- m_assembler.dmovRegReg(src, dest);
- m_assembler.dsqrt(dest);
- }
-
- void absDouble(FPRegisterID, FPRegisterID)
- {
- RELEASE_ASSERT_NOT_REACHED();
- }
-
- Jump branchTest8(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
- {
- RegisterID addressTempRegister = claimScratch();
- load8(address, addressTempRegister);
- Jump jmp = branchTest32(cond, addressTempRegister, mask);
- releaseScratch(addressTempRegister);
- return jmp;
- }
-
- Jump branchTest8(ResultCondition cond, AbsoluteAddress address, TrustedImm32 mask = TrustedImm32(-1))
- {
- RegisterID addressTempRegister = claimScratch();
- move(TrustedImmPtr(address.m_ptr), addressTempRegister);
- load8(Address(addressTempRegister), addressTempRegister);
- Jump jmp = branchTest32(cond, addressTempRegister, mask);
- releaseScratch(addressTempRegister);
- return jmp;
- }
-
- void signExtend32ToPtr(RegisterID src, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
- }
-
- Jump branch8(RelationalCondition cond, Address left, TrustedImm32 right)
- {
- RegisterID addressTempRegister = claimScratch();
- load8(left, addressTempRegister);
- Jump jmp = branch32(cond, addressTempRegister, right);
- releaseScratch(addressTempRegister);
- return jmp;
- }
-
- void compare8(RelationalCondition cond, Address left, TrustedImm32 right, RegisterID dest)
- {
- RegisterID addressTempRegister = claimScratch();
- load8(left, addressTempRegister);
- compare32(cond, addressTempRegister, right, dest);
- releaseScratch(addressTempRegister);
- }
-
- Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest)
- {
- m_assembler.ftrcdrmfpul(src);
- m_assembler.stsfpulReg(dest);
- m_assembler.loadConstant(0x7fffffff, scratchReg3);
- m_assembler.cmplRegReg(dest, scratchReg3, SH4Condition(Equal));
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 14, sizeof(uint32_t));
- m_assembler.branch(BT_OPCODE, 2);
- m_assembler.addlImm8r(1, scratchReg3);
- m_assembler.cmplRegReg(dest, scratchReg3, SH4Condition(Equal));
- return branchTrue();
- }
-
- // Stack manipulation operations
-
- void pop(RegisterID dest)
- {
- m_assembler.popReg(dest);
- }
-
- void push(RegisterID src)
- {
- m_assembler.pushReg(src);
- }
-
- void push(Address address)
- {
- if (!address.offset) {
- push(address.base);
- return;
- }
-
- if ((address.offset < 0) || (address.offset >= 64)) {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movlMemReg(scr, SH4Registers::sp);
- m_assembler.addlImm8r(-4, SH4Registers::sp);
- releaseScratch(scr);
- return;
- }
-
- m_assembler.movlMemReg(address.offset >> 2, address.base, SH4Registers::sp);
- m_assembler.addlImm8r(-4, SH4Registers::sp);
- }
-
- void push(TrustedImm32 imm)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(imm.m_value, scr);
- push(scr);
- releaseScratch(scr);
- }
-
- // Register move operations
-
- void move(TrustedImm32 imm, RegisterID dest)
- {
- m_assembler.loadConstant(imm.m_value, dest);
- }
-
- DataLabelPtr moveWithPatch(TrustedImmPtr initialValue, RegisterID dest)
- {
- m_assembler.ensureSpace(m_assembler.maxInstructionSize, sizeof(uint32_t));
- DataLabelPtr dataLabel(this);
- m_assembler.loadConstantUnReusable(reinterpret_cast<uint32_t>(initialValue.m_value), dest);
- return dataLabel;
- }
-
- void move(RegisterID src, RegisterID dest)
- {
- if (src != dest)
- m_assembler.movlRegReg(src, dest);
- }
-
- void move(TrustedImmPtr imm, RegisterID dest)
- {
- m_assembler.loadConstant(imm.asIntptr(), dest);
- }
-
- void extuw(RegisterID src, RegisterID dst)
- {
- m_assembler.extuw(src, dst);
- }
-
- void compare32(RelationalCondition cond, RegisterID left, RegisterID right, RegisterID dest)
- {
- m_assembler.cmplRegReg(right, left, SH4Condition(cond));
- if (cond != NotEqual) {
- m_assembler.movt(dest);
- return;
- }
-
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 4);
- m_assembler.movImm8(0, dest);
- m_assembler.branch(BT_OPCODE, 0);
- m_assembler.movImm8(1, dest);
- }
-
- void compare32(RelationalCondition cond, RegisterID left, TrustedImm32 right, RegisterID dest)
- {
- if (left != dest) {
- move(right, dest);
- compare32(cond, left, dest, dest);
- return;
- }
-
- RegisterID scr = claimScratch();
- move(right, scr);
- compare32(cond, left, scr, dest);
- releaseScratch(scr);
- }
-
- void test8(ResultCondition cond, Address address, TrustedImm32 mask, RegisterID dest)
- {
- ASSERT((cond == Zero) || (cond == NonZero));
-
- load8(address, dest);
- if (mask.m_value == -1)
- compare32(0, dest, static_cast<RelationalCondition>(cond));
- else
- testlImm(mask.m_value, dest);
- if (cond != NonZero) {
- m_assembler.movt(dest);
- return;
- }
-
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 4);
- m_assembler.movImm8(0, dest);
- m_assembler.branch(BT_OPCODE, 0);
- m_assembler.movImm8(1, dest);
- }
-
- void loadPtrLinkReg(ImplicitAddress address)
- {
- RegisterID scr = claimScratch();
- load32(address, scr);
- m_assembler.ldspr(scr);
- releaseScratch(scr);
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, RegisterID right)
- {
- m_assembler.cmplRegReg(right, left, SH4Condition(cond));
- /* BT label => BF off
- nop LDR reg
- nop braf @reg
- nop nop
- */
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, TrustedImm32 right)
- {
- if (((cond == Equal) || (cond == NotEqual)) && !right.m_value)
- m_assembler.testlRegReg(left, left);
- else
- compare32(right.m_value, left, cond);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, RegisterID left, Address right)
- {
- compare32(right.offset, right.base, left, cond);
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, Address left, RegisterID right)
- {
- compare32(right, left.offset, left.base, cond);
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, Address left, TrustedImm32 right)
- {
- compare32(right.m_value, left.offset, left.base, cond);
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, AbsoluteAddress left, RegisterID right)
- {
- RegisterID scr = claimScratch();
-
- move(TrustedImm32(reinterpret_cast<uint32_t>(left.m_ptr)), scr);
- m_assembler.cmplRegReg(right, scr, SH4Condition(cond));
- releaseScratch(scr);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch32(RelationalCondition cond, AbsoluteAddress left, TrustedImm32 right)
- {
- RegisterID addressTempRegister = claimScratch();
-
- m_assembler.loadConstant(reinterpret_cast<uint32_t>(left.m_ptr), addressTempRegister);
- m_assembler.movlMemReg(addressTempRegister, addressTempRegister);
- compare32(right.m_value, addressTempRegister, cond);
- releaseScratch(addressTempRegister);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branch8(RelationalCondition cond, BaseIndex left, TrustedImm32 right)
- {
- ASSERT(!(right.m_value & 0xFFFFFF00));
- RegisterID scr = claimScratch();
-
- move(left.index, scr);
- lshift32(TrustedImm32(left.scale), scr);
-
- if (left.offset)
- add32(TrustedImm32(left.offset), scr);
- add32(left.base, scr);
- load8(scr, scr);
- RegisterID scr1 = claimScratch();
- m_assembler.loadConstant(right.m_value, scr1);
- releaseScratch(scr);
- releaseScratch(scr1);
-
- return branch32(cond, scr, scr1);
- }
-
- Jump branchTest32(ResultCondition cond, RegisterID reg, RegisterID mask)
- {
- ASSERT((cond == Zero) || (cond == NonZero));
-
- m_assembler.testlRegReg(reg, mask);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchTest32(ResultCondition cond, RegisterID reg, TrustedImm32 mask = TrustedImm32(-1))
- {
- ASSERT((cond == Zero) || (cond == NonZero));
-
- if (mask.m_value == -1)
- m_assembler.testlRegReg(reg, reg);
- else
- testlImm(mask.m_value, reg);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchTest32(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1))
- {
- ASSERT((cond == Zero) || (cond == NonZero));
-
- if (mask.m_value == -1)
- compare32(0, address.offset, address.base, static_cast<RelationalCondition>(cond));
- else
- testImm(mask.m_value, address.offset, address.base);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchTest32(ResultCondition cond, BaseIndex address, TrustedImm32 mask = TrustedImm32(-1))
- {
- RegisterID scr = claimScratch();
-
- move(address.index, scr);
- lshift32(TrustedImm32(address.scale), scr);
- add32(address.base, scr);
- load32(scr, address.offset, scr);
-
- if (mask.m_value == -1)
- m_assembler.testlRegReg(scr, scr);
- else
- testlImm(mask.m_value, scr);
-
- releaseScratch(scr);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump jump()
- {
- return Jump(m_assembler.jmp());
- }
-
- void jump(RegisterID target)
- {
- m_assembler.jmpReg(target);
- }
-
- void jump(Address address)
- {
- RegisterID scr = claimScratch();
-
- if ((address.offset < 0) || (address.offset >= 64)) {
- m_assembler.loadConstant(address.offset, scr);
- m_assembler.addlRegReg(address.base, scr);
- m_assembler.movlMemReg(scr, scr);
- } else if (address.offset)
- m_assembler.movlMemReg(address.offset >> 2, address.base, scr);
- else
- m_assembler.movlMemReg(address.base, scr);
- m_assembler.jmpReg(scr);
-
- releaseScratch(scr);
- }
-
- // Arithmetic control flow operations
-
- Jump branchAdd32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- if (cond == Overflow) {
- m_assembler.addvlRegReg(src, dest);
- return branchTrue();
- }
-
- if (cond == Signed) {
- m_assembler.addlRegReg(src, dest);
- // Check if dest is negative
- m_assembler.cmppz(dest);
- return branchFalse();
- }
-
- m_assembler.addlRegReg(src, dest);
- compare32(0, dest, Equal);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- move(imm, scratchReg3);
- return branchAdd32(cond, scratchReg3, dest);
- }
-
- Jump branchAdd32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- if (src != dest)
- move(src, dest);
-
- if (cond == Overflow) {
- move(imm, scratchReg3);
- m_assembler.addvlRegReg(scratchReg3, dest);
- return branchTrue();
- }
-
- add32(imm, dest);
-
- if (cond == Signed) {
- m_assembler.cmppz(dest);
- return branchFalse();
- }
-
- compare32(0, dest, Equal);
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchMul32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- if (cond == Overflow) {
- RegisterID scr1 = claimScratch();
- RegisterID scr = claimScratch();
- m_assembler.dmullRegReg(src, dest);
- m_assembler.stsmacl(dest);
- m_assembler.movImm8(-31, scr);
- m_assembler.movlRegReg(dest, scr1);
- m_assembler.shaRegReg(scr1, scr);
- m_assembler.stsmach(scr);
- m_assembler.cmplRegReg(scr, scr1, SH4Condition(Equal));
- releaseScratch(scr1);
- releaseScratch(scr);
- return branchFalse();
- }
-
- m_assembler.imullRegReg(src, dest);
- m_assembler.stsmacl(dest);
- if (cond == Signed) {
- // Check if dest is negative
- m_assembler.cmppz(dest);
- return branchFalse();
- }
-
- compare32(0, dest, static_cast<RelationalCondition>(cond));
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchMul32(ResultCondition cond, TrustedImm32 imm, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- move(imm, scratchReg3);
- if (src != dest)
- move(src, dest);
-
- return branchMul32(cond, scratchReg3, dest);
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- if (cond == Overflow) {
- m_assembler.subvlRegReg(src, dest);
- return branchTrue();
- }
-
- if (cond == Signed) {
- // Check if dest is negative
- m_assembler.sublRegReg(src, dest);
- compare32(0, dest, LessThan);
- return branchTrue();
- }
-
- sub32(src, dest);
- compare32(0, dest, static_cast<RelationalCondition>(cond));
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchSub32(ResultCondition cond, TrustedImm32 imm, RegisterID dest)
- {
- ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- move(imm, scratchReg3);
- return branchSub32(cond, scratchReg3, dest);
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest)
- {
- move(imm, scratchReg3);
- if (src != dest)
- move(src, dest);
- return branchSub32(cond, scratchReg3, dest);
- }
-
- Jump branchSub32(ResultCondition cond, RegisterID src1, RegisterID src2, RegisterID dest)
- {
- if (src1 != dest)
- move(src1, dest);
- return branchSub32(cond, src2, dest);
- }
-
- Jump branchOr32(ResultCondition cond, RegisterID src, RegisterID dest)
- {
- ASSERT((cond == Signed) || (cond == Zero) || (cond == NonZero));
-
- if (cond == Signed) {
- or32(src, dest);
- compare32(0, dest, static_cast<RelationalCondition>(LessThan));
- return branchTrue();
- }
-
- or32(src, dest);
- compare32(0, dest, static_cast<RelationalCondition>(cond));
-
- if (cond == NonZero) // NotEqual
- return branchFalse();
- return branchTrue();
- }
-
- void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID fpTemp)
- {
- m_assembler.ftrcdrmfpul(src);
- m_assembler.stsfpulReg(dest);
- convertInt32ToDouble(dest, fscratch);
- failureCases.append(branchDouble(DoubleNotEqualOrUnordered, fscratch, src));
-
- if (dest == SH4Registers::r0)
- m_assembler.cmpEqImmR0(0, dest);
- else {
- m_assembler.movImm8(0, scratchReg3);
- m_assembler.cmplRegReg(scratchReg3, dest, SH4Condition(Equal));
- }
- failureCases.append(branchTrue());
- }
-
- void neg32(RegisterID dst)
- {
- m_assembler.neg(dst, dst);
- }
-
- void urshift32(RegisterID shiftamount, RegisterID dest)
- {
- if (shiftamount == SH4Registers::r0)
- m_assembler.andlImm8r(0x1f, shiftamount);
- else {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(0x1f, scr);
- m_assembler.andlRegReg(scr, shiftamount);
- releaseScratch(scr);
- }
- m_assembler.neg(shiftamount, shiftamount);
- m_assembler.shllRegReg(dest, shiftamount);
- }
-
- void urshift32(TrustedImm32 imm, RegisterID dest)
- {
- RegisterID scr = claimScratch();
- m_assembler.loadConstant(-(imm.m_value & 0x1f), scr);
- m_assembler.shaRegReg(dest, scr);
- releaseScratch(scr);
- }
-
- void urshift32(RegisterID src, TrustedImm32 shiftamount, RegisterID dest)
- {
- if (src != dest)
- move(src, dest);
-
- urshift32(shiftamount, dest);
- }
-
- Call call()
- {
- return Call(m_assembler.call(), Call::Linkable);
- }
-
- Call nearCall()
- {
- return Call(m_assembler.call(), Call::LinkableNear);
- }
-
- Call call(RegisterID target)
- {
- return Call(m_assembler.call(target), Call::None);
- }
-
- void call(Address address, RegisterID target)
- {
- load32(address.base, address.offset, target);
- m_assembler.ensureSpace(m_assembler.maxInstructionSize + 2);
- m_assembler.branch(JSR_OPCODE, target);
- m_assembler.nop();
- }
-
- void breakpoint()
- {
- m_assembler.bkpt();
- m_assembler.nop();
- }
-
- Jump branchPtrWithPatch(RelationalCondition cond, RegisterID left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0))
- {
- RegisterID dataTempRegister = claimScratch();
-
- dataLabel = moveWithPatch(initialRightValue, dataTempRegister);
- m_assembler.cmplRegReg(dataTempRegister, left, SH4Condition(cond));
- releaseScratch(dataTempRegister);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- Jump branchPtrWithPatch(RelationalCondition cond, Address left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0))
- {
- RegisterID scr = claimScratch();
-
- m_assembler.loadConstant(left.offset, scr);
- m_assembler.addlRegReg(left.base, scr);
- m_assembler.movlMemReg(scr, scr);
- RegisterID scr1 = claimScratch();
- dataLabel = moveWithPatch(initialRightValue, scr1);
- m_assembler.cmplRegReg(scr1, scr, SH4Condition(cond));
- releaseScratch(scr);
- releaseScratch(scr1);
-
- if (cond == NotEqual)
- return branchFalse();
- return branchTrue();
- }
-
- void ret()
- {
- m_assembler.ret();
- m_assembler.nop();
- }
-
- DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, ImplicitAddress address)
- {
- RegisterID scr = claimScratch();
- DataLabelPtr label = moveWithPatch(initialValue, scr);
- store32(scr, address);
- releaseScratch(scr);
- return label;
- }
-
- DataLabelPtr storePtrWithPatch(ImplicitAddress address) { return storePtrWithPatch(TrustedImmPtr(0), address); }
-
- int sizeOfConstantPool()
- {
- return m_assembler.sizeOfConstantPool();
- }
-
- Call tailRecursiveCall()
- {
- RegisterID scr = claimScratch();
-
- m_assembler.loadConstantUnReusable(0x0, scr, true);
- Jump m_jump = Jump(m_assembler.jmp(scr));
- releaseScratch(scr);
-
- return Call::fromTailJump(m_jump);
- }
-
- Call makeTailRecursiveCall(Jump oldJump)
- {
- oldJump.link(this);
- return tailRecursiveCall();
- }
-
- void nop()
- {
- m_assembler.nop();
- }
-
- static FunctionPtr readCallTarget(CodeLocationCall call)
- {
- return FunctionPtr(reinterpret_cast<void(*)()>(SH4Assembler::readCallTarget(call.dataLocation())));
- }
-
- static void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination)
- {
- RELEASE_ASSERT_NOT_REACHED();
- }
-
- static ptrdiff_t maxJumpReplacementSize()
- {
- RELEASE_ASSERT_NOT_REACHED();
- return 0;
- }
-
- static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; }
-
- static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
- {
- return label.labelAtOffset(0);
- }
-
- static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
- {
- SH4Assembler::revertJump(instructionStart.dataLocation(), reinterpret_cast<uintptr_t>(initialValue) & 0xffff);
- }
-
- static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr)
- {
- UNREACHABLE_FOR_PLATFORM();
- return CodeLocationLabel();
- }
-
- static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address, void* initialValue)
- {
- UNREACHABLE_FOR_PLATFORM();
- }
-
-protected:
- SH4Assembler::Condition SH4Condition(RelationalCondition cond)
- {
- return static_cast<SH4Assembler::Condition>(cond);
- }
-
- SH4Assembler::Condition SH4Condition(ResultCondition cond)
- {
- return static_cast<SH4Assembler::Condition>(cond);
- }
-private:
- template <typename, template <typename> class> friend class LinkBufferBase;
- friend class RepatchBuffer;
-
- static void linkCall(void*, Call, FunctionPtr);
- static void repatchCall(CodeLocationCall, CodeLocationLabel);
- static void repatchCall(CodeLocationCall, FunctionPtr);
-};
-
-} // namespace JSC
-
-#endif // ENABLE(ASSEMBLER)
-
-#endif // MacroAssemblerSH4_h
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerX86.h b/src/3rdparty/masm/assembler/MacroAssemblerX86.h
index 280cf427fc..e3e0bfe5e1 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerX86.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerX86.h
@@ -108,6 +108,11 @@ public:
m_assembler.adcl_im(imm.m_value >> 31, reinterpret_cast<const char*>(address.m_ptr) + sizeof(int32_t));
}
+ void getEffectiveAddress(BaseIndex address, RegisterID dest)
+ {
+ return x86Lea32(address, dest);
+ }
+
void and32(TrustedImm32 imm, AbsoluteAddress address)
{
m_assembler.andl_im(imm.m_value, address.m_ptr);
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerX86Common.h b/src/3rdparty/masm/assembler/MacroAssemblerX86Common.h
index 94771be6a7..769b4346ee 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerX86Common.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerX86Common.h
@@ -146,14 +146,24 @@ public:
m_assembler.andl_rr(src, dest);
}
- void add32(RegisterID op1, RegisterID op2, RegisterID dest)
+ void add32(RegisterID a, RegisterID b, RegisterID dest)
{
- if (op2 == dest) {
- add32(op1, dest);
- } else {
- move(op1, dest);
- add32(op2, dest);
+ x86Lea32(BaseIndex(a, b, TimesOne), dest);
+ }
+
+ void x86Lea32(BaseIndex index, RegisterID dest)
+ {
+ if (!index.scale && !index.offset) {
+ if (index.base == dest) {
+ add32(index.index, dest);
+ return;
+ }
+ if (index.index == dest) {
+ add32(index.base, dest);
+ return;
+ }
}
+ m_assembler.leal_mr(index.offset, index.base, index.index, index.scale, dest);
}
void and32(TrustedImm32 imm, RegisterID dest)
@@ -501,6 +511,11 @@ public:
load32(address, dest);
}
+ void load16Unaligned(ImplicitAddress address, RegisterID dest)
+ {
+ load16(address, dest);
+ }
+
void load16Unaligned(BaseIndex address, RegisterID dest)
{
load16(address, dest);
@@ -558,6 +573,11 @@ public:
m_assembler.movzwl_mr(address.offset, address.base, address.index, address.scale, dest);
}
+ void load16(ImplicitAddress address, RegisterID dest)
+ {
+ m_assembler.movzwl_mr(address.offset, address.base, dest);
+ }
+
void load16(Address address, RegisterID dest)
{
m_assembler.movzwl_mr(address.offset, address.base, dest);
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerX86_64.h b/src/3rdparty/masm/assembler/MacroAssemblerX86_64.h
index 002caaae78..f4349e1f93 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerX86_64.h
+++ b/src/3rdparty/masm/assembler/MacroAssemblerX86_64.h
@@ -243,6 +243,26 @@ public:
add64(imm, Address(scratchRegister));
}
+ void x86Lea64(BaseIndex index, RegisterID dest)
+ {
+ if (!index.scale && !index.offset) {
+ if (index.base == dest) {
+ add64(index.index, dest);
+ return;
+ }
+ if (index.index == dest) {
+ add64(index.base, dest);
+ return;
+ }
+ }
+ m_assembler.leaq_mr(index.offset, index.base, index.index, index.scale, dest);
+ }
+
+ void getEffectiveAddress(BaseIndex address, RegisterID dest)
+ {
+ return x86Lea64(address, dest);
+ }
+
void and64(RegisterID src, RegisterID dest)
{
m_assembler.andq_rr(src, dest);
diff --git a/src/3rdparty/masm/assembler/SH4Assembler.h b/src/3rdparty/masm/assembler/SH4Assembler.h
deleted file mode 100644
index b7a166ea99..0000000000
--- a/src/3rdparty/masm/assembler/SH4Assembler.h
+++ /dev/null
@@ -1,2152 +0,0 @@
-/*
- * Copyright (C) 2009-2011 STMicroelectronics. All rights reserved.
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SH4Assembler_h
-#define SH4Assembler_h
-
-#if ENABLE(ASSEMBLER) && CPU(SH4)
-
-#include "AssemblerBuffer.h"
-#include "AssemblerBufferWithConstantPool.h"
-#include "JITCompilationEffort.h"
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <wtf/Assertions.h>
-#include <wtf/DataLog.h>
-#include <wtf/Vector.h>
-
-#ifndef NDEBUG
-#define SH4_ASSEMBLER_TRACING
-#endif
-
-namespace JSC {
-typedef uint16_t SH4Word;
-
-enum {
- INVALID_OPCODE = 0xffff,
- ADD_OPCODE = 0x300c,
- ADDIMM_OPCODE = 0x7000,
- ADDC_OPCODE = 0x300e,
- ADDV_OPCODE = 0x300f,
- AND_OPCODE = 0x2009,
- ANDIMM_OPCODE = 0xc900,
- DIV0_OPCODE = 0x2007,
- DIV1_OPCODE = 0x3004,
- BF_OPCODE = 0x8b00,
- BFS_OPCODE = 0x8f00,
- BRA_OPCODE = 0xa000,
- BRAF_OPCODE = 0x0023,
- NOP_OPCODE = 0x0009,
- BSR_OPCODE = 0xb000,
- RTS_OPCODE = 0x000b,
- BT_OPCODE = 0x8900,
- BTS_OPCODE = 0x8d00,
- BSRF_OPCODE = 0x0003,
- BRK_OPCODE = 0x003b,
- FTRC_OPCODE = 0xf03d,
- CMPEQ_OPCODE = 0x3000,
- CMPEQIMM_OPCODE = 0x8800,
- CMPGE_OPCODE = 0x3003,
- CMPGT_OPCODE = 0x3007,
- CMPHI_OPCODE = 0x3006,
- CMPHS_OPCODE = 0x3002,
- CMPPL_OPCODE = 0x4015,
- CMPPZ_OPCODE = 0x4011,
- CMPSTR_OPCODE = 0x200c,
- DT_OPCODE = 0x4010,
- FCMPEQ_OPCODE = 0xf004,
- FCMPGT_OPCODE = 0xf005,
- FMOV_OPCODE = 0xf00c,
- FADD_OPCODE = 0xf000,
- FMUL_OPCODE = 0xf002,
- FSUB_OPCODE = 0xf001,
- FDIV_OPCODE = 0xf003,
- FNEG_OPCODE = 0xf04d,
- JMP_OPCODE = 0x402b,
- JSR_OPCODE = 0x400b,
- LDSPR_OPCODE = 0x402a,
- LDSLPR_OPCODE = 0x4026,
- MOV_OPCODE = 0x6003,
- MOVIMM_OPCODE = 0xe000,
- MOVB_WRITE_RN_OPCODE = 0x2000,
- MOVB_WRITE_RNDEC_OPCODE = 0x2004,
- MOVB_WRITE_R0RN_OPCODE = 0x0004,
- MOVB_WRITE_OFFGBR_OPCODE = 0xc000,
- MOVB_WRITE_OFFRN_OPCODE = 0x8000,
- MOVB_READ_RM_OPCODE = 0x6000,
- MOVB_READ_RMINC_OPCODE = 0x6004,
- MOVB_READ_R0RM_OPCODE = 0x000c,
- MOVB_READ_OFFGBR_OPCODE = 0xc400,
- MOVB_READ_OFFRM_OPCODE = 0x8400,
- MOVL_WRITE_RN_OPCODE = 0x2002,
- MOVL_WRITE_RNDEC_OPCODE = 0x2006,
- MOVL_WRITE_R0RN_OPCODE = 0x0006,
- MOVL_WRITE_OFFGBR_OPCODE = 0xc200,
- MOVL_WRITE_OFFRN_OPCODE = 0x1000,
- MOVL_READ_RM_OPCODE = 0x6002,
- MOVL_READ_RMINC_OPCODE = 0x6006,
- MOVL_READ_R0RM_OPCODE = 0x000e,
- MOVL_READ_OFFGBR_OPCODE = 0xc600,
- MOVL_READ_OFFPC_OPCODE = 0xd000,
- MOVL_READ_OFFRM_OPCODE = 0x5000,
- MOVW_WRITE_RN_OPCODE = 0x2001,
- MOVW_READ_RM_OPCODE = 0x6001,
- MOVW_READ_R0RM_OPCODE = 0x000d,
- MOVW_READ_OFFRM_OPCODE = 0x8500,
- MOVW_READ_OFFPC_OPCODE = 0x9000,
- MOVA_READ_OFFPC_OPCODE = 0xc700,
- MOVT_OPCODE = 0x0029,
- MULL_OPCODE = 0x0007,
- DMULL_L_OPCODE = 0x3005,
- STSMACL_OPCODE = 0x001a,
- STSMACH_OPCODE = 0x000a,
- DMULSL_OPCODE = 0x300d,
- NEG_OPCODE = 0x600b,
- NEGC_OPCODE = 0x600a,
- NOT_OPCODE = 0x6007,
- OR_OPCODE = 0x200b,
- ORIMM_OPCODE = 0xcb00,
- ORBIMM_OPCODE = 0xcf00,
- SETS_OPCODE = 0x0058,
- SETT_OPCODE = 0x0018,
- SHAD_OPCODE = 0x400c,
- SHAL_OPCODE = 0x4020,
- SHAR_OPCODE = 0x4021,
- SHLD_OPCODE = 0x400d,
- SHLL_OPCODE = 0x4000,
- SHLL2_OPCODE = 0x4008,
- SHLL8_OPCODE = 0x4018,
- SHLL16_OPCODE = 0x4028,
- SHLR_OPCODE = 0x4001,
- SHLR2_OPCODE = 0x4009,
- SHLR8_OPCODE = 0x4019,
- SHLR16_OPCODE = 0x4029,
- STSPR_OPCODE = 0x002a,
- STSLPR_OPCODE = 0x4022,
- FLOAT_OPCODE = 0xf02d,
- SUB_OPCODE = 0x3008,
- SUBC_OPCODE = 0x300a,
- SUBV_OPCODE = 0x300b,
- TST_OPCODE = 0x2008,
- TSTIMM_OPCODE = 0xc800,
- TSTB_OPCODE = 0xcc00,
- EXTUB_OPCODE = 0x600c,
- EXTUW_OPCODE = 0x600d,
- XOR_OPCODE = 0x200a,
- XORIMM_OPCODE = 0xca00,
- XORB_OPCODE = 0xce00,
- FMOVS_READ_RM_INC_OPCODE = 0xf009,
- FMOVS_READ_RM_OPCODE = 0xf008,
- FMOVS_READ_R0RM_OPCODE = 0xf006,
- FMOVS_WRITE_RN_OPCODE = 0xf00a,
- FMOVS_WRITE_RN_DEC_OPCODE = 0xf00b,
- FMOVS_WRITE_R0RN_OPCODE = 0xf007,
- FCNVDS_DRM_FPUL_OPCODE = 0xf0bd,
- FCNVSD_FPUL_DRN_OPCODE = 0xf0ad,
- LDS_RM_FPUL_OPCODE = 0x405a,
- FLDS_FRM_FPUL_OPCODE = 0xf01d,
- STS_FPUL_RN_OPCODE = 0x005a,
- FSTS_FPUL_FRN_OPCODE = 0xF00d,
- LDSFPSCR_OPCODE = 0x406a,
- STSFPSCR_OPCODE = 0x006a,
- LDSRMFPUL_OPCODE = 0x405a,
- FSTSFPULFRN_OPCODE = 0xf00d,
- FSQRT_OPCODE = 0xf06d,
- FSCHG_OPCODE = 0xf3fd,
- CLRT_OPCODE = 8,
-};
-
-namespace SH4Registers {
-typedef enum {
- r0,
- r1,
- r2,
- r3,
- r4,
- r5,
- r6,
- r7,
- r8,
- r9,
- r10,
- r11,
- r12,
- r13,
- r14, fp = r14,
- r15, sp = r15,
- pc,
- pr,
-} RegisterID;
-
-typedef enum {
- fr0, dr0 = fr0,
- fr1,
- fr2, dr2 = fr2,
- fr3,
- fr4, dr4 = fr4,
- fr5,
- fr6, dr6 = fr6,
- fr7,
- fr8, dr8 = fr8,
- fr9,
- fr10, dr10 = fr10,
- fr11,
- fr12, dr12 = fr12,
- fr13,
- fr14, dr14 = fr14,
- fr15,
-} FPRegisterID;
-}
-
-inline uint16_t getOpcodeGroup1(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0xf) << 8) | ((rn & 0xf) << 4));
-}
-
-inline uint16_t getOpcodeGroup2(uint16_t opc, int rm)
-{
- return (opc | ((rm & 0xf) << 8));
-}
-
-inline uint16_t getOpcodeGroup3(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0xf) << 8) | (rn & 0xff));
-}
-
-inline uint16_t getOpcodeGroup4(uint16_t opc, int rm, int rn, int offset)
-{
- return (opc | ((rm & 0xf) << 8) | ((rn & 0xf) << 4) | (offset & 0xf));
-}
-
-inline uint16_t getOpcodeGroup5(uint16_t opc, int rm)
-{
- return (opc | (rm & 0xff));
-}
-
-inline uint16_t getOpcodeGroup6(uint16_t opc, int rm)
-{
- return (opc | (rm & 0xfff));
-}
-
-inline uint16_t getOpcodeGroup7(uint16_t opc, int rm)
-{
- return (opc | ((rm & 0x7) << 9));
-}
-
-inline uint16_t getOpcodeGroup8(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0x7) << 9) | ((rn & 0x7) << 5));
-}
-
-inline uint16_t getOpcodeGroup9(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0xf) << 8) | ((rn & 0x7) << 5));
-}
-
-inline uint16_t getOpcodeGroup10(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0x7) << 9) | ((rn & 0xf) << 4));
-}
-
-inline uint16_t getOpcodeGroup11(uint16_t opc, int rm, int rn)
-{
- return (opc | ((rm & 0xf) << 4) | (rn & 0xf));
-}
-
-inline uint16_t getRn(uint16_t x)
-{
- return ((x & 0xf00) >> 8);
-}
-
-inline uint16_t getRm(uint16_t x)
-{
- return ((x & 0xf0) >> 4);
-}
-
-inline uint16_t getDisp(uint16_t x)
-{
- return (x & 0xf);
-}
-
-inline uint16_t getImm8(uint16_t x)
-{
- return (x & 0xff);
-}
-
-inline uint16_t getImm12(uint16_t x)
-{
- return (x & 0xfff);
-}
-
-inline uint16_t getDRn(uint16_t x)
-{
- return ((x & 0xe00) >> 9);
-}
-
-inline uint16_t getDRm(uint16_t x)
-{
- return ((x & 0xe0) >> 5);
-}
-
-class SH4Assembler {
-public:
- typedef SH4Registers::RegisterID RegisterID;
- typedef SH4Registers::FPRegisterID FPRegisterID;
- typedef AssemblerBufferWithConstantPool<512, 4, 2, SH4Assembler> SH4Buffer;
- static const RegisterID scratchReg1 = SH4Registers::r3;
- static const RegisterID scratchReg2 = SH4Registers::r11;
- static const uint32_t maxInstructionSize = 16;
-
- enum {
- padForAlign8 = 0x00,
- padForAlign16 = 0x0009,
- padForAlign32 = 0x00090009,
- };
-
- enum JumpType {
- JumpFar,
- JumpNear
- };
-
- SH4Assembler()
- {
- m_claimscratchReg = 0x0;
- }
-
- // SH4 condition codes
- typedef enum {
- EQ = 0x0, // Equal
- NE = 0x1, // Not Equal
- HS = 0x2, // Unsigend Greater Than equal
- HI = 0x3, // Unsigend Greater Than
- LS = 0x4, // Unsigend Lower or Same
- LI = 0x5, // Unsigend Lower
- GE = 0x6, // Greater or Equal
- LT = 0x7, // Less Than
- GT = 0x8, // Greater Than
- LE = 0x9, // Less or Equal
- OF = 0xa, // OverFlow
- SI = 0xb, // Signed
- EQU= 0xc, // Equal or unordered(NaN)
- NEU= 0xd,
- GTU= 0xe,
- GEU= 0xf,
- LTU= 0x10,
- LEU= 0x11,
- } Condition;
-
- // Opaque label types
-public:
- bool isImmediate(int constant)
- {
- return ((constant <= 127) && (constant >= -128));
- }
-
- RegisterID claimScratch()
- {
- ASSERT((m_claimscratchReg != 0x3));
-
- if (!(m_claimscratchReg & 0x1)) {
- m_claimscratchReg = (m_claimscratchReg | 0x1);
- return scratchReg1;
- }
-
- m_claimscratchReg = (m_claimscratchReg | 0x2);
- return scratchReg2;
- }
-
- void releaseScratch(RegisterID scratchR)
- {
- if (scratchR == scratchReg1)
- m_claimscratchReg = (m_claimscratchReg & 0x2);
- else
- m_claimscratchReg = (m_claimscratchReg & 0x1);
- }
-
- // Stack operations
-
- void pushReg(RegisterID reg)
- {
- if (reg == SH4Registers::pr) {
- oneShortOp(getOpcodeGroup2(STSLPR_OPCODE, SH4Registers::sp));
- return;
- }
-
- oneShortOp(getOpcodeGroup1(MOVL_WRITE_RNDEC_OPCODE, SH4Registers::sp, reg));
- }
-
- void popReg(RegisterID reg)
- {
- if (reg == SH4Registers::pr) {
- oneShortOp(getOpcodeGroup2(LDSLPR_OPCODE, SH4Registers::sp));
- return;
- }
-
- oneShortOp(getOpcodeGroup1(MOVL_READ_RMINC_OPCODE, reg, SH4Registers::sp));
- }
-
- void movt(RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup2(MOVT_OPCODE, dst);
- oneShortOp(opc);
- }
-
- // Arithmetic operations
-
- void addlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(ADD_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void addclRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(ADDC_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void addvlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(ADDV_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void addlImm8r(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 127) && (imm8 >= -128));
-
- uint16_t opc = getOpcodeGroup3(ADDIMM_OPCODE, dst, imm8);
- oneShortOp(opc);
- }
-
- void andlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(AND_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void andlImm8r(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 255) && (imm8 >= 0));
- ASSERT(dst == SH4Registers::r0);
-
- uint16_t opc = getOpcodeGroup5(ANDIMM_OPCODE, imm8);
- oneShortOp(opc);
- }
-
- void div1lRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(DIV1_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void div0lRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(DIV0_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void notlReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(NOT_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void orlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(OR_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void orlImm8r(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 255) && (imm8 >= 0));
- ASSERT(dst == SH4Registers::r0);
-
- uint16_t opc = getOpcodeGroup5(ORIMM_OPCODE, imm8);
- oneShortOp(opc);
- }
-
- void sublRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(SUB_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void subvlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(SUBV_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void xorlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(XOR_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void xorlImm8r(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 255) && (imm8 >= 0));
- ASSERT(dst == SH4Registers::r0);
-
- uint16_t opc = getOpcodeGroup5(XORIMM_OPCODE, imm8);
- oneShortOp(opc);
- }
-
- void shllImm8r(int imm, RegisterID dst)
- {
- switch (imm) {
- case 1:
- oneShortOp(getOpcodeGroup2(SHLL_OPCODE, dst));
- break;
- case 2:
- oneShortOp(getOpcodeGroup2(SHLL2_OPCODE, dst));
- break;
- case 8:
- oneShortOp(getOpcodeGroup2(SHLL8_OPCODE, dst));
- break;
- case 16:
- oneShortOp(getOpcodeGroup2(SHLL16_OPCODE, dst));
- break;
- default:
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
-
- void neg(RegisterID dst, RegisterID src)
- {
- uint16_t opc = getOpcodeGroup1(NEG_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void shllRegReg(RegisterID dst, RegisterID rShift)
- {
- uint16_t opc = getOpcodeGroup1(SHLD_OPCODE, dst, rShift);
- oneShortOp(opc);
- }
-
- void shlrRegReg(RegisterID dst, RegisterID rShift)
- {
- neg(rShift, rShift);
- shllRegReg(dst, rShift);
- }
-
- void sharRegReg(RegisterID dst, RegisterID rShift)
- {
- neg(rShift, rShift);
- shaRegReg(dst, rShift);
- }
-
- void shaRegReg(RegisterID dst, RegisterID rShift)
- {
- uint16_t opc = getOpcodeGroup1(SHAD_OPCODE, dst, rShift);
- oneShortOp(opc);
- }
-
- void shlrImm8r(int imm, RegisterID dst)
- {
- switch (imm) {
- case 1:
- oneShortOp(getOpcodeGroup2(SHLR_OPCODE, dst));
- break;
- case 2:
- oneShortOp(getOpcodeGroup2(SHLR2_OPCODE, dst));
- break;
- case 8:
- oneShortOp(getOpcodeGroup2(SHLR8_OPCODE, dst));
- break;
- case 16:
- oneShortOp(getOpcodeGroup2(SHLR16_OPCODE, dst));
- break;
- default:
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
-
- void imullRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MULL_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void dmullRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(DMULL_L_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void dmulslRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(DMULSL_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void stsmacl(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(STSMACL_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void stsmach(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(STSMACH_OPCODE, reg);
- oneShortOp(opc);
- }
-
- // Comparisons
-
- void cmplRegReg(RegisterID left, RegisterID right, Condition cond)
- {
- switch (cond) {
- case NE:
- oneShortOp(getOpcodeGroup1(CMPEQ_OPCODE, right, left));
- break;
- case GT:
- oneShortOp(getOpcodeGroup1(CMPGT_OPCODE, right, left));
- break;
- case EQ:
- oneShortOp(getOpcodeGroup1(CMPEQ_OPCODE, right, left));
- break;
- case GE:
- oneShortOp(getOpcodeGroup1(CMPGE_OPCODE, right, left));
- break;
- case HS:
- oneShortOp(getOpcodeGroup1(CMPHS_OPCODE, right, left));
- break;
- case HI:
- oneShortOp(getOpcodeGroup1(CMPHI_OPCODE, right, left));
- break;
- case LI:
- oneShortOp(getOpcodeGroup1(CMPHI_OPCODE, left, right));
- break;
- case LS:
- oneShortOp(getOpcodeGroup1(CMPHS_OPCODE, left, right));
- break;
- case LE:
- oneShortOp(getOpcodeGroup1(CMPGE_OPCODE, left, right));
- break;
- case LT:
- oneShortOp(getOpcodeGroup1(CMPGT_OPCODE, left, right));
- break;
- default:
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
-
- void cmppl(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(CMPPL_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void cmppz(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(CMPPZ_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void cmpEqImmR0(int imm, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup5(CMPEQIMM_OPCODE, imm);
- oneShortOp(opc);
- }
-
- void testlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(TST_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void testlImm8r(int imm, RegisterID dst)
- {
- ASSERT((dst == SH4Registers::r0) && (imm <= 255) && (imm >= 0));
-
- uint16_t opc = getOpcodeGroup5(TSTIMM_OPCODE, imm);
- oneShortOp(opc);
- }
-
- void nop()
- {
- oneShortOp(NOP_OPCODE, false);
- }
-
- void sett()
- {
- oneShortOp(SETT_OPCODE);
- }
-
- void clrt()
- {
- oneShortOp(CLRT_OPCODE);
- }
-
- void fschg()
- {
- oneShortOp(FSCHG_OPCODE);
- }
-
- void bkpt()
- {
- oneShortOp(BRK_OPCODE, false);
- }
-
- void branch(uint16_t opc, int label)
- {
- switch (opc) {
- case BT_OPCODE:
- ASSERT((label <= 127) && (label >= -128));
- oneShortOp(getOpcodeGroup5(BT_OPCODE, label));
- break;
- case BRA_OPCODE:
- ASSERT((label <= 2047) && (label >= -2048));
- oneShortOp(getOpcodeGroup6(BRA_OPCODE, label));
- break;
- case BF_OPCODE:
- ASSERT((label <= 127) && (label >= -128));
- oneShortOp(getOpcodeGroup5(BF_OPCODE, label));
- break;
- default:
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
-
- void branch(uint16_t opc, RegisterID reg)
- {
- switch (opc) {
- case BRAF_OPCODE:
- oneShortOp(getOpcodeGroup2(BRAF_OPCODE, reg));
- break;
- case JMP_OPCODE:
- oneShortOp(getOpcodeGroup2(JMP_OPCODE, reg));
- break;
- case JSR_OPCODE:
- oneShortOp(getOpcodeGroup2(JSR_OPCODE, reg));
- break;
- case BSRF_OPCODE:
- oneShortOp(getOpcodeGroup2(BSRF_OPCODE, reg));
- break;
- default:
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
-
- void ldspr(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(LDSPR_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void stspr(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(STSPR_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void extub(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(EXTUB_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void extuw(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(EXTUW_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- // float operations
-
- void ldsrmfpul(RegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(LDS_RM_FPUL_OPCODE, src);
- oneShortOp(opc);
- }
-
- void fneg(FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup2(FNEG_OPCODE, dst);
- oneShortOp(opc, true, false);
- }
-
- void fsqrt(FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup2(FSQRT_OPCODE, dst);
- oneShortOp(opc, true, false);
- }
-
- void stsfpulReg(RegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(STS_FPUL_RN_OPCODE, src);
- oneShortOp(opc);
- }
-
- void floatfpulfrn(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(FLOAT_OPCODE, src);
- oneShortOp(opc, true, false);
- }
-
- void fmull(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMUL_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsReadrm(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_READ_RM_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsWriterm(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_WRITE_RN_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsWriter0r(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_WRITE_R0RN_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsReadr0r(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_READ_R0RM_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsReadrminc(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_READ_RM_INC_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void fmovsWriterndec(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(FMOVS_WRITE_RN_DEC_OPCODE, dst, src);
- oneShortOp(opc, true, false);
- }
-
- void ftrcRegfpul(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(FTRC_OPCODE, src);
- oneShortOp(opc, true, false);
- }
-
- void fldsfpul(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(FLDS_FRM_FPUL_OPCODE, src);
- oneShortOp(opc);
- }
-
- void fstsfpul(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup2(FSTS_FPUL_FRN_OPCODE, src);
- oneShortOp(opc);
- }
-
- void ldsfpscr(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(LDSFPSCR_OPCODE, reg);
- oneShortOp(opc);
- }
-
- void stsfpscr(RegisterID reg)
- {
- uint16_t opc = getOpcodeGroup2(STSFPSCR_OPCODE, reg);
- oneShortOp(opc);
- }
-
- // double operations
-
- void dcnvds(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup7(FCNVDS_DRM_FPUL_OPCODE, src >> 1);
- oneShortOp(opc);
- }
-
- void dcnvsd(FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup7(FCNVSD_FPUL_DRN_OPCODE, dst >> 1);
- oneShortOp(opc);
- }
-
- void dcmppeq(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FCMPEQ_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void dcmppgt(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FCMPGT_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void dmulRegReg(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FMUL_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void dsubRegReg(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FSUB_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void daddRegReg(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FADD_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void dmovRegReg(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FMOV_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void ddivRegReg(FPRegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup8(FDIV_OPCODE, dst >> 1, src >> 1);
- oneShortOp(opc);
- }
-
- void dsqrt(FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup7(FSQRT_OPCODE, dst >> 1);
- oneShortOp(opc);
- }
-
- void dneg(FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup7(FNEG_OPCODE, dst >> 1);
- oneShortOp(opc);
- }
-
- void fmovReadrm(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup10(FMOVS_READ_RM_OPCODE, dst >> 1, src);
- oneShortOp(opc);
- }
-
- void fmovWriterm(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup9(FMOVS_WRITE_RN_OPCODE, dst, src >> 1);
- oneShortOp(opc);
- }
-
- void fmovWriter0r(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup9(FMOVS_WRITE_R0RN_OPCODE, dst, src >> 1);
- oneShortOp(opc);
- }
-
- void fmovReadr0r(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup10(FMOVS_READ_R0RM_OPCODE, dst >> 1, src);
- oneShortOp(opc);
- }
-
- void fmovReadrminc(RegisterID src, FPRegisterID dst)
- {
- uint16_t opc = getOpcodeGroup10(FMOVS_READ_RM_INC_OPCODE, dst >> 1, src);
- oneShortOp(opc);
- }
-
- void fmovWriterndec(FPRegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup9(FMOVS_WRITE_RN_DEC_OPCODE, dst, src >> 1);
- oneShortOp(opc);
- }
-
- void floatfpulDreg(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup7(FLOAT_OPCODE, src >> 1);
- oneShortOp(opc);
- }
-
- void ftrcdrmfpul(FPRegisterID src)
- {
- uint16_t opc = getOpcodeGroup7(FTRC_OPCODE, src >> 1);
- oneShortOp(opc);
- }
-
- // Various move ops
-
- void movImm8(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 127) && (imm8 >= -128));
-
- uint16_t opc = getOpcodeGroup3(MOVIMM_OPCODE, dst, imm8);
- oneShortOp(opc);
- }
-
- void movlRegReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOV_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movwRegMem(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVW_WRITE_RN_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movwMemReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVW_READ_RM_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movwPCReg(int offset, RegisterID base, RegisterID dst)
- {
- ASSERT(base == SH4Registers::pc);
- ASSERT((offset <= 255) && (offset >= 0));
-
- uint16_t opc = getOpcodeGroup3(MOVW_READ_OFFPC_OPCODE, dst, offset);
- oneShortOp(opc);
- }
-
- void movwMemReg(int offset, RegisterID base, RegisterID dst)
- {
- ASSERT(dst == SH4Registers::r0);
-
- uint16_t opc = getOpcodeGroup11(MOVW_READ_OFFRM_OPCODE, base, offset);
- oneShortOp(opc);
- }
-
- void movwR0mr(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVW_READ_R0RM_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movlRegMem(RegisterID src, int offset, RegisterID base)
- {
- ASSERT((offset <= 15) && (offset >= 0));
-
- if (!offset) {
- oneShortOp(getOpcodeGroup1(MOVL_WRITE_RN_OPCODE, base, src));
- return;
- }
-
- oneShortOp(getOpcodeGroup4(MOVL_WRITE_OFFRN_OPCODE, base, src, offset));
- }
-
- void movlRegMem(RegisterID src, RegisterID base)
- {
- uint16_t opc = getOpcodeGroup1(MOVL_WRITE_RN_OPCODE, base, src);
- oneShortOp(opc);
- }
-
- void movlMemReg(int offset, RegisterID base, RegisterID dst)
- {
- if (base == SH4Registers::pc) {
- ASSERT((offset <= 255) && (offset >= 0));
- oneShortOp(getOpcodeGroup3(MOVL_READ_OFFPC_OPCODE, dst, offset));
- return;
- }
-
- ASSERT((offset <= 15) && (offset >= 0));
- if (!offset) {
- oneShortOp(getOpcodeGroup1(MOVL_READ_RM_OPCODE, dst, base));
- return;
- }
-
- oneShortOp(getOpcodeGroup4(MOVL_READ_OFFRM_OPCODE, dst, base, offset));
- }
-
- void movlMemRegCompact(int offset, RegisterID base, RegisterID dst)
- {
- oneShortOp(getOpcodeGroup4(MOVL_READ_OFFRM_OPCODE, dst, base, offset));
- }
-
- void movbRegMem(RegisterID src, RegisterID base)
- {
- uint16_t opc = getOpcodeGroup1(MOVB_WRITE_RN_OPCODE, base, src);
- oneShortOp(opc);
- }
-
- void movbMemReg(int offset, RegisterID base, RegisterID dst)
- {
- ASSERT(dst == SH4Registers::r0);
-
- uint16_t opc = getOpcodeGroup11(MOVB_READ_OFFRM_OPCODE, base, offset);
- oneShortOp(opc);
- }
-
- void movbR0mr(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVB_READ_R0RM_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movbMemReg(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVB_READ_RM_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movlMemReg(RegisterID base, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVL_READ_RM_OPCODE, dst, base);
- oneShortOp(opc);
- }
-
- void movlMemRegIn(RegisterID base, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVL_READ_RMINC_OPCODE, dst, base);
- oneShortOp(opc);
- }
-
- void movlR0mr(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVL_READ_R0RM_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movlRegMemr0(RegisterID src, RegisterID dst)
- {
- uint16_t opc = getOpcodeGroup1(MOVL_WRITE_R0RN_OPCODE, dst, src);
- oneShortOp(opc);
- }
-
- void movlImm8r(int imm8, RegisterID dst)
- {
- ASSERT((imm8 <= 127) && (imm8 >= -128));
-
- uint16_t opc = getOpcodeGroup3(MOVIMM_OPCODE, dst, imm8);
- oneShortOp(opc);
- }
-
- void loadConstant(uint32_t constant, RegisterID dst)
- {
- if (((int)constant <= 0x7f) && ((int)constant >= -0x80)) {
- movImm8(constant, dst);
- return;
- }
-
- uint16_t opc = getOpcodeGroup3(MOVIMM_OPCODE, dst, 0);
-
- m_buffer.ensureSpace(maxInstructionSize, sizeof(uint32_t));
- printInstr(getOpcodeGroup3(MOVIMM_OPCODE, dst, constant), m_buffer.codeSize());
- m_buffer.putShortWithConstantInt(opc, constant, true);
- }
-
- void loadConstantUnReusable(uint32_t constant, RegisterID dst, bool ensureSpace = false)
- {
- uint16_t opc = getOpcodeGroup3(MOVIMM_OPCODE, dst, 0);
-
- if (ensureSpace)
- m_buffer.ensureSpace(maxInstructionSize, sizeof(uint32_t));
-
- printInstr(getOpcodeGroup3(MOVIMM_OPCODE, dst, constant), m_buffer.codeSize());
- m_buffer.putShortWithConstantInt(opc, constant);
- }
-
- // Flow control
-
- AssemblerLabel call()
- {
- RegisterID scr = claimScratch();
- m_buffer.ensureSpace(maxInstructionSize + 4, sizeof(uint32_t));
- loadConstantUnReusable(0x0, scr);
- branch(JSR_OPCODE, scr);
- nop();
- releaseScratch(scr);
- return m_buffer.label();
- }
-
- AssemblerLabel call(RegisterID dst)
- {
- m_buffer.ensureSpace(maxInstructionSize + 2);
- branch(JSR_OPCODE, dst);
- nop();
- return m_buffer.label();
- }
-
- AssemblerLabel jmp()
- {
- RegisterID scr = claimScratch();
- m_buffer.ensureSpace(maxInstructionSize + 4, sizeof(uint32_t));
- AssemblerLabel label = m_buffer.label();
- loadConstantUnReusable(0x0, scr);
- branch(BRAF_OPCODE, scr);
- nop();
- releaseScratch(scr);
- return label;
- }
-
- void extraInstrForBranch(RegisterID dst)
- {
- loadConstantUnReusable(0x0, dst);
- nop();
- nop();
- }
-
- AssemblerLabel jmp(RegisterID dst)
- {
- jmpReg(dst);
- return m_buffer.label();
- }
-
- void jmpReg(RegisterID dst)
- {
- m_buffer.ensureSpace(maxInstructionSize + 2);
- branch(JMP_OPCODE, dst);
- nop();
- }
-
- AssemblerLabel jne()
- {
- AssemblerLabel label = m_buffer.label();
- branch(BF_OPCODE, 0);
- return label;
- }
-
- AssemblerLabel je()
- {
- AssemblerLabel label = m_buffer.label();
- branch(BT_OPCODE, 0);
- return label;
- }
-
- AssemblerLabel bra()
- {
- AssemblerLabel label = m_buffer.label();
- branch(BRA_OPCODE, 0);
- return label;
- }
-
- void ret()
- {
- m_buffer.ensureSpace(maxInstructionSize + 2);
- oneShortOp(RTS_OPCODE, false);
- }
-
- AssemblerLabel labelIgnoringWatchpoints()
- {
- m_buffer.ensureSpaceForAnyInstruction();
- return m_buffer.label();
- }
-
- AssemblerLabel label()
- {
- m_buffer.ensureSpaceForAnyInstruction();
- return m_buffer.label();
- }
-
- int sizeOfConstantPool()
- {
- return m_buffer.sizeOfConstantPool();
- }
-
- AssemblerLabel align(int alignment)
- {
- m_buffer.ensureSpace(maxInstructionSize + 2);
- while (!m_buffer.isAligned(alignment)) {
- nop();
- m_buffer.ensureSpace(maxInstructionSize + 2);
- }
- return label();
- }
-
- static void changePCrelativeAddress(int offset, uint16_t* instructionPtr, uint32_t newAddress)
- {
- uint32_t address = (offset << 2) + ((reinterpret_cast<uint32_t>(instructionPtr) + 4) &(~0x3));
- *reinterpret_cast<uint32_t*>(address) = newAddress;
- }
-
- static uint32_t readPCrelativeAddress(int offset, uint16_t* instructionPtr)
- {
- uint32_t address = (offset << 2) + ((reinterpret_cast<uint32_t>(instructionPtr) + 4) &(~0x3));
- return *reinterpret_cast<uint32_t*>(address);
- }
-
- static uint16_t* getInstructionPtr(void* code, int offset)
- {
- return reinterpret_cast<uint16_t*> (reinterpret_cast<uint32_t>(code) + offset);
- }
-
- static void linkJump(void* code, AssemblerLabel from, void* to)
- {
- ASSERT(from.isSet());
-
- uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset);
- uint16_t instruction = *instructionPtr;
- int offsetBits = (reinterpret_cast<uint32_t>(to) - reinterpret_cast<uint32_t>(code)) - from.m_offset;
-
- if (((instruction & 0xff00) == BT_OPCODE) || ((instruction & 0xff00) == BF_OPCODE)) {
- /* BT label ==> BF 2
- nop LDR reg
- nop braf @reg
- nop nop
- */
- offsetBits -= 8;
- instruction ^= 0x0202;
- *instructionPtr++ = instruction;
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits);
- instruction = (BRAF_OPCODE | (*instructionPtr++ & 0xf00));
- *instructionPtr = instruction;
- printBlockInstr(instructionPtr - 2, from.m_offset, 3);
- return;
- }
-
- /* MOV #imm, reg => LDR reg
- braf @reg braf @reg
- nop nop
- */
- ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE);
-
- offsetBits -= 4;
- if (offsetBits >= -4096 && offsetBits <= 4094) {
- *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1);
- *(++instructionPtr) = NOP_OPCODE;
- printBlockInstr(instructionPtr - 1, from.m_offset, 2);
- return;
- }
-
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2);
- printInstr(*instructionPtr, from.m_offset + 2);
- }
-
- static void linkCall(void* code, AssemblerLabel from, void* to)
- {
- uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset);
- instructionPtr -= 3;
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(to));
- }
-
- static void linkPointer(void* code, AssemblerLabel where, void* value)
- {
- uint16_t* instructionPtr = getInstructionPtr(code, where.m_offset);
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(value));
- }
-
- static unsigned getCallReturnOffset(AssemblerLabel call)
- {
- ASSERT(call.isSet());
- return call.m_offset;
- }
-
- static uint32_t* getLdrImmAddressOnPool(SH4Word* insn, uint32_t* constPool)
- {
- return (constPool + (*insn & 0xff));
- }
-
- static SH4Word patchConstantPoolLoad(SH4Word load, int value)
- {
- return ((load & ~0xff) | value);
- }
-
- static SH4Buffer::TwoShorts placeConstantPoolBarrier(int offset)
- {
- ASSERT(((offset >> 1) <=2047) && ((offset >> 1) >= -2048));
-
- SH4Buffer::TwoShorts m_barrier;
- m_barrier.high = (BRA_OPCODE | (offset >> 1));
- m_barrier.low = NOP_OPCODE;
- printInstr(((BRA_OPCODE | (offset >> 1))), 0);
- printInstr(NOP_OPCODE, 0);
- return m_barrier;
- }
-
- static void patchConstantPoolLoad(void* loadAddr, void* constPoolAddr)
- {
- SH4Word* instructionPtr = reinterpret_cast<SH4Word*>(loadAddr);
- SH4Word instruction = *instructionPtr;
- SH4Word index = instruction & 0xff;
-
- if ((instruction & 0xf000) != MOVIMM_OPCODE)
- return;
-
- ASSERT((((reinterpret_cast<uint32_t>(constPoolAddr) - reinterpret_cast<uint32_t>(loadAddr)) + index * 4)) < 1024);
-
- int offset = reinterpret_cast<uint32_t>(constPoolAddr) + (index * 4) - ((reinterpret_cast<uint32_t>(instructionPtr) & ~0x03) + 4);
- instruction &=0xf00;
- instruction |= 0xd000;
- offset &= 0x03ff;
- instruction |= (offset >> 2);
- *instructionPtr = instruction;
- printInstr(instruction, reinterpret_cast<uint32_t>(loadAddr));
- }
-
- static void repatchPointer(void* where, void* value)
- {
- patchPointer(where, value);
- }
-
- static void* readPointer(void* code)
- {
- return reinterpret_cast<void*>(readInt32(code));
- }
-
- static void repatchInt32(void* where, int32_t value)
- {
- uint16_t* instructionPtr = reinterpret_cast<uint16_t*>(where);
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, value);
- }
-
- static void repatchCompact(void* where, int32_t value)
- {
- ASSERT(value >= 0);
- ASSERT(value <= 60);
- *reinterpret_cast<uint16_t*>(where) = ((*reinterpret_cast<uint16_t*>(where) & 0xfff0) | (value >> 2));
- cacheFlush(reinterpret_cast<uint16_t*>(where), sizeof(uint16_t));
- }
-
- static void relinkCall(void* from, void* to)
- {
- uint16_t* instructionPtr = reinterpret_cast<uint16_t*>(from);
- instructionPtr -= 3;
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(to));
- }
-
- static void relinkJump(void* from, void* to)
- {
- uint16_t* instructionPtr = reinterpret_cast<uint16_t*> (from);
- uint16_t instruction = *instructionPtr;
- int32_t offsetBits = (reinterpret_cast<uint32_t>(to) - reinterpret_cast<uint32_t>(from));
-
- if (((*instructionPtr & 0xff00) == BT_OPCODE) || ((*instructionPtr & 0xff00) == BF_OPCODE)) {
- offsetBits -= 8;
- instructionPtr++;
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits);
- instruction = (BRAF_OPCODE | (*instructionPtr++ & 0xf00));
- *instructionPtr = instruction;
- printBlockInstr(instructionPtr, reinterpret_cast<uint32_t>(from) + 1, 3);
- return;
- }
-
- ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE);
- offsetBits -= 4;
- if (offsetBits >= -4096 && offsetBits <= 4094) {
- *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1);
- *(++instructionPtr) = NOP_OPCODE;
- printBlockInstr(instructionPtr - 2, reinterpret_cast<uint32_t>(from), 2);
- return;
- }
-
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2);
- printInstr(*instructionPtr, reinterpret_cast<uint32_t>(from));
- }
-
- // Linking & patching
-
- static void revertJump(void* instructionStart, SH4Word imm)
- {
- SH4Word *insn = reinterpret_cast<SH4Word*>(instructionStart);
- SH4Word disp;
-
- ASSERT((insn[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE);
-
- disp = insn[0] & 0x00ff;
- insn += 2 + (disp << 1); // PC += 4 + (disp*4)
- insn = (SH4Word *) ((unsigned) insn & (~3));
- insn[0] = imm;
- cacheFlush(insn, sizeof(SH4Word));
- }
-
- void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type = JumpFar)
- {
- ASSERT(to.isSet());
- ASSERT(from.isSet());
-
- uint16_t* instructionPtr = getInstructionPtr(data(), from.m_offset);
- uint16_t instruction = *instructionPtr;
- int offsetBits;
-
- if (type == JumpNear) {
- ASSERT((instruction == BT_OPCODE) || (instruction == BF_OPCODE) || (instruction == BRA_OPCODE));
- int offset = (codeSize() - from.m_offset) - 4;
- *instructionPtr++ = instruction | (offset >> 1);
- printInstr(*instructionPtr, from.m_offset + 2);
- return;
- }
-
- if (((instruction & 0xff00) == BT_OPCODE) || ((instruction & 0xff00) == BF_OPCODE)) {
- /* BT label => BF 2
- nop LDR reg
- nop braf @reg
- nop nop
- */
- offsetBits = (to.m_offset - from.m_offset) - 8;
- instruction ^= 0x0202;
- *instructionPtr++ = instruction;
- if ((*instructionPtr & 0xf000) == 0xe000) {
- uint32_t* addr = getLdrImmAddressOnPool(instructionPtr, m_buffer.poolAddress());
- *addr = offsetBits;
- } else
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits);
- instruction = (BRAF_OPCODE | (*instructionPtr++ & 0xf00));
- *instructionPtr = instruction;
- printBlockInstr(instructionPtr - 2, from.m_offset, 3);
- return;
- }
-
- /* MOV # imm, reg => LDR reg
- braf @reg braf @reg
- nop nop
- */
- ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE);
- offsetBits = (to.m_offset - from.m_offset) - 4;
- if (offsetBits >= -4096 && offsetBits <= 4094) {
- *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1);
- *(++instructionPtr) = NOP_OPCODE;
- printBlockInstr(instructionPtr - 1, from.m_offset, 2);
- return;
- }
-
- instruction = *instructionPtr;
- if ((instruction & 0xf000) == 0xe000) {
- uint32_t* addr = getLdrImmAddressOnPool(instructionPtr, m_buffer.poolAddress());
- *addr = offsetBits - 2;
- printInstr(*instructionPtr, from.m_offset + 2);
- return;
- }
-
- changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2);
- printInstr(*instructionPtr, from.m_offset + 2);
- }
-
- static void* getRelocatedAddress(void* code, AssemblerLabel label)
- {
- return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset);
- }
-
- static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
- {
- return b.m_offset - a.m_offset;
- }
-
- static void patchPointer(void* code, AssemblerLabel where, void* value)
- {
- patchPointer(reinterpret_cast<uint32_t*>(code) + where.m_offset, value);
- }
-
- static void patchPointer(void* code, void* value)
- {
- patchInt32(code, reinterpret_cast<uint32_t>(value));
- }
-
- static void patchInt32(void* code, uint32_t value)
- {
- changePCrelativeAddress((*(reinterpret_cast<uint16_t*>(code)) & 0xff), reinterpret_cast<uint16_t*>(code), value);
- }
-
- static uint32_t readInt32(void* code)
- {
- return readPCrelativeAddress((*(reinterpret_cast<uint16_t*>(code)) & 0xff), reinterpret_cast<uint16_t*>(code));
- }
-
- static void* readCallTarget(void* from)
- {
- uint16_t* instructionPtr = static_cast<uint16_t*>(from);
- instructionPtr -= 3;
- return reinterpret_cast<void*>(readPCrelativeAddress((*instructionPtr & 0xff), instructionPtr));
- }
-
- PassRefPtr<ExecutableMemoryHandle> executableCopy(JSGlobalData& globalData, void* ownerUID, JITCompilationEffort effort)
- {
- return m_buffer.executableCopy(globalData, ownerUID, effort);
- }
-
- static void cacheFlush(void* code, size_t size)
- {
-#if !OS(LINUX)
-#error "The cacheFlush support is missing on this platform."
-#elif defined CACHEFLUSH_D_L2
- syscall(__NR_cacheflush, reinterpret_cast<unsigned>(code), size, CACHEFLUSH_D_WB | CACHEFLUSH_I | CACHEFLUSH_D_L2);
-#else
- syscall(__NR_cacheflush, reinterpret_cast<unsigned>(code), size, CACHEFLUSH_D_WB | CACHEFLUSH_I);
-#endif
- }
-
- void prefix(uint16_t pre)
- {
- m_buffer.putByte(pre);
- }
-
- void oneShortOp(uint16_t opcode, bool checksize = true, bool isDouble = true)
- {
- printInstr(opcode, m_buffer.codeSize(), isDouble);
- if (checksize)
- m_buffer.ensureSpace(maxInstructionSize);
- m_buffer.putShortUnchecked(opcode);
- }
-
- void ensureSpace(int space)
- {
- m_buffer.ensureSpace(space);
- }
-
- void ensureSpace(int insnSpace, int constSpace)
- {
- m_buffer.ensureSpace(insnSpace, constSpace);
- }
-
- // Administrative methods
-
- void* data() const { return m_buffer.data(); }
- size_t codeSize() const { return m_buffer.codeSize(); }
-
-#ifdef SH4_ASSEMBLER_TRACING
- static void printInstr(uint16_t opc, unsigned size, bool isdoubleInst = true)
- {
- if (!getenv("JavaScriptCoreDumpJIT"))
- return;
-
- const char *format = 0;
- printfStdoutInstr("offset: 0x%8.8x\t", size);
- switch (opc) {
- case BRK_OPCODE:
- format = " BRK\n";
- break;
- case NOP_OPCODE:
- format = " NOP\n";
- break;
- case RTS_OPCODE:
- format =" *RTS\n";
- break;
- case SETS_OPCODE:
- format = " SETS\n";
- break;
- case SETT_OPCODE:
- format = " SETT\n";
- break;
- case CLRT_OPCODE:
- format = " CLRT\n";
- break;
- case FSCHG_OPCODE:
- format = " FSCHG\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format);
- return;
- }
- switch (opc & 0xf0ff) {
- case BRAF_OPCODE:
- format = " *BRAF R%d\n";
- break;
- case DT_OPCODE:
- format = " DT R%d\n";
- break;
- case CMPPL_OPCODE:
- format = " CMP/PL R%d\n";
- break;
- case CMPPZ_OPCODE:
- format = " CMP/PZ R%d\n";
- break;
- case JMP_OPCODE:
- format = " *JMP @R%d\n";
- break;
- case JSR_OPCODE:
- format = " *JSR @R%d\n";
- break;
- case LDSPR_OPCODE:
- format = " LDS R%d, PR\n";
- break;
- case LDSLPR_OPCODE:
- format = " LDS.L @R%d+, PR\n";
- break;
- case MOVT_OPCODE:
- format = " MOVT R%d\n";
- break;
- case SHAL_OPCODE:
- format = " SHAL R%d\n";
- break;
- case SHAR_OPCODE:
- format = " SHAR R%d\n";
- break;
- case SHLL_OPCODE:
- format = " SHLL R%d\n";
- break;
- case SHLL2_OPCODE:
- format = " SHLL2 R%d\n";
- break;
- case SHLL8_OPCODE:
- format = " SHLL8 R%d\n";
- break;
- case SHLL16_OPCODE:
- format = " SHLL16 R%d\n";
- break;
- case SHLR_OPCODE:
- format = " SHLR R%d\n";
- break;
- case SHLR2_OPCODE:
- format = " SHLR2 R%d\n";
- break;
- case SHLR8_OPCODE:
- format = " SHLR8 R%d\n";
- break;
- case SHLR16_OPCODE:
- format = " SHLR16 R%d\n";
- break;
- case STSPR_OPCODE:
- format = " STS PR, R%d\n";
- break;
- case STSLPR_OPCODE:
- format = " STS.L PR, @-R%d\n";
- break;
- case LDS_RM_FPUL_OPCODE:
- format = " LDS R%d, FPUL\n";
- break;
- case STS_FPUL_RN_OPCODE:
- format = " STS FPUL, R%d \n";
- break;
- case FLDS_FRM_FPUL_OPCODE:
- format = " FLDS FR%d, FPUL\n";
- break;
- case FSTS_FPUL_FRN_OPCODE:
- format = " FSTS FPUL, R%d \n";
- break;
- case LDSFPSCR_OPCODE:
- format = " LDS R%d, FPSCR \n";
- break;
- case STSFPSCR_OPCODE:
- format = " STS FPSCR, R%d \n";
- break;
- case STSMACL_OPCODE:
- format = " STS MACL, R%d \n";
- break;
- case STSMACH_OPCODE:
- format = " STS MACH, R%d \n";
- break;
- case BSRF_OPCODE:
- format = " *BSRF R%d";
- break;
- case FTRC_OPCODE:
- format = " FTRC FR%d, FPUL\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getRn(opc));
- return;
- }
- switch (opc & 0xf0ff) {
- case FNEG_OPCODE:
- format = " FNEG DR%d\n";
- break;
- case FLOAT_OPCODE:
- format = " FLOAT DR%d\n";
- break;
- case FTRC_OPCODE:
- format = " FTRC FR%d, FPUL\n";
- break;
- case FSQRT_OPCODE:
- format = " FSQRT FR%d\n";
- break;
- case FCNVDS_DRM_FPUL_OPCODE:
- format = " FCNVDS FR%d, FPUL\n";
- break;
- case FCNVSD_FPUL_DRN_OPCODE:
- format = " FCNVSD FPUL, FR%d\n";
- break;
- }
- if (format) {
- if (isdoubleInst)
- printfStdoutInstr(format, getDRn(opc) << 1);
- else
- printfStdoutInstr(format, getRn(opc));
- return;
- }
- switch (opc & 0xf00f) {
- case ADD_OPCODE:
- format = " ADD R%d, R%d\n";
- break;
- case ADDC_OPCODE:
- format = " ADDC R%d, R%d\n";
- break;
- case ADDV_OPCODE:
- format = " ADDV R%d, R%d\n";
- break;
- case AND_OPCODE:
- format = " AND R%d, R%d\n";
- break;
- case DIV1_OPCODE:
- format = " DIV1 R%d, R%d\n";
- break;
- case CMPEQ_OPCODE:
- format = " CMP/EQ R%d, R%d\n";
- break;
- case CMPGE_OPCODE:
- format = " CMP/GE R%d, R%d\n";
- break;
- case CMPGT_OPCODE:
- format = " CMP/GT R%d, R%d\n";
- break;
- case CMPHI_OPCODE:
- format = " CMP/HI R%d, R%d\n";
- break;
- case CMPHS_OPCODE:
- format = " CMP/HS R%d, R%d\n";
- break;
- case MOV_OPCODE:
- format = " MOV R%d, R%d\n";
- break;
- case MOVB_WRITE_RN_OPCODE:
- format = " MOV.B R%d, @R%d\n";
- break;
- case MOVB_WRITE_RNDEC_OPCODE:
- format = " MOV.B R%d, @-R%d\n";
- break;
- case MOVB_WRITE_R0RN_OPCODE:
- format = " MOV.B R%d, @(R0, R%d)\n";
- break;
- case MOVB_READ_RM_OPCODE:
- format = " MOV.B @R%d, R%d\n";
- break;
- case MOVB_READ_RMINC_OPCODE:
- format = " MOV.B @R%d+, R%d\n";
- break;
- case MOVB_READ_R0RM_OPCODE:
- format = " MOV.B @(R0, R%d), R%d\n";
- break;
- case MOVL_WRITE_RN_OPCODE:
- format = " MOV.L R%d, @R%d\n";
- break;
- case MOVL_WRITE_RNDEC_OPCODE:
- format = " MOV.L R%d, @-R%d\n";
- break;
- case MOVL_WRITE_R0RN_OPCODE:
- format = " MOV.L R%d, @(R0, R%d)\n";
- break;
- case MOVL_READ_RM_OPCODE:
- format = " MOV.L @R%d, R%d\n";
- break;
- case MOVL_READ_RMINC_OPCODE:
- format = " MOV.L @R%d+, R%d\n";
- break;
- case MOVL_READ_R0RM_OPCODE:
- format = " MOV.L @(R0, R%d), R%d\n";
- break;
- case MULL_OPCODE:
- format = " MUL.L R%d, R%d\n";
- break;
- case DMULL_L_OPCODE:
- format = " DMULU.L R%d, R%d\n";
- break;
- case DMULSL_OPCODE:
- format = " DMULS.L R%d, R%d\n";
- break;
- case NEG_OPCODE:
- format = " NEG R%d, R%d\n";
- break;
- case NEGC_OPCODE:
- format = " NEGC R%d, R%d\n";
- break;
- case NOT_OPCODE:
- format = " NOT R%d, R%d\n";
- break;
- case OR_OPCODE:
- format = " OR R%d, R%d\n";
- break;
- case SHAD_OPCODE:
- format = " SHAD R%d, R%d\n";
- break;
- case SHLD_OPCODE:
- format = " SHLD R%d, R%d\n";
- break;
- case SUB_OPCODE:
- format = " SUB R%d, R%d\n";
- break;
- case SUBC_OPCODE:
- format = " SUBC R%d, R%d\n";
- break;
- case SUBV_OPCODE:
- format = " SUBV R%d, R%d\n";
- break;
- case TST_OPCODE:
- format = " TST R%d, R%d\n";
- break;
- case XOR_OPCODE:
- format = " XOR R%d, R%d\n";break;
- case MOVW_WRITE_RN_OPCODE:
- format = " MOV.W R%d, @R%d\n";
- break;
- case MOVW_READ_RM_OPCODE:
- format = " MOV.W @R%d, R%d\n";
- break;
- case MOVW_READ_R0RM_OPCODE:
- format = " MOV.W @(R0, R%d), R%d\n";
- break;
- case EXTUB_OPCODE:
- format = " EXTU.B R%d, R%d\n";
- break;
- case EXTUW_OPCODE:
- format = " EXTU.W R%d, R%d\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getRm(opc), getRn(opc));
- return;
- }
- switch (opc & 0xf00f) {
- case FSUB_OPCODE:
- format = " FSUB FR%d, FR%d\n";
- break;
- case FADD_OPCODE:
- format = " FADD FR%d, FR%d\n";
- break;
- case FDIV_OPCODE:
- format = " FDIV FR%d, FR%d\n";
- break;
- case FMUL_OPCODE:
- format = " DMULL FR%d, FR%d\n";
- break;
- case FMOV_OPCODE:
- format = " FMOV FR%d, FR%d\n";
- break;
- case FCMPEQ_OPCODE:
- format = " FCMP/EQ FR%d, FR%d\n";
- break;
- case FCMPGT_OPCODE:
- format = " FCMP/GT FR%d, FR%d\n";
- break;
- }
- if (format) {
- if (isdoubleInst)
- printfStdoutInstr(format, getDRm(opc) << 1, getDRn(opc) << 1);
- else
- printfStdoutInstr(format, getRm(opc), getRn(opc));
- return;
- }
- switch (opc & 0xf00f) {
- case FMOVS_WRITE_RN_DEC_OPCODE:
- format = " %s FR%d, @-R%d\n";
- break;
- case FMOVS_WRITE_RN_OPCODE:
- format = " %s FR%d, @R%d\n";
- break;
- case FMOVS_WRITE_R0RN_OPCODE:
- format = " %s FR%d, @(R0, R%d)\n";
- break;
- }
- if (format) {
- if (isdoubleInst)
- printfStdoutInstr(format, "FMOV", getDRm(opc) << 1, getDRn(opc));
- else
- printfStdoutInstr(format, "FMOV.S", getRm(opc), getRn(opc));
- return;
- }
- switch (opc & 0xf00f) {
- case FMOVS_READ_RM_OPCODE:
- format = " %s @R%d, FR%d\n";
- break;
- case FMOVS_READ_RM_INC_OPCODE:
- format = " %s @R%d+, FR%d\n";
- break;
- case FMOVS_READ_R0RM_OPCODE:
- format = " %s @(R0, R%d), FR%d\n";
- break;
- }
- if (format) {
- if (isdoubleInst)
- printfStdoutInstr(format, "FMOV", getDRm(opc), getDRn(opc) << 1);
- else
- printfStdoutInstr(format, "FMOV.S", getRm(opc), getRn(opc));
- return;
- }
- switch (opc & 0xff00) {
- case BF_OPCODE:
- format = " BF %d\n";
- break;
- case BFS_OPCODE:
- format = " *BF/S %d\n";
- break;
- case ANDIMM_OPCODE:
- format = " AND #%d, R0\n";
- break;
- case BT_OPCODE:
- format = " BT %d\n";
- break;
- case BTS_OPCODE:
- format = " *BT/S %d\n";
- break;
- case CMPEQIMM_OPCODE:
- format = " CMP/EQ #%d, R0\n";
- break;
- case MOVB_WRITE_OFFGBR_OPCODE:
- format = " MOV.B R0, @(%d, GBR)\n";
- break;
- case MOVB_READ_OFFGBR_OPCODE:
- format = " MOV.B @(%d, GBR), R0\n";
- break;
- case MOVL_WRITE_OFFGBR_OPCODE:
- format = " MOV.L R0, @(%d, GBR)\n";
- break;
- case MOVL_READ_OFFGBR_OPCODE:
- format = " MOV.L @(%d, GBR), R0\n";
- break;
- case MOVA_READ_OFFPC_OPCODE:
- format = " MOVA @(%d, PC), R0\n";
- break;
- case ORIMM_OPCODE:
- format = " OR #%d, R0\n";
- break;
- case ORBIMM_OPCODE:
- format = " OR.B #%d, @(R0, GBR)\n";
- break;
- case TSTIMM_OPCODE:
- format = " TST #%d, R0\n";
- break;
- case TSTB_OPCODE:
- format = " TST.B %d, @(R0, GBR)\n";
- break;
- case XORIMM_OPCODE:
- format = " XOR #%d, R0\n";
- break;
- case XORB_OPCODE:
- format = " XOR.B %d, @(R0, GBR)\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getImm8(opc));
- return;
- }
- switch (opc & 0xff00) {
- case MOVB_WRITE_OFFRN_OPCODE:
- format = " MOV.B R0, @(%d, R%d)\n";
- break;
- case MOVB_READ_OFFRM_OPCODE:
- format = " MOV.B @(%d, R%d), R0\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getDisp(opc), getRm(opc));
- return;
- }
- switch (opc & 0xf000) {
- case BRA_OPCODE:
- format = " *BRA %d\n";
- break;
- case BSR_OPCODE:
- format = " *BSR %d\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getImm12(opc));
- return;
- }
- switch (opc & 0xf000) {
- case MOVL_READ_OFFPC_OPCODE:
- format = " MOV.L @(%d, PC), R%d\n";
- break;
- case ADDIMM_OPCODE:
- format = " ADD #%d, R%d\n";
- break;
- case MOVIMM_OPCODE:
- format = " MOV #%d, R%d\n";
- break;
- case MOVW_READ_OFFPC_OPCODE:
- format = " MOV.W @(%d, PC), R%d\n";
- break;
- }
- if (format) {
- printfStdoutInstr(format, getImm8(opc), getRn(opc));
- return;
- }
- switch (opc & 0xf000) {
- case MOVL_WRITE_OFFRN_OPCODE:
- format = " MOV.L R%d, @(%d, R%d)\n";
- printfStdoutInstr(format, getRm(opc), getDisp(opc), getRn(opc));
- break;
- case MOVL_READ_OFFRM_OPCODE:
- format = " MOV.L @(%d, R%d), R%d\n";
- printfStdoutInstr(format, getDisp(opc), getRm(opc), getRn(opc));
- break;
- }
- }
-
- static void printfStdoutInstr(const char* format, ...)
- {
- if (getenv("JavaScriptCoreDumpJIT")) {
- va_list args;
- va_start(args, format);
- vprintfStdoutInstr(format, args);
- va_end(args);
- }
- }
-
- static void vprintfStdoutInstr(const char* format, va_list args)
- {
- if (getenv("JavaScriptCoreDumpJIT"))
- WTF::dataLogFV(format, args);
- }
-
- static void printBlockInstr(uint16_t* first, unsigned offset, int nbInstr)
- {
- printfStdoutInstr(">> repatch instructions after link\n");
- for (int i = 0; i <= nbInstr; i++)
- printInstr(*(first + i), offset + i);
- printfStdoutInstr(">> end repatch\n");
- }
-#else
- static void printInstr(uint16_t opc, unsigned size, bool isdoubleInst = true) { };
- static void printBlockInstr(uint16_t* first, unsigned offset, int nbInstr) { };
-#endif
-
- static void replaceWithLoad(void* instructionStart)
- {
- SH4Word* insPtr = reinterpret_cast<SH4Word*>(instructionStart);
-
- insPtr += 2; // skip MOV and ADD opcodes
-
- if (((*insPtr) & 0xf00f) != MOVL_READ_RM_OPCODE) {
- *insPtr = MOVL_READ_RM_OPCODE | (*insPtr & 0x0ff0);
- cacheFlush(insPtr, sizeof(SH4Word));
- }
- }
-
- static void replaceWithAddressComputation(void* instructionStart)
- {
- SH4Word* insPtr = reinterpret_cast<SH4Word*>(instructionStart);
-
- insPtr += 2; // skip MOV and ADD opcodes
-
- if (((*insPtr) & 0xf00f) != MOV_OPCODE) {
- *insPtr = MOV_OPCODE | (*insPtr & 0x0ff0);
- cacheFlush(insPtr, sizeof(SH4Word));
- }
- }
-
-private:
- SH4Buffer m_buffer;
- int m_claimscratchReg;
-};
-
-} // namespace JSC
-
-#endif // ENABLE(ASSEMBLER) && CPU(SH4)
-
-#endif // SH4Assembler_h
diff --git a/src/3rdparty/masm/assembler/X86Assembler.h b/src/3rdparty/masm/assembler/X86Assembler.h
index b71cf290f8..2257cb2b9a 100644
--- a/src/3rdparty/masm/assembler/X86Assembler.h
+++ b/src/3rdparty/masm/assembler/X86Assembler.h
@@ -26,6 +26,8 @@
#ifndef X86Assembler_h
#define X86Assembler_h
+#include <Platform.h>
+
#if ENABLE(ASSEMBLER) && (CPU(X86) || CPU(X86_64))
#include "AssemblerBuffer.h"
@@ -1417,11 +1419,22 @@ public:
{
m_formatter.oneByteOp(OP_LEA, dst, base, offset);
}
+
+ void leal_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
+ {
+ m_formatter.oneByteOp(OP_LEA, dst, base, index, scale, offset);
+ }
+
#if CPU(X86_64)
void leaq_mr(int offset, RegisterID base, RegisterID dst)
{
m_formatter.oneByteOp64(OP_LEA, dst, base, offset);
}
+
+ void leaq_mr(int offset, RegisterID base, RegisterID index, int scale, RegisterID dst)
+ {
+ m_formatter.oneByteOp64(OP_LEA, dst, base, index, scale, offset);
+ }
#endif
// Flow control:
@@ -1892,9 +1905,18 @@ public:
ASSERT(to.isSet());
char* code = reinterpret_cast<char*>(m_formatter.data());
- ASSERT(!reinterpret_cast<int32_t*>(code + from.m_offset)[-1]);
+ ASSERT(!loadPossiblyUnaligned<int32_t>(code, from.m_offset, -1));
setRel32(code + from.m_offset, code + to.m_offset);
}
+
+ template<typename T>
+ T loadPossiblyUnaligned(char *ptr, size_t offset, int idx)
+ {
+ T *t_ptr = &reinterpret_cast<T*>(ptr + offset)[idx];
+ T val;
+ memcpy(&val, t_ptr, sizeof(T));
+ return val;
+ }
static void linkJump(void* code, AssemblerLabel from, void* to)
{
@@ -2095,7 +2117,14 @@ private:
static void setInt32(void* where, int32_t value)
{
- reinterpret_cast<int32_t*>(where)[-1] = value;
+ storePossiblyUnaligned<int32_t>(where, -1, value);
+ }
+
+ template <typename T>
+ static void storePossiblyUnaligned(void *where, int idx, T value)
+ {
+ T *ptr = &reinterpret_cast<T*>(where)[idx];
+ memcpy(ptr, &value, sizeof(T));
}
static void setInt8(void* where, int8_t value)
diff --git a/src/3rdparty/masm/masm-defs.pri b/src/3rdparty/masm/masm-defs.pri
index 34d6a67451..08c46a7ac2 100644
--- a/src/3rdparty/masm/masm-defs.pri
+++ b/src/3rdparty/masm/masm-defs.pri
@@ -20,6 +20,7 @@ INCLUDEPATH += $$PWD/assembler
INCLUDEPATH += $$PWD/runtime
INCLUDEPATH += $$PWD/wtf
INCLUDEPATH += $$PWD/stubs
+INCLUDEPATH += $$PWD/stubs/runtime
INCLUDEPATH += $$PWD/stubs/wtf
INCLUDEPATH += $$PWD
diff --git a/src/3rdparty/masm/masm.pri b/src/3rdparty/masm/masm.pri
index 7dfb24f4b8..0e63ac2ce5 100644
--- a/src/3rdparty/masm/masm.pri
+++ b/src/3rdparty/masm/masm.pri
@@ -79,10 +79,12 @@ HEADERS += $$PWD/disassembler/ARM64/A64DOpcode.h
!qmldevtools_build {
SOURCES += $$PWD/yarr/YarrCanonicalizeUCS2.cpp \
+ $$PWD/yarr/YarrCanonicalizeUnicode.cpp \
$$PWD/yarr/YarrInterpreter.cpp \
$$PWD/yarr/YarrJIT.cpp \
$$PWD/yarr/YarrPattern.cpp \
- $$PWD/yarr/YarrSyntaxChecker.cpp
+ $$PWD/yarr/YarrSyntaxChecker.cpp \
+ $$PWD/stubs/yarr/YarrUnicodeProperties.cpp
HEADERS += $$PWD/yarr/Yarr.h \
$$PWD/yarr/YarrCanonicalizeUCS2.h \
@@ -90,7 +92,8 @@ HEADERS += $$PWD/yarr/Yarr.h \
$$PWD/yarr/YarrJIT.h \
$$PWD/yarr/YarrParser.h \
$$PWD/yarr/YarrPattern.h \
- $$PWD/yarr/YarrSyntaxChecker.h
+ $$PWD/yarr/YarrSyntaxChecker.h \
+ $$PWD/yarr/YarrUnicodeProperties.h
}
#
@@ -107,7 +110,7 @@ debug_and_release {
INCLUDEPATH += $$GENERATEDDIR
retgen.output = $$GENERATEDDIR/RegExpJitTables.h
-retgen.script = $$PWD/create_regex_tables
+retgen.script = $$PWD/yarr/create_regex_tables
retgen.input = retgen.script
retgen.CONFIG += no_link
retgen.commands = python $$retgen.script > ${QMAKE_FILE_OUT}
@@ -125,3 +128,8 @@ QMAKE_EXTRA_COMPILERS += retgen
}
}
}
+
+linux {
+ requires(qtConfig(dlopen))
+ QMAKE_USE_PRIVATE += libdl
+}
diff --git a/src/3rdparty/masm/qt_attribution.json b/src/3rdparty/masm/qt_attribution.json
index f6803c6b1c..aab413ad40 100644
--- a/src/3rdparty/masm/qt_attribution.json
+++ b/src/3rdparty/masm/qt_attribution.json
@@ -8,7 +8,7 @@
"License": "BSD 2-clause \"Simplified\" License",
"LicenseId": "BSD-2-Clause",
"LicenseFile": "LICENSE",
- "Copyright": "Copyright (C) 2003-2015 Apple Inc. All rights reserved.
+ "Copyright": "Copyright (C) 2003-2018 Apple Inc. All rights reserved.
Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
Copyright (C) 2007-2009 Torch Mobile, Inc. All rights reserved. (http://www.torchmobile.com/)
Copyright (C) 2009, 2010 University of Szeged
diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h
index 16b17bd3cd..156b24b4e8 100644
--- a/src/3rdparty/masm/stubs/ExecutableAllocator.h
+++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h
@@ -82,7 +82,7 @@ struct ExecutableMemoryHandle : public RefCounted<ExecutableMemoryHandle> {
inline bool isManaged() const { return true; }
- void* start() { return m_allocation->start(); }
+ void *start() { return m_allocation->start(); }
size_t sizeInBytes() { return m_size; }
QV4::ExecutableAllocator::ChunkOfPages *chunk() const
@@ -98,7 +98,7 @@ struct ExecutableAllocator {
: realAllocator(alloc)
{}
- PassRefPtr<ExecutableMemoryHandle> allocate(JSGlobalData&, size_t size, void*, int)
+ Ref<ExecutableMemoryHandle> allocate(JSGlobalData&, size_t size, void*, int)
{
return adoptRef(new ExecutableMemoryHandle(realAllocator, size));
}
diff --git a/src/3rdparty/masm/stubs/Options.h b/src/3rdparty/masm/stubs/Options.h
index e03cc67690..6339c06033 100644
--- a/src/3rdparty/masm/stubs/Options.h
+++ b/src/3rdparty/masm/stubs/Options.h
@@ -44,6 +44,8 @@ namespace JSC {
struct Options {
static bool showDisassembly();
static bool showDFGDisassembly() { return true; }
+ static bool zeroStackFrame() { return true; }
+ static bool dumpCompiledRegExpPatterns() { return false; }
};
}
diff --git a/src/3rdparty/masm/stubs/SuperSampler.h b/src/3rdparty/masm/stubs/SuperSampler.h
new file mode 100644
index 0000000000..422de528e1
--- /dev/null
+++ b/src/3rdparty/masm/stubs/SuperSampler.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#pragma once
+
+namespace WTF {
+
+struct SuperSamplerScope {
+ SuperSamplerScope(bool) {}
+};
+
+}
+
+using WTF::SuperSamplerScope;
diff --git a/src/3rdparty/masm/stubs/WTFStubs.cpp b/src/3rdparty/masm/stubs/WTFStubs.cpp
index ea7e2d78e0..b26d10b3ab 100644
--- a/src/3rdparty/masm/stubs/WTFStubs.cpp
+++ b/src/3rdparty/masm/stubs/WTFStubs.cpp
@@ -91,7 +91,7 @@ void dataLogFV(const char* format, va_list args)
{
char buffer[1024];
qvsnprintf(buffer, sizeof(buffer), format, args);
- qDebug("%s", buffer);
+ qDebug().nospace().noquote() << buffer;
}
void dataLogF(const char* format, ...)
@@ -101,12 +101,12 @@ void dataLogF(const char* format, ...)
va_start(args, format);
qvsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
- qDebug("%s", buffer);
+ qDebug().nospace().noquote() << buffer;
}
void dataLogFString(const char* str)
{
- qDebug("%s", str);
+ qDebug().nospace().noquote() << str;
}
}
diff --git a/src/3rdparty/masm/stubs/runtime/ConcurrentJSLock.h b/src/3rdparty/masm/stubs/runtime/ConcurrentJSLock.h
new file mode 100644
index 0000000000..43868feadb
--- /dev/null
+++ b/src/3rdparty/masm/stubs/runtime/ConcurrentJSLock.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#pragma once
+
+namespace JSC {
+
+class NoLock {
+public:
+ void lock() { }
+ void unlock() { }
+ bool isHeld() { return false; }
+};
+
+typedef NoLock ConcurrentJSLock;
+
+} // namespace JSC
diff --git a/src/3rdparty/masm/stubs/runtime/RegExpKey.h b/src/3rdparty/masm/stubs/runtime/RegExpKey.h
new file mode 100644
index 0000000000..392f66fb83
--- /dev/null
+++ b/src/3rdparty/masm/stubs/runtime/RegExpKey.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 University of Szeged
+ * Copyright (C) 2010 Renata Hodovan (hodovan@inf.u-szeged.hu)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace JSC {
+
+enum RegExpFlags : int8_t {
+ NoFlags = 0,
+ FlagGlobal = 1,
+ FlagIgnoreCase = 2,
+ FlagMultiline = 4,
+ FlagSticky = 8,
+ FlagUnicode = 16,
+ FlagDotAll = 32,
+ InvalidFlags = 64,
+ DeletedValueFlags = -1
+};
+
+} // namespace JSC
diff --git a/src/3rdparty/masm/stubs/runtime/VM.h b/src/3rdparty/masm/stubs/runtime/VM.h
new file mode 100644
index 0000000000..94cce814f3
--- /dev/null
+++ b/src/3rdparty/masm/stubs/runtime/VM.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MASM_VM_H
+#define MASM_VM_H
+
+#include <qv4engine_p.h>
+
+namespace JSC {
+
+class VM : public QV4::ExecutionEngine {};
+
+}
+
+#endif // MASM_VM_H
diff --git a/src/3rdparty/masm/stubs/wtf/HashMap.h b/src/3rdparty/masm/stubs/wtf/HashMap.h
new file mode 100644
index 0000000000..888c6cceb0
--- /dev/null
+++ b/src/3rdparty/masm/stubs/wtf/HashMap.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef HASHMAP_H
+#define HASHMAP_H
+
+#include <QtCore/qhash.h>
+
+namespace WTF {
+
+template<typename Key, typename Value>
+class HashMap final : public QHash<Key, Value>
+{
+public:
+ void add(const Key &k, const Value &v) { QHash<Key, Value>::insert(k, v); }
+ Value get(const Key &k) { return QHash<Key, Value>::value(k); }
+};
+
+}
+
+using WTF::HashMap;
+
+#endif
diff --git a/src/3rdparty/masm/stubs/wtf/HashSet.h b/src/3rdparty/masm/stubs/wtf/HashSet.h
new file mode 100644
index 0000000000..3765c9a8b1
--- /dev/null
+++ b/src/3rdparty/masm/stubs/wtf/HashSet.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef HASHSET_H
+#define HASHSET_H
+
+#include <QtCore/qset.h>
+
+namespace WTF {
+
+template<typename Key>
+class HashSet final : public QSet<Key>
+{
+public:
+ struct SetAddResult {
+ bool isNewEntry;
+ };
+ SetAddResult add(const Key &k)
+ {
+ if (QSet<Key>::find(k) == QSet<Key>::constEnd()) {
+ QSet<Key>::insert(k);
+ return { true };
+ }
+ return { false };
+ }
+};
+
+}
+
+using WTF::HashSet;
+
+#endif
diff --git a/src/3rdparty/masm/stubs/wtf/Optional.h b/src/3rdparty/masm/stubs/wtf/Optional.h
new file mode 100644
index 0000000000..44fa3ee62d
--- /dev/null
+++ b/src/3rdparty/masm/stubs/wtf/Optional.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#pragma once
+
+#include <QtCore/qglobal.h>
+
+#if __cplusplus > 201402L && QT_HAS_INCLUDE(<optional>)
+#include <optional>
+#else
+
+namespace std {
+
+struct nullopt_t {};
+
+constexpr nullopt_t nullopt {};
+
+template<typename T>
+class optional {
+public:
+ optional() = default;
+ optional(nullopt_t) {}
+ optional(const T &v) : _value(v), _hasValue(true) {}
+ ~optional() = default;
+
+ optional &operator =(nullopt_t) {
+ _value = T();
+ _hasValue = false;
+ return *this;
+ }
+
+ T operator->() { return _value; }
+ T operator*() { return _value; }
+
+ operator bool() const { return _hasValue; }
+ bool has_value() const { return _hasValue; }
+
+ T value() const { return _value; }
+
+private:
+ T _value = T();
+ bool _hasValue = false;
+};
+
+}
+
+#endif
diff --git a/src/3rdparty/masm/stubs/wtf/PassRefPtr.h b/src/3rdparty/masm/stubs/wtf/PassRefPtr.h
index f072e70dd7..cc03a5d651 100644
--- a/src/3rdparty/masm/stubs/wtf/PassRefPtr.h
+++ b/src/3rdparty/masm/stubs/wtf/PassRefPtr.h
@@ -83,14 +83,22 @@ public:
private:
PassRefPtr<T>& operator=(const PassRefPtr<T>& t);
- template <typename PtrType> friend PassRefPtr<PtrType> adoptRef(PtrType*);
+protected:
mutable T* m_ptr;
};
template <typename T>
-PassRefPtr<T> adoptRef(T* ptr)
+class Ref : public PassRefPtr<T>
{
- PassRefPtr<T> result;
+ using PassRefPtr<T>::PassRefPtr;
+
+ template <typename PtrType> friend Ref<PtrType> adoptRef(PtrType*);
+};
+
+template <typename T>
+Ref<T> adoptRef(T* ptr)
+{
+ Ref<T> result;
result.m_ptr = ptr;
return result;
}
diff --git a/src/3rdparty/masm/stubs/wtf/Vector.h b/src/3rdparty/masm/stubs/wtf/Vector.h
index 2025acf8a9..f4f4dc5cf4 100644
--- a/src/3rdparty/masm/stubs/wtf/Vector.h
+++ b/src/3rdparty/masm/stubs/wtf/Vector.h
@@ -55,6 +55,8 @@ class Vector : public std::vector<T> {
public:
Vector() {}
Vector(int initialSize) : std::vector<T>(initialSize) {}
+ Vector(const Vector &other) : std::vector<T>(other) {}
+ Vector(std::initializer_list<T> list) : std::vector<T>(list) {}
inline void append(const T& value)
{ this->push_back(value); }
@@ -63,6 +65,9 @@ public:
inline void append(const OtherType& other)
{ this->push_back(T(other)); }
+ inline void append(T&& other)
+ { this->push_back(std::move(other)); }
+
inline void append(const Vector<T>& vector)
{
this->insert(this->end(), vector.begin(), vector.end());
@@ -80,6 +85,8 @@ public:
this->push_back(*it);
}
+ unsigned size() const { return static_cast<unsigned>(std::vector<T>::size()); }
+
using std::vector<T>::insert;
inline void reserveInitialCapacity(size_t size) { this->reserve(size); }
diff --git a/src/3rdparty/masm/stubs/wtf/text/CString.h b/src/3rdparty/masm/stubs/wtf/text/CString.h
index 26f74f7593..7129f5049e 100644
--- a/src/3rdparty/masm/stubs/wtf/text/CString.h
+++ b/src/3rdparty/masm/stubs/wtf/text/CString.h
@@ -39,4 +39,8 @@
#ifndef CSTRING_H
#define CSTRING_H
+class CString : public QByteArray {
+
+};
+
#endif // CSTRING_H
diff --git a/src/3rdparty/masm/stubs/wtf/text/StringBuilder.h b/src/3rdparty/masm/stubs/wtf/text/StringBuilder.h
new file mode 100644
index 0000000000..a382f6da83
--- /dev/null
+++ b/src/3rdparty/masm/stubs/wtf/text/StringBuilder.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace WTF {
+
+struct StringBuilder : public String
+{
+ String toString() const { return *this; }
+};
+
+}
+
+using WTF::StringBuilder;
diff --git a/src/3rdparty/masm/stubs/wtf/text/WTFString.h b/src/3rdparty/masm/stubs/wtf/text/WTFString.h
index 928c684fdb..da5183f734 100644
--- a/src/3rdparty/masm/stubs/wtf/text/WTFString.h
+++ b/src/3rdparty/masm/stubs/wtf/text/WTFString.h
@@ -42,26 +42,33 @@
#include <QString>
#include <wtf/ASCIICType.h>
#include <wtf/unicode/Unicode.h>
+#include <memory>
namespace WTF {
+class PrintStream;
+
class String : public QString
{
public:
+ String() = default;
String(const QString& s) : QString(s) {}
bool is8Bit() const { return false; }
const unsigned char *characters8() const { return 0; }
const UChar *characters16() const { return reinterpret_cast<const UChar*>(constData()); }
template <typename T>
- const T* getCharacters() const;
+ const T* characters() const;
+
+ bool operator!() const { return isEmpty(); }
+ void dump(PrintStream &) const {}
};
template <>
-inline const unsigned char* String::getCharacters<unsigned char>() const { return characters8(); }
+inline const unsigned char* String::characters<unsigned char>() const { return characters8(); }
template <>
-inline const UChar* String::getCharacters<UChar>() const { return characters16(); }
+inline const UChar* String::characters<UChar>() const { return characters16(); }
}
@@ -70,4 +77,6 @@ namespace JSC {
using WTF::String;
}
+#define WTFMove(value) std::move(value)
+
#endif // WTFSTRING_H
diff --git a/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h b/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h
index d61cec5c4e..0f7f005c89 100644
--- a/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h
+++ b/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h
@@ -43,6 +43,7 @@
typedef unsigned char LChar;
typedef unsigned short UChar;
+typedef int32_t UChar32;
namespace Unicode {
inline UChar toLower(UChar ch) {
@@ -52,6 +53,35 @@ namespace Unicode {
inline UChar toUpper(UChar ch) {
return QChar::toUpper(ch);
}
+ inline UChar32 u_tolower(UChar32 ch) {
+ return QChar::toLower(ch);
+ }
+ inline UChar32 u_toupper(UChar32 ch) {
+ return QChar::toUpper(ch);
+ }
}
+using Unicode::u_toupper;
+using Unicode::u_tolower;
+
+#define U16_IS_LEAD(ch) QChar::isHighSurrogate((ch))
+#define U16_IS_TRAIL(ch) QChar::isLowSurrogate((ch))
+#define U16_GET_SUPPLEMENTARY(lead, trail) static_cast<UChar32>(QChar::surrogateToUcs4((lead), (trail)))
+#define U_IS_BMP(ch) ((ch) < 0x10000)
+#define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)
+#define UCHAR_MAX_VALUE 0x10ffff
+
+#define U_MASK(category) (1u << (category))
+#define U_GET_GC_MASK(c) U_MASK(QChar::category((c)))
+#define U_GC_L_MASK (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK|U_GC_LM_MASK|U_GC_LO_MASK)
+#define U_GC_LU_MASK U_MASK(QChar::Letter_Uppercase)
+#define U_GC_LL_MASK U_MASK(QChar::Letter_Lowercase)
+#define U_GC_LT_MASK U_MASK(QChar::Letter_Titlecase)
+#define U_GC_LM_MASK U_MASK(QChar::Letter_Modifier)
+#define U_GC_LO_MASK U_MASK(QChar::Letter_Other)
+#define U_GC_MN_MASK U_MASK(QChar::Mark_NonSpacing)
+#define U_GC_MC_MASK U_MASK(QChar::Mark_SpacingCombining)
+#define U_GC_ND_MASK U_MASK(QChar::Number_DecimalDigit)
+#define U_GC_PC_MASK U_MASK(QChar::Punctuation_Connector)
+
#endif // UNICODE_H
diff --git a/src/3rdparty/masm/stubs/wtf/unicode/utypes.h b/src/3rdparty/masm/stubs/wtf/unicode/utypes.h
new file mode 100644
index 0000000000..e1b4ff90a6
--- /dev/null
+++ b/src/3rdparty/masm/stubs/wtf/unicode/utypes.h
@@ -0,0 +1 @@
+#include <unicode/Unicode.h>
diff --git a/src/3rdparty/masm/stubs/yarr/YarrUnicodeProperties.cpp b/src/3rdparty/masm/stubs/yarr/YarrUnicodeProperties.cpp
new file mode 100644
index 0000000000..99c925f406
--- /dev/null
+++ b/src/3rdparty/masm/stubs/yarr/YarrUnicodeProperties.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "config.h"
+#include "yarr/YarrUnicodeProperties.h"
+#include "qchar.h"
+
+#include "yarr/Yarr.h"
+#include "yarr/YarrPattern.h"
+
+using namespace WTF;
+
+namespace JSC { namespace Yarr {
+
+std::optional<BuiltInCharacterClassID> unicodeMatchPropertyValue(WTF::String unicodePropertyName, WTF::String unicodePropertyValue)
+{
+ Q_UNUSED(unicodePropertyName);
+ Q_UNUSED(unicodePropertyValue);
+ return std::nullopt;
+}
+
+std::optional<BuiltInCharacterClassID> unicodeMatchProperty(WTF::String unicodePropertyValue)
+{
+ Q_UNUSED(unicodePropertyValue);
+ return std::nullopt;
+}
+
+std::unique_ptr<CharacterClass> createUnicodeCharacterClassFor(BuiltInCharacterClassID unicodeClassID)
+{
+ Q_UNUSED(unicodeClassID);
+ return nullptr;
+}
+
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/wtf/Assertions.h b/src/3rdparty/masm/wtf/Assertions.h
index 491e434498..be25d43826 100644
--- a/src/3rdparty/masm/wtf/Assertions.h
+++ b/src/3rdparty/masm/wtf/Assertions.h
@@ -256,7 +256,7 @@ inline void assertUnused(T& x) { (void)x; }
(void)0)
#define ASSERT_NOT_REACHED() do { \
- WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
+ WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, NULL); \
CRASH(); \
} while (0)
diff --git a/src/3rdparty/masm/wtf/FilePrintStream.cpp b/src/3rdparty/masm/wtf/FilePrintStream.cpp
index 45f1565f46..28714ecb6f 100644
--- a/src/3rdparty/masm/wtf/FilePrintStream.cpp
+++ b/src/3rdparty/masm/wtf/FilePrintStream.cpp
@@ -38,17 +38,16 @@ FilePrintStream::~FilePrintStream()
{
if (m_adoptionMode == Borrow)
return;
- if (m_file)
- fclose(m_file);
+ fclose(m_file);
}
-PassOwnPtr<FilePrintStream> FilePrintStream::open(const char* filename, const char* mode)
+std::unique_ptr<FilePrintStream> FilePrintStream::open(const char* filename, const char* mode)
{
FILE* file = fopen(filename, mode);
if (!file)
- return PassOwnPtr<FilePrintStream>();
-
- return adoptPtr(new FilePrintStream(file));
+ return nullptr;
+
+ return std::make_unique<FilePrintStream>(file);
}
void FilePrintStream::vprintf(const char* format, va_list argList)
diff --git a/src/3rdparty/masm/wtf/FilePrintStream.h b/src/3rdparty/masm/wtf/FilePrintStream.h
index bdeab4c479..f32ca49dcb 100644
--- a/src/3rdparty/masm/wtf/FilePrintStream.h
+++ b/src/3rdparty/masm/wtf/FilePrintStream.h
@@ -27,7 +27,6 @@
#define FilePrintStream_h
#include <stdio.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/PrintStream.h>
namespace WTF {
@@ -40,14 +39,14 @@ public:
};
FilePrintStream(FILE*, AdoptionMode = Adopt);
- virtual ~FilePrintStream();
+ virtual ~FilePrintStream() override;
- static PassOwnPtr<FilePrintStream> open(const char* filename, const char* mode);
+ WTF_EXPORT_PRIVATE static std::unique_ptr<FilePrintStream> open(const char* filename, const char* mode);
FILE* file() { return m_file; }
- void vprintf(const char* format, va_list) WTF_ATTRIBUTE_PRINTF(2, 0);
- void flush();
+ void vprintf(const char* format, va_list) override WTF_ATTRIBUTE_PRINTF(2, 0);
+ void flush() override;
private:
FILE* m_file;
diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
index 0c902c7172..3b2a73a39a 100644
--- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
+++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
@@ -31,13 +31,82 @@
#include <cstdlib>
#include "PageAllocation.h"
+#include <dlfcn.h>
#include <errno.h>
#include <sys/mman.h>
#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>
+#if OS(LINUX)
+#include <sys/syscall.h>
+#ifndef MFD_CLOEXEC
+#define MFD_CLOEXEC 0x0001U
+#endif
+#endif
+
+#if defined(__ANDROID__) && defined(SYS_memfd_create)
+ // On Android it's been observed that permissions of memory mappings
+ // backed by a memfd could not be changed via mprotect for no obvious
+ // reason.
+# undef SYS_memfd_create
+#endif
+
namespace WTF {
+#ifdef SYS_memfd_create
+static int memfdForUsage(size_t bytes, OSAllocator::Usage usage)
+{
+ const char *type = "unknown-usage:";
+ switch (usage) {
+ case OSAllocator::UnknownUsage:
+ break;
+ case OSAllocator::FastMallocPages:
+ type = "fastmalloc:";
+ break;
+ case OSAllocator::JSGCHeapPages:
+ type = "JSGCHeap:";
+ break;
+ case OSAllocator::JSVMStackPages:
+ type = "JSVMStack:";
+ break;
+ case OSAllocator::JSJITCodePages:
+ type = "JITCode:";
+ break;
+ }
+
+ // try to get our own library name by giving dladdr a pointer pointing to
+ // something we know to be in it (using a pointer to string data)
+ static const char *libname = [=]() {
+ Dl_info info;
+ if (dladdr(type, &info) == 0)
+ info.dli_fname = nullptr;
+ return info.dli_fname;
+ }();
+
+ char buf[PATH_MAX];
+ strcpy(buf, type);
+ if (libname)
+ strcat(buf, libname);
+ else
+ strcat(buf, "QtQml");
+
+ int fd = syscall(SYS_memfd_create, buf, MFD_CLOEXEC);
+ if (fd != -1) {
+ if (ftruncate(fd, bytes) == 0)
+ return fd;
+ }
+ close(fd);
+ return -1;
+}
+#elif OS(LINUX)
+static int memfdForUsage(size_t bytes, OSAllocator::Usage usage)
+{
+ UNUSED_PARAM(bytes);
+ UNUSED_PARAM(usage);
+ return -1;
+}
+#endif
+
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable)
{
#if OS(QNX)
@@ -46,14 +115,18 @@ void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable,
if (result == MAP_FAILED)
CRASH();
#elif OS(LINUX)
- UNUSED_PARAM(usage);
UNUSED_PARAM(writable);
UNUSED_PARAM(executable);
+ int fd = memfdForUsage(bytes, usage);
- void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0);
+ void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE |
+ (fd == -1 ? MAP_ANON : 0), fd, 0);
if (result == MAP_FAILED)
CRASH();
madvise(result, bytes, MADV_DONTNEED);
+
+ if (fd != -1)
+ close(fd);
#else
void* result = reserveAndCommit(bytes, usage, writable, executable);
#if HAVE(MADV_FREE_REUSE)
@@ -83,6 +156,10 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
#if OS(DARWIN)
int fd = usage;
+#elif OS(LINUX)
+ int fd = memfdForUsage(bytes, usage);
+ if (fd != -1)
+ flags &= ~MAP_ANON;
#else
UNUSED_PARAM(usage);
int fd = -1;
@@ -126,6 +203,12 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
}
+
+#if OS(LINUX)
+ if (fd != -1)
+ close(fd);
+#endif
+
return result;
}
diff --git a/src/3rdparty/masm/wtf/Platform.h b/src/3rdparty/masm/wtf/Platform.h
index 5905f42f45..d5f69927db 100644
--- a/src/3rdparty/masm/wtf/Platform.h
+++ b/src/3rdparty/masm/wtf/Platform.h
@@ -2,6 +2,7 @@
* Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile, Inc.
* Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2018 The Qt Company Ltd.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -740,10 +741,6 @@
#define ENABLE_JIT 0
#endif
-#if !defined(ENABLE_JIT) && CPU(SH4) && PLATFORM(QT)
-#define ENABLE_JIT 1
-#endif
-
/* The JIT is enabled by default on all x86, x86-64, ARM & MIPS platforms. */
#if !defined(ENABLE_JIT) \
&& (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(MIPS) || CPU(ARM64)) \
@@ -1050,4 +1047,11 @@
#define WTF_USE_CONTENT_FILTERING 1
#endif
+#if ENABLE(YARR_JIT)
+#if CPU(ARM64) || (CPU(X86_64) && !OS(WINDOWS))
+/* Enable JIT'ing Regular Expressions that have nested parenthesis. */
+#define ENABLE_YARR_JIT_ALL_PARENS_EXPRESSIONS 1
+#endif
+#endif
+
#endif /* WTF_Platform_h */
diff --git a/src/3rdparty/masm/wtf/PrintStream.h b/src/3rdparty/masm/wtf/PrintStream.h
index 6fcf9c1567..4372288aff 100644
--- a/src/3rdparty/masm/wtf/PrintStream.h
+++ b/src/3rdparty/masm/wtf/PrintStream.h
@@ -206,6 +206,10 @@ public:
print(value12);
print(value13);
}
+
+ void println();
+ template<typename ...Types>
+ void println(Types... args);
};
WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const char*);
@@ -227,6 +231,19 @@ void printInternal(PrintStream& out, const T& value)
value.dump(out);
}
+inline
+void PrintStream::println()
+{
+ print("\n");
+}
+
+template<typename ...Types>
+void PrintStream::println(Types... args)
+{
+ print(args...);
+ print("\n");
+}
+
#define MAKE_PRINT_ADAPTOR(Name, Type, function) \
class Name { \
public: \
diff --git a/src/3rdparty/masm/wtf/StdLibExtras.h b/src/3rdparty/masm/wtf/StdLibExtras.h
index f0d792ed52..421712c349 100644
--- a/src/3rdparty/masm/wtf/StdLibExtras.h
+++ b/src/3rdparty/masm/wtf/StdLibExtras.h
@@ -28,6 +28,9 @@
#include <wtf/Assertions.h>
#include <wtf/CheckedArithmetic.h>
+#include <wtf/Platform.h>
+#include <memory>
+#include <qglobal.h>
// Use these to declare and define a static local variable (static T;) so that
// it is leaked so that its destructors are not called at exit. Using this
@@ -71,6 +74,8 @@
#define STRINGIZE(exp) #exp
#define STRINGIZE_VALUE_OF(exp) STRINGIZE(exp)
+#define FALLTHROUGH Q_FALLTHROUGH()
+
/*
* The reinterpret_cast<Type1*>([pointer to Type2]) expressions - where
* sizeof(Type1) > sizeof(Type2) - cause the following warning on ARM with GCC:
diff --git a/src/3rdparty/masm/wtf/VMTags.h b/src/3rdparty/masm/wtf/VMTags.h
index 117bc3721e..af5352e471 100644
--- a/src/3rdparty/masm/wtf/VMTags.h
+++ b/src/3rdparty/masm/wtf/VMTags.h
@@ -62,6 +62,14 @@
#define VM_TAG_FOR_WEBCORE_PURGEABLE_MEMORY VM_MAKE_TAG(69)
#endif // defined(VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS)
+#elif OS(LINUX)
+
+#define VM_TAG_FOR_TCMALLOC_MEMORY 0
+#define VM_TAG_FOR_COLLECTOR_MEMORY 1
+#define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY 2
+#define VM_TAG_FOR_REGISTERFILE_MEMORY 3
+#define VM_TAG_FOR_WEBCORE_PURGEABLE_MEMORY 4
+
#else // OS(DARWIN)
#define VM_TAG_FOR_TCMALLOC_MEMORY -1
diff --git a/src/3rdparty/masm/yarr/Yarr.h b/src/3rdparty/masm/yarr/Yarr.h
index d393e9fa90..ccf78f9880 100644
--- a/src/3rdparty/masm/yarr/Yarr.h
+++ b/src/3rdparty/masm/yarr/Yarr.h
@@ -25,25 +25,25 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Yarr_h
-#define Yarr_h
+#pragma once
-#include "YarrInterpreter.h"
-#include "YarrPattern.h"
+#include <limits.h>
+#include "YarrErrorCode.h"
namespace JSC { namespace Yarr {
-#define YarrStackSpaceForBackTrackInfoPatternCharacter 1 // Only for !fixed quantifiers.
-#define YarrStackSpaceForBackTrackInfoCharacterClass 1 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoPatternCharacter 2 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoCharacterClass 2 // Only for !fixed quantifiers.
#define YarrStackSpaceForBackTrackInfoBackReference 2
#define YarrStackSpaceForBackTrackInfoAlternative 1 // One per alternative.
#define YarrStackSpaceForBackTrackInfoParentheticalAssertion 1
-#define YarrStackSpaceForBackTrackInfoParenthesesOnce 1 // Only for !fixed quantifiers.
+#define YarrStackSpaceForBackTrackInfoParenthesesOnce 2
#define YarrStackSpaceForBackTrackInfoParenthesesTerminal 1
-#define YarrStackSpaceForBackTrackInfoParentheses 2
+#define YarrStackSpaceForBackTrackInfoParentheses 4
+#define YarrStackSpaceForDotStarEnclosure 1
static const unsigned quantifyInfinite = UINT_MAX;
-static const unsigned offsetNoMatch = (unsigned)-1;
+static const unsigned offsetNoMatch = std::numeric_limits<unsigned>::max();
// The below limit restricts the number of "recursive" match calls in order to
// avoid spending exponential time on complex regular expressions.
@@ -53,9 +53,10 @@ enum JSRegExpResult {
JSRegExpMatch = 1,
JSRegExpNoMatch = 0,
JSRegExpErrorNoMatch = -1,
- JSRegExpErrorHitLimit = -2,
- JSRegExpErrorNoMemory = -3,
- JSRegExpErrorInternal = -4
+ JSRegExpJITCodeFailure = -2,
+ JSRegExpErrorHitLimit = -3,
+ JSRegExpErrorNoMemory = -4,
+ JSRegExpErrorInternal = -5,
};
enum YarrCharSize {
@@ -63,7 +64,14 @@ enum YarrCharSize {
Char16
};
-} } // namespace JSC::Yarr
+enum class BuiltInCharacterClassID : unsigned {
+ DigitClassID,
+ SpaceClassID,
+ WordClassID,
+ DotClassID,
+ BaseUnicodePropertyID
+};
-#endif // Yarr_h
+struct BytecodePattern;
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrCanonicalize.h b/src/3rdparty/masm/yarr/YarrCanonicalize.h
new file mode 100644
index 0000000000..fb5e0231ac
--- /dev/null
+++ b/src/3rdparty/masm/yarr/YarrCanonicalize.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <unicode/utypes.h>
+
+namespace JSC { namespace Yarr {
+
+// This set of data provides information for each UCS2 code point as to the set of code points
+// that it should match under the ES6 case insensitive RegExp matching rules, specified in 21.2.2.8.2.
+// The non-Unicode tables are autogenerated using YarrCanonicalize.js into YarrCanonicalize.cpp.
+// The Unicode tables are autogenerated using the python script generateYarrCanonicalizeUnicode
+// which creates YarrCanonicalizeUnicode.cpp.
+enum UCS2CanonicalizationType {
+ CanonicalizeUnique, // No canonically equal values, e.g. 0x0.
+ CanonicalizeSet, // Value indicates a set in characterSetInfo.
+ CanonicalizeRangeLo, // Value is positive delta to pair, E.g. 0x41 has value 0x20, -> 0x61.
+ CanonicalizeRangeHi, // Value is positive delta to pair, E.g. 0x61 has value 0x20, -> 0x41.
+ CanonicalizeAlternatingAligned, // Aligned consequtive pair, e.g. 0x1f4,0x1f5.
+ CanonicalizeAlternatingUnaligned, // Unaligned consequtive pair, e.g. 0x241,0x242.
+};
+struct CanonicalizationRange {
+ UChar32 begin;
+ UChar32 end;
+ UChar32 value;
+ UCS2CanonicalizationType type;
+};
+
+extern const size_t UCS2_CANONICALIZATION_RANGES;
+extern const UChar32* const ucs2CharacterSetInfo[];
+extern const CanonicalizationRange ucs2RangeInfo[];
+
+extern const size_t UNICODE_CANONICALIZATION_RANGES;
+extern const UChar32* const unicodeCharacterSetInfo[];
+extern const CanonicalizationRange unicodeRangeInfo[];
+
+enum class CanonicalMode { UCS2, Unicode };
+
+inline const UChar32* canonicalCharacterSetInfo(unsigned index, CanonicalMode canonicalMode)
+{
+ const UChar32* const* rangeInfo = canonicalMode == CanonicalMode::UCS2 ? ucs2CharacterSetInfo : unicodeCharacterSetInfo;
+ return rangeInfo[index];
+}
+
+// This searches in log2 time over ~400-600 entries, so should typically result in 9 compares.
+inline const CanonicalizationRange* canonicalRangeInfoFor(UChar32 ch, CanonicalMode canonicalMode = CanonicalMode::UCS2)
+{
+ const CanonicalizationRange* info = canonicalMode == CanonicalMode::UCS2 ? ucs2RangeInfo : unicodeRangeInfo;
+ size_t entries = canonicalMode == CanonicalMode::UCS2 ? UCS2_CANONICALIZATION_RANGES : UNICODE_CANONICALIZATION_RANGES;
+
+ while (true) {
+ size_t candidate = entries >> 1;
+ const CanonicalizationRange* candidateInfo = info + candidate;
+ if (ch < candidateInfo->begin)
+ entries = candidate;
+ else if (ch <= candidateInfo->end)
+ return candidateInfo;
+ else {
+ info = candidateInfo + 1;
+ entries -= (candidate + 1);
+ }
+ }
+}
+
+// Should only be called for characters that have one canonically matching value.
+inline UChar32 getCanonicalPair(const CanonicalizationRange* info, UChar32 ch)
+{
+ ASSERT(ch >= info->begin && ch <= info->end);
+ switch (info->type) {
+ case CanonicalizeRangeLo:
+ return ch + info->value;
+ case CanonicalizeRangeHi:
+ return ch - info->value;
+ case CanonicalizeAlternatingAligned:
+ return ch ^ 1;
+ case CanonicalizeAlternatingUnaligned:
+ return ((ch - 1) ^ 1) + 1;
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+ return 0;
+}
+
+// Returns true if no other UCS2 codepoint can match this value.
+inline bool isCanonicallyUnique(UChar32 ch, CanonicalMode canonicalMode = CanonicalMode::UCS2)
+{
+ return canonicalRangeInfoFor(ch, canonicalMode)->type == CanonicalizeUnique;
+}
+
+// Returns true if values are equal, under the canonicalization rules.
+inline bool areCanonicallyEquivalent(UChar32 a, UChar32 b, CanonicalMode canonicalMode = CanonicalMode::UCS2)
+{
+ const CanonicalizationRange* info = canonicalRangeInfoFor(a, canonicalMode);
+ switch (info->type) {
+ case CanonicalizeUnique:
+ return a == b;
+ case CanonicalizeSet: {
+ for (const UChar32* set = canonicalCharacterSetInfo(info->value, canonicalMode); (a = *set); ++set) {
+ if (a == b)
+ return true;
+ }
+ return false;
+ }
+ case CanonicalizeRangeLo:
+ return (a == b) || (a + info->value == b);
+ case CanonicalizeRangeHi:
+ return (a == b) || (a - info->value == b);
+ case CanonicalizeAlternatingAligned:
+ return (a | 1) == (b | 1);
+ case CanonicalizeAlternatingUnaligned:
+ return ((a - 1) | 1) == ((b - 1) | 1);
+ }
+
+ RELEASE_ASSERT_NOT_REACHED();
+ return false;
+}
+
+} } // JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.cpp b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.cpp
index 7bb3d08eb5..d91c771590 100644
--- a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.cpp
+++ b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2013, 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,33 +23,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// DO NOT EDIT! - this file autogenerated by YarrCanonicalizeUCS2.js
+// DO NOT EDIT! - this file autogenerated by YarrCanonicalize.js
#include "config.h"
-#include "YarrCanonicalizeUCS2.h"
+#include "YarrCanonicalize.h"
namespace JSC { namespace Yarr {
-#include <stdint.h>
-
-uint16_t ucs2CharacterSet0[] = { 0x01c4u, 0x01c5u, 0x01c6u, 0 };
-uint16_t ucs2CharacterSet1[] = { 0x01c7u, 0x01c8u, 0x01c9u, 0 };
-uint16_t ucs2CharacterSet2[] = { 0x01cau, 0x01cbu, 0x01ccu, 0 };
-uint16_t ucs2CharacterSet3[] = { 0x01f1u, 0x01f2u, 0x01f3u, 0 };
-uint16_t ucs2CharacterSet4[] = { 0x0392u, 0x03b2u, 0x03d0u, 0 };
-uint16_t ucs2CharacterSet5[] = { 0x0395u, 0x03b5u, 0x03f5u, 0 };
-uint16_t ucs2CharacterSet6[] = { 0x0398u, 0x03b8u, 0x03d1u, 0 };
-uint16_t ucs2CharacterSet7[] = { 0x0345u, 0x0399u, 0x03b9u, 0x1fbeu, 0 };
-uint16_t ucs2CharacterSet8[] = { 0x039au, 0x03bau, 0x03f0u, 0 };
-uint16_t ucs2CharacterSet9[] = { 0x00b5u, 0x039cu, 0x03bcu, 0 };
-uint16_t ucs2CharacterSet10[] = { 0x03a0u, 0x03c0u, 0x03d6u, 0 };
-uint16_t ucs2CharacterSet11[] = { 0x03a1u, 0x03c1u, 0x03f1u, 0 };
-uint16_t ucs2CharacterSet12[] = { 0x03a3u, 0x03c2u, 0x03c3u, 0 };
-uint16_t ucs2CharacterSet13[] = { 0x03a6u, 0x03c6u, 0x03d5u, 0 };
-uint16_t ucs2CharacterSet14[] = { 0x1e60u, 0x1e61u, 0x1e9bu, 0 };
+const UChar32 ucs2CharacterSet0[] = { 0x01c4, 0x01c5, 0x01c6, 0 };
+const UChar32 ucs2CharacterSet1[] = { 0x01c7, 0x01c8, 0x01c9, 0 };
+const UChar32 ucs2CharacterSet2[] = { 0x01ca, 0x01cb, 0x01cc, 0 };
+const UChar32 ucs2CharacterSet3[] = { 0x01f1, 0x01f2, 0x01f3, 0 };
+const UChar32 ucs2CharacterSet4[] = { 0x0392, 0x03b2, 0x03d0, 0 };
+const UChar32 ucs2CharacterSet5[] = { 0x0395, 0x03b5, 0x03f5, 0 };
+const UChar32 ucs2CharacterSet6[] = { 0x0398, 0x03b8, 0x03d1, 0 };
+const UChar32 ucs2CharacterSet7[] = { 0x0345, 0x0399, 0x03b9, 0x1fbe, 0 };
+const UChar32 ucs2CharacterSet8[] = { 0x039a, 0x03ba, 0x03f0, 0 };
+const UChar32 ucs2CharacterSet9[] = { 0x00b5, 0x039c, 0x03bc, 0 };
+const UChar32 ucs2CharacterSet10[] = { 0x03a0, 0x03c0, 0x03d6, 0 };
+const UChar32 ucs2CharacterSet11[] = { 0x03a1, 0x03c1, 0x03f1, 0 };
+const UChar32 ucs2CharacterSet12[] = { 0x03a3, 0x03c2, 0x03c3, 0 };
+const UChar32 ucs2CharacterSet13[] = { 0x03a6, 0x03c6, 0x03d5, 0 };
+const UChar32 ucs2CharacterSet14[] = { 0x1e60, 0x1e61, 0x1e9b, 0 };
static const size_t UCS2_CANONICALIZATION_SETS = 15;
-uint16_t* characterSetInfo[UCS2_CANONICALIZATION_SETS] = {
+const UChar32* const ucs2CharacterSetInfo[UCS2_CANONICALIZATION_SETS] = {
ucs2CharacterSet0,
ucs2CharacterSet1,
ucs2CharacterSet2,
@@ -67,396 +65,399 @@ uint16_t* characterSetInfo[UCS2_CANONICALIZATION_SETS] = {
ucs2CharacterSet14,
};
-const size_t UCS2_CANONICALIZATION_RANGES = 364;
-UCS2CanonicalizationRange rangeInfo[UCS2_CANONICALIZATION_RANGES] = {
- { 0x0000u, 0x0040u, 0x0000u, CanonicalizeUnique },
- { 0x0041u, 0x005au, 0x0020u, CanonicalizeRangeLo },
- { 0x005bu, 0x0060u, 0x0000u, CanonicalizeUnique },
- { 0x0061u, 0x007au, 0x0020u, CanonicalizeRangeHi },
- { 0x007bu, 0x00b4u, 0x0000u, CanonicalizeUnique },
- { 0x00b5u, 0x00b5u, 0x0009u, CanonicalizeSet },
- { 0x00b6u, 0x00bfu, 0x0000u, CanonicalizeUnique },
- { 0x00c0u, 0x00d6u, 0x0020u, CanonicalizeRangeLo },
- { 0x00d7u, 0x00d7u, 0x0000u, CanonicalizeUnique },
- { 0x00d8u, 0x00deu, 0x0020u, CanonicalizeRangeLo },
- { 0x00dfu, 0x00dfu, 0x0000u, CanonicalizeUnique },
- { 0x00e0u, 0x00f6u, 0x0020u, CanonicalizeRangeHi },
- { 0x00f7u, 0x00f7u, 0x0000u, CanonicalizeUnique },
- { 0x00f8u, 0x00feu, 0x0020u, CanonicalizeRangeHi },
- { 0x00ffu, 0x00ffu, 0x0079u, CanonicalizeRangeLo },
- { 0x0100u, 0x012fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0130u, 0x0131u, 0x0000u, CanonicalizeUnique },
- { 0x0132u, 0x0137u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0138u, 0x0138u, 0x0000u, CanonicalizeUnique },
- { 0x0139u, 0x0148u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x0149u, 0x0149u, 0x0000u, CanonicalizeUnique },
- { 0x014au, 0x0177u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0178u, 0x0178u, 0x0079u, CanonicalizeRangeHi },
- { 0x0179u, 0x017eu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x017fu, 0x017fu, 0x0000u, CanonicalizeUnique },
- { 0x0180u, 0x0180u, 0x00c3u, CanonicalizeRangeLo },
- { 0x0181u, 0x0181u, 0x00d2u, CanonicalizeRangeLo },
- { 0x0182u, 0x0185u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0186u, 0x0186u, 0x00ceu, CanonicalizeRangeLo },
- { 0x0187u, 0x0188u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x0189u, 0x018au, 0x00cdu, CanonicalizeRangeLo },
- { 0x018bu, 0x018cu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x018du, 0x018du, 0x0000u, CanonicalizeUnique },
- { 0x018eu, 0x018eu, 0x004fu, CanonicalizeRangeLo },
- { 0x018fu, 0x018fu, 0x00cau, CanonicalizeRangeLo },
- { 0x0190u, 0x0190u, 0x00cbu, CanonicalizeRangeLo },
- { 0x0191u, 0x0192u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x0193u, 0x0193u, 0x00cdu, CanonicalizeRangeLo },
- { 0x0194u, 0x0194u, 0x00cfu, CanonicalizeRangeLo },
- { 0x0195u, 0x0195u, 0x0061u, CanonicalizeRangeLo },
- { 0x0196u, 0x0196u, 0x00d3u, CanonicalizeRangeLo },
- { 0x0197u, 0x0197u, 0x00d1u, CanonicalizeRangeLo },
- { 0x0198u, 0x0199u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x019au, 0x019au, 0x00a3u, CanonicalizeRangeLo },
- { 0x019bu, 0x019bu, 0x0000u, CanonicalizeUnique },
- { 0x019cu, 0x019cu, 0x00d3u, CanonicalizeRangeLo },
- { 0x019du, 0x019du, 0x00d5u, CanonicalizeRangeLo },
- { 0x019eu, 0x019eu, 0x0082u, CanonicalizeRangeLo },
- { 0x019fu, 0x019fu, 0x00d6u, CanonicalizeRangeLo },
- { 0x01a0u, 0x01a5u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01a6u, 0x01a6u, 0x00dau, CanonicalizeRangeLo },
- { 0x01a7u, 0x01a8u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x01a9u, 0x01a9u, 0x00dau, CanonicalizeRangeLo },
- { 0x01aau, 0x01abu, 0x0000u, CanonicalizeUnique },
- { 0x01acu, 0x01adu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01aeu, 0x01aeu, 0x00dau, CanonicalizeRangeLo },
- { 0x01afu, 0x01b0u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x01b1u, 0x01b2u, 0x00d9u, CanonicalizeRangeLo },
- { 0x01b3u, 0x01b6u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x01b7u, 0x01b7u, 0x00dbu, CanonicalizeRangeLo },
- { 0x01b8u, 0x01b9u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01bau, 0x01bbu, 0x0000u, CanonicalizeUnique },
- { 0x01bcu, 0x01bdu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01beu, 0x01beu, 0x0000u, CanonicalizeUnique },
- { 0x01bfu, 0x01bfu, 0x0038u, CanonicalizeRangeLo },
- { 0x01c0u, 0x01c3u, 0x0000u, CanonicalizeUnique },
- { 0x01c4u, 0x01c6u, 0x0000u, CanonicalizeSet },
- { 0x01c7u, 0x01c9u, 0x0001u, CanonicalizeSet },
- { 0x01cau, 0x01ccu, 0x0002u, CanonicalizeSet },
- { 0x01cdu, 0x01dcu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x01ddu, 0x01ddu, 0x004fu, CanonicalizeRangeHi },
- { 0x01deu, 0x01efu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01f0u, 0x01f0u, 0x0000u, CanonicalizeUnique },
- { 0x01f1u, 0x01f3u, 0x0003u, CanonicalizeSet },
- { 0x01f4u, 0x01f5u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x01f6u, 0x01f6u, 0x0061u, CanonicalizeRangeHi },
- { 0x01f7u, 0x01f7u, 0x0038u, CanonicalizeRangeHi },
- { 0x01f8u, 0x021fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0220u, 0x0220u, 0x0082u, CanonicalizeRangeHi },
- { 0x0221u, 0x0221u, 0x0000u, CanonicalizeUnique },
- { 0x0222u, 0x0233u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0234u, 0x0239u, 0x0000u, CanonicalizeUnique },
- { 0x023au, 0x023au, 0x2a2bu, CanonicalizeRangeLo },
- { 0x023bu, 0x023cu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x023du, 0x023du, 0x00a3u, CanonicalizeRangeHi },
- { 0x023eu, 0x023eu, 0x2a28u, CanonicalizeRangeLo },
- { 0x023fu, 0x0240u, 0x2a3fu, CanonicalizeRangeLo },
- { 0x0241u, 0x0242u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x0243u, 0x0243u, 0x00c3u, CanonicalizeRangeHi },
- { 0x0244u, 0x0244u, 0x0045u, CanonicalizeRangeLo },
- { 0x0245u, 0x0245u, 0x0047u, CanonicalizeRangeLo },
- { 0x0246u, 0x024fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0250u, 0x0250u, 0x2a1fu, CanonicalizeRangeLo },
- { 0x0251u, 0x0251u, 0x2a1cu, CanonicalizeRangeLo },
- { 0x0252u, 0x0252u, 0x2a1eu, CanonicalizeRangeLo },
- { 0x0253u, 0x0253u, 0x00d2u, CanonicalizeRangeHi },
- { 0x0254u, 0x0254u, 0x00ceu, CanonicalizeRangeHi },
- { 0x0255u, 0x0255u, 0x0000u, CanonicalizeUnique },
- { 0x0256u, 0x0257u, 0x00cdu, CanonicalizeRangeHi },
- { 0x0258u, 0x0258u, 0x0000u, CanonicalizeUnique },
- { 0x0259u, 0x0259u, 0x00cau, CanonicalizeRangeHi },
- { 0x025au, 0x025au, 0x0000u, CanonicalizeUnique },
- { 0x025bu, 0x025bu, 0x00cbu, CanonicalizeRangeHi },
- { 0x025cu, 0x025fu, 0x0000u, CanonicalizeUnique },
- { 0x0260u, 0x0260u, 0x00cdu, CanonicalizeRangeHi },
- { 0x0261u, 0x0262u, 0x0000u, CanonicalizeUnique },
- { 0x0263u, 0x0263u, 0x00cfu, CanonicalizeRangeHi },
- { 0x0264u, 0x0264u, 0x0000u, CanonicalizeUnique },
- { 0x0265u, 0x0265u, 0xa528u, CanonicalizeRangeLo },
- { 0x0266u, 0x0267u, 0x0000u, CanonicalizeUnique },
- { 0x0268u, 0x0268u, 0x00d1u, CanonicalizeRangeHi },
- { 0x0269u, 0x0269u, 0x00d3u, CanonicalizeRangeHi },
- { 0x026au, 0x026au, 0x0000u, CanonicalizeUnique },
- { 0x026bu, 0x026bu, 0x29f7u, CanonicalizeRangeLo },
- { 0x026cu, 0x026eu, 0x0000u, CanonicalizeUnique },
- { 0x026fu, 0x026fu, 0x00d3u, CanonicalizeRangeHi },
- { 0x0270u, 0x0270u, 0x0000u, CanonicalizeUnique },
- { 0x0271u, 0x0271u, 0x29fdu, CanonicalizeRangeLo },
- { 0x0272u, 0x0272u, 0x00d5u, CanonicalizeRangeHi },
- { 0x0273u, 0x0274u, 0x0000u, CanonicalizeUnique },
- { 0x0275u, 0x0275u, 0x00d6u, CanonicalizeRangeHi },
- { 0x0276u, 0x027cu, 0x0000u, CanonicalizeUnique },
- { 0x027du, 0x027du, 0x29e7u, CanonicalizeRangeLo },
- { 0x027eu, 0x027fu, 0x0000u, CanonicalizeUnique },
- { 0x0280u, 0x0280u, 0x00dau, CanonicalizeRangeHi },
- { 0x0281u, 0x0282u, 0x0000u, CanonicalizeUnique },
- { 0x0283u, 0x0283u, 0x00dau, CanonicalizeRangeHi },
- { 0x0284u, 0x0287u, 0x0000u, CanonicalizeUnique },
- { 0x0288u, 0x0288u, 0x00dau, CanonicalizeRangeHi },
- { 0x0289u, 0x0289u, 0x0045u, CanonicalizeRangeHi },
- { 0x028au, 0x028bu, 0x00d9u, CanonicalizeRangeHi },
- { 0x028cu, 0x028cu, 0x0047u, CanonicalizeRangeHi },
- { 0x028du, 0x0291u, 0x0000u, CanonicalizeUnique },
- { 0x0292u, 0x0292u, 0x00dbu, CanonicalizeRangeHi },
- { 0x0293u, 0x0344u, 0x0000u, CanonicalizeUnique },
- { 0x0345u, 0x0345u, 0x0007u, CanonicalizeSet },
- { 0x0346u, 0x036fu, 0x0000u, CanonicalizeUnique },
- { 0x0370u, 0x0373u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0374u, 0x0375u, 0x0000u, CanonicalizeUnique },
- { 0x0376u, 0x0377u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0378u, 0x037au, 0x0000u, CanonicalizeUnique },
- { 0x037bu, 0x037du, 0x0082u, CanonicalizeRangeLo },
- { 0x037eu, 0x0385u, 0x0000u, CanonicalizeUnique },
- { 0x0386u, 0x0386u, 0x0026u, CanonicalizeRangeLo },
- { 0x0387u, 0x0387u, 0x0000u, CanonicalizeUnique },
- { 0x0388u, 0x038au, 0x0025u, CanonicalizeRangeLo },
- { 0x038bu, 0x038bu, 0x0000u, CanonicalizeUnique },
- { 0x038cu, 0x038cu, 0x0040u, CanonicalizeRangeLo },
- { 0x038du, 0x038du, 0x0000u, CanonicalizeUnique },
- { 0x038eu, 0x038fu, 0x003fu, CanonicalizeRangeLo },
- { 0x0390u, 0x0390u, 0x0000u, CanonicalizeUnique },
- { 0x0391u, 0x0391u, 0x0020u, CanonicalizeRangeLo },
- { 0x0392u, 0x0392u, 0x0004u, CanonicalizeSet },
- { 0x0393u, 0x0394u, 0x0020u, CanonicalizeRangeLo },
- { 0x0395u, 0x0395u, 0x0005u, CanonicalizeSet },
- { 0x0396u, 0x0397u, 0x0020u, CanonicalizeRangeLo },
- { 0x0398u, 0x0398u, 0x0006u, CanonicalizeSet },
- { 0x0399u, 0x0399u, 0x0007u, CanonicalizeSet },
- { 0x039au, 0x039au, 0x0008u, CanonicalizeSet },
- { 0x039bu, 0x039bu, 0x0020u, CanonicalizeRangeLo },
- { 0x039cu, 0x039cu, 0x0009u, CanonicalizeSet },
- { 0x039du, 0x039fu, 0x0020u, CanonicalizeRangeLo },
- { 0x03a0u, 0x03a0u, 0x000au, CanonicalizeSet },
- { 0x03a1u, 0x03a1u, 0x000bu, CanonicalizeSet },
- { 0x03a2u, 0x03a2u, 0x0000u, CanonicalizeUnique },
- { 0x03a3u, 0x03a3u, 0x000cu, CanonicalizeSet },
- { 0x03a4u, 0x03a5u, 0x0020u, CanonicalizeRangeLo },
- { 0x03a6u, 0x03a6u, 0x000du, CanonicalizeSet },
- { 0x03a7u, 0x03abu, 0x0020u, CanonicalizeRangeLo },
- { 0x03acu, 0x03acu, 0x0026u, CanonicalizeRangeHi },
- { 0x03adu, 0x03afu, 0x0025u, CanonicalizeRangeHi },
- { 0x03b0u, 0x03b0u, 0x0000u, CanonicalizeUnique },
- { 0x03b1u, 0x03b1u, 0x0020u, CanonicalizeRangeHi },
- { 0x03b2u, 0x03b2u, 0x0004u, CanonicalizeSet },
- { 0x03b3u, 0x03b4u, 0x0020u, CanonicalizeRangeHi },
- { 0x03b5u, 0x03b5u, 0x0005u, CanonicalizeSet },
- { 0x03b6u, 0x03b7u, 0x0020u, CanonicalizeRangeHi },
- { 0x03b8u, 0x03b8u, 0x0006u, CanonicalizeSet },
- { 0x03b9u, 0x03b9u, 0x0007u, CanonicalizeSet },
- { 0x03bau, 0x03bau, 0x0008u, CanonicalizeSet },
- { 0x03bbu, 0x03bbu, 0x0020u, CanonicalizeRangeHi },
- { 0x03bcu, 0x03bcu, 0x0009u, CanonicalizeSet },
- { 0x03bdu, 0x03bfu, 0x0020u, CanonicalizeRangeHi },
- { 0x03c0u, 0x03c0u, 0x000au, CanonicalizeSet },
- { 0x03c1u, 0x03c1u, 0x000bu, CanonicalizeSet },
- { 0x03c2u, 0x03c3u, 0x000cu, CanonicalizeSet },
- { 0x03c4u, 0x03c5u, 0x0020u, CanonicalizeRangeHi },
- { 0x03c6u, 0x03c6u, 0x000du, CanonicalizeSet },
- { 0x03c7u, 0x03cbu, 0x0020u, CanonicalizeRangeHi },
- { 0x03ccu, 0x03ccu, 0x0040u, CanonicalizeRangeHi },
- { 0x03cdu, 0x03ceu, 0x003fu, CanonicalizeRangeHi },
- { 0x03cfu, 0x03cfu, 0x0008u, CanonicalizeRangeLo },
- { 0x03d0u, 0x03d0u, 0x0004u, CanonicalizeSet },
- { 0x03d1u, 0x03d1u, 0x0006u, CanonicalizeSet },
- { 0x03d2u, 0x03d4u, 0x0000u, CanonicalizeUnique },
- { 0x03d5u, 0x03d5u, 0x000du, CanonicalizeSet },
- { 0x03d6u, 0x03d6u, 0x000au, CanonicalizeSet },
- { 0x03d7u, 0x03d7u, 0x0008u, CanonicalizeRangeHi },
- { 0x03d8u, 0x03efu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x03f0u, 0x03f0u, 0x0008u, CanonicalizeSet },
- { 0x03f1u, 0x03f1u, 0x000bu, CanonicalizeSet },
- { 0x03f2u, 0x03f2u, 0x0007u, CanonicalizeRangeLo },
- { 0x03f3u, 0x03f4u, 0x0000u, CanonicalizeUnique },
- { 0x03f5u, 0x03f5u, 0x0005u, CanonicalizeSet },
- { 0x03f6u, 0x03f6u, 0x0000u, CanonicalizeUnique },
- { 0x03f7u, 0x03f8u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x03f9u, 0x03f9u, 0x0007u, CanonicalizeRangeHi },
- { 0x03fau, 0x03fbu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x03fcu, 0x03fcu, 0x0000u, CanonicalizeUnique },
- { 0x03fdu, 0x03ffu, 0x0082u, CanonicalizeRangeHi },
- { 0x0400u, 0x040fu, 0x0050u, CanonicalizeRangeLo },
- { 0x0410u, 0x042fu, 0x0020u, CanonicalizeRangeLo },
- { 0x0430u, 0x044fu, 0x0020u, CanonicalizeRangeHi },
- { 0x0450u, 0x045fu, 0x0050u, CanonicalizeRangeHi },
- { 0x0460u, 0x0481u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0482u, 0x0489u, 0x0000u, CanonicalizeUnique },
- { 0x048au, 0x04bfu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x04c0u, 0x04c0u, 0x000fu, CanonicalizeRangeLo },
- { 0x04c1u, 0x04ceu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x04cfu, 0x04cfu, 0x000fu, CanonicalizeRangeHi },
- { 0x04d0u, 0x0527u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x0528u, 0x0530u, 0x0000u, CanonicalizeUnique },
- { 0x0531u, 0x0556u, 0x0030u, CanonicalizeRangeLo },
- { 0x0557u, 0x0560u, 0x0000u, CanonicalizeUnique },
- { 0x0561u, 0x0586u, 0x0030u, CanonicalizeRangeHi },
- { 0x0587u, 0x109fu, 0x0000u, CanonicalizeUnique },
- { 0x10a0u, 0x10c5u, 0x1c60u, CanonicalizeRangeLo },
- { 0x10c6u, 0x1d78u, 0x0000u, CanonicalizeUnique },
- { 0x1d79u, 0x1d79u, 0x8a04u, CanonicalizeRangeLo },
- { 0x1d7au, 0x1d7cu, 0x0000u, CanonicalizeUnique },
- { 0x1d7du, 0x1d7du, 0x0ee6u, CanonicalizeRangeLo },
- { 0x1d7eu, 0x1dffu, 0x0000u, CanonicalizeUnique },
- { 0x1e00u, 0x1e5fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x1e60u, 0x1e61u, 0x000eu, CanonicalizeSet },
- { 0x1e62u, 0x1e95u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x1e96u, 0x1e9au, 0x0000u, CanonicalizeUnique },
- { 0x1e9bu, 0x1e9bu, 0x000eu, CanonicalizeSet },
- { 0x1e9cu, 0x1e9fu, 0x0000u, CanonicalizeUnique },
- { 0x1ea0u, 0x1effu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x1f00u, 0x1f07u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f08u, 0x1f0fu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f10u, 0x1f15u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f16u, 0x1f17u, 0x0000u, CanonicalizeUnique },
- { 0x1f18u, 0x1f1du, 0x0008u, CanonicalizeRangeHi },
- { 0x1f1eu, 0x1f1fu, 0x0000u, CanonicalizeUnique },
- { 0x1f20u, 0x1f27u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f28u, 0x1f2fu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f30u, 0x1f37u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f38u, 0x1f3fu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f40u, 0x1f45u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f46u, 0x1f47u, 0x0000u, CanonicalizeUnique },
- { 0x1f48u, 0x1f4du, 0x0008u, CanonicalizeRangeHi },
- { 0x1f4eu, 0x1f50u, 0x0000u, CanonicalizeUnique },
- { 0x1f51u, 0x1f51u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f52u, 0x1f52u, 0x0000u, CanonicalizeUnique },
- { 0x1f53u, 0x1f53u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f54u, 0x1f54u, 0x0000u, CanonicalizeUnique },
- { 0x1f55u, 0x1f55u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f56u, 0x1f56u, 0x0000u, CanonicalizeUnique },
- { 0x1f57u, 0x1f57u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f58u, 0x1f58u, 0x0000u, CanonicalizeUnique },
- { 0x1f59u, 0x1f59u, 0x0008u, CanonicalizeRangeHi },
- { 0x1f5au, 0x1f5au, 0x0000u, CanonicalizeUnique },
- { 0x1f5bu, 0x1f5bu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f5cu, 0x1f5cu, 0x0000u, CanonicalizeUnique },
- { 0x1f5du, 0x1f5du, 0x0008u, CanonicalizeRangeHi },
- { 0x1f5eu, 0x1f5eu, 0x0000u, CanonicalizeUnique },
- { 0x1f5fu, 0x1f5fu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f60u, 0x1f67u, 0x0008u, CanonicalizeRangeLo },
- { 0x1f68u, 0x1f6fu, 0x0008u, CanonicalizeRangeHi },
- { 0x1f70u, 0x1f71u, 0x004au, CanonicalizeRangeLo },
- { 0x1f72u, 0x1f75u, 0x0056u, CanonicalizeRangeLo },
- { 0x1f76u, 0x1f77u, 0x0064u, CanonicalizeRangeLo },
- { 0x1f78u, 0x1f79u, 0x0080u, CanonicalizeRangeLo },
- { 0x1f7au, 0x1f7bu, 0x0070u, CanonicalizeRangeLo },
- { 0x1f7cu, 0x1f7du, 0x007eu, CanonicalizeRangeLo },
- { 0x1f7eu, 0x1fafu, 0x0000u, CanonicalizeUnique },
- { 0x1fb0u, 0x1fb1u, 0x0008u, CanonicalizeRangeLo },
- { 0x1fb2u, 0x1fb7u, 0x0000u, CanonicalizeUnique },
- { 0x1fb8u, 0x1fb9u, 0x0008u, CanonicalizeRangeHi },
- { 0x1fbau, 0x1fbbu, 0x004au, CanonicalizeRangeHi },
- { 0x1fbcu, 0x1fbdu, 0x0000u, CanonicalizeUnique },
- { 0x1fbeu, 0x1fbeu, 0x0007u, CanonicalizeSet },
- { 0x1fbfu, 0x1fc7u, 0x0000u, CanonicalizeUnique },
- { 0x1fc8u, 0x1fcbu, 0x0056u, CanonicalizeRangeHi },
- { 0x1fccu, 0x1fcfu, 0x0000u, CanonicalizeUnique },
- { 0x1fd0u, 0x1fd1u, 0x0008u, CanonicalizeRangeLo },
- { 0x1fd2u, 0x1fd7u, 0x0000u, CanonicalizeUnique },
- { 0x1fd8u, 0x1fd9u, 0x0008u, CanonicalizeRangeHi },
- { 0x1fdau, 0x1fdbu, 0x0064u, CanonicalizeRangeHi },
- { 0x1fdcu, 0x1fdfu, 0x0000u, CanonicalizeUnique },
- { 0x1fe0u, 0x1fe1u, 0x0008u, CanonicalizeRangeLo },
- { 0x1fe2u, 0x1fe4u, 0x0000u, CanonicalizeUnique },
- { 0x1fe5u, 0x1fe5u, 0x0007u, CanonicalizeRangeLo },
- { 0x1fe6u, 0x1fe7u, 0x0000u, CanonicalizeUnique },
- { 0x1fe8u, 0x1fe9u, 0x0008u, CanonicalizeRangeHi },
- { 0x1feau, 0x1febu, 0x0070u, CanonicalizeRangeHi },
- { 0x1fecu, 0x1fecu, 0x0007u, CanonicalizeRangeHi },
- { 0x1fedu, 0x1ff7u, 0x0000u, CanonicalizeUnique },
- { 0x1ff8u, 0x1ff9u, 0x0080u, CanonicalizeRangeHi },
- { 0x1ffau, 0x1ffbu, 0x007eu, CanonicalizeRangeHi },
- { 0x1ffcu, 0x2131u, 0x0000u, CanonicalizeUnique },
- { 0x2132u, 0x2132u, 0x001cu, CanonicalizeRangeLo },
- { 0x2133u, 0x214du, 0x0000u, CanonicalizeUnique },
- { 0x214eu, 0x214eu, 0x001cu, CanonicalizeRangeHi },
- { 0x214fu, 0x215fu, 0x0000u, CanonicalizeUnique },
- { 0x2160u, 0x216fu, 0x0010u, CanonicalizeRangeLo },
- { 0x2170u, 0x217fu, 0x0010u, CanonicalizeRangeHi },
- { 0x2180u, 0x2182u, 0x0000u, CanonicalizeUnique },
- { 0x2183u, 0x2184u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x2185u, 0x24b5u, 0x0000u, CanonicalizeUnique },
- { 0x24b6u, 0x24cfu, 0x001au, CanonicalizeRangeLo },
- { 0x24d0u, 0x24e9u, 0x001au, CanonicalizeRangeHi },
- { 0x24eau, 0x2bffu, 0x0000u, CanonicalizeUnique },
- { 0x2c00u, 0x2c2eu, 0x0030u, CanonicalizeRangeLo },
- { 0x2c2fu, 0x2c2fu, 0x0000u, CanonicalizeUnique },
- { 0x2c30u, 0x2c5eu, 0x0030u, CanonicalizeRangeHi },
- { 0x2c5fu, 0x2c5fu, 0x0000u, CanonicalizeUnique },
- { 0x2c60u, 0x2c61u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x2c62u, 0x2c62u, 0x29f7u, CanonicalizeRangeHi },
- { 0x2c63u, 0x2c63u, 0x0ee6u, CanonicalizeRangeHi },
- { 0x2c64u, 0x2c64u, 0x29e7u, CanonicalizeRangeHi },
- { 0x2c65u, 0x2c65u, 0x2a2bu, CanonicalizeRangeHi },
- { 0x2c66u, 0x2c66u, 0x2a28u, CanonicalizeRangeHi },
- { 0x2c67u, 0x2c6cu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x2c6du, 0x2c6du, 0x2a1cu, CanonicalizeRangeHi },
- { 0x2c6eu, 0x2c6eu, 0x29fdu, CanonicalizeRangeHi },
- { 0x2c6fu, 0x2c6fu, 0x2a1fu, CanonicalizeRangeHi },
- { 0x2c70u, 0x2c70u, 0x2a1eu, CanonicalizeRangeHi },
- { 0x2c71u, 0x2c71u, 0x0000u, CanonicalizeUnique },
- { 0x2c72u, 0x2c73u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x2c74u, 0x2c74u, 0x0000u, CanonicalizeUnique },
- { 0x2c75u, 0x2c76u, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x2c77u, 0x2c7du, 0x0000u, CanonicalizeUnique },
- { 0x2c7eu, 0x2c7fu, 0x2a3fu, CanonicalizeRangeHi },
- { 0x2c80u, 0x2ce3u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0x2ce4u, 0x2ceau, 0x0000u, CanonicalizeUnique },
- { 0x2cebu, 0x2ceeu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0x2cefu, 0x2cffu, 0x0000u, CanonicalizeUnique },
- { 0x2d00u, 0x2d25u, 0x1c60u, CanonicalizeRangeHi },
- { 0x2d26u, 0xa63fu, 0x0000u, CanonicalizeUnique },
- { 0xa640u, 0xa66du, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa66eu, 0xa67fu, 0x0000u, CanonicalizeUnique },
- { 0xa680u, 0xa697u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa698u, 0xa721u, 0x0000u, CanonicalizeUnique },
- { 0xa722u, 0xa72fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa730u, 0xa731u, 0x0000u, CanonicalizeUnique },
- { 0xa732u, 0xa76fu, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa770u, 0xa778u, 0x0000u, CanonicalizeUnique },
- { 0xa779u, 0xa77cu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0xa77du, 0xa77du, 0x8a04u, CanonicalizeRangeHi },
- { 0xa77eu, 0xa787u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa788u, 0xa78au, 0x0000u, CanonicalizeUnique },
- { 0xa78bu, 0xa78cu, 0x0000u, CanonicalizeAlternatingUnaligned },
- { 0xa78du, 0xa78du, 0xa528u, CanonicalizeRangeHi },
- { 0xa78eu, 0xa78fu, 0x0000u, CanonicalizeUnique },
- { 0xa790u, 0xa791u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa792u, 0xa79fu, 0x0000u, CanonicalizeUnique },
- { 0xa7a0u, 0xa7a9u, 0x0000u, CanonicalizeAlternatingAligned },
- { 0xa7aau, 0xff20u, 0x0000u, CanonicalizeUnique },
- { 0xff21u, 0xff3au, 0x0020u, CanonicalizeRangeLo },
- { 0xff3bu, 0xff40u, 0x0000u, CanonicalizeUnique },
- { 0xff41u, 0xff5au, 0x0020u, CanonicalizeRangeHi },
- { 0xff5bu, 0xffffu, 0x0000u, CanonicalizeUnique },
-};
-
-const size_t LATIN_CANONICALIZATION_RANGES = 20;
-LatinCanonicalizationRange latinRangeInfo[LATIN_CANONICALIZATION_RANGES] = {
- { 0x0000u, 0x0040u, 0x0000u, CanonicalizeLatinSelf },
- { 0x0041u, 0x005au, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x005bu, 0x0060u, 0x0000u, CanonicalizeLatinSelf },
- { 0x0061u, 0x007au, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x007bu, 0x00bfu, 0x0000u, CanonicalizeLatinSelf },
- { 0x00c0u, 0x00d6u, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x00d7u, 0x00d7u, 0x0000u, CanonicalizeLatinSelf },
- { 0x00d8u, 0x00deu, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x00dfu, 0x00dfu, 0x0000u, CanonicalizeLatinSelf },
- { 0x00e0u, 0x00f6u, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x00f7u, 0x00f7u, 0x0000u, CanonicalizeLatinSelf },
- { 0x00f8u, 0x00feu, 0x0000u, CanonicalizeLatinMask0x20 },
- { 0x00ffu, 0x00ffu, 0x0000u, CanonicalizeLatinSelf },
- { 0x0100u, 0x0177u, 0x0000u, CanonicalizeLatinInvalid },
- { 0x0178u, 0x0178u, 0x00ffu, CanonicalizeLatinOther },
- { 0x0179u, 0x039bu, 0x0000u, CanonicalizeLatinInvalid },
- { 0x039cu, 0x039cu, 0x00b5u, CanonicalizeLatinOther },
- { 0x039du, 0x03bbu, 0x0000u, CanonicalizeLatinInvalid },
- { 0x03bcu, 0x03bcu, 0x00b5u, CanonicalizeLatinOther },
- { 0x03bdu, 0xffffu, 0x0000u, CanonicalizeLatinInvalid },
+const size_t UCS2_CANONICALIZATION_RANGES = 391;
+const CanonicalizationRange ucs2RangeInfo[UCS2_CANONICALIZATION_RANGES] = {
+ { 0x0000, 0x0040, 0x0000, CanonicalizeUnique },
+ { 0x0041, 0x005a, 0x0020, CanonicalizeRangeLo },
+ { 0x005b, 0x0060, 0x0000, CanonicalizeUnique },
+ { 0x0061, 0x007a, 0x0020, CanonicalizeRangeHi },
+ { 0x007b, 0x00b4, 0x0000, CanonicalizeUnique },
+ { 0x00b5, 0x00b5, 0x0009, CanonicalizeSet },
+ { 0x00b6, 0x00bf, 0x0000, CanonicalizeUnique },
+ { 0x00c0, 0x00d6, 0x0020, CanonicalizeRangeLo },
+ { 0x00d7, 0x00d7, 0x0000, CanonicalizeUnique },
+ { 0x00d8, 0x00de, 0x0020, CanonicalizeRangeLo },
+ { 0x00df, 0x00df, 0x0000, CanonicalizeUnique },
+ { 0x00e0, 0x00f6, 0x0020, CanonicalizeRangeHi },
+ { 0x00f7, 0x00f7, 0x0000, CanonicalizeUnique },
+ { 0x00f8, 0x00fe, 0x0020, CanonicalizeRangeHi },
+ { 0x00ff, 0x00ff, 0x0079, CanonicalizeRangeLo },
+ { 0x0100, 0x012f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0130, 0x0131, 0x0000, CanonicalizeUnique },
+ { 0x0132, 0x0137, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0138, 0x0138, 0x0000, CanonicalizeUnique },
+ { 0x0139, 0x0148, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0149, 0x0149, 0x0000, CanonicalizeUnique },
+ { 0x014a, 0x0177, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0178, 0x0178, 0x0079, CanonicalizeRangeHi },
+ { 0x0179, 0x017e, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x017f, 0x017f, 0x0000, CanonicalizeUnique },
+ { 0x0180, 0x0180, 0x00c3, CanonicalizeRangeLo },
+ { 0x0181, 0x0181, 0x00d2, CanonicalizeRangeLo },
+ { 0x0182, 0x0185, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0186, 0x0186, 0x00ce, CanonicalizeRangeLo },
+ { 0x0187, 0x0188, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0189, 0x018a, 0x00cd, CanonicalizeRangeLo },
+ { 0x018b, 0x018c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x018d, 0x018d, 0x0000, CanonicalizeUnique },
+ { 0x018e, 0x018e, 0x004f, CanonicalizeRangeLo },
+ { 0x018f, 0x018f, 0x00ca, CanonicalizeRangeLo },
+ { 0x0190, 0x0190, 0x00cb, CanonicalizeRangeLo },
+ { 0x0191, 0x0192, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0193, 0x0193, 0x00cd, CanonicalizeRangeLo },
+ { 0x0194, 0x0194, 0x00cf, CanonicalizeRangeLo },
+ { 0x0195, 0x0195, 0x0061, CanonicalizeRangeLo },
+ { 0x0196, 0x0196, 0x00d3, CanonicalizeRangeLo },
+ { 0x0197, 0x0197, 0x00d1, CanonicalizeRangeLo },
+ { 0x0198, 0x0199, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x019a, 0x019a, 0x00a3, CanonicalizeRangeLo },
+ { 0x019b, 0x019b, 0x0000, CanonicalizeUnique },
+ { 0x019c, 0x019c, 0x00d3, CanonicalizeRangeLo },
+ { 0x019d, 0x019d, 0x00d5, CanonicalizeRangeLo },
+ { 0x019e, 0x019e, 0x0082, CanonicalizeRangeLo },
+ { 0x019f, 0x019f, 0x00d6, CanonicalizeRangeLo },
+ { 0x01a0, 0x01a5, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01a6, 0x01a6, 0x00da, CanonicalizeRangeLo },
+ { 0x01a7, 0x01a8, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01a9, 0x01a9, 0x00da, CanonicalizeRangeLo },
+ { 0x01aa, 0x01ab, 0x0000, CanonicalizeUnique },
+ { 0x01ac, 0x01ad, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01ae, 0x01ae, 0x00da, CanonicalizeRangeLo },
+ { 0x01af, 0x01b0, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01b1, 0x01b2, 0x00d9, CanonicalizeRangeLo },
+ { 0x01b3, 0x01b6, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01b7, 0x01b7, 0x00db, CanonicalizeRangeLo },
+ { 0x01b8, 0x01b9, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01ba, 0x01bb, 0x0000, CanonicalizeUnique },
+ { 0x01bc, 0x01bd, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01be, 0x01be, 0x0000, CanonicalizeUnique },
+ { 0x01bf, 0x01bf, 0x0038, CanonicalizeRangeLo },
+ { 0x01c0, 0x01c3, 0x0000, CanonicalizeUnique },
+ { 0x01c4, 0x01c6, 0x0000, CanonicalizeSet },
+ { 0x01c7, 0x01c9, 0x0001, CanonicalizeSet },
+ { 0x01ca, 0x01cc, 0x0002, CanonicalizeSet },
+ { 0x01cd, 0x01dc, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01dd, 0x01dd, 0x004f, CanonicalizeRangeHi },
+ { 0x01de, 0x01ef, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01f0, 0x01f0, 0x0000, CanonicalizeUnique },
+ { 0x01f1, 0x01f3, 0x0003, CanonicalizeSet },
+ { 0x01f4, 0x01f5, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01f6, 0x01f6, 0x0061, CanonicalizeRangeHi },
+ { 0x01f7, 0x01f7, 0x0038, CanonicalizeRangeHi },
+ { 0x01f8, 0x021f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0220, 0x0220, 0x0082, CanonicalizeRangeHi },
+ { 0x0221, 0x0221, 0x0000, CanonicalizeUnique },
+ { 0x0222, 0x0233, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0234, 0x0239, 0x0000, CanonicalizeUnique },
+ { 0x023a, 0x023a, 0x2a2b, CanonicalizeRangeLo },
+ { 0x023b, 0x023c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x023d, 0x023d, 0x00a3, CanonicalizeRangeHi },
+ { 0x023e, 0x023e, 0x2a28, CanonicalizeRangeLo },
+ { 0x023f, 0x0240, 0x2a3f, CanonicalizeRangeLo },
+ { 0x0241, 0x0242, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0243, 0x0243, 0x00c3, CanonicalizeRangeHi },
+ { 0x0244, 0x0244, 0x0045, CanonicalizeRangeLo },
+ { 0x0245, 0x0245, 0x0047, CanonicalizeRangeLo },
+ { 0x0246, 0x024f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0250, 0x0250, 0x2a1f, CanonicalizeRangeLo },
+ { 0x0251, 0x0251, 0x2a1c, CanonicalizeRangeLo },
+ { 0x0252, 0x0252, 0x2a1e, CanonicalizeRangeLo },
+ { 0x0253, 0x0253, 0x00d2, CanonicalizeRangeHi },
+ { 0x0254, 0x0254, 0x00ce, CanonicalizeRangeHi },
+ { 0x0255, 0x0255, 0x0000, CanonicalizeUnique },
+ { 0x0256, 0x0257, 0x00cd, CanonicalizeRangeHi },
+ { 0x0258, 0x0258, 0x0000, CanonicalizeUnique },
+ { 0x0259, 0x0259, 0x00ca, CanonicalizeRangeHi },
+ { 0x025a, 0x025a, 0x0000, CanonicalizeUnique },
+ { 0x025b, 0x025b, 0x00cb, CanonicalizeRangeHi },
+ { 0x025c, 0x025c, 0xa54f, CanonicalizeRangeLo },
+ { 0x025d, 0x025f, 0x0000, CanonicalizeUnique },
+ { 0x0260, 0x0260, 0x00cd, CanonicalizeRangeHi },
+ { 0x0261, 0x0261, 0xa54b, CanonicalizeRangeLo },
+ { 0x0262, 0x0262, 0x0000, CanonicalizeUnique },
+ { 0x0263, 0x0263, 0x00cf, CanonicalizeRangeHi },
+ { 0x0264, 0x0264, 0x0000, CanonicalizeUnique },
+ { 0x0265, 0x0265, 0xa528, CanonicalizeRangeLo },
+ { 0x0266, 0x0266, 0xa544, CanonicalizeRangeLo },
+ { 0x0267, 0x0267, 0x0000, CanonicalizeUnique },
+ { 0x0268, 0x0268, 0x00d1, CanonicalizeRangeHi },
+ { 0x0269, 0x0269, 0x00d3, CanonicalizeRangeHi },
+ { 0x026a, 0x026a, 0x0000, CanonicalizeUnique },
+ { 0x026b, 0x026b, 0x29f7, CanonicalizeRangeLo },
+ { 0x026c, 0x026c, 0xa541, CanonicalizeRangeLo },
+ { 0x026d, 0x026e, 0x0000, CanonicalizeUnique },
+ { 0x026f, 0x026f, 0x00d3, CanonicalizeRangeHi },
+ { 0x0270, 0x0270, 0x0000, CanonicalizeUnique },
+ { 0x0271, 0x0271, 0x29fd, CanonicalizeRangeLo },
+ { 0x0272, 0x0272, 0x00d5, CanonicalizeRangeHi },
+ { 0x0273, 0x0274, 0x0000, CanonicalizeUnique },
+ { 0x0275, 0x0275, 0x00d6, CanonicalizeRangeHi },
+ { 0x0276, 0x027c, 0x0000, CanonicalizeUnique },
+ { 0x027d, 0x027d, 0x29e7, CanonicalizeRangeLo },
+ { 0x027e, 0x027f, 0x0000, CanonicalizeUnique },
+ { 0x0280, 0x0280, 0x00da, CanonicalizeRangeHi },
+ { 0x0281, 0x0282, 0x0000, CanonicalizeUnique },
+ { 0x0283, 0x0283, 0x00da, CanonicalizeRangeHi },
+ { 0x0284, 0x0286, 0x0000, CanonicalizeUnique },
+ { 0x0287, 0x0287, 0xa52a, CanonicalizeRangeLo },
+ { 0x0288, 0x0288, 0x00da, CanonicalizeRangeHi },
+ { 0x0289, 0x0289, 0x0045, CanonicalizeRangeHi },
+ { 0x028a, 0x028b, 0x00d9, CanonicalizeRangeHi },
+ { 0x028c, 0x028c, 0x0047, CanonicalizeRangeHi },
+ { 0x028d, 0x0291, 0x0000, CanonicalizeUnique },
+ { 0x0292, 0x0292, 0x00db, CanonicalizeRangeHi },
+ { 0x0293, 0x029d, 0x0000, CanonicalizeUnique },
+ { 0x029e, 0x029e, 0xa512, CanonicalizeRangeLo },
+ { 0x029f, 0x0344, 0x0000, CanonicalizeUnique },
+ { 0x0345, 0x0345, 0x0007, CanonicalizeSet },
+ { 0x0346, 0x036f, 0x0000, CanonicalizeUnique },
+ { 0x0370, 0x0373, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0374, 0x0375, 0x0000, CanonicalizeUnique },
+ { 0x0376, 0x0377, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0378, 0x037a, 0x0000, CanonicalizeUnique },
+ { 0x037b, 0x037d, 0x0082, CanonicalizeRangeLo },
+ { 0x037e, 0x037e, 0x0000, CanonicalizeUnique },
+ { 0x037f, 0x037f, 0x0074, CanonicalizeRangeLo },
+ { 0x0380, 0x0385, 0x0000, CanonicalizeUnique },
+ { 0x0386, 0x0386, 0x0026, CanonicalizeRangeLo },
+ { 0x0387, 0x0387, 0x0000, CanonicalizeUnique },
+ { 0x0388, 0x038a, 0x0025, CanonicalizeRangeLo },
+ { 0x038b, 0x038b, 0x0000, CanonicalizeUnique },
+ { 0x038c, 0x038c, 0x0040, CanonicalizeRangeLo },
+ { 0x038d, 0x038d, 0x0000, CanonicalizeUnique },
+ { 0x038e, 0x038f, 0x003f, CanonicalizeRangeLo },
+ { 0x0390, 0x0390, 0x0000, CanonicalizeUnique },
+ { 0x0391, 0x0391, 0x0020, CanonicalizeRangeLo },
+ { 0x0392, 0x0392, 0x0004, CanonicalizeSet },
+ { 0x0393, 0x0394, 0x0020, CanonicalizeRangeLo },
+ { 0x0395, 0x0395, 0x0005, CanonicalizeSet },
+ { 0x0396, 0x0397, 0x0020, CanonicalizeRangeLo },
+ { 0x0398, 0x0398, 0x0006, CanonicalizeSet },
+ { 0x0399, 0x0399, 0x0007, CanonicalizeSet },
+ { 0x039a, 0x039a, 0x0008, CanonicalizeSet },
+ { 0x039b, 0x039b, 0x0020, CanonicalizeRangeLo },
+ { 0x039c, 0x039c, 0x0009, CanonicalizeSet },
+ { 0x039d, 0x039f, 0x0020, CanonicalizeRangeLo },
+ { 0x03a0, 0x03a0, 0x000a, CanonicalizeSet },
+ { 0x03a1, 0x03a1, 0x000b, CanonicalizeSet },
+ { 0x03a2, 0x03a2, 0x0000, CanonicalizeUnique },
+ { 0x03a3, 0x03a3, 0x000c, CanonicalizeSet },
+ { 0x03a4, 0x03a5, 0x0020, CanonicalizeRangeLo },
+ { 0x03a6, 0x03a6, 0x000d, CanonicalizeSet },
+ { 0x03a7, 0x03ab, 0x0020, CanonicalizeRangeLo },
+ { 0x03ac, 0x03ac, 0x0026, CanonicalizeRangeHi },
+ { 0x03ad, 0x03af, 0x0025, CanonicalizeRangeHi },
+ { 0x03b0, 0x03b0, 0x0000, CanonicalizeUnique },
+ { 0x03b1, 0x03b1, 0x0020, CanonicalizeRangeHi },
+ { 0x03b2, 0x03b2, 0x0004, CanonicalizeSet },
+ { 0x03b3, 0x03b4, 0x0020, CanonicalizeRangeHi },
+ { 0x03b5, 0x03b5, 0x0005, CanonicalizeSet },
+ { 0x03b6, 0x03b7, 0x0020, CanonicalizeRangeHi },
+ { 0x03b8, 0x03b8, 0x0006, CanonicalizeSet },
+ { 0x03b9, 0x03b9, 0x0007, CanonicalizeSet },
+ { 0x03ba, 0x03ba, 0x0008, CanonicalizeSet },
+ { 0x03bb, 0x03bb, 0x0020, CanonicalizeRangeHi },
+ { 0x03bc, 0x03bc, 0x0009, CanonicalizeSet },
+ { 0x03bd, 0x03bf, 0x0020, CanonicalizeRangeHi },
+ { 0x03c0, 0x03c0, 0x000a, CanonicalizeSet },
+ { 0x03c1, 0x03c1, 0x000b, CanonicalizeSet },
+ { 0x03c2, 0x03c3, 0x000c, CanonicalizeSet },
+ { 0x03c4, 0x03c5, 0x0020, CanonicalizeRangeHi },
+ { 0x03c6, 0x03c6, 0x000d, CanonicalizeSet },
+ { 0x03c7, 0x03cb, 0x0020, CanonicalizeRangeHi },
+ { 0x03cc, 0x03cc, 0x0040, CanonicalizeRangeHi },
+ { 0x03cd, 0x03ce, 0x003f, CanonicalizeRangeHi },
+ { 0x03cf, 0x03cf, 0x0008, CanonicalizeRangeLo },
+ { 0x03d0, 0x03d0, 0x0004, CanonicalizeSet },
+ { 0x03d1, 0x03d1, 0x0006, CanonicalizeSet },
+ { 0x03d2, 0x03d4, 0x0000, CanonicalizeUnique },
+ { 0x03d5, 0x03d5, 0x000d, CanonicalizeSet },
+ { 0x03d6, 0x03d6, 0x000a, CanonicalizeSet },
+ { 0x03d7, 0x03d7, 0x0008, CanonicalizeRangeHi },
+ { 0x03d8, 0x03ef, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x03f0, 0x03f0, 0x0008, CanonicalizeSet },
+ { 0x03f1, 0x03f1, 0x000b, CanonicalizeSet },
+ { 0x03f2, 0x03f2, 0x0007, CanonicalizeRangeLo },
+ { 0x03f3, 0x03f3, 0x0074, CanonicalizeRangeHi },
+ { 0x03f4, 0x03f4, 0x0000, CanonicalizeUnique },
+ { 0x03f5, 0x03f5, 0x0005, CanonicalizeSet },
+ { 0x03f6, 0x03f6, 0x0000, CanonicalizeUnique },
+ { 0x03f7, 0x03f8, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x03f9, 0x03f9, 0x0007, CanonicalizeRangeHi },
+ { 0x03fa, 0x03fb, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x03fc, 0x03fc, 0x0000, CanonicalizeUnique },
+ { 0x03fd, 0x03ff, 0x0082, CanonicalizeRangeHi },
+ { 0x0400, 0x040f, 0x0050, CanonicalizeRangeLo },
+ { 0x0410, 0x042f, 0x0020, CanonicalizeRangeLo },
+ { 0x0430, 0x044f, 0x0020, CanonicalizeRangeHi },
+ { 0x0450, 0x045f, 0x0050, CanonicalizeRangeHi },
+ { 0x0460, 0x0481, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0482, 0x0489, 0x0000, CanonicalizeUnique },
+ { 0x048a, 0x04bf, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x04c0, 0x04c0, 0x000f, CanonicalizeRangeLo },
+ { 0x04c1, 0x04ce, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x04cf, 0x04cf, 0x000f, CanonicalizeRangeHi },
+ { 0x04d0, 0x052f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0530, 0x0530, 0x0000, CanonicalizeUnique },
+ { 0x0531, 0x0556, 0x0030, CanonicalizeRangeLo },
+ { 0x0557, 0x0560, 0x0000, CanonicalizeUnique },
+ { 0x0561, 0x0586, 0x0030, CanonicalizeRangeHi },
+ { 0x0587, 0x109f, 0x0000, CanonicalizeUnique },
+ { 0x10a0, 0x10c5, 0x1c60, CanonicalizeRangeLo },
+ { 0x10c6, 0x10c6, 0x0000, CanonicalizeUnique },
+ { 0x10c7, 0x10c7, 0x1c60, CanonicalizeRangeLo },
+ { 0x10c8, 0x10cc, 0x0000, CanonicalizeUnique },
+ { 0x10cd, 0x10cd, 0x1c60, CanonicalizeRangeLo },
+ { 0x10ce, 0x1d78, 0x0000, CanonicalizeUnique },
+ { 0x1d79, 0x1d79, 0x8a04, CanonicalizeRangeLo },
+ { 0x1d7a, 0x1d7c, 0x0000, CanonicalizeUnique },
+ { 0x1d7d, 0x1d7d, 0x0ee6, CanonicalizeRangeLo },
+ { 0x1d7e, 0x1dff, 0x0000, CanonicalizeUnique },
+ { 0x1e00, 0x1e5f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1e60, 0x1e61, 0x000e, CanonicalizeSet },
+ { 0x1e62, 0x1e95, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1e96, 0x1e9a, 0x0000, CanonicalizeUnique },
+ { 0x1e9b, 0x1e9b, 0x000e, CanonicalizeSet },
+ { 0x1e9c, 0x1e9f, 0x0000, CanonicalizeUnique },
+ { 0x1ea0, 0x1eff, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1f00, 0x1f07, 0x0008, CanonicalizeRangeLo },
+ { 0x1f08, 0x1f0f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f10, 0x1f15, 0x0008, CanonicalizeRangeLo },
+ { 0x1f16, 0x1f17, 0x0000, CanonicalizeUnique },
+ { 0x1f18, 0x1f1d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f1e, 0x1f1f, 0x0000, CanonicalizeUnique },
+ { 0x1f20, 0x1f27, 0x0008, CanonicalizeRangeLo },
+ { 0x1f28, 0x1f2f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f30, 0x1f37, 0x0008, CanonicalizeRangeLo },
+ { 0x1f38, 0x1f3f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f40, 0x1f45, 0x0008, CanonicalizeRangeLo },
+ { 0x1f46, 0x1f47, 0x0000, CanonicalizeUnique },
+ { 0x1f48, 0x1f4d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f4e, 0x1f50, 0x0000, CanonicalizeUnique },
+ { 0x1f51, 0x1f51, 0x0008, CanonicalizeRangeLo },
+ { 0x1f52, 0x1f52, 0x0000, CanonicalizeUnique },
+ { 0x1f53, 0x1f53, 0x0008, CanonicalizeRangeLo },
+ { 0x1f54, 0x1f54, 0x0000, CanonicalizeUnique },
+ { 0x1f55, 0x1f55, 0x0008, CanonicalizeRangeLo },
+ { 0x1f56, 0x1f56, 0x0000, CanonicalizeUnique },
+ { 0x1f57, 0x1f57, 0x0008, CanonicalizeRangeLo },
+ { 0x1f58, 0x1f58, 0x0000, CanonicalizeUnique },
+ { 0x1f59, 0x1f59, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5a, 0x1f5a, 0x0000, CanonicalizeUnique },
+ { 0x1f5b, 0x1f5b, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5c, 0x1f5c, 0x0000, CanonicalizeUnique },
+ { 0x1f5d, 0x1f5d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5e, 0x1f5e, 0x0000, CanonicalizeUnique },
+ { 0x1f5f, 0x1f5f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f60, 0x1f67, 0x0008, CanonicalizeRangeLo },
+ { 0x1f68, 0x1f6f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f70, 0x1f71, 0x004a, CanonicalizeRangeLo },
+ { 0x1f72, 0x1f75, 0x0056, CanonicalizeRangeLo },
+ { 0x1f76, 0x1f77, 0x0064, CanonicalizeRangeLo },
+ { 0x1f78, 0x1f79, 0x0080, CanonicalizeRangeLo },
+ { 0x1f7a, 0x1f7b, 0x0070, CanonicalizeRangeLo },
+ { 0x1f7c, 0x1f7d, 0x007e, CanonicalizeRangeLo },
+ { 0x1f7e, 0x1faf, 0x0000, CanonicalizeUnique },
+ { 0x1fb0, 0x1fb1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fb2, 0x1fb7, 0x0000, CanonicalizeUnique },
+ { 0x1fb8, 0x1fb9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fba, 0x1fbb, 0x004a, CanonicalizeRangeHi },
+ { 0x1fbc, 0x1fbd, 0x0000, CanonicalizeUnique },
+ { 0x1fbe, 0x1fbe, 0x0007, CanonicalizeSet },
+ { 0x1fbf, 0x1fc7, 0x0000, CanonicalizeUnique },
+ { 0x1fc8, 0x1fcb, 0x0056, CanonicalizeRangeHi },
+ { 0x1fcc, 0x1fcf, 0x0000, CanonicalizeUnique },
+ { 0x1fd0, 0x1fd1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fd2, 0x1fd7, 0x0000, CanonicalizeUnique },
+ { 0x1fd8, 0x1fd9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fda, 0x1fdb, 0x0064, CanonicalizeRangeHi },
+ { 0x1fdc, 0x1fdf, 0x0000, CanonicalizeUnique },
+ { 0x1fe0, 0x1fe1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fe2, 0x1fe4, 0x0000, CanonicalizeUnique },
+ { 0x1fe5, 0x1fe5, 0x0007, CanonicalizeRangeLo },
+ { 0x1fe6, 0x1fe7, 0x0000, CanonicalizeUnique },
+ { 0x1fe8, 0x1fe9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fea, 0x1feb, 0x0070, CanonicalizeRangeHi },
+ { 0x1fec, 0x1fec, 0x0007, CanonicalizeRangeHi },
+ { 0x1fed, 0x1ff7, 0x0000, CanonicalizeUnique },
+ { 0x1ff8, 0x1ff9, 0x0080, CanonicalizeRangeHi },
+ { 0x1ffa, 0x1ffb, 0x007e, CanonicalizeRangeHi },
+ { 0x1ffc, 0x2131, 0x0000, CanonicalizeUnique },
+ { 0x2132, 0x2132, 0x001c, CanonicalizeRangeLo },
+ { 0x2133, 0x214d, 0x0000, CanonicalizeUnique },
+ { 0x214e, 0x214e, 0x001c, CanonicalizeRangeHi },
+ { 0x214f, 0x215f, 0x0000, CanonicalizeUnique },
+ { 0x2160, 0x216f, 0x0010, CanonicalizeRangeLo },
+ { 0x2170, 0x217f, 0x0010, CanonicalizeRangeHi },
+ { 0x2180, 0x2182, 0x0000, CanonicalizeUnique },
+ { 0x2183, 0x2184, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2185, 0x24b5, 0x0000, CanonicalizeUnique },
+ { 0x24b6, 0x24cf, 0x001a, CanonicalizeRangeLo },
+ { 0x24d0, 0x24e9, 0x001a, CanonicalizeRangeHi },
+ { 0x24ea, 0x2bff, 0x0000, CanonicalizeUnique },
+ { 0x2c00, 0x2c2e, 0x0030, CanonicalizeRangeLo },
+ { 0x2c2f, 0x2c2f, 0x0000, CanonicalizeUnique },
+ { 0x2c30, 0x2c5e, 0x0030, CanonicalizeRangeHi },
+ { 0x2c5f, 0x2c5f, 0x0000, CanonicalizeUnique },
+ { 0x2c60, 0x2c61, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2c62, 0x2c62, 0x29f7, CanonicalizeRangeHi },
+ { 0x2c63, 0x2c63, 0x0ee6, CanonicalizeRangeHi },
+ { 0x2c64, 0x2c64, 0x29e7, CanonicalizeRangeHi },
+ { 0x2c65, 0x2c65, 0x2a2b, CanonicalizeRangeHi },
+ { 0x2c66, 0x2c66, 0x2a28, CanonicalizeRangeHi },
+ { 0x2c67, 0x2c6c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2c6d, 0x2c6d, 0x2a1c, CanonicalizeRangeHi },
+ { 0x2c6e, 0x2c6e, 0x29fd, CanonicalizeRangeHi },
+ { 0x2c6f, 0x2c6f, 0x2a1f, CanonicalizeRangeHi },
+ { 0x2c70, 0x2c70, 0x2a1e, CanonicalizeRangeHi },
+ { 0x2c71, 0x2c71, 0x0000, CanonicalizeUnique },
+ { 0x2c72, 0x2c73, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2c74, 0x2c74, 0x0000, CanonicalizeUnique },
+ { 0x2c75, 0x2c76, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2c77, 0x2c7d, 0x0000, CanonicalizeUnique },
+ { 0x2c7e, 0x2c7f, 0x2a3f, CanonicalizeRangeHi },
+ { 0x2c80, 0x2ce3, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2ce4, 0x2cea, 0x0000, CanonicalizeUnique },
+ { 0x2ceb, 0x2cee, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2cef, 0x2cf1, 0x0000, CanonicalizeUnique },
+ { 0x2cf2, 0x2cf3, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2cf4, 0x2cff, 0x0000, CanonicalizeUnique },
+ { 0x2d00, 0x2d25, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d26, 0x2d26, 0x0000, CanonicalizeUnique },
+ { 0x2d27, 0x2d27, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d28, 0x2d2c, 0x0000, CanonicalizeUnique },
+ { 0x2d2d, 0x2d2d, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d2e, 0xa63f, 0x0000, CanonicalizeUnique },
+ { 0xa640, 0xa66d, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa66e, 0xa67f, 0x0000, CanonicalizeUnique },
+ { 0xa680, 0xa69b, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa69c, 0xa721, 0x0000, CanonicalizeUnique },
+ { 0xa722, 0xa72f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa730, 0xa731, 0x0000, CanonicalizeUnique },
+ { 0xa732, 0xa76f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa770, 0xa778, 0x0000, CanonicalizeUnique },
+ { 0xa779, 0xa77c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0xa77d, 0xa77d, 0x8a04, CanonicalizeRangeHi },
+ { 0xa77e, 0xa787, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa788, 0xa78a, 0x0000, CanonicalizeUnique },
+ { 0xa78b, 0xa78c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0xa78d, 0xa78d, 0xa528, CanonicalizeRangeHi },
+ { 0xa78e, 0xa78f, 0x0000, CanonicalizeUnique },
+ { 0xa790, 0xa793, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa794, 0xa795, 0x0000, CanonicalizeUnique },
+ { 0xa796, 0xa7a9, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa7aa, 0xa7aa, 0xa544, CanonicalizeRangeHi },
+ { 0xa7ab, 0xa7ab, 0xa54f, CanonicalizeRangeHi },
+ { 0xa7ac, 0xa7ac, 0xa54b, CanonicalizeRangeHi },
+ { 0xa7ad, 0xa7ad, 0xa541, CanonicalizeRangeHi },
+ { 0xa7ae, 0xa7af, 0x0000, CanonicalizeUnique },
+ { 0xa7b0, 0xa7b0, 0xa512, CanonicalizeRangeHi },
+ { 0xa7b1, 0xa7b1, 0xa52a, CanonicalizeRangeHi },
+ { 0xa7b2, 0xff20, 0x0000, CanonicalizeUnique },
+ { 0xff21, 0xff3a, 0x0020, CanonicalizeRangeLo },
+ { 0xff3b, 0xff40, 0x0000, CanonicalizeUnique },
+ { 0xff41, 0xff5a, 0x0020, CanonicalizeRangeHi },
+ { 0xff5b, 0xffff, 0x0000, CanonicalizeUnique },
};
} } // JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.js b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.js
index 00361dd46e..dc578cfece 100644
--- a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.js
+++ b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,7 +23,61 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// See ES 5.1, 15.10.2.8
+function printHeader()
+{
+ var copyright = (
+ "/*" + "\n" +
+ " * Copyright (C) 2012-2013, 2015-2016 Apple Inc. All rights reserved." + "\n" +
+ " *" + "\n" +
+ " * Redistribution and use in source and binary forms, with or without" + "\n" +
+ " * modification, are permitted provided that the following conditions" + "\n" +
+ " * are met:" + "\n" +
+ " * 1. Redistributions of source code must retain the above copyright" + "\n" +
+ " * notice, this list of conditions and the following disclaimer." + "\n" +
+ " * 2. Redistributions in binary form must reproduce the above copyright" + "\n" +
+ " * notice, this list of conditions and the following disclaimer in the" + "\n" +
+ " * documentation and/or other materials provided with the distribution." + "\n" +
+ " *" + "\n" +
+ " * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY" + "\n" +
+ " * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE" + "\n" +
+ " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR" + "\n" +
+ " * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR" + "\n" +
+ " * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL," + "\n" +
+ " * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO," + "\n" +
+ " * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR" + "\n" +
+ " * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY" + "\n" +
+ " * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT" + "\n" +
+ " * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE" + "\n" +
+ " * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " + "\n" +
+ " */");
+
+ print(copyright);
+ print();
+ print("// DO NOT EDIT! - this file autogenerated by YarrCanonicalize.js");
+ print();
+ print('#include "config.h"');
+ print('#include "YarrCanonicalize.h"');
+ print();
+ print("namespace JSC { namespace Yarr {");
+ print();
+}
+
+function printFooter()
+{
+ print("} } // JSC::Yarr");
+ print();
+}
+
+// Helper function to convert a number to a fixed width hex representation of a UChar32.
+function hex(x)
+{
+ var s = Number(x).toString(16);
+ while (s.length < 4)
+ s = 0 + s;
+ return "0x" + s;
+}
+
+// See ES 6.0, 21.2.2.8.2 Steps 3
function canonicalize(ch)
{
var u = String.fromCharCode(ch).toUpperCase();
@@ -36,184 +90,104 @@ function canonicalize(ch)
}
var MAX_UCS2 = 0xFFFF;
-var MAX_LATIN = 0xFF;
-
-var groupedCanonically = [];
-// Pass 1: populate groupedCanonically - this is mapping from canonicalized
-// values back to the set of character code that canonicalize to them.
-for (var i = 0; i <= MAX_UCS2; ++i) {
- var ch = canonicalize(i);
- if (!groupedCanonically[ch])
- groupedCanonically[ch] = [];
- groupedCanonically[ch].push(i);
-}
-var typeInfo = [];
-var latinTypeInfo = [];
-var characterSetInfo = [];
-// Pass 2: populate typeInfo & characterSetInfo. For every character calculate
-// a typeInfo value, described by the types above, and a value payload.
-for (cu in groupedCanonically) {
- // The set of characters that canonicalize to cu
- var characters = groupedCanonically[cu];
-
- // If there is only one, it is unique.
- if (characters.length == 1) {
- typeInfo[characters[0]] = "CanonicalizeUnique:0";
- latinTypeInfo[characters[0]] = characters[0] <= MAX_LATIN ? "CanonicalizeLatinSelf:0" : "CanonicalizeLatinInvalid:0";
- continue;
+function createUCS2CanonicalGroups()
+{
+ var groupedCanonically = [];
+ // Pass 1: populate groupedCanonically - this is mapping from canonicalized
+ // values back to the set of character code that canonicalize to them.
+ for (var i = 0; i <= MAX_UCS2; ++i) {
+ var ch = canonicalize(i);
+ if (!groupedCanonically[ch])
+ groupedCanonically[ch] = [];
+ groupedCanonically[ch].push(i);
}
- // Sort the array.
- characters.sort(function(x,y){return x-y;});
+ return groupedCanonically;
+}
- // If there are more than two characters, create an entry in characterSetInfo.
- if (characters.length > 2) {
- for (i in characters)
- typeInfo[characters[i]] = "CanonicalizeSet:" + characterSetInfo.length;
- characterSetInfo.push(characters);
+function createTables(prefix, maxValue, canonicalGroups)
+{
+ var prefixLower = prefix.toLowerCase();
+ var prefixUpper = prefix.toUpperCase();
+ var typeInfo = [];
+ var characterSetInfo = [];
+ // Pass 2: populate typeInfo & characterSetInfo. For every character calculate
+ // a typeInfo value, described by the types above, and a value payload.
+ for (cu in canonicalGroups) {
+ // The set of characters that canonicalize to cu
+ var characters = canonicalGroups[cu];
+
+ // If there is only one, it is unique.
+ if (characters.length == 1) {
+ typeInfo[characters[0]] = "CanonicalizeUnique:0";
+ continue;
+ }
- if (characters[1] <= MAX_LATIN)
- throw new Error("sets with more than one latin character not supported!");
- if (characters[0] <= MAX_LATIN) {
- for (i in characters)
- latinTypeInfo[characters[i]] = "CanonicalizeLatinOther:" + characters[0];
- latinTypeInfo[characters[0]] = "CanonicalizeLatinSelf:0";
- } else {
+ // Sort the array.
+ characters.sort(function(x,y){return x-y;});
+
+ // If there are more than two characters, create an entry in characterSetInfo.
+ if (characters.length > 2) {
for (i in characters)
- latinTypeInfo[characters[i]] = "CanonicalizeLatinInvalid:0";
+ typeInfo[characters[i]] = "CanonicalizeSet:" + characterSetInfo.length;
+ characterSetInfo.push(characters);
+
+ continue;
}
- continue;
+ // We have a pair, mark alternating ranges, otherwise track whether this is the low or high partner.
+ var lo = characters[0];
+ var hi = characters[1];
+ var delta = hi - lo;
+ if (delta == 1) {
+ var type = lo & 1 ? "CanonicalizeAlternatingUnaligned:0" : "CanonicalizeAlternatingAligned:0";
+ typeInfo[lo] = type;
+ typeInfo[hi] = type;
+ } else {
+ typeInfo[lo] = "CanonicalizeRangeLo:" + delta;
+ typeInfo[hi] = "CanonicalizeRangeHi:" + delta;
+ }
}
- // We have a pair, mark alternating ranges, otherwise track whether this is the low or high partner.
- var lo = characters[0];
- var hi = characters[1];
- var delta = hi - lo;
- if (delta == 1) {
- var type = lo & 1 ? "CanonicalizeAlternatingUnaligned:0" : "CanonicalizeAlternatingAligned:0";
- typeInfo[lo] = type;
- typeInfo[hi] = type;
- } else {
- typeInfo[lo] = "CanonicalizeRangeLo:" + delta;
- typeInfo[hi] = "CanonicalizeRangeHi:" + delta;
+ var rangeInfo = [];
+ // Pass 3: coallesce types into ranges.
+ for (var end = 0; end <= maxValue; ++end) {
+ var begin = end;
+ var type = typeInfo[end];
+ while (end < maxValue && typeInfo[end + 1] == type)
+ ++end;
+ rangeInfo.push({begin:begin, end:end, type:type});
}
- if (lo > MAX_LATIN) {
- latinTypeInfo[lo] = "CanonicalizeLatinInvalid:0";
- latinTypeInfo[hi] = "CanonicalizeLatinInvalid:0";
- } else if (hi > MAX_LATIN) {
- latinTypeInfo[lo] = "CanonicalizeLatinSelf:0";
- latinTypeInfo[hi] = "CanonicalizeLatinOther:" + lo;
- } else {
- if (delta != 0x20 || lo & 0x20)
- throw new Error("pairs of latin characters that don't mask with 0x20 not supported!");
- latinTypeInfo[lo] = "CanonicalizeLatinMask0x20:0";
- latinTypeInfo[hi] = "CanonicalizeLatinMask0x20:0";
+ for (i in characterSetInfo) {
+ var characters = ""
+ var set = characterSetInfo[i];
+ for (var j in set)
+ characters += hex(set[j]) + ", ";
+ print("const UChar32 " + prefixLower + "CharacterSet" + i + "[] = { " + characters + "0 };");
}
+ print();
+ print("static const size_t " + prefixUpper + "_CANONICALIZATION_SETS = " + characterSetInfo.length + ";");
+ print("const UChar32* const " + prefixLower + "CharacterSetInfo[" + prefixUpper + "_CANONICALIZATION_SETS] = {");
+ for (i in characterSetInfo)
+ print(" " + prefixLower + "CharacterSet" + i + ",");
+ print("};");
+ print();
+ print("const size_t " + prefixUpper + "_CANONICALIZATION_RANGES = " + rangeInfo.length + ";");
+ print("const CanonicalizationRange " + prefixLower + "RangeInfo[" + prefixUpper + "_CANONICALIZATION_RANGES] = {");
+ for (i in rangeInfo) {
+ var info = rangeInfo[i];
+ var typeAndValue = info.type.split(':');
+ print(" { " + hex(info.begin) + ", " + hex(info.end) + ", " + hex(typeAndValue[1]) + ", " + typeAndValue[0] + " },");
+ }
+ print("};");
+ print();
}
-var rangeInfo = [];
-// Pass 3: coallesce types into ranges.
-for (var end = 0; end <= MAX_UCS2; ++end) {
- var begin = end;
- var type = typeInfo[end];
- while (end < MAX_UCS2 && typeInfo[end + 1] == type)
- ++end;
- rangeInfo.push({begin:begin, end:end, type:type});
-}
+printHeader();
-var latinRangeInfo = [];
-// Pass 4: coallesce latin-1 types into ranges.
-for (var end = 0; end <= MAX_UCS2; ++end) {
- var begin = end;
- var type = latinTypeInfo[end];
- while (end < MAX_UCS2 && latinTypeInfo[end + 1] == type)
- ++end;
- latinRangeInfo.push({begin:begin, end:end, type:type});
-}
+createTables("UCS2", MAX_UCS2, createUCS2CanonicalGroups());
-
-// Helper function to convert a number to a fixed width hex representation of a C uint16_t.
-function hex(x)
-{
- var s = Number(x).toString(16);
- while (s.length < 4)
- s = 0 + s;
- return "0x" + s + "u";
-}
-
-var copyright = (
- "/*" + "\n" +
- " * Copyright (C) 2012 Apple Inc. All rights reserved." + "\n" +
- " *" + "\n" +
- " * Redistribution and use in source and binary forms, with or without" + "\n" +
- " * modification, are permitted provided that the following conditions" + "\n" +
- " * are met:" + "\n" +
- " * 1. Redistributions of source code must retain the above copyright" + "\n" +
- " * notice, this list of conditions and the following disclaimer." + "\n" +
- " * 2. Redistributions in binary form must reproduce the above copyright" + "\n" +
- " * notice, this list of conditions and the following disclaimer in the" + "\n" +
- " * documentation and/or other materials provided with the distribution." + "\n" +
- " *" + "\n" +
- " * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY" + "\n" +
- " * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE" + "\n" +
- " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR" + "\n" +
- " * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR" + "\n" +
- " * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL," + "\n" +
- " * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO," + "\n" +
- " * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR" + "\n" +
- " * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY" + "\n" +
- " * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT" + "\n" +
- " * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE" + "\n" +
- " * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " + "\n" +
- " */");
-
-print(copyright);
-print();
-print("// DO NOT EDIT! - this file autogenerated by YarrCanonicalizeUCS2.js");
-print();
-print('#include "config.h"');
-print('#include "YarrCanonicalizeUCS2.h"');
-print();
-print("namespace JSC { namespace Yarr {");
-print();
-print("#include <stdint.h>");
-print();
-
-for (i in characterSetInfo) {
- var characters = ""
- var set = characterSetInfo[i];
- for (var j in set)
- characters += hex(set[j]) + ", ";
- print("uint16_t ucs2CharacterSet" + i + "[] = { " + characters + "0 };");
-}
-print();
-print("static const size_t UCS2_CANONICALIZATION_SETS = " + characterSetInfo.length + ";");
-print("uint16_t* characterSetInfo[UCS2_CANONICALIZATION_SETS] = {");
-for (i in characterSetInfo)
-print(" ucs2CharacterSet" + i + ",");
-print("};");
-print();
-print("const size_t UCS2_CANONICALIZATION_RANGES = " + rangeInfo.length + ";");
-print("UCS2CanonicalizationRange rangeInfo[UCS2_CANONICALIZATION_RANGES] = {");
-for (i in rangeInfo) {
- var info = rangeInfo[i];
- var typeAndValue = info.type.split(':');
- print(" { " + hex(info.begin) + ", " + hex(info.end) + ", " + hex(typeAndValue[1]) + ", " + typeAndValue[0] + " },");
-}
-print("};");
-print();
-print("const size_t LATIN_CANONICALIZATION_RANGES = " + latinRangeInfo.length + ";");
-print("LatinCanonicalizationRange latinRangeInfo[LATIN_CANONICALIZATION_RANGES] = {");
-for (i in latinRangeInfo) {
- var info = latinRangeInfo[i];
- var typeAndValue = info.type.split(':');
- print(" { " + hex(info.begin) + ", " + hex(info.end) + ", " + hex(typeAndValue[1]) + ", " + typeAndValue[0] + " },");
-}
-print("};");
-print();
-print("} } // JSC::Yarr");
-print();
+printFooter();
diff --git a/src/3rdparty/masm/yarr/YarrCanonicalizeUnicode.cpp b/src/3rdparty/masm/yarr/YarrCanonicalizeUnicode.cpp
new file mode 100644
index 0000000000..37bfc5e060
--- /dev/null
+++ b/src/3rdparty/masm/yarr/YarrCanonicalizeUnicode.cpp
@@ -0,0 +1,591 @@
+/*
+* Copyright (C) 2016 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+// DO NO EDIT! - This file was generated by generateYarrCanonicalizeUnicode
+
+#include "config.h"
+#include "YarrCanonicalize.h"
+
+namespace JSC { namespace Yarr {
+
+const UChar32 unicodeCharacterSet0[] = { 0x004b, 0x006b, 0x212a, 0 };
+const UChar32 unicodeCharacterSet1[] = { 0x0053, 0x0073, 0x017f, 0 };
+const UChar32 unicodeCharacterSet2[] = { 0x00c5, 0x00e5, 0x212b, 0 };
+const UChar32 unicodeCharacterSet3[] = { 0x01c4, 0x01c5, 0x01c6, 0 };
+const UChar32 unicodeCharacterSet4[] = { 0x01c7, 0x01c8, 0x01c9, 0 };
+const UChar32 unicodeCharacterSet5[] = { 0x01ca, 0x01cb, 0x01cc, 0 };
+const UChar32 unicodeCharacterSet6[] = { 0x01f1, 0x01f2, 0x01f3, 0 };
+const UChar32 unicodeCharacterSet7[] = { 0x0392, 0x03b2, 0x03d0, 0 };
+const UChar32 unicodeCharacterSet8[] = { 0x0395, 0x03b5, 0x03f5, 0 };
+const UChar32 unicodeCharacterSet9[] = { 0x0398, 0x03b8, 0x03d1, 0x03f4, 0 };
+const UChar32 unicodeCharacterSet10[] = { 0x0345, 0x0399, 0x03b9, 0x1fbe, 0 };
+const UChar32 unicodeCharacterSet11[] = { 0x039a, 0x03ba, 0x03f0, 0 };
+const UChar32 unicodeCharacterSet12[] = { 0x00b5, 0x039c, 0x03bc, 0 };
+const UChar32 unicodeCharacterSet13[] = { 0x03a0, 0x03c0, 0x03d6, 0 };
+const UChar32 unicodeCharacterSet14[] = { 0x03a1, 0x03c1, 0x03f1, 0 };
+const UChar32 unicodeCharacterSet15[] = { 0x03a3, 0x03c2, 0x03c3, 0 };
+const UChar32 unicodeCharacterSet16[] = { 0x03a6, 0x03c6, 0x03d5, 0 };
+const UChar32 unicodeCharacterSet17[] = { 0x03a9, 0x03c9, 0x2126, 0 };
+const UChar32 unicodeCharacterSet18[] = { 0x0412, 0x0432, 0x1c80, 0 };
+const UChar32 unicodeCharacterSet19[] = { 0x0414, 0x0434, 0x1c81, 0 };
+const UChar32 unicodeCharacterSet20[] = { 0x041e, 0x043e, 0x1c82, 0 };
+const UChar32 unicodeCharacterSet21[] = { 0x0421, 0x0441, 0x1c83, 0 };
+const UChar32 unicodeCharacterSet22[] = { 0x0422, 0x0442, 0x1c84, 0x1c85, 0 };
+const UChar32 unicodeCharacterSet23[] = { 0x042a, 0x044a, 0x1c86, 0 };
+const UChar32 unicodeCharacterSet24[] = { 0x0462, 0x0463, 0x1c87, 0 };
+const UChar32 unicodeCharacterSet25[] = { 0x1e60, 0x1e61, 0x1e9b, 0 };
+const UChar32 unicodeCharacterSet26[] = { 0x1c88, 0xa64a, 0xa64b, 0 };
+
+static const size_t UNICODE_CANONICALIZATION_SETS = 27;
+const UChar32* const unicodeCharacterSetInfo[UNICODE_CANONICALIZATION_SETS] = {
+ unicodeCharacterSet0,
+ unicodeCharacterSet1,
+ unicodeCharacterSet2,
+ unicodeCharacterSet3,
+ unicodeCharacterSet4,
+ unicodeCharacterSet5,
+ unicodeCharacterSet6,
+ unicodeCharacterSet7,
+ unicodeCharacterSet8,
+ unicodeCharacterSet9,
+ unicodeCharacterSet10,
+ unicodeCharacterSet11,
+ unicodeCharacterSet12,
+ unicodeCharacterSet13,
+ unicodeCharacterSet14,
+ unicodeCharacterSet15,
+ unicodeCharacterSet16,
+ unicodeCharacterSet17,
+ unicodeCharacterSet18,
+ unicodeCharacterSet19,
+ unicodeCharacterSet20,
+ unicodeCharacterSet21,
+ unicodeCharacterSet22,
+ unicodeCharacterSet23,
+ unicodeCharacterSet24,
+ unicodeCharacterSet25,
+ unicodeCharacterSet26,
+};
+
+const size_t UNICODE_CANONICALIZATION_RANGES = 495;
+const CanonicalizationRange unicodeRangeInfo[UNICODE_CANONICALIZATION_RANGES] = {
+ { 0x0000, 0x0040, 0x0000, CanonicalizeUnique },
+ { 0x0041, 0x004a, 0x0020, CanonicalizeRangeLo },
+ { 0x004b, 0x004b, 0x0000, CanonicalizeSet },
+ { 0x004c, 0x0052, 0x0020, CanonicalizeRangeLo },
+ { 0x0053, 0x0053, 0x0001, CanonicalizeSet },
+ { 0x0054, 0x005a, 0x0020, CanonicalizeRangeLo },
+ { 0x005b, 0x0060, 0x0000, CanonicalizeUnique },
+ { 0x0061, 0x006a, 0x0020, CanonicalizeRangeHi },
+ { 0x006b, 0x006b, 0x0000, CanonicalizeSet },
+ { 0x006c, 0x0072, 0x0020, CanonicalizeRangeHi },
+ { 0x0073, 0x0073, 0x0001, CanonicalizeSet },
+ { 0x0074, 0x007a, 0x0020, CanonicalizeRangeHi },
+ { 0x007b, 0x00b4, 0x0000, CanonicalizeUnique },
+ { 0x00b5, 0x00b5, 0x000c, CanonicalizeSet },
+ { 0x00b6, 0x00bf, 0x0000, CanonicalizeUnique },
+ { 0x00c0, 0x00c4, 0x0020, CanonicalizeRangeLo },
+ { 0x00c5, 0x00c5, 0x0002, CanonicalizeSet },
+ { 0x00c6, 0x00d6, 0x0020, CanonicalizeRangeLo },
+ { 0x00d7, 0x00d7, 0x0000, CanonicalizeUnique },
+ { 0x00d8, 0x00de, 0x0020, CanonicalizeRangeLo },
+ { 0x00df, 0x00df, 0x1dbf, CanonicalizeRangeLo },
+ { 0x00e0, 0x00e4, 0x0020, CanonicalizeRangeHi },
+ { 0x00e5, 0x00e5, 0x0002, CanonicalizeSet },
+ { 0x00e6, 0x00f6, 0x0020, CanonicalizeRangeHi },
+ { 0x00f7, 0x00f7, 0x0000, CanonicalizeUnique },
+ { 0x00f8, 0x00fe, 0x0020, CanonicalizeRangeHi },
+ { 0x00ff, 0x00ff, 0x0079, CanonicalizeRangeLo },
+ { 0x0100, 0x012f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0130, 0x0131, 0x0000, CanonicalizeUnique },
+ { 0x0132, 0x0137, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0138, 0x0138, 0x0000, CanonicalizeUnique },
+ { 0x0139, 0x0148, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0149, 0x0149, 0x0000, CanonicalizeUnique },
+ { 0x014a, 0x0177, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0178, 0x0178, 0x0079, CanonicalizeRangeHi },
+ { 0x0179, 0x017e, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x017f, 0x017f, 0x0001, CanonicalizeSet },
+ { 0x0180, 0x0180, 0x00c3, CanonicalizeRangeLo },
+ { 0x0181, 0x0181, 0x00d2, CanonicalizeRangeLo },
+ { 0x0182, 0x0185, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0186, 0x0186, 0x00ce, CanonicalizeRangeLo },
+ { 0x0187, 0x0188, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0189, 0x018a, 0x00cd, CanonicalizeRangeLo },
+ { 0x018b, 0x018c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x018d, 0x018d, 0x0000, CanonicalizeUnique },
+ { 0x018e, 0x018e, 0x004f, CanonicalizeRangeLo },
+ { 0x018f, 0x018f, 0x00ca, CanonicalizeRangeLo },
+ { 0x0190, 0x0190, 0x00cb, CanonicalizeRangeLo },
+ { 0x0191, 0x0192, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0193, 0x0193, 0x00cd, CanonicalizeRangeLo },
+ { 0x0194, 0x0194, 0x00cf, CanonicalizeRangeLo },
+ { 0x0195, 0x0195, 0x0061, CanonicalizeRangeLo },
+ { 0x0196, 0x0196, 0x00d3, CanonicalizeRangeLo },
+ { 0x0197, 0x0197, 0x00d1, CanonicalizeRangeLo },
+ { 0x0198, 0x0199, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x019a, 0x019a, 0x00a3, CanonicalizeRangeLo },
+ { 0x019b, 0x019b, 0x0000, CanonicalizeUnique },
+ { 0x019c, 0x019c, 0x00d3, CanonicalizeRangeLo },
+ { 0x019d, 0x019d, 0x00d5, CanonicalizeRangeLo },
+ { 0x019e, 0x019e, 0x0082, CanonicalizeRangeLo },
+ { 0x019f, 0x019f, 0x00d6, CanonicalizeRangeLo },
+ { 0x01a0, 0x01a5, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01a6, 0x01a6, 0x00da, CanonicalizeRangeLo },
+ { 0x01a7, 0x01a8, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01a9, 0x01a9, 0x00da, CanonicalizeRangeLo },
+ { 0x01aa, 0x01ab, 0x0000, CanonicalizeUnique },
+ { 0x01ac, 0x01ad, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01ae, 0x01ae, 0x00da, CanonicalizeRangeLo },
+ { 0x01af, 0x01b0, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01b1, 0x01b2, 0x00d9, CanonicalizeRangeLo },
+ { 0x01b3, 0x01b6, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01b7, 0x01b7, 0x00db, CanonicalizeRangeLo },
+ { 0x01b8, 0x01b9, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01ba, 0x01bb, 0x0000, CanonicalizeUnique },
+ { 0x01bc, 0x01bd, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01be, 0x01be, 0x0000, CanonicalizeUnique },
+ { 0x01bf, 0x01bf, 0x0038, CanonicalizeRangeLo },
+ { 0x01c0, 0x01c3, 0x0000, CanonicalizeUnique },
+ { 0x01c4, 0x01c6, 0x0003, CanonicalizeSet },
+ { 0x01c7, 0x01c9, 0x0004, CanonicalizeSet },
+ { 0x01ca, 0x01cc, 0x0005, CanonicalizeSet },
+ { 0x01cd, 0x01dc, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x01dd, 0x01dd, 0x004f, CanonicalizeRangeHi },
+ { 0x01de, 0x01ef, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01f0, 0x01f0, 0x0000, CanonicalizeUnique },
+ { 0x01f1, 0x01f3, 0x0006, CanonicalizeSet },
+ { 0x01f4, 0x01f5, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x01f6, 0x01f6, 0x0061, CanonicalizeRangeHi },
+ { 0x01f7, 0x01f7, 0x0038, CanonicalizeRangeHi },
+ { 0x01f8, 0x021f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0220, 0x0220, 0x0082, CanonicalizeRangeHi },
+ { 0x0221, 0x0221, 0x0000, CanonicalizeUnique },
+ { 0x0222, 0x0233, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0234, 0x0239, 0x0000, CanonicalizeUnique },
+ { 0x023a, 0x023a, 0x2a2b, CanonicalizeRangeLo },
+ { 0x023b, 0x023c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x023d, 0x023d, 0x00a3, CanonicalizeRangeHi },
+ { 0x023e, 0x023e, 0x2a28, CanonicalizeRangeLo },
+ { 0x023f, 0x0240, 0x2a3f, CanonicalizeRangeLo },
+ { 0x0241, 0x0242, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x0243, 0x0243, 0x00c3, CanonicalizeRangeHi },
+ { 0x0244, 0x0244, 0x0045, CanonicalizeRangeLo },
+ { 0x0245, 0x0245, 0x0047, CanonicalizeRangeLo },
+ { 0x0246, 0x024f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0250, 0x0250, 0x2a1f, CanonicalizeRangeLo },
+ { 0x0251, 0x0251, 0x2a1c, CanonicalizeRangeLo },
+ { 0x0252, 0x0252, 0x2a1e, CanonicalizeRangeLo },
+ { 0x0253, 0x0253, 0x00d2, CanonicalizeRangeHi },
+ { 0x0254, 0x0254, 0x00ce, CanonicalizeRangeHi },
+ { 0x0255, 0x0255, 0x0000, CanonicalizeUnique },
+ { 0x0256, 0x0257, 0x00cd, CanonicalizeRangeHi },
+ { 0x0258, 0x0258, 0x0000, CanonicalizeUnique },
+ { 0x0259, 0x0259, 0x00ca, CanonicalizeRangeHi },
+ { 0x025a, 0x025a, 0x0000, CanonicalizeUnique },
+ { 0x025b, 0x025b, 0x00cb, CanonicalizeRangeHi },
+ { 0x025c, 0x025c, 0xa54f, CanonicalizeRangeLo },
+ { 0x025d, 0x025f, 0x0000, CanonicalizeUnique },
+ { 0x0260, 0x0260, 0x00cd, CanonicalizeRangeHi },
+ { 0x0261, 0x0261, 0xa54b, CanonicalizeRangeLo },
+ { 0x0262, 0x0262, 0x0000, CanonicalizeUnique },
+ { 0x0263, 0x0263, 0x00cf, CanonicalizeRangeHi },
+ { 0x0264, 0x0264, 0x0000, CanonicalizeUnique },
+ { 0x0265, 0x0265, 0xa528, CanonicalizeRangeLo },
+ { 0x0266, 0x0266, 0xa544, CanonicalizeRangeLo },
+ { 0x0267, 0x0267, 0x0000, CanonicalizeUnique },
+ { 0x0268, 0x0268, 0x00d1, CanonicalizeRangeHi },
+ { 0x0269, 0x0269, 0x00d3, CanonicalizeRangeHi },
+ { 0x026a, 0x026a, 0xa544, CanonicalizeRangeLo },
+ { 0x026b, 0x026b, 0x29f7, CanonicalizeRangeLo },
+ { 0x026c, 0x026c, 0xa541, CanonicalizeRangeLo },
+ { 0x026d, 0x026e, 0x0000, CanonicalizeUnique },
+ { 0x026f, 0x026f, 0x00d3, CanonicalizeRangeHi },
+ { 0x0270, 0x0270, 0x0000, CanonicalizeUnique },
+ { 0x0271, 0x0271, 0x29fd, CanonicalizeRangeLo },
+ { 0x0272, 0x0272, 0x00d5, CanonicalizeRangeHi },
+ { 0x0273, 0x0274, 0x0000, CanonicalizeUnique },
+ { 0x0275, 0x0275, 0x00d6, CanonicalizeRangeHi },
+ { 0x0276, 0x027c, 0x0000, CanonicalizeUnique },
+ { 0x027d, 0x027d, 0x29e7, CanonicalizeRangeLo },
+ { 0x027e, 0x027f, 0x0000, CanonicalizeUnique },
+ { 0x0280, 0x0280, 0x00da, CanonicalizeRangeHi },
+ { 0x0281, 0x0282, 0x0000, CanonicalizeUnique },
+ { 0x0283, 0x0283, 0x00da, CanonicalizeRangeHi },
+ { 0x0284, 0x0286, 0x0000, CanonicalizeUnique },
+ { 0x0287, 0x0287, 0xa52a, CanonicalizeRangeLo },
+ { 0x0288, 0x0288, 0x00da, CanonicalizeRangeHi },
+ { 0x0289, 0x0289, 0x0045, CanonicalizeRangeHi },
+ { 0x028a, 0x028b, 0x00d9, CanonicalizeRangeHi },
+ { 0x028c, 0x028c, 0x0047, CanonicalizeRangeHi },
+ { 0x028d, 0x0291, 0x0000, CanonicalizeUnique },
+ { 0x0292, 0x0292, 0x00db, CanonicalizeRangeHi },
+ { 0x0293, 0x029c, 0x0000, CanonicalizeUnique },
+ { 0x029d, 0x029d, 0xa515, CanonicalizeRangeLo },
+ { 0x029e, 0x029e, 0xa512, CanonicalizeRangeLo },
+ { 0x029f, 0x0344, 0x0000, CanonicalizeUnique },
+ { 0x0345, 0x0345, 0x000a, CanonicalizeSet },
+ { 0x0346, 0x036f, 0x0000, CanonicalizeUnique },
+ { 0x0370, 0x0373, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0374, 0x0375, 0x0000, CanonicalizeUnique },
+ { 0x0376, 0x0377, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0378, 0x037a, 0x0000, CanonicalizeUnique },
+ { 0x037b, 0x037d, 0x0082, CanonicalizeRangeLo },
+ { 0x037e, 0x037e, 0x0000, CanonicalizeUnique },
+ { 0x037f, 0x037f, 0x0074, CanonicalizeRangeLo },
+ { 0x0380, 0x0385, 0x0000, CanonicalizeUnique },
+ { 0x0386, 0x0386, 0x0026, CanonicalizeRangeLo },
+ { 0x0387, 0x0387, 0x0000, CanonicalizeUnique },
+ { 0x0388, 0x038a, 0x0025, CanonicalizeRangeLo },
+ { 0x038b, 0x038b, 0x0000, CanonicalizeUnique },
+ { 0x038c, 0x038c, 0x0040, CanonicalizeRangeLo },
+ { 0x038d, 0x038d, 0x0000, CanonicalizeUnique },
+ { 0x038e, 0x038f, 0x003f, CanonicalizeRangeLo },
+ { 0x0390, 0x0390, 0x0000, CanonicalizeUnique },
+ { 0x0391, 0x0391, 0x0020, CanonicalizeRangeLo },
+ { 0x0392, 0x0392, 0x0007, CanonicalizeSet },
+ { 0x0393, 0x0394, 0x0020, CanonicalizeRangeLo },
+ { 0x0395, 0x0395, 0x0008, CanonicalizeSet },
+ { 0x0396, 0x0397, 0x0020, CanonicalizeRangeLo },
+ { 0x0398, 0x0398, 0x0009, CanonicalizeSet },
+ { 0x0399, 0x0399, 0x000a, CanonicalizeSet },
+ { 0x039a, 0x039a, 0x000b, CanonicalizeSet },
+ { 0x039b, 0x039b, 0x0020, CanonicalizeRangeLo },
+ { 0x039c, 0x039c, 0x000c, CanonicalizeSet },
+ { 0x039d, 0x039f, 0x0020, CanonicalizeRangeLo },
+ { 0x03a0, 0x03a0, 0x000d, CanonicalizeSet },
+ { 0x03a1, 0x03a1, 0x000e, CanonicalizeSet },
+ { 0x03a2, 0x03a2, 0x0000, CanonicalizeUnique },
+ { 0x03a3, 0x03a3, 0x000f, CanonicalizeSet },
+ { 0x03a4, 0x03a5, 0x0020, CanonicalizeRangeLo },
+ { 0x03a6, 0x03a6, 0x0010, CanonicalizeSet },
+ { 0x03a7, 0x03a8, 0x0020, CanonicalizeRangeLo },
+ { 0x03a9, 0x03a9, 0x0011, CanonicalizeSet },
+ { 0x03aa, 0x03ab, 0x0020, CanonicalizeRangeLo },
+ { 0x03ac, 0x03ac, 0x0026, CanonicalizeRangeHi },
+ { 0x03ad, 0x03af, 0x0025, CanonicalizeRangeHi },
+ { 0x03b0, 0x03b0, 0x0000, CanonicalizeUnique },
+ { 0x03b1, 0x03b1, 0x0020, CanonicalizeRangeHi },
+ { 0x03b2, 0x03b2, 0x0007, CanonicalizeSet },
+ { 0x03b3, 0x03b4, 0x0020, CanonicalizeRangeHi },
+ { 0x03b5, 0x03b5, 0x0008, CanonicalizeSet },
+ { 0x03b6, 0x03b7, 0x0020, CanonicalizeRangeHi },
+ { 0x03b8, 0x03b8, 0x0009, CanonicalizeSet },
+ { 0x03b9, 0x03b9, 0x000a, CanonicalizeSet },
+ { 0x03ba, 0x03ba, 0x000b, CanonicalizeSet },
+ { 0x03bb, 0x03bb, 0x0020, CanonicalizeRangeHi },
+ { 0x03bc, 0x03bc, 0x000c, CanonicalizeSet },
+ { 0x03bd, 0x03bf, 0x0020, CanonicalizeRangeHi },
+ { 0x03c0, 0x03c0, 0x000d, CanonicalizeSet },
+ { 0x03c1, 0x03c1, 0x000e, CanonicalizeSet },
+ { 0x03c2, 0x03c3, 0x000f, CanonicalizeSet },
+ { 0x03c4, 0x03c5, 0x0020, CanonicalizeRangeHi },
+ { 0x03c6, 0x03c6, 0x0010, CanonicalizeSet },
+ { 0x03c7, 0x03c8, 0x0020, CanonicalizeRangeHi },
+ { 0x03c9, 0x03c9, 0x0011, CanonicalizeSet },
+ { 0x03ca, 0x03cb, 0x0020, CanonicalizeRangeHi },
+ { 0x03cc, 0x03cc, 0x0040, CanonicalizeRangeHi },
+ { 0x03cd, 0x03ce, 0x003f, CanonicalizeRangeHi },
+ { 0x03cf, 0x03cf, 0x0008, CanonicalizeRangeLo },
+ { 0x03d0, 0x03d0, 0x0007, CanonicalizeSet },
+ { 0x03d1, 0x03d1, 0x0009, CanonicalizeSet },
+ { 0x03d2, 0x03d4, 0x0000, CanonicalizeUnique },
+ { 0x03d5, 0x03d5, 0x0010, CanonicalizeSet },
+ { 0x03d6, 0x03d6, 0x000d, CanonicalizeSet },
+ { 0x03d7, 0x03d7, 0x0008, CanonicalizeRangeHi },
+ { 0x03d8, 0x03ef, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x03f0, 0x03f0, 0x000b, CanonicalizeSet },
+ { 0x03f1, 0x03f1, 0x000e, CanonicalizeSet },
+ { 0x03f2, 0x03f2, 0x0007, CanonicalizeRangeLo },
+ { 0x03f3, 0x03f3, 0x0074, CanonicalizeRangeHi },
+ { 0x03f4, 0x03f4, 0x0009, CanonicalizeSet },
+ { 0x03f5, 0x03f5, 0x0008, CanonicalizeSet },
+ { 0x03f6, 0x03f6, 0x0000, CanonicalizeUnique },
+ { 0x03f7, 0x03f8, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x03f9, 0x03f9, 0x0007, CanonicalizeRangeHi },
+ { 0x03fa, 0x03fb, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x03fc, 0x03fc, 0x0000, CanonicalizeUnique },
+ { 0x03fd, 0x03ff, 0x0082, CanonicalizeRangeHi },
+ { 0x0400, 0x040f, 0x0050, CanonicalizeRangeLo },
+ { 0x0410, 0x0411, 0x0020, CanonicalizeRangeLo },
+ { 0x0412, 0x0412, 0x0012, CanonicalizeSet },
+ { 0x0413, 0x0413, 0x0020, CanonicalizeRangeLo },
+ { 0x0414, 0x0414, 0x0013, CanonicalizeSet },
+ { 0x0415, 0x041d, 0x0020, CanonicalizeRangeLo },
+ { 0x041e, 0x041e, 0x0014, CanonicalizeSet },
+ { 0x041f, 0x0420, 0x0020, CanonicalizeRangeLo },
+ { 0x0421, 0x0421, 0x0015, CanonicalizeSet },
+ { 0x0422, 0x0422, 0x0016, CanonicalizeSet },
+ { 0x0423, 0x0429, 0x0020, CanonicalizeRangeLo },
+ { 0x042a, 0x042a, 0x0017, CanonicalizeSet },
+ { 0x042b, 0x042f, 0x0020, CanonicalizeRangeLo },
+ { 0x0430, 0x0431, 0x0020, CanonicalizeRangeHi },
+ { 0x0432, 0x0432, 0x0012, CanonicalizeSet },
+ { 0x0433, 0x0433, 0x0020, CanonicalizeRangeHi },
+ { 0x0434, 0x0434, 0x0013, CanonicalizeSet },
+ { 0x0435, 0x043d, 0x0020, CanonicalizeRangeHi },
+ { 0x043e, 0x043e, 0x0014, CanonicalizeSet },
+ { 0x043f, 0x0440, 0x0020, CanonicalizeRangeHi },
+ { 0x0441, 0x0441, 0x0015, CanonicalizeSet },
+ { 0x0442, 0x0442, 0x0016, CanonicalizeSet },
+ { 0x0443, 0x0449, 0x0020, CanonicalizeRangeHi },
+ { 0x044a, 0x044a, 0x0017, CanonicalizeSet },
+ { 0x044b, 0x044f, 0x0020, CanonicalizeRangeHi },
+ { 0x0450, 0x045f, 0x0050, CanonicalizeRangeHi },
+ { 0x0460, 0x0461, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0462, 0x0463, 0x0018, CanonicalizeSet },
+ { 0x0464, 0x0481, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0482, 0x0489, 0x0000, CanonicalizeUnique },
+ { 0x048a, 0x04bf, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x04c0, 0x04c0, 0x000f, CanonicalizeRangeLo },
+ { 0x04c1, 0x04ce, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x04cf, 0x04cf, 0x000f, CanonicalizeRangeHi },
+ { 0x04d0, 0x052f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x0530, 0x0530, 0x0000, CanonicalizeUnique },
+ { 0x0531, 0x0556, 0x0030, CanonicalizeRangeLo },
+ { 0x0557, 0x0560, 0x0000, CanonicalizeUnique },
+ { 0x0561, 0x0586, 0x0030, CanonicalizeRangeHi },
+ { 0x0587, 0x109f, 0x0000, CanonicalizeUnique },
+ { 0x10a0, 0x10c5, 0x1c60, CanonicalizeRangeLo },
+ { 0x10c6, 0x10c6, 0x0000, CanonicalizeUnique },
+ { 0x10c7, 0x10c7, 0x1c60, CanonicalizeRangeLo },
+ { 0x10c8, 0x10cc, 0x0000, CanonicalizeUnique },
+ { 0x10cd, 0x10cd, 0x1c60, CanonicalizeRangeLo },
+ { 0x10ce, 0x139f, 0x0000, CanonicalizeUnique },
+ { 0x13a0, 0x13ef, 0x97d0, CanonicalizeRangeLo },
+ { 0x13f0, 0x13f5, 0x0008, CanonicalizeRangeLo },
+ { 0x13f6, 0x13f7, 0x0000, CanonicalizeUnique },
+ { 0x13f8, 0x13fd, 0x0008, CanonicalizeRangeHi },
+ { 0x13fe, 0x1c7f, 0x0000, CanonicalizeUnique },
+ { 0x1c80, 0x1c80, 0x0012, CanonicalizeSet },
+ { 0x1c81, 0x1c81, 0x0013, CanonicalizeSet },
+ { 0x1c82, 0x1c82, 0x0014, CanonicalizeSet },
+ { 0x1c83, 0x1c83, 0x0015, CanonicalizeSet },
+ { 0x1c84, 0x1c85, 0x0016, CanonicalizeSet },
+ { 0x1c86, 0x1c86, 0x0017, CanonicalizeSet },
+ { 0x1c87, 0x1c87, 0x0018, CanonicalizeSet },
+ { 0x1c88, 0x1c88, 0x001a, CanonicalizeSet },
+ { 0x1c89, 0x1d78, 0x0000, CanonicalizeUnique },
+ { 0x1d79, 0x1d79, 0x8a04, CanonicalizeRangeLo },
+ { 0x1d7a, 0x1d7c, 0x0000, CanonicalizeUnique },
+ { 0x1d7d, 0x1d7d, 0x0ee6, CanonicalizeRangeLo },
+ { 0x1d7e, 0x1dff, 0x0000, CanonicalizeUnique },
+ { 0x1e00, 0x1e5f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1e60, 0x1e61, 0x0019, CanonicalizeSet },
+ { 0x1e62, 0x1e95, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1e96, 0x1e9a, 0x0000, CanonicalizeUnique },
+ { 0x1e9b, 0x1e9b, 0x0019, CanonicalizeSet },
+ { 0x1e9c, 0x1e9d, 0x0000, CanonicalizeUnique },
+ { 0x1e9e, 0x1e9e, 0x1dbf, CanonicalizeRangeHi },
+ { 0x1e9f, 0x1e9f, 0x0000, CanonicalizeUnique },
+ { 0x1ea0, 0x1eff, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x1f00, 0x1f07, 0x0008, CanonicalizeRangeLo },
+ { 0x1f08, 0x1f0f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f10, 0x1f15, 0x0008, CanonicalizeRangeLo },
+ { 0x1f16, 0x1f17, 0x0000, CanonicalizeUnique },
+ { 0x1f18, 0x1f1d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f1e, 0x1f1f, 0x0000, CanonicalizeUnique },
+ { 0x1f20, 0x1f27, 0x0008, CanonicalizeRangeLo },
+ { 0x1f28, 0x1f2f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f30, 0x1f37, 0x0008, CanonicalizeRangeLo },
+ { 0x1f38, 0x1f3f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f40, 0x1f45, 0x0008, CanonicalizeRangeLo },
+ { 0x1f46, 0x1f47, 0x0000, CanonicalizeUnique },
+ { 0x1f48, 0x1f4d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f4e, 0x1f50, 0x0000, CanonicalizeUnique },
+ { 0x1f51, 0x1f51, 0x0008, CanonicalizeRangeLo },
+ { 0x1f52, 0x1f52, 0x0000, CanonicalizeUnique },
+ { 0x1f53, 0x1f53, 0x0008, CanonicalizeRangeLo },
+ { 0x1f54, 0x1f54, 0x0000, CanonicalizeUnique },
+ { 0x1f55, 0x1f55, 0x0008, CanonicalizeRangeLo },
+ { 0x1f56, 0x1f56, 0x0000, CanonicalizeUnique },
+ { 0x1f57, 0x1f57, 0x0008, CanonicalizeRangeLo },
+ { 0x1f58, 0x1f58, 0x0000, CanonicalizeUnique },
+ { 0x1f59, 0x1f59, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5a, 0x1f5a, 0x0000, CanonicalizeUnique },
+ { 0x1f5b, 0x1f5b, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5c, 0x1f5c, 0x0000, CanonicalizeUnique },
+ { 0x1f5d, 0x1f5d, 0x0008, CanonicalizeRangeHi },
+ { 0x1f5e, 0x1f5e, 0x0000, CanonicalizeUnique },
+ { 0x1f5f, 0x1f5f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f60, 0x1f67, 0x0008, CanonicalizeRangeLo },
+ { 0x1f68, 0x1f6f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f70, 0x1f71, 0x004a, CanonicalizeRangeLo },
+ { 0x1f72, 0x1f75, 0x0056, CanonicalizeRangeLo },
+ { 0x1f76, 0x1f77, 0x0064, CanonicalizeRangeLo },
+ { 0x1f78, 0x1f79, 0x0080, CanonicalizeRangeLo },
+ { 0x1f7a, 0x1f7b, 0x0070, CanonicalizeRangeLo },
+ { 0x1f7c, 0x1f7d, 0x007e, CanonicalizeRangeLo },
+ { 0x1f7e, 0x1f7f, 0x0000, CanonicalizeUnique },
+ { 0x1f80, 0x1f87, 0x0008, CanonicalizeRangeLo },
+ { 0x1f88, 0x1f8f, 0x0008, CanonicalizeRangeHi },
+ { 0x1f90, 0x1f97, 0x0008, CanonicalizeRangeLo },
+ { 0x1f98, 0x1f9f, 0x0008, CanonicalizeRangeHi },
+ { 0x1fa0, 0x1fa7, 0x0008, CanonicalizeRangeLo },
+ { 0x1fa8, 0x1faf, 0x0008, CanonicalizeRangeHi },
+ { 0x1fb0, 0x1fb1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fb2, 0x1fb2, 0x0000, CanonicalizeUnique },
+ { 0x1fb3, 0x1fb3, 0x0009, CanonicalizeRangeLo },
+ { 0x1fb4, 0x1fb7, 0x0000, CanonicalizeUnique },
+ { 0x1fb8, 0x1fb9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fba, 0x1fbb, 0x004a, CanonicalizeRangeHi },
+ { 0x1fbc, 0x1fbc, 0x0009, CanonicalizeRangeHi },
+ { 0x1fbd, 0x1fbd, 0x0000, CanonicalizeUnique },
+ { 0x1fbe, 0x1fbe, 0x000a, CanonicalizeSet },
+ { 0x1fbf, 0x1fc2, 0x0000, CanonicalizeUnique },
+ { 0x1fc3, 0x1fc3, 0x0009, CanonicalizeRangeLo },
+ { 0x1fc4, 0x1fc7, 0x0000, CanonicalizeUnique },
+ { 0x1fc8, 0x1fcb, 0x0056, CanonicalizeRangeHi },
+ { 0x1fcc, 0x1fcc, 0x0009, CanonicalizeRangeHi },
+ { 0x1fcd, 0x1fcf, 0x0000, CanonicalizeUnique },
+ { 0x1fd0, 0x1fd1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fd2, 0x1fd7, 0x0000, CanonicalizeUnique },
+ { 0x1fd8, 0x1fd9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fda, 0x1fdb, 0x0064, CanonicalizeRangeHi },
+ { 0x1fdc, 0x1fdf, 0x0000, CanonicalizeUnique },
+ { 0x1fe0, 0x1fe1, 0x0008, CanonicalizeRangeLo },
+ { 0x1fe2, 0x1fe4, 0x0000, CanonicalizeUnique },
+ { 0x1fe5, 0x1fe5, 0x0007, CanonicalizeRangeLo },
+ { 0x1fe6, 0x1fe7, 0x0000, CanonicalizeUnique },
+ { 0x1fe8, 0x1fe9, 0x0008, CanonicalizeRangeHi },
+ { 0x1fea, 0x1feb, 0x0070, CanonicalizeRangeHi },
+ { 0x1fec, 0x1fec, 0x0007, CanonicalizeRangeHi },
+ { 0x1fed, 0x1ff2, 0x0000, CanonicalizeUnique },
+ { 0x1ff3, 0x1ff3, 0x0009, CanonicalizeRangeLo },
+ { 0x1ff4, 0x1ff7, 0x0000, CanonicalizeUnique },
+ { 0x1ff8, 0x1ff9, 0x0080, CanonicalizeRangeHi },
+ { 0x1ffa, 0x1ffb, 0x007e, CanonicalizeRangeHi },
+ { 0x1ffc, 0x1ffc, 0x0009, CanonicalizeRangeHi },
+ { 0x1ffd, 0x2125, 0x0000, CanonicalizeUnique },
+ { 0x2126, 0x2126, 0x0011, CanonicalizeSet },
+ { 0x2127, 0x2129, 0x0000, CanonicalizeUnique },
+ { 0x212a, 0x212a, 0x0000, CanonicalizeSet },
+ { 0x212b, 0x212b, 0x0002, CanonicalizeSet },
+ { 0x212c, 0x2131, 0x0000, CanonicalizeUnique },
+ { 0x2132, 0x2132, 0x001c, CanonicalizeRangeLo },
+ { 0x2133, 0x214d, 0x0000, CanonicalizeUnique },
+ { 0x214e, 0x214e, 0x001c, CanonicalizeRangeHi },
+ { 0x214f, 0x215f, 0x0000, CanonicalizeUnique },
+ { 0x2160, 0x216f, 0x0010, CanonicalizeRangeLo },
+ { 0x2170, 0x217f, 0x0010, CanonicalizeRangeHi },
+ { 0x2180, 0x2182, 0x0000, CanonicalizeUnique },
+ { 0x2183, 0x2184, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2185, 0x24b5, 0x0000, CanonicalizeUnique },
+ { 0x24b6, 0x24cf, 0x001a, CanonicalizeRangeLo },
+ { 0x24d0, 0x24e9, 0x001a, CanonicalizeRangeHi },
+ { 0x24ea, 0x2bff, 0x0000, CanonicalizeUnique },
+ { 0x2c00, 0x2c2e, 0x0030, CanonicalizeRangeLo },
+ { 0x2c2f, 0x2c2f, 0x0000, CanonicalizeUnique },
+ { 0x2c30, 0x2c5e, 0x0030, CanonicalizeRangeHi },
+ { 0x2c5f, 0x2c5f, 0x0000, CanonicalizeUnique },
+ { 0x2c60, 0x2c61, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2c62, 0x2c62, 0x29f7, CanonicalizeRangeHi },
+ { 0x2c63, 0x2c63, 0x0ee6, CanonicalizeRangeHi },
+ { 0x2c64, 0x2c64, 0x29e7, CanonicalizeRangeHi },
+ { 0x2c65, 0x2c65, 0x2a2b, CanonicalizeRangeHi },
+ { 0x2c66, 0x2c66, 0x2a28, CanonicalizeRangeHi },
+ { 0x2c67, 0x2c6c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2c6d, 0x2c6d, 0x2a1c, CanonicalizeRangeHi },
+ { 0x2c6e, 0x2c6e, 0x29fd, CanonicalizeRangeHi },
+ { 0x2c6f, 0x2c6f, 0x2a1f, CanonicalizeRangeHi },
+ { 0x2c70, 0x2c70, 0x2a1e, CanonicalizeRangeHi },
+ { 0x2c71, 0x2c71, 0x0000, CanonicalizeUnique },
+ { 0x2c72, 0x2c73, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2c74, 0x2c74, 0x0000, CanonicalizeUnique },
+ { 0x2c75, 0x2c76, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2c77, 0x2c7d, 0x0000, CanonicalizeUnique },
+ { 0x2c7e, 0x2c7f, 0x2a3f, CanonicalizeRangeHi },
+ { 0x2c80, 0x2ce3, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2ce4, 0x2cea, 0x0000, CanonicalizeUnique },
+ { 0x2ceb, 0x2cee, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0x2cef, 0x2cf1, 0x0000, CanonicalizeUnique },
+ { 0x2cf2, 0x2cf3, 0x0000, CanonicalizeAlternatingAligned },
+ { 0x2cf4, 0x2cff, 0x0000, CanonicalizeUnique },
+ { 0x2d00, 0x2d25, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d26, 0x2d26, 0x0000, CanonicalizeUnique },
+ { 0x2d27, 0x2d27, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d28, 0x2d2c, 0x0000, CanonicalizeUnique },
+ { 0x2d2d, 0x2d2d, 0x1c60, CanonicalizeRangeHi },
+ { 0x2d2e, 0xa63f, 0x0000, CanonicalizeUnique },
+ { 0xa640, 0xa649, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa64a, 0xa64b, 0x001a, CanonicalizeSet },
+ { 0xa64c, 0xa66d, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa66e, 0xa67f, 0x0000, CanonicalizeUnique },
+ { 0xa680, 0xa69b, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa69c, 0xa721, 0x0000, CanonicalizeUnique },
+ { 0xa722, 0xa72f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa730, 0xa731, 0x0000, CanonicalizeUnique },
+ { 0xa732, 0xa76f, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa770, 0xa778, 0x0000, CanonicalizeUnique },
+ { 0xa779, 0xa77c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0xa77d, 0xa77d, 0x8a04, CanonicalizeRangeHi },
+ { 0xa77e, 0xa787, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa788, 0xa78a, 0x0000, CanonicalizeUnique },
+ { 0xa78b, 0xa78c, 0x0000, CanonicalizeAlternatingUnaligned },
+ { 0xa78d, 0xa78d, 0xa528, CanonicalizeRangeHi },
+ { 0xa78e, 0xa78f, 0x0000, CanonicalizeUnique },
+ { 0xa790, 0xa793, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa794, 0xa795, 0x0000, CanonicalizeUnique },
+ { 0xa796, 0xa7a9, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa7aa, 0xa7aa, 0xa544, CanonicalizeRangeHi },
+ { 0xa7ab, 0xa7ab, 0xa54f, CanonicalizeRangeHi },
+ { 0xa7ac, 0xa7ac, 0xa54b, CanonicalizeRangeHi },
+ { 0xa7ad, 0xa7ad, 0xa541, CanonicalizeRangeHi },
+ { 0xa7ae, 0xa7ae, 0xa544, CanonicalizeRangeHi },
+ { 0xa7af, 0xa7af, 0x0000, CanonicalizeUnique },
+ { 0xa7b0, 0xa7b0, 0xa512, CanonicalizeRangeHi },
+ { 0xa7b1, 0xa7b1, 0xa52a, CanonicalizeRangeHi },
+ { 0xa7b2, 0xa7b2, 0xa515, CanonicalizeRangeHi },
+ { 0xa7b3, 0xa7b3, 0x03a0, CanonicalizeRangeLo },
+ { 0xa7b4, 0xa7b7, 0x0000, CanonicalizeAlternatingAligned },
+ { 0xa7b8, 0xab52, 0x0000, CanonicalizeUnique },
+ { 0xab53, 0xab53, 0x03a0, CanonicalizeRangeHi },
+ { 0xab54, 0xab6f, 0x0000, CanonicalizeUnique },
+ { 0xab70, 0xabbf, 0x97d0, CanonicalizeRangeHi },
+ { 0xabc0, 0xff20, 0x0000, CanonicalizeUnique },
+ { 0xff21, 0xff3a, 0x0020, CanonicalizeRangeLo },
+ { 0xff3b, 0xff40, 0x0000, CanonicalizeUnique },
+ { 0xff41, 0xff5a, 0x0020, CanonicalizeRangeHi },
+ { 0xff5b, 0x103ff, 0x0000, CanonicalizeUnique },
+ { 0x10400, 0x10427, 0x0028, CanonicalizeRangeLo },
+ { 0x10428, 0x1044f, 0x0028, CanonicalizeRangeHi },
+ { 0x10450, 0x104af, 0x0000, CanonicalizeUnique },
+ { 0x104b0, 0x104d3, 0x0028, CanonicalizeRangeLo },
+ { 0x104d4, 0x104d7, 0x0000, CanonicalizeUnique },
+ { 0x104d8, 0x104fb, 0x0028, CanonicalizeRangeHi },
+ { 0x104fc, 0x10c7f, 0x0000, CanonicalizeUnique },
+ { 0x10c80, 0x10cb2, 0x0040, CanonicalizeRangeLo },
+ { 0x10cb3, 0x10cbf, 0x0000, CanonicalizeUnique },
+ { 0x10cc0, 0x10cf2, 0x0040, CanonicalizeRangeHi },
+ { 0x10cf3, 0x1189f, 0x0000, CanonicalizeUnique },
+ { 0x118a0, 0x118bf, 0x0020, CanonicalizeRangeLo },
+ { 0x118c0, 0x118df, 0x0020, CanonicalizeRangeHi },
+ { 0x118e0, 0x1e8ff, 0x0000, CanonicalizeUnique },
+ { 0x1e900, 0x1e921, 0x0022, CanonicalizeRangeLo },
+ { 0x1e922, 0x1e943, 0x0022, CanonicalizeRangeHi },
+ { 0x1e944, 0x10ffff, 0x0000, CanonicalizeUnique },
+};
+
+} } // JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrErrorCode.cpp b/src/3rdparty/masm/yarr/YarrErrorCode.cpp
new file mode 100644
index 0000000000..aaebd4613d
--- /dev/null
+++ b/src/3rdparty/masm/yarr/YarrErrorCode.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "YarrErrorCode.h"
+
+#include "Error.h"
+
+namespace JSC { namespace Yarr {
+
+const char* errorMessage(ErrorCode error)
+{
+#define REGEXP_ERROR_PREFIX "Invalid regular expression: "
+ // The order of this array must match the ErrorCode enum.
+ static const char* errorMessages[] = {
+ nullptr, // NoError
+ REGEXP_ERROR_PREFIX "regular expression too large", // PatternTooLarge
+ REGEXP_ERROR_PREFIX "numbers out of order in {} quantifier", // QuantifierOutOfOrder
+ REGEXP_ERROR_PREFIX "nothing to repeat", // QuantifierWithoutAtom
+ REGEXP_ERROR_PREFIX "number too large in {} quantifier", // QuantifierTooLarge
+ REGEXP_ERROR_PREFIX "missing )", // MissingParentheses
+ REGEXP_ERROR_PREFIX "unmatched parentheses", // ParenthesesUnmatched
+ REGEXP_ERROR_PREFIX "unrecognized character after (?", // ParenthesesTypeInvalid
+ REGEXP_ERROR_PREFIX "invalid group specifier name", // InvalidGroupName
+ REGEXP_ERROR_PREFIX "duplicate group specifier name", // DuplicateGroupName
+ REGEXP_ERROR_PREFIX "missing terminating ] for character class", // CharacterClassUnmatched
+ REGEXP_ERROR_PREFIX "range out of order in character class", // CharacterClassOutOfOrder
+ REGEXP_ERROR_PREFIX "\\ at end of pattern", // EscapeUnterminated
+ REGEXP_ERROR_PREFIX "invalid unicode {} escape", // InvalidUnicodeEscape
+ REGEXP_ERROR_PREFIX "invalid backreference for unicode pattern", // InvalidBackreference
+ REGEXP_ERROR_PREFIX "invalid escaped character for unicode pattern", // InvalidIdentityEscape
+ REGEXP_ERROR_PREFIX "invalid property expression", // InvalidUnicodePropertyExpression
+ REGEXP_ERROR_PREFIX "too many nested disjunctions", // TooManyDisjunctions
+ REGEXP_ERROR_PREFIX "pattern exceeds string length limits", // OffsetTooLarge
+ REGEXP_ERROR_PREFIX "invalid flags" // InvalidRegularExpressionFlags
+ };
+
+ return errorMessages[static_cast<unsigned>(error)];
+}
+
+JSObject* errorToThrow(ExecState* exec, ErrorCode error)
+{
+ switch (error) {
+ case ErrorCode::NoError:
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ case ErrorCode::PatternTooLarge:
+ case ErrorCode::QuantifierOutOfOrder:
+ case ErrorCode::QuantifierWithoutAtom:
+ case ErrorCode::QuantifierTooLarge:
+ case ErrorCode::MissingParentheses:
+ case ErrorCode::ParenthesesUnmatched:
+ case ErrorCode::ParenthesesTypeInvalid:
+ case ErrorCode::InvalidGroupName:
+ case ErrorCode::DuplicateGroupName:
+ case ErrorCode::CharacterClassUnmatched:
+ case ErrorCode::CharacterClassOutOfOrder:
+ case ErrorCode::EscapeUnterminated:
+ case ErrorCode::InvalidUnicodeEscape:
+ case ErrorCode::InvalidBackreference:
+ case ErrorCode::InvalidIdentityEscape:
+ case ErrorCode::InvalidUnicodePropertyExpression:
+ case ErrorCode::OffsetTooLarge:
+ case ErrorCode::InvalidRegularExpressionFlags:
+ return createSyntaxError(exec, errorMessage(error));
+ case ErrorCode::TooManyDisjunctions:
+ return createOutOfMemoryError(exec, errorMessage(error));
+ }
+
+ ASSERT_NOT_REACHED();
+ return nullptr;
+}
+
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrErrorCode.h b/src/3rdparty/masm/yarr/YarrErrorCode.h
new file mode 100644
index 0000000000..48f2bb7900
--- /dev/null
+++ b/src/3rdparty/masm/yarr/YarrErrorCode.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace JSC {
+
+class ExecState;
+class JSObject;
+
+namespace Yarr {
+
+enum class ErrorCode : uint8_t {
+ NoError = 0,
+ PatternTooLarge,
+ QuantifierOutOfOrder,
+ QuantifierWithoutAtom,
+ QuantifierTooLarge,
+ MissingParentheses,
+ ParenthesesUnmatched,
+ ParenthesesTypeInvalid,
+ InvalidGroupName,
+ DuplicateGroupName,
+ CharacterClassUnmatched,
+ CharacterClassOutOfOrder,
+ EscapeUnterminated,
+ InvalidUnicodeEscape,
+ InvalidBackreference,
+ InvalidIdentityEscape,
+ InvalidUnicodePropertyExpression,
+ TooManyDisjunctions,
+ OffsetTooLarge,
+ InvalidRegularExpressionFlags,
+};
+
+JS_EXPORT_PRIVATE const char* errorMessage(ErrorCode);
+inline bool hasError(ErrorCode errorCode)
+{
+ return errorCode != ErrorCode::NoError;
+}
+JS_EXPORT_PRIVATE JSObject* errorToThrow(ExecState*, ErrorCode);
+
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.cpp b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
index 16fc183cad..6eb6750dc4 100644
--- a/src/3rdparty/masm/yarr/YarrInterpreter.cpp
+++ b/src/3rdparty/masm/yarr/YarrInterpreter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2013-2017 Apple Inc. All rights reserved.
* Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged
*
* Redistribution and use in source and binary forms, with or without
@@ -27,17 +27,15 @@
#include "config.h"
#include "YarrInterpreter.h"
+#include "Options.h"
+#include "SuperSampler.h"
#include "Yarr.h"
-#include "YarrCanonicalizeUCS2.h"
+#include "YarrCanonicalize.h"
#include <wtf/BumpPointerAllocator.h>
#include <wtf/DataLog.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
-#ifndef NDEBUG
-#include <stdio.h>
-#endif
-
using namespace WTF;
namespace JSC { namespace Yarr {
@@ -47,28 +45,6 @@ class Interpreter {
public:
struct ParenthesesDisjunctionContext;
- struct BackTrackInfoPatternCharacter {
- uintptr_t matchAmount;
- };
- struct BackTrackInfoCharacterClass {
- uintptr_t matchAmount;
- };
- struct BackTrackInfoBackReference {
- uintptr_t begin; // Not really needed for greedy quantifiers.
- uintptr_t matchAmount; // Not really needed for fixed quantifiers.
- };
- struct BackTrackInfoAlternative {
- uintptr_t offset;
- };
- struct BackTrackInfoParentheticalAssertion {
- uintptr_t begin;
- };
- struct BackTrackInfoParenthesesOnce {
- uintptr_t begin;
- };
- struct BackTrackInfoParenthesesTerminal {
- uintptr_t begin;
- };
struct BackTrackInfoParentheses {
uintptr_t matchAmount;
ParenthesesDisjunctionContext* lastContext;
@@ -158,7 +134,7 @@ public:
ParenthesesDisjunctionContext* allocParenthesesDisjunctionContext(ByteDisjunction* disjunction, unsigned* output, ByteTerm& term)
{
- size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
+ size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + static_cast<size_t>(disjunction->m_frameSize) * sizeof(uintptr_t);
allocatorPool = allocatorPool->ensureCapacity(size);
RELEASE_ASSERT(allocatorPool);
return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
@@ -171,10 +147,11 @@ public:
class InputStream {
public:
- InputStream(const CharType* input, unsigned start, unsigned length)
+ InputStream(const CharType* input, unsigned start, unsigned length, bool decodeSurrogatePairs)
: input(input)
, pos(start)
, length(length)
+ , decodeSurrogatePairs(decodeSurrogatePairs)
{
}
@@ -208,13 +185,40 @@ public:
RELEASE_ASSERT(pos >= negativePositionOffest);
unsigned p = pos - negativePositionOffest;
ASSERT(p < length);
- return input[p];
+ int result = input[p];
+ if (U16_IS_LEAD(result) && decodeSurrogatePairs && p + 1 < length && U16_IS_TRAIL(input[p + 1])) {
+ if (atEnd())
+ return -1;
+
+ result = U16_GET_SUPPLEMENTARY(result, input[p + 1]);
+ next();
+ }
+ return result;
+ }
+
+ int readSurrogatePairChecked(unsigned negativePositionOffset)
+ {
+ RELEASE_ASSERT(pos >= negativePositionOffset);
+ unsigned p = pos - negativePositionOffset;
+ ASSERT(p < length);
+ if (p + 1 >= length)
+ return -1;
+
+ int first = input[p];
+ int second = input[p + 1];
+ if (U16_IS_LEAD(first) && U16_IS_TRAIL(second))
+ return U16_GET_SUPPLEMENTARY(first, second);
+
+ return -1;
}
int reread(unsigned from)
{
ASSERT(from < length);
- return input[from];
+ int result = input[from];
+ if (U16_IS_LEAD(result) && decodeSurrogatePairs && from + 1 < length && U16_IS_TRAIL(input[from + 1]))
+ result = U16_GET_SUPPLEMENTARY(result, input[from + 1]);
+ return result;
}
int prev()
@@ -265,9 +269,9 @@ public:
pos -= count;
}
- bool atStart(unsigned negativePositionOffest)
+ bool atStart(unsigned negativePositionOffset)
{
- return pos == negativePositionOffest;
+ return pos == negativePositionOffset;
}
bool atEnd(unsigned negativePositionOffest)
@@ -285,24 +289,106 @@ public:
const CharType* input;
unsigned pos;
unsigned length;
+ bool decodeSurrogatePairs;
};
bool testCharacterClass(CharacterClass* characterClass, int ch)
{
- if (ch & 0xFF80) {
- for (unsigned i = 0; i < characterClass->m_matchesUnicode.size(); ++i)
- if (ch == characterClass->m_matchesUnicode[i])
+ auto linearSearchMatches = [&ch](const Vector<UChar32>& matches) {
+ for (unsigned i = 0; i < matches.size(); ++i) {
+ if (ch == matches[i])
+ return true;
+ }
+
+ return false;
+ };
+
+ auto binarySearchMatches = [&ch](const Vector<UChar32>& matches) {
+ size_t low = 0;
+ size_t high = matches.size() - 1;
+
+ while (low <= high) {
+ size_t mid = low + (high - low) / 2;
+ int diff = ch - matches[mid];
+ if (!diff)
+ return true;
+
+ if (diff < 0) {
+ if (mid == low)
+ return false;
+ high = mid - 1;
+ } else
+ low = mid + 1;
+ }
+ return false;
+ };
+
+ auto linearSearchRanges = [&ch](const Vector<CharacterRange>& ranges) {
+ for (unsigned i = 0; i < ranges.size(); ++i) {
+ if ((ch >= ranges[i].begin) && (ch <= ranges[i].end))
return true;
- for (unsigned i = 0; i < characterClass->m_rangesUnicode.size(); ++i)
- if ((ch >= characterClass->m_rangesUnicode[i].begin) && (ch <= characterClass->m_rangesUnicode[i].end))
+ }
+
+ return false;
+ };
+
+ auto binarySearchRanges = [&ch](const Vector<CharacterRange>& ranges) {
+ size_t low = 0;
+ size_t high = ranges.size() - 1;
+
+ while (low <= high) {
+ size_t mid = low + (high - low) / 2;
+ int rangeBeginDiff = ch - ranges[mid].begin;
+ if (rangeBeginDiff >= 0 && ch <= ranges[mid].end)
return true;
+
+ if (rangeBeginDiff < 0) {
+ if (mid == low)
+ return false;
+ high = mid - 1;
+ } else
+ low = mid + 1;
+ }
+ return false;
+ };
+
+ if (characterClass->m_anyCharacter)
+ return true;
+
+ const size_t thresholdForBinarySearch = 6;
+
+ if (!isASCII(ch)) {
+ if (characterClass->m_matchesUnicode.size()) {
+ if (characterClass->m_matchesUnicode.size() > thresholdForBinarySearch) {
+ if (binarySearchMatches(characterClass->m_matchesUnicode))
+ return true;
+ } else if (linearSearchMatches(characterClass->m_matchesUnicode))
+ return true;
+ }
+
+ if (characterClass->m_rangesUnicode.size()) {
+ if (characterClass->m_rangesUnicode.size() > thresholdForBinarySearch) {
+ if (binarySearchRanges(characterClass->m_rangesUnicode))
+ return true;
+ } else if (linearSearchRanges(characterClass->m_rangesUnicode))
+ return true;
+ }
} else {
- for (unsigned i = 0; i < characterClass->m_matches.size(); ++i)
- if (ch == characterClass->m_matches[i])
+ if (characterClass->m_matches.size()) {
+ if (characterClass->m_matches.size() > thresholdForBinarySearch) {
+ if (binarySearchMatches(characterClass->m_matches))
+ return true;
+ } else if (linearSearchMatches(characterClass->m_matches))
return true;
- for (unsigned i = 0; i < characterClass->m_ranges.size(); ++i)
- if ((ch >= characterClass->m_ranges[i].begin) && (ch <= characterClass->m_ranges[i].end))
+ }
+
+ if (characterClass->m_ranges.size()) {
+ if (characterClass->m_ranges.size() > thresholdForBinarySearch) {
+ if (binarySearchRanges(characterClass->m_ranges))
+ return true;
+ } else if (linearSearchRanges(characterClass->m_ranges))
return true;
+ }
}
return false;
@@ -313,6 +399,11 @@ public:
return testChar == input.readChecked(negativeInputOffset);
}
+ bool checkSurrogatePair(int testUnicodeChar, unsigned negativeInputOffset)
+ {
+ return testUnicodeChar == input.readSurrogatePairChecked(negativeInputOffset);
+ }
+
bool checkCasedCharacter(int loChar, int hiChar, unsigned negativeInputOffset)
{
int ch = input.readChecked(negativeInputOffset);
@@ -332,32 +423,31 @@ public:
if (!input.checkInput(matchSize))
return false;
- if (pattern->m_ignoreCase) {
- for (unsigned i = 0; i < matchSize; ++i) {
- int oldCh = input.reread(matchBegin + i);
- int ch = input.readChecked(negativeInputOffset + matchSize - i);
-
- if (oldCh == ch)
- continue;
-
- // The definition for canonicalize (see ES 5.1, 15.10.2.8) means that
- // unicode values are never allowed to match against ascii ones.
- if (isASCII(oldCh) || isASCII(ch)) {
+ for (unsigned i = 0; i < matchSize; ++i) {
+ int oldCh = input.reread(matchBegin + i);
+ int ch;
+ if (!U_IS_BMP(oldCh)) {
+ ch = input.readSurrogatePairChecked(negativeInputOffset + matchSize - i);
+ ++i;
+ } else
+ ch = input.readChecked(negativeInputOffset + matchSize - i);
+
+ if (oldCh == ch)
+ continue;
+
+ if (pattern->ignoreCase()) {
+ // See ES 6.0, 21.2.2.8.2 for the definition of Canonicalize(). For non-Unicode
+ // patterns, Unicode values are never allowed to match against ASCII ones.
+ // For Unicode, we need to check all canonical equivalents of a character.
+ if (!unicode && (isASCII(oldCh) || isASCII(ch))) {
if (toASCIIUpper(oldCh) == toASCIIUpper(ch))
continue;
- } else if (areCanonicallyEquivalent(oldCh, ch))
+ } else if (areCanonicallyEquivalent(oldCh, ch, unicode ? CanonicalMode::Unicode : CanonicalMode::UCS2))
continue;
-
- input.uncheckInput(matchSize);
- return false;
- }
- } else {
- for (unsigned i = 0; i < matchSize; ++i) {
- if (!checkCharacter(input.reread(matchBegin + i), negativeInputOffset + matchSize - i)) {
- input.uncheckInput(matchSize);
- return false;
- }
}
+
+ input.uncheckInput(matchSize);
+ return false;
}
return true;
@@ -365,15 +455,15 @@ public:
bool matchAssertionBOL(ByteTerm& term)
{
- return (input.atStart(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition + 1)));
+ return (input.atStart(term.inputPosition)) || (pattern->multiline() && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition + 1)));
}
bool matchAssertionEOL(ByteTerm& term)
{
if (term.inputPosition)
- return (input.atEnd(term.inputPosition)) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition)));
+ return (input.atEnd(term.inputPosition)) || (pattern->multiline() && testCharacterClass(pattern->newlineCharacterClass, input.readChecked(term.inputPosition)));
- return (input.atEnd()) || (pattern->m_multiline && testCharacterClass(pattern->newlineCharacterClass, input.read()));
+ return (input.atEnd()) || (pattern->multiline() && testCharacterClass(pattern->newlineCharacterClass, input.read()));
}
bool matchAssertionWordBoundary(ByteTerm& term)
@@ -400,18 +490,18 @@ public:
case QuantifierGreedy:
if (backTrack->matchAmount) {
--backTrack->matchAmount;
- input.uncheckInput(1);
+ input.uncheckInput(U16_LENGTH(term.atom.patternCharacter));
return true;
}
break;
case QuantifierNonGreedy:
- if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
+ if ((backTrack->matchAmount < term.atom.quantityMaxCount) && input.checkInput(1)) {
++backTrack->matchAmount;
if (checkCharacter(term.atom.patternCharacter, term.inputPosition + 1))
return true;
}
- input.uncheckInput(backTrack->matchAmount);
+ input.setPos(backTrack->begin);
break;
}
@@ -435,7 +525,7 @@ public:
break;
case QuantifierNonGreedy:
- if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
+ if ((backTrack->matchAmount < term.atom.quantityMaxCount) && input.checkInput(1)) {
++backTrack->matchAmount;
if (checkCasedCharacter(term.atom.casedCharacter.lo, term.atom.casedCharacter.hi, term.inputPosition + 1))
return true;
@@ -450,11 +540,24 @@ public:
bool matchCharacterClass(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeCharacterClass);
- BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
+ BackTrackInfoCharacterClass* backTrack = reinterpret_cast<BackTrackInfoCharacterClass*>(context->frame + term.frameLocation);
switch (term.atom.quantityType) {
case QuantifierFixedCount: {
- for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
+ if (unicode) {
+ backTrack->begin = input.getPos();
+ unsigned matchAmount = 0;
+ for (matchAmount = 0; matchAmount < term.atom.quantityMaxCount; ++matchAmount) {
+ if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - matchAmount)) {
+ input.setPos(backTrack->begin);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ for (unsigned matchAmount = 0; matchAmount < term.atom.quantityMaxCount; ++matchAmount) {
if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition - matchAmount))
return false;
}
@@ -462,13 +565,16 @@ public:
}
case QuantifierGreedy: {
+ unsigned position = input.getPos();
+ backTrack->begin = position;
unsigned matchAmount = 0;
- while ((matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
+ while ((matchAmount < term.atom.quantityMaxCount) && input.checkInput(1)) {
if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + 1)) {
- input.uncheckInput(1);
+ input.setPos(position);
break;
}
++matchAmount;
+ position = input.getPos();
}
backTrack->matchAmount = matchAmount;
@@ -476,6 +582,7 @@ public:
}
case QuantifierNonGreedy:
+ backTrack->begin = input.getPos();
backTrack->matchAmount = 0;
return true;
}
@@ -487,14 +594,28 @@ public:
bool backtrackCharacterClass(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeCharacterClass);
- BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + term.frameLocation);
+ BackTrackInfoCharacterClass* backTrack = reinterpret_cast<BackTrackInfoCharacterClass*>(context->frame + term.frameLocation);
switch (term.atom.quantityType) {
case QuantifierFixedCount:
+ if (unicode)
+ input.setPos(backTrack->begin);
break;
case QuantifierGreedy:
if (backTrack->matchAmount) {
+ if (unicode) {
+ // Rematch one less match
+ input.setPos(backTrack->begin);
+ --backTrack->matchAmount;
+ for (unsigned matchAmount = 0; (matchAmount < backTrack->matchAmount) && input.checkInput(1); ++matchAmount) {
+ if (!checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + 1)) {
+ input.uncheckInput(1);
+ break;
+ }
+ }
+ return true;
+ }
--backTrack->matchAmount;
input.uncheckInput(1);
return true;
@@ -502,12 +623,12 @@ public:
break;
case QuantifierNonGreedy:
- if ((backTrack->matchAmount < term.atom.quantityCount) && input.checkInput(1)) {
+ if ((backTrack->matchAmount < term.atom.quantityMaxCount) && input.checkInput(1)) {
++backTrack->matchAmount;
if (checkCharacterClass(term.atom.characterClass, term.invert(), term.inputPosition + 1))
return true;
}
- input.uncheckInput(backTrack->matchAmount);
+ input.setPos(backTrack->begin);
break;
}
@@ -539,7 +660,7 @@ public:
switch (term.atom.quantityType) {
case QuantifierFixedCount: {
backTrack->begin = input.getPos();
- for (unsigned matchAmount = 0; matchAmount < term.atom.quantityCount; ++matchAmount) {
+ for (unsigned matchAmount = 0; matchAmount < term.atom.quantityMaxCount; ++matchAmount) {
if (!tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
input.setPos(backTrack->begin);
return false;
@@ -550,7 +671,7 @@ public:
case QuantifierGreedy: {
unsigned matchAmount = 0;
- while ((matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition))
+ while ((matchAmount < term.atom.quantityMaxCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition))
++matchAmount;
backTrack->matchAmount = matchAmount;
return true;
@@ -584,7 +705,7 @@ public:
switch (term.atom.quantityType) {
case QuantifierFixedCount:
- // for quantityCount == 1, could rewind.
+ // for quantityMaxCount == 1, could rewind.
input.setPos(backTrack->begin);
break;
@@ -597,7 +718,7 @@ public:
break;
case QuantifierNonGreedy:
- if ((backTrack->matchAmount < term.atom.quantityCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
+ if ((backTrack->matchAmount < term.atom.quantityMaxCount) && tryConsumeBackReference(matchBegin, matchEnd, term.inputPosition)) {
++backTrack->matchAmount;
return true;
}
@@ -612,8 +733,8 @@ public:
{
if (term.capture()) {
unsigned subpatternId = term.atom.subpatternId;
- output[(subpatternId << 1)] = context->getDisjunctionContext(term)->matchBegin + term.inputPosition;
- output[(subpatternId << 1) + 1] = context->getDisjunctionContext(term)->matchEnd + term.inputPosition;
+ output[(subpatternId << 1)] = context->getDisjunctionContext(term)->matchBegin - term.inputPosition;
+ output[(subpatternId << 1) + 1] = context->getDisjunctionContext(term)->matchEnd - term.inputPosition;
}
}
void resetMatches(ByteTerm& term, ParenthesesDisjunctionContext* context)
@@ -645,7 +766,7 @@ public:
bool matchParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
@@ -675,11 +796,11 @@ public:
bool matchParenthesesOnceEnd(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
if (term.capture()) {
unsigned subpatternId = term.atom.subpatternId;
- output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;
+ output[(subpatternId << 1) + 1] = input.getPos() - term.inputPosition;
}
if (term.atom.quantityType == QuantifierFixedCount)
@@ -692,7 +813,7 @@ public:
bool backtrackParenthesesOnceBegin(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
@@ -711,6 +832,7 @@ public:
return true;
case QuantifierNonGreedy:
ASSERT(backTrack->begin != notFound);
+ FALLTHROUGH;
case QuantifierFixedCount:
break;
}
@@ -721,7 +843,7 @@ public:
bool backtrackParenthesesOnceEnd(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternOnceEnd);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParenthesesOnce* backTrack = reinterpret_cast<BackTrackInfoParenthesesOnce*>(context->frame + term.frameLocation);
@@ -731,7 +853,7 @@ public:
context->term -= term.atom.parenthesesWidth;
return false;
}
- Q_FALLTHROUGH();
+ FALLTHROUGH;
case QuantifierNonGreedy:
if (backTrack->begin == notFound) {
backTrack->begin = input.getPos();
@@ -742,11 +864,12 @@ public:
ASSERT((&term - term.atom.parenthesesWidth)->type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
ASSERT((&term - term.atom.parenthesesWidth)->inputPosition == term.inputPosition);
unsigned subpatternId = term.atom.subpatternId;
- output[subpatternId << 1] = input.getPos() + term.inputPosition;
+ output[subpatternId << 1] = input.getPos() - term.inputPosition;
}
context->term -= term.atom.parenthesesWidth;
return true;
}
+ FALLTHROUGH;
case QuantifierFixedCount:
break;
}
@@ -758,7 +881,7 @@ public:
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);
ASSERT(term.atom.quantityType == QuantifierGreedy);
- ASSERT(term.atom.quantityCount == quantifyInfinite);
+ ASSERT(term.atom.quantityMaxCount == quantifyInfinite);
ASSERT(!term.capture());
BackTrackInfoParenthesesTerminal* backTrack = reinterpret_cast<BackTrackInfoParenthesesTerminal*>(context->frame + term.frameLocation);
@@ -775,7 +898,7 @@ public:
if (backTrack->begin == input.getPos())
return false;
- // Successful match! Okay, what's next? - loop around and try to match moar!
+ // Successful match! Okay, what's next? - loop around and try to match more!
context->term -= (term.atom.parenthesesWidth + 1);
return true;
}
@@ -784,7 +907,7 @@ public:
{
ASSERT(term.type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);
ASSERT(term.atom.quantityType == QuantifierGreedy);
- ASSERT(term.atom.quantityCount == quantifyInfinite);
+ ASSERT(term.atom.quantityMaxCount == quantifyInfinite);
ASSERT(!term.capture());
// If we backtrack to this point, we have failed to match this iteration of the parens.
@@ -804,7 +927,7 @@ public:
bool matchParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
@@ -815,7 +938,7 @@ public:
bool matchParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
@@ -833,7 +956,7 @@ public:
bool backtrackParentheticalAssertionBegin(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParentheticalAssertionBegin);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
// We've failed to match parens; if they are inverted, this is win!
if (term.invert()) {
@@ -847,7 +970,7 @@ public:
bool backtrackParentheticalAssertionEnd(ByteTerm& term, DisjunctionContext* context)
{
ASSERT(term.type == ByteTerm::TypeParentheticalAssertionEnd);
- ASSERT(term.atom.quantityCount == 1);
+ ASSERT(term.atom.quantityMaxCount == 1);
BackTrackInfoParentheticalAssertion* backTrack = reinterpret_cast<BackTrackInfoParentheticalAssertion*>(context->frame + term.frameLocation);
@@ -867,36 +990,45 @@ public:
backTrack->matchAmount = 0;
backTrack->lastContext = 0;
- switch (term.atom.quantityType) {
- case QuantifierFixedCount: {
+ ASSERT(term.atom.quantityType != QuantifierFixedCount || term.atom.quantityMinCount == term.atom.quantityMaxCount);
+
+ unsigned minimumMatchCount = term.atom.quantityMinCount;
+ JSRegExpResult fixedMatchResult;
+
+ // Handle fixed matches and the minimum part of a variable length match.
+ if (minimumMatchCount) {
// While we haven't yet reached our fixed limit,
- while (backTrack->matchAmount < term.atom.quantityCount) {
+ while (backTrack->matchAmount < minimumMatchCount) {
// Try to do a match, and it it succeeds, add it to the list.
ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
- JSRegExpResult result = matchDisjunction(disjunctionBody, context->getDisjunctionContext(term));
- if (result == JSRegExpMatch)
+ fixedMatchResult = matchDisjunction(disjunctionBody, context->getDisjunctionContext(term));
+ if (fixedMatchResult == JSRegExpMatch)
appendParenthesesDisjunctionContext(backTrack, context);
else {
// The match failed; try to find an alternate point to carry on from.
resetMatches(term, context);
freeParenthesesDisjunctionContext(context);
-
- if (result != JSRegExpNoMatch)
- return result;
+
+ if (fixedMatchResult != JSRegExpNoMatch)
+ return fixedMatchResult;
JSRegExpResult backtrackResult = parenthesesDoBacktrack(term, backTrack);
if (backtrackResult != JSRegExpMatch)
return backtrackResult;
}
}
- ASSERT(backTrack->matchAmount == term.atom.quantityCount);
ParenthesesDisjunctionContext* context = backTrack->lastContext;
recordParenthesesMatch(term, context);
+ }
+
+ switch (term.atom.quantityType) {
+ case QuantifierFixedCount: {
+ ASSERT(backTrack->matchAmount == term.atom.quantityMaxCount);
return JSRegExpMatch;
}
case QuantifierGreedy: {
- while (backTrack->matchAmount < term.atom.quantityCount) {
+ while (backTrack->matchAmount < term.atom.quantityMaxCount) {
ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));
if (result == JSRegExpMatch)
@@ -946,7 +1078,7 @@ public:
switch (term.atom.quantityType) {
case QuantifierFixedCount: {
- ASSERT(backTrack->matchAmount == term.atom.quantityCount);
+ ASSERT(backTrack->matchAmount == term.atom.quantityMaxCount);
ParenthesesDisjunctionContext* context = 0;
JSRegExpResult result = parenthesesDoBacktrack(term, backTrack);
@@ -955,7 +1087,7 @@ public:
return result;
// While we haven't yet reached our fixed limit,
- while (backTrack->matchAmount < term.atom.quantityCount) {
+ while (backTrack->matchAmount < term.atom.quantityMaxCount) {
// Try to do a match, and it it succeeds, add it to the list.
context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
result = matchDisjunction(disjunctionBody, context->getDisjunctionContext(term));
@@ -975,7 +1107,7 @@ public:
}
}
- ASSERT(backTrack->matchAmount == term.atom.quantityCount);
+ ASSERT(backTrack->matchAmount == term.atom.quantityMaxCount);
context = backTrack->lastContext;
recordParenthesesMatch(term, context);
return JSRegExpMatch;
@@ -988,7 +1120,7 @@ public:
ParenthesesDisjunctionContext* context = backTrack->lastContext;
JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term), true);
if (result == JSRegExpMatch) {
- while (backTrack->matchAmount < term.atom.quantityCount) {
+ while (backTrack->matchAmount < term.atom.quantityMaxCount) {
ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
JSRegExpResult parenthesesResult = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));
if (parenthesesResult == JSRegExpMatch)
@@ -1008,7 +1140,7 @@ public:
popParenthesesDisjunctionContext(backTrack);
freeParenthesesDisjunctionContext(context);
- if (result != JSRegExpNoMatch)
+ if (result != JSRegExpNoMatch || backTrack->matchAmount < term.atom.quantityMinCount)
return result;
}
@@ -1021,7 +1153,7 @@ public:
case QuantifierNonGreedy: {
// If we've not reached the limit, try to add one more match.
- if (backTrack->matchAmount < term.atom.quantityCount) {
+ if (backTrack->matchAmount < term.atom.quantityMaxCount) {
ParenthesesDisjunctionContext* context = allocParenthesesDisjunctionContext(disjunctionBody, output, term);
JSRegExpResult result = matchNonZeroDisjunction(disjunctionBody, context->getDisjunctionContext(term));
if (result == JSRegExpMatch) {
@@ -1070,16 +1202,23 @@ public:
bool matchDotStarEnclosure(ByteTerm& term, DisjunctionContext* context)
{
UNUSED_PARAM(term);
+
+ if (pattern->dotAll()) {
+ context->matchBegin = startOffset;
+ context->matchEnd = input.end();
+ return true;
+ }
+
unsigned matchBegin = context->matchBegin;
- if (matchBegin) {
+ if (matchBegin > startOffset) {
for (matchBegin--; true; matchBegin--) {
if (testCharacterClass(pattern->newlineCharacterClass, input.reread(matchBegin))) {
++matchBegin;
break;
}
- if (!matchBegin)
+ if (matchBegin == startOffset)
break;
}
}
@@ -1091,7 +1230,7 @@ public:
if (((matchBegin && term.anchors.m_bol)
|| ((matchEnd != input.end()) && term.anchors.m_eol))
- && !pattern->m_multiline)
+ && !pattern->multiline())
return false;
context->matchBegin = matchBegin;
@@ -1156,21 +1295,37 @@ public:
case ByteTerm::TypePatternCharacterOnce:
case ByteTerm::TypePatternCharacterFixed: {
- for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityCount; ++matchAmount) {
- if (!checkCharacter(currentTerm().atom.patternCharacter, currentTerm().inputPosition - matchAmount))
+ if (unicode) {
+ if (!U_IS_BMP(currentTerm().atom.patternCharacter)) {
+ for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityMaxCount; ++matchAmount) {
+ if (!checkSurrogatePair(currentTerm().atom.patternCharacter, currentTerm().inputPosition - 2 * matchAmount)) {
+ BACKTRACK();
+ }
+ }
+ MATCH_NEXT();
+ }
+ }
+ unsigned position = input.getPos(); // May need to back out reading a surrogate pair.
+
+ for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityMaxCount; ++matchAmount) {
+ if (!checkCharacter(currentTerm().atom.patternCharacter, currentTerm().inputPosition - matchAmount)) {
+ input.setPos(position);
BACKTRACK();
+ }
}
MATCH_NEXT();
}
case ByteTerm::TypePatternCharacterGreedy: {
BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);
unsigned matchAmount = 0;
- while ((matchAmount < currentTerm().atom.quantityCount) && input.checkInput(1)) {
+ unsigned position = input.getPos(); // May need to back out reading a surrogate pair.
+ while ((matchAmount < currentTerm().atom.quantityMaxCount) && input.checkInput(1)) {
if (!checkCharacter(currentTerm().atom.patternCharacter, currentTerm().inputPosition + 1)) {
- input.uncheckInput(1);
+ input.setPos(position);
break;
}
++matchAmount;
+ position = input.getPos();
}
backTrack->matchAmount = matchAmount;
@@ -1178,13 +1333,29 @@ public:
}
case ByteTerm::TypePatternCharacterNonGreedy: {
BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);
+ backTrack->begin = input.getPos();
backTrack->matchAmount = 0;
MATCH_NEXT();
}
case ByteTerm::TypePatternCasedCharacterOnce:
case ByteTerm::TypePatternCasedCharacterFixed: {
- for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityCount; ++matchAmount) {
+ if (unicode) {
+ // Case insensitive matching of unicode characters is handled as TypeCharacterClass.
+ ASSERT(U_IS_BMP(currentTerm().atom.patternCharacter));
+
+ unsigned position = input.getPos(); // May need to back out reading a surrogate pair.
+
+ for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityMaxCount; ++matchAmount) {
+ if (!checkCasedCharacter(currentTerm().atom.casedCharacter.lo, currentTerm().atom.casedCharacter.hi, currentTerm().inputPosition - matchAmount)) {
+ input.setPos(position);
+ BACKTRACK();
+ }
+ }
+ MATCH_NEXT();
+ }
+
+ for (unsigned matchAmount = 0; matchAmount < currentTerm().atom.quantityMaxCount; ++matchAmount) {
if (!checkCasedCharacter(currentTerm().atom.casedCharacter.lo, currentTerm().atom.casedCharacter.hi, currentTerm().inputPosition - matchAmount))
BACKTRACK();
}
@@ -1192,8 +1363,12 @@ public:
}
case ByteTerm::TypePatternCasedCharacterGreedy: {
BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);
+
+ // Case insensitive matching of unicode characters is handled as TypeCharacterClass.
+ ASSERT(!unicode || U_IS_BMP(currentTerm().atom.patternCharacter));
+
unsigned matchAmount = 0;
- while ((matchAmount < currentTerm().atom.quantityCount) && input.checkInput(1)) {
+ while ((matchAmount < currentTerm().atom.quantityMaxCount) && input.checkInput(1)) {
if (!checkCasedCharacter(currentTerm().atom.casedCharacter.lo, currentTerm().atom.casedCharacter.hi, currentTerm().inputPosition + 1)) {
input.uncheckInput(1);
break;
@@ -1206,6 +1381,10 @@ public:
}
case ByteTerm::TypePatternCasedCharacterNonGreedy: {
BackTrackInfoPatternCharacter* backTrack = reinterpret_cast<BackTrackInfoPatternCharacter*>(context->frame + currentTerm().frameLocation);
+
+ // Case insensitive matching of unicode characters is handled as TypeCharacterClass.
+ ASSERT(!unicode || U_IS_BMP(currentTerm().atom.patternCharacter));
+
backTrack->matchAmount = 0;
MATCH_NEXT();
}
@@ -1287,7 +1466,7 @@ public:
if (offset > 0)
MATCH_NEXT();
- if (input.atEnd())
+ if (input.atEnd() || pattern->sticky())
return JSRegExpNoMatch;
input.next();
@@ -1417,6 +1596,9 @@ public:
if (!input.isAvailableInput(0))
return offsetNoMatch;
+ if (pattern->m_lock)
+ pattern->m_lock->lock();
+
for (unsigned i = 0; i < pattern->m_body->m_numSubpatterns + 1; ++i)
output[i << 1] = offsetNoMatch;
@@ -1436,23 +1618,31 @@ public:
pattern->m_allocator->stopAllocator();
ASSERT((result == JSRegExpMatch) == (output[0] != offsetNoMatch));
+
+ if (pattern->m_lock)
+ pattern->m_lock->unlock();
+
return output[0];
}
Interpreter(BytecodePattern* pattern, unsigned* output, const CharType* input, unsigned length, unsigned start)
: pattern(pattern)
+ , unicode(pattern->unicode())
, output(output)
- , input(input, start, length)
+ , input(input, start, length, pattern->unicode())
, allocatorPool(0)
+ , startOffset(start)
, remainingMatchCount(matchLimit)
{
}
private:
BytecodePattern* pattern;
+ bool unicode;
unsigned* output;
InputStream input;
BumpPointerPool* allocatorPool;
+ unsigned startOffset;
unsigned remainingMatchCount;
};
@@ -1474,13 +1664,18 @@ public:
m_currentAlternativeIndex = 0;
}
- PassOwnPtr<BytecodePattern> compile(BumpPointerAllocator* allocator)
+ std::unique_ptr<BytecodePattern> compile(BumpPointerAllocator* allocator, ConcurrentJSLock* lock)
{
regexBegin(m_pattern.m_numSubpatterns, m_pattern.m_body->m_callFrameSize, m_pattern.m_body->m_alternatives[0]->onceThrough());
emitDisjunction(m_pattern.m_body);
regexEnd();
- return adoptPtr(new BytecodePattern(m_bodyDisjunction.release(), m_allParenthesesInfo, m_pattern, allocator));
+#ifndef NDEBUG
+ if (Options::dumpCompiledRegExpPatterns())
+ dumpDisjunction(m_bodyDisjunction.get());
+#endif
+
+ return std::make_unique<BytecodePattern>(WTFMove(m_bodyDisjunction), m_allParenthesesInfo, m_pattern, allocator, lock);
}
void checkInput(unsigned count)
@@ -1508,45 +1703,44 @@ public:
m_bodyDisjunction->terms.append(ByteTerm::WordBoundary(invert, inputPosition));
}
- void atomPatternCharacter(UChar ch, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomPatternCharacter(UChar32 ch, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
- if (m_pattern.m_ignoreCase) {
- UChar lo = Unicode::toLower(ch);
- UChar hi = Unicode::toUpper(ch);
+ if (m_pattern.ignoreCase()) {
+ UChar32 lo = u_tolower(ch);
+ UChar32 hi = u_toupper(ch);
if (lo != hi) {
- m_bodyDisjunction->terms.append(ByteTerm(lo, hi, inputPosition, frameLocation, quantityCount, quantityType));
+ m_bodyDisjunction->terms.append(ByteTerm(lo, hi, inputPosition, frameLocation, quantityMaxCount, quantityType));
return;
}
}
- m_bodyDisjunction->terms.append(ByteTerm(ch, inputPosition, frameLocation, quantityCount, quantityType));
+ m_bodyDisjunction->terms.append(ByteTerm(ch, inputPosition, frameLocation, quantityMaxCount, quantityType));
}
- void atomCharacterClass(CharacterClass* characterClass, bool invert, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomCharacterClass(CharacterClass* characterClass, bool invert, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
m_bodyDisjunction->terms.append(ByteTerm(characterClass, invert, inputPosition));
- m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityType = quantityType;
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
}
- void atomBackReference(unsigned subpatternId, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomBackReference(unsigned subpatternId, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
ASSERT(subpatternId);
m_bodyDisjunction->terms.append(ByteTerm::BackReference(subpatternId, inputPosition));
- m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].atom.quantityType = quantityType;
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
}
void atomParenthesesOnceBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)
{
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ unsigned beginTerm = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1559,8 +1753,7 @@ public:
void atomParenthesesTerminalBegin(unsigned subpatternId, bool capture, unsigned inputPosition, unsigned frameLocation, unsigned alternativeFrameLocation)
{
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ int beginTerm = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternTerminalBegin, subpatternId, capture, false, inputPosition));
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1577,8 +1770,7 @@ public:
// then fix this up at the end! - simplifying this should make it much clearer.
// https://bugs.webkit.org/show_bug.cgi?id=50136
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ int beginTerm = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpatternOnceBegin, subpatternId, capture, false, inputPosition));
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1591,8 +1783,7 @@ public:
void atomParentheticalAssertionBegin(unsigned subpatternId, bool invert, unsigned frameLocation, unsigned alternativeFrameLocation)
{
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int beginTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ int beginTerm = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParentheticalAssertionBegin, subpatternId, false, invert, 0));
m_bodyDisjunction->terms[m_bodyDisjunction->terms.size() - 1].frameLocation = frameLocation;
@@ -1603,12 +1794,11 @@ public:
m_currentAlternativeIndex = beginTerm + 1;
}
- void atomParentheticalAssertionEnd(unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomParentheticalAssertionEnd(unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
unsigned beginTerm = popParenthesesStack();
closeAlternative(beginTerm + 1);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ unsigned endTerm = m_bodyDisjunction->terms.size();
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParentheticalAssertionBegin);
@@ -1620,9 +1810,9 @@ public:
m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;
m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;
- m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;
- m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[endTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;
}
@@ -1634,8 +1824,7 @@ public:
unsigned popParenthesesStack()
{
ASSERT(m_parenthesesStack.size());
- ASSERT(m_parenthesesStack.size() <= INT_MAX);
- int stackEnd = static_cast<int>(m_parenthesesStack.size()) - 1;
+ int stackEnd = m_parenthesesStack.size() - 1;
unsigned beginTerm = m_parenthesesStack[stackEnd].beginTerm;
m_currentAlternativeIndex = m_parenthesesStack[stackEnd].savedAlternativeIndex;
m_parenthesesStack.shrink(stackEnd);
@@ -1646,22 +1835,11 @@ public:
return beginTerm;
}
-#ifndef NDEBUG
- void dumpDisjunction(ByteDisjunction* disjunction)
- {
- dataLogF("ByteDisjunction(%p):\n\t", disjunction);
- for (unsigned i = 0; i < disjunction->terms.size(); ++i)
- dataLogF("{ %d } ", disjunction->terms[i].type);
- dataLogF("\n");
- }
-#endif
-
void closeAlternative(int beginTerm)
{
int origBeginTerm = beginTerm;
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeAlternativeBegin);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());
+ int endIndex = m_bodyDisjunction->terms.size();
unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;
@@ -1687,8 +1865,7 @@ public:
int beginTerm = 0;
int origBeginTerm = 0;
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeBodyAlternativeBegin);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int endIndex = static_cast<int>(m_bodyDisjunction->terms.size());
+ int endIndex = m_bodyDisjunction->terms.size();
unsigned frameLocation = m_bodyDisjunction->terms[beginTerm].frameLocation;
@@ -1705,12 +1882,11 @@ public:
m_bodyDisjunction->terms[endIndex].frameLocation = frameLocation;
}
- void atomParenthesesSubpatternEnd(unsigned lastSubpatternId, int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType, unsigned callFrameSize = 0)
+ void atomParenthesesSubpatternEnd(unsigned lastSubpatternId, unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMinCount, Checked<unsigned> quantityMaxCount, QuantifierType quantityType, unsigned callFrameSize = 0)
{
unsigned beginTerm = popParenthesesStack();
closeAlternative(beginTerm + 1);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ unsigned endTerm = m_bodyDisjunction->terms.size();
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
@@ -1720,7 +1896,7 @@ public:
unsigned subpatternId = parenthesesBegin.atom.subpatternId;
unsigned numSubpatterns = lastSubpatternId - subpatternId + 1;
- OwnPtr<ByteDisjunction> parenthesesDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));
+ auto parenthesesDisjunction = std::make_unique<ByteDisjunction>(numSubpatterns, callFrameSize);
unsigned firstTermInParentheses = beginTerm + 1;
parenthesesDisjunction->terms.reserveInitialCapacity(endTerm - firstTermInParentheses + 2);
@@ -1733,19 +1909,19 @@ public:
m_bodyDisjunction->terms.shrink(beginTerm);
m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, inputPosition));
- m_allParenthesesInfo.append(parenthesesDisjunction.release());
+ m_allParenthesesInfo.append(WTFMove(parenthesesDisjunction));
- m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMinCount = quantityMinCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;
m_bodyDisjunction->terms[beginTerm].frameLocation = frameLocation;
}
- void atomParenthesesOnceEnd(int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomParenthesesOnceEnd(unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMinCount, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
unsigned beginTerm = popParenthesesStack();
closeAlternative(beginTerm + 1);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ unsigned endTerm = m_bodyDisjunction->terms.size();
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternOnceBegin);
@@ -1757,18 +1933,19 @@ public:
m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;
m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;
- m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMinCount = quantityMinCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;
- m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[endTerm].atom.quantityMinCount = quantityMinCount.unsafeGet();
+ m_bodyDisjunction->terms[endTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;
}
- void atomParenthesesTerminalEnd(int inputPosition, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ void atomParenthesesTerminalEnd(unsigned inputPosition, unsigned frameLocation, Checked<unsigned> quantityMinCount, Checked<unsigned> quantityMaxCount, QuantifierType quantityType)
{
unsigned beginTerm = popParenthesesStack();
closeAlternative(beginTerm + 1);
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- unsigned endTerm = static_cast<int>(m_bodyDisjunction->terms.size());
+ unsigned endTerm = m_bodyDisjunction->terms.size();
ASSERT(m_bodyDisjunction->terms[beginTerm].type == ByteTerm::TypeParenthesesSubpatternTerminalBegin);
@@ -1780,15 +1957,17 @@ public:
m_bodyDisjunction->terms[endTerm].atom.parenthesesWidth = endTerm - beginTerm;
m_bodyDisjunction->terms[endTerm].frameLocation = frameLocation;
- m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMinCount = quantityMinCount.unsafeGet();
+ m_bodyDisjunction->terms[beginTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType;
- m_bodyDisjunction->terms[endTerm].atom.quantityCount = quantityCount.unsafeGet();
+ m_bodyDisjunction->terms[endTerm].atom.quantityMinCount = quantityMinCount.unsafeGet();
+ m_bodyDisjunction->terms[endTerm].atom.quantityMaxCount = quantityMaxCount.unsafeGet();
m_bodyDisjunction->terms[endTerm].atom.quantityType = quantityType;
}
void regexBegin(unsigned numSubpatterns, unsigned callFrameSize, bool onceThrough)
{
- m_bodyDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize));
+ m_bodyDisjunction = std::make_unique<ByteDisjunction>(numSubpatterns, callFrameSize);
m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeBegin(onceThrough));
m_bodyDisjunction->terms[0].frameLocation = 0;
m_currentAlternativeIndex = 0;
@@ -1801,8 +1980,7 @@ public:
void alternativeBodyDisjunction(bool onceThrough)
{
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());
+ int newAlternativeIndex = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;
m_bodyDisjunction->terms.append(ByteTerm::BodyAlternativeDisjunction(onceThrough));
@@ -1811,8 +1989,7 @@ public:
void alternativeDisjunction()
{
- ASSERT(m_bodyDisjunction->terms.size() <= INT_MAX);
- int newAlternativeIndex = static_cast<int>(m_bodyDisjunction->terms.size());
+ int newAlternativeIndex = m_bodyDisjunction->terms.size();
m_bodyDisjunction->terms[m_currentAlternativeIndex].alternative.next = newAlternativeIndex - m_currentAlternativeIndex;
m_bodyDisjunction->terms.append(ByteTerm::AlternativeDisjunction());
@@ -1842,9 +2019,7 @@ public:
currentCountAlreadyChecked += countToCheck;
}
- for (unsigned i = 0; i < alternative->m_terms.size(); ++i) {
- PatternTerm& term = alternative->m_terms[i];
-
+ for (auto& term : alternative->m_terms) {
switch (term.type) {
case PatternTerm::TypeAssertionBOL:
assertionBOL(currentCountAlreadyChecked - term.inputPosition);
@@ -1859,15 +2034,15 @@ public:
break;
case PatternTerm::TypePatternCharacter:
- atomPatternCharacter(term.patternCharacter, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);
+ atomPatternCharacter(term.patternCharacter, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityMaxCount, term.quantityType);
break;
case PatternTerm::TypeCharacterClass:
- atomCharacterClass(term.characterClass, term.invert(), currentCountAlreadyChecked- term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);
+ atomCharacterClass(term.characterClass, term.invert(), currentCountAlreadyChecked- term.inputPosition, term.frameLocation, term.quantityMaxCount, term.quantityType);
break;
case PatternTerm::TypeBackReference:
- atomBackReference(term.backReferenceSubpatternId, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityCount, term.quantityType);
+ atomBackReference(term.backReferenceSubpatternId, currentCountAlreadyChecked - term.inputPosition, term.frameLocation, term.quantityMaxCount, term.quantityType);
break;
case PatternTerm::TypeForwardReference:
@@ -1875,27 +2050,30 @@ public:
case PatternTerm::TypeParenthesesSubpattern: {
unsigned disjunctionAlreadyCheckedCount = 0;
- if (term.quantityCount == 1 && !term.parentheses.isCopy) {
+ if (term.quantityMaxCount == 1 && !term.parentheses.isCopy) {
unsigned alternativeFrameLocation = term.frameLocation;
// For QuantifierFixedCount we pre-check the minimum size; for greedy/non-greedy we reserve a slot in the frame.
if (term.quantityType == QuantifierFixedCount)
disjunctionAlreadyCheckedCount = term.parentheses.disjunction->m_minimumSize;
else
alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
- unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
- atomParenthesesOnceBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, alternativeFrameLocation);
+ ASSERT(currentCountAlreadyChecked >= term.inputPosition);
+ unsigned delegateEndInputOffset = currentCountAlreadyChecked - term.inputPosition;
+ atomParenthesesOnceBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount + delegateEndInputOffset, term.frameLocation, alternativeFrameLocation);
emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, disjunctionAlreadyCheckedCount);
- atomParenthesesOnceEnd(delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType);
+ atomParenthesesOnceEnd(delegateEndInputOffset, term.frameLocation, term.quantityMinCount, term.quantityMaxCount, term.quantityType);
} else if (term.parentheses.isTerminal) {
- unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
- atomParenthesesTerminalBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, term.frameLocation + YarrStackSpaceForBackTrackInfoParenthesesOnce);
+ ASSERT(currentCountAlreadyChecked >= term.inputPosition);
+ unsigned delegateEndInputOffset = currentCountAlreadyChecked - term.inputPosition;
+ atomParenthesesTerminalBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount + delegateEndInputOffset, term.frameLocation, term.frameLocation + YarrStackSpaceForBackTrackInfoParenthesesTerminal);
emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, disjunctionAlreadyCheckedCount);
- atomParenthesesTerminalEnd(delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType);
+ atomParenthesesTerminalEnd(delegateEndInputOffset, term.frameLocation, term.quantityMinCount, term.quantityMaxCount, term.quantityType);
} else {
- unsigned delegateEndInputOffset = term.inputPosition - currentCountAlreadyChecked;
- atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount - delegateEndInputOffset, term.frameLocation, 0);
+ ASSERT(currentCountAlreadyChecked >= term.inputPosition);
+ unsigned delegateEndInputOffset = currentCountAlreadyChecked - term.inputPosition;
+ atomParenthesesSubpatternBegin(term.parentheses.subpatternId, term.capture(), disjunctionAlreadyCheckedCount + delegateEndInputOffset, term.frameLocation, 0);
emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, 0);
- atomParenthesesSubpatternEnd(term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);
+ atomParenthesesSubpatternEnd(term.parentheses.lastSubpatternId, delegateEndInputOffset, term.frameLocation, term.quantityMinCount, term.quantityMaxCount, term.quantityType, term.parentheses.disjunction->m_callFrameSize);
}
break;
}
@@ -1903,8 +2081,8 @@ public:
case PatternTerm::TypeParentheticalAssertion: {
unsigned alternativeFrameLocation = term.frameLocation + YarrStackSpaceForBackTrackInfoParentheticalAssertion;
- ASSERT(currentCountAlreadyChecked >= static_cast<unsigned>(term.inputPosition));
- unsigned positiveInputOffset = currentCountAlreadyChecked - static_cast<unsigned>(term.inputPosition);
+ ASSERT(currentCountAlreadyChecked >= term.inputPosition);
+ unsigned positiveInputOffset = currentCountAlreadyChecked - term.inputPosition;
unsigned uncheckAmount = 0;
if (positiveInputOffset > term.parentheses.disjunction->m_minimumSize) {
uncheckAmount = positiveInputOffset - term.parentheses.disjunction->m_minimumSize;
@@ -1914,7 +2092,7 @@ public:
atomParentheticalAssertionBegin(term.parentheses.subpatternId, term.invert(), term.frameLocation, alternativeFrameLocation);
emitDisjunction(term.parentheses.disjunction, currentCountAlreadyChecked, positiveInputOffset - uncheckAmount);
- atomParentheticalAssertionEnd(0, term.frameLocation, term.quantityCount, term.quantityType);
+ atomParentheticalAssertionEnd(0, term.frameLocation, term.quantityMaxCount, term.quantityType);
if (uncheckAmount) {
checkInput(uncheckAmount);
currentCountAlreadyChecked += uncheckAmount;
@@ -1929,22 +2107,283 @@ public:
}
}
}
+#ifndef NDEBUG
+ void dumpDisjunction(ByteDisjunction* disjunction, unsigned nesting = 0)
+ {
+ PrintStream& out = WTF::dataFile();
+
+ unsigned termIndexNest = 0;
+
+ if (!nesting) {
+ out.printf("ByteDisjunction(%p):\n", disjunction);
+ nesting = 1;
+ } else {
+ termIndexNest = nesting - 1;
+ nesting = 2;
+ }
+
+ auto outputTermIndexAndNest = [&](size_t index, unsigned termNesting) {
+ for (unsigned nestingDepth = 0; nestingDepth < termIndexNest; nestingDepth++)
+ out.print(" ");
+ out.printf("%4zu", index);
+ for (unsigned nestingDepth = 0; nestingDepth < termNesting; nestingDepth++)
+ out.print(" ");
+ };
+
+ auto dumpQuantity = [&](ByteTerm& term) {
+ if (term.atom.quantityType == QuantifierFixedCount && term.atom.quantityMinCount == 1 && term.atom.quantityMaxCount == 1)
+ return;
+
+ out.print(" {", term.atom.quantityMinCount);
+ if (term.atom.quantityMinCount != term.atom.quantityMaxCount) {
+ if (term.atom.quantityMaxCount == UINT_MAX)
+ out.print(",inf");
+ else
+ out.print(",", term.atom.quantityMaxCount);
+ }
+ out.print("}");
+ if (term.atom.quantityType == QuantifierGreedy)
+ out.print(" greedy");
+ else if (term.atom.quantityType == QuantifierNonGreedy)
+ out.print(" non-greedy");
+ };
+
+ auto dumpCaptured = [&](ByteTerm& term) {
+ if (term.capture())
+ out.print(" captured (#", term.atom.subpatternId, ")");
+ };
+
+ auto dumpInverted = [&](ByteTerm& term) {
+ if (term.invert())
+ out.print(" inverted");
+ };
+
+ auto dumpInputPosition = [&](ByteTerm& term) {
+ out.printf(" inputPosition %u", term.inputPosition);
+ };
+
+ auto dumpFrameLocation = [&](ByteTerm& term) {
+ out.printf(" frameLocation %u", term.frameLocation);
+ };
+
+ auto dumpCharacter = [&](ByteTerm& term) {
+ out.print(" ");
+ dumpUChar32(out, term.atom.patternCharacter);
+ };
+
+ auto dumpCharClass = [&](ByteTerm& term) {
+ out.print(" ");
+ dumpCharacterClass(out, &m_pattern, term.atom.characterClass);
+ };
+
+ for (size_t idx = 0; idx < disjunction->terms.size(); ++idx) {
+ ByteTerm term = disjunction->terms[idx];
+
+ bool outputNewline = true;
+
+ switch (term.type) {
+ case ByteTerm::TypeBodyAlternativeBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("BodyAlternativeBegin");
+ if (term.alternative.onceThrough)
+ out.print(" onceThrough");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeBodyAlternativeDisjunction:
+ outputTermIndexAndNest(idx, nesting - 1);
+ out.print("BodyAlternativeDisjunction");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeBodyAlternativeEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("BodyAlternativeEnd");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeAlternativeBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("AlternativeBegin");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeAlternativeDisjunction:
+ outputTermIndexAndNest(idx, nesting - 1);
+ out.print("AlternativeDisjunction");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeAlternativeEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("AlternativeEnd");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeSubpatternBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("SubpatternBegin");
+ break;
+ case ByteTerm::TypeSubpatternEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("SubpatternEnd");
+ break;
+ case ByteTerm::TypeAssertionBOL:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("AssertionBOL");
+ break;
+ case ByteTerm::TypeAssertionEOL:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("AssertionEOL");
+ break;
+ case ByteTerm::TypeAssertionWordBoundary:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("AssertionWordBoundary");
+ break;
+ case ByteTerm::TypePatternCharacterOnce:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCharacterOnce");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpCharacter(term);
+ dumpQuantity(term);
+ break;
+ case ByteTerm::TypePatternCharacterFixed:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCharacterFixed");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpCharacter(term);
+ out.print(" {", term.atom.quantityMinCount, "}");
+ break;
+ case ByteTerm::TypePatternCharacterGreedy:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCharacterGreedy");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpCharacter(term);
+ dumpQuantity(term);
+ break;
+ case ByteTerm::TypePatternCharacterNonGreedy:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCharacterNonGreedy");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpCharacter(term);
+ dumpQuantity(term);
+ break;
+ case ByteTerm::TypePatternCasedCharacterOnce:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCasedCharacterOnce");
+ break;
+ case ByteTerm::TypePatternCasedCharacterFixed:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCasedCharacterFixed");
+ break;
+ case ByteTerm::TypePatternCasedCharacterGreedy:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCasedCharacterGreedy");
+ break;
+ case ByteTerm::TypePatternCasedCharacterNonGreedy:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("PatternCasedCharacterNonGreedy");
+ break;
+ case ByteTerm::TypeCharacterClass:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("CharacterClass");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpCharClass(term);
+ dumpQuantity(term);
+ break;
+ case ByteTerm::TypeBackReference:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("BackReference #", term.atom.subpatternId);
+ dumpQuantity(term);
+ break;
+ case ByteTerm::TypeParenthesesSubpattern:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("ParenthesesSubpattern");
+ dumpCaptured(term);
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ dumpQuantity(term);
+ out.print("\n");
+ outputNewline = false;
+ dumpDisjunction(term.atom.parenthesesDisjunction, nesting);
+ break;
+ case ByteTerm::TypeParenthesesSubpatternOnceBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("ParenthesesSubpatternOnceBegin");
+ dumpCaptured(term);
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeParenthesesSubpatternOnceEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("ParenthesesSubpatternOnceEnd");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeParenthesesSubpatternTerminalBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("ParenthesesSubpatternTerminalBegin");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeParenthesesSubpatternTerminalEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("ParenthesesSubpatternTerminalEnd");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeParentheticalAssertionBegin:
+ outputTermIndexAndNest(idx, nesting++);
+ out.print("ParentheticalAssertionBegin");
+ dumpInverted(term);
+ dumpInputPosition(term);
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeParentheticalAssertionEnd:
+ outputTermIndexAndNest(idx, --nesting);
+ out.print("ParentheticalAssertionEnd");
+ dumpFrameLocation(term);
+ break;
+ case ByteTerm::TypeCheckInput:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("CheckInput ", term.checkInputCount);
+ break;
+ case ByteTerm::TypeUncheckInput:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("UncheckInput ", term.checkInputCount);
+ break;
+ case ByteTerm::TypeDotStarEnclosure:
+ outputTermIndexAndNest(idx, nesting);
+ out.print("DotStarEnclosure");
+ break;
+ }
+ if (outputNewline)
+ out.print("\n");
+ }
+ }
+#endif
private:
YarrPattern& m_pattern;
- OwnPtr<ByteDisjunction> m_bodyDisjunction;
+ std::unique_ptr<ByteDisjunction> m_bodyDisjunction;
unsigned m_currentAlternativeIndex;
Vector<ParenthesesStackEntry> m_parenthesesStack;
- Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo;
+ Vector<std::unique_ptr<ByteDisjunction>> m_allParenthesesInfo;
};
-PassOwnPtr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator)
+std::unique_ptr<BytecodePattern> byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator, ConcurrentJSLock* lock)
{
- return ByteCompiler(pattern).compile(allocator);
+ return ByteCompiler(pattern).compile(allocator, lock);
}
unsigned interpret(BytecodePattern* bytecode, const String& input, unsigned start, unsigned* output)
{
+ SuperSamplerScope superSamplerScope(false);
if (input.is8Bit())
return Interpreter<LChar>(bytecode, output, input.characters8(), input.length(), start).interpret();
return Interpreter<UChar>(bytecode, output, input.characters16(), input.length(), start).interpret();
@@ -1952,22 +2391,24 @@ unsigned interpret(BytecodePattern* bytecode, const String& input, unsigned star
unsigned interpret(BytecodePattern* bytecode, const LChar* input, unsigned length, unsigned start, unsigned* output)
{
+ SuperSamplerScope superSamplerScope(false);
return Interpreter<LChar>(bytecode, output, input, length, start).interpret();
}
unsigned interpret(BytecodePattern* bytecode, const UChar* input, unsigned length, unsigned start, unsigned* output)
{
+ SuperSamplerScope superSamplerScope(false);
return Interpreter<UChar>(bytecode, output, input, length, start).interpret();
}
// These should be the same for both UChar & LChar.
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoAlternative) == (YarrStackSpaceForBackTrackInfoAlternative * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoAlternative);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheticalAssertion) == (YarrStackSpaceForBackTrackInfoParentheticalAssertion * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheticalAssertion);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParenthesesOnce) == (YarrStackSpaceForBackTrackInfoParenthesesOnce * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParenthesesOnce);
-COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheses) == (YarrStackSpaceForBackTrackInfoParentheses * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheses);
+COMPILE_ASSERT(sizeof(BackTrackInfoPatternCharacter) == (YarrStackSpaceForBackTrackInfoPatternCharacter * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoPatternCharacter);
+COMPILE_ASSERT(sizeof(BackTrackInfoCharacterClass) == (YarrStackSpaceForBackTrackInfoCharacterClass * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoCharacterClass);
+COMPILE_ASSERT(sizeof(BackTrackInfoBackReference) == (YarrStackSpaceForBackTrackInfoBackReference * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoBackReference);
+COMPILE_ASSERT(sizeof(BackTrackInfoAlternative) == (YarrStackSpaceForBackTrackInfoAlternative * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoAlternative);
+COMPILE_ASSERT(sizeof(BackTrackInfoParentheticalAssertion) == (YarrStackSpaceForBackTrackInfoParentheticalAssertion * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheticalAssertion);
+COMPILE_ASSERT(sizeof(BackTrackInfoParenthesesOnce) == (YarrStackSpaceForBackTrackInfoParenthesesOnce * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParenthesesOnce);
+COMPILE_ASSERT(sizeof(Interpreter<UChar>::BackTrackInfoParentheses) <= (YarrStackSpaceForBackTrackInfoParentheses * sizeof(uintptr_t)), CheckYarrStackSpaceForBackTrackInfoParentheses);
} }
diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.h b/src/3rdparty/masm/yarr/YarrInterpreter.h
index 3b44acbd2b..a319cb3461 100644
--- a/src/3rdparty/masm/yarr/YarrInterpreter.h
+++ b/src/3rdparty/masm/yarr/YarrInterpreter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010-2012, 2014, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,12 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef YarrInterpreter_h
-#define YarrInterpreter_h
+#pragma once
+#include "ConcurrentJSLock.h"
#include "YarrPattern.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/unicode/Unicode.h>
namespace WTF {
class BumpPointerAllocator;
@@ -76,10 +74,10 @@ struct ByteTerm {
union {
struct {
union {
- UChar patternCharacter;
+ UChar32 patternCharacter;
struct {
- UChar lo;
- UChar hi;
+ UChar32 lo;
+ UChar32 hi;
} casedCharacter;
CharacterClass* characterClass;
unsigned subpatternId;
@@ -89,7 +87,8 @@ struct ByteTerm {
unsigned parenthesesWidth;
};
QuantifierType quantityType;
- unsigned quantityCount;
+ unsigned quantityMinCount;
+ unsigned quantityMaxCount;
} atom;
struct {
int next;
@@ -107,11 +106,17 @@ struct ByteTerm {
bool m_invert : 1;
unsigned inputPosition;
- ByteTerm(UChar ch, int inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ ByteTerm(UChar32 ch, unsigned inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
: frameLocation(frameLocation)
, m_capture(false)
, m_invert(false)
{
+ atom.patternCharacter = ch;
+ atom.quantityType = quantityType;
+ atom.quantityMinCount = quantityCount.unsafeGet();
+ atom.quantityMaxCount = quantityCount.unsafeGet();
+ inputPosition = inputPos;
+
switch (quantityType) {
case QuantifierFixedCount:
type = (quantityCount == 1) ? ByteTerm::TypePatternCharacterOnce : ByteTerm::TypePatternCharacterFixed;
@@ -123,14 +128,9 @@ struct ByteTerm {
type = ByteTerm::TypePatternCharacterNonGreedy;
break;
}
-
- atom.patternCharacter = ch;
- atom.quantityType = quantityType;
- atom.quantityCount = quantityCount.unsafeGet();
- inputPosition = inputPos;
}
- ByteTerm(UChar lo, UChar hi, int inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
+ ByteTerm(UChar32 lo, UChar32 hi, unsigned inputPos, unsigned frameLocation, Checked<unsigned> quantityCount, QuantifierType quantityType)
: frameLocation(frameLocation)
, m_capture(false)
, m_invert(false)
@@ -150,22 +150,24 @@ struct ByteTerm {
atom.casedCharacter.lo = lo;
atom.casedCharacter.hi = hi;
atom.quantityType = quantityType;
- atom.quantityCount = quantityCount.unsafeGet();
+ atom.quantityMinCount = quantityCount.unsafeGet();
+ atom.quantityMaxCount = quantityCount.unsafeGet();
inputPosition = inputPos;
}
- ByteTerm(CharacterClass* characterClass, bool invert, int inputPos)
+ ByteTerm(CharacterClass* characterClass, bool invert, unsigned inputPos)
: type(ByteTerm::TypeCharacterClass)
, m_capture(false)
, m_invert(invert)
{
atom.characterClass = characterClass;
atom.quantityType = QuantifierFixedCount;
- atom.quantityCount = 1;
+ atom.quantityMinCount = 1;
+ atom.quantityMaxCount = 1;
inputPosition = inputPos;
}
- ByteTerm(Type type, unsigned subpatternId, ByteDisjunction* parenthesesInfo, bool capture, int inputPos)
+ ByteTerm(Type type, unsigned subpatternId, ByteDisjunction* parenthesesInfo, bool capture, unsigned inputPos)
: type(type)
, m_capture(capture)
, m_invert(false)
@@ -173,7 +175,8 @@ struct ByteTerm {
atom.subpatternId = subpatternId;
atom.parenthesesDisjunction = parenthesesInfo;
atom.quantityType = QuantifierFixedCount;
- atom.quantityCount = 1;
+ atom.quantityMinCount = 1;
+ atom.quantityMaxCount = 1;
inputPosition = inputPos;
}
@@ -183,21 +186,23 @@ struct ByteTerm {
, m_invert(invert)
{
atom.quantityType = QuantifierFixedCount;
- atom.quantityCount = 1;
+ atom.quantityMinCount = 1;
+ atom.quantityMaxCount = 1;
}
- ByteTerm(Type type, unsigned subpatternId, bool capture, bool invert, int inputPos)
+ ByteTerm(Type type, unsigned subpatternId, bool capture, bool invert, unsigned inputPos)
: type(type)
, m_capture(capture)
, m_invert(invert)
{
atom.subpatternId = subpatternId;
atom.quantityType = QuantifierFixedCount;
- atom.quantityCount = 1;
+ atom.quantityMinCount = 1;
+ atom.quantityMaxCount = 1;
inputPosition = inputPos;
}
- static ByteTerm BOL(int inputPos)
+ static ByteTerm BOL(unsigned inputPos)
{
ByteTerm term(TypeAssertionBOL);
term.inputPosition = inputPos;
@@ -218,21 +223,21 @@ struct ByteTerm {
return term;
}
- static ByteTerm EOL(int inputPos)
+ static ByteTerm EOL(unsigned inputPos)
{
ByteTerm term(TypeAssertionEOL);
term.inputPosition = inputPos;
return term;
}
- static ByteTerm WordBoundary(bool invert, int inputPos)
+ static ByteTerm WordBoundary(bool invert, unsigned inputPos)
{
ByteTerm term(TypeAssertionWordBoundary, invert);
term.inputPosition = inputPos;
return term;
}
- static ByteTerm BackReference(unsigned subpatternId, int inputPos)
+ static ByteTerm BackReference(unsigned subpatternId, unsigned inputPos)
{
return ByteTerm(TypeBackReference, subpatternId, false, false, inputPos);
}
@@ -329,6 +334,8 @@ public:
{
}
+ size_t estimatedSizeInBytes() const { return terms.capacity() * sizeof(ByteTerm); }
+
Vector<ByteTerm> terms;
unsigned m_numSubpatterns;
unsigned m_frameSize;
@@ -337,16 +344,19 @@ public:
struct BytecodePattern {
WTF_MAKE_FAST_ALLOCATED;
public:
- BytecodePattern(PassOwnPtr<ByteDisjunction> body, Vector<OwnPtr<ByteDisjunction> >& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator)
- : m_body(body)
- , m_ignoreCase(pattern.m_ignoreCase)
- , m_multiline(pattern.m_multiline)
+ BytecodePattern(std::unique_ptr<ByteDisjunction> body, Vector<std::unique_ptr<ByteDisjunction>>& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator, ConcurrentJSLock* lock)
+ : m_body(WTFMove(body))
+ , m_flags(pattern.m_flags)
, m_allocator(allocator)
+ , m_lock(lock)
{
m_body->terms.shrinkToFit();
newlineCharacterClass = pattern.newlineCharacterClass();
- wordcharCharacterClass = pattern.wordcharCharacterClass();
+ if (unicode() && ignoreCase())
+ wordcharCharacterClass = pattern.wordUnicodeIgnoreCaseCharCharacterClass();
+ else
+ wordcharCharacterClass = pattern.wordcharCharacterClass();
m_allParenthesesInfo.swap(parenthesesInfoToAdopt);
m_allParenthesesInfo.shrinkToFit();
@@ -355,26 +365,32 @@ public:
m_userCharacterClasses.shrinkToFit();
}
- OwnPtr<ByteDisjunction> m_body;
- bool m_ignoreCase;
- bool m_multiline;
+ size_t estimatedSizeInBytes() const { return m_body->estimatedSizeInBytes(); }
+
+ bool ignoreCase() const { return m_flags & FlagIgnoreCase; }
+ bool multiline() const { return m_flags & FlagMultiline; }
+ bool sticky() const { return m_flags & FlagSticky; }
+ bool unicode() const { return m_flags & FlagUnicode; }
+ bool dotAll() const { return m_flags & FlagDotAll; }
+
+ std::unique_ptr<ByteDisjunction> m_body;
+ RegExpFlags m_flags;
// Each BytecodePattern is associated with a RegExp, each RegExp is associated
- // with a JSGlobalData. Cache a pointer to out JSGlobalData's m_regExpAllocator.
+ // with a VM. Cache a pointer to out VM's m_regExpAllocator.
BumpPointerAllocator* m_allocator;
+ ConcurrentJSLock* m_lock;
CharacterClass* newlineCharacterClass;
CharacterClass* wordcharCharacterClass;
private:
- Vector<OwnPtr<ByteDisjunction> > m_allParenthesesInfo;
- Vector<OwnPtr<CharacterClass> > m_userCharacterClasses;
+ Vector<std::unique_ptr<ByteDisjunction>> m_allParenthesesInfo;
+ Vector<std::unique_ptr<CharacterClass>> m_userCharacterClasses;
};
-JS_EXPORT_PRIVATE PassOwnPtr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*);
+JS_EXPORT_PRIVATE std::unique_ptr<BytecodePattern> byteCompile(YarrPattern&, BumpPointerAllocator*, ConcurrentJSLock* = nullptr);
JS_EXPORT_PRIVATE unsigned interpret(BytecodePattern*, const String& input, unsigned start, unsigned* output);
unsigned interpret(BytecodePattern*, const LChar* input, unsigned length, unsigned start, unsigned* output);
unsigned interpret(BytecodePattern*, const UChar* input, unsigned length, unsigned start, unsigned* output);
} } // namespace JSC::Yarr
-
-#endif // YarrInterpreter_h
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
index 71123b7be7..ce7c7163ed 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.cpp
+++ b/src/3rdparty/masm/yarr/YarrJIT.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,22 +25,23 @@
#include "config.h"
#include "YarrJIT.h"
+
#include <wtf/ASCIICType.h>
+#include "LinkBuffer.h"
#include "Options.h"
+#include "VM.h"
#include "Yarr.h"
-#include "YarrCanonicalizeUCS2.h"
+#include "YarrCanonicalize.h"
#if ENABLE(YARR_JIT)
-#include "LinkBuffer.h"
-
using namespace WTF;
namespace JSC { namespace Yarr {
template<YarrJITCompileMode compileMode>
class YarrGenerator : private DefaultMacroAssembler {
- friend void jitCompile(JSGlobalData*, YarrCodeBlock& jitObject, const String& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline);
+ friend void jitCompile(VM*, YarrCodeBlock&, const String& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline);
#if CPU(ARM)
static const RegisterID input = ARMRegisters::r0;
@@ -50,20 +51,38 @@ class YarrGenerator : private DefaultMacroAssembler {
static const RegisterID regT0 = ARMRegisters::r4;
static const RegisterID regT1 = ARMRegisters::r5;
+ static const RegisterID initialStart = ARMRegisters::r8;
static const RegisterID returnRegister = ARMRegisters::r0;
static const RegisterID returnRegister2 = ARMRegisters::r1;
+
+#define HAVE_INITIAL_START_REG
#elif CPU(ARM64)
+ // Argument registers
static const RegisterID input = ARM64Registers::x0;
static const RegisterID index = ARM64Registers::x1;
static const RegisterID length = ARM64Registers::x2;
static const RegisterID output = ARM64Registers::x3;
-
- static const RegisterID regT0 = ARM64Registers::x4;
- static const RegisterID regT1 = ARM64Registers::x5;
+ static const RegisterID freelistRegister = ARM64Registers::x4;
+ static const RegisterID freelistSizeRegister = ARM64Registers::x5;
+
+ // Scratch registers
+ static const RegisterID regT0 = ARM64Registers::x6;
+ static const RegisterID regT1 = ARM64Registers::x7;
+ static const RegisterID regT2 = ARM64Registers::x8;
+ static const RegisterID remainingMatchCount = ARM64Registers::x9;
+ static const RegisterID regUnicodeInputAndTrail = ARM64Registers::x10;
+ static const RegisterID initialStart = ARM64Registers::x11;
+ static const RegisterID supplementaryPlanesBase = ARM64Registers::x12;
+ static const RegisterID surrogateTagMask = ARM64Registers::x13;
+ static const RegisterID leadingSurrogateTag = ARM64Registers::x14;
+ static const RegisterID trailingSurrogateTag = ARM64Registers::x15;
static const RegisterID returnRegister = ARM64Registers::x0;
static const RegisterID returnRegister2 = ARM64Registers::x1;
+
+#define HAVE_INITIAL_START_REG
+#define JIT_UNICODE_EXPRESSIONS
#elif CPU(MIPS)
static const RegisterID input = MIPSRegisters::a0;
static const RegisterID index = MIPSRegisters::a1;
@@ -72,20 +91,12 @@ class YarrGenerator : private DefaultMacroAssembler {
static const RegisterID regT0 = MIPSRegisters::t4;
static const RegisterID regT1 = MIPSRegisters::t5;
+ static const RegisterID initialStart = MIPSRegisters::t6;
static const RegisterID returnRegister = MIPSRegisters::v0;
static const RegisterID returnRegister2 = MIPSRegisters::v1;
-#elif CPU(SH4)
- static const RegisterID input = SH4Registers::r4;
- static const RegisterID index = SH4Registers::r5;
- static const RegisterID length = SH4Registers::r6;
- static const RegisterID output = SH4Registers::r7;
- static const RegisterID regT0 = SH4Registers::r0;
- static const RegisterID regT1 = SH4Registers::r1;
-
- static const RegisterID returnRegister = SH4Registers::r0;
- static const RegisterID returnRegister2 = SH4Registers::r1;
+#define HAVE_INITIAL_START_REG
#elif CPU(X86)
static const RegisterID input = X86Registers::eax;
static const RegisterID index = X86Registers::edx;
@@ -99,10 +110,13 @@ class YarrGenerator : private DefaultMacroAssembler {
static const RegisterID returnRegister2 = X86Registers::edx;
#elif CPU(X86_64)
#if !OS(WINDOWS)
+ // Argument registers
static const RegisterID input = X86Registers::edi;
static const RegisterID index = X86Registers::esi;
static const RegisterID length = X86Registers::edx;
static const RegisterID output = X86Registers::ecx;
+ static const RegisterID freelistRegister = X86Registers::r8;
+ static const RegisterID freelistSizeRegister = X86Registers::r9; // Only used during initialization.
#else
// If the return value doesn't fit in 64bits, its destination is pointed by rcx and the parameters are shifted.
// http://msdn.microsoft.com/en-us/library/7572ztz4.aspx
@@ -113,11 +127,186 @@ class YarrGenerator : private DefaultMacroAssembler {
static const RegisterID output = X86Registers::r10;
#endif
+ // Scratch registers
static const RegisterID regT0 = X86Registers::eax;
- static const RegisterID regT1 = X86Registers::ebx;
+#if !OS(WINDOWS)
+ static const RegisterID regT1 = X86Registers::r9;
+ static const RegisterID regT2 = X86Registers::r10;
+#else
+ static const RegisterID regT1 = X86Registers::ecx;
+ static const RegisterID regT2 = X86Registers::edi;
+#endif
+
+ static const RegisterID initialStart = X86Registers::ebx;
+#if !OS(WINDOWS)
+ static const RegisterID remainingMatchCount = X86Registers::r12;
+#else
+ static const RegisterID remainingMatchCount = X86Registers::esi;
+#endif
+ static const RegisterID regUnicodeInputAndTrail = X86Registers::r13;
+ static const RegisterID leadingSurrogateTag = X86Registers::r14;
+ static const RegisterID trailingSurrogateTag = X86Registers::r15;
static const RegisterID returnRegister = X86Registers::eax;
static const RegisterID returnRegister2 = X86Registers::edx;
+
+ const TrustedImm32 supplementaryPlanesBase = TrustedImm32(0x10000);
+ const TrustedImm32 surrogateTagMask = TrustedImm32(0xfffffc00);
+#define HAVE_INITIAL_START_REG
+#define JIT_UNICODE_EXPRESSIONS
+#endif
+
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ struct ParenContextSizes {
+ size_t m_numSubpatterns;
+ size_t m_frameSlots;
+
+ ParenContextSizes(size_t numSubpatterns, size_t frameSlots)
+ : m_numSubpatterns(numSubpatterns)
+ , m_frameSlots(frameSlots)
+ {
+ }
+
+ size_t numSubpatterns() { return m_numSubpatterns; }
+
+ size_t frameSlots() { return m_frameSlots; }
+ };
+
+ struct ParenContext {
+ struct ParenContext* next;
+ uint32_t begin;
+ uint32_t matchAmount;
+ uintptr_t returnAddress;
+ struct Subpatterns {
+ unsigned start;
+ unsigned end;
+ } subpatterns[0];
+ uintptr_t frameSlots[0];
+
+ static size_t sizeFor(ParenContextSizes& parenContextSizes)
+ {
+ return sizeof(ParenContext) + sizeof(Subpatterns) * parenContextSizes.numSubpatterns() + sizeof(uintptr_t) * parenContextSizes.frameSlots();
+ }
+
+ static ptrdiff_t nextOffset()
+ {
+ return offsetof(ParenContext, next);
+ }
+
+ static ptrdiff_t beginOffset()
+ {
+ return offsetof(ParenContext, begin);
+ }
+
+ static ptrdiff_t matchAmountOffset()
+ {
+ return offsetof(ParenContext, matchAmount);
+ }
+
+ static ptrdiff_t returnAddressOffset()
+ {
+ return offsetof(ParenContext, returnAddress);
+ }
+
+ static ptrdiff_t subpatternOffset(size_t subpattern)
+ {
+ return offsetof(ParenContext, subpatterns) + (subpattern - 1) * sizeof(Subpatterns);
+ }
+
+ static ptrdiff_t savedFrameOffset(ParenContextSizes& parenContextSizes)
+ {
+ return offsetof(ParenContext, subpatterns) + (parenContextSizes.numSubpatterns()) * sizeof(Subpatterns);
+ }
+ };
+
+ void initParenContextFreeList()
+ {
+ RegisterID parenContextPointer = regT0;
+ RegisterID nextParenContextPointer = regT2;
+
+ size_t parenContextSize = ParenContext::sizeFor(m_parenContextSizes);
+
+ parenContextSize = WTF::roundUpToMultipleOf<sizeof(uintptr_t)>(parenContextSize);
+
+ // Check that the paren context is a reasonable size.
+ if (parenContextSize > INT16_MAX)
+ m_abortExecution.append(jump());
+
+ Jump emptyFreeList = branchTestPtr(Zero, freelistRegister);
+ move(freelistRegister, parenContextPointer);
+ addPtr(TrustedImm32(parenContextSize), freelistRegister, nextParenContextPointer);
+ addPtr(freelistRegister, freelistSizeRegister);
+ subPtr(TrustedImm32(parenContextSize), freelistSizeRegister);
+
+ Label loopTop(this);
+ Jump initDone = branchPtr(Above, nextParenContextPointer, freelistSizeRegister);
+ storePtr(nextParenContextPointer, Address(parenContextPointer, ParenContext::nextOffset()));
+ move(nextParenContextPointer, parenContextPointer);
+ addPtr(TrustedImm32(parenContextSize), parenContextPointer, nextParenContextPointer);
+ jump(loopTop);
+
+ initDone.link(this);
+ storePtr(TrustedImmPtr(nullptr), Address(parenContextPointer, ParenContext::nextOffset()));
+ emptyFreeList.link(this);
+ }
+
+ void allocateParenContext(RegisterID result)
+ {
+ m_abortExecution.append(branchTestPtr(Zero, freelistRegister));
+ sub32(TrustedImm32(1), remainingMatchCount);
+ m_hitMatchLimit.append(branchTestPtr(Zero, remainingMatchCount));
+ move(freelistRegister, result);
+ loadPtr(Address(freelistRegister, ParenContext::nextOffset()), freelistRegister);
+ }
+
+ void freeParenContext(RegisterID headPtrRegister, RegisterID newHeadPtrRegister)
+ {
+ loadPtr(Address(headPtrRegister, ParenContext::nextOffset()), newHeadPtrRegister);
+ storePtr(freelistRegister, Address(headPtrRegister, ParenContext::nextOffset()));
+ move(headPtrRegister, freelistRegister);
+ }
+
+ void saveParenContext(RegisterID parenContextReg, RegisterID tempReg, unsigned firstSubpattern, unsigned lastSubpattern, unsigned subpatternBaseFrameLocation)
+ {
+ store32(index, Address(parenContextReg, ParenContext::beginOffset()));
+ loadFromFrame(subpatternBaseFrameLocation + BackTrackInfoParentheses::matchAmountIndex(), tempReg);
+ store32(tempReg, Address(parenContextReg, ParenContext::matchAmountOffset()));
+ loadFromFrame(subpatternBaseFrameLocation + BackTrackInfoParentheses::returnAddressIndex(), tempReg);
+ storePtr(tempReg, Address(parenContextReg, ParenContext::returnAddressOffset()));
+ if (compileMode == IncludeSubpatterns) {
+ for (unsigned subpattern = firstSubpattern; subpattern <= lastSubpattern; subpattern++) {
+ loadPtr(Address(output, (subpattern << 1) * sizeof(unsigned)), tempReg);
+ storePtr(tempReg, Address(parenContextReg, ParenContext::subpatternOffset(subpattern)));
+ clearSubpatternStart(subpattern);
+ }
+ }
+ subpatternBaseFrameLocation += YarrStackSpaceForBackTrackInfoParentheses;
+ for (unsigned frameLocation = subpatternBaseFrameLocation; frameLocation < m_parenContextSizes.frameSlots(); frameLocation++) {
+ loadFromFrame(frameLocation, tempReg);
+ storePtr(tempReg, Address(parenContextReg, ParenContext::savedFrameOffset(m_parenContextSizes) + frameLocation * sizeof(uintptr_t)));
+ }
+ }
+
+ void restoreParenContext(RegisterID parenContextReg, RegisterID tempReg, unsigned firstSubpattern, unsigned lastSubpattern, unsigned subpatternBaseFrameLocation)
+ {
+ load32(Address(parenContextReg, ParenContext::beginOffset()), index);
+ storeToFrame(index, subpatternBaseFrameLocation + BackTrackInfoParentheses::beginIndex());
+ load32(Address(parenContextReg, ParenContext::matchAmountOffset()), tempReg);
+ storeToFrame(tempReg, subpatternBaseFrameLocation + BackTrackInfoParentheses::matchAmountIndex());
+ loadPtr(Address(parenContextReg, ParenContext::returnAddressOffset()), tempReg);
+ storeToFrame(tempReg, subpatternBaseFrameLocation + BackTrackInfoParentheses::returnAddressIndex());
+ if (compileMode == IncludeSubpatterns) {
+ for (unsigned subpattern = firstSubpattern; subpattern <= lastSubpattern; subpattern++) {
+ loadPtr(Address(parenContextReg, ParenContext::subpatternOffset(subpattern)), tempReg);
+ storePtr(tempReg, Address(output, (subpattern << 1) * sizeof(unsigned)));
+ }
+ }
+ subpatternBaseFrameLocation += YarrStackSpaceForBackTrackInfoParentheses;
+ for (unsigned frameLocation = subpatternBaseFrameLocation; frameLocation < m_parenContextSizes.frameSlots(); frameLocation++) {
+ loadPtr(Address(parenContextReg, ParenContext::savedFrameOffset(m_parenContextSizes) + frameLocation * sizeof(uintptr_t)), tempReg);
+ storeToFrame(tempReg, frameLocation);
+ }
+ }
#endif
void optimizeAlternative(PatternAlternative* alternative)
@@ -129,8 +318,10 @@ class YarrGenerator : private DefaultMacroAssembler {
PatternTerm& term = alternative->m_terms[i];
PatternTerm& nextTerm = alternative->m_terms[i + 1];
+ // We can move BMP only character classes after fixed character terms.
if ((term.type == PatternTerm::TypeCharacterClass)
&& (term.quantityType == QuantifierFixedCount)
+ && (!m_decodeSurrogatePairs || (!term.characterClass->m_hasNonBMPCharacters && !term.m_invert))
&& (nextTerm.type == PatternTerm::TypePatternCharacter)
&& (nextTerm.quantityType == QuantifierFixedCount)) {
PatternTerm termCopy = term;
@@ -140,7 +331,7 @@ class YarrGenerator : private DefaultMacroAssembler {
}
}
- void matchCharacterClassRange(RegisterID character, JumpList& failures, JumpList& matchDest, const CharacterRange* ranges, unsigned count, unsigned* matchIndex, const UChar* matches, unsigned matchCount)
+ void matchCharacterClassRange(RegisterID character, JumpList& failures, JumpList& matchDest, const CharacterRange* ranges, unsigned count, unsigned* matchIndex, const UChar32* matches, unsigned matchCount)
{
do {
// pick which range we're going to generate
@@ -189,26 +380,28 @@ class YarrGenerator : private DefaultMacroAssembler {
void matchCharacterClass(RegisterID character, JumpList& matchDest, const CharacterClass* charClass)
{
- if (charClass->m_table) {
+ if (charClass->m_table && !m_decodeSurrogatePairs) {
ExtendedAddress tableEntry(character, reinterpret_cast<intptr_t>(charClass->m_table));
matchDest.append(branchTest8(charClass->m_tableInverted ? Zero : NonZero, tableEntry));
return;
}
- Jump unicodeFail;
+ JumpList unicodeFail;
if (charClass->m_matchesUnicode.size() || charClass->m_rangesUnicode.size()) {
- Jump isAscii = branch32(LessThanOrEqual, character, TrustedImm32(0x7f));
+ JumpList isAscii;
+ if (charClass->m_matches.size() || charClass->m_ranges.size())
+ isAscii.append(branch32(LessThanOrEqual, character, TrustedImm32(0x7f)));
if (charClass->m_matchesUnicode.size()) {
for (unsigned i = 0; i < charClass->m_matchesUnicode.size(); ++i) {
- UChar ch = charClass->m_matchesUnicode[i];
+ UChar32 ch = charClass->m_matchesUnicode[i];
matchDest.append(branch32(Equal, character, Imm32(ch)));
}
}
if (charClass->m_rangesUnicode.size()) {
for (unsigned i = 0; i < charClass->m_rangesUnicode.size(); ++i) {
- UChar lo = charClass->m_rangesUnicode[i].begin;
- UChar hi = charClass->m_rangesUnicode[i].end;
+ UChar32 lo = charClass->m_rangesUnicode[i].begin;
+ UChar32 hi = charClass->m_rangesUnicode[i].end;
Jump below = branch32(LessThan, character, Imm32(lo));
matchDest.append(branch32(LessThanOrEqual, character, Imm32(hi)));
@@ -216,18 +409,16 @@ class YarrGenerator : private DefaultMacroAssembler {
}
}
- unicodeFail = jump();
+ if (charClass->m_matches.size() || charClass->m_ranges.size())
+ unicodeFail = jump();
isAscii.link(this);
}
if (charClass->m_ranges.size()) {
unsigned matchIndex = 0;
JumpList failures;
- ASSERT(charClass->m_ranges.size() <= UINT_MAX);
- matchCharacterClassRange(character, failures, matchDest, &charClass->m_ranges[0],
- static_cast<unsigned>(charClass->m_ranges.size()),
- &matchIndex, charClass->m_matches.isEmpty() ? 0 : &charClass->m_matches[0],
- static_cast<unsigned>(charClass->m_matches.size()));
+ matchCharacterClassRange(character, failures, matchDest, charClass->m_ranges.data(), charClass->m_ranges.size(),
+ &matchIndex, charClass->m_matches.data(), charClass->m_matches.size());
while (matchIndex < charClass->m_matches.size())
matchDest.append(branch32(Equal, character, Imm32((unsigned short)charClass->m_matches[matchIndex++])));
@@ -238,7 +429,7 @@ class YarrGenerator : private DefaultMacroAssembler {
for (unsigned i = 0; i < charClass->m_matches.size(); ++i) {
char ch = charClass->m_matches[i];
- if (m_pattern.m_ignoreCase) {
+ if (m_pattern.ignoreCase()) {
if (isASCIILower(ch)) {
matchesAZaz.append(ch);
continue;
@@ -249,8 +440,7 @@ class YarrGenerator : private DefaultMacroAssembler {
matchDest.append(branch32(Equal, character, Imm32((unsigned short)ch)));
}
- ASSERT(matchesAZaz.size() <= UINT_MAX);
- if (unsigned countAZaz = static_cast<int>(matchesAZaz.size())) {
+ if (unsigned countAZaz = matchesAZaz.size()) {
or32(TrustedImm32(32), character);
for (unsigned i = 0; i < countAZaz; ++i)
matchDest.append(branch32(Equal, character, TrustedImm32(matchesAZaz[i])));
@@ -290,29 +480,102 @@ class YarrGenerator : private DefaultMacroAssembler {
return branch32(NotEqual, index, length);
}
- Jump jumpIfCharNotEquals(UChar ch, int inputPosition, RegisterID character)
+ BaseIndex negativeOffsetIndexedAddress(Checked<unsigned> negativeCharacterOffset, RegisterID tempReg, RegisterID indexReg = index)
{
- readCharacter(inputPosition, character);
-
- // For case-insesitive compares, non-ascii characters that have different
- // upper & lower case representations are converted to a character class.
- ASSERT(!m_pattern.m_ignoreCase || isASCIIAlpha(ch) || isCanonicallyUnique(ch));
- if (m_pattern.m_ignoreCase && isASCIIAlpha(ch)) {
- or32(TrustedImm32(0x20), character);
- ch |= 0x20;
+ RegisterID base = input;
+
+ // BaseIndex() addressing can take a int32_t offset. Given that we can have a regular
+ // expression that has unsigned character offsets, BaseIndex's signed offset is insufficient
+ // for addressing in extreme cases where we might underflow. Therefore we check to see if
+ // negativeCharacterOffset will underflow directly or after converting for 16 bit characters.
+ // If so, we do our own address calculating by adjusting the base, using the result register
+ // as a temp address register.
+ unsigned maximumNegativeOffsetForCharacterSize = m_charSize == Char8 ? 0x7fffffff : 0x3fffffff;
+ unsigned offsetAdjustAmount = 0x40000000;
+ if (negativeCharacterOffset.unsafeGet() > maximumNegativeOffsetForCharacterSize) {
+ base = tempReg;
+ move(input, base);
+ while (negativeCharacterOffset.unsafeGet() > maximumNegativeOffsetForCharacterSize) {
+ subPtr(TrustedImm32(offsetAdjustAmount), base);
+ if (m_charSize != Char8)
+ subPtr(TrustedImm32(offsetAdjustAmount), base);
+ negativeCharacterOffset -= offsetAdjustAmount;
+ }
}
- return branch32(NotEqual, character, Imm32(ch));
+ Checked<int32_t> characterOffset(-static_cast<int32_t>(negativeCharacterOffset.unsafeGet()));
+
+ if (m_charSize == Char8)
+ return BaseIndex(input, indexReg, TimesOne, (characterOffset * static_cast<int32_t>(sizeof(char))).unsafeGet());
+
+ return BaseIndex(input, indexReg, TimesTwo, (characterOffset * static_cast<int32_t>(sizeof(UChar))).unsafeGet());
+ }
+
+#ifdef JIT_UNICODE_EXPRESSIONS
+ void tryReadUnicodeCharImpl(RegisterID resultReg)
+ {
+ ASSERT(m_charSize == Char16);
+
+ JumpList notUnicode;
+ load16Unaligned(regUnicodeInputAndTrail, resultReg);
+ and32(surrogateTagMask, resultReg, regT2);
+ notUnicode.append(branch32(NotEqual, regT2, leadingSurrogateTag));
+ addPtr(TrustedImm32(2), regUnicodeInputAndTrail);
+ getEffectiveAddress(BaseIndex(input, length, TimesTwo), regT2);
+ notUnicode.append(branch32(AboveOrEqual, regUnicodeInputAndTrail, regT2));
+ load16Unaligned(Address(regUnicodeInputAndTrail), regUnicodeInputAndTrail);
+ and32(surrogateTagMask, regUnicodeInputAndTrail, regT2);
+ notUnicode.append(branch32(NotEqual, regT2, trailingSurrogateTag));
+ sub32(leadingSurrogateTag, resultReg);
+ sub32(trailingSurrogateTag, regUnicodeInputAndTrail);
+ lshift32(TrustedImm32(10), resultReg);
+ or32(regUnicodeInputAndTrail, resultReg);
+ add32(supplementaryPlanesBase, resultReg);
+ notUnicode.link(this);
+ }
+
+ void tryReadUnicodeChar(BaseIndex address, RegisterID resultReg)
+ {
+ ASSERT(m_charSize == Char16);
+
+ getEffectiveAddress(address, regUnicodeInputAndTrail);
+
+ if (resultReg == regT0)
+ m_tryReadUnicodeCharacterCalls.append(nearCall());
+ else
+ tryReadUnicodeCharImpl(resultReg);
}
+#endif
- void readCharacter(int inputPosition, RegisterID reg)
+ void readCharacter(Checked<unsigned> negativeCharacterOffset, RegisterID resultReg, RegisterID indexReg = index)
{
+ BaseIndex address = negativeOffsetIndexedAddress(negativeCharacterOffset, resultReg, indexReg);
+
if (m_charSize == Char8)
- load8(BaseIndex(input, index, TimesOne, inputPosition * sizeof(char)), reg);
+ load8(address, resultReg);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ else if (m_decodeSurrogatePairs)
+ tryReadUnicodeChar(address, resultReg);
+#endif
else
- load16(BaseIndex(input, index, TimesTwo, inputPosition * sizeof(UChar)), reg);
+ load16Unaligned(address, resultReg);
}
+ Jump jumpIfCharNotEquals(UChar32 ch, Checked<unsigned> negativeCharacterOffset, RegisterID character)
+ {
+ readCharacter(negativeCharacterOffset, character);
+
+ // For case-insesitive compares, non-ascii characters that have different
+ // upper & lower case representations are converted to a character class.
+ ASSERT(!m_pattern.ignoreCase() || isASCIIAlpha(ch) || isCanonicallyUnique(ch, m_canonicalMode));
+ if (m_pattern.ignoreCase() && isASCIIAlpha(ch)) {
+ or32(TrustedImm32(0x20), character);
+ ch |= 0x20;
+ }
+
+ return branch32(NotEqual, character, Imm32(ch));
+ }
+
void storeToFrame(RegisterID reg, unsigned frameLocation)
{
poke(reg, frameLocation);
@@ -323,9 +586,16 @@ class YarrGenerator : private DefaultMacroAssembler {
poke(imm, frameLocation);
}
+#if CPU(ARM64) || CPU(X86_64)
+ void storeToFrame(TrustedImmPtr imm, unsigned frameLocation)
+ {
+ poke(imm, frameLocation);
+ }
+#endif
+
DataLabelPtr storeToFrameWithPatch(unsigned frameLocation)
{
- return storePtrWithPatch(TrustedImmPtr(0), Address(stackPointerRegister, frameLocation * sizeof(void*)));
+ return storePtrWithPatch(TrustedImmPtr(nullptr), Address(stackPointerRegister, frameLocation * sizeof(void*)));
}
void loadFromFrame(unsigned frameLocation, RegisterID reg)
@@ -340,32 +610,82 @@ class YarrGenerator : private DefaultMacroAssembler {
unsigned alignCallFrameSizeInBytes(unsigned callFrameSize)
{
+ if (!callFrameSize)
+ return 0;
+
callFrameSize *= sizeof(void*);
if (callFrameSize / sizeof(void*) != m_pattern.m_body->m_callFrameSize)
CRASH();
- // Originally, the code was:
-// callFrameSize = (callFrameSize + 0x3f) & ~0x3f;
- // However, 64 bytes is a bit surprising. The biggest "alignment" requirement is on Aarch64, where:
- // "SP mod 16 = 0. The stack must be quad-word aligned." (IHI0055B_aapcs64.pdf)
- callFrameSize = (callFrameSize + 0xf) & ~0xf;
- if (!callFrameSize)
- CRASH();
+ callFrameSize = (callFrameSize + 0x3f) & ~0x3f;
return callFrameSize;
}
void initCallFrame()
{
- unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
- if (callFrameSize)
- subPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
+ unsigned callFrameSizeInBytes = alignCallFrameSizeInBytes(m_pattern.m_body->m_callFrameSize);
+ if (callFrameSizeInBytes) {
+#if CPU(X86_64) || CPU(ARM64)
+ if (Options::zeroStackFrame()) {
+ // We need to start from the stack pointer, because we could have spilled callee saves
+ move(stackPointerRegister, regT0);
+ subPtr(Imm32(callFrameSizeInBytes), stackPointerRegister);
+ if (callFrameSizeInBytes <= 128) {
+ for (unsigned offset = 0; offset < callFrameSizeInBytes; offset += sizeof(intptr_t))
+ storePtr(TrustedImmPtr(0), Address(regT0, -8 - offset));
+ } else {
+ Label zeroLoop = label();
+ subPtr(TrustedImm32(sizeof(intptr_t) * 2), regT0);
+#if CPU(ARM64)
+ storePair64(ARM64Registers::zr, ARM64Registers::zr, regT0);
+#else
+ storePtr(TrustedImmPtr(0), Address(regT0));
+ storePtr(TrustedImmPtr(0), Address(regT0, sizeof(intptr_t)));
+#endif
+ branchPtr(NotEqual, regT0, stackPointerRegister).linkTo(zeroLoop, this);
+ }
+ } else
+#endif
+ subPtr(Imm32(callFrameSizeInBytes), stackPointerRegister);
+
+ }
}
void removeCallFrame()
{
- unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
- if (callFrameSize)
- addPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
+ unsigned callFrameSizeInBytes = alignCallFrameSizeInBytes(m_pattern.m_body->m_callFrameSize);
+ if (callFrameSizeInBytes)
+ addPtr(Imm32(callFrameSizeInBytes), stackPointerRegister);
+ }
+
+ void generateFailReturn()
+ {
+ move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
+ move(TrustedImm32(0), returnRegister2);
+ generateReturn();
+ }
+
+ void generateJITFailReturn()
+ {
+ if (m_abortExecution.empty() && m_hitMatchLimit.empty())
+ return;
+
+ JumpList finishExiting;
+ if (!m_abortExecution.empty()) {
+ m_abortExecution.link(this);
+ move(TrustedImmPtr((void*)static_cast<size_t>(-2)), returnRegister);
+ finishExiting.append(jump());
+ }
+
+ if (!m_hitMatchLimit.empty()) {
+ m_hitMatchLimit.link(this);
+ move(TrustedImmPtr((void*)static_cast<size_t>(-1)), returnRegister);
+ }
+
+ finishExiting.link(this);
+ removeCallFrame();
+ move(TrustedImm32(0), returnRegister2);
+ generateReturn();
}
- // Used to record subpatters, should only be called if compileMode is IncludeSubpatterns.
+ // Used to record subpatterns, should only be called if compileMode is IncludeSubpatterns.
void setSubpatternStart(RegisterID reg, unsigned subpattern)
{
ASSERT(subpattern);
@@ -385,6 +705,12 @@ class YarrGenerator : private DefaultMacroAssembler {
store32(TrustedImm32(-1), Address(output, (subpattern << 1) * sizeof(int)));
}
+ void clearMatches(unsigned subpattern, unsigned lastSubpattern)
+ {
+ for (; subpattern <= lastSubpattern; subpattern++)
+ clearSubpatternStart(subpattern);
+ }
+
// We use one of three different strategies to track the start of the current match,
// while matching.
// 1) If the pattern has a fixed size, do nothing! - we calculate the value lazily
@@ -427,18 +753,21 @@ class YarrGenerator : private DefaultMacroAssembler {
OpNestedAlternativeNext,
OpNestedAlternativeEnd,
// Used for alternatives in subpatterns where there is only a single
- // alternative (backtrackingis easier in these cases), or for alternatives
+ // alternative (backtracking is easier in these cases), or for alternatives
// which never need to be backtracked (those in parenthetical assertions,
// terminal subpatterns).
OpSimpleNestedAlternativeBegin,
OpSimpleNestedAlternativeNext,
OpSimpleNestedAlternativeEnd,
- // Used to wrap 'Once' subpattern matches (quantityCount == 1).
+ // Used to wrap 'Once' subpattern matches (quantityMaxCount == 1).
OpParenthesesSubpatternOnceBegin,
OpParenthesesSubpatternOnceEnd,
// Used to wrap 'Terminal' subpattern matches (at the end of the regexp).
OpParenthesesSubpatternTerminalBegin,
OpParenthesesSubpatternTerminalEnd,
+ // Used to wrap generic captured matches
+ OpParenthesesSubpatternBegin,
+ OpParenthesesSubpatternEnd,
// Used to wrap parenthetical assertions.
OpParentheticalAssertionBegin,
OpParentheticalAssertionEnd,
@@ -468,16 +797,16 @@ class YarrGenerator : private DefaultMacroAssembler {
// The operation, as a YarrOpCode, and also a reference to the PatternTerm.
YarrOpCode m_op;
- PatternTerm* m_term = nullptr;
+ PatternTerm* m_term;
// For alternatives, this holds the PatternAlternative and doubly linked
// references to this alternative's siblings. In the case of the
// OpBodyAlternativeEnd node at the end of a section of repeating nodes,
// m_nextOp will reference the OpBodyAlternativeBegin node of the first
// repeating alternative.
- PatternAlternative* m_alternative = nullptr;
- size_t m_previousOp = 0;
- size_t m_nextOp = 0;
+ PatternAlternative* m_alternative;
+ size_t m_previousOp;
+ size_t m_nextOp;
// Used to record a set of Jumps out of the generated code, typically
// used for jumps out to backtracking code, and a single reentry back
@@ -495,9 +824,9 @@ class YarrGenerator : private DefaultMacroAssembler {
bool m_isDeadCode;
// Currently used in the case of some of the more complex management of
- // 'm_checked', to cache the offset used in this alternative, to avoid
+ // 'm_checkedOffset', to cache the offset used in this alternative, to avoid
// recalculating it.
- int m_checkAdjust;
+ Checked<unsigned> m_checkAdjust;
// Used by OpNestedAlternativeNext/End to hold the pointer to the
// value that will be pushed into the pattern's frame to return to,
@@ -599,7 +928,7 @@ class YarrGenerator : private DefaultMacroAssembler {
}
// Called at the end of code generation to link all return addresses.
- void linkDataLabels(LinkBuffer<JSC::DefaultMacroAssembler>& linkBuffer)
+ void linkDataLabels(DefaultLinkBuffer& linkBuffer)
{
ASSERT(isEmpty());
for (unsigned i = 0; i < m_backtrackRecords.size(); ++i)
@@ -642,14 +971,14 @@ class YarrGenerator : private DefaultMacroAssembler {
YarrOp& op = m_ops[opIndex];
PatternTerm* term = op.m_term;
- if (m_pattern.m_multiline) {
+ if (m_pattern.multiline()) {
const RegisterID character = regT0;
JumpList matchDest;
if (!term->inputPosition)
- matchDest.append(branch32(Equal, index, Imm32(m_checked)));
+ matchDest.append(branch32(Equal, index, Imm32(m_checkedOffset.unsafeGet())));
- readCharacter((term->inputPosition - m_checked) - 1, character);
+ readCharacter(m_checkedOffset - term->inputPosition + 1, character);
matchCharacterClass(character, matchDest, m_pattern.newlineCharacterClass());
op.m_jumps.append(jump());
@@ -659,7 +988,7 @@ class YarrGenerator : private DefaultMacroAssembler {
if (term->inputPosition)
op.m_jumps.append(jump());
else
- op.m_jumps.append(branch32(NotEqual, index, Imm32(m_checked)));
+ op.m_jumps.append(branch32(NotEqual, index, Imm32(m_checkedOffset.unsafeGet())));
}
}
void backtrackAssertionBOL(size_t opIndex)
@@ -672,20 +1001,20 @@ class YarrGenerator : private DefaultMacroAssembler {
YarrOp& op = m_ops[opIndex];
PatternTerm* term = op.m_term;
- if (m_pattern.m_multiline) {
+ if (m_pattern.multiline()) {
const RegisterID character = regT0;
JumpList matchDest;
- if (term->inputPosition == m_checked)
+ if (term->inputPosition == m_checkedOffset.unsafeGet())
matchDest.append(atEndOfInput());
- readCharacter(term->inputPosition - m_checked, character);
+ readCharacter(m_checkedOffset - term->inputPosition, character);
matchCharacterClass(character, matchDest, m_pattern.newlineCharacterClass());
op.m_jumps.append(jump());
matchDest.link(this);
} else {
- if (term->inputPosition == m_checked)
+ if (term->inputPosition == m_checkedOffset.unsafeGet())
op.m_jumps.append(notAtEndOfInput());
// Erk, really should poison out these alternatives early. :-/
else
@@ -705,11 +1034,19 @@ class YarrGenerator : private DefaultMacroAssembler {
const RegisterID character = regT0;
- if (term->inputPosition == m_checked)
+ if (term->inputPosition == m_checkedOffset.unsafeGet())
nextIsNotWordChar.append(atEndOfInput());
- readCharacter((term->inputPosition - m_checked), character);
- matchCharacterClass(character, nextIsWordChar, m_pattern.wordcharCharacterClass());
+ readCharacter(m_checkedOffset - term->inputPosition, character);
+
+ CharacterClass* wordcharCharacterClass;
+
+ if (m_unicodeIgnoreCase)
+ wordcharCharacterClass = m_pattern.wordUnicodeIgnoreCaseCharCharacterClass();
+ else
+ wordcharCharacterClass = m_pattern.wordcharCharacterClass();
+
+ matchCharacterClass(character, nextIsWordChar, wordcharCharacterClass);
}
void generateAssertionWordBoundary(size_t opIndex)
@@ -722,9 +1059,17 @@ class YarrGenerator : private DefaultMacroAssembler {
Jump atBegin;
JumpList matchDest;
if (!term->inputPosition)
- atBegin = branch32(Equal, index, Imm32(m_checked));
- readCharacter((term->inputPosition - m_checked) - 1, character);
- matchCharacterClass(character, matchDest, m_pattern.wordcharCharacterClass());
+ atBegin = branch32(Equal, index, Imm32(m_checkedOffset.unsafeGet()));
+ readCharacter(m_checkedOffset - term->inputPosition + 1, character);
+
+ CharacterClass* wordcharCharacterClass;
+
+ if (m_unicodeIgnoreCase)
+ wordcharCharacterClass = m_pattern.wordUnicodeIgnoreCaseCharCharacterClass();
+ else
+ wordcharCharacterClass = m_pattern.wordcharCharacterClass();
+
+ matchCharacterClass(character, matchDest, wordcharCharacterClass);
if (!term->inputPosition)
atBegin.link(this);
@@ -775,7 +1120,7 @@ class YarrGenerator : private DefaultMacroAssembler {
YarrOp* nextOp = &m_ops[opIndex + 1];
PatternTerm* term = op.m_term;
- UChar ch = term->patternCharacter;
+ UChar32 ch = term->patternCharacter;
if ((ch > 0xff) && (m_charSize == Char8)) {
// Have a 16 bit pattern character and an 8 bit string - short circuit
@@ -784,21 +1129,21 @@ class YarrGenerator : private DefaultMacroAssembler {
}
const RegisterID character = regT0;
- int maxCharactersAtOnce = m_charSize == Char8 ? 4 : 2;
+ unsigned maxCharactersAtOnce = m_charSize == Char8 ? 4 : 2;
unsigned ignoreCaseMask = 0;
#if CPU(BIG_ENDIAN)
int allCharacters = ch << (m_charSize == Char8 ? 24 : 16);
#else
int allCharacters = ch;
#endif
- int numberCharacters;
- int startTermPosition = term->inputPosition;
+ unsigned numberCharacters;
+ unsigned startTermPosition = term->inputPosition;
// For case-insesitive compares, non-ascii characters that have different
// upper & lower case representations are converted to a character class.
- ASSERT(!m_pattern.m_ignoreCase || isASCIIAlpha(ch) || isCanonicallyUnique(ch));
+ ASSERT(!m_pattern.ignoreCase() || isASCIIAlpha(ch) || isCanonicallyUnique(ch, m_canonicalMode));
- if (m_pattern.m_ignoreCase && isASCIIAlpha(ch))
+ if (m_pattern.ignoreCase() && isASCIIAlpha(ch))
#if CPU(BIG_ENDIAN)
ignoreCaseMask |= 32 << (m_charSize == Char8 ? 24 : 16);
#else
@@ -810,8 +1155,9 @@ class YarrGenerator : private DefaultMacroAssembler {
if (nextTerm->type != PatternTerm::TypePatternCharacter
|| nextTerm->quantityType != QuantifierFixedCount
- || nextTerm->quantityCount != 1
- || nextTerm->inputPosition != (startTermPosition + numberCharacters))
+ || nextTerm->quantityMaxCount != 1
+ || nextTerm->inputPosition != (startTermPosition + numberCharacters)
+ || (U16_LENGTH(nextTerm->patternCharacter) != 1 && m_decodeSurrogatePairs))
break;
nextOp->m_isDeadCode = true;
@@ -822,7 +1168,7 @@ class YarrGenerator : private DefaultMacroAssembler {
int shiftAmount = (m_charSize == Char8 ? 8 : 16) * numberCharacters;
#endif
- UChar currentCharacter = nextTerm->patternCharacter;
+ UChar32 currentCharacter = nextTerm->patternCharacter;
if ((currentCharacter > 0xff) && (m_charSize == Char8)) {
// Have a 16 bit pattern character and an 8 bit string - short circuit
@@ -832,47 +1178,43 @@ class YarrGenerator : private DefaultMacroAssembler {
// For case-insesitive compares, non-ascii characters that have different
// upper & lower case representations are converted to a character class.
- ASSERT(!m_pattern.m_ignoreCase || isASCIIAlpha(currentCharacter) || isCanonicallyUnique(currentCharacter));
+ ASSERT(!m_pattern.ignoreCase() || isASCIIAlpha(currentCharacter) || isCanonicallyUnique(currentCharacter, m_canonicalMode));
allCharacters |= (currentCharacter << shiftAmount);
- if ((m_pattern.m_ignoreCase) && (isASCIIAlpha(currentCharacter)))
+ if ((m_pattern.ignoreCase()) && (isASCIIAlpha(currentCharacter)))
ignoreCaseMask |= 32 << shiftAmount;
}
if (m_charSize == Char8) {
switch (numberCharacters) {
case 1:
- op.m_jumps.append(jumpIfCharNotEquals(ch, startTermPosition - m_checked, character));
+ op.m_jumps.append(jumpIfCharNotEquals(ch, m_checkedOffset - startTermPosition, character));
return;
case 2: {
- BaseIndex address(input, index, TimesOne, (startTermPosition - m_checked) * sizeof(LChar));
- load16Unaligned(address, character);
+ load16Unaligned(negativeOffsetIndexedAddress(m_checkedOffset - startTermPosition, character), character);
break;
}
case 3: {
- BaseIndex highAddress(input, index, TimesOne, (startTermPosition - m_checked) * sizeof(LChar));
- load16Unaligned(highAddress, character);
+ load16Unaligned(negativeOffsetIndexedAddress(m_checkedOffset - startTermPosition, character), character);
if (ignoreCaseMask)
or32(Imm32(ignoreCaseMask), character);
op.m_jumps.append(branch32(NotEqual, character, Imm32((allCharacters & 0xffff) | ignoreCaseMask)));
- op.m_jumps.append(jumpIfCharNotEquals(allCharacters >> 16, startTermPosition + 2 - m_checked, character));
+ op.m_jumps.append(jumpIfCharNotEquals(allCharacters >> 16, m_checkedOffset - startTermPosition - 2, character));
return;
}
case 4: {
- BaseIndex address(input, index, TimesOne, (startTermPosition - m_checked) * sizeof(LChar));
- load32WithUnalignedHalfWords(address, character);
+ load32WithUnalignedHalfWords(negativeOffsetIndexedAddress(m_checkedOffset- startTermPosition, character), character);
break;
}
}
} else {
switch (numberCharacters) {
case 1:
- op.m_jumps.append(jumpIfCharNotEquals(ch, term->inputPosition - m_checked, character));
+ op.m_jumps.append(jumpIfCharNotEquals(ch, m_checkedOffset - term->inputPosition, character));
return;
case 2:
- BaseIndex address(input, index, TimesTwo, (term->inputPosition - m_checked) * sizeof(UChar));
- load32WithUnalignedHalfWords(address, character);
+ load32WithUnalignedHalfWords(negativeOffsetIndexedAddress(m_checkedOffset- term->inputPosition, character), character);
break;
}
}
@@ -891,32 +1233,33 @@ class YarrGenerator : private DefaultMacroAssembler {
{
YarrOp& op = m_ops[opIndex];
PatternTerm* term = op.m_term;
- UChar ch = term->patternCharacter;
+ UChar32 ch = term->patternCharacter;
const RegisterID character = regT0;
const RegisterID countRegister = regT1;
move(index, countRegister);
- sub32(Imm32(term->quantityCount.unsafeGet()), countRegister);
+ Checked<unsigned> scaledMaxCount = term->quantityMaxCount;
+ scaledMaxCount *= U_IS_BMP(ch) ? 1 : 2;
+ sub32(Imm32(scaledMaxCount.unsafeGet()), countRegister);
Label loop(this);
- BaseIndex address(input, countRegister, m_charScale, (Checked<int>(term->inputPosition - m_checked + Checked<int64_t>(term->quantityCount)) * static_cast<int>(m_charSize == Char8 ? sizeof(char) : sizeof(UChar))).unsafeGet());
-
- if (m_charSize == Char8)
- load8(address, character);
- else
- load16(address, character);
-
+ readCharacter(m_checkedOffset - term->inputPosition - scaledMaxCount, character, countRegister);
// For case-insesitive compares, non-ascii characters that have different
// upper & lower case representations are converted to a character class.
- ASSERT(!m_pattern.m_ignoreCase || isASCIIAlpha(ch) || isCanonicallyUnique(ch));
- if (m_pattern.m_ignoreCase && isASCIIAlpha(ch)) {
+ ASSERT(!m_pattern.ignoreCase() || isASCIIAlpha(ch) || isCanonicallyUnique(ch, m_canonicalMode));
+ if (m_pattern.ignoreCase() && isASCIIAlpha(ch)) {
or32(TrustedImm32(0x20), character);
ch |= 0x20;
}
op.m_jumps.append(branch32(NotEqual, character, Imm32(ch)));
- add32(TrustedImm32(1), countRegister);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs && !U_IS_BMP(ch))
+ add32(TrustedImm32(2), countRegister);
+ else
+#endif
+ add32(TrustedImm32(1), countRegister);
branch32(NotEqual, countRegister, index).linkTo(loop, this);
}
void backtrackPatternCharacterFixed(size_t opIndex)
@@ -928,7 +1271,7 @@ class YarrGenerator : private DefaultMacroAssembler {
{
YarrOp& op = m_ops[opIndex];
PatternTerm* term = op.m_term;
- UChar ch = term->patternCharacter;
+ UChar32 ch = term->patternCharacter;
const RegisterID character = regT0;
const RegisterID countRegister = regT1;
@@ -940,20 +1283,30 @@ class YarrGenerator : private DefaultMacroAssembler {
JumpList failures;
Label loop(this);
failures.append(atEndOfInput());
- failures.append(jumpIfCharNotEquals(ch, term->inputPosition - m_checked, character));
+ failures.append(jumpIfCharNotEquals(ch, m_checkedOffset - term->inputPosition, character));
- add32(TrustedImm32(1), countRegister);
add32(TrustedImm32(1), index);
- if (term->quantityCount == quantifyInfinite)
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs && !U_IS_BMP(ch)) {
+ Jump surrogatePairOk = notAtEndOfInput();
+ sub32(TrustedImm32(1), index);
+ failures.append(jump());
+ surrogatePairOk.link(this);
+ add32(TrustedImm32(1), index);
+ }
+#endif
+ add32(TrustedImm32(1), countRegister);
+
+ if (term->quantityMaxCount == quantifyInfinite)
jump(loop);
else
- branch32(NotEqual, countRegister, Imm32(term->quantityCount.unsafeGet())).linkTo(loop, this);
+ branch32(NotEqual, countRegister, Imm32(term->quantityMaxCount.unsafeGet())).linkTo(loop, this);
failures.link(this);
}
op.m_reentry = label();
- storeToFrame(countRegister, term->frameLocation);
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoPatternCharacter::matchAmountIndex());
}
void backtrackPatternCharacterGreedy(size_t opIndex)
{
@@ -964,10 +1317,13 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.link(this);
- loadFromFrame(term->frameLocation, countRegister);
+ loadFromFrame(term->frameLocation + BackTrackInfoPatternCharacter::matchAmountIndex(), countRegister);
m_backtrackingState.append(branchTest32(Zero, countRegister));
sub32(TrustedImm32(1), countRegister);
- sub32(TrustedImm32(1), index);
+ if (!m_decodeSurrogatePairs || U_IS_BMP(term->patternCharacter))
+ sub32(TrustedImm32(1), index);
+ else
+ sub32(TrustedImm32(2), index);
jump(op.m_reentry);
}
@@ -980,36 +1336,50 @@ class YarrGenerator : private DefaultMacroAssembler {
move(TrustedImm32(0), countRegister);
op.m_reentry = label();
- storeToFrame(countRegister, term->frameLocation);
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoPatternCharacter::matchAmountIndex());
}
void backtrackPatternCharacterNonGreedy(size_t opIndex)
{
YarrOp& op = m_ops[opIndex];
PatternTerm* term = op.m_term;
- UChar ch = term->patternCharacter;
+ UChar32 ch = term->patternCharacter;
const RegisterID character = regT0;
const RegisterID countRegister = regT1;
m_backtrackingState.link(this);
- loadFromFrame(term->frameLocation, countRegister);
+ loadFromFrame(term->frameLocation + BackTrackInfoPatternCharacter::matchAmountIndex(), countRegister);
// Unless have a 16 bit pattern character and an 8 bit string - short circuit
if (!((ch > 0xff) && (m_charSize == Char8))) {
JumpList nonGreedyFailures;
nonGreedyFailures.append(atEndOfInput());
- if (term->quantityCount != quantifyInfinite)
- nonGreedyFailures.append(branch32(Equal, countRegister, Imm32(term->quantityCount.unsafeGet())));
- nonGreedyFailures.append(jumpIfCharNotEquals(ch, term->inputPosition - m_checked, character));
+ if (term->quantityMaxCount != quantifyInfinite)
+ nonGreedyFailures.append(branch32(Equal, countRegister, Imm32(term->quantityMaxCount.unsafeGet())));
+ nonGreedyFailures.append(jumpIfCharNotEquals(ch, m_checkedOffset - term->inputPosition, character));
- add32(TrustedImm32(1), countRegister);
add32(TrustedImm32(1), index);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs && !U_IS_BMP(ch)) {
+ Jump surrogatePairOk = notAtEndOfInput();
+ sub32(TrustedImm32(1), index);
+ nonGreedyFailures.append(jump());
+ surrogatePairOk.link(this);
+ add32(TrustedImm32(1), index);
+ }
+#endif
+ add32(TrustedImm32(1), countRegister);
jump(op.m_reentry);
nonGreedyFailures.link(this);
}
+ if (m_decodeSurrogatePairs && !U_IS_BMP(ch)) {
+ // subtract countRegister*2 for non-BMP characters
+ lshift32(TrustedImm32(1), countRegister);
+ }
+
sub32(countRegister, index);
m_backtrackingState.fallthrough();
}
@@ -1021,19 +1391,43 @@ class YarrGenerator : private DefaultMacroAssembler {
const RegisterID character = regT0;
+ if (m_decodeSurrogatePairs)
+ storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
+
JumpList matchDest;
- readCharacter(term->inputPosition - m_checked, character);
- matchCharacterClass(character, matchDest, term->characterClass);
+ readCharacter(m_checkedOffset - term->inputPosition, character);
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
+ if (term->invert() || !term->characterClass->m_anyCharacter) {
+ matchCharacterClass(character, matchDest, term->characterClass);
- if (term->invert())
- op.m_jumps.append(matchDest);
- else {
- op.m_jumps.append(jump());
- matchDest.link(this);
+ if (term->invert())
+ op.m_jumps.append(matchDest);
+ else {
+ op.m_jumps.append(jump());
+ matchDest.link(this);
+ }
}
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
+#endif
}
void backtrackCharacterClassOnce(size_t opIndex)
{
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ YarrOp& op = m_ops[opIndex];
+ PatternTerm* term = op.m_term;
+
+ m_backtrackingState.link(this);
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
+ m_backtrackingState.fallthrough();
+ }
+#endif
backtrackTermDefault(opIndex);
}
@@ -1046,24 +1440,34 @@ class YarrGenerator : private DefaultMacroAssembler {
const RegisterID countRegister = regT1;
move(index, countRegister);
- sub32(Imm32(term->quantityCount.unsafeGet()), countRegister);
+ sub32(Imm32(term->quantityMaxCount.unsafeGet()), countRegister);
Label loop(this);
JumpList matchDest;
- if (m_charSize == Char8)
- load8(BaseIndex(input, countRegister, TimesOne, (Checked<int>(term->inputPosition - m_checked + Checked<int64_t>(term->quantityCount)) * static_cast<int>(sizeof(char))).unsafeGet()), character);
- else
- load16(BaseIndex(input, countRegister, TimesTwo, (Checked<int>(term->inputPosition - m_checked + Checked<int64_t>(term->quantityCount)) * static_cast<int>(sizeof(UChar))).unsafeGet()), character);
- matchCharacterClass(character, matchDest, term->characterClass);
+ readCharacter(m_checkedOffset - term->inputPosition - term->quantityMaxCount, character, countRegister);
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
+ if (term->invert() || !term->characterClass->m_anyCharacter) {
+ matchCharacterClass(character, matchDest, term->characterClass);
- if (term->invert())
- op.m_jumps.append(matchDest);
- else {
- op.m_jumps.append(jump());
- matchDest.link(this);
+ if (term->invert())
+ op.m_jumps.append(matchDest);
+ else {
+ op.m_jumps.append(jump());
+ matchDest.link(this);
+ }
}
add32(TrustedImm32(1), countRegister);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ op.m_jumps.append(atEndOfInput());
+ add32(TrustedImm32(1), countRegister);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
+#endif
branch32(NotEqual, countRegister, index).linkTo(loop, this);
}
void backtrackCharacterClassFixed(size_t opIndex)
@@ -1079,6 +1483,8 @@ class YarrGenerator : private DefaultMacroAssembler {
const RegisterID character = regT0;
const RegisterID countRegister = regT1;
+ if (m_decodeSurrogatePairs)
+ storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
move(TrustedImm32(0), countRegister);
JumpList failures;
@@ -1086,20 +1492,33 @@ class YarrGenerator : private DefaultMacroAssembler {
failures.append(atEndOfInput());
if (term->invert()) {
- readCharacter(term->inputPosition - m_checked, character);
+ readCharacter(m_checkedOffset - term->inputPosition, character);
matchCharacterClass(character, failures, term->characterClass);
} else {
JumpList matchDest;
- readCharacter(term->inputPosition - m_checked, character);
- matchCharacterClass(character, matchDest, term->characterClass);
- failures.append(jump());
+ readCharacter(m_checkedOffset - term->inputPosition, character);
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
+ if (!term->characterClass->m_anyCharacter) {
+ matchCharacterClass(character, matchDest, term->characterClass);
+ failures.append(jump());
+ }
matchDest.link(this);
}
- add32(TrustedImm32(1), countRegister);
add32(TrustedImm32(1), index);
- if (term->quantityCount != quantifyInfinite) {
- branch32(NotEqual, countRegister, Imm32(term->quantityCount.unsafeGet())).linkTo(loop, this);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ failures.append(atEndOfInput());
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
+#endif
+ add32(TrustedImm32(1), countRegister);
+
+ if (term->quantityMaxCount != quantifyInfinite) {
+ branch32(NotEqual, countRegister, Imm32(term->quantityMaxCount.unsafeGet())).linkTo(loop, this);
failures.append(jump());
} else
jump(loop);
@@ -1107,7 +1526,7 @@ class YarrGenerator : private DefaultMacroAssembler {
failures.link(this);
op.m_reentry = label();
- storeToFrame(countRegister, term->frameLocation);
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
}
void backtrackCharacterClassGreedy(size_t opIndex)
{
@@ -1118,10 +1537,34 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.link(this);
- loadFromFrame(term->frameLocation, countRegister);
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
m_backtrackingState.append(branchTest32(Zero, countRegister));
sub32(TrustedImm32(1), countRegister);
- sub32(TrustedImm32(1), index);
+ if (!m_decodeSurrogatePairs)
+ sub32(TrustedImm32(1), index);
+ else {
+ const RegisterID character = regT0;
+
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
+ // Rematch one less
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
+
+ Label rematchLoop(this);
+ readCharacter(m_checkedOffset - term->inputPosition, character);
+
+ sub32(TrustedImm32(1), countRegister);
+ add32(TrustedImm32(1), index);
+
+#ifdef JIT_UNICODE_EXPRESSIONS
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+#endif
+
+ branchTest32(Zero, countRegister).linkTo(rematchLoop, this);
+
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
+ }
jump(op.m_reentry);
}
@@ -1134,8 +1577,11 @@ class YarrGenerator : private DefaultMacroAssembler {
move(TrustedImm32(0), countRegister);
op.m_reentry = label();
- storeToFrame(countRegister, term->frameLocation);
+ if (m_decodeSurrogatePairs)
+ storeToFrame(index, term->frameLocation + BackTrackInfoCharacterClass::beginIndex());
+ storeToFrame(countRegister, term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex());
}
+
void backtrackCharacterClassNonGreedy(size_t opIndex)
{
YarrOp& op = m_ops[opIndex];
@@ -1148,24 +1594,38 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.link(this);
- loadFromFrame(term->frameLocation, countRegister);
+ if (m_decodeSurrogatePairs)
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::beginIndex(), index);
+ loadFromFrame(term->frameLocation + BackTrackInfoCharacterClass::matchAmountIndex(), countRegister);
nonGreedyFailures.append(atEndOfInput());
- nonGreedyFailures.append(branch32(Equal, countRegister, Imm32(term->quantityCount.unsafeGet())));
+ nonGreedyFailures.append(branch32(Equal, countRegister, Imm32(term->quantityMaxCount.unsafeGet())));
JumpList matchDest;
- readCharacter(term->inputPosition - m_checked, character);
- matchCharacterClass(character, matchDest, term->characterClass);
+ readCharacter(m_checkedOffset - term->inputPosition, character);
+ // If we are matching the "any character" builtin class we only need to read the
+ // character and don't need to match as it will always succeed.
+ if (term->invert() || !term->characterClass->m_anyCharacter) {
+ matchCharacterClass(character, matchDest, term->characterClass);
- if (term->invert())
- nonGreedyFailures.append(matchDest);
- else {
- nonGreedyFailures.append(jump());
- matchDest.link(this);
+ if (term->invert())
+ nonGreedyFailures.append(matchDest);
+ else {
+ nonGreedyFailures.append(jump());
+ matchDest.link(this);
+ }
}
- add32(TrustedImm32(1), countRegister);
add32(TrustedImm32(1), index);
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ nonGreedyFailures.append(atEndOfInput());
+ Jump isBMPChar = branch32(LessThan, character, supplementaryPlanesBase);
+ add32(TrustedImm32(1), index);
+ isBMPChar.link(this);
+ }
+#endif
+ add32(TrustedImm32(1), countRegister);
jump(op.m_reentry);
@@ -1181,15 +1641,28 @@ class YarrGenerator : private DefaultMacroAssembler {
const RegisterID character = regT0;
const RegisterID matchPos = regT1;
+#ifndef HAVE_INITIAL_START_REG
+ const RegisterID initialStart = character;
+#endif
JumpList foundBeginningNewLine;
JumpList saveStartIndex;
JumpList foundEndingNewLine;
+ if (m_pattern.dotAll()) {
+ move(TrustedImm32(0), matchPos);
+ setMatchStart(matchPos);
+ move(length, index);
+ return;
+ }
+
ASSERT(!m_pattern.m_body->m_hasFixedSize);
getMatchStart(matchPos);
- saveStartIndex.append(branchTest32(Zero, matchPos));
+#ifndef HAVE_INITIAL_START_REG
+ loadFromFrame(m_pattern.m_initialStartValueFrameLocation, initialStart);
+#endif
+ saveStartIndex.append(branch32(BelowOrEqual, matchPos, initialStart));
Label findBOLLoop(this);
sub32(TrustedImm32(1), matchPos);
if (m_charSize == Char8)
@@ -1197,14 +1670,18 @@ class YarrGenerator : private DefaultMacroAssembler {
else
load16(BaseIndex(input, matchPos, TimesTwo, 0), character);
matchCharacterClass(character, foundBeginningNewLine, m_pattern.newlineCharacterClass());
- branchTest32(NonZero, matchPos).linkTo(findBOLLoop, this);
+
+#ifndef HAVE_INITIAL_START_REG
+ loadFromFrame(m_pattern.m_initialStartValueFrameLocation, initialStart);
+#endif
+ branch32(Above, matchPos, initialStart).linkTo(findBOLLoop, this);
saveStartIndex.append(jump());
foundBeginningNewLine.link(this);
add32(TrustedImm32(1), matchPos); // Advance past newline
saveStartIndex.link(this);
- if (!m_pattern.m_multiline && term->anchors.bolAnchor)
+ if (!m_pattern.multiline() && term->anchors.bolAnchor)
op.m_jumps.append(branchTest32(NonZero, matchPos));
ASSERT(!m_pattern.m_body->m_hasFixedSize);
@@ -1224,7 +1701,7 @@ class YarrGenerator : private DefaultMacroAssembler {
foundEndingNewLine.link(this);
- if (!m_pattern.m_multiline && term->anchors.eolAnchor)
+ if (!m_pattern.multiline() && term->anchors.eolAnchor)
op.m_jumps.append(branch32(NotEqual, matchPos, length));
move(matchPos, index);
@@ -1247,7 +1724,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case PatternTerm::TypePatternCharacter:
switch (term->quantityType) {
case QuantifierFixedCount:
- if (term->quantityCount == 1)
+ if (term->quantityMaxCount == 1)
generatePatternCharacterOnce(opIndex);
else
generatePatternCharacterFixed(opIndex);
@@ -1264,7 +1741,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case PatternTerm::TypeCharacterClass:
switch (term->quantityType) {
case QuantifierFixedCount:
- if (term->quantityCount == 1)
+ if (term->quantityMaxCount == 1)
generateCharacterClassOnce(opIndex);
else
generateCharacterClassFixed(opIndex);
@@ -1297,7 +1774,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case PatternTerm::TypeParentheticalAssertion:
RELEASE_ASSERT_NOT_REACHED();
case PatternTerm::TypeBackReference:
- m_shouldFallBack = true;
+ m_failureReason = JITFailureReason::BackReference;
break;
case PatternTerm::TypeDotStarEnclosure:
generateDotStarEnclosure(opIndex);
@@ -1313,7 +1790,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case PatternTerm::TypePatternCharacter:
switch (term->quantityType) {
case QuantifierFixedCount:
- if (term->quantityCount == 1)
+ if (term->quantityMaxCount == 1)
backtrackPatternCharacterOnce(opIndex);
else
backtrackPatternCharacterFixed(opIndex);
@@ -1330,7 +1807,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case PatternTerm::TypeCharacterClass:
switch (term->quantityType) {
case QuantifierFixedCount:
- if (term->quantityCount == 1)
+ if (term->quantityMaxCount == 1)
backtrackCharacterClassOnce(opIndex);
else
backtrackCharacterClassFixed(opIndex);
@@ -1368,7 +1845,7 @@ class YarrGenerator : private DefaultMacroAssembler {
break;
case PatternTerm::TypeBackReference:
- m_shouldFallBack = true;
+ m_failureReason = JITFailureReason::BackReference;
break;
}
}
@@ -1419,7 +1896,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// set as appropriate to this alternative.
op.m_reentry = label();
- m_checked += alternative->m_minimumSize;
+ m_checkedOffset += alternative->m_minimumSize;
break;
}
case OpBodyAlternativeNext:
@@ -1472,8 +1949,8 @@ class YarrGenerator : private DefaultMacroAssembler {
}
if (op.m_op == OpBodyAlternativeNext)
- m_checked += alternative->m_minimumSize;
- m_checked -= priorAlternative->m_minimumSize;
+ m_checkedOffset += alternative->m_minimumSize;
+ m_checkedOffset -= priorAlternative->m_minimumSize;
break;
}
@@ -1500,13 +1977,13 @@ class YarrGenerator : private DefaultMacroAssembler {
PatternDisjunction* disjunction = term->parentheses.disjunction;
// Calculate how much input we need to check for, and if non-zero check.
- op.m_checkAdjust = alternative->m_minimumSize;
+ op.m_checkAdjust = Checked<unsigned>(alternative->m_minimumSize);
if ((term->quantityType == QuantifierFixedCount) && (term->type != PatternTerm::TypeParentheticalAssertion))
op.m_checkAdjust -= disjunction->m_minimumSize;
if (op.m_checkAdjust)
- op.m_jumps.append(jumpIfNoAvailableInput(op.m_checkAdjust));
+ op.m_jumps.append(jumpIfNoAvailableInput(op.m_checkAdjust.unsafeGet()));
- m_checked += op.m_checkAdjust;
+ m_checkedOffset += op.m_checkAdjust;
break;
}
case OpSimpleNestedAlternativeNext:
@@ -1518,10 +1995,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// In the non-simple case, store a 'return address' so we can backtrack correctly.
if (op.m_op == OpNestedAlternativeNext) {
unsigned parenthesesFrameLocation = term->frameLocation;
- unsigned alternativeFrameLocation = parenthesesFrameLocation;
- if (term->quantityType != QuantifierFixedCount)
- alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
- op.m_returnAddress = storeToFrameWithPatch(alternativeFrameLocation);
+ op.m_returnAddress = storeToFrameWithPatch(parenthesesFrameLocation + BackTrackInfoParentheses::returnAddressIndex());
}
if (term->quantityType != QuantifierFixedCount && !m_ops[op.m_previousOp].m_alternative->m_minimumSize) {
@@ -1554,11 +2028,11 @@ class YarrGenerator : private DefaultMacroAssembler {
if ((term->quantityType == QuantifierFixedCount) && (term->type != PatternTerm::TypeParentheticalAssertion))
op.m_checkAdjust -= disjunction->m_minimumSize;
if (op.m_checkAdjust)
- op.m_jumps.append(jumpIfNoAvailableInput(op.m_checkAdjust));
+ op.m_jumps.append(jumpIfNoAvailableInput(op.m_checkAdjust.unsafeGet()));
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked -= lastOp.m_checkAdjust;
- m_checked += op.m_checkAdjust;
+ m_checkedOffset -= lastOp.m_checkAdjust;
+ m_checkedOffset += op.m_checkAdjust;
break;
}
case OpSimpleNestedAlternativeEnd:
@@ -1568,10 +2042,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// In the non-simple case, store a 'return address' so we can backtrack correctly.
if (op.m_op == OpNestedAlternativeEnd) {
unsigned parenthesesFrameLocation = term->frameLocation;
- unsigned alternativeFrameLocation = parenthesesFrameLocation;
- if (term->quantityType != QuantifierFixedCount)
- alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
- op.m_returnAddress = storeToFrameWithPatch(alternativeFrameLocation);
+ op.m_returnAddress = storeToFrameWithPatch(parenthesesFrameLocation + BackTrackInfoParentheses::returnAddressIndex());
}
if (term->quantityType != QuantifierFixedCount && !m_ops[op.m_previousOp].m_alternative->m_minimumSize) {
@@ -1587,7 +2058,7 @@ class YarrGenerator : private DefaultMacroAssembler {
op.m_jumps.clear();
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked -= lastOp.m_checkAdjust;
+ m_checkedOffset -= lastOp.m_checkAdjust;
break;
}
@@ -1599,7 +2070,7 @@ class YarrGenerator : private DefaultMacroAssembler {
PatternTerm* term = op.m_term;
unsigned parenthesesFrameLocation = term->frameLocation;
const RegisterID indexTemporary = regT0;
- ASSERT(term->quantityCount == 1);
+ ASSERT(term->quantityMaxCount == 1);
// Upon entry to a Greedy quantified set of parenthese store the index.
// We'll use this for two purposes:
@@ -1616,12 +2087,12 @@ class YarrGenerator : private DefaultMacroAssembler {
//
// FIXME: for capturing parens, could use the index in the capture array?
if (term->quantityType == QuantifierGreedy)
- storeToFrame(index, parenthesesFrameLocation);
+ storeToFrame(index, parenthesesFrameLocation + BackTrackInfoParenthesesOnce::beginIndex());
else if (term->quantityType == QuantifierNonGreedy) {
- storeToFrame(TrustedImm32(-1), parenthesesFrameLocation);
+ storeToFrame(TrustedImm32(-1), parenthesesFrameLocation + BackTrackInfoParenthesesOnce::beginIndex());
op.m_jumps.append(jump());
op.m_reentry = label();
- storeToFrame(index, parenthesesFrameLocation);
+ storeToFrame(index, parenthesesFrameLocation + BackTrackInfoParenthesesOnce::beginIndex());
}
// If the parenthese are capturing, store the starting index value to the
@@ -1631,12 +2102,12 @@ class YarrGenerator : private DefaultMacroAssembler {
// offsets only afterwards, at the point the results array is
// being accessed.
if (term->capture() && compileMode == IncludeSubpatterns) {
- int inputOffset = term->inputPosition - m_checked;
+ unsigned inputOffset = (m_checkedOffset - term->inputPosition).unsafeGet();
if (term->quantityType == QuantifierFixedCount)
- inputOffset -= term->parentheses.disjunction->m_minimumSize;
+ inputOffset += term->parentheses.disjunction->m_minimumSize;
if (inputOffset) {
move(index, indexTemporary);
- add32(Imm32(inputOffset), indexTemporary);
+ sub32(Imm32(inputOffset), indexTemporary);
setSubpatternStart(indexTemporary, term->parentheses.subpatternId);
} else
setSubpatternStart(index, term->parentheses.subpatternId);
@@ -1646,18 +2117,16 @@ class YarrGenerator : private DefaultMacroAssembler {
case OpParenthesesSubpatternOnceEnd: {
PatternTerm* term = op.m_term;
const RegisterID indexTemporary = regT0;
- ASSERT(term->quantityCount == 1);
+ ASSERT(term->quantityMaxCount == 1);
-#ifndef NDEBUG
// Runtime ASSERT to make sure that the nested alternative handled the
// "no input consumed" check.
- if (term->quantityType != QuantifierFixedCount && !term->parentheses.disjunction->m_minimumSize) {
+ if (!ASSERT_DISABLED && term->quantityType != QuantifierFixedCount && !term->parentheses.disjunction->m_minimumSize) {
Jump pastBreakpoint;
pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
- breakpoint();
+ // ### abortWithReason(YARRNoInputConsumed);
pastBreakpoint.link(this);
}
-#endif
// If the parenthese are capturing, store the ending index value to the
// captures array, offsetting as necessary.
@@ -1666,10 +2135,10 @@ class YarrGenerator : private DefaultMacroAssembler {
// offsets only afterwards, at the point the results array is
// being accessed.
if (term->capture() && compileMode == IncludeSubpatterns) {
- int inputOffset = term->inputPosition - m_checked;
+ unsigned inputOffset = (m_checkedOffset - term->inputPosition).unsafeGet();
if (inputOffset) {
move(index, indexTemporary);
- add32(Imm32(inputOffset), indexTemporary);
+ sub32(Imm32(inputOffset), indexTemporary);
setSubpatternEnd(indexTemporary, term->parentheses.subpatternId);
} else
setSubpatternEnd(index, term->parentheses.subpatternId);
@@ -1691,7 +2160,7 @@ class YarrGenerator : private DefaultMacroAssembler {
case OpParenthesesSubpatternTerminalBegin: {
PatternTerm* term = op.m_term;
ASSERT(term->quantityType == QuantifierGreedy);
- ASSERT(term->quantityCount == quantifyInfinite);
+ ASSERT(term->quantityMaxCount == quantifyInfinite);
ASSERT(!term->capture());
// Upon entry set a label to loop back to.
@@ -1699,23 +2168,23 @@ class YarrGenerator : private DefaultMacroAssembler {
// Store the start index of the current match; we need to reject zero
// length matches.
- storeToFrame(index, term->frameLocation);
+ storeToFrame(index, term->frameLocation + BackTrackInfoParenthesesTerminal::beginIndex());
break;
}
case OpParenthesesSubpatternTerminalEnd: {
YarrOp& beginOp = m_ops[op.m_previousOp];
-#ifndef NDEBUG
- PatternTerm* term = op.m_term;
-
- // Runtime ASSERT to make sure that the nested alternative handled the
- // "no input consumed" check.
- Jump pastBreakpoint;
- pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
- breakpoint();
- pastBreakpoint.link(this);
-#endif
+ if (!ASSERT_DISABLED) {
+ PatternTerm* term = op.m_term;
+
+ // Runtime ASSERT to make sure that the nested alternative handled the
+ // "no input consumed" check.
+ Jump pastBreakpoint;
+ pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, term->frameLocation * sizeof(void*)));
+ // ### abortWithReason(YARRNoInputConsumed);
+ pastBreakpoint.link(this);
+ }
- // We know that the match is non-zero, we can accept it and
+ // We know that the match is non-zero, we can accept it and
// loop back up to the head of the subpattern.
jump(beginOp.m_reentry);
@@ -1725,6 +2194,131 @@ class YarrGenerator : private DefaultMacroAssembler {
break;
}
+ // OpParenthesesSubpatternBegin/End
+ //
+ // These nodes support generic subpatterns.
+ case OpParenthesesSubpatternBegin: {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ PatternTerm* term = op.m_term;
+ unsigned parenthesesFrameLocation = term->frameLocation;
+
+ // Upon entry to a Greedy quantified set of parenthese store the index.
+ // We'll use this for two purposes:
+ // - To indicate which iteration we are on of mathing the remainder of
+ // the expression after the parentheses - the first, including the
+ // match within the parentheses, or the second having skipped over them.
+ // - To check for empty matches, which must be rejected.
+ //
+ // At the head of a NonGreedy set of parentheses we'll immediately set the
+ // value on the stack to -1 (indicating a match skipping the subpattern),
+ // and plant a jump to the end. We'll also plant a label to backtrack to
+ // to reenter the subpattern later, with a store to set up index on the
+ // second iteration.
+ //
+ // FIXME: for capturing parens, could use the index in the capture array?
+ if (term->quantityType == QuantifierGreedy || term->quantityType == QuantifierNonGreedy) {
+ storeToFrame(TrustedImm32(0), parenthesesFrameLocation + BackTrackInfoParentheses::matchAmountIndex());
+ storeToFrame(TrustedImmPtr(nullptr), parenthesesFrameLocation + BackTrackInfoParentheses::parenContextHeadIndex());
+
+ if (term->quantityType == QuantifierNonGreedy) {
+ storeToFrame(TrustedImm32(-1), parenthesesFrameLocation + BackTrackInfoParentheses::beginIndex());
+ op.m_jumps.append(jump());
+ }
+
+ op.m_reentry = label();
+ RegisterID currParenContextReg = regT0;
+ RegisterID newParenContextReg = regT1;
+
+ loadFromFrame(parenthesesFrameLocation + BackTrackInfoParentheses::parenContextHeadIndex(), currParenContextReg);
+ allocateParenContext(newParenContextReg);
+ storePtr(currParenContextReg, newParenContextReg);
+ storeToFrame(newParenContextReg, parenthesesFrameLocation + BackTrackInfoParentheses::parenContextHeadIndex());
+ saveParenContext(newParenContextReg, regT2, term->parentheses.subpatternId, term->parentheses.lastSubpatternId, parenthesesFrameLocation);
+ storeToFrame(index, parenthesesFrameLocation + BackTrackInfoParentheses::beginIndex());
+ }
+
+ // If the parenthese are capturing, store the starting index value to the
+ // captures array, offsetting as necessary.
+ //
+ // FIXME: could avoid offsetting this value in JIT code, apply
+ // offsets only afterwards, at the point the results array is
+ // being accessed.
+ if (term->capture() && compileMode == IncludeSubpatterns) {
+ const RegisterID indexTemporary = regT0;
+ unsigned inputOffset = (m_checkedOffset - term->inputPosition).unsafeGet();
+ if (term->quantityType == QuantifierFixedCount)
+ inputOffset += term->parentheses.disjunction->m_minimumSize;
+ if (inputOffset) {
+ move(index, indexTemporary);
+ sub32(Imm32(inputOffset), indexTemporary);
+ setSubpatternStart(indexTemporary, term->parentheses.subpatternId);
+ } else
+ setSubpatternStart(index, term->parentheses.subpatternId);
+ }
+#else // !YARR_JIT_ALL_PARENS_EXPRESSIONS
+ RELEASE_ASSERT_NOT_REACHED();
+#endif
+ break;
+ }
+ case OpParenthesesSubpatternEnd: {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ PatternTerm* term = op.m_term;
+ unsigned parenthesesFrameLocation = term->frameLocation;
+
+ // Runtime ASSERT to make sure that the nested alternative handled the
+ // "no input consumed" check.
+ if (!ASSERT_DISABLED && term->quantityType != QuantifierFixedCount && !term->parentheses.disjunction->m_minimumSize) {
+ Jump pastBreakpoint;
+ pastBreakpoint = branch32(NotEqual, index, Address(stackPointerRegister, parenthesesFrameLocation * sizeof(void*)));
+ // ### abortWithReason(YARRNoInputConsumed);
+ pastBreakpoint.link(this);
+ }
+
+ const RegisterID countTemporary = regT1;
+
+ YarrOp& beginOp = m_ops[op.m_previousOp];
+ loadFromFrame(parenthesesFrameLocation + BackTrackInfoParentheses::matchAmountIndex(), countTemporary);
+ add32(TrustedImm32(1), countTemporary);
+ storeToFrame(countTemporary, parenthesesFrameLocation + BackTrackInfoParentheses::matchAmountIndex());
+
+ // If the parenthese are capturing, store the ending index value to the
+ // captures array, offsetting as necessary.
+ //
+ // FIXME: could avoid offsetting this value in JIT code, apply
+ // offsets only afterwards, at the point the results array is
+ // being accessed.
+ if (term->capture() && compileMode == IncludeSubpatterns) {
+ const RegisterID indexTemporary = regT0;
+
+ unsigned inputOffset = (m_checkedOffset - term->inputPosition).unsafeGet();
+ if (inputOffset) {
+ move(index, indexTemporary);
+ sub32(Imm32(inputOffset), indexTemporary);
+ setSubpatternEnd(indexTemporary, term->parentheses.subpatternId);
+ } else
+ setSubpatternEnd(index, term->parentheses.subpatternId);
+ }
+
+ // If the parentheses are quantified Greedy then add a label to jump back
+ // to if get a failed match from after the parentheses. For NonGreedy
+ // parentheses, link the jump from before the subpattern to here.
+ if (term->quantityType == QuantifierGreedy) {
+ if (term->quantityMaxCount != quantifyInfinite)
+ branch32(Below, countTemporary, Imm32(term->quantityMaxCount.unsafeGet())).linkTo(beginOp.m_reentry, this);
+ else
+ jump(beginOp.m_reentry);
+
+ op.m_reentry = label();
+ } else if (term->quantityType == QuantifierNonGreedy) {
+ YarrOp& beginOp = m_ops[op.m_previousOp];
+ beginOp.m_jumps.link(this);
+ }
+#else // !YARR_JIT_ALL_PARENS_EXPRESSIONS
+ RELEASE_ASSERT_NOT_REACHED();
+#endif
+ break;
+ }
+
// OpParentheticalAssertionBegin/End
case OpParentheticalAssertionBegin: {
PatternTerm* term = op.m_term;
@@ -1732,14 +2326,14 @@ class YarrGenerator : private DefaultMacroAssembler {
// Store the current index - assertions should not update index, so
// we will need to restore it upon a successful match.
unsigned parenthesesFrameLocation = term->frameLocation;
- storeToFrame(index, parenthesesFrameLocation);
+ storeToFrame(index, parenthesesFrameLocation + BackTrackInfoParentheticalAssertion::beginIndex());
// Check
- op.m_checkAdjust = m_checked - term->inputPosition;
+ op.m_checkAdjust = m_checkedOffset - term->inputPosition;
if (op.m_checkAdjust)
- sub32(Imm32(op.m_checkAdjust), index);
+ sub32(Imm32(op.m_checkAdjust.unsafeGet()), index);
- m_checked -= op.m_checkAdjust;
+ m_checkedOffset -= op.m_checkAdjust;
break;
}
case OpParentheticalAssertionEnd: {
@@ -1747,7 +2341,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// Restore the input index value.
unsigned parenthesesFrameLocation = term->frameLocation;
- loadFromFrame(parenthesesFrameLocation, index);
+ loadFromFrame(parenthesesFrameLocation + BackTrackInfoParentheticalAssertion::beginIndex(), index);
// If inverted, a successful match of the assertion must be treated
// as a failure, so jump to backtracking.
@@ -1757,15 +2351,13 @@ class YarrGenerator : private DefaultMacroAssembler {
}
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked += lastOp.m_checkAdjust;
+ m_checkedOffset += lastOp.m_checkAdjust;
break;
}
case OpMatchFailed:
removeCallFrame();
- move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
- move(TrustedImm32(0), returnRegister2);
- generateReturn();
+ generateFailReturn();
break;
}
@@ -1817,9 +2409,9 @@ class YarrGenerator : private DefaultMacroAssembler {
if (op.m_op == OpBodyAlternativeNext) {
PatternAlternative* priorAlternative = m_ops[op.m_previousOp].m_alternative;
- m_checked += priorAlternative->m_minimumSize;
+ m_checkedOffset += priorAlternative->m_minimumSize;
}
- m_checked -= alternative->m_minimumSize;
+ m_checkedOffset -= alternative->m_minimumSize;
// Is this the last alternative? If not, then if we backtrack to this point we just
// need to jump to try to match the next alternative.
@@ -1836,6 +2428,8 @@ class YarrGenerator : private DefaultMacroAssembler {
}
bool onceThrough = endOp.m_nextOp == notFound;
+
+ JumpList lastStickyAlternativeFailures;
// First, generate code to handle cases where we backtrack out of an attempted match
// of the last alternative. If this is a 'once through' set of alternatives then we
@@ -1851,43 +2445,49 @@ class YarrGenerator : private DefaultMacroAssembler {
&& (alternative->m_minimumSize > beginOp->m_alternative->m_minimumSize)
&& (alternative->m_minimumSize - beginOp->m_alternative->m_minimumSize == 1))
m_backtrackingState.linkTo(beginOp->m_reentry, this);
- else {
+ else if (m_pattern.sticky() && m_ops[op.m_nextOp].m_op == OpBodyAlternativeEnd) {
+ // It is a sticky pattern and the last alternative failed, jump to the end.
+ m_backtrackingState.takeBacktracksToJumpList(lastStickyAlternativeFailures, this);
+ } else {
// We need to generate a trampoline of code to execute before looping back
// around to the first alternative.
m_backtrackingState.link(this);
- // If the pattern size is not fixed, then store the start index, for use if we match.
- if (!m_pattern.m_body->m_hasFixedSize) {
- if (alternative->m_minimumSize == 1)
- setMatchStart(index);
- else {
- move(index, regT0);
- if (alternative->m_minimumSize)
- sub32(Imm32(alternative->m_minimumSize - 1), regT0);
- else
- add32(TrustedImm32(1), regT0);
- setMatchStart(regT0);
+ // No need to advance and retry for a sticky pattern.
+ if (!m_pattern.sticky()) {
+ // If the pattern size is not fixed, then store the start index for use if we match.
+ if (!m_pattern.m_body->m_hasFixedSize) {
+ if (alternative->m_minimumSize == 1)
+ setMatchStart(index);
+ else {
+ move(index, regT0);
+ if (alternative->m_minimumSize)
+ sub32(Imm32(alternative->m_minimumSize - 1), regT0);
+ else
+ add32(TrustedImm32(1), regT0);
+ setMatchStart(regT0);
+ }
}
- }
- // Generate code to loop. Check whether the last alternative is longer than the
- // first (e.g. /a|xy/ or /a|xyz/).
- if (alternative->m_minimumSize > beginOp->m_alternative->m_minimumSize) {
- // We want to loop, and increment input position. If the delta is 1, it is
- // already correctly incremented, if more than one then decrement as appropriate.
- unsigned delta = alternative->m_minimumSize - beginOp->m_alternative->m_minimumSize;
- ASSERT(delta);
- if (delta != 1)
- sub32(Imm32(delta - 1), index);
- jump(beginOp->m_reentry);
- } else {
- // If the first alternative has minimum size 0xFFFFFFFFu, then there cannot
- // be sufficent input available to handle this, so just fall through.
- unsigned delta = beginOp->m_alternative->m_minimumSize - alternative->m_minimumSize;
- if (delta != 0xFFFFFFFFu) {
- // We need to check input because we are incrementing the input.
- add32(Imm32(delta + 1), index);
- checkInput().linkTo(beginOp->m_reentry, this);
+ // Generate code to loop. Check whether the last alternative is longer than the
+ // first (e.g. /a|xy/ or /a|xyz/).
+ if (alternative->m_minimumSize > beginOp->m_alternative->m_minimumSize) {
+ // We want to loop, and increment input position. If the delta is 1, it is
+ // already correctly incremented, if more than one then decrement as appropriate.
+ unsigned delta = alternative->m_minimumSize - beginOp->m_alternative->m_minimumSize;
+ ASSERT(delta);
+ if (delta != 1)
+ sub32(Imm32(delta - 1), index);
+ jump(beginOp->m_reentry);
+ } else {
+ // If the first alternative has minimum size 0xFFFFFFFFu, then there cannot
+ // be sufficent input available to handle this, so just fall through.
+ unsigned delta = beginOp->m_alternative->m_minimumSize - alternative->m_minimumSize;
+ if (delta != 0xFFFFFFFFu) {
+ // We need to check input because we are incrementing the input.
+ add32(Imm32(delta + 1), index);
+ checkInput().linkTo(beginOp->m_reentry, this);
+ }
}
}
}
@@ -1896,7 +2496,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// We can reach this point in the code in two ways:
// - Fallthrough from the code above (a repeating alternative backtracked out of its
// last alternative, and did not have sufficent input to run the first).
- // - We will loop back up to the following label when a releating alternative loops,
+ // - We will loop back up to the following label when a repeating alternative loops,
// following a failed input check.
//
// Either way, we have just failed the input check for the first alternative.
@@ -1956,56 +2556,57 @@ class YarrGenerator : private DefaultMacroAssembler {
needsToUpdateMatchStart = false;
}
- // Check whether there is sufficient input to loop. Increment the input position by
- // one, and check. Also add in the minimum disjunction size before checking - there
- // is no point in looping if we're just going to fail all the input checks around
- // the next iteration.
- ASSERT(alternative->m_minimumSize >= m_pattern.m_body->m_minimumSize);
- if (alternative->m_minimumSize == m_pattern.m_body->m_minimumSize) {
- // If the last alternative had the same minimum size as the disjunction,
- // just simply increment input pos by 1, no adjustment based on minimum size.
- add32(TrustedImm32(1), index);
- } else {
- // If the minumum for the last alternative was one greater than than that
- // for the disjunction, we're already progressed by 1, nothing to do!
- unsigned delta = (alternative->m_minimumSize - m_pattern.m_body->m_minimumSize) - 1;
- if (delta)
- sub32(Imm32(delta), index);
- }
- Jump matchFailed = jumpIfNoAvailableInput();
+ if (!m_pattern.sticky()) {
+ // Check whether there is sufficient input to loop. Increment the input position by
+ // one, and check. Also add in the minimum disjunction size before checking - there
+ // is no point in looping if we're just going to fail all the input checks around
+ // the next iteration.
+ ASSERT(alternative->m_minimumSize >= m_pattern.m_body->m_minimumSize);
+ if (alternative->m_minimumSize == m_pattern.m_body->m_minimumSize) {
+ // If the last alternative had the same minimum size as the disjunction,
+ // just simply increment input pos by 1, no adjustment based on minimum size.
+ add32(TrustedImm32(1), index);
+ } else {
+ // If the minumum for the last alternative was one greater than than that
+ // for the disjunction, we're already progressed by 1, nothing to do!
+ unsigned delta = (alternative->m_minimumSize - m_pattern.m_body->m_minimumSize) - 1;
+ if (delta)
+ sub32(Imm32(delta), index);
+ }
+ Jump matchFailed = jumpIfNoAvailableInput();
+
+ if (needsToUpdateMatchStart) {
+ if (!m_pattern.m_body->m_minimumSize)
+ setMatchStart(index);
+ else {
+ move(index, regT0);
+ sub32(Imm32(m_pattern.m_body->m_minimumSize), regT0);
+ setMatchStart(regT0);
+ }
+ }
- if (needsToUpdateMatchStart) {
- if (!m_pattern.m_body->m_minimumSize)
- setMatchStart(index);
+ // Calculate how much more input the first alternative requires than the minimum
+ // for the body as a whole. If no more is needed then we dont need an additional
+ // input check here - jump straight back up to the start of the first alternative.
+ if (beginOp->m_alternative->m_minimumSize == m_pattern.m_body->m_minimumSize)
+ jump(beginOp->m_reentry);
else {
- move(index, regT0);
- sub32(Imm32(m_pattern.m_body->m_minimumSize), regT0);
- setMatchStart(regT0);
+ if (beginOp->m_alternative->m_minimumSize > m_pattern.m_body->m_minimumSize)
+ add32(Imm32(beginOp->m_alternative->m_minimumSize - m_pattern.m_body->m_minimumSize), index);
+ else
+ sub32(Imm32(m_pattern.m_body->m_minimumSize - beginOp->m_alternative->m_minimumSize), index);
+ checkInput().linkTo(beginOp->m_reentry, this);
+ jump(firstInputCheckFailed);
}
- }
- // Calculate how much more input the first alternative requires than the minimum
- // for the body as a whole. If no more is needed then we dont need an additional
- // input check here - jump straight back up to the start of the first alternative.
- if (beginOp->m_alternative->m_minimumSize == m_pattern.m_body->m_minimumSize)
- jump(beginOp->m_reentry);
- else {
- if (beginOp->m_alternative->m_minimumSize > m_pattern.m_body->m_minimumSize)
- add32(Imm32(beginOp->m_alternative->m_minimumSize - m_pattern.m_body->m_minimumSize), index);
- else
- sub32(Imm32(m_pattern.m_body->m_minimumSize - beginOp->m_alternative->m_minimumSize), index);
- checkInput().linkTo(beginOp->m_reentry, this);
- jump(firstInputCheckFailed);
+ // We jump to here if we iterate to the point that there is insufficient input to
+ // run any matches, and need to return a failure state from JIT code.
+ matchFailed.link(this);
}
- // We jump to here if we iterate to the point that there is insufficient input to
- // run any matches, and need to return a failure state from JIT code.
- matchFailed.link(this);
-
+ lastStickyAlternativeFailures.link(this);
removeCallFrame();
- move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
- move(TrustedImm32(0), returnRegister2);
- generateReturn();
+ generateFailReturn();
break;
}
case OpBodyAlternativeEnd: {
@@ -2013,7 +2614,7 @@ class YarrGenerator : private DefaultMacroAssembler {
ASSERT(m_backtrackingState.isEmpty());
PatternAlternative* priorAlternative = m_ops[op.m_previousOp].m_alternative;
- m_checked += priorAlternative->m_minimumSize;
+ m_checkedOffset += priorAlternative->m_minimumSize;
break;
}
@@ -2064,7 +2665,7 @@ class YarrGenerator : private DefaultMacroAssembler {
if (op.m_checkAdjust) {
// Handle the cases where we need to link the backtracks here.
m_backtrackingState.link(this);
- sub32(Imm32(op.m_checkAdjust), index);
+ sub32(Imm32(op.m_checkAdjust.unsafeGet()), index);
if (!isLastAlternative) {
// An alternative that is not the last should jump to its successor.
jump(nextOp.m_reentry);
@@ -2114,9 +2715,9 @@ class YarrGenerator : private DefaultMacroAssembler {
if (!isBegin) {
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked += lastOp.m_checkAdjust;
+ m_checkedOffset += lastOp.m_checkAdjust;
}
- m_checked -= op.m_checkAdjust;
+ m_checkedOffset -= op.m_checkAdjust;
break;
}
case OpSimpleNestedAlternativeEnd:
@@ -2136,10 +2737,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// Plant a jump to the return address.
unsigned parenthesesFrameLocation = term->frameLocation;
- unsigned alternativeFrameLocation = parenthesesFrameLocation;
- if (term->quantityType != QuantifierFixedCount)
- alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
- loadFromFrameAndJump(alternativeFrameLocation);
+ loadFromFrameAndJump(parenthesesFrameLocation + BackTrackInfoParentheses::returnAddressIndex());
// Link the DataLabelPtr associated with the end of the last
// alternative to this point.
@@ -2147,7 +2745,7 @@ class YarrGenerator : private DefaultMacroAssembler {
}
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked += lastOp.m_checkAdjust;
+ m_checkedOffset += lastOp.m_checkAdjust;
break;
}
@@ -2168,9 +2766,9 @@ class YarrGenerator : private DefaultMacroAssembler {
// matching start, depending of whether the match is Greedy or NonGreedy.
case OpParenthesesSubpatternOnceBegin: {
PatternTerm* term = op.m_term;
- ASSERT(term->quantityCount == 1);
+ ASSERT(term->quantityMaxCount == 1);
- // We only need to backtrack to thispoint if capturing or greedy.
+ // We only need to backtrack to this point if capturing or greedy.
if ((term->capture() && compileMode == IncludeSubpatterns) || term->quantityType == QuantifierGreedy) {
m_backtrackingState.link(this);
@@ -2182,7 +2780,7 @@ class YarrGenerator : private DefaultMacroAssembler {
if (term->quantityType == QuantifierGreedy) {
// Clear the flag in the stackframe indicating we ran through the subpattern.
unsigned parenthesesFrameLocation = term->frameLocation;
- storeToFrame(TrustedImm32(-1), parenthesesFrameLocation);
+ storeToFrame(TrustedImm32(-1), parenthesesFrameLocation + BackTrackInfoParenthesesOnce::beginIndex());
// Jump to after the parentheses, skipping the subpattern.
jump(m_ops[op.m_nextOp].m_reentry);
// A backtrack from after the parentheses, when skipping the subpattern,
@@ -2204,7 +2802,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// are currently in a state where we had skipped over the subpattern
// (in which case the flag value on the stack will be -1).
unsigned parenthesesFrameLocation = term->frameLocation;
- Jump hadSkipped = branch32(Equal, Address(stackPointerRegister, parenthesesFrameLocation * sizeof(void*)), TrustedImm32(-1));
+ Jump hadSkipped = branch32(Equal, Address(stackPointerRegister, (parenthesesFrameLocation + BackTrackInfoParenthesesOnce::beginIndex()) * sizeof(void*)), TrustedImm32(-1));
if (term->quantityType == QuantifierGreedy) {
// For Greedy parentheses, we skip after having already tried going
@@ -2248,6 +2846,108 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.append(op.m_jumps);
break;
+ // OpParenthesesSubpatternBegin/End
+ //
+ // When we are backtracking back out of a capturing subpattern we need
+ // to clear the start index in the matches output array, to record that
+ // this subpattern has not been captured.
+ //
+ // When backtracking back out of a Greedy quantified subpattern we need
+ // to catch this, and try running the remainder of the alternative after
+ // the subpattern again, skipping the parentheses.
+ //
+ // Upon backtracking back into a quantified set of parentheses we need to
+ // check whether we were currently skipping the subpattern. If not, we
+ // can backtrack into them, if we were we need to either backtrack back
+ // out of the start of the parentheses, or jump back to the forwards
+ // matching start, depending of whether the match is Greedy or NonGreedy.
+ case OpParenthesesSubpatternBegin: {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ PatternTerm* term = op.m_term;
+ unsigned parenthesesFrameLocation = term->frameLocation;
+
+ if (term->quantityType != QuantifierFixedCount) {
+ m_backtrackingState.link(this);
+
+ if (term->quantityType == QuantifierGreedy) {
+ RegisterID currParenContextReg = regT0;
+ RegisterID newParenContextReg = regT1;
+
+ loadFromFrame(parenthesesFrameLocation + BackTrackInfoParentheses::parenContextHeadIndex(), currParenContextReg);
+
+ restoreParenContext(currParenContextReg, regT2, term->parentheses.subpatternId, term->parentheses.lastSubpatternId, parenthesesFrameLocation);
+
+ freeParenContext(currParenContextReg, newParenContextReg);
+ storeToFrame(newParenContextReg, parenthesesFrameLocation + BackTrackInfoParentheses::parenContextHeadIndex());
+ const RegisterID countTemporary = regT0;
+ loadFromFrame(parenthesesFrameLocation + BackTrackInfoParentheses::matchAmountIndex(), countTemporary);
+ Jump zeroLengthMatch = branchTest32(Zero, countTemporary);
+
+ sub32(TrustedImm32(1), countTemporary);
+ storeToFrame(countTemporary, parenthesesFrameLocation + BackTrackInfoParentheses::matchAmountIndex());
+
+ jump(m_ops[op.m_nextOp].m_reentry);
+
+ zeroLengthMatch.link(this);
+
+ // Clear the flag in the stackframe indicating we didn't run through the subpattern.
+ storeToFrame(TrustedImm32(-1), parenthesesFrameLocation + BackTrackInfoParentheses::beginIndex());
+
+ jump(m_ops[op.m_nextOp].m_reentry);
+ }
+
+ // If Greedy, jump to the end.
+ if (term->quantityType == QuantifierGreedy) {
+ // A backtrack from after the parentheses, when skipping the subpattern,
+ // will jump back to here.
+ op.m_jumps.link(this);
+ }
+
+ m_backtrackingState.fallthrough();
+ }
+#else // !YARR_JIT_ALL_PARENS_EXPRESSIONS
+ RELEASE_ASSERT_NOT_REACHED();
+#endif
+ break;
+ }
+ case OpParenthesesSubpatternEnd: {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ PatternTerm* term = op.m_term;
+
+ if (term->quantityType != QuantifierFixedCount) {
+ m_backtrackingState.link(this);
+
+ // Check whether we should backtrack back into the parentheses, or if we
+ // are currently in a state where we had skipped over the subpattern
+ // (in which case the flag value on the stack will be -1).
+ unsigned parenthesesFrameLocation = term->frameLocation;
+ Jump hadSkipped = branch32(Equal, Address(stackPointerRegister, (parenthesesFrameLocation + BackTrackInfoParentheses::beginIndex()) * sizeof(void*)), TrustedImm32(-1));
+
+ if (term->quantityType == QuantifierGreedy) {
+ // For Greedy parentheses, we skip after having already tried going
+ // through the subpattern, so if we get here we're done.
+ YarrOp& beginOp = m_ops[op.m_previousOp];
+ beginOp.m_jumps.append(hadSkipped);
+ } else {
+ // For NonGreedy parentheses, we try skipping the subpattern first,
+ // so if we get here we need to try running through the subpattern
+ // next. Jump back to the start of the parentheses in the forwards
+ // matching path.
+ ASSERT(term->quantityType == QuantifierNonGreedy);
+ YarrOp& beginOp = m_ops[op.m_previousOp];
+ hadSkipped.linkTo(beginOp.m_reentry, this);
+ }
+
+ m_backtrackingState.fallthrough();
+ }
+
+ m_backtrackingState.append(op.m_jumps);
+#else // !YARR_JIT_ALL_PARENS_EXPRESSIONS
+ RELEASE_ASSERT_NOT_REACHED();
+#endif
+ break;
+ }
+
// OpParentheticalAssertionBegin/End
case OpParentheticalAssertionBegin: {
PatternTerm* term = op.m_term;
@@ -2260,7 +2960,7 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.link(this);
if (op.m_checkAdjust)
- add32(Imm32(op.m_checkAdjust), index);
+ add32(Imm32(op.m_checkAdjust.unsafeGet()), index);
// In an inverted assertion failure to match the subpattern
// is treated as a successful match - jump to the end of the
@@ -2277,7 +2977,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// added the failure caused by a successful match to this.
m_backtrackingState.append(endOp.m_jumps);
- m_checked += op.m_checkAdjust;
+ m_checkedOffset += op.m_checkAdjust;
break;
}
case OpParentheticalAssertionEnd: {
@@ -2289,7 +2989,7 @@ class YarrGenerator : private DefaultMacroAssembler {
m_backtrackingState.takeBacktracksToJumpList(op.m_jumps, this);
YarrOp& lastOp = m_ops[op.m_previousOp];
- m_checked -= lastOp.m_checkAdjust;
+ m_checkedOffset -= lastOp.m_checkAdjust;
break;
}
@@ -2307,9 +3007,9 @@ class YarrGenerator : private DefaultMacroAssembler {
// Emits ops for a subpattern (set of parentheses). These consist
// of a set of alternatives wrapped in an outer set of nodes for
// the parentheses.
- // Supported types of parentheses are 'Once' (quantityCount == 1)
- // and 'Terminal' (non-capturing parentheses quantified as greedy
- // and infinite).
+ // Supported types of parentheses are 'Once' (quantityMaxCount == 1),
+ // 'Terminal' (non-capturing parentheses quantified as greedy
+ // and infinite), and 0 based greedy quantified parentheses.
// Alternatives will use the 'Simple' set of ops if either the
// subpattern is terminal (in which case we will never need to
// backtrack), or if the subpattern only contains one alternative.
@@ -2328,7 +3028,10 @@ class YarrGenerator : private DefaultMacroAssembler {
// comes where the subpattern is capturing, in which case we would
// need to restore the capture from the first subpattern upon a
// failure in the second.
- if (term->quantityCount == 1 && !term->parentheses.isCopy) {
+ if (term->quantityMinCount && term->quantityMinCount != term->quantityMaxCount) {
+ m_failureReason = JITFailureReason::VariableCountedParenthesisWithNonZeroMinimum;
+ return;
+ } if (term->quantityMaxCount == 1 && !term->parentheses.isCopy) {
// Select the 'Once' nodes.
parenthesesBeginOpCode = OpParenthesesSubpatternOnceBegin;
parenthesesEndOpCode = OpParenthesesSubpatternOnceEnd;
@@ -2344,9 +3047,31 @@ class YarrGenerator : private DefaultMacroAssembler {
parenthesesBeginOpCode = OpParenthesesSubpatternTerminalBegin;
parenthesesEndOpCode = OpParenthesesSubpatternTerminalEnd;
} else {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ // We only handle generic parenthesis with greedy counts.
+ if (term->quantityType != QuantifierGreedy) {
+ // This subpattern is not supported by the JIT.
+ m_failureReason = JITFailureReason::NonGreedyParenthesizedSubpattern;
+ return;
+ }
+
+ m_containsNestedSubpatterns = true;
+
+ // Select the 'Generic' nodes.
+ parenthesesBeginOpCode = OpParenthesesSubpatternBegin;
+ parenthesesEndOpCode = OpParenthesesSubpatternEnd;
+
+ // If there is more than one alternative we cannot use the 'simple' nodes.
+ if (term->parentheses.disjunction->m_alternatives.size() != 1) {
+ alternativeBeginOpCode = OpNestedAlternativeBegin;
+ alternativeNextOpCode = OpNestedAlternativeNext;
+ alternativeEndOpCode = OpNestedAlternativeEnd;
+ }
+#else
// This subpattern is not supported by the JIT.
- m_shouldFallBack = true;
+ m_failureReason = JITFailureReason::ParenthesizedSubpattern;
return;
+#endif
}
size_t parenBegin = m_ops.size();
@@ -2355,7 +3080,7 @@ class YarrGenerator : private DefaultMacroAssembler {
m_ops.append(alternativeBeginOpCode);
m_ops.last().m_previousOp = notFound;
m_ops.last().m_term = term;
- Vector<OwnPtr<PatternAlternative> >& alternatives = term->parentheses.disjunction->m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
for (unsigned i = 0; i < alternatives.size(); ++i) {
size_t lastOpIndex = m_ops.size() - 1;
@@ -2406,7 +3131,7 @@ class YarrGenerator : private DefaultMacroAssembler {
m_ops.append(OpSimpleNestedAlternativeBegin);
m_ops.last().m_previousOp = notFound;
m_ops.last().m_term = term;
- Vector<OwnPtr<PatternAlternative> >& alternatives = term->parentheses.disjunction->m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>>& alternatives = term->parentheses.disjunction->m_alternatives;
for (unsigned i = 0; i < alternatives.size(); ++i) {
size_t lastOpIndex = m_ops.size() - 1;
@@ -2480,7 +3205,7 @@ class YarrGenerator : private DefaultMacroAssembler {
// to return the failing result.
void opCompileBody(PatternDisjunction* disjunction)
{
- Vector<OwnPtr<PatternAlternative> >& alternatives = disjunction->m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>>& alternatives = disjunction->m_alternatives;
size_t currentAlternativeIndex = 0;
// Emit the 'once through' alternatives.
@@ -2548,18 +3273,59 @@ class YarrGenerator : private DefaultMacroAssembler {
lastOp.m_nextOp = repeatLoop;
}
+ void generateTryReadUnicodeCharacterHelper()
+ {
+#ifdef JIT_UNICODE_EXPRESSIONS
+ if (m_tryReadUnicodeCharacterCalls.isEmpty())
+ return;
+
+ ASSERT(m_decodeSurrogatePairs);
+
+ m_tryReadUnicodeCharacterEntry = label();
+
+ tryReadUnicodeCharImpl(regT0);
+
+ ret();
+#endif
+ }
+
void generateEnter()
{
#if CPU(X86_64)
push(X86Registers::ebp);
move(stackPointerRegister, X86Registers::ebp);
- push(X86Registers::ebx);
+
+ if (m_pattern.m_saveInitialStartValue)
+ push(X86Registers::ebx);
+
+#if OS(WINDOWS)
+ push(X86Registers::edi);
+#endif
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ if (m_containsNestedSubpatterns) {
+#if OS(WINDOWS)
+ push(X86Registers::esi);
+#endif
+ push(X86Registers::r12);
+ }
+#endif
+
+ if (m_decodeSurrogatePairs) {
+ push(X86Registers::r13);
+ push(X86Registers::r14);
+ push(X86Registers::r15);
+
+ move(TrustedImm32(0xd800), leadingSurrogateTag);
+ move(TrustedImm32(0xdc00), trailingSurrogateTag);
+ }
// The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves.
zeroExtend32ToPtr(index, index);
zeroExtend32ToPtr(length, length);
#if OS(WINDOWS)
if (compileMode == IncludeSubpatterns)
loadPtr(Address(X86Registers::ebp, 6 * sizeof(void*)), output);
+ // rcx is the pointer to the allocated space for result in x64 Windows.
+ push(X86Registers::ecx);
#endif
#elif CPU(X86)
push(X86Registers::ebp);
@@ -2580,6 +3346,14 @@ class YarrGenerator : private DefaultMacroAssembler {
loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), output);
#endif
#elif CPU(ARM64)
+ if (m_decodeSurrogatePairs) {
+ pushPair(framePointerRegister, linkRegister);
+ move(TrustedImm32(0x10000), supplementaryPlanesBase);
+ move(TrustedImm32(0xfffffc00), surrogateTagMask);
+ move(TrustedImm32(0xd800), leadingSurrogateTag);
+ move(TrustedImm32(0xdc00), trailingSurrogateTag);
+ }
+
// The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves.
zeroExtend32ToPtr(index, index);
zeroExtend32ToPtr(length, length);
@@ -2587,45 +3361,60 @@ class YarrGenerator : private DefaultMacroAssembler {
push(ARMRegisters::r4);
push(ARMRegisters::r5);
push(ARMRegisters::r6);
-#if CPU(ARM_TRADITIONAL)
- push(ARMRegisters::r8); // scratch register
-#endif
- if (compileMode == IncludeSubpatterns)
- move(ARMRegisters::r3, output);
-#elif CPU(SH4)
- push(SH4Registers::r11);
- push(SH4Registers::r13);
+ push(ARMRegisters::r8);
#elif CPU(MIPS)
// Do nothing.
#endif
+
+ store8(TrustedImm32(1), &m_vm->isExecutingInRegExpJIT);
}
void generateReturn()
{
+ store8(TrustedImm32(0), &m_vm->isExecutingInRegExpJIT);
+
#if CPU(X86_64)
#if OS(WINDOWS)
// Store the return value in the allocated space pointed by rcx.
+ pop(X86Registers::ecx);
store64(returnRegister, Address(X86Registers::ecx));
store64(returnRegister2, Address(X86Registers::ecx, sizeof(void*)));
move(X86Registers::ecx, returnRegister);
#endif
- pop(X86Registers::ebx);
+ if (m_decodeSurrogatePairs) {
+ pop(X86Registers::r15);
+ pop(X86Registers::r14);
+ pop(X86Registers::r13);
+ }
+
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ if (m_containsNestedSubpatterns) {
+ pop(X86Registers::r12);
+#if OS(WINDOWS)
+ pop(X86Registers::esi);
+#endif
+ }
+#endif
+#if OS(WINDOWS)
+ pop(X86Registers::edi);
+#endif
+
+ if (m_pattern.m_saveInitialStartValue)
+ pop(X86Registers::ebx);
pop(X86Registers::ebp);
#elif CPU(X86)
pop(X86Registers::esi);
pop(X86Registers::edi);
pop(X86Registers::ebx);
pop(X86Registers::ebp);
+#elif CPU(ARM64)
+ if (m_decodeSurrogatePairs)
+ popPair(framePointerRegister, linkRegister);
#elif CPU(ARM)
-#if CPU(ARM_TRADITIONAL)
- pop(ARMRegisters::r8); // scratch register
-#endif
+ pop(ARMRegisters::r8);
pop(ARMRegisters::r6);
pop(ARMRegisters::r5);
pop(ARMRegisters::r4);
-#elif CPU(SH4)
- pop(SH4Registers::r13);
- pop(SH4Registers::r11);
#elif CPU(MIPS)
// Do nothing
#endif
@@ -2633,25 +3422,57 @@ class YarrGenerator : private DefaultMacroAssembler {
}
public:
- YarrGenerator(YarrPattern& pattern, YarrCharSize charSize)
- : m_pattern(pattern)
+ YarrGenerator(VM* vm, YarrPattern& pattern, YarrCodeBlock& codeBlock, YarrCharSize charSize)
+ : m_vm(vm)
+ , m_pattern(pattern)
+ , m_codeBlock(codeBlock)
, m_charSize(charSize)
- , m_charScale(m_charSize == Char8 ? TimesOne: TimesTwo)
- , m_shouldFallBack(false)
- , m_checked(0)
+ , m_decodeSurrogatePairs(m_charSize == Char16 && m_pattern.unicode())
+ , m_unicodeIgnoreCase(m_pattern.unicode() && m_pattern.ignoreCase())
+ , m_canonicalMode(m_pattern.unicode() ? CanonicalMode::Unicode : CanonicalMode::UCS2)
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ , m_containsNestedSubpatterns(false)
+ , m_parenContextSizes(compileMode == IncludeSubpatterns ? m_pattern.m_numSubpatterns : 0, m_pattern.m_body->m_callFrameSize)
+#endif
{
}
- void compile(JSGlobalData* globalData, YarrCodeBlock& jitObject)
+ void compile()
{
+ YarrCodeBlock& codeBlock = m_codeBlock;
+
+#ifndef JIT_UNICODE_EXPRESSIONS
+ if (m_decodeSurrogatePairs) {
+ codeBlock.setFallBackWithFailureReason(JITFailureReason::DecodeSurrogatePair);
+ return;
+ }
+#endif
+
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ if (m_containsNestedSubpatterns)
+ codeBlock.setUsesPaternContextBuffer();
+#endif
+
+ // We need to compile before generating code since we set flags based on compilation that
+ // are used during generation.
+ opCompileBody(m_pattern.m_body);
+
+ if (m_failureReason) {
+ codeBlock.setFallBackWithFailureReason(*m_failureReason);
+ return;
+ }
+
generateEnter();
Jump hasInput = checkInput();
- move(TrustedImmPtr((void*)WTF::notFound), returnRegister);
- move(TrustedImm32(0), returnRegister2);
- generateReturn();
+ generateFailReturn();
hasInput.link(this);
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ if (m_containsNestedSubpatterns)
+ move(TrustedImm32(matchLimit), remainingMatchCount);
+#endif
+
if (compileMode == IncludeSubpatterns) {
for (unsigned i = 0; i < m_pattern.m_numSubpatterns + 1; ++i)
store32(TrustedImm32(-1), Address(output, (i << 1) * sizeof(int)));
@@ -2662,47 +3483,80 @@ public:
initCallFrame();
- // Compile the pattern to the internal 'YarrOp' representation.
- opCompileBody(m_pattern.m_body);
-
- // If we encountered anything we can't handle in the JIT code
- // (e.g. backreferences) then return early.
- if (m_shouldFallBack) {
- jitObject.setFallBack(true);
- return;
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ if (m_containsNestedSubpatterns)
+ initParenContextFreeList();
+#endif
+
+ if (m_pattern.m_saveInitialStartValue) {
+#ifdef HAVE_INITIAL_START_REG
+ move(index, initialStart);
+#else
+ storeToFrame(index, m_pattern.m_initialStartValueFrameLocation);
+#endif
}
generate();
backtrack();
- // Link & finalize the code.
- LinkBuffer<JSC::DefaultMacroAssembler> linkBuffer(*globalData, this, REGEXP_CODE_ID);
+ generateTryReadUnicodeCharacterHelper();
+
+ generateJITFailReturn();
+
+ JSGlobalData data(m_vm->regExpAllocator);
+ DefaultLinkBuffer linkBuffer(data, this, REGEXP_CODE_ID, JITCompilationCanFail);
+ if (linkBuffer.didFailToAllocate()) {
+ codeBlock.setFallBackWithFailureReason(JITFailureReason::ExecutableMemoryAllocationFailure);
+ return;
+ }
+
+ if (!m_tryReadUnicodeCharacterCalls.isEmpty()) {
+ CodeLocationLabel tryReadUnicodeCharacterHelper = linkBuffer.locationOf(m_tryReadUnicodeCharacterEntry);
+
+ for (auto call : m_tryReadUnicodeCharacterCalls)
+ linkBuffer.link(call, tryReadUnicodeCharacterHelper);
+ }
+
m_backtrackingState.linkDataLabels(linkBuffer);
if (compileMode == MatchOnly) {
if (m_charSize == Char8)
- jitObject.set8BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, ("Match-only 8-bit regular expression")));
+ codeBlock.set8BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarJIT", "Match-only 8-bit regular expression"));
else
- jitObject.set16BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, ("Match-only 16-bit regular expression")));
+ codeBlock.set16BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarJIT", "Match-only 16-bit regular expression"));
} else {
if (m_charSize == Char8)
- jitObject.set8BitCode(FINALIZE_CODE(linkBuffer, ("8-bit regular expression")));
+ codeBlock.set8BitCode(FINALIZE_CODE(linkBuffer, "YarJIT", "8-bit regular expression"));
else
- jitObject.set16BitCode(FINALIZE_CODE(linkBuffer, ("16-bit regular expression")));
+ codeBlock.set16BitCode(FINALIZE_CODE(linkBuffer, "YarJIT", "16-bit regular expression"));
}
- jitObject.setFallBack(m_shouldFallBack);
+ if (m_failureReason)
+ codeBlock.setFallBackWithFailureReason(*m_failureReason);
}
private:
+ VM* m_vm;
+
YarrPattern& m_pattern;
+ YarrCodeBlock& m_codeBlock;
YarrCharSize m_charSize;
- Scale m_charScale;
-
// Used to detect regular expression constructs that are not currently
// supported in the JIT; fall back to the interpreter when this is detected.
- bool m_shouldFallBack;
+ std::optional<JITFailureReason> m_failureReason;
+
+ bool m_decodeSurrogatePairs;
+ bool m_unicodeIgnoreCase;
+ CanonicalMode m_canonicalMode;
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ bool m_containsNestedSubpatterns;
+ ParenContextSizes m_parenContextSizes;
+#endif
+ JumpList m_abortExecution;
+ JumpList m_hitMatchLimit;
+ Vector<Call> m_tryReadUnicodeCharacterCalls;
+ Label m_tryReadUnicodeCharacterEntry;
// The regular expression expressed as a linear sequence of operations.
Vector<YarrOp, 128> m_ops;
@@ -2717,18 +3571,47 @@ private:
// FIXME: This should go away. Rather than tracking this value throughout
// code generation, we should gather this information up front & store it
// on the YarrOp structure.
- int m_checked;
+ Checked<unsigned> m_checkedOffset;
// This class records state whilst generating the backtracking path of code.
BacktrackingState m_backtrackingState;
};
-void jitCompile(YarrPattern& pattern, YarrCharSize charSize, JSGlobalData* globalData, YarrCodeBlock& jitObject, YarrJITCompileMode mode)
+static void dumpCompileFailure(JITFailureReason failure)
+{
+ switch (failure) {
+ case JITFailureReason::DecodeSurrogatePair:
+ dataLog("Can't JIT a pattern decoding surrogate pairs\n");
+ break;
+ case JITFailureReason::BackReference:
+ dataLog("Can't JIT a pattern containing back references\n");
+ break;
+ case JITFailureReason::VariableCountedParenthesisWithNonZeroMinimum:
+ dataLog("Can't JIT a pattern containing a variable counted parenthesis with a non-zero minimum\n");
+ break;
+ case JITFailureReason::ParenthesizedSubpattern:
+ dataLog("Can't JIT a pattern containing parenthesized subpatterns\n");
+ break;
+ case JITFailureReason::NonGreedyParenthesizedSubpattern:
+ dataLog("Can't JIT a pattern containing non-greedy parenthesized subpatterns\n");
+ break;
+ case JITFailureReason::ExecutableMemoryAllocationFailure:
+ dataLog("Can't JIT because of failure of allocation of executable memory\n");
+ break;
+ }
+}
+
+void jitCompile(YarrPattern& pattern, YarrCharSize charSize, VM* vm, YarrCodeBlock& codeBlock, YarrJITCompileMode mode)
{
if (mode == MatchOnly)
- YarrGenerator<MatchOnly>(pattern, charSize).compile(globalData, jitObject);
+ YarrGenerator<MatchOnly>(vm, pattern, codeBlock, charSize).compile();
else
- YarrGenerator<IncludeSubpatterns>(pattern, charSize).compile(globalData, jitObject);
+ YarrGenerator<IncludeSubpatterns>(vm, pattern, codeBlock, charSize).compile();
+
+ if (auto failureReason = codeBlock.failureReason()) {
+ if (Options::dumpCompiledRegExpPatterns())
+ dumpCompileFailure(*failureReason);
+ }
}
}}
diff --git a/src/3rdparty/masm/yarr/YarrJIT.h b/src/3rdparty/masm/yarr/YarrJIT.h
index bb7033fdea..8b6b3a7577 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.h
+++ b/src/3rdparty/masm/yarr/YarrJIT.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,12 +23,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef YarrJIT_h
-#define YarrJIT_h
+#pragma once
+
+#include <Platform.h>
#if ENABLE(YARR_JIT)
-#include "JSGlobalData.h"
#include "MacroAssemblerCodeRef.h"
#include "MatchResult.h"
#include "Yarr.h"
@@ -40,19 +40,39 @@
#define YARR_CALL
#endif
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+constexpr size_t patternContextBufferSize = 8192; // Space caller allocates to save nested parenthesis context
+#endif
+
namespace JSC {
-class JSGlobalData;
+class VM;
class ExecutablePool;
namespace Yarr {
+enum class JITFailureReason : uint8_t {
+ DecodeSurrogatePair,
+ BackReference,
+ VariableCountedParenthesisWithNonZeroMinimum,
+ ParenthesizedSubpattern,
+ NonGreedyParenthesizedSubpattern,
+ ExecutableMemoryAllocationFailure,
+};
+
class YarrCodeBlock {
-#if CPU(X86_64)
+#if CPU(X86_64) || CPU(ARM64)
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ typedef MatchResult (*YarrJITCode8)(const LChar* input, unsigned start, unsigned length, int* output, void* freeParenContext, unsigned parenContextSize) YARR_CALL;
+ typedef MatchResult (*YarrJITCode16)(const UChar* input, unsigned start, unsigned length, int* output, void* freeParenContext, unsigned parenContextSize) YARR_CALL;
+ typedef MatchResult (*YarrJITCodeMatchOnly8)(const LChar* input, unsigned start, unsigned length, void*, void* freeParenContext, unsigned parenContextSize) YARR_CALL;
+ typedef MatchResult (*YarrJITCodeMatchOnly16)(const UChar* input, unsigned start, unsigned length, void*, void* freeParenContext, unsigned parenContextSize) YARR_CALL;
+#else
typedef MatchResult (*YarrJITCode8)(const LChar* input, unsigned start, unsigned length, int* output) YARR_CALL;
typedef MatchResult (*YarrJITCode16)(const UChar* input, unsigned start, unsigned length, int* output) YARR_CALL;
typedef MatchResult (*YarrJITCodeMatchOnly8)(const LChar* input, unsigned start, unsigned length) YARR_CALL;
typedef MatchResult (*YarrJITCodeMatchOnly16)(const UChar* input, unsigned start, unsigned length) YARR_CALL;
+#endif
#else
typedef EncodedMatchResult (*YarrJITCode8)(const LChar* input, unsigned start, unsigned length, int* output) YARR_CALL;
typedef EncodedMatchResult (*YarrJITCode16)(const UChar* input, unsigned start, unsigned length, int* output) YARR_CALL;
@@ -61,17 +81,10 @@ class YarrCodeBlock {
#endif
public:
- YarrCodeBlock()
- : m_needFallBack(false)
- {
- }
-
- ~YarrCodeBlock()
- {
- }
+ YarrCodeBlock() = default;
- void setFallBack(bool fallback) { m_needFallBack = fallback; }
- bool isFallBack() { return m_needFallBack; }
+ void setFallBackWithFailureReason(JITFailureReason failureReason) { m_failureReason = failureReason; }
+ std::optional<JITFailureReason> failureReason() { return m_failureReason; }
bool has8BitCode() { return m_ref8.size(); }
bool has16BitCode() { return m_ref16.size(); }
@@ -83,6 +96,34 @@ public:
void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly8 = matchOnly; }
void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly16 = matchOnly; }
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ bool usesPatternContextBuffer() { return m_usesPatternContextBuffer; }
+ void setUsesPaternContextBuffer() { m_usesPatternContextBuffer = true; }
+
+ MatchResult execute(const LChar* input, unsigned start, unsigned length, int* output, void* freeParenContext, unsigned parenContextSize)
+ {
+ ASSERT(has8BitCode());
+ return MatchResult(reinterpret_cast<YarrJITCode8>(m_ref8.code().executableAddress())(input, start, length, output, freeParenContext, parenContextSize));
+ }
+
+ MatchResult execute(const UChar* input, unsigned start, unsigned length, int* output, void* freeParenContext, unsigned parenContextSize)
+ {
+ ASSERT(has16BitCode());
+ return MatchResult(reinterpret_cast<YarrJITCode16>(m_ref16.code().executableAddress())(input, start, length, output, freeParenContext, parenContextSize));
+ }
+
+ MatchResult execute(const LChar* input, unsigned start, unsigned length, void* freeParenContext, unsigned parenContextSize)
+ {
+ ASSERT(has8BitCodeMatchOnly());
+ return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly8>(m_matchOnly8.code().executableAddress())(input, start, length, 0, freeParenContext, parenContextSize));
+ }
+
+ MatchResult execute(const UChar* input, unsigned start, unsigned length, void* freeParenContext, unsigned parenContextSize)
+ {
+ ASSERT(has16BitCodeMatchOnly());
+ return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly16>(m_matchOnly16.code().executableAddress())(input, start, length, 0, freeParenContext, parenContextSize));
+ }
+#else
MatchResult execute(const LChar* input, unsigned start, unsigned length, int* output)
{
ASSERT(has8BitCode());
@@ -106,18 +147,54 @@ public:
ASSERT(has16BitCodeMatchOnly());
return MatchResult(reinterpret_cast<YarrJITCodeMatchOnly16>(m_matchOnly16.code().executableAddress())(input, start, length));
}
+#endif
#if ENABLE(REGEXP_TRACING)
- void *getAddr() { return m_ref.code().executableAddress(); }
+ void *get8BitMatchOnlyAddr()
+ {
+ if (!has8BitCodeMatchOnly())
+ return 0;
+
+ return m_matchOnly8.code().executableAddress();
+ }
+
+ void *get16BitMatchOnlyAddr()
+ {
+ if (!has16BitCodeMatchOnly())
+ return 0;
+
+ return m_matchOnly16.code().executableAddress();
+ }
+
+ void *get8BitMatchAddr()
+ {
+ if (!has8BitCode())
+ return 0;
+
+ return m_ref8.code().executableAddress();
+ }
+
+ void *get16BitMatchAddr()
+ {
+ if (!has16BitCode())
+ return 0;
+
+ return m_ref16.code().executableAddress();
+ }
#endif
+ size_t size() const
+ {
+ return m_ref8.size() + m_ref16.size() + m_matchOnly8.size() + m_matchOnly16.size();
+ }
+
void clear()
{
m_ref8 = MacroAssemblerCodeRef();
m_ref16 = MacroAssemblerCodeRef();
m_matchOnly8 = MacroAssemblerCodeRef();
m_matchOnly16 = MacroAssemblerCodeRef();
- m_needFallBack = false;
+ m_failureReason = std::nullopt;
}
private:
@@ -125,17 +202,18 @@ private:
MacroAssemblerCodeRef m_ref16;
MacroAssemblerCodeRef m_matchOnly8;
MacroAssemblerCodeRef m_matchOnly16;
- bool m_needFallBack;
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ bool m_usesPatternContextBuffer;
+#endif
+ std::optional<JITFailureReason> m_failureReason;
};
enum YarrJITCompileMode {
MatchOnly,
IncludeSubpatterns
};
-void jitCompile(YarrPattern&, YarrCharSize, JSGlobalData*, YarrCodeBlock& jitObject, YarrJITCompileMode = IncludeSubpatterns);
+void jitCompile(YarrPattern&, YarrCharSize, VM*, YarrCodeBlock& jitObject, YarrJITCompileMode = IncludeSubpatterns);
} } // namespace JSC::Yarr
#endif
-
-#endif // YarrJIT_h
diff --git a/src/3rdparty/masm/yarr/YarrParser.h b/src/3rdparty/masm/yarr/YarrParser.h
index 13ffd3a1d6..3e5311f1fb 100644
--- a/src/3rdparty/masm/yarr/YarrParser.h
+++ b/src/3rdparty/masm/yarr/YarrParser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,46 +23,25 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef YarrParser_h
-#define YarrParser_h
+#pragma once
#include "Yarr.h"
+#include "YarrPattern.h"
+#include "YarrUnicodeProperties.h"
#include <wtf/ASCIICType.h>
+#include <wtf/HashSet.h>
+#include <wtf/Optional.h>
+#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
-#include <wtf/unicode/Unicode.h>
namespace JSC { namespace Yarr {
-#define REGEXP_ERROR_PREFIX "Invalid regular expression: "
-
-enum BuiltInCharacterClassID {
- DigitClassID,
- SpaceClassID,
- WordClassID,
- NewlineClassID,
-};
-
// The Parser class should not be used directly - only via the Yarr::parse() method.
template<class Delegate, typename CharType>
class Parser {
private:
template<class FriendDelegate>
- friend const char* parse(FriendDelegate&, const String& pattern, unsigned backReferenceLimit);
-
- enum ErrorCode {
- NoError,
- PatternTooLarge,
- QuantifierOutOfOrder,
- QuantifierWithoutAtom,
- QuantifierTooLarge,
- MissingParentheses,
- ParenthesesUnmatched,
- ParenthesesTypeInvalid,
- CharacterClassUnmatched,
- CharacterClassOutOfOrder,
- EscapeUnterminated,
- NumberOfErrorCodes
- };
+ friend ErrorCode parse(FriendDelegate&, const String& pattern, bool isUnicode, unsigned backReferenceLimit);
/*
* CharacterClassParserDelegate:
@@ -77,7 +56,7 @@ private:
public:
CharacterClassParserDelegate(Delegate& delegate, ErrorCode& err)
: m_delegate(delegate)
- , m_err(err)
+ , m_errorCode(err)
, m_state(Empty)
, m_character(0)
{
@@ -102,7 +81,7 @@ private:
* mode we will allow a hypen to be treated as indicating a range (i.e. /[a-z]/
* is different to /[a\-z]/).
*/
- void atomPatternCharacter(UChar ch, bool hyphenIsRange = false)
+ void atomPatternCharacter(UChar32 ch, bool hyphenIsRange = false)
{
switch (m_state) {
case AfterCharacterClass:
@@ -118,7 +97,8 @@ private:
m_state = AfterCharacterClassHyphen;
return;
}
- Q_FALLTHROUGH(); // cached character, so treat this as Empty.
+ // Otherwise just fall through - cached character so treat this as Empty.
+ FALLTHROUGH;
case Empty:
m_character = ch;
@@ -136,7 +116,7 @@ private:
case CachedCharacterHyphen:
if (ch < m_character) {
- m_err = CharacterClassOutOfOrder;
+ m_errorCode = ErrorCode::CharacterClassOutOfOrder;
return;
}
m_delegate.atomCharacterClassRange(m_character, ch);
@@ -168,8 +148,7 @@ private:
case CachedCharacter:
// Flush the currently cached character, then fall through.
m_delegate.atomCharacterClassAtom(m_character);
- Q_FALLTHROUGH();
-
+ FALLTHROUGH;
case Empty:
case AfterCharacterClass:
m_state = AfterCharacterClass;
@@ -187,7 +166,7 @@ private:
case CachedCharacterHyphen:
m_delegate.atomCharacterClassAtom(m_character);
m_delegate.atomCharacterClassAtom('-');
- // fall through
+ FALLTHROUGH;
case AfterCharacterClassHyphen:
m_delegate.atomCharacterClassBuiltIn(classID, invert);
m_state = Empty;
@@ -215,10 +194,11 @@ private:
// invoked with inCharacterClass set.
NO_RETURN_DUE_TO_ASSERT void assertionWordBoundary(bool) { RELEASE_ASSERT_NOT_REACHED(); }
NO_RETURN_DUE_TO_ASSERT void atomBackReference(unsigned) { RELEASE_ASSERT_NOT_REACHED(); }
+ NO_RETURN_DUE_TO_ASSERT void atomNamedBackReference(String) { RELEASE_ASSERT_NOT_REACHED(); }
private:
Delegate& m_delegate;
- ErrorCode& m_err;
+ ErrorCode& m_errorCode;
enum CharacterClassConstructionState {
Empty,
CachedCharacter,
@@ -226,20 +206,31 @@ private:
AfterCharacterClass,
AfterCharacterClassHyphen,
} m_state;
- UChar m_character;
+ UChar32 m_character;
};
- Parser(Delegate& delegate, const String& pattern, unsigned backReferenceLimit)
+ Parser(Delegate& delegate, const String& pattern, bool isUnicode, unsigned backReferenceLimit)
: m_delegate(delegate)
, m_backReferenceLimit(backReferenceLimit)
- , m_err(NoError)
- , m_data(pattern.getCharacters<CharType>())
+ , m_data(pattern.characters<CharType>())
, m_size(pattern.length())
- , m_index(0)
- , m_parenthesesNestingDepth(0)
+ , m_isUnicode(isUnicode)
{
}
+ // The handling of IdentityEscapes is different depending on the unicode flag.
+ // For Unicode patterns, IdentityEscapes only include SyntaxCharacters or '/'.
+ // For non-unicode patterns, most any character can be escaped.
+ bool isIdentityEscapeAnError(int ch)
+ {
+ if (m_isUnicode && !strchr("^$\\.*+?()[]{}|/", ch)) {
+ m_errorCode = ErrorCode::InvalidIdentityEscape;
+ return true;
+ }
+
+ return false;
+ }
+
/*
* parseEscape():
*
@@ -263,12 +254,12 @@ private:
template<bool inCharacterClass, class EscapeDelegate>
bool parseEscape(EscapeDelegate& delegate)
{
- ASSERT(!m_err);
+ ASSERT(!hasError(m_errorCode));
ASSERT(peek() == '\\');
consume();
if (atEndOfPattern()) {
- m_err = EscapeUnterminated;
+ m_errorCode = ErrorCode::EscapeUnterminated;
return false;
}
@@ -276,18 +267,24 @@ private:
// Assertions
case 'b':
consume();
- if (inCharacterClass)
+ if (inCharacterClass) {
+ if (isIdentityEscapeAnError('b'))
+ break;
+
delegate.atomPatternCharacter('\b');
- else {
+ } else {
delegate.assertionWordBoundary(false);
return false;
}
break;
case 'B':
consume();
- if (inCharacterClass)
+ if (inCharacterClass) {
+ if (isIdentityEscapeAnError('B'))
+ break;
+
delegate.atomPatternCharacter('B');
- else {
+ } else {
delegate.assertionWordBoundary(true);
return false;
}
@@ -296,27 +293,27 @@ private:
// CharacterClassEscape
case 'd':
consume();
- delegate.atomBuiltInCharacterClass(DigitClassID, false);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::DigitClassID, false);
break;
case 's':
consume();
- delegate.atomBuiltInCharacterClass(SpaceClassID, false);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::SpaceClassID, false);
break;
case 'w':
consume();
- delegate.atomBuiltInCharacterClass(WordClassID, false);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::WordClassID, false);
break;
case 'D':
consume();
- delegate.atomBuiltInCharacterClass(DigitClassID, true);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::DigitClassID, true);
break;
case 'S':
consume();
- delegate.atomBuiltInCharacterClass(SpaceClassID, true);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::SpaceClassID, true);
break;
case 'W':
consume();
- delegate.atomBuiltInCharacterClass(WordClassID, true);
+ delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::WordClassID, true);
break;
// DecimalEscape
@@ -341,15 +338,22 @@ private:
}
restoreState(state);
+
+ if (m_isUnicode) {
+ m_errorCode = ErrorCode::InvalidBackreference;
+ return false;
+ }
}
-
- // Not a backreference, and not octal.
+
+ // Not a backreference, and not octal. Just a number.
if (peek() >= '8') {
- delegate.atomPatternCharacter('\\');
+ delegate.atomPatternCharacter(consume());
break;
}
+
+ // Fall-through to handle this as an octal escape.
+ FALLTHROUGH;
}
- Q_FALLTHROUGH(); // Handle this as an octal escape.
// Octal escape
case '0':
@@ -400,32 +404,161 @@ private:
case 'x': {
consume();
int x = tryConsumeHex(2);
- if (x == -1)
+ if (x == -1) {
+ if (isIdentityEscapeAnError('x'))
+ break;
+
delegate.atomPatternCharacter('x');
- else
+ } else
delegate.atomPatternCharacter(x);
break;
}
+ // Named backreference
+ case 'k': {
+ consume();
+ ParseState state = saveState();
+ if (!atEndOfPattern() && !inCharacterClass) {
+ if (consume() == '<') {
+ auto groupName = tryConsumeGroupName();
+ if (groupName && m_captureGroupNames.contains(groupName.value())) {
+ delegate.atomNamedBackReference(groupName.value());
+ break;
+ }
+ if (m_isUnicode) {
+ m_errorCode = ErrorCode::InvalidBackreference;
+ break;
+ }
+ }
+ }
+ restoreState(state);
+ delegate.atomPatternCharacter('k');
+ break;
+ }
+
+ // Unicode property escapes
+ case 'p':
+ case 'P': {
+ int escapeChar = consume();
+
+ if (!m_isUnicode) {
+ if (isIdentityEscapeAnError(escapeChar))
+ break;
+ delegate.atomPatternCharacter(escapeChar);
+ break;
+ }
+
+ if (!atEndOfPattern() && peek() == '{') {
+ consume();
+ auto optClassID = tryConsumeUnicodePropertyExpression();
+ if (!optClassID) {
+ // tryConsumeUnicodePropertyExpression() will set m_errorCode for a malformed property expression
+ break;
+ }
+ delegate.atomBuiltInCharacterClass(optClassID.value(), escapeChar == 'P');
+ } else
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ break;
+ }
+
// UnicodeEscape
case 'u': {
consume();
+ if (atEndOfPattern()) {
+ if (isIdentityEscapeAnError('u'))
+ break;
+
+ delegate.atomPatternCharacter('u');
+ break;
+ }
+
+ if (m_isUnicode && peek() == '{') {
+ consume();
+ UChar32 codePoint = 0;
+ do {
+ if (atEndOfPattern() || !isASCIIHexDigit(peek())) {
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ break;
+ }
+
+ codePoint = (codePoint << 4) | toASCIIHexValue(consume());
+
+ if (codePoint > UCHAR_MAX_VALUE)
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ } while (!atEndOfPattern() && peek() != '}');
+ if (!atEndOfPattern() && peek() == '}')
+ consume();
+ else if (!hasError(m_errorCode))
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ if (hasError(m_errorCode))
+ return false;
+
+ delegate.atomPatternCharacter(codePoint);
+ break;
+ }
int u = tryConsumeHex(4);
- if (u == -1)
+ if (u == -1) {
+ if (isIdentityEscapeAnError('u'))
+ break;
+
delegate.atomPatternCharacter('u');
- else
+ } else {
+ // If we have the first of a surrogate pair, look for the second.
+ if (U16_IS_LEAD(u) && m_isUnicode && (patternRemaining() >= 6) && peek() == '\\') {
+ ParseState state = saveState();
+ consume();
+
+ if (tryConsume('u')) {
+ int surrogate2 = tryConsumeHex(4);
+ if (U16_IS_TRAIL(surrogate2)) {
+ u = U16_GET_SUPPLEMENTARY(u, surrogate2);
+ delegate.atomPatternCharacter(u);
+ break;
+ }
+ }
+
+ restoreState(state);
+ }
delegate.atomPatternCharacter(u);
+ }
break;
}
// IdentityEscape
default:
+ int ch = peek();
+
+ if (ch == '-' && m_isUnicode && inCharacterClass) {
+ // \- is allowed for ClassEscape with unicode flag.
+ delegate.atomPatternCharacter(consume());
+ break;
+ }
+
+ if (isIdentityEscapeAnError(ch))
+ break;
+
delegate.atomPatternCharacter(consume());
}
return true;
}
+ UChar32 consumePossibleSurrogatePair()
+ {
+ UChar32 ch = consume();
+ if (U16_IS_LEAD(ch) && m_isUnicode && (patternRemaining() > 0)) {
+ ParseState state = saveState();
+
+ UChar32 surrogate2 = consume();
+ if (U16_IS_TRAIL(surrogate2))
+ ch = U16_GET_SUPPLEMENTARY(ch, surrogate2);
+ else
+ restoreState(state);
+ }
+
+ return ch;
+ }
+
/*
* parseAtomEscape(), parseCharacterClassEscape():
*
@@ -449,11 +582,11 @@ private:
*/
void parseCharacterClass()
{
- ASSERT(!m_err);
+ ASSERT(!hasError(m_errorCode));
ASSERT(peek() == '[');
consume();
- CharacterClassParserDelegate characterClassConstructor(m_delegate, m_err);
+ CharacterClassParserDelegate characterClassConstructor(m_delegate, m_errorCode);
characterClassConstructor.begin(tryConsume('^'));
@@ -469,14 +602,14 @@ private:
break;
default:
- characterClassConstructor.atomPatternCharacter(consume(), true);
+ characterClassConstructor.atomPatternCharacter(consumePossibleSurrogatePair(), true);
}
- if (m_err)
+ if (hasError(m_errorCode))
return;
}
- m_err = CharacterClassUnmatched;
+ m_errorCode = ErrorCode::CharacterClassUnmatched;
}
/*
@@ -486,13 +619,13 @@ private:
*/
void parseParenthesesBegin()
{
- ASSERT(!m_err);
+ ASSERT(!hasError(m_errorCode));
ASSERT(peek() == '(');
consume();
if (tryConsume('?')) {
if (atEndOfPattern()) {
- m_err = ParenthesesTypeInvalid;
+ m_errorCode = ErrorCode::ParenthesesTypeInvalid;
return;
}
@@ -508,9 +641,23 @@ private:
case '!':
m_delegate.atomParentheticalAssertionBegin(true);
break;
-
+
+ case '<': {
+ auto groupName = tryConsumeGroupName();
+ if (groupName) {
+ auto setAddResult = m_captureGroupNames.add(groupName.value());
+ if (setAddResult.isNewEntry)
+ m_delegate.atomParenthesesSubpatternBegin(true, groupName);
+ else
+ m_errorCode = ErrorCode::DuplicateGroupName;
+ } else
+ m_errorCode = ErrorCode::InvalidGroupName;
+
+ break;
+ }
+
default:
- m_err = ParenthesesTypeInvalid;
+ m_errorCode = ErrorCode::ParenthesesTypeInvalid;
}
} else
m_delegate.atomParenthesesSubpatternBegin();
@@ -525,14 +672,14 @@ private:
*/
void parseParenthesesEnd()
{
- ASSERT(!m_err);
+ ASSERT(!hasError(m_errorCode));
ASSERT(peek() == ')');
consume();
if (m_parenthesesNestingDepth > 0)
m_delegate.atomParenthesesEnd();
else
- m_err = ParenthesesUnmatched;
+ m_errorCode = ErrorCode::ParenthesesUnmatched;
--m_parenthesesNestingDepth;
}
@@ -544,18 +691,18 @@ private:
*/
void parseQuantifier(bool lastTokenWasAnAtom, unsigned min, unsigned max)
{
- ASSERT(!m_err);
+ ASSERT(!hasError(m_errorCode));
ASSERT(min <= max);
if (min == UINT_MAX) {
- m_err = QuantifierTooLarge;
+ m_errorCode = ErrorCode::QuantifierTooLarge;
return;
}
if (lastTokenWasAnAtom)
m_delegate.quantifyAtom(min, max, !tryConsume('?'));
else
- m_err = QuantifierWithoutAtom;
+ m_errorCode = ErrorCode::QuantifierWithoutAtom;
}
/*
@@ -603,7 +750,7 @@ private:
case '.':
consume();
- m_delegate.atomBuiltInCharacterClass(NewlineClassID, true);
+ m_delegate.atomBuiltInCharacterClass(BuiltInCharacterClassID::DotClassID, false);
lastTokenWasAnAtom = true;
break;
@@ -649,7 +796,7 @@ private:
if (min <= max)
parseQuantifier(lastTokenWasAnAtom, min, max);
else
- m_err = QuantifierOutOfOrder;
+ m_errorCode = ErrorCode::QuantifierOutOfOrder;
lastTokenWasAnAtom = false;
break;
}
@@ -657,51 +804,36 @@ private:
restoreState(state);
}
- Q_FALLTHROUGH(); // if we did not find a complete quantifer, fall through to the default case.
+ // if we did not find a complete quantifer, fall through to the default case.
+ FALLTHROUGH;
default:
- m_delegate.atomPatternCharacter(consume());
+ m_delegate.atomPatternCharacter(consumePossibleSurrogatePair());
lastTokenWasAnAtom = true;
}
- if (m_err)
+ if (hasError(m_errorCode))
return;
}
if (m_parenthesesNestingDepth > 0)
- m_err = MissingParentheses;
+ m_errorCode = ErrorCode::MissingParentheses;
}
/*
* parse():
*
- * This method calls parseTokens() to parse over the input and converts any
- * error code to a const char* for a result.
+ * This method calls parseTokens() to parse over the input and returns error code for a result.
*/
- const char* parse()
+ ErrorCode parse()
{
if (m_size > MAX_PATTERN_SIZE)
- m_err = PatternTooLarge;
+ m_errorCode = ErrorCode::PatternTooLarge;
else
parseTokens();
- ASSERT(atEndOfPattern() || m_err);
-
- // The order of this array must match the ErrorCode enum.
- static const char* errorMessages[NumberOfErrorCodes] = {
- 0, // NoError
- REGEXP_ERROR_PREFIX "regular expression too large",
- REGEXP_ERROR_PREFIX "numbers out of order in {} quantifier",
- REGEXP_ERROR_PREFIX "nothing to repeat",
- REGEXP_ERROR_PREFIX "number too large in {} quantifier",
- REGEXP_ERROR_PREFIX "missing )",
- REGEXP_ERROR_PREFIX "unmatched parentheses",
- REGEXP_ERROR_PREFIX "unrecognized character after (?",
- REGEXP_ERROR_PREFIX "missing terminating ] for character class",
- REGEXP_ERROR_PREFIX "range out of order in character class",
- REGEXP_ERROR_PREFIX "\\ at end of pattern"
- };
-
- return errorMessages[m_err];
+ ASSERT(atEndOfPattern() || hasError(m_errorCode));
+
+ return m_errorCode;
}
// Misc helper functions:
@@ -724,6 +856,12 @@ private:
return m_index == m_size;
}
+ unsigned patternRemaining()
+ {
+ ASSERT(m_index <= m_size);
+ return m_size - m_index;
+ }
+
int peek()
{
ASSERT(m_index < m_size);
@@ -741,6 +879,87 @@ private:
return peek() - '0';
}
+ int tryConsumeUnicodeEscape()
+ {
+ if (!tryConsume('u'))
+ return -1;
+
+ if (m_isUnicode && tryConsume('{')) {
+ int codePoint = 0;
+ do {
+ if (atEndOfPattern() || !isASCIIHexDigit(peek())) {
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ return -1;
+ }
+
+ codePoint = (codePoint << 4) | toASCIIHexValue(consume());
+
+ if (codePoint > UCHAR_MAX_VALUE) {
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ return -1;
+ }
+ } while (!atEndOfPattern() && peek() != '}');
+ if (!atEndOfPattern() && peek() == '}')
+ consume();
+ else if (!hasError(m_errorCode))
+ m_errorCode = ErrorCode::InvalidUnicodeEscape;
+ if (hasError(m_errorCode))
+ return -1;
+
+ return codePoint;
+ }
+
+ int u = tryConsumeHex(4);
+ if (u == -1)
+ return -1;
+
+ // If we have the first of a surrogate pair, look for the second.
+ if (U16_IS_LEAD(u) && m_isUnicode && (patternRemaining() >= 6) && peek() == '\\') {
+ ParseState state = saveState();
+ consume();
+
+ if (tryConsume('u')) {
+ int surrogate2 = tryConsumeHex(4);
+ if (U16_IS_TRAIL(surrogate2)) {
+ u = U16_GET_SUPPLEMENTARY(u, surrogate2);
+ return u;
+ }
+ }
+
+ restoreState(state);
+ }
+
+ return u;
+ }
+
+ int tryConsumeIdentifierCharacter()
+ {
+ int ch = peek();
+
+ if (ch == '\\') {
+ consume();
+ ch = tryConsumeUnicodeEscape();
+ } else
+ consume();
+
+ return ch;
+ }
+
+ bool isIdentifierStart(int ch)
+ {
+ return (WTF::isASCII(ch) && (WTF::isASCIIAlpha(ch) || ch == '_' || ch == '$')) || (U_GET_GC_MASK(ch) & U_GC_L_MASK);
+ }
+
+ bool isIdentifierPart(int ch)
+ {
+ return (WTF::isASCII(ch) && (WTF::isASCIIAlpha(ch) || ch == '_' || ch == '$')) || (U_GET_GC_MASK(ch) & (U_GC_L_MASK | U_GC_MN_MASK | U_GC_MC_MASK | U_GC_ND_MASK | U_GC_PC_MASK)) || ch == 0x200C || ch == 0x200D;
+ }
+
+ bool isUnicodePropertyValueExpressionChar(int ch)
+ {
+ return WTF::isASCIIAlphanumeric(ch) || ch == '_' || ch == '=';
+ }
+
int consume()
{
ASSERT(m_index < m_size);
@@ -755,13 +974,10 @@ private:
unsigned consumeNumber()
{
- unsigned n = consumeDigit();
- // check for overflow.
- for (unsigned newValue; peekIsDigit() && ((newValue = n * 10 + peekDigit()) >= n); ) {
- n = newValue;
- consume();
- }
- return n;
+ Checked<unsigned, RecordOverflow> n = consumeDigit();
+ while (peekIsDigit())
+ n = n * 10 + consumeDigit();
+ return n.hasOverflowed() ? quantifyInfinite : n.unsafeGet();
}
unsigned consumeOctal()
@@ -797,13 +1013,99 @@ private:
return n;
}
+ std::optional<String> tryConsumeGroupName()
+ {
+ if (atEndOfPattern())
+ return std::nullopt;
+
+ ParseState state = saveState();
+
+ int ch = tryConsumeIdentifierCharacter();
+
+ if (isIdentifierStart(ch)) {
+ StringBuilder identifierBuilder;
+ identifierBuilder.append(ch);
+
+ while (!atEndOfPattern()) {
+ ch = tryConsumeIdentifierCharacter();
+ if (ch == '>')
+ return std::optional<String>(identifierBuilder.toString());
+
+ if (!isIdentifierPart(ch))
+ break;
+
+ identifierBuilder.append(ch);
+ }
+ }
+
+ restoreState(state);
+
+ return std::nullopt;
+ }
+
+ std::optional<BuiltInCharacterClassID> tryConsumeUnicodePropertyExpression()
+ {
+ if (atEndOfPattern() || !isUnicodePropertyValueExpressionChar(peek())) {
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ return std::nullopt;
+ }
+
+ StringBuilder expressionBuilder;
+ String unicodePropertyName;
+ bool foundEquals = false;
+ unsigned errors = 0;
+
+ expressionBuilder.append(consume());
+
+ while (!atEndOfPattern()) {
+ int ch = peek();
+ if (ch == '}') {
+ consume();
+ if (errors) {
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ return std::nullopt;
+ }
+
+ if (foundEquals) {
+ auto result = unicodeMatchPropertyValue(unicodePropertyName, expressionBuilder.toString());
+ if (!result)
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ return result;
+ }
+
+ auto result = unicodeMatchProperty(expressionBuilder.toString());
+ if (!result)
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ return result;
+ }
+
+ consume();
+ if (ch == '=') {
+ if (!foundEquals) {
+ foundEquals = true;
+ unicodePropertyName = expressionBuilder.toString();
+ expressionBuilder.clear();
+ } else
+ errors++;
+ } else if (!isUnicodePropertyValueExpressionChar(ch))
+ errors++;
+ else
+ expressionBuilder.append(ch);
+ }
+
+ m_errorCode = ErrorCode::InvalidUnicodePropertyExpression;
+ return std::nullopt;
+ }
+
Delegate& m_delegate;
unsigned m_backReferenceLimit;
- ErrorCode m_err;
+ ErrorCode m_errorCode { ErrorCode::NoError };
const CharType* m_data;
unsigned m_size;
- unsigned m_index;
- unsigned m_parenthesesNestingDepth;
+ unsigned m_index { 0 };
+ bool m_isUnicode;
+ unsigned m_parenthesesNestingDepth { 0 };
+ HashSet<String> m_captureGroupNames;
// Derived by empirical testing of compile time in PCRE and WREC.
static const unsigned MAX_PATTERN_SIZE = 1024 * 1024;
@@ -823,17 +1125,18 @@ private:
* void assertionEOL();
* void assertionWordBoundary(bool invert);
*
- * void atomPatternCharacter(UChar ch);
+ * void atomPatternCharacter(UChar32 ch);
* void atomBuiltInCharacterClass(BuiltInCharacterClassID classID, bool invert);
* void atomCharacterClassBegin(bool invert)
- * void atomCharacterClassAtom(UChar ch)
- * void atomCharacterClassRange(UChar begin, UChar end)
+ * void atomCharacterClassAtom(UChar32 ch)
+ * void atomCharacterClassRange(UChar32 begin, UChar32 end)
* void atomCharacterClassBuiltIn(BuiltInCharacterClassID classID, bool invert)
* void atomCharacterClassEnd()
- * void atomParenthesesSubpatternBegin(bool capture = true);
+ * void atomParenthesesSubpatternBegin(bool capture = true, std::optional<String> groupName);
* void atomParentheticalAssertionBegin(bool invert = false);
* void atomParenthesesEnd();
* void atomBackReference(unsigned subpatternId);
+ * void atomNamedBackReference(String subpatternName);
*
* void quantifyAtom(unsigned min, unsigned max, bool greedy);
*
@@ -869,13 +1172,11 @@ private:
*/
template<class Delegate>
-const char* parse(Delegate& delegate, const String& pattern, unsigned backReferenceLimit = quantifyInfinite)
+ErrorCode parse(Delegate& delegate, const String& pattern, bool isUnicode, unsigned backReferenceLimit = quantifyInfinite)
{
if (pattern.is8Bit())
- return Parser<Delegate, LChar>(delegate, pattern, backReferenceLimit).parse();
- return Parser<Delegate, UChar>(delegate, pattern, backReferenceLimit).parse();
+ return Parser<Delegate, LChar>(delegate, pattern, isUnicode, backReferenceLimit).parse();
+ return Parser<Delegate, UChar>(delegate, pattern, isUnicode, backReferenceLimit).parse();
}
} } // namespace JSC::Yarr
-
-#endif // YarrParser_h
diff --git a/src/3rdparty/masm/yarr/YarrPattern.cpp b/src/3rdparty/masm/yarr/YarrPattern.cpp
index c7e5b6b09b..ac66ea1b9a 100644
--- a/src/3rdparty/masm/yarr/YarrPattern.cpp
+++ b/src/3rdparty/masm/yarr/YarrPattern.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2013-2016 Apple Inc. All rights reserved.
* Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged
*
* Redistribution and use in source and binary forms, with or without
@@ -27,10 +27,15 @@
#include "config.h"
#include "YarrPattern.h"
+#include "Options.h"
#include "Yarr.h"
-#include "YarrCanonicalizeUCS2.h"
+#include "YarrCanonicalize.h"
#include "YarrParser.h"
+#include <wtf/DataLog.h>
+#include <wtf/Optional.h>
+//#include <wtf/Threading.h>
#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
using namespace WTF;
@@ -40,8 +45,11 @@ namespace JSC { namespace Yarr {
class CharacterClassConstructor {
public:
- CharacterClassConstructor(bool isCaseInsensitive = false)
+ CharacterClassConstructor(bool isCaseInsensitive, CanonicalMode canonicalMode)
: m_isCaseInsensitive(isCaseInsensitive)
+ , m_hasNonBMPCharacters(false)
+ , m_anyCharacter(false)
+ , m_canonicalMode(canonicalMode)
{
}
@@ -51,6 +59,8 @@ public:
m_ranges.clear();
m_matchesUnicode.clear();
m_rangesUnicode.clear();
+ m_hasNonBMPCharacters = false;
+ m_anyCharacter = false;
}
void append(const CharacterClass* other)
@@ -65,11 +75,71 @@ public:
addSortedRange(m_rangesUnicode, other->m_rangesUnicode[i].begin, other->m_rangesUnicode[i].end);
}
- void putChar(UChar ch)
+ void appendInverted(const CharacterClass* other)
{
- // Handle ascii cases.
- if (ch <= 0x7f) {
- if (m_isCaseInsensitive && isASCIIAlpha(ch)) {
+ auto addSortedInverted = [&](UChar32 min, UChar32 max,
+ const Vector<UChar32>& srcMatches, const Vector<CharacterRange>& srcRanges,
+ Vector<UChar32>& destMatches, Vector<CharacterRange>& destRanges) {
+
+ auto addSortedMatchOrRange = [&](UChar32 lo, UChar32 hiPlusOne) {
+ if (lo < hiPlusOne) {
+ if (lo + 1 == hiPlusOne)
+ addSorted(destMatches, lo);
+ else
+ addSortedRange(destRanges, lo, hiPlusOne - 1);
+ }
+ };
+
+ UChar32 lo = min;
+ size_t matchesIndex = 0;
+ size_t rangesIndex = 0;
+ bool matchesRemaining = matchesIndex < srcMatches.size();
+ bool rangesRemaining = rangesIndex < srcRanges.size();
+
+ if (!matchesRemaining && !rangesRemaining) {
+ addSortedMatchOrRange(min, max + 1);
+ return;
+ }
+
+ while (matchesRemaining || rangesRemaining) {
+ UChar32 hiPlusOne;
+ UChar32 nextLo;
+
+ if (matchesRemaining
+ && (!rangesRemaining || srcMatches[matchesIndex] < srcRanges[rangesIndex].begin)) {
+ hiPlusOne = srcMatches[matchesIndex];
+ nextLo = hiPlusOne + 1;
+ ++matchesIndex;
+ matchesRemaining = matchesIndex < srcMatches.size();
+ } else {
+ hiPlusOne = srcRanges[rangesIndex].begin;
+ nextLo = srcRanges[rangesIndex].end + 1;
+ ++rangesIndex;
+ rangesRemaining = rangesIndex < srcRanges.size();
+ }
+
+ addSortedMatchOrRange(lo, hiPlusOne);
+
+ lo = nextLo;
+ }
+
+ addSortedMatchOrRange(lo, max + 1);
+ };
+
+ addSortedInverted(0, 0x7f, other->m_matches, other->m_ranges, m_matches, m_ranges);
+ addSortedInverted(0x80, 0x10ffff, other->m_matchesUnicode, other->m_rangesUnicode, m_matchesUnicode, m_rangesUnicode);
+ }
+
+ void putChar(UChar32 ch)
+ {
+ if (!m_isCaseInsensitive) {
+ addSorted(ch);
+ return;
+ }
+
+ if (m_canonicalMode == CanonicalMode::UCS2 && isASCII(ch)) {
+ // Handle ASCII cases.
+ if (isASCIIAlpha(ch)) {
addSorted(m_matches, toASCIIUpper(ch));
addSorted(m_matches, toASCIILower(ch));
} else
@@ -77,40 +147,33 @@ public:
return;
}
- // Simple case, not a case-insensitive match.
- if (!m_isCaseInsensitive) {
- addSorted(m_matchesUnicode, ch);
- return;
- }
-
// Add multiple matches, if necessary.
- UCS2CanonicalizationRange* info = rangeInfoFor(ch);
+ const CanonicalizationRange* info = canonicalRangeInfoFor(ch, m_canonicalMode);
if (info->type == CanonicalizeUnique)
- addSorted(m_matchesUnicode, ch);
+ addSorted(ch);
else
putUnicodeIgnoreCase(ch, info);
}
- void putUnicodeIgnoreCase(UChar ch, UCS2CanonicalizationRange* info)
+ void putUnicodeIgnoreCase(UChar32 ch, const CanonicalizationRange* info)
{
ASSERT(m_isCaseInsensitive);
- ASSERT(ch > 0x7f);
ASSERT(ch >= info->begin && ch <= info->end);
ASSERT(info->type != CanonicalizeUnique);
if (info->type == CanonicalizeSet) {
- for (uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
- addSorted(m_matchesUnicode, ch);
+ for (const UChar32* set = canonicalCharacterSetInfo(info->value, m_canonicalMode); (ch = *set); ++set)
+ addSorted(ch);
} else {
- addSorted(m_matchesUnicode, ch);
- addSorted(m_matchesUnicode, getCanonicalPair(info, ch));
+ addSorted(ch);
+ addSorted(getCanonicalPair(info, ch));
}
}
- void putRange(UChar lo, UChar hi)
+ void putRange(UChar32 lo, UChar32 hi)
{
- if (lo <= 0x7f) {
+ if (isASCII(lo)) {
char asciiLo = lo;
- char asciiHi = std::min(hi, (UChar)0x7f);
+ char asciiHi = std::min(hi, (UChar32)0x7f);
addSortedRange(m_ranges, lo, asciiHi);
if (m_isCaseInsensitive) {
@@ -120,19 +183,19 @@ public:
addSortedRange(m_ranges, std::max(asciiLo, 'a')+('A'-'a'), std::min(asciiHi, 'z')+('A'-'a'));
}
}
- if (hi <= 0x7f)
+ if (isASCII(hi))
return;
- lo = std::max(lo, (UChar)0x80);
+ lo = std::max(lo, (UChar32)0x80);
addSortedRange(m_rangesUnicode, lo, hi);
if (!m_isCaseInsensitive)
return;
- UCS2CanonicalizationRange* info = rangeInfoFor(lo);
+ const CanonicalizationRange* info = canonicalRangeInfoFor(lo, m_canonicalMode);
while (true) {
// Handle the range [lo .. end]
- UChar end = std::min<UChar>(info->end, hi);
+ UChar32 end = std::min<UChar32>(info->end, hi);
switch (info->type) {
case CanonicalizeUnique:
@@ -140,7 +203,7 @@ public:
break;
case CanonicalizeSet: {
UChar ch;
- for (uint16_t* set = characterSetInfo[info->value]; (ch = *set); ++set)
+ for (const UChar32* set = canonicalCharacterSetInfo(info->value, m_canonicalMode); (ch = *set); ++set)
addSorted(m_matchesUnicode, ch);
break;
}
@@ -175,24 +238,38 @@ public:
}
- PassOwnPtr<CharacterClass> charClass()
+ std::unique_ptr<CharacterClass> charClass()
{
- OwnPtr<CharacterClass> characterClass = adoptPtr(new CharacterClass);
+ coalesceTables();
+
+ auto characterClass = std::make_unique<CharacterClass>();
characterClass->m_matches.swap(m_matches);
characterClass->m_ranges.swap(m_ranges);
characterClass->m_matchesUnicode.swap(m_matchesUnicode);
characterClass->m_rangesUnicode.swap(m_rangesUnicode);
+ characterClass->m_hasNonBMPCharacters = hasNonBMPCharacters();
+ characterClass->m_anyCharacter = anyCharacter();
+
+ m_hasNonBMPCharacters = false;
+ m_anyCharacter = false;
- return characterClass.release();
+ return characterClass;
}
private:
- void addSorted(Vector<UChar>& matches, UChar ch)
+ void addSorted(UChar32 ch)
+ {
+ addSorted(isASCII(ch) ? m_matches : m_matchesUnicode, ch);
+ }
+
+ void addSorted(Vector<UChar32>& matches, UChar32 ch)
{
unsigned pos = 0;
- ASSERT(matches.size() <= UINT_MAX);
- unsigned range = static_cast<unsigned>(matches.size());
+ unsigned range = matches.size();
+
+ if (!U_IS_BMP(ch))
+ m_hasNonBMPCharacters = true;
// binary chop, find position to insert char.
while (range) {
@@ -201,9 +278,31 @@ private:
int val = matches[pos+index] - ch;
if (!val)
return;
- else if (val > 0)
+ else if (val > 0) {
+ if (val == 1) {
+ UChar32 lo = ch;
+ UChar32 hi = ch + 1;
+ matches.remove(pos + index);
+ if (pos + index > 0 && matches[pos + index - 1] == ch - 1) {
+ lo = ch - 1;
+ matches.remove(pos + index - 1);
+ }
+ addSortedRange(isASCII(ch) ? m_ranges : m_rangesUnicode, lo, hi);
+ return;
+ }
range = index;
- else {
+ } else {
+ if (val == -1) {
+ UChar32 lo = ch - 1;
+ UChar32 hi = ch;
+ matches.remove(pos + index);
+ if (pos + index + 1 < matches.size() && matches[pos + index + 1] == ch + 1) {
+ hi = ch + 1;
+ matches.remove(pos + index + 1);
+ }
+ addSortedRange(isASCII(ch) ? m_ranges : m_rangesUnicode, lo, hi);
+ return;
+ }
pos += (index+1);
range -= (index+1);
}
@@ -215,17 +314,19 @@ private:
matches.insert(pos, ch);
}
- void addSortedRange(Vector<CharacterRange>& ranges, UChar lo, UChar hi)
+ void addSortedRange(Vector<CharacterRange>& ranges, UChar32 lo, UChar32 hi)
{
- ASSERT(ranges.size() <= UINT_MAX);
- unsigned end = static_cast<unsigned>(ranges.size());
-
+ size_t end = ranges.size();
+
+ if (!U_IS_BMP(hi))
+ m_hasNonBMPCharacters = true;
+
// Simple linear scan - I doubt there are that many ranges anyway...
// feel free to fix this with something faster (eg binary chop).
- for (unsigned i = 0; i < end; ++i) {
+ for (size_t i = 0; i < end; ++i) {
// does the new range fall before the current position in the array
if (hi < ranges[i].begin) {
- // optional optimization: concatenate appending ranges? - may not be worthwhile.
+ // Concatenate appending ranges.
if (hi == (ranges[i].begin - 1)) {
ranges[i].begin = lo;
return;
@@ -233,7 +334,7 @@ private:
ranges.insert(i, CharacterRange(lo, hi));
return;
}
- // Okay, since we didn't hit the last case, the end of the new range is definitely at or after the beginning
+ // Okay, since we didn't hit the last case, the end of the new range is definitely at or after the begining
// If the new range start at or before the end of the last range, then the overlap (if it starts one after the
// end of the last range they concatenate, which is just as good.
if (lo <= (ranges[i].end + 1)) {
@@ -241,18 +342,7 @@ private:
ranges[i].begin = std::min(ranges[i].begin, lo);
ranges[i].end = std::max(ranges[i].end, hi);
- // now check if the new range can subsume any subsequent ranges.
- unsigned next = i+1;
- // each iteration of the loop we will either remove something from the list, or break the loop.
- while (next < ranges.size()) {
- if (ranges[next].begin <= (ranges[i].end + 1)) {
- // the next entry now overlaps / concatenates this one.
- ranges[i].end = std::max(ranges[i].end, ranges[next].end);
- ranges.remove(next);
- } else
- break;
- }
-
+ mergeRangesFrom(ranges, i);
return;
}
}
@@ -261,25 +351,95 @@ private:
ranges.append(CharacterRange(lo, hi));
}
- bool m_isCaseInsensitive;
+ void mergeRangesFrom(Vector<CharacterRange>& ranges, size_t index)
+ {
+ size_t next = index + 1;
+
+ // each iteration of the loop we will either remove something from the list, or break out of the loop.
+ while (next < ranges.size()) {
+ if (ranges[next].begin <= (ranges[index].end + 1)) {
+ // the next entry now overlaps / concatenates with this one.
+ ranges[index].end = std::max(ranges[index].end, ranges[next].end);
+ ranges.remove(next);
+ } else
+ break;
+ }
+
+ }
+
+ void coalesceTables()
+ {
+ auto coalesceMatchesAndRanges = [&](Vector<UChar32>& matches, Vector<CharacterRange>& ranges) {
+
+ size_t matchesIndex = 0;
+ size_t rangesIndex = 0;
+
+ while (matchesIndex < matches.size() && rangesIndex < ranges.size()) {
+ while (matchesIndex < matches.size() && matches[matchesIndex] < ranges[rangesIndex].begin - 1)
+ matchesIndex++;
+
+ if (matchesIndex < matches.size() && matches[matchesIndex] == ranges[rangesIndex].begin - 1) {
+ ranges[rangesIndex].begin = matches[matchesIndex];
+ matches.remove(matchesIndex);
+ }
+
+ while (matchesIndex < matches.size() && matches[matchesIndex] < ranges[rangesIndex].end + 1)
+ matchesIndex++;
+
+ if (matchesIndex < matches.size()) {
+ if (matches[matchesIndex] == ranges[rangesIndex].end + 1) {
+ ranges[rangesIndex].end = matches[matchesIndex];
+ matches.remove(matchesIndex);
+
+ mergeRangesFrom(ranges, rangesIndex);
+ } else
+ matchesIndex++;
+ }
+ }
+ };
+
+ coalesceMatchesAndRanges(m_matches, m_ranges);
+ coalesceMatchesAndRanges(m_matchesUnicode, m_rangesUnicode);
+
+ if (!m_matches.size() && !m_matchesUnicode.size()
+ && m_ranges.size() == 1 && m_rangesUnicode.size() == 1
+ && m_ranges[0].begin == 0 && m_ranges[0].end == 0x7f
+ && m_rangesUnicode[0].begin == 0x80 && m_rangesUnicode[0].end == 0x10ffff)
+ m_anyCharacter = true;
+ }
- Vector<UChar> m_matches;
+ bool hasNonBMPCharacters()
+ {
+ return m_hasNonBMPCharacters;
+ }
+
+ bool anyCharacter()
+ {
+ return m_anyCharacter;
+ }
+
+ bool m_isCaseInsensitive : 1;
+ bool m_hasNonBMPCharacters : 1;
+ bool m_anyCharacter : 1;
+ CanonicalMode m_canonicalMode;
+
+ Vector<UChar32> m_matches;
Vector<CharacterRange> m_ranges;
- Vector<UChar> m_matchesUnicode;
+ Vector<UChar32> m_matchesUnicode;
Vector<CharacterRange> m_rangesUnicode;
};
class YarrPatternConstructor {
public:
- YarrPatternConstructor(YarrPattern& pattern)
+ YarrPatternConstructor(YarrPattern& pattern, void* stackLimit)
: m_pattern(pattern)
- , m_characterClassConstructor(pattern.m_ignoreCase)
- , m_invertParentheticalAssertion(false)
+ , m_characterClassConstructor(pattern.ignoreCase(), pattern.unicode() ? CanonicalMode::Unicode : CanonicalMode::UCS2)
+ , m_stackLimit(stackLimit)
{
- OwnPtr<PatternDisjunction> body = adoptPtr(new PatternDisjunction);
+ auto body = std::make_unique<PatternDisjunction>();
m_pattern.m_body = body.get();
m_alternative = body->addNewAlternative();
- m_pattern.m_disjunctions.append(body.release());
+ m_pattern.m_disjunctions.append(WTFMove(body));
}
~YarrPatternConstructor()
@@ -291,15 +451,15 @@ public:
m_pattern.reset();
m_characterClassConstructor.reset();
- OwnPtr<PatternDisjunction> body = adoptPtr(new PatternDisjunction);
+ auto body = std::make_unique<PatternDisjunction>();
m_pattern.m_body = body.get();
m_alternative = body->addNewAlternative();
- m_pattern.m_disjunctions.append(body.release());
+ m_pattern.m_disjunctions.append(WTFMove(body));
}
void assertionBOL()
{
- if (!m_alternative->m_terms.size() & !m_invertParentheticalAssertion) {
+ if (!m_alternative->m_terms.size() && !m_invertParentheticalAssertion) {
m_alternative->m_startsWithBOL = true;
m_alternative->m_containsBOL = true;
m_pattern.m_containsBOL = true;
@@ -315,41 +475,51 @@ public:
m_alternative->m_terms.append(PatternTerm::WordBoundary(invert));
}
- void atomPatternCharacter(UChar ch)
+ void atomPatternCharacter(UChar32 ch)
{
// We handle case-insensitive checking of unicode characters which do have both
// cases by handling them as if they were defined using a CharacterClass.
- if (!m_pattern.m_ignoreCase || isASCII(ch)) {
+ if (!m_pattern.ignoreCase() || (isASCII(ch) && !m_pattern.unicode())) {
m_alternative->m_terms.append(PatternTerm(ch));
return;
}
- UCS2CanonicalizationRange* info = rangeInfoFor(ch);
+ const CanonicalizationRange* info = canonicalRangeInfoFor(ch, m_pattern.unicode() ? CanonicalMode::Unicode : CanonicalMode::UCS2);
if (info->type == CanonicalizeUnique) {
m_alternative->m_terms.append(PatternTerm(ch));
return;
}
m_characterClassConstructor.putUnicodeIgnoreCase(ch, info);
- OwnPtr<CharacterClass> newCharacterClass = m_characterClassConstructor.charClass();
+ auto newCharacterClass = m_characterClassConstructor.charClass();
m_alternative->m_terms.append(PatternTerm(newCharacterClass.get(), false));
- m_pattern.m_userCharacterClasses.append(newCharacterClass.release());
+ m_pattern.m_userCharacterClasses.append(WTFMove(newCharacterClass));
}
void atomBuiltInCharacterClass(BuiltInCharacterClassID classID, bool invert)
{
switch (classID) {
- case DigitClassID:
+ case BuiltInCharacterClassID::DigitClassID:
m_alternative->m_terms.append(PatternTerm(m_pattern.digitsCharacterClass(), invert));
break;
- case SpaceClassID:
+ case BuiltInCharacterClassID::SpaceClassID:
m_alternative->m_terms.append(PatternTerm(m_pattern.spacesCharacterClass(), invert));
break;
- case WordClassID:
- m_alternative->m_terms.append(PatternTerm(m_pattern.wordcharCharacterClass(), invert));
+ case BuiltInCharacterClassID::WordClassID:
+ if (m_pattern.unicode() && m_pattern.ignoreCase())
+ m_alternative->m_terms.append(PatternTerm(m_pattern.wordUnicodeIgnoreCaseCharCharacterClass(), invert));
+ else
+ m_alternative->m_terms.append(PatternTerm(m_pattern.wordcharCharacterClass(), invert));
+ break;
+ case BuiltInCharacterClassID::DotClassID:
+ ASSERT(!invert);
+ if (m_pattern.dotAll())
+ m_alternative->m_terms.append(PatternTerm(m_pattern.anyCharacterClass(), false));
+ else
+ m_alternative->m_terms.append(PatternTerm(m_pattern.newlineCharacterClass(), true));
break;
- case NewlineClassID:
- m_alternative->m_terms.append(PatternTerm(m_pattern.newlineCharacterClass(), invert));
+ default:
+ m_alternative->m_terms.append(PatternTerm(m_pattern.unicodeCharacterClassFor(classID), invert));
break;
}
}
@@ -359,64 +529,83 @@ public:
m_invertCharacterClass = invert;
}
- void atomCharacterClassAtom(UChar ch)
+ void atomCharacterClassAtom(UChar32 ch)
{
m_characterClassConstructor.putChar(ch);
}
- void atomCharacterClassRange(UChar begin, UChar end)
+ void atomCharacterClassRange(UChar32 begin, UChar32 end)
{
m_characterClassConstructor.putRange(begin, end);
}
void atomCharacterClassBuiltIn(BuiltInCharacterClassID classID, bool invert)
{
- ASSERT(classID != NewlineClassID);
+ ASSERT(classID != BuiltInCharacterClassID::DotClassID);
switch (classID) {
- case DigitClassID:
+ case BuiltInCharacterClassID::DigitClassID:
m_characterClassConstructor.append(invert ? m_pattern.nondigitsCharacterClass() : m_pattern.digitsCharacterClass());
break;
- case SpaceClassID:
+ case BuiltInCharacterClassID::SpaceClassID:
m_characterClassConstructor.append(invert ? m_pattern.nonspacesCharacterClass() : m_pattern.spacesCharacterClass());
break;
- case WordClassID:
- m_characterClassConstructor.append(invert ? m_pattern.nonwordcharCharacterClass() : m_pattern.wordcharCharacterClass());
+ case BuiltInCharacterClassID::WordClassID:
+ if (m_pattern.unicode() && m_pattern.ignoreCase())
+ m_characterClassConstructor.append(invert ? m_pattern.nonwordUnicodeIgnoreCaseCharCharacterClass() : m_pattern.wordUnicodeIgnoreCaseCharCharacterClass());
+ else
+ m_characterClassConstructor.append(invert ? m_pattern.nonwordcharCharacterClass() : m_pattern.wordcharCharacterClass());
break;
default:
- RELEASE_ASSERT_NOT_REACHED();
+ if (!invert)
+ m_characterClassConstructor.append(m_pattern.unicodeCharacterClassFor(classID));
+ else
+ m_characterClassConstructor.appendInverted(m_pattern.unicodeCharacterClassFor(classID));
}
}
void atomCharacterClassEnd()
{
- OwnPtr<CharacterClass> newCharacterClass = m_characterClassConstructor.charClass();
+ auto newCharacterClass = m_characterClassConstructor.charClass();
+
+ if (!m_invertCharacterClass && newCharacterClass.get()->m_anyCharacter) {
+ m_alternative->m_terms.append(PatternTerm(m_pattern.anyCharacterClass(), false));
+ return;
+ }
m_alternative->m_terms.append(PatternTerm(newCharacterClass.get(), m_invertCharacterClass));
- m_pattern.m_userCharacterClasses.append(newCharacterClass.release());
+ m_pattern.m_userCharacterClasses.append(WTFMove(newCharacterClass));
}
- void atomParenthesesSubpatternBegin(bool capture = true)
+ void atomParenthesesSubpatternBegin(bool capture = true, std::optional<String> optGroupName = std::nullopt)
{
unsigned subpatternId = m_pattern.m_numSubpatterns + 1;
- if (capture)
+ if (capture) {
m_pattern.m_numSubpatterns++;
+ if (optGroupName) {
+ while (m_pattern.m_captureGroupNames.size() < subpatternId)
+ m_pattern.m_captureGroupNames.append(String());
+ m_pattern.m_captureGroupNames.append(optGroupName.value());
+ m_pattern.m_namedGroupToParenIndex.add(optGroupName.value(), subpatternId);
+ }
+ } else
+ ASSERT(!optGroupName);
- OwnPtr<PatternDisjunction> parenthesesDisjunction = adoptPtr(new PatternDisjunction(m_alternative));
+ auto parenthesesDisjunction = std::make_unique<PatternDisjunction>(m_alternative);
m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, false));
m_alternative = parenthesesDisjunction->addNewAlternative();
- m_pattern.m_disjunctions.append(parenthesesDisjunction.release());
+ m_pattern.m_disjunctions.append(WTFMove(parenthesesDisjunction));
}
void atomParentheticalAssertionBegin(bool invert = false)
{
- OwnPtr<PatternDisjunction> parenthesesDisjunction = adoptPtr(new PatternDisjunction(m_alternative));
+ auto parenthesesDisjunction = std::make_unique<PatternDisjunction>(m_alternative);
m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParentheticalAssertion, m_pattern.m_numSubpatterns + 1, parenthesesDisjunction.get(), false, invert));
m_alternative = parenthesesDisjunction->addNewAlternative();
m_invertParentheticalAssertion = invert;
- m_pattern.m_disjunctions.append(parenthesesDisjunction.release());
+ m_pattern.m_disjunctions.append(WTFMove(parenthesesDisjunction));
}
void atomParenthesesEnd()
@@ -429,8 +618,7 @@ public:
PatternTerm& lastTerm = m_alternative->lastTerm();
- ASSERT(parenthesesDisjunction->m_alternatives.size() <= UINT_MAX);
- unsigned numParenAlternatives = static_cast<unsigned>(parenthesesDisjunction->m_alternatives.size());
+ unsigned numParenAlternatives = parenthesesDisjunction->m_alternatives.size();
unsigned numBOLAnchoredAlts = 0;
for (unsigned i = 0; i < numParenAlternatives; i++) {
@@ -478,16 +666,22 @@ public:
m_alternative->m_terms.append(PatternTerm(subpatternId));
}
- // deep copy the argument disjunction. If filterStartsWithBOL is true,
+ void atomNamedBackReference(String subpatternName)
+ {
+ ASSERT(m_pattern.m_namedGroupToParenIndex.find(subpatternName) != m_pattern.m_namedGroupToParenIndex.end());
+ atomBackReference(m_pattern.m_namedGroupToParenIndex.get(subpatternName));
+ }
+
+ // deep copy the argument disjunction. If filterStartsWithBOL is true,
// skip alternatives with m_startsWithBOL set true.
PatternDisjunction* copyDisjunction(PatternDisjunction* disjunction, bool filterStartsWithBOL = false)
{
- OwnPtr<PatternDisjunction> newDisjunction;
+ std::unique_ptr<PatternDisjunction> newDisjunction;
for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
PatternAlternative* alternative = disjunction->m_alternatives[alt].get();
if (!filterStartsWithBOL || !alternative->m_startsWithBOL) {
if (!newDisjunction) {
- newDisjunction = adoptPtr(new PatternDisjunction());
+ newDisjunction = std::make_unique<PatternDisjunction>();
newDisjunction->m_parent = disjunction->m_parent;
}
PatternAlternative* newAlternative = newDisjunction->addNewAlternative();
@@ -501,7 +695,7 @@ public:
return 0;
PatternDisjunction* copiedDisjunction = newDisjunction.get();
- m_pattern.m_disjunctions.append(newDisjunction.release());
+ m_pattern.m_disjunctions.append(WTFMove(newDisjunction));
return copiedDisjunction;
}
@@ -512,6 +706,7 @@ public:
PatternTerm termCopy = term;
termCopy.parentheses.disjunction = copyDisjunction(termCopy.parentheses.disjunction, filterStartsWithBOL);
+ m_pattern.m_hasCopiedParenSubexpressions = true;
return termCopy;
}
@@ -527,7 +722,7 @@ public:
PatternTerm& term = m_alternative->lastTerm();
ASSERT(term.type > PatternTerm::TypeAssertionWordBoundary);
- ASSERT((term.quantityCount == 1) && (term.quantityType == QuantifierFixedCount));
+ ASSERT(term.quantityMinCount == 1 && term.quantityMaxCount == 1 && term.quantityType == QuantifierFixedCount);
if (term.type == PatternTerm::TypeParentheticalAssertion) {
// If an assertion is quantified with a minimum count of zero, it can simply be removed.
@@ -549,12 +744,12 @@ public:
return;
}
- if (min == 0)
- term.quantify(max, greedy ? QuantifierGreedy : QuantifierNonGreedy);
- else if (min == max)
- term.quantify(min, QuantifierFixedCount);
+ if (min == max)
+ term.quantify(min, max, QuantifierFixedCount);
+ else if (!min || (term.type == PatternTerm::TypeParenthesesSubpattern && m_pattern.m_hasCopiedParenSubexpressions))
+ term.quantify(min, max, greedy ? QuantifierGreedy : QuantifierNonGreedy);
else {
- term.quantify(min, QuantifierFixedCount);
+ term.quantify(min, min, QuantifierFixedCount);
m_alternative->m_terms.append(copyTerm(term));
// NOTE: this term is interesting from an analysis perspective, in that it can be ignored.....
m_alternative->lastTerm().quantify((max == quantifyInfinite) ? max : max - min, greedy ? QuantifierGreedy : QuantifierNonGreedy);
@@ -568,10 +763,14 @@ public:
m_alternative = m_alternative->m_parent->addNewAlternative();
}
- unsigned setupAlternativeOffsets(PatternAlternative* alternative, unsigned currentCallFrameSize, unsigned initialInputPosition)
+ ErrorCode setupAlternativeOffsets(PatternAlternative* alternative, unsigned currentCallFrameSize, unsigned initialInputPosition, unsigned& newCallFrameSize) WARN_UNUSED_RETURN
{
+ if (UNLIKELY(!isSafeToRecurse()))
+ return ErrorCode::TooManyDisjunctions;
+
+ ErrorCode error = ErrorCode::NoError;
alternative->m_hasFixedSize = true;
- Checked<unsigned> currentInputPosition = initialInputPosition;
+ Checked<unsigned, RecordOverflow> currentInputPosition = initialInputPosition;
for (unsigned i = 0; i < alternative->m_terms.size(); ++i) {
PatternTerm& term = alternative->m_terms[i];
@@ -599,8 +798,14 @@ public:
term.frameLocation = currentCallFrameSize;
currentCallFrameSize += YarrStackSpaceForBackTrackInfoPatternCharacter;
alternative->m_hasFixedSize = false;
+ } else if (m_pattern.unicode()) {
+ Checked<unsigned, RecordOverflow> tempCount = term.quantityMaxCount;
+ tempCount *= U16_LENGTH(term.patternCharacter);
+ if (tempCount.hasOverflowed())
+ return ErrorCode::OffsetTooLarge;
+ currentInputPosition += tempCount;
} else
- currentInputPosition += term.quantityCount;
+ currentInputPosition += term.quantityMaxCount;
break;
case PatternTerm::TypeCharacterClass:
@@ -609,29 +814,39 @@ public:
term.frameLocation = currentCallFrameSize;
currentCallFrameSize += YarrStackSpaceForBackTrackInfoCharacterClass;
alternative->m_hasFixedSize = false;
+ } else if (m_pattern.unicode()) {
+ term.frameLocation = currentCallFrameSize;
+ currentCallFrameSize += YarrStackSpaceForBackTrackInfoCharacterClass;
+ currentInputPosition += term.quantityMaxCount;
+ alternative->m_hasFixedSize = false;
} else
- currentInputPosition += term.quantityCount;
+ currentInputPosition += term.quantityMaxCount;
break;
case PatternTerm::TypeParenthesesSubpattern:
// Note: for fixed once parentheses we will ensure at least the minimum is available; others are on their own.
term.frameLocation = currentCallFrameSize;
- if (term.quantityCount == 1 && !term.parentheses.isCopy) {
- if (term.quantityType != QuantifierFixedCount)
- currentCallFrameSize += YarrStackSpaceForBackTrackInfoParenthesesOnce;
- currentCallFrameSize = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet());
+ if (term.quantityMaxCount == 1 && !term.parentheses.isCopy) {
+ currentCallFrameSize += YarrStackSpaceForBackTrackInfoParenthesesOnce;
+ error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet(), currentCallFrameSize);
+ if (hasError(error))
+ return error;
// If quantity is fixed, then pre-check its minimum size.
if (term.quantityType == QuantifierFixedCount)
currentInputPosition += term.parentheses.disjunction->m_minimumSize;
term.inputPosition = currentInputPosition.unsafeGet();
} else if (term.parentheses.isTerminal) {
currentCallFrameSize += YarrStackSpaceForBackTrackInfoParenthesesTerminal;
- currentCallFrameSize = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet());
+ error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet(), currentCallFrameSize);
+ if (hasError(error))
+ return error;
term.inputPosition = currentInputPosition.unsafeGet();
} else {
term.inputPosition = currentInputPosition.unsafeGet();
- setupDisjunctionOffsets(term.parentheses.disjunction, 0, currentInputPosition.unsafeGet());
currentCallFrameSize += YarrStackSpaceForBackTrackInfoParentheses;
+ error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize, currentInputPosition.unsafeGet(), currentCallFrameSize);
+ if (hasError(error))
+ return error;
}
// Fixed count of 1 could be accepted, if they have a fixed size *AND* if all alternatives are of the same length.
alternative->m_hasFixedSize = false;
@@ -640,35 +855,53 @@ public:
case PatternTerm::TypeParentheticalAssertion:
term.inputPosition = currentInputPosition.unsafeGet();
term.frameLocation = currentCallFrameSize;
- currentCallFrameSize = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize + YarrStackSpaceForBackTrackInfoParentheticalAssertion, currentInputPosition.unsafeGet());
+ error = setupDisjunctionOffsets(term.parentheses.disjunction, currentCallFrameSize + YarrStackSpaceForBackTrackInfoParentheticalAssertion, currentInputPosition.unsafeGet(), currentCallFrameSize);
+ if (hasError(error))
+ return error;
break;
case PatternTerm::TypeDotStarEnclosure:
+ ASSERT(!m_pattern.m_saveInitialStartValue);
alternative->m_hasFixedSize = false;
term.inputPosition = initialInputPosition;
+ m_pattern.m_initialStartValueFrameLocation = currentCallFrameSize;
+ currentCallFrameSize += YarrStackSpaceForDotStarEnclosure;
+ m_pattern.m_saveInitialStartValue = true;
break;
}
+ if (currentInputPosition.hasOverflowed())
+ return ErrorCode::OffsetTooLarge;
}
alternative->m_minimumSize = (currentInputPosition - initialInputPosition).unsafeGet();
- return currentCallFrameSize;
+ newCallFrameSize = currentCallFrameSize;
+ return error;
}
- unsigned setupDisjunctionOffsets(PatternDisjunction* disjunction, unsigned initialCallFrameSize, unsigned initialInputPosition)
+ ErrorCode setupDisjunctionOffsets(PatternDisjunction* disjunction, unsigned initialCallFrameSize, unsigned initialInputPosition, unsigned& callFrameSize)
{
+ if (UNLIKELY(!isSafeToRecurse()))
+ return ErrorCode::TooManyDisjunctions;
+
if ((disjunction != m_pattern.m_body) && (disjunction->m_alternatives.size() > 1))
initialCallFrameSize += YarrStackSpaceForBackTrackInfoAlternative;
unsigned minimumInputSize = UINT_MAX;
unsigned maximumCallFrameSize = 0;
bool hasFixedSize = true;
+ ErrorCode error = ErrorCode::NoError;
for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
PatternAlternative* alternative = disjunction->m_alternatives[alt].get();
- unsigned currentAlternativeCallFrameSize = setupAlternativeOffsets(alternative, initialCallFrameSize, initialInputPosition);
+ unsigned currentAlternativeCallFrameSize;
+ error = setupAlternativeOffsets(alternative, initialCallFrameSize, initialInputPosition, currentAlternativeCallFrameSize);
+ if (hasError(error))
+ return error;
minimumInputSize = std::min(minimumInputSize, alternative->m_minimumSize);
maximumCallFrameSize = std::max(maximumCallFrameSize, currentAlternativeCallFrameSize);
hasFixedSize &= alternative->m_hasFixedSize;
+ if (alternative->m_minimumSize > INT_MAX)
+ m_pattern.m_containsUnsignedLengthPattern = true;
}
ASSERT(minimumInputSize != UINT_MAX);
@@ -677,12 +910,15 @@ public:
disjunction->m_hasFixedSize = hasFixedSize;
disjunction->m_minimumSize = minimumInputSize;
disjunction->m_callFrameSize = maximumCallFrameSize;
- return maximumCallFrameSize;
+ callFrameSize = maximumCallFrameSize;
+ return error;
}
- void setupOffsets()
+ ErrorCode setupOffsets()
{
- setupDisjunctionOffsets(m_pattern.m_body, 0, 0);
+ // FIXME: Yarr should not use the stack to handle subpatterns (rdar://problem/26436314).
+ unsigned ignoredCallFrameSize;
+ return setupDisjunctionOffsets(m_pattern.m_body, 0, 0, ignoredCallFrameSize);
}
// This optimization identifies sets of parentheses that we will never need to backtrack.
@@ -699,14 +935,15 @@ public:
if (m_pattern.m_numSubpatterns)
return;
- Vector<OwnPtr<PatternAlternative> >& alternatives = m_pattern.m_body->m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>>& alternatives = m_pattern.m_body->m_alternatives;
for (size_t i = 0; i < alternatives.size(); ++i) {
Vector<PatternTerm>& terms = alternatives[i]->m_terms;
if (terms.size()) {
PatternTerm& term = terms.last();
if (term.type == PatternTerm::TypeParenthesesSubpattern
&& term.quantityType == QuantifierGreedy
- && term.quantityCount == quantifyInfinite
+ && term.quantityMinCount == 0
+ && term.quantityMaxCount == quantifyInfinite
&& !term.capture())
term.parentheses.isTerminal = true;
}
@@ -722,7 +959,7 @@ public:
// At this point, this is only valid for non-multiline expressions.
PatternDisjunction* disjunction = m_pattern.m_body;
- if (!m_pattern.m_containsBOL || m_pattern.m_multiline)
+ if (!m_pattern.m_containsBOL || m_pattern.multiline())
return;
PatternDisjunction* loopDisjunction = copyDisjunction(disjunction, true);
@@ -740,11 +977,12 @@ public:
}
}
- bool containsCapturingTerms(PatternAlternative* alternative, size_t firstTermIndex, size_t lastTermIndex)
+ bool containsCapturingTerms(PatternAlternative* alternative, size_t firstTermIndex, size_t endIndex)
{
Vector<PatternTerm>& terms = alternative->m_terms;
- for (size_t termIndex = firstTermIndex; termIndex <= lastTermIndex; ++termIndex) {
+ ASSERT(endIndex <= terms.size());
+ for (size_t termIndex = firstTermIndex; termIndex < endIndex; ++termIndex) {
PatternTerm& term = terms[termIndex];
if (term.m_capture)
@@ -753,7 +991,7 @@ public:
if (term.type == PatternTerm::TypeParenthesesSubpattern) {
PatternDisjunction* nestedDisjunction = term.parentheses.disjunction;
for (unsigned alt = 0; alt < nestedDisjunction->m_alternatives.size(); ++alt) {
- if (containsCapturingTerms(nestedDisjunction->m_alternatives[alt].get(), 0, nestedDisjunction->m_alternatives[alt]->m_terms.size() - 1))
+ if (containsCapturingTerms(nestedDisjunction->m_alternatives[alt].get(), 0, nestedDisjunction->m_alternatives[alt]->m_terms.size()))
return true;
}
}
@@ -769,16 +1007,17 @@ public:
// beginning and the end of the match.
void optimizeDotStarWrappedExpressions()
{
- Vector<OwnPtr<PatternAlternative> >& alternatives = m_pattern.m_body->m_alternatives;
+ Vector<std::unique_ptr<PatternAlternative>>& alternatives = m_pattern.m_body->m_alternatives;
if (alternatives.size() != 1)
return;
+ CharacterClass* dotCharacterClass = m_pattern.dotAll() ? m_pattern.anyCharacterClass() : m_pattern.newlineCharacterClass();
PatternAlternative* alternative = alternatives[0].get();
Vector<PatternTerm>& terms = alternative->m_terms;
if (terms.size() >= 3) {
bool startsWithBOL = false;
bool endsWithEOL = false;
- size_t termIndex, firstExpressionTerm, lastExpressionTerm;
+ size_t termIndex, firstExpressionTerm;
termIndex = 0;
if (terms[termIndex].type == PatternTerm::TypeAssertionBOL) {
@@ -787,7 +1026,10 @@ public:
}
PatternTerm& firstNonAnchorTerm = terms[termIndex];
- if ((firstNonAnchorTerm.type != PatternTerm::TypeCharacterClass) || (firstNonAnchorTerm.characterClass != m_pattern.newlineCharacterClass()) || !((firstNonAnchorTerm.quantityType == QuantifierGreedy) || (firstNonAnchorTerm.quantityType == QuantifierNonGreedy)))
+ if (firstNonAnchorTerm.type != PatternTerm::TypeCharacterClass
+ || firstNonAnchorTerm.characterClass != dotCharacterClass
+ || firstNonAnchorTerm.quantityMinCount
+ || firstNonAnchorTerm.quantityMaxCount != quantifyInfinite)
return;
firstExpressionTerm = termIndex + 1;
@@ -799,16 +1041,19 @@ public:
}
PatternTerm& lastNonAnchorTerm = terms[termIndex];
- if ((lastNonAnchorTerm.type != PatternTerm::TypeCharacterClass) || (lastNonAnchorTerm.characterClass != m_pattern.newlineCharacterClass()) || (lastNonAnchorTerm.quantityType != QuantifierGreedy))
+ if (lastNonAnchorTerm.type != PatternTerm::TypeCharacterClass
+ || lastNonAnchorTerm.characterClass != dotCharacterClass
+ || lastNonAnchorTerm.quantityType != QuantifierGreedy
+ || lastNonAnchorTerm.quantityMinCount
+ || lastNonAnchorTerm.quantityMaxCount != quantifyInfinite)
return;
-
- lastExpressionTerm = termIndex - 1;
- if (firstExpressionTerm > lastExpressionTerm)
+ size_t endIndex = termIndex;
+ if (firstExpressionTerm >= endIndex)
return;
- if (!containsCapturingTerms(alternative, firstExpressionTerm, lastExpressionTerm)) {
- for (termIndex = terms.size() - 1; termIndex > lastExpressionTerm; --termIndex)
+ if (!containsCapturingTerms(alternative, firstExpressionTerm, endIndex)) {
+ for (termIndex = terms.size() - 1; termIndex >= endIndex; --termIndex)
terms.remove(termIndex);
for (termIndex = firstExpressionTerm; termIndex > 0; --termIndex)
@@ -822,62 +1067,445 @@ public:
}
private:
+ bool isSafeToRecurse() const
+ {
+ if (!m_stackLimit)
+ return true;
+ int8_t* curr = reinterpret_cast<int8_t*>(&curr);
+ int8_t* limit = reinterpret_cast<int8_t*>(m_stackLimit);
+ return curr >= limit;
+ }
+
YarrPattern& m_pattern;
PatternAlternative* m_alternative;
CharacterClassConstructor m_characterClassConstructor;
+ void* m_stackLimit;
bool m_invertCharacterClass;
- bool m_invertParentheticalAssertion;
+ bool m_invertParentheticalAssertion { false };
};
-const char* YarrPattern::compile(const String& patternString)
+ErrorCode YarrPattern::compile(const String& patternString, void* stackLimit)
{
- YarrPatternConstructor constructor(*this);
+ YarrPatternConstructor constructor(*this, stackLimit);
- if (const char* error = parse(constructor, patternString))
- return error;
+ if (m_flags == InvalidFlags)
+ return ErrorCode::InvalidRegularExpressionFlags;
+
+ {
+ ErrorCode error = parse(constructor, patternString, unicode());
+ if (hasError(error))
+ return error;
+ }
// If the pattern contains illegal backreferences reset & reparse.
// Quoting Netscape's "What's new in JavaScript 1.2",
// "Note: if the number of left parentheses is less than the number specified
// in \#, the \# is taken as an octal escape as described in the next row."
if (containsIllegalBackReference()) {
+ if (unicode())
+ return ErrorCode::InvalidBackreference;
+
unsigned numSubpatterns = m_numSubpatterns;
constructor.reset();
-#if !ASSERT_DISABLED
- const char* error =
-#endif
- parse(constructor, patternString, numSubpatterns);
-
- ASSERT(!error);
+ ErrorCode error = parse(constructor, patternString, unicode(), numSubpatterns);
+ ASSERT_UNUSED(error, !hasError(error));
ASSERT(numSubpatterns == m_numSubpatterns);
}
constructor.checkForTerminalParentheses();
constructor.optimizeDotStarWrappedExpressions();
constructor.optimizeBOL();
-
- constructor.setupOffsets();
- return 0;
+ {
+ ErrorCode error = constructor.setupOffsets();
+ if (hasError(error))
+ return error;
+ }
+
+ if (Options::dumpCompiledRegExpPatterns())
+ dumpPattern(patternString);
+
+ return ErrorCode::NoError;
}
-YarrPattern::YarrPattern(const String& pattern, bool ignoreCase, bool multiline, const char** error)
- : m_ignoreCase(ignoreCase)
- , m_multiline(multiline)
- , m_containsBackreferences(false)
+YarrPattern::YarrPattern(const String& pattern, RegExpFlags flags, ErrorCode& error, void* stackLimit)
+ : m_containsBackreferences(false)
, m_containsBOL(false)
- , m_numSubpatterns(0)
- , m_maxBackReference(0)
- , newlineCached(0)
- , digitsCached(0)
- , spacesCached(0)
- , wordcharCached(0)
- , nondigitsCached(0)
- , nonspacesCached(0)
- , nonwordcharCached(0)
+ , m_containsUnsignedLengthPattern(false)
+ , m_hasCopiedParenSubexpressions(false)
+ , m_saveInitialStartValue(false)
+ , m_flags(flags)
+{
+ error = compile(pattern, stackLimit);
+}
+
+void indentForNestingLevel(PrintStream& out, unsigned nestingDepth)
+{
+ out.print(" ");
+ for (; nestingDepth; --nestingDepth)
+ out.print(" ");
+}
+
+void dumpUChar32(PrintStream& out, UChar32 c)
+{
+ if (c >= ' '&& c <= 0xff)
+ out.printf("'%c'", static_cast<char>(c));
+ else
+ out.printf("0x%04x", c);
+}
+
+void dumpCharacterClass(PrintStream& out, YarrPattern* pattern, CharacterClass* characterClass)
+{
+ if (characterClass == pattern->anyCharacterClass())
+ out.print("<any character>");
+ else if (characterClass == pattern->newlineCharacterClass())
+ out.print("<newline>");
+ else if (characterClass == pattern->digitsCharacterClass())
+ out.print("<digits>");
+ else if (characterClass == pattern->spacesCharacterClass())
+ out.print("<whitespace>");
+ else if (characterClass == pattern->wordcharCharacterClass())
+ out.print("<word>");
+ else if (characterClass == pattern->wordUnicodeIgnoreCaseCharCharacterClass())
+ out.print("<unicode ignore case>");
+ else if (characterClass == pattern->nondigitsCharacterClass())
+ out.print("<non-digits>");
+ else if (characterClass == pattern->nonspacesCharacterClass())
+ out.print("<non-whitespace>");
+ else if (characterClass == pattern->nonwordcharCharacterClass())
+ out.print("<non-word>");
+ else if (characterClass == pattern->nonwordUnicodeIgnoreCaseCharCharacterClass())
+ out.print("<unicode non-ignore case>");
+ else {
+ bool needMatchesRangesSeperator = false;
+
+ auto dumpMatches = [&] (const char* prefix, Vector<UChar32> matches) {
+ size_t matchesSize = matches.size();
+ if (matchesSize) {
+ if (needMatchesRangesSeperator)
+ out.print(",");
+ needMatchesRangesSeperator = true;
+
+ out.print(prefix, ":(");
+ for (size_t i = 0; i < matchesSize; ++i) {
+ if (i)
+ out.print(",");
+ dumpUChar32(out, matches[i]);
+ }
+ out.print(")");
+ }
+ };
+
+ auto dumpRanges = [&] (const char* prefix, Vector<CharacterRange> ranges) {
+ size_t rangeSize = ranges.size();
+ if (rangeSize) {
+ if (needMatchesRangesSeperator)
+ out.print(",");
+ needMatchesRangesSeperator = true;
+
+ out.print(prefix, " ranges:(");
+ for (size_t i = 0; i < rangeSize; ++i) {
+ if (i)
+ out.print(",");
+ CharacterRange range = ranges[i];
+ out.print("(");
+ dumpUChar32(out, range.begin);
+ out.print("..");
+ dumpUChar32(out, range.end);
+ out.print(")");
+ }
+ out.print(")");
+ }
+ };
+
+ out.print("[");
+ dumpMatches("ASCII", characterClass->m_matches);
+ dumpRanges("ASCII", characterClass->m_ranges);
+ dumpMatches("Unicode", characterClass->m_matchesUnicode);
+ dumpRanges("Unicode", characterClass->m_rangesUnicode);
+ out.print("]");
+ }
+}
+
+void PatternAlternative::dump(PrintStream& out, YarrPattern* thisPattern, unsigned nestingDepth)
+{
+ out.print("minimum size: ", m_minimumSize);
+ if (m_hasFixedSize)
+ out.print(",fixed size");
+ if (m_onceThrough)
+ out.print(",once through");
+ if (m_startsWithBOL)
+ out.print(",starts with ^");
+ if (m_containsBOL)
+ out.print(",contains ^");
+ out.print("\n");
+
+ for (size_t i = 0; i < m_terms.size(); ++i)
+ m_terms[i].dump(out, thisPattern, nestingDepth);
+}
+
+void PatternTerm::dumpQuantifier(PrintStream& out)
+{
+ if (quantityType == QuantifierFixedCount && quantityMinCount == 1 && quantityMaxCount == 1)
+ return;
+ out.print(" {", quantityMinCount.unsafeGet());
+ if (quantityMinCount != quantityMaxCount) {
+ if (quantityMaxCount == UINT_MAX)
+ out.print(",...");
+ else
+ out.print(",", quantityMaxCount.unsafeGet());
+ }
+ out.print("}");
+ if (quantityType == QuantifierGreedy)
+ out.print(" greedy");
+ else if (quantityType == QuantifierNonGreedy)
+ out.print(" non-greedy");
+}
+
+void PatternTerm::dump(PrintStream& out, YarrPattern* thisPattern, unsigned nestingDepth)
+{
+ indentForNestingLevel(out, nestingDepth);
+
+ if (type != TypeParenthesesSubpattern && type != TypeParentheticalAssertion) {
+ if (invert())
+ out.print("not ");
+ }
+
+ switch (type) {
+ case TypeAssertionBOL:
+ out.println("BOL");
+ break;
+ case TypeAssertionEOL:
+ out.println("EOL");
+ break;
+ case TypeAssertionWordBoundary:
+ out.println("word boundary");
+ break;
+ case TypePatternCharacter:
+ out.printf("character ");
+ out.printf("inputPosition %u ", inputPosition);
+ if (thisPattern->ignoreCase() && isASCIIAlpha(patternCharacter)) {
+ dumpUChar32(out, toASCIIUpper(patternCharacter));
+ out.print("/");
+ dumpUChar32(out, toASCIILower(patternCharacter));
+ } else
+ dumpUChar32(out, patternCharacter);
+ dumpQuantifier(out);
+ if (quantityType != QuantifierFixedCount)
+ out.print(",frame location ", frameLocation);
+ out.println();
+ break;
+ case TypeCharacterClass:
+ out.print("character class ");
+ if (characterClass->m_anyCharacter)
+ out.print("<any character>");
+ else if (characterClass == thisPattern->newlineCharacterClass())
+ out.print("<newline>");
+ else if (characterClass == thisPattern->digitsCharacterClass())
+ out.print("<digits>");
+ else if (characterClass == thisPattern->spacesCharacterClass())
+ out.print("<whitespace>");
+ else if (characterClass == thisPattern->wordcharCharacterClass())
+ out.print("<word>");
+ else if (characterClass == thisPattern->wordUnicodeIgnoreCaseCharCharacterClass())
+ out.print("<unicode ignore case>");
+ else if (characterClass == thisPattern->nondigitsCharacterClass())
+ out.print("<non-digits>");
+ else if (characterClass == thisPattern->nonspacesCharacterClass())
+ out.print("<non-whitespace>");
+ else if (characterClass == thisPattern->nonwordcharCharacterClass())
+ out.print("<non-word>");
+ else if (characterClass == thisPattern->nonwordUnicodeIgnoreCaseCharCharacterClass())
+ out.print("<unicode non-ignore case>");
+ else {
+ bool needMatchesRangesSeperator = false;
+
+ auto dumpMatches = [&] (const char* prefix, Vector<UChar32> matches) {
+ size_t matchesSize = matches.size();
+ if (matchesSize) {
+ if (needMatchesRangesSeperator)
+ out.print(",");
+ needMatchesRangesSeperator = true;
+
+ out.print(prefix, ":(");
+ for (size_t i = 0; i < matchesSize; ++i) {
+ if (i)
+ out.print(",");
+ dumpUChar32(out, matches[i]);
+ }
+ out.print(")");
+ }
+ };
+
+ auto dumpRanges = [&] (const char* prefix, Vector<CharacterRange> ranges) {
+ size_t rangeSize = ranges.size();
+ if (rangeSize) {
+ if (needMatchesRangesSeperator)
+ out.print(",");
+ needMatchesRangesSeperator = true;
+
+ out.print(prefix, " ranges:(");
+ for (size_t i = 0; i < rangeSize; ++i) {
+ if (i)
+ out.print(",");
+ CharacterRange range = ranges[i];
+ out.print("(");
+ dumpUChar32(out, range.begin);
+ out.print("..");
+ dumpUChar32(out, range.end);
+ out.print(")");
+ }
+ out.print(")");
+ }
+ };
+
+ out.print("[");
+ dumpMatches("ASCII", characterClass->m_matches);
+ dumpRanges("ASCII", characterClass->m_ranges);
+ dumpMatches("Unicode", characterClass->m_matchesUnicode);
+ dumpRanges("Unicode", characterClass->m_rangesUnicode);
+ out.print("]");
+ }
+ dumpQuantifier(out);
+ if (quantityType != QuantifierFixedCount || thisPattern->unicode())
+ out.print(",frame location ", frameLocation);
+ out.println();
+ break;
+ case TypeBackReference:
+ out.print("back reference to subpattern #", backReferenceSubpatternId);
+ out.println(",frame location ", frameLocation);
+ break;
+ case TypeForwardReference:
+ out.println("forward reference");
+ break;
+ case TypeParenthesesSubpattern:
+ if (m_capture)
+ out.print("captured ");
+ else
+ out.print("non-captured ");
+
+ FALLTHROUGH;
+ case TypeParentheticalAssertion:
+ if (m_invert)
+ out.print("inverted ");
+
+ if (type == TypeParenthesesSubpattern)
+ out.print("subpattern");
+ else if (type == TypeParentheticalAssertion)
+ out.print("assertion");
+
+ if (m_capture)
+ out.print(" #", parentheses.subpatternId);
+
+ dumpQuantifier(out);
+
+ if (parentheses.isCopy)
+ out.print(",copy");
+
+ if (parentheses.isTerminal)
+ out.print(",terminal");
+
+ out.println(",frame location ", frameLocation);
+
+ if (parentheses.disjunction->m_alternatives.size() > 1) {
+ indentForNestingLevel(out, nestingDepth + 1);
+ unsigned alternativeFrameLocation = frameLocation;
+ if (quantityMaxCount == 1 && !parentheses.isCopy)
+ alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesOnce;
+ else if (parentheses.isTerminal)
+ alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParenthesesTerminal;
+ else
+ alternativeFrameLocation += YarrStackSpaceForBackTrackInfoParentheses;
+ out.println("alternative list,frame location ", alternativeFrameLocation);
+ }
+
+ parentheses.disjunction->dump(out, thisPattern, nestingDepth + 1);
+ break;
+ case TypeDotStarEnclosure:
+ out.println(".* enclosure,frame location ", thisPattern->m_initialStartValueFrameLocation);
+ break;
+ }
+}
+
+void PatternDisjunction::dump(PrintStream& out, YarrPattern* thisPattern, unsigned nestingDepth = 0)
+{
+ unsigned alternativeCount = m_alternatives.size();
+ for (unsigned i = 0; i < alternativeCount; ++i) {
+ indentForNestingLevel(out, nestingDepth);
+ if (alternativeCount > 1)
+ out.print("alternative #", i, ": ");
+ m_alternatives[i].get()->dump(out, thisPattern, nestingDepth + (alternativeCount > 1));
+ }
+}
+
+void YarrPattern::dumpPattern(const String& patternString)
+{
+ dumpPattern(WTF::dataFile(), patternString);
+}
+
+void YarrPattern::dumpPattern(PrintStream& out, const String& patternString)
+{
+ out.print("RegExp pattern for /");
+ out.print(patternString);
+ out.print("/");
+ if (global())
+ out.print("g");
+ if (ignoreCase())
+ out.print("i");
+ if (multiline())
+ out.print("m");
+ if (unicode())
+ out.print("u");
+ if (sticky())
+ out.print("y");
+ if (m_flags != NoFlags) {
+ bool printSeperator = false;
+ out.print(" (");
+ if (global()) {
+ out.print("global");
+ printSeperator = true;
+ }
+ if (ignoreCase()) {
+ if (printSeperator)
+ out.print("|");
+ out.print("ignore case");
+ printSeperator = true;
+ }
+ if (multiline()) {
+ if (printSeperator)
+ out.print("|");
+ out.print("multiline");
+ printSeperator = true;
+ }
+ if (unicode()) {
+ if (printSeperator)
+ out.print("|");
+ out.print("unicode");
+ printSeperator = true;
+ }
+ if (sticky()) {
+ if (printSeperator)
+ out.print("|");
+ out.print("sticky");
+ printSeperator = true;
+ }
+ out.print(")");
+ }
+ out.print(":\n");
+ if (m_body->m_callFrameSize)
+ out.print(" callframe size: ", m_body->m_callFrameSize, "\n");
+ m_body->dump(out, this);
+}
+
+std::unique_ptr<CharacterClass> anycharCreate()
{
- *error = compile(pattern);
+ auto characterClass = std::make_unique<CharacterClass>();
+ characterClass->m_ranges.append(CharacterRange(0x00, 0x7f));
+ characterClass->m_rangesUnicode.append(CharacterRange(0x0080, 0x10ffff));
+ characterClass->m_hasNonBMPCharacters = true;
+ characterClass->m_anyCharacter = true;
+ return characterClass;
}
-} }
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrPattern.h b/src/3rdparty/masm/yarr/YarrPattern.h
index e7d187c2b3..59decbac46 100644
--- a/src/3rdparty/masm/yarr/YarrPattern.h
+++ b/src/3rdparty/masm/yarr/YarrPattern.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2013-2017 Apple Inc. All rights reserved.
* Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged
*
* Redistribution and use in source and binary forms, with or without
@@ -24,26 +24,27 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef YarrPattern_h
-#define YarrPattern_h
+#pragma once
+#include "RegExpKey.h"
+#include "YarrErrorCode.h"
+#include "YarrUnicodeProperties.h"
#include <wtf/CheckedArithmetic.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
+#include <wtf/HashMap.h>
+#include <wtf/PrintStream.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
-#include <wtf/unicode/Unicode.h>
namespace JSC { namespace Yarr {
+struct YarrPattern;
struct PatternDisjunction;
struct CharacterRange {
- UChar begin;
- UChar end;
+ UChar32 begin { 0 };
+ UChar32 end { 0x10ffff };
- CharacterRange(UChar begin, UChar end)
+ CharacterRange(UChar32 begin, UChar32 end)
: begin(begin)
, end(end)
{
@@ -58,20 +59,38 @@ public:
// specified matches and ranges)
CharacterClass()
: m_table(0)
+ , m_hasNonBMPCharacters(false)
+ , m_anyCharacter(false)
{
}
CharacterClass(const char* table, bool inverted)
: m_table(table)
, m_tableInverted(inverted)
+ , m_hasNonBMPCharacters(false)
+ , m_anyCharacter(false)
{
}
- Vector<UChar> m_matches;
+ CharacterClass(std::initializer_list<UChar32> matches, std::initializer_list<CharacterRange> ranges, std::initializer_list<UChar32> matchesUnicode, std::initializer_list<CharacterRange> rangesUnicode)
+ : m_matches(matches)
+ , m_ranges(ranges)
+ , m_matchesUnicode(matchesUnicode)
+ , m_rangesUnicode(rangesUnicode)
+ , m_table(0)
+ , m_tableInverted(false)
+ , m_hasNonBMPCharacters(false)
+ , m_anyCharacter(false)
+ {
+ }
+
+ Vector<UChar32> m_matches;
Vector<CharacterRange> m_ranges;
- Vector<UChar> m_matchesUnicode;
+ Vector<UChar32> m_matchesUnicode;
Vector<CharacterRange> m_rangesUnicode;
const char* m_table;
- bool m_tableInverted;
+ bool m_tableInverted : 1;
+ bool m_hasNonBMPCharacters : 1;
+ bool m_anyCharacter : 1;
};
enum QuantifierType {
@@ -96,7 +115,7 @@ struct PatternTerm {
bool m_capture :1;
bool m_invert :1;
union {
- UChar patternCharacter;
+ UChar32 patternCharacter;
CharacterClass* characterClass;
unsigned backReferenceSubpatternId;
struct {
@@ -112,18 +131,19 @@ struct PatternTerm {
} anchors;
};
QuantifierType quantityType;
- Checked<unsigned> quantityCount;
- int inputPosition;
+ Checked<unsigned> quantityMinCount;
+ Checked<unsigned> quantityMaxCount;
+ unsigned inputPosition;
unsigned frameLocation;
- PatternTerm(UChar ch)
+ PatternTerm(UChar32 ch)
: type(PatternTerm::TypePatternCharacter)
, m_capture(false)
, m_invert(false)
{
patternCharacter = ch;
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
PatternTerm(CharacterClass* charClass, bool invert)
@@ -133,7 +153,7 @@ struct PatternTerm {
{
characterClass = charClass;
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
PatternTerm(Type type, unsigned subpatternId, PatternDisjunction* disjunction, bool capture = false, bool invert = false)
@@ -146,7 +166,7 @@ struct PatternTerm {
parentheses.isCopy = false;
parentheses.isTerminal = false;
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
PatternTerm(Type type, bool invert = false)
@@ -155,7 +175,7 @@ struct PatternTerm {
, m_invert(invert)
{
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
PatternTerm(unsigned spatternId)
@@ -165,7 +185,7 @@ struct PatternTerm {
{
backReferenceSubpatternId = spatternId;
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
PatternTerm(bool bolAnchor, bool eolAnchor)
@@ -176,7 +196,7 @@ struct PatternTerm {
anchors.bolAnchor = bolAnchor;
anchors.eolAnchor = eolAnchor;
quantityType = QuantifierFixedCount;
- quantityCount = 1;
+ quantityMinCount = quantityMaxCount = 1;
}
static PatternTerm ForwardReference()
@@ -208,12 +228,32 @@ struct PatternTerm {
{
return m_capture;
}
-
+
+ bool containsAnyCaptures()
+ {
+ ASSERT(this->type == TypeParenthesesSubpattern);
+ return parentheses.lastSubpatternId >= parentheses.subpatternId;
+ }
+
void quantify(unsigned count, QuantifierType type)
{
- quantityCount = count;
+ quantityMinCount = 0;
+ quantityMaxCount = count;
quantityType = type;
}
+
+ void quantify(unsigned minCount, unsigned maxCount, QuantifierType type)
+ {
+ // Currently only Parentheses can specify a non-zero min with a different max.
+ ASSERT(this->type == TypeParenthesesSubpattern || !minCount || minCount == maxCount);
+ ASSERT(minCount <= maxCount);
+ quantityMinCount = minCount;
+ quantityMaxCount = maxCount;
+ quantityType = type;
+ }
+
+ void dumpQuantifier(PrintStream&);
+ void dump(PrintStream&, YarrPattern*, unsigned);
};
struct PatternAlternative {
@@ -250,6 +290,8 @@ public:
return m_onceThrough;
}
+ void dump(PrintStream&, YarrPattern*, unsigned);
+
Vector<PatternTerm> m_terms;
PatternDisjunction* m_parent;
unsigned m_minimumSize;
@@ -270,12 +312,13 @@ public:
PatternAlternative* addNewAlternative()
{
- PatternAlternative* alternative = new PatternAlternative(this);
- m_alternatives.append(adoptPtr(alternative));
- return alternative;
+ m_alternatives.append(std::make_unique<PatternAlternative>(this));
+ return static_cast<PatternAlternative*>(m_alternatives.last().get());
}
- Vector<OwnPtr<PatternAlternative> > m_alternatives;
+ void dump(PrintStream&, YarrPattern*, unsigned);
+
+ Vector<std::unique_ptr<PatternAlternative>> m_alternatives;
PatternAlternative* m_parent;
unsigned m_minimumSize;
unsigned m_callFrameSize;
@@ -286,13 +329,17 @@ public:
// (please to be calling newlineCharacterClass() et al on your
// friendly neighborhood YarrPattern instance to get nicely
// cached copies).
-CharacterClass* newlineCreate();
-CharacterClass* digitsCreate();
-CharacterClass* spacesCreate();
-CharacterClass* wordcharCreate();
-CharacterClass* nondigitsCreate();
-CharacterClass* nonspacesCreate();
-CharacterClass* nonwordcharCreate();
+
+std::unique_ptr<CharacterClass> anycharCreate();
+std::unique_ptr<CharacterClass> newlineCreate();
+std::unique_ptr<CharacterClass> digitsCreate();
+std::unique_ptr<CharacterClass> spacesCreate();
+std::unique_ptr<CharacterClass> wordcharCreate();
+std::unique_ptr<CharacterClass> wordUnicodeIgnoreCaseCharCreate();
+std::unique_ptr<CharacterClass> nondigitsCreate();
+std::unique_ptr<CharacterClass> nonspacesCreate();
+std::unique_ptr<CharacterClass> nonwordcharCreate();
+std::unique_ptr<CharacterClass> nonwordUnicodeIgnoreCaseCharCreate();
struct TermChain {
TermChain(PatternTerm term)
@@ -303,27 +350,37 @@ struct TermChain {
Vector<TermChain> hotTerms;
};
+
struct YarrPattern {
- JS_EXPORT_PRIVATE YarrPattern(const String& pattern, bool ignoreCase, bool multiline, const char** error);
+ JS_EXPORT_PRIVATE YarrPattern(const String& pattern, RegExpFlags, ErrorCode&, void* stackLimit = nullptr);
void reset()
{
m_numSubpatterns = 0;
m_maxBackReference = 0;
+ m_initialStartValueFrameLocation = 0;
m_containsBackreferences = false;
m_containsBOL = false;
-
- newlineCached = 0;
- digitsCached = 0;
- spacesCached = 0;
- wordcharCached = 0;
- nondigitsCached = 0;
- nonspacesCached = 0;
- nonwordcharCached = 0;
+ m_containsUnsignedLengthPattern = false;
+ m_hasCopiedParenSubexpressions = false;
+ m_saveInitialStartValue = false;
+
+ anycharCached = nullptr;
+ newlineCached = nullptr;
+ digitsCached = nullptr;
+ spacesCached = nullptr;
+ wordcharCached = nullptr;
+ wordUnicodeIgnoreCaseCharCached = nullptr;
+ nondigitsCached = nullptr;
+ nonspacesCached = nullptr;
+ nonwordcharCached = nullptr;
+ nonwordUnicodeIgnoreCasecharCached = nullptr;
+ unicodePropertiesCached.clear();
m_disjunctions.clear();
m_userCharacterClasses.clear();
+ m_captureGroupNames.shrink(0);
}
bool containsIllegalBackReference()
@@ -331,71 +388,212 @@ struct YarrPattern {
return m_maxBackReference > m_numSubpatterns;
}
+ bool containsUnsignedLengthPattern()
+ {
+ return m_containsUnsignedLengthPattern;
+ }
+
+ CharacterClass* anyCharacterClass()
+ {
+ if (!anycharCached) {
+ m_userCharacterClasses.append(anycharCreate());
+ anycharCached = m_userCharacterClasses.last().get();
+ }
+ return anycharCached;
+ }
CharacterClass* newlineCharacterClass()
{
- if (!newlineCached)
- m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate()));
+ if (!newlineCached) {
+ m_userCharacterClasses.append(newlineCreate());
+ newlineCached = m_userCharacterClasses.last().get();
+ }
return newlineCached;
}
CharacterClass* digitsCharacterClass()
{
- if (!digitsCached)
- m_userCharacterClasses.append(adoptPtr(digitsCached = digitsCreate()));
+ if (!digitsCached) {
+ m_userCharacterClasses.append(digitsCreate());
+ digitsCached = m_userCharacterClasses.last().get();
+ }
return digitsCached;
}
CharacterClass* spacesCharacterClass()
{
- if (!spacesCached)
- m_userCharacterClasses.append(adoptPtr(spacesCached = spacesCreate()));
+ if (!spacesCached) {
+ m_userCharacterClasses.append(spacesCreate());
+ spacesCached = m_userCharacterClasses.last().get();
+ }
return spacesCached;
}
CharacterClass* wordcharCharacterClass()
{
- if (!wordcharCached)
- m_userCharacterClasses.append(adoptPtr(wordcharCached = wordcharCreate()));
+ if (!wordcharCached) {
+ m_userCharacterClasses.append(wordcharCreate());
+ wordcharCached = m_userCharacterClasses.last().get();
+ }
return wordcharCached;
}
+ CharacterClass* wordUnicodeIgnoreCaseCharCharacterClass()
+ {
+ if (!wordUnicodeIgnoreCaseCharCached) {
+ m_userCharacterClasses.append(wordUnicodeIgnoreCaseCharCreate());
+ wordUnicodeIgnoreCaseCharCached = m_userCharacterClasses.last().get();
+ }
+ return wordUnicodeIgnoreCaseCharCached;
+ }
CharacterClass* nondigitsCharacterClass()
{
- if (!nondigitsCached)
- m_userCharacterClasses.append(adoptPtr(nondigitsCached = nondigitsCreate()));
+ if (!nondigitsCached) {
+ m_userCharacterClasses.append(nondigitsCreate());
+ nondigitsCached = m_userCharacterClasses.last().get();
+ }
return nondigitsCached;
}
CharacterClass* nonspacesCharacterClass()
{
- if (!nonspacesCached)
- m_userCharacterClasses.append(adoptPtr(nonspacesCached = nonspacesCreate()));
+ if (!nonspacesCached) {
+ m_userCharacterClasses.append(nonspacesCreate());
+ nonspacesCached = m_userCharacterClasses.last().get();
+ }
return nonspacesCached;
}
CharacterClass* nonwordcharCharacterClass()
{
- if (!nonwordcharCached)
- m_userCharacterClasses.append(adoptPtr(nonwordcharCached = nonwordcharCreate()));
+ if (!nonwordcharCached) {
+ m_userCharacterClasses.append(nonwordcharCreate());
+ nonwordcharCached = m_userCharacterClasses.last().get();
+ }
return nonwordcharCached;
}
+ CharacterClass* nonwordUnicodeIgnoreCaseCharCharacterClass()
+ {
+ if (!nonwordUnicodeIgnoreCasecharCached) {
+ m_userCharacterClasses.append(nonwordUnicodeIgnoreCaseCharCreate());
+ nonwordUnicodeIgnoreCasecharCached = m_userCharacterClasses.last().get();
+ }
+ return nonwordUnicodeIgnoreCasecharCached;
+ }
+ CharacterClass* unicodeCharacterClassFor(BuiltInCharacterClassID unicodeClassID)
+ {
+ ASSERT(unicodeClassID >= BuiltInCharacterClassID::BaseUnicodePropertyID);
+
+ unsigned classID = static_cast<unsigned>(unicodeClassID);
+
+ if (unicodePropertiesCached.find(classID) == unicodePropertiesCached.end()) {
+ m_userCharacterClasses.append(createUnicodeCharacterClassFor(unicodeClassID));
+ CharacterClass* result = m_userCharacterClasses.last().get();
+ unicodePropertiesCached.add(classID, result);
+ return result;
+ }
+
+ return unicodePropertiesCached.get(classID);
+ }
+
+ void dumpPattern(const String& pattern);
+ void dumpPattern(PrintStream& out, const String& pattern);
+
+ bool global() const { return m_flags & FlagGlobal; }
+ bool ignoreCase() const { return m_flags & FlagIgnoreCase; }
+ bool multiline() const { return m_flags & FlagMultiline; }
+ bool sticky() const { return m_flags & FlagSticky; }
+ bool unicode() const { return m_flags & FlagUnicode; }
+ bool dotAll() const { return m_flags & FlagDotAll; }
- bool m_ignoreCase : 1;
- bool m_multiline : 1;
bool m_containsBackreferences : 1;
bool m_containsBOL : 1;
- unsigned m_numSubpatterns;
- unsigned m_maxBackReference;
+ bool m_containsUnsignedLengthPattern : 1;
+ bool m_hasCopiedParenSubexpressions : 1;
+ bool m_saveInitialStartValue : 1;
+ RegExpFlags m_flags;
+ unsigned m_numSubpatterns { 0 };
+ unsigned m_maxBackReference { 0 };
+ unsigned m_initialStartValueFrameLocation { 0 };
PatternDisjunction* m_body;
- Vector<OwnPtr<PatternDisjunction>, 4> m_disjunctions;
- Vector<OwnPtr<CharacterClass> > m_userCharacterClasses;
+ Vector<std::unique_ptr<PatternDisjunction>, 4> m_disjunctions;
+ Vector<std::unique_ptr<CharacterClass>> m_userCharacterClasses;
+ Vector<String> m_captureGroupNames;
+ HashMap<String, unsigned> m_namedGroupToParenIndex;
private:
- const char* compile(const String& patternString);
-
- CharacterClass* newlineCached;
- CharacterClass* digitsCached;
- CharacterClass* spacesCached;
- CharacterClass* wordcharCached;
- CharacterClass* nondigitsCached;
- CharacterClass* nonspacesCached;
- CharacterClass* nonwordcharCached;
+ ErrorCode compile(const String& patternString, void* stackLimit);
+
+ CharacterClass* anycharCached { nullptr };
+ CharacterClass* newlineCached { nullptr };
+ CharacterClass* digitsCached { nullptr };
+ CharacterClass* spacesCached { nullptr };
+ CharacterClass* wordcharCached { nullptr };
+ CharacterClass* wordUnicodeIgnoreCaseCharCached { nullptr };
+ CharacterClass* nondigitsCached { nullptr };
+ CharacterClass* nonspacesCached { nullptr };
+ CharacterClass* nonwordcharCached { nullptr };
+ CharacterClass* nonwordUnicodeIgnoreCasecharCached { nullptr };
+ HashMap<unsigned, CharacterClass*> unicodePropertiesCached;
};
-} } // namespace JSC::Yarr
+ void indentForNestingLevel(PrintStream&, unsigned);
+ void dumpUChar32(PrintStream&, UChar32);
+ void dumpCharacterClass(PrintStream&, YarrPattern*, CharacterClass*);
+
+ struct BackTrackInfoPatternCharacter {
+ uintptr_t begin; // Only needed for unicode patterns
+ uintptr_t matchAmount;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoPatternCharacter, begin) / sizeof(uintptr_t); }
+ static unsigned matchAmountIndex() { return offsetof(BackTrackInfoPatternCharacter, matchAmount) / sizeof(uintptr_t); }
+ };
-#endif // YarrPattern_h
+ struct BackTrackInfoCharacterClass {
+ uintptr_t begin; // Only needed for unicode patterns
+ uintptr_t matchAmount;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoCharacterClass, begin) / sizeof(uintptr_t); }
+ static unsigned matchAmountIndex() { return offsetof(BackTrackInfoCharacterClass, matchAmount) / sizeof(uintptr_t); }
+ };
+
+ struct BackTrackInfoBackReference {
+ uintptr_t begin; // Not really needed for greedy quantifiers.
+ uintptr_t matchAmount; // Not really needed for fixed quantifiers.
+
+ unsigned beginIndex() { return offsetof(BackTrackInfoBackReference, begin) / sizeof(uintptr_t); }
+ unsigned matchAmountIndex() { return offsetof(BackTrackInfoBackReference, matchAmount) / sizeof(uintptr_t); }
+ };
+
+ struct BackTrackInfoAlternative {
+ union {
+ uintptr_t offset;
+ };
+ };
+
+ struct BackTrackInfoParentheticalAssertion {
+ uintptr_t begin;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoParentheticalAssertion, begin) / sizeof(uintptr_t); }
+ };
+
+ struct BackTrackInfoParenthesesOnce {
+ uintptr_t begin;
+ uintptr_t returnAddress;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoParenthesesOnce, begin) / sizeof(uintptr_t); }
+ static unsigned returnAddressIndex() { return offsetof(BackTrackInfoParenthesesOnce, returnAddress) / sizeof(uintptr_t); }
+ };
+
+ struct BackTrackInfoParenthesesTerminal {
+ uintptr_t begin;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoParenthesesTerminal, begin) / sizeof(uintptr_t); }
+ };
+
+ struct BackTrackInfoParentheses {
+ uintptr_t begin;
+ uintptr_t returnAddress;
+ uintptr_t matchAmount;
+ uintptr_t parenContextHead;
+
+ static unsigned beginIndex() { return offsetof(BackTrackInfoParentheses, begin) / sizeof(uintptr_t); }
+ static unsigned returnAddressIndex() { return offsetof(BackTrackInfoParentheses, returnAddress) / sizeof(uintptr_t); }
+ static unsigned matchAmountIndex() { return offsetof(BackTrackInfoParentheses, matchAmount) / sizeof(uintptr_t); }
+ static unsigned parenContextHeadIndex() { return offsetof(BackTrackInfoParentheses, parenContextHead) / sizeof(uintptr_t); }
+ };
+
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrSyntaxChecker.cpp b/src/3rdparty/masm/yarr/YarrSyntaxChecker.cpp
index aa98c4a354..9f05f22852 100644
--- a/src/3rdparty/masm/yarr/YarrSyntaxChecker.cpp
+++ b/src/3rdparty/masm/yarr/YarrSyntaxChecker.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,8 @@
#include "YarrSyntaxChecker.h"
#include "YarrParser.h"
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
namespace JSC { namespace Yarr {
@@ -35,25 +37,26 @@ public:
void assertionBOL() {}
void assertionEOL() {}
void assertionWordBoundary(bool) {}
- void atomPatternCharacter(UChar) {}
+ void atomPatternCharacter(UChar32) {}
void atomBuiltInCharacterClass(BuiltInCharacterClassID, bool) {}
void atomCharacterClassBegin(bool = false) {}
void atomCharacterClassAtom(UChar) {}
void atomCharacterClassRange(UChar, UChar) {}
void atomCharacterClassBuiltIn(BuiltInCharacterClassID, bool) {}
void atomCharacterClassEnd() {}
- void atomParenthesesSubpatternBegin(bool = true) {}
+ void atomParenthesesSubpatternBegin(bool = true, std::optional<String> = std::nullopt) {}
void atomParentheticalAssertionBegin(bool = false) {}
void atomParenthesesEnd() {}
void atomBackReference(unsigned) {}
+ void atomNamedBackReference(String) {}
void quantifyAtom(unsigned, unsigned, bool) {}
void disjunction() {}
};
-const char* checkSyntax(const String& pattern)
+ErrorCode checkSyntax(const String& pattern, const String& flags)
{
SyntaxChecker syntaxChecker;
- return parse(syntaxChecker, pattern);
+ return parse(syntaxChecker, pattern, flags.contains('u'));
}
-}} // JSC::YARR
+}} // JSC::Yarr
diff --git a/src/3rdparty/masm/yarr/YarrSyntaxChecker.h b/src/3rdparty/masm/yarr/YarrSyntaxChecker.h
index 104ced3ab4..86daf38bcb 100644
--- a/src/3rdparty/masm/yarr/YarrSyntaxChecker.h
+++ b/src/3rdparty/masm/yarr/YarrSyntaxChecker.h
@@ -23,16 +23,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef YarrSyntaxChecker_h
-#define YarrSyntaxChecker_h
+#pragma once
+#include "YarrErrorCode.h"
#include <wtf/text/WTFString.h>
namespace JSC { namespace Yarr {
-const char* checkSyntax(const String& pattern);
-
-}} // JSC::YARR
-
-#endif // YarrSyntaxChecker_h
+ErrorCode checkSyntax(const String& pattern, const String& flags);
+}} // JSC::Yarr
diff --git a/src/3rdparty/masm/assembler/MacroAssemblerSH4.cpp b/src/3rdparty/masm/yarr/YarrUnicodeProperties.h
index 59de3ff48c..20f6739de3 100644
--- a/src/3rdparty/masm/assembler/MacroAssemblerSH4.cpp
+++ b/src/3rdparty/masm/yarr/YarrUnicodeProperties.h
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2011 STMicroelectronics. All rights reserved.
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -21,32 +20,22 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-#include "config.h"
+#pragma once
-#if ENABLE(ASSEMBLER) && CPU(SH4)
+#include "Yarr.h"
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
-#include "MacroAssemblerSH4.h"
+namespace JSC { namespace Yarr {
-namespace JSC {
+struct CharacterClass;
-void MacroAssemblerSH4::linkCall(void* code, Call call, FunctionPtr function)
-{
- SH4Assembler::linkCall(code, call.m_label, function.value());
-}
+JS_EXPORT_PRIVATE std::optional<BuiltInCharacterClassID> unicodeMatchPropertyValue(WTF::String, WTF::String);
+JS_EXPORT_PRIVATE std::optional<BuiltInCharacterClassID> unicodeMatchProperty(WTF::String);
-void MacroAssemblerSH4::repatchCall(CodeLocationCall call, CodeLocationLabel destination)
-{
- SH4Assembler::relinkCall(call.dataLocation(), destination.executableAddress());
-}
+std::unique_ptr<CharacterClass> createUnicodeCharacterClassFor(BuiltInCharacterClassID);
-void MacroAssemblerSH4::repatchCall(CodeLocationCall call, FunctionPtr destination)
-{
- SH4Assembler::relinkCall(call.dataLocation(), destination.executableAddress());
-}
-
-} // namespace JSC
-
-#endif // ENABLE(ASSEMBLER)
+} } // namespace JSC::Yarr
diff --git a/src/3rdparty/masm/create_regex_tables b/src/3rdparty/masm/yarr/create_regex_tables
index 7544b75cd9..4c3dbbe3fb 100644
--- a/src/3rdparty/masm/create_regex_tables
+++ b/src/3rdparty/masm/yarr/create_regex_tables
@@ -1,4 +1,6 @@
-# Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
+#!/usr/bin/env python
+
+# Copyright (C) 2010, 2013-2017 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -21,16 +23,19 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import os
import sys
types = {
"wordchar": { "UseTable" : True, "data": ['_', ('0','9'), ('A', 'Z'), ('a','z')]},
- "nonwordchar": { "UseTable" : True, "Inverse": "wordchar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0xffff)]},
+ "wordUnicodeIgnoreCaseChar": { "UseTable" : False, "data": ['_', ('0', '9'), ('A', 'Z'), ('a', 'z'), 0x017f, 0x212a]},
+ "nonwordchar": { "UseTable" : True, "Inverse": "wordchar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0x10ffff)]},
+ "nonwordUnicodeIgnoreCaseChar": { "UseTable" : False, "Inverse": "wordUnicodeIgnoreCaseChar", "data": ['`', (0, ord('0') - 1), (ord('9') + 1, ord('A') - 1), (ord('Z') + 1, ord('_') - 1), (ord('z') + 1, 0x017e), (0x0180, 0x2129), (0x212b, 0x10ffff)]},
"newline": { "UseTable" : False, "data": ['\n', '\r', 0x2028, 0x2029]},
"spaces": { "UseTable" : True, "data": [' ', ('\t', '\r'), 0xa0, 0x1680, 0x180e, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000, (0x2000, 0x200a), 0xfeff]},
- "nonspaces": { "UseTable" : True, "Inverse": "spaces", "data": [(0, ord('\t') - 1), (ord('\r') + 1, ord(' ') - 1), (ord(' ') + 1, 0x009f), (0x00a1, 0x167f), (0x1681, 0x180d), (0x180f, 0x1fff), (0x200b, 0x2027), (0x202a, 0x202e), (0x2030, 0x205e), (0x2060, 0x2fff), (0x3001, 0xfefe), (0xff00, 0xffff)]},
+ "nonspaces": { "UseTable" : True, "Inverse": "spaces", "data": [(0, ord('\t') - 1), (ord('\r') + 1, ord(' ') - 1), (ord(' ') + 1, 0x009f), (0x00a1, 0x167f), (0x1681, 0x180d), (0x180f, 0x1fff), (0x200b, 0x2027), (0x202a, 0x202e), (0x2030, 0x205e), (0x2060, 0x2fff), (0x3001, 0xfefe), (0xff00, 0x10ffff)]},
"digits": { "UseTable" : False, "data": [('0', '9')]},
- "nondigits": { "UseTable" : False, "Inverse": "digits", "data": [(0, ord('0') - 1), (ord('9') + 1, 0xffff)] }
+ "nondigits": { "UseTable" : False, "Inverse": "digits", "data": [(0, ord('0') - 1), (ord('9') + 1, 0x10ffff)] }
}
entriesPerLine = 50
arrays = "";
@@ -86,15 +91,16 @@ for name, classes in types.items():
# Generate createFunction:
function = "";
- function += ("CharacterClass* %sCreate()\n" % name)
+ function += ("std::unique_ptr<CharacterClass> %sCreate()\n" % name)
function += ("{\n")
if emitTables and classes["UseTable"]:
if "Inverse" in classes:
- function += (" CharacterClass* characterClass = new CharacterClass(_%sData, true);\n" % (classes["Inverse"]))
+ function += (" auto characterClass = std::make_unique<CharacterClass>(_%sData, true);\n" % (classes["Inverse"]))
else:
- function += (" CharacterClass* characterClass = new CharacterClass(_%sData, false);\n" % (name))
+ function += (" auto characterClass = std::make_unique<CharacterClass>(_%sData, false);\n" % (name))
else:
- function += (" CharacterClass* characterClass = new CharacterClass;\n")
+ function += (" auto characterClass = std::make_unique<CharacterClass>();\n")
+ hasNonBMPCharacters = False
for (min, max) in ranges:
if (min == max):
if (min > 127):
@@ -106,12 +112,19 @@ for name, classes in types.items():
function += (" characterClass->m_rangesUnicode.append(CharacterRange(0x%04x, 0x%04x));\n" % (min, max))
else:
function += (" characterClass->m_ranges.append(CharacterRange(0x%02x, 0x%02x));\n" % (min, max))
+ if max >= 0x10000:
+ hasNonBMPCharacters = True
+ function += (" characterClass->m_hasNonBMPCharacters = %s;\n" % ("true" if hasNonBMPCharacters else "false"))
function += (" return characterClass;\n")
function += ("}\n\n")
functions += function
if (len(sys.argv) > 1):
- f = open(sys.argv[-1], "w")
+ path = sys.argv[-1]
+ dirname = os.path.dirname(path)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname)
+ f = open(path, "w")
f.write(arrays)
f.write(functions)
f.close()
diff --git a/src/3rdparty/masm/yarr/generateYarrCanonicalizeUnicode b/src/3rdparty/masm/yarr/generateYarrCanonicalizeUnicode
new file mode 100644
index 0000000000..a103bcdf16
--- /dev/null
+++ b/src/3rdparty/masm/yarr/generateYarrCanonicalizeUnicode
@@ -0,0 +1,204 @@
+#! /usr/bin/env python
+
+# Copyright (C) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# This tool processes the Unicode Character Database file CaseFolding.txt to create
+# canonicalization table as decribed in ECMAScript 6 standard in section
+# "21.2.2.8.2 Runtime Semantics: Canonicalize()", step 2.
+
+import optparse
+import os
+import re
+import sys
+from sets import Set
+
+header = """/*
+* Copyright (C) 2016 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+// DO NO EDIT! - This file was generated by generateYarrCanonicalizeUnicode
+
+#include "config.h"
+#include "YarrCanonicalize.h"
+
+namespace JSC { namespace Yarr {
+
+"""
+
+footer = """} } // JSC::Yarr
+"""
+
+MaxUnicode = 0x10ffff
+commonAndSimpleLinesRE = re.compile(r"(?P<code>[0-9A-F]+)\s*;\s*[CS]\s*;\s*(?P<mapping>[0-9A-F]+)", re.IGNORECASE)
+
+def openOrExit(path, mode):
+ try:
+ dirname = os.path.dirname(path)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname)
+ return open(path, mode)
+ except IOError as e:
+ print "I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror)
+ exit(1)
+
+class Canonicalize:
+ def __init__(self):
+ self.canonicalGroups = {};
+
+ def addMapping(self, code, mapping):
+ if mapping not in self.canonicalGroups:
+ self.canonicalGroups[mapping] = []
+ self.canonicalGroups[mapping].append(code)
+
+ def readCaseFolding(self, file):
+ codesSeen = Set()
+ for line in file:
+ line = line.split('#', 1)[0]
+ line = line.rstrip()
+ if (not len(line)):
+ continue
+
+ fields = commonAndSimpleLinesRE.match(line)
+ if (not fields):
+ continue
+
+ code = int(fields.group('code'), 16)
+ mapping = int(fields.group('mapping'), 16)
+
+ codesSeen.add(code)
+ self.addMapping(code, mapping)
+
+ for i in range(MaxUnicode + 1):
+ if i in codesSeen:
+ continue;
+
+ self.addMapping(i, i)
+
+ def createTables(self, file):
+ typeInfo = [""] * (MaxUnicode + 1)
+ characterSets = []
+
+ for mapping in sorted(self.canonicalGroups.keys()):
+ characters = self.canonicalGroups[mapping]
+ if len(characters) == 1:
+ typeInfo[characters[0]] = "CanonicalizeUnique:0"
+ else:
+ characters.sort()
+ if len(characters) > 2:
+ for ch in characters:
+ typeInfo[ch] = "CanonicalizeSet:%d" % len(characterSets)
+ characterSets.append(characters)
+ else:
+ low = characters[0]
+ high = characters[1]
+ delta = high - low
+ if delta == 1:
+ type = "CanonicalizeAlternatingUnaligned:0" if low & 1 else "CanonicalizeAlternatingAligned:0"
+ typeInfo[low] = type
+ typeInfo[high] = type
+ else:
+ typeInfo[low] = "CanonicalizeRangeLo:%d" % delta
+ typeInfo[high] = "CanonicalizeRangeHi:%d" % delta
+
+ rangeInfo = []
+ end = 0
+ while end <= MaxUnicode:
+ begin = end
+ type = typeInfo[end]
+ while end < MaxUnicode and typeInfo[end + 1] == type:
+ end = end + 1
+ rangeInfo.append({"begin": begin, "end": end, "type": type})
+ end = end + 1
+
+ for i in range(len(characterSets)):
+ characters = ""
+ set = characterSets[i]
+ for ch in set:
+ characters = characters + "0x{character:04x}, ".format(character=ch)
+ file.write("const UChar32 unicodeCharacterSet{index:d}[] = {{ {characters}0 }};\n".format(index=i, characters=characters))
+
+ file.write("\n")
+ file.write("static const size_t UNICODE_CANONICALIZATION_SETS = {setCount:d};\n".format(setCount=len(characterSets)))
+ file.write("const UChar32* const unicodeCharacterSetInfo[UNICODE_CANONICALIZATION_SETS] = {\n")
+
+ for i in range(len(characterSets)):
+ file.write(" unicodeCharacterSet{setNumber:d},\n".format(setNumber=i))
+
+ file.write("};\n")
+ file.write("\n")
+ file.write("const size_t UNICODE_CANONICALIZATION_RANGES = {rangeCount:d};\n".format(rangeCount=len(rangeInfo)))
+ file.write("const CanonicalizationRange unicodeRangeInfo[UNICODE_CANONICALIZATION_RANGES] = {\n")
+
+ for info in rangeInfo:
+ typeAndValue = info["type"].split(":")
+ file.write(" {{ 0x{begin:04x}, 0x{end:04x}, 0x{value:04x}, {type} }},\n".format(begin=info["begin"], end=info["end"], value=int(typeAndValue[1]), type=typeAndValue[0]))
+
+ file.write("};\n")
+ file.write("\n")
+
+
+if __name__ == "__main__":
+ parser = optparse.OptionParser(usage = "usage: %prog <CaseFolding.txt> <YarrCanonicalizeUnicode.h>")
+ (options, args) = parser.parse_args()
+
+ if len(args) != 2:
+ parser.error("<CaseFolding.txt> <YarrCanonicalizeUnicode.h>")
+
+ caseFoldingTxtPath = args[0]
+ canonicalizeHPath = args[1]
+ caseFoldingTxtFile = openOrExit(caseFoldingTxtPath, "r")
+ canonicalizeHFile = openOrExit(canonicalizeHPath, "wb")
+
+ canonicalize = Canonicalize()
+ canonicalize.readCaseFolding(caseFoldingTxtFile)
+
+ canonicalizeHFile.write(header);
+ canonicalize.createTables(canonicalizeHFile)
+ canonicalizeHFile.write(footer);
+
+ caseFoldingTxtFile.close()
+ canonicalizeHFile.close()
+
+ exit(0)
diff --git a/src/3rdparty/masm/yarr/yarr.pri b/src/3rdparty/masm/yarr/yarr.pri
index 7e9b4d3f3b..c8e30990be 100644
--- a/src/3rdparty/masm/yarr/yarr.pri
+++ b/src/3rdparty/masm/yarr/yarr.pri
@@ -8,5 +8,8 @@ SOURCES += \
$$PWD/YarrInterpreter.cpp \
$$PWD/YarrPattern.cpp \
$$PWD/YarrSyntaxChecker.cpp \
- $$PWD/YarrCanonicalizeUCS2.cpp
+ $$PWD/YarrCanonicalizeUCS2.cpp \
+ $$PWD/YarrCanonicalizeUnicode.cpp \
+ $$PWD/YarrErrorCode.cpp \
+ $$PWD/YarrUnicodeProperties.cpp
diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes
index 53c5300685..f2179aaf7a 100644
--- a/src/imports/builtins/builtins.qmltypes
+++ b/src/imports/builtins/builtins.qmltypes
@@ -428,7 +428,8 @@ Module {
"WA_AlwaysStackOnTop": 128,
"WA_TabletTracking": 129,
"WA_ContentsMarginsRespectsSafeArea": 130,
- "WA_AttributeCount": 131
+ "WA_StyleSheetTarget": 131,
+ "WA_AttributeCount": 132
}
}
Enum {
@@ -1648,7 +1649,8 @@ Module {
"NoScrollPhase": 0,
"ScrollBegin": 1,
"ScrollUpdate": 2,
- "ScrollEnd": 3
+ "ScrollEnd": 3,
+ "ScrollMomentum": 4
}
}
Enum {
diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro
index 99c54113e4..54ef107e45 100644
--- a/src/imports/folderlistmodel/folderlistmodel.pro
+++ b/src/imports/folderlistmodel/folderlistmodel.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlfolderlistmodelplugin
TARGETPATH = Qt/labs/folderlistmodel
-IMPORT_VERSION = 2.1
+IMPORT_VERSION = 2.$$QT_MINOR_VERSION
QT = core-private qml-private
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index 5e8b41401f..7089fed4ad 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -42,13 +42,6 @@
#include "qquickfolderlistmodel.h"
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_Qt_labs_folderlistmodel);
-#endif
-}
-
QT_BEGIN_NAMESPACE
//![class decl]
@@ -58,7 +51,7 @@ class QmlFolderListModelPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QmlFolderListModelPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QmlFolderListModelPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel"));
diff --git a/src/imports/folderlistmodel/plugins.qmltypes b/src/imports/folderlistmodel/plugins.qmltypes
index a336b55022..cfa4765116 100644
--- a/src/imports/folderlistmodel/plugins.qmltypes
+++ b/src/imports/folderlistmodel/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable Qt.labs.folderlistmodel 2.11'
+// 'qmlplugindump -nonrelocatable Qt.labs.folderlistmodel 2.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickFolderListModel"
prototype: "QAbstractListModel"
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 7b2884df77..66d9e7ae46 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -224,16 +224,16 @@ QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path)
}
/*!
- \qmlmodule Qt.labs.folderlistmodel 2.11
+ \qmlmodule Qt.labs.folderlistmodel 2.\QtMinorVersion
\title Qt Labs FolderListModel QML Types
\ingroup qmlmodules
\brief The FolderListModel provides a model of the contents of a file system folder.
To use this module, import the module with the following line:
- \code
- import Qt.labs.folderlistmodel 2.11
- \endcode
+ \qml \QtMinorVersion
+ import Qt.labs.folderlistmodel 2.\1
+ \endqml
*/
@@ -251,7 +251,9 @@ QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path)
\e{Elements in the Qt.labs module are not guaranteed to remain compatible
in future versions.}
- \b{import Qt.labs.folderlistmodel 2.11}
+ \qml \QtMinorVersion
+ import Qt.labs.folderlistmodel 2.\1
+ \endqml
The \l folder property specifies the folder to access. Information about the
files and directories in the folder is supplied via the model's interface.
@@ -295,9 +297,9 @@ QString QQuickFolderListModelPrivate::resolvePath(const QUrl &path)
The following example shows a FolderListModel being used to provide a list
of QML files in a \l ListView:
- \qml
- import QtQuick 2.0
- import Qt.labs.folderlistmodel 2.11
+ \qml \QtMinorVersion
+ import QtQuick 2.\1
+ import Qt.labs.folderlistmodel 2.\1
ListView {
width: 200; height: 400
diff --git a/src/imports/handlers/handlers.pro b/src/imports/handlers/handlers.pro
deleted file mode 100644
index 0e32644773..0000000000
--- a/src/imports/handlers/handlers.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CXX_MODULE = qml
-TARGET = handlersplugin
-TARGETPATH = Qt/labs/handlers
-IMPORT_VERSION = 1.0
-
-SOURCES += \
- plugin.cpp
-
-QT += quick-private qml-private
-
-load(qml_plugin)
diff --git a/src/imports/handlers/plugins.qmltypes b/src/imports/handlers/plugins.qmltypes
deleted file mode 100644
index f51e1e4bf3..0000000000
--- a/src/imports/handlers/plugins.qmltypes
+++ /dev/null
@@ -1,308 +0,0 @@
-import QtQuick.tooling 1.2
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-//
-// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable Qt.labs.handlers 1.0'
-
-Module {
- dependencies: ["QtQuick 2.8"]
- Component {
- name: "QQuickDragAxis"
- prototype: "QObject"
- exports: ["Qt.labs.handlers/DragAxis 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Property { name: "minimum"; type: "double" }
- Property { name: "maximum"; type: "double" }
- Property { name: "enabled"; type: "bool" }
- }
- Component {
- name: "QQuickDragHandler"
- prototype: "QQuickSinglePointHandler"
- exports: ["Qt.labs.handlers/DragHandler 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "xAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
- Property { name: "yAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
- Property { name: "translation"; type: "QVector2D"; isReadonly: true }
- Method { name: "enforceConstraints" }
- }
- Component {
- name: "QQuickEventPoint"
- prototype: "QObject"
- exports: ["Qt.labs.handlers/EventPoint 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Enum {
- name: "States"
- values: {
- "Pressed": 1,
- "Updated": 2,
- "Stationary": 4,
- "Released": 8
- }
- }
- Enum {
- name: "GrabState"
- values: {
- "GrabPassive": 1,
- "UngrabPassive": 2,
- "CancelGrabPassive": 3,
- "OverrideGrabPassive": 4,
- "GrabExclusive": 16,
- "UngrabExclusive": 32,
- "CancelGrabExclusive": 48
- }
- }
- Property { name: "event"; type: "QQuickPointerEvent"; isReadonly: true; isPointer: true }
- Property { name: "position"; type: "QPointF"; isReadonly: true }
- Property { name: "scenePosition"; type: "QPointF"; isReadonly: true }
- Property { name: "scenePressPosition"; type: "QPointF"; isReadonly: true }
- Property { name: "sceneGrabPosition"; type: "QPointF"; isReadonly: true }
- Property { name: "state"; type: "State"; isReadonly: true }
- Property { name: "pointId"; type: "int"; isReadonly: true }
- Property { name: "timeHeld"; type: "double"; isReadonly: true }
- Property { name: "velocity"; type: "QVector2D"; isReadonly: true }
- Property { name: "accepted"; type: "bool" }
- Property { name: "exclusiveGrabber"; type: "QObject"; isPointer: true }
- }
- Component {
- name: "QQuickEventTouchPoint"
- prototype: "QQuickEventPoint"
- exports: ["Qt.labs.handlers/EventTouchPoint 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Property { name: "rotation"; type: "double"; isReadonly: true }
- Property { name: "pressure"; type: "double"; isReadonly: true }
- Property { name: "ellipseDiameters"; type: "QSizeF"; isReadonly: true }
- Property { name: "uniqueId"; type: "QPointingDeviceUniqueId"; isReadonly: true }
- }
- Component {
- name: "QQuickMultiPointHandler"
- prototype: "QQuickPointerDeviceHandler"
- Property { name: "minimumPointCount"; type: "int" }
- Property { name: "maximumPointCount"; type: "int" }
- Property { name: "pointDistanceThreshold"; type: "double" }
- }
- Component {
- name: "QQuickPinchHandler"
- prototype: "QQuickMultiPointHandler"
- exports: ["Qt.labs.handlers/PinchHandler 1.0"]
- exportMetaObjectRevisions: [0]
- Enum {
- name: "PinchOrigin"
- values: {
- "FirstPoint": 0,
- "PinchCenter": 1,
- "TargetCenter": 2
- }
- }
- Property { name: "minimumScale"; type: "double" }
- Property { name: "maximumScale"; type: "double" }
- Property { name: "minimumRotation"; type: "double" }
- Property { name: "maximumRotation"; type: "double" }
- Property { name: "pinchOrigin"; type: "PinchOrigin" }
- Property { name: "centroid"; type: "QPointF"; isReadonly: true }
- Property { name: "centroidVelocity"; type: "QVector2D"; isReadonly: true }
- Property { name: "scale"; type: "double"; isReadonly: true }
- Property { name: "rotation"; type: "double"; isReadonly: true }
- Property { name: "translation"; type: "QVector2D"; isReadonly: true }
- Property { name: "minimumX"; type: "double" }
- Property { name: "maximumX"; type: "double" }
- Property { name: "minimumY"; type: "double" }
- Property { name: "maximumY"; type: "double" }
- Signal { name: "updated" }
- }
- Component {
- name: "QQuickPointHandler"
- prototype: "QQuickSinglePointHandler"
- exports: ["Qt.labs.handlers/PointHandler 1.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "translation"; type: "QVector2D"; isReadonly: true }
- }
- Component {
- name: "QQuickPointerDevice"
- prototype: "QObject"
- exports: ["Qt.labs.handlers/PointerDevice 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Enum {
- name: "DeviceType"
- values: {
- "UnknownDevice": 0,
- "Mouse": 1,
- "TouchScreen": 2,
- "TouchPad": 4,
- "Puck": 8,
- "Stylus": 16,
- "Airbrush": 32,
- "AllDevices": 63
- }
- }
- Enum {
- name: "DeviceTypes"
- values: {
- "UnknownDevice": 0,
- "Mouse": 1,
- "TouchScreen": 2,
- "TouchPad": 4,
- "Puck": 8,
- "Stylus": 16,
- "Airbrush": 32,
- "AllDevices": 63
- }
- }
- Enum {
- name: "PointerType"
- values: {
- "GenericPointer": 1,
- "Finger": 2,
- "Pen": 4,
- "Eraser": 8,
- "Cursor": 16,
- "AllPointerTypes": 31
- }
- }
- Enum {
- name: "PointerTypes"
- values: {
- "GenericPointer": 1,
- "Finger": 2,
- "Pen": 4,
- "Eraser": 8,
- "Cursor": 16,
- "AllPointerTypes": 31
- }
- }
- Enum {
- name: "CapabilityFlag"
- values: {
- "Position": 1,
- "Area": 2,
- "Pressure": 4,
- "Velocity": 8,
- "Scroll": 256,
- "Hover": 512,
- "Rotation": 1024,
- "XTilt": 2048,
- "YTilt": 4096
- }
- }
- Enum {
- name: "Capabilities"
- values: {
- "Position": 1,
- "Area": 2,
- "Pressure": 4,
- "Velocity": 8,
- "Scroll": 256,
- "Hover": 512,
- "Rotation": 1024,
- "XTilt": 2048,
- "YTilt": 4096
- }
- }
- Property { name: "type"; type: "DeviceType"; isReadonly: true }
- Property { name: "pointerType"; type: "PointerType"; isReadonly: true }
- Property { name: "capabilities"; type: "Capabilities"; isReadonly: true }
- Property { name: "maximumTouchPoints"; type: "int"; isReadonly: true }
- Property { name: "buttonCount"; type: "int"; isReadonly: true }
- Property { name: "name"; type: "string"; isReadonly: true }
- Property { name: "uniqueId"; type: "QPointingDeviceUniqueId"; isReadonly: true }
- }
- Component {
- name: "QQuickPointerDeviceHandler"
- prototype: "QQuickPointerHandler"
- Property { name: "acceptedDevices"; type: "QQuickPointerDevice::DeviceTypes" }
- Property { name: "acceptedPointerTypes"; type: "QQuickPointerDevice::PointerTypes" }
- Property { name: "acceptedModifiers"; type: "Qt::KeyboardModifiers" }
- Method {
- name: "setAcceptedDevices"
- Parameter { name: "acceptedDevices"; type: "QQuickPointerDevice::DeviceTypes" }
- }
- Method {
- name: "setAcceptedPointerTypes"
- Parameter { name: "acceptedPointerTypes"; type: "QQuickPointerDevice::PointerTypes" }
- }
- Method {
- name: "setAcceptedModifiers"
- Parameter { name: "acceptedModifiers"; type: "Qt::KeyboardModifiers" }
- }
- }
- Component {
- name: "QQuickPointerEvent"
- prototype: "QObject"
- exports: ["Qt.labs.handlers/PointerEvent 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Property { name: "device"; type: "const QQuickPointerDevice"; isReadonly: true; isPointer: true }
- Property { name: "modifiers"; type: "Qt::KeyboardModifiers"; isReadonly: true }
- Property { name: "button"; type: "Qt::MouseButtons"; isReadonly: true }
- Property { name: "buttons"; type: "Qt::MouseButtons"; isReadonly: true }
- }
- Component {
- name: "QQuickPointerHandler"
- prototype: "QObject"
- exports: ["Qt.labs.handlers/PointerHandler 1.0"]
- isCreatable: false
- exportMetaObjectRevisions: [0]
- Enum {
- name: "GrabPermissions"
- values: {
- "TakeOverForbidden": 0,
- "CanTakeOverFromHandlersOfSameType": 1,
- "CanTakeOverFromHandlersOfDifferentType": 2,
- "CanTakeOverFromItems": 4,
- "CanTakeOverFromAnything": 15,
- "ApprovesTakeOverByHandlersOfSameType": 16,
- "ApprovesTakeOverByHandlersOfDifferentType": 32,
- "ApprovesTakeOverByItems": 64,
- "ApprovesCancellation": 128,
- "ApprovesTakeOverByAnything": 240
- }
- }
- Property { name: "enabled"; type: "bool" }
- Property { name: "active"; type: "bool"; isReadonly: true }
- Property { name: "target"; type: "QQuickItem"; isPointer: true }
- Property { name: "parent"; type: "QQuickItem"; isReadonly: true; isPointer: true }
- Property { name: "grabPermissions"; type: "GrabPermissions" }
- Signal {
- name: "grabChanged"
- Parameter { name: "point"; type: "QQuickEventPoint"; isPointer: true }
- }
- Signal { name: "grabPermissionChanged" }
- Signal {
- name: "canceled"
- Parameter { name: "point"; type: "QQuickEventPoint"; isPointer: true }
- }
- }
- Component {
- name: "QQuickSinglePointHandler"
- prototype: "QQuickPointerDeviceHandler"
- Property { name: "acceptedButtons"; type: "Qt::MouseButtons" }
- Property { name: "point"; type: "QQuickHandlerPoint"; isReadonly: true }
- Signal { name: "singlePointGrabChanged" }
- }
- Component {
- name: "QQuickTapHandler"
- prototype: "QQuickSinglePointHandler"
- exports: ["Qt.labs.handlers/TapHandler 1.0"]
- exportMetaObjectRevisions: [0]
- Enum {
- name: "GesturePolicy"
- values: {
- "DragThreshold": 0,
- "WithinBounds": 1,
- "ReleaseWithinBounds": 2
- }
- }
- Property { name: "pressed"; type: "bool"; isReadonly: true }
- Property { name: "tapCount"; type: "int"; isReadonly: true }
- Property { name: "timeHeld"; type: "double"; isReadonly: true }
- Property { name: "longPressThreshold"; type: "double" }
- Property { name: "gesturePolicy"; type: "GesturePolicy" }
- Signal { name: "tapped" }
- Signal { name: "longPressed" }
- }
-}
diff --git a/src/imports/handlers/qmldir b/src/imports/handlers/qmldir
deleted file mode 100644
index 4896348c2e..0000000000
--- a/src/imports/handlers/qmldir
+++ /dev/null
@@ -1,5 +0,0 @@
-module Qt.labs.handlers
-plugin handlersplugin
-classname QtQuickHandlersPlugin
-typeinfo plugins.qmltypes
-
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index e188602277..eb3e336c7f 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -1,20 +1,20 @@
TEMPLATE = subdirs
-QT_FOR_CONFIG += quick-private
-
SUBDIRS += \
builtins \
qtqml \
- folderlistmodel \
- models
+ models \
+ labsmodels
+qtConfig(thread): SUBDIRS += folderlistmodel
qtHaveModule(sql): SUBDIRS += localstorage
qtConfig(settings): SUBDIRS += settings
qtConfig(statemachine): SUBDIRS += statemachine
qtHaveModule(quick) {
+ QT_FOR_CONFIG += quick-private
+
SUBDIRS += \
- handlers \
layouts \
qtquick2 \
window
@@ -24,7 +24,7 @@ qtHaveModule(quick) {
qtConfig(quick-particles): \
SUBDIRS += particles
- qtConfig(quick-path): SUBDIRS += shapes
+ qtConfig(quick-path):qtConfig(thread): SUBDIRS += shapes
}
qtHaveModule(xmlpatterns) : SUBDIRS += xmllistmodel
diff --git a/src/imports/labsmodels/labsmodels.pro b/src/imports/labsmodels/labsmodels.pro
new file mode 100644
index 0000000000..1795ae5e43
--- /dev/null
+++ b/src/imports/labsmodels/labsmodels.pro
@@ -0,0 +1,11 @@
+CXX_MODULE = qml
+TARGET = labsmodelsplugin
+TARGETPATH = Qt/labs/qmlmodels
+IMPORT_VERSION = 1.0
+
+SOURCES += \
+ plugin.cpp
+
+QT = qml-private
+
+load(qml_plugin)
diff --git a/src/imports/handlers/plugin.cpp b/src/imports/labsmodels/plugin.cpp
index d1041d6539..e18f08b70b 100644
--- a/src/imports/handlers/plugin.cpp
+++ b/src/imports/labsmodels/plugin.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -38,30 +38,42 @@
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
-#include <private/qquickhandlersmodule_p.h>
-
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_Qt_labs_handlers);
-#endif
-}
+#include <private/qqmlmodelsmodule_p.h>
QT_BEGIN_NAMESPACE
+/*!
+ \qmlmodule Qt.labs.qmlmodels 1.0
+ \title Qt QML Models experimental QML Types
+ \ingroup qmlmodules
+ \brief Provides QML experimental types for data models
+ \since 5.12
+
+ This QML module contains experimental QML types related to data models.
+
+ To use the types in this module, import the module with the following line:
+
+ \code
+ import Qt.labs.qmlmodels 1.0
+ \endcode
+*/
+
//![class decl]
-class QtQuickHandlersPlugin : public QQmlExtensionPlugin
+class QtQmlLabsModelsPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuickHandlersPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQmlLabsModelsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
- Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.handlers"));
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.qmlmodels"));
Q_UNUSED(uri);
- QQuickHandlersModule::defineModule();
+ QQmlModelsModule::defineLabsModule();
+
+ qmlRegisterModule(uri, 1, 0);
}
};
//![class decl]
diff --git a/src/imports/labsmodels/plugins.qmltypes b/src/imports/labsmodels/plugins.qmltypes
new file mode 100644
index 0000000000..606b8712da
--- /dev/null
+++ b/src/imports/labsmodels/plugins.qmltypes
@@ -0,0 +1,41 @@
+import QtQuick.tooling 1.2
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated by:
+// 'qmlplugindump -nonrelocatable Qt.labs.qmlmodels 1.0'
+
+Module {
+ dependencies: ["QtQuick 2.12"]
+ Component {
+ name: "QQmlAbstractDelegateComponent"
+ prototype: "QQmlComponent"
+ exports: ["Qt.labs.qmlmodels/AbstractDelegateComponent 1.0"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Signal { name: "delegateChanged" }
+ }
+ Component {
+ name: "QQmlDelegateChoice"
+ defaultProperty: "delegate"
+ prototype: "QObject"
+ exports: ["Qt.labs.qmlmodels/DelegateChoice 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "roleValue"; type: "QVariant" }
+ Property { name: "row"; type: "int" }
+ Property { name: "index"; type: "int" }
+ Property { name: "column"; type: "int" }
+ Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
+ Signal { name: "changed" }
+ }
+ Component {
+ name: "QQmlDelegateChooser"
+ defaultProperty: "choices"
+ prototype: "QQmlAbstractDelegateComponent"
+ exports: ["Qt.labs.qmlmodels/DelegateChooser 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "role"; type: "string" }
+ Property { name: "choices"; type: "QQmlDelegateChoice"; isList: true; isReadonly: true }
+ }
+}
diff --git a/src/imports/labsmodels/qmldir b/src/imports/labsmodels/qmldir
new file mode 100644
index 0000000000..9c735711c4
--- /dev/null
+++ b/src/imports/labsmodels/qmldir
@@ -0,0 +1,3 @@
+module Qt.labs.qmlmodels
+plugin labsmodelsplugin
+classname QtQmlLabsModelsPlugin
diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp
index c805c9fb43..80799e8859 100644
--- a/src/imports/layouts/plugin.cpp
+++ b/src/imports/layouts/plugin.cpp
@@ -42,13 +42,6 @@
#include "qquicklinearlayout_p.h"
#include "qquickstacklayout_p.h"
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_Layouts);
-#endif
-}
-
QT_BEGIN_NAMESPACE
//![class decl]
@@ -59,7 +52,6 @@ class QtQuickLayoutsPlugin : public QQmlExtensionPlugin
public:
QtQuickLayoutsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent)
{
- initResources();
}
void registerTypes(const char *uri) override
{
diff --git a/src/imports/layouts/plugins.qmltypes b/src/imports/layouts/plugins.qmltypes
index afb563391d..f8d7b9acfe 100644
--- a/src/imports/layouts/plugins.qmltypes
+++ b/src/imports/layouts/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Layouts 1.3'
+// 'qmlplugindump -nonrelocatable QtQuick.Layouts 1.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickColumnLayout"
defaultProperty: "data"
diff --git a/src/imports/localstorage/dependencies.json b/src/imports/localstorage/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/imports/localstorage/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index 2fc976d37d..5c8177e238 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmllocalstorageplugin
TARGETPATH = QtQuick/LocalStorage
-IMPORT_VERSION = 2.$${QT_MINOR_VERSION}
+IMPORT_VERSION = 2.$$QT_MINOR_VERSION
QT = sql qml-private core-private
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 9cca11ac5d..e7e8d130bb 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -61,19 +61,12 @@
#include <private/qv4jscall_p.h>
#include <private/qv4objectiterator_p.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_LocalStorage);
-#endif
-}
-
QT_BEGIN_NAMESPACE
#define V4THROW_SQL(error, desc) { \
QV4::ScopedString v(scope, scope.engine->newString(desc)); \
QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
scope.engine->throwError(ex); \
RETURN_UNDEFINED(); \
}
@@ -81,7 +74,7 @@ QT_BEGIN_NAMESPACE
#define V4THROW_SQL2(error, desc) { \
QV4::ScopedString v(scope, scope.engine->newString(desc)); \
QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \
args->setReturnValue(scope.engine->throwError(ex)); \
return; \
}
@@ -148,13 +141,13 @@ public:
static Heap::QQmlSqlDatabaseWrapper *create(QV4::ExecutionEngine *engine)
{
- return engine->memoryManager->allocObject<QQmlSqlDatabaseWrapper>();
+ return engine->memoryManager->allocate<QQmlSqlDatabaseWrapper>();
}
~QQmlSqlDatabaseWrapper() {
}
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
};
}
@@ -244,12 +237,16 @@ static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r,
}
}
-ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue QQmlSqlDatabaseWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
+ if (!id.isArrayIndex())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
+ uint index = id.asArrayIndex();
Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m);
if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
- return Object::getIndexed(m, index, hasProperty);
+ return Object::virtualGet(m, id, receiver, hasProperty);
return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty);
}
@@ -294,7 +291,7 @@ static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Va
QSqlQuery query(db);
bool err = false;
- ScopedValue result(scope, Primitive::undefinedValue());
+ ScopedValue result(scope, Value::undefinedValue());
if (query.prepare(sql)) {
if (argc > 1) {
@@ -304,11 +301,11 @@ static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Va
quint32 size = array->getLength();
QV4::ScopedValue v(scope);
for (quint32 ii = 0; ii < size; ++ii) {
- query.bindValue(ii, toSqlVariant(scope.engine, (v = array->getIndexed(ii))));
+ query.bindValue(ii, toSqlVariant(scope.engine, (v = array->get(ii))));
}
} else if (values->as<Object>()) {
ScopedObject object(scope, values);
- ObjectIterator it(scope, object, ObjectIterator::WithProtoChain|ObjectIterator::EnumerableOnly);
+ ObjectIterator it(scope, object, ObjectIterator::EnumerableOnly);
ScopedValue key(scope);
QV4::ScopedValue val(scope);
while (1) {
@@ -330,7 +327,7 @@ static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Va
if (query.exec()) {
QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
QV4::ScopedObject p(scope, databaseData(scope.engine)->rowsProto.value());
- rows->setPrototype(p.getPointer());
+ rows->setPrototypeUnchecked(p.getPointer());
rows->d()->type = Heap::QQmlSqlDatabaseWrapper::Rows;
*rows->d()->database = db;
*rows->d()->sqlQuery = query;
@@ -340,7 +337,7 @@ static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Va
// XXX optimize
ScopedString s(scope);
ScopedValue v(scope);
- resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Primitive::fromInt32(query.numRowsAffected())));
+ resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected())));
resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString())));
resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows);
} else {
@@ -397,14 +394,14 @@ static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const
QSqlDatabase db = *r->d()->database;
QString from_version = argv[0].toQString();
QString to_version = argv[1].toQString();
- ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Value::undefinedValue());
if (from_version != *r->d()->version)
V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version));
Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
- w->setPrototype(p.getPointer());
+ w->setPrototypeUnchecked(p.getPointer());
w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
*w->d()->database = db;
*w->d()->version = *r->d()->version;
@@ -456,7 +453,7 @@ static ReturnedValue qmlsqldatabase_transaction_shared(const FunctionObject *b,
Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
QV4::ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
- w->setPrototype(p.getPointer());
+ w->setPrototypeUnchecked(p.getPointer());
w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
*w->d()->database = db;
*w->d()->version = *r->d()->version;
@@ -523,7 +520,7 @@ through the data.
/*!
- \qmlmodule QtQuick.LocalStorage 2.11
+ \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion
\title Qt Quick Local Storage QML Types
\ingroup qmlmodules
\brief Provides a JavaScript object singleton type for accessing a local
@@ -544,16 +541,16 @@ through the data.
To use the types in this module, import the module and call the
relevant functions using the \c LocalStorage type:
- \code
- import QtQuick.LocalStorage 2.0
- import QtQuick 2.0
+ \qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQuick.LocalStorage 2.\1
Item {
Component.onCompleted: {
var db = LocalStorage.openDatabaseSync(...)
}
}
- \endcode
+ \endqml
These databases are user-specific and QML-specific, but accessible to all QML applications.
@@ -573,11 +570,13 @@ The \l{Qt Quick Examples - Local Storage}{SQL Local Storage example} demonstrate
using the Offline Storage API.
\section3 Open or Create a Database
-\code
-import QtQuick.LocalStorage 2.0 as Sql
+
+\qml \QtMinorVersion
+import QtQuick.LocalStorage 2.\1 as Sql
db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db))
-\endcode
+\endqml
+
The above code returns the database identified by \e identifier. If the database does not already exist, it
is created, and the function \e callback is called with the database as a parameter. \e identifier is the
name of the physical file (with or without full path) containing the database. \e description and
@@ -780,7 +779,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
QV4::ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
- db->setPrototype(p.getPointer());
+ db->setPrototypeUnchecked(p.getPointer());
*db->d()->database = database;
*db->d()->version = version;
@@ -814,7 +813,6 @@ class QQmlLocalStoragePlugin : public QQmlExtensionPlugin
public:
QQmlLocalStoragePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent)
{
- initResources();
}
void registerTypes(const char *uri) override
{
diff --git a/src/imports/localstorage/plugins.qmltypes b/src/imports/localstorage/plugins.qmltypes
index 412989c001..59944328d6 100644
--- a/src/imports/localstorage/plugins.qmltypes
+++ b/src/imports/localstorage/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.LocalStorage 2.11'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.LocalStorage 2.12'
Module {
dependencies: []
diff --git a/src/imports/models/dependencies.json b/src/imports/models/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/imports/models/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp
index 83f8597408..2b19345f6b 100644
--- a/src/imports/models/plugin.cpp
+++ b/src/imports/models/plugin.cpp
@@ -42,17 +42,10 @@
#include <private/qqmlmodelsmodule_p.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQml_Models_2);
-#endif
-}
-
QT_BEGIN_NAMESPACE
/*!
- \qmlmodule QtQml.Models 2.11
+ \qmlmodule QtQml.Models 2.\QtMinorVersion
\title Qt QML Models QML Types
\ingroup qmlmodules
\brief Provides QML types for data models
@@ -62,9 +55,9 @@ QT_BEGIN_NAMESPACE
To use the types in this module, import the module with the following line:
- \code
- import QtQml.Models 2.11
- \endcode
+ \qml \QtMinorVersion
+ import QtQml.Models 2.\1
+ \endqml
Note that QtQml.Models module started at version 2.1 to match the version
of the parent module, \l{Qt QML}.
@@ -78,7 +71,7 @@ class QtQmlModelsPlugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQmlModelsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQmlModelsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQml.Models"));
diff --git a/src/imports/models/plugins.qmltypes b/src/imports/models/plugins.qmltypes
index 60146f51ba..87ec0fee76 100644
--- a/src/imports/models/plugins.qmltypes
+++ b/src/imports/models/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQml.Models 2.11'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.Models 2.12'
Module {
dependencies: []
diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp
index d548f26599..e2b8712599 100644
--- a/src/imports/particles/plugin.cpp
+++ b/src/imports/particles/plugin.cpp
@@ -42,13 +42,6 @@
#include <private/qquickparticlesmodule_p.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_Particles_2);
-#endif
-}
-
QT_BEGIN_NAMESPACE
//![class decl]
@@ -57,7 +50,7 @@ class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuick2ParticlesPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQuick2ParticlesPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Particles"));
diff --git a/src/imports/particles/plugins.qmltypes b/src/imports/particles/plugins.qmltypes
index 6c7c98cc71..b68be6c5da 100644
--- a/src/imports/particles/plugins.qmltypes
+++ b/src/imports/particles/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Particles 2.0'
+// 'qmlplugindump -nonrelocatable QtQuick.Particles 2.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickAgeAffector"
defaultProperty: "data"
diff --git a/src/imports/qtqml/plugins.qmltypes b/src/imports/qtqml/plugins.qmltypes
index 82333627a0..1ffe4a78ca 100644
--- a/src/imports/qtqml/plugins.qmltypes
+++ b/src/imports/qtqml/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -noforceqtquick QtQml 2.3'
+// 'qmlplugindump -nonrelocatable -noforceqtquick QtQml 2.12'
Module {
dependencies: []
@@ -96,7 +96,7 @@ Module {
exports: ["QtQml/Connections 2.0", "QtQml/Connections 2.3"]
exportMetaObjectRevisions: [0, 1]
Property { name: "target"; type: "QObject"; isPointer: true }
- Property { name: "enabled"; type: "bool" }
+ Property { name: "enabled"; revision: 1; type: "bool" }
Property { name: "ignoreUnknownSignals"; type: "bool" }
Signal { name: "enabledChanged"; revision: 1 }
}
@@ -198,9 +198,20 @@ Module {
Component {
name: "QQmlLoggingCategory"
prototype: "QObject"
- exports: ["QtQml/LoggingCategory 2.8"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQml/LoggingCategory 2.12", "QtQml/LoggingCategory 2.8"]
+ exportMetaObjectRevisions: [1, 0]
+ Enum {
+ name: "DefaultLogLevel"
+ values: {
+ "Debug": 0,
+ "Info": 4,
+ "Warning": 1,
+ "Critical": 2,
+ "Fatal": 3
+ }
+ }
Property { name: "name"; type: "string" }
+ Property { name: "defaultLogLevel"; revision: 1; type: "DefaultLogLevel" }
}
Component {
name: "QQmlTimer"
@@ -229,5 +240,6 @@ Module {
Property { name: "wasHeld"; type: "bool"; isReadonly: true }
Property { name: "isClick"; type: "bool"; isReadonly: true }
Property { name: "accepted"; type: "bool" }
+ Property { name: "flags"; revision: 11; type: "int"; isReadonly: true }
}
}
diff --git a/src/imports/qtqml/qtqml.pro b/src/imports/qtqml/qtqml.pro
index 8804c944e7..c00172ddc4 100644
--- a/src/imports/qtqml/qtqml.pro
+++ b/src/imports/qtqml/qtqml.pro
@@ -7,8 +7,6 @@ load(qml_module)
!cross_compile:if(build_pass|!debug_and_release) {
qtPrepareTool(QMLPLUGINDUMP, qmlplugindump)
- # Use QtQml version defined in qmlplugindump source
- # TODO: retrieve the correct version from QtQml
- qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable QtQml 2.2 > $$PWD/plugins.qmltypes
+ qmltypes.commands = $$QMLPLUGINDUMP -nonrelocatable -noforceqtquick QtQml 2.$$QT_MINOR_VERSION > $$PWD/plugins.qmltypes
QMAKE_EXTRA_TARGETS += qmltypes
}
diff --git a/src/imports/qtquick2/dependencies.json b/src/imports/qtquick2/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/imports/qtquick2/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp
index 147f01e81b..d73a8b3688 100644
--- a/src/imports/qtquick2/plugin.cpp
+++ b/src/imports/qtquick2/plugin.cpp
@@ -41,13 +41,6 @@
#include <private/qtquick2_p.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_2);
-#endif
-}
-
QT_BEGIN_NAMESPACE
//![class decl]
@@ -56,7 +49,7 @@ class QtQuick2Plugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuick2Plugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQuick2Plugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick"));
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes
index 6f6f1de8c3..456db6316e 100644
--- a/src/imports/qtquick2/plugins.qmltypes
+++ b/src/imports/qtquick2/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick 2.11'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick 2.12'
Module {
dependencies: []
@@ -742,9 +742,9 @@ Module {
Component {
name: "QQuickAbstractAnimation"
prototype: "QObject"
- exports: ["QtQuick/Animation 2.0"]
+ exports: ["QtQuick/Animation 2.0", "QtQuick/Animation 2.12"]
isCreatable: false
- exportMetaObjectRevisions: [0]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "Loops"
values: {
@@ -773,6 +773,7 @@ Module {
name: "loopCountChanged"
Parameter { type: "int" }
}
+ Signal { name: "finished"; revision: 12 }
Method { name: "restart" }
Method { name: "start" }
Method { name: "pause" }
@@ -960,8 +961,8 @@ Module {
name: "QQuickAnimatedSprite"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/AnimatedSprite 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/AnimatedSprite 2.0", "QtQuick/AnimatedSprite 2.12"]
+ exportMetaObjectRevisions: [0, 12]
Enum {
name: "LoopParameters"
values: {
@@ -1043,6 +1044,7 @@ Module {
name: "currentFrameChanged"
Parameter { name: "arg"; type: "int" }
}
+ Signal { name: "finished"; revision: 12 }
Method { name: "start" }
Method { name: "stop" }
Method { name: "restart" }
@@ -1448,6 +1450,25 @@ Module {
Method { name: "drop"; type: "int" }
}
Component {
+ name: "QQuickDragAxis"
+ prototype: "QObject"
+ exports: ["QtQuick/DragAxis 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Property { name: "minimum"; type: "double" }
+ Property { name: "maximum"; type: "double" }
+ Property { name: "enabled"; type: "bool" }
+ }
+ Component {
+ name: "QQuickDragHandler"
+ prototype: "QQuickMultiPointHandler"
+ exports: ["QtQuick/DragHandler 2.12"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "xAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
+ Property { name: "yAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
+ Property { name: "translation"; type: "QVector2D"; isReadonly: true }
+ }
+ Component {
name: "QQuickDropArea"
defaultProperty: "data"
prototype: "QQuickItem"
@@ -1525,15 +1546,66 @@ Module {
Property { name: "type"; type: "Qt::EnterKeyType" }
}
Component {
+ name: "QQuickEventPoint"
+ prototype: "QObject"
+ exports: ["QtQuick/EventPoint 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "States"
+ values: {
+ "Pressed": 1,
+ "Updated": 2,
+ "Stationary": 4,
+ "Released": 8
+ }
+ }
+ Enum {
+ name: "GrabTransition"
+ values: {
+ "GrabPassive": 1,
+ "UngrabPassive": 2,
+ "CancelGrabPassive": 3,
+ "OverrideGrabPassive": 4,
+ "GrabExclusive": 16,
+ "UngrabExclusive": 32,
+ "CancelGrabExclusive": 48
+ }
+ }
+ Property { name: "event"; type: "QQuickPointerEvent"; isReadonly: true; isPointer: true }
+ Property { name: "position"; type: "QPointF"; isReadonly: true }
+ Property { name: "scenePosition"; type: "QPointF"; isReadonly: true }
+ Property { name: "scenePressPosition"; type: "QPointF"; isReadonly: true }
+ Property { name: "sceneGrabPosition"; type: "QPointF"; isReadonly: true }
+ Property { name: "state"; type: "State"; isReadonly: true }
+ Property { name: "pointId"; type: "int"; isReadonly: true }
+ Property { name: "timeHeld"; type: "double"; isReadonly: true }
+ Property { name: "velocity"; type: "QVector2D"; isReadonly: true }
+ Property { name: "accepted"; type: "bool" }
+ Property { name: "exclusiveGrabber"; type: "QObject"; isPointer: true }
+ }
+ Component {
+ name: "QQuickEventTouchPoint"
+ prototype: "QQuickEventPoint"
+ exports: ["QtQuick/EventTouchPoint 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Property { name: "rotation"; type: "double"; isReadonly: true }
+ Property { name: "pressure"; type: "double"; isReadonly: true }
+ Property { name: "ellipseDiameters"; type: "QSizeF"; isReadonly: true }
+ Property { name: "uniqueId"; type: "QPointingDeviceUniqueId"; isReadonly: true }
+ }
+ Component {
name: "QQuickFlickable"
defaultProperty: "flickableData"
prototype: "QQuickItem"
exports: [
"QtQuick/Flickable 2.0",
"QtQuick/Flickable 2.10",
+ "QtQuick/Flickable 2.12",
"QtQuick/Flickable 2.9"
]
- exportMetaObjectRevisions: [0, 10, 9]
+ exportMetaObjectRevisions: [0, 10, 12, 9]
Enum {
name: "BoundsBehavior"
values: {
@@ -1600,6 +1672,7 @@ Module {
isPointer: true
}
Property { name: "pixelAligned"; type: "bool" }
+ Property { name: "synchronousDrag"; revision: 12; type: "bool" }
Property { name: "horizontalOvershoot"; revision: 9; type: "double"; isReadonly: true }
Property { name: "verticalOvershoot"; revision: 9; type: "double"; isReadonly: true }
Property { name: "flickableData"; type: "QObject"; isList: true; isReadonly: true }
@@ -1612,8 +1685,13 @@ Module {
Signal { name: "flickEnded" }
Signal { name: "dragStarted" }
Signal { name: "dragEnded" }
+ Signal { name: "synchronousDragChanged"; revision: 12 }
Signal { name: "horizontalOvershootChanged"; revision: 9 }
Signal { name: "verticalOvershootChanged"; revision: 9 }
+ Signal { name: "atXEndChanged"; revision: 12 }
+ Signal { name: "atYEndChanged"; revision: 12 }
+ Signal { name: "atXBeginningChanged"; revision: 12 }
+ Signal { name: "atYBeginningChanged"; revision: 12 }
Method {
name: "resizeContent"
Parameter { name: "w"; type: "double" }
@@ -1836,9 +1914,17 @@ Module {
name: "QQuickGradient"
defaultProperty: "stops"
prototype: "QObject"
- exports: ["QtQuick/Gradient 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/Gradient 2.0", "QtQuick/Gradient 2.12"]
+ exportMetaObjectRevisions: [0, 12]
+ Enum {
+ name: "Orientation"
+ values: {
+ "Vertical": 2,
+ "Horizontal": 1
+ }
+ }
Property { name: "stops"; type: "QQuickGradientStop"; isList: true; isReadonly: true }
+ Property { name: "orientation"; revision: 12; type: "Orientation" }
Signal { name: "updated" }
}
Component {
@@ -2017,6 +2103,13 @@ Module {
}
Component { name: "QQuickGridViewAttached"; prototype: "QQuickItemViewAttached" }
Component {
+ name: "QQuickHoverHandler"
+ prototype: "QQuickSinglePointHandler"
+ exports: ["QtQuick/HoverHandler 2.12"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "hovered"; type: "bool"; isReadonly: true }
+ }
+ Component {
name: "QQuickImage"
defaultProperty: "data"
prototype: "QQuickImageBase"
@@ -2890,6 +2983,14 @@ Module {
Signal { name: "pressAndHoldIntervalChanged"; revision: 9 }
}
Component {
+ name: "QQuickMultiPointHandler"
+ prototype: "QQuickPointerDeviceHandler"
+ Property { name: "minimumPointCount"; type: "int" }
+ Property { name: "maximumPointCount"; type: "int" }
+ Property { name: "centroid"; type: "QQuickHandlerPoint"; isReadonly: true }
+ Signal { name: "marginChanged" }
+ }
+ Component {
name: "QQuickMultiPointTouchArea"
defaultProperty: "data"
prototype: "QQuickItem"
@@ -3401,6 +3502,213 @@ Module {
Property { name: "accepted"; type: "bool" }
}
Component {
+ name: "QQuickPinchHandler"
+ prototype: "QQuickMultiPointHandler"
+ exports: ["QtQuick/PinchHandler 2.12"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "minimumScale"; type: "double" }
+ Property { name: "maximumScale"; type: "double" }
+ Property { name: "minimumRotation"; type: "double" }
+ Property { name: "maximumRotation"; type: "double" }
+ Property { name: "scale"; type: "double"; isReadonly: true }
+ Property { name: "activeScale"; type: "double"; isReadonly: true }
+ Property { name: "rotation"; type: "double"; isReadonly: true }
+ Property { name: "translation"; type: "QVector2D"; isReadonly: true }
+ Property { name: "minimumX"; type: "double" }
+ Property { name: "maximumX"; type: "double" }
+ Property { name: "minimumY"; type: "double" }
+ Property { name: "maximumY"; type: "double" }
+ Property { name: "xAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
+ Property { name: "yAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true }
+ Signal { name: "updated" }
+ }
+ Component {
+ name: "QQuickPointHandler"
+ prototype: "QQuickSinglePointHandler"
+ exports: ["QtQuick/PointHandler 2.12"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "translation"; type: "QVector2D"; isReadonly: true }
+ }
+ Component {
+ name: "QQuickPointerDevice"
+ prototype: "QObject"
+ exports: ["QtQuick/PointerDevice 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "DeviceType"
+ values: {
+ "UnknownDevice": 0,
+ "Mouse": 1,
+ "TouchScreen": 2,
+ "TouchPad": 4,
+ "Puck": 8,
+ "Stylus": 16,
+ "Airbrush": 32,
+ "AllDevices": 32767
+ }
+ }
+ Enum {
+ name: "DeviceTypes"
+ values: {
+ "UnknownDevice": 0,
+ "Mouse": 1,
+ "TouchScreen": 2,
+ "TouchPad": 4,
+ "Puck": 8,
+ "Stylus": 16,
+ "Airbrush": 32,
+ "AllDevices": 32767
+ }
+ }
+ Enum {
+ name: "PointerType"
+ values: {
+ "GenericPointer": 1,
+ "Finger": 2,
+ "Pen": 4,
+ "Eraser": 8,
+ "Cursor": 16,
+ "AllPointerTypes": 32767
+ }
+ }
+ Enum {
+ name: "PointerTypes"
+ values: {
+ "GenericPointer": 1,
+ "Finger": 2,
+ "Pen": 4,
+ "Eraser": 8,
+ "Cursor": 16,
+ "AllPointerTypes": 32767
+ }
+ }
+ Enum {
+ name: "CapabilityFlag"
+ values: {
+ "Position": 1,
+ "Area": 2,
+ "Pressure": 4,
+ "Velocity": 8,
+ "MouseEmulation": 64,
+ "Scroll": 256,
+ "Hover": 512,
+ "Rotation": 1024,
+ "XTilt": 2048,
+ "YTilt": 4096
+ }
+ }
+ Enum {
+ name: "Capabilities"
+ values: {
+ "Position": 1,
+ "Area": 2,
+ "Pressure": 4,
+ "Velocity": 8,
+ "MouseEmulation": 64,
+ "Scroll": 256,
+ "Hover": 512,
+ "Rotation": 1024,
+ "XTilt": 2048,
+ "YTilt": 4096
+ }
+ }
+ Property { name: "type"; type: "DeviceType"; isReadonly: true }
+ Property { name: "pointerType"; type: "PointerType"; isReadonly: true }
+ Property { name: "capabilities"; type: "Capabilities"; isReadonly: true }
+ Property { name: "maximumTouchPoints"; type: "int"; isReadonly: true }
+ Property { name: "buttonCount"; type: "int"; isReadonly: true }
+ Property { name: "name"; type: "string"; isReadonly: true }
+ Property { name: "uniqueId"; type: "QPointingDeviceUniqueId"; isReadonly: true }
+ }
+ Component {
+ name: "QQuickPointerDeviceHandler"
+ prototype: "QQuickPointerHandler"
+ Property { name: "acceptedDevices"; type: "QQuickPointerDevice::DeviceTypes" }
+ Property { name: "acceptedPointerTypes"; type: "QQuickPointerDevice::PointerTypes" }
+ Property { name: "acceptedButtons"; type: "Qt::MouseButtons" }
+ Property { name: "acceptedModifiers"; type: "Qt::KeyboardModifiers" }
+ Method {
+ name: "setAcceptedDevices"
+ Parameter { name: "acceptedDevices"; type: "QQuickPointerDevice::DeviceTypes" }
+ }
+ Method {
+ name: "setAcceptedPointerTypes"
+ Parameter { name: "acceptedPointerTypes"; type: "QQuickPointerDevice::PointerTypes" }
+ }
+ Method {
+ name: "setAcceptedButtons"
+ Parameter { name: "buttons"; type: "Qt::MouseButtons" }
+ }
+ Method {
+ name: "setAcceptedModifiers"
+ Parameter { name: "acceptedModifiers"; type: "Qt::KeyboardModifiers" }
+ }
+ }
+ Component {
+ name: "QQuickPointerEvent"
+ prototype: "QObject"
+ exports: ["QtQuick/PointerEvent 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Property { name: "device"; type: "QQuickPointerDevice"; isReadonly: true; isPointer: true }
+ Property { name: "modifiers"; type: "Qt::KeyboardModifiers"; isReadonly: true }
+ Property { name: "button"; type: "Qt::MouseButtons"; isReadonly: true }
+ Property { name: "buttons"; type: "Qt::MouseButtons"; isReadonly: true }
+ }
+ Component {
+ name: "QQuickPointerHandler"
+ prototype: "QObject"
+ exports: ["QtQuick/PointerHandler 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "GrabPermissions"
+ values: {
+ "TakeOverForbidden": 0,
+ "CanTakeOverFromHandlersOfSameType": 1,
+ "CanTakeOverFromHandlersOfDifferentType": 2,
+ "CanTakeOverFromItems": 4,
+ "CanTakeOverFromAnything": 15,
+ "ApprovesTakeOverByHandlersOfSameType": 16,
+ "ApprovesTakeOverByHandlersOfDifferentType": 32,
+ "ApprovesTakeOverByItems": 64,
+ "ApprovesCancellation": 128,
+ "ApprovesTakeOverByAnything": 240
+ }
+ }
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "active"; type: "bool"; isReadonly: true }
+ Property { name: "target"; type: "QQuickItem"; isPointer: true }
+ Property { name: "parent"; type: "QQuickItem"; isReadonly: true; isPointer: true }
+ Property { name: "grabPermissions"; type: "GrabPermissions" }
+ Property { name: "margin"; type: "double" }
+ Signal {
+ name: "grabChanged"
+ Parameter { name: "transition"; type: "QQuickEventPoint::GrabTransition" }
+ Parameter { name: "point"; type: "QQuickEventPoint"; isPointer: true }
+ }
+ Signal { name: "grabPermissionChanged" }
+ Signal {
+ name: "canceled"
+ Parameter { name: "point"; type: "QQuickEventPoint"; isPointer: true }
+ }
+ }
+ Component {
+ name: "QQuickPointerMouseEvent"
+ prototype: "QQuickSinglePointEvent"
+ exports: ["QtQuick/PointerMouseEvent 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ }
+ Component {
+ name: "QQuickPointerTouchEvent"
+ prototype: "QQuickPointerEvent"
+ exports: ["QtQuick/PointerTouchEvent 2.12"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ }
+ Component {
name: "QQuickPositionerAttached"
prototype: "QObject"
Property { name: "index"; type: "int"; isReadonly: true }
@@ -3470,7 +3778,7 @@ Module {
exports: ["QtQuick/Rectangle 2.0"]
exportMetaObjectRevisions: [0]
Property { name: "color"; type: "QColor" }
- Property { name: "gradient"; type: "QQuickGradient"; isPointer: true }
+ Property { name: "gradient"; type: "QJSValue" }
Property { name: "border"; type: "QQuickPen"; isReadonly: true; isPointer: true }
Property { name: "radius"; type: "double" }
}
@@ -3580,6 +3888,10 @@ Module {
Property { name: "right"; type: "int" }
Property { name: "bottom"; type: "int" }
Signal { name: "borderChanged" }
+ Signal { name: "leftBorderChanged" }
+ Signal { name: "topBorderChanged" }
+ Signal { name: "rightBorderChanged" }
+ Signal { name: "bottomBorderChanged" }
}
Component {
name: "QQuickScriptAction"
@@ -3704,6 +4016,12 @@ Module {
Signal { name: "activated" }
Signal { name: "activatedAmbiguously" }
}
+ Component { name: "QQuickSinglePointEvent"; prototype: "QQuickPointerEvent" }
+ Component {
+ name: "QQuickSinglePointHandler"
+ prototype: "QQuickPointerDeviceHandler"
+ Property { name: "point"; type: "QQuickHandlerPoint"; isReadonly: true }
+ }
Component {
name: "QQuickSmoothedAnimation"
prototype: "QQuickNumberAnimation"
@@ -4012,18 +4330,84 @@ Module {
Signal { name: "paletteChanged" }
}
Component {
+ name: "QQuickTableView"
+ defaultProperty: "flickableData"
+ prototype: "QQuickFlickable"
+ exports: ["QtQuick/TableView 2.12"]
+ exportMetaObjectRevisions: [0]
+ attachedType: "QQuickTableViewAttached"
+ Property { name: "rows"; type: "int"; isReadonly: true }
+ Property { name: "columns"; type: "int"; isReadonly: true }
+ Property { name: "rowSpacing"; type: "double" }
+ Property { name: "columnSpacing"; type: "double" }
+ Property { name: "topMargin"; type: "double" }
+ Property { name: "bottomMargin"; type: "double" }
+ Property { name: "leftMargin"; type: "double" }
+ Property { name: "rightMargin"; type: "double" }
+ Property { name: "rowHeightProvider"; type: "QJSValue" }
+ Property { name: "columnWidthProvider"; type: "QJSValue" }
+ Property { name: "model"; type: "QVariant" }
+ Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
+ Property { name: "reuseItems"; type: "bool" }
+ Property { name: "contentWidth"; type: "double" }
+ Property { name: "contentHeight"; type: "double" }
+ Signal { name: "contentWidthOverrideChanged" }
+ Signal { name: "contentHeightOverrideChanged" }
+ Method { name: "forceLayout" }
+ }
+ Component {
+ name: "QQuickTableViewAttached"
+ prototype: "QObject"
+ Property { name: "view"; type: "QQuickTableView"; isReadonly: true; isPointer: true }
+ Signal { name: "pooled" }
+ Signal { name: "reused" }
+ }
+ Component {
+ name: "QQuickTapHandler"
+ prototype: "QQuickSinglePointHandler"
+ exports: ["QtQuick/TapHandler 2.12"]
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "GesturePolicy"
+ values: {
+ "DragThreshold": 0,
+ "WithinBounds": 1,
+ "ReleaseWithinBounds": 2
+ }
+ }
+ Property { name: "pressed"; type: "bool"; isReadonly: true }
+ Property { name: "tapCount"; type: "int"; isReadonly: true }
+ Property { name: "timeHeld"; type: "double"; isReadonly: true }
+ Property { name: "longPressThreshold"; type: "double" }
+ Property { name: "gesturePolicy"; type: "GesturePolicy" }
+ Signal {
+ name: "tapped"
+ Parameter { name: "eventPoint"; type: "QQuickEventPoint"; isPointer: true }
+ }
+ Signal {
+ name: "singleTapped"
+ Parameter { name: "eventPoint"; type: "QQuickEventPoint"; isPointer: true }
+ }
+ Signal {
+ name: "doubleTapped"
+ Parameter { name: "eventPoint"; type: "QQuickEventPoint"; isPointer: true }
+ }
+ Signal { name: "longPressed" }
+ }
+ Component {
name: "QQuickText"
defaultProperty: "data"
prototype: "QQuickImplicitSizeItem"
exports: [
"QtQuick/Text 2.0",
"QtQuick/Text 2.10",
+ "QtQuick/Text 2.12",
"QtQuick/Text 2.2",
"QtQuick/Text 2.3",
"QtQuick/Text 2.6",
"QtQuick/Text 2.9"
]
- exportMetaObjectRevisions: [0, 10, 2, 3, 6, 9]
+ exportMetaObjectRevisions: [0, 10, 12, 2, 3, 6, 9]
Enum {
name: "HAlignment"
values: {
@@ -4174,6 +4558,16 @@ Module {
}
Signal { name: "contentSizeChanged" }
Signal {
+ name: "contentWidthChanged"
+ revision: 12
+ Parameter { name: "contentWidth"; type: "double" }
+ }
+ Signal {
+ name: "contentHeightChanged"
+ revision: 12
+ Parameter { name: "contentHeight"; type: "double" }
+ }
+ Signal {
name: "lineHeightChanged"
Parameter { name: "lineHeight"; type: "double" }
}
diff --git a/src/imports/qtquick2/qtquick2.pro b/src/imports/qtquick2/qtquick2.pro
index 01ac034104..744dce4195 100644
--- a/src/imports/qtquick2/qtquick2.pro
+++ b/src/imports/qtquick2/qtquick2.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtquick2plugin
TARGETPATH = QtQuick.2
-IMPORT_VERSION = 2.11
+IMPORT_VERSION = 2.$$QT_MINOR_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/settings/dependencies.json b/src/imports/settings/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/imports/settings/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp
index 65de78a2f1..3ac0ad4653 100644
--- a/src/imports/settings/plugin.cpp
+++ b/src/imports/settings/plugin.cpp
@@ -42,13 +42,6 @@
#include "qqmlsettings_p.h"
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_Qt_labs_settings);
-#endif
-}
-
QT_BEGIN_NAMESPACE
class QmlSettingsPlugin : public QQmlExtensionPlugin
@@ -57,11 +50,12 @@ class QmlSettingsPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QmlSettingsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QmlSettingsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings"));
qmlRegisterType<QQmlSettings>(uri, 1, 0, "Settings");
+ qmlRegisterType<QQmlSettings,1>(uri, 1, 1, "Settings");
}
};
diff --git a/src/imports/settings/plugins.qmltypes b/src/imports/settings/plugins.qmltypes
index 40d8746525..1d69fcf7e9 100644
--- a/src/imports/settings/plugins.qmltypes
+++ b/src/imports/settings/plugins.qmltypes
@@ -4,15 +4,38 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -noforceqtquick Qt.labs.settings 1.0'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json Qt.labs.settings 1.1'
Module {
dependencies: []
Component {
name: "QQmlSettings"
prototype: "QObject"
- exports: ["Qt.labs.settings/Settings 1.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "Qt.labs.settings/Settings 1.0",
+ "Qt.labs.settings/Settings 1.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "category"; type: "string" }
+ Property { name: "fileName"; revision: 1; type: "string" }
+ Method {
+ name: "value"
+ revision: 1
+ type: "QVariant"
+ Parameter { name: "key"; type: "string" }
+ Parameter { name: "defaultValue"; type: "QVariant" }
+ }
+ Method {
+ name: "value"
+ revision: 1
+ type: "QVariant"
+ Parameter { name: "key"; type: "string" }
+ }
+ Method {
+ name: "setValue"
+ revision: 1
+ Parameter { name: "key"; type: "string" }
+ Parameter { name: "value"; type: "QVariant" }
+ }
}
}
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp
index 2271774643..6b3904909a 100644
--- a/src/imports/settings/qqmlsettings.cpp
+++ b/src/imports/settings/qqmlsettings.cpp
@@ -156,7 +156,8 @@ QT_BEGIN_NAMESPACE
Application specific settings are identified by providing application
\l {QCoreApplication::applicationName}{name},
\l {QCoreApplication::organizationName}{organization} and
- \l {QCoreApplication::organizationDomain}{domain}.
+ \l {QCoreApplication::organizationDomain}{domain}, or by specifying
+ \l fileName.
\code
#include <QGuiApplication>
@@ -258,6 +259,7 @@ public:
int timerId = 0;
bool initialized = false;
QString category;
+ QString fileName;
mutable QPointer<QSettings> settings;
QHash<const char *, QVariant> changedProperties;
};
@@ -268,7 +270,7 @@ QSettings *QQmlSettingsPrivate::instance() const
{
if (!settings) {
QQmlSettings *q = const_cast<QQmlSettings*>(q_func());
- settings = new QSettings(q);
+ settings = fileName.isEmpty() ? new QSettings(q) : new QSettings(fileName, QSettings::IniFormat, q);
if (!category.isEmpty())
settings->beginGroup(category);
if (initialized)
@@ -299,6 +301,11 @@ void QQmlSettingsPrivate::load()
const QMetaObject *mo = q->metaObject();
const int offset = mo->propertyOffset();
const int count = mo->propertyCount();
+
+ // don't save built-in properties if there aren't any qml properties
+ if (offset == 1)
+ return;
+
for (int i = offset; i < count; ++i) {
QMetaProperty property = mo->property(i);
@@ -398,6 +405,66 @@ void QQmlSettings::setCategory(const QString &category)
}
}
+/*!
+ \qmlproperty string Settings::fileName
+
+ This property holds the path to the settings file. If the file doesn't
+ already exist, it is created.
+
+ \sa QSettings::fileName, QSettings::IniFormat
+
+ \since Qt.labs.settings 1.1
+*/
+QString QQmlSettings::fileName() const
+{
+ Q_D(const QQmlSettings);
+ return d->fileName;
+}
+
+void QQmlSettings::setFileName(const QString &fileName)
+{
+ Q_D(QQmlSettings);
+ if (d->fileName != fileName) {
+ d->reset();
+ d->fileName = fileName;
+ if (d->initialized)
+ d->load();
+ }
+}
+
+/*!
+ \qmlmethod var Settings::value(string key, var defaultValue)
+
+ Returns the value for setting \a key. If the setting doesn't exist,
+ returns \a defaultValue.
+
+ \sa QSettings::value
+
+ \since Qt.labs.settings 1.1
+*/
+QVariant QQmlSettings::value(const QString &key, const QVariant &defaultValue) const
+{
+ Q_D(const QQmlSettings);
+ return d->instance()->value(key, defaultValue);
+}
+
+/*!
+ \qmlmethod Settings::setValue(string key, var value)
+
+ Sets the value of setting key to value. If the key already exists,
+ the previous value is overwritten.
+
+ \sa QSettings::setValue
+
+ \since Qt.labs.settings 1.1
+*/
+void QQmlSettings::setValue(const QString &key, const QVariant &value)
+{
+ Q_D(const QQmlSettings);
+ d->instance()->setValue(key, value);
+ qCDebug(lcSettings) << "QQmlSettings: setValue" << key << ":" << value;
+}
+
void QQmlSettings::classBegin()
{
}
diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h
index ce942d7564..f73e595557 100644
--- a/src/imports/settings/qqmlsettings_p.h
+++ b/src/imports/settings/qqmlsettings_p.h
@@ -65,6 +65,7 @@ class QQmlSettings : public QObject, public QQmlParserStatus
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString category READ category WRITE setCategory FINAL)
+ Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL REVISION 1)
public:
explicit QQmlSettings(QObject *parent = 0);
@@ -73,6 +74,12 @@ public:
QString category() const;
void setCategory(const QString &category);
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ Q_REVISION(1) Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
+ Q_REVISION(1) Q_INVOKABLE void setValue(const QString &key, const QVariant &value);
+
protected:
void timerEvent(QTimerEvent *event) override;
diff --git a/src/imports/settings/settings.pro b/src/imports/settings/settings.pro
index 29229f59cb..816a6a9fef 100644
--- a/src/imports/settings/settings.pro
+++ b/src/imports/settings/settings.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlsettingsplugin
TARGETPATH = Qt/labs/settings
-IMPORT_VERSION = 1.0
+IMPORT_VERSION = 1.1
QT = core qml
diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp
index f0e66479b6..e3a9017681 100644
--- a/src/imports/shapes/plugin.cpp
+++ b/src/imports/shapes/plugin.cpp
@@ -39,16 +39,7 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-
-#include "qquickshape_p.h"
-
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_Shapes);
-#endif
- Q_INIT_RESOURCE(qtquickshapesplugin);
-}
+#include <QtQuickShapes/private/qquickshape_p.h>
QT_BEGIN_NAMESPACE
@@ -58,7 +49,11 @@ class QmlShapesPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QmlShapesPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QmlShapesPlugin(QObject *parent = nullptr)
+ : QQmlExtensionPlugin(parent)
+ {
+ }
+
void registerTypes(const char *uri) override
{
Q_ASSERT(QByteArray(uri) == QByteArray("QtQuick.Shapes"));
diff --git a/src/imports/shapes/plugins.qmltypes b/src/imports/shapes/plugins.qmltypes
index a140644d6d..a851b20ed2 100644
--- a/src/imports/shapes/plugins.qmltypes
+++ b/src/imports/shapes/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Shapes 1.11'
+// 'qmlplugindump -nonrelocatable QtQuick.Shapes 1.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickShape"
defaultProperty: "data"
diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro
index 4d6e9508af..857fcd7564 100644
--- a/src/imports/shapes/shapes.pro
+++ b/src/imports/shapes/shapes.pro
@@ -1,33 +1,11 @@
CXX_MODULE = qml
TARGET = qmlshapesplugin
TARGETPATH = QtQuick/Shapes
-IMPORT_VERSION = 1.11
+IMPORT_VERSION = 1.$$QT_MINOR_VERSION
-QT = core gui-private qml quick-private
-
-HEADERS += \
- qquickshape_p.h \
- qquickshape_p_p.h \
- qquickshapegenericrenderer_p.h \
- qquickshapesoftwarerenderer_p.h
+QT = core gui-private qml quick-private quickshapes-private
SOURCES += \
plugin.cpp \
- qquickshape.cpp \
- qquickshapegenericrenderer.cpp \
- qquickshapesoftwarerenderer.cpp
-
-qtConfig(opengl) {
- HEADERS += \
- qquicknvprfunctions_p.h \
- qquicknvprfunctions_p_p.h \
- qquickshapenvprrenderer_p.h
-
- SOURCES += \
- qquicknvprfunctions.cpp \
- qquickshapenvprrenderer.cpp
-}
-
-RESOURCES += qtquickshapesplugin.qrc
load(qml_plugin)
diff --git a/src/imports/sharedimage/plugins.qmltypes b/src/imports/sharedimage/plugins.qmltypes
index 46fa24df1a..504186936b 100644
--- a/src/imports/sharedimage/plugins.qmltypes
+++ b/src/imports/sharedimage/plugins.qmltypes
@@ -7,5 +7,5 @@ import QtQuick.tooling 1.2
// 'qmlplugindump -nonrelocatable Qt.labs.sharedimage 1.0'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
}
diff --git a/src/imports/statemachine/dependencies.json b/src/imports/statemachine/dependencies.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/src/imports/statemachine/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
index 93ced6e280..bf7499b31a 100644
--- a/src/imports/statemachine/plugin.cpp
+++ b/src/imports/statemachine/plugin.cpp
@@ -47,13 +47,6 @@
#include <QQmlExtensionPlugin>
#include <qqml.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQml_StateMachine);
-#endif
-}
-
QT_BEGIN_NAMESPACE
class QtQmlStateMachinePlugin : public QQmlExtensionPlugin
@@ -62,7 +55,7 @@ class QtQmlStateMachinePlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
qmlRegisterType<State>(uri, 1, 0, "State");
diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes
index e6ecaa75c8..001efd3847 100644
--- a/src/imports/statemachine/plugins.qmltypes
+++ b/src/imports/statemachine/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQml.StateMachine 1.11'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.StateMachine 1.12'
Module {
dependencies: []
diff --git a/src/imports/statemachine/signaltransition.cpp b/src/imports/statemachine/signaltransition.cpp
index ab625788bb..d4ea25cc4b 100644
--- a/src/imports/statemachine/signaltransition.cpp
+++ b/src/imports/statemachine/signaltransition.cpp
@@ -185,12 +185,12 @@ void SignalTransition::connectTriggered()
m_signalExpression = expression;
}
-void SignalTransitionParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props)
+void SignalTransitionParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
for (int ii = 0; ii < props.count(); ++ii) {
const QV4::CompiledData::Binding *binding = props.at(ii);
- QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propName = compilationUnit->stringAt(binding->propertyNameIndex);
if (propName != QLatin1String("onTriggered")) {
error(props.at(ii), SignalTransition::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
@@ -204,7 +204,7 @@ void SignalTransitionParser::verifyBindings(const QV4::CompiledData::Unit *qmlUn
}
}
-void SignalTransitionParser::applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void SignalTransitionParser::applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
SignalTransition *st = qobject_cast<SignalTransition*>(object);
st->m_compilationUnit = compilationUnit;
diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h
index d7a3b7b618..90e6f96fbc 100644
--- a/src/imports/statemachine/signaltransition.h
+++ b/src/imports/statemachine/signaltransition.h
@@ -97,8 +97,8 @@ private:
class SignalTransitionParser : public QQmlCustomParser
{
public:
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
- void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
QT_END_NAMESPACE
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 77b644d3f2..535e29ee70 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -1084,6 +1084,24 @@ Item {
does not occur, then the test will fail. Similar to
\c{QTest::ignoreMessage(QtWarningMsg, message)} in C++.
+ Since Qt 5.12, \a message can be either a string, or a regular
+ expression providing a pattern of messages to ignore.
+
+ For example, the following snippet will ignore a string warning message:
+ \qml
+ ignoreWarning("Something sort of bad happened")
+ \endqml
+
+ And the following snippet will ignore a regular expression matching a
+ number of possible warning messages:
+ \qml
+ ignoreWarning(new RegExp("[0-9]+ bad things happened"))
+ \endqml
+
+ \note Despite being a JavaScript RegExp object, it will not be
+ interpreted as such; instead, the pattern will be passed to
+ \l QRegularExpression.
+
\sa warn()
*/
function ignoreWarning(msg) {
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index 443229bee9..af15a44012 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -54,13 +54,6 @@ QML_DECLARE_TYPE(QuickTestEvent)
#include <QtDebug>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtTest);
-#endif
-}
-
QT_BEGIN_NAMESPACE
class QuickTestUtil : public QObject
@@ -150,7 +143,7 @@ class QTestQmlModule : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QTestQmlModule(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QTestQmlModule(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest"));
diff --git a/src/imports/testlib/plugins.qmltypes b/src/imports/testlib/plugins.qmltypes
index 7f3140d86b..56b4ecf662 100644
--- a/src/imports/testlib/plugins.qmltypes
+++ b/src/imports/testlib/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -noforceqtquick QtTest 1.2'
+// 'qmlplugindump -nonrelocatable QtTest 1.12'
Module {
dependencies: ["QtQuick 2.0", "QtQuick.Window 2.0"]
@@ -269,7 +269,7 @@ Module {
}
Method {
name: "ignoreWarning"
- Parameter { name: "message"; type: "string" }
+ Parameter { name: "message"; type: "QJSValue" }
}
Method {
name: "wait"
diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp
index 907eecb060..657b230fa2 100644
--- a/src/imports/window/plugin.cpp
+++ b/src/imports/window/plugin.cpp
@@ -41,17 +41,10 @@
#include <private/qquickwindowmodule_p.h>
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_Window_2);
-#endif
-}
-
QT_BEGIN_NAMESPACE
/*!
- \qmlmodule QtQuick.Window 2.11
+ \qmlmodule QtQuick.Window 2.\QtMinorVersion
\title Qt Quick Window QML Types
\ingroup qmlmodules
\brief Provides QML types for window management
@@ -60,9 +53,9 @@ QT_BEGIN_NAMESPACE
To use the types in this module, import the module with the following line:
- \code
- import QtQuick.Window 2.11
- \endcode
+ \qml \QtMinorVersion
+ import QtQuick.Window 2.\1
+ \endqml
*/
@@ -72,7 +65,7 @@ class QtQuick2WindowPlugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuick2WindowPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); }
+ QtQuick2WindowPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Window"));
diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes
index 4815be7262..8ecb09968c 100644
--- a/src/imports/window/plugins.qmltypes
+++ b/src/imports/window/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Window 2.11'
+// 'qmlplugindump -nonrelocatable QtQuick.Window 2.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickRootItem"
defaultProperty: "data"
diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp
index 82e11eeeb3..c5356b8534 100644
--- a/src/imports/xmllistmodel/plugin.cpp
+++ b/src/imports/xmllistmodel/plugin.cpp
@@ -42,13 +42,6 @@
#include "qqmlxmllistmodel_p.h"
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_QtQuick_XmlListModel);
-#endif
-}
-
QT_BEGIN_NAMESPACE
class QmlXmlListModelPlugin : public QQmlExtensionPlugin
@@ -57,7 +50,7 @@ class QmlXmlListModelPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); }
+ QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel"));
diff --git a/src/imports/xmllistmodel/plugins.qmltypes b/src/imports/xmllistmodel/plugins.qmltypes
index cc675d5f83..951d0b6eeb 100644
--- a/src/imports/xmllistmodel/plugins.qmltypes
+++ b/src/imports/xmllistmodel/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.XmlListModel 2.0'
+// 'qmlplugindump -nonrelocatable QtQuick.XmlListModel 2.12'
Module {
- dependencies: ["QtQuick 2.8"]
+ dependencies: ["QtQuick 2.12"]
Component {
name: "QQuickXmlListModel"
defaultProperty: "roles"
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
index 773d9747f0..470b419c1f 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
@@ -54,8 +54,10 @@
#include <QXmlResultItems>
#include <QXmlNodeModelIndex>
#include <QBuffer>
+#if QT_CONFIG(qml_network)
#include <QNetworkRequest>
#include <QNetworkReply>
+#endif
#include <QTimer>
#include <QMutex>
@@ -72,7 +74,7 @@ typedef QPair<int, int> QQuickXmlListRange;
#define XMLLISTMODEL_CLEAR_ID 0
/*!
- \qmlmodule QtQuick.XmlListModel 2.11
+ \qmlmodule QtQuick.XmlListModel 2.\QtMinorVersion
\title Qt Quick XmlListModel QML Types
\ingroup qmlmodules
\brief Provides QML types for creating models from XML data
@@ -81,9 +83,9 @@ typedef QPair<int, int> QQuickXmlListRange;
To use the types in this module, import the module with the following line:
- \code
- import QtQuick.XmlListModel 2.11
- \endcode
+ \qml \QtMinorVersion
+ import QtQuick.XmlListModel 2.\1
+ \endqml
*/
/*!
@@ -542,7 +544,10 @@ class QQuickXmlListModelPrivate : public QAbstractItemModelPrivate
public:
QQuickXmlListModelPrivate()
: isComponentComplete(true), size(0), highestRole(Qt::UserRole)
- , reply(0), status(QQuickXmlListModel::Null), progress(0.0)
+#if QT_CONFIG(qml_network)
+ , reply(0)
+#endif
+ , status(QQuickXmlListModel::Null), progress(0.0)
, queryId(-1), roleObjects(), redirectCount(0) {}
@@ -555,6 +560,7 @@ public:
emit q->statusChanged(status);
}
+#if QT_CONFIG(qml_network)
void deleteReply() {
Q_Q(QQuickXmlListModel);
if (reply) {
@@ -563,6 +569,7 @@ public:
reply = 0;
}
}
+#endif
bool isComponentComplete;
QUrl src;
@@ -574,7 +581,9 @@ public:
QStringList roleNames;
int highestRole;
+#if QT_CONFIG(qml_network)
QNetworkReply *reply;
+#endif
QQuickXmlListModel::Status status;
QString errorString;
qreal progress;
@@ -1036,10 +1045,12 @@ void QQuickXmlListModel::reload()
if (d->size < 0)
d->size = 0;
+#if QT_CONFIG(qml_network)
if (d->reply) {
d->reply->abort();
d->deleteReply();
}
+#endif
if (!d->xml.isEmpty()) {
d->queryId = QQuickXmlQueryEngine::instance(qmlEngine(this))->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
@@ -1050,7 +1061,19 @@ void QQuickXmlListModel::reload()
d->notifyQueryStarted(false);
QTimer::singleShot(0, this, SLOT(dataCleared()));
+ } else if (QQmlFile::isLocalFile(d->src)) {
+ QFile file(QQmlFile::urlToLocalFileOrQrc(d->src));
+ QByteArray data = file.open(QIODevice::ReadOnly) ? file.readAll() : QByteArray();
+ d->notifyQueryStarted(false);
+ if (data.isEmpty()) {
+ d->queryId = XMLLISTMODEL_CLEAR_ID;
+ QTimer::singleShot(0, this, SLOT(dataCleared()));
+ } else {
+ d->queryId = QQuickXmlQueryEngine::instance(qmlEngine(this))->doQuery(
+ d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
+ }
} else {
+#if QT_CONFIG(qml_network)
d->notifyQueryStarted(true);
QNetworkRequest req(d->src);
req.setRawHeader("Accept", "application/xml,*/*");
@@ -1058,11 +1081,17 @@ void QQuickXmlListModel::reload()
QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(requestProgress(qint64,qint64)));
+#else
+ d->queryId = XMLLISTMODEL_CLEAR_ID;
+ d->notifyQueryStarted(false);
+ QTimer::singleShot(0, this, SLOT(dataCleared()));
+#endif
}
}
#define XMLLISTMODEL_MAX_REDIRECT 16
+#if QT_CONFIG(qml_network)
void QQuickXmlListModel::requestFinished()
{
Q_D(QQuickXmlListModel);
@@ -1108,6 +1137,7 @@ void QQuickXmlListModel::requestFinished()
emit progressChanged(d->progress);
}
}
+#endif
void QQuickXmlListModel::requestProgress(qint64 received, qint64 total)
{
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel_p.h b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
index e6a0898bb9..65f1299324 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
@@ -144,7 +144,9 @@ public Q_SLOTS:
void reload();
private Q_SLOTS:
+#if QT_CONFIG(qml_network)
void requestFinished();
+#endif
void requestProgress(qint64,qint64);
void dataCleared();
void queryCompleted(const QQuickXmlQueryResult &);
diff --git a/src/imports/xmllistmodel/xmllistmodel.pro b/src/imports/xmllistmodel/xmllistmodel.pro
index 5eaaaf6af9..1e61f4d3d9 100644
--- a/src/imports/xmllistmodel/xmllistmodel.pro
+++ b/src/imports/xmllistmodel/xmllistmodel.pro
@@ -3,7 +3,8 @@ TARGET = qmlxmllistmodelplugin
TARGETPATH = QtQuick/XmlListModel
IMPORT_VERSION = 2.$$QT_MINOR_VERSION
-QT = network xmlpatterns qml-private core-private
+QT = xmlpatterns qml-private core-private
+qtConfig(qml-network): QT += network
SOURCES += qqmlxmllistmodel.cpp plugin.cpp
HEADERS += qqmlxmllistmodel_p.h
diff --git a/src/particles/qquickcustomaffector.cpp b/src/particles/qquickcustomaffector.cpp
index 53557e1d0b..ccb00eeba2 100644
--- a/src/particles/qquickcustomaffector.cpp
+++ b/src/particles/qquickcustomaffector.cpp
@@ -154,7 +154,7 @@ void QQuickCustomAffector::affectSystem(qreal dt)
QV4::ScopedArrayObject array(scope, v4->newArrayObject(toAffect.size()));
QV4::ScopedValue v(scope);
for (int i=0; i<toAffect.size(); i++)
- array->putIndexed(i, (v = toAffect[i]->v4Value(m_system)));
+ array->put(i, (v = toAffect[i]->v4Value(m_system)));
if (dt >= simulationCutoff || dt <= simulationDelta) {
affectProperties(toAffect, dt);
diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp
index cd4cdcf3ef..5ec834a463 100644
--- a/src/particles/qquickparticleemitter.cpp
+++ b/src/particles/qquickparticleemitter.cpp
@@ -494,7 +494,7 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
QV4::ScopedArrayObject array(scope, v4->newArrayObject(toEmit.size()));
QV4::ScopedValue v(scope);
for (int i=0; i<toEmit.size(); i++)
- array->putIndexed(i, (v = toEmit[i]->v4Value(m_system)));
+ array->put(i, (v = toEmit[i]->v4Value(m_system)));
emitParticles(QQmlV4Handle(array));//A chance for arbitrary JS changes
}
diff --git a/src/particles/qquicktrailemitter.cpp b/src/particles/qquicktrailemitter.cpp
index f0a0b297e2..ca3ebbd4ec 100644
--- a/src/particles/qquicktrailemitter.cpp
+++ b/src/particles/qquicktrailemitter.cpp
@@ -273,7 +273,7 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
QV4::ScopedArrayObject array(scope, v4->newArrayObject(toEmit.size()));
QV4::ScopedValue v(scope);
for (int i=0; i<toEmit.size(); i++)
- array->putIndexed(i, (v = toEmit[i]->v4Value(m_system)));
+ array->put(i, (v = toEmit[i]->v4Value(m_system)));
if (isEmitFollowConnected())
emitFollowParticles(QQmlV4Handle(array), d->v4Value(m_system));//A chance for many arbitrary JS changes
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index eb9d2288d6..42b30f0472 100644
--- a/src/particles/qquickv4particledata.cpp
+++ b/src/particles/qquickv4particledata.cpp
@@ -518,9 +518,9 @@ QQuickV4ParticleData::QQuickV4ParticleData(QV4::ExecutionEngine* v4, QQuickParti
QV4::Scope scope(v4);
QV4ParticleDataDeletable *d = particleV4Data(scope.engine);
- QV4::ScopedObject o(scope, v4->memoryManager->allocObject<QV4ParticleData>(datum, system));
+ QV4::ScopedObject o(scope, v4->memoryManager->allocate<QV4ParticleData>(datum, system));
QV4::ScopedObject p(scope, d->proto.value());
- o->setPrototype(p);
+ o->setPrototypeUnchecked(p);
m_v4Value = o;
}
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 0afd71767e..86fdf87650 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += qml
-qtConfig(qml-debug):SUBDIRS += qmltooling
+qtConfig(thread):qtConfig(qml-debug):SUBDIRS += qmltooling
qtHaveModule(quick):SUBDIRS += scenegraph
diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
index e1d6263e36..3e75e39f86 100644
--- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
+++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
@@ -106,6 +106,9 @@ class QPacketProtocolPrivate : public QObjectPrivate
public:
QPacketProtocolPrivate(QIODevice *dev);
+ bool writeToDevice(const char *bytes, qint64 size);
+ bool readFromDevice(char *buffer, qint64 size);
+
QList<qint32> sendingPackets;
QList<QByteArray> packets;
QByteArray inProgress;
@@ -125,7 +128,6 @@ QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
Q_ASSERT(dev);
QObject::connect(dev, &QIODevice::readyRead, this, &QPacketProtocol::readyToRead);
- QObject::connect(dev, &QIODevice::aboutToClose, this, &QPacketProtocol::aboutToClose);
QObject::connect(dev, &QIODevice::bytesWritten, this, &QPacketProtocol::bytesWritten);
}
@@ -143,18 +145,18 @@ void QPacketProtocol::send(const QByteArray &data)
return; // We don't send empty packets
if (data.size() > maxSize) {
- emit invalidPacket();
+ emit error();
return;
}
- qint32 sendSize = data.size() + sizeof(qint32);
+ const qint32 sendSize = data.size() + static_cast<qint32>(sizeof(qint32));
d->sendingPackets.append(sendSize);
+
qint32 sendSizeLE = qToLittleEndian(sendSize);
- qint64 writeBytes = d->dev->write((char *)&sendSizeLE, sizeof(qint32));
- Q_UNUSED(writeBytes);
- Q_ASSERT(writeBytes == sizeof(qint32));
- writeBytes = d->dev->write(data);
- Q_ASSERT(writeBytes == data.size());
+ if (!d->writeToDevice((const char *)&sendSizeLE, sizeof(qint32))
+ || !d->writeToDevice(data.data(), data.size())) {
+ emit error();
+ }
}
/*!
@@ -206,17 +208,6 @@ bool QPacketProtocol::waitForReadyRead(int msecs)
} while (true);
}
-/*!
- Return the QIODevice passed to the QPacketProtocol constructor.
-*/
-void QPacketProtocol::aboutToClose()
-{
- Q_D(QPacketProtocol);
- d->inProgress.clear();
- d->sendingPackets.clear();
- d->inProgressSize = -1;
-}
-
void QPacketProtocol::bytesWritten(qint64 bytes)
{
Q_D(QPacketProtocol);
@@ -240,28 +231,40 @@ void QPacketProtocol::readyToRead()
// Need to get trailing data
if (-1 == d->inProgressSize) {
// We need a size header of sizeof(qint32)
- if (sizeof(qint32) > (uint)d->dev->bytesAvailable())
+ if (static_cast<qint64>(sizeof(qint32)) > d->dev->bytesAvailable())
return;
// Read size header
qint32 inProgressSizeLE;
- const qint64 read = d->dev->read((char *)&inProgressSizeLE, sizeof(qint32));
+ if (!d->readFromDevice((char *)&inProgressSizeLE, sizeof(qint32))) {
+ emit error();
+ return;
+ }
d->inProgressSize = qFromLittleEndian(inProgressSizeLE);
// Check sizing constraints
- if (read != sizeof(qint32) || d->inProgressSize < read) {
+ if (d->inProgressSize < qint32(sizeof(qint32))) {
disconnect(d->dev, &QIODevice::readyRead, this, &QPacketProtocol::readyToRead);
- disconnect(d->dev, &QIODevice::aboutToClose, this, &QPacketProtocol::aboutToClose);
disconnect(d->dev, &QIODevice::bytesWritten, this, &QPacketProtocol::bytesWritten);
d->dev = nullptr;
- emit invalidPacket();
+ emit error();
return;
}
- d->inProgressSize -= read;
+ d->inProgressSize -= sizeof(qint32);
} else {
- d->inProgress.append(d->dev->read(d->inProgressSize - d->inProgress.size()));
+ const int bytesToRead = static_cast<int>(
+ qMin(d->dev->bytesAvailable(),
+ static_cast<qint64>(d->inProgressSize - d->inProgress.size())));
+
+ QByteArray toRead(bytesToRead, Qt::Uninitialized);
+ if (!d->readFromDevice(toRead.data(), toRead.length())) {
+ emit error();
+ return;
+ }
+
+ d->inProgress.append(toRead);
if (d->inProgressSize == d->inProgress.size()) {
// Packet has arrived!
d->packets.append(d->inProgress);
@@ -281,6 +284,30 @@ QPacketProtocolPrivate::QPacketProtocolPrivate(QIODevice *dev) :
{
}
+bool QPacketProtocolPrivate::writeToDevice(const char *bytes, qint64 size)
+{
+ qint64 totalWritten = 0;
+ while (totalWritten < size) {
+ const qint64 chunkSize = dev->write(bytes + totalWritten, size - totalWritten);
+ if (chunkSize < 0)
+ return false;
+ totalWritten += chunkSize;
+ }
+ return totalWritten == size;
+}
+
+bool QPacketProtocolPrivate::readFromDevice(char *buffer, qint64 size)
+{
+ qint64 totalRead = 0;
+ while (totalRead < size) {
+ const qint64 chunkSize = dev->read(buffer + totalRead, size - totalRead);
+ if (chunkSize < 0)
+ return false;
+ totalRead += chunkSize;
+ }
+ return totalRead == size;
+}
+
/*!
\fn void QPacketProtocol::readyRead()
diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h
index 35edb568aa..b401a58437 100644
--- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h
+++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h
@@ -72,10 +72,9 @@ public:
Q_SIGNALS:
void readyRead();
- void invalidPacket();
+ void error();
private:
- void aboutToClose();
void bytesWritten(qint64 bytes);
void readyToRead();
};
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
index 95e6d5704c..3dfb755936 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
@@ -46,6 +46,7 @@
#include <private/qv4objectiterator_p.h>
#include <private/qv4identifier_p.h>
#include <private/qv4runtime_p.h>
+#include <private/qv4identifiertable_p.h>
#include <private/qqmlcontext_p.h>
#include <private/qqmlengine_p.h>
@@ -96,33 +97,28 @@ int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType s
{
switch (scopeType) {
case QV4::Heap::ExecutionContext::Type_GlobalContext:
- return 0;
- case QV4::Heap::ExecutionContext::Type_CatchContext:
- return 4;
+ break;
case QV4::Heap::ExecutionContext::Type_WithContext:
return 2;
case QV4::Heap::ExecutionContext::Type_CallContext:
return 1;
case QV4::Heap::ExecutionContext::Type_QmlContext:
return 3;
- default:
- return -1;
+ case QV4::Heap::ExecutionContext::Type_BlockContext:
+ return 4;
}
+ return 0;
}
QV4DataCollector::QV4DataCollector(QV4::ExecutionEngine *engine)
- : m_engine(engine), m_namesAsObjects(true), m_redundantRefs(true)
+ : m_engine(engine)
{
m_values.set(engine, engine->newArrayObject());
}
-// TODO: Directly call addRef() once we don't need to support redundantRefs anymore
-QV4DataCollector::Ref QV4DataCollector::collect(const QV4::ScopedValue &value)
+QV4DataCollector::Ref QV4DataCollector::addValueRef(const QV4::ScopedValue &value)
{
- Ref ref = addRef(value);
- if (m_redundantRefs)
- m_collectedRefs.append(ref);
- return ref;
+ return addRef(value);
}
const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::ExecutionEngine *engine,
@@ -158,15 +154,13 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution
int numProperties = 0;
QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly);
QV4::PropertyAttributes attrs;
- uint index;
QV4::ScopedProperty p(scope);
- QV4::ScopedString name(scope);
+ QV4::ScopedPropertyKey name(scope);
while (true) {
- it.next(name.getRef(), &index, p, &attrs);
- if (attrs.isEmpty())
+ name = it.next(p, &attrs);
+ if (!name->isValid())
break;
- else
- ++numProperties;
+ ++numProperties;
}
dict.insert(valueKey, numProperties);
return o;
@@ -192,61 +186,21 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution
}
}
-QJsonObject QV4DataCollector::lookupRef(Ref ref, bool deep)
+QJsonObject QV4DataCollector::lookupRef(Ref ref)
{
QJsonObject dict;
- if (m_namesAsObjects) {
- if (lookupSpecialRef(ref, &dict))
- return dict;
- }
-
- if (m_redundantRefs)
- deep = true;
-
dict.insert(QStringLiteral("handle"), qint64(ref));
QV4::Scope scope(engine());
QV4::ScopedValue value(scope, getValue(ref));
const QV4::Object *object = collectProperty(value, engine(), dict);
- if (deep && object)
+ if (object)
dict.insert(QStringLiteral("properties"), collectProperties(object));
return dict;
}
-// TODO: Drop this method once we don't need to support namesAsObjects anymore
-QV4DataCollector::Ref QV4DataCollector::addFunctionRef(const QString &functionName)
-{
- Q_ASSERT(m_namesAsObjects);
- Ref ref = addRef(QV4::Primitive::emptyValue(), false);
-
- QJsonObject dict;
- dict.insert(QStringLiteral("handle"), qint64(ref));
- dict.insert(QStringLiteral("type"), QStringLiteral("function"));
- dict.insert(QStringLiteral("name"), functionName);
- m_specialRefs.insert(ref, dict);
- m_collectedRefs.append(ref);
-
- return ref;
-}
-
-// TODO: Drop this method once we don't need to support namesAsObjects anymore
-QV4DataCollector::Ref QV4DataCollector::addScriptRef(const QString &scriptName)
-{
- Q_ASSERT(m_namesAsObjects);
- Ref ref = addRef(QV4::Primitive::emptyValue(), false);
-
- QJsonObject dict;
- dict.insert(QStringLiteral("handle"), qint64(ref));
- dict.insert(QStringLiteral("type"), QStringLiteral("script"));
- dict.insert(QStringLiteral("name"), scriptName);
- m_specialRefs.insert(ref, dict);
- m_collectedRefs.append(ref);
-
- return ref;
-}
-
bool QV4DataCollector::isValidRef(QV4DataCollector::Ref ref) const
{
QV4::Scope scope(engine());
@@ -268,12 +222,12 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr)
Refs collectedRefs;
QV4::ScopedValue v(scope);
- QV4::InternalClass *ic = ctxt->internalClass();
+ QV4::Heap::InternalClass *ic = ctxt->internalClass();
for (uint i = 0; i < ic->size; ++i) {
- QString name = ic->nameMap[i]->string;
+ QString name = ic->keyAt(i);
names.append(name);
v = static_cast<QV4::Heap::CallContext *>(ctxt->d())->locals[i];
- collectedRefs.append(collect(v));
+ collectedRefs.append(addValueRef(v));
}
Q_ASSERT(names.size() == collectedRefs.size());
@@ -284,13 +238,7 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr)
}
}
- Ref scopeObjectRef = addRef(scopeObject);
- if (m_redundantRefs) {
- dict->insert(QStringLiteral("ref"), qint64(scopeObjectRef));
- m_collectedRefs.append(scopeObjectRef);
- } else {
- *dict = lookupRef(scopeObjectRef, true);
- }
+ *dict = lookupRef(addRef(scopeObject));
return true;
}
@@ -306,13 +254,8 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int
QJsonObject frame;
frame[QLatin1String("index")] = frameNr;
frame[QLatin1String("debuggerFrame")] = false;
- if (m_namesAsObjects) {
- frame[QLatin1String("func")] = toRef(addFunctionRef(stackFrame.function));
- frame[QLatin1String("script")] = toRef(addScriptRef(stackFrame.source));
- } else {
- frame[QLatin1String("func")] = stackFrame.function;
- frame[QLatin1String("script")] = stackFrame.source;
- }
+ frame[QLatin1String("func")] = stackFrame.function;
+ frame[QLatin1String("script")] = stackFrame.source;
frame[QLatin1String("line")] = stackFrame.line - 1;
if (stackFrame.column >= 0)
frame[QLatin1String("column")] = stackFrame.column;
@@ -330,7 +273,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int
if (ctxt) {
QV4::ScopedValue o(scope, ctxt->d()->activation);
- frame[QLatin1String("receiver")] = toRef(collect(o));
+ frame[QLatin1String("receiver")] = toRef(addValueRef(o));
}
// Only type and index are used by Qt Creator, so we keep it easy:
@@ -351,30 +294,9 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int
return frame;
}
-// TODO: Drop this method once we don't need to support redundantRefs anymore
-QJsonArray QV4DataCollector::flushCollectedRefs()
-{
- Q_ASSERT(m_redundantRefs);
- QJsonArray refs;
- std::sort(m_collectedRefs.begin(), m_collectedRefs.end());
- for (int i = 0, ei = m_collectedRefs.size(); i != ei; ++i) {
- QV4DataCollector::Ref ref = m_collectedRefs.at(i);
- if (i > 0 && ref == m_collectedRefs.at(i - 1))
- continue;
- refs.append(lookupRef(ref, true));
- }
-
- m_collectedRefs.clear();
- return refs;
-}
-
void QV4DataCollector::clear()
{
m_values.set(engine(), engine()->newArrayObject());
- m_collectedRefs.clear();
- m_specialRefs.clear();
- m_namesAsObjects = true;
- m_redundantRefs = true;
}
QV4DataCollector::Ref QV4DataCollector::addRef(QV4::Value value, bool deduplicate)
@@ -394,18 +316,18 @@ QV4DataCollector::Ref QV4DataCollector::addRef(QV4::Value value, bool deduplicat
{ std::swap(*hasExceptionLoc, hadException); }
};
- // if we wouldn't do this, the putIndexed won't work.
+ // if we wouldn't do this, the put won't work.
ExceptionStateSaver resetExceptionState(engine());
QV4::Scope scope(engine());
QV4::ScopedObject array(scope, m_values.value());
if (deduplicate) {
for (Ref i = 0; i < array->getLength(); ++i) {
- if (array->getIndexed(i) == value.rawValue() && !m_specialRefs.contains(i))
+ if (array->get(i) == value.rawValue())
return i;
}
}
Ref ref = array->getLength();
- array->putIndexed(ref, value);
+ array->put(ref, value);
Q_ASSERT(array->getLength() - 1 == ref);
return ref;
}
@@ -415,19 +337,7 @@ QV4::ReturnedValue QV4DataCollector::getValue(Ref ref)
QV4::Scope scope(engine());
QV4::ScopedObject array(scope, m_values.value());
Q_ASSERT(ref < array->getLength());
- return array->getIndexed(ref, nullptr);
-}
-
-// TODO: Drop this method once we don't need to support namesAsObjects anymore
-bool QV4DataCollector::lookupSpecialRef(Ref ref, QJsonObject *dict)
-{
- Q_ASSERT(m_namesAsObjects);
- SpecialRefs::const_iterator it = m_specialRefs.constFind(ref);
- if (it == m_specialRefs.cend())
- return false;
-
- *dict = it.value();
- return true;
+ return array->get(ref, nullptr);
}
QJsonArray QV4DataCollector::collectProperties(const QV4::Object *object)
@@ -459,8 +369,6 @@ QJsonObject QV4DataCollector::collectAsJson(const QString &name, const QV4::Scop
if (value->isManaged() && !value->isString()) {
Ref ref = addRef(value);
dict.insert(QStringLiteral("ref"), qint64(ref));
- if (m_redundantRefs)
- m_collectedRefs.append(ref);
}
collectProperty(value, engine(), dict);
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
index 5494e10e9a..bc178fa2db 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h
@@ -67,42 +67,27 @@ public:
QV4DataCollector(QV4::ExecutionEngine *engine);
- Ref collect(const QV4::ScopedValue &value); // only for redundantRefs
- Ref addFunctionRef(const QString &functionName); // only for namesAsObjects
- Ref addScriptRef(const QString &scriptName); // only for namesAsObjects
-
- void setNamesAsObjects(bool namesAsObjects) { m_namesAsObjects = namesAsObjects; }
- bool namesAsObjects() const { return m_namesAsObjects; }
-
- void setRedundantRefs(bool redundantRefs) { m_redundantRefs = redundantRefs; }
- bool redundantRefs() const { return m_redundantRefs; }
+ Ref addValueRef(const QV4::ScopedValue &value);
bool isValidRef(Ref ref) const;
- QJsonObject lookupRef(Ref ref, bool deep);
+ QJsonObject lookupRef(Ref ref);
bool collectScope(QJsonObject *dict, int frameNr, int scopeNr);
QJsonObject buildFrame(const QV4::StackFrame &stackFrame, int frameNr);
QV4::ExecutionEngine *engine() const { return m_engine; }
- QJsonArray flushCollectedRefs(); // only for redundantRefs
void clear();
private:
Ref addRef(QV4::Value value, bool deduplicate = true);
QV4::ReturnedValue getValue(Ref ref);
- bool lookupSpecialRef(Ref ref, QJsonObject *dict); // only for namesAsObjects
QJsonArray collectProperties(const QV4::Object *object);
QJsonObject collectAsJson(const QString &name, const QV4::ScopedValue &value);
void collectArgumentsInContext();
QV4::ExecutionEngine *m_engine;
- Refs m_collectedRefs; // only for redundantRefs
QV4::PersistentValue m_values;
- typedef QHash<Ref, QJsonObject> SpecialRefs; // only for namesAsObjects
- SpecialRefs m_specialRefs; // only for namesAsObjects
- bool m_namesAsObjects;
- bool m_redundantRefs;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
index a1ed211a55..3170ee0c1b 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
@@ -70,7 +70,7 @@ QV4Debugger::QV4Debugger(QV4::ExecutionEngine *engine)
, m_pauseRequested(false)
, m_haveBreakPoints(false)
, m_breakOnThrow(false)
- , m_returnedValue(engine, QV4::Primitive::undefinedValue())
+ , m_returnedValue(engine, QV4::Value::undefinedValue())
, m_gatherSources(nullptr)
, m_runningJob(nullptr)
, m_collector(engine)
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
index 7950d21612..b424ef9f6c 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
@@ -65,7 +65,7 @@ void JavaScriptJob::run()
QV4::Scope scope(engine);
QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext()
- : engine->rootContext());
+ : engine->scriptContext());
QObject scopeObject;
QV4::CppStackFrame *frame = engine->currentStackFrame;
@@ -103,7 +103,7 @@ void JavaScriptJob::run()
}
}
- QV4::Script script(ctx, QV4::Compiler::EvalCode, this->script);
+ QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, this->script);
if (const QV4::Function *function = frame ? frame->v4Function : engine->globalCode)
script.strictMode = function->isStrict();
@@ -150,7 +150,6 @@ void BacktraceJob::run()
result.insert(QStringLiteral("toFrame"), fromFrame + frameArray.size());
result.insert(QStringLiteral("frames"), frameArray);
}
- flushRedundantRefs();
}
FrameJob::FrameJob(QV4DataCollector *collector, int frameNr) :
@@ -165,7 +164,6 @@ void FrameJob::run()
success = false;
} else {
result = collector->buildFrame(frames[frameNr], frameNr);
- flushRedundantRefs();
success = true;
}
}
@@ -195,7 +193,6 @@ void ScopeJob::run()
result[QLatin1String("index")] = scopeNr;
result[QLatin1String("frameIndex")] = frameNr;
result[QLatin1String("object")] = object;
- flushRedundantRefs();
}
bool ScopeJob::wasSuccessful() const
@@ -228,9 +225,8 @@ void ValueLookupJob::run()
exception = QString::fromLatin1("Invalid Ref: %1").arg(ref);
break;
}
- result[QString::number(ref)] = collector->lookupRef(ref, true);
+ result[QString::number(ref)] = collector->lookupRef(ref);
}
- flushRedundantRefs();
}
const QString &ValueLookupJob::exceptionMessage() const
@@ -249,9 +245,7 @@ void ExpressionEvalJob::handleResult(QV4::ScopedValue &value)
{
if (hasExeption())
exception = value->toQStringNoThrow();
- result = collector->lookupRef(collector->collect(value), true);
- if (collector->redundantRefs())
- collectedRefs = collector->flushCollectedRefs();
+ result = collector->lookupRef(collector->addValueRef(value));
}
const QString &ExpressionEvalJob::exceptionMessage() const
@@ -264,13 +258,6 @@ const QJsonObject &ExpressionEvalJob::returnValue() const
return result;
}
-// TODO: Drop this method once we don't need to support redundantRefs anymore
-const QJsonArray &ExpressionEvalJob::refs() const
-{
- Q_ASSERT(collector->redundantRefs());
- return collectedRefs;
-}
-
GatherSourcesJob::GatherSourcesJob(QV4::ExecutionEngine *engine)
: engine(engine)
{}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
index eca8710e15..d1c7495863 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
@@ -78,24 +78,10 @@ class CollectJob : public QV4DebugJob
protected:
QV4DataCollector *collector;
QJsonObject result;
- QJsonArray collectedRefs; // only for redundantRefs
-
- void flushRedundantRefs()
- {
- if (collector->redundantRefs())
- collectedRefs = collector->flushCollectedRefs();
- }
public:
CollectJob(QV4DataCollector *collector) : collector(collector) {}
const QJsonObject &returnValue() const { return result; }
-
- // TODO: Drop this method once we don't need to support redundantRefs anymore
- const QJsonArray &refs() const
- {
- Q_ASSERT(collector->redundantRefs());
- return collectedRefs;
- }
};
class BacktraceJob: public CollectJob
@@ -146,7 +132,6 @@ class ExpressionEvalJob: public JavaScriptJob
QV4DataCollector *collector;
QString exception;
QJsonObject result;
- QJsonArray collectedRefs; // only for redundantRefs
public:
ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context,
@@ -154,7 +139,6 @@ public:
void handleResult(QV4::ScopedValue &value) override;
const QString &exceptionMessage() const;
const QJsonObject &returnValue() const;
- const QJsonArray &refs() const; // only for redundantRefs
};
class GatherSourcesJob: public QV4DebugJob
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
index 32de8e9027..5866163ca6 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
@@ -67,21 +67,21 @@ const char *const V4_PAUSE = "interrupt";
QT_BEGIN_NAMESPACE
-class V8CommandHandler;
-class UnknownV8CommandHandler;
+class V4CommandHandler;
+class UnknownV4CommandHandler;
using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>;
int QV4DebugServiceImpl::sequence = 0;
-class V8CommandHandler
+class V4CommandHandler
{
public:
- V8CommandHandler(const QString &command)
+ V4CommandHandler(const QString &command)
: cmd(command)
{}
- virtual ~V8CommandHandler()
+ virtual ~V4CommandHandler()
{}
QString command() const { return cmd; }
@@ -122,21 +122,6 @@ protected:
response.insert(QStringLiteral("running"), debugService->debuggerAgent.isRunning());
}
- QV4DataCollector *saneCollector(QV4Debugger *debugger)
- {
- QV4DataCollector *collector = debugger->collector();
- collector->setNamesAsObjects(debugService->clientRequiresNamesAsObjects());
- collector->setRedundantRefs(debugService->clientRequiresRedundantRefs());
- return collector;
- }
-
- // TODO: drop this method once we don't need to support redundantRefs anymore.
- void addRefs(const QJsonArray &refs)
- {
- Q_ASSERT(debugService->clientRequiresRedundantRefs());
- response.insert(QStringLiteral("refs"), refs);
- }
-
void createErrorResponse(const QString &msg)
{
QJsonValue command = req.value(QLatin1String("command"));
@@ -158,10 +143,10 @@ protected:
QJsonObject response;
};
-class UnknownV8CommandHandler: public V8CommandHandler
+class UnknownV4CommandHandler: public V4CommandHandler
{
public:
- UnknownV8CommandHandler(): V8CommandHandler(QString()) {}
+ UnknownV4CommandHandler(): V4CommandHandler(QString()) {}
void handleRequest() override
{
@@ -173,10 +158,10 @@ public:
};
namespace {
-class V8VersionRequest: public V8CommandHandler
+class V4VersionRequest: public V4CommandHandler
{
public:
- V8VersionRequest(): V8CommandHandler(QStringLiteral("version")) {}
+ V4VersionRequest(): V4CommandHandler(QStringLiteral("version")) {}
void handleRequest() override
{
@@ -189,98 +174,137 @@ public:
QLatin1String("this is not V8, this is V4 in Qt " QT_VERSION_STR));
body.insert(QStringLiteral("UnpausedEvaluate"), true);
body.insert(QStringLiteral("ContextEvaluate"), true);
+ body.insert(QStringLiteral("ChangeBreakpoint"), true);
addBody(body);
}
};
-class V8SetBreakPointRequest: public V8CommandHandler
+class V4BreakPointRequest: public V4CommandHandler
{
public:
- V8SetBreakPointRequest(): V8CommandHandler(QStringLiteral("setbreakpoint")) {}
+ V4BreakPointRequest(const QString &name): V4CommandHandler(name) {}
- void handleRequest() override
+ void handleRequest() final
{
+ // Other types are currently not supported
+ m_type = QStringLiteral("scriptRegExp");
+
// decypher the payload:
- QJsonObject args = req.value(QLatin1String("arguments")).toObject();
- if (args.isEmpty())
+ m_args = req.value(QLatin1String("arguments")).toObject();
+ if (m_args.isEmpty()) {
+ createErrorResponse(QStringLiteral("breakpoint request with empty arguments object"));
return;
+ }
- QString type = args.value(QLatin1String("type")).toString();
+ const int id = handleBreakPointRequest();
+ if (id < 0) {
+ createErrorResponse(m_error);
+ } else {
+ // response:
+ addCommand();
+ addRequestSequence();
+ addSuccess(true);
+ addRunning();
+ QJsonObject body;
+ body.insert(QStringLiteral("type"), m_type);
+ body.insert(QStringLiteral("breakpoint"), id);
+ addBody(body);
+ }
+ }
+
+protected:
+ virtual int handleBreakPointRequest() = 0;
+
+ QJsonObject m_args;
+ QString m_type;
+ QString m_error;
+};
+
+class V4SetBreakPointRequest: public V4BreakPointRequest
+{
+public:
+ V4SetBreakPointRequest(): V4BreakPointRequest(QStringLiteral("setbreakpoint")) {}
+
+ int handleBreakPointRequest() final
+ {
+ // decypher the payload:
+ const QString type = m_args.value(QLatin1String("type")).toString();
if (type != QLatin1String("scriptRegExp")) {
- createErrorResponse(QStringLiteral("breakpoint type \"%1\" is not implemented").arg(type));
- return;
+ m_error = QStringLiteral("breakpoint type \"%1\" is not implemented").arg(type);
+ return -1;
}
- QString fileName = args.value(QLatin1String("target")).toString();
+ const QString fileName = m_args.value(QLatin1String("target")).toString();
if (fileName.isEmpty()) {
- createErrorResponse(QStringLiteral("breakpoint has no file name"));
- return;
+ m_error = QStringLiteral("breakpoint has no file name");
+ return -1;
}
- int line = args.value(QLatin1String("line")).toInt(-1);
+
+ const int line = m_args.value(QLatin1String("line")).toInt(-1);
if (line < 0) {
- createErrorResponse(QStringLiteral("breakpoint has an invalid line number"));
- return;
+ m_error = QStringLiteral("breakpoint has an invalid line number");
+ return -1;
}
- bool enabled = args.value(QStringLiteral("enabled")).toBool(true);
- QString condition = args.value(QStringLiteral("condition")).toString();
+ const bool enabled = m_args.value(QStringLiteral("enabled")).toBool(true);
+ const QString condition = m_args.value(QStringLiteral("condition")).toString();
// set the break point:
- int id = debugService->debuggerAgent.addBreakPoint(fileName, line + 1, enabled, condition);
+ return debugService->debuggerAgent.addBreakPoint(fileName, line + 1, enabled, condition);
- // response:
- addCommand();
- addRequestSequence();
- addSuccess(true);
- addRunning();
- QJsonObject body;
- body.insert(QStringLiteral("type"), type);
- body.insert(QStringLiteral("breakpoint"), id);
// It's undocumented, but V8 sends back an actual_locations array too. However, our
// Debugger currently doesn't tell us when it resolved a breakpoint, so we'll leave them
// pending until the breakpoint is hit for the first time.
- addBody(body);
}
};
-class V8ClearBreakPointRequest: public V8CommandHandler
+class V4ClearBreakPointRequest: public V4BreakPointRequest
{
public:
- V8ClearBreakPointRequest(): V8CommandHandler(QStringLiteral("clearbreakpoint")) {}
+ V4ClearBreakPointRequest(): V4BreakPointRequest(QStringLiteral("clearbreakpoint")) {}
- void handleRequest() override
+ int handleBreakPointRequest() final
{
- // decypher the payload:
- QJsonObject args = req.value(QLatin1String("arguments")).toObject();
- if (args.isEmpty())
- return;
+ const int id = m_args.value(QLatin1String("breakpoint")).toInt(-1);
+ if (id < 0)
+ m_error = QStringLiteral("breakpoint has an invalid number");
+ else // remove the break point:
+ debugService->debuggerAgent.removeBreakPoint(id);
- int id = args.value(QLatin1String("breakpoint")).toInt(-1);
+ return id;
+ }
+};
+
+class V4ChangeBreakPointRequest: public V4BreakPointRequest
+{
+public:
+ V4ChangeBreakPointRequest(): V4BreakPointRequest(QStringLiteral("changebreakpoint")) {}
+
+ int handleBreakPointRequest() final
+ {
+ const int id = m_args.value(QLatin1String("breakpoint")).toInt(-1);
if (id < 0) {
- createErrorResponse(QStringLiteral("breakpoint has an invalid number"));
- return;
+ m_error = QStringLiteral("breakpoint has an invalid number");
+ return id;
}
- // remove the break point:
- debugService->debuggerAgent.removeBreakPoint(id);
+ const QJsonValue enabled = m_args.value(QLatin1String("enabled"));
+ if (!enabled.isBool()) {
+ m_error = QStringLiteral("missing bool \"enabled\" in breakpoint change request");
+ return -1;
+ }
- // response:
- addCommand();
- addRequestSequence();
- addSuccess(true);
- addRunning();
- QJsonObject body;
- body.insert(QStringLiteral("type"), QStringLiteral("scriptRegExp"));
- body.insert(QStringLiteral("breakpoint"), id);
- addBody(body);
+ // enable or disable the break point:
+ debugService->debuggerAgent.enableBreakPoint(id, enabled.toBool());
+ return id;
}
};
-class V8BacktraceRequest: public V8CommandHandler
+class V4BacktraceRequest: public V4CommandHandler
{
public:
- V8BacktraceRequest(): V8CommandHandler(QStringLiteral("backtrace")) {}
+ V4BacktraceRequest(): V4CommandHandler(QStringLiteral("backtrace")) {}
void handleRequest() override
{
@@ -297,7 +321,7 @@ public:
return;
}
- BacktraceJob job(saneCollector(debugger), fromFrame, toFrame);
+ BacktraceJob job(debugger->collector(), fromFrame, toFrame);
debugger->runInEngine(&job);
// response:
@@ -306,15 +330,13 @@ public:
addSuccess(true);
addRunning();
addBody(job.returnValue());
- if (debugService->clientRequiresRedundantRefs())
- addRefs(job.refs());
}
};
-class V8FrameRequest: public V8CommandHandler
+class V4FrameRequest: public V4CommandHandler
{
public:
- V8FrameRequest(): V8CommandHandler(QStringLiteral("frame")) {}
+ V4FrameRequest(): V4CommandHandler(QStringLiteral("frame")) {}
void handleRequest() override
{
@@ -334,7 +356,7 @@ public:
return;
}
- FrameJob job(saneCollector(debugger), frameNr);
+ FrameJob job(debugger->collector(), frameNr);
debugger->runInEngine(&job);
if (!job.wasSuccessful()) {
createErrorResponse(QStringLiteral("frame retrieval failed"));
@@ -349,15 +371,13 @@ public:
addSuccess(true);
addRunning();
addBody(job.returnValue());
- if (debugService->clientRequiresRedundantRefs())
- addRefs(job.refs());
}
};
-class V8ScopeRequest: public V8CommandHandler
+class V4ScopeRequest: public V4CommandHandler
{
public:
- V8ScopeRequest(): V8CommandHandler(QStringLiteral("scope")) {}
+ V4ScopeRequest(): V4CommandHandler(QStringLiteral("scope")) {}
void handleRequest() override
{
@@ -382,7 +402,7 @@ public:
return;
}
- ScopeJob job(saneCollector(debugger), frameNr, scopeNr);
+ ScopeJob job(debugger->collector(), frameNr, scopeNr);
debugger->runInEngine(&job);
if (!job.wasSuccessful()) {
createErrorResponse(QStringLiteral("scope retrieval failed"));
@@ -395,15 +415,13 @@ public:
addSuccess(true);
addRunning();
addBody(job.returnValue());
- if (debugService->clientRequiresRedundantRefs())
- addRefs(job.refs());
}
};
-class V8LookupRequest: public V8CommandHandler
+class V4LookupRequest: public V4CommandHandler
{
public:
- V8LookupRequest(): V8CommandHandler(QStringLiteral("lookup")) {}
+ V4LookupRequest(): V4CommandHandler(QStringLiteral("lookup")) {}
void handleRequest() override
{
@@ -424,7 +442,7 @@ public:
debugger = debuggers.first();
}
- ValueLookupJob job(handles, saneCollector(debugger));
+ ValueLookupJob job(handles, debugger->collector());
debugger->runInEngine(&job);
if (!job.exceptionMessage().isEmpty()) {
createErrorResponse(job.exceptionMessage());
@@ -435,16 +453,14 @@ public:
addSuccess(true);
addRunning();
addBody(job.returnValue());
- if (debugService->clientRequiresRedundantRefs())
- addRefs(job.refs());
}
}
};
-class V8ContinueRequest: public V8CommandHandler
+class V4ContinueRequest: public V4CommandHandler
{
public:
- V8ContinueRequest(): V8CommandHandler(QStringLiteral("continue")) {}
+ V4ContinueRequest(): V4CommandHandler(QStringLiteral("continue")) {}
void handleRequest() override
{
@@ -487,10 +503,10 @@ public:
}
};
-class V8DisconnectRequest: public V8CommandHandler
+class V4DisconnectRequest: public V4CommandHandler
{
public:
- V8DisconnectRequest(): V8CommandHandler(QStringLiteral("disconnect")) {}
+ V4DisconnectRequest(): V4CommandHandler(QStringLiteral("disconnect")) {}
void handleRequest() override
{
@@ -505,10 +521,10 @@ public:
}
};
-class V8SetExceptionBreakRequest: public V8CommandHandler
+class V4SetExceptionBreakRequest: public V4CommandHandler
{
public:
- V8SetExceptionBreakRequest(): V8CommandHandler(QStringLiteral("setexceptionbreak")) {}
+ V4SetExceptionBreakRequest(): V4CommandHandler(QStringLiteral("setexceptionbreak")) {}
void handleRequest() override
{
@@ -545,10 +561,10 @@ public:
}
};
-class V8ScriptsRequest: public V8CommandHandler
+class V4ScriptsRequest: public V4CommandHandler
{
public:
- V8ScriptsRequest(): V8CommandHandler(QStringLiteral("scripts")) {}
+ V4ScriptsRequest(): V4CommandHandler(QStringLiteral("scripts")) {}
void handleRequest() override
{
@@ -617,10 +633,10 @@ public:
// }
//
// The "value" key in "body" is the result of evaluating the expression in the request.
-class V8EvaluateRequest: public V8CommandHandler
+class V4EvaluateRequest: public V4CommandHandler
{
public:
- V8EvaluateRequest(): V8CommandHandler(QStringLiteral("evaluate")) {}
+ V4EvaluateRequest(): V4CommandHandler(QStringLiteral("evaluate")) {}
void handleRequest() override
{
@@ -645,7 +661,7 @@ public:
}
ExpressionEvalJob job(debugger->engine(), frame, context, expression,
- saneCollector(debugger));
+ debugger->collector());
debugger->runInEngine(&job);
if (job.hasExeption()) {
createErrorResponse(job.exceptionMessage());
@@ -655,44 +671,43 @@ public:
addSuccess(true);
addRunning();
addBody(job.returnValue());
- if (debugService->clientRequiresRedundantRefs())
- addRefs(job.refs());
}
}
};
} // anonymous namespace
-void QV4DebugServiceImpl::addHandler(V8CommandHandler* handler)
+void QV4DebugServiceImpl::addHandler(V4CommandHandler* handler)
{
handlers[handler->command()] = handler;
}
-V8CommandHandler *QV4DebugServiceImpl::v8CommandHandler(const QString &command) const
+V4CommandHandler *QV4DebugServiceImpl::v4CommandHandler(const QString &command) const
{
- V8CommandHandler *handler = handlers.value(command, 0);
+ V4CommandHandler *handler = handlers.value(command, 0);
if (handler)
return handler;
else
- return unknownV8CommandHandler.data();
+ return unknownV4CommandHandler.data();
}
QV4DebugServiceImpl::QV4DebugServiceImpl(QObject *parent) :
QQmlConfigurableDebugService<QV4DebugService>(1, parent),
- debuggerAgent(this), theSelectedFrame(0), redundantRefs(true), namesAsObjects(true),
- unknownV8CommandHandler(new UnknownV8CommandHandler)
+ debuggerAgent(this), theSelectedFrame(0),
+ unknownV4CommandHandler(new UnknownV4CommandHandler)
{
- addHandler(new V8VersionRequest);
- addHandler(new V8SetBreakPointRequest);
- addHandler(new V8ClearBreakPointRequest);
- addHandler(new V8BacktraceRequest);
- addHandler(new V8FrameRequest);
- addHandler(new V8ScopeRequest);
- addHandler(new V8LookupRequest);
- addHandler(new V8ContinueRequest);
- addHandler(new V8DisconnectRequest);
- addHandler(new V8SetExceptionBreakRequest);
- addHandler(new V8ScriptsRequest);
- addHandler(new V8EvaluateRequest);
+ addHandler(new V4VersionRequest);
+ addHandler(new V4SetBreakPointRequest);
+ addHandler(new V4ClearBreakPointRequest);
+ addHandler(new V4ChangeBreakPointRequest);
+ addHandler(new V4BacktraceRequest);
+ addHandler(new V4FrameRequest);
+ addHandler(new V4ScopeRequest);
+ addHandler(new V4LookupRequest);
+ addHandler(new V4ContinueRequest);
+ addHandler(new V4DisconnectRequest);
+ addHandler(new V4SetExceptionBreakRequest);
+ addHandler(new V4ScriptsRequest);
+ addHandler(new V4EvaluateRequest);
}
QV4DebugServiceImpl::~QV4DebugServiceImpl()
@@ -782,12 +797,7 @@ void QV4DebugServiceImpl::messageReceived(const QByteArray &message)
if (type == V4_CONNECT) {
QJsonObject parameters = QJsonDocument::fromJson(payload).object();
- namesAsObjects = true;
- redundantRefs = true;
- if (parameters.contains("namesAsObjects"))
- namesAsObjects = parameters.value("namesAsObjects").toBool();
- if (parameters.contains("redundantRefs"))
- redundantRefs = parameters.value("redundantRefs").toBool();
+ Q_UNUSED(parameters); // For future protocol changes
emit messageToClient(name(), packMessage(type));
stopWaiting();
@@ -805,10 +815,10 @@ void QV4DebugServiceImpl::messageReceived(const QByteArray &message)
else
breakOnSignals.removeOne(signalName);
} else if (type == "v8request") {
- handleV8Request(payload);
+ handleV4Request(payload);
} else if (type == V4_DISCONNECT) {
TRACE_PROTOCOL(qDebug() << "... payload:" << payload.constData());
- handleV8Request(payload);
+ handleV4Request(payload);
} else {
sendSomethingToSomebody(type, 0);
}
@@ -823,7 +833,7 @@ void QV4DebugServiceImpl::sendSomethingToSomebody(const char *type, int magicNum
emit messageToClient(name(), packMessage(type, rs.data()));
}
-void QV4DebugServiceImpl::handleV8Request(const QByteArray &payload)
+void QV4DebugServiceImpl::handleV4Request(const QByteArray &payload)
{
TRACE_PROTOCOL(qDebug() << "v8request, payload:" << payload.constData());
@@ -832,7 +842,7 @@ void QV4DebugServiceImpl::handleV8Request(const QByteArray &payload)
QJsonValue type = o.value(QLatin1String("type"));
if (type.toString() == QLatin1String("request")) {
QJsonValue command = o.value(QLatin1String("command"));
- V8CommandHandler *h = v8CommandHandler(command.toString());
+ V4CommandHandler *h = v4CommandHandler(command.toString());
if (h)
h->handle(o, this);
}
@@ -846,11 +856,11 @@ QByteArray QV4DebugServiceImpl::packMessage(const QByteArray &command, const QBy
return rs.data();
}
-void QV4DebugServiceImpl::send(QJsonObject v8Payload)
+void QV4DebugServiceImpl::send(QJsonObject v4Payload)
{
- v8Payload[QLatin1String("seq")] = sequence++;
+ v4Payload[QLatin1String("seq")] = sequence++;
QJsonDocument doc;
- doc.setObject(v8Payload);
+ doc.setObject(v4Payload);
#ifdef NO_PROTOCOL_TRACING
QByteArray responseData = doc.toJson(QJsonDocument::Compact);
#else
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h
index 5401956994..d0b104dfad 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.h
@@ -64,15 +64,15 @@ QT_BEGIN_NAMESPACE
namespace QV4 { struct ExecutionEngine; }
class VariableCollector;
-class V8CommandHandler;
-class UnknownV8CommandHandler;
+class V4CommandHandler;
+class UnknownV4CommandHandler;
class QV4DebugServiceImpl;
class QV4DebugServiceImpl : public QQmlConfigurableDebugService<QV4DebugService>
{
Q_OBJECT
public:
- explicit QV4DebugServiceImpl(QObject *parent = 0);
+ explicit QV4DebugServiceImpl(QObject *parent = nullptr);
~QV4DebugServiceImpl() override;
void engineAdded(QJSEngine *engine) override;
@@ -81,14 +81,11 @@ public:
void stateAboutToBeChanged(State state) override;
void signalEmitted(const QString &signal) override;
- void send(QJsonObject v8Payload);
+ void send(QJsonObject v4Payload);
int selectedFrame() const;
void selectFrame(int frameNr);
- bool clientRequiresRedundantRefs() const { return redundantRefs; }
- bool clientRequiresNamesAsObjects() const { return namesAsObjects; }
-
QV4DebuggerAgent debuggerAgent;
protected:
@@ -98,22 +95,19 @@ protected:
private:
friend class QQmlDebuggerServiceFactory;
- void handleV8Request(const QByteArray &payload);
+ void handleV4Request(const QByteArray &payload);
static QByteArray packMessage(const QByteArray &command,
const QByteArray &message = QByteArray());
void processCommand(const QByteArray &command, const QByteArray &data);
- V8CommandHandler *v8CommandHandler(const QString &command) const;
+ V4CommandHandler *v4CommandHandler(const QString &command) const;
QStringList breakOnSignals;
static int sequence;
int theSelectedFrame;
- bool redundantRefs;
- bool namesAsObjects;
-
- void addHandler(V8CommandHandler* handler);
- QHash<QString, V8CommandHandler*> handlers;
- QScopedPointer<UnknownV8CommandHandler> unknownV8CommandHandler;
+ void addHandler(V4CommandHandler* handler);
+ QHash<QString, V4CommandHandler*> handlers;
+ QScopedPointer<UnknownV4CommandHandler> unknownV4CommandHandler;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
index b19115aa60..ceaa8a8de1 100644
--- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
@@ -51,6 +51,7 @@
#include <private/qv4runtime_p.h>
#include <private/qversionedpacket_p.h>
#include <private/qqmldebugserviceinterfaces_p.h>
+#include <private/qv4identifiertable_p.h>
#include <QtQml/qjsengine.h>
#include <QtCore/qjsonarray.h>
@@ -252,9 +253,9 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression)
m_runningJob = true;
QV4::ExecutionContext *ctx = m_engine->currentStackFrame ? m_engine->currentContext()
- : m_engine->rootContext();
+ : m_engine->scriptContext();
- QV4::Script script(ctx, QV4::Compiler::EvalCode, expression);
+ QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, expression);
if (const QV4::Function *function = m_engine->currentStackFrame
? m_engine->currentStackFrame->v4Function : m_engine->globalCode)
script.strictMode = function->isStrict();
@@ -276,7 +277,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression)
}
NativeDebugger::NativeDebugger(QQmlNativeDebugServiceImpl *service, QV4::ExecutionEngine *engine)
- : m_returnedValue(engine, QV4::Primitive::undefinedValue())
+ : m_returnedValue(engine, QV4::Value::undefinedValue())
{
m_stepping = NotStepping;
m_pauseRequested = false;
@@ -414,7 +415,7 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri
if (isExpanded(iname)) {
QJsonArray children;
for (uint i = 0; i < n; ++i) {
- QV4::ReturnedValue v = array->getIndexed(i);
+ QV4::ReturnedValue v = array->get(i);
QV4::ScopedValue sval(scope, v);
collect(&children, iname, QString::number(i), *sval);
}
@@ -426,20 +427,17 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri
qint64 numProperties = 0;
QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::EnumerableOnly);
QV4::ScopedProperty p(scope);
- QV4::ScopedString name(scope);
+ QV4::ScopedPropertyKey name(scope);
while (true) {
QV4::PropertyAttributes attrs;
- uint index;
- it.next(name.getRef(), &index, p, &attrs);
- if (attrs.isEmpty())
+ name = it.next(p, &attrs);
+ if (!name->isValid())
break;
- if (name.getPointer()) {
+ if (name->isStringOrSymbol()) {
++numProperties;
if (expanded) {
- if (name.getPointer()) {
- QV4::Value v = p.property->value;
- collect(&children, iname, name->toQStringNoThrow(), v);
- }
+ QV4::Value v = p.property->value;
+ collect(&children, iname, name->toQString(), v);
}
}
}
@@ -493,10 +491,10 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a
collector.collect(&output, QString(), QStringLiteral("this"), thisObject);
QV4::Scoped<QV4::CallContext> callContext(scope, frame->callContext());
if (callContext) {
- QV4::InternalClass *ic = callContext->internalClass();
+ QV4::Heap::InternalClass *ic = callContext->internalClass();
QV4::ScopedValue v(scope);
for (uint i = 0; i < ic->size; ++i) {
- QString name = ic->nameMap[i]->string;
+ QString name = ic->keyAt(i);
v = callContext->d()->locals[i];
collector.collect(&output, QString(), name, v);
}
diff --git a/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro
new file mode 100644
index 0000000000..08686a43e3
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro
@@ -0,0 +1,29 @@
+QT += core-private qml-private packetprotocol-private network quick-private gui-private
+
+TARGET = qmldbg_preview
+
+SOURCES += \
+ $$PWD/qqmlpreviewblacklist.cpp \
+ $$PWD/qqmlpreviewfileengine.cpp \
+ $$PWD/qqmlpreviewfileloader.cpp \
+ $$PWD/qqmlpreviewhandler.cpp \
+ $$PWD/qqmlpreviewposition.cpp \
+ $$PWD/qqmlpreviewservice.cpp \
+ $$PWD/qqmlpreviewservicefactory.cpp
+
+HEADERS += \
+ $$PWD/qqmlpreviewblacklist.h \
+ $$PWD/qqmlpreviewfileengine.h \
+ $$PWD/qqmlpreviewfileloader.h \
+ $$PWD/qqmlpreviewhandler.h \
+ $$PWD/qqmlpreviewposition.h \
+ $$PWD/qqmlpreviewservice.h \
+ $$PWD/qqmlpreviewservicefactory.h
+
+OTHER_FILES += \
+ $$PWD/qqmlpreviewservice.json
+
+PLUGIN_TYPE = qmltooling
+PLUGIN_CLASS_NAME = QQmlPreviewServiceFactory
+
+load(qt_plugin)
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.cpp
new file mode 100644
index 0000000000..77fe69821c
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewblacklist.h"
+
+QT_BEGIN_NAMESPACE
+
+void QQmlPreviewBlacklist::blacklist(const QString &path)
+{
+ if (!path.isEmpty())
+ m_root.insert(path, 0);
+}
+
+void QQmlPreviewBlacklist::whitelist(const QString &path)
+{
+ if (!path.isEmpty())
+ m_root.remove(path, 0);
+}
+
+bool QQmlPreviewBlacklist::isBlacklisted(const QString &path) const
+{
+ return path.isEmpty() ? true : m_root.containedPrefixLeaf(path, 0) > 0;
+}
+
+void QQmlPreviewBlacklist::clear()
+{
+ m_root = Node();
+}
+
+QQmlPreviewBlacklist::Node::Node()
+{
+}
+
+QQmlPreviewBlacklist::Node::Node(const QQmlPreviewBlacklist::Node &other) :
+ m_mine(other.m_mine), m_isLeaf(other.m_isLeaf)
+{
+ for (auto it = other.m_next.begin(), end = other.m_next.end(); it != end; ++it)
+ m_next.insert(it.key(), new Node(**it));
+}
+
+QQmlPreviewBlacklist::Node::Node(QQmlPreviewBlacklist::Node &&other) Q_DECL_NOEXCEPT
+{
+ m_mine.swap(other.m_mine);
+ m_next.swap(other.m_next);
+ m_isLeaf = other.m_isLeaf;
+}
+
+QQmlPreviewBlacklist::Node::~Node()
+{
+ qDeleteAll(m_next);
+}
+
+QQmlPreviewBlacklist::Node &QQmlPreviewBlacklist::Node::operator=(
+ const QQmlPreviewBlacklist::Node &other)
+{
+ if (&other != this) {
+ m_mine = other.m_mine;
+ for (auto it = other.m_next.begin(), end = other.m_next.end(); it != end; ++it)
+ m_next.insert(it.key(), new Node(**it));
+ m_isLeaf = other.m_isLeaf;
+ }
+ return *this;
+}
+
+QQmlPreviewBlacklist::Node &QQmlPreviewBlacklist::Node::operator=(
+ QQmlPreviewBlacklist::Node &&other) Q_DECL_NOEXCEPT
+{
+ if (&other != this) {
+ m_mine.swap(other.m_mine);
+ m_next.swap(other.m_next);
+ m_isLeaf = other.m_isLeaf;
+ }
+ return *this;
+}
+
+void QQmlPreviewBlacklist::Node::split(QString::iterator it, QString::iterator end)
+{
+ QString existing;
+ existing.resize(end - it - 1);
+ std::copy(it + 1, end, existing.begin());
+
+ Node *node = new Node(existing, m_next, m_isLeaf);
+ m_next.clear();
+ m_next.insert(*it, node);
+ m_mine.resize(it - m_mine.begin());
+ m_isLeaf = false;
+}
+
+void QQmlPreviewBlacklist::Node::insert(const QString &path, int offset)
+{
+ for (auto it = m_mine.begin(), end = m_mine.end(); it != end; ++it) {
+ if (offset == path.size()) {
+ split(it, end);
+ m_isLeaf = true;
+ return;
+ }
+
+ if (path.at(offset) != *it) {
+ split(it, end);
+
+ QString inserted;
+ inserted.resize(path.size() - offset - 1);
+ std::copy(path.begin() + offset + 1, path.end(), inserted.begin());
+ m_next.insert(path.at(offset), new Node(inserted));
+ return;
+ }
+
+ ++offset;
+ }
+
+ if (offset == path.size()) {
+ m_isLeaf = true;
+ return;
+ }
+
+ Node *&node = m_next[path.at(offset++)];
+ if (node == nullptr) {
+ QString inserted;
+ inserted.resize(path.size() - offset);
+ std::copy(path.begin() + offset, path.end(), inserted.begin());
+ node = new Node(inserted);
+ } else {
+ node->insert(path, offset);
+ }
+}
+
+void QQmlPreviewBlacklist::Node::remove(const QString &path, int offset)
+{
+ for (auto it = m_mine.begin(), end = m_mine.end(); it != end; ++it) {
+ if (offset == path.size() || path.at(offset) != *it) {
+ split(it, end);
+ return;
+ }
+ ++offset;
+ }
+
+ m_isLeaf = false;
+ if (offset == path.size())
+ return;
+
+ auto it = m_next.find(path.at(offset));
+ if (it != m_next.end())
+ (*it)->remove(path, ++offset);
+}
+
+int QQmlPreviewBlacklist::Node::containedPrefixLeaf(const QString &path, int offset) const
+{
+ if (offset == path.size())
+ return (m_mine.isEmpty() && m_isLeaf) ? offset : -1;
+
+ for (auto it = m_mine.begin(), end = m_mine.end(); it != end; ++it) {
+ if (path.at(offset) != *it)
+ return -1;
+
+ if (++offset == path.size())
+ return (++it == end && m_isLeaf) ? offset : -1;
+ }
+
+ const QChar c = path.at(offset);
+ if (m_isLeaf && c == '/')
+ return offset;
+
+ auto it = m_next.find(c);
+ if (it == m_next.end())
+ return -1;
+
+ return (*it)->containedPrefixLeaf(path, ++offset);
+}
+
+QQmlPreviewBlacklist::Node::Node(const QString &mine,
+ const QHash<QChar, QQmlPreviewBlacklist::Node *> &next,
+ bool isLeaf)
+ : m_mine(mine), m_next(next), m_isLeaf(isLeaf)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h
new file mode 100644
index 0000000000..2f743ca7a6
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPREVIEWBLACKLIST_H
+#define QQMLPREVIEWBLACKLIST_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qhash.h>
+#include <QtCore/qchar.h>
+#include <QtCore/qstring.h>
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlPreviewBlacklist
+{
+public:
+ void blacklist(const QString &path);
+ void whitelist(const QString &path);
+ bool isBlacklisted(const QString &path) const;
+ void clear();
+
+private:
+ class Node {
+ public:
+ Node();
+ Node(const Node &other);
+ Node(Node &&other) Q_DECL_NOEXCEPT;
+
+ ~Node();
+
+ Node &operator=(const Node &other);
+ Node &operator=(Node &&other) Q_DECL_NOEXCEPT;
+
+ void split(QString::iterator it, QString::iterator end);
+ void insert(const QString &path, int offset);
+ void remove(const QString &path, int offset);
+ int containedPrefixLeaf(const QString &path, int offset) const;
+
+ private:
+ Node(const QString &mine, const QHash<QChar, Node *> &next = QHash<QChar, Node *>(),
+ bool isLeaf = true);
+
+ QString m_mine;
+ QHash<QChar, Node *> m_next;
+ bool m_isLeaf = false;
+ };
+
+ Node m_root;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPREVIEWBLACKLIST_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
new file mode 100644
index 0000000000..72de52bbe1
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
@@ -0,0 +1,443 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewfileengine.h"
+#include "qqmlpreviewservice.h"
+
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qwaitcondition.h>
+
+#include <cstring>
+
+QT_BEGIN_NAMESPACE
+
+static bool isRelative(const QString &path)
+{
+ if (path.isEmpty())
+ return true;
+ if (path.at(0) == '/')
+ return false;
+ if (path.at(0) == ':' && path.length() >= 2 && path.at(1) == '/')
+ return false;
+#ifdef Q_OS_WIN
+ if (path.length() >= 2 && path.at(1) == ':')
+ return false;
+#endif
+ return true;
+}
+
+static QString absolutePath(const QString &path)
+{
+ return QDir::cleanPath(isRelative(path) ? (QDir::currentPath() + '/' + path) : path);
+}
+
+bool isRootPath(const QString &path)
+{
+ return QFileSystemEntry::isRootPath(path);
+}
+
+class QQmlPreviewFileEngineIterator : public QAbstractFileEngineIterator
+{
+public:
+ QQmlPreviewFileEngineIterator(QDir::Filters filters, const QStringList &filterNames,
+ const QStringList &m_entries);
+ ~QQmlPreviewFileEngineIterator();
+
+ QString next() override;
+ bool hasNext() const override;
+ QString currentFileName() const override;
+
+private:
+ const QStringList m_entries;
+ int m_index;
+};
+
+QQmlPreviewFileEngineIterator::QQmlPreviewFileEngineIterator(QDir::Filters filters,
+ const QStringList &filterNames,
+ const QStringList &entries)
+ : QAbstractFileEngineIterator(filters, filterNames), m_entries(entries), m_index(0)
+{
+}
+
+QQmlPreviewFileEngineIterator::~QQmlPreviewFileEngineIterator()
+{
+}
+
+QString QQmlPreviewFileEngineIterator::next()
+{
+ if (!hasNext())
+ return QString();
+ ++m_index;
+ return currentFilePath();
+}
+
+bool QQmlPreviewFileEngineIterator::hasNext() const
+{
+ return m_index < m_entries.size();
+}
+
+QString QQmlPreviewFileEngineIterator::currentFileName() const
+{
+ if (m_index == 0 || m_index > m_entries.size())
+ return QString();
+ return m_entries.at(m_index - 1);
+}
+
+QQmlPreviewFileEngine::QQmlPreviewFileEngine(const QString &file, const QString &absolute,
+ QQmlPreviewFileLoader *loader) :
+ m_name(file), m_absolute(absolute), m_loader(loader)
+{
+ load();
+}
+
+void QQmlPreviewFileEngine::setFileName(const QString &file)
+{
+ m_name = file;
+ m_absolute = absolutePath(file);
+ m_fallback.reset();
+ m_contents.close();
+ m_contents.setData(QByteArray());
+ m_entries.clear();
+ load();
+}
+
+bool QQmlPreviewFileEngine::open(QIODevice::OpenMode flags)
+{
+ switch (m_result) {
+ case QQmlPreviewFileLoader::File:
+ return m_contents.open(flags);
+ case QQmlPreviewFileLoader::Directory:
+ return false;
+ case QQmlPreviewFileLoader::Fallback:
+ return m_fallback->open(flags);
+ default:
+ Q_UNREACHABLE();
+ return false;
+ }
+}
+
+bool QQmlPreviewFileEngine::close()
+{
+ switch (m_result) {
+ case QQmlPreviewFileLoader::Fallback:
+ return m_fallback->close();
+ case QQmlPreviewFileLoader::File:
+ m_contents.close();
+ return true;
+ case QQmlPreviewFileLoader::Directory:
+ return false;
+ default:
+ Q_UNREACHABLE();
+ return false;
+ }
+}
+
+qint64 QQmlPreviewFileEngine::size() const
+{
+ return m_fallback ? m_fallback->size() : m_contents.size();
+}
+
+qint64 QQmlPreviewFileEngine::pos() const
+{
+ return m_fallback ? m_fallback->pos() : m_contents.pos();
+}
+
+bool QQmlPreviewFileEngine::seek(qint64 newPos)
+{
+ return m_fallback? m_fallback->seek(newPos) : m_contents.seek(newPos);
+}
+
+qint64 QQmlPreviewFileEngine::read(char *data, qint64 maxlen)
+{
+ return m_fallback ? m_fallback->read(data, maxlen) : m_contents.read(data, maxlen);
+}
+
+QAbstractFileEngine::FileFlags QQmlPreviewFileEngine::fileFlags(
+ QAbstractFileEngine::FileFlags type) const
+{
+ if (m_fallback)
+ return m_fallback->fileFlags(type);
+
+ QAbstractFileEngine::FileFlags ret = 0;
+
+ if (type & PermsMask) {
+ ret |= QAbstractFileEngine::FileFlags(
+ ReadOwnerPerm | ReadUserPerm | ReadGroupPerm | ReadOtherPerm);
+ }
+
+ if (type & TypesMask) {
+ if (m_result == QQmlPreviewFileLoader::Directory)
+ ret |= DirectoryType;
+ else
+ ret |= FileType;
+ }
+
+ if (type & FlagsMask) {
+ ret |= ExistsFlag;
+ if (isRootPath(m_name))
+ ret |= RootFlag;
+ }
+
+ return ret;
+}
+
+QString QQmlPreviewFileEngine::fileName(QAbstractFileEngine::FileName file) const
+{
+ if (m_fallback)
+ return m_fallback->fileName(file);
+
+ if (file == BaseName) {
+ int slashPos = m_name.lastIndexOf('/');
+ if (slashPos == -1)
+ return m_name;
+ return m_name.mid(slashPos + 1);
+ } else if (file == PathName || file == AbsolutePathName) {
+ const QString path = (file == AbsolutePathName) ? m_absolute : m_name;
+ const int slashPos = path.lastIndexOf('/');
+ if (slashPos == -1)
+ return QString();
+ else if (slashPos == 0)
+ return "/";
+ return path.left(slashPos);
+ } else if (file == CanonicalName || file == CanonicalPathName) {
+ if (file == CanonicalPathName) {
+ const int slashPos = m_absolute.lastIndexOf('/');
+ if (slashPos != -1)
+ return m_absolute.left(slashPos);
+ }
+ return m_absolute;
+ }
+ return m_name;
+}
+
+uint QQmlPreviewFileEngine::ownerId(QAbstractFileEngine::FileOwner owner) const
+{
+ return m_fallback ? m_fallback->ownerId(owner) : static_cast<uint>(-2);
+}
+
+QAbstractFileEngine::Iterator *QQmlPreviewFileEngine::beginEntryList(QDir::Filters filters,
+ const QStringList &filterNames)
+{
+ return m_fallback ? m_fallback->beginEntryList(filters, filterNames)
+ : new QQmlPreviewFileEngineIterator(filters, filterNames, m_entries);
+}
+
+QAbstractFileEngine::Iterator *QQmlPreviewFileEngine::endEntryList()
+{
+ return m_fallback ? m_fallback->endEntryList() : nullptr;
+}
+
+bool QQmlPreviewFileEngine::flush()
+{
+ return m_fallback ? m_fallback->flush() : true;
+}
+
+bool QQmlPreviewFileEngine::syncToDisk()
+{
+ return m_fallback ? m_fallback->syncToDisk() : false;
+}
+
+bool QQmlPreviewFileEngine::isSequential() const
+{
+ return m_fallback ? m_fallback->isSequential() : m_contents.isSequential();
+}
+
+bool QQmlPreviewFileEngine::remove()
+{
+ return m_fallback ? m_fallback->remove() : false;
+}
+
+bool QQmlPreviewFileEngine::copy(const QString &newName)
+{
+ return m_fallback ? m_fallback->copy(newName) : false;
+}
+
+bool QQmlPreviewFileEngine::rename(const QString &newName)
+{
+ return m_fallback ? m_fallback->rename(newName) : false;
+}
+
+bool QQmlPreviewFileEngine::renameOverwrite(const QString &newName)
+{
+ return m_fallback ? m_fallback->renameOverwrite(newName) : false;
+}
+
+bool QQmlPreviewFileEngine::link(const QString &newName)
+{
+ return m_fallback ? m_fallback->link(newName) : false;
+}
+
+bool QQmlPreviewFileEngine::mkdir(const QString &dirName, bool createParentDirectories) const
+{
+ return m_fallback ? m_fallback->mkdir(dirName, createParentDirectories) : false;
+}
+
+bool QQmlPreviewFileEngine::rmdir(const QString &dirName, bool recurseParentDirectories) const
+{
+ return m_fallback ? m_fallback->rmdir(dirName, recurseParentDirectories) : false;
+}
+
+bool QQmlPreviewFileEngine::setSize(qint64 size)
+{
+ switch (m_result) {
+ case QQmlPreviewFileLoader::Fallback:
+ return m_fallback->setSize(size);
+ case QQmlPreviewFileLoader::File:
+ if (size < 0 || size > std::numeric_limits<int>::max())
+ return false;
+ m_contents.buffer().resize(static_cast<int>(size));
+ return true;
+ case QQmlPreviewFileLoader::Directory:
+ return false;
+ default:
+ Q_UNREACHABLE();
+ return false;
+ }
+}
+
+bool QQmlPreviewFileEngine::caseSensitive() const
+{
+ return m_fallback ? m_fallback->caseSensitive() : true;
+}
+
+bool QQmlPreviewFileEngine::isRelativePath() const
+{
+ return m_fallback ? m_fallback->isRelativePath() : isRelative(m_name);
+}
+
+QStringList QQmlPreviewFileEngine::entryList(QDir::Filters filters,
+ const QStringList &filterNames) const
+{
+ return m_fallback ? m_fallback->entryList(filters, filterNames)
+ : QAbstractFileEngine::entryList(filters, filterNames);
+}
+
+bool QQmlPreviewFileEngine::setPermissions(uint perms)
+{
+ return m_fallback ? m_fallback->setPermissions(perms) : false;
+}
+
+QByteArray QQmlPreviewFileEngine::id() const
+{
+ return m_fallback ? m_fallback->id() : QByteArray();
+}
+
+QString QQmlPreviewFileEngine::owner(FileOwner owner) const
+{
+ return m_fallback ? m_fallback->owner(owner) : QString();
+}
+
+QDateTime QQmlPreviewFileEngine::fileTime(FileTime time) const
+{
+ // Files we replace are always newer than the ones we had before. This makes the QML engine
+ // actually recompile them, rather than pick them from the cache.
+ return m_fallback ? m_fallback->fileTime(time) : QDateTime::currentDateTime();
+}
+
+int QQmlPreviewFileEngine::handle() const
+{
+ return m_fallback ? m_fallback->handle() : -1;
+}
+
+qint64 QQmlPreviewFileEngine::readLine(char *data, qint64 maxlen)
+{
+ return m_fallback ? m_fallback->readLine(data, maxlen) : m_contents.readLine(data, maxlen);
+}
+
+qint64 QQmlPreviewFileEngine::write(const char *data, qint64 len)
+{
+ return m_fallback ? m_fallback->write(data, len) : m_contents.write(data, len);
+}
+
+bool QQmlPreviewFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)
+{
+ return m_fallback ? m_fallback->extension(extension, option, output) : false;
+}
+
+bool QQmlPreviewFileEngine::supportsExtension(Extension extension) const
+{
+ return m_fallback ? m_fallback->supportsExtension(extension) : false;
+}
+
+void QQmlPreviewFileEngine::load() const
+{
+ m_result = m_loader->load(m_absolute);
+ switch (m_result) {
+ case QQmlPreviewFileLoader::File:
+ m_contents.setData(m_loader->contents());
+ break;
+ case QQmlPreviewFileLoader::Directory:
+ m_entries = m_loader->entries();
+ break;
+ case QQmlPreviewFileLoader::Fallback:
+ m_fallback.reset(QAbstractFileEngine::create(m_name));
+ break;
+ case QQmlPreviewFileLoader::Unknown:
+ Q_UNREACHABLE();
+ break;
+ }
+}
+
+QQmlPreviewFileEngineHandler::QQmlPreviewFileEngineHandler(QQmlPreviewFileLoader *loader)
+ : m_loader(loader)
+{
+}
+
+QAbstractFileEngine *QQmlPreviewFileEngineHandler::create(const QString &fileName) const
+{
+ // Don't load compiled QML/JS over the network
+ if (fileName.endsWith(".qmlc") || fileName.endsWith(".jsc") || isRootPath(fileName)) {
+ return nullptr;
+ }
+
+ QString relative = fileName;
+ while (relative.endsWith('/'))
+ relative.chop(1);
+
+ if (relative.isEmpty() || relative == ":")
+ return nullptr;
+
+ const QString absolute = relative.startsWith(':') ? relative : absolutePath(relative);
+
+ return m_loader->isBlacklisted(absolute)
+ ? nullptr : new QQmlPreviewFileEngine(relative, absolute, m_loader.data());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.h
new file mode 100644
index 0000000000..9a40b6360c
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPREVIEWFILEENGINE_H
+#define QQMLPREVIEWFILEENGINE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qqmlpreviewfileloader.h"
+
+#include <private/qabstractfileengine_p.h>
+#include <private/qfsfileengine_p.h>
+#include <QtCore/qbuffer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlPreviewFileEngine : public QAbstractFileEngine
+{
+public:
+ QQmlPreviewFileEngine(const QString &file, const QString &absolute,
+ QQmlPreviewFileLoader *loader);
+
+ void setFileName(const QString &file) override;
+
+ bool open(QIODevice::OpenMode flags) override ;
+ bool close() override;
+ qint64 size() const override;
+ qint64 pos() const override;
+ bool seek(qint64) override;
+ qint64 read(char *data, qint64 maxlen) override;
+
+ FileFlags fileFlags(FileFlags type) const override;
+ QString fileName(QAbstractFileEngine::FileName file) const override;
+ uint ownerId(FileOwner) const override;
+
+ Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override;
+ Iterator *endEntryList() override;
+
+ // Forwarding to fallback if exists
+ bool flush() override;
+ bool syncToDisk() override;
+ bool isSequential() const override;
+ bool remove() override;
+ bool copy(const QString &newName) override;
+ bool rename(const QString &newName) override;
+ bool renameOverwrite(const QString &newName) override;
+ bool link(const QString &newName) override;
+ bool mkdir(const QString &dirName, bool createParentDirectories) const override;
+ bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
+ bool setSize(qint64 size) override;
+ bool caseSensitive() const override;
+ bool isRelativePath() const override;
+ QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
+ bool setPermissions(uint perms) override;
+ QByteArray id() const override;
+ QString owner(FileOwner) const override;
+ QDateTime fileTime(FileTime time) const override;
+ int handle() const override;
+ qint64 readLine(char *data, qint64 maxlen) override;
+ qint64 write(const char *data, qint64 len) override;
+ bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) override;
+ bool supportsExtension(Extension extension) const override;
+
+private:
+ void load() const;
+
+ QString m_name;
+ QString m_absolute;
+ QPointer<QQmlPreviewFileLoader> m_loader;
+
+ mutable QBuffer m_contents;
+ mutable QStringList m_entries;
+ mutable QScopedPointer<QAbstractFileEngine> m_fallback;
+ mutable QQmlPreviewFileLoader::Result m_result = QQmlPreviewFileLoader::Unknown;
+};
+
+class QQmlPreviewFileEngineHandler : public QAbstractFileEngineHandler
+{
+public:
+ QQmlPreviewFileEngineHandler(QQmlPreviewFileLoader *loader);
+ QAbstractFileEngine *create(const QString &fileName) const override;
+
+private:
+ QPointer<QQmlPreviewFileLoader> m_loader;
+};
+
+
+
+QT_END_NAMESPACE
+
+#endif // QQMLPREVIEWFILEENGINE_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.cpp
new file mode 100644
index 0000000000..560b1a84b2
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.cpp
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewfileloader.h"
+#include "qqmlpreviewservice.h"
+
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qstandardpaths.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlPreviewFileLoader::QQmlPreviewFileLoader(QQmlPreviewServiceImpl *service) : m_service(service)
+{
+ // Exclude some resource paths used by Qt itself. There is no point in loading those from the
+ // client as the client will not have the files (or even worse, it may have different ones).
+ m_blacklist.blacklist(":/qt-project.org");
+ m_blacklist.blacklist(":/QtQuick/Controls/Styles");
+ m_blacklist.blacklist(":/ExtrasImports/QtQuick/Controls/Styles");
+ m_blacklist.blacklist(":/qgradient");
+
+ // Target specific configuration should not replaced with files from the host.
+ m_blacklist.blacklist("/etc");
+
+ for (int loc = QLibraryInfo::PrefixPath; loc <= QLibraryInfo::TestsPath; ++loc) {
+ m_blacklist.blacklist(QLibraryInfo::location(
+ static_cast<QLibraryInfo::LibraryLocation>(loc)));
+ }
+ m_blacklist.blacklist(QLibraryInfo::location(QLibraryInfo::SettingsPath));
+
+ static const QStandardPaths::StandardLocation blackListLocations[] = {
+ QStandardPaths::DataLocation,
+ QStandardPaths::CacheLocation,
+ QStandardPaths::GenericDataLocation,
+ QStandardPaths::ConfigLocation,
+ QStandardPaths::GenericCacheLocation,
+ QStandardPaths::GenericConfigLocation,
+ QStandardPaths::AppDataLocation,
+ QStandardPaths::AppConfigLocation
+ };
+
+ for (auto locationType : blackListLocations) {
+ const QStringList locations = QStandardPaths::standardLocations(locationType);
+ for (const QString &location : locations)
+ m_blacklist.blacklist(location);
+ }
+
+ connect(this, &QQmlPreviewFileLoader::request, service, &QQmlPreviewServiceImpl::forwardRequest,
+ Qt::DirectConnection);
+ connect(service, &QQmlPreviewServiceImpl::directory, this, &QQmlPreviewFileLoader::directory);
+ connect(service, &QQmlPreviewServiceImpl::file, this, &QQmlPreviewFileLoader::file);
+ connect(service, &QQmlPreviewServiceImpl::error, this, &QQmlPreviewFileLoader::error);
+ connect(service, &QQmlPreviewServiceImpl::clearCache, this, &QQmlPreviewFileLoader::clearCache);
+ moveToThread(&m_thread);
+ m_thread.start();
+}
+
+QQmlPreviewFileLoader::~QQmlPreviewFileLoader() {
+ m_thread.quit();
+ m_thread.wait();
+}
+
+QQmlPreviewFileLoader::Result QQmlPreviewFileLoader::load(const QString &path)
+{
+ QMutexLocker locker(&m_mutex);
+ m_path = path;
+
+ auto fileIterator = m_fileCache.constFind(path);
+ if (fileIterator != m_fileCache.constEnd()) {
+ m_result = File;
+ m_contents = *fileIterator;
+ m_entries.clear();
+ return m_result;
+ }
+
+ auto dirIterator = m_directoryCache.constFind(path);
+ if (dirIterator != m_directoryCache.constEnd()) {
+ m_result = Directory;
+ m_contents.clear();
+ m_entries = *dirIterator;
+ return m_result;
+ }
+
+ m_result = Unknown;
+ m_entries.clear();
+ m_contents.clear();
+ emit request(path);
+ m_waitCondition.wait(&m_mutex);
+ return m_result;
+}
+
+QByteArray QQmlPreviewFileLoader::contents()
+{
+ QMutexLocker locker(&m_mutex);
+ return m_contents;
+}
+
+QStringList QQmlPreviewFileLoader::entries()
+{
+ QMutexLocker locker(&m_mutex);
+ return m_entries;
+}
+
+void QQmlPreviewFileLoader::whitelist(const QUrl &url)
+{
+ const QString path = QQmlFile::urlToLocalFileOrQrc(url);
+ if (!path.isEmpty()) {
+ QMutexLocker locker(&m_mutex);
+ m_blacklist.whitelist(path);
+ }
+}
+
+bool QQmlPreviewFileLoader::isBlacklisted(const QString &path)
+{
+ QMutexLocker locker(&m_mutex);
+ return m_blacklist.isBlacklisted(path);
+}
+
+void QQmlPreviewFileLoader::file(const QString &path, const QByteArray &contents)
+{
+ QMutexLocker locker(&m_mutex);
+ m_blacklist.whitelist(path);
+ m_fileCache[path] = contents;
+ if (path == m_path) {
+ m_contents = contents;
+ m_result = File;
+ m_waitCondition.wakeOne();
+ }
+}
+
+void QQmlPreviewFileLoader::directory(const QString &path, const QStringList &entries)
+{
+ QMutexLocker locker(&m_mutex);
+ m_blacklist.whitelist(path);
+ m_directoryCache[path] = entries;
+ if (path == m_path) {
+ m_entries = entries;
+ m_result = Directory;
+ m_waitCondition.wakeOne();
+ }
+}
+
+void QQmlPreviewFileLoader::error(const QString &path)
+{
+ QMutexLocker locker(&m_mutex);
+ m_blacklist.blacklist(path);
+ if (path == m_path) {
+ m_result = Fallback;
+ m_waitCondition.wakeOne();
+ }
+}
+
+void QQmlPreviewFileLoader::clearCache()
+{
+ QMutexLocker locker(&m_mutex);
+ m_fileCache.clear();
+ m_directoryCache.clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h
new file mode 100644
index 0000000000..0c55c48c4a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileloader.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPREVIEWFILELOADER_H
+#define QQMLPREVIEWFILELOADER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qqmlpreviewblacklist.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qset.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlPreviewServiceImpl;
+class QQmlPreviewFileLoader : public QObject
+{
+ Q_OBJECT
+public:
+ enum Result {
+ File,
+ Directory,
+ Fallback,
+ Unknown
+ };
+
+ QQmlPreviewFileLoader(QQmlPreviewServiceImpl *service);
+ ~QQmlPreviewFileLoader();
+
+ Result load(const QString &file);
+ QByteArray contents();
+ QStringList entries();
+
+ void whitelist(const QUrl &url);
+ bool isBlacklisted(const QString &file);
+
+signals:
+ void request(const QString &file);
+
+private:
+ QMutex m_mutex;
+ QWaitCondition m_waitCondition;
+
+ QThread m_thread;
+ QPointer<QQmlPreviewServiceImpl> m_service;
+
+ QString m_path;
+ QByteArray m_contents;
+ QStringList m_entries;
+ Result m_result;
+
+ QQmlPreviewBlacklist m_blacklist;
+ QHash<QString, QByteArray> m_fileCache;
+ QHash<QString, QStringList> m_directoryCache;
+
+ void file(const QString &file, const QByteArray &contents);
+ void directory(const QString &file, const QStringList &entries);
+ void error(const QString &file);
+ void clearCache();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPREVIEWFILELOADER_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp
new file mode 100644
index 0000000000..5bd96af582
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.cpp
@@ -0,0 +1,472 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewhandler.h"
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qsettings.h>
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qtranslator.h>
+
+#include <QtGui/qwindow.h>
+#include <QtGui/qguiapplication.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQml/qqmlcomponent.h>
+
+#include <private/qquickpixmapcache_p.h>
+#include <private/qquickview_p.h>
+#include <private/qhighdpiscaling_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QuitLockDisabler
+{
+ const bool quitLockEnabled;
+
+ QuitLockDisabler() : quitLockEnabled(QCoreApplication::isQuitLockEnabled())
+ {
+ QCoreApplication::setQuitLockEnabled(false);
+ }
+
+ ~QuitLockDisabler()
+ {
+ QCoreApplication::setQuitLockEnabled(quitLockEnabled);
+ }
+};
+
+QQmlPreviewHandler::QQmlPreviewHandler(QObject *parent) : QObject(parent)
+{
+ m_dummyItem.reset(new QQuickItem);
+
+ // TODO: Is there a better way to determine this? We want to keep the window alive when possible
+ // as otherwise it will reappear in a different place when (re)loading a file. However,
+ // the file we load might create another window, in which case the eglfs plugin (and
+ // others?) will do a qFatal as it only supports a single window.
+ const QString platformName = QGuiApplication::platformName();
+ m_supportsMultipleWindows = (platformName == QStringLiteral("windows")
+ || platformName == QStringLiteral("cocoa")
+ || platformName == QStringLiteral("xcb")
+ || platformName == QStringLiteral("wayland"));
+
+ QCoreApplication::instance()->installEventFilter(this);
+
+ m_fpsTimer.setInterval(1000);
+ connect(&m_fpsTimer, &QTimer::timeout, this, &QQmlPreviewHandler::fpsTimerHit);
+}
+
+QQmlPreviewHandler::~QQmlPreviewHandler()
+{
+ removeTranslators();
+ clear();
+}
+
+static void closeAllWindows()
+{
+ const QWindowList windows = QGuiApplication::allWindows();
+ for (QWindow *window : windows)
+ window->close();
+}
+
+bool QQmlPreviewHandler::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::Show) {
+ if (QWindow *window = qobject_cast<QQuickWindow*>(obj)) {
+ m_lastPosition.initLastSavedWindowPosition(window);
+ }
+ }
+ if (m_currentWindow && (event->type() == QEvent::Move || event->type() == QEvent::Resize) &&
+ qobject_cast<QQuickWindow*>(obj) == m_currentWindow) {
+ // we always start with factor 1 so calculate and save the origin as it would be not scaled
+ m_lastPosition.setPosition(m_currentWindow->framePosition() *
+ QHighDpiScaling::factor(m_currentWindow));
+ }
+
+ return QObject::eventFilter(obj, event);
+}
+
+void QQmlPreviewHandler::addEngine(QQmlEngine *qmlEngine)
+{
+ m_engines.append(qmlEngine);
+}
+
+void QQmlPreviewHandler::removeEngine(QQmlEngine *qmlEngine)
+{
+ const bool found = m_engines.removeOne(qmlEngine);
+ Q_ASSERT(found);
+ for (QObject *obj : m_createdObjects)
+ if (obj && QtQml::qmlEngine(obj) == qmlEngine)
+ delete obj;
+ m_createdObjects.removeAll(nullptr);
+}
+
+void QQmlPreviewHandler::loadUrl(const QUrl &url)
+{
+ QSharedPointer<QuitLockDisabler> disabler(new QuitLockDisabler);
+
+ clear();
+ m_component.reset(nullptr);
+ QQuickPixmap::purgeCache();
+
+ const int numEngines = m_engines.count();
+ if (numEngines > 1) {
+ emit error(QString::fromLatin1("%1 QML engines available. We cannot decide which one "
+ "should load the component.").arg(numEngines));
+ return;
+ } else if (numEngines == 0) {
+ emit error(QLatin1String("No QML engines found."));
+ return;
+ }
+ m_lastPosition.loadWindowPositionSettings(url);
+
+ QQmlEngine *engine = m_engines.front();
+ engine->clearComponentCache();
+ m_component.reset(new QQmlComponent(engine, url, this));
+
+ auto onStatusChanged = [disabler, this](QQmlComponent::Status status) {
+ switch (status) {
+ case QQmlComponent::Null:
+ case QQmlComponent::Loading:
+ return true; // try again later
+ case QQmlComponent::Ready:
+ tryCreateObject();
+ break;
+ case QQmlComponent::Error:
+ emit error(m_component->errorString());
+ break;
+ default:
+ Q_UNREACHABLE();
+ break;
+ }
+
+ disconnect(m_component.data(), &QQmlComponent::statusChanged, this, nullptr);
+ return false; // we're done
+ };
+
+ if (onStatusChanged(m_component->status()))
+ connect(m_component.data(), &QQmlComponent::statusChanged, this, onStatusChanged);
+}
+
+void QQmlPreviewHandler::rerun()
+{
+ if (m_component.isNull() || !m_component->isReady())
+ emit error(QLatin1String("Component is not ready."));
+
+ QuitLockDisabler disabler;
+ Q_UNUSED(disabler);
+ clear();
+ tryCreateObject();
+}
+
+void QQmlPreviewHandler::zoom(qreal newFactor)
+{
+ if (!m_currentWindow)
+ return;
+ if (qFuzzyIsNull(newFactor)) {
+ emit error(QString::fromLatin1("Zooming with factor: %1 will result in nothing " \
+ "so it will be ignored.").arg(newFactor));
+ return;
+ }
+ QString errorMessage;
+ bool resetZoom = false;
+
+ if (newFactor < 0) {
+ resetZoom = true;
+ newFactor = 1.0;
+ }
+
+ // On single-window devices we allow any scale factor as the window will adapt to the screen.
+ if (m_supportsMultipleWindows) {
+ const QSize newAvailableScreenSize = QQmlPreviewPosition::currentScreenSize(m_currentWindow)
+ * QHighDpiScaling::factor(m_currentWindow) / newFactor;
+ if (m_currentWindow->size().width() > newAvailableScreenSize.width()) {
+ errorMessage = QString::fromLatin1(
+ "Zooming with factor: "
+ "%1 will result in a too wide preview.").arg(newFactor);
+ }
+ if (m_currentWindow->size().height() > newAvailableScreenSize.height()) {
+ errorMessage = QString::fromLatin1(
+ "Zooming with factor: "
+ "%1 will result in a too heigh preview.").arg(newFactor);
+ }
+ }
+
+ if (errorMessage.isEmpty()) {
+ const QPoint newToOriginMappedPosition = m_currentWindow->position() *
+ QHighDpiScaling::factor(m_currentWindow) / newFactor;
+ m_currentWindow->destroy();
+ QHighDpiScaling::setScreenFactor(m_currentWindow->screen(), newFactor);
+ if (resetZoom)
+ QHighDpiScaling::updateHighDpiScaling();
+ m_currentWindow->setPosition(newToOriginMappedPosition);
+ m_currentWindow->show();
+ } else {
+ emit error(errorMessage);
+ }
+}
+
+void QQmlPreviewHandler::removeTranslators()
+{
+ if (!m_qtTranslator.isNull()) {
+ QCoreApplication::removeTranslator(m_qtTranslator.get());
+ m_qtTranslator.reset();
+ }
+
+ if (m_qmlTranslator.isNull()) {
+ QCoreApplication::removeTranslator(m_qmlTranslator.get());
+ m_qmlTranslator.reset();
+ }
+}
+
+void QQmlPreviewHandler::language(const QUrl &context, const QLocale &locale)
+{
+ removeTranslators();
+
+ m_qtTranslator.reset(new QTranslator(this));
+ if (m_qtTranslator->load(locale, QLatin1String("qt"), QLatin1String("_"),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ QCoreApplication::installTranslator(m_qtTranslator.get());
+ }
+
+ m_qmlTranslator.reset(new QTranslator(this));
+ if (m_qmlTranslator->load(locale, QLatin1String("qml"), QLatin1String("_"),
+ context.toLocalFile() + QLatin1String("/i18n"))) {
+ QCoreApplication::installTranslator(m_qmlTranslator.get());
+ }
+
+ for (QQmlEngine *engine : qAsConst(m_engines))
+ engine->retranslate();
+}
+
+void QQmlPreviewHandler::clear()
+{
+ qDeleteAll(m_createdObjects);
+ m_createdObjects.clear();
+ setCurrentWindow(nullptr);
+}
+
+Qt::WindowFlags fixFlags(Qt::WindowFlags flags)
+{
+ // If only the type flag is given, some other window flags are automatically assumed. When we
+ // add a flag, we need to make those explicit.
+ switch (flags) {
+ case Qt::Window:
+ return flags | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint
+ | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint;
+ case Qt::Dialog:
+ case Qt::Tool:
+ return flags | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+ default:
+ return flags;
+ }
+}
+
+void QQmlPreviewHandler::showObject(QObject *object)
+{
+ if (QWindow *window = qobject_cast<QWindow *>(object)) {
+ setCurrentWindow(qobject_cast<QQuickWindow *>(window));
+ for (QWindow *otherWindow : QGuiApplication::allWindows()) {
+ if (QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(otherWindow)) {
+ if (quickWindow == m_currentWindow)
+ continue;
+ quickWindow->setVisible(false);
+ quickWindow->setFlags(quickWindow->flags() & ~Qt::WindowStaysOnTopHint);
+ }
+ }
+ } else if (QQuickItem *item = qobject_cast<QQuickItem *>(object)) {
+ setCurrentWindow(nullptr);
+ for (QWindow *window : QGuiApplication::allWindows()) {
+ if (QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window)) {
+ if (m_currentWindow != nullptr) {
+ emit error(QLatin1String("Multiple QQuickWindows available. We cannot "
+ "decide which one to use."));
+ return;
+ }
+ setCurrentWindow(quickWindow);
+ } else {
+ window->setVisible(false);
+ window->setFlag(Qt::WindowStaysOnTopHint, false);
+ }
+ }
+
+ if (m_currentWindow == nullptr) {
+ setCurrentWindow(new QQuickWindow);
+ m_createdObjects.append(m_currentWindow.data());
+ }
+
+ for (QQuickItem *oldItem : m_currentWindow->contentItem()->childItems())
+ oldItem->setParentItem(m_dummyItem.data());
+
+ // Special case for QQuickView, as that keeps a "root" pointer around, and uses it to
+ // automatically resize the window or the item.
+ if (QQuickView *view = qobject_cast<QQuickView *>(m_currentWindow))
+ QQuickViewPrivate::get(view)->setRootObject(item);
+ else
+ item->setParentItem(m_currentWindow->contentItem());
+
+ m_currentWindow->resize(item->size().toSize());
+ } else {
+ emit error(QLatin1String("Created object is neither a QWindow nor a QQuickItem."));
+ }
+
+ if (m_currentWindow) {
+ m_lastPosition.initLastSavedWindowPosition(m_currentWindow);
+ m_currentWindow->setFlags(fixFlags(m_currentWindow->flags()) | Qt::WindowStaysOnTopHint);
+ m_currentWindow->setVisible(true);
+ }
+}
+
+void QQmlPreviewHandler::setCurrentWindow(QQuickWindow *window)
+{
+ if (window == m_currentWindow.data())
+ return;
+
+ if (m_currentWindow) {
+ disconnect(m_currentWindow.data(), &QQuickWindow::beforeSynchronizing,
+ this, &QQmlPreviewHandler::beforeSynchronizing);
+ disconnect(m_currentWindow.data(), &QQuickWindow::afterSynchronizing,
+ this, &QQmlPreviewHandler::afterSynchronizing);
+ disconnect(m_currentWindow.data(), &QQuickWindow::beforeRendering,
+ this, &QQmlPreviewHandler::beforeRendering);
+ disconnect(m_currentWindow.data(), &QQuickWindow::frameSwapped,
+ this, &QQmlPreviewHandler::frameSwapped);
+ m_fpsTimer.stop();
+ m_rendering = FrameTime();
+ m_synchronizing = FrameTime();
+ }
+
+ m_currentWindow = window;
+
+ if (m_currentWindow) {
+ connect(m_currentWindow.data(), &QQuickWindow::beforeSynchronizing,
+ this, &QQmlPreviewHandler::beforeSynchronizing, Qt::DirectConnection);
+ connect(m_currentWindow.data(), &QQuickWindow::afterSynchronizing,
+ this, &QQmlPreviewHandler::afterSynchronizing, Qt::DirectConnection);
+ connect(m_currentWindow.data(), &QQuickWindow::beforeRendering,
+ this, &QQmlPreviewHandler::beforeRendering, Qt::DirectConnection);
+ connect(m_currentWindow.data(), &QQuickWindow::frameSwapped,
+ this, &QQmlPreviewHandler::frameSwapped, Qt::DirectConnection);
+ m_fpsTimer.start();
+ }
+}
+
+void QQmlPreviewHandler::beforeSynchronizing()
+{
+ m_synchronizing.beginFrame();
+}
+
+void QQmlPreviewHandler::afterSynchronizing()
+{
+
+ if (m_rendering.elapsed >= 0)
+ m_rendering.endFrame();
+ m_synchronizing.recordFrame();
+ m_synchronizing.endFrame();
+}
+
+void QQmlPreviewHandler::beforeRendering()
+{
+ m_rendering.beginFrame();
+}
+
+void QQmlPreviewHandler::frameSwapped()
+{
+ m_rendering.recordFrame();
+}
+
+void QQmlPreviewHandler::FrameTime::beginFrame()
+{
+ timer.start();
+}
+
+void QQmlPreviewHandler::FrameTime::recordFrame()
+{
+ elapsed = timer.elapsed();
+}
+
+void QQmlPreviewHandler::FrameTime::endFrame()
+{
+ if (elapsed < min)
+ min = static_cast<quint16>(qMax(0ll, elapsed));
+ if (elapsed > max)
+ max = static_cast<quint16>(qMin(qint64(std::numeric_limits<quint16>::max()), elapsed));
+ total = static_cast<quint16>(qBound(0ll, qint64(std::numeric_limits<quint16>::max()),
+ elapsed + total));
+ ++number;
+ elapsed = -1;
+}
+
+void QQmlPreviewHandler::FrameTime::reset()
+{
+ min = std::numeric_limits<quint16>::max();
+ max = 0;
+ total = 0;
+ number = 0;
+}
+
+void QQmlPreviewHandler::fpsTimerHit()
+{
+ const FpsInfo info = {
+ m_synchronizing.number,
+ m_synchronizing.min,
+ m_synchronizing.max,
+ m_synchronizing.total,
+
+ m_rendering.number,
+ m_rendering.min,
+ m_rendering.max,
+ m_rendering.total
+ };
+
+ emit fps(info);
+
+ m_rendering.reset();
+ m_synchronizing.reset();
+}
+
+void QQmlPreviewHandler::tryCreateObject()
+{
+ if (!m_supportsMultipleWindows)
+ closeAllWindows();
+ QObject *object = m_component->create();
+ m_createdObjects.append(object);
+ showObject(object);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.h
new file mode 100644
index 0000000000..21ea672580
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewhandler.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPREVIEWHANDLER_H
+#define QQMLPREVIEWHANDLER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qqmlpreviewposition.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qelapsedtimer.h>
+#include <QtQml/qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QQuickItem;
+class QQmlPreviewUrlInterceptor;
+class QQuickWindow;
+class QTranslator;
+
+class QQmlPreviewHandler : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QQmlPreviewHandler(QObject *parent = nullptr);
+ ~QQmlPreviewHandler();
+
+ void addEngine(QQmlEngine *engine);
+ void removeEngine(QQmlEngine *engine);
+
+ void loadUrl(const QUrl &url);
+ void rerun();
+ void zoom(qreal newFactor);
+ void language(const QUrl &context, const QLocale &locale);
+
+ void clear();
+
+ struct FpsInfo {
+ quint16 numSyncs;
+ quint16 minSync;
+ quint16 maxSync;
+ quint16 totalSync;
+
+ quint16 numRenders;
+ quint16 minRender;
+ quint16 maxRender;
+ quint16 totalRender;
+ };
+
+signals:
+ void error(const QString &message);
+ void fps(const FpsInfo &info);
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+private:
+ void tryCreateObject();
+ void showObject(QObject *object);
+ void setCurrentWindow(QQuickWindow *window);
+
+ void beforeSynchronizing();
+ void afterSynchronizing();
+ void beforeRendering();
+ void frameSwapped();
+
+ void fpsTimerHit();
+ void removeTranslators();
+
+ QScopedPointer<QQuickItem> m_dummyItem;
+ QList<QQmlEngine *> m_engines;
+ QVector<QPointer<QObject>> m_createdObjects;
+ QScopedPointer<QQmlComponent> m_component;
+ QPointer<QQuickWindow> m_currentWindow;
+ bool m_supportsMultipleWindows;
+ QQmlPreviewPosition m_lastPosition;
+
+ QTimer m_fpsTimer;
+
+ struct FrameTime {
+ void beginFrame();
+ void recordFrame();
+ void endFrame();
+ void reset();
+
+ QElapsedTimer timer;
+ qint64 elapsed = -1;
+ quint16 min = std::numeric_limits<quint16>::max();
+ quint16 max = 0;
+ quint16 total = 0;
+ quint16 number = 0;
+ };
+
+ FrameTime m_rendering;
+ FrameTime m_synchronizing;
+
+ QScopedPointer<QTranslator> m_qtTranslator;
+ QScopedPointer<QTranslator> m_qmlTranslator;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlPreviewHandler::FpsInfo)
+
+#endif // QQMLPREVIEWHANDLER_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.cpp
new file mode 100644
index 0000000000..3edcbac0a9
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewposition.h"
+
+#include <QtGui/qwindow.h>
+#include <QtGui/qscreen.h>
+#include <QtGui/qguiapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+static const QSize availableScreenSize(const QPoint &point)
+{
+ if (const QScreen *screen = QGuiApplication::screenAt(point))
+ return screen->availableGeometry().size();
+ return QSize();
+}
+
+QQmlPreviewPosition::QQmlPreviewPosition()
+ : m_settings("QtProject", "QtQmlPreview")
+{
+ m_savePositionTimer.setSingleShot(true);
+ m_savePositionTimer.setInterval(500);
+ QObject::connect(&m_savePositionTimer, &QTimer::timeout, [this]() {
+ saveWindowPosition();
+ });
+}
+
+void QQmlPreviewPosition::setPosition(const QPoint &point)
+{
+ m_hasPosition = true;
+ m_lastWindowPosition = point;
+ m_savePositionTimer.start();
+}
+
+void QQmlPreviewPosition::saveWindowPosition()
+{
+ if (m_hasPosition) {
+ if (!m_settingsKey.isNull())
+ m_settings.setValue(m_settingsKey, m_lastWindowPosition);
+
+ m_settings.setValue(QLatin1String("global_lastpostion"), m_lastWindowPosition);
+ }
+}
+
+void QQmlPreviewPosition::loadWindowPositionSettings(const QUrl &url)
+{
+ m_settingsKey = url.toString(QUrl::PreferLocalFile) + QLatin1String("_lastpostion");
+
+ if (m_settings.contains(m_settingsKey)) {
+ m_hasPosition = true;
+ m_lastWindowPosition = m_settings.value(m_settingsKey).toPoint();
+ }
+}
+
+void QQmlPreviewPosition::initLastSavedWindowPosition(QWindow *window)
+{
+ if (m_positionedWindows.contains(window))
+ return;
+ if (!m_hasPosition) {
+ // in case there was nothing saved, we do not want to set anything
+ if (!m_settings.contains(QLatin1String("global_lastpostion")))
+ return;
+ m_lastWindowPosition = m_settings.value(QLatin1String("global_lastpostion")).toPoint();
+ }
+ if (QGuiApplication::screenAt(m_lastWindowPosition))
+ window->setFramePosition(m_lastWindowPosition);
+
+ m_positionedWindows.append(window);
+}
+
+const QSize QQmlPreviewPosition::currentScreenSize(QWindow *window)
+{
+ return availableScreenSize(window->position());
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/compressedtexture/qsgtexturefilehandler_p.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.h
index 8b831aebb9..3d4ca9dc67 100644
--- a/src/quick/scenegraph/compressedtexture/qsgtexturefilehandler_p.h
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewposition.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtQuick module of the Qt Toolkit.
+** This file is part of the QML preview debug service.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGTEXTUREFILEHANDLER_P_H
-#define QSGTEXTUREFILEHANDLER_P_H
+#ifndef QQMLPREVIEWPOSITION_H
+#define QQMLPREVIEWPOSITION_H
//
// W A R N I N G
@@ -51,33 +51,37 @@
// We mean it.
//
-#include <QLoggingCategory>
+#include <QtCore/qvector.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qsettings.h>
QT_BEGIN_NAMESPACE
-Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TEXTUREIO)
+class QWindow;
-class QQuickTextureFactory;
-
-class QSGTextureFileHandler
+class QQmlPreviewPosition
{
public:
- QSGTextureFileHandler(QIODevice *device, const QByteArray &logName = QByteArray())
- : m_device(device)
- {
- m_logName = !logName.isEmpty() ? logName : QByteArrayLiteral("(unknown)");
- }
- virtual ~QSGTextureFileHandler() {}
+ QQmlPreviewPosition();
- virtual QQuickTextureFactory *read() = 0;
- QIODevice *device() const { return m_device; }
- QByteArray logName() const { return m_logName; }
+ void setPosition(const QPoint &point);
+ void saveWindowPosition();
+ void loadWindowPositionSettings(const QUrl &url);
+ void initLastSavedWindowPosition(QWindow *window);
+ static const QSize currentScreenSize(QWindow *window);
private:
- QIODevice *m_device = nullptr;
- QByteArray m_logName;
+ bool m_hasPosition = false;
+ QPoint m_lastWindowPosition;
+ QSettings m_settings;
+ QString m_settingsKey;
+ QTimer m_savePositionTimer;
+ QVector<QWindow *> m_positionedWindows;
};
+
QT_END_NAMESPACE
-#endif // QSGTEXTUREFILEHANDLER_P_H
+#endif // QQMLPREVIEWPOSITION_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.cpp
new file mode 100644
index 0000000000..2e2224df47
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.cpp
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewservice.h"
+
+#include <QtCore/qpointer.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qquickitem.h>
+#include <QtGui/qguiapplication.h>
+
+#include <private/qquickpixmapcache_p.h>
+#include <private/qqmldebugconnector_p.h>
+#include <private/qversionedpacket_p.h>
+
+QT_BEGIN_NAMESPACE
+
+const QString QQmlPreviewServiceImpl::s_key = QStringLiteral("QmlPreview");
+using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>;
+
+QQmlPreviewServiceImpl::QQmlPreviewServiceImpl(QObject *parent) :
+ QQmlDebugService(s_key, 1.0f, parent)
+{
+ m_loader.reset(new QQmlPreviewFileLoader(this));
+ connect(this, &QQmlPreviewServiceImpl::load,
+ m_loader.data(), &QQmlPreviewFileLoader::whitelist, Qt::DirectConnection);
+ connect(this, &QQmlPreviewServiceImpl::load, &m_handler, &QQmlPreviewHandler::loadUrl);
+ connect(this, &QQmlPreviewServiceImpl::rerun, &m_handler, &QQmlPreviewHandler::rerun);
+ connect(this, &QQmlPreviewServiceImpl::zoom, &m_handler, &QQmlPreviewHandler::zoom);
+ connect(this, &QQmlPreviewServiceImpl::language, &m_handler, &QQmlPreviewHandler::language);
+ connect(&m_handler, &QQmlPreviewHandler::error, this, &QQmlPreviewServiceImpl::forwardError,
+ Qt::DirectConnection);
+ connect(&m_handler, &QQmlPreviewHandler::fps, this, &QQmlPreviewServiceImpl::forwardFps,
+ Qt::DirectConnection);
+}
+
+QQmlPreviewServiceImpl::~QQmlPreviewServiceImpl()
+{
+}
+
+void QQmlPreviewServiceImpl::messageReceived(const QByteArray &data)
+{
+ QQmlDebugPacket packet(data);
+ qint8 command;
+
+ packet >> command;
+ switch (command) {
+ case File: {
+ QString path;
+ QByteArray contents;
+ packet >> path >> contents;
+ emit file(path, contents);
+
+ // Replace the whole scene with the first file successfully loaded over the debug
+ // connection. This is an OK approximation of the root component, and if the client wants
+ // something specific, it will send an explicit Load anyway.
+ if (m_currentUrl.isEmpty() && path.endsWith(".qml")) {
+ if (path.startsWith(':'))
+ m_currentUrl = QUrl("qrc" + path);
+ else
+ m_currentUrl = QUrl::fromLocalFile(path);
+ emit load(m_currentUrl);
+ }
+ break;
+ }
+ case Directory: {
+ QString path;
+ QStringList entries;
+ packet >> path >> entries;
+ emit directory(path, entries);
+ break;
+ }
+ case Load: {
+ QUrl url;
+ packet >> url;
+ if (url.isEmpty())
+ url = m_currentUrl;
+ else
+ m_currentUrl = url;
+ emit load(url);
+ break;
+ }
+ case Error: {
+ QString file;
+ packet >> file;
+ emit error(file);
+ break;
+ }
+ case Rerun:
+ emit rerun();
+ break;
+ case ClearCache:
+ emit clearCache();
+ break;
+ case Zoom: {
+ float factor;
+ packet >> factor;
+ emit zoom(static_cast<qreal>(factor));
+ break;
+ }
+ case Language: {
+ QUrl context;
+ QString locale;
+ packet >> context >> locale;
+ emit language(context.isEmpty() ? m_currentUrl : context,
+ locale.isEmpty() ? QLocale() : QLocale(locale));
+ break;
+ }
+ default:
+ forwardError(QString::fromLatin1("Invalid command: %1").arg(command));
+ break;
+ }
+}
+
+void QQmlPreviewServiceImpl::engineAboutToBeAdded(QJSEngine *engine)
+{
+ if (QQmlEngine *qmlEngine = qobject_cast<QQmlEngine *>(engine))
+ m_handler.addEngine(qmlEngine);
+ emit attachedToEngine(engine);
+}
+
+void QQmlPreviewServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
+{
+ if (QQmlEngine *qmlEngine = qobject_cast<QQmlEngine *>(engine))
+ m_handler.removeEngine(qmlEngine);
+ emit detachedFromEngine(engine);
+}
+
+void QQmlPreviewServiceImpl::stateChanged(QQmlDebugService::State state)
+{
+ m_fileEngine.reset(state == Enabled ? new QQmlPreviewFileEngineHandler(m_loader.data())
+ : nullptr);
+}
+
+void QQmlPreviewServiceImpl::forwardRequest(const QString &file)
+{
+ QQmlDebugPacket packet;
+ packet << static_cast<qint8>(Request) << file;
+ emit messageToClient(name(), packet.data());
+}
+
+void QQmlPreviewServiceImpl::forwardError(const QString &error)
+{
+ QQmlDebugPacket packet;
+ packet << static_cast<qint8>(Error) << error;
+ emit messageToClient(name(), packet.data());
+}
+
+void QQmlPreviewServiceImpl::forwardFps(const QQmlPreviewHandler::FpsInfo &frames)
+{
+ QQmlDebugPacket packet;
+ packet << static_cast<qint8>(Fps)
+ << frames.numSyncs << frames.minSync << frames.maxSync << frames.totalSync
+ << frames.numRenders << frames.minRender << frames.maxRender << frames.totalRender;
+ emit messageToClient(name(), packet.data());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.h
new file mode 100644
index 0000000000..7bdc87ec59
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLPREVIEWSERVICE_H
+#define QQMLPREVIEWSERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qqmlpreviewhandler.h"
+#include "qqmlpreviewfileengine.h"
+#include <private/qqmldebugserviceinterfaces_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlPreviewFileEngineHandler;
+class QQmlPreviewHandler;
+class QQmlPreviewServiceImpl : public QQmlDebugService
+{
+ Q_OBJECT
+
+public:
+ enum Command {
+ File,
+ Load,
+ Request,
+ Error,
+ Rerun,
+ Directory,
+ ClearCache,
+ Zoom,
+ Fps,
+ Language
+ };
+
+ static const QString s_key;
+
+ QQmlPreviewServiceImpl(QObject *parent = nullptr);
+ virtual ~QQmlPreviewServiceImpl();
+
+ void messageReceived(const QByteArray &message) override;
+ void engineAboutToBeAdded(QJSEngine *engine) override;
+ void engineAboutToBeRemoved(QJSEngine *engine) override;
+ void stateChanged(State state) override;
+
+ void forwardRequest(const QString &file);
+ void forwardError(const QString &error);
+ void forwardFps(const QQmlPreviewHandler::FpsInfo &frames);
+
+signals:
+ void error(const QString &file);
+ void file(const QString &file, const QByteArray &contents);
+ void directory(const QString &file, const QStringList &entries);
+ void load(const QUrl &url);
+ void rerun();
+ void clearCache();
+ void zoom(qreal factor);
+ void language(const QUrl &context, const QLocale &locale);
+
+private:
+ QScopedPointer<QQmlPreviewFileEngineHandler> m_fileEngine;
+ QScopedPointer<QQmlPreviewFileLoader> m_loader;
+ QQmlPreviewHandler m_handler;
+ QUrl m_currentUrl;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPREVIEWSERVICE_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json
new file mode 100644
index 0000000000..d7e1ef1f10
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json
@@ -0,0 +1,3 @@
+{
+ "Keys" : [ "QmlPreview" ]
+}
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp
new file mode 100644
index 0000000000..f0aa3226c8
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QML preview debug service.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlpreviewservicefactory.h"
+#include "qqmlpreviewservice.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebugService *QQmlPreviewServiceFactory::create(const QString &key)
+{
+ return key == QQmlPreviewServiceImpl::s_key ? new QQmlPreviewServiceImpl(this) : nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/compressedtexture/qsgktxhandler_p.h b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.h
index 22f4db65b2..0ceadf24f5 100644
--- a/src/quick/scenegraph/compressedtexture/qsgktxhandler_p.h
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtQuick module of the Qt Toolkit.
+** This file is part of the QML preview debug service.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGKTXHANDLER_H
-#define QSGKTXHANDLER_H
+#ifndef QQMLPREVIEWSERVCIEFACTORY_H
+#define QQMLPREVIEWSERVCIEFACTORY_H
//
// W A R N I N G
@@ -51,28 +51,19 @@
// We mean it.
//
-#include "qsgtexturefilehandler_p.h"
+#include <private/qqmldebugservicefactory_p.h>
QT_BEGIN_NAMESPACE
-struct KTXHeader;
-
-class QSGKtxHandler : public QSGTextureFileHandler
+class QQmlPreviewServiceFactory : public QQmlDebugServiceFactory
{
-public:
- using QSGTextureFileHandler::QSGTextureFileHandler;
-
- static bool canRead(const QByteArray &suffix, const QByteArray &block);
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlpreviewservice.json")
- QQuickTextureFactory *read() override;
-
-private:
- bool checkHeader(const KTXHeader &header);
- quint32 decode(quint32 val);
-
- bool inverseEndian = false;
+public:
+ QQmlDebugService *create(const QString &key) override;
};
QT_END_NAMESPACE
-#endif // QSGKTXHANDLER_H
+#endif // QQMLPREVIEWSERVCIEFACTORY_H
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
index 19104927f2..a688e98b3f 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
@@ -80,8 +80,7 @@ void QQmlProfilerAdapter::init(QQmlProfilerService *service, QQmlProfiler *profi
// convert to QByteArrays that can be sent to the debug client
static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
QQmlProfiler::LocationHash &locations,
- QList<QByteArray> &messages,
- bool trackLocations)
+ QList<QByteArray> &messages)
{
QQmlDebugPacket ds;
Q_ASSERT_X((d.messageType & (1 << 31)) == 0, Q_FUNC_INFO,
@@ -96,7 +95,7 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
if (decodedMessageType == QQmlProfilerDefinitions::RangeEnd
|| decodedMessageType == QQmlProfilerDefinitions::RangeStart) {
ds << d.time << decodedMessageType << static_cast<quint32>(d.detailType);
- if (trackLocations && d.locationId != 0)
+ if (d.locationId != 0)
ds << static_cast<qint64>(d.locationId);
} else {
auto i = locations.find(d.locationId);
@@ -107,8 +106,7 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
<< static_cast<qint32>(i->location.column);
if (d.messageType & (1 << QQmlProfilerDefinitions::RangeData)) {
// Send both, location and data ...
- if (trackLocations)
- ds << static_cast<qint64>(d.locationId);
+ ds << static_cast<qint64>(d.locationId);
messages.append(ds.squeezedData());
ds.clear();
ds << d.time << int(QQmlProfilerDefinitions::RangeData)
@@ -116,10 +114,8 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
<< (i->location.sourceFile.isEmpty() ? i->url.toString() :
i->location.sourceFile);
}
- if (trackLocations) {
- ds << static_cast<qint64>(d.locationId);
- locations.erase(i); // ... so that we can erase here without missing anything.
- }
+ ds << static_cast<qint64>(d.locationId);
+ locations.erase(i); // ... so that we can erase here without missing anything.
} else {
// Skip RangeData and RangeLocation: We've already sent them
continue;
@@ -130,14 +126,13 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
}
}
-qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages,
- bool trackLocations)
+qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
while (next != data.length()) {
const QQmlProfilerData &nextData = data.at(next);
if (nextData.time > until || messages.length() > s_numMessagesPerBatch)
return nextData.time;
- qQmlProfilerDataToByteArrays(nextData, locations, messages, trackLocations);
+ qQmlProfilerDataToByteArrays(nextData, locations, messages);
++next;
}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h
index b14b72d254..12544a19c2 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h
@@ -61,8 +61,7 @@ class QQmlProfilerAdapter : public QQmlAbstractProfilerAdapter {
public:
QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine);
QQmlProfilerAdapter(QQmlProfilerService *service, QQmlTypeLoader *loader);
- qint64 sendMessages(qint64 until, QList<QByteArray> &messages,
- bool trackLocations) override;
+ qint64 sendMessages(qint64 until, QList<QByteArray> &messages) override;
void receiveData(const QVector<QQmlProfilerData> &new_data,
const QQmlProfiler::LocationHash &locations);
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
index 21a5663f59..462401a093 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
@@ -58,7 +58,7 @@ Q_QML_DEBUG_PLUGIN_LOADER(QQmlAbstractProfilerAdapter)
QQmlProfilerServiceImpl::QQmlProfilerServiceImpl(QObject *parent) :
QQmlConfigurableDebugService<QQmlProfilerService>(1, parent),
- m_waitingForStop(false), m_useMessageTypes(false), m_globalEnabled(false), m_globalFeatures(0)
+ m_waitingForStop(false), m_globalEnabled(false), m_globalFeatures(0)
{
m_timer.start();
QQmlAbstractProfilerAdapter *quickAdapter =
@@ -332,7 +332,7 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine)
m_waitingForStop = true;
for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
- profiler->reportData(m_useMessageTypes);
+ profiler->reportData();
for (QQmlAbstractProfilerAdapter *profiler : qAsConst(stopping))
profiler->stopProfiling();
@@ -367,8 +367,7 @@ void QQmlProfilerServiceImpl::sendMessages()
m_startTimes.erase(m_startTimes.begin());
qint64 next = first->sendMessages(m_startTimes.isEmpty() ?
std::numeric_limits<qint64>::max() :
- m_startTimes.begin().key(), messages,
- m_useMessageTypes);
+ m_startTimes.begin().key(), messages);
if (next != -1)
m_startTimes.insert(next, first);
@@ -454,13 +453,15 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message)
&m_flushTimer, &QTimer::stop);
}
}
+
+ bool useMessageTypes = false;
if (!stream.atEnd())
- stream >> m_useMessageTypes;
+ stream >> useMessageTypes;
// If engineId == -1 objectForId() and then the cast will return 0.
- if (enabled)
+ if (enabled && useMessageTypes) // If the client doesn't support message types don't profile.
startProfiling(qobject_cast<QJSEngine *>(objectForId(engineId)), features);
- else
+ else if (!enabled) // On stopProfiling the client doesn't repeat useMessageTypes.
stopProfiling(qobject_cast<QJSEngine *>(objectForId(engineId)));
stopWaiting();
@@ -486,7 +487,7 @@ void QQmlProfilerServiceImpl::flush()
}
for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
- profiler->reportData(m_useMessageTypes);
+ profiler->reportData();
}
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h
index 2b92a478c1..3791ab29ae 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h
@@ -117,7 +117,6 @@ private:
QElapsedTimer m_timer;
QTimer m_flushTimer;
bool m_waitingForStop;
- bool m_useMessageTypes;
bool m_globalEnabled;
quint64 m_globalFeatures;
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
index f1ac8ef998..e4f2f556fc 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
@@ -104,8 +104,7 @@ qint64 QV4ProfilerAdapter::finalizeMessages(qint64 until, QList<QByteArray> &mes
return callNext == -1 ? memoryNext : qMin(callNext, memoryNext);
}
-qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages,
- bool trackLocations)
+qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
QQmlDebugPacket d;
@@ -134,24 +133,17 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
appendMemoryEvents(props.start, messages, d);
auto location = m_functionLocations.find(props.id);
- d << props.start << int(RangeStart) << int(Javascript);
- if (trackLocations)
- d << static_cast<qint64>(props.id);
+ d << props.start << int(RangeStart) << int(Javascript) << static_cast<qint64>(props.id);
if (location != m_functionLocations.end()) {
messages.push_back(d.squeezedData());
d.clear();
d << props.start << int(RangeLocation) << int(Javascript) << location->file << location->line
- << location->column;
- if (trackLocations)
- d << static_cast<qint64>(props.id);
+ << location->column << static_cast<qint64>(props.id);
messages.push_back(d.squeezedData());
d.clear();
- d << props.start << int(RangeData) << int(Javascript) << location->name;
-
- if (trackLocations) {
- d << static_cast<qint64>(props.id);
- m_functionLocations.erase(location);
- }
+ d << props.start << int(RangeData) << int(Javascript) << location->name
+ << static_cast<qint64>(props.id);
+ m_functionLocations.erase(location);
}
messages.push_back(d.squeezedData());
d.clear();
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h
index 2211c82fc5..c4ca38d9b0 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h
@@ -68,8 +68,7 @@ class QV4ProfilerAdapter : public QQmlAbstractProfilerAdapter {
public:
QV4ProfilerAdapter(QQmlProfilerService *service, QV4::ExecutionEngine *engine);
- virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages,
- bool trackLocations) override;
+ virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages) override;
void receiveData(const QV4::Profiling::FunctionLocationHash &,
const QVector<QV4::Profiling::FunctionCallProperties> &,
diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
index 2c152e4cd5..79a1c82411 100644
--- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp
@@ -152,10 +152,8 @@ static void qQuickProfilerDataToByteArrays(const QQuickProfilerData &data,
}
}
-qint64 QQuickProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages,
- bool trackLocations)
+qint64 QQuickProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
- Q_UNUSED(trackLocations);
while (next < m_data.size()) {
if (m_data[next].time <= until && messages.length() <= s_numMessagesPerBatch)
qQuickProfilerDataToByteArrays(m_data[next++], messages);
diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h
index 1ad020afd6..1f3467c1d0 100644
--- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h
+++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h
@@ -61,7 +61,7 @@ class QQuickProfilerAdapter : public QQmlAbstractProfilerAdapter {
public:
QQuickProfilerAdapter(QObject *parent = 0);
~QQuickProfilerAdapter();
- qint64 sendMessages(qint64 until, QList<QByteArray> &messages, bool trackLocations) override;
+ qint64 sendMessages(qint64 until, QList<QByteArray> &messages) override;
void receiveData(const QVector<QQuickProfilerData> &new_data);
private:
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index c1e86f0b3c..8293e88038 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -177,14 +177,13 @@ private:
void changeServiceState(const QString &serviceName, QQmlDebugService::State state);
void removeThread();
void receiveMessage();
- void invalidPacket();
+ void protocolError();
QQmlDebugServerConnection *m_connection;
QHash<QString, QQmlDebugService *> m_plugins;
QStringList m_clientPlugins;
bool m_gotHello;
bool m_blockingMode;
- bool m_clientSupportsMultiPackets;
QHash<QJSEngine *, EngineCondition> m_engineConditions;
@@ -277,8 +276,7 @@ static void cleanupOnShutdown()
QQmlDebugServerImpl::QQmlDebugServerImpl() :
m_connection(nullptr),
m_gotHello(false),
- m_blockingMode(false),
- m_clientSupportsMultiPackets(false)
+ m_blockingMode(false)
{
static bool postRoutineAdded = false;
if (!postRoutineAdded) {
@@ -464,10 +462,9 @@ void QQmlDebugServerImpl::receiveMessage()
s_dataStreamVersion = QDataStream::Qt_DefaultCompiledVersion;
}
+ bool clientSupportsMultiPackets = false;
if (!in.atEnd())
- in >> m_clientSupportsMultiPackets;
- else
- m_clientSupportsMultiPackets = false;
+ in >> clientSupportsMultiPackets;
// Send the hello answer immediately, since it needs to arrive before
// the plugins below start sending messages.
@@ -475,13 +472,15 @@ void QQmlDebugServerImpl::receiveMessage()
QQmlDebugPacket out;
QStringList pluginNames;
QList<float> pluginVersions;
- const int count = m_plugins.count();
- pluginNames.reserve(count);
- pluginVersions.reserve(count);
- for (QHash<QString, QQmlDebugService *>::ConstIterator i = m_plugins.constBegin();
- i != m_plugins.constEnd(); ++i) {
- pluginNames << i.key();
- pluginVersions << i.value()->version();
+ if (clientSupportsMultiPackets) { // otherwise, disable all plugins
+ const int count = m_plugins.count();
+ pluginNames.reserve(count);
+ pluginVersions.reserve(count);
+ for (QHash<QString, QQmlDebugService *>::ConstIterator i = m_plugins.constBegin();
+ i != m_plugins.constEnd(); ++i) {
+ pluginNames << i.key();
+ pluginVersions << i.value()->version();
+ }
}
out << QString(QStringLiteral("QDeclarativeDebugClient")) << 0 << protocolVersion
@@ -523,7 +522,7 @@ void QQmlDebugServerImpl::receiveMessage()
} else {
qWarning("QML Debugger: Invalid control message %d.", op);
- invalidPacket();
+ protocolError();
return;
}
@@ -701,16 +700,11 @@ void QQmlDebugServerImpl::sendMessage(const QString &name, const QByteArray &mes
void QQmlDebugServerImpl::sendMessages(const QString &name, const QList<QByteArray> &messages)
{
if (canSendMessage(name)) {
- if (m_clientSupportsMultiPackets) {
- QQmlDebugPacket out;
- out << name;
- for (const QByteArray &message : messages)
- out << message;
- m_protocol->send(out.data());
- } else {
- for (const QByteArray &message : messages)
- doSendMessage(name, message);
- }
+ QQmlDebugPacket out;
+ out << name;
+ for (const QByteArray &message : messages)
+ out << message;
+ m_protocol->send(out.data());
m_connection->flush();
}
}
@@ -743,16 +737,16 @@ void QQmlDebugServerImpl::setDevice(QIODevice *socket)
m_protocol = new QPacketProtocol(socket, this);
QObject::connect(m_protocol, &QPacketProtocol::readyRead,
this, &QQmlDebugServerImpl::receiveMessage);
- QObject::connect(m_protocol, &QPacketProtocol::invalidPacket,
- this, &QQmlDebugServerImpl::invalidPacket);
+ QObject::connect(m_protocol, &QPacketProtocol::error,
+ this, &QQmlDebugServerImpl::protocolError);
if (blockingMode())
m_protocol->waitForReadyRead(-1);
}
-void QQmlDebugServerImpl::invalidPacket()
+void QQmlDebugServerImpl::protocolError()
{
- qWarning("QML Debugger: Received a corrupted packet! Giving up ...");
+ qWarning("QML Debugger: A protocol error has occurred! Giving up ...");
m_connection->disconnect();
// protocol might still be processing packages at this point
m_protocol->deleteLater();
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 119415372b..30097be77b 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -6,9 +6,8 @@ SUBDIRS += \
packetprotocol
# Connectors
-SUBDIRS += \
- qmldbg_native \
- qmldbg_server
+SUBDIRS += qmldbg_native
+qtConfig(thread): SUBDIRS += qmldbg_server
qmldbg_native.depends = packetprotocol
qmldbg_server.depends = packetprotocol
@@ -36,6 +35,10 @@ qtHaveModule(quick) {
SUBDIRS += \
qmldbg_inspector \
qmldbg_quickprofiler
+
+ qtConfig(qml-network): SUBDIRS += qmldbg_preview
+
qmldbg_inspector.depends = packetprotocol
qmldbg_quickprofiler.depends = packetprotocol
+ qmldbg_preview.depends = packetprotocol
}
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
index 0bd51cbf46..d728686248 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
@@ -176,6 +176,12 @@ void QSGOpenVGInternalRectangleNode::setGradientStops(const QGradientStops &stop
m_fillDirty = true;
}
+void QSGOpenVGInternalRectangleNode::setGradientVertical(bool vertical)
+{
+ m_vertical = vertical;
+ m_fillDirty = true;
+}
+
void QSGOpenVGInternalRectangleNode::setRadius(qreal radius)
{
m_radius = radius;
@@ -242,13 +248,13 @@ void QSGOpenVGInternalRectangleNode::render()
} else {
// Linear Gradient
vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
- const VGfloat verticalLinearGradient[] = {
- 0.0f,
+ const VGfloat linearGradient[] = {
0.0f,
0.0f,
- static_cast<VGfloat>(m_rect.height())
+ m_vertical ? 0.0f : static_cast<VGfloat>(m_rect.width()),
+ m_vertical ? static_cast<VGfloat>(m_rect.height()) : 0.0f
};
- vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, verticalLinearGradient);
+ vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_PAD);
vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, false);
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
index e8d25c94f8..86d2c3318c 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
@@ -59,6 +59,7 @@ public:
void setPenColor(const QColor &color) override;
void setPenWidth(qreal width) override;
void setGradientStops(const QGradientStops &stops) override;
+ void setGradientVertical(bool vertical) override;
void setRadius(qreal radius) override;
void setAligned(bool aligned) override;
void update() override;
@@ -85,6 +86,7 @@ private:
qreal m_penWidth = 0.0;
qreal m_radius = 0.0;
bool m_aligned = false;
+ bool m_vertical = true;
QGradientStops m_gradientStops;
VGPath m_rectanglePath;
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index 3f33e7e81b..ece2f0d692 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -70,17 +70,12 @@ QQmlAnimationTimer::QQmlAnimationTimer() :
QQmlAnimationTimer *QQmlAnimationTimer::instance(bool create)
{
QQmlAnimationTimer *inst;
-#ifndef QT_NO_THREAD
if (create && !animationTimer()->hasLocalData()) {
inst = new QQmlAnimationTimer;
animationTimer()->setLocalData(inst);
} else {
inst = animationTimer() ? animationTimer()->localData() : 0;
}
-#else
- static QAnimationTimer unifiedTimer;
- inst = &unifiedTimer;
-#endif
return inst;
}
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index 63fd4b0dac..0be6ca96ea 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -56,6 +56,8 @@
#include <QtCore/private/qabstractanimation_p.h>
#include <vector>
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class QAnimationGroupJob;
diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h
index fb567dc019..b01b2f3b36 100644
--- a/src/qml/animations/qanimationgroupjob_p.h
+++ b/src/qml/animations/qanimationgroupjob_p.h
@@ -54,6 +54,8 @@
#include "private/qabstractanimationjob_p.h"
#include <QtCore/qdebug.h>
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QAnimationGroupJob : public QAbstractAnimationJob
diff --git a/src/qml/animations/qanimationjobutil_p.h b/src/qml/animations/qanimationjobutil_p.h
index 0bb9e83b2d..e3d6fe9178 100644
--- a/src/qml/animations/qanimationjobutil_p.h
+++ b/src/qml/animations/qanimationjobutil_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+QT_REQUIRE_CONFIG(qml_animation);
+
#define RETURN_IF_DELETED(func) \
{ \
bool *prevWasDeleted = m_wasDeleted; \
diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h
index baf4ff1ae5..c67b8d39ad 100644
--- a/src/qml/animations/qcontinuinganimationgroupjob_p.h
+++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h
@@ -53,6 +53,8 @@
#include "private/qanimationgroupjob_p.h"
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QContinuingAnimationGroupJob : public QAnimationGroupJob
diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h
index 67ba626247..0265fe3274 100644
--- a/src/qml/animations/qparallelanimationgroupjob_p.h
+++ b/src/qml/animations/qparallelanimationgroupjob_p.h
@@ -53,6 +53,8 @@
#include "private/qanimationgroupjob_p.h"
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob
diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h
index d0e8d57fc7..6c9bbf0dab 100644
--- a/src/qml/animations/qpauseanimationjob_p.h
+++ b/src/qml/animations/qpauseanimationjob_p.h
@@ -53,6 +53,8 @@
#include <private/qanimationgroupjob_p.h>
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QPauseAnimationJob : public QAbstractAnimationJob
diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h
index 800f0c3b90..13f9806be1 100644
--- a/src/qml/animations/qsequentialanimationgroupjob_p.h
+++ b/src/qml/animations/qsequentialanimationgroupjob_p.h
@@ -53,6 +53,8 @@
#include <private/qanimationgroupjob_p.h>
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class QPauseAnimationJob;
diff --git a/src/qml/compiler/compiler.pri b/src/qml/compiler/compiler.pri
index 95096db51d..da3c173545 100644
--- a/src/qml/compiler/compiler.pri
+++ b/src/qml/compiler/compiler.pri
@@ -11,7 +11,8 @@ HEADERS += \
$$PWD/qv4codegen_p.h \
$$PWD/qqmlirbuilder_p.h \
$$PWD/qqmltypecompiler_p.h \
- $$PWD/qv4instr_moth_p.h
+ $$PWD/qv4instr_moth_p.h \
+ $$PWD/qv4bytecodehandler_p.h
SOURCES += \
$$PWD/qv4bytecodegenerator.cpp \
@@ -21,7 +22,8 @@ SOURCES += \
$$PWD/qv4compilerscanfunctions.cpp \
$$PWD/qv4codegen.cpp \
$$PWD/qqmlirbuilder.cpp \
- $$PWD/qv4instr_moth.cpp
+ $$PWD/qv4instr_moth.cpp \
+ $$PWD/qv4bytecodehandler.cpp
!qmldevtools_build {
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 8a1b3744ee..883b21ab07 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -96,23 +96,24 @@ void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, cons
declarationsOverride = nullptr;
}
-QString Object::sanityCheckFunctionNames(const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation)
+QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation)
{
QSet<int> functionNames;
- for (Function *f = functions->first; f; f = f->next) {
- QQmlJS::AST::FunctionDeclaration *function = f->functionDeclaration;
- Q_ASSERT(function);
- *errorLocation = function->identifierToken;
+ for (auto functionit = obj->functionsBegin(); functionit != obj->functionsEnd(); ++functionit) {
+ Function *f = functionit.ptr;
+ errorLocation->startLine = f->location.line;
+ errorLocation->startColumn = f->location.column;
if (functionNames.contains(f->nameIndex))
return tr("Duplicate method name");
functionNames.insert(f->nameIndex);
- for (QmlIR::Signal *s = qmlSignals->first; s; s = s->next) {
+ for (auto signalit = obj->signalsBegin(); signalit != obj->signalsEnd(); ++signalit) {
+ QmlIR::Signal *s = signalit.ptr;
if (s->nameIndex == f->nameIndex)
return tr("Duplicate method name");
}
- const QString name = function->name.toString();
+ const QString name = stringAt(f->nameIndex);
if (name.at(0).isUpper())
return tr("Method names cannot begin with an upper case letter");
if (illegalNames.contains(name))
@@ -497,7 +498,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectBinding *node)
bool IRBuilder::visit(QQmlJS::AST::UiScriptBinding *node)
{
- appendBinding(node->qualifiedId, node->statement);
+ appendBinding(node->qualifiedId, node->statement, node);
return false;
}
@@ -601,7 +602,7 @@ bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qu
return false;
QQmlJS::AST::SourceLocation loc;
- QString error = obj->sanityCheckFunctionNames(illegalNames, &loc);
+ QString error = sanityCheckFunctionNames(obj, illegalNames, &loc);
if (!error.isEmpty()) {
recordError(loc, error);
return false;
@@ -618,7 +619,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiImport *node)
if (!node->fileName.isNull()) {
uri = node->fileName.toString();
- if (uri.endsWith(QLatin1String(".js"))) {
+ if (uri.endsWith(QLatin1String(".js")) || uri.endsWith(QLatin1String(".mjs"))) {
import->type = QV4::CompiledData::Import::ImportScript;
} else {
import->type = QV4::CompiledData::Import::ImportFile;
@@ -690,9 +691,9 @@ bool IRBuilder::visit(QQmlJS::AST::UiPragma *node)
Pragma *pragma = New<Pragma>();
// For now the only valid pragma is Singleton, so lets validate the input
- if (!node->pragmaType->name.isNull())
+ if (!node->name.isNull())
{
- if (QLatin1String("Singleton") == node->pragmaType->name)
+ if (QLatin1String("Singleton") == node->name)
{
pragma->type = Pragma::PragmaSingleton;
} else {
@@ -957,7 +958,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
QQmlJS::AST::Node::accept(node->binding, this);
} else if (node->statement) {
if (!isRedundantNullInitializerForPropertyDeclaration(_propertyDeclaration, node->statement))
- appendBinding(node->identifierToken, node->identifierToken, _propertyDeclaration->nameIndex, node->statement);
+ appendBinding(node->identifierToken, node->identifierToken, _propertyDeclaration->nameIndex, node->statement, node);
}
qSwap(_propertyDeclaration, property);
}
@@ -971,26 +972,27 @@ bool IRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
if (QQmlJS::AST::FunctionDeclaration *funDecl = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration *>(node->sourceElement)) {
CompiledFunctionOrExpression *foe = New<CompiledFunctionOrExpression>();
foe->node = funDecl;
+ foe->parentNode = funDecl;
foe->nameIndex = registerString(funDecl->name.toString());
foe->disableAcceleratedLookups = false;
const int index = _object->functionsAndExpressions->append(foe);
Function *f = New<Function>();
- f->functionDeclaration = funDecl;
QQmlJS::AST::SourceLocation loc = funDecl->identifierToken;
f->location.line = loc.startLine;
f->location.column = loc.startColumn;
f->index = index;
f->nameIndex = registerString(funDecl->name.toString());
- int formalsCount = 0;
- for (QQmlJS::AST::FormalParameterList *it = funDecl->formals; it; it = it->next)
- ++formalsCount;
+ const QStringList formals = funDecl->formals ? funDecl->formals->formals() : QStringList();
+ int formalsCount = formals.size();
f->formals.allocate(pool, formalsCount);
int i = 0;
- for (QQmlJS::AST::FormalParameterList *it = funDecl->formals; it; it = it->next, ++i)
- f->formals[i] = registerString(it->name.toString());
+ for (const QString &arg : formals) {
+ f->formals[i] = registerString(arg);
+ ++i;
+ }
_object->appendFunction(f);
} else {
@@ -1044,7 +1046,7 @@ QStringRef IRBuilder::textRefAt(const QQmlJS::AST::SourceLocation &first, const
return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
}
-void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement)
+void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
{
QQmlJS::AST::SourceLocation loc = statement->firstSourceLocation();
binding->valueLocation.line = loc.startLine;
@@ -1067,7 +1069,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
binding->value.b = false;
} else if (QQmlJS::AST::NumericLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(expr)) {
binding->type = QV4::CompiledData::Binding::Type_Number;
- binding->setNumberValueInternal(lit->value);
+ binding->value.constantValueIndex = jsGenerator->registerConstant(QV4::Encode(lit->value));
} else if (QQmlJS::AST::CallExpression *call = QQmlJS::AST::cast<QQmlJS::AST::CallExpression *>(expr)) {
if (QQmlJS::AST::IdentifierExpression *base = QQmlJS::AST::cast<QQmlJS::AST::IdentifierExpression *>(call->base)) {
tryGeneratingTranslationBinding(base->name, call->arguments, binding);
@@ -1079,7 +1081,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
} else if (QQmlJS::AST::UnaryMinusExpression *unaryMinus = QQmlJS::AST::cast<QQmlJS::AST::UnaryMinusExpression *>(expr)) {
if (QQmlJS::AST::NumericLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(unaryMinus->expression)) {
binding->type = QV4::CompiledData::Binding::Type_Number;
- binding->setNumberValueInternal(-lit->value);
+ binding->value.constantValueIndex = jsGenerator->registerConstant(QV4::Encode(-lit->value));
}
}
}
@@ -1090,6 +1092,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
CompiledFunctionOrExpression *expr = New<CompiledFunctionOrExpression>();
expr->node = statement;
+ expr->parentNode = parentNode;
expr->nameIndex = registerString(QLatin1String("expression for ")
+ stringAt(binding->propertyNameIndex));
expr->disableAcceleratedLookups = false;
@@ -1117,6 +1120,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
} else {
return; // first argument is not a string, stop
}
+ translationData.stringIndex = jsGenerator->registerString(translation.toString());
args = args->next;
@@ -1141,8 +1145,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
return; // too many arguments, stop
binding->type = QV4::CompiledData::Binding::Type_Translation;
- binding->stringIndex = jsGenerator->registerString(translation.toString());
- binding->value.translationData = translationData;
+ binding->value.translationDataIndex = jsGenerator->registerTranslation(translationData);
} else if (base == QLatin1String("qsTrId")) {
QV4::CompiledData::TranslationData translationData;
translationData.number = -1;
@@ -1157,6 +1160,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
} else {
return; // first argument is not a string, stop
}
+ translationData.stringIndex = jsGenerator->registerString(id.toString());
args = args->next;
@@ -1173,8 +1177,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
return; // too many arguments, stop
binding->type = QV4::CompiledData::Binding::Type_TranslationById;
- binding->stringIndex = jsGenerator->registerString(id.toString());
- binding->value.translationData = translationData;
+ binding->value.translationDataIndex = jsGenerator->registerTranslation(translationData);
} else if (base == QLatin1String("QT_TR_NOOP") || base == QLatin1String("QT_TRID_NOOP")) {
if (!args || !args->expression)
return; // no arguments, stop
@@ -1216,7 +1219,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
}
}
-void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value)
+void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
{
const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken;
Object *object = nullptr;
@@ -1227,7 +1230,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Sta
return;
}
qSwap(_object, object);
- appendBinding(qualifiedNameLocation, name->identifierToken, registerString(name->name.toString()), value);
+ appendBinding(qualifiedNameLocation, name->identifierToken, registerString(name->name.toString()), value, parentNode);
qSwap(_object, object);
}
@@ -1242,7 +1245,8 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex,
qSwap(_object, object);
}
-void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value)
+void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
+ QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
{
Binding *binding = New<Binding>();
binding->propertyNameIndex = propertyNameIndex;
@@ -1250,7 +1254,7 @@ void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLo
binding->location.line = nameLocation.startLine;
binding->location.column = nameLocation.startColumn;
binding->flags = 0;
- setBindingValue(binding, value);
+ setBindingValue(binding, value, parentNode);
QString error = bindingsTarget()->appendBinding(binding, /*isListBinding*/false);
if (!error.isEmpty()) {
recordError(qualifiedNameLocation, error);
@@ -1547,68 +1551,105 @@ bool IRBuilder::isRedundantNullInitializerForPropertyDeclaration(Property *prope
return QQmlJS::AST::cast<QQmlJS::AST::NullExpression *>(expr);
}
-QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher)
+void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher)
{
+ output.jsGenerator.stringTable.registerString(output.jsModule.fileName);
+ output.jsGenerator.stringTable.registerString(output.jsModule.finalUrl);
+
QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = output.javaScriptCompilationUnit;
- QV4::CompiledData::Unit *jsUnit = compilationUnit->createUnitData(&output);
- const uint unitSize = jsUnit->unitSize;
- const int importSize = sizeof(QV4::CompiledData::Import) * output.imports.count();
- const int objectOffsetTableSize = output.objects.count() * sizeof(quint32);
+ const QV4::CompiledData::Unit *jsUnit = nullptr;
+ std::function<QV4::CompiledData::QmlUnit *(QV4::CompiledData::QmlUnit *, uint)> unitFinalizer
+ = [](QV4::CompiledData::QmlUnit *unit, uint) {
+ return unit;
+ };
+
+ // We may already have unit data if we're loading an ahead-of-time generated cache file.
+ if (compilationUnit->data) {
+ jsUnit = compilationUnit->data;
+#ifndef V4_BOOTSTRAP
+ output.javaScriptCompilationUnit->dynamicStrings = output.jsGenerator.stringTable.allStrings();
+#endif
+ } else {
+ QV4::CompiledData::Unit *createdUnit;
+ jsUnit = createdUnit = output.jsGenerator.generateUnit();
+
+ // enable flag if we encountered pragma Singleton
+ for (Pragma *p : qAsConst(output.pragmas)) {
+ if (p->type == Pragma::PragmaSingleton) {
+ createdUnit->flags |= QV4::CompiledData::Unit::IsSingleton;
+ break;
+ }
+ }
+ // This unit's memory was allocated with malloc on the heap, so it's
+ // definitely not suitable for StaticData access.
+ createdUnit->flags &= ~QV4::CompiledData::Unit::StaticData;
+
+#ifndef V4_BOOTSTRAP
+ if (dependencyHasher) {
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ if (dependencyHasher(&hash)) {
+ QByteArray checksum = hash.result();
+ Q_ASSERT(checksum.size() == sizeof(createdUnit->dependencyMD5Checksum));
+ memcpy(createdUnit->dependencyMD5Checksum, checksum.constData(), sizeof(createdUnit->dependencyMD5Checksum));
+ }
+ }
+#else
+ Q_UNUSED(dependencyHasher);
+#endif
+ createdUnit->sourceFileIndex = output.jsGenerator.stringTable.getStringId(output.jsModule.fileName);
+ createdUnit->finalUrlIndex = output.jsGenerator.stringTable.getStringId(output.jsModule.finalUrl);
+
+ // Combine the qml data into the general unit data.
+ unitFinalizer = [&jsUnit](QV4::CompiledData::QmlUnit *qmlUnit, uint qmlDataSize) {
+ void *ptr = const_cast<QV4::CompiledData::Unit*>(jsUnit);
+ QV4::CompiledData::Unit *newUnit = (QV4::CompiledData::Unit *)realloc(ptr, jsUnit->unitSize + qmlDataSize);
+ jsUnit = newUnit;
+ newUnit->offsetToQmlUnit = newUnit->unitSize;
+ newUnit->unitSize += qmlDataSize;
+ memcpy(const_cast<QV4::CompiledData::QmlUnit *>(newUnit->qmlUnit()), qmlUnit, qmlDataSize);
+ free(const_cast<QV4::CompiledData::QmlUnit*>(qmlUnit));
+ qmlUnit = nullptr;
+ newUnit->generateChecksum();
+ return const_cast<QV4::CompiledData::QmlUnit*>(newUnit->qmlUnit());
+ };
+ }
+
+ // No more new strings after this point, we're calculating offsets.
+ output.jsGenerator.stringTable.freeze();
+
+ const uint importSize = sizeof(QV4::CompiledData::Import) * output.imports.count();
+ const uint objectOffsetTableSize = output.objects.count() * sizeof(quint32);
QHash<const Object*, quint32> objectOffsets;
- int objectsSize = 0;
+ const unsigned int objectOffset = sizeof(QV4::CompiledData::QmlUnit) + importSize;
+ uint nextOffset = objectOffset + objectOffsetTableSize;
for (Object *o : qAsConst(output.objects)) {
- objectOffsets.insert(o, unitSize + importSize + objectOffsetTableSize + objectsSize);
- objectsSize += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count);
+ objectOffsets.insert(o, nextOffset);
+ nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count);
int signalTableSize = 0;
for (const Signal *s = o->firstSignal(); s; s = s->next)
signalTableSize += QV4::CompiledData::Signal::calculateSize(s->parameters->count);
- objectsSize += signalTableSize;
+ nextOffset += signalTableSize;
int enumTableSize = 0;
for (const Enum *e = o->firstEnum(); e; e = e->next)
enumTableSize += QV4::CompiledData::Enum::calculateSize(e->enumValues->count);
- objectsSize += enumTableSize;
+ nextOffset += enumTableSize;
}
- const int totalSize = unitSize + importSize + objectOffsetTableSize + objectsSize + output.jsGenerator.stringTable.sizeOfTableAndData();
+ const uint totalSize = nextOffset;
char *data = (char*)malloc(totalSize);
- memcpy(data, jsUnit, unitSize);
- memset(data + unitSize, 0, totalSize - unitSize);
- if (jsUnit != compilationUnit->data)
- free(jsUnit);
- jsUnit = nullptr;
-
- QV4::CompiledData::Unit *qmlUnit = reinterpret_cast<QV4::CompiledData::Unit *>(data);
- qmlUnit->unitSize = totalSize;
- qmlUnit->flags |= QV4::CompiledData::Unit::IsQml;
- // This unit's memory was allocated with malloc on the heap, so it's
- // definitely not suitable for StaticData access.
- qmlUnit->flags &= ~QV4::CompiledData::Unit::StaticData;
- qmlUnit->offsetToImports = unitSize;
+ memset(data, 0, totalSize);
+ QV4::CompiledData::QmlUnit *qmlUnit = reinterpret_cast<QV4::CompiledData::QmlUnit *>(data);
+ qmlUnit->offsetToImports = sizeof(*qmlUnit);
qmlUnit->nImports = output.imports.count();
- qmlUnit->offsetToObjects = unitSize + importSize;
+ qmlUnit->offsetToObjects = objectOffset;
qmlUnit->nObjects = output.objects.count();
- qmlUnit->offsetToStringTable = totalSize - output.jsGenerator.stringTable.sizeOfTableAndData();
- qmlUnit->stringTableSize = output.jsGenerator.stringTable.stringCount();
-
-#ifndef V4_BOOTSTRAP
- if (dependencyHasher) {
- QCryptographicHash hash(QCryptographicHash::Md5);
- if (dependencyHasher(&hash)) {
- QByteArray checksum = hash.result();
- Q_ASSERT(checksum.size() == sizeof(qmlUnit->dependencyMD5Checksum));
- memcpy(qmlUnit->dependencyMD5Checksum, checksum.constData(), sizeof(qmlUnit->dependencyMD5Checksum));
- }
- }
-#else
- Q_UNUSED(dependencyHasher);
-#endif
// write imports
char *importPtr = data + qmlUnit->offsetToImports;
@@ -1620,9 +1661,9 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, const QV4:
// write objects
quint32_le *objectTable = reinterpret_cast<quint32_le*>(data + qmlUnit->offsetToObjects);
- char *objectPtr = data + qmlUnit->offsetToObjects + objectOffsetTableSize;
for (int i = 0; i < output.objects.count(); ++i) {
const Object *o = output.objects.at(i);
+ char * const objectPtr = data + objectOffsets.value(o);
*objectTable++ = objectOffsets.value(o);
QV4::CompiledData::Object *objectToWrite = reinterpret_cast<QV4::CompiledData::Object*>(objectPtr);
@@ -1736,25 +1777,33 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, const QV4:
for (int i = 0; i < o->namedObjectsInComponent.count; ++i) {
*namedObjectInComponentPtr++ = o->namedObjectsInComponent.at(i);
}
-
- objectPtr += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count);
- objectPtr += signalTableSize;
- objectPtr += enumTableSize;
}
- // enable flag if we encountered pragma Singleton
- for (Pragma *p : qAsConst(output.pragmas)) {
- if (p->type == Pragma::PragmaSingleton) {
- qmlUnit->flags |= QV4::CompiledData::Unit::IsSingleton;
- break;
- }
- }
+ qmlUnit = unitFinalizer(qmlUnit, totalSize);
- output.jsGenerator.stringTable.serialize(qmlUnit);
-
- qmlUnit->generateChecksum();
+ static const bool showStats = qEnvironmentVariableIsSet("QML_SHOW_UNIT_STATS");
+ if (showStats) {
+ qDebug() << "Generated QML unit that is" << totalSize << "bytes big contains:";
+ qDebug() << " " << jsUnit->functionTableSize << "functions";
+ qDebug() << " " << jsUnit->unitSize << "for JS unit";
+ qDebug() << " " << importSize << "for imports";
+ qDebug() << " " << nextOffset - objectOffset - objectOffsetTableSize << "for" << qmlUnit->nObjects << "objects";
+ quint32 totalBindingCount = 0;
+ for (quint32 i = 0; i < qmlUnit->nObjects; ++i)
+ totalBindingCount += qmlUnit->objectAt(i)->nBindings;
+ qDebug() << " " << totalBindingCount << "bindings";
+ quint32 totalCodeSize = 0;
+ for (quint32 i = 0; i < jsUnit->functionTableSize; ++i)
+ totalCodeSize += jsUnit->functionAt(i)->codeSize;
+ qDebug() << " " << totalCodeSize << "bytes total byte code";
+ qDebug() << " " << jsUnit->stringTableSize << "strings";
+ quint32 totalStringSize = 0;
+ for (quint32 i = 0; i < jsUnit->stringTableSize; ++i)
+ totalStringSize += QV4::CompiledData::String::calculateSize(jsUnit->stringAtInternal(i));
+ qDebug() << " " << totalStringSize << "bytes total strings";
+ }
- return qmlUnit;
+ compilationUnit->setUnitData(jsUnit, qmlUnit, output.jsModule.fileName, output.jsModule.finalUrl);
}
char *QmlUnitGenerator::writeBindings(char *bindingPtr, const Object *o, BindingFilter filter) const
@@ -1806,24 +1855,36 @@ void JSCodeGen::beginObjectScope(QQmlPropertyCache *scopeObject)
QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions)
{
+ auto qmlName = [&](const CompiledFunctionOrExpression &c) {
+ if (c.nameIndex != 0)
+ return stringPool->stringForIndex(c.nameIndex);
+ else
+ return QStringLiteral("%qml-expression-entry");
+ };
QVector<int> runtimeFunctionIndices(functions.size());
- QV4::Compiler::ScanFunctions scan(this, sourceCode, QV4::Compiler::GlobalCode);
- scan.enterGlobalEnvironment(QV4::Compiler::QmlBinding);
+ QV4::Compiler::ScanFunctions scan(this, sourceCode, QV4::Compiler::ContextType::Global);
+ scan.enterGlobalEnvironment(QV4::Compiler::ContextType::Binding);
for (const CompiledFunctionOrExpression &f : functions) {
Q_ASSERT(f.node != qmlRoot);
+ Q_ASSERT(f.parentNode && f.parentNode != qmlRoot);
QQmlJS::AST::FunctionDeclaration *function = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(f.node);
- if (function)
+ if (function) {
scan.enterQmlFunction(function);
- else
- scan.enterEnvironment(f.node, QV4::Compiler::QmlBinding);
+ } else {
+ Q_ASSERT(f.node != f.parentNode);
+ scan.enterEnvironment(f.parentNode, QV4::Compiler::ContextType::Binding, qmlName(f));
+ }
scan(function ? function->body : f.node);
scan.leaveEnvironment();
}
scan.leaveEnvironment();
+ if (hasError)
+ return QVector<int>();
+
_context = nullptr;
for (int i = 0; i < functions.count(); ++i) {
@@ -1836,15 +1897,13 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil
QString name;
if (function)
name = function->name.toString();
- else if (qmlFunction.nameIndex != 0)
- name = stringPool->stringForIndex(qmlFunction.nameIndex);
else
- name = QStringLiteral("%qml-expression-entry");
+ name = qmlName(qmlFunction);
- QQmlJS::AST::SourceElements *body;
- if (function)
- body = function->body ? function->body->elements : nullptr;
- else {
+ QQmlJS::AST::StatementList *body;
+ if (function) {
+ body = function->body;
+ } else {
// Synthesize source elements.
QQmlJS::MemoryPool *pool = jsEngine->pool();
@@ -1854,13 +1913,12 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil
QQmlJS::AST::ExpressionNode *expr = node->expressionCast();
stmt = new (pool) QQmlJS::AST::ExpressionStatement(expr);
}
- QQmlJS::AST::SourceElement *element = new (pool) QQmlJS::AST::StatementSourceElement(stmt);
- body = new (pool) QQmlJS::AST::SourceElements(element);
+ body = new (pool) QQmlJS::AST::StatementList(stmt);
body = body->finish();
}
_disableAcceleratedLookups = qmlFunction.disableAcceleratedLookups;
- int idx = defineFunction(name, node,
+ int idx = defineFunction(name, function ? function : qmlFunction.parentNode,
function ? function->formals : nullptr,
body);
runtimeFunctionIndices[i] = idx;
@@ -1869,7 +1927,7 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil
return runtimeFunctionIndices;
}
-int JSCodeGen::defineFunction(const QString &name, AST::Node *ast, AST::FormalParameterList *formals, AST::SourceElements *body)
+int JSCodeGen::defineFunction(const QString &name, AST::Node *ast, AST::FormalParameterList *formals, AST::StatementList *body)
{
int qmlContextTemp = -1;
int importedScriptsTemp = -1;
@@ -2190,7 +2248,7 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n
// Look for IDs first.
for (const IdMapping &mapping : qAsConst(_idObjects)) {
if (name == mapping.name) {
- if (_context->compilationMode == QV4::Compiler::QmlBinding)
+ if (_context->contextType == QV4::Compiler::ContextType::Binding)
_context->idObjectDependencies.insert(mapping.idIndex);
Instruction::LoadIdObject load;
@@ -2221,42 +2279,38 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n
if (_scopeObject) {
QQmlPropertyData *data = lookupQmlCompliantProperty(_scopeObject, name);
- if (!data)
- return Reference::fromName(this, name);
-
- Reference base = Reference::fromStackSlot(this, _qmlContextSlot);
- Reference::PropertyCapturePolicy capturePolicy;
- if (!data->isConstant() && !data->isQmlBinding())
- capturePolicy = Reference::CaptureAtRuntime;
- else
- capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime;
- return Reference::fromQmlScopeObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy);
+ if (data) {
+ Reference base = Reference::fromStackSlot(this, _qmlContextSlot);
+ Reference::PropertyCapturePolicy capturePolicy;
+ if (!data->isConstant() && !data->isQmlBinding())
+ capturePolicy = Reference::CaptureAtRuntime;
+ else
+ capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime;
+ return Reference::fromQmlScopeObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy);
+ }
}
if (_contextObject) {
QQmlPropertyData *data = lookupQmlCompliantProperty(_contextObject, name);
- if (!data)
- return Reference::fromName(this, name);
-
- Reference base = Reference::fromStackSlot(this, _qmlContextSlot);
- Reference::PropertyCapturePolicy capturePolicy;
- if (!data->isConstant() && !data->isQmlBinding())
- capturePolicy = Reference::CaptureAtRuntime;
- else
- capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime;
- return Reference::fromQmlContextObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy);
+ if (data) {
+ Reference base = Reference::fromStackSlot(this, _qmlContextSlot);
+ Reference::PropertyCapturePolicy capturePolicy;
+ if (!data->isConstant() && !data->isQmlBinding())
+ capturePolicy = Reference::CaptureAtRuntime;
+ else
+ capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime;
+ return Reference::fromQmlContextObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy);
+ }
}
- if (m_globalNames.contains(name)) {
- Reference r = Reference::fromName(this, name);
+ Reference r = Reference::fromName(this, name);
+ if (m_globalNames.contains(name))
r.global = true;
- return r;
- }
+ return r;
#else
Q_UNUSED(name)
-#endif // V4_BOOTSTRAP
- // fall back to name lookup at run-time.
return Reference();
+#endif // V4_BOOTSTRAP
}
#ifndef V4_BOOTSTRAP
@@ -2317,12 +2371,12 @@ IRLoader::IRLoader(const QV4::CompiledData::Unit *qmlData, QmlIR::Document *outp
void IRLoader::load()
{
- output->jsGenerator.stringTable.clear();
- for (uint i = 0; i < unit->stringTableSize; ++i)
- output->jsGenerator.stringTable.registerString(unit->stringAt(i));
+ output->jsGenerator.stringTable.initializeFromBackingUnit(unit);
+
+ const QV4::CompiledData::QmlUnit *qmlUnit = unit->qmlUnit();
- for (quint32 i = 0; i < unit->nImports; ++i)
- output->imports << unit->importAt(i);
+ for (quint32 i = 0; i < qmlUnit->nImports; ++i)
+ output->imports << qmlUnit->importAt(i);
if (unit->flags & QV4::CompiledData::Unit::IsSingleton) {
QmlIR::Pragma *p = New<QmlIR::Pragma>();
@@ -2331,8 +2385,8 @@ void IRLoader::load()
output->pragmas << p;
}
- for (uint i = 0; i < unit->nObjects; ++i) {
- const QV4::CompiledData::Object *serializedObject = unit->objectAt(i);
+ for (uint i = 0; i < qmlUnit->nObjects; ++i) {
+ const QV4::CompiledData::Object *serializedObject = qmlUnit->objectAt(i);
QmlIR::Object *object = loadObject(serializedObject);
output->objects.append(object);
}
@@ -2446,8 +2500,6 @@ QmlIR::Object *IRLoader::loadObject(const QV4::CompiledData::Object *serializedO
}
}
- QQmlJS::Engine *jsParserEngine = &output->jsParserEngine;
-
const quint32_le *functionIdx = serializedObject->functionOffsetTable();
for (uint i = 0; i < serializedObject->nFunctions; ++i, ++functionIdx) {
QmlIR::Function *f = pool->New<QmlIR::Function>();
@@ -2458,26 +2510,10 @@ QmlIR::Object *IRLoader::loadObject(const QV4::CompiledData::Object *serializedO
f->location = compiledFunction->location;
f->nameIndex = compiledFunction->nameIndex;
- QQmlJS::AST::FormalParameterList *paramList = nullptr;
- const quint32_le *formalNameIdx = compiledFunction->formalsTable();
- for (uint i = 0; i < compiledFunction->nFormals; ++i, ++formalNameIdx) {
- const QString formal = unit->stringAt(*formalNameIdx);
- QStringRef paramNameRef = jsParserEngine->newStringRef(formal);
-
- if (paramList)
- paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, paramNameRef);
- else
- paramList = new (pool) QQmlJS::AST::FormalParameterList(paramNameRef);
- }
-
- if (paramList)
- paramList = paramList->finish();
-
- const QString name = unit->stringAt(compiledFunction->nameIndex);
- f->functionDeclaration = new(pool) QQmlJS::AST::FunctionDeclaration(jsParserEngine->newStringRef(name), paramList, /*body*/nullptr);
+ const QString name = unit->stringAtInternal(compiledFunction->nameIndex);
f->formals.allocate(pool, int(compiledFunction->nFormals));
- formalNameIdx = compiledFunction->formalsTable();
+ const quint32_le *formalNameIdx = compiledFunction->formalsTable();
for (uint i = 0; i < compiledFunction->nFormals; ++i, ++formalNameIdx)
f->formals[i] = *formalNameIdx;
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index 689b232b1c..d1e2b17bb7 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -57,7 +57,6 @@
#include <private/qqmljsmemorypool_p.h>
#include <private/qv4codegen_p.h>
#include <private/qv4compiler_p.h>
-#include <private/qqmljslexer_p.h>
#include <QTextStream>
#include <QCoreApplication>
@@ -325,7 +324,6 @@ struct Alias : public QV4::CompiledData::Alias
struct Function
{
- QQmlJS::AST::FunctionDeclaration *functionDeclaration;
QV4::CompiledData::Location location;
int nameIndex;
quint32 index; // index in parsedQML::functions
@@ -342,12 +340,9 @@ struct Function
struct Q_QML_PRIVATE_EXPORT CompiledFunctionOrExpression
{
CompiledFunctionOrExpression()
-
{}
- CompiledFunctionOrExpression(QQmlJS::AST::Node *n)
- : node(n)
- {}
+ QQmlJS::AST::Node *parentNode = nullptr; // FunctionDeclaration, Statement or Expression
QQmlJS::AST::Node *node = nullptr; // FunctionDeclaration, Statement or Expression
quint32 nameIndex = 0;
bool disableAcceleratedLookups = false;
@@ -400,8 +395,6 @@ public:
void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &location = QQmlJS::AST::SourceLocation());
- QString sanityCheckFunctionNames(const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation);
-
QString appendEnum(Enum *enumeration);
QString appendSignal(Signal *signal);
QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
@@ -520,12 +513,12 @@ public:
QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first,
const QQmlJS::AST::SourceLocation &last) const;
- void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement);
+ void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, AST::Node *parentNode);
void tryGeneratingTranslationBinding(const QStringRef &base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding);
- void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value);
+ void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, AST::Node *parentNode);
void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false);
- void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value);
+ void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value, AST::Node *parentNode);
void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem = false, bool isOnAssignment = false);
bool appendAlias(QQmlJS::AST::UiPublicMember *node);
@@ -548,6 +541,8 @@ public:
static bool isStatementNodeScript(QQmlJS::AST::Statement *statement);
static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement);
+ QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation);
+
QList<QQmlJS::DiagnosticMessage> errors;
QSet<QString> illegalNames;
@@ -568,7 +563,7 @@ public:
struct Q_QML_PRIVATE_EXPORT QmlUnitGenerator
{
- QV4::CompiledData::Unit *generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher = QV4::CompiledData::DependentTypesHasher());
+ void generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher = QV4::CompiledData::DependentTypesHasher());
private:
typedef bool (Binding::*BindingFilter)() const;
@@ -578,7 +573,7 @@ private:
#ifndef V4_BOOTSTRAP
struct Q_QML_EXPORT PropertyResolver
{
- PropertyResolver(const QQmlPropertyCache *cache)
+ PropertyResolver(const QQmlRefPointer<QQmlPropertyCache> &cache)
: cache(cache)
{}
@@ -597,7 +592,7 @@ struct Q_QML_EXPORT PropertyResolver
// This code must match the semantics of QQmlPropertyPrivate::findSignalByName
QQmlPropertyData *signal(const QString &name, bool *notInRevision) const;
- const QQmlPropertyCache *cache;
+ QQmlRefPointer<QQmlPropertyCache> cache;
};
#endif
@@ -623,7 +618,7 @@ struct Q_QML_PRIVATE_EXPORT JSCodeGen : public QV4::Compiler::Codegen
int defineFunction(const QString &name, AST::Node *ast,
AST::FormalParameterList *formals,
- AST::SourceElements *body) override;
+ AST::StatementList *body) override;
protected:
void beginFunctionBodyHook() override;
diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h
index 8bbc8291b4..02517ea6bb 100644
--- a/src/qml/compiler/qqmlpropertycachecreator_p.h
+++ b/src/qml/compiler/qqmlpropertycachecreator_p.h
@@ -99,8 +99,8 @@ public:
protected:
QQmlCompileError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context);
- QQmlPropertyCache *propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const;
- QQmlCompileError createMetaObject(int objectIndex, const CompiledObject *obj, QQmlPropertyCache *baseTypeCache);
+ QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const;
+ QQmlCompileError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
QString stringAt(int index) const { return objectContainer->stringAt(index); }
@@ -152,7 +152,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje
const CompiledObject *obj = objectContainer->objectAt(context.referencingObjectIndex);
auto *typeRef = objectContainer->resolvedTypes.value(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
- QQmlPropertyCache *baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
+ QQmlRefPointer<QQmlPropertyCache> baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
QQmlCompileError error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
if (error.isSet())
return error;
@@ -166,7 +166,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje
}
}
- QQmlPropertyCache *baseTypeCache;
+ QQmlRefPointer<QQmlPropertyCache> baseTypeCache;
{
QQmlCompileError error;
baseTypeCache = propertyCacheForObject(obj, context, &error);
@@ -209,7 +209,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje
}
template <typename ObjectContainer>
-inline QQmlPropertyCache *QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const
+inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const
{
if (context.instantiatingProperty) {
return context.instantiatingPropertyCache(enginePrivate);
@@ -241,14 +241,12 @@ inline QQmlPropertyCache *QQmlPropertyCacheCreator<ObjectContainer>::propertyCac
QString propertyName = stringAt(context.instantiatingBinding->propertyNameIndex);
if (imports->resolveType(propertyName, &qmltype, nullptr, nullptr, nullptr)) {
if (qmltype.isComposite()) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
+ QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
auto compilationUnit = tdata->compilationUnit();
qmltype = QQmlMetaType::qmlType(compilationUnit->metaTypeId);
-
- tdata->release();
}
}
}
@@ -264,7 +262,7 @@ inline QQmlPropertyCache *QQmlPropertyCacheCreator<ObjectContainer>::propertyCac
}
template <typename ObjectContainer>
-inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, QQmlPropertyCache *baseTypeCache)
+inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
{
QQmlRefPointer<QQmlPropertyCache> cache;
cache.adopt(baseTypeCache->copyAndReserve(obj->propertyCount() + obj->aliasCount(),
@@ -314,7 +312,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
}
}
if (newClassName.isEmpty()) {
- newClassName = QQmlMetaObject(baseTypeCache).className();
+ newClassName = QQmlMetaObject(baseTypeCache.data()).className();
newClassName.append("_QML_");
newClassName.append(QByteArray::number(classIndexCounter.fetchAndAddRelaxed(1)));
}
@@ -354,7 +352,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
// and throw an error if there is a signal/method defined as an override.
QSet<QString> seenSignals;
seenSignals << QStringLiteral("destroyed") << QStringLiteral("parentChanged") << QStringLiteral("objectNameChanged");
- QQmlPropertyCache *parentCache = cache;
+ QQmlPropertyCache *parentCache = cache.data();
while ((parentCache = parentCache->parent())) {
if (int pSigCount = parentCache->signalCount()) {
int pSigOffset = parentCache->signalOffset();
@@ -440,15 +438,13 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
return QQmlCompileError(s->location, QQmlPropertyCacheCreatorBase::tr("Invalid signal parameter type: %1").arg(customTypeName));
if (qmltype.isComposite()) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
+ QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
auto compilationUnit = tdata->compilationUnit();
paramTypes[i + 1] = compilationUnit->metaTypeId;
-
- tdata->release();
} else {
paramTypes[i + 1] = qmltype.typeId();
}
@@ -523,7 +519,7 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
Q_ASSERT(qmltype.isValid());
if (qmltype.isComposite()) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
+ QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
@@ -534,8 +530,6 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
} else {
propertyType = compilationUnit->listMetaTypeId;
}
-
- tdata->release();
} else {
if (p->type == QV4::CompiledData::Property::Custom) {
propertyType = qmltype.typeId();
diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp
index ffd3b5975a..4cb922ca8d 100644
--- a/src/qml/compiler/qqmlpropertyvalidator.cpp
+++ b/src/qml/compiler/qqmlpropertyvalidator.cpp
@@ -45,15 +45,16 @@
QT_BEGIN_NAMESPACE
-QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, QV4::CompiledData::CompilationUnit *compilationUnit)
+QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
: enginePrivate(enginePrivate)
+ , compilationUnit(compilationUnit)
, imports(imports)
- , qmlUnit(compilationUnit->data)
+ , qmlUnit(compilationUnit->unitData())
, resolvedTypes(compilationUnit->resolvedTypes)
, propertyCaches(compilationUnit->propertyCaches)
, bindingPropertyDataPerObject(&compilationUnit->bindingPropertyDataPerObject)
{
- bindingPropertyDataPerObject->resize(qmlUnit->nObjects);
+ bindingPropertyDataPerObject->resize(compilationUnit->objectCount());
}
QVector<QQmlCompileError> QQmlPropertyValidator::validate()
@@ -81,7 +82,7 @@ struct BindingFinder
QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty) const
{
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(objectIndex);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(objectIndex);
if (obj->flags & QV4::CompiledData::Object::IsComponent) {
Q_ASSERT(obj->nBindings == 1);
@@ -305,7 +306,7 @@ QVector<QQmlCompileError> QQmlPropertyValidator::validateObject(int objectIndex,
customParser->validator = this;
customParser->engine = enginePrivate;
customParser->imports = &imports;
- customParser->verifyBindings(qmlUnit, customBindings);
+ customParser->verifyBindings(compilationUnit, customBindings);
customParser->validator = nullptr;
customParser->engine = nullptr;
customParser->imports = (QQmlImports*)nullptr;
@@ -332,7 +333,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum)
return noError;
- QString value = binding->valueAsString(qmlUnit);
+ QString value = binding->valueAsString(compilationUnit.data());
QMetaProperty p = propertyCache->firstCppMetaObject()->property(property->coreIndex());
bool ok;
if (p.isFlagType()) {
@@ -375,7 +376,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::UInt: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
- double d = binding->valueAsNumber();
+ double d = binding->valueAsNumber(compilationUnit->constants);
if (double(uint(d)) == d)
return noError;
}
@@ -384,7 +385,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::Int: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
- double d = binding->valueAsNumber();
+ double d = binding->valueAsNumber(compilationUnit->constants);
if (double(int(d)) == d)
return noError;
}
@@ -405,7 +406,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::Color: {
bool ok = false;
- QQmlStringConverters::rgbaFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::rgbaFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: color expected"));
}
@@ -414,7 +415,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
#if QT_CONFIG(datestring)
case QVariant::Date: {
bool ok = false;
- QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::dateFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: date expected"));
}
@@ -422,7 +423,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::Time: {
bool ok = false;
- QQmlStringConverters::timeFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::timeFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: time expected"));
}
@@ -430,7 +431,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::DateTime: {
bool ok = false;
- QQmlStringConverters::dateTimeFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::dateTimeFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: datetime expected"));
}
@@ -439,7 +440,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
#endif // datestring
case QVariant::Point: {
bool ok = false;
- QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
}
@@ -447,7 +448,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::PointF: {
bool ok = false;
- QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
}
@@ -455,7 +456,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::Size: {
bool ok = false;
- QQmlStringConverters::sizeFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: size expected"));
}
@@ -463,7 +464,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::SizeF: {
bool ok = false;
- QQmlStringConverters::sizeFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: size expected"));
}
@@ -471,7 +472,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::Rect: {
bool ok = false;
- QQmlStringConverters::rectFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: rect expected"));
}
@@ -479,7 +480,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
break;
case QVariant::RectF: {
bool ok = false;
- QQmlStringConverters::rectFFromString(binding->valueAsString(qmlUnit), &ok);
+ QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
}
@@ -496,7 +497,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float xp;
float yp;
} vec;
- if (!QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(qmlUnit), &vec, sizeof(vec))) {
+ if (!QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 2D vector expected"));
}
}
@@ -507,7 +508,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float yp;
float zy;
} vec;
- if (!QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(qmlUnit), &vec, sizeof(vec))) {
+ if (!QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 3D vector expected"));
}
}
@@ -519,7 +520,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float zy;
float wp;
} vec;
- if (!QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(qmlUnit), &vec, sizeof(vec))) {
+ if (!QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 4D vector expected"));
}
}
@@ -531,7 +532,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float yp;
float zp;
} vec;
- if (!QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(qmlUnit), &vec, sizeof(vec))) {
+ if (!QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: quaternion expected"));
}
}
@@ -548,7 +549,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
} else if (property->propType() == qMetaTypeId<QList<int> >()) {
bool ok = (binding->type == QV4::CompiledData::Binding::Type_Number);
if (ok) {
- double n = binding->valueAsNumber();
+ double n = binding->valueAsNumber(compilationUnit->constants);
if (double(int(n)) != n)
ok = false;
}
@@ -627,9 +628,9 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *
bool isValueSource = false;
bool isPropertyInterceptor = false;
- const QV4::CompiledData::Object *targetObject = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *targetObject = compilationUnit->objectAt(binding->value.objectIndex);
if (auto *typeRef = resolvedTypes.value(targetObject->inheritedTypeNameIndex)) {
- QQmlPropertyCache *cache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
+ QQmlRefPointer<QQmlPropertyCache> cache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
const QMetaObject *mo = cache->firstCppMetaObject();
QQmlType qmlType;
while (mo && !qmlType.isValid()) {
@@ -665,12 +666,12 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *
}
}
return noError;
- } else if (qmlUnit->objectAt(binding->value.objectIndex)->flags & QV4::CompiledData::Object::IsComponent) {
+ } else if (compilationUnit->objectAt(binding->value.objectIndex)->flags & QV4::CompiledData::Object::IsComponent) {
return noError;
} else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) {
return noError;
} else if (QQmlValueTypeFactory::isValueType(property->propType())) {
- return QQmlCompileError(binding->location, tr("Unexpected object assignment"));
+ return QQmlCompileError(binding->location, tr("Unexpected object assignment for property \"%1\"").arg(propertyName));
} else if (property->propType() == qMetaTypeId<QQmlScriptString>()) {
return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: script expected"));
} else {
@@ -680,7 +681,7 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *
// Using -1 for the minor version ensures that we get the raw metaObject.
QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(property->propType(), -1);
- // Will be true if the assgned type inherits propertyMetaObject
+ // Will be true if the assigned type inherits propertyMetaObject
bool isAssignable = false;
// Determine isAssignable value
if (propertyMetaObject) {
@@ -692,7 +693,8 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *
}
if (!isAssignable) {
- return QQmlCompileError(binding->valueLocation, tr("Cannot assign object to property"));
+ return QQmlCompileError(binding->valueLocation, tr("Cannot assign object of type \"%1\" to property of type \"%2\" as the former is neither the same as the latter nor a sub-class of it.")
+ .arg(stringAt(compilationUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex)).arg(QLatin1String(QMetaType::typeName(property->propType()))));
}
}
return noError;
diff --git a/src/qml/compiler/qqmlpropertyvalidator_p.h b/src/qml/compiler/qqmlpropertyvalidator_p.h
index e37b8141f4..67a2f989af 100644
--- a/src/qml/compiler/qqmlpropertyvalidator_p.h
+++ b/src/qml/compiler/qqmlpropertyvalidator_p.h
@@ -58,7 +58,7 @@ class QQmlPropertyValidator
{
Q_DECLARE_TR_FUNCTIONS(QQmlPropertyValidator)
public:
- QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, QV4::CompiledData::CompilationUnit *compilationUnit);
+ QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
QVector<QQmlCompileError> validate();
@@ -71,9 +71,10 @@ private:
Q_REQUIRED_RESULT QVector<QQmlCompileError> recordError(const QV4::CompiledData::Location &location, const QString &description) const;
Q_REQUIRED_RESULT QVector<QQmlCompileError> recordError(const QQmlCompileError &error) const;
- QString stringAt(int index) const { return qmlUnit->stringAt(index); }
+ QString stringAt(int index) const { return compilationUnit->stringAt(index); }
QQmlEnginePrivate *enginePrivate;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit;
const QQmlImports &imports;
const QV4::CompiledData::Unit *qmlUnit;
const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypes;
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index a896745b3f..a03f69576d 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -44,8 +44,7 @@
#include <private/qqmlcustomparser_p.h>
#include <private/qqmlvmemetaobject_p.h>
#include <private/qqmlcomponent_p.h>
-
-//#include "qv4jssimplifier_p.h"
+#include <private/qqmldelegatecomponent_p.h>
#define COMPILE_EXCEPTION(token, desc) \
{ \
@@ -67,7 +66,7 @@ QQmlTypeCompiler::QQmlTypeCompiler(QQmlEnginePrivate *engine, QQmlTypeData *type
{
}
-QV4::CompiledData::CompilationUnit *QQmlTypeCompiler::compile()
+QQmlRefPointer<QV4::CompiledData::CompilationUnit> QQmlTypeCompiler::compile()
{
// Build property caches and VME meta object data
@@ -135,8 +134,8 @@ QV4::CompiledData::CompilationUnit *QQmlTypeCompiler::compile()
return nullptr;
}
- // Compile JS binding expressions and signal handlers
if (!document->javaScriptCompilationUnit) {
+ // Compile JS binding expressions and signal handlers if necessary
{
// We can compile script strings ahead of time, but they must be compiled
// without type optimizations as their scope is always entirely dynamic.
@@ -147,7 +146,7 @@ QV4::CompiledData::CompilationUnit *QQmlTypeCompiler::compile()
document->jsModule.fileName = typeData->urlString();
document->jsModule.finalUrl = typeData->finalUrlString();
QmlIR::JSCodeGen v4CodeGenerator(document->code, &document->jsGenerator, &document->jsModule, &document->jsParserEngine,
- document->program, typeNameCache, &document->jsGenerator.stringTable, engine->v8engine()->illegalNames());
+ document->program, typeNameCache.data(), &document->jsGenerator.stringTable, engine->v8engine()->illegalNames());
v4CodeGenerator.setUseFastLookups(false);
QQmlJSCodeGenerator jsCodeGen(this, &v4CodeGenerator);
if (!jsCodeGen.generateCodeForComponents())
@@ -159,18 +158,14 @@ QV4::CompiledData::CompilationUnit *QQmlTypeCompiler::compile()
// Generate QML compiled type data structures
QmlIR::QmlUnitGenerator qmlGenerator;
- QV4::CompiledData::Unit *qmlUnit = qmlGenerator.generate(*document, dependencyHasher);
-
- Q_ASSERT(document->javaScriptCompilationUnit);
- // The js unit owns the data and will free the qml unit.
- document->javaScriptCompilationUnit->data = qmlUnit;
+ qmlGenerator.generate(*document, dependencyHasher);
- QV4::CompiledData::CompilationUnit *compilationUnit = document->javaScriptCompilationUnit;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = document->javaScriptCompilationUnit;
compilationUnit = document->javaScriptCompilationUnit;
compilationUnit->typeNameCache = typeNameCache;
compilationUnit->resolvedTypes = resolvedTypes;
compilationUnit->propertyCaches = std::move(m_propertyCaches);
- Q_ASSERT(compilationUnit->propertyCaches.count() == static_cast<int>(compilationUnit->data->nObjects));
+ Q_ASSERT(compilationUnit->propertyCaches.count() == static_cast<int>(compilationUnit->objectCount()));
if (errors.isEmpty())
return compilationUnit;
@@ -209,9 +204,14 @@ int QQmlTypeCompiler::registerString(const QString &str)
return document->jsGenerator.registerString(str);
}
+int QQmlTypeCompiler::registerConstant(QV4::ReturnedValue v)
+{
+ return document->jsGenerator.registerConstant(v);
+}
+
const QV4::CompiledData::Unit *QQmlTypeCompiler::qmlUnit() const
{
- return document->javaScriptCompilationUnit->data;
+ return document->javaScriptCompilationUnit->unitData();
}
const QQmlImports *QQmlTypeCompiler::imports() const
@@ -339,14 +339,12 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
if (!type.isValid()) {
if (imports->resolveType(propertyName, &type, nullptr, nullptr, nullptr)) {
if (type.isComposite()) {
- QQmlTypeData *tdata = enginePrivate->typeLoader.getType(type.sourceUrl());
+ QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(type.sourceUrl());
Q_ASSERT(tdata);
Q_ASSERT(tdata->isComplete());
auto compilationUnit = tdata->compilationUnit();
type = QQmlMetaType::qmlType(compilationUnit->metaTypeId);
-
- tdata->release();
}
}
}
@@ -466,14 +464,12 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
for (const QString &param : qAsConst(parameters)) {
QStringRef paramNameRef = compiler->newStringRef(param);
- if (paramList)
- paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, paramNameRef);
- else
- paramList = new (pool) QQmlJS::AST::FormalParameterList(paramNameRef);
+ QQmlJS::AST::PatternElement *b = new (pool) QQmlJS::AST::PatternElement(paramNameRef, nullptr);
+ paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, b);
}
if (paramList)
- paramList = paramList->finish();
+ paramList = paramList->finish(pool);
QmlIR::CompiledFunctionOrExpression *foe = obj->functionsAndExpressions->slowAt(binding->value.compiledScriptIndex);
QQmlJS::AST::FunctionDeclaration *functionDeclaration = nullptr;
@@ -490,11 +486,8 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
}
if (!functionDeclaration) {
QQmlJS::AST::Statement *statement = static_cast<QQmlJS::AST::Statement*>(foe->node);
- QQmlJS::AST::SourceElement *sourceElement = new (pool) QQmlJS::AST::StatementSourceElement(statement);
- QQmlJS::AST::SourceElements *elements = new (pool) QQmlJS::AST::SourceElements(sourceElement);
- elements = elements->finish();
-
- QQmlJS::AST::FunctionBody *body = new (pool) QQmlJS::AST::FunctionBody(elements);
+ QQmlJS::AST::StatementList *body = new (pool) QQmlJS::AST::StatementList(statement);
+ body = body->finish();
functionDeclaration = new (pool) QQmlJS::AST::FunctionDeclaration(compiler->newStringRef(stringAt(binding->propertyNameIndex)), paramList, body);
functionDeclaration->lbraceToken = functionDeclaration->functionToken
@@ -564,7 +557,8 @@ bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, const QS
COMPILE_EXCEPTION(binding, tr("Invalid property assignment: Enum value \"%1\" cannot start with a lowercase letter").arg(enumName.toString()));
}
binding->type = QV4::CompiledData::Binding::Type_Number;
- binding->setNumberValueInternal((double)enumValue);
+ binding->value.constantValueIndex = compiler->registerConstant(QV4::Encode((double)enumValue));
+// binding->setNumberValueInternal((double)enumValue);
binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum;
return true;
}
@@ -811,13 +805,21 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
const QmlIR::Object *targetObject = qmlObjects->at(binding->value.objectIndex);
auto *tr = resolvedTypes->value(targetObject->inheritedTypeNameIndex);
Q_ASSERT(tr);
- if (tr->type.isValid()) {
- if (tr->type.metaObject() == &QQmlComponent::staticMetaObject)
- continue;
- } else if (tr->compilationUnit) {
- if (tr->compilationUnit->rootPropertyCache()->firstCppMetaObject() == &QQmlComponent::staticMetaObject)
- continue;
- }
+
+ const QMetaObject *firstMetaObject = nullptr;
+ if (tr->type.isValid())
+ firstMetaObject = tr->type.metaObject();
+ else if (tr->compilationUnit)
+ firstMetaObject = tr->compilationUnit->rootPropertyCache()->firstCppMetaObject();
+ // 1: test for QQmlComponent
+ if (firstMetaObject && firstMetaObject == &QQmlComponent::staticMetaObject)
+ continue;
+ // 2: test for QQmlAbstractDelegateComponent
+ while (firstMetaObject && firstMetaObject != &QQmlAbstractDelegateComponent::staticMetaObject)
+ firstMetaObject = firstMetaObject->superClass();
+ if (firstMetaObject)
+ continue;
+ // if here, not a QQmlComponent or a QQmlAbstractDelegateComponent, so needs wrapping
QQmlPropertyData *pd = nullptr;
if (binding->propertyNameIndex != quint32(0)) {
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index b8eddcb9b2..ffe04eb090 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -92,7 +92,7 @@ public:
QV4::CompiledData::ResolvedTypeReferenceMap resolvedTypes;
// ---
- QV4::CompiledData::CompilationUnit *compile();
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compile();
QList<QQmlError> compilationErrors() const { return errors; }
void recordError(QQmlError error);
@@ -100,6 +100,7 @@ public:
void recordError(const QQmlCompileError &error);
int registerString(const QString &str);
+ int registerConstant(QV4::ReturnedValue v);
const QV4::CompiledData::Unit *qmlUnit() const;
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index 4d50654d27..8ecb762f9c 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -70,14 +70,14 @@ int BytecodeGenerator::newRegisterArray(int n)
void BytecodeGenerator::packInstruction(I &i)
{
- uchar type = *reinterpret_cast<uchar *>(i.packed);
- Q_ASSERT(type >= MOTH_NUM_INSTRUCTIONS());
- if (type >= MOTH_NUM_INSTRUCTIONS())
- type -= MOTH_NUM_INSTRUCTIONS();
+ Instr::Type type = Instr::unpack(i.packed);
+ Q_ASSERT(int(type) < MOTH_NUM_INSTRUCTIONS());
+ type = Instr::narrowInstructionType(type);
int instructionsAsInts[sizeof(Instr)/sizeof(int)] = {};
int nMembers = Moth::InstrInfo::argumentCount[static_cast<int>(i.type)];
+ uchar *code = i.packed + Instr::encodedLength(type);
for (int j = 0; j < nMembers; ++j) {
- instructionsAsInts[j] = qFromLittleEndian<qint32>(i.packed + 1 + j * sizeof(int));
+ instructionsAsInts[j] = qFromLittleEndian<qint32>(code + j * sizeof(int));
}
enum {
Normal,
@@ -89,11 +89,10 @@ void BytecodeGenerator::packInstruction(I &i)
break;
}
}
- char *code = i.packed;
+ code = i.packed;
switch (width) {
case Normal:
- *reinterpret_cast<uchar *>(code) = type;
- ++code;
+ code = Instr::pack(code, type);
for (int n = 0; n < nMembers; ++n) {
qint8 v = static_cast<qint8>(instructionsAsInts[n]);
memcpy(code, &v, 1);
@@ -121,8 +120,8 @@ void BytecodeGenerator::adjustJumpOffsets()
int jumpOffset = linkedInstruction.position - (i.position + i.size);
// qDebug() << "adjusting jump offset for instruction" << index << i.position << i.size << "offsetForJump" << i.offsetForJump << "target"
// << labels.at(i.linkedLabel) << linkedInstruction.position << "jumpOffset" << jumpOffset;
- uchar type = *reinterpret_cast<const uchar *>(i.packed);
- if (type >= MOTH_NUM_INSTRUCTIONS()) {
+ Instr::Type type = Instr::unpack(i.packed);
+ if (Instr::isWide(type)) {
Q_ASSERT(i.offsetForJump == i.size - 4);
qToLittleEndian<qint32>(jumpOffset, c);
} else {
@@ -177,7 +176,7 @@ void BytecodeGenerator::finalize(Compiler::Context *context)
entry.line = currentLine;
lineNumbers.append(entry);
}
- code.append(i.packed, i.size);
+ code.append(reinterpret_cast<const char *>(i.packed), i.size);
}
context->code = code;
@@ -185,6 +184,25 @@ void BytecodeGenerator::finalize(Compiler::Context *context)
}
int BytecodeGenerator::addInstructionHelper(Instr::Type type, const Instr &i, int offsetOfOffset) {
+ if (lastInstrType == int(Instr::Type::StoreReg)) {
+ if (type == Instr::Type::LoadReg) {
+ if (i.LoadReg.reg == lastInstr.StoreReg.reg) {
+ // value is already in the accumulator
+ return -1;
+ }
+ }
+ if (type == Instr::Type::MoveReg) {
+ if (i.MoveReg.srcReg == lastInstr.StoreReg.reg) {
+ Instruction::StoreReg store;
+ store.reg = i.MoveReg.destReg;
+ addInstruction(store);
+ return -1;
+ }
+ }
+ }
+ lastInstrType = int(type);
+ lastInstr = i;
+
#if QT_CONFIG(qml_debug)
if (debugMode && type != Instr::Type::Debug) {
QT_WARNING_PUSH
@@ -207,12 +225,10 @@ QT_WARNING_POP
const int argCount = Moth::InstrInfo::argumentCount[static_cast<int>(type)];
int s = argCount*sizeof(int);
if (offsetOfOffset != -1)
- offsetOfOffset += 1;
- I instr{type, static_cast<short>(s + 1), 0, currentLine, offsetOfOffset, -1, "\0\0" };
- char *code = instr.packed;
- *reinterpret_cast<uchar *>(code) = static_cast<uchar>(MOTH_NUM_INSTRUCTIONS() + static_cast<int>(type));
- ++code;
- Q_ASSERT(MOTH_NUM_INSTRUCTIONS() + static_cast<int>(type) < 256);
+ offsetOfOffset += Instr::encodedLength(type);
+ I instr{type, static_cast<short>(s + Instr::encodedLength(type)), 0, currentLine, offsetOfOffset, -1, "\0\0" };
+ uchar *code = instr.packed;
+ code = Instr::pack(code, Instr::wideInstructionType(type));
for (int j = 0; j < argCount; ++j) {
qToLittleEndian<qint32>(i.argumentsAsInts[j], code);
diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h
index e69f2cd310..4f3dc27acc 100644
--- a/src/qml/compiler/qv4bytecodegenerator_p.h
+++ b/src/qml/compiler/qv4bytecodegenerator_p.h
@@ -77,22 +77,18 @@ public:
Label(BytecodeGenerator *generator, LinkMode mode = LinkNow)
: generator(generator),
index(generator->labels.size()) {
- generator->labels.append(mode == LinkNow ? generator->instructions.size() : -1);
- }
- static Label returnLabel() {
- Label l;
- l.index = INT_MAX;
- return l;
- }
- bool isReturn() const {
- return index == INT_MAX;
+ generator->labels.append(-1);
+ if (mode == LinkNow)
+ link();
}
void link() {
Q_ASSERT(index >= 0);
Q_ASSERT(generator->labels[index] == -1);
generator->labels[index] = generator->instructions.size();
+ generator->clearLastInstruction();
}
+ bool isValid() const { return generator != nullptr; }
BytecodeGenerator *generator = nullptr;
int index = -1;
@@ -133,14 +129,16 @@ public:
};
struct ExceptionHandler : public Label {
+ ExceptionHandler() = default;
ExceptionHandler(BytecodeGenerator *generator)
: Label(generator, LinkLater)
{
}
~ExceptionHandler()
{
- Q_ASSERT(generator->currentExceptionHandler != this);
+ Q_ASSERT(!generator || generator->currentExceptionHandler != this);
}
+ bool isValid() const { return generator != nullptr; }
};
Label label() {
@@ -165,8 +163,11 @@ public:
Q_REQUIRED_RESULT Jump jump()
{
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // broken gcc warns about Instruction::Debug()
Instruction::Jump data;
return addJumpInstruction(data);
+QT_WARNING_POP
}
Q_REQUIRED_RESULT Jump jumpTrue()
@@ -181,6 +182,18 @@ public:
return addJumpInstruction(data);
}
+ Q_REQUIRED_RESULT Jump jumpNotUndefined()
+ {
+ Instruction::JumpNotUndefined data;
+ return addJumpInstruction(data);
+ }
+
+ Q_REQUIRED_RESULT Jump jumpNoException()
+ {
+ Instruction::JumpNoException data;
+ return addJumpInstruction(data);
+ }
+
void jumpStrictEqual(const StackSlot &lhs, const Label &target)
{
Instruction::CmpStrictEqual cmp;
@@ -197,26 +210,10 @@ public:
addJumpInstruction(Instruction::JumpTrue()).link(target);
}
- Q_REQUIRED_RESULT Jump jumpStrictEqualStackSlotInt(const StackSlot &lhs, int rhs)
- {
- Instruction::JumpStrictEqualStackSlotInt data;
- data.lhs = lhs;
- data.rhs = rhs;
- return addJumpInstruction(data);
- }
-
- Q_REQUIRED_RESULT Jump jumpStrictNotEqualStackSlotInt(const StackSlot &lhs, int rhs)
- {
- Instruction::JumpStrictNotEqualStackSlotInt data;
- data.lhs = lhs;
- data.rhs = rhs;
- return addJumpInstruction(data);
- }
-
- void setExceptionHandler(ExceptionHandler *handler)
+ void setUnwindHandler(ExceptionHandler *handler)
{
currentExceptionHandler = handler;
- Instruction::SetExceptionHandler data;
+ Instruction::SetUnwindHandler data;
data.offset = 0;
if (!handler)
addInstruction(data);
@@ -224,6 +221,19 @@ public:
addJumpInstruction(data).link(*handler);
}
+ void unwindToLabel(int level, const Label &target)
+ {
+ if (level) {
+ Instruction::UnwindToLabel unwind;
+ unwind.level = level;
+ addJumpInstruction(unwind).link(target);
+ } else {
+ jump().link(target);
+ }
+ }
+
+
+
void setLocation(const QQmlJS::AST::SourceLocation &loc);
ExceptionHandler *exceptionHandler() const {
@@ -233,6 +243,7 @@ public:
int newRegister();
int newRegisterArray(int n);
int registerCount() const { return regCount; }
+ int currentRegister() const { return currentReg; }
void finalize(Compiler::Context *context);
@@ -252,6 +263,11 @@ public:
addJumpInstruction(Instruction::JumpTrue()).link(*trueLabel);
}
+ void clearLastInstruction()
+ {
+ lastInstrType = -1;
+ }
+
private:
friend struct Jump;
friend struct Label;
@@ -266,7 +282,7 @@ private:
int line;
int offsetForJump;
int linkedLabel;
- char packed[sizeof(Instr) + 2]; // 2 for instruction and prefix
+ unsigned char packed[sizeof(Instr) + 2]; // 2 for instruction type
};
void compressInstructions();
@@ -275,7 +291,7 @@ private:
QVector<I> instructions;
QVector<int> labels;
- ExceptionHandler *currentExceptionHandler;
+ ExceptionHandler *currentExceptionHandler = nullptr;
int regCount = 0;
public:
int currentReg = 0;
@@ -283,6 +299,9 @@ private:
int startLine = 0;
int currentLine = 0;
bool debugMode = false;
+
+ int lastInstrType = -1;
+ Moth::Instr lastInstr;
};
}
diff --git a/src/qml/compiler/qv4bytecodehandler.cpp b/src/qml/compiler/qv4bytecodehandler.cpp
new file mode 100644
index 0000000000..65293becfd
--- /dev/null
+++ b/src/qml/compiler/qv4bytecodehandler.cpp
@@ -0,0 +1,551 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qv4bytecodehandler_p.h>
+
+QT_USE_NAMESPACE
+using namespace QV4;
+using namespace Moth;
+
+ByteCodeHandler::~ByteCodeHandler()
+{
+}
+
+#define DISPATCH_INSTRUCTION(name, nargs, ...) \
+ generate_##name( \
+ __VA_ARGS__ \
+ );
+
+#define DECODE_AND_DISPATCH(instr) \
+ { \
+ INSTR_##instr(MOTH_DECODE_WITH_BASE) \
+ Q_UNUSED(base_ptr); \
+ _currentOffset = _nextOffset; \
+ _nextOffset = code - start; \
+ startInstruction(Instr::Type::instr); \
+ INSTR_##instr(DISPATCH) \
+ endInstruction(Instr::Type::instr); \
+ continue; \
+ }
+
+void ByteCodeHandler::decode(const char *code, uint len)
+{
+ MOTH_JUMP_TABLE;
+
+ const char *start = code;
+ const char *end = code + len;
+ while (code < end) {
+ MOTH_DISPATCH()
+
+ FOR_EACH_MOTH_INSTR(DECODE_AND_DISPATCH)
+ }
+}
+
+#undef DECODE_AND_DISPATCH
+#undef DISPATCH_INSTRUCTION
+
+#define MOTH_UNUSED_ARGS0()
+#define MOTH_UNUSED_ARGS1(arg) \
+ Q_UNUSED(arg);
+#define MOTH_UNUSED_ARGS2(arg1, arg2) \
+ Q_UNUSED(arg1); \
+ Q_UNUSED(arg2);
+#define MOTH_UNUSED_ARGS3(arg1, arg2, arg3) \
+ Q_UNUSED(arg1); \
+ Q_UNUSED(arg2); \
+ Q_UNUSED(arg3);
+#define MOTH_UNUSED_ARGS4(arg1, arg2, arg3, arg4) \
+ Q_UNUSED(arg1); \
+ Q_UNUSED(arg2); \
+ Q_UNUSED(arg3); \
+ Q_UNUSED(arg4);
+
+#define MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, ...) \
+ MOTH_EXPAND_FOR_MSVC(MOTH_UNUSED_ARGS##nargs(__VA_ARGS__))
+
+#define MOTH_MARK_ARGS_UNUSED_INSTRUCTION(name, nargs, ...) \
+ MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, __VA_ARGS__)
+
+#define COLLECTOR_BEGIN_INSTR(instr) \
+ { \
+ INSTR_##instr(MOTH_DECODE_WITH_BASE) \
+ INSTR_##instr(MOTH_MARK_ARGS_UNUSED) \
+ Q_UNUSED(base_ptr);
+
+#define COLLECTOR_END_INSTR(instr) \
+ continue; \
+ }
+
+std::vector<int> ByteCodeHandler::collectLabelsInBytecode(const char *code, uint len)
+{
+ MOTH_JUMP_TABLE;
+
+ std::vector<int> labels;
+
+ const auto addLabel = [&labels,len](int offset) {
+ Q_ASSERT(offset >= 0 && offset < static_cast<int>(len));
+ labels.push_back(offset);
+ };
+
+ const char *start = code;
+ const char *end = code + len;
+ while (code < end) {
+ MOTH_DISPATCH()
+ Q_UNREACHABLE();
+
+ COLLECTOR_BEGIN_INSTR(LoadReg)
+ COLLECTOR_END_INSTR(LoadReg)
+
+ COLLECTOR_BEGIN_INSTR(StoreReg)
+ COLLECTOR_END_INSTR(StoreReg)
+
+ COLLECTOR_BEGIN_INSTR(MoveReg)
+ COLLECTOR_END_INSTR(MoveReg)
+
+ COLLECTOR_BEGIN_INSTR(LoadConst)
+ COLLECTOR_END_INSTR(LoadConst)
+
+ COLLECTOR_BEGIN_INSTR(LoadNull)
+ COLLECTOR_END_INSTR(LoadNull)
+
+ COLLECTOR_BEGIN_INSTR(LoadZero)
+ COLLECTOR_END_INSTR(LoadZero)
+
+ COLLECTOR_BEGIN_INSTR(LoadTrue)
+ COLLECTOR_END_INSTR(LoadTrue)
+
+ COLLECTOR_BEGIN_INSTR(LoadFalse)
+ COLLECTOR_END_INSTR(LoadFalse)
+
+ COLLECTOR_BEGIN_INSTR(LoadUndefined)
+ COLLECTOR_END_INSTR(LoadUndefined)
+
+ COLLECTOR_BEGIN_INSTR(LoadInt)
+ COLLECTOR_END_INSTR(LoadInt)
+
+ COLLECTOR_BEGIN_INSTR(MoveConst)
+ COLLECTOR_END_INSTR(MoveConst)
+
+ COLLECTOR_BEGIN_INSTR(LoadImport)
+ COLLECTOR_END_INSTR(LoadImport)
+
+ COLLECTOR_BEGIN_INSTR(LoadLocal)
+ COLLECTOR_END_INSTR(LoadLocal)
+
+ COLLECTOR_BEGIN_INSTR(StoreLocal)
+ COLLECTOR_END_INSTR(StoreLocal)
+
+ COLLECTOR_BEGIN_INSTR(LoadScopedLocal)
+ COLLECTOR_END_INSTR(LoadScopedLocal)
+
+ COLLECTOR_BEGIN_INSTR(StoreScopedLocal)
+ COLLECTOR_END_INSTR(StoreScopedLocal)
+
+ COLLECTOR_BEGIN_INSTR(LoadRuntimeString)
+ COLLECTOR_END_INSTR(LoadRuntimeString)
+
+ COLLECTOR_BEGIN_INSTR(MoveRegExp)
+ COLLECTOR_END_INSTR(MoveRegExp)
+
+ COLLECTOR_BEGIN_INSTR(LoadClosure)
+ COLLECTOR_END_INSTR(LoadClosure)
+
+ COLLECTOR_BEGIN_INSTR(LoadName)
+ COLLECTOR_END_INSTR(LoadName)
+
+ COLLECTOR_BEGIN_INSTR(LoadGlobalLookup)
+ COLLECTOR_END_INSTR(LoadGlobalLookup)
+
+ COLLECTOR_BEGIN_INSTR(StoreNameSloppy)
+ COLLECTOR_END_INSTR(StoreNameSloppy)
+
+ COLLECTOR_BEGIN_INSTR(StoreNameStrict)
+ COLLECTOR_END_INSTR(StoreNameStrict)
+
+ COLLECTOR_BEGIN_INSTR(LoadElement)
+ COLLECTOR_END_INSTR(LoadElement)
+
+ COLLECTOR_BEGIN_INSTR(StoreElement)
+ COLLECTOR_END_INSTR(StoreElement)
+
+ COLLECTOR_BEGIN_INSTR(LoadProperty)
+ COLLECTOR_END_INSTR(LoadProperty)
+
+ COLLECTOR_BEGIN_INSTR(GetLookup)
+ COLLECTOR_END_INSTR(GetLookup)
+
+ COLLECTOR_BEGIN_INSTR(StoreProperty)
+ COLLECTOR_END_INSTR(StoreProperty)
+
+ COLLECTOR_BEGIN_INSTR(SetLookup)
+ COLLECTOR_END_INSTR(SetLookup)
+
+ COLLECTOR_BEGIN_INSTR(LoadSuperProperty)
+ COLLECTOR_END_INSTR(LoadSuperProperty)
+
+ COLLECTOR_BEGIN_INSTR(StoreSuperProperty)
+ COLLECTOR_END_INSTR(StoreSuperProperty)
+
+ COLLECTOR_BEGIN_INSTR(StoreScopeObjectProperty)
+ COLLECTOR_END_INSTR(StoreScopeObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(LoadScopeObjectProperty)
+ COLLECTOR_END_INSTR(LoadScopeObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(StoreContextObjectProperty)
+ COLLECTOR_END_INSTR(StoreContextObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(LoadContextObjectProperty)
+ COLLECTOR_END_INSTR(LoadContextObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(LoadIdObject)
+ COLLECTOR_END_INSTR(LoadIdObject)
+
+ COLLECTOR_BEGIN_INSTR(Yield)
+ COLLECTOR_END_INSTR(Yield)
+
+ COLLECTOR_BEGIN_INSTR(YieldStar)
+ COLLECTOR_END_INSTR(YieldStar)
+
+ COLLECTOR_BEGIN_INSTR(Resume)
+ COLLECTOR_END_INSTR(Resume)
+
+ COLLECTOR_BEGIN_INSTR(CallValue)
+ COLLECTOR_END_INSTR(CallValue)
+
+ COLLECTOR_BEGIN_INSTR(CallWithReceiver)
+ COLLECTOR_END_INSTR(CallWithReceiver)
+
+ COLLECTOR_BEGIN_INSTR(CallProperty)
+ COLLECTOR_END_INSTR(CallProperty)
+
+ COLLECTOR_BEGIN_INSTR(CallPropertyLookup)
+ COLLECTOR_END_INSTR(CallPropertyLookup)
+
+ COLLECTOR_BEGIN_INSTR(CallElement)
+ COLLECTOR_END_INSTR(CallElement)
+
+ COLLECTOR_BEGIN_INSTR(CallName)
+ COLLECTOR_END_INSTR(CallName)
+
+ COLLECTOR_BEGIN_INSTR(CallPossiblyDirectEval)
+ COLLECTOR_END_INSTR(CallPossiblyDirectEval)
+
+ COLLECTOR_BEGIN_INSTR(CallGlobalLookup)
+ COLLECTOR_END_INSTR(CallGlobalLookup)
+
+ COLLECTOR_BEGIN_INSTR(CallScopeObjectProperty)
+ COLLECTOR_END_INSTR(CallScopeObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(CallContextObjectProperty)
+ COLLECTOR_END_INSTR(CallContextObjectProperty)
+
+ COLLECTOR_BEGIN_INSTR(CallWithSpread)
+ COLLECTOR_END_INSTR(CallWithSpread)
+
+ COLLECTOR_BEGIN_INSTR(Construct)
+ COLLECTOR_END_INSTR(Construct)
+
+ COLLECTOR_BEGIN_INSTR(ConstructWithSpread)
+ COLLECTOR_END_INSTR(ConstructWithSpread)
+
+ COLLECTOR_BEGIN_INSTR(SetUnwindHandler)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(SetUnwindHandler)
+
+ COLLECTOR_BEGIN_INSTR(UnwindDispatch)
+ COLLECTOR_END_INSTR(UnwindDispatch)
+
+ COLLECTOR_BEGIN_INSTR(UnwindToLabel)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(UnwindToLabel)
+
+ COLLECTOR_BEGIN_INSTR(DeadTemporalZoneCheck)
+ COLLECTOR_END_INSTR(DeadTemporalZoneCheck)
+
+ COLLECTOR_BEGIN_INSTR(ThrowException)
+ COLLECTOR_END_INSTR(ThrowException)
+
+ COLLECTOR_BEGIN_INSTR(GetException)
+ COLLECTOR_END_INSTR(HasException)
+
+ COLLECTOR_BEGIN_INSTR(SetException)
+ COLLECTOR_END_INSTR(SetExceptionFlag)
+
+ COLLECTOR_BEGIN_INSTR(CreateCallContext)
+ COLLECTOR_END_INSTR(CreateCallContext)
+
+ COLLECTOR_BEGIN_INSTR(PushCatchContext)
+ COLLECTOR_END_INSTR(PushCatchContext)
+
+ COLLECTOR_BEGIN_INSTR(PushWithContext)
+ COLLECTOR_END_INSTR(PushWithContext)
+
+ COLLECTOR_BEGIN_INSTR(PushBlockContext)
+ COLLECTOR_END_INSTR(PushBlockContext)
+
+ COLLECTOR_BEGIN_INSTR(CloneBlockContext)
+ COLLECTOR_END_INSTR(CloneBlockContext)
+
+ COLLECTOR_BEGIN_INSTR(PushScriptContext)
+ COLLECTOR_END_INSTR(PushScriptContext)
+
+ COLLECTOR_BEGIN_INSTR(PopScriptContext)
+ COLLECTOR_END_INSTR(PopScriptContext)
+
+ COLLECTOR_BEGIN_INSTR(PopContext)
+ COLLECTOR_END_INSTR(PopContext)
+
+ COLLECTOR_BEGIN_INSTR(GetIterator)
+ COLLECTOR_END_INSTR(GetIterator)
+
+ COLLECTOR_BEGIN_INSTR(IteratorNext)
+ COLLECTOR_END_INSTR(IteratorNext)
+
+ COLLECTOR_BEGIN_INSTR(IteratorNextForYieldStar)
+ COLLECTOR_END_INSTR(IteratorNextForYieldStar)
+
+ COLLECTOR_BEGIN_INSTR(IteratorClose)
+ COLLECTOR_END_INSTR(IteratorClose)
+
+ COLLECTOR_BEGIN_INSTR(DestructureRestElement)
+ COLLECTOR_END_INSTR(DestructureRestElement)
+
+ COLLECTOR_BEGIN_INSTR(DeleteProperty)
+ COLLECTOR_END_INSTR(DeleteProperty)
+
+ COLLECTOR_BEGIN_INSTR(DeleteName)
+ COLLECTOR_END_INSTR(DeleteName)
+
+ COLLECTOR_BEGIN_INSTR(TypeofName)
+ COLLECTOR_END_INSTR(TypeofName)
+
+ COLLECTOR_BEGIN_INSTR(TypeofValue)
+ COLLECTOR_END_INSTR(TypeofValue)
+
+ COLLECTOR_BEGIN_INSTR(DeclareVar)
+ COLLECTOR_END_INSTR(DeclareVar)
+
+ COLLECTOR_BEGIN_INSTR(DefineArray)
+ COLLECTOR_END_INSTR(DefineArray)
+
+ COLLECTOR_BEGIN_INSTR(DefineObjectLiteral)
+ COLLECTOR_END_INSTR(DefineObjectLiteral)
+
+ COLLECTOR_BEGIN_INSTR(CreateClass)
+ COLLECTOR_END_INSTR(CreateClass)
+
+ COLLECTOR_BEGIN_INSTR(CreateMappedArgumentsObject)
+ COLLECTOR_END_INSTR(CreateMappedArgumentsObject)
+
+ COLLECTOR_BEGIN_INSTR(CreateUnmappedArgumentsObject)
+ COLLECTOR_END_INSTR(CreateUnmappedArgumentsObject)
+
+ COLLECTOR_BEGIN_INSTR(CreateRestParameter)
+ COLLECTOR_END_INSTR(CreateRestParameter)
+
+ COLLECTOR_BEGIN_INSTR(ConvertThisToObject)
+ COLLECTOR_END_INSTR(ConvertThisToObject)
+
+ COLLECTOR_BEGIN_INSTR(LoadSuperConstructor)
+ COLLECTOR_END_INSTR(LoadSuperConstructor)
+
+ COLLECTOR_BEGIN_INSTR(ToObject)
+ COLLECTOR_END_INSTR(ToObject)
+
+ COLLECTOR_BEGIN_INSTR(Jump)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(Jump)
+
+ COLLECTOR_BEGIN_INSTR(JumpTrue)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(JumpTrue)
+
+ COLLECTOR_BEGIN_INSTR(JumpFalse)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(JumpFalse)
+
+ COLLECTOR_BEGIN_INSTR(JumpNoException)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(JumpNoException)
+
+ COLLECTOR_BEGIN_INSTR(JumpNotUndefined)
+ addLabel(code - start + offset);
+ COLLECTOR_END_INSTR(JumpNotUndefined)
+
+ COLLECTOR_BEGIN_INSTR(CmpEqNull)
+ COLLECTOR_END_INSTR(CmpEqNull)
+
+ COLLECTOR_BEGIN_INSTR(CmpNeNull)
+ COLLECTOR_END_INSTR(CmpNeNull)
+
+ COLLECTOR_BEGIN_INSTR(CmpEqInt)
+ COLLECTOR_END_INSTR(CmpEq)
+
+ COLLECTOR_BEGIN_INSTR(CmpNeInt)
+ COLLECTOR_END_INSTR(CmpNeInt)
+
+ COLLECTOR_BEGIN_INSTR(CmpEq)
+ COLLECTOR_END_INSTR(CmpEq)
+
+ COLLECTOR_BEGIN_INSTR(CmpNe)
+ COLLECTOR_END_INSTR(CmpNe)
+
+ COLLECTOR_BEGIN_INSTR(CmpGt)
+ COLLECTOR_END_INSTR(CmpGt)
+
+ COLLECTOR_BEGIN_INSTR(CmpGe)
+ COLLECTOR_END_INSTR(CmpGe)
+
+ COLLECTOR_BEGIN_INSTR(CmpLt)
+ COLLECTOR_END_INSTR(CmpLt)
+
+ COLLECTOR_BEGIN_INSTR(CmpLe)
+ COLLECTOR_END_INSTR(CmpLe)
+
+ COLLECTOR_BEGIN_INSTR(CmpStrictEqual)
+ COLLECTOR_END_INSTR(CmpStrictEqual)
+
+ COLLECTOR_BEGIN_INSTR(CmpStrictNotEqual)
+ COLLECTOR_END_INSTR(CmpStrictNotEqual)
+
+ COLLECTOR_BEGIN_INSTR(CmpIn)
+ COLLECTOR_END_INSTR(CmpIn)
+
+ COLLECTOR_BEGIN_INSTR(CmpInstanceOf)
+ COLLECTOR_END_INSTR(CmpInstanceOf)
+
+ COLLECTOR_BEGIN_INSTR(UNot)
+ COLLECTOR_END_INSTR(UNot)
+
+ COLLECTOR_BEGIN_INSTR(UPlus)
+ COLLECTOR_END_INSTR(UPlus)
+
+ COLLECTOR_BEGIN_INSTR(UMinus)
+ COLLECTOR_END_INSTR(UMinus)
+
+ COLLECTOR_BEGIN_INSTR(UCompl)
+ COLLECTOR_END_INSTR(UCompl)
+
+ COLLECTOR_BEGIN_INSTR(Increment)
+ COLLECTOR_END_INSTR(PreIncrement)
+
+ COLLECTOR_BEGIN_INSTR(Decrement)
+ COLLECTOR_END_INSTR(PreDecrement)
+
+ COLLECTOR_BEGIN_INSTR(Add)
+ COLLECTOR_END_INSTR(Add)
+
+ COLLECTOR_BEGIN_INSTR(BitAnd)
+ COLLECTOR_END_INSTR(BitAnd)
+
+ COLLECTOR_BEGIN_INSTR(BitOr)
+ COLLECTOR_END_INSTR(BitOr)
+
+ COLLECTOR_BEGIN_INSTR(BitXor)
+ COLLECTOR_END_INSTR(BitXor)
+
+ COLLECTOR_BEGIN_INSTR(UShr)
+ COLLECTOR_END_INSTR(UShr)
+
+ COLLECTOR_BEGIN_INSTR(Shr)
+ COLLECTOR_END_INSTR(Shr)
+
+ COLLECTOR_BEGIN_INSTR(Shl)
+ COLLECTOR_END_INSTR(Shl)
+
+ COLLECTOR_BEGIN_INSTR(BitAndConst)
+ COLLECTOR_END_INSTR(BitAndConst)
+
+ COLLECTOR_BEGIN_INSTR(BitOrConst)
+ COLLECTOR_END_INSTR(BitOr)
+
+ COLLECTOR_BEGIN_INSTR(BitXorConst)
+ COLLECTOR_END_INSTR(BitXor)
+
+ COLLECTOR_BEGIN_INSTR(UShrConst)
+ COLLECTOR_END_INSTR(UShrConst)
+
+ COLLECTOR_BEGIN_INSTR(ShrConst)
+ COLLECTOR_END_INSTR(ShrConst)
+
+ COLLECTOR_BEGIN_INSTR(ShlConst)
+ COLLECTOR_END_INSTR(ShlConst)
+
+ COLLECTOR_BEGIN_INSTR(Exp)
+ COLLECTOR_END_INSTR(Exp)
+
+ COLLECTOR_BEGIN_INSTR(Mul)
+ COLLECTOR_END_INSTR(Mul)
+
+ COLLECTOR_BEGIN_INSTR(Div)
+ COLLECTOR_END_INSTR(Div)
+
+ COLLECTOR_BEGIN_INSTR(Mod)
+ COLLECTOR_END_INSTR(Mod)
+
+ COLLECTOR_BEGIN_INSTR(Sub)
+ COLLECTOR_END_INSTR(Sub)
+
+ COLLECTOR_BEGIN_INSTR(Ret)
+ COLLECTOR_END_INSTR(Ret)
+
+#ifndef QT_NO_QML_DEBUGGER
+ COLLECTOR_BEGIN_INSTR(Debug)
+ COLLECTOR_END_INSTR(Debug)
+#endif // QT_NO_QML_DEBUGGER
+
+ COLLECTOR_BEGIN_INSTR(InitializeBlockDeadTemporalZone)
+ COLLECTOR_END_INSTR(InitializeBlockDeadTemporalZone)
+
+ COLLECTOR_BEGIN_INSTR(ThrowOnNullOrUndefined)
+ COLLECTOR_END_INSTR(ThrowOnNullOrUndefined)
+
+ COLLECTOR_BEGIN_INSTR(LoadQmlContext)
+ COLLECTOR_END_INSTR(LoadQmlContext)
+
+ COLLECTOR_BEGIN_INSTR(LoadQmlImportedScripts)
+ COLLECTOR_END_INSTR(LoadQmlImportedScripts)
+ }
+
+ return labels;
+}
+
+#undef COLLECTOR_BEGIN_INSTR
+#undef COLLECTOR_END_INSTR
diff --git a/src/qml/compiler/qv4bytecodehandler_p.h b/src/qml/compiler/qv4bytecodehandler_p.h
new file mode 100644
index 0000000000..ca6abf3dc3
--- /dev/null
+++ b/src/qml/compiler/qv4bytecodehandler_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4BYTECODEHANDLER_P_H
+#define QV4BYTECODEHANDLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#include <private/qv4instr_moth_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+namespace Moth {
+
+#define BYTECODE_HANDLER_DEFINE_ARGS(nargs, ...) \
+ MOTH_EXPAND_FOR_MSVC(BYTECODE_HANDLER_DEFINE_ARGS##nargs(__VA_ARGS__))
+
+#define BYTECODE_HANDLER_DEFINE_ARGS0()
+#define BYTECODE_HANDLER_DEFINE_ARGS1(arg) \
+ int arg
+#define BYTECODE_HANDLER_DEFINE_ARGS2(arg1, arg2) \
+ int arg1, \
+ int arg2
+#define BYTECODE_HANDLER_DEFINE_ARGS3(arg1, arg2, arg3) \
+ int arg1, \
+ int arg2, \
+ int arg3
+#define BYTECODE_HANDLER_DEFINE_ARGS4(arg1, arg2, arg3, arg4) \
+ int arg1, \
+ int arg2, \
+ int arg3, \
+ int arg4
+
+#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER_INSTRUCTION(name, nargs, ...) \
+ virtual void generate_##name( \
+ BYTECODE_HANDLER_DEFINE_ARGS(nargs, __VA_ARGS__) \
+ ) = 0;
+
+#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER(instr) \
+ INSTR_##instr(BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER)
+
+class ByteCodeHandler
+{
+public:
+ virtual ~ByteCodeHandler();
+
+ void decode(const char *code, uint len);
+
+ int currentInstructionOffset() const { return _currentOffset; }
+ int nextInstructionOffset() const { return _nextOffset; }
+
+ static std::vector<int> collectLabelsInBytecode(const char *code, uint len);
+
+protected:
+ FOR_EACH_MOTH_INSTR(BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER)
+
+ virtual void startInstruction(Moth::Instr::Type instr) = 0;
+ virtual void endInstruction(Moth::Instr::Type instr) = 0;
+
+private:
+ int _currentOffset = 0;
+ int _nextOffset = 0;
+};
+
+} // Moth namespace
+} // QV4 namespace
+
+QT_END_NAMESPACE
+
+#endif // QV4BYTECODEHANDLER_P_H
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index e831fd48f5..8709e3fff8 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QBitArray>
#include <QtCore/QLinkedList>
#include <QtCore/QStack>
+#include <QScopeGuard>
#include <private/qqmljsast_p.h>
#include <private/qv4string_p.h>
#include <private/qv4value_p.h>
@@ -58,6 +59,8 @@
#include <cmath>
#include <iostream>
+static const bool disable_lookups = false;
+
#ifdef CONST
#undef CONST
#endif
@@ -77,8 +80,6 @@ static inline void setJumpOutLocation(QV4::Moth::BytecodeGenerator *bytecodeGene
case Statement::Kind_ForEachStatement:
case Statement::Kind_ForStatement:
case Statement::Kind_IfStatement:
- case Statement::Kind_LocalForEachStatement:
- case Statement::Kind_LocalForStatement:
case Statement::Kind_WhileStatement:
bytecodeGenerator->setLocation(fallback);
break;
@@ -90,7 +91,7 @@ static inline void setJumpOutLocation(QV4::Moth::BytecodeGenerator *bytecodeGene
Codegen::Codegen(QV4::Compiler::JSUnitGenerator *jsUnitGenerator, bool strict)
: _module(nullptr)
- , _returnAddress(0)
+ , _returnAddress(-1)
, _context(nullptr)
, _labelledStatement(nullptr)
, jsUnitGenerator(jsUnitGenerator)
@@ -106,7 +107,7 @@ void Codegen::generateFromProgram(const QString &fileName,
const QString &sourceCode,
Program *node,
Module *module,
- CompilationMode mode)
+ ContextType contextType)
{
Q_ASSERT(node);
@@ -117,10 +118,59 @@ void Codegen::generateFromProgram(const QString &fileName,
_module->fileName = fileName;
_module->finalUrl = finalUrl;
- ScanFunctions scan(this, sourceCode, mode);
+ ScanFunctions scan(this, sourceCode, contextType);
scan(node);
- defineFunction(QStringLiteral("%entry"), node, nullptr, node->elements);
+ if (hasError)
+ return;
+
+ defineFunction(QStringLiteral("%entry"), node, nullptr, node->statements);
+}
+
+void Codegen::generateFromModule(const QString &fileName,
+ const QString &finalUrl,
+ const QString &sourceCode,
+ ESModule *node,
+ Module *module)
+{
+ Q_ASSERT(node);
+
+ _module = module;
+ _context = nullptr;
+
+ // ### should be set on the module outside of this method
+ _module->fileName = fileName;
+ _module->finalUrl = finalUrl;
+
+ ScanFunctions scan(this, sourceCode, ContextType::ESModule);
+ scan(node);
+
+ if (hasError)
+ return;
+
+ {
+ Compiler::Context *moduleContext = _module->contextMap.value(node);
+ for (const auto &entry: moduleContext->exportEntries) {
+ if (entry.moduleRequest.isEmpty()) {
+ // ### check against imported bound names
+ _module->localExportEntries << entry;
+ } else if (entry.importName == QLatin1Char('*')) {
+ _module->starExportEntries << entry;
+ } else {
+ _module->indirectExportEntries << entry;
+ }
+ }
+ _module->importEntries = moduleContext->importEntries;
+
+ _module->moduleRequests = std::move(moduleContext->moduleRequests);
+ _module->moduleRequests.removeDuplicates();
+ }
+
+ std::sort(_module->localExportEntries.begin(), _module->localExportEntries.end(), ExportEntry::lessThan);
+ std::sort(_module->starExportEntries.begin(), _module->starExportEntries.end(), ExportEntry::lessThan);
+ std::sort(_module->indirectExportEntries.begin(), _module->indirectExportEntries.end(), ExportEntry::lessThan);
+
+ defineFunction(QStringLiteral("%entry"), node, nullptr, node->body);
}
void Codegen::enterContext(Node *node)
@@ -132,19 +182,23 @@ void Codegen::enterContext(Node *node)
int Codegen::leaveContext()
{
Q_ASSERT(_context);
- Q_ASSERT(!_context->controlFlow);
int functionIndex = _context->functionIndex;
_context = _context->parent;
return functionIndex;
}
+Context *Codegen::enterBlock(Node *node)
+{
+ enterContext(node);
+ return _context;
+}
+
Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
{
if (hasError)
return _expr.result();
-#ifndef V4_BOOTSTRAP
- if (expr.isConst()) {
+ if (expr.isConstant()) {
auto v = Value::fromReturnedValue(expr.constant);
if (v.isNumber()) {
switch (op) {
@@ -161,7 +215,6 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
}
}
}
-#endif // V4_BOOTSTRAP
switch (op) {
case UMinus: {
@@ -267,9 +320,9 @@ void Codegen::statement(Statement *ast)
bytecodeGenerator->setLocation(ast->firstSourceLocation());
VolatileMemoryLocations vLocs = scanVolatileMemoryLocations(ast);
- qSwap(_volataleMemoryLocations, vLocs);
+ qSwap(_volatileMemoryLocations, vLocs);
accept(ast);
- qSwap(_volataleMemoryLocations, vLocs);
+ qSwap(_volatileMemoryLocations, vLocs);
}
void Codegen::statement(ExpressionNode *ast)
@@ -282,11 +335,11 @@ void Codegen::statement(ExpressionNode *ast)
Result r(nx);
qSwap(_expr, r);
VolatileMemoryLocations vLocs = scanVolatileMemoryLocations(ast);
- qSwap(_volataleMemoryLocations, vLocs);
+ qSwap(_volatileMemoryLocations, vLocs);
accept(ast);
- qSwap(_volataleMemoryLocations, vLocs);
+ qSwap(_volatileMemoryLocations, vLocs);
qSwap(_expr, r);
if (hasError)
@@ -337,60 +390,103 @@ Codegen::Reference Codegen::expression(ExpressionNode *ast)
return r.result();
}
-Codegen::Result Codegen::sourceElement(SourceElement *ast)
+void Codegen::program(Program *ast)
{
- Result r(nx);
if (ast) {
- qSwap(_expr, r);
- accept(ast);
- qSwap(_expr, r);
+ statementList(ast->statements);
}
- return r;
}
-void Codegen::functionBody(FunctionBody *ast)
-{
- if (ast)
- sourceElements(ast->elements);
-}
+enum class CompletionState {
+ Empty,
+ EmptyAbrupt,
+ NonEmpty
+};
-void Codegen::program(Program *ast)
-{
- if (ast) {
- sourceElements(ast->elements);
+static CompletionState completionState(StatementList *list)
+{
+ for (StatementList *it = list; it; it = it->next) {
+ if (it->statement->kind == Statement::Kind_BreakStatement ||
+ it->statement->kind == Statement::Kind_ContinueStatement)
+ return CompletionState::EmptyAbrupt;
+ if (it->statement->kind == Statement::Kind_EmptyStatement ||
+ it->statement->kind == Statement::Kind_VariableDeclaration ||
+ it->statement->kind == Statement::Kind_FunctionDeclaration)
+ continue;
+ if (it->statement->kind == Statement::Kind_Block) {
+ CompletionState subState = completionState(static_cast<Block *>(it->statement)->statements);
+ if (subState != CompletionState::Empty)
+ return subState;
+ continue;
+ }
+ return CompletionState::NonEmpty;
}
+ return CompletionState::Empty;
}
-void Codegen::sourceElements(SourceElements *ast)
+static Node *completionStatement(StatementList *list)
{
- bool _requiresReturnValue = false;
- qSwap(_requiresReturnValue, requiresReturnValue);
- for (SourceElements *it = ast; it; it = it->next) {
- if (!it->next)
- qSwap(_requiresReturnValue, requiresReturnValue);
- sourceElement(it->element);
- if (hasError)
- return;
- if (StatementSourceElement *sse = AST::cast<StatementSourceElement *>(it->element)) {
- if (AST::cast<ThrowStatement *>(sse->statement) ||
- AST::cast<ReturnStatement *>(sse->statement))
- return;
+ Node *completionStatement = nullptr;
+ for (StatementList *it = list; it; it = it->next) {
+ if (it->statement->kind == Statement::Kind_BreakStatement ||
+ it->statement->kind == Statement::Kind_ContinueStatement)
+ return completionStatement;
+ if (it->statement->kind == Statement::Kind_ThrowStatement ||
+ it->statement->kind == Statement::Kind_ReturnStatement)
+ return it->statement;
+ if (it->statement->kind == Statement::Kind_EmptyStatement ||
+ it->statement->kind == Statement::Kind_VariableStatement ||
+ it->statement->kind == Statement::Kind_FunctionDeclaration)
+ continue;
+ if (it->statement->kind == Statement::Kind_Block) {
+ CompletionState state = completionState(static_cast<Block *>(it->statement)->statements);
+ switch (state) {
+ case CompletionState::Empty:
+ continue;
+ case CompletionState::EmptyAbrupt:
+ return it->statement;
+ case CompletionState::NonEmpty:
+ break;
+ }
}
+ completionStatement = it->statement;
}
+ return completionStatement;
}
void Codegen::statementList(StatementList *ast)
{
+ if (!ast)
+ return;
+
bool _requiresReturnValue = requiresReturnValue;
- requiresReturnValue = false;
- for (StatementList *it = ast; it; it = it->next) {
- if (!it->next ||
- it->next->statement->kind == Statement::Kind_BreakStatement ||
- it->next->statement->kind == Statement::Kind_ContinueStatement ||
- it->next->statement->kind == Statement::Kind_ReturnStatement)
- requiresReturnValue = _requiresReturnValue;
- statement(it->statement);
+ // ### the next line is pessimizing a bit too much, as there are many cases, where the complietion from the break
+ // statement will not be used, but it's at least spec compliant
+ if (!controlFlow || !controlFlow->hasLoop())
requiresReturnValue = false;
+
+ Node *needsCompletion = nullptr;
+
+ if (_requiresReturnValue && !requiresReturnValue)
+ needsCompletion = completionStatement(ast);
+
+ if (requiresReturnValue && !needsCompletion && !insideSwitch) {
+ // break or continue is the first real statement, set the return value to undefined
+ Reference::fromConst(this, Encode::undefined()).storeOnStack(_returnAddress);
+ }
+
+ bool _insideSwitch = insideSwitch;
+ insideSwitch = false;
+
+ for (StatementList *it = ast; it; it = it->next) {
+ if (it->statement == needsCompletion)
+ requiresReturnValue = true;
+ if (Statement *s = it->statement->statementCast())
+ statement(s);
+ else
+ statement(static_cast<ExpressionNode *>(it->statement));
+ if (it->statement == needsCompletion)
+ requiresReturnValue = false;
if (it->statement->kind == Statement::Kind_ThrowStatement ||
it->statement->kind == Statement::Kind_BreakStatement ||
it->statement->kind == Statement::Kind_ContinueStatement ||
@@ -399,22 +495,22 @@ void Codegen::statementList(StatementList *ast)
break;
}
requiresReturnValue = _requiresReturnValue;
+ insideSwitch = _insideSwitch;
}
-void Codegen::variableDeclaration(VariableDeclaration *ast)
+void Codegen::variableDeclaration(PatternElement *ast)
{
RegisterScope scope(this);
- if (!ast->expression)
- return;
- Reference rhs = expression(ast->expression);
- if (hasError)
+ if (!ast->initializer) {
+ if (ast->isLexicallyScoped()) {
+ Reference::fromConst(this, Encode::undefined()).loadInAccumulator();
+ Reference varToStore = targetForPatternElement(ast);
+ varToStore.storeConsumeAccumulator();
+ }
return;
-
- Reference lhs = referenceForName(ast->name.toString(), true);
- //### if lhs is a temp, this won't generate a temp-to-temp move. Same for when rhs is a const
- rhs.loadInAccumulator();
- lhs.storeConsumeAccumulator();
+ }
+ initializeAndDestructureBindingElement(ast, Reference(), /*isDefinition*/ true);
}
void Codegen::variableDeclarationList(VariableDeclarationList *ast)
@@ -424,6 +520,203 @@ void Codegen::variableDeclarationList(VariableDeclarationList *ast)
}
}
+Codegen::Reference Codegen::targetForPatternElement(AST::PatternElement *p)
+{
+ if (!p->bindingIdentifier.isNull())
+ return referenceForName(p->bindingIdentifier.toString(), true, p->firstSourceLocation());
+ if (!p->bindingTarget || p->destructuringPattern())
+ return Codegen::Reference::fromStackSlot(this);
+ Reference lhs = expression(p->bindingTarget);
+ if (hasError)
+ return lhs;
+ lhs = lhs.asLValue();
+ return lhs;
+}
+
+void Codegen::initializeAndDestructureBindingElement(AST::PatternElement *e, const Reference &base, bool isDefinition)
+{
+ Q_ASSERT(e->type == AST::PatternElement::Binding || e->type == AST::PatternElement::RestElement);
+ RegisterScope scope(this);
+ Reference baseRef = (base.isAccumulator()) ? base.storeOnStack() : base;
+ Reference varToStore = targetForPatternElement(e);
+ if (isDefinition)
+ varToStore.isReferenceToConst = false;
+ if (hasError)
+ return;
+
+ if (e->initializer) {
+ if (!baseRef.isValid()) {
+ // assignment
+ Reference expr = expression(e->initializer);
+ if (hasError)
+ return;
+ expr.loadInAccumulator();
+ varToStore.storeConsumeAccumulator();
+ } else if (baseRef == varToStore) {
+ baseRef.loadInAccumulator();
+ BytecodeGenerator::Jump jump = bytecodeGenerator->jumpNotUndefined();
+ Reference expr = expression(e->initializer);
+ if (hasError) {
+ jump.link();
+ return;
+ }
+ expr.loadInAccumulator();
+ varToStore.storeConsumeAccumulator();
+ jump.link();
+ } else {
+ baseRef.loadInAccumulator();
+ BytecodeGenerator::Jump jump = bytecodeGenerator->jumpNotUndefined();
+ Reference expr = expression(e->initializer);
+ if (hasError) {
+ jump.link();
+ return;
+ }
+ expr.loadInAccumulator();
+ jump.link();
+ varToStore.storeConsumeAccumulator();
+ }
+ } else if (baseRef != varToStore && baseRef.isValid()) {
+ baseRef.loadInAccumulator();
+ varToStore.storeConsumeAccumulator();
+ }
+ Pattern *p = e->destructuringPattern();
+ if (!p)
+ return;
+
+ if (!varToStore.isStackSlot())
+ varToStore = varToStore.storeOnStack();
+ if (PatternElementList *l = e->elementList()) {
+ destructureElementList(varToStore, l, isDefinition);
+ } else if (PatternPropertyList *p = e->propertyList()) {
+ destructurePropertyList(varToStore, p, isDefinition);
+ } else if (e->bindingTarget) {
+ // empty binding pattern. For spec compatibility, try to coerce the argument to an object
+ varToStore.loadInAccumulator();
+ Instruction::ToObject toObject;
+ bytecodeGenerator->addInstruction(toObject);
+ return;
+ }
+}
+
+Codegen::Reference Codegen::referenceForPropertyName(const Codegen::Reference &object, AST::PropertyName *name)
+{
+ AST::ComputedPropertyName *cname = AST::cast<AST::ComputedPropertyName *>(name);
+ Reference property;
+ if (cname) {
+ Reference computedName = expression(cname->expression);
+ if (hasError)
+ return Reference();
+ computedName = computedName.storeOnStack();
+ property = Reference::fromSubscript(object, computedName).asLValue();
+ } else {
+ QString propertyName = name->asString();
+ property = Reference::fromMember(object, propertyName);
+ }
+ return property;
+}
+
+void Codegen::destructurePropertyList(const Codegen::Reference &object, PatternPropertyList *bindingList, bool isDefinition)
+{
+ RegisterScope scope(this);
+
+ object.loadInAccumulator();
+ Instruction::ThrowOnNullOrUndefined t;
+ bytecodeGenerator->addInstruction(t);
+
+ for (PatternPropertyList *it = bindingList; it; it = it->next) {
+ PatternProperty *p = it->property;
+ RegisterScope scope(this);
+ Reference property = referenceForPropertyName(object, p->name);
+ if (hasError)
+ return;
+ initializeAndDestructureBindingElement(p, property, isDefinition);
+ if (hasError)
+ return;
+ }
+}
+
+void Codegen::destructureElementList(const Codegen::Reference &array, PatternElementList *bindingList, bool isDefinition)
+{
+ RegisterScope scope(this);
+
+ Reference iterator = Reference::fromStackSlot(this);
+ Reference iteratorValue = Reference::fromStackSlot(this);
+ Reference iteratorDone = Reference::fromStackSlot(this);
+ Reference::storeConstOnStack(this, Encode(false), iteratorDone.stackSlot());
+
+ array.loadInAccumulator();
+ Instruction::GetIterator iteratorObjInstr;
+ iteratorObjInstr.iterator = static_cast<int>(AST::ForEachType::Of);
+ bytecodeGenerator->addInstruction(iteratorObjInstr);
+ iterator.storeConsumeAccumulator();
+
+ bool hasRest = false;
+
+ BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
+ {
+ auto cleanup = [this, iterator, iteratorDone]() {
+ iterator.loadInAccumulator();
+ Instruction::IteratorClose close;
+ close.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(close);
+ };
+
+ ControlFlowUnwindCleanup flow(this, cleanup);
+
+ for (PatternElementList *p = bindingList; p; p = p->next) {
+ PatternElement *e = p->element;
+ for (Elision *elision = p->elision; elision; elision = elision->next) {
+ iterator.loadInAccumulator();
+ Instruction::IteratorNext next;
+ next.value = iteratorValue.stackSlot();
+ next.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+ }
+
+ if (!e)
+ continue;
+
+ RegisterScope scope(this);
+ iterator.loadInAccumulator();
+
+ if (e->type == PatternElement::RestElement) {
+ Reference::fromConst(this, Encode(true)).storeOnStack(iteratorDone.stackSlot());
+ bytecodeGenerator->addInstruction(Instruction::DestructureRestElement());
+ initializeAndDestructureBindingElement(e, Reference::fromAccumulator(this), isDefinition);
+ hasRest = true;
+ } else {
+ Instruction::IteratorNext next;
+ next.value = iteratorValue.stackSlot();
+ next.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+ initializeAndDestructureBindingElement(e, iteratorValue, isDefinition);
+ if (hasError) {
+ end.link();
+ return;
+ }
+ }
+ }
+
+ if (hasRest)
+ // no need to close the iterator
+ bytecodeGenerator->jump().link(end);
+ }
+
+
+ end.link();
+}
+
+void Codegen::destructurePattern(Pattern *p, const Reference &rhs)
+{
+ RegisterScope scope(this);
+ if (auto *o = AST::cast<ObjectPattern *>(p))
+ destructurePropertyList(rhs, o->properties);
+ else if (auto *a = AST::cast<ArrayPattern *>(p))
+ destructureElementList(rhs, a->elements);
+ else
+ Q_UNREACHABLE();
+}
+
bool Codegen::visit(ArgumentList *)
{
@@ -461,12 +754,6 @@ bool Codegen::visit(DefaultClause *)
return false;
}
-bool Codegen::visit(ElementList *)
-{
- Q_UNREACHABLE();
- return false;
-}
-
bool Codegen::visit(Elision *)
{
Q_UNREACHABLE();
@@ -485,39 +772,66 @@ bool Codegen::visit(FormalParameterList *)
return false;
}
-bool Codegen::visit(FunctionBody *)
+bool Codegen::visit(Program *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(Program *)
+bool Codegen::visit(PatternElement *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(PropertyAssignmentList *)
+bool Codegen::visit(PatternElementList *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(PropertyNameAndValue *)
+bool Codegen::visit(PatternProperty *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(PropertyGetterSetter *)
+bool Codegen::visit(PatternPropertyList *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(SourceElements *)
+bool Codegen::visit(ExportDeclaration *ast)
{
- Q_UNREACHABLE();
+ if (!ast->exportDefault)
+ return true;
+
+ Reference exportedValue;
+
+ if (auto *fdecl = AST::cast<FunctionDeclaration*>(ast->variableStatementOrDeclaration)) {
+ Result r;
+ qSwap(_expr, r);
+ visit(static_cast<FunctionExpression*>(fdecl));
+ qSwap(_expr, r);
+ exportedValue = r.result();
+ } else if (auto *classDecl = AST::cast<ClassDeclaration*>(ast->variableStatementOrDeclaration)) {
+ Result r;
+ qSwap(_expr, r);
+ visit(static_cast<ClassExpression*>(classDecl));
+ qSwap(_expr, r);
+ exportedValue = r.result();
+ } else if (ExpressionNode *expr = ast->variableStatementOrDeclaration->expressionCast()) {
+ exportedValue = expression(expr);
+ }
+
+ exportedValue.loadInAccumulator();
+
+ const int defaultExportIndex = _context->locals.indexOf(_context->localNameForDefaultExport);
+ Q_ASSERT(defaultExportIndex != -1);
+ Reference defaultExportSlot = Reference::fromScopedLocal(this, defaultExportIndex, /*scope*/0);
+ defaultExportSlot.storeConsumeAccumulator();
+
return false;
}
@@ -581,21 +895,121 @@ bool Codegen::visit(UiQualifiedId *)
return false;
}
-bool Codegen::visit(UiQualifiedPragmaId *)
+bool Codegen::visit(VariableDeclarationList *)
{
Q_UNREACHABLE();
return false;
}
-bool Codegen::visit(VariableDeclaration *)
+bool Codegen::visit(ClassExpression *ast)
{
- Q_UNREACHABLE();
+ Compiler::Class jsClass;
+ jsClass.nameIndex = registerString(ast->name.toString());
+
+ ClassElementList *constructor = nullptr;
+ int nComputedNames = 0;
+ int nStaticComputedNames = 0;
+
+ RegisterScope scope(this);
+ ControlFlowBlock controlFlow(this, ast);
+
+ for (auto *member = ast->elements; member; member = member->next) {
+ PatternProperty *p = member->property;
+ FunctionExpression *f = p->initializer->asFunctionDefinition();
+ Q_ASSERT(f);
+ AST::ComputedPropertyName *cname = AST::cast<ComputedPropertyName *>(p->name);
+ if (cname) {
+ ++nComputedNames;
+ if (member->isStatic)
+ ++nStaticComputedNames;
+ }
+ QString name = p->name->asString();
+ uint nameIndex = cname ? UINT_MAX : registerString(name);
+ Compiler::Class::Method::Type type = Compiler::Class::Method::Regular;
+ if (p->type == PatternProperty::Getter)
+ type = Compiler::Class::Method::Getter;
+ else if (p->type == PatternProperty::Setter)
+ type = Compiler::Class::Method::Setter;
+ Compiler::Class::Method m{ nameIndex, type, static_cast<uint>(defineFunction(name, f, f->formals, f->body)) };
+
+ if (member->isStatic) {
+ if (name == QStringLiteral("prototype")) {
+ throwSyntaxError(ast->firstSourceLocation(), QLatin1String("Cannot declare a static method named 'prototype'."));
+ return false;
+ }
+ jsClass.staticMethods << m;
+ } else {
+ if (name == QStringLiteral("constructor")) {
+ if (constructor) {
+ throwSyntaxError(ast->firstSourceLocation(), QLatin1String("Cannot declare a multiple constructors in a class."));
+ return false;
+ }
+ if (m.type != Compiler::Class::Method::Regular) {
+ throwSyntaxError(ast->firstSourceLocation(), QLatin1String("Cannot declare a getter or setter named 'constructor'."));
+ return false;
+ }
+ constructor = member;
+ jsClass.constructorIndex = m.functionIndex;
+ continue;
+ }
+
+ jsClass.methods << m;
+ }
+ }
+
+ int classIndex = _module->classes.size();
+ _module->classes.append(jsClass);
+
+ Reference heritage = Reference::fromStackSlot(this);
+ if (ast->heritage) {
+ bytecodeGenerator->setLocation(ast->heritage->firstSourceLocation());
+ Reference r = expression(ast->heritage);
+ if (hasError)
+ return false;
+ r.storeOnStack(heritage.stackSlot());
+ } else {
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).loadInAccumulator();
+ heritage.storeConsumeAccumulator();
+ }
+
+ int computedNames = nComputedNames ? bytecodeGenerator->newRegisterArray(nComputedNames) : 0;
+ int currentStaticName = computedNames;
+ int currentNonStaticName = computedNames + nStaticComputedNames;
+
+ for (auto *member = ast->elements; member; member = member->next) {
+ AST::ComputedPropertyName *cname = AST::cast<AST::ComputedPropertyName *>(member->property->name);
+ if (!cname)
+ continue;
+ RegisterScope scope(this);
+ bytecodeGenerator->setLocation(cname->firstSourceLocation());
+ Reference computedName = expression(cname->expression);
+ if (hasError)
+ return false;
+ computedName.storeOnStack(member->isStatic ? currentStaticName++ : currentNonStaticName++);
+ }
+
+ Instruction::CreateClass createClass;
+ createClass.classIndex = classIndex;
+ createClass.heritage = heritage.stackSlot();
+ createClass.computedNames = computedNames;
+
+ bytecodeGenerator->addInstruction(createClass);
+
+ if (!ast->name.isEmpty()) {
+ Reference ctor = referenceForName(ast->name.toString(), true);
+ ctor.isReferenceToConst = false; // this is the definition
+ (void) ctor.storeRetainAccumulator();
+ }
+
+ _expr.setResult(Reference::fromAccumulator(this));
return false;
}
-bool Codegen::visit(VariableDeclarationList *)
+bool Codegen::visit(ClassDeclaration *ast)
{
- Q_UNREACHABLE();
+ Reference outerVar = referenceForName(ast->name.toString(), true);
+ visit(static_cast<ClassExpression *>(ast));
+ (void) outerVar.storeRetainAccumulator();
return false;
}
@@ -609,50 +1023,162 @@ bool Codegen::visit(Expression *ast)
return false;
}
-bool Codegen::visit(ArrayLiteral *ast)
+bool Codegen::visit(ArrayPattern *ast)
{
if (hasError)
return false;
- RegisterScope scope(this);
+ PatternElementList *it = ast->elements;
int argc = 0;
- int args = -1;
- auto push = [this, &argc, &args](AST::ExpressionNode *arg) {
- int temp = bytecodeGenerator->newRegister();
- if (args == -1)
- args = temp;
- if (!arg) {
- auto c = Reference::fromConst(this, Primitive::emptyValue().asReturnedValue());
- (void) c.storeOnStack(temp);
- } else {
- RegisterScope scope(this);
- (void) expression(arg).storeOnStack(temp);
+ {
+ RegisterScope scope(this);
+
+ int args = -1;
+ auto push = [this, &argc, &args](AST::ExpressionNode *arg) {
+ int temp = bytecodeGenerator->newRegister();
+ if (args == -1)
+ args = temp;
+ if (!arg) {
+ auto c = Reference::fromConst(this, Value::emptyValue().asReturnedValue());
+ (void) c.storeOnStack(temp);
+ } else {
+ RegisterScope scope(this);
+ Reference r = expression(arg);
+ if (hasError)
+ return;
+ (void) r.storeOnStack(temp);
+ }
+ ++argc;
+ };
+
+ for (; it; it = it->next) {
+ PatternElement *e = it->element;
+ if (e && e->type == PatternElement::SpreadElement)
+ break;
+ for (Elision *elision = it->elision; elision; elision = elision->next)
+ push(nullptr);
+
+ if (!e)
+ continue;
+
+ push(e->initializer);
+ if (hasError)
+ return false;
}
- ++argc;
- };
- for (ElementList *it = ast->elements; it; it = it->next) {
+ if (args == -1) {
+ Q_ASSERT(argc == 0);
+ args = 0;
+ }
- for (Elision *elision = it->elision; elision; elision = elision->next)
- push(nullptr);
+ Instruction::DefineArray call;
+ call.argc = argc;
+ call.args = Moth::StackSlot::createRegister(args);
+ bytecodeGenerator->addInstruction(call);
+ }
- push(it->expression);
- if (hasError)
- return false;
+ if (!it) {
+ _expr.setResult(Reference::fromAccumulator(this));
+ return false;
}
- for (Elision *elision = ast->elision; elision; elision = elision->next)
- push(nullptr);
+ Q_ASSERT(it->element && it->element->type == PatternElement::SpreadElement);
- if (args == -1) {
- Q_ASSERT(argc == 0);
- args = 0;
+ RegisterScope scope(this);
+ Reference array = Reference::fromStackSlot(this);
+ array.storeConsumeAccumulator();
+ Reference index = Reference::storeConstOnStack(this, Encode(argc));
+
+ auto pushAccumulator = [&]() {
+ Reference slot = Reference::fromSubscript(array, index);
+ slot.storeConsumeAccumulator();
+
+ index.loadInAccumulator();
+ Instruction::Increment inc;
+ bytecodeGenerator->addInstruction(inc);
+ index.storeConsumeAccumulator();
+ };
+
+ while (it) {
+ for (Elision *elision = it->elision; elision; elision = elision->next) {
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).loadInAccumulator();
+ pushAccumulator();
+ }
+
+ if (!it->element) {
+ it = it->next;
+ continue;
+ }
+
+ // handle spread element
+ if (it->element->type == PatternElement::SpreadElement) {
+ RegisterScope scope(this);
+
+ Reference iterator = Reference::fromStackSlot(this);
+ Reference iteratorDone = Reference::fromConst(this, Encode(false)).storeOnStack();
+ Reference lhsValue = Reference::fromStackSlot(this);
+
+ // There should be a temporal block, so that variables declared in lhs shadow outside vars.
+ // This block should define a temporal dead zone for those variables, which is not yet implemented.
+ {
+ RegisterScope innerScope(this);
+ Reference expr = expression(it->element->initializer);
+ if (hasError)
+ return false;
+
+ expr.loadInAccumulator();
+ Instruction::GetIterator iteratorObjInstr;
+ iteratorObjInstr.iterator = static_cast<int>(AST::ForEachType::Of);
+ bytecodeGenerator->addInstruction(iteratorObjInstr);
+ iterator.storeConsumeAccumulator();
+ }
+
+ BytecodeGenerator::Label in = bytecodeGenerator->newLabel();
+ BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
+ BytecodeGenerator::Label done = bytecodeGenerator->newLabel();
+
+ {
+ auto cleanup = [this, iterator, iteratorDone]() {
+ iterator.loadInAccumulator();
+ Instruction::IteratorClose close;
+ close.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(close);
+ };
+ ControlFlowLoop flow(this, &end, &in, cleanup);
+ bytecodeGenerator->jump().link(in);
+
+ BytecodeGenerator::Label body = bytecodeGenerator->label();
+
+ lhsValue.loadInAccumulator();
+ pushAccumulator();
+
+ in.link();
+ iterator.loadInAccumulator();
+ Instruction::IteratorNext next;
+ next.value = lhsValue.stackSlot();
+ next.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+ bytecodeGenerator->addJumpInstruction(Instruction::JumpFalse()).link(body);
+ bytecodeGenerator->jump().link(done);
+
+ end.link();
+ }
+
+ done.link();
+ } else {
+ RegisterScope innerScope(this);
+ Reference expr = expression(it->element->initializer);
+ if (hasError)
+ return false;
+
+ expr.loadInAccumulator();
+ pushAccumulator();
+ }
+
+ it = it->next;
}
- Instruction::DefineArray call;
- call.argc = argc;
- call.args = Moth::StackSlot::createRegister(args);
- bytecodeGenerator->addInstruction(call);
+ array.loadInAccumulator();
_expr.setResult(Reference::fromAccumulator(this));
return false;
@@ -666,7 +1192,14 @@ bool Codegen::visit(ArrayMemberExpression *ast)
Reference base = expression(ast->base);
if (hasError)
return false;
+ if (base.isSuper()) {
+ Reference index = expression(ast->expression).storeOnStack();
+ _expr.setResult(Reference::fromSuperProperty(index));
+ return false;
+ }
base = base.storeOnStack();
+ if (hasError)
+ return false;
if (AST::StringLiteral *str = AST::cast<AST::StringLiteral *>(ast->expression)) {
QString s = str->value.toString();
uint arrayIndex = QV4::String::toArrayIndex(s);
@@ -692,6 +1225,7 @@ static QSOperator::Op baseOp(int op)
case QSOperator::InplaceAdd: return QSOperator::Add;
case QSOperator::InplaceLeftShift: return QSOperator::LShift;
case QSOperator::InplaceMod: return QSOperator::Mod;
+ case QSOperator::InplaceExp: return QSOperator::Exp;
case QSOperator::InplaceMul: return QSOperator::Mul;
case QSOperator::InplaceOr: return QSOperator::BitOr;
case QSOperator::InplaceRightShift: return QSOperator::RShift;
@@ -764,19 +1298,21 @@ bool Codegen::visit(BinaryExpression *ast)
_expr.setResult(Reference::fromAccumulator(this));
}
return false;
- }
-
- Reference left = expression(ast->left);
- if (hasError)
- return false;
-
- switch (ast->op) {
- case QSOperator::Or:
- case QSOperator::And:
- Q_UNREACHABLE(); // handled separately above
- break;
+ } else if (ast->op == QSOperator::Assign) {
+ if (AST::Pattern *p = ast->left->patternCast()) {
+ RegisterScope scope(this);
+ Reference right = expression(ast->right).storeOnStack();
+ destructurePattern(p, right);
+ if (!_expr.accept(nx)) {
+ right.loadInAccumulator();
+ _expr.setResult(Reference::fromAccumulator(this));
+ }
+ return false;
+ }
+ Reference left = expression(ast->left);
+ if (hasError)
+ return false;
- case QSOperator::Assign: {
if (!left.isLValue()) {
throwReferenceError(ast->operatorToken, QStringLiteral("left-hand side of assignment operator is not an lvalue"));
return false;
@@ -792,15 +1328,27 @@ bool Codegen::visit(BinaryExpression *ast)
_expr.setResult(left.storeConsumeAccumulator());
else
_expr.setResult(left.storeRetainAccumulator());
- break;
+ return false;
}
+ Reference left = expression(ast->left);
+ if (hasError)
+ return false;
+
+ switch (ast->op) {
+ case QSOperator::Or:
+ case QSOperator::And:
+ case QSOperator::Assign:
+ Q_UNREACHABLE(); // handled separately above
+ break;
+
case QSOperator::InplaceAnd:
case QSOperator::InplaceSub:
case QSOperator::InplaceDiv:
case QSOperator::InplaceAdd:
case QSOperator::InplaceLeftShift:
case QSOperator::InplaceMod:
+ case QSOperator::InplaceExp:
case QSOperator::InplaceMul:
case QSOperator::InplaceOr:
case QSOperator::InplaceRightShift:
@@ -830,7 +1378,7 @@ bool Codegen::visit(BinaryExpression *ast)
case QSOperator::BitAnd:
case QSOperator::BitOr:
case QSOperator::BitXor:
- if (left.isConst()) {
+ if (left.isConstant()) {
Reference right = expression(ast->right);
if (hasError)
return false;
@@ -850,6 +1398,7 @@ bool Codegen::visit(BinaryExpression *ast)
case QSOperator::StrictNotEqual:
case QSOperator::Add:
case QSOperator::Div:
+ case QSOperator::Exp:
case QSOperator::Mod:
case QSOperator::Mul:
case QSOperator::Sub:
@@ -890,7 +1439,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
break;
}
case QSOperator::Sub: {
- if (right.isConst() && right.constant == Encode(int(1))) {
+ if (right.isConstant() && right.constant == Encode(int(1))) {
left.loadInAccumulator();
bytecodeGenerator->addInstruction(Instruction::Decrement());
} else {
@@ -902,6 +1451,14 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
}
+ case QSOperator::Exp: {
+ left = left.storeOnStack();
+ right.loadInAccumulator();
+ Instruction::Exp exp;
+ exp.lhs = left.stackSlot();
+ bytecodeGenerator->addInstruction(exp);
+ break;
+ }
case QSOperator::Mul: {
left = left.storeOnStack();
right.loadInAccumulator();
@@ -927,10 +1484,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
break;
}
case QSOperator::BitAnd:
- if (right.isConst()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
- if (left.isConst()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() & rightAsInt;
+ if (right.isConstant()) {
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
+ if (left.isConstant()) {
+ int result = Value::fromReturnedValue(left.constant).toInt32() & rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -945,10 +1502,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
case QSOperator::BitOr:
- if (right.isConst()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
- if (left.isConst()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() | rightAsInt;
+ if (right.isConstant()) {
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
+ if (left.isConstant()) {
+ int result = Value::fromReturnedValue(left.constant).toInt32() | rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -963,10 +1520,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
case QSOperator::BitXor:
- if (right.isConst()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
- if (left.isConst()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() ^ rightAsInt;
+ if (right.isConstant()) {
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
+ if (left.isConstant()) {
+ int result = Value::fromReturnedValue(left.constant).toInt32() ^ rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -981,10 +1538,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
case QSOperator::URShift:
- if (right.isConst()) {
+ if (right.isConstant()) {
left.loadInAccumulator();
Instruction::UShrConst ushr;
- ushr.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ ushr.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(ushr);
} else {
right.loadInAccumulator();
@@ -994,10 +1551,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
case QSOperator::RShift:
- if (right.isConst()) {
+ if (right.isConstant()) {
left.loadInAccumulator();
Instruction::ShrConst shr;
- shr.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ shr.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(shr);
} else {
right.loadInAccumulator();
@@ -1007,10 +1564,10 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
break;
case QSOperator::LShift:
- if (right.isConst()) {
+ if (right.isConstant()) {
left.loadInAccumulator();
Instruction::ShlConst shl;
- shl.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ shl.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(shl);
} else {
right.loadInAccumulator();
@@ -1146,13 +1703,13 @@ static QSOperator::Op operatorForSwappedOperands(QSOperator::Op oper)
Codegen::Reference Codegen::jumpBinop(QSOperator::Op oper, Reference &left, Reference &right)
{
- if (left.isConst()) {
+ if (left.isConstant()) {
oper = operatorForSwappedOperands(oper);
qSwap(left, right);
}
- if (right.isConst() && (oper == QSOperator::Equal || oper == QSOperator::NotEqual)) {
- Value c = Primitive::fromReturnedValue(right.constant);
+ if (right.isConstant() && (oper == QSOperator::Equal || oper == QSOperator::NotEqual)) {
+ Value c = Value::fromReturnedValue(right.constant);
if (c.isNull() || c.isUndefined()) {
left.loadInAccumulator();
if (oper == QSOperator::Equal) {
@@ -1259,6 +1816,7 @@ bool Codegen::visit(CallExpression *ast)
RegisterScope scope(this);
Reference base = expression(ast->base);
+
if (hasError)
return false;
switch (base.type) {
@@ -1270,15 +1828,52 @@ bool Codegen::visit(CallExpression *ast)
break;
case Reference::Name:
break;
+ case Reference::Super:
+ handleConstruct(base, ast->arguments);
+ return false;
+ case Reference::SuperProperty:
+ break;
default:
base = base.storeOnStack();
break;
}
+ int thisObject = bytecodeGenerator->newRegister();
+ int functionObject = bytecodeGenerator->newRegister();
+
auto calldata = pushArgs(ast->arguments);
if (hasError)
return false;
+ if (calldata.hasSpread) {
+ Reference baseObject = base.baseObject();
+ if (!baseObject.isStackSlot()) {
+ baseObject.storeOnStack(thisObject);
+ baseObject = Reference::fromStackSlot(this, thisObject);
+ }
+ if (!base.isStackSlot()) {
+ base.storeOnStack(functionObject);
+ base = Reference::fromStackSlot(this, functionObject);
+ }
+
+ Instruction::CallWithSpread call;
+ call.func = base.stackSlot();
+ call.thisObject = baseObject.stackSlot();
+ call.argc = calldata.argc;
+ call.argv = calldata.argv;
+ bytecodeGenerator->addInstruction(call);
+
+ _expr.setResult(Reference::fromAccumulator(this));
+ return false;
+
+ }
+
+ handleCall(base, calldata, functionObject, thisObject);
+ return false;
+}
+
+void Codegen::handleCall(Reference &base, Arguments calldata, int slotForFunction, int slotForThisObject)
+{
//### Do we really need all these call instructions? can's we load the callee in a temp?
if (base.type == Reference::QmlScopeObject) {
Instruction::CallScopeObjectProperty call;
@@ -1295,7 +1890,7 @@ bool Codegen::visit(CallExpression *ast)
call.argv = calldata.argv;
bytecodeGenerator->addInstruction(call);
} else if (base.type == Reference::Member) {
- if (useFastLookups) {
+ if (!disable_lookups && useFastLookups) {
Instruction::CallPropertyLookup call;
call.base = base.propertyBase.stackSlot();
call.lookupIndex = registerGetterLookup(base.propertyNameIndex);
@@ -1323,7 +1918,7 @@ bool Codegen::visit(CallExpression *ast)
call.argc = calldata.argc;
call.argv = calldata.argv;
bytecodeGenerator->addInstruction(call);
- } else if (useFastLookups && base.global) {
+ } else if (!disable_lookups && useFastLookups && base.global) {
Instruction::CallGlobalLookup call;
call.index = registerGlobalGetterLookup(base.nameAsIndex());
call.argc = calldata.argc;
@@ -1336,6 +1931,22 @@ bool Codegen::visit(CallExpression *ast)
call.argv = calldata.argv;
bytecodeGenerator->addInstruction(call);
}
+ } else if (base.type == Reference::SuperProperty) {
+ Reference receiver = base.baseObject();
+ if (!base.isStackSlot()) {
+ base.storeOnStack(slotForFunction);
+ base = Reference::fromStackSlot(this, slotForFunction);
+ }
+ if (!receiver.isStackSlot()) {
+ receiver.storeOnStack(slotForThisObject);
+ receiver = Reference::fromStackSlot(this, slotForThisObject);
+ }
+ Instruction::CallWithReceiver call;
+ call.name = base.stackSlot();
+ call.thisObject = receiver.stackSlot();
+ call.argc = calldata.argc;
+ call.argv = calldata.argv;
+ bytecodeGenerator->addInstruction(call);
} else {
Q_ASSERT(base.isStackSlot());
Instruction::CallValue call;
@@ -1346,36 +1957,69 @@ bool Codegen::visit(CallExpression *ast)
}
_expr.setResult(Reference::fromAccumulator(this));
- return false;
}
Codegen::Arguments Codegen::pushArgs(ArgumentList *args)
{
+ bool hasSpread = false;
int argc = 0;
- for (ArgumentList *it = args; it; it = it->next)
+ for (ArgumentList *it = args; it; it = it->next) {
+ if (it->isSpreadElement) {
+ hasSpread = true;
+ ++argc;
+ }
++argc;
+ }
if (!argc)
- return { 0, 0 };
+ return { 0, 0, false };
int calldata = bytecodeGenerator->newRegisterArray(argc);
argc = 0;
for (ArgumentList *it = args; it; it = it->next) {
+ if (it->isSpreadElement) {
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).storeOnStack(calldata + argc);
+ ++argc;
+ }
RegisterScope scope(this);
Reference e = expression(it->expression);
if (hasError)
break;
- if (!argc && !it->next) {
+ if (!argc && !it->next && !hasSpread) {
// avoid copy for functions taking a single argument
if (e.isStackSlot())
- return { 1, e.stackSlot() };
+ return { 1, e.stackSlot(), hasSpread };
}
(void) e.storeOnStack(calldata + argc);
++argc;
}
- return { argc, calldata };
+ return { argc, calldata, hasSpread };
+}
+
+Codegen::Arguments Codegen::pushTemplateArgs(TemplateLiteral *args)
+{
+ int argc = 0;
+ for (TemplateLiteral *it = args; it; it = it->next)
+ ++argc;
+
+ if (!argc)
+ return { 0, 0, false };
+
+ int calldata = bytecodeGenerator->newRegisterArray(argc);
+
+ argc = 0;
+ for (TemplateLiteral *it = args; it && it->expression; it = it->next) {
+ RegisterScope scope(this);
+ Reference e = expression(it->expression);
+ if (hasError)
+ break;
+ (void) e.storeOnStack(calldata + argc);
+ ++argc;
+ }
+
+ return { argc, calldata, false };
}
bool Codegen::visit(ConditionalExpression *ast)
@@ -1413,11 +2057,15 @@ bool Codegen::visit(DeleteExpression *ast)
if (hasError)
return false;
+ RegisterScope scope(this);
Reference expr = expression(ast->expression);
if (hasError)
return false;
switch (expr.type) {
+ case Reference::SuperProperty:
+ // ### this should throw a reference error at runtime.
+ return false;
case Reference::StackSlot:
if (!expr.stackSlotIsLocalOrArgument)
break;
@@ -1444,9 +2092,14 @@ bool Codegen::visit(DeleteExpression *ast)
case Reference::Member: {
//### maybe add a variant where the base can be in the accumulator?
expr = expr.asLValue();
- Instruction::DeleteMember del;
+ Instruction::LoadRuntimeString instr;
+ instr.stringId = expr.propertyNameIndex;
+ bytecodeGenerator->addInstruction(instr);
+ Reference index = Reference::fromStackSlot(this);
+ index.storeConsumeAccumulator();
+ Instruction::DeleteProperty del;
del.base = expr.propertyBase.stackSlot();
- del.member = expr.propertyNameIndex;
+ del.index = index.stackSlot();
bytecodeGenerator->addInstruction(del);
_expr.setResult(Reference::fromAccumulator(this));
return false;
@@ -1454,7 +2107,7 @@ bool Codegen::visit(DeleteExpression *ast)
case Reference::Subscript: {
//### maybe add a variant where the index can be in the accumulator?
expr = expr.asLValue();
- Instruction::DeleteSubscript del;
+ Instruction::DeleteProperty del;
del.base = expr.elementBase;
del.index = expr.elementSubscript.stackSlot();
bytecodeGenerator->addInstruction(del);
@@ -1478,109 +2131,187 @@ bool Codegen::visit(FalseLiteral *)
return false;
}
+bool Codegen::visit(SuperLiteral *)
+{
+ if (hasError)
+ return false;
+
+ _expr.setResult(Reference::fromSuper(this));
+ return false;
+}
+
bool Codegen::visit(FieldMemberExpression *ast)
{
if (hasError)
return false;
+ if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(ast->base)) {
+ if (id->name == QLatin1String("new")) {
+ // new.target
+ Q_ASSERT(ast->name == QLatin1String("target"));
+
+ if (_context->isArrowFunction || _context->contextType == ContextType::Eval) {
+ Reference r = referenceForName(QStringLiteral("new.target"), false);
+ r.isReadonly = true;
+ _expr.setResult(r);
+ return false;
+ }
+
+ Reference r = Reference::fromStackSlot(this, CallData::NewTarget);
+ _expr.setResult(r);
+ return false;
+ }
+ }
+
Reference base = expression(ast->base);
if (hasError)
return false;
+ if (base.isSuper()) {
+ Instruction::LoadRuntimeString load;
+ load.stringId = registerString(ast->name.toString());
+ bytecodeGenerator->addInstruction(load);
+ Reference property = Reference::fromAccumulator(this).storeOnStack();
+ _expr.setResult(Reference::fromSuperProperty(property));
+ return false;
+ }
_expr.setResult(Reference::fromMember(base, ast->name.toString()));
return false;
}
-bool Codegen::visit(FunctionExpression *ast)
+bool Codegen::visit(TaggedTemplate *ast)
{
if (hasError)
return false;
RegisterScope scope(this);
- int function = defineFunction(ast->name.toString(), ast, ast->formals, ast->body ? ast->body->elements : nullptr);
- loadClosure(function);
- _expr.setResult(Reference::fromAccumulator(this));
+ int functionObject = -1, thisObject = -1;
+
+ Reference base = expression(ast->base);
+ if (hasError)
+ return false;
+ switch (base.type) {
+ case Reference::Member:
+ case Reference::Subscript:
+ base = base.asLValue();
+ break;
+ case Reference::Name:
+ break;
+ case Reference::SuperProperty:
+ thisObject = bytecodeGenerator->newRegister();
+ functionObject = bytecodeGenerator->newRegister();
+ break;
+ default:
+ base = base.storeOnStack();
+ break;
+ }
+
+ int arrayTemp = createTemplateArray(ast->templateLiteral);
+ Q_UNUSED(arrayTemp);
+ auto calldata = pushTemplateArgs(ast->templateLiteral);
+ if (hasError)
+ return false;
+ ++calldata.argc;
+ Q_ASSERT(calldata.argv == arrayTemp + 1);
+ --calldata.argv;
+
+ handleCall(base, calldata, functionObject, thisObject);
return false;
}
-Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs)
+int Codegen::createTemplateArray(TemplateLiteral *t)
{
- int scope = 0;
- Context *c = _context;
+ int arrayTemp = bytecodeGenerator->newRegister();
- // skip the innermost context if it's simple (as the runtime won't
- // create a context for it
- if (c->canUseSimpleCall()) {
- Context::Member m = c->findMember(name);
- if (m.type != Context::UndefinedMember) {
- Q_ASSERT((!m.canEscape));
- Reference r = Reference::fromStackSlot(this, m.index, true /*isLocal*/);
- if (name == QLatin1String("arguments") || name == QLatin1String("eval")) {
- r.isArgOrEval = true;
- if (isLhs && c->isStrict)
- // ### add correct source location
- throwSyntaxError(SourceLocation(), QStringLiteral("Variable name may not be eval or arguments in strict mode"));
- }
- return r;
- }
- const int argIdx = c->findArgument(name);
- if (argIdx != -1) {
- Q_ASSERT(!c->argumentsCanEscape && (c->usesArgumentsObject != Context::ArgumentsObjectUsed || c->isStrict));
- return Reference::fromArgument(this, argIdx, _volataleMemoryLocations.isVolatile(name));
- }
- c = c->parent;
- }
+ RegisterScope scope(this);
- while (c->parent) {
- if (c->forceLookupByName())
- goto loadByName;
+ int argc = 0;
+ int args = -1;
+ auto push = [this, &argc, &args](const QStringRef &arg) {
+ int temp = bytecodeGenerator->newRegister();
+ if (args == -1)
+ args = temp;
+ Instruction::LoadRuntimeString instr;
+ instr.stringId = registerString(arg.toString());
+ bytecodeGenerator->addInstruction(instr);
+ Instruction::StoreReg store;
+ store.reg = temp;
+ bytecodeGenerator->addInstruction(store);
- Context::Member m = c->findMember(name);
- if (m.type != Context::UndefinedMember) {
- Reference r = m.canEscape ? Reference::fromScopedLocal(this, m.index, scope)
- : Reference::fromStackSlot(this, m.index, true /*isLocal*/);
- if (name == QLatin1String("arguments") || name == QLatin1String("eval")) {
- r.isArgOrEval = true;
- if (isLhs && c->isStrict)
- // ### add correct source location
- throwSyntaxError(SourceLocation(), QStringLiteral("Variable name may not be eval or arguments in strict mode"));
- }
- return r;
- }
- const int argIdx = c->findArgument(name);
- if (argIdx != -1) {
- if (c->argumentsCanEscape || c->usesArgumentsObject == Context::ArgumentsObjectUsed) {
- int idx = argIdx + c->locals.size();
- return Reference::fromScopedLocal(this, idx, scope);
- } else {
- Q_ASSERT(scope == 0);
- return Reference::fromArgument(this, argIdx, _volataleMemoryLocations.isVolatile(name));
- }
- }
+ ++argc;
+ };
- if (!c->isStrict && c->hasDirectEval)
- goto loadByName;
+ for (TemplateLiteral *it = t; it; it = it->next)
+ push(it->value);
- ++scope;
- c = c->parent;
+ if (args == -1) {
+ Q_ASSERT(argc == 0);
+ args = 0;
}
- {
- // This hook allows implementing QML lookup semantics
- Reference fallback = fallbackNameLookup(name);
- if (fallback.type != Reference::Invalid)
- return fallback;
- }
+ Instruction::DefineArray call;
+ call.argc = argc;
+ call.args = Moth::StackSlot::createRegister(args);
+ bytecodeGenerator->addInstruction(call);
+
+ Instruction::StoreReg store;
+ store.reg = arrayTemp;
+ bytecodeGenerator->addInstruction(store);
+
+ return arrayTemp;
+}
+
+bool Codegen::visit(FunctionExpression *ast)
+{
+ if (hasError)
+ return false;
+
+ RegisterScope scope(this);
- if (!c->parent && !c->forceLookupByName() && _context->compilationMode != EvalCode && c->compilationMode != QmlBinding) {
- Reference r = Reference::fromName(this, name);
- r.global = true;
+ int function = defineFunction(ast->name.toString(), ast, ast->formals, ast->body);
+ if (hasError)
+ return false;
+ loadClosure(function);
+ _expr.setResult(Reference::fromAccumulator(this));
+ return false;
+}
+
+Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs, const SourceLocation &accessLocation)
+{
+ Context::ResolvedName resolved = _context->resolveName(name, accessLocation);
+
+ if (resolved.type == Context::ResolvedName::Local || resolved.type == Context::ResolvedName::Stack
+ || resolved.type == Context::ResolvedName::Import) {
+ if (resolved.isArgOrEval && isLhs)
+ // ### add correct source location
+ throwSyntaxError(SourceLocation(), QStringLiteral("Variable name may not be eval or arguments in strict mode"));
+ Reference r;
+ switch (resolved.type) {
+ case Context::ResolvedName::Local:
+ r = Reference::fromScopedLocal(this, resolved.index, resolved.scope); break;
+ case Context::ResolvedName::Stack:
+ r = Reference::fromStackSlot(this, resolved.index, true /*isLocal*/); break;
+ case Context::ResolvedName::Import:
+ r = Reference::fromImport(this, resolved.index); break;
+ default: Q_UNREACHABLE();
+ }
+ if (r.isStackSlot() && _volatileMemoryLocations.isVolatile(name))
+ r.isVolatile = true;
+ r.isArgOrEval = resolved.isArgOrEval;
+ r.isReferenceToConst = resolved.isConst;
+ r.requiresTDZCheck = resolved.requiresTDZCheck;
+ r.name = name; // used to show correct name at run-time when TDZ check fails.
return r;
}
- // global context or with. Lookup by name
- loadByName:
- return Reference::fromName(this, name);
+ // This hook allows implementing QML lookup semantics
+ Reference fallback = fallbackNameLookup(name);
+ if (fallback.type != Reference::Invalid)
+ return fallback;
+
+ Reference r = Reference::fromName(this, name);
+ r.global = useFastLookups && (resolved.type == Context::ResolvedName::Global);
+ return r;
}
void Codegen::loadClosure(int closureId)
@@ -1605,7 +2336,7 @@ bool Codegen::visit(IdentifierExpression *ast)
if (hasError)
return false;
- _expr.setResult(referenceForName(ast->name.toString(), false));
+ _expr.setResult(referenceForName(ast->name.toString(), false, ast->firstSourceLocation()));
return false;
}
@@ -1618,6 +2349,46 @@ bool Codegen::visit(NestedExpression *ast)
return false;
}
+void Codegen::handleConstruct(const Reference &base, ArgumentList *arguments)
+{
+ Reference constructor;
+ if (base.isSuper()) {
+ Instruction::LoadSuperConstructor super;
+ bytecodeGenerator->addInstruction(super);
+ constructor = Reference::fromAccumulator(this).storeOnStack();
+ } else {
+ constructor = base.storeOnStack();
+ }
+
+ auto calldata = pushArgs(arguments);
+ if (hasError)
+ return;
+
+ if (base.isSuper())
+ Reference::fromStackSlot(this, CallData::NewTarget).loadInAccumulator();
+ else
+ constructor.loadInAccumulator();
+
+ if (calldata.hasSpread) {
+ Instruction::ConstructWithSpread create;
+ create.func = constructor.stackSlot();
+ create.argc = calldata.argc;
+ create.argv = calldata.argv;
+ bytecodeGenerator->addInstruction(create);
+ } else {
+ Instruction::Construct create;
+ create.func = constructor.stackSlot();
+ create.argc = calldata.argc;
+ create.argv = calldata.argv;
+ bytecodeGenerator->addInstruction(create);
+ }
+ if (base.isSuper())
+ // set the result up as the thisObject
+ Reference::fromAccumulator(this).storeOnStack(CallData::This);
+
+ _expr.setResult(Reference::fromAccumulator(this));
+}
+
bool Codegen::visit(NewExpression *ast)
{
if (hasError)
@@ -1628,15 +2399,12 @@ bool Codegen::visit(NewExpression *ast)
Reference base = expression(ast->expression);
if (hasError)
return false;
- //### Maybe create a ConstructA that takes an accumulator?
- base = base.storeOnStack();
+ if (base.isSuper()) {
+ throwSyntaxError(ast->expression->firstSourceLocation(), QStringLiteral("Cannot use new with super."));
+ return false;
+ }
- Instruction::Construct create;
- create.func = base.stackSlot();
- create.argc = 0;
- create.argv = 0;
- bytecodeGenerator->addInstruction(create);
- _expr.setResult(Reference::fromAccumulator(this));
+ handleConstruct(base, nullptr);
return false;
}
@@ -1650,18 +2418,12 @@ bool Codegen::visit(NewMemberExpression *ast)
Reference base = expression(ast->base);
if (hasError)
return false;
- base = base.storeOnStack();
-
- auto calldata = pushArgs(ast->arguments);
- if (hasError)
+ if (base.isSuper()) {
+ throwSyntaxError(ast->base->firstSourceLocation(), QStringLiteral("Cannot use new with super."));
return false;
+ }
- Instruction::Construct create;
- create.func = base.stackSlot();
- create.argc = calldata.argc;
- create.argv = calldata.argv;
- bytecodeGenerator->addInstruction(create);
- _expr.setResult(Reference::fromAccumulator(this));
+ handleConstruct(base, ast->arguments);
return false;
}
@@ -1696,133 +2458,117 @@ bool Codegen::visit(NumericLiteral *ast)
return false;
}
-bool Codegen::visit(ObjectLiteral *ast)
+bool Codegen::visit(ObjectPattern *ast)
{
if (hasError)
return false;
+ QVector<QPair<Reference, ObjectPropertyValue>> computedProperties;
QMap<QString, ObjectPropertyValue> valueMap;
RegisterScope scope(this);
- for (PropertyAssignmentList *it = ast->properties; it; it = it->next) {
- QString name = it->assignment->name->asString();
- if (PropertyNameAndValue *nv = AST::cast<AST::PropertyNameAndValue *>(it->assignment)) {
- Reference value = expression(nv->value);
- if (hasError)
- return false;
-
- ObjectPropertyValue &v = valueMap[name];
- if (v.hasGetter() || v.hasSetter() || (_context->isStrict && v.rvalue.isValid())) {
- throwSyntaxError(nv->lastSourceLocation(),
- QStringLiteral("Illegal duplicate key '%1' in object literal").arg(name));
- return false;
- }
+ QStringList members;
- v.rvalue = value.storeOnStack();
- } else if (PropertyGetterSetter *gs = AST::cast<AST::PropertyGetterSetter *>(it->assignment)) {
- const int function = defineFunction(name, gs, gs->formals, gs->functionBody ? gs->functionBody->elements : nullptr);
- ObjectPropertyValue &v = valueMap[name];
- if (v.rvalue.isValid() ||
- (gs->type == PropertyGetterSetter::Getter && v.hasGetter()) ||
- (gs->type == PropertyGetterSetter::Setter && v.hasSetter())) {
- throwSyntaxError(gs->lastSourceLocation(),
- QStringLiteral("Illegal duplicate key '%1' in object literal").arg(name));
- return false;
- }
- if (gs->type == PropertyGetterSetter::Getter)
- v.getter = function;
- else
- v.setter = function;
- } else {
- Q_UNREACHABLE();
- }
- }
-
- QVector<QString> nonArrayKey, arrayKeyWithValue, arrayKeyWithGetterSetter;
- bool needSparseArray = false; // set to true if any array index is bigger than 16
-
- for (QMap<QString, ObjectPropertyValue>::iterator it = valueMap.begin(), eit = valueMap.end();
- it != eit; ++it) {
- QString name = it.key();
- uint keyAsIndex = QV4::String::toArrayIndex(name);
- if (keyAsIndex != std::numeric_limits<uint>::max()) {
- it->keyAsIndex = keyAsIndex;
- if (keyAsIndex > 16)
- needSparseArray = true;
- if (it->hasSetter() || it->hasGetter())
- arrayKeyWithGetterSetter.append(name);
- else
- arrayKeyWithValue.append(name);
- } else {
- nonArrayKey.append(name);
- }
- }
-
- int args = -1;
- auto push = [this, &args](const Reference &arg) {
+ int argc = 0;
+ int args = 0;
+ auto push = [this, &args, &argc](const Reference &arg) {
int temp = bytecodeGenerator->newRegister();
- if (args == -1)
+ if (argc == 0)
args = temp;
(void) arg.storeOnStack(temp);
+ ++argc;
};
- QVector<QV4::Compiler::JSUnitGenerator::MemberInfo> members;
+ PatternPropertyList *it = ast->properties;
+ for (; it; it = it->next) {
+ PatternProperty *p = it->property;
+ AST::ComputedPropertyName *cname = AST::cast<AST::ComputedPropertyName *>(p->name);
+ if (cname || p->type != PatternProperty::Literal)
+ break;
+ QString name = p->name->asString();
+ uint arrayIndex = QV4::String::toArrayIndex(name);
+ if (arrayIndex != UINT_MAX)
+ break;
+ if (members.contains(name))
+ break;
+ members.append(name);
- Reference acc = Reference::fromAccumulator(this);
- // generate the key/value pairs
- for (const QString &key : qAsConst(nonArrayKey)) {
- const ObjectPropertyValue &prop = valueMap[key];
-
- if (prop.hasGetter() || prop.hasSetter()) {
- Q_ASSERT(!prop.rvalue.isValid());
- loadClosure(prop.getter);
- push(acc);
- loadClosure(prop.setter);
- push(acc);
- members.append({ key, true });
- } else {
- Q_ASSERT(prop.rvalue.isValid());
- push(prop.rvalue);
- members.append({ key, false });
+ {
+ RegisterScope innerScope(this);
+ Reference value = expression(p->initializer);
+ if (hasError)
+ return false;
+ value.loadInAccumulator();
}
- }
-
- // generate array entries with values
- for (const QString &key : qAsConst(arrayKeyWithValue)) {
- const ObjectPropertyValue &prop = valueMap[key];
- Q_ASSERT(!prop.hasGetter() && !prop.hasSetter());
- push(Reference::fromConst(this, Encode(prop.keyAsIndex)));
- push(prop.rvalue);
- }
-
- // generate array entries with both a value and a setter
- for (const QString &key : qAsConst(arrayKeyWithGetterSetter)) {
- const ObjectPropertyValue &prop = valueMap[key];
- Q_ASSERT(!prop.rvalue.isValid());
- push(Reference::fromConst(this, Encode(prop.keyAsIndex)));
- loadClosure(prop.getter);
- push(acc);
- loadClosure(prop.setter);
- push(acc);
+ push(Reference::fromAccumulator(this));
}
int classId = jsUnitGenerator->registerJSClass(members);
- uint arrayGetterSetterCountAndFlags = arrayKeyWithGetterSetter.size();
- arrayGetterSetterCountAndFlags |= needSparseArray << 30;
-
- if (args == -1)
- args = 0;
+ // handle complex property setters
+ for (; it; it = it->next) {
+ PatternProperty *p = it->property;
+ AST::ComputedPropertyName *cname = AST::cast<AST::ComputedPropertyName *>(p->name);
+ ObjectLiteralArgument argType = ObjectLiteralArgument::Value;
+ if (p->type == PatternProperty::Method)
+ argType = ObjectLiteralArgument::Method;
+ else if (p->type == PatternProperty::Getter)
+ argType = ObjectLiteralArgument::Getter;
+ else if (p->type == PatternProperty::Setter)
+ argType = ObjectLiteralArgument::Setter;
+
+ Reference::fromConst(this, Encode(int(argType))).loadInAccumulator();
+ push(Reference::fromAccumulator(this));
+
+ if (cname) {
+ RegisterScope innerScope(this);
+ Reference name = expression(cname->expression);
+ if (hasError)
+ return false;
+ name.loadInAccumulator();
+ } else {
+ QString name = p->name->asString();
+#if 0
+ uint arrayIndex = QV4::String::toArrayIndex(name);
+ if (arrayIndex != UINT_MAX) {
+ Reference::fromConst(this, Encode(arrayIndex)).loadInAccumulator();
+ } else
+#endif
+ {
+ Instruction::LoadRuntimeString instr;
+ instr.stringId = registerString(name);
+ bytecodeGenerator->addInstruction(instr);
+ }
+ }
+ push(Reference::fromAccumulator(this));
+ {
+ RegisterScope innerScope(this);
+ if (p->type != PatternProperty::Literal) {
+ // need to get the closure id for the method
+ FunctionExpression *f = p->initializer->asFunctionDefinition();
+ Q_ASSERT(f);
+ int function = defineFunction(f->name.toString(), f, f->formals, f->body);
+ if (hasError)
+ return false;
+ Reference::fromConst(this, Encode(function)).loadInAccumulator();
+ } else {
+ Reference value = expression(p->initializer);
+ if (hasError)
+ return false;
+ value.loadInAccumulator();
+ }
+ }
+ push(Reference::fromAccumulator(this));
+ }
Instruction::DefineObjectLiteral call;
call.internalClassId = classId;
- call.arrayValueCount = arrayKeyWithValue.size();
- call.arrayGetterSetterCountAndFlags = arrayGetterSetterCountAndFlags;
+ call.argc = argc;
call.args = Moth::StackSlot::createRegister(args);
bytecodeGenerator->addInstruction(call);
-
- _expr.setResult(Reference::fromAccumulator(this));
+ Reference result = Reference::fromAccumulator(this);
+ _expr.setResult(result);
return false;
}
@@ -1933,11 +2679,60 @@ bool Codegen::visit(StringLiteral *ast)
return false;
}
+bool Codegen::visit(TemplateLiteral *ast)
+{
+ if (hasError)
+ return false;
+
+ Instruction::LoadRuntimeString instr;
+ instr.stringId = registerString(ast->value.toString());
+ bytecodeGenerator->addInstruction(instr);
+
+ if (ast->expression) {
+ RegisterScope scope(this);
+ int temp = bytecodeGenerator->newRegister();
+ Instruction::StoreReg store;
+ store.reg = temp;
+ bytecodeGenerator->addInstruction(store);
+
+ Reference expr = expression(ast->expression);
+
+ if (ast->next) {
+ int temp2 = bytecodeGenerator->newRegister();
+ expr.storeOnStack(temp2);
+ visit(ast->next);
+
+ Instruction::Add instr;
+ instr.lhs = temp2;
+ bytecodeGenerator->addInstruction(instr);
+ } else {
+ expr.loadInAccumulator();
+ }
+
+ Instruction::Add instr;
+ instr.lhs = temp;
+ bytecodeGenerator->addInstruction(instr);
+ }
+
+ auto r = Reference::fromAccumulator(this);
+ r.isReadonly = true;
+
+ _expr.setResult(r);
+ return false;
+
+}
+
bool Codegen::visit(ThisExpression *)
{
if (hasError)
return false;
+ if (_context->isArrowFunction) {
+ Reference r = referenceForName(QStringLiteral("this"), false);
+ r.isReadonly = true;
+ _expr.setResult(r);
+ return false;
+ }
_expr.setResult(Reference::fromThis(this));
return false;
}
@@ -2023,13 +2818,79 @@ bool Codegen::visit(FunctionDeclaration * ast)
RegisterScope scope(this);
- if (_context->compilationMode == QmlBinding)
- Reference::fromName(this, ast->name.toString()).loadInAccumulator();
+ if (_functionContext->contextType == ContextType::Binding)
+ referenceForName(ast->name.toString(), true).loadInAccumulator();
_expr.accept(nx);
return false;
}
-static bool endsWithReturn(Node *node)
+bool Codegen::visit(YieldExpression *ast)
+{
+ if (inFormalParameterList) {
+ throwSyntaxError(ast->firstSourceLocation(), QLatin1String("yield is not allowed inside parameter lists"));
+ return false;
+ }
+
+ RegisterScope scope(this);
+ Reference expr = ast->expression ? expression(ast->expression) : Reference::fromConst(this, Encode::undefined());
+ if (hasError)
+ return false;
+
+ Reference acc = Reference::fromAccumulator(this);
+
+ if (ast->isYieldStar) {
+ Reference iterator = Reference::fromStackSlot(this);
+ Reference lhsValue = Reference::fromConst(this, Encode::undefined()).storeOnStack();
+
+ expr.loadInAccumulator();
+ Instruction::GetIterator getIterator;
+ getIterator.iterator = static_cast<int>(AST::ForEachType::Of);
+ bytecodeGenerator->addInstruction(getIterator);
+ iterator.storeConsumeAccumulator();
+ Instruction::LoadUndefined load;
+ bytecodeGenerator->addInstruction(load);
+
+ BytecodeGenerator::Label in = bytecodeGenerator->newLabel();
+ bytecodeGenerator->jump().link(in);
+
+ BytecodeGenerator::Label loop = bytecodeGenerator->label();
+
+ lhsValue.loadInAccumulator();
+ Instruction::YieldStar yield;
+ bytecodeGenerator->addInstruction(yield);
+
+ in.link();
+
+ Instruction::IteratorNextForYieldStar next;
+ next.object = lhsValue.stackSlot();
+ next.iterator = iterator.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+
+ BytecodeGenerator::Jump done = bytecodeGenerator->jumpTrue();
+ bytecodeGenerator->jumpNotUndefined().link(loop);
+ lhsValue.loadInAccumulator();
+ emitReturn(acc);
+
+
+ done.link();
+
+ lhsValue.loadInAccumulator();
+ _expr.setResult(acc);
+ return false;
+ }
+
+ expr.loadInAccumulator();
+ Instruction::Yield yield;
+ bytecodeGenerator->addInstruction(yield);
+ Instruction::Resume resume;
+ BytecodeGenerator::Jump jump = bytecodeGenerator->addJumpInstruction(resume);
+ emitReturn(acc);
+ jump.link();
+ _expr.setResult(acc);
+ return false;
+}
+
+static bool endsWithReturn(Module *module, Node *node)
{
if (!node)
return false;
@@ -2038,32 +2899,29 @@ static bool endsWithReturn(Node *node)
if (AST::cast<ThrowStatement *>(node))
return true;
if (Program *p = AST::cast<Program *>(node))
- return endsWithReturn(p->elements);
- if (SourceElements *se = AST::cast<SourceElements *>(node)) {
- while (se->next)
- se = se->next;
- return endsWithReturn(se->element);
- }
- if (StatementSourceElement *sse = AST::cast<StatementSourceElement *>(node))
- return endsWithReturn(sse->statement);
+ return endsWithReturn(module, p->statements);
if (StatementList *sl = AST::cast<StatementList *>(node)) {
while (sl->next)
sl = sl->next;
- return endsWithReturn(sl->statement);
+ return endsWithReturn(module, sl->statement);
+ }
+ if (Block *b = AST::cast<Block *>(node)) {
+ Context *blockContext = module->contextMap.value(node);
+ if (blockContext->requiresExecutionContext)
+ // we need to emit a return statement here, because of the
+ // unwind handler
+ return false;
+ return endsWithReturn(module, b->statements);
}
- if (Block *b = AST::cast<Block *>(node))
- return endsWithReturn(b->statements);
if (IfStatement *is = AST::cast<IfStatement *>(node))
- return is->ko && endsWithReturn(is->ok) && endsWithReturn(is->ko);
+ return is->ko && endsWithReturn(module, is->ok) && endsWithReturn(module, is->ko);
return false;
}
int Codegen::defineFunction(const QString &name, AST::Node *ast,
AST::FormalParameterList *formals,
- AST::SourceElements *body)
+ AST::StatementList *body)
{
- Q_UNUSED(formals);
-
enterContext(ast);
if (_context->functionIndex >= 0)
@@ -2074,7 +2932,15 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
_module->functions.append(_context);
_context->functionIndex = _module->functions.count() - 1;
- _context->hasDirectEval |= (_context->compilationMode == EvalCode || _context->compilationMode == GlobalCode || _module->debugMode); // Conditional breakpoints are like eval in the function
+ Context *savedFunctionContext = _functionContext;
+ _functionContext = _context;
+ ControlFlow *savedControlFlow = controlFlow;
+ controlFlow = nullptr;
+
+ if (_context->contextType == ContextType::Global) {
+ _module->blocks.append(_context);
+ _context->blockIndex = _module->blocks.count() - 1;
+ }
if (_module->debugMode) // allow the debugger to see overwritten arguments
_context->argumentsCanEscape = true;
@@ -2084,132 +2950,104 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
// at all, because if the onSignal is a signal handler, the user is actually making it explicit
// that the binding is a function, so we should execute that. However, we don't know that during
// AOT compilation, so mark the surrounding function as only-returning-a-closure.
- _context->returnsClosure = cast<ExpressionStatement *>(ast) && cast<FunctionExpression *>(cast<ExpressionStatement *>(ast)->expression);
+ _context->returnsClosure = body && body->statement && cast<ExpressionStatement *>(body->statement) && cast<FunctionExpression *>(cast<ExpressionStatement *>(body->statement)->expression);
BytecodeGenerator bytecode(_context->line, _module->debugMode);
BytecodeGenerator *savedBytecodeGenerator;
savedBytecodeGenerator = bytecodeGenerator;
bytecodeGenerator = &bytecode;
bytecodeGenerator->setLocation(ast->firstSourceLocation());
+ BytecodeGenerator::Label *savedReturnLabel = _returnLabel;
+ _returnLabel = nullptr;
+
+ bool savedFunctionEndsWithReturn = functionEndsWithReturn;
+ functionEndsWithReturn = endsWithReturn(_module, body);
// reserve the js stack frame (Context & js Function & accumulator)
bytecodeGenerator->newRegisterArray(sizeof(CallData)/sizeof(Value) - 1 + _context->arguments.size());
+ bool _inFormalParameterList = false;
+ qSwap(_inFormalParameterList, inFormalParameterList);
+
int returnAddress = -1;
- bool _requiresReturnValue = (_context->compilationMode == QmlBinding || _context->compilationMode == EvalCode || _context->compilationMode == GlobalCode);
+ bool _requiresReturnValue = _context->requiresImplicitReturnValue();
qSwap(requiresReturnValue, _requiresReturnValue);
- if (requiresReturnValue)
- returnAddress = bytecodeGenerator->newRegister();
- if (!_context->parent || _context->usesArgumentsObject == Context::ArgumentsObjectUnknown)
- _context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
- if (_context->usesArgumentsObject == Context::ArgumentsObjectUsed)
- _context->addLocalVar(QStringLiteral("arguments"), Context::VariableDeclaration, AST::VariableDeclaration::FunctionScope);
-
- bool allVarsEscape = _context->hasWith || _context->hasTry || _context->hasDirectEval;
- bool needsCallContext = false;
- const QLatin1String exprForOn("expression for on");
- if (!_context->canUseSimpleCall() && _context->compilationMode != GlobalCode && (_context->compilationMode != EvalCode || _context->isStrict))
- needsCallContext = true;
- else if (_context->compilationMode == QmlBinding && name.length() > exprForOn.size() && name.startsWith(exprForOn) && name.at(exprForOn.size()).isUpper())
- // we don't really need this for bindings, but we do for signal handlers, and we don't know if the code is a signal handler or not.
- needsCallContext = true;
- if (needsCallContext) {
- Instruction::CreateCallContext createContext;
- bytecodeGenerator->addInstruction(createContext);
- }
-
- // variables in global code are properties of the global context object, not locals as with other functions.
- if (_context->compilationMode == FunctionCode || _context->compilationMode == QmlBinding) {
- for (Context::MemberMap::iterator it = _context->members.begin(), end = _context->members.end(); it != end; ++it) {
- const QString &local = it.key();
- if (allVarsEscape)
- it->canEscape = true;
- if (it->canEscape) {
- it->index = _context->locals.size();
- _context->locals.append(local);
- if (it->type == Context::ThisFunctionName) {
- // move the name from the stack to the call context
- Instruction::LoadReg load;
- load.reg = CallData::Function;
- bytecodeGenerator->addInstruction(load);
- Instruction::StoreLocal store;
- store.index = it->index;
- bytecodeGenerator->addInstruction(store);
- }
- } else {
- if (it->type == Context::ThisFunctionName)
- it->index = CallData::Function;
- else
- it->index = bytecodeGenerator->newRegister();
- }
- }
- } else {
- for (Context::MemberMap::const_iterator it = _context->members.constBegin(), cend = _context->members.constEnd(); it != cend; ++it) {
- const QString &local = it.key();
+ returnAddress = bytecodeGenerator->newRegister();
+ qSwap(_returnAddress, returnAddress);
- Instruction::DeclareVar declareVar;
- declareVar.isDeletable = false;
- declareVar.varName = registerString(local);
- bytecodeGenerator->addInstruction(declareVar);
- }
+ // register the lexical scope for global code
+ if (!_context->parent && _context->requiresExecutionContext) {
+ _module->blocks.append(_context);
+ _context->blockIndex = _module->blocks.count() - 1;
}
- qSwap(_returnAddress, returnAddress);
- for (const Context::Member &member : qAsConst(_context->members)) {
- if (member.function) {
- const int function = defineFunction(member.function->name.toString(), member.function, member.function->formals,
- member.function->body ? member.function->body->elements : nullptr);
- loadClosure(function);
- if (! _context->parent) {
- Reference::fromName(this, member.function->name.toString()).storeConsumeAccumulator();
- } else {
- Q_ASSERT(member.index >= 0);
- Reference local = member.canEscape ? Reference::fromScopedLocal(this, member.index, 0)
- : Reference::fromStackSlot(this, member.index, true);
- local.storeConsumeAccumulator();
- }
+ RegisterScope registerScope(this);
+ _context->emitBlockHeader(this);
+
+ inFormalParameterList = true;
+ int argc = 0;
+ while (formals) {
+ PatternElement *e = formals->element;
+ if (!e) {
+ if (!formals->next)
+ // trailing comma
+ break;
+ Q_UNREACHABLE();
}
- }
- if (_context->usesArgumentsObject == Context::ArgumentsObjectUsed) {
- if (_context->isStrict) {
- Instruction::CreateUnmappedArgumentsObject setup;
- bytecodeGenerator->addInstruction(setup);
+
+ Reference arg = referenceForName(e->bindingIdentifier.toString(), true);
+ if (e->type == PatternElement::RestElement) {
+ Q_ASSERT(!formals->next);
+ Instruction::CreateRestParameter rest;
+ rest.argIndex = argc;
+ bytecodeGenerator->addInstruction(rest);
+ arg.storeConsumeAccumulator();
} else {
- Instruction::CreateMappedArgumentsObject setup;
- bytecodeGenerator->addInstruction(setup);
+ if (e->bindingTarget || e->initializer) {
+ initializeAndDestructureBindingElement(e, arg);
+ if (hasError)
+ break;
+ }
}
- referenceForName(QStringLiteral("arguments"), false).storeConsumeAccumulator();
+ formals = formals->next;
+ ++argc;
}
- if (_context->usesThis && !_context->isStrict) {
- // make sure we convert this to an object
- Instruction::ConvertThisToObject convert;
- bytecodeGenerator->addInstruction(convert);
+ inFormalParameterList = false;
+
+ if (_context->isGenerator) {
+ Instruction::Yield yield;
+ bytecodeGenerator->addInstruction(yield);
}
beginFunctionBodyHook();
- sourceElements(body);
+ statementList(body);
- if (hasError || !endsWithReturn(body)) {
- bytecodeGenerator->setLocation(ast->lastSourceLocation());
- if (requiresReturnValue) {
- if (_returnAddress >= 0) {
- Instruction::LoadReg load;
- load.reg = Moth::StackSlot::createRegister(_returnAddress);
- bytecodeGenerator->addInstruction(load);
- }
+ bytecodeGenerator->setLocation(ast->lastSourceLocation());
+ _context->emitBlockFooter(this);
+
+ if (_returnLabel || hasError || !functionEndsWithReturn) {
+ if (_returnLabel)
+ _returnLabel->link();
+
+ if (_returnLabel || requiresReturnValue) {
+ Instruction::LoadReg load;
+ load.reg = Moth::StackSlot::createRegister(_returnAddress);
+ bytecodeGenerator->addInstruction(load);
} else {
Reference::fromConst(this, Encode::undefined()).loadInAccumulator();
}
+
bytecodeGenerator->addInstruction(Instruction::Ret());
}
+ Q_ASSERT(_context == _functionContext);
bytecodeGenerator->finalize(_context);
- _context->registerCount = bytecodeGenerator->registerCount();
+ _context->registerCountInFunction = bytecodeGenerator->registerCount();
static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
if (showCode) {
qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
- << "register count" << _context->registerCount;
+ << "register count" << _context->registerCountInFunction << "implicit return" << requiresReturnValue;
QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
_context->line, _context->lineNumberMapping);
qDebug();
@@ -2217,29 +3055,17 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
qSwap(_returnAddress, returnAddress);
qSwap(requiresReturnValue, _requiresReturnValue);
+ qSwap(_inFormalParameterList, inFormalParameterList);
bytecodeGenerator = savedBytecodeGenerator;
+ delete _returnLabel;
+ _returnLabel = savedReturnLabel;
+ controlFlow = savedControlFlow;
+ functionEndsWithReturn = savedFunctionEndsWithReturn;
+ _functionContext = savedFunctionContext;
return leaveContext();
}
-bool Codegen::visit(FunctionSourceElement *ast)
-{
- if (hasError)
- return false;
-
- statement(ast->declaration);
- return false;
-}
-
-bool Codegen::visit(StatementSourceElement *ast)
-{
- if (hasError)
- return false;
-
- statement(ast->statement);
- return false;
-}
-
bool Codegen::visit(Block *ast)
{
if (hasError)
@@ -2247,6 +3073,7 @@ bool Codegen::visit(Block *ast)
RegisterScope scope(this);
+ ControlFlowBlock controlFlow(this, ast);
statementList(ast->statements);
return false;
}
@@ -2256,13 +3083,13 @@ bool Codegen::visit(BreakStatement *ast)
if (hasError)
return false;
- if (!_context->controlFlow) {
+ if (!controlFlow) {
throwSyntaxError(ast->lastSourceLocation(), QStringLiteral("Break outside of loop"));
return false;
}
- ControlFlow::Handler h = _context->controlFlow->getHandler(ControlFlow::Break, ast->label.toString());
- if (h.type == ControlFlow::Invalid) {
+ ControlFlow::UnwindTarget target = controlFlow->unwindTarget(ControlFlow::Break, ast->label.toString());
+ if (!target.linkLabel.isValid()) {
if (ast->label.isEmpty())
throwSyntaxError(ast->lastSourceLocation(), QStringLiteral("Break outside of loop"));
else
@@ -2270,7 +3097,7 @@ bool Codegen::visit(BreakStatement *ast)
return false;
}
- _context->controlFlow->jumpToHandler(h);
+ bytecodeGenerator->unwindToLabel(target.unwindLevel, target.linkLabel);
return false;
}
@@ -2282,13 +3109,13 @@ bool Codegen::visit(ContinueStatement *ast)
RegisterScope scope(this);
- if (!_context->controlFlow) {
+ if (!controlFlow) {
throwSyntaxError(ast->lastSourceLocation(), QStringLiteral("Continue outside of loop"));
return false;
}
- ControlFlow::Handler h = _context->controlFlow->getHandler(ControlFlow::Continue, ast->label.toString());
- if (h.type == ControlFlow::Invalid) {
+ ControlFlow::UnwindTarget target = controlFlow->unwindTarget(ControlFlow::Continue, ast->label.toString());
+ if (!target.linkLabel.isValid()) {
if (ast->label.isEmpty())
throwSyntaxError(ast->lastSourceLocation(), QStringLiteral("Undefined label '%1'").arg(ast->label.toString()));
else
@@ -2296,7 +3123,7 @@ bool Codegen::visit(ContinueStatement *ast)
return false;
}
- _context->controlFlow->jumpToHandler(h);
+ bytecodeGenerator->unwindToLabel(target.unwindLevel, target.linkLabel);
return false;
}
@@ -2370,45 +3197,88 @@ bool Codegen::visit(ForEachStatement *ast)
RegisterScope scope(this);
- Reference nextIterObj = Reference::fromStackSlot(this);
- Reference iterObj = Reference::fromStackSlot(this);
- Reference expr = expression(ast->expression);
- if (hasError)
- return true;
+ Reference iterator = Reference::fromStackSlot(this);
+ Reference iteratorDone = Reference::fromConst(this, Encode(false)).storeOnStack();
+ Reference lhsValue = Reference::fromStackSlot(this);
- expr.loadInAccumulator();
- Instruction::ForeachIteratorObject iteratorObjInstr;
- bytecodeGenerator->addInstruction(iteratorObjInstr);
- iterObj.storeConsumeAccumulator();
+ // There should be a temporal block, so that variables declared in lhs shadow outside vars.
+ // This block should define a temporal dead zone for those variables.
+ {
+ RegisterScope innerScope(this);
+ ControlFlowBlock controlFlow(this, ast);
+ Reference expr = expression(ast->expression);
+ if (hasError)
+ return true;
- Reference lhs = expression(ast->initialiser).asLValue();
+ expr.loadInAccumulator();
+ Instruction::GetIterator iteratorObjInstr;
+ iteratorObjInstr.iterator = static_cast<int>(ast->type);
+ bytecodeGenerator->addInstruction(iteratorObjInstr);
+ iterator.storeConsumeAccumulator();
+ }
BytecodeGenerator::Label in = bytecodeGenerator->newLabel();
BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
+ BytecodeGenerator::Label done = bytecodeGenerator->newLabel();
- bytecodeGenerator->jump().link(in);
-
- ControlFlowLoop flow(this, &end, &in);
-
- BytecodeGenerator::Label body = bytecodeGenerator->label();
-
- nextIterObj.loadInAccumulator();
- lhs.storeConsumeAccumulator();
-
- statement(ast->statement);
- setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
+ {
+ auto cleanup = [ast, iterator, iteratorDone, this]() {
+ if (ast->type == ForEachType::Of) {
+ iterator.loadInAccumulator();
+ Instruction::IteratorClose close;
+ close.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(close);
+ }
+ };
+ ControlFlowLoop flow(this, &end, &in, cleanup);
+ bytecodeGenerator->jump().link(in);
+
+ BytecodeGenerator::Label body = bytecodeGenerator->label();
+
+ // each iteration gets it's own context, as per spec
+ {
+ RegisterScope innerScope(this);
+ ControlFlowBlock controlFlow(this, ast);
+
+ if (ExpressionNode *e = ast->lhs->expressionCast()) {
+ if (AST::Pattern *p = e->patternCast()) {
+ RegisterScope scope(this);
+ destructurePattern(p, lhsValue);
+ } else {
+ Reference lhs = expression(e);
+ if (hasError)
+ goto error;
+ lhs = lhs.asLValue();
+ lhsValue.loadInAccumulator();
+ lhs.storeConsumeAccumulator();
+ }
+ } else if (PatternElement *p = AST::cast<PatternElement *>(ast->lhs)) {
+ initializeAndDestructureBindingElement(p, lhsValue, /*isDefinition =*/ true);
+ if (hasError)
+ goto error;
+ } else {
+ Q_UNREACHABLE();
+ }
- in.link();
+ statement(ast->statement);
+ setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
- iterObj.loadInAccumulator();
- Instruction::ForeachNextPropertyName nextPropInstr;
- bytecodeGenerator->addInstruction(nextPropInstr);
- nextIterObj.storeConsumeAccumulator();
+ }
- Reference::fromConst(this, QV4::Encode::null()).loadInAccumulator();
- bytecodeGenerator->jumpStrictNotEqual(nextIterObj.stackSlot(), body);
+ error:
+ in.link();
+ iterator.loadInAccumulator();
+ Instruction::IteratorNext next;
+ next.value = lhsValue.stackSlot();
+ next.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+ bytecodeGenerator->addJumpInstruction(Instruction::JumpFalse()).link(body);
+ bytecodeGenerator->jump().link(done);
+
+ end.link();
+ }
- end.link();
+ done.link();
return false;
}
@@ -2420,7 +3290,12 @@ bool Codegen::visit(ForStatement *ast)
RegisterScope scope(this);
- statement(ast->initialiser);
+ ControlFlowBlock controlFlow(this, ast);
+
+ if (ast->initialiser)
+ statement(ast->initialiser);
+ else if (ast->declarations)
+ variableDeclarationList(ast->declarations);
BytecodeGenerator::Label cond = bytecodeGenerator->label();
BytecodeGenerator::Label body = bytecodeGenerator->newLabel();
@@ -2436,6 +3311,10 @@ bool Codegen::visit(ForStatement *ast)
setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
step.link();
+ if (_context->requiresExecutionContext) {
+ Instruction::CloneBlockContext clone;
+ bytecodeGenerator->addInstruction(clone);
+ }
statement(ast->expression);
bytecodeGenerator->jump().link(cond);
@@ -2458,7 +3337,7 @@ bool Codegen::visit(IfStatement *ast)
trueLabel.link();
statement(ast->ok);
if (ast->ko) {
- if (endsWithReturn(ast)) {
+ if (endsWithReturn(_module, ast)) {
falseLabel.link();
statement(ast->ko);
} else {
@@ -2482,7 +3361,7 @@ bool Codegen::visit(LabelledStatement *ast)
RegisterScope scope(this);
// check that no outer loop contains the label
- ControlFlow *l = _context->controlFlow;
+ ControlFlow *l = controlFlow;
while (l) {
if (l->label() == ast->label) {
QString error = QString(QStringLiteral("Label '%1' has already been declared")).arg(ast->label.toString());
@@ -2497,9 +3376,7 @@ bool Codegen::visit(LabelledStatement *ast)
AST::cast<AST::WhileStatement *>(ast->statement) ||
AST::cast<AST::DoWhileStatement *>(ast->statement) ||
AST::cast<AST::ForStatement *>(ast->statement) ||
- AST::cast<AST::ForEachStatement *>(ast->statement) ||
- AST::cast<AST::LocalForStatement *>(ast->statement) ||
- AST::cast<AST::LocalForEachStatement *>(ast->statement)) {
+ AST::cast<AST::ForEachStatement *>(ast->statement)) {
statement(ast->statement); // labelledStatement will be associated with the ast->statement's loop.
} else {
BytecodeGenerator::Label breakLabel = bytecodeGenerator->newLabel();
@@ -2511,85 +3388,17 @@ bool Codegen::visit(LabelledStatement *ast)
return false;
}
-bool Codegen::visit(LocalForEachStatement *ast)
-{
- if (hasError)
- return true;
-
- RegisterScope scope(this);
-
- Reference nextIterObj = Reference::fromStackSlot(this);
- Reference iterObj = Reference::fromStackSlot(this);
- Reference expr = expression(ast->expression);
- if (hasError)
- return true;
-
- variableDeclaration(ast->declaration);
-
- expr.loadInAccumulator();
- Instruction::ForeachIteratorObject iteratorObjInstr;
- bytecodeGenerator->addInstruction(iteratorObjInstr);
- iterObj.storeConsumeAccumulator();
-
- BytecodeGenerator::Label in = bytecodeGenerator->newLabel();
- BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
-
- bytecodeGenerator->jump().link(in);
- ControlFlowLoop flow(this, &end, &in);
-
- BytecodeGenerator::Label body = bytecodeGenerator->label();
-
- Reference it = referenceForName(ast->declaration->name.toString(), true).asLValue();
-
- nextIterObj.loadInAccumulator();
- it.storeConsumeAccumulator();
-
- statement(ast->statement);
- setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
-
- in.link();
-
- iterObj.loadInAccumulator();
- Instruction::ForeachNextPropertyName nextPropInstr;
- bytecodeGenerator->addInstruction(nextPropInstr);
- nextIterObj.storeConsumeAccumulator();
-
- Reference::fromConst(this, QV4::Encode::null()).loadInAccumulator();
- bytecodeGenerator->jumpStrictNotEqual(nextIterObj.stackSlot(), body);
-
- end.link();
-
- return false;
-}
-
-bool Codegen::visit(LocalForStatement *ast)
+void Codegen::emitReturn(const Reference &expr)
{
- if (hasError)
- return true;
-
- RegisterScope scope(this);
-
- variableDeclarationList(ast->declarations);
-
- BytecodeGenerator::Label cond = bytecodeGenerator->label();
- BytecodeGenerator::Label body = bytecodeGenerator->newLabel();
- BytecodeGenerator::Label step = bytecodeGenerator->newLabel();
- BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
-
- ControlFlowLoop flow(this, &end, &step);
-
- condition(ast->condition, &body, &end, true);
-
- body.link();
- statement(ast->statement);
- setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
-
- step.link();
- statement(ast->expression);
- bytecodeGenerator->jump().link(cond);
- end.link();
-
- return false;
+ ControlFlow::UnwindTarget target = controlFlow ? controlFlow->unwindTarget(ControlFlow::Return) : ControlFlow::UnwindTarget();
+ if (target.linkLabel.isValid() && target.unwindLevel) {
+ Q_ASSERT(_returnAddress >= 0);
+ (void) expr.storeOnStack(_returnAddress);
+ bytecodeGenerator->unwindToLabel(target.unwindLevel, target.linkLabel);
+ } else {
+ expr.loadInAccumulator();
+ bytecodeGenerator->addInstruction(Instruction::Ret());
+ }
}
bool Codegen::visit(ReturnStatement *ast)
@@ -2597,7 +3406,7 @@ bool Codegen::visit(ReturnStatement *ast)
if (hasError)
return true;
- if (_context->compilationMode != FunctionCode && _context->compilationMode != QmlBinding) {
+ if (_functionContext->contextType != ContextType::Function && _functionContext->contextType != ContextType::Binding) {
throwSyntaxError(ast->returnToken, QStringLiteral("Return statement outside of function"));
return false;
}
@@ -2610,17 +3419,8 @@ bool Codegen::visit(ReturnStatement *ast)
expr = Reference::fromConst(this, Encode::undefined());
}
- if (_context->controlFlow && _context->controlFlow->returnRequiresUnwind()) {
- if (_returnAddress >= 0)
- (void) expr.storeOnStack(_returnAddress);
- else
- expr.loadInAccumulator();
- ControlFlow::Handler h = _context->controlFlow->getHandler(ControlFlow::Return);
- _context->controlFlow->jumpToHandler(h);
- } else {
- expr.loadInAccumulator();
- bytecodeGenerator->addInstruction(Instruction::Ret());
- }
+ emitReturn(expr);
+
return false;
}
@@ -2629,6 +3429,9 @@ bool Codegen::visit(SwitchStatement *ast)
if (hasError)
return true;
+ if (requiresReturnValue)
+ Reference::fromConst(this, Encode::undefined()).storeOnStack(_returnAddress);
+
RegisterScope scope(this);
if (ast->block) {
@@ -2639,6 +3442,8 @@ bool Codegen::visit(SwitchStatement *ast)
return false;
lhs = lhs.storeOnStack();
+ ControlFlowBlock controlFlow(this, ast->block);
+
// set up labels for all clauses
QHash<Node *, BytecodeGenerator::Label> blockMap;
for (CaseClauses *it = ast->block->clauses; it; it = it->next)
@@ -2674,6 +3479,7 @@ bool Codegen::visit(SwitchStatement *ast)
ControlFlowLoop flow(this, &switchEnd);
+ insideSwitch = true;
for (CaseClauses *it = ast->block->clauses; it; it = it->next) {
CaseClause *clause = it->clause;
blockMap[clause].link();
@@ -2694,6 +3500,7 @@ bool Codegen::visit(SwitchStatement *ast)
statementList(clause->statements);
}
+ insideSwitch = false;
switchEnd.link();
@@ -2713,25 +3520,15 @@ bool Codegen::visit(ThrowStatement *ast)
if (hasError)
return false;
- if (_context->controlFlow) {
- _context->controlFlow->handleThrow(expr);
- } else {
- expr.loadInAccumulator();
- Instruction::ThrowException instr;
- bytecodeGenerator->addInstruction(instr);
- }
+ expr.loadInAccumulator();
+ Instruction::ThrowException instr;
+ bytecodeGenerator->addInstruction(instr);
return false;
}
void Codegen::handleTryCatch(TryStatement *ast)
{
Q_ASSERT(ast);
- if (_context->isStrict &&
- (ast->catchExpression->name == QLatin1String("eval") || ast->catchExpression->name == QLatin1String("arguments"))) {
- throwSyntaxError(ast->catchExpression->identifierToken, QStringLiteral("Catch variable name may not be eval or arguments in strict mode"));
- return;
- }
-
RegisterScope scope(this);
BytecodeGenerator::Label noException = bytecodeGenerator->newLabel();
{
@@ -2761,8 +3558,6 @@ bool Codegen::visit(TryStatement *ast)
if (hasError)
return true;
- Q_ASSERT(_context->hasTry);
-
RegisterScope scope(this);
if (ast->finallyExpression && ast->finallyExpression->statement) {
@@ -2817,17 +3612,18 @@ bool Codegen::visit(WithStatement *ast)
RegisterScope scope(this);
- _context->hasWith = true;
-
Reference src = expression(ast->expression);
if (hasError)
return false;
src = src.storeOnStack(); // trigger load before we setup the exception handler, so exceptions here go to the right place
src.loadInAccumulator();
- ControlFlowWith flow(this);
-
- statement(ast->statement);
+ enterContext(ast);
+ {
+ ControlFlowWith flow(this);
+ statement(ast->statement);
+ }
+ leaveContext();
return false;
}
@@ -2917,9 +3713,10 @@ QList<QQmlJS::DiagnosticMessage> Codegen::errors() const
QQmlRefPointer<CompiledData::CompilationUnit> Codegen::generateCompilationUnit(bool generateUnitData)
{
- CompiledData::CompilationUnit *compilationUnit = new CompiledData::CompilationUnit;
+ CompiledData::Unit *unitData = nullptr;
if (generateUnitData)
- compilationUnit->data = jsUnitGenerator->generateUnit();
+ unitData = jsUnitGenerator->generateUnit();
+ CompiledData::CompilationUnit *compilationUnit = new CompiledData::CompilationUnit(unitData);
QQmlRefPointer<CompiledData::CompilationUnit> unit;
unit.adopt(compilationUnit);
@@ -3080,6 +3877,22 @@ Codegen::RValue Codegen::RValue::storeOnStack() const
}
}
+void Codegen::RValue::loadInAccumulator() const
+{
+ switch (type) {
+ case Accumulator:
+ // nothing to do
+ return;
+ case StackSlot:
+ return Reference::fromStackSlot(codegen, theStackSlot).loadInAccumulator();
+ case Const:
+ return Reference::fromConst(codegen, constant).loadInAccumulator();
+ default:
+ Q_UNREACHABLE();
+ }
+
+}
+
Codegen::Reference::Reference(const Codegen::Reference &other)
{
*this = other;
@@ -3093,6 +3906,11 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
case Invalid:
case Accumulator:
break;
+ case Super:
+ break;
+ case SuperProperty:
+ property = other.property;
+ break;
case StackSlot:
theStackSlot = other.theStackSlot;
break;
@@ -3101,7 +3919,7 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
scope = other.scope;
break;
case Name:
- name = other.name;
+ // name is always copied
break;
case Member:
propertyBase = other.propertyBase;
@@ -3111,6 +3929,9 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
elementBase = other.elementBase;
elementSubscript = other.elementSubscript;
break;
+ case Import:
+ index = other.index;
+ break;
case Const:
constant = other.constant;
break;
@@ -3127,6 +3948,9 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
isArgOrEval = other.isArgOrEval;
codegen = other.codegen;
isReadonly = other.isReadonly;
+ isReferenceToConst = other.isReferenceToConst;
+ name = other.name;
+ requiresTDZCheck = other.requiresTDZCheck;
stackSlotIsLocalOrArgument = other.stackSlotIsLocalOrArgument;
isVolatile = other.isVolatile;
global = other.global;
@@ -3141,6 +3965,10 @@ bool Codegen::Reference::operator==(const Codegen::Reference &other) const
case Invalid:
case Accumulator:
break;
+ case Super:
+ return true;
+ case SuperProperty:
+ return property == other.property;
case StackSlot:
return theStackSlot == other.theStackSlot;
case ScopedLocal:
@@ -3151,6 +3979,8 @@ bool Codegen::Reference::operator==(const Codegen::Reference &other) const
return propertyBase == other.propertyBase && propertyNameIndex == other.propertyNameIndex;
case Subscript:
return elementBase == other.elementBase && elementSubscript == other.elementSubscript;
+ case Import:
+ return index == other.index;
case Const:
return constant == other.constant;
case QmlScopeObject:
@@ -3184,6 +4014,9 @@ Codegen::Reference Codegen::Reference::asLValue() const
case Invalid:
case Accumulator:
Q_UNREACHABLE();
+ case Super:
+ codegen->throwSyntaxError(AST::SourceLocation(), QStringLiteral("Super lvalues not implemented."));
+ return *this;
case Member:
if (!propertyBase.isStackSlot()) {
Reference r = *this;
@@ -3209,6 +4042,30 @@ Codegen::Reference Codegen::Reference::storeConsumeAccumulator() const
return Reference();
}
+Codegen::Reference Codegen::Reference::baseObject() const
+{
+ if (type == Reference::QmlScopeObject || type == Reference::QmlContextObject) {
+ return Reference::fromStackSlot(codegen, qmlBase.stackSlot());
+ } else if (type == Reference::Member) {
+ RValue rval = propertyBase;
+ if (!rval.isValid())
+ return Reference::fromConst(codegen, Encode::undefined());
+ if (rval.isAccumulator())
+ return Reference::fromAccumulator(codegen);
+ if (rval.isStackSlot())
+ return Reference::fromStackSlot(codegen, rval.stackSlot());
+ if (rval.isConst())
+ return Reference::fromConst(codegen, rval.constantValue());
+ Q_UNREACHABLE();
+ } else if (type == Reference::Subscript) {
+ return Reference::fromStackSlot(codegen, elementBase.stackSlot());
+ } else if (type == Reference::SuperProperty) {
+ return Reference::fromStackSlot(codegen, CallData::This);
+ } else {
+ return Reference::fromConst(codegen, Encode::undefined());
+ }
+}
+
Codegen::Reference Codegen::Reference::storeOnStack() const
{ return doStoreOnStack(-1); }
@@ -3217,10 +4074,10 @@ void Codegen::Reference::storeOnStack(int slotIndex) const
Codegen::Reference Codegen::Reference::doStoreOnStack(int slotIndex) const
{
- if (isStackSlot() && slotIndex == -1 && !(stackSlotIsLocalOrArgument && isVolatile))
+ if (isStackSlot() && slotIndex == -1 && !(stackSlotIsLocalOrArgument && isVolatile) && !requiresTDZCheck)
return *this;
- if (isStackSlot()) { // temp-to-temp move
+ if (isStackSlot() && !requiresTDZCheck) { // temp-to-temp move
Reference dest = Reference::fromStackSlot(codegen, slotIndex);
Instruction::MoveReg move;
move.srcReg = stackSlot();
@@ -3230,7 +4087,7 @@ Codegen::Reference Codegen::Reference::doStoreOnStack(int slotIndex) const
}
Reference slot = Reference::fromStackSlot(codegen, slotIndex);
- if (isConst()) {
+ if (isConstant()) {
Instruction::MoveConst move;
move.constIndex = codegen->registerConstant(constant);
move.destTemp = slot.stackSlot();
@@ -3280,7 +4137,29 @@ bool Codegen::Reference::storeWipesAccumulator() const
void Codegen::Reference::storeAccumulator() const
{
+ if (isReferenceToConst) {
+ // throw a type error
+ RegisterScope scope(codegen);
+ Reference r = codegen->referenceForName(QStringLiteral("TypeError"), false);
+ r = r.storeOnStack();
+ Instruction::Construct construct;
+ construct.func = r.stackSlot();
+ construct.argc = 0;
+ construct.argv = 0;
+ codegen->bytecodeGenerator->addInstruction(construct);
+ Instruction::ThrowException throwException;
+ codegen->bytecodeGenerator->addInstruction(throwException);
+ return;
+ }
switch (type) {
+ case Super:
+ Q_UNREACHABLE();
+ return;
+ case SuperProperty:
+ Instruction::StoreSuperProperty store;
+ store.property = property.stackSlot();
+ codegen->bytecodeGenerator->addInstruction(store);
+ return;
case StackSlot: {
Instruction::StoreReg store;
store.reg = theStackSlot;
@@ -3313,7 +4192,7 @@ void Codegen::Reference::storeAccumulator() const
}
} return;
case Member:
- if (codegen->useFastLookups) {
+ if (!disable_lookups && codegen->useFastLookups) {
Instruction::SetLookup store;
store.base = propertyBase.stackSlot();
store.index = codegen->registerSetterLookup(propertyNameIndex);
@@ -3346,6 +4225,7 @@ void Codegen::Reference::storeAccumulator() const
case Invalid:
case Accumulator:
case Const:
+ case Import:
break;
}
@@ -3355,9 +4235,34 @@ void Codegen::Reference::storeAccumulator() const
void Codegen::Reference::loadInAccumulator() const
{
+ auto tdzCheck = [this](bool requiresCheck){
+ if (!requiresCheck)
+ return;
+ Instruction::DeadTemporalZoneCheck check;
+ check.name = codegen->registerString(name);
+ codegen->bytecodeGenerator->addInstruction(check);
+ };
+ auto tdzCheckStackSlot = [this, tdzCheck](Moth::StackSlot slot, bool requiresCheck){
+ if (!requiresCheck)
+ return;
+ Instruction::LoadReg load;
+ load.reg = slot;
+ codegen->bytecodeGenerator->addInstruction(load);
+ tdzCheck(true);
+ };
+
switch (type) {
case Accumulator:
return;
+ case Super:
+ Q_UNREACHABLE();
+ return;
+ case SuperProperty:
+ tdzCheckStackSlot(property, subscriptRequiresTDZCheck);
+ Instruction::LoadSuperProperty load;
+ load.property = property.stackSlot();
+ codegen->bytecodeGenerator->addInstruction(load);
+ return;
case Const: {
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty structs.
@@ -3374,7 +4279,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty str
Instruction::LoadUndefined load;
codegen->bytecodeGenerator->addInstruction(load);
} else {
- Value p = Primitive::fromReturnedValue(constant);
+ Value p = Value::fromReturnedValue(constant);
if (p.isNumber()) {
double d = p.asDouble();
int i = static_cast<int>(d);
@@ -3385,7 +4290,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty str
return;
}
Instruction::LoadInt load;
- load.value = Primitive::fromReturnedValue(constant).toInt32();
+ load.value = Value::fromReturnedValue(constant).toInt32();
codegen->bytecodeGenerator->addInstruction(load);
return;
}
@@ -3400,6 +4305,7 @@ QT_WARNING_POP
Instruction::LoadReg load;
load.reg = stackSlot();
codegen->bytecodeGenerator->addInstruction(load);
+ tdzCheck(requiresTDZCheck);
} return;
case ScopedLocal: {
if (!scope) {
@@ -3412,6 +4318,7 @@ QT_WARNING_POP
load.scope = scope;
codegen->bytecodeGenerator->addInstruction(load);
}
+ tdzCheck(requiresTDZCheck);
return;
}
case Name:
@@ -3429,7 +4336,7 @@ QT_WARNING_POP
return;
}
}
- if (codegen->useFastLookups && global) {
+ if (!disable_lookups && global) {
Instruction::LoadGlobalLookup load;
load.index = codegen->registerGlobalGetterLookup(nameAsIndex());
codegen->bytecodeGenerator->addInstruction(load);
@@ -3440,46 +4347,31 @@ QT_WARNING_POP
}
return;
case Member:
- if (codegen->useFastLookups) {
- if (propertyBase.isAccumulator()) {
- Instruction::GetLookupA load;
- load.index = codegen->registerGetterLookup(propertyNameIndex);
- codegen->bytecodeGenerator->addInstruction(load);
- } else {
- Instruction::GetLookup load;
- load.base = propertyBase.storeOnStack().stackSlot();
- load.index = codegen->registerGetterLookup(propertyNameIndex);
- codegen->bytecodeGenerator->addInstruction(load);
- }
- } else {
- if (propertyBase.isAccumulator()) {
- Instruction::LoadPropertyA load;
- load.name = propertyNameIndex;
- codegen->bytecodeGenerator->addInstruction(load);
- } else {
- Instruction::LoadProperty load;
- load.base = propertyBase.storeOnStack().stackSlot();
- load.name = propertyNameIndex;
- codegen->bytecodeGenerator->addInstruction(load);
- }
- }
- return;
- case Subscript: {
- if (elementSubscript.isAccumulator()) {
- Instruction::LoadElementA load;
- load.base = elementBase;
- codegen->bytecodeGenerator->addInstruction(load);
- } else if (elementSubscript.isConst()) {
- Reference::fromConst(codegen, elementSubscript.constantValue()).loadInAccumulator();
- Instruction::LoadElementA load;
- load.base = elementBase;
+ propertyBase.loadInAccumulator();
+ tdzCheck(requiresTDZCheck);
+ if (!disable_lookups && codegen->useFastLookups) {
+ Instruction::GetLookup load;
+ load.index = codegen->registerGetterLookup(propertyNameIndex);
codegen->bytecodeGenerator->addInstruction(load);
} else {
- Instruction::LoadElement load;
- load.base = elementBase;
- load.index = elementSubscript.storeOnStack().stackSlot();
+ Instruction::LoadProperty load;
+ load.name = propertyNameIndex;
codegen->bytecodeGenerator->addInstruction(load);
}
+ return;
+ case Import: {
+ Instruction::LoadImport load;
+ load.index = index;
+ codegen->bytecodeGenerator->addInstruction(load);
+ tdzCheck(requiresTDZCheck);
+ } return;
+ case Subscript: {
+ tdzCheckStackSlot(elementBase, requiresTDZCheck);
+ elementSubscript.loadInAccumulator();
+ tdzCheck(subscriptRequiresTDZCheck);
+ Instruction::LoadElement load;
+ load.base = elementBase;
+ codegen->bytecodeGenerator->addInstruction(load);
} return;
case QmlScopeObject: {
Instruction::LoadScopeObjectProperty load;
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index d51dc29517..ae3e074e07 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -66,6 +66,7 @@
#endif
#include <private/qv4util_p.h>
#include <private/qv4bytecodegenerator_p.h>
+#include <private/qv4stackframe_p.h>
QT_BEGIN_NAMESPACE
@@ -101,7 +102,13 @@ public:
const QString &sourceCode,
AST::Program *ast,
Module *module,
- CompilationMode mode = GlobalCode);
+ ContextType contextType = ContextType::Global);
+
+ void generateFromModule(const QString &fileName,
+ const QString &finalUrl,
+ const QString &sourceCode,
+ AST::ESModule *ast,
+ Module *module);
public:
class VolatileMemoryLocationScanner;
@@ -172,16 +179,20 @@ public:
}
Q_REQUIRED_RESULT RValue storeOnStack() const;
+ void loadInAccumulator() const;
};
struct Reference {
enum Type {
Invalid,
Accumulator,
+ Super,
+ SuperProperty,
StackSlot,
ScopedLocal,
Name,
Member,
Subscript,
+ Import,
QmlScopeObject,
QmlContextObject,
LastLValue = QmlContextObject,
@@ -197,6 +208,8 @@ public:
Reference &operator =(const Reference &other);
bool operator==(const Reference &other) const;
+ bool operator!=(const Reference &other) const
+ { return !(*this == other); }
bool isValid() const { return type != Invalid; }
bool loadTriggersSideEffect() const {
@@ -204,13 +217,16 @@ public:
case Name:
case Member:
case Subscript:
+ case SuperProperty:
return true;
default:
- return false;
+ return requiresTDZCheck;
}
}
- bool isConst() const { return type == Const; }
+ bool isConstant() const { return type == Const; }
bool isAccumulator() const { return type == Accumulator; }
+ bool isSuper() const { return type == Super; }
+ bool isSuperProperty() const { return type == SuperProperty; }
bool isStackSlot() const { return type == StackSlot; }
bool isRegister() const {
return isStackSlot();
@@ -241,6 +257,9 @@ public:
static Reference fromAccumulator(Codegen *cg) {
return Reference(cg, Accumulator);
}
+ static Reference fromSuper(Codegen *cg) {
+ return Reference(cg, Super);
+ }
static Reference fromStackSlot(Codegen *cg, int tempIndex = -1, bool isLocal = false) {
Reference r(cg, StackSlot);
if (tempIndex == -1)
@@ -262,6 +281,11 @@ public:
r.scope = scope;
return r;
}
+ static Reference fromImport(Codegen *cg, int index) {
+ Reference r(cg, Import);
+ r.index = index;
+ return r;
+ }
static Reference fromName(Codegen *cg, const QString &name) {
Reference r(cg, Name);
r.name = name;
@@ -271,6 +295,14 @@ public:
Reference r(baseRef.codegen, Member);
r.propertyBase = baseRef.asRValue();
r.propertyNameIndex = r.codegen->registerString(name);
+ r.requiresTDZCheck = baseRef.requiresTDZCheck;
+ return r;
+ }
+ static Reference fromSuperProperty(const Reference &property) {
+ Q_ASSERT(property.isStackSlot());
+ Reference r(property.codegen, SuperProperty);
+ r.property = property.stackSlot();
+ r.subscriptRequiresTDZCheck = property.requiresTDZCheck;
return r;
}
static Reference fromSubscript(const Reference &baseRef, const Reference &subscript) {
@@ -278,6 +310,8 @@ public:
Reference r(baseRef.codegen, Subscript);
r.elementBase = baseRef.stackSlot();
r.elementSubscript = subscript.asRValue();
+ r.requiresTDZCheck = baseRef.requiresTDZCheck;
+ r.subscriptRequiresTDZCheck = subscript.requiresTDZCheck;
return r;
}
static Reference fromConst(Codegen *cg, QV4::ReturnedValue constant) {
@@ -305,6 +339,9 @@ public:
static Reference fromThis(Codegen *cg) {
Reference r = fromStackSlot(cg, CallData::This);
r.isReadonly = true;
+ // ### Optimize this. Functions that are not derived constructors or arrow functions can't have an
+ // empty this object
+ r.requiresTDZCheck = true;
return r;
}
@@ -322,6 +359,8 @@ public:
Q_REQUIRED_RESULT Reference storeRetainAccumulator() const;
Reference storeConsumeAccumulator() const;
+ Q_REQUIRED_RESULT Reference baseObject() const;
+
bool storeWipesAccumulator() const;
void loadInAccumulator() const;
@@ -357,10 +396,14 @@ public:
qint16 qmlNotifyIndex;
PropertyCapturePolicy capturePolicy;
};
+ Moth::StackSlot property; // super property
};
QString name;
mutable bool isArgOrEval = false;
bool isReadonly = false;
+ bool isReferenceToConst = false;
+ bool requiresTDZCheck = false;
+ bool subscriptRequiresTDZCheck = false;
bool stackSlotIsLocalOrArgument = false;
bool isVolatile = false;
bool global = false;
@@ -464,7 +507,10 @@ protected:
void enterContext(AST::Node *node);
int leaveContext();
-
+public:
+ Context *enterBlock(AST::Node *node);
+ int leaveBlock() { return leaveContext(); }
+protected:
void leaveLoop();
enum UnaryOperation {
@@ -482,6 +528,7 @@ protected:
void addCJump();
+public:
int registerString(const QString &name) {
return jsUnitGenerator->registerString(name);
}
@@ -493,33 +540,37 @@ protected:
// Returns index in _module->functions
virtual int defineFunction(const QString &name, AST::Node *ast,
AST::FormalParameterList *formals,
- AST::SourceElements *body);
+ AST::StatementList *body);
+protected:
void statement(AST::Statement *ast);
void statement(AST::ExpressionNode *ast);
void condition(AST::ExpressionNode *ast, const BytecodeGenerator::Label *iftrue,
const BytecodeGenerator::Label *iffalse,
bool trueBlockFollowsCondition);
Reference expression(AST::ExpressionNode *ast);
- Result sourceElement(AST::SourceElement *ast);
void accept(AST::Node *node);
- void functionBody(AST::FunctionBody *ast);
void program(AST::Program *ast);
- void sourceElements(AST::SourceElements *ast);
void statementList(AST::StatementList *ast);
- void variableDeclaration(AST::VariableDeclaration *ast);
+ void variableDeclaration(AST::PatternElement *ast);
void variableDeclarationList(AST::VariableDeclarationList *ast);
- Reference referenceForName(const QString &name, bool lhs);
+ Reference targetForPatternElement(AST::PatternElement *p);
+ void initializeAndDestructureBindingElement(AST::PatternElement *e, const Reference &baseRef = Reference(), bool isDefinition = false);
+ void destructurePropertyList(const Reference &object, AST::PatternPropertyList *bindingList, bool isDefinition = false);
+ void destructureElementList(const Reference &array, AST::PatternElementList *bindingList, bool isDefinition = false);
+ void destructurePattern(AST::Pattern *p, const Reference &rhs);
- void loadClosure(int index);
+ Reference referenceForPropertyName(const Codegen::Reference &object, AST::PropertyName *name);
// Hook provided to implement QML lookup semantics
virtual Reference fallbackNameLookup(const QString &name);
virtual void beginFunctionBodyHook() {}
+ void emitReturn(const Reference &expr);
+
// nodes
bool visit(AST::ArgumentList *ast) override;
bool visit(AST::CaseBlock *ast) override;
@@ -527,16 +578,10 @@ protected:
bool visit(AST::CaseClauses *ast) override;
bool visit(AST::Catch *ast) override;
bool visit(AST::DefaultClause *ast) override;
- bool visit(AST::ElementList *ast) override;
bool visit(AST::Elision *ast) override;
bool visit(AST::Finally *ast) override;
bool visit(AST::FormalParameterList *ast) override;
- bool visit(AST::FunctionBody *ast) override;
bool visit(AST::Program *ast) override;
- bool visit(AST::PropertyNameAndValue *ast) override;
- bool visit(AST::PropertyAssignmentList *ast) override;
- bool visit(AST::PropertyGetterSetter *ast) override;
- bool visit(AST::SourceElements *ast) override;
bool visit(AST::StatementList *ast) override;
bool visit(AST::UiArrayMemberList *ast) override;
bool visit(AST::UiImport *ast) override;
@@ -547,20 +592,27 @@ protected:
bool visit(AST::UiParameterList *ast) override;
bool visit(AST::UiProgram *ast) override;
bool visit(AST::UiQualifiedId *ast) override;
- bool visit(AST::UiQualifiedPragmaId *ast) override;
- bool visit(AST::VariableDeclaration *ast) override;
bool visit(AST::VariableDeclarationList *ast) override;
+ bool visit(AST::PatternElement *ast) override;
+ bool visit(AST::PatternElementList *ast) override;
+ bool visit(AST::PatternProperty *ast) override;
+ bool visit(AST::PatternPropertyList *ast) override;
+
+ bool visit(AST::ExportDeclaration *ast) override;
+
// expressions
bool visit(AST::Expression *ast) override;
- bool visit(AST::ArrayLiteral *ast) override;
+ bool visit(AST::ArrayPattern *ast) override;
bool visit(AST::ArrayMemberExpression *ast) override;
bool visit(AST::BinaryExpression *ast) override;
bool visit(AST::CallExpression *ast) override;
bool visit(AST::ConditionalExpression *ast) override;
bool visit(AST::DeleteExpression *ast) override;
bool visit(AST::FalseLiteral *ast) override;
+ bool visit(AST::SuperLiteral *ast) override;
bool visit(AST::FieldMemberExpression *ast) override;
+ bool visit(AST::TaggedTemplate *ast) override;
bool visit(AST::FunctionExpression *ast) override;
bool visit(AST::IdentifierExpression *ast) override;
bool visit(AST::NestedExpression *ast) override;
@@ -569,13 +621,14 @@ protected:
bool visit(AST::NotExpression *ast) override;
bool visit(AST::NullExpression *ast) override;
bool visit(AST::NumericLiteral *ast) override;
- bool visit(AST::ObjectLiteral *ast) override;
+ bool visit(AST::ObjectPattern *ast) override;
bool visit(AST::PostDecrementExpression *ast) override;
bool visit(AST::PostIncrementExpression *ast) override;
bool visit(AST::PreDecrementExpression *ast) override;
bool visit(AST::PreIncrementExpression *ast) override;
bool visit(AST::RegExpLiteral *ast) override;
bool visit(AST::StringLiteral *ast) override;
+ bool visit(AST::TemplateLiteral *ast) override;
bool visit(AST::ThisExpression *ast) override;
bool visit(AST::TildeExpression *ast) override;
bool visit(AST::TrueLiteral *ast) override;
@@ -584,10 +637,9 @@ protected:
bool visit(AST::UnaryPlusExpression *ast) override;
bool visit(AST::VoidExpression *ast) override;
bool visit(AST::FunctionDeclaration *ast) override;
-
- // source elements
- bool visit(AST::FunctionSourceElement *ast) override;
- bool visit(AST::StatementSourceElement *ast) override;
+ bool visit(AST::YieldExpression *ast) override;
+ bool visit(AST::ClassExpression *ast) override;
+ bool visit(AST::ClassDeclaration *ast) override;
// statements
bool visit(AST::Block *ast) override;
@@ -601,8 +653,6 @@ protected:
bool visit(AST::ForStatement *ast) override;
bool visit(AST::IfStatement *ast) override;
bool visit(AST::LabelledStatement *ast) override;
- bool visit(AST::LocalForEachStatement *ast) override;
- bool visit(AST::LocalForStatement *ast) override;
bool visit(AST::ReturnStatement *ast) override;
bool visit(AST::SwitchStatement *ast) override;
bool visit(AST::ThrowStatement *ast) override;
@@ -631,18 +681,36 @@ public:
Reference binopHelper(QSOperator::Op oper, Reference &left, Reference &right);
Reference jumpBinop(QSOperator::Op oper, Reference &left, Reference &right);
- struct Arguments { int argc; int argv; };
+ struct Arguments { int argc; int argv; bool hasSpread; };
Arguments pushArgs(AST::ArgumentList *args);
+ void handleCall(Reference &base, Arguments calldata, int slotForFunction, int slotForThisObject);
+
+ Arguments pushTemplateArgs(AST::TemplateLiteral *args);
+ int createTemplateArray(AST::TemplateLiteral *t);
void setUseFastLookups(bool b) { useFastLookups = b; }
void handleTryCatch(AST::TryStatement *ast);
void handleTryFinally(AST::TryStatement *ast);
+
+ Reference referenceForName(const QString &name, bool lhs, const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation());
+
QQmlRefPointer<QV4::CompiledData::CompilationUnit> generateCompilationUnit(bool generateUnitData = true);
static QQmlRefPointer<QV4::CompiledData::CompilationUnit> createUnitForLoading();
Context *currentContext() const { return _context; }
+ BytecodeGenerator *generator() const { return bytecodeGenerator; }
+
+ void loadClosure(int index);
+
+ Module *module() const { return _module; }
+
+ BytecodeGenerator::Label returnLabel() {
+ if (!_returnLabel)
+ _returnLabel = new BytecodeGenerator::Label(bytecodeGenerator->newLabel());
+ return *_returnLabel;
+ }
protected:
friend class ScanFunctions;
@@ -650,16 +718,22 @@ protected:
friend struct ControlFlowCatch;
friend struct ControlFlowFinally;
Result _expr;
- VolatileMemoryLocations _volataleMemoryLocations;
+ VolatileMemoryLocations _volatileMemoryLocations;
Module *_module;
int _returnAddress;
Context *_context;
+ Context *_functionContext = nullptr;
AST::LabelledStatement *_labelledStatement;
QV4::Compiler::JSUnitGenerator *jsUnitGenerator;
BytecodeGenerator *bytecodeGenerator = nullptr;
+ Moth::BytecodeGenerator::Label *_returnLabel = nullptr;
bool _strictMode;
bool useFastLookups = true;
bool requiresReturnValue = false;
+ bool insideSwitch = false;
+ bool inFormalParameterList = false;
+ bool functionEndsWithReturn = false;
+ ControlFlow *controlFlow = nullptr;
bool _fileNameIsUrl;
bool hasError;
@@ -667,6 +741,7 @@ protected:
private:
VolatileMemoryLocations scanVolatileMemoryLocations(AST::Node *ast) const;
+ void handleConstruct(const Reference &base, AST::ArgumentList *args);
};
}
diff --git a/src/qml/compiler/qv4compilationunitmapper_unix.cpp b/src/qml/compiler/qv4compilationunitmapper_unix.cpp
index 8348613888..6768bc9596 100644
--- a/src/qml/compiler/qv4compilationunitmapper_unix.cpp
+++ b/src/qml/compiler/qv4compilationunitmapper_unix.cpp
@@ -42,7 +42,7 @@
#include <sys/mman.h>
#include <functional>
#include <private/qcore_unix_p.h>
-#include <private/qdeferredcleanup_p.h>
+#include <QScopeGuard>
#include <QDateTime>
#include "qv4compileddata_p.h"
@@ -61,7 +61,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
return nullptr;
}
- QDeferredCleanup cleanup([fd]{
+ auto cleanup = qScopeGuard([fd]{
qt_safe_close(fd) ;
});
@@ -92,8 +92,16 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
void CompilationUnitMapper::close()
{
- if (dataPtr != nullptr)
- munmap(dataPtr, length);
+ // Do not unmap the data here.
+ if (dataPtr != nullptr) {
+ // Do not unmap cache files that are built with the StaticData flag. That's the majority of
+ // them and it's necessary to benefit from the QString literal optimization. There might
+ // still be QString instances around that point into that memory area. The memory is backed
+ // on the disk, so the kernel is free to release the pages and all that remains is the
+ // address space allocation.
+ if (!(reinterpret_cast<CompiledData::Unit*>(dataPtr)->flags & CompiledData::Unit::StaticData))
+ munmap(dataPtr, length);
+ }
dataPtr = nullptr;
}
diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp
index 8b000021f8..779c1288fe 100644
--- a/src/qml/compiler/qv4compilationunitmapper_win.cpp
+++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp
@@ -40,7 +40,7 @@
#include "qv4compilationunitmapper_p.h"
#include "qv4compileddata_p.h"
-#include <private/qdeferredcleanup_p.h>
+#include <QScopeGuard>
#include <QFileInfo>
#include <QDateTime>
#include <qt_windows.h>
@@ -71,7 +71,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
return nullptr;
}
- QDeferredCleanup fileHandleCleanup([handle]{
+ auto fileHandleCleanup = qScopeGuard([handle]{
CloseHandle(handle);
});
@@ -90,24 +90,19 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
if (!header.verifyHeader(sourceTimeStamp, errorString))
return nullptr;
- const uint mappingFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
- ? PAGE_EXECUTE_READ : PAGE_READONLY;
- const uint viewFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
- ? (FILE_MAP_READ | FILE_MAP_EXECUTE) : FILE_MAP_READ;
-
// Data structure and qt version matched, so now we can access the rest of the file safely.
- HANDLE fileMappingHandle = CreateFileMapping(handle, 0, mappingFlags, 0, 0, 0);
+ HANDLE fileMappingHandle = CreateFileMapping(handle, 0, PAGE_READONLY, 0, 0, 0);
if (!fileMappingHandle) {
*errorString = qt_error_string(GetLastError());
return nullptr;
}
- QDeferredCleanup mappingCleanup([fileMappingHandle]{
+ auto mappingCleanup = qScopeGuard([fileMappingHandle]{
CloseHandle(fileMappingHandle);
});
- dataPtr = MapViewOfFile(fileMappingHandle, viewFlags, 0, 0, 0);
+ dataPtr = MapViewOfFile(fileMappingHandle, FILE_MAP_READ, 0, 0, 0);
if (!dataPtr) {
*errorString = qt_error_string(GetLastError());
return nullptr;
@@ -118,8 +113,15 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
void CompilationUnitMapper::close()
{
- if (dataPtr != nullptr)
- UnmapViewOfFile(dataPtr);
+ if (dataPtr != nullptr) {
+ // Do not unmap cache files that are built with the StaticData flag. That's the majority of
+ // them and it's necessary to benefit from the QString literal optimization. There might
+ // still be QString instances around that point into that memory area. The memory is backed
+ // on the disk, so the kernel is free to release the pages and all that remains is the
+ // address space allocation.
+ if (!(reinterpret_cast<CompiledData::Unit*>(dataPtr)->flags & CompiledData::Unit::StaticData))
+ UnmapViewOfFile(dataPtr);
+ }
dataPtr = nullptr;
}
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 8dcc068a06..c82f3d1bc8 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -50,6 +50,7 @@
#include <private/qqmltypeloader_p.h>
#include <private/qqmlengine_p.h>
#include <private/qv4vme_moth_p.h>
+#include <private/qv4module_p.h>
#include "qv4compilationunitmapper_p.h"
#include <QQmlPropertyMap>
#include <QDateTime>
@@ -64,6 +65,7 @@
#include <QCoreApplication>
#include <QCryptographicHash>
#include <QSaveFile>
+#include <QScopeGuard>
// generated by qmake:
#include "qml_compile_hash_p.h"
@@ -76,36 +78,56 @@ namespace QV4 {
namespace CompiledData {
+#if defined(QML_COMPILE_HASH)
+# ifdef Q_OS_LINUX
+// Place on a separate section on Linux so it's easier to check from outside
+// what the hash version is.
+__attribute__((section(".qml_compile_hash")))
+# endif
+const char qml_compile_hash[48 + 1] = QML_COMPILE_HASH;
static_assert(sizeof(Unit::libraryVersionHash) >= QML_COMPILE_HASH_LENGTH + 1, "Compile hash length exceeds reserved size in data structure. Please adjust and bump the format version");
+#else
+# error "QML_COMPILE_HASH must be defined for the build of QtDeclarative to ensure version checking for cache files"
+#endif
-#if !defined(V4_BOOTSTRAP)
-static QString cacheFilePath(const QUrl &url)
+
+CompilationUnit::CompilationUnit(const Unit *unitData, const QString &fileName, const QString &finalUrlString)
{
- const QString localSourcePath = QQmlFile::urlToLocalFileOrQrc(url);
- const QString localCachePath = localSourcePath + QLatin1Char('c');
-#ifndef Q_OS_ANDROID
- if (QFile::exists(localCachePath) || QFileInfo(QFileInfo(localSourcePath).dir().absolutePath()).isWritable())
- return localCachePath;
-#endif
- QCryptographicHash fileNameHash(QCryptographicHash::Sha1);
- fileNameHash.addData(localSourcePath.toUtf8());
- QString directory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/qmlcache/");
- QDir::root().mkpath(directory);
- return directory + QString::fromUtf8(fileNameHash.result().toHex()) + QLatin1Char('.') + QFileInfo(localCachePath).completeSuffix();
+ setUnitData(unitData, nullptr, fileName, finalUrlString);
}
-#endif
-
-CompilationUnit::CompilationUnit(const Unit *unitData)
- : data(unitData)
-{}
#ifndef V4_BOOTSTRAP
CompilationUnit::~CompilationUnit()
{
unlink();
- if (data && !(data->flags & QV4::CompiledData::Unit::StaticData))
- free(const_cast<Unit *>(data));
+
+ if (data) {
+ if (data->qmlUnit() != qmlData)
+ free(const_cast<QmlUnit *>(qmlData));
+ qmlData = nullptr;
+
+ if (!(data->flags & QV4::CompiledData::Unit::StaticData))
+ free(const_cast<Unit *>(data));
+ }
data = nullptr;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ delete [] constants;
+ constants = nullptr;
+#endif
+
+ delete [] imports;
+ imports = nullptr;
+}
+
+QString CompilationUnit::localCacheFilePath(const QUrl &url)
+{
+ const QString localSourcePath = QQmlFile::urlToLocalFileOrQrc(url);
+ const QString cacheFileSuffix = QFileInfo(localSourcePath + QLatin1Char('c')).completeSuffix();
+ QCryptographicHash fileNameHash(QCryptographicHash::Sha1);
+ fileNameHash.addData(localSourcePath.toUtf8());
+ QString directory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/qmlcache/");
+ QDir::root().mkpath(directory);
+ return directory + QString::fromUtf8(fileNameHash.result().toHex()) + QLatin1Char('.') + cacheFileSuffix;
}
QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
@@ -115,27 +137,21 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
Q_ASSERT(!runtimeStrings);
Q_ASSERT(data);
- runtimeStrings = (QV4::Heap::String **)malloc(data->stringTableSize * sizeof(QV4::Heap::String*));
+ const quint32 stringCount = totalStringCount();
+ runtimeStrings = (QV4::Heap::String **)malloc(stringCount * sizeof(QV4::Heap::String*));
// memset the strings to 0 in case a GC run happens while we're within the loop below
- memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*));
- for (uint i = 0; i < data->stringTableSize; ++i)
- runtimeStrings[i] = engine->newString(data->stringAt(i));
+ memset(runtimeStrings, 0, stringCount * sizeof(QV4::Heap::String*));
+ for (uint i = 0; i < stringCount; ++i)
+ runtimeStrings[i] = engine->newString(stringAt(i));
runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
// memset the regexps to 0 in case a GC run happens while we're within the loop below
memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::Value));
for (uint i = 0; i < data->regexpTableSize; ++i) {
const CompiledData::RegExp *re = data->regexpAt(i);
- bool global = false;
- bool multiline = false;
- bool ignoreCase = false;
- if (re->flags & CompiledData::RegExp::RegExp_Global)
- global = true;
- if (re->flags & CompiledData::RegExp::RegExp_IgnoreCase)
- ignoreCase = true;
- if (re->flags & CompiledData::RegExp::RegExp_Multiline)
- multiline = true;
- runtimeRegularExpressions[i] = QV4::RegExp::create(engine, data->stringAt(re->stringIndex), ignoreCase, multiline, global);
+ uint f = re->flags;
+ const CompiledData::RegExp::Flags flags = static_cast<CompiledData::RegExp::Flags>(f);
+ runtimeRegularExpressions[i] = QV4::RegExp::create(engine, stringAt(re->stringIndex), flags);
}
if (data->lookupTableSize) {
@@ -157,36 +173,45 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
}
if (data->jsClassTableSize) {
- runtimeClasses = (QV4::InternalClass**)malloc(data->jsClassTableSize * sizeof(QV4::InternalClass*));
+ runtimeClasses = (QV4::Heap::InternalClass **)malloc(data->jsClassTableSize * sizeof(QV4::Heap::InternalClass *));
+ // memset the regexps to 0 in case a GC run happens while we're within the loop below
+ memset(runtimeClasses, 0, data->jsClassTableSize * sizeof(QV4::Heap::InternalClass *));
for (uint i = 0; i < data->jsClassTableSize; ++i) {
int memberCount = 0;
const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount);
- QV4::InternalClass *klass = engine->internalClasses[QV4::ExecutionEngine::Class_Object];
+ runtimeClasses[i] = engine->internalClasses(QV4::ExecutionEngine::Class_Object);
for (int j = 0; j < memberCount; ++j, ++member)
- klass = klass->addMember(engine->identifierTable->identifier(runtimeStrings[member->nameOffset]), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
-
- runtimeClasses[i] = klass;
+ runtimeClasses[i] = runtimeClasses[i]->addMember(engine->identifierTable->asPropertyKey(runtimeStrings[member->nameOffset]), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
}
}
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- Value *bigEndianConstants = new Value[data->constantTableSize];
- const quint64_le *littleEndianConstants = data->constants();
- for (uint i = 0; i < data->constantTableSize; ++i)
- bigEndianConstants[i] = Value::fromReturnedValue(littleEndianConstants[i]);
- constants = bigEndianConstants;
-#else
- constants = reinterpret_cast<const Value*>(data->constants());
-#endif
+ runtimeFunctions.resize(data->functionTableSize);
+ for (int i = 0 ;i < runtimeFunctions.size(); ++i) {
+ const QV4::CompiledData::Function *compiledFunction = data->functionAt(i);
+ runtimeFunctions[i] = new QV4::Function(engine, this, compiledFunction);
+ }
+
+ Scope scope(engine);
+ Scoped<InternalClass> ic(scope);
- linkBackendToEngine(engine);
+ runtimeBlocks.resize(data->blockTableSize);
+ for (int i = 0 ;i < runtimeBlocks.size(); ++i) {
+ const QV4::CompiledData::Block *compiledBlock = data->blockAt(i);
+ ic = engine->internalClasses(EngineBase::Class_CallContext);
+
+ // first locals
+ const quint32_le *localsIndices = compiledBlock->localsTable();
+ for (quint32 i = 0; i < compiledBlock->nLocals; ++i)
+ ic = ic->addMember(engine->identifierTable->asPropertyKey(runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
+ runtimeBlocks[i] = ic->d();
+ }
static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
if (showCode) {
qDebug() << "=== Constant table";
Moth::dumpConstantTable(constants, data->constantTableSize);
qDebug() << "=== String table";
- for (uint i = 0; i < data->stringTableSize; ++i)
+ for (uint i = 0, end = totalStringCount(); i < end; ++i)
qDebug() << " " << i << ":" << runtimeStrings[i]->toQString();
qDebug() << "=== Closure table";
for (uint i = 0; i < data->functionTableSize; ++i)
@@ -215,8 +240,6 @@ void CompilationUnit::unlink()
propertyCaches.clear();
- for (int ii = 0; ii < dependentScripts.count(); ++ii)
- dependentScripts.at(ii)->release();
dependentScripts.clear();
typeNameCache = nullptr;
@@ -236,37 +259,50 @@ void CompilationUnit::unlink()
runtimeClasses = nullptr;
qDeleteAll(runtimeFunctions);
runtimeFunctions.clear();
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- delete [] constants;
- constants = nullptr;
-#endif
}
void CompilationUnit::markObjects(QV4::MarkStack *markStack)
{
- for (uint i = 0; i < data->stringTableSize; ++i)
- if (runtimeStrings[i])
- runtimeStrings[i]->mark(markStack);
+ if (runtimeStrings) {
+ for (uint i = 0, end = totalStringCount(); i < end; ++i)
+ if (runtimeStrings[i])
+ runtimeStrings[i]->mark(markStack);
+ }
if (runtimeRegularExpressions) {
for (uint i = 0; i < data->regexpTableSize; ++i)
runtimeRegularExpressions[i].mark(markStack);
}
+ if (runtimeClasses) {
+ for (uint i = 0; i < data->jsClassTableSize; ++i)
+ if (runtimeClasses[i])
+ runtimeClasses[i]->mark(markStack);
+ }
+ for (QV4::Function *f : qAsConst(runtimeFunctions))
+ if (f && f->internalClass)
+ f->internalClass->mark(markStack);
+ for (QV4::Heap::InternalClass *c : qAsConst(runtimeBlocks))
+ if (c)
+ c->mark(markStack);
+
+ if (runtimeLookups) {
+ for (uint i = 0; i < data->lookupTableSize; ++i)
+ runtimeLookups[i].markObjects(markStack);
+ }
+
+ if (m_module)
+ m_module->mark(markStack);
}
-IdentifierHash CompilationUnit::namedObjectsPerComponent(int componentObjectIndex)
+IdentifierHash CompilationUnit::createNamedObjectsPerComponent(int componentObjectIndex)
{
- auto it = namedObjectsPerComponentCache.find(componentObjectIndex);
- if (it == namedObjectsPerComponentCache.end()) {
- IdentifierHash namedObjectCache(engine);
- const CompiledData::Object *component = data->objectAt(componentObjectIndex);
- const quint32_le *namedObjectIndexPtr = component->namedObjectsInComponentTable();
- for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) {
- const CompiledData::Object *namedObject = data->objectAt(*namedObjectIndexPtr);
- namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id);
- }
- it = namedObjectsPerComponentCache.insert(componentObjectIndex, namedObjectCache);
- }
- return *it;
+ IdentifierHash namedObjectCache(engine);
+ const CompiledData::Object *component = objectAt(componentObjectIndex);
+ const quint32_le *namedObjectIndexPtr = component->namedObjectsInComponentTable();
+ for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) {
+ const CompiledData::Object *namedObject = objectAt(*namedObjectIndexPtr);
+ namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id);
+ }
+ return *namedObjectsPerComponentCache.insert(componentObjectIndex, namedObjectCache);
}
void CompilationUnit::finalizeCompositeType(QQmlEnginePrivate *qmlEngine)
@@ -294,8 +330,8 @@ void CompilationUnit::finalizeCompositeType(QQmlEnginePrivate *qmlEngine)
int bindingCount = 0;
int parserStatusCount = 0;
int objectCount = 0;
- for (quint32 i = 0; i < data->nObjects; ++i) {
- const QV4::CompiledData::Object *obj = data->objectAt(i);
+ for (quint32 i = 0, count = this->objectCount(); i < count; ++i) {
+ const QV4::CompiledData::Object *obj = objectAt(i);
bindingCount += obj->nBindings;
if (auto *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) {
if (typeRef->type.isValid()) {
@@ -334,6 +370,219 @@ bool CompilationUnit::verifyChecksum(const DependentTypesHasher &dependencyHashe
sizeof(data->dependencyMD5Checksum)) == 0;
}
+QStringList CompilationUnit::moduleRequests() const
+{
+ QStringList requests;
+ requests.reserve(data->moduleRequestTableSize);
+ for (uint i = 0; i < data->moduleRequestTableSize; ++i)
+ requests << stringAt(data->moduleRequestTable()[i]);
+ return requests;
+}
+
+Heap::Module *CompilationUnit::instantiate(ExecutionEngine *engine)
+{
+ if (m_module)
+ return m_module;
+
+ if (!this->engine)
+ linkToEngine(engine);
+
+ m_module = engine->memoryManager->allocate<Module>(engine, this);
+
+ for (const QString &request: moduleRequests()) {
+ auto dependentModuleUnit = engine->loadModule(QUrl(request), this);
+ if (engine->hasException)
+ return nullptr;
+ dependentModuleUnit->instantiate(engine);
+ }
+
+ Scope scope(engine);
+ ScopedString importName(scope);
+
+ const uint importCount = data->importEntryTableSize;
+ imports = new const Value *[importCount];
+ memset(imports, 0, importCount * sizeof(Value *));
+ for (uint i = 0; i < importCount; ++i) {
+ const CompiledData::ImportEntry &entry = data->importEntryTable()[i];
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(entry.moduleRequest)), this);
+ importName = runtimeStrings[entry.importName];
+ const Value *valuePtr = dependentModuleUnit->resolveExport(importName);
+ if (!valuePtr) {
+ QString referenceErrorMessage = QStringLiteral("Unable to resolve import reference ");
+ referenceErrorMessage += importName->toQString();
+ engine->throwReferenceError(referenceErrorMessage, fileName(), /*### line*/1, /*### column*/1);
+ return nullptr;
+ }
+ imports[i] = valuePtr;
+ }
+
+ for (uint i = 0; i < data->indirectExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->indirectExportEntryTable()[i];
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(entry.moduleRequest)), this);
+ if (!dependentModuleUnit)
+ return nullptr;
+
+ ScopedString importName(scope, runtimeStrings[entry.importName]);
+ if (!dependentModuleUnit->resolveExport(importName)) {
+ QString referenceErrorMessage = QStringLiteral("Unable to resolve re-export reference ");
+ referenceErrorMessage += importName->toQString();
+ engine->throwReferenceError(referenceErrorMessage, fileName(), /*### line*/1, /*### column*/1);
+ return nullptr;
+ }
+ }
+
+ return m_module;
+}
+
+const Value *CompilationUnit::resolveExport(QV4::String *exportName)
+{
+ QVector<ResolveSetEntry> resolveSet;
+ return resolveExportRecursively(exportName, &resolveSet);
+}
+
+QStringList CompilationUnit::exportedNames() const
+{
+ QStringList names;
+ QVector<const CompiledData::CompilationUnit*> exportNameSet;
+ getExportedNamesRecursively(&names, &exportNameSet);
+ names.sort();
+ auto last = std::unique(names.begin(), names.end());
+ names.erase(last, names.end());
+ return names;
+}
+
+const Value *CompilationUnit::resolveExportRecursively(QV4::String *exportName, QVector<ResolveSetEntry> *resolveSet)
+{
+ if (!m_module)
+ return nullptr;
+
+ for (const auto &entry: *resolveSet)
+ if (entry.module == this && entry.exportName->isEqualTo(exportName))
+ return nullptr;
+
+ (*resolveSet) << ResolveSetEntry(this, exportName);
+
+ if (exportName->toQString() == QLatin1String("*"))
+ return &m_module->self;
+
+ Scope scope(engine);
+
+ if (auto localExport = lookupNameInExportTable(data->localExportEntryTable(), data->localExportEntryTableSize, exportName)) {
+ ScopedString localName(scope, runtimeStrings[localExport->localName]);
+ uint index = m_module->scope->internalClass->indexOfValueOrGetter(localName->toPropertyKey());
+ if (index == UINT_MAX)
+ return nullptr;
+ if (index >= m_module->scope->locals.size)
+ return imports[index - m_module->scope->locals.size];
+ return &m_module->scope->locals[index];
+ }
+
+ if (auto indirectExport = lookupNameInExportTable(data->indirectExportEntryTable(), data->indirectExportEntryTableSize, exportName)) {
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(indirectExport->moduleRequest)), this);
+ if (!dependentModuleUnit)
+ return nullptr;
+ ScopedString importName(scope, runtimeStrings[indirectExport->importName]);
+ return dependentModuleUnit->resolveExportRecursively(importName, resolveSet);
+ }
+
+
+ if (exportName->toQString() == QLatin1String("default"))
+ return nullptr;
+
+ const Value *starResolution = nullptr;
+
+ for (uint i = 0; i < data->starExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->starExportEntryTable()[i];
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(entry.moduleRequest)), this);
+ if (!dependentModuleUnit)
+ return nullptr;
+
+ const Value *resolution = dependentModuleUnit->resolveExportRecursively(exportName, resolveSet);
+ // ### handle ambiguous
+ if (resolution) {
+ if (!starResolution) {
+ starResolution = resolution;
+ continue;
+ }
+ if (resolution != starResolution)
+ return nullptr;
+ }
+ }
+
+ return starResolution;
+}
+
+const ExportEntry *CompilationUnit::lookupNameInExportTable(const ExportEntry *firstExportEntry, int tableSize, QV4::String *name) const
+{
+ const CompiledData::ExportEntry *lastExportEntry = firstExportEntry + tableSize;
+ auto matchingExport = std::lower_bound(firstExportEntry, lastExportEntry, name, [this](const CompiledData::ExportEntry &lhs, QV4::String *name) {
+ return stringAt(lhs.exportName) < name->toQString();
+ });
+ if (matchingExport == lastExportEntry || stringAt(matchingExport->exportName) != name->toQString())
+ return nullptr;
+ return matchingExport;
+}
+
+void CompilationUnit::getExportedNamesRecursively(QStringList *names, QVector<const CompilationUnit*> *exportNameSet, bool includeDefaultExport) const
+{
+ if (exportNameSet->contains(this))
+ return;
+ exportNameSet->append(this);
+
+ const auto append = [names, includeDefaultExport](const QString &name) {
+ if (!includeDefaultExport && name == QLatin1String("default"))
+ return;
+ names->append(name);
+ };
+
+ for (uint i = 0; i < data->localExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->localExportEntryTable()[i];
+ append(stringAt(entry.exportName));
+ }
+
+ for (uint i = 0; i < data->indirectExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->indirectExportEntryTable()[i];
+ append(stringAt(entry.exportName));
+ }
+
+ for (uint i = 0; i < data->starExportEntryTableSize; ++i) {
+ const CompiledData::ExportEntry &entry = data->starExportEntryTable()[i];
+ auto dependentModuleUnit = engine->loadModule(QUrl(stringAt(entry.moduleRequest)), this);
+ if (!dependentModuleUnit)
+ return;
+ dependentModuleUnit->getExportedNamesRecursively(names, exportNameSet, /*includeDefaultExport*/false);
+ }
+}
+
+void CompilationUnit::evaluate()
+{
+ if (m_moduleEvaluated)
+ return;
+ m_moduleEvaluated = true;
+
+ for (const QString &request: moduleRequests()) {
+ auto dependentModuleUnit = engine->loadModule(QUrl(request), this);
+ if (engine->hasException)
+ return;
+ dependentModuleUnit->evaluate();
+ if (engine->hasException)
+ return;
+ }
+
+ QV4::Function *moduleFunction = runtimeFunctions[data->indexOfRootFunction];
+ CppStackFrame frame;
+ frame.init(engine, moduleFunction, nullptr, 0);
+ frame.setupJSFrame(engine->jsStackTop, Value::undefinedValue(), m_module->scope,
+ Value::undefinedValue(), Value::undefinedValue());
+
+ frame.push();
+ engine->jsStackTop += frame.requiredJSStackFrameSize();
+ auto frameCleanup = qScopeGuard([&frame]() {
+ frame.pop();
+ });
+ Moth::VME::exec(&frame, engine);
+}
+
bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString)
{
if (!QQmlFile::isLocalFile(url)) {
@@ -344,31 +593,31 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeS
const QString sourcePath = QQmlFile::urlToLocalFileOrQrc(url);
QScopedPointer<CompilationUnitMapper> cacheFile(new CompilationUnitMapper());
- CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourceTimeStamp, errorString);
- if (!mappedUnit)
- return false;
-
- const Unit * const oldDataPtr = (data && !(data->flags & QV4::CompiledData::Unit::StaticData)) ? data : nullptr;
- QScopedValueRollback<const Unit *> dataPtrChange(data, mappedUnit);
+ const QStringList cachePaths = { sourcePath + QLatin1Char('c'), localCacheFilePath(url) };
+ for (const QString &cachePath : cachePaths) {
+ CompiledData::Unit *mappedUnit = cacheFile->open(cachePath, sourceTimeStamp, errorString);
+ if (!mappedUnit)
+ continue;
+
+ const Unit * const oldDataPtr = (data && !(data->flags & QV4::CompiledData::Unit::StaticData)) ? data : nullptr;
+ const Unit *oldData = data;
+ auto dataPtrRevert = qScopeGuard([this, oldData](){
+ setUnitData(oldData);
+ });
+ setUnitData(mappedUnit);
+
+ if (data->sourceFileIndex != 0 && sourcePath != QQmlFile::urlToLocalFileOrQrc(stringAt(data->sourceFileIndex))) {
+ *errorString = QStringLiteral("QML source file has moved to a different location.");
+ continue;
+ }
- if (data->sourceFileIndex != 0 && sourcePath != QQmlFile::urlToLocalFileOrQrc(stringAt(data->sourceFileIndex))) {
- *errorString = QStringLiteral("QML source file has moved to a different location.");
- return false;
+ dataPtrRevert.dismiss();
+ free(const_cast<Unit*>(oldDataPtr));
+ backingFile.reset(cacheFile.take());
+ return true;
}
- dataPtrChange.commit();
- free(const_cast<Unit*>(oldDataPtr));
- backingFile.reset(cacheFile.take());
- return true;
-}
-
-void CompilationUnit::linkBackendToEngine(ExecutionEngine *engine)
-{
- runtimeFunctions.resize(data->functionTableSize);
- for (int i = 0 ;i < runtimeFunctions.size(); ++i) {
- const QV4::CompiledData::Function *compiledFunction = data->functionAt(i);
- runtimeFunctions[i] = new QV4::Function(engine, this, compiledFunction, &Moth::VME::exec);
- }
+ return false;
}
#endif // V4_BOOTSTRAP
@@ -391,7 +640,7 @@ bool CompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorString)
*errorString = QStringLiteral("File has to be a local file.");
return false;
}
- const QString outputFileName = cacheFilePath(unitUrl);
+ const QString outputFileName = localCacheFilePath(unitUrl);
#endif
#if QT_CONFIG(temporaryfile)
@@ -429,109 +678,38 @@ bool CompilationUnit::saveToDisk(const QUrl &unitUrl, QString *errorString)
#endif // QT_CONFIG(temporaryfile)
}
-Unit *CompilationUnit::createUnitData(QmlIR::Document *irDocument)
+void CompilationUnit::setUnitData(const Unit *unitData, const QmlUnit *qmlUnit,
+ const QString &fileName, const QString &finalUrlString)
{
- if (!irDocument->javaScriptCompilationUnit->data)
- return irDocument->jsGenerator.generateUnit(QV4::Compiler::JSUnitGenerator::GenerateWithoutStringTable);
-
- QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = irDocument->javaScriptCompilationUnit;
- QV4::CompiledData::Unit *jsUnit = const_cast<QV4::CompiledData::Unit*>(compilationUnit->data);
- auto ensureWritableUnit = [&jsUnit, &compilationUnit]() {
- if (jsUnit == compilationUnit->data) {
- char *unitCopy = (char*)malloc(jsUnit->unitSize);
- memcpy(unitCopy, jsUnit, jsUnit->unitSize);
- jsUnit = reinterpret_cast<QV4::CompiledData::Unit*>(unitCopy);
- }
- };
-
- QV4::Compiler::StringTableGenerator &stringTable = irDocument->jsGenerator.stringTable;
-
- if (jsUnit->sourceFileIndex == quint32(0) || jsUnit->stringAt(jsUnit->sourceFileIndex) != irDocument->jsModule.fileName) {
- ensureWritableUnit();
- jsUnit->sourceFileIndex = stringTable.registerString(irDocument->jsModule.fileName);
- jsUnit->finalUrlIndex = stringTable.registerString(irDocument->jsModule.finalUrl);
- }
-
- // Collect signals that have had a change in signature (from onClicked to onClicked(mouse) for example)
- // and now need fixing in the QV4::CompiledData. Also register strings at the same time, to finalize
- // the string table.
- QVector<quint32> changedSignals;
- QVector<QQmlJS::AST::FormalParameterList*> changedSignalParameters;
- for (QmlIR::Object *o: qAsConst(irDocument->objects)) {
- for (QmlIR::Binding *binding = o->firstBinding(); binding; binding = binding->next) {
- if (!(binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression))
- continue;
-
- quint32 functionIndex = binding->value.compiledScriptIndex;
- QmlIR::CompiledFunctionOrExpression *foe = o->functionsAndExpressions->slowAt(functionIndex);
- if (!foe)
- continue;
-
- // save absolute index
- changedSignals << o->runtimeFunctionIndices.at(functionIndex);
-
- Q_ASSERT(foe->node);
- Q_ASSERT(QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(foe->node));
-
- QQmlJS::AST::FormalParameterList *parameters = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(foe->node)->formals;
- changedSignalParameters << parameters;
-
- for (; parameters; parameters = parameters->next)
- stringTable.registerString(parameters->name.toString());
- }
- }
-
- QVector<quint32> signalParameterNameTable;
- quint32 signalParameterNameTableOffset = jsUnit->unitSize;
-
- // Update signal signatures
- if (!changedSignals.isEmpty()) {
- if (jsUnit == compilationUnit->data) {
- char *unitCopy = (char*)malloc(jsUnit->unitSize);
- memcpy(unitCopy, jsUnit, jsUnit->unitSize);
- jsUnit = reinterpret_cast<QV4::CompiledData::Unit*>(unitCopy);
- }
-
- for (int i = 0; i < changedSignals.count(); ++i) {
- const uint functionIndex = changedSignals.at(i);
- // The data is now read-write due to the copy above, so the const_cast is ok.
- QV4::CompiledData::Function *function = const_cast<QV4::CompiledData::Function *>(jsUnit->functionAt(functionIndex));
- Q_ASSERT(function->nFormals == quint32(0));
-
- function->formalsOffset = signalParameterNameTableOffset - jsUnit->functionOffsetTable()[functionIndex];
-
- for (QQmlJS::AST::FormalParameterList *parameters = changedSignalParameters.at(i);
- parameters; parameters = parameters->next) {
- signalParameterNameTable.append(stringTable.getStringId(parameters->name.toString()));
- function->nFormals = function->nFormals + 1;
- }
-
- // Hack to ensure an activation is created.
- function->flags |= QV4::CompiledData::Function::HasCatchOrWith | QV4::CompiledData::Function::HasDirectEval;
-
- signalParameterNameTableOffset += function->nFormals * sizeof(quint32);
- }
- }
+ data = unitData;
+ qmlData = nullptr;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ delete [] constants;
+#endif
+ constants = nullptr;
+ m_fileName.clear();
+ m_finalUrlString.clear();
+ if (!data)
+ return;
- if (!signalParameterNameTable.isEmpty()) {
- ensureWritableUnit();
- Q_ASSERT(jsUnit != compilationUnit->data);
- const uint signalParameterTableSize = signalParameterNameTable.count() * sizeof(quint32);
- uint newSize = jsUnit->unitSize + signalParameterTableSize;
- const uint oldSize = jsUnit->unitSize;
- char *unitWithSignalParameters = (char*)realloc(jsUnit, newSize);
- memcpy(unitWithSignalParameters + oldSize, signalParameterNameTable.constData(), signalParameterTableSize);
- jsUnit = reinterpret_cast<QV4::CompiledData::Unit*>(unitWithSignalParameters);
- jsUnit->unitSize = newSize;
- }
+ qmlData = qmlUnit ? qmlUnit : data->qmlUnit();
- if (jsUnit != compilationUnit->data)
- jsUnit->flags &= ~QV4::CompiledData::Unit::StaticData;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ Value *bigEndianConstants = new Value[data->constantTableSize];
+ const quint64_le *littleEndianConstants = data->constants();
+ for (uint i = 0; i < data->constantTableSize; ++i)
+ bigEndianConstants[i] = Value::fromReturnedValue(littleEndianConstants[i]);
+ constants = bigEndianConstants;
+#else
+ constants = reinterpret_cast<const Value*>(data->constants());
+#endif
- return jsUnit;
+ m_fileName = !fileName.isEmpty() ? fileName : stringAt(data->sourceFileIndex);
+ m_finalUrlString = !finalUrlString.isEmpty() ? finalUrlString : stringAt(data->finalUrlIndex);
}
-QString Binding::valueAsString(const Unit *unit) const
+#ifndef V4_BOOTSTRAP
+QString Binding::valueAsString(const CompilationUnit *unit) const
{
switch (type) {
case Type_Script:
@@ -540,29 +718,31 @@ QString Binding::valueAsString(const Unit *unit) const
case Type_Boolean:
return value.b ? QStringLiteral("true") : QStringLiteral("false");
case Type_Number:
- return QString::number(valueAsNumber());
+ return QString::number(valueAsNumber(unit->constants));
case Type_Invalid:
return QString();
#if !QT_CONFIG(translation)
case Type_TranslationById:
case Type_Translation:
- return unit->stringAt(stringIndex);
+ return unit->stringAt(unit->unitData->translations()[value.translationDataIndex].stringIndex);
#else
case Type_TranslationById: {
- QByteArray id = unit->stringAt(stringIndex).toUtf8();
- return qtTrId(id.constData(), value.translationData.number);
+ const TranslationData &translation = unit->unitData()->translations()[value.translationDataIndex];
+ QByteArray id = unit->stringAt(translation.stringIndex).toUtf8();
+ return qtTrId(id.constData(), translation.number);
}
case Type_Translation: {
+ const TranslationData &translation = unit->unitData()->translations()[value.translationDataIndex];
// This code must match that in the qsTr() implementation
- const QString &path = unit->stringAt(unit->sourceFileIndex);
+ const QString &path = unit->stringAt(unit->unitData()->sourceFileIndex);
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5)
: QStringRef();
QByteArray contextUtf8 = context.toUtf8();
- QByteArray comment = unit->stringAt(value.translationData.commentIndex).toUtf8();
- QByteArray text = unit->stringAt(stringIndex).toUtf8();
+ QByteArray comment = unit->stringAt(translation.commentIndex).toUtf8();
+ QByteArray text = unit->stringAt(translation.stringIndex).toUtf8();
return QCoreApplication::translate(contextUtf8.constData(), text.constData(),
- comment.constData(), value.translationData.number);
+ comment.constData(), translation.number);
}
#endif
default:
@@ -614,7 +794,7 @@ QString Binding::escapedString(const QString &string)
return tmp;
}
-QString Binding::valueAsScriptString(const Unit *unit) const
+QString Binding::valueAsScriptString(const CompilationUnit *unit) const
{
if (type == Type_String)
return escapedString(unit->stringAt(stringIndex));
@@ -622,11 +802,10 @@ QString Binding::valueAsScriptString(const Unit *unit) const
return valueAsString(unit);
}
-#ifndef V4_BOOTSTRAP
/*!
Returns the property cache, if one alread exists. The cache is not referenced.
*/
-QQmlPropertyCache *ResolvedTypeReference::propertyCache() const
+QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::propertyCache() const
{
if (type.isValid())
return typePropertyCache;
@@ -637,7 +816,7 @@ QQmlPropertyCache *ResolvedTypeReference::propertyCache() const
/*!
Returns the property cache, creating one if it doesn't already exist. The cache is not referenced.
*/
-QQmlPropertyCache *ResolvedTypeReference::createPropertyCache(QQmlEngine *engine)
+QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::createPropertyCache(QQmlEngine *engine)
{
if (typePropertyCache) {
return typePropertyCache;
@@ -656,7 +835,7 @@ bool ResolvedTypeReference::addToHash(QCryptographicHash *hash, QQmlEngine *engi
hash->addData(createPropertyCache(engine)->checksum(&ok));
return ok;
}
- hash->addData(compilationUnit->data->md5Checksum, sizeof(compilationUnit->data->md5Checksum));
+ hash->addData(compilationUnit->unitData()->md5Checksum, sizeof(compilationUnit->unitData()->md5Checksum));
return true;
}
@@ -754,7 +933,7 @@ bool Unit::verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString)
}
#if defined(QML_COMPILE_HASH)
- if (qstrcmp(QML_COMPILE_HASH, libraryVersionHash) != 0) {
+ if (qstrcmp(CompiledData::qml_compile_hash, libraryVersionHash) != 0) {
*errorString = QStringLiteral("QML library version mismatch. Expected compile hash does not match");
return false;
}
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 1df9d6794f..1f6c591ada 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -88,6 +88,10 @@ struct Document;
namespace QV4 {
+namespace Heap {
+struct Module;
+};
+
struct Function;
class EvalISelFactory;
class CompilationUnitMapper;
@@ -133,14 +137,17 @@ static_assert(sizeof(Location) == 4, "Location structure needs to have the expec
struct RegExp
{
enum Flags : unsigned int {
+ RegExp_NoFlags = 0x0,
RegExp_Global = 0x01,
RegExp_IgnoreCase = 0x02,
- RegExp_Multiline = 0x04
+ RegExp_Multiline = 0x04,
+ RegExp_Unicode = 0x08,
+ RegExp_Sticky = 0x10
};
union {
quint32 _dummy;
- quint32_le_bitfield<0, 4> flags;
- quint32_le_bitfield<4, 28> stringIndex;
+ quint32_le_bitfield<0, 5> flags;
+ quint32_le_bitfield<5, 27> stringIndex;
};
RegExp() : _dummy(0) { }
@@ -186,21 +193,67 @@ struct JSClass
};
static_assert(sizeof(JSClass) == 4, "JSClass structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+// This data structure is intended to be binary compatible with QStringData/QStaticStringData on
+// 64-bit and 32-bit little-endian architectures, in all directions. So the same structure mapped
+// from a file must be castable to a QStringData regardless of the pointer size. With the first
+// few fields that's easy, they're always 32-bit. However the offset field of QArrayData is a
+// ptrdiff_t and thus variable in size.
+// On 64-bit systems compilers enforce an 8-byte alignment and thus place it at offset 16, while
+// on 32-bit systems offset 12 is sufficient. Therefore the two values don't overlap and contain
+// the same value.
struct String
{
+ qint32_le refcount; // -1
qint32_le size;
+ quint32_le allocAndCapacityReservedFlag; // 0
+ quint32_le offsetOn32Bit;
+ quint64_le offsetOn64Bit;
// uint16 strdata[]
static int calculateSize(const QString &str) {
- return (sizeof(String) + str.length() * sizeof(quint16) + 7) & ~0x7;
+ return (sizeof(String) + (str.length() + 1) * sizeof(quint16) + 7) & ~0x7;
}
};
-static_assert(sizeof(String) == 4, "String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(String) == 24, "String structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+// Ensure compatibility with QString
+static_assert(offsetof(QArrayData, ref) == offsetof(String, refcount), "refcount must be at the same location");
+static_assert(offsetof(QArrayData, size) == offsetof(String, size), "size must be at the same location");
+static_assert(offsetof(String, offsetOn64Bit) == 16, "offset must be at 8-byte aligned location");
+static_assert(offsetof(String, offsetOn32Bit) == 12, "offset must be at 4-byte aligned location");
+#if QT_POINTER_SIZE == 8
+static_assert(offsetof(QArrayData, offset) == offsetof(String, offsetOn64Bit), "offset must be at the same location");
+#else
+static_assert(offsetof(QArrayData, offset) == offsetof(String, offsetOn32Bit), "offset must be at the same location");
+#endif
struct CodeOffsetToLine {
quint32_le codeOffset;
quint32_le line;
};
+static_assert(sizeof(CodeOffsetToLine) == 8, "CodeOffsetToLine structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+struct Block
+{
+ quint32_le nLocals;
+ quint32_le localsOffset;
+ quint16_le sizeOfLocalTemporalDeadZone;
+ quint16_le padding;
+
+ const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); }
+
+ static int calculateSize(int nLocals) {
+ int trailingData = nLocals*sizeof (quint32);
+ size_t size = align(align(sizeof(Block)) + size_t(trailingData));
+ Q_ASSERT(size < INT_MAX);
+ return int(size);
+ }
+
+ static size_t align(size_t a) {
+ return (a + 7) & ~size_t(7);
+ }
+};
+static_assert(sizeof(Block) == 12, "Block structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
// Function is aligned on an 8-byte boundary to make sure there are no bus errors or penalties
// for unaligned access. The ordering of the fields is also from largest to smallest.
@@ -208,10 +261,8 @@ struct Function
{
enum Flags : unsigned int {
IsStrict = 0x1,
- HasDirectEval = 0x2,
- UsesArgumentsObject = 0x4,
-// Unused = 0x8,
- HasCatchOrWith = 0x10
+ IsArrowFunction = 0x2,
+ IsGenerator = 0x4
};
// Absolute offset into file where the code for this function is located.
@@ -219,48 +270,52 @@ struct Function
quint32_le codeSize;
quint32_le nameIndex;
- quint32_le nFormals;
- quint32_le formalsOffset;
- quint32_le nLocals;
+ quint16_le length;
+ quint16_le nFormals;
+ quint32_le formalsOffset; // Can't turn this into a calculated offset because of the mutation in CompilationUnit::createUnitData.
quint32_le localsOffset;
- quint32_le nLineNumbers;
- quint32_le lineNumberOffset;
+ quint16_le nLocals;
+ quint16_le nLineNumbers;
+ size_t lineNumberOffset() const { return localsOffset + nLocals * sizeof(quint32); }
quint32_le nestedFunctionIndex; // for functions that only return a single closure, used in signal handlers
- quint32_le nRegisters;
+ quint16_le sizeOfLocalTemporalDeadZone;
+ quint16_le firstTemporalDeadZoneRegister;
+ quint16_le sizeOfRegisterTemporalDeadZone;
+ quint16_le nRegisters;
Location location;
// Qml Extensions Begin
- quint32_le nDependingIdObjects;
- quint32_le dependingIdObjectsOffset; // Array of resolved ID objects
- quint32_le nDependingContextProperties;
- quint32_le dependingContextPropertiesOffset; // Array of int pairs (property index and notify index)
- quint32_le nDependingScopeProperties;
- quint32_le dependingScopePropertiesOffset; // Array of int pairs (property index and notify index)
+ // Array of resolved ID objects
+ size_t dependingIdObjectsOffset() const { return lineNumberOffset() + nLineNumbers * sizeof(CodeOffsetToLine); }
+ quint16_le nDependingIdObjects;
+ quint16_le nDependingContextProperties;
+ // Array of int pairs (property index and notify index)
+ size_t dependingContextPropertiesOffset() const { return dependingIdObjectsOffset() + nDependingIdObjects * sizeof(quint32); }
+ quint16_le nDependingScopeProperties;
+ // Array of int pairs (property index and notify index)
+ size_t dependingScopePropertiesOffset() const { return dependingContextPropertiesOffset() + nDependingContextProperties * sizeof(quint32); }
// Qml Extensions End
-// quint32 formalsIndex[nFormals]
-// quint32 localsIndex[nLocals]
-// quint32 offsetForInnerFunctions[nInnerFunctions]
-// Function[nInnerFunctions]
-
// Keep all unaligned data at the end
quint8 flags;
quint8 padding1;
- quint16_le padding2;
+
+ // quint32 formalsIndex[nFormals]
+ // quint32 localsIndex[nLocals]
const quint32_le *formalsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + formalsOffset); }
const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); }
- const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast<const CodeOffsetToLine *>(reinterpret_cast<const char *>(this) + lineNumberOffset); }
- const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset); }
- const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset); }
- const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset); }
+ const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast<const CodeOffsetToLine *>(reinterpret_cast<const char *>(this) + lineNumberOffset()); }
+ const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset()); }
+ const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset()); }
+ const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset()); }
// --- QQmlPropertyCacheCreator interface
const quint32_le *formalsBegin() const { return formalsTable(); }
const quint32_le *formalsEnd() const { return formalsTable() + nFormals; }
// ---
- const uchar *code() const { return reinterpret_cast<const uchar *>(this) + codeOffset; }
+ const char *code() const { return reinterpret_cast<const char *>(this) + codeOffset; }
inline bool hasQmlDependencies() const { return nDependingIdObjects > 0 || nDependingContextProperties > 0 || nDependingScopeProperties > 0; }
@@ -276,15 +331,73 @@ struct Function
return (a + 7) & ~size_t(7);
}
};
-static_assert(sizeof(Function) == 76, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Function) == 52, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+struct Method {
+ enum Type {
+ Regular,
+ Getter,
+ Setter
+ };
+
+ quint32_le name;
+ quint32_le type;
+ quint32_le function;
+};
+static_assert(sizeof(Method) == 12, "Method structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+struct Class
+{
+ quint32_le nameIndex;
+ quint32_le scopeIndex;
+ quint32_le constructorFunction;
+ quint32_le nStaticMethods;
+ quint32_le nMethods;
+ quint32_le methodTableOffset;
+
+ const Method *methodTable() const { return reinterpret_cast<const Method *>(reinterpret_cast<const char *>(this) + methodTableOffset); }
+
+ static int calculateSize(int nStaticMethods, int nMethods) {
+ int trailingData = (nStaticMethods + nMethods) * sizeof(Method);
+ size_t size = align(sizeof(Class) + trailingData);
+ Q_ASSERT(size < INT_MAX);
+ return int(size);
+ }
+
+ static size_t align(size_t a) {
+ return (a + 7) & ~size_t(7);
+ }
+};
+static_assert(sizeof(Class) == 24, "Class structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+struct ExportEntry
+{
+ quint32_le exportName;
+ quint32_le moduleRequest;
+ quint32_le importName;
+ quint32_le localName;
+};
+static_assert(sizeof(ExportEntry) == 16, "ExportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+struct ImportEntry
+{
+ quint32_le moduleRequest;
+ quint32_le importName;
+ quint32_le localName;
+ quint32_le padding;
+};
+static_assert(sizeof(ImportEntry) == 16, "ImportEntry structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
// Qml data structures
-struct Q_QML_EXPORT TranslationData {
+struct Q_QML_EXPORT TranslationData
+{
+ quint32_le stringIndex;
quint32_le commentIndex;
qint32_le number;
+ quint32_le padding;
};
-static_assert(sizeof(TranslationData) == 8, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(TranslationData) == 16, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Q_QML_PRIVATE_EXPORT Binding
{
@@ -322,18 +435,16 @@ struct Q_QML_PRIVATE_EXPORT Binding
};
union {
bool b;
- quint64 doubleValue; // do not access directly, needs endian protected access
+ quint32_le constantValueIndex;
quint32_le compiledScriptIndex; // used when Type_Script
quint32_le objectIndex;
- TranslationData translationData; // used when Type_Translation
+ quint32_le translationDataIndex; // used when Type_Translation
} value;
- quint32_le stringIndex; // Set for Type_String, Type_Translation and Type_Script (the latter because of script strings)
+ quint32_le stringIndex; // Set for Type_String and Type_Script (the latter because of script strings)
Location location;
Location valueLocation;
- quint32_le padding;
-
bool isValueBinding() const
{
if (type == Type_AttachedProperty
@@ -385,25 +496,18 @@ struct Q_QML_PRIVATE_EXPORT Binding
static QString escapedString(const QString &string);
- bool containsTranslations() const { return type == Type_Translation || type == Type_TranslationById; }
- bool evaluatesToString() const { return type == Type_String || containsTranslations(); }
+ bool isTranslationBinding() const { return type == Type_Translation || type == Type_TranslationById; }
+ bool evaluatesToString() const { return type == Type_String || isTranslationBinding(); }
- QString valueAsString(const Unit *unit) const;
- QString valueAsScriptString(const Unit *unit) const;
- double valueAsNumber() const
+#ifndef V4_BOOTSTRAP
+ QString valueAsString(const CompilationUnit *unit) const;
+ QString valueAsScriptString(const CompilationUnit *unit) const;
+#endif
+ double valueAsNumber(const Value *constantTable) const
{
if (type != Type_Number)
return 0.0;
- quint64 intval = qFromLittleEndian<quint64>(value.doubleValue);
- double d;
- memcpy(&d, &intval, sizeof(double));
- return d;
- }
- void setNumberValueInternal(double d)
- {
- quint64 intval;
- memcpy(&intval, &d, sizeof(double));
- value.doubleValue = qToLittleEndian<quint64>(intval);
+ return constantTable[value.constantValueIndex].doubleValue();
}
bool valueAsBoolean() const
@@ -415,7 +519,7 @@ struct Q_QML_PRIVATE_EXPORT Binding
};
-static_assert(sizeof(Binding) == 32, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Binding) == 24, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct EnumValue
{
@@ -423,6 +527,7 @@ struct EnumValue
qint32_le value;
Location location;
};
+static_assert(sizeof(EnumValue) == 12, "EnumValue structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Enum
{
@@ -446,6 +551,7 @@ struct Enum
int enumValueCount() const { return nEnumValues; }
// ---
};
+static_assert(sizeof(Enum) == 12, "Enum structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Parameter
{
@@ -552,17 +658,17 @@ struct Object
qint32_le_bitfield<16, 16> id;
};
qint32_le indexOfDefaultPropertyOrAlias; // -1 means no default property declared in this object
- quint32_le nFunctions;
+ quint16_le nFunctions;
+ quint16_le nProperties;
quint32_le offsetToFunctions;
- quint32_le nProperties;
quint32_le offsetToProperties;
- quint32_le nAliases;
quint32_le offsetToAliases;
- quint32_le nEnums;
+ quint16_le nAliases;
+ quint16_le nEnums;
quint32_le offsetToEnums; // which in turn will be a table with offsets to variable-sized Enum objects
- quint32_le nSignals;
quint32_le offsetToSignals; // which in turn will be a table with offsets to variable-sized Signal objects
- quint32_le nBindings;
+ quint16_le nSignals;
+ quint16_le nBindings;
quint32_le offsetToBindings;
quint32_le nNamedObjectsInComponent;
quint32_le offsetToNamedObjectsInComponent;
@@ -653,7 +759,7 @@ struct Object
int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; }
// ---
};
-static_assert(sizeof(Object) == 80, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Object) == 68, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Import
{
@@ -676,7 +782,28 @@ struct Import
};
static_assert(sizeof(Import) == 24, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+struct QmlUnit
+{
+ quint32_le nImports;
+ quint32_le offsetToImports;
+ quint32_le nObjects;
+ quint32_le offsetToObjects;
+
+ const Import *importAt(int idx) const {
+ return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import));
+ }
+
+ const Object *objectAt(int idx) const {
+ const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToObjects);
+ const quint32_le offset = offsetTable[idx];
+ return reinterpret_cast<const Object*>(reinterpret_cast<const char*>(this) + offset);
+ }
+};
+static_assert(sizeof(QmlUnit) == 16, "QmlUnit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
+enum { QmlCompileHashSpace = 48 };
static const char magic_str[] = "qv4cdata";
+extern const char qml_compile_hash[QmlCompileHashSpace + 1];
struct Unit
{
@@ -688,7 +815,7 @@ struct Unit
quint32_le unitSize; // Size of the Unit and any depending data.
// END DO NOT CHANGE THESE FIELDS EVER
- char libraryVersionHash[48];
+ char libraryVersionHash[QmlCompileHashSpace];
char md5Checksum[16]; // checksum of all bytes following this field.
void generateChecksum();
@@ -697,18 +824,21 @@ struct Unit
enum : unsigned int {
IsJavascript = 0x1,
- IsQml = 0x2,
- StaticData = 0x4, // Unit data persistent in memory?
- IsSingleton = 0x8,
- IsSharedLibrary = 0x10, // .pragma shared?
- ContainsMachineCode = 0x20, // used to determine if we need to mmap with execute permissions
- PendingTypeCompilation = 0x40 // the QML data structures present are incomplete and require type compilation
+ StaticData = 0x2, // Unit data persistent in memory?
+ IsSingleton = 0x4,
+ IsSharedLibrary = 0x8, // .pragma shared?
+ IsESModule = 0x10,
+ PendingTypeCompilation = 0x20 // the QML data structures present are incomplete and require type compilation
};
quint32_le flags;
quint32_le stringTableSize;
quint32_le offsetToStringTable;
quint32_le functionTableSize;
quint32_le offsetToFunctionTable;
+ quint32_le classTableSize;
+ quint32_le offsetToClassTable;
+ quint32_le blockTableSize;
+ quint32_le offsetToBlockTable;
quint32_le lookupTableSize;
quint32_le offsetToLookupTable;
quint32_le regexpTableSize;
@@ -717,28 +847,30 @@ struct Unit
quint32_le offsetToConstantTable;
quint32_le jsClassTableSize;
quint32_le offsetToJSClassTable;
+ quint32_le translationTableSize;
+ quint32_le offsetToTranslationTable;
+ quint32_le localExportEntryTableSize;
+ quint32_le offsetToLocalExportEntryTable;
+ quint32_le indirectExportEntryTableSize;
+ quint32_le offsetToIndirectExportEntryTable;
+ quint32_le starExportEntryTableSize;
+ quint32_le offsetToStarExportEntryTable;
+ quint32_le importEntryTableSize;
+ quint32_le offsetToImportEntryTable;
+ quint32_le moduleRequestTableSize;
+ quint32_le offsetToModuleRequestTable;
qint32_le indexOfRootFunction;
quint32_le sourceFileIndex;
quint32_le finalUrlIndex;
- /* QML specific fields */
- quint32_le nImports;
- quint32_le offsetToImports;
- quint32_le nObjects;
- quint32_le offsetToObjects;
-
- quint32_le padding;
+ quint32_le offsetToQmlUnit;
bool verifyHeader(QDateTime expectedSourceTimeStamp, QString *errorString) const;
- const Import *importAt(int idx) const {
- return reinterpret_cast<const Import*>((reinterpret_cast<const char *>(this)) + offsetToImports + idx * sizeof(Import));
- }
+ /* QML specific fields */
- const Object *objectAt(int idx) const {
- const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToObjects);
- const quint32_le offset = offsetTable[idx];
- return reinterpret_cast<const Object*>(reinterpret_cast<const char*>(this) + offset);
+ const QmlUnit *qmlUnit() const {
+ return reinterpret_cast<const QmlUnit *>(reinterpret_cast<const char *>(this) + offsetToQmlUnit);
}
bool isSingleton() const {
@@ -746,18 +878,19 @@ struct Unit
}
/* end QML specific fields*/
- QString stringAt(int idx) const {
+ QString stringAtInternal(int idx) const {
+ Q_ASSERT(idx < int(stringTableSize));
const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToStringTable);
const quint32_le offset = offsetTable[idx];
const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset);
if (str->size == 0)
return QString();
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ if (flags & StaticData) {
+ const QStringDataPtr holder = { const_cast<QStringData *>(reinterpret_cast<const QStringData*>(str)) };
+ return QString(holder);
+ }
const QChar *characters = reinterpret_cast<const QChar *>(str + 1);
- // Too risky to do this while we unmap disk backed compilation but keep pointers to string
- // data in the identifier tables.
- // if (flags & StaticData)
- // return QString::fromRawData(characters, str->size);
return QString(characters, str->size);
#else
const quint16_le *characters = reinterpret_cast<const quint16_le *>(str + 1);
@@ -770,6 +903,8 @@ struct Unit
}
const quint32_le *functionOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); }
+ const quint32_le *classOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToClassTable); }
+ const quint32_le *blockOffsetTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToBlockTable); }
const Function *functionAt(int idx) const {
const quint32_le *offsetTable = functionOffsetTable();
@@ -777,6 +912,18 @@ struct Unit
return reinterpret_cast<const Function*>(reinterpret_cast<const char *>(this) + offset);
}
+ const Class *classAt(int idx) const {
+ const quint32_le *offsetTable = classOffsetTable();
+ const quint32_le offset = offsetTable[idx];
+ return reinterpret_cast<const Class *>(reinterpret_cast<const char *>(this) + offset);
+ }
+
+ const Block *blockAt(int idx) const {
+ const quint32_le *offsetTable = blockOffsetTable();
+ const quint32_le offset = offsetTable[idx];
+ return reinterpret_cast<const Block *>(reinterpret_cast<const char *>(this) + offset);
+ }
+
const Lookup *lookupTable() const { return reinterpret_cast<const Lookup*>(reinterpret_cast<const char *>(this) + offsetToLookupTable); }
const RegExp *regexpAt(int index) const {
return reinterpret_cast<const RegExp*>(reinterpret_cast<const char *>(this) + offsetToRegexpTable + index * sizeof(RegExp));
@@ -793,9 +940,20 @@ struct Unit
*nMembers = klass->nMembers;
return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass));
}
+
+ const TranslationData *translations() const {
+ return reinterpret_cast<const TranslationData *>(reinterpret_cast<const char *>(this) + offsetToTranslationTable);
+ }
+
+ const ImportEntry *importEntryTable() const { return reinterpret_cast<const ImportEntry *>(reinterpret_cast<const char *>(this) + offsetToImportEntryTable); }
+ const ExportEntry *localExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToLocalExportEntryTable); }
+ const ExportEntry *indirectExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToIndirectExportEntryTable); }
+ const ExportEntry *starExportEntryTable() const { return reinterpret_cast<const ExportEntry *>(reinterpret_cast<const char *>(this) + offsetToStarExportEntryTable); }
+
+ const quint32_le *moduleRequestTable() const { return reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToModuleRequestTable); }
};
-static_assert(sizeof(Unit) == 192, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Unit) == 240, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct TypeReference
{
@@ -832,9 +990,7 @@ struct TypeReferenceMap : QHash<int, TypeReference>
auto propEnd = obj->propertiesEnd();
for ( ; prop != propEnd; ++prop) {
if (prop->type >= QV4::CompiledData::Property::Custom) {
- // ### FIXME: We could report the more accurate location here by using prop->location, but the old
- // compiler can't and the tests expect it to be the object location right now.
- TypeReference &r = this->add(prop->customTypeNameIndex, obj->location);
+ TypeReference &r = this->add(prop->customTypeNameIndex, prop->location);
r.errorWhenNotFound = true;
}
}
@@ -881,17 +1037,23 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnitBase
QV4::Heap::String **runtimeStrings = nullptr; // Array
const Value* constants = nullptr;
QV4::Value *runtimeRegularExpressions = nullptr;
+ QV4::Heap::InternalClass **runtimeClasses = nullptr;
+ const Value** imports = nullptr;
};
Q_STATIC_ASSERT(std::is_standard_layout<CompilationUnitBase>::value);
Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeStrings) == 0);
Q_STATIC_ASSERT(offsetof(CompilationUnitBase, constants) == sizeof(QV4::Heap::String **));
Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeRegularExpressions) == offsetof(CompilationUnitBase, constants) + sizeof(const Value *));
+Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeClasses) == offsetof(CompilationUnitBase, runtimeRegularExpressions) + sizeof(const Value *));
+Q_STATIC_ASSERT(offsetof(CompilationUnitBase, imports) == offsetof(CompilationUnitBase, runtimeClasses) + sizeof(const Value *));
struct Q_QML_PRIVATE_EXPORT CompilationUnit final : public CompilationUnitBase
{
+ const Unit *data = nullptr;
+ const QmlUnit *qmlData = nullptr;
public:
- CompilationUnit(const Unit *unitData = nullptr);
+ CompilationUnit(const Unit *unitData = nullptr, const QString &fileName = QString(), const QString &finalUrlString = QString());
#ifdef V4_BOOTSTRAP
~CompilationUnit() {}
#else
@@ -915,10 +1077,9 @@ public:
return refCount.load();
}
- const Unit *data = nullptr;
-
- // Called only when building QML, when we build the header for JS first and append QML data
- QV4::CompiledData::Unit *createUnitData(QmlIR::Document *irDocument);
+ const Unit *unitData() const { return data; }
+ void setUnitData(const Unit *unitData, const QmlUnit *qmlUnit = nullptr,
+ const QString &fileName = QString(), const QString &finalUrlString = QString());
#ifndef V4_BOOTSTRAP
QIntrusiveListNode nextCompilationUnit;
@@ -932,8 +1093,8 @@ public:
// finalUrl() and finalUrlString() shall be used to resolve further URLs referred to in the code
// They are _not_ intercepted and thus represent the "logical" name for the code.
- QString fileName() const { return data->stringAt(data->sourceFileIndex); }
- QString finalUrlString() const { return data->stringAt(data->finalUrlIndex); }
+ QString fileName() const { return m_fileName; }
+ QString finalUrlString() const { return m_finalUrlString; }
QUrl url() const { if (m_url.isNull) m_url = QUrl(fileName()); return m_url; }
QUrl finalUrl() const
{
@@ -943,14 +1104,14 @@ public:
}
QV4::Lookup *runtimeLookups = nullptr;
- QV4::InternalClass **runtimeClasses = nullptr;
QVector<QV4::Function *> runtimeFunctions;
+ QVector<QV4::Heap::InternalClass *> runtimeBlocks;
mutable QQmlNullableValue<QUrl> m_url;
mutable QQmlNullableValue<QUrl> m_finalUrl;
// QML specific fields
QQmlPropertyCacheVector propertyCaches;
- QQmlPropertyCache *rootPropertyCache() const { return propertyCaches.at(/*root object*/0); }
+ QQmlRefPointer<QQmlPropertyCache> rootPropertyCache() const { return propertyCaches.at(/*root object*/0); }
QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
@@ -962,7 +1123,7 @@ public:
// mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects
// this is initialized on-demand by QQmlContextData
QHash<int, IdentifierHash> namedObjectsPerComponentCache;
- IdentifierHash namedObjectsPerComponent(int componentObjectIndex);
+ inline IdentifierHash namedObjectsPerComponent(int componentObjectIndex);
void finalizeCompositeType(QQmlEnginePrivate *qmlEngine);
@@ -970,7 +1131,7 @@ public:
int totalParserStatusCount = 0; // Number of instantiated types that are QQmlParserStatus subclasses
int totalObjectCount = 0; // Number of objects explicitly instantiated
- QVector<QQmlScriptData *> dependentScripts;
+ QVector<QQmlRefPointer<QQmlScriptData>> dependentScripts;
ResolvedTypeReferenceMap resolvedTypes;
bool verifyChecksum(const DependentTypesHasher &dependencyHasher) const;
@@ -980,12 +1141,20 @@ public:
bool isRegisteredWithEngine = false;
QScopedPointer<CompilationUnitMapper> backingFile;
+ QStringList dynamicStrings;
// --- interface for QQmlPropertyCacheCreator
typedef Object CompiledObject;
- int objectCount() const { return data->nObjects; }
- const Object *objectAt(int index) const { return data->objectAt(index); }
- QString stringAt(int index) const { return data->stringAt(index); }
+ int objectCount() const { return qmlData->nObjects; }
+ const Object *objectAt(int index) const { return qmlData->objectAt(index); }
+ int importCount() const { return qmlData->nImports; }
+ const Import *importAt(int index) const { return qmlData->importAt(index); }
+ QString stringAt(int index) const
+ {
+ if (uint(index) >= data->stringTableSize)
+ return dynamicStrings.at(index - data->stringTableSize);
+ return data->stringAtInternal(index);
+ }
struct FunctionIterator
{
@@ -1003,6 +1172,12 @@ public:
FunctionIterator objectFunctionsEnd(const Object *object) const { return FunctionIterator(data, object, object->nFunctions); }
// ---
+ QStringList moduleRequests() const;
+ Heap::Module *instantiate(ExecutionEngine *engine);
+ const Value *resolveExport(QV4::String *exportName);
+ QStringList exportedNames() const;
+ void evaluate();
+
QV4::Function *linkToEngine(QV4::ExecutionEngine *engine);
void unlink();
@@ -1010,15 +1185,42 @@ public:
bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString);
+ static QString localCacheFilePath(const QUrl &url);
+
protected:
- void linkBackendToEngine(QV4::ExecutionEngine *engine);
+ quint32 totalStringCount() const
+ { return data->stringTableSize; }
+
+#else // V4_BOOTSTRAP
+ QString stringAt(int index) const { return data->stringAtInternal(index); }
#endif // V4_BOOTSTRAP
private:
void destroy();
+ struct ResolveSetEntry
+ {
+ ResolveSetEntry() {}
+ ResolveSetEntry(CompilationUnit *module, QV4::String *exportName)
+ : module(module), exportName(exportName) {}
+ CompilationUnit *module = nullptr;
+ QV4::String *exportName = nullptr;
+ };
+
+ const Value *resolveExportRecursively(QV4::String *exportName, QVector<ResolveSetEntry> *resolveSet);
+ const ExportEntry *lookupNameInExportTable(const ExportEntry *firstExportEntry, int tableSize, QV4::String *name) const;
+ void getExportedNamesRecursively(QStringList *names, QVector<const CompilationUnit *> *exportNameSet, bool includeDefaultExport = true) const;
+
+ QString m_fileName; // initialized from data->sourceFileIndex
+ QString m_finalUrlString; // initialized from data->finalUrlIndex
+
QAtomicInt refCount = 1;
+ Q_NEVER_INLINE IdentifierHash createNamedObjectsPerComponent(int componentObjectIndex);
+
+ Heap::Module *m_module = nullptr;
+ bool m_moduleEvaluated = false;
+
public:
#if defined(V4_BOOTSTRAP)
bool saveToDisk(const QString &outputFileName, QString *errorString);
@@ -1046,17 +1248,24 @@ struct ResolvedTypeReference
// therefore cannot have a property cache installed when instantiated.
bool isFullyDynamicType;
- QQmlPropertyCache *propertyCache() const;
- QQmlPropertyCache *createPropertyCache(QQmlEngine *);
+ QQmlRefPointer<QQmlPropertyCache> propertyCache() const;
+ QQmlRefPointer<QQmlPropertyCache> createPropertyCache(QQmlEngine *);
bool addToHash(QCryptographicHash *hash, QQmlEngine *engine);
void doDynamicTypeCheck();
};
-#endif
+IdentifierHash CompilationUnit::namedObjectsPerComponent(int componentObjectIndex)
+{
+ auto it = namedObjectsPerComponentCache.find(componentObjectIndex);
+ if (Q_UNLIKELY(it == namedObjectsPerComponentCache.end()))
+ return createNamedObjectsPerComponent(componentObjectIndex);
+ return *it;
}
+#endif // V4_BOOTSTRAP
-}
+} // CompiledData namespace
+} // QV4 namespace
Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE);
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index c9e535c93f..f2e3aaedb5 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -48,9 +48,6 @@
#include <wtf/MathExtras.h>
#include <QCryptographicHash>
-// generated by qmake:
-#include "qml_compile_hash_p.h"
-
QV4::Compiler::StringTableGenerator::StringTableGenerator()
{
clear();
@@ -58,6 +55,7 @@ QV4::Compiler::StringTableGenerator::StringTableGenerator()
int QV4::Compiler::StringTableGenerator::registerString(const QString &str)
{
+ Q_ASSERT(!frozen);
QHash<QString, int>::ConstIterator it = stringToId.constFind(str);
if (it != stringToId.cend())
return *it;
@@ -78,26 +76,44 @@ void QV4::Compiler::StringTableGenerator::clear()
strings.clear();
stringToId.clear();
stringDataSize = 0;
+ frozen = false;
+}
+
+void QV4::Compiler::StringTableGenerator::initializeFromBackingUnit(const QV4::CompiledData::Unit *unit)
+{
+ clear();
+ for (uint i = 0; i < unit->stringTableSize; ++i)
+ registerString(unit->stringAtInternal(i));
+ backingUnitTableSize = unit->stringTableSize;
+ stringDataSize = 0;
}
void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit)
{
char *dataStart = reinterpret_cast<char *>(unit);
quint32_le *stringTable = reinterpret_cast<quint32_le *>(dataStart + unit->offsetToStringTable);
- char *stringData = dataStart + unit->offsetToStringTable + unit->stringTableSize * sizeof(uint);
- for (int i = 0; i < strings.size(); ++i) {
- stringTable[i] = stringData - dataStart;
+ char *stringData = reinterpret_cast<char *>(stringTable) + WTF::roundUpToMultipleOf(8, unit->stringTableSize * sizeof(uint));
+ for (int i = backingUnitTableSize ; i < strings.size(); ++i) {
+ const int index = i - backingUnitTableSize;
+ stringTable[index] = stringData - dataStart;
const QString &qstr = strings.at(i);
QV4::CompiledData::String *s = reinterpret_cast<QV4::CompiledData::String *>(stringData);
+ Q_ASSERT(reinterpret_cast<uintptr_t>(s) % alignof(QV4::CompiledData::String) == 0);
+ s->refcount = -1;
s->size = qstr.length();
+ s->allocAndCapacityReservedFlag = 0;
+ s->offsetOn32Bit = sizeof(QV4::CompiledData::String);
+ s->offsetOn64Bit = sizeof(QV4::CompiledData::String);
+
+ ushort *uc = reinterpret_cast<ushort *>(reinterpret_cast<char *>(s) + sizeof(*s));
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- memcpy(s + 1, qstr.constData(), qstr.length()*sizeof(ushort));
+ memcpy(uc, qstr.constData(), s->size * sizeof(ushort));
#else
- ushort *uc = reinterpret_cast<ushort *>(s + 1);
- for (int i = 0; i < qstr.length(); ++i)
+ for (int i = 0; i < s->size; ++i)
uc[i] = qToLittleEndian<ushort>(qstr.at(i).unicode());
#endif
+ uc[s->size] = 0;
stringData += QV4::CompiledData::String::calculateSize(qstr);
}
@@ -164,6 +180,10 @@ int QV4::Compiler::JSUnitGenerator::registerRegExp(QQmlJS::AST::RegExpLiteral *r
re.flags |= CompiledData::RegExp::RegExp_IgnoreCase;
if (regexp->flags & QQmlJS::Lexer::RegExp_Multiline)
re.flags |= CompiledData::RegExp::RegExp_Multiline;
+ if (regexp->flags & QQmlJS::Lexer::RegExp_Unicode)
+ re.flags |= CompiledData::RegExp::RegExp_Unicode;
+ if (regexp->flags & QQmlJS::Lexer::RegExp_Sticky)
+ re.flags |= CompiledData::RegExp::RegExp_Sticky;
regexps.append(re);
return regexps.size() - 1;
@@ -183,7 +203,7 @@ QV4::ReturnedValue QV4::Compiler::JSUnitGenerator::constant(int idx)
return constants.at(idx);
}
-int QV4::Compiler::JSUnitGenerator::registerJSClass(const QVector<MemberInfo> &members)
+int QV4::Compiler::JSUnitGenerator::registerJSClass(const QStringList &members)
{
// ### re-use existing class definitions.
@@ -197,29 +217,19 @@ int QV4::Compiler::JSUnitGenerator::registerJSClass(const QVector<MemberInfo> &m
jsClass->nMembers = members.size();
CompiledData::JSClassMember *member = reinterpret_cast<CompiledData::JSClassMember*>(jsClass + 1);
- for (const MemberInfo &memberInfo : members) {
- member->nameOffset = registerString(memberInfo.name);
- member->isAccessor = memberInfo.isAccessor;
+ for (const auto &name : members) {
+ member->nameOffset = registerString(name);
+ member->isAccessor = false;
++member;
}
return jsClassOffsets.size() - 1;
}
-int QV4::Compiler::JSUnitGenerator::registerJSClass(int count, CompiledData::JSClassMember *members)
+int QV4::Compiler::JSUnitGenerator::registerTranslation(const QV4::CompiledData::TranslationData &translation)
{
- const int size = CompiledData::JSClass::calculateSize(count);
- jsClassOffsets.append(jsClassData.size());
- const int oldSize = jsClassData.size();
- jsClassData.resize(jsClassData.size() + size);
- memset(jsClassData.data() + oldSize, 0, size);
-
- CompiledData::JSClass *jsClass = reinterpret_cast<CompiledData::JSClass*>(jsClassData.data() + oldSize);
- jsClass->nMembers = count;
- CompiledData::JSClassMember *jsClassMembers = reinterpret_cast<CompiledData::JSClassMember*>(jsClass + 1);
- memcpy(jsClassMembers, members, sizeof(CompiledData::JSClassMember)*count);
-
- return jsClassOffsets.size() - 1;
+ translations.append(translation);
+ return translations.size() - 1;
}
QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorOption option)
@@ -233,28 +243,67 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
for (int i = 0; i < f->locals.size(); ++i)
registerString(f->locals.at(i));
}
+ for (Context *c : qAsConst(module->blocks)) {
+ for (int i = 0; i < c->locals.size(); ++i)
+ registerString(c->locals.at(i));
+ }
+ {
+ const auto registerExportEntry = [this](const Compiler::ExportEntry &entry) {
+ registerString(entry.exportName);
+ registerString(entry.moduleRequest);
+ registerString(entry.importName);
+ registerString(entry.localName);
+ };
+ std::for_each(module->localExportEntries.constBegin(), module->localExportEntries.constEnd(), registerExportEntry);
+ std::for_each(module->indirectExportEntries.constBegin(), module->indirectExportEntries.constEnd(), registerExportEntry);
+ std::for_each(module->starExportEntries.constBegin(), module->starExportEntries.constEnd(), registerExportEntry);
+ }
+ {
+ for (const auto &entry: module->importEntries) {
+ registerString(entry.moduleRequest);
+ registerString(entry.importName);
+ registerString(entry.localName);
+ }
+
+ for (const QString &request: module->moduleRequests)
+ registerString(request);
+ }
- Q_ALLOCA_VAR(quint32_le, functionOffsets, module->functions.size() * sizeof(quint32_le));
+ Q_ALLOCA_VAR(quint32_le, blockClassAndFunctionOffsets, (module->functions.size() + module->classes.size() + module->blocks.size()) * sizeof(quint32_le));
uint jsClassDataOffset = 0;
char *dataPtr;
CompiledData::Unit *unit;
{
- QV4::CompiledData::Unit tempHeader = generateHeader(option, functionOffsets, &jsClassDataOffset);
+ QV4::CompiledData::Unit tempHeader = generateHeader(option, blockClassAndFunctionOffsets, &jsClassDataOffset);
dataPtr = reinterpret_cast<char *>(malloc(tempHeader.unitSize));
memset(dataPtr, 0, tempHeader.unitSize);
memcpy(&unit, &dataPtr, sizeof(CompiledData::Unit*));
memcpy(unit, &tempHeader, sizeof(tempHeader));
}
- memcpy(dataPtr + unit->offsetToFunctionTable, functionOffsets, unit->functionTableSize * sizeof(quint32_le));
+ memcpy(dataPtr + unit->offsetToFunctionTable, blockClassAndFunctionOffsets, unit->functionTableSize * sizeof(quint32_le));
+ memcpy(dataPtr + unit->offsetToClassTable, blockClassAndFunctionOffsets + unit->functionTableSize, unit->classTableSize * sizeof(quint32_le));
+ memcpy(dataPtr + unit->offsetToBlockTable, blockClassAndFunctionOffsets + unit->functionTableSize + unit->classTableSize, unit->blockTableSize * sizeof(quint32_le));
for (int i = 0; i < module->functions.size(); ++i) {
Context *function = module->functions.at(i);
if (function == module->rootContext)
unit->indexOfRootFunction = i;
- writeFunction(dataPtr + functionOffsets[i], function);
+ writeFunction(dataPtr + blockClassAndFunctionOffsets[i], function);
+ }
+
+ for (int i = 0; i < module->classes.size(); ++i) {
+ const Class &c = module->classes.at(i);
+
+ writeClass(dataPtr + blockClassAndFunctionOffsets[i + module->functions.size()], c);
+ }
+
+ for (int i = 0; i < module->blocks.size(); ++i) {
+ Context *block = module->blocks.at(i);
+
+ writeBlock(dataPtr + blockClassAndFunctionOffsets[i + module->classes.size() + module->functions.size()], block);
}
CompiledData::Lookup *lookupsToWrite = reinterpret_cast<CompiledData::Lookup*>(dataPtr + unit->offsetToLookupTable);
@@ -282,6 +331,43 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
jsClassOffsetTable[i] = jsClassDataOffset + jsClassOffsets.at(i);
}
+
+ memcpy(dataPtr + unit->offsetToTranslationTable, translations.constData(), translations.count() * sizeof(CompiledData::TranslationData));
+
+ {
+ const auto populateExportEntryTable = [this, dataPtr](const QVector<Compiler::ExportEntry> &table, quint32_le offset) {
+ CompiledData::ExportEntry *entryToWrite = reinterpret_cast<CompiledData::ExportEntry *>(dataPtr + offset);
+ for (const Compiler::ExportEntry &entry: table) {
+ entryToWrite->exportName = getStringId(entry.exportName);
+ entryToWrite->moduleRequest = getStringId(entry.moduleRequest);
+ entryToWrite->importName = getStringId(entry.importName);
+ entryToWrite->localName = getStringId(entry.localName);
+ entryToWrite++;
+ }
+ };
+ populateExportEntryTable(module->localExportEntries, unit->offsetToLocalExportEntryTable);
+ populateExportEntryTable(module->indirectExportEntries, unit->offsetToIndirectExportEntryTable);
+ populateExportEntryTable(module->starExportEntries, unit->offsetToStarExportEntryTable);
+ }
+
+ {
+ CompiledData::ImportEntry *entryToWrite = reinterpret_cast<CompiledData::ImportEntry *>(dataPtr + unit->offsetToImportEntryTable);
+ for (const Compiler::ImportEntry &entry: module->importEntries) {
+ entryToWrite->moduleRequest = getStringId(entry.moduleRequest);
+ entryToWrite->importName = getStringId(entry.importName);
+ entryToWrite->localName = getStringId(entry.localName);
+ entryToWrite++;
+ }
+ }
+
+ {
+ quint32_le *moduleRequestEntryToWrite = reinterpret_cast<quint32_le *>(dataPtr + unit->offsetToModuleRequestTable);
+ for (const QString &moduleRequest: module->moduleRequests) {
+ *moduleRequestEntryToWrite = getStringId(moduleRequest);
+ moduleRequestEntryToWrite++;
+ }
+ }
+
// write strings and string table
if (option == GenerateWithStringTable)
stringTable.serialize(unit);
@@ -295,36 +381,38 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
{
QV4::CompiledData::Function *function = (QV4::CompiledData::Function *)f;
- quint32 currentOffset = sizeof(QV4::CompiledData::Function);
- currentOffset = (currentOffset + 7) & ~quint32(0x7);
+ quint32 currentOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, sizeof(*function)));
function->nameIndex = getStringId(irFunction->name);
function->flags = 0;
- if (irFunction->hasDirectEval)
- function->flags |= CompiledData::Function::HasDirectEval;
- if (irFunction->usesArgumentsObject)
- function->flags |= CompiledData::Function::UsesArgumentsObject;
if (irFunction->isStrict)
function->flags |= CompiledData::Function::IsStrict;
- if (irFunction->hasTry || irFunction->hasWith)
- function->flags |= CompiledData::Function::HasCatchOrWith;
+ if (irFunction->isArrowFunction)
+ function->flags |= CompiledData::Function::IsArrowFunction;
+ if (irFunction->isGenerator)
+ function->flags |= CompiledData::Function::IsGenerator;
function->nestedFunctionIndex =
irFunction->returnsClosure ? quint32(module->functions.indexOf(irFunction->nestedContexts.first()))
: std::numeric_limits<uint32_t>::max();
+ function->length = irFunction->formals ? irFunction->formals->length() : 0;
function->nFormals = irFunction->arguments.size();
function->formalsOffset = currentOffset;
currentOffset += function->nFormals * sizeof(quint32);
+ function->sizeOfLocalTemporalDeadZone = irFunction->sizeOfLocalTemporalDeadZone;
+ function->sizeOfRegisterTemporalDeadZone = irFunction->sizeOfRegisterTemporalDeadZone;
+ function->firstTemporalDeadZoneRegister = irFunction->firstTemporalDeadZoneRegister;
+
function->nLocals = irFunction->locals.size();
function->localsOffset = currentOffset;
currentOffset += function->nLocals * sizeof(quint32);
function->nLineNumbers = irFunction->lineNumberMapping.size();
- function->lineNumberOffset = currentOffset;
+ Q_ASSERT(function->lineNumberOffset() == currentOffset);
currentOffset += function->nLineNumbers * sizeof(CompiledData::CodeOffsetToLine);
- function->nRegisters = irFunction->registerCount;
+ function->nRegisters = irFunction->registerCountInFunction;
function->nDependingIdObjects = 0;
function->nDependingContextProperties = 0;
@@ -332,19 +420,19 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
if (!irFunction->idObjectDependencies.isEmpty()) {
function->nDependingIdObjects = irFunction->idObjectDependencies.count();
- function->dependingIdObjectsOffset = currentOffset;
+ Q_ASSERT(function->dependingIdObjectsOffset() == currentOffset);
currentOffset += function->nDependingIdObjects * sizeof(quint32);
}
if (!irFunction->contextObjectPropertyDependencies.isEmpty()) {
function->nDependingContextProperties = irFunction->contextObjectPropertyDependencies.count();
- function->dependingContextPropertiesOffset = currentOffset;
+ Q_ASSERT(function->dependingContextPropertiesOffset() == currentOffset);
currentOffset += function->nDependingContextProperties * sizeof(quint32) * 2;
}
if (!irFunction->scopeObjectPropertyDependencies.isEmpty()) {
function->nDependingScopeProperties = irFunction->scopeObjectPropertyDependencies.count();
- function->dependingScopePropertiesOffset = currentOffset;
+ Q_ASSERT(function->dependingScopePropertiesOffset() == currentOffset);
currentOffset += function->nDependingScopeProperties * sizeof(quint32) * 2;
}
@@ -365,22 +453,22 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
locals[i] = getStringId(irFunction->locals.at(i));
// write line numbers
- memcpy(f + function->lineNumberOffset, irFunction->lineNumberMapping.constData(), irFunction->lineNumberMapping.size()*sizeof(CompiledData::CodeOffsetToLine));
+ memcpy(f + function->lineNumberOffset(), irFunction->lineNumberMapping.constData(), irFunction->lineNumberMapping.size()*sizeof(CompiledData::CodeOffsetToLine));
// write QML dependencies
- quint32_le *writtenDeps = (quint32_le *)(f + function->dependingIdObjectsOffset);
+ quint32_le *writtenDeps = (quint32_le *)(f + function->dependingIdObjectsOffset());
for (int id : irFunction->idObjectDependencies) {
Q_ASSERT(id >= 0);
*writtenDeps++ = static_cast<quint32>(id);
}
- writtenDeps = (quint32_le *)(f + function->dependingContextPropertiesOffset);
+ writtenDeps = (quint32_le *)(f + function->dependingContextPropertiesOffset());
for (auto property : irFunction->contextObjectPropertyDependencies) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
}
- writtenDeps = (quint32_le *)(f + function->dependingScopePropertiesOffset);
+ writtenDeps = (quint32_le *)(f + function->dependingScopePropertiesOffset());
for (auto property : irFunction->scopeObjectPropertyDependencies) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
@@ -390,7 +478,84 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
memcpy(f + function->codeOffset, irFunction->code.constData(), irFunction->code.size());
}
-QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Compiler::JSUnitGenerator::GeneratorOption option, quint32_le *functionOffsets, uint *jsClassDataOffset)
+static_assert(int(QV4::Compiler::Class::Method::Regular) == int(QV4::CompiledData::Method::Regular), "Incompatible layout");
+static_assert(int(QV4::Compiler::Class::Method::Getter) == int(QV4::CompiledData::Method::Getter), "Incompatible layout");
+static_assert(int(QV4::Compiler::Class::Method::Setter) == int(QV4::CompiledData::Method::Setter), "Incompatible layout");
+
+void QV4::Compiler::JSUnitGenerator::writeClass(char *b, const QV4::Compiler::Class &c)
+{
+ QV4::CompiledData::Class *cls = reinterpret_cast<QV4::CompiledData::Class *>(b);
+
+ quint32 currentOffset = sizeof(QV4::CompiledData::Class);
+
+ QVector<Class::Method> allMethods = c.staticMethods;
+ allMethods += c.methods;
+
+ cls->constructorFunction = c.constructorIndex;
+ cls->nameIndex = c.nameIndex;
+ cls->nMethods = c.methods.size();
+ cls->nStaticMethods = c.staticMethods.size();
+ cls->methodTableOffset = currentOffset;
+ CompiledData::Method *method = reinterpret_cast<CompiledData::Method *>(b + currentOffset);
+
+ // write methods
+ for (int i = 0; i < allMethods.size(); ++i) {
+ method->name = allMethods.at(i).nameIndex;
+ method->type = allMethods.at(i).type;
+ method->function = allMethods.at(i).functionIndex;
+ ++method;
+ }
+
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
+ if (showCode) {
+ qDebug() << "=== Class " << stringForIndex(cls->nameIndex) << "static methods" << cls->nStaticMethods << "methods" << cls->nMethods;
+ qDebug() << " constructor:" << cls->constructorFunction;
+ const char *staticString = ": static ";
+ for (uint i = 0; i < cls->nStaticMethods + cls->nMethods; ++i) {
+ if (i == cls->nStaticMethods)
+ staticString = ": ";
+ const char *type;
+ switch (cls->methodTable()[i].type) {
+ case CompiledData::Method::Getter:
+ type = "get "; break;
+ case CompiledData::Method::Setter:
+ type = "set "; break;
+ default:
+ type = "";
+
+ }
+ qDebug() << " " << i << staticString << type << stringForIndex(cls->methodTable()[i].name) << cls->methodTable()[i].function;
+ }
+ qDebug();
+ }
+}
+
+void QV4::Compiler::JSUnitGenerator::writeBlock(char *b, QV4::Compiler::Context *irBlock) const
+{
+ QV4::CompiledData::Block *block = reinterpret_cast<QV4::CompiledData::Block *>(b);
+
+ quint32 currentOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, sizeof(*block)));
+
+ block->sizeOfLocalTemporalDeadZone = irBlock->sizeOfLocalTemporalDeadZone;
+ block->nLocals = irBlock->locals.size();
+ block->localsOffset = currentOffset;
+ currentOffset += block->nLocals * sizeof(quint32);
+
+ // write locals
+ quint32_le *locals = (quint32_le *)(b + block->localsOffset);
+ for (int i = 0; i < irBlock->locals.size(); ++i)
+ locals[i] = getStringId(irBlock->locals.at(i));
+
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
+ if (showCode) {
+ qDebug() << "=== Variables for block" << irBlock->blockIndex;
+ for (int i = 0; i < irBlock->locals.size(); ++i)
+ qDebug() << " " << i << ":" << locals[i];
+ qDebug();
+ }
+}
+
+QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Compiler::JSUnitGenerator::GeneratorOption option, quint32_le *blockAndFunctionOffsets, uint *jsClassDataOffset)
{
CompiledData::Unit unit;
memset(&unit, 0, sizeof(unit));
@@ -399,7 +564,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.flags |= module->unitFlags;
unit.version = QV4_DATA_STRUCTURE_VERSION;
unit.qtVersion = QT_VERSION;
- qstrcpy(unit.libraryVersionHash, QML_COMPILE_HASH);
+ qstrcpy(unit.libraryVersionHash, CompiledData::qml_compile_hash);
memset(unit.md5Checksum, 0, sizeof(unit.md5Checksum));
memset(unit.dependencyMD5Checksum, 0, sizeof(unit.dependencyMD5Checksum));
@@ -409,6 +574,14 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.offsetToFunctionTable = nextOffset;
nextOffset += unit.functionTableSize * sizeof(uint);
+ unit.classTableSize = module->classes.size();
+ unit.offsetToClassTable = nextOffset;
+ nextOffset += unit.classTableSize * sizeof(uint);
+
+ unit.blockTableSize = module->blocks.size();
+ unit.offsetToBlockTable = nextOffset;
+ nextOffset += unit.blockTableSize * sizeof(uint);
+
unit.lookupTableSize = lookups.count();
unit.offsetToLookupTable = nextOffset;
nextOffset += unit.lookupTableSize * sizeof(CompiledData::Lookup);
@@ -431,20 +604,68 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
*jsClassDataOffset = nextOffset;
nextOffset += jsClassData.size();
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
+
+ unit.translationTableSize = translations.count();
+ unit.offsetToTranslationTable = nextOffset;
+ nextOffset += unit.translationTableSize * sizeof(CompiledData::TranslationData);
+
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
+
+ const auto reserveExportTable = [&nextOffset](int count, quint32_le *tableSizePtr, quint32_le *offsetPtr) {
+ *tableSizePtr = count;
+ *offsetPtr = nextOffset;
+ nextOffset += count * sizeof(CompiledData::ExportEntry);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
+ };
+ reserveExportTable(module->localExportEntries.count(), &unit.localExportEntryTableSize, &unit.offsetToLocalExportEntryTable);
+ reserveExportTable(module->indirectExportEntries.count(), &unit.indirectExportEntryTableSize, &unit.offsetToIndirectExportEntryTable);
+ reserveExportTable(module->starExportEntries.count(), &unit.starExportEntryTableSize, &unit.offsetToStarExportEntryTable);
+
+ unit.importEntryTableSize = module->importEntries.count();
+ unit.offsetToImportEntryTable = nextOffset;
+ nextOffset += unit.importEntryTableSize * sizeof(CompiledData::ImportEntry);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
+
+ unit.moduleRequestTableSize = module->moduleRequests.count();
+ unit.offsetToModuleRequestTable = nextOffset;
+ nextOffset += unit.moduleRequestTableSize * sizeof(uint);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
+
+ quint32 functionSize = 0;
for (int i = 0; i < module->functions.size(); ++i) {
Context *f = module->functions.at(i);
- functionOffsets[i] = nextOffset;
+ blockAndFunctionOffsets[i] = nextOffset;
const int qmlIdDepsCount = f->idObjectDependencies.count();
const int qmlPropertyDepsCount = f->scopeObjectPropertyDependencies.count() + f->contextObjectPropertyDependencies.count();
- nextOffset += QV4::CompiledData::Function::calculateSize(f->arguments.size(), f->locals.size(), f->lineNumberMapping.size(), f->nestedContexts.size(),
+ quint32 size = QV4::CompiledData::Function::calculateSize(f->arguments.size(), f->locals.size(), f->lineNumberMapping.size(), f->nestedContexts.size(),
qmlIdDepsCount, qmlPropertyDepsCount, f->code.size());
+ functionSize += size - f->code.size();
+ nextOffset += size;
+ }
+
+ blockAndFunctionOffsets += module->functions.size();
+
+ for (int i = 0; i < module->classes.size(); ++i) {
+ const Class &c = module->classes.at(i);
+ blockAndFunctionOffsets[i] = nextOffset;
+
+ nextOffset += QV4::CompiledData::Class::calculateSize(c.staticMethods.size(), c.methods.size());
+ }
+ blockAndFunctionOffsets += module->classes.size();
+
+ for (int i = 0; i < module->blocks.size(); ++i) {
+ Context *c = module->blocks.at(i);
+ blockAndFunctionOffsets[i] = nextOffset;
+
+ nextOffset += QV4::CompiledData::Block::calculateSize(c->locals.size());
}
if (option == GenerateWithStringTable) {
unit.stringTableSize = stringTable.stringCount();
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
unit.offsetToStringTable = nextOffset;
nextOffset += stringTable.sizeOfTableAndData();
} else {
@@ -455,12 +676,16 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.sourceFileIndex = getStringId(module->fileName);
unit.finalUrlIndex = getStringId(module->finalUrl);
unit.sourceTimeStamp = module->sourceTimeStamp.isValid() ? module->sourceTimeStamp.toMSecsSinceEpoch() : 0;
- unit.nImports = 0;
- unit.offsetToImports = 0;
- unit.nObjects = 0;
- unit.offsetToObjects = 0;
+ unit.offsetToQmlUnit = 0;
unit.unitSize = nextOffset;
+ static const bool showStats = qEnvironmentVariableIsSet("QML_SHOW_UNIT_STATS");
+ if (showStats) {
+ qDebug() << "Generated JS unit that is" << unit.unitSize << "bytes contains:";
+ qDebug() << " " << functionSize << "bytes for non-code function data for" << unit.functionTableSize << "functions";
+ qDebug() << " " << translations.count() * sizeof(CompiledData::TranslationData) << "bytes for" << translations.count() << "translations";
+ }
+
return unit;
}
diff --git a/src/qml/compiler/qv4compiler_p.h b/src/qml/compiler/qv4compiler_p.h
index 360af6540f..c4c886ffad 100644
--- a/src/qml/compiler/qv4compiler_p.h
+++ b/src/qml/compiler/qv4compiler_p.h
@@ -72,24 +72,33 @@ struct JSClassMember;
namespace Compiler {
+struct Class;
+
struct Q_QML_PRIVATE_EXPORT StringTableGenerator {
StringTableGenerator();
int registerString(const QString &str);
int getStringId(const QString &string) const;
QString stringForIndex(int index) const { return strings.at(index); }
- uint stringCount() const { return strings.size(); }
+ uint stringCount() const { return strings.size() - backingUnitTableSize; }
+
+ uint sizeOfTableAndData() const { return stringDataSize + ((stringCount() * sizeof(uint) + 7) & ~7); }
- uint sizeOfTableAndData() const { return stringDataSize + strings.count() * sizeof(uint); }
+ void freeze() { frozen = true; }
void clear();
+ void initializeFromBackingUnit(const CompiledData::Unit *unit);
+
void serialize(CompiledData::Unit *unit);
+ QStringList allStrings() const { return strings.mid(backingUnitTableSize); }
private:
QHash<QString, int> stringToId;
QStringList strings;
uint stringDataSize;
+ uint backingUnitTableSize = 0;
+ bool frozen = false;
};
struct Q_QML_PRIVATE_EXPORT JSUnitGenerator {
@@ -116,8 +125,9 @@ struct Q_QML_PRIVATE_EXPORT JSUnitGenerator {
int registerConstant(ReturnedValue v);
ReturnedValue constant(int idx);
- int registerJSClass(const QVector<MemberInfo> &members);
- int registerJSClass(int count, CompiledData::JSClassMember *members);
+ int registerJSClass(const QStringList &members);
+
+ int registerTranslation(const CompiledData::TranslationData &translation);
enum GeneratorOption {
GenerateWithStringTable,
@@ -125,8 +135,9 @@ struct Q_QML_PRIVATE_EXPORT JSUnitGenerator {
};
QV4::CompiledData::Unit *generateUnit(GeneratorOption option = GenerateWithStringTable);
- // Returns bytes written
void writeFunction(char *f, Context *irFunction) const;
+ void writeClass(char *f, const Class &c);
+ void writeBlock(char *f, Context *irBlock) const;
StringTableGenerator stringTable;
QString codeGeneratorName;
@@ -140,6 +151,7 @@ private:
QVector<ReturnedValue> constants;
QByteArray jsClassData;
QVector<int> jsClassOffsets;
+ QVector<CompiledData::TranslationData> translations;
};
}
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index 0a9d3d8efe..b423dcf0b7 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -39,6 +39,7 @@
#include "qv4compilercontext_p.h"
#include "qv4compilercontrolflow_p.h"
+#include "qv4bytecodegenerator_p.h"
QT_USE_NAMESPACE
using namespace QV4;
@@ -47,11 +48,11 @@ using namespace QQmlJS::AST;
QT_BEGIN_NAMESPACE
-Context *Module::newContext(Node *node, Context *parent, CompilationMode compilationMode)
+Context *Module::newContext(Node *node, Context *parent, ContextType contextType)
{
Q_ASSERT(!contextMap.contains(node));
- Context *c = new Context(parent, compilationMode);
+ Context *c = new Context(parent, contextType);
if (node) {
SourceLocation loc = node->firstSourceLocation();
c->line = loc.startLine;
@@ -70,15 +71,339 @@ Context *Module::newContext(Node *node, Context *parent, CompilationMode compila
return c;
}
-bool Context::forceLookupByName()
+bool Context::Member::requiresTDZCheck(const SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const
{
- ControlFlow *flow = controlFlow;
- while (flow) {
- if (flow->needsLookupByName)
+ if (!isLexicallyScoped())
+ return false;
+
+ if (accessAcrossContextBoundaries)
+ return true;
+
+ if (!accessLocation.isValid() || !endOfInitializerLocation.isValid())
+ return true;
+
+ return accessLocation.begin() < endOfInitializerLocation.end();
+}
+
+bool Context::addLocalVar(const QString &name, Context::MemberType type, VariableScope scope, FunctionExpression *function,
+ const QQmlJS::AST::SourceLocation &endOfInitializer)
+{
+ // ### can this happen?
+ if (name.isEmpty())
+ return true;
+
+ if (type != FunctionDefinition) {
+ if (formals && formals->containsName(name))
+ return (scope == VariableScope::Var);
+ }
+ if (!isCatchBlock || name != caughtVariable) {
+ MemberMap::iterator it = members.find(name);
+ if (it != members.end()) {
+ if (scope != VariableScope::Var || (*it).scope != VariableScope::Var)
+ return false;
+ if ((*it).type <= type) {
+ (*it).type = type;
+ (*it).function = function;
+ }
return true;
- flow = flow->parent;
+ }
}
- return false;
+
+ // hoist var declarations to the function level
+ if (contextType == ContextType::Block && (scope == VariableScope::Var && type != MemberType::FunctionDefinition))
+ return parent->addLocalVar(name, type, scope, function, endOfInitializer);
+
+ Member m;
+ m.type = type;
+ m.function = function;
+ m.scope = scope;
+ m.endOfInitializerLocation = endOfInitializer;
+ members.insert(name, m);
+ return true;
+}
+
+Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation)
+{
+ int scope = 0;
+ Context *c = this;
+
+ ResolvedName result;
+
+ while (c) {
+ if (c->isWithBlock)
+ return result;
+
+ Context::Member m = c->findMember(name);
+ if (!c->parent && m.index < 0)
+ break;
+
+ if (m.type != Context::UndefinedMember) {
+ result.type = m.canEscape ? ResolvedName::Local : ResolvedName::Stack;
+ result.scope = scope;
+ result.index = m.index;
+ result.isConst = (m.scope == VariableScope::Const);
+ result.requiresTDZCheck = m.requiresTDZCheck(accessLocation, c != this);
+ if (c->isStrict && (name == QLatin1String("arguments") || name == QLatin1String("eval")))
+ result.isArgOrEval = true;
+ return result;
+ }
+ const int argIdx = c->findArgument(name);
+ if (argIdx != -1) {
+ if (c->argumentsCanEscape) {
+ result.index = argIdx + c->locals.size();
+ result.scope = scope;
+ result.type = ResolvedName::Local;
+ result.isConst = false;
+ return result;
+ } else {
+ result.index = argIdx + sizeof(CallData)/sizeof(Value) - 1;
+ result.scope = 0;
+ result.type = ResolvedName::Stack;
+ result.isConst = false;
+ return result;
+ }
+ }
+ if (c->hasDirectEval) {
+ Q_ASSERT(!c->isStrict && c->contextType != ContextType::Block);
+ return result;
+ }
+
+ if (c->requiresExecutionContext)
+ ++scope;
+ c = c->parent;
+ }
+
+ if (c && c->contextType == ContextType::ESModule) {
+ for (int i = 0; i < c->importEntries.count(); ++i) {
+ if (c->importEntries.at(i).localName == name) {
+ result.index = i;
+ result.type = ResolvedName::Import;
+ result.isConst = true;
+ // We don't know at compile time whether the imported value is let/const or not.
+ result.requiresTDZCheck = true;
+ return result;
+ }
+ }
+ }
+
+ // ### can we relax the restrictions here?
+ if (contextType == ContextType::Eval || c->contextType == ContextType::Binding)
+ return result;
+
+ result.type = ResolvedName::Global;
+ return result;
+}
+
+void Context::emitBlockHeader(Codegen *codegen)
+{
+ using Instruction = Moth::Instruction;
+ Moth::BytecodeGenerator *bytecodeGenerator = codegen->generator();
+
+ setupFunctionIndices(bytecodeGenerator);
+
+ if (requiresExecutionContext) {
+ if (blockIndex < 0) {
+ codegen->module()->blocks.append(this);
+ blockIndex = codegen->module()->blocks.count() - 1;
+ }
+
+ if (contextType == ContextType::Global) {
+ Instruction::PushScriptContext scriptContext;
+ scriptContext.index = blockIndex;
+ bytecodeGenerator->addInstruction(scriptContext);
+ } else if (contextType == ContextType::Block || (contextType == ContextType::Eval && !isStrict)) {
+ if (isCatchBlock) {
+ Instruction::PushCatchContext catchContext;
+ catchContext.index = blockIndex;
+ catchContext.name = codegen->registerString(caughtVariable);
+ bytecodeGenerator->addInstruction(catchContext);
+ } else {
+ Instruction::PushBlockContext blockContext;
+ blockContext.index = blockIndex;
+ bytecodeGenerator->addInstruction(blockContext);
+ }
+ } else if (contextType != ContextType::ESModule) {
+ Instruction::CreateCallContext createContext;
+ bytecodeGenerator->addInstruction(createContext);
+ }
+ }
+
+ if (contextType == ContextType::Block && sizeOfRegisterTemporalDeadZone > 0) {
+ Instruction::InitializeBlockDeadTemporalZone tdzInit;
+ tdzInit.firstReg = registerOffset + nRegisters - sizeOfRegisterTemporalDeadZone;
+ tdzInit.count = sizeOfRegisterTemporalDeadZone;
+ bytecodeGenerator->addInstruction(tdzInit);
+ }
+
+ if (usesThis) {
+ Q_ASSERT(!isStrict);
+ // make sure we convert this to an object
+ Instruction::ConvertThisToObject convert;
+ bytecodeGenerator->addInstruction(convert);
+ }
+ if (innerFunctionAccessesThis) {
+ Instruction::LoadReg load;
+ load.reg = CallData::This;
+ bytecodeGenerator->addInstruction(load);
+ Codegen::Reference r = codegen->referenceForName(QStringLiteral("this"), true);
+ r.storeConsumeAccumulator();
+ }
+ if (innerFunctionAccessesNewTarget) {
+ Instruction::LoadReg load;
+ load.reg = CallData::NewTarget;
+ bytecodeGenerator->addInstruction(load);
+ Codegen::Reference r = codegen->referenceForName(QStringLiteral("new.target"), true);
+ r.storeConsumeAccumulator();
+ }
+
+ if (contextType == ContextType::Global || (contextType == ContextType::Eval && !isStrict)) {
+ // variables in global code are properties of the global context object, not locals as with other functions.
+ for (Context::MemberMap::const_iterator it = members.constBegin(), cend = members.constEnd(); it != cend; ++it) {
+ if (it->isLexicallyScoped())
+ continue;
+ const QString &local = it.key();
+
+ Instruction::DeclareVar declareVar;
+ declareVar.isDeletable = (contextType == ContextType::Eval);
+ declareVar.varName = codegen->registerString(local);
+ bytecodeGenerator->addInstruction(declareVar);
+ }
+ }
+
+ if (contextType == ContextType::Function || contextType == ContextType::Binding || contextType == ContextType::ESModule) {
+ for (Context::MemberMap::iterator it = members.begin(), end = members.end(); it != end; ++it) {
+ if (it->canEscape && it->type == Context::ThisFunctionName) {
+ // move the function from the stack to the call context
+ Instruction::LoadReg load;
+ load.reg = CallData::Function;
+ bytecodeGenerator->addInstruction(load);
+ Instruction::StoreLocal store;
+ store.index = it->index;
+ bytecodeGenerator->addInstruction(store);
+ }
+ }
+ }
+
+ if (usesArgumentsObject == Context::ArgumentsObjectUsed) {
+ Q_ASSERT(contextType != ContextType::Block);
+ if (isStrict || (formals && !formals->isSimpleParameterList())) {
+ Instruction::CreateUnmappedArgumentsObject setup;
+ bytecodeGenerator->addInstruction(setup);
+ } else {
+ Instruction::CreateMappedArgumentsObject setup;
+ bytecodeGenerator->addInstruction(setup);
+ }
+ codegen->referenceForName(QStringLiteral("arguments"), false).storeConsumeAccumulator();
+ }
+
+ for (const Context::Member &member : qAsConst(members)) {
+ if (member.function) {
+ const int function = codegen->defineFunction(member.function->name.toString(), member.function, member.function->formals, member.function->body);
+ codegen->loadClosure(function);
+ Codegen::Reference r = codegen->referenceForName(member.function->name.toString(), true);
+ r.storeConsumeAccumulator();
+ }
+ }
+}
+
+void Context::emitBlockFooter(Codegen *codegen)
+{
+ using Instruction = Moth::Instruction;
+ Moth::BytecodeGenerator *bytecodeGenerator = codegen->generator();
+
+ if (!requiresExecutionContext)
+ return;
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty structs.
+ if (contextType == ContextType::Global)
+ bytecodeGenerator->addInstruction(Instruction::PopScriptContext());
+ else if (contextType != ContextType::ESModule)
+ bytecodeGenerator->addInstruction(Instruction::PopContext());
+QT_WARNING_POP
+}
+
+void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
+{
+ if (registerOffset != -1) {
+ // already computed, check for consistency
+ Q_ASSERT(registerOffset == bytecodeGenerator->currentRegister());
+ bytecodeGenerator->newRegisterArray(nRegisters);
+ return;
+ }
+ Q_ASSERT(locals.size() == 0);
+ Q_ASSERT(nRegisters == 0);
+ registerOffset = bytecodeGenerator->currentRegister();
+
+ QVector<Context::MemberMap::Iterator> localsInTDZ;
+ const auto registerLocal = [this, &localsInTDZ](Context::MemberMap::iterator member) {
+ if (member->isLexicallyScoped()) {
+ localsInTDZ << member;
+ } else {
+ member->index = locals.size();
+ locals.append(member.key());
+ }
+ };
+
+ QVector<Context::MemberMap::Iterator> registersInTDZ;
+ const auto allocateRegister = [bytecodeGenerator, &registersInTDZ](Context::MemberMap::iterator member) {
+ if (member->isLexicallyScoped())
+ registersInTDZ << member;
+ else
+ member->index = bytecodeGenerator->newRegister();
+ };
+
+ switch (contextType) {
+ case ContextType::ESModule:
+ case ContextType::Block:
+ case ContextType::Function:
+ case ContextType::Binding: {
+ for (Context::MemberMap::iterator it = members.begin(), end = members.end(); it != end; ++it) {
+ if (it->canEscape) {
+ registerLocal(it);
+ } else {
+ if (it->type == Context::ThisFunctionName)
+ it->index = CallData::Function;
+ else
+ allocateRegister(it);
+ }
+ }
+ break;
+ }
+ case ContextType::Global:
+ case ContextType::Eval:
+ for (Context::MemberMap::iterator it = members.begin(), end = members.end(); it != end; ++it) {
+ if (!it->isLexicallyScoped() && (contextType == ContextType::Global || !isStrict))
+ continue;
+ if (it->canEscape)
+ registerLocal(it);
+ else
+ allocateRegister(it);
+ }
+ break;
+ }
+
+ sizeOfLocalTemporalDeadZone = localsInTDZ.count();
+ for (auto &member: qAsConst(localsInTDZ)) {
+ member->index = locals.size();
+ locals.append(member.key());
+ }
+
+ if (contextType == ContextType::ESModule && !localNameForDefaultExport.isEmpty()) {
+ if (!members.contains(localNameForDefaultExport)) {
+ // allocate a local slot for the default export, to be used in
+ // CodeGen::visit(ExportDeclaration*).
+ locals.append(localNameForDefaultExport);
+ ++sizeOfLocalTemporalDeadZone;
+ }
+ }
+
+ sizeOfRegisterTemporalDeadZone = registersInTDZ.count();
+ firstTemporalDeadZoneRegister = bytecodeGenerator->currentRegister();
+ for (auto &member: qAsConst(registersInTDZ))
+ member->index = bytecodeGenerator->newRegister();
+
+ nRegisters = bytecodeGenerator->currentRegister() - registerOffset;
}
QT_END_NAMESPACE
diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h
index 455a76c729..63306b3672 100644
--- a/src/qml/compiler/qv4compilercontext_p.h
+++ b/src/qml/compiler/qv4compilercontext_p.h
@@ -66,18 +66,56 @@ namespace Compiler {
struct ControlFlow;
-enum CompilationMode {
- GlobalCode,
- EvalCode,
- FunctionCode,
- QmlBinding // This is almost the same as EvalCode, except:
+enum class ContextType {
+ Global,
+ Function,
+ Eval,
+ Binding, // This is almost the same as Eval, except:
// * function declarations are moved to the return address when encountered
// * return statements are allowed everywhere (like in FunctionCode)
// * variable declarations are treated as true locals (like in FunctionCode)
+ Block,
+ ESModule
};
struct Context;
+struct Class {
+ struct Method {
+ enum Type {
+ Regular,
+ Getter,
+ Setter
+ };
+ uint nameIndex;
+ Type type;
+ uint functionIndex;
+ };
+
+ uint nameIndex;
+ uint constructorIndex = UINT_MAX;
+ QVector<Method> staticMethods;
+ QVector<Method> methods;
+};
+
+struct ExportEntry
+{
+ QString exportName;
+ QString moduleRequest;
+ QString importName;
+ QString localName;
+
+ static bool lessThan(const ExportEntry &lhs, const ExportEntry &rhs)
+ { return lhs.exportName < rhs.exportName; }
+};
+
+struct ImportEntry
+{
+ QString moduleRequest;
+ QString importName;
+ QString localName;
+};
+
struct Module {
Module(bool debugMode)
: debugMode(debugMode)
@@ -86,16 +124,23 @@ struct Module {
qDeleteAll(contextMap);
}
- Context *newContext(QQmlJS::AST::Node *node, Context *parent, CompilationMode compilationMode);
+ Context *newContext(QQmlJS::AST::Node *node, Context *parent, ContextType compilationMode);
QHash<QQmlJS::AST::Node *, Context *> contextMap;
QList<Context *> functions;
+ QList<Context *> blocks;
+ QVector<Class> classes;
Context *rootContext;
QString fileName;
QString finalUrl;
QDateTime sourceTimeStamp;
uint unitFlags = 0; // flags merged into CompiledData::Unit::flags
bool debugMode = false;
+ QVector<ExportEntry> localExportEntries;
+ QVector<ExportEntry> indirectExportEntries;
+ QVector<ExportEntry> starExportEntries;
+ QVector<ImportEntry> importEntries;
+ QStringList moduleRequests;
};
@@ -104,8 +149,9 @@ struct Context {
QString name;
int line = 0;
int column = 0;
- int registerCount = 0;
+ int registerCountInFunction = 0;
int functionIndex = -1;
+ int blockIndex = -1;
enum MemberType {
UndefinedMember,
@@ -118,11 +164,13 @@ struct Context {
struct Member {
MemberType type = UndefinedMember;
int index = -1;
- QQmlJS::AST::VariableDeclaration::VariableScope scope = QQmlJS::AST::VariableDeclaration::FunctionScope;
+ QQmlJS::AST::VariableScope scope = QQmlJS::AST::VariableScope::Var;
mutable bool canEscape = false;
QQmlJS::AST::FunctionExpression *function = nullptr;
+ QQmlJS::AST::SourceLocation endOfInitializerLocation;
- bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableDeclaration::FunctionScope; }
+ bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableScope::Var; }
+ bool requiresTDZCheck(const QQmlJS::AST::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const;
};
typedef QMap<QString, Member> MemberMap;
@@ -131,21 +179,38 @@ struct Context {
QQmlJS::AST::FormalParameterList *formals = nullptr;
QStringList arguments;
QStringList locals;
+ QStringList moduleRequests;
+ QVector<ImportEntry> importEntries;
+ QVector<ExportEntry> exportEntries;
+ QString localNameForDefaultExport;
QVector<Context *> nestedContexts;
ControlFlow *controlFlow = nullptr;
QByteArray code;
QVector<CompiledData::CodeOffsetToLine> lineNumberMapping;
- int maxNumberOfArguments = 0;
+ int nRegisters = 0;
+ int registerOffset = -1;
+ int sizeOfLocalTemporalDeadZone = 0;
+ int firstTemporalDeadZoneRegister = 0;
+ int sizeOfRegisterTemporalDeadZone = 0;
bool hasDirectEval = false;
+ bool allVarsEscape = false;
bool hasNestedFunctions = false;
bool isStrict = false;
+ bool isArrowFunction = false;
+ bool isGenerator = false;
bool usesThis = false;
+ bool innerFunctionAccessesThis = false;
+ bool innerFunctionAccessesNewTarget = false;
bool hasTry = false;
- bool hasWith = false;
bool returnsClosure = false;
mutable bool argumentsCanEscape = false;
+ bool requiresExecutionContext = false;
+ bool isWithBlock = false;
+ bool isCatchBlock = false;
+ QString caughtVariable;
+ QQmlJS::AST::SourceLocation lastBlockInitializerLocation;
enum UsesArgumentsObject {
ArgumentsObjectUnknown,
@@ -155,7 +220,7 @@ struct Context {
UsesArgumentsObject usesArgumentsObject = ArgumentsObjectUnknown;
- CompilationMode compilationMode;
+ ContextType contextType;
template <typename T>
class SmallSet: public QVarLengthArray<T, 8>
@@ -204,25 +269,15 @@ struct Context {
PropertyDependencyMap contextObjectPropertyDependencies;
PropertyDependencyMap scopeObjectPropertyDependencies;
- Context(Context *parent, CompilationMode mode)
+ Context(Context *parent, ContextType type)
: parent(parent)
- , compilationMode(mode)
+ , contextType(type)
{
if (parent && parent->isStrict)
isStrict = true;
}
- bool forceLookupByName();
-
-
- bool canUseSimpleCall() const {
- return nestedContexts.isEmpty() &&
- locals.isEmpty() &&
- !hasTry && !hasWith &&
- (usesArgumentsObject == ArgumentsObjectNotUsed || isStrict) && !hasDirectEval;
- }
-
- int findArgument(const QString &name)
+ int findArgument(const QString &name) const
{
// search backwards to handle duplicate argument names correctly
for (int i = arguments.size() - 1; i >= 0; --i) {
@@ -253,37 +308,41 @@ struct Context {
return true;
}
+ bool requiresImplicitReturnValue() const {
+ return contextType == ContextType::Binding ||
+ contextType == ContextType::Eval ||
+ contextType == ContextType::Global;
+ }
+
void addUsedVariable(const QString &name) {
usedVariables.insert(name);
}
- bool addLocalVar(const QString &name, MemberType type, QQmlJS::AST::VariableDeclaration::VariableScope scope, QQmlJS::AST::FunctionExpression *function = nullptr)
- {
- if (name.isEmpty())
- return true;
+ bool addLocalVar(const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, QQmlJS::AST::FunctionExpression *function = nullptr,
+ const QQmlJS::AST::SourceLocation &endOfInitializer = QQmlJS::AST::SourceLocation());
+
+ struct ResolvedName {
+ enum Type {
+ Unresolved,
+ Global,
+ Local,
+ Stack,
+ Import
+ };
+ Type type = Unresolved;
+ bool isArgOrEval = false;
+ bool isConst = false;
+ bool requiresTDZCheck = false;
+ int scope = -1;
+ int index = -1;
+ QQmlJS::AST::SourceLocation endOfDeclarationLocation;
+ bool isValid() const { return type != Unresolved; }
+ };
+ ResolvedName resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation);
+ void emitBlockHeader(Compiler::Codegen *codegen);
+ void emitBlockFooter(Compiler::Codegen *codegen);
- if (type != FunctionDefinition) {
- for (QQmlJS::AST::FormalParameterList *it = formals; it; it = it->next)
- if (it->name == name)
- return (scope == QQmlJS::AST::VariableDeclaration::FunctionScope);
- }
- MemberMap::iterator it = members.find(name);
- if (it != members.end()) {
- if (scope != QQmlJS::AST::VariableDeclaration::FunctionScope || (*it).scope != QQmlJS::AST::VariableDeclaration::FunctionScope)
- return false;
- if ((*it).type <= type) {
- (*it).type = type;
- (*it).function = function;
- }
- return true;
- }
- Member m;
- m.type = type;
- m.function = function;
- m.scope = scope;
- members.insert(name, m);
- return true;
- }
+ void setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator);
};
diff --git a/src/qml/compiler/qv4compilercontrolflow_p.h b/src/qml/compiler/qv4compilercontrolflow_p.h
index 9bda20905a..5b622e81d8 100644
--- a/src/qml/compiler/qv4compilercontrolflow_p.h
+++ b/src/qml/compiler/qv4compilercontrolflow_p.h
@@ -53,6 +53,7 @@
#include <private/qv4global_p.h>
#include <private/qv4codegen_p.h>
#include <private/qqmljsast_p.h>
+#include <private/qv4bytecodegenerator_p.h>
QT_BEGIN_NAMESPACE
@@ -68,117 +69,84 @@ struct ControlFlow {
enum Type {
Loop,
With,
+ Block,
Finally,
Catch
};
- enum HandlerType {
- Invalid,
+ enum UnwindType {
Break,
Continue,
- Return,
- Throw
+ Return
};
- struct Handler {
- HandlerType type;
- QString label;
+ struct UnwindTarget {
BytecodeGenerator::Label linkLabel;
- int tempIndex;
- int value;
+ int unwindLevel;
};
Codegen *cg;
ControlFlow *parent;
Type type;
- bool needsLookupByName = false;
ControlFlow(Codegen *cg, Type type)
- : cg(cg), parent(cg->_context->controlFlow), type(type)
+ : cg(cg), parent(cg->controlFlow), type(type)
{
- cg->_context->controlFlow = this;
+ cg->controlFlow = this;
}
virtual ~ControlFlow() {
- cg->_context->controlFlow = parent;
+ cg->controlFlow = parent;
}
- void emitReturnStatement() const {
- if (cg->_returnAddress >= 0) {
- Instruction::LoadReg load;
- load.reg = Moth::StackSlot::createRegister(cg->_returnAddress);
- generator()->addInstruction(load);
+ UnwindTarget unwindTarget(UnwindType type, const QString &label = QString())
+ {
+ Q_ASSERT(type == Break || type == Continue || type == Return);
+ ControlFlow *flow = this;
+ int level = 0;
+ while (flow) {
+ BytecodeGenerator::Label l = flow->getUnwindTarget(type, label);
+ if (l.isValid())
+ return UnwindTarget{l, level};
+ if (flow->requiresUnwind())
+ ++level;
+ flow = flow->parent;
}
- Instruction::Ret ret;
- cg->bytecodeGenerator->addInstruction(ret);
+ if (type == Return)
+ return UnwindTarget{ cg->returnLabel(), level };
+ return UnwindTarget();
}
- void jumpToHandler(const Handler &h) {
- if (h.linkLabel.isReturn()) {
- emitReturnStatement();
- } else {
- if (h.tempIndex >= 0)
- Reference::storeConstOnStack(cg, QV4::Encode(h.value), h.tempIndex);
- cg->bytecodeGenerator->jump().link(h.linkLabel);
- }
- }
+ virtual QString label() const { return QString(); }
- bool returnRequiresUnwind() const {
- const ControlFlow *f = this;
- while (f) {
- if (f->type == Finally)
+ bool hasLoop() const {
+ const ControlFlow *flow = this;
+ while (flow) {
+ if (flow->type == Loop)
return true;
- f = f->parent;
+ flow = flow->parent;
}
return false;
}
- virtual QString label() const { return QString(); }
-
- bool isSimple() const {
- return type == Loop;
+protected:
+ virtual BytecodeGenerator::Label getUnwindTarget(UnwindType, const QString & = QString()) {
+ return BytecodeGenerator::Label();
}
-
- Handler getParentHandler(HandlerType type, const QString &label = QString()) {
- if (parent)
- return parent->getHandler(type, label);
- switch (type) {
- case Break:
- case Continue:
- return { Invalid, QString(), {}, -1, 0 };
- case Return:
- case Throw:
- return { type, QString(), BytecodeGenerator::Label::returnLabel(), -1, 0 };
- case Invalid:
- break;
- }
- Q_ASSERT(false);
- Q_UNREACHABLE();
+ virtual bool requiresUnwind() {
+ return false;
}
- virtual Handler getHandler(HandlerType type, const QString &label = QString()) = 0;
-
- BytecodeGenerator::ExceptionHandler *parentExceptionHandler() {
- return parent ? parent->exceptionHandler() : nullptr;
+public:
+ BytecodeGenerator::ExceptionHandler *parentUnwindHandler() {
+ return parent ? parent->unwindHandler() : nullptr;
}
- virtual BytecodeGenerator::ExceptionHandler *exceptionHandler() {
- return parentExceptionHandler();
+ virtual BytecodeGenerator::ExceptionHandler *unwindHandler() {
+ return parentUnwindHandler();
}
- virtual void handleThrow(const Reference &expr) {
- Reference e = expr;
- Handler h = getHandler(ControlFlow::Throw);
- if (h.tempIndex >= 0) {
- e = e.storeOnStack();
- Reference::storeConstOnStack(cg, QV4::Encode(h.value), h.tempIndex);
- }
- e.loadInAccumulator();
- Instruction::ThrowException instr;
- generator()->addInstruction(instr);
- }
-
protected:
QString loopLabel() const {
QString label;
@@ -193,136 +161,155 @@ protected:
}
};
-struct ControlFlowLoop : public ControlFlow
+struct ControlFlowUnwind : public ControlFlow
{
- QString loopLabel;
- BytecodeGenerator::Label *breakLabel = nullptr;
- BytecodeGenerator::Label *continueLabel = nullptr;
+ BytecodeGenerator::ExceptionHandler unwindLabel;
+
+ ControlFlowUnwind(Codegen *cg, Type type)
+ : ControlFlow(cg, type)
+ {
+ }
- ControlFlowLoop(Codegen *cg, BytecodeGenerator::Label *breakLabel, BytecodeGenerator::Label *continueLabel = nullptr)
- : ControlFlow(cg, Loop), loopLabel(ControlFlow::loopLabel()), breakLabel(breakLabel), continueLabel(continueLabel)
+ void setupUnwindHandler()
{
+ unwindLabel = generator()->newExceptionHandler();
}
- virtual QString label() const { return loopLabel; }
+ void emitUnwindHandler()
+ {
+ Q_ASSERT(requiresUnwind());
- virtual Handler getHandler(HandlerType type, const QString &label = QString()) {
- switch (type) {
- case Break:
- if (breakLabel && (label.isEmpty() || label == loopLabel))
- return { type, loopLabel, *breakLabel, -1, 0 };
- break;
- case Continue:
- if (continueLabel && (label.isEmpty() || label == loopLabel))
- return { type, loopLabel, *continueLabel, -1, 0 };
- break;
- case Return:
- case Throw:
- break;
- case Invalid:
- Q_ASSERT(false);
- Q_UNREACHABLE();
- }
- return getParentHandler(type, label);
+ Instruction::UnwindDispatch dispatch;
+ generator()->addInstruction(dispatch);
}
+ virtual BytecodeGenerator::ExceptionHandler *unwindHandler() override {
+ return unwindLabel.isValid() ? &unwindLabel : parentUnwindHandler();
+ }
};
-struct ControlFlowUnwind : public ControlFlow
+struct ControlFlowUnwindCleanup : public ControlFlowUnwind
{
- BytecodeGenerator::ExceptionHandler unwindLabel;
- int controlFlowTemp;
- QVector<Handler> handlers;
+ std::function<void()> cleanup = nullptr;
- ControlFlowUnwind(Codegen *cg, Type type)
- : ControlFlow(cg, type), unwindLabel(generator()->newExceptionHandler())
+ ControlFlowUnwindCleanup(Codegen *cg, std::function<void()> cleanup, Type type = Block)
+ : ControlFlowUnwind(cg, type), cleanup(cleanup)
{
- Q_ASSERT(type != Loop);
- controlFlowTemp = static_cast<int>(generator()->newRegister());
- Reference::storeConstOnStack(cg, QV4::Encode::undefined(), controlFlowTemp);
- // we'll need at least a handler for throw
- getHandler(Throw);
+ if (cleanup) {
+ setupUnwindHandler();
+ generator()->setUnwindHandler(&unwindLabel);
+ }
}
- void emitUnwindHandler()
- {
- Q_ASSERT(!isSimple());
-
- Reference temp = Reference::fromStackSlot(cg, controlFlowTemp);
- for (const auto &h : qAsConst(handlers)) {
- Handler parentHandler = getParentHandler(h.type, h.label);
-
- if (h.type == Throw || parentHandler.tempIndex >= 0) {
- BytecodeGenerator::Label skip = generator()->newLabel();
- generator()->jumpStrictNotEqualStackSlotInt(temp.stackSlot(), h.value).link(skip);
- if (h.type == Throw)
- emitForThrowHandling();
- jumpToHandler(parentHandler);
- skip.link();
- } else {
- if (parentHandler.linkLabel.isReturn()) {
- BytecodeGenerator::Label skip = generator()->newLabel();
- generator()->jumpStrictNotEqualStackSlotInt(temp.stackSlot(), h.value).link(skip);
- emitReturnStatement();
- skip.link();
- } else {
- generator()->jumpStrictEqualStackSlotInt(temp.stackSlot(), h.value).link(parentHandler.linkLabel);
- }
- }
+ ~ControlFlowUnwindCleanup() {
+ if (cleanup) {
+ unwindLabel.link();
+ generator()->setUnwindHandler(parentUnwindHandler());
+ cleanup();
+ emitUnwindHandler();
}
}
- virtual Handler getHandler(HandlerType type, const QString &label = QString()) {
- for (const auto &h : qAsConst(handlers)) {
- if (h.type == type && h.label == label)
- return h;
- }
- Handler h = {
- type,
- label,
- unwindLabel,
- controlFlowTemp,
- handlers.size()
- };
- handlers.append(h);
- return h;
+ bool requiresUnwind() override {
+ return cleanup != nullptr;
}
+};
+
+struct ControlFlowLoop : public ControlFlowUnwindCleanup
+{
+ QString loopLabel;
+ BytecodeGenerator::Label *breakLabel = nullptr;
+ BytecodeGenerator::Label *continueLabel = nullptr;
- virtual BytecodeGenerator::ExceptionHandler *exceptionHandler() {
- return &unwindLabel;
+ ControlFlowLoop(Codegen *cg, BytecodeGenerator::Label *breakLabel, BytecodeGenerator::Label *continueLabel = nullptr, std::function<void()> cleanup = nullptr)
+ : ControlFlowUnwindCleanup(cg, cleanup, Loop), loopLabel(ControlFlow::loopLabel()), breakLabel(breakLabel), continueLabel(continueLabel)
+ {
+ }
+
+ BytecodeGenerator::Label getUnwindTarget(UnwindType type, const QString &label) override {
+ switch (type) {
+ case Break:
+ if (breakLabel && (label.isEmpty() || label == loopLabel))
+ return *breakLabel;
+ break;
+ case Continue:
+ if (continueLabel && (label.isEmpty() || label == loopLabel))
+ return *continueLabel;
+ break;
+ default:
+ break;
+ }
+ return BytecodeGenerator::Label();
}
- virtual void emitForThrowHandling() { }
+ QString label() const override { return loopLabel; }
};
+
struct ControlFlowWith : public ControlFlowUnwind
{
ControlFlowWith(Codegen *cg)
: ControlFlowUnwind(cg, With)
{
- needsLookupByName = true;
-
- savedContextRegister = Moth::StackSlot::createRegister(generator()->newRegister());
+ setupUnwindHandler();
// assumes the with object is in the accumulator
Instruction::PushWithContext pushScope;
- pushScope.reg = savedContextRegister;
generator()->addInstruction(pushScope);
- generator()->setExceptionHandler(&unwindLabel);
+ generator()->setUnwindHandler(&unwindLabel);
}
- virtual ~ControlFlowWith() {
+ ~ControlFlowWith() {
// emit code for unwinding
unwindLabel.link();
- generator()->setExceptionHandler(parentExceptionHandler());
+ generator()->setUnwindHandler(parentUnwindHandler());
Instruction::PopContext pop;
- pop.reg = savedContextRegister;
generator()->addInstruction(pop);
emitUnwindHandler();
}
- Moth::StackSlot savedContextRegister;
+
+ bool requiresUnwind() override {
+ return true;
+ }
+
+
+};
+
+struct ControlFlowBlock : public ControlFlowUnwind
+{
+ ControlFlowBlock(Codegen *cg, AST::Node *ast)
+ : ControlFlowUnwind(cg, Block)
+ {
+ block = cg->enterBlock(ast);
+ block->emitBlockHeader(cg);
+
+ if (block->requiresExecutionContext) {
+ setupUnwindHandler();
+ generator()->setUnwindHandler(&unwindLabel);
+ }
+ }
+
+ virtual ~ControlFlowBlock() {
+ // emit code for unwinding
+ if (block->requiresExecutionContext) {
+ unwindLabel.link();
+ generator()->setUnwindHandler(parentUnwindHandler());
+ }
+
+ block->emitBlockFooter(cg);
+
+ if (block->requiresExecutionContext )
+ emitUnwindHandler();
+ cg->leaveBlock();
+ }
+
+ virtual bool requiresUnwind() override {
+ return block->requiresExecutionContext;
+ }
+
+ Context *block;
};
struct ControlFlowCatch : public ControlFlowUnwind
@@ -330,71 +317,56 @@ struct ControlFlowCatch : public ControlFlowUnwind
AST::Catch *catchExpression;
bool insideCatch = false;
BytecodeGenerator::ExceptionHandler exceptionLabel;
- BytecodeGenerator::ExceptionHandler catchUnwindLabel;
ControlFlowCatch(Codegen *cg, AST::Catch *catchExpression)
: ControlFlowUnwind(cg, Catch), catchExpression(catchExpression),
- exceptionLabel(generator()->newExceptionHandler()),
- catchUnwindLabel(generator()->newExceptionHandler())
+ exceptionLabel(generator()->newExceptionHandler())
{
- generator()->setExceptionHandler(&exceptionLabel);
+ generator()->setUnwindHandler(&exceptionLabel);
}
- virtual Handler getHandler(HandlerType type, const QString &label = QString()) {
- Handler h = getParentHandler(type, label);
- if (h.type == Invalid)
- return h;
- h = ControlFlowUnwind::getHandler(type, label);
- if (insideCatch)
- // if we're inside the catch block, we need to jump to the pop scope
- // instruction at the end of the catch block, not the unwind handler
- h.linkLabel = catchUnwindLabel;
- else if (type == Throw)
- // if we're inside the try block, we need to jump to the catch block,
- // not the unwind handler
- h.linkLabel = exceptionLabel;
- return h;
+ virtual bool requiresUnwind() override {
+ return true;
}
- virtual BytecodeGenerator::ExceptionHandler *exceptionHandler() {
- return insideCatch ? &catchUnwindLabel : &exceptionLabel;
+ BytecodeGenerator::ExceptionHandler *unwindHandler() override {
+ return insideCatch ? &unwindLabel : &exceptionLabel;
}
~ControlFlowCatch() {
// emit code for unwinding
-
- needsLookupByName = true;
insideCatch = true;
+ setupUnwindHandler();
Codegen::RegisterScope scope(cg);
// exceptions inside the try block go here
exceptionLabel.link();
- Moth::StackSlot savedContextReg = Moth::StackSlot::createRegister(generator()->newRegister());
- Instruction::PushCatchContext pushCatch;
- pushCatch.name = cg->registerString(catchExpression->name.toString());
- pushCatch.reg = savedContextReg;
- generator()->addInstruction(pushCatch);
- // clear the unwind temp for exceptions, we want to resume normal code flow afterwards
- Reference::storeConstOnStack(cg, QV4::Encode::undefined(), controlFlowTemp);
- generator()->setExceptionHandler(&catchUnwindLabel);
+ BytecodeGenerator::Jump noException = generator()->jumpNoException();
- cg->statement(catchExpression->statement);
+ Context *block = cg->enterBlock(catchExpression);
- insideCatch = false;
- needsLookupByName = false;
+ block->emitBlockHeader(cg);
- // exceptions inside catch and break/return statements go here
- catchUnwindLabel.link();
- Instruction::PopContext pop;
- pop.reg = savedContextReg;
- generator()->addInstruction(pop);
+ generator()->setUnwindHandler(&unwindLabel);
+
+ if (catchExpression->patternElement->bindingIdentifier.isEmpty())
+ // destructuring pattern
+ cg->initializeAndDestructureBindingElement(catchExpression->patternElement, Reference::fromName(cg, QStringLiteral("@caught")));
+ // skip the additional block
+ cg->statementList(catchExpression->statement->statements);
- // break/continue/return statements in try go here
+ // exceptions inside catch and break/return statements go here
unwindLabel.link();
- generator()->setExceptionHandler(parentExceptionHandler());
+ block->emitBlockFooter(cg);
+
+ cg->leaveBlock();
+
+ noException.link();
+ generator()->setUnwindHandler(parentUnwindHandler());
emitUnwindHandler();
+ insideCatch = false;
}
};
@@ -402,25 +374,21 @@ struct ControlFlowFinally : public ControlFlowUnwind
{
AST::Finally *finally;
bool insideFinally = false;
- int exceptionTemp = -1;
ControlFlowFinally(Codegen *cg, AST::Finally *finally)
: ControlFlowUnwind(cg, Finally), finally(finally)
{
Q_ASSERT(finally != nullptr);
- generator()->setExceptionHandler(&unwindLabel);
+ setupUnwindHandler();
+ generator()->setUnwindHandler(&unwindLabel);
}
- virtual Handler getHandler(HandlerType type, const QString &label = QString()) {
- // if we're inside the finally block, any exceptions etc. should
- // go directly to the parent handler
- if (insideFinally)
- return getParentHandler(type, label);
- return ControlFlowUnwind::getHandler(type, label);
+ virtual bool requiresUnwind() override {
+ return !insideFinally;
}
- virtual BytecodeGenerator::ExceptionHandler *exceptionHandler() {
- return insideFinally ? parentExceptionHandler() : ControlFlowUnwind::exceptionHandler();
+ BytecodeGenerator::ExceptionHandler *unwindHandler() override {
+ return insideFinally ? parentUnwindHandler() : ControlFlowUnwind::unwindHandler();
}
~ControlFlowFinally() {
@@ -429,34 +397,35 @@ struct ControlFlowFinally : public ControlFlowUnwind
Codegen::RegisterScope scope(cg);
- Moth::StackSlot retVal = Moth::StackSlot::createRegister(generator()->newRegister());
- Instruction::StoreReg storeRetVal;
- storeRetVal.reg = retVal;
- generator()->addInstruction(storeRetVal);
-
insideFinally = true;
- exceptionTemp = generator()->newRegister();
+ int returnValueTemp = -1;
+ if (cg->requiresReturnValue) {
+ returnValueTemp = generator()->newRegister();
+ Instruction::MoveReg move;
+ move.srcReg = cg->_returnAddress;
+ move.destReg = returnValueTemp;
+ generator()->addInstruction(move);
+ }
+ int exceptionTemp = generator()->newRegister();
Instruction::GetException instr;
generator()->addInstruction(instr);
Reference::fromStackSlot(cg, exceptionTemp).storeConsumeAccumulator();
- generator()->setExceptionHandler(parentExceptionHandler());
+ generator()->setUnwindHandler(parentUnwindHandler());
cg->statement(finally->statement);
insideFinally = false;
- Instruction::LoadReg loadRetVal;
- loadRetVal.reg = retVal;
- generator()->addInstruction(loadRetVal);
-
- emitUnwindHandler();
- }
-
- virtual void emitForThrowHandling() {
- // reset the exception flag, that got cleared before executing the statements in finally
+ if (cg->requiresReturnValue) {
+ Instruction::MoveReg move;
+ move.srcReg = returnValueTemp;
+ move.destReg = cg->_returnAddress;
+ generator()->addInstruction(move);
+ }
Reference::fromStackSlot(cg, exceptionTemp).loadInAccumulator();
Instruction::SetException setException;
- Q_ASSERT(exceptionTemp != -1);
generator()->addInstruction(setException);
+
+ emitUnwindHandler();
}
};
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index 84ee452332..4e18af2227 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -56,12 +56,12 @@ using namespace QV4;
using namespace QV4::Compiler;
using namespace QQmlJS::AST;
-ScanFunctions::ScanFunctions(Codegen *cg, const QString &sourceCode, CompilationMode defaultProgramMode)
+ScanFunctions::ScanFunctions(Codegen *cg, const QString &sourceCode, ContextType defaultProgramType)
: _cg(cg)
, _sourceCode(sourceCode)
, _context(nullptr)
, _allowFuncDecls(true)
- , defaultProgramMode(defaultProgramMode)
+ , defaultProgramType(defaultProgramType)
{
}
@@ -73,18 +73,19 @@ void ScanFunctions::operator()(Node *node)
calcEscapingVariables();
}
-void ScanFunctions::enterGlobalEnvironment(CompilationMode compilationMode)
+void ScanFunctions::enterGlobalEnvironment(ContextType compilationMode)
{
- enterEnvironment(astNodeForGlobalEnvironment, compilationMode);
+ enterEnvironment(astNodeForGlobalEnvironment, compilationMode, QStringLiteral("%GlobalCode"));
}
-void ScanFunctions::enterEnvironment(Node *node, CompilationMode compilationMode)
+void ScanFunctions::enterEnvironment(Node *node, ContextType compilationMode, const QString &name)
{
Context *c = _cg->_module->contextMap.value(node);
if (!c)
c = _cg->_module->newContext(node, _context, compilationMode);
if (!c->isStrict)
c->isStrict = _cg->_strictMode;
+ c->name = name;
_contextStack.append(c);
_context = c;
}
@@ -92,28 +93,26 @@ void ScanFunctions::enterEnvironment(Node *node, CompilationMode compilationMode
void ScanFunctions::leaveEnvironment()
{
_contextStack.pop();
- _context = _contextStack.isEmpty() ? 0 : _contextStack.top();
-}
-
-void ScanFunctions::checkDirectivePrologue(SourceElements *ast)
-{
- for (SourceElements *it = ast; it; it = it->next) {
- if (StatementSourceElement *stmt = cast<StatementSourceElement *>(it->element)) {
- if (ExpressionStatement *expr = cast<ExpressionStatement *>(stmt->statement)) {
- if (StringLiteral *strLit = cast<StringLiteral *>(expr->expression)) {
- // Use the source code, because the StringLiteral's
- // value might have escape sequences in it, which is not
- // allowed.
- if (strLit->literalToken.length < 2)
- continue;
- QStringRef str = _sourceCode.midRef(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
- if (str == QLatin1String("use strict")) {
- _context->isStrict = true;
- } else {
- // TODO: give a warning.
- }
+ _context = _contextStack.isEmpty() ? nullptr : _contextStack.top();
+}
+
+void ScanFunctions::checkDirectivePrologue(StatementList *ast)
+{
+ for (StatementList *it = ast; it; it = it->next) {
+ if (ExpressionStatement *expr = cast<ExpressionStatement *>(it->statement)) {
+ if (StringLiteral *strLit = cast<StringLiteral *>(expr->expression)) {
+ // Use the source code, because the StringLiteral's
+ // value might have escape sequences in it, which is not
+ // allowed.
+ if (strLit->literalToken.length < 2)
continue;
+ QStringRef str = _sourceCode.midRef(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
+ if (str == QLatin1String("use strict")) {
+ _context->isStrict = true;
+ } else {
+ // TODO: give a warning.
}
+ continue;
}
}
@@ -138,31 +137,162 @@ void ScanFunctions::checkName(const QStringRef &name, const SourceLocation &loc)
}
}
-bool ScanFunctions::formalsContainName(AST::FormalParameterList *parameters, const QString &name)
+bool ScanFunctions::visit(Program *ast)
{
- while (parameters) {
- if (parameters->name == name)
- return true;
- parameters = parameters->next;
- }
- return false;
+ enterEnvironment(ast, defaultProgramType, QStringLiteral("%ProgramCode"));
+ checkDirectivePrologue(ast->statements);
+ return true;
}
-bool ScanFunctions::visit(Program *ast)
+void ScanFunctions::endVisit(Program *)
+{
+ leaveEnvironment();
+}
+
+bool ScanFunctions::visit(ESModule *ast)
{
- enterEnvironment(ast, defaultProgramMode);
- checkDirectivePrologue(ast->elements);
+ enterEnvironment(ast, defaultProgramType, QStringLiteral("%ModuleCode"));
+ _context->isStrict = true;
return true;
}
-void ScanFunctions::endVisit(Program *)
+void ScanFunctions::endVisit(ESModule *)
{
leaveEnvironment();
}
+bool ScanFunctions::visit(ExportDeclaration *declaration)
+{
+ QString module;
+ if (declaration->fromClause) {
+ module = declaration->fromClause->moduleSpecifier.toString();
+ if (!module.isEmpty())
+ _context->moduleRequests << module;
+ }
+
+ QString localNameForDefaultExport = QStringLiteral("*default*");
+
+ if (declaration->exportAll) {
+ Compiler::ExportEntry entry;
+ entry.moduleRequest = declaration->fromClause->moduleSpecifier.toString();
+ entry.importName = QStringLiteral("*");
+ _context->exportEntries << entry;
+ } else if (declaration->exportClause) {
+ for (ExportsList *it = declaration->exportClause->exportsList; it; it = it->next) {
+ ExportSpecifier *spec = it->exportSpecifier;
+ Compiler::ExportEntry entry;
+ if (module.isEmpty())
+ entry.localName = spec->identifier.toString();
+ else
+ entry.importName = spec->identifier.toString();
+
+ entry.moduleRequest = module;
+ entry.exportName = spec->exportedIdentifier.toString();
+
+ _context->exportEntries << entry;
+ }
+ } else if (auto *vstmt = AST::cast<AST::VariableStatement*>(declaration->variableStatementOrDeclaration)) {
+ QStringList boundNames;
+ for (VariableDeclarationList *it = vstmt->declarations; it; it = it->next) {
+ if (!it->declaration)
+ continue;
+ it->declaration->boundNames(&boundNames);
+ }
+ for (const QString &name: boundNames) {
+ Compiler::ExportEntry entry;
+ entry.localName = name;
+ entry.exportName = name;
+ _context->exportEntries << entry;
+ }
+ } else if (auto *classDecl = AST::cast<AST::ClassDeclaration*>(declaration->variableStatementOrDeclaration)) {
+ QString name = classDecl->name.toString();
+ if (!name.isEmpty()) {
+ Compiler::ExportEntry entry;
+ entry.localName = name;
+ entry.exportName = name;
+ _context->exportEntries << entry;
+ if (declaration->exportDefault)
+ localNameForDefaultExport = entry.localName;
+ }
+ } else if (auto *fdef = declaration->variableStatementOrDeclaration->asFunctionDefinition()) {
+ QString functionName;
+
+ // Only function definitions for which we enter their name into the local environment
+ // can result in exports. Nested expressions such as (function foo() {}) are not accessible
+ // as locals and can only be exported as default exports (further down).
+ auto ast = declaration->variableStatementOrDeclaration;
+ if (AST::cast<AST::ExpressionStatement*>(ast) || AST::cast<AST::FunctionDeclaration*>(ast))
+ functionName = fdef->name.toString();
+
+ if (!functionName.isEmpty()) {
+ Compiler::ExportEntry entry;
+ entry.localName = functionName;
+ entry.exportName = functionName;
+ _context->exportEntries << entry;
+ if (declaration->exportDefault)
+ localNameForDefaultExport = entry.localName;
+ }
+ }
+
+ if (declaration->exportDefault) {
+ Compiler::ExportEntry entry;
+ entry.localName = localNameForDefaultExport;
+ _context->localNameForDefaultExport = localNameForDefaultExport;
+ entry.exportName = QStringLiteral("default");
+ _context->exportEntries << entry;
+ }
+
+ return true; // scan through potential assignment expression code, etc.
+}
+
+bool ScanFunctions::visit(ImportDeclaration *declaration)
+{
+ QString module;
+ if (declaration->fromClause) {
+ module = declaration->fromClause->moduleSpecifier.toString();
+ if (!module.isEmpty())
+ _context->moduleRequests << module;
+ }
+
+ if (!declaration->moduleSpecifier.isEmpty())
+ _context->moduleRequests << declaration->moduleSpecifier.toString();
+
+ if (ImportClause *import = declaration->importClause) {
+ if (!import->importedDefaultBinding.isEmpty()) {
+ Compiler::ImportEntry entry;
+ entry.moduleRequest = module;
+ entry.importName = QStringLiteral("default");
+ entry.localName = import->importedDefaultBinding.toString();
+ _context->importEntries << entry;
+ }
+
+ if (import->nameSpaceImport) {
+ Compiler::ImportEntry entry;
+ entry.moduleRequest = module;
+ entry.importName = QStringLiteral("*");
+ entry.localName = import->nameSpaceImport->importedBinding.toString();
+ _context->importEntries << entry;
+ }
+
+ if (import->namedImports) {
+ for (ImportsList *it = import->namedImports->importsList; it; it = it->next) {
+ Compiler::ImportEntry entry;
+ entry.moduleRequest = module;
+ entry.localName = it->importSpecifier->importedBinding.toString();
+ if (!it->importSpecifier->identifier.isEmpty())
+ entry.importName = it->importSpecifier->identifier.toString();
+ else
+ entry.importName = entry.localName;
+ _context->importEntries << entry;
+ }
+ }
+ }
+ return false;
+}
+
bool ScanFunctions::visit(CallExpression *ast)
{
- if (! _context->hasDirectEval) {
+ if (!_context->hasDirectEval) {
if (IdentifierExpression *id = cast<IdentifierExpression *>(ast->base)) {
if (id->name == QLatin1String("eval")) {
if (_context->usesArgumentsObject == Context::ArgumentsObjectUnknown)
@@ -171,53 +301,36 @@ bool ScanFunctions::visit(CallExpression *ast)
}
}
}
- int argc = 0;
- for (ArgumentList *it = ast->arguments; it; it = it->next)
- ++argc;
- _context->maxNumberOfArguments = qMax(_context->maxNumberOfArguments, argc);
return true;
}
-bool ScanFunctions::visit(NewMemberExpression *ast)
+bool ScanFunctions::visit(PatternElement *ast)
{
- int argc = 0;
- for (ArgumentList *it = ast->arguments; it; it = it->next)
- ++argc;
- _context->maxNumberOfArguments = qMax(_context->maxNumberOfArguments, argc);
- return true;
-}
+ if (!ast->isVariableDeclaration())
+ return true;
-bool ScanFunctions::visit(ArrayLiteral *ast)
-{
- int index = 0;
- for (ElementList *it = ast->elements; it; it = it->next) {
- for (Elision *elision = it->elision; elision; elision = elision->next)
- ++index;
- ++index;
- }
- if (ast->elision) {
- for (Elision *elision = ast->elision->next; elision; elision = elision->next)
- ++index;
- }
- _context->maxNumberOfArguments = qMax(_context->maxNumberOfArguments, index);
- return true;
-}
+ QStringList names;
+ ast->boundNames(&names);
-bool ScanFunctions::visit(VariableDeclaration *ast)
-{
- if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments")))
- _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
- checkName(ast->name, ast->identifierToken);
- if (ast->name == QLatin1String("arguments"))
- _context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
- if (ast->scope == AST::VariableDeclaration::VariableScope::ReadOnlyBlockScope && !ast->expression) {
- _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Missing initializer in const declaration"));
- return false;
- }
- QString name = ast->name.toString();
- if (!_context->addLocalVar(ast->name.toString(), ast->expression ? Context::VariableDefinition : Context::VariableDeclaration, ast->scope)) {
- _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Identifier %1 has already been declared").arg(name));
- return false;
+ QQmlJS::AST::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
+ if (_context->lastBlockInitializerLocation.isValid())
+ lastInitializerLocation = _context->lastBlockInitializerLocation;
+
+ for (const QString &name : qAsConst(names)) {
+ if (_context->isStrict && (name == QLatin1String("eval") || name == QLatin1String("arguments")))
+ _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
+ checkName(QStringRef(&name), ast->identifierToken);
+ if (name == QLatin1String("arguments"))
+ _context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
+ if (ast->scope == VariableScope::Const && !ast->initializer && !ast->isForDeclaration && !ast->destructuringPattern()) {
+ _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Missing initializer in const declaration"));
+ return false;
+ }
+ if (!_context->addLocalVar(name, ast->initializer ? Context::VariableDefinition : Context::VariableDeclaration, ast->scope,
+ /*function*/nullptr, lastInitializerLocation)) {
+ _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Identifier %1 has already been declared").arg(name));
+ return false;
+ }
}
return true;
}
@@ -237,7 +350,8 @@ bool ScanFunctions::visit(ExpressionStatement *ast)
if (!_allowFuncDecls)
_cg->throwSyntaxError(expr->functionToken, QStringLiteral("conditional function or closure declaration"));
- enterFunction(expr, /*enterName*/ true);
+ if (!enterFunction(expr, /*enterName*/ true))
+ return false;
Node::accept(expr->formals, this);
Node::accept(expr->body, this);
leaveEnvironment();
@@ -253,79 +367,137 @@ bool ScanFunctions::visit(ExpressionStatement *ast)
bool ScanFunctions::visit(FunctionExpression *ast)
{
- enterFunction(ast, /*enterName*/ false);
+ return enterFunction(ast, /*enterName*/ false);
+}
+
+bool ScanFunctions::visit(ClassExpression *ast)
+{
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%Class"));
+ _context->isStrict = true;
+ _context->hasNestedFunctions = true;
+ if (!ast->name.isEmpty())
+ _context->addLocalVar(ast->name.toString(), Context::VariableDefinition, AST::VariableScope::Const);
return true;
}
-void ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName)
+void ScanFunctions::endVisit(ClassExpression *)
{
- if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments")))
- _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Function name may not be eval or arguments in strict mode"));
- enterFunction(ast, ast->name.toString(), ast->formals, ast->body, enterName ? ast : nullptr);
+ leaveEnvironment();
}
-void ScanFunctions::endVisit(FunctionExpression *)
+bool ScanFunctions::visit(ClassDeclaration *ast)
+{
+ if (!ast->name.isEmpty())
+ _context->addLocalVar(ast->name.toString(), Context::VariableDeclaration, AST::VariableScope::Let);
+
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%Class"));
+ _context->isStrict = true;
+ _context->hasNestedFunctions = true;
+ if (!ast->name.isEmpty())
+ _context->addLocalVar(ast->name.toString(), Context::VariableDefinition, AST::VariableScope::Const);
+ return true;
+}
+
+void ScanFunctions::endVisit(ClassDeclaration *)
{
leaveEnvironment();
}
-bool ScanFunctions::visit(ObjectLiteral *ast)
+bool ScanFunctions::visit(TemplateLiteral *ast)
{
- int argc = 0;
- for (PropertyAssignmentList *it = ast->properties; it; it = it->next) {
- QString key = it->assignment->name->asString();
- if (QV4::String::toArrayIndex(key) != UINT_MAX)
- ++argc;
- ++argc;
- if (AST::cast<AST::PropertyGetterSetter *>(it->assignment))
- ++argc;
+ while (ast) {
+ if (ast->expression)
+ Node::accept(ast->expression, this);
+ ast = ast->next;
}
- _context->maxNumberOfArguments = qMax(_context->maxNumberOfArguments, argc);
+ return true;
+
+}
+
+bool ScanFunctions::visit(SuperLiteral *)
+{
+ Context *c = _context;
+ bool needContext = false;
+ while (c && (c->contextType == ContextType::Block || c->isArrowFunction)) {
+ needContext |= c->isArrowFunction;
+ c = c->parent;
+ }
+
+ c->requiresExecutionContext |= needContext;
- TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, true);
- Node::accept(ast->properties, this);
return false;
}
-bool ScanFunctions::visit(PropertyGetterSetter *ast)
+bool ScanFunctions::visit(FieldMemberExpression *ast)
{
- TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, true);
- enterFunction(ast, QString(), ast->formals, ast->functionBody, /*FunctionExpression*/nullptr);
+ if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(ast->base)) {
+ if (id->name == QLatin1String("new")) {
+ // new.target
+ if (ast->name != QLatin1String("target")) {
+ _cg->throwSyntaxError(ast->identifierToken, QLatin1String("Expected 'target' after 'new.'."));
+ return false;
+ }
+ Context *c = _context;
+ bool needContext = false;
+ while (c->contextType == ContextType::Block || c->isArrowFunction) {
+ needContext |= c->isArrowFunction;
+ c = c->parent;
+ }
+ c->requiresExecutionContext |= needContext;
+ c->innerFunctionAccessesNewTarget |= needContext;
+
+ return false;
+ }
+ }
+
return true;
}
-void ScanFunctions::endVisit(PropertyGetterSetter *)
+bool ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName)
{
- leaveEnvironment();
+ if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments")))
+ _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Function name may not be eval or arguments in strict mode"));
+ return enterFunction(ast, ast->name.toString(), ast->formals, ast->body, enterName);
}
-bool ScanFunctions::visit(FunctionDeclaration *ast)
+void ScanFunctions::endVisit(FunctionExpression *)
{
- enterFunction(ast, /*enterName*/ true);
- return true;
+ leaveEnvironment();
}
-void ScanFunctions::endVisit(FunctionDeclaration *)
+bool ScanFunctions::visit(ObjectPattern *ast)
{
- leaveEnvironment();
+ TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, true);
+ Node::accept(ast->properties, this);
+ return false;
}
-bool ScanFunctions::visit(TryStatement *)
+bool ScanFunctions::visit(PatternProperty *ast)
{
- // ### should limit to catch(), as try{} finally{} should be ok without
- _context->hasTry = true;
+ Q_UNUSED(ast);
+ // ### Shouldn't be required anymore
+// if (ast->type == PatternProperty::Getter || ast->type == PatternProperty::Setter) {
+// TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, true);
+// return enterFunction(ast, QString(), ast->formals, ast->functionBody, /*enterName */ false);
+// }
return true;
}
-bool ScanFunctions::visit(WithStatement *ast)
+void ScanFunctions::endVisit(PatternProperty *)
{
- if (_context->isStrict) {
- _cg->throwSyntaxError(ast->withToken, QStringLiteral("'with' statement is not allowed in strict mode"));
- return false;
- }
+ // ###
+// if (ast->type == PatternProperty::Getter || ast->type == PatternProperty::Setter)
+// leaveEnvironment();
+}
- _context->hasWith = true;
- return true;
+bool ScanFunctions::visit(FunctionDeclaration *ast)
+{
+ return enterFunction(ast, /*enterName*/ true);
+}
+
+void ScanFunctions::endVisit(FunctionDeclaration *)
+{
+ leaveEnvironment();
}
bool ScanFunctions::visit(DoWhileStatement *ast) {
@@ -338,7 +510,9 @@ bool ScanFunctions::visit(DoWhileStatement *ast) {
}
bool ScanFunctions::visit(ForStatement *ast) {
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%For"));
Node::accept(ast->initialiser, this);
+ Node::accept(ast->declarations, this);
Node::accept(ast->condition, this);
Node::accept(ast->expression, this);
@@ -348,9 +522,16 @@ bool ScanFunctions::visit(ForStatement *ast) {
return false;
}
-bool ScanFunctions::visit(LocalForStatement *ast) {
- Node::accept(ast->declarations, this);
- Node::accept(ast->condition, this);
+void ScanFunctions::endVisit(ForStatement *)
+{
+ leaveEnvironment();
+}
+
+bool ScanFunctions::visit(ForEachStatement *ast) {
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%Foreach"));
+ if (ast->expression)
+ _context->lastBlockInitializerLocation = ast->expression->lastSourceLocation();
+ Node::accept(ast->lhs, this);
Node::accept(ast->expression, this);
TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, !_context->isStrict);
@@ -359,90 +540,154 @@ bool ScanFunctions::visit(LocalForStatement *ast) {
return false;
}
-bool ScanFunctions::visit(ForEachStatement *ast) {
- Node::accept(ast->initialiser, this);
- Node::accept(ast->expression, this);
+void ScanFunctions::endVisit(ForEachStatement *)
+{
+ leaveEnvironment();
+}
- TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, !_context->isStrict);
- Node::accept(ast->statement, this);
+bool ScanFunctions::visit(ThisExpression *)
+{
+ _context->usesThis = true;
+ return false;
+}
+bool ScanFunctions::visit(Block *ast)
+{
+ TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, _context->isStrict ? false : _allowFuncDecls);
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%Block"));
+ Node::accept(ast->statements, this);
return false;
}
-bool ScanFunctions::visit(LocalForEachStatement *ast) {
- Node::accept(ast->declaration, this);
- Node::accept(ast->expression, this);
+void ScanFunctions::endVisit(Block *)
+{
+ leaveEnvironment();
+}
- TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, !_context->isStrict);
- Node::accept(ast->statement, this);
+bool ScanFunctions::visit(CaseBlock *ast)
+{
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%CaseBlock"));
+ return true;
+}
- return false;
+void ScanFunctions::endVisit(CaseBlock *)
+{
+ leaveEnvironment();
}
-bool ScanFunctions::visit(ThisExpression *)
+bool ScanFunctions::visit(Catch *ast)
{
- _context->usesThis = true;
+ TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, _context->isStrict ? false : _allowFuncDecls);
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%CatchBlock"));
+ _context->isCatchBlock = true;
+ QString caughtVar = ast->patternElement->bindingIdentifier.toString();
+ if (caughtVar.isEmpty())
+ caughtVar = QStringLiteral("@caught");
+ _context->addLocalVar(caughtVar, Context::MemberType::VariableDefinition, VariableScope::Let);
+
+ _context->caughtVariable = caughtVar;
+ if (_context->isStrict &&
+ (caughtVar == QLatin1String("eval") || caughtVar == QLatin1String("arguments"))) {
+ _cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Catch variable name may not be eval or arguments in strict mode"));
+ return false;
+ }
+ Node::accept(ast->patternElement, this);
+ // skip the block statement
+ Node::accept(ast->statement->statements, this);
return false;
}
-bool ScanFunctions::visit(Block *ast) {
+void ScanFunctions::endVisit(Catch *)
+{
+ leaveEnvironment();
+}
+
+bool ScanFunctions::visit(WithStatement *ast)
+{
+ Node::accept(ast->expression, this);
+
TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, _context->isStrict ? false : _allowFuncDecls);
- Node::accept(ast->statements, this);
+ enterEnvironment(ast, ContextType::Block, QStringLiteral("%WithBlock"));
+ _context->isWithBlock = true;
+
+ if (_context->isStrict) {
+ _cg->throwSyntaxError(ast->withToken, QStringLiteral("'with' statement is not allowed in strict mode"));
+ return false;
+ }
+ Node::accept(ast->statement, this);
+
return false;
}
-void ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParameterList *formals, FunctionBody *body, FunctionExpression *expr)
+void ScanFunctions::endVisit(WithStatement *)
+{
+ leaveEnvironment();
+}
+
+bool ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParameterList *formals, StatementList *body, bool enterName)
{
Context *outerContext = _context;
- enterEnvironment(ast, FunctionCode);
+ enterEnvironment(ast, ContextType::Function, name);
+ FunctionExpression *expr = AST::cast<FunctionExpression *>(ast);
+ if (!expr)
+ expr = AST::cast<FunctionDeclaration *>(ast);
if (outerContext) {
outerContext->hasNestedFunctions = true;
// The identifier of a function expression cannot be referenced from the enclosing environment.
- if (expr) {
- if (!outerContext->addLocalVar(name, Context::FunctionDefinition, AST::VariableDeclaration::FunctionScope, expr)) {
+ if (enterName) {
+ if (!outerContext->addLocalVar(name, Context::FunctionDefinition, VariableScope::Var, expr)) {
_cg->throwSyntaxError(ast->firstSourceLocation(), QStringLiteral("Identifier %1 has already been declared").arg(name));
- return;
+ return false;
}
+ outerContext->addLocalVar(name, Context::FunctionDefinition, VariableScope::Var, expr);
}
if (name == QLatin1String("arguments"))
outerContext->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
}
- if (formalsContainName(formals, QStringLiteral("arguments")))
+ _context->name = name;
+ if (formals && formals->containsName(QStringLiteral("arguments")))
_context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
+ if (expr) {
+ if (expr->isArrowFunction)
+ _context->isArrowFunction = true;
+ else if (expr->isGenerator)
+ _context->isGenerator = true;
+ }
- if (!name.isEmpty() && !formalsContainName(formals, name))
- _context->addLocalVar(name, Context::ThisFunctionName, QQmlJS::AST::VariableDeclaration::FunctionScope);
+ if (!enterName && (!name.isEmpty() && (!formals || !formals->containsName(name))))
+ _context->addLocalVar(name, Context::ThisFunctionName, VariableScope::Var);
_context->formals = formals;
if (body && !_context->isStrict)
- checkDirectivePrologue(body->elements);
-
- for (FormalParameterList *it = formals; it; it = it->next) {
- QString arg = it->name.toString();
- int duplicateIndex = _context->arguments.indexOf(arg);
- if (duplicateIndex != -1) {
- if (_context->isStrict) {
- _cg->throwSyntaxError(it->identifierToken, QStringLiteral("Duplicate parameter name '%1' is not allowed in strict mode").arg(arg));
- return;
- } else {
- // change the name of the earlier argument to enforce the specified lookup semantics
- QString modified = arg;
- while (_context->arguments.contains(modified))
- modified += QString(0xfffe);
- _context->arguments[duplicateIndex] = modified;
+ checkDirectivePrologue(body);
+
+ bool isSimpleParameterList = formals && formals->isSimpleParameterList();
+
+ _context->arguments = formals ? formals->formals() : QStringList();
+
+ const QStringList boundNames = formals ? formals->boundNames() : QStringList();
+ for (int i = 0; i < boundNames.size(); ++i) {
+ const QString &arg = boundNames.at(i);
+ if (_context->isStrict || !isSimpleParameterList) {
+ bool duplicate = (boundNames.indexOf(arg, i + 1) != -1);
+ if (duplicate) {
+ _cg->throwSyntaxError(formals->firstSourceLocation(), QStringLiteral("Duplicate parameter name '%1' is not allowed.").arg(arg));
+ return false;
}
}
if (_context->isStrict) {
if (arg == QLatin1String("eval") || arg == QLatin1String("arguments")) {
- _cg->throwSyntaxError(it->identifierToken, QStringLiteral("'%1' cannot be used as parameter name in strict mode").arg(arg));
- return;
+ _cg->throwSyntaxError(formals->firstSourceLocation(), QStringLiteral("'%1' cannot be used as parameter name in strict mode").arg(arg));
+ return false;
}
}
- _context->arguments += arg;
+ if (!_context->arguments.contains(arg))
+ _context->addLocalVar(arg, Context::VariableDefinition, VariableScope::Var);
}
+ return true;
}
void ScanFunctions::calcEscapingVariables()
@@ -450,27 +695,150 @@ void ScanFunctions::calcEscapingVariables()
Module *m = _cg->_module;
for (Context *inner : qAsConst(m->contextMap)) {
+ if (inner->usesArgumentsObject != Context::ArgumentsObjectUsed)
+ continue;
+ if (inner->contextType != ContextType::Block && !inner->isArrowFunction)
+ continue;
+ Context *c = inner->parent;
+ while (c && (c->contextType == ContextType::Block || c->isArrowFunction))
+ c = c->parent;
+ if (c)
+ c->usesArgumentsObject = Context::ArgumentsObjectUsed;
+ inner->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
+ }
+ for (Context *inner : qAsConst(m->contextMap)) {
+ if (!inner->parent || inner->usesArgumentsObject == Context::ArgumentsObjectUnknown)
+ inner->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
+ if (inner->usesArgumentsObject == Context::ArgumentsObjectUsed) {
+ QString arguments = QStringLiteral("arguments");
+ inner->addLocalVar(arguments, Context::VariableDeclaration, AST::VariableScope::Var);
+ if (!inner->isStrict) {
+ inner->argumentsCanEscape = true;
+ inner->requiresExecutionContext = true;
+ }
+ }
+ }
+
+ for (Context *c : qAsConst(m->contextMap)) {
+ if (c->contextType != ContextType::ESModule)
+ continue;
+ for (const auto &entry: c->exportEntries) {
+ auto m = c->members.find(entry.localName);
+ if (m != c->members.end())
+ m->canEscape = true;
+ }
+ break;
+ }
+
+ for (Context *inner : qAsConst(m->contextMap)) {
for (const QString &var : qAsConst(inner->usedVariables)) {
Context *c = inner;
while (c) {
+ Context *current = c;
+ c = c->parent;
+ if (current->isWithBlock || current->contextType != ContextType::Block)
+ break;
+ }
+ Q_ASSERT(c != inner);
+ while (c) {
Context::MemberMap::const_iterator it = c->members.find(var);
if (it != c->members.end()) {
- if (c != inner)
+ if (c->parent || it->isLexicallyScoped()) {
+ it->canEscape = true;
+ c->requiresExecutionContext = true;
+ } else if (c->contextType == ContextType::ESModule) {
+ // Module instantiation provides a context, but vars used from inner
+ // scopes need to be stored in its locals[].
it->canEscape = true;
+ }
break;
}
if (c->findArgument(var) != -1) {
- if (c != inner)
- c->argumentsCanEscape = true;
+ c->argumentsCanEscape = true;
+ c->requiresExecutionContext = true;
break;
}
c = c->parent;
}
}
- Context *c = inner->parent;
- while (c) {
- c->hasDirectEval |= inner->hasDirectEval;
- c = c->parent;
+ if (inner->hasDirectEval) {
+ inner->hasDirectEval = false;
+ inner->innerFunctionAccessesNewTarget = true;
+ if (!inner->isStrict) {
+ Context *c = inner;
+ while (c->contextType == ContextType::Block) {
+ c = c->parent;
+ }
+ Q_ASSERT(c);
+ c->hasDirectEval = true;
+ c->innerFunctionAccessesThis = true;
+ }
+ Context *c = inner;
+ while (c) {
+ c->allVarsEscape = true;
+ c = c->parent;
+ }
+ }
+ if (inner->usesThis) {
+ inner->usesThis = false;
+ bool innerFunctionAccessesThis = false;
+ Context *c = inner;
+ while (c->contextType == ContextType::Block || c->isArrowFunction) {
+ innerFunctionAccessesThis |= c->isArrowFunction;
+ c = c->parent;
+ }
+ Q_ASSERT(c);
+ if (!inner->isStrict)
+ c->usesThis = true;
+ c->innerFunctionAccessesThis |= innerFunctionAccessesThis;
+ }
+ }
+ for (Context *c : qAsConst(m->contextMap)) {
+ if (c->innerFunctionAccessesThis) {
+ // add an escaping 'this' variable
+ c->addLocalVar(QStringLiteral("this"), Context::VariableDefinition, VariableScope::Let);
+ c->requiresExecutionContext = true;
+ auto m = c->members.find(QStringLiteral("this"));
+ m->canEscape = true;
+ }
+ if (c->innerFunctionAccessesNewTarget) {
+ // add an escaping 'new.target' variable
+ c->addLocalVar(QStringLiteral("new.target"), Context::VariableDefinition, VariableScope::Let);
+ c->requiresExecutionContext = true;
+ auto m = c->members.find(QStringLiteral("new.target"));
+ m->canEscape = true;
+ }
+ if (c->allVarsEscape && c->contextType == ContextType::Block && c->members.isEmpty())
+ c->allVarsEscape = false;
+ if (c->contextType == ContextType::Global || (!c->isStrict && c->contextType == ContextType::Eval) || m->debugMode)
+ c->allVarsEscape = true;
+ if (c->allVarsEscape) {
+ if (c->parent) {
+ c->requiresExecutionContext = true;
+ c->argumentsCanEscape = true;
+ } else {
+ for (const auto &m : qAsConst(c->members)) {
+ if (m.isLexicallyScoped()) {
+ c->requiresExecutionContext = true;
+ break;
+ }
+ }
+ }
+ }
+ if (c->contextType == ContextType::Block && c->isCatchBlock) {
+ c->requiresExecutionContext = true;
+ auto m = c->members.find(c->caughtVariable);
+ m->canEscape = true;
+ }
+ const QLatin1String exprForOn("expression for on");
+ if (c->contextType == ContextType::Binding && c->name.length() > exprForOn.size() &&
+ c->name.startsWith(exprForOn) && c->name.at(exprForOn.size()).isUpper())
+ // we don't really need this for bindings, but we do for signal handlers, and in this case,
+ // we don't know if the code is a signal handler or not.
+ c->requiresExecutionContext = true;
+ if (c->allVarsEscape) {
+ for (auto &m : c->members)
+ m.canEscape = true;
}
}
@@ -478,10 +846,13 @@ void ScanFunctions::calcEscapingVariables()
if (showEscapingVars) {
qDebug() << "==== escaping variables ====";
for (Context *c : qAsConst(m->contextMap)) {
- qDebug() << "Context" << c->name << ":";
- qDebug() << " Arguments escape" << c->argumentsCanEscape;
+ qDebug() << "Context" << c << c->name << "requiresExecutionContext" << c->requiresExecutionContext << "isStrict" << c->isStrict;
+ qDebug() << " isArrowFunction" << c->isArrowFunction << "innerFunctionAccessesThis" << c->innerFunctionAccessesThis;
+ qDebug() << " parent:" << c->parent;
+ if (c->argumentsCanEscape)
+ qDebug() << " Arguments escape";
for (auto it = c->members.constBegin(); it != c->members.constEnd(); ++it) {
- qDebug() << " " << it.key() << it.value().canEscape;
+ qDebug() << " " << it.key() << it.value().index << it.value().canEscape << "isLexicallyScoped:" << it.value().isLexicallyScoped();
}
}
}
diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h
index 87b7210879..bb07540ec9 100644
--- a/src/qml/compiler/qv4compilerscanfunctions_p.h
+++ b/src/qml/compiler/qv4compilerscanfunctions_p.h
@@ -58,6 +58,7 @@
#include <private/qv4util_p.h>
#include <QtCore/QStringList>
#include <QStack>
+#include <QScopedValueRollback>
QT_BEGIN_NAMESPACE
@@ -79,13 +80,13 @@ class Codegen;
class ScanFunctions: protected QQmlJS::AST::Visitor
{
- typedef QV4::TemporaryAssignment<bool> TemporaryBoolAssignment;
+ typedef QScopedValueRollback<bool> TemporaryBoolAssignment;
public:
- ScanFunctions(Codegen *cg, const QString &sourceCode, CompilationMode defaultProgramMode);
+ ScanFunctions(Codegen *cg, const QString &sourceCode, ContextType defaultProgramType);
void operator()(AST::Node *node);
- void enterGlobalEnvironment(CompilationMode compilationMode);
- void enterEnvironment(AST::Node *node, CompilationMode compilationMode);
+ void enterGlobalEnvironment(ContextType compilationMode);
+ void enterEnvironment(AST::Node *node, ContextType compilationMode, const QString &name);
void leaveEnvironment();
void enterQmlFunction(AST::FunctionDeclaration *ast)
@@ -95,48 +96,68 @@ protected:
using Visitor::visit;
using Visitor::endVisit;
- void checkDirectivePrologue(AST::SourceElements *ast);
+ void checkDirectivePrologue(AST::StatementList *ast);
void checkName(const QStringRef &name, const AST::SourceLocation &loc);
- bool formalsContainName(AST::FormalParameterList *parameters, const QString &name);
bool visit(AST::Program *ast) override;
void endVisit(AST::Program *) override;
+ bool visit(AST::ESModule *ast) override;
+ void endVisit(AST::ESModule *) override;
+
+ bool visit(AST::ExportDeclaration *declaration) override;
+ bool visit(AST::ImportDeclaration *declaration) override;
+
bool visit(AST::CallExpression *ast) override;
- bool visit(AST::NewMemberExpression *ast) override;
- bool visit(AST::ArrayLiteral *ast) override;
- bool visit(AST::VariableDeclaration *ast) override;
+ bool visit(AST::PatternElement *ast) override;
bool visit(AST::IdentifierExpression *ast) override;
bool visit(AST::ExpressionStatement *ast) override;
bool visit(AST::FunctionExpression *ast) override;
+ bool visit(AST::TemplateLiteral *ast) override;
+ bool visit(AST::SuperLiteral *) override;
+ bool visit(AST::FieldMemberExpression *) override;
- void enterFunction(AST::FunctionExpression *ast, bool enterName);
+ bool enterFunction(AST::FunctionExpression *ast, bool enterName);
void endVisit(AST::FunctionExpression *) override;
- bool visit(AST::ObjectLiteral *ast) override;
+ bool visit(AST::ObjectPattern *ast) override;
- bool visit(AST::PropertyGetterSetter *ast) override;
- void endVisit(AST::PropertyGetterSetter *) override;
+ bool visit(AST::PatternProperty *ast) override;
+ void endVisit(AST::PatternProperty *) override;
bool visit(AST::FunctionDeclaration *ast) override;
void endVisit(AST::FunctionDeclaration *) override;
- bool visit(AST::TryStatement *ast) override;
- bool visit(AST::WithStatement *ast) override;
+ bool visit(AST::ClassExpression *ast) override;
+ void endVisit(AST::ClassExpression *) override;
+
+ bool visit(AST::ClassDeclaration *ast) override;
+ void endVisit(AST::ClassDeclaration *) override;
bool visit(AST::DoWhileStatement *ast) override;
bool visit(AST::ForStatement *ast) override;
- bool visit(AST::LocalForStatement *ast) override;
+ void endVisit(AST::ForStatement *) override;
bool visit(AST::ForEachStatement *ast) override;
- bool visit(AST::LocalForEachStatement *ast) override;
+ void endVisit(AST::ForEachStatement *) override;
+
bool visit(AST::ThisExpression *ast) override;
bool visit(AST::Block *ast) override;
+ void endVisit(AST::Block *ast) override;
+
+ bool visit(AST::CaseBlock *ast) override;
+ void endVisit(AST::CaseBlock *ast) override;
+
+ bool visit(AST::Catch *ast) override;
+ void endVisit(AST::Catch *ast) override;
+
+ bool visit(AST::WithStatement *ast) override;
+ void endVisit(AST::WithStatement *ast) override;
protected:
- void enterFunction(AST::Node *ast, const QString &name, AST::FormalParameterList *formals, AST::FunctionBody *body, AST::FunctionExpression *expr);
+ bool enterFunction(AST::Node *ast, const QString &name, AST::FormalParameterList *formals, AST::StatementList *body, bool enterName);
void calcEscapingVariables();
// fields:
@@ -146,7 +167,7 @@ protected:
QStack<Context *> _contextStack;
bool _allowFuncDecls;
- CompilationMode defaultProgramMode;
+ ContextType defaultProgramType;
private:
static constexpr AST::Node *astNodeForGlobalEnvironment = nullptr;
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index 450fa50528..a125f0ce28 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -39,15 +39,16 @@
#include "qv4instr_moth_p.h"
#include <private/qv4compileddata_p.h>
+#include <private/qv4stackframe_p.h>
using namespace QV4;
using namespace QV4::Moth;
int InstrInfo::size(Instr::Type type)
{
-#define MOTH_RETURN_INSTR_SIZE(I) case Instr::Type::I: return InstrMeta<int(Instr::Type::I)>::Size;
+#define MOTH_RETURN_INSTR_SIZE(I) case Instr::Type::I: case Instr::Type::I##_Wide: return InstrMeta<int(Instr::Type::I)>::Size;
switch (type) {
- FOR_EACH_MOTH_INSTR(MOTH_RETURN_INSTR_SIZE)
+ FOR_EACH_MOTH_INSTR_ALL(MOTH_RETURN_INSTR_SIZE)
}
#undef MOTH_RETURN_INSTR_SIZE
Q_UNREACHABLE();
@@ -110,6 +111,8 @@ static QString toString(QV4::ReturnedValue v)
QDebug d = qDebug(); \
d.noquote(); \
d.nospace(); \
+ if (static_cast<int>(Instr::Type::instr) >= 0x100) \
+ --base_ptr; \
d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " \
<< rawBytes(base_ptr, int(code - base_ptr)) << #instr << " ";
@@ -122,7 +125,7 @@ namespace QV4 {
namespace Moth {
const int InstrInfo::argumentCount[] = {
- FOR_EACH_MOTH_INSTR(MOTH_COLLECT_NARGS)
+ FOR_EACH_MOTH_INSTR_ALL(MOTH_COLLECT_NARGS)
};
@@ -147,11 +150,13 @@ QString dumpRegister(int reg, int nFormals)
return QStringLiteral("(context)");
else if (reg == CallData::Accumulator)
return QStringLiteral("(accumulator)");
+ else if (reg == CallData::NewTarget)
+ return QStringLiteral("(new.target)");
else if (reg == CallData::This)
return QStringLiteral("(this)");
else if (reg == CallData::Argc)
return QStringLiteral("(argc)");
- reg -= 4;
+ reg -= CallData::OffsetCount;
if (reg <= nFormals)
return QStringLiteral("a%1").arg(reg);
reg -= nFormals;
@@ -202,6 +207,10 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << dumpRegister(destReg, nFormals) << ", " << dumpRegister(srcReg, nFormals);
MOTH_END_INSTR(MoveReg)
+ MOTH_BEGIN_INSTR(LoadImport)
+ d << "i" << index;
+ MOTH_END_INSTR(LoadImport)
+
MOTH_BEGIN_INSTR(LoadConst)
d << "C" << index;
MOTH_END_INSTR(LoadConst)
@@ -286,10 +295,6 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(StoreNameStrict)
MOTH_BEGIN_INSTR(LoadElement)
- d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]";
- MOTH_END_INSTR(LoadElement)
-
- MOTH_BEGIN_INSTR(LoadElementA)
d << dumpRegister(base, nFormals) << "[acc]";
MOTH_END_INSTR(LoadElement)
@@ -298,20 +303,12 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
- d << dumpRegister(base, nFormals) << "[" << name << "]";
- MOTH_END_INSTR(LoadProperty)
-
- MOTH_BEGIN_INSTR(LoadPropertyA)
d << "acc[" << name << "]";
- MOTH_END_INSTR(LoadElementA)
+ MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(GetLookup)
- d << dumpRegister(base, nFormals) << "(" << index << ")";
- MOTH_END_INSTR(GetLookup)
-
- MOTH_BEGIN_INSTR(GetLookupA)
d << "acc(" << index << ")";
- MOTH_END_INSTR(GetLookupA)
+ MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(StoreProperty)
d << dumpRegister(base, nFormals) << "[" << name<< "]";
@@ -321,6 +318,14 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << dumpRegister(base, nFormals) << "(" << index << ")";
MOTH_END_INSTR(SetLookup)
+ MOTH_BEGIN_INSTR(LoadSuperProperty)
+ d << dumpRegister(property, nFormals);
+ MOTH_END_INSTR(LoadSuperProperty)
+
+ MOTH_BEGIN_INSTR(StoreSuperProperty)
+ d << dumpRegister(property, nFormals);
+ MOTH_END_INSTR(StoreSuperProperty)
+
MOTH_BEGIN_INSTR(StoreScopeObjectProperty)
d << dumpRegister(base, nFormals) << "[" << propertyIndex << "]";
MOTH_END_INSTR(StoreScopeObjectProperty)
@@ -341,10 +346,24 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << dumpRegister(base, nFormals) << "[" << index << "]";
MOTH_END_INSTR(LoadIdObject)
+ MOTH_BEGIN_INSTR(Yield)
+ MOTH_END_INSTR(Yield)
+
+ MOTH_BEGIN_INSTR(YieldStar)
+ MOTH_END_INSTR(YieldStar)
+
+ MOTH_BEGIN_INSTR(Resume)
+ d << ABSOLUTE_OFFSET();
+ MOTH_END_INSTR(Resume)
+
MOTH_BEGIN_INSTR(CallValue)
d << dumpRegister(name, nFormals) << dumpArguments(argc, argv, nFormals);
MOTH_END_INSTR(CallValue)
+ MOTH_BEGIN_INSTR(CallWithReceiver)
+ d << dumpRegister(name, nFormals) << dumpRegister(thisObject, nFormals) << dumpArguments(argc, argv, nFormals);
+ MOTH_END_INSTR(CallWithReceiver)
+
MOTH_BEGIN_INSTR(CallProperty)
d << dumpRegister(base, nFormals) << "." << name << dumpArguments(argc, argv, nFormals);
MOTH_END_INSTR(CallProperty)
@@ -377,12 +396,35 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << dumpRegister(base, nFormals) << "." << name << dumpArguments(argc, argv, nFormals);
MOTH_END_INSTR(CallContextObjectProperty)
- MOTH_BEGIN_INSTR(SetExceptionHandler)
+ MOTH_BEGIN_INSTR(CallWithSpread)
+ d << "new" << dumpRegister(func, nFormals) << dumpRegister(thisObject, nFormals) << dumpArguments(argc, argv, nFormals);
+ MOTH_END_INSTR(CallWithSpread)
+
+ MOTH_BEGIN_INSTR(Construct)
+ d << "new" << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
+ MOTH_END_INSTR(Construct)
+
+ MOTH_BEGIN_INSTR(ConstructWithSpread)
+ d << "new" << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
+ MOTH_END_INSTR(ConstructWithSpread)
+
+ MOTH_BEGIN_INSTR(SetUnwindHandler)
if (offset)
d << ABSOLUTE_OFFSET();
else
d << "<null>";
- MOTH_END_INSTR(SetExceptionHandler)
+ MOTH_END_INSTR(SetUnwindHandler)
+
+ MOTH_BEGIN_INSTR(UnwindDispatch)
+ MOTH_END_INSTR(UnwindDispatch)
+
+ MOTH_BEGIN_INSTR(UnwindToLabel)
+ d << "(" << level << ") " << ABSOLUTE_OFFSET();
+ MOTH_END_INSTR(UnwindToLabel)
+
+ MOTH_BEGIN_INSTR(DeadTemporalZoneCheck)
+ d << name;
+ MOTH_END_INSTR(DeadTemporalZoneCheck)
MOTH_BEGIN_INSTR(ThrowException)
MOTH_END_INSTR(ThrowException)
@@ -397,30 +439,51 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(CreateCallContext)
MOTH_BEGIN_INSTR(PushCatchContext)
- d << dumpRegister(reg, nFormals) << ", " << name;
+ d << index << ", " << name;
MOTH_END_INSTR(PushCatchContext)
MOTH_BEGIN_INSTR(PushWithContext)
- d << dumpRegister(reg, nFormals);
MOTH_END_INSTR(PushWithContext)
+ MOTH_BEGIN_INSTR(PushBlockContext)
+ d << index;
+ MOTH_END_INSTR(PushBlockContext)
+
+ MOTH_BEGIN_INSTR(CloneBlockContext)
+ MOTH_END_INSTR(CloneBlockContext)
+
+ MOTH_BEGIN_INSTR(PushScriptContext)
+ d << index;
+ MOTH_END_INSTR(PushScriptContext)
+
+ MOTH_BEGIN_INSTR(PopScriptContext)
+ MOTH_END_INSTR(PopScriptContext)
+
MOTH_BEGIN_INSTR(PopContext)
- d << dumpRegister(reg, nFormals);
MOTH_END_INSTR(PopContext)
- MOTH_BEGIN_INSTR(ForeachIteratorObject)
- MOTH_END_INSTR(ForeachIteratorObject)
+ MOTH_BEGIN_INSTR(GetIterator)
+ d << iterator;
+ MOTH_END_INSTR(GetIterator)
+
+ MOTH_BEGIN_INSTR(IteratorNext)
+ d << dumpRegister(value, nFormals) << ", " << dumpRegister(done, nFormals);
+ MOTH_END_INSTR(IteratorNext)
+
+ MOTH_BEGIN_INSTR(IteratorNextForYieldStar)
+ d << dumpRegister(iterator, nFormals) << ", " << dumpRegister(object, nFormals);
+ MOTH_END_INSTR(IteratorNextForYieldStar)
- MOTH_BEGIN_INSTR(ForeachNextPropertyName)
- MOTH_END_INSTR(ForeachNextPropertyName)
+ MOTH_BEGIN_INSTR(IteratorClose)
+ d << dumpRegister(done, nFormals);
+ MOTH_END_INSTR(IteratorClose)
- MOTH_BEGIN_INSTR(DeleteMember)
- d << dumpRegister(base, nFormals) << "[" << member << "]";
- MOTH_END_INSTR(DeleteMember)
+ MOTH_BEGIN_INSTR(DestructureRestElement)
+ MOTH_END_INSTR(DestructureRestElement)
- MOTH_BEGIN_INSTR(DeleteSubscript)
+ MOTH_BEGIN_INSTR(DeleteProperty)
d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]";
- MOTH_END_INSTR(DeleteSubscript)
+ MOTH_END_INSTR(DeleteProperty)
MOTH_BEGIN_INSTR(DeleteName)
d << name;
@@ -442,24 +505,35 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(DefineArray)
MOTH_BEGIN_INSTR(DefineObjectLiteral)
- d << dumpRegister(args, nFormals)
- << ", " << internalClassId
- << ", " << arrayValueCount
- << ", " << arrayGetterSetterCountAndFlags;
+ d << internalClassId
+ << ", " << argc
+ << ", " << dumpRegister(args, nFormals);
MOTH_END_INSTR(DefineObjectLiteral)
+ MOTH_BEGIN_INSTR(CreateClass)
+ d << classIndex
+ << ", " << dumpRegister(heritage, nFormals)
+ << ", " << dumpRegister(computedNames, nFormals);
+ MOTH_END_INSTR(CreateClass)
+
MOTH_BEGIN_INSTR(CreateMappedArgumentsObject)
MOTH_END_INSTR(CreateMappedArgumentsObject)
MOTH_BEGIN_INSTR(CreateUnmappedArgumentsObject)
MOTH_END_INSTR(CreateUnmappedArgumentsObject)
+ MOTH_BEGIN_INSTR(CreateRestParameter)
+ d << argIndex;
+ MOTH_END_INSTR(CreateRestParameter)
+
MOTH_BEGIN_INSTR(ConvertThisToObject)
MOTH_END_INSTR(ConvertThisToObject)
- MOTH_BEGIN_INSTR(Construct)
- d << "new" << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
- MOTH_END_INSTR(Construct)
+ MOTH_BEGIN_INSTR(LoadSuperConstructor)
+ MOTH_END_INSTR(LoadSuperConstructor)
+
+ MOTH_BEGIN_INSTR(ToObject)
+ MOTH_END_INSTR(ToObject)
MOTH_BEGIN_INSTR(Jump)
d << ABSOLUTE_OFFSET();
@@ -473,6 +547,14 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << ABSOLUTE_OFFSET();
MOTH_END_INSTR(JumpFalse)
+ MOTH_BEGIN_INSTR(JumpNotUndefined)
+ d << ABSOLUTE_OFFSET();
+ MOTH_END_INSTR(JumpNotUndefined)
+
+ MOTH_BEGIN_INSTR(JumpNoException)
+ d << ABSOLUTE_OFFSET();
+ MOTH_END_INSTR(JumpNoException)
+
MOTH_BEGIN_INSTR(CmpEqNull)
MOTH_END_INSTR(CmpEqNull)
@@ -519,14 +601,6 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << dumpRegister(lhs, nFormals);
MOTH_END_INSTR(CmpStrictNotEqual)
- MOTH_BEGIN_INSTR(JumpStrictEqualStackSlotInt)
- d << dumpRegister(lhs, nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
- MOTH_END_INSTR(JumpStrictEqualStackSlotInt)
-
- MOTH_BEGIN_INSTR(JumpStrictNotEqualStackSlotInt)
- d << dumpRegister(lhs, nFormals) << ", " << rhs << " " << ABSOLUTE_OFFSET();
- MOTH_END_INSTR(JumpStrictNotEqualStackSlotInt)
-
MOTH_BEGIN_INSTR(UNot)
MOTH_END_INSTR(UNot)
@@ -597,6 +671,10 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
d << "acc, " << rhs;
MOTH_END_INSTR(ShlConst)
+ MOTH_BEGIN_INSTR(Exp)
+ d << dumpRegister(lhs, nFormals) << ", acc";
+ MOTH_END_INSTR(Exp)
+
MOTH_BEGIN_INSTR(Mul)
d << dumpRegister(lhs, nFormals) << ", acc";
MOTH_END_INSTR(Mul)
@@ -627,6 +705,13 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_BEGIN_INSTR(Debug)
MOTH_END_INSTR(Debug)
+ MOTH_BEGIN_INSTR(InitializeBlockDeadTemporalZone)
+ d << dumpRegister(firstReg, nFormals) << ", " << count;
+ MOTH_END_INSTR(InitializeBlockDeadTemporalZone)
+
+ MOTH_BEGIN_INSTR(ThrowOnNullOrUndefined)
+ MOTH_END_INSTR(ThrowOnNullOrUndefined)
+
MOTH_BEGIN_INSTR(LoadQmlContext)
d << dumpRegister(result, nFormals);
MOTH_END_INSTR(LoadQmlContext)
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index df9182e924..f9bd3cdd4a 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -53,6 +53,8 @@
#include <private/qv4global_p.h>
#include <private/qv4value_p.h>
#include <private/qv4runtime_p.h>
+#include <private/qv4compileddata_p.h> // for CompiledData::CodeOffsetToLine used by the dumper
+#include <qendian.h>
QT_BEGIN_NAMESPACE
@@ -60,6 +62,7 @@ QT_BEGIN_NAMESPACE
op##_INSTRUCTION(name, nargs, __VA_ARGS__)
/* for all jump instructions, the offset has to come last, to simplify the job of the bytecode generator */
+#define INSTR_Nop(op) INSTRUCTION(op, Nop, 0)
#define INSTR_Ret(op) INSTRUCTION(op, Ret, 0)
#define INSTR_Debug(op) INSTRUCTION(op, Debug, 0)
#define INSTR_LoadConst(op) INSTRUCTION(op, LoadConst, 1, index)
@@ -73,6 +76,7 @@ QT_BEGIN_NAMESPACE
#define INSTR_LoadReg(op) INSTRUCTION(op, LoadReg, 1, reg)
#define INSTR_StoreReg(op) INSTRUCTION(op, StoreReg, 1, reg)
#define INSTR_MoveReg(op) INSTRUCTION(op, MoveReg, 2, srcReg, destReg)
+#define INSTR_LoadImport(op) INSTRUCTION(op, LoadImport, 1, index)
#define INSTR_LoadLocal(op) INSTRUCTION(op, LoadLocal, 1, index)
#define INSTR_StoreLocal(op) INSTRUCTION(op, StoreLocal, 1, index)
#define INSTR_LoadScopedLocal(op) INSTRUCTION(op, LoadScopedLocal, 2, scope, index)
@@ -84,21 +88,25 @@ QT_BEGIN_NAMESPACE
#define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 1, index)
#define INSTR_StoreNameSloppy(op) INSTRUCTION(op, StoreNameSloppy, 1, name)
#define INSTR_StoreNameStrict(op) INSTRUCTION(op, StoreNameStrict, 1, name)
-#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 2, name, base)
-#define INSTR_LoadPropertyA(op) INSTRUCTION(op, LoadPropertyA, 1, name)
-#define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 2, index, base)
-#define INSTR_GetLookupA(op) INSTRUCTION(op, GetLookupA, 1, index)
+#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 1, name)
+#define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 1, index)
#define INSTR_LoadScopeObjectProperty(op) INSTRUCTION(op, LoadScopeObjectProperty, 3, propertyIndex, base, captureRequired)
#define INSTR_LoadContextObjectProperty(op) INSTRUCTION(op, LoadContextObjectProperty, 3, propertyIndex, base, captureRequired)
#define INSTR_LoadIdObject(op) INSTRUCTION(op, LoadIdObject, 2, index, base)
+#define INSTR_Yield(op) INSTRUCTION(op, Yield, 0)
+#define INSTR_YieldStar(op) INSTRUCTION(op, YieldStar, 0)
+#define INSTR_Resume(op) INSTRUCTION(op, Resume, 1, offset)
+#define INSTR_IteratorNextForYieldStar(op) INSTRUCTION(op, IteratorNextForYieldStar, 2, iterator, object)
#define INSTR_StoreProperty(op) INSTRUCTION(op, StoreProperty, 2, name, base)
#define INSTR_SetLookup(op) INSTRUCTION(op, SetLookup, 2, index, base)
+#define INSTR_LoadSuperProperty(op) INSTRUCTION(op, LoadSuperProperty, 1, property)
+#define INSTR_StoreSuperProperty(op) INSTRUCTION(op, StoreSuperProperty, 1, property)
#define INSTR_StoreScopeObjectProperty(op) INSTRUCTION(op, StoreScopeObjectProperty, 2, base, propertyIndex)
#define INSTR_StoreContextObjectProperty(op) INSTRUCTION(op, StoreContextObjectProperty, 2, base, propertyIndex)
-#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 2, base, index)
-#define INSTR_LoadElementA(op) INSTRUCTION(op, LoadElementA, 1, base)
+#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 1, base)
#define INSTR_StoreElement(op) INSTRUCTION(op, StoreElement, 2, base, index)
#define INSTR_CallValue(op) INSTRUCTION(op, CallValue, 3, name, argc, argv)
+#define INSTR_CallWithReceiver(op) INSTRUCTION(op, CallWithReceiver, 4, name, thisObject, argc, argv)
#define INSTR_CallProperty(op) INSTRUCTION(op, CallProperty, 4, name, base, argc, argv)
#define INSTR_CallPropertyLookup(op) INSTRUCTION(op, CallPropertyLookup, 4, lookupIndex, base, argc, argv)
#define INSTR_CallElement(op) INSTRUCTION(op, CallElement, 4, base, index, argc, argv)
@@ -107,32 +115,47 @@ QT_BEGIN_NAMESPACE
#define INSTR_CallGlobalLookup(op) INSTRUCTION(op, CallGlobalLookup, 3, index, argc, argv)
#define INSTR_CallScopeObjectProperty(op) INSTRUCTION(op, CallScopeObjectProperty, 4, name, base, argc, argv)
#define INSTR_CallContextObjectProperty(op) INSTRUCTION(op, CallContextObjectProperty, 4, name, base, argc, argv)
-#define INSTR_SetExceptionHandler(op) INSTRUCTION(op, SetExceptionHandler, 1, offset)
+#define INSTR_CallWithSpread(op) INSTRUCTION(op, CallWithSpread, 4, func, thisObject, argc, argv)
+#define INSTR_Construct(op) INSTRUCTION(op, Construct, 3, func, argc, argv)
+#define INSTR_ConstructWithSpread(op) INSTRUCTION(op, ConstructWithSpread, 3, func, argc, argv)
+#define INSTR_SetUnwindHandler(op) INSTRUCTION(op, SetUnwindHandler, 1, offset)
+#define INSTR_UnwindDispatch(op) INSTRUCTION(op, UnwindDispatch, 0)
+#define INSTR_UnwindToLabel(op) INSTRUCTION(op, UnwindToLabel, 2, level, offset)
+#define INSTR_DeadTemporalZoneCheck(op) INSTRUCTION(op, DeadTemporalZoneCheck, 1, name)
#define INSTR_ThrowException(op) INSTRUCTION(op, ThrowException, 0)
#define INSTR_GetException(op) INSTRUCTION(op, GetException, 0)
#define INSTR_SetException(op) INSTRUCTION(op, SetException, 0)
#define INSTR_CreateCallContext(op) INSTRUCTION(op, CreateCallContext, 0)
-#define INSTR_PushCatchContext(op) INSTRUCTION(op, PushCatchContext, 2, name, reg)
-#define INSTR_PushWithContext(op) INSTRUCTION(op, PushWithContext, 1, reg)
-#define INSTR_PopContext(op) INSTRUCTION(op, PopContext, 1, reg)
-#define INSTR_ForeachIteratorObject(op) INSTRUCTION(op, ForeachIteratorObject, 0)
-#define INSTR_ForeachNextPropertyName(op) INSTRUCTION(op, ForeachNextPropertyName, 0)
-#define INSTR_DeleteMember(op) INSTRUCTION(op, DeleteMember, 2, member, base)
-#define INSTR_DeleteSubscript(op) INSTRUCTION(op, DeleteSubscript, 2, base, index)
+#define INSTR_PushCatchContext(op) INSTRUCTION(op, PushCatchContext, 2, index, name)
+#define INSTR_PushWithContext(op) INSTRUCTION(op, PushWithContext, 0)
+#define INSTR_PushBlockContext(op) INSTRUCTION(op, PushBlockContext, 1, index)
+#define INSTR_CloneBlockContext(op) INSTRUCTION(op, CloneBlockContext, 0)
+#define INSTR_PushScriptContext(op) INSTRUCTION(op, PushScriptContext, 1, index)
+#define INSTR_PopScriptContext(op) INSTRUCTION(op, PopScriptContext, 0)
+#define INSTR_PopContext(op) INSTRUCTION(op, PopContext, 0)
+#define INSTR_GetIterator(op) INSTRUCTION(op, GetIterator, 1, iterator)
+#define INSTR_IteratorNext(op) INSTRUCTION(op, IteratorNext, 2, value, done)
+#define INSTR_IteratorClose(op) INSTRUCTION(op, IteratorClose, 1, done)
+#define INSTR_DestructureRestElement(op) INSTRUCTION(op, DestructureRestElement, 0)
+#define INSTR_DeleteProperty(op) INSTRUCTION(op, DeleteProperty, 2, base, index)
#define INSTR_DeleteName(op) INSTRUCTION(op, DeleteName, 1, name)
#define INSTR_TypeofName(op) INSTRUCTION(op, TypeofName, 1, name)
#define INSTR_TypeofValue(op) INSTRUCTION(op, TypeofValue, 0)
#define INSTR_DeclareVar(op) INSTRUCTION(op, DeclareVar, 2, varName, isDeletable)
#define INSTR_DefineArray(op) INSTRUCTION(op, DefineArray, 2, argc, args)
-// arrayGetterSetterCountAndFlags contains 30 bits for count, 1 bit for needsSparseArray boolean
-#define INSTR_DefineObjectLiteral(op) INSTRUCTION(op, DefineObjectLiteral, 4, internalClassId, arrayValueCount, arrayGetterSetterCountAndFlags, args)
+#define INSTR_DefineObjectLiteral(op) INSTRUCTION(op, DefineObjectLiteral, 3, internalClassId, argc, args)
+#define INSTR_CreateClass(op) INSTRUCTION(op, CreateClass, 3, classIndex, heritage, computedNames)
#define INSTR_CreateMappedArgumentsObject(op) INSTRUCTION(op, CreateMappedArgumentsObject, 0)
#define INSTR_CreateUnmappedArgumentsObject(op) INSTRUCTION(op, CreateUnmappedArgumentsObject, 0)
+#define INSTR_CreateRestParameter(op) INSTRUCTION(op, CreateRestParameter, 1, argIndex)
#define INSTR_ConvertThisToObject(op) INSTRUCTION(op, ConvertThisToObject, 0)
-#define INSTR_Construct(op) INSTRUCTION(op, Construct, 3, func, argc, argv)
+#define INSTR_LoadSuperConstructor(op) INSTRUCTION(op, LoadSuperConstructor, 0)
+#define INSTR_ToObject(op) INSTRUCTION(op, ToObject, 0)
#define INSTR_Jump(op) INSTRUCTION(op, Jump, 1, offset)
#define INSTR_JumpTrue(op) INSTRUCTION(op, JumpTrue, 1, offset)
#define INSTR_JumpFalse(op) INSTRUCTION(op, JumpFalse, 1, offset)
+#define INSTR_JumpNotUndefined(op) INSTRUCTION(op, JumpNotUndefined, 1, offset)
+#define INSTR_JumpNoException(op) INSTRUCTION(op, JumpNoException, 1, offset)
#define INSTR_CmpEqNull(op) INSTRUCTION(op, CmpEqNull, 0)
#define INSTR_CmpNeNull(op) INSTRUCTION(op, CmpNeNull, 0)
#define INSTR_CmpEqInt(op) INSTRUCTION(op, CmpEqInt, 1, lhs)
@@ -147,8 +170,6 @@ QT_BEGIN_NAMESPACE
#define INSTR_CmpStrictNotEqual(op) INSTRUCTION(op, CmpStrictNotEqual, 1, lhs)
#define INSTR_CmpIn(op) INSTRUCTION(op, CmpIn, 1, lhs)
#define INSTR_CmpInstanceOf(op) INSTRUCTION(op, CmpInstanceOf, 1, lhs)
-#define INSTR_JumpStrictEqualStackSlotInt(op) INSTRUCTION(op, JumpStrictEqualStackSlotInt, 3, lhs, rhs, offset)
-#define INSTR_JumpStrictNotEqualStackSlotInt(op) INSTRUCTION(op, JumpStrictNotEqualStackSlotInt, 3, lhs, rhs, offset)
#define INSTR_UNot(op) INSTRUCTION(op, UNot, 0)
#define INSTR_UPlus(op) INSTRUCTION(op, UPlus, 0)
#define INSTR_UMinus(op) INSTRUCTION(op, UMinus, 0)
@@ -168,17 +189,22 @@ QT_BEGIN_NAMESPACE
#define INSTR_UShrConst(op) INSTRUCTION(op, UShrConst, 1, rhs)
#define INSTR_ShrConst(op) INSTRUCTION(op, ShrConst, 1, rhs)
#define INSTR_ShlConst(op) INSTRUCTION(op, ShlConst, 1, rhs)
+#define INSTR_Exp(op) INSTRUCTION(op, Exp, 1, lhs)
#define INSTR_Mul(op) INSTRUCTION(op, Mul, 1, lhs)
#define INSTR_Div(op) INSTRUCTION(op, Div, 1, lhs)
#define INSTR_Mod(op) INSTRUCTION(op, Mod, 1, lhs)
#define INSTR_Sub(op) INSTRUCTION(op, Sub, 1, lhs)
#define INSTR_LoadQmlContext(op) INSTRUCTION(op, LoadQmlContext, 1, result)
#define INSTR_LoadQmlImportedScripts(op) INSTRUCTION(op, LoadQmlImportedScripts, 1, result)
+#define INSTR_InitializeBlockDeadTemporalZone(op) INSTRUCTION(op, InitializeBlockDeadTemporalZone, 2, firstReg, count)
+#define INSTR_ThrowOnNullOrUndefined(op) INSTRUCTION(op, ThrowOnNullOrUndefined, 0)
+#define FOR_EACH_MOTH_INSTR_ALL(F) \
+ F(Nop) \
+ FOR_EACH_MOTH_INSTR(F)
#define FOR_EACH_MOTH_INSTR(F) \
F(Ret) \
- F(Debug) \
F(LoadConst) \
F(LoadZero) \
F(LoadTrue) \
@@ -186,15 +212,16 @@ QT_BEGIN_NAMESPACE
F(LoadNull) \
F(LoadUndefined) \
F(LoadInt) \
+ F(LoadRuntimeString) \
F(MoveConst) \
F(LoadReg) \
F(StoreReg) \
F(MoveReg) \
+ F(LoadImport) \
F(LoadLocal) \
F(StoreLocal) \
F(LoadScopedLocal) \
F(StoreScopedLocal) \
- F(LoadRuntimeString) \
F(MoveRegExp) \
F(LoadClosure) \
F(LoadName) \
@@ -202,53 +229,25 @@ QT_BEGIN_NAMESPACE
F(StoreNameSloppy) \
F(StoreNameStrict) \
F(LoadElement) \
- F(LoadElementA) \
F(StoreElement) \
F(LoadProperty) \
- F(LoadPropertyA) \
F(GetLookup) \
- F(GetLookupA) \
F(StoreProperty) \
F(SetLookup) \
+ F(LoadSuperProperty) \
+ F(StoreSuperProperty) \
F(StoreScopeObjectProperty) \
F(StoreContextObjectProperty) \
F(LoadScopeObjectProperty) \
F(LoadContextObjectProperty) \
F(LoadIdObject) \
- F(CallValue) \
- F(CallProperty) \
- F(CallPropertyLookup) \
- F(CallElement) \
- F(CallName) \
- F(CallPossiblyDirectEval) \
- F(CallGlobalLookup) \
- F(CallScopeObjectProperty) \
- F(CallContextObjectProperty) \
- F(SetExceptionHandler) \
- F(ThrowException) \
- F(GetException) \
- F(SetException) \
- F(CreateCallContext) \
- F(PushCatchContext) \
- F(PushWithContext) \
- F(PopContext) \
- F(ForeachIteratorObject) \
- F(ForeachNextPropertyName) \
- F(DeleteMember) \
- F(DeleteSubscript) \
- F(DeleteName) \
- F(TypeofName) \
- F(TypeofValue) \
- F(DeclareVar) \
- F(DefineArray) \
- F(DefineObjectLiteral) \
- F(CreateMappedArgumentsObject) \
- F(CreateUnmappedArgumentsObject) \
F(ConvertThisToObject) \
- F(Construct) \
+ F(ToObject) \
F(Jump) \
F(JumpTrue) \
F(JumpFalse) \
+ F(JumpNoException) \
+ F(JumpNotUndefined) \
F(CmpEqNull) \
F(CmpNeNull) \
F(CmpEqInt) \
@@ -263,8 +262,6 @@ QT_BEGIN_NAMESPACE
F(CmpStrictNotEqual) \
F(CmpIn) \
F(CmpInstanceOf) \
- F(JumpStrictEqualStackSlotInt) \
- F(JumpStrictNotEqualStackSlotInt) \
F(UNot) \
F(UPlus) \
F(UMinus) \
@@ -284,13 +281,66 @@ QT_BEGIN_NAMESPACE
F(UShrConst) \
F(ShrConst) \
F(ShlConst) \
+ F(Exp) \
F(Mul) \
F(Div) \
F(Mod) \
F(Sub) \
+ F(CallValue) \
+ F(CallWithReceiver) \
+ F(CallProperty) \
+ F(CallPropertyLookup) \
+ F(CallElement) \
+ F(CallName) \
+ F(CallPossiblyDirectEval) \
+ F(CallGlobalLookup) \
+ F(CallScopeObjectProperty) \
+ F(CallContextObjectProperty) \
+ F(CallWithSpread) \
+ F(Construct) \
+ F(ConstructWithSpread) \
+ F(SetUnwindHandler) \
+ F(UnwindDispatch) \
+ F(UnwindToLabel) \
+ F(DeadTemporalZoneCheck) \
+ F(ThrowException) \
+ F(GetException) \
+ F(SetException) \
+ F(CreateCallContext) \
+ F(PushCatchContext) \
+ F(PushWithContext) \
+ F(PushBlockContext) \
+ F(CloneBlockContext) \
+ F(PopContext) \
+ F(GetIterator) \
+ F(IteratorNext) \
+ F(IteratorClose) \
+ F(DestructureRestElement) \
+ F(DeleteProperty) \
+ F(DeleteName) \
+ F(TypeofName) \
+ F(TypeofValue) \
+ F(DeclareVar) \
+ F(DefineArray) \
+ F(DefineObjectLiteral) \
+ F(CreateMappedArgumentsObject) \
+ F(CreateUnmappedArgumentsObject) \
+ F(CreateRestParameter) \
F(LoadQmlContext) \
- F(LoadQmlImportedScripts)
-#define MOTH_NUM_INSTRUCTIONS() (static_cast<int>(Moth::Instr::Type::LoadQmlImportedScripts) + 1)
+ F(LoadQmlImportedScripts) \
+ F(Yield) \
+ F(YieldStar) \
+ F(Resume) \
+ F(IteratorNextForYieldStar) \
+ F(CreateClass) \
+ F(LoadSuperConstructor) \
+ F(PushScriptContext) \
+ F(PopScriptContext) \
+ F(InitializeBlockDeadTemporalZone) \
+ F(ThrowOnNullOrUndefined) \
+ F(Debug) \
+
+#define MOTH_NUM_INSTRUCTIONS() (static_cast<int>(Moth::Instr::Type::Debug_Wide) + 1)
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
// icc before version 1200 doesn't support computed goto, and at least up to version 18.0.0 the
@@ -301,7 +351,7 @@ QT_BEGIN_NAMESPACE
#define MOTH_INSTR_ALIGN_MASK (Q_ALIGNOF(QV4::Moth::Instr) - 1)
-#define MOTH_INSTR_ENUM(I) I,
+#define MOTH_INSTR_ENUM(I) I, I##_Wide,
#define MOTH_INSTR_SIZE(I) (sizeof(QV4::Moth::Instr::instr_##I))
#define MOTH_EXPAND_FOR_MSVC(x) x
@@ -344,7 +394,7 @@ QT_BEGIN_NAMESPACE
#define MOTH_COLLECT_NARGS(instr) \
INSTR_##instr(MOTH_COLLECT_ARG_COUNT)
#define MOTH_COLLECT_ARG_COUNT_INSTRUCTION(name, nargs, ...) \
- nargs,
+ nargs, nargs,
#define MOTH_DECODE_ARG(arg, type, nargs, offset) \
arg = qFromLittleEndian<type>(qFromUnaligned<type>(reinterpret_cast<const type *>(code) - nargs + offset));
@@ -397,38 +447,53 @@ QT_BEGIN_NAMESPACE
#ifdef MOTH_COMPUTED_GOTO
/* collect jump labels */
#define COLLECT_LABELS(instr) \
- INSTR_##instr(GET_LABEL)
+ INSTR_##instr(GET_LABEL) \
+ INSTR_##instr(GET_LABEL_WIDE)
#define GET_LABEL_INSTRUCTION(name, ...) \
&&op_byte_##name,
-#define COLLECT_LABELS_WIDE(instr) \
- INSTR_##instr(GET_LABEL_WIDE)
#define GET_LABEL_WIDE_INSTRUCTION(name, ...) \
&&op_int_##name,
#define MOTH_JUMP_TABLE \
static const void *jumpTable[] = { \
- FOR_EACH_MOTH_INSTR(COLLECT_LABELS) \
- FOR_EACH_MOTH_INSTR(COLLECT_LABELS_WIDE) \
+ FOR_EACH_MOTH_INSTR_ALL(COLLECT_LABELS) \
};
-#define MOTH_DISPATCH() \
+#define MOTH_DISPATCH_SINGLE() \
goto *jumpTable[*reinterpret_cast<const uchar *>(code)];
+
+#define MOTH_DISPATCH() \
+ MOTH_DISPATCH_SINGLE() \
+ op_byte_Nop: \
+ ++code; \
+ MOTH_DISPATCH_SINGLE() \
+ op_int_Nop: /* wide prefix */ \
+ ++code; \
+ goto *jumpTable[0x100 | *reinterpret_cast<const uchar *>(code)];
#else
#define MOTH_JUMP_TABLE
#define MOTH_INSTR_CASE_AND_JUMP(instr) \
- INSTR_##instr(GET_CASE_AND_JUMP)
-#define GET_CASE_AND_JUMP_INSTRUCTION(name, ...) \
- case static_cast<uchar>(Instr::Type::name): goto op_byte_##name;
-#define MOTH_INSTR_CASE_AND_JUMP_WIDE(instr) \
+ INSTR_##instr(GET_CASE_AND_JUMP) \
INSTR_##instr(GET_CASE_AND_JUMP_WIDE)
+#define GET_CASE_AND_JUMP_INSTRUCTION(name, ...) \
+ case Instr::Type::name: goto op_byte_##name;
#define GET_CASE_AND_JUMP_WIDE_INSTRUCTION(name, ...) \
- case (static_cast<uchar>(Instr::Type::name) + MOTH_NUM_INSTRUCTIONS()): goto op_int_##name;
+ case Instr::Type::name##_Wide: goto op_int_##name;
#define MOTH_DISPATCH() \
- switch (static_cast<uchar>(*code)) { \
+ Instr::Type type = Instr::Type(static_cast<uchar>(*code)); \
+ dispatch: \
+ switch (type) { \
+ case Instr::Type::Nop: \
+ ++code; \
+ type = Instr::Type(static_cast<uchar>(*code)); \
+ goto dispatch; \
+ case Instr::Type::Nop_Wide: /* wide prefix */ \
+ ++code; \
+ type = Instr::Type(0x100 | static_cast<uchar>(*code)); \
+ goto dispatch; \
FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP) \
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_CASE_AND_JUMP_WIDE) \
}
#endif
@@ -471,12 +536,29 @@ inline void dumpBytecode(const QByteArray &bytecode, int nLocals, int nFormals,
union Instr
{
enum class Type {
- FOR_EACH_MOTH_INSTR(MOTH_INSTR_ENUM)
+ FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_ENUM)
};
- FOR_EACH_MOTH_INSTR(MOTH_EMIT_STRUCTS)
+ static Type wideInstructionType(Type t) { return Type(int(t) | 1); }
+ static Type narrowInstructionType(Type t) { return Type(int(t) & ~1); }
+ static bool isWide(Type t) { return int(t) & 1; }
+ static bool isNarrow(Type t) { return !(int(t) & 1); }
+ static int encodedLength(Type t) { return int(t) >= 256 ? 2 : 1; }
+
+ static Type unpack(const uchar *c) { if (c[0] == 0x1) return Type(0x100 + c[1]); return Type(c[0]); }
+ static uchar *pack(uchar *c, Type t) {
+ if (uint(t) >= 256) {
+ c[0] = 0x1;
+ c[1] = uint(t) &0xff;
+ return c + 2;
+ }
+ c[0] = uchar(uint(t));
+ return c + 1;
+ }
+
+ FOR_EACH_MOTH_INSTR_ALL(MOTH_EMIT_STRUCTS)
- FOR_EACH_MOTH_INSTR(MOTH_EMIT_INSTR_MEMBERS)
+ FOR_EACH_MOTH_INSTR_ALL(MOTH_EMIT_INSTR_MEMBERS)
int argumentsAsInts[4];
};
@@ -487,8 +569,6 @@ struct InstrInfo
static int size(Instr::Type type);
};
-Q_STATIC_ASSERT(MOTH_NUM_INSTRUCTIONS() < 128);
-
template<int N>
struct InstrMeta {
};
@@ -506,7 +586,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
reinterpret_cast<const char *>(&v), \
Size); } \
};
-FOR_EACH_MOTH_INSTR(MOTH_INSTR_META_TEMPLATE);
+FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_META_TEMPLATE);
#undef MOTH_INSTR_META_TEMPLATE
QT_WARNING_POP
@@ -517,7 +597,7 @@ class InstrData : public InstrMeta<InstrType>::DataType
struct Instruction {
#define MOTH_INSTR_DATA_TYPEDEF(I) typedef InstrData<int(Instr::Type::I)> I;
-FOR_EACH_MOTH_INSTR(MOTH_INSTR_DATA_TYPEDEF)
+FOR_EACH_MOTH_INSTR_ALL(MOTH_INSTR_DATA_TYPEDEF)
#undef MOTH_INSTR_DATA_TYPEDEF
private:
Instruction();
diff --git a/src/qml/compiler/qv4jssimplifier.cpp b/src/qml/compiler/qv4jssimplifier.cpp
deleted file mode 100644
index 7d09218fe6..0000000000
--- a/src/qml/compiler/qv4jssimplifier.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4jssimplifier_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QQmlJavaScriptBindingExpressionSimplificationPass::QQmlJavaScriptBindingExpressionSimplificationPass(const QVector<QmlIR::Object*> &qmlObjects, QV4::IR::Module *jsModule, QV4::Compiler::JSUnitGenerator *unitGenerator)
- : qmlObjects(qmlObjects)
- , jsModule(jsModule)
- , unitGenerator(unitGenerator)
-{
-
-}
-
-void QQmlJavaScriptBindingExpressionSimplificationPass::reduceTranslationBindings()
-{
- for (int i = 0; i < qmlObjects.count(); ++i)
- reduceTranslationBindings(i);
- if (!irFunctionsToRemove.isEmpty()) {
- QQmlIRFunctionCleanser cleanser(jsModule, qmlObjects, irFunctionsToRemove);
- cleanser.clean();
- }
-}
-
-void QQmlJavaScriptBindingExpressionSimplificationPass::reduceTranslationBindings(int objectIndex)
-{
- const QmlIR::Object *obj = qmlObjects.at(objectIndex);
-
- for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
- if (binding->type != QV4::CompiledData::Binding::Type_Script)
- continue;
-
- const int irFunctionIndex = obj->runtimeFunctionIndices.at(binding->value.compiledScriptIndex);
- QV4::IR::Function *irFunction = jsModule->functions.at(irFunctionIndex);
- if (simplifyBinding(irFunction, binding)) {
- irFunctionsToRemove.append(irFunctionIndex);
- jsModule->functions[irFunctionIndex] = 0;
- delete irFunction;
- }
- }
-}
-
-void QQmlJavaScriptBindingExpressionSimplificationPass::visitMove(QV4::IR::Move *move)
-{
- QV4::IR::Temp *target = move->target->asTemp();
- if (!target || target->kind != QV4::IR::Temp::VirtualRegister) {
- discard();
- return;
- }
-
- if (QV4::IR::Call *call = move->source->asCall()) {
- if (QV4::IR::Name *n = call->base->asName()) {
- if (n->builtin == QV4::IR::Name::builtin_invalid) {
- visitFunctionCall(n->id, call->args, target);
- return;
- }
- }
- discard();
- return;
- }
-
- if (QV4::IR::Name *n = move->source->asName()) {
- if (n->builtin == QV4::IR::Name::builtin_qml_context
- || n->builtin == QV4::IR::Name::builtin_qml_imported_scripts_object) {
- // these are free of side-effects
- return;
- }
- discard();
- return;
- }
-
- if (!move->source->asTemp() && !move->source->asString() && !move->source->asConst()) {
- discard();
- return;
- }
-
- _temps[target->index] = move->source;
-}
-
-void QQmlJavaScriptBindingExpressionSimplificationPass::visitFunctionCall(const QString *name, QV4::IR::ExprList *args, QV4::IR::Temp *target)
-{
- // more than one function call?
- if (_nameOfFunctionCalled) {
- discard();
- return;
- }
-
- _nameOfFunctionCalled = name;
-
- _functionParameters.clear();
- while (args) {
- int slot;
- if (QV4::IR::Temp *param = args->expr->asTemp()) {
- if (param->kind != QV4::IR::Temp::VirtualRegister) {
- discard();
- return;
- }
- slot = param->index;
- _functionParameters.append(slot);
- } else if (QV4::IR::Const *param = args->expr->asConst()) {
- slot = --_synthesizedConsts;
- Q_ASSERT(!_temps.contains(slot));
- _temps[slot] = param;
- _functionParameters.append(slot);
- }
- args = args->next;
- }
-
- _functionCallReturnValue = target->index;
-}
-
-void QQmlJavaScriptBindingExpressionSimplificationPass::visitRet(QV4::IR::Ret *ret)
-{
- // nothing initialized earlier?
- if (_returnValueOfBindingExpression != -1) {
- discard();
- return;
- }
- QV4::IR::Temp *target = ret->expr->asTemp();
- if (!target || target->kind != QV4::IR::Temp::VirtualRegister) {
- discard();
- return;
- }
- _returnValueOfBindingExpression = target->index;
-}
-
-bool QQmlJavaScriptBindingExpressionSimplificationPass::simplifyBinding(QV4::IR::Function *function, QmlIR::Binding *binding)
-{
- _canSimplify = true;
- _nameOfFunctionCalled = 0;
- _functionParameters.clear();
- _functionCallReturnValue = -1;
- _temps.clear();
- _returnValueOfBindingExpression = -1;
- _synthesizedConsts = 0;
-
- // It would seem unlikely that function with some many basic blocks (after optimization)
- // consists merely of a qsTr call or a constant value return ;-)
- if (function->basicBlockCount() > 10)
- return false;
-
- for (QV4::IR::BasicBlock *bb : function->basicBlocks()) {
- for (QV4::IR::Stmt *s : bb->statements()) {
- visit(s);
- if (!_canSimplify)
- return false;
- }
- }
-
- if (_returnValueOfBindingExpression == -1)
- return false;
-
- if (_nameOfFunctionCalled) {
- if (_functionCallReturnValue != _returnValueOfBindingExpression)
- return false;
- return detectTranslationCallAndConvertBinding(binding);
- }
-
- return false;
-}
-
-bool QQmlJavaScriptBindingExpressionSimplificationPass::detectTranslationCallAndConvertBinding(QmlIR::Binding *binding)
-{
- if (*_nameOfFunctionCalled == QLatin1String("qsTr")) {
- QString translation;
- QV4::CompiledData::TranslationData translationData;
- translationData.number = -1;
- translationData.commentIndex = 0; // empty string
-
- QVector<int>::ConstIterator param = _functionParameters.constBegin();
- QVector<int>::ConstIterator end = _functionParameters.constEnd();
- if (param == end)
- return false;
-
- QV4::IR::String *stringParam = _temps[*param]->asString();
- if (!stringParam)
- return false;
-
- translation = *stringParam->value;
-
- ++param;
- if (param != end) {
- stringParam = _temps[*param]->asString();
- if (!stringParam)
- return false;
- translationData.commentIndex = unitGenerator->registerString(*stringParam->value);
- ++param;
-
- if (param != end) {
- QV4::IR::Const *constParam = _temps[*param]->asConst();
- if (!constParam || constParam->type != QV4::IR::SInt32Type)
- return false;
-
- translationData.number = int(constParam->value);
- ++param;
- }
- }
-
- if (param != end)
- return false;
-
- binding->type = QV4::CompiledData::Binding::Type_Translation;
- binding->stringIndex = unitGenerator->registerString(translation);
- binding->value.translationData = translationData;
- return true;
- } else if (*_nameOfFunctionCalled == QLatin1String("qsTrId")) {
- QString id;
- QV4::CompiledData::TranslationData translationData;
- translationData.number = -1;
- translationData.commentIndex = 0; // empty string, but unused
-
- QVector<int>::ConstIterator param = _functionParameters.constBegin();
- QVector<int>::ConstIterator end = _functionParameters.constEnd();
- if (param == end)
- return false;
-
- QV4::IR::String *stringParam = _temps[*param]->asString();
- if (!stringParam)
- return false;
-
- id = *stringParam->value;
-
- ++param;
- if (param != end) {
- QV4::IR::Const *constParam = _temps[*param]->asConst();
- if (!constParam || constParam->type != QV4::IR::SInt32Type)
- return false;
-
- translationData.number = int(constParam->value);
- ++param;
- }
-
- if (param != end)
- return false;
-
- binding->type = QV4::CompiledData::Binding::Type_TranslationById;
- binding->stringIndex = unitGenerator->registerString(id);
- binding->value.translationData = translationData;
- return true;
- } else if (*_nameOfFunctionCalled == QLatin1String("QT_TR_NOOP") || *_nameOfFunctionCalled == QLatin1String("QT_TRID_NOOP")) {
- QVector<int>::ConstIterator param = _functionParameters.constBegin();
- QVector<int>::ConstIterator end = _functionParameters.constEnd();
- if (param == end)
- return false;
-
- QV4::IR::String *stringParam = _temps[*param]->asString();
- if (!stringParam)
- return false;
-
- ++param;
- if (param != end)
- return false;
-
- binding->type = QV4::CompiledData::Binding::Type_String;
- binding->stringIndex = unitGenerator->registerString(*stringParam->value);
- return true;
- } else if (*_nameOfFunctionCalled == QLatin1String("QT_TRANSLATE_NOOP")) {
- QVector<int>::ConstIterator param = _functionParameters.constBegin();
- QVector<int>::ConstIterator end = _functionParameters.constEnd();
- if (param == end)
- return false;
-
- ++param;
- if (param == end)
- return false;
-
- QV4::IR::String *stringParam = _temps[*param]->asString();
- if (!stringParam)
- return false;
-
- ++param;
- if (param != end)
- return false;
-
- binding->type = QV4::CompiledData::Binding::Type_String;
- binding->stringIndex = unitGenerator->registerString(*stringParam->value);
- return true;
- }
- return false;
-}
-
-QQmlIRFunctionCleanser::QQmlIRFunctionCleanser(QV4::IR::Module *module, const QVector<QmlIR::Object *> &qmlObjects, const QVector<int> &functionsToRemove)
- : module(module)
- , qmlObjects(qmlObjects)
- , functionsToRemove(functionsToRemove)
-{
-}
-
-void QQmlIRFunctionCleanser::clean()
-{
- QVector<QV4::IR::Function*> newFunctions;
- newFunctions.reserve(module->functions.count() - functionsToRemove.count());
-
- newFunctionIndices.resize(module->functions.count());
-
- for (int i = 0; i < module->functions.count(); ++i) {
- QV4::IR::Function *f = module->functions.at(i);
- Q_ASSERT(f || functionsToRemove.contains(i));
- if (f) {
- newFunctionIndices[i] = newFunctions.count();
- newFunctions << f;
- }
- }
-
- module->functions = newFunctions;
-
- for (QV4::IR::Function *function : qAsConst(module->functions)) {
- for (QV4::IR::BasicBlock *block : function->basicBlocks()) {
- for (QV4::IR::Stmt *s : block->statements()) {
- visit(s);
- }
- }
- }
-
- for (QmlIR::Object *obj : qmlObjects) {
- for (int i = 0; i < obj->runtimeFunctionIndices.count; ++i)
- obj->runtimeFunctionIndices[i] = newFunctionIndices[obj->runtimeFunctionIndices.at(i)];
- }
-}
-
-void QQmlIRFunctionCleanser::visit(QV4::IR::Stmt *s)
-{
-
- switch (s->stmtKind) {
- case QV4::IR::Stmt::PhiStmt:
- // nothing to do
- break;
- default:
- STMT_VISIT_ALL_KINDS(s);
- break;
- }
-}
-
-void QQmlIRFunctionCleanser::visit(QV4::IR::Expr *e)
-{
- switch (e->exprKind) {
- case QV4::IR::Expr::ClosureExpr: {
- auto closure = e->asClosure();
- closure->value = newFunctionIndices.at(closure->value);
- } break;
- default:
- EXPR_VISIT_ALL_KINDS(e);
- break;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/compiler/qv4jssimplifier_p.h b/src/qml/compiler/qv4jssimplifier_p.h
deleted file mode 100644
index ae8d74135c..0000000000
--- a/src/qml/compiler/qv4jssimplifier_p.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QV4JSSIMPLIFIER
-#define QV4JSSIMPLIFIER
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qv4global_p.h>
-
-#include "qqmlirbuilder_p.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace QmlIR {
-struct Document;
-}
-
-namespace QV4 {
-namespace CompiledData {
-struct QmlUnit;
-struct Location;
-}
-}
-
-class QQmlJavaScriptBindingExpressionSimplificationPass
-{
-public:
- QQmlJavaScriptBindingExpressionSimplificationPass(const QVector<QmlIR::Object*> &qmlObjects, QV4::IR::Module *jsModule, QV4::Compiler::JSUnitGenerator *unitGenerator);
-
- void reduceTranslationBindings();
-
-private:
- void reduceTranslationBindings(int objectIndex);
-
- void visit(QV4::IR::Stmt *s)
- {
- switch (s->stmtKind) {
- case QV4::IR::Stmt::MoveStmt:
- visitMove(s->asMove());
- break;
- case QV4::IR::Stmt::RetStmt:
- visitRet(s->asRet());
- break;
- case QV4::IR::Stmt::CJumpStmt:
- discard();
- break;
- case QV4::IR::Stmt::ExpStmt:
- discard();
- break;
- case QV4::IR::Stmt::JumpStmt:
- break;
- case QV4::IR::Stmt::PhiStmt:
- break;
- }
- }
-
- void visitMove(QV4::IR::Move *move);
- void visitRet(QV4::IR::Ret *ret);
-
- void visitFunctionCall(const QString *name, QV4::IR::ExprList *args, QV4::IR::Temp *target);
-
- void discard() { _canSimplify = false; }
-
- bool simplifyBinding(QV4::IR::Function *function, QmlIR::Binding *binding);
- bool detectTranslationCallAndConvertBinding(QmlIR::Binding *binding);
-
- const QVector<QmlIR::Object*> &qmlObjects;
- QV4::IR::Module *jsModule;
- QV4::Compiler::JSUnitGenerator *unitGenerator;
-
- bool _canSimplify;
- const QString *_nameOfFunctionCalled;
- QVector<int> _functionParameters;
- int _functionCallReturnValue;
-
- QHash<int, QV4::IR::Expr*> _temps;
- int _returnValueOfBindingExpression;
- int _synthesizedConsts;
-
- QVector<int> irFunctionsToRemove;
-};
-
-class QQmlIRFunctionCleanser
-{
-public:
- QQmlIRFunctionCleanser(QV4::IR::Module *module, const QVector<QmlIR::Object*> &qmlObjects, const QVector<int> &functionsToRemove);
-
- void clean();
-
-private:
- virtual void visitMove(QV4::IR::Move *s) {
- visit(s->source);
- visit(s->target);
- }
-
- void visit(QV4::IR::Stmt *s);
- void visit(QV4::IR::Expr *e);
-
-private:
- QV4::IR::Module *module;
- const QVector<QmlIR::Object*> &qmlObjects;
- const QVector<int> &functionsToRemove;
-
- QVector<int> newFunctionIndices;
-};
-
-QT_END_NAMESPACE
-
-#endif // QV4JSSIMPLIFIER
diff --git a/src/qml/configure.json b/src/qml/configure.json
index 681cecea99..9d30dd7be2 100644
--- a/src/qml/configure.json
+++ b/src/qml/configure.json
@@ -32,19 +32,77 @@
"section": "QML",
"condition": [
"features.commandlineparser",
- "features.localserver",
- "features.process",
"features.qml-debug",
- "features.qml-network",
+ "features.qml-network && features.localserver",
"features.xmlstreamwriter"
],
"output": [ "privateFeature" ]
},
+ "qml-preview": {
+ "label": "Command line QML Preview tool",
+ "purpose": "Updates QML documents in your application live as you change them on disk",
+ "section": "QML",
+ "condition": [
+ "features.commandlineparser",
+ "features.qml-network && features.localserver",
+ "features.process",
+ "features.qml-debug"
+ ],
+ "output": [ "privateFeature" ]
+ },
+ "qml-devtools": {
+ "label": "QML Development Tools",
+ "purpose": "Provides the QmlDevtools library and various utilities.",
+ "section": "QML",
+ "output": [ "privateFeature" ]
+ },
+ "qml-sequence-object": {
+ "label": "QML sequence object",
+ "purpose": "Supports mapping sequence types into QML.",
+ "section": "QML",
+ "output": [ "privateFeature" ]
+ },
+ "qml-list-model": {
+ "label": "QML list model",
+ "purpose": "Provides the ListModel QML type.",
+ "section": "QML",
+ "output": [ "privateFeature" ]
+ },
+ "qml-xml-http-request": {
+ "label": "QML XML http request",
+ "purpose": "Provides support for sending XML http requests.",
+ "section": "QML",
+ "condition": [
+ "features.xmlstreamreader",
+ "features.qml-network"
+ ],
+ "output": [ "privateFeature" ]
+ },
+ "qml-locale": {
+ "label": "QML Locale",
+ "purpose": "Provides support for locales in QML.",
+ "section": "QML",
+ "output": [ "privateFeature" ]
+ },
+ "qml-animation": {
+ "label": "QML Animations",
+ "purpose": "Provides support for animations and timers in QML.",
+ "section": "QML",
+ "condition": "features.animation",
+ "output": [ "privateFeature" ]
+ },
"qml-delegate-model": {
"label": "QML delegate model",
"purpose": "Provides the DelegateModel QML type.",
"section": "QML",
"output": [ "privateFeature" ]
+ },
+ "qml-worker-script": {
+ "label": "QML WorkerScript",
+ "purpose": "Enables the use of threads in QML.",
+ "section": "QML",
+ "condition": "features.thread",
+ "output": [ "privateFeature" ]
}
},
@@ -54,6 +112,10 @@
"entries": [
"qml-network",
"qml-debug",
+ "qml-sequence-object",
+ "qml-list-model",
+ "qml-xml-http-request",
+ "qml-locale",
"qml-delegate-model"
]
}
diff --git a/src/qml/debugger/qqmlabstractprofileradapter_p.h b/src/qml/debugger/qqmlabstractprofileradapter_p.h
index c63e694c7e..f39f8fccd2 100644
--- a/src/qml/debugger/qqmlabstractprofileradapter_p.h
+++ b/src/qml/debugger/qqmlabstractprofileradapter_p.h
@@ -73,13 +73,13 @@ public:
~QQmlAbstractProfilerAdapter() override {}
void setService(QQmlProfilerService *new_service) { service = new_service; }
- virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages, bool trackLocations) = 0;
+ virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages) = 0;
void startProfiling(quint64 features);
void stopProfiling();
- void reportData(bool trackLocations) { emit dataRequested(trackLocations); }
+ void reportData() { emit dataRequested(); }
void stopWaiting() { waiting = false; }
void startWaiting() { waiting = true; }
@@ -96,7 +96,7 @@ signals:
void profilingDisabled();
void profilingDisabledWhileWaiting();
- void dataRequested(bool trackLocations);
+ void dataRequested();
void referenceTimeKnown(const QElapsedTimer &timer);
protected:
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index d9f51ce09f..0ef40d6911 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -82,7 +82,7 @@ Q_GLOBAL_STATIC(QQmlDebugConnectorParams, qmlDebugConnectorParams)
void QQmlDebugConnector::setPluginKey(const QString &key)
{
QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
- if (params) {
+ if (params && params->pluginKey != key) {
if (params->instance)
qWarning() << "QML debugger: Cannot set plugin key after loading the plugin.";
else
diff --git a/src/qml/debugger/qqmlprofiler.cpp b/src/qml/debugger/qqmlprofiler.cpp
index 8c0bd73822..da0b14dd85 100644
--- a/src/qml/debugger/qqmlprofiler.cpp
+++ b/src/qml/debugger/qqmlprofiler.cpp
@@ -59,19 +59,18 @@ void QQmlProfiler::startProfiling(quint64 features)
void QQmlProfiler::stopProfiling()
{
featuresEnabled = false;
- reportData(true);
+ reportData();
m_locations.clear();
}
-void QQmlProfiler::reportData(bool trackLocations)
+void QQmlProfiler::reportData()
{
LocationHash resolved;
resolved.reserve(m_locations.size());
for (auto it = m_locations.begin(), end = m_locations.end(); it != end; ++it) {
- if (!trackLocations || !it->sent) {
+ if (!it->sent) {
resolved.insert(it.key(), it.value());
- if (trackLocations)
- it->sent = true;
+ it->sent = true;
}
}
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 287c53ea05..d01e2bc429 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -383,7 +383,7 @@ public:
void startProfiling(quint64 features);
void stopProfiling();
- void reportData(bool trackLocations);
+ void reportData();
void setTimer(const QElapsedTimer &timer) { m_timer = timer; }
signals:
diff --git a/src/qml/doc/images/cpp-qml-integration-flowchart.odg b/src/qml/doc/images/cpp-qml-integration-flowchart.odg
index 8482bd4bf4..f24021635e 100644
--- a/src/qml/doc/images/cpp-qml-integration-flowchart.odg
+++ b/src/qml/doc/images/cpp-qml-integration-flowchart.odg
Binary files differ
diff --git a/src/qml/doc/images/cpp-qml-integration-flowchart.png b/src/qml/doc/images/cpp-qml-integration-flowchart.png
index 56a33205fd..3649ff9e41 100644
--- a/src/qml/doc/images/cpp-qml-integration-flowchart.png
+++ b/src/qml/doc/images/cpp-qml-integration-flowchart.png
Binary files differ
diff --git a/src/qml/doc/images/visualitemmodel.png b/src/qml/doc/images/objectmodel.png
index 5e6d1325b2..5e6d1325b2 100644
--- a/src/qml/doc/images/visualitemmodel.png
+++ b/src/qml/doc/images/objectmodel.png
Binary files differ
diff --git a/src/qml/doc/snippets/delegatemodel/visualdatamodel.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel.qml
index 1a7baa6b1e..1a7baa6b1e 100644
--- a/src/qml/doc/snippets/delegatemodel/visualdatamodel.qml
+++ b/src/qml/doc/snippets/delegatemodel/delegatemodel.qml
diff --git a/src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/main.cpp b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp
index a56eb69616..a56eb69616 100644
--- a/src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/main.cpp
+++ b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp
diff --git a/src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/view.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml
index 2e17eed8f0..2e17eed8f0 100644
--- a/src/qml/doc/snippets/delegatemodel/visualdatamodel_rootindex/view.qml
+++ b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml
diff --git a/src/qml/doc/snippets/delegatemodel/visualdatagroup.qml b/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml
index 8562deeeda..8562deeeda 100644
--- a/src/qml/doc/snippets/delegatemodel/visualdatagroup.qml
+++ b/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml
diff --git a/src/qml/doc/snippets/qml/workerscript/script.js b/src/qml/doc/snippets/qml/workerscript/script.mjs
index f55dee3507..f55dee3507 100644
--- a/src/qml/doc/snippets/qml/workerscript/script.js
+++ b/src/qml/doc/snippets/qml/workerscript/script.mjs
diff --git a/src/qml/doc/snippets/qml/workerscript/workerscript.qml b/src/qml/doc/snippets/qml/workerscript/workerscript.qml
index e3fe3c92e6..cc637d34cf 100644
--- a/src/qml/doc/snippets/qml/workerscript/workerscript.qml
+++ b/src/qml/doc/snippets/qml/workerscript/workerscript.qml
@@ -61,7 +61,7 @@ Rectangle {
WorkerScript {
id: myWorker
- source: "script.js"
+ source: "script.mjs"
onMessage: myText.text = messageObject.reply
}
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index 8a606d672a..6159ffe20b 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -262,8 +262,8 @@ method.
\section2 Sequence Type to JavaScript Array
-Certain C++ sequence types are supported transparently in QML as JavaScript
-\c Array types.
+Certain C++ sequence types are supported transparently in QML to behave like
+JavaScript \c Array types.
In particular, QML currently supports:
\list
@@ -420,6 +420,47 @@ To use an enum as a \l {QFlags}{flags} type in QML, see \l Q_FLAG().
\note The names of enum values must begin with a capital letter in order to
be accessible from QML.
+\code
+...
+enum class Status {
+ Ready,
+ Loading,
+ Error
+}
+Q_ENUM(Status)
+...
+\endcode
+
+Enum classes are registered in QML as scoped and unscoped properties.
+The \c Ready value will be registered at \c Message.Status.Ready and \c Message.Ready .
+
+When using enum classes, there can be multiple enums using the same identifiers.
+The unscoped registration will be overwriten by the last registered enum. For classes
+that contain such name conficts it is possible to disable the unscoped registration by
+annotating your class with a special Q_CLASSINFO macro.
+Use the name \c RegisterEnumClassesUnscoped with the value \c false to prevent scoped
+enums from being merged into the same name space.
+
+\code
+class Message : public QObject
+ {
+ Q_OBJECT
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
+ Q_ENUM(ScopedEnum)
+ Q_ENUM(OtherValue)
+
+ public:
+ enum class ScopedEnum {
+ Value1,
+ Value2,
+ OtherValue
+ };
+ enum class OtherValue {
+ Value1,
+ Value2
+ };
+ };
+\endcode
\section2 Enumeration Types as Signal and Method Parameters
diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
index aefdfd9401..52534b4a62 100644
--- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
+++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
@@ -255,9 +255,6 @@ type, and so cannot provide the necessary QML property characteristics
through the Qt meta object system, such as signal notifications when a list
is modified.
-QQmlListProperty is a template class that can be conveniently constructed from
-a QList value.
-
For example, the \c MessageBoard class below has a \c messages property of
type QQmlListProperty that stores a list of \c Message instances:
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index 55ca040af6..62c0f5d81b 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -538,30 +538,6 @@
}
\endqml
- Since singleton types do not have an associated QQmlContext object, then within the functions of a QObject-derived
- type that is registered as a singleton type implementation the QML context and engine information is not available.
- The QQmlEngine::contextForObject() function returns NULL when supplied with a pointer to an QObject that
- implements a singleton type.
-
- Extending the above example:
-
- \code
- class SingletonTypeExample : public QObject
- {
- ...
-
- Q_INVOKABLE void doSomethingElse()
- {
- // QML Engine/Context information is not accessible here:
- Q_ASSERT(QQmlEngine::contextForObject(this) == 0);
- Q_ASSERT(qmlContext(this) == 0);
- Q_ASSERT(qmlEngine(this) == 0);
- }
-
- ...
- }
- \endcode
-
\sa {Choosing the Correct Integration Method Between C++ and QML}
*/
@@ -662,3 +638,25 @@
are registered for that version. This is particularly useful for keeping the
versions of related modules in sync.
*/
+
+/*!
+ \since 5.12
+ \fn int qmlTypeId(const char* uri, int versionMajor, int versionMinor, const char *qmlName);
+ \relates QQmlEngine
+
+ Returns the QML type id of a type that was registered with the
+ name \a qmlName in a particular \a uri and a version specified in \a
+ versionMajor and \a versionMinor.
+
+ This function returns the same value as the QML type registration functions
+ such as qmlRegisterType() and qmlRegisterSingletonType().
+
+ If \a qmlName, \a uri and \a versionMajor match a registered type, but the
+ specified minor version in \a versionMinor is higher, then the id of the type
+ with the closest minor version is returned.
+
+ Returns -1 if no matching type was found or one of the given parameters
+ was invalid.
+
+ \sa qmlRegisterType(), qmlRegisterSingletonType()
+*/
diff --git a/src/qml/doc/src/qmltypereference.qdoc b/src/qml/doc/src/qmltypereference.qdoc
index 960ea116c9..79bfdc7042 100644
--- a/src/qml/doc/src/qmltypereference.qdoc
+++ b/src/qml/doc/src/qmltypereference.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
-\qmlmodule QtQml 2.11
+\qmlmodule QtQml 2.\QtMinorVersion
\title Qt QML QML Types
\ingroup qmlmodules
\brief List of QML types provided by the Qt QML module
@@ -43,19 +43,19 @@ The types provided by the \c QtQml module are only available in a QML document
if that document imports the \c QtQml namespace (or if the document imports the
\c QtQuick namespace, as noted below).
-The current version of the \c QtQml module is version 2.11, and thus it may be
-imported via the following statement:
+The current version of the \c QtQml module is version 2.\QtMinorVersion, and
+thus it may be imported via the following statement:
-\qml
-import QtQml 2.11
+\qml \QtMinorVersion
+import QtQml 2.\1
\endqml
Most clients will never need to use the \c QtQml import, as all of the types
are also provided by the \c QtQuick namespace which may be imported as
follows:
-\qml
-import QtQuick 2.11
+\qml \QtMinorVersion
+import QtQuick 2.\1
\endqml
See the \l{Qt Quick} module documentation for more information about the \c
diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc
index b4bc9a0774..68d2b66950 100644
--- a/src/qml/doc/src/qtqml.qdoc
+++ b/src/qml/doc/src/qtqml.qdoc
@@ -55,11 +55,12 @@ following directive:
#include <QtQml>
\endcode
-The QML types in Qt QML are available through the \c QtQML import. To use the
+The QML types in Qt QML are available through the \c QtQml import. To use the
types, add the following import statement to your .qml file:
-\code
-import QtQml 2.11
-\endcode
+
+\qml \QtMinorVersion
+import QtQml 2.\1
+\endqml
To link against the module, add this line to your \l qmake \c
diff --git a/src/qml/doc/src/statemachine.qdoc b/src/qml/doc/src/statemachine.qdoc
index 59170a223f..6986f1baa0 100644
--- a/src/qml/doc/src/statemachine.qdoc
+++ b/src/qml/doc/src/statemachine.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \qmlmodule QtQml.StateMachine 1.11
+ \qmlmodule QtQml.StateMachine 1.\QtMinorVersion
\title Declarative State Machine QML Types
\brief Provides QML types to create and execute state graphs.
@@ -68,9 +68,9 @@
\e{QtQml.StateMachine} \e{last}. This way, the \e{State} type is provided
by the Declarative State Machine Framework and not by \l{QtQuick}:
- \qml
- import QtQuick 2.0
- import QtQml.StateMachine 1.0
+ \qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQml.StateMachine 1.\1
StateMachine {
State {
@@ -82,9 +82,9 @@
Alternatively, you can import \e{QtQml.StateMachine} into a separate
namespace to avoid any ambiguity with QtQuick's \e{State} item:
- \qml
- import QtQuick 2.0
- import QtQml.StateMachine 1.0 as DSM
+ \qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQml.StateMachine 1.\1 as DSM
DSM.StateMachine {
DSM.State {
diff --git a/src/qml/jit/jit.pri b/src/qml/jit/jit.pri
index 2080844d93..2c664af188 100644
--- a/src/qml/jit/jit.pri
+++ b/src/qml/jit/jit.pri
@@ -2,9 +2,13 @@ INCLUDEPATH += $$PWD
INCLUDEPATH += $$OUT_PWD
SOURCES += \
- $$PWD/qv4jit.cpp \
- $$PWD/qv4assembler.cpp
+ $$PWD/qv4jithelpers.cpp \
+ $$PWD/qv4baselinejit.cpp \
+ $$PWD/qv4baselineassembler.cpp \
+ $$PWD/qv4assemblercommon.cpp
HEADERS += \
- $$PWD/qv4jit_p.h \
- $$PWD/qv4assembler_p.h
+ $$PWD/qv4jithelpers_p.h \
+ $$PWD/qv4baselinejit_p.h \
+ $$PWD/qv4baselineassembler_p.h \
+ $$PWD/qv4assemblercommon_p.h
diff --git a/src/qml/jit/qv4assemblercommon.cpp b/src/qml/jit/qv4assemblercommon.cpp
new file mode 100644
index 0000000000..0ae4da17fa
--- /dev/null
+++ b/src/qml/jit/qv4assemblercommon.cpp
@@ -0,0 +1,343 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QBuffer>
+#include <QFile>
+
+#include "qv4engine_p.h"
+#include "qv4assemblercommon_p.h"
+#include <private/qv4function_p.h>
+#include <private/qv4runtime_p.h>
+
+#include <assembler/MacroAssemblerCodeRef.h>
+#include <assembler/LinkBuffer.h>
+#include <WTFStubs.h>
+
+#undef ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES
+
+#ifdef V4_ENABLE_JIT
+
+QT_BEGIN_NAMESPACE
+namespace QV4 {
+namespace JIT {
+
+namespace {
+class QIODevicePrintStream: public FilePrintStream
+{
+ Q_DISABLE_COPY(QIODevicePrintStream)
+
+public:
+ explicit QIODevicePrintStream(QIODevice *dest)
+ : FilePrintStream(nullptr)
+ , dest(dest)
+ , buf(4096, '0')
+ {
+ Q_ASSERT(dest);
+ }
+
+ ~QIODevicePrintStream()
+ {}
+
+ void vprintf(const char* format, va_list argList) WTF_ATTRIBUTE_PRINTF(2, 0)
+ {
+ const int written = qvsnprintf(buf.data(), buf.size(), format, argList);
+ if (written > 0)
+ dest->write(buf.constData(), written);
+ memset(buf.data(), 0, qMin(written, buf.size()));
+ }
+
+ void flush()
+ {}
+
+private:
+ QIODevice *dest;
+ QByteArray buf;
+};
+} // anonymous namespace
+
+static void printDisassembledOutputWithCalls(QByteArray processedOutput,
+ const QHash<const void*, const char*>& functions)
+{
+ for (QHash<const void*, const char*>::ConstIterator it = functions.begin(), end = functions.end();
+ it != end; ++it) {
+ const QByteArray ptrString = "0x" + QByteArray::number(quintptr(it.key()), 16);
+ int idx = 0;
+ while (idx >= 0) {
+ idx = processedOutput.indexOf(ptrString, idx);
+ if (idx < 0)
+ break;
+ idx = processedOutput.indexOf('\n', idx);
+ if (idx < 0)
+ break;
+ processedOutput = processedOutput.insert(idx, QByteArrayLiteral(" ; ") + it.value());
+ }
+ }
+
+ qDebug("%s", processedOutput.constData());
+}
+
+static QByteArray functionName(Function *function)
+{
+ QByteArray name = function->name()->toQString().toUtf8();
+ if (name.isEmpty()) {
+ name = QByteArray::number(reinterpret_cast<quintptr>(function), 16);
+ name.prepend("QV4::Function(0x");
+ name.append(')');
+ }
+ return name;
+}
+
+JIT::PlatformAssemblerCommon::~PlatformAssemblerCommon()
+{}
+
+void PlatformAssemblerCommon::link(Function *function, const char *jitKind)
+{
+ for (const auto &jumpTarget : jumpsToLink)
+ jumpTarget.jump.linkTo(labelForOffset[jumpTarget.offset], this);
+
+ JSC::JSGlobalData dummy(function->internalClass->engine->executableAllocator);
+ JSC::LinkBuffer<MacroAssembler> linkBuffer(dummy, this, nullptr);
+
+ for (const auto &ehTarget : ehTargets) {
+ auto targetLabel = labelForOffset.value(ehTarget.offset);
+ linkBuffer.patch(ehTarget.label, linkBuffer.locationOf(targetLabel));
+ }
+
+ JSC::MacroAssemblerCodeRef codeRef;
+
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_ASM");
+ if (showCode) {
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ WTF::setDataFile(new QIODevicePrintStream(&buf));
+
+ QByteArray name = functionName(function);
+ codeRef = linkBuffer.finalizeCodeWithDisassembly(jitKind, "%s", name.constData());
+
+ WTF::setDataFile(stderr);
+ printDisassembledOutputWithCalls(buf.data(), functions);
+ } else {
+ codeRef = linkBuffer.finalizeCodeWithoutDisassembly();
+ }
+
+ function->codeRef = new JSC::MacroAssemblerCodeRef(codeRef);
+ function->jittedCode = reinterpret_cast<Function::JittedCode>(function->codeRef->code().executableAddress());
+
+ // This implements writing of JIT'd addresses so that perf can find the
+ // symbol names.
+ //
+ // Perf expects the mapping to be in a certain place and have certain
+ // content, for more information, see:
+ // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
+ static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
+ if (Q_UNLIKELY(doProfile)) {
+ static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
+ .arg(QCoreApplication::applicationPid()));
+ static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
+ if (!isOpen) {
+ qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
+ doProfile = false;
+ } else {
+ perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(
+ codeRef.code().executableAddress()), 16));
+ perfMapFile.putChar(' ');
+ perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef.size()), 16));
+ perfMapFile.putChar(' ');
+ perfMapFile.write(functionName(function));
+ perfMapFile.putChar('\n');
+ perfMapFile.flush();
+ }
+ }
+}
+
+void PlatformAssemblerCommon::prepareCallWithArgCount(int argc)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(remainingArgcForCall == NoCall);
+ remainingArgcForCall = argc;
+#endif
+
+ if (argc > ArgInRegCount) {
+ argcOnStackForCall = int(WTF::roundUpToMultipleOf(16, size_t(argc - ArgInRegCount) * PointerSize));
+ subPtr(TrustedImm32(argcOnStackForCall), StackPointerRegister);
+ }
+}
+
+void PlatformAssemblerCommon::storeInstructionPointer(int instructionOffset)
+{
+ Address addr(CppStackFrameRegister, offsetof(QV4::CppStackFrame, instructionPointer));
+ store32(TrustedImm32(instructionOffset), addr);
+}
+
+PlatformAssemblerCommon::Address PlatformAssemblerCommon::argStackAddress(int arg)
+{
+ int offset = arg - ArgInRegCount;
+ Q_ASSERT(offset >= 0);
+ return Address(StackPointerRegister, offset * PointerSize);
+}
+
+void PlatformAssemblerCommon::passAccumulatorAsArg(int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ passAccumulatorAsArg_internal(arg, false);
+}
+
+void JIT::PlatformAssemblerCommon::pushAccumulatorAsArg(int arg)
+{
+ passAccumulatorAsArg_internal(arg, true);
+}
+
+void PlatformAssemblerCommon::passAccumulatorAsArg_internal(int arg, bool doPush)
+{
+ if (arg < ArgInRegCount) {
+ addPtr(TrustedImm32(offsetof(CallData, accumulator)), JSStackFrameRegister, registerForArg(arg));
+ } else {
+ addPtr(TrustedImm32(offsetof(CallData, accumulator)), JSStackFrameRegister, ScratchRegister);
+ if (doPush)
+ push(ScratchRegister);
+ else
+ storePtr(ScratchRegister, argStackAddress(arg));
+ }
+}
+
+void PlatformAssemblerCommon::passFunctionAsArg(int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount) {
+ loadFunctionPtr(registerForArg(arg));
+ } else {
+ loadFunctionPtr(ScratchRegister);
+ storePtr(ScratchRegister, argStackAddress(arg));
+ }
+}
+
+void PlatformAssemblerCommon::passEngineAsArg(int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount) {
+ move(EngineRegister, registerForArg(arg));
+ } else {
+ storePtr(EngineRegister, argStackAddress(arg));
+ }
+}
+
+void PlatformAssemblerCommon::passJSSlotAsArg(int reg, int arg)
+{
+ Address addr(JSStackFrameRegister, reg * int(sizeof(QV4::Value)));
+ passAddressAsArg(addr, arg);
+}
+
+void JIT::PlatformAssemblerCommon::passAddressAsArg(Address addr, int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount) {
+ addPtr(TrustedImm32(addr.offset), addr.base, registerForArg(arg));
+ } else {
+ addPtr(TrustedImm32(addr.offset), addr.base, ScratchRegister);
+ storePtr(ScratchRegister, argStackAddress(arg));
+ }
+}
+
+void PlatformAssemblerCommon::passCppFrameAsArg(int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount)
+ move(CppStackFrameRegister, registerForArg(arg));
+ else
+ store32(CppStackFrameRegister, argStackAddress(arg));
+}
+
+void PlatformAssemblerCommon::passInt32AsArg(int value, int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount)
+ move(TrustedImm32(value), registerForArg(arg));
+ else
+ store32(TrustedImm32(value), argStackAddress(arg));
+}
+
+void PlatformAssemblerCommon::callRuntime(const char *functionName, const void *funcPtr)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(remainingArgcForCall == 0);
+ remainingArgcForCall = NoCall;
+#endif
+ callRuntimeUnchecked(functionName, funcPtr);
+ if (argcOnStackForCall > 0) {
+ addPtr(TrustedImm32(argcOnStackForCall), StackPointerRegister);
+ argcOnStackForCall = 0;
+ }
+}
+
+void JIT::PlatformAssemblerCommon::callRuntimeUnchecked(const char *functionName, const void *funcPtr)
+{
+ functions.insert(funcPtr, functionName);
+ callAbsolute(funcPtr);
+}
+
+} // JIT namespace
+} // QV4 namepsace
+
+QT_END_NAMESPACE
+
+#endif // V4_ENABLE_JIT
diff --git a/src/qml/jit/qv4assemblercommon_p.h b/src/qml/jit/qv4assemblercommon_p.h
new file mode 100644
index 0000000000..d64b9d0e5d
--- /dev/null
+++ b/src/qml/jit/qv4assemblercommon_p.h
@@ -0,0 +1,697 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4PLATFORMASSEMBLER_P_H
+#define QV4PLATFORMASSEMBLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qv4engine_p.h>
+#include <private/qv4global_p.h>
+#include <private/qv4function_p.h>
+#include <QHash>
+#include <wtf/Vector.h>
+#include <assembler/MacroAssembler.h>
+
+#ifdef V4_ENABLE_JIT
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+namespace JIT {
+
+#if defined(Q_PROCESSOR_X86_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
+#if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD) || defined(Q_OS_DARWIN)
+
+class PlatformAssembler_X86_64_SysV : public JSC::MacroAssembler<JSC::MacroAssemblerX86_64>
+{
+public:
+ static constexpr int NativeStackAlignment = 16;
+
+ static const RegisterID NoRegister = RegisterID(-1);
+
+ static const RegisterID ReturnValueRegister = RegisterID::eax;
+ static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
+ static const RegisterID AccumulatorRegister = RegisterID::eax;
+ static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
+ static const RegisterID ScratchRegister = RegisterID::r10;
+ static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg5Reg, so do not use while setting up a call!
+ static const RegisterID JSStackFrameRegister = RegisterID::r12;
+ static const RegisterID CppStackFrameRegister = RegisterID::r13;
+ static const RegisterID EngineRegister = RegisterID::r14;
+ static const RegisterID StackPointerRegister = RegisterID::esp;
+ static const RegisterID FramePointerRegister = RegisterID::ebp;
+ static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
+ static const FPRegisterID FPScratchRegister2 = FPRegisterID::xmm2;
+
+ static const RegisterID Arg0Reg = RegisterID::edi;
+ static const RegisterID Arg1Reg = RegisterID::esi;
+ static const RegisterID Arg2Reg = RegisterID::edx;
+ static const RegisterID Arg3Reg = RegisterID::ecx;
+ static const RegisterID Arg4Reg = RegisterID::r8;
+ static const RegisterID Arg5Reg = RegisterID::r9;
+ static const RegisterID Arg6Reg = NoRegister;
+ static const RegisterID Arg7Reg = NoRegister;
+ static const int ArgInRegCount = 6;
+
+ void popValue()
+ {
+ addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
+ }
+
+ void generatePlatformFunctionEntry()
+ {
+ push(FramePointerRegister);
+ move(StackPointerRegister, FramePointerRegister);
+ move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler
+ push(JSStackFrameRegister);
+ push(CppStackFrameRegister);
+ push(EngineRegister);
+ move(Arg0Reg, CppStackFrameRegister);
+ move(Arg1Reg, EngineRegister);
+ }
+
+ void generatePlatformFunctionExit()
+ {
+ pop(EngineRegister);
+ pop(CppStackFrameRegister);
+ pop(JSStackFrameRegister);
+ pop(); // exceptionHandler
+ pop(FramePointerRegister);
+ ret();
+ }
+
+ void callAbsolute(const void *funcPtr)
+ {
+ move(TrustedImmPtr(funcPtr), ScratchRegister);
+ call(ScratchRegister);
+ }
+
+ void pushAligned(RegisterID reg)
+ {
+ subPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ push(reg);
+ }
+
+ void popAligned(RegisterID reg)
+ {
+ pop(reg);
+ addPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ }
+};
+
+typedef PlatformAssembler_X86_64_SysV PlatformAssemblerBase;
+
+#endif
+#if defined(Q_OS_WIN)
+
+class PlatformAssembler_Win64 : public JSC::MacroAssembler<JSC::MacroAssemblerX86_64>
+{
+public:
+ static const RegisterID NoRegister = RegisterID(-1);
+
+ static const RegisterID ReturnValueRegister = RegisterID::eax;
+ static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
+ static const RegisterID AccumulatorRegister = RegisterID::eax;
+ static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
+ static const RegisterID ScratchRegister = RegisterID::r10;
+ static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg3Reg, so do not use while setting up a call!
+ static const RegisterID JSStackFrameRegister = RegisterID::r12;
+ static const RegisterID CppStackFrameRegister = RegisterID::r13;
+ static const RegisterID EngineRegister = RegisterID::r14;
+ static const RegisterID StackPointerRegister = RegisterID::esp;
+ static const RegisterID FramePointerRegister = RegisterID::ebp;
+ static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
+
+ static const RegisterID Arg0Reg = RegisterID::ecx;
+ static const RegisterID Arg1Reg = RegisterID::edx;
+ static const RegisterID Arg2Reg = RegisterID::r8;
+ static const RegisterID Arg3Reg = RegisterID::r9;
+ static const RegisterID Arg4Reg = NoRegister;
+ static const RegisterID Arg5Reg = NoRegister;
+ static const RegisterID Arg6Reg = NoRegister;
+ static const RegisterID Arg7Reg = NoRegister;
+ static const int ArgInRegCount = 4;
+
+ void popValue()
+ {
+ addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
+ }
+
+ void generatePlatformFunctionEntry()
+ {
+ push(FramePointerRegister);
+ move(StackPointerRegister, FramePointerRegister);
+ move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler
+ push(JSStackFrameRegister);
+ push(CppStackFrameRegister);
+ push(EngineRegister);
+ move(Arg0Reg, CppStackFrameRegister);
+ move(Arg1Reg, EngineRegister);
+ }
+
+ void generatePlatformFunctionExit()
+ {
+ pop(EngineRegister);
+ pop(CppStackFrameRegister);
+ pop(JSStackFrameRegister);
+ pop(); // exceptionHandler
+ pop(FramePointerRegister);
+ ret();
+ }
+
+ void callAbsolute(const void *funcPtr)
+ {
+ move(TrustedImmPtr(funcPtr), ScratchRegister);
+ subPtr(TrustedImm32(4 * PointerSize), StackPointerRegister);
+ call(ScratchRegister);
+ addPtr(TrustedImm32(4 * PointerSize), StackPointerRegister);
+ }
+
+ void pushAligned(RegisterID reg)
+ {
+ subPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ push(reg);
+ }
+
+ void popAligned(RegisterID reg)
+ {
+ pop(reg);
+ addPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ }
+};
+
+typedef PlatformAssembler_Win64 PlatformAssemblerBase;
+
+#endif
+#endif
+
+#if (defined(Q_PROCESSOR_X86) && !defined(Q_PROCESSOR_X86_64)) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
+
+class PlatformAssembler_X86_All : public JSC::MacroAssembler<JSC::MacroAssemblerX86>
+{
+public:
+ static const RegisterID NoRegister = RegisterID(-1);
+
+ static const RegisterID ReturnValueRegisterValue = RegisterID::eax;
+ static const RegisterID ReturnValueRegisterTag = RegisterID::edx;
+ static const RegisterID ScratchRegister = RegisterID::ecx;
+ static const RegisterID AccumulatorRegisterValue = ReturnValueRegisterValue;
+ static const RegisterID AccumulatorRegisterTag = ReturnValueRegisterTag;
+ static const RegisterID JSStackFrameRegister = RegisterID::ebx;
+ static const RegisterID CppStackFrameRegister = RegisterID::esi;
+ static const RegisterID EngineRegister = RegisterID::edi;
+ static const RegisterID StackPointerRegister = RegisterID::esp;
+ static const RegisterID FramePointerRegister = RegisterID::ebp;
+ static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
+
+ static const RegisterID Arg0Reg = NoRegister;
+ static const RegisterID Arg1Reg = NoRegister;
+ static const RegisterID Arg2Reg = NoRegister;
+ static const RegisterID Arg3Reg = NoRegister;
+ static const RegisterID Arg4Reg = NoRegister;
+ static const RegisterID Arg5Reg = NoRegister;
+ static const RegisterID Arg6Reg = NoRegister;
+ static const RegisterID Arg7Reg = NoRegister;
+ static const int ArgInRegCount = 0;
+
+ void popValue()
+ {
+ addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
+ }
+
+ void generatePlatformFunctionEntry()
+ {
+ push(RegisterID::ebp);
+ move(RegisterID::esp, RegisterID::ebp);
+ move(TrustedImmPtr(nullptr), AccumulatorRegisterValue); push(AccumulatorRegisterValue); // exceptionHandler
+ push(JSStackFrameRegister);
+ push(CppStackFrameRegister);
+ push(EngineRegister);
+ // Ensure the stack is 16-byte aligned in order for compiler generated aligned SSE2
+ // instructions to be able to target the stack.
+ subPtr(TrustedImm32(8), StackPointerRegister);
+ loadPtr(Address(FramePointerRegister, 2 * PointerSize), CppStackFrameRegister);
+ loadPtr(Address(FramePointerRegister, 3 * PointerSize), EngineRegister);
+ }
+
+ void generatePlatformFunctionExit()
+ {
+ addPtr(TrustedImm32(8), StackPointerRegister);
+ pop(EngineRegister);
+ pop(CppStackFrameRegister);
+ pop(JSStackFrameRegister);
+ pop(); // exceptionHandler
+ pop(RegisterID::ebp);
+ ret();
+ }
+
+ void callAbsolute(const void *funcPtr)
+ {
+ move(TrustedImmPtr(funcPtr), ScratchRegister);
+ call(ScratchRegister);
+ }
+
+ void pushAligned(RegisterID reg)
+ {
+ subPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ push(reg);
+ }
+
+ void popAligned(RegisterID reg)
+ {
+ pop(reg);
+ addPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ }
+};
+
+typedef PlatformAssembler_X86_All PlatformAssemblerBase;
+
+#endif
+
+#if defined(Q_PROCESSOR_ARM_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
+
+class PlatformAssembler_ARM64 : public JSC::MacroAssembler<JSC::MacroAssemblerARM64>
+{
+public:
+ static const RegisterID NoRegister = RegisterID(-1);
+
+ static const RegisterID ReturnValueRegister = JSC::ARM64Registers::x0;
+ static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
+ static const RegisterID AccumulatorRegister = JSC::ARM64Registers::x9;
+ static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
+ static const RegisterID ScratchRegister = JSC::ARM64Registers::x10;
+ static const RegisterID ScratchRegister2 = JSC::ARM64Registers::x7; // Note: overlaps with Arg7Reg, so do not use while setting up a call!
+ static const RegisterID JSStackFrameRegister = JSC::ARM64Registers::x19;
+ static const RegisterID CppStackFrameRegister = JSC::ARM64Registers::x20;
+ static const RegisterID EngineRegister = JSC::ARM64Registers::x21;
+ static const RegisterID StackPointerRegister = JSC::ARM64Registers::sp;
+ static const RegisterID FramePointerRegister = JSC::ARM64Registers::fp;
+ static const FPRegisterID FPScratchRegister = JSC::ARM64Registers::q1;
+
+ static const RegisterID Arg0Reg = JSC::ARM64Registers::x0;
+ static const RegisterID Arg1Reg = JSC::ARM64Registers::x1;
+ static const RegisterID Arg2Reg = JSC::ARM64Registers::x2;
+ static const RegisterID Arg3Reg = JSC::ARM64Registers::x3;
+ static const RegisterID Arg4Reg = JSC::ARM64Registers::x4;
+ static const RegisterID Arg5Reg = JSC::ARM64Registers::x5;
+ static const RegisterID Arg6Reg = JSC::ARM64Registers::x6;
+ static const RegisterID Arg7Reg = JSC::ARM64Registers::x7;
+ static const int ArgInRegCount = 8;
+
+ void push(RegisterID src)
+ {
+ pushToSave(src);
+ }
+
+ void pop(RegisterID dest)
+ {
+ popToRestore(dest);
+ }
+
+ void pop()
+ {
+ add64(TrustedImm32(16), stackPointerRegister);
+ }
+
+ void popValue()
+ {
+ pop();
+ }
+
+ void generatePlatformFunctionEntry()
+ {
+ pushPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr);
+ move(RegisterID::sp, RegisterID::fp);
+ move(TrustedImmPtr(nullptr), AccumulatorRegister); // exceptionHandler
+ pushPair(JSStackFrameRegister, AccumulatorRegister);
+ pushPair(EngineRegister, CppStackFrameRegister);
+ move(Arg0Reg, CppStackFrameRegister);
+ move(Arg1Reg, EngineRegister);
+ }
+
+ void generatePlatformFunctionExit()
+ {
+ move(AccumulatorRegister, ReturnValueRegister);
+ popPair(EngineRegister, CppStackFrameRegister);
+ popPair(JSStackFrameRegister, AccumulatorRegister);
+ popPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr);
+ ret();
+ }
+
+ void callAbsolute(const void *funcPtr)
+ {
+ move(TrustedImmPtr(funcPtr), ScratchRegister);
+ call(ScratchRegister);
+ }
+
+ void pushAligned(RegisterID reg)
+ {
+ pushToSave(reg);
+ }
+
+ void popAligned(RegisterID reg)
+ {
+ popToRestore(reg);
+ }
+};
+
+typedef PlatformAssembler_ARM64 PlatformAssemblerBase;
+
+#endif
+
+#if defined(Q_PROCESSOR_ARM_32) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
+
+class PlatformAssembler_ARM32 : public JSC::MacroAssembler<JSC::MacroAssemblerARMv7>
+{
+public:
+ static const RegisterID NoRegister = RegisterID(-1);
+
+ static const RegisterID ReturnValueRegisterValue = JSC::ARMRegisters::r0;
+ static const RegisterID ReturnValueRegisterTag = JSC::ARMRegisters::r1;
+ static const RegisterID ScratchRegister = JSC::ARMRegisters::r2;
+ static const RegisterID AccumulatorRegisterValue = JSC::ARMRegisters::r4;
+ static const RegisterID AccumulatorRegisterTag = JSC::ARMRegisters::r5;
+ // r6 is used by MacroAssemblerARMv7
+ static const RegisterID JSStackFrameRegister = JSC::ARMRegisters::r8;
+ static const RegisterID CppStackFrameRegister = JSC::ARMRegisters::r10;
+#if CPU(ARM_THUMB2) || defined(V4_BOOTSTRAP)
+ static const RegisterID FramePointerRegister = JSC::ARMRegisters::r7;
+ static const RegisterID EngineRegister = JSC::ARMRegisters::r11;
+#else // Thumbs down
+ static const RegisterID FramePointerRegister = JSC::ARMRegisters::r11;
+ static const RegisterID EngineRegister = JSC::ARMRegisters::r7;
+#endif
+ static const RegisterID StackPointerRegister = JSC::ARMRegisters::r13;
+ static const FPRegisterID FPScratchRegister = JSC::ARMRegisters::d1;
+
+ static const RegisterID Arg0Reg = JSC::ARMRegisters::r0;
+ static const RegisterID Arg1Reg = JSC::ARMRegisters::r1;
+ static const RegisterID Arg2Reg = JSC::ARMRegisters::r2;
+ static const RegisterID Arg3Reg = JSC::ARMRegisters::r3;
+ static const RegisterID Arg4Reg = NoRegister;
+ static const RegisterID Arg5Reg = NoRegister;
+ static const RegisterID Arg6Reg = NoRegister;
+ static const RegisterID Arg7Reg = NoRegister;
+ static const int ArgInRegCount = 4;
+
+ void popValue()
+ {
+ addPtr(TrustedImm32(sizeof(ReturnedValue)), StackPointerRegister);
+ }
+
+ void generatePlatformFunctionEntry()
+ {
+ push(JSC::ARMRegisters::lr);
+ push(FramePointerRegister);
+ move(StackPointerRegister, FramePointerRegister);
+ push(TrustedImm32(0)); // exceptionHandler
+ push(AccumulatorRegisterValue);
+ push(AccumulatorRegisterTag);
+ push(addressTempRegister);
+ push(JSStackFrameRegister);
+ push(CppStackFrameRegister);
+ push(EngineRegister);
+ subPtr(TrustedImm32(4), StackPointerRegister); // stack alignment
+ move(Arg0Reg, CppStackFrameRegister);
+ move(Arg1Reg, EngineRegister);
+ }
+
+ void generatePlatformFunctionExit()
+ {
+ move(AccumulatorRegisterValue, ReturnValueRegisterValue);
+ move(AccumulatorRegisterTag, ReturnValueRegisterTag);
+ addPtr(TrustedImm32(4), StackPointerRegister); // stack alignment
+ pop(EngineRegister);
+ pop(CppStackFrameRegister);
+ pop(JSStackFrameRegister);
+ pop(addressTempRegister);
+ pop(AccumulatorRegisterTag);
+ pop(AccumulatorRegisterValue);
+ pop(); // exceptionHandler
+ pop(FramePointerRegister);
+ pop(JSC::ARMRegisters::lr);
+ ret();
+ }
+
+ void callAbsolute(const void *funcPtr)
+ {
+ move(TrustedImmPtr(funcPtr), dataTempRegister);
+ call(dataTempRegister);
+ }
+
+ void pushAligned(RegisterID reg)
+ {
+ subPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ push(reg);
+ }
+
+ void popAligned(RegisterID reg)
+ {
+ pop(reg);
+ addPtr(TrustedImm32(PointerSize), StackPointerRegister);
+ }
+};
+
+typedef PlatformAssembler_ARM32 PlatformAssemblerBase;
+#endif
+
+class PlatformAssemblerCommon : public JIT::PlatformAssemblerBase
+{
+public:
+ PlatformAssemblerCommon(const Value *constantTable)
+ : constantTable(constantTable)
+ {}
+
+ virtual ~PlatformAssemblerCommon();
+
+ Address exceptionHandlerAddress() const
+ {
+ return Address(FramePointerRegister, -1 * PointerSize);
+ }
+
+ Address contextAddress() const
+ {
+ return Address(JSStackFrameRegister, offsetof(CallData, context));
+ }
+
+ RegisterID registerForArg(int arg) const
+ {
+ Q_ASSERT(arg >= 0);
+ Q_ASSERT(arg < ArgInRegCount);
+ switch (arg) {
+ case 0: return Arg0Reg;
+ case 1: return Arg1Reg;
+ case 2: return Arg2Reg;
+ case 3: return Arg3Reg;
+ case 4: return Arg4Reg;
+ case 5: return Arg5Reg;
+ case 6: return Arg6Reg;
+ case 7: return Arg7Reg;
+ default:
+ Q_UNIMPLEMENTED();
+ Q_UNREACHABLE();
+ }
+ }
+
+ Address loadFunctionPtr(RegisterID target)
+ {
+ Address addr(CppStackFrameRegister, offsetof(CppStackFrame, v4Function));
+ loadPtr(addr, target);
+ return Address(target);
+ }
+
+ Address loadCompilationUnitPtr(RegisterID target)
+ {
+ Address addr = loadFunctionPtr(target);
+ addr.offset = offsetof(QV4::Function, compilationUnit);
+ loadPtr(addr, target);
+ return Address(target);
+ }
+
+ Address loadConstAddress(int constIndex, RegisterID baseReg = ScratchRegister)
+ {
+ Address addr = loadCompilationUnitPtr(baseReg);
+ addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, constants);
+ loadPtr(addr, baseReg);
+ addr.offset = constIndex * int(sizeof(QV4::Value));
+ return addr;
+ }
+
+ Address loadStringAddress(int stringId)
+ {
+ Address addr = loadCompilationUnitPtr(ScratchRegister);
+ addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, runtimeStrings);
+ loadPtr(addr, ScratchRegister);
+ return Address(ScratchRegister, stringId * PointerSize);
+ }
+
+ void passAsArg(RegisterID src, int arg)
+ {
+ move(src, registerForArg(arg));
+ }
+
+ void generateCatchTrampoline(std::function<void()> loadUndefined)
+ {
+ for (Jump j : catchyJumps)
+ j.link(this);
+
+ loadPtr(exceptionHandlerAddress(), ScratchRegister);
+ Jump exitFunction = branchPtr(Equal, ScratchRegister, TrustedImmPtr(0));
+ jump(ScratchRegister);
+ exitFunction.link(this);
+ loadUndefined();
+
+ if (functionExit.isSet())
+ jump(functionExit);
+ else
+ generateFunctionExit();
+ }
+
+ void checkException()
+ {
+ addCatchyJump(
+ branch32(NotEqual,
+ Address(EngineRegister, offsetof(EngineBase, hasException)),
+ TrustedImm32(0)));
+ }
+
+ void addCatchyJump(Jump j)
+ {
+ Q_ASSERT(j.isSet());
+ catchyJumps.push_back(j);
+ }
+
+ void generateFunctionEntry()
+ {
+ generatePlatformFunctionEntry();
+ loadPtr(Address(CppStackFrameRegister, offsetof(CppStackFrame, jsFrame)), JSStackFrameRegister);
+ allocateStackSpace();
+ }
+
+ virtual void allocateStackSpace() {}
+
+ void generateFunctionExit()
+ {
+ if (functionExit.isSet()) {
+ jump(functionExit);
+ return;
+ }
+
+ functionExit = label();
+ freeStackSpace();
+ generatePlatformFunctionExit();
+ }
+
+ virtual void freeStackSpace() {}
+
+ void addLabelForOffset(int offset)
+ {
+ labelForOffset.insert(offset, label());
+ }
+
+ void addJumpToOffset(const Jump &jump, int offset)
+ {
+ jumpsToLink.push_back({ jump, offset });
+ }
+
+ void addEHTarget(const DataLabelPtr &label, int offset)
+ {
+ ehTargets.push_back({ label, offset });
+ }
+
+ void link(Function *function, const char *jitKind);
+
+ Value constant(int idx) const
+ { return constantTable[idx]; }
+
+ // stuff for runtime calls
+ void prepareCallWithArgCount(int argc);
+ void storeInstructionPointer(int instructionOffset);
+ void passAccumulatorAsArg(int arg);
+ void pushAccumulatorAsArg(int arg);
+ void passFunctionAsArg(int arg);
+ void passEngineAsArg(int arg);
+ void passJSSlotAsArg(int reg, int arg);
+ void passAddressAsArg(Address addr, int arg);
+ void passCppFrameAsArg(int arg);
+ void passInt32AsArg(int value, int arg);
+ void callRuntime(const char *functionName, const void *funcPtr);
+ void callRuntimeUnchecked(const char *functionName, const void *funcPtr);
+
+
+private:
+ void passAccumulatorAsArg_internal(int arg, bool doPush);
+ static Address argStackAddress(int arg);
+
+private:
+ const Value* constantTable;
+ struct JumpTarget { JSC::MacroAssemblerBase::Jump jump; int offset; };
+ std::vector<JumpTarget> jumpsToLink;
+ struct ExceptionHanlderTarget { JSC::MacroAssemblerBase::DataLabelPtr label; int offset; };
+ std::vector<ExceptionHanlderTarget> ehTargets;
+ QHash<int, JSC::MacroAssemblerBase::Label> labelForOffset;
+ QHash<const void *, const char *> functions;
+ std::vector<Jump> catchyJumps;
+ Label functionExit;
+
+#ifndef QT_NO_DEBUG
+ enum { NoCall = -1 };
+ int remainingArgcForCall = NoCall;
+#endif
+ int argcOnStackForCall = 0;
+};
+
+} // JIT namespace
+} // QV4 namespace
+
+QT_END_NAMESPACE
+
+#endif // V4_ENABLE_JIT
+
+#endif // QV4PLATFORMASSEMBLER_P_H
diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4baselineassembler.cpp
index 9786293e4c..d53bb84827 100644
--- a/src/qml/jit/qv4assembler.cpp
+++ b/src/qml/jit/qv4baselineassembler.cpp
@@ -41,9 +41,11 @@
#include <QFile>
#include "qv4engine_p.h"
-#include "qv4assembler_p.h"
+#include "qv4baselineassembler_p.h"
+#include "qv4assemblercommon_p.h"
#include <private/qv4function_p.h>
#include <private/qv4runtime_p.h>
+#include <private/qv4stackframe_p.h>
#include <wtf/Vector.h>
#include <assembler/MacroAssembler.h>
@@ -59,7 +61,9 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace JIT {
-#define callHelper(x) PlatformAssemblerCommon::callRuntime(#x, reinterpret_cast<void *>(&x))
+#define ASM_GENERATE_RUNTIME_CALL(function, destination) \
+ pasm()->GENERATE_RUNTIME_CALL(function, destination)
+#define callHelper(x) PlatformAssemblerCommon::callRuntimeUnchecked(#x, reinterpret_cast<void *>(&x))
const QV4::Value::ValueTypeInternal IntegerTag = QV4::Value::ValueTypeInternal::Integer;
@@ -73,568 +77,19 @@ static ReturnedValue toInt32Helper(ReturnedValue v)
return Encode(Value::fromReturnedValue(v).toInt32());
}
-#if defined(Q_PROCESSOR_X86_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-#if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD) || defined(Q_OS_DARWIN)
-
-struct PlatformAssembler_X86_64_SysV : JSC::MacroAssembler<JSC::MacroAssemblerX86_64>
-{
- static const RegisterID NoRegister = RegisterID(-1);
-
- static const RegisterID ReturnValueRegister = RegisterID::eax;
- static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
- static const RegisterID AccumulatorRegister = RegisterID::eax;
- static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
- static const RegisterID ScratchRegister = RegisterID::r10;
- static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg5Reg, so do not use while setting up a call!
- static const RegisterID JSStackFrameRegister = RegisterID::r12;
- static const RegisterID CppStackFrameRegister = RegisterID::r13;
- static const RegisterID EngineRegister = RegisterID::r14;
- static const RegisterID StackPointerRegister = RegisterID::esp;
- static const RegisterID FramePointerRegister = RegisterID::ebp;
- static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
-
- static const RegisterID Arg0Reg = RegisterID::edi;
- static const RegisterID Arg1Reg = RegisterID::esi;
- static const RegisterID Arg2Reg = RegisterID::edx;
- static const RegisterID Arg3Reg = RegisterID::ecx;
- static const RegisterID Arg4Reg = RegisterID::r8;
- static const RegisterID Arg5Reg = RegisterID::r9;
- static const RegisterID Arg6Reg = NoRegister;
- static const RegisterID Arg7Reg = NoRegister;
- static const int ArgInRegCount = 6;
-
- void popValue()
- {
- addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
- }
-
- void generatePlatformFunctionEntry()
- {
- push(RegisterID::ebp);
- move(RegisterID::esp, RegisterID::ebp);
- move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler
- push(JSStackFrameRegister);
- push(CppStackFrameRegister);
- push(EngineRegister);
- move(Arg0Reg, CppStackFrameRegister);
- move(Arg1Reg, EngineRegister);
- }
-
- void generatePlatformFunctionExit()
- {
- pop(EngineRegister);
- pop(CppStackFrameRegister);
- pop(JSStackFrameRegister);
- pop(); // exceptionHandler
- pop(RegisterID::ebp);
- ret();
- }
-
- void callAbsolute(const void *funcPtr)
- {
- move(TrustedImmPtr(funcPtr), ScratchRegister);
- call(ScratchRegister);
- }
-
- void pushAligned(RegisterID reg)
- {
- subPtr(TrustedImm32(PointerSize), StackPointerRegister);
- push(reg);
- }
-
- void popAligned(RegisterID reg)
- {
- pop(reg);
- addPtr(TrustedImm32(PointerSize), StackPointerRegister);
- }
-};
-
-typedef PlatformAssembler_X86_64_SysV PlatformAssemblerBase;
-
-#endif
-#if defined(Q_OS_WIN)
-
-struct PlatformAssembler_Win64 : JSC::MacroAssembler<JSC::MacroAssemblerX86_64>
-{
- static const RegisterID NoRegister = RegisterID(-1);
-
- static const RegisterID ReturnValueRegister = RegisterID::eax;
- static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
- static const RegisterID AccumulatorRegister = RegisterID::eax;
- static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
- static const RegisterID ScratchRegister = RegisterID::r10;
- static const RegisterID ScratchRegister2 = RegisterID::r9; // Note: overlaps with Arg3Reg, so do not use while setting up a call!
- static const RegisterID JSStackFrameRegister = RegisterID::r12;
- static const RegisterID CppStackFrameRegister = RegisterID::r13;
- static const RegisterID EngineRegister = RegisterID::r14;
- static const RegisterID StackPointerRegister = RegisterID::esp;
- static const RegisterID FramePointerRegister = RegisterID::ebp;
- static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
-
- static const RegisterID Arg0Reg = RegisterID::ecx;
- static const RegisterID Arg1Reg = RegisterID::edx;
- static const RegisterID Arg2Reg = RegisterID::r8;
- static const RegisterID Arg3Reg = RegisterID::r9;
- static const RegisterID Arg4Reg = NoRegister;
- static const RegisterID Arg5Reg = NoRegister;
- static const RegisterID Arg6Reg = NoRegister;
- static const RegisterID Arg7Reg = NoRegister;
- static const int ArgInRegCount = 4;
-
- void popValue()
- {
- addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
- }
-
- void generatePlatformFunctionEntry()
- {
- push(RegisterID::ebp);
- move(RegisterID::esp, RegisterID::ebp);
- move(TrustedImmPtr(nullptr), AccumulatorRegister); push(AccumulatorRegister); // exceptionHandler
- push(JSStackFrameRegister);
- push(CppStackFrameRegister);
- push(EngineRegister);
- move(Arg0Reg, CppStackFrameRegister);
- move(Arg1Reg, EngineRegister);
- }
-
- void generatePlatformFunctionExit()
- {
- pop(EngineRegister);
- pop(CppStackFrameRegister);
- pop(JSStackFrameRegister);
- pop(); // exceptionHandler
- pop(RegisterID::ebp);
- ret();
- }
-
- void callAbsolute(const void *funcPtr)
- {
- move(TrustedImmPtr(funcPtr), ScratchRegister);
- subPtr(TrustedImm32(4 * PointerSize), StackPointerRegister);
- call(ScratchRegister);
- addPtr(TrustedImm32(4 * PointerSize), StackPointerRegister);
- }
-
- void pushAligned(RegisterID reg)
- {
- subPtr(TrustedImm32(PointerSize), StackPointerRegister);
- push(reg);
- }
-
- void popAligned(RegisterID reg)
- {
- pop(reg);
- addPtr(TrustedImm32(PointerSize), StackPointerRegister);
- }
-};
-
-typedef PlatformAssembler_Win64 PlatformAssemblerBase;
-
-#endif
-#endif
-
-#if (defined(Q_PROCESSOR_X86) && !defined(Q_PROCESSOR_X86_64)) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-
-struct PlatformAssembler_X86_All : JSC::MacroAssembler<JSC::MacroAssemblerX86>
-{
- static const RegisterID NoRegister = RegisterID(-1);
-
- static const RegisterID ReturnValueRegisterValue = RegisterID::eax;
- static const RegisterID ReturnValueRegisterTag = RegisterID::edx;
- static const RegisterID ScratchRegister = RegisterID::ecx;
- static const RegisterID AccumulatorRegisterValue = ReturnValueRegisterValue;
- static const RegisterID AccumulatorRegisterTag = ReturnValueRegisterTag;
- static const RegisterID JSStackFrameRegister = RegisterID::ebx;
- static const RegisterID CppStackFrameRegister = RegisterID::esi;
- static const RegisterID EngineRegister = RegisterID::edi;
- static const RegisterID StackPointerRegister = RegisterID::esp;
- static const RegisterID FramePointerRegister = RegisterID::ebp;
- static const FPRegisterID FPScratchRegister = FPRegisterID::xmm1;
-
- static const RegisterID Arg0Reg = NoRegister;
- static const RegisterID Arg1Reg = NoRegister;
- static const RegisterID Arg2Reg = NoRegister;
- static const RegisterID Arg3Reg = NoRegister;
- static const RegisterID Arg4Reg = NoRegister;
- static const RegisterID Arg5Reg = NoRegister;
- static const RegisterID Arg6Reg = NoRegister;
- static const RegisterID Arg7Reg = NoRegister;
- static const int ArgInRegCount = 0;
-
- void popValue()
- {
- addPtr(TrustedImmPtr(sizeof(ReturnedValue)), StackPointerRegister);
- }
-
- void generatePlatformFunctionEntry()
- {
- push(RegisterID::ebp);
- move(RegisterID::esp, RegisterID::ebp);
- move(TrustedImmPtr(nullptr), AccumulatorRegisterValue); push(AccumulatorRegisterValue); // exceptionHandler
- push(JSStackFrameRegister);
- push(CppStackFrameRegister);
- push(EngineRegister);
- // Ensure the stack is 16-byte aligned in order for compiler generated aligned SSE2
- // instructions to be able to target the stack.
- subPtr(TrustedImm32(8), StackPointerRegister);
- loadPtr(Address(FramePointerRegister, 2 * PointerSize), CppStackFrameRegister);
- loadPtr(Address(FramePointerRegister, 3 * PointerSize), EngineRegister);
- }
-
- void generatePlatformFunctionExit()
- {
- addPtr(TrustedImm32(8), StackPointerRegister);
- pop(EngineRegister);
- pop(CppStackFrameRegister);
- pop(JSStackFrameRegister);
- pop(); // exceptionHandler
- pop(RegisterID::ebp);
- ret();
- }
-
- void callAbsolute(const void *funcPtr)
- {
- move(TrustedImmPtr(funcPtr), ScratchRegister);
- call(ScratchRegister);
- }
-
- void pushAligned(RegisterID reg)
- {
- subPtr(TrustedImm32(PointerSize), StackPointerRegister);
- push(reg);
- }
-
- void popAligned(RegisterID reg)
- {
- pop(reg);
- addPtr(TrustedImm32(PointerSize), StackPointerRegister);
- }
-};
-
-typedef PlatformAssembler_X86_All PlatformAssemblerBase;
-
-#endif
-
-#if defined(Q_PROCESSOR_ARM_64) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-
-struct PlatformAssembler_ARM64 : JSC::MacroAssembler<JSC::MacroAssemblerARM64>
-{
- static const RegisterID NoRegister = RegisterID(-1);
-
- static const RegisterID ReturnValueRegister = JSC::ARM64Registers::x0;
- static const RegisterID ReturnValueRegisterValue = ReturnValueRegister;
- static const RegisterID AccumulatorRegister = JSC::ARM64Registers::x9;
- static const RegisterID AccumulatorRegisterValue = AccumulatorRegister;
- static const RegisterID ScratchRegister = JSC::ARM64Registers::x10;
- static const RegisterID ScratchRegister2 = JSC::ARM64Registers::x7; // Note: overlaps with Arg7Reg, so do not use while setting up a call!
- static const RegisterID JSStackFrameRegister = JSC::ARM64Registers::x19;
- static const RegisterID CppStackFrameRegister = JSC::ARM64Registers::x20;
- static const RegisterID EngineRegister = JSC::ARM64Registers::x21;
- static const RegisterID StackPointerRegister = JSC::ARM64Registers::sp;
- static const RegisterID FramePointerRegister = JSC::ARM64Registers::fp;
- static const FPRegisterID FPScratchRegister = JSC::ARM64Registers::q1;
-
- static const RegisterID Arg0Reg = JSC::ARM64Registers::x0;
- static const RegisterID Arg1Reg = JSC::ARM64Registers::x1;
- static const RegisterID Arg2Reg = JSC::ARM64Registers::x2;
- static const RegisterID Arg3Reg = JSC::ARM64Registers::x3;
- static const RegisterID Arg4Reg = JSC::ARM64Registers::x4;
- static const RegisterID Arg5Reg = JSC::ARM64Registers::x5;
- static const RegisterID Arg6Reg = JSC::ARM64Registers::x6;
- static const RegisterID Arg7Reg = JSC::ARM64Registers::x7;
- static const int ArgInRegCount = 8;
-
- void push(RegisterID src)
- {
- pushToSave(src);
- }
-
- void pop(RegisterID dest)
- {
- popToRestore(dest);
- }
-
- void pop()
- {
- add64(TrustedImm32(16), stackPointerRegister);
- }
-
- void popValue()
- {
- pop();
- }
-
- void generatePlatformFunctionEntry()
- {
- pushPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr);
- move(RegisterID::sp, RegisterID::fp);
- move(TrustedImmPtr(nullptr), AccumulatorRegister); // exceptionHandler
- pushPair(JSStackFrameRegister, AccumulatorRegister);
- pushPair(EngineRegister, CppStackFrameRegister);
- move(Arg0Reg, CppStackFrameRegister);
- move(Arg1Reg, EngineRegister);
- }
-
- void generatePlatformFunctionExit()
- {
- move(AccumulatorRegister, ReturnValueRegister);
- popPair(EngineRegister, CppStackFrameRegister);
- popPair(JSStackFrameRegister, AccumulatorRegister);
- popPair(JSC::ARM64Registers::fp, JSC::ARM64Registers::lr);
- ret();
- }
-
- void callAbsolute(const void *funcPtr)
- {
- move(TrustedImmPtr(funcPtr), ScratchRegister);
- call(ScratchRegister);
- }
-
- void pushAligned(RegisterID reg)
- {
- pushToSave(reg);
- }
-
- void popAligned(RegisterID reg)
- {
- popToRestore(reg);
- }
-};
-
-typedef PlatformAssembler_ARM64 PlatformAssemblerBase;
-
-#endif
-
-#if defined(Q_PROCESSOR_ARM_32) || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-
-struct PlatformAssembler_ARM32 : JSC::MacroAssembler<JSC::MacroAssemblerARMv7>
-{
- static const RegisterID NoRegister = RegisterID(-1);
-
- static const RegisterID ReturnValueRegisterValue = JSC::ARMRegisters::r0;
- static const RegisterID ReturnValueRegisterTag = JSC::ARMRegisters::r1;
- static const RegisterID ScratchRegister = JSC::ARMRegisters::r2;
- static const RegisterID AccumulatorRegisterValue = JSC::ARMRegisters::r4;
- static const RegisterID AccumulatorRegisterTag = JSC::ARMRegisters::r5;
- // r6 is used by MacroAssemblerARMv7
- static const RegisterID JSStackFrameRegister = JSC::ARMRegisters::r8;
- static const RegisterID CppStackFrameRegister = JSC::ARMRegisters::r10;
-#if CPU(ARM_THUMB2) || defined(V4_BOOTSTRAP)
- static const RegisterID FramePointerRegister = JSC::ARMRegisters::r7;
- static const RegisterID EngineRegister = JSC::ARMRegisters::r11;
-#else // Thumbs down
- static const RegisterID FramePointerRegister = JSC::ARMRegisters::r11;
- static const RegisterID EngineRegister = JSC::ARMRegisters::r7;
-#endif
- static const RegisterID StackPointerRegister = JSC::ARMRegisters::r13;
- static const FPRegisterID FPScratchRegister = JSC::ARMRegisters::d1;
-
- static const RegisterID Arg0Reg = JSC::ARMRegisters::r0;
- static const RegisterID Arg1Reg = JSC::ARMRegisters::r1;
- static const RegisterID Arg2Reg = JSC::ARMRegisters::r2;
- static const RegisterID Arg3Reg = JSC::ARMRegisters::r3;
- static const RegisterID Arg4Reg = NoRegister;
- static const RegisterID Arg5Reg = NoRegister;
- static const RegisterID Arg6Reg = NoRegister;
- static const RegisterID Arg7Reg = NoRegister;
- static const int ArgInRegCount = 4;
-
- void popValue()
- {
- addPtr(TrustedImm32(sizeof(ReturnedValue)), StackPointerRegister);
- }
-
- void generatePlatformFunctionEntry()
- {
- push(JSC::ARMRegisters::lr);
- push(FramePointerRegister);
- move(StackPointerRegister, FramePointerRegister);
- push(TrustedImm32(0)); // exceptionHandler
- push(AccumulatorRegisterValue);
- push(AccumulatorRegisterTag);
- push(addressTempRegister);
- push(JSStackFrameRegister);
- push(CppStackFrameRegister);
- push(EngineRegister);
- subPtr(TrustedImm32(4), StackPointerRegister); // stack alignment
- move(Arg0Reg, CppStackFrameRegister);
- move(Arg1Reg, EngineRegister);
- }
-
- void generatePlatformFunctionExit()
- {
- move(AccumulatorRegisterValue, ReturnValueRegisterValue);
- move(AccumulatorRegisterTag, ReturnValueRegisterTag);
- addPtr(TrustedImm32(4), StackPointerRegister); // stack alignment
- pop(EngineRegister);
- pop(CppStackFrameRegister);
- pop(JSStackFrameRegister);
- pop(addressTempRegister);
- pop(AccumulatorRegisterTag);
- pop(AccumulatorRegisterValue);
- pop(); // exceptionHandler
- pop(FramePointerRegister);
- pop(JSC::ARMRegisters::lr);
- ret();
- }
-
- void callAbsolute(const void *funcPtr)
- {
- move(TrustedImmPtr(funcPtr), dataTempRegister);
- call(dataTempRegister);
- }
-
- void pushAligned(RegisterID reg)
- {
- subPtr(TrustedImm32(PointerSize), StackPointerRegister);
- push(reg);
- }
-
- void popAligned(RegisterID reg)
- {
- pop(reg);
- addPtr(TrustedImm32(PointerSize), StackPointerRegister);
- }
-};
-
-typedef PlatformAssembler_ARM32 PlatformAssemblerBase;
-
-#endif
-
-struct PlatformAssemblerCommon : PlatformAssemblerBase
-{
- const Value* constantTable;
- struct JumpTarget { JSC::MacroAssemblerBase::Jump jump; int offset; };
- std::vector<JumpTarget> patches;
- struct ExceptionHanlderTarget { JSC::MacroAssemblerBase::DataLabelPtr label; int offset; };
- std::vector<ExceptionHanlderTarget> ehTargets;
- QHash<int, JSC::MacroAssemblerBase::Label> labelsByOffset;
- QHash<const void *, const char *> functions;
- std::vector<Jump> catchyJumps;
- Label functionExit;
-
- Address exceptionHandlerAddress() const
- {
- return Address(FramePointerRegister, -1 * PointerSize);
- }
-
- Address contextAddress() const
- {
- return Address(JSStackFrameRegister, offsetof(CallData, context));
- }
-
- RegisterID registerForArg(int arg) const
- {
- Q_ASSERT(arg >= 0);
- Q_ASSERT(arg < ArgInRegCount);
- switch (arg) {
- case 0: return Arg0Reg;
- case 1: return Arg1Reg;
- case 2: return Arg2Reg;
- case 3: return Arg3Reg;
- case 4: return Arg4Reg;
- case 5: return Arg5Reg;
- case 6: return Arg6Reg;
- case 7: return Arg7Reg;
- default:
- Q_UNIMPLEMENTED();
- Q_UNREACHABLE();
- }
- }
-
- void callRuntime(const char *functionName, const void *funcPtr)
- {
- functions.insert(funcPtr, functionName);
- callAbsolute(funcPtr);
- }
-
- Address loadFunctionPtr(RegisterID target)
- {
- Address addr(CppStackFrameRegister, offsetof(CppStackFrame, v4Function));
- loadPtr(addr, target);
- return Address(target);
- }
-
- Address loadCompilationUnitPtr(RegisterID target)
- {
- Address addr = loadFunctionPtr(target);
- addr.offset = offsetof(QV4::Function, compilationUnit);
- loadPtr(addr, target);
- return Address(target);
- }
-
- Address loadConstAddress(int constIndex, RegisterID baseReg = ScratchRegister)
- {
- Address addr = loadCompilationUnitPtr(baseReg);
- addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, constants);
- loadPtr(addr, baseReg);
- addr.offset = constIndex * int(sizeof(QV4::Value));
- return addr;
- }
-
- Address loadStringAddress(int stringId)
- {
- Address addr = loadCompilationUnitPtr(ScratchRegister);
- addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, runtimeStrings);
- loadPtr(addr, ScratchRegister);
- return Address(ScratchRegister, stringId * PointerSize);
- }
-
- void passAsArg(RegisterID src, int arg)
- {
- move(src, registerForArg(arg));
- }
-
- void generateCatchTrampoline(std::function<void()> loadUndefined)
- {
- for (Jump j : catchyJumps)
- j.link(this);
-
- loadPtr(exceptionHandlerAddress(), ScratchRegister);
- Jump exitFunction = branchPtr(Equal, ScratchRegister, TrustedImmPtr(0));
- jump(ScratchRegister);
- exitFunction.link(this);
- loadUndefined();
-
- if (functionExit.isSet())
- jump(functionExit);
- else
- generateFunctionExit();
- }
-
- void addCatchyJump(Jump j)
- {
- Q_ASSERT(j.isSet());
- catchyJumps.push_back(j);
- }
-
- void generateFunctionEntry()
- {
- generatePlatformFunctionEntry();
- loadPtr(Address(CppStackFrameRegister, offsetof(CppStackFrame, jsFrame)), JSStackFrameRegister);
- }
-
- void generateFunctionExit()
- {
- if (functionExit.isSet()) {
- jump(functionExit);
- return;
- }
-
- functionExit = label();
- generatePlatformFunctionExit();
- }
-};
-
#if QT_POINTER_SIZE == 8 || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-struct PlatformAssembler64 : PlatformAssemblerCommon
+class PlatformAssembler64 : public PlatformAssemblerCommon
{
+public:
+ PlatformAssembler64(const Value *constantTable)
+ : PlatformAssemblerCommon(constantTable)
+ {}
+
void callRuntime(const char *functionName, const void *funcPtr,
- Assembler::CallResultDestination dest)
+ CallResultDestination dest)
{
PlatformAssemblerCommon::callRuntime(functionName, funcPtr);
- if (dest == Assembler::ResultInAccumulator)
+ if (dest == CallResultDestination::InAccumulator)
saveReturnValueInAccumulator();
}
@@ -651,7 +106,7 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
void copyConst(int constIndex, Address dest)
{
//###
- if (constantTable[constIndex].isUndefined()) {
+ if (constant(constIndex).isUndefined()) {
loadUndefined(ScratchRegister);
} else {
load64(loadConstAddress(constIndex, ScratchRegister), ScratchRegister);
@@ -680,6 +135,12 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
store64(AccumulatorRegister, addr);
}
+ void moveReg(Address sourceRegAddress, Address destRegAddress)
+ {
+ load64(sourceRegAddress, ScratchRegister);
+ store64(ScratchRegister, destRegAddress);
+ }
+
void loadString(int stringId)
{
loadAccumulator(loadStringAddress(stringId));
@@ -700,6 +161,22 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
PlatformAssemblerCommon::generateCatchTrampoline([this](){loadUndefined();});
}
+ void jumpNotUndefined(int offset)
+ {
+ auto jump = branch64(NotEqual, AccumulatorRegister, TrustedImm64(0));
+ addJumpToOffset(jump, offset);
+ }
+
+ Jump jumpEmpty()
+ {
+ return branch64(Equal, AccumulatorRegister, TrustedImm64(Value::emptyValue().asReturnedValue()));
+ }
+
+ Jump jumpNotEmpty()
+ {
+ return branch64(NotEqual, AccumulatorRegister, TrustedImm64(Value::emptyValue().asReturnedValue()));
+ }
+
void toBoolean(std::function<void(RegisterID)> continuation)
{
urshift64(AccumulatorRegister, TrustedImm32(Value::IsIntegerConvertible_Shift), ScratchRegister);
@@ -762,8 +239,8 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
auto isInt = branch32(Equal, TrustedImm32(Value::QT_Int), ScratchRegister2);
move(AccumulatorRegister, registerForArg(0));
- callRuntime("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper),
- Assembler::ResultInAccumulator);
+ callRuntimeUnchecked("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper));
+ saveReturnValueInAccumulator();
isInt.link(this);
}
@@ -809,7 +286,7 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
load64(lhsAddr, ScratchRegister);
Jump isUndef = branch64(Equal, ScratchRegister, TrustedImm64(0));
Jump equal = branch32(Equal, TrustedImm32(rhs), ScratchRegister);
- patches.push_back({ equal, offset });
+ addJumpToOffset(equal, offset);
isUndef.link(this);
}
@@ -818,9 +295,9 @@ struct PlatformAssembler64 : PlatformAssemblerCommon
Address lhsAddr(JSStackFrameRegister, lhs * int(sizeof(Value)));
load64(lhsAddr, ScratchRegister);
Jump isUndef = branch64(Equal, ScratchRegister, TrustedImm64(0));
- patches.push_back({ isUndef, offset });
+ addJumpToOffset(isUndef, offset);
Jump notEqual = branch32(NotEqual, TrustedImm32(rhs), ScratchRegister);
- patches.push_back({ notEqual, offset });
+ addJumpToOffset(notEqual, offset);
}
void setAccumulatorTag(QV4::Value::ValueTypeInternal tag, RegisterID sourceReg = NoRegister)
@@ -898,13 +375,18 @@ typedef PlatformAssembler64 PlatformAssembler;
#endif
#if QT_POINTER_SIZE == 4 || defined(ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES)
-struct PlatformAssembler32 : PlatformAssemblerCommon
+class PlatformAssembler32 : public PlatformAssemblerCommon
{
+public:
+ PlatformAssembler32(const Value *constantTable)
+ : PlatformAssemblerCommon(constantTable)
+ {}
+
void callRuntime(const char *functionName, const void *funcPtr,
- Assembler::CallResultDestination dest)
+ CallResultDestination dest)
{
PlatformAssemblerCommon::callRuntime(functionName, funcPtr);
- if (dest == Assembler::ResultInAccumulator)
+ if (dest == CallResultDestination::InAccumulator)
saveReturnValueInAccumulator();
}
@@ -923,7 +405,7 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
void copyConst(int constIndex, Address destRegAddr)
{
//###
- if (constantTable[constIndex].isUndefined()) {
+ if (constant(constIndex).isUndefined()) {
move(TrustedImm32(0), ScratchRegister);
store32(ScratchRegister, destRegAddr);
destRegAddr.offset += 4;
@@ -960,6 +442,16 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
store32(AccumulatorRegisterTag, addr);
}
+ void moveReg(Address sourceRegAddress, Address destRegAddress)
+ {
+ load32(sourceRegAddress, ReturnValueRegisterValue);
+ sourceRegAddress.offset += 4;
+ load32(sourceRegAddress, ReturnValueRegisterTag);
+ store32(ReturnValueRegisterValue, destRegAddress);
+ destRegAddress.offset += 4;
+ store32(ReturnValueRegisterTag, destRegAddress);
+ }
+
void loadString(int stringId)
{
load32(loadStringAddress(stringId), AccumulatorRegisterValue);
@@ -997,8 +489,7 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
move(AccumulatorRegisterValue, registerForArg(0));
move(AccumulatorRegisterTag, registerForArg(1));
}
- callRuntime("toNumberHelper", reinterpret_cast<void *>(&toNumberHelper),
- Assembler::ResultInAccumulator);
+ callRuntimeUnchecked("toNumberHelper", reinterpret_cast<void *>(&toNumberHelper));
saveReturnValueInAccumulator();
if (ArgInRegCount < 2)
addPtr(TrustedImm32(2 * PointerSize), StackPointerRegister);
@@ -1050,8 +541,8 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
move(AccumulatorRegisterValue, registerForArg(0));
move(AccumulatorRegisterTag, registerForArg(1));
}
- callRuntime("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper),
- Assembler::ResultInAccumulator);
+ callRuntimeUnchecked("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper));
+ saveReturnValueInAccumulator();
if (ArgInRegCount < 2)
addPtr(TrustedImm32(2 * PointerSize), StackPointerRegister);
popAligned(lhsTarget);
@@ -1071,8 +562,8 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
move(AccumulatorRegisterValue, registerForArg(0));
move(AccumulatorRegisterTag, registerForArg(1));
}
- callRuntime("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper),
- Assembler::ResultInAccumulator);
+ callRuntimeUnchecked("toInt32Helper", reinterpret_cast<void *>(&toInt32Helper));
+ saveReturnValueInAccumulator();
if (ArgInRegCount < 2)
addPtr(TrustedImm32(2 * PointerSize), StackPointerRegister);
@@ -1135,6 +626,24 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
push(TrustedImm32(v));
}
+ void jumpNotUndefined(int offset)
+ {
+ move(AccumulatorRegisterTag, ScratchRegister);
+ or32(AccumulatorRegisterValue, ScratchRegister);
+ auto jump = branch32(NotEqual, ScratchRegister, TrustedImm32(0));
+ addJumpToOffset(jump, offset);
+ }
+
+ Jump jumpEmpty()
+ {
+ return branch32(Equal, AccumulatorRegisterTag, TrustedImm32(Value::emptyValue().asReturnedValue() >> 32));
+ }
+
+ Jump jumpNotEmpty()
+ {
+ return branch32(NotEqual, AccumulatorRegisterTag, TrustedImm32(Value::emptyValue().asReturnedValue() >> 32));
+ }
+
void toBoolean(std::function<void(RegisterID)> continuation)
{
urshift32(AccumulatorRegisterTag, TrustedImm32(Value::IsIntegerConvertible_Shift - 32),
@@ -1180,11 +689,11 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
load32(lhsAddr, ScratchRegister);
Jump notEqInt = branch32(NotEqual, ScratchRegister, TrustedImm32(rhs));
Jump notEqUndefVal = branch32(NotEqual, ScratchRegister, TrustedImm32(0));
- patches.push_back({ notEqUndefVal, offset });
+ addJumpToOffset(notEqUndefVal, offset);
lhsAddr.offset += 4;
load32(lhsAddr, ScratchRegister);
Jump notEqUndefTag = branch32(NotEqual, ScratchRegister, TrustedImm32(0));
- patches.push_back({ notEqUndefTag, offset });
+ addJumpToOffset(notEqUndefTag, offset);
notEqInt.link(this);
}
@@ -1193,12 +702,12 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
Address lhsAddr(JSStackFrameRegister, lhs * int(sizeof(Value)));
load32(lhsAddr, ScratchRegister);
Jump notEqual = branch32(NotEqual, TrustedImm32(rhs), ScratchRegister);
- patches.push_back({ notEqual, offset });
+ addJumpToOffset(notEqual, offset);
Jump notUndefValue = branch32(NotEqual, TrustedImm32(0), ScratchRegister);
lhsAddr.offset += 4;
load32(lhsAddr, ScratchRegister);
Jump equalUndef = branch32(Equal, TrustedImm32(0), ScratchRegister);
- patches.push_back({ equalUndef, offset });
+ addJumpToOffset(equalUndef, offset);
notUndefValue.link(this);
}
@@ -1281,6 +790,8 @@ struct PlatformAssembler32 : PlatformAssemblerCommon
typedef PlatformAssembler32 PlatformAssembler;
#endif
+#define pasm() reinterpret_cast<PlatformAssembler *>(this->d)
+
typedef PlatformAssembler::TrustedImmPtr TrustedImmPtr;
typedef PlatformAssembler::TrustedImm32 TrustedImm32;
typedef PlatformAssembler::TrustedImm64 TrustedImm64;
@@ -1288,193 +799,72 @@ typedef PlatformAssembler::Address Address;
typedef PlatformAssembler::RegisterID RegisterID;
typedef PlatformAssembler::FPRegisterID FPRegisterID;
-#define pasm() reinterpret_cast<PlatformAssembler *>(this->d)
-
static Address regAddr(int reg)
{
return Address(PlatformAssembler::JSStackFrameRegister, reg * int(sizeof(QV4::Value)));
}
-Assembler::Assembler(const Value *constantTable)
- : d(new PlatformAssembler)
+BaselineAssembler::BaselineAssembler(const Value *constantTable)
+ : d(new PlatformAssembler(constantTable))
{
- pasm()->constantTable = constantTable;
}
-Assembler::~Assembler()
+BaselineAssembler::~BaselineAssembler()
{
delete pasm();
}
-void Assembler::generatePrologue()
+void BaselineAssembler::generatePrologue()
{
pasm()->generateFunctionEntry();
}
-void Assembler::generateEpilogue()
+void BaselineAssembler::generateEpilogue()
{
pasm()->generateCatchTrampoline();
}
-namespace {
-class QIODevicePrintStream: public FilePrintStream
-{
- Q_DISABLE_COPY(QIODevicePrintStream)
-
-public:
- explicit QIODevicePrintStream(QIODevice *dest)
- : FilePrintStream(nullptr)
- , dest(dest)
- , buf(4096, '0')
- {
- Q_ASSERT(dest);
- }
-
- ~QIODevicePrintStream()
- {}
-
- void vprintf(const char* format, va_list argList) WTF_ATTRIBUTE_PRINTF(2, 0)
- {
- const int written = qvsnprintf(buf.data(), buf.size(), format, argList);
- if (written > 0)
- dest->write(buf.constData(), written);
- memset(buf.data(), 0, qMin(written, buf.size()));
- }
-
- void flush()
- {}
-
-private:
- QIODevice *dest;
- QByteArray buf;
-};
-} // anonymous namespace
-
-static void printDisassembledOutputWithCalls(QByteArray processedOutput,
- const QHash<const void*, const char*>& functions)
-{
- for (QHash<const void*, const char*>::ConstIterator it = functions.begin(), end = functions.end();
- it != end; ++it) {
- const QByteArray ptrString = "0x" + QByteArray::number(quintptr(it.key()), 16);
- int idx = 0;
- while (idx >= 0) {
- idx = processedOutput.indexOf(ptrString, idx);
- if (idx < 0)
- break;
- idx = processedOutput.indexOf('\n', idx);
- if (idx < 0)
- break;
- processedOutput = processedOutput.insert(idx, QByteArrayLiteral(" ; ") + it.value());
- }
- }
-
- qDebug("%s", processedOutput.constData());
-}
-
-static QByteArray functionName(Function *function)
-{
- QByteArray name = function->name()->toQString().toUtf8();
- if (name.isEmpty()) {
- name = QByteArray::number(reinterpret_cast<quintptr>(function), 16);
- name.prepend("QV4::Function(0x");
- name.append(')');
- }
- return name;
-}
-
-void Assembler::link(Function *function)
+void BaselineAssembler::link(Function *function)
{
- for (const auto &jumpTarget : pasm()->patches)
- jumpTarget.jump.linkTo(pasm()->labelsByOffset[jumpTarget.offset], pasm());
-
- JSC::JSGlobalData dummy(function->internalClass->engine->executableAllocator);
- JSC::LinkBuffer<PlatformAssembler::MacroAssembler> linkBuffer(dummy, pasm(), nullptr);
-
- for (const auto &ehTarget : pasm()->ehTargets) {
- auto targetLabel = pasm()->labelsByOffset.value(ehTarget.offset);
- linkBuffer.patch(ehTarget.label, linkBuffer.locationOf(targetLabel));
- }
-
- JSC::MacroAssemblerCodeRef codeRef;
-
- static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_ASM");
- if (showCode) {
- QBuffer buf;
- buf.open(QIODevice::WriteOnly);
- WTF::setDataFile(new QIODevicePrintStream(&buf));
-
- QByteArray name = functionName(function);
- codeRef = linkBuffer.finalizeCodeWithDisassembly("%s", name.data());
-
- WTF::setDataFile(stderr);
- printDisassembledOutputWithCalls(buf.data(), pasm()->functions);
- } else {
- codeRef = linkBuffer.finalizeCodeWithoutDisassembly();
- }
-
- function->codeRef = new JSC::MacroAssemblerCodeRef(codeRef);
- function->jittedCode = reinterpret_cast<Function::JittedCode>(function->codeRef->code().executableAddress());
-
-#if defined(Q_OS_LINUX)
- // This implements writing of JIT'd addresses so that perf can find the
- // symbol names.
- //
- // Perf expects the mapping to be in a certain place and have certain
- // content, for more information, see:
- // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
- static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
- if (doProfile) {
- static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
- .arg(QCoreApplication::applicationPid()));
- static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
- if (!isOpen) {
- qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
- doProfile = false;
- } else {
- perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(
- codeRef.code().executableAddress()), 16));
- perfMapFile.putChar(' ');
- perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef.size()), 16));
- perfMapFile.putChar(' ');
- perfMapFile.write(functionName(function));
- perfMapFile.putChar('\n');
- perfMapFile.flush();
- }
- }
-#endif
+ pasm()->link(function, "BaselineJIT");
}
-void Assembler::addLabel(int offset)
+void BaselineAssembler::addLabel(int offset)
{
- pasm()->labelsByOffset[offset] = pasm()->label();
+ pasm()->addLabelForOffset(offset);
}
-void Assembler::loadConst(int constIndex)
+void BaselineAssembler::loadConst(int constIndex)
{
//###
- if (pasm()->constantTable[constIndex].isUndefined()) {
+ if (pasm()->constant(constIndex).isUndefined()) {
pasm()->loadUndefined();
} else {
pasm()->loadAccumulator(pasm()->loadConstAddress(constIndex));
}
}
-void Assembler::copyConst(int constIndex, int destReg)
+void BaselineAssembler::copyConst(int constIndex, int destReg)
{
pasm()->copyConst(constIndex, regAddr(destReg));
}
-void Assembler::loadReg(int reg)
+void BaselineAssembler::loadReg(int reg)
{
pasm()->loadAccumulator(regAddr(reg));
}
-void Assembler::storeReg(int reg)
+void JIT::BaselineAssembler::moveReg(int sourceReg, int destReg)
+{
+ pasm()->moveReg(regAddr(sourceReg), regAddr(destReg));
+}
+
+void BaselineAssembler::storeReg(int reg)
{
pasm()->storeAccumulator(regAddr(reg));
}
-void Assembler::loadLocal(int index, int level)
+void BaselineAssembler::loadLocal(int index, int level)
{
Heap::CallContext ctx;
Q_UNUSED(ctx)
@@ -1486,7 +876,7 @@ void Assembler::loadLocal(int index, int level)
pasm()->loadAccumulator(Address(PlatformAssembler::ScratchRegister, ctx.locals.offset + offsetof(ValueArray<0>, values) + sizeof(Value)*index));
}
-void Assembler::storeLocal(int index, int level)
+void BaselineAssembler::storeLocal(int index, int level)
{
Heap::CallContext ctx;
Q_UNUSED(ctx)
@@ -1498,36 +888,46 @@ void Assembler::storeLocal(int index, int level)
pasm()->storeAccumulator(Address(PlatformAssembler::ScratchRegister, ctx.locals.offset + offsetof(ValueArray<0>, values) + sizeof(Value)*index));
}
-void Assembler::loadString(int stringId)
+void BaselineAssembler::loadString(int stringId)
{
pasm()->loadString(stringId);
}
-void Assembler::loadValue(ReturnedValue value)
+void BaselineAssembler::loadValue(ReturnedValue value)
{
pasm()->loadValue(value);
}
-void JIT::Assembler::storeHeapObject(int reg)
+void BaselineAssembler::storeHeapObject(int reg)
{
pasm()->storeHeapObject(PlatformAssembler::ReturnValueRegisterValue, regAddr(reg));
}
-void Assembler::toNumber()
+void BaselineAssembler::loadImport(int index)
+{
+ Address addr = pasm()->loadCompilationUnitPtr(PlatformAssembler::ScratchRegister);
+ addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, imports);
+ pasm()->loadPtr(addr, PlatformAssembler::ScratchRegister);
+ addr.offset = index * int(sizeof(QV4::Value*));
+ pasm()->loadPtr(addr, PlatformAssembler::ScratchRegister);
+ pasm()->loadAccumulator(Address(PlatformAssembler::ScratchRegister));
+}
+
+void BaselineAssembler::toNumber()
{
pasm()->toNumber();
}
-void Assembler::uminus()
+void BaselineAssembler::uminus()
{
saveAccumulatorInFrame();
- prepareCallWithArgCount(1);
- passAccumulatorAsArg(0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_uMinus, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(1);
+ pasm()->passAccumulatorAsArg(0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_uMinus, CallResultDestination::InAccumulator);
checkException();
}
-void Assembler::ucompl()
+void BaselineAssembler::ucompl()
{
pasm()->toInt32();
pasm()->xor32(TrustedImm32(-1), PlatformAssembler::AccumulatorRegisterValue);
@@ -1544,7 +944,7 @@ static ReturnedValue incHelper(const Value v)
return Encode(d + 1.);
}
-void Assembler::inc()
+void BaselineAssembler::inc()
{
auto done = pasm()->unopIntPath([this](){
auto overflowed = pasm()->branchAdd32(PlatformAssembler::Overflow,
@@ -1576,7 +976,7 @@ static ReturnedValue decHelper(const Value v)
return Encode(d - 1.);
}
-void Assembler::dec()
+void BaselineAssembler::dec()
{
auto done = pasm()->unopIntPath([this](){
auto overflowed = pasm()->branchSub32(PlatformAssembler::Overflow,
@@ -1598,7 +998,7 @@ void Assembler::dec()
done.link(pasm());
}
-void Assembler::unot()
+void BaselineAssembler::unot()
{
pasm()->toBoolean([this](PlatformAssembler::RegisterID resultReg){
pasm()->compare32(PlatformAssembler::Equal, resultReg,
@@ -1607,7 +1007,7 @@ void Assembler::unot()
});
}
-void Assembler::add(int lhs)
+void BaselineAssembler::add(int lhs)
{
auto done = pasm()->binopBothIntPath(regAddr(lhs), [this](){
auto overflowed = pasm()->branchAdd32(PlatformAssembler::Overflow,
@@ -1620,18 +1020,18 @@ void Assembler::add(int lhs)
// slow path:
saveAccumulatorInFrame();
- prepareCallWithArgCount(3);
- passAccumulatorAsArg(2);
- passRegAsArg(lhs, 1);
- passEngineAsArg(0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_add, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(3);
+ pasm()->passAccumulatorAsArg(2);
+ pasm()->passJSSlotAsArg(lhs, 1);
+ pasm()->passEngineAsArg(0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_add, CallResultDestination::InAccumulator);
checkException();
// done.
done.link(pasm());
}
-void Assembler::bitAnd(int lhs)
+void BaselineAssembler::bitAnd(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1639,7 +1039,7 @@ void Assembler::bitAnd(int lhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::bitOr(int lhs)
+void BaselineAssembler::bitOr(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1647,7 +1047,7 @@ void Assembler::bitOr(int lhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::bitXor(int lhs)
+void BaselineAssembler::bitXor(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1655,7 +1055,7 @@ void Assembler::bitXor(int lhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::ushr(int lhs)
+void BaselineAssembler::ushr(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1676,7 +1076,7 @@ void Assembler::ushr(int lhs)
done.link(pasm());
}
-void Assembler::shr(int lhs)
+void BaselineAssembler::shr(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1686,7 +1086,7 @@ void Assembler::shr(int lhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::shl(int lhs)
+void BaselineAssembler::shl(int lhs)
{
PlatformAssembler::Address lhsAddr = regAddr(lhs);
pasm()->toInt32LhsAcc(lhsAddr, PlatformAssembler::ScratchRegister);
@@ -1696,28 +1096,28 @@ void Assembler::shl(int lhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::bitAndConst(int rhs)
+void BaselineAssembler::bitAndConst(int rhs)
{
pasm()->toInt32();
pasm()->and32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue);
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::bitOrConst(int rhs)
+void BaselineAssembler::bitOrConst(int rhs)
{
pasm()->toInt32();
pasm()->or32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue);
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::bitXorConst(int rhs)
+void BaselineAssembler::bitXorConst(int rhs)
{
pasm()->toInt32();
pasm()->xor32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue);
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::ushrConst(int rhs)
+void BaselineAssembler::ushrConst(int rhs)
{
rhs &= 0x1f;
pasm()->toInt32();
@@ -1742,7 +1142,7 @@ void Assembler::ushrConst(int rhs)
}
}
-void Assembler::shrConst(int rhs)
+void BaselineAssembler::shrConst(int rhs)
{
rhs &= 0x1f;
pasm()->toInt32();
@@ -1751,7 +1151,7 @@ void Assembler::shrConst(int rhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::shlConst(int rhs)
+void BaselineAssembler::shlConst(int rhs)
{
rhs &= 0x1f;
pasm()->toInt32();
@@ -1760,7 +1160,7 @@ void Assembler::shlConst(int rhs)
pasm()->setAccumulatorTag(IntegerTag);
}
-void Assembler::mul(int lhs)
+void BaselineAssembler::mul(int lhs)
{
auto done = pasm()->binopBothIntPath(regAddr(lhs), [this](){
auto overflowed = pasm()->branchMul32(PlatformAssembler::Overflow,
@@ -1773,37 +1173,37 @@ void Assembler::mul(int lhs)
// slow path:
saveAccumulatorInFrame();
- prepareCallWithArgCount(2);
- passAccumulatorAsArg(1);
- passRegAsArg(lhs, 0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_mul, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(2);
+ pasm()->passAccumulatorAsArg(1);
+ pasm()->passJSSlotAsArg(lhs, 0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_mul, CallResultDestination::InAccumulator);
checkException();
// done.
done.link(pasm());
}
-void Assembler::div(int lhs)
+void BaselineAssembler::div(int lhs)
{
saveAccumulatorInFrame();
- prepareCallWithArgCount(2);
- passAccumulatorAsArg(1);
- passRegAsArg(lhs, 0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_div, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(2);
+ pasm()->passAccumulatorAsArg(1);
+ pasm()->passJSSlotAsArg(lhs, 0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_div, CallResultDestination::InAccumulator);
checkException();
}
-void Assembler::mod(int lhs)
+void BaselineAssembler::mod(int lhs)
{
saveAccumulatorInFrame();
- prepareCallWithArgCount(2);
- passAccumulatorAsArg(1);
- passRegAsArg(lhs, 0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_mod, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(2);
+ pasm()->passAccumulatorAsArg(1);
+ pasm()->passJSSlotAsArg(lhs, 0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_mod, CallResultDestination::InAccumulator);
checkException();
}
-void Assembler::sub(int lhs)
+void BaselineAssembler::sub(int lhs)
{
auto done = pasm()->binopBothIntPath(regAddr(lhs), [this](){
auto overflowed = pasm()->branchSub32(PlatformAssembler::Overflow,
@@ -1816,30 +1216,30 @@ void Assembler::sub(int lhs)
// slow path:
saveAccumulatorInFrame();
- prepareCallWithArgCount(2);
- passAccumulatorAsArg(1);
- passRegAsArg(lhs, 0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_sub, ResultInAccumulator);
+ pasm()->prepareCallWithArgCount(2);
+ pasm()->passAccumulatorAsArg(1);
+ pasm()->passJSSlotAsArg(lhs, 0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_sub, CallResultDestination::InAccumulator);
checkException();
// done.
done.link(pasm());
}
-void Assembler::cmpeqNull()
+void BaselineAssembler::cmpeqNull()
{
pasm()->isNullOrUndefined();
pasm()->setAccumulatorTag(QV4::Value::ValueTypeInternal::Boolean);
}
-void Assembler::cmpneNull()
+void BaselineAssembler::cmpneNull()
{
pasm()->isNullOrUndefined();
pasm()->xor32(TrustedImm32(1), PlatformAssembler::AccumulatorRegisterValue);
pasm()->setAccumulatorTag(QV4::Value::ValueTypeInternal::Boolean);
}
-void Assembler::cmpeqInt(int lhs)
+void BaselineAssembler::cmpeqInt(int lhs)
{
auto isIntOrBool = pasm()->isIntOrBool();
saveAccumulatorInFrame();
@@ -1848,8 +1248,9 @@ void Assembler::cmpeqInt(int lhs)
pasm()->push(PlatformAssembler::StackPointerRegister);
else
pasm()->move(PlatformAssembler::StackPointerRegister, pasm()->registerForArg(1));
- passAccumulatorAsArg_internal(0, true);
- pasm()->callRuntime("Runtime::method_equal", (void*)Runtime::method_equal, ResultInAccumulator);
+ pasm()->pushAccumulatorAsArg(0);
+ pasm()->callRuntimeUnchecked("Runtime::method_equal", (void*)Runtime::method_equal);
+ pasm()->saveReturnValueInAccumulator();
if (PlatformAssembler::ArgInRegCount < 2)
pasm()->addPtr(TrustedImm32(2 * PlatformAssembler::PointerSize), PlatformAssembler::StackPointerRegister);
pasm()->popValueAligned();
@@ -1862,7 +1263,7 @@ void Assembler::cmpeqInt(int lhs)
done.link(pasm());
}
-void Assembler::cmpneInt(int lhs)
+void BaselineAssembler::cmpneInt(int lhs)
{
auto isIntOrBool = pasm()->isIntOrBool();
saveAccumulatorInFrame();
@@ -1871,8 +1272,9 @@ void Assembler::cmpneInt(int lhs)
pasm()->push(PlatformAssembler::StackPointerRegister);
else
pasm()->move(PlatformAssembler::StackPointerRegister, pasm()->registerForArg(1));
- passAccumulatorAsArg_internal(0, true);
- pasm()->callRuntime("Runtime::method_notEqual", (void*)Runtime::method_notEqual, ResultInAccumulator);
+ pasm()->pushAccumulatorAsArg(0);
+ pasm()->callRuntimeUnchecked("Runtime::method_notEqual", (void*)Runtime::method_notEqual);
+ pasm()->saveReturnValueInAccumulator();
if (PlatformAssembler::ArgInRegCount < 2)
pasm()->addPtr(TrustedImm32(2 * PlatformAssembler::PointerSize), PlatformAssembler::StackPointerRegister);
pasm()->popValueAligned();
@@ -1885,7 +1287,7 @@ void Assembler::cmpneInt(int lhs)
done.link(pasm());
}
-void Assembler::cmp(int cond, CmpFunc function, const char *functionName, int lhs)
+void BaselineAssembler::cmp(int cond, CmpFunc function, const char *functionName, int lhs)
{
auto c = static_cast<PlatformAssembler::RelationalCondition>(cond);
auto done = pasm()->binopBothIntPath(regAddr(lhs), [this, c](){
@@ -1898,11 +1300,11 @@ void Assembler::cmp(int cond, CmpFunc function, const char *functionName, int lh
// slow path:
saveAccumulatorInFrame();
- prepareCallWithArgCount(2);
- passAccumulatorAsArg(1);
- passRegAsArg(lhs, 0);
+ pasm()->prepareCallWithArgCount(2);
+ pasm()->passAccumulatorAsArg(1);
+ pasm()->passJSSlotAsArg(lhs, 0);
- callRuntime(functionName, reinterpret_cast<void*>(function), ResultInAccumulator);
+ callRuntime(functionName, reinterpret_cast<void*>(function), CallResultDestination::InAccumulator);
checkException();
pasm()->setAccumulatorTag(QV4::Value::ValueTypeInternal::Boolean);
@@ -1910,49 +1312,49 @@ void Assembler::cmp(int cond, CmpFunc function, const char *functionName, int lh
done.link(pasm());
}
-void Assembler::cmpeq(int lhs)
+void BaselineAssembler::cmpeq(int lhs)
{
cmp(PlatformAssembler::Equal, &Runtime::method_compareEqual,
"Runtime::method_compareEqual", lhs);
}
-void Assembler::cmpne(int lhs)
+void BaselineAssembler::cmpne(int lhs)
{
cmp(PlatformAssembler::NotEqual, &Runtime::method_compareNotEqual,
"Runtime::method_compareNotEqual", lhs);
}
-void Assembler::cmpgt(int lhs)
+void BaselineAssembler::cmpgt(int lhs)
{
cmp(PlatformAssembler::GreaterThan, &Runtime::method_compareGreaterThan,
"Runtime::method_compareGreaterThan", lhs);
}
-void Assembler::cmpge(int lhs)
+void BaselineAssembler::cmpge(int lhs)
{
cmp(PlatformAssembler::GreaterThanOrEqual, &Runtime::method_compareGreaterEqual,
"Runtime::method_compareGreaterEqual", lhs);
}
-void Assembler::cmplt(int lhs)
+void BaselineAssembler::cmplt(int lhs)
{
cmp(PlatformAssembler::LessThan, &Runtime::method_compareLessThan,
"Runtime::method_compareLessThan", lhs);
}
-void Assembler::cmple(int lhs)
+void BaselineAssembler::cmple(int lhs)
{
cmp(PlatformAssembler::LessThanOrEqual, &Runtime::method_compareLessEqual,
"Runtime::method_compareLessEqual", lhs);
}
-void Assembler::cmpStrictEqual(int lhs)
+void BaselineAssembler::cmpStrictEqual(int lhs)
{
cmp(PlatformAssembler::Equal, &RuntimeHelpers::strictEqual,
"RuntimeHelpers::strictEqual", lhs);
}
-void Assembler::cmpStrictNotEqual(int lhs)
+void BaselineAssembler::cmpStrictNotEqual(int lhs)
{
cmp(PlatformAssembler::Equal, &RuntimeHelpers::strictEqual,
"RuntimeHelpers::strictEqual", lhs);
@@ -1960,206 +1362,104 @@ void Assembler::cmpStrictNotEqual(int lhs)
pasm()->setAccumulatorTag(QV4::Value::ValueTypeInternal::Boolean);
}
-void Assembler::jump(int offset)
+void BaselineAssembler::jump(int offset)
{
- pasm()->patches.push_back({ pasm()->jump(), offset });
+ pasm()->addJumpToOffset(pasm()->jump(), offset);
}
-void Assembler::jumpTrue(int offset)
+void BaselineAssembler::jumpTrue(int offset)
{
pasm()->toBoolean([this, offset](PlatformAssembler::RegisterID resultReg) {
auto jump = pasm()->branch32(PlatformAssembler::NotEqual, TrustedImm32(0), resultReg);
- pasm()->patches.push_back({ jump, offset });
+ pasm()->addJumpToOffset(jump, offset);
});
}
-void Assembler::jumpFalse(int offset)
+void BaselineAssembler::jumpFalse(int offset)
{
pasm()->toBoolean([this, offset](PlatformAssembler::RegisterID resultReg) {
auto jump = pasm()->branch32(PlatformAssembler::Equal, TrustedImm32(0), resultReg);
- pasm()->patches.push_back({ jump, offset });
+ pasm()->addJumpToOffset(jump, offset);
});
}
-void Assembler::jumpStrictEqualStackSlotInt(int lhs, int rhs, int offset)
+void BaselineAssembler::jumpNoException(int offset)
{
- pasm()->jumpStrictEqualStackSlotInt(lhs, rhs, offset);
+ auto jump = pasm()->branch32(
+ PlatformAssembler::Equal,
+ PlatformAssembler::Address(PlatformAssembler::EngineRegister,
+ offsetof(EngineBase, hasException)),
+ TrustedImm32(0));
+ pasm()->addJumpToOffset(jump, offset);
}
-void Assembler::jumpStrictNotEqualStackSlotInt(int lhs, int rhs, int offset)
+void BaselineAssembler::jumpNotUndefined(int offset)
{
- pasm()->jumpStrictNotEqualStackSlotInt(lhs, rhs, offset);
+ pasm()->jumpNotUndefined(offset);
}
-void Assembler::prepareCallWithArgCount(int argc)
+void BaselineAssembler::prepareCallWithArgCount(int argc)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(remainingArgcForCall == NoCall);
- remainingArgcForCall = argc;
-#endif
-
- if (argc > PlatformAssembler::ArgInRegCount) {
- argcOnStackForCall = int(WTF::roundUpToMultipleOf(16, size_t(argc - PlatformAssembler::ArgInRegCount) * PlatformAssembler::PointerSize));
- pasm()->subPtr(TrustedImm32(argcOnStackForCall), PlatformAssembler::StackPointerRegister);
- }
+ pasm()->prepareCallWithArgCount(argc);
}
-void Assembler::storeInstructionPointer(int instructionOffset)
+void BaselineAssembler::storeInstructionPointer(int instructionOffset)
{
- PlatformAssembler::Address addr(PlatformAssembler::CppStackFrameRegister,
- offsetof(QV4::CppStackFrame, instructionPointer));
- pasm()->store32(TrustedImm32(instructionOffset), addr);
+ pasm()->storeInstructionPointer(instructionOffset);
}
-Address argStackAddress(int arg)
+void BaselineAssembler::passAccumulatorAsArg(int arg)
{
- int offset = arg - PlatformAssembler::ArgInRegCount;
- Q_ASSERT(offset >= 0);
- return Address(PlatformAssembler::StackPointerRegister, offset * PlatformAssembler::PointerSize);
+ pasm()->passAccumulatorAsArg(arg);
}
-void Assembler::passAccumulatorAsArg(int arg)
+void BaselineAssembler::passFunctionAsArg(int arg)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- passAccumulatorAsArg_internal(arg, false);
+ pasm()->passFunctionAsArg(arg);
}
-void Assembler::passAccumulatorAsArg_internal(int arg, bool push)
+void BaselineAssembler::passEngineAsArg(int arg)
{
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->addPtr(TrustedImm32(offsetof(CallData, accumulator)),
- PlatformAssembler::JSStackFrameRegister,
- pasm()->registerForArg(arg));
- } else {
- pasm()->addPtr(TrustedImm32(offsetof(CallData, accumulator)),
- PlatformAssembler::JSStackFrameRegister,
- PlatformAssembler::ScratchRegister);
- if (push)
- pasm()->push(PlatformAssembler::ScratchRegister);
- else
- pasm()->storePtr(PlatformAssembler::ScratchRegister,
- argStackAddress(arg));
- }
+ pasm()->passEngineAsArg(arg);
}
-void Assembler::passFunctionAsArg(int arg)
+void BaselineAssembler::passJSSlotAsArg(int reg, int arg)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->loadFunctionPtr(pasm()->registerForArg(arg));
- } else {
- pasm()->loadFunctionPtr(PlatformAssembler::ScratchRegister);
- pasm()->storePtr(PlatformAssembler::ScratchRegister,
- argStackAddress(arg));
- }
+ pasm()->passJSSlotAsArg(reg, arg);
}
-void Assembler::passEngineAsArg(int arg)
+void BaselineAssembler::passCppFrameAsArg(int arg)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->move(PlatformAssembler::EngineRegister, pasm()->registerForArg(arg));
- } else {
- pasm()->storePtr(PlatformAssembler::EngineRegister, argStackAddress(arg));
- }
+ pasm()->passCppFrameAsArg(arg);
}
-void Assembler::passRegAsArg(int reg, int arg)
+void BaselineAssembler::passInt32AsArg(int value, int arg)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->addPtr(TrustedImm32(reg * int(sizeof(QV4::Value))),
- PlatformAssembler::JSStackFrameRegister,
- pasm()->registerForArg(arg));
- } else {
- pasm()->addPtr(TrustedImm32(reg * int(sizeof(QV4::Value))),
- PlatformAssembler::JSStackFrameRegister,
- PlatformAssembler::ScratchRegister);
- pasm()->storePtr(PlatformAssembler::ScratchRegister,
- argStackAddress(arg));
- }
+ pasm()->passInt32AsArg(value, arg);
}
-void JIT::Assembler::passCppFrameAsArg(int arg)
+void BaselineAssembler::callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest)
{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->move(PlatformAssembler::CppStackFrameRegister, pasm()->registerForArg(arg));
- } else {
- pasm()->store32(PlatformAssembler::CppStackFrameRegister, argStackAddress(arg));
- }
-}
-
-void Assembler::passInt32AsArg(int value, int arg)
-{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(arg < remainingArgcForCall);
- --remainingArgcForCall;
-#endif
-
- if (arg < PlatformAssembler::ArgInRegCount) {
- pasm()->move(TrustedImm32(value), pasm()->registerForArg(arg));
- } else {
- pasm()->store32(TrustedImm32(value), argStackAddress(arg));
- }
-}
-
-void Assembler::callRuntime(const char *functionName, const void *funcPtr,
- Assembler::CallResultDestination dest)
-{
-#ifndef QT_NO_DEBUG
- Q_ASSERT(remainingArgcForCall == 0);
- remainingArgcForCall = NoCall;
-#endif
pasm()->callRuntime(functionName, funcPtr, dest);
- if (argcOnStackForCall > 0) {
- pasm()->addPtr(TrustedImm32(argcOnStackForCall), PlatformAssembler::StackPointerRegister);
- argcOnStackForCall = 0;
- }
}
-void Assembler::saveAccumulatorInFrame()
+void BaselineAssembler::saveAccumulatorInFrame()
{
pasm()->storeAccumulator(PlatformAssembler::Address(PlatformAssembler::JSStackFrameRegister,
offsetof(CallData, accumulator)));
}
-void Assembler::checkException()
+void BaselineAssembler::checkException()
{
- pasm()->addCatchyJump(
- pasm()->branch32(
- PlatformAssembler::NotEqual,
- PlatformAssembler::Address(PlatformAssembler::EngineRegister,
- offsetof(EngineBase, hasException)),
- TrustedImm32(0)));
+ pasm()->checkException();
}
-void Assembler::gotoCatchException()
+void BaselineAssembler::gotoCatchException()
{
pasm()->addCatchyJump(pasm()->jump());
}
-void Assembler::getException()
+void BaselineAssembler::getException()
{
Q_STATIC_ASSERT(sizeof(QV4::EngineBase::hasException) == 1);
@@ -2175,49 +1475,93 @@ void Assembler::getException()
pasm()->store8(TrustedImm32(0), hasExceptionAddr);
auto done = pasm()->jump();
nope.link(pasm());
- pasm()->loadValue(Primitive::emptyValue().asReturnedValue());
+ pasm()->loadValue(Value::emptyValue().asReturnedValue());
done.link(pasm());
}
-void Assembler::setException()
+void BaselineAssembler::setException()
{
+ auto noException = pasm()->jumpEmpty();
Address addr(PlatformAssembler::EngineRegister, offsetof(EngineBase, exceptionValue));
pasm()->loadPtr(addr, PlatformAssembler::ScratchRegister);
pasm()->storeAccumulator(Address(PlatformAssembler::ScratchRegister));
addr.offset = offsetof(EngineBase, hasException);
Q_STATIC_ASSERT(sizeof(QV4::EngineBase::hasException) == 1);
pasm()->store8(TrustedImm32(1), addr);
+ noException.link(pasm());
}
-void Assembler::setExceptionHandler(int offset)
+void BaselineAssembler::setUnwindHandler(int offset)
{
auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), pasm()->exceptionHandlerAddress());
- pasm()->ehTargets.push_back({ l, offset });
+ pasm()->addEHTarget(l, offset);
}
-void Assembler::clearExceptionHandler()
+void BaselineAssembler::clearUnwindHandler()
{
pasm()->storePtr(TrustedImmPtr(nullptr), pasm()->exceptionHandlerAddress());
}
-void Assembler::pushCatchContext(int name, int reg)
+void JIT::BaselineAssembler::unwindDispatch()
{
- pasm()->copyReg(pasm()->contextAddress(), regAddr(reg));
- prepareCallWithArgCount(2);
- passInt32AsArg(name, 1);
- passRegAsArg(CallData::Context, 0);
- IN_JIT_GENERATE_RUNTIME_CALL(Runtime::method_createCatchContext, ResultInAccumulator);
+ checkException();
+ pasm()->load32(Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel)), PlatformAssembler::ScratchRegister);
+ auto noUnwind = pasm()->branch32(PlatformAssembler::Equal, PlatformAssembler::ScratchRegister, TrustedImm32(0));
+ pasm()->sub32(TrustedImm32(1), PlatformAssembler::ScratchRegister);
+ pasm()->store32(PlatformAssembler::ScratchRegister, Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel)));
+ auto jump = pasm()->branch32(PlatformAssembler::Equal, PlatformAssembler::ScratchRegister, TrustedImm32(0));
+ gotoCatchException();
+ jump.link(pasm());
+
+ pasm()->loadPtr(Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLabel)), PlatformAssembler::ScratchRegister);
+ pasm()->jump(PlatformAssembler::ScratchRegister);
+
+ noUnwind.link(pasm());
+}
+
+void JIT::BaselineAssembler::unwindToLabel(int level, int offset)
+{
+ auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLabel)));
+ pasm()->addEHTarget(l, offset);
+ pasm()->store32(TrustedImm32(level), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel)));
+ gotoCatchException();
+}
+
+void BaselineAssembler::pushCatchContext(int index, int name)
+{
+ pasm()->prepareCallWithArgCount(3);
+ pasm()->passInt32AsArg(name, 2);
+ pasm()->passInt32AsArg(index, 1);
+ pasm()->passJSSlotAsArg(CallData::Context, 0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_createCatchContext, CallResultDestination::InAccumulator);
pasm()->storeAccumulator(pasm()->contextAddress());
}
-void Assembler::popContext(int reg)
+void BaselineAssembler::popContext()
+{
+ Heap::CallContext ctx;
+ Q_UNUSED(ctx)
+ pasm()->loadPointerFromValue(regAddr(CallData::Context), PlatformAssembler::ScratchRegister);
+ pasm()->loadPtr(Address(PlatformAssembler::ScratchRegister, ctx.outer.offset), PlatformAssembler::ScratchRegister);
+ pasm()->storeHeapObject(PlatformAssembler::ScratchRegister, regAddr(CallData::Context));
+}
+
+void BaselineAssembler::deadTemporalZoneCheck(int offsetForSavedIP, int variableName)
{
- pasm()->copyReg(regAddr(reg), pasm()->contextAddress());
+ auto valueIsAliveJump = pasm()->jumpNotEmpty();
+ storeInstructionPointer(offsetForSavedIP);
+ saveAccumulatorInFrame();
+ prepareCallWithArgCount(2);
+ passInt32AsArg(variableName, 1);
+ passEngineAsArg(0);
+ ASM_GENERATE_RUNTIME_CALL(Runtime::method_throwReferenceError, CallResultDestination::Ignore);
+ gotoCatchException();
+ valueIsAliveJump.link(pasm());
}
-void Assembler::ret()
+void BaselineAssembler::ret()
{
pasm()->generateFunctionExit();
}
diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4baselineassembler_p.h
index 37d4232a17..a2140ce47b 100644
--- a/src/qml/jit/qv4assembler_p.h
+++ b/src/qml/jit/qv4baselineassembler_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QV4ASSEMBLER_P_H
-#define QV4ASSEMBLER_P_H
+#ifndef QV4BASELINEASSEMBLER_P_H
+#define QV4BASELINEASSEMBLER_P_H
//
// W A R N I N G
@@ -63,22 +63,15 @@ namespace JIT {
#define JIT_STRINGIFYx(s) #s
#define JIT_STRINGIFY(s) JIT_STRINGIFYx(s)
-#define IN_JIT_GENERATE_RUNTIME_CALL(function, destination) \
+#define GENERATE_RUNTIME_CALL(function, destination) \
callRuntime(JIT_STRINGIFY(function), \
reinterpret_cast<void *>(&function), \
destination)
-#define JIT_GENERATE_RUNTIME_CALL(function, destination) \
- as->IN_JIT_GENERATE_RUNTIME_CALL(function, destination)
-class Assembler {
+class BaselineAssembler {
public:
- enum CallResultDestination {
- IgnoreResult,
- ResultInAccumulator,
- };
-
- Assembler(const Value* constantTable);
- ~Assembler();
+ BaselineAssembler(const Value* constantTable);
+ ~BaselineAssembler();
// codegen infrastructure
void generatePrologue();
@@ -90,12 +83,14 @@ public:
void loadConst(int constIndex);
void copyConst(int constIndex, int destReg);
void loadReg(int reg);
+ void moveReg(int sourceReg, int destReg);
void storeReg(int reg);
void loadLocal(int index, int level = 0);
void storeLocal(int index, int level = 0);
void loadString(int stringId);
void loadValue(ReturnedValue value);
void storeHeapObject(int reg);
+ void loadImport(int index);
// numeric ops
void unot();
@@ -140,8 +135,8 @@ public:
void jump(int offset);
void jumpTrue(int offset);
void jumpFalse(int offset);
- void jumpStrictEqualStackSlotInt(int lhs, int rhs, int offset);
- void jumpStrictNotEqualStackSlotInt(int lhs, int rhs, int offset);
+ void jumpNoException(int offset);
+ void jumpNotUndefined(int offset);
// stuff for runtime calls
void prepareCallWithArgCount(int argc);
@@ -149,10 +144,10 @@ public:
void passAccumulatorAsArg(int arg);
void passFunctionAsArg(int arg);
void passEngineAsArg(int arg);
- void passRegAsArg(int reg, int arg);
+ void passJSSlotAsArg(int reg, int arg);
void passCppFrameAsArg(int arg);
void passInt32AsArg(int value, int arg);
- void callRuntime(const char *functionName, const void *funcPtr, Assembler::CallResultDestination dest);
+ void callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest);
void saveAccumulatorInFrame();
// exception/context stuff
@@ -160,10 +155,13 @@ public:
void gotoCatchException();
void getException();
void setException();
- void setExceptionHandler(int offset);
- void clearExceptionHandler();
- void pushCatchContext(int name, int reg);
- void popContext(int reg);
+ void setUnwindHandler(int offset);
+ void clearUnwindHandler();
+ void unwindDispatch();
+ void unwindToLabel(int level, int offset);
+ void pushCatchContext(int index, int name);
+ void popContext();
+ void deadTemporalZoneCheck(int offsetForSavedIP, int variableName);
// other stuff
void ret();
@@ -171,16 +169,9 @@ public:
protected:
void *d;
-#ifndef QT_NO_DEBUG
- enum { NoCall = -1 };
- int remainingArgcForCall = NoCall;
-#endif
- int argcOnStackForCall = 0;
-
private:
typedef unsigned(*CmpFunc)(const Value&,const Value&);
void cmp(int cond, CmpFunc function, const char *functionName, int lhs);
- void passAccumulatorAsArg_internal(int arg, bool push);
};
} // namespace JIT
@@ -188,4 +179,4 @@ private:
QT_END_NAMESPACE
-#endif // QV4ASSEMBLER_P_H
+#endif // QV4BASELINEASSEMBLER_P_H
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp
new file mode 100644
index 0000000000..7b4f2b00e7
--- /dev/null
+++ b/src/qml/jit/qv4baselinejit.cpp
@@ -0,0 +1,1000 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4baselinejit_p.h"
+#include "qv4jithelpers_p.h"
+#include "qv4baselineassembler_p.h"
+#include <private/qv4lookup_p.h>
+#include <private/qv4generatorobject_p.h>
+
+#ifdef V4_ENABLE_JIT
+
+QT_USE_NAMESPACE
+using namespace QV4;
+using namespace QV4::JIT;
+using namespace QV4::Moth;
+
+BaselineJIT::BaselineJIT(Function *function)
+ : function(function)
+ , as(new BaselineAssembler(function->compilationUnit->constants))
+{}
+
+BaselineJIT::~BaselineJIT()
+{}
+
+void BaselineJIT::generate()
+{
+// qDebug()<<"jitting" << function->name()->toQString();
+ const char *code = function->codeData;
+ uint len = function->compiledFunction->codeSize;
+ labels = collectLabelsInBytecode(code, len);
+
+ as->generatePrologue();
+ decode(code, len);
+ as->generateEpilogue();
+
+ as->link(function);
+// qDebug()<<"done";
+}
+
+#define STORE_IP() as->storeInstructionPointer(nextInstructionOffset())
+#define STORE_ACC() as->saveAccumulatorInFrame()
+#define BASELINEJIT_GENERATE_RUNTIME_CALL(function, destination) \
+ as->GENERATE_RUNTIME_CALL(function, destination)
+
+void BaselineJIT::generate_Ret()
+{
+ as->ret();
+}
+
+void BaselineJIT::generate_Debug() { Q_UNREACHABLE(); }
+
+void BaselineJIT::generate_LoadConst(int index)
+{
+ as->loadConst(index);
+}
+
+void BaselineJIT::generate_LoadZero()
+{
+ as->loadValue(Encode(int(0)));
+}
+
+void BaselineJIT::generate_LoadTrue()
+{
+ as->loadValue(Encode(true));
+}
+
+void BaselineJIT::generate_LoadFalse()
+{
+ as->loadValue(Encode(false));
+}
+
+void BaselineJIT::generate_LoadNull()
+{
+ as->loadValue(Encode::null());
+}
+
+void BaselineJIT::generate_LoadUndefined()
+{
+ as->loadValue(Encode::undefined());
+}
+
+void BaselineJIT::generate_LoadInt(int value)
+{
+ //###
+ as->loadValue(Encode(value));
+}
+
+void BaselineJIT::generate_MoveConst(int constIndex, int destTemp)
+{
+ as->copyConst(constIndex, destTemp);
+}
+
+void BaselineJIT::generate_LoadReg(int reg)
+{
+ as->loadReg(reg);
+}
+
+void BaselineJIT::generate_StoreReg(int reg)
+{
+ as->storeReg(reg);
+}
+
+void BaselineJIT::generate_MoveReg(int srcReg, int destReg)
+{
+ // Don't clobber the accumulator.
+ as->moveReg(srcReg, destReg);
+}
+
+void BaselineJIT::generate_LoadImport(int index)
+{
+ as->loadImport(index);
+}
+
+void BaselineJIT::generate_LoadLocal(int index)
+{
+ as->loadLocal(index);
+}
+
+void BaselineJIT::generate_StoreLocal(int index)
+{
+ as->checkException();
+ as->storeLocal(index);
+}
+
+void BaselineJIT::generate_LoadScopedLocal(int scope, int index)
+{
+ as->loadLocal(index, scope);
+}
+
+void BaselineJIT::generate_StoreScopedLocal(int scope, int index)
+{
+ as->checkException();
+ as->storeLocal(index, scope);
+}
+
+void BaselineJIT::generate_LoadRuntimeString(int stringId)
+{
+ as->loadString(stringId);
+}
+
+void BaselineJIT::generate_MoveRegExp(int regExpId, int destReg)
+{
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(regExpId, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_regexpLiteral, CallResultDestination::InAccumulator);
+ as->storeReg(destReg);
+}
+
+void BaselineJIT::generate_LoadClosure(int value)
+{
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(value, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_closure, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_LoadName(int name)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadName, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadGlobalLookup(int index)
+{
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(index, 2);
+ as->passEngineAsArg(1);
+ as->passFunctionAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::loadGlobalLookup, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreNameSloppy(int name)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passInt32AsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameSloppy, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreNameStrict(int name)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passInt32AsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameStrict, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadElement(int base)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadElement, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreElement(int base, int index)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passAccumulatorAsArg(3);
+ as->passJSSlotAsArg(index, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeElement, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadProperty(int name)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(name, 2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_GetLookup(int index)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(index, 3);
+ as->passAccumulatorAsArg(2);
+ as->passEngineAsArg(1);
+ as->passFunctionAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::getLookup, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreProperty(int name, int base)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passAccumulatorAsArg(3);
+ as->passInt32AsArg(name, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeProperty, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_SetLookup(int index, int base)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passAccumulatorAsArg(3);
+ as->passJSSlotAsArg(base, 2);
+ as->passInt32AsArg(index, 1);
+ as->passFunctionAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL((function->isStrict() ? Helpers::setLookupStrict : Helpers::setLookupSloppy),
+ CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadSuperProperty(int property)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passJSSlotAsArg(property, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadSuperProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreSuperProperty(int property)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(property, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeSuperProperty, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+
+void BaselineJIT::generate_StoreScopeObjectProperty(int base, int propertyIndex)
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passAccumulatorAsArg(3);
+ as->passInt32AsArg(propertyIndex, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeQmlScopeObjectProperty, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_StoreContextObjectProperty(int base, int propertyIndex)
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(4);
+ as->passAccumulatorAsArg(3);
+ as->passInt32AsArg(propertyIndex, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeQmlContextObjectProperty, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadScopeObjectProperty(int propertyIndex, int base, int captureRequired)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(captureRequired, 3);
+ as->passInt32AsArg(propertyIndex, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlScopeObjectProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadContextObjectProperty(int propertyIndex, int base, int captureRequired)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(captureRequired, 3);
+ as->passInt32AsArg(propertyIndex, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlContextObjectProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadIdObject(int index, int base)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(index, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlIdObject, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_Yield()
+{
+ // #####
+ Q_UNREACHABLE();
+}
+
+void BaselineJIT::generate_YieldStar()
+{
+ // #####
+ Q_UNREACHABLE();
+}
+
+void BaselineJIT::generate_Resume(int)
+{
+ // #####
+ Q_UNREACHABLE();
+}
+
+void BaselineJIT::generate_CallValue(int name, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(argc, 3);
+ as->passJSSlotAsArg(argv, 2);
+ as->passJSSlotAsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callValue, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallWithReceiver(int name, int thisObject, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passJSSlotAsArg(thisObject, 2);
+ as->passJSSlotAsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callWithReceiver, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallProperty(int name, int base, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passInt32AsArg(name, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passInt32AsArg(lookupIndex, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callPropertyLookup, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallElement(int base, int index, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passJSSlotAsArg(index, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callElement, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallName(int name, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(argc, 3);
+ as->passJSSlotAsArg(argv, 2);
+ as->passInt32AsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callName, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallPossiblyDirectEval(int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(argc, 2);
+ as->passJSSlotAsArg(argv, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callPossiblyDirectEval, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallGlobalLookup(int index, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(4);
+ as->passInt32AsArg(argc, 3);
+ as->passJSSlotAsArg(argv, 2);
+ as->passInt32AsArg(index, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callGlobalLookup, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallScopeObjectProperty(int propIdx, int base, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passInt32AsArg(propIdx, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callQmlScopeObjectProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CallContextObjectProperty(int propIdx, int base, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passInt32AsArg(propIdx, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callQmlContextObjectProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+
+void BaselineJIT::generate_CallWithSpread(int func, int thisObject, int argc, int argv)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passJSSlotAsArg(thisObject, 2);
+ as->passJSSlotAsArg(func, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_callWithSpread, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+
+void BaselineJIT::generate_Construct(int func, int argc, int argv)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(func, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_construct, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_ConstructWithSpread(int func, int argc, int argv)
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(5);
+ as->passInt32AsArg(argc, 4);
+ as->passJSSlotAsArg(argv, 3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(func, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_constructWithSpread, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_SetUnwindHandler(int offset)
+{
+ if (offset)
+ as->setUnwindHandler(absoluteOffsetForJump(offset));
+ else
+ as->clearUnwindHandler();
+}
+
+void BaselineJIT::generate_UnwindDispatch()
+{
+ as->unwindDispatch();
+}
+
+void BaselineJIT::generate_UnwindToLabel(int level, int offset)
+{
+ as->unwindToLabel(level, absoluteOffsetForJump(offset));
+}
+
+void BaselineJIT::generate_DeadTemporalZoneCheck(int name)
+{
+ as->deadTemporalZoneCheck(nextInstructionOffset(), name);
+}
+
+void BaselineJIT::generate_ThrowException()
+{
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_throwException, CallResultDestination::Ignore);
+ as->gotoCatchException();
+}
+
+void BaselineJIT::generate_GetException() { as->getException(); }
+void BaselineJIT::generate_SetException() { as->setException(); }
+
+void BaselineJIT::generate_CreateCallContext()
+{
+ as->prepareCallWithArgCount(1);
+ as->passCppFrameAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(ExecutionContext::newCallContext, CallResultDestination::Ignore); // keeps result in return value register
+ as->storeHeapObject(CallData::Context);
+}
+
+void BaselineJIT::generate_PushCatchContext(int index, int name) { as->pushCatchContext(index, name); }
+
+void BaselineJIT::generate_PushWithContext()
+{
+ STORE_IP();
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(2);
+ as->passJSSlotAsArg(0, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_createWithContext, CallResultDestination::Ignore); // keeps result in return value register
+ as->checkException();
+ as->storeHeapObject(CallData::Context);
+}
+
+void BaselineJIT::generate_PushBlockContext(int index)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(index, 1);
+ as->passJSSlotAsArg(0, 0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushBlockContext, CallResultDestination::Ignore);
+}
+
+void BaselineJIT::generate_CloneBlockContext()
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(1);
+ as->passJSSlotAsArg(CallData::Context, 0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::cloneBlockContext, CallResultDestination::Ignore);
+}
+
+void BaselineJIT::generate_PushScriptContext(int index)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(index, 2);
+ as->passEngineAsArg(1);
+ as->passJSSlotAsArg(0, 0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushScriptContext, CallResultDestination::Ignore);
+}
+
+void BaselineJIT::generate_PopScriptContext()
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(2);
+ as->passEngineAsArg(1);
+ as->passJSSlotAsArg(0, 0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::popScriptContext, CallResultDestination::Ignore);
+}
+
+void BaselineJIT::generate_PopContext() { as->popContext(); }
+
+void BaselineJIT::generate_GetIterator(int iterator)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(iterator, 2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_getIterator, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_IteratorNext(int value, int done)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(3);
+ as->passJSSlotAsArg(value, 2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_iteratorNext, CallResultDestination::InAccumulator);
+ as->storeReg(done);
+ as->checkException();
+}
+
+void BaselineJIT::generate_IteratorNextForYieldStar(int iterator, int object)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(4);
+ as->passJSSlotAsArg(object, 3);
+ as->passJSSlotAsArg(iterator, 2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_iteratorNextForYieldStar, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_IteratorClose(int done)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(3);
+ as->passJSSlotAsArg(done, 2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_iteratorClose, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_DestructureRestElement()
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_destructureRestElement, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_DeleteProperty(int base, int index)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(3);
+ as->passJSSlotAsArg(index, 2);
+ as->passJSSlotAsArg(base, 1);
+ as->passFunctionAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::deleteProperty, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_DeleteName(int name)
+{
+ STORE_IP();
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(name, 1);
+ as->passFunctionAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::deleteName, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_TypeofName(int name)
+{
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(name, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_typeofName, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_TypeofValue()
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_typeofValue, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_DeclareVar(int varName, int isDeletable)
+{
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(varName, 2);
+ as->passInt32AsArg(isDeletable, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_declareVar, CallResultDestination::Ignore);
+}
+
+void BaselineJIT::generate_DefineArray(int argc, int args)
+{
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(argc, 2);
+ as->passJSSlotAsArg(args, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_arrayLiteral, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_DefineObjectLiteral(int internalClassId, int argc, int args)
+{
+ as->prepareCallWithArgCount(4);
+ as->passJSSlotAsArg(args, 3);
+ as->passInt32AsArg(argc, 2);
+ as->passInt32AsArg(internalClassId, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_objectLiteral, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_CreateClass(int classIndex, int heritage, int computedNames)
+{
+ as->prepareCallWithArgCount(4);
+ as->passJSSlotAsArg(computedNames, 3);
+ as->passJSSlotAsArg(heritage, 2);
+ as->passInt32AsArg(classIndex, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_createClass, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_CreateMappedArgumentsObject()
+{
+ as->prepareCallWithArgCount(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_createMappedArgumentsObject,
+ CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_CreateUnmappedArgumentsObject()
+{
+ as->prepareCallWithArgCount(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_createUnmappedArgumentsObject,
+ CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_CreateRestParameter(int argIndex)
+{
+ as->prepareCallWithArgCount(2);
+ as->passInt32AsArg(argIndex, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_createRestParameter, CallResultDestination::InAccumulator);
+}
+
+void BaselineJIT::generate_ConvertThisToObject()
+{
+ as->prepareCallWithArgCount(2);
+ as->passJSSlotAsArg(CallData::This, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::convertThisToObject, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+void BaselineJIT::generate_LoadSuperConstructor()
+{
+ as->prepareCallWithArgCount(2);
+ as->passJSSlotAsArg(CallData::Function, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadSuperConstructor, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_ToObject()
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::toObject, CallResultDestination::InAccumulator);
+ as->checkException();
+
+}
+
+void BaselineJIT::generate_Jump(int offset) { as->jump(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpTrue(int offset) { as->jumpTrue(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpFalse(int offset) { as->jumpFalse(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpNoException(int offset) { as->jumpNoException(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpNotUndefined(int offset) { as->jumpNotUndefined(absoluteOffsetForJump(offset)); }
+
+void BaselineJIT::generate_CmpEqNull() { as->cmpeqNull(); }
+void BaselineJIT::generate_CmpNeNull() { as->cmpneNull(); }
+void BaselineJIT::generate_CmpEqInt(int lhs) { as->cmpeqInt(lhs); }
+void BaselineJIT::generate_CmpNeInt(int lhs) { as->cmpneInt(lhs); }
+void BaselineJIT::generate_CmpEq(int lhs) { as->cmpeq(lhs); }
+void BaselineJIT::generate_CmpNe(int lhs) { as->cmpne(lhs); }
+void BaselineJIT::generate_CmpGt(int lhs) { as->cmpgt(lhs); }
+void BaselineJIT::generate_CmpGe(int lhs) { as->cmpge(lhs); }
+void BaselineJIT::generate_CmpLt(int lhs) { as->cmplt(lhs); }
+void BaselineJIT::generate_CmpLe(int lhs) { as->cmple(lhs); }
+void BaselineJIT::generate_CmpStrictEqual(int lhs) { as->cmpStrictEqual(lhs); }
+void BaselineJIT::generate_CmpStrictNotEqual(int lhs) { as->cmpStrictNotEqual(lhs); }
+
+void BaselineJIT::generate_CmpIn(int lhs)
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(lhs, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_in, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_CmpInstanceOf(int lhs)
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(3);
+ as->passAccumulatorAsArg(2);
+ as->passJSSlotAsArg(lhs, 1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_instanceof, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+
+void BaselineJIT::generate_UNot() { as->unot(); }
+void BaselineJIT::generate_UPlus() { as->toNumber(); }
+void BaselineJIT::generate_UMinus() { as->uminus(); }
+void BaselineJIT::generate_UCompl() { as->ucompl(); }
+void BaselineJIT::generate_Increment() { as->inc(); }
+void BaselineJIT::generate_Decrement() { as->dec(); }
+void BaselineJIT::generate_Add(int lhs) { as->add(lhs); }
+
+void BaselineJIT::generate_BitAnd(int lhs) { as->bitAnd(lhs); }
+void BaselineJIT::generate_BitOr(int lhs) { as->bitOr(lhs); }
+void BaselineJIT::generate_BitXor(int lhs) { as->bitXor(lhs); }
+void BaselineJIT::generate_UShr(int lhs) { as->ushr(lhs); }
+void BaselineJIT::generate_Shr(int lhs) { as->shr(lhs); }
+void BaselineJIT::generate_Shl(int lhs) { as->shl(lhs); }
+
+void BaselineJIT::generate_BitAndConst(int rhs) { as->bitAndConst(rhs); }
+void BaselineJIT::generate_BitOrConst(int rhs) { as->bitOrConst(rhs); }
+void BaselineJIT::generate_BitXorConst(int rhs) { as->bitXorConst(rhs); }
+void BaselineJIT::generate_UShrConst(int rhs) { as->ushrConst(rhs); }
+void BaselineJIT::generate_ShrConst(int rhs) { as->shrConst(rhs); }
+void BaselineJIT::generate_ShlConst(int rhs) { as->shlConst(rhs); }
+
+void BaselineJIT::generate_Exp(int lhs) {
+ STORE_IP();
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passJSSlotAsArg(lhs, 0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::exp, CallResultDestination::InAccumulator);
+ as->checkException();
+}
+void BaselineJIT::generate_Mul(int lhs) { as->mul(lhs); }
+void BaselineJIT::generate_Div(int lhs) { as->div(lhs); }
+void BaselineJIT::generate_Mod(int lhs) { as->mod(lhs); }
+void BaselineJIT::generate_Sub(int lhs) { as->sub(lhs); }
+
+//void BaselineJIT::generate_BinopContext(int alu, int lhs)
+//{
+// auto engine = function->internalClass->engine;
+// void *op = engine->runtime.runtimeMethods[alu];
+// STORE_ACC();
+// as->passAccumulatorAsArg(2);
+// as->passRegAsArg(lhs, 1);
+// as->passEngineAsArg(0);
+// as->callRuntime("binopContext", op, CallResultDestination::InAccumulator);
+// as->checkException();
+//}
+
+void BaselineJIT::generate_LoadQmlContext(int result)
+{
+ as->prepareCallWithArgCount(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlContext, CallResultDestination::InAccumulator);
+ as->storeReg(result);
+}
+
+void BaselineJIT::generate_LoadQmlImportedScripts(int result)
+{
+ as->prepareCallWithArgCount(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlImportedScripts, CallResultDestination::InAccumulator);
+ as->storeReg(result);
+}
+
+void BaselineJIT::generate_InitializeBlockDeadTemporalZone(int firstReg, int count)
+{
+ as->loadValue(Value::emptyValue().rawValue());
+ for (int i = firstReg, end = firstReg + count; i < end; ++i)
+ as->storeReg(i);
+}
+
+void BaselineJIT::generate_ThrowOnNullOrUndefined()
+{
+ STORE_ACC();
+ as->prepareCallWithArgCount(2);
+ as->passAccumulatorAsArg(1);
+ as->passEngineAsArg(0);
+ BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::throwOnNullOrUndefined, CallResultDestination::Ignore);
+ as->checkException();
+}
+
+
+void BaselineJIT::startInstruction(Instr::Type /*instr*/)
+{
+ if (hasLabel())
+ as->addLabel(currentInstructionOffset());
+}
+
+void BaselineJIT::endInstruction(Instr::Type instr)
+{
+ Q_UNUSED(instr);
+}
+
+#endif // V4_ENABLE_JIT
diff --git a/src/qml/jit/qv4jit_p.h b/src/qml/jit/qv4baselinejit_p.h
index 5aebf78a8d..d4c1b074f6 100644
--- a/src/qml/jit/qv4jit_p.h
+++ b/src/qml/jit/qv4baselinejit_p.h
@@ -54,68 +54,23 @@
#include <private/qv4global_p.h>
#include <private/qv4function_p.h>
#include <private/qv4instr_moth_p.h>
+#include <private/qv4bytecodehandler_p.h>
//QT_REQUIRE_CONFIG(qml_jit);
-#define JIT_DEFINE_ARGS(nargs, ...) \
- MOTH_EXPAND_FOR_MSVC(JIT_DEFINE_ARGS##nargs(__VA_ARGS__))
-
-#define JIT_DEFINE_ARGS0()
-#define JIT_DEFINE_ARGS1(arg) \
- int arg
-#define JIT_DEFINE_ARGS2(arg1, arg2) \
- int arg1, \
- int arg2
-#define JIT_DEFINE_ARGS3(arg1, arg2, arg3) \
- int arg1, \
- int arg2, \
- int arg3
-#define JIT_DEFINE_ARGS4(arg1, arg2, arg3, arg4) \
- int arg1, \
- int arg2, \
- int arg3, \
- int arg4
-
-#define JIT_DEFINE_VIRTUAL_BYTECODE_HANDLER_INSTRUCTION(name, nargs, ...) \
- virtual void generate_##name( \
- JIT_DEFINE_ARGS(nargs, __VA_ARGS__) \
- ) = 0;
-
-#define JIT_DEFINE_VIRTUAL_BYTECODE_HANDLER(instr) \
- INSTR_##instr(JIT_DEFINE_VIRTUAL_BYTECODE_HANDLER)
-
QT_BEGIN_NAMESPACE
namespace QV4 {
namespace JIT {
-class Assembler;
-
-class ByteCodeHandler
-{
-public:
- virtual ~ByteCodeHandler();
-
- void decode(const char *code, uint len);
-
- int instructionOffset() const { return _offset; }
-
-protected:
- FOR_EACH_MOTH_INSTR(JIT_DEFINE_VIRTUAL_BYTECODE_HANDLER)
-
- virtual void startInstruction(Moth::Instr::Type instr) = 0;
- virtual void endInstruction(Moth::Instr::Type instr) = 0;
-
-private:
- int _offset = 0;
-};
+class BaselineAssembler;
#ifdef V4_ENABLE_JIT
-class BaselineJIT final: public ByteCodeHandler
+class BaselineJIT final: public Moth::ByteCodeHandler
{
public:
BaselineJIT(QV4::Function *);
- virtual ~BaselineJIT();
+ virtual ~BaselineJIT() Q_DECL_OVERRIDE;
void generate();
@@ -132,6 +87,7 @@ public:
void generate_LoadReg(int reg) override;
void generate_StoreReg(int reg) override;
void generate_MoveReg(int srcReg, int destReg) override;
+ void generate_LoadImport(int index) override;
void generate_LoadLocal(int index) override;
void generate_StoreLocal(int index) override;
void generate_LoadScopedLocal(int scope, int index) override;
@@ -143,15 +99,14 @@ public:
void generate_LoadGlobalLookup(int index) override;
void generate_StoreNameSloppy(int name) override;
void generate_StoreNameStrict(int name) override;
- void generate_LoadElement(int base, int index) override;
- void generate_LoadElementA(int base) override;
+ void generate_LoadElement(int base) override;
void generate_StoreElement(int base, int index) override;
- void generate_LoadProperty(int name, int base) override;
- void generate_LoadPropertyA(int name) override;
- void generate_GetLookup(int index, int base) override;
- void generate_GetLookupA(int index) override;
+ void generate_LoadProperty(int name) override;
+ void generate_GetLookup(int index) override;
void generate_StoreProperty(int name, int base) override;
void generate_SetLookup(int index, int base) override;
+ void generate_LoadSuperProperty(int property) override;
+ void generate_StoreSuperProperty(int property) override;
void generate_StoreScopeObjectProperty(int base,
int propertyIndex) override;
void generate_StoreContextObjectProperty(int base,
@@ -161,7 +116,12 @@ public:
void generate_LoadContextObjectProperty(int propertyIndex, int base,
int captureRequired) override;
void generate_LoadIdObject(int index, int base) override;
+ void generate_Yield() override;
+ void generate_YieldStar() override;
+ void generate_Resume(int) override;
+
void generate_CallValue(int name, int argc, int argv) override;
+ void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override;
void generate_CallProperty(int name, int base, int argc, int argv) override;
void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override;
void generate_CallElement(int base, int index, int argc, int argv) override;
@@ -170,33 +130,48 @@ public:
void generate_CallGlobalLookup(int index, int argc, int argv) override;
void generate_CallScopeObjectProperty(int propIdx, int base, int argc, int argv) override;
void generate_CallContextObjectProperty(int propIdx, int base, int argc, int argv) override;
- void generate_SetExceptionHandler(int offset) override;
+ void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override;
+ void generate_Construct(int func, int argc, int argv) override;
+ void generate_ConstructWithSpread(int func, int argc, int argv) override;
+ void generate_SetUnwindHandler(int offset) override;
+ void generate_UnwindDispatch() override;
+ void generate_UnwindToLabel(int level, int offset) override;
+ void generate_DeadTemporalZoneCheck(int name) override;
void generate_ThrowException() override;
void generate_GetException() override;
void generate_SetException() override;
void generate_CreateCallContext() override;
- void generate_PushCatchContext(int name, int reg) override;
- void generate_PushWithContext(int reg) override;
- void generate_PopContext(int reg) override;
- void generate_ForeachIteratorObject() override;
- void generate_ForeachNextPropertyName() override;
- void generate_DeleteMember(int member, int base) override;
- void generate_DeleteSubscript(int base, int index) override;
+ void generate_PushCatchContext(int index, int name) override;
+ void generate_PushWithContext() override;
+ void generate_PushBlockContext(int index) override;
+ void generate_CloneBlockContext() override;
+ void generate_PushScriptContext(int index) override;
+ void generate_PopScriptContext() override;
+ void generate_PopContext() override;
+ void generate_GetIterator(int iterator) override;
+ void generate_IteratorNext(int value, int done) override;
+ void generate_IteratorNextForYieldStar(int iterator, int object) override;
+ void generate_IteratorClose(int done) override;
+ void generate_DestructureRestElement() override;
+ void generate_DeleteProperty(int base, int index) override;
void generate_DeleteName(int name) override;
void generate_TypeofName(int name) override;
void generate_TypeofValue() override;
void generate_DeclareVar(int varName, int isDeletable) override;
void generate_DefineArray(int argc, int args) override;
- void generate_DefineObjectLiteral(int internalClassId, int arrayValueCount,
- int arrayGetterSetterCountAndFlags,
- int args) override;
+ void generate_DefineObjectLiteral(int internalClassId, int argc, int args) override;
+ void generate_CreateClass(int classIndex, int heritage, int computedNames) override;
void generate_CreateMappedArgumentsObject() override;
void generate_CreateUnmappedArgumentsObject() override;
+ void generate_CreateRestParameter(int argIndex) override;
void generate_ConvertThisToObject() override;
- void generate_Construct(int func, int argc, int argv) override;
+ void generate_LoadSuperConstructor() override;
+ void generate_ToObject() override;
void generate_Jump(int offset) override;
void generate_JumpTrue(int offset) override;
void generate_JumpFalse(int offset) override;
+ void generate_JumpNoException(int offset) override;
+ void generate_JumpNotUndefined(int offset) override;
void generate_CmpEqNull() override;
void generate_CmpNeNull() override;
void generate_CmpEqInt(int lhs) override;
@@ -211,10 +186,6 @@ public:
void generate_CmpStrictNotEqual(int lhs) override;
void generate_CmpIn(int lhs) override;
void generate_CmpInstanceOf(int lhs) override;
- void generate_JumpStrictEqualStackSlotInt(int lhs, int rhs,
- int offset) override;
- void generate_JumpStrictNotEqualStackSlotInt(int lhs, int rhs,
- int offset) override;
void generate_UNot() override;
void generate_UPlus() override;
void generate_UMinus() override;
@@ -234,26 +205,29 @@ public:
void generate_UShrConst(int rhs) override;
void generate_ShrConst(int rhs) override;
void generate_ShlConst(int rhs) override;
+ void generate_Exp(int lhs) override;
void generate_Mul(int lhs) override;
void generate_Div(int lhs) override;
void generate_Mod(int lhs) override;
void generate_Sub(int lhs) override;
void generate_LoadQmlContext(int result) override;
void generate_LoadQmlImportedScripts(int result) override;
+ void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override;
+ void generate_ThrowOnNullOrUndefined() override;
void startInstruction(Moth::Instr::Type instr) override;
void endInstruction(Moth::Instr::Type instr) override;
protected:
bool hasLabel() const
- { return std::find(labels.cbegin(), labels.cend(), instructionOffset()) != labels.cend(); }
+ { return std::find(labels.cbegin(), labels.cend(), currentInstructionOffset()) != labels.cend(); }
-private:
- void collectLabelsInBytecode();
+ int absoluteOffsetForJump(int relativeOffset) const
+ { return nextInstructionOffset() + relativeOffset; }
private:
QV4::Function *function;
- QScopedPointer<Assembler> as;
+ QScopedPointer<BaselineAssembler> as;
std::vector<int> labels;
};
#endif // V4_ENABLE_JIT
diff --git a/src/qml/jit/qv4jit.cpp b/src/qml/jit/qv4jit.cpp
deleted file mode 100644
index bc46c0ca1d..0000000000
--- a/src/qml/jit/qv4jit.cpp
+++ /dev/null
@@ -1,1328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qv4jit_p.h"
-#include "qv4assembler_p.h"
-#include <private/qv4lookup_p.h>
-
-#ifdef V4_ENABLE_JIT
-
-QT_USE_NAMESPACE
-using namespace QV4;
-using namespace QV4::JIT;
-using namespace QV4::Moth;
-
-ByteCodeHandler::~ByteCodeHandler()
-{
-}
-
-#define DISPATCH_INSTRUCTION(name, nargs, ...) \
- generate_##name( \
- __VA_ARGS__ \
- );
-
-#define DECODE_AND_DISPATCH(instr) \
- { \
- INSTR_##instr(MOTH_DECODE_WITH_BASE) \
- Q_UNUSED(base_ptr); \
- startInstruction(Instr::Type::instr); \
- _offset = code - start; \
- INSTR_##instr(DISPATCH) \
- endInstruction(Instr::Type::instr); \
- continue; \
- }
-
-void ByteCodeHandler::decode(const char *code, uint len)
-{
- MOTH_JUMP_TABLE;
-
- const char *start = code;
- const char *end = code + len;
- while (code < end) {
- MOTH_DISPATCH()
-
- FOR_EACH_MOTH_INSTR(DECODE_AND_DISPATCH)
- }
-}
-
-#undef DECODE_AND_DISPATCH
-#undef DISPATCH_INSTRUCTION
-
-BaselineJIT::BaselineJIT(Function *function)
- : function(function)
- , as(new Assembler(function->compilationUnit->constants))
-{}
-
-BaselineJIT::~BaselineJIT()
-{}
-
-void BaselineJIT::generate()
-{
-// qDebug()<<"jitting" << function->name()->toQString();
- collectLabelsInBytecode();
-
- as->generatePrologue();
- decode(reinterpret_cast<const char *>(function->codeData), function->compiledFunction->codeSize);
- as->generateEpilogue();
-
- as->link(function);
-// qDebug()<<"done";
-}
-
-#define STORE_IP() as->storeInstructionPointer(instructionOffset())
-#define STORE_ACC() as->saveAccumulatorInFrame()
-
-void BaselineJIT::generate_Ret()
-{
- as->ret();
-}
-
-void BaselineJIT::generate_Debug() { Q_UNREACHABLE(); }
-
-void BaselineJIT::generate_LoadConst(int index)
-{
- as->loadConst(index);
-}
-
-void BaselineJIT::generate_LoadZero()
-{
- as->loadValue(Encode(int(0)));
-}
-
-void BaselineJIT::generate_LoadTrue()
-{
- as->loadValue(Encode(true));
-}
-
-void BaselineJIT::generate_LoadFalse()
-{
- as->loadValue(Encode(false));
-}
-
-void BaselineJIT::generate_LoadNull()
-{
- as->loadValue(Encode::null());
-}
-
-void BaselineJIT::generate_LoadUndefined()
-{
- as->loadValue(Encode::undefined());
-}
-
-void BaselineJIT::generate_LoadInt(int value)
-{
- //###
- as->loadValue(Encode(value));
-}
-
-void BaselineJIT::generate_MoveConst(int constIndex, int destTemp)
-{
- as->copyConst(constIndex, destTemp);
-}
-
-void BaselineJIT::generate_LoadReg(int reg)
-{
- as->loadReg(reg);
-}
-
-void BaselineJIT::generate_StoreReg(int reg)
-{
- as->storeReg(reg);
-}
-
-void BaselineJIT::generate_MoveReg(int srcReg, int destReg)
-{
- as->loadReg(srcReg);
- as->storeReg(destReg);
-}
-
-void BaselineJIT::generate_LoadLocal(int index)
-{
- as->loadLocal(index);
-}
-
-void BaselineJIT::generate_StoreLocal(int index)
-{
- as->checkException();
- as->storeLocal(index);
-}
-
-void BaselineJIT::generate_LoadScopedLocal(int scope, int index)
-{
- as->loadLocal(index, scope);
-}
-
-void BaselineJIT::generate_StoreScopedLocal(int scope, int index)
-{
- as->checkException();
- as->storeLocal(index, scope);
-}
-
-void BaselineJIT::generate_LoadRuntimeString(int stringId)
-{
- as->loadString(stringId);
-}
-
-void BaselineJIT::generate_MoveRegExp(int regExpId, int destReg)
-{
- as->prepareCallWithArgCount(2);
- as->passInt32AsArg(regExpId, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_regexpLiteral, Assembler::ResultInAccumulator);
- as->storeReg(destReg);
-}
-
-void BaselineJIT::generate_LoadClosure(int value)
-{
- as->prepareCallWithArgCount(2);
- as->passInt32AsArg(value, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_closure, Assembler::ResultInAccumulator);
-}
-
-void BaselineJIT::generate_LoadName(int name)
-{
- STORE_IP();
- as->prepareCallWithArgCount(2);
- as->passInt32AsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadName, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static ReturnedValue loadGlobalLookupHelper(ExecutionEngine *engine, QV4::Function *f, int index)
-{
- QV4::Lookup *l = f->compilationUnit->runtimeLookups + index;
- return l->globalGetter(l, engine);
-}
-
-void BaselineJIT::generate_LoadGlobalLookup(int index)
-{
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(index, 2);
- as->passFunctionAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(loadGlobalLookupHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_StoreNameSloppy(int name)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passAccumulatorAsArg(2);
- as->passInt32AsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameSloppy, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_StoreNameStrict(int name)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passAccumulatorAsArg(2);
- as->passInt32AsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameStrict, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadElement(int base, int index)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passRegAsArg(index, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadElement, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadElementA(int base)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passAccumulatorAsArg(2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadElement, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static void storeElementHelper(QV4::Function *f, const Value &base, const Value &index, const Value &value)
-{
- auto engine = f->internalClass->engine;
- if (!Runtime::method_storeElement(engine, base, index, value) && f->isStrict())
- engine->throwTypeError();
-}
-
-void BaselineJIT::generate_StoreElement(int base, int index)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passRegAsArg(index, 2);
- as->passRegAsArg(base, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(storeElementHelper, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadProperty(int name, int base)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(name, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-void BaselineJIT::generate_LoadPropertyA(int name)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(name, 2);
- as->passAccumulatorAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static ReturnedValue getLookupHelper(ExecutionEngine *engine, QV4::Function *f, int index, const QV4::Value &base)
-{
- QV4::Lookup *l = f->compilationUnit->runtimeLookups + index;
- return l->getter(l, engine, base);
-}
-
-void BaselineJIT::generate_GetLookup(int index, int base)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passRegAsArg(base, 3);
- as->passInt32AsArg(index, 2);
- as->passFunctionAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(getLookupHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_GetLookupA(int index)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passInt32AsArg(index, 2);
- as->passFunctionAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(getLookupHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static void storePropertyHelper(QV4::Function *f, const Value &base, int name, const Value &value)
-{
- auto engine = f->internalClass->engine;
- if (!Runtime::method_storeProperty(engine, base, name, value) && f->isStrict())
- engine->throwTypeError();
-}
-
-void BaselineJIT::generate_StoreProperty(int name, int base)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passInt32AsArg(name, 2);
- as->passRegAsArg(base, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(storePropertyHelper, Assembler::IgnoreResult);
- as->checkException();
-}
-
-static void setLookupHelper(QV4::Function *f, int index, QV4::Value &base, const QV4::Value &value)
-{
- ExecutionEngine *engine = f->internalClass->engine;
- QV4::Lookup *l = f->compilationUnit->runtimeLookups + index;
- if (!l->setter(l, engine, base, value) && f->isStrict())
- engine->throwTypeError();
-}
-
-void BaselineJIT::generate_SetLookup(int index, int base)
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passRegAsArg(base, 2);
- as->passInt32AsArg(index, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(setLookupHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_StoreScopeObjectProperty(int base, int propertyIndex)
-{
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passInt32AsArg(propertyIndex, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_storeQmlScopeObjectProperty, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_StoreContextObjectProperty(int base, int propertyIndex)
-{
- STORE_ACC();
- as->prepareCallWithArgCount(4);
- as->passAccumulatorAsArg(3);
- as->passInt32AsArg(propertyIndex, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_storeQmlContextObjectProperty, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadScopeObjectProperty(int propertyIndex, int base, int captureRequired)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(captureRequired, 3);
- as->passInt32AsArg(propertyIndex, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlScopeObjectProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadContextObjectProperty(int propertyIndex, int base, int captureRequired)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(captureRequired, 3);
- as->passInt32AsArg(propertyIndex, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlContextObjectProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_LoadIdObject(int index, int base)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(index, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlIdObject, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallValue(int name, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(argc, 3);
- as->passRegAsArg(argv, 2);
- as->passRegAsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callValue, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallProperty(int name, int base, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(argc, 4);
- as->passRegAsArg(argv, 3);
- as->passInt32AsArg(name, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(argc, 4);
- as->passRegAsArg(argv, 3);
- as->passInt32AsArg(lookupIndex, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callPropertyLookup, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallElement(int base, int index, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(argc, 4);
- as->passRegAsArg(argv, 3);
- as->passRegAsArg(index, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callElement, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallName(int name, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(argc, 3);
- as->passRegAsArg(argv, 2);
- as->passInt32AsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callName, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallPossiblyDirectEval(int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(argc, 2);
- as->passRegAsArg(argv, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callPossiblyDirectEval, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallGlobalLookup(int index, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(argc, 3);
- as->passRegAsArg(argv, 2);
- as->passInt32AsArg(index, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callGlobalLookup, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallScopeObjectProperty(int propIdx, int base, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(argc, 4);
- as->passRegAsArg(argv, 3);
- as->passInt32AsArg(propIdx, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callQmlScopeObjectProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CallContextObjectProperty(int propIdx, int base, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(argc, 4);
- as->passRegAsArg(argv, 3);
- as->passInt32AsArg(propIdx, 2);
- as->passRegAsArg(base, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_callQmlContextObjectProperty, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_SetExceptionHandler(int offset)
-{
- if (offset)
- as->setExceptionHandler(instructionOffset() + offset);
- else
- as->clearExceptionHandler();
-}
-
-void BaselineJIT::generate_ThrowException()
-{
- STORE_IP();
- STORE_ACC();
- as->prepareCallWithArgCount(2);
- as->passAccumulatorAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_throwException, Assembler::IgnoreResult);
- as->gotoCatchException();
-}
-
-void BaselineJIT::generate_GetException() { as->getException(); }
-void BaselineJIT::generate_SetException() { as->setException(); }
-
-void BaselineJIT::generate_CreateCallContext()
-{
- as->prepareCallWithArgCount(1);
- as->passCppFrameAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(ExecutionContext::newCallContext, Assembler::IgnoreResult); // keeps result in return value register
- as->storeHeapObject(CallData::Context);
-}
-
-void BaselineJIT::generate_PushCatchContext(int name, int reg) { as->pushCatchContext(name, reg); }
-
-static void pushWithContextHelper(ExecutionEngine *engine, QV4::Value *stack, int reg)
-{
- QV4::Value &accumulator = stack[CallData::Accumulator];
- accumulator = accumulator.toObject(engine);
- if (engine->hasException)
- return;
- stack[reg] = stack[CallData::Context];
- ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
- stack[CallData::Context] = Runtime::method_createWithContext(c, accumulator);
-}
-
-void BaselineJIT::generate_PushWithContext(int reg)
-{
- STORE_IP();
- as->saveAccumulatorInFrame();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(reg, 2);
- as->passRegAsArg(0, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(pushWithContextHelper, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_PopContext(int reg) { as->popContext(reg); }
-
-void BaselineJIT::generate_ForeachIteratorObject()
-{
- as->saveAccumulatorInFrame();
- as->prepareCallWithArgCount(2);
- as->passAccumulatorAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_foreachIterator, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_ForeachNextPropertyName()
-{
- as->saveAccumulatorInFrame();
- as->prepareCallWithArgCount(1);
- as->passAccumulatorAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_foreachNextPropertyName,
- Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static ReturnedValue deleteMemberHelper(QV4::Function *function, const QV4::Value &base, int member)
-{
- auto engine = function->internalClass->engine;
- if (!Runtime::method_deleteMember(engine, base, member)) {
- if (function->isStrict())
- engine->throwTypeError();
- return Encode(false);
- } else {
- return Encode(true);
- }
-}
-
-void BaselineJIT::generate_DeleteMember(int member, int base)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(member, 2);
- as->passRegAsArg(base, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(deleteMemberHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static ReturnedValue deleteSubscriptHelper(QV4::Function *function, const QV4::Value &base, const QV4::Value &index)
-{
- auto engine = function->internalClass->engine;
- if (!Runtime::method_deleteElement(engine, base, index)) {
- if (function->isStrict())
- engine->throwTypeError();
- return Encode(false);
- } else {
- return Encode(true);
- }
-}
-
-void BaselineJIT::generate_DeleteSubscript(int base, int index)
-{
- STORE_IP();
- as->prepareCallWithArgCount(3);
- as->passRegAsArg(index, 2);
- as->passRegAsArg(base, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(deleteSubscriptHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-static ReturnedValue deleteNameHelper(QV4::Function *function, int name)
-{
- auto engine = function->internalClass->engine;
- if (!Runtime::method_deleteName(engine, name)) {
- if (function->isStrict())
- engine->throwTypeError();
- return Encode(false);
- } else {
- return Encode(true);
- }
-}
-
-void BaselineJIT::generate_DeleteName(int name)
-{
- STORE_IP();
- as->prepareCallWithArgCount(2);
- as->passInt32AsArg(name, 1);
- as->passFunctionAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(deleteNameHelper, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_TypeofName(int name)
-{
- as->prepareCallWithArgCount(2);
- as->passInt32AsArg(name, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_typeofName, Assembler::ResultInAccumulator);
-}
-
-void BaselineJIT::generate_TypeofValue()
-{
- STORE_ACC();
- as->prepareCallWithArgCount(2);
- as->passAccumulatorAsArg(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_typeofValue, Assembler::ResultInAccumulator);
-}
-
-void BaselineJIT::generate_DeclareVar(int varName, int isDeletable)
-{
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(varName, 2);
- as->passInt32AsArg(isDeletable, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_declareVar, Assembler::IgnoreResult);
-}
-
-void BaselineJIT::generate_DefineArray(int argc, int args)
-{
- as->prepareCallWithArgCount(3);
- as->passInt32AsArg(argc, 2);
- as->passRegAsArg(args, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_arrayLiteral, Assembler::ResultInAccumulator);
-}
-
-void BaselineJIT::generate_DefineObjectLiteral(int internalClassId, int arrayValueCount,
- int arrayGetterSetterCountAndFlags, int args)
-{
- as->prepareCallWithArgCount(5);
- as->passInt32AsArg(arrayGetterSetterCountAndFlags, 4);
- as->passInt32AsArg(arrayValueCount, 3);
- as->passInt32AsArg(internalClassId, 2);
- as->passRegAsArg(args, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_objectLiteral, Assembler::ResultInAccumulator);
-}
-void BaselineJIT::generate_CreateMappedArgumentsObject()
-{
- as->prepareCallWithArgCount(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_createMappedArgumentsObject,
- Assembler::ResultInAccumulator);
-}
-
-void BaselineJIT::generate_CreateUnmappedArgumentsObject()
-{
- as->prepareCallWithArgCount(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_createUnmappedArgumentsObject,
- Assembler::ResultInAccumulator);
-}
-
-static void convertThisToObjectHelper(ExecutionEngine *engine, Value *t)
-{
- if (!t->isObject()) {
- if (t->isNullOrUndefined()) {
- *t = engine->globalObject->asReturnedValue();
- } else {
- *t = t->toObject(engine)->asReturnedValue();
- }
- }
-}
-
-void BaselineJIT::generate_ConvertThisToObject()
-{
- as->prepareCallWithArgCount(2);
- as->passRegAsArg(CallData::This, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(convertThisToObjectHelper, Assembler::IgnoreResult);
- as->checkException();
-}
-
-void BaselineJIT::generate_Construct(int func, int argc, int argv)
-{
- STORE_IP();
- as->prepareCallWithArgCount(4);
- as->passInt32AsArg(argc, 3);
- as->passRegAsArg(argv, 2);
- as->passRegAsArg(func, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_construct, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_Jump(int offset) { as->jump(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpTrue(int offset) { as->jumpTrue(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpFalse(int offset) { as->jumpFalse(instructionOffset() + offset); }
-
-void BaselineJIT::generate_CmpEqNull() { as->cmpeqNull(); }
-void BaselineJIT::generate_CmpNeNull() { as->cmpneNull(); }
-void BaselineJIT::generate_CmpEqInt(int lhs) { as->cmpeqInt(lhs); }
-void BaselineJIT::generate_CmpNeInt(int lhs) { as->cmpneInt(lhs); }
-void BaselineJIT::generate_CmpEq(int lhs) { as->cmpeq(lhs); }
-void BaselineJIT::generate_CmpNe(int lhs) { as->cmpne(lhs); }
-void BaselineJIT::generate_CmpGt(int lhs) { as->cmpgt(lhs); }
-void BaselineJIT::generate_CmpGe(int lhs) { as->cmpge(lhs); }
-void BaselineJIT::generate_CmpLt(int lhs) { as->cmplt(lhs); }
-void BaselineJIT::generate_CmpLe(int lhs) { as->cmple(lhs); }
-void BaselineJIT::generate_CmpStrictEqual(int lhs) { as->cmpStrictEqual(lhs); }
-void BaselineJIT::generate_CmpStrictNotEqual(int lhs) { as->cmpStrictNotEqual(lhs); }
-
-void BaselineJIT::generate_CmpIn(int lhs)
-{
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passAccumulatorAsArg(2);
- as->passRegAsArg(lhs, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_in, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_CmpInstanceOf(int lhs)
-{
- STORE_ACC();
- as->prepareCallWithArgCount(3);
- as->passAccumulatorAsArg(2);
- as->passRegAsArg(lhs, 1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_instanceof, Assembler::ResultInAccumulator);
- as->checkException();
-}
-
-void BaselineJIT::generate_JumpStrictEqualStackSlotInt(int lhs, int rhs, int offset)
-{
- as->jumpStrictEqualStackSlotInt(lhs, rhs, instructionOffset() + offset);
-}
-
-void BaselineJIT::generate_JumpStrictNotEqualStackSlotInt(int lhs, int rhs, int offset)
-{
- as->jumpStrictNotEqualStackSlotInt(lhs, rhs, instructionOffset() + offset);
-}
-
-void BaselineJIT::generate_UNot() { as->unot(); }
-void BaselineJIT::generate_UPlus() { as->toNumber(); }
-void BaselineJIT::generate_UMinus() { as->uminus(); }
-void BaselineJIT::generate_UCompl() { as->ucompl(); }
-void BaselineJIT::generate_Increment() { as->inc(); }
-void BaselineJIT::generate_Decrement() { as->dec(); }
-void BaselineJIT::generate_Add(int lhs) { as->add(lhs); }
-
-void BaselineJIT::generate_BitAnd(int lhs) { as->bitAnd(lhs); }
-void BaselineJIT::generate_BitOr(int lhs) { as->bitOr(lhs); }
-void BaselineJIT::generate_BitXor(int lhs) { as->bitXor(lhs); }
-void BaselineJIT::generate_UShr(int lhs) { as->ushr(lhs); }
-void BaselineJIT::generate_Shr(int lhs) { as->shr(lhs); }
-void BaselineJIT::generate_Shl(int lhs) { as->shl(lhs); }
-
-void BaselineJIT::generate_BitAndConst(int rhs) { as->bitAndConst(rhs); }
-void BaselineJIT::generate_BitOrConst(int rhs) { as->bitOrConst(rhs); }
-void BaselineJIT::generate_BitXorConst(int rhs) { as->bitXorConst(rhs); }
-void BaselineJIT::generate_UShrConst(int rhs) { as->ushrConst(rhs); }
-void BaselineJIT::generate_ShrConst(int rhs) { as->shrConst(rhs); }
-void BaselineJIT::generate_ShlConst(int rhs) { as->shlConst(rhs); }
-
-void BaselineJIT::generate_Mul(int lhs) { as->mul(lhs); }
-void BaselineJIT::generate_Div(int lhs) { as->div(lhs); }
-void BaselineJIT::generate_Mod(int lhs) { as->mod(lhs); }
-void BaselineJIT::generate_Sub(int lhs) { as->sub(lhs); }
-
-//void BaselineJIT::generate_BinopContext(int alu, int lhs)
-//{
-// auto engine = function->internalClass->engine;
-// void *op = engine->runtime.runtimeMethods[alu];
-// STORE_ACC();
-// as->passAccumulatorAsArg(2);
-// as->passRegAsArg(lhs, 1);
-// as->passEngineAsArg(0);
-// as->callRuntime("binopContext", op, Assembler::ResultInAccumulator);
-// as->checkException();
-//}
-
-void BaselineJIT::generate_LoadQmlContext(int result)
-{
- as->prepareCallWithArgCount(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlContext, Assembler::ResultInAccumulator);
- as->storeReg(result);
-}
-
-void BaselineJIT::generate_LoadQmlImportedScripts(int result)
-{
- as->prepareCallWithArgCount(1);
- as->passEngineAsArg(0);
- JIT_GENERATE_RUNTIME_CALL(Runtime::method_loadQmlImportedScripts, Assembler::ResultInAccumulator);
- as->storeReg(result);
-}
-
-void BaselineJIT::startInstruction(Instr::Type /*instr*/)
-{
- if (hasLabel())
- as->addLabel(instructionOffset());
-}
-
-void BaselineJIT::endInstruction(Instr::Type instr)
-{
- Q_UNUSED(instr);
-}
-
-#define MOTH_UNUSED_ARGS0()
-#define MOTH_UNUSED_ARGS1(arg) \
- Q_UNUSED(arg);
-#define MOTH_UNUSED_ARGS2(arg1, arg2) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2);
-#define MOTH_UNUSED_ARGS3(arg1, arg2, arg3) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2); \
- Q_UNUSED(arg3);
-#define MOTH_UNUSED_ARGS4(arg1, arg2, arg3, arg4) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2); \
- Q_UNUSED(arg3); \
- Q_UNUSED(arg4);
-
-#define MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, ...) \
- MOTH_EXPAND_FOR_MSVC(MOTH_UNUSED_ARGS##nargs(__VA_ARGS__))
-
-#define MOTH_MARK_ARGS_UNUSED_INSTRUCTION(name, nargs, ...) \
- MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, __VA_ARGS__)
-
-#define MOTH_BEGIN_INSTR(instr) \
- { \
- INSTR_##instr(MOTH_DECODE_WITH_BASE) \
- INSTR_##instr(MOTH_MARK_ARGS_UNUSED) \
- Q_UNUSED(base_ptr);
-
-#define MOTH_END_INSTR(instr) \
- continue; \
- }
-
-void BaselineJIT::collectLabelsInBytecode()
-{
- MOTH_JUMP_TABLE;
-
- const auto addLabel = [&](int offset) {
- Q_ASSERT(offset >= 0 && offset < static_cast<int>(function->compiledFunction->codeSize));
- labels.push_back(offset);
- };
-
- const char *code = reinterpret_cast<const char *>(function->codeData);
- const char *start = code;
- const char *end = code + function->compiledFunction->codeSize;
- while (code < end) {
- MOTH_DISPATCH()
- Q_UNREACHABLE();
-
- MOTH_BEGIN_INSTR(LoadReg)
- MOTH_END_INSTR(LoadReg)
-
- MOTH_BEGIN_INSTR(StoreReg)
- MOTH_END_INSTR(StoreReg)
-
- MOTH_BEGIN_INSTR(MoveReg)
- MOTH_END_INSTR(MoveReg)
-
- MOTH_BEGIN_INSTR(LoadConst)
- MOTH_END_INSTR(LoadConst)
-
- MOTH_BEGIN_INSTR(LoadNull)
- MOTH_END_INSTR(LoadNull)
-
- MOTH_BEGIN_INSTR(LoadZero)
- MOTH_END_INSTR(LoadZero)
-
- MOTH_BEGIN_INSTR(LoadTrue)
- MOTH_END_INSTR(LoadTrue)
-
- MOTH_BEGIN_INSTR(LoadFalse)
- MOTH_END_INSTR(LoadFalse)
-
- MOTH_BEGIN_INSTR(LoadUndefined)
- MOTH_END_INSTR(LoadUndefined)
-
- MOTH_BEGIN_INSTR(LoadInt)
- MOTH_END_INSTR(LoadInt)
-
- MOTH_BEGIN_INSTR(MoveConst)
- MOTH_END_INSTR(MoveConst)
-
- MOTH_BEGIN_INSTR(LoadLocal)
- MOTH_END_INSTR(LoadLocal)
-
- MOTH_BEGIN_INSTR(StoreLocal)
- MOTH_END_INSTR(StoreLocal)
-
- MOTH_BEGIN_INSTR(LoadScopedLocal)
- MOTH_END_INSTR(LoadScopedLocal)
-
- MOTH_BEGIN_INSTR(StoreScopedLocal)
- MOTH_END_INSTR(StoreScopedLocal)
-
- MOTH_BEGIN_INSTR(LoadRuntimeString)
- MOTH_END_INSTR(LoadRuntimeString)
-
- MOTH_BEGIN_INSTR(MoveRegExp)
- MOTH_END_INSTR(MoveRegExp)
-
- MOTH_BEGIN_INSTR(LoadClosure)
- MOTH_END_INSTR(LoadClosure)
-
- MOTH_BEGIN_INSTR(LoadName)
- MOTH_END_INSTR(LoadName)
-
- MOTH_BEGIN_INSTR(LoadGlobalLookup)
- MOTH_END_INSTR(LoadGlobalLookup)
-
- MOTH_BEGIN_INSTR(StoreNameSloppy)
- MOTH_END_INSTR(StoreNameSloppy)
-
- MOTH_BEGIN_INSTR(StoreNameStrict)
- MOTH_END_INSTR(StoreNameStrict)
-
- MOTH_BEGIN_INSTR(LoadElement)
- MOTH_END_INSTR(LoadElement)
-
- MOTH_BEGIN_INSTR(LoadElementA)
- MOTH_END_INSTR(LoadElement)
-
- MOTH_BEGIN_INSTR(StoreElement)
- MOTH_END_INSTR(StoreElement)
-
- MOTH_BEGIN_INSTR(LoadProperty)
- MOTH_END_INSTR(LoadProperty)
-
- MOTH_BEGIN_INSTR(LoadPropertyA)
- MOTH_END_INSTR(LoadElementA)
-
- MOTH_BEGIN_INSTR(GetLookup)
- MOTH_END_INSTR(GetLookup)
-
- MOTH_BEGIN_INSTR(GetLookupA)
- MOTH_END_INSTR(GetLookupA)
-
- MOTH_BEGIN_INSTR(StoreProperty)
- MOTH_END_INSTR(StoreProperty)
-
- MOTH_BEGIN_INSTR(SetLookup)
- MOTH_END_INSTR(SetLookup)
-
- MOTH_BEGIN_INSTR(StoreScopeObjectProperty)
- MOTH_END_INSTR(StoreScopeObjectProperty)
-
- MOTH_BEGIN_INSTR(LoadScopeObjectProperty)
- MOTH_END_INSTR(LoadScopeObjectProperty)
-
- MOTH_BEGIN_INSTR(StoreContextObjectProperty)
- MOTH_END_INSTR(StoreContextObjectProperty)
-
- MOTH_BEGIN_INSTR(LoadContextObjectProperty)
- MOTH_END_INSTR(LoadContextObjectProperty)
-
- MOTH_BEGIN_INSTR(LoadIdObject)
- MOTH_END_INSTR(LoadIdObject)
-
- MOTH_BEGIN_INSTR(CallValue)
- MOTH_END_INSTR(CallValue)
-
- MOTH_BEGIN_INSTR(CallProperty)
- MOTH_END_INSTR(CallProperty)
-
- MOTH_BEGIN_INSTR(CallPropertyLookup)
- MOTH_END_INSTR(CallPropertyLookup)
-
- MOTH_BEGIN_INSTR(CallElement)
- MOTH_END_INSTR(CallElement)
-
- MOTH_BEGIN_INSTR(CallName)
- MOTH_END_INSTR(CallName)
-
- MOTH_BEGIN_INSTR(CallPossiblyDirectEval)
- MOTH_END_INSTR(CallPossiblyDirectEval)
-
- MOTH_BEGIN_INSTR(CallGlobalLookup)
- MOTH_END_INSTR(CallGlobalLookup)
-
- MOTH_BEGIN_INSTR(CallScopeObjectProperty)
- MOTH_END_INSTR(CallScopeObjectProperty)
-
- MOTH_BEGIN_INSTR(CallContextObjectProperty)
- MOTH_END_INSTR(CallContextObjectProperty)
-
- MOTH_BEGIN_INSTR(SetExceptionHandler)
- addLabel(code - start + offset);
- MOTH_END_INSTR(SetExceptionHandler)
-
- MOTH_BEGIN_INSTR(ThrowException)
- MOTH_END_INSTR(ThrowException)
-
- MOTH_BEGIN_INSTR(GetException)
- MOTH_END_INSTR(HasException)
-
- MOTH_BEGIN_INSTR(SetException)
- MOTH_END_INSTR(SetExceptionFlag)
-
- MOTH_BEGIN_INSTR(CreateCallContext)
- MOTH_END_INSTR(CreateCallContext)
-
- MOTH_BEGIN_INSTR(PushCatchContext)
- MOTH_END_INSTR(PushCatchContext)
-
- MOTH_BEGIN_INSTR(PushWithContext)
- MOTH_END_INSTR(PushWithContext)
-
- MOTH_BEGIN_INSTR(PopContext)
- MOTH_END_INSTR(PopContext)
-
- MOTH_BEGIN_INSTR(ForeachIteratorObject)
- MOTH_END_INSTR(ForeachIteratorObject)
-
- MOTH_BEGIN_INSTR(ForeachNextPropertyName)
- MOTH_END_INSTR(ForeachNextPropertyName)
-
- MOTH_BEGIN_INSTR(DeleteMember)
- MOTH_END_INSTR(DeleteMember)
-
- MOTH_BEGIN_INSTR(DeleteSubscript)
- MOTH_END_INSTR(DeleteSubscript)
-
- MOTH_BEGIN_INSTR(DeleteName)
- MOTH_END_INSTR(DeleteName)
-
- MOTH_BEGIN_INSTR(TypeofName)
- MOTH_END_INSTR(TypeofName)
-
- MOTH_BEGIN_INSTR(TypeofValue)
- MOTH_END_INSTR(TypeofValue)
-
- MOTH_BEGIN_INSTR(DeclareVar)
- MOTH_END_INSTR(DeclareVar)
-
- MOTH_BEGIN_INSTR(DefineArray)
- MOTH_END_INSTR(DefineArray)
-
- MOTH_BEGIN_INSTR(DefineObjectLiteral)
- MOTH_END_INSTR(DefineObjectLiteral)
-
- MOTH_BEGIN_INSTR(CreateMappedArgumentsObject)
- MOTH_END_INSTR(CreateMappedArgumentsObject)
-
- MOTH_BEGIN_INSTR(CreateUnmappedArgumentsObject)
- MOTH_END_INSTR(CreateUnmappedArgumentsObject)
-
- MOTH_BEGIN_INSTR(ConvertThisToObject)
- MOTH_END_INSTR(ConvertThisToObject)
-
- MOTH_BEGIN_INSTR(Construct)
- MOTH_END_INSTR(Construct)
-
- MOTH_BEGIN_INSTR(Jump)
- addLabel(code - start + offset);
- MOTH_END_INSTR(Jump)
-
- MOTH_BEGIN_INSTR(JumpTrue)
- addLabel(code - start + offset);
- MOTH_END_INSTR(JumpTrue)
-
- MOTH_BEGIN_INSTR(JumpFalse)
- addLabel(code - start + offset);
- MOTH_END_INSTR(JumpFalse)
-
- MOTH_BEGIN_INSTR(CmpEqNull)
- MOTH_END_INSTR(CmpEqNull)
-
- MOTH_BEGIN_INSTR(CmpNeNull)
- MOTH_END_INSTR(CmpNeNull)
-
- MOTH_BEGIN_INSTR(CmpEqInt)
- MOTH_END_INSTR(CmpEq)
-
- MOTH_BEGIN_INSTR(CmpNeInt)
- MOTH_END_INSTR(CmpNeInt)
-
- MOTH_BEGIN_INSTR(CmpEq)
- MOTH_END_INSTR(CmpEq)
-
- MOTH_BEGIN_INSTR(CmpNe)
- MOTH_END_INSTR(CmpNe)
-
- MOTH_BEGIN_INSTR(CmpGt)
- MOTH_END_INSTR(CmpGt)
-
- MOTH_BEGIN_INSTR(CmpGe)
- MOTH_END_INSTR(CmpGe)
-
- MOTH_BEGIN_INSTR(CmpLt)
- MOTH_END_INSTR(CmpLt)
-
- MOTH_BEGIN_INSTR(CmpLe)
- MOTH_END_INSTR(CmpLe)
-
- MOTH_BEGIN_INSTR(CmpStrictEqual)
- MOTH_END_INSTR(CmpStrictEqual)
-
- MOTH_BEGIN_INSTR(CmpStrictNotEqual)
- MOTH_END_INSTR(CmpStrictNotEqual)
-
- MOTH_BEGIN_INSTR(CmpIn)
- MOTH_END_INSTR(CmpIn)
-
- MOTH_BEGIN_INSTR(CmpInstanceOf)
- MOTH_END_INSTR(CmpInstanceOf)
-
- MOTH_BEGIN_INSTR(JumpStrictEqualStackSlotInt)
- addLabel(code - start + offset);
- MOTH_END_INSTR(JumpStrictEqualStackSlotInt)
-
- MOTH_BEGIN_INSTR(JumpStrictNotEqualStackSlotInt)
- addLabel(code - start + offset);
- MOTH_END_INSTR(JumpStrictNotEqualStackSlotInt)
-
- MOTH_BEGIN_INSTR(UNot)
- MOTH_END_INSTR(UNot)
-
- MOTH_BEGIN_INSTR(UPlus)
- MOTH_END_INSTR(UPlus)
-
- MOTH_BEGIN_INSTR(UMinus)
- MOTH_END_INSTR(UMinus)
-
- MOTH_BEGIN_INSTR(UCompl)
- MOTH_END_INSTR(UCompl)
-
- MOTH_BEGIN_INSTR(Increment)
- MOTH_END_INSTR(PreIncrement)
-
- MOTH_BEGIN_INSTR(Decrement)
- MOTH_END_INSTR(PreDecrement)
-
- MOTH_BEGIN_INSTR(Add)
- MOTH_END_INSTR(Add)
-
- MOTH_BEGIN_INSTR(BitAnd)
- MOTH_END_INSTR(BitAnd)
-
- MOTH_BEGIN_INSTR(BitOr)
- MOTH_END_INSTR(BitOr)
-
- MOTH_BEGIN_INSTR(BitXor)
- MOTH_END_INSTR(BitXor)
-
- MOTH_BEGIN_INSTR(UShr)
- MOTH_END_INSTR(UShr)
-
- MOTH_BEGIN_INSTR(Shr)
- MOTH_END_INSTR(Shr)
-
- MOTH_BEGIN_INSTR(Shl)
- MOTH_END_INSTR(Shl)
-
- MOTH_BEGIN_INSTR(BitAndConst)
- MOTH_END_INSTR(BitAndConst)
-
- MOTH_BEGIN_INSTR(BitOrConst)
- MOTH_END_INSTR(BitOr)
-
- MOTH_BEGIN_INSTR(BitXorConst)
- MOTH_END_INSTR(BitXor)
-
- MOTH_BEGIN_INSTR(UShrConst)
- MOTH_END_INSTR(UShrConst)
-
- MOTH_BEGIN_INSTR(ShrConst)
- MOTH_END_INSTR(ShrConst)
-
- MOTH_BEGIN_INSTR(ShlConst)
- MOTH_END_INSTR(ShlConst)
-
- MOTH_BEGIN_INSTR(Mul)
- MOTH_END_INSTR(Mul)
-
- MOTH_BEGIN_INSTR(Div)
- MOTH_END_INSTR(Div)
-
- MOTH_BEGIN_INSTR(Mod)
- MOTH_END_INSTR(Mod)
-
- MOTH_BEGIN_INSTR(Sub)
- MOTH_END_INSTR(Sub)
-
- MOTH_BEGIN_INSTR(Ret)
- MOTH_END_INSTR(Ret)
-
- MOTH_BEGIN_INSTR(Debug)
- MOTH_END_INSTR(Debug)
-
- MOTH_BEGIN_INSTR(LoadQmlContext)
- MOTH_END_INSTR(LoadQmlContext)
-
- MOTH_BEGIN_INSTR(LoadQmlImportedScripts)
- MOTH_END_INSTR(LoadQmlImportedScripts)
- }
-}
-#undef MOTH_BEGIN_INSTR
-#undef MOTH_END_INSTR
-
-#endif // V4_ENABLE_JIT
diff --git a/src/qml/jit/qv4jithelpers.cpp b/src/qml/jit/qv4jithelpers.cpp
new file mode 100644
index 0000000000..f43f37ad70
--- /dev/null
+++ b/src/qml/jit/qv4jithelpers.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4jithelpers_p.h"
+#include "qv4engine_p.h"
+#include "qv4function_p.h"
+#include "qv4value_p.h"
+#include "qv4object_p.h"
+#include "qv4functionobject_p.h"
+#include "qv4lookup_p.h"
+#include <QtCore/private/qnumeric_p.h>
+
+#ifdef V4_ENABLE_JIT
+
+QT_BEGIN_NAMESPACE
+namespace QV4 {
+namespace JIT {
+namespace Helpers {
+
+void convertThisToObject(ExecutionEngine *engine, Value *t)
+{
+ if (!t->isObject()) {
+ if (t->isNullOrUndefined()) {
+ *t = engine->globalObject->asReturnedValue();
+ } else {
+ *t = t->toObject(engine)->asReturnedValue();
+ }
+ }
+}
+
+ReturnedValue loadGlobalLookup(Function *f, ExecutionEngine *engine, int index)
+{
+ Lookup *l = f->compilationUnit->runtimeLookups + index;
+ return l->globalGetter(l, engine);
+}
+
+ReturnedValue toObject(ExecutionEngine *engine, const Value &obj)
+{
+ if (obj.isObject())
+ return obj.asReturnedValue();
+
+ return obj.toObject(engine)->asReturnedValue();
+}
+
+ReturnedValue exp(const Value &base, const Value &exp)
+{
+ double b = base.toNumber();
+ double e = exp.toNumber();
+ if (qt_is_inf(e) && (b == 1 || b == -1))
+ return Encode(qt_snan());
+ return Encode(pow(b,e));
+}
+
+ReturnedValue getLookup(Function *f, ExecutionEngine *engine, const Value &base, int index)
+{
+ Lookup *l = f->compilationUnit->runtimeLookups + index;
+ return l->getter(l, engine, base);
+}
+
+void setLookupSloppy(Function *f, int index, Value &base, const Value &value)
+{
+ ExecutionEngine *engine = f->internalClass->engine;
+ QV4::Lookup *l = f->compilationUnit->runtimeLookups + index;
+ l->setter(l, engine, base, value);
+}
+
+void setLookupStrict(Function *f, int index, Value &base, const Value &value)
+{
+ ExecutionEngine *engine = f->internalClass->engine;
+ QV4::Lookup *l = f->compilationUnit->runtimeLookups + index;
+ if (!l->setter(l, engine, base, value))
+ engine->throwTypeError();
+}
+
+
+void pushBlockContext(Value *stack, int index)
+{
+ ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
+ stack[CallData::Context] = Runtime::method_createBlockContext(c, index);
+}
+
+void cloneBlockContext(Value *contextSlot)
+{
+ *contextSlot = Runtime::method_cloneBlockContext(static_cast<QV4::ExecutionContext *>(contextSlot));
+}
+
+void pushScriptContext(Value *stack, ExecutionEngine *engine, int index)
+{
+ stack[CallData::Context] = Runtime::method_createScriptContext(engine, index);
+}
+
+void popScriptContext(Value *stack, ExecutionEngine *engine)
+{
+ stack[CallData::Context] = Runtime::method_popScriptContext(engine);
+}
+
+ReturnedValue deleteProperty(QV4::Function *function, const QV4::Value &base, const QV4::Value &index)
+{
+ auto engine = function->internalClass->engine;
+ if (!Runtime::method_deleteProperty(engine, base, index)) {
+ if (function->isStrict())
+ engine->throwTypeError();
+ return Encode(false);
+ } else {
+ return Encode(true);
+ }
+}
+
+ReturnedValue deleteName(Function *function, int name)
+{
+ auto engine = function->internalClass->engine;
+ if (!Runtime::method_deleteName(engine, name)) {
+ if (function->isStrict())
+ engine->throwTypeError();
+ return Encode(false);
+ } else {
+ return Encode(true);
+ }
+}
+
+void throwOnNullOrUndefined(ExecutionEngine *engine, const Value &v)
+{
+ if (v.isNullOrUndefined())
+ engine->throwTypeError();
+}
+
+} // Helpers namespace
+} // JIT namespace
+} // QV4 namespace
+QT_END_NAMESPACE
+
+#endif // V4_ENABLE_JIT
diff --git a/src/qml/jit/qv4jithelpers_p.h b/src/qml/jit/qv4jithelpers_p.h
new file mode 100644
index 0000000000..bd5f65034d
--- /dev/null
+++ b/src/qml/jit/qv4jithelpers_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEMPLATE_H
+#define TEMPLATE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qv4global_p.h>
+
+//QT_REQUIRE_CONFIG(qml_jit);
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+#ifdef V4_ENABLE_JIT
+
+namespace JIT {
+namespace Helpers {
+
+void convertThisToObject(ExecutionEngine *engine, Value *t);
+ReturnedValue loadGlobalLookup(Function *f, ExecutionEngine *engine, int index);
+ReturnedValue toObject(ExecutionEngine *engine, const Value &obj);
+ReturnedValue exp(const Value &base, const Value &exp);
+ReturnedValue getLookup(Function *f, ExecutionEngine *engine, const Value &base, int index);
+void setLookupStrict(Function *f, int index, Value &base, const Value &value);
+void setLookupSloppy(Function *f, int index, Value &base, const Value &value);
+void pushBlockContext(Value *stack, int index);
+void cloneBlockContext(Value *contextSlot);
+void pushScriptContext(Value *stack, ExecutionEngine *engine, int index);
+void popScriptContext(Value *stack, ExecutionEngine *engine);
+ReturnedValue deleteProperty(QV4::Function *function, const QV4::Value &base, const QV4::Value &index);
+ReturnedValue deleteName(Function *function, int name);
+void throwOnNullOrUndefined(ExecutionEngine *engine, const Value &v);
+
+} // Helpers namespace
+} // JIT namespace
+
+#endif // V4_ENABLE_JIT
+
+} // QV4 namespace
+
+QT_END_NAMESPACE
+
+#endif // TEMPLATE_H
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index c483af638b..4aa7c4b45d 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -51,6 +51,8 @@
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmldebugconnector_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qv4stackframe_p.h>
+#include <private/qv4module_p.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qmetaobject.h>
@@ -113,6 +115,45 @@ Q_DECLARE_METATYPE(QList<int>)
argument is a general-purpose string that is stored in the \c Error
object for debugging purposes.
+ For larger pieces of functionality, you may want to encapsulate
+ your code and data into modules. A module is a file that contains
+ script code, variables, etc., and uses export statements to describe
+ its interface towards the rest of the application. With the help of
+ import statements, a module can refer to functionality from other modules.
+ This allows building a scripted application from smaller connected building blocks
+ in a safe way. In contrast, the approach of using evaluate() carries the risk
+ that internal variables or functions from one evaluate() call accidentally pollute the
+ global object and affect subsequent evaluations.
+
+ The following example provides a module that can add numbers:
+
+ \code
+ export function sum(left, right)
+ {
+ return left + right
+ }
+ \endcode
+
+ This module can be loaded with QJSEngine::import() if it is saved under
+ the name \c{math.mjs}:
+
+ \code
+ QJSvalue module = myEngine.importModule("./math.mjs");
+ QJSValue sumFunction = module.property("sum");
+ QJSValue result = sumFunction.call(args);
+ \endcode
+
+ Modules can also use functionality from other modules using import
+ statements:
+
+ \code
+ import { sum } from "./math.mjs";
+ export function addTwice(left, right)
+ {
+ return sum(left, right) * 2;
+ }
+ \endcode
+
\section1 Engine Configuration
The globalObject() function returns the \b {Global Object}
@@ -304,9 +345,9 @@ QJSEngine::QJSEngine()
QJSEngine::QJSEngine(QObject *parent)
: QObject(*new QJSEnginePrivate, parent)
- , m_v4Engine(new QV4::ExecutionEngine)
+ , m_v4Engine(new QV4::ExecutionEngine(this))
{
- m_v4Engine->v8Engine = new QV8Engine(this, m_v4Engine);
+ m_v4Engine->v8Engine = new QV8Engine(m_v4Engine);
checkForApplicationInstance();
QJSEnginePrivate::addToDebugServer(this);
@@ -317,9 +358,9 @@ QJSEngine::QJSEngine(QObject *parent)
*/
QJSEngine::QJSEngine(QJSEnginePrivate &dd, QObject *parent)
: QObject(dd, parent)
- , m_v4Engine(new QV4::ExecutionEngine)
+ , m_v4Engine(new QV4::ExecutionEngine(this))
{
- m_v4Engine->v8Engine = new QV8Engine(this, m_v4Engine);
+ m_v4Engine->v8Engine = new QV8Engine(m_v4Engine);
checkForApplicationInstance();
}
@@ -462,7 +503,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
QV4::Scope scope(v4);
QV4::ScopedValue result(scope);
- QV4::Script script(v4->rootContext(), QV4::Compiler::GlobalCode, program, fileName, lineNumber);
+ QV4::Script script(v4->rootContext(), QV4::Compiler::ContextType::Global, program, fileName, lineNumber);
script.strictMode = false;
if (v4->currentStackFrame)
script.strictMode = v4->currentStackFrame->v4Function->isStrict();
@@ -480,6 +521,54 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
return retval;
}
+static QUrl moduleUrlForFileName(const QString &fileName)
+{
+ QString absolutePath = QFileInfo(fileName).canonicalFilePath();
+ if (!absolutePath.startsWith(QLatin1Char(':')))
+ return QUrl::fromLocalFile(absolutePath);
+
+ absolutePath.remove(0, 1);
+ QUrl url;
+ url.setPath(absolutePath);
+ url.setScheme(QLatin1String("qrc"));
+ return url;
+}
+
+/*!
+ Imports the module located at \a fileName and returns a module namespace object that
+ contains all exported variables, constants and functions as properties.
+
+ If this is the first time the module is imported in the engine, the file is loaded
+ from the specified location in either the local file system or the Qt resource system
+ and evaluated as an ECMAScript module. The file is expected to be encoded in UTF-8 text.
+
+ Subsequent imports of the same module will return the previously imported instance. Modules
+ are singletons and remain around until the engine is destroyed.
+
+ The specified \a fileName will internally be normalized using \a QFileInfo::canonicalFilePath().
+ That means that multiple imports of the same file on disk using different relative paths will
+ load the file only once.
+
+ \note If an exception is thrown during the loading of the module, the return value
+ will be the exception (typically an \c{Error} object; see QJSValue::isError()).
+
+ \since 5.12
+ */
+QJSValue QJSEngine::importModule(const QString &fileName)
+{
+ const QUrl url = moduleUrlForFileName(fileName);
+ auto moduleUnit = m_v4Engine->loadModule(url);
+ if (m_v4Engine->hasException)
+ return QJSValue(m_v4Engine, m_v4Engine->catchException());
+
+ QV4::Scope scope(m_v4Engine);
+ QV4::Scoped<QV4::Module> moduleNamespace(scope, moduleUnit->instantiate(m_v4Engine));
+ if (m_v4Engine->hasException)
+ return QJSValue(m_v4Engine, m_v4Engine->catchException());
+ moduleUnit->evaluate();
+ return QJSValue(m_v4Engine, moduleNamespace->asReturnedValue());
+}
+
/*!
Creates a JavaScript object of class Object.
@@ -637,16 +726,16 @@ bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
double d = QV4::RuntimeHelpers::stringToNumber(string);
switch (type) {
case QMetaType::Int:
- *reinterpret_cast<int*>(ptr) = QV4::Primitive::toInt32(d);
+ *reinterpret_cast<int*>(ptr) = QV4::Value::toInt32(d);
return true;
case QMetaType::UInt:
- *reinterpret_cast<uint*>(ptr) = QV4::Primitive::toUInt32(d);
+ *reinterpret_cast<uint*>(ptr) = QV4::Value::toUInt32(d);
return true;
case QMetaType::LongLong:
- *reinterpret_cast<qlonglong*>(ptr) = QV4::Primitive::toInteger(d);
+ *reinterpret_cast<qlonglong*>(ptr) = QV4::Value::toInteger(d);
return true;
case QMetaType::ULongLong:
- *reinterpret_cast<qulonglong*>(ptr) = QV4::Primitive::toInteger(d);
+ *reinterpret_cast<qulonglong*>(ptr) = QV4::Value::toInteger(d);
return true;
case QMetaType::Double:
*reinterpret_cast<double*>(ptr) = d;
@@ -655,19 +744,19 @@ bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
*reinterpret_cast<float*>(ptr) = d;
return true;
case QMetaType::Short:
- *reinterpret_cast<short*>(ptr) = QV4::Primitive::toInt32(d);
+ *reinterpret_cast<short*>(ptr) = QV4::Value::toInt32(d);
return true;
case QMetaType::UShort:
- *reinterpret_cast<unsigned short*>(ptr) = QV4::Primitive::toUInt32(d);
+ *reinterpret_cast<unsigned short*>(ptr) = QV4::Value::toUInt32(d);
return true;
case QMetaType::Char:
- *reinterpret_cast<char*>(ptr) = QV4::Primitive::toInt32(d);
+ *reinterpret_cast<char*>(ptr) = QV4::Value::toInt32(d);
return true;
case QMetaType::UChar:
- *reinterpret_cast<unsigned char*>(ptr) = QV4::Primitive::toUInt32(d);
+ *reinterpret_cast<unsigned char*>(ptr) = QV4::Value::toUInt32(d);
return true;
case QMetaType::QChar:
- *reinterpret_cast<QChar*>(ptr) = QV4::Primitive::toUInt32(d);
+ *reinterpret_cast<QChar*>(ptr) = QV4::Value::toUInt32(d);
return true;
default:
return false;
@@ -738,6 +827,74 @@ bool QJSEngine::convertV2(const QJSValue &value, int type, void *ptr)
\sa toScriptValue()
*/
+/*!
+ Throws a run-time error (exception) with the given \a message.
+
+ This method is the C++ counterpart of a \c throw() expression in
+ JavaScript. It enables C++ code to report run-time errors to QJSEngine.
+ Therefore it should only be called from C++ code that was invoked by a
+ JavaScript function through QJSEngine.
+
+ When returning from C++, the engine will interrupt the normal flow of
+ execution and call the the next pre-registered exception handler with
+ an error object that contains the given \a message. The error object
+ will point to the location of the top-most context on the JavaScript
+ caller stack; specifically, it will have properties \c lineNumber,
+ \c fileName and \c stack. These properties are described in
+ \l{Script Exceptions}.
+
+ In the following example a C++ method in \e FileAccess.cpp throws an error
+ in \e qmlFile.qml at the position where \c readFileAsText() is called:
+
+ \code
+ // qmlFile.qml
+ function someFunction() {
+ ...
+ var text = FileAccess.readFileAsText("/path/to/file.txt");
+ }
+ \endcode
+
+ \code
+ // FileAccess.cpp
+ // Assuming that FileAccess is a QObject-derived class that has been
+ // registered as a singleton type and provides an invokable method
+ // readFileAsText()
+
+ QJSValue FileAccess::readFileAsText(const QString & filePath) {
+ QFile file(filePath);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ jsEngine->throwError(file.errorString());
+ return QString();
+ }
+
+ ...
+ return content;
+ }
+ \endcode
+
+ It is also possible to catch the thrown error in JavaScript:
+ \code
+ // qmlFile.qml
+ function someFunction() {
+ ...
+ var text;
+ try {
+ text = FileAccess.readFileAsText("/path/to/file.txt");
+ } catch (error) {
+ console.warn("In " + error.fileName + ":" + "error.lineNumber" +
+ ": " + error.message);
+ }
+ }
+ \endcode
+
+ \since Qt 5.12
+ \sa {Script Exceptions}
+*/
+void QJSEngine::throwError(const QString &message)
+{
+ m_v4Engine->throwError(message);
+}
QJSEnginePrivate *QJSEnginePrivate::get(QV4::ExecutionEngine *e)
{
diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h
index 3ba2b52e89..5c8613ffd6 100644
--- a/src/qml/jsapi/qjsengine.h
+++ b/src/qml/jsapi/qjsengine.h
@@ -69,6 +69,8 @@ public:
QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
+ QJSValue importModule(const QString &fileName);
+
QJSValue newObject();
QJSValue newArray(uint length = 0);
@@ -111,6 +113,8 @@ public:
QV4::ExecutionEngine *handle() const { return m_v4Engine; }
+ void throwError(const QString &message);
+
private:
QJSValue create(int type, const void *ptr);
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 348ddb25d9..9671e82187 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -569,7 +569,7 @@ qint32 QJSValue::toInt() const
if (!val) {
QVariant *variant = QJSValuePrivate::getVariant(this);
if (variant->userType() == QMetaType::QString)
- return QV4::Primitive::toInt32(RuntimeHelpers::stringToNumber(variant->toString()));
+ return QV4::Value::toInt32(RuntimeHelpers::stringToNumber(variant->toString()));
else
return variant->toInt();
}
@@ -603,7 +603,7 @@ quint32 QJSValue::toUInt() const
if (!val) {
QVariant *variant = QJSValuePrivate::getVariant(this);
if (variant->userType() == QMetaType::QString)
- return QV4::Primitive::toUInt32(RuntimeHelpers::stringToNumber(variant->toString()));
+ return QV4::Value::toUInt32(RuntimeHelpers::stringToNumber(variant->toString()));
else
return variant->toUInt();
}
@@ -852,7 +852,7 @@ QJSValue QJSValue::prototype() const
ScopedObject o(scope, QJSValuePrivate::getValue(this)->as<QV4::Object>());
if (!o)
return QJSValue();
- ScopedObject p(scope, o->prototype());
+ ScopedObject p(scope, o->getPrototypeOf());
if (!p)
return QJSValue(NullValue);
return QJSValue(o->internalClass()->engine, p.asReturnedValue());
@@ -884,7 +884,7 @@ void QJSValue::setPrototype(const QJSValue& prototype)
if (!val)
return;
if (val->isNull()) {
- o->setPrototype(nullptr);
+ o->setPrototypeOf(nullptr);
return;
}
@@ -895,7 +895,7 @@ void QJSValue::setPrototype(const QJSValue& prototype)
qWarning("QJSValue::setPrototype() failed: cannot set a prototype created in a different engine");
return;
}
- if (!o->setPrototype(p))
+ if (!o->setPrototypeOf(p))
qWarning("QJSValue::setPrototype() failed: cyclic prototype value");
}
@@ -1058,12 +1058,7 @@ QJSValue QJSValue::property(const QString& name) const
return QJSValue();
ScopedString s(scope, engine->newString(name));
- uint idx = s->asArrayIndex();
- if (idx < UINT_MAX)
- return property(idx);
-
- s->makeIdentifier();
- QV4::ScopedValue result(scope, o->get(s));
+ QV4::ScopedValue result(scope, o->get(s->toPropertyKey()));
if (engine->hasException)
result = engine->catchException();
@@ -1110,7 +1105,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
if (!o)
return QJSValue();
- QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->getIndexed(arrayIndex));
+ QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->get(arrayIndex));
if (engine->hasException)
engine->catchException();
return QJSValue(engine, result->asReturnedValue());
@@ -1148,15 +1143,8 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value)
}
ScopedString s(scope, engine->newString(name));
- uint idx = s->asArrayIndex();
- if (idx < UINT_MAX) {
- setProperty(idx, value);
- return;
- }
-
- s->makeIdentifier();
QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value));
- o->put(s, v);
+ o->put(s->toPropertyKey(), v);
if (engine->hasException)
engine->catchException();
}
@@ -1209,10 +1197,8 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
}
QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value));
- if (arrayIndex != UINT_MAX)
- o->putIndexed(arrayIndex, v);
- else
- o->put(engine->id_uintMax(), v);
+ PropertyKey id = arrayIndex != UINT_MAX ? PropertyKey::fromArrayIndex(arrayIndex) : engine->id_uintMax()->propertyKey();
+ o->put(id, v);
if (engine->hasException)
engine->catchException();
}
@@ -1249,7 +1235,7 @@ bool QJSValue::deleteProperty(const QString &name)
return false;
ScopedString s(scope, engine->newString(name));
- return o->deleteProperty(s);
+ return o->deleteProperty(s->toPropertyKey());
}
/*!
@@ -1269,8 +1255,8 @@ bool QJSValue::hasProperty(const QString &name) const
if (!o)
return false;
- ScopedString s(scope, engine->newIdentifier(name));
- return o->hasProperty(s);
+ ScopedString s(scope, engine->newString(name));
+ return o->hasProperty(s->toPropertyKey());
}
/*!
@@ -1291,7 +1277,7 @@ bool QJSValue::hasOwnProperty(const QString &name) const
return false;
ScopedString s(scope, engine->newIdentifier(name));
- return o->hasOwnProperty(s);
+ return o->getOwnProperty(s->propertyKey()) != Attr_Invalid;
}
/*!
diff --git a/src/qml/jsapi/qjsvalue_p.h b/src/qml/jsapi/qjsvalue_p.h
index 62e09f72be..bcf0a9d12d 100644
--- a/src/qml/jsapi/qjsvalue_p.h
+++ b/src/qml/jsapi/qjsvalue_p.h
@@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
-class QJSValuePrivate
+class Q_AUTOTEST_EXPORT QJSValuePrivate
{
public:
static inline QV4::Value *getValue(const QJSValue *jsval)
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index ce472ce7e5..076b90c5f2 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -47,19 +47,50 @@
QT_BEGIN_NAMESPACE
QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValue &v)
- : value(v)
- , currentIndex(UINT_MAX)
- , nextIndex(UINT_MAX)
{
+ init(v);
+}
+
+void QJSValueIteratorPrivate::init(const QJSValue &v)
+{
+ engine = nullptr;
+
QV4::ExecutionEngine *e = QJSValuePrivate::engine(&v);
if (!e)
return;
+ QV4::Object *o = QJSValuePrivate::getValue(&v)->objectValue();
+ if (!o)
+ return;
- QV4::Scope scope(e);
- QV4::ScopedObject o(scope, QJSValuePrivate::getValue(&v));
- iterator.set(e, e->newForEachIteratorObject(o));
+ engine = e;
+ object = o;
+ iterator.reset(o->ownPropertyKeys(object.valueRef()));
+ next();
}
+void QJSValueIteratorPrivate::next()
+{
+ QV4::Object *o = object.as<QV4::Object>();
+ if (!o || !iterator)
+ return;
+
+ QV4::PropertyKey key;
+ while (1) {
+ key = iterator->next(o);
+ if (!key.isSymbol())
+ break;
+ }
+ currentKey = nextKey;
+ nextKey.set(engine, key.id());
+}
+
+bool QJSValueIteratorPrivate::isValid() const
+{
+ if (!engine || !iterator)
+ return false;
+ QV4::Value *val = object.valueRef();
+ return (val && val->isObject());
+}
/*!
\class QJSValueIterator
@@ -98,17 +129,6 @@ QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValue &v)
QJSValueIterator::QJSValueIterator(const QJSValue& object)
: d_ptr(new QJSValueIteratorPrivate(object))
{
- QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
- if (!v4)
- return;
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->d()->it().flags = QV4::ObjectIterator::NoFlags;
- QV4::ScopedString nm(scope);
- QV4::Property nextProperty;
- QV4::PropertyAttributes nextAttributes;
- it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
- d_ptr->nextName.set(v4, nm.asReturnedValue());
}
/*!
@@ -127,10 +147,9 @@ QJSValueIterator::~QJSValueIterator()
*/
bool QJSValueIterator::hasNext() const
{
- QV4::Value *val = QJSValuePrivate::getValue(&d_ptr->value);
- if (!val || !val->isObject())
+ if (!d_ptr->isValid())
return false;
- return d_ptr->nextName.as<QV4::String>() || d_ptr->nextIndex != UINT_MAX;
+ return QV4::PropertyKey::fromId(d_ptr->nextKey.value()).isValid();
}
/*!
@@ -143,23 +162,10 @@ bool QJSValueIterator::hasNext() const
*/
bool QJSValueIterator::next()
{
- QV4::Value *val = QJSValuePrivate::getValue(&d_ptr->value);
- if (!val || !val->isObject())
- return false;
- d_ptr->currentName = d_ptr->nextName;
- d_ptr->currentIndex = d_ptr->nextIndex;
-
- QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
- if (!v4)
+ if (!d_ptr->isValid())
return false;
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- QV4::ScopedString nm(scope);
- QV4::Property nextProperty;
- QV4::PropertyAttributes nextAttributes;
- it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
- d_ptr->nextName.set(v4, nm.asReturnedValue());
- return d_ptr->currentName.as<QV4::String>() || d_ptr->currentIndex != UINT_MAX;
+ d_ptr->next();
+ return QV4::PropertyKey::fromId(d_ptr->currentKey.value()).isValid();
}
/*!
@@ -170,14 +176,14 @@ bool QJSValueIterator::next()
*/
QString QJSValueIterator::name() const
{
- QV4::Value *val = QJSValuePrivate::getValue(&d_ptr->value);
- if (!val || !val->isObject())
+ if (!d_ptr->isValid())
+ return QString();
+ QV4::Scope scope(d_ptr->engine);
+ QV4::ScopedPropertyKey key(scope, QV4::PropertyKey::fromId(d_ptr->currentKey.value()));
+ if (!key->isValid())
return QString();
- if (QV4::String *s = d_ptr->currentName.as<QV4::String>())
- return s->toQString();
- if (d_ptr->currentIndex < UINT_MAX)
- return QString::number(d_ptr->currentIndex);
- return QString();
+ Q_ASSERT(!key->isSymbol());
+ return key->toStringOrSymbol(d_ptr->engine)->toQString();
}
@@ -189,23 +195,21 @@ QString QJSValueIterator::name() const
*/
QJSValue QJSValueIterator::value() const
{
- QV4::ExecutionEngine *engine = d_ptr->iterator.engine();
- if (!engine)
+ if (!d_ptr->isValid())
return QJSValue();
- QV4::Scope scope(engine);
- QV4::ScopedObject obj(scope, QJSValuePrivate::getValue(&d_ptr->value));
- if (!obj)
+ QV4::Scope scope(d_ptr->engine);
+ QV4::ScopedPropertyKey key(scope, QV4::PropertyKey::fromId(d_ptr->currentKey.value()));
+ if (!key->isValid())
return QJSValue();
- if (!d_ptr->currentName.as<QV4::String>() && d_ptr->currentIndex == UINT_MAX)
- return QJSValue();
+ QV4::ScopedObject obj(scope, d_ptr->object.asManaged());
+ QV4::ScopedValue val(scope, obj->get(key));
- QV4::ScopedValue v(scope, d_ptr->currentIndex == UINT_MAX ? obj->get(d_ptr->currentName.as<QV4::String>()) : obj->getIndexed(d_ptr->currentIndex));
if (scope.hasException()) {
- engine->catchException();
+ scope.engine->catchException();
return QJSValue();
}
- return QJSValue(engine, v->asReturnedValue());
+ return QJSValue(scope.engine, val->asReturnedValue());
}
@@ -216,27 +220,7 @@ QJSValue QJSValueIterator::value() const
*/
QJSValueIterator& QJSValueIterator::operator=(QJSValue& object)
{
- d_ptr->value = object;
- d_ptr->currentIndex = UINT_MAX;
- d_ptr->nextIndex = UINT_MAX;
- d_ptr->currentName.clear();
- d_ptr->nextName.clear();
- QV4::ExecutionEngine *v4 = d_ptr->iterator.engine();
- if (!v4) {
- d_ptr->iterator.clear();
- return *this;
- }
-
- QV4::Scope scope(v4);
- QV4::ScopedObject o(scope, QJSValuePrivate::getValue(&object));
- d_ptr->iterator.set(v4, v4->newForEachIteratorObject(o));
- QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value());
- it->d()->it().flags = QV4::ObjectIterator::NoFlags;
- QV4::ScopedString nm(scope);
- QV4::Property nextProperty;
- QV4::PropertyAttributes nextAttributes;
- it->d()->it().next(nm.getRef(), &d_ptr->nextIndex, &nextProperty, &nextAttributes);
- d_ptr->nextName.set(v4, nm.asReturnedValue());
+ d_ptr->init(object);
return *this;
}
diff --git a/src/qml/jsapi/qjsvalueiterator_p.h b/src/qml/jsapi/qjsvalueiterator_p.h
index 474a98b9fa..a870850c11 100644
--- a/src/qml/jsapi/qjsvalueiterator_p.h
+++ b/src/qml/jsapi/qjsvalueiterator_p.h
@@ -61,12 +61,16 @@ class QJSValueIteratorPrivate
public:
QJSValueIteratorPrivate(const QJSValue &v);
- QJSValue value;
- QV4::PersistentValue iterator;
- QV4::PersistentValue currentName;
- uint currentIndex;
- QV4::PersistentValue nextName;
- uint nextIndex;
+ void init(const QJSValue &v);
+ bool isValid() const;
+
+ void next();
+
+ QV4::ExecutionEngine *engine = nullptr;
+ QV4::PersistentValue object;
+ QScopedPointer<QV4::OwnPropertyKeyIterator> iterator;
+ QV4::PersistentValue currentKey;
+ QV4::PersistentValue nextKey;
};
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri
index 4bc877bd9d..2a338c6792 100644
--- a/src/qml/jsruntime/jsruntime.pri
+++ b/src/qml/jsruntime/jsruntime.pri
@@ -3,7 +3,6 @@ INCLUDEPATH += $$OUT_PWD
!qmldevtools_build {
SOURCES += \
- $$PWD/qv4engine.cpp \
$$PWD/qv4context.cpp \
$$PWD/qv4persistent.cpp \
$$PWD/qv4lookup.cpp \
@@ -12,23 +11,32 @@ SOURCES += \
$$PWD/qv4managed.cpp \
$$PWD/qv4internalclass.cpp \
$$PWD/qv4sparsearray.cpp \
+ $$PWD/qv4atomics.cpp \
$$PWD/qv4arraydata.cpp \
$$PWD/qv4arrayobject.cpp \
+ $$PWD/qv4arrayiterator.cpp \
$$PWD/qv4argumentsobject.cpp \
$$PWD/qv4booleanobject.cpp \
$$PWD/qv4dateobject.cpp \
$$PWD/qv4errorobject.cpp \
$$PWD/qv4function.cpp \
$$PWD/qv4functionobject.cpp \
+ $$PWD/qv4generatorobject.cpp \
$$PWD/qv4globalobject.cpp \
+ $$PWD/qv4iterator.cpp \
$$PWD/qv4jsonobject.cpp \
$$PWD/qv4mathobject.cpp \
$$PWD/qv4memberdata.cpp \
$$PWD/qv4numberobject.cpp \
$$PWD/qv4object.cpp \
$$PWD/qv4objectproto.cpp \
+ $$PWD/qv4propertykey.cpp \
+ $$PWD/qv4proxy.cpp \
$$PWD/qv4qmlcontext.cpp \
+ $$PWD/qv4reflect.cpp \
$$PWD/qv4regexpobject.cpp \
+ $$PWD/qv4stackframe.cpp \
+ $$PWD/qv4stringiterator.cpp \
$$PWD/qv4stringobject.cpp \
$$PWD/qv4variantobject.cpp \
$$PWD/qv4objectiterator.cpp \
@@ -36,13 +44,19 @@ SOURCES += \
$$PWD/qv4runtimecodegen.cpp \
$$PWD/qv4serialize.cpp \
$$PWD/qv4script.cpp \
- $$PWD/qv4sequenceobject.cpp \
+ $$PWD/qv4symbol.cpp \
+ $$PWD/qv4setobject.cpp \
+ $$PWD/qv4setiterator.cpp \
$$PWD/qv4include.cpp \
$$PWD/qv4qobjectwrapper.cpp \
$$PWD/qv4arraybuffer.cpp \
$$PWD/qv4typedarray.cpp \
$$PWD/qv4dataview.cpp \
- $$PWD/qv4vme_moth.cpp
+ $$PWD/qv4vme_moth.cpp \
+ $$PWD/qv4mapobject.cpp \
+ $$PWD/qv4mapiterator.cpp \
+ $$PWD/qv4estable.cpp \
+ $$PWD/qv4module.cpp
qtConfig(qml-debug): SOURCES += $$PWD/qv4profiling.cpp
@@ -62,24 +76,33 @@ HEADERS += \
$$PWD/qv4internalclass_p.h \
$$PWD/qv4jscall_p.h \
$$PWD/qv4sparsearray_p.h \
+ $$PWD/qv4atomics_p.h \
$$PWD/qv4arraydata_p.h \
$$PWD/qv4arrayobject_p.h \
+ $$PWD/qv4arrayiterator_p.h \
$$PWD/qv4argumentsobject_p.h \
$$PWD/qv4booleanobject_p.h \
$$PWD/qv4dateobject_p.h \
$$PWD/qv4errorobject_p.h \
$$PWD/qv4function_p.h \
$$PWD/qv4functionobject_p.h \
+ $$PWD/qv4generatorobject_p.h \
$$PWD/qv4globalobject_p.h \
+ $$PWD/qv4iterator_p.h \
$$PWD/qv4jsonobject_p.h \
$$PWD/qv4mathobject_p.h \
$$PWD/qv4memberdata_p.h \
$$PWD/qv4numberobject_p.h \
$$PWD/qv4object_p.h \
$$PWD/qv4objectproto_p.h \
+ $$PWD/qv4propertykey_p.h \
+ $$PWD/qv4proxy_p.h \
$$PWD/qv4qmlcontext_p.h \
+ $$PWD/qv4reflect_p.h \
$$PWD/qv4regexpobject_p.h \
$$PWD/qv4runtimecodegen_p.h \
+ $$PWD/qv4stackframe_p.h \
+ $$PWD/qv4stringiterator_p.h \
$$PWD/qv4stringobject_p.h \
$$PWD/qv4variantobject_p.h \
$$PWD/qv4property_p.h \
@@ -87,16 +110,31 @@ HEADERS += \
$$PWD/qv4regexp_p.h \
$$PWD/qv4serialize_p.h \
$$PWD/qv4script_p.h \
+ $$PWD/qv4symbol_p.h \
+ $$PWD/qv4setobject_p.h \
+ $$PWD/qv4setiterator_p.h \
$$PWD/qv4scopedvalue_p.h \
$$PWD/qv4executableallocator_p.h \
- $$PWD/qv4sequenceobject_p.h \
$$PWD/qv4include_p.h \
$$PWD/qv4qobjectwrapper_p.h \
$$PWD/qv4profiling_p.h \
$$PWD/qv4arraybuffer_p.h \
$$PWD/qv4typedarray_p.h \
$$PWD/qv4dataview_p.h \
- $$PWD/qv4vme_moth_p.h
+ $$PWD/qv4vme_moth_p.h \
+ $$PWD/qv4mapobject_p.h \
+ $$PWD/qv4mapiterator_p.h \
+ $$PWD/qv4estable_p.h \
+ $$PWD/qv4vtable_p.h \
+ $$PWD/qv4module_p.h
+
+qtConfig(qml-sequence-object) {
+ HEADERS += \
+ $$PWD/qv4sequenceobject_p.h
+
+ SOURCES += \
+ $$PWD/qv4sequenceobject.cpp
+}
}
@@ -110,6 +148,7 @@ HEADERS += \
$$PWD/qv4value_p.h
SOURCES += \
+ $$PWD/qv4engine.cpp \
$$PWD/qv4runtime.cpp \
$$PWD/qv4string.cpp \
$$PWD/qv4value.cpp \
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 075e7afd8a..4a21f62cf2 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -37,218 +37,187 @@
**
****************************************************************************/
#include <qv4argumentsobject_p.h>
+#include <qv4arrayobject_p.h>
#include <qv4alloca_p.h>
#include <qv4scopedvalue_p.h>
#include <qv4string_p.h>
#include <qv4function_p.h>
#include <qv4jscall_p.h>
+#include <qv4symbol_p.h>
using namespace QV4;
DEFINE_OBJECT_VTABLE(ArgumentsObject);
DEFINE_OBJECT_VTABLE(StrictArgumentsObject);
-void Heap::ArgumentsObject::init(QV4::CppStackFrame *frame)
-{
- ExecutionEngine *v4 = internalClass->engine;
-
- int nFormals = frame->v4Function->nFormals;
- QV4::CallContext *context = static_cast<QV4::CallContext *>(frame->context());
-
- Object::init();
- fullyCreated = false;
- this->nFormals = nFormals;
- this->context.set(v4, context->d());
- Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable());
-
- Q_ASSERT(CalleePropertyIndex == internalClass->find(v4->id_callee()));
- setProperty(v4, CalleePropertyIndex, context->d()->function);
- Q_ASSERT(LengthPropertyIndex == internalClass->find(v4->id_length()));
- setProperty(v4, LengthPropertyIndex, Primitive::fromInt32(context->argc()));
-}
-
void Heap::StrictArgumentsObject::init(QV4::CppStackFrame *frame)
+
{
Q_ASSERT(vtable() == QV4::StrictArgumentsObject::staticVTable());
ExecutionEngine *v4 = internalClass->engine;
Object::init();
- Q_ASSERT(CalleePropertyIndex == internalClass->find(v4->id_callee()));
- Q_ASSERT(CallerPropertyIndex == internalClass->find(v4->id_caller()));
- setProperty(v4, CalleePropertyIndex + QV4::Object::GetterOffset, *v4->thrower());
- setProperty(v4, CalleePropertyIndex + QV4::Object::SetterOffset, *v4->thrower());
- setProperty(v4, CallerPropertyIndex + QV4::Object::GetterOffset, *v4->thrower());
- setProperty(v4, CallerPropertyIndex + QV4::Object::SetterOffset, *v4->thrower());
+ Q_ASSERT(internalClass->verifyIndex(v4->id_callee()->propertyKey(), CalleePropertyIndex));
+ Q_ASSERT(internalClass->findValueOrSetter(v4->id_callee()->propertyKey()).index == CalleeSetterPropertyIndex);
+ Q_ASSERT(internalClass->verifyIndex(v4->symbol_iterator()->propertyKey(), SymbolIteratorPropertyIndex));
+ setProperty(v4, SymbolIteratorPropertyIndex, *v4->arrayProtoValues());
+ setProperty(v4, CalleePropertyIndex, *v4->thrower());
+ setProperty(v4, CalleeSetterPropertyIndex, *v4->thrower());
Scope scope(v4);
Scoped<QV4::StrictArgumentsObject> args(scope, this);
args->arrayReserve(frame->originalArgumentsCount);
args->arrayPut(0, frame->originalArguments, frame->originalArgumentsCount);
- Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(v4->id_length()));
- setProperty(v4, LengthPropertyIndex, Primitive::fromInt32(frame->originalArgumentsCount));
+ Q_ASSERT(args->internalClass()->verifyIndex(v4->id_length()->propertyKey(), LengthPropertyIndex));
+ setProperty(v4, LengthPropertyIndex, Value::fromInt32(frame->originalArgumentsCount));
+}
+
+void Heap::ArgumentsObject::init(QV4::CppStackFrame *frame)
+{
+ ExecutionEngine *v4 = internalClass->engine;
+
+ QV4::CallContext *context = static_cast<QV4::CallContext *>(frame->context());
+
+ Object::init();
+ this->context.set(v4, context->d());
+ Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable());
+
+ Q_ASSERT(internalClass->verifyIndex(v4->id_callee()->propertyKey(), CalleePropertyIndex));
+ setProperty(v4, CalleePropertyIndex, context->d()->function);
+ Q_ASSERT(internalClass->verifyIndex(v4->id_length()->propertyKey(), LengthPropertyIndex));
+ setProperty(v4, LengthPropertyIndex, Value::fromInt32(context->argc()));
+ Q_ASSERT(internalClass->verifyIndex(v4->symbol_iterator()->propertyKey(), SymbolIteratorPropertyIndex));
+ setProperty(v4, SymbolIteratorPropertyIndex, *v4->arrayProtoValues());
+
+ fullyCreated = false;
+ argCount = frame->originalArgumentsCount;
+ uint nFormals = frame->v4Function->nFormals;
+ mapped = nFormals > 63 ? std::numeric_limits<quint64>::max() : (1ull << nFormals) - 1;
}
void ArgumentsObject::fullyCreate()
{
- if (fullyCreated())
+ if (d()->fullyCreated)
return;
Scope scope(engine());
- int argCount = context()->argc();
- uint numAccessors = qMin(d()->nFormals, argCount);
- ArrayData::realloc(this, Heap::ArrayData::Sparse, argCount, true);
- scope.engine->requireArgumentsAccessors(numAccessors);
-
- Scoped<MemberData> md(scope, d()->mappedArguments);
- if (numAccessors) {
- d()->mappedArguments.set(scope.engine, md->allocate(scope.engine, numAccessors));
- for (uint i = 0; i < numAccessors; ++i) {
- d()->mappedArguments->values.set(scope.engine, i, context()->args()[i]);
- arraySet(i, scope.engine->argumentsAccessors + i, Attr_Accessor);
- }
- }
- arrayPut(numAccessors, context()->args() + numAccessors, argCount - numAccessors);
- for (int i = int(numAccessors); i < argCount; ++i)
- setArrayAttributes(i, Attr_Data);
+ arrayReserve(d()->argCount);
+ arrayPut(0, context()->args(), d()->argCount);
+ // Use a sparse array, so that method_getElement() doesn't shortcut
+ initSparseArray();
d()->fullyCreated = true;
}
-bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, const Property *desc, PropertyAttributes attrs)
+bool ArgumentsObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs)
{
- fullyCreate();
-
- Scope scope(engine);
- ScopedProperty map(scope);
- PropertyAttributes mapAttrs;
- uint numAccessors = qMin(d()->nFormals, context()->argc());
- bool isMapped = false;
- if (arrayData() && index < numAccessors &&
- arrayData()->attributes(index).isAccessor() &&
- arrayData()->get(index) == scope.engine->argumentsAccessors[index].getter()->asReturnedValue())
- isMapped = true;
-
- if (isMapped) {
- Q_ASSERT(arrayData());
- mapAttrs = arrayData()->attributes(index);
- arrayData()->getProperty(index, map, &mapAttrs);
- setArrayAttributes(index, Attr_Data);
- ArrayData::Index arrayIndex{ arrayData(), arrayData()->mappedIndex(index) };
- arrayIndex.set(scope.engine, d()->mappedArguments->values[index]);
+ ArgumentsObject *args = static_cast<ArgumentsObject *>(m);
+ args->fullyCreate();
+ uint index = id.asArrayIndex();
+
+ if (!args->isMapped(index))
+ return Object::virtualDefineOwnProperty(m, id, desc, attrs);
+
+ Scope scope(args);
+ PropertyAttributes cAttrs = attrs;
+ ScopedProperty cDesc(scope);
+ cDesc->copy(desc, attrs);
+
+ if (attrs.isData() && desc->value.isEmpty() && attrs.hasWritable() && !attrs.isWritable()) {
+ cDesc->value = args->context()->args()[index];
+ cAttrs.setType(PropertyAttributes::Data);
}
- bool result = Object::defineOwnProperty2(scope.engine, index, desc, attrs);
- if (!result) {
+ bool allowed = Object::virtualDefineOwnProperty(m, id, cDesc, cAttrs);
+ if (!allowed)
return false;
- }
- if (isMapped && attrs.isData()) {
- Q_ASSERT(arrayData());
- ScopedFunctionObject setter(scope, map->setter());
- JSCallData jsCallData(scope, 1);
- *jsCallData->thisObject = this->asReturnedValue();
- jsCallData->args[0] = desc->value;
- setter->call(jsCallData);
-
- if (attrs.isWritable()) {
- setArrayAttributes(index, mapAttrs);
- arrayData()->setProperty(engine, index, map);
- }
+ if (attrs.isAccessor()) {
+ args->removeMapping(index);
+ } else {
+ if (!desc->value.isEmpty())
+ args->context()->setArg(index, desc->value);
+ if (attrs.hasWritable() && !attrs.isWritable())
+ args->removeMapping(index);
}
-
- return result;
+ return true;
}
-ReturnedValue ArgumentsObject::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue ArgumentsObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
const ArgumentsObject *args = static_cast<const ArgumentsObject *>(m);
- if (args->fullyCreated())
- return Object::getIndexed(m, index, hasProperty);
-
- if (index < static_cast<uint>(args->context()->argc())) {
+ uint index = id.asArrayIndex();
+ if (index < args->d()->argCount && !args->d()->fullyCreated) {
if (hasProperty)
*hasProperty = true;
return args->context()->args()[index].asReturnedValue();
}
+
+ if (!args->isMapped(index))
+ return Object::virtualGet(m, id, receiver, hasProperty);
+ Q_ASSERT(index < static_cast<uint>(args->context()->function->formalParameterCount()));
if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
+ *hasProperty = true;
+ return args->context()->args()[index].asReturnedValue();
}
-bool ArgumentsObject::putIndexed(Managed *m, uint index, const Value &value)
+bool ArgumentsObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
ArgumentsObject *args = static_cast<ArgumentsObject *>(m);
- if (!args->fullyCreated() && index >= static_cast<uint>(args->context()->argc()))
- args->fullyCreate();
+ uint index = id.asArrayIndex();
- if (args->fullyCreated())
- return Object::putIndexed(m, index, value);
+ if (args == receiver && index < args->d()->argCount && !args->d()->fullyCreated) {
+ args->context()->setArg(index, value);
+ return true;
+ }
- args->context()->setArg(index, value);
- return true;
+ bool isMapped = (args == receiver && args->isMapped(index));
+ if (isMapped)
+ args->context()->setArg(index, value);
+
+ return Object::virtualPut(m, id, value, receiver);
}
-bool ArgumentsObject::deleteIndexedProperty(Managed *m, uint index)
+bool ArgumentsObject::virtualDeleteProperty(Managed *m, PropertyKey id)
{
ArgumentsObject *args = static_cast<ArgumentsObject *>(m);
- if (!args->fullyCreated())
- args->fullyCreate();
- return Object::deleteIndexedProperty(m, index);
+ args->fullyCreate();
+ bool result = Object::virtualDeleteProperty(m, id);
+ if (result)
+ args->removeMapping(id.asArrayIndex());
+ return result;
}
-PropertyAttributes ArgumentsObject::queryIndexed(const Managed *m, uint index)
+PropertyAttributes ArgumentsObject::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
{
const ArgumentsObject *args = static_cast<const ArgumentsObject *>(m);
- if (args->fullyCreated())
- return Object::queryIndexed(m, index);
-
- uint numAccessors = qMin(args->d()->nFormals, args->context()->argc());
- uint argCount = args->context()->argc();
- if (index >= argCount)
- return PropertyAttributes();
- if (index >= numAccessors)
+ uint index = id.asArrayIndex();
+ if (index < args->d()->argCount && !args->d()->fullyCreated) {
+ p->value = args->context()->args()[index];
return Attr_Data;
- return Attr_Accessor;
-}
+ }
-DEFINE_OBJECT_VTABLE(ArgumentsGetterFunction);
+ PropertyAttributes attrs = Object::virtualGetOwnProperty(m, id, p);
+ if (attrs.isEmpty() || !args->isMapped(index))
+ return attrs;
-ReturnedValue ArgumentsGetterFunction::call(const FunctionObject *getter, const Value *thisObject, const Value *, int)
-{
- ExecutionEngine *v4 = getter->engine();
- Scope scope(v4);
- const ArgumentsGetterFunction *g = static_cast<const ArgumentsGetterFunction *>(getter);
- Scoped<ArgumentsObject> o(scope, thisObject->as<ArgumentsObject>());
- if (!o)
- return v4->throwTypeError();
-
- Q_ASSERT(g->index() < static_cast<unsigned>(o->context()->argc()));
- return o->context()->args()[g->index()].asReturnedValue();
+ Q_ASSERT(index < static_cast<uint>(args->context()->function->formalParameterCount()));
+ if (p)
+ p->value = args->context()->args()[index];
+ return attrs;
}
-DEFINE_OBJECT_VTABLE(ArgumentsSetterFunction);
-
-ReturnedValue ArgumentsSetterFunction::call(const FunctionObject *setter, const Value *thisObject, const Value *argv, int argc)
+qint64 ArgumentsObject::virtualGetLength(const Managed *m)
{
- ExecutionEngine *v4 = setter->engine();
- Scope scope(v4);
- const ArgumentsSetterFunction *s = static_cast<const ArgumentsSetterFunction *>(setter);
- Scoped<ArgumentsObject> o(scope, thisObject->as<ArgumentsObject>());
- if (!o)
- return v4->throwTypeError();
-
- Q_ASSERT(s->index() < static_cast<unsigned>(o->context()->argc()));
- o->context()->setArg(s->index(), argc ? argv[0] : Primitive::undefinedValue());
- return Encode::undefined();
+ const ArgumentsObject *a = static_cast<const ArgumentsObject *>(m);
+ return a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->toLength();
}
-uint ArgumentsObject::getLength(const Managed *m)
+OwnPropertyKeyIterator *ArgumentsObject::virtualOwnPropertyKeys(const Object *m, Value *target)
{
- const ArgumentsObject *a = static_cast<const ArgumentsObject *>(m);
- if (a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->isInteger())
- return a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->integerValue();
- return Primitive::toUInt32(a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->doubleValue());
+ static_cast<ArgumentsObject *>(const_cast<Object *>(m))->fullyCreate();
+ return Object::virtualOwnPropertyKeys(m, target);
}
diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h
index ac281f555a..f0e2192c7e 100644
--- a/src/qml/jsruntime/qv4argumentsobject_p.h
+++ b/src/qml/jsruntime/qv4argumentsobject_p.h
@@ -59,33 +59,18 @@ namespace QV4 {
namespace Heap {
-#define ArgumentsGetterFunctionMembers(class, Member) \
- Member(class, NoMark, uint, index)
-
-DECLARE_HEAP_OBJECT(ArgumentsGetterFunction, FunctionObject) {
- DECLARE_MARKOBJECTS(ArgumentsGetterFunction);
- inline void init(QV4::ExecutionContext *scope, uint index);
-};
-
-#define ArgumentsSetterFunctionMembers(class, Member) \
- Member(class, NoMark, uint, index)
-
-DECLARE_HEAP_OBJECT(ArgumentsSetterFunction, FunctionObject) {
- DECLARE_MARKOBJECTS(ArgumentsSetterFunction);
- inline void init(QV4::ExecutionContext *scope, uint index);
-};
-
#define ArgumentsObjectMembers(class, Member) \
Member(class, Pointer, CallContext *, context) \
- Member(class, Pointer, MemberData *, mappedArguments) \
Member(class, NoMark, bool, fullyCreated) \
- Member(class, NoMark, int, nFormals)
+ Member(class, NoMark, uint, argCount) \
+ Member(class, NoMark, quint64, mapped)
DECLARE_HEAP_OBJECT(ArgumentsObject, Object) {
DECLARE_MARKOBJECTS(ArgumentsObject);
enum {
LengthPropertyIndex = 0,
- CalleePropertyIndex = 1
+ SymbolIteratorPropertyIndex = 1,
+ CalleePropertyIndex = 2
};
void init(CppStackFrame *frame);
};
@@ -95,45 +80,15 @@ DECLARE_HEAP_OBJECT(ArgumentsObject, Object) {
DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object) {
enum {
LengthPropertyIndex = 0,
- CalleePropertyIndex = 1,
- CallerPropertyIndex = 3
+ SymbolIteratorPropertyIndex = 1,
+ CalleePropertyIndex = 2,
+ CalleeSetterPropertyIndex = 3
};
void init(CppStackFrame *frame);
};
}
-struct ArgumentsGetterFunction: FunctionObject
-{
- V4_OBJECT2(ArgumentsGetterFunction, FunctionObject)
-
- uint index() const { return d()->index; }
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
-};
-
-inline void
-Heap::ArgumentsGetterFunction::init(QV4::ExecutionContext *scope, uint index)
-{
- Heap::FunctionObject::init(scope);
- this->index = index;
-}
-
-struct ArgumentsSetterFunction: FunctionObject
-{
- V4_OBJECT2(ArgumentsSetterFunction, FunctionObject)
-
- uint index() const { return d()->index; }
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
-};
-
-inline void
-Heap::ArgumentsSetterFunction::init(QV4::ExecutionContext *scope, uint index)
-{
- Heap::FunctionObject::init(scope);
- this->index = index;
-}
-
-
struct ArgumentsObject: Object {
V4_OBJECT2(ArgumentsObject, Object)
Q_MANAGED_TYPE(ArgumentsObject)
@@ -142,18 +97,30 @@ struct ArgumentsObject: Object {
bool fullyCreated() const { return d()->fullyCreated; }
static bool isNonStrictArgumentsObject(Managed *m) {
- return m->d()->vtable() == staticVTable();
+ return m->vtable() == staticVTable();
}
- bool defineOwnProperty(ExecutionEngine *engine, uint index, const Property *desc, PropertyAttributes attrs);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
- static bool putIndexed(Managed *m, uint index, const Value &value);
- static bool deleteIndexedProperty(Managed *m, uint index);
- static PropertyAttributes queryIndexed(const Managed *m, uint index);
- static uint getLength(const Managed *m);
+ static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static bool virtualDeleteProperty(Managed *m, PropertyKey id);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static qint64 virtualGetLength(const Managed *m);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
void fullyCreate();
+ // There's a slight hack here, as this limits the amount of mapped arguments to 64, but that should be
+ // more than enough for all practical uses of arguments
+ bool isMapped(uint arg) const {
+ return arg < 64 && (d()->mapped & (1ull << arg));
+ }
+
+ void removeMapping(uint arg) {
+ if (arg < 64)
+ (d()->mapped &= ~(1ull << arg));
+ }
+
};
struct StrictArgumentsObject : Object {
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp
index 59a2b9d913..a99ec16943 100644
--- a/src/qml/jsruntime/qv4arraybuffer.cpp
+++ b/src/qml/jsruntime/qv4arraybuffer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -41,23 +41,56 @@
#include "qv4dataview_p.h"
#include "qv4string_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
using namespace QV4;
+DEFINE_OBJECT_VTABLE(SharedArrayBufferCtor);
DEFINE_OBJECT_VTABLE(ArrayBufferCtor);
+DEFINE_OBJECT_VTABLE(SharedArrayBuffer);
DEFINE_OBJECT_VTABLE(ArrayBuffer);
+void Heap::SharedArrayBufferCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("SharedArrayBuffer"));
+}
+
void Heap::ArrayBufferCtor::init(QV4::ExecutionContext *scope)
{
Heap::FunctionObject::init(scope, QStringLiteral("ArrayBuffer"));
}
-ReturnedValue ArrayBufferCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue SharedArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ Scope scope(f);
+ if (newTarget->isUndefined())
+ return scope.engine->throwTypeError();
+
+ qint64 len = argc ? argv[0].toIndex() : 0;
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ if (len < 0 || len >= INT_MAX)
+ return scope.engine->throwRangeError(QStringLiteral("SharedArrayBuffer: Invalid length."));
+
+ Scoped<SharedArrayBuffer> a(scope, scope.engine->memoryManager->allocate<SharedArrayBuffer>(len));
+ if (scope.engine->hasException)
+ return Encode::undefined();
+
+ return a->asReturnedValue();
+}
+
+ReturnedValue SharedArrayBufferCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError();
+}
+
+
+ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
ExecutionEngine *v4 = f->engine();
Scope scope(v4);
- ScopedValue l(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue l(scope, argc ? argv[0] : Value::undefinedValue());
double dl = l->toInteger();
if (v4->hasException)
return Encode::undefined();
@@ -66,18 +99,18 @@ ReturnedValue ArrayBufferCtor::callAsConstructor(const FunctionObject *f, const
return v4->throwRangeError(QLatin1String("ArrayBuffer constructor: invalid length"));
Scoped<ArrayBuffer> a(scope, v4->newArrayBuffer(len));
+ if (newTarget->heapObject() != f->heapObject() && newTarget->isFunctionObject()) {
+ const FunctionObject *nt = static_cast<const FunctionObject *>(newTarget);
+ ScopedObject o(scope, nt->protoProperty());
+ if (o)
+ a->setPrototypeOf(o);
+ }
if (scope.engine->hasException)
return Encode::undefined();
return a->asReturnedValue();
}
-
-ReturnedValue ArrayBufferCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
-{
- return callAsConstructor(f, argv, argc);
-}
-
ReturnedValue ArrayBufferCtor::method_isView(const FunctionObject *, const Value *, const Value *argv, int argc)
{
if (argc < 1)
@@ -91,26 +124,29 @@ ReturnedValue ArrayBufferCtor::method_isView(const FunctionObject *, const Value
}
-void Heap::ArrayBuffer::init(size_t length)
+void Heap::SharedArrayBuffer::init(size_t length)
{
Object::init();
- data = QTypedArrayData<char>::allocate(length + 1);
+ if (length < UINT_MAX)
+ data = QTypedArrayData<char>::allocate(length + 1);
if (!data) {
internalClass->engine->throwRangeError(QStringLiteral("ArrayBuffer: out of memory"));
return;
}
data->size = int(length);
memset(data->data(), 0, length + 1);
+ isShared = true;
}
-void Heap::ArrayBuffer::init(const QByteArray& array)
+void Heap::SharedArrayBuffer::init(const QByteArray& array)
{
Object::init();
data = const_cast<QByteArray&>(array).data_ptr();
data->ref.ref();
+ isShared = true;
}
-void Heap::ArrayBuffer::destroy()
+void Heap::SharedArrayBuffer::destroy()
{
if (data && !data->ref.deref())
QTypedArrayData<char>::deallocate(data);
@@ -143,57 +179,98 @@ void ArrayBuffer::detach() {
}
-void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
+void SharedArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineDefaultProperty(QStringLiteral("isView"), ArrayBufferCtor::method_isView, 1);
+ ctor->addSymbolSpecies();
+
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, nullptr);
defineDefaultProperty(QStringLiteral("slice"), method_slice, 2);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ ScopedString name(scope, engine->newString(QStringLiteral("SharedArrayBuffer")));
+ defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);
}
-ReturnedValue ArrayBufferPrototype::method_get_byteLength(const FunctionObject *b, const Value *thisObject, const Value *, int)
+ReturnedValue SharedArrayBufferPrototype::method_get_byteLength(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
- const ArrayBuffer *a = thisObject->as<ArrayBuffer>();
- if (!a)
+ const SharedArrayBuffer *a = thisObject->as<SharedArrayBuffer>();
+ if (!a || a->isDetachedBuffer() || !a->isSharedArrayBuffer())
return b->engine()->throwTypeError();
return Encode(a->d()->data->size);
}
-ReturnedValue ArrayBufferPrototype::method_slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue SharedArrayBufferPrototype::method_slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
- ExecutionEngine *v4 = b->engine();
- const ArrayBuffer *a = thisObject->as<ArrayBuffer>();
- if (!a)
- return v4->throwTypeError();
+ return slice(b, thisObject, argv, argc, true);
+}
+
+ReturnedValue SharedArrayBufferPrototype::slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared)
+{
+ Scope scope(b);
+ const SharedArrayBuffer *a = thisObject->as<SharedArrayBuffer>();
+ if (!a || a->isDetachedBuffer() || (a->isSharedArrayBuffer() != shared))
+ return scope.engine->throwTypeError();
double start = argc > 0 ? argv[0].toInteger() : 0;
double end = (argc < 2 || argv[1].isUndefined()) ?
a->d()->data->size : argv[1].toInteger();
- if (v4->hasException)
+ if (scope.hasException())
return QV4::Encode::undefined();
double first = (start < 0) ? qMax(a->d()->data->size + start, 0.) : qMin(start, (double)a->d()->data->size);
double final = (end < 0) ? qMax(a->d()->data->size + end, 0.) : qMin(end, (double)a->d()->data->size);
- Scope scope(v4);
- ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor()));
+ const FunctionObject *constructor = a->speciesConstructor(scope, shared ? scope.engine->sharedArrayBufferCtor() : scope.engine->arrayBufferCtor());
if (!constructor)
- return v4->throwTypeError();
+ return scope.engine->throwTypeError();
double newLen = qMax(final - first, 0.);
ScopedValue argument(scope, QV4::Encode(newLen));
- QV4::Scoped<ArrayBuffer> newBuffer(scope, constructor->callAsConstructor(argument, 1));
- if (!newBuffer || newBuffer->d()->data->size < (int)newLen)
- return v4->throwTypeError();
+ QV4::Scoped<SharedArrayBuffer> newBuffer(scope, constructor->callAsConstructor(argument, 1));
+ if (!newBuffer || newBuffer->d()->data->size < (int)newLen ||
+ newBuffer->isDetachedBuffer() || (newBuffer->isSharedArrayBuffer() != shared) ||
+ newBuffer->sameValue(*a) ||
+ a->isDetachedBuffer())
+ return scope.engine->throwTypeError();
memcpy(newBuffer->d()->data->data(), a->d()->data->data() + (uint)first, newLen);
- return Encode::undefined();
+ return newBuffer->asReturnedValue();
+}
+
+
+void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedObject o(scope);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
+ ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
+ ctor->defineDefaultProperty(QStringLiteral("isView"), ArrayBufferCtor::method_isView, 1);
+ ctor->addSymbolSpecies();
+
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+ defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, nullptr);
+ defineDefaultProperty(QStringLiteral("slice"), method_slice, 2);
+ defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ ScopedString name(scope, engine->newString(QStringLiteral("ArrayBuffer")));
+ defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);
+}
+
+ReturnedValue ArrayBufferPrototype::method_get_byteLength(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ const ArrayBuffer *a = thisObject->as<ArrayBuffer>();
+ if (!a || a->isDetachedBuffer() || a->isSharedArrayBuffer())
+ return f->engine()->throwTypeError();
+
+ return Encode(a->d()->data->size);
+}
+
+ReturnedValue ArrayBufferPrototype::method_slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ return slice(b, thisObject, argv, argc, false);
}
ReturnedValue ArrayBufferPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)
diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h
index 59e78ee85f..8344fa2554 100644
--- a/src/qml/jsruntime/qv4arraybuffer_p.h
+++ b/src/qml/jsruntime/qv4arraybuffer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -59,48 +59,107 @@ namespace QV4 {
namespace Heap {
-struct ArrayBufferCtor : FunctionObject {
+struct SharedArrayBufferCtor : FunctionObject {
void init(QV4::ExecutionContext *scope);
};
-struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object {
+struct ArrayBufferCtor : SharedArrayBufferCtor {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct Q_QML_PRIVATE_EXPORT SharedArrayBuffer : Object {
void init(size_t length);
void init(const QByteArray& array);
void destroy();
QTypedArrayData<char> *data;
+ bool isShared;
+
+ uint byteLength() const { return data ? data->size : 0; }
- uint byteLength() const { return data->size; }
+ bool isDetachedBuffer() const { return !data; }
+ bool isSharedArrayBuffer() const { return isShared; }
};
+struct Q_QML_PRIVATE_EXPORT ArrayBuffer : SharedArrayBuffer {
+ void init(size_t length) {
+ SharedArrayBuffer::init(length);
+ isShared = false;
+ }
+ void init(const QByteArray& array) {
+ SharedArrayBuffer::init(array);
+ isShared = false;
+ }
+ void detachArrayBuffer() {
+ if (data && !data->ref.deref())
+ QTypedArrayData<char>::deallocate(data);
+ data = nullptr;
+ }
+};
+
+
}
-struct ArrayBufferCtor: FunctionObject
+struct SharedArrayBufferCtor : FunctionObject
{
- V4_OBJECT2(ArrayBufferCtor, FunctionObject)
+ V4_OBJECT2(SharedArrayBufferCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct ArrayBufferCtor : SharedArrayBufferCtor
+{
+ V4_OBJECT2(ArrayBufferCtor, SharedArrayBufferCtor)
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
static ReturnedValue method_isView(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct Q_QML_PRIVATE_EXPORT SharedArrayBuffer : Object
+{
+ V4_OBJECT2(SharedArrayBuffer, Object)
+ V4_NEEDS_DESTROY
+ V4_PROTOTYPE(sharedArrayBufferPrototype)
+ QByteArray asByteArray() const;
+ uint byteLength() const { return d()->byteLength(); }
+ char *data() { Q_ASSERT(d()->data); return d()->data->data(); }
+ const char *constData() { Q_ASSERT(d()->data); return d()->data->data(); }
+
+ bool isShared() { return d()->data->ref.isShared(); }
+ bool isDetachedBuffer() const { return !d()->data; }
+ bool isSharedArrayBuffer() const { return d()->isShared; }
};
-struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object
+struct Q_QML_PRIVATE_EXPORT ArrayBuffer : SharedArrayBuffer
{
- V4_OBJECT2(ArrayBuffer, Object)
+ V4_OBJECT2(ArrayBuffer, SharedArrayBuffer)
V4_NEEDS_DESTROY
V4_PROTOTYPE(arrayBufferPrototype)
QByteArray asByteArray() const;
uint byteLength() const { return d()->byteLength(); }
char *data() { detach(); return d()->data ? d()->data->data() : nullptr; }
+ // ### is that detach needed?
const char *constData() { detach(); return d()->data ? d()->data->data() : nullptr; }
-private:
+ bool isShared() { return d()->data && d()->data->ref.isShared(); }
void detach();
+ void detachArrayBuffer() { d()->detachArrayBuffer(); }
+};
+
+struct SharedArrayBufferPrototype : Object
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared);
};
-struct ArrayBufferPrototype: Object
+struct ArrayBufferPrototype : SharedArrayBufferPrototype
{
void init(ExecutionEngine *engine, Object *ctor);
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 855407e6f7..654d33b8d1 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -47,25 +47,7 @@
using namespace QV4;
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON
-
-const QV4::VTable QV4::ArrayData::static_vtbl = {
- nullptr,
- 0,
- 0,
- QV4::ArrayData::IsExecutionContext,
- QV4::ArrayData::IsString,
- QV4::ArrayData::IsObject,
- QV4::ArrayData::IsFunctionObject,
- QV4::ArrayData::IsErrorObject,
- QV4::ArrayData::IsArrayData,
- 0,
- QV4::ArrayData::MyType,
- "ArrayData",
- Q_VTABLE_FUNCTION(QV4::ArrayData, destroy),
- ArrayData::Data::markObjects,
- isEqualTo
-};
+DEFINE_MANAGED_VTABLE(ArrayData);
const ArrayVTable SimpleArrayData::static_vtbl =
{
@@ -99,18 +81,9 @@ const ArrayVTable SparseArrayData::static_vtbl =
SparseArrayData::length
};
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
-
Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SimpleArrayData));
Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SparseArrayData));
-static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value)
-{
- Value v;
- v.setEmpty(value);
- *target = v.asReturnedValue();
-}
-
void Heap::ArrayData::markObjects(Heap::Base *base, MarkStack *stack)
{
ArrayData *a = static_cast<ArrayData *>(base);
@@ -145,8 +118,6 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
if (d->type() > newType)
newType = d->type();
}
- if (enforceAttributes && newType == Heap::ArrayData::Simple)
- newType = Heap::ArrayData::Complex;
while (alloc < requested)
alloc *= 2;
@@ -195,7 +166,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
Heap::SparseArrayData *sparse = static_cast<Heap::SparseArrayData *>(newData->d());
- ReturnedValue *lastFree;
+ Value *lastFree;
if (d && d->type() == Heap::ArrayData::Sparse) {
Heap::SparseArrayData *old = static_cast<Heap::SparseArrayData *>(d->d());
sparse->sparse = old->sparse;
@@ -204,29 +175,29 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
} else {
sparse->sparse = new SparseArray;
lastFree = &sparse->sparse->freeList;
- storeValue(lastFree, 0);
+ *lastFree = Encode(0);
for (uint i = 0; i < toCopy; ++i) {
if (!sparse->values[i].isEmpty()) {
SparseArrayNode *n = sparse->sparse->insert(i);
n->value = i;
} else {
- storeValue(lastFree, i);
+ *lastFree = Encode(i);
sparse->values.values[i].setEmpty();
- lastFree = &sparse->values.values[i].rawValueRef();
+ lastFree = &sparse->values.values[i];
}
}
}
if (toCopy < sparse->values.alloc) {
for (uint i = toCopy; i < sparse->values.alloc; ++i) {
- storeValue(lastFree, i);
+ *lastFree = Encode(i);
sparse->values.values[i].setEmpty();
- lastFree = &sparse->values.values[i].rawValueRef();
+ lastFree = &sparse->values.values[i];
}
}
- storeValue(lastFree, UINT_MAX);
+ *lastFree = Encode(-1);
- Q_ASSERT(Value::fromReturnedValue(sparse->sparse->freeList).isEmpty());
+ Q_ASSERT(sparse->sparse->freeList.isInteger());
// ### Could explicitly free the old data
}
@@ -248,7 +219,7 @@ ReturnedValue SimpleArrayData::get(const Heap::ArrayData *d, uint index)
{
const Heap::SimpleArrayData *dd = static_cast<const Heap::SimpleArrayData *>(d);
if (index >= dd->values.size)
- return Primitive::emptyValue().asReturnedValue();
+ return Value::emptyValue().asReturnedValue();
return dd->data(index).asReturnedValue();
}
@@ -273,7 +244,7 @@ bool SimpleArrayData::del(Object *o, uint index)
return true;
if (!dd->attrs || dd->attrs[index].isConfigurable()) {
- dd->setData(o->engine(), index, Primitive::emptyValue());
+ dd->setData(o->engine(), index, Value::emptyValue());
if (dd->attrs)
dd->attrs[index] = Attr_Data;
return true;
@@ -355,7 +326,7 @@ bool SimpleArrayData::putArray(Object *o, uint index, const Value *values, uint
}
QV4::ExecutionEngine *e = o->engine();
for (uint i = dd->values.size; i < index; ++i)
- dd->setData(e, i, Primitive::emptyValue());
+ dd->setData(e, i, Value::emptyValue());
for (uint i = 0; i < n; ++i)
dd->setData(e, index + i, values[i]);
dd->values.size = qMax(dd->values.size, index + n);
@@ -368,12 +339,12 @@ void SparseArrayData::free(Heap::ArrayData *d, uint idx)
Value *v = d->values.values + idx;
if (d->attrs && d->attrs[idx].isAccessor()) {
// double slot, free both. Order is important, so we have a double slot for allocation again afterwards.
- v[1].setEmpty(Value::fromReturnedValue(d->sparse->freeList).emptyValue());
- v[0].setEmpty(idx + 1);
+ v[1] = d->sparse->freeList;
+ v[0] = Encode(idx + 1);
} else {
- v->setEmpty(Value::fromReturnedValue(d->sparse->freeList).emptyValue());
+ *v = d->sparse->freeList;
}
- d->sparse->freeList = Primitive::emptyValue(idx).asReturnedValue();
+ d->sparse->freeList = Encode(idx);
if (d->attrs)
d->attrs[idx].clear();
}
@@ -390,36 +361,34 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot)
Q_ASSERT(o->d()->arrayData->type == Heap::ArrayData::Sparse);
Heap::SimpleArrayData *dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
if (doubleSlot) {
- ReturnedValue *last = &dd->sparse->freeList;
+ Value *last = &dd->sparse->freeList;
while (1) {
- if (Value::fromReturnedValue(*last).value() == UINT_MAX) {
+ if (last->int_32() == -1) {
reallocate(o, dd->values.alloc + 2, true);
dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
last = &dd->sparse->freeList;
- Q_ASSERT(Value::fromReturnedValue(*last).value() != UINT_MAX);
+ Q_ASSERT(last->int_32() != -1);
}
- Q_ASSERT(dd->values[Value::fromReturnedValue(*last).value()].value() != Value::fromReturnedValue(*last).value());
- if (dd->values[Value::fromReturnedValue(*last).value()].value() == (Value::fromReturnedValue(*last).value() + 1)) {
+ Q_ASSERT(dd->values[static_cast<uint>(last->int_32())].int_32() != last->int_32());
+ if (dd->values[static_cast<uint>(last->int_32())].int_32() == last->int_32() + 1) {
// found two slots in a row
- uint idx = Value::fromReturnedValue(*last).emptyValue();
- Value lastV = Value::fromReturnedValue(*last);
- lastV.setEmpty(dd->values[lastV.emptyValue() + 1].value());
- *last = lastV.rawValue();
+ uint idx = static_cast<uint>(last->int_32());
+ *last = Encode(dd->values[static_cast<uint>(last->int_32()) + 1].int_32());
dd->attrs[idx] = Attr_Accessor;
return idx;
}
- last = &dd->values.values[Value::fromReturnedValue(*last).value()].rawValueRef();
+ last = &dd->values.values[last->int_32()];
}
} else {
- if (Value::fromReturnedValue(dd->sparse->freeList).value() == UINT_MAX) {
+ if (dd->sparse->freeList.int_32() == -1) {
reallocate(o, dd->values.alloc + 1, false);
dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
}
- uint idx = Value::fromReturnedValue(dd->sparse->freeList).value();
- Q_ASSERT(idx != UINT_MAX);
- dd->sparse->freeList = dd->values[idx].asReturnedValue();
- Q_ASSERT(Value::fromReturnedValue(dd->sparse->freeList).isEmpty());
+ Q_ASSERT(dd->sparse->freeList.int_32() != -1);
+ uint idx = static_cast<uint>(dd->sparse->freeList.int_32());
+ dd->sparse->freeList = dd->values[idx];
+ Q_ASSERT(dd->sparse->freeList.isInteger());
if (dd->attrs)
dd->attrs[idx] = Attr_Data;
return idx;
@@ -431,7 +400,7 @@ ReturnedValue SparseArrayData::get(const Heap::ArrayData *d, uint index)
const Heap::SparseArrayData *s = static_cast<const Heap::SparseArrayData *>(d);
index = s->mappedIndex(index);
if (index == UINT_MAX)
- return Primitive::emptyValue().asReturnedValue();
+ return Value::emptyValue().asReturnedValue();
return s->values[index].asReturnedValue();
}
@@ -474,14 +443,14 @@ bool SparseArrayData::del(Object *o, uint index)
if (isAccessor) {
// free up both indices
- dd->values.values[pidx + 1].setEmpty(Value::fromReturnedValue(dd->sparse->freeList).emptyValue());
- dd->values.values[pidx].setEmpty(pidx + 1);
+ dd->values.values[pidx + 1] = dd->sparse->freeList;
+ dd->values.values[pidx] = Encode(pidx + 1);
} else {
Q_ASSERT(dd->type == Heap::ArrayData::Sparse);
- dd->values.values[pidx].setEmpty(Value::fromReturnedValue(dd->sparse->freeList).emptyValue());
+ dd->values.values[pidx] = dd->sparse->freeList;
}
- dd->sparse->freeList = Primitive::emptyValue(pidx).asReturnedValue();
+ dd->sparse->freeList = Encode(pidx);
dd->sparse->erase(n);
return true;
}
@@ -593,7 +562,7 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
if (!other || ArgumentsObject::isNonStrictArgumentsObject(otherObj)) {
ScopedValue v(scope);
for (uint i = 0; i < n; ++i)
- obj->arraySet(oldSize + i, (v = otherObj->getIndexed(i)));
+ obj->arraySet(oldSize + i, (v = otherObj->get(i)));
} else if (other && other->isSparse()) {
Heap::SparseArrayData *os = static_cast<Heap::SparseArrayData *>(other->d());
if (other->hasAttributes()) {
@@ -635,7 +604,7 @@ void ArrayData::insert(Object *o, uint index, const Value *v, bool isAccessor)
if (index >= d->values.size) {
// mark possible hole in the array
for (uint i = d->values.size; i < index; ++i)
- d->setData(o->engine(), i, Primitive::emptyValue());
+ d->setData(o->engine(), i, Value::emptyValue());
d->values.size = index + 1;
}
d->setData(o->engine(), index, *v);
@@ -828,7 +797,7 @@ void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const Value &c
break;
Q_ASSERT(!d->attrs || !d->attrs[len].isAccessor());
d->setData(engine, i, d->data(len));
- d->setData(engine, len, Primitive::emptyValue());
+ d->setData(engine, len, Value::emptyValue());
}
}
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 7ec060f9c6..64b2161ef5 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -101,34 +101,22 @@ namespace Heap {
DECLARE_HEAP_OBJECT(ArrayData, Base) {
static void markObjects(Heap::Base *base, MarkStack *stack);
- enum Type { Simple = 0, Complex = 1, Sparse = 2, Custom = 3 };
-
- struct Index {
- Heap::ArrayData *arrayData;
- uint index;
-
- void set(EngineBase *e, Value newVal) {
- arrayData->values.set(e, index, newVal);
- }
- const Value *operator->() const { return &arrayData->values[index]; }
- const Value &operator*() const { return arrayData->values[index]; }
- bool isNull() const { return !arrayData; }
- };
+ enum Type { Simple = 0, Sparse = 1, Custom = 2 };
bool isSparse() const { return type == Sparse; }
- const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(Base::vtable()); }
+ const ArrayVTable *vtable() const { return reinterpret_cast<const ArrayVTable *>(internalClass->vtable); }
inline ReturnedValue get(uint i) const {
return vtable()->get(this, i);
}
inline bool getProperty(uint index, Property *p, PropertyAttributes *attrs);
inline void setProperty(EngineBase *e, uint index, const Property *p);
- inline Index getValueOrSetter(uint index, PropertyAttributes *attrs);
+ inline PropertyIndex getValueOrSetter(uint index, PropertyAttributes *attrs);
inline PropertyAttributes attributes(uint i) const;
bool isEmpty(uint i) const {
- return get(i) == Primitive::emptyValue().asReturnedValue();
+ return get(i) == Value::emptyValue().asReturnedValue();
}
inline uint length() const {
@@ -187,8 +175,6 @@ struct Q_QML_EXPORT ArrayData : public Managed
IsArrayData = true
};
- typedef Heap::ArrayData::Index Index;
-
uint alloc() const { return d()->values.alloc; }
uint &alloc() { return d()->values.alloc; }
void setAlloc(uint a) { d()->values.alloc = a; }
@@ -303,9 +289,9 @@ bool ArrayData::getProperty(uint index, Property *p, PropertyAttributes *attrs)
*attrs = attributes(index);
if (p) {
- p->value = *(Index{ this, mapped });
+ p->value = *(PropertyIndex{ this, values.values + mapped });
if (attrs->isAccessor())
- p->set = *(Index{ this, mapped + 1 /*Object::SetterOffset*/ });
+ p->set = *(PropertyIndex{ this, values.values + mapped + 1 /*Object::SetterOffset*/ });
}
return true;
}
@@ -326,16 +312,18 @@ inline PropertyAttributes ArrayData::attributes(uint i) const
return static_cast<const SimpleArrayData *>(this)->attributes(i);
}
-ArrayData::Index ArrayData::getValueOrSetter(uint index, PropertyAttributes *attrs)
+PropertyIndex ArrayData::getValueOrSetter(uint index, PropertyAttributes *attrs)
{
uint idx = mappedIndex(index);
if (idx == UINT_MAX) {
*attrs = Attr_Invalid;
- return { nullptr, 0 };
+ return { nullptr, nullptr };
}
*attrs = attributes(index);
- return { this, attrs->isAccessor() ? idx + 1 /* QV4::Object::SetterOffset*/ : idx };
+ if (attrs->isAccessor())
+ ++idx;
+ return { this, values.values + idx };
}
diff --git a/src/qml/jsruntime/qv4arrayiterator.cpp b/src/qml/jsruntime/qv4arrayiterator.cpp
new file mode 100644
index 0000000000..199b1a728a
--- /dev/null
+++ b/src/qml/jsruntime/qv4arrayiterator.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Crimson AS <info@crimson.no>
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qv4iterator_p.h>
+#include <private/qv4arrayiterator_p.h>
+#include <private/qv4typedarray_p.h>
+#include <private/qv4symbol_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(ArrayIteratorObject);
+
+void ArrayIteratorPrototype::init(ExecutionEngine *e)
+{
+ defineDefaultProperty(QStringLiteral("next"), method_next, 0);
+
+ Scope scope(e);
+ ScopedString val(scope, e->newString(QLatin1String("Array Iterator")));
+ defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);
+}
+
+ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const Value *that, const Value *, int)
+{
+ Scope scope(b);
+ const ArrayIteratorObject *thisObject = that->as<ArrayIteratorObject>();
+ if (!thisObject)
+ return scope.engine->throwTypeError(QLatin1String("Not an Array Iterator instance"));
+
+ ScopedObject a(scope, thisObject->d()->iteratedObject);
+ if (!a) {
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ quint32 index = thisObject->d()->nextIndex;
+ IteratorKind itemKind = thisObject->d()->iterationKind;
+
+ Scoped<TypedArray> ta(scope, a->as<TypedArray>());
+ quint32 len = a->getLength();
+
+ if (index >= len) {
+ thisObject->d()->iteratedObject.set(scope.engine, nullptr);
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ thisObject->d()->nextIndex = index + 1;
+ if (itemKind == KeyIteratorKind) {
+ return IteratorPrototype::createIterResultObject(scope.engine, Value::fromInt32(index), false);
+ }
+
+ ReturnedValue elementValue = a->get(index);
+ CHECK_EXCEPTION();
+
+ if (itemKind == ValueIteratorKind) {
+ return IteratorPrototype::createIterResultObject(scope.engine, Value::fromReturnedValue(elementValue), false);
+ } else {
+ Q_ASSERT(itemKind == KeyValueIteratorKind);
+
+ ScopedArrayObject resultArray(scope, scope.engine->newArrayObject());
+ resultArray->arrayReserve(2);
+ resultArray->arrayPut(0, Value::fromInt32(index));
+ resultArray->arrayPut(1, Value::fromReturnedValue(elementValue));
+ resultArray->setArrayLengthUnchecked(2);
+
+ return IteratorPrototype::createIterResultObject(scope.engine, resultArray, false);
+ }
+}
+
diff --git a/src/qml/jsruntime/qv4arrayiterator_p.h b/src/qml/jsruntime/qv4arrayiterator_p.h
new file mode 100644
index 0000000000..6d6bb466f1
--- /dev/null
+++ b/src/qml/jsruntime/qv4arrayiterator_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Crimson AS <info@crimson.no>
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4ARRAYITERATOR_P_H
+#define QV4ARRAYITERATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4iterator_p.h"
+#include "qv4arraydata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+namespace QV4 {
+
+namespace Heap {
+
+#define ArrayIteratorObjectMembers(class, Member) \
+ Member(class, Pointer, Object *, iteratedObject) \
+ Member(class, NoMark, IteratorKind, iterationKind) \
+ Member(class, NoMark, quint32, nextIndex)
+
+DECLARE_HEAP_OBJECT(ArrayIteratorObject, Object) {
+ DECLARE_MARKOBJECTS(ArrayIteratorObject);
+ void init(Object *obj, QV4::ExecutionEngine *engine)
+ {
+ Object::init();
+ this->iteratedObject.set(engine, obj);
+ this->nextIndex = 0;
+ }
+};
+
+}
+
+struct ArrayIteratorPrototype : Object
+{
+ V4_PROTOTYPE(iteratorPrototype)
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct ArrayIteratorObject : Object
+{
+ V4_OBJECT2(ArrayIteratorObject, Object)
+ Q_MANAGED_TYPE(ArrayIteratorObject)
+ V4_PROTOTYPE(arrayIteratorPrototype)
+
+ void init(ExecutionEngine *engine);
+};
+
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4ARRAYITERATOR_P_H
+
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index bd019d3bcb..2e7c994550 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
@@ -38,13 +39,17 @@
****************************************************************************/
#include "qv4arrayobject_p.h"
+#include "qv4objectiterator_p.h"
+#include "qv4arrayiterator_p.h"
#include "qv4sparsearray_p.h"
#include "qv4objectproto_p.h"
#include "qv4jscall_p.h"
#include "qv4argumentsobject_p.h"
#include "qv4runtime_p.h"
#include "qv4string_p.h"
+#include "qv4symbol_p.h"
#include <QtCore/qscopedvaluerollback.h>
+#include "qv4proxy_p.h"
using namespace QV4;
@@ -55,7 +60,7 @@ void Heap::ArrayCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Array"));
}
-ReturnedValue ArrayCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue ArrayCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
{
ExecutionEngine *v4 = static_cast<const ArrayCtor *>(f)->engine();
Scope scope(v4);
@@ -80,25 +85,50 @@ ReturnedValue ArrayCtor::callAsConstructor(const FunctionObject *f, const Value
return a.asReturnedValue();
}
-ReturnedValue ArrayCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue ArrayCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- return callAsConstructor(f, argv, argc);
+ return virtualCallAsConstructor(f, argv, argc, f);
}
void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1);
+ ctor->defineDefaultProperty(QStringLiteral("of"), method_of, 0);
+ ctor->defineDefaultProperty(QStringLiteral("from"), method_from, 1);
+ ctor->addSymbolSpecies();
+
+ ScopedObject unscopables(scope, engine->newObject(engine->classes[EngineBase::Class_Empty]->changeVTable(QV4::Object::staticVTable())));
+ ScopedString name(scope);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString, 0);
- defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
+ defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
- defineDefaultProperty(QStringLiteral("find"), method_find, 1);
- defineDefaultProperty(QStringLiteral("findIndex"), method_findIndex, 1);
+ name = engine->newIdentifier(QStringLiteral("copyWithin"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_copyWithin, 2);
+ name = engine->newIdentifier(QStringLiteral("entries"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_entries, 0);
+ name = engine->newIdentifier(QStringLiteral("fill"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_fill, 1);
+ name = engine->newIdentifier(QStringLiteral("find"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_find, 1);
+ name = engine->newIdentifier(QStringLiteral("findIndex"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_findIndex, 1);
+ name = engine->newIdentifier(QStringLiteral("includes"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_includes, 1);
defineDefaultProperty(QStringLiteral("join"), method_join, 1);
+ name = engine->newIdentifier(QStringLiteral("keys"));
+ unscopables->put(name, Value::fromBoolean(true));
+ defineDefaultProperty(name, method_keys, 0);
defineDefaultProperty(QStringLiteral("pop"), method_pop, 0);
defineDefaultProperty(QStringLiteral("push"), method_push, 1);
defineDefaultProperty(QStringLiteral("reverse"), method_reverse, 0);
@@ -116,12 +146,205 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(QStringLiteral("filter"), method_filter, 1);
defineDefaultProperty(QStringLiteral("reduce"), method_reduce, 1);
defineDefaultProperty(QStringLiteral("reduceRight"), method_reduceRight, 1);
+ ScopedString valuesString(scope, engine->newIdentifier(QStringLiteral("values")));
+ ScopedObject values(scope, FunctionObject::createBuiltinFunction(engine, valuesString, method_values, 0));
+ engine->jsObjects[ExecutionEngine::ArrayProtoValues] = values;
+ unscopables->put(valuesString, Value::fromBoolean(true));
+ defineDefaultProperty(valuesString, values);
+ defineDefaultProperty(engine->symbol_iterator(), values);
+
+ defineReadonlyConfigurableProperty(engine->symbol_unscopables(), unscopables);
}
ReturnedValue ArrayPrototype::method_isArray(const FunctionObject *, const Value *, const Value *argv, int argc)
{
- bool isArray = argc && argv[0].as<ArrayObject>();
- return Encode(isArray);
+ if (!argc || !argv->objectValue())
+ return Encode(false);
+ return Encode(argv->objectValue()->isArray());
+}
+
+static ScopedObject createObjectFromCtorOrArray(Scope &scope, ScopedFunctionObject ctor, bool useLen, int len)
+{
+ ScopedObject a(scope, Value::undefinedValue());
+
+ if (ctor && ctor->isConstructor()) {
+ // this isn't completely kosher. for instance:
+ // Array.from.call(Object, []).constructor == Object
+ // is expected by the tests, but naturally, we get Number.
+ ScopedValue argument(scope, useLen ? QV4::Encode(len) : Value::undefinedValue());
+ a = ctor->callAsConstructor(argument, useLen ? 1 : 0);
+ } else {
+ a = scope.engine->newArrayObject(len);
+ }
+
+ return a;
+}
+
+ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(builtin);
+ ScopedFunctionObject thatCtor(scope, thisObject);
+ ScopedObject itemsObject(scope, argv[0]);
+ bool usingIterator = false;
+
+ if (itemsObject) {
+ // If the object claims to support iterators, then let's try use them.
+ ScopedValue it(scope, itemsObject->get(scope.engine->symbol_iterator()));
+ if (!it->isNullOrUndefined()) {
+ ScopedFunctionObject itfunc(scope, it);
+ if (!itfunc)
+ return scope.engine->throwTypeError();
+ usingIterator = true;
+ }
+ }
+
+ ScopedFunctionObject mapfn(scope, Value::undefinedValue());
+ Value *mapArguments = nullptr;
+ if (argc > 1) {
+ mapfn = ScopedFunctionObject(scope, argv[1]);
+ if (!mapfn)
+ return scope.engine->throwTypeError(QString::fromLatin1("%1 is not a function").arg(argv[1].toQStringNoThrow()));
+ mapArguments = scope.alloc(2);
+ }
+
+ ScopedValue thisArg(scope);
+ if (argc > 2)
+ thisArg = argv[2];
+
+ if (usingIterator) {
+ // Item iteration supported, so let's go ahead and try use that.
+ ScopedObject a(createObjectFromCtorOrArray(scope, thatCtor, false, 0));
+ CHECK_EXCEPTION();
+ ScopedObject iterator(scope, Runtime::method_getIterator(scope.engine, itemsObject, true));
+ CHECK_EXCEPTION(); // symbol_iterator threw; whoops.
+ if (!iterator) {
+ return scope.engine->throwTypeError(); // symbol_iterator wasn't an object.
+ }
+
+ qint64 k = 0;
+ ScopedValue mappedValue(scope);
+ Value *nextValue = scope.alloc(1);
+ ScopedValue done(scope);
+
+ // The loop below pulls out all the properties using the iterator, and
+ // sets them into the created array.
+ forever {
+ if (k > (static_cast<qint64>(1) << 53) - 1) {
+ ScopedValue falsey(scope, Encode(false));
+ ScopedValue error(scope, scope.engine->throwTypeError());
+ return Runtime::method_iteratorClose(scope.engine, iterator, falsey);
+ }
+
+ // Retrieve the next value. If the iteration ends, we're done here.
+ done = Value::fromReturnedValue(Runtime::method_iteratorNext(scope.engine, iterator, nextValue));
+ CHECK_EXCEPTION();
+ if (done->toBoolean()) {
+ if (ArrayObject *ao = a->as<ArrayObject>()) {
+ ao->setArrayLengthUnchecked(k);
+ } else {
+ a->set(scope.engine->id_length(), Value::fromDouble(k), QV4::Object::DoThrowOnRejection);
+ CHECK_EXCEPTION();
+ }
+ return a.asReturnedValue();
+ }
+
+ if (mapfn) {
+ mapArguments[0] = *nextValue;
+ mapArguments[1] = Value::fromDouble(k);
+ mappedValue = mapfn->call(thisArg, mapArguments, 2);
+ if (scope.engine->hasException)
+ return Runtime::method_iteratorClose(scope.engine, iterator, Value::fromBoolean(false));
+ } else {
+ mappedValue = *nextValue;
+ }
+
+ if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) == Attr_Invalid) {
+ a->arraySet(k, mappedValue);
+ } else {
+ // Don't return: we need to close the iterator.
+ scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k));
+ }
+
+ if (scope.engine->hasException) {
+ ScopedValue falsey(scope, Encode(false));
+ return Runtime::method_iteratorClose(scope.engine, iterator, falsey);
+ }
+
+ k++;
+ }
+
+ // the return is hidden up in the loop above, when iteration finishes.
+ } else {
+ // Array-like fallback. We request properties by index, and set them on
+ // the return object.
+ ScopedObject arrayLike(scope, argv[0].toObject(scope.engine));
+ if (!arrayLike)
+ return scope.engine->throwTypeError(QString::fromLatin1("Cannot convert %1 to object").arg(argv[0].toQStringNoThrow()));
+ qint64 len = arrayLike->getLength();
+ ScopedObject a(createObjectFromCtorOrArray(scope, thatCtor, true, len));
+ CHECK_EXCEPTION();
+
+ qint64 k = 0;
+ ScopedValue mappedValue(scope, Value::undefinedValue());
+ ScopedValue kValue(scope);
+ while (k < len) {
+ kValue = arrayLike->get(k);
+ CHECK_EXCEPTION();
+
+ if (mapfn) {
+ mapArguments[0] = kValue;
+ mapArguments[1] = Value::fromDouble(k);
+ mappedValue = mapfn->call(thisArg, mapArguments, 2);
+ CHECK_EXCEPTION();
+ } else {
+ mappedValue = kValue;
+ }
+
+ if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) != Attr_Invalid)
+ return scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k));
+
+ a->arraySet(k, mappedValue);
+ CHECK_EXCEPTION();
+
+ k++;
+ }
+
+ if (ArrayObject *ao = a->as<ArrayObject>()) {
+ ao->setArrayLengthUnchecked(k);
+ } else {
+ a->set(scope.engine->id_length(), Value::fromDouble(k), QV4::Object::DoThrowOnRejection);
+ CHECK_EXCEPTION();
+ }
+ return a.asReturnedValue();
+ }
+
+}
+
+ReturnedValue ArrayPrototype::method_of(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(builtin);
+ ScopedFunctionObject that(scope, thisObject);
+ ScopedObject a(createObjectFromCtorOrArray(scope, that, true, argc));
+ CHECK_EXCEPTION();
+
+ int k = 0;
+ while (k < argc) {
+ if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) != Attr_Invalid) {
+ return scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k));
+ }
+ a->arraySet(k, argv[k]);
+ CHECK_EXCEPTION();
+
+ k++;
+ }
+
+ // ArrayObject updates its own length, and will throw if we try touch it.
+ if (!a->as<ArrayObject>()) {
+ a->set(scope.engine->id_length(), Value::fromDouble(argc), QV4::Object::DoThrowOnRejection);
+ CHECK_EXCEPTION();
+ }
+
+ return a.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_toString(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
@@ -138,9 +361,36 @@ ReturnedValue ArrayPrototype::method_toString(const FunctionObject *builtin, con
return ObjectPrototype::method_toString(builtin, that, argv, argc);
}
-ReturnedValue ArrayPrototype::method_toLocaleString(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue ArrayPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
- return method_toString(builtin, thisObject, argv, argc);
+ Scope scope(b);
+ ScopedObject instance(scope, thisObject);
+ if (!instance)
+ return scope.engine->throwTypeError();
+
+ uint len = instance->getLength();
+ const QString separator = QStringLiteral(",");
+
+ QString R;
+
+ ScopedValue v(scope);
+ ScopedString s(scope);
+
+ for (uint k = 0; k < len; ++k) {
+ if (k)
+ R += separator;
+
+ v = instance->get(k);
+ if (v->isNullOrUndefined())
+ continue;
+ v = Runtime::method_callElement(scope.engine, v, *scope.engine->id_toLocaleString(), nullptr, 0);
+ s = v->toString(scope.engine);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ R += s->toQString();
+ }
+ return scope.engine->newString(R)->asReturnedValue();
}
ReturnedValue ArrayPrototype::method_concat(const FunctionObject *b, const Value *that, const Value *argv, int argc)
@@ -152,37 +402,128 @@ ReturnedValue ArrayPrototype::method_concat(const FunctionObject *b, const Value
ScopedArrayObject result(scope, scope.engine->newArrayObject());
- if (thisObject->isArrayObject()) {
- result->copyArrayData(thisObject);
- } else {
- result->arraySet(0, thisObject);
- }
-
ScopedArrayObject elt(scope);
ScopedObject eltAsObj(scope);
ScopedValue entry(scope);
- for (int i = 0, ei = argc; i < ei; ++i) {
- eltAsObj = argv[i];
- elt = argv[i];
+ for (int i = -1; i < argc; ++i) {
+ const Value *v = i == -1 ? thisObject.getPointer() : argv + i;
+ eltAsObj = *v;
+ elt = *v;
if (elt) {
uint n = elt->getLength();
uint newLen = ArrayData::append(result, elt, n);
result->setArrayLengthUnchecked(newLen);
+ } else if (eltAsObj && eltAsObj->isConcatSpreadable()) {
+ const uint startIndex = result->getLength();
+ const uint len = eltAsObj->getLength();
+ if (scope.engine->hasException)
+ return Encode::undefined();
+
+ for (uint i = 0; i < len; ++i) {
+ bool hasProperty = false;
+ entry = eltAsObj->get(i, &hasProperty);
+ if (hasProperty) {
+ if (!result->put(startIndex + i, entry))
+ return scope.engine->throwTypeError();
+ }
+ }
} else if (eltAsObj && eltAsObj->isListType()) {
const uint startIndex = result->getLength();
for (int i = 0, len = eltAsObj->getLength(); i < len; ++i) {
- entry = eltAsObj->getIndexed(i);
+ entry = eltAsObj->get(i);
// spec says not to throw if this fails
- result->putIndexed(startIndex + i, entry);
+ result->put(startIndex + i, entry);
}
} else {
- result->arraySet(result->getLength(), argv[i]);
+ result->arraySet(result->getLength(), *v);
}
}
return result.asReturnedValue();
}
+ReturnedValue ArrayPrototype::method_copyWithin(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ ScopedObject instance(scope, thisObject->toObject(scope.engine));
+ if (!instance)
+ RETURN_UNDEFINED();
+
+ double len = instance->getLength();
+ double target = argv[0].toInteger();
+ double start = argc > 1 ? argv[1].toInteger() : 0;
+ double end = len;
+
+ if (argc > 2 && !argv[2].isUndefined()) {
+ end = argv[2].toInteger();
+ }
+
+ double relativeTarget = target;
+ double relativeStart = start;
+ double relativeEnd = end;
+ double from = 0;
+ double to = 0;
+
+ if (relativeTarget < 0) {
+ to = std::max(len+relativeTarget, 0.0);
+ } else {
+ to = std::min(relativeTarget, len);
+ }
+ if (relativeStart < 0) {
+ from = std::max(len+relativeStart, 0.0);
+ } else {
+ from = std::min(relativeStart, len);
+ }
+
+ double fin = 0;
+ if (relativeEnd < 0) {
+ fin = std::max(len+relativeEnd, 0.0);
+ } else {
+ fin = std::min(relativeEnd, len);
+ }
+ double count = std::min(fin-from, len-to);
+ double direction = 1;
+ if (from < to && to < from+count) {
+ direction = -1;
+ from = from + count - 1;
+ to = to + count - 1;
+ }
+
+ while (count > 0) {
+ bool fromPresent = false;
+ ScopedValue fromVal(scope, instance->get(from, &fromPresent));
+
+ if (fromPresent) {
+ instance->setIndexed(to, fromVal, QV4::Object::DoThrowOnRejection);
+ CHECK_EXCEPTION();
+ } else {
+ bool didDelete = instance->deleteProperty(PropertyKey::fromArrayIndex(to));
+ CHECK_EXCEPTION();
+ if (!didDelete) {
+ return scope.engine->throwTypeError();
+ }
+ }
+
+ from = from + direction;
+ to = to + direction;
+ count = count - 1;
+ }
+
+ return instance.asReturnedValue();
+}
+
+ReturnedValue ArrayPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ ScopedObject O(scope, thisObject->toObject(scope.engine));
+ if (!O)
+ RETURN_UNDEFINED();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
ReturnedValue ArrayPrototype::method_find(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
@@ -199,13 +540,13 @@ ReturnedValue ArrayPrototype::method_find(const FunctionObject *b, const Value *
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
- arguments[0] = instance->getIndexed(k);
+ arguments[0] = instance->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
@@ -233,13 +574,13 @@ ReturnedValue ArrayPrototype::method_findIndex(const FunctionObject *b, const Va
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
for (uint k = 0; k < len; ++k) {
- arguments[0] = instance->getIndexed(k);
+ arguments[0] = instance->get(k);
CHECK_EXCEPTION();
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
@@ -259,7 +600,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
if (!instance)
return Encode(scope.engine->newString());
- ScopedValue arg(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue arg(scope, argc ? argv[0] : Value::undefinedValue());
QString r4;
if (arg->isUndefined())
@@ -282,7 +623,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
if (i)
R += r4;
- e = a->getIndexed(i);
+ e = a->get(i);
CHECK_EXCEPTION();
if (!e->isNullOrUndefined())
R += e->toQString();
@@ -300,7 +641,7 @@ ReturnedValue ArrayPrototype::method_join(const FunctionObject *b, const Value *
for (quint32 k = 1; k < r2; ++k) {
R += r4;
- name = Primitive::fromDouble(k).toString(scope.engine);
+ name = Value::fromDouble(k).toString(scope.engine);
r12 = instance->get(name);
CHECK_EXCEPTION();
@@ -323,20 +664,20 @@ ReturnedValue ArrayPrototype::method_pop(const FunctionObject *b, const Value *t
if (!len) {
if (!instance->isArrayObject())
- instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0)));
+ instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromInt32(0)));
RETURN_UNDEFINED();
}
- ScopedValue result(scope, instance->getIndexed(len - 1));
+ ScopedValue result(scope, instance->get(len - 1));
CHECK_EXCEPTION();
- if (!instance->deleteIndexedProperty(len - 1))
+ if (!instance->deleteProperty(PropertyKey::fromArrayIndex(len - 1)))
return scope.engine->throwTypeError();
if (instance->isArrayObject())
instance->setArrayLength(len - 1);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - 1))))
return scope.engine->throwTypeError();
}
return result->asReturnedValue();
@@ -352,20 +693,20 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value *
instance->arrayCreate();
Q_ASSERT(instance->arrayData());
- uint len = instance->getLength();
+ qint64 len = instance->getLength();
- if (len + argc < len) {
+ if (len + quint64(argc) >= UINT_MAX) {
// ughh... this goes beyond UINT_MAX
double l = len;
ScopedString s(scope);
for (int i = 0, ei = argc; i < ei; ++i) {
- s = Primitive::fromDouble(l + i).toString(scope.engine);
+ s = Value::fromDouble(l + i).toString(scope.engine);
if (!instance->put(s, argv[i]))
return scope.engine->throwTypeError();
}
double newLen = l + argc;
if (!instance->isArrayObject()) {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(newLen))))
return scope.engine->throwTypeError();
} else {
ScopedString str(scope, scope.engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
@@ -381,7 +722,7 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value *
len = instance->arrayData()->length();
} else {
for (int i = 0, ei = argc; i < ei; ++i) {
- if (!instance->putIndexed(len + i, argv[i]))
+ if (!instance->put(len + i, argv[i]))
return scope.engine->throwTypeError();
}
len += argc;
@@ -389,11 +730,11 @@ ReturnedValue ArrayPrototype::method_push(const FunctionObject *b, const Value *
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len))))
return scope.engine->throwTypeError();
}
- return Encode(len);
+ return Encode(uint(len));
}
ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -403,7 +744,10 @@ ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Valu
if (!instance)
RETURN_UNDEFINED();
- uint length = instance->getLength();
+ qint64 length = instance->getLength();
+ // ### FIXME
+ if (length >= UINT_MAX)
+ return scope.engine->throwRangeError(QLatin1String("Array.prototype.reverse: Length out of range."));
int lo = 0, hi = length - 1;
@@ -411,19 +755,19 @@ ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Valu
ScopedValue hval(scope);
for (; lo < hi; ++lo, --hi) {
bool loExists, hiExists;
- lval = instance->getIndexed(lo, &loExists);
- hval = instance->getIndexed(hi, &hiExists);
+ lval = instance->get(lo, &loExists);
+ hval = instance->get(hi, &hiExists);
CHECK_EXCEPTION();
bool ok;
if (hiExists)
- ok = instance->putIndexed(lo, hval);
+ ok = instance->put(lo, hval);
else
- ok = instance->deleteIndexedProperty(lo);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(lo));
if (ok) {
if (loExists)
- ok = instance->putIndexed(hi, lval);
+ ok = instance->put(hi, lval);
else
- ok = instance->deleteIndexedProperty(hi);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(hi));
}
if (!ok)
return scope.engine->throwTypeError();
@@ -445,7 +789,7 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (!len) {
if (!instance->isArrayObject())
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromInt32(0))))
return scope.engine->throwTypeError();
RETURN_UNDEFINED();
}
@@ -454,23 +798,23 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (!instance->protoHasArray() && !instance->arrayData()->attrs && instance->arrayData()->length() <= len && instance->arrayData()->type != Heap::ArrayData::Custom) {
result = instance->arrayData()->vtable()->pop_front(instance);
} else {
- result = instance->getIndexed(0);
+ result = instance->get(uint(0));
CHECK_EXCEPTION();
ScopedValue v(scope);
// do it the slow way
for (uint k = 1; k < len; ++k) {
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
- ok = instance->putIndexed(k - 1, v);
+ ok = instance->put(k - 1, v);
else
- ok = instance->deleteIndexedProperty(k - 1);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k - 1));
if (!ok)
return scope.engine->throwTypeError();
}
- bool ok = instance->deleteIndexedProperty(len - 1);
+ bool ok = instance->deleteProperty(PropertyKey::fromArrayIndex(len - 1));
if (!ok)
return scope.engine->throwTypeError();
}
@@ -478,7 +822,7 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len - 1);
else {
- bool ok = instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1)));
+ bool ok = instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - 1)));
if (!ok)
return scope.engine->throwTypeError();
}
@@ -495,7 +839,7 @@ ReturnedValue ArrayPrototype::method_slice(const FunctionObject *b, const Value
ScopedArrayObject result(scope, scope.engine->newArrayObject());
uint len = o->getLength();
- double s = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double s = (argc ? argv[0] : Value::undefinedValue()).toInteger();
uint start;
if (s < 0)
start = (uint)qMax(len + s, 0.);
@@ -518,7 +862,7 @@ ReturnedValue ArrayPrototype::method_slice(const FunctionObject *b, const Value
uint n = 0;
for (uint i = start; i < end; ++i) {
bool exists;
- v = o->getIndexed(i, &exists);
+ v = o->get(i, &exists);
CHECK_EXCEPTION();
if (exists)
result->arraySet(n, v);
@@ -536,7 +880,7 @@ ReturnedValue ArrayPrototype::method_sort(const FunctionObject *b, const Value *
uint len = instance->getLength();
- ScopedValue comparefn(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue comparefn(scope, argc ? argv[0] : Value::undefinedValue());
ArrayData::sort(scope.engine, instance, comparefn, len);
return thisObject->asReturnedValue();
}
@@ -548,60 +892,71 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
if (!instance)
RETURN_UNDEFINED();
- uint len = instance->getLength();
-
- ScopedArrayObject newArray(scope, scope.engine->newArrayObject());
+ qint64 len = instance->getLength();
- double rs = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
- uint start;
+ double rs = (argc ? argv[0] : Value::undefinedValue()).toInteger();
+ qint64 start;
if (rs < 0)
- start = (uint) qMax(0., len + rs);
+ start = static_cast<qint64>(qMax(0., len + rs));
else
- start = (uint) qMin(rs, (double)len);
+ start = static_cast<qint64>(qMin(rs, static_cast<double>(len)));
+
+ qint64 deleteCount = 0;
+ qint64 itemCount = 0;
+ if (argc == 1) {
+ deleteCount = len - start;
+ } else if (argc > 1){
+ itemCount = argc - 2;
+ double dc = argv[1].toInteger();
+ deleteCount = static_cast<qint64>(qMin(qMax(dc, 0.), double(len - start)));
+ }
- uint deleteCount = (uint)qMin(qMax((argc > 1 ? argv[1] : Primitive::undefinedValue()).toInteger(), 0.), (double)(len - start));
+ if (len + itemCount - deleteCount > /*(static_cast<qint64>(1) << 53) - 1*/ UINT_MAX - 1)
+ return scope.engine->throwTypeError();
+ if (deleteCount > /*(static_cast<qint64>(1) << 53) - 1*/ UINT_MAX - 1)
+ return scope.engine->throwRangeError(QString::fromLatin1("Array length out of range."));
+ ScopedArrayObject newArray(scope, scope.engine->newArrayObject());
newArray->arrayReserve(deleteCount);
ScopedValue v(scope);
for (uint i = 0; i < deleteCount; ++i) {
bool exists;
- v = instance->getIndexed(start + i, &exists);
+ v = instance->get(start + i, &exists);
CHECK_EXCEPTION();
if (exists)
newArray->arrayPut(i, v);
}
newArray->setArrayLengthUnchecked(deleteCount);
- uint itemCount = argc < 2 ? 0 : argc - 2;
if (itemCount < deleteCount) {
for (uint k = start; k < len - deleteCount; ++k) {
bool exists;
- v = instance->getIndexed(k + deleteCount, &exists);
+ v = instance->get(k + deleteCount, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
- ok = instance->putIndexed(k + itemCount, v);
+ ok = instance->put(k + itemCount, v);
else
- ok = instance->deleteIndexedProperty(k + itemCount);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + itemCount));
if (!ok)
return scope.engine->throwTypeError();
}
for (uint k = len; k > len - deleteCount + itemCount; --k) {
- if (!instance->deleteIndexedProperty(k - 1))
+ if (!instance->deleteProperty(PropertyKey::fromArrayIndex(k - 1)))
return scope.engine->throwTypeError();
}
} else if (itemCount > deleteCount) {
uint k = len - deleteCount;
while (k > start) {
bool exists;
- v = instance->getIndexed(k + deleteCount - 1, &exists);
+ v = instance->get(k + deleteCount - 1, &exists);
CHECK_EXCEPTION();
bool ok;
if (exists)
- ok = instance->putIndexed(k + itemCount - 1, v);
+ ok = instance->put(k + itemCount - 1, v);
else
- ok = instance->deleteIndexedProperty(k + itemCount - 1);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + itemCount - 1));
if (!ok)
return scope.engine->throwTypeError();
--k;
@@ -609,9 +964,9 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value
}
for (uint i = 0; i < itemCount; ++i)
- instance->putIndexed(start + i, argv[i + 2]);
+ instance->put(start + i, argv[i + 2]);
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(len - deleteCount + itemCount))))
return scope.engine->throwTypeError();
return newArray->asReturnedValue();
@@ -636,17 +991,17 @@ ReturnedValue ArrayPrototype::method_unshift(const FunctionObject *b, const Valu
ScopedValue v(scope);
for (uint k = len; k > 0; --k) {
bool exists;
- v = instance->getIndexed(k - 1, &exists);
+ v = instance->get(k - 1, &exists);
bool ok;
if (exists)
- ok = instance->putIndexed(k + argc - 1, v);
+ ok = instance->put(k + argc - 1, v);
else
- ok = instance->deleteIndexedProperty(k + argc - 1);
+ ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + argc - 1));
if (!ok)
return scope.engine->throwTypeError();
}
for (int i = 0, ei = argc; i < ei; ++i) {
- bool ok = instance->putIndexed(i, argv[i]);
+ bool ok = instance->put(i, argv[i]);
if (!ok)
return scope.engine->throwTypeError();
}
@@ -656,13 +1011,51 @@ ReturnedValue ArrayPrototype::method_unshift(const FunctionObject *b, const Valu
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(newLen);
else {
- if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen))))
+ if (!instance->put(scope.engine->id_length(), ScopedValue(scope, Value::fromDouble(newLen))))
return scope.engine->throwTypeError();
}
return Encode(newLen);
}
+ReturnedValue ArrayPrototype::method_includes(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ ScopedObject instance(scope, thisObject->toObject(scope.engine));
+ if (!instance)
+ RETURN_UNDEFINED();
+
+ qint64 len = instance->getLength();
+ if (len == 0) {
+ return Encode(false);
+ }
+
+ double n = 0;
+ if (argc > 1 && !argv[1].isUndefined()) {
+ n = argv[1].toInteger();
+ }
+
+ double k = 0;
+ if (n >= 0) {
+ k = n;
+ } else {
+ k = len + n;
+ if (k < 0) {
+ k = 0;
+ }
+ }
+
+ while (k < len) {
+ ScopedValue val(scope, instance->get(k));
+ if (val->sameValueZero(argv[0])) {
+ return Encode(true);
+ }
+ k++;
+ }
+
+ return Encode(false);
+}
+
ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
@@ -674,7 +1067,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
if (!len)
return Encode(-1);
- ScopedValue searchValue(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
uint fromIndex = 0;
if (argc >= 2) {
@@ -691,7 +1084,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
ScopedValue v(scope);
for (uint k = fromIndex; k < len; ++k) {
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
if (exists && RuntimeHelpers::strictEqual(v, searchValue))
return Encode(k);
}
@@ -705,7 +1098,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
// lets be safe and slow
for (uint i = fromIndex; i < len; ++i) {
bool exists;
- value = instance->getIndexed(i, &exists);
+ value = instance->get(i, &exists);
CHECK_EXCEPTION();
if (exists && RuntimeHelpers::strictEqual(value, searchValue))
return Encode(i);
@@ -713,7 +1106,7 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
} else if (!instance->arrayData()) {
return Encode(-1);
} else {
- Q_ASSERT(instance->arrayType() == Heap::ArrayData::Simple || instance->arrayType() == Heap::ArrayData::Complex);
+ Q_ASSERT(instance->arrayType() == Heap::ArrayData::Simple);
Heap::SimpleArrayData *sa = instance->d()->arrayData.cast<Heap::SimpleArrayData>();
if (len > sa->values.size)
len = sa->values.size;
@@ -729,6 +1122,18 @@ ReturnedValue ArrayPrototype::method_indexOf(const FunctionObject *b, const Valu
return Encode(-1);
}
+ReturnedValue ArrayPrototype::method_keys(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ ScopedObject O(scope, thisObject->toObject(scope.engine));
+ if (!O)
+ RETURN_UNDEFINED();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ ao->d()->iterationKind = IteratorKind::KeyIteratorKind;
+ return ao->asReturnedValue();
+}
+
ReturnedValue ArrayPrototype::method_lastIndexOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
@@ -746,7 +1151,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(const FunctionObject *b, const
if (argc >= 1)
searchValue = argv[0];
else
- searchValue = Primitive::undefinedValue();
+ searchValue = Value::undefinedValue();
if (argc >= 2) {
double f = argv[1].toInteger();
@@ -765,7 +1170,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(const FunctionObject *b, const
for (uint k = fromIndex; k > 0;) {
--k;
bool exists;
- v = instance->getIndexed(k, &exists);
+ v = instance->get(k, &exists);
CHECK_EXCEPTION();
if (exists && RuntimeHelpers::strictEqual(v, searchValue))
return Encode(k);
@@ -786,18 +1191,18 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue r(scope);
Value *arguments = scope.alloc(3);
bool ok = true;
for (uint k = 0; ok && k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
r = callback->call(that, arguments, 3);
ok = r->toBoolean();
@@ -805,6 +1210,42 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
return Encode(ok);
}
+ReturnedValue ArrayPrototype::method_fill(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ ScopedObject instance(scope, thisObject->toObject(scope.engine));
+ if (!instance)
+ RETURN_UNDEFINED();
+
+ uint len = instance->getLength();
+ int relativeStart = argc > 1 ? argv[1].toInteger() : 0;
+ int relativeEnd = len;
+ if (argc > 2 && !argv[2].isUndefined()) {
+ relativeEnd = argv[2].toInteger();
+ }
+ uint k = 0;
+ uint fin = 0;
+
+ if (relativeStart < 0) {
+ k = std::max(len+relativeStart, uint(0));
+ } else {
+ k = std::min(uint(relativeStart), len);
+ }
+
+ if (relativeEnd < 0) {
+ fin = std::max(len + relativeEnd, uint(0));
+ } else {
+ fin = std::min(uint(relativeEnd), len);
+ }
+
+ while (k < fin) {
+ instance->setIndexed(k, argv[0], QV4::Object::DoThrowOnRejection);
+ k++;
+ }
+
+ return instance.asReturnedValue();
+}
+
ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
@@ -818,17 +1259,17 @@ ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedValue result(scope);
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
if (result->toBoolean())
@@ -850,16 +1291,16 @@ ReturnedValue ArrayPrototype::method_forEach(const FunctionObject *b, const Valu
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
callback->call(that, arguments, 3);
}
@@ -873,28 +1314,31 @@ ReturnedValue ArrayPrototype::method_map(const FunctionObject *b, const Value *t
if (!instance)
RETURN_UNDEFINED();
- uint len = instance->getLength();
+ qint64 len = instance->getLength();
if (!argc || !argv->isFunctionObject())
THROW_TYPE_ERROR();
const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+ if (len > UINT_MAX - 1)
+ return scope.engine->throwRangeError(QString::fromLatin1("Array length out of range."));
+
ScopedArrayObject a(scope, scope.engine->newArrayObject());
a->arrayReserve(len);
a->setArrayLengthUnchecked(len);
ScopedValue v(scope);
ScopedValue mapped(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
mapped = callback->call(that, arguments, 3);
a->arraySet(k, mapped);
@@ -919,17 +1363,17 @@ ReturnedValue ArrayPrototype::method_filter(const FunctionObject *b, const Value
a->arrayReserve(len);
ScopedValue selected(scope);
- ScopedValue that(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
Value *arguments = scope.alloc(3);
uint to = 0;
for (uint k = 0; k < len; ++k) {
bool exists;
- arguments[0] = instance->getIndexed(k, &exists);
+ arguments[0] = instance->get(k, &exists);
if (!exists)
continue;
- arguments[1] = Primitive::fromDouble(k);
+ arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
selected = callback->call(that, arguments, 3);
if (selected->toBoolean()) {
@@ -962,7 +1406,7 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
} else {
bool kPresent = false;
while (k < len && !kPresent) {
- v = instance->getIndexed(k, &kPresent);
+ v = instance->get(k, &kPresent);
if (kPresent)
acc = v;
++k;
@@ -975,11 +1419,11 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
while (k < len) {
bool kPresent;
- v = instance->getIndexed(k, &kPresent);
+ v = instance->get(k, &kPresent);
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k);
+ arguments[2] = Value::fromDouble(k);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
@@ -1015,7 +1459,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
} else {
bool kPresent = false;
while (k > 0 && !kPresent) {
- v = instance->getIndexed(k - 1, &kPresent);
+ v = instance->get(k - 1, &kPresent);
if (kPresent)
acc = v;
--k;
@@ -1028,11 +1472,11 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
while (k > 0) {
bool kPresent;
- v = instance->getIndexed(k - 1, &kPresent);
+ v = instance->get(k - 1, &kPresent);
if (kPresent) {
arguments[0] = acc;
arguments[1] = v;
- arguments[2] = Primitive::fromDouble(k - 1);
+ arguments[2] = Value::fromDouble(k - 1);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
}
@@ -1041,3 +1485,20 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
return acc->asReturnedValue();
}
+ReturnedValue ArrayPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ ScopedObject O(scope, thisObject->toObject(scope.engine));
+ if (!O)
+ RETURN_UNDEFINED();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(O));
+ ao->d()->iterationKind = IteratorKind::ValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue ArrayPrototype::method_get_species(const FunctionObject *, const Value *thisObject, const Value *, int)
+{
+ return thisObject->asReturnedValue();
+}
+
diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h
index 3825a600a2..04ec7e1607 100644
--- a/src/qml/jsruntime/qv4arrayobject_p.h
+++ b/src/qml/jsruntime/qv4arrayobject_p.h
@@ -70,8 +70,8 @@ struct ArrayCtor: FunctionObject
{
V4_OBJECT2(ArrayCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
struct ArrayPrototype: ArrayObject
@@ -79,9 +79,13 @@ struct ArrayPrototype: ArrayObject
void init(ExecutionEngine *engine, Object *ctor);
static ReturnedValue method_isArray(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_from(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_of(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_concat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_copyWithin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_find(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_findIndex(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_join(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -93,15 +97,23 @@ struct ArrayPrototype: ArrayObject
static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_every(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_fill(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_some(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_map(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_filter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_reduce(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_reduceRight(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ // while this function is implemented here, it's the same for many other JS classes, so the corresponding JS function
+ // is instantiated in the engine, and it can be added to any JS object through Object::addSymbolSpecies()
+ static ReturnedValue method_get_species(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
diff --git a/src/qml/jsruntime/qv4atomics.cpp b/src/qml/jsruntime/qv4atomics.cpp
new file mode 100644
index 0000000000..4299aef859
--- /dev/null
+++ b/src/qml/jsruntime/qv4atomics.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qv4arraybuffer_p.h"
+#include "qv4typedarray_p.h"
+#include "qv4atomics_p.h"
+#include "qv4symbol_p.h"
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(Atomics);
+
+void Heap::Atomics::init()
+{
+ Object::init();
+ Scope scope(internalClass->engine);
+ ScopedObject m(scope, this);
+
+ m->defineDefaultProperty(QStringLiteral("add"), QV4::Atomics::method_add, 3);
+ m->defineDefaultProperty(QStringLiteral("and"), QV4::Atomics::method_and, 3);
+ m->defineDefaultProperty(QStringLiteral("compareExchange"), QV4::Atomics::method_compareExchange, 4);
+ m->defineDefaultProperty(QStringLiteral("exchange"), QV4::Atomics::method_exchange, 3);
+ m->defineDefaultProperty(QStringLiteral("isLockFree"), QV4::Atomics::method_isLockFree, 1);
+ m->defineDefaultProperty(QStringLiteral("load"), QV4::Atomics::method_load, 2);
+ m->defineDefaultProperty(QStringLiteral("or"), QV4::Atomics::method_or, 3);
+ m->defineDefaultProperty(QStringLiteral("store"), QV4::Atomics::method_store, 3);
+ m->defineDefaultProperty(QStringLiteral("sub"), QV4::Atomics::method_sub, 3);
+ m->defineDefaultProperty(QStringLiteral("wait"), QV4::Atomics::method_wait, 4);
+ m->defineDefaultProperty(QStringLiteral("wake"), QV4::Atomics::method_wake, 3);
+ m->defineDefaultProperty(QStringLiteral("xor"), QV4::Atomics::method_xor, 3);
+
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("Atomics")));
+ m->defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);
+}
+
+static SharedArrayBuffer *validateSharedIntegerTypedArray(Scope &scope, const Value &typedArray, bool onlyInt32 = false)
+{
+ const TypedArray *a = typedArray.as<TypedArray>();
+ if (!a) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ TypedArrayType t(a->arrayType());
+ if (!a->d()->type->atomicLoad || (onlyInt32 && t != TypedArrayType::Int32Array)) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ Scoped<SharedArrayBuffer> buffer(scope, a->d()->buffer);
+ if (!buffer->isSharedArrayBuffer()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ Q_ASSERT(!buffer->isDetachedBuffer());
+ return buffer;
+}
+
+static int validateAtomicAccess(Scope &scope, const TypedArray &typedArray, const Value &index)
+{
+ const TypedArray &a = static_cast<const TypedArray &>(typedArray);
+ qint64 idx = index.toIndex();
+ if (scope.hasException())
+ return -1;
+ if (idx < 0 || idx >= a.length()) {
+ scope.engine->throwRangeError(QStringLiteral("index out of range."));
+ return -1;
+ }
+ return static_cast<int>(idx);
+}
+
+ReturnedValue atomicReadModifyWrite(const FunctionObject *f, const Value *argv, int argc, AtomicModifyOps modify)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ SharedArrayBuffer *buffer = validateSharedIntegerTypedArray(scope, argv[0]);
+ if (!buffer)
+ return Encode::undefined();
+ const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
+ if (index < 0)
+ return Encode::undefined();
+
+ Value v = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int bytesPerElement = a.d()->type->bytesPerElement;
+ int byteOffset = a.d()->byteOffset + index * bytesPerElement;
+
+ return a.d()->type->atomicModifyOps[modify](buffer->data() + byteOffset, v);
+}
+
+ReturnedValue Atomics::method_add(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicAdd);
+}
+
+ReturnedValue Atomics::method_and(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicAnd);
+}
+
+ReturnedValue Atomics::method_compareExchange(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ SharedArrayBuffer *buffer = validateSharedIntegerTypedArray(scope, argv[0]);
+ if (!buffer)
+ return Encode::undefined();
+ const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
+ if (index < 0)
+ return Encode::undefined();
+
+ Value expected = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
+ if (scope.hasException())
+ return Encode::undefined();
+ Value v = Value::fromReturnedValue((argc > 3 ? argv[3] : Value::undefinedValue()).convertedToNumber());
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int bytesPerElement = a.d()->type->bytesPerElement;
+ int byteOffset = a.d()->byteOffset + index * bytesPerElement;
+
+ return a.d()->type->atomicCompareExchange(buffer->data() + byteOffset, expected, v);
+}
+
+ReturnedValue Atomics::method_exchange(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicExchange);
+}
+
+ReturnedValue Atomics::method_isLockFree(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ if (!argc)
+ return Encode(false);
+ double n = argv[0].toInteger();
+ if (n == 4.)
+ return Encode(true);
+ if (n == 2.)
+ return Encode(QAtomicOps<unsigned short>::isTestAndSetNative());
+#ifdef Q_ATOMIC_INT8_IS_SUPPORTED
+ if (n == 1.)
+ return Encode(QAtomicOps<unsigned char>::isTestAndSetNative());
+#endif
+ return Encode(false);
+}
+
+ReturnedValue Atomics::method_load(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ SharedArrayBuffer *buffer = validateSharedIntegerTypedArray(scope, argv[0]);
+ if (!buffer)
+ return Encode::undefined();
+ const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
+ if (index < 0)
+ return Encode::undefined();
+
+ int bytesPerElement = a.d()->type->bytesPerElement;
+ int byteOffset = a.d()->byteOffset + index * bytesPerElement;
+
+ return a.d()->type->atomicLoad(buffer->data() + byteOffset);
+}
+
+ReturnedValue Atomics::method_or(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicOr);
+}
+
+ReturnedValue Atomics::method_store(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ SharedArrayBuffer *buffer = validateSharedIntegerTypedArray(scope, argv[0]);
+ if (!buffer)
+ return Encode::undefined();
+ const TypedArray &a = static_cast<const TypedArray &>(argv[0]);
+ int index = validateAtomicAccess(scope, a, argc > 1 ? argv[1] : Value::undefinedValue());
+ if (index < 0)
+ return Encode::undefined();
+
+ Value v = Value::fromReturnedValue((argc > 2 ? argv[2] : Value::undefinedValue()).convertedToNumber());
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int bytesPerElement = a.d()->type->bytesPerElement;
+ int byteOffset = a.d()->byteOffset + index * bytesPerElement;
+
+ return a.d()->type->atomicStore(buffer->data() + byteOffset, v);
+}
+
+ReturnedValue Atomics::method_sub(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicSub);
+}
+
+ReturnedValue Atomics::method_wait(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError();
+}
+
+ReturnedValue Atomics::method_wake(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError();
+}
+
+ReturnedValue Atomics::method_xor(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return atomicReadModifyWrite(f, argv, argc, AtomicXor);
+
+}
diff --git a/src/qml/jsruntime/qv4atomics_p.h b/src/qml/jsruntime/qv4atomics_p.h
new file mode 100644
index 0000000000..35b64bf4fe
--- /dev/null
+++ b/src/qml/jsruntime/qv4atomics_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4ATOMICS_H
+#define QV4ATOMICS_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4functionobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+struct Atomics : Object {
+ void init();
+};
+
+}
+
+struct Atomics : Object
+{
+ V4_OBJECT2(Atomics, Object)
+
+ static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_and(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_compareExchange(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_exchange(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isLockFree(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_load(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_or(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_store(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_sub(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_wait(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_wake(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_xor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+
+} // namespace QV4
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index eb83f902db..075ee1657e 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -50,13 +50,13 @@ void Heap::BooleanCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Boolean"));
}
-ReturnedValue BooleanCtor::callAsConstructor(const FunctionObject *that, const Value *argv, int argc)
+ReturnedValue BooleanCtor::virtualCallAsConstructor(const FunctionObject *that, const Value *argv, int argc, const Value *)
{
bool n = argc ? argv[0].toBoolean() : false;
return Encode(that->engine()->newBooleanObject(n));
}
-ReturnedValue BooleanCtor::call(const FunctionObject *, const Value *, const Value *argv, int argc)
+ReturnedValue BooleanCtor::virtualCall(const FunctionObject *, const Value *, const Value *argv, int argc)
{
bool value = argc ? argv[0].toBoolean() : 0;
return Encode(value);
@@ -66,7 +66,7 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString);
diff --git a/src/qml/jsruntime/qv4booleanobject_p.h b/src/qml/jsruntime/qv4booleanobject_p.h
index 3cf09b2667..276ec8393b 100644
--- a/src/qml/jsruntime/qv4booleanobject_p.h
+++ b/src/qml/jsruntime/qv4booleanobject_p.h
@@ -70,8 +70,8 @@ struct BooleanCtor: FunctionObject
{
V4_OBJECT2(BooleanCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
struct BooleanPrototype: BooleanObject
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 020e519e74..94b1a9fb73 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -48,12 +48,51 @@
#include "qv4errorobject_p.h"
#include "qv4string_p.h"
#include "qv4qmlcontext_p.h"
+#include "qv4stackframe_p.h"
+#include "qv4symbol_p.h"
using namespace QV4;
DEFINE_MANAGED_VTABLE(ExecutionContext);
DEFINE_MANAGED_VTABLE(CallContext);
-DEFINE_MANAGED_VTABLE(CatchContext);
+
+Heap::CallContext *ExecutionContext::newBlockContext(CppStackFrame *frame, int blockIndex)
+{
+ Function *function = frame->v4Function;
+
+ Heap::InternalClass *ic = function->compilationUnit->runtimeBlocks.at(blockIndex);
+ uint nLocals = ic->size;
+ size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * nLocals;
+
+ ExecutionEngine *v4 = function->internalClass->engine;
+ Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, ic);
+ c->init();
+ c->type = Heap::ExecutionContext::Type_BlockContext;
+
+ Heap::ExecutionContext *outer = static_cast<Heap::ExecutionContext *>(frame->context()->m());
+ c->outer.set(v4, outer);
+ c->function.set(v4, static_cast<Heap::FunctionObject *>(frame->jsFrame->function.m()));
+
+ c->locals.size = nLocals;
+ c->locals.alloc = nLocals;
+
+ c->setupLocalTemporalDeadZone(function->compilationUnit->unitData()->blockAt(blockIndex));
+
+ return c;
+}
+
+Heap::CallContext *ExecutionContext::cloneBlockContext(Heap::CallContext *context)
+{
+ uint nLocals = context->locals.alloc;
+ size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * nLocals;
+
+ ExecutionEngine *v4 = context->internalClass->engine;
+ Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, context->internalClass);
+ memcpy(c, context, requiredMemory);
+
+ return c;
+
+}
Heap::CallContext *ExecutionContext::newCallContext(CppStackFrame *frame)
{
@@ -75,8 +114,10 @@ Heap::CallContext *ExecutionContext::newCallContext(CppStackFrame *frame)
uint nLocals = compiledFunction->nLocals;
c->locals.size = nLocals;
c->locals.alloc = localsAndFormals;
- // memory allocated from the JS heap is 0 initialized, so check if undefined is 0
- Q_ASSERT(Primitive::undefinedValue().asReturnedValue() == 0);
+ // memory allocated from the JS heap is 0 initialized, so check if empty is 0
+ Q_ASSERT(Value::undefinedValue().asReturnedValue() == 0);
+
+ c->setupLocalTemporalDeadZone(compiledFunction);
Value *args = c->locals.values + nLocals;
::memcpy(args, frame->originalArguments, frame->originalArgumentsCount * sizeof(Value));
@@ -96,11 +137,14 @@ Heap::ExecutionContext *ExecutionContext::newWithContext(Heap::Object *with)
return c;
}
-Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue)
+Heap::ExecutionContext *ExecutionContext::newCatchContext(CppStackFrame *frame, int blockIndex, Heap::String *exceptionVarName)
{
- Scope scope(this);
- ScopedValue e(scope, exceptionValue);
- return engine()->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e);
+ Scope scope(frame->context());
+ ScopedString name(scope, exceptionVarName);
+ ScopedValue val(scope, scope.engine->catchException(nullptr));
+ ScopedContext ctx(scope, newBlockContext(frame, blockIndex));
+ ctx->setProperty(name, val);
+ return ctx->d();
}
void ExecutionContext::createMutableBinding(String *name, bool deletable)
@@ -132,59 +176,77 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable)
activation = ctx->d()->activation;
break;
}
+ case Heap::ExecutionContext::Type_BlockContext:
+ // never create activation records on block contexts
default:
break;
}
ctx = ctx->d()->outer;
}
- if (activation->hasOwnProperty(name))
+ PropertyKey id = name->toPropertyKey();
+ if (activation->getOwnProperty(id) != Attr_Invalid)
return;
ScopedProperty desc(scope);
PropertyAttributes attrs(Attr_Data);
attrs.setConfigurable(deletable);
- activation->__defineOwnProperty__(scope.engine, name, desc, attrs);
+ if (!activation->defineOwnProperty(id, desc, attrs))
+ scope.engine->throwTypeError();
}
-void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName,
- const Value &exceptionValue)
+static bool unscopable(ExecutionEngine *engine, Heap::Object *withObject, PropertyKey id)
{
- Heap::ExecutionContext::init(Heap::ExecutionContext::Type_CatchContext);
- outer.set(internalClass->engine, outerContext);
-
- this->exceptionVarName.set(internalClass->engine, exceptionVarName);
- this->exceptionValue.set(internalClass->engine, exceptionValue);
+ if (!withObject)
+ return false;
+ Scope scope(engine);
+ ScopedObject w(scope, withObject);
+ ScopedObject o(scope, w->get(scope.engine->symbol_unscopables()));
+ if (o) {
+ ScopedValue blocked(scope, o->get(id));
+ return blocked->toBoolean();
+ }
+ return false;
}
bool ExecutionContext::deleteProperty(String *name)
{
- name->makeIdentifier();
- Identifier *id = name->identifier();
+ PropertyKey id = name->toPropertyKey();
Heap::ExecutionContext *ctx = d();
+ ExecutionEngine *engine = ctx->internalClass->engine;
+
for (; ctx; ctx = ctx->outer) {
switch (ctx->type) {
- case Heap::ExecutionContext::Type_CatchContext: {
- Heap::CatchContext *c = static_cast<Heap::CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name->d()))
- return false;
- break;
- }
+ case Heap::ExecutionContext::Type_BlockContext:
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx);
- uint index = c->internalClass->find(id);
+ uint index = c->internalClass->indexOfValueOrGetter(id);
if (index < UINT_MAX)
// ### throw in strict mode?
return false;
Q_FALLTHROUGH();
}
- case Heap::ExecutionContext::Type_WithContext:
+ case Heap::ExecutionContext::Type_WithContext: {
+ if (ctx->activation) {
+ Scope scope(this);
+ ScopedObject object(scope, ctx->activation);
+ if (object && object->hasProperty(id)) {
+ bool u = ::unscopable(engine, ctx->activation, id);
+ if (engine->hasException)
+ return false;
+ if (u)
+ break;
+ return object->deleteProperty(id);
+ }
+ }
+ break;
+ }
case Heap::ExecutionContext::Type_GlobalContext: {
if (ctx->activation) {
Scope scope(this);
ScopedObject object(scope, ctx->activation);
- if (object && object->hasProperty(name))
- return object->deleteProperty(name);
+ if (object && object->hasProperty(id))
+ return object->deleteProperty(id);
}
break;
}
@@ -194,60 +256,57 @@ bool ExecutionContext::deleteProperty(String *name)
}
}
- return !engine()->currentStackFrame->v4Function->isStrict();
+ return !engine->currentStackFrame->v4Function->isStrict();
}
ExecutionContext::Error ExecutionContext::setProperty(String *name, const Value &value)
{
- name->makeIdentifier();
- Identifier *id = name->identifier();
+ PropertyKey id = name->toPropertyKey();
- QV4::ExecutionEngine *v4 = engine();
Heap::ExecutionContext *ctx = d();
+ QV4::ExecutionEngine *engine = ctx->internalClass->engine;
for (; ctx; ctx = ctx->outer) {
switch (ctx->type) {
- case Heap::ExecutionContext::Type_CatchContext: {
- Heap::CatchContext *c = static_cast<Heap::CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name->d())) {
- c->exceptionValue.set(v4, value);
- return NoError;
- }
- break;
- }
case Heap::ExecutionContext::Type_WithContext: {
- Scope scope(v4);
+ Scope scope(engine);
ScopedObject w(scope, ctx->activation);
- if (w->hasProperty(name)) {
+ if (w->hasProperty(id)) {
+ bool u = ::unscopable(engine, ctx->activation, id);
+ if (engine->hasException)
+ return TypeError;
+ if (u)
+ break;
if (!w->put(name, value))
return TypeError;
return NoError;
}
break;
}
+ case Heap::ExecutionContext::Type_BlockContext:
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx);
- uint index = c->internalClass->find(id);
+ uint index = c->internalClass->indexOfValueOrGetter(id);
if (index < UINT_MAX) {
- static_cast<Heap::CallContext *>(c)->locals.set(v4, index, value);
+ static_cast<Heap::CallContext *>(c)->locals.set(engine, index, value);
return NoError;
}
}
Q_FALLTHROUGH();
case Heap::ExecutionContext::Type_GlobalContext:
if (ctx->activation) {
- uint member = ctx->activation->internalClass->find(id);
- if (member < UINT_MAX) {
- Scope scope(v4);
+ auto member = ctx->activation->internalClass->findValueOrSetter(id);
+ if (member.index < UINT_MAX) {
+ Scope scope(engine);
ScopedObject a(scope, ctx->activation);
- if (!a->putValue(member, value))
+ if (!a->putValue(member.index, member.attrs, value))
return TypeError;
return NoError;
}
}
break;
case Heap::ExecutionContext::Type_QmlContext: {
- Scope scope(v4);
+ Scope scope(engine);
ScopedObject activation(scope, ctx->activation);
if (!activation->put(name, value))
return TypeError;
@@ -262,34 +321,43 @@ ExecutionContext::Error ExecutionContext::setProperty(String *name, const Value
ReturnedValue ExecutionContext::getProperty(String *name)
{
- name->makeIdentifier();
+ PropertyKey id = name->toPropertyKey();
Heap::ExecutionContext *ctx = d();
+ QV4::ExecutionEngine *engine = ctx->internalClass->engine;
+
for (; ctx; ctx = ctx->outer) {
switch (ctx->type) {
- case Heap::ExecutionContext::Type_CatchContext: {
- Heap::CatchContext *c = static_cast<Heap::CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name->d()))
- return c->exceptionValue.asReturnedValue();
- break;
- }
+ case Heap::ExecutionContext::Type_BlockContext:
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx);
- Identifier *id = name->identifier();
- uint index = c->internalClass->find(id);
+ uint index = c->internalClass->indexOfValueOrGetter(id);
if (index < UINT_MAX)
return c->locals[index].asReturnedValue();
Q_FALLTHROUGH();
}
case Heap::ExecutionContext::Type_WithContext:
+ if (ctx->activation) {
+ Scope scope(this);
+ ScopedObject activation(scope, ctx->activation);
+ if (activation->hasProperty(id)) {
+ bool u = ::unscopable(engine, ctx->activation, id);
+ if (engine->hasException)
+ return false;
+ if (u)
+ break;
+ return activation->get(id);
+ }
+ }
+ break;
case Heap::ExecutionContext::Type_GlobalContext:
case Heap::ExecutionContext::Type_QmlContext: {
if (ctx->activation) {
Scope scope(this);
ScopedObject activation(scope, ctx->activation);
bool hasProperty = false;
- ReturnedValue v = activation->get(name, &hasProperty);
+ ReturnedValue v = activation->get(id, nullptr, &hasProperty);
if (hasProperty)
return v;
}
@@ -297,29 +365,24 @@ ReturnedValue ExecutionContext::getProperty(String *name)
}
}
}
- return engine()->throwReferenceError(*name);
+ return engine->throwReferenceError(*name);
}
ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
{
base->setM(nullptr);
- name->makeIdentifier();
+ PropertyKey id = name->toPropertyKey();
Heap::ExecutionContext *ctx = d();
+ QV4::ExecutionEngine *engine = ctx->internalClass->engine;
+
for (; ctx; ctx = ctx->outer) {
switch (ctx->type) {
- case Heap::ExecutionContext::Type_CatchContext: {
- Heap::CatchContext *c = static_cast<Heap::CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name->d()))
- return c->exceptionValue.asReturnedValue();
- break;
- }
+ case Heap::ExecutionContext::Type_BlockContext:
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx);
- name->makeIdentifier();
- Identifier *id = name->identifier();
- uint index = c->internalClass->find(id);
+ uint index = c->internalClass->indexOfValueOrGetter(id);
if (index < UINT_MAX)
return c->locals[index].asReturnedValue();
Q_FALLTHROUGH();
@@ -336,11 +399,25 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
break;
}
case Heap::ExecutionContext::Type_WithContext:
+ if (ctx->activation) {
+ Scope scope(this);
+ ScopedObject activation(scope, ctx->activation);
+ if (activation->hasProperty(id)) {
+ bool u = ::unscopable(engine, ctx->activation, id);
+ if (engine->hasException)
+ return false;
+ if (u)
+ break;
+ base->setM(activation->d());
+ return activation->get(id);
+ }
+ }
+ break;
case Heap::ExecutionContext::Type_QmlContext: {
Scope scope(this);
ScopedObject o(scope, ctx->activation);
bool hasProperty = false;
- ReturnedValue v = o->get(name, &hasProperty);
+ ReturnedValue v = o->get(id, nullptr, &hasProperty);
if (hasProperty) {
base->setM(o->d());
return v;
@@ -349,7 +426,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
}
}
}
- return engine()->throwReferenceError(*name);
+ return engine->throwReferenceError(*name);
}
void Heap::CallContext::setArg(uint index, Value v)
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 512bfa06d8..5cd2f9ddf0 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -55,66 +55,11 @@
QT_BEGIN_NAMESPACE
-class QObject;
-class QQmlContextData;
-
namespace QV4 {
-namespace CompiledData {
-struct CompilationUnitBase;
-struct Function;
-}
-
-struct Function;
-struct Identifier;
-struct CallContext;
-struct CatchContext;
-struct QmlContext;
-struct QQmlContextWrapper;
-
-struct CallData
-{
- enum Offsets {
- Function = 0,
- Context = 1,
- Accumulator = 2,
- This = 3,
- Argc = 4
- };
-
- Value function;
- Value context;
- Value accumulator;
- Value thisObject;
- Value _argc;
-
- int argc() const {
- Q_ASSERT(_argc.isInteger());
- return _argc.int_32();
- }
-
- void setArgc(int argc) {
- Q_ASSERT(argc >= 0);
- _argc.setInt_32(argc);
- }
-
- inline ReturnedValue argument(int i) const {
- return i < argc() ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
- }
-
- Value args[1];
-
- static Q_DECL_CONSTEXPR int HeaderSize() { return offsetof(CallData, args) / sizeof(QV4::Value); }
-};
-
-Q_STATIC_ASSERT(std::is_standard_layout<CallData>::value);
-Q_STATIC_ASSERT(offsetof(CallData, thisObject) == CallData::This*sizeof(Value));
-Q_STATIC_ASSERT(offsetof(CallData, args) == 5*sizeof(Value));
namespace Heap {
-struct QmlContext;
-
#define ExecutionContextMembers(class, Member) \
Member(class, Pointer, ExecutionContext *, outer) \
Member(class, Pointer, Object *, activation)
@@ -124,9 +69,9 @@ DECLARE_HEAP_OBJECT(ExecutionContext, Base) {
enum ContextType {
Type_GlobalContext = 0x1,
- Type_CatchContext = 0x2,
- Type_WithContext = 0x3,
- Type_QmlContext = 0x4,
+ Type_WithContext = 0x2,
+ Type_QmlContext = 0x3,
+ Type_BlockContext = 0x4,
Type_CallContext = 0x5
};
@@ -137,6 +82,10 @@ DECLARE_HEAP_OBJECT(ExecutionContext, Base) {
type = t;
}
+ const VTable *vtable() const {
+ return internalClass->vtable;
+ }
+
quint32 type : 8;
quint32 nArgs : 24;
#if QT_POINTER_SIZE == 8
@@ -169,6 +118,12 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
return locals.data() + locals.size;
}
void setArg(uint index, Value v);
+
+ template <typename BlockOrFunction>
+ void setupLocalTemporalDeadZone(BlockOrFunction *bof) {
+ for (uint i = bof->nLocals - bof->sizeOfLocalTemporalDeadZone; i < bof->nLocals; ++i)
+ locals.values[i] = Value::emptyValue();
+ }
};
Q_STATIC_ASSERT(std::is_trivial< CallContext >::value);
Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value);
@@ -181,16 +136,6 @@ Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0);
//Q_STATIC_ASSERT(sizeof(CallContext) == sizeof(ExecutionContext) + sizeof(CallContextData));
//#endif
-#define CatchContextMembers(class, Member) \
- Member(class, Pointer, String *, exceptionVarName) \
- Member(class, HeapValue, HeapValue, exceptionValue)
-
-DECLARE_HEAP_OBJECT(CatchContext, ExecutionContext) {
- DECLARE_MARKOBJECTS(CatchContext);
-
- void init(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue);
-};
-Q_STATIC_ASSERT(std::is_trivial< CatchContext >::value);
}
@@ -204,9 +149,11 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
Q_MANAGED_TYPE(ExecutionContext)
V4_INTERNALCLASS(ExecutionContext)
+ static Heap::CallContext *newBlockContext(QV4::CppStackFrame *frame, int blockIndex);
+ static Heap::CallContext *cloneBlockContext(Heap::CallContext *context);
static Heap::CallContext *newCallContext(QV4::CppStackFrame *frame);
Heap::ExecutionContext *newWithContext(Heap::Object *with);
- Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue);
+ static Heap::ExecutionContext *newCatchContext(CppStackFrame *frame, int blockIndex, Heap::String *exceptionVarName);
void createMutableBinding(String *name, bool deletable);
@@ -224,6 +171,12 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
inline CallContext *asCallContext();
inline const CallContext *asCallContext() const;
+
+protected:
+ // vtable method required for compilation
+ static bool virtualDeleteProperty(Managed *, PropertyKey) {
+ Q_UNREACHABLE();
+ }
};
struct Q_QML_EXPORT CallContext : public ExecutionContext
@@ -239,11 +192,6 @@ struct Q_QML_EXPORT CallContext : public ExecutionContext
}
};
-struct CatchContext : public ExecutionContext
-{
- V4_MANAGED(CatchContext, ExecutionContext)
-};
-
inline CallContext *ExecutionContext::asCallContext()
{
return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<CallContext *>(this) : nullptr;
diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp
index d894d909ff..5ab8cf2dcb 100644
--- a/src/qml/jsruntime/qv4dataview.cpp
+++ b/src/qml/jsruntime/qv4dataview.cpp
@@ -40,6 +40,7 @@
#include "qv4dataview_p.h"
#include "qv4arraybuffer_p.h"
#include "qv4string_p.h"
+#include "qv4symbol_p.h"
#include <QtCore/private/qnumeric_p.h>
#include "qendian.h"
@@ -54,69 +55,97 @@ void Heap::DataViewCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("DataView"));
}
-ReturnedValue DataViewCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+static uint toIndex(ExecutionEngine *e, const Value &v)
+{
+ if (v.isUndefined())
+ return 0;
+ double index = v.toInteger();
+ if (index < 0) {
+ e->throwRangeError(QStringLiteral("index out of range"));
+ return 0;
+ }
+ uint idx = static_cast<uint>(index);
+ if (idx != index) {
+ e->throwRangeError(QStringLiteral("index out of range"));
+ return 0;
+ }
+ return idx;
+}
+
+ReturnedValue DataViewCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
Scope scope(f->engine());
- Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Primitive::undefinedValue());
- if (!buffer)
+ Scoped<SharedArrayBuffer> buffer(scope, argc ? argv[0] : Value::undefinedValue());
+ if (!newTarget || !buffer)
+ return scope.engine->throwTypeError();
+
+ uint offset = ::toIndex(scope.engine, argc > 1 ? argv[1]: Value::undefinedValue());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (buffer->isDetachedBuffer())
return scope.engine->throwTypeError();
- double bo = argc > 1 ? argv[1].toNumber() : 0;
- uint byteOffset = (uint)bo;
uint bufferLength = buffer->d()->data->size;
- double bl = argc < 3 || argv[2].isUndefined() ? (bufferLength - bo) : argv[2].toNumber();
- uint byteLength = (uint)bl;
- if (bo != byteOffset || bl != byteLength || byteOffset + byteLength > bufferLength)
+ if (offset > bufferLength)
+ return scope.engine->throwRangeError(QStringLiteral("DataView: constructor arguments out of range"));
+
+ uint byteLength = (argc < 3 || argv[2].isUndefined()) ? (bufferLength - offset) : ::toIndex(scope.engine, argv[2]);
+ if (scope.hasException())
+ return Encode::undefined();
+ if (offset + byteLength > bufferLength)
return scope.engine->throwRangeError(QStringLiteral("DataView: constructor arguments out of range"));
- Scoped<DataView> a(scope, scope.engine->memoryManager->allocObject<DataView>());
+ Scoped<DataView> a(scope, scope.engine->memoryManager->allocate<DataView>());
a->d()->buffer.set(scope.engine, buffer->d());
a->d()->byteLength = byteLength;
- a->d()->byteOffset = byteOffset;
+ a->d()->byteOffset = offset;
return a.asReturnedValue();
}
-ReturnedValue DataViewCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue DataViewCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
{
- return callAsConstructor(f, argv, argc);
+ return f->engine()->throwTypeError();
}
void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(3));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, nullptr);
defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, nullptr);
defineAccessorProperty(QStringLiteral("byteOffset"), method_get_byteOffset, nullptr);
- defineDefaultProperty(QStringLiteral("getInt8"), method_getChar<signed char>, 0);
- defineDefaultProperty(QStringLiteral("getUint8"), method_getChar<unsigned char>, 0);
- defineDefaultProperty(QStringLiteral("getInt16"), method_get<short>, 0);
- defineDefaultProperty(QStringLiteral("getUint16"), method_get<unsigned short>, 0);
- defineDefaultProperty(QStringLiteral("getInt32"), method_get<int>, 0);
- defineDefaultProperty(QStringLiteral("getUint32"), method_get<unsigned int>, 0);
- defineDefaultProperty(QStringLiteral("getFloat32"), method_getFloat<float>, 0);
- defineDefaultProperty(QStringLiteral("getFloat64"), method_getFloat<double>, 0);
-
- defineDefaultProperty(QStringLiteral("setInt8"), method_setChar<signed char>, 0);
- defineDefaultProperty(QStringLiteral("setUint8"), method_setChar<unsigned char>, 0);
- defineDefaultProperty(QStringLiteral("setInt16"), method_set<short>, 0);
- defineDefaultProperty(QStringLiteral("setUint16"), method_set<unsigned short>, 0);
- defineDefaultProperty(QStringLiteral("setInt32"), method_set<int>, 0);
- defineDefaultProperty(QStringLiteral("setUint32"), method_set<unsigned int>, 0);
- defineDefaultProperty(QStringLiteral("setFloat32"), method_setFloat<float>, 0);
- defineDefaultProperty(QStringLiteral("setFloat64"), method_setFloat<double>, 0);
+ defineDefaultProperty(QStringLiteral("getInt8"), method_getChar<signed char>, 1);
+ defineDefaultProperty(QStringLiteral("getUint8"), method_getChar<unsigned char>, 1);
+ defineDefaultProperty(QStringLiteral("getInt16"), method_get<short>, 1);
+ defineDefaultProperty(QStringLiteral("getUint16"), method_get<unsigned short>, 1);
+ defineDefaultProperty(QStringLiteral("getInt32"), method_get<int>, 1);
+ defineDefaultProperty(QStringLiteral("getUint32"), method_get<unsigned int>, 1);
+ defineDefaultProperty(QStringLiteral("getFloat32"), method_getFloat<float>, 1);
+ defineDefaultProperty(QStringLiteral("getFloat64"), method_getFloat<double>, 1);
+
+ defineDefaultProperty(QStringLiteral("setInt8"), method_setChar<signed char>, 2);
+ defineDefaultProperty(QStringLiteral("setUint8"), method_setChar<unsigned char>, 2);
+ defineDefaultProperty(QStringLiteral("setInt16"), method_set<short>, 2);
+ defineDefaultProperty(QStringLiteral("setUint16"), method_set<unsigned short>, 2);
+ defineDefaultProperty(QStringLiteral("setInt32"), method_set<int>, 2);
+ defineDefaultProperty(QStringLiteral("setUint32"), method_set<unsigned int>, 2);
+ defineDefaultProperty(QStringLiteral("setFloat32"), method_setFloat<float>, 2);
+ defineDefaultProperty(QStringLiteral("setFloat64"), method_setFloat<double>, 2);
+
+ ScopedString name(scope, engine->newString(QStringLiteral("DataView")));
+ defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);
// For backword compatibility
- defineDefaultProperty(QStringLiteral("getUInt8"), method_getChar<unsigned char>, 0);
- defineDefaultProperty(QStringLiteral("getUInt16"), method_get<unsigned short>, 0);
- defineDefaultProperty(QStringLiteral("getUInt32"), method_get<unsigned int>, 0);
- defineDefaultProperty(QStringLiteral("setUInt8"), method_setChar<unsigned char>, 0);
- defineDefaultProperty(QStringLiteral("setUInt16"), method_set<unsigned short>, 0);
- defineDefaultProperty(QStringLiteral("setUInt32"), method_set<unsigned int>, 0);
+ defineDefaultProperty(QStringLiteral("getUInt8"), method_getChar<unsigned char>, 1);
+ defineDefaultProperty(QStringLiteral("getUInt16"), method_get<unsigned short>, 1);
+ defineDefaultProperty(QStringLiteral("getUInt32"), method_get<unsigned int>, 1);
+ defineDefaultProperty(QStringLiteral("setUInt8"), method_setChar<unsigned char>, 1);
+ defineDefaultProperty(QStringLiteral("setUInt16"), method_set<unsigned short>, 1);
+ defineDefaultProperty(QStringLiteral("setUInt32"), method_set<unsigned int>, 1);
}
ReturnedValue DataViewPrototype::method_get_buffer(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -134,6 +163,9 @@ ReturnedValue DataViewPrototype::method_get_byteLength(const FunctionObject *b,
if (!v)
return b->engine()->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return b->engine()->throwTypeError();
+
return Encode(v->d()->byteLength);
}
@@ -143,19 +175,26 @@ ReturnedValue DataViewPrototype::method_get_byteOffset(const FunctionObject *b,
if (!v)
return b->engine()->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return b->engine()->throwTypeError();
+
return Encode(v->d()->byteOffset);
}
template <typename T>
ReturnedValue DataViewPrototype::method_getChar(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
idx += v->d()->byteOffset;
T t = T(v->d()->buffer->data->data()[idx]);
@@ -166,13 +205,17 @@ ReturnedValue DataViewPrototype::method_getChar(const FunctionObject *b, const V
template <typename T>
ReturnedValue DataViewPrototype::method_get(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
idx += v->d()->byteOffset;
bool littleEndian = argc < 2 ? false : argv[1].toBoolean();
@@ -187,13 +230,17 @@ ReturnedValue DataViewPrototype::method_get(const FunctionObject *b, const Value
template <typename T>
ReturnedValue DataViewPrototype::method_getFloat(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
idx += v->d()->byteOffset;
bool littleEndian = argc < 2 ? false : argv[1].toBoolean();
@@ -224,16 +271,23 @@ ReturnedValue DataViewPrototype::method_getFloat(const FunctionObject *b, const
template <typename T>
ReturnedValue DataViewPrototype::method_setChar(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
- idx += v->d()->byteOffset;
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
int val = argc >= 2 ? argv[1].toInt32() : 0;
+
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
+ idx += v->d()->byteOffset;
+
v->d()->buffer->data->data()[idx] = (char)val;
RETURN_UNDEFINED();
@@ -242,19 +296,25 @@ ReturnedValue DataViewPrototype::method_setChar(const FunctionObject *b, const V
template <typename T>
ReturnedValue DataViewPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
- idx += v->d()->byteOffset;
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
int val = argc >= 2 ? argv[1].toInt32() : 0;
-
bool littleEndian = argc < 3 ? false : argv[2].toBoolean();
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
+ idx += v->d()->byteOffset;
+
+
if (littleEndian)
qToLittleEndian<T>(val, (uchar *)v->d()->buffer->data->data() + idx);
else
@@ -266,18 +326,24 @@ ReturnedValue DataViewPrototype::method_set(const FunctionObject *b, const Value
template <typename T>
ReturnedValue DataViewPrototype::method_setFloat(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ ExecutionEngine *e = b->engine();
const DataView *v = thisObject->as<DataView>();
- if (!v || argc < 1)
- return b->engine()->throwTypeError();
- double l = argv[0].toNumber();
- uint idx = (uint)l;
- if (l != idx || idx + sizeof(T) > v->d()->byteLength)
- return b->engine()->throwTypeError();
- idx += v->d()->byteOffset;
+ if (!v)
+ return e->throwTypeError();
+ uint idx = ::toIndex(e, argc ? argv[0] : Value::undefinedValue());
+ if (e->hasException)
+ return Encode::undefined();
double val = argc >= 2 ? argv[1].toNumber() : qt_qnan();
bool littleEndian = argc < 3 ? false : argv[2].toBoolean();
+ if (v->d()->buffer->isDetachedBuffer())
+ return e->throwTypeError();
+
+ if (idx + sizeof(T) > v->d()->byteLength)
+ return e->throwRangeError(QStringLiteral("index out of range"));
+ idx += v->d()->byteOffset;
+
if (sizeof(T) == 4) {
// float
union {
diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h
index 1e07d85118..199a6f9f80 100644
--- a/src/qml/jsruntime/qv4dataview_p.h
+++ b/src/qml/jsruntime/qv4dataview_p.h
@@ -64,7 +64,7 @@ struct DataViewCtor : FunctionObject {
};
#define DataViewMembers(class, Member) \
- Member(class, Pointer, ArrayBuffer *, buffer) \
+ Member(class, Pointer, SharedArrayBuffer *, buffer) \
Member(class, NoMark, uint, byteLength) \
Member(class, NoMark, uint, byteOffset)
@@ -79,8 +79,8 @@ struct DataViewCtor: FunctionObject
{
V4_OBJECT2(DataViewCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
struct DataView : Object
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 5bbe312146..df3bb37e9c 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -44,6 +44,7 @@
#include "qv4runtime_p.h"
#include "qv4string_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
@@ -89,9 +90,6 @@ static const double msPerMinute = 60000.0;
static const double msPerHour = 3600000.0;
static const double msPerDay = 86400000.0;
-// The current *standard* time offset, regardless of DST:
-static double LocalTZA = 0.0; // initialized at startup
-
static inline double TimeWithinDay(double t)
{
double r = ::fmod(t, msPerDay);
@@ -224,7 +222,7 @@ static inline double MonthFromTime(double t)
static inline double DateFromTime(double t)
{
- int m = (int) Primitive::toInteger(MonthFromTime(t));
+ int m = (int) QV4::Value::toInteger(MonthFromTime(t));
double d = DayWithinYear(t);
double l = InLeapYear(t);
@@ -255,6 +253,12 @@ static inline double WeekDay(double t)
static inline double MakeTime(double hour, double min, double sec, double ms)
{
+ if (!qIsFinite(hour) || !qIsFinite(min) || !qIsFinite(sec) || !qIsFinite(ms))
+ return qQNaN();
+ hour = QV4::Value::toInteger(hour);
+ min = QV4::Value::toInteger(min);
+ sec = QV4::Value::toInteger(sec);
+ ms = QV4::Value::toInteger(ms);
return ((hour * MinutesPerHour + min) * SecondsPerMinute + sec) * msPerSecond + ms;
}
@@ -280,6 +284,12 @@ static inline double DayFromMonth(double month, double leap)
static double MakeDay(double year, double month, double day)
{
+ if (!qIsFinite(year) || !qIsFinite(month) || !qIsFinite(day))
+ return qQNaN();
+ year = QV4::Value::toInteger(year);
+ month = QV4::Value::toInteger(month);
+ day = QV4::Value::toInteger(day);
+
year += ::floor(month / 12.0);
month = ::fmod(month, 12.0);
@@ -318,14 +328,14 @@ static inline double MakeDate(double day, double time)
against the ECMAScript spec is https://github.com/tc39/ecma262/issues/725
*/
-static inline double DaylightSavingTA(double t) // t is a UTC time
+static inline double DaylightSavingTA(double t, double localTZA) // t is a UTC time
{
return QTimeZone::systemTimeZone().offsetFromUtc(
- QDateTime::fromMSecsSinceEpoch(qint64(t), Qt::UTC)) * 1e3 - LocalTZA;
+ QDateTime::fromMSecsSinceEpoch(qint64(t), Qt::UTC)) * 1e3 - localTZA;
}
#else
// This implementation fails to take account of past changes in standard offset.
-static inline double DaylightSavingTA(double t)
+static inline double DaylightSavingTA(double t, double /*localTZA*/)
{
struct tm tmtm;
#if defined(Q_CC_MSVC)
@@ -348,19 +358,19 @@ static inline double DaylightSavingTA(double t)
}
#endif // USE_QTZ_SYSTEM_ZONE
-static inline double LocalTime(double t)
+static inline double LocalTime(double t, double localTZA)
{
// Flawed, yet verbatim from the spec:
- return t + LocalTZA + DaylightSavingTA(t);
+ return t + localTZA + DaylightSavingTA(t, localTZA);
}
// The spec does note [*] that UTC and LocalTime are not quite mutually inverse.
// [*] http://www.ecma-international.org/ecma-262/7.0/index.html#sec-utc-t
-static inline double UTC(double t)
+static inline double UTC(double t, double localTZA)
{
// Flawed, yet verbatim from the spec:
- return t - LocalTZA - DaylightSavingTA(t - LocalTZA);
+ return t - localTZA - DaylightSavingTA(t - localTZA, localTZA);
}
static inline double currentTime()
@@ -374,10 +384,10 @@ static inline double TimeClip(double t)
return qt_qnan();
// +0 looks weird, but is correct. See ES6 20.3.1.15. We must not return -0.
- return Primitive::toInteger(t) + 0;
+ return QV4::Value::toInteger(t) + 0;
}
-static inline double ParseString(const QString &s)
+static inline double ParseString(const QString &s, double localTZA)
{
/*
First, try the format defined in ECMA 262's "Date Time String Format";
@@ -533,9 +543,9 @@ static inline double ParseString(const QString &s)
if (seenZ)
t -= offset * offsetSign * 60 * 1000;
else if (seenT) // No zone specified, treat date-time as local time
- t = UTC(t);
+ t = UTC(t, localTZA);
// else: treat plain date as already in UTC
- return t;
+ return TimeClip(t);
}
QDateTime dt = QDateTime::fromString(s, Qt::TextDate);
@@ -605,7 +615,7 @@ static inline double ParseString(const QString &s)
}
if (!dt.isValid())
return qt_qnan();
- return dt.toMSecsSinceEpoch();
+ return TimeClip(dt.toMSecsSinceEpoch());
}
/*!
@@ -621,12 +631,12 @@ static inline QDateTime ToDateTime(double t, Qt::TimeSpec spec)
return QDateTime::fromMSecsSinceEpoch(t, Qt::UTC).toTimeSpec(spec);
}
-static inline QString ToString(double t)
+static inline QString ToString(double t, double localTZA)
{
if (std::isnan(t))
return QStringLiteral("Invalid Date");
QString str = ToDateTime(t, Qt::LocalTime).toString() + QLatin1String(" GMT");
- double tzoffset = LocalTZA + DaylightSavingTA(t);
+ double tzoffset = localTZA + DaylightSavingTA(t, localTZA);
if (tzoffset) {
int hours = static_cast<int>(::fabs(tzoffset) / 1000 / 60 / 60);
int mins = int(::fabs(tzoffset) / 1000 / 60) % 60;
@@ -705,7 +715,7 @@ DEFINE_OBJECT_VTABLE(DateObject);
void Heap::DateObject::init(const QDateTime &date)
{
Object::init();
- this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan();
+ this->date = date.isValid() ? TimeClip(date.toMSecsSinceEpoch()) : qt_qnan();
}
void Heap::DateObject::init(const QTime &time)
@@ -730,7 +740,7 @@ void Heap::DateObject::init(const QTime &time)
*/
static const double d = MakeDay(1925, 5, 8);
double t = MakeTime(time.hour(), time.minute(), time.second(), time.msec());
- date = TimeClip(UTC(MakeDate(d, t)));
+ date = TimeClip(UTC(MakeDate(d, t), internalClass->engine->localTZA));
}
QDateTime DateObject::toQDateTime() const
@@ -745,15 +755,16 @@ void Heap::DateCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Date"));
}
-ReturnedValue DateCtor::callAsConstructor(const FunctionObject *that, const Value *argv, int argc)
+ReturnedValue DateCtor::virtualCallAsConstructor(const FunctionObject *that, const Value *argv, int argc, const Value *)
{
+ ExecutionEngine *e = that->engine();
double t = 0;
if (argc == 0)
t = currentTime();
else if (argc == 1) {
- Scope scope(that->engine());
+ Scope scope(e);
ScopedValue arg(scope, argv[0]);
if (DateObject *d = arg->as<DateObject>()) {
t = d->date();
@@ -761,7 +772,7 @@ ReturnedValue DateCtor::callAsConstructor(const FunctionObject *that, const Valu
arg = RuntimeHelpers::toPrimitive(arg, PREFERREDTYPE_HINT);
if (String *s = arg->stringValue())
- t = ParseString(s->toQString());
+ t = ParseString(s->toQString(), e->localTZA);
else
t = TimeClip(arg->toNumber());
}
@@ -778,16 +789,17 @@ ReturnedValue DateCtor::callAsConstructor(const FunctionObject *that, const Valu
if (year >= 0 && year <= 99)
year += 1900;
t = MakeDate(MakeDay(year, month, day), MakeTime(hours, mins, secs, ms));
- t = TimeClip(UTC(t));
+ t = TimeClip(UTC(t, e->localTZA));
}
- return Encode(that->engine()->newDateObject(Primitive::fromDouble(t)));
+ return Encode(e->newDateObject(Value::fromDouble(t)));
}
-ReturnedValue DateCtor::call(const FunctionObject *m, const Value *, const Value *, int)
+ReturnedValue DateCtor::virtualCall(const FunctionObject *m, const Value *, const Value *, int)
{
+ ExecutionEngine *e = m->engine();
double t = currentTime();
- return m->engine()->newString(ToString(t))->asReturnedValue();
+ return e->newString(ToString(t, e->localTZA))->asReturnedValue();
}
void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
@@ -795,8 +807,8 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(7));
- LocalTZA = getLocalTZA();
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(7));
+ engine->localTZA = getLocalTZA();
ctor->defineDefaultProperty(QStringLiteral("parse"), method_parse, 1);
ctor->defineDefaultProperty(QStringLiteral("UTC"), method_UTC, 7);
@@ -806,7 +818,7 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("toDateString"), method_toDateString, 0);
defineDefaultProperty(QStringLiteral("toTimeString"), method_toTimeString, 0);
- defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
+ defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("toLocaleDateString"), method_toLocaleDateString, 0);
defineDefaultProperty(QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString, 0);
defineDefaultProperty(engine->id_valueOf(), method_valueOf, 0);
@@ -853,15 +865,14 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
QString toGmtString(QStringLiteral("toGMTString"));
ScopedString us(scope, engine->newIdentifier(toUtcString));
ScopedString gs(scope, engine->newIdentifier(toGmtString));
- ExecutionContext *global = engine->rootContext();
- ScopedFunctionObject toUtcGmtStringFn(scope, FunctionObject::createBuiltinFunction(global, us, method_toUTCString));
- toUtcGmtStringFn->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ ScopedFunctionObject toUtcGmtStringFn(scope, FunctionObject::createBuiltinFunction(engine, us, method_toUTCString, 0));
defineDefaultProperty(us, toUtcGmtStringFn);
defineDefaultProperty(gs, toUtcGmtStringFn);
}
defineDefaultProperty(QStringLiteral("toISOString"), method_toISOString, 0);
defineDefaultProperty(QStringLiteral("toJSON"), method_toJSON, 1);
+ defineDefaultProperty(engine->symbol_toPrimitive(), method_symbolToPrimitive, 1, Attr_ReadOnly_ButConfigurable);
}
double DatePrototype::getThisDate(ExecutionEngine *v4, const Value *thisObject)
@@ -872,32 +883,47 @@ double DatePrototype::getThisDate(ExecutionEngine *v4, const Value *thisObject)
return 0;
}
-ReturnedValue DatePrototype::method_parse(const FunctionObject *, const Value *, const Value *argv, int argc)
+ReturnedValue DatePrototype::method_parse(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
if (!argc)
return Encode(qt_qnan());
else
- return Encode(ParseString(argv[0].toQString()));
+ return Encode(ParseString(argv[0].toQString(), f->engine()->localTZA));
}
-ReturnedValue DatePrototype::method_UTC(const FunctionObject *, const Value *, const Value *argv, int argc)
+ReturnedValue DatePrototype::method_UTC(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
const int numArgs = argc;
- if (numArgs >= 2) {
- double year = argv[0].toNumber();
- double month = argv[1].toNumber();
- double day = numArgs >= 3 ? argv[2].toNumber() : 1;
- double hours = numArgs >= 4 ? argv[3].toNumber() : 0;
- double mins = numArgs >= 5 ? argv[4].toNumber() : 0;
- double secs = numArgs >= 6 ? argv[5].toNumber() : 0;
- double ms = numArgs >= 7 ? argv[6].toNumber() : 0;
- if (year >= 0 && year <= 99)
- year += 1900;
- double t = MakeDate(MakeDay(year, month, day),
- MakeTime(hours, mins, secs, ms));
- return Encode(TimeClip(t));
- }
- RETURN_UNDEFINED();
+ if (numArgs < 1)
+ return Encode(qQNaN());
+ ExecutionEngine *e = f->engine();
+ double year = argv[0].toNumber();
+ if (e->hasException)
+ return Encode::undefined();
+ double month = numArgs >= 2 ? argv[1].toNumber() : 0;
+ if (e->hasException)
+ return Encode::undefined();
+ double day = numArgs >= 3 ? argv[2].toNumber() : 1;
+ if (e->hasException)
+ return Encode::undefined();
+ double hours = numArgs >= 4 ? argv[3].toNumber() : 0;
+ if (e->hasException)
+ return Encode::undefined();
+ double mins = numArgs >= 5 ? argv[4].toNumber() : 0;
+ if (e->hasException)
+ return Encode::undefined();
+ double secs = numArgs >= 6 ? argv[5].toNumber() : 0;
+ if (e->hasException)
+ return Encode::undefined();
+ double ms = numArgs >= 7 ? argv[6].toNumber() : 0;
+ if (e->hasException)
+ return Encode::undefined();
+ double iyear = QV4::Value::toInteger(year);
+ if (!qIsNaN(year) && iyear >= 0 && iyear <= 99)
+ year = 1900 + iyear;
+ double t = MakeDate(MakeDay(year, month, day),
+ MakeTime(hours, mins, secs, ms));
+ return Encode(TimeClip(t));
}
ReturnedValue DatePrototype::method_now(const FunctionObject *, const Value *, const Value *, int)
@@ -909,7 +935,7 @@ ReturnedValue DatePrototype::method_toString(const FunctionObject *b, const Valu
{
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
- return Encode(v4->newString(ToString(t)));
+ return Encode(v4->newString(ToString(t, v4->localTZA)));
}
ReturnedValue DatePrototype::method_toDateString(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -966,7 +992,7 @@ ReturnedValue DatePrototype::method_getYear(const FunctionObject *b, const Value
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = YearFromTime(LocalTime(t)) - 1900;
+ t = YearFromTime(LocalTime(t, v4->localTZA)) - 1900;
return Encode(t);
}
@@ -975,7 +1001,7 @@ ReturnedValue DatePrototype::method_getFullYear(const FunctionObject *b, const V
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = YearFromTime(LocalTime(t));
+ t = YearFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -993,7 +1019,7 @@ ReturnedValue DatePrototype::method_getMonth(const FunctionObject *b, const Valu
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = MonthFromTime(LocalTime(t));
+ t = MonthFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1011,7 +1037,7 @@ ReturnedValue DatePrototype::method_getDate(const FunctionObject *b, const Value
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = DateFromTime(LocalTime(t));
+ t = DateFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1029,7 +1055,7 @@ ReturnedValue DatePrototype::method_getDay(const FunctionObject *b, const Value
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = WeekDay(LocalTime(t));
+ t = WeekDay(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1047,7 +1073,7 @@ ReturnedValue DatePrototype::method_getHours(const FunctionObject *b, const Valu
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = HourFromTime(LocalTime(t));
+ t = HourFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1065,7 +1091,7 @@ ReturnedValue DatePrototype::method_getMinutes(const FunctionObject *b, const Va
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = MinFromTime(LocalTime(t));
+ t = MinFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1083,7 +1109,7 @@ ReturnedValue DatePrototype::method_getSeconds(const FunctionObject *b, const Va
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = SecFromTime(LocalTime(t));
+ t = SecFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1101,7 +1127,7 @@ ReturnedValue DatePrototype::method_getMilliseconds(const FunctionObject *b, con
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = msFromTime(LocalTime(t));
+ t = msFromTime(LocalTime(t, v4->localTZA));
return Encode(t);
}
@@ -1119,7 +1145,7 @@ ReturnedValue DatePrototype::method_getTimezoneOffset(const FunctionObject *b, c
ExecutionEngine *v4 = b->engine();
double t = getThisDate(v4, thisObject);
if (!std::isnan(t))
- t = (t - LocalTime(t)) / msPerMinute;
+ t = (t - LocalTime(t, v4->localTZA)) / msPerMinute;
return Encode(t);
}
@@ -1144,13 +1170,13 @@ ReturnedValue DatePrototype::method_setMilliseconds(const FunctionObject *b, con
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double ms = argc ? argv[0].toNumber() : qt_qnan();
if (v4->hasException)
return QV4::Encode::undefined();
- self->setDate(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
+ self->setDate(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)), v4->localTZA)));
return Encode(self->date());
}
@@ -1178,7 +1204,7 @@ ReturnedValue DatePrototype::method_setSeconds(const FunctionObject *b, const Va
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double sec = argc ? argv[0].toNumber() : qt_qnan();
@@ -1187,7 +1213,7 @@ ReturnedValue DatePrototype::method_setSeconds(const FunctionObject *b, const Va
double ms = (argc < 2) ? msFromTime(t) : argv[1].toNumber();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
+ t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1214,7 +1240,7 @@ ReturnedValue DatePrototype::method_setMinutes(const FunctionObject *b, const Va
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double min = argc ? argv[0].toNumber() : qt_qnan();
@@ -1226,7 +1252,7 @@ ReturnedValue DatePrototype::method_setMinutes(const FunctionObject *b, const Va
double ms = (argc < 3) ? msFromTime(t) : argv[2].toNumber();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
+ t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1254,7 +1280,7 @@ ReturnedValue DatePrototype::method_setHours(const FunctionObject *b, const Valu
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double hour = argc ? argv[0].toNumber() : qt_qnan();
@@ -1269,7 +1295,7 @@ ReturnedValue DatePrototype::method_setHours(const FunctionObject *b, const Valu
double ms = (argc < 4) ? msFromTime(t) : argv[3].toNumber();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
+ t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1298,13 +1324,13 @@ ReturnedValue DatePrototype::method_setDate(const FunctionObject *b, const Value
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double date = argc ? argv[0].toNumber() : qt_qnan();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
+ t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1334,7 +1360,7 @@ ReturnedValue DatePrototype::method_setMonth(const FunctionObject *b, const Valu
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
double month = argc ? argv[0].toNumber() : qt_qnan();
@@ -1343,7 +1369,7 @@ ReturnedValue DatePrototype::method_setMonth(const FunctionObject *b, const Valu
double date = (argc < 2) ? DateFromTime(t) : argv[1].toNumber();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
+ t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1374,16 +1400,16 @@ ReturnedValue DatePrototype::method_setYear(const FunctionObject *b, const Value
if (std::isnan(t))
t = 0;
else
- t = LocalTime(t);
+ t = LocalTime(t, v4->localTZA);
double year = argc ? argv[0].toNumber() : qt_qnan();
double r;
if (std::isnan(year)) {
r = qt_qnan();
} else {
- if ((Primitive::toInteger(year) >= 0) && (Primitive::toInteger(year) <= 99))
+ if ((QV4::Value::toInteger(year) >= 0) && (QV4::Value::toInteger(year) <= 99))
year += 1900;
r = MakeDay(year, MonthFromTime(t), DateFromTime(t));
- r = UTC(MakeDate(r, TimeWithinDay(t)));
+ r = UTC(MakeDate(r, TimeWithinDay(t)), v4->localTZA);
r = TimeClip(r);
}
self->setDate(r);
@@ -1413,7 +1439,7 @@ ReturnedValue DatePrototype::method_setFullYear(const FunctionObject *b, const V
if (!self)
return v4->throwTypeError();
- double t = LocalTime(self->date());
+ double t = LocalTime(self->date(), v4->localTZA);
if (v4->hasException)
return QV4::Encode::undefined();
if (std::isnan(t))
@@ -1427,7 +1453,7 @@ ReturnedValue DatePrototype::method_setFullYear(const FunctionObject *b, const V
double date = (argc < 3) ? DateFromTime(t) : argv[2].toNumber();
if (v4->hasException)
return QV4::Encode::undefined();
- t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
+ t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)), v4->localTZA));
self->setDate(t);
return Encode(self->date());
}
@@ -1471,7 +1497,7 @@ ReturnedValue DatePrototype::method_toISOString(const FunctionObject *b, const V
int year = (int)YearFromTime(t);
if (year < 0 || year > 9999) {
if (qAbs(year) >= 1000000)
- RETURN_RESULT(v4->newString(QStringLiteral("Invalid Date")));
+ RETURN_RESULT(v4->throwRangeError(*thisObject));
result += year < 0 ? QLatin1Char('-') : QLatin1Char('+');
year = qAbs(year);
addZeroPrefixedInt(result, year, 6);
@@ -1518,7 +1544,23 @@ ReturnedValue DatePrototype::method_toJSON(const FunctionObject *b, const Value
return toIso->call(O, nullptr, 0);
}
-void DatePrototype::timezoneUpdated()
+ReturnedValue DatePrototype::method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *e = f->engine();
+ if (!thisObject->isObject() || !argc || !argv->isString())
+ return e->throwTypeError();
+
+ String *hint = argv->stringValue();
+ PropertyKey id = hint->toPropertyKey();
+ if (id == e->id_default()->propertyKey())
+ hint = e->id_string();
+ else if (id != e->id_string()->propertyKey() && id != e->id_number()->propertyKey())
+ return e->throwTypeError();
+
+ return RuntimeHelpers::ordinaryToPrimitive(e, static_cast<const Object *>(thisObject), hint);
+}
+
+void DatePrototype::timezoneUpdated(ExecutionEngine *e)
{
- LocalTZA = getLocalTZA();
+ e->localTZA = getLocalTZA();
}
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h
index 2b9a580288..5b9934282c 100644
--- a/src/qml/jsruntime/qv4dateobject_p.h
+++ b/src/qml/jsruntime/qv4dateobject_p.h
@@ -101,15 +101,15 @@ struct DateObject: Object {
template<>
inline const DateObject *Value::as() const {
- return isManaged() && m()->vtable()->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : nullptr;
+ return isManaged() && m()->internalClass->vtable->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : nullptr;
}
struct DateCtor: FunctionObject
{
V4_OBJECT2(DateCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int);
};
struct DatePrototype: Object
@@ -169,8 +169,9 @@ struct DatePrototype: Object
static ReturnedValue method_toUTCString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toISOString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toJSON(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *, int);
- static void timezoneUpdated();
+ static void timezoneUpdated(ExecutionEngine *e);
};
}
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 0ed0df89a9..8f64c84eae 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -37,11 +37,30 @@
**
****************************************************************************/
#include <qv4engine_p.h>
+
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljsast_p.h>
+#include <private/qv4compileddata_p.h>
+#include <private/qv4compiler_p.h>
+#include <private/qv4compilercontext_p.h>
+#include <private/qv4codegen_p.h>
+
+#include <QtCore/QTextStream>
+#include <QDateTime>
+#include <QDir>
+#include <QFileInfo>
+
+#ifndef V4_BOOTSTRAP
+
#include <qv4qmlcontext_p.h>
#include <qv4value_p.h>
#include <qv4object_p.h>
#include <qv4objectproto_p.h>
#include <qv4objectiterator_p.h>
+#include <qv4setiterator_p.h>
+#include <qv4mapiterator_p.h>
+#include <qv4arrayiterator_p.h>
#include <qv4arrayobject_p.h>
#include <qv4booleanobject_p.h>
#include <qv4globalobject_p.h>
@@ -52,6 +71,9 @@
#include <qv4numberobject_p.h>
#include <qv4regexpobject_p.h>
#include <qv4regexp_p.h>
+#include "qv4symbol_p.h"
+#include "qv4setobject_p.h"
+#include "qv4mapobject_p.h"
#include <qv4variantobject_p.h>
#include <qv4runtime_p.h>
#include <private/qv4mm_p.h>
@@ -63,7 +85,18 @@
#include "qv4debugging_p.h"
#include "qv4profiling_p.h"
#include "qv4executableallocator_p.h"
+#include "qv4iterator_p.h"
+#include "qv4stringiterator_p.h"
+#include "qv4generatorobject_p.h"
+#include "qv4reflect_p.h"
+#include "qv4proxy_p.h"
+#include "qv4stackframe_p.h"
+#include "qv4atomics_p.h"
+
+#if QT_CONFIG(qml_sequence_object)
#include "qv4sequenceobject_p.h"
+#endif
+
#include "qv4qobjectwrapper_p.h"
#include "qv4memberdata_p.h"
#include "qv4arraybuffer_p.h"
@@ -76,10 +109,11 @@
#include <private/qqmlvaluetype_p.h>
#include <private/qqmllistwrapper_p.h>
#include <private/qqmllist_p.h>
+#include <private/qqmltypeloader_p.h>
+#if QT_CONFIG(qml_locale)
#include <private/qqmllocale_p.h>
-
-#include <QtCore/QTextStream>
-#include <QDateTime>
+#endif
+#include <qqmlfile.h>
#if USE(PTHREADS)
# include <pthread.h>
@@ -95,10 +129,14 @@
#include <valgrind/memcheck.h>
#endif
+#endif // #ifndef V4_BOOTSTRAP
+
QT_BEGIN_NAMESPACE
using namespace QV4;
+#ifndef V4_BOOTSTRAP
+
static QBasicAtomicInt engineSerial = Q_BASIC_ATOMIC_INITIALIZER(1);
ReturnedValue throwTypeError(const FunctionObject *b, const QV4::Value *, const QV4::Value *, int)
@@ -106,22 +144,9 @@ ReturnedValue throwTypeError(const FunctionObject *b, const QV4::Value *, const
return b->engine()->throwTypeError();
}
-
-#ifdef V4_BOOTSTRAP
-QJSEngine *ExecutionEngine::jsEngine() const
-{
- return v8Engine->publicEngine();
-}
-
-QQmlEngine *ExecutionEngine::qmlEngine() const
-{
- return v8Engine->engine();
-}
-#endif // V4_BOOTSTRAP
-
qint32 ExecutionEngine::maxCallDepth = -1;
-ExecutionEngine::ExecutionEngine()
+ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
: executableAllocator(new QV4::ExecutableAllocator)
, regExpAllocator(new QV4::ExecutableAllocator)
, bumperPointerAllocator(new WTF::BumpPointerAllocator)
@@ -129,8 +154,7 @@ ExecutionEngine::ExecutionEngine()
, gcStack(new WTF::PageAllocation)
, globalCode(nullptr)
, v8Engine(nullptr)
- , argumentsAccessors(nullptr)
- , nArgumentsAccessors(0)
+ , publicEngine(jsEngine)
, m_engineId(engineSerial.fetchAndAddOrdered(1))
, regExpCache(nullptr)
, m_multiplyWrappedQObjects(nullptr)
@@ -181,27 +205,44 @@ ExecutionEngine::ExecutionEngine()
}
exceptionValue = jsAlloca(1);
+ *exceptionValue = Encode::undefined();
globalObject = static_cast<Object *>(jsAlloca(1));
jsObjects = jsAlloca(NJSObjects);
typedArrayPrototype = static_cast<Object *>(jsAlloca(NTypedArrayTypes));
typedArrayCtors = static_cast<FunctionObject *>(jsAlloca(NTypedArrayTypes));
jsStrings = jsAlloca(NJSStrings);
+ jsSymbols = jsAlloca(NJSSymbols);
// set up stack limits
jsStackLimit = jsStackBase + JSStackLimit/sizeof(Value);
identifierTable = new IdentifierTable(this);
- classPool = new InternalClassPool;
+ memset(classes, 0, sizeof(classes));
+ classes[Class_Empty] = memoryManager->allocIC<InternalClass>();
+ classes[Class_Empty]->init(this);
+
+ classes[Class_MemberData] = classes[Class_Empty]->changeVTable(QV4::MemberData::staticVTable());
+ classes[Class_SimpleArrayData] = classes[Class_Empty]->changeVTable(QV4::SimpleArrayData::staticVTable());
+ classes[Class_SparseArrayData] = classes[Class_Empty]->changeVTable(QV4::SparseArrayData::staticVTable());
+ classes[Class_ExecutionContext] = classes[Class_Empty]->changeVTable(QV4::ExecutionContext::staticVTable());
+ classes[Class_CallContext] = classes[Class_Empty]->changeVTable(QV4::CallContext::staticVTable());
+ classes[Class_QmlContext] = classes[Class_Empty]->changeVTable(QV4::QmlContext::staticVTable());
+
+ Scope scope(this);
+ Scoped<InternalClass> ic(scope);
+ ic = classes[Class_Empty]->changeVTable(QV4::Object::staticVTable());
+ jsObjects[ObjectProto] = memoryManager->allocObject<ObjectPrototype>(ic->d());
+ classes[Class_Object] = ic->changePrototype(objectPrototype()->d());
+ classes[Class_QmlContextWrapper] = classes[Class_Object]->changeVTable(QV4::QQmlContextWrapper::staticVTable());
+
+ ic = newInternalClass(QV4::StringObject::staticVTable(), objectPrototype());
+ jsObjects[StringProto] = memoryManager->allocObject<StringPrototype>(ic->d(), /*init =*/ false);
+ classes[Class_String] = classes[Class_Empty]->changeVTable(QV4::String::staticVTable())->changePrototype(stringPrototype()->d());
+ Q_ASSERT(stringPrototype()->d() && classes[Class_String]->prototype);
- internalClasses[Class_Empty] = new (classPool) InternalClass(this);
- internalClasses[Class_String] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::String::staticVTable());
- internalClasses[Class_MemberData] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::MemberData::staticVTable());
- internalClasses[Class_SimpleArrayData] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::SimpleArrayData::staticVTable());
- internalClasses[Class_SparseArrayData] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::SparseArrayData::staticVTable());
- internalClasses[Class_ExecutionContext] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::ExecutionContext::staticVTable());
- internalClasses[Class_QmlContext] = internalClasses[EngineBase::Class_ExecutionContext]->changeVTable(QV4::QmlContext::staticVTable());
- internalClasses[Class_CallContext] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::CallContext::staticVTable());
+ jsObjects[SymbolProto] = memoryManager->allocate<SymbolPrototype>();
+ classes[Class_Symbol] = classes[EngineBase::Class_Empty]->changeVTable(QV4::Symbol::staticVTable())->changePrototype(symbolPrototype()->d());
jsStrings[String_Empty] = newIdentifier(QString());
jsStrings[String_undefined] = newIdentifier(QStringLiteral("undefined"));
@@ -211,6 +252,8 @@ ExecutionEngine::ExecutionEngine()
jsStrings[String_boolean] = newIdentifier(QStringLiteral("boolean"));
jsStrings[String_number] = newIdentifier(QStringLiteral("number"));
jsStrings[String_string] = newIdentifier(QStringLiteral("string"));
+ jsStrings[String_default] = newIdentifier(QStringLiteral("default"));
+ jsStrings[String_symbol] = newIdentifier(QStringLiteral("symbol"));
jsStrings[String_object] = newIdentifier(QStringLiteral("object"));
jsStrings[String_function] = newIdentifier(QStringLiteral("function"));
jsStrings[String_length] = newIdentifier(QStringLiteral("length"));
@@ -233,147 +276,212 @@ ExecutionEngine::ExecutionEngine()
jsStrings[String_index] = newIdentifier(QStringLiteral("index"));
jsStrings[String_input] = newIdentifier(QStringLiteral("input"));
jsStrings[String_toString] = newIdentifier(QStringLiteral("toString"));
+ jsStrings[String_toLocaleString] = newIdentifier(QStringLiteral("toLocaleString"));
jsStrings[String_destroy] = newIdentifier(QStringLiteral("destroy"));
jsStrings[String_valueOf] = newIdentifier(QStringLiteral("valueOf"));
jsStrings[String_byteLength] = newIdentifier(QStringLiteral("byteLength"));
jsStrings[String_byteOffset] = newIdentifier(QStringLiteral("byteOffset"));
jsStrings[String_buffer] = newIdentifier(QStringLiteral("buffer"));
jsStrings[String_lastIndex] = newIdentifier(QStringLiteral("lastIndex"));
-
- InternalClass *ic = internalClasses[Class_Empty]->changeVTable(QV4::Object::staticVTable());
- jsObjects[ObjectProto] = memoryManager->allocObject<ObjectPrototype>(ic);
- internalClasses[Class_Object] = ic->changePrototype(objectPrototype()->d());
- internalClasses[EngineBase::Class_QmlContextWrapper] = internalClasses[Class_Object]->changeVTable(QV4::QQmlContextWrapper::staticVTable());
+ jsStrings[String_next] = newIdentifier(QStringLiteral("next"));
+ jsStrings[String_done] = newIdentifier(QStringLiteral("done"));
+ jsStrings[String_return] = newIdentifier(QStringLiteral("return"));
+ jsStrings[String_throw] = newIdentifier(QStringLiteral("throw"));
+ jsStrings[String_global] = newIdentifier(QStringLiteral("global"));
+ jsStrings[String_ignoreCase] = newIdentifier(QStringLiteral("ignoreCase"));
+ jsStrings[String_multiline] = newIdentifier(QStringLiteral("multiline"));
+ jsStrings[String_unicode] = newIdentifier(QStringLiteral("unicode"));
+ jsStrings[String_sticky] = newIdentifier(QStringLiteral("sticky"));
+ jsStrings[String_source] = newIdentifier(QStringLiteral("source"));
+ jsStrings[String_flags] = newIdentifier(QStringLiteral("flags"));
+
+ jsSymbols[Symbol_hasInstance] = Symbol::create(this, QStringLiteral("@Symbol.hasInstance"));
+ jsSymbols[Symbol_isConcatSpreadable] = Symbol::create(this, QStringLiteral("@Symbol.isConcatSpreadable"));
+ jsSymbols[Symbol_iterator] = Symbol::create(this, QStringLiteral("@Symbol.iterator"));
+ jsSymbols[Symbol_match] = Symbol::create(this, QStringLiteral("@Symbol.match"));
+ jsSymbols[Symbol_replace] = Symbol::create(this, QStringLiteral("@Symbol.replace"));
+ jsSymbols[Symbol_search] = Symbol::create(this, QStringLiteral("@Symbol.search"));
+ jsSymbols[Symbol_species] = Symbol::create(this, QStringLiteral("@Symbol.species"));
+ jsSymbols[Symbol_split] = Symbol::create(this, QStringLiteral("@Symbol.split"));
+ jsSymbols[Symbol_toPrimitive] = Symbol::create(this, QStringLiteral("@Symbol.toPrimitive"));
+ jsSymbols[Symbol_toStringTag] = Symbol::create(this, QStringLiteral("@Symbol.toStringTag"));
+ jsSymbols[Symbol_unscopables] = Symbol::create(this, QStringLiteral("@Symbol.unscopables"));
+ jsSymbols[Symbol_revokableProxy] = Symbol::create(this, QStringLiteral("@Proxy.revokableProxy"));
ic = newInternalClass(ArrayPrototype::staticVTable(), objectPrototype());
- Q_ASSERT(ic->prototype);
- ic = ic->addMember(id_length(), Attr_NotConfigurable|Attr_NotEnumerable);
- Q_ASSERT(ic->prototype);
- jsObjects[ArrayProto] = memoryManager->allocObject<ArrayPrototype>(ic, objectPrototype());
- internalClasses[Class_ArrayObject] = ic->changePrototype(arrayPrototype()->d());
- jsObjects[PropertyListProto] = memoryManager->allocObject<PropertyListPrototype>();
-
- InternalClass *argsClass = newInternalClass(ArgumentsObject::staticVTable(), objectPrototype());
- argsClass = argsClass->addMember(id_length(), Attr_NotEnumerable);
- internalClasses[EngineBase::Class_ArgumentsObject] = argsClass->addMember(id_callee(), Attr_Data|Attr_NotEnumerable);
+ Q_ASSERT(ic->d()->prototype);
+ ic = ic->addMember(id_length()->propertyKey(), Attr_NotConfigurable|Attr_NotEnumerable);
+ Q_ASSERT(ic->d()->prototype);
+ jsObjects[ArrayProto] = memoryManager->allocObject<ArrayPrototype>(ic->d());
+ classes[Class_ArrayObject] = ic->changePrototype(arrayPrototype()->d());
+ jsObjects[PropertyListProto] = memoryManager->allocate<PropertyListPrototype>();
+
+ Scoped<InternalClass> argsClass(scope);
+ argsClass = newInternalClass(ArgumentsObject::staticVTable(), objectPrototype());
+ argsClass = argsClass->addMember(id_length()->propertyKey(), Attr_NotEnumerable);
+ argsClass = argsClass->addMember(symbol_iterator()->propertyKey(), Attr_Data|Attr_NotEnumerable);
+ classes[Class_ArgumentsObject] = argsClass->addMember(id_callee()->propertyKey(), Attr_Data|Attr_NotEnumerable);
argsClass = newInternalClass(StrictArgumentsObject::staticVTable(), objectPrototype());
- argsClass = argsClass->addMember(id_length(), Attr_NotEnumerable);
- argsClass = argsClass->addMember(id_callee(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- internalClasses[EngineBase::Class_StrictArgumentsObject] = argsClass->addMember(id_caller(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ argsClass = argsClass->addMember(id_length()->propertyKey(), Attr_NotEnumerable);
+ argsClass = argsClass->addMember(symbol_iterator()->propertyKey(), Attr_Data|Attr_NotEnumerable);
+ classes[Class_StrictArgumentsObject] = argsClass->addMember(id_callee()->propertyKey(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
*static_cast<Value *>(globalObject) = newObject();
Q_ASSERT(globalObject->d()->vtable());
initRootContext();
ic = newInternalClass(QV4::StringObject::staticVTable(), objectPrototype());
- ic = ic->addMember(id_length(), Attr_ReadOnly);
- jsObjects[StringProto] = memoryManager->allocObject<StringPrototype>(ic);
- internalClasses[Class_StringObject] = ic->changePrototype(stringPrototype()->d());
- Q_ASSERT(internalClasses[EngineBase::Class_StringObject]->find(id_length()) == Heap::StringObject::LengthPropertyIndex);
+ ic = ic->addMember(id_length()->propertyKey(), Attr_ReadOnly);
+ classes[Class_StringObject] = ic->changePrototype(stringPrototype()->d());
+ Q_ASSERT(classes[Class_StringObject]->verifyIndex(id_length()->propertyKey(), Heap::StringObject::LengthPropertyIndex));
- jsObjects[NumberProto] = memoryManager->allocObject<NumberPrototype>();
- jsObjects[BooleanProto] = memoryManager->allocObject<BooleanPrototype>();
- jsObjects[DateProto] = memoryManager->allocObject<DatePrototype>();
+ classes[Class_SymbolObject] = newInternalClass(QV4::SymbolObject::staticVTable(), symbolPrototype());
- uint index;
+ jsObjects[NumberProto] = memoryManager->allocate<NumberPrototype>();
+ jsObjects[BooleanProto] = memoryManager->allocate<BooleanPrototype>();
+ jsObjects[DateProto] = memoryManager->allocate<DatePrototype>();
+
+#ifdef QT_NO_DEBUG
+ InternalClassEntry *index = nullptr;
+#else
+ InternalClassEntry _index;
+ auto *index = &_index;
+#endif
ic = newInternalClass(QV4::FunctionPrototype::staticVTable(), objectPrototype());
- ic = ic->addMember(id_prototype(), Attr_NotEnumerable, &index);
- Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
- jsObjects[FunctionProto] = memoryManager->allocObject<FunctionPrototype>(ic, objectPrototype());
+ auto addProtoHasInstance = [&] {
+ // Add an invalid prototype slot, so that all function objects have the same layout
+ // This helps speed up instanceof operations and other things where we need to query
+ // prototype property (as we always know it's location)
+ ic = ic->addMember(id_prototype()->propertyKey(), Attr_Invalid, index);
+ Q_ASSERT(index->index == Heap::FunctionObject::Index_Prototype);
+ // add an invalid @hasInstance slot, so that we can quickly track whether the
+ // hasInstance method has been reimplemented. This is required for a fast
+ // instanceof implementation
+ ic = ic->addMember(symbol_hasInstance()->propertyKey(), Attr_Invalid, index);
+ Q_ASSERT(index->index == Heap::FunctionObject::Index_HasInstance);
+ };
+ addProtoHasInstance();
+ jsObjects[FunctionProto] = memoryManager->allocObject<FunctionPrototype>(ic->d());
ic = newInternalClass(FunctionObject::staticVTable(), functionPrototype());
- ic = ic->addMember(id_prototype(), Attr_NotEnumerable|Attr_NotConfigurable, &index);
- Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
- internalClasses[EngineBase::Class_FunctionObject] = ic;
- ic = ic->addMember(id_name(), Attr_ReadOnly, &index);
- Q_ASSERT(index == Heap::ScriptFunction::Index_Name);
+ addProtoHasInstance();
+ classes[Class_FunctionObject] = ic->d();
+ ic = ic->addMember(id_name()->propertyKey(), Attr_ReadOnly, index);
+ Q_ASSERT(index->index == Heap::ArrowFunction::Index_Name);
+ ic = ic->addMember(id_length()->propertyKey(), Attr_ReadOnly_ButConfigurable, index);
+ Q_ASSERT(index->index == Heap::ArrowFunction::Index_Length);
+ classes[Class_ArrowFunction] = ic->changeVTable(ArrowFunction::staticVTable());
+ ic = ic->changeVTable(MemberFunction::staticVTable());
+ classes[Class_MemberFunction] = ic->d();
+ ic = ic->changeVTable(GeneratorFunction::staticVTable());
+ classes[Class_GeneratorFunction] = ic->d();
+ ic = ic->changeVTable(MemberGeneratorFunction::staticVTable());
+ classes[Class_MemberGeneratorFunction] = ic->d();
+
+ ic = ic->changeMember(id_prototype()->propertyKey(), Attr_NotConfigurable|Attr_NotEnumerable);
ic = ic->changeVTable(ScriptFunction::staticVTable());
- internalClasses[EngineBase::Class_ScriptFunction] = ic->addMember(id_length(), Attr_ReadOnly, &index);
- Q_ASSERT(index == Heap::ScriptFunction::Index_Length);
- internalClasses[EngineBase::Class_ObjectProto] = internalClasses[Class_Object]->addMember(id_constructor(), Attr_NotEnumerable, &index);
- Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
+ classes[Class_ScriptFunction] = ic->d();
+ ic = ic->changeVTable(ConstructorFunction::staticVTable());
+ classes[Class_ConstructorFunction] = ic->d();
+
+ classes[Class_ObjectProto] = classes[Class_Object]->addMember(id_constructor()->propertyKey(), Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == Heap::FunctionObject::Index_ProtoConstructor);
+
+ jsObjects[GeneratorProto] = memoryManager->allocObject<GeneratorPrototype>(classes[Class_Object]);
+ classes[Class_GeneratorObject] = newInternalClass(QV4::GeneratorObject::staticVTable(), generatorPrototype());
- Scope scope(this);
ScopedString str(scope);
- internalClasses[Class_RegExp] = internalClasses[EngineBase::Class_Empty]->changeVTable(QV4::RegExp::staticVTable());
+ classes[Class_RegExp] = classes[Class_Empty]->changeVTable(QV4::RegExp::staticVTable());
ic = newInternalClass(QV4::RegExpObject::staticVTable(), objectPrototype());
- ic = ic->addMember(id_lastIndex(), Attr_NotEnumerable|Attr_NotConfigurable, &index);
- Q_ASSERT(index == RegExpObject::Index_LastIndex);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("source"))), Attr_ReadOnly, &index);
- Q_ASSERT(index == RegExpObject::Index_Source);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("global"))), Attr_ReadOnly, &index);
- Q_ASSERT(index == RegExpObject::Index_Global);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("ignoreCase"))), Attr_ReadOnly, &index);
- Q_ASSERT(index == RegExpObject::Index_IgnoreCase);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("multiline"))), Attr_ReadOnly, &index);
- Q_ASSERT(index == RegExpObject::Index_Multiline);
- jsObjects[RegExpProto] = memoryManager->allocObject<RegExpPrototype>(ic, objectPrototype());
- internalClasses[Class_RegExpObject] = ic->changePrototype(regExpPrototype()->d());
-
- ic = internalClasses[Class_ArrayObject]->addMember(id_index(), Attr_Data, &index);
- Q_ASSERT(index == RegExpObject::Index_ArrayIndex);
- internalClasses[EngineBase::Class_RegExpExecArray] = ic->addMember(id_input(), Attr_Data, &index);
- Q_ASSERT(index == RegExpObject::Index_ArrayInput);
+ ic = ic->addMember(id_lastIndex()->propertyKey(), Attr_NotEnumerable|Attr_NotConfigurable, index);
+ Q_ASSERT(index->index == RegExpObject::Index_LastIndex);
+ jsObjects[RegExpProto] = memoryManager->allocObject<RegExpPrototype>(classes[Class_Object]);
+ classes[Class_RegExpObject] = ic->changePrototype(regExpPrototype()->d());
- ic = newInternalClass(ErrorObject::staticVTable(), nullptr);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("stack"))), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorObject::Index_Stack);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("fileName"))), Attr_Data|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorObject::Index_FileName);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("lineNumber"))), Attr_Data|Attr_NotEnumerable, &index);
- internalClasses[EngineBase::Class_ErrorObject] = ic;
- Q_ASSERT(index == ErrorObject::Index_LineNumber);
- internalClasses[EngineBase::Class_ErrorObjectWithMessage] = ic->addMember((str = newIdentifier(QStringLiteral("message"))), Attr_Data|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorObject::Index_Message);
- ic = newInternalClass(ErrorObject::staticVTable(), objectPrototype());
- ic = ic->addMember(id_constructor(), Attr_Data|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorPrototype::Index_Constructor);
- ic = ic->addMember((str = newIdentifier(QStringLiteral("message"))), Attr_Data|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorPrototype::Index_Message);
- internalClasses[EngineBase::Class_ErrorProto] = ic->addMember(id_name(), Attr_Data|Attr_NotEnumerable, &index);
- Q_ASSERT(index == ErrorPrototype::Index_Name);
-
- jsObjects[GetStack_Function] = FunctionObject::createBuiltinFunction(rootContext(), str = newIdentifier(QStringLiteral("stack")), ErrorObject::method_get_stack);
- getStackFunction()->defineReadonlyProperty(id_length(), Primitive::fromInt32(0));
-
- jsObjects[ErrorProto] = memoryManager->allocObject<ErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto], objectPrototype());
- jsObjects[EvalErrorProto] = memoryManager->allocObject<EvalErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
- jsObjects[RangeErrorProto] = memoryManager->allocObject<RangeErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
- jsObjects[ReferenceErrorProto] = memoryManager->allocObject<ReferenceErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
- jsObjects[SyntaxErrorProto] = memoryManager->allocObject<SyntaxErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
- jsObjects[TypeErrorProto] = memoryManager->allocObject<TypeErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
- jsObjects[URIErrorProto] = memoryManager->allocObject<URIErrorPrototype>(internalClasses[EngineBase::Class_ErrorProto]->changePrototype(errorPrototype()->d()), errorPrototype());
-
- jsObjects[VariantProto] = memoryManager->allocObject<VariantPrototype>();
- Q_ASSERT(variantPrototype()->prototype() == objectPrototype()->d());
+ ic = classes[Class_ArrayObject]->addMember(id_index()->propertyKey(), Attr_Data, index);
+ Q_ASSERT(index->index == RegExpObject::Index_ArrayIndex);
+ classes[Class_RegExpExecArray] = ic->addMember(id_input()->propertyKey(), Attr_Data, index);
+ Q_ASSERT(index->index == RegExpObject::Index_ArrayInput);
+ ic = newInternalClass(ErrorObject::staticVTable(), nullptr);
+ ic = ic->addMember((str = newIdentifier(QStringLiteral("stack")))->propertyKey(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorObject::Index_Stack);
+ Q_ASSERT(index->setterIndex == ErrorObject::Index_StackSetter);
+ ic = ic->addMember((str = newIdentifier(QStringLiteral("fileName")))->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorObject::Index_FileName);
+ ic = ic->addMember((str = newIdentifier(QStringLiteral("lineNumber")))->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ classes[Class_ErrorObject] = ic->d();
+ Q_ASSERT(index->index == ErrorObject::Index_LineNumber);
+ classes[Class_ErrorObjectWithMessage] = ic->addMember((str = newIdentifier(QStringLiteral("message")))->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorObject::Index_Message);
+ ic = newInternalClass(Object::staticVTable(), objectPrototype());
+ ic = ic->addMember(id_constructor()->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorPrototype::Index_Constructor);
+ ic = ic->addMember((str = newIdentifier(QStringLiteral("message")))->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorPrototype::Index_Message);
+ classes[Class_ErrorProto] = ic->addMember(id_name()->propertyKey(), Attr_Data|Attr_NotEnumerable, index);
+ Q_ASSERT(index->index == ErrorPrototype::Index_Name);
+
+ classes[Class_ProxyObject] = classes[Class_Empty]->changeVTable(ProxyObject::staticVTable());
+ classes[Class_ProxyFunctionObject] = classes[Class_Empty]->changeVTable(ProxyFunctionObject::staticVTable());
+
+ jsObjects[GetStack_Function] = FunctionObject::createBuiltinFunction(this, str = newIdentifier(QStringLiteral("stack")), ErrorObject::method_get_stack, 0);
+
+ jsObjects[ErrorProto] = memoryManager->allocObject<ErrorPrototype>(classes[Class_ErrorProto]);
+ ic = classes[Class_ErrorProto]->changePrototype(errorPrototype()->d());
+ jsObjects[EvalErrorProto] = memoryManager->allocObject<EvalErrorPrototype>(ic->d());
+ jsObjects[RangeErrorProto] = memoryManager->allocObject<RangeErrorPrototype>(ic->d());
+ jsObjects[ReferenceErrorProto] = memoryManager->allocObject<ReferenceErrorPrototype>(ic->d());
+ jsObjects[SyntaxErrorProto] = memoryManager->allocObject<SyntaxErrorPrototype>(ic->d());
+ jsObjects[TypeErrorProto] = memoryManager->allocObject<TypeErrorPrototype>(ic->d());
+ jsObjects[URIErrorProto] = memoryManager->allocObject<URIErrorPrototype>(ic->d());
+
+ jsObjects[VariantProto] = memoryManager->allocate<VariantPrototype>();
+ Q_ASSERT(variantPrototype()->getPrototypeOf() == objectPrototype()->d());
+
+#if QT_CONFIG(qml_sequence_object)
ic = newInternalClass(SequencePrototype::staticVTable(), SequencePrototype::defaultPrototype(this));
- jsObjects[SequenceProto] = ScopedValue(scope, memoryManager->allocObject<SequencePrototype>(ic, SequencePrototype::defaultPrototype(this)));
+ jsObjects[SequenceProto] = ScopedValue(scope, memoryManager->allocObject<SequencePrototype>(ic->d()));
+#endif
ExecutionContext *global = rootContext();
- jsObjects[Object_Ctor] = memoryManager->allocObject<ObjectCtor>(global);
- jsObjects[String_Ctor] = memoryManager->allocObject<StringCtor>(global);
- jsObjects[Number_Ctor] = memoryManager->allocObject<NumberCtor>(global);
- jsObjects[Boolean_Ctor] = memoryManager->allocObject<BooleanCtor>(global);
- jsObjects[Array_Ctor] = memoryManager->allocObject<ArrayCtor>(global);
- jsObjects[Function_Ctor] = memoryManager->allocObject<FunctionCtor>(global);
- jsObjects[Date_Ctor] = memoryManager->allocObject<DateCtor>(global);
- jsObjects[RegExp_Ctor] = memoryManager->allocObject<RegExpCtor>(global);
- jsObjects[Error_Ctor] = memoryManager->allocObject<ErrorCtor>(global);
- jsObjects[EvalError_Ctor] = memoryManager->allocObject<EvalErrorCtor>(global);
- jsObjects[RangeError_Ctor] = memoryManager->allocObject<RangeErrorCtor>(global);
- jsObjects[ReferenceError_Ctor] = memoryManager->allocObject<ReferenceErrorCtor>(global);
- jsObjects[SyntaxError_Ctor] = memoryManager->allocObject<SyntaxErrorCtor>(global);
- jsObjects[TypeError_Ctor] = memoryManager->allocObject<TypeErrorCtor>(global);
- jsObjects[URIError_Ctor] = memoryManager->allocObject<URIErrorCtor>(global);
+
+ jsObjects[Object_Ctor] = memoryManager->allocate<ObjectCtor>(global);
+ jsObjects[String_Ctor] = memoryManager->allocate<StringCtor>(global);
+ jsObjects[Symbol_Ctor] = memoryManager->allocate<SymbolCtor>(global);
+ jsObjects[Number_Ctor] = memoryManager->allocate<NumberCtor>(global);
+ jsObjects[Boolean_Ctor] = memoryManager->allocate<BooleanCtor>(global);
+ jsObjects[Array_Ctor] = memoryManager->allocate<ArrayCtor>(global);
+ jsObjects[Function_Ctor] = memoryManager->allocate<FunctionCtor>(global);
+ jsObjects[GeneratorFunction_Ctor] = memoryManager->allocate<GeneratorFunctionCtor>(global);
+ jsObjects[Date_Ctor] = memoryManager->allocate<DateCtor>(global);
+ jsObjects[RegExp_Ctor] = memoryManager->allocate<RegExpCtor>(global);
+ jsObjects[Error_Ctor] = memoryManager->allocate<ErrorCtor>(global);
+ jsObjects[EvalError_Ctor] = memoryManager->allocate<EvalErrorCtor>(global);
+ jsObjects[RangeError_Ctor] = memoryManager->allocate<RangeErrorCtor>(global);
+ jsObjects[ReferenceError_Ctor] = memoryManager->allocate<ReferenceErrorCtor>(global);
+ jsObjects[SyntaxError_Ctor] = memoryManager->allocate<SyntaxErrorCtor>(global);
+ jsObjects[TypeError_Ctor] = memoryManager->allocate<TypeErrorCtor>(global);
+ jsObjects[URIError_Ctor] = memoryManager->allocate<URIErrorCtor>(global);
+ jsObjects[IteratorProto] = memoryManager->allocate<IteratorPrototype>();
+ jsObjects[ForInIteratorProto] = memoryManager->allocObject<ForInIteratorPrototype>(newInternalClass(ForInIteratorPrototype::staticVTable(), iteratorPrototype()));
+ jsObjects[MapIteratorProto] = memoryManager->allocObject<MapIteratorPrototype>(newInternalClass(SetIteratorPrototype::staticVTable(), iteratorPrototype()));
+ jsObjects[SetIteratorProto] = memoryManager->allocObject<SetIteratorPrototype>(newInternalClass(SetIteratorPrototype::staticVTable(), iteratorPrototype()));
+ jsObjects[ArrayIteratorProto] = memoryManager->allocObject<ArrayIteratorPrototype>(newInternalClass(ArrayIteratorPrototype::staticVTable(), iteratorPrototype()));
+ jsObjects[StringIteratorProto] = memoryManager->allocObject<StringIteratorPrototype>(newInternalClass(StringIteratorPrototype::staticVTable(), iteratorPrototype()));
+
+ str = newString(QStringLiteral("get [Symbol.species]"));
+ jsObjects[GetSymbolSpecies] = FunctionObject::createBuiltinFunction(this, str, ArrayPrototype::method_get_species, 0);
static_cast<ObjectPrototype *>(objectPrototype())->init(this, objectCtor());
static_cast<StringPrototype *>(stringPrototype())->init(this, stringCtor());
+ static_cast<SymbolPrototype *>(symbolPrototype())->init(this, symbolCtor());
static_cast<NumberPrototype *>(numberPrototype())->init(this, numberCtor());
static_cast<BooleanPrototype *>(booleanPrototype())->init(this, booleanCtor());
static_cast<ArrayPrototype *>(arrayPrototype())->init(this, arrayCtor());
static_cast<PropertyListPrototype *>(propertyListPrototype())->init(this);
static_cast<DatePrototype *>(datePrototype())->init(this, dateCtor());
static_cast<FunctionPrototype *>(functionPrototype())->init(this, functionCtor());
+ static_cast<GeneratorPrototype *>(generatorPrototype())->init(this, generatorFunctionCtor());
static_cast<RegExpPrototype *>(regExpPrototype())->init(this, regExpCtor());
static_cast<ErrorPrototype *>(errorPrototype())->init(this, errorCtor());
static_cast<EvalErrorPrototype *>(evalErrorPrototype())->init(this, evalErrorCtor());
@@ -383,25 +491,59 @@ ExecutionEngine::ExecutionEngine()
static_cast<TypeErrorPrototype *>(typeErrorPrototype())->init(this, typeErrorCtor());
static_cast<URIErrorPrototype *>(uRIErrorPrototype())->init(this, uRIErrorCtor());
+ static_cast<IteratorPrototype *>(iteratorPrototype())->init(this);
+ static_cast<ForInIteratorPrototype *>(forInIteratorPrototype())->init(this);
+ static_cast<MapIteratorPrototype *>(mapIteratorPrototype())->init(this);
+ static_cast<SetIteratorPrototype *>(setIteratorPrototype())->init(this);
+ static_cast<ArrayIteratorPrototype *>(arrayIteratorPrototype())->init(this);
+ static_cast<StringIteratorPrototype *>(stringIteratorPrototype())->init(this);
+
static_cast<VariantPrototype *>(variantPrototype())->init();
+
+#if QT_CONFIG(qml_sequence_object)
sequencePrototype()->cast<SequencePrototype>()->init();
+#endif
+
+ jsObjects[WeakMap_Ctor] = memoryManager->allocate<WeakMapCtor>(global);
+ jsObjects[WeakMapProto] = memoryManager->allocate<WeakMapPrototype>();
+ static_cast<WeakMapPrototype *>(weakMapPrototype())->init(this, weakMapCtor());
+ jsObjects[Map_Ctor] = memoryManager->allocate<MapCtor>(global);
+ jsObjects[MapProto] = memoryManager->allocate<MapPrototype>();
+ static_cast<MapPrototype *>(mapPrototype())->init(this, mapCtor());
+
+ jsObjects[WeakSet_Ctor] = memoryManager->allocate<WeakSetCtor>(global);
+ jsObjects[WeakSetProto] = memoryManager->allocate<WeakSetPrototype>();
+ static_cast<WeakSetPrototype *>(weakSetPrototype())->init(this, weakSetCtor());
+
+ jsObjects[Set_Ctor] = memoryManager->allocate<SetCtor>(global);
+ jsObjects[SetProto] = memoryManager->allocate<SetPrototype>();
+ static_cast<SetPrototype *>(setPrototype())->init(this, setCtor());
// typed arrays
- jsObjects[ArrayBuffer_Ctor] = memoryManager->allocObject<ArrayBufferCtor>(global);
- jsObjects[ArrayBufferProto] = memoryManager->allocObject<ArrayBufferPrototype>();
+ jsObjects[SharedArrayBuffer_Ctor] = memoryManager->allocate<SharedArrayBufferCtor>(global);
+ jsObjects[SharedArrayBufferProto] = memoryManager->allocate<SharedArrayBufferPrototype>();
+ static_cast<SharedArrayBufferPrototype *>(sharedArrayBufferPrototype())->init(this, sharedArrayBufferCtor());
+
+ jsObjects[ArrayBuffer_Ctor] = memoryManager->allocate<ArrayBufferCtor>(global);
+ jsObjects[ArrayBufferProto] = memoryManager->allocate<ArrayBufferPrototype>();
static_cast<ArrayBufferPrototype *>(arrayBufferPrototype())->init(this, arrayBufferCtor());
- jsObjects[DataView_Ctor] = memoryManager->allocObject<DataViewCtor>(global);
- jsObjects[DataViewProto] = memoryManager->allocObject<DataViewPrototype>();
+ jsObjects[DataView_Ctor] = memoryManager->allocate<DataViewCtor>(global);
+ jsObjects[DataViewProto] = memoryManager->allocate<DataViewPrototype>();
static_cast<DataViewPrototype *>(dataViewPrototype())->init(this, dataViewCtor());
jsObjects[ValueTypeProto] = (Heap::Base *) nullptr;
jsObjects[SignalHandlerProto] = (Heap::Base *) nullptr;
- for (int i = 0; i < Heap::TypedArray::NTypes; ++i) {
- static_cast<Value &>(typedArrayCtors[i]) = memoryManager->allocObject<TypedArrayCtor>(global, Heap::TypedArray::Type(i));
- static_cast<Value &>(typedArrayPrototype[i]) = memoryManager->allocObject<TypedArrayPrototype>(Heap::TypedArray::Type(i));
+ jsObjects[IntrinsicTypedArray_Ctor] = memoryManager->allocate<IntrinsicTypedArrayCtor>(global);
+ jsObjects[IntrinsicTypedArrayProto] = memoryManager->allocate<IntrinsicTypedArrayPrototype>();
+ static_cast<IntrinsicTypedArrayPrototype *>(intrinsicTypedArrayPrototype())
+ ->init(this, static_cast<IntrinsicTypedArrayCtor *>(intrinsicTypedArrayCtor()));
+
+ for (int i = 0; i < NTypedArrayTypes; ++i) {
+ static_cast<Value &>(typedArrayCtors[i]) = memoryManager->allocate<TypedArrayCtor>(global, Heap::TypedArray::Type(i));
+ static_cast<Value &>(typedArrayPrototype[i]) = memoryManager->allocate<TypedArrayPrototype>(Heap::TypedArray::Type(i));
typedArrayPrototype[i].as<TypedArrayPrototype>()->init(this, static_cast<TypedArrayCtor *>(typedArrayCtors[i].as<Object>()));
}
@@ -413,6 +555,7 @@ ExecutionEngine::ExecutionEngine()
globalObject->defineDefaultProperty(QStringLiteral("Object"), *objectCtor());
globalObject->defineDefaultProperty(QStringLiteral("String"), *stringCtor());
+ globalObject->defineDefaultProperty(QStringLiteral("Symbol"), *symbolCtor());
FunctionObject *numberObject = numberCtor();
globalObject->defineDefaultProperty(QStringLiteral("Number"), *numberObject);
globalObject->defineDefaultProperty(QStringLiteral("Boolean"), *booleanCtor());
@@ -428,20 +571,29 @@ ExecutionEngine::ExecutionEngine()
globalObject->defineDefaultProperty(QStringLiteral("TypeError"), *typeErrorCtor());
globalObject->defineDefaultProperty(QStringLiteral("URIError"), *uRIErrorCtor());
+ globalObject->defineDefaultProperty(QStringLiteral("SharedArrayBuffer"), *sharedArrayBufferCtor());
globalObject->defineDefaultProperty(QStringLiteral("ArrayBuffer"), *arrayBufferCtor());
globalObject->defineDefaultProperty(QStringLiteral("DataView"), *dataViewCtor());
- for (int i = 0; i < Heap::TypedArray::NTypes; ++i)
- globalObject->defineDefaultProperty((str = typedArrayCtors[i].as<FunctionObject>()->name())->toQString(), typedArrayCtors[i]);
+ globalObject->defineDefaultProperty(QStringLiteral("WeakSet"), *weakSetCtor());
+ globalObject->defineDefaultProperty(QStringLiteral("Set"), *setCtor());
+ globalObject->defineDefaultProperty(QStringLiteral("WeakMap"), *weakMapCtor());
+ globalObject->defineDefaultProperty(QStringLiteral("Map"), *mapCtor());
+
+ for (int i = 0; i < NTypedArrayTypes; ++i)
+ globalObject->defineDefaultProperty((str = typedArrayCtors[i].as<FunctionObject>()->name()), typedArrayCtors[i]);
ScopedObject o(scope);
- globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = memoryManager->allocObject<MathObject>()));
- globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = memoryManager->allocObject<JsonObject>()));
+ globalObject->defineDefaultProperty(QStringLiteral("Atomics"), (o = memoryManager->allocate<Atomics>()));
+ globalObject->defineDefaultProperty(QStringLiteral("Math"), (o = memoryManager->allocate<MathObject>()));
+ globalObject->defineDefaultProperty(QStringLiteral("JSON"), (o = memoryManager->allocate<JsonObject>()));
+ globalObject->defineDefaultProperty(QStringLiteral("Reflect"), (o = memoryManager->allocate<Reflect>()));
+ globalObject->defineDefaultProperty(QStringLiteral("Proxy"), (o = memoryManager->allocate<Proxy>(rootContext())));
- globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Primitive::undefinedValue());
- globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN()));
- globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY));
+ globalObject->defineReadonlyProperty(QStringLiteral("undefined"), Value::undefinedValue());
+ globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Value::fromDouble(std::numeric_limits<double>::quiet_NaN()));
+ globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Value::fromDouble(Q_INFINITY));
- jsObjects[Eval_Function] = memoryManager->allocObject<EvalFunction>(global);
+ jsObjects[Eval_Function] = memoryManager->allocate<EvalFunction>(global);
globalObject->defineDefaultProperty(QStringLiteral("eval"), *evalFunction());
// ES6: 20.1.2.12 & 20.1.2.13:
@@ -453,11 +605,8 @@ ExecutionEngine::ExecutionEngine()
Scope scope(this);
ScopedString pi(scope, newIdentifier(piString));
ScopedString pf(scope, newIdentifier(pfString));
- ExecutionContext *global = rootContext();
- ScopedFunctionObject parseIntFn(scope, FunctionObject::createBuiltinFunction(global, pi, GlobalFunctions::method_parseInt));
- ScopedFunctionObject parseFloatFn(scope, FunctionObject::createBuiltinFunction(global, pf, GlobalFunctions::method_parseFloat));
- parseIntFn->defineReadonlyConfigurableProperty(id_length(), Primitive::fromInt32(2));
- parseFloatFn->defineReadonlyConfigurableProperty(id_length(), Primitive::fromInt32(1));
+ ScopedFunctionObject parseIntFn(scope, FunctionObject::createBuiltinFunction(this, pi, GlobalFunctions::method_parseInt, 2));
+ ScopedFunctionObject parseFloatFn(scope, FunctionObject::createBuiltinFunction(this, pf, GlobalFunctions::method_parseFloat, 1));
globalObject->defineDefaultProperty(piString, parseIntFn);
globalObject->defineDefaultProperty(pfString, parseFloatFn);
numberObject->defineDefaultProperty(piString, parseIntFn);
@@ -473,12 +622,21 @@ ExecutionEngine::ExecutionEngine()
globalObject->defineDefaultProperty(QStringLiteral("escape"), GlobalFunctions::method_escape, 1);
globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1);
- ScopedString name(scope, newString(QStringLiteral("thrower")));
- jsObjects[ThrowerObject] = FunctionObject::createBuiltinFunction(global, name, ::throwTypeError);
+ ScopedFunctionObject t(scope, memoryManager->allocate<FunctionObject>(rootContext(), nullptr, ::throwTypeError));
+ t->defineReadonlyProperty(id_length(), Value::fromInt32(0));
+ t->setInternalClass(t->internalClass()->frozen());
+ jsObjects[ThrowerObject] = t;
+
+ ScopedProperty pd(scope);
+ pd->value = thrower();
+ pd->set = thrower();
+ functionPrototype()->insertMember(id_caller(), pd, Attr_Accessor|Attr_ReadOnly_ButConfigurable);
+ functionPrototype()->insertMember(id_arguments(), pd, Attr_Accessor|Attr_ReadOnly_ButConfigurable);
}
ExecutionEngine::~ExecutionEngine()
{
+ modules.clear();
delete m_multiplyWrappedQObjects;
m_multiplyWrappedQObjects = nullptr;
delete identifierTable;
@@ -487,8 +645,6 @@ ExecutionEngine::~ExecutionEngine()
while (!compilationUnits.isEmpty())
(*compilationUnits.begin())->unlink();
- internalClasses[Class_Empty]->destroy();
- delete classPool;
delete bumperPointerAllocator;
delete regExpCache;
delete regExpAllocator;
@@ -497,7 +653,11 @@ ExecutionEngine::~ExecutionEngine()
delete jsStack;
gcStack->deallocate();
delete gcStack;
- delete [] argumentsAccessors;
+}
+
+ExecutionContext *ExecutionEngine::currentContext() const
+{
+ return static_cast<ExecutionContext *>(&currentStackFrame->jsFrame->context);
}
#if QT_CONFIG(qml_debug)
@@ -521,59 +681,71 @@ void ExecutionEngine::initRootContext()
r->d_unchecked()->init(Heap::ExecutionContext::Type_GlobalContext);
r->d()->activation.set(this, globalObject->d());
jsObjects[RootContext] = r;
+ jsObjects[ScriptContext] = r;
jsObjects[IntegerNull] = Encode((int)0);
}
-InternalClass *ExecutionEngine::newClass(const InternalClass &other)
+Heap::InternalClass *ExecutionEngine::newClass(Heap::InternalClass *other)
{
- return new (classPool) InternalClass(other);
+ Heap::InternalClass *ic = memoryManager->allocIC<InternalClass>();
+ ic->init(other);
+ return ic;
}
-InternalClass *ExecutionEngine::newInternalClass(const VTable *vtable, Object *prototype)
+Heap::InternalClass *ExecutionEngine::newInternalClass(const VTable *vtable, Object *prototype)
{
- return internalClasses[EngineBase::Class_Empty]->changeVTable(vtable)->changePrototype(prototype ? prototype->d() : nullptr);
+ Scope scope(this);
+ Scoped<InternalClass> ic(scope, internalClasses(Class_Empty)->changeVTable(vtable));
+ return ic->changePrototype(prototype ? prototype->d() : nullptr);
}
Heap::Object *ExecutionEngine::newObject()
{
- return memoryManager->allocObject<Object>();
+ return memoryManager->allocate<Object>();
}
-Heap::Object *ExecutionEngine::newObject(InternalClass *internalClass, QV4::Object *prototype)
+Heap::Object *ExecutionEngine::newObject(Heap::InternalClass *internalClass)
{
- return memoryManager->allocObject<Object>(internalClass, prototype);
+ return memoryManager->allocObject<Object>(internalClass);
}
Heap::String *ExecutionEngine::newString(const QString &s)
{
- Scope scope(this);
- return ScopedString(scope, memoryManager->allocWithStringData<String>(s.length() * sizeof(QChar), s))->d();
+ return memoryManager->allocWithStringData<String>(s.length() * sizeof(QChar), s);
}
Heap::String *ExecutionEngine::newIdentifier(const QString &text)
{
- return identifierTable->insertString(text);
+ Scope scope(this);
+ ScopedString s(scope, memoryManager->allocWithStringData<String>(text.length() * sizeof(QChar), text));
+ s->toPropertyKey();
+ return s->d();
}
Heap::Object *ExecutionEngine::newStringObject(const String *string)
{
- return memoryManager->allocObject<StringObject>(string);
+ return memoryManager->allocate<StringObject>(string);
+}
+
+Heap::Object *ExecutionEngine::newSymbolObject(const Symbol *symbol)
+{
+ return memoryManager->allocObject<SymbolObject>(classes[Class_SymbolObject], symbol);
}
Heap::Object *ExecutionEngine::newNumberObject(double value)
{
- return memoryManager->allocObject<NumberObject>(value);
+ return memoryManager->allocate<NumberObject>(value);
}
Heap::Object *ExecutionEngine::newBooleanObject(bool b)
{
- return memoryManager->allocObject<BooleanObject>(b);
+ return memoryManager->allocate<BooleanObject>(b);
}
Heap::ArrayObject *ExecutionEngine::newArrayObject(int count)
{
Scope scope(this);
- ScopedArrayObject object(scope, memoryManager->allocObject<ArrayObject>());
+ ScopedArrayObject object(scope, memoryManager->allocate<ArrayObject>());
if (count) {
if (count < 0x1000)
@@ -586,7 +758,7 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(int count)
Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int length)
{
Scope scope(this);
- ScopedArrayObject a(scope, memoryManager->allocObject<ArrayObject>());
+ ScopedArrayObject a(scope, memoryManager->allocate<ArrayObject>());
if (length) {
size_t size = sizeof(Heap::ArrayData) + (length-1)*sizeof(Value);
@@ -607,72 +779,64 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int leng
Heap::ArrayObject *ExecutionEngine::newArrayObject(const QStringList &list)
{
- Scope scope(this);
- ScopedArrayObject object(scope, memoryManager->allocObject<ArrayObject>(list));
- return object->d();
+ return memoryManager->allocate<ArrayObject>(list);
}
-Heap::ArrayObject *ExecutionEngine::newArrayObject(InternalClass *internalClass, Object *prototype)
+Heap::ArrayObject *ExecutionEngine::newArrayObject(Heap::InternalClass *internalClass)
{
- Scope scope(this);
- ScopedArrayObject object(scope, memoryManager->allocObject<ArrayObject>(internalClass, prototype));
- return object->d();
+ return memoryManager->allocObject<ArrayObject>(internalClass);
}
Heap::ArrayBuffer *ExecutionEngine::newArrayBuffer(const QByteArray &array)
{
- return memoryManager->allocObject<ArrayBuffer>(array);
+ return memoryManager->allocate<ArrayBuffer>(array);
}
Heap::ArrayBuffer *ExecutionEngine::newArrayBuffer(size_t length)
{
- return memoryManager->allocObject<ArrayBuffer>(length);
+ return memoryManager->allocate<ArrayBuffer>(length);
}
Heap::DateObject *ExecutionEngine::newDateObject(const Value &value)
{
- return memoryManager->allocObject<DateObject>(value);
+ return memoryManager->allocate<DateObject>(value);
}
Heap::DateObject *ExecutionEngine::newDateObject(const QDateTime &dt)
{
Scope scope(this);
- Scoped<DateObject> object(scope, memoryManager->allocObject<DateObject>(dt));
+ Scoped<DateObject> object(scope, memoryManager->allocate<DateObject>(dt));
return object->d();
}
Heap::DateObject *ExecutionEngine::newDateObjectFromTime(const QTime &t)
{
Scope scope(this);
- Scoped<DateObject> object(scope, memoryManager->allocObject<DateObject>(t));
+ Scoped<DateObject> object(scope, memoryManager->allocate<DateObject>(t));
return object->d();
}
Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QString &pattern, int flags)
{
- bool global = (flags & QV4::CompiledData::RegExp::RegExp_Global);
- bool ignoreCase = (flags & QV4::CompiledData::RegExp::RegExp_IgnoreCase);
- bool multiline = (flags & QV4::CompiledData::RegExp::RegExp_Multiline);
-
Scope scope(this);
- Scoped<RegExp> re(scope, RegExp::create(this, pattern, ignoreCase, multiline, global));
+ Scoped<RegExp> re(scope, RegExp::create(this, pattern, static_cast<CompiledData::RegExp::Flags>(flags)));
return newRegExpObject(re);
}
Heap::RegExpObject *ExecutionEngine::newRegExpObject(RegExp *re)
{
- return memoryManager->allocObject<RegExpObject>(re);
+ return memoryManager->allocate<RegExpObject>(re);
}
Heap::RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re)
{
- return memoryManager->allocObject<RegExpObject>(re);
+ return memoryManager->allocate<RegExpObject>(re);
}
Heap::Object *ExecutionEngine::newErrorObject(const Value &value)
{
- return ErrorObject::create<ErrorObject>(this, value);
+ return ErrorObject::create<ErrorObject>(this, value, errorCtor());
}
Heap::Object *ExecutionEngine::newSyntaxErrorObject(const QString &message)
@@ -709,21 +873,36 @@ Heap::Object *ExecutionEngine::newRangeErrorObject(const QString &message)
Heap::Object *ExecutionEngine::newURIErrorObject(const Value &message)
{
- return ErrorObject::create<URIErrorObject>(this, message);
+ return ErrorObject::create<URIErrorObject>(this, message, uRIErrorCtor());
}
Heap::Object *ExecutionEngine::newVariantObject(const QVariant &v)
{
- return memoryManager->allocObject<VariantObject>(v);
+ return memoryManager->allocate<VariantObject>(v);
}
-Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o)
+Heap::Object *ExecutionEngine::newForInIteratorObject(Object *o)
{
Scope scope(this);
- ScopedObject obj(scope, memoryManager->allocObject<ForEachIteratorObject>(o));
+ ScopedObject obj(scope, memoryManager->allocate<ForInIteratorObject>(o));
return obj->d();
}
+Heap::Object *ExecutionEngine::newMapIteratorObject(Object *o)
+{
+ return memoryManager->allocate<MapIteratorObject>(o->d(), this);
+}
+
+Heap::Object *ExecutionEngine::newSetIteratorObject(Object *o)
+{
+ return memoryManager->allocate<SetIteratorObject>(o->d(), this);
+}
+
+Heap::Object *ExecutionEngine::newArrayIteratorObject(Object *o)
+{
+ return memoryManager->allocate<ArrayIteratorObject>(o->d(), this);
+}
+
Heap::QmlContext *ExecutionEngine::qmlContext() const
{
if (!currentStackFrame)
@@ -761,37 +940,6 @@ QQmlContextData *ExecutionEngine::callingQmlContext() const
return ctx->qml()->context->contextData();
}
-QString CppStackFrame::source() const
-{
- return v4Function ? v4Function->sourceFile() : QString();
-}
-
-QString CppStackFrame::function() const
-{
- return v4Function ? v4Function->name()->toQString() : QString();
-}
-
-int CppStackFrame::lineNumber() const
-{
- if (!v4Function)
- return -1;
-
- auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) {
- return entry.codeOffset < offset;
- };
-
- const QV4::CompiledData::Function *cf = v4Function->compiledFunction;
- uint offset = instructionPointer;
- const CompiledData::CodeOffsetToLine *lineNumbers = cf->lineNumberTable();
- uint nLineNumbers = cf->nLineNumbers;
- const CompiledData::CodeOffsetToLine *line = std::lower_bound(lineNumbers, lineNumbers + nLineNumbers, offset, findLine) - 1;
- return line->line;
-}
-
-ReturnedValue CppStackFrame::thisObject() const {
- return jsFrame->thisObject.asReturnedValue();
-}
-
StackTrace ExecutionEngine::stackTrace(int frameLimit) const
{
Scope scope(const_cast<ExecutionEngine *>(this));
@@ -871,47 +1019,15 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file)
return base.resolved(src);
}
-void ExecutionEngine::requireArgumentsAccessors(int n)
-{
- if (n <= nArgumentsAccessors)
- return;
-
- Scope scope(this);
- ScopedFunctionObject get(scope);
- ScopedFunctionObject set(scope);
-
- if (n >= nArgumentsAccessors) {
- Property *oldAccessors = argumentsAccessors;
- int oldSize = nArgumentsAccessors;
- nArgumentsAccessors = qMax(8, n);
- argumentsAccessors = new Property[nArgumentsAccessors];
- if (oldAccessors) {
- memcpy(static_cast<void *>(argumentsAccessors), static_cast<const void *>(oldAccessors), oldSize*sizeof(Property));
- delete [] oldAccessors;
- }
- ExecutionContext *global = rootContext();
- for (int i = oldSize; i < nArgumentsAccessors; ++i) {
- argumentsAccessors[i].value = ScopedValue(scope, memoryManager->allocObject<ArgumentsGetterFunction>(global, i));
- argumentsAccessors[i].set = ScopedValue(scope, memoryManager->allocObject<ArgumentsSetterFunction>(global, i));
- }
- }
-}
-
void ExecutionEngine::markObjects(MarkStack *markStack)
{
- identifierTable->mark(markStack);
-
- for (int i = 0; i < nArgumentsAccessors; ++i) {
- const Property &pd = argumentsAccessors[i];
- if (Heap::FunctionObject *getter = pd.getter())
- getter->mark(markStack);
- if (Heap::FunctionObject *setter = pd.setter())
- setter->mark(markStack);
- }
-
- classPool->markObjects(markStack);
+ for (int i = 0; i < NClasses; ++i)
+ if (classes[i])
+ classes[i]->mark(markStack);
markStack->drain();
+ identifierTable->markObjects(markStack);
+
for (auto compilationUnit: compilationUnits) {
compilationUnit->markObjects(markStack);
markStack->drain();
@@ -950,7 +1066,7 @@ ReturnedValue ExecutionEngine::catchException(StackTrace *trace)
exceptionStackTrace.clear();
hasException = false;
ReturnedValue res = exceptionValue->asReturnedValue();
- *exceptionValue = Primitive::emptyValue();
+ *exceptionValue = Value::emptyValue();
return res;
}
@@ -1053,12 +1169,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError()
error.setColumn(frame.column);
}
QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception);
- if (!!errorObj && errorObj->asSyntaxError()) {
- QV4::ScopedString m(scope, newString(QStringLiteral("message")));
- QV4::ScopedValue v(scope, errorObj->get(m));
- error.setDescription(v->toQStringNoThrow());
- } else
- error.setDescription(exception->toQStringNoThrow());
+ error.setDescription(exception->toQStringNoThrow());
return error;
}
@@ -1117,8 +1228,11 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return v->toVariant();
} else if (QV4::QmlListWrapper *l = object->as<QV4::QmlListWrapper>()) {
return l->toVariant();
- } else if (object->isListType())
+#if QT_CONFIG(qml_sequence_object)
+ } else if (object->isListType()) {
return QV4::SequencePrototype::toVariant(object);
+#endif
+ }
}
if (value.as<ArrayObject>()) {
@@ -1128,7 +1242,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
uint length = a->getLength();
QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope);
for (uint ii = 0; ii < length; ++ii) {
- qobjectWrapper = a->getIndexed(ii);
+ qobjectWrapper = a->get(ii);
if (!!qobjectWrapper) {
list << qobjectWrapper->object();
} else {
@@ -1141,10 +1255,12 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return QVariant::fromValue(QV4::JsonObject::toJsonArray(a));
}
+#if QT_CONFIG(qml_sequence_object)
bool succeeded = false;
QVariant retn = QV4::SequencePrototype::toVariant(value, typeHint, &succeeded);
if (succeeded)
return retn;
+#endif
}
if (value.isUndefined())
@@ -1164,8 +1280,10 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return str.at(0);
return str;
}
+#if QT_CONFIG(qml_locale)
if (const QV4::QQmlLocaleData *ld = value.as<QV4::QQmlLocaleData>())
return *ld->d()->locale;
+#endif
if (const QV4::DateObject *d = value.as<DateObject>())
return d->toQDateTime();
if (const ArrayBuffer *d = value.as<ArrayBuffer>())
@@ -1211,7 +1329,7 @@ static QVariant objectToVariant(QV4::ExecutionEngine *e, const QV4::Object *o, V
int length = a->getLength();
for (int ii = 0; ii < length; ++ii) {
- v = a->getIndexed(ii);
+ v = a->get(ii);
list << ::toVariant(e, v, -1, /*createJSValueForObjects*/false, visitedObjects);
}
@@ -1260,9 +1378,6 @@ static QV4::ReturnedValue objectFromVariantMap(QV4::ExecutionEngine *e, const QV
QV4::ScopedValue v(scope);
for (QVariantMap::const_iterator iter = map.begin(), cend = map.end(); iter != cend; ++iter) {
s = e->newString(iter.key());
- uint idx = s->asArrayIndex();
- if (idx > 16 && (!o->arrayData() || idx > o->arrayData()->length() * 2))
- o->initSparseArray();
o->put(s, (v = e->fromVariant(iter.value())));
}
return o.asReturnedValue();
@@ -1321,6 +1436,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant)
return QV4::Encode(newRegExpObject(*reinterpret_cast<const QRegExp *>(ptr)));
case QMetaType::QObjectStar:
return QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(ptr));
+#if QT_CONFIG(qml_sequence_object)
case QMetaType::QStringList:
{
bool succeeded = false;
@@ -1330,6 +1446,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant)
return retn->asReturnedValue();
return QV4::Encode(newArrayObject(*reinterpret_cast<const QStringList *>(ptr)));
}
+#endif
case QMetaType::QVariantList:
return arrayFromVariantList(this, *reinterpret_cast<const QVariantList *>(ptr));
case QMetaType::QVariantMap:
@@ -1340,8 +1457,10 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant)
return QV4::JsonObject::fromJsonObject(this, *reinterpret_cast<const QJsonObject *>(ptr));
case QMetaType::QJsonArray:
return QV4::JsonObject::fromJsonArray(this, *reinterpret_cast<const QJsonArray *>(ptr));
+#if QT_CONFIG(qml_locale)
case QMetaType::QLocale:
return QQmlLocale::wrap(this, *reinterpret_cast<const QLocale*>(ptr));
+#endif
default:
break;
}
@@ -1381,10 +1500,12 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant)
if (objOk)
return QV4::QObjectWrapper::wrap(this, obj);
+#if QT_CONFIG(qml_sequence_object)
bool succeeded = false;
QV4::ScopedValue retn(scope, QV4::SequencePrototype::fromVariant(this, variant, &succeeded));
if (succeeded)
return retn->asReturnedValue();
+#endif
if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(type))
return QV4::QQmlValueTypeWrapper::create(this, variant, vtmo, type);
@@ -1428,11 +1549,13 @@ static QV4::ReturnedValue variantMapToJS(QV4::ExecutionEngine *v4, const QVarian
QV4::Scope scope(v4);
QV4::ScopedObject o(scope, v4->newObject());
QV4::ScopedString s(scope);
+ QV4::ScopedPropertyKey key(scope);
QV4::ScopedValue v(scope);
for (QVariantMap::const_iterator it = vmap.constBegin(), cend = vmap.constEnd(); it != cend; ++it) {
s = v4->newIdentifier(it.key());
+ key = s->propertyKey();
v = variantToJS(v4, it.value());
- uint idx = s->asArrayIndex();
+ uint idx = key->asArrayIndex();
if (idx < UINT_MAX)
o->arraySet(idx, v);
else
@@ -1538,6 +1661,128 @@ ReturnedValue ExecutionEngine::global()
return globalObject->asReturnedValue();
}
+QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::compileModule(const QUrl &url)
+{
+ QFile f(QQmlFile::urlToLocalFileOrQrc(url));
+ if (!f.open(QIODevice::ReadOnly)) {
+ throwError(QStringLiteral("Could not open module %1 for reading").arg(url.toString()));
+ return nullptr;
+ }
+
+ const QDateTime timeStamp = QFileInfo(f).lastModified();
+
+ const QString sourceCode = QString::fromUtf8(f.readAll());
+ f.close();
+
+ return compileModule(url, sourceCode, timeStamp);
+}
+
+
+QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::compileModule(const QUrl &url, const QString &sourceCode, const QDateTime &sourceTimeStamp)
+{
+ QList<QQmlJS::DiagnosticMessage> diagnostics;
+ auto unit = compileModule(/*debugMode*/debugger() != nullptr, url.toString(), sourceCode, sourceTimeStamp, &diagnostics);
+ for (const QQmlJS::DiagnosticMessage &m : diagnostics) {
+ if (m.isError()) {
+ throwSyntaxError(m.message, url.toString(), m.loc.startLine, m.loc.startColumn);
+ return nullptr;
+ } else {
+ qWarning() << url << ':' << m.loc.startLine << ':' << m.loc.startColumn
+ << ": warning: " << m.message;
+ }
+ }
+ return unit;
+}
+
+#endif // ifndef V4_BOOTSTRAP
+
+QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::compileModule(bool debugMode, const QString &url, const QString &sourceCode,
+ const QDateTime &sourceTimeStamp, QList<QQmlJS::DiagnosticMessage> *diagnostics)
+{
+ QQmlJS::Engine ee;
+ QQmlJS::Lexer lexer(&ee);
+ lexer.setCode(sourceCode, /*line*/1, /*qml mode*/false);
+ QQmlJS::Parser parser(&ee);
+
+ const bool parsed = parser.parseModule();
+
+ if (diagnostics)
+ *diagnostics = parser.diagnosticMessages();
+
+ if (!parsed)
+ return nullptr;
+
+ QQmlJS::AST::ESModule *moduleNode = QQmlJS::AST::cast<QQmlJS::AST::ESModule*>(parser.rootNode());
+ if (!moduleNode) {
+ // if parsing was successful, and we have no module, then
+ // the file was empty.
+ if (diagnostics)
+ diagnostics->clear();
+ return nullptr;
+ }
+
+ using namespace QV4::Compiler;
+ Compiler::Module compilerModule(debugMode);
+ compilerModule.unitFlags |= CompiledData::Unit::IsESModule;
+ compilerModule.sourceTimeStamp = sourceTimeStamp;
+ JSUnitGenerator jsGenerator(&compilerModule);
+ Codegen cg(&jsGenerator, /*strictMode*/true);
+ cg.generateFromModule(url, url, sourceCode, moduleNode, &compilerModule);
+ auto errors = cg.errors();
+ if (diagnostics)
+ *diagnostics << errors;
+
+ if (!errors.isEmpty())
+ return nullptr;
+
+ return cg.generateCompilationUnit();
+}
+
+#ifndef V4_BOOTSTRAP
+
+void ExecutionEngine::injectModule(const QQmlRefPointer<CompiledData::CompilationUnit> &moduleUnit)
+{
+ // Injection can happen from the QML type loader thread for example, but instantiation and
+ // evaluation must be limited to the ExecutionEngine's thread.
+ QMutexLocker moduleGuard(&moduleMutex);
+ modules.insert(moduleUnit->finalUrl(), moduleUnit);
+}
+
+QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::moduleForUrl(const QUrl &_url, const CompiledData::CompilationUnit *referrer) const
+{
+ QUrl url = QQmlTypeLoader::normalize(_url);
+ if (referrer)
+ url = referrer->finalUrl().resolved(url);
+
+ QMutexLocker moduleGuard(&moduleMutex);
+ auto existingModule = modules.find(url);
+ if (existingModule == modules.end())
+ return nullptr;
+ return *existingModule;
+}
+
+QQmlRefPointer<CompiledData::CompilationUnit> ExecutionEngine::loadModule(const QUrl &_url, const CompiledData::CompilationUnit *referrer)
+{
+ QUrl url = QQmlTypeLoader::normalize(_url);
+ if (referrer)
+ url = referrer->finalUrl().resolved(url);
+
+ QMutexLocker moduleGuard(&moduleMutex);
+ auto existingModule = modules.find(url);
+ if (existingModule != modules.end())
+ return *existingModule;
+
+ moduleGuard.unlock();
+
+ auto newModule = compileModule(url);
+ if (newModule) {
+ moduleGuard.relock();
+ modules.insert(url, newModule);
+ }
+
+ return newModule;
+}
+
// Converts a JS value to a meta-type.
// data must point to a place that can store a value of the given type.
// Returns true if conversion succeeded, false otherwise.
@@ -1707,7 +1952,7 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data)
} else if (Object *o = value->objectValue()) {
// Look in the prototype chain.
QV4::Scope scope(this);
- QV4::ScopedObject proto(scope, o->prototype());
+ QV4::ScopedObject proto(scope, o->getPrototypeOf());
while (proto) {
bool canCast = false;
if (QV4::VariantObject *vo = proto->as<QV4::VariantObject>()) {
@@ -1728,7 +1973,7 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data)
*reinterpret_cast<void* *>(data) = var.data();
return true;
}
- proto = proto->prototype();
+ proto = proto->getPrototypeOf();
}
}
} else if (value->isNull() && name.endsWith('*')) {
@@ -1777,5 +2022,6 @@ static QObject *qtObjectFromJS(QV4::ExecutionEngine *engine, const QV4::Value &v
return wrapper->object();
}
+#endif // ifndef V4_BOOTSTRAP
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index c7fb743088..276efe6e13 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -55,7 +55,8 @@
#include "qv4context_p.h"
#include <private/qintrusivelist_p.h>
#include "qv4enginebase_p.h"
-
+#include <private/qqmlrefcount_p.h>
+#include <private/qqmljsengine_p.h>
#ifndef V4_BOOTSTRAP
# include "qv4function_p.h"
@@ -87,34 +88,11 @@ namespace CompiledData {
struct CompilationUnit;
}
-struct Function;
-struct InternalClass;
-struct InternalClassPool;
-
-struct Q_QML_EXPORT CppStackFrame {
- CppStackFrame *parent;
- Function *v4Function;
- CallData *jsFrame;
- const Value *originalArguments;
- int originalArgumentsCount;
- int instructionPointer;
-
- QString source() const;
- QString function() const;
- inline QV4::ExecutionContext *context() const {
- return static_cast<ExecutionContext *>(&jsFrame->context);
- }
- int lineNumber() const;
-
- inline QV4::Heap::CallContext *callContext() const {
- Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\
- while (ctx->type != Heap::ExecutionContext::Type_CallContext)
- ctx = ctx->outer;
- return static_cast<Heap::CallContext *>(ctx);
- }
- ReturnedValue thisObject() const;
+namespace Heap {
+struct Module;
};
+struct Function;
struct Q_QML_EXPORT ExecutionEngine : public EngineBase
@@ -142,8 +120,6 @@ public:
QML_NEARLY_ALWAYS_INLINE Value *jsAlloca(int nValues) {
Value *ptr = jsStackTop;
jsStackTop = ptr + nValues;
- for (int i = 0; i < nValues; ++i)
- ptr[i] = Primitive::undefinedValue();
return ptr;
}
@@ -153,22 +129,27 @@ public:
QJSEngine *jsEngine() const;
QQmlEngine *qmlEngine() const;
#else // !V4_BOOTSTRAP
- QJSEngine *jsEngine() const { return v8Engine->publicEngine(); }
+ QJSEngine *jsEngine() const { return publicEngine; }
QQmlEngine *qmlEngine() const { return v8Engine ? v8Engine->engine() : nullptr; }
#endif // V4_BOOTSTRAP
QV8Engine *v8Engine;
+ QJSEngine *publicEngine;
enum JSObjects {
RootContext,
+ ScriptContext,
IntegerNull, // Has to come after the RootContext to make the context stack safe
ObjectProto,
+ SymbolProto,
ArrayProto,
+ ArrayProtoValues,
PropertyListProto,
StringProto,
NumberProto,
BooleanProto,
DateProto,
FunctionProto,
+ GeneratorProto,
RegExpProto,
ErrorProto,
EvalErrorProto,
@@ -178,18 +159,34 @@ public:
TypeErrorProto,
URIErrorProto,
VariantProto,
+#if QT_CONFIG(qml_sequence_object)
SequenceProto,
+#endif
+ SharedArrayBufferProto,
ArrayBufferProto,
DataViewProto,
+ WeakSetProto,
+ SetProto,
+ WeakMapProto,
+ MapProto,
+ IntrinsicTypedArrayProto,
ValueTypeProto,
SignalHandlerProto,
+ IteratorProto,
+ ForInIteratorProto,
+ SetIteratorProto,
+ MapIteratorProto,
+ ArrayIteratorProto,
+ StringIteratorProto,
Object_Ctor,
String_Ctor,
+ Symbol_Ctor,
Number_Ctor,
Boolean_Ctor,
Array_Ctor,
Function_Ctor,
+ GeneratorFunction_Ctor,
Date_Ctor,
RegExp_Ctor,
Error_Ctor,
@@ -199,8 +196,16 @@ public:
SyntaxError_Ctor,
TypeError_Ctor,
URIError_Ctor,
+ SharedArrayBuffer_Ctor,
ArrayBuffer_Ctor,
DataView_Ctor,
+ WeakSet_Ctor,
+ Set_Ctor,
+ WeakMap_Ctor,
+ Map_Ctor,
+ IntrinsicTypedArray_Ctor,
+
+ GetSymbolSpecies,
Eval_Function,
GetStack_Function,
@@ -211,12 +216,16 @@ public:
enum { NTypedArrayTypes = 9 }; // == TypedArray::NValues, avoid header dependency
ExecutionContext *rootContext() const { return reinterpret_cast<ExecutionContext *>(jsObjects + RootContext); }
+ ExecutionContext *scriptContext() const { return reinterpret_cast<ExecutionContext *>(jsObjects + ScriptContext); }
+ void setScriptContext(ReturnedValue c) { jsObjects[ScriptContext] = c; }
FunctionObject *objectCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Object_Ctor); }
FunctionObject *stringCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + String_Ctor); }
+ FunctionObject *symbolCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Symbol_Ctor); }
FunctionObject *numberCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Number_Ctor); }
FunctionObject *booleanCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Boolean_Ctor); }
FunctionObject *arrayCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Array_Ctor); }
FunctionObject *functionCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Function_Ctor); }
+ FunctionObject *generatorFunctionCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + GeneratorFunction_Ctor); }
FunctionObject *dateCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Date_Ctor); }
FunctionObject *regExpCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + RegExp_Ctor); }
FunctionObject *errorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Error_Ctor); }
@@ -226,18 +235,29 @@ public:
FunctionObject *syntaxErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + SyntaxError_Ctor); }
FunctionObject *typeErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + TypeError_Ctor); }
FunctionObject *uRIErrorCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + URIError_Ctor); }
+ FunctionObject *sharedArrayBufferCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + SharedArrayBuffer_Ctor); }
FunctionObject *arrayBufferCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + ArrayBuffer_Ctor); }
FunctionObject *dataViewCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + DataView_Ctor); }
+ FunctionObject *weakSetCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + WeakSet_Ctor); }
+ FunctionObject *setCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Set_Ctor); }
+ FunctionObject *weakMapCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + WeakMap_Ctor); }
+ FunctionObject *mapCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + Map_Ctor); }
+ FunctionObject *intrinsicTypedArrayCtor() const { return reinterpret_cast<FunctionObject *>(jsObjects + IntrinsicTypedArray_Ctor); }
FunctionObject *typedArrayCtors;
+ FunctionObject *getSymbolSpecies() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetSymbolSpecies); }
+
Object *objectPrototype() const { return reinterpret_cast<Object *>(jsObjects + ObjectProto); }
+ Object *symbolPrototype() const { return reinterpret_cast<Object *>(jsObjects + SymbolProto); }
Object *arrayPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayProto); }
+ Object *arrayProtoValues() const { return reinterpret_cast<Object *>(jsObjects + ArrayProtoValues); }
Object *propertyListPrototype() const { return reinterpret_cast<Object *>(jsObjects + PropertyListProto); }
Object *stringPrototype() const { return reinterpret_cast<Object *>(jsObjects + StringProto); }
Object *numberPrototype() const { return reinterpret_cast<Object *>(jsObjects + NumberProto); }
Object *booleanPrototype() const { return reinterpret_cast<Object *>(jsObjects + BooleanProto); }
Object *datePrototype() const { return reinterpret_cast<Object *>(jsObjects + DateProto); }
Object *functionPrototype() const { return reinterpret_cast<Object *>(jsObjects + FunctionProto); }
+ Object *generatorPrototype() const { return reinterpret_cast<Object *>(jsObjects + GeneratorProto); }
Object *regExpPrototype() const { return reinterpret_cast<Object *>(jsObjects + RegExpProto); }
Object *errorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ErrorProto); }
Object *evalErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + EvalErrorProto); }
@@ -247,23 +267,33 @@ public:
Object *typeErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + TypeErrorProto); }
Object *uRIErrorPrototype() const { return reinterpret_cast<Object *>(jsObjects + URIErrorProto); }
Object *variantPrototype() const { return reinterpret_cast<Object *>(jsObjects + VariantProto); }
+#if QT_CONFIG(qml_sequence_object)
Object *sequencePrototype() const { return reinterpret_cast<Object *>(jsObjects + SequenceProto); }
+#endif
+ Object *sharedArrayBufferPrototype() const { return reinterpret_cast<Object *>(jsObjects + SharedArrayBufferProto); }
Object *arrayBufferPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayBufferProto); }
Object *dataViewPrototype() const { return reinterpret_cast<Object *>(jsObjects + DataViewProto); }
+ Object *weakSetPrototype() const { return reinterpret_cast<Object *>(jsObjects + WeakSetProto); }
+ Object *setPrototype() const { return reinterpret_cast<Object *>(jsObjects + SetProto); }
+ Object *weakMapPrototype() const { return reinterpret_cast<Object *>(jsObjects + WeakMapProto); }
+ Object *mapPrototype() const { return reinterpret_cast<Object *>(jsObjects + MapProto); }
+ Object *intrinsicTypedArrayPrototype() const { return reinterpret_cast<Object *>(jsObjects + IntrinsicTypedArrayProto); }
Object *typedArrayPrototype;
Object *valueTypeWrapperPrototype() const { return reinterpret_cast<Object *>(jsObjects + ValueTypeProto); }
Object *signalHandlerPrototype() const { return reinterpret_cast<Object *>(jsObjects + SignalHandlerProto); }
+ Object *iteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + IteratorProto); }
+ Object *forInIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ForInIteratorProto); }
+ Object *setIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + SetIteratorProto); }
+ Object *mapIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + MapIteratorProto); }
+ Object *arrayIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + ArrayIteratorProto); }
+ Object *stringIteratorPrototype() const { return reinterpret_cast<Object *>(jsObjects + StringIteratorProto); }
- InternalClassPool *classPool;
EvalFunction *evalFunction() const { return reinterpret_cast<EvalFunction *>(jsObjects + Eval_Function); }
FunctionObject *getStackFunction() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetStack_Function); }
FunctionObject *thrower() const { return reinterpret_cast<FunctionObject *>(jsObjects + ThrowerObject); }
- Property *argumentsAccessors;
- int nArgumentsAccessors;
-
enum JSStrings {
String_Empty,
String_undefined,
@@ -273,6 +303,8 @@ public:
String_boolean,
String_number,
String_string,
+ String_default,
+ String_symbol,
String_object,
String_function,
String_length,
@@ -295,16 +327,46 @@ public:
String_index,
String_input,
String_toString,
+ String_toLocaleString,
String_destroy,
String_valueOf,
String_byteLength,
String_byteOffset,
String_buffer,
String_lastIndex,
+ String_next,
+ String_done,
+ String_return,
+ String_throw,
+ String_global,
+ String_ignoreCase,
+ String_multiline,
+ String_unicode,
+ String_sticky,
+ String_source,
+ String_flags,
+
NJSStrings
};
Value *jsStrings;
+ enum JSSymbols {
+ Symbol_hasInstance,
+ Symbol_isConcatSpreadable,
+ Symbol_iterator,
+ Symbol_match,
+ Symbol_replace,
+ Symbol_search,
+ Symbol_species,
+ Symbol_split,
+ Symbol_toPrimitive,
+ Symbol_toStringTag,
+ Symbol_unscopables,
+ Symbol_revokableProxy,
+ NJSSymbols
+ };
+ Value *jsSymbols;
+
String *id_empty() const { return reinterpret_cast<String *>(jsStrings + String_Empty); }
String *id_undefined() const { return reinterpret_cast<String *>(jsStrings + String_undefined); }
String *id_null() const { return reinterpret_cast<String *>(jsStrings + String_null); }
@@ -313,6 +375,8 @@ public:
String *id_boolean() const { return reinterpret_cast<String *>(jsStrings + String_boolean); }
String *id_number() const { return reinterpret_cast<String *>(jsStrings + String_number); }
String *id_string() const { return reinterpret_cast<String *>(jsStrings + String_string); }
+ String *id_default() const { return reinterpret_cast<String *>(jsStrings + String_default); }
+ String *id_symbol() const { return reinterpret_cast<String *>(jsStrings + String_symbol); }
String *id_object() const { return reinterpret_cast<String *>(jsStrings + String_object); }
String *id_function() const { return reinterpret_cast<String *>(jsStrings + String_function); }
String *id_length() const { return reinterpret_cast<String *>(jsStrings + String_length); }
@@ -335,12 +399,37 @@ public:
String *id_index() const { return reinterpret_cast<String *>(jsStrings + String_index); }
String *id_input() const { return reinterpret_cast<String *>(jsStrings + String_input); }
String *id_toString() const { return reinterpret_cast<String *>(jsStrings + String_toString); }
+ String *id_toLocaleString() const { return reinterpret_cast<String *>(jsStrings + String_toLocaleString); }
String *id_destroy() const { return reinterpret_cast<String *>(jsStrings + String_destroy); }
String *id_valueOf() const { return reinterpret_cast<String *>(jsStrings + String_valueOf); }
String *id_byteLength() const { return reinterpret_cast<String *>(jsStrings + String_byteLength); }
String *id_byteOffset() const { return reinterpret_cast<String *>(jsStrings + String_byteOffset); }
String *id_buffer() const { return reinterpret_cast<String *>(jsStrings + String_buffer); }
String *id_lastIndex() const { return reinterpret_cast<String *>(jsStrings + String_lastIndex); }
+ String *id_next() const { return reinterpret_cast<String *>(jsStrings + String_next); }
+ String *id_done() const { return reinterpret_cast<String *>(jsStrings + String_done); }
+ String *id_return() const { return reinterpret_cast<String *>(jsStrings + String_return); }
+ String *id_throw() const { return reinterpret_cast<String *>(jsStrings + String_throw); }
+ String *id_global() const { return reinterpret_cast<String *>(jsStrings + String_global); }
+ String *id_ignoreCase() const { return reinterpret_cast<String *>(jsStrings + String_ignoreCase); }
+ String *id_multiline() const { return reinterpret_cast<String *>(jsStrings + String_multiline); }
+ String *id_unicode() const { return reinterpret_cast<String *>(jsStrings + String_unicode); }
+ String *id_sticky() const { return reinterpret_cast<String *>(jsStrings + String_sticky); }
+ String *id_source() const { return reinterpret_cast<String *>(jsStrings + String_source); }
+ String *id_flags() const { return reinterpret_cast<String *>(jsStrings + String_flags); }
+
+ Symbol *symbol_hasInstance() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_hasInstance); }
+ Symbol *symbol_isConcatSpreadable() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_isConcatSpreadable); }
+ Symbol *symbol_iterator() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_iterator); }
+ Symbol *symbol_match() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_match); }
+ Symbol *symbol_replace() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_replace); }
+ Symbol *symbol_search() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_search); }
+ Symbol *symbol_species() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_species); }
+ Symbol *symbol_split() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_split); }
+ Symbol *symbol_toPrimitive() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_toPrimitive); }
+ Symbol *symbol_toStringTag() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_toStringTag); }
+ Symbol *symbol_unscopables() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_unscopables); }
+ Symbol *symbol_revokableProxy() const { return reinterpret_cast<Symbol *>(jsSymbols + Symbol_revokableProxy); }
#ifndef V4_BOOTSTRAP
QIntrusiveList<CompiledData::CompilationUnit, &CompiledData::CompilationUnit::nextCompilationUnit> compilationUnits;
@@ -372,9 +461,9 @@ public:
const bool m_canAllocateExecutableMemory;
#endif
- int internalClassIdCount = 0;
+ quintptr protoIdCount = 1;
- ExecutionEngine();
+ ExecutionEngine(QJSEngine *jsEngine = nullptr);
~ExecutionEngine();
#if !QT_CONFIG(qml_debug)
@@ -391,29 +480,28 @@ public:
void setProfiler(Profiling::Profiler *profiler);
#endif // QT_CONFIG(qml_debug)
- void setCurrentContext(Heap::ExecutionContext *context);
- ExecutionContext *currentContext() const {
- return static_cast<ExecutionContext *>(&currentStackFrame->jsFrame->context);
- }
+ ExecutionContext *currentContext() const;
- int newInternalClassId() { return ++internalClassIdCount; }
+ // ensure we always get odd prototype IDs. This helps make marking in QV4::Lookup fast
+ quintptr newProtoId() { return (protoIdCount += 2); }
- InternalClass *newInternalClass(const VTable *vtable, Object *prototype);
+ Heap::InternalClass *newInternalClass(const VTable *vtable, Object *prototype);
Heap::Object *newObject();
- Heap::Object *newObject(InternalClass *internalClass, Object *prototype);
+ Heap::Object *newObject(Heap::InternalClass *internalClass);
Heap::String *newString(const QString &s = QString());
Heap::String *newIdentifier(const QString &text);
Heap::Object *newStringObject(const String *string);
+ Heap::Object *newSymbolObject(const Symbol *symbol);
Heap::Object *newNumberObject(double value);
Heap::Object *newBooleanObject(bool b);
Heap::ArrayObject *newArrayObject(int count = 0);
Heap::ArrayObject *newArrayObject(const Value *values, int length);
Heap::ArrayObject *newArrayObject(const QStringList &list);
- Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype);
+ Heap::ArrayObject *newArrayObject(Heap::InternalClass *ic);
Heap::ArrayBuffer *newArrayBuffer(const QByteArray &array);
Heap::ArrayBuffer *newArrayBuffer(size_t length);
@@ -437,7 +525,10 @@ public:
Heap::Object *newVariantObject(const QVariant &v);
- Heap::Object *newForEachIteratorObject(Object *o);
+ Heap::Object *newForInIteratorObject(Object *o);
+ Heap::Object *newSetIteratorObject(Object *o);
+ Heap::Object *newMapIteratorObject(Object *o);
+ Heap::Object *newArrayIteratorObject(Object *o);
Heap::QmlContext *qmlContext() const;
QObject *qmlScopeObject() const;
@@ -447,13 +538,11 @@ public:
StackTrace stackTrace(int frameLimit = -1) const;
QUrl resolvedUrl(const QString &file);
- void requireArgumentsAccessors(int n);
-
void markObjects(MarkStack *markStack);
void initRootContext();
- InternalClass *newClass(const InternalClass &other);
+ Heap::InternalClass *newClass(Heap::InternalClass *other);
StackTrace exceptionStackTrace;
@@ -492,7 +581,7 @@ public:
if (!m_canAllocateExecutableMemory)
return false;
if (f)
- return f->interpreterCallCount >= jitCallCountThreshold;
+ return !f->isGenerator() && f->interpreterCallCount >= jitCallCountThreshold;
return true;
#else
Q_UNUSED(f);
@@ -502,6 +591,20 @@ public:
QV4::ReturnedValue global();
+ double localTZA = 0.0; // local timezone, initialized at startup
+
+ static QQmlRefPointer<CompiledData::CompilationUnit> compileModule(bool debugMode, const QString &url, const QString &sourceCode, const QDateTime &sourceTimeStamp, QList<QQmlJS::DiagnosticMessage> *diagnostics);
+#ifndef V4_BOOTSTRAP
+ QQmlRefPointer<CompiledData::CompilationUnit> compileModule(const QUrl &url);
+ QQmlRefPointer<CompiledData::CompilationUnit> compileModule(const QUrl &url, const QString &sourceCode, const QDateTime &sourceTimeStamp);
+
+ mutable QMutex moduleMutex;
+ QHash<QUrl, QQmlRefPointer<CompiledData::CompilationUnit>> modules;
+ void injectModule(const QQmlRefPointer<CompiledData::CompilationUnit> &moduleUnit);
+ QQmlRefPointer<CompiledData::CompilationUnit> moduleForUrl(const QUrl &_url, const CompiledData::CompilationUnit *referrer = nullptr) const;
+ QQmlRefPointer<CompiledData::CompilationUnit> loadModule(const QUrl &_url, const CompiledData::CompilationUnit *referrer = nullptr);
+#endif
+
private:
#if QT_CONFIG(qml_debug)
QScopedPointer<QV4::Debugging::Debugger> m_debugger;
@@ -521,11 +624,6 @@ struct NoThrowEngine;
#endif
-inline void ExecutionEngine::setCurrentContext(Heap::ExecutionContext *context)
-{
- currentStackFrame->jsFrame->context = context;
-}
-
#define CHECK_STACK_LIMITS(v4) if ((v4)->checkStackLimits()) return Encode::undefined(); \
ExecutionEngineCallDepthRecorder _executionEngineCallDepthRecorder(v4);
diff --git a/src/qml/jsruntime/qv4enginebase_p.h b/src/qml/jsruntime/qv4enginebase_p.h
index 59fb4a564a..b5cfea8863 100644
--- a/src/qml/jsruntime/qv4enginebase_p.h
+++ b/src/qml/jsruntime/qv4enginebase_p.h
@@ -72,9 +72,8 @@ struct Q_QML_EXPORT EngineBase {
quint8 hasException = false;
quint8 writeBarrierActive = false;
quint16 unused = 0;
-#if QT_POINTER_SIZE == 8
- quint8 padding[4];
-#endif
+ quint8 isExecutingInRegExpJIT = false;
+ quint8 padding[3];
MemoryManager *memoryManager = nullptr;
Runtime runtime;
@@ -88,7 +87,7 @@ struct Q_QML_EXPORT EngineBase {
// Exception handling
Value *exceptionValue = nullptr;
- enum {
+ enum InternalClassType {
Class_Empty,
Class_String,
Class_MemberData,
@@ -96,11 +95,19 @@ struct Q_QML_EXPORT EngineBase {
Class_SparseArrayData,
Class_ExecutionContext,
Class_CallContext,
+ Class_QmlContext,
Class_Object,
Class_ArrayObject,
Class_FunctionObject,
+ Class_ArrowFunction,
+ Class_GeneratorFunction,
+ Class_GeneratorObject,
Class_StringObject,
+ Class_SymbolObject,
Class_ScriptFunction,
+ Class_ConstructorFunction,
+ Class_MemberFunction,
+ Class_MemberGeneratorFunction,
Class_ObjectProto,
Class_RegExp,
Class_RegExpObject,
@@ -111,10 +118,13 @@ struct Q_QML_EXPORT EngineBase {
Class_ErrorObjectWithMessage,
Class_ErrorProto,
Class_QmlContextWrapper,
- Class_QmlContext,
+ Class_ProxyObject,
+ Class_ProxyFunctionObject,
+ Class_Symbol,
NClasses
};
- InternalClass *internalClasses[NClasses];
+ Heap::InternalClass *classes[NClasses];
+ Heap::InternalClass *internalClasses(InternalClassType icType) { return classes[icType]; }
};
#if defined(Q_CC_MSVC) || defined(Q_CC_GNU)
#pragma pack(pop)
@@ -124,7 +134,7 @@ Q_STATIC_ASSERT(std::is_standard_layout<EngineBase>::value);
Q_STATIC_ASSERT(offsetof(EngineBase, currentStackFrame) == 0);
Q_STATIC_ASSERT(offsetof(EngineBase, jsStackTop) == offsetof(EngineBase, currentStackFrame) + QT_POINTER_SIZE);
Q_STATIC_ASSERT(offsetof(EngineBase, hasException) == offsetof(EngineBase, jsStackTop) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(EngineBase, memoryManager) == offsetof(EngineBase, hasException) + QT_POINTER_SIZE);
+Q_STATIC_ASSERT(offsetof(EngineBase, memoryManager) == offsetof(EngineBase, hasException) + 8);
Q_STATIC_ASSERT(offsetof(EngineBase, runtime) == offsetof(EngineBase, memoryManager) + QT_POINTER_SIZE);
}
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index 90e158ba37..c6d6c77d11 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -47,10 +47,6 @@
#include "qv4string_p.h"
#include <private/qv4mm_p.h>
-#include <private/qqmljsengine_p.h>
-#include <private/qqmljslexer_p.h>
-#include <private/qqmljsparser_p.h>
-#include <private/qqmljsast_p.h>
#include <qv4codegen_p.h>
#ifndef Q_OS_WIN
@@ -74,13 +70,13 @@ void Heap::ErrorObject::init()
Scope scope(internalClass->engine);
Scoped<QV4::ErrorObject> e(scope, this);
- if (internalClass == scope.engine->internalClasses[EngineBase::Class_ErrorProto])
+ if (internalClass == scope.engine->internalClasses(EngineBase::Class_ErrorProto))
return;
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
- setProperty(scope.engine, QV4::ErrorObject::Index_FileName, Primitive::undefinedValue());
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_StackSetter, Value::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_FileName, Value::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::undefinedValue());
}
void Heap::ErrorObject::init(const Value &message, ErrorType t)
@@ -92,12 +88,12 @@ void Heap::ErrorObject::init(const Value &message, ErrorType t)
Scoped<QV4::ErrorObject> e(scope, this);
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_StackSetter, Value::undefinedValue());
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
if (!e->d()->stackTrace->isEmpty()) {
setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::fromInt32(e->d()->stackTrace->at(0).line));
}
if (!message.isUndefined())
@@ -114,7 +110,7 @@ void Heap::ErrorObject::init(const Value &message, const QString &fileName, int
Scoped<QV4::ErrorObject> e(scope, this);
setProperty(scope.engine, QV4::ErrorObject::Index_Stack, scope.engine->getStackFunction()->d());
- setProperty(scope.engine, QV4::ErrorObject::Index_Stack + QV4::Object::SetterOffset, Primitive::undefinedValue());
+ setProperty(scope.engine, QV4::ErrorObject::Index_StackSetter, Value::undefinedValue());
e->d()->stackTrace = new StackTrace(scope.engine->stackTrace());
StackFrame frame;
@@ -125,7 +121,7 @@ void Heap::ErrorObject::init(const Value &message, const QString &fileName, int
Q_ASSERT(!e->d()->stackTrace->isEmpty());
setProperty(scope.engine, QV4::ErrorObject::Index_FileName, scope.engine->newString(e->d()->stackTrace->at(0).source));
- setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Primitive::fromInt32(e->d()->stackTrace->at(0).line));
+ setProperty(scope.engine, QV4::ErrorObject::Index_LineNumber, Value::fromInt32(e->d()->stackTrace->at(0).line));
if (!message.isUndefined())
setProperty(scope.engine, QV4::ErrorObject::Index_Message, message);
@@ -233,81 +229,81 @@ void Heap::ErrorCtor::init(QV4::ExecutionContext *scope, const QString &name)
Heap::FunctionObject::init(scope, name);
}
-ReturnedValue ErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue ErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<ErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<ErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
-ReturnedValue ErrorCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue ErrorCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
return f->callAsConstructor(argv, argc);
}
void Heap::EvalErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("EvalError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("EvalError"));
}
-ReturnedValue EvalErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue EvalErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<EvalErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<EvalErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void Heap::RangeErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("RangeError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("RangeError"));
}
-ReturnedValue RangeErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue RangeErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<RangeErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<RangeErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void Heap::ReferenceErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("ReferenceError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("ReferenceError"));
}
-ReturnedValue ReferenceErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue ReferenceErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<ReferenceErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<ReferenceErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void Heap::SyntaxErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("SyntaxError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("SyntaxError"));
}
-ReturnedValue SyntaxErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue SyntaxErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<SyntaxErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<SyntaxErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void Heap::TypeErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("TypeError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("TypeError"));
}
-ReturnedValue TypeErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue TypeErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<TypeErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<TypeErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void Heap::URIErrorCtor::init(QV4::ExecutionContext *scope)
{
- Heap::ErrorCtor::init(scope, QStringLiteral("URIError"));
+ Heap::FunctionObject::init(scope, QStringLiteral("URIError"));
}
-ReturnedValue URIErrorCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue URIErrorCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- Value v = argc ? *argv : Primitive::undefinedValue();
- return ErrorObject::create<URIErrorObject>(f->engine(), v)->asReturnedValue();
+ Value v = argc ? *argv : Value::undefinedValue();
+ return ErrorObject::create<URIErrorObject>(f->engine(), v, newTarget)->asReturnedValue();
}
void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj, Heap::ErrorObject::ErrorType t)
@@ -316,7 +312,7 @@ void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj, He
ScopedString s(scope);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = obj));
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
obj->setProperty(Index_Constructor, ctor->d());
obj->setProperty(Index_Message, engine->id_empty()->d());
obj->setProperty(Index_Name, engine->newString(QString::fromLatin1(ErrorObject::className(t))));
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index 6b578e8c38..139bcc9754 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -115,7 +115,7 @@ struct URIErrorObject : ErrorObject {
void init(const Value &message);
};
-struct ErrorCtor : Heap::FunctionObject {
+struct ErrorCtor : FunctionObject {
void init(QV4::ExecutionContext *scope);
void init(QV4::ExecutionContext *scope, const QString &name);
};
@@ -153,6 +153,7 @@ struct ErrorObject: Object {
enum {
Index_Stack = 0, // Accessor Property
+ Index_StackSetter = 1, // Accessor Property
Index_FileName = 2,
Index_LineNumber = 3,
Index_Message = 4
@@ -165,7 +166,7 @@ struct ErrorObject: Object {
V4_NEEDS_DESTROY
template <typename T>
- static Heap::Object *create(ExecutionEngine *e, const Value &message);
+ static Heap::Object *create(ExecutionEngine *e, const Value &message, const Value *newTarget);
template <typename T>
static Heap::Object *create(ExecutionEngine *e, const QString &message);
template <typename T>
@@ -180,7 +181,7 @@ struct ErrorObject: Object {
template<>
inline const ErrorObject *Value::as() const {
- return isManaged() && m()->vtable()->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : nullptr;
+ return isManaged() && m()->internalClass->vtable->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : nullptr;
}
struct EvalErrorObject: ErrorObject {
@@ -229,54 +230,60 @@ struct ErrorCtor: FunctionObject
{
V4_OBJECT2(ErrorCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
struct EvalErrorCtor: ErrorCtor
{
- V4_OBJECT2(EvalErrorCtor, ErrorCtor)
+ V4_OBJECT2(EvalErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
struct RangeErrorCtor: ErrorCtor
{
- V4_OBJECT2(RangeErrorCtor, ErrorCtor)
+ V4_OBJECT2(RangeErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
struct ReferenceErrorCtor: ErrorCtor
{
- V4_OBJECT2(ReferenceErrorCtor, ErrorCtor)
+ V4_OBJECT2(ReferenceErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
struct SyntaxErrorCtor: ErrorCtor
{
- V4_OBJECT2(SyntaxErrorCtor, ErrorCtor)
+ V4_OBJECT2(SyntaxErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
struct TypeErrorCtor: ErrorCtor
{
- V4_OBJECT2(TypeErrorCtor, ErrorCtor)
+ V4_OBJECT2(TypeErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
struct URIErrorCtor: ErrorCtor
{
- V4_OBJECT2(URIErrorCtor, ErrorCtor)
+ V4_OBJECT2(URIErrorCtor, FunctionObject)
+ V4_PROTOTYPE(errorCtor)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
};
-struct ErrorPrototype : ErrorObject
+struct ErrorPrototype : Object
{
enum {
Index_Constructor = 0,
@@ -289,32 +296,32 @@ struct ErrorPrototype : ErrorObject
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
-struct EvalErrorPrototype : ErrorObject
+struct EvalErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::EvalError); }
};
-struct RangeErrorPrototype : ErrorObject
+struct RangeErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::RangeError); }
};
-struct ReferenceErrorPrototype : ErrorObject
+struct ReferenceErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::ReferenceError); }
};
-struct SyntaxErrorPrototype : ErrorObject
+struct SyntaxErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::SyntaxError); }
};
-struct TypeErrorPrototype : ErrorObject
+struct TypeErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::TypeError); }
};
-struct URIErrorPrototype : ErrorObject
+struct URIErrorPrototype : Object
{
void init(ExecutionEngine *engine, Object *ctor) { ErrorPrototype::init(engine, ctor, this, Heap::ErrorObject::URIError); }
};
@@ -327,26 +334,28 @@ inline SyntaxErrorObject *ErrorObject::asSyntaxError()
template <typename T>
-Heap::Object *ErrorObject::create(ExecutionEngine *e, const Value &message) {
- InternalClass *ic = e->internalClasses[message.isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage];
- ic = ic->changePrototype(T::defaultPrototype(e)->d());
- return e->memoryManager->allocObject<T>(ic, T::defaultPrototype(e), message);
+Heap::Object *ErrorObject::create(ExecutionEngine *e, const Value &message, const Value *newTarget) {
+ EngineBase::InternalClassType klass = message.isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage;
+ Scope scope(e);
+ ScopedObject proto(scope, static_cast<const Object *>(newTarget)->get(scope.engine->id_prototype()));
+ Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(proto->d()));
+ return e->memoryManager->allocObject<T>(ic->d(), message);
}
template <typename T>
Heap::Object *ErrorObject::create(ExecutionEngine *e, const QString &message) {
Scope scope(e);
ScopedValue v(scope, message.isEmpty() ? Encode::undefined() : e->newString(message)->asReturnedValue());
- InternalClass *ic = e->internalClasses[v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage];
- ic = ic->changePrototype(T::defaultPrototype(e)->d());
- return e->memoryManager->allocObject<T>(ic, T::defaultPrototype(e), v);
+ EngineBase::InternalClassType klass = v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage;
+ Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d()));
+ return e->memoryManager->allocObject<T>(ic->d(), v);
}
template <typename T>
Heap::Object *ErrorObject::create(ExecutionEngine *e, const QString &message, const QString &filename, int line, int column) {
Scope scope(e);
ScopedValue v(scope, message.isEmpty() ? Encode::undefined() : e->newString(message)->asReturnedValue());
- InternalClass *ic = e->internalClasses[v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage];
- ic = ic->changePrototype(T::defaultPrototype(e)->d());
- return e->memoryManager->allocObject<T>(ic, T::defaultPrototype(e), v, filename, line, column);
+ EngineBase::InternalClassType klass = v->isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage;
+ Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d()));
+ return e->memoryManager->allocObject<T>(ic->d(), v, filename, line, column);
}
diff --git a/src/qml/jsruntime/qv4estable.cpp b/src/qml/jsruntime/qv4estable.cpp
new file mode 100644
index 0000000000..99f6bf6aa0
--- /dev/null
+++ b/src/qml/jsruntime/qv4estable.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4estable_p.h"
+#include "qv4object_p.h"
+
+using namespace QV4;
+
+// The ES spec requires that Map/Set be implemented using a data structure that
+// is a little different from most; it requires nonlinear access, and must also
+// preserve the order of insertion of items in a deterministic way.
+//
+// This class implements those requirements, except for fast access: that
+// will be addressed in a followup patch.
+
+ESTable::ESTable()
+ : m_capacity(8)
+{
+ m_keys = (Value*)malloc(m_capacity * sizeof(Value));
+ m_values = (Value*)malloc(m_capacity * sizeof(Value));
+ memset(m_keys, 0, m_capacity);
+ memset(m_values, 0, m_capacity);
+}
+
+ESTable::~ESTable()
+{
+ free(m_keys);
+ free(m_values);
+ m_size = 0;
+ m_capacity = 0;
+ m_keys = nullptr;
+ m_values = nullptr;
+}
+
+void ESTable::markObjects(MarkStack *s, bool isWeakMap)
+{
+ for (uint i = 0; i < m_size; ++i) {
+ if (!isWeakMap)
+ m_keys[i].mark(s);
+ m_values[i].mark(s);
+ }
+}
+
+// Pretends that there's nothing in the table. Doesn't actually free memory, as
+// it will almost certainly be reused again anyway.
+void ESTable::clear()
+{
+ m_size = 0;
+}
+
+// Update the table to contain \a value for a given \a key. The key is
+// normalized, as required by the ES spec.
+void ESTable::set(const Value &key, const Value &value)
+{
+ for (uint i = 0; i < m_size; ++i) {
+ if (m_keys[i].sameValueZero(key)) {
+ m_values[i] = value;
+ return;
+ }
+ }
+
+ if (m_capacity == m_size) {
+ uint oldCap = m_capacity;
+ m_capacity *= 2;
+ m_keys = (Value*)realloc(m_keys, m_capacity * sizeof(Value));
+ m_values = (Value*)realloc(m_values, m_capacity * sizeof(Value));
+ memset(m_keys + oldCap, 0, m_capacity - oldCap);
+ memset(m_values + oldCap, 0, m_capacity - oldCap);
+ }
+
+ Value nk = key;
+ if (nk.isDouble()) {
+ if (nk.doubleValue() == 0 && std::signbit(nk.doubleValue()))
+ nk = Value::fromDouble(+0);
+ }
+
+ m_keys[m_size] = nk;
+ m_values[m_size] = value;
+
+ m_size++;
+}
+
+// Returns true if the table contains \a key, false otherwise.
+bool ESTable::has(const Value &key) const
+{
+ for (uint i = 0; i < m_size; ++i) {
+ if (m_keys[i].sameValueZero(key))
+ return true;
+ }
+
+ return false;
+}
+
+// Fetches the value for the given \a key, and if \a hasValue is passed in,
+// it is set depending on whether or not the given key was found.
+ReturnedValue ESTable::get(const Value &key, bool *hasValue) const
+{
+ for (uint i = 0; i < m_size; ++i) {
+ if (m_keys[i].sameValueZero(key)) {
+ if (hasValue)
+ *hasValue = true;
+ return m_values[i].asReturnedValue();
+ }
+ }
+
+ if (hasValue)
+ *hasValue = false;
+ return Encode::undefined();
+}
+
+// Removes the given \a key from the table
+bool ESTable::remove(const Value &key)
+{
+ bool found = false;
+ uint idx = 0;
+ for (; idx < m_size; ++idx) {
+ if (m_keys[idx].sameValueZero(key)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found == true) {
+ memmove(m_keys + idx, m_keys + idx + 1, (m_size - idx)*sizeof(Value));
+ memmove(m_values + idx, m_values + idx + 1, (m_size - idx)*sizeof(Value));
+ m_size--;
+ }
+ return found;
+}
+
+// Returns the size of the table. Note that the size may not match the underlying allocation.
+uint ESTable::size() const
+{
+ return m_size;
+}
+
+// Retrieves a key and value for a given \a idx, and places them in \a key and
+// \a value. They must be valid pointers.
+void ESTable::iterate(uint idx, Value *key, Value *value)
+{
+ Q_ASSERT(idx < m_size);
+ Q_ASSERT(key);
+ Q_ASSERT(value);
+ *key = m_keys[idx];
+ *value = m_values[idx];
+}
+
+void ESTable::removeUnmarkedKeys()
+{
+ uint idx = 0;
+ uint toIdx = 0;
+ for (; idx < m_size; ++idx) {
+ Q_ASSERT(m_keys[idx].isObject());
+ Object &o = static_cast<Object &>(m_keys[idx]);
+ if (o.d()->isMarked()) {
+ m_keys[toIdx] = m_keys[idx];
+ m_values[toIdx] = m_values[idx];
+ ++toIdx;
+ }
+ }
+ m_size = toIdx;
+}
+
diff --git a/src/qml/jsruntime/qv4estable_p.h b/src/qml/jsruntime/qv4estable_p.h
new file mode 100644
index 0000000000..f54fc37a7b
--- /dev/null
+++ b/src/qml/jsruntime/qv4estable_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QV4ESTABLE_P_H
+#define QV4ESTABLE_P_H
+
+#include "qv4value_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4
+{
+
+class ESTable
+{
+public:
+ ESTable();
+ ~ESTable();
+
+ void markObjects(MarkStack *s, bool isWeakMap);
+ void clear();
+ void set(const Value &k, const Value &v);
+ bool has(const Value &k) const;
+ ReturnedValue get(const Value &k, bool *hasValue = nullptr) const;
+ bool remove(const Value &k);
+ uint size() const;
+ void iterate(uint idx, Value *k, Value *v);
+
+ void removeUnmarkedKeys();
+
+private:
+ Value *m_keys = nullptr;
+ Value *m_values = nullptr;
+ uint m_size = 0;
+ uint m_capacity = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 6fca9ecd45..941c37de5b 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -47,32 +47,51 @@
#include <private/qv4mm_p.h>
#include <private/qv4identifiertable_p.h>
#include <assembler/MacroAssemblerCodeRef.h>
+#include <private/qv4vme_moth_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
using namespace QV4;
-Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Code codePtr)
- : compiledFunction(function)
- , compilationUnit(unit)
- , code(codePtr)
- , codeData(function->code())
+ReturnedValue Function::call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) {
+ ExecutionEngine *engine = context->engine();
+ CppStackFrame frame;
+ frame.init(engine, this, argv, argc);
+ frame.setupJSFrame(engine->jsStackTop, Value::undefinedValue(), context->d(),
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
+
+ frame.push();
+ engine->jsStackTop += frame.requiredJSStackFrameSize();
+
+ ReturnedValue result = Moth::VME::exec(&frame, engine);
+
+ frame.pop();
+
+ return result;
+}
+
+Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function)
+ : compiledFunction(function)
+ , compilationUnit(unit)
+ , codeData(function->code())
, jittedCode(nullptr)
, codeRef(nullptr)
, hasQmlDependencies(function->hasQmlDependencies())
{
- Q_UNUSED(engine);
-
- internalClass = engine->internalClasses[EngineBase::Class_CallContext];
+ Scope scope(engine);
+ Scoped<InternalClass> ic(scope, engine->internalClasses(EngineBase::Class_CallContext));
// first locals
const quint32_le *localsIndices = compiledFunction->localsTable();
for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
- internalClass = internalClass->addMember(engine->identifierTable->identifier(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
+ ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
const quint32_le *formalsIndices = compiledFunction->formalsTable();
for (quint32 i = 0; i < compiledFunction->nFormals; ++i)
- internalClass = internalClass->addMember(engine->identifierTable->identifier(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable);
+ ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable);
+ internalClass = ic->d();
nFormals = compiledFunction->nFormals;
}
@@ -110,20 +129,25 @@ void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArr
}
- internalClass = engine->internalClasses[EngineBase::Class_CallContext];
+ internalClass = engine->internalClasses(EngineBase::Class_CallContext);
// first locals
const quint32_le *localsIndices = compiledFunction->localsTable();
for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
- internalClass = internalClass->addMember(engine->identifierTable->identifier(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
+ internalClass = internalClass->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable);
Scope scope(engine);
ScopedString arg(scope);
for (const QString &parameterName : parameterNames) {
- arg = engine->newString(parameterName);
- internalClass = internalClass->addMember(arg, Attr_NotConfigurable);
+ arg = engine->newIdentifier(parameterName);
+ internalClass = internalClass->addMember(arg->propertyKey(), Attr_NotConfigurable);
}
nFormals = parameters.size();
}
+QQmlSourceLocation Function::sourceLocation() const
+{
+ return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 59a94e5dde..029dd7786b 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -51,10 +51,8 @@
//
#include "qv4global_p.h"
-#include <private/qqmlglobal_p.h>
#include <private/qv4compileddata_p.h>
#include <private/qv4context_p.h>
-#include <private/qv4vme_moth_p.h>
namespace JSC {
class MacroAssemblerCodeRef;
@@ -62,31 +60,30 @@ class MacroAssemblerCodeRef;
QT_BEGIN_NAMESPACE
+struct QQmlSourceLocation;
+
namespace QV4 {
struct Q_QML_EXPORT Function {
const CompiledData::Function *compiledFunction;
CompiledData::CompilationUnit *compilationUnit;
- ReturnedValue call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) {
- return Moth::VME::exec(this, thisObject, argv, argc, context);
- }
+ ReturnedValue call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context);
- typedef ReturnedValue (*Code)(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc);
- Code code;
- const uchar *codeData;
+ const char *codeData;
typedef ReturnedValue (*JittedCode)(CppStackFrame *, ExecutionEngine *);
JittedCode jittedCode;
JSC::MacroAssemblerCodeRef *codeRef;
// first nArguments names in internalClass are the actual arguments
- InternalClass *internalClass;
+ Heap::InternalClass *internalClass;
uint nFormals;
int interpreterCallCount = 0;
bool hasQmlDependencies;
+ bool isEval = false;
- Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Code codePtr);
+ Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
~Function();
// used when dynamically assigning signal handlers (QQmlConnection)
@@ -98,13 +95,11 @@ struct Q_QML_EXPORT Function {
inline QString sourceFile() const { return compilationUnit->fileName(); }
inline QUrl finalUrl() const { return compilationUnit->finalUrl(); }
- inline bool usesArgumentsObject() const { return compiledFunction->flags & CompiledData::Function::UsesArgumentsObject; }
inline bool isStrict() const { return compiledFunction->flags & CompiledData::Function::IsStrict; }
+ inline bool isArrowFunction() const { return compiledFunction->flags & CompiledData::Function::IsArrowFunction; }
+ inline bool isGenerator() const { return compiledFunction->flags & CompiledData::Function::IsGenerator; }
- QQmlSourceLocation sourceLocation() const
- {
- return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
- }
+ QQmlSourceLocation sourceLocation() const;
Function *nestedFunction() const
{
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 83608070ec..f6b279ddaf 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -41,6 +41,7 @@
#include "qv4objectproto_p.h"
#include "qv4stringobject_p.h"
#include "qv4function_p.h"
+#include "qv4symbol_p.h"
#include <private/qv4mm_p.h>
#include "qv4arrayobject_p.h"
@@ -57,6 +58,7 @@
#include "private/qlocale_tools_p.h"
#include "private/qqmlbuiltinfunctions_p.h"
#include <private/qv4jscall_p.h>
+#include <private/qv4vme_moth_p.h>
#include <QtCore/QDebug>
#include <algorithm>
@@ -68,61 +70,65 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(FunctionObject);
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name,
- ReturnedValue (*code)(const QV4::FunctionObject *, const Value *thisObject, const Value *argv, int argc))
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, VTable::Call call)
{
- jsCall = code;
- jsConstruct = QV4::FunctionObject::callAsConstructor;
+ jsCall = call;
+ jsConstruct = nullptr;
Object::init();
this->scope.set(scope->engine(), scope->d());
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
- f->init(name, false);
+ if (name)
+ f->setName(name);
}
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name)
{
- jsCall = reinterpret_cast<const ObjectVTable *>(vtable())->call;
- jsConstruct = reinterpret_cast<const ObjectVTable *>(vtable())->callAsConstructor;
+ ExecutionEngine *e = scope->engine();
+
+ jsCall = vtable()->call;
+ jsConstruct = vtable()->callAsConstructor;
Object::init();
this->scope.set(scope->engine(), scope->d());
- Scope s(scope->engine());
+ Scope s(e);
ScopedFunctionObject f(s, this);
- f->init(name, createProto);
+ if (name)
+ f->setName(name);
}
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto)
+
+
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, QV4::String *n)
{
- jsCall = reinterpret_cast<const ObjectVTable *>(vtable())->call;
- jsConstruct = reinterpret_cast<const ObjectVTable *>(vtable())->callAsConstructor;
+ jsCall = vtable()->call;
+ jsConstruct = vtable()->callAsConstructor;
Object::init();
setFunction(function);
this->scope.set(scope->engine(), scope->d());
Scope s(scope->engine());
- ScopedString name(s, function->name());
+ ScopedString name(s, n ? n->d() : function->name());
ScopedFunctionObject f(s, this);
- f->init(name, createProto);
+ if (name)
+ f->setName(name);
}
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto)
+void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name)
{
Scope valueScope(scope);
ScopedString s(valueScope, valueScope.engine->newString(name));
- init(scope, s, createProto);
+ init(scope, s);
}
void Heap::FunctionObject::init()
{
- jsCall = reinterpret_cast<const ObjectVTable *>(vtable())->call;
- jsConstruct = reinterpret_cast<const ObjectVTable *>(vtable())->callAsConstructor;
+ jsCall = vtable()->call;
+ jsConstruct = vtable()->callAsConstructor;
Object::init();
this->scope.set(internalClass->engine, internalClass->engine->rootContext()->d());
- Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype);
- setProperty(internalClass->engine, Index_Prototype, Primitive::undefinedValue());
}
void Heap::FunctionObject::setFunction(Function *f)
@@ -139,23 +145,15 @@ void Heap::FunctionObject::destroy()
Object::destroy();
}
-void FunctionObject::init(String *n, bool createProto)
+void FunctionObject::createDefaultPrototypeProperty(uint protoConstructorSlot)
{
- Scope s(internalClass()->engine);
- ScopedValue protectThis(s, this);
+ Scope s(this);
- Q_ASSERT(internalClass() && internalClass()->find(s.engine->id_prototype()) == Heap::FunctionObject::Index_Prototype);
- if (createProto) {
- ScopedObject proto(s, s.engine->newObject(s.engine->internalClasses[EngineBase::Class_ObjectProto], s.engine->objectPrototype()));
- Q_ASSERT(s.engine->internalClasses[EngineBase::Class_ObjectProto]->find(s.engine->id_constructor()) == Heap::FunctionObject::Index_ProtoConstructor);
- proto->setProperty(Heap::FunctionObject::Index_ProtoConstructor, d());
- setProperty(Heap::FunctionObject::Index_Prototype, proto);
- } else {
- setProperty(Heap::FunctionObject::Index_Prototype, Primitive::undefinedValue());
- }
+ Q_ASSERT(s.engine->internalClasses(EngineBase::Class_ObjectProto)->verifyIndex(s.engine->id_constructor()->propertyKey(), protoConstructorSlot));
- if (n)
- defineReadonlyConfigurableProperty(s.engine->id_name(), *n);
+ ScopedObject proto(s, s.engine->newObject(s.engine->internalClasses(EngineBase::Class_ObjectProto)));
+ proto->setProperty(protoConstructorSlot, d());
+ defineDefaultProperty(s.engine->id_prototype(), proto, Attr_NotEnumerable|Attr_NotConfigurable);
}
ReturnedValue FunctionObject::name() const
@@ -163,29 +161,59 @@ ReturnedValue FunctionObject::name() const
return get(scope()->internalClass->engine->id_name());
}
-ReturnedValue FunctionObject::callAsConstructor(const FunctionObject *f, const Value *, int)
+ReturnedValue FunctionObject::virtualCall(const FunctionObject *, const Value *, const Value *, int)
{
- return f->engine()->throwTypeError();
+ return Encode::undefined();
}
-ReturnedValue FunctionObject::call(const FunctionObject *, const Value *, const Value *, int)
+Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function)
{
- return Encode::undefined();
+ if (function->isArrowFunction())
+ return scope->engine()->memoryManager->allocate<ArrowFunction>(scope, function);
+ return scope->engine()->memoryManager->allocate<ScriptFunction>(scope, function);
}
-Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function)
+Heap::FunctionObject *FunctionObject::createConstructorFunction(ExecutionContext *scope, Function *function, Object *homeObject, bool isDerivedConstructor)
+{
+ if (!function) {
+ Heap::DefaultClassConstructorFunction *c = scope->engine()->memoryManager->allocate<DefaultClassConstructorFunction>(scope);
+ c->isDerivedConstructor = isDerivedConstructor;
+ return c;
+ }
+ Heap::ConstructorFunction *c = scope->engine()->memoryManager->allocate<ConstructorFunction>(scope, function);
+ c->homeObject.set(scope->engine(), homeObject->d());
+ c->isDerivedConstructor = isDerivedConstructor;
+ return c;
+}
+
+Heap::FunctionObject *FunctionObject::createMemberFunction(ExecutionContext *scope, Function *function, Object *homeObject, QV4::String *name)
{
- return scope->engine()->memoryManager->allocObject<ScriptFunction>(scope, function);
+ Heap::MemberFunction *m = scope->engine()->memoryManager->allocate<MemberFunction>(scope, function, name);
+ m->homeObject.set(scope->engine(), homeObject->d());
+ return m;
}
-bool FunctionObject::isBinding() const
+Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, VTable::Call code, int argumentCount)
{
- return d()->vtable() == QQmlBindingFunction::staticVTable();
+ Scope scope(engine);
+ ScopedString name(scope, nameOrSymbol);
+ if (!name)
+ name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']'));
+
+ ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code));
+ function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount));
+ return function->d();
}
-bool FunctionObject::isBoundFunction() const
+ReturnedValue FunctionObject::getHomeObject() const
{
- return d()->vtable() == BoundFunction::staticVTable();
+ const MemberFunction *m = as<MemberFunction>();
+ if (m)
+ return m->d()->homeObject->asReturnedValue();
+ const ConstructorFunction *c = as<ConstructorFunction>();
+ if (c)
+ return c->d()->homeObject->asReturnedValue();
+ return Encode::undefined();
}
QQmlSourceLocation FunctionObject::sourceLocation() const
@@ -201,10 +229,8 @@ void Heap::FunctionCtor::init(QV4::ExecutionContext *scope)
}
// 15.3.2
-ReturnedValue FunctionCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+QQmlRefPointer<CompiledData::CompilationUnit> FunctionCtor::parse(ExecutionEngine *engine, const Value *argv, int argc, Type t)
{
- Scope scope(f->engine());
-
QString arguments;
QString body;
if (argc > 0) {
@@ -215,42 +241,58 @@ ReturnedValue FunctionCtor::callAsConstructor(const FunctionObject *f, const Val
}
body = argv[argc - 1].toQString();
}
- if (scope.engine->hasException)
- return Encode::undefined();
+ if (engine->hasException)
+ return nullptr;
- QString function = QLatin1String("function(") + arguments + QLatin1String("){") + body + QLatin1Char('}');
+ QString function = (t == Type_Function ? QLatin1String("function anonymous(") : QLatin1String("function* anonymous(")) + arguments + QLatin1String("\n){") + body + QLatin1String("\n}");
- QQmlJS::Engine ee, *engine = &ee;
- QQmlJS::Lexer lexer(engine);
+ QQmlJS::Engine ee;
+ QQmlJS::Lexer lexer(&ee);
lexer.setCode(function, 1, false);
- QQmlJS::Parser parser(engine);
+ QQmlJS::Parser parser(&ee);
const bool parsed = parser.parseExpression();
- if (!parsed)
- return scope.engine->throwSyntaxError(QLatin1String("Parse error"));
+ if (!parsed) {
+ engine->throwSyntaxError(QLatin1String("Parse error"));
+ return nullptr;
+ }
QQmlJS::AST::FunctionExpression *fe = QQmlJS::AST::cast<QQmlJS::AST::FunctionExpression *>(parser.rootNode());
- if (!fe)
- return scope.engine->throwSyntaxError(QLatin1String("Parse error"));
+ if (!fe) {
+ engine->throwSyntaxError(QLatin1String("Parse error"));
+ return nullptr;
+ }
- Compiler::Module module(scope.engine->debugger() != nullptr);
+ Compiler::Module module(engine->debugger() != nullptr);
Compiler::JSUnitGenerator jsGenerator(&module);
- RuntimeCodegen cg(scope.engine, &jsGenerator, false);
+ RuntimeCodegen cg(engine, &jsGenerator, false);
cg.generateFromFunctionExpression(QString(), function, fe, &module);
- QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = cg.generateCompilationUnit();
- Function *vmf = compilationUnit->linkToEngine(scope.engine);
+ if (engine->hasException)
+ return nullptr;
+
+ return cg.generateCompilationUnit();
+}
- ExecutionContext *global = scope.engine->rootContext();
+ReturnedValue FunctionCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
+{
+ ExecutionEngine *engine = f->engine();
+
+ QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = parse(engine, argv, argc, Type_Function);
+ if (engine->hasException)
+ return Encode::undefined();
+
+ Function *vmf = compilationUnit->linkToEngine(engine);
+ ExecutionContext *global = engine->scriptContext();
return Encode(FunctionObject::createScriptFunction(global, vmf));
}
// 15.3.1: This is equivalent to new Function(...)
-ReturnedValue FunctionCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue FunctionCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- return callAsConstructor(f, argv, argc);
+ return virtualCallAsConstructor(f, argv, argc, f);
}
DEFINE_OBJECT_VTABLE(FunctionPrototype);
@@ -265,16 +307,17 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(0));
+ defineReadonlyConfigurableProperty(engine->id_name(), *engine->id_empty());
+ defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("apply"), method_apply, 2);
defineDefaultProperty(QStringLiteral("call"), method_call, 1);
defineDefaultProperty(QStringLiteral("bind"), method_bind, 1);
-
+ defineDefaultProperty(engine->symbol_hasInstance(), method_hasInstance, 1, Attr_ReadOnly);
}
ReturnedValue FunctionPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -284,7 +327,19 @@ ReturnedValue FunctionPrototype::method_toString(const FunctionObject *b, const
if (!fun)
return v4->throwTypeError();
- return Encode(v4->newString(QStringLiteral("function() { [code] }")));
+ const Scope scope(fun->engine());
+ const ScopedString scopedFunctionName(scope, fun->name());
+ const QString functionName(scopedFunctionName ? scopedFunctionName->toQString() : QString());
+ QString functionAsString = QStringLiteral("function");
+
+ // If fun->name() is empty, then there is no function name
+ // to append because the function is anonymous.
+ if (!functionName.isEmpty())
+ functionAsString.append(QLatin1Char(' ') + functionName);
+
+ functionAsString.append(QStringLiteral("() { [native code] }"));
+
+ return Encode(v4->newString(functionAsString));
}
ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -304,14 +359,14 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
uint len = arr->getLength();
Scope scope(v4);
- Value *arguments = v4->jsAlloca(len);
+ Value *arguments = scope.alloc<Scope::Uninitialized>(len);
if (len) {
if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast<ArgumentsObject>()->fullyCreated()) {
QV4::ArgumentsObject *a = arr->cast<ArgumentsObject>();
int l = qMin(len, (uint)a->d()->context->argc());
memcpy(arguments, a->d()->context->args(), l*sizeof(Value));
for (quint32 i = l; i < len; ++i)
- arguments[i] = Primitive::undefinedValue();
+ arguments[i] = Value::undefinedValue();
} else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) {
auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData());
uint alen = sad ? sad->values.size : 0;
@@ -320,10 +375,12 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
for (uint i = 0; i < alen; ++i)
arguments[i] = sad->data(i);
for (quint32 i = alen; i < len; ++i)
- arguments[i] = Primitive::undefinedValue();
+ arguments[i] = Value::undefinedValue();
} else {
+ // need to init the arguments array, as the get() calls below can have side effects
+ memset(arguments, 0, len*sizeof(Value));
for (quint32 i = 0; i < len; ++i)
- arguments[i] = arr->getIndexed(i);
+ arguments[i] = arr->get(i);
}
}
@@ -352,7 +409,7 @@ ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Valu
if (!target || target->isBinding())
return scope.engine->throwTypeError();
- ScopedValue boundThis(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue boundThis(scope, argc ? argv[0] : Value::undefinedValue());
Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)nullptr);
int nArgs = (argc - 1 >= 0) ? argc - 1 : 0;
@@ -383,18 +440,50 @@ ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Valu
return bound->asReturnedValue();
}
+ReturnedValue FunctionPrototype::method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
+{
+ if (!argc)
+ return Encode(false);
+ const Object *o = thisObject->as<Object>();
+ if (!o)
+ return Encode(false);
+
+ return Object::virtualInstanceOf(o, argv[0]);
+}
+
DEFINE_OBJECT_VTABLE(ScriptFunction);
-ReturnedValue ScriptFunction::callAsConstructor(const FunctionObject *fo, const Value *argv, int argc)
+ReturnedValue ScriptFunction::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *newTarget)
{
ExecutionEngine *v4 = fo->engine();
const ScriptFunction *f = static_cast<const ScriptFunction *>(fo);
+ Q_ASSERT(newTarget->isFunctionObject());
+ const FunctionObject *nt = static_cast<const FunctionObject *>(newTarget);
Scope scope(v4);
- InternalClass *ic = f->classForConstructor();
+ Scoped<InternalClass> ic(scope);
+ if (nt->d() == f->d()) {
+ ic = f->classForConstructor();
+ } else {
+ ScopedObject o(scope, nt->protoProperty());
+ ic = scope.engine->internalClasses(EngineBase::Class_Object);
+ if (o)
+ ic = ic->changePrototype(o->d());
+ }
ScopedValue thisObject(scope, v4->memoryManager->allocObject<Object>(ic));
- ReturnedValue result = Moth::VME::exec(fo, thisObject, argv, argc);
+ CppStackFrame frame;
+ frame.init(v4, f->function(), argv, argc);
+ frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
+ thisObject,
+ newTarget ? *newTarget : Value::undefinedValue());
+
+ frame.push();
+ v4->jsStackTop += frame.requiredJSStackFrameSize();
+
+ ReturnedValue result = Moth::VME::exec(&frame, v4);
+
+ frame.pop();
if (Q_UNLIKELY(v4->hasException))
return Encode::undefined();
@@ -403,50 +492,169 @@ ReturnedValue ScriptFunction::callAsConstructor(const FunctionObject *fo, const
return result;
}
-ReturnedValue ScriptFunction::call(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc)
+DEFINE_OBJECT_VTABLE(ArrowFunction);
+
+ReturnedValue ArrowFunction::virtualCall(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc)
{
- return Moth::VME::exec(fo, thisObject, argv, argc);
+ ExecutionEngine *engine = fo->engine();
+ CppStackFrame frame;
+ frame.init(engine, fo->function(), argv, argc);
+ frame.setupJSFrame(engine->jsStackTop, *fo, fo->scope(),
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
+
+ frame.push();
+ engine->jsStackTop += frame.requiredJSStackFrameSize();
+
+ ReturnedValue result = Moth::VME::exec(&frame, engine);
+
+ frame.pop();
+
+ return result;
}
-void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
+void Heap::ArrowFunction::init(QV4::ExecutionContext *scope, Function *function, QV4::String *n)
{
FunctionObject::init();
this->scope.set(scope->engine(), scope->d());
setFunction(function);
Q_ASSERT(function);
- Q_ASSERT(function->code);
Scope s(scope);
ScopedFunctionObject f(s, this);
- ScopedString name(s, function->name());
- f->init(name, true);
- Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length);
- setProperty(s.engine, Index_Length, Primitive::fromInt32(f->formalParameterCount()));
-
- if (function->isStrict()) {
- ScopedProperty pd(s);
- pd->value = s.engine->thrower();
- pd->set = s.engine->thrower();
- f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- f->insertMember(s.engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ ScopedString name(s, n ? n->d() : function->name());
+ if (name)
+ f->setName(name);
+
+ Q_ASSERT(internalClass && internalClass->verifyIndex(s.engine->id_length()->propertyKey(), Index_Length));
+ setProperty(s.engine, Index_Length, Value::fromInt32(int(function->compiledFunction->length)));
+}
+
+void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
+{
+ ArrowFunction::init(scope, function);
+ Q_ASSERT(!function->isArrowFunction());
+
+ Scope s(scope);
+ ScopedFunctionObject f(s, this);
+ f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor);
+}
+
+Heap::InternalClass *ScriptFunction::classForConstructor() const
+{
+ Scope scope(engine());
+ ScopedValue o(scope, protoProperty());
+ if (d()->cachedClassForConstructor && d()->cachedClassForConstructor->prototype == o->heapObject())
+ return d()->cachedClassForConstructor;
+
+ Scoped<InternalClass> ic(scope, engine()->internalClasses(EngineBase::Class_Object));
+ ScopedObject p(scope, o);
+ if (p)
+ ic = ic->changePrototype(p->d());
+ d()->cachedClassForConstructor.set(scope.engine, ic->d());
+
+ return ic->d();
+}
+
+DEFINE_OBJECT_VTABLE(ConstructorFunction);
+
+ReturnedValue ConstructorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ const ConstructorFunction *c = static_cast<const ConstructorFunction *>(f);
+ if (!c->d()->isDerivedConstructor)
+ return ScriptFunction::virtualCallAsConstructor(f, argv, argc, newTarget);
+
+ ExecutionEngine *v4 = f->engine();
+
+ CppStackFrame frame;
+ frame.init(v4, f->function(), argv, argc);
+ frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
+ Value::emptyValue(),
+ newTarget ? *newTarget : Value::undefinedValue());
+
+ frame.push();
+ v4->jsStackTop += frame.requiredJSStackFrameSize();
+
+ ReturnedValue result = Moth::VME::exec(&frame, v4);
+ ReturnedValue thisObject = frame.jsFrame->thisObject.asReturnedValue();
+
+ frame.pop();
+
+ if (Q_UNLIKELY(v4->hasException))
+ return Encode::undefined();
+ else if (Value::fromReturnedValue(result).isObject())
+ return result;
+ else if (!Value::fromReturnedValue(result).isUndefined())
+ return v4->throwTypeError();
+ else if (Value::fromReturnedValue(thisObject).isEmpty()) {
+ Scope scope(v4);
+ ScopedString s(scope, v4->newString(QStringLiteral("this")));
+ return v4->throwReferenceError(s);
}
+ return thisObject;
+}
+
+ReturnedValue ConstructorFunction::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError(QStringLiteral("Cannot call a class constructor without |new|"));
}
-InternalClass *ScriptFunction::classForConstructor() const
+DEFINE_OBJECT_VTABLE(MemberFunction);
+
+DEFINE_OBJECT_VTABLE(DefaultClassConstructorFunction);
+
+ReturnedValue DefaultClassConstructorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
- const Object *o = d()->protoProperty();
- InternalClass *ic = d()->cachedClassForConstructor;
- if (ic && ic->prototype == o->d())
- return ic;
+ const DefaultClassConstructorFunction *c = static_cast<const DefaultClassConstructorFunction *>(f);
+ ExecutionEngine *v4 = f->engine();
+
+ Scope scope(v4);
+
+ if (!c->d()->isDerivedConstructor) {
+ ScopedObject proto(scope, static_cast<const Object *>(newTarget)->get(scope.engine->id_prototype()));
+ ScopedObject c(scope, scope.engine->newObject());
+ c->setPrototypeUnchecked(proto);
+ return c->asReturnedValue();
+ }
+
+ ScopedFunctionObject super(scope, f->getPrototypeOf());
+ Q_ASSERT(super->isFunctionObject());
+
+ CppStackFrame frame;
+ frame.init(v4, nullptr, argv, argc);
+ frame.setupJSFrame(v4->jsStackTop, *f, f->scope(),
+ Value::undefinedValue(),
+ newTarget ? *newTarget : Value::undefinedValue(), argc, argc);
- ic = engine()->internalClasses[EngineBase::Class_Object];
- if (o)
- ic = ic->changePrototype(o->d());
- d()->cachedClassForConstructor = ic;
+ frame.push();
+ v4->jsStackTop += frame.requiredJSStackFrameSize(argc);
- return ic;
+ // Do a super call
+ ReturnedValue result = super->callAsConstructor(argv, argc, newTarget);
+ ReturnedValue thisObject = frame.jsFrame->thisObject.asReturnedValue();
+
+ frame.pop();
+
+ if (Q_UNLIKELY(v4->hasException))
+ return Encode::undefined();
+ else if (Value::fromReturnedValue(result).isObject())
+ return result;
+ else if (!Value::fromReturnedValue(result).isUndefined())
+ return v4->throwTypeError();
+ else if (Value::fromReturnedValue(thisObject).isEmpty()) {
+ Scope scope(v4);
+ ScopedString s(scope, v4->newString(QStringLiteral("this")));
+ return v4->throwReferenceError(s);
+ }
+
+ return thisObject;
+}
+
+ReturnedValue DefaultClassConstructorFunction::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError(QStringLiteral("Cannot call a class constructor without |new|"));
}
DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction);
@@ -462,6 +670,9 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject
this->boundArgs.set(s.engine, boundArgs ? boundArgs->d() : nullptr);
this->boundThis.set(scope->engine(), boundThis);
+ if (!target->isConstructor())
+ jsConstruct = nullptr;
+
ScopedObject f(s, this);
ScopedValue l(s, target->get(s.engine->id_length()));
@@ -470,7 +681,7 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject
len -= boundArgs->size();
if (len < 0)
len = 0;
- f->defineReadonlyConfigurableProperty(s.engine->id_length(), Primitive::fromInt32(len));
+ f->defineReadonlyConfigurableProperty(s.engine->id_length(), Value::fromInt32(len));
ScopedProperty pd(s);
pd->value = s.engine->thrower();
@@ -479,7 +690,7 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject
f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
-ReturnedValue BoundFunction::call(const FunctionObject *fo, const Value *, const Value *argv, int argc)
+ReturnedValue BoundFunction::virtualCall(const FunctionObject *fo, const Value *, const Value *argv, int argc)
{
const BoundFunction *f = static_cast<const BoundFunction *>(fo);
Scope scope(f->engine());
@@ -500,7 +711,7 @@ ReturnedValue BoundFunction::call(const FunctionObject *fo, const Value *, const
return target->call(jsCallData);
}
-ReturnedValue BoundFunction::callAsConstructor(const FunctionObject *fo, const Value *argv, int argc)
+ReturnedValue BoundFunction::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *)
{
const BoundFunction *f = static_cast<const BoundFunction *>(fo);
Scope scope(f->engine());
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 32e71a175b..b08b333411 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -64,29 +64,31 @@ namespace QV4 {
struct IndexedBuiltinFunction;
struct JSCallData;
-typedef ReturnedValue (*jsCallFunction)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
-typedef ReturnedValue (*jsConstructFunction)(const FunctionObject *, const Value *argv, int argc);
-
namespace Heap {
#define FunctionObjectMembers(class, Member) \
Member(class, Pointer, ExecutionContext *, scope) \
Member(class, NoMark, Function *, function) \
- Member(class, NoMark, jsCallFunction, jsCall) \
- Member(class, NoMark, jsConstructFunction, jsConstruct)
+ Member(class, NoMark, VTable::Call, jsCall) \
+ Member(class, NoMark, VTable::CallAsConstructor, jsConstruct)
DECLARE_HEAP_OBJECT(FunctionObject, Object) {
DECLARE_MARKOBJECTS(FunctionObject);
enum {
+ Index_ProtoConstructor = 0,
Index_Prototype = 0,
- Index_ProtoConstructor = 0
+ Index_HasInstance = 1,
};
- Q_QML_PRIVATE_EXPORT void init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(const QV4::FunctionObject *, const Value *thisObject, const Value *argv, int argc));
- void init(QV4::ExecutionContext *scope, QV4::String *name = nullptr, bool createProto = false);
- void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false);
- void init(QV4::ExecutionContext *scope, const QString &name, bool createProto = false);
+ bool isConstructor() const {
+ return jsConstruct != nullptr;
+ }
+
+ Q_QML_PRIVATE_EXPORT void init(QV4::ExecutionContext *scope, QV4::String *name, VTable::Call call);
+ void init(QV4::ExecutionContext *scope, QV4::String *name = nullptr);
+ void init(QV4::ExecutionContext *scope, QV4::Function *function, QV4::String *n = nullptr);
+ void init(QV4::ExecutionContext *scope, const QString &name);
void init();
void destroy();
@@ -94,8 +96,6 @@ DECLARE_HEAP_OBJECT(FunctionObject, Object) {
unsigned int formalParameterCount() { return function ? function->nFormals : 0; }
unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; }
-
- const QV4::Object *protoProperty() const { return propertyData(Index_Prototype)->as<QV4::Object>(); }
};
struct FunctionCtor : FunctionObject {
@@ -107,18 +107,48 @@ struct FunctionPrototype : FunctionObject {
};
struct IndexedBuiltinFunction : FunctionObject {
- inline void init(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(const QV4::FunctionObject *, const Value *, const Value *, int));
+ inline void init(QV4::ExecutionContext *scope, uint index, VTable::Call call);
uint index;
};
-struct ScriptFunction : FunctionObject {
+struct ArrowFunction : FunctionObject {
enum {
- Index_Name = FunctionObject::Index_Prototype + 1,
+ Index_Name = Index_HasInstance + 1,
Index_Length
};
+ void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr);
+};
+
+#define ScriptFunctionMembers(class, Member) \
+ Member(class, Pointer, InternalClass *, cachedClassForConstructor)
+
+DECLARE_HEAP_OBJECT(ScriptFunction, ArrowFunction) {
+ DECLARE_MARKOBJECTS(ScriptFunction)
void init(QV4::ExecutionContext *scope, Function *function);
+};
+
+#define MemberFunctionMembers(class, Member) \
+ Member(class, Pointer, Object *, homeObject)
+
+DECLARE_HEAP_OBJECT(MemberFunction, ArrowFunction) {
+ DECLARE_MARKOBJECTS(MemberFunction)
- QV4::InternalClass *cachedClassForConstructor;
+ void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr) {
+ ArrowFunction::init(scope, function, name);
+ }
+};
+
+#define ConstructorFunctionMembers(class, Member) \
+ Member(class, Pointer, Object *, homeObject)
+
+DECLARE_HEAP_OBJECT(ConstructorFunction, ScriptFunction) {
+ DECLARE_MARKOBJECTS(ConstructorFunction)
+ bool isDerivedConstructor;
+};
+
+struct DefaultClassConstructorFunction : FunctionObject
+{
+ bool isDerivedConstructor;
};
#define BoundFunctionMembers(class, Member) \
@@ -152,36 +182,52 @@ struct Q_QML_EXPORT FunctionObject: Object {
unsigned int formalParameterCount() const { return d()->formalParameterCount(); }
unsigned int varCount() const { return d()->varCount(); }
- void init(String *name, bool createProto);
+ void setName(String *name) {
+ defineReadonlyConfigurableProperty(engine()->id_name(), *name);
+ }
+ void createDefaultPrototypeProperty(uint protoConstructorSlot);
inline ReturnedValue callAsConstructor(const JSCallData &data) const;
- ReturnedValue callAsConstructor(const Value *argv, int argc) const {
- return d()->jsConstruct(this, argv, argc);
+ ReturnedValue callAsConstructor(const Value *argv, int argc, const Value *newTarget = nullptr) const {
+ if (!d()->jsConstruct)
+ return engine()->throwTypeError(QStringLiteral("Function is not a constructor."));
+ return d()->jsConstruct(this, argv, argc, newTarget ? newTarget : this);
}
inline ReturnedValue call(const JSCallData &data) const;
ReturnedValue call(const Value *thisObject, const Value *argv, int argc) const {
+ if (!d()->jsCall)
+ return engine()->throwTypeError(QStringLiteral("Function can only be called with |new|."));
return d()->jsCall(this, thisObject, argv, argc);
}
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function);
- static Heap::FunctionObject *createBuiltinFunction(ExecutionContext *scope, String *name,
- ReturnedValue (*code)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc))
- {
- return scope->engine()->memoryManager->allocObject<FunctionObject>(scope, name, code);
- }
+ static Heap::FunctionObject *createConstructorFunction(ExecutionContext *scope, Function *function, Object *homeObject, bool isDerivedConstructor);
+ static Heap::FunctionObject *createMemberFunction(ExecutionContext *scope, Function *function, Object *homeObject, String *name);
+ static Heap::FunctionObject *createBuiltinFunction(ExecutionEngine *engine, StringOrSymbol *nameOrSymbol, VTable::Call code, int argumentCount);
bool strictMode() const { return d()->function ? d()->function->isStrict() : false; }
bool isBinding() const;
bool isBoundFunction() const;
+ bool isConstructor() const {
+ return d()->isConstructor();
+ }
+
+ ReturnedValue getHomeObject() const;
+
+ ReturnedValue protoProperty() const {
+ return getValueByIndex(Heap::FunctionObject::Index_Prototype);
+ }
+ bool hasHasInstanceProperty() const {
+ return !internalClass()->propertyData.at(Heap::FunctionObject::Index_HasInstance).isEmpty();
+ }
QQmlSourceLocation sourceLocation() const;
};
template<>
inline const FunctionObject *Value::as() const {
- return isManaged() && m()->vtable()->isFunctionObject ? reinterpret_cast<const FunctionObject *>(this) : nullptr;
+ return isManaged() && m()->internalClass->vtable->isFunctionObject ? reinterpret_cast<const FunctionObject *>(this) : nullptr;
}
@@ -189,8 +235,14 @@ struct FunctionCtor: FunctionObject
{
V4_OBJECT2(FunctionCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+protected:
+ enum Type {
+ Type_Function,
+ Type_Generator
+ };
+ static QQmlRefPointer<CompiledData::CompilationUnit> parse(ExecutionEngine *engine, const Value *argv, int argc, Type t = Type_Function);
};
struct FunctionPrototype: FunctionObject
@@ -203,6 +255,7 @@ struct FunctionPrototype: FunctionObject
static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_bind(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
struct IndexedBuiltinFunction : FunctionObject
@@ -210,43 +263,70 @@ struct IndexedBuiltinFunction : FunctionObject
V4_OBJECT2(IndexedBuiltinFunction, FunctionObject)
};
-void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index,
- ReturnedValue (*code)(const QV4::FunctionObject *, const Value *thisObject, const Value *argv, int argc))
+void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index, VTable::Call call)
{
Heap::FunctionObject::init(scope);
- this->jsCall = code;
+ this->jsCall = call;
this->index = index;
}
+struct ArrowFunction : FunctionObject {
+ V4_OBJECT2(ArrowFunction, FunctionObject)
+ V4_INTERNALCLASS(ArrowFunction)
+ enum { NInlineProperties = 3 };
-struct ScriptFunction : FunctionObject {
- V4_OBJECT2(ScriptFunction, FunctionObject)
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct ScriptFunction : ArrowFunction {
+ V4_OBJECT2(ScriptFunction, ArrowFunction)
V4_INTERNALCLASS(ScriptFunction)
- enum { NInlineProperties = 3 };
- static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
- InternalClass *classForConstructor() const;
+ Heap::InternalClass *classForConstructor() const;
};
+struct MemberFunction : ArrowFunction {
+ V4_OBJECT2(MemberFunction, ArrowFunction)
+ V4_INTERNALCLASS(MemberFunction)
+};
+
+struct ConstructorFunction : ScriptFunction {
+ V4_OBJECT2(ConstructorFunction, ScriptFunction)
+ V4_INTERNALCLASS(ConstructorFunction)
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct DefaultClassConstructorFunction : FunctionObject {
+ V4_OBJECT2(DefaultClassConstructorFunction, FunctionObject)
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
struct BoundFunction: FunctionObject {
V4_OBJECT2(BoundFunction, FunctionObject)
static Heap::BoundFunction *create(ExecutionContext *scope, FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs)
{
- return scope->engine()->memoryManager->allocObject<BoundFunction>(scope, target, boundThis, boundArgs);
+ return scope->engine()->memoryManager->allocate<BoundFunction>(scope, target, boundThis, boundArgs);
}
Heap::FunctionObject *target() const { return d()->target; }
Value boundThis() const { return d()->boundThis; }
Heap::MemberData *boundArgs() const { return d()->boundArgs; }
- static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
+inline bool FunctionObject::isBoundFunction() const
+{
+ return d()->vtable() == BoundFunction::staticVTable();
+}
+
+
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4generatorobject.cpp b/src/qml/jsruntime/qv4generatorobject.cpp
new file mode 100644
index 0000000000..da87127e08
--- /dev/null
+++ b/src/qml/jsruntime/qv4generatorobject.cpp
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qv4generatorobject_p.h>
+#include <qv4symbol_p.h>
+#include <qv4iterator_p.h>
+#include <qv4jscall_p.h>
+#include <qv4vme_moth_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(GeneratorFunctionCtor);
+DEFINE_OBJECT_VTABLE(GeneratorFunction);
+DEFINE_OBJECT_VTABLE(GeneratorObject);
+
+void Heap::GeneratorFunctionCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("GeneratorFunction"));
+}
+
+ReturnedValue GeneratorFunctionCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
+{
+ ExecutionEngine *engine = f->engine();
+
+ QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = parse(engine, argv, argc, Type_Generator);
+ if (engine->hasException)
+ return Encode::undefined();
+
+ Function *vmf = compilationUnit->linkToEngine(engine);
+ ExecutionContext *global = engine->scriptContext();
+ return Encode(GeneratorFunction::create(global, vmf));
+}
+
+// 15.3.1: This is equivalent to new Function(...)
+ReturnedValue GeneratorFunctionCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ return virtualCallAsConstructor(f, argv, argc, f);
+}
+
+Heap::FunctionObject *GeneratorFunction::create(ExecutionContext *context, Function *function)
+{
+ Scope scope(context);
+ Scoped<GeneratorFunction> g(scope, context->engine()->memoryManager->allocate<GeneratorFunction>(context, function));
+ ScopedObject proto(scope, scope.engine->newObject());
+ proto->setPrototypeOf(scope.engine->generatorPrototype());
+ g->defineDefaultProperty(scope.engine->id_prototype(), proto, Attr_NotConfigurable|Attr_NotEnumerable);
+ g->setPrototypeOf(ScopedObject(scope, scope.engine->generatorFunctionCtor()->get(scope.engine->id_prototype())));
+ return g->d();
+}
+
+ReturnedValue GeneratorFunction::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ const GeneratorFunction *gf = static_cast<const GeneratorFunction *>(f);
+ Function *function = gf->function();
+ ExecutionEngine *engine = gf->engine();
+
+ // We need to set up a separate stack for the generator, as it's being re-entered
+ uint stackSize = argc // space for the original arguments
+ + CppStackFrame::requiredJSStackFrameSize(function); // space for the JS stack frame
+
+ size_t requiredMemory = sizeof(GeneratorObject::Data) - sizeof(Value) + sizeof(Value) * stackSize;
+
+ Scope scope(gf);
+ Scoped<GeneratorObject> g(scope, scope.engine->memoryManager->allocManaged<GeneratorObject>(requiredMemory, scope.engine->classes[EngineBase::Class_GeneratorObject]));
+ g->setPrototypeOf(ScopedObject(scope, gf->get(scope.engine->id_prototype())));
+
+ Heap::GeneratorObject *gp = g->d();
+ gp->stack.size = stackSize;
+ gp->stack.alloc = stackSize;
+
+ // copy original arguments
+ memcpy(gp->stack.values, argv, argc*sizeof(Value));
+ gp->cppFrame.init(engine, function, gp->stack.values, argc);
+ gp->cppFrame.setupJSFrame(&gp->stack.values[argc], *gf, gf->scope(),
+ thisObject ? *thisObject : Value::undefinedValue(),
+ Value::undefinedValue());
+
+ gp->cppFrame.push();
+
+ Moth::VME::interpret(&gp->cppFrame, engine, function->codeData);
+ gp->state = GeneratorState::SuspendedStart;
+
+ gp->cppFrame.pop();
+ return g->asReturnedValue();
+}
+
+
+void Heap::GeneratorPrototype::init()
+{
+ Heap::FunctionObject::init();
+}
+
+
+void GeneratorPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedValue v(scope);
+
+ ScopedObject ctorProto(scope, engine->newObject(engine->newInternalClass(Object::staticVTable(), engine->functionPrototype())));
+
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
+ ctor->defineReadonlyProperty(engine->id_prototype(), ctorProto);
+
+ ctorProto->defineDefaultProperty(QStringLiteral("constructor"), (v = ctor), Attr_ReadOnly_ButConfigurable);
+ ctorProto->defineDefaultProperty(engine->symbol_toStringTag(), (v = engine->newIdentifier(QStringLiteral("GeneratorFunction"))), Attr_ReadOnly_ButConfigurable);
+ ctorProto->defineDefaultProperty(engine->id_prototype(), (v = this), Attr_ReadOnly_ButConfigurable);
+
+ setPrototypeOf(engine->iteratorPrototype());
+ defineDefaultProperty(QStringLiteral("constructor"), ctorProto, Attr_ReadOnly_ButConfigurable);
+ defineDefaultProperty(QStringLiteral("next"), method_next, 1);
+ defineDefaultProperty(QStringLiteral("return"), method_return, 1);
+ defineDefaultProperty(QStringLiteral("throw"), method_throw, 1);
+ defineDefaultProperty(engine->symbol_toStringTag(), (v = engine->newString(QStringLiteral("Generator"))), Attr_ReadOnly_ButConfigurable);
+}
+
+ReturnedValue GeneratorPrototype::method_next(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *engine = f->engine();
+ const GeneratorObject *g = thisObject->as<GeneratorObject>();
+ if (!g || g->d()->state == GeneratorState::Executing)
+ return engine->throwTypeError();
+ Heap::GeneratorObject *gp = g->d();
+
+ if (gp->state == GeneratorState::Completed)
+ return IteratorPrototype::createIterResultObject(engine, Value::undefinedValue(), true);
+
+ return g->resume(engine, argc ? argv[0] : Value::undefinedValue());
+}
+
+ReturnedValue GeneratorPrototype::method_return(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *engine = f->engine();
+ const GeneratorObject *g = thisObject->as<GeneratorObject>();
+ if (!g || g->d()->state == GeneratorState::Executing)
+ return engine->throwTypeError();
+
+ Heap::GeneratorObject *gp = g->d();
+
+ if (gp->state == GeneratorState::SuspendedStart)
+ gp->state = GeneratorState::Completed;
+
+ if (gp->state == GeneratorState::Completed)
+ return IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Value::undefinedValue(), true);
+
+ // the bytecode interpreter interprets an exception with empty value as
+ // a yield called with return()
+ engine->throwError(Value::emptyValue());
+
+ return g->resume(engine, argc ? argv[0]: Value::undefinedValue());
+}
+
+ReturnedValue GeneratorPrototype::method_throw(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *engine = f->engine();
+ const GeneratorObject *g = thisObject->as<GeneratorObject>();
+ if (!g || g->d()->state == GeneratorState::Executing)
+ return engine->throwTypeError();
+
+ Heap::GeneratorObject *gp = g->d();
+
+ engine->throwError(argc ? argv[0]: Value::undefinedValue());
+
+ if (gp->state == GeneratorState::SuspendedStart || gp->state == GeneratorState::Completed) {
+ gp->state = GeneratorState::Completed;
+ return Encode::undefined();
+ }
+
+ return g->resume(engine, Value::undefinedValue());
+}
+
+ReturnedValue GeneratorObject::resume(ExecutionEngine *engine, const Value &arg) const
+{
+ Heap::GeneratorObject *gp = d();
+ gp->state = GeneratorState::Executing;
+ gp->cppFrame.parent = engine->currentStackFrame;
+ engine->currentStackFrame = &gp->cppFrame;
+
+ Q_ASSERT(gp->cppFrame.yield != nullptr);
+ const char *code = gp->cppFrame.yield;
+ gp->cppFrame.yield = nullptr;
+ gp->cppFrame.jsFrame->accumulator = arg;
+ gp->cppFrame.yieldIsIterator = false;
+
+ Scope scope(engine);
+ ScopedValue result(scope, Moth::VME::interpret(&gp->cppFrame, engine, code));
+
+ engine->currentStackFrame = gp->cppFrame.parent;
+
+ bool done = (gp->cppFrame.yield == nullptr);
+ gp->state = done ? GeneratorState::Completed : GeneratorState::SuspendedYield;
+ if (engine->hasException)
+ return Encode::undefined();
+ if (gp->cppFrame.yieldIsIterator)
+ return result->asReturnedValue();
+ return IteratorPrototype::createIterResultObject(engine, result, done);
+}
+
+DEFINE_OBJECT_VTABLE(MemberGeneratorFunction);
+
+Heap::FunctionObject *MemberGeneratorFunction::create(ExecutionContext *context, Function *function, Object *homeObject, String *name)
+{
+ Scope scope(context);
+ Scoped<MemberGeneratorFunction> g(scope, context->engine()->memoryManager->allocate<MemberGeneratorFunction>(context, function, name));
+ g->d()->homeObject.set(scope.engine, homeObject->d());
+ ScopedObject proto(scope, scope.engine->newObject());
+ proto->setPrototypeOf(scope.engine->generatorPrototype());
+ g->defineDefaultProperty(scope.engine->id_prototype(), proto, Attr_NotConfigurable|Attr_NotEnumerable);
+ g->setPrototypeOf(ScopedObject(scope, scope.engine->generatorFunctionCtor()->get(scope.engine->id_prototype())));
+ return g->d();
+}
+
+ReturnedValue MemberGeneratorFunction::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ return GeneratorFunction::virtualCall(f, thisObject, argv, argc);
+}
diff --git a/src/qml/jsruntime/qv4generatorobject_p.h b/src/qml/jsruntime/qv4generatorobject_p.h
new file mode 100644
index 0000000000..366319723d
--- /dev/null
+++ b/src/qml/jsruntime/qv4generatorobject_p.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4GENERATOROBJECT_P_H
+#define QV4GENERATOROBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4functionobject_p.h"
+#include "qv4stackframe_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+enum class GeneratorState {
+ Undefined,
+ SuspendedStart,
+ SuspendedYield,
+ Executing,
+ Completed
+};
+
+namespace Heap {
+
+struct GeneratorFunctionCtor : FunctionObject {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct GeneratorFunction : ArrowFunction {
+ void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr) {
+ ArrowFunction::init(scope, function, name);
+ }
+};
+
+struct MemberGeneratorFunction : MemberFunction {
+};
+
+struct GeneratorPrototype : FunctionObject {
+ void init();
+};
+
+#define GeneratorObjectMembers(class, Member) \
+ Member(class, Pointer, ExecutionContext *, context) \
+ Member(class, Pointer, GeneratorFunction *, function) \
+ Member(class, NoMark, GeneratorState, state) \
+ Member(class, NoMark, CppStackFrame, cppFrame) \
+ Member(class, ValueArray, ValueArray, stack)
+
+DECLARE_HEAP_OBJECT(GeneratorObject, Object) {
+ DECLARE_MARKOBJECTS(GeneratorObject);
+};
+
+}
+
+struct GeneratorFunctionCtor : FunctionCtor
+{
+ V4_OBJECT2(GeneratorFunctionCtor, FunctionCtor)
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct GeneratorFunction : ArrowFunction
+{
+ V4_OBJECT2(GeneratorFunction, ArrowFunction)
+ V4_INTERNALCLASS(GeneratorFunction)
+
+ static Heap::FunctionObject *create(ExecutionContext *scope, Function *function);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct MemberGeneratorFunction : MemberFunction
+{
+ V4_OBJECT2(MemberGeneratorFunction, MemberFunction)
+ V4_INTERNALCLASS(MemberGeneratorFunction)
+
+ static Heap::FunctionObject *create(ExecutionContext *scope, Function *function, Object *homeObject, String *name);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct GeneratorPrototype : Object
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_next(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_return(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_throw(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+
+struct GeneratorObject : Object {
+ V4_OBJECT2(GeneratorObject, Object)
+ Q_MANAGED_TYPE(GeneratorObject)
+ V4_INTERNALCLASS(GeneratorObject)
+ V4_PROTOTYPE(generatorPrototype)
+
+ ReturnedValue resume(ExecutionEngine *engine, const Value &arg) const;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4GENERATORFUNCTION_P_H
+
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 1fa4bae049..eab519720f 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -153,6 +153,11 @@ namespace Compiler {
struct Module;
struct Context;
struct JSUnitGenerator;
+ class Codegen;
+}
+
+namespace Moth {
+ class BytecodeGenerator;
}
namespace Heap {
@@ -160,13 +165,17 @@ namespace Heap {
struct MemberData;
struct ArrayData;
+ struct StringOrSymbol;
struct String;
+ struct Symbol;
struct Object;
struct ObjectPrototype;
struct ExecutionContext;
struct CallContext;
+ struct QmlContext;
struct ScriptFunction;
+ struct InternalClass;
struct BooleanObject;
struct NumberObject;
@@ -181,21 +190,30 @@ namespace Heap {
struct RegExp;
struct EvalFunction;
+ struct SharedArrayBuffer;
struct ArrayBuffer;
struct DataView;
struct TypedArray;
+ struct MapObject;
+ struct SetObject;
+
template <typename T, size_t> struct Pointer;
}
+struct CppStackFrame;
class MemoryManager;
class ExecutableAllocator;
+struct PropertyKey;
+struct StringOrSymbol;
struct String;
+struct Symbol;
struct Object;
struct ObjectPrototype;
struct ObjectIterator;
struct ExecutionContext;
struct CallContext;
+struct QmlContext;
struct ScriptFunction;
struct InternalClass;
struct Property;
@@ -222,10 +240,14 @@ struct RegExpObject;
struct RegExp;
struct EvalFunction;
+struct SharedArrayBuffer;
struct ArrayBuffer;
struct DataView;
struct TypedArray;
+struct MapObject;
+struct SetMapObject;
+
// ReturnedValue is used to return values from runtime methods
// the type has to be a primitive type (no struct or union), so that the compiler
// will return it in a register on all platforms.
@@ -236,6 +258,7 @@ struct Scope;
struct ScopedValue;
template<typename T> struct Scoped;
typedef Scoped<String> ScopedString;
+typedef Scoped<StringOrSymbol> ScopedStringOrSymbol;
typedef Scoped<Object> ScopedObject;
typedef Scoped<ArrayObject> ScopedArrayObject;
typedef Scoped<FunctionObject> ScopedFunctionObject;
@@ -244,6 +267,7 @@ typedef Scoped<ExecutionContext> ScopedContext;
struct PersistentValueStorage;
class PersistentValue;
class WeakValue;
+struct MarkStack;
struct IdentifierTable;
class RegExpCache;
@@ -340,6 +364,7 @@ struct PropertyAttributes
bool isEmpty() const { return !m_all; }
uint flags() const { return m_flags; }
+ uint all() const { return m_all; }
bool operator==(PropertyAttributes other) {
return m_all == other.m_all;
@@ -357,7 +382,23 @@ struct Q_QML_EXPORT StackFrame {
};
typedef QVector<StackFrame> StackTrace;
-}
+enum class ObjectLiteralArgument {
+ Value,
+ Method,
+ Getter,
+ Setter
+};
+
+namespace JIT {
+
+enum class CallResultDestination {
+ Ignore,
+ InAccumulator,
+};
+
+} // JIT namespace
+
+} // QV4 namespace
Q_DECLARE_TYPEINFO(QV4::PropertyAttributes, Q_PRIMITIVE_TYPE);
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index f419ab53fe..becdc3bc55 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -335,7 +335,7 @@ void Heap::EvalFunction::init(QV4::ExecutionContext *scope)
Scope s(scope);
Heap::FunctionObject::init(scope, s.engine->id_eval());
ScopedFunctionObject f(s, this);
- f->defineReadonlyProperty(s.engine->id_length(), Primitive::fromInt32(1));
+ f->defineReadonlyConfigurableProperty(s.engine->id_length(), Value::fromInt32(1));
}
ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc, bool directCall) const
@@ -351,7 +351,7 @@ ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc,
if (!directCall) {
// the context for eval should be the global scope
- ctx = v4->rootContext();
+ ctx = v4->scriptContext();
}
String *scode = argv[0].stringValue();
@@ -361,7 +361,7 @@ ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc,
const QString code = scode->toQString();
bool inheritContext = !isStrict;
- Script script(ctx, QV4::Compiler::EvalCode, code, QStringLiteral("eval code"));
+ Script script(ctx, QV4::Compiler::ContextType::Eval, code, QStringLiteral("eval code"));
script.strictMode = (directCall && isStrict);
script.inheritContext = inheritContext;
script.parse();
@@ -371,6 +371,7 @@ ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc,
Function *function = script.function();
if (!function)
return Encode::undefined();
+ function->isEval = true;
if (function->isStrict() || isStrict) {
ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function));
@@ -384,7 +385,7 @@ ReturnedValue EvalFunction::evalCall(const Value *, const Value *argv, int argc,
}
-ReturnedValue EvalFunction::call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue EvalFunction::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
{
// indirect call
return static_cast<const EvalFunction *>(f)->evalCall(thisObject, argv, argc, false);
@@ -411,8 +412,8 @@ static inline int toInt(const QChar &qc, int R)
ReturnedValue GlobalFunctions::method_parseInt(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
Scope scope(b);
- ScopedValue inputString(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue radix(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue inputString(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue radix(scope, argc > 1 ? argv[1] : Value::undefinedValue());
int R = radix->isUndefined() ? 0 : radix->toInt32();
// [15.1.2.2] step by step:
@@ -493,7 +494,7 @@ ReturnedValue GlobalFunctions::method_parseFloat(const FunctionObject *b, const
{
Scope scope(b);
// [15.1.2.3] step by step:
- ScopedString inputString(scope, argc ? argv[0] : Primitive::undefinedValue(), ScopedString::Convert);
+ ScopedString inputString(scope, argc ? argv[0] : Value::undefinedValue(), ScopedString::Convert);
CHECK_EXCEPTION();
QString trimmed = inputString->toQString().trimmed(); // 2
diff --git a/src/qml/jsruntime/qv4globalobject_p.h b/src/qml/jsruntime/qv4globalobject_p.h
index fd1820c23c..021b445955 100644
--- a/src/qml/jsruntime/qv4globalobject_p.h
+++ b/src/qml/jsruntime/qv4globalobject_p.h
@@ -71,7 +71,7 @@ struct Q_QML_EXPORT EvalFunction : FunctionObject
ReturnedValue evalCall(const Value *thisObject, const Value *argv, int argc, bool directCall) const;
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
struct GlobalFunctions
diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp
index c122bcb51a..5db5bd46ec 100644
--- a/src/qml/jsruntime/qv4identifier.cpp
+++ b/src/qml/jsruntime/qv4identifier.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qv4identifier_p.h"
#include "qv4identifiertable_p.h"
+#include "qv4string_p.h"
QT_BEGIN_NAMESPACE
@@ -54,14 +55,16 @@ static inline int primeForNumBits(int numBits)
}
-IdentifierHashData::IdentifierHashData(int numBits)
+IdentifierHashData::IdentifierHashData(IdentifierTable *table, int numBits)
: size(0)
, numBits(numBits)
+ , identifierTable(table)
{
refCount.store(1);
alloc = primeForNumBits(numBits);
entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry));
memset(entries, 0, alloc*sizeof(IdentifierHashEntry));
+ identifierTable->addIdentifierHash(this);
}
IdentifierHashData::IdentifierHashData(IdentifierHashData *other)
@@ -73,12 +76,18 @@ IdentifierHashData::IdentifierHashData(IdentifierHashData *other)
alloc = other->alloc;
entries = (IdentifierHashEntry *)malloc(alloc*sizeof(IdentifierHashEntry));
memcpy(entries, other->entries, alloc*sizeof(IdentifierHashEntry));
+ identifierTable->addIdentifierHash(this);
+}
+
+IdentifierHashData::~IdentifierHashData() {
+ free(entries);
+ if (identifierTable)
+ identifierTable->removeIdentifierHash(this);
}
IdentifierHash::IdentifierHash(ExecutionEngine *engine)
{
- d = new IdentifierHashData(3);
- d->identifierTable = engine->identifierTable;
+ d = new IdentifierHashData(engine->identifierTable, 3);
}
void IdentifierHash::detach()
@@ -92,8 +101,10 @@ void IdentifierHash::detach()
}
-IdentifierHashEntry *IdentifierHash::addEntry(const Identifier *identifier)
+IdentifierHashEntry *IdentifierHash::addEntry(PropertyKey identifier)
{
+ Q_ASSERT(identifier.isStringOrSymbol());
+
// fill up to max 50%
bool grow = (d->alloc <= d->size*2);
@@ -104,10 +115,10 @@ IdentifierHashEntry *IdentifierHash::addEntry(const Identifier *identifier)
memset(newEntries, 0, newAlloc*sizeof(IdentifierHashEntry));
for (int i = 0; i < d->alloc; ++i) {
const IdentifierHashEntry &e = d->entries[i];
- if (!e.identifier)
+ if (!e.identifier.isValid())
continue;
- uint idx = e.identifier->hashValue % newAlloc;
- while (newEntries[idx].identifier) {
+ uint idx = e.identifier.id() % newAlloc;
+ while (newEntries[idx].identifier.isValid()) {
++idx;
idx %= newAlloc;
}
@@ -118,8 +129,8 @@ IdentifierHashEntry *IdentifierHash::addEntry(const Identifier *identifier)
d->alloc = newAlloc;
}
- uint idx = identifier->hashValue % d->alloc;
- while (d->entries[idx].identifier) {
+ uint idx = identifier.id() % d->alloc;
+ while (d->entries[idx].identifier.isValid()) {
Q_ASSERT(d->entries[idx].identifier != identifier);
++idx;
idx %= d->alloc;
@@ -129,15 +140,15 @@ IdentifierHashEntry *IdentifierHash::addEntry(const Identifier *identifier)
return d->entries + idx;
}
-const IdentifierHashEntry *IdentifierHash::lookup(const Identifier *identifier) const
+const IdentifierHashEntry *IdentifierHash::lookup(PropertyKey identifier) const
{
- if (!d)
+ if (!d || !identifier.isStringOrSymbol())
return nullptr;
Q_ASSERT(d->entries);
- uint idx = identifier->hashValue % d->alloc;
+ uint idx = identifier.id() % d->alloc;
while (1) {
- if (!d->entries[idx].identifier)
+ if (!d->entries[idx].identifier.isValid())
return nullptr;
if (d->entries[idx].identifier == identifier)
return d->entries + idx;
@@ -150,39 +161,54 @@ const IdentifierHashEntry *IdentifierHash::lookup(const QString &str) const
{
if (!d)
return nullptr;
- Q_ASSERT(d->entries);
- uint hash = String::createHashValue(str.constData(), str.length(), nullptr);
- uint idx = hash % d->alloc;
- while (1) {
- if (!d->entries[idx].identifier)
- return nullptr;
- if (d->entries[idx].identifier->string == str)
- return d->entries + idx;
- ++idx;
- idx %= d->alloc;
- }
+ PropertyKey id = d->identifierTable->asPropertyKey(str);
+ return lookup(id);
}
const IdentifierHashEntry *IdentifierHash::lookup(String *str) const
{
if (!d)
return nullptr;
- if (str->d()->identifier)
- return lookup(str->d()->identifier);
+ PropertyKey id = d->identifierTable->asPropertyKey(str);
+ if (id.isValid())
+ return lookup(id);
return lookup(str->toQString());
}
-const Identifier *IdentifierHash::toIdentifier(const QString &str) const
+const PropertyKey IdentifierHash::toIdentifier(const QString &str) const
{
Q_ASSERT(d);
- return d->identifierTable->identifier(str);
+ return d->identifierTable->asPropertyKey(str);
}
-const Identifier *IdentifierHash::toIdentifier(Heap::String *str) const
+const PropertyKey IdentifierHash::toIdentifier(Heap::String *str) const
{
Q_ASSERT(d);
- return d->identifierTable->identifier(str);
+ return d->identifierTable->asPropertyKey(str);
+}
+
+QString QV4::IdentifierHash::findId(int value) const
+{
+ IdentifierHashEntry *e = d->entries;
+ IdentifierHashEntry *end = e + d->alloc;
+ while (e < end) {
+ if (e->identifier.isValid() && e->value == value)
+ return e->identifier.toQString();
+ ++e;
+ }
+ return QString();
+}
+
+void IdentifierHashData::markObjects(MarkStack *markStack) const
+{
+ IdentifierHashEntry *e = entries;
+ IdentifierHashEntry *end = e + alloc;
+ while (e < end) {
+ if (Heap::Base *o = e->identifier.asStringOrSymbol())
+ o->mark(markStack);
+ ++e;
+ }
}
diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h
index 82346d5f68..32de8b7c8d 100644
--- a/src/qml/jsruntime/qv4identifier_p.h
+++ b/src/qml/jsruntime/qv4identifier_p.h
@@ -51,38 +51,24 @@
//
#include <qstring.h>
+#include <private/qv4global_p.h>
+#include <private/qv4propertykey_p.h>
QT_BEGIN_NAMESPACE
namespace QV4 {
-namespace Heap {
- struct String;
-}
-
-struct String;
-struct IdentifierTable;
-struct ExecutionEngine;
-
-struct Identifier
-{
- QString string;
- uint hashValue;
-};
-
-
struct IdentifierHashEntry {
- const Identifier *identifier;
+ PropertyKey identifier;
int value;
};
struct IdentifierHashData
{
- IdentifierHashData(int numBits);
+ IdentifierHashData(IdentifierTable *table, int numBits);
explicit IdentifierHashData(IdentifierHashData *other);
- ~IdentifierHashData() {
- free(entries);
- }
+ ~IdentifierHashData();
+ void markObjects(MarkStack *markStack) const;
QBasicAtomicInt refCount;
int alloc;
@@ -117,12 +103,12 @@ struct IdentifierHash
QString findId(int value) const;
protected:
- IdentifierHashEntry *addEntry(const Identifier *i);
- const IdentifierHashEntry *lookup(const Identifier *identifier) const;
+ IdentifierHashEntry *addEntry(PropertyKey i);
+ const IdentifierHashEntry *lookup(PropertyKey identifier) const;
const IdentifierHashEntry *lookup(const QString &str) const;
const IdentifierHashEntry *lookup(String *str) const;
- const Identifier *toIdentifier(const QString &str) const;
- const Identifier *toIdentifier(Heap::String *str) const;
+ const PropertyKey toIdentifier(const QString &str) const;
+ const PropertyKey toIdentifier(Heap::String *str) const;
};
@@ -180,20 +166,6 @@ inline int IdentifierHash::value(String *str) const
return e ? e->value : -1;
}
-
-inline
-QString IdentifierHash::findId(int value) const
-{
- IdentifierHashEntry *e = d->entries;
- IdentifierHashEntry *end = e + d->alloc;
- while (e < end) {
- if (e->identifier && e->value == value)
- return e->identifier->string;
- ++e;
- }
- return QString();
-}
-
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp
index b77f9478d3..e476baa886 100644
--- a/src/qml/jsruntime/qv4identifiertable.cpp
+++ b/src/qml/jsruntime/qv4identifiertable.cpp
@@ -37,6 +37,7 @@
**
****************************************************************************/
#include "qv4identifiertable_p.h"
+#include "qv4symbol_p.h"
QT_BEGIN_NAMESPACE
@@ -53,44 +54,44 @@ static inline int primeForNumBits(int numBits)
}
-IdentifierTable::IdentifierTable(ExecutionEngine *engine)
+IdentifierTable::IdentifierTable(ExecutionEngine *engine, int numBits)
: engine(engine)
, size(0)
- , numBits(8)
+ , numBits(numBits)
{
alloc = primeForNumBits(numBits);
- entries = (Heap::String **)malloc(alloc*sizeof(Heap::String *));
- memset(entries, 0, alloc*sizeof(Heap::String *));
+ entriesByHash = (Heap::StringOrSymbol **)malloc(alloc*sizeof(Heap::StringOrSymbol *));
+ entriesById = (Heap::StringOrSymbol **)malloc(alloc*sizeof(Heap::StringOrSymbol *));
+ memset(entriesByHash, 0, alloc*sizeof(Heap::String *));
+ memset(entriesById, 0, alloc*sizeof(Heap::String *));
}
IdentifierTable::~IdentifierTable()
{
- for (int i = 0; i < alloc; ++i)
- if (entries[i])
- delete entries[i]->identifier;
- free(entries);
+ free(entriesByHash);
+ free(entriesById);
+ for (auto &h : idHashes)
+ h->identifierTable = nullptr;
}
-void IdentifierTable::addEntry(Heap::String *str)
+void IdentifierTable::addEntry(Heap::StringOrSymbol *str)
{
uint hash = str->hashValue();
if (str->subtype == Heap::String::StringType_ArrayIndex)
return;
- str->identifier = new Identifier;
- str->identifier->string = str->toQString();
- str->identifier->hashValue = hash;
+ str->identifier = PropertyKey::fromStringOrSymbol(str);
bool grow = (alloc <= size*2);
if (grow) {
++numBits;
int newAlloc = primeForNumBits(numBits);
- Heap::String **newEntries = (Heap::String **)malloc(newAlloc*sizeof(Heap::String *));
- memset(newEntries, 0, newAlloc*sizeof(Heap::String *));
- for (int i = 0; i < alloc; ++i) {
- Heap::String *e = entries[i];
+ Heap::StringOrSymbol **newEntries = (Heap::StringOrSymbol **)malloc(newAlloc*sizeof(Heap::String *));
+ memset(newEntries, 0, newAlloc*sizeof(Heap::StringOrSymbol *));
+ for (uint i = 0; i < alloc; ++i) {
+ Heap::StringOrSymbol *e = entriesByHash[i];
if (!e)
continue;
uint idx = e->stringHash % newAlloc;
@@ -100,17 +101,42 @@ void IdentifierTable::addEntry(Heap::String *str)
}
newEntries[idx] = e;
}
- free(entries);
- entries = newEntries;
+ free(entriesByHash);
+ entriesByHash = newEntries;
+
+ newEntries = (Heap::StringOrSymbol **)malloc(newAlloc*sizeof(Heap::String *));
+ memset(newEntries, 0, newAlloc*sizeof(Heap::StringOrSymbol *));
+ for (uint i = 0; i < alloc; ++i) {
+ Heap::StringOrSymbol *e = entriesById[i];
+ if (!e)
+ continue;
+ uint idx = e->identifier.id() % newAlloc;
+ while (newEntries[idx]) {
+ ++idx;
+ idx %= newAlloc;
+ }
+ newEntries[idx] = e;
+ }
+ free(entriesById);
+ entriesById = newEntries;
+
alloc = newAlloc;
}
uint idx = hash % alloc;
- while (entries[idx]) {
+ while (entriesByHash[idx]) {
++idx;
idx %= alloc;
}
- entries[idx] = str;
+ entriesByHash[idx] = str;
+
+ idx = str->identifier.id() % alloc;
+ while (entriesById[idx]) {
+ ++idx;
+ idx %= alloc;
+ }
+ entriesById[idx] = str;
+
++size;
}
@@ -120,10 +146,16 @@ Heap::String *IdentifierTable::insertString(const QString &s)
{
uint subtype;
uint hash = String::createHashValue(s.constData(), s.length(), &subtype);
+ if (subtype == Heap::String::StringType_ArrayIndex) {
+ Heap::String *str = engine->newString(s);
+ str->stringHash = hash;
+ str->subtype = subtype;
+ return str;
+ }
uint idx = hash % alloc;
- while (Heap::String *e = entries[idx]) {
+ while (Heap::StringOrSymbol *e = entriesByHash[idx]) {
if (e->stringHash == hash && e->toQString() == s)
- return e;
+ return static_cast<Heap::String *>(e);
++idx;
idx %= alloc;
}
@@ -135,18 +167,42 @@ Heap::String *IdentifierTable::insertString(const QString &s)
return str;
}
+Heap::Symbol *IdentifierTable::insertSymbol(const QString &s)
+{
+ Q_ASSERT(s.at(0) == QLatin1Char('@'));
+
+ uint subtype;
+ uint hash = String::createHashValue(s.constData(), s.length(), &subtype);
+ uint idx = hash % alloc;
+ while (Heap::StringOrSymbol *e = entriesByHash[idx]) {
+ if (e->stringHash == hash && e->toQString() == s)
+ return static_cast<Heap::Symbol *>(e);
+ ++idx;
+ idx %= alloc;
+ }
-Identifier *IdentifierTable::identifierImpl(const Heap::String *str)
+ Heap::Symbol *str = Symbol::create(engine, s);
+ str->stringHash = hash;
+ str->subtype = subtype;
+ addEntry(str);
+ return str;
+
+}
+
+
+PropertyKey IdentifierTable::asPropertyKeyImpl(const Heap::String *str)
{
- if (str->identifier)
+ if (str->identifier.isValid())
return str->identifier;
uint hash = str->hashValue();
- if (str->subtype == Heap::String::StringType_ArrayIndex)
- return nullptr;
+ if (str->subtype == Heap::String::StringType_ArrayIndex) {
+ str->identifier = PropertyKey::fromArrayIndex(hash);
+ return str->identifier;
+ }
uint idx = hash % alloc;
- while (Heap::String *e = entries[idx]) {
- if (e->stringHash == hash && e->isEqualTo(str)) {
+ while (Heap::StringOrSymbol *e = entriesByHash[idx]) {
+ if (e->stringHash == hash && e->toQString() == str->toQString()) {
str->identifier = e->identifier;
return e->identifier;
}
@@ -158,37 +214,96 @@ Identifier *IdentifierTable::identifierImpl(const Heap::String *str)
return str->identifier;
}
-Heap::String *IdentifierTable::stringFromIdentifier(Identifier *i)
+Heap::StringOrSymbol *IdentifierTable::resolveId(PropertyKey i) const
{
- if (!i)
+ uint arrayIdx = i.asArrayIndex();
+ if (arrayIdx < UINT_MAX)
+ return engine->newString(QString::number(arrayIdx));
+ if (!i.isValid())
return nullptr;
- uint idx = i->hashValue % alloc;
+ uint idx = i.id() % alloc;
while (1) {
- Heap::String *e = entries[idx];
- Q_ASSERT(e);
- if (e->identifier == i)
+ Heap::StringOrSymbol *e = entriesById[idx];
+ if (!e || e->identifier == i)
return e;
++idx;
idx %= alloc;
}
}
-Identifier *IdentifierTable::identifier(const QString &s)
+Heap::String *IdentifierTable::stringForId(PropertyKey i) const
+{
+ Heap::StringOrSymbol *s = resolveId(i);
+ Q_ASSERT(s && s->internalClass->vtable->isString);
+ return static_cast<Heap::String *>(s);
+}
+
+Heap::Symbol *IdentifierTable::symbolForId(PropertyKey i) const
+{
+ Heap::StringOrSymbol *s = resolveId(i);
+ Q_ASSERT(!s || !s->internalClass->vtable->isString);
+ return static_cast<Heap::Symbol *>(s);
+}
+
+void IdentifierTable::markObjects(MarkStack *markStack)
+{
+ for (const auto &h : idHashes)
+ h->markObjects(markStack);
+}
+
+void IdentifierTable::sweep()
+{
+ int freed = 0;
+
+ Heap::StringOrSymbol **newTable = (Heap::StringOrSymbol **)malloc(alloc*sizeof(Heap::String *));
+ memset(newTable, 0, alloc*sizeof(Heap::StringOrSymbol *));
+ memset(entriesById, 0, alloc*sizeof(Heap::StringOrSymbol *));
+ for (uint i = 0; i < alloc; ++i) {
+ Heap::StringOrSymbol *e = entriesByHash[i];
+ if (!e)
+ continue;
+ if (!e->isMarked()) {
+ ++freed;
+ continue;
+ }
+ uint idx = e->hashValue() % alloc;
+ while (newTable[idx]) {
+ ++idx;
+ if (idx == alloc)
+ idx = 0;
+ }
+ newTable[idx] = e;
+
+ idx = e->identifier.id() % alloc;
+ while (entriesById[idx]) {
+ ++idx;
+ if (idx == alloc)
+ idx = 0;
+ }
+ entriesById[idx] = e;
+ }
+ free(entriesByHash);
+ entriesByHash = newTable;
+
+ size -= freed;
+}
+
+PropertyKey IdentifierTable::asPropertyKey(const QString &s)
{
return insertString(s)->identifier;
}
-Identifier *IdentifierTable::identifier(const char *s, int len)
+PropertyKey IdentifierTable::asPropertyKey(const char *s, int len)
{
uint subtype;
uint hash = String::createHashValue(s, len, &subtype);
if (hash == UINT_MAX)
- return identifier(QString::fromUtf8(s, len));
+ return asPropertyKey(QString::fromUtf8(s, len));
QLatin1String latin(s, len);
uint idx = hash % alloc;
- while (Heap::String *e = entries[idx]) {
+ while (Heap::StringOrSymbol *e = entriesByHash[idx]) {
if (e->stringHash == hash && e->toQString() == latin)
return e->identifier;
++idx;
diff --git a/src/qml/jsruntime/qv4identifiertable_p.h b/src/qml/jsruntime/qv4identifiertable_p.h
index b0b08f1e54..78e2b6620e 100644
--- a/src/qml/jsruntime/qv4identifiertable_p.h
+++ b/src/qml/jsruntime/qv4identifiertable_p.h
@@ -53,55 +53,61 @@
#include "qv4identifier_p.h"
#include "qv4string_p.h"
#include "qv4engine_p.h"
+#include <qset.h>
#include <limits.h>
QT_BEGIN_NAMESPACE
namespace QV4 {
-struct IdentifierTable
+struct Q_QML_PRIVATE_EXPORT IdentifierTable
{
ExecutionEngine *engine;
- int alloc;
- int size;
+ uint alloc;
+ uint size;
int numBits;
- Heap::String **entries;
+ Heap::StringOrSymbol **entriesByHash;
+ Heap::StringOrSymbol **entriesById;
- void addEntry(Heap::String *str);
+ QSet<IdentifierHashData *> idHashes;
+
+ void addEntry(Heap::StringOrSymbol *str);
public:
- IdentifierTable(ExecutionEngine *engine);
+ IdentifierTable(ExecutionEngine *engine, int numBits = 8);
~IdentifierTable();
Heap::String *insertString(const QString &s);
+ Heap::Symbol *insertSymbol(const QString &s);
- Identifier *identifier(const Heap::String *str) {
- if (str->identifier)
+ PropertyKey asPropertyKey(const Heap::String *str) {
+ if (str->identifier.isValid())
return str->identifier;
- return identifierImpl(str);
+ return asPropertyKeyImpl(str);
}
- Identifier *identifier(const QV4::String *str) {
- return identifier(str->d());
+ PropertyKey asPropertyKey(const QV4::String *str) {
+ return asPropertyKey(str->d());
}
- Identifier *identifier(const QString &s);
- Identifier *identifier(const char *s, int len);
+ PropertyKey asPropertyKey(const QString &s);
+ PropertyKey asPropertyKey(const char *s, int len);
+
+ PropertyKey asPropertyKeyImpl(const Heap::String *str);
- Identifier *identifierImpl(const Heap::String *str);
+ Heap::StringOrSymbol *resolveId(PropertyKey i) const;
+ Heap::String *stringForId(PropertyKey i) const;
+ Heap::Symbol *symbolForId(PropertyKey i) const;
- Heap::String *stringFromIdentifier(Identifier *i);
+ void markObjects(MarkStack *markStack);
+ void sweep();
- void mark(MarkStack *markStack) {
- for (int i = 0; i < alloc; ++i) {
- Heap::String *entry = entries[i];
- if (!entry || entry->isMarked())
- continue;
- entry->setMarkBit();
- Q_ASSERT(entry->vtable()->markObjects);
- entry->vtable()->markObjects(entry, markStack);
- }
+ void addIdentifierHash(IdentifierHashData *h) {
+ idHashes.insert(h);
+ }
+ void removeIdentifierHash(IdentifierHashData *h) {
+ idHashes.remove(h);
}
};
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index d0d66c9b9a..e456879d9c 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -101,11 +101,11 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat
QV4::ScopedObject o(scope, v4->newObject());
QV4::ScopedString s(scope);
QV4::ScopedValue v(scope);
- o->put((s = v4->newString(QStringLiteral("OK"))), (v = QV4::Primitive::fromInt32(Ok)));
- o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Primitive::fromInt32(Loading)));
- o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Primitive::fromInt32(NetworkError)));
- o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Primitive::fromInt32(Exception)));
- o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Primitive::fromInt32(status)));
+ o->put((s = v4->newString(QStringLiteral("OK"))), (v = QV4::Value::fromInt32(Ok)));
+ o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Value::fromInt32(Loading)));
+ o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Value::fromInt32(NetworkError)));
+ o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Value::fromInt32(Exception)));
+ o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Value::fromInt32(status)));
if (!statusText.isEmpty())
o->put((s = v4->newString(QStringLiteral("statusText"))), (v = v4->newString(statusText)));
@@ -173,20 +173,20 @@ void QV4Include::finished()
script.run();
if (scope.engine->hasException) {
QV4::ScopedValue ex(scope, scope.engine->catchException());
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Exception)));
QV4::ScopedString exception(scope, v4->newString(QStringLiteral("exception")));
resultObj->put(exception, ex);
} else {
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Ok)));
}
} else {
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError)));
}
#else
QV4::Scope scope(v4);
QV4::ScopedObject resultObj(scope, m_resultObject.value());
QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
- resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
+ resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError)));
#endif // qml_network
QV4::ScopedValue cb(scope, m_callbackFunction.value());
@@ -207,10 +207,10 @@ QV4::ReturnedValue QV4Include::method_include(const QV4::FunctionObject *b, cons
QQmlContextData *context = scope.engine->callingQmlContext();
- if (!context || !context->isJSContext)
+ if ((!context || !context->isJSContext) && scope.engine->qmlEngine())
RETURN_RESULT(scope.engine->throwError(QString::fromUtf8("Qt.include(): Can only be called from JavaScript files")));
- QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue callbackFunction(scope, QV4::Value::undefinedValue());
if (argc >= 2 && argv[1].as<QV4::FunctionObject>())
callbackFunction = argv[1];
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp
index 3bfcf358bf..ddb8542e07 100644
--- a/src/qml/jsruntime/qv4internalclass.cpp
+++ b/src/qml/jsruntime/qv4internalclass.cpp
@@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
-using namespace QV4;
+namespace QV4 {
static const uchar prime_deltas[] = {
0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
@@ -74,27 +74,11 @@ void PropertyHash::addEntry(const PropertyHash::Entry &entry, int classSize)
// fill up to max 50%
bool grow = (d->alloc <= d->size*2);
- if (classSize < d->size || grow) {
- PropertyHashData *dd = new PropertyHashData(grow ? d->numBits + 1 : d->numBits);
- for (int i = 0; i < d->alloc; ++i) {
- const Entry &e = d->entries[i];
- if (!e.identifier || e.index >= static_cast<unsigned>(classSize))
- continue;
- uint idx = e.identifier->hashValue % dd->alloc;
- while (dd->entries[idx].identifier) {
- ++idx;
- idx %= dd->alloc;
- }
- dd->entries[idx] = e;
- }
- dd->size = classSize;
- Q_ASSERT(d->refCount > 1);
- --d->refCount;
- d = dd;
- }
+ if (classSize < d->size || grow)
+ detach(grow, classSize);
- uint idx = entry.identifier->hashValue % d->alloc;
- while (d->entries[idx].identifier) {
+ uint idx = entry.identifier.id() % d->alloc;
+ while (d->entries[idx].identifier.isValid()) {
++idx;
idx %= d->alloc;
}
@@ -102,74 +86,205 @@ void PropertyHash::addEntry(const PropertyHash::Entry &entry, int classSize)
++d->size;
}
+int PropertyHash::removeIdentifier(PropertyKey identifier, int classSize)
+{
+ int val = -1;
+ PropertyHashData *dd = new PropertyHashData(d->numBits);
+ for (int i = 0; i < d->alloc; ++i) {
+ const Entry &e = d->entries[i];
+ if (!e.identifier.isValid() || e.index >= static_cast<unsigned>(classSize))
+ continue;
+ if (e.identifier == identifier) {
+ val = e.index;
+ continue;
+ }
+ uint idx = e.identifier.id() % dd->alloc;
+ while (dd->entries[idx].identifier.isValid()) {
+ ++idx;
+ idx %= dd->alloc;
+ }
+ dd->entries[idx] = e;
+ }
+ dd->size = classSize;
+ if (!--d->refCount)
+ delete d;
+ d = dd;
-InternalClass::InternalClass(ExecutionEngine *engine)
- : engine(engine)
- , vtable(nullptr)
- , prototype(nullptr)
- , m_sealed(nullptr)
- , m_frozen(nullptr)
- , size(0)
- , extensible(true)
+ Q_ASSERT(val != -1);
+ return val;
+}
+
+void PropertyHash::detach(bool grow, int classSize)
{
- id = engine->newInternalClassId();
+ if (d->refCount == 1 && !grow)
+ return;
+
+ PropertyHashData *dd = new PropertyHashData(grow ? d->numBits + 1 : d->numBits);
+ for (int i = 0; i < d->alloc; ++i) {
+ const Entry &e = d->entries[i];
+ if (!e.identifier.isValid() || e.index >= static_cast<unsigned>(classSize))
+ continue;
+ uint idx = e.identifier.id() % dd->alloc;
+ while (dd->entries[idx].identifier.isValid()) {
+ ++idx;
+ idx %= dd->alloc;
+ }
+ dd->entries[idx] = e;
+ }
+ dd->size = classSize;
+ if (!--d->refCount)
+ delete d;
+ d = dd;
}
-InternalClass::InternalClass(const QV4::InternalClass &other)
- : QQmlJS::Managed()
- , engine(other.engine)
- , vtable(other.vtable)
- , prototype(other.prototype)
- , propertyTable(other.propertyTable)
- , nameMap(other.nameMap)
- , propertyData(other.propertyData)
- , m_sealed(nullptr)
- , m_frozen(nullptr)
- , size(other.size)
- , extensible(other.extensible)
- , isUsedAsProto(other.isUsedAsProto)
+SharedInternalClassDataPrivate<PropertyKey>::SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate<PropertyKey> &other)
+ : refcount(1),
+ engine(other.engine),
+ data(nullptr)
{
- id = engine->newInternalClassId();
+ if (other.alloc()) {
+ int s = other.size();
+ data = MemberData::allocate(engine, other.alloc(), other.data);
+ setSize(s);
+ }
}
-static void insertHoleIntoPropertyData(Object *object, int idx)
+SharedInternalClassDataPrivate<PropertyKey>::SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate<PropertyKey> &other,
+ uint pos, PropertyKey value)
+ : refcount(1),
+ engine(other.engine)
{
- Heap::Object *o = object->d();
- ExecutionEngine *v4 = o->internalClass->engine;
- int size = o->internalClass->size;
- for (int i = size - 1; i > idx; --i)
- o->setProperty(v4, i, *o->propertyData(i - 1));
+ data = MemberData::allocate(engine, other.alloc(), nullptr);
+ memcpy(data, other.data, sizeof(Heap::MemberData) - sizeof(Value) + pos*sizeof(Value));
+ data->values.size = pos + 1;
+ data->values.set(engine, pos, Value::fromReturnedValue(value.id()));
}
-static void removeFromPropertyData(Object *object, int idx, bool accessor = false)
+void SharedInternalClassDataPrivate<PropertyKey>::grow()
{
- Heap::Object *o = object->d();
- ExecutionEngine *v4 = o->internalClass->engine;
- int size = o->internalClass->size;
- for (int i = idx; i < size; ++i)
- o->setProperty(v4, i, *o->propertyData(i + (accessor ? 2 : 1)));
- o->setProperty(v4, size, Primitive::undefinedValue());
- if (accessor)
- o->setProperty(v4, size + 1, Primitive::undefinedValue());
+ uint a = alloc() * 2;
+ int s = size();
+ data = MemberData::allocate(engine, a, data);
+ setSize(s);
+ Q_ASSERT(alloc() >= a);
}
-void InternalClass::changeMember(Object *object, String *string, PropertyAttributes data, uint *index)
+uint SharedInternalClassDataPrivate<PropertyKey>::alloc() const
{
- uint idx;
- InternalClass *oldClass = object->internalClass();
- InternalClass *newClass = oldClass->changeMember(string->identifier(), data, &idx);
- if (index)
- *index = idx;
+ return data ? data->values.alloc : 0;
+}
- object->setInternalClass(newClass);
- if (newClass->size > oldClass->size) {
- Q_ASSERT(newClass->size == oldClass->size + 1);
- insertHoleIntoPropertyData(object, idx);
- } else if (newClass->size < oldClass->size) {
- Q_ASSERT(newClass->size == oldClass->size - 1);
- removeFromPropertyData(object, idx + 1);
+uint SharedInternalClassDataPrivate<PropertyKey>::size() const
+{
+ return data ? data->values.size : 0;
+}
+
+void SharedInternalClassDataPrivate<PropertyKey>::setSize(uint s)
+{
+ Q_ASSERT(data && s <= alloc());
+ data->values.size = s;
+}
+
+PropertyKey SharedInternalClassDataPrivate<PropertyKey>::at(uint i)
+{
+ Q_ASSERT(data && i < size());
+ return PropertyKey::fromId(data->values.values[i].rawValue());
+}
+
+void SharedInternalClassDataPrivate<PropertyKey>::set(uint i, PropertyKey t)
+{
+ Q_ASSERT(data && i < size());
+ data->values.values[i].rawValueRef() = t.id();
+}
+
+void SharedInternalClassDataPrivate<PropertyKey>::mark(MarkStack *s)
+{
+ if (data)
+ data->mark(s);
+}
+
+
+
+namespace Heap {
+
+void InternalClass::init(ExecutionEngine *engine)
+{
+ Base::init();
+ new (&propertyTable) PropertyHash();
+ new (&nameMap) SharedInternalClassData<PropertyKey>(engine);
+ new (&propertyData) SharedInternalClassData<PropertyAttributes>(engine);
+ new (&transitions) std::vector<Transition>();
+
+ this->engine = engine;
+ vtable = QV4::InternalClass::staticVTable();
+// prototype = nullptr;
+// parent = nullptr;
+// size = 0;
+ extensible = true;
+ isFrozen = false;
+ isSealed = false;
+ isUsedAsProto = false;
+ protoId = engine->newProtoId();
+
+ // Also internal classes need an internal class pointer. Simply make it point to itself
+ internalClass.set(engine, this);
+}
+
+
+void InternalClass::init(Heap::InternalClass *other)
+{
+ Base::init();
+ Q_ASSERT(!other->isFrozen);
+ new (&propertyTable) PropertyHash(other->propertyTable);
+ new (&nameMap) SharedInternalClassData<PropertyKey>(other->nameMap);
+ new (&propertyData) SharedInternalClassData<PropertyAttributes>(other->propertyData);
+ new (&transitions) std::vector<Transition>();
+
+ engine = other->engine;
+ vtable = other->vtable;
+ prototype = other->prototype;
+ parent = other;
+ size = other->size;
+ extensible = other->extensible;
+ isSealed = other->isSealed;
+ isFrozen = other->isFrozen;
+ isUsedAsProto = other->isUsedAsProto;
+ protoId = engine->newProtoId();
+
+ internalClass.set(engine, other->internalClass);
+}
+
+void InternalClass::destroy()
+{
+#ifndef QT_NO_DEBUG
+ for (const auto &t : transitions) {
+ Q_ASSERT(!t.lookup || !t.lookup->isMarked());
}
+#endif
+ if (parent && parent->engine && parent->isMarked())
+ parent->removeChildEntry(this);
+
+ propertyTable.~PropertyHash();
+ nameMap.~SharedInternalClassData<PropertyKey>();
+ propertyData.~SharedInternalClassData<PropertyAttributes>();
+ transitions.~vector<Transition>();
+ engine = nullptr;
+ Base::destroy();
+}
+
+QString InternalClass::keyAt(uint index) const
+{
+ return nameMap.at(index).toQString();
+}
+
+void InternalClass::changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry)
+{
+ Q_ASSERT(id.isStringOrSymbol());
+
+ Heap::InternalClass *oldClass = object->internalClass();
+ Heap::InternalClass *newClass = oldClass->changeMember(id, data, entry);
+ object->setInternalClass(newClass);
}
InternalClassTransition &InternalClass::lookupOrInsertTransition(const InternalClassTransition &t)
@@ -183,47 +298,66 @@ InternalClassTransition &InternalClass::lookupOrInsertTransition(const InternalC
}
}
-InternalClass *InternalClass::changeMember(Identifier *identifier, PropertyAttributes data, uint *index)
+static void addDummyEntry(InternalClass *newClass, PropertyHash::Entry e)
+{
+ // add a dummy entry, since we need two entries for accessors
+ newClass->propertyTable.addEntry(e, newClass->size);
+ newClass->nameMap.add(newClass->size, PropertyKey::invalid());
+ newClass->propertyData.add(newClass->size, PropertyAttributes());
+ ++newClass->size;
+}
+
+Heap::InternalClass *InternalClass::changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry)
{
- data.resolve();
- uint idx = find(identifier);
+ if (!data.isEmpty())
+ data.resolve();
+ PropertyHash::Entry *e = findEntry(identifier);
+ Q_ASSERT(e && e->index != UINT_MAX);
+ uint idx = e->index;
Q_ASSERT(idx != UINT_MAX);
- if (index)
- *index = idx;
+ if (entry) {
+ entry->index = idx;
+ entry->setterIndex = e->setterIndex;
+ entry->attributes = data;
+ }
if (data == propertyData.at(idx))
- return this;
+ return static_cast<Heap::InternalClass *>(this);
- Transition temp = { { identifier }, nullptr, (int)data.flags() };
+ Transition temp = { { identifier }, nullptr, int(data.all()) };
Transition &t = lookupOrInsertTransition(temp);
if (t.lookup)
return t.lookup;
// create a new class and add it to the tree
- InternalClass *newClass = engine->internalClasses[EngineBase::Class_Empty]->changeVTable(vtable);
- newClass = newClass->changePrototype(prototype);
- for (uint i = 0; i < size; ++i) {
- if (i == idx) {
- newClass = newClass->addMember(nameMap.at(i), data);
- } else if (!propertyData.at(i).isEmpty()) {
- newClass = newClass->addMember(nameMap.at(i), propertyData.at(i));
- }
+ Heap::InternalClass *newClass = engine->newClass(this);
+ if (data.isAccessor() && e->setterIndex == UINT_MAX) {
+ Q_ASSERT(!propertyData.at(idx).isAccessor());
+
+ // add a dummy entry for the accessor
+ entry->setterIndex = newClass->size;
+ e->setterIndex = newClass->size;
+ addDummyEntry(newClass, *e);
}
+ newClass->propertyData.set(idx, data);
+
t.lookup = newClass;
Q_ASSERT(t.lookup);
return newClass;
}
-InternalClass *InternalClass::changePrototypeImpl(Heap::Object *proto)
+Heap::InternalClass *InternalClass::changePrototypeImpl(Heap::Object *proto)
{
+ Scope scope(engine);
+ ScopedValue protectThis(scope, this);
if (proto)
proto->setUsedAsProto();
Q_ASSERT(prototype != proto);
Q_ASSERT(!proto || proto->internalClass->isUsedAsProto);
- Transition temp = { { nullptr }, nullptr, Transition::PrototypeChange };
+ Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::PrototypeChange };
temp.prototype = proto;
Transition &t = lookupOrInsertTransition(temp);
@@ -231,29 +365,19 @@ InternalClass *InternalClass::changePrototypeImpl(Heap::Object *proto)
return t.lookup;
// create a new class and add it to the tree
- InternalClass *newClass;
- if (!size && !prototype) {
- newClass = engine->newClass(*this);
- newClass->prototype = proto;
- } else {
- newClass = engine->internalClasses[EngineBase::Class_Empty]->changeVTable(vtable);
- newClass = newClass->changePrototype(proto);
- for (uint i = 0; i < size; ++i) {
- if (!propertyData.at(i).isEmpty())
- newClass = newClass->addMember(nameMap.at(i), propertyData.at(i));
- }
- }
+ Heap::InternalClass *newClass = engine->newClass(this);
+ newClass->prototype = proto;
t.lookup = newClass;
return newClass;
}
-InternalClass *InternalClass::changeVTableImpl(const VTable *vt)
+Heap::InternalClass *InternalClass::changeVTableImpl(const VTable *vt)
{
Q_ASSERT(vtable != vt);
- Transition temp = { { nullptr }, nullptr, Transition::VTableChange };
+ Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::VTableChange };
temp.vtable = vt;
Transition &t = lookupOrInsertTransition(temp);
@@ -261,18 +385,8 @@ InternalClass *InternalClass::changeVTableImpl(const VTable *vt)
return t.lookup;
// create a new class and add it to the tree
- InternalClass *newClass;
- if (this == engine->internalClasses[EngineBase::Class_Empty]) {
- newClass = engine->newClass(*this);
- newClass->vtable = vt;
- } else {
- newClass = engine->internalClasses[EngineBase::Class_Empty]->changeVTable(vt);
- newClass = newClass->changePrototype(prototype);
- for (uint i = 0; i < size; ++i) {
- if (!propertyData.at(i).isEmpty())
- newClass = newClass->addMember(nameMap.at(i), propertyData.at(i));
- }
- }
+ Heap::InternalClass *newClass = engine->newClass(this);
+ newClass->vtable = vt;
t.lookup = newClass;
Q_ASSERT(t.lookup);
@@ -280,17 +394,17 @@ InternalClass *InternalClass::changeVTableImpl(const VTable *vt)
return newClass;
}
-InternalClass *InternalClass::nonExtensible()
+Heap::InternalClass *InternalClass::nonExtensible()
{
if (!extensible)
return this;
- Transition temp = { { nullptr }, nullptr, Transition::NotExtensible};
+ Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::NotExtensible};
Transition &t = lookupOrInsertTransition(temp);
if (t.lookup)
return t.lookup;
- InternalClass *newClass = engine->newClass(*this);
+ Heap::InternalClass *newClass = engine->newClass(this);
newClass->extensible = false;
t.lookup = newClass;
@@ -298,177 +412,221 @@ InternalClass *InternalClass::nonExtensible()
return newClass;
}
-void InternalClass::addMember(Object *object, String *string, PropertyAttributes data, uint *index)
+void InternalClass::addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry)
{
- data.resolve();
- object->internalClass()->engine->identifierTable->identifier(string);
- if (object->internalClass()->propertyTable.lookup(string->d()->identifier) < object->internalClass()->size) {
- changeMember(object, string, data, index);
+ Q_ASSERT(id.isStringOrSymbol());
+ if (!data.isEmpty())
+ data.resolve();
+ PropertyHash::Entry *e = object->internalClass()->findEntry(id);
+ if (e) {
+ changeMember(object, id, data, entry);
return;
}
- uint idx;
- InternalClass *newClass = object->internalClass()->addMemberImpl(string->identifier(), data, &idx);
- if (index)
- *index = idx;
-
+ Heap::InternalClass *newClass = object->internalClass()->addMemberImpl(id, data, entry);
object->setInternalClass(newClass);
}
-InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, uint *index)
+Heap::InternalClass *InternalClass::addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry)
{
- engine->identifierTable->identifier(string);
- return addMember(string->identifier(), data, index);
-}
+ Q_ASSERT(identifier.isStringOrSymbol());
+ if (!data.isEmpty())
+ data.resolve();
-InternalClass *InternalClass::addMember(Identifier *identifier, PropertyAttributes data, uint *index)
-{
- data.resolve();
-
- if (propertyTable.lookup(identifier) < size)
- return changeMember(identifier, data, index);
+ PropertyHash::Entry *e = findEntry(identifier);
+ if (e)
+ return changeMember(identifier, data, entry);
- return addMemberImpl(identifier, data, index);
+ return addMemberImpl(identifier, data, entry);
}
-InternalClass *InternalClass::addMemberImpl(Identifier *identifier, PropertyAttributes data, uint *index)
+Heap::InternalClass *InternalClass::addMemberImpl(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry)
{
Transition temp = { { identifier }, nullptr, (int)data.flags() };
Transition &t = lookupOrInsertTransition(temp);
- if (index)
- *index = size;
+ if (entry) {
+ entry->index = size;
+ entry->setterIndex = data.isAccessor() ? size + 1 : UINT_MAX;
+ entry->attributes = data;
+ }
if (t.lookup)
return t.lookup;
// create a new class and add it to the tree
- InternalClass *newClass = engine->newClass(*this);
- PropertyHash::Entry e = { identifier, newClass->size };
+ Scope scope(engine);
+ Scoped<QV4::InternalClass> ic(scope, engine->newClass(this));
+ InternalClass *newClass = ic->d();
+ PropertyHash::Entry e = { identifier, newClass->size, data.isAccessor() ? newClass->size + 1 : UINT_MAX };
newClass->propertyTable.addEntry(e, newClass->size);
newClass->nameMap.add(newClass->size, identifier);
newClass->propertyData.add(newClass->size, data);
++newClass->size;
- if (data.isAccessor()) {
- // add a dummy entry, since we need two entries for accessors
- newClass->propertyTable.addEntry(e, newClass->size);
- newClass->nameMap.add(newClass->size, 0);
- newClass->propertyData.add(newClass->size, PropertyAttributes());
- ++newClass->size;
- }
+ if (data.isAccessor())
+ addDummyEntry(newClass, e);
t.lookup = newClass;
Q_ASSERT(t.lookup);
return newClass;
}
-void InternalClass::removeMember(Object *object, Identifier *id)
+void InternalClass::removeChildEntry(InternalClass *child)
{
- InternalClass *oldClass = object->internalClass();
- uint propIdx = oldClass->propertyTable.lookup(id);
- Q_ASSERT(propIdx < oldClass->size);
-
- Transition temp = { { id }, nullptr, -1 };
- Transition &t = object->internalClass()->lookupOrInsertTransition(temp);
-
- bool accessor = oldClass->propertyData.at(propIdx).isAccessor();
-
- if (t.lookup) {
- object->setInternalClass(t.lookup);
- } else {
- // create a new class and add it to the tree
- InternalClass *newClass = oldClass->engine->internalClasses[EngineBase::Class_Empty]->changeVTable(oldClass->vtable);
- newClass = newClass->changePrototype(oldClass->prototype);
- for (uint i = 0; i < oldClass->size; ++i) {
- if (i == propIdx)
- continue;
- if (!oldClass->propertyData.at(i).isEmpty())
- newClass = newClass->addMember(oldClass->nameMap.at(i), oldClass->propertyData.at(i));
+ Q_ASSERT(engine);
+ for (auto &t : transitions) {
+ if (t.lookup == child) {
+ t.lookup = nullptr;
+ return;
}
- object->setInternalClass(newClass);
}
+ Q_UNREACHABLE();
- Q_ASSERT(object->internalClass()->size == oldClass->size - (accessor ? 2 : 1));
-
- // remove the entry in the property data
- removeFromPropertyData(object, propIdx, accessor);
-
- t.lookup = object->internalClass();
- Q_ASSERT(t.lookup);
}
-uint InternalClass::find(const String *string)
+void InternalClass::removeMember(QV4::Object *object, PropertyKey identifier)
{
- engine->identifierTable->identifier(string);
- const Identifier *id = string->d()->identifier;
+#ifndef QT_NO_DEBUG
+ Heap::InternalClass *oldClass = object->internalClass();
+ Q_ASSERT(oldClass->findEntry(identifier) != nullptr);
+#endif
- uint index = propertyTable.lookup(id);
- if (index < size)
- return index;
+ changeMember(object, identifier, Attr_Invalid);
- return UINT_MAX;
+#ifndef QT_NO_DEBUG
+ // we didn't remove the data slot, just made it inaccessible
+ Q_ASSERT(object->internalClass()->size == oldClass->size);
+#endif
}
-InternalClass *InternalClass::sealed()
+Heap::InternalClass *InternalClass::sealed()
{
- if (m_sealed)
- return m_sealed;
+ if (isSealed)
+ return this;
+
+ bool alreadySealed = !extensible;
+ for (uint i = 0; i < size; ++i) {
+ PropertyAttributes attrs = propertyData.at(i);
+ if (attrs.isEmpty())
+ continue;
+ if (attrs.isConfigurable()) {
+ alreadySealed = false;
+ break;
+ }
+ }
+
+ if (alreadySealed) {
+ isSealed = true;
+ return this;
+ }
+
+ Transition temp = { { PropertyKey::invalid() }, nullptr, InternalClassTransition::Sealed };
+ Transition &t = lookupOrInsertTransition(temp);
+
+ if (t.lookup) {
+ Q_ASSERT(t.lookup && t.lookup->isSealed);
+ return t.lookup;
+ }
+
+ Scope scope(engine);
+ Scoped<QV4::InternalClass> ic(scope, engine->newClass(this));
+ Heap::InternalClass *s = ic->d();
- m_sealed = engine->internalClasses[EngineBase::Class_Empty]->changeVTable(vtable);
- m_sealed = m_sealed->changePrototype(prototype);
for (uint i = 0; i < size; ++i) {
PropertyAttributes attrs = propertyData.at(i);
if (attrs.isEmpty())
continue;
attrs.setConfigurable(false);
- m_sealed = m_sealed->addMember(nameMap.at(i), attrs);
+ s->propertyData.set(i, attrs);
}
- m_sealed = m_sealed->nonExtensible();
+ s->extensible = false;
+ s->isSealed = true;
- m_sealed->m_sealed = m_sealed;
- return m_sealed;
+ t.lookup = s;
+ return s;
}
-InternalClass *InternalClass::frozen()
+Heap::InternalClass *InternalClass::frozen()
{
- if (m_frozen)
- return m_frozen;
+ if (isFrozen)
+ return this;
+
+ bool alreadyFrozen = !extensible;
+ for (uint i = 0; i < size; ++i) {
+ PropertyAttributes attrs = propertyData.at(i);
+ if (attrs.isEmpty())
+ continue;
+ if ((attrs.isData() && attrs.isWritable()) || attrs.isConfigurable()) {
+ alreadyFrozen = false;
+ break;
+ }
+ }
+
+ if (alreadyFrozen) {
+ isSealed = true;
+ isFrozen = true;
+ return this;
+ }
- m_frozen = propertiesFrozen();
- m_frozen = m_frozen->nonExtensible();
+ Transition temp = { { PropertyKey::invalid() }, nullptr, InternalClassTransition::Frozen };
+ Transition &t = lookupOrInsertTransition(temp);
+
+ if (t.lookup) {
+ Q_ASSERT(t.lookup && t.lookup->isSealed && t.lookup->isFrozen);
+ return t.lookup;
+ }
- m_frozen->m_frozen = m_frozen;
- m_frozen->m_sealed = m_frozen;
- return m_frozen;
+ Scope scope(engine);
+ Scoped<QV4::InternalClass> ic(scope, engine->newClass(this));
+ Heap::InternalClass *f = ic->d();
+
+ for (uint i = 0; i < size; ++i) {
+ PropertyAttributes attrs = propertyData.at(i);
+ if (attrs.isEmpty())
+ continue;
+ if (attrs.isData())
+ attrs.setWritable(false);
+ attrs.setConfigurable(false);
+ f->propertyData.set(i, attrs);
+ }
+ f->extensible = false;
+ f->isSealed = true;
+ f->isFrozen = true;
+
+ t.lookup = f;
+ return f;
}
-InternalClass *InternalClass::propertiesFrozen() const
+Heap::InternalClass *InternalClass::propertiesFrozen() const
{
- InternalClass *frozen = engine->internalClasses[EngineBase::Class_Empty]->changeVTable(vtable);
+ Scope scope(engine);
+ Scoped<QV4::InternalClass> frozen(scope, engine->internalClasses(EngineBase::Class_Empty)->changeVTable(vtable));
frozen = frozen->changePrototype(prototype);
for (uint i = 0; i < size; ++i) {
PropertyAttributes attrs = propertyData.at(i);
- if (attrs.isEmpty())
+ if (!nameMap.at(i).isValid())
continue;
- attrs.setWritable(false);
- attrs.setConfigurable(false);
+ if (!attrs.isEmpty()) {
+ attrs.setWritable(false);
+ attrs.setConfigurable(false);
+ }
frozen = frozen->addMember(nameMap.at(i), attrs);
}
- return frozen;
+ return frozen->d();
}
-InternalClass *InternalClass::asProtoClass()
+Heap::InternalClass *InternalClass::asProtoClass()
{
if (isUsedAsProto)
return this;
- Transition temp = { { nullptr }, nullptr, Transition::ProtoClass };
+ Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::ProtoClass };
Transition &t = lookupOrInsertTransition(temp);
if (t.lookup)
return t.lookup;
- InternalClass *newClass = engine->newClass(*this);
+ Heap::InternalClass *newClass = engine->newClass(this);
newClass->isUsedAsProto = true;
t.lookup = newClass;
@@ -476,90 +634,39 @@ InternalClass *InternalClass::asProtoClass()
return newClass;
}
-void InternalClass::destroy()
+static void updateProtoUsage(Heap::Object *o, Heap::InternalClass *ic)
{
- std::vector<InternalClass *> destroyStack;
- destroyStack.reserve(64);
- destroyStack.push_back(this);
-
- while (!destroyStack.empty()) {
- InternalClass *next = destroyStack.back();
- destroyStack.pop_back();
- if (!next->engine)
- continue;
- next->engine = nullptr;
- next->propertyTable.~PropertyHash();
- next->nameMap.~SharedInternalClassData<Identifier *>();
- next->propertyData.~SharedInternalClassData<PropertyAttributes>();
- if (next->m_sealed)
- destroyStack.push_back(next->m_sealed);
- if (next->m_frozen)
- destroyStack.push_back(next->m_frozen);
-
- for (size_t i = 0; i < next->transitions.size(); ++i) {
- Q_ASSERT(next->transitions.at(i).lookup);
- destroyStack.push_back(next->transitions.at(i).lookup);
- }
-
- next->transitions.~vector<Transition>();
+ if (ic->prototype == o)
+ ic->protoId = ic->engine->newProtoId();
+ for (auto &t : ic->transitions) {
+ if (t.lookup)
+ updateProtoUsage(o, t.lookup);
}
}
+
void InternalClass::updateProtoUsage(Heap::Object *o)
{
Q_ASSERT(isUsedAsProto);
- InternalClass *ic = engine->internalClasses[EngineBase::Class_Empty];
+ Heap::InternalClass *ic = engine->internalClasses(EngineBase::Class_Empty);
Q_ASSERT(!ic->prototype);
- // only need to go two levels into the IC hierarchy, as prototype changes
- // can only happen there
- for (auto &t : ic->transitions) {
- Q_ASSERT(t.lookup);
- if (t.flags == InternalClassTransition::VTableChange) {
- InternalClass *ic2 = t.lookup;
- for (auto &t2 : ic2->transitions) {
- if (t2.flags == InternalClassTransition::PrototypeChange &&
- t2.lookup->prototype == o)
- ic2->updateInternalClassIdRecursive();
- }
- } else if (t.flags == InternalClassTransition::PrototypeChange && t.lookup->prototype == o) {
- ic->updateInternalClassIdRecursive();
- }
- }
+ Heap::updateProtoUsage(o, ic);
}
-void InternalClass::updateInternalClassIdRecursive()
+void InternalClass::markObjects(Heap::Base *b, MarkStack *stack)
{
- id = engine->newInternalClassId();
- for (auto &t : transitions) {
- Q_ASSERT(t.lookup);
- if (t.flags == InternalClassTransition::VTableChange || t.flags == InternalClassTransition::PrototypeChange)
- continue;
- t.lookup->updateInternalClassIdRecursive();
- }
-}
-
+ Heap::InternalClass *ic = static_cast<Heap::InternalClass *>(b);
+ if (ic->prototype)
+ ic->prototype->mark(stack);
+ if (ic->parent)
+ ic->parent->mark(stack);
+ ic->nameMap.mark(stack);
+}
-void InternalClassPool::markObjects(MarkStack *markStack)
-{
- InternalClass *ic = markStack->engine->internalClasses[EngineBase::Class_Empty];
- Q_ASSERT(!ic->prototype);
+}
- // only need to go two levels into the IC hierarchy, as prototype changes
- // can only happen there
- for (auto &t : ic->transitions) {
- Q_ASSERT(t.lookup);
- if (t.flags == InternalClassTransition::VTableChange) {
- InternalClass *ic2 = t.lookup;
- for (auto &t2 : ic2->transitions) {
- if (t2.flags == InternalClassTransition::PrototypeChange)
- t2.lookup->prototype->mark(markStack);
- }
- } else if (t.flags == InternalClassTransition::PrototypeChange) {
- t.lookup->prototype->mark(markStack);
- }
- }
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h
index b689272006..681cbda5f9 100644
--- a/src/qml/jsruntime/qv4internalclass_p.h
+++ b/src/qml/jsruntime/qv4internalclass_p.h
@@ -53,25 +53,30 @@
#include "qv4global_p.h"
#include <QHash>
-#include <private/qqmljsmemorypool_p.h>
-#include <private/qv4identifier_p.h>
+#include <private/qv4propertykey_p.h>
+#include <private/qv4heap_p.h>
QT_BEGIN_NAMESPACE
namespace QV4 {
-struct String;
-struct Object;
-struct Identifier;
struct VTable;
struct MarkStack;
+struct InternalClassEntry {
+ uint index;
+ uint setterIndex;
+ PropertyAttributes attributes;
+ bool isValid() const { return !attributes.isEmpty(); }
+};
+
struct PropertyHashData;
struct PropertyHash
{
struct Entry {
- const Identifier *identifier;
+ PropertyKey identifier;
uint index;
+ uint setterIndex;
};
PropertyHashData *d;
@@ -79,12 +84,12 @@ struct PropertyHash
inline PropertyHash();
inline PropertyHash(const PropertyHash &other);
inline ~PropertyHash();
+ PropertyHash &operator=(const PropertyHash &other);
void addEntry(const Entry &entry, int classSize);
- uint lookup(const Identifier *identifier) const;
-
-private:
- PropertyHash &operator=(const PropertyHash &other);
+ Entry *lookup(PropertyKey identifier) const;
+ int removeIdentifier(PropertyKey identifier, int classSize);
+ void detach(bool grow, int classSize);
};
struct PropertyHashData
@@ -118,40 +123,121 @@ inline PropertyHash::~PropertyHash()
delete d;
}
-inline uint PropertyHash::lookup(const Identifier *identifier) const
+inline PropertyHash &PropertyHash::operator=(const PropertyHash &other)
+{
+ ++other.d->refCount;
+ if (!--d->refCount)
+ delete d;
+ d = other.d;
+ return *this;
+}
+
+
+
+inline PropertyHash::Entry *PropertyHash::lookup(PropertyKey identifier) const
{
Q_ASSERT(d->entries);
- uint idx = identifier->hashValue % d->alloc;
+ uint idx = identifier.id() % d->alloc;
while (1) {
if (d->entries[idx].identifier == identifier)
- return d->entries[idx].index;
- if (!d->entries[idx].identifier)
- return UINT_MAX;
+ return d->entries + idx;
+ if (!d->entries[idx].identifier.isValid())
+ return nullptr;
++idx;
idx %= d->alloc;
}
}
+template<typename T>
+struct SharedInternalClassDataPrivate {
+ SharedInternalClassDataPrivate(ExecutionEngine *)
+ : refcount(1),
+ m_alloc(0),
+ m_size(0),
+ data(nullptr)
+ { }
+ SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other)
+ : refcount(1),
+ m_alloc(other.m_alloc),
+ m_size(other.m_size)
+ {
+ if (m_alloc) {
+ data = new T[m_alloc];
+ memcpy(data, other.data, m_size*sizeof(T));
+ }
+ }
+ SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other, uint pos, T value)
+ : refcount(1),
+ m_alloc(pos + 8),
+ m_size(pos + 1)
+ {
+ data = new T[m_alloc];
+ if (other.data)
+ memcpy(data, other.data, (m_size - 1)*sizeof(T));
+ data[pos] = value;
+ }
+ ~SharedInternalClassDataPrivate() { delete [] data; }
+
+
+ void grow() {
+ if (!m_alloc)
+ m_alloc = 4;
+ T *n = new T[m_alloc * 2];
+ if (data) {
+ memcpy(n, data, m_alloc*sizeof(T));
+ delete [] data;
+ }
+ data = n;
+ m_alloc *= 2;
+ }
+
+ uint alloc() const { return m_alloc; }
+ uint size() const { return m_size; }
+ void setSize(uint s) { m_size = s; }
+
+ T at(uint i) { Q_ASSERT(data && i < m_alloc); return data[i]; }
+ void set(uint i, T t) { Q_ASSERT(data && i < m_alloc); data[i] = t; }
+
+ void mark(MarkStack *) {}
+
+ int refcount = 1;
+private:
+ uint m_alloc;
+ uint m_size;
+ T *data;
+};
+
+template<>
+struct SharedInternalClassDataPrivate<PropertyKey> {
+ SharedInternalClassDataPrivate(ExecutionEngine *e) : refcount(1), engine(e), data(nullptr) {}
+ SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other);
+ SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other, uint pos, PropertyKey value);
+ ~SharedInternalClassDataPrivate() {}
+
+ void grow();
+ uint alloc() const;
+ uint size() const;
+ void setSize(uint s);
+
+ PropertyKey at(uint i);
+ void set(uint i, PropertyKey t);
+
+ void mark(MarkStack *s);
+
+ int refcount = 1;
+private:
+ ExecutionEngine *engine;
+ Heap::MemberData *data;
+};
+
template <typename T>
struct SharedInternalClassData {
- struct Private {
- Private(int alloc)
- : refcount(1),
- alloc(alloc),
- size(0)
- { data = new T [alloc]; }
- ~Private() { delete [] data; }
-
- int refcount;
- uint alloc;
- uint size;
- T *data;
- };
+ using Private = SharedInternalClassDataPrivate<T>;
Private *d;
- inline SharedInternalClassData() {
- d = new Private(8);
+ inline SharedInternalClassData(ExecutionEngine *e) {
+ d = new Private(e);
}
inline SharedInternalClassData(const SharedInternalClassData &other)
@@ -163,77 +249,72 @@ struct SharedInternalClassData {
if (!--d->refcount)
delete d;
}
+ SharedInternalClassData &operator=(const SharedInternalClassData &other) {
+ ++other.d->refcount;
+ if (!--d->refcount)
+ delete d;
+ d = other.d;
+ return *this;
+ }
void add(uint pos, T value) {
- if (pos < d->size) {
+ if (pos < d->size()) {
Q_ASSERT(d->refcount > 1);
// need to detach
- Private *dd = new Private(pos + 8);
- memcpy(dd->data, d->data, pos*sizeof(T));
- dd->size = pos + 1;
- dd->data[pos] = value;
+ Private *dd = new Private(*d, pos, value);
if (!--d->refcount)
delete d;
d = dd;
return;
}
- Q_ASSERT(pos == d->size);
- if (pos == d->alloc) {
- T *n = new T[d->alloc * 2];
- memcpy(n, d->data, d->alloc*sizeof(T));
- delete [] d->data;
- d->data = n;
- d->alloc *= 2;
- }
- d->data[pos] = value;
- ++d->size;
+ Q_ASSERT(pos == d->size());
+ if (pos == d->alloc())
+ d->grow();
+ d->setSize(d->size() + 1);
+ d->set(pos, value);
}
void set(uint pos, T value) {
- Q_ASSERT(pos < d->size);
+ Q_ASSERT(pos < d->size());
if (d->refcount > 1) {
// need to detach
- Private *dd = new Private(d->alloc);
- memcpy(dd->data, d->data, d->size*sizeof(T));
- dd->size = d->size;
+ Private *dd = new Private(*d);
if (!--d->refcount)
delete d;
d = dd;
}
- d->data[pos] = value;
+ d->set(pos, value);
}
- T *constData() const {
- return d->data;
- }
T at(uint i) const {
- Q_ASSERT(i < d->size);
- return d->data[i];
+ Q_ASSERT(i < d->size());
+ return d->at(i);
}
T operator[] (uint i) {
- Q_ASSERT(i < d->size);
- return d->data[i];
+ Q_ASSERT(i < d->size());
+ return d->at(i);
}
-private:
- SharedInternalClassData &operator=(const SharedInternalClassData &other);
+ void mark(MarkStack *s) { d->mark(s); }
};
struct InternalClassTransition
{
union {
- Identifier *id;
+ PropertyKey id;
const VTable *vtable;
Heap::Object *prototype;
};
- InternalClass *lookup;
+ Heap::InternalClass *lookup;
int flags;
enum {
// range 0-0xff is reserved for attribute changes
NotExtensible = 0x100,
VTableChange = 0x200,
PrototypeChange = 0x201,
- ProtoClass = 0x202
+ ProtoClass = 0x202,
+ Sealed = 0x203,
+ Frozen = 0x204
};
bool operator==(const InternalClassTransition &other) const
@@ -243,79 +324,168 @@ struct InternalClassTransition
{ return id < other.id || (id == other.id && flags < other.flags); }
};
-struct InternalClass : public QQmlJS::Managed {
- int id = 0; // unique across the engine, gets changed also when proto chain changes
+namespace Heap {
+
+struct InternalClass : Base {
ExecutionEngine *engine;
const VTable *vtable;
+ quintptr protoId; // unique across the engine, gets changed whenever the proto chain changes
Heap::Object *prototype;
+ InternalClass *parent;
PropertyHash propertyTable; // id to valueIndex
- SharedInternalClassData<Identifier *> nameMap;
+ SharedInternalClassData<PropertyKey> nameMap;
SharedInternalClassData<PropertyAttributes> propertyData;
typedef InternalClassTransition Transition;
std::vector<Transition> transitions;
InternalClassTransition &lookupOrInsertTransition(const InternalClassTransition &t);
- InternalClass *m_sealed;
- InternalClass *m_frozen;
-
uint size;
bool extensible;
- bool isUsedAsProto = false;
+ bool isSealed;
+ bool isFrozen;
+ bool isUsedAsProto;
+ void init(ExecutionEngine *engine);
+ void init(InternalClass *other);
+ void destroy();
+
+ Q_QML_PRIVATE_EXPORT QString keyAt(uint index) const;
Q_REQUIRED_RESULT InternalClass *nonExtensible();
- Q_REQUIRED_RESULT InternalClass *changeVTable(const VTable *vt) {
- if (vtable == vt)
- return this;
- return changeVTableImpl(vt);
+
+ static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry);
+ Q_REQUIRED_RESULT InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr);
+ Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr);
+ static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry = nullptr);
+ static void removeMember(QV4::Object *object, PropertyKey identifier);
+ PropertyHash::Entry *findEntry(const PropertyKey id)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size)
+ return e;
+
+ return nullptr;
}
- Q_REQUIRED_RESULT InternalClass *changePrototype(Heap::Object *proto) {
- if (prototype == proto)
- return this;
- return changePrototypeImpl(proto);
+
+ InternalClassEntry find(const PropertyKey id)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ PropertyAttributes a = propertyData.at(e->index);
+ if (!a.isEmpty())
+ return { e->index, e->setterIndex, a };
+ }
+
+ return { UINT_MAX, UINT_MAX, Attr_Invalid };
+ }
+
+ struct IndexAndAttribute {
+ uint index;
+ PropertyAttributes attrs;
+ bool isValid() const { return index != UINT_MAX; }
+ };
+
+ IndexAndAttribute findValueOrGetter(const PropertyKey id)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ PropertyAttributes a = propertyData.at(e->index);
+ if (!a.isEmpty())
+ return { e->index, a };
+ }
+
+ return { UINT_MAX, Attr_Invalid };
+ }
+
+ IndexAndAttribute findValueOrSetter(const PropertyKey id)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ PropertyAttributes a = propertyData.at(e->index);
+ if (!a.isEmpty()) {
+ if (a.isAccessor()) {
+ Q_ASSERT(e->setterIndex != UINT_MAX);
+ return { e->setterIndex, a };
+ }
+ return { e->index, a };
+ }
+ }
+
+ return { UINT_MAX, Attr_Invalid };
}
- static void addMember(Object *object, String *string, PropertyAttributes data, uint *index);
- Q_REQUIRED_RESULT InternalClass *addMember(String *string, PropertyAttributes data, uint *index = nullptr);
- Q_REQUIRED_RESULT InternalClass *addMember(Identifier *identifier, PropertyAttributes data, uint *index = nullptr);
- Q_REQUIRED_RESULT InternalClass *changeMember(Identifier *identifier, PropertyAttributes data, uint *index = nullptr);
- static void changeMember(Object *object, String *string, PropertyAttributes data, uint *index = nullptr);
- static void removeMember(Object *object, Identifier *id);
- uint find(const String *string);
- uint find(const Identifier *id)
+ uint indexOfValueOrGetter(const PropertyKey id)
{
- uint index = propertyTable.lookup(id);
- if (index < size)
- return index;
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ Q_ASSERT(!propertyData.at(e->index).isEmpty());
+ return e->index;
+ }
return UINT_MAX;
}
+ bool verifyIndex(const PropertyKey id, uint index)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ Q_ASSERT(!propertyData.at(e->index).isEmpty());
+ return e->index == index;
+ }
+
+ return false;
+ }
+
Q_REQUIRED_RESULT InternalClass *sealed();
Q_REQUIRED_RESULT InternalClass *frozen();
Q_REQUIRED_RESULT InternalClass *propertiesFrozen() const;
Q_REQUIRED_RESULT InternalClass *asProtoClass();
- void destroy();
+ Q_REQUIRED_RESULT InternalClass *changeVTable(const VTable *vt) {
+ if (vtable == vt)
+ return this;
+ return changeVTableImpl(vt);
+ }
+ Q_REQUIRED_RESULT InternalClass *changePrototype(Heap::Object *proto) {
+ if (prototype == proto)
+ return this;
+ return changePrototypeImpl(proto);
+ }
void updateProtoUsage(Heap::Object *o);
+ static void markObjects(Heap::Base *ic, MarkStack *stack);
+
private:
Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt);
Q_QML_EXPORT InternalClass *changePrototypeImpl(Heap::Object *proto);
- InternalClass *addMemberImpl(Identifier *identifier, PropertyAttributes data, uint *index);
- void updateInternalClassIdRecursive();
+ InternalClass *addMemberImpl(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry);
+
+ void removeChildEntry(InternalClass *child);
friend struct ExecutionEngine;
- InternalClass(ExecutionEngine *engine);
- InternalClass(const InternalClass &other);
};
-struct InternalClassPool : public QQmlJS::MemoryPool
+inline
+void Base::markObjects(Base *b, MarkStack *stack)
{
- void markObjects(MarkStack *markStack);
-};
+ b->internalClass->mark(stack);
+}
+
+}
}
diff --git a/src/qml/jsruntime/qv4iterator.cpp b/src/qml/jsruntime/qv4iterator.cpp
new file mode 100644
index 0000000000..a543565b37
--- /dev/null
+++ b/src/qml/jsruntime/qv4iterator.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qv4iterator_p.h>
+#include <qv4symbol_p.h>
+#include <qv4engine_p.h>
+
+using namespace QV4;
+
+void IteratorPrototype::init(ExecutionEngine *engine)
+{
+ defineDefaultProperty(engine->symbol_iterator(), method_iterator, 0);
+}
+
+ReturnedValue IteratorPrototype::method_iterator(const FunctionObject *, const Value *thisObject, const Value *, int)
+{
+ return thisObject->asReturnedValue();
+}
+
+
+ReturnedValue IteratorPrototype::createIterResultObject(ExecutionEngine *engine, const Value &value, bool done)
+{
+ Scope scope(engine);
+ ScopedObject obj(scope, engine->newObject());
+ obj->set(ScopedString(scope, engine->newString(QStringLiteral("value"))), value, Object::DoNotThrow);
+ obj->set(ScopedString(scope, engine->newString(QStringLiteral("done"))), Value::fromBoolean(done), Object::DoNotThrow);
+ return obj->asReturnedValue();
+}
+
diff --git a/src/qml/jsruntime/qv4iterator_p.h b/src/qml/jsruntime/qv4iterator_p.h
new file mode 100644
index 0000000000..28e337d21b
--- /dev/null
+++ b/src/qml/jsruntime/qv4iterator_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4ITERATOR_P_H
+#define QV4ITERATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4arraydata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+namespace QV4 {
+
+enum IteratorKind {
+ KeyIteratorKind,
+ ValueIteratorKind,
+ KeyValueIteratorKind
+};
+
+struct IteratorPrototype : Object
+{
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_iterator(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue createIterResultObject(ExecutionEngine *engine, const Value &value, bool done);
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4ARRAYITERATOR_P_H
+
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index c676b57c51..31689b1ba1 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -55,6 +55,7 @@
#include "qv4functionobject_p.h"
#include "qv4context_p.h"
#include "qv4scopedvalue_p.h"
+#include "qv4stackframe_p.h"
QT_BEGIN_NAMESPACE
@@ -67,7 +68,7 @@ struct JSCallData {
if (thisObject)
this->thisObject = const_cast<Value *>(thisObject);
else
- this->thisObject = scope.alloc(1);
+ this->thisObject = scope.alloc();
if (argv)
this->args = const_cast<Value *>(argv);
else
@@ -80,12 +81,12 @@ struct JSCallData {
CallData *callData(const FunctionObject *f = nullptr) const {
int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc;
- CallData *ptr = reinterpret_cast<CallData *>(scope.engine->jsStackTop);
- scope.engine->jsStackTop += size;
+ CallData *ptr = reinterpret_cast<CallData *>(scope.alloc<Scope::Uninitialized>(size));
ptr->function = Encode::undefined();
ptr->context = Encode::undefined();
ptr->accumulator = Encode::undefined();
ptr->thisObject = thisObject->asReturnedValue();
+ ptr->newTarget = Encode::undefined();
ptr->setArgc(argc);
if (argc)
memcpy(ptr->args, args, argc*sizeof(Value));
@@ -102,13 +103,13 @@ struct JSCallData {
inline
ReturnedValue FunctionObject::callAsConstructor(const JSCallData &data) const
{
- return d()->jsConstruct(this, data.args, data.argc);
+ return callAsConstructor(data.args, data.argc, this);
}
inline
ReturnedValue FunctionObject::call(const JSCallData &data) const
{
- return d()->jsCall(this, data.thisObject, data.args, data.argc);
+ return call(data.thisObject, data.args, data.argc);
}
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index c3569c29d2..0c5436a0d6 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -47,6 +47,7 @@
#include <qv4variantobject_p.h>
#include "qv4string_p.h"
#include "qv4jscall_p.h"
+#include <qv4symbol_p.h>
#include <qstack.h>
#include <qstringlist.h>
@@ -260,11 +261,12 @@ bool JsonParser::parseMember(Object *o)
if (!parseValue(val))
return false;
- ScopedString s(scope, engine->newIdentifier(key));
- uint idx = s->asArrayIndex();
- if (idx < UINT_MAX) {
- o->putIndexed(idx, val);
+ ScopedString s(scope, engine->newString(key));
+ PropertyKey skey = s->toPropertyKey();
+ if (skey.isArrayIndex()) {
+ o->put(skey.asArrayIndex(), val);
} else {
+ // avoid trouble with properties named __proto__
o->insertMember(s, val);
}
@@ -338,7 +340,7 @@ bool JsonParser::parseValue(Value *val)
if (*json++ == 'u' &&
*json++ == 'l' &&
*json++ == 'l') {
- *val = Primitive::nullValue();
+ *val = Value::nullValue();
DEBUG << "value: null";
END;
return true;
@@ -353,7 +355,7 @@ bool JsonParser::parseValue(Value *val)
if (*json++ == 'r' &&
*json++ == 'u' &&
*json++ == 'e') {
- *val = Primitive::fromBoolean(true);
+ *val = Value::fromBoolean(true);
DEBUG << "value: true";
END;
return true;
@@ -369,7 +371,7 @@ bool JsonParser::parseValue(Value *val)
*json++ == 'l' &&
*json++ == 's' &&
*json++ == 'e') {
- *val = Primitive::fromBoolean(false);
+ *val = Value::fromBoolean(false);
DEBUG << "value: false";
END;
return true;
@@ -477,7 +479,7 @@ bool JsonParser::parseNumber(Value *val)
bool ok;
int n = number.toInt(&ok);
if (ok && n < (1<<25) && n > -(1<<25)) {
- *val = Primitive::fromInt32(n);
+ *val = Value::fromInt32(n);
END;
return true;
}
@@ -492,7 +494,7 @@ bool JsonParser::parseNumber(Value *val)
return false;
}
- * val = Primitive::fromDouble(d);
+ * val = Value::fromDouble(d);
END;
return true;
@@ -743,7 +745,7 @@ QString Stringify::Str(const QString &key, const Value &v)
o = value->asReturnedValue();
if (o) {
if (!o->as<FunctionObject>()) {
- if (o->as<ArrayObject>() || o->isListType()) {
+ if (o->isArrayLike()) {
return JA(o.getPointer());
} else {
return JO(o);
@@ -846,7 +848,7 @@ QString Stringify::JA(Object *a)
ScopedValue v(scope);
for (uint i = 0; i < len; ++i) {
bool exists;
- v = a->getIndexed(i, &exists);
+ v = a->get(i, &exists);
if (!exists) {
partial += QStringLiteral("null");
continue;
@@ -881,6 +883,8 @@ void Heap::JsonObject::init()
o->defineDefaultProperty(QStringLiteral("parse"), QV4::JsonObject::method_parse, 2);
o->defineDefaultProperty(QStringLiteral("stringify"), QV4::JsonObject::method_stringify, 3);
+ ScopedString json(scope, scope.engine->newString(QStringLiteral("JSON")));
+ o->defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), json);
}
@@ -908,7 +912,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
Scope scope(b);
Stringify stringify(scope.engine);
- ScopedObject o(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedObject o(scope, argc > 1 ? argv[1] : Value::undefinedValue());
if (o) {
stringify.replacerFunction = o->as<FunctionObject>();
if (o->isArrayObject()) {
@@ -916,7 +920,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
stringify.propertyList = static_cast<QV4::String *>(scope.alloc(arrayLen));
for (uint i = 0; i < arrayLen; ++i) {
Value *v = stringify.propertyList + i;
- *v = o->getIndexed(i);
+ *v = o->get(i);
if (v->as<NumberObject>() || v->as<StringObject>() || v->isNumber())
*v = v->toString(scope.engine);
if (!v->isString()) {
@@ -933,7 +937,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
}
}
- ScopedValue s(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedValue s(scope, argc > 2 ? argv[2] : Value::undefinedValue());
if (NumberObject *n = s->as<NumberObject>())
s = Encode(n->value());
else if (StringObject *so = s->as<StringObject>())
@@ -946,7 +950,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
}
- ScopedValue arg0(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue arg0(scope, argc ? argv[0] : Value::undefinedValue());
QString result = stringify.Str(QString(), arg0);
if (result.isEmpty() || scope.engine->hasException)
RETURN_UNDEFINED();
@@ -1078,7 +1082,7 @@ QJsonArray JsonObject::toJsonArray(const ArrayObject *a, V4ObjectSet &visitedObj
ScopedValue v(scope);
quint32 length = a->getLength();
for (quint32 i = 0; i < length; ++i) {
- v = a->getIndexed(i);
+ v = a->get(i);
if (v->as<FunctionObject>())
v = Encode::null();
result.append(toJsonValue(v, visitedObjects));
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 52ab03cd94..994daa864b 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -47,13 +47,13 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
-void Lookup::resolveProtoGetter(Identifier *name, const Heap::Object *proto)
+void Lookup::resolveProtoGetter(PropertyKey name, const Heap::Object *proto)
{
while (proto) {
- uint index = proto->internalClass->find(name);
- if (index != UINT_MAX) {
- PropertyAttributes attrs = proto->internalClass->propertyData.at(index);
- protoLookup.data = proto->propertyData(index);
+ auto index = proto->internalClass->findValueOrGetter(name);
+ if (index.isValid()) {
+ PropertyAttributes attrs = index.attrs;
+ protoLookup.data = proto->propertyData(index.index);
if (attrs.isData()) {
getter = getterProto;
} else {
@@ -70,29 +70,34 @@ void Lookup::resolveProtoGetter(Identifier *name, const Heap::Object *proto)
ReturnedValue Lookup::resolveGetter(ExecutionEngine *engine, const Object *object)
{
Heap::Object *obj = object->d();
- Identifier *name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ if (name.isArrayIndex()) {
+ indexedLookup.index = name.asArrayIndex();
+ getter = getterIndexed;
+ return getter(this, engine, *object);
+ }
- uint index = obj->internalClass->find(name);
- if (index != UINT_MAX) {
- PropertyAttributes attrs = obj->internalClass->propertyData.at(index);
+ auto index = obj->internalClass->findValueOrGetter(name);
+ if (index.isValid()) {
+ PropertyAttributes attrs = index.attrs;
uint nInline = obj->vtable()->nInlineProperties;
if (attrs.isData()) {
- if (index < obj->vtable()->nInlineProperties) {
- index += obj->vtable()->inlinePropertyOffset;
+ if (index.index < obj->vtable()->nInlineProperties) {
+ index.index += obj->vtable()->inlinePropertyOffset;
getter = getter0Inline;
} else {
- index -= nInline;
+ index.index -= nInline;
getter = getter0MemberData;
}
} else {
getter = getterAccessor;
}
objectLookup.ic = obj->internalClass;
- objectLookup.offset = index;
+ objectLookup.offset = index.index;
return getter(this, engine, *object);
}
- protoLookup.icIdentifier = obj->internalClass->id;
+ protoLookup.protoId = obj->internalClass->protoId;
resolveProtoGetter(name, obj->prototype());
return getter(this, engine, *object);
}
@@ -109,11 +114,12 @@ ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Valu
break;
case Value::Managed_Type: {
// ### Should move this over to the Object path, as strings also have an internalClass
- Q_ASSERT(object.isString());
- primitiveLookup.proto = engine->stringPrototype()->d();
+ Q_ASSERT(object.isStringOrSymbol());
+ primitiveLookup.proto = static_cast<const Managed &>(object).internalClass()->prototype;
+ Q_ASSERT(primitiveLookup.proto);
Scope scope(engine);
ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- if (name->equals(engine->id_length())) {
+ if (object.isString() && name->equals(engine->id_length())) {
// special case, as the property is on the object itself
getter = stringLengthGetter;
return stringLengthGetter(this, engine, object);
@@ -125,8 +131,8 @@ ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Valu
primitiveLookup.proto = engine->numberPrototype()->d();
}
- Identifier *name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- protoLookup.icIdentifier = primitiveLookup.proto->internalClass->id;
+ PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ protoLookup.protoId = primitiveLookup.proto->internalClass->protoId;
resolveProtoGetter(name, primitiveLookup.proto);
if (getter == getterProto)
@@ -139,8 +145,8 @@ ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Valu
ReturnedValue Lookup::resolveGlobalGetter(ExecutionEngine *engine)
{
Object *o = engine->globalObject;
- Identifier *name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- protoLookup.icIdentifier = o->internalClass()->id;
+ PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ protoLookup.protoId = o->internalClass()->protoId;
resolveProtoGetter(name, o->d());
if (getter == getterProto)
@@ -188,16 +194,16 @@ ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const
return result;
}
if (first.getter == getterProto && second.getter == getterProto) {
- l->protoLookupTwoClasses.icIdentifier = first.protoLookup.icIdentifier;
- l->protoLookupTwoClasses.icIdentifier2 = second.protoLookup.icIdentifier;
+ l->protoLookupTwoClasses.protoId = first.protoLookup.protoId;
+ l->protoLookupTwoClasses.protoId2 = second.protoLookup.protoId;
l->protoLookupTwoClasses.data = first.protoLookup.data;
l->protoLookupTwoClasses.data2 = second.protoLookup.data;
l->getter = getterProtoTwoClasses;
return result;
}
if (first.getter == getterProtoAccessor && second.getter == getterProtoAccessor) {
- l->protoLookupTwoClasses.icIdentifier = first.protoLookup.icIdentifier;
- l->protoLookupTwoClasses.icIdentifier2 = second.protoLookup.icIdentifier;
+ l->protoLookupTwoClasses.protoId = first.protoLookup.protoId;
+ l->protoLookupTwoClasses.protoId2 = second.protoLookup.protoId;
l->protoLookupTwoClasses.data = first.protoLookup.data;
l->protoLookupTwoClasses.data2 = second.protoLookup.data;
l->getter = getterProtoAccessorTwoClasses;
@@ -250,7 +256,7 @@ ReturnedValue Lookup::getterProto(Lookup *l, ExecutionEngine *engine, const Valu
// the internal class won't match
Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
if (o) {
- if (l->protoLookup.icIdentifier == o->internalClass->id)
+ if (l->protoLookup.protoId == o->internalClass->protoId)
return l->protoLookup.data->asReturnedValue();
}
return getterTwoClasses(l, engine, object);
@@ -266,6 +272,9 @@ ReturnedValue Lookup::getter0Inlinegetter0Inline(Lookup *l, ExecutionEngine *eng
return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue();
if (l->objectLookupTwoClasses.ic2 == o->internalClass)
return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset2)->asReturnedValue();
+ Value obj = Value::fromHeapObject(o);
+ Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
+ return static_cast<Object &>(obj).get(&static_cast<String &>(str));
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
@@ -281,6 +290,9 @@ ReturnedValue Lookup::getter0Inlinegetter0MemberData(Lookup *l, ExecutionEngine
return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue();
if (l->objectLookupTwoClasses.ic2 == o->internalClass)
return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue();
+ Value obj = Value::fromHeapObject(o);
+ Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
+ return static_cast<Object &>(obj).get(&static_cast<String &>(str));
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
@@ -296,6 +308,9 @@ ReturnedValue Lookup::getter0MemberDatagetter0MemberData(Lookup *l, ExecutionEng
return o->memberData->values.data()[l->objectLookupTwoClasses.offset].asReturnedValue();
if (l->objectLookupTwoClasses.ic2 == o->internalClass)
return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue();
+ Value obj = Value::fromHeapObject(o);
+ Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
+ return static_cast<Object &>(obj).get(&static_cast<String &>(str));
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
@@ -307,11 +322,13 @@ ReturnedValue Lookup::getterProtoTwoClasses(Lookup *l, ExecutionEngine *engine,
// the internal class won't match
Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
if (o) {
- if (l->protoLookupTwoClasses.icIdentifier == o->internalClass->id)
+ if (l->protoLookupTwoClasses.protoId == o->internalClass->protoId)
return l->protoLookupTwoClasses.data->asReturnedValue();
- if (l->protoLookupTwoClasses.icIdentifier2 == o->internalClass->id)
+ if (l->protoLookupTwoClasses.protoId2 == o->internalClass->protoId)
return l->protoLookupTwoClasses.data2->asReturnedValue();
- return getterFallback(l, engine, object);
+ Value obj = Value::fromHeapObject(o);
+ Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
+ return static_cast<Object &>(obj).get(&static_cast<String &>(str));
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
@@ -340,14 +357,13 @@ ReturnedValue Lookup::getterProtoAccessor(Lookup *l, ExecutionEngine *engine, co
// we can safely cast to a QV4::Object here. If object is actually a string,
// the internal class won't match
Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
- if (o && l->protoLookup.icIdentifier == o->internalClass->id) {
+ if (o && l->protoLookup.protoId == o->internalClass->protoId) {
const Value *getter = l->protoLookup.data;
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);
}
- l->getter = getterTwoClasses;
return getterTwoClasses(l, engine, object);
}
@@ -358,9 +374,9 @@ ReturnedValue Lookup::getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *
Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
if (o) {
const Value *getter = nullptr;
- if (l->protoLookupTwoClasses.icIdentifier == o->internalClass->id)
+ if (l->protoLookupTwoClasses.protoId == o->internalClass->protoId)
getter = l->protoLookupTwoClasses.data;
- else if (l->protoLookupTwoClasses.icIdentifier2 == o->internalClass->id)
+ else if (l->protoLookupTwoClasses.protoId2 == o->internalClass->protoId)
getter = l->protoLookupTwoClasses.data2;
if (getter) {
if (!getter->isFunctionObject()) // ### catch at resolve time
@@ -373,11 +389,29 @@ ReturnedValue Lookup::getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *
return getterFallback(l, engine, object);
}
+ReturnedValue Lookup::getterIndexed(Lookup *l, ExecutionEngine *engine, const Value &object)
+{
+ Object *o = object.objectValue();
+ if (o) {
+ Heap::Object *ho = o->d();
+ if (ho->arrayData && ho->arrayData->type == Heap::ArrayData::Simple) {
+ Heap::SimpleArrayData *s = ho->arrayData.cast<Heap::SimpleArrayData>();
+ if (l->indexedLookup.index < s->values.size)
+ if (!s->data(l->indexedLookup.index).isEmpty())
+ return s->data(l->indexedLookup.index).asReturnedValue();
+ }
+ return o->get(l->indexedLookup.index);
+ }
+ l->getter = getterFallback;
+ return getterFallback(l, engine, object);
+
+}
+
ReturnedValue Lookup::primitiveGetterProto(Lookup *l, ExecutionEngine *engine, const Value &object)
{
if (object.type() == l->primitiveLookup.type) {
Heap::Object *o = l->primitiveLookup.proto;
- if (l->primitiveLookup.icIdentifier == o->internalClass->id)
+ if (l->primitiveLookup.protoId == o->internalClass->protoId)
return l->primitiveLookup.data->asReturnedValue();
}
l->getter = getterGeneric;
@@ -388,7 +422,7 @@ ReturnedValue Lookup::primitiveGetterAccessor(Lookup *l, ExecutionEngine *engine
{
if (object.type() == l->primitiveLookup.type) {
Heap::Object *o = l->primitiveLookup.proto;
- if (l->primitiveLookup.icIdentifier == o->internalClass->id) {
+ if (l->primitiveLookup.protoId == o->internalClass->protoId) {
const Value *getter = l->primitiveLookup.data;
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
@@ -417,7 +451,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionEngine *engine)
ReturnedValue Lookup::globalGetterProto(Lookup *l, ExecutionEngine *engine)
{
Heap::Object *o = engine->globalObject->d();
- if (l->protoLookup.icIdentifier == o->internalClass->id)
+ if (l->protoLookup.protoId == o->internalClass->protoId)
return l->protoLookup.data->asReturnedValue();
l->globalGetter = globalGetterGeneric;
return globalGetterGeneric(l, engine);
@@ -426,7 +460,7 @@ ReturnedValue Lookup::globalGetterProto(Lookup *l, ExecutionEngine *engine)
ReturnedValue Lookup::globalGetterProtoAccessor(Lookup *l, ExecutionEngine *engine)
{
Heap::Object *o = engine->globalObject->d();
- if (l->protoLookup.icIdentifier == o->internalClass->id) {
+ if (l->protoLookup.protoId == o->internalClass->protoId) {
const Value *getter = l->protoLookup.data;
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
@@ -442,16 +476,18 @@ bool Lookup::resolveSetter(ExecutionEngine *engine, Object *object, const Value
Scope scope(engine);
ScopedString name(scope, scope.engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- InternalClass *c = object->internalClass();
- uint idx = c->find(name);
- if (idx != UINT_MAX) {
- if (object->isArrayObject() && idx == Heap::ArrayObject::LengthPropertyIndex) {
+ Heap::InternalClass *c = object->internalClass();
+ PropertyKey key = name->toPropertyKey();
+ auto idx = c->findValueOrSetter(key);
+ if (idx.isValid()) {
+ if (object->isArrayObject() && idx.index == Heap::ArrayObject::LengthPropertyIndex) {
+ Q_ASSERT(!idx.attrs.isAccessor());
setter = arrayLengthSetter;
return setter(this, engine, *object, value);
- } else if (object->internalClass()->propertyData[idx].isData() && object->internalClass()->propertyData[idx].isWritable()) {
+ } else if (idx.attrs.isData() && idx.attrs.isWritable()) {
objectLookup.ic = object->internalClass();
- objectLookup.offset = idx;
- setter = idx < object->d()->vtable()->nInlineProperties ? Lookup::setter0Inline : Lookup::setter0;
+ objectLookup.offset = idx.index;
+ setter = idx.index < object->d()->vtable()->nInlineProperties ? Lookup::setter0Inline : Lookup::setter0;
return setter(this, engine, *object, value);
} else {
// ### handle setter
@@ -460,8 +496,8 @@ bool Lookup::resolveSetter(ExecutionEngine *engine, Object *object, const Value
return setter(this, engine, *object, value);
}
- insertionLookup.icIdentifier = c->id;
- if (!object->put(name, value)) {
+ insertionLookup.protoId = c->protoId;
+ if (!object->put(key, value)) {
setter = Lookup::setterFallback;
return false;
}
@@ -471,13 +507,13 @@ bool Lookup::resolveSetter(ExecutionEngine *engine, Object *object, const Value
setter = setterFallback;
return true;
}
- idx = object->internalClass()->find(name);
- if (idx == UINT_MAX) { // ### can this even happen?
+ idx = object->internalClass()->findValueOrSetter(key);
+ if (!idx.isValid() || idx.attrs.isAccessor()) { // ### can this even happen?
setter = setterFallback;
return false;
}
insertionLookup.newClass = object->internalClass();
- insertionLookup.offset = idx;
+ insertionLookup.offset = idx.index;
setter = setterInsert;
return true;
}
@@ -487,6 +523,9 @@ bool Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, Value &object, co
if (object.isObject())
return l->resolveSetter(engine, static_cast<Object *>(&object), value);
+ if (engine->currentStackFrame->v4Function->isStrict())
+ return false;
+
Scope scope(engine);
ScopedObject o(scope, RuntimeHelpers::convertToObject(scope.engine, object));
if (!o) // type error
@@ -574,7 +613,7 @@ bool Lookup::setter0setter0(Lookup *l, ExecutionEngine *engine, Value &object, c
bool Lookup::setterInsert(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
{
Object *o = static_cast<Object *>(object.managed());
- if (o && o->internalClass()->id == l->insertionLookup.icIdentifier) {
+ if (o && o->internalClass()->protoId == l->insertionLookup.protoId) {
o->setInternalClass(l->insertionLookup.newClass);
o->d()->setProperty(engine, l->insertionLookup.offset, value);
return true;
diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h
index 5f507733fd..83e561863b 100644
--- a/src/qml/jsruntime/qv4lookup_p.h
+++ b/src/qml/jsruntime/qv4lookup_p.h
@@ -65,7 +65,6 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
struct Lookup {
- enum { Size = 4 };
union {
ReturnedValue (*getter)(Lookup *l, ExecutionEngine *engine, const Value &object);
ReturnedValue (*globalGetter)(Lookup *l, ExecutionEngine *engine);
@@ -73,44 +72,57 @@ struct Lookup {
};
union {
struct {
- InternalClass *ic;
+ Heap::Base *h1;
+ Heap::Base *h2;
+ quintptr unused;
+ quintptr unused2;
+ } markDef;
+ struct {
+ Heap::InternalClass *ic;
+ quintptr _unused;
int offset;
} objectLookup;
struct {
+ quintptr protoId;
+ quintptr _unused;
const Value *data;
- int icIdentifier;
} protoLookup;
struct {
- InternalClass *ic;
- InternalClass *ic2;
+ Heap::InternalClass *ic;
+ Heap::InternalClass *ic2;
int offset;
int offset2;
} objectLookupTwoClasses;
struct {
+ quintptr protoId;
+ quintptr protoId2;
const Value *data;
const Value *data2;
- int icIdentifier;
- int icIdentifier2;
} protoLookupTwoClasses;
struct {
// Make sure the next two values are in sync with protoLookup
- const Value *data;
- int icIdentifier;
- unsigned type;
+ quintptr protoId;
Heap::Object *proto;
+ const Value *data;
+ quintptr type;
} primitiveLookup;
struct {
- InternalClass *newClass;
- int icIdentifier;
+ Heap::InternalClass *newClass;
+ quintptr protoId;
int offset;
} insertionLookup;
+ struct {
+ quintptr _unused;
+ quintptr _unused2;
+ uint index;
+ } indexedLookup;
};
uint nameIndex;
ReturnedValue resolveGetter(ExecutionEngine *engine, const Object *object);
ReturnedValue resolvePrimitiveGetter(ExecutionEngine *engine, const Value &object);
ReturnedValue resolveGlobalGetter(ExecutionEngine *engine);
- void resolveProtoGetter(Identifier *name, const Heap::Object *proto);
+ void resolveProtoGetter(PropertyKey name, const Heap::Object *proto);
static ReturnedValue getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object);
static ReturnedValue getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object);
@@ -126,6 +138,7 @@ struct Lookup {
static ReturnedValue getterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object);
static ReturnedValue getterProtoAccessor(Lookup *l, ExecutionEngine *engine, const Value &object);
static ReturnedValue getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object);
+ static ReturnedValue getterIndexed(Lookup *l, ExecutionEngine *engine, const Value &object);
static ReturnedValue primitiveGetterProto(Lookup *l, ExecutionEngine *engine, const Value &object);
static ReturnedValue primitiveGetterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object);
@@ -137,13 +150,24 @@ struct Lookup {
bool resolveSetter(ExecutionEngine *engine, Object *object, const Value &value);
static bool setterGeneric(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
- static bool setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
+ Q_NEVER_INLINE static bool setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool setter0Inline(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool setter0setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool setterInsert(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
static bool arrayLengthSetter(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value);
+
+ void markObjects(MarkStack *stack) {
+ if (markDef.h1 && !(reinterpret_cast<quintptr>(markDef.h1) & 1))
+ markDef.h1->mark(stack);
+ if (markDef.h2 && !(reinterpret_cast<quintptr>(markDef.h2) & 1))
+ markDef.h2->mark(stack);
+ }
+
+ void clear() {
+ memset(&markDef, 0, sizeof(markDef));
+ }
};
Q_STATIC_ASSERT(std::is_standard_layout<Lookup>::value);
diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp
index b50e5f0355..d51b03d90b 100644
--- a/src/qml/jsruntime/qv4managed.cpp
+++ b/src/qml/jsruntime/qv4managed.cpp
@@ -43,34 +43,23 @@
using namespace QV4;
+DEFINE_MANAGED_VTABLE(Managed);
-const VTable Managed::static_vtbl =
-{
- nullptr,
- 0,
- 0,
- Managed::IsExecutionContext,
- Managed::IsString,
- Managed::IsObject,
- Managed::IsFunctionObject,
- Managed::IsErrorObject,
- Managed::IsArrayData,
- 0,
- Managed::MyType,
- "Managed",
- nullptr,
- nullptr /*markObjects*/,
- isEqualTo
-};
+DEFINE_MANAGED_VTABLE(InternalClass);
QString Managed::className() const
{
const char *s = nullptr;
- switch (Type(d()->vtable()->type)) {
+ switch (Type(vtable()->type)) {
case Type_Invalid:
- case Type_String:
return QString();
+ case Type_String:
+ s = "String";
+ break;
+ case Type_Symbol:
+ s = "Symbol";
+ break;
case Type_Object:
s = "Object";
break;
@@ -80,6 +69,9 @@ QString Managed::className() const
case Type_FunctionObject:
s = "Function";
break;
+ case Type_GeneratorObject:
+ s = "Generator";
+ break;
case Type_BooleanObject:
s = "Boolean";
break;
@@ -89,6 +81,9 @@ QString Managed::className() const
case Type_StringObject:
s = "String";
break;
+ case Type_SymbolObject:
+ s = "Symbol";
+ break;
case Type_DateObject:
s = "Date";
break;
@@ -96,7 +91,7 @@ QString Managed::className() const
s = "RegExp";
break;
case Type_ErrorObject:
- s = ErrorObject::className(static_cast<Heap::ErrorObject *>(d())->errorType);
+ s = "Error";
break;
case Type_ArgumentsObject:
s = "Arguments";
@@ -104,6 +99,9 @@ QString Managed::className() const
case Type_JsonObject:
s = "JSON";
break;
+ case Type_ProxyObject:
+ s = "ProxyObject";
+ break;
case Type_MathObject:
s = "Math";
break;
@@ -111,8 +109,23 @@ QString Managed::className() const
case Type_ExecutionContext:
s = "__ExecutionContext";
break;
- case Type_ForeachIteratorObject:
- s = "__ForeachIterator";
+ case Type_MapIteratorObject:
+ s = "Map Iterator";
+ break;
+ case Type_SetIteratorObject:
+ s = "Set Iterator";
+ break;
+ case Type_ArrayIteratorObject:
+ s = "Array Iterator";
+ break;
+ case Type_StringIteratorObject:
+ s = "String Iterator";
+ break;
+ case Type_ForInIterator:
+ s = "__ForIn Iterator";
+ break;
+ case Type_InternalClass:
+ s = "__InternalClass";
break;
case Type_RegExp:
s = "__RegExp";
@@ -125,7 +138,12 @@ QString Managed::className() const
return QString::fromLatin1(s);
}
-bool Managed::isEqualTo(Managed *, Managed *)
+bool Managed::virtualIsEqualTo(Managed *, Managed *)
{
return false;
}
+
+
+OwnPropertyKeyIterator::~OwnPropertyKeyIterator()
+{
+}
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 092c61b81c..d85b30a056 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -55,6 +55,7 @@
#include "qv4enginebase_p.h"
#include <private/qv4heap_p.h>
#include <private/qv4writebarrier_p.h>
+#include <private/qv4vtable_p.h>
QT_BEGIN_NAMESPACE
@@ -70,13 +71,9 @@ inline int qYouForgotTheQ_MANAGED_Macro(T, T) { return 0; }
template <typename T1, typename T2>
inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
-#ifdef Q_COMPILER_STATIC_ASSERT
-#define V4_MANAGED_SIZE_TEST void __dataTest() { Q_STATIC_ASSERT(sizeof(*this) == sizeof(Managed)); }
-#else
-#define V4_MANAGED_SIZE_TEST
-#endif
+#define V4_MANAGED_SIZE_TEST void __dataTest() { static_assert (sizeof(*this) == sizeof(Managed), "Classes derived from Managed can't have own data members."); }
-#define V4_NEEDS_DESTROY static void destroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->destroy(); }
+#define V4_NEEDS_DESTROY static void virtualDestroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->destroy(); }
#define V4_MANAGED_ITSELF(DataClass, superClass) \
@@ -92,77 +89,30 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
QV4::Heap::DataClass *dptr = d_unchecked(); \
dptr->_checkIsInitialized(); \
return dptr; \
- } \
- Q_STATIC_ASSERT(std::is_trivial< QV4::Heap::DataClass >::value);
+ }
#define V4_MANAGED(DataClass, superClass) \
private: \
DataClass() Q_DECL_EQ_DELETE; \
Q_DISABLE_COPY(DataClass) \
- V4_MANAGED_ITSELF(DataClass, superClass)
+ V4_MANAGED_ITSELF(DataClass, superClass) \
+ Q_STATIC_ASSERT(std::is_trivial< QV4::Heap::DataClass >::value);
#define Q_MANAGED_TYPE(type) \
public: \
enum { MyType = Type_##type };
-#define Q_VTABLE_FUNCTION(classname, func) \
- (classname::func == QV4::Managed::func ? 0 : classname::func)
-
-// Q_VTABLE_FUNCTION triggers a bogus tautological-compare warning in GCC6+
-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 600)
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
- QT_WARNING_PUSH; \
- QT_WARNING_DISABLE_GCC("-Wtautological-compare")
-
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF \
- ;QT_WARNING_POP
-#elif defined(Q_CC_CLANG) && Q_CC_CLANG >= 306
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
- QT_WARNING_PUSH; \
- QT_WARNING_DISABLE_CLANG("-Wtautological-compare")
-
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF \
- ;QT_WARNING_POP
-#else
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON
-#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
-#endif
-
-#define DEFINE_MANAGED_VTABLE_INT(classname, parentVTable) \
-{ \
- parentVTable, \
- (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \
- (sizeof(classname::Data) + (classname::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) \
- - (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \
- classname::IsExecutionContext, \
- classname::IsString, \
- classname::IsObject, \
- classname::IsFunctionObject, \
- classname::IsErrorObject, \
- classname::IsArrayData, \
- 0, \
- classname::MyType, \
- #classname, \
- Q_VTABLE_FUNCTION(classname, destroy), \
- classname::Data::markObjects, \
- isEqualTo \
-} \
-
-#define DEFINE_MANAGED_VTABLE(classname) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
-const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, 0) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
-
#define V4_INTERNALCLASS(c) \
- static QV4::InternalClass *defaultInternalClass(QV4::EngineBase *e) \
- { return e->internalClasses[QV4::EngineBase::Class_##c]; }
+ static Heap::InternalClass *defaultInternalClass(QV4::EngineBase *e) \
+ { return e->internalClasses(QV4::EngineBase::Class_##c); }
-struct Q_QML_PRIVATE_EXPORT Managed : Value
+struct Q_QML_PRIVATE_EXPORT Managed : Value, VTableBase
{
V4_MANAGED_ITSELF(Base, Managed)
enum {
IsExecutionContext = false,
IsString = false,
+ IsStringOrSymbol = false,
IsObject = false,
IsFunctionObject = false,
IsErrorObject = false,
@@ -180,47 +130,55 @@ public:
Type_Invalid,
Type_String,
Type_Object,
+ Type_Symbol,
Type_ArrayObject,
Type_FunctionObject,
+ Type_GeneratorObject,
Type_BooleanObject,
Type_NumberObject,
Type_StringObject,
+ Type_SymbolObject,
Type_DateObject,
Type_RegExpObject,
Type_ErrorObject,
Type_ArgumentsObject,
Type_JsonObject,
Type_MathObject,
+ Type_ProxyObject,
Type_ExecutionContext,
- Type_ForeachIteratorObject,
+ Type_InternalClass,
+ Type_SetIteratorObject,
+ Type_MapIteratorObject,
+ Type_ArrayIteratorObject,
+ Type_StringIteratorObject,
+ Type_ForInIterator,
Type_RegExp,
Type_QmlSequence
};
Q_MANAGED_TYPE(Invalid)
- InternalClass *internalClass() const { return d()->internalClass; }
+ Heap::InternalClass *internalClass() const { return d()->internalClass; }
+ const VTable *vtable() const { return d()->internalClass->vtable; }
inline ExecutionEngine *engine() const { return internalClass()->engine; }
- bool isListType() const { return d()->vtable()->type == Type_QmlSequence; }
+ bool isListType() const { return d()->internalClass->vtable->type == Type_QmlSequence; }
+ bool isArrayLike() const { return isArrayObject() || isListType(); }
- bool isArrayObject() const { return d()->vtable()->type == Type_ArrayObject; }
- bool isStringObject() const { return d()->vtable()->type == Type_StringObject; }
+ bool isArrayObject() const { return d()->internalClass->vtable->type == Type_ArrayObject; }
+ bool isStringObject() const { return d()->internalClass->vtable->type == Type_StringObject; }
+ bool isSymbolObject() const { return d()->internalClass->vtable->type == Type_SymbolObject; }
QString className() const;
bool isEqualTo(const Managed *other) const
- { return d()->vtable()->isEqualTo(const_cast<Managed *>(this), const_cast<Managed *>(other)); }
-
- static bool isEqualTo(Managed *m, Managed *other);
+ { return d()->internalClass->vtable->isEqualTo(const_cast<Managed *>(this), const_cast<Managed *>(other)); }
bool inUse() const { return d()->inUse(); }
bool markBit() const { return d()->isMarked(); }
inline void mark(MarkStack *markStack);
- static void destroy(Heap::Base *) {}
-
Q_ALWAYS_INLINE Heap::Base *heapObject() const {
return m();
}
@@ -232,6 +190,9 @@ public:
return static_cast<const T *>(this);
}
+protected:
+ static bool virtualIsEqualTo(Managed *m, Managed *other);
+
private:
friend class MemoryManager;
friend struct Identifiers;
@@ -254,6 +215,33 @@ inline const Object *Value::as() const {
return objectValue();
}
+
+struct InternalClass : Managed
+{
+ V4_MANAGED_ITSELF(InternalClass, Managed)
+ Q_MANAGED_TYPE(InternalClass)
+ V4_INTERNALCLASS(Empty)
+ V4_NEEDS_DESTROY
+
+ Q_REQUIRED_RESULT Heap::InternalClass *changeVTable(const VTable *vt) {
+ return d()->changeVTable(vt);
+ }
+ Q_REQUIRED_RESULT Heap::InternalClass *changePrototype(Heap::Object *proto) {
+ return d()->changePrototype(proto);
+ }
+ Q_REQUIRED_RESULT Heap::InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr) {
+ return d()->addMember(identifier, data, entry);
+ }
+
+ Q_REQUIRED_RESULT Heap::InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr) {
+ return d()->changeMember(identifier, data, entry);
+ }
+
+ void operator =(Heap::InternalClass *ic) {
+ Value::operator=(ic);
+ }
+};
+
}
diff --git a/src/qml/jsruntime/qv4mapiterator.cpp b/src/qml/jsruntime/qv4mapiterator.cpp
new file mode 100644
index 0000000000..cd5fbb8e63
--- /dev/null
+++ b/src/qml/jsruntime/qv4mapiterator.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qv4iterator_p.h>
+#include <private/qv4estable_p.h>
+#include <private/qv4mapiterator_p.h>
+#include <private/qv4mapobject_p.h>
+#include <private/qv4symbol_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(MapIteratorObject);
+
+void MapIteratorPrototype::init(ExecutionEngine *e)
+{
+ defineDefaultProperty(QStringLiteral("next"), method_next, 0);
+
+ Scope scope(e);
+ ScopedString val(scope, e->newString(QLatin1String("Map Iterator")));
+ defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);
+}
+
+ReturnedValue MapIteratorPrototype::method_next(const FunctionObject *b, const Value *that, const Value *, int)
+{
+ Scope scope(b);
+ const MapIteratorObject *thisObject = that->as<MapIteratorObject>();
+ if (!thisObject)
+ return scope.engine->throwTypeError(QLatin1String("Not a Map Iterator instance"));
+
+ Scoped<MapObject> s(scope, thisObject->d()->iteratedMap);
+ uint index = thisObject->d()->mapNextIndex;
+ IteratorKind itemKind = thisObject->d()->iterationKind;
+
+ if (!s) {
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ Value *arguments = scope.alloc(2);
+
+ while (index < s->d()->esTable->size()) {
+ s->d()->esTable->iterate(index, &arguments[0], &arguments[1]);
+ thisObject->d()->mapNextIndex = index + 1;
+
+ ScopedValue result(scope);
+
+ if (itemKind == KeyIteratorKind) {
+ result = arguments[0];
+ } else if (itemKind == ValueIteratorKind) {
+ result = arguments[1];
+ } else {
+ Q_ASSERT(itemKind == KeyValueIteratorKind);
+
+ result = scope.engine->newArrayObject();
+
+ Scoped<ArrayObject> resultArray(scope, result);
+ resultArray->arrayReserve(2);
+ resultArray->arrayPut(0, arguments[0]);
+ resultArray->arrayPut(1, arguments[1]);
+ resultArray->setArrayLengthUnchecked(2);
+ }
+
+ return IteratorPrototype::createIterResultObject(scope.engine, result, false);
+ }
+
+ thisObject->d()->iteratedMap.set(scope.engine, nullptr);
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+}
+
+
diff --git a/src/qml/jsruntime/qv4mapiterator_p.h b/src/qml/jsruntime/qv4mapiterator_p.h
new file mode 100644
index 0000000000..836ba14663
--- /dev/null
+++ b/src/qml/jsruntime/qv4mapiterator_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4MAPITERATOR_P_H
+#define QV4MAPITERATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4iterator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+#define MapIteratorObjectMembers(class, Member) \
+ Member(class, Pointer, Object *, iteratedMap) \
+ Member(class, NoMark, IteratorKind, iterationKind) \
+ Member(class, NoMark, quint32, mapNextIndex)
+
+DECLARE_HEAP_OBJECT(MapIteratorObject, Object) {
+ DECLARE_MARKOBJECTS(MapIteratorObject);
+ void init(Object *obj, QV4::ExecutionEngine *engine)
+ {
+ Object::init();
+ this->iteratedMap.set(engine, obj);
+ this->mapNextIndex = 0;
+ }
+};
+
+}
+
+struct MapIteratorPrototype : Object
+{
+ V4_PROTOTYPE(iteratorPrototype)
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct MapIteratorObject : Object
+{
+ V4_OBJECT2(MapIteratorObject, Object)
+ Q_MANAGED_TYPE(MapIteratorObject)
+ V4_PROTOTYPE(mapIteratorPrototype)
+
+ void init(ExecutionEngine *engine);
+};
+
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4MAPITERATOR_P_H
+
+
diff --git a/src/qml/jsruntime/qv4mapobject.cpp b/src/qml/jsruntime/qv4mapobject.cpp
new file mode 100644
index 0000000000..7d53b36fcd
--- /dev/null
+++ b/src/qml/jsruntime/qv4mapobject.cpp
@@ -0,0 +1,379 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4setobject_p.h" // ### temporary
+#include "qv4mapobject_p.h"
+#include "qv4mapiterator_p.h"
+#include "qv4estable_p.h"
+#include "qv4symbol_p.h"
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(WeakMapCtor);
+DEFINE_OBJECT_VTABLE(MapCtor);
+DEFINE_OBJECT_VTABLE(MapObject);
+
+void Heap::WeakMapCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("WeakMap"));
+}
+
+void Heap::MapCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("Map"));
+}
+
+ReturnedValue WeakMapCtor::construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakMap)
+{
+ Scope scope(f);
+ Scoped<MapObject> a(scope, scope.engine->memoryManager->allocate<MapObject>());
+ if (weakMap) {
+ a->setPrototypeOf(scope.engine->weakMapPrototype());
+ scope.engine->memoryManager->registerWeakMap(a->d());
+ }
+ a->d()->isWeakMap = weakMap;
+
+ if (argc > 0) {
+ ScopedValue iterable(scope, argv[0]);
+
+ if (!iterable->isNullOrUndefined()) {
+ ScopedFunctionObject adder(scope, a->get(ScopedString(scope, scope.engine->newString(QString::fromLatin1("set")))));
+ if (!adder)
+ return scope.engine->throwTypeError();
+
+ ScopedObject iter(scope, Runtime::method_getIterator(scope.engine, iterable, true));
+ if (scope.hasException())
+ return Encode::undefined();
+ Q_ASSERT(iter);
+
+ ScopedValue obj(scope);
+ Value *arguments = scope.alloc(2);
+ ScopedValue done(scope);
+ forever {
+ done = Runtime::method_iteratorNext(scope.engine, iter, obj);
+ if (scope.hasException())
+ break;
+ if (done->toBoolean())
+ return a->asReturnedValue();
+ const Object *o = obj->objectValue();
+ if (!o) {
+ scope.engine->throwTypeError();
+ break;
+ }
+
+ arguments[0] = o->get(PropertyKey::fromArrayIndex(0));
+ if (scope.hasException())
+ break;
+ arguments[1] = o->get(PropertyKey::fromArrayIndex(1));
+ if (scope.hasException())
+ break;
+
+ adder->call(a, arguments, 2);
+ if (scope.hasException())
+ break;
+ }
+ ScopedValue falsey(scope, Encode(false));
+ return Runtime::method_iteratorClose(scope.engine, iter, falsey);
+ }
+ }
+ return a->asReturnedValue();
+
+}
+
+ReturnedValue WeakMapCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ return construct(f, argv, argc, newTarget, true);
+}
+
+ReturnedValue WeakMapCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ Scope scope(f);
+ return scope.engine->throwTypeError(QString::fromLatin1("(Weak)Map requires new"));
+}
+
+
+ReturnedValue MapCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ return construct(f, argv, argc, newTarget, false);
+}
+
+void WeakMapPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedObject o(scope);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+ ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+
+ defineDefaultProperty(QStringLiteral("delete"), method_delete, 1);
+ defineDefaultProperty(QStringLiteral("get"), method_get, 1);
+ defineDefaultProperty(QStringLiteral("has"), method_has, 1);
+ defineDefaultProperty(QStringLiteral("set"), method_set, 2);
+
+ ScopedString val(scope, engine->newString(QLatin1String("WeakMap")));
+ defineReadonlyConfigurableProperty(engine->symbol_toStringTag(), val);
+}
+
+
+void MapPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedObject o(scope);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+ ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
+ ctor->addSymbolSpecies();
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+
+ defineDefaultProperty(QStringLiteral("clear"), method_clear, 0);
+ defineDefaultProperty(QStringLiteral("delete"), method_delete, 1);
+ defineDefaultProperty(QStringLiteral("forEach"), method_forEach, 1);
+ defineDefaultProperty(QStringLiteral("get"), method_get, 1);
+ defineDefaultProperty(QStringLiteral("has"), method_has, 1);
+ defineDefaultProperty(QStringLiteral("keys"), method_keys, 0);
+ defineDefaultProperty(QStringLiteral("set"), method_set, 2);
+ defineAccessorProperty(QStringLiteral("size"), method_get_size, nullptr);
+ defineDefaultProperty(QStringLiteral("values"), method_values, 0);
+
+ // Per the spec, the value for entries/@@iterator is the same
+ ScopedString valString(scope, scope.engine->newIdentifier(QStringLiteral("entries")));
+ ScopedFunctionObject entriesFn(scope, FunctionObject::createBuiltinFunction(engine, valString, MapPrototype::method_entries, 0));
+ defineDefaultProperty(QStringLiteral("entries"), entriesFn);
+ defineDefaultProperty(engine->symbol_iterator(), entriesFn);
+
+ ScopedString val(scope, engine->newString(QLatin1String("Map")));
+ defineReadonlyConfigurableProperty(engine->symbol_toStringTag(), val);
+}
+
+void Heap::MapObject::init()
+{
+ Object::init();
+ esTable = new ESTable();
+}
+
+void Heap::MapObject::destroy()
+{
+ delete esTable;
+ esTable = nullptr;
+}
+
+void Heap::MapObject::removeUnmarkedKeys()
+{
+ esTable->removeUnmarkedKeys();
+}
+
+void Heap::MapObject::markObjects(Heap::Base *that, MarkStack *markStack)
+{
+ MapObject *m = static_cast<MapObject *>(that);
+ m->esTable->markObjects(markStack, m->isWeakMap);
+ Object::markObjects(that, markStack);
+}
+
+ReturnedValue WeakMapPrototype::method_delete(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || !that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+ if (!argc || !argv[0].isObject())
+ return Encode(false);
+
+ return Encode(that->d()->esTable->remove(argv[0]));
+
+}
+
+ReturnedValue WeakMapPrototype::method_get(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || !that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+ if (!argc || !argv[0].isObject())
+ return Encode::undefined();
+
+ return that->d()->esTable->get(argv[0]);
+}
+
+ReturnedValue WeakMapPrototype::method_has(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || !that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+ if (!argc || !argv[0].isObject())
+ return Encode(false);
+
+ return Encode(that->d()->esTable->has(argv[0]));
+}
+
+ReturnedValue WeakMapPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if ((!that || !that->d()->isWeakMap) ||
+ (!argc || !argv[0].isObject()))
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->set(argv[0], argc > 1 ? argv[1] : Value::undefinedValue());
+ return that.asReturnedValue();
+}
+
+
+ReturnedValue MapPrototype::method_clear(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->clear();
+ return Encode::undefined();
+}
+
+ReturnedValue MapPrototype::method_delete(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->remove(argc ? argv[0] : Value::undefinedValue()));
+}
+
+ReturnedValue MapPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ Scoped<MapIteratorObject> ao(scope, scope.engine->newMapIteratorObject(that));
+ ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue MapPrototype::method_forEach(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject callbackfn(scope, argv[0]);
+ if (!callbackfn)
+ return scope.engine->throwTypeError();
+
+ ScopedValue thisArg(scope, Value::undefinedValue());
+ if (argc > 1)
+ thisArg = ScopedValue(scope, argv[1]);
+
+ Value *arguments = scope.alloc(3);
+ arguments[2] = that;
+ for (uint i = 0; i < that->d()->esTable->size(); ++i) {
+ that->d()->esTable->iterate(i, &arguments[1], &arguments[0]); // fill in key (0), value (1)
+
+ callbackfn->call(thisArg, arguments, 3);
+ CHECK_EXCEPTION();
+ }
+ return Encode::undefined();
+}
+
+ReturnedValue MapPrototype::method_get(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ return that->d()->esTable->get(argc ? argv[0] : Value::undefinedValue());
+}
+
+ReturnedValue MapPrototype::method_has(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->has(argc ? argv[0] : Value::undefinedValue()));
+}
+
+ReturnedValue MapPrototype::method_keys(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ Scoped<MapIteratorObject> ao(scope, scope.engine->newMapIteratorObject(that));
+ ao->d()->iterationKind = IteratorKind::KeyIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue MapPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->set(argc ? argv[0] : Value::undefinedValue(), argc > 1 ? argv[1] : Value::undefinedValue());
+ return that.asReturnedValue();
+}
+
+ReturnedValue MapPrototype::method_get_size(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->size());
+}
+
+ReturnedValue MapPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<MapObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakMap)
+ return scope.engine->throwTypeError();
+
+ Scoped<MapIteratorObject> ao(scope, scope.engine->newMapIteratorObject(that));
+ ao->d()->iterationKind = IteratorKind::ValueIteratorKind;
+ return ao->asReturnedValue();
+}
diff --git a/src/qml/jsruntime/qv4mapobject_p.h b/src/qml/jsruntime/qv4mapobject_p.h
new file mode 100644
index 0000000000..a0fae2a14a
--- /dev/null
+++ b/src/qml/jsruntime/qv4mapobject_p.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4MAPOBJECT_P_H
+#define QV4MAPOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4objectproto_p.h"
+#include "qv4functionobject_p.h"
+#include "qv4string_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+class ESTable;
+
+namespace Heap {
+
+struct WeakMapCtor : FunctionObject {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct MapCtor : WeakMapCtor {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct MapObject : Object {
+ static void markObjects(Heap::Base *that, MarkStack *markStack);
+ void init();
+ void destroy();
+ void removeUnmarkedKeys();
+
+ MapObject *nextWeakMap;
+ ESTable *esTable;
+ bool isWeakMap;
+};
+
+}
+
+struct WeakMapCtor: FunctionObject
+{
+ V4_OBJECT2(WeakMapCtor, FunctionObject)
+
+ static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakMap);
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct MapCtor : WeakMapCtor
+{
+ V4_OBJECT2(MapCtor, WeakMapCtor)
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+};
+
+struct MapObject : Object
+{
+ V4_OBJECT2(MapObject, Object)
+ V4_PROTOTYPE(mapPrototype)
+ V4_NEEDS_DESTROY
+};
+
+struct WeakMapPrototype : Object
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct MapPrototype : WeakMapPrototype
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_clear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_size(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+
+} // namespace QV4
+
+
+QT_END_NAMESPACE
+
+#endif // QV4MAPOBJECT_P_H
+
diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h
index 67c963622f..90246c4229 100644
--- a/src/qml/jsruntime/qv4math_p.h
+++ b/src/qml/jsruntime/qv4math_p.h
@@ -70,24 +70,24 @@ static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(add_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) + b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) + b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(sub_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) - b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) - b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b)
{
int result;
if (Q_UNLIKELY(mul_overflow(a, b, &result)))
- return Primitive::fromDouble(static_cast<double>(a) * b).asReturnedValue();
- return Primitive::fromInt32(result).asReturnedValue();
+ return Value::fromDouble(static_cast<double>(a) * b).asReturnedValue();
+ return Value::fromInt32(result).asReturnedValue();
}
}
diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp
index 0c18d908de..07440047d4 100644
--- a/src/qml/jsruntime/qv4mathobject.cpp
+++ b/src/qml/jsruntime/qv4mathobject.cpp
@@ -39,6 +39,7 @@
#include "qv4mathobject_p.h"
#include "qv4objectproto_p.h"
+#include "qv4symbol_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qmath.h>
@@ -59,25 +60,38 @@ void Heap::MathObject::init()
Scope scope(internalClass->engine);
ScopedObject m(scope, this);
- m->defineReadonlyProperty(QStringLiteral("E"), Primitive::fromDouble(M_E));
- m->defineReadonlyProperty(QStringLiteral("LN2"), Primitive::fromDouble(M_LN2));
- m->defineReadonlyProperty(QStringLiteral("LN10"), Primitive::fromDouble(M_LN10));
- m->defineReadonlyProperty(QStringLiteral("LOG2E"), Primitive::fromDouble(M_LOG2E));
- m->defineReadonlyProperty(QStringLiteral("LOG10E"), Primitive::fromDouble(M_LOG10E));
- m->defineReadonlyProperty(QStringLiteral("PI"), Primitive::fromDouble(M_PI));
- m->defineReadonlyProperty(QStringLiteral("SQRT1_2"), Primitive::fromDouble(M_SQRT1_2));
- m->defineReadonlyProperty(QStringLiteral("SQRT2"), Primitive::fromDouble(M_SQRT2));
+ m->defineReadonlyProperty(QStringLiteral("E"), Value::fromDouble(M_E));
+ m->defineReadonlyProperty(QStringLiteral("LN2"), Value::fromDouble(M_LN2));
+ m->defineReadonlyProperty(QStringLiteral("LN10"), Value::fromDouble(M_LN10));
+ m->defineReadonlyProperty(QStringLiteral("LOG2E"), Value::fromDouble(M_LOG2E));
+ m->defineReadonlyProperty(QStringLiteral("LOG10E"), Value::fromDouble(M_LOG10E));
+ m->defineReadonlyProperty(QStringLiteral("PI"), Value::fromDouble(M_PI));
+ m->defineReadonlyProperty(QStringLiteral("SQRT1_2"), Value::fromDouble(M_SQRT1_2));
+ m->defineReadonlyProperty(QStringLiteral("SQRT2"), Value::fromDouble(M_SQRT2));
m->defineDefaultProperty(QStringLiteral("abs"), QV4::MathObject::method_abs, 1);
m->defineDefaultProperty(QStringLiteral("acos"), QV4::MathObject::method_acos, 1);
- m->defineDefaultProperty(QStringLiteral("asin"), QV4::MathObject::method_asin, 0);
+ m->defineDefaultProperty(QStringLiteral("acosh"), QV4::MathObject::method_acosh, 1);
+ m->defineDefaultProperty(QStringLiteral("asin"), QV4::MathObject::method_asin, 1);
+ m->defineDefaultProperty(QStringLiteral("asinh"), QV4::MathObject::method_asinh, 1);
m->defineDefaultProperty(QStringLiteral("atan"), QV4::MathObject::method_atan, 1);
+ m->defineDefaultProperty(QStringLiteral("atanh"), QV4::MathObject::method_atanh, 1);
m->defineDefaultProperty(QStringLiteral("atan2"), QV4::MathObject::method_atan2, 2);
+ m->defineDefaultProperty(QStringLiteral("cbrt"), QV4::MathObject::method_cbrt, 1);
m->defineDefaultProperty(QStringLiteral("ceil"), QV4::MathObject::method_ceil, 1);
+ m->defineDefaultProperty(QStringLiteral("clz32"), QV4::MathObject::method_clz32, 1);
m->defineDefaultProperty(QStringLiteral("cos"), QV4::MathObject::method_cos, 1);
+ m->defineDefaultProperty(QStringLiteral("cosh"), QV4::MathObject::method_cosh, 1);
m->defineDefaultProperty(QStringLiteral("exp"), QV4::MathObject::method_exp, 1);
+ m->defineDefaultProperty(QStringLiteral("expm1"), QV4::MathObject::method_expm1, 1);
m->defineDefaultProperty(QStringLiteral("floor"), QV4::MathObject::method_floor, 1);
+ m->defineDefaultProperty(QStringLiteral("fround"), QV4::MathObject::method_fround, 1);
+ m->defineDefaultProperty(QStringLiteral("hypot"), QV4::MathObject::method_hypot, 2);
+ m->defineDefaultProperty(QStringLiteral("imul"), QV4::MathObject::method_imul, 2);
m->defineDefaultProperty(QStringLiteral("log"), QV4::MathObject::method_log, 1);
+ m->defineDefaultProperty(QStringLiteral("log10"), QV4::MathObject::method_log10, 1);
+ m->defineDefaultProperty(QStringLiteral("log1p"), QV4::MathObject::method_log1p, 1);
+ m->defineDefaultProperty(QStringLiteral("log2"), QV4::MathObject::method_log2, 1);
m->defineDefaultProperty(QStringLiteral("max"), QV4::MathObject::method_max, 2);
m->defineDefaultProperty(QStringLiteral("min"), QV4::MathObject::method_min, 2);
m->defineDefaultProperty(QStringLiteral("pow"), QV4::MathObject::method_pow, 2);
@@ -85,8 +99,14 @@ void Heap::MathObject::init()
m->defineDefaultProperty(QStringLiteral("round"), QV4::MathObject::method_round, 1);
m->defineDefaultProperty(QStringLiteral("sign"), QV4::MathObject::method_sign, 1);
m->defineDefaultProperty(QStringLiteral("sin"), QV4::MathObject::method_sin, 1);
+ m->defineDefaultProperty(QStringLiteral("sinh"), QV4::MathObject::method_sinh, 1);
m->defineDefaultProperty(QStringLiteral("sqrt"), QV4::MathObject::method_sqrt, 1);
m->defineDefaultProperty(QStringLiteral("tan"), QV4::MathObject::method_tan, 1);
+ m->defineDefaultProperty(QStringLiteral("tanh"), QV4::MathObject::method_tanh, 1);
+ m->defineDefaultProperty(QStringLiteral("trunc"), QV4::MathObject::method_trunc, 1);
+
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("Math")));
+ m->defineReadonlyConfigurableProperty(scope.engine->symbol_toStringTag(), name);
}
static Q_ALWAYS_INLINE double copySign(double x, double y)
@@ -120,6 +140,19 @@ ReturnedValue MathObject::method_acos(const FunctionObject *, const Value *, con
RETURN_RESULT(Encode(std::acos(v)));
}
+ReturnedValue MathObject::method_acosh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : 2;
+ if (v < 1)
+ RETURN_RESULT(Encode(qt_qnan()));
+
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ RETURN_RESULT(Encode(std::log(v +std::sqrt(v + 1) * std::sqrt(v - 1))));
+#else
+ RETURN_RESULT(Encode(std::acosh(v)));
+#endif
+}
+
ReturnedValue MathObject::method_asin(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : 2;
@@ -129,6 +162,19 @@ ReturnedValue MathObject::method_asin(const FunctionObject *, const Value *, con
RETURN_RESULT(Encode(std::asin(v)));
}
+ReturnedValue MathObject::method_asinh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : 2;
+ if (v == 0.0)
+ RETURN_RESULT(Encode(v));
+
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ RETURN_RESULT(Encode(std::log(v +std::sqrt(1 + v * v))));
+#else
+ RETURN_RESULT(Encode(std::asinh(v)));
+#endif
+}
+
ReturnedValue MathObject::method_atan(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
@@ -138,6 +184,25 @@ ReturnedValue MathObject::method_atan(const FunctionObject *, const Value *, con
RETURN_RESULT(Encode(std::atan(v)));
}
+ReturnedValue MathObject::method_atanh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v == 0.0)
+ RETURN_RESULT(Encode(v));
+
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ if (-1 < v && v < 1)
+ RETURN_RESULT(Encode(0.5 * (std::log(v + 1) - std::log(v - 1))));
+
+ if (v > 1 || v < -1)
+ RETURN_RESULT(Encode(qt_qnan()));
+
+ RETURN_RESULT(Encode(copySign(qt_inf(), v)));
+#else
+ RETURN_RESULT(Encode(std::atanh(v)));
+#endif
+}
+
ReturnedValue MathObject::method_atan2(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v1 = argc ? argv[0].toNumber() : qt_qnan();
@@ -156,6 +221,16 @@ ReturnedValue MathObject::method_atan2(const FunctionObject *, const Value *, co
RETURN_RESULT(Encode(std::atan2(v1, v2)));
}
+ReturnedValue MathObject::method_cbrt(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ RETURN_RESULT(Encode(copySign(std::exp(std::log(std::abs(v)) / 3), v)));
+#else
+ RETURN_RESULT(Encode(std::cbrt(v))); // cube root
+#endif
+}
+
ReturnedValue MathObject::method_ceil(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
@@ -165,12 +240,24 @@ ReturnedValue MathObject::method_ceil(const FunctionObject *, const Value *, con
RETURN_RESULT(Encode(std::ceil(v)));
}
+ReturnedValue MathObject::method_clz32(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ quint32 v = argc ? argv[0].toUInt32() : 0;
+ RETURN_RESULT(Encode(qint32(qCountLeadingZeroBits(v))));
+}
+
ReturnedValue MathObject::method_cos(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
RETURN_RESULT(Encode(std::cos(v)));
}
+ReturnedValue MathObject::method_cosh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ RETURN_RESULT(Encode(std::cosh(v)));
+}
+
ReturnedValue MathObject::method_exp(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
@@ -184,14 +271,80 @@ ReturnedValue MathObject::method_exp(const FunctionObject *, const Value *, cons
}
}
+ReturnedValue MathObject::method_expm1(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (std::isnan(v) || qIsNull(v)) {
+ RETURN_RESULT(Encode(v));
+ } else if (qt_is_inf(v)) {
+ if (copySign(1.0, v) == -1.0)
+ RETURN_RESULT(Encode(-1.0));
+ else
+ RETURN_RESULT(Encode(qt_inf()));
+ } else {
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ RETURN_RESULT(Encode(std::exp(v) - 1));
+#else
+ RETURN_RESULT(Encode(std::expm1(v)));
+#endif
+ }
+}
+
ReturnedValue MathObject::method_floor(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
- Value result = Primitive::fromDouble(std::floor(v));
+ Value result = Value::fromDouble(std::floor(v));
result.isInt32();
RETURN_RESULT(result);
}
+ReturnedValue MathObject::method_fround(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (std::isnan(v) || qt_is_inf(v) || qIsNull(v))
+ RETURN_RESULT(Encode(v));
+ else // convert to 32-bit float using roundTiesToEven, then convert back to 64-bit double
+ RETURN_RESULT(Encode(double(float(v))));
+}
+
+ReturnedValue MathObject::method_hypot(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ // ES6 Math.hypot(v1, ..., vn) -> sqrt(sum(vi**2)) but "should take care to
+ // avoid the loss of precision from overflows and underflows" (as std::hypot does).
+ double v = argc ? argv[0].toNumber() : 0;
+ // Spec mandates +0 on no args; and says nothing about what to do if toNumber() signals ...
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ bool big = qt_is_inf(v), bad = std::isnan(v);
+ v *= v;
+ for (int i = 1; !big && i < argc; i++) {
+ double u = argv[i].toNumber();
+ if (qt_is_inf(u))
+ big = true;
+ if (std::isnan(u))
+ bad = true;
+ v += u * u;
+ }
+ if (big)
+ RETURN_RESULT(Encode(qt_inf()));
+ if (bad)
+ RETURN_RESULT(Encode(qt_qnan()));
+ // Should actually check for {und,ov}erflow, but too fiddly !
+ RETURN_RESULT(Value::fromDouble(sqrt(v)));
+#else
+ for (int i = 1; i < argc; i++)
+ v = std::hypot(v, argv[i].toNumber());
+#endif
+ RETURN_RESULT(Value::fromDouble(v));
+}
+
+ReturnedValue MathObject::method_imul(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ quint32 a = argc ? argv[0].toUInt32() : 0;
+ quint32 b = argc > 0 ? argv[1].toUInt32() : 0;
+ qint32 product = a * b;
+ RETURN_RESULT(Encode(product));
+}
+
ReturnedValue MathObject::method_log(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
@@ -201,15 +354,54 @@ ReturnedValue MathObject::method_log(const FunctionObject *, const Value *, cons
RETURN_RESULT(Encode(std::log(v)));
}
+ReturnedValue MathObject::method_log10(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v < 0)
+ RETURN_RESULT(Encode(qt_qnan()));
+ else
+ RETURN_RESULT(Encode(std::log10(v)));
+}
+
+ReturnedValue MathObject::method_log1p(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+#if !defined(__ANDROID__)
+ using std::log1p;
+#endif
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v < -1)
+ RETURN_RESULT(Encode(qt_qnan()));
+ else
+ RETURN_RESULT(Encode(log1p(v)));
+}
+
+ReturnedValue MathObject::method_log2(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v < 0) {
+ RETURN_RESULT(Encode(qt_qnan()));
+ } else {
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ // Android ndk r10e doesn't have std::log2, so fall back.
+ const double ln2 = std::log(2.0);
+ RETURN_RESULT(Encode(std::log(v) / ln2));
+#else
+ RETURN_RESULT(Encode(std::log2(v)));
+#endif
+ }
+}
+
ReturnedValue MathObject::method_max(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double mx = -qt_inf();
for (int i = 0, ei = argc; i < ei; ++i) {
double x = argv[i].toNumber();
- if (x > mx || std::isnan(x))
+ if ((x == 0 && mx == x && copySign(1.0, x) == 1.0)
+ || (x > mx) || std::isnan(x)) {
mx = x;
+ }
}
- RETURN_RESULT(Encode(mx));
+ RETURN_RESULT(Encode::smallestNumber(mx));
}
ReturnedValue MathObject::method_min(const FunctionObject *, const Value *, const Value *argv, int argc)
@@ -222,7 +414,7 @@ ReturnedValue MathObject::method_min(const FunctionObject *, const Value *, cons
mx = x;
}
}
- RETURN_RESULT(Encode(mx));
+ RETURN_RESULT(Encode::smallestNumber(mx));
}
ReturnedValue MathObject::method_pow(const FunctionObject *, const Value *, const Value *argv, int argc)
@@ -283,8 +475,11 @@ ReturnedValue MathObject::method_random(const FunctionObject *, const Value *, c
ReturnedValue MathObject::method_round(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
- v = copySign(std::floor(v + 0.5), v);
- RETURN_RESULT(Encode(v));
+ if (std::isnan(v) || qt_is_inf(v) || qIsNull(v))
+ RETURN_RESULT(Encode(v));
+
+ v = copySign(std::floor(v + 0.5), v);
+ RETURN_RESULT(Encode(v));
}
ReturnedValue MathObject::method_sign(const FunctionObject *, const Value *, const Value *argv, int argc)
@@ -303,7 +498,19 @@ ReturnedValue MathObject::method_sign(const FunctionObject *, const Value *, con
ReturnedValue MathObject::method_sin(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double v = argc ? argv[0].toNumber() : qt_qnan();
- RETURN_RESULT(Encode(std::sin(v)));
+ if (v == 0.0)
+ RETURN_RESULT(Encode(v));
+ else
+ RETURN_RESULT(Encode(std::sin(v)));
+}
+
+ReturnedValue MathObject::method_sinh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v == 0.0)
+ RETURN_RESULT(Encode(v));
+ else
+ RETURN_RESULT(Encode(std::sinh(v)));
}
ReturnedValue MathObject::method_sqrt(const FunctionObject *, const Value *, const Value *argv, int argc)
@@ -321,3 +528,25 @@ ReturnedValue MathObject::method_tan(const FunctionObject *, const Value *, cons
RETURN_RESULT(Encode(std::tan(v)));
}
+ReturnedValue MathObject::method_tanh(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+ if (v == 0.0)
+ RETURN_RESULT(Encode(v));
+ else
+ RETURN_RESULT(Encode(std::tanh(v)));
+}
+
+ReturnedValue MathObject::method_trunc(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ double v = argc ? argv[0].toNumber() : qt_qnan();
+#ifdef Q_OS_ANDROID // incomplete std :-(
+ if (std::isnan(v) || qt_is_inf(v) || qIsNull(v))
+ RETURN_RESULT(Encode(v));
+ // Nearest integer not greater in magnitude:
+ quint64 whole = std::abs(v);
+ RETURN_RESULT(Encode(copySign(whole, v)));
+#else
+ RETURN_RESULT(Encode(std::trunc(v)));
+#endif
+}
diff --git a/src/qml/jsruntime/qv4mathobject_p.h b/src/qml/jsruntime/qv4mathobject_p.h
index 0bf5da9404..2658e25438 100644
--- a/src/qml/jsruntime/qv4mathobject_p.h
+++ b/src/qml/jsruntime/qv4mathobject_p.h
@@ -71,14 +71,27 @@ struct MathObject: Object
static ReturnedValue method_abs(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_acos(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_acosh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_asin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_asinh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_atan(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_atanh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_atan2(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_cbrt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_ceil(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_clz32(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_cos(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_cosh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_exp(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_expm1(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_floor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_fround(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_hypot(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_imul(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_log(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_log10(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_log1p(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_log2(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_max(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_min(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_pow(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -86,8 +99,11 @@ struct MathObject: Object
static ReturnedValue method_round(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_sign(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_sin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_sinh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_sqrt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_tan(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_tanh(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_trunc(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
}
diff --git a/src/qml/jsruntime/qv4memberdata.cpp b/src/qml/jsruntime/qv4memberdata.cpp
index da086bd47a..246f857643 100644
--- a/src/qml/jsruntime/qv4memberdata.cpp
+++ b/src/qml/jsruntime/qv4memberdata.cpp
@@ -62,8 +62,9 @@ static size_t nextPowerOfTwo(size_t s)
Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n, Heap::MemberData *old)
{
- Q_ASSERT(!old || old->values.size < n);
- Q_ASSERT(n);
+ Q_ASSERT(!old || old->values.size <= n);
+ if (!n)
+ n = 4;
size_t alloc = MemoryManager::align(sizeof(Heap::MemberData) + (n - 1)*sizeof(Value));
// round up to next power of two to avoid quadratic behaviour for very large objects
diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h
index ac9671254d..186083b83a 100644
--- a/src/qml/jsruntime/qv4memberdata_p.h
+++ b/src/qml/jsruntime/qv4memberdata_p.h
@@ -74,18 +74,6 @@ struct MemberData : Managed
V4_MANAGED(MemberData, Managed)
V4_INTERNALCLASS(MemberData)
- struct Index {
- Heap::Base *base;
- Value *slot;
-
- void set(EngineBase *e, Value newVal) {
- WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue());
- }
- const Value *operator->() const { return slot; }
- const Value &operator*() const { return *slot; }
- bool isNull() const { return !slot; }
- };
-
const Value &operator[] (uint idx) const { return d()->values[idx]; }
const Value *data() const { return d()->values.data(); }
void set(EngineBase *e, uint index, Value v) { d()->values.set(e, index, v); }
diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp
new file mode 100644
index 0000000000..19a036374f
--- /dev/null
+++ b/src/qml/jsruntime/qv4module.cpp
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qv4module_p.h"
+
+#include <private/qv4mm_p.h>
+#include <private/qv4vme_moth_p.h>
+#include <private/qv4context_p.h>
+#include <private/qv4symbol_p.h>
+#include <private/qv4identifiertable_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(Module);
+
+void Heap::Module::init(ExecutionEngine *engine, CompiledData::CompilationUnit *moduleUnit)
+{
+ Object::init();
+
+ // This is a back pointer and there is no need to call addref() on the unit, because the unit
+ // owns this object instead.
+ unit = moduleUnit;
+ self.set(engine, this);
+
+ Function *moduleFunction = unit->runtimeFunctions[unit->unitData()->indexOfRootFunction];
+
+ const uint locals = moduleFunction->compiledFunction->nLocals;
+ const size_t requiredMemory = sizeof(QV4::CallContext::Data) - sizeof(Value) + sizeof(Value) * locals;
+ scope.set(engine, engine->memoryManager->allocManaged<QV4::CallContext>(requiredMemory, moduleFunction->internalClass));
+ scope->init();
+ scope->outer.set(engine, engine->rootContext()->d());
+ scope->locals.size = locals;
+ scope->locals.alloc = locals;
+ scope->nArgs = 0;
+
+ // Prepare the temporal dead zone
+ scope->setupLocalTemporalDeadZone(moduleFunction->compiledFunction);
+
+ Scope valueScope(engine);
+
+ // It's possible for example to re-export an import, for example:
+ // import * as foo from "./bar.js"
+ // export { foo }
+ // Since we don't add imports to the locals, it won't be found typically.
+ // Except now we add imports at the end of the internal class in the index
+ // space past the locals, so that resolveExport can find it.
+ {
+ Scoped<QV4::InternalClass> ic(valueScope, scope->internalClass);
+
+ for (uint i = 0; i < unit->data->importEntryTableSize; ++i) {
+ const CompiledData::ImportEntry &import = unit->data->importEntryTable()[i];
+ ic = ic->addMember(engine->identifierTable->asPropertyKey(unit->runtimeStrings[import.localName]), Attr_NotConfigurable);
+ }
+ scope->internalClass.set(engine, ic->d());
+ }
+
+
+ Scoped<QV4::Module> This(valueScope, this);
+ ScopedString name(valueScope, engine->newString(QStringLiteral("Module")));
+ This->insertMember(engine->symbol_toStringTag(), name, Attr_ReadOnly);
+ This->setPrototypeUnchecked(nullptr);
+}
+
+ReturnedValue Module::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
+{
+ if (id.isSymbol())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ if (hasProperty)
+ *hasProperty = v != nullptr;
+ if (!v)
+ return Encode::undefined();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ return scope.engine->throwReferenceError(propName);
+ }
+ return v->asReturnedValue();
+}
+
+PropertyAttributes Module::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
+{
+ if (id.isSymbol())
+ return Object::virtualGetOwnProperty(m, id, p);
+
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ if (!v) {
+ if (p)
+ p->value = Encode::undefined();
+ return Attr_Invalid;
+ }
+ if (p)
+ p->value = v->isEmpty() ? Encode::undefined() : v->asReturnedValue();
+ if (v->isEmpty()) {
+ ScopedValue propName(scope, id.toStringOrSymbol(scope.engine));
+ scope.engine->throwReferenceError(propName);
+ }
+ return Attr_Data | Attr_NotConfigurable;
+}
+
+bool Module::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ if (id.isSymbol())
+ return Object::virtualHasProperty(m, id);
+
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ return v != nullptr;
+}
+
+bool Module::virtualPreventExtensions(Managed *)
+{
+ return true;
+}
+
+bool Module::virtualDefineOwnProperty(Managed *, PropertyKey, const Property *, PropertyAttributes)
+{
+ return false;
+}
+
+bool Module::virtualPut(Managed *, PropertyKey, const Value &, Value *)
+{
+ return false;
+}
+
+bool Module::virtualDeleteProperty(Managed *m, PropertyKey id)
+{
+ if (id.isSymbol())
+ return Object::virtualDeleteProperty(m, id);
+ const Module *module = static_cast<const Module *>(m);
+ Scope scope(m->engine());
+ ScopedString expectedName(scope, id.toStringOrSymbol(scope.engine));
+ if (!expectedName)
+ return true;
+ const Value *v = module->d()->unit->resolveExport(expectedName);
+ if (v)
+ return false;
+ return true;
+}
+
+struct ModuleNamespaceIterator : ObjectOwnPropertyKeyIterator
+{
+ QStringList exportedNames;
+ int exportIndex = 0;
+ ModuleNamespaceIterator(const QStringList &names) : exportedNames(names) {}
+ ~ModuleNamespaceIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey ModuleNamespaceIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
+{
+ const Module *module = static_cast<const Module *>(o);
+ if (exportIndex < exportedNames.count()) {
+ if (attrs)
+ *attrs = Attr_Data;
+ Scope scope(module->engine());
+ ScopedString exportName(scope, scope.engine->newString(exportedNames.at(exportIndex)));
+ exportIndex++;
+ const Value *v = module->d()->unit->resolveExport(exportName);
+ if (pd) {
+ if (v->isEmpty())
+ scope.engine->throwReferenceError(exportName);
+ else
+ pd->value = *v;
+ }
+ return exportName->toPropertyKey();
+ }
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *Module::virtualOwnPropertyKeys(const Object *o, Value *target)
+{
+ const Module *module = static_cast<const Module *>(o);
+ *target = *o;
+ return new ModuleNamespaceIterator(module->d()->unit->exportedNames());
+}
+
+Heap::Object *Module::virtualGetPrototypeOf(const Managed *)
+{
+ return nullptr;
+}
+
+bool Module::virtualSetPrototypeOf(Managed *, const Object *proto)
+{
+ return proto == nullptr;
+}
+
+bool Module::virtualIsExtensible(const Managed *)
+{
+ return false;
+}
diff --git a/src/qml/jsruntime/qv4module_p.h b/src/qml/jsruntime/qv4module_p.h
new file mode 100644
index 0000000000..0cab161b82
--- /dev/null
+++ b/src/qml/jsruntime/qv4module_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4MODULE
+#define QV4MODULE
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4context_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+#define ModuleMembers(class, Member) \
+ Member(class, NoMark, CompiledData::CompilationUnit *, unit) \
+ Member(class, Pointer, CallContext *, scope) \
+ Member(class, HeapValue, HeapValue, self)
+
+DECLARE_EXPORTED_HEAP_OBJECT(Module, Object) {
+ DECLARE_MARKOBJECTS(Module)
+
+ void init(ExecutionEngine *engine, CompiledData::CompilationUnit *moduleUnit);
+};
+
+}
+
+struct Q_QML_EXPORT Module : public Object {
+ V4_OBJECT2(Module, Object)
+
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
+ static bool virtualPreventExtensions(Managed *);
+ static bool virtualDefineOwnProperty(Managed *, PropertyKey, const Property *, PropertyAttributes);
+ static bool virtualPut(Managed *, PropertyKey, const Value &, Value *);
+ static bool virtualDeleteProperty(Managed *m, PropertyKey id);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
+ static Heap::Object *virtualGetPrototypeOf(const Managed *);
+ static bool virtualSetPrototypeOf(Managed *, const Object *proto);
+ static bool virtualIsExtensible(const Managed *);
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4MODULE
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index f58ff45801..11ec53ced5 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -78,13 +78,13 @@ void Heap::NumberCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Number"));
}
-ReturnedValue NumberCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue NumberCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
{
double dbl = argc ? argv[0].toNumber() : 0.;
return Encode(f->engine()->newNumberObject(dbl));
}
-ReturnedValue NumberCtor::call(const FunctionObject *, const Value *, const Value *argv, int argc)
+ReturnedValue NumberCtor::virtualCall(const FunctionObject *, const Value *, const Value *argv, int argc)
{
double dbl = argc ? argv[0].toNumber() : 0.;
return Encode(dbl);
@@ -95,19 +95,19 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
- ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qt_qnan()));
- ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf()));
- ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf()));
- ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308));
- ctor->defineReadonlyProperty(QStringLiteral("EPSILON"), Primitive::fromDouble(std::numeric_limits<double>::epsilon()));
- ctor->defineReadonlyProperty(QStringLiteral("MAX_SAFE_INTEGER"), Primitive::fromDouble(9007199254740991));
- ctor->defineReadonlyProperty(QStringLiteral("MIN_SAFE_INTEGER"), Primitive::fromDouble(-9007199254740991));
+ ctor->defineReadonlyProperty(QStringLiteral("NaN"), Value::fromDouble(qt_qnan()));
+ ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf()));
+ ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf()));
+ ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308));
+ ctor->defineReadonlyProperty(QStringLiteral("EPSILON"), Value::fromDouble(std::numeric_limits<double>::epsilon()));
+ ctor->defineReadonlyProperty(QStringLiteral("MAX_SAFE_INTEGER"), Value::fromDouble(9007199254740991));
+ ctor->defineReadonlyProperty(QStringLiteral("MIN_SAFE_INTEGER"), Value::fromDouble(-9007199254740991));
QT_WARNING_PUSH
QT_WARNING_DISABLE_INTEL(239)
- ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Primitive::fromDouble(5e-324));
+ ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324));
QT_WARNING_POP
ctor->defineDefaultProperty(QStringLiteral("isFinite"), method_isFinite, 1);
@@ -117,7 +117,7 @@ QT_WARNING_POP
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString, 1);
- defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString);
+ defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString);
defineDefaultProperty(engine->id_valueOf(), method_valueOf);
defineDefaultProperty(QStringLiteral("toFixed"), method_toFixed, 1);
defineDefaultProperty(QStringLiteral("toExponential"), method_toExponential, 1);
@@ -150,7 +150,7 @@ inline double thisNumber(ExecutionEngine *engine, const Value *thisObject)
ReturnedValue NumberPrototype::method_isFinite(const FunctionObject *, const Value *, const Value *argv, int argc)
{
- if (!argc)
+ if (!argc || !argv[0].isNumber())
return Encode(false);
double v = argv[0].toNumber();
@@ -193,7 +193,7 @@ ReturnedValue NumberPrototype::method_isSafeInteger(const FunctionObject *, cons
ReturnedValue NumberPrototype::method_isNaN(const FunctionObject *, const Value *, const Value *argv, int argc)
{
- if (!argc)
+ if (!argc || !argv[0].isNumber())
return Encode(false);
double v = argv[0].toNumber();
@@ -229,7 +229,7 @@ ReturnedValue NumberPrototype::method_toString(const FunctionObject *b, const Va
num = -num;
}
double frac = num - std::floor(num);
- num = Primitive::toInteger(num);
+ num = Value::toInteger(num);
do {
char c = (char)std::fmod(num, radix);
c = (c < 10) ? (c + '0') : (c - 10 + 'a');
@@ -252,7 +252,7 @@ ReturnedValue NumberPrototype::method_toString(const FunctionObject *b, const Va
}
}
- return Encode(Primitive::fromDouble(num).toString(v4));
+ return Encode(Value::fromDouble(num).toString(v4));
}
ReturnedValue NumberPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -282,7 +282,7 @@ ReturnedValue NumberPrototype::method_toFixed(const FunctionObject *b, const Val
if (std::isnan(fdigits))
fdigits = 0;
- if (fdigits < 0 || fdigits > 20)
+ if (fdigits < 0 || fdigits > 100)
return v4->throwRangeError(*thisObject);
QString str;
@@ -305,16 +305,21 @@ ReturnedValue NumberPrototype::method_toExponential(const FunctionObject *b, con
if (v4->hasException)
return QV4::Encode::undefined();
+ bool defaultDigits = !argc || argv[0].isUndefined();
+ int fdigits = !defaultDigits ? argv[0].toInteger() : NumberLocale::instance()->defaultDoublePrecision;
+ if (v4->hasException)
+ return QV4::Encode::undefined();
- int fdigits = NumberLocale::instance()->defaultDoublePrecision;
+ if (std::isnan(d))
+ return Encode(v4->newString(QLatin1String("NaN")));
- if (argc && !argv[0].isUndefined()) {
- fdigits = argv[0].toInt32();
- if (fdigits < 0 || fdigits > 20) {
- Scope scope(v4);
- ScopedString error(scope, v4->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
- return v4->throwRangeError(error);
- }
+ if (qIsInf(d))
+ return Encode(v4->newString(QLatin1String(d < 0 ? "-Infinity" : "Infinity")));
+
+ if (!defaultDigits && (fdigits < 0 || fdigits > 100)) {
+ Scope scope(v4);
+ ScopedString error(scope, v4->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
+ return v4->throwRangeError(error);
}
QString result = NumberLocale::instance()->toString(d, 'e', fdigits);
@@ -327,17 +332,26 @@ ReturnedValue NumberPrototype::method_toPrecision(const FunctionObject *b, const
ScopedValue v(scope, thisNumberValue(scope.engine, thisObject));
if (scope.engine->hasException)
return QV4::Encode::undefined();
-
+ double d = v->asDouble();
if (!argc || argv[0].isUndefined())
return Encode(v->toString(scope.engine));
int precision = argv[0].toInt32();
- if (precision < 1 || precision > 21) {
+ if (scope.engine->hasException)
+ return QV4::Encode::undefined();
+
+ if (std::isnan(d))
+ return Encode(scope.engine->newString(QLatin1String("NaN")));
+
+ if (qIsInf(d))
+ return Encode(scope.engine->newString(QLatin1String(d < 0 ? "-Infinity" : "Infinity")));
+
+ if (precision < 1 || precision > 100) {
ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
return scope.engine->throwRangeError(error);
}
- QString result = NumberLocale::instance()->toString(v->asDouble(), 'g', precision);
+ QString result = NumberLocale::instance()->toString(d, 'g', precision);
return Encode(scope.engine->newString(result));
}
diff --git a/src/qml/jsruntime/qv4numberobject_p.h b/src/qml/jsruntime/qv4numberobject_p.h
index cfdcf9bc1d..576817cf36 100644
--- a/src/qml/jsruntime/qv4numberobject_p.h
+++ b/src/qml/jsruntime/qv4numberobject_p.h
@@ -79,8 +79,8 @@ struct NumberCtor: FunctionObject
{
V4_OBJECT2(NumberCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
struct NumberPrototype: NumberObject
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 0c6cde84ad..a7ede4627c 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -50,6 +50,8 @@
#include "qv4string_p.h"
#include "qv4identifiertable_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
+#include "qv4proxy_p.h"
#include <stdint.h>
@@ -57,9 +59,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(Object);
-void Object::setInternalClass(InternalClass *ic)
+void Object::setInternalClass(Heap::InternalClass *ic)
{
- d()->internalClass = ic;
+ d()->internalClass.set(engine(), ic);
if (ic->isUsedAsProto)
ic->updateProtoUsage(d());
Q_ASSERT(ic && ic->vtable);
@@ -72,40 +74,26 @@ void Object::setInternalClass(InternalClass *ic)
d()->memberData.set(ic->engine, MemberData::allocate(ic->engine, requiredSize, d()->memberData));
}
-void Object::getProperty(uint index, Property *p, PropertyAttributes *attrs) const
+void Object::getProperty(const InternalClassEntry &entry, Property *p) const
{
- p->value = *propertyData(index);
- *attrs = internalClass()->propertyData.at(index);
- if (attrs->isAccessor())
- p->set = *propertyData(index + SetterOffset);
+ p->value = *propertyData(entry.index);
+ if (entry.attributes.isAccessor())
+ p->set = *propertyData(entry.setterIndex);
}
-void Object::setProperty(uint index, const Property *p)
+void Object::setProperty(const InternalClassEntry &entry, const Property *p)
{
- setProperty(index, p->value);
- if (internalClass()->propertyData.at(index).isAccessor())
- setProperty(index + SetterOffset, p->set);
+ setProperty(entry.index, p->value);
+ if (entry.attributes.isAccessor())
+ setProperty(entry.setterIndex, p->set);
}
void Heap::Object::setUsedAsProto()
{
- internalClass = internalClass->asProtoClass();
+ internalClass.set(internalClass->engine, internalClass->asProtoClass());
}
-bool Object::setPrototype(Object *proto)
-{
- Heap::Object *p = proto ? proto->d() : nullptr;
- Heap::Object *pp = p;
- while (pp) {
- if (pp == d())
- return false;
- pp = pp->prototype();
- }
- setInternalClass(internalClass()->changePrototype(p));
- return true;
-}
-
-ReturnedValue Object::getValue(const Value &thisObject, const Value &v, PropertyAttributes attrs)
+ReturnedValue Object::getValueAccessor(const Value &thisObject, const Value &v, PropertyAttributes attrs)
{
if (!attrs.isAccessor())
return v.asReturnedValue();
@@ -119,16 +107,14 @@ ReturnedValue Object::getValue(const Value &thisObject, const Value &v, Property
return f->call(jsCallData);
}
-bool Object::putValue(uint memberIndex, const Value &value)
+bool Object::putValue(uint memberIndex, PropertyAttributes attrs, const Value &value)
{
- QV4::InternalClass *ic = internalClass();
+ Heap::InternalClass *ic = internalClass();
if (ic->engine->hasException)
return false;
- PropertyAttributes attrs = ic->propertyData[memberIndex];
-
if (attrs.isAccessor()) {
- const FunctionObject *set = propertyData(memberIndex + SetterOffset)->as<FunctionObject>();
+ const FunctionObject *set = propertyData(memberIndex)->as<FunctionObject>();
if (set) {
Scope scope(ic->engine);
ScopedFunctionObject setter(scope, set);
@@ -148,37 +134,34 @@ bool Object::putValue(uint memberIndex, const Value &value)
return true;
}
-void Object::defineDefaultProperty(const QString &name, const Value &value)
+void Object::defineDefaultProperty(const QString &name, const Value &value, PropertyAttributes attributes)
{
ExecutionEngine *e = engine();
Scope scope(e);
ScopedString s(scope, e->newIdentifier(name));
- defineDefaultProperty(s, value);
+ defineDefaultProperty(s, value, attributes);
}
-void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc), int argumentCount)
+void Object::defineDefaultProperty(const QString &name, VTable::Call code,
+ int argumentCount, PropertyAttributes attributes)
{
ExecutionEngine *e = engine();
Scope scope(e);
ScopedString s(scope, e->newIdentifier(name));
- ExecutionContext *global = e->rootContext();
- ScopedFunctionObject function(scope, FunctionObject::createBuiltinFunction(global, s, code));
- function->defineReadonlyConfigurableProperty(e->id_length(), Primitive::fromInt32(argumentCount));
- defineDefaultProperty(s, function);
+ ScopedFunctionObject function(scope, FunctionObject::createBuiltinFunction(e, s, code, argumentCount));
+ defineDefaultProperty(s, function, attributes);
}
-void Object::defineDefaultProperty(String *name, ReturnedValue (*code)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc), int argumentCount)
+void Object::defineDefaultProperty(StringOrSymbol *nameOrSymbol, VTable::Call code,
+ int argumentCount, PropertyAttributes attributes)
{
ExecutionEngine *e = engine();
Scope scope(e);
- ExecutionContext *global = e->rootContext();
- ScopedFunctionObject function(scope, FunctionObject::createBuiltinFunction(global, name, code));
- function->defineReadonlyConfigurableProperty(e->id_length(), Primitive::fromInt32(argumentCount));
- defineDefaultProperty(name, function);
+ ScopedFunctionObject function(scope, FunctionObject::createBuiltinFunction(e, nameOrSymbol, code, argumentCount));
+ defineDefaultProperty(nameOrSymbol, function, attributes);
}
-void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter)(const FunctionObject *, const Value *, const Value *, int),
- ReturnedValue (*setter)(const FunctionObject *, const Value *, const Value *, int))
+void Object::defineAccessorProperty(const QString &name, VTable::Call getter, VTable::Call setter)
{
ExecutionEngine *e = engine();
Scope scope(e);
@@ -186,16 +169,27 @@ void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter)
defineAccessorProperty(s, getter, setter);
}
-void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(const FunctionObject *, const Value *, const Value *, int),
- ReturnedValue (*setter)(const FunctionObject *, const Value *, const Value *, int))
+void Object::defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, VTable::Call setter)
{
ExecutionEngine *v4 = engine();
QV4::Scope scope(v4);
ScopedProperty p(scope);
- ExecutionContext *global = v4->rootContext();
- p->setGetter(ScopedFunctionObject(scope, (getter ? FunctionObject::createBuiltinFunction(global, name, getter) : nullptr)));
- p->setSetter(ScopedFunctionObject(scope, (setter ? FunctionObject::createBuiltinFunction(global, name, setter) : nullptr)));
- insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+ QString n = name->toQString();
+ if (n.at(0) == QLatin1Char('@'))
+ n = QChar::fromLatin1('[') + n.midRef(1) + QChar::fromLatin1(']');
+ if (getter) {
+ ScopedString getName(scope, v4->newString(QString::fromLatin1("get ") + n));
+ p->setGetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, getName, getter, 0)));
+ } else {
+ p->setGetter(nullptr);
+ }
+ if (setter) {
+ ScopedString setName(scope, v4->newString(QString::fromLatin1("set ") + n));
+ p->setSetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, setName, setter, 0)));
+ } else {
+ p->setSetter(nullptr);
+ }
+ insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable);
}
@@ -221,13 +215,23 @@ void Object::defineReadonlyConfigurableProperty(const QString &name, const Value
defineReadonlyConfigurableProperty(s, value);
}
-void Object::defineReadonlyConfigurableProperty(String *name, const Value &value)
+void Object::defineReadonlyConfigurableProperty(StringOrSymbol *name, const Value &value)
{
insertMember(name, value, Attr_ReadOnly_ButConfigurable);
}
+void Object::addSymbolSpecies()
+{
+ Scope scope(engine());
+ ScopedProperty p(scope);
+ p->setGetter(scope.engine->getSymbolSpecies());
+ p->setSetter(nullptr);
+ insertMember(scope.engine->symbol_species(), p, QV4::Attr_Accessor|QV4::Attr_NotWritable|QV4::Attr_NotEnumerable);
+}
+
void Heap::Object::markObjects(Heap::Base *b, MarkStack *stack)
{
+ Base::markObjects(b, stack);
Object *o = static_cast<Object *>(b);
if (o->memberData)
o->memberData->mark(stack);
@@ -242,367 +246,208 @@ void Heap::Object::markObjects(Heap::Base *b, MarkStack *stack)
}
}
-void Object::insertMember(String *s, const Property *p, PropertyAttributes attributes)
+void Object::insertMember(StringOrSymbol *s, const Property *p, PropertyAttributes attributes)
{
- uint idx;
- InternalClass::addMember(this, s, attributes, &idx);
+ InternalClassEntry idx;
+ PropertyKey key = s->toPropertyKey();
+ Heap::InternalClass::addMember(this, key, attributes, &idx);
- if (attributes.isAccessor()) {
- setProperty(idx + GetterOffset, p->value);
- setProperty(idx + SetterOffset, p->set);
- } else {
- setProperty(idx, p->value);
- }
+ setProperty(idx.index, p->value);
+ if (attributes.isAccessor())
+ setProperty(idx.setterIndex, p->set);
}
-// Section 8.12.1
-void Object::getOwnProperty(String *name, PropertyAttributes *attrs, Property *p)
+void Object::setPrototypeUnchecked(const Object *p)
{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return getOwnProperty(idx, attrs, p);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- uint member = internalClass()->find(id);
- if (member < UINT_MAX) {
- *attrs = internalClass()->propertyData[member];
- if (p) {
- p->value = *propertyData(member);
- if (attrs->isAccessor())
- p->set = *propertyData(member + SetterOffset);
- }
- return;
- }
-
- if (attrs)
- *attrs = Attr_Invalid;
- return;
-}
-
-void Object::getOwnProperty(uint index, PropertyAttributes *attrs, Property *p)
-{
- if (arrayData()) {
- if (arrayData()->getProperty(index, p, attrs))
- return;
- }
- if (isStringObject()) {
- *attrs = Attr_NotConfigurable|Attr_NotWritable;
- if (p)
- p->value = static_cast<StringObject *>(this)->getIndex(index);
- return;
- }
-
- if (attrs)
- *attrs = Attr_Invalid;
- return;
+ setInternalClass(internalClass()->changePrototype(p ? p->d() : nullptr));
}
// Section 8.12.2
-MemberData::Index Object::getValueOrSetter(String *name, PropertyAttributes *attrs)
+PropertyIndex Object::getValueOrSetter(PropertyKey id, PropertyAttributes *attrs)
{
- Q_ASSERT(name->asArrayIndex() == UINT_MAX);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- Heap::Object *o = d();
- while (o) {
- uint idx = o->internalClass->find(id);
- if (idx < UINT_MAX) {
- *attrs = o->internalClass->propertyData[idx];
- return o->writablePropertyData(attrs->isAccessor() ? idx + SetterOffset : idx );
- }
-
- o = o->prototype();
- }
- *attrs = Attr_Invalid;
- return { nullptr, nullptr };
-}
-
-ArrayData::Index Object::getValueOrSetter(uint index, PropertyAttributes *attrs)
-{
- Heap::Object *o = d();
- while (o) {
- if (o->arrayData) {
- uint idx = o->arrayData->mappedIndex(index);
- if (idx != UINT_MAX) {
- *attrs = o->arrayData->attributes(index);
- return { o->arrayData , attrs->isAccessor() ? idx + SetterOffset : idx };
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ Heap::Object *o = d();
+ while (o) {
+ if (o->arrayData) {
+ uint idx = o->arrayData->mappedIndex(index);
+ if (idx != UINT_MAX) {
+ *attrs = o->arrayData->attributes(index);
+ return { o->arrayData , o->arrayData->values.values + (attrs->isAccessor() ? idx + SetterOffset : idx) };
+ }
+ }
+ if (o->vtable()->type == Type_StringObject) {
+ if (index < static_cast<const Heap::StringObject *>(o)->length()) {
+ // this is an evil hack, but it works, as the method is only ever called from put,
+ // where we don't use the returned pointer there for non writable attributes
+ *attrs = (Attr_NotWritable|Attr_NotConfigurable);
+ return { reinterpret_cast<Heap::ArrayData *>(0x1), nullptr };
+ }
}
+ o = o->prototype();
}
- if (o->vtable()->type == Type_StringObject) {
- if (index < static_cast<const Heap::StringObject *>(o)->length()) {
- // this is an evil hack, but it works, as the method is only ever called from putIndexed,
- // where we don't use the returned pointer there for non writable attributes
- *attrs = (Attr_NotWritable|Attr_NotConfigurable);
- return { reinterpret_cast<Heap::ArrayData *>(0x1), 0 };
+ } else {
+ Heap::Object *o = d();
+ while (o) {
+ auto idx = o->internalClass->findValueOrSetter(id);
+ if (idx.isValid()) {
+ *attrs = idx.attrs;
+ return o->writablePropertyData(idx.index);
}
+
+ o = o->prototype();
}
- o = o->prototype();
}
*attrs = Attr_Invalid;
- return { nullptr, 0 };
-}
-
-bool Object::hasProperty(String *name) const
-{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return hasProperty(idx);
-
- Scope scope(engine());
- ScopedObject o(scope, d());
- while (o) {
- if (o->hasOwnProperty(name))
- return true;
-
- o = o->prototype();
- }
-
- return false;
-}
-
-bool Object::hasProperty(uint index) const
-{
- Scope scope(engine());
- ScopedObject o(scope, d());
- while (o) {
- if (o->hasOwnProperty(index))
- return true;
-
- o = o->prototype();
- }
-
- return false;
-}
-
-bool Object::hasOwnProperty(String *name) const
-{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return hasOwnProperty(idx);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- if (internalClass()->find(id) < UINT_MAX)
- return true;
- if (!query(name).isEmpty())
- return true;
- return false;
-}
-
-bool Object::hasOwnProperty(uint index) const
-{
- if (arrayData() && !arrayData()->isEmpty(index))
- return true;
-
- if (isStringObject()) {
- if (index < static_cast<const StringObject *>(this)->length())
- return true;
- }
- if (!queryIndexed(index).isEmpty())
- return true;
- return false;
-}
-
-ReturnedValue Object::callAsConstructor(const FunctionObject *f, const Value *, int)
-{
- return f->engine()->throwTypeError();
-}
-
-ReturnedValue Object::call(const FunctionObject *f, const Value *, const Value *, int)
-{
- return f->engine()->throwTypeError();
-}
-
-ReturnedValue Object::get(const Managed *m, String *name, bool *hasProperty)
-{
- return static_cast<const Object *>(m)->internalGet(name, hasProperty);
-}
-
-ReturnedValue Object::getIndexed(const Managed *m, uint index, bool *hasProperty)
-{
- return static_cast<const Object *>(m)->internalGetIndexed(index, hasProperty);
-}
-
-bool Object::put(Managed *m, String *name, const Value &value)
-{
- return static_cast<Object *>(m)->internalPut(name, value);
-}
-
-bool Object::putIndexed(Managed *m, uint index, const Value &value)
-{
- return static_cast<Object *>(m)->internalPutIndexed(index, value);
-}
-
-PropertyAttributes Object::query(const Managed *m, String *name)
-{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return queryIndexed(m, idx);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- const Object *o = static_cast<const Object *>(m);
- idx = o->internalClass()->find(id);
- if (idx < UINT_MAX)
- return o->internalClass()->propertyData[idx];
-
- return Attr_Invalid;
+ return { nullptr, nullptr };
}
-PropertyAttributes Object::queryIndexed(const Managed *m, uint index)
+ReturnedValue Object::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
- const Object *o = static_cast<const Object *>(m);
- if (o->arrayData() && !o->arrayData()->isEmpty(index))
- return o->arrayData()->attributes(index);
-
- if (o->isStringObject()) {
- if (index < static_cast<const StringObject *>(o)->length())
- return (Attr_NotWritable|Attr_NotConfigurable);
- }
- return Attr_Invalid;
+ return static_cast<const Object *>(m)->internalGet(id, receiver, hasProperty);
}
-bool Object::deleteProperty(Managed *m, String *name)
+bool Object::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
- return static_cast<Object *>(m)->internalDeleteProperty(name);
+ return static_cast<Object *>(m)->internalPut(id, value, receiver);
}
-bool Object::deleteIndexedProperty(Managed *m, uint index)
+bool Object::virtualDeleteProperty(Managed *m, PropertyKey id)
{
- return static_cast<Object *>(m)->internalDeleteIndexedProperty(index);
+ return static_cast<Object *>(m)->internalDeleteProperty(id);
}
-void Object::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *pd, PropertyAttributes *attrs)
+PropertyKey ObjectOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
{
- Object *o = static_cast<Object *>(m);
- name->setM(nullptr);
- *index = UINT_MAX;
-
- if (o->arrayData()) {
- if (!it->arrayIndex)
- it->arrayNode = o->sparseBegin();
+ if (arrayIndex != UINT_MAX && o->arrayData()) {
+ if (!arrayIndex)
+ arrayNode = o->sparseBegin();
// sparse arrays
- if (it->arrayNode) {
- while (it->arrayNode != o->sparseEnd()) {
- int k = it->arrayNode->key();
- uint pidx = it->arrayNode->value;
+ if (arrayNode) {
+ while (arrayNode != o->sparseEnd()) {
+ uint k = arrayNode->key();
+ uint pidx = arrayNode->value;
Heap::SparseArrayData *sa = o->d()->arrayData.cast<Heap::SparseArrayData>();
const Property *p = reinterpret_cast<const Property *>(sa->values.data() + pidx);
- it->arrayNode = it->arrayNode->nextNode();
+ arrayNode = arrayNode->nextNode();
PropertyAttributes a = sa->attrs ? sa->attrs[pidx] : Attr_Data;
- if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) {
- it->arrayIndex = k + 1;
- *index = k;
- *attrs = a;
+ arrayIndex = k + 1;
+ if (pd)
pd->copy(p, a);
- return;
- }
+ if (attrs)
+ *attrs = a;
+ return PropertyKey::fromArrayIndex(k);
}
- it->arrayNode = nullptr;
- it->arrayIndex = UINT_MAX;
+ arrayNode = nullptr;
+ arrayIndex = UINT_MAX;
}
// dense arrays
- while (it->arrayIndex < o->d()->arrayData->values.size) {
+ while (arrayIndex < o->d()->arrayData->values.size) {
Heap::SimpleArrayData *sa = o->d()->arrayData.cast<Heap::SimpleArrayData>();
- const Value &val = sa->data(it->arrayIndex);
- PropertyAttributes a = o->arrayData()->attributes(it->arrayIndex);
- ++it->arrayIndex;
- if (!val.isEmpty()
- && (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable())) {
- *index = it->arrayIndex - 1;
- *attrs = a;
- pd->value = val;
- return;
+ const Value &val = sa->data(arrayIndex);
+ PropertyAttributes a = o->arrayData()->attributes(arrayIndex);
+ int index = arrayIndex;
+ ++arrayIndex;
+ if (!val.isEmpty()) {
+ if (pd)
+ pd->value = val;
+ if (attrs)
+ *attrs = a;
+ return PropertyKey::fromArrayIndex(index);
}
}
+ arrayIndex = UINT_MAX;
}
- while (it->memberIndex < o->internalClass()->size) {
- Identifier *n = o->internalClass()->nameMap.at(it->memberIndex);
- if (!n) {
- // accessor properties have a dummy entry with n == 0
- ++it->memberIndex;
- continue;
- }
-
- int idx = it->memberIndex;
- PropertyAttributes a = o->internalClass()->propertyData[it->memberIndex];
- ++it->memberIndex;
- if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) {
- name->setM(o->engine()->identifierTable->stringFromIdentifier(n));
- *attrs = a;
- pd->value = *o->propertyData(idx);
- if (a.isAccessor())
- pd->set = *o->propertyData(idx + SetterOffset);
- return;
+ while (true) {
+ while (memberIndex < o->internalClass()->size) {
+ PropertyKey n = o->internalClass()->nameMap.at(memberIndex);
+ ++memberIndex;
+ if (!n.isStringOrSymbol())
+ // accessor properties have a dummy entry with n == 0
+ continue;
+ if (!iterateOverSymbols && n.isSymbol())
+ continue;
+ if (iterateOverSymbols && !n.isSymbol())
+ continue;
+
+ InternalClassEntry e = o->internalClass()->find(n);
+ if (!e.isValid())
+ continue;
+ if (pd) {
+ pd->value = *o->propertyData(e.index);
+ if (e.attributes.isAccessor())
+ pd->set = *o->propertyData(e.setterIndex);
+ }
+ if (attrs)
+ *attrs = e.attributes;
+ return n;
}
+ if (iterateOverSymbols)
+ break;
+ iterateOverSymbols = true;
+ memberIndex = 0;
}
- *attrs = PropertyAttributes();
+ return PropertyKey::invalid();
}
-// Section 8.12.3
-ReturnedValue Object::internalGet(String *name, bool *hasProperty) const
+OwnPropertyKeyIterator *Object::virtualOwnPropertyKeys(const Object *o, Value *target)
{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return getIndexed(idx, hasProperty);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- Heap::Object *o = d();
- while (o) {
- uint idx = o->internalClass->find(id);
- if (idx < UINT_MAX) {
- if (hasProperty)
- *hasProperty = true;
- return getValue(*o->propertyData(idx), o->internalClass->propertyData.at(idx));
- }
-
- o = o->prototype();
- }
-
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
+ *target = *o;
+ return new ObjectOwnPropertyKeyIterator;
}
-ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
+// Section 8.12.3
+ReturnedValue Object::internalGet(PropertyKey id, const Value *receiver, bool *hasProperty) const
{
- PropertyAttributes attrs;
- Scope scope(engine());
- ScopedObject o(scope, this);
- ScopedProperty pd(scope);
- bool exists = false;
- while (o) {
- if (o->arrayData() && o->arrayData()->getProperty(index, pd, &attrs)) {
- exists = true;
- break;
+ Heap::Object *o = d();
+
+ uint index = id.asArrayIndex();
+ if (index != UINT_MAX) {
+ Scope scope(this);
+ PropertyAttributes attrs;
+ ScopedProperty pd(scope);
+ while (1) {
+ if (o->arrayData && o->arrayData->getProperty(index, pd, &attrs)) {
+ if (hasProperty)
+ *hasProperty = true;
+ return Object::getValue(*receiver, pd->value, attrs);
+ }
+ if (o->internalClass->vtable->type == Type_StringObject) {
+ ScopedString str(scope, static_cast<Heap::StringObject *>(o)->getIndex(index));
+ if (str) {
+ attrs = (Attr_NotWritable|Attr_NotConfigurable);
+ if (hasProperty)
+ *hasProperty = true;
+ return str.asReturnedValue();
+ }
+ }
+ o = o->prototype();
+ if (!o || o->internalClass->vtable->get != Object::virtualGet)
+ break;
}
- if (o->isStringObject()) {
- ScopedString str(scope, static_cast<StringObject *>(o.getPointer())->getIndex(index));
- if (str) {
- attrs = (Attr_NotWritable|Attr_NotConfigurable);
+ } else {
+ Q_ASSERT(!id.isArrayIndex());
+
+ while (1) {
+ auto idx = o->internalClass->findValueOrGetter(id);
+ if (idx.isValid()) {
if (hasProperty)
*hasProperty = true;
- return str.asReturnedValue();
+ return Object::getValue(*receiver, *o->propertyData(idx.index), idx.attrs);
}
+ o = o->prototype();
+ if (!o || o->internalClass->vtable->get != Object::virtualGet)
+ break;
}
- o = o->prototype();
}
- if (exists) {
- if (hasProperty)
- *hasProperty = true;
- return getValue(pd->value, attrs);
+ if (o) {
+ const Value v = Value::fromHeapObject(o);
+ const Object &obj = static_cast<const Object &>(v);
+ return obj.get(id, receiver, hasProperty);
}
if (hasProperty)
@@ -610,295 +455,141 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
return Encode::undefined();
}
-
// Section 8.12.5
-bool Object::internalPut(String *name, const Value &value)
+bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver)
{
- ExecutionEngine *engine = this->engine();
- if (engine->hasException)
+ Scope scope(this);
+ if (scope.engine->hasException)
return false;
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return putIndexed(idx, value);
-
- name->makeIdentifier();
- Identifier *id = name->identifier();
-
- MemberData::Index memberIndex{nullptr, nullptr};
- uint member = internalClass()->find(id);
- PropertyAttributes attrs;
- if (member < UINT_MAX) {
- attrs = internalClass()->propertyData[member];
- memberIndex = d()->writablePropertyData(attrs.isAccessor() ? member + SetterOffset : member);
- }
-
- // clause 1
- if (!memberIndex.isNull()) {
- if (attrs.isAccessor()) {
- if (memberIndex->as<FunctionObject>())
- goto cont;
- return false;
- } else if (!attrs.isWritable())
- return false;
- else if (isArrayObject() && name->equals(engine->id_length())) {
- bool ok;
- uint l = value.asArrayLength(&ok);
- if (!ok) {
- engine->throwRangeError(value);
- return false;
+ Object *r = receiver->objectValue();
+ if (r && r->d() == d()) {
+ // receiver and this object are the same
+ if (d()->internalClass->vtable->getOwnProperty == Object::virtualGetOwnProperty) {
+ // This object standard methods in the vtable, so we can take a shortcut
+ // and avoid the calls to getOwnProperty and defineOwnProperty
+ uint index = id.asArrayIndex();
+
+ PropertyAttributes attrs;
+ PropertyIndex propertyIndex{nullptr, nullptr};
+
+ if (index != UINT_MAX) {
+ if (arrayData())
+ propertyIndex = arrayData()->getValueOrSetter(index, &attrs);
+ } else {
+ auto member = internalClass()->findValueOrSetter(id);
+ if (member.isValid()) {
+ attrs = member.attrs;
+ propertyIndex = d()->writablePropertyData(member.index);
+ }
}
- ok = setArrayLength(l);
- if (!ok)
- return false;
- } else {
- memberIndex.set(engine, value);
- }
- return true;
- } else if (!prototype()) {
- if (!isExtensible())
- return false;
- } else {
- // clause 4
- Scope scope(engine);
- memberIndex = ScopedObject(scope, prototype())->getValueOrSetter(name, &attrs);
- if (!memberIndex.isNull()) {
- if (attrs.isAccessor()) {
- if (!memberIndex->as<FunctionObject>())
+
+ if (!propertyIndex.isNull() && !attrs.isAccessor()) {
+ if (!attrs.isWritable())
return false;
- } else if (!isExtensible() || !attrs.isWritable()) {
- return false;
+ else if (isArrayObject() && id == scope.engine->id_length()->propertyKey()) {
+ bool ok;
+ uint l = value.asArrayLength(&ok);
+ if (!ok) {
+ scope.engine->throwRangeError(value);
+ return false;
+ }
+ ok = setArrayLength(l);
+ if (!ok)
+ return false;
+ } else {
+ propertyIndex.set(scope.engine, value);
+ }
+ return true;
}
- } else if (!isExtensible()) {
- return false;
}
}
- cont:
-
- // Clause 5
- if (!memberIndex.isNull() && attrs.isAccessor()) {
- Q_ASSERT(memberIndex->as<FunctionObject>());
+ ScopedProperty p(scope);
+ PropertyAttributes attrs;
+ attrs = getOwnProperty(id, p);
+ if (attrs == Attr_Invalid) {
+ ScopedObject p(scope, getPrototypeOf());
+ if (p)
+ return p->put(id, value, receiver);
+ attrs = Attr_Data;
+ }
- Scope scope(engine);
- ScopedFunctionObject setter(scope, *memberIndex);
+ if (attrs.isAccessor()) {
+ ScopedFunctionObject setter(scope, p->setter());
+ if (!setter)
+ return false;
JSCallData jsCallData(scope, 1);
jsCallData->args[0] = value;
- *jsCallData->thisObject = this;
+ *jsCallData->thisObject = *receiver;
setter->call(jsCallData);
- return !engine->hasException;
+ return !scope.engine->hasException;
}
- insertMember(name, value);
- return true;
-}
-
-bool Object::internalPutIndexed(uint index, const Value &value)
-{
- ExecutionEngine *engine = this->engine();
- if (engine->hasException)
+ // Data property
+ if (!attrs.isWritable())
return false;
+ if (!r)
+ return false;
+ attrs = r->getOwnProperty(id, p);
- PropertyAttributes attrs;
-
- ArrayData::Index arrayIndex = arrayData() ? arrayData()->getValueOrSetter(index, &attrs) : ArrayData::Index{ nullptr, 0 };
-
- if (arrayIndex.isNull() && isStringObject()) {
- if (index < static_cast<StringObject *>(this)->length())
- // not writable
- return false;
- }
-
- // clause 1
- if (!arrayIndex.isNull()) {
- if (attrs.isAccessor()) {
- if (arrayIndex->as<FunctionObject>())
- goto cont;
- return false;
- } else if (!attrs.isWritable())
- return false;
-
- arrayIndex.set(engine, value);
- return true;
- } else if (!prototype()) {
- if (!isExtensible())
+ if (attrs != Attr_Invalid) {
+ if (attrs.isAccessor() || !attrs.isWritable())
return false;
} else {
- // clause 4
- Scope scope(engine);
- arrayIndex = ScopedObject(scope, prototype())->getValueOrSetter(index, &attrs);
- if (!arrayIndex.isNull()) {
- if (attrs.isAccessor()) {
- if (!arrayIndex->as<FunctionObject>())
- return false;
- } else if (!isExtensible() || !attrs.isWritable()) {
- return false;
- }
- } else if (!isExtensible()) {
+ if (!r->isExtensible())
return false;
- }
+ attrs = Attr_Data;
}
- cont:
-
- // Clause 5
- if (!arrayIndex.isNull() && attrs.isAccessor()) {
- Q_ASSERT(arrayIndex->as<FunctionObject>());
-
- Scope scope(engine);
- ScopedFunctionObject setter(scope, *arrayIndex);
- JSCallData jsCallData(scope, 1);
- jsCallData->args[0] = value;
- *jsCallData->thisObject = this;
- setter->call(jsCallData);
- return !engine->hasException;
+ if (r->internalClass()->vtable->defineOwnProperty == virtualDefineOwnProperty) {
+ // standard object, we can avoid some more checks
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX) {
+ ScopedStringOrSymbol s(scope, id.asStringOrSymbol());
+ r->insertMember(s, value);
+ } else {
+ r->arraySet(index, value);
+ }
+ return true;
}
- arraySet(index, value);
- return true;
+ p->value = value;
+ return r->defineOwnProperty(id, p, attrs);
}
// Section 8.12.7
-bool Object::internalDeleteProperty(String *name)
+bool Object::internalDeleteProperty(PropertyKey id)
{
if (internalClass()->engine->hasException)
return false;
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return deleteIndexedProperty(idx);
-
- name->makeIdentifier();
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ Scope scope(engine());
+ if (scope.engine->hasException)
+ return false;
- uint memberIdx = internalClass()->find(name->identifier());
- if (memberIdx != UINT_MAX) {
- if (internalClass()->propertyData[memberIdx].isConfigurable()) {
- InternalClass::removeMember(this, name->identifier());
+ Scoped<ArrayData> ad(scope, arrayData());
+ if (!ad || ad->vtable()->del(this, index))
return true;
- }
- return false;
- }
-
- return true;
-}
-bool Object::internalDeleteIndexedProperty(uint index)
-{
- Scope scope(engine());
- if (scope.engine->hasException)
return false;
+ }
- Scoped<ArrayData> ad(scope, arrayData());
- if (!ad || ad->vtable()->del(this, index))
- return true;
-
- return false;
-}
-
-// Section 8.12.9
-bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const Property *p, PropertyAttributes attrs)
-{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return __defineOwnProperty__(engine, idx, p, attrs);
-
- Scope scope(engine);
- name->makeIdentifier();
-
- uint memberIndex;
-
- if (isArrayObject() && name->equals(engine->id_length())) {
- Q_ASSERT(Heap::ArrayObject::LengthPropertyIndex == internalClass()->find(engine->id_length()));
- ScopedProperty lp(scope);
- PropertyAttributes cattrs;
- getProperty(Heap::ArrayObject::LengthPropertyIndex, lp, &cattrs);
- if (attrs.isEmpty() || p->isSubset(attrs, lp, cattrs))
+ auto memberIdx = internalClass()->findValueOrGetter(id);
+ if (memberIdx.isValid()) {
+ if (memberIdx.attrs.isConfigurable()) {
+ Heap::InternalClass::removeMember(this, id);
return true;
- if (!cattrs.isWritable() || attrs.type() == PropertyAttributes::Accessor || attrs.isConfigurable() || attrs.isEnumerable())
- return false;
- bool succeeded = true;
- if (attrs.type() == PropertyAttributes::Data) {
- bool ok;
- uint l = p->value.asArrayLength(&ok);
- if (!ok) {
- ScopedValue v(scope, p->value);
- engine->throwRangeError(v);
- return false;
- }
- succeeded = setArrayLength(l);
- }
- if (attrs.hasWritable() && !attrs.isWritable()) {
- cattrs.setWritable(false);
- InternalClass::changeMember(this, engine->id_length(), cattrs);
}
- if (!succeeded)
- return false;
- return true;
- }
-
- // Clause 1
- memberIndex = internalClass()->find(name->identifier());
-
- if (memberIndex == UINT_MAX) {
- // clause 3
- if (!isExtensible())
- return false;
- // clause 4
- ScopedProperty pd(scope);
- pd->copy(p, attrs);
- pd->fullyPopulated(&attrs);
- insertMember(name, pd, attrs);
- return true;
- }
-
- return __defineOwnProperty__(engine, memberIndex, name, p, attrs);
-}
-
-bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, const Property *p, PropertyAttributes attrs)
-{
- // 15.4.5.1, 4b
- if (isArrayObject() && index >= getLength() && !internalClass()->propertyData[Heap::ArrayObject::LengthPropertyIndex].isWritable())
return false;
-
- if (ArgumentsObject::isNonStrictArgumentsObject(this))
- return static_cast<ArgumentsObject *>(this)->defineOwnProperty(engine, index, p, attrs);
-
- return defineOwnProperty2(engine, index, p, attrs);
-}
-
-bool Object::defineOwnProperty2(ExecutionEngine *engine, uint index, const Property *p, PropertyAttributes attrs)
-{
- bool hasProperty = 0;
-
- // Clause 1
- if (arrayData()) {
- hasProperty = arrayData()->mappedIndex(index) != UINT_MAX;
- if (!hasProperty && isStringObject())
- hasProperty = (index < static_cast<StringObject *>(this)->length());
}
- if (!hasProperty) {
- // clause 3
- if (!isExtensible())
- return false;
- // clause 4
- Scope scope(engine);
- ScopedProperty pp(scope);
- pp->copy(p, attrs);
- pp->fullyPopulated(&attrs);
- if (attrs == Attr_Data) {
- ScopedValue v(scope, pp->value);
- arraySet(index, v);
- } else {
- arraySet(index, pp, attrs);
- }
- return true;
- }
-
- return __defineOwnProperty__(engine, index, nullptr, p, attrs);
+ return true;
}
-bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *member, const Property *p, PropertyAttributes attrs)
+bool Object::internalDefineOwnProperty(ExecutionEngine *engine, uint index, const InternalClassEntry *memberEntry, const Property *p, PropertyAttributes attrs)
{
// clause 5
if (attrs.isEmpty())
@@ -907,9 +598,9 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *
Scope scope(engine);
ScopedProperty current(scope);
PropertyAttributes cattrs;
- if (member) {
- getProperty(index, current, &cattrs);
- cattrs = internalClass()->propertyData[index];
+ if (memberEntry) {
+ getProperty(*memberEntry, current);
+ cattrs = memberEntry->attributes;
} else if (arrayData()) {
arrayData()->getProperty(index, current, &cattrs);
cattrs = arrayData()->attributes(index);
@@ -940,7 +631,7 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *
// 9b
cattrs.setType(PropertyAttributes::Accessor);
cattrs.clearWritable();
- if (!member) {
+ if (!memberEntry) {
// need to convert the array and the slot
initSparseArray();
Q_ASSERT(arrayData());
@@ -952,11 +643,11 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *
// 9c
cattrs.setType(PropertyAttributes::Data);
cattrs.setWritable(false);
- if (!member) {
+ if (!memberEntry) {
// need to convert the array and the slot
setArrayAttributes(index, cattrs);
}
- current->value = Primitive::undefinedValue();
+ current->value = Value::undefinedValue();
}
} else if (cattrs.isData() && attrs.isData()) { // clause 10
if (!cattrs.isConfigurable() && !cattrs.isWritable()) {
@@ -976,9 +667,11 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *
accept:
current->merge(cattrs, p, attrs);
- if (member) {
- InternalClass::changeMember(this, member, cattrs);
- setProperty(index, current);
+ if (memberEntry) {
+ PropertyKey key = internalClass()->nameMap.at(memberEntry->index);
+ InternalClassEntry e;
+ Heap::InternalClass::changeMember(this, key, cattrs, &e);
+ setProperty(e, current);
} else {
setArrayAttributes(index, cattrs);
arrayData()->setProperty(scope.engine, index, current);
@@ -986,15 +679,6 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *
return true;
}
-
-bool Object::__defineOwnProperty__(ExecutionEngine *engine, const QString &name, const Property *p, PropertyAttributes attrs)
-{
- Scope scope(engine);
- ScopedString s(scope, engine->newString(name));
- return __defineOwnProperty__(engine, s, p, attrs);
-}
-
-
void Object::copyArrayData(Object *other)
{
Q_ASSERT(isArrayObject());
@@ -1007,7 +691,7 @@ void Object::copyArrayData(Object *other)
ScopedValue v(scope);
for (uint i = 0; i < len; ++i) {
- arraySet(i, (v = other->getIndexed(i)));
+ arraySet(i, (v = other->get(i)));
}
} else if (!other->arrayData()) {
;
@@ -1030,15 +714,15 @@ void Object::copyArrayData(Object *other)
setArrayLengthUnchecked(other->getLength());
}
-uint Object::getLength(const Managed *m)
+qint64 Object::virtualGetLength(const Managed *m)
{
Scope scope(static_cast<const Object *>(m)->engine());
ScopedValue v(scope, static_cast<Object *>(const_cast<Managed *>(m))->get(scope.engine->id_length()));
- return v->toUInt32();
+ return v->toLength();
}
// 'var' is 'V' in 15.3.5.3.
-ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var)
+ReturnedValue Object::virtualInstanceOf(const Object *typeObject, const Value &var)
{
QV4::ExecutionEngine *engine = typeObject->internalClass()->engine;
@@ -1047,9 +731,16 @@ ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var)
if (!function)
return engine->throwTypeError();
- Heap::FunctionObject *f = function->d();
- if (function->isBoundFunction())
- f = function->cast<BoundFunction>()->target();
+ return checkedInstanceOf(engine, function, var);
+}
+
+ReturnedValue Object::checkedInstanceOf(ExecutionEngine *engine, const FunctionObject *f, const Value &var)
+{
+ Scope scope(engine);
+ if (f->isBoundFunction()) {
+ ScopedValue v(scope, static_cast<const BoundFunction *>(f)->target());
+ f = v->as<FunctionObject>();
+ }
// 15.3.5.3, 1: HasInstance can only be used on an object
const Object *lhs = var.as<Object>();
@@ -1057,9 +748,10 @@ ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var)
return Encode(false);
// 15.3.5.3, 2
- const Object *o = f->protoProperty();
+ Value p = Value::fromReturnedValue(f->protoProperty());
+ const Object *o = p.objectValue();
if (!o) // 15.3.5.3, 3
- return engine->throwTypeError();
+ return f->engine()->throwTypeError();
Heap::Object *v = lhs->d();
@@ -1080,6 +772,142 @@ ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var)
return Encode(false);
}
+bool Object::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ Scope scope(m->engine());
+ ScopedObject o(scope, m);
+ ScopedProperty p(scope);
+
+ if (o->getOwnProperty(id, p) != Attr_Invalid)
+ return true;
+
+ o = o->getPrototypeOf();
+ if (o)
+ return o->hasProperty(id);
+
+ return false;
+}
+
+PropertyAttributes Object::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
+{
+ PropertyAttributes attrs;
+ const Object *o = static_cast<const Object *>(m);
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ if (o->arrayData()) {
+ if (o->arrayData()->getProperty(index, p, &attrs))
+ return attrs;
+ }
+ } else {
+ Q_ASSERT(id.asStringOrSymbol());
+
+ auto member = o->internalClass()->find(id);
+ if (member.isValid()) {
+ attrs = member.attributes;
+ if (p) {
+ p->value = *o->propertyData(member.index);
+ if (attrs.isAccessor())
+ p->set = *o->propertyData(member.setterIndex);
+ }
+ return attrs;
+ }
+ }
+
+ return Attr_Invalid;
+}
+
+bool Object::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
+{
+ Object *o = static_cast<Object *>(m);
+ Scope scope(o);
+
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+
+ bool hasProperty = false;
+
+ if (o->arrayData()) {
+ hasProperty = o->arrayData()->mappedIndex(index) != UINT_MAX;
+ if (!hasProperty && o->isStringObject())
+ hasProperty = (index < static_cast<StringObject *>(o)->length());
+ }
+
+ if (!hasProperty) {
+ if (!o->isExtensible())
+ return false;
+
+ ScopedProperty pp(scope);
+ pp->copy(p, attrs);
+ pp->fullyPopulated(&attrs);
+ if (attrs == Attr_Data) {
+ ScopedValue v(scope, pp->value);
+ o->arraySet(index, v);
+ } else {
+ o->arraySet(index, pp, attrs);
+ }
+ return true;
+ }
+
+ return o->internalDefineOwnProperty(scope.engine, index, nullptr, p, attrs);
+ }
+
+ auto memberIndex = o->internalClass()->find(id);
+
+ if (!memberIndex.isValid()) {
+ if (!o->isExtensible())
+ return false;
+
+ Scoped<StringOrSymbol> name(scope, id.asStringOrSymbol());
+ ScopedProperty pd(scope);
+ pd->copy(p, attrs);
+ pd->fullyPopulated(&attrs);
+ o->insertMember(name, pd, attrs);
+ return true;
+ }
+
+ return o->internalDefineOwnProperty(scope.engine, UINT_MAX, &memberIndex, p, attrs);
+}
+
+bool Object::virtualIsExtensible(const Managed *m)
+{
+ return m->d()->internalClass->extensible;
+}
+
+bool Object::virtualPreventExtensions(Managed *m)
+{
+ Q_ASSERT(m->isObject());
+ Object *o = static_cast<Object *>(m);
+ o->setInternalClass(o->internalClass()->nonExtensible());
+ return true;
+}
+
+Heap::Object *Object::virtualGetPrototypeOf(const Managed *m)
+{
+ return m->internalClass()->prototype;
+}
+
+bool Object::virtualSetPrototypeOf(Managed *m, const Object *proto)
+{
+ Q_ASSERT(m->isObject());
+ Object *o = static_cast<Object *>(m);
+ Heap::Object *current = o->internalClass()->prototype;
+ Heap::Object *protod = proto ? proto->d() : nullptr;
+ if (current == protod)
+ return true;
+ if (!o->internalClass()->extensible)
+ return false;
+ Heap::Object *p = protod;
+ while (p) {
+ if (p == o->d())
+ return false;
+ if (p->vtable()->getPrototypeOf != Object::staticVTable()->getPrototypeOf)
+ break;
+ p = p->prototype();
+ }
+ o->setInternalClass(o->internalClass()->changePrototype(protod));
+ return true;
+}
+
bool Object::setArrayLength(uint newLen)
{
Q_ASSERT(isArrayObject());
@@ -1110,6 +938,54 @@ void Object::initSparseArray()
ArrayData::realloc(this, Heap::ArrayData::Sparse, 0, false);
}
+bool Object::isConcatSpreadable() const
+{
+ Scope scope(this);
+ ScopedValue spreadable(scope, get(scope.engine->symbol_isConcatSpreadable()));
+ if (!spreadable->isUndefined())
+ return spreadable->toBoolean();
+ return isArray();
+}
+
+bool Object::isArray() const
+{
+ if (isArrayObject())
+ return true;
+ if (vtable() == ProxyObject::staticVTable()) {
+ const ProxyObject *p = static_cast<const ProxyObject *>(this);
+ Scope scope(this);
+ if (!p->d()->handler) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ ScopedObject o(scope, p->d()->target);
+ return o->isArray();
+ }
+ return false;
+}
+
+const FunctionObject *Object::speciesConstructor(Scope &scope, const FunctionObject *defaultConstructor) const
+{
+ ScopedValue C(scope, get(scope.engine->id_constructor()));
+ if (C->isUndefined())
+ return defaultConstructor;
+ const Object *c = C->objectValue();
+ if (!c) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ ScopedValue S(scope, c->get(scope.engine->symbol_species()));
+ if (S->isNullOrUndefined())
+ return defaultConstructor;
+ const FunctionObject *f = S->as<FunctionObject>();
+ if (!f || !f->isConstructor()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ Q_ASSERT(f->isFunctionObject());
+ return static_cast<const FunctionObject *>(f);
+}
+
DEFINE_OBJECT_VTABLE(ArrayObject);
@@ -1132,12 +1008,10 @@ void Heap::ArrayObject::init(const QStringList &list)
a->setArrayLengthUnchecked(len);
}
-uint ArrayObject::getLength(const Managed *m)
+qint64 ArrayObject::virtualGetLength(const Managed *m)
{
const ArrayObject *a = static_cast<const ArrayObject *>(m);
- if (a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->isInteger())
- return a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->integerValue();
- return Primitive::toUInt32(a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->doubleValue());
+ return a->propertyData(Heap::ArrayObject::LengthPropertyIndex)->toLength();
}
QStringList ArrayObject::toQStringList() const
@@ -1150,8 +1024,62 @@ QStringList ArrayObject::toQStringList() const
uint length = getLength();
for (uint i = 0; i < length; ++i) {
- v = const_cast<ArrayObject *>(this)->getIndexed(i);
+ v = const_cast<ArrayObject *>(this)->get(i);
result.append(v->toQStringNoThrow());
}
return result;
}
+
+bool ArrayObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
+{
+ Q_ASSERT(m->isArrayObject());
+ ArrayObject *a = static_cast<ArrayObject *>(m);
+
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ uint len = a->getLength();
+ if (index >= len && !a->internalClass()->propertyData[Heap::ArrayObject::LengthPropertyIndex].isWritable())
+ return false;
+
+ bool succeeded = Object::virtualDefineOwnProperty(m, id, p, attrs);
+ if (!succeeded)
+ return false;
+
+ if (index >= len)
+ a->setArrayLengthUnchecked(index + 1);
+
+ return true;
+ }
+
+ ExecutionEngine *engine = m->engine();
+ if (id == engine->id_length()->propertyKey()) {
+ Scope scope(engine);
+ Q_ASSERT(a->internalClass()->verifyIndex(engine->id_length()->propertyKey(), Heap::ArrayObject::LengthPropertyIndex));
+ ScopedProperty lp(scope);
+ InternalClassEntry e = a->internalClass()->find(scope.engine->id_length()->propertyKey());
+ a->getProperty(e, lp);
+ if (attrs.isEmpty() || p->isSubset(attrs, lp, e.attributes))
+ return true;
+ if (!e.attributes.isWritable() || attrs.type() == PropertyAttributes::Accessor || attrs.isConfigurable() || attrs.isEnumerable())
+ return false;
+ bool succeeded = true;
+ if (attrs.type() == PropertyAttributes::Data) {
+ bool ok;
+ uint l = p->value.asArrayLength(&ok);
+ if (!ok) {
+ ScopedValue v(scope, p->value);
+ engine->throwRangeError(v);
+ return false;
+ }
+ succeeded = a->setArrayLength(l);
+ }
+ if (attrs.hasWritable() && !attrs.isWritable()) {
+ e.attributes.setWritable(false);
+ Heap::InternalClass::changeMember(a, engine->id_length()->propertyKey(), e.attributes);
+ }
+ if (!succeeded)
+ return false;
+ return true;
+ }
+ return Object::virtualDefineOwnProperty(m, id, p, attrs);
+}
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 1731ae3c76..6753ebfcd4 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -74,6 +74,10 @@ DECLARE_EXPORTED_HEAP_OBJECT(Object, Base) {
static void markObjects(Heap::Base *base, MarkStack *stack);
void init() { Base::init(); }
+ const VTable *vtable() const {
+ return internalClass->vtable;
+ }
+
const Value *inlinePropertyDataWithOffset(uint indexWithOffset) const {
Q_ASSERT(indexWithOffset >= vtable()->inlinePropertyOffset && indexWithOffset < vtable()->inlinePropertyOffset + vtable()->nInlineProperties);
return reinterpret_cast<const Value *>(this) + indexWithOffset;
@@ -90,15 +94,15 @@ DECLARE_EXPORTED_HEAP_OBJECT(Object, Base) {
void setInlineProperty(ExecutionEngine *e, uint index, Heap::Base *b) {
Q_ASSERT(index < vtable()->nInlineProperties);
Value *prop = reinterpret_cast<Value *>(this) + vtable()->inlinePropertyOffset + index;
- WriteBarrier::write(e, this, prop->data_ptr(), b->asReturnedValue());
+ WriteBarrier::write(e, this, prop->data_ptr(), Value::fromHeapObject(b).asReturnedValue());
}
- QV4::MemberData::Index writablePropertyData(uint index) {
+ PropertyIndex writablePropertyData(uint index) {
uint nInline = vtable()->nInlineProperties;
if (index < nInline)
- return { this, reinterpret_cast<Value *>(this) + vtable()->inlinePropertyOffset + index};
+ return PropertyIndex{ this, reinterpret_cast<Value *>(this) + vtable()->inlinePropertyOffset + index};
index -= nInline;
- return { memberData, memberData->values.values + index };
+ return PropertyIndex{ memberData, memberData->values.values + index };
}
const Value *propertyData(uint index) const {
@@ -134,76 +138,6 @@ DECLARE_EXPORTED_HEAP_OBJECT(Object, Base) {
}
-#define V4_OBJECT2(DataClass, superClass) \
- private: \
- DataClass() Q_DECL_EQ_DELETE; \
- Q_DISABLE_COPY(DataClass) \
- public: \
- Q_MANAGED_CHECK \
- typedef QV4::Heap::DataClass Data; \
- typedef superClass SuperClass; \
- static const QV4::ObjectVTable static_vtbl; \
- static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \
- V4_MANAGED_SIZE_TEST \
- QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
- QV4::Heap::DataClass *d() const { \
- QV4::Heap::DataClass *dptr = d_unchecked(); \
- dptr->_checkIsInitialized(); \
- return dptr; \
- } \
- Q_STATIC_ASSERT(std::is_trivial< QV4::Heap::DataClass >::value);
-
-#define V4_PROTOTYPE(p) \
- static QV4::Object *defaultPrototype(QV4::ExecutionEngine *e) \
- { return e->p(); }
-
-struct ObjectVTable
-{
- VTable vTable;
- ReturnedValue (*call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- ReturnedValue (*callAsConstructor)(const FunctionObject *, const Value *argv, int argc);
- ReturnedValue (*get)(const Managed *, String *name, bool *hasProperty);
- ReturnedValue (*getIndexed)(const Managed *, uint index, bool *hasProperty);
- bool (*put)(Managed *, String *name, const Value &value);
- bool (*putIndexed)(Managed *, uint index, const Value &value);
- PropertyAttributes (*query)(const Managed *, String *name);
- PropertyAttributes (*queryIndexed)(const Managed *, uint index);
- bool (*deleteProperty)(Managed *m, String *name);
- bool (*deleteIndexedProperty)(Managed *m, uint index);
- uint (*getLength)(const Managed *m);
- void (*advanceIterator)(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
- ReturnedValue (*instanceOf)(const Object *typeObject, const Value &var);
-};
-
-#define DEFINE_OBJECT_VTABLE_BASE(classname) \
-const QV4::ObjectVTable classname::static_vtbl = \
-{ \
- DEFINE_MANAGED_VTABLE_INT(classname, (std::is_same<classname::SuperClass, Object>::value) ? nullptr : &classname::SuperClass::static_vtbl.vTable), \
- call, \
- callAsConstructor, \
- get, \
- getIndexed, \
- put, \
- putIndexed, \
- query, \
- queryIndexed, \
- deleteProperty, \
- deleteIndexedProperty, \
- getLength, \
- advanceIterator, \
- instanceOf \
-}
-
-#define DEFINE_OBJECT_VTABLE(classname) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
-DEFINE_OBJECT_VTABLE_BASE(classname) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
-
-#define DEFINE_OBJECT_TEMPLATE_VTABLE(classname) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
-template<> DEFINE_OBJECT_VTABLE_BASE(classname) \
-QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
-
struct Q_QML_EXPORT Object: Managed {
V4_OBJECT2(Object, Object)
Q_MANAGED_TYPE(Object)
@@ -218,82 +152,92 @@ struct Q_QML_EXPORT Object: Managed {
SetterOffset = 1
};
- void setInternalClass(InternalClass *ic);
+ void setInternalClass(Heap::InternalClass *ic);
const Value *propertyData(uint index) const { return d()->propertyData(index); }
Heap::ArrayData *arrayData() const { return d()->arrayData; }
void setArrayData(ArrayData *a) { d()->arrayData.set(engine(), a->d()); }
- void getProperty(uint index, Property *p, PropertyAttributes *attrs) const;
- void setProperty(uint index, const Property *p);
+ void getProperty(const InternalClassEntry &entry, Property *p) const;
+ void setProperty(const InternalClassEntry &entry, const Property *p);
void setProperty(uint index, Value v) const { d()->setProperty(engine(), index, v); }
void setProperty(uint index, Heap::Base *b) const { d()->setProperty(engine(), index, b); }
void setProperty(ExecutionEngine *engine, uint index, Value v) const { d()->setProperty(engine, index, v); }
void setProperty(ExecutionEngine *engine, uint index, Heap::Base *b) const { d()->setProperty(engine, index, b); }
- const ObjectVTable *vtable() const { return reinterpret_cast<const ObjectVTable *>(d()->vtable()); }
- Heap::Object *prototype() const { return d()->prototype(); }
- bool setPrototype(Object *proto);
-
- void getOwnProperty(String *name, PropertyAttributes *attrs, Property *p = nullptr);
- void getOwnProperty(uint index, PropertyAttributes *attrs, Property *p = nullptr);
+ const VTable *vtable() const { return d()->vtable(); }
- MemberData::Index getValueOrSetter(String *name, PropertyAttributes *attrs);
- ArrayData::Index getValueOrSetter(uint index, PropertyAttributes *attrs);
+ PropertyAttributes getOwnProperty(PropertyKey id, Property *p = nullptr) const {
+ return vtable()->getOwnProperty(this, id, p);
+ }
- bool hasProperty(String *name) const;
- bool hasProperty(uint index) const;
+ PropertyIndex getValueOrSetter(PropertyKey id, PropertyAttributes *attrs);
- bool hasOwnProperty(String *name) const;
- bool hasOwnProperty(uint index) const;
+ bool hasProperty(PropertyKey id) const {
+ return vtable()->hasProperty(this, id);
+ }
- bool __defineOwnProperty__(ExecutionEngine *engine, uint index, String *member, const Property *p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionEngine *engine, String *name, const Property *p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionEngine *engine, uint index, const Property *p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionEngine *engine, const QString &name, const Property *p, PropertyAttributes attrs);
- bool defineOwnProperty2(ExecutionEngine *engine, uint index, const Property *p, PropertyAttributes attrs);
+ bool defineOwnProperty(PropertyKey id, const Property *p, PropertyAttributes attrs) {
+ return vtable()->defineOwnProperty(this, id, p, attrs);
+ }
//
// helpers
//
- static ReturnedValue getValue(const Value &thisObject, const Value &v, PropertyAttributes attrs);
+ static ReturnedValue getValue(const Value &thisObject, const Value &v, PropertyAttributes attrs) {
+ if (attrs.isData())
+ return v.asReturnedValue();
+ return getValueAccessor(thisObject, v, attrs);
+ }
ReturnedValue getValue(const Value &v, PropertyAttributes attrs) const {
- Scope scope(this->engine());
- ScopedValue t(scope, const_cast<Object *>(this));
- return getValue(t, v, attrs);
+ return getValue(*this, v, attrs);
+ }
+ ReturnedValue getValueByIndex(uint propertyIndex) const {
+ PropertyAttributes attrs = internalClass()->propertyData.at(propertyIndex);
+ const Value *v = propertyData(propertyIndex);
+ if (!attrs.isAccessor())
+ return v->asReturnedValue();
+ return getValueAccessor(*this, *v, attrs);
}
+ static ReturnedValue getValueAccessor(const Value &thisObject, const Value &v, PropertyAttributes attrs);
- bool putValue(uint memberIndex, const Value &value);
+ bool putValue(uint memberIndex, PropertyAttributes attrs, const Value &value);
/* The spec default: Writable: true, Enumerable: false, Configurable: true */
- void defineDefaultProperty(String *name, const Value &value) {
- insertMember(name, value, Attr_Data|Attr_NotEnumerable);
- }
- void defineDefaultProperty(const QString &name, const Value &value);
- void defineDefaultProperty(const QString &name, ReturnedValue (*code)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc), int argumentCount = 0);
- void defineDefaultProperty(String *name, ReturnedValue (*code)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc), int argumentCount = 0);
- void defineAccessorProperty(const QString &name, ReturnedValue (*getter)(const FunctionObject *, const Value *, const Value *, int),
- ReturnedValue (*setter)(const FunctionObject *, const Value *, const Value *, int));
- void defineAccessorProperty(String *name, ReturnedValue (*getter)(const FunctionObject *, const Value *, const Value *, int),
- ReturnedValue (*setter)(const FunctionObject *, const Value *, const Value *, int));
+ void defineDefaultProperty(StringOrSymbol *name, const Value &value, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable) {
+ insertMember(name, value, attributes);
+ }
+ void defineDefaultProperty(const QString &name, const Value &value, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable);
+ void defineDefaultProperty(const QString &name, VTable::Call code,
+ int argumentCount = 0, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable);
+ void defineDefaultProperty(StringOrSymbol *name, VTable::Call code,
+ int argumentCount = 0, PropertyAttributes attributes = Attr_Data|Attr_NotEnumerable);
+ void defineAccessorProperty(const QString &name, VTable::Call getter, VTable::Call setter);
+ void defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, VTable::Call setter);
/* Fixed: Writable: false, Enumerable: false, Configurable: false */
void defineReadonlyProperty(const QString &name, const Value &value);
void defineReadonlyProperty(String *name, const Value &value);
/* Fixed: Writable: false, Enumerable: false, Configurable: true */
void defineReadonlyConfigurableProperty(const QString &name, const Value &value);
- void defineReadonlyConfigurableProperty(String *name, const Value &value);
+ void defineReadonlyConfigurableProperty(StringOrSymbol *name, const Value &value);
+
+ void addSymbolSpecies();
- void insertMember(String *s, const Value &v, PropertyAttributes attributes = Attr_Data) {
+ void insertMember(StringOrSymbol *s, const Value &v, PropertyAttributes attributes = Attr_Data) {
Scope scope(engine());
ScopedProperty p(scope);
p->value = v;
insertMember(s, p, attributes);
}
- void insertMember(String *s, const Property *p, PropertyAttributes attributes);
+ void insertMember(StringOrSymbol *s, const Property *p, PropertyAttributes attributes);
- bool isExtensible() const { return d()->internalClass->extensible; }
+ bool isExtensible() const { return vtable()->isExtensible(this); }
+ bool preventExtensions() { return vtable()->preventExtensions(this); }
+ Heap::Object *getPrototypeOf() const { return vtable()->getPrototypeOf(this); }
+ bool setPrototypeOf(const Object *p) { return vtable()->setPrototypeOf(this, p); }
+ void setPrototypeUnchecked(const Object *p);
// Array handling
@@ -346,40 +290,65 @@ public:
}
void initSparseArray();
- SparseArrayNode *sparseBegin() { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->begin() : nullptr; }
- SparseArrayNode *sparseEnd() { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->end() : nullptr; }
+ SparseArrayNode *sparseBegin() const { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->begin() : nullptr; }
+ SparseArrayNode *sparseEnd() const { return arrayType() == Heap::ArrayData::Sparse ? d()->arrayData->sparse->end() : nullptr; }
inline bool protoHasArray() {
Scope scope(engine());
ScopedObject p(scope, this);
- while ((p = p->prototype()))
+ while ((p = p->getPrototypeOf()))
if (p->arrayData())
return true;
return false;
}
- inline ReturnedValue get(String *name, bool *hasProperty = nullptr) const
- { return vtable()->get(this, name, hasProperty); }
- inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
- { return vtable()->getIndexed(this, idx, hasProperty); }
+ inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, name->toPropertyKey(), receiver, hasProperty); }
+ inline ReturnedValue get(uint idx, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, PropertyKey::fromArrayIndex(idx), receiver, hasProperty); }
+ QT_DEPRECATED inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
+ { return get(idx, hasProperty); }
+ inline ReturnedValue get(PropertyKey id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, id, receiver, hasProperty); }
// use the set variants instead, to customize throw behavior
- inline bool put(String *name, const Value &v)
- { return vtable()->put(this, name, v); }
- inline bool putIndexed(uint idx, const Value &v)
- { return vtable()->putIndexed(this, idx, v); }
+ inline bool put(StringOrSymbol *name, const Value &v, Value *receiver = nullptr)
+ { if (!receiver) receiver = this; return vtable()->put(this, name->toPropertyKey(), v, receiver); }
+ inline bool put(uint idx, const Value &v, Value *receiver = nullptr)
+ { if (!receiver) receiver = this; return vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, receiver); }
+ QT_DEPRECATED inline bool putIndexed(uint idx, const Value &v)
+ { return put(idx, v); }
+ inline bool put(PropertyKey id, const Value &v, Value *receiver = nullptr)
+ { if (!receiver) receiver = this; return vtable()->put(this, id, v, receiver); }
enum ThrowOnFailure {
DoThrowOnRejection,
DoNotThrow
};
+ // This is the same as set(), but it doesn't require creating a string key,
+ // which is much more efficient for the array case.
+ inline bool setIndexed(uint idx, const Value &v, ThrowOnFailure shouldThrow)
+ {
+ bool ret = vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, this);
+ // ES6: 7.3.3, 6: If success is false and Throw is true, throw a TypeError exception.
+ if (!ret && shouldThrow == ThrowOnFailure::DoThrowOnRejection) {
+ ExecutionEngine *e = engine();
+ if (!e->hasException) { // allow a custom set impl to throw itself
+ QString message = QLatin1String("Cannot assign to read-only property \"") +
+ QString::number(idx) + QLatin1Char('\"');
+ e->throwTypeError(message);
+ }
+ }
+ return ret;
+ }
+
// ES6: 7.3.3 Set (O, P, V, Throw)
- inline bool set(String *name, const Value &v, ThrowOnFailure shouldThrow)
+ inline bool set(StringOrSymbol *name, const Value &v, ThrowOnFailure shouldThrow)
{
- bool ret = vtable()->put(this, name, v);
+ bool ret = vtable()->put(this, name->toPropertyKey(), v, this);
// ES6: 7.3.3, 6: If success is false and Throw is true, throw a TypeError exception.
if (!ret && shouldThrow == ThrowOnFailure::DoThrowOnRejection) {
ExecutionEngine *e = engine();
@@ -392,47 +361,57 @@ public:
return ret;
}
- PropertyAttributes query(String *name) const
- { return vtable()->query(this, name); }
- PropertyAttributes queryIndexed(uint index) const
- { return vtable()->queryIndexed(this, index); }
- bool deleteProperty(String *name)
- { return vtable()->deleteProperty(this, name); }
- bool deleteIndexedProperty(uint index)
- { return vtable()->deleteIndexedProperty(this, index); }
- void advanceIterator(ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
- { vtable()->advanceIterator(this, it, name, index, p, attributes); }
- uint getLength() const { return vtable()->getLength(this); }
+ bool deleteProperty(PropertyKey id)
+ { return vtable()->deleteProperty(this, id); }
+ OwnPropertyKeyIterator *ownPropertyKeys(Value *target) const
+ { return vtable()->ownPropertyKeys(this, target); }
+ qint64 getLength() const { return vtable()->getLength(this); }
ReturnedValue instanceOf(const Value &var) const
{ return vtable()->instanceOf(this, var); }
+ bool isConcatSpreadable() const;
+ bool isArray() const;
+ const FunctionObject *speciesConstructor(Scope &scope, const FunctionObject *defaultConstructor) const;
+
protected:
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
- static bool putIndexed(Managed *m, uint index, const Value &value);
- static PropertyAttributes query(const Managed *m, String *name);
- static PropertyAttributes queryIndexed(const Managed *m, uint index);
- static bool deleteProperty(Managed *m, String *name);
- static bool deleteIndexedProperty(Managed *m, uint index);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
- static uint getLength(const Managed *m);
- static ReturnedValue instanceOf(const Object *typeObject, const Value &var);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver,bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static bool virtualDeleteProperty(Managed *m, PropertyKey id);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs);
+ static bool virtualIsExtensible(const Managed *m);
+ static bool virtualPreventExtensions(Managed *);
+ static Heap::Object *virtualGetPrototypeOf(const Managed *);
+ static bool virtualSetPrototypeOf(Managed *, const Object *);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
+ static qint64 virtualGetLength(const Managed *m);
+ static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var);
+public:
+ // qv4runtime uses this directly
+ static ReturnedValue checkedInstanceOf(ExecutionEngine *engine, const FunctionObject *typeObject, const Value &var);
private:
- ReturnedValue internalGet(String *name, bool *hasProperty) const;
- ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const;
- bool internalPut(String *name, const Value &value);
- bool internalPutIndexed(uint index, const Value &value);
- bool internalDeleteProperty(String *name);
- bool internalDeleteIndexedProperty(uint index);
+ bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, const InternalClassEntry *memberEntry, const Property *p, PropertyAttributes attrs);
+ ReturnedValue internalGet(PropertyKey id, const Value *receiver, bool *hasProperty) const;
+ bool internalPut(PropertyKey id, const Value &value, Value *receiver);
+ bool internalDeleteProperty(PropertyKey id);
friend struct ObjectIterator;
friend struct ObjectPrototype;
};
+struct ObjectOwnPropertyKeyIterator : OwnPropertyKeyIterator
+{
+ uint arrayIndex = 0;
+ uint memberIndex = 0;
+ bool iterateOverSymbols = false;
+ SparseArrayNode *arrayNode = nullptr;
+ ~ObjectOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
namespace Heap {
struct BooleanObject : Object {
@@ -469,7 +448,7 @@ struct ArrayObject : Object {
private:
void commonInit()
- { setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(0)); }
+ { setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(0)); }
};
}
@@ -499,16 +478,18 @@ struct ArrayObject: Object {
void init(ExecutionEngine *engine);
- using Object::getLength;
- static uint getLength(const Managed *m);
+ static qint64 virtualGetLength(const Managed *m);
QStringList toQStringList() const;
+protected:
+ static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs);
+
};
inline void Object::setArrayLengthUnchecked(uint l)
{
if (isArrayObject())
- setProperty(Heap::ArrayObject::LengthPropertyIndex, Primitive::fromUInt32(l));
+ setProperty(Heap::ArrayObject::LengthPropertyIndex, Value::fromUInt32(l));
}
inline void Object::push_back(const Value &v)
@@ -551,7 +532,7 @@ inline void Object::arraySet(uint index, const Value &value)
template<>
inline const ArrayObject *Value::as() const {
- return isManaged() && m()->vtable()->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : nullptr;
+ return isManaged() && m()->internalClass->vtable->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : nullptr;
}
#ifndef V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index 7bf7e1aa04..e529b8e86b 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -42,145 +42,170 @@
#include "qv4identifier_p.h"
#include "qv4argumentsobject_p.h"
#include "qv4string_p.h"
+#include "qv4iterator_p.h"
+#include "qv4propertykey_p.h"
using namespace QV4;
-void ObjectIterator::init(const Object *o)
+void ForInIteratorPrototype::init(ExecutionEngine *)
{
- object->setM(o ? o->m() : nullptr);
- current->setM(o ? o->m() : nullptr);
-
- if (object->as<ArgumentsObject>()) {
- Scope scope(engine);
- Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate();
- }
+ defineDefaultProperty(QStringLiteral("next"), method_next, 0);
}
-void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttributes *attrs)
+PropertyKey ObjectIterator::next(Property *pd, PropertyAttributes *attrs)
{
- name->setM(nullptr);
- *index = UINT_MAX;
+ if (!object || !iterator)
+ return PropertyKey::invalid();
- if (!object->as<Object>()) {
- *attrs = PropertyAttributes();
- return;
- }
Scope scope(engine);
- ScopedObject o(scope);
- ScopedString n(scope);
+ ScopedPropertyKey key(scope);
while (1) {
- Object *co = current->objectValue();
- if (!co)
- break;
-
- while (1) {
- co->advanceIterator(this, name, index, pd, attrs);
- if (attrs->isEmpty())
- break;
- // check the property is not already defined earlier in the proto chain
- if (co->heapObject() != object->heapObject()) {
- o = object->as<Object>();
- n = *name;
- bool shadowed = false;
- while (o->d() != current->heapObject()) {
- if ((!!n && o->hasOwnProperty(n)) ||
- (*index != UINT_MAX && o->hasOwnProperty(*index))) {
- shadowed = true;
- break;
- }
- o = o->prototype();
- }
- if (shadowed)
- continue;
- }
- return;
+ key = iterator->next(object, pd, attrs);
+ if (!key->isValid()) {
+ object = nullptr;
+ return key;
}
-
- if (flags & WithProtoChain)
- current->setM(co->prototype());
- else
- current->setM(nullptr);
-
- arrayIndex = 0;
- memberIndex = 0;
+ if ((!(flags & WithSymbols) && key->isSymbol()) ||
+ ((flags & EnumerableOnly) && !attrs->isEnumerable()))
+ continue;
+ return key;
}
- *attrs = PropertyAttributes();
}
ReturnedValue ObjectIterator::nextPropertyName(Value *value)
{
- Object *o = object->objectValue();
- if (!o)
+ if (!object)
return Encode::null();
PropertyAttributes attrs;
- uint index;
Scope scope(engine);
ScopedProperty p(scope);
- ScopedString name(scope);
- next(name.getRef(), &index, p, &attrs);
- if (attrs.isEmpty())
+ ScopedPropertyKey key(scope, next(p, &attrs));
+ if (!key->isValid())
return Encode::null();
- *value = o->getValue(p->value, attrs);
-
- if (!!name)
- return name->asReturnedValue();
- Q_ASSERT(index < UINT_MAX);
- return Encode(index);
+ *value = object->getValue(p->value, attrs);
+ if (key->isArrayIndex())
+ return Encode(key->asArrayIndex());
+ Q_ASSERT(key->isStringOrSymbol());
+ return key->asStringOrSymbol()->asReturnedValue();
}
ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
{
- Object *o = object->objectValue();
- if (!o)
+ if (!object)
return Encode::null();
PropertyAttributes attrs;
- uint index;
Scope scope(engine);
ScopedProperty p(scope);
- ScopedString name(scope);
- next(name.getRef(), &index, p, &attrs);
- if (attrs.isEmpty())
+ ScopedPropertyKey key(scope, next(p, &attrs));
+ if (!key->isValid())
return Encode::null();
- *value = o->getValue(p->value, attrs);
+ *value = object->getValue(p->value, attrs);
- if (!!name)
- return name->asReturnedValue();
- Q_ASSERT(index < UINT_MAX);
- return Encode(engine->newString(QString::number(index)));
+ return key->toStringOrSymbol(engine)->asReturnedValue();
}
ReturnedValue ObjectIterator::nextPropertyNameAsString()
{
- if (!object->as<Object>())
+ if (!object)
return Encode::null();
PropertyAttributes attrs;
- uint index;
Scope scope(engine);
- ScopedProperty p(scope);
- ScopedString name(scope);
- next(name.getRef(), &index, p, &attrs);
- if (attrs.isEmpty())
+ ScopedPropertyKey key(scope, next(nullptr, &attrs));
+ if (!key->isValid())
return Encode::null();
- if (!!name)
- return name->asReturnedValue();
- Q_ASSERT(index < UINT_MAX);
- return Encode(engine->newString(QString::number(index)));
+ return key->toStringOrSymbol(engine)->asReturnedValue();
}
-DEFINE_OBJECT_VTABLE(ForEachIteratorObject);
+DEFINE_OBJECT_VTABLE(ForInIteratorObject);
-void Heap::ForEachIteratorObject::markObjects(Heap::Base *that, MarkStack *markStack)
+void Heap::ForInIteratorObject::markObjects(Heap::Base *that, MarkStack *markStack)
{
- ForEachIteratorObject *o = static_cast<ForEachIteratorObject *>(that);
+ ForInIteratorObject *o = static_cast<ForInIteratorObject *>(that);
+ if (o->object)
+ o->object->mark(markStack);
+ if (o->current)
+ o->current->mark(markStack);
o->workArea[0].mark(markStack);
o->workArea[1].mark(markStack);
Object::markObjects(that, markStack);
}
+
+void Heap::ForInIteratorObject::destroy()
+{
+ delete iterator;
+}
+
+ReturnedValue ForInIteratorPrototype::method_next(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ const ForInIteratorObject *forIn = static_cast<const ForInIteratorObject *>(thisObject);
+ Q_ASSERT(forIn);
+ Scope scope(b);
+
+ ScopedPropertyKey key(scope, forIn->nextProperty());
+ bool done = false;
+ if (!key->isValid())
+ done = true;
+ ScopedStringOrSymbol s(scope, key->toStringOrSymbol(scope.engine));
+ return IteratorPrototype::createIterResultObject(scope.engine, s, done);
+}
+
+
+PropertyKey ForInIteratorObject::nextProperty() const
+{
+ if (!d()->current)
+ return PropertyKey::invalid();
+
+ Scope scope(this);
+ ScopedObject c(scope, d()->current);
+ ScopedObject t(scope, d()->target);
+ ScopedObject o(scope);
+ ScopedProperty p(scope);
+ ScopedPropertyKey key(scope);
+ PropertyAttributes attrs;
+
+ while (1) {
+ while (1) {
+ key = d()->iterator->next(t, p, &attrs);
+ if (!key->isValid())
+ break;
+ if (!attrs.isEnumerable() || key->isSymbol())
+ continue;
+ // check the property is not already defined earlier in the proto chain
+ if (d()->current != d()->object) {
+ o = d()->object;
+ bool shadowed = false;
+ while (o->d() != c->heapObject()) {
+ if (o->getOwnProperty(key) != Attr_Invalid) {
+ shadowed = true;
+ break;
+ }
+ o = o->getPrototypeOf();
+ }
+ if (shadowed)
+ continue;
+ }
+ return key;
+ }
+
+ c = c->getPrototypeOf();
+ d()->current.set(scope.engine, c->d());
+ if (!c)
+ break;
+ delete d()->iterator;
+ d()->iterator = c->ownPropertyKeys(t.getRef());
+ d()->target.set(scope.engine, t->d());
+ if (!d()->iterator) {
+ scope.engine->throwTypeError();
+ return PropertyKey::invalid();
+ }
+ }
+ return PropertyKey::invalid();
+}
diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h
index 744d16301a..a20ce9cb88 100644
--- a/src/qml/jsruntime/qv4objectiterator_p.h
+++ b/src/qml/jsruntime/qv4objectiterator_p.h
@@ -57,85 +57,86 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
-struct Q_QML_EXPORT ObjectIteratorData
+struct Q_QML_EXPORT ObjectIterator
{
enum Flags {
NoFlags = 0,
EnumerableOnly = 0x1,
- WithProtoChain = 0x2,
+ WithSymbols = 0x2
};
ExecutionEngine *engine;
- Value *object;
- Value *current;
- SparseArrayNode *arrayNode;
- uint arrayIndex;
- uint memberIndex;
+ Object *object;
+ OwnPropertyKeyIterator *iterator = nullptr;
uint flags;
-};
-Q_STATIC_ASSERT(std::is_trivial< ObjectIteratorData >::value);
-
-struct Q_QML_EXPORT ObjectIterator: ObjectIteratorData
-{
- ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags)
- {
- engine = e;
- object = scratch1;
- current = scratch2;
- arrayNode = nullptr;
- arrayIndex = 0;
- memberIndex = 0;
- this->flags = flags;
- init(o);
- }
ObjectIterator(Scope &scope, const Object *o, uint flags)
{
engine = scope.engine;
- object = scope.alloc(1);
- current = scope.alloc(1);
- arrayNode = nullptr;
- arrayIndex = 0;
- memberIndex = 0;
+ object = static_cast<Object *>(scope.alloc());
this->flags = flags;
- init(o);
+ object->setM(o ? o->m() : nullptr);
+ if (o)
+ iterator = object->ownPropertyKeys(object);
+ }
+ ~ObjectIterator()
+ {
+ delete iterator;
}
- void next(Value *name, uint *index, Property *pd, PropertyAttributes *attributes = nullptr);
+ PropertyKey next(Property *pd = nullptr, PropertyAttributes *attributes = nullptr);
ReturnedValue nextPropertyName(Value *value);
ReturnedValue nextPropertyNameAsString(Value *value);
ReturnedValue nextPropertyNameAsString();
-
-private:
- void init(const Object *o);
};
namespace Heap {
-struct ForEachIteratorObject : Object {
+
+#define ForInIteratorObjectMembers(class, Member) \
+ Member(class, Pointer, Object *, object) \
+ Member(class, Pointer, Object *, current) \
+ Member(class, Pointer, Object *, target) \
+ Member(class, NoMark, OwnPropertyKeyIterator *, iterator)
+
+DECLARE_HEAP_OBJECT(ForInIteratorObject, Object) {
void init(QV4::Object *o);
- ObjectIterator &it() { return *reinterpret_cast<ObjectIterator*>(&itData); }
Value workArea[2];
static void markObjects(Heap::Base *that, MarkStack *markStack);
-private:
- ObjectIteratorData itData;
+ void destroy();
};
}
-struct ForEachIteratorObject: Object {
- V4_OBJECT2(ForEachIteratorObject, Object)
- Q_MANAGED_TYPE(ForeachIteratorObject)
+struct ForInIteratorPrototype : Object
+{
+ V4_PROTOTYPE(iteratorPrototype)
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct ForInIteratorObject: Object {
+ V4_OBJECT2(ForInIteratorObject, Object)
+ Q_MANAGED_TYPE(ForInIterator)
+ V4_PROTOTYPE(forInIteratorPrototype)
+ V4_NEEDS_DESTROY
- ReturnedValue nextPropertyName() { return d()->it().nextPropertyNameAsString(); }
+ PropertyKey nextProperty() const;
};
inline
-void Heap::ForEachIteratorObject::init(QV4::Object *o)
+void Heap::ForInIteratorObject::init(QV4::Object *o)
{
Object::init();
- it() = ObjectIterator(internalClass->engine, workArea, workArea + 1, o,
- ObjectIterator::EnumerableOnly | ObjectIterator::WithProtoChain);
+ if (!o)
+ return;
+ object.set(o->engine(), o->d());
+ current.set(o->engine(), o->d());
+ Scope scope(o);
+ ScopedObject obj(scope);
+ iterator = o->ownPropertyKeys(obj.getRef());
+ target.set(o->engine(), obj->d());
}
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index b998b78520..6b4c3ba71a 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -47,6 +47,8 @@
#include "qv4objectiterator_p.h"
#include "qv4string_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
+#include "qv4propertykey_p.h"
#include <QtCore/QDateTime>
#include <QtCore/QStringList>
@@ -61,23 +63,23 @@ void Heap::ObjectCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("Object"));
}
-ReturnedValue ObjectCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue ObjectCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
ExecutionEngine *v4 = f->engine();
- const ObjectCtor *ctor = static_cast<const ObjectCtor *>(f);
+ const ObjectCtor *nt = static_cast<const ObjectCtor *>(newTarget);
if (!argc || argv[0].isUndefined() || argv[0].isNull()) {
Scope scope(v4);
ScopedObject obj(scope, scope.engine->newObject());
- ScopedObject proto(scope, ctor->get(scope.engine->id_prototype()));
+ ScopedObject proto(scope, nt->get(scope.engine->id_prototype()));
if (!!proto)
- obj->setPrototype(proto);
+ obj->setPrototypeOf(proto);
return obj.asReturnedValue();
} else {
return argv[0].toObject(v4)->asReturnedValue();
}
}
-ReturnedValue ObjectCtor::call(const FunctionObject *m, const Value *, const Value *argv, int argc)
+ReturnedValue ObjectCtor::virtualCall(const FunctionObject *m, const Value *, const Value *argv, int argc)
{
ExecutionEngine *v4 = m->engine();
if (!argc || argv[0].isUndefined() || argv[0].isNull()) {
@@ -93,25 +95,31 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ScopedObject o(scope, this);
ctor->defineReadonlyProperty(v4->id_prototype(), o);
- ctor->defineReadonlyConfigurableProperty(v4->id_length(), Primitive::fromInt32(1));
+ ctor->defineReadonlyConfigurableProperty(v4->id_length(), Value::fromInt32(1));
ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2);
+ ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptors"), method_getOwnPropertyDescriptors, 1);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1);
+ ctor->defineDefaultProperty(QStringLiteral("getOwnPropertySymbols"), method_getOwnPropertySymbols, 1);
ctor->defineDefaultProperty(QStringLiteral("assign"), method_assign, 2);
ctor->defineDefaultProperty(QStringLiteral("create"), method_create, 2);
ctor->defineDefaultProperty(QStringLiteral("defineProperty"), method_defineProperty, 3);
ctor->defineDefaultProperty(QStringLiteral("defineProperties"), method_defineProperties, 2);
+ ctor->defineDefaultProperty(QStringLiteral("entries"), method_entries, 1);
ctor->defineDefaultProperty(QStringLiteral("seal"), method_seal, 1);
ctor->defineDefaultProperty(QStringLiteral("freeze"), method_freeze, 1);
ctor->defineDefaultProperty(QStringLiteral("preventExtensions"), method_preventExtensions, 1);
+ ctor->defineDefaultProperty(QStringLiteral("is"), method_is, 2);
ctor->defineDefaultProperty(QStringLiteral("isSealed"), method_isSealed, 1);
ctor->defineDefaultProperty(QStringLiteral("isFrozen"), method_isFrozen, 1);
ctor->defineDefaultProperty(QStringLiteral("isExtensible"), method_isExtensible, 1);
ctor->defineDefaultProperty(QStringLiteral("keys"), method_keys, 1);
+ ctor->defineDefaultProperty(QStringLiteral("setPrototypeOf"), method_setPrototypeOf, 2);
+ ctor->defineDefaultProperty(QStringLiteral("values"), method_values, 1);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(v4->id_toString(), method_toString, 0);
- defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
+ defineDefaultProperty(v4->id_toLocaleString(), method_toLocaleString, 0);
defineDefaultProperty(v4->id_valueOf(), method_valueOf, 0);
defineDefaultProperty(QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 1);
defineDefaultProperty(QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 1);
@@ -119,11 +127,7 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
defineDefaultProperty(QStringLiteral("__defineGetter__"), method_defineGetter, 2);
defineDefaultProperty(QStringLiteral("__defineSetter__"), method_defineSetter, 2);
- ExecutionContext *global = v4->rootContext();
- ScopedProperty p(scope);
- p->value = FunctionObject::createBuiltinFunction(global, v4->id___proto__(), method_get_proto);
- p->set = FunctionObject::createBuiltinFunction(global, v4->id___proto__(), method_set_proto);
- insertMember(v4->id___proto__(), p, Attr_Accessor|Attr_NotEnumerable);
+ defineAccessorProperty(v4->id___proto__(), method_get_proto, method_set_proto);
}
ReturnedValue ObjectPrototype::method_getPrototypeOf(const FunctionObject *b, const Value *, const Value *argv, int argc)
@@ -136,10 +140,19 @@ ReturnedValue ObjectPrototype::method_getPrototypeOf(const FunctionObject *b, co
if (scope.engine->hasException)
return QV4::Encode::undefined();
- ScopedObject p(scope, o->prototype());
+ ScopedObject p(scope, o->getPrototypeOf());
return (!!p ? p->asReturnedValue() : Encode::null());
}
+ReturnedValue ObjectPrototype::method_is(const FunctionObject *, const Value *, const Value *argv, int argc)
+{
+ if (!argc)
+ return Encode(true);
+ if (argc == 1)
+ return Encode((argv[0].isUndefined() ? true : false));
+ return Encode(argv[0].sameValue(argv[1]));
+}
+
ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
Scope scope(b);
@@ -153,17 +166,45 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj
if (ArgumentsObject::isNonStrictArgumentsObject(O))
static_cast<ArgumentsObject *>(O.getPointer())->fullyCreate();
- ScopedValue v(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
- ScopedString name(scope, v->toString(scope.engine));
+ ScopedValue v(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ ScopedPropertyKey name(scope, v->toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- PropertyAttributes attrs;
ScopedProperty desc(scope);
- O->getOwnProperty(name, &attrs, desc);
+ PropertyAttributes attrs = O->getOwnProperty(name, desc);
return fromPropertyDescriptor(scope.engine, desc, attrs);
}
+ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptors(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, argv[0].toObject(scope.engine));
+ if (scope.engine->hasException)
+ return Encode::undefined();
+
+ ScopedObject descriptors(scope, scope.engine->newObject());
+
+ ObjectIterator it(scope, o, ObjectIterator::WithSymbols);
+ ScopedProperty pd(scope);
+ PropertyAttributes attrs;
+ ScopedPropertyKey key(scope);
+ ScopedObject entry(scope);
+ while (1) {
+ key = it.next(pd, &attrs);
+ if (!key->isValid())
+ break;
+ entry = fromPropertyDescriptor(scope.engine, pd, attrs);
+ descriptors->put(key, entry);
+ }
+
+ return descriptors.asReturnedValue();
+
+}
+
ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
Scope scope(b);
@@ -177,6 +218,32 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject *
return Encode(getOwnPropertyNames(scope.engine, argv[0]));
}
+ReturnedValue ObjectPrototype::method_getOwnPropertySymbols(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject O(scope, argv[0].toObject(scope.engine));
+ if (!O)
+ return Encode::undefined();
+
+ ScopedArrayObject array(scope, scope.engine->newArrayObject());
+ if (O) {
+ ObjectIterator it(scope, O, ObjectIterator::WithSymbols);
+ ScopedValue name(scope);
+ while (1) {
+ name = it.nextPropertyNameAsString();
+ if (name->isNull())
+ break;
+ if (!name->isSymbol())
+ continue;
+ array->push_back(name);
+ }
+ }
+ return array->asReturnedValue();
+}
+
// 19.1.2.1
ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
@@ -204,11 +271,10 @@ ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Valu
ScopedString nextKey(scope);
ScopedValue propValue(scope);
for (quint32 i = 0; i < length; ++i) {
- nextKey = Value::fromReturnedValue(keys->getIndexed(i)).toString(scope.engine);
+ nextKey = Value::fromReturnedValue(keys->get(i)).toString(scope.engine);
- PropertyAttributes attrs;
ScopedProperty prop(scope);
- from->getOwnProperty(nextKey, &attrs, prop);
+ PropertyAttributes attrs = from->getOwnProperty(nextKey->toPropertyKey(), prop);
if (attrs == PropertyFlag::Attr_Invalid)
continue;
@@ -235,7 +301,7 @@ ReturnedValue ObjectPrototype::method_create(const FunctionObject *builtin, cons
ScopedObject O(scope, argv[0]);
ScopedObject newObject(scope, scope.engine->newObject());
- newObject->setPrototype(O);
+ newObject->setPrototypeOf(O);
if (argc > 1 && !argv[1].isUndefined()) {
@@ -255,18 +321,18 @@ ReturnedValue ObjectPrototype::method_defineProperty(const FunctionObject *b, co
return scope.engine->throwTypeError();
ScopedObject O(scope, argv[0]);
- ScopedString name(scope, argc > 1 ? argv[1] : Primitive::undefinedValue(), ScopedString::Convert);
+ ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- ScopedValue attributes(scope, argc > 2 ? argv[2] : Primitive::undefinedValue());
+ ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue());
ScopedProperty pd(scope);
PropertyAttributes attrs;
toPropertyDescriptor(scope.engine, attributes, pd, &attrs);
if (scope.engine->hasException)
return QV4::Encode::undefined();
- if (!O->__defineOwnProperty__(scope.engine, name, pd, attrs))
+ if (!O->defineOwnProperty(name, pd, attrs))
THROW_TYPE_ERROR();
return O.asReturnedValue();
@@ -287,25 +353,20 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b,
ScopedValue val(scope);
ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
- ScopedString name(scope);
ScopedProperty pd(scope);
ScopedProperty n(scope);
+ ScopedPropertyKey key(scope);
while (1) {
- uint index;
PropertyAttributes attrs;
- it.next(name.getRef(), &index, pd, &attrs);
- if (attrs.isEmpty())
+ key = it.next(pd, &attrs);
+ if (!key->isValid())
break;
PropertyAttributes nattrs;
val = o->getValue(pd->value, attrs);
toPropertyDescriptor(scope.engine, val, n, &nattrs);
if (scope.engine->hasException)
return QV4::Encode::undefined();
- bool ok;
- if (name)
- ok = O->__defineOwnProperty__(scope.engine, name, n, nattrs);
- else
- ok = O->__defineOwnProperty__(scope.engine, index, n, nattrs);
+ bool ok = O->defineOwnProperty(key, n, nattrs);
if (!ok)
THROW_TYPE_ERROR();
}
@@ -313,9 +374,48 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b,
return O.asReturnedValue();
}
+ReturnedValue ObjectPrototype::method_entries(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, argv[0].toObject(scope.engine));
+ if (scope.engine->hasException)
+ return Encode::undefined();
+
+ ScopedArrayObject a(scope, scope.engine->newArrayObject());
+
+ ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
+ ScopedString name(scope);
+ ScopedArrayObject entry(scope);
+ while (1) {
+ name = it.nextPropertyNameAsString();
+ if (!name)
+ break;
+ entry = scope.engine->newArrayObject();
+ entry->push_back(name);
+ a->push_back(entry);
+ }
+
+ // now add values, do this after the loop above as reading out the values can have side effects
+ uint len = a->getLength();
+ ScopedValue value(scope);
+ for (uint i = 0; i < len; ++i) {
+ entry = a->get(PropertyKey::fromArrayIndex(i));
+ name = entry->get(PropertyKey::fromArrayIndex(0));
+ value = o->get(name->toPropertyKey());
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ entry->push_back(value);
+ }
+
+ return a.asReturnedValue();
+}
+
ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
- const Value a = argc ? argv[0] : Primitive::undefinedValue();
+ const Value a = argc ? argv[0] : Value::undefinedValue();
if (!a.isObject())
// 19.1.2.17, 1
return a.asReturnedValue();
@@ -337,7 +437,7 @@ ReturnedValue ObjectPrototype::method_seal(const FunctionObject *b, const Value
ReturnedValue ObjectPrototype::method_freeze(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
- const Value a = argc ? argv[0] : Primitive::undefinedValue();
+ const Value a = argc ? argv[0] : Value::undefinedValue();
if (!a.isObject())
// 19.1.2.5, 1
return a.asReturnedValue();
@@ -366,13 +466,13 @@ ReturnedValue ObjectPrototype::method_preventExtensions(const FunctionObject *b,
{
Scope scope(b);
if (!argc)
- return scope.engine->throwTypeError();
+ return Encode::undefined();
- ScopedObject o(scope, argv[0].toObject(scope.engine));
+ ScopedObject o(scope, argv[0]);
if (!o)
return argv[0].asReturnedValue();
- o->setInternalClass(o->internalClass()->nonExtensible());
+ o->preventExtensions();
return o.asReturnedValue();
}
@@ -380,9 +480,9 @@ ReturnedValue ObjectPrototype::method_isSealed(const FunctionObject *b, const Va
{
Scope scope(b);
if (!argc)
- return scope.engine->throwTypeError();
+ return Encode(true);
- ScopedObject o(scope, argv[0].toObject(scope.engine));
+ ScopedObject o(scope, argv[0]);
if (!o)
return Encode(true);
@@ -412,9 +512,9 @@ ReturnedValue ObjectPrototype::method_isFrozen(const FunctionObject *b, const Va
{
Scope scope(b);
if (!argc)
- return scope.engine->throwTypeError();
+ return Encode(true);
- ScopedObject o(scope, argv[0].toObject(scope.engine));
+ ScopedObject o(scope, argv[0]);
if (!o)
return Encode(true);
@@ -444,9 +544,9 @@ ReturnedValue ObjectPrototype::method_isExtensible(const FunctionObject *b, cons
{
Scope scope(b);
if (!argc)
- return scope.engine->throwTypeError();
+ return Encode(false);
- ScopedObject o(scope, argv[0].toObject(scope.engine));
+ ScopedObject o(scope, argv[0]);
if (!o)
return Encode(false);
@@ -467,8 +567,9 @@ ReturnedValue ObjectPrototype::method_keys(const FunctionObject *b, const Value
ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
ScopedValue name(scope);
+ ScopedValue value(scope);
while (1) {
- name = it.nextPropertyNameAsString();
+ name = it.nextPropertyNameAsString(value);
if (name->isNull())
break;
a->push_back(name);
@@ -477,19 +578,81 @@ ReturnedValue ObjectPrototype::method_keys(const FunctionObject *b, const Value
return a.asReturnedValue();
}
+ReturnedValue ObjectPrototype::method_setPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f->engine());
+ if (argc < 2 || argv[0].isNullOrUndefined() || !(argv[1].isObject() || argv[1].isNull()))
+ return scope.engine->throwTypeError();
+
+ if (!argv[0].isObject())
+ return argv[0].asReturnedValue();
+
+ ScopedObject o(scope, argv[0]);
+ const Object *p = argv[1].isNull() ? nullptr : static_cast<const Object *>(argv + 1);
+ bool ok = o->setPrototypeOf(p);
+ if (!ok)
+ return scope.engine->throwTypeError(QStringLiteral("Could not change prototype."));
+ return o->asReturnedValue();
+}
+
+ReturnedValue ObjectPrototype::method_values(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, argv[0].toObject(scope.engine));
+ if (scope.engine->hasException)
+ return QV4::Encode::undefined();
+
+ ScopedArrayObject a(scope, scope.engine->newArrayObject());
+
+ ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
+ ScopedPropertyKey key(scope);
+ ScopedProperty pd(scope);
+ ScopedValue value(scope);
+ PropertyAttributes attrs;
+ while (1) {
+ key = it.next(pd, &attrs);
+ if (!key->isValid())
+ break;
+ value = o->getValue(pd->value, attrs);
+ a->push_back(value);
+ }
+
+ return a.asReturnedValue();
+}
+
ReturnedValue ObjectPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
+ QString string;
if (thisObject->isUndefined()) {
- return Encode(v4->newString(QStringLiteral("[object Undefined]")));
+ string = QStringLiteral("[object Undefined]");
} else if (thisObject->isNull()) {
- return Encode(v4->newString(QStringLiteral("[object Null]")));
+ string = QStringLiteral("[object Null]");
} else {
+ const Object *o = thisObject->as<Object>();
+ if (!o) {
+ // primitive, get the proper prototype
+ if (thisObject->isBoolean())
+ o = v4->booleanPrototype();
+ else if (thisObject->isNumber())
+ o = v4->numberPrototype();
+ else if (thisObject->isString())
+ o = v4->stringPrototype();
+ else if (thisObject->isSymbol())
+ o = v4->symbolPrototype();
+ Q_ASSERT(o);
+ }
+ QString name = o->className();
Scope scope(v4);
- ScopedObject obj(scope, thisObject->toObject(scope.engine));
- QString className = obj->className();
- return Encode(v4->newString(QStringLiteral("[object %1]").arg(className)));
+ ScopedString toStringTag(scope, o->get(v4->symbol_toStringTag()));
+ if (toStringTag)
+ name = toStringTag->toQString();
+ string = QStringLiteral("[object %1]").arg(name);
}
+ return Encode(v4->newString(string));
}
ReturnedValue ObjectPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -514,15 +677,13 @@ ReturnedValue ObjectPrototype::method_valueOf(const FunctionObject *b, const Val
ReturnedValue ObjectPrototype::method_hasOwnProperty(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
- ScopedString P(scope, argc ? argv[0] : Primitive::undefinedValue(), ScopedString::Convert);
+ ScopedPropertyKey P(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
ScopedObject O(scope, thisObject->toObject(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- bool r = O->hasOwnProperty(P);
- if (!r)
- r = !O->query(P).isEmpty();
+ bool r = O->getOwnProperty(P) != Attr_Invalid;
return Encode(r);
}
@@ -536,11 +697,11 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(const FunctionObject *b, con
ScopedObject O(scope, thisObject->toObject(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- ScopedObject proto(scope, V->prototype());
+ ScopedObject proto(scope, V->getPrototypeOf());
while (proto) {
if (O->d() == proto->d())
return Encode(true);
- proto = proto->prototype();
+ proto = proto->getPrototypeOf();
}
return Encode(false);
}
@@ -548,15 +709,14 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(const FunctionObject *b, con
ReturnedValue ObjectPrototype::method_propertyIsEnumerable(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
- ScopedString p(scope, argc ? argv[0] : Primitive::undefinedValue(), ScopedString::Convert);
+ ScopedPropertyKey p(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
ScopedObject o(scope, thisObject->toObject(scope.engine));
if (scope.engine->hasException)
return QV4::Encode::undefined();
- PropertyAttributes attrs;
- o->getOwnProperty(p, &attrs);
+ PropertyAttributes attrs = o->getOwnProperty(p);
return Encode(attrs.isEnumerable());
}
@@ -583,8 +743,8 @@ ReturnedValue ObjectPrototype::method_defineGetter(const FunctionObject *b, cons
ScopedProperty pd(scope);
pd->value = f;
- pd->set = Primitive::emptyValue();
- bool ok = o->__defineOwnProperty__(scope.engine, prop, pd, Attr_Accessor);
+ pd->set = Value::emptyValue();
+ bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor);
if (!ok)
THROW_TYPE_ERROR();
RETURN_UNDEFINED();
@@ -612,9 +772,9 @@ ReturnedValue ObjectPrototype::method_defineSetter(const FunctionObject *b, cons
}
ScopedProperty pd(scope);
- pd->value = Primitive::emptyValue();
+ pd->value = Value::emptyValue();
pd->set = f;
- bool ok = o->__defineOwnProperty__(scope.engine, prop, pd, Attr_Accessor);
+ bool ok = o->defineOwnProperty(prop->toPropertyKey(), pd, Attr_Accessor);
if (!ok)
THROW_TYPE_ERROR();
RETURN_UNDEFINED();
@@ -627,32 +787,21 @@ ReturnedValue ObjectPrototype::method_get_proto(const FunctionObject *b, const V
if (!o)
THROW_TYPE_ERROR();
- return Encode(o->prototype());
+ return Encode(o->getPrototypeOf());
}
ReturnedValue ObjectPrototype::method_set_proto(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
ScopedObject o(scope, thisObject);
- if (!o || !argc)
+ if (!o || !argc || (!argv[0].isObject() && !argv[0].isNull()))
THROW_TYPE_ERROR();
- if (argv[0].isNull()) {
- o->setPrototype(nullptr);
- RETURN_UNDEFINED();
- }
-
- ScopedObject p(scope, argv[0]);
- bool ok = false;
- if (!!p) {
- if (o->prototype() == p->d()) {
- ok = true;
- } else if (o->isExtensible()) {
- ok = o->setPrototype(p);
- }
- }
+ const Object *p = argv[0].isNull() ? nullptr : static_cast<const Object *>(argv);
+ bool ok = o->setPrototypeOf(p);
if (!ok)
- return scope.engine->throwTypeError(QStringLiteral("Cyclic __proto__ value"));
+ return scope.engine->throwTypeError(QStringLiteral("Could not change prototype."));
+ return Encode::undefined();
RETURN_UNDEFINED();
}
@@ -666,17 +815,17 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
}
attrs->clear();
- desc->value = Primitive::emptyValue();
- desc->set = Primitive::emptyValue();
+ desc->value = Value::emptyValue();
+ desc->set = Value::emptyValue();
ScopedValue tmp(scope);
- if (o->hasProperty(engine->id_enumerable()))
+ if (o->hasProperty(engine->id_enumerable()->toPropertyKey()))
attrs->setEnumerable((tmp = o->get(engine->id_enumerable()))->toBoolean());
- if (o->hasProperty(engine->id_configurable()))
+ if (o->hasProperty(engine->id_configurable()->toPropertyKey()))
attrs->setConfigurable((tmp = o->get(engine->id_configurable()))->toBoolean());
- if (o->hasProperty(engine->id_get())) {
+ if (o->hasProperty(engine->id_get()->toPropertyKey())) {
ScopedValue get(scope, o->get(engine->id_get()));
FunctionObject *f = get->as<FunctionObject>();
if (f || get->isUndefined()) {
@@ -688,7 +837,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
attrs->setType(PropertyAttributes::Accessor);
}
- if (o->hasProperty(engine->id_set())) {
+ if (o->hasProperty(engine->id_set()->toPropertyKey())) {
ScopedValue set(scope, o->get(engine->id_set()));
FunctionObject *f = set->as<FunctionObject>();
if (f || set->isUndefined()) {
@@ -700,17 +849,15 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
attrs->setType(PropertyAttributes::Accessor);
}
- if (o->hasProperty(engine->id_writable())) {
+ if (o->hasProperty(engine->id_writable()->toPropertyKey())) {
if (attrs->isAccessor()) {
engine->throwTypeError();
return;
}
attrs->setWritable((tmp = o->get(engine->id_writable()))->toBoolean());
- // writable forces it to be a data descriptor
- desc->value = Primitive::undefinedValue();
}
- if (o->hasProperty(engine->id_value())) {
+ if (o->hasProperty(engine->id_value()->toPropertyKey())) {
if (attrs->isAccessor()) {
engine->throwTypeError();
return;
@@ -720,7 +867,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
}
if (attrs->isGeneric())
- desc->value = Primitive::emptyValue();
+ desc->value = Value::emptyValue();
}
@@ -734,29 +881,28 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionEngine *engine, c
// is the standard built-in constructor with that name.
ScopedObject o(scope, engine->newObject());
ScopedString s(scope);
+ ScopedValue v(scope);
- ScopedProperty pd(scope);
if (attrs.isData()) {
- pd->value = desc->value;
s = engine->newString(QStringLiteral("value"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
- pd->value = Primitive::fromBoolean(attrs.isWritable());
+ o->put(s, desc->value);
+ v = Value::fromBoolean(attrs.isWritable());
s = engine->newString(QStringLiteral("writable"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
+ o->put(s, v);
} else {
- pd->value = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined();
+ v = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("get"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
- pd->value = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined();
+ o->put(s, v);
+ v = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("set"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
+ o->put(s, v);
}
- pd->value = Primitive::fromBoolean(attrs.isEnumerable());
+ v = Value::fromBoolean(attrs.isEnumerable());
s = engine->newString(QStringLiteral("enumerable"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
- pd->value = Primitive::fromBoolean(attrs.isConfigurable());
+ o->put(s, v);
+ v = Value::fromBoolean(attrs.isConfigurable());
s = engine->newString(QStringLiteral("configurable"));
- o->__defineOwnProperty__(scope.engine, s, pd, Attr_Data);
+ o->put(s, v);
return o.asReturnedValue();
}
@@ -774,6 +920,8 @@ Heap::ArrayObject *ObjectPrototype::getOwnPropertyNames(ExecutionEngine *v4, con
name = it.nextPropertyNameAsString();
if (name->isNull())
break;
+ if (name->isSymbol())
+ continue;
array->push_back(name);
}
}
diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h
index 2b231d46ad..e9515b5b68 100644
--- a/src/qml/jsruntime/qv4objectproto_p.h
+++ b/src/qml/jsruntime/qv4objectproto_p.h
@@ -70,28 +70,34 @@ struct ObjectCtor: FunctionObject
{
V4_OBJECT2(ObjectCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc);
};
struct ObjectPrototype: Object
{
void init(ExecutionEngine *engine, Object *ctor);
- static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_getOwnPropertyNames(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_assign(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_create(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_defineProperties(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_seal(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_freeze(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_isSealed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_isFrozen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getOwnPropertyDescriptors(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getOwnPropertyNames(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getOwnPropertySymbols(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_is(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_isExtensible(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isFrozen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isSealed(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_seal(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_setPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp
index 7fc74173e3..79c372348f 100644
--- a/src/qml/jsruntime/qv4persistent.cpp
+++ b/src/qml/jsruntime/qv4persistent.cpp
@@ -98,9 +98,9 @@ Page *allocatePage(PersistentValueStorage *storage)
p->header.freeList = 0;
insertInFront(storage, p);
for (int i = 0; i < kEntriesPerPage - 1; ++i) {
- p->values[i].setEmpty(i + 1);
+ p->values[i] = Encode(i + 1);
}
- p->values[kEntriesPerPage - 1].setEmpty(-1);
+ p->values[kEntriesPerPage - 1] = Encode(-1);
return p;
}
@@ -226,7 +226,7 @@ void PersistentValueStorage::free(Value *v)
Page *p = getPage(v);
- v->setEmpty(p->header.freeList);
+ *v = Encode(p->header.freeList);
p->header.freeList = v - p->values;
if (!--p->header.refCount)
freePage(p);
@@ -302,6 +302,10 @@ PersistentValue &PersistentValue::operator=(const PersistentValue &other)
return *this;
val = other.engine()->memoryManager->m_persistentValues->allocate();
}
+ if (!other.val) {
+ *val = Encode::undefined();
+ return *this;
+ }
Q_ASSERT(engine() == other.engine());
@@ -316,6 +320,10 @@ PersistentValue &PersistentValue::operator=(const WeakValue &other)
return *this;
val = other.engine()->memoryManager->m_persistentValues->allocate();
}
+ if (!other.valueRef()) {
+ *val = Encode::undefined();
+ return *this;
+ }
Q_ASSERT(engine() == other.engine());
@@ -379,6 +387,10 @@ WeakValue &WeakValue::operator=(const WeakValue &other)
return *this;
allocVal(other.engine());
}
+ if (!other.val) {
+ *val = Encode::undefined();
+ return *this;
+ }
Q_ASSERT(engine() == other.engine());
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp
index 5fd200efc1..b337243204 100644
--- a/src/qml/jsruntime/qv4profiling.cpp
+++ b/src/qml/jsruntime/qv4profiling.cpp
@@ -78,7 +78,7 @@ Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(
void Profiler::stopProfiling()
{
featuresEnabled = 0;
- reportData(true);
+ reportData();
m_sentLocations.clear();
}
@@ -89,7 +89,7 @@ bool operator<(const FunctionCall &call1, const FunctionCall &call2)
(call1.m_end == call2.m_end && call1.m_function < call2.m_function)));
}
-void Profiler::reportData(bool trackLocations)
+void Profiler::reportData()
{
std::sort(m_data.begin(), m_data.end());
QVector<FunctionCallProperties> properties;
@@ -100,12 +100,11 @@ void Profiler::reportData(bool trackLocations)
properties.append(call.properties());
Function *function = call.function();
SentMarker &marker = m_sentLocations[reinterpret_cast<quintptr>(function)];
- if (!trackLocations || !marker.isValid()) {
+ if (!marker.isValid()) {
FunctionLocation &location = locations[properties.constLast().id];
if (!location.isValid())
location = call.resolveLocation();
- if (trackLocations)
- marker.setFunction(function);
+ marker.setFunction(function);
}
}
diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h
index e8c154e4e7..8461384e9a 100644
--- a/src/qml/jsruntime/qv4profiling_p.h
+++ b/src/qml/jsruntime/qv4profiling_p.h
@@ -251,7 +251,7 @@ public:
void stopProfiling();
void startProfiling(quint64 features);
- void reportData(bool trackLocations);
+ void reportData();
void setTimer(const QElapsedTimer &timer) { m_timer = timer; }
signals:
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h
index 7cb106c424..555f323737 100644
--- a/src/qml/jsruntime/qv4property_p.h
+++ b/src/qml/jsruntime/qv4property_p.h
@@ -66,18 +66,36 @@ struct Property {
// Section 8.10
inline void fullyPopulated(PropertyAttributes *attrs) {
if (!attrs->hasType()) {
- value = Primitive::undefinedValue();
+ value = Value::undefinedValue();
}
if (attrs->type() == PropertyAttributes::Accessor) {
attrs->clearWritable();
if (value.isEmpty())
- value = Primitive::undefinedValue();
+ value = Value::undefinedValue();
if (set.isEmpty())
- set = Primitive::undefinedValue();
+ set = Value::undefinedValue();
}
attrs->resolve();
}
+ // ES8: 6.2.5.6
+ void completed(PropertyAttributes *attrs) {
+ if (value.isEmpty())
+ value = Encode::undefined();
+ if (attrs->isGeneric() || attrs->isData()) {
+ attrs->setType(PropertyAttributes::Data);
+ if (!attrs->hasWritable())
+ attrs->setWritable(false);
+ } else {
+ if (set.isEmpty())
+ set = Encode::undefined();
+ }
+ if (!attrs->hasEnumerable())
+ attrs->setEnumerable(false);
+ if (!attrs->hasConfigurable())
+ attrs->setConfigurable(false);
+ }
+
inline bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const;
inline void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs);
@@ -92,6 +110,40 @@ struct Property {
set = other->set;
}
+ // ES8, section 9.1.6.2/9,.1.6.3
+ bool isCompatible(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const {
+ if (otherAttrs.isEmpty())
+ return true;
+ if (!attrs.isConfigurable()) {
+ if (otherAttrs.hasConfigurable() && otherAttrs.isConfigurable())
+ return false;
+ if (otherAttrs.hasEnumerable() && otherAttrs.isEnumerable() != attrs.isEnumerable())
+ return false;
+ }
+ if (otherAttrs.isGeneric())
+ return true;
+ if (attrs.isData() != otherAttrs.isData()) {
+ if (!attrs.isConfigurable())
+ return false;
+ } else if (attrs.isData() && otherAttrs.isData()) {
+ if (!attrs.isConfigurable() && !attrs.isWritable()) {
+ if (otherAttrs.hasWritable() && otherAttrs.isWritable())
+ return false;
+ if (!other->value.isEmpty() && !value.sameValue(other->value))
+ return false;
+ }
+ } else if (attrs.isAccessor() && otherAttrs.isAccessor()) {
+ if (!attrs.isConfigurable()) {
+ if (!other->value.isEmpty() && !value.sameValue(other->value))
+ return false;
+ if (!other->set.isEmpty() && !set.sameValue(other->set))
+ return false;
+ }
+ }
+ return true;
+ }
+
+
explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(nullptr); }
Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter) {
value.setM(reinterpret_cast<Heap::Base *>(getter));
@@ -142,6 +194,19 @@ inline void Property::merge(PropertyAttributes &attrs, const Property *other, Pr
}
}
+struct PropertyIndex {
+ Heap::Base *base;
+ Value *slot;
+
+ void set(EngineBase *e, Value newVal) {
+ WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue());
+ }
+ const Value *operator->() const { return slot; }
+ const Value &operator*() const { return *slot; }
+ bool isNull() const { return !slot; }
+};
+
+
}
Q_DECLARE_TYPEINFO(QV4::Property, Q_MOVABLE_TYPE);
diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp
new file mode 100644
index 0000000000..064d030b83
--- /dev/null
+++ b/src/qml/jsruntime/qv4propertykey.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4propertykey_p.h"
+
+#include <QtCore/qstring.h>
+#include <qv4string_p.h>
+#include <qv4engine_p.h>
+#include <qv4scopedvalue_p.h>
+
+QV4::Heap::StringOrSymbol *QV4::PropertyKey::toStringOrSymbol(QV4::ExecutionEngine *e)
+{
+ if (isArrayIndex())
+ return Value::fromUInt32(asArrayIndex()).toString(e);
+ return static_cast<Heap::StringOrSymbol *>(asStringOrSymbol());
+}
+
+bool QV4::PropertyKey::isString() const {
+ Heap::StringOrSymbol *s = asStringOrSymbol();
+ return s && s->internalClass->vtable->isString;
+}
+
+bool QV4::PropertyKey::isSymbol() const {
+ Heap::Base *s = asStringOrSymbol();
+ return s && !s->internalClass->vtable->isString && s->internalClass->vtable->isStringOrSymbol;
+}
+
+bool QV4::PropertyKey::isCanonicalNumericIndexString() const
+{
+ if (isArrayIndex())
+ return true;
+ if (isSymbol())
+ return false;
+ Heap::String *s = static_cast<Heap::String *>(asStringOrSymbol());
+ Scope scope(s->internalClass->engine);
+ ScopedString str(scope, s);
+ double d = str->toNumber();
+ if (d == 0. && std::signbit(d))
+ return true;
+ ScopedString converted(scope, Value::fromDouble(d).toString(scope.engine));
+ if (converted->equals(str))
+ return true;
+ return false;
+}
+
+QString QV4::PropertyKey::toQString() const
+{
+ if (isArrayIndex())
+ return QString::number(asArrayIndex());
+ Heap::StringOrSymbol *s = asStringOrSymbol();
+ Q_ASSERT(s->internalClass->vtable->isStringOrSymbol);
+ return s->toQString();
+}
+
+QV4::Heap::String *QV4::PropertyKey::asFunctionName(ExecutionEngine *engine, FunctionNamePrefix prefix) const
+{
+ QString n;
+ if (prefix == Getter)
+ n = QStringLiteral("get ");
+ else if (prefix == Setter)
+ n = QStringLiteral("set ");
+ if (isArrayIndex())
+ n += QString::number(asArrayIndex());
+ else {
+ Heap::StringOrSymbol *s = asStringOrSymbol();
+ QString str = s->toQString();
+ if (s->internalClass->vtable->isString)
+ n += s->toQString();
+ else if (str.length() > 1)
+ n += QChar::fromLatin1('[') + str.midRef(1) + QChar::fromLatin1(']');
+ }
+ return engine->newString(n);
+}
diff --git a/src/qml/jsruntime/qv4propertykey_p.h b/src/qml/jsruntime/qv4propertykey_p.h
new file mode 100644
index 0000000000..cb2661f244
--- /dev/null
+++ b/src/qml/jsruntime/qv4propertykey_p.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4PROPERTYKEY_H
+#define QV4PROPERTYKEY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qv4global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QString;
+
+namespace QV4 {
+
+struct PropertyKey
+{
+private:
+ // Property keys are Strings, Symbols or unsigned integers.
+ // For convenience we derive them from Values, allowing us to store them
+ // on the JS stack
+ //
+ // They do however behave somewhat different than a Value:
+ // * If the key is a String, the pointer to the string is stored in the identifier
+ // table and thus unique.
+ // * If the key is a Symbol it simply points to the referenced symbol object
+ // * if the key is an array index (a uint < UINT_MAX), it's encoded as an
+ // integer value
+ quint64 val;
+
+ // Important: Always keep this in sync with the definitions for Integers and heap objects in Value
+ static const quint64 ArrayIndexMask = 0x3800000000000ull;
+ enum {
+ IsManagedOrUndefined_Shift = 64-15,
+ };
+ inline bool isManaged() const { return (val >> IsManagedOrUndefined_Shift) == 0; }
+ inline quint32 value() const { return val & quint64(~quint32(0)); }
+
+#if QT_POINTER_SIZE == 8
+ QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const
+ {
+ Heap::StringOrSymbol *b;
+ memcpy(&b, &val, 8);
+ return b;
+ }
+ QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b)
+ {
+ memcpy(&val, &b, 8);
+ }
+#elif QT_POINTER_SIZE == 4
+ QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const
+ {
+ Q_STATIC_ASSERT(sizeof(Heap::StringOrSymbol*) == sizeof(quint32));
+ Heap::StringOrSymbol *b;
+ quint32 v = value();
+ memcpy(&b, &v, 4);
+ return b;
+ }
+ QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b)
+ {
+ quint32 v;
+ memcpy(&v, &b, 4);
+ val = v;
+ }
+#endif
+
+public:
+ static PropertyKey invalid() { PropertyKey key; key.val = 0; return key; }
+ static PropertyKey fromArrayIndex(uint idx) { PropertyKey key; key.val = ArrayIndexMask | static_cast<quint64>(idx); return key; }
+ bool isStringOrSymbol() const { return isManaged() && val != 0; }
+ uint asArrayIndex() const { return (isManaged() || val == 0) ? std::numeric_limits<uint>::max() : static_cast<uint>(val & 0xffffffff); }
+ uint isArrayIndex() const { return !isManaged() && val != 0; }
+ bool isValid() const { return val != 0; }
+ static PropertyKey fromStringOrSymbol(Heap::StringOrSymbol *b)
+ { PropertyKey key; key.setM(b); return key; }
+ Heap::StringOrSymbol *asStringOrSymbol() const {
+ if (!isManaged())
+ return nullptr;
+ return m();
+ }
+
+ bool isString() const;
+ bool isSymbol() const;
+ bool isCanonicalNumericIndexString() const;
+
+ Q_QML_EXPORT QString toQString() const;
+ Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e);
+ quint64 id() const { return val; }
+ static PropertyKey fromId(quint64 id) {
+ PropertyKey key; key.val = id; return key;
+ }
+
+ enum FunctionNamePrefix {
+ None,
+ Getter,
+ Setter
+ };
+ Heap::String *asFunctionName(ExecutionEngine *e, FunctionNamePrefix prefix) const;
+
+ bool operator ==(const PropertyKey &other) const { return val == other.val; }
+ bool operator !=(const PropertyKey &other) const { return val != other.val; }
+ bool operator <(const PropertyKey &other) const { return val < other.val; }
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp
new file mode 100644
index 0000000000..9325e2e53b
--- /dev/null
+++ b/src/qml/jsruntime/qv4proxy.cpp
@@ -0,0 +1,782 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qv4proxy_p.h"
+#include "qv4symbol_p.h"
+#include "qv4jscall_p.h"
+#include "qv4objectproto_p.h"
+#include "qv4persistent_p.h"
+#include "qv4objectiterator_p.h"
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(ProxyObject);
+DEFINE_OBJECT_VTABLE(ProxyFunctionObject);
+
+void Heap::ProxyObject::init(const QV4::Object *target, const QV4::Object *handler)
+{
+ Object::init();
+ ExecutionEngine *e = internalClass->engine;
+ this->target.set(e, target->d());
+ this->handler.set(e, handler->d());
+}
+
+void Heap::ProxyFunctionObject::init(const QV4::FunctionObject *target, const QV4::Object *handler)
+{
+ ExecutionEngine *e = internalClass->engine;
+ FunctionObject::init(e->rootContext());
+ this->target.set(e, target->d());
+ this->handler.set(e, handler->d());
+
+ if (!target->isConstructor())
+ jsConstruct = nullptr;
+}
+
+
+ReturnedValue ProxyObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedValue trap(scope, handler->get(scope.engine->id_get()));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->get(id, receiver, hasProperty);
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+ if (hasProperty)
+ *hasProperty = true;
+
+ JSCallData cdata(scope, 3, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.toStringOrSymbol(scope.engine);
+ cdata.args[2] = *receiver;
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
+ if (attributes != Attr_Invalid && !attributes.isConfigurable()) {
+ if (attributes.isData() && !attributes.isWritable()) {
+ if (!trapResult->sameValue(targetDesc->value))
+ return scope.engine->throwTypeError();
+ }
+ if (attributes.isAccessor() && targetDesc->value.isUndefined()) {
+ if (!trapResult->isUndefined())
+ return scope.engine->throwTypeError();
+ }
+ }
+ return trapResult->asReturnedValue();
+}
+
+bool ProxyObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedValue trap(scope, handler->get(scope.engine->id_set()));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->put(id, value, receiver);
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ JSCallData cdata(scope, 4, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.toStringOrSymbol(scope.engine);
+ cdata.args[2] = value;
+ cdata.args[3] = *receiver;
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (!trapResult->toBoolean())
+ return false;
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
+ if (attributes != Attr_Invalid && !attributes.isConfigurable()) {
+ if (attributes.isData() && !attributes.isWritable()) {
+ if (!value.sameValue(targetDesc->value))
+ return scope.engine->throwTypeError();
+ }
+ if (attributes.isAccessor() && targetDesc->set.isUndefined())
+ return scope.engine->throwTypeError();
+ }
+ return true;
+}
+
+bool ProxyObject::virtualDeleteProperty(Managed *m, PropertyKey id)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString deleteProp(scope, scope.engine->newString(QStringLiteral("deleteProperty")));
+ ScopedValue trap(scope, handler->get(deleteProp));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->deleteProperty(id);
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ JSCallData cdata(scope, 3, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.toStringOrSymbol(scope.engine);
+ cdata.args[2] = o->d(); // ### fix receiver handling
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (!trapResult->toBoolean())
+ return false;
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
+ if (attributes == Attr_Invalid)
+ return true;
+ if (!attributes.isConfigurable())
+ return scope.engine->throwTypeError();
+ return true;
+}
+
+bool ProxyObject::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString hasProp(scope, scope.engine->newString(QStringLiteral("has")));
+ ScopedValue trap(scope, handler->get(hasProp));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->hasProperty(id);
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ JSCallData cdata(scope, 2, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ bool result = trapResult->toBoolean();
+ if (!result) {
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
+ if (attributes != Attr_Invalid) {
+ if (!attributes.isConfigurable() || !target->isExtensible())
+ return scope.engine->throwTypeError();
+ }
+ }
+ return result;
+}
+
+PropertyAttributes ProxyObject::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString deleteProp(scope, scope.engine->newString(QStringLiteral("getOwnPropertyDescriptor")));
+ ScopedValue trap(scope, handler->get(deleteProp));
+ if (scope.hasException())
+ return Attr_Invalid;
+ if (trap->isNullOrUndefined())
+ return target->getOwnProperty(id, p);
+ if (!trap->isFunctionObject()) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+
+ JSCallData cdata(scope, 2, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (!trapResult->isObject() && !trapResult->isUndefined()) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes targetAttributes = target->getOwnProperty(id, targetDesc);
+ if (trapResult->isUndefined()) {
+ p->value = Encode::undefined();
+ if (targetAttributes == Attr_Invalid) {
+ p->value = Encode::undefined();
+ return Attr_Invalid;
+ }
+ if (!targetAttributes.isConfigurable() || !target->isExtensible()) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+ return Attr_Invalid;
+ }
+
+ //bool extensibleTarget = target->isExtensible();
+ ScopedProperty resultDesc(scope);
+ PropertyAttributes resultAttributes;
+ ObjectPrototype::toPropertyDescriptor(scope.engine, trapResult, resultDesc, &resultAttributes);
+ resultDesc->completed(&resultAttributes);
+
+ if (!targetDesc->isCompatible(targetAttributes, resultDesc, resultAttributes)) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+
+ if (!resultAttributes.isConfigurable()) {
+ if (targetAttributes == Attr_Invalid || targetAttributes.isConfigurable()) {
+ scope.engine->throwTypeError();
+ return Attr_Invalid;
+ }
+ }
+
+ p->value = resultDesc->value;
+ p->set = resultDesc->set;
+ return resultAttributes;
+}
+
+bool ProxyObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString prop(scope, scope.engine->newString(QStringLiteral("defineProperty")));
+ ScopedValue trap(scope, handler->get(prop));
+ if (scope.hasException())
+ return false;
+ if (trap->isNullOrUndefined())
+ return target->defineOwnProperty(id, p, attrs);
+ if (!trap->isFunctionObject()) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+
+ JSCallData cdata(scope, 3, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
+ cdata.args[2] = ObjectPrototype::fromPropertyDescriptor(scope.engine, p, attrs);
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ bool result = trapResult->toBoolean();
+ if (!result)
+ return false;
+
+ ScopedProperty targetDesc(scope);
+ PropertyAttributes targetAttributes = target->getOwnProperty(id, targetDesc);
+ bool extensibleTarget = target->isExtensible();
+ bool settingConfigFalse = attrs.hasConfigurable() && !attrs.isConfigurable();
+ if (targetAttributes == Attr_Invalid) {
+ if (!extensibleTarget || settingConfigFalse) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ } else {
+ if (!targetDesc->isCompatible(targetAttributes, p, attrs)) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ if (settingConfigFalse && targetAttributes.isConfigurable()) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool ProxyObject::virtualIsExtensible(const Managed *m)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString hasProp(scope, scope.engine->newString(QStringLiteral("isExtensible")));
+ ScopedValue trap(scope, handler->get(hasProp));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->isExtensible();
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ JSCallData cdata(scope, 1, nullptr, handler);
+ cdata.args[0] = target;
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ bool result = trapResult->toBoolean();
+ if (result != target->isExtensible()) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ return result;
+}
+
+bool ProxyObject::virtualPreventExtensions(Managed *m)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString hasProp(scope, scope.engine->newString(QStringLiteral("preventExtensions")));
+ ScopedValue trap(scope, handler->get(hasProp));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->preventExtensions();
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ JSCallData cdata(scope, 1, nullptr, handler);
+ cdata.args[0] = target;
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ bool result = trapResult->toBoolean();
+ if (result && target->isExtensible()) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ return result;
+}
+
+Heap::Object *ProxyObject::virtualGetPrototypeOf(const Managed *m)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("getPrototypeOf")));
+ ScopedValue trap(scope, handler->get(name));
+ if (scope.hasException())
+ return nullptr;
+ if (trap->isNullOrUndefined())
+ return target->getPrototypeOf();
+ if (!trap->isFunctionObject()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ JSCallData cdata(scope, 1, nullptr, handler);
+ cdata.args[0] = target;
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (!trapResult->isNull() && !trapResult->isObject()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ Heap::Object *proto = trapResult->isNull() ? nullptr : static_cast<Heap::Object *>(trapResult->heapObject());
+ if (!target->isExtensible()) {
+ Heap::Object *targetProto = target->getPrototypeOf();
+ if (proto != targetProto) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ }
+ return proto;
+}
+
+bool ProxyObject::virtualSetPrototypeOf(Managed *m, const Object *p)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("setPrototypeOf")));
+ ScopedValue trap(scope, handler->get(name));
+ if (scope.hasException())
+ return false;
+ if (trap->isNullOrUndefined())
+ return target->setPrototypeOf(p);
+ if (!trap->isFunctionObject()) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+
+ JSCallData cdata(scope, 2, nullptr, handler);
+ cdata.args[0] = target;
+ cdata.args[1] = p ? p->asReturnedValue() : Encode::null();
+
+ ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ bool result = trapResult->toBoolean();
+ if (!result)
+ return false;
+ if (!target->isExtensible()) {
+ Heap::Object *targetProto = target->getPrototypeOf();
+ if (p->d() != targetProto) {
+ scope.engine->throwTypeError();
+ return false;
+ }
+ }
+ return true;
+}
+
+struct ProxyObjectOwnPropertyKeyIterator : OwnPropertyKeyIterator
+{
+ PersistentValue ownKeys;
+ uint index = 0;
+ uint len = 0;
+
+ ProxyObjectOwnPropertyKeyIterator(ArrayObject *keys);
+ ~ProxyObjectOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+ProxyObjectOwnPropertyKeyIterator::ProxyObjectOwnPropertyKeyIterator(ArrayObject *keys)
+{
+ ownKeys = keys;
+ len = keys->getLength();
+}
+
+PropertyKey ProxyObjectOwnPropertyKeyIterator::next(const Object *m, Property *pd, PropertyAttributes *attrs)
+{
+ if (index >= len)
+ return PropertyKey::invalid();
+
+ Scope scope(m);
+ ScopedObject keys(scope, ownKeys.asManaged());
+ PropertyKey key = PropertyKey::fromId(keys->get(PropertyKey::fromArrayIndex(index)));
+ ++index;
+
+ if (pd || attrs) {
+ ScopedProperty p(scope);
+ PropertyAttributes a = const_cast<Object *>(m)->getOwnProperty(key, pd ? pd : p);
+ if (attrs)
+ *attrs = a;
+ }
+
+ return key;
+}
+
+static bool removeAllOccurrences(ArrayObject *target, ReturnedValue val) {
+ uint len = target->getLength();
+ bool found = false;
+ for (uint i = 0; i < len; ++i) {
+ ReturnedValue v = target->get(i);
+ if (v == val) {
+ found = true;
+ target->put(i, Value::undefinedValue());
+ }
+ }
+ return found;
+}
+
+OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Value *iteratorTarget)
+{
+ Scope scope(m);
+ const ProxyObject *o = static_cast<const ProxyObject *>(m);
+ if (!o->d()->handler) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ ScopedObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("ownKeys")));
+ ScopedValue trap(scope, handler->get(name));
+
+ if (scope.hasException())
+ return nullptr;
+ if (trap->isUndefined())
+ return target->ownPropertyKeys(iteratorTarget);
+ if (!trap->isFunctionObject()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ JSCallData cdata(scope, 1, nullptr, handler);
+ cdata.args[0] = target;
+ ScopedObject trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (!trapResult) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ uint len = trapResult->getLength();
+ ScopedArrayObject trapKeys(scope, scope.engine->newArrayObject());
+ ScopedStringOrSymbol key(scope);
+ for (uint i = 0; i < len; ++i) {
+ key = trapResult->get(i);
+ if (scope.engine->hasException)
+ return nullptr;
+ if (!key) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ Value keyAsValue = Value::fromReturnedValue(key->toPropertyKey().id());
+ trapKeys->push_back(keyAsValue);
+ }
+
+ ScopedArrayObject targetConfigurableKeys(scope, scope.engine->newArrayObject());
+ ScopedArrayObject targetNonConfigurableKeys(scope, scope.engine->newArrayObject());
+ ObjectIterator it(scope, target, ObjectIterator::EnumerableOnly);
+ ScopedPropertyKey k(scope);
+ while (1) {
+ PropertyAttributes attrs;
+ k = it.next(nullptr, &attrs);
+ if (!k->isValid())
+ break;
+ Value keyAsValue = Value::fromReturnedValue(k->id());
+ if (attrs.isConfigurable())
+ targetConfigurableKeys->push_back(keyAsValue);
+ else
+ targetNonConfigurableKeys->push_back(keyAsValue);
+ }
+ if (target->isExtensible() && targetNonConfigurableKeys->getLength() == 0)
+ return new ProxyObjectOwnPropertyKeyIterator(trapKeys);
+
+ ScopedArrayObject uncheckedResultKeys(scope, scope.engine->newArrayObject());
+ uncheckedResultKeys->copyArrayData(trapKeys);
+
+ len = targetNonConfigurableKeys->getLength();
+ for (uint i = 0; i < len; ++i) {
+ k = PropertyKey::fromId(targetNonConfigurableKeys->get(i));
+ if (!removeAllOccurrences(uncheckedResultKeys, k->id())) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ }
+
+ if (target->isExtensible())
+ return new ProxyObjectOwnPropertyKeyIterator(trapKeys);
+
+ len = targetConfigurableKeys->getLength();
+ for (uint i = 0; i < len; ++i) {
+ k = PropertyKey::fromId(targetConfigurableKeys->get(i));
+ if (!removeAllOccurrences(uncheckedResultKeys, k->id())) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ }
+
+ len = uncheckedResultKeys->getLength();
+ for (uint i = 0; i < len; ++i) {
+ if (uncheckedResultKeys->get(i) != Encode::undefined()) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ }
+
+ *iteratorTarget = *m;
+ return new ProxyObjectOwnPropertyKeyIterator(trapKeys);
+}
+
+
+ReturnedValue ProxyFunctionObject::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ Scope scope(f);
+ const ProxyObject *o = static_cast<const ProxyObject *>(f);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("construct")));
+ ScopedValue trap(scope, handler->get(name));
+
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined()) {
+ Q_ASSERT(target->isConstructor());
+ return target->callAsConstructor(argv, argc, newTarget);
+ }
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject trapFunction(scope, trap);
+ Value *arguments = scope.alloc(3);
+ arguments[0] = target;
+ arguments[1] = scope.engine->newArrayObject(argv, argc);
+ arguments[2] = newTarget ? *newTarget : Value::undefinedValue();
+ ScopedObject result(scope, trapFunction->call(handler, arguments, 3));
+
+ if (!result)
+ return scope.engine->throwTypeError();
+ return result->asReturnedValue();
+}
+
+ReturnedValue ProxyFunctionObject::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+
+ const ProxyObject *o = static_cast<const ProxyObject *>(f);
+ if (!o->d()->handler)
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject target(scope, o->d()->target);
+ Q_ASSERT(target);
+ ScopedObject handler(scope, o->d()->handler);
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("apply")));
+ ScopedValue trap(scope, handler->get(name));
+
+ if (scope.hasException())
+ return Encode::undefined();
+ if (trap->isNullOrUndefined())
+ return target->call(thisObject, argv, argc);
+ if (!trap->isFunctionObject())
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject trapFunction(scope, trap);
+ Value *arguments = scope.alloc(3);
+ arguments[0] = target;
+ arguments[1] = thisObject ? *thisObject : Value::undefinedValue();
+ arguments[2] = scope.engine->newArrayObject(argv, argc);
+ return trapFunction->call(handler, arguments, 3);
+}
+
+DEFINE_OBJECT_VTABLE(Proxy);
+
+void Heap::Proxy::init(QV4::ExecutionContext *ctx)
+{
+ Heap::FunctionObject::init(ctx, QStringLiteral("Proxy"));
+
+ Scope scope(ctx);
+ Scoped<QV4::Proxy> ctor(scope, this);
+ ctor->defineDefaultProperty(QStringLiteral("revocable"), QV4::Proxy::method_revocable, 2);
+ ctor->defineReadonlyConfigurableProperty(scope.engine->id_length(), Value::fromInt32(2));
+}
+
+ReturnedValue Proxy::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
+{
+ Scope scope(f);
+ if (argc < 2 || !argv[0].isObject() || !argv[1].isObject())
+ return scope.engine->throwTypeError();
+
+ const Object *target = static_cast<const Object *>(argv);
+ const Object *handler = static_cast<const Object *>(argv + 1);
+ if (const ProxyObject *ptarget = target->as<ProxyObject>())
+ if (!ptarget->d()->handler)
+ return scope.engine->throwTypeError();
+ if (const ProxyObject *phandler = handler->as<ProxyObject>())
+ if (!phandler->d()->handler)
+ return scope.engine->throwTypeError();
+
+ const FunctionObject *targetFunction = target->as<FunctionObject>();
+ if (targetFunction)
+ return scope.engine->memoryManager->allocate<ProxyFunctionObject>(targetFunction, handler)->asReturnedValue();
+ return scope.engine->memoryManager->allocate<ProxyObject>(target, handler)->asReturnedValue();
+}
+
+ReturnedValue Proxy::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ return f->engine()->throwTypeError();
+}
+
+ReturnedValue Proxy::method_revocable(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedObject proxy(scope, Proxy::virtualCallAsConstructor(f, argv, argc, f));
+ if (scope.hasException())
+ return Encode::undefined();
+ Q_ASSERT(proxy);
+
+ ScopedString revoke(scope, scope.engine->newString(QStringLiteral("revoke")));
+ ScopedFunctionObject revoker(scope, scope.engine->memoryManager->allocate<FunctionObject>(scope.engine->rootContext(), nullptr, method_revoke));
+ revoker->defineReadonlyConfigurableProperty(scope.engine->id_length(), Value::fromInt32(0));
+ revoker->defineDefaultProperty(scope.engine->symbol_revokableProxy(), proxy);
+
+ ScopedObject o(scope, scope.engine->newObject());
+ ScopedString p(scope, scope.engine->newString(QStringLiteral("proxy")));
+ o->defineDefaultProperty(p, proxy);
+ o->defineDefaultProperty(revoke, revoker);
+ return o->asReturnedValue();
+}
+
+ReturnedValue Proxy::method_revoke(const FunctionObject *f, const Value *, const Value *, int)
+{
+ Scope scope(f);
+ ScopedObject o(scope, f->get(scope.engine->symbol_revokableProxy()));
+ Q_ASSERT(o);
+ ProxyObject *proxy = o->cast<ProxyObject>();
+
+ proxy->d()->target.set(scope.engine, nullptr);
+ proxy->d()->handler.set(scope.engine, nullptr);
+ return Encode::undefined();
+}
diff --git a/src/qml/jsruntime/qv4proxy_p.h b/src/qml/jsruntime/qv4proxy_p.h
new file mode 100644
index 0000000000..2ccb50ece6
--- /dev/null
+++ b/src/qml/jsruntime/qv4proxy_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4PROXY_P_H
+#define QV4PROXY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4functionobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+#define ProxyObjectMembers(class, Member) \
+ Member(class, Pointer, Object *, target) \
+ Member(class, Pointer, Object *, handler)
+
+DECLARE_HEAP_OBJECT(ProxyObject, FunctionObject) {
+ DECLARE_MARKOBJECTS(ProxyObject)
+
+ void init(const QV4::Object *target, const QV4::Object *handler);
+};
+
+struct ProxyFunctionObject : ProxyObject {
+ void init(const QV4::FunctionObject *target, const QV4::Object *handler);
+};
+
+#define ProxyMembers(class, Member) \
+ Member(class, Pointer, Symbol *, revokableProxySymbol) \
+
+DECLARE_HEAP_OBJECT(Proxy, FunctionObject) {
+ DECLARE_MARKOBJECTS(Proxy)
+
+ void init(QV4::ExecutionContext *ctx);
+};
+
+}
+
+/*
+ * The inheritance from FunctionObject is a hack. Regular proxy objects are no function objects.
+ * But this helps implement the proxy for function objects, where we need this and thus gives us
+ * all the virtual methods from ProxyObject without having to duplicate them.
+ *
+ * But it does require a few hacks to make sure we don't recognize regular proxy objects as function
+ * objects in the runtime.
+ */
+struct ProxyObject : FunctionObject {
+ V4_OBJECT2(ProxyObject, Object)
+ Q_MANAGED_TYPE(ProxyObject)
+ V4_INTERNALCLASS(ProxyObject)
+ enum {
+ IsFunctionObject = false
+ };
+
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static bool virtualDeleteProperty(Managed *m, PropertyKey id);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs);
+ static bool virtualIsExtensible(const Managed *m);
+ static bool virtualPreventExtensions(Managed *);
+ static Heap::Object *virtualGetPrototypeOf(const Managed *);
+ static bool virtualSetPrototypeOf(Managed *, const Object *);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *iteratorTarget);
+};
+
+struct ProxyFunctionObject : ProxyObject {
+ V4_OBJECT2(ProxyFunctionObject, FunctionObject)
+ Q_MANAGED_TYPE(ProxyObject)
+ V4_INTERNALCLASS(ProxyFunctionObject)
+ enum {
+ IsFunctionObject = true
+ };
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct Proxy : FunctionObject
+{
+ V4_OBJECT2(Proxy, FunctionObject)
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue method_revocable(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue method_revoke(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4ECMAOBJECTS_P_H
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index 040f060476..cc0b0feeee 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -65,8 +65,6 @@ DEFINE_MANAGED_VTABLE(QmlContext);
void Heap::QQmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject)
{
Object::init();
- readOnly = true;
- isNullWrapper = false;
this->context = new QQmlContextDataRef(context);
this->scopeObject.init(scopeObject);
}
@@ -78,30 +76,22 @@ void Heap::QQmlContextWrapper::destroy()
Object::destroy();
}
-ReturnedValue QQmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QQmlContextWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlContextWrapper>());
+
+ if (!id.isString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
const QQmlContextWrapper *resource = static_cast<const QQmlContextWrapper *>(m);
QV4::ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
- // In V8 the JS global object would come _before_ the QML global object,
- // so simulate that here.
- bool hasProp;
- QV4::ScopedValue result(scope, v4->globalObject->get(name, &hasProp));
- if (hasProp) {
- if (hasProperty)
- *hasProperty = hasProp;
- return result->asReturnedValue();
- }
-
- if (resource->d()->isNullWrapper)
- return Object::get(m, name, hasProperty);
-
if (v4->callingQmlContext() != *resource->d()->context)
- return Object::get(m, name, hasProperty);
+ return Object::virtualGet(m, id, receiver, hasProperty);
- result = Object::get(m, name, &hasProp);
+ bool hasProp = false;
+ ScopedValue result(scope, Object::virtualGet(m, id, receiver, &hasProp));
if (hasProp) {
if (hasProperty)
*hasProperty = hasProp;
@@ -129,6 +119,38 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, String *name, bool *hasP
QObject *scopeObject = resource->getScopeObject();
+ ScopedString name(scope, id.asStringOrSymbol());
+
+ const auto performGobalLookUp = [&result, v4, &name, hasProperty]() {
+ bool hasProp = false;
+ result = v4->globalObject->get(name, &hasProp);
+ if (hasProp) {
+ if (hasProperty)
+ *hasProperty = hasProp;
+ return true;
+ }
+ return false;
+ };
+
+ // If the scope object is a QAbstractDynamicMetaObject, then QMetaObject::indexOfProperty
+ // will call createProperty() on the QADMO and implicitly create the property. While that
+ // is questionable behavior, there are two use-cases that we support in the light of this:
+ //
+ // (1) The implicit creation of properties is necessary because it will also result in
+ // a recorded capture, which will allow a re-evaluation of bindings when the value
+ // is populated later. See QTBUG-35233 and the test-case in tst_qqmlpropertymap.
+ //
+ // (1) Looking up "console" in order to place a console.log() call for example must
+ // find the console instead of creating a new property. Therefore we prioritize the
+ // lookup in the global object here.
+ //
+ // Note: The scope object is only a QADMO for example when somebody registers a QQmlPropertyMap
+ // sub-class as QML type and then instantiates it in .qml.
+ if (scopeObject && QQmlPropertyCache::isDynamicMetaObject(scopeObject->metaObject())) {
+ if (performGobalLookUp())
+ return result->asReturnedValue();
+ }
+
if (context->imports && name->startsWithUpper()) {
// Search for attached properties, enums and imported scripts
QQmlTypeNameCache::Result r = context->imports->query(name, QQmlImport::AllowRecursion);
@@ -139,7 +161,7 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, String *name, bool *hasP
if (r.scriptIndex != -1) {
QV4::ScopedObject scripts(scope, context->importedScripts.valueRef());
if (scripts)
- return scripts->getIndexed(r.scriptIndex);
+ return scripts->get(r.scriptIndex);
return QV4::Encode::null();
} else if (r.type.isValid()) {
return QQmlTypeWrapper::create(v4, scopeObject, r.type);
@@ -219,14 +241,23 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, String *name, bool *hasP
context = context->parent;
}
+ // Do a lookup in the global object here to avoid expressionContext->unresolvedNames becoming
+ // true if we access properties of the global object.
+ if (performGobalLookUp())
+ return result->asReturnedValue();
+
expressionContext->unresolvedNames = true;
return Encode::undefined();
}
-bool QQmlContextWrapper::put(Managed *m, String *name, const Value &value)
+bool QQmlContextWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
Q_ASSERT(m->as<QQmlContextWrapper>());
+
+ if (id.isSymbol() || id.isArrayIndex())
+ return Object::virtualPut(m, id, value, receiver);
+
QQmlContextWrapper *resource = static_cast<QQmlContextWrapper *>(m);
ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
@@ -234,21 +265,9 @@ bool QQmlContextWrapper::put(Managed *m, String *name, const Value &value)
return false;
QV4::Scoped<QQmlContextWrapper> wrapper(scope, resource);
- uint member = wrapper->internalClass()->find(name);
- if (member < UINT_MAX)
- return wrapper->putValue(member, value);
-
- if (wrapper->d()->isNullWrapper) {
- if (wrapper && wrapper->d()->readOnly) {
- QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
- QLatin1Char('"');
- ScopedString e(scope, v4->newString(error));
- v4->throwError(e);
- return false;
- }
-
- return Object::put(m, name, value);
- }
+ auto member = wrapper->internalClass()->findValueOrSetter(id);
+ if (member.index < UINT_MAX)
+ return wrapper->putValue(member.index, member.attrs, value);
// It's possible we could delay the calculation of the "actual" context (in the case
// of sub contexts) until it is definitely needed.
@@ -261,6 +280,7 @@ bool QQmlContextWrapper::put(Managed *m, String *name, const Value &value)
// See QV8ContextWrapper::Getter for resolution order
QObject *scopeObject = wrapper->getScopeObject();
+ ScopedString name(scope, id.asStringOrSymbol());
while (context) {
const QV4::IdentifierHash &properties = context->propertyNames();
@@ -284,14 +304,10 @@ bool QQmlContextWrapper::put(Managed *m, String *name, const Value &value)
expressionContext->unresolvedNames = true;
- if (wrapper->d()->readOnly) {
- QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
- QLatin1Char('"');
- v4->throwError(error);
- return false;
- }
-
- return Object::put(m, name, value);
+ QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
+ QLatin1Char('"');
+ v4->throwError(error);
+ return false;
}
void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContextWrapper *qml)
@@ -302,35 +318,11 @@ void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContex
this->activation.set(internalClass->engine, qml->d());
}
-Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, const QUrl &source, Value *sendFunction)
-{
- Scope scope(parent);
-
- QQmlContextData *context = new QQmlContextData;
- context->baseUrl = source;
- context->baseUrlString = source.toString();
- context->isInternal = true;
- context->isJSContext = true;
-
- Scoped<QQmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QQmlContextWrapper>(context, (QObject*)nullptr));
- qml->d()->isNullWrapper = true;
-
- qml->setReadOnly(false);
- QV4::ScopedObject api(scope, scope.engine->newObject());
- api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), *sendFunction);
- qml->QV4::Object::put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api);
- qml->setReadOnly(true);
-
- Heap::QmlContext *c = scope.engine->memoryManager->alloc<QmlContext>(parent, qml);
- Q_ASSERT(c->vtable() == staticVTable());
- return c;
-}
-
Heap::QmlContext *QmlContext::create(ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject)
{
Scope scope(parent);
- Scoped<QQmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QQmlContextWrapper>(context, scopeObject));
+ Scoped<QQmlContextWrapper> qml(scope, scope.engine->memoryManager->allocate<QQmlContextWrapper>(context, scopeObject));
Heap::QmlContext *c = scope.engine->memoryManager->alloc<QmlContext>(parent, qml);
Q_ASSERT(c->vtable() == staticVTable());
return c;
diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h
index 647bef7fc1..4fe34a0a06 100644
--- a/src/qml/jsruntime/qv4qmlcontext_p.h
+++ b/src/qml/jsruntime/qv4qmlcontext_p.h
@@ -69,8 +69,6 @@ namespace Heap {
struct QQmlContextWrapper : Object {
void init(QQmlContextData *context, QObject *scopeObject);
void destroy();
- bool readOnly;
- bool isNullWrapper;
QQmlContextDataRef *context;
QQmlQPointer<QObject> scopeObject;
@@ -96,10 +94,8 @@ struct Q_QML_EXPORT QQmlContextWrapper : Object
inline QObject *getScopeObject() const { return d()->scopeObject; }
inline QQmlContextData *getContext() const { return *d()->context; }
- void setReadOnly(bool b) { d()->readOnly = b; }
-
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
};
struct Q_QML_EXPORT QmlContext : public ExecutionContext
@@ -107,7 +103,6 @@ struct Q_QML_EXPORT QmlContext : public ExecutionContext
V4_MANAGED(QmlContext, ExecutionContext)
V4_INTERNALCLASS(QmlContext)
- static Heap::QmlContext *createWorkerContext(QV4::ExecutionContext *parent, const QUrl &source, Value *sendFunction);
static Heap::QmlContext *create(QV4::ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject);
QObject *qmlScope() const {
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index d63d42478a..2e4223de7d 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -56,7 +56,11 @@
#include <private/qv4functionobject_p.h>
#include <private/qv4runtime_p.h>
#include <private/qv4variantobject_p.h>
+
+#if QT_CONFIG(qml_sequence_object)
#include <private/qv4sequenceobject_p.h>
+#endif
+
#include <private/qv4objectproto_p.h>
#include <private/qv4jsonobject_p.h>
#include <private/qv4regexpobject_p.h>
@@ -181,11 +185,13 @@ static QV4::ReturnedValue loadProperty(QV4::ExecutionEngine *v4, QObject *object
if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property.propType()))
return QV4::QQmlValueTypeWrapper::create(v4, object, property.coreIndex(), valueTypeMetaObject, property.propType());
} else {
+#if QT_CONFIG(qml_sequence_object)
// see if it's a sequence type
bool succeeded = false;
- QV4::ScopedValue retn(scope, QV4::SequencePrototype::newSequence(v4, property.propType(), object, property.coreIndex(), &succeeded));
+ QV4::ScopedValue retn(scope, QV4::SequencePrototype::newSequence(v4, property.propType(), object, property.coreIndex(), !property.isWritable(), &succeeded));
if (succeeded)
return retn->asReturnedValue();
+#endif
}
if (property.propType() == QMetaType::UnknownType) {
@@ -242,7 +248,7 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje
return QV4::QObjectMethod::create(global, object, property->coreIndex());
} else if (property->isSignalHandler()) {
QmlSignalHandler::initProto(engine);
- return engine->memoryManager->allocObject<QV4::QmlSignalHandler>(object, property->coreIndex())->asReturnedValue();
+ return engine->memoryManager->allocate<QV4::QmlSignalHandler>(object, property->coreIndex())->asReturnedValue();
} else {
ExecutionContext *global = engine->rootContext();
return QV4::QObjectMethod::create(global, object, property->coreIndex());
@@ -308,7 +314,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
}
}
}
- return QV4::Object::get(this, name, hasProperty);
+ return QV4::Object::virtualGet(this, name->propertyKey(), this, hasProperty);
}
QQmlData *ddata = QQmlData::get(d()->object(), false);
@@ -661,7 +667,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, int p
return setProperty(engine, object, property, value);
}
-bool QObjectWrapper::isEqualTo(Managed *a, Managed *b)
+bool QObjectWrapper::virtualIsEqualTo(Managed *a, Managed *b)
{
Q_ASSERT(a->as<QV4::QObjectWrapper>());
QV4::QObjectWrapper *qobjectWrapper = static_cast<QV4::QObjectWrapper *>(a);
@@ -684,70 +690,92 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
return result;
}
}
- return (engine->memoryManager->allocObject<QV4::QObjectWrapper>(object))->asReturnedValue();
+ return (engine->memoryManager->allocate<QV4::QObjectWrapper>(object))->asReturnedValue();
}
-QV4::ReturnedValue QObjectWrapper::get(const Managed *m, String *name, bool *hasProperty)
+QV4::ReturnedValue QObjectWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
+ if (!id.isString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
+ Scope scope(that);
+ ScopedString n(scope, id.asStringOrSymbol());
QQmlContextData *qmlContext = that->engine()->callingQmlContext();
- return that->getQmlProperty(qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
+ return that->getQmlProperty(qmlContext, n, IgnoreRevision, hasProperty, /*includeImports*/ true);
}
-bool QObjectWrapper::put(Managed *m, String *name, const Value &value)
+bool QObjectWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
+ if (!id.isString())
+ return Object::virtualPut(m, id, value, receiver);
+
+ Scope scope(m);
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
- ExecutionEngine *v4 = that->engine();
+ ScopedString name(scope, id.asStringOrSymbol());
- if (v4->hasException || QQmlData::wasDeleted(that->d()->object()))
+ if (scope.engine->hasException || QQmlData::wasDeleted(that->d()->object()))
return false;
- QQmlContextData *qmlContext = v4->callingQmlContext();
- if (!setQmlProperty(v4, qmlContext, that->d()->object(), name, QV4::QObjectWrapper::IgnoreRevision, value)) {
+ QQmlContextData *qmlContext = scope.engine->callingQmlContext();
+ if (!setQmlProperty(scope.engine, qmlContext, that->d()->object(), name, QV4::QObjectWrapper::IgnoreRevision, value)) {
QQmlData *ddata = QQmlData::get(that->d()->object());
// Types created by QML are not extensible at run-time, but for other QObjects we can store them
// as regular JavaScript properties, like on JavaScript objects.
if (ddata && ddata->context) {
QString error = QLatin1String("Cannot assign to non-existent property \"") +
name->toQString() + QLatin1Char('\"');
- v4->throwError(error);
+ scope.engine->throwError(error);
return false;
} else {
- return QV4::Object::put(m, name, value);
+ return QV4::Object::virtualPut(m, id, value, receiver);
}
}
return true;
}
-PropertyAttributes QObjectWrapper::query(const Managed *m, String *name)
+PropertyAttributes QObjectWrapper::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
{
- const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
- const QObject *thatObject = that->d()->object();
- if (QQmlData::wasDeleted(thatObject))
- return QV4::Object::query(m, name);
+ if (id.isString()) {
+ const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
+ const QObject *thatObject = that->d()->object();
+ if (!QQmlData::wasDeleted(thatObject)) {
+ Scope scope(m);
+ ScopedString n(scope, id.asStringOrSymbol());
+ QQmlContextData *qmlContext = scope.engine->callingQmlContext();
+ QQmlPropertyData local;
+ if (that->findProperty(scope.engine, qmlContext, n, IgnoreRevision, &local)
+ || n->equals(scope.engine->id_destroy()) || n->equals(scope.engine->id_toString())) {
+ if (p) {
+ // ### probably not the fastest implementation
+ bool hasProperty;
+ p->value = that->getQmlProperty(qmlContext, n, IgnoreRevision, &hasProperty, /*includeImports*/ true);
+ }
+ return QV4::Attr_Data;
+ }
+ }
+ }
- ExecutionEngine *engine = that->engine();
- QQmlContextData *qmlContext = engine->callingQmlContext();
- QQmlPropertyData local;
- if (that->findProperty(engine, qmlContext, name, IgnoreRevision, &local)
- || name->equals(engine->id_destroy()) || name->equals(engine->id_toString()))
- return QV4::Attr_Data;
- else
- return QV4::Object::query(m, name);
+ return QV4::Object::virtualGetOwnProperty(m, id, p);
}
-void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
+struct QObjectWrapperOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
+{
+ int propertyIndex = 0;
+ ~QObjectWrapperOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey QObjectWrapperOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
{
// Used to block access to QObject::destroyed() and QObject::deleteLater() from QML
static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)");
static const int destroyedIdx2 = QObject::staticMetaObject.indexOfSignal("destroyed()");
static const int deleteLaterIdx = QObject::staticMetaObject.indexOfSlot("deleteLater()");
- name->setM(nullptr);
- *index = UINT_MAX;
-
- QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
+ const QObjectWrapper *that = static_cast<const QObjectWrapper*>(o);
QObject *thatObject = that->d()->object();
if (thatObject && !QQmlData::wasDeleted(thatObject)) {
@@ -755,40 +783,50 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name
// These indices don't apply to gadgets, so don't block them.
const bool preventDestruction = mo->superClass() || mo == &QObject::staticMetaObject;
const int propertyCount = mo->propertyCount();
- if (it->arrayIndex < static_cast<uint>(propertyCount)) {
+ if (propertyIndex < propertyCount) {
ExecutionEngine *thatEngine = that->engine();
Scope scope(thatEngine);
- const QMetaProperty property = mo->property(it->arrayIndex);
+ const QMetaProperty property = mo->property(propertyIndex);
ScopedString propName(scope, thatEngine->newString(QString::fromUtf8(property.name())));
- name->setM(propName->d());
- ++it->arrayIndex;
- *attributes = QV4::Attr_Data;
-
- QQmlPropertyData local;
- local.load(property);
- p->value = that->getProperty(thatEngine, thatObject, &local);
- return;
+ ++propertyIndex;
+ if (attrs)
+ *attrs= QV4::Attr_Data;
+ if (pd) {
+ QQmlPropertyData local;
+ local.load(property);
+ pd->value = that->getProperty(thatEngine, thatObject, &local);
+ }
+ return propName->toPropertyKey();
}
const int methodCount = mo->methodCount();
- while (it->arrayIndex < static_cast<uint>(propertyCount + methodCount)) {
- const int index = it->arrayIndex - propertyCount;
+ while (propertyIndex < propertyCount + methodCount) {
+ Q_ASSERT(propertyIndex >= propertyCount);
+ int index = propertyIndex - propertyCount;
const QMetaMethod method = mo->method(index);
- ++it->arrayIndex;
+ ++propertyIndex;
if (method.access() == QMetaMethod::Private || (preventDestruction && (index == deleteLaterIdx || index == destroyedIdx1 || index == destroyedIdx2)))
continue;
ExecutionEngine *thatEngine = that->engine();
Scope scope(thatEngine);
ScopedString methodName(scope, thatEngine->newString(QString::fromUtf8(method.name())));
- name->setM(methodName->d());
- *attributes = QV4::Attr_Data;
-
- QQmlPropertyData local;
- local.load(method);
- p->value = that->getProperty(thatEngine, thatObject, &local);
- return;
+ if (attrs)
+ *attrs = QV4::Attr_Data;
+ if (pd) {
+ QQmlPropertyData local;
+ local.load(method);
+ pd->value = that->getProperty(thatEngine, thatObject, &local);
+ }
+ return methodName->toPropertyKey();
}
}
- QV4::Object::advanceIterator(m, it, name, index, p, attributes);
+
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *QObjectWrapper::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new QObjectWrapperOwnPropertyKeyIterator;
}
namespace QV4 {
@@ -1619,6 +1657,7 @@ void CallArgument::initAsType(int callType)
}
}
+#if QT_CONFIG(qml_sequence_object)
template <class T, class M>
void CallArgument::fromContainerValue(const QV4::Object *object, int callType, M CallArgument::*member, bool &queryEngine)
{
@@ -1631,6 +1670,7 @@ void CallArgument::fromContainerValue(const QV4::Object *object, int callType, M
}
}
}
+#endif
void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const QV4::Value &value)
{
@@ -1685,7 +1725,7 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q
uint length = array->getLength();
for (uint ii = 0; ii < length; ++ii) {
QObject *o = nullptr;
- qobjectWrapper = array->getIndexed(ii);
+ qobjectWrapper = array->get(ii);
if (!!qobjectWrapper)
o = qobjectWrapper->object();
qlistPtr->append(o);
@@ -1713,6 +1753,7 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q
type = callType;
} else if (callType == QMetaType::Void) {
*qvariantPtr = QVariant();
+#if QT_CONFIG(qml_sequence_object)
} else if (callType == qMetaTypeId<std::vector<int>>()
|| callType == qMetaTypeId<std::vector<qreal>>()
|| callType == qMetaTypeId<std::vector<bool>>()
@@ -1740,6 +1781,7 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q
stdVectorQModelIndexPtr = nullptr;
fromContainerValue<std::vector<QModelIndex>>(object, callType, &CallArgument::stdVectorQModelIndexPtr, queryEngine);
}
+#endif
} else {
queryEngine = true;
}
@@ -1833,7 +1875,7 @@ QV4::ReturnedValue CallArgument::toValue(QV4::ExecutionEngine *engine)
ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index)
{
Scope valueScope(scope);
- Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope));
+ Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocate<QObjectMethod>(scope));
method->d()->setObject(object);
if (QQmlData *ddata = QQmlData::get(object))
@@ -1846,7 +1888,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in
ReturnedValue QObjectMethod::create(ExecutionContext *scope, const QQmlValueTypeWrapper *valueType, int index)
{
Scope valueScope(scope);
- Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope));
+ Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocate<QObjectMethod>(scope));
method->d()->setPropertyCache(valueType->d()->propertyCache());
method->d()->index = index;
method->d()->valueTypeWrapper.set(valueScope.engine, valueType->d());
@@ -1906,7 +1948,7 @@ QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionEngine *engine, c
return Encode::undefined();
}
-ReturnedValue QObjectMethod::call(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue QObjectMethod::virtualCall(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc)
{
const QObjectMethod *This = static_cast<const QObjectMethod*>(m);
return This->callInternal(thisObject, argv, argc);
@@ -1961,7 +2003,7 @@ ReturnedValue QObjectMethod::callInternal(const Value *thisObject, const Value *
CallData *callData = cData.callData();
if (method.isV4Function()) {
- QV4::ScopedValue rv(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue rv(scope, QV4::Value::undefinedValue());
QQmlV4Function func(callData, rv, v4);
QQmlV4Function *funcptr = &func;
@@ -2019,7 +2061,7 @@ void Heap::QMetaObjectWrapper::ensureConstructorsCache() {
ReturnedValue QMetaObjectWrapper::create(ExecutionEngine *engine, const QMetaObject* metaObject) {
QV4::Scope scope(engine);
- Scoped<QMetaObjectWrapper> mo(scope, engine->memoryManager->allocObject<QV4::QMetaObjectWrapper>(metaObject)->asReturnedValue());
+ Scoped<QMetaObjectWrapper> mo(scope, engine->memoryManager->allocate<QV4::QMetaObjectWrapper>(metaObject)->asReturnedValue());
mo->init(engine);
return mo->asReturnedValue();
}
@@ -2032,12 +2074,12 @@ void QMetaObjectWrapper::init(ExecutionEngine *) {
for (int k = 0; k < Enum.keyCount(); k++) {
const char* key = Enum.key(k);
const int value = Enum.value(k);
- defineReadonlyProperty(QLatin1String(key), Primitive::fromInt32(value));
+ defineReadonlyProperty(QLatin1String(key), Value::fromInt32(value));
}
}
}
-ReturnedValue QMetaObjectWrapper::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue QMetaObjectWrapper::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
{
const QMetaObjectWrapper *This = static_cast<const QMetaObjectWrapper*>(f);
return This->constructInternal(argv, argc);
@@ -2068,7 +2110,7 @@ ReturnedValue QMetaObjectWrapper::constructInternal(const Value *argv, int argc)
}
Scoped<QMetaObjectWrapper> metaObject(scope, this);
object->defineDefaultProperty(v4->id_constructor(), metaObject);
- object->setPrototype(const_cast<QMetaObjectWrapper*>(this));
+ object->setPrototypeOf(const_cast<QMetaObjectWrapper*>(this));
return object.asReturnedValue();
}
@@ -2143,7 +2185,7 @@ ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine
}
}
-bool QMetaObjectWrapper::isEqualTo(Managed *a, Managed *b)
+bool QMetaObjectWrapper::virtualIsEqualTo(Managed *a, Managed *b)
{
Q_ASSERT(a->as<QMetaObjectWrapper>());
QMetaObjectWrapper *aMetaObject = a->as<QMetaObjectWrapper>();
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 1455acc1b3..be46245d5a 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -182,21 +182,20 @@ struct Q_QML_EXPORT QObjectWrapper : public Object
void destroyObject(bool lastCall);
-protected:
- static bool isEqualTo(Managed *that, Managed *o);
-
static ReturnedValue getProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property, bool captureRequired = true);
+protected:
static void setProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property, const Value &value);
+ static bool virtualIsEqualTo(Managed *that, Managed *o);
static ReturnedValue create(ExecutionEngine *engine, QObject *object);
static QQmlPropertyData *findProperty(ExecutionEngine *engine, QObject *o, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local);
QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
- static PropertyAttributes query(const Managed *, String *name);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
static ReturnedValue method_connect(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_disconnect(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -237,7 +236,7 @@ struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject
QV4::ReturnedValue method_toString(QV4::ExecutionEngine *engine) const;
QV4::ReturnedValue method_destroy(QV4::ExecutionEngine *ctx, const Value *args, int argc) const;
- static ReturnedValue call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
ReturnedValue callInternal(const Value *thisObject, const Value *argv, int argc) const;
@@ -251,11 +250,12 @@ struct Q_QML_EXPORT QMetaObjectWrapper : public QV4::FunctionObject
V4_NEEDS_DESTROY
static ReturnedValue create(ExecutionEngine *engine, const QMetaObject* metaObject);
- static ReturnedValue callAsConstructor(const FunctionObject *, const Value *argv, int argc);
- static bool isEqualTo(Managed *a, Managed *b);
-
const QMetaObject *metaObject() const { return d()->metaObject; }
+protected:
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *);
+ static bool virtualIsEqualTo(Managed *a, Managed *b);
+
private:
void init(ExecutionEngine *engine);
ReturnedValue constructInternal(const Value *argv, int argc) const;
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
new file mode 100644
index 0000000000..15dcb602eb
--- /dev/null
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qv4reflect_p.h"
+#include "qv4symbol_p.h"
+#include "qv4runtimeapi_p.h"
+#include "qv4objectproto_p.h"
+#include "qv4propertykey_p.h"
+#include "qv4objectiterator_p.h"
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(Reflect);
+
+void Heap::Reflect::init()
+{
+ Object::init();
+ Scope scope(internalClass->engine);
+ ScopedObject r(scope, this);
+
+ r->defineDefaultProperty(QStringLiteral("apply"), QV4::Reflect::method_apply, 3);
+ r->defineDefaultProperty(QStringLiteral("construct"), QV4::Reflect::method_construct, 2);
+ r->defineDefaultProperty(QStringLiteral("defineProperty"), QV4::Reflect::method_defineProperty, 3);
+ r->defineDefaultProperty(QStringLiteral("deleteProperty"), QV4::Reflect::method_deleteProperty, 2);
+ r->defineDefaultProperty(QStringLiteral("get"), QV4::Reflect::method_get, 2);
+ r->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), QV4::Reflect::method_getOwnPropertyDescriptor, 2);
+ r->defineDefaultProperty(QStringLiteral("getPrototypeOf"), QV4::Reflect::method_getPrototypeOf, 1);
+ r->defineDefaultProperty(QStringLiteral("has"), QV4::Reflect::method_has, 2);
+ r->defineDefaultProperty(QStringLiteral("isExtensible"), QV4::Reflect::method_isExtensible, 1);
+ r->defineDefaultProperty(QStringLiteral("ownKeys"), QV4::Reflect::method_ownKeys, 1);
+ r->defineDefaultProperty(QStringLiteral("preventExtensions"), QV4::Reflect::method_preventExtensions, 1);
+ r->defineDefaultProperty(QStringLiteral("set"), QV4::Reflect::method_set, 3);
+ r->defineDefaultProperty(QStringLiteral("setPrototypeOf"), QV4::Reflect::method_setPrototypeOf, 2);
+}
+
+struct CallArgs {
+ Value *argv;
+ int argc;
+};
+
+static CallArgs createListFromArrayLike(Scope &scope, const Object *o)
+{
+ int len = o->getLength();
+ Value *arguments = scope.alloc(len);
+
+ for (int i = 0; i < len; ++i) {
+ arguments[i] = o->get(i);
+ if (scope.hasException())
+ return { nullptr, 0 };
+ }
+ return { arguments, len };
+}
+
+ReturnedValue Reflect::method_apply(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (argc < 3 || !argv[0].isFunctionObject() || !argv[2].isObject())
+ return scope.engine->throwTypeError();
+
+ const Object *o = static_cast<const Object *>(argv + 2);
+ CallArgs arguments = createListFromArrayLike(scope, o);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ return static_cast<const FunctionObject &>(argv[0]).call(&argv[1], arguments.argv, arguments.argc);
+}
+
+ReturnedValue Reflect::method_construct(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (argc < 2 || !argv[1].isObject())
+ return scope.engine->throwTypeError();
+ const FunctionObject *target = argv[0].as<FunctionObject>();
+ const FunctionObject *newTarget = argc == 3 ? argv[2].as<FunctionObject>() : target;
+ if (!target || !target->isConstructor() || !newTarget || !newTarget->isConstructor())
+ return scope.engine->throwTypeError();
+
+ const Object *o = static_cast<const Object *>(argv + 1);
+ CallArgs arguments = createListFromArrayLike(scope, o);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ return target->callAsConstructor(arguments.argv, arguments.argc, newTarget);
+}
+
+ReturnedValue Reflect::method_defineProperty(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc || !argv[0].isObject())
+ return scope.engine->throwTypeError();
+
+ ScopedObject O(scope, argv[0]);
+ ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine));
+ if (scope.engine->hasException)
+ return QV4::Encode::undefined();
+
+ ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue());
+ ScopedProperty pd(scope);
+ PropertyAttributes attrs;
+ ObjectPrototype::toPropertyDescriptor(scope.engine, attributes, pd, &attrs);
+ if (scope.engine->hasException)
+ return QV4::Encode::undefined();
+
+ bool result = O->defineOwnProperty(name, pd, attrs);
+
+ return Encode(result);
+}
+
+ReturnedValue Reflect::method_deleteProperty(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ ExecutionEngine *e = f->engine();
+ if (!argc || !argv[0].isObject())
+ return e->throwTypeError();
+
+ bool result = Runtime::method_deleteProperty(e, argv[0], argc > 1 ? argv[1] : Value::undefinedValue());
+ return Encode(result);
+}
+
+ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc || !argv[0].isObject())
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ Value undef = Value::undefinedValue();
+ const Value *index = argc > 1 ? &argv[1] : &undef;
+ ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ ScopedValue receiver(scope, argc > 2 ? argv[2] : *o);
+
+ return Encode(o->get(name, receiver));
+}
+
+ReturnedValue Reflect::method_getOwnPropertyDescriptor(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ if (!argc || !argv[0].isObject())
+ return f->engine()->throwTypeError();
+
+ return ObjectPrototype::method_getOwnPropertyDescriptor(f, thisObject, argv, argc);
+}
+
+ReturnedValue Reflect::method_getPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ if (!argc || !argv[0].isObject())
+ return f->engine()->throwTypeError();
+
+ const Object *o = static_cast<const Object *>(argv);
+ Heap::Object *p = o->getPrototypeOf();
+ return (p ? p->asReturnedValue() : Encode::null());
+}
+
+ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc || !argv[0].isObject())
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ Value undef = Value::undefinedValue();
+ const Value *index = argc > 1 ? &argv[1] : &undef;
+
+ ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine));
+ if (scope.engine->hasException)
+ return false;
+
+ return Encode(o->hasProperty(name));
+}
+
+ReturnedValue Reflect::method_isExtensible(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ if (!argc || !argv[0].isObject())
+ return f->engine()->throwTypeError();
+
+ const Object *o = static_cast<const Object *>(argv);
+ return Encode(o->isExtensible());
+}
+
+
+ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ if (!argc || !argv[0].isObject())
+ return f->engine()->throwTypeError();
+
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject O(scope, argv[0].toObject(scope.engine));
+ if (!O)
+ return Encode::undefined();
+
+ ScopedArrayObject keys(scope, scope.engine->newArrayObject());
+
+ ObjectIterator it(scope, O, ObjectIterator::WithSymbols);
+ ScopedPropertyKey key(scope);
+ ScopedValue v(scope);
+ while (1) {
+ key = it.next();
+ if (!key->isValid())
+ break;
+ v = key->toStringOrSymbol(scope.engine);
+ keys->push_back(v);
+ }
+
+ return keys->asReturnedValue();
+
+}
+
+ReturnedValue Reflect::method_preventExtensions(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc || !argv[0].isObject())
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ return Encode(o->preventExtensions());
+}
+
+ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc || !argv[0].isObject())
+ return scope.engine->throwTypeError();
+
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ Value undef = Value::undefinedValue();
+ const Value *index = argc > 1 ? &argv[1] : &undef;
+ const Value &val = argc > 2 ? argv[2] : undef;
+ ScopedValue receiver(scope, argc >3 ? argv[3] : argv[0]);
+
+ ScopedPropertyKey propertyKey(scope, index->toPropertyKey(scope.engine));
+ if (scope.engine->hasException)
+ return false;
+ bool result = o->put(propertyKey, val, receiver);
+ return Encode(result);
+}
+
+ReturnedValue Reflect::method_setPrototypeOf(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ if (argc < 2 || !argv[0].isObject() || (!argv[1].isNull() && !argv[1].isObject()))
+ return f->engine()->throwTypeError();
+
+ Scope scope(f);
+ ScopedObject o(scope, static_cast<const Object *>(argv));
+ const Object *proto = argv[1].isNull() ? nullptr : static_cast<const Object *>(argv + 1);
+ return Encode(o->setPrototypeOf(proto));
+}
diff --git a/src/qml/jsruntime/qv4reflect_p.h b/src/qml/jsruntime/qv4reflect_p.h
new file mode 100644
index 0000000000..d480e1d914
--- /dev/null
+++ b/src/qml/jsruntime/qv4reflect_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4REFLECT_H
+#define QV4REFLECT_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+struct Reflect : Object {
+ void init();
+};
+
+}
+
+struct Reflect : Object {
+ V4_OBJECT2(Reflect, Object)
+
+ static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_construct(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_defineProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_deleteProperty(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getOwnPropertyDescriptor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_getPrototypeOf(const FunctionObject *, const Value *, const Value *argv, int argc);
+ static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_isExtensible(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_ownKeys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_preventExtensions(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_setPrototypeOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index e10493b879..05c3b4c4ca 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -41,6 +41,7 @@
#include "qv4engine_p.h"
#include "qv4scopedvalue_p.h"
#include <private/qv4mm_p.h>
+#include <runtime/VM.h>
using namespace QV4;
@@ -62,16 +63,92 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets)
WTF::String s(string);
#if ENABLE(YARR_JIT)
- if (d()->hasValidJITCode())
+ if (d()->hasValidJITCode()) {
+#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
+ char buffer[8192];
+ return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets, buffer, 8192).start);
+#else
return uint(jitCode()->execute(s.characters16(), start, s.length(), (int*)matchOffsets).start);
#endif
+ }
+#endif
return JSC::Yarr::interpret(byteCode(), s.characters16(), string.length(), start, matchOffsets);
}
-Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline, bool global)
+QString RegExp::getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement)
+{
+ QString result;
+
+ int matchedLength = matched.length();
+ Q_ASSERT(position >= 0 && position <= str.length());
+ int tailPos = position + matchedLength;
+ int seenDollar = -1;
+ for (int i = 0; i < replacement.length(); ++i) {
+ QChar ch = replacement.at(i);
+ if (seenDollar >= 0) {
+ if (ch.unicode() == '$') {
+ result += QLatin1Char('$');
+ } else if (ch.unicode() == '&') {
+ result += matched;
+ } else if (ch.unicode() == '`') {
+ result += str.left(position);
+ } else if (ch.unicode() == '\'') {
+ result += str.mid(tailPos);
+ } else if (ch.unicode() >= '0' && ch.unicode() <= '9') {
+ int n = ch.unicode() - '0';
+ if (i + 1 < replacement.length()) {
+ ch = replacement.at(i + 1);
+ if (ch.unicode() >= '0' && ch.unicode() <= '9') {
+ n = n*10 + (ch.unicode() - '0');
+ ++i;
+ }
+ }
+ if (n > 0 && n <= nCaptures) {
+ String *s = captures[n].stringValue();
+ if (s)
+ result += s->toQString();
+ } else {
+ for (int j = seenDollar; j <= i; ++j)
+ result += replacement.at(j);
+ }
+ } else {
+ result += QLatin1Char('$');
+ result += ch;
+ }
+ seenDollar = -1;
+ } else {
+ if (ch == QLatin1Char('$')) {
+ seenDollar = i;
+ continue;
+ }
+ result += ch;
+ }
+ }
+ if (seenDollar >= 0)
+ result += QLatin1Char('$');
+ return result;
+}
+
+QString Heap::RegExp::flagsAsString() const
+{
+ QString result;
+ if (flags & CompiledData::RegExp::RegExp_Global)
+ result += QLatin1Char('g');
+ if (flags & CompiledData::RegExp::RegExp_IgnoreCase)
+ result += QLatin1Char('i');
+ if (flags & CompiledData::RegExp::RegExp_Multiline)
+ result += QLatin1Char('m');
+ if (flags & CompiledData::RegExp::RegExp_Unicode)
+ result += QLatin1Char('u');
+ if (flags & CompiledData::RegExp::RegExp_Sticky)
+ result += QLatin1Char('y');
+ return result;
+}
+
+Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, uint flags)
{
- RegExpCacheKey key(pattern, ignoreCase, multiline, global);
+ RegExpCacheKey key(pattern, flags);
RegExpCache *cache = engine->regExpCache;
if (!cache)
@@ -82,7 +159,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
return result->d();
Scope scope(engine);
- Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(engine, pattern, ignoreCase, multiline, global));
+ Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(engine, pattern, flags));
result->d()->cache = cache;
cachedValue.set(engine, result);
@@ -90,26 +167,36 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
return result->d();
}
-void Heap::RegExp::init(ExecutionEngine *engine, const QString &pattern, bool ignoreCase, bool multiline, bool global)
+void Heap::RegExp::init(ExecutionEngine *engine, const QString &pattern, uint flags)
{
Base::init();
this->pattern = new QString(pattern);
- this->ignoreCase = ignoreCase;
- this->multiLine = multiline;
- this->global = global;
+ this->flags = flags;
valid = false;
- const char* error = nullptr;
- JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), ignoreCase, multiLine, &error);
- if (error)
+ JSC::Yarr::ErrorCode error = JSC::Yarr::ErrorCode::NoError;
+ JSC::RegExpFlags jscFlags = JSC::NoFlags;
+ if (flags & CompiledData::RegExp::RegExp_Global)
+ jscFlags = static_cast<JSC::RegExpFlags>(flags | JSC::FlagGlobal);
+ if (flags & CompiledData::RegExp::RegExp_IgnoreCase)
+ jscFlags = static_cast<JSC::RegExpFlags>(flags | JSC::FlagIgnoreCase);
+ if (flags & CompiledData::RegExp::RegExp_Multiline)
+ jscFlags = static_cast<JSC::RegExpFlags>(flags | JSC::FlagMultiline);
+ if (flags & CompiledData::RegExp::RegExp_Unicode)
+ jscFlags = static_cast<JSC::RegExpFlags>(flags | JSC::FlagUnicode);
+ if (flags & CompiledData::RegExp::RegExp_Sticky)
+ jscFlags = static_cast<JSC::RegExpFlags>(flags | JSC::FlagSticky);
+
+ JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), jscFlags, error);
+ if (error != JSC::Yarr::ErrorCode::NoError)
return;
subPatternCount = yarrPattern.m_numSubpatterns;
#if ENABLE(YARR_JIT)
if (!yarrPattern.m_containsBackreferences && engine->canJIT()) {
jitCode = new JSC::Yarr::YarrCodeBlock;
- JSC::JSGlobalData dummy(internalClass->engine->regExpAllocator);
- JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, *jitCode);
+ JSC::VM *vm = static_cast<JSC::VM *>(engine);
+ JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, vm, *jitCode);
}
#else
Q_UNUSED(engine)
@@ -118,8 +205,7 @@ void Heap::RegExp::init(ExecutionEngine *engine, const QString &pattern, bool ig
valid = true;
return;
}
- OwnPtr<JSC::Yarr::BytecodePattern> p = JSC::Yarr::byteCompile(yarrPattern, internalClass->engine->bumperPointerAllocator);
- byteCode = p.take();
+ byteCode = JSC::Yarr::byteCompile(yarrPattern, internalClass->engine->bumperPointerAllocator).release();
if (byteCode)
valid = true;
}
diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h
index 56454f73d3..6afb10ea95 100644
--- a/src/qml/jsruntime/qv4regexp_p.h
+++ b/src/qml/jsruntime/qv4regexp_p.h
@@ -76,7 +76,7 @@ struct RegExpCacheKey;
namespace Heap {
struct RegExp : Base {
- void init(ExecutionEngine *engine, const QString& pattern, bool ignoreCase, bool multiline, bool global);
+ void init(ExecutionEngine *engine, const QString& pattern, uint flags);
void destroy();
QString *pattern;
@@ -86,18 +86,24 @@ struct RegExp : Base {
#endif
bool hasValidJITCode() const {
#if ENABLE(YARR_JIT)
- return jitCode && !jitCode->isFallBack() && jitCode->has16BitCode();
+ return jitCode && !jitCode->failureReason().has_value() && jitCode->has16BitCode();
#else
return false;
#endif
}
+
+ bool ignoreCase() const { return flags & CompiledData::RegExp::RegExp_IgnoreCase; }
+ bool multiLine() const { return flags & CompiledData::RegExp::RegExp_Multiline; }
+ bool global() const { return flags & CompiledData::RegExp::RegExp_Global; }
+ bool unicode() const { return flags & CompiledData::RegExp::RegExp_Unicode; }
+ bool sticky() const { return flags & CompiledData::RegExp::RegExp_Sticky; }
+
RegExpCache *cache;
int subPatternCount;
- bool ignoreCase;
- bool multiLine;
- bool global;
+ uint flags;
bool valid;
+ QString flagsAsString() const;
int captureCount() const { return subPatternCount + 1; }
};
Q_STATIC_ASSERT(std::is_trivial< RegExp >::value);
@@ -118,11 +124,13 @@ struct RegExp : public Managed
#endif
RegExpCache *cache() const { return d()->cache; }
int subPatternCount() const { return d()->subPatternCount; }
- bool ignoreCase() const { return d()->ignoreCase; }
- bool multiLine() const { return d()->multiLine; }
- bool global() const { return d()->global; }
+ bool ignoreCase() const { return d()->ignoreCase(); }
+ bool multiLine() const { return d()->multiLine(); }
+ bool global() const { return d()->global(); }
+ bool unicode() const { return d()->unicode(); }
+ bool sticky() const { return d()->sticky(); }
- static Heap::RegExp *create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false, bool global = false);
+ static Heap::RegExp *create(ExecutionEngine* engine, const QString& pattern, uint flags = CompiledData::RegExp::RegExp_NoFlags);
bool isValid() const { return d()->valid; }
@@ -130,35 +138,30 @@ struct RegExp : public Managed
int captureCount() const { return subPatternCount() + 1; }
+ static QString getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement);
+
friend class RegExpCache;
};
struct RegExpCacheKey
{
- RegExpCacheKey(const QString &pattern, bool ignoreCase, bool multiLine, bool global)
- : pattern(pattern)
- , ignoreCase(ignoreCase)
- , multiLine(multiLine)
- , global(global)
+ RegExpCacheKey(const QString &pattern, uint flags)
+ : pattern(pattern), flags(flags)
{ }
explicit inline RegExpCacheKey(const RegExp::Data *re);
bool operator==(const RegExpCacheKey &other) const
- { return pattern == other.pattern && ignoreCase == other.ignoreCase && multiLine == other.multiLine && global == other.global; }
+ { return pattern == other.pattern && flags == other.flags;; }
bool operator!=(const RegExpCacheKey &other) const
{ return !operator==(other); }
QString pattern;
- uint ignoreCase : 1;
- uint multiLine : 1;
- uint global : 1;
+ uint flags;
};
inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re)
: pattern(*re->pattern)
- , ignoreCase(re->ignoreCase)
- , multiLine(re->multiLine)
- , global(re->global)
+ , flags(re->flags)
{}
inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 000e2c3a7e..634fbcbd97 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -44,11 +44,8 @@
#include <private/qv4mm_p.h>
#include "qv4scopedvalue_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
-#include <private/qqmljsengine_p.h>
-#include <private/qqmljslexer_p.h>
-#include <private/qqmljsparser_p.h>
-#include <private/qqmljsast_p.h>
#include "private/qlocale_tools_p.h"
#include <QtCore/QDebug>
@@ -71,7 +68,7 @@ void Heap::RegExpObject::init()
Object::init();
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
- value.set(scope.engine, QV4::RegExp::create(scope.engine, QString(), false, false));
+ value.set(scope.engine, QV4::RegExp::create(scope.engine, QString(), CompiledData::RegExp::RegExp_NoFlags));
o->initProperties();
}
@@ -131,30 +128,17 @@ void Heap::RegExpObject::init(const QRegExp &re)
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
- o->d()->value.set(scope.engine,
- QV4::RegExp::create(scope.engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false));
+ uint flags = (re.caseSensitivity() == Qt::CaseInsensitive ? CompiledData::RegExp::RegExp_IgnoreCase : CompiledData::RegExp::RegExp_NoFlags);
+ o->d()->value.set(scope.engine, QV4::RegExp::create(scope.engine, pattern, flags));
o->initProperties();
}
void RegExpObject::initProperties()
{
- setProperty(Index_LastIndex, Primitive::fromInt32(0));
+ setProperty(Index_LastIndex, Value::fromInt32(0));
Q_ASSERT(value());
-
- QString p = *value()->pattern;
- if (p.isEmpty()) {
- p = QStringLiteral("(?:)");
- } else {
- // escape certain parts, see ch. 15.10.4
- p.replace('/', QLatin1String("\\/"));
- }
-
- setProperty(Index_Source, engine()->newString(p));
- setProperty(Index_Global, Primitive::fromBoolean(global()));
- setProperty(Index_IgnoreCase, Primitive::fromBoolean(value()->ignoreCase));
- setProperty(Index_Multiline, Primitive::fromBoolean(value()->multiLine));
}
// Converts a JS RegExp to a QRegExp.
@@ -162,40 +146,80 @@ void RegExpObject::initProperties()
// have different semantics/flags, but we try to do our best.
QRegExp RegExpObject::toQRegExp() const
{
- Qt::CaseSensitivity caseSensitivity = value()->ignoreCase ? Qt::CaseInsensitive : Qt::CaseSensitive;
+ Qt::CaseSensitivity caseSensitivity = (value()->flags & CompiledData::RegExp::RegExp_IgnoreCase) ? Qt::CaseInsensitive : Qt::CaseSensitive;
return QRegExp(*value()->pattern, caseSensitivity, QRegExp::RegExp2);
}
QString RegExpObject::toString() const
{
- QString result = QLatin1Char('/') + source() + QLatin1Char('/');
- if (global())
- result += QLatin1Char('g');
- if (value()->ignoreCase)
- result += QLatin1Char('i');
- if (value()->multiLine)
- result += QLatin1Char('m');
- return result;
+ QString p = *value()->pattern;
+ if (p.isEmpty()) {
+ p = QStringLiteral("(?:)");
+ } else {
+ // escape certain parts, see ch. 15.10.4
+ p.replace('/', QLatin1String("\\/"));
+ }
+ return p;
}
QString RegExpObject::source() const
{
Scope scope(engine());
- ScopedString source(scope, scope.engine->newIdentifier(QStringLiteral("source")));
- ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source));
+ ScopedValue s(scope, get(scope.engine->id_source()));
return s->toQString();
}
-uint RegExpObject::flags() const
+ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *str)
{
- uint f = 0;
- if (global())
- f |= QV4::RegExpObject::RegExp_Global;
- if (value()->ignoreCase)
- f |= QV4::RegExpObject::RegExp_IgnoreCase;
- if (value()->multiLine)
- f |= QV4::RegExpObject::RegExp_Multiline;
- return f;
+ QString s = str->toQString();
+
+ Scope scope(engine);
+ int offset = (global() || sticky()) ? lastIndex() : 0;
+ if (offset < 0 || offset > s.length()) {
+ setLastIndex(0);
+ RETURN_RESULT(Encode::null());
+ }
+
+ Q_ALLOCA_VAR(uint, matchOffsets, value()->captureCount() * 2 * sizeof(uint));
+ const int result = Scoped<RegExp>(scope, value())->match(s, offset, matchOffsets);
+
+ RegExpCtor *regExpCtor = static_cast<RegExpCtor *>(scope.engine->regExpCtor());
+ regExpCtor->d()->clearLastMatch();
+
+ if (result == -1) {
+ if (global() || sticky())
+ setLastIndex(0);
+ RETURN_RESULT(Encode::null());
+ }
+
+ // fill in result data
+ ScopedArrayObject array(scope, scope.engine->newArrayObject(scope.engine->internalClasses(EngineBase::Class_RegExpExecArray)));
+ int len = value()->captureCount();
+ array->arrayReserve(len);
+ ScopedValue v(scope);
+ int strlen = s.length();
+ for (int i = 0; i < len; ++i) {
+ int start = matchOffsets[i * 2];
+ int end = matchOffsets[i * 2 + 1];
+ if (end > strlen)
+ end = strlen;
+ v = (start != -1) ? scope.engine->memoryManager->alloc<ComplexString>(str->d(), start, end - start)->asReturnedValue() : Encode::undefined();
+ array->arrayPut(i, v);
+ }
+ array->setArrayLengthUnchecked(len);
+ array->setProperty(Index_ArrayIndex, Value::fromInt32(result));
+ array->setProperty(Index_ArrayInput, *str);
+
+ RegExpCtor::Data *dd = regExpCtor->d();
+ dd->lastMatch.set(scope.engine, array);
+ dd->lastInput.set(scope.engine, str->d());
+ dd->lastMatchStart = matchOffsets[0];
+ dd->lastMatchEnd = matchOffsets[1];
+
+ if (global() || sticky())
+ setLastIndex(matchOffsets[1]);
+
+ return array.asReturnedValue();
}
DEFINE_OBJECT_VTABLE(RegExpCtor);
@@ -208,54 +232,102 @@ void Heap::RegExpCtor::init(QV4::ExecutionContext *scope)
void Heap::RegExpCtor::clearLastMatch()
{
- lastMatch.set(internalClass->engine, Primitive::nullValue());
+ lastMatch.set(internalClass->engine, Value::nullValue());
lastInput.set(internalClass->engine, internalClass->engine->id_empty()->d());
lastMatchStart = 0;
lastMatchEnd = 0;
}
-ReturnedValue RegExpCtor::callAsConstructor(const FunctionObject *fo, const Value *argv, int argc)
+static bool isRegExp(ExecutionEngine *e, const Value *arg)
{
- Scope scope(fo->engine());
- ScopedValue r(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue f(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
- Scoped<RegExpObject> re(scope, r);
- if (re) {
- if (!f->isUndefined())
- return scope.engine->throwTypeError();
-
- Scoped<RegExp> regexp(scope, re->value());
- return Encode(scope.engine->newRegExpObject(regexp));
- }
-
- QString pattern;
- if (!r->isUndefined())
- pattern = r->toQString();
- if (scope.hasException())
- return Encode::undefined();
+ const Object *o = arg->objectValue();
+ if (!o)
+ return false;
+
+ Value isRegExp = Value::fromReturnedValue(o->get(e->symbol_match()));
+ if (!isRegExp.isUndefined())
+ return isRegExp.toBoolean();
+ const RegExpObject *re = o->as<RegExpObject>();
+ return re ? true : false;
+}
- bool global = false;
- bool ignoreCase = false;
- bool multiLine = false;
+uint parseFlags(Scope &scope, const Value *f)
+{
+ uint flags = CompiledData::RegExp::RegExp_NoFlags;
if (!f->isUndefined()) {
ScopedString s(scope, f->toString(scope.engine));
if (scope.hasException())
- return Encode::undefined();
+ return flags;
QString str = s->toQString();
for (int i = 0; i < str.length(); ++i) {
- if (str.at(i) == QLatin1Char('g') && !global) {
- global = true;
- } else if (str.at(i) == QLatin1Char('i') && !ignoreCase) {
- ignoreCase = true;
- } else if (str.at(i) == QLatin1Char('m') && !multiLine) {
- multiLine = true;
+ if (str.at(i) == QLatin1Char('g') && !(flags & CompiledData::RegExp::RegExp_Global)) {
+ flags |= CompiledData::RegExp::RegExp_Global;
+ } else if (str.at(i) == QLatin1Char('i') && !(flags & CompiledData::RegExp::RegExp_IgnoreCase)) {
+ flags |= CompiledData::RegExp::RegExp_IgnoreCase;
+ } else if (str.at(i) == QLatin1Char('m') && !(flags & CompiledData::RegExp::RegExp_Multiline)) {
+ flags |= CompiledData::RegExp::RegExp_Multiline;
+ } else if (str.at(i) == QLatin1Char('u') && !(flags & CompiledData::RegExp::RegExp_Unicode)) {
+ flags |= CompiledData::RegExp::RegExp_Unicode;
+ } else if (str.at(i) == QLatin1Char('y') && !(flags & CompiledData::RegExp::RegExp_Sticky)) {
+ flags |= CompiledData::RegExp::RegExp_Sticky;
} else {
- return scope.engine->throwSyntaxError(QStringLiteral("Invalid flags supplied to RegExp constructor"));
+ scope.engine->throwSyntaxError(QStringLiteral("Invalid flags supplied to RegExp constructor"));
+ return flags;
}
}
}
+ return flags;
+}
+
+ReturnedValue RegExpCtor::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *newTarget)
+{
+ Scope scope(fo);
+
+ bool patternIsRegExp = argc ? ::isRegExp(scope.engine, argv) : false;
+
+ if (newTarget == fo) {
+ if (patternIsRegExp && (argc < 2 || argv[1].isUndefined())) {
+ const Object *pattern = static_cast<const Object *>(argv);
+ ScopedValue patternConstructor(scope, pattern->get(scope.engine->id_constructor()));
+ if (patternConstructor->sameValue(*newTarget))
+ return pattern->asReturnedValue();
+ }
+ }
- Scoped<RegExp> regexp(scope, RegExp::create(scope.engine, pattern, ignoreCase, multiLine, global));
+ ScopedValue p(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue f(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ Scoped<RegExpObject> re(scope, p);
+ QString pattern;
+ uint flags = CompiledData::RegExp::RegExp_NoFlags;
+
+ if (re) {
+ if (f->isUndefined()) {
+ Scoped<RegExp> regexp(scope, re->value());
+ return Encode(scope.engine->newRegExpObject(regexp));
+ }
+ pattern = *re->value()->pattern;
+ flags = parseFlags(scope, f);
+ } else if (patternIsRegExp) {
+ const Object *po = static_cast<const Object *>(argv);
+ p = po->get(scope.engine->id_source());
+ if (!p->isUndefined())
+ pattern = p->toQString();
+ if (scope.hasException())
+ return Encode::undefined();
+ if (f->isUndefined())
+ f = po->get(scope.engine->id_flags());
+ flags = parseFlags(scope, f);
+ } else {
+ if (!p->isUndefined())
+ pattern = p->toQString();
+ if (scope.hasException())
+ return Encode::undefined();
+ flags = parseFlags(scope, f);
+ }
+ if (scope.hasException())
+ return Encode::undefined();
+
+ Scoped<RegExp> regexp(scope, RegExp::create(scope.engine, pattern, flags));
if (!regexp->isValid()) {
return scope.engine->throwSyntaxError(QStringLiteral("Invalid regular expression"));
}
@@ -263,14 +335,9 @@ ReturnedValue RegExpCtor::callAsConstructor(const FunctionObject *fo, const Valu
return Encode(scope.engine->newRegExpObject(regexp));
}
-ReturnedValue RegExpCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue RegExpCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
- if (argc > 0 && argv[0].as<RegExpObject>()) {
- if (argc == 1 || argv[1].isUndefined())
- return Encode(argv[0]);
- }
-
- return callAsConstructor(f, argv, argc);
+ return virtualCallAsConstructor(f, argv, argc, f);
}
void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
@@ -280,7 +347,8 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
ScopedObject ctor(scope, constructor);
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(2));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(2));
+ ctor->addSymbolSpecies();
// Properties deprecated in the spec but required by "the web" :(
ctor->defineAccessorProperty(QStringLiteral("lastMatch"), method_get_lastMatch_n<0>, nullptr);
@@ -304,9 +372,22 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
ctor->defineAccessorProperty(QStringLiteral("$'"), method_get_rightContext, nullptr);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
+ defineAccessorProperty(scope.engine->id_flags(), method_get_flags, nullptr);
+ defineAccessorProperty(scope.engine->id_global(), method_get_global, nullptr);
+ defineAccessorProperty(scope.engine->id_ignoreCase(), method_get_ignoreCase, nullptr);
defineDefaultProperty(QStringLiteral("exec"), method_exec, 1);
+ defineDefaultProperty(engine->symbol_match(), method_match, 1);
+ defineAccessorProperty(scope.engine->id_multiline(), method_get_multiline, nullptr);
+ defineDefaultProperty(engine->symbol_replace(), method_replace, 2);
+ defineDefaultProperty(engine->symbol_search(), method_search, 1);
+ defineAccessorProperty(scope.engine->id_source(), method_get_source, nullptr);
+ defineDefaultProperty(engine->symbol_split(), method_split, 2);
+ defineAccessorProperty(scope.engine->id_sticky(), method_get_sticky, nullptr);
defineDefaultProperty(QStringLiteral("test"), method_test, 1);
defineDefaultProperty(engine->id_toString(), method_toString, 0);
+ defineAccessorProperty(scope.engine->id_unicode(), method_get_unicode, nullptr);
+
+ // another web extension
defineDefaultProperty(QStringLiteral("compile"), method_compile, 2);
}
@@ -317,7 +398,7 @@ ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Val
Scoped<RegExpObject> r(scope, thisObject->as<RegExpObject>());
Q_ASSERT(r && r->global());
- ScopedString str(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedString str(scope, argc ? argv[0] : Value::undefinedValue());
Q_ASSERT(str);
QString s = str->toQString();
@@ -356,6 +437,23 @@ ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Val
return retVal;
}
+ReturnedValue RegExpPrototype::exec(ExecutionEngine *engine, const Object *o, const String *s)
+{
+ Scope scope(engine);
+ ScopedString key(scope, scope.engine->newString(QStringLiteral("exec")));
+ ScopedFunctionObject exec(scope, o->get(key));
+ if (exec) {
+ ScopedValue result(scope, exec->call(o, s, 1));
+ if (!result->isNull() && !result->isObject())
+ return scope.engine->throwTypeError();
+ return result->asReturnedValue();
+ }
+ Scoped<RegExpObject> re(scope, o);
+ if (!re)
+ return scope.engine->throwTypeError();
+ return re->builtinExec(engine, s);
+}
+
ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
@@ -363,54 +461,418 @@ ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value
if (!r)
return scope.engine->throwTypeError();
- ScopedValue arg(scope, argc ? argv[0]: Primitive::undefinedValue());
+ ScopedValue arg(scope, argc ? argv[0]: Value::undefinedValue());
ScopedString str(scope, arg->toString(scope.engine));
if (scope.hasException())
RETURN_UNDEFINED();
- QString s = str->toQString();
- int offset = r->global() ? r->lastIndex() : 0;
- if (offset < 0 || offset > s.length()) {
- r->setLastIndex(0);
- RETURN_RESULT(Encode::null());
+ return r->builtinExec(scope.engine, str);
+}
+
+ReturnedValue RegExpPrototype::method_get_flags(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ ScopedObject o(scope, thisObject);
+ if (!o)
+ return scope.engine->throwTypeError();
+
+ QString result;
+ ScopedValue v(scope);
+ v = o->get(scope.engine->id_global());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (v->toBoolean())
+ result += QLatin1Char('g');
+ v = o->get(scope.engine->id_ignoreCase());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (v->toBoolean())
+ result += QLatin1Char('i');
+ v = o->get(scope.engine->id_multiline());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (v->toBoolean())
+ result += QLatin1Char('m');
+ v = o->get(scope.engine->id_unicode());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (v->toBoolean())
+ result += QLatin1Char('u');
+ v = o->get(scope.engine->id_sticky());
+ if (scope.hasException())
+ return Encode::undefined();
+ if (v->toBoolean())
+ result += QLatin1Char('y');
+ return scope.engine->newString(result)->asReturnedValue();
+}
+
+ReturnedValue RegExpPrototype::method_get_global(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return Encode::undefined();
+ return scope.engine->throwTypeError();
}
- Q_ALLOCA_VAR(uint, matchOffsets, r->value()->captureCount() * 2 * sizeof(uint));
- const int result = Scoped<RegExp>(scope, r->value())->match(s, offset, matchOffsets);
+ bool b = re->value()->flags & CompiledData::RegExp::RegExp_Global;
+ return Encode(b);
+}
- RegExpCtor *regExpCtor = static_cast<RegExpCtor *>(scope.engine->regExpCtor());
- regExpCtor->d()->clearLastMatch();
+ReturnedValue RegExpPrototype::method_get_ignoreCase(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return Encode::undefined();
+ return scope.engine->throwTypeError();
+ }
- if (result == -1) {
- r->setLastIndex(0);
- RETURN_RESULT(Encode::null());
+ bool b = re->value()->flags & CompiledData::RegExp::RegExp_IgnoreCase;
+ return Encode(b);
+}
+
+static int advanceStringIndex(int index, const QString &str, bool unicode)
+{
+ if (unicode) {
+ if (index < str.length() - 1 &&
+ str.at(index).isHighSurrogate() &&
+ str.at(index + 1).isLowSurrogate())
+ ++index;
}
+ ++index;
+ return index;
+}
- // fill in result data
- ScopedArrayObject array(scope, scope.engine->newArrayObject(scope.engine->internalClasses[EngineBase::Class_RegExpExecArray], scope.engine->arrayPrototype()));
- int len = r->value()->captureCount();
- array->arrayReserve(len);
+static void advanceLastIndexOnEmptyMatch(ExecutionEngine *e, bool unicode, Object *rx, const String *matchString, const QString &str)
+{
+ Scope scope(e);
+ if (matchString->d()->length() == 0) {
+ ScopedValue v(scope, rx->get(scope.engine->id_lastIndex()));
+ int lastIndex = advanceStringIndex(v->toLength(), str, unicode);
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(lastIndex)))
+ scope.engine->throwTypeError();
+ }
+}
+
+ReturnedValue RegExpPrototype::method_match(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedObject rx(scope, thisObject);
+ if (!rx)
+ return scope.engine->throwTypeError();
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ bool global = ScopedValue(scope, rx->get(scope.engine->id_global()))->toBoolean();
+
+ if (!global)
+ return exec(scope.engine, rx, s);
+
+ bool unicode = ScopedValue(scope, rx->get(scope.engine->id_unicode()))->toBoolean();
+
+ rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0));
+ ScopedArrayObject a(scope, scope.engine->newArrayObject());
+ uint n = 0;
+
+ ScopedValue result(scope);
+ ScopedValue match(scope);
+ ScopedString matchString(scope);
ScopedValue v(scope);
- for (int i = 0; i < len; ++i) {
- int start = matchOffsets[i * 2];
- int end = matchOffsets[i * 2 + 1];
- v = (start != -1) ? scope.engine->memoryManager->alloc<ComplexString>(str->d(), start, end - start)->asReturnedValue() : Encode::undefined();
- array->arrayPut(i, v);
+ while (1) {
+ result = exec(scope.engine, rx, s);
+ if (scope.hasException())
+ return Encode::undefined();
+ if (result->isNull()) {
+ if (!n)
+ return Encode::null();
+ return a->asReturnedValue();
+ }
+ Q_ASSERT(result->isObject());
+ match = static_cast<Object &>(*result).get(PropertyKey::fromArrayIndex(0));
+ matchString = match->toString(scope.engine);
+ if (scope.hasException())
+ return Encode::undefined();
+ a->push_back(matchString);
+ advanceLastIndexOnEmptyMatch(scope.engine, unicode, rx, matchString, s->toQString());
+ ++n;
}
- array->setArrayLengthUnchecked(len);
- array->setProperty(Index_ArrayIndex, Primitive::fromInt32(result));
- array->setProperty(Index_ArrayInput, str);
+}
- RegExpCtor::Data *dd = regExpCtor->d();
- dd->lastMatch.set(scope.engine, array);
- dd->lastInput.set(scope.engine, str->d());
- dd->lastMatchStart = matchOffsets[0];
- dd->lastMatchEnd = matchOffsets[1];
+ReturnedValue RegExpPrototype::method_get_multiline(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return Encode::undefined();
+ return scope.engine->throwTypeError();
+ }
- if (r->global())
- r->setLastIndex(matchOffsets[1]);
+ bool b = re->value()->flags & CompiledData::RegExp::RegExp_Multiline;
+ return Encode(b);
+}
- return array.asReturnedValue();
+ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedObject rx(scope, thisObject);
+ if (!rx)
+ return scope.engine->throwTypeError();
+
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int lengthS = s->toQString().length();
+
+ ScopedString replaceValue(scope);
+ ScopedFunctionObject replaceFunction(scope, (argc > 1 ? argv[1] : Value::undefinedValue()));
+ bool functionalReplace = !!replaceFunction;
+ if (!functionalReplace)
+ replaceValue = (argc > 1 ? argv[1] : Value::undefinedValue()).toString(scope.engine);
+
+ ScopedValue v(scope);
+ bool global = (v = rx->get(scope.engine->id_global()))->toBoolean();
+ bool unicode = false;
+ if (global) {
+ unicode = (v = rx->get(scope.engine->id_unicode()))->toBoolean();
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0)))
+ return scope.engine->throwTypeError();
+ }
+
+ ScopedArrayObject results(scope, scope.engine->newArrayObject());
+ ScopedValue result(scope);
+ ScopedValue match(scope);
+ ScopedString matchString(scope);
+ while (1) {
+ result = exec(scope.engine, rx, s);
+ if (scope.hasException())
+ return Encode::undefined();
+ if (result->isNull())
+ break;
+ results->push_back(result);
+ if (!global)
+ break;
+ match = static_cast<Object &>(*result).get(PropertyKey::fromArrayIndex(0));
+ matchString = match->toString(scope.engine);
+ if (scope.hasException())
+ return Encode::undefined();
+ advanceLastIndexOnEmptyMatch(scope.engine, unicode, rx, matchString, s->toQString());
+ }
+ QString accumulatedResult;
+ int nextSourcePosition = 0;
+ int resultsLength = results->getLength();
+ ScopedObject resultObject(scope);
+ for (int i = 0; i < resultsLength; ++i) {
+ resultObject = results->get(PropertyKey::fromArrayIndex(i));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int nCaptures = resultObject->getLength();
+ nCaptures = qMax(nCaptures - 1, 0);
+ match = resultObject->get(PropertyKey::fromArrayIndex(0));
+ matchString = match->toString(scope.engine);
+ if (scope.hasException())
+ return Encode::undefined();
+ QString m = matchString->toQString();
+ int matchLength = m.length();
+ v = resultObject->get(scope.engine->id_index());
+ int position = v->toInt32();
+ position = qMax(qMin(position, lengthS), 0);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ int n = 1;
+ Scope innerScope(scope.engine);
+ JSCallData cData(scope, nCaptures + 3);
+ while (n <= nCaptures) {
+ v = resultObject->get(PropertyKey::fromArrayIndex(n));
+ if (!v->isUndefined())
+ cData->args[n] = v->toString(scope.engine);
+ ++n;
+ }
+ QString replacement;
+ if (functionalReplace) {
+ cData->args[0] = matchString;
+ cData->args[nCaptures + 1] = Encode(position);
+ cData->args[nCaptures + 2] = s;
+ ScopedValue replValue(scope, replaceFunction->call(cData));
+ replacement = replValue->toQString();
+ } else {
+ replacement = RegExp::getSubstitution(matchString->toQString(), s->toQString(), position, cData.args, nCaptures, replaceValue->toQString());
+ }
+ if (scope.hasException())
+ return Encode::undefined();
+ if (position >= nextSourcePosition) {
+ accumulatedResult += s->toQString().midRef(nextSourcePosition, position - nextSourcePosition) + replacement;
+ nextSourcePosition = position + matchLength;
+ }
+ }
+ if (nextSourcePosition < lengthS) {
+ accumulatedResult += s->toQString().midRef(nextSourcePosition);
+ }
+ return scope.engine->newString(accumulatedResult)->asReturnedValue();
+}
+
+ReturnedValue RegExpPrototype::method_search(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedObject rx(scope, thisObject);
+ if (!rx)
+ return scope.engine->throwTypeError();
+
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ ScopedValue previousLastIndex(scope, rx->get(scope.engine->id_lastIndex()));
+ if (previousLastIndex->toNumber() != 0) {
+ if (!rx->put(scope.engine->id_lastIndex(), Value::fromInt32(0)))
+ return scope.engine->throwTypeError();
+ }
+
+ ScopedValue result(scope, exec(scope.engine, rx, s));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ ScopedValue currentLastIndex(scope, rx->get(scope.engine->id_lastIndex()));
+ if (!currentLastIndex->sameValue(previousLastIndex)) {
+ if (!rx->put(scope.engine->id_lastIndex(), previousLastIndex))
+ return scope.engine->throwTypeError();
+ }
+
+ if (result->isNull())
+ return Encode(-1);
+ ScopedObject o(scope, result);
+ Q_ASSERT(o);
+ return o->get(scope.engine->id_index());
+}
+
+
+ReturnedValue RegExpPrototype::method_get_source(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return scope.engine->newString(QStringLiteral("(?:)"))->asReturnedValue();
+ return scope.engine->throwTypeError();
+ }
+
+ return scope.engine->newString(re->toString())->asReturnedValue();
+}
+
+ReturnedValue RegExpPrototype::method_split(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedObject rx(scope, thisObject);
+ if (!rx)
+ return scope.engine->throwTypeError();
+
+ ScopedString s(scope, (argc ? argv[0] : Value::undefinedValue()).toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ ScopedValue flagsValue(scope, rx->get(scope.engine->id_flags()));
+ ScopedString flags(scope, flagsValue->toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ QString flagsString = flags->toQString();
+ if (!flagsString.contains(QLatin1Char('y')))
+ flags = scope.engine->newString(flagsString + QLatin1Char('y'));
+ bool unicodeMatching = flagsString.contains(QLatin1Char('u'));
+
+ const FunctionObject *C = rx->speciesConstructor(scope, scope.engine->regExpCtor());
+ if (!C)
+ return Encode::undefined();
+
+ Value *args = scope.alloc(2);
+ args[0] = rx;
+ args[1] = flags;
+ ScopedObject splitter(scope, C->callAsConstructor(args, 2, f));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ ScopedArrayObject A(scope, scope.engine->newArrayObject());
+ uint lengthA = 0;
+ uint limit = argc < 2 ? UINT_MAX : argv[1].toUInt32();
+ if (limit == 0)
+ return A->asReturnedValue();
+
+ QString S = s->toQString();
+ int size = S.length();
+ if (size == 0) {
+ ScopedValue z(scope, exec(scope.engine, splitter, s));
+ if (z->isNull())
+ A->push_back(s);
+ return A->asReturnedValue();
+ }
+
+ int p = 0;
+ int q = 0;
+ ScopedValue v(scope);
+ ScopedValue z(scope);
+ ScopedObject zz(scope);
+ ScopedString t(scope);
+ while (q < size) {
+ Value qq = Value::fromInt32(q);
+ if (!splitter->put(scope.engine->id_lastIndex(), qq))
+ return scope.engine->throwTypeError();
+ z = exec(scope.engine, splitter, s);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ if (z->isNull()) {
+ q = advanceStringIndex(q, S, unicodeMatching);
+ continue;
+ }
+
+ v = splitter->get(scope.engine->id_lastIndex());
+ int e = qMin(v->toInt32(), size);
+ if (e == p) {
+ q = advanceStringIndex(q, S, unicodeMatching);
+ continue;
+ }
+ QString T = S.mid(p, q - p);
+ t = scope.engine->newString(T);
+ A->push_back(t);
+ ++lengthA;
+ if (lengthA == limit)
+ return A->asReturnedValue();
+ p = e;
+ zz = *z;
+ uint numberOfCaptures = qMax(zz->getLength() - 1, 0ll);
+ for (uint i = 1; i <= numberOfCaptures; ++i) {
+ v = zz->get(PropertyKey::fromArrayIndex(i));
+ A->push_back(v);
+ ++lengthA;
+ if (lengthA == limit)
+ return A->asReturnedValue();
+ }
+ q = p;
+ }
+
+ QString T = S.mid(p);
+ t = scope.engine->newString(T);
+ A->push_back(t);
+ return A->asReturnedValue();
+}
+
+ReturnedValue RegExpPrototype::method_get_sticky(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return Encode::undefined();
+ return scope.engine->throwTypeError();
+ }
+
+ bool b = re->value()->flags & CompiledData::RegExp::RegExp_Sticky;
+ return Encode(b);
}
ReturnedValue RegExpPrototype::method_test(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -421,12 +883,37 @@ ReturnedValue RegExpPrototype::method_test(const FunctionObject *b, const Value
ReturnedValue RegExpPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
- ExecutionEngine *v4 = b->engine();
- const RegExpObject *r = thisObject->as<RegExpObject>();
+ Scope scope(b);
+ const Object *r = thisObject->as<Object>();
if (!r)
- return v4->throwTypeError();
+ return scope.engine->throwTypeError();
+
+ ScopedValue v(scope);
+ v = r->get(scope.engine->id_source());
+ ScopedString source(scope, v->toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ v = r->get(scope.engine->id_flags());
+ ScopedString flags(scope, v->toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ QString result = QLatin1Char('/') + source->toQString() + QLatin1Char('/') + flags->toQString();
+ return Encode(scope.engine->newString(result));
+}
+
+ReturnedValue RegExpPrototype::method_get_unicode(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<RegExpObject> re(scope, thisObject);
+ if (!re) {
+ if (thisObject->sameValue(*scope.engine->regExpPrototype()))
+ return Encode::undefined();
+ return scope.engine->throwTypeError();
+ }
- return Encode(v4->newString(r->toString()));
+ bool b = re->value()->flags & CompiledData::RegExp::RegExp_Unicode;
+ return Encode(b);
}
ReturnedValue RegExpPrototype::method_compile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -442,12 +929,12 @@ ReturnedValue RegExpPrototype::method_compile(const FunctionObject *b, const Val
return Encode::undefined();
}
-template <int index>
+template <uint index>
ReturnedValue RegExpPrototype::method_get_lastMatch_n(const FunctionObject *b, const Value *, const Value *, int)
{
Scope scope(b);
ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch());
- ScopedValue res(scope, lastMatch ? lastMatch->getIndexed(index) : Encode::undefined());
+ ScopedValue res(scope, lastMatch ? lastMatch->get(index) : Encode::undefined());
if (res->isUndefined())
res = scope.engine->newString();
return res->asReturnedValue();
@@ -457,7 +944,7 @@ ReturnedValue RegExpPrototype::method_get_lastParen(const FunctionObject *b, con
{
Scope scope(b);
ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch());
- ScopedValue res(scope, lastMatch ? lastMatch->getIndexed(lastMatch->getLength() - 1) : Encode::undefined());
+ ScopedValue res(scope, lastMatch ? lastMatch->get(lastMatch->getLength() - 1) : Encode::undefined());
if (res->isUndefined())
res = scope.engine->newString();
return res->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h
index 181628241b..a584404c0b 100644
--- a/src/qml/jsruntime/qv4regexpobject_p.h
+++ b/src/qml/jsruntime/qv4regexpobject_p.h
@@ -76,7 +76,7 @@ namespace Heap {
Member(class, Pointer, RegExp *, value)
DECLARE_HEAP_OBJECT(RegExpObject, Object) {
- DECLARE_MARKOBJECTS(RegExpObject);
+ DECLARE_MARKOBJECTS(RegExpObject)
void init();
void init(QV4::RegExp *value);
@@ -108,39 +108,46 @@ struct RegExpObject: Object {
enum Flags {
RegExp_Global = 0x01,
RegExp_IgnoreCase = 0x02,
- RegExp_Multiline = 0x04
+ RegExp_Multiline = 0x04,
+ RegExp_Unicode = 0x08,
+ RegExp_Sticky = 0x10
};
enum {
Index_LastIndex = 0,
- Index_Source = 1,
- Index_Global = 2,
- Index_IgnoreCase = 3,
- Index_Multiline = 4,
Index_ArrayIndex = Heap::ArrayObject::LengthPropertyIndex + 1,
Index_ArrayInput = Index_ArrayIndex + 1
};
enum { NInlineProperties = 5 };
- Heap::RegExp *value() const { return d()->value; }
- bool global() const { return d()->value->global; }
void initProperties();
int lastIndex() const {
- Q_ASSERT(Index_LastIndex == internalClass()->find(engine()->id_lastIndex()));
+ Q_ASSERT(internalClass()->verifyIndex(engine()->id_lastIndex()->propertyKey(), Index_LastIndex));
return propertyData(Index_LastIndex)->toInt32();
}
void setLastIndex(int index) {
- Q_ASSERT(Index_LastIndex == internalClass()->find(engine()->id_lastIndex()));
- return setProperty(Index_LastIndex, Primitive::fromInt32(index));
+ Q_ASSERT(internalClass()->verifyIndex(engine()->id_lastIndex()->propertyKey(), Index_LastIndex));
+ if (!internalClass()->propertyData[Index_LastIndex].isWritable()) {
+ engine()->throwTypeError();
+ return;
+ }
+ return setProperty(Index_LastIndex, Value::fromInt32(index));
}
QRegExp toQRegExp() const;
QString toString() const;
QString source() const;
- uint flags() const;
+
+ Heap::RegExp *value() const { return d()->value; }
+ uint flags() const { return d()->value->flags; }
+ bool global() const { return d()->value->global(); }
+ bool sticky() const { return d()->value->sticky(); }
+ bool unicode() const { return d()->value->unicode(); }
+
+ ReturnedValue builtinExec(ExecutionEngine *engine, const String *s);
};
struct RegExpCtor: FunctionObject
@@ -152,20 +159,34 @@ struct RegExpCtor: FunctionObject
int lastMatchStart() { return d()->lastMatchStart; }
int lastMatchEnd() { return d()->lastMatchEnd; }
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
-struct RegExpPrototype: RegExpObject
+struct RegExpPrototype: Object
{
void init(ExecutionEngine *engine, Object *ctor);
static ReturnedValue method_exec(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_flags(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_global(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_ignoreCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_match(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_multiline(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_replace(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_search(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_source(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_split(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_sticky(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_test(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_unicode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ // Web extension
static ReturnedValue method_compile(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- template <int index>
+ // properties on the constructor, web extensions
+ template <uint index>
static ReturnedValue method_get_lastMatch_n(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_lastParen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_input(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -173,6 +194,8 @@ struct RegExpPrototype: RegExpObject
static ReturnedValue method_get_rightContext(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue execFirstMatch(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue exec(ExecutionEngine *engine, const Object *o, const String *s);
};
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 9729228511..7b1a38ff06 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -61,6 +61,8 @@
#include <private/qqmlengine_p.h>
#include <private/qqmljavascriptexpression_p.h>
#include "qv4qobjectwrapper_p.h"
+#include "qv4symbol_p.h"
+#include "qv4generatorobject_p.h"
#include <private/qv8engine_p.h>
#endif
@@ -285,7 +287,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix)
}
double frac = num - ::floor(num);
- num = Primitive::toInteger(num);
+ num = Value::toInteger(num);
do {
char c = (char)::fmod(num, radix);
@@ -314,37 +316,23 @@ ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId)
QV4::Function *clos = static_cast<CompiledData::CompilationUnit*>(engine->currentStackFrame->v4Function->compilationUnit)->runtimeFunctions[functionId];
Q_ASSERT(clos);
ExecutionContext *current = static_cast<ExecutionContext *>(&engine->currentStackFrame->jsFrame->context);
+ if (clos->isGenerator())
+ return GeneratorFunction::create(current, clos)->asReturnedValue();
return FunctionObject::createScriptFunction(current, clos)->asReturnedValue();
}
-bool Runtime::method_deleteElement(ExecutionEngine *engine, const Value &base, const Value &index)
+bool Runtime::method_deleteProperty(ExecutionEngine *engine, const Value &base, const Value &index)
{
Scope scope(engine);
- ScopedObject o(scope, base);
- if (o) {
- uint n = index.asArrayIndex();
- if (n < UINT_MAX)
- return o->deleteIndexedProperty(n);
- }
-
- ScopedString name(scope, index.toString(engine));
- return method_deleteMemberString(engine, base, name);
-}
-
-bool Runtime::method_deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex)
-{
- Scope scope(engine);
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- return method_deleteMemberString(engine, base, name);
-}
-
-bool Runtime::method_deleteMemberString(ExecutionEngine *engine, const Value &base, String *name)
-{
- Scope scope(engine);
- ScopedObject obj(scope, base.toObject(engine));
+ ScopedObject o(scope, base.toObject(engine));
if (scope.engine->hasException)
return Encode::undefined();
- return obj->deleteProperty(name);
+ Q_ASSERT(o);
+
+ ScopedPropertyKey key(scope, index.toPropertyKey(engine));
+ if (engine->hasException)
+ return false;
+ return o->deleteProperty(key);
}
bool Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex)
@@ -361,8 +349,22 @@ QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Val
if (!rhs)
return engine->throwTypeError();
- // 11.8.6, 7: call "HasInstance", which we term instanceOf, and return the result.
- return rhs->instanceOf(lval);
+ const FunctionObject *f = rhs->as<FunctionObject>();
+ // shortcut hasInstance evaluation. In this case we know that we are calling the regular hasInstance()
+ // method of the FunctionPrototype
+ if (f && f->d()->prototype() == engine->functionPrototype()->d() && !f->hasHasInstanceProperty())
+ return Object::checkedInstanceOf(engine, f, lval);
+
+ Scope scope(engine);
+ ScopedValue hasInstance(scope, rhs->get(engine->symbol_hasInstance()));
+ if (hasInstance->isUndefined())
+ return rhs->instanceOf(lval);
+ FunctionObject *fHasInstance = hasInstance->as<FunctionObject>();
+ if (!fHasInstance)
+ return engine->throwTypeError();
+
+ ScopedValue result(scope, fHasInstance->call(&rval, &lval, 1));
+ return Encode(result->toBoolean());
}
QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right)
@@ -371,7 +373,7 @@ QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left
if (!ro)
return engine->throwTypeError();
Scope scope(engine);
- ScopedString s(scope, left.toString(engine));
+ ScopedPropertyKey s(scope, left.toPropertyKey(engine));
if (scope.hasException())
return Encode::undefined();
bool r = ro->hasProperty(s);
@@ -381,9 +383,24 @@ QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left
double RuntimeHelpers::stringToNumber(const QString &string)
{
const QStringRef s = QStringRef(&string).trimmed();
- if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
- return s.toLong(nullptr, 16);
- bool ok;
+ if (s.startsWith(QLatin1Char('0'))) {
+ int base = -1;
+ if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
+ base = 16;
+ else if (s.startsWith(QLatin1String("0o")) || s.startsWith(QLatin1String("0O")))
+ base = 8;
+ else if (s.startsWith(QLatin1String("0b")) || s.startsWith(QLatin1String("0B")))
+ base = 2;
+ if (base > 0) {
+ bool ok = true;
+ qlonglong num;
+ num = s.mid(2).toLongLong(&ok, base);
+ if (!ok)
+ return qQNaN();
+ return num;
+ }
+ }
+ bool ok = false;
QByteArray ba = s.toLatin1();
const char *begin = ba.constData();
const char *end = nullptr;
@@ -408,27 +425,59 @@ Heap::String *RuntimeHelpers::stringFromNumber(ExecutionEngine *engine, double n
ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeHint)
{
- if (typeHint == PREFERREDTYPE_HINT) {
- if (object->as<DateObject>())
- typeHint = STRING_HINT;
- else
- typeHint = NUMBER_HINT;
+ ExecutionEngine *engine = object->internalClass()->engine;
+ if (engine->hasException)
+ return Encode::undefined();
+
+ String *hint;
+ switch (typeHint) {
+ case STRING_HINT:
+ hint = engine->id_string();
+ break;
+ case NUMBER_HINT:
+ hint = engine->id_number();
+ break;
+ default:
+ hint = engine->id_default();
+ break;
}
- ExecutionEngine *engine = object->internalClass()->engine;
+ Scope scope(engine);
+ ScopedFunctionObject toPrimitive(scope, object->get(engine->symbol_toPrimitive()));
if (engine->hasException)
return Encode::undefined();
+ if (toPrimitive) {
+ ScopedValue result(scope, toPrimitive->call(object, hint, 1));
+ if (engine->hasException)
+ return Encode::undefined();
+ if (!result->isPrimitive())
+ return engine->throwTypeError();
+ return result->asReturnedValue();
+ }
+
+ if (hint == engine->id_default())
+ hint = engine->id_number();
+ return ordinaryToPrimitive(engine, object, hint);
+}
+
+
+ReturnedValue RuntimeHelpers::ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint)
+{
+ Q_ASSERT(!engine->hasException);
String *meth1 = engine->id_toString();
String *meth2 = engine->id_valueOf();
- if (typeHint == NUMBER_HINT)
+ if (typeHint->propertyKey() == engine->id_number()->propertyKey()) {
qSwap(meth1, meth2);
+ } else {
+ Q_ASSERT(typeHint->propertyKey() == engine->id_string()->propertyKey());
+ }
Scope scope(engine);
ScopedValue result(scope);
- ScopedValue conv(scope, object->get(meth1));
+ ScopedValue conv(scope, object->get(meth1));
if (FunctionObject *o = conv->as<FunctionObject>()) {
result = o->call(object, nullptr, 0);
if (result->isPrimitive())
@@ -449,19 +498,22 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH
}
-
Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Value &value)
{
Q_ASSERT(!value.isObject());
switch (value.type()) {
case Value::Undefined_Type:
+ engine->throwTypeError(QLatin1String("Value is undefined and could not be converted to an object"));
+ return nullptr;
case Value::Null_Type:
- engine->throwTypeError();
+ engine->throwTypeError(QLatin1String("Value is null and could not be converted to an object"));
return nullptr;
case Value::Boolean_Type:
return engine->newBooleanObject(value.booleanValue());
case Value::Managed_Type:
- Q_ASSERT(value.isString());
+ Q_ASSERT(value.isStringOrSymbol());
+ if (!value.isString())
+ return engine->newSymbolObject(value.symbolValue());
return engine->newStringObject(value.stringValue());
case Value::Integer_Type:
default: // double
@@ -488,7 +540,11 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, Value val
case Value::Managed_Type: {
if (value.isString())
return static_cast<const String &>(value).d();
- value = Primitive::fromReturnedValue(RuntimeHelpers::toPrimitive(value, hint));
+ if (value.isSymbol()) {
+ engine->throwTypeError(QLatin1String("Cannot convert a symbol to a string."));
+ return nullptr;
+ }
+ value = Value::fromReturnedValue(RuntimeHelpers::toPrimitive(value, hint));
Q_ASSERT(value.isPrimitive());
if (value.isString())
return static_cast<const String &>(value).d();
@@ -539,14 +595,21 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu
return Encode(x + y);
}
-bool Runtime::method_storeProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)
+void Runtime::method_storeProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- ScopedObject o(scope, object.toObject(engine));
- if (!o)
- return false;
- return o->put(name, value);
+ QV4::Function *v4Function = engine->currentStackFrame->v4Function;
+ ScopedString name(scope, v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedObject o(scope, object);
+ if (!o) {
+ if (v4Function->isStrict()) {
+ engine->throwTypeError();
+ return;
+ }
+ o = object.toObject(engine);
+ }
+ if ((!o || !o->put(name, value)) && v4Function->isStrict())
+ engine->throwTypeError();
}
static Q_NEVER_INLINE ReturnedValue getElementIntFallback(ExecutionEngine *engine, const Value &object, uint idx)
@@ -579,12 +642,13 @@ static Q_NEVER_INLINE ReturnedValue getElementIntFallback(ExecutionEngine *engin
return v->asReturnedValue();
}
- return o->getIndexed(idx);
+ return o->get(idx);
}
static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine, const Value &object, const Value &index)
{
- Q_ASSERT(index.asArrayIndex() == UINT_MAX);
+ Q_ASSERT(!index.isPositiveInt());
+
Scope scope(engine);
ScopedObject o(scope, object);
@@ -598,26 +662,18 @@ static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine,
Q_ASSERT(!!o); // can't fail as null/undefined is covered above
}
- ScopedString name(scope, index.toString(engine));
+ ScopedPropertyKey name(scope, index.toPropertyKey(engine));
if (scope.hasException())
return Encode::undefined();
return o->get(name);
}
-/* load element:
-
- Managed *m = object.heapObject();
- if (m)
- return m->internalClass->getIndexed(m, index);
- return getIndexedFallback(object, index);
-*/
-
ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &object, const Value &index)
{
- uint idx = 0;
- if (index.asArrayIndex(idx)) {
+ if (index.isPositiveInt()) {
+ uint idx = static_cast<uint>(index.int_32());
if (Heap::Base *b = object.heapObject()) {
- if (b->vtable()->isObject) {
+ if (b->internalClass->vtable->isObject) {
Heap::Object *o = static_cast<Heap::Object *>(b);
if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>();
@@ -636,12 +692,20 @@ ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &
static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)
{
Scope scope(engine);
- ScopedObject o(scope, object.toObject(engine));
+ ScopedObject o(scope, object);
+ if (!o) {
+ if (engine->currentStackFrame->v4Function->isStrict()) {
+ engine->throwTypeError();
+ return false;
+ }
+
+ o = object.toObject(engine);
+ }
if (engine->hasException)
return false;
- uint idx = 0;
- if (index.asArrayIndex(idx)) {
+ if (index.isPositiveInt()) {
+ uint idx = static_cast<uint>(index.int_32());
if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
if (idx < s->values.size) {
@@ -649,53 +713,229 @@ static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Val
return true;
}
}
- return o->putIndexed(idx, value);
+ return o->put(idx, value);
}
- ScopedString name(scope, index.toString(engine));
+ ScopedPropertyKey name(scope, index.toPropertyKey(engine));
+ if (engine->hasException)
+ return false;
return o->put(name, value);
}
-bool Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)
+void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)
{
- uint idx = 0;
- if (index.asArrayIndex(idx)) {
+ if (index.isPositiveInt()) {
+ uint idx = static_cast<uint>(index.int_32());
if (Heap::Base *b = object.heapObject()) {
- if (b->vtable()->isObject) {
+ if (b->internalClass->vtable->isObject) {
Heap::Object *o = static_cast<Heap::Object *>(b);
if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>();
if (idx < s->values.size) {
s->setData(engine, idx, value);
- return true;
+ return;
}
}
}
}
}
- return setElementFallback(engine, object, index, value);
+ if (!setElementFallback(engine, object, index, value) && engine->currentStackFrame->v4Function->isStrict())
+ engine->throwTypeError();
}
-ReturnedValue Runtime::method_foreachIterator(ExecutionEngine *engine, const Value &in)
+ReturnedValue Runtime::method_getIterator(ExecutionEngine *engine, const Value &in, int iterator)
{
Scope scope(engine);
ScopedObject o(scope, (Object *)nullptr);
if (!in.isNullOrUndefined())
o = in.toObject(engine);
- return engine->newForEachIteratorObject(o)->asReturnedValue();
+ if (engine->hasException)
+ return Encode::undefined();
+ if (iterator == static_cast<int>(QQmlJS::AST::ForEachType::Of)) {
+ if (!o)
+ return engine->throwTypeError();
+ ScopedFunctionObject f(scope, o->get(engine->symbol_iterator()));
+ if (!f)
+ return engine->throwTypeError();
+ JSCallData cData(scope, 0, nullptr, o);
+ ScopedObject it(scope, f->call(cData));
+ if (!it)
+ return engine->throwTypeError();
+ return it->asReturnedValue();
+ }
+ return engine->newForInIteratorObject(o)->asReturnedValue();
}
-ReturnedValue Runtime::method_foreachNextPropertyName(const Value &foreach_iterator)
+ReturnedValue Runtime::method_iteratorNext(ExecutionEngine *engine, const Value &iterator, Value *value)
{
- Q_ASSERT(foreach_iterator.isObject());
+ // if we throw an exception from here, return true, not undefined. This is to ensure iteratorDone is set to true
+ // and the stack unwinding won't close the iterator
+ Q_ASSERT(iterator.isObject());
- ForEachIteratorObject *it = static_cast<ForEachIteratorObject *>(foreach_iterator.objectValue());
- Q_ASSERT(it->as<ForEachIteratorObject>());
+ Scope scope(engine);
+ ScopedFunctionObject f(scope, static_cast<const Object &>(iterator).get(engine->id_next()));
+ if (!f) {
+ engine->throwTypeError();
+ return Encode(true);
+ }
+ JSCallData cData(scope, 0, nullptr, &iterator);
+ ScopedObject o(scope, f->call(cData));
+ if (scope.hasException())
+ return Encode(true);
+ if (!o) {
+ engine->throwTypeError();
+ return Encode(true);
+ }
+
+ ScopedValue d(scope, o->get(engine->id_done()));
+ if (scope.hasException())
+ return Encode(true);
+ bool done = d->toBoolean();
+ if (done) {
+ *value = Encode::undefined();
+ return Encode(true);
+ }
+
+ *value = o->get(engine->id_value());
+ if (scope.hasException())
+ return Encode(true);
+ return Encode(false);
+}
+
+ReturnedValue Runtime::method_iteratorNextForYieldStar(ExecutionEngine *engine, const Value &received, const Value &iterator, Value *object)
+{
+ // the return value encodes how to continue the yield* iteration.
+ // true implies iteration is done, false for iteration to continue
+ // a return value of undefines is a special marker, that the iterator has been invoked with return()
+
+ Scope scope(engine);
+ Q_ASSERT(iterator.isObject());
+
+ const Value *arg = &received;
+ bool returnCalled = false;
+ FunctionObject *f = nullptr;
+ if (engine->hasException) {
+ if (engine->exceptionValue->isEmpty()) {
+ // generator called with return()
+ *engine->exceptionValue = Encode::undefined();
+ engine->hasException = false;
+
+ ScopedValue ret(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
+ if (ret->isUndefined()) {
+ // propagate return()
+ return Encode::undefined();
+ }
+ returnCalled = true;
+ f = ret->as<FunctionObject>();
+ } else {
+ // generator called with throw
+ ScopedValue exceptionValue(scope, *engine->exceptionValue);
+ *engine->exceptionValue = Encode::undefined();
+ engine->hasException = false;
+
+ ScopedValue t(scope, static_cast<const Object &>(iterator).get(engine->id_throw()));
+ if (engine->hasException)
+ return Encode::undefined();
+ if (t->isUndefined()) {
+ // no throw method on the iterator
+ ScopedValue done(scope, Encode(false));
+ method_iteratorClose(engine, iterator, done);
+ if (engine->hasException)
+ return Encode::undefined();
+ return engine->throwTypeError();
+ }
+ f = t->as<FunctionObject>();
+ arg = exceptionValue;
+ }
+ } else {
+ // generator called with next()
+ ScopedFunctionObject next(scope, static_cast<const Object &>(iterator).get(engine->id_next()));
+ f = next->as<FunctionObject>();
+ }
+
+ if (!f)
+ return engine->throwTypeError();
+
+ ScopedObject o(scope, f->call(&iterator, arg, 1));
+ if (scope.hasException())
+ return Encode(true);
+ if (!o)
+ return engine->throwTypeError();
+
+ ScopedValue d(scope, o->get(engine->id_done()));
+ if (scope.hasException())
+ return Encode(true);
+ bool done = d->toBoolean();
+ if (done) {
+ *object = o->get(engine->id_value());
+ return returnCalled ? Encode::undefined() : Encode(true);
+ }
+ *object = o;
+ return Encode(false);
+}
- return it->nextPropertyName();
+ReturnedValue Runtime::method_iteratorClose(ExecutionEngine *engine, const Value &iterator, const Value &done)
+{
+ Q_ASSERT(iterator.isObject());
+ Q_ASSERT(done.isBoolean());
+ if (done.booleanValue())
+ return Encode::undefined();
+
+ Scope scope(engine);
+ ScopedValue e(scope);
+ bool hadException = engine->hasException;
+ if (hadException) {
+ e = *engine->exceptionValue;
+ engine->hasException = false;
+ }
+
+ auto originalCompletion = [=]() {
+ if (hadException) {
+ *engine->exceptionValue = e;
+ engine->hasException = hadException;
+ }
+ return Encode::undefined();
+ };
+
+ ScopedValue ret(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
+ ScopedObject o(scope);
+ if (!ret->isUndefined()) {
+ FunctionObject *f = ret->as<FunctionObject>();
+ o = f->call(&iterator, nullptr, 0);
+ if (engine->hasException && !hadException)
+ return Encode::undefined();
+ }
+ if (hadException || ret->isUndefined())
+ return originalCompletion();
+
+ if (!o)
+ return engine->throwTypeError();
+
+ return originalCompletion();
}
+ReturnedValue Runtime::method_destructureRestElement(ExecutionEngine *engine, const Value &iterator)
+{
+ Q_ASSERT(iterator.isObject());
+
+ Scope scope(engine);
+ ScopedArrayObject array(scope, engine->newArrayObject());
+ array->arrayCreate();
+ uint index = 0;
+ while (1) {
+ ScopedValue n(scope);
+ ScopedValue done(scope, method_iteratorNext(engine, iterator, n));
+ if (engine->hasException)
+ return Encode::undefined();
+ Q_ASSERT(done->isBoolean());
+ if (done->booleanValue())
+ break;
+ array->arraySet(index, n);
+ ++index;
+ }
+ return array->asReturnedValue();
+}
void Runtime::method_storeNameSloppy(ExecutionEngine *engine, int nameIndex, const Value &value)
{
@@ -745,6 +985,84 @@ ReturnedValue Runtime::method_loadName(ExecutionEngine *engine, int nameIndex)
return static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name);
}
+static Object *getSuperBase(Scope &scope)
+{
+ if (scope.engine->currentStackFrame->jsFrame->thisObject.isEmpty()) {
+ scope.engine->throwReferenceError(QStringLiteral("Missing call to super()."), QString(), 0, 0);
+ return nullptr;
+ }
+
+ ScopedFunctionObject f(scope, scope.engine->currentStackFrame->jsFrame->function);
+ ScopedObject homeObject(scope, f->getHomeObject());
+ if (!homeObject) {
+ ScopedContext ctx(scope, static_cast<ExecutionContext *>(&scope.engine->currentStackFrame->jsFrame->context));
+ Q_ASSERT(ctx);
+ while (ctx) {
+ if (CallContext *c = ctx->asCallContext()) {
+ f = c->d()->function;
+ QV4::Function *fn = f->function();
+ if (fn && !fn->isArrowFunction() && !fn->isEval)
+ break;
+ }
+ ctx = ctx->d()->outer;
+ }
+ homeObject = f->getHomeObject();
+ }
+ if (!homeObject) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ Q_ASSERT(homeObject);
+ ScopedObject proto(scope, homeObject->getPrototypeOf());
+ if (!proto) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ return proto;
+}
+
+ReturnedValue Runtime::method_loadSuperProperty(ExecutionEngine *engine, const Value &property)
+{
+ Scope scope(engine);
+ Object *base = getSuperBase(scope);
+ if (!base)
+ return Encode::undefined();
+ ScopedPropertyKey key(scope, property.toPropertyKey(engine));
+ if (engine->hasException)
+ return Encode::undefined();
+ return base->get(key, &engine->currentStackFrame->jsFrame->thisObject);
+}
+
+void Runtime::method_storeSuperProperty(ExecutionEngine *engine, const Value &property, const Value &value)
+{
+ Scope scope(engine);
+ Object *base = getSuperBase(scope);
+ if (!base)
+ return;
+ ScopedPropertyKey key(scope, property.toPropertyKey(engine));
+ if (engine->hasException)
+ return;
+ bool result = base->put(key, value, &engine->currentStackFrame->jsFrame->thisObject);
+ if (!result && engine->currentStackFrame->v4Function->isStrict())
+ engine->throwTypeError();
+}
+
+ReturnedValue Runtime::method_loadSuperConstructor(ExecutionEngine *engine, const Value &t)
+{
+ if (engine->currentStackFrame->thisObject() != Value::emptyValue().asReturnedValue()) {
+ return engine->throwReferenceError(QStringLiteral("super() already called."), QString(), 0, 0); // ### fix line number
+ }
+ const FunctionObject *f = t.as<FunctionObject>();
+ if (!f)
+ return engine->throwTypeError();
+ Heap::Object *c = static_cast<const Object &>(t).getPrototypeOf();
+ if (!c->vtable()->isFunctionObject || !static_cast<Heap::FunctionObject *>(c)->isConstructor())
+ return engine->throwTypeError();
+ return c->asReturnedValue();
+}
+
+
+
#endif // V4_BOOTSTRAP
uint RuntimeHelpers::equalHelper(const Value &x, const Value &y)
@@ -764,9 +1082,9 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y)
double dx = RuntimeHelpers::toNumber(x);
return dx == y.asDouble();
} else if (x.isBoolean()) {
- return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y);
+ return Runtime::method_compareEqual(Value::fromDouble((double) x.booleanValue()), y);
} else if (y.isBoolean()) {
- return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue()));
+ return Runtime::method_compareEqual(x, Value::fromDouble((double) y.booleanValue()));
} else {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
@@ -817,7 +1135,7 @@ QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r)
Q_UNIMPLEMENTED();
return false;
#else
- return sr->compare(sl);
+ return sr->lessThan(sl);
#endif
}
@@ -854,7 +1172,7 @@ QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r)
Q_UNIMPLEMENTED();
return false;
#else
- return sl->compare(sr);
+ return sl->lessThan(sr);
#endif
}
@@ -891,7 +1209,7 @@ QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r)
Q_UNIMPLEMENTED();
return false;
#else
- return !sl->compare(sr);
+ return !sl->lessThan(sr);
#endif
}
@@ -928,7 +1246,7 @@ QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r)
Q_UNIMPLEMENTED();
return false;
#else
- return !sr->compare(sl);
+ return !sr->lessThan(sl);
#endif
}
@@ -978,7 +1296,7 @@ ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint ind
if (!function.isFunctionObject())
return engine->throwTypeError();
- Value thisObject = Primitive::undefinedValue();
+ Value thisObject = Value::undefinedValue();
return static_cast<FunctionObject &>(function).call(&thisObject, argv, argc);
}
@@ -1033,24 +1351,31 @@ ReturnedValue Runtime::method_callName(ExecutionEngine *engine, int nameIndex, V
ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, Value *base, int nameIndex, Value *argv, int argc)
{
Scope scope(engine);
+ ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedObject lookupObject(scope, base);
- if (!base->isObject()) {
+ if (!lookupObject) {
Q_ASSERT(!base->isEmpty());
if (base->isNullOrUndefined()) {
QString message = QStringLiteral("Cannot call method '%1' of %2")
- .arg(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]->toQString(),
- base->toQStringNoThrow());
+ .arg(name->toQString(), base->toQStringNoThrow());
return engine->throwTypeError(message);
}
- ScopedValue thisObject(scope, RuntimeHelpers::convertToObject(engine, *base));
- if (engine->hasException) // type error
- return Encode::undefined();
- base = thisObject;
+ if (base->isManaged()) {
+ Managed *m = static_cast<Managed *>(base);
+ lookupObject = m->internalClass()->prototype;
+ Q_ASSERT(m->internalClass()->prototype);
+ } else {
+ lookupObject = RuntimeHelpers::convertToObject(engine, *base);
+ if (engine->hasException) // type error
+ return Encode::undefined();
+ if (!engine->currentStackFrame->v4Function->isStrict())
+ base = lookupObject;
+ }
}
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- ScopedFunctionObject f(scope, static_cast<Object *>(base)->get(name));
+ ScopedFunctionObject f(scope, static_cast<Object *>(lookupObject)->get(name));
if (!f) {
QString error = QStringLiteral("Property '%1' of object %2 is not a function")
@@ -1080,7 +1405,7 @@ ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, Value *base,
ScopedValue thisObject(scope, base->toObject(engine));
base = thisObject;
- ScopedString str(scope, index.toString(engine));
+ ScopedPropertyKey str(scope, index.toPropertyKey(engine));
if (engine->hasException)
return Encode::undefined();
@@ -1095,7 +1420,15 @@ ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &fu
{
if (!func.isFunctionObject())
return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
- return static_cast<const FunctionObject &>(func).call(nullptr, argv, argc);
+ Value undef = Value::undefinedValue();
+ return static_cast<const FunctionObject &>(func).call(&undef, argv, argc);
+}
+
+ReturnedValue Runtime::method_callWithReceiver(ExecutionEngine *engine, const Value &func, const Value *thisObject, Value *argv, int argc)
+{
+ if (!func.isFunctionObject())
+ return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
+ return static_cast<const FunctionObject &>(func).call(thisObject, argv, argc);
}
ReturnedValue Runtime::method_callQmlScopeObjectProperty(ExecutionEngine *engine, Value *base,
@@ -1130,12 +1463,79 @@ ReturnedValue Runtime::method_callQmlContextObjectProperty(ExecutionEngine *engi
return fo->call(qmlContextValue, argv, argc);
}
-ReturnedValue Runtime::method_construct(ExecutionEngine *engine, const Value &function, Value *argv, int argc)
+struct CallArgs {
+ Value *argv;
+ int argc;
+};
+
+static CallArgs createSpreadArguments(Scope &scope, Value *argv, int argc)
+{
+ ScopedValue it(scope);
+ ScopedValue done(scope);
+
+ int argCount = 0;
+
+ Value *v = scope.alloc<Scope::Uninitialized>();
+ Value *arguments = v;
+ for (int i = 0; i < argc; ++i) {
+ if (!argv[i].isEmpty()) {
+ *v = argv[i];
+ ++argCount;
+ v = scope.alloc<Scope::Uninitialized>();
+ continue;
+ }
+ // spread element
+ ++i;
+ it = Runtime::method_getIterator(scope.engine, argv[i], /* ForInIterator */ 1);
+ if (scope.engine->hasException)
+ return { nullptr, 0 };
+ while (1) {
+ done = Runtime::method_iteratorNext(scope.engine, it, v);
+ if (scope.engine->hasException)
+ return { nullptr, 0 };
+ Q_ASSERT(done->isBoolean());
+ if (done->booleanValue())
+ break;
+ ++argCount;
+ v = scope.alloc<Scope::Uninitialized>();
+ }
+ }
+ return { arguments, argCount };
+}
+
+ReturnedValue Runtime::method_callWithSpread(ExecutionEngine *engine, const Value &function, const Value &thisObject, Value *argv, int argc)
+{
+ Q_ASSERT(argc >= 1);
+ if (!function.isFunctionObject())
+ return engine->throwTypeError();
+
+ Scope scope(engine);
+ CallArgs arguments = createSpreadArguments(scope, argv, argc);
+ if (engine->hasException)
+ return Encode::undefined();
+
+ return static_cast<const FunctionObject &>(function).call(&thisObject, arguments.argv, arguments.argc);
+}
+
+ReturnedValue Runtime::method_construct(ExecutionEngine *engine, const Value &function, const Value &newTarget, Value *argv, int argc)
{
if (!function.isFunctionObject())
return engine->throwTypeError();
- return static_cast<const FunctionObject &>(function).callAsConstructor(argv, argc);
+ return static_cast<const FunctionObject &>(function).callAsConstructor(argv, argc, &newTarget);
+}
+
+ReturnedValue Runtime::method_constructWithSpread(ExecutionEngine *engine, const Value &function, const Value &newTarget, Value *argv, int argc)
+{
+ if (!function.isFunctionObject())
+ return engine->throwTypeError();
+
+ Scope scope(engine);
+ CallArgs arguments = createSpreadArguments(scope, argv, argc);
+ if (engine->hasException)
+ return Encode::undefined();
+
+ return static_cast<const FunctionObject &>(function).callAsConstructor(arguments.argv, arguments.argc, &newTarget);
}
void Runtime::method_throwException(ExecutionEngine *engine, const Value &value)
@@ -1161,6 +1561,8 @@ ReturnedValue Runtime::method_typeofValue(ExecutionEngine *engine, const Value &
case Value::Managed_Type:
if (value.isString())
res = engine->id_string();
+ else if (value.isSymbol())
+ res = engine->id_symbol();
else if (value.objectValue()->as<FunctionObject>())
res = engine->id_function();
else
@@ -1183,23 +1585,58 @@ QV4::ReturnedValue Runtime::method_typeofName(ExecutionEngine *engine, int nameI
return method_typeofValue(engine, prop);
}
-/* The next three methods are a bit tricky. They can't open up a Scope, as that
- * would mess up the pushing of the context.
- *
- * Instead the push/pop pair acts as a non local scope.
- */
-ReturnedValue Runtime::method_createWithContext(ExecutionContext *parent, const Value &o)
+ReturnedValue Runtime::method_createWithContext(ExecutionEngine *engine, Value *jsStackFrame)
{
- Q_ASSERT(o.isObject());
- const Object &obj = static_cast<const Object &>(o);
- return parent->newWithContext(obj.d())->asReturnedValue();
+ QV4::Value &accumulator = jsStackFrame[CallData::Accumulator];
+ accumulator = accumulator.toObject(engine);
+ if (engine->hasException)
+ return Encode::undefined();
+ Q_ASSERT(accumulator.isObject());
+ const Object &obj = static_cast<const Object &>(accumulator);
+ ExecutionContext *context = static_cast<ExecutionContext *>(jsStackFrame + CallData::Context);
+ return context->newWithContext(obj.d())->asReturnedValue();
}
-ReturnedValue Runtime::method_createCatchContext(ExecutionContext *parent, int exceptionVarNameIndex)
+ReturnedValue Runtime::method_createCatchContext(ExecutionContext *parent, int blockIndex, int exceptionVarNameIndex)
{
ExecutionEngine *e = parent->engine();
- return parent->newCatchContext(e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex],
- e->catchException(nullptr))->asReturnedValue();
+ return parent->newCatchContext(e->currentStackFrame, blockIndex,
+ e->currentStackFrame->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex])->asReturnedValue();
+}
+
+ReturnedValue Runtime::method_createBlockContext(ExecutionContext *parent, int index)
+{
+ ExecutionEngine *e = parent->engine();
+ return parent->newBlockContext(e->currentStackFrame, index)->asReturnedValue();
+}
+
+ReturnedValue Runtime::method_cloneBlockContext(ExecutionContext *previous)
+{
+ return ExecutionContext::cloneBlockContext(static_cast<Heap::CallContext *>(previous->d()))->asReturnedValue();
+}
+
+
+ReturnedValue Runtime::method_createScriptContext(ExecutionEngine *engine, int index)
+{
+ Q_ASSERT(engine->currentStackFrame->context()->d()->type == Heap::ExecutionContext::Type_GlobalContext ||
+ engine->currentStackFrame->context()->d()->type == Heap::ExecutionContext::Type_QmlContext);
+ ReturnedValue c = ExecutionContext::newBlockContext(engine->currentStackFrame, index)->asReturnedValue();
+ engine->setScriptContext(c);
+ return c;
+}
+
+ReturnedValue Runtime::method_popScriptContext(ExecutionEngine *engine)
+{
+ ReturnedValue root = engine->rootContext()->asReturnedValue();
+ engine->setScriptContext(root);
+ return root;
+}
+
+void Runtime::method_throwReferenceError(ExecutionEngine *engine, int nameIndex)
+{
+ Scope scope(engine);
+ ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
+ engine->throwReferenceError(name);
}
void Runtime::method_declareVar(ExecutionEngine *engine, bool deletable, int nameIndex)
@@ -1214,61 +1651,204 @@ ReturnedValue Runtime::method_arrayLiteral(ExecutionEngine *engine, Value *value
return engine->newArrayObject(values, length)->asReturnedValue();
}
-ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)
+ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, int classId, int argc, const QV4::Value *args)
{
Scope scope(engine);
- QV4::InternalClass *klass = static_cast<CompiledData::CompilationUnit*>(engine->currentStackFrame->v4Function->compilationUnit)->runtimeClasses[classId];
- ScopedObject o(scope, engine->newObject(klass, engine->objectPrototype()));
+ Scoped<InternalClass> klass(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeClasses[classId]);
+ ScopedObject o(scope, engine->newObject(klass->d()));
- {
- bool needSparseArray = arrayGetterSetterCountAndFlags >> 30;
- if (needSparseArray)
- o->initSparseArray();
- }
+ Q_ASSERT(uint(argc) >= klass->d()->size);
- for (uint i = 0; i < klass->size; ++i)
+ for (uint i = 0; i < klass->d()->size; ++i)
o->setProperty(i, *args++);
- if (arrayValueCount > 0) {
- ScopedValue entry(scope);
- for (int i = 0; i < arrayValueCount; ++i) {
- uint idx = args->toUInt32();
- ++args;
- entry = *args++;
- o->arraySet(idx, entry);
+ Q_ASSERT((argc - klass->d()->size) % 3 == 0);
+ int additionalArgs = (argc - int(klass->d()->size))/3;
+
+ if (!additionalArgs)
+ return o->asReturnedValue();
+
+ ScopedPropertyKey name(scope);
+ ScopedProperty pd(scope);
+ ScopedFunctionObject fn(scope);
+ ScopedString fnName(scope);
+ ScopedValue value(scope);
+ for (int i = 0; i < additionalArgs; ++i) {
+ Q_ASSERT(args->isInteger());
+ ObjectLiteralArgument arg = ObjectLiteralArgument(args->integerValue());
+ name = args[1].toPropertyKey(engine);
+ value = args[2];
+ if (engine->hasException)
+ return Encode::undefined();
+ if (arg != ObjectLiteralArgument::Value) {
+ Q_ASSERT(args[2].isInteger());
+ int functionId = args[2].integerValue();
+ QV4::Function *clos = static_cast<CompiledData::CompilationUnit*>(engine->currentStackFrame->v4Function->compilationUnit)->runtimeFunctions[functionId];
+ Q_ASSERT(clos);
+
+ PropertyKey::FunctionNamePrefix prefix = PropertyKey::None;
+ if (arg == ObjectLiteralArgument::Getter)
+ prefix = PropertyKey::Getter;
+ else if (arg == ObjectLiteralArgument::Setter)
+ prefix = PropertyKey::Setter;
+ else
+ arg = ObjectLiteralArgument::Value;
+ fnName = name->asFunctionName(engine, prefix);
+
+ ExecutionContext *current = static_cast<ExecutionContext *>(&engine->currentStackFrame->jsFrame->context);
+ if (clos->isGenerator())
+ value = MemberGeneratorFunction::create(current, clos, o, fnName)->asReturnedValue();
+ else
+ value = FunctionObject::createMemberFunction(current, clos, o, fnName)->asReturnedValue();
+ } else if (args[2].isFunctionObject()) {
+ fn = static_cast<const FunctionObject &>(args[2]);
+
+ fnName = name->asFunctionName(engine, PropertyKey::None);
+ fn->setName(fnName);
+ }
+ Q_ASSERT(arg != ObjectLiteralArgument::Method);
+ Q_ASSERT(arg == ObjectLiteralArgument::Value || value->isFunctionObject());
+ if (arg == ObjectLiteralArgument::Value || arg == ObjectLiteralArgument::Getter) {
+ pd->value = value;
+ pd->set = Value::emptyValue();
+ } else {
+ pd->value = Value::emptyValue();
+ pd->set = value;
}
+ bool ok = o->defineOwnProperty(name, pd, (arg == ObjectLiteralArgument::Value ? Attr_Data : Attr_Accessor));
+ if (!ok)
+ return engine->throwTypeError();
+
+ args += 3;
}
+ return o.asReturnedValue();
+}
- uint arrayGetterSetterCount = arrayGetterSetterCountAndFlags & ((1 << 30) - 1);
- if (arrayGetterSetterCount > 0) {
- ScopedProperty pd(scope);
- for (uint i = 0; i < arrayGetterSetterCount; ++i) {
- uint idx = args->toUInt32();
- ++args;
- pd->value = *args;
- ++args;
- pd->set = *args;
- ++args;
- o->arraySet(idx, pd, Attr_Accessor);
+ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classIndex, const Value &superClass, const Value *computedNames)
+{
+ const CompiledData::CompilationUnit *unit = engine->currentStackFrame->v4Function->compilationUnit;
+ const QV4::CompiledData::Class *cls = unit->unitData()->classAt(classIndex);
+
+ Scope scope(engine);
+ ScopedObject protoParent(scope, engine->objectPrototype());
+ ScopedObject constructorParent(scope, engine->functionPrototype());
+ if (!superClass.isEmpty()) {
+ if (superClass.isNull()) {
+ protoParent = Encode::null();
+ } else {
+ const FunctionObject *superFunction = superClass.as<FunctionObject>();
+ // ### check that the heritage object is a constructor
+ if (!superFunction || !superFunction->isConstructor())
+ return engine->throwTypeError(QStringLiteral("The superclass is not a function object."));
+ const FunctionObject *s = static_cast<const FunctionObject *>(&superClass);
+ ScopedValue result(scope, s->get(scope.engine->id_prototype()));
+ if (!result->isObject() && !result->isNull())
+ return engine->throwTypeError(QStringLiteral("The value of the superclass's prototype property is not an object."));
+ protoParent = *result;
+ constructorParent = superClass;
}
}
- return o.asReturnedValue();
+ ScopedObject proto(scope, engine->newObject());
+ proto->setPrototypeUnchecked(protoParent);
+ ExecutionContext *current = static_cast<ExecutionContext *>(&engine->currentStackFrame->jsFrame->context);
+
+ ScopedFunctionObject constructor(scope);
+ QV4::Function *f = cls->constructorFunction != UINT_MAX ? unit->runtimeFunctions[cls->constructorFunction] : nullptr;
+ constructor = FunctionObject::createConstructorFunction(current, f, proto, !superClass.isEmpty())->asReturnedValue();
+ constructor->setPrototypeUnchecked(constructorParent);
+ Value argCount = Value::fromInt32(f ? f->nFormals : 0);
+ constructor->defineReadonlyConfigurableProperty(scope.engine->id_length(), argCount);
+ constructor->defineReadonlyConfigurableProperty(engine->id_prototype(), proto);
+ proto->defineDefaultProperty(engine->id_constructor(), constructor);
+
+ ScopedString name(scope);
+ if (cls->nameIndex != UINT_MAX) {
+ name = unit->runtimeStrings[cls->nameIndex];
+ constructor->defineReadonlyConfigurableProperty(engine->id_name(), name);
+ }
+
+ ScopedObject receiver(scope, *constructor);
+ ScopedPropertyKey propertyName(scope);
+ ScopedFunctionObject function(scope);
+ ScopedProperty property(scope);
+ const CompiledData::Method *methods = cls->methodTable();
+ for (uint i = 0; i < cls->nStaticMethods + cls->nMethods; ++i) {
+ if (i == cls->nStaticMethods)
+ receiver = proto;
+ if (methods[i].name == UINT_MAX) {
+ propertyName = computedNames->toPropertyKey(engine);
+ if (propertyName == scope.engine->id_prototype()->propertyKey() && receiver->d() == constructor->d())
+ return engine->throwTypeError(QStringLiteral("Cannot declare a static method named 'prototype'."));
+ if (engine->hasException)
+ return Encode::undefined();
+ ++computedNames;
+ } else {
+ name = unit->runtimeStrings[methods[i].name];
+ propertyName = name->toPropertyKey();
+ }
+ QV4::Function *f = unit->runtimeFunctions[methods[i].function];
+ Q_ASSERT(f);
+ PropertyKey::FunctionNamePrefix prefix = PropertyKey::None;
+ if (methods[i].type == CompiledData::Method::Getter)
+ prefix = PropertyKey::Getter;
+ else if (methods[i].type == CompiledData::Method::Setter)
+ prefix = PropertyKey::Setter;
+
+ name = propertyName->asFunctionName(engine, prefix);
+
+ if (f->isGenerator())
+ function = MemberGeneratorFunction::create(current, f, receiver, name);
+ else
+ function = FunctionObject::createMemberFunction(current, f, receiver, name);
+ Q_ASSERT(function);
+ PropertyAttributes attributes;
+ switch (methods[i].type) {
+ case CompiledData::Method::Getter:
+ property->setGetter(function);
+ property->set = Value::emptyValue();
+ attributes = Attr_Accessor|Attr_NotEnumerable;
+ break;
+ case CompiledData::Method::Setter:
+ property->value = Value::emptyValue();
+ property->setSetter(function);
+ attributes = Attr_Accessor|Attr_NotEnumerable;
+ break;
+ default: // Regular
+ property->value = function;
+ property->set = Value::emptyValue();
+ attributes = Attr_Data|Attr_NotEnumerable;
+ break;
+ }
+ receiver->defineOwnProperty(propertyName, property, attributes);
+ }
+
+ return constructor->asReturnedValue();
}
QV4::ReturnedValue Runtime::method_createMappedArgumentsObject(ExecutionEngine *engine)
{
Q_ASSERT(engine->currentContext()->d()->type == Heap::ExecutionContext::Type_CallContext);
- QV4::InternalClass *ic = engine->internalClasses[EngineBase::Class_ArgumentsObject];
- return engine->memoryManager->allocObject<ArgumentsObject>(ic, engine->objectPrototype(), engine->currentStackFrame)->asReturnedValue();
+ Heap::InternalClass *ic = engine->internalClasses(EngineBase::Class_ArgumentsObject);
+ return engine->memoryManager->allocObject<ArgumentsObject>(ic, engine->currentStackFrame)->asReturnedValue();
}
QV4::ReturnedValue Runtime::method_createUnmappedArgumentsObject(ExecutionEngine *engine)
{
- QV4::InternalClass *ic = engine->internalClasses[EngineBase::Class_StrictArgumentsObject];
- return engine->memoryManager->allocObject<StrictArgumentsObject>(ic, engine->objectPrototype(), engine->currentStackFrame)->asReturnedValue();
+ Heap::InternalClass *ic = engine->internalClasses(EngineBase::Class_StrictArgumentsObject);
+ return engine->memoryManager->allocObject<StrictArgumentsObject>(ic, engine->currentStackFrame)->asReturnedValue();
+}
+
+QV4::ReturnedValue Runtime::method_createRestParameter(ExecutionEngine *engine, int argIndex)
+{
+ const Value *values = engine->currentStackFrame->originalArguments + argIndex;
+ int nValues = engine->currentStackFrame->originalArgumentsCount - argIndex;
+ if (nValues <= 0)
+ return engine->newArrayObject(0)->asReturnedValue();
+ return engine->newArrayObject(values, nValues)->asReturnedValue();
}
+
ReturnedValue Runtime::method_loadQmlContext(NoThrowEngine *engine)
{
Heap::QmlContext *ctx = engine->qmlContext();
@@ -1327,6 +1907,7 @@ ReturnedValue Runtime::method_loadQmlImportedScripts(NoThrowEngine *engine)
return Encode::undefined();
return context->importedScripts.value();
}
+#endif // V4_BOOTSTRAP
ReturnedValue Runtime::method_uMinus(const Value &value)
{
@@ -1352,11 +1933,10 @@ ReturnedValue Runtime::method_add(ExecutionEngine *engine, const Value &left, co
if (Q_LIKELY(left.integerCompatible() && right.integerCompatible()))
return add_int32(left.integerValue(), right.integerValue());
if (left.isNumber() && right.isNumber())
- return Primitive::fromDouble(left.asDouble() + right.asDouble()).asReturnedValue();
+ return Value::fromDouble(left.asDouble() + right.asDouble()).asReturnedValue();
return RuntimeHelpers::addHelper(engine, left, right);
}
-#endif // V4_BOOTSTRAP
ReturnedValue Runtime::method_sub(const Value &left, const Value &right)
{
@@ -1368,7 +1948,7 @@ ReturnedValue Runtime::method_sub(const Value &left, const Value &right)
double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl();
double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl();
- return Primitive::fromDouble(lval - rval).asReturnedValue();
+ return Value::fromDouble(lval - rval).asReturnedValue();
}
ReturnedValue Runtime::method_mul(const Value &left, const Value &right)
@@ -1381,7 +1961,7 @@ ReturnedValue Runtime::method_mul(const Value &left, const Value &right)
double lval = left.isNumber() ? left.asDouble() : left.toNumberImpl();
double rval = right.isNumber() ? right.asDouble() : right.toNumberImpl();
- return Primitive::fromDouble(lval * rval).asReturnedValue();
+ return Value::fromDouble(lval * rval).asReturnedValue();
}
ReturnedValue Runtime::method_div(const Value &left, const Value &right)
@@ -1401,17 +1981,20 @@ ReturnedValue Runtime::method_div(const Value &left, const Value &right)
double lval = left.toNumber();
double rval = right.toNumber();
- return Primitive::fromDouble(lval / rval).asReturnedValue();
+ return Value::fromDouble(lval / rval).asReturnedValue();
}
ReturnedValue Runtime::method_mod(const Value &left, const Value &right)
{
TRACE2(left, right);
- if (Value::integerCompatible(left, right) && left.integerValue() > 0 && right.integerValue() > 0) {
- int intRes = left.integerValue() % right.integerValue();
- if (intRes != 0 || left.integerValue() >= 0)
- return Encode(intRes);
+ if (Value::integerCompatible(left, right) && left.integerValue() >= 0 && right.integerValue() > 0) {
+ // special cases are handled by fmod, among them:
+ // - arithmic execeptions for ints in c++, eg: INT_MIN % -1
+ // - undefined behavior in c++, e.g.: anything % 0
+ // - uncommon cases which would complicate the condition, e.g.: negative integers
+ // (this makes sure that -1 % 1 == -0 by passing it to fmod)
+ return Encode(left.integerValue() % right.integerValue());
}
double lval = RuntimeHelpers::toNumber(left);
@@ -1419,7 +2002,7 @@ ReturnedValue Runtime::method_mod(const Value &left, const Value &right)
#ifdef fmod
# undef fmod
#endif
- return Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue();
+ return Value::fromDouble(std::fmod(lval, rval)).asReturnedValue();
}
ReturnedValue Runtime::method_shl(const Value &left, const Value &right)
@@ -1485,24 +2068,133 @@ ReturnedValue Runtime::method_lessEqual(const Value &left, const Value &right)
return Encode(r);
}
+struct LazyScope
+{
+ ExecutionEngine *engine = nullptr;
+ Value *stackMark = nullptr;
+ ~LazyScope() {
+ if (engine)
+ engine->jsStackTop = stackMark;
+ }
+ template <typename T>
+ void set(Value **scopedValue, T value, ExecutionEngine *e) {
+ if (!engine) {
+ engine = e;
+ stackMark = engine->jsStackTop;
+ }
+ if (!*scopedValue)
+ *scopedValue = e->jsAlloca(1);
+ **scopedValue = value;
+ }
+};
+
Bool Runtime::method_compareEqual(const Value &left, const Value &right)
{
TRACE2(left, right);
- if (left.rawValue() == right.rawValue())
- // NaN != NaN
- return !left.isNaN();
+ Value lhs = left;
+ Value rhs = right;
- if (left.type() == right.type()) {
- if (left.isDouble() && left.doubleValue() == 0 && right.doubleValue() == 0)
- return true; // this takes care of -0 == +0 (which obviously have different raw values)
- if (!left.isManaged())
- return false;
- if (left.isString() == right.isString())
- return left.cast<Managed>()->isEqualTo(right.cast<Managed>());
+#ifndef V4_BOOTSTRAP
+ LazyScope scope;
+ Value *lhsGuard = nullptr;
+ Value *rhsGuard = nullptr;
+#endif
+
+ redo:
+ if (lhs.asReturnedValue() == rhs.asReturnedValue())
+ return !lhs.isNaN();
+
+ int lt = lhs.quickType();
+ int rt = rhs.quickType();
+ if (rt < lt) {
+ qSwap(lhs, rhs);
+ qSwap(lt, rt);
}
- return RuntimeHelpers::equalHelper(left, right);
+ switch (lt) {
+ case QV4::Value::QT_ManagedOrUndefined:
+ if (lhs.isUndefined())
+ return rhs.isNullOrUndefined();
+ Q_FALLTHROUGH();
+ case QV4::Value::QT_ManagedOrUndefined1:
+ case QV4::Value::QT_ManagedOrUndefined2:
+ case QV4::Value::QT_ManagedOrUndefined3:
+ // LHS: Managed
+ switch (rt) {
+ case QV4::Value::QT_ManagedOrUndefined:
+ if (rhs.isUndefined())
+ return false;
+ Q_FALLTHROUGH();
+ case QV4::Value::QT_ManagedOrUndefined1:
+ case QV4::Value::QT_ManagedOrUndefined2:
+ case QV4::Value::QT_ManagedOrUndefined3: {
+#ifndef V4_BOOTSTRAP
+ // RHS: Managed
+ Heap::Base *l = lhs.m();
+ Heap::Base *r = rhs.m();
+ Q_ASSERT(l);
+ Q_ASSERT(r);
+ if (l->internalClass->vtable->isStringOrSymbol == r->internalClass->vtable->isStringOrSymbol)
+ return static_cast<QV4::Managed &>(lhs).isEqualTo(&static_cast<QV4::Managed &>(rhs));
+ if (l->internalClass->vtable->isStringOrSymbol) {
+ scope.set(&rhsGuard, RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(rhs), PREFERREDTYPE_HINT), r->internalClass->engine);
+ rhs = rhsGuard->asReturnedValue();
+ break;
+ } else {
+ Q_ASSERT(r->internalClass->vtable->isStringOrSymbol);
+ scope.set(&lhsGuard, RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(lhs), PREFERREDTYPE_HINT), l->internalClass->engine);
+ lhs = lhsGuard->asReturnedValue();
+ break;
+ }
+#endif
+ return false;
+ }
+ case QV4::Value::QT_Empty:
+ Q_UNREACHABLE();
+ case QV4::Value::QT_Null:
+ return false;
+ case QV4::Value::QT_Bool:
+ case QV4::Value::QT_Int:
+ rhs = Value::fromDouble(rhs.int_32());
+ // fall through
+ default: // double
+#ifndef V4_BOOTSTRAP
+ if (lhs.m()->internalClass->vtable->isStringOrSymbol) {
+ return lhs.m()->internalClass->vtable->isString ? (RuntimeHelpers::toNumber(lhs) == rhs.doubleValue()) : false;
+ } else {
+ scope.set(&lhsGuard, RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(lhs), PREFERREDTYPE_HINT), lhs.m()->internalClass->engine);
+ lhs = lhsGuard->asReturnedValue();
+ }
+#else
+ Q_UNIMPLEMENTED();
+#endif
+ }
+ goto redo;
+ case QV4::Value::QT_Empty:
+ Q_UNREACHABLE();
+ case QV4::Value::QT_Null:
+ return rhs.isNull();
+ case QV4::Value::QT_Bool:
+ case QV4::Value::QT_Int:
+ switch (rt) {
+ case QV4::Value::QT_ManagedOrUndefined:
+ case QV4::Value::QT_ManagedOrUndefined1:
+ case QV4::Value::QT_ManagedOrUndefined2:
+ case QV4::Value::QT_ManagedOrUndefined3:
+ case QV4::Value::QT_Empty:
+ case QV4::Value::QT_Null:
+ Q_UNREACHABLE();
+ case QV4::Value::QT_Bool:
+ case QV4::Value::QT_Int:
+ return lhs.int_32() == rhs.int_32();
+ default: // double
+ return lhs.int_32() == rhs.doubleValue();
+ }
+ default: // double
+ Q_ASSERT(rhs.isDouble());
+ return lhs.doubleValue() == rhs.doubleValue();
+ }
}
ReturnedValue Runtime::method_equal(const Value &left, const Value &right)
diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h
index 3a26c23990..72af90d1dc 100644
--- a/src/qml/jsruntime/qv4runtime_p.h
+++ b/src/qml/jsruntime/qv4runtime_p.h
@@ -100,6 +100,7 @@ enum TypeHint {
struct Q_QML_PRIVATE_EXPORT RuntimeHelpers {
static ReturnedValue objectDefaultValue(const Object *object, int typeHint);
static ReturnedValue toPrimitive(const Value &value, TypeHint typeHint);
+ static ReturnedValue ordinaryToPrimitive(ExecutionEngine *engine, const Object *object, String *typeHint);
static double stringToNumber(const QString &s);
static Heap::String *stringFromNumber(ExecutionEngine *engine, double number);
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h
index 91232256a9..34b04929af 100644
--- a/src/qml/jsruntime/qv4runtimeapi_p.h
+++ b/src/qml/jsruntime/qv4runtimeapi_p.h
@@ -98,34 +98,43 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> {
F(ReturnedValue, callPropertyLookup, (ExecutionEngine *engine, Value *base, uint index, Value *argv, int argc)) \
F(ReturnedValue, callElement, (ExecutionEngine *engine, Value *base, const Value &index, Value *argv, int argc)) \
F(ReturnedValue, callValue, (ExecutionEngine *engine, const Value &func, Value *argv, int argc)) \
+ F(ReturnedValue, callWithReceiver, (ExecutionEngine *engine, const Value &func, const Value *thisObject, Value *argv, int argc)) \
F(ReturnedValue, callPossiblyDirectEval, (ExecutionEngine *engine, Value *argv, int argc)) \
+ F(ReturnedValue, callWithSpread, (ExecutionEngine *engine, const Value &func, const Value &thisObject, Value *argv, int argc)) \
\
/* construct */ \
- F(ReturnedValue, construct, (ExecutionEngine *engine, const Value &func, Value *argv, int argc)) \
+ F(ReturnedValue, construct, (ExecutionEngine *engine, const Value &func, const Value &newTarget, Value *argv, int argc)) \
+ F(ReturnedValue, constructWithSpread, (ExecutionEngine *engine, const Value &func, const Value &newTarget, Value *argv, int argc)) \
\
/* load & store */ \
F(void, storeNameStrict, (ExecutionEngine *engine, int nameIndex, const Value &value)) \
F(void, storeNameSloppy, (ExecutionEngine *engine, int nameIndex, const Value &value)) \
- F(bool, storeProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)) \
- F(bool, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \
+ F(void, storeProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)) \
+ F(void, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \
F(ReturnedValue, loadProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)) \
F(ReturnedValue, loadName, (ExecutionEngine *engine, int nameIndex)) \
F(ReturnedValue, loadElement, (ExecutionEngine *engine, const Value &object, const Value &index)) \
+ F(ReturnedValue, loadSuperProperty, (ExecutionEngine *engine, const Value &property)) \
+ F(void, storeSuperProperty, (ExecutionEngine *engine, const Value &property, const Value &value)) \
+ F(ReturnedValue, loadSuperConstructor, (ExecutionEngine *engine, const Value &t)) \
\
/* typeof */ \
F(ReturnedValue, typeofValue, (ExecutionEngine *engine, const Value &val)) \
F(ReturnedValue, typeofName, (ExecutionEngine *engine, int nameIndex)) \
\
/* delete */ \
- F(bool, deleteElement, (ExecutionEngine *engine, const Value &base, const Value &index)) \
- F(bool, deleteMember, (ExecutionEngine *engine, const Value &base, int nameIndex)) \
- F(bool, deleteMemberString, (ExecutionEngine *engine, const Value &base, String *name)) \
+ F(bool, deleteProperty, (ExecutionEngine *engine, const Value &base, const Value &index)) \
F(bool, deleteName, (ExecutionEngine *engine, int nameIndex)) \
\
/* exceptions & scopes */ \
F(void, throwException, (ExecutionEngine *engine, const Value &value)) \
- F(ReturnedValue, createWithContext, (ExecutionContext *parent, const Value &o)) \
- F(ReturnedValue, createCatchContext, (ExecutionContext *parent, int exceptionVarNameIndex)) \
+ F(ReturnedValue, createWithContext, (ExecutionEngine *, Value *jsStackFrame)) \
+ F(ReturnedValue, createCatchContext, (ExecutionContext *parent, int blockIndex, int exceptionVarNameIndex)) \
+ F(ReturnedValue, createBlockContext, (ExecutionContext *parent, int index)) \
+ F(ReturnedValue, createScriptContext, (ExecutionEngine *engine, int index)) \
+ F(ReturnedValue, cloneBlockContext, (ExecutionContext *previous)) \
+ F(ReturnedValue, popScriptContext, (ExecutionEngine *engine)) \
+ F(void, throwReferenceError, (ExecutionEngine *engine, int nameIndex)) \
\
/* closures */ \
F(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)) \
@@ -134,14 +143,19 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> {
F(void, declareVar, (ExecutionEngine *engine, bool deletable, int nameIndex)) \
F(ReturnedValue, createMappedArgumentsObject, (ExecutionEngine *engine)) \
F(ReturnedValue, createUnmappedArgumentsObject, (ExecutionEngine *engine)) \
+ F(ReturnedValue, createRestParameter, (ExecutionEngine *engine, int argIndex)) \
\
/* literals */ \
F(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)) \
- F(ReturnedValue, objectLiteral, (ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)) \
- \
- /* foreach */ \
- F(ReturnedValue, foreachIterator, (ExecutionEngine *engine, const Value &in)) \
- F(ReturnedValue, foreachNextPropertyName, (const Value &foreach_iterator)) \
+ F(ReturnedValue, objectLiteral, (ExecutionEngine *engine, int classId, int argc, const Value *args)) \
+ F(ReturnedValue, createClass, (ExecutionEngine *engine, int classIndex, const Value &heritage, const Value *computedNames)) \
+ \
+ /* for-in, for-of and array destructuring */ \
+ F(ReturnedValue, getIterator, (ExecutionEngine *engine, const Value &in, int iterator)) \
+ F(ReturnedValue, iteratorNext, (ExecutionEngine *engine, const Value &iterator, Value *value)) \
+ F(ReturnedValue, iteratorNextForYieldStar, (ExecutionEngine *engine, const Value &received, const Value &iterator, Value *object)) \
+ F(ReturnedValue, iteratorClose, (ExecutionEngine *engine, const Value &iterator, const Value &done)) \
+ F(ReturnedValue, destructureRestElement, (ExecutionEngine *engine, const Value &iterator)) \
\
/* unary operators */ \
F(ReturnedValue, uMinus, (const Value &value)) \
diff --git a/src/qml/jsruntime/qv4runtimecodegen.cpp b/src/qml/jsruntime/qv4runtimecodegen.cpp
index fe18ddf9ed..9866966936 100644
--- a/src/qml/jsruntime/qv4runtimecodegen.cpp
+++ b/src/qml/jsruntime/qv4runtimecodegen.cpp
@@ -52,13 +52,16 @@ void RuntimeCodegen::generateFromFunctionExpression(const QString &fileName,
_module->finalUrl = fileName;
_context = nullptr;
- Compiler::ScanFunctions scan(this, sourceCode, Compiler::GlobalCode);
+ Compiler::ScanFunctions scan(this, sourceCode, Compiler::ContextType::Global);
// fake a global environment
- scan.enterEnvironment(nullptr, Compiler::FunctionCode);
+ scan.enterEnvironment(nullptr, Compiler::ContextType::Function, QString());
scan(ast);
scan.leaveEnvironment();
- int index = defineFunction(ast->name.toString(), ast, ast->formals, ast->body ? ast->body->elements : nullptr);
+ if (hasError)
+ return;
+
+ int index = defineFunction(ast->name.toString(), ast, ast->formals, ast->body);
_module->rootContext = _module->functions.at(index);
}
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index bb20f384b3..c28a3ffa2d 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -53,6 +53,7 @@
#include "qv4engine_p.h"
#include "qv4value_p.h"
#include "qv4property_p.h"
+#include "qv4propertykey_p.h"
#ifdef V4_USE_VALGRIND
#include <valgrind/memcheck.h>
@@ -117,8 +118,45 @@ struct Scope {
engine->jsStackTop = mark;
}
- QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const {
- return engine->jsAlloca(nValues);
+ enum AllocMode {
+ Undefined,
+ Empty,
+ /* Be careful when using Uninitialized, the stack has to be fully initialized before calling into the memory manager again */
+ Uninitialized
+ };
+ template <AllocMode mode = Undefined>
+ QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const
+ {
+ Value *ptr = engine->jsAlloca(nValues);
+ switch (mode) {
+ case Undefined:
+ for (int i = 0; i < nValues; ++i)
+ ptr[i] = Value::undefinedValue();
+ break;
+ case Empty:
+ for (int i = 0; i < nValues; ++i)
+ ptr[i] = Value::emptyValue();
+ break;
+ case Uninitialized:
+ break;
+ }
+ return ptr;
+ }
+ template <AllocMode mode = Undefined>
+ QML_NEARLY_ALWAYS_INLINE Value *alloc() const
+ {
+ Value *ptr = engine->jsAlloca(1);
+ switch (mode) {
+ case Undefined:
+ *ptr = Value::undefinedValue();
+ break;
+ case Empty:
+ *ptr = Value::emptyValue();
+ break;
+ case Uninitialized:
+ break;
+ }
+ return ptr;
}
bool hasException() const {
@@ -136,31 +174,31 @@ struct ScopedValue
{
ScopedValue(const Scope &scope)
{
- ptr = scope.engine->jsStackTop++;
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setRawValue(0);
}
ScopedValue(const Scope &scope, const Value &v)
{
- ptr = scope.engine->jsStackTop++;
+ ptr = scope.alloc<Scope::Uninitialized>();
*ptr = v;
}
ScopedValue(const Scope &scope, Heap::Base *o)
{
- ptr = scope.engine->jsStackTop++;
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setM(o);
}
ScopedValue(const Scope &scope, Managed *m)
{
- ptr = scope.engine->jsStackTop++;
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setRawValue(m->asReturnedValue());
}
ScopedValue(const Scope &scope, const ReturnedValue &v)
{
- ptr = scope.engine->jsStackTop++;
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setRawValue(v);
}
@@ -203,6 +241,50 @@ struct ScopedValue
Value *ptr;
};
+
+struct ScopedPropertyKey
+{
+ ScopedPropertyKey(const Scope &scope)
+ {
+ ptr = reinterpret_cast<PropertyKey *>(scope.alloc<Scope::Uninitialized>());
+ *ptr = PropertyKey::invalid();
+ }
+
+ ScopedPropertyKey(const Scope &scope, const PropertyKey &v)
+ {
+ ptr = reinterpret_cast<PropertyKey *>(scope.alloc<Scope::Uninitialized>());
+ *ptr = v;
+ }
+
+ ScopedPropertyKey &operator=(const PropertyKey &other) {
+ *ptr = other;
+ return *this;
+ }
+
+ PropertyKey *operator->() {
+ return ptr;
+ }
+ operator PropertyKey() const {
+ return *ptr;
+ }
+
+ bool operator==(const PropertyKey &other) const {
+ return *ptr == other;
+ }
+ bool operator==(const ScopedPropertyKey &other) const {
+ return *ptr == *other.ptr;
+ }
+ bool operator!=(const PropertyKey &other) const {
+ return *ptr != other;
+ }
+ bool operator!=(const ScopedPropertyKey &other) const {
+ return *ptr != *other.ptr;
+ }
+
+ PropertyKey *ptr;
+};
+
+
template<typename T>
struct Scoped
{
@@ -214,66 +296,66 @@ struct Scoped
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Undefined>();
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(v.as<T>());
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, Heap::Base *o)
{
Value v;
v = o;
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(v.as<T>());
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ScopedValue &v)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(v.ptr->as<T>());
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v, ConvertType)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setRawValue(value_convert<T>(scope.engine, v));
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value *v)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(v ? v->as<T>() : nullptr);
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, T *t)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(t);
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const T *t)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(t);
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, typename T::Data *t)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
*ptr = t;
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
setPointer(QV4::Value::fromReturnedValue(v).as<T>());
}
QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v, ConvertType)
{
- ptr = scope.engine->jsAlloca(1);
+ ptr = scope.alloc<Scope::Uninitialized>();
ptr->setRawValue(value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v)));
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 5cd62c90f1..070c048c8f 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -57,10 +57,11 @@
#include <QtCore/QDebug>
#include <QtCore/QString>
+#include <QScopedValueRollback>
using namespace QV4;
-Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit)
+Script::Script(ExecutionEngine *v4, QmlContext *qml, const QQmlRefPointer<CompiledData::CompilationUnit> &compilationUnit)
: line(1), column(0), context(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
, compilationUnit(compilationUnit), vmFunction(nullptr), parseAsBinding(true)
{
@@ -128,7 +129,7 @@ void Script::parse()
RuntimeCodegen cg(v4, &jsGenerator, strictMode);
if (inheritContext)
cg.setUseFastLookups(false);
- cg.generateFromProgram(sourceFile, sourceFile, sourceCode, program, &module, compilationMode);
+ cg.generateFromProgram(sourceFile, sourceFile, sourceCode, program, &module, contextType);
if (v4->hasException)
return;
@@ -154,7 +155,7 @@ ReturnedValue Script::run(const QV4::Value *thisObject)
QV4::Scope valueScope(engine);
if (qmlContext.isUndefined()) {
- TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
+ QScopedValueRollback<Function*> savedGlobalCode(engine->globalCode, vmFunction);
return vmFunction->call(thisObject ? thisObject : engine->globalObject, nullptr, 0,
context);
@@ -171,39 +172,20 @@ Function *Script::function()
return vmFunction;
}
-QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compiler::Module *module, Compiler::JSUnitGenerator *unitGenerator,
+QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine, Compiler::JSUnitGenerator *unitGenerator,
const QString &fileName, const QString &finalUrl, const QString &source,
- QList<QQmlError> *reportedErrors, Directives *directivesCollector)
+ QList<QQmlError> *reportedErrors)
{
using namespace QV4::Compiler;
using namespace QQmlJS::AST;
- Engine ee;
- if (directivesCollector)
- ee.setDirectives(directivesCollector);
- Lexer lexer(&ee);
+ Lexer lexer(jsEngine);
lexer.setCode(source, /*line*/1, /*qml mode*/false);
- Parser parser(&ee);
+ Parser parser(jsEngine);
parser.parseProgram();
- QList<QQmlError> errors;
-
- const auto diagnosticMessages = parser.diagnosticMessages();
- for (const DiagnosticMessage &m : diagnosticMessages) {
- if (m.isWarning()) {
- qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message));
- continue;
- }
-
- QQmlError error;
- error.setUrl(QUrl(fileName));
- error.setDescription(m.message);
- error.setLine(m.loc.startLine);
- error.setColumn(m.loc.startColumn);
- errors << error;
- }
-
+ QList<QQmlError> errors = QQmlEnginePrivate::qmlErrorFromDiagnostics(fileName, parser.diagnosticMessages());
if (!errors.isEmpty()) {
if (reportedErrors)
*reportedErrors << errors;
@@ -219,7 +201,7 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compi
Codegen cg(unitGenerator, /*strict mode*/false);
cg.setUseFastLookups(false);
- cg.generateFromProgram(fileName, finalUrl, source, program, module, GlobalCode);
+ cg.generateFromProgram(fileName, finalUrl, source, program, module, ContextType::Global);
errors = cg.qmlErrors();
if (!errors.isEmpty()) {
if (reportedErrors)
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index b4ac150044..e7189664e2 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -62,12 +62,16 @@ QT_BEGIN_NAMESPACE
class QQmlContextData;
+namespace QQmlJS {
+class Engine;
+}
+
namespace QV4 {
struct Q_QML_EXPORT Script {
- Script(ExecutionContext *scope, QV4::Compiler::CompilationMode mode, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
+ Script(ExecutionContext *scope, QV4::Compiler::ContextType mode, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
: sourceFile(source), line(line), column(column), sourceCode(sourceCode)
- , context(scope), strictMode(false), inheritContext(false), parsed(false), compilationMode(mode)
+ , context(scope), strictMode(false), inheritContext(false), parsed(false), contextType(mode)
, vmFunction(nullptr), parseAsBinding(false) {}
Script(ExecutionEngine *engine, QmlContext *qml, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
: sourceFile(source), line(line), column(column), sourceCode(sourceCode)
@@ -76,7 +80,7 @@ struct Q_QML_EXPORT Script {
if (qml)
qmlContext.set(engine, *qml);
}
- Script(ExecutionEngine *engine, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit);
+ Script(ExecutionEngine *engine, QmlContext *qml, const QQmlRefPointer<CompiledData::CompilationUnit> &compilationUnit);
~Script();
QString sourceFile;
int line;
@@ -86,7 +90,7 @@ struct Q_QML_EXPORT Script {
bool strictMode;
bool inheritContext;
bool parsed;
- QV4::Compiler::CompilationMode compilationMode = QV4::Compiler::EvalCode;
+ QV4::Compiler::ContextType contextType = QV4::Compiler::ContextType::Eval;
QV4::PersistentValue qmlContext;
QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit;
Function *vmFunction;
@@ -97,10 +101,9 @@ struct Q_QML_EXPORT Script {
Function *function();
- static QQmlRefPointer<CompiledData::CompilationUnit> precompile(
- QV4::Compiler::Module *module, Compiler::JSUnitGenerator *unitGenerator,
+ static QQmlRefPointer<CompiledData::CompilationUnit> precompile(QV4::Compiler::Module *module, QQmlJS::Engine *jsEngine, Compiler::JSUnitGenerator *unitGenerator,
const QString &fileName, const QString &finalUrl, const QString &source,
- QList<QQmlError> *reportedErrors = nullptr, QQmlJS::Directives *directivesCollector = nullptr);
+ QList<QQmlError> *reportedErrors = nullptr);
static Script *createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl, QString *error);
static ReturnedValue evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext);
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 7d29d0b517..1eef12a491 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -227,7 +227,7 @@ namespace Heap {
template <typename Container>
struct QQmlSequence : Object {
void init(const Container &container);
- void init(QObject *object, int propertyIndex);
+ void init(QObject *object, int propertyIndex, bool readOnly);
void destroy() {
delete container;
object.destroy();
@@ -237,7 +237,8 @@ struct QQmlSequence : Object {
mutable Container *container;
QQmlQPointer<QObject> object;
int propertyIndex;
- bool isReference;
+ bool isReference : 1;
+ bool isReadOnly : 1;
};
}
@@ -294,6 +295,9 @@ public:
return false;
}
+ if (d()->isReadOnly)
+ return false;
+
if (d()->isReference) {
if (!d()->object)
return false;
@@ -338,27 +342,37 @@ public:
return (index < size_t(d()->container->size())) ? QV4::Attr_Data : QV4::Attr_Invalid;
}
- void containerAdvanceIterator(ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs)
+ struct OwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
{
- name->setM(nullptr);
- *index = UINT_MAX;
+ ~OwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override
+ {
+ const QQmlSequence *s = static_cast<const QQmlSequence *>(o);
- if (d()->isReference) {
- if (!d()->object) {
- QV4::Object::advanceIterator(this, it, name, index, p, attrs);
- return;
+ if (s->d()->isReference) {
+ if (!s->d()->object)
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+ s->loadReference();
}
- loadReference();
- }
- if (it->arrayIndex < static_cast<uint>(d()->container->size())) {
- *index = it->arrayIndex;
- ++it->arrayIndex;
- *attrs = QV4::Attr_Data;
- p->value = convertElementToValue(engine(), d()->container->at(*index));
- return;
+ if (arrayIndex < static_cast<uint>(s->d()->container->size())) {
+ uint index = arrayIndex;
+ ++arrayIndex;
+ if (attrs)
+ *attrs = QV4::Attr_Data;
+ if (pd)
+ pd->value = convertElementToValue(s->engine(), s->d()->container->at(index));
+ return PropertyKey::fromArrayIndex(index);
+ }
+
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
}
- QV4::Object::advanceIterator(this, it, name, index, p, attrs);
+ };
+
+ static OwnPropertyKeyIterator *containerOwnPropertyKeys(const Object *m, Value *target)
+ {
+ *target = *m;
+ return new OwnPropertyKeyIterator;
}
bool containerDeleteIndexedProperty(uint index)
@@ -366,6 +380,8 @@ public:
/* Qt containers have int (rather than uint) allowable indexes. */
if (index > INT_MAX)
return false;
+ if (d()->isReadOnly)
+ return false;
if (d()->isReference) {
if (!d()->object)
return false;
@@ -432,11 +448,13 @@ public:
const QV4::Value *m_compareFn;
};
- void sort(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ bool sort(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
+ if (d()->isReadOnly)
+ return false;
if (d()->isReference) {
if (!d()->object)
- return;
+ return false;
loadReference();
}
@@ -450,6 +468,8 @@ public:
if (d()->isReference)
storeReference();
+
+ return true;
}
static QV4::ReturnedValue method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -480,6 +500,10 @@ public:
generateWarning(scope.engine, QLatin1String("Index out of range during length set"));
RETURN_UNDEFINED();
}
+
+ if (This->d()->isReadOnly)
+ THROW_TYPE_ERROR();
+
/* Read the sequence from the QObject property if we're a reference */
if (This->d()->isReference) {
if (!This->d()->object)
@@ -524,7 +548,7 @@ public:
quint32 length = array->getLength();
QV4::ScopedValue v(scope);
for (quint32 i = 0; i < length; ++i)
- result.push_back(convertValueToElement<typename Container::value_type>((v = array->getIndexed(i))));
+ result.push_back(convertValueToElement<typename Container::value_type>((v = array->get(i))));
return QVariant::fromValue(result);
}
@@ -549,18 +573,32 @@ public:
QMetaObject::metacall(d()->object, QMetaObject::WriteProperty, d()->propertyIndex, a);
}
- static QV4::ReturnedValue getIndexed(const QV4::Managed *that, uint index, bool *hasProperty)
- { return static_cast<const QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty); }
- static bool putIndexed(Managed *that, uint index, const QV4::Value &value)
- { return static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(index, value); }
+ static QV4::ReturnedValue virtualGet(const QV4::Managed *that, PropertyKey id, const Value *receiver, bool *hasProperty)
+ {
+ if (!id.isArrayIndex())
+ return Object::virtualGet(that, id, receiver, hasProperty);
+ return static_cast<const QQmlSequence<Container> *>(that)->containerGetIndexed(id.asArrayIndex(), hasProperty);
+ }
+ static bool virtualPut(Managed *that, PropertyKey id, const QV4::Value &value, Value *receiver)
+ {
+ if (id.isArrayIndex())
+ return static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(id.asArrayIndex(), value);
+ return Object::virtualPut(that, id, value, receiver);
+ }
static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index)
{ return static_cast<const QQmlSequence<Container> *>(that)->containerQueryIndexed(index); }
- static bool deleteIndexedProperty(QV4::Managed *that, uint index)
- { return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index); }
- static bool isEqualTo(Managed *that, Managed *other)
+ static bool virtualDeleteProperty(QV4::Managed *that, PropertyKey id)
+ {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ return static_cast<QQmlSequence<Container> *>(that)->containerDeleteIndexedProperty(index);
+ }
+ return Object::virtualDeleteProperty(that, id);
+ }
+ static bool virtualIsEqualTo(Managed *that, Managed *other)
{ return static_cast<QQmlSequence<Container> *>(that)->containerIsEqualTo(other); }
- static void advanceIterator(Managed *that, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs)
- { return static_cast<QQmlSequence<Container> *>(that)->containerAdvanceIterator(it, name, index, p, attrs); }
+ static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target)
+ { return static_cast<const QQmlSequence<Container> *>(m)->containerOwnPropertyKeys(m, target);}
};
@@ -572,6 +610,7 @@ void Heap::QQmlSequence<Container>::init(const Container &container)
this->container = new Container(container);
propertyIndex = -1;
isReference = false;
+ isReadOnly = false;
object.init();
QV4::Scope scope(internalClass->engine);
@@ -581,12 +620,13 @@ void Heap::QQmlSequence<Container>::init(const Container &container)
}
template <typename Container>
-void Heap::QQmlSequence<Container>::init(QObject *object, int propertyIndex)
+void Heap::QQmlSequence<Container>::init(QObject *object, int propertyIndex, bool readOnly)
{
Object::init();
this->container = new Container;
this->propertyIndex = propertyIndex;
isReference = true;
+ this->isReadOnly = readOnly;
this->object.init(object);
QV4::Scope scope(internalClass->engine);
QV4::Scoped<QV4::QQmlSequence<Container> > o(scope, this);
@@ -668,7 +708,8 @@ ReturnedValue SequencePrototype::method_sort(const FunctionObject *b, const Valu
#define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \
if (QQml##SequenceElementTypeName##List *s = o->as<QQml##SequenceElementTypeName##List>()) { \
- s->sort(b, thisObject, argv, argc); \
+ if (!s->sort(b, thisObject, argv, argc)) \
+ THROW_TYPE_ERROR(); \
} else
FOREACH_QML_SEQUENCE_TYPE(CALL_SORT)
@@ -691,11 +732,11 @@ bool SequencePrototype::isSequenceType(int sequenceTypeId)
#define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
if (sequenceType == qMetaTypeId<SequenceType>()) { \
- QV4::ScopedObject obj(scope, engine->memoryManager->allocObject<QQml##ElementTypeName##List>(object, propertyIndex)); \
+ QV4::ScopedObject obj(scope, engine->memoryManager->allocate<QQml##ElementTypeName##List>(object, propertyIndex, readOnly)); \
return obj.asReturnedValue(); \
} else
-ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int sequenceType, QObject *object, int propertyIndex, bool *succeeded)
+ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int sequenceType, QObject *object, int propertyIndex, bool readOnly, bool *succeeded)
{
QV4::Scope scope(engine);
// This function is called when the property is a QObject Q_PROPERTY of
@@ -709,7 +750,7 @@ ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int s
#define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \
if (sequenceType == qMetaTypeId<SequenceType>()) { \
- QV4::ScopedObject obj(scope, engine->memoryManager->allocObject<QQml##ElementTypeName##List>(v.value<SequenceType >())); \
+ QV4::ScopedObject obj(scope, engine->memoryManager->allocate<QQml##ElementTypeName##List>(v.value<SequenceType >())); \
return obj.asReturnedValue(); \
} else
diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h
index e9bef2f604..da71215bed 100644
--- a/src/qml/jsruntime/qv4sequenceobject_p.h
+++ b/src/qml/jsruntime/qv4sequenceobject_p.h
@@ -59,6 +59,8 @@
#include "qv4context_p.h"
#include "qv4string_p.h"
+QT_REQUIRE_CONFIG(qml_sequence_object);
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -72,7 +74,7 @@ struct SequencePrototype : public QV4::Object
static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static bool isSequenceType(int sequenceTypeId);
- static ReturnedValue newSequence(QV4::ExecutionEngine *engine, int sequenceTypeId, QObject *object, int propertyIndex, bool *succeeded);
+ static ReturnedValue newSequence(QV4::ExecutionEngine *engine, int sequenceTypeId, QObject *object, int propertyIndex, bool readOnly, bool *succeeded);
static ReturnedValue fromVariant(QV4::ExecutionEngine *engine, const QVariant& v, bool *succeeded);
static int metaTypeForSequence(const Object *object);
static QVariant toVariant(Object *object);
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index 14def49d0a..50871a4d87 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -40,13 +40,17 @@
#include "qv4serialize_p.h"
#include <private/qv8engine_p.h>
+#if QT_CONFIG(qml_list_model)
#include <private/qqmllistmodel_p.h>
#include <private/qqmllistmodelworkeragent_p.h>
+#endif
#include <private/qv4value_p.h>
#include <private/qv4dateobject_p.h>
#include <private/qv4regexpobject_p.h>
+#if QT_CONFIG(qml_sequence_object)
#include <private/qv4sequenceobject_p.h>
+#endif
#include <private/qv4objectproto_p.h>
#include <private/qv4qobjectwrapper_p.h>
@@ -82,8 +86,12 @@ enum Type {
WorkerNumber,
WorkerDate,
WorkerRegexp,
+#if QT_CONFIG(qml_list_model)
WorkerListModel,
+#endif
+#if QT_CONFIG(qml_sequence_object)
WorkerSequence
+#endif
};
static inline quint32 valueheader(Type type, quint32 size = 0)
@@ -189,7 +197,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
push(data, valueheader(WorkerArray, length));
ScopedValue val(scope);
for (uint ii = 0; ii < length; ++ii)
- serialize(data, (val = array->getIndexed(ii)), engine);
+ serialize(data, (val = array->get(ii)), engine);
} else if (v.isInteger()) {
reserve(data, 2 * sizeof(quint32));
push(data, valueheader(WorkerInt32));
@@ -228,6 +236,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
} else if (const QObjectWrapper *qobjectWrapper = v.as<QV4::QObjectWrapper>()) {
// XXX TODO: Generalize passing objects between the main thread and worker scripts so
// that others can trivially plug in their elements.
+#if QT_CONFIG(qml_list_model)
QQmlListModel *lm = qobject_cast<QQmlListModel *>(qobjectWrapper->object());
if (lm && lm->agent()) {
QQmlListModelWorkerAgent *agent = lm->agent();
@@ -236,9 +245,13 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
push(data, (void *)agent);
return;
}
+#else
+ Q_UNUSED(qobjectWrapper);
+#endif
// No other QObject's are allowed to be sent
push(data, valueheader(WorkerUndefined));
} else if (const Object *o = v.as<Object>()) {
+#if QT_CONFIG(qml_sequence_object)
if (o->isListType()) {
// valid sequence. we generate a length (sequence length + 1 for the sequence type)
uint seqLength = ScopedValue(scope, o->get(engine->id_length()))->toUInt32();
@@ -249,13 +262,14 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
}
reserve(data, sizeof(quint32) + length * sizeof(quint32));
push(data, valueheader(WorkerSequence, length));
- serialize(data, QV4::Primitive::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type
+ serialize(data, QV4::Value::fromInt32(QV4::SequencePrototype::metaTypeForSequence(o)), engine); // sequence type
ScopedValue val(scope);
for (uint ii = 0; ii < seqLength; ++ii)
- serialize(data, (val = o->getIndexed(ii)), engine); // sequence elements
+ serialize(data, (val = o->get(ii)), engine); // sequence elements
return;
}
+#endif
// regular object
QV4::ScopedValue val(scope, v);
@@ -269,7 +283,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
QV4::ScopedValue s(scope);
for (quint32 ii = 0; ii < length; ++ii) {
- s = properties->getIndexed(ii);
+ s = properties->get(ii);
serialize(data, s, engine);
QV4::String *str = s->as<String>();
@@ -318,7 +332,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
ScopedValue v(scope);
for (quint32 ii = 0; ii < size; ++ii) {
v = deserialize(data, engine);
- a->putIndexed(ii, v);
+ a->put(ii, v);
}
return a.asReturnedValue();
}
@@ -344,7 +358,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
case WorkerNumber:
return QV4::Encode(popDouble(data));
case WorkerDate:
- return QV4::Encode(engine->newDateObject(QV4::Primitive::fromDouble(popDouble(data))));
+ return QV4::Encode(engine->newDateObject(QV4::Value::fromDouble(popDouble(data))));
case WorkerRegexp:
{
quint32 flags = headersize(header);
@@ -353,6 +367,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
data += ALIGN(length * sizeof(quint16));
return Encode(engine->newRegExpObject(pattern, flags));
}
+#if QT_CONFIG(qml_list_model)
case WorkerListModel:
{
void *ptr = popPtr(data);
@@ -369,6 +384,8 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
agent->setEngine(engine);
return rv->asReturnedValue();
}
+#endif
+#if QT_CONFIG(qml_sequence_object)
case WorkerSequence:
{
ScopedValue value(scope);
@@ -387,6 +404,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine)
QVariant seqVariant = QV4::SequencePrototype::toVariant(array, sequenceType, &succeeded);
return QV4::SequencePrototype::fromVariant(engine, seqVariant, &succeeded);
}
+#endif
}
Q_ASSERT(!"Unreachable");
return QV4::Encode::undefined();
diff --git a/src/qml/jsruntime/qv4setiterator.cpp b/src/qml/jsruntime/qv4setiterator.cpp
new file mode 100644
index 0000000000..d32e2079a0
--- /dev/null
+++ b/src/qml/jsruntime/qv4setiterator.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qv4iterator_p.h>
+#include <private/qv4estable_p.h>
+#include <private/qv4setiterator_p.h>
+#include <private/qv4setobject_p.h>
+#include <private/qv4symbol_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(SetIteratorObject);
+
+void SetIteratorPrototype::init(ExecutionEngine *e)
+{
+ defineDefaultProperty(QStringLiteral("next"), method_next, 0);
+
+ Scope scope(e);
+ ScopedString val(scope, e->newString(QLatin1String("Set Iterator")));
+ defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);
+}
+
+ReturnedValue SetIteratorPrototype::method_next(const FunctionObject *b, const Value *that, const Value *, int)
+{
+ Scope scope(b);
+ const SetIteratorObject *thisObject = that->as<SetIteratorObject>();
+ if (!thisObject)
+ return scope.engine->throwTypeError(QLatin1String("Not a Set Iterator instance"));
+
+ Scoped<SetObject> s(scope, thisObject->d()->iteratedSet);
+ uint index = thisObject->d()->setNextIndex;
+ IteratorKind itemKind = thisObject->d()->iterationKind;
+
+ if (!s) {
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ Value *arguments = scope.alloc(2);
+
+ while (index < s->d()->esTable->size()) {
+ s->d()->esTable->iterate(index, &arguments[0], &arguments[1]);
+ thisObject->d()->setNextIndex = index + 1;
+
+ if (itemKind == KeyValueIteratorKind) {
+ ScopedArrayObject resultArray(scope, scope.engine->newArrayObject());
+ resultArray->arrayReserve(2);
+ resultArray->arrayPut(0, arguments[0]);
+ resultArray->arrayPut(1, arguments[0]); // yes, the key is repeated.
+ resultArray->setArrayLengthUnchecked(2);
+
+ return IteratorPrototype::createIterResultObject(scope.engine, resultArray, false);
+ }
+
+ return IteratorPrototype::createIterResultObject(scope.engine, arguments[0], false);
+ }
+
+ thisObject->d()->iteratedSet.set(scope.engine, nullptr);
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+}
+
diff --git a/src/qml/jsruntime/qv4setiterator_p.h b/src/qml/jsruntime/qv4setiterator_p.h
new file mode 100644
index 0000000000..78eda6d57b
--- /dev/null
+++ b/src/qml/jsruntime/qv4setiterator_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4SETITERATOR_P_H
+#define QV4SETITERATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4iterator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+
+#define SetIteratorObjectMembers(class, Member) \
+ Member(class, Pointer, Object *, iteratedSet) \
+ Member(class, NoMark, IteratorKind, iterationKind) \
+ Member(class, NoMark, quint32, setNextIndex)
+
+DECLARE_HEAP_OBJECT(SetIteratorObject, Object) {
+ DECLARE_MARKOBJECTS(SetIteratorObject);
+ void init(Object *obj, QV4::ExecutionEngine *engine)
+ {
+ Object::init();
+ this->iteratedSet.set(engine, obj);
+ this->setNextIndex = 0;
+ }
+};
+
+}
+
+struct SetIteratorPrototype : Object
+{
+ V4_PROTOTYPE(iteratorPrototype)
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct SetIteratorObject : Object
+{
+ V4_OBJECT2(SetIteratorObject, Object)
+ Q_MANAGED_TYPE(SetIteratorObject)
+ V4_PROTOTYPE(setIteratorPrototype)
+
+ void init(ExecutionEngine *engine);
+};
+
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4SETITERATOR_P_H
+
diff --git a/src/qml/jsruntime/qv4setobject.cpp b/src/qml/jsruntime/qv4setobject.cpp
new file mode 100644
index 0000000000..3c9b5031d1
--- /dev/null
+++ b/src/qml/jsruntime/qv4setobject.cpp
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qv4setobject_p.h"
+#include "qv4setiterator_p.h"
+#include "qv4estable_p.h"
+#include "qv4symbol_p.h"
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(SetCtor);
+DEFINE_OBJECT_VTABLE(WeakSetCtor);
+DEFINE_OBJECT_VTABLE(SetObject);
+
+void Heap::WeakSetCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("WeakSet"));
+}
+
+void Heap::SetCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("Set"));
+}
+
+ReturnedValue WeakSetCtor::construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool isWeak)
+{
+ Scope scope(f);
+ Scoped<SetObject> a(scope, scope.engine->memoryManager->allocate<SetObject>());
+ if (isWeak)
+ a->setPrototypeOf(scope.engine->weakSetPrototype());
+ a->d()->isWeakSet = isWeak;
+
+ if (argc > 0) {
+ ScopedValue iterable(scope, argv[0]);
+ if (!iterable->isUndefined() && !iterable->isNull()) {
+ ScopedFunctionObject adder(scope, a->get(ScopedString(scope, scope.engine->newString(QString::fromLatin1("add")))));
+ if (!adder)
+ return scope.engine->throwTypeError();
+ ScopedObject iter(scope, Runtime::method_getIterator(scope.engine, iterable, true));
+ CHECK_EXCEPTION();
+ if (!iter)
+ return a.asReturnedValue();
+
+ Value *nextValue = scope.alloc(1);
+ ScopedValue done(scope);
+ forever {
+ done = Runtime::method_iteratorNext(scope.engine, iter, nextValue);
+ CHECK_EXCEPTION();
+ if (done->toBoolean())
+ return a.asReturnedValue();
+
+ adder->call(a, nextValue, 1);
+ if (scope.engine->hasException) {
+ ScopedValue falsey(scope, Encode(false));
+ return Runtime::method_iteratorClose(scope.engine, iter, falsey);
+ }
+ }
+ }
+ }
+
+ return a.asReturnedValue();
+}
+
+ReturnedValue WeakSetCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ return construct(f, argv, argc, newTarget, true);
+}
+
+ReturnedValue WeakSetCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
+{
+ Scope scope(f);
+ return scope.engine->throwTypeError(QString::fromLatin1("Set requires new"));
+}
+
+ReturnedValue SetCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
+{
+ return construct(f, argv, argc, newTarget, false);
+}
+
+void WeakSetPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedObject o(scope);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+ ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+
+ defineDefaultProperty(QStringLiteral("add"), method_add, 1);
+ defineDefaultProperty(QStringLiteral("delete"), method_delete, 1);
+ defineDefaultProperty(QStringLiteral("has"), method_has, 1);
+
+ ScopedString val(scope, engine->newString(QLatin1String("WeakSet")));
+ defineReadonlyConfigurableProperty(engine->symbol_toStringTag(), val);
+}
+
+ReturnedValue WeakSetPrototype::method_add(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if ((!that || !that->d()->isWeakSet) ||
+ (!argc || !argv[0].isObject()))
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->set(argv[0], Value::undefinedValue());
+ return that.asReturnedValue();
+}
+
+ReturnedValue WeakSetPrototype::method_delete(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || !that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+ if (!argc || !argv[0].isObject())
+ return Encode(false);
+
+ return Encode(that->d()->esTable->remove(argv[0]));
+}
+
+ReturnedValue WeakSetPrototype::method_has(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || !that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+ if (!argc || !argv[0].isObject())
+ return Encode(false);
+
+ return Encode(that->d()->esTable->has(argv[0]));
+}
+
+void SetPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedObject o(scope);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+ ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
+ ctor->addSymbolSpecies();
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+
+ defineDefaultProperty(QStringLiteral("add"), method_add, 1);
+ defineDefaultProperty(QStringLiteral("clear"), method_clear, 0);
+ defineDefaultProperty(QStringLiteral("delete"), method_delete, 1);
+ defineDefaultProperty(QStringLiteral("entries"), method_entries, 0);
+ defineDefaultProperty(QStringLiteral("forEach"), method_forEach, 1);
+ defineDefaultProperty(QStringLiteral("has"), method_has, 1);
+ defineAccessorProperty(QStringLiteral("size"), method_get_size, nullptr);
+
+ // Per the spec, the value for 'keys' is the same as 'values'.
+ ScopedString valString(scope, scope.engine->newIdentifier(QStringLiteral("values")));
+ ScopedFunctionObject valuesFn(scope, FunctionObject::createBuiltinFunction(engine, valString, SetPrototype::method_values, 0));
+ defineDefaultProperty(QStringLiteral("keys"), valuesFn);
+ defineDefaultProperty(QStringLiteral("values"), valuesFn);
+
+ defineDefaultProperty(engine->symbol_iterator(), valuesFn);
+
+ ScopedString val(scope, engine->newString(QLatin1String("Set")));
+ defineReadonlyConfigurableProperty(engine->symbol_toStringTag(), val);
+}
+
+void Heap::SetObject::init()
+{
+ Object::init();
+ esTable = new ESTable();
+}
+
+void Heap::SetObject::destroy()
+{
+ delete esTable;
+ esTable = 0;
+}
+
+void Heap::SetObject::removeUnmarkedKeys()
+{
+ esTable->removeUnmarkedKeys();
+}
+
+void Heap::SetObject::markObjects(Heap::Base *that, MarkStack *markStack)
+{
+ SetObject *s = static_cast<SetObject *>(that);
+ s->esTable->markObjects(markStack, s->isWeakSet);
+ Object::markObjects(that, markStack);
+}
+
+ReturnedValue SetPrototype::method_add(const FunctionObject *b, const Value *thisObject, const Value *argv, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->set(argv[0], Value::undefinedValue());
+ return that.asReturnedValue();
+}
+
+ReturnedValue SetPrototype::method_clear(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ that->d()->esTable->clear();
+ return Encode::undefined();
+}
+
+ReturnedValue SetPrototype::method_delete(const FunctionObject *b, const Value *thisObject, const Value *argv, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->remove(argv[0]));
+}
+
+ReturnedValue SetPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ Scoped<SetIteratorObject> ao(scope, scope.engine->newSetIteratorObject(that));
+ ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue SetPrototype::method_forEach(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ ScopedFunctionObject callbackfn(scope, argv[0]);
+ if (!callbackfn)
+ return scope.engine->throwTypeError();
+
+ ScopedValue thisArg(scope, Value::undefinedValue());
+ if (argc > 1)
+ thisArg = ScopedValue(scope, argv[1]);
+
+ Value *arguments = scope.alloc(3);
+ for (uint i = 0; i < that->d()->esTable->size(); ++i) {
+ that->d()->esTable->iterate(i, &arguments[0], &arguments[1]); // fill in key (0), value (1)
+ arguments[1] = arguments[0]; // but for set, we want to return the key twice; value is always undefined.
+
+ arguments[2] = that;
+ callbackfn->call(thisArg, arguments, 3);
+ CHECK_EXCEPTION();
+ }
+ return Encode::undefined();
+}
+
+ReturnedValue SetPrototype::method_has(const FunctionObject *b, const Value *thisObject, const Value *argv, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->has(argv[0]));
+}
+
+ReturnedValue SetPrototype::method_get_size(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ return Encode(that->d()->esTable->size());
+}
+
+ReturnedValue SetPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<SetObject> that(scope, thisObject);
+ if (!that || that->d()->isWeakSet)
+ return scope.engine->throwTypeError();
+
+ Scoped<SetIteratorObject> ao(scope, scope.engine->newSetIteratorObject(that));
+ ao->d()->iterationKind = IteratorKind::ValueIteratorKind;
+ return ao->asReturnedValue();
+}
diff --git a/src/qml/jsruntime/qv4setobject_p.h b/src/qml/jsruntime/qv4setobject_p.h
new file mode 100644
index 0000000000..21584e2132
--- /dev/null
+++ b/src/qml/jsruntime/qv4setobject_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Crimson AS <info@crimson.no>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4SETOBJECT_P_H
+#define QV4SETOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4objectproto_p.h"
+#include "qv4functionobject_p.h"
+#include "qv4string_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+class ESTable;
+
+namespace Heap {
+
+struct WeakSetCtor : FunctionObject {
+ void init(QV4::ExecutionContext *scope);
+};
+
+
+struct SetCtor : WeakSetCtor {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct SetObject : Object {
+ static void markObjects(Heap::Base *that, MarkStack *markStack);
+ void init();
+ void destroy();
+ void removeUnmarkedKeys();
+
+ ESTable *esTable;
+ SetObject *nextWeakSet;
+ bool isWeakSet;
+};
+
+}
+
+
+struct WeakSetCtor: FunctionObject
+{
+ V4_OBJECT2(WeakSetCtor, FunctionObject)
+
+ static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakSet);
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct SetCtor : WeakSetCtor
+{
+ V4_OBJECT2(SetCtor, WeakSetCtor)
+
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+};
+
+struct SetObject : Object
+{
+ V4_OBJECT2(SetObject, Object)
+ V4_PROTOTYPE(setPrototype)
+ V4_NEEDS_DESTROY
+};
+
+struct WeakSetPrototype : Object
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+
+struct SetPrototype : WeakSetPrototype
+{
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_clear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_get_size(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+
+} // namespace QV4
+
+
+QT_END_NAMESPACE
+
+#endif // QV4SETOBJECT_P_H
diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp
index 2a3e28bf63..8930c9a94d 100644
--- a/src/qml/jsruntime/qv4sparsearray.cpp
+++ b/src/qml/jsruntime/qv4sparsearray.cpp
@@ -395,7 +395,7 @@ void SparseArray::freeTree(SparseArrayNode *root, int alignment)
SparseArray::SparseArray()
: numEntries(0)
{
- freeList = Primitive::emptyValue(UINT_MAX).asReturnedValue();
+ freeList = Encode(-1);
header.p = 0;
header.left = nullptr;
header.right = nullptr;
diff --git a/src/qml/jsruntime/qv4sparsearray_p.h b/src/qml/jsruntime/qv4sparsearray_p.h
index 51869b259f..c1e50c8dcf 100644
--- a/src/qml/jsruntime/qv4sparsearray_p.h
+++ b/src/qml/jsruntime/qv4sparsearray_p.h
@@ -52,6 +52,7 @@
//
#include "qv4global_p.h"
+#include "qv4value_p.h"
#include <QtCore/qlist.h>
//#define Q_MAP_DEBUG
@@ -151,7 +152,7 @@ struct Q_QML_EXPORT SparseArray
SparseArray(const SparseArray &other);
- ReturnedValue freeList;
+ Value freeList;
private:
SparseArray &operator=(const SparseArray &other);
diff --git a/src/qml/jsruntime/qv4stackframe.cpp b/src/qml/jsruntime/qv4stackframe.cpp
new file mode 100644
index 0000000000..a716c53aea
--- /dev/null
+++ b/src/qml/jsruntime/qv4stackframe.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qv4stackframe_p.h"
+#include <QtCore/qstring.h>
+
+using namespace QV4;
+
+QString CppStackFrame::source() const
+{
+ return v4Function ? v4Function->sourceFile() : QString();
+}
+
+QString CppStackFrame::function() const
+{
+ return v4Function ? v4Function->name()->toQString() : QString();
+}
+
+int CppStackFrame::lineNumber() const
+{
+ if (!v4Function)
+ return -1;
+
+ auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) {
+ return entry.codeOffset < offset;
+ };
+
+ const QV4::CompiledData::Function *cf = v4Function->compiledFunction;
+ uint offset = instructionPointer;
+ const CompiledData::CodeOffsetToLine *lineNumbers = cf->lineNumberTable();
+ uint nLineNumbers = cf->nLineNumbers;
+ const CompiledData::CodeOffsetToLine *line = std::lower_bound(lineNumbers, lineNumbers + nLineNumbers, offset, findLine) - 1;
+ return line->line;
+}
+
+ReturnedValue CppStackFrame::thisObject() const {
+ return jsFrame->thisObject.asReturnedValue();
+}
+
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h
new file mode 100644
index 0000000000..dd68c29a88
--- /dev/null
+++ b/src/qml/jsruntime/qv4stackframe_p.h
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4STACKFRAME_H
+#define QV4STACKFRAME_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qv4context_p.h>
+#include <private/qv4enginebase_p.h>
+#ifndef V4_BOOTSTRAP
+#include <private/qv4function_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+struct CallData
+{
+ enum Offsets {
+ Function = 0,
+ Context = 1,
+ Accumulator = 2,
+ This = 3,
+ NewTarget = 4,
+ Argc = 5,
+
+ LastOffset = Argc,
+ OffsetCount = LastOffset + 1
+ };
+
+ Value function;
+ Value context;
+ Value accumulator;
+ Value thisObject;
+ Value newTarget;
+ Value _argc;
+
+ int argc() const {
+ Q_ASSERT(_argc.isInteger());
+ return _argc.int_32();
+ }
+
+ void setArgc(int argc) {
+ Q_ASSERT(argc >= 0);
+ _argc.setInt_32(argc);
+ }
+
+ inline ReturnedValue argument(int i) const {
+ return i < argc() ? args[i].asReturnedValue() : Value::undefinedValue().asReturnedValue();
+ }
+
+ Value args[1];
+
+ static Q_DECL_CONSTEXPR int HeaderSize() { return offsetof(CallData, args) / sizeof(QV4::Value); }
+};
+
+Q_STATIC_ASSERT(std::is_standard_layout<CallData>::value);
+Q_STATIC_ASSERT(offsetof(CallData, function ) == CallData::Function * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, context ) == CallData::Context * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, accumulator) == CallData::Accumulator * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, thisObject ) == CallData::This * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, newTarget ) == CallData::NewTarget * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, _argc ) == CallData::Argc * sizeof(Value));
+Q_STATIC_ASSERT(offsetof(CallData, args ) == 6 * sizeof(Value));
+
+struct Q_QML_EXPORT CppStackFrame {
+ EngineBase *engine;
+ Value *savedStackTop;
+ CppStackFrame *parent;
+ Function *v4Function;
+ CallData *jsFrame;
+ const Value *originalArguments;
+ int originalArgumentsCount;
+ int instructionPointer;
+ const char *yield;
+ const char *unwindHandler;
+ const char *unwindLabel;
+ int unwindLevel;
+ bool yieldIsIterator;
+
+ void init(EngineBase *engine, Function *v4Function, const Value *argv, int argc) {
+ this->engine = engine;
+
+ this->v4Function = v4Function;
+ originalArguments = argv;
+ originalArgumentsCount = argc;
+ instructionPointer = 0;
+ yield = nullptr;
+ unwindHandler = nullptr;
+ unwindLabel = nullptr;
+ unwindLevel = 0;
+ yieldIsIterator = false;
+ }
+
+ void push() {
+ parent = engine->currentStackFrame;
+ engine->currentStackFrame = this;
+ savedStackTop = engine->jsStackTop;
+ }
+
+ void pop() {
+ engine->currentStackFrame = parent;
+ engine->jsStackTop = savedStackTop;
+ }
+
+#ifndef V4_BOOTSTRAP
+ static uint requiredJSStackFrameSize(uint nRegisters) {
+ return CallData::HeaderSize() + nRegisters;
+ }
+ static uint requiredJSStackFrameSize(Function *v4Function) {
+ return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters;
+ }
+ uint requiredJSStackFrameSize() const {
+ return requiredJSStackFrameSize(v4Function);
+ }
+ void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
+ const Value &thisObject, const Value &newTarget = Value::undefinedValue()) {
+ setupJSFrame(stackSpace, function, scope, thisObject, newTarget,
+ v4Function->nFormals, v4Function->compiledFunction->nRegisters);
+ }
+ void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
+ const Value &thisObject, const Value &newTarget, uint nFormals, uint nRegisters)
+ {
+ jsFrame = reinterpret_cast<CallData *>(stackSpace);
+ jsFrame->function = function;
+ jsFrame->context = scope->asReturnedValue();
+ jsFrame->accumulator = Encode::undefined();
+ jsFrame->thisObject = thisObject;
+ jsFrame->newTarget = newTarget;
+
+ uint argc = uint(originalArgumentsCount);
+ if (argc > nFormals)
+ argc = nFormals;
+ jsFrame->setArgc(argc);
+
+ memcpy(jsFrame->args, originalArguments, argc*sizeof(Value));
+ Q_STATIC_ASSERT(Encode::undefined() == 0);
+ memset(jsFrame->args + argc, 0, (nRegisters - argc)*sizeof(Value));
+
+ if (v4Function && v4Function->compiledFunction) {
+ const int firstDeadZoneRegister = v4Function->compiledFunction->firstTemporalDeadZoneRegister;
+ const int registerDeadZoneSize = v4Function->compiledFunction->sizeOfRegisterTemporalDeadZone;
+
+ const Value * tdzEnd = stackSpace + firstDeadZoneRegister + registerDeadZoneSize;
+ for (Value *v = stackSpace + firstDeadZoneRegister; v < tdzEnd; ++v)
+ *v = Value::emptyValue().asReturnedValue();
+ }
+ }
+#endif
+
+ QString source() const;
+ QString function() const;
+ inline QV4::ExecutionContext *context() const {
+ return static_cast<ExecutionContext *>(&jsFrame->context);
+ }
+ int lineNumber() const;
+
+ inline QV4::Heap::CallContext *callContext() const {
+ Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\
+ while (ctx->type != Heap::ExecutionContext::Type_CallContext)
+ ctx = ctx->outer;
+ return static_cast<Heap::CallContext *>(ctx);
+ }
+ ReturnedValue thisObject() const;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 447992ebec..68d65f2e24 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -52,8 +52,17 @@ using namespace QV4;
#ifndef V4_BOOTSTRAP
+void Heap::StringOrSymbol::markObjects(Heap::Base *that, MarkStack *markStack)
+{
+ StringOrSymbol *s = static_cast<StringOrSymbol *>(that);
+ Heap::StringOrSymbol *id = s->identifier.asStringOrSymbol();
+ if (id)
+ id->mark(markStack);
+}
+
void Heap::String::markObjects(Heap::Base *that, MarkStack *markStack)
{
+ StringOrSymbol::markObjects(that, markStack);
String *s = static_cast<String *>(that);
if (s->subtype < StringType_Complex)
return;
@@ -68,15 +77,16 @@ void Heap::String::markObjects(Heap::Base *that, MarkStack *markStack)
}
}
+DEFINE_MANAGED_VTABLE(StringOrSymbol);
DEFINE_MANAGED_VTABLE(String);
-bool String::isEqualTo(Managed *t, Managed *o)
+bool String::virtualIsEqualTo(Managed *t, Managed *o)
{
if (t == o)
return true;
- if (!o->d()->vtable()->isString)
+ if (!o->vtable()->isString)
return false;
return static_cast<String *>(t)->isEqualTo(static_cast<String *>(o));
@@ -128,7 +138,8 @@ void Heap::ComplexString::init(Heap::String *ref, int from, int len)
this->len = len;
}
-void Heap::String::destroy() {
+void Heap::StringOrSymbol::destroy()
+{
if (text) {
internalClass->engine->memoryManager->changeUnmanagedHeapSizeUsage(qptrdiff(-text->size) * (int)sizeof(QChar));
if (!text->ref.deref())
@@ -155,12 +166,12 @@ uint String::toUInt(bool *ok) const
return UINT_MAX;
}
-void String::makeIdentifierImpl() const
+void String::createPropertyKeyImpl() const
{
if (!d()->text)
d()->simplifyString();
Q_ASSERT(d()->text);
- engine()->identifierTable->identifier(this);
+ engine()->identifierTable->asPropertyKey(this);
}
void Heap::String::simplifyString() const
@@ -174,7 +185,7 @@ void Heap::String::simplifyString() const
text = result.data_ptr();
text->ref.ref();
const ComplexString *cs = static_cast<const ComplexString *>(this);
- identifier = nullptr;
+ identifier = PropertyKey::invalid();
cs->left = cs->right = nullptr;
internalClass->engine->memoryManager->changeUnmanagedHeapSizeUsage(qptrdiff(text->size) * (qptrdiff)sizeof(QChar));
@@ -227,17 +238,19 @@ void Heap::String::append(const String *data, QChar *ch)
}
}
-void Heap::String::createHashValue() const
+void Heap::StringOrSymbol::createHashValue() const
{
- if (!text)
- simplifyString();
+ if (!text) {
+ Q_ASSERT(internalClass->vtable->isString);
+ static_cast<const Heap::String *>(this)->simplifyString();
+ }
Q_ASSERT(text);
const QChar *ch = reinterpret_cast<const QChar *>(text->data());
const QChar *end = ch + text->size;
stringHash = QV4::String::calculateHashValue(ch, end, &subtype);
}
-uint String::getLength(const Managed *m)
+qint64 String::virtualGetLength(const Managed *m)
{
return static_cast<const String *>(m)->d()->length();
}
@@ -248,4 +261,3 @@ uint String::toArrayIndex(const QString &str)
{
return QV4::String::toArrayIndex(str.constData(), str.constData() + str.length());
}
-
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 5466cc274d..fbd4f5f550 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -60,13 +60,14 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
struct ExecutionEngine;
-struct Identifier;
+struct PropertyKey;
namespace Heap {
-struct Q_QML_PRIVATE_EXPORT String : Base {
- static void markObjects(Heap::Base *that, MarkStack *markStack);
+struct Q_QML_PRIVATE_EXPORT StringOrSymbol : Base
+{
enum StringType {
+ StringType_Symbol,
StringType_Regular,
StringType_ArrayIndex,
StringType_Unknown,
@@ -75,13 +76,20 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
StringType_Complex = StringType_AddedString
};
-#ifndef V4_BOOTSTRAP
- void init(const QString &text);
+ mutable QStringData *text;
+ mutable PropertyKey identifier;
+ mutable uint subtype;
+ mutable uint stringHash;
+
+ static void markObjects(Heap::Base *that, MarkStack *markStack);
void destroy();
- void simplifyString() const;
- int length() const;
- std::size_t retainedTextSize() const {
- return subtype >= StringType_Complex ? 0 : (std::size_t(text->size) * sizeof(QChar));
+
+ inline QString toQString() const {
+ if (!text)
+ return QString();
+ QStringDataPtr ptr = { text };
+ text->ref.ref();
+ return QString(ptr);
}
void createHashValue() const;
inline unsigned hashValue() const {
@@ -91,6 +99,22 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
return stringHash;
}
+};
+
+struct Q_QML_PRIVATE_EXPORT String : StringOrSymbol {
+ static void markObjects(Heap::Base *that, MarkStack *markStack);
+
+#ifndef V4_BOOTSTRAP
+ const VTable *vtable() const {
+ return internalClass->vtable;
+ }
+
+ void init(const QString &text);
+ void simplifyString() const;
+ int length() const;
+ std::size_t retainedTextSize() const {
+ return subtype >= StringType_Complex ? 0 : (std::size_t(text->size) * sizeof(QChar));
+ }
inline QString toQString() const {
if (subtype >= StringType_Complex)
simplifyString();
@@ -104,7 +128,7 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
if (hashValue() != other->hashValue())
return false;
Q_ASSERT(subtype < StringType_Complex);
- if (identifier && identifier == other->identifier)
+ if (identifier.isValid() && identifier == other->identifier)
return true;
if (subtype == Heap::String::StringType_ArrayIndex && other->subtype == Heap::String::StringType_ArrayIndex)
return true;
@@ -114,10 +138,6 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
bool startsWithUpper() const;
- mutable QStringData *text;
- mutable Identifier *identifier;
- mutable uint subtype;
- mutable uint stringHash;
private:
static void append(const String *data, QChar *ch);
#endif
@@ -146,12 +166,32 @@ int String::length() const {
}
-struct Q_QML_PRIVATE_EXPORT String : public Managed {
+struct Q_QML_PRIVATE_EXPORT StringOrSymbol : public Managed {
#ifndef V4_BOOTSTRAP
- V4_MANAGED(String, Managed)
+ V4_MANAGED(StringOrSymbol, Managed)
+ V4_NEEDS_DESTROY
+ enum {
+ IsStringOrSymbol = true
+ };
+
+private:
+ inline void createPropertyKey() const;
+public:
+ PropertyKey propertyKey() const { Q_ASSERT(d()->identifier.isValid()); return d()->identifier; }
+ PropertyKey toPropertyKey() const;
+
+
+ inline QString toQString() const {
+ return d()->toQString();
+ }
+#endif
+};
+
+struct Q_QML_PRIVATE_EXPORT String : public StringOrSymbol {
+#ifndef V4_BOOTSTRAP
+ V4_MANAGED(String, StringOrSymbol)
Q_MANAGED_TYPE(String)
V4_INTERNALCLASS(String)
- V4_NEEDS_DESTROY
enum {
IsString = true
};
@@ -166,7 +206,7 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
return d()->isEqualTo(other->d());
}
- inline bool compare(const String *other) {
+ inline bool lessThan(const String *other) {
return toQString() < other->toQString();
}
@@ -177,24 +217,10 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
inline unsigned hashValue() const {
return d()->hashValue();
}
- uint asArrayIndex() const {
- if (subtype() >= Heap::String::StringType_Unknown)
- d()->createHashValue();
- Q_ASSERT(d()->subtype < Heap::String::StringType_Complex);
- if (subtype() == Heap::String::StringType_ArrayIndex)
- return d()->stringHash;
- return UINT_MAX;
- }
uint toUInt(bool *ok) const;
- void makeIdentifier() const {
- if (d()->identifier)
- return;
- makeIdentifierImpl();
- }
-
// slow path
- Q_NEVER_INLINE void makeIdentifierImpl() const;
+ Q_NEVER_INLINE void createPropertyKeyImpl() const;
static uint createHashValue(const QChar *ch, int length, uint *subtype)
{
@@ -210,11 +236,9 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
bool startsWithUpper() const { return d()->startsWithUpper(); }
- Identifier *identifier() const { return d()->identifier; }
-
protected:
- static bool isEqualTo(Managed *that, Managed *o);
- static uint getLength(const Managed *m);
+ static bool virtualIsEqualTo(Managed *that, Managed *o);
+ static qint64 virtualGetLength(const Managed *m);
#endif
public:
@@ -254,7 +278,7 @@ public:
uint h = toArrayIndex(ch, end);
if (h != UINT_MAX) {
if (subtype)
- *subtype = Heap::String::StringType_ArrayIndex;
+ *subtype = Heap::StringOrSymbol::StringType_ArrayIndex;
return h;
}
@@ -264,7 +288,7 @@ public:
}
if (subtype)
- *subtype = Heap::String::StringType_Regular;
+ *subtype = (toUInt(ch) == '@') ? Heap::StringOrSymbol::StringType_Symbol : Heap::StringOrSymbol::StringType_Regular;
return h;
}
};
@@ -280,9 +304,27 @@ struct ComplexString : String {
}
};
+inline
+void StringOrSymbol::createPropertyKey() const {
+ Q_ASSERT(!d()->identifier.isValid());
+ Q_ASSERT(isString());
+ static_cast<const String *>(this)->createPropertyKeyImpl();
+}
+
+inline PropertyKey StringOrSymbol::toPropertyKey() const {
+ if (!d()->identifier.isValid())
+ createPropertyKey();
+ return d()->identifier;
+}
+
+template<>
+inline const StringOrSymbol *Value::as() const {
+ return isManaged() && m()->internalClass->vtable->isStringOrSymbol ? static_cast<const String *>(this) : nullptr;
+}
+
template<>
inline const String *Value::as() const {
- return isManaged() && m()->vtable()->isString ? static_cast<const String *>(this) : nullptr;
+ return isManaged() && m()->internalClass->vtable->isString ? static_cast<const String *>(this) : nullptr;
}
template<>
diff --git a/src/qml/jsruntime/qv4stringiterator.cpp b/src/qml/jsruntime/qv4stringiterator.cpp
new file mode 100644
index 0000000000..62db83ff26
--- /dev/null
+++ b/src/qml/jsruntime/qv4stringiterator.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Crimson AS <info@crimson.no>
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qv4iterator_p.h>
+#include <private/qv4stringiterator_p.h>
+#include <private/qv4symbol_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(StringIteratorObject);
+
+void StringIteratorPrototype::init(ExecutionEngine *e)
+{
+ defineDefaultProperty(QStringLiteral("next"), method_next, 0);
+
+ Scope scope(e);
+ ScopedString val(scope, e->newString(QLatin1String("String Iterator")));
+ defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);
+}
+
+ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, const Value *that, const Value *, int)
+{
+ Scope scope(b);
+ const StringIteratorObject *thisObject = that->as<StringIteratorObject>();
+ if (!thisObject)
+ return scope.engine->throwTypeError(QLatin1String("Not an String Iterator instance"));
+
+ ScopedString s(scope, thisObject->d()->iteratedString);
+ if (!s) {
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ quint32 index = thisObject->d()->nextIndex;
+
+ QString str = s->toQString();
+ quint32 len = str.length();
+
+ if (index >= len) {
+ thisObject->d()->iteratedString.set(scope.engine, nullptr);
+ QV4::Value undefined = Value::undefinedValue();
+ return IteratorPrototype::createIterResultObject(scope.engine, undefined, true);
+ }
+
+ QChar ch = str.at(index);
+ int num = 1;
+ if (ch.unicode() >= 0xd800 && ch.unicode() <= 0xdbff && index + 1 != len) {
+ ch = str.at(index + 1);
+ if (ch.unicode() >= 0xdc00 && ch.unicode() <= 0xdfff)
+ num = 2;
+ }
+
+ thisObject->d()->nextIndex += num;
+
+ ScopedString resultString(scope, scope.engine->newString(s->toQString().mid(index, num)));
+ return IteratorPrototype::createIterResultObject(scope.engine, resultString, false);
+}
+
diff --git a/src/qml/jsruntime/qv4stringiterator_p.h b/src/qml/jsruntime/qv4stringiterator_p.h
new file mode 100644
index 0000000000..672ccc9963
--- /dev/null
+++ b/src/qml/jsruntime/qv4stringiterator_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QV4STRINGITERATOR_P_H
+#define QV4STRINGITERATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4object_p.h"
+#include "qv4string_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+namespace QV4 {
+
+namespace Heap {
+
+#define StringIteratorObjectMembers(class, Member) \
+ Member(class, Pointer, String *, iteratedString) \
+ Member(class, NoMark, quint32, nextIndex)
+
+DECLARE_HEAP_OBJECT(StringIteratorObject, Object) {
+ DECLARE_MARKOBJECTS(StringIteratorObject);
+ void init(String *str, QV4::ExecutionEngine *engine)
+ {
+ Object::init();
+ this->iteratedString.set(engine, str);
+ this->nextIndex = 0;
+ }
+};
+
+}
+
+struct StringIteratorPrototype : Object
+{
+ V4_PROTOTYPE(iteratorPrototype)
+ void init(ExecutionEngine *engine);
+
+ static ReturnedValue method_next(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct StringIteratorObject : Object
+{
+ V4_OBJECT2(StringIteratorObject, Object)
+ Q_MANAGED_TYPE(StringIteratorObject)
+ V4_PROTOTYPE(stringIteratorPrototype)
+
+ void init(ExecutionEngine *engine);
+};
+
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4ARRAYITERATOR_P_H
+
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 61176b3706..f6b9c5ba94 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -44,8 +44,10 @@
#include "qv4objectproto_p.h"
#include <private/qv4mm_p.h>
#include "qv4scopedvalue_p.h"
+#include "qv4symbol_p.h"
#include "qv4alloca_p.h"
#include "qv4jscall_p.h"
+#include "qv4stringiterator_p.h"
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QStringList>
@@ -72,14 +74,14 @@ void Heap::StringObject::init()
Object::init();
Q_ASSERT(vtable() == QV4::StringObject::staticVTable());
string.set(internalClass->engine, internalClass->engine->id_empty()->d());
- setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(0));
+ setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(0));
}
void Heap::StringObject::init(const QV4::String *str)
{
Object::init();
string.set(internalClass->engine, str->d());
- setProperty(internalClass->engine, LengthPropertyIndex, Primitive::fromInt32(length()));
+ setProperty(internalClass->engine, LengthPropertyIndex, Value::fromInt32(length()));
}
Heap::String *Heap::StringObject::getIndex(uint index) const
@@ -95,45 +97,70 @@ uint Heap::StringObject::length() const
return string->length();
}
-bool StringObject::deleteIndexedProperty(Managed *m, uint index)
+bool StringObject::virtualDeleteProperty(Managed *m, PropertyKey id)
{
- ExecutionEngine *v4 = static_cast<StringObject *>(m)->engine();
- Scope scope(v4);
- Scoped<StringObject> o(scope, m->as<StringObject>());
- Q_ASSERT(!!o);
-
- if (index < static_cast<uint>(o->d()->string->toQString().length()))
- return false;
- return true;
+ Q_ASSERT(m->as<StringObject>());
+ if (id.isArrayIndex()) {
+ StringObject *o = static_cast<StringObject *>(m);
+ uint index = id.asArrayIndex();
+ if (index < static_cast<uint>(o->d()->string->toQString().length()))
+ return false;
+ }
+ return Object::virtualDeleteProperty(m, id);
}
-void StringObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs)
+struct StringObjectOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
+{
+ ~StringObjectOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey StringObjectOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
{
- name->setM(nullptr);
- StringObject *s = static_cast<StringObject *>(m);
+ const StringObject *s = static_cast<const StringObject *>(o);
uint slen = s->d()->string->toQString().length();
- if (it->arrayIndex <= slen) {
- while (it->arrayIndex < slen) {
- *index = it->arrayIndex;
- ++it->arrayIndex;
- PropertyAttributes a;
- Property pd;
- s->getOwnProperty(*index, &a, &pd);
- if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) {
- *attrs = a;
- p->copy(&pd, a);
- return;
- }
- }
+ if (arrayIndex < slen) {
+ uint index = arrayIndex;
+ ++arrayIndex;
+ if (attrs)
+ *attrs = Attr_NotConfigurable|Attr_NotWritable;
+ if (pd)
+ pd->value = s->getIndex(index);
+ return PropertyKey::fromArrayIndex(index);
+ } else if (arrayIndex == slen) {
if (s->arrayData()) {
- it->arrayNode = s->sparseBegin();
+ arrayNode = s->sparseBegin();
// iterate until we're past the end of the string
- while (it->arrayNode && it->arrayNode->key() < slen)
- it->arrayNode = it->arrayNode->nextNode();
+ while (arrayNode && arrayNode->key() < slen)
+ arrayNode = arrayNode->nextNode();
}
}
- return Object::advanceIterator(m, it, name, index, p, attrs);
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *StringObject::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new StringObjectOwnPropertyKeyIterator;
+}
+
+PropertyAttributes StringObject::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
+{
+ PropertyAttributes attributes = Object::virtualGetOwnProperty(m, id, p);
+ if (attributes != Attr_Invalid)
+ return attributes;
+
+ const StringObject *s = static_cast<const StringObject *>(m);
+ uint slen = s->d()->string->toQString().length();
+ uint index = id.asArrayIndex();
+ if (index < slen) {
+ if (p)
+ p->value = s->getIndex(index);
+ return Attr_NotConfigurable|Attr_NotWritable;
+ }
+ return Object::virtualGetOwnProperty(m, id, p);
}
DEFINE_OBJECT_VTABLE(StringCtor);
@@ -143,7 +170,7 @@ void Heap::StringCtor::init(QV4::ExecutionContext *scope)
Heap::FunctionObject::init(scope, QStringLiteral("String"));
}
-ReturnedValue StringCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue StringCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *)
{
ExecutionEngine *v4 = static_cast<const Object *>(f)->engine();
Scope scope(v4);
@@ -152,16 +179,99 @@ ReturnedValue StringCtor::callAsConstructor(const FunctionObject *f, const Value
value = argv[0].toString(v4);
else
value = v4->newString();
+ CHECK_EXCEPTION();
return Encode(v4->newStringObject(value));
}
-ReturnedValue StringCtor::call(const FunctionObject *m, const Value *, const Value *argv, int argc)
+ReturnedValue StringCtor::virtualCall(const FunctionObject *m, const Value *, const Value *argv, int argc)
{
ExecutionEngine *v4 = m->engine();
- if (argc)
- return argv[0].toString(v4)->asReturnedValue();
- else
+ if (!argc)
return v4->newString()->asReturnedValue();
+ if (argv[0].isSymbol())
+ return v4->newString(argv[0].symbolValue()->descriptiveString())->asReturnedValue();
+ return argv[0].toString(v4)->asReturnedValue();
+}
+
+ReturnedValue StringCtor::method_fromCharCode(const FunctionObject *b, const Value *, const Value *argv, int argc)
+{
+ QString str(argc, Qt::Uninitialized);
+ QChar *ch = str.data();
+ for (int i = 0, ei = argc; i < ei; ++i) {
+ *ch = QChar(argv[i].toUInt16());
+ ++ch;
+ }
+ *ch = 0;
+ return Encode(b->engine()->newString(str));
+}
+
+
+
+ReturnedValue StringCtor::method_fromCodePoint(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ ExecutionEngine *e = f->engine();
+ QString result(argc*2, Qt::Uninitialized); // assume worst case
+ QChar *ch = result.data();
+ for (int i = 0; i < argc; ++i) {
+ double num = argv[i].toNumber();
+ if (e->hasException)
+ return Encode::undefined();
+ int cp = static_cast<int>(num);
+ if (cp != num || cp < 0 || cp > 0x10ffff)
+ return e->throwRangeError(QStringLiteral("String.fromCodePoint: argument out of range."));
+ if (cp > 0xffff) {
+ *ch = QChar::highSurrogate(cp);
+ ++ch;
+ *ch = QChar::lowSurrogate(cp);
+ } else {
+ *ch = cp;
+ }
+ ++ch;
+ }
+ *ch = 0;
+ result.truncate(ch - result.constData());
+ return e->newString(result)->asReturnedValue();
+}
+
+ReturnedValue StringCtor::method_raw(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject cooked(scope, argv[0].toObject(scope.engine));
+ if (!cooked)
+ return scope.engine->throwTypeError();
+ ScopedString rawString(scope, scope.engine->newIdentifier(QStringLiteral("raw")));
+ ScopedValue rawValue(scope, cooked->get(rawString));
+ ScopedObject raw(scope, rawValue->toObject(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
+ ++argv;
+ --argc;
+
+ QString result;
+ uint literalSegments = raw->getLength();
+ if (!literalSegments)
+ return scope.engine->id_empty()->asReturnedValue();
+
+ uint nextIndex = 0;
+ ScopedValue val(scope);
+ while (1) {
+ val = raw->get(nextIndex);
+ result += val->toQString();
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ if (nextIndex + 1 == literalSegments)
+ return scope.engine->newString(result)->asReturnedValue();
+
+ if (nextIndex < static_cast<uint>(argc))
+ result += argv[nextIndex].toQString();
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ ++nextIndex;
+ }
}
void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
@@ -169,15 +279,24 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
+ // need to set this once again, as these were not fully defined when creating the string proto
+ Heap::InternalClass *ic = scope.engine->classes[ExecutionEngine::Class_StringObject]->changePrototype(scope.engine->objectPrototype()->d());
+ d()->internalClass.set(scope.engine, ic);
+ d()->string.set(scope.engine, scope.engine->id_empty()->d());
+ setProperty(scope.engine, Heap::StringObject::LengthPropertyIndex, Value::fromInt32(0));
+
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
- ctor->defineDefaultProperty(QStringLiteral("fromCharCode"), method_fromCharCode, 1);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(1));
+ ctor->defineDefaultProperty(QStringLiteral("fromCharCode"), StringCtor::method_fromCharCode, 1);
+ ctor->defineDefaultProperty(QStringLiteral("fromCodePoint"), StringCtor::method_fromCodePoint, 1);
+ ctor->defineDefaultProperty(QStringLiteral("raw"), StringCtor::method_raw, 1);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString(), method_toString);
defineDefaultProperty(engine->id_valueOf(), method_toString); // valueOf and toString are identical
defineDefaultProperty(QStringLiteral("charAt"), method_charAt, 1);
defineDefaultProperty(QStringLiteral("charCodeAt"), method_charCodeAt, 1);
+ defineDefaultProperty(QStringLiteral("codePointAt"), method_codePointAt, 1);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
defineDefaultProperty(QStringLiteral("endsWith"), method_endsWith, 1);
defineDefaultProperty(QStringLiteral("indexOf"), method_indexOf, 1);
@@ -185,6 +304,9 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(QStringLiteral("lastIndexOf"), method_lastIndexOf, 1);
defineDefaultProperty(QStringLiteral("localeCompare"), method_localeCompare, 1);
defineDefaultProperty(QStringLiteral("match"), method_match, 1);
+ defineDefaultProperty(QStringLiteral("normalize"), method_normalize, 0);
+ defineDefaultProperty(QStringLiteral("padEnd"), method_padEnd, 1);
+ defineDefaultProperty(QStringLiteral("padStart"), method_padStart, 1);
defineDefaultProperty(QStringLiteral("repeat"), method_repeat, 1);
defineDefaultProperty(QStringLiteral("replace"), method_replace, 2);
defineDefaultProperty(QStringLiteral("search"), method_search, 1);
@@ -198,6 +320,7 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(QStringLiteral("toUpperCase"), method_toUpperCase);
defineDefaultProperty(QStringLiteral("toLocaleUpperCase"), method_toLocaleUpperCase);
defineDefaultProperty(QStringLiteral("trim"), method_trim);
+ defineDefaultProperty(engine->symbol_iterator(), method_iterator);
}
static Heap::String *thisAsString(ExecutionEngine *v4, const QV4::Value *thisObject)
@@ -270,6 +393,29 @@ ReturnedValue StringPrototype::method_charCodeAt(const FunctionObject *b, const
return Encode(qt_qnan());
}
+ReturnedValue StringPrototype::method_codePointAt(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *v4 = f->engine();
+ QString value = getThisString(v4, thisObject);
+ if (v4->hasException)
+ return QV4::Encode::undefined();
+
+ int index = argc ? argv[0].toInteger() : 0;
+ if (v4->hasException)
+ return QV4::Encode::undefined();
+
+ if (index < 0 || index >= value.size())
+ return Encode::undefined();
+
+ uint first = value.at(index).unicode();
+ if (QChar::isHighSurrogate(first) && index + 1 < value.size()) {
+ uint second = value.at(index + 1).unicode();
+ if (QChar::isLowSurrogate(second))
+ return Encode(QChar::surrogateToUcs4(first, second));
+ }
+ return Encode(first);
+}
+
ReturnedValue StringPrototype::method_concat(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
ExecutionEngine *v4 = b->engine();
@@ -298,12 +444,11 @@ ReturnedValue StringPrototype::method_endsWith(const FunctionObject *b, const Va
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString;
- if (argc) {
- if (argv[0].as<RegExpObject>())
- return v4->throwTypeError();
- searchString = argv[0].toQString();
- }
+ if (argc && argv[0].as<RegExpObject>())
+ return v4->throwTypeError();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
+ if (v4->hasException)
+ return Encode::undefined();
int pos = value.length();
if (argc > 1)
@@ -323,9 +468,9 @@ ReturnedValue StringPrototype::method_indexOf(const FunctionObject *b, const Val
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString;
- if (argc)
- searchString = argv[0].toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
+ if (v4->hasException)
+ return Encode::undefined();
int pos = 0;
if (argc > 1)
@@ -345,12 +490,11 @@ ReturnedValue StringPrototype::method_includes(const FunctionObject *b, const Va
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString;
- if (argc) {
- if (argv[0].as<RegExpObject>())
- return v4->throwTypeError();
- searchString = argv[0].toQString();
- }
+ if (argc && argv[0].as<RegExpObject>())
+ return v4->throwTypeError();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
+ if (v4->hasException)
+ return Encode::undefined();
int pos = 0;
if (argc > 1) {
@@ -374,9 +518,9 @@ ReturnedValue StringPrototype::method_lastIndexOf(const FunctionObject *b, const
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString;
- if (argc)
- searchString = argv[0].toQString();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
+ if (v4->hasException)
+ return Encode::undefined();
double position = argc > 1 ? RuntimeHelpers::toNumber(argv[1]) : +qInf();
if (std::isnan(position))
@@ -400,7 +544,7 @@ ReturnedValue StringPrototype::method_localeCompare(const FunctionObject *b, con
if (v4->hasException)
return QV4::Encode::undefined();
- const QString that = (argc ? argv[0] : Primitive::undefinedValue()).toQString();
+ const QString that = (argc ? argv[0] : Value::undefinedValue()).toQString();
return Encode(QString::localeAwareCompare(value, that));
}
@@ -411,50 +555,147 @@ ReturnedValue StringPrototype::method_match(const FunctionObject *b, const Value
return v4->throwTypeError();
Scope scope(v4);
+ if (argc && !argv[0].isNullOrUndefined()) {
+ ScopedObject r(scope, argv[0].toObject(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ ScopedValue f(scope, r->get(scope.engine->symbol_match()));
+ if (!f->isNullOrUndefined()) {
+ ScopedFunctionObject fo(scope, f);
+ if (!fo)
+ return scope.engine->throwTypeError();
+ return fo->call(r, thisObject, 1);
+ }
+ }
+
ScopedString s(scope, thisObject->toString(v4));
if (v4->hasException)
return Encode::undefined();
- Scoped<RegExpObject> that(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<RegExpObject> that(scope, argc ? argv[0] : Value::undefinedValue());
if (!that) {
// convert args[0] to a regexp
- that = RegExpCtor::callAsConstructor(b, argv, argc);
+ that = RegExpCtor::virtualCallAsConstructor(b, argv, argc, b);
if (v4->hasException)
return Encode::undefined();
}
Q_ASSERT(!!that);
- bool global = that->global();
+ ScopedFunctionObject match(scope, that->get(scope.engine->symbol_match()));
+ if (!match)
+ return scope.engine->throwTypeError();
+ return match->call(that, s, 1);
+}
+
+ReturnedValue StringPrototype::method_normalize(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *v4 = f->engine();
+ const QString value = getThisString(v4, thisObject);
+ if (v4->hasException)
+ return Encode::undefined();
+
+ QString::NormalizationForm form = QString::NormalizationForm_C;
+ if (argc >= 1 && !argv[0].isUndefined()) {
+ QString f = argv[0].toQString();
+ if (v4->hasException)
+ return Encode::undefined();
+ if (f == QLatin1String("NFC"))
+ form = QString::NormalizationForm_C;
+ else if (f == QLatin1String("NFD"))
+ form = QString::NormalizationForm_D;
+ else if (f == QLatin1String("NFKC"))
+ form = QString::NormalizationForm_KC;
+ else if (f == QLatin1String("NFKD"))
+ form = QString::NormalizationForm_KD;
+ else
+ return v4->throwRangeError(QLatin1String("String.prototype.normalize: Invalid normalization form."));
+ }
+ QString normalized = value.normalized(form);
+ return v4->newString(normalized)->asReturnedValue();
+}
+
+ReturnedValue StringPrototype::method_padEnd(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *v4 = f->engine();
+ if (thisObject->isNullOrUndefined())
+ return v4->throwTypeError();
- if (!global)
- return RegExpPrototype::method_exec(b, that, s, 1);
+ Scope scope(v4);
+ ScopedString s(scope, thisAsString(v4, thisObject));
+ if (v4->hasException)
+ return Encode::undefined();
+ if (!argc)
+ return s->asReturnedValue();
- // rx is now in thisObject
- that->setLastIndex(0);
- ScopedArrayObject a(scope, scope.engine->newArrayObject());
+ int maxLen = argv[0].toInteger();
+ if (maxLen <= s->d()->length())
+ return s->asReturnedValue();
+ QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : QString::fromLatin1(" ");
+ if (v4->hasException)
+ return Encode::undefined();
- int previousLastIndex = 0;
- uint n = 0;
- while (1) {
- Value result = Primitive::fromReturnedValue(RegExpPrototype::execFirstMatch(b, that, s, 1));
- if (result.isNull())
- break;
- int index = that->lastIndex();
- if (previousLastIndex == index) {
- previousLastIndex = index + 1;
- that->setLastIndex(previousLastIndex);
- } else {
- previousLastIndex = index;
- }
- a->arraySet(n, result);
- ++n;
+ if (fillString.isEmpty())
+ return s->asReturnedValue();
+
+ QString padded = s->toQString();
+ int oldLength = padded.length();
+ int toFill = maxLen - oldLength;
+ padded.resize(maxLen);
+ QChar *ch = padded.data() + oldLength;
+ while (toFill) {
+ int copy = qMin(fillString.length(), toFill);
+ memcpy(ch, fillString.constData(), copy*sizeof(QChar));
+ toFill -= copy;
+ ch += copy;
}
- if (!n)
- return Encode::null();
- else
- return a.asReturnedValue();
+ *ch = 0;
+
+ return v4->newString(padded)->asReturnedValue();
+}
+
+ReturnedValue StringPrototype::method_padStart(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ ExecutionEngine *v4 = f->engine();
+ if (thisObject->isNullOrUndefined())
+ return v4->throwTypeError();
+
+ Scope scope(v4);
+ ScopedString s(scope, thisAsString(v4, thisObject));
+ if (v4->hasException)
+ return Encode::undefined();
+ if (!argc)
+ return s->asReturnedValue();
+
+ int maxLen = argv[0].toInteger();
+ if (maxLen <= s->d()->length())
+ return s->asReturnedValue();
+ QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : QString::fromLatin1(" ");
+ if (v4->hasException)
+ return Encode::undefined();
+
+ if (fillString.isEmpty())
+ return s->asReturnedValue();
+
+ QString original = s->toQString();
+ int oldLength = original.length();
+ int toFill = maxLen - oldLength;
+ QString padded;
+ padded.resize(maxLen);
+ QChar *ch = padded.data();
+ while (toFill) {
+ int copy = qMin(fillString.length(), toFill);
+ memcpy(ch, fillString.constData(), copy*sizeof(QChar));
+ toFill -= copy;
+ ch += copy;
+ }
+ memcpy(ch, original.constData(), oldLength*sizeof(QChar));
+ ch += oldLength;
+ *ch = 0;
+
+ return v4->newString(padded)->asReturnedValue();
}
+
ReturnedValue StringPrototype::method_repeat(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
ExecutionEngine *v4 = b->engine();
@@ -462,7 +703,7 @@ ReturnedValue StringPrototype::method_repeat(const FunctionObject *b, const Valu
if (v4->hasException)
return QV4::Encode::undefined();
- double repeats = (argc ? argv[0] : Primitive::undefinedValue()).toInteger();
+ double repeats = (argc ? argv[0] : Value::undefinedValue()).toInteger();
if (repeats < 0 || qIsInf(repeats))
return v4->throwRangeError(QLatin1String("Invalid count value"));
@@ -532,7 +773,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
uint *matchOffsets = _matchOffsets;
Scope scope(b);
- ScopedValue searchValue(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
Scoped<RegExpObject> regExp(scope, searchValue);
if (regExp) {
uint offset = 0;
@@ -559,8 +800,11 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
break;
offset = qMax(offset + 1, matchOffsets[oldSize + 1]);
}
- if (regExp->global())
+ if (regExp->global()) {
regExp->setLastIndex(0);
+ if (scope.hasException())
+ return Encode::undefined();
+ }
numStringMatches = nMatchOffsets / (regExp->value()->captureCount() * 2);
numCaptures = regExp->value()->captureCount();
} else {
@@ -576,7 +820,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
QString result;
ScopedValue replacement(scope);
- ScopedValue replaceValue(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue replaceValue(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedFunctionObject searchCallback(scope, replaceValue);
if (!!searchCallback) {
result.reserve(string.length() + 10*numStringMatches);
@@ -588,7 +832,7 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
int idx = (i * numCaptures + k) * 2;
uint start = matchOffsets[idx];
uint end = matchOffsets[idx + 1];
- entry = Primitive::undefinedValue();
+ entry = Value::undefinedValue();
if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch)
entry = scope.engine->newString(string.mid(start, end - start));
arguments[k] = entry;
@@ -596,10 +840,10 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
uint matchStart = matchOffsets[i * numCaptures * 2];
Q_ASSERT(matchStart >= static_cast<uint>(lastEnd));
uint matchEnd = matchOffsets[i * numCaptures * 2 + 1];
- arguments[numCaptures] = Primitive::fromUInt32(matchStart);
+ arguments[numCaptures] = Value::fromUInt32(matchStart);
arguments[numCaptures + 1] = scope.engine->newString(string);
- Value that = Primitive::undefinedValue();
+ Value that = Value::undefinedValue();
replacement = searchCallback->call(&that, arguments, numCaptures + 2);
result += string.midRef(lastEnd, matchStart - lastEnd);
result += replacement->toQString();
@@ -638,7 +882,7 @@ ReturnedValue StringPrototype::method_search(const FunctionObject *b, const Valu
if (scope.engine->hasException)
return QV4::Encode::undefined();
- Scoped<RegExpObject> regExp(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<RegExpObject> regExp(scope, argc ? argv[0] : Value::undefinedValue());
if (!regExp) {
regExp = scope.engine->regExpCtor()->callAsConstructor(argv, 1);
if (scope.engine->hasException)
@@ -695,8 +939,8 @@ ReturnedValue StringPrototype::method_split(const FunctionObject *b, const Value
return QV4::Encode::undefined();
Scope scope(v4);
- ScopedValue separatorValue(scope, argc ? argv[0] : Primitive::undefinedValue());
- ScopedValue limitValue(scope, argc > 1 ? argv[1] : Primitive::undefinedValue());
+ ScopedValue separatorValue(scope, argc ? argv[0] : Value::undefinedValue());
+ ScopedValue limitValue(scope, argc > 1 ? argv[1] : Value::undefinedValue());
ScopedArrayObject array(scope, scope.engine->newArrayObject());
@@ -777,12 +1021,11 @@ ReturnedValue StringPrototype::method_startsWith(const FunctionObject *b, const
if (v4->hasException)
return QV4::Encode::undefined();
- QString searchString;
- if (argc) {
- if (argv[0].as<RegExpObject>())
- return v4->throwTypeError();
- searchString = argv[0].toQString();
- }
+ if (argc && argv[0].as<RegExpObject>())
+ return v4->throwTypeError();
+ QString searchString = (argc ? argv[0] : Value::undefinedValue()).toQString();
+ if (v4->hasException)
+ return Encode::undefined();
int pos = 0;
if (argc > 1)
@@ -816,8 +1059,8 @@ ReturnedValue StringPrototype::method_substr(const FunctionObject *b, const Valu
length = qMin(qMax(length, 0.0), count - start);
- qint32 x = Primitive::toInt32(start);
- qint32 y = Primitive::toInt32(length);
+ qint32 x = Value::toInt32(start);
+ qint32 y = Value::toInt32(length);
return Encode(v4->newString(value.mid(x, y)));
}
@@ -892,17 +1135,6 @@ ReturnedValue StringPrototype::method_toLocaleUpperCase(const FunctionObject *b,
return method_toUpperCase(b, thisObject, argv, argc);
}
-ReturnedValue StringPrototype::method_fromCharCode(const FunctionObject *b, const Value *, const Value *argv, int argc)
-{
- QString str(argc, Qt::Uninitialized);
- QChar *ch = str.data();
- for (int i = 0, ei = argc; i < ei; ++i) {
- *ch = QChar(argv[i].toUInt16());
- ++ch;
- }
- return Encode(b->engine()->newString(str));
-}
-
ReturnedValue StringPrototype::method_trim(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
@@ -923,3 +1155,16 @@ ReturnedValue StringPrototype::method_trim(const FunctionObject *b, const Value
return Encode(v4->newString(QString(chars + start, end - start + 1)));
}
+
+
+
+ReturnedValue StringPrototype::method_iterator(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ ScopedString s(scope, thisObject->toString(scope.engine));
+ if (!s || thisObject->isNullOrUndefined())
+ return scope.engine->throwTypeError();
+
+ Scoped<StringIteratorObject> si(scope, scope.engine->memoryManager->allocate<StringIteratorObject>(s->d(), scope.engine));
+ return si->asReturnedValue();
+}
diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h
index 7d25678b61..794ee91575 100644
--- a/src/qml/jsruntime/qv4stringobject_p.h
+++ b/src/qml/jsruntime/qv4stringobject_p.h
@@ -70,6 +70,8 @@ DECLARE_HEAP_OBJECT(StringObject, Object) {
LengthPropertyIndex = 0
};
+ void init(bool /*don't init*/)
+ { Object::init(); }
void init();
void init(const QV4::String *string);
@@ -96,18 +98,23 @@ struct StringObject: Object {
return d()->length();
}
- static bool deleteIndexedProperty(Managed *m, uint index);
-
+ using Object::getOwnProperty;
protected:
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs);
+ static bool virtualDeleteProperty(Managed *m, PropertyKey id);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
};
struct StringCtor: FunctionObject
{
V4_OBJECT2(StringCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue method_fromCharCode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_fromCodePoint(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_raw(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
struct StringPrototype: StringObject
@@ -118,6 +125,7 @@ struct StringPrototype: StringObject
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_charAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_charCodeAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_codePointAt(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_concat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_endsWith(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -125,6 +133,9 @@ struct StringPrototype: StringObject
static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_localeCompare(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_match(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_normalize(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_padEnd(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_padStart(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_repeat(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_replace(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_search(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
@@ -137,8 +148,8 @@ struct StringPrototype: StringObject
static ReturnedValue method_toLocaleLowerCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_toLocaleUpperCase(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue method_fromCharCode(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_trim(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_iterator(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
}
diff --git a/src/qml/jsruntime/qv4symbol.cpp b/src/qml/jsruntime/qv4symbol.cpp
new file mode 100644
index 0000000000..004a9938e2
--- /dev/null
+++ b/src/qml/jsruntime/qv4symbol.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qv4symbol_p.h>
+#include <qv4functionobject_p.h>
+#include <qv4identifiertable_p.h>
+
+using namespace QV4;
+
+DEFINE_OBJECT_VTABLE(SymbolCtor);
+DEFINE_MANAGED_VTABLE(Symbol);
+DEFINE_OBJECT_VTABLE(SymbolObject);
+
+void Heap::Symbol::init(const QString &s)
+{
+ Q_ASSERT(s.at(0) == QLatin1Char('@'));
+ identifier = PropertyKey::fromStringOrSymbol(this);
+ QString desc(s);
+ text = desc.data_ptr();
+ text->ref.ref();
+}
+
+void Heap::SymbolCtor::init(QV4::ExecutionContext *scope)
+{
+ Heap::FunctionObject::init(scope, QStringLiteral("Symbol"));
+}
+
+void Heap::SymbolObject::init(const QV4::Symbol *s)
+{
+ Object::init();
+ symbol.set(internalClass->engine, s->d());
+}
+
+ReturnedValue QV4::SymbolCtor::virtualCall(const QV4::FunctionObject *f, const QV4::Value *, const QV4::Value *argv, int argc)
+{
+ Scope scope(f);
+ QString desc = QChar::fromLatin1('@');
+ if (argc && !argv[0].isUndefined()) {
+ ScopedString s(scope, argv[0].toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ desc += s->toQString();
+ }
+ return Symbol::create(scope.engine, desc)->asReturnedValue();
+}
+
+ReturnedValue SymbolCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *)
+{
+ return f->engine()->throwTypeError(QStringLiteral("Symbol can't be used together with |new|."));
+}
+
+ReturnedValue SymbolCtor::method_for(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ ScopedValue k(scope, argc ? argv[0]: Value::undefinedValue());
+ ScopedString key(scope, k->toString(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+ QString desc = QLatin1Char('@') + key->toQString();
+ return scope.engine->identifierTable->insertSymbol(desc)->asReturnedValue();
+}
+
+ReturnedValue SymbolCtor::method_keyFor(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ ExecutionEngine *e = f->engine();
+ if (!argc || !argv[0].isSymbol())
+ return e->throwTypeError(QLatin1String("Symbol.keyFor: Argument is not a symbol."));
+ const Symbol &arg = static_cast<const Symbol &>(argv[0]);
+ Heap::Symbol *s = e->identifierTable->symbolForId(arg.propertyKey());
+ Q_ASSERT(!s || s == arg.d());
+ if (s)
+ return e->newString(arg.toQString().mid((1)))->asReturnedValue();
+ return Encode::undefined();
+}
+
+void SymbolPrototype::init(ExecutionEngine *engine, Object *ctor)
+{
+ Scope scope(engine);
+ ScopedValue v(scope);
+ ctor->defineReadonlyProperty(engine->id_prototype(), (v = this));
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+
+ ctor->defineDefaultProperty(QStringLiteral("for"), SymbolCtor::method_for, 1);
+ ctor->defineDefaultProperty(QStringLiteral("keyFor"), SymbolCtor::method_keyFor, 1);
+ ctor->defineReadonlyProperty(QStringLiteral("hasInstance"), *engine->symbol_hasInstance());
+ ctor->defineReadonlyProperty(QStringLiteral("isConcatSpreadable"), *engine->symbol_isConcatSpreadable());
+ ctor->defineReadonlyProperty(QStringLiteral("iterator"), *engine->symbol_iterator());
+ ctor->defineReadonlyProperty(QStringLiteral("match"), *engine->symbol_match());
+ ctor->defineReadonlyProperty(QStringLiteral("replace"), *engine->symbol_replace());
+ ctor->defineReadonlyProperty(QStringLiteral("search"), *engine->symbol_search());
+ ctor->defineReadonlyProperty(QStringLiteral("species"), *engine->symbol_species());
+ ctor->defineReadonlyProperty(QStringLiteral("split"), *engine->symbol_split());
+ ctor->defineReadonlyProperty(QStringLiteral("toPrimitive"), *engine->symbol_toPrimitive());
+ ctor->defineReadonlyProperty(QStringLiteral("toStringTag"), *engine->symbol_toStringTag());
+ ctor->defineReadonlyProperty(QStringLiteral("unscopables"), *engine->symbol_unscopables());
+
+ defineDefaultProperty(QStringLiteral("constructor"), (v = ctor));
+ defineDefaultProperty(QStringLiteral("toString"), method_toString);
+ defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf);
+ defineDefaultProperty(engine->symbol_toPrimitive(), method_symbolToPrimitive, 1, Attr_ReadOnly_ButConfigurable);
+
+ v = engine->newString(QStringLiteral("Symbol"));
+ defineReadonlyConfigurableProperty(engine->symbol_toStringTag(), v);
+
+}
+
+ReturnedValue SymbolPrototype::method_toString(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<Symbol> s(scope, thisObject->as<Symbol>());
+ if (!s) {
+ if (const SymbolObject *o = thisObject->as<SymbolObject>())
+ s = o->d()->symbol;
+ else
+ return scope.engine->throwTypeError();
+ }
+ return scope.engine->newString(s->descriptiveString())->asReturnedValue();
+}
+
+ReturnedValue SymbolPrototype::method_valueOf(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ Scope scope(f);
+ Scoped<Symbol> s(scope, thisObject->as<Symbol>());
+ if (!s) {
+ if (const SymbolObject *o = thisObject->as<SymbolObject>())
+ s = o->d()->symbol;
+ else
+ return scope.engine->throwTypeError();
+ }
+ return s->asReturnedValue();
+}
+
+ReturnedValue SymbolPrototype::method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *, int)
+{
+ if (thisObject->isSymbol())
+ return thisObject->asReturnedValue();
+ if (const SymbolObject *o = thisObject->as<SymbolObject>())
+ return o->d()->symbol->asReturnedValue();
+ return f->engine()->throwTypeError();
+}
+
+Heap::Symbol *Symbol::create(ExecutionEngine *e, const QString &s)
+{
+ Q_ASSERT(s.at(0) == QLatin1Char('@'));
+ return e->memoryManager->alloc<Symbol>(s);
+}
+
+QString Symbol::descriptiveString() const
+{
+ return QLatin1String("Symbol(") + toQString().midRef(1) + QLatin1String(")");
+}
diff --git a/src/qml/jsruntime/qv4symbol_p.h b/src/qml/jsruntime/qv4symbol_p.h
new file mode 100644
index 0000000000..c7e12b512b
--- /dev/null
+++ b/src/qml/jsruntime/qv4symbol_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4_SYMBOL_H
+#define QV4_SYMBOL_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4string_p.h"
+#include "qv4functionobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+namespace QV4 {
+
+namespace Heap {
+
+struct SymbolCtor : FunctionObject {
+ void init(QV4::ExecutionContext *scope);
+};
+
+struct Symbol : StringOrSymbol {
+ void init(const QString &s);
+};
+
+#define SymbolObjectMembers(class, Member) \
+ Member(class, Pointer, Symbol *, symbol)
+
+DECLARE_HEAP_OBJECT(SymbolObject, Object) {
+ DECLARE_MARKOBJECTS(SymbolObject);
+ void init(const QV4::Symbol *s);
+};
+
+}
+
+struct SymbolCtor : FunctionObject
+{
+ V4_OBJECT2(SymbolCtor, FunctionObject)
+
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *, const Value *argv, int argc, const Value *newTarget);
+ static ReturnedValue method_for(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_keyFor(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct SymbolPrototype : Object
+{
+ V4_PROTOTYPE(objectPrototype)
+ void init(ExecutionEngine *engine, Object *ctor);
+
+ static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue method_symbolToPrimitive(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+};
+
+struct Symbol : StringOrSymbol
+{
+ V4_MANAGED(Symbol, StringOrSymbol)
+ Q_MANAGED_TYPE(Symbol)
+ V4_INTERNALCLASS(Symbol)
+ V4_NEEDS_DESTROY
+
+ static Heap::Symbol *create(ExecutionEngine *e, const QString &s);
+
+ QString descriptiveString() const;
+};
+
+struct SymbolObject : Object
+{
+ V4_OBJECT2(SymbolObject, Object)
+ Q_MANAGED_TYPE(SymbolObject)
+ V4_INTERNALCLASS(SymbolObject)
+ V4_PROTOTYPE(symbolPrototype)
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index ea1532b8ce..faf7934c06 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -36,170 +36,241 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include "qv4typedarray_p.h"
+#include "qv4arrayiterator_p.h"
#include "qv4arraybuffer_p.h"
#include "qv4string_p.h"
#include "qv4jscall_p.h"
+#include "qv4symbol_p.h"
+#include "qv4runtime_p.h"
+#include <QtCore/qatomic.h>
#include <cmath>
using namespace QV4;
+DEFINE_OBJECT_VTABLE(IntrinsicTypedArrayCtor);
+DEFINE_OBJECT_VTABLE(IntrinsicTypedArrayPrototype);
DEFINE_OBJECT_VTABLE(TypedArrayCtor);
DEFINE_OBJECT_VTABLE(TypedArrayPrototype);
DEFINE_OBJECT_VTABLE(TypedArray);
-Q_STATIC_ASSERT((int)ExecutionEngine::NTypedArrayTypes == (int)Heap::TypedArray::NTypes);
+Q_STATIC_ASSERT((int)ExecutionEngine::NTypedArrayTypes == (int)NTypedArrayTypes);
-ReturnedValue Int8ArrayRead(const char *data, int index)
+static inline int toInt32(Value v)
{
- return Encode((int)(signed char)data[index]);
+ Q_ASSERT(v.isNumber());
+ if (v.isInteger())
+ return v.integerValue();
+ return Double::toInt32(v.doubleValue());
}
-void Int8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+static inline double toDouble(Value v)
{
- signed char v = (signed char)value.toUInt32();
- if (e->hasException)
- return;
- data[index] = v;
+ Q_ASSERT(v.isNumber());
+ if (v.isInteger())
+ return v.integerValue();
+ return v.doubleValue();
}
-ReturnedValue UInt8ArrayRead(const char *data, int index)
-{
- return Encode((int)(unsigned char)data[index]);
+struct ClampedUInt8 {
+ quint8 c;
+};
+
+template <typename T>
+ReturnedValue typeToValue(T t) {
+ return Encode(t);
}
-void UInt8ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <>
+ReturnedValue typeToValue(ClampedUInt8 t) {
+ return Encode(t.c);
+}
+
+template <typename T>
+T valueToType(Value value)
{
- unsigned char v = (unsigned char)value.toUInt32();
- if (e->hasException)
- return;
- data[index] = v;
+ Q_ASSERT(value.isNumber());
+ int n = toInt32(value);
+ return static_cast<T>(n);
}
-void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <>
+ClampedUInt8 valueToType(Value value)
{
- if (value.isInteger()) {
- data[index] = (char)(unsigned char)qBound(0, value.integerValue(), 255);
- return;
- }
- double d = value.toNumber();
- if (e->hasException)
- return;
+ Q_ASSERT(value.isNumber());
+ if (value.isInteger())
+ return { static_cast<quint8>(qBound(0, value.integerValue(), 255)) };
+ Q_ASSERT(value.isDouble());
+ double d = value.doubleValue();
// ### is there a way to optimise this?
- if (d <= 0 || std::isnan(d)) {
- data[index] = 0;
- return;
- }
- if (d >= 255) {
- data[index] = (char)(255);
- return;
- }
+ if (d <= 0 || std::isnan(d))
+ return { 0 };
+ if (d >= 255)
+ return { 255 };
double f = std::floor(d);
- if (f + 0.5 < d) {
- data[index] = (unsigned char)(f + 1);
- return;
- }
- if (d < f + 0.5) {
- data[index] = (unsigned char)(f);
- return;
- }
- if (int(f) % 2) {
+ if (f + 0.5 < d)
+ return { (quint8)(f + 1) };
+ if (d < f + 0.5)
+ return { (quint8)(f) };
+ if (int(f) % 2)
// odd number
- data[index] = (unsigned char)(f + 1);
- return;
- }
- data[index] = (unsigned char)(f);
+ return { (quint8)(f + 1) };
+ return { (quint8)(f) };
}
-ReturnedValue Int16ArrayRead(const char *data, int index)
+template <>
+float valueToType(Value value)
{
- return Encode((int)*(const short *)(data + index));
+ Q_ASSERT(value.isNumber());
+ double d = toDouble(value);
+ return static_cast<float>(d);
}
-void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <>
+double valueToType(Value value)
{
- short v = (short)value.toInt32();
- if (e->hasException)
- return;
- *(short *)(data + index) = v;
+ Q_ASSERT(value.isNumber());
+ return toDouble(value);
}
-ReturnedValue UInt16ArrayRead(const char *data, int index)
+template <typename T>
+ReturnedValue read(const char *data) {
+ return typeToValue(*reinterpret_cast<const T *>(data));
+}
+template <typename T>
+void write(char *data, Value value)
{
- return Encode((int)*(const unsigned short *)(data + index));
+ *reinterpret_cast<T *>(data) = valueToType<T>(value);
}
-void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <typename T>
+ReturnedValue atomicAdd(char *data, Value v)
{
- unsigned short v = (unsigned short)value.toInt32();
- if (e->hasException)
- return;
- *(unsigned short *)(data + index) = v;
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndAddOrdered(*mem, value);
+ return typeToValue(value);
}
-ReturnedValue Int32ArrayRead(const char *data, int index)
+template <typename T>
+ReturnedValue atomicAnd(char *data, Value v)
{
- return Encode(*(const int *)(data + index));
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndAndOrdered(*mem, value);
+ return typeToValue(value);
}
-void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <typename T>
+ReturnedValue atomicExchange(char *data, Value v)
{
- int v = (int)value.toInt32();
- if (e->hasException)
- return;
- *(int *)(data + index) = v;
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndStoreOrdered(*mem, value);
+ return typeToValue(value);
}
-ReturnedValue UInt32ArrayRead(const char *data, int index)
+template <typename T>
+ReturnedValue atomicOr(char *data, Value v)
{
- return Encode(*(const unsigned int *)(data + index));
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndOrOrdered(*mem, value);
+ return typeToValue(value);
}
-void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <typename T>
+ReturnedValue atomicSub(char *data, Value v)
{
- unsigned int v = (unsigned int)value.toUInt32();
- if (e->hasException)
- return;
- *(unsigned int *)(data + index) = v;
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndSubOrdered(*mem, value);
+ return typeToValue(value);
}
-ReturnedValue Float32ArrayRead(const char *data, int index)
+template <typename T>
+ReturnedValue atomicXor(char *data, Value v)
{
- return Encode(*(const float *)(data + index));
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ value = QAtomicOps<T>::fetchAndXorOrdered(*mem, value);
+ return typeToValue(value);
}
-void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <typename T>
+ReturnedValue atomicCompareExchange(char *data, Value expected, Value v)
{
- float v = value.toNumber();
- if (e->hasException)
- return;
- *(float *)(data + index) = v;
+ T value = valueToType<T>(v);
+ T exp = valueToType<T>(expected);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ T old;
+ QAtomicOps<T>::testAndSetOrdered(*mem, exp, value, &old);
+ return typeToValue(old);
}
-ReturnedValue Float64ArrayRead(const char *data, int index)
+template <typename T>
+ReturnedValue atomicLoad(char *data)
{
- return Encode(*(const double *)(data + index));
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ T val = QAtomicOps<T>::load(*mem);
+ return typeToValue(val);
}
-void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value)
+template <typename T>
+ReturnedValue atomicStore(char *data, Value v)
{
- double v = value.toNumber();
- if (e->hasException)
- return;
- *(double *)(data + index) = v;
+ T value = valueToType<T>(v);
+ typename QAtomicOps<T>::Type *mem = reinterpret_cast<typename QAtomicOps<T>::Type *>(data);
+ QAtomicOps<T>::store(*mem, value);
+ return typeToValue(value);
}
-const TypedArrayOperations operations[Heap::TypedArray::NTypes] = {
- { 1, "Int8Array", Int8ArrayRead, Int8ArrayWrite },
- { 1, "Uint8Array", UInt8ArrayRead, UInt8ArrayWrite },
- { 1, "Uint8ClampedArray", UInt8ArrayRead, UInt8ClampedArrayWrite },
- { 2, "Int16Array", Int16ArrayRead, Int16ArrayWrite },
- { 2, "Uint16Array", UInt16ArrayRead, UInt16ArrayWrite },
- { 4, "Int32Array", Int32ArrayRead, Int32ArrayWrite },
- { 4, "Uint32Array", UInt32ArrayRead, UInt32ArrayWrite },
- { 4, "Float32Array", Float32ArrayRead, Float32ArrayWrite },
- { 8, "Float64Array", Float64ArrayRead, Float64ArrayWrite },
+
+template<typename T>
+constexpr TypedArrayOperations TypedArrayOperations::create(const char *name)
+{
+ return { sizeof(T),
+ name,
+ ::read<T>,
+ ::write<T>,
+ { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr },
+ nullptr,
+ nullptr,
+ nullptr
+ };
+}
+
+template<typename T>
+constexpr TypedArrayOperations TypedArrayOperations::createWithAtomics(const char *name)
+{
+ return { sizeof(T),
+ name,
+ ::read<T>,
+ ::write<T>,
+ { ::atomicAdd<T>, ::atomicAnd<T>, ::atomicExchange<T>, ::atomicOr<T>, ::atomicSub<T>, ::atomicXor<T> },
+ ::atomicCompareExchange<T>,
+ ::atomicLoad<T>,
+ ::atomicStore<T>
+ };
+}
+
+const TypedArrayOperations operations[NTypedArrayTypes] = {
+#ifdef Q_ATOMIC_INT8_IS_SUPPORTED
+ TypedArrayOperations::createWithAtomics<qint8>("Int8Array"),
+ TypedArrayOperations::createWithAtomics<quint8>("Uint8Array"),
+#else
+ TypedArrayOperations::create<qint8>("Int8Array"),
+ TypedArrayOperations::create<quint8>("Uint8Array"),
+#endif
+ TypedArrayOperations::createWithAtomics<qint16>("Int16Array"),
+ TypedArrayOperations::createWithAtomics<quint16>("Uint16Array"),
+ TypedArrayOperations::createWithAtomics<qint32>("Int32Array"),
+ TypedArrayOperations::createWithAtomics<quint32>("Uint32Array"),
+ TypedArrayOperations::create<ClampedUInt8>("Uint8ClampedArray"),
+ TypedArrayOperations::create<float>("Float32Array"),
+ TypedArrayOperations::create<double>("Float64Array")
};
@@ -209,16 +280,28 @@ void Heap::TypedArrayCtor::init(QV4::ExecutionContext *scope, TypedArray::Type t
type = t;
}
-ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const Value *argv, int argc)
+ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget)
{
Scope scope(f->engine());
const TypedArrayCtor *that = static_cast<const TypedArrayCtor *>(f);
+ auto updateProto = [=](Scope &scope, Scoped<TypedArray> &a) {
+ if (newTarget->heapObject() != f->heapObject() && newTarget->isFunctionObject()) {
+ const FunctionObject *nt = static_cast<const FunctionObject *>(newTarget);
+ ScopedObject o(scope, nt->protoProperty());
+ if (o)
+ a->setPrototypeOf(o);
+ }
+ };
+
if (!argc || !argv[0].isObject()) {
// ECMA 6 22.2.1.1
- double l = argc ? argv[0].toNumber() : 0;
+ qint64 l = argc ? argv[0].toIndex() : 0;
if (scope.engine->hasException)
return Encode::undefined();
+ // ### lift UINT_MAX restriction
+ if (l < 0 || l > UINT_MAX)
+ return scope.engine->throwRangeError(QLatin1String("Index out of range."));
uint len = (uint)l;
if (l != len)
scope.engine->throwRangeError(QStringLiteral("Non integer length for typed array."));
@@ -232,12 +315,15 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
array->d()->byteLength = byteLength;
array->d()->byteOffset = 0;
+ updateProto(scope, array);
return array.asReturnedValue();
}
- Scoped<TypedArray> typedArray(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<TypedArray> typedArray(scope, argc ? argv[0] : Value::undefinedValue());
if (!!typedArray) {
// ECMA 6 22.2.1.2
Scoped<ArrayBuffer> buffer(scope, typedArray->d()->buffer);
+ if (!buffer || buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
uint srcElementSize = typedArray->d()->type->bytesPerElement;
uint destElementSize = operations[that->d()->type].bytesPerElement;
uint byteLength = typedArray->d()->byteLength;
@@ -261,22 +347,27 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
} else {
// not same size, we need to loop
uint l = typedArray->length();
- TypedArrayRead read = typedArray->d()->type->read;
- TypedArrayWrite write =array->d()->type->write;
+ TypedArrayOperations::Read read = typedArray->d()->type->read;
+ TypedArrayOperations::Write write =array->d()->type->write;
for (uint i = 0; i < l; ++i) {
- Primitive val;
- val.setRawValue(read(src, i*srcElementSize));
- write(scope.engine, dest, i*destElementSize, val);
+ Value val;
+ val.setRawValue(read(src + i*srcElementSize));
+ write(dest + i*destElementSize, val);
}
}
+ updateProto(scope, array);
return array.asReturnedValue();
}
- Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Primitive::undefinedValue());
+ Scoped<ArrayBuffer> buffer(scope, argc ? argv[0] : Value::undefinedValue());
if (!!buffer) {
// ECMA 6 22.2.1.4
double dbyteOffset = argc > 1 ? argv[1].toInteger() : 0;
+
+ if (buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
uint byteOffset = (uint)dbyteOffset;
uint elementSize = operations[that->d()->type].bytesPerElement;
if (dbyteOffset < 0 || (byteOffset % elementSize) || dbyteOffset > buffer->byteLength())
@@ -291,6 +382,8 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
double l = qBound(0., argv[2].toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
return Encode::undefined();
+ if (buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
l *= elementSize;
if (buffer->byteLength() - byteOffset < l)
return scope.engine->throwRangeError(QStringLiteral("new TypedArray: invalid length"));
@@ -301,18 +394,23 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
array->d()->buffer.set(scope.engine, buffer->d());
array->d()->byteLength = byteLength;
array->d()->byteOffset = byteOffset;
+
+ updateProto(scope, array);
return array.asReturnedValue();
}
// ECMA 6 22.2.1.3
- ScopedObject o(scope, argc ? argv[0] : Primitive::undefinedValue());
+ ScopedObject o(scope, argc ? argv[0] : Value::undefinedValue());
uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length()))->toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
return scope.engine->throwTypeError();
uint elementSize = operations[that->d()->type].bytesPerElement;
- Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(l * elementSize));
+ size_t bufferSize;
+ if (mul_overflow(size_t(l), size_t(elementSize), &bufferSize))
+ return scope.engine->throwRangeError(QLatin1String("new TypedArray: invalid length"));
+ Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(bufferSize));
if (scope.engine->hasException)
return Encode::undefined();
@@ -325,91 +423,207 @@ ReturnedValue TypedArrayCtor::callAsConstructor(const FunctionObject *f, const V
char *b = newBuffer->d()->data->data();
ScopedValue val(scope);
while (idx < l) {
- val = o->getIndexed(idx);
- array->d()->type->write(scope.engine, b, 0, val);
+ val = o->get(idx);
+ val = val->convertedToNumber();
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ array->d()->type->write(b, val);
if (scope.engine->hasException)
return Encode::undefined();
++idx;
b += elementSize;
}
-
+ updateProto(scope, array);
return array.asReturnedValue();
}
-ReturnedValue TypedArrayCtor::call(const FunctionObject *f, const Value *, const Value *argv, int argc)
+ReturnedValue TypedArrayCtor::virtualCall(const FunctionObject *f, const Value *, const Value *, int)
{
- return callAsConstructor(f, argv, argc);
+ return f->engine()->throwTypeError(QStringLiteral("calling a TypedArray constructor without new is invalid"));
}
void Heap::TypedArray::init(Type t)
{
Object::init();
- type = operations + t;
- arrayType = t;
+ type = operations + static_cast<int>(t);
+ arrayType = static_cast<int>(t);
}
Heap::TypedArray *TypedArray::create(ExecutionEngine *e, Heap::TypedArray::Type t)
{
- QV4::InternalClass *ic = e->internalClasses[EngineBase::Class_Empty]->changeVTable(staticVTable());
- ic = ic->changePrototype(e->typedArrayPrototype[t].d());
- return e->memoryManager->allocObject<TypedArray>(ic, e->typedArrayPrototype + t, t);
+ Scope scope(e);
+ Scoped<InternalClass> ic(scope, e->newInternalClass(staticVTable(), e->typedArrayPrototype + static_cast<int>(t)));
+ return e->memoryManager->allocObject<TypedArray>(ic->d(), t);
}
-ReturnedValue TypedArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue TypedArray::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX && !id.isCanonicalNumericIndexString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+ // fall through, with index == UINT_MAX it'll do the right thing.
+
Scope scope(static_cast<const Object *>(m)->engine());
Scoped<TypedArray> a(scope, static_cast<const TypedArray *>(m));
+ if (a->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
- uint bytesPerElement = a->d()->type->bytesPerElement;
- uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
- if (byteOffset + bytesPerElement > (uint)a->d()->buffer->byteLength()) {
+ if (index >= a->length()) {
if (hasProperty)
*hasProperty = false;
return Encode::undefined();
}
+
+ uint bytesPerElement = a->d()->type->bytesPerElement;
+ uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
+ Q_ASSERT(byteOffset + bytesPerElement <= (uint)a->d()->buffer->byteLength());
+
if (hasProperty)
*hasProperty = true;
- return a->d()->type->read(a->d()->buffer->data->data(), byteOffset);
+ return a->d()->type->read(a->d()->buffer->data->data() + byteOffset);
+}
+
+bool TypedArray::virtualHasProperty(const Managed *m, PropertyKey id)
+{
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX && !id.isCanonicalNumericIndexString())
+ return Object::virtualHasProperty(m, id);
+ // fall through, with index == UINT_MAX it'll do the right thing.
+
+ const TypedArray *a = static_cast<const TypedArray *>(m);
+ if (a->d()->buffer->isDetachedBuffer()) {
+ a->engine()->throwTypeError();
+ return false;
+ }
+ if (index >= a->length())
+ return false;
+ return true;
}
-bool TypedArray::putIndexed(Managed *m, uint index, const Value &value)
+PropertyAttributes TypedArray::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
{
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX && !id.isCanonicalNumericIndexString())
+ return Object::virtualGetOwnProperty(m, id, p);
+ // fall through, with index == UINT_MAX it'll do the right thing.
+
+ bool hasProperty = false;
+ ReturnedValue v = virtualGet(m, id, m, &hasProperty);
+ if (p)
+ p->value = v;
+ return hasProperty ? Attr_NotConfigurable : PropertyAttributes();
+}
+
+bool TypedArray::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
+{
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX && !id.isCanonicalNumericIndexString())
+ return Object::virtualPut(m, id, value, receiver);
+ // fall through, with index == UINT_MAX it'll do the right thing.
+
ExecutionEngine *v4 = static_cast<Object *>(m)->engine();
if (v4->hasException)
return false;
Scope scope(v4);
Scoped<TypedArray> a(scope, static_cast<TypedArray *>(m));
+ if (a->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ if (index >= a->length())
+ return false;
uint bytesPerElement = a->d()->type->bytesPerElement;
uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
- if (byteOffset + bytesPerElement > (uint)a->d()->buffer->byteLength())
+ Q_ASSERT(byteOffset + bytesPerElement <= (uint)a->d()->buffer->byteLength());
+
+ Value v = Value::fromReturnedValue(value.convertedToNumber());
+ if (scope.hasException() || a->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ a->d()->type->write(a->d()->buffer->data->data() + byteOffset, v);
+ return true;
+}
+
+bool TypedArray::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
+{
+ uint index = id.asArrayIndex();
+ if (index == UINT_MAX && !id.isCanonicalNumericIndexString())
+ return Object::virtualDefineOwnProperty(m, id, p, attrs);
+ // fall through, with index == UINT_MAX it'll do the right thing.
+
+ TypedArray *a = static_cast<TypedArray *>(m);
+ if (index >= a->length() || attrs.isAccessor())
return false;
- a->d()->type->write(scope.engine, a->d()->buffer->data->data(), byteOffset, value);
+ if (attrs.hasConfigurable() && attrs.isConfigurable())
+ return false;
+ if (attrs.hasEnumerable() && !attrs.isEnumerable())
+ return false;
+ if (attrs.hasWritable() && !attrs.isWritable())
+ return false;
+ if (!p->value.isEmpty()) {
+ ExecutionEngine *engine = a->engine();
+
+ Value v = Value::fromReturnedValue(p->value.convertedToNumber());
+ if (engine->hasException || a->d()->buffer->isDetachedBuffer())
+ return engine->throwTypeError();
+ uint bytesPerElement = a->d()->type->bytesPerElement;
+ uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
+ Q_ASSERT(byteOffset + bytesPerElement <= (uint)a->d()->buffer->byteLength());
+ a->d()->type->write(a->d()->buffer->data->data() + byteOffset, v);
+ }
return true;
}
+struct TypedArrayOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
+{
+ ~TypedArrayOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey TypedArrayOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
+{
+ const TypedArray *a = static_cast<const TypedArray *>(o);
+ if (arrayIndex < a->length()) {
+ if (attrs)
+ *attrs = Attr_NotConfigurable;
+ PropertyKey id = PropertyKey::fromArrayIndex(arrayIndex);
+ if (pd) {
+ bool hasProperty = false;
+ pd->value = TypedArray::virtualGet(a, id, a, &hasProperty);
+ }
+ ++arrayIndex;
+ return id;
+ }
+
+ arrayIndex = UINT_MAX;
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *TypedArray::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new TypedArrayOwnPropertyKeyIterator();
+}
+
void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
- ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(3));
- ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
- ctor->defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Primitive::fromInt32(operations[ctor->d()->type].bytesPerElement));
- defineDefaultProperty(engine->id_constructor(), (o = ctor));
- defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, nullptr);
- defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, nullptr);
- defineAccessorProperty(QStringLiteral("byteOffset"), method_get_byteOffset, nullptr);
- defineAccessorProperty(QStringLiteral("length"), method_get_length, nullptr);
- defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Primitive::fromInt32(operations[ctor->d()->type].bytesPerElement));
- defineDefaultProperty(QStringLiteral("set"), method_set, 1);
- defineDefaultProperty(QStringLiteral("subarray"), method_subarray, 0);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(3));
+ ctor->defineReadonlyProperty(engine->id_prototype(), *this);
+ ctor->defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Value::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
+ ctor->setPrototypeOf(engine->intrinsicTypedArrayCtor());
+
+ setPrototypeOf(engine->intrinsicTypedArrayPrototype());
+ defineDefaultProperty(engine->id_constructor(), (o = ctor));
+ defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Value::fromInt32(operations[static_cast<int>(ctor->d()->type)].bytesPerElement));
}
-ReturnedValue TypedArrayPrototype::method_get_buffer(const FunctionObject *b, const Value *thisObject, const Value *, int)
+ReturnedValue IntrinsicTypedArrayPrototype::method_get_buffer(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
const TypedArray *v = thisObject->as<TypedArray>();
@@ -419,49 +633,773 @@ ReturnedValue TypedArrayPrototype::method_get_buffer(const FunctionObject *b, co
return v->d()->buffer->asReturnedValue();
}
-ReturnedValue TypedArrayPrototype::method_get_byteLength(const FunctionObject *b, const Value *thisObject, const Value *, int)
+ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteLength(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
const TypedArray *v = thisObject->as<TypedArray>();
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteLength);
}
-ReturnedValue TypedArrayPrototype::method_get_byteOffset(const FunctionObject *b, const Value *thisObject, const Value *, int)
+ReturnedValue IntrinsicTypedArrayPrototype::method_get_byteOffset(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
const TypedArray *v = thisObject->as<TypedArray>();
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteOffset);
}
-ReturnedValue TypedArrayPrototype::method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int)
+ReturnedValue IntrinsicTypedArrayPrototype::method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int)
{
ExecutionEngine *v4 = b->engine();
const TypedArray *v = thisObject->as<TypedArray>();
if (!v)
return v4->throwTypeError();
+ if (v->d()->buffer->isDetachedBuffer())
+ return Encode(0);
+
return Encode(v->d()->byteLength/v->d()->type->bytesPerElement);
}
-ReturnedValue TypedArrayPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue IntrinsicTypedArrayPrototype::method_copyWithin(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ Scoped<TypedArray> O(scope, thisObject);
+ if (!O || O->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ if (!argc)
+ return O->asReturnedValue();
+
+ qint64 len = static_cast<uint>(O->length());
+
+ qint64 to = static_cast<qint64>(argv[0].toInteger());
+ if (to < 0)
+ to = qMax(len + to, 0ll);
+ else
+ to = qMin(to, len);
+
+ qint64 from = (argc > 1) ? static_cast<qint64>(argv[1].toInteger()) : 0ll;
+ if (from < 0)
+ from = qMax(len + from, 0ll);
+ else
+ from = qMin(from, len);
+
+ double fend = argv[2].toInteger();
+ if (fend > len)
+ fend = len;
+ qint64 end = (argc > 2 && !argv[2].isUndefined()) ? static_cast<qint64>(fend) : len;
+ if (end < 0)
+ end = qMax(len + end, 0ll);
+ else
+ end = qMin(end, len);
+
+ qint64 count = qMin(end - from, len - to);
+
+ if (count <= 0)
+ return O->asReturnedValue();
+
+ if (O->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ if (from != to) {
+ int elementSize = O->d()->type->bytesPerElement;
+ char *data = O->d()->buffer->data->data() + O->d()->byteOffset;
+ memmove(data + to*elementSize, data + from*elementSize, count*elementSize);
+ }
+
+ return O->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_entries(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
+ ao->d()->iterationKind = IteratorKind::KeyValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_every(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ ScopedValue r(scope);
+ Value *arguments = scope.alloc(3);
+
+ const char *data = v->d()->buffer->data->data();
+ uint bytesPerElement = v->d()->type->bytesPerElement;
+ uint byteOffset = v->d()->byteOffset;
+
+ bool ok = true;
+ for (uint k = 0; ok && k < len; ++k) {
+ if (v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ arguments[0] = v->d()->type->read(data + byteOffset + k * bytesPerElement);
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = v;
+ r = callback->call(that, arguments, 3);
+ ok = r->toBoolean();
+ }
+ return Encode(ok);
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_fill(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+ double dlen = len;
+ double relativeStart = argc > 1 ? argv[1].toInteger() : 0.;
+ double relativeEnd = len;
+ if (argc > 2 && !argv[2].isUndefined())
+ relativeEnd = argv[2].toInteger();
+
+ uint k = 0;
+ uint fin = 0;
+
+ if (relativeStart < 0) {
+ k = static_cast<uint>(std::max(len+relativeStart, 0.));
+ } else {
+ k = static_cast<uint>(std::min(relativeStart, dlen));
+ }
+
+ if (relativeEnd < 0) {
+ fin = static_cast<uint>(std::max(len + relativeEnd, 0.));
+ } else {
+ fin = static_cast<uint>(std::min(relativeEnd, dlen));
+ }
+
+ double val = argc ? argv[0].toNumber() : std::numeric_limits<double>::quiet_NaN();
+ Value value = Value::fromDouble(val);
+ if (scope.hasException() || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ char *data = v->d()->buffer->data->data();
+ uint bytesPerElement = v->d()->type->bytesPerElement;
+ uint byteOffset = v->d()->byteOffset;
+
+ while (k < fin) {
+ v->d()->type->write(data + byteOffset + k * bytesPerElement, value);
+ k++;
+ }
+
+ return v.asReturnedValue();
+}
+
+static TypedArray *typedArraySpeciesCreate(Scope &scope, const TypedArray *instance, uint len)
+{
+ const FunctionObject *constructor = instance->speciesConstructor(scope, scope.engine->typedArrayCtors + instance->d()->arrayType);
+ if (!constructor) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+
+ Value *arguments = scope.alloc(1);
+ arguments[0] = Encode(len);
+ Scoped<TypedArray> a(scope, constructor->callAsConstructor(arguments, 1));
+ if (!a || a->d()->buffer->isDetachedBuffer() || a->length() < len) {
+ scope.engine->throwTypeError();
+ return nullptr;
+ }
+ return a;
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_filter(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue selected(scope);
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ Value *arguments = scope.alloc(3);
+ Value *list = arguments;
+
+ uint to = 0;
+ for (uint k = 0; k < len; ++k) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ bool exists;
+ arguments[0] = instance->get(k, &exists);
+ if (!exists)
+ continue;
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = instance;
+ selected = callback->call(that, arguments, 3);
+ if (selected->toBoolean()) {
+ ++arguments;
+ scope.alloc(1);
+ ++to;
+ }
+ }
+
+ TypedArray *a = typedArraySpeciesCreate(scope, instance, to);
+ if (!a)
+ return Encode::undefined();
+
+ for (uint i = 0; i < to; ++i)
+ a->put(i, list[i]);
+
+ return a->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_find(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+
+ if (!argc || !argv[0].isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue result(scope);
+ Value *arguments = scope.alloc(3);
+
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+
+ for (uint k = 0; k < len; ++k) {
+ if (v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ arguments[0] = v->get(k);
+ CHECK_EXCEPTION();
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = v;
+ result = callback->call(that, arguments, 3);
+
+ CHECK_EXCEPTION();
+ if (result->toBoolean())
+ return arguments[0].asReturnedValue();
+ }
+
+ RETURN_UNDEFINED();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_findIndex(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+
+ if (!argc || !argv[0].isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue result(scope);
+ Value *arguments = scope.alloc(3);
+
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+
+ for (uint k = 0; k < len; ++k) {
+ if (v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ arguments[0] = v->get(k);
+ CHECK_EXCEPTION();
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = v;
+ result = callback->call(that, arguments, 3);
+
+ CHECK_EXCEPTION();
+ if (result->toBoolean())
+ return Encode(k);
+ }
+
+ return Encode(-1);
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_forEach(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ Value *arguments = scope.alloc(3);
+
+ for (uint k = 0; k < len; ++k) {
+ if (v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ bool exists;
+ arguments[0] = v->get(k, &exists);
+ if (!exists)
+ continue;
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = v;
+ callback->call(that, arguments, 3);
+ }
+ RETURN_UNDEFINED();
+}
+
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_includes(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+ if (len == 0) {
+ return Encode(false);
+ }
+
+ double n = 0;
+ if (argc > 1 && !argv[1].isUndefined()) {
+ n = argv[1].toInteger();
+ }
+
+ double k = 0;
+ if (n >= 0) {
+ k = n;
+ } else {
+ k = len + n;
+ if (k < 0) {
+ k = 0;
+ }
+ }
+
+ while (k < len) {
+ ScopedValue val(scope, v->get(k));
+ if (val->sameValueZero(argv[0])) {
+ return Encode(true);
+ }
+ k++;
+ }
+
+ return Encode(false);
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_indexOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+ if (!len)
+ return Encode(-1);
+
+ ScopedValue searchValue(scope, argc ? argv[0] : Value::undefinedValue());
+ uint fromIndex = 0;
+
+ if (argc >= 2) {
+ double f = argv[1].toInteger();
+ CHECK_EXCEPTION();
+ if (f >= len)
+ return Encode(-1);
+ if (f < 0)
+ f = qMax(len + f, 0.);
+ fromIndex = (uint) f;
+ }
+
+ if (v->isStringObject()) {
+ ScopedValue value(scope);
+ for (uint k = fromIndex; k < len; ++k) {
+ bool exists;
+ value = v->get(k, &exists);
+ if (exists && RuntimeHelpers::strictEqual(value, searchValue))
+ return Encode(k);
+ }
+ return Encode(-1);
+ }
+
+ ScopedValue value(scope);
+
+ for (uint i = fromIndex; i < len; ++i) {
+ bool exists;
+ value = v->get(i, &exists);
+ CHECK_EXCEPTION();
+ if (exists && RuntimeHelpers::strictEqual(value, searchValue))
+ return Encode(i);
+ }
+ return Encode(-1);
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_join(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = v->length();
+
+ ScopedValue arg(scope, argc ? argv[0] : Value::undefinedValue());
+
+ QString r4;
+ if (arg->isUndefined())
+ r4 = QStringLiteral(",");
+ else
+ r4 = arg->toQString();
+
+ const quint32 r2 = len;
+
+ if (!r2)
+ return Encode(scope.engine->newString());
+
+ QString R;
+
+ //
+ // crazy!
+ //
+ ScopedString name(scope, scope.engine->newString(QStringLiteral("0")));
+ ScopedValue r6(scope, v->get(name));
+ if (!r6->isNullOrUndefined())
+ R = r6->toQString();
+
+ ScopedValue r12(scope);
+ for (quint32 k = 1; k < r2; ++k) {
+ R += r4;
+
+ name = Value::fromDouble(k).toString(scope.engine);
+ r12 = v->get(name);
+ CHECK_EXCEPTION();
+
+ if (!r12->isNullOrUndefined())
+ R += r12->toQString();
+ }
+
+ return Encode(scope.engine->newString(R));
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_keys(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
+ ao->d()->iterationKind = IteratorKind::KeyIteratorKind;
+ return ao->asReturnedValue();
+}
+
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_lastIndexOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+ if (!len)
+ return Encode(-1);
+
+ ScopedValue searchValue(scope);
+ uint fromIndex = len;
+
+ if (argc >= 1)
+ searchValue = argv[0];
+ else
+ searchValue = Value::undefinedValue();
+
+ if (argc >= 2) {
+ double f = argv[1].toInteger();
+ CHECK_EXCEPTION();
+ if (f > 0)
+ f = qMin(f, (double)(len - 1));
+ else if (f < 0) {
+ f = len + f;
+ if (f < 0)
+ return Encode(-1);
+ }
+ fromIndex = (uint) f + 1;
+ }
+
+ ScopedValue value(scope);
+ for (uint k = fromIndex; k > 0;) {
+ --k;
+ bool exists;
+ value = instance->get(k, &exists);
+ if (exists && RuntimeHelpers::strictEqual(value, searchValue))
+ return Encode(k);
+ }
+ return Encode(-1);
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_map(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ TypedArray *a = typedArraySpeciesCreate(scope, instance, len);
+ if (!a)
+ return Encode::undefined();
+
+ ScopedValue v(scope);
+ ScopedValue mapped(scope);
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ Value *arguments = scope.alloc(3);
+
+ for (uint k = 0; k < len; ++k) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ arguments[0] = instance->get(k);
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = instance;
+ mapped = callback->call(that, arguments, 3);
+ a->put(k, mapped);
+ }
+ return a->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_reduce(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ uint k = 0;
+ ScopedValue acc(scope);
+ ScopedValue v(scope);
+
+ if (argc > 1) {
+ acc = argv[1];
+ } else {
+ bool kPresent = false;
+ while (k < len && !kPresent) {
+ v = instance->get(k, &kPresent);
+ if (kPresent)
+ acc = v;
+ ++k;
+ }
+ if (!kPresent)
+ THROW_TYPE_ERROR();
+ }
+
+ Value *arguments = scope.alloc(4);
+
+ while (k < len) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ bool kPresent;
+ v = instance->get(k, &kPresent);
+ if (kPresent) {
+ arguments[0] = acc;
+ arguments[1] = v;
+ arguments[2] = Value::fromDouble(k);
+ arguments[3] = instance;
+ acc = callback->call(nullptr, arguments, 4);
+ }
+ ++k;
+ }
+ return acc->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_reduceRight(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ if (len == 0) {
+ if (argc == 1)
+ THROW_TYPE_ERROR();
+ return argv[1].asReturnedValue();
+ }
+
+ uint k = len;
+ ScopedValue acc(scope);
+ ScopedValue v(scope);
+ if (argc > 1) {
+ acc = argv[1];
+ } else {
+ bool kPresent = false;
+ while (k > 0 && !kPresent) {
+ v = instance->get(k - 1, &kPresent);
+ if (kPresent)
+ acc = v;
+ --k;
+ }
+ if (!kPresent)
+ THROW_TYPE_ERROR();
+ }
+
+ Value *arguments = scope.alloc(4);
+
+ while (k > 0) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ bool kPresent;
+ v = instance->get(k - 1, &kPresent);
+ if (kPresent) {
+ arguments[0] = acc;
+ arguments[1] = v;
+ arguments[2] = Value::fromDouble(k - 1);
+ arguments[3] = instance;
+ acc = callback->call(nullptr, arguments, 4);
+ }
+ --k;
+ }
+ return acc->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_reverse(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint length = instance->length();
+
+ int lo = 0, hi = length - 1;
+
+ ScopedValue lval(scope);
+ ScopedValue hval(scope);
+ for (; lo < hi; ++lo, --hi) {
+ bool loExists, hiExists;
+ lval = instance->get(lo, &loExists);
+ hval = instance->get(hi, &hiExists);
+ Q_ASSERT(hiExists && loExists);
+ bool ok;
+ ok = instance->put(lo, hval);
+ Q_ASSERT(ok);
+ ok = instance->put(hi, lval);
+ Q_ASSERT(ok);
+ }
+ return instance->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_some(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ if (!argc || !argv->isFunctionObject())
+ THROW_TYPE_ERROR();
+ const FunctionObject *callback = static_cast<const FunctionObject *>(argv);
+
+ ScopedValue that(scope, argc > 1 ? argv[1] : Value::undefinedValue());
+ ScopedValue result(scope);
+ Value *arguments = scope.alloc(3);
+
+ for (uint k = 0; k < len; ++k) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ bool exists;
+ arguments[0] = instance->get(k, &exists);
+ if (!exists)
+ continue;
+
+ arguments[1] = Value::fromDouble(k);
+ arguments[2] = instance;
+ result = callback->call(that, arguments, 3);
+ if (result->toBoolean())
+ return Encode(true);
+ }
+ return Encode(false);
+}
+
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_values(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<TypedArray> v(scope, thisObject);
+ if (!v || v->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ Scoped<ArrayIteratorObject> ao(scope, scope.engine->newArrayIteratorObject(v));
+ ao->d()->iterationKind = IteratorKind::ValueIteratorKind;
+ return ao->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(b);
Scoped<TypedArray> a(scope, *thisObject);
if (!a)
return scope.engine->throwTypeError();
Scoped<ArrayBuffer> buffer(scope, a->d()->buffer);
- if (!buffer)
- scope.engine->throwTypeError();
double doffset = argc >= 2 ? argv[1].toInteger() : 0;
if (scope.engine->hasException)
RETURN_UNDEFINED();
+ if (!buffer || buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
if (doffset < 0 || doffset >= UINT_MAX)
RETURN_RESULT(scope.engine->throwRangeError(QStringLiteral("TypedArray.set: out of range")));
@@ -484,11 +1422,18 @@ ReturnedValue TypedArrayPrototype::method_set(const FunctionObject *b, const Val
RETURN_RESULT(scope.engine->throwRangeError(QStringLiteral("TypedArray.set: out of range")));
uint idx = 0;
+ if (buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
char *b = buffer->d()->data->data() + a->d()->byteOffset + offset*elementSize;
ScopedValue val(scope);
while (idx < l) {
- val = o->getIndexed(idx);
- a->d()->type->write(scope.engine, b, 0, val);
+ val = o->get(idx);
+ if (scope.hasException())
+ return Encode::undefined();
+ val = val->convertedToNumber();
+ if (scope.hasException() || buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ a->d()->type->write(b, val);
if (scope.engine->hasException)
RETURN_UNDEFINED();
++idx;
@@ -499,7 +1444,7 @@ ReturnedValue TypedArrayPrototype::method_set(const FunctionObject *b, const Val
// src is a typed array
Scoped<ArrayBuffer> srcBuffer(scope, srcTypedArray->d()->buffer);
- if (!srcBuffer)
+ if (!srcBuffer || srcBuffer->isDetachedBuffer())
return scope.engine->throwTypeError();
uint l = srcTypedArray->length();
@@ -524,12 +1469,12 @@ ReturnedValue TypedArrayPrototype::method_set(const FunctionObject *b, const Val
// typed arrays of different kind, need to manually loop
uint srcElementSize = srcTypedArray->d()->type->bytesPerElement;
- TypedArrayRead read = srcTypedArray->d()->type->read;
- TypedArrayWrite write = a->d()->type->write;
+ TypedArrayOperations::Read read = srcTypedArray->d()->type->read;
+ TypedArrayOperations::Write write = a->d()->type->write;
for (uint i = 0; i < l; ++i) {
- Primitive val;
- val.setRawValue(read(src, i*srcElementSize));
- write(scope.engine, dest, i*elementSize, val);
+ Value val;
+ val.setRawValue(read(src + i*srcElementSize));
+ write(dest + i*elementSize, val);
}
if (srcCopy)
@@ -538,7 +1483,54 @@ ReturnedValue TypedArrayPrototype::method_set(const FunctionObject *b, const Val
RETURN_UNDEFINED();
}
-ReturnedValue TypedArrayPrototype::method_subarray(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue IntrinsicTypedArrayPrototype::method_slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+
+ double s = (argc ? argv[0] : Value::undefinedValue()).toInteger();
+ uint start;
+ if (s < 0)
+ start = (uint)qMax(len + s, 0.);
+ else if (s > len)
+ start = len;
+ else
+ start = (uint) s;
+ uint end = len;
+ if (argc > 1 && !argv[1].isUndefined()) {
+ double e = argv[1].toInteger();
+ if (e < 0)
+ end = (uint)qMax(len + e, 0.);
+ else if (e > len)
+ end = len;
+ else
+ end = (uint) e;
+ }
+ uint count = start > end ? 0 : end - start;
+
+ TypedArray *a = typedArraySpeciesCreate(scope, instance, count);
+ if (!a)
+ return Encode::undefined();
+
+ ScopedValue v(scope);
+ uint n = 0;
+ for (uint i = start; i < end; ++i) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ v = instance->get(i);
+ if (a->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ a->put(n, v);
+ ++n;
+ }
+ return a->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_subarray(const FunctionObject *builtin, const Value *thisObject, const Value *argv, int argc)
{
Scope scope(builtin);
Scoped<TypedArray> a(scope, *thisObject);
@@ -547,8 +1539,7 @@ ReturnedValue TypedArrayPrototype::method_subarray(const FunctionObject *builtin
return scope.engine->throwTypeError();
Scoped<ArrayBuffer> buffer(scope, a->d()->buffer);
- if (!buffer)
- return scope.engine->throwTypeError();
+ Q_ASSERT(buffer);
int len = a->length();
double b = argc > 0 ? argv[0].toInteger() : 0;
@@ -568,7 +1559,7 @@ ReturnedValue TypedArrayPrototype::method_subarray(const FunctionObject *builtin
int newLen = end - begin;
- ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor()));
+ ScopedFunctionObject constructor(scope, a->speciesConstructor(scope, scope.engine->typedArrayCtors + a->d()->arrayType));
if (!constructor)
return scope.engine->throwTypeError();
@@ -576,5 +1567,134 @@ ReturnedValue TypedArrayPrototype::method_subarray(const FunctionObject *builtin
arguments[0] = buffer;
arguments[1] = Encode(a->d()->byteOffset + begin*a->d()->type->bytesPerElement);
arguments[2] = Encode(newLen);
- return constructor->callAsConstructor(arguments, 3);
+ a = constructor->callAsConstructor(arguments, 3);
+ if (!a || a->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ return a->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_toLocaleString(const FunctionObject *b, const Value *thisObject, const Value *, int)
+{
+ Scope scope(b);
+ Scoped<TypedArray> instance(scope, thisObject);
+ if (!instance || instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+
+ uint len = instance->length();
+ const QString separator = QStringLiteral(",");
+
+ QString R;
+
+ ScopedValue v(scope);
+ ScopedString s(scope);
+
+ for (uint k = 0; k < len; ++k) {
+ if (instance->d()->buffer->isDetachedBuffer())
+ return scope.engine->throwTypeError();
+ if (k)
+ R += separator;
+
+ v = instance->get(k);
+ v = Runtime::method_callElement(scope.engine, v, *scope.engine->id_toLocaleString(), nullptr, 0);
+ s = v->toString(scope.engine);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ R += s->toQString();
+ }
+ return scope.engine->newString(R)->asReturnedValue();
+}
+
+ReturnedValue IntrinsicTypedArrayPrototype::method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *, int)
+{
+ const TypedArray *a = thisObject->as<TypedArray>();
+ if (!a)
+ return Encode::undefined();
+
+ return a->engine()->newString(QString::fromLatin1(a->d()->type->name))->asReturnedValue();
+}
+
+static bool validateTypedArray(const Object *o)
+{
+ const TypedArray *a = o->as<TypedArray>();
+ if (!a)
+ return false;
+ if (a->d()->buffer->isDetachedBuffer())
+ return false;
+ return true;
+}
+
+ReturnedValue IntrinsicTypedArrayCtor::method_of(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+{
+ Scope scope(f);
+ int len = argc;
+ const Value *items = argv;
+ const FunctionObject *C = thisObject->as<FunctionObject>();
+ if (!C || !C->isConstructor())
+ return scope.engine->throwTypeError();
+
+ Value lenValue = Value::fromInt32(len);
+ ScopedObject newObj(scope, C->callAsConstructor(&lenValue, 1));
+ if (scope.hasException())
+ return Encode::undefined();
+ if (!::validateTypedArray(newObj))
+ return scope.engine->throwTypeError();
+ TypedArray *a = newObj->as<TypedArray>();
+ Q_ASSERT(a);
+ if (a->length() < static_cast<uint>(len))
+ return scope.engine->throwTypeError();
+
+ for (int k = 0; k < len; ++k) {
+ newObj->put(PropertyKey::fromArrayIndex(k), items[k]);
+ }
+ return newObj->asReturnedValue();
+}
+
+void IntrinsicTypedArrayPrototype::init(ExecutionEngine *engine, IntrinsicTypedArrayCtor *ctor)
+{
+ Scope scope(engine);
+ ctor->defineReadonlyProperty(engine->id_prototype(), *this);
+ ctor->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(0));
+ ScopedString s(scope, engine->newString(QStringLiteral("TypedArray")));
+ ctor->defineReadonlyConfigurableProperty(engine->id_name(), s);
+ s = scope.engine->newString(QStringLiteral("of"));
+ ctor->defineDefaultProperty(s, IntrinsicTypedArrayCtor::method_of);
+ ctor->addSymbolSpecies();
+
+ defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, nullptr);
+ defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, nullptr);
+ defineAccessorProperty(QStringLiteral("byteOffset"), method_get_byteOffset, nullptr);
+ defineAccessorProperty(QStringLiteral("length"), method_get_length, nullptr);
+
+ defineDefaultProperty(QStringLiteral("copyWithin"), method_copyWithin, 2);
+ defineDefaultProperty(QStringLiteral("entries"), method_entries, 0);
+ defineDefaultProperty(QStringLiteral("every"), method_every, 1);
+ defineDefaultProperty(QStringLiteral("fill"), method_fill, 1);
+ defineDefaultProperty(QStringLiteral("filter"), method_filter, 1);
+ defineDefaultProperty(QStringLiteral("find"), method_find, 1);
+ defineDefaultProperty(QStringLiteral("findIndex"), method_findIndex, 1);
+ defineDefaultProperty(QStringLiteral("forEach"), method_forEach, 1);
+ defineDefaultProperty(QStringLiteral("includes"), method_includes, 1);
+ defineDefaultProperty(QStringLiteral("indexOf"), method_indexOf, 1);
+ defineDefaultProperty(QStringLiteral("join"), method_join, 1);
+ defineDefaultProperty(QStringLiteral("keys"), method_keys, 0);
+ defineDefaultProperty(QStringLiteral("lastIndexOf"), method_lastIndexOf, 1);
+ defineDefaultProperty(QStringLiteral("map"), method_map, 1);
+ defineDefaultProperty(QStringLiteral("reduce"), method_reduce, 1);
+ defineDefaultProperty(QStringLiteral("reduceRight"), method_reduceRight, 1);
+ defineDefaultProperty(QStringLiteral("reverse"), method_reverse, 0);
+ defineDefaultProperty(QStringLiteral("some"), method_some, 1);
+ defineDefaultProperty(QStringLiteral("set"), method_set, 1);
+ defineDefaultProperty(QStringLiteral("slice"), method_slice, 2);
+ defineDefaultProperty(QStringLiteral("subarray"), method_subarray, 2);
+ defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString, 0);
+ ScopedObject f(scope, engine->arrayPrototype()->get(engine->id_toString()));
+ defineDefaultProperty(engine->id_toString(), f);
+
+ ScopedString valuesString(scope, engine->newIdentifier(QStringLiteral("values")));
+ ScopedObject values(scope, FunctionObject::createBuiltinFunction(engine, valuesString, method_values, 0));
+ defineDefaultProperty(QStringLiteral("values"), values);
+ defineDefaultProperty(engine->symbol_iterator(), values);
+
+ defineAccessorProperty(engine->symbol_toStringTag(), method_get_toStringTag, nullptr);
}
diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h
index 129c662c97..64792f23a2 100644
--- a/src/qml/jsruntime/qv4typedarray_p.h
+++ b/src/qml/jsruntime/qv4typedarray_p.h
@@ -60,14 +60,50 @@ namespace QV4 {
struct ArrayBuffer;
-typedef ReturnedValue (*TypedArrayRead)(const char *data, int index);
-typedef void (*TypedArrayWrite)(ExecutionEngine *engine, char *data, int index, const Value &value);
+enum TypedArrayType {
+ Int8Array,
+ UInt8Array,
+ Int16Array,
+ UInt16Array,
+ Int32Array,
+ UInt32Array,
+ UInt8ClampedArray,
+ Float32Array,
+ Float64Array,
+ NTypedArrayTypes
+};
+
+enum AtomicModifyOps {
+ AtomicAdd,
+ AtomicAnd,
+ AtomicExchange,
+ AtomicOr,
+ AtomicSub,
+ AtomicXor,
+ NAtomicModifyOps
+};
struct TypedArrayOperations {
+ typedef ReturnedValue (*Read)(const char *data);
+ typedef void (*Write)(char *data, Value value);
+ typedef ReturnedValue (*AtomicModify)(char *data, Value value);
+ typedef ReturnedValue (*AtomicCompareExchange)(char *data, Value expected, Value v);
+ typedef ReturnedValue (*AtomicLoad)(char *data);
+ typedef ReturnedValue (*AtomicStore)(char *data, Value value);
+
+ template<typename T>
+ static constexpr TypedArrayOperations create(const char *name);
+ template<typename T>
+ static constexpr TypedArrayOperations createWithAtomics(const char *name);
+
int bytesPerElement;
const char *name;
- TypedArrayRead read;
- TypedArrayWrite write;
+ Read read;
+ Write write;
+ AtomicModify atomicModifyOps[AtomicModifyOps::NAtomicModifyOps];
+ AtomicCompareExchange atomicCompareExchange;
+ AtomicLoad atomicLoad;
+ AtomicStore atomicStore;
};
namespace Heap {
@@ -81,28 +117,23 @@ namespace Heap {
DECLARE_HEAP_OBJECT(TypedArray, Object) {
DECLARE_MARKOBJECTS(TypedArray);
- enum Type {
- Int8Array,
- UInt8Array,
- UInt8ClampedArray,
- Int16Array,
- UInt16Array,
- Int32Array,
- UInt32Array,
- Float32Array,
- Float64Array,
- NTypes
- };
+ using Type = TypedArrayType;
void init(Type t);
};
+struct IntrinsicTypedArrayCtor : FunctionObject {
+};
+
struct TypedArrayCtor : FunctionObject {
void init(QV4::ExecutionContext *scope, TypedArray::Type t);
TypedArray::Type type;
};
+struct IntrinsicTypedArrayPrototype : Object {
+};
+
struct TypedArrayPrototype : Object {
inline void init(TypedArray::Type t);
TypedArray::Type type;
@@ -132,34 +163,80 @@ struct Q_QML_PRIVATE_EXPORT TypedArray : Object
Heap::TypedArray::Type arrayType() const {
return static_cast<Heap::TypedArray::Type>(d()->arrayType);
}
+ using Object::get;
+
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualHasProperty(const Managed *m, PropertyKey id);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
+
+};
+
+struct IntrinsicTypedArrayCtor: FunctionObject
+{
+ V4_OBJECT2(IntrinsicTypedArrayCtor, FunctionObject)
+
+ static constexpr VTable::Call virtualCall = nullptr;
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
- static bool putIndexed(Managed *m, uint index, const Value &value);
+ static ReturnedValue method_of(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
};
struct TypedArrayCtor: FunctionObject
{
V4_OBJECT2(TypedArrayCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
- static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *);
+ static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
-
-struct TypedArrayPrototype : Object
+struct IntrinsicTypedArrayPrototype : Object
{
- V4_OBJECT2(TypedArrayPrototype, Object)
+ V4_OBJECT2(IntrinsicTypedArrayPrototype, Object)
V4_PROTOTYPE(objectPrototype)
- void init(ExecutionEngine *engine, TypedArrayCtor *ctor);
+ void init(ExecutionEngine *engine, IntrinsicTypedArrayCtor *ctor);
static ReturnedValue method_get_buffer(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_byteOffset(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_copyWithin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_every(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_fill(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_filter(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_find(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_findIndex(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_includes(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_join(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_map(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_reduce(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_reduceRight(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_reverse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_some(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_subarray(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ static ReturnedValue method_toLocaleString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+ static ReturnedValue method_get_toStringTag(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+
+};
+
+struct TypedArrayPrototype : Object
+{
+ V4_OBJECT2(TypedArrayPrototype, Object)
+ V4_PROTOTYPE(objectPrototype)
+
+ void init(ExecutionEngine *engine, TypedArrayCtor *ctor);
};
inline void
diff --git a/src/qml/jsruntime/qv4util_p.h b/src/qml/jsruntime/qv4util_p.h
index 2669a3e4bf..073832937d 100644
--- a/src/qml/jsruntime/qv4util_p.h
+++ b/src/qml/jsruntime/qv4util_p.h
@@ -59,26 +59,6 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
-template <typename T>
-struct TemporaryAssignment
-{
- TemporaryAssignment(T &var, const T& temporaryValue)
- : variable(var)
- , savedValue(var)
- {
- variable = temporaryValue;
- }
- ~TemporaryAssignment()
- {
- variable = savedValue;
- }
- T &variable;
- T savedValue;
-private:
- TemporaryAssignment(const TemporaryAssignment<T>&);
- TemporaryAssignment operator=(const TemporaryAssignment<T>&);
-};
-
#if !defined(BROKEN_STD_VECTOR_BOOL_OR_BROKEN_STD_FIND)
// Sanity:
class BitVector
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 0d4711df3c..cbc153bb86 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -39,7 +39,9 @@
#include <qv4engine_p.h>
#include <qv4runtime_p.h>
#include <qv4string_p.h>
+#include <qv4propertykey_p.h>
#ifndef V4_BOOTSTRAP
+#include <qv4symbol_p.h>
#include <qv4object_p.h>
#include <qv4objectproto_p.h>
#include <private/qv4mm_p.h>
@@ -84,7 +86,7 @@ bool Value::toBooleanImpl(Value val)
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- if (b->vtable()->isString)
+ if (b->internalClass->vtable->isString)
return static_cast<Heap::String *>(b)->length() > 0;
#endif
return true;
@@ -107,6 +109,11 @@ double Value::toNumberImpl(Value val)
#else
if (String *s = val.stringValue())
return RuntimeHelpers::stringToNumber(s->toQString());
+ if (val.isSymbol()) {
+ Managed &m = static_cast<Managed &>(val);
+ m.engine()->throwTypeError();
+ return 0;
+ }
{
Q_ASSERT(val.isObject());
Scope scope(val.objectValue()->engine());
@@ -145,6 +152,8 @@ QString Value::toQStringNoThrow() const
case Value::Managed_Type:
if (String *s = stringValue())
return s->toQString();
+ if (Symbol *s = symbolValue())
+ return s->descriptiveString();
{
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
@@ -197,9 +206,12 @@ QString Value::toQString() const
else
return QStringLiteral("false");
case Value::Managed_Type:
- if (String *s = stringValue())
+ if (String *s = stringValue()) {
return s->toQString();
- {
+ } else if (isSymbol()) {
+ static_cast<const Managed *>(this)->engine()->throwTypeError();
+ return QString();
+ } else {
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
ScopedValue prim(scope, RuntimeHelpers::toPrimitive(*this, STRING_HINT));
@@ -217,6 +229,25 @@ QString Value::toQString() const
}
} // switch
}
+
+QV4::PropertyKey Value::toPropertyKey(ExecutionEngine *e) const
+{
+ if (isInteger() && int_32() >= 0)
+ return PropertyKey::fromArrayIndex(static_cast<uint>(int_32()));
+ if (isStringOrSymbol()) {
+ Scope scope(e);
+ ScopedStringOrSymbol s(scope, this);
+ return s->toPropertyKey();
+ }
+ Scope scope(e);
+ ScopedValue v(scope, RuntimeHelpers::toPrimitive(*this, STRING_HINT));
+ if (!v->isStringOrSymbol())
+ v = v->toString(e);
+ if (e->hasException)
+ return PropertyKey::invalid();
+ ScopedStringOrSymbol s(scope, v);
+ return s->toPropertyKey();
+}
#endif // V4_BOOTSTRAP
bool Value::sameValue(Value other) const {
@@ -235,6 +266,25 @@ bool Value::sameValue(Value other) const {
return false;
}
+bool Value::sameValueZero(Value other) const {
+ if (_val == other._val)
+ return true;
+ String *s = stringValue();
+ String *os = other.stringValue();
+ if (s && os)
+ return s->isEqualTo(os);
+ if (isInteger() && other.isDouble())
+ return double(int_32()) == other.doubleValue();
+ if (isDouble() && other.isInteger())
+ return other.int_32() == doubleValue();
+ if (isDouble() && other.isDouble()) {
+ if (doubleValue() == 0 && other.doubleValue() == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
#ifndef V4_BOOTSTRAP
Heap::String *Value::toString(ExecutionEngine *e, Value val)
{
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index a5ee6b5373..7c895e3637 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -56,6 +56,7 @@
#include <QtCore/QString>
#include "qv4global_p.h"
#include <private/qv4heap_p.h>
+#include <private/qv4internalclass_p.h>
#include <private/qnumeric_p.h>
@@ -69,7 +70,6 @@ namespace Heap {
struct Q_QML_PRIVATE_EXPORT Value
{
-private:
/*
We use 8 bytes for a value and a different variant of NaN boxing. A Double
NaN (actually -qNaN) is indicated by a number that has the top 13 bits set, and for a
@@ -125,10 +125,9 @@ private:
quint64 _val;
-public:
- QML_NEARLY_ALWAYS_INLINE quint64 &rawValueRef() { return _val; }
- QML_NEARLY_ALWAYS_INLINE quint64 rawValue() const { return _val; }
- QML_NEARLY_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR quint64 &rawValueRef() { return _val; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR quint64 rawValue() const { return _val; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setRawValue(quint64 raw) { _val = raw; }
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
static inline int valueOffset() { return 0; }
@@ -137,10 +136,11 @@ public:
static inline int valueOffset() { return 4; }
static inline int tagOffset() { return 0; }
#endif
- QML_NEARLY_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
- QML_NEARLY_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
- QML_NEARLY_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
- QML_NEARLY_ALWAYS_INLINE void setTag(quint32 tag) { setTagValue(tag, value()); }
+ static inline constexpr quint64 tagValue(quint32 tag, quint32 value) { return quint64(tag) << 32 | value; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
+ QML_NEARLY_ALWAYS_INLINE constexpr quint32 value() const { return _val & quint64(~quint32(0)); }
+ QML_NEARLY_ALWAYS_INLINE constexpr quint32 tag() const { return _val >> 32; }
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setTag(quint32 tag) { setTagValue(tag, value()); }
#if QT_POINTER_SIZE == 8
QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const
@@ -172,35 +172,19 @@ public:
# error "unsupported pointer size"
#endif
- QML_NEARLY_ALWAYS_INLINE int int_32() const
+ QML_NEARLY_ALWAYS_INLINE constexpr int int_32() const
{
return int(value());
}
- QML_NEARLY_ALWAYS_INLINE void setInt_32(int i)
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setInt_32(int i)
{
setTagValue(quint32(ValueTypeInternal::Integer), quint32(i));
}
QML_NEARLY_ALWAYS_INLINE uint uint_32() const { return value(); }
- QML_NEARLY_ALWAYS_INLINE void setEmpty()
- {
- setTagValue(quint32(ValueTypeInternal::Empty), value());
- }
-
- QML_NEARLY_ALWAYS_INLINE void setEmpty(int i)
- {
- setTagValue(quint32(ValueTypeInternal::Empty), quint32(i));
- }
-
- QML_NEARLY_ALWAYS_INLINE void setEmpty(quint32 i)
+ QML_NEARLY_ALWAYS_INLINE Q_DECL_RELAXED_CONSTEXPR void setEmpty()
{
- setTagValue(quint32(ValueTypeInternal::Empty), i);
- }
-
- QML_NEARLY_ALWAYS_INLINE quint32 emptyValue()
- {
- Q_ASSERT(isEmpty());
- return quint32(value());
+ setTagValue(quint32(ValueTypeInternal::Empty), 0);
}
// ### Fix for 32 bit (easiest solution is to set highest bit to 1 for mananged/undefined/integercompatible
@@ -248,7 +232,8 @@ public:
IsManagedOrUndefined_Shift = 64-15,
IsIntegerConvertible_Shift = 64-15,
IsIntegerOrBool_Shift = 64-16,
- QuickType_Shift = 64 - 17
+ QuickType_Shift = 64 - 17,
+ IsPositiveIntShift = 31
};
static const quint64 Immediate_Mask_64 = 0x00020000u; // bit 49
@@ -315,6 +300,14 @@ public:
}
inline bool isNaN() const { return (tag() & 0x7ffc0000 ) == 0x00040000; }
+ inline bool isPositiveInt() const {
+#if QT_POINTER_SIZE == 4
+ return isInteger() && int_32() >= 0;
+#else
+ return (_val >> IsPositiveIntShift) == (quint64(ValueTypeInternal::Integer) << 1);
+#endif
+ }
+
QML_NEARLY_ALWAYS_INLINE double doubleValue() const {
Q_ASSERT(isDouble());
double d;
@@ -331,6 +324,8 @@ public:
Q_ASSERT(isDouble());
}
inline bool isString() const;
+ inline bool isStringOrSymbol() const;
+ inline bool isSymbol() const;
inline bool isObject() const;
inline bool isFunctionObject() const;
inline bool isInt32() {
@@ -338,14 +333,17 @@ public:
return true;
if (isDouble()) {
double d = doubleValue();
- int i = (int)d;
- if (i == d && !(d == 0 && std::signbit(d))) {
- setInt_32(i);
+ if (isInt32(d)) {
+ setInt_32(int(d));
return true;
}
}
return false;
}
+ QML_NEARLY_ALWAYS_INLINE static bool isInt32(double d) {
+ int i = int(d);
+ return (i == d && !(d == 0 && std::signbit(d)));
+ }
double asDouble() const {
if (tag() == quint32(ValueTypeInternal::Integer))
return int_32();
@@ -362,7 +360,17 @@ public:
QML_NEARLY_ALWAYS_INLINE String *stringValue() const {
if (!isString())
return nullptr;
- return reinterpret_cast<String*>(const_cast<Value *>(this));
+ return reinterpret_cast<String *>(const_cast<Value *>(this));
+ }
+ QML_NEARLY_ALWAYS_INLINE StringOrSymbol *stringOrSymbolValue() const {
+ if (!isStringOrSymbol())
+ return nullptr;
+ return reinterpret_cast<StringOrSymbol *>(const_cast<Value *>(this));
+ }
+ QML_NEARLY_ALWAYS_INLINE Symbol *symbolValue() const {
+ if (!isSymbol())
+ return nullptr;
+ return reinterpret_cast<Symbol *>(const_cast<Value *>(this));
}
QML_NEARLY_ALWAYS_INLINE Object *objectValue() const {
if (!isObject())
@@ -388,6 +396,8 @@ public:
int toUInt16() const;
inline int toInt32() const;
inline unsigned int toUInt32() const;
+ qint64 toLength() const;
+ inline qint64 toIndex() const;
bool toBoolean() const {
if (integerCompatible())
@@ -397,6 +407,7 @@ public:
}
static bool toBooleanImpl(Value val);
double toInteger() const;
+ inline ReturnedValue convertedToNumber() const;
inline double toNumber() const;
static double toNumberImpl(Value v);
double toNumberImpl() const { return toNumberImpl(*this); }
@@ -407,6 +418,8 @@ public:
return reinterpret_cast<Heap::String *>(m());
return toString(e, *this);
}
+ QV4::PropertyKey toPropertyKey(ExecutionEngine *e) const;
+
static Heap::String *toString(ExecutionEngine *e, Value val);
Heap::Object *toObject(ExecutionEngine *e) const {
if (isObject())
@@ -428,11 +441,11 @@ public:
if (!isManaged())
return nullptr;
- Q_ASSERT(m()->vtable());
+ Q_ASSERT(m()->internalClass->vtable);
#if !defined(QT_NO_QOBJECT_CHECK)
static_cast<const T *>(this)->qt_check_for_QMANAGED_macro(static_cast<const T *>(this));
#endif
- const VTable *vt = m()->vtable();
+ const VTable *vt = m()->internalClass->vtable;
while (vt) {
if (vt == T::staticVTable())
return static_cast<const T *>(this);
@@ -455,21 +468,32 @@ public:
return static_cast<const T *>(managed());
}
- inline uint asArrayIndex() const;
- inline bool asArrayIndex(uint &idx) const;
#ifndef V4_BOOTSTRAP
uint asArrayLength(bool *ok) const;
#endif
ReturnedValue *data_ptr() { return &_val; }
- ReturnedValue asReturnedValue() const { return _val; }
+ constexpr ReturnedValue asReturnedValue() const { return _val; }
static Value fromReturnedValue(ReturnedValue val) { Value v; v._val = val; return v; }
- // Section 9.12
+ // As per ES specs
bool sameValue(Value other) const;
+ bool sameValueZero(Value other) const;
inline void mark(MarkStack *markStack);
+ inline static constexpr Value emptyValue() { return { tagValue(quint32(ValueTypeInternal::Empty), 0) }; }
+ static inline constexpr Value fromBoolean(bool b) { return { tagValue(quint32(ValueTypeInternal::Boolean), b) }; }
+ static inline constexpr Value fromInt32(int i) { return { tagValue(quint32(ValueTypeInternal::Integer), quint32(i)) }; }
+ inline static constexpr Value undefinedValue() { return { 0 }; }
+ static inline constexpr Value nullValue() { return { tagValue(quint32(ValueTypeInternal::Null), 0) }; }
+ static inline Value fromDouble(double d);
+ static inline Value fromUInt32(uint i);
+
+ static double toInteger(double d);
+ static int toInt32(double d);
+ static unsigned int toUInt32(double d);
+
Value &operator =(const ScopedValue &v);
Value &operator=(ReturnedValue v) { _val = v; return *this; }
Value &operator=(Managed *m) {
@@ -500,18 +524,32 @@ inline void Value::mark(MarkStack *markStack)
inline bool Value::isString() const
{
Heap::Base *b = heapObject();
- return b && b->vtable()->isString;
+ return b && b->internalClass->vtable->isString;
}
+
+bool Value::isStringOrSymbol() const
+{
+ Heap::Base *b = heapObject();
+ return b && b->internalClass->vtable->isStringOrSymbol;
+}
+
+bool Value::isSymbol() const
+{
+ Heap::Base *b = heapObject();
+ return b && b->internalClass->vtable->isStringOrSymbol && !b->internalClass->vtable->isString;
+}
+
inline bool Value::isObject() const
+
{
Heap::Base *b = heapObject();
- return b && b->vtable()->isObject;
+ return b && b->internalClass->vtable->isObject;
}
inline bool Value::isFunctionObject() const
{
Heap::Base *b = heapObject();
- return b && b->vtable()->isFunctionObject;
+ return b && b->internalClass->vtable->isFunctionObject;
}
inline bool Value::isPrimitive() const
@@ -528,42 +566,14 @@ inline double Value::toNumber() const
return toNumberImpl();
}
-
-#ifndef V4_BOOTSTRAP
-inline uint Value::asArrayIndex() const
+inline ReturnedValue Value::convertedToNumber() const
{
-#if QT_POINTER_SIZE == 8
- if (!isNumber())
- return UINT_MAX;
- if (isInteger())
- return int_32() >= 0 ? (uint)int_32() : UINT_MAX;
-#else
- if (isInteger() && int_32() >= 0)
- return (uint)int_32();
- if (!isDouble())
- return UINT_MAX;
-#endif
- double d = doubleValue();
- uint idx = (uint)d;
- if (idx != d)
- return UINT_MAX;
- return idx;
-}
-
-inline bool Value::asArrayIndex(uint &idx) const
-{
- if (Q_LIKELY(!isDouble())) {
- if (Q_LIKELY(isInteger() && int_32() >= 0)) {
- idx = (uint)int_32();
- return true;
- }
- return false;
- }
- double d = doubleValue();
- idx = (uint)d;
- return (idx == d && idx != UINT_MAX);
+ if (isInteger() || isDouble())
+ return asReturnedValue();
+ Value v;
+ v.setDouble(toNumberImpl());
+ return v.asReturnedValue();
}
-#endif
inline
ReturnedValue Heap::Base::asReturnedValue() const
@@ -571,79 +581,16 @@ ReturnedValue Heap::Base::asReturnedValue() const
return Value::fromHeapObject(const_cast<Heap::Base *>(this)).asReturnedValue();
}
-
-
-struct Q_QML_PRIVATE_EXPORT Primitive : public Value
-{
- inline static Primitive emptyValue();
- inline static Primitive emptyValue(uint v);
- static inline Primitive fromBoolean(bool b);
- static inline Primitive fromInt32(int i);
- inline static Primitive undefinedValue();
- static inline Primitive nullValue();
- static inline Primitive fromDouble(double d);
- static inline Primitive fromUInt32(uint i);
-
- using Value::toInt32;
- using Value::toUInt32;
-
- static double toInteger(double d);
- static int toInt32(double d);
- static unsigned int toUInt32(double d);
-};
-
-inline Primitive Primitive::undefinedValue()
-{
- Primitive v;
- v.setM(nullptr);
- return v;
-}
-
-inline Primitive Primitive::emptyValue()
-{
- Primitive v;
- v.setEmpty(0);
- return v;
-}
-
-inline Primitive Primitive::emptyValue(uint e)
-{
- Primitive v;
- v.setEmpty(e);
- return v;
-}
-
-inline Primitive Primitive::nullValue()
-{
- Primitive v;
- v.setTagValue(quint32(ValueTypeInternal::Null), 0);
- return v;
-}
-
-inline Primitive Primitive::fromBoolean(bool b)
+inline Value Value::fromDouble(double d)
{
- Primitive v;
- v.setTagValue(quint32(ValueTypeInternal::Boolean), b);
- return v;
-}
-
-inline Primitive Primitive::fromDouble(double d)
-{
- Primitive v;
+ Value v;
v.setDouble(d);
return v;
}
-inline Primitive Primitive::fromInt32(int i)
-{
- Primitive v;
- v.setInt_32(i);
- return v;
-}
-
-inline Primitive Primitive::fromUInt32(uint i)
+inline Value Value::fromUInt32(uint i)
{
- Primitive v;
+ Value v;
if (i < INT_MAX) {
v.setTagValue(quint32(ValueTypeInternal::Integer), i);
} else {
@@ -699,7 +646,7 @@ struct Double {
}
};
-inline double Primitive::toInteger(double d)
+inline double Value::toInteger(double d)
{
if (std::isnan(d))
return +0;
@@ -708,41 +655,48 @@ inline double Primitive::toInteger(double d)
return d >= 0 ? std::floor(d) : std::ceil(d);
}
-inline int Primitive::toInt32(double value)
+inline int Value::toInt32(double value)
{
return Double::toInt32(value);
}
-inline unsigned int Primitive::toUInt32(double d)
+inline unsigned int Value::toUInt32(double d)
{
return static_cast<uint>(toInt32(d));
}
+// For source compat with older code in other modules
+using Primitive = Value;
+
struct Encode {
- static ReturnedValue undefined() {
- return Primitive::undefinedValue().rawValue();
+ static constexpr ReturnedValue undefined() {
+ return Value::undefinedValue().asReturnedValue();
}
- static ReturnedValue null() {
- return Primitive::nullValue().rawValue();
+ static constexpr ReturnedValue null() {
+ return Value::nullValue().asReturnedValue();
}
- explicit Encode(bool b) {
- val = Primitive::fromBoolean(b).rawValue();
+ explicit constexpr Encode(bool b)
+ : val(Value::fromBoolean(b).asReturnedValue())
+ {
}
explicit Encode(double d) {
- val = Primitive::fromDouble(d).rawValue();
+ val = Value::fromDouble(d).asReturnedValue();
}
- explicit Encode(int i) {
- val = Primitive::fromInt32(i).rawValue();
+ explicit constexpr Encode(int i)
+ : val(Value::fromInt32(i).asReturnedValue())
+ {
}
explicit Encode(uint i) {
- val = Primitive::fromUInt32(i).rawValue();
+ val = Value::fromUInt32(i).asReturnedValue();
}
- explicit Encode(ReturnedValue v) {
- val = v;
+ explicit constexpr Encode(ReturnedValue v)
+ : val(v)
+ {
}
- Encode(Value v) {
- val = v.rawValue();
+ constexpr Encode(Value v)
+ : val(v.asReturnedValue())
+ {
}
explicit Encode(Heap::Base *o) {
@@ -755,13 +709,13 @@ struct Encode {
}
static ReturnedValue smallestNumber(double d) {
- if (static_cast<int>(d) == d && !(d == 0. && std::signbit(d)))
+ if (Value::isInt32(d))
return Encode(static_cast<int>(d));
else
return Encode(d);
}
- operator ReturnedValue() const {
+ constexpr operator ReturnedValue() const {
return val;
}
quint64 val;
@@ -788,12 +742,37 @@ inline unsigned int Value::toUInt32() const
return static_cast<unsigned int>(toInt32());
}
+inline qint64 Value::toLength() const
+{
+ if (Q_LIKELY(integerCompatible()))
+ return int_32() < 0 ? 0 : int_32();
+ double i = Value::toInteger(isDouble() ? doubleValue() : toNumberImpl());
+ if (i <= 0)
+ return 0;
+ if (i > (static_cast<qint64>(1) << 53) - 1)
+ return (static_cast<qint64>(1) << 53) - 1;
+ return static_cast<qint64>(i);
+}
+
+inline qint64 Value::toIndex() const
+{
+ qint64 idx;
+ if (Q_LIKELY(integerCompatible())) {
+ idx = int_32();
+ } else {
+ idx = static_cast<qint64>(Value::toInteger(isDouble() ? doubleValue() : toNumberImpl()));
+ }
+ if (idx > (static_cast<qint64>(1) << 53) - 1)
+ idx = -1;
+ return idx;
+}
+
inline double Value::toInteger() const
{
if (integerCompatible())
return int_32();
- return Primitive::toInteger(isDouble() ? doubleValue() : toNumberImpl());
+ return Value::toInteger(isDouble() ? doubleValue() : toNumberImpl());
}
@@ -831,7 +810,7 @@ struct ValueArray {
WriteBarrier::write(e, base(), values[index].data_ptr(), v.asReturnedValue());
}
void set(EngineBase *e, uint index, Heap::Base *b) {
- WriteBarrier::write(e, base(), values[index].data_ptr(), b->asReturnedValue());
+ WriteBarrier::write(e, base(), values[index].data_ptr(), Value::fromHeapObject(b).asReturnedValue());
}
inline const Value &operator[] (uint index) const {
Q_ASSERT(index < alloc);
@@ -884,7 +863,6 @@ struct ValueArray {
// have wrong offsets between host and target.
Q_STATIC_ASSERT(offsetof(ValueArray<0>, values) == 8);
-
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index bee17e0390..ef0877dbd0 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -70,7 +70,7 @@ bool VariantObject::Data::isScarce() const
return t == QVariant::Pixmap || t == QVariant::Image;
}
-bool VariantObject::isEqualTo(Managed *m, Managed *other)
+bool VariantObject::virtualIsEqualTo(Managed *m, Managed *other)
{
Q_ASSERT(m->as<QV4::VariantObject>());
QV4::VariantObject *lv = static_cast<QV4::VariantObject *>(m);
diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h
index 62fa7ff9a8..78e0a5373a 100644
--- a/src/qml/jsruntime/qv4variantobject_p.h
+++ b/src/qml/jsruntime/qv4variantobject_p.h
@@ -99,7 +99,8 @@ struct VariantObject : Object
void addVmePropertyReference() const;
void removeVmePropertyReference() const;
- static bool isEqualTo(Managed *m, Managed *other);
+protected:
+ static bool virtualIsEqualTo(Managed *m, Managed *other);
};
struct VariantPrototype : VariantObject
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index a1f5b01fa9..f81c8438ce 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -55,12 +55,13 @@
#include <private/qv4string_p.h>
#include <private/qv4profiling_p.h>
#include <private/qv4jscall_p.h>
+#include <private/qv4generatorobject_p.h>
#include <private/qqmljavascriptexpression_p.h>
#include <iostream>
#include "qv4alloca_p.h"
-#include <private/qv4jit_p.h>
+#include <private/qv4baselinejit_p.h>
#undef COUNT_INSTRUCTIONS
@@ -327,7 +328,7 @@ static struct InstrCount {
#ifdef MOTH_COMPUTED_GOTO
#define MOTH_END_INSTR(instr) \
- MOTH_DISPATCH() \
+ MOTH_DISPATCH_SINGLE() \
}
#else // !MOTH_COMPUTED_GOTO
#define MOTH_END_INSTR(instr) \
@@ -343,7 +344,7 @@ static struct InstrCount {
#endif
#define CHECK_EXCEPTION \
if (engine->hasException) \
- goto catchException
+ goto handleUnwind
static inline Heap::CallContext *getScope(QV4::Value *stack, int level)
{
@@ -361,95 +362,6 @@ static inline const QV4::Value &constant(Function *function, int index)
return function->compilationUnit->constants[index];
}
-
-static bool compareEqual(QV4::Value lhs, QV4::Value rhs)
-{
- redo:
- if (lhs.asReturnedValue() == rhs.asReturnedValue())
- return !lhs.isNaN();
-
- int lt = lhs.quickType();
- int rt = rhs.quickType();
- if (rt < lt) {
- qSwap(lhs, rhs);
- qSwap(lt, rt);
- }
-
- switch (lt) {
- case QV4::Value::QT_ManagedOrUndefined:
- if (lhs.isUndefined())
- return rhs.isNullOrUndefined();
- Q_FALLTHROUGH();
- case QV4::Value::QT_ManagedOrUndefined1:
- case QV4::Value::QT_ManagedOrUndefined2:
- case QV4::Value::QT_ManagedOrUndefined3:
- // LHS: Managed
- switch (rt) {
- case QV4::Value::QT_ManagedOrUndefined:
- if (rhs.isUndefined())
- return false;
- Q_FALLTHROUGH();
- case QV4::Value::QT_ManagedOrUndefined1:
- case QV4::Value::QT_ManagedOrUndefined2:
- case QV4::Value::QT_ManagedOrUndefined3: {
- // RHS: Managed
- Heap::Base *l = lhs.m();
- Heap::Base *r = rhs.m();
- Q_ASSERT(l);
- Q_ASSERT(r);
- if (l->vtable()->isString == r->vtable()->isString)
- return static_cast<QV4::Managed &>(lhs).isEqualTo(&static_cast<QV4::Managed &>(rhs));
- if (l->vtable()->isString) {
- rhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(rhs), PREFERREDTYPE_HINT));
- break;
- } else {
- Q_ASSERT(r->vtable()->isString);
- lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(lhs), PREFERREDTYPE_HINT));
- break;
- }
- return false;
- }
- case QV4::Value::QT_Empty:
- Q_UNREACHABLE();
- case QV4::Value::QT_Null:
- return false;
- case QV4::Value::QT_Bool:
- case QV4::Value::QT_Int:
- rhs = Primitive::fromDouble(rhs.int_32());
- // fall through
- default: // double
- if (lhs.m()->vtable()->isString)
- return RuntimeHelpers::toNumber(lhs) == rhs.doubleValue();
- else
- lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(lhs), PREFERREDTYPE_HINT));
- }
- goto redo;
- case QV4::Value::QT_Empty:
- Q_UNREACHABLE();
- case QV4::Value::QT_Null:
- return rhs.isNull();
- case QV4::Value::QT_Bool:
- case QV4::Value::QT_Int:
- switch (rt) {
- case QV4::Value::QT_ManagedOrUndefined:
- case QV4::Value::QT_ManagedOrUndefined1:
- case QV4::Value::QT_ManagedOrUndefined2:
- case QV4::Value::QT_ManagedOrUndefined3:
- case QV4::Value::QT_Empty:
- case QV4::Value::QT_Null:
- Q_UNREACHABLE();
- case QV4::Value::QT_Bool:
- case QV4::Value::QT_Int:
- return lhs.int_32() == rhs.int_32();
- default: // double
- return lhs.int_32() == rhs.doubleValue();
- }
- default: // double
- Q_ASSERT(rhs.isDouble());
- return lhs.doubleValue() == rhs.doubleValue();
- }
-}
-
static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
{
redo:
@@ -462,10 +374,10 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
case QV4::Value::QT_ManagedOrUndefined2:
case QV4::Value::QT_ManagedOrUndefined3:
// LHS: Managed
- if (lhs.m()->vtable()->isString)
+ if (lhs.m()->internalClass->vtable->isString)
return RuntimeHelpers::stringToNumber(static_cast<String &>(lhs).toQString()) == rhs;
accumulator = lhs;
- lhs = Primitive::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(accumulator), PREFERREDTYPE_HINT));
+ lhs = Value::fromReturnedValue(RuntimeHelpers::objectDefaultValue(&static_cast<QV4::Object &>(accumulator), PREFERREDTYPE_HINT));
goto redo;
case QV4::Value::QT_Empty:
Q_UNREACHABLE();
@@ -479,9 +391,9 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
}
}
-#define STORE_IP() frame.instructionPointer = int(code - codeStart);
+#define STORE_IP() frame->instructionPointer = int(code - function->codeData);
#define STORE_ACC() accumulator = acc;
-#define ACC Primitive::fromReturnedValue(acc)
+#define ACC Value::fromReturnedValue(acc)
#define VALUE_TO_INT(i, val) \
int i; \
do { \
@@ -500,82 +412,46 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
} \
} while (false)
-QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
+ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
{
qt_v4ResolvePendingBreakpointsHook();
- ExecutionEngine *engine;
- QV4::Value *stack;
- CppStackFrame frame;
- frame.originalArguments = argv;
- frame.originalArgumentsCount = argc;
- Function *function;
-
- {
- Heap::ExecutionContext *scope;
-
- quintptr d = reinterpret_cast<quintptr>(fo);
- if (d & 0x1) {
- // we don't have a FunctionObject, but a ExecData
- ExecData *data = reinterpret_cast<ExecData *>(d - 1);
- function = data->function;
- scope = data->scope->d();
- fo = nullptr;
- } else {
- function = fo->function();
- scope = fo->scope();
- }
-
- engine = function->internalClass->engine;
-
- stack = engine->jsStackTop;
- CallData *callData = reinterpret_cast<CallData *>(stack);
- callData->function = fo ? fo->asReturnedValue() : Encode::undefined();
- callData->context = scope;
- callData->accumulator = Encode::undefined();
- callData->thisObject = thisObject ? *thisObject : Primitive::undefinedValue();
- if (argc > int(function->nFormals))
- argc = int(function->nFormals);
- callData->setArgc(argc);
-
- int jsStackFrameSize = offsetof(CallData, args)/sizeof(Value) + function->compiledFunction->nRegisters;
- engine->jsStackTop += jsStackFrameSize;
- memcpy(callData->args, argv, argc*sizeof(Value));
- for (Value *v = callData->args + argc; v < engine->jsStackTop; ++v)
- *v = Encode::undefined();
-
- frame.parent = engine->currentStackFrame;
- frame.v4Function = function;
- frame.instructionPointer = 0;
- frame.jsFrame = callData;
- engine->currentStackFrame = &frame;
- }
CHECK_STACK_LIMITS(engine);
+ Function *function = frame->v4Function;
Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling
QV4::Debugging::Debugger *debugger = engine->debugger();
- const uchar *exceptionHandler = nullptr;
-
- QV4::Value &accumulator = frame.jsFrame->accumulator;
- QV4::ReturnedValue acc = Encode::undefined();
#ifdef V4_ENABLE_JIT
- if (function->jittedCode == nullptr && debugger == nullptr) {
- if (engine->canJIT(function))
- QV4::JIT::BaselineJIT(function).generate();
- else
- ++function->interpreterCallCount;
+ if (debugger == nullptr) {
+ if (function->jittedCode == nullptr) {
+ if (engine->canJIT(function))
+ QV4::JIT::BaselineJIT(function).generate();
+ else
+ ++function->interpreterCallCount;
+ }
+ if (function->jittedCode != nullptr)
+ return function->jittedCode(frame, engine);
}
#endif // V4_ENABLE_JIT
+ // interpreter
if (debugger)
debugger->enteringFunction();
- if (function->jittedCode != nullptr && debugger == nullptr) {
- acc = function->jittedCode(&frame, engine);
- } else {
- // interpreter
- const uchar *code = function->codeData;
- const uchar *codeStart = code;
+ ReturnedValue result = interpret(frame, engine, function->codeData);
+
+ if (debugger)
+ debugger->leavingFunction(result);
+
+ return result;
+}
+
+QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, const char *code)
+{
+ QV4::Function *function = frame->v4Function;
+ QV4::Value &accumulator = frame->jsFrame->accumulator;
+ QV4::ReturnedValue acc = accumulator.asReturnedValue();
+ Value *stack = reinterpret_cast<Value *>(frame->jsFrame);
MOTH_JUMP_TABLE;
@@ -627,14 +503,20 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
STACK_VALUE(destReg) = STACK_VALUE(srcReg);
MOTH_END_INSTR(MoveReg)
+ MOTH_BEGIN_INSTR(LoadImport)
+ acc = function->compilationUnit->imports[index]->asReturnedValue();
+ MOTH_END_INSTR(LoadImport)
+
MOTH_BEGIN_INSTR(LoadLocal)
auto cc = static_cast<Heap::CallContext *>(stack[CallData::Context].m());
+ Q_ASSERT(cc->type != QV4::Heap::CallContext::Type_GlobalContext);
acc = cc->locals[index].asReturnedValue();
MOTH_END_INSTR(LoadLocal)
MOTH_BEGIN_INSTR(StoreLocal)
CHECK_EXCEPTION;
auto cc = static_cast<Heap::CallContext *>(stack[CallData::Context].m());
+ Q_ASSERT(cc->type != QV4::Heap::CallContext::Type_GlobalContext);
QV4::WriteBarrier::write(engine, cc, cc->locals.values[index].data_ptr(), acc);
MOTH_END_INSTR(StoreLocal)
@@ -689,58 +571,37 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
MOTH_BEGIN_INSTR(LoadElement)
STORE_IP();
- acc = Runtime::method_loadElement(engine, STACK_VALUE(base), STACK_VALUE(index));
- CHECK_EXCEPTION;
- MOTH_END_INSTR(LoadElement)
-
- MOTH_BEGIN_INSTR(LoadElementA)
- STORE_IP();
STORE_ACC();
acc = Runtime::method_loadElement(engine, STACK_VALUE(base), accumulator);
CHECK_EXCEPTION;
- MOTH_END_INSTR(LoadElementA)
+ MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(StoreElement)
STORE_IP();
STORE_ACC();
- if (!Runtime::method_storeElement(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator) && function->isStrict())
- engine->throwTypeError();
+ Runtime::method_storeElement(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator);
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
STORE_IP();
- acc = Runtime::method_loadProperty(engine, STACK_VALUE(base), name);
- CHECK_EXCEPTION;
- MOTH_END_INSTR(LoadProperty)
-
- MOTH_BEGIN_INSTR(LoadPropertyA)
- STORE_IP();
STORE_ACC();
acc = Runtime::method_loadProperty(engine, accumulator, name);
CHECK_EXCEPTION;
- MOTH_END_INSTR(LoadPropertyA)
+ MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(GetLookup)
STORE_IP();
- QV4::Lookup *l = function->compilationUnit->runtimeLookups + index;
- acc = l->getter(l, engine, STACK_VALUE(base));
- CHECK_EXCEPTION;
- MOTH_END_INSTR(GetLookup)
-
- MOTH_BEGIN_INSTR(GetLookupA)
- STORE_IP();
STORE_ACC();
QV4::Lookup *l = function->compilationUnit->runtimeLookups + index;
acc = l->getter(l, engine, accumulator);
CHECK_EXCEPTION;
- MOTH_END_INSTR(GetLookupA)
+ MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(StoreProperty)
STORE_IP();
STORE_ACC();
- if (!Runtime::method_storeProperty(engine, STACK_VALUE(base), name, accumulator) && function->isStrict())
- engine->throwTypeError();
+ Runtime::method_storeProperty(engine, STACK_VALUE(base), name, accumulator);
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreProperty)
@@ -753,6 +614,20 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
CHECK_EXCEPTION;
MOTH_END_INSTR(SetLookup)
+ MOTH_BEGIN_INSTR(LoadSuperProperty)
+ STORE_IP();
+ STORE_ACC();
+ acc = Runtime::method_loadSuperProperty(engine, STACK_VALUE(property));
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(LoadSuperProperty)
+
+ MOTH_BEGIN_INSTR(StoreSuperProperty)
+ STORE_IP();
+ STORE_ACC();
+ Runtime::method_storeSuperProperty(engine, STACK_VALUE(property), accumulator);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(StoreSuperProperty)
+
MOTH_BEGIN_INSTR(StoreScopeObjectProperty)
STORE_ACC();
Runtime::method_storeQmlScopeObjectProperty(engine, STACK_VALUE(base), propertyIndex, accumulator);
@@ -784,17 +659,60 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
CHECK_EXCEPTION;
MOTH_END_INSTR(LoadIdObject)
+ MOTH_BEGIN_INSTR(Yield)
+ frame->yield = code;
+ frame->yieldIsIterator = false;
+ return acc;
+ MOTH_END_INSTR(Yield)
+
+ MOTH_BEGIN_INSTR(YieldStar)
+ frame->yield = code;
+ frame->yieldIsIterator = true;
+ return acc;
+ MOTH_END_INSTR(YieldStar)
+
+ MOTH_BEGIN_INSTR(Resume)
+ // check exception, in case the generator was called with throw() or return()
+ if (engine->hasException) {
+ // an empty value indicates that the generator was called with return()
+ if (engine->exceptionValue->asReturnedValue() != Value::emptyValue().asReturnedValue())
+ goto handleUnwind;
+ engine->hasException = false;
+ *engine->exceptionValue = Value::undefinedValue();
+ } else {
+ code += offset;
+ }
+ MOTH_END_INSTR(Resume)
+
+ MOTH_BEGIN_INSTR(IteratorNextForYieldStar)
+ STORE_ACC();
+ acc = Runtime::method_iteratorNextForYieldStar(engine, accumulator, STACK_VALUE(iterator), &STACK_VALUE(object));
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(IteratorNextForYieldStar)
+
MOTH_BEGIN_INSTR(CallValue)
STORE_IP();
Value func = STACK_VALUE(name);
if (Q_UNLIKELY(!func.isFunctionObject())) {
acc = engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
- goto catchException;
+ goto handleUnwind;
}
- acc = static_cast<const FunctionObject &>(func).call(nullptr, stack + argv, argc);
+ Value undef = Value::undefinedValue();
+ acc = static_cast<const FunctionObject &>(func).call(&undef, stack + argv, argc);
CHECK_EXCEPTION;
MOTH_END_INSTR(CallValue)
+ MOTH_BEGIN_INSTR(CallWithReceiver)
+ STORE_IP();
+ Value func = STACK_VALUE(name);
+ if (Q_UNLIKELY(!func.isFunctionObject())) {
+ acc = engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
+ goto handleUnwind;
+ }
+ acc = static_cast<const FunctionObject &>(func).call(stack + thisObject, stack + argv, argc);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(CallWithReceiver)
+
MOTH_BEGIN_INSTR(CallProperty)
STORE_IP();
acc = Runtime::method_callProperty(engine, stack + base, name, stack + argv, argc);
@@ -809,7 +727,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
if (Q_UNLIKELY(!f.isFunctionObject())) {
acc = engine->throwTypeError();
- goto catchException;
+ goto handleUnwind;
}
acc = static_cast<FunctionObject &>(f).call(stack + base, stack + argv, argc);
@@ -852,89 +770,152 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
CHECK_EXCEPTION;
MOTH_END_INSTR(CallContextObjectProperty)
- MOTH_BEGIN_INSTR(SetExceptionHandler)
- exceptionHandler = offset ? code + offset : nullptr;
- MOTH_END_INSTR(SetExceptionHandler)
+ MOTH_BEGIN_INSTR(CallWithSpread)
+ STORE_IP();
+ acc = Runtime::method_callWithSpread(engine, STACK_VALUE(func), STACK_VALUE(thisObject), stack + argv, argc);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(CallWithSpread)
+
+ MOTH_BEGIN_INSTR(Construct)
+ STORE_IP();
+ acc = Runtime::method_construct(engine, STACK_VALUE(func), ACC, stack + argv, argc);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(Construct)
+
+ MOTH_BEGIN_INSTR(ConstructWithSpread)
+ STORE_IP();
+ acc = Runtime::method_constructWithSpread(engine, STACK_VALUE(func), ACC, stack + argv, argc);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(ConstructWithSpread)
+
+ MOTH_BEGIN_INSTR(SetUnwindHandler)
+ frame->unwindHandler = offset ? code + offset : nullptr;
+ MOTH_END_INSTR(SetUnwindHandler)
+
+ MOTH_BEGIN_INSTR(UnwindDispatch)
+ CHECK_EXCEPTION;
+ if (frame->unwindLevel) {
+ --frame->unwindLevel;
+ if (frame->unwindLevel)
+ goto handleUnwind;
+ code = frame->unwindLabel;
+ }
+ MOTH_END_INSTR(UnwindDispatch)
+
+ MOTH_BEGIN_INSTR(UnwindToLabel)
+ frame->unwindLevel = level;
+ frame->unwindLabel = code + offset;
+ goto handleUnwind;
+ MOTH_END_INSTR(UnwindToLabel)
+
+ MOTH_BEGIN_INSTR(DeadTemporalZoneCheck)
+ if (ACC.isEmpty()) {
+ STORE_IP();
+ STORE_ACC();
+ Runtime::method_throwReferenceError(engine, name);
+ goto handleUnwind;
+ }
+ MOTH_END_INSTR(DeadTemporalZoneCheck)
MOTH_BEGIN_INSTR(ThrowException)
STORE_IP();
STORE_ACC();
Runtime::method_throwException(engine, accumulator);
- goto catchException;
+ goto handleUnwind;
MOTH_END_INSTR(ThrowException)
MOTH_BEGIN_INSTR(GetException)
acc = engine->hasException ? engine->exceptionValue->asReturnedValue()
- : Primitive::emptyValue().asReturnedValue();
+ : Value::emptyValue().asReturnedValue();
engine->hasException = false;
MOTH_END_INSTR(HasException)
MOTH_BEGIN_INSTR(SetException)
- *engine->exceptionValue = acc;
- engine->hasException = true;
+ if (acc != Value::emptyValue().asReturnedValue()) {
+ *engine->exceptionValue = acc;
+ engine->hasException = true;
+ }
MOTH_END_INSTR(SetException)
MOTH_BEGIN_INSTR(PushCatchContext)
- STACK_VALUE(reg) = STACK_VALUE(CallData::Context);
ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
- STACK_VALUE(CallData::Context) = Runtime::method_createCatchContext(c, name);
+ STACK_VALUE(CallData::Context) = Runtime::method_createCatchContext(c, index, name);
MOTH_END_INSTR(PushCatchContext)
MOTH_BEGIN_INSTR(CreateCallContext)
- stack[CallData::Context] = ExecutionContext::newCallContext(&frame);
+ stack[CallData::Context] = ExecutionContext::newCallContext(frame);
MOTH_END_INSTR(CreateCallContext)
MOTH_BEGIN_INSTR(PushWithContext)
STORE_IP();
STORE_ACC();
- accumulator = accumulator.toObject(engine);
+ auto ctx = Runtime::method_createWithContext(engine, stack);
CHECK_EXCEPTION;
- STACK_VALUE(reg) = STACK_VALUE(CallData::Context);
- ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
- STACK_VALUE(CallData::Context) = Runtime::method_createWithContext(c, accumulator);
+ STACK_VALUE(CallData::Context) = ctx;
MOTH_END_INSTR(PushWithContext)
+ MOTH_BEGIN_INSTR(PushBlockContext)
+ STORE_ACC();
+ ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
+ STACK_VALUE(CallData::Context) = Runtime::method_createBlockContext(c, index);
+ MOTH_END_INSTR(PushBlockContext)
+
+ MOTH_BEGIN_INSTR(CloneBlockContext)
+ STORE_ACC();
+ ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
+ STACK_VALUE(CallData::Context) = Runtime::method_cloneBlockContext(c);
+ MOTH_END_INSTR(CloneBlockContext)
+
+ MOTH_BEGIN_INSTR(PushScriptContext)
+ STACK_VALUE(CallData::Context) = Runtime::method_createScriptContext(engine, index);
+ MOTH_END_INSTR(PushScriptContext)
+
+ MOTH_BEGIN_INSTR(PopScriptContext)
+ STACK_VALUE(CallData::Context) = Runtime::method_popScriptContext(engine);
+ MOTH_END_INSTR(PopScriptContext)
+
MOTH_BEGIN_INSTR(PopContext)
- STACK_VALUE(CallData::Context) = STACK_VALUE(reg);
+ ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
+ STACK_VALUE(CallData::Context) = c->d()->outer;
MOTH_END_INSTR(PopContext)
- MOTH_BEGIN_INSTR(ForeachIteratorObject)
+ MOTH_BEGIN_INSTR(GetIterator)
STORE_ACC();
- acc = Runtime::method_foreachIterator(engine, accumulator);
+ acc = Runtime::method_getIterator(engine, accumulator, iterator);
CHECK_EXCEPTION;
- MOTH_END_INSTR(ForeachIteratorObject)
+ MOTH_END_INSTR(GetIterator)
- MOTH_BEGIN_INSTR(ForeachNextPropertyName)
+ MOTH_BEGIN_INSTR(IteratorNext)
STORE_ACC();
- acc = Runtime::method_foreachNextPropertyName(accumulator);
+ acc = Runtime::method_iteratorNext(engine, accumulator, &STACK_VALUE(value));
+ STACK_VALUE(done) = acc;
CHECK_EXCEPTION;
- MOTH_END_INSTR(ForeachNextPropertyName)
+ MOTH_END_INSTR(IteratorNext)
- MOTH_BEGIN_INSTR(DeleteMember)
- if (!Runtime::method_deleteMember(engine, STACK_VALUE(base), member)) {
- if (function->isStrict()) {
- STORE_IP();
- engine->throwTypeError();
- goto catchException;
- }
- acc = Encode(false);
- } else {
- acc = Encode(true);
- }
- MOTH_END_INSTR(DeleteMember)
+ MOTH_BEGIN_INSTR(IteratorClose)
+ STORE_ACC();
+ acc = Runtime::method_iteratorClose(engine, accumulator, STACK_VALUE(done));
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(IteratorClose)
+
+ MOTH_BEGIN_INSTR(DestructureRestElement)
+ STORE_ACC();
+ acc = Runtime::method_destructureRestElement(engine, ACC);
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(DestructureRestElement)
- MOTH_BEGIN_INSTR(DeleteSubscript)
- if (!Runtime::method_deleteElement(engine, STACK_VALUE(base), STACK_VALUE(index))) {
+ MOTH_BEGIN_INSTR(DeleteProperty)
+ if (!Runtime::method_deleteProperty(engine, STACK_VALUE(base), STACK_VALUE(index))) {
if (function->isStrict()) {
STORE_IP();
engine->throwTypeError();
- goto catchException;
+ goto handleUnwind;
}
acc = Encode(false);
} else {
acc = Encode(true);
}
- MOTH_END_INSTR(DeleteSubscript)
+ MOTH_END_INSTR(DeleteProperty)
MOTH_BEGIN_INSTR(DeleteName)
if (!Runtime::method_deleteName(engine, name)) {
@@ -942,7 +923,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
STORE_IP();
QString n = function->compilationUnit->runtimeStrings[name]->toQString();
engine->throwSyntaxError(QStringLiteral("Can't delete property %1").arg(n));
- goto catchException;
+ goto handleUnwind;
}
acc = Encode(false);
} else {
@@ -970,9 +951,13 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
MOTH_BEGIN_INSTR(DefineObjectLiteral)
QV4::Value *arguments = stack + args;
- acc = Runtime::method_objectLiteral(engine, arguments, internalClassId, arrayValueCount, arrayGetterSetterCountAndFlags);
+ acc = Runtime::method_objectLiteral(engine, internalClassId, argc, arguments);
MOTH_END_INSTR(DefineObjectLiteral)
+ MOTH_BEGIN_INSTR(CreateClass)
+ acc = Runtime::method_createClass(engine, classIndex, STACK_VALUE(heritage), stack + computedNames);
+ MOTH_END_INSTR(CreateClass)
+
MOTH_BEGIN_INSTR(CreateMappedArgumentsObject)
acc = Runtime::method_createMappedArgumentsObject(engine);
MOTH_END_INSTR(CreateMappedArgumentsObject)
@@ -981,6 +966,10 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
acc = Runtime::method_createUnmappedArgumentsObject(engine);
MOTH_END_INSTR(CreateUnmappedArgumentsObject)
+ MOTH_BEGIN_INSTR(CreateRestParameter)
+ acc = Runtime::method_createRestParameter(engine, argIndex);
+ MOTH_END_INSTR(CreateRestParameter)
+
MOTH_BEGIN_INSTR(ConvertThisToObject)
Value *t = &stack[CallData::This];
if (!t->isObject()) {
@@ -993,11 +982,15 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
}
MOTH_END_INSTR(ConvertThisToObject)
- MOTH_BEGIN_INSTR(Construct)
- STORE_IP();
- acc = Runtime::method_construct(engine, STACK_VALUE(func), stack + argv, argc);
+ MOTH_BEGIN_INSTR(LoadSuperConstructor)
+ acc = Runtime::method_loadSuperConstructor(engine, stack[CallData::Function]);
CHECK_EXCEPTION;
- MOTH_END_INSTR(Construct)
+ MOTH_END_INSTR(LoadSuperConstructor)
+
+ MOTH_BEGIN_INSTR(ToObject)
+ acc = ACC.toObject(engine)->asReturnedValue();
+ CHECK_EXCEPTION;
+ MOTH_END_INSTR(ToObject)
MOTH_BEGIN_INSTR(Jump)
code += offset;
@@ -1023,6 +1016,16 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
}
MOTH_END_INSTR(JumpFalse)
+ MOTH_BEGIN_INSTR(JumpNoException)
+ if (!engine->hasException)
+ code += offset;
+ MOTH_END_INSTR(JumpNoException)
+
+ MOTH_BEGIN_INSTR(JumpNotUndefined)
+ if (Q_LIKELY(acc != QV4::Encode::undefined()))
+ code += offset;
+ MOTH_END_INSTR(JumpNotUndefined)
+
MOTH_BEGIN_INSTR(CmpEqNull)
acc = Encode(ACC.isNullOrUndefined());
MOTH_END_INSTR(CmpEqNull)
@@ -1059,7 +1062,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
acc = Encode(left.int_32() == ACC.int_32());
} else {
STORE_ACC();
- acc = Encode(compareEqual(left, accumulator));
+ acc = Encode(bool(Runtime::method_compareEqual(left, accumulator)));
CHECK_EXCEPTION;
}
MOTH_END_INSTR(CmpEq)
@@ -1070,7 +1073,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
acc = Encode(bool(left.int_32() != ACC.int_32()));
} else {
STORE_ACC();
- acc = Encode(!compareEqual(left, accumulator));
+ acc = Encode(bool(!Runtime::method_compareEqual(left, accumulator)));
CHECK_EXCEPTION;
}
MOTH_END_INSTR(CmpNe)
@@ -1154,27 +1157,11 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
MOTH_END_INSTR(CmpIn)
MOTH_BEGIN_INSTR(CmpInstanceOf)
- // 11.8.6, 5: rval must be an Object
- if (Q_UNLIKELY(!Primitive::fromReturnedValue(acc).isObject())) {
- acc = engine->throwTypeError();
- goto catchException;
- }
-
- // 11.8.6, 7: call "HasInstance", which we term instanceOf, and return the result.
- acc = Primitive::fromReturnedValue(acc).objectValue()->instanceOf(STACK_VALUE(lhs));
+ STORE_ACC();
+ acc = Runtime::method_instanceof(engine, STACK_VALUE(lhs), ACC);
CHECK_EXCEPTION;
MOTH_END_INSTR(CmpInstanceOf)
- MOTH_BEGIN_INSTR(JumpStrictNotEqualStackSlotInt)
- if (STACK_VALUE(lhs).int_32() != rhs || STACK_VALUE(lhs).isUndefined())
- code += offset;
- MOTH_END_INSTR(JumpStrictNotEqualStackSlotInt)
-
- MOTH_BEGIN_INSTR(JumpStrictEqualStackSlotInt)
- if (STACK_VALUE(lhs).int_32() == rhs && !STACK_VALUE(lhs).isUndefined())
- code += offset;
- MOTH_END_INSTR(JumpStrictNotEqualStackSlotInt)
-
MOTH_BEGIN_INSTR(UNot)
if (ACC.integerCompatible()) {
acc = Encode(!static_cast<bool>(ACC.int_32()));
@@ -1259,6 +1246,16 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
}
MOTH_END_INSTR(Sub)
+ MOTH_BEGIN_INSTR(Exp)
+ const Value left = STACK_VALUE(lhs);
+ double base = left.toNumber();
+ double exp = ACC.toNumber();
+ if (qIsInf(exp) && (base == 1 || base == -1))
+ acc = Encode(qSNaN());
+ else
+ acc = Encode(pow(base,exp));
+ MOTH_END_INSTR(Exp)
+
MOTH_BEGIN_INSTR(Mul)
const Value left = STACK_VALUE(lhs);
if (Q_LIKELY(Value::integerCompatible(left, ACC))) {
@@ -1351,9 +1348,22 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
MOTH_END_INSTR(ShlConst)
MOTH_BEGIN_INSTR(Ret)
- goto functionExit;
+ return acc;
MOTH_END_INSTR(Ret)
+ MOTH_BEGIN_INSTR(InitializeBlockDeadTemporalZone)
+ acc = Encode(Value::emptyValue());
+ for (int i = firstReg, end = firstReg + count; i < end; ++i)
+ STACK_VALUE(i) = acc;
+ MOTH_END_INSTR(InitializeBlockDeadTemporalZone)
+
+ MOTH_BEGIN_INSTR(ThrowOnNullOrUndefined)
+ if (Value::fromReturnedValue(acc).isNullOrUndefined()) {
+ engine->throwTypeError();
+ goto handleUnwind;
+ }
+ MOTH_END_INSTR(ThrowOnNullOrUndefined)
+
MOTH_BEGIN_INSTR(Debug)
#if QT_CONFIG(qml_debug)
STORE_IP();
@@ -1369,21 +1379,12 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const QV4::Value *thisObj
STACK_VALUE(result) = Runtime::method_loadQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine));
MOTH_END_INSTR(LoadQmlImportedScripts)
- catchException:
- Q_ASSERT(engine->hasException);
- if (!exceptionHandler) {
+ handleUnwind:
+ Q_ASSERT(engine->hasException || frame->unwindLevel);
+ if (!frame->unwindHandler) {
acc = Encode::undefined();
- goto functionExit;
+ return acc;
}
- code = exceptionHandler;
- }
+ code = frame->unwindHandler;
}
-
-functionExit:
- if (QV4::Debugging::Debugger *debugger = engine->debugger())
- debugger->leavingFunction(ACC.asReturnedValue());
- engine->currentStackFrame = frame.parent;
- engine->jsStackTop = stack;
-
- return acc;
}
diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h
index 3b7723ca7e..8a76e60f20 100644
--- a/src/qml/jsruntime/qv4vme_moth_p.h
+++ b/src/qml/jsruntime/qv4vme_moth_p.h
@@ -65,13 +65,8 @@ public:
QV4::Function *function;
const QV4::ExecutionContext *scope;
};
- static inline
- QV4::ReturnedValue exec(Function *v4Function, const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) {
- ExecData data{v4Function, context};
- quintptr d = reinterpret_cast<quintptr>(&data) | 0x1;
- return exec(reinterpret_cast<const FunctionObject *>(d), thisObject, argv, argc);
- }
- static QV4::ReturnedValue exec(const FunctionObject *fo, const Value *thisObject, const Value *argv, int argc);
+ static QV4::ReturnedValue exec(CppStackFrame *frame, ExecutionEngine *engine);
+ static QV4::ReturnedValue interpret(CppStackFrame *frame, ExecutionEngine *engine, const char *codeEntry);
};
} // namespace Moth
diff --git a/src/qml/jsruntime/qv4vtable_p.h b/src/qml/jsruntime/qv4vtable_p.h
new file mode 100644
index 0000000000..4acefecdf5
--- /dev/null
+++ b/src/qml/jsruntime/qv4vtable_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QV4VTABLE_P_H
+#define QV4VTABLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qv4global_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+struct OwnPropertyKeyIterator {
+ virtual ~OwnPropertyKeyIterator() = 0;
+ virtual PropertyKey next(const Object *o, Property *p = nullptr, PropertyAttributes *attrs = nullptr) = 0;
+};
+
+struct VTable
+{
+ typedef void (*Destroy)(Heap::Base *);
+ typedef void (*MarkObjects)(Heap::Base *, MarkStack *markStack);
+ typedef bool (*IsEqualTo)(Managed *m, Managed *other);
+
+ typedef ReturnedValue (*Get)(const Managed *, PropertyKey id, const Value *receiver, bool *hasProperty);
+ typedef bool (*Put)(Managed *, PropertyKey id, const Value &value, Value *receiver);
+ typedef bool (*DeleteProperty)(Managed *m, PropertyKey id);
+ typedef bool (*HasProperty)(const Managed *m, PropertyKey id);
+ typedef PropertyAttributes (*GetOwnProperty)(const Managed *m, PropertyKey id, Property *p);
+ typedef bool (*DefineOwnProperty)(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs);
+ typedef bool (*IsExtensible)(const Managed *);
+ typedef bool (*PreventExtensions)(Managed *);
+ typedef Heap::Object *(*GetPrototypeOf)(const Managed *);
+ typedef bool (*SetPrototypeOf)(Managed *, const Object *);
+ typedef qint64 (*GetLength)(const Managed *m);
+ typedef OwnPropertyKeyIterator *(*OwnPropertyKeys)(const Object *m, Value *target);
+ typedef ReturnedValue (*InstanceOf)(const Object *typeObject, const Value &var);
+
+ typedef ReturnedValue (*Call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
+ typedef ReturnedValue (*CallAsConstructor)(const FunctionObject *, const Value *argv, int argc, const Value *newTarget);
+
+ const VTable * const parent;
+ quint32 inlinePropertyOffset : 16;
+ quint32 nInlineProperties : 16;
+ quint8 isExecutionContext;
+ quint8 isString;
+ quint8 isObject;
+ quint8 isFunctionObject;
+ quint8 isErrorObject;
+ quint8 isArrayData;
+ quint8 isStringOrSymbol;
+ quint8 type;
+ quint8 unused[4];
+ const char *className;
+
+ Destroy destroy;
+ MarkObjects markObjects;
+ IsEqualTo isEqualTo;
+
+ Get get;
+ Put put;
+ DeleteProperty deleteProperty;
+ HasProperty hasProperty;
+ GetOwnProperty getOwnProperty;
+ DefineOwnProperty defineOwnProperty;
+ IsExtensible isExtensible;
+ PreventExtensions preventExtensions;
+ GetPrototypeOf getPrototypeOf;
+ SetPrototypeOf setPrototypeOf;
+ GetLength getLength;
+ OwnPropertyKeys ownPropertyKeys;
+ InstanceOf instanceOf;
+
+ Call call;
+ CallAsConstructor callAsConstructor;
+};
+
+
+struct VTableBase {
+protected:
+ static constexpr VTable::Destroy virtualDestroy = nullptr;
+ static constexpr VTable::IsEqualTo virtualIsEqualTo = nullptr;
+
+ static constexpr VTable::Get virtualGet = nullptr;
+ static constexpr VTable::Put virtualPut = nullptr;
+ static constexpr VTable::DeleteProperty virtualDeleteProperty = nullptr;
+ static constexpr VTable::HasProperty virtualHasProperty = nullptr;
+ static constexpr VTable::GetOwnProperty virtualGetOwnProperty = nullptr;
+ static constexpr VTable::DefineOwnProperty virtualDefineOwnProperty = nullptr;
+ static constexpr VTable::IsExtensible virtualIsExtensible = nullptr;
+ static constexpr VTable::PreventExtensions virtualPreventExtensions = nullptr;
+ static constexpr VTable::GetPrototypeOf virtualGetPrototypeOf = nullptr;
+ static constexpr VTable::SetPrototypeOf virtualSetPrototypeOf = nullptr;
+ static constexpr VTable::GetLength virtualGetLength = nullptr;
+ static constexpr VTable::OwnPropertyKeys virtualOwnPropertyKeys = nullptr;
+ static constexpr VTable::InstanceOf virtualInstanceOf = nullptr;
+
+ static constexpr VTable::Call virtualCall = nullptr;
+ static constexpr VTable::CallAsConstructor virtualCallAsConstructor = nullptr;
+};
+
+#define DEFINE_MANAGED_VTABLE_INT(classname, parentVTable) \
+{ \
+ parentVTable, \
+ (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \
+ (sizeof(classname::Data) + (classname::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) \
+ - (sizeof(classname::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), \
+ classname::IsExecutionContext, \
+ classname::IsString, \
+ classname::IsObject, \
+ classname::IsFunctionObject, \
+ classname::IsErrorObject, \
+ classname::IsArrayData, \
+ classname::IsStringOrSymbol, \
+ classname::MyType, \
+ { 0, 0, 0, 0 }, \
+ #classname, \
+ \
+ classname::virtualDestroy, \
+ classname::Data::markObjects, \
+ classname::virtualIsEqualTo, \
+ \
+ classname::virtualGet, \
+ classname::virtualPut, \
+ classname::virtualDeleteProperty, \
+ classname::virtualHasProperty, \
+ classname::virtualGetOwnProperty, \
+ classname::virtualDefineOwnProperty, \
+ classname::virtualIsExtensible, \
+ classname::virtualPreventExtensions, \
+ classname::virtualGetPrototypeOf, \
+ classname::virtualSetPrototypeOf, \
+ classname::virtualGetLength, \
+ classname::virtualOwnPropertyKeys, \
+ classname::virtualInstanceOf, \
+ \
+ classname::virtualCall, \
+ classname::virtualCallAsConstructor, \
+}
+
+#define DEFINE_MANAGED_VTABLE(classname) \
+const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, 0)
+
+#define V4_OBJECT2(DataClass, superClass) \
+ private: \
+ DataClass() Q_DECL_EQ_DELETE; \
+ Q_DISABLE_COPY(DataClass) \
+ public: \
+ Q_MANAGED_CHECK \
+ typedef QV4::Heap::DataClass Data; \
+ typedef superClass SuperClass; \
+ static const QV4::VTable static_vtbl; \
+ static inline const QV4::VTable *staticVTable() { return &static_vtbl; } \
+ V4_MANAGED_SIZE_TEST \
+ QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
+ QV4::Heap::DataClass *d() const { \
+ QV4::Heap::DataClass *dptr = d_unchecked(); \
+ dptr->_checkIsInitialized(); \
+ return dptr; \
+ } \
+ Q_STATIC_ASSERT(std::is_trivial< QV4::Heap::DataClass >::value);
+
+#define V4_PROTOTYPE(p) \
+ static QV4::Object *defaultPrototype(QV4::ExecutionEngine *e) \
+ { return e->p(); }
+
+
+#define DEFINE_OBJECT_VTABLE_BASE(classname) \
+ const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, (std::is_same<classname::SuperClass, Object>::value) ? nullptr : &classname::SuperClass::static_vtbl)
+
+#define DEFINE_OBJECT_VTABLE(classname) \
+DEFINE_OBJECT_VTABLE_BASE(classname)
+
+#define DEFINE_OBJECT_TEMPLATE_VTABLE(classname) \
+template<> DEFINE_OBJECT_VTABLE_BASE(classname)
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index 53933cd090..07af5a6f7a 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -54,7 +54,7 @@
#include <private/qv4global_p.h>
#include <private/qv4mmdefs_p.h>
#include <private/qv4writebarrier_p.h>
-#include <private/qv4internalclass_p.h>
+#include <private/qv4vtable_p.h>
#include <QSharedPointer>
// To check if Heap::Base::init is called (meaning, all subclasses did their init and called their
@@ -65,40 +65,43 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
-struct InternalClass;
+namespace Heap {
-struct VTable
-{
- const VTable * const parent;
- uint inlinePropertyOffset : 16;
- uint nInlineProperties : 16;
- uint isExecutionContext : 1;
- uint isString : 1;
- uint isObject : 1;
- uint isFunctionObject : 1;
- uint isErrorObject : 1;
- uint isArrayData : 1;
- uint unused : 18;
- uint type : 8;
- const char *className;
- void (*destroy)(Heap::Base *);
- void (*markObjects)(Heap::Base *, MarkStack *markStack);
- bool (*isEqualTo)(Managed *m, Managed *other);
-};
+template <typename T, size_t o>
+struct Pointer {
+ static Q_CONSTEXPR size_t offset = o;
+ T operator->() const { return get(); }
+ operator T () const { return get(); }
-namespace Heap {
+ Base *base();
+
+ void set(EngineBase *e, T newVal) {
+ WriteBarrier::write(e, base(), &ptr, reinterpret_cast<Base *>(newVal));
+ }
+
+ T get() const { return reinterpret_cast<T>(ptr); }
+
+ template <typename Type>
+ Type *cast() { return static_cast<Type *>(ptr); }
+
+ Base *heapObject() const { return ptr; }
+
+private:
+ Base *ptr;
+};
+typedef Pointer<char *, 0> V4PointerCheck;
+Q_STATIC_ASSERT(std::is_trivial< V4PointerCheck >::value);
struct Q_QML_EXPORT Base {
void *operator new(size_t) = delete;
- static void markObjects(Heap::Base *, MarkStack *) {}
+ static void markObjects(Base *, MarkStack *);
- InternalClass *internalClass;
+ Pointer<InternalClass *, 0> internalClass;
inline ReturnedValue asReturnedValue() const;
inline void mark(QV4::MarkStack *markStack);
- const VTable *vtable() const { return internalClass->vtable; }
inline bool isMarked() const {
const HeapItem *h = reinterpret_cast<const HeapItem *>(this);
Chunk *c = h->chunk();
@@ -125,13 +128,9 @@ struct Q_QML_EXPORT Base {
return Chunk::testBit(c->objectBitmap, h - c->realBase());
}
- inline void markChildren(MarkStack *markStack) {
- vtable()->markObjects(this, markStack);
- }
-
void *operator new(size_t, Managed *m) { return m; }
- void *operator new(size_t, Heap::Base *m) { return m; }
- void operator delete(void *, Heap::Base *) {}
+ void *operator new(size_t, Base *m) { return m; }
+ void operator delete(void *, Base *) {}
void init() { _setInitialized(); }
void destroy() { _setDestroyed(); }
@@ -178,10 +177,8 @@ Q_STATIC_ASSERT(std::is_standard_layout<Base>::value);
Q_STATIC_ASSERT(offsetof(Base, internalClass) == 0);
Q_STATIC_ASSERT(sizeof(Base) == QT_POINTER_SIZE);
-}
-
inline
-void Heap::Base::mark(QV4::MarkStack *markStack)
+void Base::mark(QV4::MarkStack *markStack)
{
Q_ASSERT(inUse());
const HeapItem *h = reinterpret_cast<const HeapItem *>(this);
@@ -196,36 +193,12 @@ void Heap::Base::mark(QV4::MarkStack *markStack)
}
}
-namespace Heap {
-
-template <typename T, size_t o>
-struct Pointer {
- static Q_CONSTEXPR size_t offset = o;
- T operator->() const { return get(); }
- operator T () const { return get(); }
-
- Heap::Base *base() {
- Heap::Base *base = reinterpret_cast<Heap::Base *>(this) - (offset/sizeof(Heap::Base));
- Q_ASSERT(base->inUse());
- return base;
- }
-
- void set(EngineBase *e, T newVal) {
- WriteBarrier::write(e, base(), &ptr, reinterpret_cast<Heap::Base *>(newVal));
- }
-
- T get() const { return reinterpret_cast<T>(ptr); }
-
- template <typename Type>
- Type *cast() { return static_cast<Type *>(ptr); }
-
- Heap::Base *heapObject() const { return ptr; }
-
-private:
- Heap::Base *ptr;
-};
-typedef Pointer<char *, 0> V4PointerCheck;
-Q_STATIC_ASSERT(std::is_trivial< V4PointerCheck >::value);
+template<typename T, size_t o>
+Base *Pointer<T, o>::base() {
+ Base *base = reinterpret_cast<Base *>(this) - (offset/sizeof(Base *));
+ Q_ASSERT(base->inUse());
+ return base;
+}
}
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 4e83abebdf..fb6d9478db 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -42,6 +42,7 @@
#include "qv4objectproto_p.h"
#include "qv4mm_p.h"
#include "qv4qobjectwrapper_p.h"
+#include "qv4identifiertable_p.h"
#include <QtCore/qalgorithms.h>
#include <QtCore/private/qnumeric_p.h>
#include <QtCore/qloggingcategory.h>
@@ -60,6 +61,8 @@
#include <algorithm>
#include "qv4alloca_p.h"
#include "qv4profiling_p.h"
+#include "qv4mapobject_p.h"
+#include "qv4setobject_p.h"
//#define MM_STATS
@@ -335,7 +338,7 @@ bool Chunk::sweep(ExecutionEngine *engine)
HeapItem *itemToFree = o + index;
Heap::Base *b = *itemToFree;
- const VTable *v = b->vtable();
+ const VTable *v = b->internalClass->vtable;
// if (Q_UNLIKELY(classCountPtr))
// classCountPtr(v->className);
if (v->destroy) {
@@ -389,8 +392,8 @@ void Chunk::freeAll(ExecutionEngine *engine)
HeapItem *itemToFree = o + index;
Heap::Base *b = *itemToFree;
- if (b->vtable()->destroy) {
- b->vtable()->destroy(b);
+ if (b->internalClass->vtable->destroy) {
+ b->internalClass->vtable->destroy(b);
b->_checkIsDestroyed();
}
#ifdef V4_USE_HEAPTRACK
@@ -412,10 +415,6 @@ void Chunk::resetBlackBits()
memset(blackBitmap, 0, sizeof(blackBitmap));
}
-#ifdef MM_STATS
-static uint nGrayItems = 0;
-#endif
-
void Chunk::collectGrayItems(MarkStack *markStack)
{
// DEBUG << "sweeping chunk" << this << (*freeList);
@@ -438,10 +437,6 @@ void Chunk::collectGrayItems(MarkStack *markStack)
Heap::Base *b = *itemToFree;
Q_ASSERT(b->inUse());
markStack->push(b);
-#ifdef MM_STATS
- ++nGrayItems;
-// qDebug() << "adding gray item" << b << "to mark stack";
-#endif
}
grayBitmap[i] = 0;
o += Chunk::Bits;
@@ -459,7 +454,7 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
#else
const int start = 1;
#endif
-#ifdef MM_STATS
+#ifndef QT_NO_DEBUG
uint freeSlots = 0;
uint allocatedSlots = 0;
#endif
@@ -469,7 +464,7 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
if (!i)
usedSlots |= (static_cast<quintptr>(1) << (HeaderSize/SlotSize)) - 1;
#endif
-#ifdef MM_STATS
+#ifndef QT_NO_DEBUG
allocatedSlots += qPopulationCount(usedSlots);
// qDebug() << hex << " i=" << i << "used=" << usedSlots;
#endif
@@ -486,7 +481,7 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
break;
}
usedSlots = (objectBitmap[i]|extendsBitmap[i]);
-#ifdef MM_STATS
+#ifndef QT_NO_DEBUG
allocatedSlots += qPopulationCount(usedSlots);
// qDebug() << hex << " i=" << i << "used=" << usedSlots;
#endif
@@ -497,7 +492,7 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
usedSlots |= (quintptr(1) << index) - 1;
uint freeEnd = i*Bits + index;
uint nSlots = freeEnd - freeStart;
-#ifdef MM_STATS
+#ifndef QT_NO_DEBUG
// qDebug() << hex << " got free slots from" << freeStart << "to" << freeEnd << "n=" << nSlots << "usedSlots=" << usedSlots;
freeSlots += nSlots;
#endif
@@ -508,7 +503,7 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins)
bins[bin] = freeItem;
}
}
-#ifdef MM_STATS
+#ifndef QT_NO_DEBUG
Q_ASSERT(freeSlots + allocatedSlots == (EntriesInBitmap - start) * 8 * sizeof(quintptr));
#endif
}
@@ -624,27 +619,30 @@ void BlockAllocator::sweep()
// qDebug() << "BlockAlloc: sweep";
usedSlotsAfterLastSweep = 0;
- auto isFree = [this] (Chunk *c) {
- bool isUsed = c->sweep(engine);
+ auto firstEmptyChunk = std::partition(chunks.begin(), chunks.end(), [this](Chunk *c) {
+ return c->sweep(engine);
+ });
- if (isUsed) {
- c->sortIntoBins(freeBins, NumBins);
- usedSlotsAfterLastSweep += c->nUsedSlots();
- } else {
- Q_V4_PROFILE_DEALLOC(engine, Chunk::DataSize, Profiling::HeapPage);
- chunkAllocator->free(c);
- }
- return !isUsed;
- };
+ std::for_each(chunks.begin(), firstEmptyChunk, [this](Chunk *c) {
+ c->sortIntoBins(freeBins, NumBins);
+ usedSlotsAfterLastSweep += c->nUsedSlots();
+ });
- auto newEnd = std::remove_if(chunks.begin(), chunks.end(), isFree);
- chunks.erase(newEnd, chunks.end());
+ // only free the chunks at the end to avoid that the sweep() calls indirectly
+ // access freed memory
+ std::for_each(firstEmptyChunk, chunks.end(), [this](Chunk *c) {
+ Q_V4_PROFILE_DEALLOC(engine, Chunk::DataSize, Profiling::HeapPage);
+ chunkAllocator->free(c);
+ });
+
+ chunks.erase(firstEmptyChunk, chunks.end());
}
void BlockAllocator::freeAll()
{
- for (auto c : chunks) {
+ for (auto c : chunks)
c->freeAll(engine);
+ for (auto c : chunks) {
Q_V4_PROFILE_DEALLOC(engine, Chunk::DataSize, Profiling::HeapPage);
chunkAllocator->free(c);
}
@@ -691,7 +689,7 @@ static void freeHugeChunk(ChunkAllocator *chunkAllocator, const HugeItemAllocato
{
HeapItem *itemToFree = c.chunk->first();
Heap::Base *b = *itemToFree;
- const VTable *v = b->vtable();
+ const VTable *v = b->internalClass->vtable;
if (Q_UNLIKELY(classCountPtr))
classCountPtr(v->className);
@@ -758,6 +756,7 @@ MemoryManager::MemoryManager(ExecutionEngine *engine)
: engine(engine)
, chunkAllocator(new ChunkAllocator)
, blockAllocator(chunkAllocator, engine)
+ , icAllocator(chunkAllocator, engine)
, hugeItemAllocator(chunkAllocator, engine)
, m_persistentValues(new PersistentValueStorage(engine))
, m_weakValues(new PersistentValueStorage(engine))
@@ -774,11 +773,6 @@ MemoryManager::MemoryManager(ExecutionEngine *engine)
blockAllocator.allocationStats = statistics.allocations;
}
-#ifdef MM_STATS
-static int allocationCount = 0;
-static size_t lastAllocRequestedSlots = 0;
-#endif
-
Heap::Base *MemoryManager::allocString(std::size_t unmanagedSize)
{
const size_t stringSize = align(sizeof(Heap::String));
@@ -884,7 +878,7 @@ Heap::Object *MemoryManager::allocObjectWithMemberData(const QV4::VTable *vtable
Chunk::clearBit(c->extendsBitmap, index);
}
o->memberData.set(engine, m);
- m->internalClass = engine->internalClasses[EngineBase::Class_MemberData];
+ m->internalClass.set(engine, engine->internalClasses(EngineBase::Class_MemberData));
Q_ASSERT(o->memberData->internalClass);
m->values.alloc = static_cast<uint>((memberSize - sizeof(Heap::MemberData) + sizeof(Value))/sizeof(Value));
m->values.size = o->memberData->values.alloc;
@@ -911,7 +905,7 @@ void MarkStack::drain()
Heap::Base *h = pop();
++markStackSize;
Q_ASSERT(h); // at this point we should only have Heap::Base objects in this area on the stack. If not, weird things might happen.
- h->markChildren(this);
+ h->internalClass->vtable->markObjects(h, this);
}
}
@@ -981,7 +975,30 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
if (QObjectWrapper *qobjectWrapper = (*it).as<QObjectWrapper>())
qobjectWrapper->destroyObject(lastSweep);
- (*it) = Primitive::undefinedValue();
+ (*it) = Value::undefinedValue();
+ }
+
+ // remove objects from weak maps and sets
+ Heap::MapObject *map = weakMaps;
+ Heap::MapObject **lastMap = &weakMaps;
+ while (map) {
+ if (map->isMarked()) {
+ map->removeUnmarkedKeys();
+ *lastMap = map;
+ lastMap = &map->nextWeakMap;
+ }
+ map = map->nextWeakMap;
+ }
+
+ Heap::SetObject *set = weakSets;
+ Heap::SetObject **lastSet = &weakSets;
+ while (set) {
+ if (set->isMarked()) {
+ set->removeUnmarkedKeys();
+ *lastSet = set;
+ lastSet = &set->nextWeakSet;
+ }
+ set = set->nextWeakSet;
}
// onDestruction handlers may have accessed other QObject wrappers and reset their value, so ensure
@@ -990,7 +1007,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
Managed *m = (*it).managed();
if (!m || m->markBit())
continue;
- (*it) = Primitive::undefinedValue();
+ (*it) = Value::undefinedValue();
}
// Now it is time to free QV4::QObjectWrapper Value, we must check the Value's tag to make sure its object has been destroyed
@@ -1017,13 +1034,18 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
}
}
- blockAllocator.sweep();
- hugeItemAllocator.sweep(classCountPtr);
+
+ if (!lastSweep) {
+ engine->identifierTable->sweep();
+ blockAllocator.sweep(/*classCountPtr*/);
+ hugeItemAllocator.sweep(classCountPtr);
+ icAllocator.sweep(/*classCountPtr*/);
+ }
}
bool MemoryManager::shouldRunGC() const
{
- size_t total = blockAllocator.totalSlots();
+ size_t total = blockAllocator.totalSlots() + icAllocator.totalSlots();
if (total > MinSlotsGCLimit && usedSlotsAfterLastFullSweep * GCOverallocation < total * 100)
return true;
return false;
@@ -1096,10 +1118,6 @@ void MemoryManager::runGC()
qDebug(stats) << "Fragmented memory before GC" << (totalMem - usedBefore);
dumpBins(&blockAllocator);
-#ifdef MM_STATS
- nGrayItems = 0;
-#endif
-
QElapsedTimer t;
t.start();
mark();
@@ -1159,24 +1177,26 @@ void MemoryManager::runGC()
if (aggressiveGC) {
// ensure we don't 'loose' any memory
- Q_ASSERT(blockAllocator.allocatedMem() == getUsedMem() + dumpBins(&blockAllocator, false));
+ Q_ASSERT(blockAllocator.allocatedMem()
+ == blockAllocator.usedMem() + dumpBins(&blockAllocator, false));
}
- usedSlotsAfterLastFullSweep = blockAllocator.usedSlotsAfterLastSweep;
+ usedSlotsAfterLastFullSweep = blockAllocator.usedSlotsAfterLastSweep + icAllocator.usedSlotsAfterLastSweep;
// reset all black bits
blockAllocator.resetBlackBits();
hugeItemAllocator.resetBlackBits();
+ icAllocator.resetBlackBits();
}
size_t MemoryManager::getUsedMem() const
{
- return blockAllocator.usedMem();
+ return blockAllocator.usedMem() + icAllocator.usedMem();
}
size_t MemoryManager::getAllocatedMem() const
{
- return blockAllocator.allocatedMem() + hugeItemAllocator.usedMem();
+ return blockAllocator.allocatedMem() + icAllocator.allocatedMem() + hugeItemAllocator.usedMem();
}
size_t MemoryManager::getLargeItemsMem() const
@@ -1184,6 +1204,18 @@ size_t MemoryManager::getLargeItemsMem() const
return hugeItemAllocator.usedMem();
}
+void MemoryManager::registerWeakMap(Heap::MapObject *map)
+{
+ map->nextWeakMap = weakMaps;
+ weakMaps = map;
+}
+
+void MemoryManager::registerWeakSet(Heap::SetObject *set)
+{
+ set->nextWeakSet = weakSets;
+ weakSets = set;
+}
+
MemoryManager::~MemoryManager()
{
delete m_persistentValues;
@@ -1193,6 +1225,7 @@ MemoryManager::~MemoryManager()
sweep(/*lastSweep*/true);
blockAllocator.freeAll();
hugeItemAllocator.freeAll();
+ icAllocator.freeAll();
delete m_weakValues;
#ifdef V4_USE_VALGRIND
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 40670bcdc7..bbbbb1aef6 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -160,224 +160,98 @@ public:
{ return (size + Chunk::SlotSize - 1) & ~(Chunk::SlotSize - 1); }
template<typename ManagedType>
- inline typename ManagedType::Data *allocManaged(std::size_t size)
+ inline typename ManagedType::Data *allocManaged(std::size_t size, Heap::InternalClass *ic)
{
Q_STATIC_ASSERT(std::is_trivial< typename ManagedType::Data >::value);
size = align(size);
- Heap::Base *o = allocData(size);
- InternalClass *ic = ManagedType::defaultInternalClass(engine);
- ic = ic->changeVTable(ManagedType::staticVTable());
- o->internalClass = ic;
- Q_ASSERT(o->internalClass && o->internalClass->vtable);
- return static_cast<typename ManagedType::Data *>(o);
+ typename ManagedType::Data *d = static_cast<typename ManagedType::Data *>(allocData(size));
+ d->internalClass.set(engine, ic);
+ Q_ASSERT(d->internalClass && d->internalClass->vtable);
+ Q_ASSERT(ic->vtable == ManagedType::staticVTable());
+ return d;
}
template<typename ManagedType>
inline typename ManagedType::Data *allocManaged(std::size_t size, InternalClass *ic)
{
- Q_STATIC_ASSERT(std::is_trivial< typename ManagedType::Data >::value);
- size = align(size);
- Heap::Base *o = allocData(size);
- o->internalClass = ic;
- Q_ASSERT(o->internalClass && o->internalClass->vtable);
- Q_ASSERT(ic->vtable == ManagedType::staticVTable());
- return static_cast<typename ManagedType::Data *>(o);
+ return allocManaged<ManagedType>(size, ic->d());
+ }
+
+ template<typename ManagedType>
+ inline typename ManagedType::Data *allocManaged(std::size_t size)
+ {
+ Scope scope(engine);
+ Scoped<InternalClass> ic(scope, ManagedType::defaultInternalClass(engine));
+ return allocManaged<ManagedType>(size, ic);
}
template <typename ObjectType>
- typename ObjectType::Data *allocateObject(InternalClass *ic)
+ typename ObjectType::Data *allocateObject(Heap::InternalClass *ic)
{
Heap::Object *o = allocObjectWithMemberData(ObjectType::staticVTable(), ic->size);
- o->internalClass = ic;
- Q_ASSERT(o->internalClass && o->internalClass->vtable);
- Q_ASSERT(ic->vtable == ObjectType::staticVTable());
+ o->internalClass.set(engine, ic);
+ Q_ASSERT(o->internalClass.get() && o->vtable());
+ Q_ASSERT(o->vtable() == ObjectType::staticVTable());
return static_cast<typename ObjectType::Data *>(o);
}
template <typename ObjectType>
+ typename ObjectType::Data *allocateObject(InternalClass *ic)
+ {
+ return allocateObject<ObjectType>(ic->d());
+ }
+
+ template <typename ObjectType>
typename ObjectType::Data *allocateObject()
{
- InternalClass *ic = ObjectType::defaultInternalClass(engine);
+ Scope scope(engine);
+ Scoped<InternalClass> ic(scope, ObjectType::defaultInternalClass(engine));
ic = ic->changeVTable(ObjectType::staticVTable());
ic = ic->changePrototype(ObjectType::defaultPrototype(engine)->d());
- Heap::Object *o = allocObjectWithMemberData(ObjectType::staticVTable(), ic->size);
- o->internalClass = ic;
- Q_ASSERT(o->internalClass && o->internalClass->vtable);
- Q_ASSERT(o->internalClass->prototype == ObjectType::defaultPrototype(engine)->d());
- return static_cast<typename ObjectType::Data *>(o);
+ return allocateObject<ObjectType>(ic);
}
template <typename ManagedType, typename Arg1>
typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 arg1)
{
typename ManagedType::Data *o = reinterpret_cast<typename ManagedType::Data *>(allocString(unmanagedSize));
- o->internalClass = ManagedType::defaultInternalClass(engine);
+ o->internalClass.set(engine, ManagedType::defaultInternalClass(engine));
Q_ASSERT(o->internalClass && o->internalClass->vtable);
o->init(arg1);
return o;
}
- template <typename ObjectType>
- typename ObjectType::Data *allocObject(InternalClass *ic)
+ template <typename ObjectType, typename... Args>
+ typename ObjectType::Data *allocObject(Heap::InternalClass *ic, Args... args)
{
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- t->d_unchecked()->init();
- return t->d();
+ typename ObjectType::Data *d = allocateObject<ObjectType>(ic);
+ d->init(args...);
+ return d;
}
- template <typename ObjectType>
- typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype)
+ template <typename ObjectType, typename... Args>
+ typename ObjectType::Data *allocObject(InternalClass *ic, Args... args)
{
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr));
- Q_UNUSED(prototype);
- t->d_unchecked()->init();
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1>
- typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr));
- Q_UNUSED(prototype);
- t->d_unchecked()->init(arg1);
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1, typename Arg2>
- typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1, Arg2 arg2)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr));
- Q_UNUSED(prototype);
- t->d_unchecked()->init(arg1, arg2);
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1, typename Arg2, typename Arg3>
- typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1, Arg2 arg2, Arg3 arg3)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr));
- Q_UNUSED(prototype);
- t->d_unchecked()->init(arg1, arg2, arg3);
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
- Q_ASSERT(t->internalClass()->prototype == (prototype ? prototype->d() : nullptr));
- Q_UNUSED(prototype);
- t->d_unchecked()->init(arg1, arg2, arg3, arg4);
- return t->d();
- }
-
- template <typename ObjectType>
- typename ObjectType::Data *allocObject()
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- t->d_unchecked()->init();
- return t->d();
+ typename ObjectType::Data *d = allocateObject<ObjectType>(ic);
+ d->init(args...);
+ return d;
}
- template <typename ObjectType, typename Arg1>
- typename ObjectType::Data *allocObject(Arg1 arg1)
+ template <typename ObjectType, typename... Args>
+ typename ObjectType::Data *allocate(Args... args)
{
Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- t->d_unchecked()->init(arg1);
+ t->d_unchecked()->init(args...);
return t->d();
}
- template <typename ObjectType, typename Arg1, typename Arg2>
- typename ObjectType::Data *allocObject(Arg1 arg1, Arg2 arg2)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- t->d_unchecked()->init(arg1, arg2);
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1, typename Arg2, typename Arg3>
- typename ObjectType::Data *allocObject(Arg1 arg1, Arg2 arg2, Arg3 arg3)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- t->d_unchecked()->init(arg1, arg2, arg3);
- return t->d();
- }
-
- template <typename ObjectType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- typename ObjectType::Data *allocObject(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
- {
- Scope scope(engine);
- Scoped<ObjectType> t(scope, allocateObject<ObjectType>());
- t->d_unchecked()->init(arg1, arg2, arg3, arg4);
- return t->d();
- }
-
-
- template <typename ManagedType>
- typename ManagedType::Data *alloc()
- {
- Scope scope(engine);
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init();
- return t->d();
- }
-
- template <typename ManagedType, typename Arg1>
- typename ManagedType::Data *alloc(Arg1 arg1)
- {
- Scope scope(engine);
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init(arg1);
- return t->d();
- }
-
- template <typename ManagedType, typename Arg1, typename Arg2>
- typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2)
- {
- Scope scope(engine);
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init(arg1, arg2);
- return t->d();
- }
-
- template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3>
- typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3)
- {
- Scope scope(engine);
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init(arg1, arg2, arg3);
- return t->d();
- }
-
- template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
- {
- Scope scope(engine);
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init(arg1, arg2, arg3, arg4);
- return t->d();
- }
-
- template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
- typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
+ template <typename ManagedType, typename... Args>
+ typename ManagedType::Data *alloc(Args... args)
{
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- t->d_unchecked()->init(arg1, arg2, arg3, arg4, arg5);
+ t->d_unchecked()->init(args...);
return t->d();
}
@@ -392,6 +266,17 @@ public:
// called when a JS object grows itself. Specifically: Heap::String::append
void changeUnmanagedHeapSizeUsage(qptrdiff delta) { unmanagedHeapSize += delta; }
+ template<typename ManagedType>
+ typename ManagedType::Data *allocIC()
+ {
+ size_t size = align(sizeof(typename ManagedType::Data));
+ Heap::Base *b = *icAllocator.allocate(size, true);
+ return static_cast<typename ManagedType::Data *>(b);
+ }
+
+ void registerWeakMap(Heap::MapObject *map);
+ void registerWeakSet(Heap::SetObject *set);
+
protected:
/// expects size to be aligned
Heap::Base *allocString(std::size_t unmanagedSize);
@@ -409,10 +294,13 @@ public:
QV4::ExecutionEngine *engine;
ChunkAllocator *chunkAllocator;
BlockAllocator blockAllocator;
+ BlockAllocator icAllocator;
HugeItemAllocator hugeItemAllocator;
PersistentValueStorage *m_persistentValues;
PersistentValueStorage *m_weakValues;
QVector<Value *> m_pendingFreedObjectWrapperValue;
+ Heap::MapObject *weakMaps = nullptr;
+ Heap::SetObject *weakSets = nullptr;
std::size_t unmanagedHeapSize = 0; // the amount of bytes of heap that is not managed by the memory manager, but which is held onto by managed items.
std::size_t unmanagedHeapSizeGCLimit;
@@ -423,6 +311,9 @@ public:
bool gcStats = false;
bool gcCollectorStats = false;
+ int allocationCount = 0;
+ size_t lastAllocRequestedSlots = 0;
+
struct {
size_t maxReservedMem = 0;
size_t maxAllocatedMem = 0;
diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri
index e5b8ae2749..adab4ef9a2 100644
--- a/src/qml/parser/parser.pri
+++ b/src/qml/parser/parser.pri
@@ -3,20 +3,24 @@ HEADERS += \
$$PWD/qqmljsastfwd_p.h \
$$PWD/qqmljsastvisitor_p.h \
$$PWD/qqmljsengine_p.h \
- $$PWD/qqmljsgrammar_p.h \
$$PWD/qqmljslexer_p.h \
$$PWD/qqmljsmemorypool_p.h \
- $$PWD/qqmljsparser_p.h \
$$PWD/qqmljsglobal_p.h \
$$PWD/qqmljskeywords_p.h \
+ $$PWD/qqmljsengine_p.h \
+ $$PWD/qqmljsglobal_p.h
SOURCES += \
$$PWD/qqmljsast.cpp \
$$PWD/qqmljsastvisitor.cpp \
$$PWD/qqmljsengine_p.cpp \
- $$PWD/qqmljsgrammar.cpp \
$$PWD/qqmljslexer.cpp \
- $$PWD/qqmljsparser.cpp \
-OTHER_FILES += \
- $$PWD/qqmljs.g
+CONFIG += qlalr
+QLALRSOURCES = $$PWD/qqmljs.g
+QMAKE_QLALRFLAGS = --no-debug --qt
+
+OTHER_FILES += $$QLALRSOURCES
+
+# make sure we install the headers generated by qlalr
+private_headers.CONFIG += no_check_exist
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index d2d947e55c..a844e3cb3e 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -40,8 +40,7 @@
%parser QQmlJSGrammar
%decl qqmljsparser_p.h
%impl qqmljsparser.cpp
-%expect 5
-%expect-rr 2
+%expect 1
%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&="
%token T_BREAK "break" T_CASE "case" T_CATCH "catch"
@@ -64,7 +63,8 @@
%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%"
%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")"
%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*"
-%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal"
+%token T_STAR_STAR "**" T_STAR_STAR_EQ "**=" T_STAR_EQ "*="
+%token T_STRING_LITERAL "string literal"
%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly"
%token T_SWITCH "switch" T_THIS "this" T_THROW "throw"
%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof"
@@ -77,14 +77,29 @@
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
%token T_COMMENT "comment"
%token T_COMPATIBILITY_SEMICOLON
+%token T_ARROW "=>"
%token T_ENUM "enum"
+%token T_ELLIPSIS "..."
+%token T_YIELD "yield"
+%token T_SUPER "super"
+%token T_CLASS "class"
+%token T_EXTENDS "extends"
+%token T_STATIC "static"
+%token T_EXPORT "export"
+%token T_FROM "from"
+
+--- template strings
+%token T_NO_SUBSTITUTION_TEMPLATE"(no subst template)"
+%token T_TEMPLATE_HEAD "(template head)"
+%token T_TEMPLATE_MIDDLE "(template middle)"
+%token T_TEMPLATE_TAIL "(template tail)"
--- context keywords.
%token T_PUBLIC "public"
%token T_IMPORT "import"
%token T_PRAGMA "pragma"
%token T_AS "as"
-%token T_ON "on"
+%token T_OF "of"
%token T_GET "get"
%token T_SET "set"
@@ -95,11 +110,16 @@
%token T_FEED_UI_OBJECT_MEMBER
%token T_FEED_JS_STATEMENT
%token T_FEED_JS_EXPRESSION
-%token T_FEED_JS_SOURCE_ELEMENT
-%token T_FEED_JS_PROGRAM
+%token T_FEED_JS_SCRIPT
+%token T_FEED_JS_MODULE
-%nonassoc SHIFT_THERE
-%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET
+--- Lookahead handling
+%token T_FORCE_DECLARATION "(force decl)"
+%token T_FORCE_BLOCK "(force block)"
+%token T_FOR_LOOKAHEAD_OK "(for lookahead ok)"
+
+--%left T_PLUS T_MINUS
+%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM T_AS
%nonassoc REDUCE_HERE
%start TopLevel
@@ -143,10 +163,10 @@
**
****************************************************************************/
-#include "qqmljsengine_p.h"
-#include "qqmljslexer_p.h"
-#include "qqmljsast_p.h"
-#include "qqmljsmemorypool_p.h"
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsmemorypool_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreapplication.h>
@@ -221,10 +241,10 @@
#ifndef QQMLJSPARSER_P_H
#define QQMLJSPARSER_P_H
-#include "qqmljsglobal_p.h"
-#include "qqmljsgrammar_p.h"
-#include "qqmljsast_p.h"
-#include "qqmljsengine_p.h"
+#include <private/qqmljsglobal_p.h>
+#include <private/qqmljsgrammar_p.h>
+#include <private/qqmljsast_p.h>
+#include <private/qqmljsengine_p.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
@@ -241,30 +261,42 @@ public:
union Value {
int ival;
double dval;
+ AST::VariableScope scope;
+ AST::ForEachType forEachType;
AST::ArgumentList *ArgumentList;
AST::CaseBlock *CaseBlock;
AST::CaseClause *CaseClause;
AST::CaseClauses *CaseClauses;
AST::Catch *Catch;
AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
AST::Elision *Elision;
AST::ExpressionNode *Expression;
+ AST::TemplateLiteral *Template;
AST::Finally *Finally;
AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
AST::FunctionDeclaration *FunctionDeclaration;
AST::Node *Node;
AST::PropertyName *PropertyName;
- AST::PropertyAssignment *PropertyAssignment;
- AST::PropertyAssignmentList *PropertyAssignmentList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
AST::Statement *Statement;
AST::StatementList *StatementList;
AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
AST::VariableDeclarationList *VariableDeclarationList;
+ AST::Pattern *Pattern;
+ AST::PatternElement *PatternElement;
+ AST::PatternElementList *PatternElementList;
+ AST::PatternProperty *PatternProperty;
+ AST::PatternPropertyList *PatternPropertyList;
+ AST::ClassElementList *ClassElementList;
+ AST::ImportClause *ImportClause;
+ AST::FromClause *FromClause;
+ AST::NameSpaceImport *NameSpaceImport;
+ AST::ImportsList *ImportsList;
+ AST::NamedImports *NamedImports;
+ AST::ImportSpecifier *ImportSpecifier;
+ AST::ExportSpecifier *ExportSpecifier;
+ AST::ExportsList *ExportsList;
+ AST::ExportClause *ExportClause;
+ AST::ExportDeclaration *ExportDeclaration;
AST::UiProgram *UiProgram;
AST::UiHeaderItemList *UiHeaderItemList;
@@ -281,7 +313,6 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
- AST::UiQualifiedPragmaId *UiQualifiedPragmaId;
AST::UiEnumMemberList *UiEnumMemberList;
};
@@ -290,12 +321,13 @@ public:
~Parser();
// parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parse() { ++functionNestingLevel; bool r = parse(T_FEED_UI_PROGRAM); --functionNestingLevel; return r; }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
+ bool parseUiObjectMember() { ++functionNestingLevel; bool r = parse(T_FEED_UI_OBJECT_MEMBER); --functionNestingLevel; return r; }
+ bool parseProgram() { return parse(T_FEED_JS_SCRIPT); }
+ bool parseScript() { return parse(T_FEED_JS_SCRIPT); }
+ bool parseModule() { return parse(T_FEED_JS_MODULE); }
AST::UiProgram *ast() const
{ return AST::cast<AST::UiProgram *>(program); }
@@ -364,22 +396,31 @@ protected:
{ return location_stack [tos + index - 1]; }
AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
- AST::UiQualifiedPragmaId *reparseAsQualifiedPragmaId(AST::ExpressionNode *expr);
+
+ void pushToken(int token);
+ int lookaheadToken(Lexer *lexer);
+
+ void syntaxError(const AST::SourceLocation &location, const char *message) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location, QLatin1String(message)));
+ }
+ void syntaxError(const AST::SourceLocation &location, const QString &message) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location, message));
+ }
protected:
Engine *driver;
MemoryPool *pool;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
- QStringRef *string_stack;
+ int tos = 0;
+ int stack_size = 0;
+ Value *sym_stack = nullptr;
+ int *state_stack = nullptr;
+ AST::SourceLocation *location_stack = nullptr;
+ QVector<QStringRef> string_stack;
- AST::Node *program;
+ AST::Node *program = nullptr;
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
+ // error recovery and lookahead handling
+ enum { TOKEN_BUFFER_SIZE = 5 };
struct SavedToken {
int token;
@@ -388,14 +429,25 @@ protected:
QStringRef spell;
};
- double yylval;
+ int yytoken = -1;
+ double yylval = 0.;
QStringRef yytokenspell;
AST::SourceLocation yylloc;
AST::SourceLocation yyprevlloc;
SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
+ SavedToken *first_token = nullptr;
+ SavedToken *last_token = nullptr;
+
+ int functionNestingLevel = 0;
+
+ enum CoverExpressionType {
+ CE_Invalid,
+ CE_ParenthesizedExpression,
+ CE_FormalParameterList
+ };
+ AST::SourceLocation coverExpressionErrorLocation;
+ CoverExpressionType coverExpressionType = CE_Invalid;
QList<DiagnosticMessage> diagnostic_messages;
};
@@ -424,6 +476,8 @@ protected:
// qlalr --no-debug --no-lines --qt qqmljs.g
//
+#define UNIMPLEMENTED syntaxError(loc(1), "Unimplemented"); return false
+
using namespace QQmlJS;
QT_QML_BEGIN_NAMESPACE
@@ -438,22 +492,12 @@ void Parser::reallocateStack()
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
- string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
+ string_stack.resize(stack_size);
}
Parser::Parser(Engine *engine):
driver(engine),
- pool(engine->pool()),
- tos(0),
- stack_size(0),
- sym_stack(0),
- state_stack(0),
- location_stack(0),
- string_stack(0),
- program(0),
- yylval(0),
- first_token(0),
- last_token(0)
+ pool(engine->pool())
{
}
@@ -463,7 +507,6 @@ Parser::~Parser()
free(sym_stack);
free(state_stack);
free(location_stack);
- free(string_stack);
}
}
@@ -505,29 +548,39 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
return 0;
}
-AST::UiQualifiedPragmaId *Parser::reparseAsQualifiedPragmaId(AST::ExpressionNode *expr)
+void Parser::pushToken(int token)
{
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(expr)) {
- AST::UiQualifiedPragmaId *q = new (pool) AST::UiQualifiedPragmaId(idExpr->name);
- q->identifierToken = idExpr->identifierToken;
+ last_token->token = yytoken;
+ last_token->dval = yylval;
+ last_token->spell = yytokenspell;
+ last_token->loc = yylloc;
+ ++last_token;
+ yytoken = token;
+}
- return q->finish();
+int Parser::lookaheadToken(Lexer *lexer)
+{
+ if (yytoken < 0) {
+ yytoken = lexer->lex();
+ yylval = lexer->tokenValue();
+ yytokenspell = lexer->tokenSpell();
+ yylloc = location(lexer);
}
-
- return 0;
+ return yytoken;
}
+//#define PARSER_DEBUG
bool Parser::parse(int startToken)
{
Lexer *lexer = driver->lexer();
bool hadErrors = false;
- int yytoken = -1;
+ yytoken = -1;
int action = 0;
token_buffer[0].token = startToken;
first_token = &token_buffer[0];
- if (startToken == T_FEED_JS_PROGRAM && !lexer->qmlMode()) {
+ if (startToken == T_FEED_JS_SCRIPT && !lexer->qmlMode()) {
Directives ignoreDirectives;
Directives *directives = driver->directives();
if (!directives)
@@ -570,10 +623,19 @@ bool Parser::parse(int startToken)
yytokenspell = first_token->spell;
yylloc = first_token->loc;
++first_token;
+ if (first_token == last_token)
+ first_token = last_token = &token_buffer[0];
}
}
+#ifdef PARSER_DEBUG
+ qDebug() << " in state" << action;
+#endif
+
action = t_action(action, yytoken);
+#ifdef PARSER_DEBUG
+ qDebug() << " current token" << yytoken << (yytoken >= 0 ? spell[yytoken] : "(null)") << "new state" << action;
+#endif
if (action > 0) {
if (action != ACCEPT_STATE) {
yytoken = -1;
@@ -588,6 +650,10 @@ bool Parser::parse(int startToken)
const int r = -action - 1;
tos -= rhs[r];
+#ifdef PARSER_DEBUG
+ qDebug() << " reducing through rule " << -action;
+#endif
+
switch (r) {
./
@@ -595,2582 +661,3693 @@ bool Parser::parse(int startToken)
-- Declarative UI
--------------------------------------------------------------------------------------------------------
-TopLevel: T_FEED_UI_PROGRAM UiProgram ;
+TopLevel: T_FEED_UI_PROGRAM UiProgram;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
-TopLevel: T_FEED_JS_STATEMENT Statement ;
+TopLevel: T_FEED_JS_STATEMENT Statement;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
-TopLevel: T_FEED_JS_EXPRESSION Expression ;
+TopLevel: T_FEED_JS_EXPRESSION Expression;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
-TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ;
+TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
-TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
+TopLevel: T_FEED_JS_SCRIPT Script;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
-TopLevel: T_FEED_JS_PROGRAM Program ;
+TopLevel: T_FEED_JS_MODULE Module;
/.
-case $rule_number: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+ } break;
./
+
UiProgram: UiHeaderItemListOpt UiRootMember;
/.
-case $rule_number: {
- sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiHeaderItemList,
- sym(2).UiObjectMemberList->finish());
-} break;
+ case $rule_number: {
+ sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiHeaderItemList, sym(2).UiObjectMemberList->finish());
+ } break;
./
-UiHeaderItemListOpt: Empty ;
-UiHeaderItemListOpt: UiHeaderItemList ;
+UiHeaderItemListOpt: Empty;
+UiHeaderItemListOpt: UiHeaderItemList;
/.
-case $rule_number: {
- sym(1).Node = sym(1).UiHeaderItemList->finish();
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).UiHeaderItemList->finish();
+ } break;
./
-UiHeaderItemList: UiPragma ;
+UiHeaderItemList: UiPragma;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiPragma);
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiPragma);
+ } break;
./
-UiHeaderItemList: UiImport ;
+UiHeaderItemList: UiImport;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiImport);
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiImport);
+ } break;
./
-UiHeaderItemList: UiHeaderItemList UiPragma ;
+UiHeaderItemList: UiHeaderItemList UiPragma;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiPragma);
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiPragma);
+ } break;
./
-UiHeaderItemList: UiHeaderItemList UiImport ;
+UiHeaderItemList: UiHeaderItemList UiImport;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiImport);
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiImport);
+ } break;
./
-PragmaId: MemberExpression ;
-
-ImportId: MemberExpression ;
+PragmaId: JsIdentifier;
-UiPragma: UiPragmaHead T_AUTOMATIC_SEMICOLON ;
-UiPragma: UiPragmaHead T_SEMICOLON ;
+UiPragma: T_PRAGMA PragmaId T_AUTOMATIC_SEMICOLON;
+UiPragma: T_PRAGMA PragmaId T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).UiPragma->semicolonToken = loc(2);
-} break;
+ case $rule_number: {
+ AST::UiPragma *pragma = new (pool) AST::UiPragma(stringRef(2));
+ pragma->pragmaToken = loc(1);
+ pragma->semicolonToken = loc(3);
+ sym(1).Node = pragma;
+ } break;
./
-UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_SEMICOLON ;
+ImportId: MemberExpression;
+
+UiImport: UiImportHead T_AUTOMATIC_SEMICOLON;
+UiImport: UiImportHead T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
+ case $rule_number: {
+ sym(1).UiImport->semicolonToken = loc(2);
+ } break;
./
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
+ case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->semicolonToken = loc(3);
+ } break;
./
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiImport: UiImportHead T_NUMERIC_LITERAL T_AS QmlIdentifier T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = stringRef(4);
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
+ case $rule_number: {
+ sym(1).UiImport->versionToken = loc(2);
+ sym(1).UiImport->asToken = loc(3);
+ sym(1).UiImport->importIdToken = loc(4);
+ sym(1).UiImport->importId = stringRef(4);
+ sym(1).UiImport->semicolonToken = loc(5);
+ } break;
./
-UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ;
+UiImport: UiImportHead T_AS QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiImport: UiImportHead T_AS QmlIdentifier T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = stringRef(3);
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
+ case $rule_number: {
+ sym(1).UiImport->asToken = loc(2);
+ sym(1).UiImport->importIdToken = loc(3);
+ sym(1).UiImport->importId = stringRef(3);
+ sym(1).UiImport->semicolonToken = loc(4);
+ } break;
./
-UiPragmaHead: T_PRAGMA PragmaId ;
+UiImportHead: T_IMPORT ImportId;
/.
-case $rule_number: {
- AST::UiPragma *node = 0;
+ case $rule_number: {
+ AST::UiImport *node = 0;
- if (AST::UiQualifiedPragmaId *qualifiedId = reparseAsQualifiedPragmaId(sym(2).Expression)) {
- node = new (pool) AST::UiPragma(qualifiedId);
- }
+ if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(importIdLiteral->value);
+ node->fileNameToken = loc(2);
+ } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
+ node = new (pool) AST::UiImport(qualifiedId);
+ node->fileNameToken = loc(2);
+ }
- sym(1).Node = node;
+ sym(1).Node = node;
- if (node) {
- node->pragmaToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
+ if (node) {
+ node->importToken = loc(1);
+ } else {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id or a string literal")));
- return false; // ### remove me
- }
-} break;
+ return false; // ### remove me
+ }
+ } break;
./
+Empty: ;
+/.
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
+./
-UiImportHead: T_IMPORT ImportId ;
+UiRootMember: UiObjectDefinition;
/.
-case $rule_number: {
- AST::UiImport *node = 0;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = new (pool) AST::UiImport(importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- node = new (pool) AST::UiImport(qualifiedId);
- node->fileNameToken = loc(2);
- }
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+ } break;
+./
- sym(1).Node = node;
+UiObjectMemberList: UiObjectMember;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
+ } break;
+./
- if (node) {
- node->importToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
+UiObjectMemberList: UiObjectMemberList UiObjectMember;
+/.
+ case $rule_number: {
+ AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(sym(1).UiObjectMemberList, sym(2).UiObjectMember);
+ sym(1).Node = node;
+ } break;
+./
- return false; // ### remove me
- }
-} break;
+UiArrayMemberList: UiObjectDefinition;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
+ } break;
./
-Empty: ;
+UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(sym(1).UiArrayMemberList, sym(3).UiObjectMember);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UiRootMember: UiObjectDefinition ;
+UiObjectInitializer: T_LBRACE T_RBRACE;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
+ case $rule_number: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMemberList: UiObjectMember ;
+UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
+ case $rule_number: {
+ AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMemberList: UiObjectMemberList UiObjectMember ;
+UiObjectDefinition: UiQualifiedId UiObjectInitializer;
/.
-case $rule_number: {
- AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+ } break;
./
-UiArrayMemberList: UiObjectDefinition ;
+UiObjectMember: UiObjectDefinition;
+
+UiObjectMember: UiQualifiedId T_COLON ExpressionStatementLookahead T_LBRACKET UiArrayMemberList T_RBRACKET;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
-} break;
+ case $rule_number: {
+ AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(sym(1).UiQualifiedId, sym(5).UiArrayMemberList->finish());
+ node->colonToken = loc(2);
+ node->lbracketToken = loc(4);
+ node->rbracketToken = loc(6);
+ sym(1).Node = node;
+ } break;
./
-UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ;
+UiObjectMember: UiQualifiedId T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer;
/.
-case $rule_number: {
- AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(1).UiQualifiedId, sym(4).UiQualifiedId, sym(5).UiObjectInitializer);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UiObjectInitializer: T_LBRACE T_RBRACE ;
+UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer;
/.
-case $rule_number: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
+ sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ node->hasOnToken = true;
+ sym(1).Node = node;
+ } break;
./
-UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ;
+
+UiObjectLiteral: T_LBRACE ExpressionStatementLookahead UiPropertyDefinitionList T_RBRACE;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiObjectLiteral: T_LBRACE ExpressionStatementLookahead UiPropertyDefinitionList T_COMMA T_RBRACE;
/.
-case $rule_number: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ObjectPattern *l = new (pool) AST::ObjectPattern(sym(3).PatternPropertyList->finish());
+ l->lbraceToken = loc(1);
+ l->rbraceToken = loc(4);
+ AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(l);
+ sym(1).Node = node;
+ } break;
./
-UiObjectDefinition: UiQualifiedId UiObjectInitializer ;
+
+UiScriptStatement: ExpressionStatementLookahead T_FORCE_DECLARATION ExpressionStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead T_FORCE_BLOCK Block;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead T_FORCE_BLOCK UiObjectLiteral;
/.
-case $rule_number: {
- AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(3).Node;
+ } break;
./
-UiObjectMember: UiObjectDefinition ;
-UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+UiScriptStatement: ExpressionStatementLookahead EmptyStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead ExpressionStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead IfStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead WithStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead SwitchStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiScriptStatement: ExpressionStatementLookahead TryStatement;
/.
-case $rule_number: {
- AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ } break;
./
-UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ;
+UiObjectMember: UiQualifiedId T_COLON UiScriptStatement;
/.
-case $rule_number: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
+case $rule_number:
+{
+ AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(sym(1).UiQualifiedId, sym(3).Statement);
node->colonToken = loc(2);
sym(1).Node = node;
-} break;
+ } break;
./
-UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ;
+UiPropertyType: T_VAR;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiPropertyType: T_RESERVED_WORD;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+UiPropertyType: T_IDENTIFIER;
/.
-case $rule_number: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- node->hasOnToken = true;
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-UiScriptStatement: Block ;
-UiScriptStatement: EmptyStatement ;
-UiScriptStatement: ExpressionStatement ;
-UiScriptStatement: IfStatement ;
-UiScriptStatement: WithStatement ;
-UiScriptStatement: SwitchStatement ;
-UiScriptStatement: TryStatement ;
+UiPropertyType: UiPropertyType T_DOT T_IDENTIFIER;
+/.
+ case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3));
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
-UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
+UiParameterListOpt: ;
/.
-case $rule_number:
-{
- AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-UiPropertyType: T_VAR ;
+UiParameterListOpt: UiParameterList;
/.
-case $rule_number: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).UiParameterList->finish();
+ } break;
./
-UiPropertyType: T_RESERVED_WORD ;
+UiParameterList: UiPropertyType QmlIdentifier;
/.
-case $rule_number: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
+ node->propertyTypeToken = loc(1);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+UiParameterList: UiParameterList T_COMMA UiPropertyType QmlIdentifier;
+/.
+ case $rule_number: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
+ node->propertyTypeToken = loc(3);
+ node->commaToken = loc(2);
+ node->identifierToken = loc(4);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->parameters = sym(4).UiParameterList;
+ node->semicolonToken = loc(6);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
+ node->type = AST::UiPublicMember::Signal;
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType QmlIdentifier T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_AUTOMATIC_SEMICOLON;
+UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->typeModifier = stringRef(3);
+ node->propertyToken = loc(2);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(7);
+ node->semicolonToken = loc(8);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3), sym(5).Statement);
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement);
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-UiPropertyType: T_IDENTIFIER ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement;
/.
-case $rule_number: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement);
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->colonToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-UiPropertyType: UiPropertyType T_DOT T_IDENTIFIER ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET;
/.
-case $rule_number: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3));
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
+ node->typeModifier = stringRef(2);
+ node->propertyToken = loc(1);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->semicolonToken = loc(7); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
+ propertyName->identifierToken = loc(6);
+ propertyName->next = 0;
+
+ AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(9).UiArrayMemberList->finish());
+ binding->colonToken = loc(7);
+ binding->lbracketToken = loc(8);
+ binding->rbracketToken = loc(10);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+ } break;
./
-UiParameterListOpt: ;
+UiObjectMember: T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
+ node->propertyToken = loc(1);
+ node->typeToken = loc(2);
+ node->identifierToken = loc(3);
+ node->semicolonToken = loc(4); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
+ propertyName->identifierToken = loc(3);
+ propertyName->next = 0;
+
+ AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
+ propertyName, sym(6).UiQualifiedId, sym(7).UiObjectInitializer);
+ binding->colonToken = loc(4);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+ } break;
./
-UiParameterListOpt: UiParameterList ;
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType QmlIdentifier T_COLON ExpressionStatementLookahead UiQualifiedId UiObjectInitializer;
/.
-case $rule_number: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
+ node->isReadonlyMember = true;
+ node->readonlyToken = loc(1);
+ node->propertyToken = loc(2);
+ node->typeToken = loc(3);
+ node->identifierToken = loc(4);
+ node->semicolonToken = loc(5); // insert a fake ';' before ':'
+
+ AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(4));
+ propertyName->identifierToken = loc(4);
+ propertyName->next = 0;
+
+ AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
+ propertyName, sym(7).UiQualifiedId, sym(8).UiObjectInitializer);
+ binding->colonToken = loc(5);
+
+ node->binding = binding;
+
+ sym(1).Node = node;
+ } break;
./
-UiParameterList: UiPropertyType JsIdentifier ;
+UiObjectMember: FunctionDeclaration;
/.
-case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
- node->propertyTypeToken = loc(1);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+ } break;
./
-UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
+UiObjectMember: VariableStatement;
/.
-case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
- node->propertyTypeToken = loc(3);
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
+ } break;
./
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
+UiQualifiedId: MemberExpression;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
+ QLatin1String("Ignored annotation")));
+
+ sym(1).Expression = mem->base;
+ }
+
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false; // ### recover
+ }
+ } break;
./
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
+UiObjectMember: T_ENUM T_IDENTIFIER T_LBRACE EnumMemberList T_RBRACE;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiEnumDeclaration *enumDeclaration = new (pool) AST::UiEnumDeclaration(stringRef(2), sym(4).UiEnumMemberList->finish());
+ enumDeclaration->enumToken = loc(1);
+ enumDeclaration->rbraceToken = loc(5);
+ sym(1).Node = enumDeclaration;
+ break;
+ }
./
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
+EnumMemberList: T_IDENTIFIER;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1));
+ node->memberToken = loc(1);
+ sym(1).Node = node;
+ break;
+ }
./
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
+EnumMemberList: T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1), sym(3).dval);
+ node->memberToken = loc(1);
+ node->valueToken = loc(3);
+ sym(1).Node = node;
+ break;
+ }
./
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
+EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3));
+ node->memberToken = loc(3);
+ sym(1).Node = node;
+ break;
+ }
./
-UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
-UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
+EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->typeModifier = stringRef(3);
- node->propertyToken = loc(2);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(7);
- node->semicolonToken = loc(8);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3), sym(5).dval);
+ node->memberToken = loc(3);
+ node->valueToken = loc(5);
+ sym(1).Node = node;
+ break;
+ }
./
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+QmlIdentifier: T_IDENTIFIER;
+QmlIdentifier: T_PROPERTY;
+QmlIdentifier: T_SIGNAL;
+QmlIdentifier: T_READONLY;
+QmlIdentifier: T_ON;
+QmlIdentifier: T_GET;
+QmlIdentifier: T_SET;
+QmlIdentifier: T_FROM;
+QmlIdentifier: T_OF;
+
+JsIdentifier: T_IDENTIFIER;
+JsIdentifier: T_PROPERTY;
+JsIdentifier: T_SIGNAL;
+JsIdentifier: T_READONLY;
+JsIdentifier: T_ON;
+JsIdentifier: T_GET;
+JsIdentifier: T_SET;
+JsIdentifier: T_FROM;
+JsIdentifier: T_STATIC;
+JsIdentifier: T_OF;
+JsIdentifier: T_AS;
+
+IdentifierReference: JsIdentifier;
+BindingIdentifier: IdentifierReference;
+
+--------------------------------------------------------------------------------------------------------
+-- Expressions
+--------------------------------------------------------------------------------------------------------
+
+PrimaryExpression: T_THIS;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3),
- sym(5).Statement);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ThisExpression *node = new (pool) AST::ThisExpression();
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+PrimaryExpression: IdentifierReference;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
- sym(6).Statement);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
+PrimaryExpression: Literal;
+PrimaryExpression: ArrayLiteral;
+PrimaryExpression: ObjectLiteral;
+PrimaryExpression: FunctionExpression;
+PrimaryExpression: ClassExpression;
+PrimaryExpression: GeneratorExpression;
+PrimaryExpression: RegularExpressionLiteral;
+PrimaryExpression: TemplateLiteral;
+
+PrimaryExpression: CoverParenthesizedExpressionAndArrowParameterList;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
- sym(6).Statement);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (coverExpressionType != CE_ParenthesizedExpression) {
+ syntaxError(coverExpressionErrorLocation, "Expected token ')'.");
+ return false;
+ }
+ } break;
./
-UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
+-- Parsing of the CoverParenthesizedExpressionAndArrowParameterList is restricted to the one rule below when this is parsed as a primary expression
+CoverParenthesizedExpressionAndArrowParameterList: T_LPAREN Expression_In T_RPAREN;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
- propertyName->identifierToken = loc(6);
- propertyName->next = 0;
-
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
- propertyName, sym(9).UiArrayMemberList->finish());
- binding->colonToken = loc(7);
- binding->lbracketToken = loc(8);
- binding->rbracketToken = loc(10);
-
- node->binding = binding;
+ case $rule_number: {
+ AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
+ node->lparenToken = loc(1);
+ node->rparenToken = loc(3);
+ sym(1).Node = node;
+ coverExpressionType = CE_ParenthesizedExpression;
+ } break;
+./
- sym(1).Node = node;
-} break;
+CoverParenthesizedExpressionAndArrowParameterList: T_LPAREN T_RPAREN;
+/.
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ coverExpressionErrorLocation = loc(2);
+ coverExpressionType = CE_FormalParameterList;
+ } break;
./
-UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
+CoverParenthesizedExpressionAndArrowParameterList: T_LPAREN BindingRestElement T_RPAREN;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4); // insert a fake ';' before ':'
+ case $rule_number: {
+ AST::FormalParameterList *node = (new (pool) AST::FormalParameterList(nullptr, sym(2).PatternElement))->finish(pool);
+ sym(1).Node = node;
+ coverExpressionErrorLocation = loc(2);
+ coverExpressionType = CE_FormalParameterList;
+ } break;
+./
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
- propertyName->identifierToken = loc(3);
- propertyName->next = 0;
+CoverParenthesizedExpressionAndArrowParameterList: T_LPAREN Expression_In T_COMMA BindingRestElementOpt T_RPAREN;
+/.
+ case $rule_number: {
+ AST::FormalParameterList *list = sym(2).Expression->reparseAsFormalParameterList(pool);
+ if (!list) {
+ syntaxError(loc(1), "Invalid Arrow parameter list.");
+ return false;
+ }
+ if (sym(4).Node) {
+ list = new (pool) AST::FormalParameterList(list, sym(4).PatternElement);
+ }
+ coverExpressionErrorLocation = loc(4);
+ coverExpressionType = CE_FormalParameterList;
+ sym(1).Node = list->finish(pool);
+ } break;
+./
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
- binding->colonToken = loc(4);
+Literal: T_NULL;
+/.
+ case $rule_number: {
+ AST::NullExpression *node = new (pool) AST::NullExpression();
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
- node->binding = binding;
+Literal: T_TRUE;
+/.
+ case $rule_number: {
+ AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
- sym(1).Node = node;
-} break;
+Literal: T_FALSE;
+/.
+ case $rule_number: {
+ AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
+Literal: T_NUMERIC_LITERAL;
/.
-case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5); // insert a fake ';' before ':'
+ case $rule_number: {
+ AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(4));
- propertyName->identifierToken = loc(4);
- propertyName->next = 0;
+Literal: T_MULTILINE_STRING_LITERAL;
+/. case $rule_number: Q_FALLTHROUGH(); ./
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(6).UiQualifiedId, sym(7).UiObjectInitializer);
- binding->colonToken = loc(5);
+Literal: T_STRING_LITERAL;
+/.
+ case $rule_number: {
+ AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
+
+RegularExpressionLiteral: T_DIVIDE_;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
+:/
+/.
+{
+ Lexer::RegExpBodyPrefix prefix;
+ case $rule_number:
+ prefix = Lexer::NoPrefix;
+ goto scan_regexp;
+./
- node->binding = binding;
+RegularExpressionLiteral: T_DIVIDE_EQ;
+/:
+#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
+:/
+/.
+ case $rule_number:
+ prefix = Lexer::EqualPrefix;
+ goto scan_regexp;
- sym(1).Node = node;
-} break;
+ scan_regexp: {
+ bool rx = lexer->scanRegExp(prefix);
+ if (!rx) {
+ diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
+ return false;
+ }
+
+ loc(1).length = lexer->tokenLength();
+ yylloc = loc(1); // adjust the location of the current token
+
+ AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+ } break;
+}
./
-UiObjectMember: FunctionDeclaration ;
+
+ArrayLiteral: T_LBRACKET ElisionOpt T_RBRACKET;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
+ case $rule_number: {
+ AST::PatternElementList *list = nullptr;
+ if (sym(2).Elision)
+ list = (new (pool) AST::PatternElementList(sym(2).Elision, nullptr))->finish();
+ AST::ArrayPattern *node = new (pool) AST::ArrayPattern(list);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMember: VariableStatement ;
+ArrayLiteral: T_LBRACKET ElementList T_RBRACKET;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
+ case $rule_number: {
+ AST::ArrayPattern *node = new (pool) AST::ArrayPattern(sym(2).PatternElementList->finish());
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-UiObjectMember: T_ENUM T_IDENTIFIER T_LBRACE EnumMemberList T_RBRACE;
+ArrayLiteral: T_LBRACKET ElementList T_COMMA ElisionOpt T_RBRACKET;
/.
-case $rule_number: {
- AST::UiEnumDeclaration *enumDeclaration = new (pool) AST::UiEnumDeclaration(stringRef(2), sym(4).UiEnumMemberList->finish());
- enumDeclaration->enumToken = loc(1);
- enumDeclaration->rbraceToken = loc(5);
- sym(1).Node = enumDeclaration;
- break;
-}
+ case $rule_number: {
+ auto *list = sym(2).PatternElementList;
+ if (sym(4).Elision) {
+ AST::PatternElementList *l = new (pool) AST::PatternElementList(sym(4).Elision, nullptr);
+ list = list->append(l);
+ }
+ AST::ArrayPattern *node = new (pool) AST::ArrayPattern(list->finish());
+ node->lbracketToken = loc(1);
+ node->commaToken = loc(3);
+ node->rbracketToken = loc(5);
+ sym(1).Node = node;
+ Q_ASSERT(node->isValidArrayLiteral());
+ } break;
./
-EnumMemberList: T_IDENTIFIER;
+ElementList: AssignmentExpression_In;
/.
-case $rule_number: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1));
- node->memberToken = loc(1);
- sym(1).Node = node;
- break;
-}
+ case $rule_number: {
+ AST::PatternElement *e = new (pool) AST::PatternElement(sym(1).Expression);
+ sym(1).Node = new (pool) AST::PatternElementList(nullptr, e);
+ } break;
./
-EnumMemberList: T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
+ElementList: Elision AssignmentExpression_In;
/.
-case $rule_number: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1), sym(3).dval);
- node->memberToken = loc(1);
- node->valueToken = loc(3);
- sym(1).Node = node;
- break;
-}
+ case $rule_number: {
+ AST::PatternElement *e = new (pool) AST::PatternElement(sym(2).Expression);
+ sym(1).Node = new (pool) AST::PatternElementList(sym(1).Elision->finish(), e);
+ } break;
./
-EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER;
+ElementList: ElisionOpt SpreadElement;
/.
-case $rule_number: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3));
- node->memberToken = loc(3);
- sym(1).Node = node;
- break;
-}
+ case $rule_number: {
+ AST::PatternElementList *node = new (pool) AST::PatternElementList(sym(1).Elision, sym(2).PatternElement);
+ sym(1).Node = node;
+ } break;
./
-EnumMemberList: EnumMemberList T_COMMA T_IDENTIFIER T_EQ T_NUMERIC_LITERAL;
+ElementList: ElementList T_COMMA ElisionOpt AssignmentExpression_In;
/.
-case $rule_number: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3), sym(5).dval);
- node->memberToken = loc(3);
- node->valueToken = loc(5);
- sym(1).Node = node;
- break;
-}
+ case $rule_number: {
+ AST::PatternElement *e = new (pool) AST::PatternElement(sym(4).Expression);
+ AST::PatternElementList *node = new (pool) AST::PatternElementList(sym(3).Elision, e);
+ sym(1).Node = sym(1).PatternElementList->append(node);
+ } break;
./
-JsIdentifier: T_IDENTIFIER;
+ElementList: ElementList T_COMMA ElisionOpt SpreadElement;
+/.
+ case $rule_number: {
+ AST::PatternElementList *node = new (pool) AST::PatternElementList(sym(3).Elision, sym(4).PatternElement);
+ sym(1).Node = sym(1).PatternElementList->append(node);
+ } break;
+./
-JsIdentifier: T_PROPERTY ;
-JsIdentifier: T_SIGNAL ;
-JsIdentifier: T_READONLY ;
-JsIdentifier: T_ON ;
-JsIdentifier: T_GET ;
-JsIdentifier: T_SET ;
+Elision: T_COMMA;
+/.
+ case $rule_number: {
+ AST::Elision *node = new (pool) AST::Elision();
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
---------------------------------------------------------------------------------------------------------
--- Expressions
---------------------------------------------------------------------------------------------------------
+Elision: Elision T_COMMA;
+/.
+ case $rule_number: {
+ AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
-PrimaryExpression: T_THIS ;
+ElisionOpt: ;
/.
-case $rule_number: {
- AST::ThisExpression *node = new (pool) AST::ThisExpression();
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-PrimaryExpression: JsIdentifier ;
+ElisionOpt: Elision;
/.
-case $rule_number: {
- AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).Elision->finish();
+ } break;
./
-PrimaryExpression: T_NULL ;
+SpreadElement: T_ELLIPSIS AssignmentExpression;
/.
-case $rule_number: {
- AST::NullExpression *node = new (pool) AST::NullExpression();
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(sym(2).Expression, AST::PatternElement::SpreadElement);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_TRUE ;
+ObjectLiteral: T_LBRACE T_RBRACE;
/.
-case $rule_number: {
- AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ObjectPattern *node = new (pool) AST::ObjectPattern();
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_FALSE ;
+ObjectLiteral: T_LBRACE PropertyDefinitionList T_RBRACE;
/.
-case $rule_number: {
- AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ObjectPattern *node = new (pool) AST::ObjectPattern(sym(2).PatternPropertyList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_NUMERIC_LITERAL ;
+ObjectLiteral: T_LBRACE PropertyDefinitionList T_COMMA T_RBRACE;
/.
-case $rule_number: {
- AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ObjectPattern *node = new (pool) AST::ObjectPattern(sym(2).PatternPropertyList->finish());
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
-/.case $rule_number:./
-PrimaryExpression: T_STRING_LITERAL ;
+UiPropertyDefinitionList: UiPropertyDefinition;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+PropertyDefinitionList: PropertyDefinition;
/.
-case $rule_number: {
- AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::PatternPropertyList(sym(1).PatternProperty);
+ } break;
./
-PrimaryExpression: T_DIVIDE_ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number
-:/
+UiPropertyDefinitionList: UiPropertyDefinitionList T_COMMA UiPropertyDefinition;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+PropertyDefinitionList: PropertyDefinitionList T_COMMA PropertyDefinition;
/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternPropertyList *node = new (pool) AST::PatternPropertyList(sym(1).PatternPropertyList, sym(3).PatternProperty);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_DIVIDE_EQ ;
-/:
-#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number
-:/
+PropertyDefinition: IdentifierReference;
/.
-case $rule_number: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
+ case $rule_number: {
+ AST::IdentifierPropertyName *name = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ name->propertyNameToken = loc(1);
+ AST::IdentifierExpression *expr = new (pool) AST::IdentifierExpression(stringRef(1));
+ expr->identifierToken = loc(1);
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(name, expr);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
+-- Using this production should result in a syntax error when used in an ObjectLiteral
+PropertyDefinition: CoverInitializedName;
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
+CoverInitializedName: IdentifierReference Initializer_In;
+/.
+ case $rule_number: {
+ AST::IdentifierPropertyName *name = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ name->propertyNameToken = loc(1);
+ AST::IdentifierExpression *left = new (pool) AST::IdentifierExpression(stringRef(1));
+ left->identifierToken = loc(1);
+ // if initializer is an anonymous function expression, we need to assign identifierref as it's name
+ if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression))
+ f->name = stringRef(1);
+ if (auto *c = asAnonymousClassDefinition(sym(2).Expression))
+ c->name = stringRef(1);
+ AST::BinaryExpression *assignment = new (pool) AST::BinaryExpression(left, QSOperator::Assign, sym(2).Expression);
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(name, assignment);
+ node->colonToken = loc(1);
+ sym(1).Node = node;
+
+ } break;
./
-PrimaryExpression: T_LBRACKET T_RBRACKET ;
+UiPropertyDefinition: UiPropertyName T_COLON AssignmentExpression_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+PropertyDefinition: PropertyName T_COLON AssignmentExpression_In;
/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(1).PropertyName, sym(3).Expression);
+ if (auto *f = asAnonymousFunctionDefinition(sym(3).Expression)) {
+ if (!AST::cast<AST::ComputedPropertyName *>(sym(1).PropertyName))
+ f->name = driver->newStringRef(sym(1).PropertyName->asString());
+ }
+ if (auto *c = asAnonymousClassDefinition(sym(3).Expression)) {
+ if (!AST::cast<AST::ComputedPropertyName *>(sym(1).PropertyName))
+ c->name = driver->newStringRef(sym(1).PropertyName->asString());
+ }
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+PropertyDefinition: MethodDefinition;
+
+PropertyName: LiteralPropertyName;
+PropertyName: ComputedPropertyName;
+
+LiteralPropertyName: IdentifierName;
+/.
+ case $rule_number: {
+ AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_LBRACKET Elision T_RBRACKET ;
+UiPropertyName: T_STRING_LITERAL;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LiteralPropertyName: T_STRING_LITERAL;
/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ;
+UiPropertyName: T_NUMERIC_LITERAL;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LiteralPropertyName: T_NUMERIC_LITERAL;
/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ;
+IdentifierName: IdentifierReference;
+IdentifierName: ReservedIdentifier;
+
+ReservedIdentifier: T_BREAK;
+ReservedIdentifier: T_CASE;
+ReservedIdentifier: T_CATCH;
+ReservedIdentifier: T_CONTINUE;
+ReservedIdentifier: T_DEFAULT;
+ReservedIdentifier: T_DELETE;
+ReservedIdentifier: T_DO;
+ReservedIdentifier: T_ELSE;
+ReservedIdentifier: T_ENUM;
+ReservedIdentifier: T_FALSE;
+ReservedIdentifier: T_FINALLY;
+ReservedIdentifier: T_FOR;
+ReservedIdentifier: T_FUNCTION;
+ReservedIdentifier: T_IF;
+ReservedIdentifier: T_IN;
+ReservedIdentifier: T_INSTANCEOF;
+ReservedIdentifier: T_NEW;
+ReservedIdentifier: T_NULL;
+ReservedIdentifier: T_RETURN;
+ReservedIdentifier: T_SWITCH;
+ReservedIdentifier: T_THIS;
+ReservedIdentifier: T_THROW;
+ReservedIdentifier: T_TRUE;
+ReservedIdentifier: T_TRY;
+ReservedIdentifier: T_TYPEOF;
+ReservedIdentifier: T_VAR;
+ReservedIdentifier: T_VOID;
+ReservedIdentifier: T_WHILE;
+ReservedIdentifier: T_CONST;
+ReservedIdentifier: T_LET;
+ReservedIdentifier: T_DEBUGGER;
+ReservedIdentifier: T_RESERVED_WORD;
+ReservedIdentifier: T_SUPER;
+ReservedIdentifier: T_WITH;
+ReservedIdentifier: T_CLASS;
+ReservedIdentifier: T_EXTENDS;
+ReservedIdentifier: T_EXPORT;
+ReservedIdentifier: T_IMPORT;
+
+ComputedPropertyName: T_LBRACKET AssignmentExpression_In T_RBRACKET;
/.
-case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- (AST::Elision *) 0);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ComputedPropertyName *node = new (pool) AST::ComputedPropertyName(sym(2).Expression);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ;
+Initializer: T_EQ AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Initializer_In: T_EQ AssignmentExpression_In;
/.
case $rule_number: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
+ sym(1) = sym(2);
} break;
./
--- PrimaryExpression: T_LBRACE T_RBRACE ;
--- /.
--- case $rule_number: {
--- sym(1).Node = new (pool) AST::ObjectLiteral();
--- } break;
--- ./
-PrimaryExpression: T_LBRACE PropertyAssignmentListOpt T_RBRACE ;
+InitializerOpt: ;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+InitializerOpt_In: ;
/.
-case $rule_number: {
- AST::ObjectLiteral *node = 0;
- if (sym(2).Node)
- node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyAssignmentList->finish ());
- else
- node = new (pool) AST::ObjectLiteral();
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-PrimaryExpression: T_LBRACE PropertyAssignmentList T_COMMA T_RBRACE ;
+InitializerOpt: Initializer;
+InitializerOpt_In: Initializer_In;
+
+TemplateLiteral: T_NO_SUBSTITUTION_TEMPLATE;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+
+TemplateSpans: T_TEMPLATE_TAIL;
/.
-case $rule_number: {
- AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyAssignmentList->finish ());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::TemplateLiteral *node = new (pool) AST::TemplateLiteral(stringRef(1), nullptr);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-PrimaryExpression: T_LPAREN Expression T_RPAREN ;
+TemplateSpans: T_TEMPLATE_MIDDLE Expression TemplateSpans;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+
+TemplateLiteral: T_TEMPLATE_HEAD Expression TemplateSpans;
/.
-case $rule_number: {
- AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::TemplateLiteral *node = new (pool) AST::TemplateLiteral(stringRef(1), sym(2).Expression);
+ node->next = sym(3).Template;
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-UiQualifiedId: MemberExpression ;
+MemberExpression: PrimaryExpression;
+
+Super: T_SUPER;
/.
-case $rule_number: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
+ case $rule_number: {
+ AST::SuperLiteral *node = new (pool) AST::SuperLiteral();
+ node->superToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
- sym(1).Expression = mem->base;
- }
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = 0;
+MemberExpression: Super T_LBRACKET Expression_In T_RBRACKET;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+MemberExpression: MemberExpression T_LBRACKET Expression_In T_RBRACKET;
+/.
+ case $rule_number: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+ } break;
+./
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
- return false; // ### recover
- }
-} break;
+-- the identifier has to be "target", catched at codegen time
+NewTarget: T_NEW T_DOT T_IDENTIFIER;
+/. case $rule_number:
+ {
+ AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
+ node->identifierToken= loc(1);
+ sym(1).Node = node;
+ } Q_FALLTHROUGH();
+./
+MemberExpression: Super T_DOT IdentifierName;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+MemberExpression: MemberExpression T_DOT IdentifierName;
+/.
+ case $rule_number: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-ElementList: AssignmentExpression ;
+MemberExpression: MetaProperty;
+
+MemberExpression: T_NEW MemberExpression T_LPAREN Arguments T_RPAREN;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
-} break;
+ case $rule_number: {
+ AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
+ node->newToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-ElementList: Elision AssignmentExpression ;
+MetaProperty: NewTarget;
+
+
+NewExpression: MemberExpression;
+
+NewExpression: T_NEW NewExpression;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
-} break;
+ case $rule_number: {
+ AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-ElementList: ElementList T_COMMA AssignmentExpression ;
+
+CallExpression: CallExpression TemplateLiteral;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+MemberExpression: MemberExpression TemplateLiteral;
/.
-case $rule_number: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
- (AST::Elision *) 0, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::TaggedTemplate *node = new (pool) AST::TaggedTemplate(sym(1).Expression, sym(2).Template);
+ sym(1).Node = node;
+ } break;
./
-ElementList: ElementList T_COMMA Elision AssignmentExpression ;
+CallExpression: MemberExpression T_LPAREN Arguments T_RPAREN;
/.
-case $rule_number: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-Elision: T_COMMA ;
+CallExpression: Super T_LPAREN Arguments T_RPAREN;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+CallExpression: CallExpression T_LPAREN Arguments T_RPAREN;
/.
-case $rule_number: {
- AST::Elision *node = new (pool) AST::Elision();
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-Elision: Elision T_COMMA ;
+CallExpression: CallExpression T_LBRACKET Expression_In T_RBRACKET;
/.
-case $rule_number: {
- AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
+ node->lbracketToken = loc(2);
+ node->rbracketToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-PropertyAssignment: PropertyName T_COLON AssignmentExpression ;
+CallExpression: CallExpression T_DOT IdentifierName;
/.
-case $rule_number: {
- AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue(
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-PropertyAssignment: T_GET PropertyName T_LPAREN T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+Arguments: ;
/.
-case $rule_number: {
- AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
- sym(2).PropertyName, sym(6).FunctionBody);
- node->getSetToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(4);
- node->lbraceToken = loc(5);
- node->rbraceToken = loc(7);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-PropertyAssignment: T_SET PropertyName T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+Arguments: ArgumentList;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Arguments: ArgumentList T_COMMA;
/.
-case $rule_number: {
- AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
- sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->getSetToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+ } break;
./
-PropertyAssignmentList: PropertyAssignment ;
+ArgumentList: AssignmentExpression_In;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment);
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
+ } break;
./
-PropertyAssignmentList: PropertyAssignmentList T_COMMA PropertyAssignment ;
+ArgumentList: T_ELLIPSIS AssignmentExpression_In;
/.
-case $rule_number: {
- AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList(
- sym(1).PropertyAssignmentList, sym(3).PropertyAssignment);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(2).Expression);
+ node->isSpreadElement = true;
+ sym(1).Node = node;
+ } break;
./
-PropertyName: JsIdentifier %prec SHIFT_THERE ;
+ArgumentList: ArgumentList T_COMMA AssignmentExpression_In;
/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-PropertyName: T_STRING_LITERAL ;
+ArgumentList: ArgumentList T_COMMA T_ELLIPSIS AssignmentExpression_In;
/.
-case $rule_number: {
- AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(4).Expression);
+ node->commaToken = loc(2);
+ node->isSpreadElement = true;
+ sym(1).Node = node;
+ } break;
./
-PropertyName: T_NUMERIC_LITERAL ;
+LeftHandSideExpression: NewExpression;
+LeftHandSideExpression: CallExpression;
+
+UpdateExpression: LeftHandSideExpression;
+
+UpdateExpression: LeftHandSideExpression T_PLUS_PLUS;
/.
-case $rule_number: {
- AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-PropertyName: ReservedIdentifier ;
+UpdateExpression: LeftHandSideExpression T_MINUS_MINUS;
/.
-case $rule_number: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-ReservedIdentifier: T_BREAK ;
-ReservedIdentifier: T_CASE ;
-ReservedIdentifier: T_CATCH ;
-ReservedIdentifier: T_CONTINUE ;
-ReservedIdentifier: T_DEFAULT ;
-ReservedIdentifier: T_DELETE ;
-ReservedIdentifier: T_DO ;
-ReservedIdentifier: T_ELSE ;
-ReservedIdentifier: T_ENUM ;
-ReservedIdentifier: T_FALSE ;
-ReservedIdentifier: T_FINALLY ;
-ReservedIdentifier: T_FOR ;
-ReservedIdentifier: T_FUNCTION ;
-ReservedIdentifier: T_IF ;
-ReservedIdentifier: T_IN ;
-ReservedIdentifier: T_INSTANCEOF ;
-ReservedIdentifier: T_NEW ;
-ReservedIdentifier: T_NULL ;
-ReservedIdentifier: T_RETURN ;
-ReservedIdentifier: T_SWITCH ;
-ReservedIdentifier: T_THIS ;
-ReservedIdentifier: T_THROW ;
-ReservedIdentifier: T_TRUE ;
-ReservedIdentifier: T_TRY ;
-ReservedIdentifier: T_TYPEOF ;
-ReservedIdentifier: T_VAR ;
-ReservedIdentifier: T_VOID ;
-ReservedIdentifier: T_WHILE ;
-ReservedIdentifier: T_CONST ;
-ReservedIdentifier: T_LET ;
-ReservedIdentifier: T_DEBUGGER ;
-ReservedIdentifier: T_RESERVED_WORD ;
-ReservedIdentifier: T_WITH ;
-
-PropertyIdentifier: JsIdentifier ;
-PropertyIdentifier: ReservedIdentifier ;
-
-MemberExpression: PrimaryExpression ;
-MemberExpression: FunctionExpression ;
-
-MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ;
+UpdateExpression: T_PLUS_PLUS UnaryExpression;
/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-MemberExpression: MemberExpression T_DOT PropertyIdentifier ;
+UpdateExpression: T_MINUS_MINUS UnaryExpression;
/.
-case $rule_number: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+UnaryExpression: UpdateExpression;
+
+UnaryExpression: T_DELETE UnaryExpression;
/.
-case $rule_number: {
- AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-NewExpression: MemberExpression ;
+UnaryExpression: T_VOID UnaryExpression;
+/.
+ case $rule_number: {
+ AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
-NewExpression: T_NEW NewExpression ;
+UnaryExpression: T_TYPEOF UnaryExpression;
/.
-case $rule_number: {
- AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+UnaryExpression: T_PLUS UnaryExpression;
/.
-case $rule_number: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ;
+UnaryExpression: T_MINUS UnaryExpression;
/.
-case $rule_number: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ;
+UnaryExpression: T_TILDE UnaryExpression;
/.
-case $rule_number: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-CallExpression: CallExpression T_DOT PropertyIdentifier ;
+UnaryExpression: T_NOT UnaryExpression;
/.
-case $rule_number: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-ArgumentListOpt: ;
+ExponentiationExpression: UnaryExpression;
+
+ExponentiationExpression: UpdateExpression T_STAR_STAR ExponentiationExpression;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Exp, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-ArgumentListOpt: ArgumentList ;
+MultiplicativeExpression: ExponentiationExpression;
+
+MultiplicativeExpression: MultiplicativeExpression MultiplicativeOperator ExponentiationExpression;
/.
-case $rule_number: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-ArgumentList: AssignmentExpression ;
+MultiplicativeOperator: T_STAR;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::Mul;
+ } break;
./
-ArgumentList: ArgumentList T_COMMA AssignmentExpression ;
+MultiplicativeOperator: T_DIVIDE_;
/.
-case $rule_number: {
- AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::Div;
+ } break;
+./
+
+MultiplicativeOperator: T_REMAINDER;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::Mod;
+ } break;
./
-LeftHandSideExpression: NewExpression ;
-LeftHandSideExpression: CallExpression ;
-PostfixExpression: LeftHandSideExpression ;
+AdditiveExpression: MultiplicativeExpression;
-PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ;
+AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression;
/.
-case $rule_number: {
- AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Add, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ;
+AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression;
/.
-case $rule_number: {
- AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Sub, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: PostfixExpression ;
+ShiftExpression: AdditiveExpression;
-UnaryExpression: T_DELETE UnaryExpression ;
+ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression;
/.
-case $rule_number: {
- AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::LShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_VOID UnaryExpression ;
+ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression;
/.
-case $rule_number: {
- AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::RShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_TYPEOF UnaryExpression ;
+ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression;
/.
-case $rule_number: {
- AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::URShift, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_PLUS_PLUS UnaryExpression ;
+RelationalExpression_In: ShiftExpression;
+RelationalExpression: ShiftExpression;
+
+RelationalExpression_In: RelationalExpression_In RelationalOperator ShiftExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+RelationalExpression: RelationalExpression RelationalOperator ShiftExpression;
/.
-case $rule_number: {
- AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_MINUS_MINUS UnaryExpression ;
+RelationalOperator: T_LT;
/.
-case $rule_number: {
- AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::Lt;
+ } break;
+./
+RelationalOperator: T_GT;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::Gt;
+ } break;
+./
+RelationalOperator: T_LE;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::Le;
+ } break;
+./
+RelationalOperator: T_GE;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::Ge;
+ } break;
+./
+RelationalOperator: T_INSTANCEOF;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::InstanceOf;
+ } break;
./
-UnaryExpression: T_PLUS UnaryExpression ;
+RelationalExpression_In: RelationalExpression_In T_IN ShiftExpression;
/.
-case $rule_number: {
- AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::In, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_MINUS UnaryExpression ;
+EqualityExpression_In: RelationalExpression_In;
+EqualityExpression: RelationalExpression;
+
+EqualityExpression_In: EqualityExpression_In EqualityOperator RelationalExpression_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+EqualityExpression: EqualityExpression EqualityOperator RelationalExpression;
/.
-case $rule_number: {
- AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-UnaryExpression: T_TILDE UnaryExpression ;
+EqualityOperator: T_EQ_EQ;
/.
-case $rule_number: {
- AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::Equal;
+ } break;
+./
+EqualityOperator: T_NOT_EQ;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::NotEqual;
+ } break;
+./
+EqualityOperator: T_EQ_EQ_EQ;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::StrictEqual;
+ } break;
+./
+EqualityOperator: T_NOT_EQ_EQ;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::StrictNotEqual;
+ } break;
./
-UnaryExpression: T_NOT UnaryExpression ;
+
+BitwiseANDExpression: EqualityExpression;
+BitwiseANDExpression_In: EqualityExpression_In;
+
+BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+BitwiseANDExpression_In: BitwiseANDExpression_In T_AND EqualityExpression_In;
/.
-case $rule_number: {
- AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitAnd, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-MultiplicativeExpression: UnaryExpression ;
-MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ;
+BitwiseXORExpression: BitwiseANDExpression;
+BitwiseXORExpression_In: BitwiseANDExpression_In;
+
+BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+BitwiseXORExpression_In: BitwiseXORExpression_In T_XOR BitwiseANDExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitXor, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ;
+BitwiseORExpression: BitwiseXORExpression;
+BitwiseORExpression_In: BitwiseXORExpression_In;
+
+BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+BitwiseORExpression_In: BitwiseORExpression_In T_OR BitwiseXORExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitOr, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ;
+LogicalANDExpression: BitwiseORExpression;
+LogicalANDExpression_In: BitwiseORExpression_In;
+
+LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LogicalANDExpression_In: LogicalANDExpression_In T_AND_AND BitwiseORExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::And, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-AdditiveExpression: MultiplicativeExpression ;
+LogicalORExpression: LogicalANDExpression;
+LogicalORExpression_In: LogicalANDExpression_In;
-AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ;
+LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LogicalORExpression_In: LogicalORExpression_In T_OR_OR LogicalANDExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Or, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ;
+
+ConditionalExpression: LogicalORExpression;
+ConditionalExpression_In: LogicalORExpression_In;
+
+ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression_In T_COLON AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ConditionalExpression_In: LogicalORExpression_In T_QUESTION AssignmentExpression_In T_COLON AssignmentExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, sym(3).Expression, sym(5).Expression);
+ node->questionToken = loc(2);
+ node->colonToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-ShiftExpression: AdditiveExpression ;
+AssignmentExpression: ConditionalExpression;
+AssignmentExpression_In: ConditionalExpression_In;
+
+AssignmentExpression: YieldExpression;
+AssignmentExpression_In: YieldExpression_In;
-ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ;
+AssignmentExpression: ArrowFunction;
+AssignmentExpression_In: ArrowFunction_In;
+
+AssignmentExpression: LeftHandSideExpression T_EQ AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
+ if (AST::Pattern *p = sym(1).Expression->patternCast()) {
+ AST::SourceLocation errorLoc;
+ QString errorMsg;
+ if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
+ syntaxError(errorLoc, errorMsg);
+ return false;
+ }
+ }
+ // if lhs is an identifier expression and rhs is an anonymous function expression, we need to assign the name of lhs to the function
+ if (auto *f = asAnonymousFunctionDefinition(sym(3).Expression)) {
+ if (auto *id = AST::cast<AST::IdentifierExpression *>(sym(1).Expression))
+ f->name = id->name;
+ }
+ if (auto *c = asAnonymousClassDefinition(sym(3).Expression)) {
+ if (auto *id = AST::cast<AST::IdentifierExpression *>(sym(1).Expression))
+ c->name = id->name;
+ }
+
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Assign, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ;
+AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+AssignmentExpression_In: LeftHandSideExpression AssignmentOperator AssignmentExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression);
+ node->operatorToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ;
+AssignmentOperator: T_STAR_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMul;
+ } break;
./
-RelationalExpression: ShiftExpression ;
+AssignmentOperator: T_STAR_STAR_EQ;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceExp;
+ } break;
+./
-RelationalExpression: RelationalExpression T_LT ShiftExpression ;
+AssignmentOperator: T_DIVIDE_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceDiv;
+ } break;
./
-RelationalExpression: RelationalExpression T_GT ShiftExpression ;
+AssignmentOperator: T_REMAINDER_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceMod;
+ } break;
./
-RelationalExpression: RelationalExpression T_LE ShiftExpression ;
+AssignmentOperator: T_PLUS_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAdd;
+ } break;
./
-RelationalExpression: RelationalExpression T_GE ShiftExpression ;
+AssignmentOperator: T_MINUS_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceSub;
+ } break;
./
-RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ;
+AssignmentOperator: T_LT_LT_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+ } break;
./
-RelationalExpression: RelationalExpression T_IN ShiftExpression ;
+AssignmentOperator: T_GT_GT_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+ } break;
./
-RelationalExpressionNotIn: ShiftExpression ;
+AssignmentOperator: T_GT_GT_GT_EQ;
+/.
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+ } break;
+./
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ;
+AssignmentOperator: T_AND_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceAnd;
+ } break;
./
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ;
+AssignmentOperator: T_XOR_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceXor;
+ } break;
./
-RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ;
+AssignmentOperator: T_OR_EQ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).ival = QSOperator::InplaceOr;
+ } break;
./
-RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ;
+Expression: AssignmentExpression;
+Expression_In: AssignmentExpression_In;
+
+Expression: Expression T_COMMA AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Expression_In: Expression_In T_COMMA AssignmentExpression_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ;
+ExpressionOpt: ;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ExpressionOpt_In: ;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-EqualityExpression: RelationalExpression ;
+ExpressionOpt: Expression;
+ExpressionOpt_In: Expression_In;
-EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ;
+-- Statements
+
+Statement: ExpressionStatementLookahead T_FORCE_BLOCK BlockStatement;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(3).Node;
+ } break;
./
-EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ;
+Statement: ExpressionStatementLookahead VariableStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead EmptyStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead ExpressionStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead IfStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead BreakableStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead ContinueStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead BreakStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead ReturnStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead WithStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead LabelledStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead ThrowStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead TryStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+Statement: ExpressionStatementLookahead DebuggerStatement;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ } break;
./
-EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ;
+Declaration: HoistableDeclaration;
+Declaration: ClassDeclaration;
+Declaration: LexicalDeclaration_In;
+
+HoistableDeclaration: FunctionDeclaration;
+HoistableDeclaration: GeneratorDeclaration;
+
+HoistableDeclaration_Default: FunctionDeclaration_Default;
+HoistableDeclaration_Default: GeneratorDeclaration_Default;
+
+BreakableStatement: IterationStatement;
+BreakableStatement: SwitchStatement;
+
+BlockStatement: Block;
+
+Block: T_LBRACE StatementListOpt T_RBRACE;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ;
+StatementList: StatementListItem;
+
+StatementList: StatementList StatementListItem;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).StatementList = sym(1).StatementList->append(sym(2).StatementList);
+ } break;
./
-EqualityExpressionNotIn: RelationalExpressionNotIn ;
+StatementListItem: Statement;
+/.
+ case $rule_number: {
+ sym(1).StatementList = new (pool) AST::StatementList(sym(1).Statement);
+ } break;
+./
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ;
+StatementListItem: ExpressionStatementLookahead T_FORCE_DECLARATION Declaration T_AUTOMATIC_SEMICOLON;
+StatementListItem: ExpressionStatementLookahead T_FORCE_DECLARATION Declaration T_SEMICOLON;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::StatementList(sym(3).FunctionDeclaration);
+ } break;
./
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn;
+StatementListOpt: ExpressionStatementLookahead;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ;
+StatementListOpt: StatementList;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).StatementList->finish();
+ } break;
./
-EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ;
+LetOrConst: T_LET;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).scope = AST::VariableScope::Let;
+ } break;
+./
+LetOrConst: T_CONST;
+/.
+ case $rule_number: {
+ sym(1).scope = AST::VariableScope::Const;
+ } break;
./
-BitwiseANDExpression: EqualityExpression ;
+Var: T_VAR;
+/.
+ case $rule_number: {
+ sym(1).scope = AST::VariableScope::Var;
+ } break;
+./
-BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ;
+LexicalDeclaration: LetOrConst BindingList;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LexicalDeclaration_In: LetOrConst BindingList_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VarDeclaration: Var VariableDeclarationList;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VarDeclaration_In: Var VariableDeclarationList_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::VariableStatement *node = new (pool) AST::VariableStatement(sym(2).VariableDeclarationList->finish(sym(1).scope));
+ node->declarationKindToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-BitwiseANDExpressionNotIn: EqualityExpressionNotIn ;
+VariableStatement: VarDeclaration_In T_AUTOMATIC_SEMICOLON;
+VariableStatement: VarDeclaration_In T_SEMICOLON;
-BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ;
+BindingList: LexicalBinding_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+BindingList_In: LexicalBinding_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclarationList: VariableDeclaration;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclarationList_In: VariableDeclaration_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).PatternElement);
+ } break;
./
-BitwiseXORExpression: BitwiseANDExpression ;
-
-BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ;
+BindingList: BindingList T_COMMA LexicalBinding;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+BindingList_In: BindingList_In T_COMMA LexicalBinding_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclarationList_In: VariableDeclarationList_In T_COMMA VariableDeclaration_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).PatternElement);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ;
+LexicalBinding: BindingIdentifier InitializerOpt;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LexicalBinding_In: BindingIdentifier InitializerOpt_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclaration: BindingIdentifier InitializerOpt;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclaration_In: BindingIdentifier InitializerOpt_In;
+/.
+ case $rule_number: {
+ auto *node = new (pool) AST::PatternElement(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+ // if initializer is an anonymous function expression, we need to assign identifierref as it's name
+ if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression))
+ f->name = stringRef(1);
+ if (auto *c = asAnonymousClassDefinition(sym(2).Expression))
+ c->name = stringRef(1);
+ } break;
+./
-BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ;
+LexicalBinding: BindingPattern Initializer;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+LexicalBinding_In: BindingPattern Initializer_In;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclaration: BindingPattern Initializer;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+VariableDeclaration_In: BindingPattern Initializer_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ auto *node = new (pool) AST::PatternElement(sym(1).Pattern, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-BitwiseORExpression: BitwiseXORExpression ;
+BindingPattern: T_LBRACE ObjectBindingPattern T_RBRACE;
+/.
+ case $rule_number: {
+ auto *node = new (pool) AST::ObjectPattern(sym(2).PatternPropertyList);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ node->parseMode = AST::Pattern::Binding;
+ sym(1).Node = node;
+ } break;
+./
-BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ;
+BindingPattern: T_LBRACKET ArrayBindingPattern T_RBRACKET;
+/.
+ case $rule_number: {
+ auto *node = new (pool) AST::ArrayPattern(sym(2).PatternElementList);
+ node->lbracketToken = loc(1);
+ node->rbracketToken = loc(3);
+ node->parseMode = AST::Pattern::Binding;
+ sym(1).Node = node;
+ } break;
+./
+
+ObjectBindingPattern: ;
+/.
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
+./
+
+ObjectBindingPattern: BindingPropertyList;
+/. case $rule_number: ./
+ObjectBindingPattern: BindingPropertyList T_COMMA;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).PatternPropertyList->finish();
+ } break;
+./
+
+ArrayBindingPattern: ElisionOpt BindingRestElementOpt;
+/.
+ case $rule_number: {
+ if (sym(1).Elision || sym(2).Node) {
+ auto *l = new (pool) AST::PatternElementList(sym(1).Elision, sym(2).PatternElement);
+ sym(1).Node = l->finish();
+ } else {
+ sym(1).Node = nullptr;
+ }
+ } break;
./
-BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ;
+ArrayBindingPattern: BindingElementList;
+/.
+ case $rule_number: {
+ sym(1).Node = sym(1).PatternElementList->finish();
+ } break;
+./
-BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ;
+ArrayBindingPattern: BindingElementList T_COMMA ElisionOpt BindingRestElementOpt;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (sym(3).Elision || sym(4).Node) {
+ auto *l = new (pool) AST::PatternElementList(sym(3).Elision, sym(4).PatternElement);
+ l = sym(1).PatternElementList->append(l);
+ sym(1).Node = l;
+ }
+ sym(1).Node = sym(1).PatternElementList->finish();
+ } break;
./
-LogicalANDExpression: BitwiseORExpression ;
+BindingPropertyList: BindingProperty;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::PatternPropertyList(sym(1).PatternProperty);
+ } break;
+./
-LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ;
+BindingPropertyList: BindingPropertyList T_COMMA BindingProperty;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::PatternPropertyList(sym(1).PatternPropertyList, sym(3).PatternProperty);
+ } break;
./
-LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ;
+BindingElementList: BindingElisionElement;
-LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ;
+BindingElementList: BindingElementList T_COMMA BindingElisionElement;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).PatternElementList = sym(1).PatternElementList->append(sym(3).PatternElementList);
+ } break;
./
-LogicalORExpression: LogicalANDExpression ;
-
-LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ;
+BindingElisionElement: ElisionOpt BindingElement;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::PatternElementList(sym(1).Elision, sym(2).PatternElement);
+ } break;
./
-LogicalORExpressionNotIn: LogicalANDExpressionNotIn ;
-LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ;
+BindingProperty: BindingIdentifier InitializerOpt_In;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::StringLiteralPropertyName *name = new (pool) AST::StringLiteralPropertyName(stringRef(1));
+ name->propertyNameToken = loc(1);
+ // if initializer is an anonymous function expression, we need to assign identifierref as it's name
+ if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression))
+ f->name = stringRef(1);
+ if (auto *c = asAnonymousClassDefinition(sym(2).Expression))
+ c->name = stringRef(1);
+ sym(1).Node = new (pool) AST::PatternProperty(name, stringRef(1), sym(2).Expression);
+ } break;
./
-ConditionalExpression: LogicalORExpression ;
+BindingProperty: PropertyName T_COLON BindingIdentifier InitializerOpt_In;
+/.
+ case $rule_number: {
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(1).PropertyName, stringRef(3), sym(4).Expression);
+ sym(1).Node = node;
+ } break;
+./
-ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ;
+BindingProperty: PropertyName T_COLON BindingPattern InitializerOpt_In;
/.
-case $rule_number: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(1).PropertyName, sym(3).Pattern, sym(4).Expression);
+ sym(1).Node = node;
+ } break;
./
-ConditionalExpressionNotIn: LogicalORExpressionNotIn ;
+BindingElement: BindingIdentifier InitializerOpt_In;
+/.
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(stringRef(1), sym(2).Expression);
+ node->identifierToken = loc(1);
+ // if initializer is an anonymous function expression, we need to assign identifierref as it's name
+ if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression))
+ f->name = stringRef(1);
+ if (auto *c = asAnonymousClassDefinition(sym(2).Expression))
+ c->name = stringRef(1);
+ sym(1).Node = node;
+ } break;
+./
-ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ;
+BindingElement: BindingPattern InitializerOpt_In;
/.
-case $rule_number: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(sym(1).Pattern, sym(2).Expression);
+ sym(1).Node = node;
+ } break;
./
-AssignmentExpression: ConditionalExpression ;
+BindingRestElement: T_ELLIPSIS BindingIdentifier;
+/.
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(stringRef(2), nullptr, AST::PatternElement::RestElement);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
-AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ;
+BindingRestElement: T_ELLIPSIS BindingPattern;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(sym(2).Pattern, nullptr, AST::PatternElement::RestElement);
+ sym(1).Node = node;
+ } break;
+./
+
+BindingRestElementOpt: ;
+/.
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-AssignmentExpressionNotIn: ConditionalExpressionNotIn ;
+BindingRestElementOpt: BindingRestElement;
-AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ;
+
+EmptyStatement: T_SEMICOLON;
/.
-case $rule_number: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_EQ ;
+-- Spec says it should have a "[lookahead ∉ { {, function, class, let [ }]" before the Expression statement.
+-- This is implemented with the rule below that is run before any statement and inserts a T_EXPRESSION_STATEMENT_OK
+-- token if it's ok to parse as an expression statement.
+ExpressionStatementLookahead: ;
+/:
+#define J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE $rule_number
+:/
/.
-case $rule_number: {
- sym(1).ival = QSOperator::Assign;
-} break;
+ case $rule_number: {
+ int token = lookaheadToken(lexer);
+ if (token == T_LBRACE)
+ pushToken(T_FORCE_BLOCK);
+ else if (token == T_FUNCTION || token == T_CLASS || token == T_LET || token == T_CONST)
+ pushToken(T_FORCE_DECLARATION);
+ } break;
./
-AssignmentOperator: T_STAR_EQ ;
+ExpressionStatement: Expression_In T_AUTOMATIC_SEMICOLON;
+ExpressionStatement: Expression_In T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
+ case $rule_number: {
+ AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_DIVIDE_EQ ;
+IfStatement: T_IF T_LPAREN Expression_In T_RPAREN Statement T_ELSE Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
+ case $rule_number: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->elseToken = loc(6);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_REMAINDER_EQ ;
+IfStatement: T_IF T_LPAREN Expression_In T_RPAREN Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
+ case $rule_number: {
+ AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
+ node->ifToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_PLUS_EQ ;
+
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression_In T_RPAREN T_AUTOMATIC_SEMICOLON;
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression_In T_RPAREN T_COMPATIBILITY_SEMICOLON; -- for JSC/V8 compatibility
+IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression_In T_RPAREN T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
+ case $rule_number: {
+ AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
+ node->doToken = loc(1);
+ node->whileToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->semicolonToken = loc(7);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_MINUS_EQ ;
+IterationStatement: T_WHILE T_LPAREN Expression_In T_RPAREN Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
+ case $rule_number: {
+ AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
+ node->whileToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_LT_LT_EQ ;
+IterationStatement: T_FOR T_LPAREN ExpressionOpt T_SEMICOLON ExpressionOpt_In T_SEMICOLON ExpressionOpt_In T_RPAREN Statement; -- [lookahead != { let [ }]
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
+ case $rule_number: {
+ AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_GT_GT_EQ ;
+IterationStatement: T_FOR T_LPAREN VarDeclaration T_SEMICOLON ExpressionOpt_In T_SEMICOLON ExpressionOpt_In T_RPAREN Statement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+IterationStatement: T_FOR T_LPAREN LexicalDeclaration T_SEMICOLON ExpressionOpt_In T_SEMICOLON ExpressionOpt_In T_RPAREN Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
+ case $rule_number: {
+ // ### get rid of the static_cast!
+ AST::ForStatement *node = new (pool) AST::ForStatement(
+ static_cast<AST::VariableStatement *>(sym(3).Node)->declarations, sym(5).Expression,
+ sym(7).Expression, sym(9).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->firstSemicolonToken = loc(4);
+ node->secondSemicolonToken = loc(6);
+ node->rparenToken = loc(8);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_GT_GT_GT_EQ ;
+InOrOf: T_IN;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
+ case $rule_number: {
+ sym(1).forEachType = AST::ForEachType::In;
+ } break;
./
-AssignmentOperator: T_AND_EQ ;
+InOrOf: T_OF;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
+ case $rule_number: {
+ sym(1).forEachType = AST::ForEachType::Of;
+ } break;
./
-AssignmentOperator: T_XOR_EQ ;
+IterationStatement: T_FOR T_LPAREN LeftHandSideExpression InOrOf Expression_In T_RPAREN Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
+ case $rule_number: {
+ // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
+ if (AST::Pattern *p = sym(3).Expression->patternCast()) {
+ AST::SourceLocation errorLoc;
+ QString errorMsg;
+ if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
+ syntaxError(errorLoc, errorMsg);
+ return false;
+ }
+ }
+ AST::ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inOfToken = loc(4);
+ node->rparenToken = loc(6);
+ node->type = sym(4).forEachType;
+ sym(1).Node = node;
+ } break;
+./
+
+IterationStatement: T_FOR T_LPAREN ForDeclaration InOrOf Expression_In T_RPAREN Statement;
+/.
+ case $rule_number: {
+ AST::ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).PatternElement, sym(5).Expression, sym(7).Statement);
+ node->forToken = loc(1);
+ node->lparenToken = loc(2);
+ node->inOfToken = loc(4);
+ node->rparenToken = loc(6);
+ node->type = sym(4).forEachType;
+ sym(1).Node = node;
+ } break;
+./
+
+ForDeclaration: LetOrConst BindingIdentifier;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ForDeclaration: Var BindingIdentifier;
+/.
+ case $rule_number: {
+ auto *node = new (pool) AST::PatternElement(stringRef(2), nullptr);
+ node->identifierToken = loc(2);
+ node->scope = sym(1).scope;
+ node->isForDeclaration = true;
+ sym(1).Node = node;
+ } break;
+./
+
+ForDeclaration: LetOrConst BindingPattern;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ForDeclaration: Var BindingPattern;
+/.
+ case $rule_number: {
+ auto *node = new (pool) AST::PatternElement(sym(2).Pattern, nullptr);
+ node->scope = sym(1).scope;
+ node->isForDeclaration = true;
+ sym(1).Node = node;
+ } break;
+./
+
+ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON;
+ContinueStatement: T_CONTINUE T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+ContinueStatement: T_CONTINUE IdentifierReference T_AUTOMATIC_SEMICOLON;
+ContinueStatement: T_CONTINUE IdentifierReference T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
+ node->continueToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
+
+BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON;
+BreakStatement: T_BREAK T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+BreakStatement: T_BREAK IdentifierReference T_AUTOMATIC_SEMICOLON;
+BreakStatement: T_BREAK IdentifierReference T_SEMICOLON;
+/.
+ case $rule_number: {
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
+ node->breakToken = loc(1);
+ node->identifierToken = loc(2);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
+
+ReturnStatement: T_RETURN ExpressionOpt_In T_AUTOMATIC_SEMICOLON;
+ReturnStatement: T_RETURN ExpressionOpt_In T_SEMICOLON;
+/.
+ case $rule_number: {
+ if (!functionNestingLevel) {
+ syntaxError(loc(1), "Return statement not allowed outside of Function declaration.");
+ return false;
+ }
+ AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
+ node->returnToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-AssignmentOperator: T_OR_EQ ;
+WithStatement: T_WITH T_LPAREN Expression_In T_RPAREN Statement;
/.
-case $rule_number: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
+ case $rule_number: {
+ AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
+ node->withToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-Expression: AssignmentExpression ;
+SwitchStatement: T_SWITCH T_LPAREN Expression_In T_RPAREN CaseBlock;
+/.
+ case $rule_number: {
+ AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
+ node->switchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
+./
-Expression: Expression T_COMMA AssignmentExpression ;
+CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE;
/.
-case $rule_number: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-ExpressionOpt: ;
+CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
+ node->lbraceToken = loc(1);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-ExpressionOpt: Expression ;
+CaseClauses: CaseClause;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
+ } break;
+./
-ExpressionNotIn: AssignmentExpressionNotIn ;
+CaseClauses: CaseClauses CaseClause;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
+ } break;
+./
-ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ;
+CaseClausesOpt: ;
/.
-case $rule_number: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-ExpressionNotInOpt: ;
+CaseClausesOpt: CaseClauses;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).CaseClauses->finish();
+ } break;
./
-ExpressionNotInOpt: ExpressionNotIn ;
+CaseClause: T_CASE Expression_In T_COLON StatementListOpt;
+/.
+ case $rule_number: {
+ AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
+ node->caseToken = loc(1);
+ node->colonToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
-Statement: Block ;
-Statement: VariableStatement ;
-Statement: EmptyStatement ;
-Statement: ExpressionStatement ;
-Statement: IfStatement ;
-Statement: IterationStatement ;
-Statement: ContinueStatement ;
-Statement: BreakStatement ;
-Statement: ReturnStatement ;
-Statement: WithStatement ;
-Statement: LabelledStatement ;
-Statement: SwitchStatement ;
-Statement: ThrowStatement ;
-Statement: TryStatement ;
-Statement: DebuggerStatement ;
+DefaultClause: T_DEFAULT T_COLON StatementListOpt;
+/.
+ case $rule_number: {
+ AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
+ node->defaultToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+LabelledStatement: IdentifierReference T_COLON LabelledItem;
+/.
+ case $rule_number: {
+ AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
+ node->identifierToken = loc(1);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+LabelledItem: Statement;
-Block: T_LBRACE StatementListOpt T_RBRACE ;
+LabelledItem: ExpressionStatementLookahead T_FORCE_DECLARATION FunctionDeclaration;
/.
-case $rule_number: {
- AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ syntaxError(loc(3), "FunctionDeclarations are not allowed after a label.");
+ return false;
+ } break;
./
-StatementList: Statement ;
+ThrowStatement: T_THROW Expression_In T_AUTOMATIC_SEMICOLON;
+ThrowStatement: T_THROW Expression_In T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
-} break;
+ case $rule_number: {
+ AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
+ node->throwToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
./
-StatementList: StatementList Statement ;
+TryStatement: T_TRY Block Catch;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
-} break;
+ case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-StatementListOpt: ;
+TryStatement: T_TRY Block Finally;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-StatementListOpt: StatementList ;
+TryStatement: T_TRY Block Catch Finally;
/.
-case $rule_number: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
+ case $rule_number: {
+ AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ;
+Catch: T_CATCH T_LPAREN CatchParameter T_RPAREN Block;
/.
-case $rule_number: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- if (sym(1).ival == T_LET)
- s = AST::VariableDeclaration::BlockScope;
- else if (sym(1).ival == T_CONST)
- s = AST::VariableDeclaration::ReadOnlyBlockScope;
-
- AST::VariableStatement *node = new (pool) AST::VariableStatement(sym(2).VariableDeclarationList->finish(s));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::Catch *node = new (pool) AST::Catch(sym(3).PatternElement, sym(5).Block);
+ node->catchToken = loc(1);
+ node->lparenToken = loc(2);
+ node->identifierToken = loc(3);
+ node->rparenToken = loc(4);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationKind: T_LET ;
+Finally: T_FINALLY Block;
/.
-case $rule_number: {
- sym(1).ival = T_LET;
-} break;
+ case $rule_number: {
+ AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationKind: T_CONST ;
+CatchParameter: BindingIdentifier;
/.
-case $rule_number: {
- sym(1).ival = T_CONST;
-} break;
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(stringRef(1));
+ node->identifierToken = loc(1);
+ node->scope = AST::VariableScope::Let;
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationKind: T_VAR ;
+CatchParameter: BindingPattern;
/.
-case $rule_number: {
- sym(1).ival = T_VAR;
-} break;
+ case $rule_number: {
+ AST::PatternElement *node = new (pool) AST::PatternElement(sym(1).Pattern);
+ node->scope = AST::VariableScope::Let;
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationList: VariableDeclaration ;
+DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON; -- automatic semicolon
+DebuggerStatement: T_DEBUGGER T_SEMICOLON;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
+ case $rule_number: {
+ AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ;
+-- tell the parser to prefer function declarations to function expressions.
+-- That is, the `Function' symbol is used to mark the start of a function
+-- declaration.
+-- This is still required for parsing QML, where MemberExpression and FunctionDeclaration would
+-- otherwise conflict.
+Function: T_FUNCTION %prec REDUCE_HERE;
+
+FunctionDeclaration: Function BindingIdentifier T_LPAREN FormalParameters T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationListNotIn: VariableDeclarationNotIn ;
+
+FunctionDeclaration_Default: FunctionDeclaration;
+FunctionDeclaration_Default: Function T_LPAREN FormalParameters T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
+ case $rule_number: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
+ node->functionToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->lbraceToken = loc(5);
+ node->rbraceToken = loc(7);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ;
+FunctionExpression: T_FUNCTION BindingIdentifier T_LPAREN FormalParameters T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
+ node->functionToken = loc(1);
+ if (! stringRef(2).isNull())
+ node->identifierToken = loc(2);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclaration: JsIdentifier InitialiserOpt ;
+FunctionExpression: T_FUNCTION T_LPAREN FormalParameters T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression, s);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
+ node->functionToken = loc(1);
+ node->lparenToken = loc(2);
+ node->rparenToken = loc(4);
+ node->lbraceToken = loc(5);
+ node->rbraceToken = loc(7);
+ sym(1).Node = node;
+ } break;
./
-VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ;
+StrictFormalParameters: FormalParameters;
+
+FormalParameters: ;
/.
-case $rule_number: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression, s);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-Initialiser: T_EQ AssignmentExpression ;
+FormalParameters: BindingRestElement;
/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
+ case $rule_number: {
+ AST::FormalParameterList *node = (new (pool) AST::FormalParameterList(nullptr, sym(1).PatternElement))->finish(pool);
+ sym(1).Node = node;
+ } break;
./
-InitialiserOpt: ;
+FormalParameters: FormalParameterList;
+/. case $rule_number: ./
+FormalParameters: FormalParameterList T_COMMA;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(1).FormalParameterList->finish(pool);
+ } break;
./
-InitialiserOpt: Initialiser ;
+FormalParameters: FormalParameterList T_COMMA BindingRestElement;
+/.
+ case $rule_number: {
+ AST::FormalParameterList *node = (new (pool) AST::FormalParameterList(sym(1).FormalParameterList, sym(3).PatternElement))->finish(pool);
+ sym(1).Node = node;
+ } break;
+./
-InitialiserNotIn: T_EQ AssignmentExpressionNotIn ;
+FormalParameterList: BindingElement;
/.
-case $rule_number: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
+ case $rule_number: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(nullptr, sym(1).PatternElement);
+ sym(1).Node = node;
+ } break;
./
-InitialiserNotInOpt: ;
+
+FormalParameterList: FormalParameterList T_COMMA BindingElement;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, sym(3).PatternElement);
+ sym(1).Node = node;
+ } break;
./
-InitialiserNotInOpt: InitialiserNotIn ;
+FormalParameter: BindingElement;
-EmptyStatement: T_SEMICOLON ;
+FunctionLBrace: T_LBRACE;
/.
-case $rule_number: {
- AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ ++functionNestingLevel;
+ } break;
./
-ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ExpressionStatement: Expression T_SEMICOLON ;
+FunctionRBrace: T_RBRACE;
/.
-case $rule_number: {
- AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ --functionNestingLevel;
+ } break;
./
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ;
+
+FunctionBody: StatementListOpt;
+
+ArrowFunction: ArrowParameters T_ARROW ConciseBodyLookahead AssignmentExpression; -- [lookahead ≠ {]
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead AssignmentExpression_In; -- [lookahead ≠ {]
/.
-case $rule_number: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(6);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ReturnStatement *ret = new (pool) AST::ReturnStatement(sym(4).Expression);
+ ret->returnToken = sym(4).Node->firstSourceLocation();
+ ret->semicolonToken = sym(4).Node->lastSourceLocation();
+ AST::StatementList *statements = (new (pool) AST::StatementList(ret))->finish();
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, statements);
+ f->isArrowFunction = true;
+ f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
+ f->lbraceToken = sym(4).Node->firstSourceLocation();
+ f->rbraceToken = sym(4).Node->lastSourceLocation();
+ sym(1).Node = f;
+ } break;
./
-IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ;
+ArrowFunction: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK FunctionLBrace FunctionBody FunctionRBrace;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, sym(6).StatementList);
+ f->isArrowFunction = true;
+ f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
+ f->lbraceToken = loc(6);
+ f->rbraceToken = loc(7);
+ sym(1).Node = f;
+ } break;
./
+ArrowParameters: BindingIdentifier;
+/.
+ case $rule_number: {
+ AST::PatternElement *e = new (pool) AST::PatternElement(stringRef(1), nullptr, AST::PatternElement::Binding);
+ e->identifierToken = loc(1);
+ sym(1).FormalParameterList = (new (pool) AST::FormalParameterList(nullptr, e))->finish(pool);
+ } break;
+./
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_COMPATIBILITY_SEMICOLON ; -- for JSC/V8 compatibility
-IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ;
+-- CoverParenthesizedExpressionAndArrowParameterList for ArrowParameters i being refined to:
+-- ArrowFormalParameters: T_LPAREN StrictFormalParameters T_RPAREN
+ArrowParameters: CoverParenthesizedExpressionAndArrowParameterList;
/.
-case $rule_number: {
- AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (coverExpressionType != CE_FormalParameterList) {
+ AST::NestedExpression *ne = static_cast<AST::NestedExpression *>(sym(1).Node);
+ AST::FormalParameterList *list = ne->expression->reparseAsFormalParameterList(pool);
+ if (!list) {
+ syntaxError(loc(1), "Invalid Arrow parameter list.");
+ return false;
+ }
+ sym(1).Node = list->finish(pool);
+ }
+ } break;
./
-IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ;
+ConciseBodyLookahead: ;
+/:
+#define J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE $rule_number
+:/
/.
-case $rule_number: {
- AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (lookaheadToken(lexer) == T_LBRACE)
+ pushToken(T_FORCE_BLOCK);
+ } break;
./
-IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+MethodDefinition: PropertyName T_LPAREN StrictFormalParameters T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(stringRef(1), sym(3).FormalParameterList, sym(6).StatementList);
+ f->functionToken = sym(1).PropertyName->firstSourceLocation();
+ f->lparenToken = loc(2);
+ f->rparenToken = loc(4);
+ f->lbraceToken = loc(5);
+ f->rbraceToken = loc(7);
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(1).PropertyName, f, AST::PatternProperty::Method);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ;
+MethodDefinition: T_STAR PropertyName GeneratorLParen StrictFormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
-case $rule_number: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
- sym(4).VariableDeclarationList->finish(s), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
+ f->functionToken = sym(2).PropertyName->firstSourceLocation();
+ f->lparenToken = loc(3);
+ f->rparenToken = loc(5);
+ f->lbraceToken = loc(6);
+ f->rbraceToken = loc(8);
+ f->isGenerator = true;
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(2).PropertyName, f, AST::PatternProperty::Method);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+
+MethodDefinition: T_GET PropertyName T_LPAREN T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
+/.
+ case $rule_number: {
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(stringRef(2), nullptr, sym(6).StatementList);
+ f->functionToken = sym(2).PropertyName->firstSourceLocation();
+ f->lparenToken = loc(3);
+ f->rparenToken = loc(4);
+ f->lbraceToken = loc(5);
+ f->rbraceToken = loc(7);
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(2).PropertyName, f, AST::PatternProperty::Getter);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ;
+MethodDefinition: T_SET PropertyName T_LPAREN PropertySetParameterList T_RPAREN FunctionLBrace FunctionBody FunctionRBrace;
/.
-case $rule_number: {
- AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).StatementList);
+ f->functionToken = sym(2).PropertyName->firstSourceLocation();
+ f->lparenToken = loc(3);
+ f->rparenToken = loc(5);
+ f->lbraceToken = loc(6);
+ f->rbraceToken = loc(8);
+ AST::PatternProperty *node = new (pool) AST::PatternProperty(sym(2).PropertyName, f, AST::PatternProperty::Setter);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+ } break;
./
-IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ;
+
+PropertySetParameterList: FormalParameter;
/.
-case $rule_number: {
- AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FormalParameterList *node = (new (pool) AST::FormalParameterList(nullptr, sym(1).PatternElement))->finish(pool);
+ sym(1).Node = node;
+ } break;
./
-ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE T_SEMICOLON ;
+GeneratorLParen: T_LPAREN;
/.
-case $rule_number: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ lexer->enterGeneratorBody();
+ } break;
./
-ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ;
+GeneratorRBrace: T_RBRACE;
/.
-case $rule_number: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ --functionNestingLevel;
+ lexer->leaveGeneratorBody();
+ } break;
./
-BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK T_SEMICOLON ;
+GeneratorDeclaration: Function T_STAR BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
-case $rule_number: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(3), sym(5).FormalParameterList, sym(8).StatementList);
+ node->functionToken = loc(1);
+ node->identifierToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->lbraceToken = loc(7);
+ node->rbraceToken = loc(9);
+ node->isGenerator = true;
+ sym(1).Node = node;
+ } break;
./
-BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ;
+GeneratorDeclaration_Default: GeneratorDeclaration;
+GeneratorDeclaration_Default: Function T_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
+/.
+ case $rule_number: {
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(4).FormalParameterList, sym(7).StatementList);
+ node->functionToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ node->isGenerator = true;
+ sym(1).Node = node;
+ } break;
+./
+
+GeneratorExpression: T_FUNCTION T_STAR BindingIdentifier GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
-case $rule_number: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(3), sym(5).FormalParameterList, sym(8).StatementList);
+ node->functionToken = loc(1);
+ if (!stringRef(3).isNull())
+ node->identifierToken = loc(3);
+ node->lparenToken = loc(4);
+ node->rparenToken = loc(6);
+ node->lbraceToken = loc(7);
+ node->rbraceToken = loc(9);
+ node->isGenerator = true;
+ sym(1).Node = node;
+ } break;
./
-ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ;
+GeneratorExpression: T_FUNCTION T_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
-case $rule_number: {
- AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(4).FormalParameterList, sym(7).StatementList);
+ node->functionToken = loc(1);
+ node->lparenToken = loc(3);
+ node->rparenToken = loc(5);
+ node->lbraceToken = loc(6);
+ node->rbraceToken = loc(8);
+ node->isGenerator = true;
+ sym(1).Node = node;
+ } break;
./
-WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ;
+GeneratorBody: FunctionBody;
+
+YieldExpression: T_YIELD;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+YieldExpression_In: T_YIELD;
/.
-case $rule_number: {
- AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::YieldExpression *node = new (pool) AST::YieldExpression();
+ node->yieldToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ;
+YieldExpression: T_YIELD T_STAR AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+YieldExpression_In: T_YIELD T_STAR AssignmentExpression_In;
/.
-case $rule_number: {
- AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::YieldExpression *node = new (pool) AST::YieldExpression(sym(3).Expression);
+ node->yieldToken = loc(1);
+ node->isYieldStar = true;
+ sym(1).Node = node;
+ } break;
./
-CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ;
+YieldExpression: T_YIELD AssignmentExpression;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+YieldExpression_In: T_YIELD AssignmentExpression_In;
/.
-case $rule_number: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::YieldExpression *node = new (pool) AST::YieldExpression(sym(2).Expression);
+ node->yieldToken = loc(1);
+ sym(1).Node = node;
+ } break;
./
-CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ;
+
+ClassDeclaration: T_CLASS BindingIdentifier ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
-case $rule_number: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(stringRef(2), sym(3).Expression, sym(5).ClassElementList);
+ node->classToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lbraceToken = loc(4);
+ node->rbraceToken = loc(6);
+ sym(1).Node = node;
+ } break;
./
-CaseClauses: CaseClause ;
+ClassExpression: T_CLASS BindingIdentifier ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
-} break;
+ case $rule_number: {
+ AST::ClassExpression *node = new (pool) AST::ClassExpression(stringRef(2), sym(3).Expression, sym(5).ClassElementList);
+ node->classToken = loc(1);
+ node->identifierToken = loc(2);
+ node->lbraceToken = loc(4);
+ node->rbraceToken = loc(6);
+ sym(1).Node = node;
+ } break;
./
-CaseClauses: CaseClauses CaseClause ;
+ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
-} break;
+ case $rule_number: {
+ AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
+ node->classToken = loc(1);
+ node->lbraceToken = loc(3);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-CaseClausesOpt: ;
+ClassExpression: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ AST::ClassExpression *node = new (pool) AST::ClassExpression(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
+ node->classToken = loc(1);
+ node->lbraceToken = loc(3);
+ node->rbraceToken = loc(5);
+ sym(1).Node = node;
+ } break;
./
-CaseClausesOpt: CaseClauses ;
+ClassDeclaration_Default: ClassDeclaration;
+
+ClassLBrace: T_LBRACE;
/.
-case $rule_number: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
+ case $rule_number: {
+ lexer->setStaticIsKeyword(true);
+ } break;
./
-CaseClause: T_CASE Expression T_COLON StatementListOpt ;
+ClassRBrace: T_RBRACE;
+/. case $rule_number: ./
+ClassStaticQualifier: T_STATIC;
/.
-case $rule_number: {
- AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ lexer->setStaticIsKeyword(false);
+ } break;
./
-DefaultClause: T_DEFAULT T_COLON StatementListOpt ;
+ClassHeritageOpt: ;
/.
-case $rule_number: {
- AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-LabelledStatement: JsIdentifier T_COLON Statement ;
+ClassHeritageOpt: T_EXTENDS LeftHandSideExpression;
/.
-case $rule_number: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ } break;
./
-ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-ThrowStatement: T_THROW Expression T_SEMICOLON ;
+ClassBodyOpt: ;
/.
-case $rule_number: {
- AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-TryStatement: T_TRY Block Catch ;
+ClassBodyOpt: ClassElementList;
/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (sym(1).Node)
+ sym(1).Node = sym(1).ClassElementList->finish();
+ } break;
./
-TryStatement: T_TRY Block Finally ;
+ClassElementList: ClassElement;
+
+ClassElementList: ClassElementList ClassElement;
/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ if (sym(2).Node)
+ sym(1).ClassElementList = sym(1).ClassElementList->append(sym(2).ClassElementList);
+ } break;
./
-TryStatement: T_TRY Block Catch Finally ;
+ClassElement: MethodDefinition;
/.
-case $rule_number: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ AST::ClassElementList *node = new (pool) AST::ClassElementList(sym(1).PatternProperty, false);
+ sym(1).Node = node;
+ } break;
./
-Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ;
+ClassElement: ClassStaticQualifier MethodDefinition;
/.
-case $rule_number: {
- AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ lexer->setStaticIsKeyword(true);
+ AST::ClassElementList *node = new (pool) AST::ClassElementList(sym(2).PatternProperty, true);
+ sym(1).Node = node;
+ } break;
./
-Finally: T_FINALLY Block ;
+ClassElement: T_SEMICOLON;
/.
-case $rule_number: {
- AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
-DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-DebuggerStatement: T_DEBUGGER T_SEMICOLON ;
+-- Scripts and Modules
+
+Script: ;
/.
-case $rule_number: {
- AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = nullptr;
+ } break;
./
--- tell the parser to prefer function declarations to function expressions.
--- That is, the `Function' symbol is used to mark the start of a function
--- declaration.
-Function: T_FUNCTION %prec REDUCE_HERE ;
+Script: ScriptBody;
-FunctionDeclaration: Function JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+ScriptBody: StatementList;
/.
-case $rule_number: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::Program(sym(1).StatementList->finish());
+ } break;
./
-FunctionExpression: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+Module: ModuleBodyOpt;
+/. case $rule_number: {
+ sym(1).Node = new (pool) AST::ESModule(sym(1).StatementList);
+ } break;
+./
+
+ModuleBody: ModuleItemList;
/.
-case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (! stringRef(2).isNull())
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).StatementList = sym(1).StatementList->finish();
+ } break;
./
-FunctionExpression: T_FUNCTION T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ;
+ModuleBodyOpt: ;
/.
-case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody);
- node->functionToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->lbraceToken = loc(5);
- node->rbraceToken = loc(7);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).StatementList = nullptr;
+ } break;
./
+ModuleBodyOpt: ModuleBody;
+
+ModuleItemList: ModuleItem;
-FormalParameterList: JsIdentifier ;
+ModuleItemList: ModuleItemList ModuleItem;
/.
-case $rule_number: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).StatementList = sym(1).StatementList->append(sym(2).StatementList);
+ } break;
./
-FormalParameterList: FormalParameterList T_COMMA JsIdentifier ;
+ModuleItem: ImportDeclaration T_AUTOMATIC_SEMICOLON;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ModuleItem: ImportDeclaration T_SEMICOLON;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ModuleItem: ExportDeclaration T_AUTOMATIC_SEMICOLON;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ModuleItem: ExportDeclaration T_SEMICOLON;
/.
-case $rule_number: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
+ case $rule_number: {
+ sym(1).StatementList = new (pool) AST::StatementList(sym(1).Node);
+ } break;
./
-FormalParameterListOpt: ;
+ModuleItem: StatementListItem;
+
+ImportDeclaration: T_IMPORT ImportClause FromClause;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ auto decl = new (pool) AST::ImportDeclaration(sym(2).ImportClause, sym(3).FromClause);
+ decl->importToken = loc(1);
+ sym(1).Node = decl;
+ } break;
+./
+ImportDeclaration: T_IMPORT ModuleSpecifier;
+/.
+ case $rule_number: {
+ auto decl = new (pool) AST::ImportDeclaration(stringRef(2));
+ decl->importToken = loc(1);
+ decl->moduleSpecifierToken = loc(2);
+ sym(1).Node = decl;
+ } break;
./
-FormalParameterListOpt: FormalParameterList ;
+ImportClause: ImportedDefaultBinding;
/.
-case $rule_number: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
+ case $rule_number: {
+ auto clause = new (pool) AST::ImportClause(stringRef(1));
+ clause->importedDefaultBindingToken = loc(1);
+ sym(1).ImportClause = clause;
+ } break;
+./
+ImportClause: NameSpaceImport;
+/.
+ case $rule_number: {
+ sym(1).ImportClause = new (pool) AST::ImportClause(sym(1).NameSpaceImport);
+ } break;
+./
+ImportClause: NamedImports;
+/.
+ case $rule_number: {
+ sym(1).ImportClause = new (pool) AST::ImportClause(sym(1).NamedImports);
+ } break;
+./
+ImportClause: ImportedDefaultBinding T_COMMA NameSpaceImport;
+/.
+ case $rule_number: {
+ auto importClause = new (pool) AST::ImportClause(stringRef(1), sym(3).NameSpaceImport);
+ importClause->importedDefaultBindingToken = loc(1);
+ sym(1).ImportClause = importClause;
+ } break;
+./
+ImportClause: ImportedDefaultBinding T_COMMA NamedImports;
+/.
+ case $rule_number: {
+ auto importClause = new (pool) AST::ImportClause(stringRef(1), sym(3).NamedImports);
+ importClause->importedDefaultBindingToken = loc(1);
+ sym(1).ImportClause = importClause;
+ } break;
./
-FunctionBodyOpt: ;
+ImportedDefaultBinding: ImportedBinding;
+
+NameSpaceImport: T_STAR T_AS ImportedBinding;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ auto import = new (pool) AST::NameSpaceImport(stringRef(3));
+ import->starToken = loc(1);
+ import->importedBindingToken = loc(3);
+ sym(1).NameSpaceImport = import;
+ } break;
./
-FunctionBodyOpt: FunctionBody ;
+NamedImports: T_LBRACE T_RBRACE;
+/.
+ case $rule_number: {
+ auto namedImports = new (pool) AST::NamedImports();
+ namedImports->leftBraceToken = loc(1);
+ namedImports->rightBraceToken = loc(2);
+ sym(1).NamedImports = namedImports;
+ } break;
+./
+NamedImports: T_LBRACE ImportsList T_RBRACE;
+/.
+ case $rule_number: {
+ auto namedImports = new (pool) AST::NamedImports(sym(2).ImportsList->finish());
+ namedImports->leftBraceToken = loc(1);
+ namedImports->rightBraceToken = loc(3);
+ sym(1).NamedImports = namedImports;
+ } break;
+./
+NamedImports: T_LBRACE ImportsList T_COMMA T_RBRACE;
+/.
+ case $rule_number: {
+ auto namedImports = new (pool) AST::NamedImports(sym(2).ImportsList->finish());
+ namedImports->leftBraceToken = loc(1);
+ namedImports->rightBraceToken = loc(4);
+ sym(1).NamedImports = namedImports;
+ } break;
+./
-FunctionBody: SourceElements ;
+FromClause: T_FROM ModuleSpecifier;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
-} break;
+ case $rule_number: {
+ auto clause = new (pool) AST::FromClause(stringRef(2));
+ clause->fromToken = loc(1);
+ clause->moduleSpecifierToken = loc(2);
+ sym(1).FromClause = clause;
+ } break;
./
-Program: Empty ;
+ImportsList: ImportSpecifier;
+/.
+ case $rule_number: {
+ auto importsList = new (pool) AST::ImportsList(sym(1).ImportSpecifier);
+ importsList->importSpecifierToken = loc(1);
+ sym(1).ImportsList = importsList;
+ } break;
+./
+ImportsList: ImportsList T_COMMA ImportSpecifier;
+/.
+ case $rule_number: {
+ auto importsList = new (pool) AST::ImportsList(sym(1).ImportsList, sym(3).ImportSpecifier);
+ importsList->importSpecifierToken = loc(3);
+ sym(1).ImportsList = importsList;
+ } break;
+./
-Program: SourceElements ;
+ImportSpecifier: ImportedBinding;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
-} break;
+ case $rule_number: {
+ auto importSpecifier = new (pool) AST::ImportSpecifier(stringRef(1));
+ importSpecifier->importedBindingToken = loc(1);
+ sym(1).ImportSpecifier = importSpecifier;
+ } break;
./
+ImportSpecifier: IdentifierName T_AS ImportedBinding;
+/.
+ case $rule_number: {
+ auto importSpecifier = new (pool) AST::ImportSpecifier(stringRef(1), stringRef(3));
+ importSpecifier->identifierToken = loc(1);
+ importSpecifier->importedBindingToken = loc(3);
+ sym(1).ImportSpecifier = importSpecifier;
+ } break;
+./
+
+ModuleSpecifier: T_STRING_LITERAL;
-SourceElements: SourceElement ;
+ImportedBinding: BindingIdentifier;
+
+ExportDeclarationLookahead: ;
+/:
+#define J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE $rule_number
+:/
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
-} break;
+ case $rule_number: {
+ int token = lookaheadToken(lexer);
+ if (token == T_FUNCTION || token == T_CLASS)
+ pushToken(T_FORCE_DECLARATION);
+ } break;
./
-SourceElements: SourceElements SourceElement ;
+ExportDeclaration: T_EXPORT T_STAR FromClause;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
-} break;
+ case $rule_number: {
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(sym(3).FromClause);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
+./
+ExportDeclaration: T_EXPORT ExportClause FromClause;
+/.
+ case $rule_number: {
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(sym(2).ExportClause, sym(3).FromClause);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
+./
+ExportDeclaration: T_EXPORT ExportClause;
+/.
+ case $rule_number: {
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(sym(2).ExportClause);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
+./
+ExportDeclaration: T_EXPORT VariableStatement;
+/. case $rule_number: Q_FALLTHROUGH(); ./
+ExportDeclaration: T_EXPORT Declaration;
+/.
+ case $rule_number: {
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(/*exportDefault=*/false, sym(2).Node);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
+./
+ExportDeclaration: T_EXPORT T_DEFAULT ExportDeclarationLookahead T_FORCE_DECLARATION HoistableDeclaration_Default;
+/.
+ case $rule_number: {
+ if (auto *f = AST::cast<AST::FunctionDeclaration*>(sym(5).Node)) {
+ if (f->name.isEmpty()) {
+ f->name = stringRef(2);
+ f->identifierToken = loc(2);
+ }
+ }
+ } Q_FALLTHROUGH();
./
+ExportDeclaration: T_EXPORT T_DEFAULT ExportDeclarationLookahead T_FORCE_DECLARATION ClassDeclaration_Default;
+/.
+ case $rule_number: {
+ // Emulate 15.2.3.11
+ if (auto *cls = AST::cast<AST::ClassDeclaration*>(sym(5).Node)) {
+ if (cls->name.isEmpty()) {
+ cls->name = stringRef(2);
+ cls->identifierToken = loc(2);
+ }
+ }
-SourceElement: Statement ;
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(/*exportDefault=*/true, sym(5).Node);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
+./
+ExportDeclaration: T_EXPORT T_DEFAULT ExportDeclarationLookahead AssignmentExpression_In; -- [lookahead ∉ { function, class }]
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
-} break;
+ case $rule_number: {
+ // if lhs is an identifier expression and rhs is an anonymous function expression, we need to assign the name of lhs to the function
+ if (auto *f = asAnonymousFunctionDefinition(sym(4).Node)) {
+ f->name = stringRef(2);
+ }
+ if (auto *c = asAnonymousClassDefinition(sym(4).Expression)) {
+ c->name = stringRef(2);
+ }
+
+ auto exportDeclaration = new (pool) AST::ExportDeclaration(/*exportDefault=*/true, sym(4).Node);
+ exportDeclaration->exportToken = loc(1);
+ sym(1).ExportDeclaration = exportDeclaration;
+ } break;
./
-SourceElement: FunctionDeclaration ;
+ExportClause: T_LBRACE T_RBRACE;
/.
-case $rule_number: {
- sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
-} break;
+ case $rule_number: {
+ auto exportClause = new (pool) AST::ExportClause();
+ exportClause->leftBraceToken = loc(1);
+ exportClause->rightBraceToken = loc(2);
+ sym(1).ExportClause = exportClause;
+ } break;
+./
+ExportClause: T_LBRACE ExportsList T_RBRACE;
+/.
+ case $rule_number: {
+ auto exportClause = new (pool) AST::ExportClause(sym(2).ExportsList->finish());
+ exportClause->leftBraceToken = loc(1);
+ exportClause->rightBraceToken = loc(3);
+ sym(1).ExportClause = exportClause;
+ } break;
+./
+ExportClause: T_LBRACE ExportsList T_COMMA T_RBRACE;
+/.
+ case $rule_number: {
+ auto exportClause = new (pool) AST::ExportClause(sym(2).ExportsList->finish());
+ exportClause->leftBraceToken = loc(1);
+ exportClause->rightBraceToken = loc(4);
+ sym(1).ExportClause = exportClause;
+ } break;
./
-PropertyAssignmentListOpt: ;
+ExportsList: ExportSpecifier;
/.
-case $rule_number: {
- sym(1).Node = 0;
-} break;
+ case $rule_number: {
+ sym(1).ExportsList = new (pool) AST::ExportsList(sym(1).ExportSpecifier);
+ } break;
+./
+ExportsList: ExportsList T_COMMA ExportSpecifier;
+/.
+ case $rule_number: {
+ sym(1).ExportsList = new (pool) AST::ExportsList(sym(1).ExportsList, sym(3).ExportSpecifier);
+ } break;
./
-PropertyAssignmentListOpt: PropertyAssignmentList ;
+ExportSpecifier: IdentifierName;
+/.
+ case $rule_number: {
+ auto exportSpecifier = new (pool) AST::ExportSpecifier(stringRef(1));
+ exportSpecifier->identifierToken = loc(1);
+ sym(1).ExportSpecifier = exportSpecifier;
+ } break;
+./
+ExportSpecifier: IdentifierName T_AS IdentifierName;
+/.
+ case $rule_number: {
+ auto exportSpecifier = new (pool) AST::ExportSpecifier(stringRef(1), stringRef(3));
+ exportSpecifier->identifierToken = loc(1);
+ exportSpecifier->exportedIdentifierToken = loc(3);
+ sym(1).ExportSpecifier = exportSpecifier;
+ } break;
+./
+
+-- Old top level code
/.
+ // ------------ end of switch statement
} // switch
action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
} // if
} while (action != 0);
+#ifdef PARSER_DEBUG
+ qDebug() << "Done or error.";
+#endif
+
if (first_token == last_token) {
const int errorState = state_stack[tos];
// automatic insertion of `;'
if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken))
|| t_action(errorState, T_COMPATIBILITY_SEMICOLON))) {
+#ifdef PARSER_DEBUG
+ qDebug() << "Inserting automatic semicolon.";
+#endif
SavedToken &tk = token_buffer[0];
tk.token = yytoken;
tk.dval = yylval;
@@ -3260,8 +4437,7 @@ PropertyAssignmentListOpt: PropertyAssignmentList ;
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION)
continue;
int a = t_action(errorState, tk);
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index 0d1b512c92..4ebb2d3b5c 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -45,6 +45,27 @@ QT_QML_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
+FunctionExpression *asAnonymousFunctionDefinition(Node *n)
+{
+ if (!n)
+ return nullptr;
+ FunctionExpression *f = n->asFunctionDefinition();
+ if (!f || !f->name.isNull())
+ return nullptr;
+ return f;
+}
+
+ClassExpression *asAnonymousClassDefinition(Node *n)
+{
+ if (!n)
+ return nullptr;
+ ClassExpression *c = n->asClassDefinition();
+ if (!c || !c->name.isNull())
+ return nullptr;
+ return c;
+}
+
+
void Node::accept(Visitor *visitor)
{
if (visitor->preVisit(this)) {
@@ -79,11 +100,67 @@ UiObjectMember *Node::uiObjectMemberCast()
return nullptr;
}
+LeftHandSideExpression *Node::leftHandSideExpressionCast()
+{
+ return nullptr;
+}
+
+Pattern *Node::patternCast()
+{
+ return nullptr;
+}
+
+FunctionExpression *Node::asFunctionDefinition()
+{
+ return nullptr;
+}
+
+ClassExpression *Node::asClassDefinition()
+{
+ return nullptr;
+}
+
ExpressionNode *ExpressionNode::expressionCast()
{
return this;
}
+FormalParameterList *ExpressionNode::reparseAsFormalParameterList(MemoryPool *pool)
+{
+ AST::ExpressionNode *expr = this;
+ AST::FormalParameterList *f = nullptr;
+ if (AST::Expression *commaExpr = AST::cast<AST::Expression *>(expr)) {
+ f = commaExpr->left->reparseAsFormalParameterList(pool);
+ if (!f)
+ return nullptr;
+
+ expr = commaExpr->right;
+ }
+
+ AST::ExpressionNode *rhs = nullptr;
+ if (AST::BinaryExpression *assign = AST::cast<AST::BinaryExpression *>(expr)) {
+ if (assign->op != QSOperator::Assign)
+ return nullptr;
+ expr = assign->left;
+ rhs = assign->right;
+ }
+ AST::PatternElement *binding = nullptr;
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(expr)) {
+ binding = new (pool) AST::PatternElement(idExpr->name, rhs);
+ binding->identifierToken = idExpr->identifierToken;
+ } else if (AST::Pattern *p = expr->patternCast()) {
+ SourceLocation loc;
+ QString s;
+ if (!p->convertLiteralToAssignmentPattern(pool, &loc, &s))
+ return nullptr;
+ binding = new (pool) AST::PatternElement(p, rhs);
+ binding->identifierToken = p->firstSourceLocation();
+ }
+ if (!binding)
+ return nullptr;
+ return new (pool) AST::FormalParameterList(f, binding);
+}
+
BinaryExpression *BinaryExpression::binaryExpressionCast()
{
return this;
@@ -107,6 +184,16 @@ void NestedExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+FunctionExpression *NestedExpression::asFunctionDefinition()
+{
+ return expression->asFunctionDefinition();
+}
+
+ClassExpression *NestedExpression::asClassDefinition()
+{
+ return expression->asClassDefinition();
+}
+
void ThisExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
@@ -147,7 +234,7 @@ void FalseLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void StringLiteral::accept0(Visitor *visitor)
+void SuperLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -155,7 +242,8 @@ void StringLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NumericLiteral::accept0(Visitor *visitor)
+
+void StringLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -163,81 +251,231 @@ void NumericLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void RegExpLiteral::accept0(Visitor *visitor)
+void TemplateLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
+ if (next)
+ accept(next, visitor);
}
visitor->endVisit(this);
}
-void ArrayLiteral::accept0(Visitor *visitor)
+void NumericLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(elements, visitor);
- accept(elision, visitor);
}
visitor->endVisit(this);
}
-void ObjectLiteral::accept0(Visitor *visitor)
+void RegExpLiteral::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(properties, visitor);
}
visitor->endVisit(this);
}
-void ElementList::accept0(Visitor *visitor)
+void ArrayPattern::accept0(Visitor *visitor)
{
- if (visitor->visit(this)) {
- for (ElementList *it = this; it; it = it->next) {
- accept(it->elision, visitor);
- accept(it->expression, visitor);
- }
- }
+ if (visitor->visit(this))
+ accept(elements, visitor);
visitor->endVisit(this);
}
-void Elision::accept0(Visitor *visitor)
+bool ArrayPattern::isValidArrayLiteral(SourceLocation *errorLocation) const {
+ for (PatternElementList *it = elements; it != nullptr; it = it->next) {
+ PatternElement *e = it->element;
+ if (e && e->bindingTarget != nullptr) {
+ if (errorLocation)
+ *errorLocation = e->firstSourceLocation();
+ return false;
+ }
+ }
+ return true;
+}
+
+void ObjectPattern::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- // ###
+ accept(properties, visitor);
}
visitor->endVisit(this);
}
-void PropertyNameAndValue::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(name, visitor);
- accept(value, visitor);
+/*
+ This is the grammar for AssignmentPattern that we need to convert the literal to:
+
+ AssignmentPattern:
+ ObjectAssignmentPattern
+ ArrayAssignmentPattern
+ ArrayAssignmentPattern:
+ [ ElisionOpt AssignmentRestElementOpt ]
+ [ AssignmentElementList ]
+ [ AssignmentElementList , ElisionOpt AssignmentRestElementOpt ]
+ AssignmentElementList:
+ AssignmentElisionElement
+ AssignmentElementList , AssignmentElisionElement
+ AssignmentElisionElement:
+ ElisionOpt AssignmentElement
+ AssignmentRestElement:
+ ... DestructuringAssignmentTarget
+
+ ObjectAssignmentPattern:
+ {}
+ { AssignmentPropertyList }
+ { AssignmentPropertyList, }
+ AssignmentPropertyList:
+ AssignmentProperty
+ AssignmentPropertyList , AssignmentProperty
+ AssignmentProperty:
+ IdentifierReference InitializerOpt_In
+ PropertyName:
+ AssignmentElement
+
+ AssignmentElement:
+ DestructuringAssignmentTarget InitializerOpt_In
+ DestructuringAssignmentTarget:
+ LeftHandSideExpression
+
+ It was originally parsed with the following grammar:
+
+ArrayLiteral:
+ [ ElisionOpt ]
+ [ ElementList ]
+ [ ElementList , ElisionOpt ]
+ElementList:
+ ElisionOpt AssignmentExpression_In
+ ElisionOpt SpreadElement
+ ElementList , ElisionOpt AssignmentExpression_In
+ ElementList , Elisionopt SpreadElement
+SpreadElement:
+ ... AssignmentExpression_In
+ObjectLiteral:
+ {}
+ { PropertyDefinitionList }
+ { PropertyDefinitionList , }
+PropertyDefinitionList:
+ PropertyDefinition
+ PropertyDefinitionList , PropertyDefinition
+PropertyDefinition:
+ IdentifierReference
+ CoverInitializedName
+ PropertyName : AssignmentExpression_In
+ MethodDefinition
+PropertyName:
+ LiteralPropertyName
+ ComputedPropertyName
+
+*/
+bool ArrayPattern::convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage)
+{
+ if (parseMode == Binding)
+ return true;
+ for (auto *it = elements; it; it = it->next) {
+ if (!it->element)
+ continue;
+ if (it->element->type == PatternElement::SpreadElement && it->next) {
+ *errorLocation = it->element->firstSourceLocation();
+ *errorMessage = QString::fromLatin1("'...' can only appear as last element in a destructuring list.");
+ return false;
+ }
+ if (!it->element->convertLiteralToAssignmentPattern(pool, errorLocation, errorMessage))
+ return false;
}
+ parseMode = Binding;
+ return true;
+}
- visitor->endVisit(this);
+bool ObjectPattern::convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage)
+{
+ if (parseMode == Binding)
+ return true;
+ for (auto *it = properties; it; it = it->next) {
+ if (!it->property->convertLiteralToAssignmentPattern(pool, errorLocation, errorMessage))
+ return false;
+ }
+ parseMode = Binding;
+ return true;
}
-void PropertyGetterSetter::accept0(Visitor *visitor)
+bool PatternElement::convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage)
{
- if (visitor->visit(this)) {
- accept(name, visitor);
- accept(formals, visitor);
- accept(functionBody, visitor);
+ Q_ASSERT(type == Literal || type == SpreadElement);
+ Q_ASSERT(bindingIdentifier.isNull());
+ Q_ASSERT(bindingTarget == nullptr);
+ Q_ASSERT(bindingTarget == nullptr);
+ Q_ASSERT(initializer);
+ ExpressionNode *init = initializer;
+
+ initializer = nullptr;
+ LeftHandSideExpression *lhs = init->leftHandSideExpressionCast();
+ if (type == SpreadElement) {
+ if (!lhs) {
+ *errorLocation = init->firstSourceLocation();
+ *errorMessage = QString::fromLatin1("Invalid lhs expression after '...' in destructuring expression.");
+ return false;
+ }
+ } else {
+ type = PatternElement::Binding;
+
+ if (BinaryExpression *b = init->binaryExpressionCast()) {
+ if (b->op != QSOperator::Assign) {
+ *errorLocation = b->operatorToken;
+ *errorMessage = QString::fromLatin1("Invalid assignment operation in destructuring expression");
+ return false;
+ }
+ lhs = b->left->leftHandSideExpressionCast();
+ initializer = b->right;
+ Q_ASSERT(lhs);
+ } else {
+ lhs = init->leftHandSideExpressionCast();
+ }
+ if (!lhs) {
+ *errorLocation = init->firstSourceLocation();
+ *errorMessage = QString::fromLatin1("Destructuring target is not a left hand side expression.");
+ return false;
+ }
}
- visitor->endVisit(this);
+ if (auto *i = cast<IdentifierExpression *>(lhs)) {
+ bindingIdentifier = i->name;
+ identifierToken = i->identifierToken;
+ return true;
+ }
+
+ bindingTarget = lhs;
+ if (auto *p = lhs->patternCast()) {
+ if (!p->convertLiteralToAssignmentPattern(pool, errorLocation, errorMessage))
+ return false;
+ }
+ return true;
+}
+
+bool PatternProperty::convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage)
+{
+ Q_ASSERT(type != SpreadElement);
+ if (type == Binding)
+ return true;
+ if (type == Getter || type == Setter) {
+ *errorLocation = firstSourceLocation();
+ *errorMessage = QString::fromLatin1("Invalid getter/setter in destructuring expression.");
+ return false;
+ }
+ if (type == Method)
+ type = Literal;
+ Q_ASSERT(type == Literal);
+ return PatternElement::convertLiteralToAssignmentPattern(pool, errorLocation, errorMessage);
}
-void PropertyAssignmentList::accept0(Visitor *visitor)
+
+void Elision::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- for (PropertyAssignmentList *it = this; it; it = it->next) {
- accept(it->assignment, visitor);
- }
+ // ###
}
visitor->endVisit(this);
@@ -518,15 +756,6 @@ void VariableDeclarationList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void VariableDeclaration::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- accept(expression, visitor);
- }
-
- visitor->endVisit(this);
-}
-
void EmptyStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
@@ -579,17 +808,6 @@ void ForStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
accept(initialiser, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
accept(declarations, visitor);
accept(condition, visitor);
accept(expression, visitor);
@@ -602,7 +820,7 @@ void LocalForStatement::accept0(Visitor *visitor)
void ForEachStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(initialiser, visitor);
+ accept(lhs, visitor);
accept(expression, visitor);
accept(statement, visitor);
}
@@ -610,18 +828,15 @@ void ForEachStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void LocalForEachStatement::accept0(Visitor *visitor)
+void ContinueStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(declaration, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
}
visitor->endVisit(this);
}
-void ContinueStatement::accept0(Visitor *visitor)
+void BreakStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -629,15 +844,16 @@ void ContinueStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void BreakStatement::accept0(Visitor *visitor)
+void ReturnStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
+ accept(expression, visitor);
}
visitor->endVisit(this);
}
-void ReturnStatement::accept0(Visitor *visitor)
+void YieldExpression::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -646,6 +862,7 @@ void ReturnStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+
void WithStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
@@ -739,6 +956,7 @@ void TryStatement::accept0(Visitor *visitor)
void Catch::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
+ accept(patternElement, visitor);
accept(statement, visitor);
}
@@ -774,57 +992,182 @@ void FunctionExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+FunctionExpression *FunctionExpression::asFunctionDefinition()
+{
+ return this;
+}
+
+QStringList FormalParameterList::formals() const
+{
+ QStringList formals;
+ int i = 0;
+ for (const FormalParameterList *it = this; it; it = it->next) {
+ if (it->element) {
+ QString name = it->element->bindingIdentifier.toString();
+ int duplicateIndex = formals.indexOf(name);
+ if (duplicateIndex >= 0) {
+ // change the name of the earlier argument to enforce the lookup semantics from the spec
+ formals[duplicateIndex] += QLatin1String("#") + QString::number(i);
+ }
+ formals += name;
+ }
+ ++i;
+ }
+ return formals;
+}
+
+QStringList FormalParameterList::boundNames() const
+{
+ QStringList names;
+ for (const FormalParameterList *it = this; it; it = it->next) {
+ if (it->element)
+ it->element->boundNames(&names);
+ }
+ return names;
+}
+
void FormalParameterList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- // ###
+ accept(element, visitor);
+ if (next)
+ accept(next, visitor);
}
visitor->endVisit(this);
}
-void FunctionBody::accept0(Visitor *visitor)
+FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *pool)
+{
+ FormalParameterList *front = next;
+ next = nullptr;
+
+ int i = 0;
+ for (const FormalParameterList *it = this; it; it = it->next) {
+ if (it->element && it->element->bindingIdentifier.isEmpty())
+ it->element->bindingIdentifier = pool->newString(QLatin1String("arg#") + QString::number(i));
+ ++i;
+ }
+ return front;
+}
+
+void Program::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(elements, visitor);
+ accept(statements, visitor);
}
visitor->endVisit(this);
}
-void Program::accept0(Visitor *visitor)
+void ImportSpecifier::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+
+ }
+ visitor->endVisit(this);
+}
+
+void ImportsList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ImportsList *it = this; it; it = it->next) {
+ accept(it->importSpecifier, visitor);
+ }
+ }
+
+ visitor->endVisit(this);
+}
+
+void NamedImports::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(importsList, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void FromClause::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void NameSpaceImport::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(elements, visitor);
}
visitor->endVisit(this);
}
-void SourceElements::accept0(Visitor *visitor)
+void ImportClause::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- for (SourceElements *it = this; it; it = it->next) {
- accept(it->element, visitor);
+ accept(nameSpaceImport, visitor);
+ accept(namedImports, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ImportDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(importClause, visitor);
+ accept(fromClause, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ExportSpecifier::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+
+ }
+
+ visitor->endVisit(this);
+}
+
+void ExportsList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (ExportsList *it = this; it; it = it->next) {
+ accept(it->exportSpecifier, visitor);
}
}
visitor->endVisit(this);
}
-void FunctionSourceElement::accept0(Visitor *visitor)
+void ExportClause::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(declaration, visitor);
+ accept(exportsList, visitor);
}
visitor->endVisit(this);
}
-void StatementSourceElement::accept0(Visitor *visitor)
+void ExportDeclaration::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(statement, visitor);
+ accept(fromClause, visitor);
+ accept(exportClause, visitor);
+ accept(variableStatementOrDeclaration, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ESModule::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(body, visitor);
}
visitor->endVisit(this);
@@ -952,18 +1295,9 @@ void UiImport::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiQualifiedPragmaId::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
- }
-
- visitor->endVisit(this);
-}
-
void UiPragma::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
- accept(pragmaType, visitor);
}
visitor->endVisit(this);
@@ -1006,6 +1340,153 @@ void UiEnumMemberList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
+void TaggedTemplate::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(base, visitor);
+ accept(templateLiteral, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PatternElement::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(bindingTarget, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PatternElement::boundNames(QStringList *names)
+{
+ if (bindingTarget) {
+ if (PatternElementList *e = elementList())
+ e->boundNames(names);
+ else if (PatternPropertyList *p = propertyList())
+ p->boundNames(names);
+ } else {
+ names->append(bindingIdentifier.toString());
+ }
+}
+
+void PatternElementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(elision, visitor);
+ accept(element, visitor);
+ if (next)
+ accept(next, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PatternElementList::boundNames(QStringList *names)
+{
+ for (PatternElementList *it = this; it; it = it->next) {
+ if (it->element)
+ it->element->boundNames(names);
+ }
+}
+
+void PatternProperty::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(name, visitor);
+ accept(bindingTarget, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PatternProperty::boundNames(QStringList *names)
+{
+ PatternElement::boundNames(names);
+}
+
+void PatternPropertyList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(property, visitor);
+ if (next)
+ accept(next, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void PatternPropertyList::boundNames(QStringList *names)
+{
+ for (PatternPropertyList *it = this; it; it = it->next)
+ it->property->boundNames(names);
+}
+
+void ComputedPropertyName::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(expression, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ClassExpression::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(heritage, visitor);
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+ClassExpression *ClassExpression::asClassDefinition()
+{
+ return this;
+}
+
+void ClassDeclaration::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(heritage, visitor);
+ accept(elements, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void ClassElementList::accept0(Visitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(property, visitor);
+ if (next)
+ accept(next, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+ClassElementList *ClassElementList::finish()
+{
+ ClassElementList *front = next;
+ next = nullptr;
+ return front;
+}
+
+Pattern *Pattern::patternCast()
+{
+ return this;
+}
+
+LeftHandSideExpression *LeftHandSideExpression::leftHandSideExpressionCast()
+{
+ return this;
+}
+
} } // namespace QQmlJS::AST
QT_QML_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 9c5fd5adf6..72c47cbe32 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -77,6 +77,8 @@ enum Op {
Div,
InplaceDiv,
Equal,
+ Exp,
+ InplaceExp,
Ge,
Gt,
In,
@@ -110,6 +112,13 @@ namespace QQmlJS {
namespace AST {
+enum class VariableScope {
+ NoScope,
+ Var,
+ Let,
+ Const
+};
+
template <typename T1, typename T2>
T1 cast(T2 *ast)
{
@@ -119,6 +128,9 @@ T1 cast(T2 *ast)
return 0;
}
+FunctionExpression *asAnonymousFunctionDefinition(AST::Node *n);
+ClassExpression *asAnonymousClassDefinition(AST::Node *n);
+
class QML_PARSER_EXPORT Node: public Managed
{
public:
@@ -126,7 +138,7 @@ public:
Kind_Undefined,
Kind_ArgumentList,
- Kind_ArrayLiteral,
+ Kind_ArrayPattern,
Kind_ArrayMemberExpression,
Kind_BinaryExpression,
Kind_Block,
@@ -148,6 +160,7 @@ public:
Kind_Expression,
Kind_ExpressionStatement,
Kind_FalseLiteral,
+ Kind_SuperLiteral,
Kind_FieldMemberExpression,
Kind_Finally,
Kind_ForEachStatement,
@@ -156,38 +169,50 @@ public:
Kind_FunctionBody,
Kind_FunctionDeclaration,
Kind_FunctionExpression,
- Kind_FunctionSourceElement,
+ Kind_ClassExpression,
+ Kind_ClassDeclaration,
Kind_IdentifierExpression,
Kind_IdentifierPropertyName,
+ Kind_ComputedPropertyName,
Kind_IfStatement,
Kind_LabelledStatement,
- Kind_LocalForEachStatement,
- Kind_LocalForStatement,
+ Kind_NameSpaceImport,
+ Kind_ImportSpecifier,
+ Kind_ImportsList,
+ Kind_NamedImports,
+ Kind_ImportClause,
+ Kind_FromClause,
+ Kind_ImportDeclaration,
+ Kind_Module,
+ Kind_ExportSpecifier,
+ Kind_ExportsList,
+ Kind_ExportClause,
+ Kind_ExportDeclaration,
Kind_NewExpression,
Kind_NewMemberExpression,
Kind_NotExpression,
Kind_NullExpression,
+ Kind_YieldExpression,
Kind_NumericLiteral,
Kind_NumericLiteralPropertyName,
- Kind_ObjectLiteral,
+ Kind_ObjectPattern,
Kind_PostDecrementExpression,
Kind_PostIncrementExpression,
Kind_PreDecrementExpression,
Kind_PreIncrementExpression,
Kind_Program,
- Kind_PropertyAssignmentList,
+ Kind_PropertyDefinitionList,
Kind_PropertyGetterSetter,
Kind_PropertyName,
Kind_PropertyNameAndValue,
Kind_RegExpLiteral,
Kind_ReturnStatement,
- Kind_SourceElement,
- Kind_SourceElements,
Kind_StatementList,
- Kind_StatementSourceElement,
Kind_StringLiteral,
Kind_StringLiteralPropertyName,
Kind_SwitchStatement,
+ Kind_TemplateLiteral,
+ Kind_TaggedTemplate,
Kind_ThisExpression,
Kind_ThrowStatement,
Kind_TildeExpression,
@@ -203,6 +228,12 @@ public:
Kind_WhileStatement,
Kind_WithStatement,
Kind_NestedExpression,
+ Kind_ClassElementList,
+ Kind_PatternElement,
+ Kind_PatternElementList,
+ Kind_PatternProperty,
+ Kind_PatternPropertyList,
+
Kind_UiArrayBinding,
Kind_UiImport,
@@ -216,7 +247,6 @@ public:
Kind_UiParameterList,
Kind_UiPublicMember,
Kind_UiQualifiedId,
- Kind_UiQualifiedPragmaId,
Kind_UiScriptBinding,
Kind_UiSourceElement,
Kind_UiHeaderItemList,
@@ -235,6 +265,11 @@ public:
virtual BinaryExpression *binaryExpressionCast();
virtual Statement *statementCast();
virtual UiObjectMember *uiObjectMemberCast();
+ virtual LeftHandSideExpression *leftHandSideExpressionCast();
+ virtual Pattern *patternCast();
+ // implements the IsFunctionDefinition rules in the spec
+ virtual FunctionExpression *asFunctionDefinition();
+ virtual ClassExpression *asClassDefinition();
void accept(Visitor *visitor);
static void accept(Node *node, Visitor *visitor);
@@ -256,6 +291,14 @@ public:
ExpressionNode() {}
ExpressionNode *expressionCast() override;
+
+ AST::FormalParameterList *reparseAsFormalParameterList(MemoryPool *pool);
+
+};
+
+class QML_PARSER_EXPORT LeftHandSideExpression : public ExpressionNode
+{
+ LeftHandSideExpression *leftHandSideExpressionCast() override;
};
class QML_PARSER_EXPORT Statement: public Node
@@ -266,7 +309,7 @@ public:
Statement *statementCast() override;
};
-class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
+class QML_PARSER_EXPORT NestedExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(NestedExpression)
@@ -283,13 +326,17 @@ public:
SourceLocation lastSourceLocation() const override
{ return rparenToken; }
+ FunctionExpression *asFunctionDefinition() override;
+ ClassExpression *asClassDefinition() override;
+
+
// attributes
ExpressionNode *expression;
SourceLocation lparenToken;
SourceLocation rparenToken;
};
-class QML_PARSER_EXPORT ThisExpression: public ExpressionNode
+class QML_PARSER_EXPORT ThisExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(ThisExpression)
@@ -308,7 +355,7 @@ public:
SourceLocation thisToken;
};
-class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
+class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(IdentifierExpression)
@@ -329,7 +376,7 @@ public:
SourceLocation identifierToken;
};
-class QML_PARSER_EXPORT NullExpression: public ExpressionNode
+class QML_PARSER_EXPORT NullExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(NullExpression)
@@ -348,7 +395,7 @@ public:
SourceLocation nullToken;
};
-class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode
+class QML_PARSER_EXPORT TrueLiteral: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(TrueLiteral)
@@ -367,7 +414,7 @@ public:
SourceLocation trueToken;
};
-class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode
+class QML_PARSER_EXPORT FalseLiteral: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(FalseLiteral)
@@ -386,7 +433,27 @@ public:
SourceLocation falseToken;
};
-class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode
+class QML_PARSER_EXPORT SuperLiteral : public LeftHandSideExpression
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(SuperLiteral)
+
+ SuperLiteral() { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return superToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return superToken; }
+
+// attributes
+ SourceLocation superToken;
+};
+
+
+class QML_PARSER_EXPORT NumericLiteral: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(NumericLiteral)
@@ -407,7 +474,7 @@ public:
SourceLocation literalToken;
};
-class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
+class QML_PARSER_EXPORT StringLiteral: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(StringLiteral)
@@ -428,7 +495,30 @@ public:
SourceLocation literalToken;
};
-class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
+class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TemplateLiteral)
+
+ TemplateLiteral(const QStringRef &str, ExpressionNode *e)
+ : value(str), expression(e), next(nullptr)
+ { kind = K; }
+
+ SourceLocation firstSourceLocation() const override
+ { return literalToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return next ? next->lastSourceLocation() : (expression ? expression->lastSourceLocation() : literalToken); }
+
+ void accept0(Visitor *visitor) override;
+
+ QStringRef value;
+ ExpressionNode *expression;
+ TemplateLiteral *next;
+ SourceLocation literalToken;
+};
+
+class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(RegExpLiteral)
@@ -450,22 +540,26 @@ public:
SourceLocation literalToken;
};
-class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode
+class QML_PARSER_EXPORT Pattern : public LeftHandSideExpression
{
public:
- QQMLJS_DECLARE_AST_NODE(ArrayLiteral)
-
- ArrayLiteral(Elision *e):
- elements (nullptr), elision (e)
- { kind = K; }
+ enum ParseMode {
+ Literal,
+ Binding
+ };
+ Pattern *patternCast() override;
+ virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) = 0;
+ ParseMode parseMode = Literal;
+};
- ArrayLiteral(ElementList *elts):
- elements (elts), elision (nullptr)
- { kind = K; }
+class QML_PARSER_EXPORT ArrayPattern : public Pattern
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ArrayPattern)
- ArrayLiteral(ElementList *elts, Elision *e):
- elements (elts), elision (e)
- { kind = K; }
+ ArrayPattern(PatternElementList *elts)
+ : elements(elts)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -475,24 +569,28 @@ public:
SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
+ bool isValidArrayLiteral(SourceLocation *errorLocation = nullptr) const;
+
+ bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
+
// attributes
- ElementList *elements;
- Elision *elision;
+ PatternElementList *elements = nullptr;
SourceLocation lbracketToken;
SourceLocation commaToken;
SourceLocation rbracketToken;
};
-class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode
+class QML_PARSER_EXPORT ObjectPattern : public Pattern
{
public:
- QQMLJS_DECLARE_AST_NODE(ObjectLiteral)
+ QQMLJS_DECLARE_AST_NODE(ObjectPattern)
- ObjectLiteral()
+ ObjectPattern()
{ kind = K; }
- ObjectLiteral(PropertyAssignmentList *plist):
- properties (plist) { kind = K; }
+ ObjectPattern(PatternPropertyList *plist)
+ : properties(plist)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -502,8 +600,10 @@ public:
SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
+ bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
+
// attributes
- PropertyAssignmentList *properties = nullptr;
+ PatternPropertyList *properties = nullptr;
SourceLocation lbraceToken;
SourceLocation rbraceToken;
};
@@ -543,53 +643,6 @@ public:
SourceLocation commaToken;
};
-class QML_PARSER_EXPORT ElementList: public Node
-{
-public:
- QQMLJS_DECLARE_AST_NODE(ElementList)
-
- ElementList(Elision *e, ExpressionNode *expr):
- elision (e), expression (expr), next (this)
- { kind = K; }
-
- ElementList(ElementList *previous, Elision *e, ExpressionNode *expr):
- elision (e), expression (expr)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- inline ElementList *finish ()
- {
- ElementList *front = next;
- next = nullptr;
- return front;
- }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- {
- if (elision)
- return elision->firstSourceLocation();
- return expression->firstSourceLocation();
- }
-
- SourceLocation lastSourceLocation() const override
- {
- if (next)
- return next->lastSourceLocation();
- return expression->lastSourceLocation();
- }
-
-// attributes
- Elision *elision;
- ExpressionNode *expression;
- ElementList *next;
- SourceLocation commaToken;
-};
-
class QML_PARSER_EXPORT PropertyName: public Node
{
public:
@@ -609,116 +662,186 @@ public:
SourceLocation propertyNameToken;
};
-class QML_PARSER_EXPORT PropertyAssignment: public Node
+class QML_PARSER_EXPORT PatternElement : public Node
{
public:
- PropertyAssignment(PropertyName *n)
- : name(n)
- {}
+ QQMLJS_DECLARE_AST_NODE(PatternElement)
+
+ enum Type {
+ // object literal types
+ Literal,
+ Method,
+ Getter,
+ Setter,
+
+ // used by both bindings and literals
+ SpreadElement,
+ RestElement = SpreadElement,
+
+ // binding types
+ Binding,
+ };
+
+ PatternElement(ExpressionNode *i = nullptr, Type t = Literal)
+ : initializer(i), type(t)
+ { kind = K; }
+
+ PatternElement(const QStringRef &n, ExpressionNode *i = nullptr, Type t = Binding)
+ : bindingIdentifier(n), initializer(i), type(t)
+ {
+ Q_ASSERT(t >= RestElement);
+ kind = K;
+ }
+
+ PatternElement(Pattern *pattern, ExpressionNode *i = nullptr, Type t = Binding)
+ : bindingTarget(pattern), initializer(i), type(t)
+ {
+ Q_ASSERT(t >= RestElement);
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+ virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage);
+
+ SourceLocation firstSourceLocation() const override
+ { return identifierToken.isValid() ? identifierToken : (bindingTarget ? bindingTarget->firstSourceLocation() : initializer->firstSourceLocation()); }
+
+ SourceLocation lastSourceLocation() const override
+ { return initializer ? initializer->lastSourceLocation() : (bindingTarget ? bindingTarget->lastSourceLocation() : identifierToken); }
+
+ ExpressionNode *destructuringTarget() const { return bindingTarget; }
+ Pattern *destructuringPattern() const { return bindingTarget ? bindingTarget->patternCast() : nullptr; }
+ PatternElementList *elementList() const { ArrayPattern *a = cast<ArrayPattern *>(bindingTarget); return a ? a->elements : nullptr; }
+ PatternPropertyList *propertyList() const { ObjectPattern *o = cast<ObjectPattern *>(bindingTarget); return o ? o->properties : nullptr; }
+
+ bool isVariableDeclaration() const { return scope != VariableScope::NoScope; }
+ bool isLexicallyScoped() const { return scope == VariableScope::Let || scope == VariableScope::Const; }
+
+ virtual void boundNames(QStringList *names);
+
// attributes
- PropertyName *name;
+ SourceLocation identifierToken;
+ QStringRef bindingIdentifier;
+ ExpressionNode *bindingTarget = nullptr;
+ ExpressionNode *initializer = nullptr;
+ Type type = Literal;
+ // when used in a VariableDeclarationList
+ VariableScope scope = VariableScope::NoScope;
+ bool isForDeclaration = false;
};
-class QML_PARSER_EXPORT PropertyAssignmentList: public Node
+class QML_PARSER_EXPORT PatternElementList : public Node
{
public:
- QQMLJS_DECLARE_AST_NODE(PropertyAssignmentList)
+ QQMLJS_DECLARE_AST_NODE(PatternElementList)
- PropertyAssignmentList(PropertyAssignment *assignment)
- : assignment(assignment)
- , next(this)
+ PatternElementList(Elision *elision, PatternElement *element)
+ : elision(elision), element(element), next(this)
{ kind = K; }
- PropertyAssignmentList(PropertyAssignmentList *previous, PropertyAssignment *assignment)
- : assignment(assignment)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
+ PatternElementList *append(PatternElementList *n) {
+ n->next = next;
+ next = n;
+ return n;
}
- inline PropertyAssignmentList *finish ()
+ inline PatternElementList *finish ()
{
- PropertyAssignmentList *front = next;
- next = nullptr;
+ PatternElementList *front = next;
+ next = 0;
return front;
}
void accept0(Visitor *visitor) override;
+ void boundNames(QStringList *names);
+
SourceLocation firstSourceLocation() const override
- { return assignment->firstSourceLocation(); }
+ { return elision ? elision->firstSourceLocation() : element->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : assignment->lastSourceLocation(); }
+ { return next ? next->lastSourceLocation() : (element ? element->lastSourceLocation() : elision->lastSourceLocation()); }
-// attributes
- PropertyAssignment *assignment;
- PropertyAssignmentList *next;
- SourceLocation commaToken;
+ Elision *elision = nullptr;
+ PatternElement *element = nullptr;
+ PatternElementList *next;
};
-class QML_PARSER_EXPORT PropertyNameAndValue: public PropertyAssignment
+class QML_PARSER_EXPORT PatternProperty : public PatternElement
{
public:
- QQMLJS_DECLARE_AST_NODE(PropertyNameAndValue)
+ QQMLJS_DECLARE_AST_NODE(PatternProperty)
- PropertyNameAndValue(PropertyName *n, ExpressionNode *v)
- : PropertyAssignment(n), value(v)
+ PatternProperty(PropertyName *name, ExpressionNode *i = nullptr, Type t = Literal)
+ : PatternElement(i, t), name(name)
+ { kind = K; }
+
+ PatternProperty(PropertyName *name, const QStringRef &n, ExpressionNode *i = nullptr)
+ : PatternElement(n, i), name(name)
+ { kind = K; }
+
+ PatternProperty(PropertyName *name, Pattern *pattern, ExpressionNode *i = nullptr)
+ : PatternElement(pattern, i), name(name)
{ kind = K; }
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return name->firstSourceLocation(); }
-
SourceLocation lastSourceLocation() const override
- { return value->lastSourceLocation(); }
+ {
+ SourceLocation loc = PatternElement::lastSourceLocation();
+ return loc.isValid() ? loc : name->lastSourceLocation();
+ }
+
+ void boundNames(QStringList *names) override;
+ bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
// attributes
+ PropertyName *name;
SourceLocation colonToken;
- ExpressionNode *value;
- SourceLocation commaToken;
};
-class QML_PARSER_EXPORT PropertyGetterSetter: public PropertyAssignment
+
+class QML_PARSER_EXPORT PatternPropertyList : public Node
{
public:
- QQMLJS_DECLARE_AST_NODE(PropertyGetterSetter)
+ QQMLJS_DECLARE_AST_NODE(PatternPropertyList)
- enum Type {
- Getter,
- Setter
- };
-
- PropertyGetterSetter(PropertyName *n, FunctionBody *b)
- : PropertyAssignment(n), type(Getter), formals(nullptr), functionBody (b)
+ PatternPropertyList(PatternProperty *property)
+ : property(property), next(this)
{ kind = K; }
- PropertyGetterSetter(PropertyName *n, FormalParameterList *f, FunctionBody *b)
- : PropertyAssignment(n), type(Setter), formals(f), functionBody (b)
- { kind = K; }
+ PatternPropertyList(PatternPropertyList *previous, PatternProperty *property)
+ : property(property), next(this)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
void accept0(Visitor *visitor) override;
+ void boundNames(QStringList *names);
+
+ inline PatternPropertyList *finish ()
+ {
+ PatternPropertyList *front = next;
+ next = 0;
+ return front;
+ }
+
SourceLocation firstSourceLocation() const override
- { return getSetToken; }
+ { return property->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return rbraceToken; }
+ { return next ? next->lastSourceLocation() : property->lastSourceLocation(); }
-// attributes
- Type type;
- SourceLocation getSetToken;
- SourceLocation lparenToken;
- FormalParameterList *formals;
- SourceLocation rparenToken;
- SourceLocation lbraceToken;
- FunctionBody *functionBody;
- SourceLocation rbraceToken;
+ PatternProperty *property;
+ PatternPropertyList *next;
};
-class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
+class QML_PARSER_EXPORT IdentifierPropertyName : public PropertyName
{
public:
QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
@@ -766,7 +889,31 @@ public:
double id;
};
-class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode
+class QML_PARSER_EXPORT ComputedPropertyName : public PropertyName
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ComputedPropertyName)
+
+ ComputedPropertyName(ExpressionNode *expression)
+ : expression(expression)
+ { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ QString asString() const override { return QString(); }
+
+ SourceLocation firstSourceLocation() const override
+ { return expression->firstSourceLocation(); }
+
+ SourceLocation lastSourceLocation() const override
+ { return expression->lastSourceLocation(); }
+
+// attributes
+ ExpressionNode *expression;
+};
+
+
+class QML_PARSER_EXPORT ArrayMemberExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(ArrayMemberExpression)
@@ -790,7 +937,7 @@ public:
SourceLocation rbracketToken;
};
-class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
+class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(FieldMemberExpression)
@@ -814,7 +961,29 @@ public:
SourceLocation identifierToken;
};
-class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode
+class QML_PARSER_EXPORT TaggedTemplate : public LeftHandSideExpression
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(TaggedTemplate)
+
+ TaggedTemplate(ExpressionNode *b, TemplateLiteral *t)
+ : base (b), templateLiteral(t)
+ { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return base->firstSourceLocation(); }
+
+ SourceLocation lastSourceLocation() const override
+ { return templateLiteral->lastSourceLocation(); }
+
+ // attributes
+ ExpressionNode *base;
+ TemplateLiteral *templateLiteral;
+};
+
+class QML_PARSER_EXPORT NewMemberExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(NewMemberExpression)
@@ -839,7 +1008,7 @@ public:
SourceLocation rparenToken;
};
-class QML_PARSER_EXPORT NewExpression: public ExpressionNode
+class QML_PARSER_EXPORT NewExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(NewExpression)
@@ -860,7 +1029,7 @@ public:
SourceLocation newToken;
};
-class QML_PARSER_EXPORT CallExpression: public ExpressionNode
+class QML_PARSER_EXPORT CallExpression: public LeftHandSideExpression
{
public:
QQMLJS_DECLARE_AST_NODE(CallExpression)
@@ -924,6 +1093,7 @@ public:
ExpressionNode *expression;
ArgumentList *next;
SourceLocation commaToken;
+ bool isSpreadElement = false;
};
class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
@@ -1257,16 +1427,15 @@ class QML_PARSER_EXPORT StatementList: public Node
public:
QQMLJS_DECLARE_AST_NODE(StatementList)
- StatementList(Statement *stmt):
- statement (stmt), next (this)
- { kind = K; }
+ // ### This should be a Statement, but FunctionDeclaration currently doesn't inherit it.
+ StatementList(Node *stmt)
+ : statement(stmt), next (this)
+ { kind = K; }
- StatementList(StatementList *previous, Statement *stmt):
- statement (stmt)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
+ StatementList *append(StatementList *n) {
+ n->next = next;
+ next = n;
+ return n;
}
void accept0(Visitor *visitor) override;
@@ -1285,76 +1454,21 @@ public:
}
// attributes
- Statement *statement;
+ Node *statement = nullptr;
StatementList *next;
};
-class QML_PARSER_EXPORT VariableStatement: public Statement
-{
-public:
- QQMLJS_DECLARE_AST_NODE(VariableStatement)
-
- VariableStatement(VariableDeclarationList *vlist):
- declarations (vlist)
- { kind = K; }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return declarationKindToken; }
-
- SourceLocation lastSourceLocation() const override
- { return semicolonToken; }
-
-// attributes
- VariableDeclarationList *declarations;
- SourceLocation declarationKindToken;
- SourceLocation semicolonToken;
-};
-
-class QML_PARSER_EXPORT VariableDeclaration: public Node
-{
-public:
- QQMLJS_DECLARE_AST_NODE(VariableDeclaration)
-
- enum VariableScope {
- FunctionScope,
- BlockScope, // let
- ReadOnlyBlockScope // const
- };
-
- VariableDeclaration(const QStringRef &n, ExpressionNode *e, VariableScope s):
- name (n), expression (e), scope(s)
- { kind = K; }
-
- bool isLexicallyScoped() const { return scope != FunctionScope; }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return identifierToken; }
-
- SourceLocation lastSourceLocation() const override
- { return expression ? expression->lastSourceLocation() : identifierToken; }
-
-// attributes
- QStringRef name;
- ExpressionNode *expression;
- SourceLocation identifierToken;
- VariableScope scope;
-};
-
class QML_PARSER_EXPORT VariableDeclarationList: public Node
{
public:
QQMLJS_DECLARE_AST_NODE(VariableDeclarationList)
- VariableDeclarationList(VariableDeclaration *decl):
- declaration (decl), next (this)
- { kind = K; }
+ VariableDeclarationList(PatternElement *decl)
+ : declaration(decl), next(this)
+ { kind = K; }
- VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl):
- declaration (decl)
+ VariableDeclarationList(VariableDeclarationList *previous, PatternElement *decl)
+ : declaration(decl)
{
kind = K;
next = previous->next;
@@ -1373,7 +1487,7 @@ public:
return declaration->lastSourceLocation();
}
- inline VariableDeclarationList *finish(VariableDeclaration::VariableScope s)
+ inline VariableDeclarationList *finish(VariableScope s)
{
VariableDeclarationList *front = next;
next = nullptr;
@@ -1385,11 +1499,33 @@ public:
}
// attributes
- VariableDeclaration *declaration;
+ PatternElement *declaration;
VariableDeclarationList *next;
SourceLocation commaToken;
};
+class QML_PARSER_EXPORT VariableStatement: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(VariableStatement)
+
+ VariableStatement(VariableDeclarationList *vlist):
+ declarations (vlist)
+ { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return declarationKindToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return declarations->lastSourceLocation(); }
+
+// attributes
+ VariableDeclarationList *declarations;
+ SourceLocation declarationKindToken;
+};
+
class QML_PARSER_EXPORT EmptyStatement: public Statement
{
public:
@@ -1423,7 +1559,7 @@ public:
{ return expression->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return semicolonToken; }
+ { return expression->lastSourceLocation(); }
// attributes
ExpressionNode *expression;
@@ -1523,35 +1659,11 @@ public:
initialiser (i), condition (c), expression (e), statement (stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return forToken; }
-
- SourceLocation lastSourceLocation() const override
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForStatement: public Statement
-{
-public:
- QQMLJS_DECLARE_AST_NODE(LocalForStatement)
-
- LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ ForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
declarations (vlist), condition (c), expression (e), statement (stmt)
{ kind = K; }
+
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
@@ -1561,26 +1673,34 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- VariableDeclarationList *declarations;
+ ExpressionNode *initialiser = nullptr;
+ VariableDeclarationList *declarations = nullptr;
ExpressionNode *condition;
ExpressionNode *expression;
Statement *statement;
SourceLocation forToken;
SourceLocation lparenToken;
- SourceLocation varToken;
SourceLocation firstSemicolonToken;
SourceLocation secondSemicolonToken;
SourceLocation rparenToken;
};
+enum class ForEachType {
+ In,
+ Of
+};
+
class QML_PARSER_EXPORT ForEachStatement: public Statement
{
public:
QQMLJS_DECLARE_AST_NODE(ForEachStatement)
- ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
- initialiser (i), expression (e), statement (stmt)
- { kind = K; }
+ ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt)
+ : lhs(i), expression(e), statement(stmt)
+ { kind = K; }
+ ForEachStatement(PatternElement *v, ExpressionNode *e, Statement *stmt)
+ : lhs(v), expression(e), statement(stmt)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -1590,42 +1710,19 @@ public:
SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation inToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForEachStatement: public Statement
-{
-public:
- QQMLJS_DECLARE_AST_NODE(LocalForEachStatement)
-
- LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt):
- declaration (v), expression (e), statement (stmt)
- { kind = K; }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return forToken; }
-
- SourceLocation lastSourceLocation() const override
- { return statement->lastSourceLocation(); }
+ PatternElement *declaration() const {
+ return AST::cast<PatternElement *>(lhs);
+ }
// attributes
- VariableDeclaration *declaration;
+ Node *lhs;
ExpressionNode *expression;
Statement *statement;
SourceLocation forToken;
SourceLocation lparenToken;
- SourceLocation varToken;
- SourceLocation inToken;
+ SourceLocation inOfToken;
SourceLocation rparenToken;
+ ForEachType type;
};
class QML_PARSER_EXPORT ContinueStatement: public Statement
@@ -1696,6 +1793,28 @@ public:
SourceLocation semicolonToken;
};
+class QML_PARSER_EXPORT YieldExpression: public ExpressionNode
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(YieldExpression)
+
+ YieldExpression(ExpressionNode *e = nullptr):
+ expression (e) { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return yieldToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return expression ? expression->lastSourceLocation() : yieldToken; }
+
+// attributes
+ ExpressionNode *expression;
+ bool isYieldStar = false;
+ SourceLocation yieldToken;
+};
+
class QML_PARSER_EXPORT WithStatement: public Statement
{
public:
@@ -1906,9 +2025,9 @@ class QML_PARSER_EXPORT Catch: public Node
public:
QQMLJS_DECLARE_AST_NODE(Catch)
- Catch(const QStringRef &n, Block *stmt):
- name (n), statement (stmt)
- { kind = K; }
+ Catch(PatternElement *p, Block *stmt)
+ : patternElement(p), statement(stmt)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -1919,7 +2038,7 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- QStringRef name;
+ PatternElement *patternElement;
Block *statement;
SourceLocation catchToken;
SourceLocation lparenToken;
@@ -1993,7 +2112,7 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
public:
QQMLJS_DECLARE_AST_NODE(FunctionExpression)
- FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
+ FunctionExpression(const QStringRef &n, FormalParameterList *f, StatementList *b):
name (n), formals (f), body (b)
{ kind = K; }
@@ -2005,10 +2124,14 @@ public:
SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
+ FunctionExpression *asFunctionDefinition() override;
+
// attributes
QStringRef name;
+ bool isArrowFunction = false;
+ bool isGenerator = false;
FormalParameterList *formals;
- FunctionBody *body;
+ StatementList *body;
SourceLocation functionToken;
SourceLocation identifierToken;
SourceLocation lparenToken;
@@ -2022,7 +2145,7 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
public:
QQMLJS_DECLARE_AST_NODE(FunctionDeclaration)
- FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
+ FunctionDeclaration(const QStringRef &n, FormalParameterList *f, StatementList *b):
FunctionExpression(n, f, b)
{ kind = K; }
@@ -2034,168 +2157,593 @@ class QML_PARSER_EXPORT FormalParameterList: public Node
public:
QQMLJS_DECLARE_AST_NODE(FormalParameterList)
- FormalParameterList(const QStringRef &n):
- name (n), next (this)
- { kind = K; }
-
- FormalParameterList(FormalParameterList *previous, const QStringRef &n):
- name (n)
+ FormalParameterList(FormalParameterList *previous, PatternElement *e)
+ : element(e)
{
kind = K;
- next = previous->next;
- previous->next = this;
+ if (previous) {
+ next = previous->next;
+ previous->next = this;
+ } else {
+ next = this;
+ }
+ }
+
+ FormalParameterList *append(FormalParameterList *n) {
+ n->next = next;
+ next = n;
+ return n;
+ }
+
+ bool isSimpleParameterList()
+ {
+ AST::FormalParameterList *formals = this;
+ while (formals) {
+ PatternElement *e = formals->element;
+ if (e && e->type == PatternElement::RestElement)
+ return false;
+ if (e && (e->initializer || e->bindingTarget))
+ return false;
+ formals = formals->next;
+ }
+ return true;
}
+ int length()
+ {
+ // the length property of Function objects
+ int l = 0;
+ AST::FormalParameterList *formals = this;
+ while (formals) {
+ PatternElement *e = formals->element;
+ if (!e || e->initializer)
+ break;
+ if (e->type == PatternElement::RestElement)
+ break;
+ ++l;
+ formals = formals->next;
+ }
+ return l;
+ }
+
+ bool containsName(const QString &name) const {
+ for (const FormalParameterList *it = this; it; it = it->next) {
+ PatternElement *b = it->element;
+ // ### handle binding patterns
+ if (b && b->bindingIdentifier == name)
+ return true;
+ }
+ return false;
+ }
+
+ QStringList formals() const;
+
+ QStringList boundNames() const;
+
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return identifierToken; }
+ { return element->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : identifierToken; }
+ { return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
- inline FormalParameterList *finish ()
- {
- FormalParameterList *front = next;
- next = nullptr;
- return front;
- }
+ FormalParameterList *finish(MemoryPool *pool);
// attributes
- QStringRef name;
+ PatternElement *element = nullptr;
FormalParameterList *next;
- SourceLocation commaToken;
- SourceLocation identifierToken;
};
-class QML_PARSER_EXPORT SourceElement: public Node
+class QML_PARSER_EXPORT ClassExpression : public ExpressionNode
{
public:
- QQMLJS_DECLARE_AST_NODE(SourceElement)
+ QQMLJS_DECLARE_AST_NODE(ClassExpression)
- inline SourceElement()
+ ClassExpression(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
+ : name(n), heritage(heritage), elements(elements)
{ kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return classToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return rbraceToken; }
+
+ ClassExpression *asClassDefinition() override;
+
+// attributes
+ QStringRef name;
+ ExpressionNode *heritage;
+ ClassElementList *elements;
+ SourceLocation classToken;
+ SourceLocation identifierToken;
+ SourceLocation lbraceToken;
+ SourceLocation rbraceToken;
};
-class QML_PARSER_EXPORT SourceElements: public Node
+class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression
{
public:
- QQMLJS_DECLARE_AST_NODE(SourceElements)
+ QQMLJS_DECLARE_AST_NODE(ClassDeclaration)
- SourceElements(SourceElement *elt):
- element (elt), next (this)
+ ClassDeclaration(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
+ : ClassExpression(n, heritage, elements)
{ kind = K; }
- SourceElements(SourceElements *previous, SourceElement *elt):
- element (elt)
+ void accept0(Visitor *visitor) override;
+};
+
+
+class QML_PARSER_EXPORT ClassElementList : public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ClassElementList)
+
+ ClassElementList(PatternProperty *property, bool isStatic)
+ : isStatic(isStatic), property(property)
{
kind = K;
- next = previous->next;
- previous->next = this;
+ next = this;
+ }
+
+ ClassElementList *append(ClassElementList *n) {
+ n->next = next;
+ next = n;
+ return n;
}
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return element->firstSourceLocation(); }
+ { return property->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
+ {
+ if (next)
+ return next->lastSourceLocation();
+ return property->lastSourceLocation();
+ }
+
+ ClassElementList *finish();
+
+ bool isStatic;
+ ClassElementList *next;
+ PatternProperty *property;
+};
+
+class QML_PARSER_EXPORT Program: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Program)
+
+ Program(StatementList *statements)
+ : statements(statements)
+ { kind = K; }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return statements ? statements->firstSourceLocation() : SourceLocation(); }
+
+ SourceLocation lastSourceLocation() const override
+ { return statements ? statements->lastSourceLocation() : SourceLocation(); }
+
+// attributes
+ StatementList *statements;
+};
+
+class QML_PARSER_EXPORT ImportSpecifier: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ImportSpecifier)
+
+ ImportSpecifier(const QStringRef &importedBinding)
+ : importedBinding(importedBinding)
+ {
+ kind = K;
+ }
+
+ ImportSpecifier(const QStringRef &identifier, const QStringRef &importedBinding)
+ : identifier(identifier), importedBinding(importedBinding)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return identifier.isNull() ? importedBindingToken : identifierToken; }
+ SourceLocation lastSourceLocation() const override
+ { return importedBindingToken; }
+
+// attributes
+ SourceLocation identifierToken;
+ SourceLocation importedBindingToken;
+ QStringRef identifier;
+ QStringRef importedBinding;
+};
+
+class QML_PARSER_EXPORT ImportsList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ImportsList)
- inline SourceElements *finish ()
+ ImportsList(ImportSpecifier *importSpecifier)
+ : importSpecifier(importSpecifier)
{
- SourceElements *front = next;
+ kind = K;
+ next = this;
+ }
+
+ ImportsList(ImportsList *previous, ImportSpecifier *importSpecifier)
+ : importSpecifier(importSpecifier)
+ {
+ kind = K;
+ if (previous) {
+ next = previous->next;
+ previous->next = this;
+ } else {
+ next = this;
+ }
+ }
+
+ ImportsList *finish()
+ {
+ ImportsList *head = next;
next = nullptr;
- return front;
+ return head;
}
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return importSpecifierToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return next ? next->lastSourceLocation() : importSpecifierToken; }
+
// attributes
- SourceElement *element;
- SourceElements *next;
+ SourceLocation importSpecifierToken;
+ ImportSpecifier *importSpecifier;
+ ImportsList *next = this;
};
-class QML_PARSER_EXPORT FunctionBody: public Node
+class QML_PARSER_EXPORT NamedImports: public Node
{
public:
- QQMLJS_DECLARE_AST_NODE(FunctionBody)
+ QQMLJS_DECLARE_AST_NODE(NamedImports)
- FunctionBody(SourceElements *elts):
- elements (elts)
- { kind = K; }
+ NamedImports()
+ {
+ kind = K;
+ }
+
+ NamedImports(ImportsList *importsList)
+ : importsList(importsList)
+ {
+ kind = K;
+ }
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return elements ? elements->firstSourceLocation() : SourceLocation(); }
+ { return leftBraceToken; }
+ SourceLocation lastSourceLocation() const override
+ { return rightBraceToken; }
+
+// attributes
+ SourceLocation leftBraceToken;
+ SourceLocation rightBraceToken;
+ ImportsList *importsList = nullptr;
+};
+
+class QML_PARSER_EXPORT NameSpaceImport: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(NameSpaceImport)
+
+ NameSpaceImport(const QStringRef &importedBinding)
+ : importedBinding(importedBinding)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ virtual SourceLocation firstSourceLocation() const override
+ { return starToken; }
+ virtual SourceLocation lastSourceLocation() const override
+ { return importedBindingToken; }
+
+// attributes
+ SourceLocation starToken;
+ SourceLocation importedBindingToken;
+ QStringRef importedBinding;
+};
+
+class QML_PARSER_EXPORT ImportClause: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ImportClause)
+
+ ImportClause(const QStringRef &importedDefaultBinding)
+ : importedDefaultBinding(importedDefaultBinding)
+ {
+ kind = K;
+ }
+
+ ImportClause(NameSpaceImport *nameSpaceImport)
+ : nameSpaceImport(nameSpaceImport)
+ {
+ kind = K;
+ }
+
+ ImportClause(NamedImports *namedImports)
+ : namedImports(namedImports)
+ {
+ kind = K;
+ }
+
+ ImportClause(const QStringRef &importedDefaultBinding, NameSpaceImport *nameSpaceImport)
+ : importedDefaultBinding(importedDefaultBinding)
+ , nameSpaceImport(nameSpaceImport)
+ {
+ kind = K;
+ }
+
+ ImportClause(const QStringRef &importedDefaultBinding, NamedImports *namedImports)
+ : importedDefaultBinding(importedDefaultBinding)
+ , namedImports(namedImports)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ virtual SourceLocation firstSourceLocation() const override
+ { return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->firstSourceLocation() : namedImports->firstSourceLocation()) : importedDefaultBindingToken; }
+ virtual SourceLocation lastSourceLocation() const override
+ { return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->lastSourceLocation() : namedImports->lastSourceLocation()) : importedDefaultBindingToken; }
+
+// attributes
+ SourceLocation importedDefaultBindingToken;
+ QStringRef importedDefaultBinding;
+ NameSpaceImport *nameSpaceImport = nullptr;
+ NamedImports *namedImports = nullptr;
+};
+
+class QML_PARSER_EXPORT FromClause: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(FromClause)
+
+ FromClause(const QStringRef &moduleSpecifier)
+ : moduleSpecifier(moduleSpecifier)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return fromToken; }
SourceLocation lastSourceLocation() const override
- { return elements ? elements->lastSourceLocation() : SourceLocation(); }
+ { return moduleSpecifierToken; }
// attributes
- SourceElements *elements;
+ SourceLocation fromToken;
+ SourceLocation moduleSpecifierToken;
+ QStringRef moduleSpecifier;
};
-class QML_PARSER_EXPORT Program: public Node
+class QML_PARSER_EXPORT ImportDeclaration: public Statement
{
public:
- QQMLJS_DECLARE_AST_NODE(Program)
+ QQMLJS_DECLARE_AST_NODE(ImportDeclaration)
- Program(SourceElements *elts):
- elements (elts)
- { kind = K; }
+ ImportDeclaration(ImportClause *importClause, FromClause *fromClause)
+ : importClause(importClause), fromClause(fromClause)
+ {
+ kind = K;
+ }
+
+ ImportDeclaration(const QStringRef &moduleSpecifier)
+ : moduleSpecifier(moduleSpecifier)
+ {
+ kind = K;
+ }
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return elements ? elements->firstSourceLocation() : SourceLocation(); }
+ { return importToken; }
SourceLocation lastSourceLocation() const override
- { return elements ? elements->lastSourceLocation() : SourceLocation(); }
+ { return moduleSpecifier.isNull() ? fromClause->lastSourceLocation() : moduleSpecifierToken; }
// attributes
- SourceElements *elements;
+ SourceLocation importToken;
+ SourceLocation moduleSpecifierToken;
+ QStringRef moduleSpecifier;
+ ImportClause *importClause = nullptr;
+ FromClause *fromClause = nullptr;
};
-class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement
+class QML_PARSER_EXPORT ExportSpecifier: public Node
{
public:
- QQMLJS_DECLARE_AST_NODE(FunctionSourceElement)
+ QQMLJS_DECLARE_AST_NODE(ExportSpecifier)
- FunctionSourceElement(FunctionDeclaration *f):
- declaration (f)
- { kind = K; }
+ ExportSpecifier(const QStringRef &identifier)
+ : identifier(identifier), exportedIdentifier(identifier)
+ {
+ kind = K;
+ }
+
+ ExportSpecifier(const QStringRef &identifier, const QStringRef &exportedIdentifier)
+ : identifier(identifier), exportedIdentifier(exportedIdentifier)
+ {
+ kind = K;
+ }
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return declaration->firstSourceLocation(); }
+ { return identifierToken; }
+ SourceLocation lastSourceLocation() const override
+ { return exportedIdentifierToken.isValid() ? exportedIdentifierToken : identifierToken; }
+
+// attributes
+ SourceLocation identifierToken;
+ SourceLocation exportedIdentifierToken;
+ QStringRef identifier;
+ QStringRef exportedIdentifier;
+};
+class QML_PARSER_EXPORT ExportsList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ExportsList)
+
+ ExportsList(ExportSpecifier *exportSpecifier)
+ : exportSpecifier(exportSpecifier)
+ {
+ kind = K;
+ next = this;
+ }
+
+ ExportsList(ExportsList *previous, ExportSpecifier *exportSpecifier)
+ : exportSpecifier(exportSpecifier)
+ {
+ kind = K;
+ if (previous) {
+ next = previous->next;
+ previous->next = this;
+ } else {
+ next = this;
+ }
+ }
+
+ ExportsList *finish()
+ {
+ ExportsList *head = next;
+ next = nullptr;
+ return head;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return exportSpecifier->firstSourceLocation(); }
SourceLocation lastSourceLocation() const override
- { return declaration->lastSourceLocation(); }
+ { return next ? next->lastSourceLocation() : exportSpecifier->lastSourceLocation(); }
// attributes
- FunctionDeclaration *declaration;
+ ExportSpecifier *exportSpecifier;
+ ExportsList *next;
};
-class QML_PARSER_EXPORT StatementSourceElement: public SourceElement
+class QML_PARSER_EXPORT ExportClause: public Node
{
public:
- QQMLJS_DECLARE_AST_NODE(StatementSourceElement)
+ QQMLJS_DECLARE_AST_NODE(ExportClause)
- StatementSourceElement(Statement *stmt):
- statement (stmt)
- { kind = K; }
+ ExportClause()
+ {
+ kind = K;
+ }
+
+ ExportClause(ExportsList *exportsList)
+ : exportsList(exportsList)
+ {
+ kind = K;
+ }
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
- { return statement->firstSourceLocation(); }
+ { return leftBraceToken; }
+ SourceLocation lastSourceLocation() const override
+ { return rightBraceToken; }
+// attributes
+ SourceLocation leftBraceToken;
+ SourceLocation rightBraceToken;
+ ExportsList *exportsList = nullptr;
+};
+
+class QML_PARSER_EXPORT ExportDeclaration: public Statement
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(ExportDeclaration)
+
+ ExportDeclaration(FromClause *fromClause)
+ : fromClause(fromClause)
+ {
+ exportAll = true;
+ kind = K;
+ }
+
+ ExportDeclaration(ExportClause *exportClause, FromClause *fromClause)
+ : exportClause(exportClause), fromClause(fromClause)
+ {
+ kind = K;
+ }
+
+ ExportDeclaration(ExportClause *exportClause)
+ : exportClause(exportClause)
+ {
+ kind = K;
+ }
+
+ ExportDeclaration(bool exportDefault, Node *variableStatementOrDeclaration)
+ : variableStatementOrDeclaration(variableStatementOrDeclaration)
+ , exportDefault(exportDefault)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return exportToken; }
SourceLocation lastSourceLocation() const override
- { return statement->lastSourceLocation(); }
+ { return fromClause ? fromClause->lastSourceLocation() : (exportClause ? exportClause->lastSourceLocation() : variableStatementOrDeclaration->lastSourceLocation()); }
// attributes
- Statement *statement;
+ SourceLocation exportToken;
+ bool exportAll = false;
+ ExportClause *exportClause = nullptr;
+ FromClause *fromClause = nullptr;
+ Node *variableStatementOrDeclaration = nullptr;
+ bool exportDefault = false;
+};
+
+class QML_PARSER_EXPORT ESModule: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(Module)
+
+ ESModule(StatementList *body)
+ : body(body)
+ {
+ kind = K;
+ }
+
+ void accept0(Visitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return body ? body->firstSourceLocation() : SourceLocation(); }
+
+ SourceLocation lastSourceLocation() const override
+ { return body ? body->lastSourceLocation() : SourceLocation(); }
+
+// attributes
+ StatementList *body;
};
class QML_PARSER_EXPORT DebuggerStatement: public Statement
@@ -2336,51 +2884,13 @@ public:
UiObjectMember *member;
};
-class QML_PARSER_EXPORT UiQualifiedPragmaId: public Node
-{
-public:
- QQMLJS_DECLARE_AST_NODE(UiQualifiedPragmaId)
-
- UiQualifiedPragmaId(const QStringRef &name)
- : next(this), name(name)
- { kind = K; }
-
- UiQualifiedPragmaId(UiQualifiedPragmaId *previous, const QStringRef &name)
- : name(name)
- {
- kind = K;
- next = previous->next;
- previous->next = this;
- }
-
- UiQualifiedPragmaId *finish()
- {
- UiQualifiedPragmaId *head = next;
- next = nullptr;
- return head;
- }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return identifierToken; }
-
- SourceLocation lastSourceLocation() const override
- { return next ? next->lastSourceLocation() : identifierToken; }
-
-// attributes
- UiQualifiedPragmaId *next;
- QStringRef name;
- SourceLocation identifierToken;
-};
-
class QML_PARSER_EXPORT UiPragma: public Node
{
public:
QQMLJS_DECLARE_AST_NODE(UiPragma)
- UiPragma(UiQualifiedPragmaId *type)
- : pragmaType(type)
+ UiPragma(QStringRef name)
+ : name(name)
{ kind = K; }
void accept0(Visitor *visitor) override;
@@ -2392,7 +2902,7 @@ public:
{ return semicolonToken; }
// attributes
- UiQualifiedPragmaId *pragmaType;
+ QStringRef name;
SourceLocation pragmaToken;
SourceLocation semicolonToken;
};
diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h
index 140a757e51..996264db59 100644
--- a/src/qml/parser/qqmljsastfwd_p.h
+++ b/src/qml/parser/qqmljsastfwd_p.h
@@ -89,22 +89,27 @@ class IdentifierExpression;
class NullExpression;
class TrueLiteral;
class FalseLiteral;
+class SuperLiteral;
class NumericLiteral;
class StringLiteral;
+class TemplateLiteral;
class RegExpLiteral;
-class ArrayLiteral;
-class ObjectLiteral;
-class ElementList;
+class Pattern;
+class ArrayPattern;
+class ObjectPattern;
+class PatternElement;
+class PatternElementList;
+class PatternProperty;
+class PatternPropertyList;
class Elision;
-class PropertyAssignmentList;
-class PropertyGetterSetter;
-class PropertyNameAndValue;
class PropertyName;
class IdentifierPropertyName;
class StringLiteralPropertyName;
class NumericLiteralPropertyName;
+class ComputedPropertyName;
class ArrayMemberExpression;
class FieldMemberExpression;
+class TaggedTemplate;
class NewMemberExpression;
class NewExpression;
class CallExpression;
@@ -123,20 +128,19 @@ class NotExpression;
class BinaryExpression;
class ConditionalExpression;
class Expression; // ### rename
+class YieldExpression;
class Block;
+class LeftHandSideExpression;
class StatementList;
class VariableStatement;
class VariableDeclarationList;
-class VariableDeclaration;
class EmptyStatement;
class ExpressionStatement;
class IfStatement;
class DoWhileStatement;
class WhileStatement;
class ForStatement;
-class LocalForStatement;
class ForEachStatement;
-class LocalForEachStatement;
class ContinueStatement;
class BreakStatement;
class ReturnStatement;
@@ -154,14 +158,26 @@ class Finally;
class FunctionDeclaration;
class FunctionExpression;
class FormalParameterList;
-class FunctionBody;
+class ExportSpecifier;
+class ExportsList;
+class ExportClause;
+class ExportDeclaration;
class Program;
-class SourceElements;
-class SourceElement;
-class FunctionSourceElement;
-class StatementSourceElement;
+class ImportSpecifier;
+class ImportsList;
+class NamedImports;
+class NameSpaceImport;
+class NamedImport;
+class ImportClause;
+class FromClause;
+class ImportDeclaration;
+class ModuleItem;
+class ESModule;
class DebuggerStatement;
class NestedExpression;
+class ClassExpression;
+class ClassDeclaration;
+class ClassElementList;
// ui elements
class UiProgram;
@@ -179,7 +195,6 @@ class UiObjectMember;
class UiObjectMemberList;
class UiArrayMemberList;
class UiQualifiedId;
-class UiQualifiedPragmaId;
class UiHeaderItemList;
class UiEnumDeclaration;
class UiEnumMemberList;
diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h
index 13218f0e98..c925096de6 100644
--- a/src/qml/parser/qqmljsastvisitor_p.h
+++ b/src/qml/parser/qqmljsastvisitor_p.h
@@ -83,7 +83,6 @@ public:
virtual bool visit(UiObjectMemberList *) { return true; }
virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
- virtual bool visit(UiQualifiedPragmaId *) { return true; }
virtual bool visit(UiEnumDeclaration *) { return true; }
virtual bool visit(UiEnumMemberList *) { return true; }
@@ -102,7 +101,6 @@ public:
virtual void endVisit(UiObjectMemberList *) {}
virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
- virtual void endVisit(UiQualifiedPragmaId *) {}
virtual void endVisit(UiEnumDeclaration *) {}
virtual void endVisit(UiEnumMemberList *) { }
@@ -122,35 +120,41 @@ public:
virtual bool visit(FalseLiteral *) { return true; }
virtual void endVisit(FalseLiteral *) {}
+ virtual bool visit(SuperLiteral *) { return true; }
+ virtual void endVisit(SuperLiteral *) {}
+
virtual bool visit(StringLiteral *) { return true; }
virtual void endVisit(StringLiteral *) {}
+ virtual bool visit(TemplateLiteral *) { return true; }
+ virtual void endVisit(TemplateLiteral *) {}
+
virtual bool visit(NumericLiteral *) { return true; }
virtual void endVisit(NumericLiteral *) {}
virtual bool visit(RegExpLiteral *) { return true; }
virtual void endVisit(RegExpLiteral *) {}
- virtual bool visit(ArrayLiteral *) { return true; }
- virtual void endVisit(ArrayLiteral *) {}
+ virtual bool visit(ArrayPattern *) { return true; }
+ virtual void endVisit(ArrayPattern *) {}
- virtual bool visit(ObjectLiteral *) { return true; }
- virtual void endVisit(ObjectLiteral *) {}
+ virtual bool visit(ObjectPattern *) { return true; }
+ virtual void endVisit(ObjectPattern *) {}
- virtual bool visit(ElementList *) { return true; }
- virtual void endVisit(ElementList *) {}
+ virtual bool visit(PatternElementList *) { return true; }
+ virtual void endVisit(PatternElementList *) {}
- virtual bool visit(Elision *) { return true; }
- virtual void endVisit(Elision *) {}
+ virtual bool visit(PatternPropertyList *) { return true; }
+ virtual void endVisit(PatternPropertyList *) {}
- virtual bool visit(PropertyAssignmentList *) { return true; }
- virtual void endVisit(PropertyAssignmentList *) {}
+ virtual bool visit(PatternElement *) { return true; }
+ virtual void endVisit(PatternElement *) {}
- virtual bool visit(PropertyNameAndValue *) { return true; }
- virtual void endVisit(PropertyNameAndValue *) {}
+ virtual bool visit(PatternProperty *) { return true; }
+ virtual void endVisit(PatternProperty *) {}
- virtual bool visit(PropertyGetterSetter *) { return true; }
- virtual void endVisit(PropertyGetterSetter *) {}
+ virtual bool visit(Elision *) { return true; }
+ virtual void endVisit(Elision *) {}
virtual bool visit(NestedExpression *) { return true; }
virtual void endVisit(NestedExpression *) {}
@@ -164,12 +168,18 @@ public:
virtual bool visit(NumericLiteralPropertyName *) { return true; }
virtual void endVisit(NumericLiteralPropertyName *) {}
+ virtual bool visit(ComputedPropertyName *) { return true; }
+ virtual void endVisit(ComputedPropertyName *) {}
+
virtual bool visit(ArrayMemberExpression *) { return true; }
virtual void endVisit(ArrayMemberExpression *) {}
virtual bool visit(FieldMemberExpression *) { return true; }
virtual void endVisit(FieldMemberExpression *) {}
+ virtual bool visit(TaggedTemplate *) { return true; }
+ virtual void endVisit(TaggedTemplate *) {}
+
virtual bool visit(NewMemberExpression *) { return true; }
virtual void endVisit(NewMemberExpression *) {}
@@ -236,9 +246,6 @@ public:
virtual bool visit(VariableDeclarationList *) { return true; }
virtual void endVisit(VariableDeclarationList *) {}
- virtual bool visit(VariableDeclaration *) { return true; }
- virtual void endVisit(VariableDeclaration *) {}
-
virtual bool visit(EmptyStatement *) { return true; }
virtual void endVisit(EmptyStatement *) {}
@@ -257,15 +264,9 @@ public:
virtual bool visit(ForStatement *) { return true; }
virtual void endVisit(ForStatement *) {}
- virtual bool visit(LocalForStatement *) { return true; }
- virtual void endVisit(LocalForStatement *) {}
-
virtual bool visit(ForEachStatement *) { return true; }
virtual void endVisit(ForEachStatement *) {}
- virtual bool visit(LocalForEachStatement *) { return true; }
- virtual void endVisit(LocalForEachStatement *) {}
-
virtual bool visit(ContinueStatement *) { return true; }
virtual void endVisit(ContinueStatement *) {}
@@ -275,6 +276,9 @@ public:
virtual bool visit(ReturnStatement *) { return true; }
virtual void endVisit(ReturnStatement *) {}
+ virtual bool visit(YieldExpression *) { return true; }
+ virtual void endVisit(YieldExpression *) {}
+
virtual bool visit(WithStatement *) { return true; }
virtual void endVisit(WithStatement *) {}
@@ -317,20 +321,56 @@ public:
virtual bool visit(FormalParameterList *) { return true; }
virtual void endVisit(FormalParameterList *) {}
- virtual bool visit(FunctionBody *) { return true; }
- virtual void endVisit(FunctionBody *) {}
+ virtual bool visit(ClassExpression *) { return true; }
+ virtual void endVisit(ClassExpression *) {}
+
+ virtual bool visit(ClassDeclaration *) { return true; }
+ virtual void endVisit(ClassDeclaration *) {}
+
+ virtual bool visit(ClassElementList *) { return true; }
+ virtual void endVisit(ClassElementList *) {}
virtual bool visit(Program *) { return true; }
virtual void endVisit(Program *) {}
- virtual bool visit(SourceElements *) { return true; }
- virtual void endVisit(SourceElements *) {}
+ virtual bool visit(NameSpaceImport *) { return true; }
+ virtual void endVisit(NameSpaceImport *) {}
+
+ virtual bool visit(ImportSpecifier *) { return true; }
+ virtual void endVisit(ImportSpecifier *) {}
+
+ virtual bool visit(ImportsList *) { return true; }
+ virtual void endVisit(ImportsList *) {}
+
+ virtual bool visit(NamedImports *) { return true; }
+ virtual void endVisit(NamedImports *) {}
+
+ virtual bool visit(FromClause *) { return true; }
+ virtual void endVisit(FromClause *) {}
+
+ virtual bool visit(ImportClause *) { return true; }
+ virtual void endVisit(ImportClause *) {}
+
+ virtual bool visit(ImportDeclaration *) { return true; }
+ virtual void endVisit(ImportDeclaration *) {}
+
+ virtual bool visit(ExportSpecifier *) { return true; }
+ virtual void endVisit(ExportSpecifier *) {}
+
+ virtual bool visit(ExportsList *) { return true; }
+ virtual void endVisit(ExportsList *) {}
+
+ virtual bool visit(ExportClause *) { return true; }
+ virtual void endVisit(ExportClause *) {}
+
+ virtual bool visit(ExportDeclaration *) { return true; }
+ virtual void endVisit(ExportDeclaration *) {}
- virtual bool visit(FunctionSourceElement *) { return true; }
- virtual void endVisit(FunctionSourceElement *) {}
+ virtual bool visit(ModuleItem *) { return true; }
+ virtual void endVisit(ModuleItem *) {}
- virtual bool visit(StatementSourceElement *) { return true; }
- virtual void endVisit(StatementSourceElement *) {}
+ virtual bool visit(ESModule *) { return true; }
+ virtual void endVisit(ESModule *) {}
virtual bool visit(DebuggerStatement *) { return true; }
virtual void endVisit(DebuggerStatement *) {}
diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp
index b4f0debf85..97ce6ebea3 100644
--- a/src/qml/parser/qqmljsengine_p.cpp
+++ b/src/qml/parser/qqmljsengine_p.cpp
@@ -112,13 +112,6 @@ double integerFromString(const char *buf, int size, int radix)
return result;
}
-double integerFromString(const QString &str, int radix)
-{
- QByteArray ba = QStringRef(&str).trimmed().toLatin1();
- return integerFromString(ba.constData(), ba.size(), radix);
-}
-
-
Engine::Engine()
: _lexer(nullptr), _directives(nullptr)
{ }
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index af26bac0ff..1de907d296 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -63,9 +63,35 @@ QT_QML_BEGIN_NAMESPACE
namespace QQmlJS {
class Lexer;
-class Directives;
class MemoryPool;
+class QML_PARSER_EXPORT Directives {
+public:
+ virtual ~Directives() {}
+
+ virtual void pragmaLibrary()
+ {
+ }
+
+ virtual void importFile(const QString &jsfile, const QString &module, int line, int column)
+ {
+ Q_UNUSED(jsfile);
+ Q_UNUSED(module);
+ Q_UNUSED(line);
+ Q_UNUSED(column);
+ }
+
+ virtual void importModule(const QString &uri, const QString &version, const QString &module, int line, int column)
+ {
+ Q_UNUSED(uri);
+ Q_UNUSED(version);
+ Q_UNUSED(module);
+ Q_UNUSED(line);
+ Q_UNUSED(column);
+ }
+};
+
+
class QML_PARSER_EXPORT DiagnosticMessage
{
public:
diff --git a/src/qml/parser/qqmljsgrammar.cpp b/src/qml/parser/qqmljsgrammar.cpp
deleted file mode 100644
index 2aaeb385e3..0000000000
--- a/src/qml/parser/qqmljsgrammar.cpp
+++ /dev/null
@@ -1,1167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// This file was generated by qlalr - DO NOT EDIT!
-#include "qqmljsgrammar_p.h"
-
-QT_BEGIN_NAMESPACE
-
-const char *const QQmlJSGrammar::spell [] = {
- "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue",
- "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===",
- "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier",
- "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=",
- "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=",
- "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return",
- ")", ";", nullptr, "*", "*=", "string literal", "property", "signal", "readonly", "switch",
- "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^",
- "^=", "null", "true", "false", "const", "let", "debugger", "reserved word", "multiline string literal", "comment",
- nullptr, "enum", "public", "import", "pragma", "as", "on", "get", "set", nullptr,
- nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
-};
-
-const short QQmlJSGrammar::lhs [] = {
- 108, 108, 108, 108, 108, 108, 109, 115, 115, 118,
- 118, 118, 118, 121, 123, 119, 119, 120, 120, 120,
- 120, 120, 120, 120, 120, 124, 125, 117, 116, 128,
- 128, 129, 129, 130, 130, 127, 113, 113, 113, 113,
- 132, 132, 132, 132, 132, 132, 132, 113, 140, 140,
- 140, 140, 141, 141, 142, 142, 113, 113, 113, 113,
- 113, 113, 113, 113, 113, 113, 113, 113, 113, 113,
- 113, 113, 113, 113, 113, 113, 113, 145, 145, 145,
- 145, 126, 126, 126, 126, 126, 126, 126, 146, 146,
- 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
- 146, 146, 146, 146, 146, 146, 131, 148, 148, 148,
- 148, 147, 147, 152, 152, 152, 150, 150, 153, 153,
- 153, 153, 156, 156, 156, 156, 156, 156, 156, 156,
- 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- 156, 156, 156, 156, 156, 157, 157, 122, 122, 122,
- 122, 122, 160, 160, 161, 161, 161, 161, 159, 159,
- 162, 162, 163, 163, 164, 164, 164, 165, 165, 165,
- 165, 165, 165, 165, 165, 165, 165, 166, 166, 166,
- 166, 167, 167, 167, 168, 168, 168, 168, 169, 169,
- 169, 169, 169, 169, 169, 170, 170, 170, 170, 170,
- 170, 171, 171, 171, 171, 171, 172, 172, 172, 172,
- 172, 173, 173, 174, 174, 175, 175, 176, 176, 177,
- 177, 178, 178, 179, 179, 180, 180, 181, 181, 182,
- 182, 183, 183, 184, 184, 151, 151, 185, 185, 186,
- 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
- 186, 111, 111, 187, 187, 188, 188, 189, 189, 110,
- 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
- 110, 110, 110, 110, 133, 198, 198, 197, 197, 144,
- 144, 199, 199, 199, 200, 200, 202, 202, 201, 203,
- 206, 204, 204, 207, 205, 205, 134, 135, 135, 136,
- 136, 190, 190, 190, 190, 190, 190, 190, 190, 191,
- 191, 191, 191, 192, 192, 192, 192, 193, 193, 137,
- 138, 208, 208, 211, 211, 209, 209, 212, 210, 194,
- 195, 195, 139, 139, 139, 213, 214, 196, 196, 215,
- 143, 158, 158, 216, 216, 155, 155, 154, 154, 217,
- 114, 114, 218, 218, 112, 112, 149, 149, 219
-};
-
-const short QQmlJSGrammar::rhs [] = {
- 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
- 1, 2, 2, 1, 1, 2, 2, 2, 2, 3,
- 3, 5, 5, 4, 4, 2, 2, 0, 1, 1,
- 2, 1, 3, 2, 3, 2, 1, 5, 4, 4,
- 1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
- 1, 3, 0, 1, 2, 4, 6, 6, 3, 3,
- 7, 7, 4, 4, 5, 5, 8, 8, 5, 6,
- 6, 10, 6, 7, 1, 1, 5, 1, 3, 3,
- 5, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 3, 4, 5, 3, 4, 3, 1, 1, 2, 3,
- 4, 1, 2, 3, 7, 8, 1, 3, 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, 4,
- 3, 5, 1, 2, 4, 4, 4, 3, 0, 1,
- 1, 3, 1, 1, 1, 2, 2, 1, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 3, 3,
- 3, 1, 3, 3, 1, 3, 3, 3, 1, 3,
- 3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
- 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 5, 1, 5, 1, 3, 1, 3, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 0, 1, 1, 3, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 3, 1, 2, 0, 1, 3,
- 3, 1, 1, 1, 1, 3, 1, 3, 2, 2,
- 2, 0, 1, 2, 0, 1, 1, 2, 2, 7,
- 5, 7, 7, 7, 5, 9, 10, 7, 8, 2,
- 2, 3, 3, 2, 2, 3, 3, 3, 3, 5,
- 5, 3, 5, 1, 2, 0, 1, 4, 3, 3,
- 3, 3, 3, 3, 4, 5, 2, 2, 2, 1,
- 8, 8, 7, 1, 3, 0, 1, 0, 1, 1,
- 1, 1, 1, 2, 1, 1, 0, 1, 2
-};
-
-const short QQmlJSGrammar::action_default [] = {
- 0, 0, 28, 0, 0, 0, 28, 0, 195, 262,
- 226, 234, 230, 174, 246, 222, 3, 159, 90, 175,
- 238, 242, 163, 192, 173, 178, 158, 212, 199, 0,
- 97, 98, 93, 0, 87, 82, 367, 0, 0, 0,
- 0, 95, 0, 0, 91, 94, 86, 0, 0, 83,
- 85, 88, 84, 96, 89, 0, 92, 0, 0, 188,
- 0, 0, 175, 194, 177, 176, 0, 0, 0, 190,
- 191, 189, 193, 0, 223, 0, 0, 0, 0, 213,
- 0, 0, 0, 0, 0, 0, 203, 0, 0, 0,
- 197, 198, 196, 201, 205, 204, 202, 200, 215, 214,
- 216, 0, 231, 0, 227, 0, 0, 169, 156, 168,
- 157, 123, 124, 125, 151, 126, 153, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 152,
- 139, 140, 154, 141, 142, 143, 144, 145, 146, 147,
- 148, 149, 150, 155, 0, 0, 167, 263, 170, 0,
- 171, 0, 172, 166, 0, 259, 252, 250, 257, 258,
- 256, 255, 261, 254, 253, 251, 260, 247, 0, 235,
- 0, 0, 239, 0, 0, 243, 0, 0, 169, 161,
- 0, 160, 0, 165, 179, 0, 356, 356, 357, 0,
- 354, 0, 355, 0, 358, 270, 277, 276, 284, 272,
- 0, 273, 0, 359, 0, 366, 274, 275, 90, 280,
- 278, 363, 360, 365, 281, 0, 293, 0, 0, 0,
- 0, 350, 0, 367, 292, 264, 307, 0, 0, 0,
- 294, 0, 0, 282, 283, 0, 271, 279, 308, 309,
- 0, 356, 0, 0, 358, 0, 351, 352, 0, 340,
- 364, 0, 324, 325, 326, 327, 0, 320, 321, 322,
- 323, 348, 349, 0, 0, 0, 0, 0, 312, 313,
- 314, 268, 266, 228, 236, 232, 248, 224, 269, 0,
- 175, 240, 244, 217, 206, 0, 0, 225, 0, 0,
- 0, 0, 218, 0, 0, 0, 0, 0, 210, 208,
- 211, 209, 207, 220, 219, 221, 0, 233, 0, 229,
- 0, 267, 175, 0, 249, 264, 265, 0, 264, 0,
- 0, 316, 0, 0, 0, 318, 0, 237, 0, 0,
- 241, 0, 0, 245, 305, 0, 297, 306, 300, 0,
- 304, 0, 264, 298, 0, 264, 0, 0, 317, 0,
- 0, 0, 319, 0, 0, 0, 311, 0, 310, 90,
- 117, 368, 0, 0, 122, 286, 289, 0, 123, 293,
- 126, 153, 128, 129, 93, 134, 135, 87, 136, 292,
- 139, 91, 94, 264, 88, 96, 142, 89, 144, 92,
- 146, 147, 294, 149, 150, 155, 0, 119, 118, 121,
- 105, 120, 104, 0, 114, 287, 285, 0, 0, 0,
- 358, 0, 115, 163, 164, 169, 0, 162, 0, 328,
- 329, 0, 356, 0, 0, 358, 0, 116, 0, 0,
- 0, 331, 336, 334, 337, 0, 0, 335, 336, 0,
- 332, 0, 333, 288, 339, 0, 288, 338, 0, 341,
- 342, 0, 288, 343, 344, 0, 0, 345, 0, 0,
- 0, 346, 347, 181, 180, 0, 0, 0, 315, 0,
- 0, 0, 330, 302, 295, 0, 303, 299, 0, 301,
- 290, 0, 291, 296, 0, 0, 358, 0, 353, 108,
- 0, 0, 112, 99, 0, 101, 110, 0, 102, 111,
- 113, 103, 109, 100, 0, 106, 185, 183, 187, 184,
- 182, 186, 361, 6, 362, 4, 2, 75, 107, 0,
- 0, 0, 83, 85, 84, 37, 5, 0, 76, 0,
- 51, 50, 49, 0, 0, 51, 0, 0, 0, 52,
- 0, 67, 68, 0, 65, 0, 66, 41, 42, 43,
- 44, 46, 47, 71, 45, 0, 0, 0, 78, 0,
- 77, 80, 0, 81, 0, 79, 0, 51, 0, 0,
- 0, 0, 0, 61, 0, 62, 0, 0, 32, 0,
- 0, 72, 33, 0, 36, 34, 30, 0, 35, 31,
- 0, 63, 0, 64, 163, 0, 69, 73, 0, 0,
- 0, 0, 163, 288, 0, 70, 90, 123, 293, 126,
- 153, 128, 129, 93, 134, 135, 136, 292, 139, 91,
- 94, 264, 96, 142, 89, 144, 92, 146, 147, 294,
- 149, 150, 155, 74, 0, 59, 53, 60, 54, 0,
- 0, 0, 0, 56, 0, 57, 58, 55, 0, 0,
- 0, 0, 48, 0, 38, 39, 0, 40, 8, 0,
- 0, 9, 0, 11, 0, 10, 0, 1, 27, 15,
- 14, 26, 13, 12, 29, 7, 0, 18, 0, 19,
- 0, 24, 25, 0, 20, 21, 0, 22, 23, 16,
- 17, 369
-};
-
-const short QQmlJSGrammar::goto_default [] = {
- 7, 667, 213, 200, 211, 526, 513, 662, 675, 512,
- 661, 665, 663, 671, 22, 668, 666, 664, 18, 525,
- 587, 577, 584, 579, 553, 195, 199, 201, 206, 237,
- 214, 234, 568, 639, 638, 205, 236, 557, 26, 491,
- 490, 362, 361, 9, 360, 363, 204, 484, 364, 109,
- 17, 149, 24, 13, 148, 19, 25, 59, 23, 8,
- 28, 27, 283, 15, 277, 10, 273, 12, 275, 11,
- 274, 20, 281, 21, 282, 14, 276, 272, 313, 418,
- 278, 279, 207, 197, 196, 210, 209, 233, 198, 367,
- 366, 235, 475, 474, 335, 336, 477, 338, 476, 337,
- 431, 435, 438, 434, 433, 453, 454, 202, 188, 203,
- 212, 0
-};
-
-const short QQmlJSGrammar::action_index [] = {
- 350, 1528, 3041, 3041, 2937, 1235, 115, 105, 239, -108,
- 102, 93, 95, 205, -108, 422, 110, -108, -108, 727,
- 92, 118, 265, 256, -108, -108, -108, 507, 247, 1528,
- -108, -108, -108, 665, -108, -108, 2729, 1826, 1528, 1528,
- 1528, -108, 1041, 1528, -108, -108, -108, 1528, 1528, -108,
- -108, -108, -108, -108, -108, 1528, -108, 1528, 1528, -108,
- 1528, 1528, 174, 221, -108, -108, 1528, 1528, 1528, -108,
- -108, -108, 177, 1528, 422, 1528, 1528, 1528, 1528, 411,
- 1528, 1528, 1528, 1528, 1528, 1528, 211, 1528, 1528, 1528,
- 142, 148, 154, 217, 223, 226, 227, 231, 507, 385,
- 395, 1528, 57, 1528, 83, 2521, 1528, 1528, -108, -108,
- -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
- -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
- -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
- -108, -108, -108, -108, 179, 1528, -108, -108, 77, 36,
- -108, 1528, -108, -108, 1528, -108, -108, -108, -108, -108,
- -108, -108, -108, -108, -108, -108, -108, -108, 1528, 56,
- 1528, 1528, 80, 74, 1528, -108, 2521, 1528, 1528, -108,
- 125, -108, 55, -108, -108, 53, 410, 418, 72, 52,
- -108, 392, -108, 46, 3041, -108, -108, -108, -108, -108,
- 273, -108, 396, -108, 44, -108, -108, -108, 76, -108,
- -108, -108, 3041, -108, -108, 744, -108, 589, 98, 2937,
- 91, 90, 88, 3249, -108, 1528, -108, 86, 1528, 81,
- -108, 75, 73, -108, -108, 586, -108, -108, -108, -108,
- 71, 491, 69, 65, 3041, 64, -108, -108, 2937, -108,
- -108, 139, -108, -108, -108, -108, 134, -108, -108, -108,
- -108, -108, -108, 63, 66, 1528, 147, 264, -108, -108,
- -108, 1726, -108, 87, 68, 70, -108, 334, 82, 78,
- 796, 89, 121, 349, 318, 469, 1528, 330, 1528, 1528,
- 1528, 1528, 359, 1528, 1528, 1528, 1528, 1528, 284, 289,
- 303, 306, 313, 365, 369, 375, 1528, 58, 1528, 85,
- 1528, -108, 849, 1528, -108, 1528, 79, 59, 1528, 61,
- 2937, -108, 1528, 146, 2937, -108, 1528, 62, 1528, 1528,
- 106, 99, 1528, -108, 96, 176, 171, -108, -108, 1528,
- -108, 407, 1528, -108, 97, 1528, -52, 2937, -108, 1528,
- 120, 2937, -108, 1528, 123, 2937, 101, 2937, -108, 116,
- -108, 84, 45, 0, -108, -108, 2937, -39, 641, -3,
- 652, 156, 1528, 2937, -7, -11, 567, 2625, -21, 5,
- 945, 2, 94, 1629, 2625, -1, -26, 6, 1528, 10,
- -15, 1528, 14, 1528, -25, -12, 2833, -108, -108, -108,
- -108, -108, -108, 1528, -108, -108, -108, -14, -58, -13,
- 3041, -36, -108, 287, -108, 1528, -46, -108, 153, -108,
- -108, -31, 586, -57, -32, 3041, 11, -108, 1528, 168,
- 29, -108, 47, -108, 48, 169, 1528, -108, 49, 50,
- -108, 9, -108, 2937, -108, 136, 2937, -108, 275, -108,
- -108, 126, 2937, 35, -108, 33, 37, -108, 466, -4,
- 38, -108, -108, -108, -108, 1528, 130, 2937, -108, 1528,
- 117, 2937, -108, 34, -108, 296, -108, -108, 1528, -108,
- -108, 404, -108, -108, 12, 40, 3041, 13, -108, -108,
- 155, 1926, -108, -108, 2026, -108, -108, 2126, -108, -108,
- -108, -108, -108, -108, 144, -108, -108, -108, -108, -108,
- -108, -108, -108, -108, 3041, -108, -108, -108, 132, -27,
- 15, 1137, 218, -23, 17, -108, -108, 196, -108, 242,
- 8, -108, -108, 579, 237, -108, 127, 18, 415, -108,
- 103, -108, -108, 236, -108, 2223, -108, -108, -108, -108,
- -108, -108, -108, -108, -108, 27, 21, 137, 31, 20,
- -108, 23, -5, -108, -9, -108, 332, -10, 571, 201,
- 195, 586, 225, -108, 7, -108, 1137, 165, -108, 4,
- 1137, -108, -108, 1333, -108, -108, -108, 1431, -108, -108,
- 184, -108, 2223, -108, 331, 3, -108, -108, 202, 531,
- 26, 2417, 327, 3145, 1, -108, 25, 629, 24, 649,
- 124, 1528, 2937, 22, -6, 514, -8, 19, 1041, 16,
- 94, 1629, 28, 42, 67, 1528, 60, 43, 1528, 54,
- 1528, 41, 39, -108, 234, -108, 228, -108, 51, -2,
- 564, 233, 575, -108, 100, -108, -108, -108, 2320, 1137,
- 1826, 32, -108, 122, -108, -108, 30, -108, -108, 1137,
- 1137, 104, 903, -108, 308, -108, 108, -108, -108, 133,
- 119, -108, -108, -108, -108, -108, 451, -108, 164, -108,
- 161, -108, -108, 458, -108, -108, 151, -108, -108, -108,
- -108, -108,
-
- -112, 18, 86, 97, 69, 316, 7, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -64,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, 66,
- -112, -112, -112, -17, -112, -112, -10, -36, 3, 90,
- 95, -112, 149, 74, -112, -112, -112, 67, 13, -112,
- -112, -112, -112, -112, -112, 178, -112, 181, 185, -112,
- 189, 190, -112, -112, -112, -112, 198, 208, 212, -112,
- -112, -112, -112, 209, -112, 201, 164, 111, 113, -112,
- 116, 130, 131, 132, 134, 142, -112, 118, 124, 144,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, 154, -112, 155, -112, 268, 28, -8, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, 42, -112, -112, -112, -112,
- -112, 47, -112, -112, 50, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, 159, -112,
- 158, 56, -112, -112, 57, -112, 362, 60, 157, -112,
- -112, -112, -112, -112, -112, -112, 20, 151, -112, -112,
- -112, 25, -112, -112, 30, -112, -112, -112, -112, -112,
- -112, -112, 31, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, 233, -112, -112, 34, -112, 35, -112, 225,
- -112, 36, -112, 216, -112, 55, -112, -112, 53, 39,
- -112, -112, -112, -112, -112, 19, -112, -112, -112, -112,
- -112, 94, -112, -112, 92, -112, -112, -112, 117, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, 33, -112, -112, -112, -112,
- -112, 88, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, 51, 220, -112, 227, 235,
- 236, 244, -112, 21, 17, 102, 91, 89, -112, -112,
- -112, -112, -112, -112, -112, -112, 211, -112, 247, -112,
- 257, -112, -112, 264, -112, 75, -112, -112, 103, -112,
- 112, -112, 29, -112, 73, -112, 263, -112, 255, 254,
- -112, -112, 245, -112, -112, -112, -112, -112, -112, 248,
- -112, 65, 105, -112, -112, 99, -112, 162, -112, 37,
- -112, 115, -112, 44, -112, 135, -112, 137, -112, -112,
- -112, -112, -112, -112, -112, -112, 138, -112, 24, -112,
- 26, -112, 104, 140, -112, -112, 32, 64, -112, -112,
- 174, -112, -112, 48, 87, -112, -112, -112, 54, -112,
- 40, 71, -112, 150, -112, -112, 197, -112, -112, -112,
- -112, -112, -112, 12, -112, -112, -112, -112, -112, -112,
- 206, -112, -112, -112, -112, 207, -112, -112, -112, -112,
- -112, -112, 231, -112, -112, 239, -112, -112, 43, -112,
- -112, -112, -112, -112, -59, -112, 38, -112, -62, -112,
- -112, -112, -112, 258, -112, -112, 259, -112, -112, -112,
- -112, -112, 163, -72, -112, -112, 41, -112, 62, -112,
- 61, -112, -112, -112, -112, 59, -112, 193, -112, 58,
- -112, 204, -112, -112, -112, -112, -112, -112, 52, -112,
- -112, 175, -112, -112, -112, -112, 186, -112, -112, -112,
- -112, 49, -112, -112, 173, -112, -112, 45, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, 213, -112, -112, -112, -112, -112,
- -112, 46, -112, -112, -112, -112, -112, -112, -112, 27,
- -112, -112, -112, -18, -9, -112, -112, -112, 15, -112,
- -112, -112, -112, -112, -112, 331, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -112, -112, 11, -6,
- -112, 10, -112, -112, -112, -112, 156, -112, -112, -112,
- 240, -112, -112, 330, -112, -112, -112, 332, -112, -112,
- -112, -112, 376, -112, -112, 8, -112, -112, -7, 76,
- -112, 358, -112, 228, 5, -112, -112, 6, -112, 4,
- -112, 79, 221, -112, -112, 2, -112, -112, 174, -112,
- -112, 16, -112, -112, -112, 14, -112, -16, 70, -112,
- 63, -112, -112, -112, -112, -112, -30, -112, -112, -112,
- -15, -28, -13, -112, -112, -112, -112, -112, 460, 93,
- 307, -12, -112, -112, -112, -112, -11, -112, -112, -2,
- -1, 85, 84, -112, -112, -112, -112, -112, -112, -112,
- -112, -112, -112, -112, -112, -112, -3, -112, -112, -112,
- -112, -112, -112, 0, -112, -112, -112, -112, -112, -112,
- -112, -112
-};
-
-const short QQmlJSGrammar::action_info [] = {
- -132, 425, 409, 424, -151, 422, -120, 403, 347, -140,
- 428, 465, -152, -143, 417, 353, 406, -145, 452, 412,
- 410, -148, 408, -140, 469, 271, -152, 569, 353, -132,
- 271, -151, 248, 601, 583, -120, 583, 583, 565, 529,
- 562, 576, 563, 598, 555, 534, 634, 539, 564, 561,
- 558, 478, 436, 436, 436, 456, 460, 443, 644, 641,
- 556, -148, 432, 583, 442, 583, 427, -145, 488, 458,
- 452, 452, 485, 486, -143, 469, 452, 465, 428, 194,
- 191, 174, 168, 248, 73, 151, 286, 145, 286, 187,
- 310, 326, 396, 0, 168, 0, 153, 0, 244, 247,
- 402, -121, 265, 73, 101, 691, 332, 241, 326, 469,
- 306, 465, 193, 339, 452, 183, 306, 357, 145, 246,
- 318, 320, 428, 248, 353, 145, 186, 271, 145, 243,
- 580, 145, 455, 145, 176, 0, 103, 308, 145, 315,
- 264, 101, 537, 446, 145, 559, 456, 176, 176, 308,
- 0, 538, 145, 177, 145, 145, 0, 0, 345, 262,
- 261, 646, 645, 494, 542, 541, 177, 177, 170, 690,
- 689, 328, 171, 580, 103, 329, 145, 471, 654, 439,
- 351, 181, 60, 355, 341, 262, 261, 145, 60, 66,
- 467, 592, 560, 61, 60, 260, 259, 659, 660, 61,
- 255, 254, 349, 648, 505, 61, 324, 267, 659, 660,
- 537, 495, 688, 687, 420, 419, 64, 262, 261, 571,
- 105, 581, 682, 681, 440, 685, 684, 65, 430, 583,
- 535, 535, 574, 66, 67, 146, 87, 342, 88, 106,
- 68, 107, 87, 545, 88, 593, 591, 567, 87, 89,
- 88, 87, 87, 88, 88, 89, 87, 535, 88, 683,
- 0, 89, 535, 0, 89, 89, 535, 0, 66, 89,
- 636, 530, 87, 0, 88, 0, 532, 532, 67, 60,
- 176, 145, 0, 145, 68, 89, 575, 573, 531, 531,
- 61, 0, 649, 532, 0, 637, 635, 546, 544, 177,
- 0, 178, 176, 532, 481, 531, 0, 0, 532, 87,
- 0, 88, 532, 67, 87, 531, 88, 532, 0, 68,
- 531, 177, 89, 415, 531, 270, 268, 89, 87, 531,
- 88, 87, 0, 88, 239, 238, 450, 449, 87, 0,
- 88, 89, 176, 87, 89, 88, 176, 176, 288, 289,
- 0, 89, 288, 289, 269, 678, 89, 482, 480, 0,
- -107, 177, 0, 178, -107, 177, 177, 178, 415, 679,
- 677, 0, 293, 294, 0, 290, 291, 0, 0, 290,
- 291, 295, 293, 294, 296, 0, 297, 0, 293, 294,
- 0, 295, 293, 294, 296, 0, 297, 295, 293, 294,
- 296, 295, 297, 676, 296, 0, 297, 295, 80, 81,
- 296, 0, 297, 0, 0, 0, 82, 83, 80, 81,
- 84, 35, 85, 0, 0, 35, 82, 83, 0, 0,
- 84, 0, 85, 35, 80, 81, 35, 0, 0, 35,
- 75, 76, 82, 83, 35, 0, 84, 35, 85, 0,
- 6, 5, 4, 1, 3, 2, 0, 0, 49, 52,
- 50, 0, 49, 52, 50, 0, 0, 77, 78, 0,
- 49, 52, 50, 49, 52, 50, 49, 52, 50, 0,
- 35, 49, 52, 50, 49, 52, 50, 35, 46, 34,
- 51, 0, 46, 34, 51, 35, 0, 0, 35, 0,
- 46, 34, 51, 46, 34, 51, 46, 34, 51, 0,
- 0, 46, 34, 51, 46, 34, 51, 49, 52, 50,
- 35, 0, 0, 0, 49, 52, 50, 0, 0, 0,
- 80, 81, 49, 52, 50, 49, 52, 50, 82, 83,
- 0, 0, 84, 35, 85, 0, 537, 46, 34, 51,
- 186, 0, 0, 0, 46, 34, 51, 49, 52, 50,
- 35, 0, 46, 34, 51, 46, 34, 51, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 537,
- 49, 52, 50, 0, 0, 0, 537, 46, 34, 51,
- 537, 0, 0, 35, 537, 0, 35, 49, 52, 50,
- 35, 0, 0, 186, 35, 0, 0, 0, 35, 0,
- 46, 34, 51, 0, 0, 35, 0, 0, 35, 0,
- 0, 0, 0, 0, 0, 0, 0, 46, 34, 51,
- 49, 52, 50, 49, 52, 50, 0, 49, 52, 50,
- 0, 49, 52, 50, 0, 49, 52, 50, 0, 0,
- 258, 257, 49, 52, 50, 49, 52, 50, 35, 0,
- 46, 34, 51, 46, 34, 51, 0, 46, 34, 51,
- 35, 46, 34, 51, 0, 46, 34, 51, 35, 0,
- 0, 35, 46, 34, 51, 46, 34, 51, 0, 0,
- 253, 252, 0, 0, 35, 49, 52, 50, 0, 0,
- 0, 186, 253, 252, 0, 0, 0, 49, 52, 50,
- 258, 257, 0, 258, 257, 49, 52, 50, 49, 52,
- 50, 0, 0, 0, 0, 46, 34, 51, 0, 0,
- 155, 49, 52, 50, 0, 0, 0, 46, 34, 51,
- 156, 0, 0, 0, 157, 46, 34, 51, 46, 34,
- 51, 0, 0, 158, 0, 159, 0, 0, 0, 0,
- 0, 46, 34, 51, 0, 0, 160, 0, 161, 64,
- 0, 0, 0, 35, 0, 0, 162, 0, 0, 163,
- 65, 0, 0, 0, 0, 164, 0, 0, 0, 0,
- 0, 165, 0, 0, 0, 0, 0, 0, 0, 155,
- 0, 0, 0, 0, 0, 253, 252, 166, 0, 156,
- 49, 52, 50, 157, 0, 0, 0, 0, 0, 0,
- 0, 0, 158, 0, 159, 0, 0, 322, 0, 0,
- 0, 0, 0, 0, 0, 160, 0, 161, 64, 0,
- 46, 34, 51, 0, 0, 162, 0, 0, 163, 65,
- 0, 0, 155, 0, 164, 0, 0, 0, 0, 0,
- 165, 0, 156, 0, 0, 0, 157, 0, 0, 0,
- 0, 0, 0, 0, 0, 158, 166, 159, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 160, 0,
- 161, 64, 0, 0, 0, 0, 0, 0, 162, 0,
- 0, 163, 65, 0, 0, 0, 0, 164, 0, 0,
- 0, 0, 0, 165, 0, 30, 31, 0, 0, 0,
- 0, 0, 0, 0, 0, 33, 0, 0, 0, 166,
- 0, 0, 35, 0, 0, 0, 36, 37, 0, 38,
- 0, 0, 0, 0, 0, 0, 521, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 30, 31, 0,
- 0, 0, 0, 0, 0, 0, 0, 33, 53, 49,
- 52, 50, 0, 54, 35, 0, 0, 0, 36, 37,
- 0, 38, 0, 0, 44, 56, 32, 0, 42, 0,
- 0, 41, 45, 0, 0, 0, 0, 0, 0, 46,
- 34, 51, 0, 0, 0, 0, 0, 0, 0, 0,
- 53, 49, 52, 50, 0, 54, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 44, 56, 32, 0,
- 0, 0, 0, 41, 0, 0, 0, 0, 0, 0,
- 0, 46, 34, 51, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 30, 31, 0, 0, 0, 0, 0,
- 0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
- 35, 0, 0, 0, 36, 37, 0, 38, 0, 0,
- 0, 0, 0, 0, 42, 0, 0, 0, 45, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 53, 49, 52, 50,
- 0, 54, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 44, 56, 32, 0, 0, 0, 0, 41,
- 0, 0, 0, 0, 0, 0, 0, 46, 34, 51,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 30,
- 31, 0, 0, 0, 0, 0, 0, 0, 0, 33,
- 0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
- 36, 37, 0, 38, 0, 0, 0, 0, 0, 0,
- 521, 0, 0, 0, 45, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 53, 49, 52, 50, 0, 54, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 44, 56,
- 32, 0, 0, 0, 0, 41, 0, 0, 0, 0,
- 0, 0, 0, 46, 34, 51, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 519, 0, 30, 31, 0,
- 0, 0, 0, 0, 0, 0, 0, 221, 0, 0,
- 0, 0, 0, 0, 35, 0, 0, 0, 36, 37,
- 0, 38, 0, 0, 0, 0, 0, 0, 521, 0,
- 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 53, 522, 524, 523, 0, 54, 0, 0, 0, 0,
- 230, 0, 0, 0, 0, 0, 44, 56, 32, 216,
- 224, 0, 0, 41, 0, 0, 520, 0, 0, 0,
- 0, 46, 34, 51, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 519, 0, 30, 31, 0, 0, 0,
- 0, 0, 0, 0, 0, 221, 0, 0, 0, 0,
- 0, 0, 35, 0, 0, 0, 36, 37, 0, 38,
- 0, 0, 0, 0, 0, 0, 521, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 585, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 53, 522,
- 524, 523, 0, 54, 0, 0, 0, 0, 230, 0,
- 0, 0, 0, 0, 44, 56, 32, 216, 224, 0,
- 0, 41, 0, 0, 520, 0, 0, 0, 0, 46,
- 34, 51, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 519, 0, 30, 31, 0, 0, 0, 0, 0,
- 0, 0, 0, 221, 0, 0, 0, 0, 0, 0,
- 35, 0, 0, 0, 36, 37, 0, 38, 0, 0,
- 0, 0, 0, 0, 521, 0, 0, 0, 45, 0,
- 0, 0, 0, 0, 0, 0, 588, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 53, 522, 524, 523,
- 0, 54, 0, 0, 0, 0, 230, 0, 0, 0,
- 0, 0, 44, 56, 32, 216, 224, 0, 0, 41,
- 0, 0, 520, 0, 0, 0, 0, 46, 34, 51,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
- 30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
- 33, 0, 0, 0, 0, 0, 0, 35, 0, 0,
- 0, 36, 37, 0, 38, 0, 0, 0, 39, 0,
- 40, 42, 43, 0, 0, 45, 0, 0, 0, 47,
- 0, 48, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 53, 49, 52, 50, 0, 54, 0,
- 55, 0, 57, 0, 58, 0, 0, 0, 0, 44,
- 56, 32, 0, 0, 0, 0, 41, 0, 0, 0,
- 0, 0, 0, 0, 46, 34, 51, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -141, 0, 0, 0,
- 29, 30, 31, 0, 0, 0, 0, 0, 0, 0,
- 0, 33, 0, 0, 0, 0, 0, 0, 35, 0,
- 0, 0, 36, 37, 0, 38, 0, 0, 0, 39,
- 0, 40, 42, 43, 0, 0, 45, 0, 0, 0,
- 47, 0, 48, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 53, 49, 52, 50, 0, 54,
- 0, 55, 0, 57, 0, 58, 0, 0, 0, 0,
- 44, 56, 32, 0, 0, 0, 0, 41, 0, 0,
- 0, 0, 0, 0, 0, 46, 34, 51, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 0, 0, 0, 36,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
- 43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 53, 49, 52, 50, 0, 54, 0, 55, 0,
- 57, 285, 58, 0, 0, 0, 0, 44, 56, 32,
- 0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
- 0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 492, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 0, 0, 0, 36,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
- 43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
- 0, 0, 493, 0, 0, 0, 0, 0, 0, 0,
- 0, 53, 49, 52, 50, 0, 54, 0, 55, 0,
- 57, 0, 58, 0, 0, 0, 0, 44, 56, 32,
- 0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
- 0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 500, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 0, 0, 0, 36,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
- 43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
- 0, 0, 503, 0, 0, 0, 0, 0, 0, 0,
- 0, 53, 49, 52, 50, 0, 54, 0, 55, 0,
- 57, 0, 58, 0, 0, 0, 0, 44, 56, 32,
- 0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
- 0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 492, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 0, 0, 0, 36,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
- 43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
- 0, 0, 498, 0, 0, 0, 0, 0, 0, 0,
- 0, 53, 49, 52, 50, 0, 54, 0, 55, 0,
- 57, 0, 58, 0, 0, 0, 0, 44, 56, 32,
- 0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
- 0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 500, 0, 0, 29, 30, 31,
- 0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 0, 0, 0, 36,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
- 43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
- 0, 0, 501, 0, 0, 0, 0, 0, 0, 0,
- 0, 53, 49, 52, 50, 0, 54, 0, 55, 0,
- 57, 0, 58, 0, 0, 0, 0, 44, 56, 32,
- 0, 0, 0, 0, 41, 0, 0, 0, 0, 0,
- 0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 29, 30, 31, 0, 0, 0,
- 0, 0, 0, 0, 0, 33, 0, 0, 0, 0,
- 0, 0, 35, 222, 0, 0, 223, 37, 0, 38,
- 0, 0, 0, 39, 0, 40, 42, 43, 0, 0,
- 45, 0, 0, 0, 47, 0, 48, 0, 0, 0,
- 0, 0, 0, 0, 226, 0, 0, 0, 53, 49,
- 52, 50, 227, 54, 0, 55, 229, 57, 0, 58,
- 0, 232, 0, 0, 44, 56, 32, 0, 0, 0,
- 0, 41, 0, 0, 0, 0, 0, 0, 0, 46,
- 34, 51, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 29, 30, 31, 0, 0, 0, 0, 0, 0,
- 0, 0, 33, 0, 0, 0, 0, 0, 0, 35,
- 222, 0, 0, 603, 650, 0, 38, 0, 0, 0,
- 39, 0, 40, 42, 43, 0, 0, 45, 0, 0,
- 0, 47, 0, 48, 0, 0, 0, 0, 0, 0,
- 0, 226, 0, 0, 0, 53, 49, 52, 50, 227,
- 54, 0, 55, 229, 57, 0, 58, 0, 232, 0,
- 0, 44, 56, 32, 0, 0, 0, 0, 41, 0,
- 0, 0, 0, 0, 0, 0, 46, 34, 51, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 29, 30,
- 31, 0, 0, 0, 0, 0, 0, 0, 0, 33,
- 0, 0, 0, 0, 0, 0, 35, 222, 0, 0,
- 603, 37, 0, 38, 0, 0, 0, 39, 0, 40,
- 42, 43, 0, 0, 45, 0, 0, 0, 47, 0,
- 48, 0, 0, 0, 0, 0, 0, 0, 226, 0,
- 0, 0, 53, 49, 52, 50, 227, 54, 0, 55,
- 229, 57, 0, 58, 0, 232, 0, 0, 44, 56,
- 32, 0, 0, 0, 0, 41, 0, 0, 0, 0,
- 0, 0, 0, 46, 34, 51, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 111, 112, 113, 0, 0,
- 115, 117, 118, 0, 0, 119, 0, 120, 0, 0,
- 0, 123, 124, 125, 0, 0, 0, 0, 0, 0,
- 35, 126, 127, 128, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 130, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 133, 0, 0, 0, 0, 0, 0, 49, 52, 50,
- 134, 135, 136, 0, 138, 139, 140, 141, 142, 143,
- 0, 0, 131, 137, 122, 114, 129, 116, 132, 0,
- 0, 0, 121, 0, 0, 0, 0, 46, 34, 51,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 111,
- 112, 113, 0, 0, 115, 117, 118, 0, 0, 119,
- 0, 120, 0, 0, 0, 123, 124, 125, 0, 0,
- 0, 0, 0, 0, 35, 126, 127, 128, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 130, 0,
- 0, 0, 399, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 133, 0, 0, 0, 0, 0,
- 401, 49, 52, 50, 134, 135, 136, 0, 138, 139,
- 140, 141, 142, 143, 0, 0, 131, 137, 122, 114,
- 129, 116, 132, 0, 0, 0, 121, 0, 0, 0,
- 0, 46, 34, 51, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 111, 112, 113, 0, 0, 115, 117,
- 118, 0, 0, 119, 0, 120, 0, 0, 0, 123,
- 124, 125, 0, 0, 0, 0, 0, 0, 35, 126,
- 127, 128, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 130, 0, 0, 0, 399, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 133, 0,
- 0, 0, 0, 0, 401, 49, 52, 50, 134, 135,
- 136, 0, 138, 139, 140, 141, 142, 143, 0, 0,
- 131, 137, 122, 114, 129, 116, 132, 0, 0, 0,
- 121, 0, 0, 0, 0, 46, 377, 384, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 111, 112, 113,
- 0, 0, 115, 117, 118, 0, 0, 119, 0, 120,
- 0, 0, 0, 123, 124, 125, 0, 0, 0, 0,
- 0, 0, 35, 126, 127, 128, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 130, 0, 0, 0,
- 399, 0, 0, 0, 0, 0, 0, 0, 400, 0,
- 0, 0, 133, 0, 0, 0, 0, 0, 401, 49,
- 52, 50, 134, 135, 136, 0, 138, 139, 140, 141,
- 142, 143, 0, 0, 131, 137, 122, 114, 129, 116,
- 132, 0, 0, 0, 121, 0, 0, 0, 0, 46,
- 377, 384, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 215, 0, 0, 0, 0, 217, 0, 29, 30,
- 31, 219, 0, 0, 0, 0, 0, 0, 220, 33,
- 0, 0, 0, 0, 0, 0, 35, 222, 0, 0,
- 223, 37, 0, 38, 0, 0, 0, 39, 0, 40,
- 42, 43, 0, 0, 45, 0, 0, 0, 47, 0,
- 48, 0, 0, 0, 0, 0, 225, 0, 226, 0,
- 0, 0, 53, 49, 52, 50, 227, 54, 228, 55,
- 229, 57, 230, 58, 231, 232, 0, 0, 44, 56,
- 32, 216, 224, 218, 0, 41, 0, 0, 0, 0,
- 0, 0, 0, 46, 34, 51, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 215, 0, 0, 0, 0,
- 217, 0, 29, 30, 31, 219, 0, 0, 0, 0,
- 0, 0, 220, 221, 0, 0, 0, 0, 0, 0,
- 35, 222, 0, 0, 223, 37, 0, 38, 0, 0,
- 0, 39, 0, 40, 42, 43, 0, 0, 45, 0,
- 0, 0, 47, 0, 48, 0, 0, 0, 0, 0,
- 225, 0, 226, 0, 0, 0, 53, 49, 52, 50,
- 227, 54, 228, 55, 229, 57, 230, 58, 231, 232,
- 0, 0, 44, 56, 32, 216, 224, 218, 0, 41,
- 0, 0, 0, 0, 0, 0, 0, 46, 34, 51,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 607,
- 112, 113, 0, 0, 609, 117, 611, 30, 31, 612,
- 0, 120, 0, 0, 0, 123, 614, 615, 0, 0,
- 0, 0, 0, 0, 35, 616, 127, 128, 223, 37,
- 0, 38, 0, 0, 0, 39, 0, 40, 618, 43,
- 0, 0, 620, 0, 0, 0, 47, 0, 48, 0,
- 0, 0, 0, 0, 621, 0, 226, 0, 0, 0,
- 622, 49, 52, 50, 623, 624, 625, 55, 627, 628,
- 629, 630, 631, 632, 0, 0, 619, 626, 613, 608,
- 617, 610, 132, 41, 0, 0, 121, 0, 0, 0,
- 0, 46, 377, 384, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 368, 112, 113, 0, 0, 370, 117,
- 372, 30, 31, 373, 0, 120, 0, 0, 0, 123,
- 375, 376, 0, 0, 0, 0, 0, 0, 35, 378,
- 127, 128, 223, 37, 0, 38, 0, 0, 0, 39,
- 0, 40, 380, 43, 0, 0, 382, 0, 0, 0,
- 47, 0, 48, 0, -288, 0, 0, 0, 383, 0,
- 226, 0, 0, 0, 385, 49, 52, 50, 386, 387,
- 388, 55, 390, 391, 392, 393, 394, 395, 0, 0,
- 381, 389, 374, 369, 379, 371, 132, 41, 0, 0,
- 121, 0, 0, 0, 0, 46, 377, 384, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-
- 543, 185, 640, 647, 642, 643, 504, 489, 397, 451,
- 655, 657, 669, 670, 154, 680, 658, 448, 686, 316,
- 185, 16, 256, 536, 251, 599, 570, 633, 572, 590,
- 597, 144, 323, 540, 457, 150, 266, 473, 190, 441,
- 350, 445, 251, 192, 256, 437, 429, 354, 208, 240,
- 185, 316, 251, 256, 185, 404, 448, 448, 316, 533,
- 566, 470, 466, 180, 451, 451, 462, 0, 62, 334,
- 510, 516, 62, 0, 0, 325, 62, 299, 316, 0,
- 459, 298, 397, 334, 0, 147, 461, 208, 499, 0,
- 152, 208, 502, 167, 600, 479, 673, 672, 518, 173,
- 175, 515, 316, 674, 208, 397, 316, 518, 316, 407,
- 208, 0, 190, 0, 321, 208, 656, 352, 62, 249,
- 464, 62, 62, 184, 509, 62, 62, 463, 463, 62,
- 208, 508, 421, 208, 62, 208, 184, 356, 245, 358,
- 405, 242, 263, 280, 62, 62, 62, 506, 284, 302,
- 62, 301, 507, 208, 317, 208, 208, 62, 208, 62,
- 343, 184, 300, 413, 348, 365, 62, 0, 62, 190,
- 518, 62, 99, 62, 100, 578, 86, 90, 346, 62,
- 208, 208, 319, 91, 344, 62, 62, 62, 413, 62,
- 93, 94, 95, 473, 96, 468, 514, 62, 189, 62,
- 150, 414, 97, 92, 208, 62, 472, 464, 182, 62,
- 62, 208, 497, 62, 62, 397, 496, 250, 365, 62,
- 104, 102, 208, 263, 208, 98, 414, 263, 169, 172,
- 365, 208, 487, 62, 359, 511, 62, 250, 463, 208,
- 62, 398, 464, 208, 62, 62, 606, 63, 72, 190,
- 150, 208, 411, 62, 518, 69, 62, 208, 416, 582,
- 365, 365, 79, 62, 62, 70, 62, 62, 483, 71,
- 0, 284, 74, 0, 0, 62, 208, 208, 423, 307,
- 284, 0, 62, 0, 287, 426, 108, 284, 0, 292,
- 62, 62, 0, 0, 0, 284, 284, 303, 304, 62,
- 312, 0, 62, 312, 284, 284, 305, 284, 284, 312,
- 62, 0, 312, 309, 284, 284, 110, 284, 62, 312,
- 0, 594, 333, 284, 284, 340, 578, 330, 653, 0,
- 518, 331, 0, 327, 311, 586, 0, 589, 0, 527,
- 0, 314, 0, 0, 518, 0, 518, 444, 447, 0,
- 489, 517, 528, 527, 0, 527, 547, 548, 549, 550,
- 554, 551, 552, 0, 0, 517, 528, 517, 528, 0,
- 0, 0, 602, 0, 0, 0, 0, 0, 0, 0,
- 108, 604, 605, 547, 548, 549, 550, 554, 551, 552,
- 594, 0, 0, 0, 0, 0, 0, 0, 0, 595,
- 596, 547, 548, 549, 550, 554, 551, 552, 0, 0,
- 110, 179, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 602, 0, 0, 0, 0, 0,
- 0, 0, 0, 651, 652, 547, 548, 549, 550, 554,
- 551, 552, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0
-};
-
-const short QQmlJSGrammar::action_check [] = {
- 7, 33, 60, 60, 7, 36, 7, 7, 60, 7,
- 36, 36, 7, 7, 60, 36, 55, 7, 33, 55,
- 33, 7, 36, 7, 36, 36, 7, 37, 36, 7,
- 36, 7, 7, 7, 33, 7, 33, 33, 47, 66,
- 17, 34, 47, 66, 29, 37, 29, 29, 17, 29,
- 29, 17, 5, 5, 5, 20, 60, 7, 60, 8,
- 33, 7, 33, 33, 55, 33, 55, 7, 55, 36,
- 33, 33, 60, 33, 7, 36, 33, 36, 36, 33,
- 8, 7, 2, 7, 1, 8, 1, 8, 1, 36,
- 8, 2, 8, -1, 2, -1, 60, -1, 33, 55,
- 55, 7, 36, 1, 48, 0, 7, 36, 2, 36,
- 48, 36, 60, 17, 33, 60, 48, 16, 8, 55,
- 61, 60, 36, 7, 36, 8, 36, 36, 8, 60,
- 8, 8, 6, 8, 15, -1, 79, 79, 8, 61,
- 77, 48, 15, 7, 8, 8, 20, 15, 15, 79,
- -1, 24, 8, 34, 8, 8, -1, -1, 61, 61,
- 62, 61, 62, 8, 61, 62, 34, 34, 50, 61,
- 62, 50, 54, 8, 79, 54, 8, 60, 56, 10,
- 60, 56, 40, 60, 8, 61, 62, 8, 40, 12,
- 60, 7, 55, 51, 40, 61, 62, 93, 94, 51,
- 61, 62, 31, 7, 60, 51, 60, 60, 93, 94,
- 15, 56, 61, 62, 61, 62, 42, 61, 62, 24,
- 15, 56, 61, 62, 55, 61, 62, 53, 60, 33,
- 29, 29, 7, 12, 57, 56, 25, 61, 27, 34,
- 63, 36, 25, 7, 27, 61, 62, 29, 25, 38,
- 27, 25, 25, 27, 27, 38, 25, 29, 27, 95,
- -1, 38, 29, -1, 38, 38, 29, -1, 12, 38,
- 36, 29, 25, -1, 27, -1, 75, 75, 57, 40,
- 15, 8, -1, 8, 63, 38, 61, 62, 87, 87,
- 51, -1, 96, 75, -1, 61, 62, 61, 62, 34,
- -1, 36, 15, 75, 8, 87, -1, -1, 75, 25,
- -1, 27, 75, 57, 25, 87, 27, 75, -1, 63,
- 87, 34, 38, 36, 87, 61, 62, 38, 25, 87,
- 27, 25, -1, 27, 61, 62, 61, 62, 25, -1,
- 27, 38, 15, 25, 38, 27, 15, 15, 18, 19,
- -1, 38, 18, 19, 90, 47, 38, 61, 62, -1,
- 33, 34, -1, 36, 33, 34, 34, 36, 36, 61,
- 62, -1, 23, 24, -1, 45, 46, -1, -1, 45,
- 46, 32, 23, 24, 35, -1, 37, -1, 23, 24,
- -1, 32, 23, 24, 35, -1, 37, 32, 23, 24,
- 35, 32, 37, 95, 35, -1, 37, 32, 23, 24,
- 35, -1, 37, -1, -1, -1, 31, 32, 23, 24,
- 35, 29, 37, -1, -1, 29, 31, 32, -1, -1,
- 35, -1, 37, 29, 23, 24, 29, -1, -1, 29,
- 18, 19, 31, 32, 29, -1, 35, 29, 37, -1,
- 100, 101, 102, 103, 104, 105, -1, -1, 66, 67,
- 68, -1, 66, 67, 68, -1, -1, 45, 46, -1,
- 66, 67, 68, 66, 67, 68, 66, 67, 68, -1,
- 29, 66, 67, 68, 66, 67, 68, 29, 96, 97,
- 98, -1, 96, 97, 98, 29, -1, -1, 29, -1,
- 96, 97, 98, 96, 97, 98, 96, 97, 98, -1,
- -1, 96, 97, 98, 96, 97, 98, 66, 67, 68,
- 29, -1, -1, -1, 66, 67, 68, -1, -1, -1,
- 23, 24, 66, 67, 68, 66, 67, 68, 31, 32,
- -1, -1, 35, 29, 37, -1, 15, 96, 97, 98,
- 36, -1, -1, -1, 96, 97, 98, 66, 67, 68,
- 29, -1, 96, 97, 98, 96, 97, 98, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 15,
- 66, 67, 68, -1, -1, -1, 15, 96, 97, 98,
- 15, -1, -1, 29, 15, -1, 29, 66, 67, 68,
- 29, -1, -1, 36, 29, -1, -1, -1, 29, -1,
- 96, 97, 98, -1, -1, 29, -1, -1, 29, -1,
- -1, -1, -1, -1, -1, -1, -1, 96, 97, 98,
- 66, 67, 68, 66, 67, 68, -1, 66, 67, 68,
- -1, 66, 67, 68, -1, 66, 67, 68, -1, -1,
- 61, 62, 66, 67, 68, 66, 67, 68, 29, -1,
- 96, 97, 98, 96, 97, 98, -1, 96, 97, 98,
- 29, 96, 97, 98, -1, 96, 97, 98, 29, -1,
- -1, 29, 96, 97, 98, 96, 97, 98, -1, -1,
- 61, 62, -1, -1, 29, 66, 67, 68, -1, -1,
- -1, 36, 61, 62, -1, -1, -1, 66, 67, 68,
- 61, 62, -1, 61, 62, 66, 67, 68, 66, 67,
- 68, -1, -1, -1, -1, 96, 97, 98, -1, -1,
- 3, 66, 67, 68, -1, -1, -1, 96, 97, 98,
- 13, -1, -1, -1, 17, 96, 97, 98, 96, 97,
- 98, -1, -1, 26, -1, 28, -1, -1, -1, -1,
- -1, 96, 97, 98, -1, -1, 39, -1, 41, 42,
- -1, -1, -1, 29, -1, -1, 49, -1, -1, 52,
- 53, -1, -1, -1, -1, 58, -1, -1, -1, -1,
- -1, 64, -1, -1, -1, -1, -1, -1, -1, 3,
- -1, -1, -1, -1, -1, 61, 62, 80, -1, 13,
- 66, 67, 68, 17, -1, -1, -1, -1, -1, -1,
- -1, -1, 26, -1, 28, -1, -1, 31, -1, -1,
- -1, -1, -1, -1, -1, 39, -1, 41, 42, -1,
- 96, 97, 98, -1, -1, 49, -1, -1, 52, 53,
- -1, -1, 3, -1, 58, -1, -1, -1, -1, -1,
- 64, -1, 13, -1, -1, -1, 17, -1, -1, -1,
- -1, -1, -1, -1, -1, 26, 80, 28, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 39, -1,
- 41, 42, -1, -1, -1, -1, -1, -1, 49, -1,
- -1, 52, 53, -1, -1, -1, -1, 58, -1, -1,
- -1, -1, -1, 64, -1, 12, 13, -1, -1, -1,
- -1, -1, -1, -1, -1, 22, -1, -1, -1, 80,
- -1, -1, 29, -1, -1, -1, 33, 34, -1, 36,
- -1, -1, -1, -1, -1, -1, 43, -1, -1, -1,
- 47, -1, -1, -1, -1, -1, -1, 12, 13, -1,
- -1, -1, -1, -1, -1, -1, -1, 22, 65, 66,
- 67, 68, -1, 70, 29, -1, -1, -1, 33, 34,
- -1, 36, -1, -1, 81, 82, 83, -1, 43, -1,
- -1, 88, 47, -1, -1, -1, -1, -1, -1, 96,
- 97, 98, -1, -1, -1, -1, -1, -1, -1, -1,
- 65, 66, 67, 68, -1, 70, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 81, 82, 83, -1,
- -1, -1, -1, 88, -1, -1, -1, -1, -1, -1,
- -1, 96, 97, 98, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 12, 13, -1, -1, -1, -1, -1,
- -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
- 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, -1, -1, -1, 43, -1, -1, -1, 47, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
- -1, 70, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 81, 82, 83, -1, -1, -1, -1, 88,
- -1, -1, -1, -1, -1, -1, -1, 96, 97, 98,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 12,
- 13, -1, -1, -1, -1, -1, -1, -1, -1, 22,
- -1, -1, -1, -1, -1, -1, 29, -1, -1, -1,
- 33, 34, -1, 36, -1, -1, -1, -1, -1, -1,
- 43, -1, -1, -1, 47, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 65, 66, 67, 68, -1, 70, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 81, 82,
- 83, -1, -1, -1, -1, 88, -1, -1, -1, -1,
- -1, -1, -1, 96, 97, 98, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 10, -1, 12, 13, -1,
- -1, -1, -1, -1, -1, -1, -1, 22, -1, -1,
- -1, -1, -1, -1, 29, -1, -1, -1, 33, 34,
- -1, 36, -1, -1, -1, -1, -1, -1, 43, -1,
- -1, -1, 47, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 65, 66, 67, 68, -1, 70, -1, -1, -1, -1,
- 75, -1, -1, -1, -1, -1, 81, 82, 83, 84,
- 85, -1, -1, 88, -1, -1, 91, -1, -1, -1,
- -1, 96, 97, 98, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 10, -1, 12, 13, -1, -1, -1,
- -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
- -1, -1, 29, -1, -1, -1, 33, 34, -1, 36,
- -1, -1, -1, -1, -1, -1, 43, -1, -1, -1,
- 47, -1, -1, -1, -1, -1, -1, -1, 55, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 65, 66,
- 67, 68, -1, 70, -1, -1, -1, -1, 75, -1,
- -1, -1, -1, -1, 81, 82, 83, 84, 85, -1,
- -1, 88, -1, -1, 91, -1, -1, -1, -1, 96,
- 97, 98, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, -1, 12, 13, -1, -1, -1, -1, -1,
- -1, -1, -1, 22, -1, -1, -1, -1, -1, -1,
- 29, -1, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, -1, -1, -1, 43, -1, -1, -1, 47, -1,
- -1, -1, -1, -1, -1, -1, 55, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 65, 66, 67, 68,
- -1, 70, -1, -1, -1, -1, 75, -1, -1, -1,
- -1, -1, 81, 82, 83, 84, 85, -1, -1, 88,
- -1, -1, 91, -1, -1, -1, -1, 96, 97, 98,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 11,
- 12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
- 22, -1, -1, -1, -1, -1, -1, 29, -1, -1,
- -1, 33, 34, -1, 36, -1, -1, -1, 40, -1,
- 42, 43, 44, -1, -1, 47, -1, -1, -1, 51,
- -1, 53, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 65, 66, 67, 68, -1, 70, -1,
- 72, -1, 74, -1, 76, -1, -1, -1, -1, 81,
- 82, 83, -1, -1, -1, -1, 88, -1, -1, -1,
- -1, -1, -1, -1, 96, 97, 98, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 7, -1, -1, -1,
- 11, 12, 13, -1, -1, -1, -1, -1, -1, -1,
- -1, 22, -1, -1, -1, -1, -1, -1, 29, -1,
- -1, -1, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 65, 66, 67, 68, -1, 70,
- -1, 72, -1, 74, -1, 76, -1, -1, -1, -1,
- 81, 82, 83, -1, -1, -1, -1, 88, -1, -1,
- -1, -1, -1, -1, -1, 96, 97, 98, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, 75, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
- -1, -1, 96, 97, 98, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
- -1, -1, 96, 97, 98, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
- -1, -1, 96, 97, 98, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
- -1, -1, 96, 97, 98, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 8, -1, -1, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
- -1, -1, -1, -1, -1, 29, -1, -1, -1, 33,
- 34, -1, 36, -1, -1, -1, 40, -1, 42, 43,
- 44, -1, -1, 47, -1, -1, -1, 51, -1, 53,
- -1, -1, 56, -1, -1, -1, -1, -1, -1, -1,
- -1, 65, 66, 67, 68, -1, 70, -1, 72, -1,
- 74, -1, 76, -1, -1, -1, -1, 81, 82, 83,
- -1, -1, -1, -1, 88, -1, -1, -1, -1, -1,
- -1, -1, 96, 97, 98, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 11, 12, 13, -1, -1, -1,
- -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
- -1, -1, 29, 30, -1, -1, 33, 34, -1, 36,
- -1, -1, -1, 40, -1, 42, 43, 44, -1, -1,
- 47, -1, -1, -1, 51, -1, 53, -1, -1, -1,
- -1, -1, -1, -1, 61, -1, -1, -1, 65, 66,
- 67, 68, 69, 70, -1, 72, 73, 74, -1, 76,
- -1, 78, -1, -1, 81, 82, 83, -1, -1, -1,
- -1, 88, -1, -1, -1, -1, -1, -1, -1, 96,
- 97, 98, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 11, 12, 13, -1, -1, -1, -1, -1, -1,
- -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
- 30, -1, -1, 33, 34, -1, 36, -1, -1, -1,
- 40, -1, 42, 43, 44, -1, -1, 47, -1, -1,
- -1, 51, -1, 53, -1, -1, -1, -1, -1, -1,
- -1, 61, -1, -1, -1, 65, 66, 67, 68, 69,
- 70, -1, 72, 73, 74, -1, 76, -1, 78, -1,
- -1, 81, 82, 83, -1, -1, -1, -1, 88, -1,
- -1, -1, -1, -1, -1, -1, 96, 97, 98, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 11, 12,
- 13, -1, -1, -1, -1, -1, -1, -1, -1, 22,
- -1, -1, -1, -1, -1, -1, 29, 30, -1, -1,
- 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
- 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
- 53, -1, -1, -1, -1, -1, -1, -1, 61, -1,
- -1, -1, 65, 66, 67, 68, 69, 70, -1, 72,
- 73, 74, -1, 76, -1, 78, -1, -1, 81, 82,
- 83, -1, -1, -1, -1, 88, -1, -1, -1, -1,
- -1, -1, -1, 96, 97, 98, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 4, 5, 6, -1, -1,
- 9, 10, 11, -1, -1, 14, -1, 16, -1, -1,
- -1, 20, 21, 22, -1, -1, -1, -1, -1, -1,
- 29, 30, 31, 32, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 43, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 59, -1, -1, -1, -1, -1, -1, 66, 67, 68,
- 69, 70, 71, -1, 73, 74, 75, 76, 77, 78,
- -1, -1, 81, 82, 83, 84, 85, 86, 87, -1,
- -1, -1, 91, -1, -1, -1, -1, 96, 97, 98,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
- 5, 6, -1, -1, 9, 10, 11, -1, -1, 14,
- -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
- -1, -1, -1, -1, 29, 30, 31, 32, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 43, -1,
- -1, -1, 47, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
- 65, 66, 67, 68, 69, 70, 71, -1, 73, 74,
- 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
- 85, 86, 87, -1, -1, -1, 91, -1, -1, -1,
- -1, 96, 97, 98, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 4, 5, 6, -1, -1, 9, 10,
- 11, -1, -1, 14, -1, 16, -1, -1, -1, 20,
- 21, 22, -1, -1, -1, -1, -1, -1, 29, 30,
- 31, 32, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 43, -1, -1, -1, 47, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 59, -1,
- -1, -1, -1, -1, 65, 66, 67, 68, 69, 70,
- 71, -1, 73, 74, 75, 76, 77, 78, -1, -1,
- 81, 82, 83, 84, 85, 86, 87, -1, -1, -1,
- 91, -1, -1, -1, -1, 96, 97, 98, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 4, 5, 6,
- -1, -1, 9, 10, 11, -1, -1, 14, -1, 16,
- -1, -1, -1, 20, 21, 22, -1, -1, -1, -1,
- -1, -1, 29, 30, 31, 32, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 43, -1, -1, -1,
- 47, -1, -1, -1, -1, -1, -1, -1, 55, -1,
- -1, -1, 59, -1, -1, -1, -1, -1, 65, 66,
- 67, 68, 69, 70, 71, -1, 73, 74, 75, 76,
- 77, 78, -1, -1, 81, 82, 83, 84, 85, 86,
- 87, -1, -1, -1, 91, -1, -1, -1, -1, 96,
- 97, 98, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 4, -1, -1, -1, -1, 9, -1, 11, 12,
- 13, 14, -1, -1, -1, -1, -1, -1, 21, 22,
- -1, -1, -1, -1, -1, -1, 29, 30, -1, -1,
- 33, 34, -1, 36, -1, -1, -1, 40, -1, 42,
- 43, 44, -1, -1, 47, -1, -1, -1, 51, -1,
- 53, -1, -1, -1, -1, -1, 59, -1, 61, -1,
- -1, -1, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, -1, -1, 81, 82,
- 83, 84, 85, 86, -1, 88, -1, -1, -1, -1,
- -1, -1, -1, 96, 97, 98, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 4, -1, -1, -1, -1,
- 9, -1, 11, 12, 13, 14, -1, -1, -1, -1,
- -1, -1, 21, 22, -1, -1, -1, -1, -1, -1,
- 29, 30, -1, -1, 33, 34, -1, 36, -1, -1,
- -1, 40, -1, 42, 43, 44, -1, -1, 47, -1,
- -1, -1, 51, -1, 53, -1, -1, -1, -1, -1,
- 59, -1, 61, -1, -1, -1, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- -1, -1, 81, 82, 83, 84, 85, 86, -1, 88,
- -1, -1, -1, -1, -1, -1, -1, 96, 97, 98,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
- 5, 6, -1, -1, 9, 10, 11, 12, 13, 14,
- -1, 16, -1, -1, -1, 20, 21, 22, -1, -1,
- -1, -1, -1, -1, 29, 30, 31, 32, 33, 34,
- -1, 36, -1, -1, -1, 40, -1, 42, 43, 44,
- -1, -1, 47, -1, -1, -1, 51, -1, 53, -1,
- -1, -1, -1, -1, 59, -1, 61, -1, -1, -1,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, -1, -1, 81, 82, 83, 84,
- 85, 86, 87, 88, -1, -1, 91, -1, -1, -1,
- -1, 96, 97, 98, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 4, 5, 6, -1, -1, 9, 10,
- 11, 12, 13, 14, -1, 16, -1, -1, -1, 20,
- 21, 22, -1, -1, -1, -1, -1, -1, 29, 30,
- 31, 32, 33, 34, -1, 36, -1, -1, -1, 40,
- -1, 42, 43, 44, -1, -1, 47, -1, -1, -1,
- 51, -1, 53, -1, 55, -1, -1, -1, 59, -1,
- 61, -1, -1, -1, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, -1, -1,
- 81, 82, 83, 84, 85, 86, 87, 88, -1, -1,
- 91, -1, -1, -1, -1, 96, 97, 98, -1, -1,
- -1, -1, -1, -1, -1, -1, -1,
-
- 18, 18, 32, 18, 32, 18, 3, 43, 18, 25,
- 22, 22, 14, 14, 78, 18, 9, 3, 18, 3,
- 18, 3, 18, 32, 18, 32, 32, 22, 18, 18,
- 22, 3, 3, 18, 106, 43, 3, 18, 18, 101,
- 3, 3, 18, 18, 18, 104, 3, 3, 18, 18,
- 18, 3, 18, 18, 18, 43, 3, 3, 3, 32,
- 14, 3, 3, 3, 25, 25, 25, -1, 55, 18,
- 57, 2, 55, -1, -1, 2, 55, 60, 3, -1,
- 18, 60, 18, 18, -1, 43, 25, 18, 43, -1,
- 43, 18, 43, 43, 18, 43, 11, 12, 14, 43,
- 43, 4, 3, 19, 18, 18, 3, 14, 3, 45,
- 18, -1, 18, -1, 2, 18, 23, 2, 55, 2,
- 57, 55, 55, 57, 57, 55, 55, 57, 57, 55,
- 18, 57, 45, 18, 55, 18, 57, 2, 46, 2,
- 2, 47, 2, 55, 55, 55, 55, 57, 60, 60,
- 55, 60, 57, 18, 79, 18, 18, 55, 18, 55,
- 95, 57, 60, 14, 2, 2, 55, -1, 55, 18,
- 14, 55, 61, 55, 61, 19, 60, 59, 79, 55,
- 18, 18, 79, 59, 79, 55, 55, 55, 14, 55,
- 60, 60, 60, 18, 60, 2, 110, 55, 47, 55,
- 43, 52, 60, 59, 18, 55, 2, 57, 51, 55,
- 55, 18, 39, 55, 55, 18, 43, 4, 2, 55,
- 65, 67, 18, 2, 18, 61, 52, 2, 69, 71,
- 2, 18, 46, 55, 18, 57, 55, 4, 57, 18,
- 55, 44, 57, 18, 55, 55, 18, 58, 58, 18,
- 43, 18, 46, 55, 14, 57, 55, 18, 51, 19,
- 2, 2, 61, 55, 55, 57, 55, 55, 93, 57,
- -1, 60, 63, -1, -1, 55, 18, 18, 47, 68,
- 60, -1, 55, -1, 64, 46, 18, 60, -1, 62,
- 55, 55, -1, -1, -1, 60, 60, 62, 62, 55,
- 55, -1, 55, 55, 60, 60, 62, 60, 60, 55,
- 55, -1, 55, 66, 60, 60, 48, 60, 55, 55,
- -1, 14, 77, 60, 60, 77, 19, 72, 21, -1,
- 14, 77, -1, 70, 77, 5, -1, 5, -1, 23,
- -1, 77, -1, -1, 14, -1, 14, 89, 89, -1,
- 43, 35, 36, 23, -1, 23, 25, 26, 27, 28,
- 29, 30, 31, -1, -1, 35, 36, 35, 36, -1,
- -1, -1, 14, -1, -1, -1, -1, -1, -1, -1,
- 18, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 14, -1, -1, -1, -1, -1, -1, -1, -1, 23,
- 24, 25, 26, 27, 28, 29, 30, 31, -1, -1,
- 48, 49, -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, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 14, -1, -1, -1, -1, -1,
- -1, -1, -1, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, -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, -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
-};
-
-QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsgrammar_p.h b/src/qml/parser/qqmljsgrammar_p.h
deleted file mode 100644
index 9d028f2191..0000000000
--- a/src/qml/parser/qqmljsgrammar_p.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// This file was generated by qlalr - DO NOT EDIT!
-#ifndef QQMLJSGRAMMAR_P_H
-#define QQMLJSGRAMMAR_P_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQmlJSGrammar
-{
-public:
- enum VariousConstants {
- EOF_SYMBOL = 0,
- REDUCE_HERE = 107,
- SHIFT_THERE = 106,
- T_AND = 1,
- T_AND_AND = 2,
- T_AND_EQ = 3,
- T_AS = 95,
- T_AUTOMATIC_SEMICOLON = 62,
- T_BREAK = 4,
- T_CASE = 5,
- T_CATCH = 6,
- T_COLON = 7,
- T_COMMA = 8,
- T_COMMENT = 89,
- T_COMPATIBILITY_SEMICOLON = 90,
- T_CONST = 84,
- T_CONTINUE = 9,
- T_DEBUGGER = 86,
- T_DEFAULT = 10,
- T_DELETE = 11,
- T_DIVIDE_ = 12,
- T_DIVIDE_EQ = 13,
- T_DO = 14,
- T_DOT = 15,
- T_ELSE = 16,
- T_ENUM = 91,
- T_EQ = 17,
- T_EQ_EQ = 18,
- T_EQ_EQ_EQ = 19,
- T_ERROR = 99,
- T_FALSE = 83,
- T_FEED_JS_EXPRESSION = 103,
- T_FEED_JS_PROGRAM = 105,
- T_FEED_JS_SOURCE_ELEMENT = 104,
- T_FEED_JS_STATEMENT = 102,
- T_FEED_UI_OBJECT_MEMBER = 101,
- T_FEED_UI_PROGRAM = 100,
- T_FINALLY = 20,
- T_FOR = 21,
- T_FUNCTION = 22,
- T_GE = 23,
- T_GET = 97,
- T_GT = 24,
- T_GT_GT = 25,
- T_GT_GT_EQ = 26,
- T_GT_GT_GT = 27,
- T_GT_GT_GT_EQ = 28,
- T_IDENTIFIER = 29,
- T_IF = 30,
- T_IMPORT = 93,
- T_IN = 31,
- T_INSTANCEOF = 32,
- T_LBRACE = 33,
- T_LBRACKET = 34,
- T_LE = 35,
- T_LET = 85,
- T_LPAREN = 36,
- T_LT = 37,
- T_LT_LT = 38,
- T_LT_LT_EQ = 39,
- T_MINUS = 40,
- T_MINUS_EQ = 41,
- T_MINUS_MINUS = 42,
- T_MULTILINE_STRING_LITERAL = 88,
- T_NEW = 43,
- T_NOT = 44,
- T_NOT_EQ = 45,
- T_NOT_EQ_EQ = 46,
- T_NULL = 81,
- T_NUMERIC_LITERAL = 47,
- T_ON = 96,
- T_OR = 48,
- T_OR_EQ = 49,
- T_OR_OR = 50,
- T_PLUS = 51,
- T_PLUS_EQ = 52,
- T_PLUS_PLUS = 53,
- T_PRAGMA = 94,
- T_PROPERTY = 66,
- T_PUBLIC = 92,
- T_QUESTION = 54,
- T_RBRACE = 55,
- T_RBRACKET = 56,
- T_READONLY = 68,
- T_REMAINDER = 57,
- T_REMAINDER_EQ = 58,
- T_RESERVED_WORD = 87,
- T_RETURN = 59,
- T_RPAREN = 60,
- T_SEMICOLON = 61,
- T_SET = 98,
- T_SIGNAL = 67,
- T_STAR = 63,
- T_STAR_EQ = 64,
- T_STRING_LITERAL = 65,
- T_SWITCH = 69,
- T_THIS = 70,
- T_THROW = 71,
- T_TILDE = 72,
- T_TRUE = 82,
- T_TRY = 73,
- T_TYPEOF = 74,
- T_VAR = 75,
- T_VOID = 76,
- T_WHILE = 77,
- T_WITH = 78,
- T_XOR = 79,
- T_XOR_EQ = 80,
-
- ACCEPT_STATE = 691,
- RULE_COUNT = 369,
- STATE_COUNT = 692,
- TERMINAL_COUNT = 108,
- NON_TERMINAL_COUNT = 112,
-
- GOTO_INDEX_OFFSET = 692,
- GOTO_INFO_OFFSET = 3357,
- GOTO_CHECK_OFFSET = 3357
- };
-
- static const char *const spell[];
- static const short lhs[];
- static const short rhs[];
- static const short goto_default[];
- static const short action_default[];
- static const short action_index[];
- static const short action_info[];
- static const short action_check[];
-
- static inline int nt_action (int state, int nt)
- {
- const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
- if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
- return goto_default [nt];
-
- return action_info [GOTO_INFO_OFFSET + yyn];
- }
-
- static inline int t_action (int state, int token)
- {
- const int yyn = action_index [state] + token;
-
- if (yyn < 0 || action_check [yyn] != token)
- return - action_default [state];
-
- return action_info [yyn];
- }
-};
-
-
-QT_END_NAMESPACE
-#endif // QQMLJSGRAMMAR_P_H
-
diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h
index 20daf545a9..b0a4951ece 100644
--- a/src/qml/parser/qqmljskeywords_p.h
+++ b/src/qml/parser/qqmljskeywords_p.h
@@ -57,10 +57,10 @@ QT_QML_BEGIN_NAMESPACE
namespace QQmlJS {
-static inline int classify2(const QChar *s, bool qmlMode) {
+static inline int classify2(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'a') {
if (s[1].unicode() == 's') {
- return qmlMode ? Lexer::T_AS : Lexer::T_IDENTIFIER;
+ return Lexer::T_AS;
}
}
else if (s[0].unicode() == 'd') {
@@ -76,15 +76,18 @@ static inline int classify2(const QChar *s, bool qmlMode) {
return Lexer::T_IN;
}
}
- else if (qmlMode && s[0].unicode() == 'o') {
+ else if (s[0].unicode() == 'o') {
if (s[1].unicode() == 'n') {
- return qmlMode ? Lexer::T_ON : Lexer::T_IDENTIFIER;
+ return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_ON : Lexer::T_IDENTIFIER;
+ }
+ else if (s[1].unicode() == 'f') {
+ return Lexer::T_OF;
}
}
return Lexer::T_IDENTIFIER;
}
-static inline int classify3(const QChar *s, bool qmlMode) {
+static inline int classify3(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'f') {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'r') {
@@ -102,7 +105,7 @@ static inline int classify3(const QChar *s, bool qmlMode) {
else if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') {
- return qmlMode ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -144,12 +147,12 @@ static inline int classify3(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify4(const QChar *s, bool qmlMode) {
+static inline int classify4(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'y') {
if (s[2].unicode() == 't') {
if (s[3].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -165,7 +168,7 @@ static inline int classify4(const QChar *s, bool qmlMode) {
else if (s[1].unicode() == 'h') {
if (s[2].unicode() == 'a') {
if (s[3].unicode() == 'r') {
- return qmlMode ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -181,7 +184,16 @@ static inline int classify4(const QChar *s, bool qmlMode) {
else if (s[1].unicode() == 'n') {
if (s[2].unicode() == 'u') {
if (s[3].unicode() == 'm') {
- return qmlMode ? int(Lexer::T_ENUM) : int(Lexer::T_RESERVED_WORD);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ENUM) : int(Lexer::T_RESERVED_WORD);
+ }
+ }
+ }
+ }
+ else if (s[0].unicode() == 'f') {
+ if (s[1].unicode() == 'r') {
+ if (s[2].unicode() == 'o') {
+ if (s[3].unicode() == 'm') {
+ return int(Lexer::T_FROM);
}
}
}
@@ -190,7 +202,7 @@ static inline int classify4(const QChar *s, bool qmlMode) {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 't') {
if (s[3].unicode() == 'o') {
- return qmlMode ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -199,7 +211,7 @@ static inline int classify4(const QChar *s, bool qmlMode) {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'g') {
- return qmlMode ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -250,7 +262,7 @@ static inline int classify4(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify5(const QChar *s, bool qmlMode) {
+static inline int classify5(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'r') {
if (s[2].unicode() == 'e') {
@@ -305,7 +317,7 @@ static inline int classify5(const QChar *s, bool qmlMode) {
if (s[2].unicode() == 'n') {
if (s[3].unicode() == 'a') {
if (s[4].unicode() == 'l') {
- return qmlMode ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -314,7 +326,7 @@ static inline int classify5(const QChar *s, bool qmlMode) {
if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'a') {
if (s[4].unicode() == 't') {
- return qmlMode ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -325,7 +337,7 @@ static inline int classify5(const QChar *s, bool qmlMode) {
if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'r') {
if (s[4].unicode() == 't') {
- return qmlMode ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -334,7 +346,7 @@ static inline int classify5(const QChar *s, bool qmlMode) {
if (s[2].unicode() == 'p') {
if (s[3].unicode() == 'e') {
if (s[4].unicode() == 'r') {
- return qmlMode ? int(Lexer::T_SUPER) : int(Lexer::T_RESERVED_WORD);
+ return int(Lexer::T_SUPER);
}
}
}
@@ -362,10 +374,21 @@ static inline int classify5(const QChar *s, bool qmlMode) {
}
}
}
+ else if (s[0].unicode() == 'y') {
+ if (s[1].unicode() == 'i') {
+ if (s[2].unicode() == 'e') {
+ if (s[3].unicode() == 'l') {
+ if (s[4].unicode() == 'd') {
+ return (parseModeFlags & Lexer::YieldIsKeyword) ? Lexer::T_YIELD : Lexer::T_IDENTIFIER;
+ }
+ }
+ }
+ }
+ }
return Lexer::T_IDENTIFIER;
}
-static inline int classify6(const QChar *s, bool qmlMode) {
+static inline int classify6(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'd') {
if (s[1].unicode() == 'e') {
if (s[2].unicode() == 'l') {
@@ -383,7 +406,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'b') {
if (s[4].unicode() == 'l') {
if (s[5].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -409,7 +432,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'o') {
if (s[4].unicode() == 'r') {
if (s[5].unicode() == 't') {
- return qmlMode ? int(Lexer::T_IMPORT) : int(Lexer::T_RESERVED_WORD);
+ return Lexer::T_IMPORT;
}
}
}
@@ -422,7 +445,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'i') {
if (s[4].unicode() == 'v') {
if (s[5].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -435,7 +458,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'l') {
if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') {
- return qmlMode ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER;
+ return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER;
}
}
}
@@ -446,7 +469,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'g') {
if (s[4].unicode() == 'm') {
if (s[5].unicode() == 'a') {
- return qmlMode ? Lexer::T_PRAGMA : Lexer::T_IDENTIFIER;
+ return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PRAGMA : Lexer::T_IDENTIFIER;
}
}
}
@@ -467,7 +490,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
}
}
else if (s[0].unicode() == 's') {
- if (qmlMode && s[1].unicode() == 'i') {
+ if ((parseModeFlags & Lexer::QmlMode) && s[1].unicode() == 'i') {
if (s[2].unicode() == 'g') {
if (s[3].unicode() == 'n') {
if (s[4].unicode() == 'a') {
@@ -483,7 +506,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 't') {
if (s[4].unicode() == 'i') {
if (s[5].unicode() == 'c') {
- return qmlMode ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::StaticIsKeyword) ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -507,7 +530,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
if (s[3].unicode() == 'o') {
if (s[4].unicode() == 'w') {
if (s[5].unicode() == 's') {
- return qmlMode ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -528,7 +551,7 @@ static inline int classify6(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify7(const QChar *s, bool qmlMode) {
+static inline int classify7(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'b') {
if (s[1].unicode() == 'o') {
if (s[2].unicode() == 'o') {
@@ -536,7 +559,7 @@ static inline int classify7(const QChar *s, bool qmlMode) {
if (s[4].unicode() == 'e') {
if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'n') {
- return qmlMode ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -596,7 +619,7 @@ static inline int classify7(const QChar *s, bool qmlMode) {
if (s[4].unicode() == 'a') {
if (s[5].unicode() == 'g') {
if (s[6].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -609,7 +632,7 @@ static inline int classify7(const QChar *s, bool qmlMode) {
if (s[4].unicode() == 'a') {
if (s[5].unicode() == 't') {
if (s[6].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -620,7 +643,7 @@ static inline int classify7(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify8(const QChar *s, bool qmlMode) {
+static inline int classify8(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'a') {
if (s[1].unicode() == 'b') {
if (s[2].unicode() == 's') {
@@ -629,7 +652,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'a') {
if (s[6].unicode() == 'c') {
if (s[7].unicode() == 't') {
- return qmlMode ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -689,7 +712,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
}
}
}
- else if (qmlMode && s[0].unicode() == 'p') {
+ else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'p') {
if (s[1].unicode() == 'r') {
if (s[2].unicode() == 'o') {
if (s[3].unicode() == 'p') {
@@ -706,7 +729,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
}
}
}
- else if (qmlMode && s[0].unicode() == 'r') {
+ else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'r') {
if (s[1].unicode() == 'e') {
if (s[2].unicode() == 'a') {
if (s[3].unicode() == 'd') {
@@ -731,7 +754,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
if (s[5].unicode() == 'i') {
if (s[6].unicode() == 'l') {
if (s[7].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -743,7 +766,7 @@ static inline int classify8(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify9(const QChar *s, bool qmlMode) {
+static inline int classify9(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'n') {
if (s[2].unicode() == 't') {
@@ -753,7 +776,7 @@ static inline int classify9(const QChar *s, bool qmlMode) {
if (s[6].unicode() == 'a') {
if (s[7].unicode() == 'c') {
if (s[8].unicode() == 'e') {
- return qmlMode ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -772,7 +795,7 @@ static inline int classify9(const QChar *s, bool qmlMode) {
if (s[6].unicode() == 't') {
if (s[7].unicode() == 'e') {
if (s[8].unicode() == 'd') {
- return qmlMode ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -791,7 +814,7 @@ static inline int classify9(const QChar *s, bool qmlMode) {
if (s[6].unicode() == 'e') {
if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') {
- return qmlMode ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -804,7 +827,7 @@ static inline int classify9(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify10(const QChar *s, bool qmlMode) {
+static inline int classify10(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 'i') {
if (s[1].unicode() == 'm') {
if (s[2].unicode() == 'p') {
@@ -815,7 +838,7 @@ static inline int classify10(const QChar *s, bool qmlMode) {
if (s[7].unicode() == 'n') {
if (s[8].unicode() == 't') {
if (s[9].unicode() == 's') {
- return qmlMode ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -848,7 +871,7 @@ static inline int classify10(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-static inline int classify12(const QChar *s, bool qmlMode) {
+static inline int classify12(const QChar *s, int parseModeFlags) {
if (s[0].unicode() == 's') {
if (s[1].unicode() == 'y') {
if (s[2].unicode() == 'n') {
@@ -861,7 +884,7 @@ static inline int classify12(const QChar *s, bool qmlMode) {
if (s[9].unicode() == 'z') {
if (s[10].unicode() == 'e') {
if (s[11].unicode() == 'd') {
- return qmlMode ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER);
+ return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER);
}
}
}
@@ -877,18 +900,18 @@ static inline int classify12(const QChar *s, bool qmlMode) {
return Lexer::T_IDENTIFIER;
}
-int Lexer::classify(const QChar *s, int n, bool qmlMode) {
+int Lexer::classify(const QChar *s, int n, int parseModeFlags) {
switch (n) {
- case 2: return classify2(s, qmlMode);
- case 3: return classify3(s, qmlMode);
- case 4: return classify4(s, qmlMode);
- case 5: return classify5(s, qmlMode);
- case 6: return classify6(s, qmlMode);
- case 7: return classify7(s, qmlMode);
- case 8: return classify8(s, qmlMode);
- case 9: return classify9(s, qmlMode);
- case 10: return classify10(s, qmlMode);
- case 12: return classify12(s, qmlMode);
+ case 2: return classify2(s, parseModeFlags);
+ case 3: return classify3(s, parseModeFlags);
+ case 4: return classify4(s, parseModeFlags);
+ case 5: return classify5(s, parseModeFlags);
+ case 6: return classify6(s, parseModeFlags);
+ case 7: return classify7(s, parseModeFlags);
+ case 8: return classify8(s, parseModeFlags);
+ case 9: return classify9(s, parseModeFlags);
+ case 10: return classify10(s, parseModeFlags);
+ case 12: return classify12(s, parseModeFlags);
default: return Lexer::T_IDENTIFIER;
} // switch
}
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index aab9025a08..b98bb8bac5 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -58,6 +58,8 @@ static inline int regExpFlagFromChar(const QChar &ch)
case 'g': return Lexer::RegExp_Global;
case 'i': return Lexer::RegExp_IgnoreCase;
case 'm': return Lexer::RegExp_Multiline;
+ case 'u': return Lexer::RegExp_Unicode;
+ case 'y': return Lexer::RegExp_Sticky;
}
return 0;
}
@@ -77,22 +79,15 @@ static inline QChar convertHex(QChar c1, QChar c2)
return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
}
-static inline QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4)
-{
- return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()),
- (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()));
-}
-
Lexer::Lexer(Engine *engine)
: _engine(engine)
, _codePtr(nullptr)
, _endPtr(nullptr)
- , _lastLinePtr(nullptr)
- , _tokenLinePtr(nullptr)
, _tokenStartPtr(nullptr)
, _char(QLatin1Char('\n'))
, _errorCode(NoError)
, _currentLineNumber(0)
+ , _currentColumnNumber(0)
, _tokenValue(0)
, _parenthesesState(IgnoreParentheses)
, _parenthesesCount(0)
@@ -101,6 +96,7 @@ Lexer::Lexer(Engine *engine)
, _tokenKind(0)
, _tokenLength(0)
, _tokenLine(0)
+ , _tokenColumn(0)
, _validTokenText(false)
, _prohibitAutomaticSemicolon(false)
, _restrictedKeyword(false)
@@ -137,14 +133,13 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
_codePtr = code.unicode();
_endPtr = _codePtr + code.length();
- _lastLinePtr = _codePtr;
- _tokenLinePtr = _codePtr;
_tokenStartPtr = _codePtr;
_char = QLatin1Char('\n');
_errorCode = NoError;
_currentLineNumber = lineno;
+ _currentColumnNumber = 0;
_tokenValue = 0;
// parentheses state
@@ -156,6 +151,7 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
_patternFlags = 0;
_tokenLength = 0;
_tokenLine = lineno;
+ _tokenColumn = 0;
_validTokenText = false;
_prohibitAutomaticSemicolon = false;
@@ -172,9 +168,10 @@ void Lexer::scanChar()
if (sequenceLength == 2)
_char = *_codePtr++;
- if (unsigned sequenceLength = isLineTerminatorSequence()) {
- _lastLinePtr = _codePtr + sequenceLength - 1; // points to the first character after the newline
+ ++_currentColumnNumber;
+ if (isLineTerminator()) {
++_currentLineNumber;
+ _currentColumnNumber = 0;
}
}
@@ -222,12 +219,32 @@ inline bool isBinop(int tok)
return false;
}
}
+
+int hexDigit(QChar c)
+{
+ if (c >= QLatin1Char('0') && c <= QLatin1Char('9'))
+ return c.unicode() - '0';
+ if (c >= QLatin1Char('a') && c <= QLatin1Char('f'))
+ return c.unicode() - 'a' + 10;
+ if (c >= QLatin1Char('A') && c <= QLatin1Char('F'))
+ return c.unicode() - 'A' + 10;
+ return -1;
+}
+
+int octalDigit(QChar c)
+{
+ if (c >= QLatin1Char('0') && c <= QLatin1Char('7'))
+ return c.unicode() - '0';
+ return -1;
+}
+
} // anonymous namespace
int Lexer::lex()
{
const int previousTokenKind = _tokenKind;
+ again:
_tokenSpell = QStringRef();
_tokenKind = scanToken();
_tokenLength = _codePtr - _tokenStartPtr - 1;
@@ -239,6 +256,9 @@ int Lexer::lex()
// update the flags
switch (_tokenKind) {
case T_LBRACE:
+ if (_bracesCount > 0)
+ ++_bracesCount;
+ Q_FALLTHROUGH();
case T_SEMICOLON:
case T_QUESTION:
case T_COLON:
@@ -266,9 +286,15 @@ int Lexer::lex()
case T_CONTINUE:
case T_BREAK:
case T_RETURN:
+ case T_YIELD:
case T_THROW:
_restrictedKeyword = true;
break;
+ case T_RBRACE:
+ if (_bracesCount > 0)
+ --_bracesCount;
+ if (_bracesCount == 0)
+ goto again;
} // switch
// update the parentheses state
@@ -295,39 +321,57 @@ int Lexer::lex()
return _tokenKind;
}
-bool Lexer::isUnicodeEscapeSequence(const QChar *chars)
-{
- if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3]))
- return true;
-
- return false;
-}
-
-QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok)
+uint Lexer::decodeUnicodeEscapeCharacter(bool *ok)
{
- if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) {
- scanChar(); // skip u
+ Q_ASSERT(_char == QLatin1Char('u'));
+ scanChar(); // skip u
+ if (_codePtr + 4 <= _endPtr && isHexDigit(_char)) {
+ uint codePoint = 0;
+ for (int i = 0; i < 4; ++i) {
+ int digit = hexDigit(_char);
+ if (digit < 0)
+ goto error;
+ codePoint *= 16;
+ codePoint += digit;
+ scanChar();
+ }
- const QChar c1 = _char;
- scanChar();
+ *ok = true;
+ return codePoint;
+ } else if (_codePtr < _endPtr && _char == QLatin1Char('{')) {
+ scanChar(); // skip '{'
+ uint codePoint = 0;
+ if (!isHexDigit(_char))
+ // need at least one hex digit
+ goto error;
- const QChar c2 = _char;
- scanChar();
+ while (_codePtr <= _endPtr) {
+ int digit = hexDigit(_char);
+ if (digit < 0)
+ break;
+ codePoint *= 16;
+ codePoint += digit;
+ if (codePoint > 0x10ffff)
+ goto error;
+ scanChar();
+ }
- const QChar c3 = _char;
- scanChar();
+ if (_char != QLatin1Char('}'))
+ goto error;
- const QChar c4 = _char;
- scanChar();
+ scanChar(); // skip '}'
- if (ok)
- *ok = true;
- return convertUnicode(c1, c2, c3, c4);
+ *ok = true;
+ return codePoint;
}
+ error:
+ _errorCode = IllegalUnicodeEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+
*ok = false;
- return QChar();
+ return 0;
}
QChar Lexer::decodeHexEscapeCharacter(bool *ok)
@@ -351,15 +395,15 @@ QChar Lexer::decodeHexEscapeCharacter(bool *ok)
return QChar();
}
-static inline bool isIdentifierStart(QChar ch)
+static inline bool isIdentifierStart(uint ch)
{
// fast path for ascii
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
- (ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
+ if ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
ch == '$' || ch == '_')
return true;
- switch (ch.category()) {
+ switch (QChar::category(ch)) {
case QChar::Number_Letter:
case QChar::Letter_Uppercase:
case QChar::Letter_Lowercase:
@@ -373,17 +417,17 @@ static inline bool isIdentifierStart(QChar ch)
return false;
}
-static bool isIdentifierPart(QChar ch)
+static bool isIdentifierPart(uint ch)
{
// fast path for ascii
- if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
- (ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
- (ch.unicode() >= '0' && ch.unicode() <= '9') ||
+ if ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
ch == '$' || ch == '_' ||
- ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */)
+ ch == 0x200c /* ZWNJ */ || ch == 0x200d /* ZWJ */)
return true;
- switch (ch.category()) {
+ switch (QChar::category(ch)) {
case QChar::Mark_NonSpacing:
case QChar::Mark_SpacingCombining:
@@ -412,19 +456,23 @@ int Lexer::scanToken()
return tk;
}
+ if (_bracesCount == 0) {
+ // we're inside a Template string
+ return scanString(TemplateContinuation);
+ }
+
+
_terminator = false;
again:
_validTokenText = false;
- _tokenLinePtr = _lastLinePtr;
while (_char.isSpace()) {
- if (unsigned sequenceLength = isLineTerminatorSequence()) {
- _tokenLinePtr = _codePtr + sequenceLength - 1;
-
+ if (isLineTerminator()) {
if (_restrictedKeyword) {
// automatic semicolon insertion
_tokenLine = _currentLineNumber;
+ _tokenColumn = _currentColumnNumber;
_tokenStartPtr = _codePtr - 1;
return T_SEMICOLON;
} else {
@@ -438,6 +486,7 @@ again:
_tokenStartPtr = _codePtr - 1;
_tokenLine = _currentLineNumber;
+ _tokenColumn = _currentColumnNumber;
if (_codePtr > _endPtr)
return EOF_SYMBOL;
@@ -501,6 +550,9 @@ again:
return T_EQ_EQ_EQ;
}
return T_EQ_EQ;
+ } else if (_char == QLatin1Char('>')) {
+ scanChar();
+ return T_ARROW;
}
return T_EQ;
@@ -557,50 +609,18 @@ again:
return T_DIVIDE_;
case '.':
- if (_char.isDigit()) {
- QVarLengthArray<char,32> chars;
-
- chars.append(ch.unicode()); // append the `.'
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
+ if (isDecimalDigit(_char.unicode()))
+ return scanNumber(ch);
+ if (_char == QLatin1Char('.')) {
+ scanChar();
+ if (_char == QLatin1Char('.')) {
scanChar();
- }
-
- if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
- if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
- _codePtr[1].isDigit())) {
-
- chars.append(_char.unicode());
- scanChar(); // consume `e'
-
- if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
- chars.append(_char.unicode());
- scanChar(); // consume the sign
- }
-
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
- }
- }
-
- chars.append('\0');
-
- const char *begin = chars.constData();
- const char *end = nullptr;
- bool ok = false;
-
- _tokenValue = qstrtod(begin, &end, &ok);
-
- if (end - begin != chars.size() - 1) {
- _errorCode = IllegalExponentIndicator;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal syntax for exponential number");
+ return T_ELLIPSIS;
+ } else {
+ _errorCode = IllegalCharacter;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unexpected token '.'");
return T_ERROR;
}
-
- return T_NUMERIC_LITERAL;
}
return T_DOT;
@@ -611,7 +631,7 @@ again:
} else if (_char == QLatin1Char('-')) {
scanChar();
- if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
+ if (_terminator && !_delimited && !_prohibitAutomaticSemicolon && _tokenKind != T_LPAREN) {
_stackToken = T_MINUS_MINUS;
return T_SEMICOLON;
}
@@ -629,7 +649,7 @@ again:
} else if (_char == QLatin1Char('+')) {
scanChar();
- if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) {
+ if (_terminator && !_delimited && !_prohibitAutomaticSemicolon && _tokenKind != T_LPAREN) {
_stackToken = T_PLUS_PLUS;
return T_SEMICOLON;
}
@@ -642,6 +662,13 @@ again:
if (_char == QLatin1Char('=')) {
scanChar();
return T_STAR_EQ;
+ } else if (_char == QLatin1Char('*')) {
+ scanChar();
+ if (_char == QLatin1Char('=')) {
+ scanChar();
+ return T_STAR_STAR_EQ;
+ }
+ return T_STAR_STAR;
}
return T_STAR;
@@ -676,141 +703,12 @@ again:
}
return T_NOT;
+ case '`':
+ _outerTemplateBraceCount.push(_bracesCount);
+ Q_FALLTHROUGH();
case '\'':
- case '"': {
- const QChar quote = ch;
- bool multilineStringLiteral = false;
-
- const QChar *startCode = _codePtr;
-
- if (_engine) {
- while (_codePtr <= _endPtr) {
- if (isLineTerminator()) {
- if (qmlMode())
- break;
- _errorCode = IllegalCharacter;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal");
- return T_ERROR;
- } else if (_char == QLatin1Char('\\')) {
- break;
- } else if (_char == quote) {
- _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
- scanChar();
-
- return T_STRING_LITERAL;
- }
- scanChar();
- }
- }
-
- _validTokenText = true;
- _tokenText.resize(0);
- startCode--;
- while (startCode != _codePtr - 1)
- _tokenText += *startCode++;
-
- while (_codePtr <= _endPtr) {
- if (unsigned sequenceLength = isLineTerminatorSequence()) {
- multilineStringLiteral = true;
- _tokenText += _char;
- if (sequenceLength == 2)
- _tokenText += *_codePtr;
- scanChar();
- } else if (_char == quote) {
- scanChar();
-
- if (_engine)
- _tokenSpell = _engine->newStringRef(_tokenText);
-
- return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL;
- } else if (_char == QLatin1Char('\\')) {
- scanChar();
- if (_codePtr > _endPtr) {
- _errorCode = IllegalEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "End of file reached at escape sequence");
- return T_ERROR;
- }
-
- QChar u;
-
- switch (_char.unicode()) {
- // unicode escape sequence
- case 'u': {
- bool ok = false;
- u = decodeUnicodeEscapeCharacter(&ok);
- if (! ok) {
- _errorCode = IllegalUnicodeEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
- return T_ERROR;
- }
- } break;
-
- // hex escape sequence
- case 'x': {
- bool ok = false;
- u = decodeHexEscapeCharacter(&ok);
- if (!ok) {
- _errorCode = IllegalHexadecimalEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal hexadecimal escape sequence");
- return T_ERROR;
- }
- } break;
-
- // single character escape sequence
- case '\\': u = QLatin1Char('\\'); scanChar(); break;
- case '\'': u = QLatin1Char('\''); scanChar(); break;
- case '\"': u = QLatin1Char('\"'); scanChar(); break;
- case 'b': u = QLatin1Char('\b'); scanChar(); break;
- case 'f': u = QLatin1Char('\f'); scanChar(); break;
- case 'n': u = QLatin1Char('\n'); scanChar(); break;
- case 'r': u = QLatin1Char('\r'); scanChar(); break;
- case 't': u = QLatin1Char('\t'); scanChar(); break;
- case 'v': u = QLatin1Char('\v'); scanChar(); break;
-
- case '0':
- if (! _codePtr->isDigit()) {
- scanChar();
- u = QLatin1Char('\0');
- break;
- }
- Q_FALLTHROUGH();
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- _errorCode = IllegalEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Octal escape sequences are not allowed");
- return T_ERROR;
-
- case '\r':
- case '\n':
- case 0x2028u:
- case 0x2029u:
- scanChar();
- continue;
-
- default:
- // non escape character
- u = _char;
- scanChar();
- }
-
- _tokenText += u;
- } else {
- _tokenText += _char;
- scanChar();
- }
- }
-
- _errorCode = UnclosedStringLiteral;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line");
- return T_ERROR;
- }
+ case '"':
+ return scanString(ScanStringMode(ch.unicode()));
case '0':
case '1':
case '2':
@@ -824,28 +722,36 @@ again:
return scanNumber(ch);
default: {
- QChar c = ch;
+ uint c = ch.unicode();
bool identifierWithEscapeChars = false;
- if (c == QLatin1Char('\\') && _char == QLatin1Char('u')) {
+ if (QChar::isHighSurrogate(c) && QChar::isLowSurrogate(_char.unicode())) {
+ c = QChar::surrogateToUcs4(ushort(c), _char.unicode());
+ scanChar();
+ } else if (c == '\\' && _char == QLatin1Char('u')) {
identifierWithEscapeChars = true;
bool ok = false;
c = decodeUnicodeEscapeCharacter(&ok);
- if (! ok) {
- _errorCode = IllegalUnicodeEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+ if (!ok)
return T_ERROR;
- }
}
if (isIdentifierStart(c)) {
if (identifierWithEscapeChars) {
_tokenText.resize(0);
- _tokenText += c;
+ if (QChar::requiresSurrogates(c)) {
+ _tokenText += QChar(QChar::highSurrogate(c));
+ _tokenText += QChar(QChar::lowSurrogate(c));
+ } else {
+ _tokenText += QChar(c);
+ }
_validTokenText = true;
}
- while (true) {
- c = _char;
- if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
- if (! identifierWithEscapeChars) {
+ while (_codePtr <= _endPtr) {
+ c = _char.unicode();
+ if (QChar::isHighSurrogate(c) && QChar::isLowSurrogate(_codePtr->unicode())) {
+ scanChar();
+ c = QChar::surrogateToUcs4(ushort(c), _char.unicode());
+ } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) {
+ if (!identifierWithEscapeChars) {
identifierWithEscapeChars = true;
_tokenText.resize(0);
_tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1);
@@ -855,38 +761,52 @@ again:
scanChar(); // skip '\\'
bool ok = false;
c = decodeUnicodeEscapeCharacter(&ok);
- if (! ok) {
- _errorCode = IllegalUnicodeEscapeSequence;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal unicode escape sequence");
+ if (!ok)
return T_ERROR;
- }
- if (isIdentifierPart(c))
- _tokenText += c;
- continue;
- } else if (isIdentifierPart(c)) {
- if (identifierWithEscapeChars)
- _tokenText += c;
- scanChar();
+ if (!isIdentifierPart(c))
+ break;
+
+ if (identifierWithEscapeChars) {
+ if (QChar::requiresSurrogates(c)) {
+ _tokenText += QChar(QChar::highSurrogate(c));
+ _tokenText += QChar(QChar::lowSurrogate(c));
+ } else {
+ _tokenText += QChar(c);
+ }
+ }
continue;
}
- _tokenLength = _codePtr - _tokenStartPtr - 1;
+ if (!isIdentifierPart(c))
+ break;
- int kind = T_IDENTIFIER;
+ if (identifierWithEscapeChars) {
+ if (QChar::requiresSurrogates(c)) {
+ _tokenText += QChar(QChar::highSurrogate(c));
+ _tokenText += QChar(QChar::lowSurrogate(c));
+ } else {
+ _tokenText += QChar(c);
+ }
+ }
+ scanChar();
+ }
+
+ _tokenLength = _codePtr - _tokenStartPtr - 1;
- if (! identifierWithEscapeChars)
- kind = classify(_tokenStartPtr, _tokenLength, _qmlMode);
+ int kind = T_IDENTIFIER;
- if (_engine) {
- if (kind == T_IDENTIFIER && identifierWithEscapeChars)
- _tokenSpell = _engine->newStringRef(_tokenText);
- else
- _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
- }
+ if (!identifierWithEscapeChars)
+ kind = classify(_tokenStartPtr, _tokenLength, parseModeFlags());
- return kind;
+ if (_engine) {
+ if (kind == T_IDENTIFIER && identifierWithEscapeChars)
+ _tokenSpell = _engine->newStringRef(_tokenText);
+ else
+ _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength);
}
+
+ return kind;
}
}
@@ -896,93 +816,278 @@ again:
return T_ERROR;
}
-int Lexer::scanNumber(QChar ch)
+int Lexer::scanString(ScanStringMode mode)
{
- if (ch != QLatin1Char('0')) {
- QVarLengthArray<char, 64> buf;
- buf += ch.toLatin1();
-
- QChar n = _char;
- const QChar *code = _codePtr;
- while (n.isDigit()) {
- buf += n.toLatin1();
- n = *code++;
- }
+ QChar quote = (mode == TemplateContinuation) ? QChar(TemplateHead) : QChar(mode);
+ bool multilineStringLiteral = false;
- if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) {
- if (code != _codePtr) {
- _codePtr = code - 1;
+ const QChar *startCode = _codePtr;
+
+ if (_engine) {
+ while (_codePtr <= _endPtr) {
+ if (isLineTerminator() && quote != QLatin1Char('`')) {
+ if (qmlMode())
+ break;
+ _errorCode = IllegalCharacter;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Stray newline in string literal");
+ return T_ERROR;
+ } else if (_char == QLatin1Char('\\')) {
+ break;
+ } else if (_char == '$' && quote == QLatin1Char('`')) {
+ break;
+ } else if (_char == quote) {
+ _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode);
scanChar();
+
+ if (quote == QLatin1Char('`'))
+ _bracesCount = _outerTemplateBraceCount.pop();
+
+ if (mode == TemplateHead)
+ return T_NO_SUBSTITUTION_TEMPLATE;
+ else if (mode == TemplateContinuation)
+ return T_TEMPLATE_TAIL;
+ else
+ return T_STRING_LITERAL;
}
- buf.append('\0');
- _tokenValue = strtod(buf.constData(), nullptr);
- return T_NUMERIC_LITERAL;
+ scanChar();
}
- } else if (_char.isDigit() && !qmlMode()) {
- _errorCode = IllegalCharacter;
- _errorMessage = QCoreApplication::translate("QQmlParser", "Decimal numbers can't start with '0'");
- return T_ERROR;
}
- QVarLengthArray<char,32> chars;
- chars.append(ch.unicode());
+ _validTokenText = true;
+ _tokenText.resize(0);
+ startCode--;
+ while (startCode != _codePtr - 1)
+ _tokenText += *startCode++;
+
+ while (_codePtr <= _endPtr) {
+ if (unsigned sequenceLength = isLineTerminatorSequence()) {
+ multilineStringLiteral = true;
+ _tokenText += _char;
+ if (sequenceLength == 2)
+ _tokenText += *_codePtr;
+ scanChar();
+ } else if (_char == mode) {
+ scanChar();
- if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) {
- ch = _char; // remember the x or X to use it in the error message below.
+ if (_engine)
+ _tokenSpell = _engine->newStringRef(_tokenText);
- // parse hex integer literal
- chars.append(_char.unicode());
- scanChar(); // consume `x'
+ if (quote == QLatin1Char('`'))
+ _bracesCount = _outerTemplateBraceCount.pop();
- while (isHexDigit(_char)) {
- chars.append(_char.unicode());
+ if (mode == TemplateContinuation)
+ return T_TEMPLATE_TAIL;
+ else if (mode == TemplateHead)
+ return T_NO_SUBSTITUTION_TEMPLATE;
+
+ return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL;
+ } else if (quote == QLatin1Char('`') && _char == QLatin1Char('$') && *_codePtr == '{') {
+ scanChar();
+ scanChar();
+ _bracesCount = 1;
+ if (_engine)
+ _tokenSpell = _engine->newStringRef(_tokenText);
+
+ return (mode == TemplateHead ? T_TEMPLATE_HEAD : T_TEMPLATE_MIDDLE);
+ } else if (_char == QLatin1Char('\\')) {
+ scanChar();
+ if (_codePtr > _endPtr) {
+ _errorCode = IllegalEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "End of file reached at escape sequence");
+ return T_ERROR;
+ }
+
+ QChar u;
+
+ switch (_char.unicode()) {
+ // unicode escape sequence
+ case 'u': {
+ bool ok = false;
+ uint codePoint = decodeUnicodeEscapeCharacter(&ok);
+ if (!ok)
+ return T_ERROR;
+ if (QChar::requiresSurrogates(codePoint)) {
+ // need to use a surrogate pair
+ _tokenText += QChar(QChar::highSurrogate(codePoint));
+ u = QChar::lowSurrogate(codePoint);
+ } else {
+ u = codePoint;
+ }
+ } break;
+
+ // hex escape sequence
+ case 'x': {
+ bool ok = false;
+ u = decodeHexEscapeCharacter(&ok);
+ if (!ok) {
+ _errorCode = IllegalHexadecimalEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Illegal hexadecimal escape sequence");
+ return T_ERROR;
+ }
+ } break;
+
+ // single character escape sequence
+ case '\\': u = QLatin1Char('\\'); scanChar(); break;
+ case '\'': u = QLatin1Char('\''); scanChar(); break;
+ case '\"': u = QLatin1Char('\"'); scanChar(); break;
+ case 'b': u = QLatin1Char('\b'); scanChar(); break;
+ case 'f': u = QLatin1Char('\f'); scanChar(); break;
+ case 'n': u = QLatin1Char('\n'); scanChar(); break;
+ case 'r': u = QLatin1Char('\r'); scanChar(); break;
+ case 't': u = QLatin1Char('\t'); scanChar(); break;
+ case 'v': u = QLatin1Char('\v'); scanChar(); break;
+
+ case '0':
+ if (! _codePtr->isDigit()) {
+ scanChar();
+ u = QLatin1Char('\0');
+ break;
+ }
+ Q_FALLTHROUGH();
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ _errorCode = IllegalEscapeSequence;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Octal escape sequences are not allowed");
+ return T_ERROR;
+
+ case '\r':
+ case '\n':
+ case 0x2028u:
+ case 0x2029u:
+ scanChar();
+ continue;
+
+ default:
+ // non escape character
+ u = _char;
+ scanChar();
+ }
+
+ _tokenText += u;
+ } else {
+ _tokenText += _char;
scanChar();
}
+ }
- if (chars.size() < 3) {
- _errorCode = IllegalHexNumber;
- _errorMessage = QCoreApplication::translate("QQmlParser", "At least one hexadecimal digit is required after '0%1'").arg(ch);
+ _errorCode = UnclosedStringLiteral;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Unclosed string at end of line");
+ return T_ERROR;
+}
+
+int Lexer::scanNumber(QChar ch)
+{
+ if (ch == QLatin1Char('0')) {
+ if (_char == QLatin1Char('x') || _char == QLatin1Char('X')) {
+ ch = _char; // remember the x or X to use it in the error message below.
+
+ // parse hex integer literal
+ scanChar(); // consume 'x'
+
+ if (!isHexDigit(_char)) {
+ _errorCode = IllegalNumber;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "At least one hexadecimal digit is required after '0%1'").arg(ch);
+ return T_ERROR;
+ }
+
+ double d = 0.;
+ while (1) {
+ int digit = ::hexDigit(_char);
+ if (digit < 0)
+ break;
+ d *= 16;
+ d += digit;
+ scanChar();
+ }
+
+ _tokenValue = d;
+ return T_NUMERIC_LITERAL;
+ } else if (_char == QLatin1Char('o') || _char == QLatin1Char('O')) {
+ ch = _char; // remember the o or O to use it in the error message below.
+
+ // parse octal integer literal
+ scanChar(); // consume 'o'
+
+ if (!isOctalDigit(_char.unicode())) {
+ _errorCode = IllegalNumber;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "At least one octal digit is required after '0%1'").arg(ch);
+ return T_ERROR;
+ }
+
+ double d = 0.;
+ while (1) {
+ int digit = ::octalDigit(_char);
+ if (digit < 0)
+ break;
+ d *= 8;
+ d += digit;
+ scanChar();
+ }
+
+ _tokenValue = d;
+ return T_NUMERIC_LITERAL;
+ } else if (_char == QLatin1Char('b') || _char == QLatin1Char('B')) {
+ ch = _char; // remember the b or B to use it in the error message below.
+
+ // parse binary integer literal
+ scanChar(); // consume 'b'
+
+ if (_char.unicode() != '0' && _char.unicode() != '1') {
+ _errorCode = IllegalNumber;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "At least one binary digit is required after '0%1'").arg(ch);
+ return T_ERROR;
+ }
+
+ double d = 0.;
+ while (1) {
+ int digit = 0;
+ if (_char.unicode() == '1')
+ digit = 1;
+ else if (_char.unicode() != '0')
+ break;
+ d *= 2;
+ d += digit;
+ scanChar();
+ }
+
+ _tokenValue = d;
+ return T_NUMERIC_LITERAL;
+ } else if (_char.isDigit() && !qmlMode()) {
+ _errorCode = IllegalCharacter;
+ _errorMessage = QCoreApplication::translate("QQmlParser", "Decimal numbers can't start with '0'");
return T_ERROR;
}
-
- _tokenValue = integerFromString(chars.constData(), chars.size(), 16);
- return T_NUMERIC_LITERAL;
}
// decimal integer literal
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar(); // consume the digit
- }
-
- if (_char == QLatin1Char('.')) {
- chars.append(_char.unicode());
- scanChar(); // consume `.'
+ QVarLengthArray<char,32> chars;
+ chars.append(ch.unicode());
+ if (ch != QLatin1Char('.')) {
while (_char.isDigit()) {
chars.append(_char.unicode());
- scanChar();
+ scanChar(); // consume the digit
}
- if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
- if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
- _codePtr[1].isDigit())) {
-
- chars.append(_char.unicode());
- scanChar(); // consume `e'
+ if (_char == QLatin1Char('.')) {
+ chars.append(_char.unicode());
+ scanChar(); // consume `.'
+ }
+ }
- if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) {
- chars.append(_char.unicode());
- scanChar(); // consume the sign
- }
+ while (_char.isDigit()) {
+ chars.append(_char.unicode());
+ scanChar();
+ }
- while (_char.isDigit()) {
- chars.append(_char.unicode());
- scanChar();
- }
- }
- }
- } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
+ if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) {
if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) &&
_codePtr[1].isDigit())) {
@@ -1001,12 +1106,6 @@ int Lexer::scanNumber(QChar ch)
}
}
- if (chars.length() == 1) {
- // if we ended up with a single digit, then it was a '0'
- _tokenValue = 0;
- return T_NUMERIC_LITERAL;
- }
-
chars.append('\0');
const char *begin = chars.constData();
@@ -1174,16 +1273,6 @@ bool Lexer::isOctalDigit(ushort c)
return (c >= '0' && c <= '7');
}
-int Lexer::tokenEndLine() const
-{
- return _currentLineNumber;
-}
-
-int Lexer::tokenEndColumn() const
-{
- return _codePtr - _lastLinePtr;
-}
-
QString Lexer::tokenText() const
{
if (_validTokenText)
@@ -1256,6 +1345,7 @@ static const int uriTokens[] = {
QQmlJSGrammar::T_FUNCTION,
QQmlJSGrammar::T_IF,
QQmlJSGrammar::T_IN,
+ QQmlJSGrammar::T_OF,
QQmlJSGrammar::T_INSTANCEOF,
QQmlJSGrammar::T_NEW,
QQmlJSGrammar::T_NULL,
@@ -1302,7 +1392,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
lex(); // skip T_DOT
- if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD))
+ if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_IMPORT))
return true; // expected a valid QML/JS directive
const QString directiveName = tokenText();
@@ -1396,7 +1486,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
//
// recognize the mandatory `as' followed by the module name
//
- if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as") && tokenStartLine() == lineNumber)) {
+ if (! (lex() == T_AS && tokenStartLine() == lineNumber)) {
if (fileImport)
error->message = QCoreApplication::translate("QQmlParser", "File import requires a qualifier");
else
diff --git a/src/qml/parser/qqmljslexer_p.h b/src/qml/parser/qqmljslexer_p.h
index 11d8081713..644c5c09aa 100644
--- a/src/qml/parser/qqmljslexer_p.h
+++ b/src/qml/parser/qqmljslexer_p.h
@@ -51,10 +51,11 @@
// We mean it.
//
-#include "qqmljsglobal_p.h"
-#include "qqmljsgrammar_p.h"
+#include <private/qqmljsglobal_p.h>
+#include <private/qqmljsgrammar_p.h>
#include <QtCore/qstring.h>
+#include <QtCore/qstack.h>
QT_QML_BEGIN_NAMESPACE
@@ -62,32 +63,7 @@ namespace QQmlJS {
class Engine;
class DiagnosticMessage;
-
-class QML_PARSER_EXPORT Directives {
-public:
- virtual ~Directives() {}
-
- virtual void pragmaLibrary()
- {
- }
-
- virtual void importFile(const QString &jsfile, const QString &module, int line, int column)
- {
- Q_UNUSED(jsfile);
- Q_UNUSED(module);
- Q_UNUSED(line);
- Q_UNUSED(column);
- }
-
- virtual void importModule(const QString &uri, const QString &version, const QString &module, int line, int column)
- {
- Q_UNUSED(uri);
- Q_UNUSED(version);
- Q_UNUSED(module);
- Q_UNUSED(line);
- Q_UNUSED(column);
- }
-};
+class Directives;
class QML_PARSER_EXPORT Lexer: public QQmlJSGrammar
{
@@ -97,10 +73,7 @@ public:
T_BOOLEAN = T_RESERVED_WORD,
T_BYTE = T_RESERVED_WORD,
T_CHAR = T_RESERVED_WORD,
- T_CLASS = T_RESERVED_WORD,
T_DOUBLE = T_RESERVED_WORD,
- T_EXPORT = T_RESERVED_WORD,
- T_EXTENDS = T_RESERVED_WORD,
T_FINAL = T_RESERVED_WORD,
T_FLOAT = T_RESERVED_WORD,
T_GOTO = T_RESERVED_WORD,
@@ -113,8 +86,6 @@ public:
T_PRIVATE = T_RESERVED_WORD,
T_PROTECTED = T_RESERVED_WORD,
T_SHORT = T_RESERVED_WORD,
- T_STATIC = T_RESERVED_WORD,
- T_SUPER = T_RESERVED_WORD,
T_SYNCHRONIZED = T_RESERVED_WORD,
T_THROWS = T_RESERVED_WORD,
T_TRANSIENT = T_RESERVED_WORD,
@@ -124,7 +95,7 @@ public:
enum Error {
NoError,
IllegalCharacter,
- IllegalHexNumber,
+ IllegalNumber,
UnclosedStringLiteral,
IllegalEscapeSequence,
IllegalUnicodeEscapeSequence,
@@ -142,13 +113,34 @@ public:
enum RegExpFlag {
RegExp_Global = 0x01,
RegExp_IgnoreCase = 0x02,
- RegExp_Multiline = 0x04
+ RegExp_Multiline = 0x04,
+ RegExp_Unicode = 0x08,
+ RegExp_Sticky = 0x10
+ };
+
+ enum ParseModeFlags {
+ QmlMode = 0x1,
+ YieldIsKeyword = 0x2,
+ StaticIsKeyword = 0x4
};
public:
Lexer(Engine *engine);
+ int parseModeFlags() const {
+ int flags = 0;
+ if (qmlMode())
+ flags |= QmlMode|StaticIsKeyword;
+ if (yieldIsKeyWord())
+ flags |= YieldIsKeyword;
+ if (_staticIsKeyword)
+ flags |= StaticIsKeyword;
+ return flags;
+ }
+
bool qmlMode() const;
+ bool yieldIsKeyWord() const { return _generatorLevel != 0; }
+ void setStaticIsKeyword(bool b) { _staticIsKeyword = b; }
QString code() const;
void setCode(const QString &code, int lineno, bool qmlMode = true);
@@ -166,10 +158,7 @@ public:
int tokenLength() const { return _tokenLength; }
int tokenStartLine() const { return _tokenLine; }
- int tokenStartColumn() const { return _tokenStartPtr - _tokenLinePtr + 1; }
-
- int tokenEndLine() const;
- int tokenEndColumn() const;
+ int tokenStartColumn() const { return _tokenColumn; }
inline QStringRef tokenSpell() const { return _tokenSpell; }
double tokenValue() const { return _tokenValue; }
@@ -188,13 +177,23 @@ public:
BalancedParentheses
};
+ void enterGeneratorBody() { ++_generatorLevel; }
+ void leaveGeneratorBody() { --_generatorLevel; }
+
protected:
- int classify(const QChar *s, int n, bool qmlMode);
+ static int classify(const QChar *s, int n, int parseModeFlags);
private:
inline void scanChar();
int scanToken();
int scanNumber(QChar ch);
+ enum ScanStringMode {
+ SingleQuote = '\'',
+ DoubleQuote = '"',
+ TemplateHead = '`',
+ TemplateContinuation = 0
+ };
+ int scanString(ScanStringMode mode);
bool isLineTerminator() const;
unsigned isLineTerminatorSequence() const;
@@ -202,10 +201,9 @@ private:
static bool isDecimalDigit(ushort c);
static bool isHexDigit(QChar c);
static bool isOctalDigit(ushort c);
- static bool isUnicodeEscapeSequence(const QChar *chars);
void syncProhibitAutomaticSemicolon();
- QChar decodeUnicodeEscapeCharacter(bool *ok);
+ uint decodeUnicodeEscapeCharacter(bool *ok);
QChar decodeHexEscapeCharacter(bool *ok);
private:
@@ -218,26 +216,30 @@ private:
const QChar *_codePtr;
const QChar *_endPtr;
- const QChar *_lastLinePtr;
- const QChar *_tokenLinePtr;
const QChar *_tokenStartPtr;
QChar _char;
Error _errorCode;
int _currentLineNumber;
+ int _currentColumnNumber;
double _tokenValue;
// parentheses state
ParenthesesState _parenthesesState;
int _parenthesesCount;
+ // template string stack
+ QStack<int> _outerTemplateBraceCount;
+ int _bracesCount = -1;
+
int _stackToken;
int _patternFlags;
int _tokenKind;
int _tokenLength;
int _tokenLine;
+ int _tokenColumn;
bool _validTokenText;
bool _prohibitAutomaticSemicolon;
@@ -246,6 +248,8 @@ private:
bool _followsClosingBrace;
bool _delimited;
bool _qmlMode;
+ int _generatorLevel = 0;
+ bool _staticIsKeyword = false;
};
} // end of namespace QQmlJS
diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h
index ef443d96bc..9a480f1224 100644
--- a/src/qml/parser/qqmljsmemorypool_p.h
+++ b/src/qml/parser/qqmljsmemorypool_p.h
@@ -83,6 +83,7 @@ public:
free(_blocks);
}
+ qDeleteAll(strings);
}
inline void *allocate(size_t size)
@@ -104,6 +105,11 @@ public:
template <typename Tp> Tp *New() { return new (this->allocate(sizeof(Tp))) Tp(); }
+ QStringRef newString(const QString &string) {
+ strings.append(new QString(string));
+ return QStringRef(strings.last());
+ }
+
private:
Q_NEVER_INLINE void *allocate_helper(size_t size)
{
@@ -143,6 +149,7 @@ private:
int _blockCount = -1;
char *_ptr = nullptr;
char *_end = nullptr;
+ QVector<QString*> strings;
enum
{
@@ -153,12 +160,10 @@ private:
class QML_PARSER_EXPORT Managed
{
- Managed(const Managed &other);
- void operator = (const Managed &other);
-
+ Q_DISABLE_COPY(Managed)
public:
- Managed() {}
- ~Managed() {}
+ Managed() = default;
+ ~Managed() = default;
void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); }
void operator delete(void *) {}
diff --git a/src/qml/parser/qqmljsparser.cpp b/src/qml/parser/qqmljsparser.cpp
deleted file mode 100644
index 24b04b02f9..0000000000
--- a/src/qml/parser/qqmljsparser.cpp
+++ /dev/null
@@ -1,2010 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qqmljsengine_p.h"
-#include "qqmljslexer_p.h"
-#include "qqmljsast_p.h"
-#include "qqmljsmemorypool_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <string.h>
-
-
-
-#include "qqmljsparser_p.h"
-
-#include <QtCore/qvarlengtharray.h>
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is automatically generated from qqmljs.g.
-// Changes should be made to that file, not here. Any change to this file will
-// be lost!
-//
-// To regenerate this file, run:
-// qlalr --no-debug --no-lines --qt qqmljs.g
-//
-
-using namespace QQmlJS;
-
-QT_QML_BEGIN_NAMESPACE
-
-void Parser::reallocateStack()
-{
- if (! stack_size)
- stack_size = 128;
- else
- stack_size <<= 1;
-
- sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
- state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
- string_stack = reinterpret_cast<QStringRef*> (realloc(static_cast<void *>(string_stack), stack_size * sizeof(QStringRef)));
-}
-
-Parser::Parser(Engine *engine):
- driver(engine),
- pool(engine->pool()),
- tos(0),
- stack_size(0),
- sym_stack(nullptr),
- state_stack(nullptr),
- location_stack(nullptr),
- string_stack(nullptr),
- program(nullptr),
- yylval(0),
- first_token(nullptr),
- last_token(nullptr)
-{
-}
-
-Parser::~Parser()
-{
- if (stack_size) {
- free(sym_stack);
- free(state_stack);
- free(location_stack);
- free(string_stack);
- }
-}
-
-static inline AST::SourceLocation location(Lexer *lexer)
-{
- AST::SourceLocation loc;
- loc.offset = lexer->tokenOffset();
- loc.length = lexer->tokenLength();
- loc.startLine = lexer->tokenStartLine();
- loc.startColumn = lexer->tokenStartColumn();
- return loc;
-}
-
-AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
-{
- QVarLengthArray<QStringRef, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
-
- AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
- nameIds.append(m->name);
- locations.append(m->identifierToken);
- it = m->base;
- }
-
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
- AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- AST::UiQualifiedId *currentId = q;
- for (int i = nameIds.size() - 1; i != -1; --i) {
- currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
- currentId->identifierToken = locations[i];
- }
-
- return currentId->finish();
- }
-
- return nullptr;
-}
-
-AST::UiQualifiedPragmaId *Parser::reparseAsQualifiedPragmaId(AST::ExpressionNode *expr)
-{
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(expr)) {
- AST::UiQualifiedPragmaId *q = new (pool) AST::UiQualifiedPragmaId(idExpr->name);
- q->identifierToken = idExpr->identifierToken;
-
- return q->finish();
- }
-
- return nullptr;
-}
-
-
-bool Parser::parse(int startToken)
-{
- Lexer *lexer = driver->lexer();
- bool hadErrors = false;
- int yytoken = -1;
- int action = 0;
-
- token_buffer[0].token = startToken;
- first_token = &token_buffer[0];
- if (startToken == T_FEED_JS_PROGRAM && !lexer->qmlMode()) {
- Directives ignoreDirectives;
- Directives *directives = driver->directives();
- if (!directives)
- directives = &ignoreDirectives;
- DiagnosticMessage error;
- if (!lexer->scanDirectives(directives, &error)) {
- diagnostic_messages.append(error);
- return false;
- }
- token_buffer[1].token = lexer->tokenKind();
- token_buffer[1].dval = lexer->tokenValue();
- token_buffer[1].loc = location(lexer);
- token_buffer[1].spell = lexer->tokenSpell();
- last_token = &token_buffer[2];
- } else {
- last_token = &token_buffer[1];
- }
-
- tos = -1;
- program = nullptr;
-
- do {
- if (++tos == stack_size)
- reallocateStack();
-
- state_stack[tos] = action;
-
- _Lcheck_token:
- if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) {
- yyprevlloc = yylloc;
-
- if (first_token == last_token) {
- yytoken = lexer->lex();
- yylval = lexer->tokenValue();
- yytokenspell = lexer->tokenSpell();
- yylloc = location(lexer);
- } else {
- yytoken = first_token->token;
- yylval = first_token->dval;
- yytokenspell = first_token->spell;
- yylloc = first_token->loc;
- ++first_token;
- }
- }
-
- action = t_action(action, yytoken);
- if (action > 0) {
- if (action != ACCEPT_STATE) {
- yytoken = -1;
- sym(1).dval = yylval;
- stringRef(1) = yytokenspell;
- loc(1) = yylloc;
- } else {
- --tos;
- return ! hadErrors;
- }
- } else if (action < 0) {
- const int r = -action - 1;
- tos -= rhs[r];
-
- switch (r) {
-
-case 0: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 1: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 2: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 3: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 4: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 5: {
- sym(1).Node = sym(2).Node;
- program = sym(1).Node;
-} break;
-
-case 6: {
- sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiHeaderItemList,
- sym(2).UiObjectMemberList->finish());
-} break;
-
-case 8: {
- sym(1).Node = sym(1).UiHeaderItemList->finish();
-} break;
-
-case 9: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiPragma);
-} break;
-
-case 10: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiImport);
-} break;
-
-case 11: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiPragma);
-} break;
-
-case 12: {
- sym(1).Node = new (pool) AST::UiHeaderItemList(sym(1).UiHeaderItemList, sym(2).UiImport);
-} break;
-
-case 16: {
- sym(1).UiPragma->semicolonToken = loc(2);
-} break;
-
-case 18: {
- sym(1).UiImport->semicolonToken = loc(2);
-} break;
-
-case 20: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->semicolonToken = loc(3);
-} break;
-
-case 22: {
- sym(1).UiImport->versionToken = loc(2);
- sym(1).UiImport->asToken = loc(3);
- sym(1).UiImport->importIdToken = loc(4);
- sym(1).UiImport->importId = stringRef(4);
- sym(1).UiImport->semicolonToken = loc(5);
-} break;
-
-case 24: {
- sym(1).UiImport->asToken = loc(2);
- sym(1).UiImport->importIdToken = loc(3);
- sym(1).UiImport->importId = stringRef(3);
- sym(1).UiImport->semicolonToken = loc(4);
-} break;
-
-case 25: {
- AST::UiPragma *node = nullptr;
-
- if (AST::UiQualifiedPragmaId *qualifiedId = reparseAsQualifiedPragmaId(sym(2).Expression)) {
- node = new (pool) AST::UiPragma(qualifiedId);
- }
-
- sym(1).Node = node;
-
- if (node) {
- node->pragmaToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### remove me
- }
-} break;
-
-case 26: {
- AST::UiImport *node = nullptr;
-
- if (AST::StringLiteral *importIdLiteral = AST::cast<AST::StringLiteral *>(sym(2).Expression)) {
- node = new (pool) AST::UiImport(importIdLiteral->value);
- node->fileNameToken = loc(2);
- } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
- node = new (pool) AST::UiImport(qualifiedId);
- node->fileNameToken = loc(2);
- }
-
- sym(1).Node = node;
-
- if (node) {
- node->importToken = loc(1);
- } else {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id or a string literal")));
-
- return false; // ### remove me
- }
-} break;
-
-case 27: {
- sym(1).Node = nullptr;
-} break;
-
-case 28: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-
-case 29: {
- sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
-} break;
-
-case 30: {
- AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(
- sym(1).UiObjectMemberList, sym(2).UiObjectMember);
- sym(1).Node = node;
-} break;
-
-case 31: {
- sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember);
-} break;
-
-case 32: {
- AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList(
- sym(1).UiArrayMemberList, sym(3).UiObjectMember);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 33: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)nullptr);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 34: {
- AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 35: {
- AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId,
- sym(2).UiObjectInitializer);
- sym(1).Node = node;
-} break;
-
-case 37: {
- AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding(
- sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish());
- node->colonToken = loc(2);
- node->lbracketToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 38: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 39: {
- AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding(
- sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
- node->colonToken = loc(2);
- node->hasOnToken = true;
- sym(1).Node = node;
-} break;
-
-case 47:
-{
- AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(
- sym(1).UiQualifiedId, sym(3).Statement);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 48: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 49: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 50: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 51: {
- AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3));
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 52: {
- sym(1).Node = nullptr;
-} break;
-
-case 53: {
- sym(1).Node = sym(1).UiParameterList->finish ();
-} break;
-
-case 54: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
- node->propertyTypeToken = loc(1);
- node->identifierToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 55: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
- node->propertyTypeToken = loc(3);
- node->commaToken = loc(2);
- node->identifierToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 57: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->parameters = sym(4).UiParameterList;
- node->semicolonToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 59: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
- node->type = AST::UiPublicMember::Signal;
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 61: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 63: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 65: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 67: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->typeModifier = stringRef(3);
- node->propertyToken = loc(2);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(7);
- node->semicolonToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 68: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3),
- sym(5).Statement);
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 69: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
- sym(6).Statement);
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 70: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
- sym(6).Statement);
- node->isDefaultMember = true;
- node->defaultToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->colonToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 71: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
- node->typeModifier = stringRef(2);
- node->propertyToken = loc(1);
- node->typeModifierToken = loc(2);
- node->typeToken = loc(4);
- node->identifierToken = loc(6);
- node->semicolonToken = loc(7); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
- propertyName->identifierToken = loc(6);
- propertyName->next = nullptr;
-
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(
- propertyName, sym(9).UiArrayMemberList->finish());
- binding->colonToken = loc(7);
- binding->lbracketToken = loc(8);
- binding->rbracketToken = loc(10);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-
-case 72: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
- node->propertyToken = loc(1);
- node->typeToken = loc(2);
- node->identifierToken = loc(3);
- node->semicolonToken = loc(4); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
- propertyName->identifierToken = loc(3);
- propertyName->next = nullptr;
-
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer);
- binding->colonToken = loc(4);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-
-case 73: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
- node->isReadonlyMember = true;
- node->readonlyToken = loc(1);
- node->propertyToken = loc(2);
- node->typeToken = loc(3);
- node->identifierToken = loc(4);
- node->semicolonToken = loc(5); // insert a fake ';' before ':'
-
- AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(4));
- propertyName->identifierToken = loc(4);
- propertyName->next = nullptr;
-
- AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding(
- propertyName, sym(6).UiQualifiedId, sym(7).UiObjectInitializer);
- binding->colonToken = loc(5);
-
- node->binding = binding;
-
- sym(1).Node = node;
-} break;
-
-case 74: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-
-case 75: {
- sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
-} break;
-
-case 76: {
- AST::UiEnumDeclaration *enumDeclaration = new (pool) AST::UiEnumDeclaration(stringRef(2), sym(4).UiEnumMemberList->finish());
- enumDeclaration->enumToken = loc(1);
- enumDeclaration->rbraceToken = loc(5);
- sym(1).Node = enumDeclaration;
- break;
-}
-
-case 77: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1));
- node->memberToken = loc(1);
- sym(1).Node = node;
- break;
-}
-
-case 78: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(stringRef(1), sym(3).dval);
- node->memberToken = loc(1);
- node->valueToken = loc(3);
- sym(1).Node = node;
- break;
-}
-
-case 79: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3));
- node->memberToken = loc(3);
- sym(1).Node = node;
- break;
-}
-
-case 80: {
- AST::UiEnumMemberList *node = new (pool) AST::UiEnumMemberList(sym(1).UiEnumMemberList, stringRef(3), sym(5).dval);
- node->memberToken = loc(3);
- node->valueToken = loc(5);
- sym(1).Node = node;
- break;
-}
-
-case 88: {
- AST::ThisExpression *node = new (pool) AST::ThisExpression();
- node->thisToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 89: {
- AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 90: {
- AST::NullExpression *node = new (pool) AST::NullExpression();
- node->nullToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 91: {
- AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
- node->trueToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 92: {
- AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
- node->falseToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 93: {
- AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-case 94:
-case 95: {
- AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 96: {
- bool rx = lexer->scanRegExp(Lexer::NoPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false; // ### remove me
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 97: {
- bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
- if (!rx) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
- return false;
- }
-
- loc(1).length = lexer->tokenLength();
- yylloc = loc(1); // adjust the location of the current token
-
- AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral(
- driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags());
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 98: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) nullptr);
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 99: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 100: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
- node->lbracketToken = loc(1);
- node->rbracketToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 101: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- (AST::Elision *) nullptr);
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 102: {
- AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
- sym(4).Elision->finish());
- node->lbracketToken = loc(1);
- node->commaToken = loc(3);
- node->rbracketToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 103: {
- AST::ObjectLiteral *node = nullptr;
- if (sym(2).Node)
- node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyAssignmentList->finish ());
- else
- node = new (pool) AST::ObjectLiteral();
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 104: {
- AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
- sym(2).PropertyAssignmentList->finish ());
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 105: {
- AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
- node->lparenToken = loc(1);
- node->rparenToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 106: {
- if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
- QLatin1String("Ignored annotation")));
-
- sym(1).Expression = mem->base;
- }
-
- if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
- sym(1).UiQualifiedId = qualifiedId;
- } else {
- sym(1).UiQualifiedId = nullptr;
-
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
- QLatin1String("Expected a qualified name id")));
-
- return false; // ### recover
- }
-} break;
-
-case 107: {
- sym(1).Node = new (pool) AST::ElementList((AST::Elision *) nullptr, sym(1).Expression);
-} break;
-
-case 108: {
- sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
-} break;
-
-case 109: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
- (AST::Elision *) nullptr, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 110: {
- AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
- sym(4).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 111: {
- AST::Elision *node = new (pool) AST::Elision();
- node->commaToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 112: {
- AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 113: {
- AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue(
- sym(1).PropertyName, sym(3).Expression);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 114: {
- AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
- sym(2).PropertyName, sym(6).FunctionBody);
- node->getSetToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(4);
- node->lbraceToken = loc(5);
- node->rbraceToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 115: {
- AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
- sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody);
- node->getSetToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 116: {
- sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment);
-} break;
-
-case 117: {
- AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList(
- sym(1).PropertyAssignmentList, sym(3).PropertyAssignment);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 118: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 119: {
- AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 120: {
- AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 121: {
- AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
- node->propertyNameToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 159: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 160: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 161: {
- AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
- node->newToken = loc(1);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 163: {
- AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
- node->newToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 164: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 165: {
- AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 166: {
- AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
- node->lbracketToken = loc(2);
- node->rbracketToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 167: {
- AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
- node->dotToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 168: {
- sym(1).Node = nullptr;
-} break;
-
-case 169: {
- sym(1).Node = sym(1).ArgumentList->finish();
-} break;
-
-case 170: {
- sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
-} break;
-
-case 171: {
- AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 175: {
- AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
- node->incrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 176: {
- AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
- node->decrementToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 178: {
- AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
- node->deleteToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 179: {
- AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
- node->voidToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 180: {
- AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
- node->typeofToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 181: {
- AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
- node->incrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 182: {
- AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
- node->decrementToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 183: {
- AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
- node->plusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 184: {
- AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
- node->minusToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 185: {
- AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
- node->tildeToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 186: {
- AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
- node->notToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 188: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mul, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 189: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Div, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 190: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Mod, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 192: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Add, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 193: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Sub, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 195: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::LShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 196: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::RShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 197: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::URShift, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 199: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 200: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 201: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 202: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 203: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 204: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::In, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 206: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Lt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 207: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Gt, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 208: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Le, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 209: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Ge, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 210: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::InstanceOf, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 212: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 213: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 214: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 215: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 217: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Equal, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 218: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::NotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 219: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 220: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::StrictNotEqual, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 222: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 224: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitAnd, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 226: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 228: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitXor, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 230: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 232: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::BitOr, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 234: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 236: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::And, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 238: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 240: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- QSOperator::Or, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 242: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 244: {
- AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
- sym(3).Expression, sym(5).Expression);
- node->questionToken = loc(2);
- node->colonToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 246: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 248: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
- sym(2).ival, sym(3).Expression);
- node->operatorToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 249: {
- sym(1).ival = QSOperator::Assign;
-} break;
-
-case 250: {
- sym(1).ival = QSOperator::InplaceMul;
-} break;
-
-case 251: {
- sym(1).ival = QSOperator::InplaceDiv;
-} break;
-
-case 252: {
- sym(1).ival = QSOperator::InplaceMod;
-} break;
-
-case 253: {
- sym(1).ival = QSOperator::InplaceAdd;
-} break;
-
-case 254: {
- sym(1).ival = QSOperator::InplaceSub;
-} break;
-
-case 255: {
- sym(1).ival = QSOperator::InplaceLeftShift;
-} break;
-
-case 256: {
- sym(1).ival = QSOperator::InplaceRightShift;
-} break;
-
-case 257: {
- sym(1).ival = QSOperator::InplaceURightShift;
-} break;
-
-case 258: {
- sym(1).ival = QSOperator::InplaceAnd;
-} break;
-
-case 259: {
- sym(1).ival = QSOperator::InplaceXor;
-} break;
-
-case 260: {
- sym(1).ival = QSOperator::InplaceOr;
-} break;
-
-case 262: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 263: {
- sym(1).Node = nullptr;
-} break;
-
-case 266: {
- AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 267: {
- sym(1).Node = nullptr;
-} break;
-
-case 284: {
- AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 285: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
-} break;
-
-case 286: {
- sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
-} break;
-
-case 287: {
- sym(1).Node = nullptr;
-} break;
-
-case 288: {
- sym(1).Node = sym(1).StatementList->finish ();
-} break;
-
-case 290: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- if (sym(1).ival == T_LET)
- s = AST::VariableDeclaration::BlockScope;
- else if (sym(1).ival == T_CONST)
- s = AST::VariableDeclaration::ReadOnlyBlockScope;
-
- AST::VariableStatement *node = new (pool) AST::VariableStatement(sym(2).VariableDeclarationList->finish(s));
- node->declarationKindToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 291: {
- sym(1).ival = T_LET;
-} break;
-
-case 292: {
- sym(1).ival = T_CONST;
-} break;
-
-case 293: {
- sym(1).ival = T_VAR;
-} break;
-
-case 294: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-
-case 295: {
- AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
- sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
- node->commaToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 296: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
-} break;
-
-case 297: {
- sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
-} break;
-
-case 298: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression, s);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 299: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression, s);
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 300: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 301: {
- sym(1).Node = nullptr;
-} break;
-
-case 303: {
- // ### TODO: AST for initializer
- sym(1) = sym(2);
-} break;
-
-case 304: {
- sym(1).Node = nullptr;
-} break;
-
-case 306: {
- AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
- node->semicolonToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 308: {
- AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 309: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->elseToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 310: {
- AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
- node->ifToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 313: {
- AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
- node->doToken = loc(1);
- node->whileToken = loc(3);
- node->lparenToken = loc(4);
- node->rparenToken = loc(6);
- node->semicolonToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 314: {
- AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
- node->whileToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 315: {
- AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Expression, sym(9).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->firstSemicolonToken = loc(4);
- node->secondSemicolonToken = loc(6);
- node->rparenToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 316: {
- AST::VariableDeclaration::VariableScope s = AST::VariableDeclaration::FunctionScope;
- AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
- sym(4).VariableDeclarationList->finish(s), sym(6).Expression,
- sym(8).Expression, sym(10).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->firstSemicolonToken = loc(5);
- node->secondSemicolonToken = loc(7);
- node->rparenToken = loc(9);
- sym(1).Node = node;
-} break;
-
-case 317: {
- AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
- sym(5).Expression, sym(7).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->inToken = loc(4);
- node->rparenToken = loc(6);
- sym(1).Node = node;
-} break;
-
-case 318: {
- AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
- sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
- node->forToken = loc(1);
- node->lparenToken = loc(2);
- node->varToken = loc(3);
- node->inToken = loc(5);
- node->rparenToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 320: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
- node->continueToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 322: {
- AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
- node->continueToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 324: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
- node->breakToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 326: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
- node->breakToken = loc(1);
- node->identifierToken = loc(2);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 328: {
- AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
- node->returnToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 329: {
- AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
- node->withToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 330: {
- AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
- node->switchToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 331: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 332: {
- AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
- node->lbraceToken = loc(1);
- node->rbraceToken = loc(5);
- sym(1).Node = node;
-} break;
-
-case 333: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
-} break;
-
-case 334: {
- sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
-} break;
-
-case 335: {
- sym(1).Node = nullptr;
-} break;
-
-case 336: {
- sym(1).Node = sym(1).CaseClauses->finish ();
-} break;
-
-case 337: {
- AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
- node->caseToken = loc(1);
- node->colonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 338: {
- AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
- node->defaultToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 339: {
- AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
- node->identifierToken = loc(1);
- node->colonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 341: {
- AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
- node->throwToken = loc(1);
- node->semicolonToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 342: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 343: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 344: {
- AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
- node->tryToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 345: {
- AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
- node->catchToken = loc(1);
- node->lparenToken = loc(2);
- node->identifierToken = loc(3);
- node->rparenToken = loc(4);
- sym(1).Node = node;
-} break;
-
-case 346: {
- AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
- node->finallyToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 348: {
- AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
- node->debuggerToken = loc(1);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-case 350: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 351: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
- node->functionToken = loc(1);
- if (! stringRef(2).isNull())
- node->identifierToken = loc(2);
- node->lparenToken = loc(3);
- node->rparenToken = loc(5);
- node->lbraceToken = loc(6);
- node->rbraceToken = loc(8);
- sym(1).Node = node;
-} break;
-
-case 352: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody);
- node->functionToken = loc(1);
- node->lparenToken = loc(2);
- node->rparenToken = loc(4);
- node->lbraceToken = loc(5);
- node->rbraceToken = loc(7);
- sym(1).Node = node;
-} break;
-
-case 353: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
- node->identifierToken = loc(1);
- sym(1).Node = node;
-} break;
-
-case 354: {
- AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
- node->commaToken = loc(2);
- node->identifierToken = loc(3);
- sym(1).Node = node;
-} break;
-
-case 355: {
- sym(1).Node = nullptr;
-} break;
-
-case 356: {
- sym(1).Node = sym(1).FormalParameterList->finish ();
-} break;
-
-case 357: {
- sym(1).Node = nullptr;
-} break;
-
-case 359: {
- sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
-} break;
-
-case 361: {
- sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
-} break;
-
-case 362: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
-} break;
-
-case 363: {
- sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
-} break;
-
-case 364: {
- sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
-} break;
-
-case 365: {
- sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
-} break;
-
-case 366: {
- sym(1).Node = nullptr;
-} break;
-
- } // switch
- action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
- } // if
- } while (action != 0);
-
- if (first_token == last_token) {
- const int errorState = state_stack[tos];
-
- // automatic insertion of `;'
- if (yytoken != -1 && ((t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken))
- || t_action(errorState, T_COMPATIBILITY_SEMICOLON))) {
- SavedToken &tk = token_buffer[0];
- tk.token = yytoken;
- tk.dval = yylval;
- tk.spell = yytokenspell;
- tk.loc = yylloc;
-
- yylloc = yyprevlloc;
- yylloc.offset += yylloc.length;
- yylloc.startColumn += yylloc.length;
- yylloc.length = 0;
-
- //const QString msg = QCoreApplication::translate("QQmlParser", "Missing `;'");
- //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[1];
-
- yytoken = T_SEMICOLON;
- yylval = 0;
-
- action = errorState;
-
- goto _Lcheck_token;
- }
-
- hadErrors = true;
-
- token_buffer[0].token = yytoken;
- token_buffer[0].dval = yylval;
- token_buffer[0].spell = yytokenspell;
- token_buffer[0].loc = yylloc;
-
- token_buffer[1].token = yytoken = lexer->lex();
- token_buffer[1].dval = yylval = lexer->tokenValue();
- token_buffer[1].spell = yytokenspell = lexer->tokenSpell();
- token_buffer[1].loc = yylloc = location(lexer);
-
- if (t_action(errorState, yytoken)) {
- QString msg;
- int token = token_buffer[0].token;
- if (token < 0 || token >= TERMINAL_COUNT)
- msg = QCoreApplication::translate("QQmlParser", "Syntax error");
- else
- msg = QCoreApplication::translate("QQmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- action = errorState;
- goto _Lcheck_token;
- }
-
- static int tokens[] = {
- T_PLUS,
- T_EQ,
-
- T_COMMA,
- T_COLON,
- T_SEMICOLON,
-
- T_RPAREN, T_RBRACKET, T_RBRACE,
-
- T_NUMERIC_LITERAL,
- T_IDENTIFIER,
-
- T_LPAREN, T_LBRACKET, T_LBRACE,
-
- EOF_SYMBOL
- };
-
- for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) {
- int a = t_action(errorState, *tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = QCoreApplication::translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = *tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- first_token = &token_buffer[0];
- last_token = &token_buffer[2];
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
- tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
- tk == T_FEED_JS_SOURCE_ELEMENT)
- continue;
-
- int a = t_action(errorState, tk);
- if (a > 0 && t_action(a, yytoken)) {
- const QString msg = QCoreApplication::translate("QQmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
-
- yytoken = tk;
- yylval = 0;
- yylloc = token_buffer[0].loc;
- yylloc.length = 0;
-
- action = errorState;
- goto _Lcheck_token;
- }
- }
-
- const QString msg = QCoreApplication::translate("QQmlParser", "Syntax error");
- diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
- }
-
- return false;
-}
-
-QT_QML_END_NAMESPACE
-
-
diff --git a/src/qml/parser/qqmljsparser_p.h b/src/qml/parser/qqmljsparser_p.h
deleted file mode 100644
index b4aecd2f08..0000000000
--- a/src/qml/parser/qqmljsparser_p.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is automatically generated from qqmljs.g.
-// Changes should be made to that file, not here. Any change to this file will
-// be lost!
-//
-// To regenerate this file, run:
-// qlalr --no-debug --no-lines --qt qqmljs.g
-//
-
-#ifndef QQMLJSPARSER_P_H
-#define QQMLJSPARSER_P_H
-
-#include "qqmljsglobal_p.h"
-#include "qqmljsgrammar_p.h"
-#include "qqmljsast_p.h"
-#include "qqmljsengine_p.h"
-
-#include <QtCore/qlist.h>
-#include <QtCore/qstring.h>
-
-QT_QML_BEGIN_NAMESPACE
-
-namespace QQmlJS {
-
-class Engine;
-
-class QML_PARSER_EXPORT Parser: protected QQmlJSGrammar
-{
-public:
- union Value {
- int ival;
- double dval;
- AST::ArgumentList *ArgumentList;
- AST::CaseBlock *CaseBlock;
- AST::CaseClause *CaseClause;
- AST::CaseClauses *CaseClauses;
- AST::Catch *Catch;
- AST::DefaultClause *DefaultClause;
- AST::ElementList *ElementList;
- AST::Elision *Elision;
- AST::ExpressionNode *Expression;
- AST::Finally *Finally;
- AST::FormalParameterList *FormalParameterList;
- AST::FunctionBody *FunctionBody;
- AST::FunctionDeclaration *FunctionDeclaration;
- AST::Node *Node;
- AST::PropertyName *PropertyName;
- AST::PropertyAssignment *PropertyAssignment;
- AST::PropertyAssignmentList *PropertyAssignmentList;
- AST::SourceElement *SourceElement;
- AST::SourceElements *SourceElements;
- AST::Statement *Statement;
- AST::StatementList *StatementList;
- AST::Block *Block;
- AST::VariableDeclaration *VariableDeclaration;
- AST::VariableDeclarationList *VariableDeclarationList;
-
- AST::UiProgram *UiProgram;
- AST::UiHeaderItemList *UiHeaderItemList;
- AST::UiPragma *UiPragma;
- AST::UiImport *UiImport;
- AST::UiParameterList *UiParameterList;
- AST::UiPublicMember *UiPublicMember;
- AST::UiObjectDefinition *UiObjectDefinition;
- AST::UiObjectInitializer *UiObjectInitializer;
- AST::UiObjectBinding *UiObjectBinding;
- AST::UiScriptBinding *UiScriptBinding;
- AST::UiArrayBinding *UiArrayBinding;
- AST::UiObjectMember *UiObjectMember;
- AST::UiObjectMemberList *UiObjectMemberList;
- AST::UiArrayMemberList *UiArrayMemberList;
- AST::UiQualifiedId *UiQualifiedId;
- AST::UiQualifiedPragmaId *UiQualifiedPragmaId;
- AST::UiEnumMemberList *UiEnumMemberList;
- };
-
-public:
- Parser(Engine *engine);
- ~Parser();
-
- // parse a UI program
- bool parse() { return parse(T_FEED_UI_PROGRAM); }
- bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
- bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
- bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
- bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
- bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
-
- AST::UiProgram *ast() const
- { return AST::cast<AST::UiProgram *>(program); }
-
- AST::Statement *statement() const
- {
- if (! program)
- return nullptr;
-
- return program->statementCast();
- }
-
- AST::ExpressionNode *expression() const
- {
- if (! program)
- return nullptr;
-
- return program->expressionCast();
- }
-
- AST::UiObjectMember *uiObjectMember() const
- {
- if (! program)
- return nullptr;
-
- return program->uiObjectMemberCast();
- }
-
- AST::Node *rootNode() const
- { return program; }
-
- QList<DiagnosticMessage> diagnosticMessages() const
- { return diagnostic_messages; }
-
- inline DiagnosticMessage diagnosticMessage() const
- {
- for (const DiagnosticMessage &d : diagnostic_messages) {
- if (d.kind != DiagnosticMessage::Warning)
- return d;
- }
-
- return DiagnosticMessage();
- }
-
- inline QString errorMessage() const
- { return diagnosticMessage().message; }
-
- inline int errorLineNumber() const
- { return diagnosticMessage().loc.startLine; }
-
- inline int errorColumnNumber() const
- { return diagnosticMessage().loc.startColumn; }
-
-protected:
- bool parse(int startToken);
-
- void reallocateStack();
-
- inline Value &sym(int index)
- { return sym_stack [tos + index - 1]; }
-
- inline QStringRef &stringRef(int index)
- { return string_stack [tos + index - 1]; }
-
- inline AST::SourceLocation &loc(int index)
- { return location_stack [tos + index - 1]; }
-
- AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
- AST::UiQualifiedPragmaId *reparseAsQualifiedPragmaId(AST::ExpressionNode *expr);
-
-protected:
- Engine *driver;
- MemoryPool *pool;
- int tos;
- int stack_size;
- Value *sym_stack;
- int *state_stack;
- AST::SourceLocation *location_stack;
- QStringRef *string_stack;
-
- AST::Node *program;
-
- // error recovery
- enum { TOKEN_BUFFER_SIZE = 3 };
-
- struct SavedToken {
- int token;
- double dval;
- AST::SourceLocation loc;
- QStringRef spell;
- };
-
- double yylval;
- QStringRef yytokenspell;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
-
- SavedToken token_buffer[TOKEN_BUFFER_SIZE];
- SavedToken *first_token;
- SavedToken *last_token;
-
- QList<DiagnosticMessage> diagnostic_messages;
-};
-
-} // end of namespace QQmlJS
-
-
-
-#define J_SCRIPT_REGEXPLITERAL_RULE1 96
-
-#define J_SCRIPT_REGEXPLITERAL_RULE2 97
-
-QT_QML_END_NAMESPACE
-
-
-
-#endif // QQMLJSPARSER_P_H
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index 2137877427..a76a87b153 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -31,7 +31,7 @@ DEFINES += QT_NO_FOREACH
!equals(tag, "$${LITERAL_DOLLAR}Format:%H$${LITERAL_DOLLAR}") {
QML_COMPILE_HASH = $$tag
} else:exists($$PWD/../../.git) {
- commit = $$system(git describe --tags --always --long --dirty)
+ commit = $$system(git rev-parse HEAD)
QML_COMPILE_HASH = $$commit
}
compile_hash_contents = \
@@ -73,7 +73,7 @@ include(jsruntime/jsruntime.pri)
include(jit/jit.pri)
include(qml/qml.pri)
include(debugger/debugger.pri)
-qtConfig(animation) {
+qtConfig(qml-animation) {
include(animations/animations.pri)
}
include(types/types.pri)
diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri
index 87d80d04bc..ade05a596b 100644
--- a/src/qml/qml/ftw/ftw.pri
+++ b/src/qml/qml/ftw/ftw.pri
@@ -11,8 +11,7 @@ HEADERS += \
$$PWD/qrecyclepool_p.h \
$$PWD/qflagpointer_p.h \
$$PWD/qlazilyallocated_p.h \
- $$PWD/qqmlnullablevalue_p.h \
- $$PWD/qdeferredcleanup_p.h \
+ $$PWD/qqmlnullablevalue_p.h
SOURCES += \
$$PWD/qintrusivelist.cpp \
diff --git a/src/qml/qml/ftw/qflagpointer_p.h b/src/qml/qml/ftw/qflagpointer_p.h
index 91ce74bec9..71b41cd30b 100644
--- a/src/qml/qml/ftw/qflagpointer_p.h
+++ b/src/qml/qml/ftw/qflagpointer_p.h
@@ -82,6 +82,8 @@ public:
inline T *data() const;
+ inline explicit operator bool() const;
+
private:
quintptr ptr_value = 0;
@@ -230,6 +232,12 @@ T *QFlagPointer<T>::data() const
return (T *)(ptr_value & ~FlagsMask);
}
+template<typename T>
+QFlagPointer<T>::operator bool() const
+{
+ return data() != nullptr;
+}
+
template<typename T, typename T2>
QBiPointer<T, T2>::QBiPointer()
{
diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h
index 3cfb345b30..d32a08e0f5 100644
--- a/src/qml/qml/ftw/qqmlrefcount_p.h
+++ b/src/qml/qml/ftw/qqmlrefcount_p.h
@@ -85,19 +85,23 @@ public:
inline QQmlRefPointer();
inline QQmlRefPointer(T *, Mode m = AddRef);
inline QQmlRefPointer(const QQmlRefPointer<T> &);
+ inline QQmlRefPointer(QQmlRefPointer<T> &&);
inline ~QQmlRefPointer();
inline QQmlRefPointer<T> &operator=(const QQmlRefPointer<T> &o);
+ inline QQmlRefPointer<T> &operator=(QQmlRefPointer<T> &&o);
inline bool isNull() const { return !o; }
inline T* operator->() const { return o; }
inline T& operator*() const { return *o; }
- inline operator T*() const { return o; }
+ explicit inline operator bool() const { return o != nullptr; }
inline T* data() const { return o; }
inline QQmlRefPointer<T> &adopt(T *);
+ inline T* take() { T *res = o; o = nullptr; return res; }
+
private:
T *o;
};
@@ -156,6 +160,12 @@ QQmlRefPointer<T>::QQmlRefPointer(const QQmlRefPointer<T> &other)
if (o) o->addref();
}
+template <class T>
+QQmlRefPointer<T>::QQmlRefPointer(QQmlRefPointer<T> &&other)
+ : o(other.take())
+{
+}
+
template<class T>
QQmlRefPointer<T>::~QQmlRefPointer()
{
@@ -171,6 +181,14 @@ QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(const QQmlRefPointer<T> &other)
return *this;
}
+template <class T>
+QQmlRefPointer<T> &QQmlRefPointer<T>::operator=(QQmlRefPointer<T> &&other)
+{
+ QQmlRefPointer<T> m(std::move(other));
+ qSwap(o, m.o);
+ return *this;
+}
+
/*!
Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership
of the callers reference of other.
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 96313d7627..2ef1dc7e93 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -316,6 +316,12 @@ void QQmlThread::shutdownThread()
void QQmlThread::internalCallMethodInThread(Message *message)
{
+#if !QT_CONFIG(thread)
+ message->call(this);
+ delete message;
+ return;
+#endif
+
Q_ASSERT(!isThisThread());
d->lock();
Q_ASSERT(d->m_mainThreadWaiting == false);
@@ -376,6 +382,10 @@ void QQmlThread::internalCallMethodInMain(Message *message)
void QQmlThread::internalPostMethodToThread(Message *message)
{
+#if !QT_CONFIG(thread)
+ internalPostMethodToMain(message);
+ return;
+#endif
Q_ASSERT(!isThisThread());
d->lock();
bool wasEmpty = d->threadList.isEmpty();
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 412dc6cba2..6d69294c17 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -20,7 +20,6 @@ SOURCES += \
$$PWD/qqmlinfo.cpp \
$$PWD/qqmlerror.cpp \
$$PWD/qqmlvaluetype.cpp \
- $$PWD/qqmlxmlhttprequest.cpp \
$$PWD/qqmlcleanup.cpp \
$$PWD/qqmlpropertycache.cpp \
$$PWD/qqmlnotifier.cpp \
@@ -31,7 +30,6 @@ SOURCES += \
$$PWD/qqmlextensionplugin.cpp \
$$PWD/qqmlimport.cpp \
$$PWD/qqmllist.cpp \
- $$PWD/qqmllocale.cpp \
$$PWD/qqmljavascriptexpression.cpp \
$$PWD/qqmlabstractbinding.cpp \
$$PWD/qqmlvaluetypeproxybinding.cpp \
@@ -85,7 +83,6 @@ HEADERS += \
$$PWD/qqmldata_p.h \
$$PWD/qqmlerror.h \
$$PWD/qqmlvaluetype_p.h \
- $$PWD/qqmlxmlhttprequest_p.h \
$$PWD/qqmlcleanup_p.h \
$$PWD/qqmlpropertycache_p.h \
$$PWD/qqmlpropertyindex_p.h \
@@ -99,7 +96,6 @@ HEADERS += \
$$PWD/qqmlimport_p.h \
$$PWD/qqmlextensionplugin.h \
$$PWD/qqmlscriptstring_p.h \
- $$PWD/qqmllocale_p.h \
$$PWD/qqmlcomponentattached_p.h \
$$PWD/qqmljavascriptexpression_p.h \
$$PWD/qqmlabstractbinding_p.h \
@@ -120,5 +116,22 @@ HEADERS += \
$$PWD/qqmldelayedcallqueue_p.h \
$$PWD/qqmlloggingcategory_p.h
+qtConfig(qml-xml-http-request) {
+ HEADERS += \
+ $$PWD/qqmlxmlhttprequest_p.h
+
+ SOURCES += \
+ $$PWD/qqmlxmlhttprequest.cpp
+
+}
+
+qtConfig(qml-locale) {
+ HEADERS += \
+ $$PWD/qqmllocale_p.h
+
+ SOURCES += \
+ $$PWD/qqmllocale.cpp
+}
+
include(ftw/ftw.pri)
include(v8/v8.pri)
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 213f23cd98..05a9f70247 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -496,6 +496,38 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
}
+template<typename T, int metaObjectRevision>
+int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, QQmlCustomParser *parser)
+{
+ QML_GETTYPENAMES
+
+ QQmlPrivate::RegisterType type = {
+ 1,
+
+ qRegisterNormalizedMetaType<T *>(pointerName.constData()),
+ qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ sizeof(T), QQmlPrivate::createInto<T>,
+ QString(),
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QQmlPrivate::attachedPropertiesFunc<T>(),
+ QQmlPrivate::attachedPropertiesMetaObject<T>(),
+
+ QQmlPrivate::StaticCastSelector<T,QQmlParserStatus>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueSource>::cast(),
+ QQmlPrivate::StaticCastSelector<T,QQmlPropertyValueInterceptor>::cast(),
+
+ nullptr, nullptr,
+
+ parser,
+ metaObjectRevision
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
+}
+
template<typename T, typename E>
int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName, QQmlCustomParser *parser)
@@ -645,6 +677,8 @@ inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, i
return QQmlPrivate::qmlregister(QQmlPrivate::CompositeRegistration, &type);
}
+int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName);
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QObject)
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index a0517e4558..9ac2100eab 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -74,7 +74,7 @@ void QQmlApplicationEnginePrivate::init()
q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit);
#if QT_CONFIG(translation)
QTranslator* qtTranslator = new QTranslator;
- if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ if (qtTranslator->load(QLocale(), QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QCoreApplication::installTranslator(qtTranslator);
translators << qtTranslator;
#endif
@@ -91,7 +91,7 @@ void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile)
QFileInfo fi(rootFile.toLocalFile());
QTranslator *translator = new QTranslator;
- if (translator->load(QLatin1String("qml_") + QLocale::system().name(), fi.path() + QLatin1String("/i18n"))) {
+ if (translator->load(QLocale(), QLatin1String("qml"), QLatin1String("_"), fi.path() + QLatin1String("/i18n"))) {
QCoreApplication::installTranslator(translator);
translators << translator;
} else {
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 30a18440a8..e38f379eb0 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -337,7 +337,7 @@ protected:
class QQmlTranslationBinding : public GenericBinding<QMetaType::QString> {
public:
- QQmlTranslationBinding(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Binding *binding)
+ QQmlTranslationBinding(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
setCompilationUnit(compilationUnit);
m_binding = binding;
@@ -358,7 +358,7 @@ public:
if (!isAddedToObject() || hasError())
return;
- const QString result = m_binding->valueAsString(m_compilationUnit->data);
+ const QString result = m_binding->valueAsString(m_compilationUnit.data());
Q_ASSERT(targetObject());
@@ -374,11 +374,13 @@ public:
}
}
+ bool hasDependencies() const override final { return true; }
+
private:
const QV4::CompiledData::Binding *m_binding;
};
-QQmlBinding *QQmlBinding::createTranslationBinding(QV4::CompiledData::CompilationUnit *unit, const QV4::CompiledData::Binding *binding, QObject *obj, QQmlContextData *ctxt)
+QQmlBinding *QQmlBinding::createTranslationBinding(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, const QV4::CompiledData::Binding *binding, QObject *obj, QQmlContextData *ctxt)
{
QQmlTranslationBinding *b = new QQmlTranslationBinding(unit, binding);
@@ -550,7 +552,7 @@ void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
QString QQmlBinding::expression() const
{
- return QStringLiteral("function() { [code] }");
+ return QStringLiteral("function() { [native code] }");
}
void QQmlBinding::setTarget(const QQmlProperty &prop)
@@ -663,6 +665,11 @@ QVector<QQmlProperty> QQmlBinding::dependencies() const
return dependencies;
}
+bool QQmlBinding::hasDependencies() const
+{
+ return !permanentGuards.isEmpty() || !activeGuards.isEmpty() || translationsCaptured();
+}
+
class QObjectPointerBinding: public QQmlNonbindingBinding
{
QQmlMetaObject targetMetaObject;
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index a1295bd0ac..f192de4342 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -79,7 +79,7 @@ public:
const QString &url = QString(), quint16 lineNumber = 0);
static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function,
QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope);
- static QQmlBinding *createTranslationBinding(QV4::CompiledData::CompilationUnit *unit, const QV4::CompiledData::Binding *binding,
+ static QQmlBinding *createTranslationBinding(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, const QV4::CompiledData::Binding *binding,
QObject *obj, QQmlContextData *ctxt);
~QQmlBinding() override;
@@ -118,6 +118,7 @@ public:
* Call this method from the UI thread.
*/
QVector<QQmlProperty> dependencies() const;
+ virtual bool hasDependencies() const;
protected:
virtual void doUpdate(const DeleteWatcher &watcher,
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index d5117c8cec..e5b78591e0 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -110,46 +110,34 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
m_index(index),
m_target(target)
{
- // If the function is marked as having a nested function, then the user wrote:
- // onSomeSignal: function() { /*....*/ }
- // So take that nested function:
- if (auto closure = function->nestedFunction())
- function = closure;
-
- setupFunction(scope, function);
+ // It's important to call init first, because m_index gets remapped in case of cloned signals.
init(ctxt, scopeObject);
-}
-QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction)
- : QQmlJavaScriptExpression(),
- m_index(index),
- m_target(target)
-{
- // It's important to call init first, because m_index gets remapped in case of cloned signals.
- init(ctxt, scope);
+ QV4::ExecutionEngine *engine = ctxt->engine->handle();
// If the function is marked as having a nested function, then the user wrote:
// onSomeSignal: function() { /*....*/ }
// So take that nested function:
- if (auto closure = runtimeFunction->nestedFunction())
- runtimeFunction = closure;
-
- QV4::ExecutionEngine *engine = ctxt->engine->handle();
-
- QList<QByteArray> signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames();
- if (!signalParameters.isEmpty()) {
- QString error;
- QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, &error);
- if (!error.isEmpty()) {
- qmlWarning(scopeObject()) << error;
- return;
+ if (auto closure = function->nestedFunction()) {
+ function = closure;
+ } else {
+ QList<QByteArray> signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames();
+ if (!signalParameters.isEmpty()) {
+ QString error;
+ QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, &error);
+ if (!error.isEmpty()) {
+ qmlWarning(scopeObject) << error;
+ return;
+ }
+ function->updateInternalClass(engine, signalParameters);
}
- runtimeFunction->updateInternalClass(engine, signalParameters);
}
QV4::Scope valueScope(engine);
- QV4::Scoped<QV4::QmlContext> qmlContext(valueScope, QV4::QmlContext::create(engine->rootContext(), ctxt, scope));
- setupFunction(qmlContext, runtimeFunction);
+ QV4::Scoped<QV4::QmlContext> qmlContext(valueScope, scope);
+ if (!qmlContext)
+ qmlContext = QV4::QmlContext::create(engine->rootContext(), ctxt, scopeObject);
+ setupFunction(qmlContext, function);
}
void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope)
@@ -180,7 +168,7 @@ void QQmlBoundSignalExpression::expressionChanged()
QString QQmlBoundSignalExpression::expression() const
{
if (expressionFunctionValid())
- return QStringLiteral("function() { [code] }");
+ return QStringLiteral("function() { [native code] }");
return QString();
}
@@ -221,12 +209,12 @@ void QQmlBoundSignalExpression::evaluate(void **a)
jsCall->args[ii] = scope.engine->fromVariant(*((QVariant *)a[ii + 1]));
} else if (type == QMetaType::Int) {
//### optimization. Can go away if we switch to metaTypeToJS, or be expanded otherwise
- jsCall->args[ii] = QV4::Primitive::fromInt32(*reinterpret_cast<const int*>(a[ii + 1]));
+ jsCall->args[ii] = QV4::Value::fromInt32(*reinterpret_cast<const int*>(a[ii + 1]));
} else if (type == qMetaTypeId<QQmlV4Handle>()) {
jsCall->args[ii] = *reinterpret_cast<QQmlV4Handle *>(a[ii + 1]);
} else if (ep->isQObject(type)) {
if (!*reinterpret_cast<void* const *>(a[ii + 1]))
- jsCall->args[ii] = QV4::Primitive::nullValue();
+ jsCall->args[ii] = QV4::Value::nullValue();
else
jsCall->args[ii] = QV4::QObjectWrapper::wrap(v4, *reinterpret_cast<QObject* const *>(a[ii + 1]));
} else {
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 01094a11f7..d1ec67210e 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -73,10 +73,8 @@ public:
const QString &parameterString = QString());
QQmlBoundSignalExpression(QObject *target, int index,
- QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope);
-
- QQmlBoundSignalExpression(QObject *target, int index,
- QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction);
+ QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function,
+ QV4::ExecutionContext *scope = nullptr);
// inherited from QQmlJavaScriptExpression.
QString expressionIdentifier() const override;
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 8885e69161..a67c5c4a2b 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -174,8 +174,6 @@ V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension);
}
}
\endcode
-
- Note that the \l {Qt Quick 1} version is named QDeclarativeComponent.
*/
/*!
@@ -334,7 +332,7 @@ void QQmlComponentPrivate::typeDataProgress(QQmlTypeData *, qreal p)
emit q->progressChanged(p);
}
-void QQmlComponentPrivate::fromTypeData(QQmlTypeData *data)
+void QQmlComponentPrivate::fromTypeData(const QQmlRefPointer<QQmlTypeData> &data)
{
url = data->finalUrl();
compilationUnit = data->compilationUnit();
@@ -343,15 +341,12 @@ void QQmlComponentPrivate::fromTypeData(QQmlTypeData *data)
Q_ASSERT(data->isError());
state.errors = data->errors();
}
-
- data->release();
}
void QQmlComponentPrivate::clear()
{
if (typeData) {
typeData->unregisterCallback(this);
- typeData->release();
typeData = nullptr;
}
@@ -387,7 +382,7 @@ QQmlComponent::~QQmlComponent()
if (d->typeData) {
d->typeData->unregisterCallback(d);
- d->typeData->release();
+ d->typeData = nullptr;
}
}
@@ -580,7 +575,7 @@ void QQmlComponent::setData(const QByteArray &data, const QUrl &url)
d->url = url;
- QQmlTypeData *typeData = QQmlEnginePrivate::get(d->engine)->typeLoader.getType(data, url);
+ QQmlRefPointer<QQmlTypeData> typeData = QQmlEnginePrivate::get(d->engine)->typeLoader.getType(data, url);
if (typeData->isCompleteOrError()) {
d->fromTypeData(typeData);
@@ -595,8 +590,8 @@ void QQmlComponent::setData(const QByteArray &data, const QUrl &url)
}
/*!
-Returns the QQmlContext the component was created in. This is only
-valid for components created directly from QML.
+ Returns the QQmlContext the component was created in. This is only
+ valid for components created directly from QML.
*/
QQmlContext *QQmlComponent::creationContext() const
{
@@ -608,6 +603,17 @@ QQmlContext *QQmlComponent::creationContext() const
}
/*!
+ Returns the QQmlEngine of this component.
+
+ \since 5.12
+*/
+QQmlEngine *QQmlComponent::engine() const
+{
+ Q_D(const QQmlComponent);
+ return d->engine;
+}
+
+/*!
Load the QQmlComponent from the provided \a url.
\include qqmlcomponent.qdoc url-note
@@ -667,7 +673,7 @@ void QQmlComponentPrivate::loadUrl(const QUrl &newUrl, QQmlComponent::Compilatio
? QQmlTypeLoader::Asynchronous
: QQmlTypeLoader::PreferSynchronous;
- QQmlTypeData *data = QQmlEnginePrivate::get(engine)->typeLoader.getType(url, loaderMode);
+ QQmlRefPointer<QQmlTypeData> data = QQmlEnginePrivate::get(engine)->typeLoader.getType(url, loaderMode);
if (data->isCompleteOrError()) {
fromTypeData(data);
@@ -848,13 +854,10 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
// Do not create infinite recursion in object creation
static const int maxCreationDepth = 10;
- if (++creationDepth.localData() >= maxCreationDepth) {
+ if (creationDepth.localData() >= maxCreationDepth) {
qWarning("QQmlComponent: Component creation is recursing - aborting");
- --creationDepth.localData();
return nullptr;
}
- Q_ASSERT(creationDepth.localData() >= 1);
- depthIncreased = true;
QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
@@ -878,10 +881,6 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
ddata->indestructible = true;
ddata->explicitIndestructibleSet = true;
ddata->rootObjectInCreation = false;
- } else {
- Q_ASSERT(creationDepth.localData() >= 1);
- --creationDepth.localData();
- depthIncreased = false;
}
return rv;
@@ -955,14 +954,10 @@ void QQmlComponent::completeCreate()
void QQmlComponentPrivate::completeCreate()
{
if (state.completePending) {
+ ++creationDepth.localData();
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
complete(ep, &state);
- }
-
- if (depthIncreased) {
- Q_ASSERT(creationDepth.localData() >= 1);
--creationDepth.localData();
- depthIncreased = false;
}
}
@@ -1226,7 +1221,7 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV
QV4::Scope scope(engine);
QV4::ScopedObject object(scope);
QV4::ScopedObject valueMap(scope, v);
- QV4::ObjectIterator it(scope, valueMap, QV4::ObjectIterator::EnumerableOnly|QV4::ObjectIterator::WithProtoChain);
+ QV4::ObjectIterator it(scope, valueMap, QV4::ObjectIterator::EnumerableOnly);
QV4::ScopedString name(scope);
QV4::ScopedValue val(scope);
if (engine->hasException)
@@ -1274,7 +1269,7 @@ void QQmlComponent::createObject(QQmlV4Function *args)
QObject *parent = nullptr;
QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
- QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
if (args->length() >= 1) {
QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, (*args)[0]);
@@ -1389,7 +1384,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
QV4::Scope scope(v4);
QObject *parent = nullptr;
- QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue());
QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous;
if (args->length() >= 1) {
@@ -1421,9 +1416,9 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
QQmlComponentExtension *e = componentExtension(args->v4engine());
- QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->allocObject<QV4::QmlIncubatorObject>(mode));
+ QV4::Scoped<QV4::QmlIncubatorObject> r(scope, v4->memoryManager->allocate<QV4::QmlIncubatorObject>(mode));
QV4::ScopedObject p(scope, e->incubationProto.value());
- r->setPrototype(p);
+ r->setPrototypeOf(p);
if (!valuemap->isUndefined())
r->d()->valuemap.set(scope.engine, valuemap);
@@ -1527,8 +1522,8 @@ QQmlComponentExtension::~QQmlComponentExtension()
void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
{
Object::init();
- valuemap.set(internalClass->engine, QV4::Primitive::undefinedValue());
- statusChanged.set(internalClass->engine, QV4::Primitive::undefinedValue());
+ valuemap.set(internalClass->engine, QV4::Value::undefinedValue());
+ statusChanged.set(internalClass->engine, QV4::Value::undefinedValue());
parent.init();
qmlContext.set(internalClass->engine, nullptr);
incubator = new QQmlComponentIncubator(this, m);
@@ -1569,7 +1564,7 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
if (f) {
QV4::JSCallData jsCallData(scope, 1);
*jsCallData->thisObject = this;
- jsCallData->args[0] = QV4::Primitive::fromUInt32(s);
+ jsCallData->args[0] = QV4::Value::fromUInt32(s);
f->call(jsCallData);
if (scope.hasException()) {
QQmlError error = scope.engine->catchExceptionAsQmlError();
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index 444b3ec46c..20199d0b21 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -109,6 +109,7 @@ public:
QQmlContext *forContext = nullptr);
QQmlContext *creationContext() const;
+ QQmlEngine *engine() const;
static QQmlComponentAttached *qmlAttachedProperties(QObject *);
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 2a8d36f317..4d9e4c6c15 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -79,7 +79,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public
public:
QQmlComponentPrivate()
- : typeData(nullptr), progress(0.), start(-1), engine(nullptr), creationContext(nullptr), depthIncreased(false) {}
+ : progress(0.), start(-1), engine(nullptr), creationContext(nullptr) {}
void loadUrl(const QUrl &newUrl, QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous);
@@ -88,18 +88,18 @@ public:
void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate);
static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v);
- void incubateObject(
+ virtual void incubateObject(
QQmlIncubator *incubationTask,
QQmlComponent *component,
QQmlEngine *engine,
QQmlContextData *context,
QQmlContextData *forContext);
- QQmlTypeData *typeData;
+ QQmlRefPointer<QQmlTypeData> typeData;
void typeDataReady(QQmlTypeData *) override;
void typeDataProgress(QQmlTypeData *, qreal) override;
- void fromTypeData(QQmlTypeData *data);
+ void fromTypeData(const QQmlRefPointer<QQmlTypeData> &data);
QUrl url;
qreal progress;
@@ -136,7 +136,6 @@ public:
QQmlEngine *engine;
QQmlGuardedContextData creationContext;
- bool depthIncreased;
void clear();
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index 3dcfa92416..cbf5a6e259 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -845,7 +845,7 @@ void QQmlContextData::initFromTypeCompilationUnit(const QQmlRefPointer<QV4::Comp
typeCompilationUnit = unit;
componentObjectIndex = subComponentIndex == -1 ? /*root object*/0 : subComponentIndex;
Q_ASSERT(!idValues);
- idValueCount = typeCompilationUnit->data->objectAt(componentObjectIndex)->nNamedObjectsInComponent;
+ idValueCount = typeCompilationUnit->objectAt(componentObjectIndex)->nNamedObjectsInComponent;
idValues = new ContextGuard[idValueCount];
}
diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h
index 2a0f805014..bf28bca447 100644
--- a/src/qml/qml/qqmlcustomparser_p.h
+++ b/src/qml/qml/qqmlcustomparser_p.h
@@ -81,8 +81,8 @@ public:
void clearErrors();
Flags flags() const { return m_flags; }
- virtual void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &) = 0;
- virtual void applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &) = 0;
+ virtual void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
+ virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
QVector<QQmlCompileError> errors() const { return exceptions; }
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index 59fefde893..2468de6857 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -232,7 +232,7 @@ public:
QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit;
QVector<DeferredData *> deferredData;
- void deferData(int objectIndex, QV4::CompiledData::CompilationUnit *, QQmlContextData *);
+ void deferData(int objectIndex, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, QQmlContextData *);
void releaseDeferredData();
QV4::WeakValue jsWrapper;
diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp
index 5bcf5cd586..61cb0a9065 100644
--- a/src/qml/qml/qqmldelayedcallqueue.cpp
+++ b/src/qml/qml/qqmldelayedcallqueue.cpp
@@ -71,7 +71,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en
*jsCallData->thisObject = QV4::Encode::undefined();
for (int i = 0; i < argCount; i++) {
- jsCallData->args[i] = array->getIndexed(i);
+ jsCallData->args[i] = array->get(i);
}
callback->call(jsCallData);
@@ -186,7 +186,7 @@ void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4
QV4::ScopedArrayObject array(scope, engine->newArrayObject(length));
uint i = 0;
for (int j = offset, ej = argc; j < ej; ++i, ++j)
- array->putIndexed(i, argv[j]);
+ array->put(i, argv[j]);
dfc.m_args.set(engine, array);
}
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp
index 4cca8a4d58..d87bf433b8 100644
--- a/src/qml/qml/qqmldirparser.cpp
+++ b/src/qml/qml/qqmldirparser.cpp
@@ -107,6 +107,7 @@ bool QQmlDirParser::parse(const QString &source)
_components.clear();
_scripts.clear();
_designerSupported = false;
+ _className.clear();
quint16 lineNumber = 0;
bool firstLine = true;
@@ -196,7 +197,8 @@ bool QQmlDirParser::parse(const QString &source)
continue;
}
- // Ignore these. qmlimportscanner uses them.
+ _className = sections[1];
+
} else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) {
reportError(lineNumber, 0,
@@ -270,7 +272,7 @@ bool QQmlDirParser::parse(const QString &source)
if (parseVersion(sections[1], &major, &minor)) {
const QString &fileName = sections[2];
- if (fileName.endsWith(QLatin1String(".js"))) {
+ if (fileName.endsWith(QLatin1String(".js")) || fileName.endsWith(QLatin1String(".mjs"))) {
// A 'js' extension indicates a namespaced script import
const Script entry(sections[0], fileName, major, minor);
_scripts.append(entry);
@@ -377,6 +379,11 @@ bool QQmlDirParser::designerSupported() const
return _designerSupported;
}
+QString QQmlDirParser::className() const
+{
+ return _className;
+}
+
QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component)
{
const QString output = QStringLiteral("{%1 %2.%3}").
diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h
index 820c40238d..d7e29813d1 100644
--- a/src/qml/qml/qqmldirparser_p.h
+++ b/src/qml/qml/qqmldirparser_p.h
@@ -135,6 +135,8 @@ public:
QList<TypeInfo> typeInfos() const;
#endif
+ QString className() const;
+
private:
bool maybeAddComponent(const QString &typeName, const QString &fileName, const QString &version, QHash<QString,Component> &hash, int lineNumber = -1, bool multi = true);
void reportError(quint16 line, quint16 column, const QString &message);
@@ -150,6 +152,7 @@ private:
#ifdef QT_CREATOR
QList<TypeInfo> _typeInfos;
#endif
+ QString _className;
};
typedef QHash<QString,QQmlDirParser::Component> QQmlDirComponents;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index c6b39581a7..a100e1adc3 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -48,7 +48,6 @@
#include "qqmlcomponent.h"
#include "qqmlvme_p.h"
#include "qqmlstringconverters_p.h"
-#include "qqmlxmlhttprequest_p.h"
#include "qqmlscriptstring.h"
#include "qqmlglobal_p.h"
#include "qqmlcomponent_p.h"
@@ -79,20 +78,26 @@
#include <private/qobject_p.h>
#include <private/qmetaobject_p.h>
+#if QT_CONFIG(qml_locale)
#include <private/qqmllocale_p.h>
+#endif
#include <private/qqmlbind_p.h>
#include <private/qqmlconnections_p.h>
-#if QT_CONFIG(animation)
+#if QT_CONFIG(qml_animation)
#include <private/qqmltimer_p.h>
#endif
+#if QT_CONFIG(qml_list_model)
#include <private/qqmllistmodel_p.h>
+#endif
#include <private/qqmlplatform_p.h>
#include <private/qquickpackage_p.h>
#if QT_CONFIG(qml_delegate_model)
#include <private/qqmldelegatemodel_p.h>
#endif
#include <private/qqmlobjectmodel_p.h>
+#if QT_CONFIG(qml_worker_script)
#include <private/qquickworkerscript_p.h>
+#endif
#include <private/qqmlinstantiator_p.h>
#include <private/qqmlloggingcategory_p.h>
@@ -217,24 +222,32 @@ void QQmlEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int
qmlRegisterType<QObject>(uri,versionMajor,versionMinor,"QtObject");
qmlRegisterType<QQmlBind>(uri, versionMajor, versionMinor,"Binding");
qmlRegisterType<QQmlBind,8>(uri, versionMajor, (versionMinor < 8 ? 8 : versionMinor), "Binding"); //Only available in >=2.8
- qmlRegisterType<QQmlConnections,1>(uri, versionMajor, (versionMinor < 3 ? 3 : versionMinor), "Connections"); //Only available in >=2.3
- qmlRegisterType<QQmlConnections>(uri, versionMajor, versionMinor,"Connections");
-#if QT_CONFIG(animation)
+ qmlRegisterCustomType<QQmlConnections>(uri, versionMajor, 0, "Connections", new QQmlConnectionsParser);
+ if (!strcmp(uri, "QtQuick"))
+ qmlRegisterCustomType<QQmlConnections,1>(uri, versionMajor, 7, "Connections", new QQmlConnectionsParser); //Only available in QtQuick >=2.7
+ else
+ qmlRegisterCustomType<QQmlConnections,1>(uri, versionMajor, 3, "Connections", new QQmlConnectionsParser); //Only available in QtQml >=2.3
+#if QT_CONFIG(qml_animation)
qmlRegisterType<QQmlTimer>(uri, versionMajor, versionMinor,"Timer");
#endif
qmlRegisterType<QQmlInstantiator>(uri, versionMajor, (versionMinor < 1 ? 1 : versionMinor), "Instantiator"); //Only available in >=2.1
- qmlRegisterCustomType<QQmlConnections>(uri, versionMajor, versionMinor,"Connections", new QQmlConnectionsParser);
qmlRegisterType<QQmlInstanceModel>();
- qmlRegisterType<QQmlLoggingCategory>(uri, versionMajor, (versionMinor < 8 ? 8 : versionMinor), "LoggingCategory"); //Only available in >=2.8
+
+ qmlRegisterType<QQmlLoggingCategory>(uri, versionMajor, 8, "LoggingCategory"); //Only available in >=2.8
+ qmlRegisterType<QQmlLoggingCategory,1>(uri, versionMajor, 12, "LoggingCategory"); //Only available in >=2.12
}
// These QtQuick types' implementation resides in the QtQml module
void QQmlEnginePrivate::registerQtQuick2Types(const char *uri, int versionMajor, int versionMinor)
{
+#if QT_CONFIG(qml_list_model)
qmlRegisterType<QQmlListElement>(uri, versionMajor, versionMinor, "ListElement"); // Now in QtQml.Models, here for compatibility
qmlRegisterCustomType<QQmlListModel>(uri, versionMajor, versionMinor, "ListModel", new QQmlListModelParser); // Now in QtQml.Models, here for compatibility
+#endif
+#if QT_CONFIG(qml_worker_script)
qmlRegisterType<QQuickWorkerScript>(uri, versionMajor, versionMinor, "WorkerScript");
+#endif
qmlRegisterType<QQuickPackage>(uri, versionMajor, versionMinor, "Package");
#if QT_CONFIG(qml_delegate_model)
qmlRegisterType<QQmlDelegateModel>(uri, versionMajor, versionMinor, "VisualDataModel");
@@ -250,7 +263,9 @@ void QQmlEnginePrivate::defineQtQuick2Module()
// register the QtQuick2 types which are implemented in the QtQml module.
registerQtQuick2Types("QtQuick",2,0);
+#if QT_CONFIG(qml_locale)
qmlRegisterUncreatableType<QQmlLocale>("QtQuick", 2, 0, "Locale", QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
+#endif
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
qmlRegisterModule("QtQuick", 2, QT_VERSION_MINOR);
@@ -676,7 +691,9 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
#endif
outputWarningsToMsgLog(true),
cleanup(nullptr), erroredBindings(nullptr), inProgressCreations(0),
+#if QT_CONFIG(qml_worker_script)
workerScriptEngine(nullptr),
+#endif
activeObjectCreator(nullptr),
#if QT_CONFIG(qml_network)
networkAccessManager(nullptr), networkAccessManagerFactory(nullptr),
@@ -951,7 +968,9 @@ void QQmlEnginePrivate::init()
if (baseModulesUninitialized) {
qmlRegisterType<QQmlComponent>("QML", 1, 0, "Component"); // required for the Compiler.
registerBaseTypes("QtQml", 2, 0); // import which provides language building blocks.
+#if QT_CONFIG(qml_locale)
qmlRegisterUncreatableType<QQmlLocale>("QtQml", 2, 2, "Locale", QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
+#endif
// Auto-increment the import to stay in sync with ALL future QtQml minor versions from 5.11 onward
qmlRegisterModule("QtQml", 2, QT_VERSION_MINOR);
@@ -974,6 +993,7 @@ void QQmlEnginePrivate::init()
rootContext = new QQmlContext(q,true);
}
+#if QT_CONFIG(qml_worker_script)
QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
{
Q_Q(QQmlEngine);
@@ -981,6 +1001,7 @@ QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
workerScriptEngine = new QQuickWorkerScriptEngine(q);
return workerScriptEngine;
}
+#endif
/*!
\class QQmlEngine
@@ -1010,8 +1031,6 @@ QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
In this case, the Text item will be created in the engine's
\l {QQmlEngine::rootContext()}{root context}.
- Note that the \l {Qt Quick 1} version is called QDeclarativeEngine.
-
\sa QQmlComponent, QQmlContext, {QML Global Object}
*/
@@ -1365,6 +1384,71 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled)
}
/*!
+ \fn template<typename T> T QQmlEngine::singletonInstance(int qmlTypeId)
+
+ Returns the instance of a singleton type that was registered under \a qmlTypeId.
+
+ The template argument \e T may be either QJSValue or a pointer to a QObject-derived
+ type and depends on how the singleton was registered. If no instance of \e T has been
+ created yet, it is created now. If \a qmlTypeId does not represent a valid singleton
+ type, either a default constructed QJSValue or a \c nullptr is returned.
+
+ QObject* example:
+ \code
+ class MySingleton : public QObject {
+ Q_OBJECT
+ static int typeId;
+ // ...
+ };
+
+ // Register with QObject* callback
+ MySingleton::typeId = qmlRegisterSingletonType<MySingleton>(...);
+
+ // Retrieve as QObject*
+ QQmlEngine engine;
+ MySingleton* instance = engine.singletonInstance<MySingleton*>(MySingleton::typeId);
+ \endcode
+
+ QJSValue example:
+ \code
+ // Register with QJSValue callback
+ int typeId = qmlRegisterSingletonType(...);
+
+ // Retrieve as QJSValue
+ QQmlEngine engine;
+ QJSValue instance = engine.singletonInstance<QJSValue>(typeId);
+ \endcode
+
+ It is recommended to store the QML type id during registration, e.g. as a static member
+ in the singleton class. Otherwise, a costly lookup via qmlTypeId() has to be performed
+ at run-time.
+
+ \sa qmlRegisterSingletonType(), qmlTypeId()
+ \since 5.12
+*/
+template<>
+QJSValue QQmlEngine::singletonInstance<QJSValue>(int qmlTypeId)
+{
+ QQmlType type = QQmlMetaType::qmlType(qmlTypeId, QQmlMetaType::TypeIdCategory::QmlType);
+
+ if (!type.isValid() || !type.isSingleton())
+ return QJSValue();
+
+ QQmlType::SingletonInstanceInfo* info = type.singletonInstanceInfo();
+ info->init(this);
+
+ if (QObject* o = info->qobjectApi(this))
+ return this->newQObject(o);
+ else {
+ QJSValue value = info->scriptApi(this);
+ if (!value.isUndefined())
+ return value;
+ }
+
+ return QJSValue();
+}
+
+/*!
Refreshes all binding expressions that use strings marked for translation.
Call this function after you have installed a new translator with
@@ -1699,7 +1783,7 @@ void QQmlData::NotifyList::layout()
todo = nullptr;
}
-void QQmlData::deferData(int objectIndex, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *context)
+void QQmlData::deferData(int objectIndex, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlContextData *context)
{
QQmlData::DeferredData *deferData = new QQmlData::DeferredData;
deferData->deferredIdx = objectIndex;
@@ -2030,6 +2114,25 @@ void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QList<QQmlError
dumpwarning(error);
}
+QList<QQmlError> QQmlEnginePrivate::qmlErrorFromDiagnostics(const QString &fileName, const QList<DiagnosticMessage> &diagnosticMessages)
+{
+ QList<QQmlError> errors;
+ for (const DiagnosticMessage &m : diagnosticMessages) {
+ if (m.isWarning()) {
+ qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message));
+ continue;
+ }
+
+ QQmlError error;
+ error.setUrl(QUrl(fileName));
+ error.setDescription(m.message);
+ error.setLine(m.loc.startLine);
+ error.setColumn(m.loc.startColumn);
+ errors << error;
+ }
+ return errors;
+}
+
void QQmlEnginePrivate::cleanupScarceResources()
{
// iterate through the list and release them all.
@@ -2266,7 +2369,7 @@ QQmlMetaObject QQmlEnginePrivate::rawMetaObjectForType(int t) const
Locker locker(this);
auto iter = m_compositeTypes.constFind(t);
if (iter != m_compositeTypes.cend()) {
- return QQmlMetaObject((*iter)->rootPropertyCache());
+ return QQmlMetaObject((*iter)->rootPropertyCache().data());
} else {
QQmlType type = QQmlMetaType::qmlType(t);
return QQmlMetaObject(type.baseMetaObject());
@@ -2278,7 +2381,7 @@ QQmlMetaObject QQmlEnginePrivate::metaObjectForType(int t) const
Locker locker(this);
auto iter = m_compositeTypes.constFind(t);
if (iter != m_compositeTypes.cend()) {
- return QQmlMetaObject((*iter)->rootPropertyCache());
+ return QQmlMetaObject((*iter)->rootPropertyCache().data());
} else {
QQmlType type = QQmlMetaType::qmlType(t);
return QQmlMetaObject(type.metaObject());
@@ -2290,7 +2393,7 @@ QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t)
Locker locker(this);
auto iter = m_compositeTypes.constFind(t);
if (iter != m_compositeTypes.cend()) {
- return (*iter)->rootPropertyCache();
+ return (*iter)->rootPropertyCache().data();
} else {
QQmlType type = QQmlMetaType::qmlType(t);
locker.unlock();
@@ -2303,7 +2406,7 @@ QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVe
Locker locker(this);
auto iter = m_compositeTypes.constFind(t);
if (iter != m_compositeTypes.cend()) {
- return (*iter)->rootPropertyCache();
+ return (*iter)->rootPropertyCache().data();
} else {
QQmlType type = QQmlMetaType::qmlType(t);
locker.unlock();
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index 73ad2754c8..871e6bd9b4 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -143,6 +143,9 @@ public:
bool outputWarningsToStandardError() const;
void setOutputWarningsToStandardError(bool);
+ template<typename T>
+ T singletonInstance(int qmlTypeId);
+
public Q_SLOTS:
void retranslate();
@@ -167,6 +170,19 @@ private:
Q_DECLARE_PRIVATE(QQmlEngine)
};
+template<>
+Q_QML_EXPORT QJSValue QQmlEngine::singletonInstance<QJSValue>(int qmlTypeId);
+
+template<typename T>
+T QQmlEngine::singletonInstance(int qmlTypeId) {
+ QJSValue instance = singletonInstance<QJSValue>(qmlTypeId);
+ if (!instance.isQObject())
+ return nullptr;
+
+ QObject *object = instance.toQObject();
+ return qobject_cast<T>(object);
+}
+
QT_END_NAMESPACE
#endif // QQMLENGINE_H
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index da52e01793..3caa6ec138 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -153,8 +153,10 @@ public:
QV8Engine *v8engine() const { return q_func()->handle()->v8Engine; }
QV4::ExecutionEngine *v4engine() const { return q_func()->handle(); }
+#if QT_CONFIG(qml_worker_script)
QQuickWorkerScriptEngine *getWorkerScriptEngine();
QQuickWorkerScriptEngine *workerScriptEngine;
+#endif
QUrl baseUrl;
@@ -245,6 +247,8 @@ public:
inline static QQmlEngine *get(QQmlEnginePrivate *p);
inline static QQmlEnginePrivate *get(QV4::ExecutionEngine *e);
+ static QList<QQmlError> qmlErrorFromDiagnostics(const QString &fileName, const QList<QQmlJS::DiagnosticMessage> &diagnosticMessages);
+
static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
static void registerQtQuick2Types(const char *uri, int versionMajor, int versionMinor);
static void defineQtQuick2Module();
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index fc5b186b29..61e9a3f37e 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -73,8 +73,6 @@ QT_BEGIN_NAMESPACE
^
\endcode
- Note that the \l {Qt Quick 1} version is named QDeclarativeError
-
\sa QQuickView::errors(), QQmlComponent::errors()
*/
class QQmlErrorPrivate
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 27d3acb9b7..0c1ffbf3a0 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -110,8 +110,6 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu
QQmlExpression *expr = new QQmlExpression(engine->rootContext(), myObject, "width * 2");
int result = expr->evaluate().toInt(); // result = 400
\endcode
-
- Note that the \l {Qt Quick 1} version is called QDeclarativeExpression.
*/
/*!
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 818ff7c34f..c1c971f0a9 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
The \l {Writing QML Extensions with C++} tutorial also contains a chapter
on creating QML plugins.
- Note that the \l {Qt Quick 1} version is called QDeclarativeExtensionPlugin.
-
\sa QQmlEngine::importPlugin(), {How to Create Qt Plugins}
*/
diff --git a/src/qml/qml/qqmlguard_p.h b/src/qml/qml/qqmlguard_p.h
index 808bf4c709..3ac63926a0 100644
--- a/src/qml/qml/qqmlguard_p.h
+++ b/src/qml/qml/qqmlguard_p.h
@@ -106,6 +106,34 @@ protected:
virtual void objectDestroyed(T *) {}
};
+template <typename T>
+class QQmlStrongJSQObjectReference : public QQmlGuard<T>
+{
+public:
+ void setObject(T *o, QObject *parent) {
+ T *old = this->object();
+ if (o == old)
+ return;
+
+ if (m_jsOwnership && old && old->parent() == parent)
+ QQml_setParent_noEvent(old, nullptr);
+
+ this->QQmlGuard<T>::operator=(o);
+
+ if (o && !o->parent() && !QQmlData::keepAliveDuringGarbageCollection(o)) {
+ m_jsOwnership = true;
+ QQml_setParent_noEvent(o, parent);
+ } else {
+ m_jsOwnership = false;
+ }
+ }
+
+private:
+ using QQmlGuard<T>::setObject;
+ using QQmlGuard<T>::operator=;
+ bool m_jsOwnership = false;
+};
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QQmlGuard<QObject>)
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 80ebab5ca3..bc53b98b5b 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -674,6 +674,7 @@ bool QQmlImportInstance::setQmldirContent(const QString &resolvedUrl, const QQml
{
Q_ASSERT(resolvedUrl.endsWith(Slash));
url = resolvedUrl;
+ localDirectoryPath = QQmlFile::urlToLocalFileOrQrc(url);
qmlDirComponents = qmldir.components();
@@ -737,7 +738,8 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
int *vmajor, int *vminor, QQmlType *type_return, QString *base,
bool *typeRecursionDetected,
QQmlType::RegistrationType registrationType,
- QQmlImport::RecursionRestriction recursionRestriction) const
+ QQmlImport::RecursionRestriction recursionRestriction,
+ QList<QQmlError> *errors) const
{
if (majversion >= 0 && minversion >= 0) {
QQmlType t = QQmlMetaType::qmlType(type, uri, majversion, minversion);
@@ -810,19 +812,32 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
*type_return = returnType;
return returnType.isValid();
}
- } else if (!isLibrary) {
+ } else if (!isLibrary && !localDirectoryPath.isEmpty()) {
QString qmlUrl;
bool exists = false;
const QString urlsToTry[2] = {
- url + QString::fromRawData(type.constData(), type.length()) + dotqml_string, // Type -> Type.qml
- url + QString::fromRawData(type.constData(), type.length()) + dotuidotqml_string // Type -> Type.ui.qml
+ typeStr + dotqml_string, // Type -> Type.qml
+ typeStr + dotuidotqml_string // Type -> Type.ui.qml
};
for (uint i = 0; i < sizeof(urlsToTry) / sizeof(urlsToTry[0]); ++i) {
- const QString url = urlsToTry[i];
- exists = !typeLoader->absoluteFilePath(QQmlFile::urlToLocalFileOrQrc(url)).isEmpty();
+ exists = typeLoader->fileExists(localDirectoryPath, urlsToTry[i]);
if (exists) {
- qmlUrl = url;
+#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
+ // don't let function.qml confuse the use of "new Function(...)" for example.
+ if (!QQml_isFileCaseCorrect(localDirectoryPath + urlsToTry[i])) {
+ exists = false;
+ if (errors) {
+ QQmlError caseError;
+ caseError.setDescription(QLatin1String("File name case mismatch"));
+ errors->append(caseError);
+ }
+ break;
+ }
+#else
+ Q_UNUSED(errors);
+#endif
+ qmlUrl = url + urlsToTry[i];
break;
}
}
@@ -908,7 +923,7 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
for (int i=0; i<imports.count(); ++i) {
const QQmlImportInstance *import = imports.at(i);
if (import->resolveType(typeLoader, type, vmajor, vminor, type_return, base,
- &typeRecursionDetected, registrationType, recursionRestriction)) {
+ &typeRecursionDetected, registrationType, recursionRestriction, errors)) {
if (qmlCheckTypes()) {
// check for type clashes
for (int j = i+1; j<imports.count(); ++j) {
@@ -1421,6 +1436,7 @@ QQmlImportInstance *QQmlImportsPrivate::addImportToNamespace(QQmlImportNamespace
QQmlImportInstance *import = new QQmlImportInstance;
import->uri = uri;
import->url = url;
+ import->localDirectoryPath = QQmlFile::urlToLocalFileOrQrc(url);
import->majversion = vmaj;
import->minversion = vmin;
import->isLibrary = (type == QV4::CompiledData::Import::ImportLibrary);
@@ -1759,7 +1775,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
filePluginPath << QLatin1String(".");
// Search order is applicationDirPath(), qrc:/qt-project.org/imports, $QML2_IMPORT_PATH, QLibraryInfo::Qml2ImportsPath
- QString installImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+ QString installImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
addImportPath(installImportsPath);
// env import paths
@@ -2050,7 +2066,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
if (QQmlExtensionPlugin *plugin = qobject_cast<QQmlExtensionPlugin *>(instance)) {
// basepath should point to the directory of the module, not the plugin file itself:
- QQmlExtensionPluginPrivate::get(plugin)->baseUrl = QUrl::fromLocalFile(basePath);
+ QQmlExtensionPluginPrivate::get(plugin)->baseUrl = QQmlImports::urlFromLocalFileOrQrcOrUrl(basePath);
}
iface->registerTypes(moduleId);
diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h
index 2437979ef8..f8c01ed876 100644
--- a/src/qml/qml/qqmlimport_p.h
+++ b/src/qml/qml/qqmlimport_p.h
@@ -78,6 +78,7 @@ struct QQmlImportInstance
{
QString uri; // e.g. QtQuick
QString url; // the base path of the import
+ QString localDirectoryPath; // the base path of the import if it's a local file
int majversion; // the major version imported
int minversion; // the minor version imported
bool isLibrary; // true means that this is not a file import
@@ -94,7 +95,8 @@ struct QQmlImportInstance
int *vmajor, int *vminor, QQmlType* type_return,
QString *base = nullptr, bool *typeRecursionDetected = nullptr,
QQmlType::RegistrationType = QQmlType::AnyRegistrationType,
- QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion) const;
+ QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion,
+ QList<QQmlError> *errors = nullptr) const;
};
class QQmlImportNamespace
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index e18ce71902..39da550d63 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -282,8 +282,9 @@ void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i)
if (!vmeGuard.isOK()) {
QQmlError error;
+ error.setMessageType(QtInfoMsg);
error.setUrl(compilationUnit->url());
- error.setDescription(QQmlComponent::tr("Object destroyed during incubation"));
+ error.setDescription(QQmlComponent::tr("Object or context destroyed during incubation"));
errors << error;
progress = QQmlIncubatorPrivate::Completed;
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 93ec9421ed..9f2a96d5d9 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -93,8 +93,7 @@ void QQmlDelayedError::catchJavaScriptException(QV4::ExecutionEngine *engine)
QQmlJavaScriptExpression::QQmlJavaScriptExpression()
- : m_error(nullptr),
- m_context(nullptr),
+ : m_context(nullptr),
m_prevExpression(nullptr),
m_nextExpression(nullptr),
m_v4Function(nullptr)
@@ -247,6 +246,9 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, b
while (QQmlJavaScriptExpressionGuard *g = capture.guards.takeFirst())
g->Delete();
+ if (!watcher.wasDeleted())
+ setTranslationsCaptured(capture.translationCaptured);
+
ep->propertyCapture = lastPropertyCapture;
return result->asReturnedValue();
@@ -392,7 +394,7 @@ QQmlDelayedError *QQmlJavaScriptExpression::delayedError()
{
if (!m_error)
m_error = new QQmlDelayedError;
- return m_error;
+ return m_error.data();
}
QV4::ReturnedValue
@@ -458,7 +460,7 @@ void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext,
setCompilationUnit(m_v4Function->compilationUnit);
}
-void QQmlJavaScriptExpression::setCompilationUnit(QV4::CompiledData::CompilationUnit *compilationUnit)
+void QQmlJavaScriptExpression::setCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
{
m_compilationUnit = compilationUnit;
}
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 01af3b89ca..de3fba0774 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -162,7 +162,7 @@ protected:
}
void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
- void setCompilationUnit(QV4::CompiledData::CompilationUnit *compilationUnit);
+ void setCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
// We store some flag bits in the following flag pointers.
// activeGuards:flag1 - notifyOnValueChanged
@@ -171,13 +171,17 @@ protected:
QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> activeGuards;
QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> permanentGuards;
+ void setTranslationsCaptured(bool captured) { m_error.setFlagValue(captured); }
+ bool translationsCaptured() const { return m_error.flag(); }
+
private:
friend class QQmlContextData;
friend class QQmlPropertyCapture;
friend void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **);
friend class QQmlTranslationBinding;
- QQmlDelayedError *m_error;
+ // m_error:flag1 translationsCapturedDuringEvaluation
+ QFlagPointer<QQmlDelayedError> m_error;
QQmlContextData *m_context;
QQmlJavaScriptExpression **m_prevExpression;
@@ -208,12 +212,14 @@ public:
static void registerQmlDependencies(QV4::Heap::QmlContext *context, const QV4::ExecutionEngine *engine, const QV4::CompiledData::Function *compiledFunction);
void captureProperty(QQmlNotifier *, Duration duration = OnlyOnce);
void captureProperty(QObject *, int, int, Duration duration = OnlyOnce, bool doNotify = true);
+ void captureTranslation() { translationCaptured = true; }
QQmlEngine *engine;
QQmlJavaScriptExpression *expression;
QQmlJavaScriptExpression::DeleteWatcher *watcher;
QFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards;
QStringList *errorString;
+ bool translationCaptured = false;
};
QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e)
@@ -260,18 +266,17 @@ void QQmlJavaScriptExpression::setScopeObject(QObject *v)
bool QQmlJavaScriptExpression::hasError() const
{
- return m_error && m_error->isValid();
+ return !m_error.isNull() && m_error->isValid();
}
bool QQmlJavaScriptExpression::hasDelayedError() const
{
- return m_error;
+ return !m_error.isNull();
}
inline void QQmlJavaScriptExpression::clearError()
{
- if (m_error)
- delete m_error;
+ delete m_error.data();
m_error = nullptr;
}
diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp
index 918b181195..656a8a470b 100644
--- a/src/qml/qml/qqmllist.cpp
+++ b/src/qml/qml/qqmllist.cpp
@@ -109,8 +109,6 @@ Attempting to add objects of the incorrect type to a list property will fail.
Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
that it does not request an out of range element using the count() method before calling at().
-
-The \l {Qt Quick 1} version of this class is named QDeclarativeListReference.
*/
/*!
@@ -367,10 +365,7 @@ Q_PROPERTY(QQmlListProperty<Fruit> fruit READ fruit)
QML list properties are type-safe - in this case \c {Fruit} is a QObject type that
\c {Apple}, \c {Orange} and \c {Banana} all derive from.
-The \l {Qt Quick 1} version of this class is named QDeclarativeListProperty.
-
\sa {Extending QML - Object and List Property Types Example}
-
*/
/*!
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 3fbe3df2ab..2f769c1aef 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -74,7 +74,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, i
Scope scope(engine);
- Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocObject<QmlListWrapper>());
+ Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocate<QmlListWrapper>());
r->d()->object = object;
r->d()->propertyType = propType;
void *args[] = { &r->d()->property(), nullptr };
@@ -86,7 +86,7 @@ ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, const QQmlListProp
{
Scope scope(engine);
- Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocObject<QmlListWrapper>());
+ Scoped<QmlListWrapper> r(scope, engine->memoryManager->allocate<QmlListWrapper>());
r->d()->object = prop.object;
r->d()->property() = prop;
r->d()->propertyType = propType;
@@ -102,68 +102,73 @@ QVariant QmlListWrapper::toVariant() const
}
-ReturnedValue QmlListWrapper::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlListWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QmlListWrapper>());
const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
QV4::ExecutionEngine *v4 = w->engine();
- if (name->equals(v4->id_length()) && !w->d()->object.isNull()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- return Primitive::fromUInt32(count).asReturnedValue();
- }
-
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return getIndexed(m, idx, hasProperty);
-
- return Object::get(m, name, hasProperty);
-}
-
-ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
-{
- Q_UNUSED(hasProperty);
-
- Q_ASSERT(m->as<QmlListWrapper>());
- const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
- QV4::ExecutionEngine *v4 = w->engine();
+ if (index < count && w->d()->property().at) {
+ if (hasProperty)
+ *hasProperty = true;
+ return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index));
+ }
- quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- if (index < count && w->d()->property().at) {
if (hasProperty)
- *hasProperty = true;
- return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index));
+ *hasProperty = false;
+ return Value::undefinedValue().asReturnedValue();
+ } else if (id.isString()) {
+ if (id == v4->id_length()->propertyKey() && !w->d()->object.isNull()) {
+ quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
+ return Value::fromUInt32(count).asReturnedValue();
+ }
}
- if (hasProperty)
- *hasProperty = false;
- return Primitive::undefinedValue().asReturnedValue();
+ return Object::virtualGet(m, id, receiver, hasProperty);
}
-bool QmlListWrapper::put(Managed *m, String *name, const Value &value)
+bool QmlListWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
// doesn't do anything. Should we throw?
Q_UNUSED(m);
- Q_UNUSED(name);
+ Q_UNUSED(id);
Q_UNUSED(value);
+ Q_UNUSED(receiver);
return false;
}
-void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs)
+struct QmlListWrapperOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
{
- name->setM(nullptr);
- *index = UINT_MAX;
- Q_ASSERT(m->as<QmlListWrapper>());
- QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
+ ~QmlListWrapperOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey QmlListWrapperOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
+{
+ const QmlListWrapper *w = static_cast<const QmlListWrapper *>(o);
+
quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0;
- if (it->arrayIndex < count) {
- *index = it->arrayIndex;
- ++it->arrayIndex;
- *attrs = QV4::Attr_Data;
- p->value = QV4::QObjectWrapper::wrap(w->engine(), w->d()->property().at(&w->d()->property(), *index));
- return;
+ if (arrayIndex < count) {
+ uint index = arrayIndex;
+ ++arrayIndex;
+ if (attrs)
+ *attrs = QV4::Attr_Data;
+ if (pd)
+ pd->value = QV4::QObjectWrapper::wrap(w->engine(), w->d()->property().at(&w->d()->property(), index));
+ return PropertyKey::fromArrayIndex(index);
}
- return QV4::Object::advanceIterator(m, it, name, index, p, attrs);
+
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *QmlListWrapper::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new QmlListWrapperOwnPropertyKeyIterator;
}
void PropertyListPrototype::init(ExecutionEngine *)
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index e02831c8d1..c185122ad9 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -93,10 +93,9 @@ struct Q_QML_EXPORT QmlListWrapper : Object
QVariant toVariant() const;
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
};
struct PropertyListPrototype : Object
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index b4f7092a22..2b17037df0 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -77,7 +77,7 @@ static bool isLocaleObject(const QV4::Value &val)
void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine)
{
- engine->datePrototype()->defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString);
+ engine->datePrototype()->defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString);
engine->datePrototype()->defineDefaultProperty(QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString);
engine->datePrototype()->defineDefaultProperty(QStringLiteral("toLocaleDateString"), method_toLocaleDateString);
engine->dateCtor()->defineDefaultProperty(QStringLiteral("fromLocaleString"), method_fromLocaleString);
@@ -350,7 +350,7 @@ ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const QV4::FunctionObjec
if (argc != 0)
THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments");
- QV4::DatePrototype::timezoneUpdated();
+ QV4::DatePrototype::timezoneUpdated(scope.engine);
RETURN_UNDEFINED();
}
@@ -360,7 +360,7 @@ ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const QV4::FunctionObjec
void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine)
{
- engine->numberPrototype()->defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString);
+ engine->numberPrototype()->defineDefaultProperty(engine->id_toLocaleString(), method_toLocaleString);
engine->numberPrototype()->defineDefaultProperty(QStringLiteral("toLocaleCurrencyString"), method_toLocaleCurrencyString);
engine->numberCtor()->defineDefaultProperty(QStringLiteral("fromLocaleString"), method_fromLocaleString);
}
@@ -512,7 +512,7 @@ ReturnedValue QQmlLocaleData::method_get_weekDays(const QV4::FunctionObject *b,
int day = days.at(i);
if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
day = 0;
- result->arrayPut(i, QV4::Primitive::fromInt32(day));
+ result->arrayPut(i, QV4::Value::fromInt32(day));
}
result->setArrayLengthUnchecked(days.size());
@@ -825,10 +825,10 @@ QV4::ReturnedValue QQmlLocale::wrap(ExecutionEngine *v4, const QLocale &locale)
{
QV4::Scope scope(v4);
QV4LocaleDataDeletable *d = localeV4Data(scope.engine);
- QV4::Scoped<QQmlLocaleData> wrapper(scope, v4->memoryManager->allocObject<QQmlLocaleData>());
+ QV4::Scoped<QQmlLocaleData> wrapper(scope, v4->memoryManager->allocate<QQmlLocaleData>());
*wrapper->d()->locale = locale;
QV4::ScopedObject p(scope, d->prototype.value());
- wrapper->setPrototype(p);
+ wrapper->setPrototypeOf(p);
return wrapper.asReturnedValue();
}
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 8341b1f555..859c36e11b 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -58,6 +58,8 @@
#include <private/qqmlglobal_p.h>
#include <private/qv4object_p.h>
+QT_REQUIRE_CONFIG(qml_locale);
+
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
index 597fe458fa..b59a26e17e 100644
--- a/src/qml/qml/qqmlloggingcategory.cpp
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -59,6 +59,7 @@
LoggingCategory {
id: category
name: "com.qt.category"
+ defaultLogLevel: LoggingCategory.Warning
}
Component.onCompleted: {
@@ -84,6 +85,17 @@
\sa QLoggingCategory::categoryName()
*/
+/*!
+ \qmlproperty enumeration QtQml::LoggingCategory::defaultLogLevel
+ \since 5.12
+
+ Holds the default log level of the logging category. By default it is
+ created with the LoggingCategory.Debug log level.
+
+ \note This property needs to be set when declaring the LoggingCategory
+ and cannot be changed later.
+*/
+
QQmlLoggingCategory::QQmlLoggingCategory(QObject *parent)
: QObject(parent)
, m_initialized(false)
@@ -99,6 +111,11 @@ QString QQmlLoggingCategory::name() const
return QString::fromUtf8(m_name);
}
+QQmlLoggingCategory::DefaultLogLevel QQmlLoggingCategory::defaultLogLevel() const
+{
+ return m_defaultLogLevel;
+}
+
QLoggingCategory *QQmlLoggingCategory::category() const
{
return m_category.data();
@@ -111,10 +128,25 @@ void QQmlLoggingCategory::classBegin()
void QQmlLoggingCategory::componentComplete()
{
m_initialized = true;
- if (m_name.isNull())
+ if (m_name.isNull()) {
qmlWarning(this) << QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !");
+ } else {
+ QScopedPointer<QLoggingCategory> category(new QLoggingCategory(m_name.constData(), QtMsgType(m_defaultLogLevel)));
+ m_category.swap(category);
+ }
}
+void QQmlLoggingCategory::setDefaultLogLevel(DefaultLogLevel defaultLogLevel)
+{
+ if (m_initialized) {
+ qmlWarning(this) << QLatin1String("The defaultLogLevel of a LoggingCategory cannot be changed after the Item is created");
+ return;
+ }
+
+ m_defaultLogLevel = defaultLogLevel;
+}
+
+
void QQmlLoggingCategory::setName(const QString &name)
{
if (m_initialized) {
@@ -123,8 +155,6 @@ void QQmlLoggingCategory::setName(const QString &name)
}
m_name = name.toUtf8();
- QScopedPointer<QLoggingCategory> category(new QLoggingCategory(m_name.constData()));
- m_category.swap(category);
}
#include "moc_qqmlloggingcategory_p.cpp"
diff --git a/src/qml/qml/qqmlloggingcategory_p.h b/src/qml/qml/qqmlloggingcategory_p.h
index 544db1fe33..ece06e04b4 100644
--- a/src/qml/qml/qqmlloggingcategory_p.h
+++ b/src/qml/qml/qqmlloggingcategory_p.h
@@ -65,11 +65,23 @@ class QQmlLoggingCategory : public QObject, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(DefaultLogLevel defaultLogLevel READ defaultLogLevel WRITE setDefaultLogLevel REVISION 1)
public:
+ enum DefaultLogLevel {
+ Debug = QtDebugMsg,
+ Info = QtInfoMsg,
+ Warning = QtWarningMsg,
+ Critical = QtCriticalMsg,
+ Fatal = QtFatalMsg
+ };
+ Q_ENUM(DefaultLogLevel);
+
QQmlLoggingCategory(QObject *parent = nullptr);
virtual ~QQmlLoggingCategory();
+ DefaultLogLevel defaultLogLevel() const;
+ void setDefaultLogLevel(DefaultLogLevel defaultLogLevel);
QString name() const;
void setName(const QString &name);
@@ -81,6 +93,7 @@ public:
private:
QByteArray m_name;
QScopedPointer<QLoggingCategory> m_category;
+ DefaultLogLevel m_defaultLogLevel = Debug;
bool m_initialized;
};
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 2705321e77..e34f7a407f 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -137,6 +137,15 @@ private:
QStringList *typeRegistrationFailures = nullptr;
};
+struct EnumInfo {
+ QStringList path;
+ QString metaObjectName;
+ QString enumName;
+ QString enumKey;
+ QString metaEnumScope;
+ bool scoped;
+};
+
class QQmlTypeModulePrivate
{
public:
@@ -218,6 +227,7 @@ public:
int attachedPropertiesId;
int propertyValueSourceCast;
int propertyValueInterceptorCast;
+ bool registerEnumClassesUnscoped;
};
struct QQmlSingletonTypeData
@@ -270,6 +280,9 @@ public:
QVector<PropertyCacheByMinorVersion> propertyCaches;
QQmlPropertyCache *propertyCacheForMinorVersion(int minorVersion) const;
void setPropertyCacheForMinorVersion(int minorVersion, QQmlPropertyCache *cache);
+private:
+ void createListOfPossibleConflictingItems(const QMetaObject *metaObject, QList<EnumInfo> &enumInfoList, QStringList path) const;
+ void createEnumConflictReport(const QMetaObject *metaObject, const QString &conflictingKey) const;
};
void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv)
@@ -288,7 +301,14 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv)
void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e)
{
if (scriptCallback && scriptApi(e).isUndefined()) {
- setScriptApi(e, scriptCallback(e, e));
+ QJSValue value = scriptCallback(e, e);
+ if (value.isQObject()) {
+ QObject *o = value.toQObject();
+ // even though the object is defined in C++, qmlContext(obj) and qmlEngine(obj)
+ // should behave identically to QML singleton types.
+ e->setContextForObject(o, new QQmlContext(e->rootContext(), e));
+ }
+ setScriptApi(e, value);
} else if (qobjectCallback && !qobjectApi(e)) {
QObject *o = qobjectCallback(e, e);
setQObjectApi(e, o);
@@ -297,6 +317,9 @@ void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e)
}
// if this object can use a property cache, create it now
QQmlData::ensurePropertyCache(e, o);
+ // even though the object is defined in C++, qmlContext(obj) and qmlEngine(obj)
+ // should behave identically to QML singleton types.
+ e->setContextForObject(o, new QQmlContext(e->rootContext(), e));
} else if (!url.isEmpty() && !qobjectApi(e)) {
QQmlComponent component(e, url, QQmlComponent::PreferSynchronous);
QObject *o = component.beginCreate(e->rootContext());
@@ -359,6 +382,7 @@ QQmlTypePrivate::QQmlTypePrivate(QQmlType::RegistrationType type)
extraData.cd->attachedPropertiesType = nullptr;
extraData.cd->propertyValueSourceCast = -1;
extraData.cd->propertyValueInterceptorCast = -1;
+ extraData.cd->registerEnumClassesUnscoped = true;
break;
case QQmlType::SingletonType:
case QQmlType::CompositeSingletonType:
@@ -485,9 +509,17 @@ QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQm
d->extraData.cd->propertyValueInterceptorCast = type.valueInterceptorCast;
d->extraData.cd->extFunc = type.extensionObjectCreate;
d->extraData.cd->customParser = type.customParser;
+ d->extraData.cd->registerEnumClassesUnscoped = true;
if (type.extensionMetaObject)
d->extraData.cd->extMetaObject = type.extensionMetaObject;
+
+ // Check if the user wants only scoped enum classes
+ if (d->baseMetaObject) {
+ auto indexOfClassInfo = d->baseMetaObject->indexOfClassInfo("RegisterEnumClassesUnscoped");
+ if (indexOfClassInfo != -1 && QString::fromUtf8(d->baseMetaObject->classInfo(indexOfClassInfo).value()) == QLatin1String("false"))
+ d->extraData.cd->registerEnumClassesUnscoped = false;
+ }
}
QQmlType::QQmlType(QQmlMetaTypeData *data, const QString &elementName, const QQmlPrivate::RegisterCompositeType &type)
@@ -600,7 +632,7 @@ QQmlType QQmlType::resolveCompositeBaseType(QQmlEnginePrivate *engine) const
Q_ASSERT(isComposite());
if (!engine || !d)
return QQmlType();
- QQmlRefPointer<QQmlTypeData> td(engine->typeLoader.getType(sourceUrl()), QQmlRefPointer<QQmlTypeData>::Adopt);
+ QQmlRefPointer<QQmlTypeData> td(engine->typeLoader.getType(sourceUrl()));
if (td.isNull() || !td->isComplete())
return QQmlType();
QV4::CompiledData::CompilationUnit *compilationUnit = td->compilationUnit();
@@ -614,11 +646,11 @@ QQmlPropertyCache *QQmlType::compositePropertyCache(QQmlEnginePrivate *engine) c
Q_ASSERT(isComposite());
if (!engine)
return nullptr;
- QQmlRefPointer<QQmlTypeData> td(engine->typeLoader.getType(sourceUrl()), QQmlRefPointer<QQmlTypeData>::Adopt);
+ QQmlRefPointer<QQmlTypeData> td(engine->typeLoader.getType(sourceUrl()));
if (td.isNull() || !td->isComplete())
return nullptr;
QV4::CompiledData::CompilationUnit *compilationUnit = td->compilationUnit();
- return compilationUnit->rootPropertyCache();
+ return compilationUnit->rootPropertyCache().data();
}
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
@@ -808,7 +840,7 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const
{
// Add any enum values defined by 'related' classes
if (metaObject->d.relatedMetaObjects) {
- const QMetaObject * const *related = metaObject->d.relatedMetaObjects;
+ const auto *related = metaObject->d.relatedMetaObjects;
if (related) {
while (*related)
insertEnums(*related++);
@@ -824,7 +856,13 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const
for (int jj = 0; jj < e.keyCount(); ++jj) {
const QString key = QString::fromUtf8(e.key(jj));
const int value = e.value(jj);
- enums.insert(key, value);
+ if (!isScoped || (regType == QQmlType::CppType && extraData.cd->registerEnumClassesUnscoped)) {
+ if (enums.contains(key)) {
+ qWarning("Previously registered enum will be overwritten due to name clash: %s.%s", metaObject->className(), key.toUtf8().constData());
+ createEnumConflictReport(metaObject, key);
+ }
+ enums.insert(key, value);
+ }
if (isScoped)
scoped->insert(key, value);
}
@@ -836,6 +874,59 @@ void QQmlTypePrivate::insertEnums(const QMetaObject *metaObject) const
}
}
+void QQmlTypePrivate::createListOfPossibleConflictingItems(const QMetaObject *metaObject, QList<EnumInfo> &enumInfoList, QStringList path) const
+{
+ path.append(QString::fromUtf8(metaObject->className()));
+
+ if (metaObject->d.relatedMetaObjects) {
+ const auto *related = metaObject->d.relatedMetaObjects;
+ if (related) {
+ while (*related)
+ createListOfPossibleConflictingItems(*related++, enumInfoList, path);
+ }
+ }
+
+ for (int ii = 0; ii < metaObject->enumeratorCount(); ++ii) {
+ const auto e = metaObject->enumerator(ii);
+
+ for (int jj = 0; jj < e.keyCount(); ++jj) {
+ const QString key = QString::fromUtf8(e.key(jj));
+
+ EnumInfo enumInfo;
+ enumInfo.metaObjectName = QString::fromUtf8(metaObject->className());
+ enumInfo.enumName = QString::fromUtf8(e.name());
+ enumInfo.enumKey = key;
+ enumInfo.scoped = e.isScoped();
+ enumInfo.path = path;
+ enumInfo.metaEnumScope = QString::fromUtf8(e.scope());
+ enumInfoList.append(enumInfo);
+ }
+ }
+}
+
+void QQmlTypePrivate::createEnumConflictReport(const QMetaObject *metaObject, const QString &conflictingKey) const
+{
+ QList<EnumInfo> enumInfoList;
+
+ if (baseMetaObject) // prefer baseMetaObject if available
+ metaObject = baseMetaObject;
+
+ if (!metaObject) { // If there is no metaObject at all return early
+ qWarning() << "No meta object information available. Skipping conflict analysis.";
+ return;
+ }
+
+ createListOfPossibleConflictingItems(metaObject, enumInfoList, QStringList());
+
+ qWarning().noquote() << QLatin1String("Possible conflicting items:");
+ // find items with conflicting key
+ for (const auto i : enumInfoList) {
+ if (i.enumKey == conflictingKey)
+ qWarning().noquote().nospace() << " " << i.metaObjectName << "." << i.enumName << "." << i.enumKey << " from scope "
+ << i.metaEnumScope << " injected by " << i.path.join(QLatin1String("->"));
+ }
+}
+
void QQmlTypePrivate::insertEnumsFromPropertyCache(const QQmlPropertyCache *cache) const
{
const QMetaObject *cppMetaObject = cache->firstCppMetaObject();
@@ -865,7 +956,7 @@ QQmlPropertyCache *QQmlTypePrivate::propertyCacheForMinorVersion(int minorVersio
{
for (int i = 0; i < propertyCaches.count(); ++i)
if (propertyCaches.at(i).minorVersion == minorVersion)
- return propertyCaches.at(i).cache;
+ return propertyCaches.at(i).cache.data();
return nullptr;
}
@@ -1877,6 +1968,23 @@ void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
p->maxMinorVersion = qMax(p->maxMinorVersion, versionMinor);
}
+//From qqml.h
+int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QMutexLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), versionMajor, data);
+ if (!module)
+ return -1;
+
+ QQmlType type = module->type(QHashedStringRef(QString::fromUtf8(qmlName)), versionMinor);
+ if (!type.isValid())
+ return -1;
+
+ return type.index();
+}
+
bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri, int majorVersion)
{
const QQmlMetaTypeData *data = metaTypeData();
@@ -2248,19 +2356,25 @@ QQmlType QQmlMetaType::qmlType(const QMetaObject *metaObject, const QHashedStrin
}
/*!
- Returns the type (if any) that corresponds to the QVariant::Type \a userType.
- Returns null if no type is registered.
+ Returns the type (if any) that corresponds to \a typeId. Depending on \a category, the
+ \a typeId is interpreted either as QVariant::Type or as QML type id returned by one of the
+ qml type registration functions. Returns null if no type is registered.
*/
-QQmlType QQmlMetaType::qmlType(int userType)
+QQmlType QQmlMetaType::qmlType(int typeId, TypeIdCategory category)
{
QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
- QQmlTypePrivate *type = data->idToType.value(userType);
- if (type && type->typeId == userType)
- return QQmlType(type);
- else
- return QQmlType();
+ if (category == TypeIdCategory::MetaType) {
+ QQmlTypePrivate *type = data->idToType.value(typeId);
+ if (type && type->typeId == typeId)
+ return QQmlType(type);
+ } else if (category == TypeIdCategory::QmlType) {
+ QQmlType type = data->types.value(typeId);
+ if (type.isValid())
+ return type;
+ }
+ return QQmlType();
}
/*!
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index bcaf62d6ba..4a5e4ba266 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -91,11 +91,16 @@ public:
static QList<QQmlType> qmlSingletonTypes();
static QList<QQmlType> qmlAllTypes();
+ enum class TypeIdCategory {
+ MetaType,
+ QmlType
+ };
+
static QQmlType qmlType(const QString &qualifiedName, int, int);
static QQmlType qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int, int);
static QQmlType qmlType(const QMetaObject *);
static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor);
- static QQmlType qmlType(int);
+ static QQmlType qmlType(int typeId, TypeIdCategory category = TypeIdCategory::MetaType);
static QQmlType qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports = false);
static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
index 1680253d73..c14a91c1fa 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
@@ -80,8 +80,6 @@ QT_BEGIN_NAMESPACE
For more information about signals and threads, see
\l {Threads and QObjects} and \l {Signals and Slots Across Threads}.
- The \l {Qt Quick 1} version of this class is named QDeclarativeNetworkAccessManagerFactory.
-
\sa {C++ Extensions: Network Access Manager Factory Example}{Network Access Manager Factory Example}
*/
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 5aaf79c9e5..c181d791f5 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -71,7 +71,7 @@ struct ActiveOCRestorer
};
}
-QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext,
+QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlContextData *creationContext,
QQmlIncubatorPrivate *incubator)
: phase(Startup)
, compilationUnit(compilationUnit)
@@ -99,7 +99,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil
}
}
-QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState)
+QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState)
: phase(Startup)
, compilationUnit(compilationUnit)
, resolvedTypes(compilationUnit->resolvedTypes)
@@ -120,7 +120,7 @@ void QQmlObjectCreator::init(QQmlContextData *providedParentContext)
if (compilationUnit && !compilationUnit->engine)
compilationUnit->linkToEngine(v4);
- qmlUnit = compilationUnit->data;
+ qmlUnit = compilationUnit->unitData();
context = nullptr;
_qobject = nullptr;
_scopeObject = nullptr;
@@ -166,7 +166,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
if (subComponentIndex == -1) {
objectToCreate = /*root object*/0;
} else {
- const QV4::CompiledData::Object *compObj = qmlUnit->objectAt(subComponentIndex);
+ const QV4::CompiledData::Object *compObj = compilationUnit->objectAt(subComponentIndex);
objectToCreate = compObj->bindingTable()->value.objectIndex;
}
@@ -193,8 +193,8 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
context->importedScripts.set(v4, scripts);
QV4::ScopedValue v(scope);
for (int i = 0; i < compilationUnit->dependentScripts.count(); ++i) {
- QQmlScriptData *s = compilationUnit->dependentScripts.at(i);
- scripts->putIndexed(i, (v = s->scriptValueForContext(context)));
+ QQmlRefPointer<QQmlScriptData> s = compilationUnit->dependentScripts.at(i);
+ scripts->put(i, (v = s->scriptValueForContext(context)));
}
} else if (sharedState->creationContext) {
context->importedScripts = sharedState->creationContext->importedScripts;
@@ -252,7 +252,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance, QQmlData::
Q_ASSERT(!sharedState->allJavaScriptObjects);
sharedState->allJavaScriptObjects = valueScope.alloc(compilationUnit->totalObjectCount);
- QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1));
+ QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc());
qSwap(_qmlContext, qmlContext);
@@ -262,7 +262,7 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance, QQmlData::
int objectIndex = deferredData->deferredIdx;
qSwap(_compiledObjectIndex, objectIndex);
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(_compiledObjectIndex);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(_compiledObjectIndex);
qSwap(_compiledObject, obj);
qSwap(_ddata, declarativeData);
@@ -312,7 +312,7 @@ bool QQmlObjectCreator::populateDeferredBinding(const QQmlProperty &qmlProperty,
if (!sharedState->allJavaScriptObjects)
sharedState->allJavaScriptObjects = valueScope.alloc(compilationUnit->totalObjectCount);
- QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1));
+ QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc());
qSwap(_qmlContext, qmlContext);
@@ -322,7 +322,7 @@ bool QQmlObjectCreator::populateDeferredBinding(const QQmlProperty &qmlProperty,
int objectIndex = deferredData->deferredIdx;
qSwap(_compiledObjectIndex, objectIndex);
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(_compiledObjectIndex);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(_compiledObjectIndex);
qSwap(_compiledObject, obj);
qSwap(_ddata, declarativeData);
@@ -373,7 +373,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
propertyType = QMetaType::Int;
} else {
// ### This should be resolved earlier at compile time and the binding value should be changed accordingly.
- QVariant value = binding->valueAsString(qmlUnit);
+ QVariant value = binding->valueAsString(compilationUnit.data());
bool ok = QQmlPropertyPrivate::write(_qobject, *property, value, context);
Q_ASSERT(ok);
Q_UNUSED(ok);
@@ -384,10 +384,10 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
switch (propertyType) {
case QMetaType::QVariant: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
- double n = binding->valueAsNumber();
+ double n = binding->valueAsNumber(compilationUnit->constants);
if (double(int(n)) == n) {
if (property->isVarProperty()) {
- _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromInt32(int(n)));
+ _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Value::fromInt32(int(n)));
} else {
int i = int(n);
QVariant value(i);
@@ -395,7 +395,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
} else {
if (property->isVarProperty()) {
- _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromDouble(n));
+ _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Value::fromDouble(n));
} else {
QVariant value(n);
property->writeProperty(_qobject, &value, propertyWriteFlags);
@@ -403,13 +403,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
} else if (binding->type == QV4::CompiledData::Binding::Type_Boolean) {
if (property->isVarProperty()) {
- _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Primitive::fromBoolean(binding->valueAsBoolean()));
+ _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Value::fromBoolean(binding->valueAsBoolean()));
} else {
QVariant value(binding->valueAsBoolean());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
} else {
- QString stringValue = binding->valueAsString(qmlUnit);
+ QString stringValue = binding->valueAsString(compilationUnit.data());
if (property->isVarProperty()) {
QV4::ScopedString s(scope, v4->newString(stringValue));
_vmeMetaObject->setVMEProperty(property->coreIndex(), s);
@@ -422,25 +422,25 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
case QVariant::String: {
Q_ASSERT(binding->evaluatesToString());
- QString value = binding->valueAsString(qmlUnit);
+ QString value = binding->valueAsString(compilationUnit.data());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::StringList: {
Q_ASSERT(binding->evaluatesToString());
- QStringList value(binding->valueAsString(qmlUnit));
+ QStringList value(binding->valueAsString(compilationUnit.data()));
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::ByteArray: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
- QByteArray value(binding->valueAsString(qmlUnit).toUtf8());
+ QByteArray value(binding->valueAsString(compilationUnit.data()).toUtf8());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Url: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
- QString string = binding->valueAsString(qmlUnit);
+ QString string = binding->valueAsString(compilationUnit.data());
// Encoded dir-separators defeat QUrl processing - decode them first
string.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive);
QUrl value = string.isEmpty() ? QUrl() : compilationUnit->finalUrl().resolved(QUrl(string));
@@ -452,7 +452,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
case QVariant::UInt: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
- double d = binding->valueAsNumber();
+ double d = binding->valueAsNumber(compilationUnit->constants);
uint value = uint(d);
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
@@ -460,7 +460,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
case QVariant::Int: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
- double d = binding->valueAsNumber();
+ double d = binding->valueAsNumber(compilationUnit->constants);
int value = int(d);
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
@@ -468,19 +468,19 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
case QMetaType::Float: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
- float value = float(binding->valueAsNumber());
+ float value = float(binding->valueAsNumber(compilationUnit->constants));
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Double: {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
- double value = binding->valueAsNumber();
+ double value = binding->valueAsNumber(compilationUnit->constants);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Color: {
bool ok = false;
- uint colorValue = QQmlStringConverters::rgbaFromString(binding->valueAsString(qmlUnit), &ok);
+ uint colorValue = QQmlStringConverters::rgbaFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
struct { void *data[4]; } buffer;
if (QQml_valueTypeProvider()->storeValueType(property->propType(), &colorValue, &buffer, sizeof(buffer))) {
@@ -491,21 +491,21 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
#if QT_CONFIG(datestring)
case QVariant::Date: {
bool ok = false;
- QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok);
+ QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Time: {
bool ok = false;
- QTime value = QQmlStringConverters::timeFromString(binding->valueAsString(qmlUnit), &ok);
+ QTime value = QQmlStringConverters::timeFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::DateTime: {
bool ok = false;
- QDateTime value = QQmlStringConverters::dateTimeFromString(binding->valueAsString(qmlUnit), &ok);
+ QDateTime value = QQmlStringConverters::dateTimeFromString(binding->valueAsString(compilationUnit.data()), &ok);
// ### VME compatibility :(
{
const qint64 date = value.date().toJulianDay();
@@ -519,42 +519,42 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
#endif // datestring
case QVariant::Point: {
bool ok = false;
- QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok).toPoint();
+ QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok).toPoint();
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::PointF: {
bool ok = false;
- QPointF value = QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok);
+ QPointF value = QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Size: {
bool ok = false;
- QSize value = QQmlStringConverters::sizeFFromString(binding->valueAsString(qmlUnit), &ok).toSize();
+ QSize value = QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok).toSize();
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::SizeF: {
bool ok = false;
- QSizeF value = QQmlStringConverters::sizeFFromString(binding->valueAsString(qmlUnit), &ok);
+ QSizeF value = QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Rect: {
bool ok = false;
- QRect value = QQmlStringConverters::rectFFromString(binding->valueAsString(qmlUnit), &ok).toRect();
+ QRect value = QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok).toRect();
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::RectF: {
bool ok = false;
- QRectF value = QQmlStringConverters::rectFFromString(binding->valueAsString(qmlUnit), &ok);
+ QRectF value = QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
Q_ASSERT(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
@@ -570,7 +570,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float xp;
float yp;
} vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(qmlUnit), &vec, sizeof(vec));
+ bool ok = QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
Q_ASSERT(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
@@ -582,7 +582,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float yp;
float zy;
} vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(qmlUnit), &vec, sizeof(vec));
+ bool ok = QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
Q_ASSERT(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
@@ -595,7 +595,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float zy;
float wp;
} vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(qmlUnit), &vec, sizeof(vec));
+ bool ok = QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
Q_ASSERT(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
@@ -608,7 +608,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float yp;
float zp;
} vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(qmlUnit), &vec, sizeof(vec));
+ bool ok = QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
Q_ASSERT(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
@@ -622,12 +622,12 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
if (property->propType() == qMetaTypeId<QList<qreal> >()) {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
QList<qreal> value;
- value.append(binding->valueAsNumber());
+ value.append(binding->valueAsNumber(compilationUnit->constants));
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QList<int> >()) {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
- double n = binding->valueAsNumber();
+ double n = binding->valueAsNumber(compilationUnit->constants);
QList<int> value;
value.append(int(n));
property->writeProperty(_qobject, &value, propertyWriteFlags);
@@ -640,7 +640,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
break;
} else if (property->propType() == qMetaTypeId<QList<QUrl> >()) {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
- QString urlString = binding->valueAsString(qmlUnit);
+ QString urlString = binding->valueAsString(compilationUnit.data());
QUrl u = urlString.isEmpty() ? QUrl()
: compilationUnit->finalUrl().resolved(QUrl(urlString));
QList<QUrl> value;
@@ -650,7 +650,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
} else if (property->propType() == qMetaTypeId<QList<QString> >()) {
Q_ASSERT(binding->evaluatesToString());
QList<QString> value;
- value.append(binding->valueAsString(qmlUnit));
+ value.append(binding->valueAsString(compilationUnit.data()));
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QJSValue>()) {
@@ -658,20 +658,20 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
if (binding->type == QV4::CompiledData::Binding::Type_Boolean) {
value = QJSValue(binding->valueAsBoolean());
} else if (binding->type == QV4::CompiledData::Binding::Type_Number) {
- double n = binding->valueAsNumber();
+ double n = binding->valueAsNumber(compilationUnit->constants);
if (double(int(n)) == n) {
value = QJSValue(int(n));
} else
value = QJSValue(n);
} else {
- value = QJSValue(binding->valueAsString(qmlUnit));
+ value = QJSValue(binding->valueAsString(compilationUnit.data()));
}
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
}
// otherwise, try a custom type assignment
- QString stringValue = binding->valueAsString(qmlUnit);
+ QString stringValue = binding->valueAsString(compilationUnit.data());
QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType());
Q_ASSERT(converter);
QVariant value = (*converter)(stringValue);
@@ -784,7 +784,7 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings)
bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProperty, const QV4::CompiledData::Binding *binding)
{
if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
- Q_ASSERT(stringAt(qmlUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex).isEmpty());
+ Q_ASSERT(stringAt(compilationUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex).isEmpty());
QV4::CompiledData::ResolvedTypeReference *tr = resolvedTypes.value(binding->propertyNameIndex);
Q_ASSERT(tr);
QQmlType attachedType = tr->type;
@@ -804,13 +804,13 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
// ### resolve this at compile time
if (bindingProperty && bindingProperty->propType() == qMetaTypeId<QQmlScriptString>()) {
- QQmlScriptString ss(binding->valueAsScriptString(qmlUnit), context->asQQmlContext(), _scopeObject);
+ QQmlScriptString ss(binding->valueAsScriptString(compilationUnit.data()), context->asQQmlContext(), _scopeObject);
ss.d.data()->bindingId = binding->type == QV4::CompiledData::Binding::Type_Script ? binding->value.compiledScriptIndex : (quint32)QQmlBinding::Invalid;
ss.d.data()->lineNumber = binding->location.line;
ss.d.data()->columnNumber = binding->location.column;
ss.d.data()->isStringLiteral = binding->type == QV4::CompiledData::Binding::Type_String;
ss.d.data()->isNumberLiteral = binding->type == QV4::CompiledData::Binding::Type_Number;
- ss.d.data()->numberValue = binding->valueAsNumber();
+ ss.d.data()->numberValue = binding->valueAsNumber(compilationUnit->constants);
QQmlPropertyData::WriteFlags propertyWriteFlags = QQmlPropertyData::BypassInterceptor |
QQmlPropertyData::RemoveBindingOnAliasWrite;
@@ -831,7 +831,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
return true;
if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty) {
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(binding->value.objectIndex);
if (stringAt(obj->inheritedTypeNameIndex).isEmpty()) {
QObject *groupObject = nullptr;
@@ -876,7 +876,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
&& !_valueTypeProperty)
QQmlPropertyPrivate::removeBinding(_bindingTarget, QQmlPropertyIndex(bindingProperty->coreIndex()));
- if (binding->type == QV4::CompiledData::Binding::Type_Script || binding->containsTranslations()) {
+ if (binding->type == QV4::CompiledData::Binding::Type_Script || binding->isTranslationBinding()) {
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
int signalIndex = _propertyCache->methodIndexToSignalIndex(bindingProperty->coreIndex());
@@ -898,7 +898,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
targetProperty = _valueTypeProperty;
subprop = bindingProperty;
}
- if (binding->containsTranslations()) {
+ if (binding->isTranslationBinding()) {
qmlBinding = QQmlBinding::createTranslationBinding(compilationUnit, binding, _scopeObject, context);
} else {
QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
@@ -1130,7 +1130,7 @@ void QQmlObjectCreator::createQmlContext()
QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isContextObject)
{
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(index);
QQmlObjectCreationProfiler profiler(sharedState->profiler.profiler, obj);
ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine));
@@ -1144,9 +1144,9 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
if (obj->flags & QV4::CompiledData::Object::IsComponent) {
isComponent = true;
- QQmlComponent *component = new QQmlComponent(engine, compilationUnit, index, parent);
+ QQmlComponent *component = new QQmlComponent(engine, compilationUnit.data(), index, parent);
Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(
- compilationUnit, obj, QStringLiteral("<component>"), context->url()));
+ compilationUnit.data(), obj, QStringLiteral("<component>"), context->url()));
QQmlComponentPrivate::get(component)->creationContext = context;
instance = component;
ddata = QQmlData::get(instance, /*create*/true);
@@ -1157,7 +1157,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
QQmlType type = typeRef->type;
if (type.isValid()) {
Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(
- compilationUnit, obj, type.qmlTypeName(), context->url()));
+ compilationUnit.data(), obj, type.qmlTypeName(), context->url()));
void *ddataMemory = nullptr;
type.create(&instance, &ddataMemory, sizeof(QQmlData));
@@ -1190,9 +1190,9 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
} else {
Q_ASSERT(typeRef->compilationUnit);
Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(
- compilationUnit, obj, typeRef->compilationUnit->fileName(),
- context->url()));
- if (typeRef->compilationUnit->data->isSingleton())
+ compilationUnit.data(), obj, typeRef->compilationUnit->fileName(),
+ context->url()));
+ if (typeRef->compilationUnit->unitData()->isSingleton())
{
recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex)));
return nullptr;
@@ -1254,17 +1254,17 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
if (customParser && obj->flags & QV4::CompiledData::Object::HasCustomParserBindings) {
customParser->engine = QQmlEnginePrivate::get(engine);
- customParser->imports = compilationUnit->typeNameCache;
+ customParser->imports = compilationUnit->typeNameCache.data();
QList<const QV4::CompiledData::Binding *> bindings;
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(index);
const QV4::CompiledData::Binding *binding = obj->bindingTable();
for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) {
if (binding->flags & QV4::CompiledData::Binding::IsCustomParserBinding) {
bindings << binding;
}
}
- customParser->applyBindings(instance, compilationUnit, bindings);
+ customParser->applyBindings(instance, compilationUnit.data(), bindings);
customParser->engine = nullptr;
customParser->imports = (QQmlTypeNameCache*)nullptr;
@@ -1280,7 +1280,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
if (installPropertyCache) {
if (ddata->propertyCache)
ddata->propertyCache->release();;
- ddata->propertyCache = cache;
+ ddata->propertyCache = cache.data();
ddata->propertyCache->addref();
}
@@ -1292,7 +1292,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
++sharedState->allJavaScriptObjects;
QV4::Scope valueScope(v4);
- QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc(1));
+ QV4::QmlContext *qmlContext = static_cast<QV4::QmlContext *>(valueScope.alloc());
qSwap(_qmlContext, qmlContext);
@@ -1344,6 +1344,11 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru
data->clearPendingBindingBit(b->targetPropertyIndex().coreIndex());
b->setEnabled(true, QQmlPropertyData::BypassInterceptor |
QQmlPropertyData::DontRemoveBinding);
+ if (!b->isValueTypeProxy()) {
+ QQmlBinding *binding = static_cast<QQmlBinding*>(b.data());
+ if (!binding->hasError() && !binding->hasDependencies())
+ b->removeFromObject();
+ }
if (watcher.hasRecursed() || interrupt.shouldInterrupt())
return nullptr;
@@ -1419,7 +1424,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
qSwap(_qobject, instance);
qSwap(_valueTypeProperty, valueTypeProperty);
qSwap(_compiledObjectIndex, index);
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(_compiledObjectIndex);
+ const QV4::CompiledData::Object *obj = compilationUnit->objectAt(_compiledObjectIndex);
qSwap(_compiledObject, obj);
qSwap(_ddata, declarativeData);
qSwap(_bindingTarget, bindingTarget);
@@ -1436,7 +1441,7 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
vmeMetaObject = new QQmlVMEMetaObject(v4, _qobject, cache, compilationUnit, _compiledObjectIndex);
if (_ddata->propertyCache)
_ddata->propertyCache->release();
- _ddata->propertyCache = cache;
+ _ddata->propertyCache = cache.data();
_ddata->propertyCache->addref();
scopeObjectProtector = _ddata->jsWrapper.value();
} else {
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 67a5bdd827..020e673941 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -85,7 +85,7 @@ class Q_QML_PRIVATE_EXPORT QQmlObjectCreator
{
Q_DECLARE_TR_FUNCTIONS(QQmlObjectCreator)
public:
- QQmlObjectCreator(QQmlContextData *parentContext, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = nullptr);
+ QQmlObjectCreator(QQmlContextData *parentContext, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlContextData *creationContext, QQmlIncubatorPrivate *incubator = nullptr);
~QQmlObjectCreator();
QObject *create(int subComponentIndex = -1, QObject *parent = nullptr, QQmlInstantiationInterrupt *interrupt = nullptr);
@@ -104,7 +104,7 @@ public:
QFiniteStack<QPointer<QObject> > &allCreatedObjects() const { return sharedState->allCreatedObjects; }
private:
- QQmlObjectCreator(QQmlContextData *contextData, QV4::CompiledData::CompilationUnit *compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState);
+ QQmlObjectCreator(QQmlContextData *contextData, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, QQmlObjectCreatorSharedState *inheritedSharedState);
void init(QQmlContextData *parentContext);
@@ -118,7 +118,7 @@ private:
void setPropertyValue(const QQmlPropertyData *property, const QV4::CompiledData::Binding *binding);
void setupFunctions();
- QString stringAt(int idx) const { return qmlUnit->stringAt(idx); }
+ QString stringAt(int idx) const { return compilationUnit->stringAt(idx); }
void recordError(const QV4::CompiledData::Location &location, const QString &description);
void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const;
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
index 1b44bbdda3..fc798a2c23 100644
--- a/src/qml/qml/qqmlopenmetaobject.cpp
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -181,46 +181,75 @@ void QQmlOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
class QQmlOpenMetaObjectPrivate
{
public:
- QQmlOpenMetaObjectPrivate(QQmlOpenMetaObject *_q)
- : q(_q), parent(nullptr), type(nullptr), cacheProperties(false) {}
+ QQmlOpenMetaObjectPrivate(QQmlOpenMetaObject *_q, bool _autoCreate, QObject *obj)
+ : q(_q), object(obj), autoCreate(_autoCreate) {}
+
+ struct Property {
+ private:
+ QVariant m_value;
+ QPointer<QObject> qobjectTracker;
+ public:
+ bool valueSet = false;
+
+ QVariant value() const {
+ if (QMetaType::typeFlags(m_value.userType()) & QMetaType::PointerToQObject
+ && qobjectTracker.isNull())
+ return QVariant::fromValue<QObject*>(nullptr);
+ return m_value;
+ }
+ QVariant &valueRef() { return m_value; }
+ void setValue(const QVariant &v) {
+ m_value = v;
+ valueSet = true;
+ if (QMetaType::typeFlags(v.userType()) & QMetaType::PointerToQObject)
+ qobjectTracker = m_value.value<QObject*>();
+ }
+ };
- inline QPair<QVariant, bool> &getDataRef(int idx) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- return data[idx];
+ inline void setPropertyValue(int idx, const QVariant &value) {
+ if (data.count() <= idx)
+ data.resize(idx + 1);
+ data[idx].setValue(value);
}
- inline QVariant &getData(int idx) {
- QPair<QVariant, bool> &prop = getDataRef(idx);
- if (!prop.second) {
- prop.first = q->initialValue(idx);
- prop.second = true;
- }
- return prop.first;
+ inline Property &propertyRef(int idx) {
+ if (data.count() <= idx)
+ data.resize(idx + 1);
+ Property &prop = data[idx];
+ if (!prop.valueSet)
+ prop.setValue(q->initialValue(idx));
+ return prop;
+ }
+
+ inline QVariant propertyValue(int idx) {
+ auto &prop = propertyRef(idx);
+ return prop.value();
+ }
+
+ inline QVariant &propertyValueRef(int idx) {
+ auto &prop = propertyRef(idx);
+ return prop.valueRef();
}
- inline bool hasData(int idx) const {
+ inline bool hasProperty(int idx) const {
if (idx >= data.count())
return false;
- return data[idx].second;
+ return data[idx].valueSet;
}
- bool autoCreate;
QQmlOpenMetaObject *q;
- QAbstractDynamicMetaObject *parent;
- QList<QPair<QVariant, bool> > data;
+ QAbstractDynamicMetaObject *parent = nullptr;
+ QVector<Property> data;
QObject *object;
- QQmlOpenMetaObjectType *type;
- bool cacheProperties;
+ QQmlRefPointer<QQmlOpenMetaObjectType> type;
+ bool autoCreate;
+ bool cacheProperties = false;
};
QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, const QMetaObject *base, bool automatic)
-: d(new QQmlOpenMetaObjectPrivate(this))
+: d(new QQmlOpenMetaObjectPrivate(this, automatic, obj))
{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = new QQmlOpenMetaObjectType(base ? base : obj->metaObject(), nullptr);
+ d->type.adopt(new QQmlOpenMetaObjectType(base ? base : obj->metaObject(), nullptr));
d->type->d->referers.insert(this);
QObjectPrivate *op = QObjectPrivate::get(obj);
@@ -230,13 +259,9 @@ QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, const QMetaObject *base, bo
}
QQmlOpenMetaObject::QQmlOpenMetaObject(QObject *obj, QQmlOpenMetaObjectType *type, bool automatic)
-: d(new QQmlOpenMetaObjectPrivate(this))
+: d(new QQmlOpenMetaObjectPrivate(this, automatic, obj))
{
- d->autoCreate = automatic;
- d->object = obj;
-
d->type = type;
- d->type->addref();
d->type->d->referers.insert(this);
QObjectPrivate *op = QObjectPrivate::get(obj);
@@ -250,13 +275,12 @@ QQmlOpenMetaObject::~QQmlOpenMetaObject()
if (d->parent)
delete d->parent;
d->type->d->referers.remove(this);
- d->type->release();
delete d;
}
QQmlOpenMetaObjectType *QQmlOpenMetaObject::type() const
{
- return d->type;
+ return d->type.data();
}
void QQmlOpenMetaObject::emitPropertyNotification(const QByteArray &propertyName)
@@ -276,13 +300,11 @@ int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void *
int propId = id - d->type->d->propertyOffset;
if (c == QMetaObject::ReadProperty) {
propertyRead(propId);
- *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
+ *reinterpret_cast<QVariant *>(a[0]) = d->propertyValue(propId);
} else if (c == QMetaObject::WriteProperty) {
- if (propId >= d->data.count() || d->data.at(propId).first != *reinterpret_cast<QVariant *>(a[0])) {
+ if (propId >= d->data.count() || d->data.at(propId).value() != *reinterpret_cast<QVariant *>(a[0])) {
propertyWrite(propId);
- QPair<QVariant, bool> &prop = d->getDataRef(propId);
- prop.first = propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0]));
- prop.second = true;
+ d->setPropertyValue(propId, propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0])));
propertyWritten(propId);
activate(o, d->type->d->signalOffset + propId, nullptr);
}
@@ -303,14 +325,12 @@ QAbstractDynamicMetaObject *QQmlOpenMetaObject::parent() const
QVariant QQmlOpenMetaObject::value(int id) const
{
- return d->getData(id);
+ return d->propertyValue(id);
}
void QQmlOpenMetaObject::setValue(int id, const QVariant &value)
{
- QPair<QVariant, bool> &prop = d->getDataRef(id);
- prop.first = propertyWriteValue(id, value);
- prop.second = true;
+ d->setPropertyValue(id, propertyWriteValue(id, value));
activate(d->object, id + d->type->d->signalOffset, nullptr);
}
@@ -320,23 +340,18 @@ QVariant QQmlOpenMetaObject::value(const QByteArray &name) const
if (iter == d->type->d->names.cend())
return QVariant();
- return d->getData(*iter);
+ return d->propertyValue(*iter);
}
-QVariant &QQmlOpenMetaObject::operator[](const QByteArray &name)
+QVariant &QQmlOpenMetaObject::valueRef(const QByteArray &name)
{
QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.constFind(name);
Q_ASSERT(iter != d->type->d->names.cend());
- return d->getData(*iter);
-}
-
-QVariant &QQmlOpenMetaObject::operator[](int id)
-{
- return d->getData(id);
+ return d->propertyValueRef(*iter);
}
-bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
+bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val, bool force)
{
QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.constFind(name);
@@ -348,11 +363,10 @@ bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
}
if (id >= 0) {
- QVariant &dataVal = d->getData(id);
- if (dataVal == val)
+ if (!force && d->propertyValue(id) == val)
return false;
- dataVal = val;
+ d->setPropertyValue(id, val);
activate(d->object, id + d->type->d->signalOffset, nullptr);
return true;
}
@@ -363,7 +377,7 @@ bool QQmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
// returns true if this value has been initialized by a call to either value() or setValue()
bool QQmlOpenMetaObject::hasValue(int id) const
{
- return d->hasData(id);
+ return d->hasProperty(id);
}
void QQmlOpenMetaObject::setCached(bool c)
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index 4905190b75..168a2a6f7f 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -100,11 +100,10 @@ public:
~QQmlOpenMetaObject() override;
QVariant value(const QByteArray &) const;
- bool setValue(const QByteArray &, const QVariant &);
+ bool setValue(const QByteArray &, const QVariant &, bool force = false);
QVariant value(int) const;
void setValue(int, const QVariant &);
- QVariant &operator[](const QByteArray &);
- QVariant &operator[](int);
+ QVariant &valueRef(const QByteArray &);
bool hasValue(int) const;
int count() const;
diff --git a/src/qml/qml/qqmlparserstatus.cpp b/src/qml/qml/qqmlparserstatus.cpp
index 1082c318cb..b8f4bb8c19 100644
--- a/src/qml/qml/qqmlparserstatus.cpp
+++ b/src/qml/qml/qqmlparserstatus.cpp
@@ -81,8 +81,6 @@ QT_BEGIN_NAMESPACE
void componentComplete();
}
\endcode
-
- The \l {Qt Quick 1} version of this class is named QDeclarativeParserStatus.
*/
/*! \internal */
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
index fabdcacc36..22e46fd7ed 100644
--- a/src/qml/qml/qqmlprivate.h
+++ b/src/qml/qml/qqmlprivate.h
@@ -95,12 +95,20 @@ namespace QQmlPrivate
{
void Q_QML_EXPORT qdeclarativeelement_destructor(QObject *);
template<typename T>
- class QQmlElement : public T
+ class QQmlElement final : public T
{
public:
~QQmlElement() override {
QQmlPrivate::qdeclarativeelement_destructor(this);
}
+ static void operator delete(void *ptr) {
+ // We allocate memory from this class in QQmlType::create
+ // along with some additional memory.
+ // So we override the operator delete in order to avoid the
+ // sized operator delete to be called with a different size than
+ // the size that was allocated.
+ ::operator delete (ptr);
+ }
};
template<typename T>
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index c4487f91a3..000b88ebaa 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -111,8 +111,6 @@ qWarning() << "Current pixel size:" << property.read().toInt();
property.write(24);
qWarning() << "Pixel size should now be 24:" << property.read().toInt();
\endcode
-
-The \l {Qt Quick 1} version of this class was named QDeclarativeProperty.
*/
/*!
@@ -255,7 +253,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
{
if (!obj) return;
- QQmlTypeNameCache *typeNameCache = context?context->imports:nullptr;
+ QQmlRefPointer<QQmlTypeNameCache> typeNameCache = context?context->imports:nullptr;
QObject *currentObject = obj;
QVector<QStringRef> path;
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 88eda9c020..0388215630 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -1360,19 +1360,21 @@ template <typename StringVisitor>
int visitEnumerations(const QMetaObject &mo, StringVisitor visitString)
{
const QMetaObjectPrivate *const priv = reinterpret_cast<const QMetaObjectPrivate*>(mo.d.data);
- const int intsPerEnumerator = 4;
+ const int intsPerEnumerator = priv->revision >= 8 ? 5 : 4;
int fieldCount = priv->enumeratorCount * intsPerEnumerator;
for (int i = 0; i < priv->enumeratorCount; ++i) {
const uint *enumeratorData = mo.d.data + priv->enumeratorData + i * intsPerEnumerator;
- const uint keyCount = enumeratorData[2];
+ const uint keyCount = enumeratorData[intsPerEnumerator == 5 ? 3 : 2];
fieldCount += keyCount * 2;
visitString(enumeratorData[0]); // name
+ if (intsPerEnumerator == 5)
+ visitString(enumeratorData[1]); // enum name
- const uint keyOffset = enumeratorData[3];
+ const uint keyOffset = enumeratorData[intsPerEnumerator == 5 ? 4 : 3];
for (uint j = 0; j < keyCount; ++j) {
visitString(mo.d.data[keyOffset + 2 * j]);
@@ -1412,7 +1414,7 @@ bool QQmlPropertyCache::determineMetaObjectSizes(const QMetaObject &mo, int *fie
int *stringCount)
{
const QMetaObjectPrivate *priv = reinterpret_cast<const QMetaObjectPrivate*>(mo.d.data);
- if (priv->revision != 7) {
+ if (priv->revision < 7 || priv->revision > 8) {
return false;
}
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index b78a2ddd20..0785910cec 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -979,13 +979,13 @@ public:
void append(QQmlPropertyCache *cache) { cache->addref(); data.append(cache); }
QQmlPropertyCache *at(int index) const { return data.at(index).data(); }
- void set(int index, QQmlPropertyCache *replacement) {
+ void set(int index, const QQmlRefPointer<QQmlPropertyCache> &replacement) {
if (QQmlPropertyCache *oldCache = data.at(index).data()) {
- if (replacement == oldCache)
+ if (replacement.data() == oldCache)
return;
oldCache->release();
}
- data[index] = replacement;
+ data[index] = replacement.data();
replacement->addref();
}
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index c656fac4ff..0b0c6242ba 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -51,7 +51,7 @@
#include <private/qqmltypecompiler_p.h>
#include <private/qqmlpropertyvalidator_p.h>
#include <private/qqmlpropertycachecreator_p.h>
-#include <private/qdeferredcleanup_p.h>
+#include <private/qv4module_p.h>
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
@@ -66,6 +66,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtQml/qqmlextensioninterface.h>
#include <QtCore/qcryptographichash.h>
+#include <QtCore/qscopeguard.h>
#include <functional>
@@ -504,11 +505,12 @@ void QQmlDataBlob::addDependency(QQmlDataBlob *blob)
if (!blob ||
blob->status() == Error || blob->status() == Complete ||
- status() == Error || status() == Complete || m_isDone ||
- m_waitingFor.contains(blob))
+ status() == Error || status() == Complete || m_isDone)
return;
- blob->addref();
+ for (auto existingDep: qAsConst(m_waitingFor))
+ if (existingDep.data() == blob)
+ return;
m_data.setStatus(WaitingForDependencies);
@@ -691,13 +693,11 @@ void QQmlDataBlob::tryDone()
void QQmlDataBlob::cancelAllWaitingFor()
{
while (m_waitingFor.count()) {
- QQmlDataBlob *blob = m_waitingFor.takeLast();
+ QQmlRefPointer<QQmlDataBlob> blob = m_waitingFor.takeLast();
Q_ASSERT(blob->m_waitingOnMe.contains(this));
blob->m_waitingOnMe.removeOne(this);
-
- blob->release();
}
}
@@ -706,7 +706,8 @@ void QQmlDataBlob::notifyAllWaitingOnMe()
while (m_waitingOnMe.count()) {
QQmlDataBlob *blob = m_waitingOnMe.takeLast();
- Q_ASSERT(blob->m_waitingFor.contains(this));
+ Q_ASSERT(std::any_of(blob->m_waitingFor.constBegin(), blob->m_waitingFor.constEnd(),
+ [this](const QQmlRefPointer<QQmlDataBlob> &waiting) { return waiting.data() == this; }));
blob->notifyComplete(this);
}
@@ -714,13 +715,19 @@ void QQmlDataBlob::notifyAllWaitingOnMe()
void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob)
{
- Q_ASSERT(m_waitingFor.contains(blob));
Q_ASSERT(blob->status() == Error || blob->status() == Complete);
QQmlCompilingProfiler prof(typeLoader()->profiler(), blob);
m_inCallback = true;
- m_waitingFor.removeOne(blob);
+ QQmlRefPointer<QQmlDataBlob> blobRef;
+ for (int i = 0; i < m_waitingFor.count(); ++i) {
+ if (m_waitingFor.at(i).data() == blob) {
+ blobRef = m_waitingFor.takeAt(i);
+ break;
+ }
+ }
+ Q_ASSERT(blobRef);
if (blob->status() == Error) {
dependencyError(blob);
@@ -728,8 +735,6 @@ void QQmlDataBlob::notifyComplete(QQmlDataBlob *blob)
dependencyComplete(blob);
}
- blob->release();
-
if (!isError() && m_waitingFor.isEmpty())
allDependenciesDone();
@@ -860,13 +865,23 @@ void QQmlTypeLoaderThread::loadWithCachedUnitAsync(QQmlDataBlob *b, const QV4::C
void QQmlTypeLoaderThread::callCompleted(QQmlDataBlob *b)
{
b->addref();
+#if !QT_CONFIG(thread)
+ if (!isThisThread())
+ postMethodToThread(&This::callCompletedMain, b);
+#else
postMethodToMain(&This::callCompletedMain, b);
+#endif
}
void QQmlTypeLoaderThread::callDownloadProgressChanged(QQmlDataBlob *b, qreal p)
{
b->addref();
+#if !QT_CONFIG(thread)
+ if (!isThisThread())
+ postMethodToThread(&This::callDownloadProgressChangedMain, b, p);
+#else
postMethodToMain(&This::callDownloadProgressChangedMain, b, p);
+#endif
}
void QQmlTypeLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
@@ -1170,7 +1185,10 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
}
#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
+
+#ifndef TYPELOADER_MINIMUM_TRIM_THRESHOLD
#define TYPELOADER_MINIMUM_TRIM_THRESHOLD 64
+#endif
#if QT_CONFIG(qml_network)
void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
@@ -1327,20 +1345,17 @@ QQmlTypeLoader::Blob::Blob(const QUrl &url, QQmlDataBlob::Type type, QQmlTypeLoa
QQmlTypeLoader::Blob::~Blob()
{
- for (int ii = 0; ii < m_qmldirs.count(); ++ii)
- m_qmldirs.at(ii)->release();
}
bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors)
{
- QQmlQmldirData *data = typeLoader()->getQmldir(url);
+ QQmlRefPointer<QQmlQmldirData> data = typeLoader()->getQmldir(url);
data->setImport(this, import);
data->setPriority(this, priority);
if (data->status() == Error) {
// This qmldir must not exist - which is not an error
- data->release();
return true;
} else if (data->status() == Complete) {
// This data is already available
@@ -1348,11 +1363,11 @@ bool QQmlTypeLoader::Blob::fetchQmldir(const QUrl &url, const QV4::CompiledData:
}
// Wait for this data to become available
- addDependency(data);
+ addDependency(data.data());
return true;
}
-bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors)
+bool QQmlTypeLoader::Blob::updateQmldir(const QQmlRefPointer<QQmlQmldirData> &data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors)
{
QString qmldirIdentifier = data->urlString();
QString qmldirUrl = qmldirIdentifier.left(qmldirIdentifier.lastIndexOf(QLatin1Char('/')) + 1);
@@ -1378,8 +1393,8 @@ bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::Compile
const auto qmldirScripts = qmldir.scripts();
for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
- QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
- addDependency(blob);
+ QQmlRefPointer<QQmlScriptBlob> blob = typeLoader()->getScript(scriptUrl);
+ addDependency(blob.data());
scriptImported(blob, import->location, script.nameSpace, importQualifier);
}
@@ -1398,8 +1413,8 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
const QString &importQualifier = stringAt(import->qualifierIndex);
if (import->type == QV4::CompiledData::Import::ImportScript) {
QUrl scriptUrl = finalUrl().resolved(QUrl(importUri));
- QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
- addDependency(blob);
+ QQmlRefPointer<QQmlScriptBlob> blob = typeLoader()->getScript(scriptUrl);
+ addDependency(blob.data());
scriptImported(blob, import->location, importQualifier, QString());
} else if (import->type == QV4::CompiledData::Import::ImportLibrary) {
@@ -1426,8 +1441,8 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
const auto qmldirScripts = qmldir.scripts();
for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
- QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
- addDependency(blob);
+ QQmlRefPointer<QQmlScriptBlob> blob = typeLoader()->getScript(scriptUrl);
+ addDependency(blob.data());
scriptImported(blob, import->location, script.nameSpace, importQualifier);
}
@@ -1499,14 +1514,6 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
return true;
}
-void QQmlTypeLoader::Blob::dependencyError(QQmlDataBlob *blob)
-{
- if (blob->type() == QQmlDataBlob::QmldirFile) {
- QQmlQmldirData *data = static_cast<QQmlQmldirData *>(blob);
- data->release();
- }
-}
-
void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
{
if (blob->type() == QQmlDataBlob::QmldirFile) {
@@ -1532,7 +1539,7 @@ bool QQmlTypeLoader::Blob::isDebugging() const
return typeLoader()->engine()->handle()->debugger() != nullptr;
}
-bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList<QQmlError> *errors)
+bool QQmlTypeLoader::Blob::qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &data, QList<QQmlError> *errors)
{
bool resolve = true;
@@ -1552,7 +1559,6 @@ bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList<QQmlE
if (resolve) {
// This is the (current) best resolution for this import
if (!updateQmldir(data, import, errors)) {
- data->release();
return false;
}
@@ -1562,7 +1568,6 @@ bool QQmlTypeLoader::Blob::qmldirDataAvailable(QQmlQmldirData *data, QList<QQmlE
}
}
- data->release();
return true;
}
@@ -1664,7 +1669,7 @@ QUrl QQmlTypeLoader::normalize(const QUrl &unNormalizedUrl)
/*!
Returns a QQmlTypeData for the specified \a url. The QQmlTypeData may be cached.
*/
-QQmlTypeData *QQmlTypeLoader::getType(const QUrl &unNormalizedUrl, Mode mode)
+QQmlRefPointer<QQmlTypeData> QQmlTypeLoader::getType(const QUrl &unNormalizedUrl, Mode mode)
{
Q_ASSERT(!unNormalizedUrl.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl).isEmpty() ||
@@ -1707,8 +1712,6 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &unNormalizedUrl, Mode mode)
}
}
- typeData->addref();
-
return typeData;
}
@@ -1716,20 +1719,20 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &unNormalizedUrl, Mode mode)
Returns a QQmlTypeData for the given \a data with the provided base \a url. The
QQmlTypeData will not be cached.
*/
-QQmlTypeData *QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url, Mode mode)
+QQmlRefPointer<QQmlTypeData> QQmlTypeLoader::getType(const QByteArray &data, const QUrl &url, Mode mode)
{
LockHolder<QQmlTypeLoader> holder(this);
QQmlTypeData *typeData = new QQmlTypeData(url, this);
QQmlTypeLoader::loadWithStaticData(typeData, data, mode);
- return typeData;
+ return QQmlRefPointer<QQmlTypeData>(typeData, QQmlRefPointer<QQmlTypeData>::Adopt);
}
/*!
Return a QQmlScriptBlob for \a url. The QQmlScriptData may be cached.
*/
-QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &unNormalizedUrl)
+QQmlRefPointer<QQmlScriptBlob> QQmlTypeLoader::getScript(const QUrl &unNormalizedUrl)
{
Q_ASSERT(!unNormalizedUrl.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(unNormalizedUrl).isEmpty() ||
@@ -1754,20 +1757,17 @@ QQmlScriptBlob *QQmlTypeLoader::getScript(const QUrl &unNormalizedUrl)
}
}
- scriptBlob->addref();
-
return scriptBlob;
}
/*!
Returns a QQmlQmldirData for \a url. The QQmlQmldirData may be cached.
*/
-QQmlQmldirData *QQmlTypeLoader::getQmldir(const QUrl &url)
+QQmlRefPointer<QQmlQmldirData> QQmlTypeLoader::getQmldir(const QUrl &url)
{
Q_ASSERT(!url.isRelative() &&
(QQmlFile::urlToLocalFileOrQrc(url).isEmpty() ||
!QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url))));
-
LockHolder<QQmlTypeLoader> holder(this);
QQmlQmldirData *qmldirData = m_qmldirCache.value(url);
@@ -1778,8 +1778,6 @@ QQmlQmldirData *QQmlTypeLoader::getQmldir(const QUrl &url)
QQmlTypeLoader::load(qmldirData);
}
- qmldirData->addref();
-
return qmldirData;
}
@@ -1859,6 +1857,52 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
return absoluteFilePath;
}
+bool QQmlTypeLoader::fileExists(const QString &path, const QString &file)
+{
+ if (path.isEmpty())
+ return false;
+ Q_ASSERT(path.endsWith(QLatin1Char('/')));
+ if (path.at(0) == QLatin1Char(':')) {
+ // qrc resource
+ QFileInfo fileInfo(path + file);
+ return fileInfo.isFile();
+ } else if (path.count() > 3 && path.at(3) == QLatin1Char(':') &&
+ path.startsWith(QLatin1String("qrc"), Qt::CaseInsensitive)) {
+ // qrc resource url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path + file));
+ return fileInfo.isFile();
+ }
+#if defined(Q_OS_ANDROID)
+ else if (path.count() > 7 && path.at(6) == QLatin1Char(':') && path.at(7) == QLatin1Char('/') &&
+ path.startsWith(QLatin1String("assets"), Qt::CaseInsensitive)) {
+ // assets resource url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path + file));
+ return fileInfo.isFile();
+ }
+#endif
+
+ LockHolder<QQmlTypeLoader> holder(this);
+ if (!m_importDirCache.contains(path)) {
+ bool exists = QDir(path).exists();
+ QCache<QString, bool> *entry = exists ? new QCache<QString, bool> : nullptr;
+ m_importDirCache.insert(path, entry);
+ }
+ QCache<QString, bool> *fileSet = m_importDirCache.object(path);
+ if (!fileSet)
+ return false;
+
+ QString absoluteFilePath;
+
+ bool *value = fileSet->object(file);
+ if (value) {
+ return *value;
+ } else {
+ bool exists = QFile::exists(path + file);
+ fileSet->insert(file, new bool(exists));
+ return exists;
+ }
+}
+
/*!
Returns true if the path is a directory via a directory cache. Cache is
@@ -2073,17 +2117,9 @@ QQmlTypeData::QQmlTypeData(const QUrl &url, QQmlTypeLoader *manager)
QQmlTypeData::~QQmlTypeData()
{
- for (int ii = 0; ii < m_scripts.count(); ++ii)
- m_scripts.at(ii).script->release();
- for (int ii = 0; ii < m_compositeSingletons.count(); ++ii) {
- if (QQmlTypeData *tdata = m_compositeSingletons.at(ii).typeData)
- tdata->release();
- }
- for (auto it = m_resolvedTypes.constBegin(), end = m_resolvedTypes.constEnd();
- it != end; ++it) {
- if (QQmlTypeData *tdata = it->typeData)
- tdata->release();
- }
+ m_scripts.clear();
+ m_compositeSingletons.clear();
+ m_resolvedTypes.clear();
}
const QList<QQmlTypeData::ScriptReference> &QQmlTypeData::resolvedScripts() const
@@ -2130,7 +2166,7 @@ bool QQmlTypeData::tryLoadFromDiskCache()
}
}
- if (unit->data->flags & QV4::CompiledData::Unit::PendingTypeCompilation) {
+ if (unit->unitData()->flags & QV4::CompiledData::Unit::PendingTypeCompilation) {
restoreIR(unit);
return true;
}
@@ -2152,8 +2188,8 @@ bool QQmlTypeData::tryLoadFromDiskCache()
return false;
// find the implicit import
- for (quint32 i = 0; i < m_compiledData->data->nImports; ++i) {
- const QV4::CompiledData::Import *import = m_compiledData->data->importAt(i);
+ for (quint32 i = 0, count = m_compiledData->importCount(); i < count; ++i) {
+ const QV4::CompiledData::Import *import = m_compiledData->importAt(i);
if (m_compiledData->stringAt(import->uriIndex) == QLatin1String(".")
&& import->qualifierIndex == 0
&& import->majorVersion == -1
@@ -2169,8 +2205,8 @@ bool QQmlTypeData::tryLoadFromDiskCache()
}
}
- for (int i = 0, count = m_compiledData->data->nImports; i < count; ++i) {
- const QV4::CompiledData::Import *import = m_compiledData->data->importAt(i);
+ for (int i = 0, count = m_compiledData->importCount(); i < count; ++i) {
+ const QV4::CompiledData::Import *import = m_compiledData->importAt(i);
QList<QQmlError> errors;
if (!addImport(import, &errors)) {
Q_ASSERT(errors.size());
@@ -2201,7 +2237,7 @@ void QQmlTypeData::createTypeAndPropertyCaches(const QQmlRefPointer<QQmlTypeName
{
QQmlPropertyCacheCreator<QV4::CompiledData::CompilationUnit> propertyCacheCreator(&m_compiledData->propertyCaches,
&pendingGroupPropertyBindings,
- engine, m_compiledData, &m_importCache);
+ engine, m_compiledData.data(), &m_importCache);
QQmlCompileError error = propertyCacheCreator.buildMetaObjects();
if (error.isSet()) {
setError(error);
@@ -2209,7 +2245,7 @@ void QQmlTypeData::createTypeAndPropertyCaches(const QQmlRefPointer<QQmlTypeName
}
}
- QQmlPropertyCacheAliasCreator<QV4::CompiledData::CompilationUnit> aliasCreator(&m_compiledData->propertyCaches, m_compiledData);
+ QQmlPropertyCacheAliasCreator<QV4::CompiledData::CompilationUnit> aliasCreator(&m_compiledData->propertyCaches, m_compiledData.data());
aliasCreator.appendAliasPropertiesToMetaObjects();
pendingGroupPropertyBindings.resolveMissingPropertyCaches(engine, &m_compiledData->propertyCaches);
@@ -2219,8 +2255,8 @@ static bool addTypeReferenceChecksumsToHash(const QList<QQmlTypeData::TypeRefere
{
for (const auto &typeRef: typeRefs) {
if (typeRef.typeData) {
- const auto unit = typeRef.typeData->compilationUnit();
- hash->addData(unit->data->md5Checksum, sizeof(unit->data->md5Checksum));
+ const auto unit = typeRef.typeData->compilationUnit()->unitData();
+ hash->addData(unit->md5Checksum, sizeof(unit->md5Checksum));
} else if (typeRef.type.isValid()) {
const auto propertyCache = QQmlEnginePrivate::get(engine)->cache(typeRef.type.metaObject());
bool ok = false;
@@ -2234,7 +2270,7 @@ static bool addTypeReferenceChecksumsToHash(const QList<QQmlTypeData::TypeRefere
void QQmlTypeData::done()
{
- QDeferredCleanup cleanup([this]{
+ auto cleanup = qScopeGuard([this]{
m_document.reset();
m_typeReferences.clear();
if (isError())
@@ -2354,7 +2390,7 @@ void QQmlTypeData::done()
{
QQmlType type = QQmlMetaType::qmlType(finalUrl(), true);
- if (m_compiledData && m_compiledData->data->flags & QV4::CompiledData::Unit::IsSingleton) {
+ if (m_compiledData && m_compiledData->unitData()->flags & QV4::CompiledData::Unit::IsSingleton) {
if (!type.isValid()) {
QQmlError error;
error.setDescription(QQmlTypeLoader::tr("No matching type found, pragma Singleton files cannot be used by QQmlComponent."));
@@ -2393,8 +2429,7 @@ void QQmlTypeData::done()
}
m_compiledData->typeNameCache->add(qualifier.toString(), scriptIndex, enclosingNamespace);
- QQmlScriptData *scriptData = script.script->scriptData();
- scriptData->addref();
+ QQmlRefPointer<QQmlScriptData> scriptData = script.script->scriptData();
m_compiledData->dependentScripts << scriptData;
}
}
@@ -2501,7 +2536,7 @@ bool QQmlTypeData::loadFromSource()
void QQmlTypeData::restoreIR(QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit)
{
m_document.reset(new QmlIR::Document(isDebugging()));
- QmlIR::IRLoader loader(unit->data, m_document.data());
+ QmlIR::IRLoader loader(unit->unitData(), m_document.data());
loader.load();
m_document->jsModule.fileName = urlString();
m_document->jsModule.finalUrl = finalUrlString();
@@ -2608,7 +2643,7 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCach
{
Q_ASSERT(m_compiledData.isNull());
- const bool typeRecompilation = m_document && m_document->javaScriptCompilationUnit && m_document->javaScriptCompilationUnit->data->flags & QV4::CompiledData::Unit::PendingTypeCompilation;
+ const bool typeRecompilation = m_document && m_document->javaScriptCompilationUnit && m_document->javaScriptCompilationUnit->unitData()->flags & QV4::CompiledData::Unit::PendingTypeCompilation;
QQmlEnginePrivate * const enginePrivate = QQmlEnginePrivate::get(typeLoader()->engine());
QQmlTypeCompiler compiler(enginePrivate, this, m_document.data(), typeNameCache, resolvedTypeCache, dependencyHasher);
@@ -2637,8 +2672,8 @@ void QQmlTypeData::resolveTypes()
// Add any imported scripts to our resolved set
const auto resolvedScripts = m_importCache.resolvedScripts();
for (const QQmlImports::ScriptReference &script : resolvedScripts) {
- QQmlScriptBlob *blob = typeLoader()->getScript(script.location);
- addDependency(blob);
+ QQmlRefPointer<QQmlScriptBlob> blob = typeLoader()->getScript(script.location);
+ addDependency(blob.data());
ScriptReference ref;
//ref.location = ...
@@ -2681,7 +2716,7 @@ void QQmlTypeData::resolveTypes()
// TODO: give an error message? If so, we should record and show the path of the cycle.
continue;
}
- addDependency(ref.typeData);
+ addDependency(ref.typeData.data());
ref.prefix = csRef.prefix;
m_compositeSingletons << ref;
@@ -2711,7 +2746,7 @@ void QQmlTypeData::resolveTypes()
if (ref.type.isComposite()) {
ref.typeData = typeLoader()->getType(ref.type.sourceUrl());
- addDependency(ref.typeData);
+ addDependency(ref.typeData.data());
}
ref.majorVersion = majorVersion;
ref.minorVersion = minorVersion;
@@ -2743,7 +2778,7 @@ QQmlCompileError QQmlTypeData::buildTypeResolutionCaches(
for (const QQmlTypeData::TypeReference &singleton: m_compositeSingletons)
(*typeNameCache)->add(singleton.type.qmlTypeName(), singleton.type.sourceUrl(), singleton.prefix);
- m_importCache.populateCache(*typeNameCache);
+ m_importCache.populateCache(typeNameCache->data());
QQmlEnginePrivate * const engine = QQmlEnginePrivate::get(typeLoader()->engine());
@@ -2833,7 +2868,7 @@ bool QQmlTypeData::resolveType(const QString &typeName, int &majorVersion, int &
return true;
}
-void QQmlTypeData::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &/*nameSpace*/)
+void QQmlTypeData::scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &/*nameSpace*/)
{
ScriptReference ref;
ref.script = blob;
@@ -2876,11 +2911,22 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent
return m_value.value();
Q_ASSERT(parentCtxt && parentCtxt->engine);
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
QV4::ExecutionEngine *v4 = parentCtxt->engine->handle();
+
+ if (m_precompiledScript->unitData()->flags & QV4::CompiledData::Unit::IsESModule) {
+ m_loaded = true;
+
+ m_value.set(v4, m_precompiledScript->instantiate(v4));
+ if (!m_value.isNullOrUndefined())
+ m_precompiledScript->evaluate();
+
+ return m_value.value();
+ }
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(parentCtxt->engine);
QV4::Scope scope(v4);
- bool shared = m_precompiledScript->data->flags & QV4::CompiledData::Unit::IsSharedLibrary;
+ bool shared = m_precompiledScript->unitData()->flags & QV4::CompiledData::Unit::IsSharedLibrary;
QQmlContextData *effectiveCtxt = parentCtxt;
if (shared)
@@ -2921,7 +2967,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent
}
QV4::ScopedValue v(scope);
for (int ii = 0; ii < scripts.count(); ++ii)
- scriptsArray->putIndexed(ii, (v = scripts.at(ii)->scriptData()->scriptValueForContext(ctxt)));
+ scriptsArray->put(ii, (v = scripts.at(ii)->scriptData()->scriptValueForContext(ctxt)));
if (!hasEngine())
initialize(parentCtxt->engine);
@@ -2959,8 +3005,6 @@ void QQmlScriptData::clear()
typeNameCache = nullptr;
}
- for (int ii = 0; ii < scripts.count(); ++ii)
- scripts.at(ii)->release();
scripts.clear();
// An addref() was made when the QQmlCleanup was added to the engine.
@@ -2968,19 +3012,16 @@ void QQmlScriptData::clear()
}
QQmlScriptBlob::QQmlScriptBlob(const QUrl &url, QQmlTypeLoader *loader)
-: QQmlTypeLoader::Blob(url, JavaScriptFile, loader), m_scriptData(nullptr)
+ : QQmlTypeLoader::Blob(url, JavaScriptFile, loader)
+ , m_isModule(url.path().endsWith(QLatin1String(".mjs")))
{
}
QQmlScriptBlob::~QQmlScriptBlob()
{
- if (m_scriptData) {
- m_scriptData->release();
- m_scriptData = nullptr;
- }
}
-QQmlScriptData *QQmlScriptBlob::scriptData() const
+QQmlRefPointer<QQmlScriptData> QQmlScriptBlob::scriptData() const
{
return m_scriptData;
}
@@ -3006,9 +3047,6 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data)
return;
}
- QmlIR::Document irUnit(isDebugging());
-
- irUnit.jsModule.sourceTimeStamp = data.sourceTimeStamp();
QString error;
QString source = data.readAll(&error);
if (!error.isEmpty()) {
@@ -3016,32 +3054,51 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data)
return;
}
- QmlIR::ScriptDirectivesCollector collector(&irUnit);
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit;
- QList<QQmlError> errors;
- QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = QV4::Script::precompile(
- &irUnit.jsModule, &irUnit.jsGenerator, urlString(), finalUrlString(),
- source, &errors, &collector);
- // No need to addref on unit, it's initial refcount is 1
- source.clear();
- if (!errors.isEmpty()) {
- setError(errors);
- return;
- }
- if (!unit) {
- unit.adopt(new QV4::CompiledData::CompilationUnit);
- }
- irUnit.javaScriptCompilationUnit = unit;
+ if (m_isModule) {
+ QList<QQmlJS::DiagnosticMessage> diagnostics;
+ unit = QV4::ExecutionEngine::compileModule(isDebugging(), urlString(), source, data.sourceTimeStamp(), &diagnostics);
+ QList<QQmlError> errors = QQmlEnginePrivate::qmlErrorFromDiagnostics(urlString(), diagnostics);
+ if (!errors.isEmpty()) {
+ setError(errors);
+ return;
+ }
+ } else {
+ QmlIR::Document irUnit(isDebugging());
+
+ irUnit.jsModule.sourceTimeStamp = data.sourceTimeStamp();
+
+ QmlIR::ScriptDirectivesCollector collector(&irUnit);
+ irUnit.jsParserEngine.setDirectives(&collector);
+
+ QList<QQmlError> errors;
+ unit = QV4::Script::precompile(
+ &irUnit.jsModule, &irUnit.jsParserEngine, &irUnit.jsGenerator, urlString(), finalUrlString(),
+ source, &errors);
+ // No need to addref on unit, it's initial refcount is 1
+ source.clear();
+ if (!errors.isEmpty()) {
+ setError(errors);
+ return;
+ }
+ if (!unit) {
+ unit.adopt(new QV4::CompiledData::CompilationUnit);
+ }
+ irUnit.javaScriptCompilationUnit = unit;
- QmlIR::QmlUnitGenerator qmlGenerator;
- QV4::CompiledData::Unit *unitData = qmlGenerator.generate(irUnit);
- Q_ASSERT(!unit->data);
- // The js unit owns the data and will free the qml unit.
- unit->data = unitData;
+ QmlIR::QmlUnitGenerator qmlGenerator;
+ qmlGenerator.generate(irUnit);
+ }
if ((!disableDiskCache() || forceDiskCache()) && !isDebugging()) {
QString errorString;
- if (!unit->saveToDisk(url(), &errorString)) {
+ if (unit->saveToDisk(url(), &errorString)) {
+ QString error;
+ if (!unit->loadFromDisk(url(), data.sourceTimeStamp(), &error)) {
+ // ignore error, keep using the in-memory compilation unit.
+ }
+ } else {
qCDebug(DBG_DISK_CACHE()) << "Error saving cached version of" << unit->fileName() << "to disk:" << errorString;
}
}
@@ -3052,7 +3109,7 @@ void QQmlScriptBlob::dataReceived(const SourceCodeData &data)
void QQmlScriptBlob::initializeFromCachedUnit(const QV4::CompiledData::Unit *unit)
{
QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit;
- compilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit));
+ compilationUnit.adopt(new QV4::CompiledData::CompilationUnit(unit, urlString(), finalUrlString()));
initializeFromCompilationUnit(compilationUnit);
}
@@ -3078,33 +3135,36 @@ void QQmlScriptBlob::done()
}
}
- m_scriptData->typeNameCache = new QQmlTypeNameCache(m_importCache);
+ if (!m_isModule) {
+ m_scriptData->typeNameCache = new QQmlTypeNameCache(m_importCache);
- QSet<QString> ns;
+ QSet<QString> ns;
- for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
- const ScriptReference &script = m_scripts.at(scriptIndex);
+ for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
+ const ScriptReference &script = m_scripts.at(scriptIndex);
- m_scriptData->scripts.append(script.script);
+ m_scriptData->scripts.append(script.script);
- if (!script.nameSpace.isNull()) {
- if (!ns.contains(script.nameSpace)) {
- ns.insert(script.nameSpace);
- m_scriptData->typeNameCache->add(script.nameSpace);
+ if (!script.nameSpace.isNull()) {
+ if (!ns.contains(script.nameSpace)) {
+ ns.insert(script.nameSpace);
+ m_scriptData->typeNameCache->add(script.nameSpace);
+ }
}
+ m_scriptData->typeNameCache->add(script.qualifier, scriptIndex, script.nameSpace);
}
- m_scriptData->typeNameCache->add(script.qualifier, scriptIndex, script.nameSpace);
- }
- m_importCache.populateCache(m_scriptData->typeNameCache);
+ m_importCache.populateCache(m_scriptData->typeNameCache);
+ }
+ m_scripts.clear();
}
QString QQmlScriptBlob::stringAt(int index) const
{
- return m_scriptData->m_precompiledScript->data->stringAt(index);
+ return m_scriptData->m_precompiledScript->stringAt(index);
}
-void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace)
+void QQmlScriptBlob::scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace)
{
ScriptReference ref;
ref.script = blob;
@@ -3118,30 +3178,45 @@ void QQmlScriptBlob::scriptImported(QQmlScriptBlob *blob, const QV4::CompiledDat
void QQmlScriptBlob::initializeFromCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit)
{
Q_ASSERT(!m_scriptData);
- m_scriptData = new QQmlScriptData();
+ m_scriptData.adopt(new QQmlScriptData());
m_scriptData->url = finalUrl();
m_scriptData->urlString = finalUrlString();
m_scriptData->m_precompiledScript = unit;
m_importCache.setBaseUrl(finalUrl(), finalUrlString());
- Q_ASSERT(m_scriptData->m_precompiledScript->data->flags & QV4::CompiledData::Unit::IsQml);
- const QV4::CompiledData::Unit *qmlUnit = m_scriptData->m_precompiledScript->data;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> script = m_scriptData->m_precompiledScript;
- QList<QQmlError> errors;
- for (quint32 i = 0; i < qmlUnit->nImports; ++i) {
- const QV4::CompiledData::Import *import = qmlUnit->importAt(i);
- if (!addImport(import, &errors)) {
- Q_ASSERT(errors.size());
- QQmlError error(errors.takeFirst());
- error.setUrl(m_importCache.baseUrl());
- error.setLine(import->location.line);
- error.setColumn(import->location.column);
- errors.prepend(error); // put it back on the list after filling out information.
- setError(errors);
- return;
+ if (!m_isModule) {
+ QList<QQmlError> errors;
+ for (quint32 i = 0, count = script->importCount(); i < count; ++i) {
+ const QV4::CompiledData::Import *import = script->importAt(i);
+ if (!addImport(import, &errors)) {
+ Q_ASSERT(errors.size());
+ QQmlError error(errors.takeFirst());
+ error.setUrl(m_importCache.baseUrl());
+ error.setLine(import->location.line);
+ error.setColumn(import->location.column);
+ errors.prepend(error); // put it back on the list after filling out information.
+ setError(errors);
+ return;
+ }
}
}
+
+ auto *v4 = QQmlEnginePrivate::getV4Engine(typeLoader()->engine());
+
+ v4->injectModule(unit);
+
+ for (const QString &request: unit->moduleRequests()) {
+ if (v4->moduleForUrl(QUrl(request), unit.data()))
+ continue;
+
+ const QUrl absoluteRequest = unit->finalUrl().resolved(QUrl(request));
+ QQmlRefPointer<QQmlScriptBlob> blob = typeLoader()->getScript(absoluteRequest);
+ addDependency(blob.data());
+ scriptImported(blob, /* ### */QV4::CompiledData::Location(), /*qualifier*/QString(), /*namespace*/QString());
+ }
}
QQmlQmldirData::QQmlQmldirData(const QUrl &url, QQmlTypeLoader *loader)
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index e75719866d..031554b330 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -217,7 +217,7 @@ private:
QList<QQmlDataBlob *> m_waitingOnMe;
// List of QQmlDataBlob's that I am waiting for to complete.
- QList<QQmlDataBlob *> m_waitingFor;
+ QVector<QQmlRefPointer<QQmlDataBlob>> m_waitingFor;
int m_redirectCount:30;
bool m_inCallback:1;
@@ -279,14 +279,13 @@ public:
bool addImport(const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
bool fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors);
- bool updateQmldir(QQmlQmldirData *data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
+ bool updateQmldir(const QQmlRefPointer<QQmlQmldirData> &data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors);
private:
- virtual bool qmldirDataAvailable(QQmlQmldirData *, QList<QQmlError> *);
+ virtual bool qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &, QList<QQmlError> *);
- virtual void scriptImported(QQmlScriptBlob *, const QV4::CompiledData::Location &, const QString &, const QString &) {}
+ virtual void scriptImported(const QQmlRefPointer<QQmlScriptBlob> &, const QV4::CompiledData::Location &, const QString &, const QString &) {}
- void dependencyError(QQmlDataBlob *) override;
void dependencyComplete(QQmlDataBlob *) override;
protected:
@@ -296,7 +295,7 @@ public:
QQmlImports m_importCache;
QHash<const QV4::CompiledData::Import*, int> m_unresolvedImports;
- QList<QQmlQmldirData *> m_qmldirs;
+ QVector<QQmlRefPointer<QQmlQmldirData>> m_qmldirs;
QQmlMetaType::CachedUnitLookupError m_cachedUnitStatus = QQmlMetaType::CachedUnitLookupError::NoError;
};
@@ -307,13 +306,14 @@ public:
static QUrl normalize(const QUrl &unNormalizedUrl);
- QQmlTypeData *getType(const QUrl &unNormalizedUrl, Mode mode = PreferSynchronous);
- QQmlTypeData *getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous);
+ QQmlRefPointer<QQmlTypeData> getType(const QUrl &unNormalizedUrl, Mode mode = PreferSynchronous);
+ QQmlRefPointer<QQmlTypeData> getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous);
- QQmlScriptBlob *getScript(const QUrl &unNormalizedUrl);
- QQmlQmldirData *getQmldir(const QUrl &);
+ QQmlRefPointer<QQmlScriptBlob> getScript(const QUrl &unNormalizedUrl);
+ QQmlRefPointer<QQmlQmldirData> getQmldir(const QUrl &);
QString absoluteFilePath(const QString &path);
+ bool fileExists(const QString &path, const QString &file);
bool directoryExists(const QString &path);
const QQmlTypeLoaderQmldirContent qmldirContent(const QString &filePath);
@@ -424,13 +424,13 @@ class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob
public:
struct TypeReference
{
- TypeReference() : majorVersion(0), minorVersion(0), typeData(nullptr), needsCreation(true) {}
+ TypeReference() : majorVersion(0), minorVersion(0), needsCreation(true) {}
QV4::CompiledData::Location location;
QQmlType type;
int majorVersion;
int minorVersion;
- QQmlTypeData *typeData;
+ QQmlRefPointer<QQmlTypeData> typeData;
QString prefix; // used by CompositeSingleton types
QString qualifiedName() const;
bool needsCreation;
@@ -438,11 +438,9 @@ public:
struct ScriptReference
{
- ScriptReference() : script(nullptr) {}
-
QV4::CompiledData::Location location;
QString qualifier;
- QQmlScriptBlob *script;
+ QQmlRefPointer<QQmlScriptBlob> script;
};
private:
@@ -495,7 +493,7 @@ private:
bool reportErrors = true,
QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType);
- void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
+ void scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
SourceCodeData m_backupSourceCode; // used when cache verification fails.
@@ -541,10 +539,12 @@ public:
QUrl url;
QString urlString;
QQmlTypeNameCache *typeNameCache;
- QList<QQmlScriptBlob *> scripts;
+ QVector<QQmlRefPointer<QQmlScriptBlob>> scripts;
QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt);
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit() const { return m_precompiledScript; }
+
protected:
void clear() override; // From QQmlCleanup
@@ -571,15 +571,13 @@ public:
struct ScriptReference
{
- ScriptReference() : script(nullptr) {}
-
QV4::CompiledData::Location location;
QString qualifier;
QString nameSpace;
- QQmlScriptBlob *script;
+ QQmlRefPointer<QQmlScriptBlob> script;
};
- QQmlScriptData *scriptData() const;
+ QQmlRefPointer<QQmlScriptData> scriptData() const;
protected:
void dataReceived(const SourceCodeData &) override;
@@ -589,11 +587,12 @@ protected:
QString stringAt(int index) const override;
private:
- void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
+ void scriptImported(const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
void initializeFromCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit);
QList<ScriptReference> m_scripts;
- QQmlScriptData *m_scriptData;
+ QQmlRefPointer<QQmlScriptData> m_scriptData;
+ const bool m_isModule;
};
class Q_AUTOTEST_EXPORT QQmlQmldirData : public QQmlTypeLoader::Blob
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index ce35e966aa..b58619c0d3 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -95,12 +95,17 @@ QObject* QQmlTypeWrapper::singletonObject() const
QVariant QQmlTypeWrapper::toVariant() const
{
- QObject *qobjectSingleton = singletonObject();
- if (qobjectSingleton)
+ // Only Singleton type wrappers can be converted to a variant.
+ if (!isSingleton())
+ return QVariant();
+
+ QQmlEngine *e = engine()->qmlEngine();
+ QQmlType::SingletonInstanceInfo *siinfo = d()->type().singletonInstanceInfo();
+ siinfo->init(e);
+ if (QObject *qobjectSingleton = siinfo->qobjectApi(e))
return QVariant::fromValue<QObject*>(qobjectSingleton);
- // only QObject Singleton Type can be converted to a variant.
- return QVariant();
+ return QVariant::fromValue<QJSValue>(siinfo->scriptApi(e));
}
@@ -111,7 +116,7 @@ ReturnedValue QQmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o,
Q_ASSERT(t.isValid());
Scope scope(engine);
- Scoped<QQmlTypeWrapper> w(scope, engine->memoryManager->allocObject<QQmlTypeWrapper>());
+ Scoped<QQmlTypeWrapper> w(scope, engine->memoryManager->allocate<QQmlTypeWrapper>());
w->d()->mode = mode; w->d()->object = o;
w->d()->typePrivate = t.priv();
QQmlType::refHandle(w->d()->typePrivate);
@@ -120,15 +125,15 @@ ReturnedValue QQmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o,
// Returns a type wrapper for importNamespace (of t) on o. This allows nested resolution of a type in a
// namespace.
-ReturnedValue QQmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, QQmlTypeNameCache *t, const QQmlImportRef *importNamespace,
+ReturnedValue QQmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, const QQmlRefPointer<QQmlTypeNameCache> &t, const QQmlImportRef *importNamespace,
Heap::QQmlTypeWrapper::TypeNameMode mode)
{
Q_ASSERT(t);
Q_ASSERT(importNamespace);
Scope scope(engine);
- Scoped<QQmlTypeWrapper> w(scope, engine->memoryManager->allocObject<QQmlTypeWrapper>());
- w->d()->mode = mode; w->d()->object = o; w->d()->typeNamespace = t; w->d()->importNamespace = importNamespace;
+ Scoped<QQmlTypeWrapper> w(scope, engine->memoryManager->allocate<QQmlTypeWrapper>());
+ w->d()->mode = mode; w->d()->object = o; w->d()->typeNamespace = t.data(); w->d()->importNamespace = importNamespace;
t->addref();
return w.asReturnedValue();
}
@@ -162,12 +167,16 @@ static ReturnedValue throwLowercaseEnumError(QV4::ExecutionEngine *v4, String *n
return v4->throwTypeError(message);
}
-ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QQmlTypeWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlTypeWrapper>());
+ if (!id.isString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
QV4::ExecutionEngine *v4 = static_cast<const QQmlTypeWrapper *>(m)->engine();
QV4::Scope scope(v4);
+ ScopedString name(scope, id.asStringOrSymbol());
Scoped<QQmlTypeWrapper> w(scope, static_cast<const QQmlTypeWrapper *>(m));
@@ -196,7 +205,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp
bool ok = false;
const int value = enumForSingleton(v4, name, qobjectSingleton, type, &ok);
if (ok)
- return QV4::Primitive::fromInt32(value).asReturnedValue();
+ return QV4::Value::fromInt32(value).asReturnedValue();
}
// check for property.
@@ -228,11 +237,11 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp
bool ok = false;
int value = type.enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, &ok);
if (ok)
- return QV4::Primitive::fromInt32(value).asReturnedValue();
+ return QV4::Value::fromInt32(value).asReturnedValue();
value = type.scopedEnumIndex(QQmlEnginePrivate::get(v4->qmlEngine()), name, &ok);
if (ok) {
- Scoped<QQmlScopedEnumWrapper> enumWrapper(scope, v4->memoryManager->allocObject<QQmlScopedEnumWrapper>());
+ Scoped<QQmlScopedEnumWrapper> enumWrapper(scope, v4->memoryManager->allocate<QQmlScopedEnumWrapper>());
enumWrapper->d()->typePrivate = type.priv();
QQmlType::refHandle(enumWrapper->d()->typePrivate);
enumWrapper->d()->scopeEnumIndex = value;
@@ -263,7 +272,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp
return create(scope.engine, object, r.type, w->d()->mode);
} else if (r.scriptIndex != -1) {
QV4::ScopedObject scripts(scope, context->importedScripts.valueRef());
- return scripts->getIndexed(r.scriptIndex);
+ return scripts->get(r.scriptIndex);
} else if (r.importNamespace) {
return create(scope.engine, object, context->imports, r.importNamespace);
}
@@ -279,7 +288,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp
}
bool ok = false;
- const ReturnedValue result = Object::get(m, name, &ok);
+ const ReturnedValue result = Object::virtualGet(m, id, receiver, &ok);
if (hasProperty)
*hasProperty = ok;
@@ -295,16 +304,20 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp
}
-bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value)
+bool QQmlTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
+ if (!id.isString())
+ return Object::virtualPut(m, id, value, receiver);
+
+
Q_ASSERT(m->as<QQmlTypeWrapper>());
QQmlTypeWrapper *w = static_cast<QQmlTypeWrapper *>(m);
- QV4::ExecutionEngine *v4 = w->engine();
- if (v4->hasException)
+ QV4::Scope scope(w);
+ if (scope.engine->hasException)
return false;
- QV4::Scope scope(v4);
- QQmlContextData *context = v4->callingQmlContext();
+ ScopedString name(scope, id.asStringOrSymbol());
+ QQmlContextData *context = scope.engine->callingQmlContext();
QQmlType type = w->d()->type();
if (type.isValid() && !type.isSingleton() && w->d()->object) {
@@ -312,7 +325,7 @@ bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value)
QQmlEngine *e = scope.engine->qmlEngine();
QObject *ao = qmlAttachedPropertiesObjectById(type.attachedPropertiesId(QQmlEnginePrivate::get(e)), object);
if (ao)
- return QV4::QObjectWrapper::setQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value);
+ return QV4::QObjectWrapper::setQmlProperty(scope.engine, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value);
return false;
} else if (type.isSingleton()) {
QQmlEngine *e = scope.engine->qmlEngine();
@@ -321,12 +334,12 @@ bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value)
QObject *qobjectSingleton = siinfo->qobjectApi(e);
if (qobjectSingleton) {
- return QV4::QObjectWrapper::setQmlProperty(v4, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, value);
+ return QV4::QObjectWrapper::setQmlProperty(scope.engine, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, value);
} else if (!siinfo->scriptApi(e).isUndefined()) {
- QV4::ScopedObject apiprivate(scope, QJSValuePrivate::convertedToValue(v4, siinfo->scriptApi(e)));
+ QV4::ScopedObject apiprivate(scope, QJSValuePrivate::convertedToValue(scope.engine, siinfo->scriptApi(e)));
if (!apiprivate) {
QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"');
- v4->throwError(error);
+ scope.engine->throwError(error);
return false;
} else {
return apiprivate->put(name, value);
@@ -337,15 +350,21 @@ bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value)
return false;
}
-PropertyAttributes QQmlTypeWrapper::query(const Managed *m, String *name)
+PropertyAttributes QQmlTypeWrapper::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
{
- // ### Implement more efficiently.
- bool hasProperty = false;
- static_cast<Object *>(const_cast<Managed*>(m))->get(name, &hasProperty);
- return hasProperty ? Attr_Data : Attr_Invalid;
+ if (id.isString()) {
+ Scope scope(m);
+ ScopedString n(scope, id.asStringOrSymbol());
+ // ### Implement more efficiently.
+ bool hasProperty = false;
+ static_cast<const Object *>(m)->get(n, &hasProperty);
+ return hasProperty ? Attr_Data : Attr_Invalid;
+ }
+
+ return QV4::Object::virtualGetOwnProperty(m, id, p);
}
-bool QQmlTypeWrapper::isEqualTo(Managed *a, Managed *b)
+bool QQmlTypeWrapper::virtualIsEqualTo(Managed *a, Managed *b)
{
Q_ASSERT(a->as<QV4::QQmlTypeWrapper>());
QV4::QQmlTypeWrapper *qmlTypeWrapperA = static_cast<QV4::QQmlTypeWrapper *>(a);
@@ -357,7 +376,7 @@ bool QQmlTypeWrapper::isEqualTo(Managed *a, Managed *b)
return false;
}
-ReturnedValue QQmlTypeWrapper::instanceOf(const Object *typeObject, const Value &var)
+ReturnedValue QQmlTypeWrapper::virtualInstanceOf(const Object *typeObject, const Value &var)
{
Q_ASSERT(typeObject->as<QV4::QQmlTypeWrapper>());
const QV4::QQmlTypeWrapper *typeWrapper = static_cast<const QV4::QQmlTypeWrapper *>(typeObject);
@@ -385,10 +404,9 @@ ReturnedValue QQmlTypeWrapper::instanceOf(const Object *typeObject, const Value
if (!theirDData->compilationUnit)
return Encode(false);
- QQmlTypeData *td = qenginepriv->typeLoader.getType(typeWrapper->d()->type().sourceUrl());
+ QQmlRefPointer<QQmlTypeData> td = qenginepriv->typeLoader.getType(typeWrapper->d()->type().sourceUrl());
CompiledData::CompilationUnit *cu = td->compilationUnit();
myQmlType = qenginepriv->metaObjectForType(cu->metaTypeId);
- td->release();
} else {
myQmlType = qenginepriv->metaObjectForType(myTypeId);
}
@@ -410,12 +428,16 @@ QQmlType Heap::QQmlScopedEnumWrapper::type() const
return QQmlType(typePrivate);
}
-ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QQmlScopedEnumWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlScopedEnumWrapper>());
+ if (!id.isString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
const QQmlScopedEnumWrapper *resource = static_cast<const QQmlScopedEnumWrapper *>(m);
QV4::ExecutionEngine *v4 = resource->engine();
QV4::Scope scope(v4);
+ ScopedString name(scope, id.asStringOrSymbol());
QQmlType type = resource->d()->type();
int index = resource->d()->scopeEnumIndex;
@@ -425,7 +447,7 @@ ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, String *name, bool *h
if (hasProperty)
*hasProperty = ok;
if (ok)
- return QV4::Primitive::fromInt32(value).asReturnedValue();
+ return QV4::Value::fromInt32(value).asReturnedValue();
return Encode::undefined();
}
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 25ff7ba7c8..fa1ad56902 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -108,15 +108,15 @@ struct Q_QML_EXPORT QQmlTypeWrapper : Object
static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &,
Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums);
- static ReturnedValue create(ExecutionEngine *, QObject *, QQmlTypeNameCache *, const QQmlImportRef *,
+ static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer<QQmlTypeNameCache> &, const QQmlImportRef *,
Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums);
-
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
- static PropertyAttributes query(const Managed *, String *name);
- static bool isEqualTo(Managed *that, Managed *o);
- static ReturnedValue instanceOf(const Object *typeObject, const Value &var);
+protected:
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static bool virtualIsEqualTo(Managed *that, Managed *o);
+ static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var);
};
struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object
@@ -124,7 +124,7 @@ struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object
V4_OBJECT2(QQmlScopedEnumWrapper, Object)
V4_NEEDS_DESTROY
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
};
}
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index 270414a676..2b21591017 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -67,8 +67,7 @@ struct QQmlValueTypeFactoryImpl
QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl()
{
- for (unsigned int ii = 0; ii < QVariant::UserType; ++ii)
- valueTypes[ii] = nullptr;
+ std::fill_n(valueTypes, int(QVariant::UserType), nullptr);
// See types wrapped in qqmlmodelindexvaluetype_p.h
qRegisterMetaType<QItemSelectionRange>();
@@ -521,38 +520,33 @@ void QQmlEasingValueType::setBezierCurve(const QVariantList &customCurveVariant)
if (customCurveVariant.isEmpty())
return;
- QVariantList variantList = customCurveVariant;
- if ((variantList.count() % 6) == 0) {
- bool allRealsOk = true;
- QVector<qreal> reals;
- const int variantListCount = variantList.count();
- reals.reserve(variantListCount);
- for (int i = 0; i < variantListCount; i++) {
- bool ok;
- const qreal real = variantList.at(i).toReal(&ok);
- reals.append(real);
- if (!ok)
- allRealsOk = false;
- }
- if (allRealsOk) {
- QEasingCurve newEasingCurve(QEasingCurve::BezierSpline);
- for (int i = 0; i < reals.count() / 6; i++) {
- const qreal c1x = reals.at(i * 6);
- const qreal c1y = reals.at(i * 6 + 1);
- const qreal c2x = reals.at(i * 6 + 2);
- const qreal c2y = reals.at(i * 6 + 3);
- const qreal c3x = reals.at(i * 6 + 4);
- const qreal c3y = reals.at(i * 6 + 5);
-
- const QPointF c1(c1x, c1y);
- const QPointF c2(c2x, c2y);
- const QPointF c3(c3x, c3y);
-
- newEasingCurve.addCubicBezierSegment(c1, c2, c3);
- v = newEasingCurve;
- }
- }
+ if ((customCurveVariant.count() % 6) != 0)
+ return;
+
+ auto convert = [](const QVariant &v, qreal &r) {
+ bool ok;
+ r = v.toReal(&ok);
+ return ok;
+ };
+
+ QEasingCurve newEasingCurve(QEasingCurve::BezierSpline);
+ for (int i = 0, ei = customCurveVariant.size(); i < ei; i += 6) {
+ qreal c1x, c1y, c2x, c2y, c3x, c3y;
+ if (!convert(customCurveVariant.at(i ), c1x)) return;
+ if (!convert(customCurveVariant.at(i + 1), c1y)) return;
+ if (!convert(customCurveVariant.at(i + 2), c2x)) return;
+ if (!convert(customCurveVariant.at(i + 3), c2y)) return;
+ if (!convert(customCurveVariant.at(i + 4), c3x)) return;
+ if (!convert(customCurveVariant.at(i + 5), c3y)) return;
+
+ const QPointF c1(c1x, c1y);
+ const QPointF c2(c2x, c2y);
+ const QPointF c3(c3x, c3y);
+
+ newEasingCurve.addCubicBezierSegment(c1, c2, c3);
}
+
+ v = newEasingCurve;
}
QVariantList QQmlEasingValueType::bezierCurve() const
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding_p.h b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
index ba0d305bd9..35b54c339b 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding_p.h
+++ b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
@@ -55,7 +55,7 @@
QT_BEGIN_NAMESPACE
-class QQmlValueTypeProxyBinding : public QQmlAbstractBinding
+class Q_AUTOTEST_EXPORT QQmlValueTypeProxyBinding : public QQmlAbstractBinding
{
public:
QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex coreIndex);
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 6196a09d94..b503d75a47 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -39,7 +39,6 @@
#include "qqmlvaluetypewrapper_p.h"
#include <private/qv8engine_p.h>
-
#include <private/qqmlvaluetype_p.h>
#include <private/qqmlbinding_p.h>
#include <private/qqmlglobal_p.h>
@@ -49,6 +48,7 @@
#include <private/qv4functionobject_p.h>
#include <private/qv4variantobject_p.h>
#include <private/qv4alloca_p.h>
+#include <private/qv4stackframe_p.h>
#include <private/qv4objectiterator_p.h>
#include <private/qv4qobjectwrapper_p.h>
#include <QtCore/qloggingcategory.h>
@@ -186,7 +186,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
Scope scope(engine);
initProto(engine);
- Scoped<QQmlValueTypeReference> r(scope, engine->memoryManager->allocObject<QQmlValueTypeReference>());
+ Scoped<QQmlValueTypeReference> r(scope, engine->memoryManager->allocate<QQmlValueTypeReference>());
r->d()->object = object;
r->d()->property = property;
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
@@ -200,7 +200,7 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
Scope scope(engine);
initProto(engine);
- Scoped<QQmlValueTypeWrapper> r(scope, engine->memoryManager->allocObject<QQmlValueTypeWrapper>());
+ Scoped<QQmlValueTypeWrapper> r(scope, engine->memoryManager->allocate<QQmlValueTypeWrapper>());
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
r->d()->valueType = QQmlValueTypeFactory::valueType(typeId);
r->d()->gadgetPtr = nullptr;
@@ -227,7 +227,7 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const
return true;
}
-bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
+bool QQmlValueTypeWrapper::virtualIsEqualTo(Managed *m, Managed *other)
{
Q_ASSERT(m && m->as<QQmlValueTypeWrapper>() && other);
QV4::QQmlValueTypeWrapper *lv = static_cast<QQmlValueTypeWrapper *>(m);
@@ -241,41 +241,58 @@ bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
return false;
}
-PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, String *name)
+PropertyAttributes QQmlValueTypeWrapper::virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
{
- Q_ASSERT(m->as<const QQmlValueTypeWrapper>());
- const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
+ if (id.isString()) {
+ Scope scope(m);
+ ScopedString n(scope, id.asStringOrSymbol());
+ const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(n.getPointer(), nullptr, nullptr);
+ return result ? Attr_Data : Attr_Invalid;
+ }
- QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr);
- return result ? Attr_Data : Attr_Invalid;
+ return QV4::Object::virtualGetOwnProperty(m, id, p);
}
-void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
+struct QQmlValueTypeWrapperOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
{
- name->setM(nullptr);
- *index = UINT_MAX;
+ int propertyIndex = 0;
+ ~QQmlValueTypeWrapperOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
- QQmlValueTypeWrapper *that = static_cast<QQmlValueTypeWrapper*>(m);
+PropertyKey QQmlValueTypeWrapperOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs) {
+ const QQmlValueTypeWrapper *that = static_cast<const QQmlValueTypeWrapper *>(o);
- if (QQmlValueTypeReference *ref = that->as<QQmlValueTypeReference>()) {
+ if (const QQmlValueTypeReference *ref = that->as<QQmlValueTypeReference>()) {
if (!ref->readReferenceValue())
- return;
+ return PropertyKey::invalid();
}
if (that->d()->propertyCache()) {
const QMetaObject *mo = that->d()->propertyCache()->createMetaObject();
const int propertyCount = mo->propertyCount();
- if (it->arrayIndex < static_cast<uint>(propertyCount)) {
+ if (propertyIndex < propertyCount) {
Scope scope(that->engine());
- ScopedString propName(scope, that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name())));
- name->setM(propName->d());
- ++it->arrayIndex;
- *attributes = QV4::Attr_Data;
- p->value = that->QV4::Object::get(propName);
- return;
+ ScopedString propName(scope, that->engine()->newString(QString::fromUtf8(mo->property(propertyIndex).name())));
+ ++propertyIndex;
+ if (attrs)
+ *attrs = QV4::Attr_Data;
+ if (pd)
+ pd->value = that->QV4::Object::get(propName);
+ return propName->toPropertyKey();
}
}
- QV4::Object::advanceIterator(m, it, name, index, p, attributes);
+
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+
+OwnPropertyKeyIterator *QQmlValueTypeWrapper::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new QQmlValueTypeWrapperOwnPropertyKeyIterator;
}
bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
@@ -355,21 +372,27 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con
return Encode(b->engine()->newString(result));
}
-ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QQmlValueTypeWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<QQmlValueTypeWrapper>());
+
+ if (!id.isString())
+ return Object::virtualGet(m, id, receiver, hasProperty);
+
const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
QV4::ExecutionEngine *v4 = r->engine();
+ Scope scope(v4);
+ ScopedString name(scope, id.asStringOrSymbol());
// Note: readReferenceValue() can change the reference->type.
if (const QQmlValueTypeReference *reference = r->as<QQmlValueTypeReference>()) {
if (!reference->readReferenceValue())
- return Primitive::undefinedValue().asReturnedValue();
+ return Value::undefinedValue().asReturnedValue();
}
- QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(name.getPointer(), nullptr, nullptr);
if (!result)
- return Object::get(m, name, hasProperty);
+ return Object::virtualGet(m, id, receiver, hasProperty);
if (hasProperty)
*hasProperty = true;
@@ -413,8 +436,11 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha
#undef VALUE_TYPE_ACCESSOR
}
-bool QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
+bool QQmlValueTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
+ if (!id.isString())
+ return Object::virtualPut(m, id, value, receiver);
+
Q_ASSERT(m->as<QQmlValueTypeWrapper>());
ExecutionEngine *v4 = static_cast<QQmlValueTypeWrapper *>(m)->engine();
Scope scope(v4);
@@ -435,8 +461,10 @@ bool QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
writeBackPropertyType = writebackProperty.userType();
}
+ ScopedString name(scope, id.asStringOrSymbol());
+
const QMetaObject *metaObject = r->d()->propertyCache()->metaObject();
- const QQmlPropertyData *pd = r->d()->propertyCache()->property(name, nullptr, nullptr);
+ const QQmlPropertyData *pd = r->d()->propertyCache()->property(name.getPointer(), nullptr, nullptr);
if (!pd)
return false;
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index f99d207d68..8db9474132 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -106,12 +106,11 @@ public:
int typeId() const;
bool write(QObject *target, int propertyIndex) const;
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static bool put(Managed *m, String *name, const Value &value);
- static bool isEqualTo(Managed *m, Managed *other);
- static PropertyAttributes query(const Managed *, String *name);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
-
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
+ static bool virtualIsEqualTo(Managed *m, Managed *other);
+ static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
static void initProto(ExecutionEngine *v4);
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
index 9a94ac6258..13c5524d96 100644
--- a/src/qml/qml/qqmlvme_p.h
+++ b/src/qml/qml/qqmlvme_p.h
@@ -124,6 +124,10 @@ private:
// Used to check that a QQmlVME that is interrupted mid-execution
// is still valid. Checks all the objects and contexts have not been
// deleted.
+//
+// VME stands for Virtual Machine Execution. QML files used to
+// be compiled to a byte code data structure that a virtual machine executed
+// (for constructing the tree of QObjects and setting properties).
class QQmlVMEGuard
{
public:
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index c1d3980b58..6bc469c836 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -106,8 +106,8 @@ void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *)
QV4::Scope scope(v4);
QV4::Scoped<QV4::MemberData> sp(scope, m_target->propertyAndMethodStorage.value());
if (sp) {
- QV4::MemberData::Index index{ sp->d(), sp->d()->values.values + m_index };
- index.set(v4, QV4::Primitive::nullValue());
+ QV4::PropertyIndex index{ sp->d(), sp->d()->values.values + m_index };
+ index.set(v4, QV4::Value::nullValue());
}
}
@@ -176,7 +176,7 @@ void QQmlVMEMetaObjectEndpoint::tryConnect()
}
-QQmlInterceptorMetaObject::QQmlInterceptorMetaObject(QObject *obj, QQmlPropertyCache *cache)
+QQmlInterceptorMetaObject::QQmlInterceptorMetaObject(QObject *obj, const QQmlRefPointer<QQmlPropertyCache> &cache)
: object(obj),
cache(cache),
interceptors(nullptr),
@@ -316,7 +316,7 @@ QAbstractDynamicMetaObject *QQmlInterceptorMetaObject::toDynamicMetaObject(QObje
QQmlVMEMetaObject::QQmlVMEMetaObject(QV4::ExecutionEngine *engine,
QObject *obj,
- QQmlPropertyCache *cache, QV4::CompiledData::CompilationUnit *qmlCompilationUnit, int qmlObjectId)
+ const QQmlRefPointer<QQmlPropertyCache> &cache, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &qmlCompilationUnit, int qmlObjectId)
: QQmlInterceptorMetaObject(obj, cache),
engine(engine),
ctxt(QQmlData::get(obj, true)->outerContext),
@@ -326,7 +326,7 @@ QQmlVMEMetaObject::QQmlVMEMetaObject(QV4::ExecutionEngine *engine,
QQmlData::get(obj)->hasVMEMetaObject = true;
if (compilationUnit && qmlObjectId >= 0) {
- compiledObject = compilationUnit->data->objectAt(qmlObjectId);
+ compiledObject = compilationUnit->objectAt(qmlObjectId);
if (compiledObject->nProperties || compiledObject->nFunctions) {
uint size = compiledObject->nProperties + compiledObject->nFunctions;
@@ -368,21 +368,21 @@ void QQmlVMEMetaObject::writeProperty(int id, int v)
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
- md->set(engine, id, QV4::Primitive::fromInt32(v));
+ md->set(engine, id, QV4::Value::fromInt32(v));
}
void QQmlVMEMetaObject::writeProperty(int id, bool v)
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
- md->set(engine, id, QV4::Primitive::fromBoolean(v));
+ md->set(engine, id, QV4::Value::fromBoolean(v));
}
void QQmlVMEMetaObject::writeProperty(int id, double v)
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
- md->set(engine, id, QV4::Primitive::fromDouble(v));
+ md->set(engine, id, QV4::Value::fromDouble(v));
}
void QQmlVMEMetaObject::writeProperty(int id, const QString& v)
@@ -1005,7 +1005,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) const
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md)
return (md->data() + id)->asReturnedValue();
- return QV4::Primitive::undefinedValue().asReturnedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) const
@@ -1122,7 +1122,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::vmeMethod(int index) const
return parentVMEMetaObject()->vmeMethod(index);
}
if (!compiledObject)
- return QV4::Primitive::undefinedValue().asReturnedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
const int plainSignals = compiledObject->nSignals + compiledObject->nProperties + compiledObject->nAliases;
Q_ASSERT(index >= (methodOffset() + plainSignals) && index < (methodOffset() + plainSignals + int(compiledObject->nFunctions)));
return method(index - methodOffset() - plainSignals);
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 0c82686d47..dbcc9d2884 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -94,7 +94,7 @@ public:
class Q_QML_PRIVATE_EXPORT QQmlInterceptorMetaObject : public QAbstractDynamicMetaObject
{
public:
- QQmlInterceptorMetaObject(QObject *obj, QQmlPropertyCache *cache);
+ QQmlInterceptorMetaObject(QObject *obj, const QQmlRefPointer<QQmlPropertyCache> &cache);
~QQmlInterceptorMetaObject() override;
void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor);
@@ -104,7 +104,7 @@ public:
QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *o) override;
// Used by auto-tests for inspection
- QQmlPropertyCache *propertyCache() const { return cache; }
+ QQmlPropertyCache *propertyCache() const { return cache.data(); }
bool intercepts(QQmlPropertyIndex propertyIndex) const
{
@@ -146,7 +146,7 @@ class QQmlVMEMetaObjectEndpoint;
class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QQmlInterceptorMetaObject
{
public:
- QQmlVMEMetaObject(QV4::ExecutionEngine *engine, QObject *obj, QQmlPropertyCache *cache, QV4::CompiledData::CompilationUnit *qmlCompilationUnit, int qmlObjectId);
+ QQmlVMEMetaObject(QV4::ExecutionEngine *engine, QObject *obj, const QQmlRefPointer<QQmlPropertyCache> &cache, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &qmlCompilationUnit, int qmlObjectId);
~QQmlVMEMetaObject() override;
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 567d83f3ee..9f629f974d 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -228,8 +228,7 @@ public:
static ReturnedValue create(ExecutionEngine *, NodeImpl *, const QList<NodeImpl *> &);
// JS API
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
};
void Heap::NamedNodeMap::init(NodeImpl *data, const QList<NodeImpl *> &list)
@@ -250,8 +249,7 @@ public:
V4_NEEDS_DESTROY
// JS API
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
// C++ API
static ReturnedValue create(ExecutionEngine *, NodeImpl *);
@@ -595,7 +593,7 @@ ReturnedValue NodePrototype::getProto(ExecutionEngine *v4)
Scope scope(v4);
QQmlXMLHttpRequestData *d = xhrdata(v4);
if (d->nodePrototype.isUndefined()) {
- ScopedObject p(scope, v4->memoryManager->allocObject<NodePrototype>());
+ ScopedObject p(scope, v4->memoryManager->allocate<NodePrototype>());
d->nodePrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
@@ -606,12 +604,12 @@ ReturnedValue Node::create(ExecutionEngine *v4, NodeImpl *data)
{
Scope scope(v4);
- Scoped<Node> instance(scope, v4->memoryManager->allocObject<Node>(data));
+ Scoped<Node> instance(scope, v4->memoryManager->allocate<Node>(data));
ScopedObject p(scope);
switch (data->type) {
case NodeImpl::Attr:
- instance->setPrototype((p = Attr::prototype(v4)));
+ instance->setPrototypeUnchecked((p = Attr::prototype(v4)));
break;
case NodeImpl::Comment:
case NodeImpl::Document:
@@ -623,13 +621,13 @@ ReturnedValue Node::create(ExecutionEngine *v4, NodeImpl *data)
case NodeImpl::ProcessingInstruction:
return Encode::undefined();
case NodeImpl::CDATA:
- instance->setPrototype((p = CDATA::prototype(v4)));
+ instance->setPrototypeUnchecked((p = CDATA::prototype(v4)));
break;
case NodeImpl::Text:
- instance->setPrototype((p = Text::prototype(v4)));
+ instance->setPrototypeUnchecked((p = Text::prototype(v4)));
break;
case NodeImpl::Element:
- instance->setPrototype((p = Element::prototype(v4)));
+ instance->setPrototypeUnchecked((p = Element::prototype(v4)));
break;
}
@@ -643,7 +641,7 @@ ReturnedValue Element::prototype(ExecutionEngine *engine)
Scope scope(engine);
ScopedObject p(scope, engine->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = NodePrototype::getProto(engine)));
+ p->setPrototypeUnchecked((pp = NodePrototype::getProto(engine)));
p->defineAccessorProperty(QStringLiteral("tagName"), NodePrototype::method_get_nodeName, nullptr);
d->elementPrototype.set(engine, p);
engine->v8Engine->freezeObject(p);
@@ -658,7 +656,7 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine)
Scope scope(engine);
ScopedObject p(scope, engine->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = NodePrototype::getProto(engine)));
+ p->setPrototypeUnchecked((pp = NodePrototype::getProto(engine)));
p->defineAccessorProperty(QStringLiteral("name"), method_name, nullptr);
p->defineAccessorProperty(QStringLiteral("value"), method_value, nullptr);
p->defineAccessorProperty(QStringLiteral("ownerElement"), method_ownerElement, nullptr);
@@ -715,7 +713,7 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4)
Scope scope(v4);
ScopedObject p(scope, v4->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = NodePrototype::getProto(v4)));
+ p->setPrototypeUnchecked((pp = NodePrototype::getProto(v4)));
p->defineAccessorProperty(QStringLiteral("data"), NodePrototype::method_get_nodeValue, nullptr);
p->defineAccessorProperty(QStringLiteral("length"), method_length, nullptr);
d->characterDataPrototype.set(v4, p);
@@ -751,7 +749,7 @@ ReturnedValue Text::prototype(ExecutionEngine *v4)
Scope scope(v4);
ScopedObject p(scope, v4->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = CharacterData::prototype(v4)));
+ p->setPrototypeUnchecked((pp = CharacterData::prototype(v4)));
p->defineAccessorProperty(QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, nullptr);
p->defineAccessorProperty(QStringLiteral("wholeText"), method_wholeText, nullptr);
d->textPrototype.set(v4, p);
@@ -768,7 +766,7 @@ ReturnedValue CDATA::prototype(ExecutionEngine *v4)
Scope scope(v4);
ScopedObject p(scope, v4->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = Text::prototype(v4)));
+ p->setPrototypeUnchecked((pp = Text::prototype(v4)));
d->cdataPrototype.set(v4, p);
v4->v8Engine->freezeObject(p);
}
@@ -782,7 +780,7 @@ ReturnedValue Document::prototype(ExecutionEngine *v4)
Scope scope(v4);
ScopedObject p(scope, v4->newObject());
ScopedObject pp(scope);
- p->setPrototype((pp = NodePrototype::getProto(v4)));
+ p->setPrototypeUnchecked((pp = NodePrototype::getProto(v4)));
p->defineAccessorProperty(QStringLiteral("xmlVersion"), method_xmlVersion, nullptr);
p->defineAccessorProperty(QStringLiteral("xmlEncoding"), method_xmlEncoding, nullptr);
p->defineAccessorProperty(QStringLiteral("xmlStandalone"), method_xmlStandalone, nullptr);
@@ -876,10 +874,10 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data)
return Encode::null();
}
- ScopedObject instance(scope, v4->memoryManager->allocObject<Node>(document));
+ ScopedObject instance(scope, v4->memoryManager->allocate<Node>(document));
document->release(); // the GC should own the NodeImpl via Node now
ScopedObject p(scope);
- instance->setPrototype((p = Document::prototype(v4)));
+ instance->setPrototypeUnchecked((p = Document::prototype(v4)));
return instance.asReturnedValue();
}
@@ -888,33 +886,33 @@ bool Node::isNull() const
return d()->d == nullptr;
}
-ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue NamedNodeMap::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<NamedNodeMap>());
+
const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
QV4::ExecutionEngine *v4 = r->engine();
- if ((int)index < r->d()->list().count()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+
+ if ((int)index < r->d()->list().count()) {
+ if (hasProperty)
+ *hasProperty = true;
+ return Node::create(v4, r->d()->list().at(index));
+ }
if (hasProperty)
- *hasProperty = true;
- return Node::create(v4, r->d()->list().at(index));
+ *hasProperty = false;
+ return Encode::undefined();
}
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
-}
-ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasProperty)
-{
- Q_ASSERT(m->as<NamedNodeMap>());
- const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
- QV4::ExecutionEngine *v4 = r->engine();
+ if (id.isSymbol())
+ return Object::virtualGet(m, id, receiver, hasProperty);
- name->makeIdentifier();
- if (name->equals(v4->id_length()))
- return Primitive::fromInt32(r->d()->list().count()).asReturnedValue();
+ if (id == v4->id_length()->propertyKey())
+ return Value::fromInt32(r->d()->list().count()).asReturnedValue();
- QString str = name->toQString();
+ QString str = id.toQString();
for (int ii = 0; ii < r->d()->list().count(); ++ii) {
if (r->d()->list().at(ii)->name == str) {
if (hasProperty)
@@ -930,41 +928,35 @@ ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasPropert
ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QList<NodeImpl *> &list)
{
- return (v4->memoryManager->allocObject<NamedNodeMap>(data, list))->asReturnedValue();
+ return (v4->memoryManager->allocate<NamedNodeMap>(data, list))->asReturnedValue();
}
-ReturnedValue NodeList::getIndexed(const Managed *m, uint index, bool *hasProperty)
+ReturnedValue NodeList::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
Q_ASSERT(m->as<NodeList>());
const NodeList *r = static_cast<const NodeList *>(m);
QV4::ExecutionEngine *v4 = r->engine();
- if ((int)index < r->d()->d->children.count()) {
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ if ((int)index < r->d()->d->children.count()) {
+ if (hasProperty)
+ *hasProperty = true;
+ return Node::create(v4, r->d()->d->children.at(index));
+ }
if (hasProperty)
- *hasProperty = true;
- return Node::create(v4, r->d()->d->children.at(index));
+ *hasProperty = false;
+ return Encode::undefined();
}
- if (hasProperty)
- *hasProperty = false;
- return Encode::undefined();
-}
-
-ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty)
-{
- Q_ASSERT(m->as<NodeList>());
- const NodeList *r = static_cast<const NodeList *>(m);
- QV4::ExecutionEngine *v4 = r->engine();
- name->makeIdentifier();
-
- if (name->equals(v4->id_length()))
- return Primitive::fromInt32(r->d()->d->children.count()).asReturnedValue();
- return Object::get(m, name, hasProperty);
+ if (id == v4->id_length()->propertyKey())
+ return Value::fromInt32(r->d()->d->children.count()).asReturnedValue();
+ return Object::virtualGet(m, id, receiver, hasProperty);
}
ReturnedValue NodeList::create(ExecutionEngine *v4, NodeImpl *data)
{
- return (v4->memoryManager->allocObject<NodeList>(data))->asReturnedValue();
+ return (v4->memoryManager->allocate<NodeList>(data))->asReturnedValue();
}
ReturnedValue Document::method_documentElement(const FunctionObject *b, const Value *thisObject, const Value *, int)
@@ -1080,7 +1072,8 @@ private:
QQmlContextDataRef m_qmlContext;
bool m_wasConstructedWithQmlContext = true;
- static void dispatchCallbackNow(Object *thisObj);
+ void dispatchCallbackNow(Object *thisObj);
+ static void dispatchCallbackNow(Object *thisObj, bool done, bool error);
void dispatchCallbackSafely();
int m_status;
@@ -1561,22 +1554,37 @@ const QByteArray &QQmlXMLHttpRequest::rawResponseBody() const
void QQmlXMLHttpRequest::dispatchCallbackNow(Object *thisObj)
{
+ dispatchCallbackNow(thisObj, m_state == Done, m_errorFlag);
+}
+
+void QQmlXMLHttpRequest::dispatchCallbackNow(Object *thisObj, bool done, bool error)
+{
Q_ASSERT(thisObj);
- QV4::Scope scope(thisObj->engine());
- ScopedString s(scope, scope.engine->newString(QStringLiteral("onreadystatechange")));
- ScopedFunctionObject callback(scope, thisObj->get(s));
- if (!callback) {
- // not an error, but no onreadystatechange function to call.
- return;
- }
+ const auto dispatch = [thisObj](const QString &eventName) {
+ QV4::Scope scope(thisObj->engine());
+ ScopedString s(scope, scope.engine->newString(eventName));
+ ScopedFunctionObject callback(scope, thisObj->get(s));
+ // not an error, but no event handler to call.
+ if (!callback)
+ return;
+
+ QV4::JSCallData jsCallData(scope);
+ callback->call(jsCallData);
- QV4::JSCallData jsCallData(scope);
- callback->call(jsCallData);
+ if (scope.engine->hasException) {
+ QQmlError error = scope.engine->catchExceptionAsQmlError();
+ QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error);
+ }
+ };
- if (scope.engine->hasException) {
- QQmlError error = scope.engine->catchExceptionAsQmlError();
- QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error);
+ dispatch(QStringLiteral("onreadystatechange"));
+ if (done) {
+ if (error)
+ dispatch(QStringLiteral("onerror"));
+ else
+ dispatch(QStringLiteral("onload"));
+ dispatch(QStringLiteral("onloadend"));
}
}
@@ -1637,19 +1645,19 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
{
V4_OBJECT2(QQmlXMLHttpRequestCtor, FunctionObject)
- static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *, int)
+ static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *)
{
Scope scope(f->engine());
const QQmlXMLHttpRequestCtor *ctor = static_cast<const QQmlXMLHttpRequestCtor *>(f);
QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(scope.engine->v8Engine->networkAccessManager(), scope.engine);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, scope.engine->memoryManager->allocObject<QQmlXMLHttpRequestWrapper>(r));
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, scope.engine->memoryManager->allocate<QQmlXMLHttpRequestWrapper>(r));
ScopedObject proto(scope, ctor->d()->proto);
- w->setPrototype(proto);
+ w->setPrototypeUnchecked(proto);
return w.asReturnedValue();
}
- static ReturnedValue call(const FunctionObject *, const Value *, const Value *, int) {
+ static ReturnedValue virtualCall(const FunctionObject *, const Value *, const Value *, int) {
return Encode::undefined();
}
@@ -1682,11 +1690,11 @@ void Heap::QQmlXMLHttpRequestCtor::init(ExecutionEngine *engine)
Scope scope(engine);
Scoped<QV4::QQmlXMLHttpRequestCtor> ctor(scope, this);
- ctor->defineReadonlyProperty(QStringLiteral("UNSENT"), Primitive::fromInt32(0));
- ctor->defineReadonlyProperty(QStringLiteral("OPENED"), Primitive::fromInt32(1));
- ctor->defineReadonlyProperty(QStringLiteral("HEADERS_RECEIVED"), Primitive::fromInt32(2));
- ctor->defineReadonlyProperty(QStringLiteral("LOADING"), Primitive::fromInt32(3));
- ctor->defineReadonlyProperty(QStringLiteral("DONE"), Primitive::fromInt32(4));
+ ctor->defineReadonlyProperty(QStringLiteral("UNSENT"), Value::fromInt32(0));
+ ctor->defineReadonlyProperty(QStringLiteral("OPENED"), Value::fromInt32(1));
+ ctor->defineReadonlyProperty(QStringLiteral("HEADERS_RECEIVED"), Value::fromInt32(2));
+ ctor->defineReadonlyProperty(QStringLiteral("LOADING"), Value::fromInt32(3));
+ ctor->defineReadonlyProperty(QStringLiteral("DONE"), Value::fromInt32(4));
if (!ctor->d()->proto)
ctor->setupProto();
ScopedString s(scope, engine->id_prototype());
@@ -1722,11 +1730,11 @@ void QQmlXMLHttpRequestCtor::setupProto()
p->defineAccessorProperty(QStringLiteral("responseType"), method_get_responseType, method_set_responseType);
// State values
- p->defineReadonlyProperty(QStringLiteral("UNSENT"), Primitive::fromInt32(0));
- p->defineReadonlyProperty(QStringLiteral("OPENED"), Primitive::fromInt32(1));
- p->defineReadonlyProperty(QStringLiteral("HEADERS_RECEIVED"), Primitive::fromInt32(2));
- p->defineReadonlyProperty(QStringLiteral("LOADING"), Primitive::fromInt32(3));
- p->defineReadonlyProperty(QStringLiteral("DONE"), Primitive::fromInt32(4));
+ p->defineReadonlyProperty(QStringLiteral("UNSENT"), Value::fromInt32(0));
+ p->defineReadonlyProperty(QStringLiteral("OPENED"), Value::fromInt32(1));
+ p->defineReadonlyProperty(QStringLiteral("HEADERS_RECEIVED"), Value::fromInt32(2));
+ p->defineReadonlyProperty(QStringLiteral("LOADING"), Value::fromInt32(3));
+ p->defineReadonlyProperty(QStringLiteral("DONE"), Value::fromInt32(4));
}
@@ -2049,7 +2057,7 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
{
Scope scope(v4);
- Scoped<QQmlXMLHttpRequestCtor> ctor(scope, v4->memoryManager->allocObject<QQmlXMLHttpRequestCtor>(v4));
+ Scoped<QQmlXMLHttpRequestCtor> ctor(scope, v4->memoryManager->allocate<QQmlXMLHttpRequestCtor>(v4));
ScopedString s(scope, v4->newString(QStringLiteral("XMLHttpRequest")));
v4->globalObject->defineReadonlyProperty(s, ctor);
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index f2836d8301..7515ef8dcc 100644
--- a/src/qml/qml/qqmlxmlhttprequest_p.h
+++ b/src/qml/qml/qqmlxmlhttprequest_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qglobal.h>
#include <private/qqmlglobal_p.h>
-#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
+QT_REQUIRE_CONFIG(qml_xml_http_request);
QT_BEGIN_NAMESPACE
@@ -64,7 +64,5 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *);
QT_END_NAMESPACE
-#endif // xmlstreamreader && qml_network
-
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index f04bee7f19..f713efb289 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -44,7 +44,9 @@
#include <private/qqmlcomponent_p.h>
#include <private/qqmlloggingcategory_p.h>
#include <private/qqmlstringconverters_p.h>
+#if QT_CONFIG(qml_locale)
#include <private/qqmllocale_p.h>
+#endif
#include <private/qv8engine_p.h>
#include <private/qqmldelayedcallqueue_p.h>
#include <QFileInfo>
@@ -65,6 +67,7 @@
#include <private/qv4jsonobject_p.h>
#include <private/qv4objectproto_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qv4stackframe_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
@@ -107,8 +110,8 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine)
{
ScopedString str(scope);
ScopedValue v(scope);
- o->put((str = scope.engine->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0)));
- o->put((str = scope.engine->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1)));
+ o->put((str = scope.engine->newString(QStringLiteral("Asynchronous"))), (v = QV4::Value::fromInt32(0)));
+ o->put((str = scope.engine->newString(QStringLiteral("Synchronous"))), (v = QV4::Value::fromInt32(1)));
}
o->defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include);
@@ -138,7 +141,9 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine)
o->defineDefaultProperty(QStringLiteral("btoa"), QV4::QtObject::method_btoa);
o->defineDefaultProperty(QStringLiteral("atob"), QV4::QtObject::method_atob);
o->defineDefaultProperty(QStringLiteral("resolvedUrl"), QV4::QtObject::method_resolvedUrl);
+#if QT_CONFIG(qml_locale)
o->defineDefaultProperty(QStringLiteral("locale"), QV4::QtObject::method_locale);
+#endif
o->defineDefaultProperty(QStringLiteral("binding"), QV4::QtObject::method_binding);
if (qmlEngine) {
@@ -178,7 +183,7 @@ ReturnedValue QtObject::findAndAdd(const QString *name, bool &foundProperty) con
QMetaEnum enumerator = qtMetaObject->enumerator(d()->enumeratorIterator);
for (int keyCount = enumerator.keyCount(); d()->keyIterator < keyCount; ++d()->keyIterator) {
key = scope.engine->newString(QString::fromUtf8(enumerator.key(d()->keyIterator)));
- value = QV4::Primitive::fromInt32(enumerator.value(d()->keyIterator));
+ value = QV4::Value::fromInt32(enumerator.value(d()->keyIterator));
o->put(key, value);
if (name && key->toQString() == *name) {
++d()->keyIterator;
@@ -193,35 +198,34 @@ ReturnedValue QtObject::findAndAdd(const QString *name, bool &foundProperty) con
return Encode::undefined();
}
-ReturnedValue QtObject::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue QtObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
bool hasProp = false;
if (hasProperty == nullptr) {
hasProperty = &hasProp;
}
- ReturnedValue ret = QV4::Object::get(m, name, hasProperty);
+ ReturnedValue ret = QV4::Object::virtualGet(m, id, receiver, hasProperty);
if (*hasProperty) {
return ret;
}
auto that = static_cast<const QtObject*>(m);
if (!that->d()->isComplete()) {
- const QString key = name->toQString();
+ const QString key = id.toQString();
ret = that->findAndAdd(&key, *hasProperty);
}
return ret;
}
-void QtObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
+OwnPropertyKeyIterator *QtObject::virtualOwnPropertyKeys(const Object *m, Value *target)
{
- auto that = static_cast<QtObject*>(m);
- if (!that->d()->isComplete()) {
- that->addAll();
- }
+ auto that = static_cast<const QtObject*>(m);
+ if (!that->d()->isComplete())
+ const_cast<QtObject *>(that)->addAll();
- QV4::Object::advanceIterator(m, it, name, index, p, attributes);
+ return Object::virtualOwnPropertyKeys(m, target);
}
/*!
@@ -1102,11 +1106,11 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va
const QQmlError &error = errors.at(ii);
errorstr += QLatin1String("\n ") + error.toString();
qmlerror = v4->newObject();
- qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))), (v = QV4::Primitive::fromInt32(error.line())));
- qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))), (v = QV4::Primitive::fromInt32(error.column())));
+ qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))), (v = QV4::Value::fromInt32(error.line())));
+ qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))), (v = QV4::Value::fromInt32(error.column())));
qmlerror->put((s = v4->newString(QStringLiteral("fileName"))), (v = v4->newString(error.url().toString())));
qmlerror->put((s = v4->newString(QStringLiteral("message"))), (v = v4->newString(error.description())));
- qmlerrors->putIndexed(ii, qmlerror);
+ qmlerrors->put(ii, qmlerror);
}
v = v4->newString(errorstr);
@@ -1152,7 +1156,7 @@ ReturnedValue QtObject::method_createQmlObject(const FunctionObject *b, const Va
if (!parentArg)
THROW_GENERIC_ERROR("Qt.createQmlObject(): Missing parent object");
- QQmlTypeData *typeData = QQmlEnginePrivate::get(engine)->typeLoader.getType(
+ QQmlRefPointer<QQmlTypeData> typeData = QQmlEnginePrivate::get(engine)->typeLoader.getType(
qml.toUtf8(), url, QQmlTypeLoader::Synchronous);
Q_ASSERT(typeData->isCompleteOrError());
QQmlComponent component(engine);
@@ -1309,6 +1313,7 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va
return QV4::QObjectWrapper::wrap(scope.engine, c);
}
+#if QT_CONFIG(qml_locale)
/*!
\qmlmethod Qt::locale(name)
@@ -1343,6 +1348,7 @@ ReturnedValue QtObject::method_locale(const FunctionObject *b, const Value *, co
return QQmlLocale::locale(scope.engine, code);
}
+#endif
void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *bindingFunction)
{
@@ -1401,10 +1407,6 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction);
\snippet qml/qtBinding.4.qml 0
- \note In \l {Qt Quick 1}, all function assignments were treated as
- binding assignments. The Qt.binding() function is new to
- \l {Qt Quick}{Qt Quick 2}.
-
\since 5.0
*/
ReturnedValue QtObject::method_binding(const FunctionObject *b, const Value *, const Value *argv, int argc)
@@ -1416,7 +1418,7 @@ ReturnedValue QtObject::method_binding(const FunctionObject *b, const Value *, c
if (!f)
THROW_TYPE_ERROR_WITH_MESSAGE("binding(): argument (binding expression) must be a function");
- return Encode(scope.engine->memoryManager->allocObject<QQmlBindingFunction>(f));
+ return Encode(scope.engine->memoryManager->allocate<QQmlBindingFunction>(f));
}
@@ -1551,7 +1553,7 @@ static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, cons
if (i != start)
result.append(QLatin1Char(' '));
- if (argv[i].as<ArrayObject>())
+ if (argv[i].isManaged() && argv[i].managed()->isArrayLike())
result += QLatin1Char('[') + argv[i].toQStringNoThrow() + QLatin1Char(']');
else
result.append(argv[i].toQStringNoThrow());
@@ -1795,7 +1797,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext
globalObject->defineDefaultProperty(QStringLiteral("print"), QV4::ConsoleObject::method_log);
- QV4::ScopedObject console(scope, globalObject->engine()->memoryManager->allocObject<QV4::ConsoleObject>());
+ QV4::ScopedObject console(scope, globalObject->engine()->memoryManager->allocate<QV4::ConsoleObject>());
globalObject->defineDefaultProperty(QStringLiteral("console"), console);
}
@@ -1850,6 +1852,10 @@ ReturnedValue GlobalExtensions::method_qsTranslate(const FunctionObject *b, cons
if (argc > i)
n = argv[i].toInt32();
+ if (QQmlEnginePrivate *ep = (scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : nullptr))
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureTranslation();
+
QString result = QCoreApplication::translate(context.toUtf8().constData(),
text.toUtf8().constData(),
comment.toUtf8().constData(),
@@ -1953,6 +1959,10 @@ ReturnedValue GlobalExtensions::method_qsTr(const FunctionObject *b, const Value
if (argc > 2)
n = argv[2].toInt32();
+ if (QQmlEnginePrivate *ep = (scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : nullptr))
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureTranslation();
+
QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(),
comment.toUtf8().constData(), n);
@@ -2033,6 +2043,10 @@ ReturnedValue GlobalExtensions::method_qsTrId(const FunctionObject *b, const Val
if (argc > 1)
n = argv[1].toInt32();
+ if (QQmlEnginePrivate *ep = (scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : nullptr))
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureTranslation();
+
return Encode(scope.engine->newString(qtTrId(argv[0].toQStringNoThrow().toUtf8().constData(), n)));
}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index ee3b5f7d6e..d87b83ba10 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -93,8 +93,8 @@ struct QtObject : Object
{
V4_OBJECT2(QtObject, Object)
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_rgba(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
@@ -126,7 +126,9 @@ struct QtObject : Object
static ReturnedValue method_resolvedUrl(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_createQmlObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_createComponent(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+#if QT_CONFIG(qml_locale)
static ReturnedValue method_locale(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
+#endif
static ReturnedValue method_binding(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_get_platform(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
@@ -186,6 +188,11 @@ struct QQmlBindingFunction : public QV4::FunctionObject
QQmlSourceLocation currentLocation() const; // from caller stack trace
};
+inline bool FunctionObject::isBinding() const
+{
+ return d()->vtable() == QQmlBindingFunction::staticVTable();
+}
+
}
QT_END_NAMESPACE
diff --git a/src/qml/qml/v8/qv4domerrors.cpp b/src/qml/qml/v8/qv4domerrors.cpp
index b680aa07da..7ad37d098f 100644
--- a/src/qml/qml/v8/qv4domerrors.cpp
+++ b/src/qml/qml/v8/qv4domerrors.cpp
@@ -48,23 +48,23 @@ void qt_add_domexceptions(ExecutionEngine *e)
{
Scope scope(e);
ScopedObject domexception(scope, e->newObject());
- domexception->defineReadonlyProperty(QStringLiteral("INDEX_SIZE_ERR"), Primitive::fromInt32(DOMEXCEPTION_INDEX_SIZE_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("DOMSTRING_SIZE_ERR"), Primitive::fromInt32(DOMEXCEPTION_DOMSTRING_SIZE_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("HIERARCHY_REQUEST_ERR"), Primitive::fromInt32(DOMEXCEPTION_HIERARCHY_REQUEST_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("WRONG_DOCUMENT_ERR"), Primitive::fromInt32(DOMEXCEPTION_WRONG_DOCUMENT_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("INVALID_CHARACTER_ERR"), Primitive::fromInt32(DOMEXCEPTION_INVALID_CHARACTER_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("NO_DATA_ALLOWED_ERR"), Primitive::fromInt32(DOMEXCEPTION_NO_DATA_ALLOWED_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("NO_MODIFICATION_ALLOWED_ERR"), Primitive::fromInt32(DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("NOT_FOUND_ERR"), Primitive::fromInt32(DOMEXCEPTION_NOT_FOUND_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("NOT_SUPPORTED_ERR"), Primitive::fromInt32(DOMEXCEPTION_NOT_SUPPORTED_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("INUSE_ATTRIBUTE_ERR"), Primitive::fromInt32(DOMEXCEPTION_INUSE_ATTRIBUTE_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("INVALID_STATE_ERR"), Primitive::fromInt32(DOMEXCEPTION_INVALID_STATE_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("SYNTAX_ERR"), Primitive::fromInt32(DOMEXCEPTION_SYNTAX_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("INVALID_MODIFICATION_ERR"), Primitive::fromInt32(DOMEXCEPTION_INVALID_MODIFICATION_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("NAMESPACE_ERR"), Primitive::fromInt32(DOMEXCEPTION_NAMESPACE_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("INVALID_ACCESS_ERR"), Primitive::fromInt32(DOMEXCEPTION_INVALID_ACCESS_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("VALIDATION_ERR"), Primitive::fromInt32(DOMEXCEPTION_VALIDATION_ERR));
- domexception->defineReadonlyProperty(QStringLiteral("TYPE_MISMATCH_ERR"), Primitive::fromInt32(DOMEXCEPTION_TYPE_MISMATCH_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INDEX_SIZE_ERR"), Value::fromInt32(DOMEXCEPTION_INDEX_SIZE_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("DOMSTRING_SIZE_ERR"), Value::fromInt32(DOMEXCEPTION_DOMSTRING_SIZE_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("HIERARCHY_REQUEST_ERR"), Value::fromInt32(DOMEXCEPTION_HIERARCHY_REQUEST_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("WRONG_DOCUMENT_ERR"), Value::fromInt32(DOMEXCEPTION_WRONG_DOCUMENT_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INVALID_CHARACTER_ERR"), Value::fromInt32(DOMEXCEPTION_INVALID_CHARACTER_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("NO_DATA_ALLOWED_ERR"), Value::fromInt32(DOMEXCEPTION_NO_DATA_ALLOWED_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("NO_MODIFICATION_ALLOWED_ERR"), Value::fromInt32(DOMEXCEPTION_NO_MODIFICATION_ALLOWED_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("NOT_FOUND_ERR"), Value::fromInt32(DOMEXCEPTION_NOT_FOUND_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("NOT_SUPPORTED_ERR"), Value::fromInt32(DOMEXCEPTION_NOT_SUPPORTED_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INUSE_ATTRIBUTE_ERR"), Value::fromInt32(DOMEXCEPTION_INUSE_ATTRIBUTE_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INVALID_STATE_ERR"), Value::fromInt32(DOMEXCEPTION_INVALID_STATE_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("SYNTAX_ERR"), Value::fromInt32(DOMEXCEPTION_SYNTAX_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INVALID_MODIFICATION_ERR"), Value::fromInt32(DOMEXCEPTION_INVALID_MODIFICATION_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("NAMESPACE_ERR"), Value::fromInt32(DOMEXCEPTION_NAMESPACE_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("INVALID_ACCESS_ERR"), Value::fromInt32(DOMEXCEPTION_INVALID_ACCESS_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("VALIDATION_ERR"), Value::fromInt32(DOMEXCEPTION_VALIDATION_ERR));
+ domexception->defineReadonlyProperty(QStringLiteral("TYPE_MISMATCH_ERR"), Value::fromInt32(DOMEXCEPTION_TYPE_MISMATCH_ERR));
e->globalObject->defineDefaultProperty(QStringLiteral("DOMException"), domexception);
}
diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h
index 06a70a13e9..1842e46a9c 100644
--- a/src/qml/qml/v8/qv4domerrors_p.h
+++ b/src/qml/qml/v8/qv4domerrors_p.h
@@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE
#define THROW_DOM(error, string) { \
QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \
QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Value::fromInt32(error))); \
return scope.engine->throwError(ex); \
}
diff --git a/src/qml/qml/v8/qv4sqlerrors.cpp b/src/qml/qml/v8/qv4sqlerrors.cpp
index db8d130cef..3f1744a687 100644
--- a/src/qml/qml/v8/qv4sqlerrors.cpp
+++ b/src/qml/qml/v8/qv4sqlerrors.cpp
@@ -49,14 +49,14 @@ void qt_add_sqlexceptions(QV4::ExecutionEngine *engine)
{
Scope scope(engine);
ScopedObject sqlexception(scope, engine->newObject());
- sqlexception->defineReadonlyProperty(QStringLiteral("UNKNOWN_ERR"), Primitive::fromInt32(SQLEXCEPTION_UNKNOWN_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("DATABASE_ERR"), Primitive::fromInt32(SQLEXCEPTION_DATABASE_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("VERSION_ERR"), Primitive::fromInt32(SQLEXCEPTION_VERSION_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("TOO_LARGE_ERR"), Primitive::fromInt32(SQLEXCEPTION_TOO_LARGE_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("QUOTA_ERR"), Primitive::fromInt32(SQLEXCEPTION_QUOTA_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("SYNTAX_ERR"), Primitive::fromInt32(SQLEXCEPTION_SYNTAX_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("CONSTRAINT_ERR"), Primitive::fromInt32(SQLEXCEPTION_CONSTRAINT_ERR));
- sqlexception->defineReadonlyProperty(QStringLiteral("TIMEOUT_ERR"), Primitive::fromInt32(SQLEXCEPTION_TIMEOUT_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("UNKNOWN_ERR"), Value::fromInt32(SQLEXCEPTION_UNKNOWN_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("DATABASE_ERR"), Value::fromInt32(SQLEXCEPTION_DATABASE_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("VERSION_ERR"), Value::fromInt32(SQLEXCEPTION_VERSION_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("TOO_LARGE_ERR"), Value::fromInt32(SQLEXCEPTION_TOO_LARGE_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("QUOTA_ERR"), Value::fromInt32(SQLEXCEPTION_QUOTA_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("SYNTAX_ERR"), Value::fromInt32(SQLEXCEPTION_SYNTAX_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("CONSTRAINT_ERR"), Value::fromInt32(SQLEXCEPTION_CONSTRAINT_ERR));
+ sqlexception->defineReadonlyProperty(QStringLiteral("TIMEOUT_ERR"), Value::fromInt32(SQLEXCEPTION_TIMEOUT_ERR));
engine->globalObject->defineDefaultProperty(QStringLiteral("SQLException"), sqlexception);
}
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 038a75d50a..d76344b613 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -39,14 +39,21 @@
#include "qv8engine_p.h"
+#if QT_CONFIG(qml_sequence_object)
#include "qv4sequenceobject_p.h"
+#endif
+
#include "private/qjsengine_p.h"
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmllist_p.h>
#include <private/qqmlengine_p.h>
+#if QT_CONFIG(qml_xml_http_request)
#include <private/qqmlxmlhttprequest_p.h>
+#endif
+#if QT_CONFIG(qml_locale)
#include <private/qqmllocale_p.h>
+#endif
#include <private/qqmlglobal_p.h>
#include <private/qqmlmemoryprofiler_p.h>
#include <private/qqmlplatform_p.h>
@@ -78,6 +85,7 @@
#include <private/qv4script_p.h>
#include <private/qv4include_p.h>
#include <private/qv4jsonobject_p.h>
+#include <private/qv4identifiertable_p.h>
Q_DECLARE_METATYPE(QList<int>)
@@ -123,17 +131,20 @@ static void restoreJSValue(QDataStream &stream, void *data)
}
}
-QV8Engine::QV8Engine(QJSEngine *qq, QV4::ExecutionEngine *v4)
- : q(qq)
- , m_engine(nullptr)
+QV8Engine::QV8Engine(QV4::ExecutionEngine *v4)
+ : m_engine(nullptr)
, m_v4Engine(v4)
+#if QT_CONFIG(qml_xml_http_request)
, m_xmlHttpRequestData(nullptr)
+#endif
{
+#ifndef Q_OS_WASM // wasm does not have working simd QTBUG-63924
#ifdef Q_PROCESSOR_X86_32
if (!qCpuHasFeature(SSE2)) {
qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
}
#endif
+#endif
QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine");
qMetaTypeId<QJSValue>();
@@ -157,7 +168,7 @@ QV8Engine::~QV8Engine()
qDeleteAll(m_extensionData);
m_extensionData.clear();
-#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
+#if QT_CONFIG(qml_xml_http_request)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = nullptr;
#endif
@@ -180,14 +191,16 @@ void QV8Engine::initializeGlobal()
QV4::Scope scope(m_v4Engine);
QV4::GlobalExtensions::init(m_v4Engine->globalObject, QJSEngine::AllExtensions);
- QV4::ScopedObject qt(scope, m_v4Engine->memoryManager->allocObject<QV4::QtObject>(m_engine));
+ QV4::ScopedObject qt(scope, m_v4Engine->memoryManager->allocate<QV4::QtObject>(m_engine));
m_v4Engine->globalObject->defineDefaultProperty(QStringLiteral("Qt"), qt);
+#if QT_CONFIG(qml_locale)
QQmlLocale::registerStringLocaleCompare(m_v4Engine);
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
+#endif
-#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
+#if QT_CONFIG(qml_xml_http_request)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
#endif
@@ -196,8 +209,10 @@ void QV8Engine::initializeGlobal()
{
for (uint i = 0; i < m_v4Engine->globalObject->internalClass()->size; ++i) {
- if (m_v4Engine->globalObject->internalClass()->nameMap.at(i))
- m_illegalNames.insert(m_v4Engine->globalObject->internalClass()->nameMap.at(i)->string);
+ if (m_v4Engine->globalObject->internalClass()->nameMap.at(i).isString()) {
+ QV4::PropertyKey id = m_v4Engine->globalObject->internalClass()->nameMap.at(i);
+ m_illegalNames.insert(id.toQString());
+ }
}
}
}
@@ -210,25 +225,25 @@ static void freeze_recursive(QV4::ExecutionEngine *v4, QV4::Object *object)
QV4::Scope scope(v4);
bool instanceOfObject = false;
- QV4::ScopedObject p(scope, object->prototype());
+ QV4::ScopedObject p(scope, object->getPrototypeOf());
while (p) {
if (p->d() == v4->objectPrototype()->d()) {
instanceOfObject = true;
break;
}
- p = p->prototype();
+ p = p->getPrototypeOf();
}
if (!instanceOfObject)
return;
- QV4::InternalClass *frozen = object->internalClass()->propertiesFrozen();
+ QV4::Heap::InternalClass *frozen = object->internalClass()->propertiesFrozen();
if (object->internalClass() == frozen)
return;
object->setInternalClass(frozen);
QV4::ScopedObject o(scope);
for (uint i = 0; i < frozen->size; ++i) {
- if (!frozen->nameMap.at(i))
+ if (!frozen->nameMap.at(i).isStringOrSymbol())
continue;
o = *object->propertyData(i);
if (o)
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index b6a378667e..23559618ef 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -67,6 +67,7 @@
#include <private/qv4value_p.h>
#include <private/qv4identifier_p.h>
#include <private/qv4context_p.h>
+#include <private/qv4stackframe_p.h>
#include <private/qqmldelayedcallqueue_p.h>
QT_BEGIN_NAMESPACE
@@ -154,10 +155,9 @@ class Q_QML_PRIVATE_EXPORT QV8Engine
friend class QJSEngine;
public:
// static QJSEngine* get(QV8Engine* d) { Q_ASSERT(d); return d->q; }
- static QV4::ExecutionEngine *getV4(QJSEngine *q) { return q->handle(); }
static QV4::ExecutionEngine *getV4(QV8Engine *d) { return d->m_v4Engine; }
- QV8Engine(QJSEngine* qq, QV4::ExecutionEngine *v4);
+ QV8Engine(QV4::ExecutionEngine *v4);
virtual ~QV8Engine();
// This enum should be in sync with QQmlEngine::ObjectOwnership
@@ -170,10 +170,11 @@ public:
void initQmlGlobalObject();
void setEngine(QQmlEngine *engine);
QQmlEngine *engine() { return m_engine; }
- QJSEngine *publicEngine() { return q; }
QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; }
+#if QT_CONFIG(qml_xml_http_request)
void *xmlHttpRequestData() const { return m_xmlHttpRequestData; }
+#endif
void freezeObject(const QV4::Value &value);
@@ -202,13 +203,14 @@ public:
int consoleCountHelper(const QString &file, quint16 line, quint16 column);
protected:
- QJSEngine* q;
QQmlEngine *m_engine;
QQmlDelayedCallQueue m_delayedCallQueue;
QV4::ExecutionEngine *m_v4Engine;
+#if QT_CONFIG(qml_xml_http_request)
void *m_xmlHttpRequestData;
+#endif
QVector<Deletable *> m_extensionData;
diff --git a/src/qml/qtqmlglobal.h b/src/qml/qtqmlglobal.h
index 6e92867cf5..e02dfa5ed4 100644
--- a/src/qml/qtqmlglobal.h
+++ b/src/qml/qtqmlglobal.h
@@ -52,6 +52,7 @@
# endif
#else
# define QT_FEATURE_qml_debug -1
+# define QT_FEATURE_qml_sequence_object 1
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h
index 4c0ba338d8..60988d12e6 100644
--- a/src/qml/qtqmlglobal_p.h
+++ b/src/qml/qtqmlglobal_p.h
@@ -57,6 +57,8 @@
# include <QtQml/private/qtqml-config_p.h>
#endif
+#define Q_QML_PRIVATE_API_VERSION 3
+
#define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT
#if !defined(QT_QMLDEVTOOLS_LIB) && !defined(QT_BUILD_QMLDEVTOOLS_LIB)
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 183bb1bf74..f601087690 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -231,11 +231,11 @@ void QQmlConnections::setIgnoreUnknownSignals(bool ignore)
d->ignoreUnknownSignals = ignore;
}
-void QQmlConnectionsParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props)
+void QQmlConnectionsParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
for (int ii = 0; ii < props.count(); ++ii) {
const QV4::CompiledData::Binding *binding = props.at(ii);
- const QString &propName = qmlUnit->stringAt(binding->propertyNameIndex);
+ const QString &propName = compilationUnit->stringAt(binding->propertyNameIndex);
if (!propName.startsWith(QLatin1String("on")) || (propName.length() < 3 || !propName.at(2).isUpper())) {
error(props.at(ii), QQmlConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
@@ -243,8 +243,8 @@ void QQmlConnectionsParser::verifyBindings(const QV4::CompiledData::Unit *qmlUni
}
if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
- const QV4::CompiledData::Object *target = qmlUnit->objectAt(binding->value.objectIndex);
- if (!qmlUnit->stringAt(target->inheritedTypeNameIndex).isEmpty())
+ const QV4::CompiledData::Object *target = compilationUnit->objectAt(binding->value.objectIndex);
+ if (!compilationUnit->stringAt(target->inheritedTypeNameIndex).isEmpty())
error(binding, QQmlConnections::tr("Connections: nested objects not allowed"));
else
error(binding, QQmlConnections::tr("Connections: syntax error"));
@@ -256,7 +256,7 @@ void QQmlConnectionsParser::verifyBindings(const QV4::CompiledData::Unit *qmlUni
}
}
-void QQmlConnectionsParser::applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void QQmlConnectionsParser::applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
QQmlConnectionsPrivate *p =
static_cast<QQmlConnectionsPrivate *>(QObjectPrivate::get(object));
@@ -276,10 +276,9 @@ void QQmlConnections::connectSignals()
QQmlData *ddata = QQmlData::get(this);
QQmlContextData *ctxtdata = ddata ? ddata->outerContext : nullptr;
- const QV4::CompiledData::Unit *qmlUnit = d->compilationUnit->data;
for (const QV4::CompiledData::Binding *binding : qAsConst(d->bindings)) {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Script);
- QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propName = d->compilationUnit->stringAt(binding->propertyNameIndex);
QQmlProperty prop(target, propName);
if (prop.isValid() && (prop.type() & QQmlProperty::SignalProperty)) {
diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h
index 50e2c59ac3..bd03d7e152 100644
--- a/src/qml/types/qqmlconnections_p.h
+++ b/src/qml/types/qqmlconnections_p.h
@@ -69,7 +69,7 @@ class Q_AUTOTEST_EXPORT QQmlConnections : public QObject, public QQmlParserStatu
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_REVISION(1) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION 1)
Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
public:
@@ -98,8 +98,8 @@ private:
class QQmlConnectionsParser : public QQmlCustomParser
{
public:
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
- void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
diff --git a/src/qml/types/qqmldelegatecomponent.cpp b/src/qml/types/qqmldelegatecomponent.cpp
new file mode 100644
index 0000000000..fa7e994afd
--- /dev/null
+++ b/src/qml/types/qqmldelegatecomponent.cpp
@@ -0,0 +1,298 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldelegatecomponent_p.h"
+#include <QtQml/private/qqmladaptormodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlAbstractDelegateComponent::QQmlAbstractDelegateComponent(QObject *parent)
+ : QQmlComponent(parent)
+{
+}
+
+QQmlAbstractDelegateComponent::~QQmlAbstractDelegateComponent()
+{
+}
+
+QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, int row, int column, const QString &role) const
+{
+ if (!adaptorModel)
+ return QVariant();
+ return adaptorModel->value(adaptorModel->indexAt(row, column), role);
+}
+
+/*!
+ \qmlmodule Qt.labs.qmlmodels 1.0
+ \title Qt Labs QML Models - QML Types
+ \ingroup qmlmodules
+ \brief The Qt Labs QML Models module provides various model-related types for use with views.
+
+ To use this module, import the module with the following line:
+
+ \code
+ import Qt.labs.qmlmodels 1.0
+ \endcode
+*/
+
+/*!
+ \qmltype DelegateChoice
+ \instantiates QQmlDelegateChoice
+ \inqmlmodule Qt.labs.qmlmodels
+ \brief Encapsulates a delegate and when to use it
+
+ The DelegateChoice type wraps a delegate and defines the circumstances
+ in which it should be chosen.
+ DelegateChoices can be nested inside a DelegateChooser.
+
+ \sa DelegateChooser
+*/
+
+/*!
+ \qmlproperty string QtQml.Models::DelegateChoice::roleValue
+ This property holds the value used to match the role data for the role provided by \l DefaultDelegateChooser::role.
+*/
+QVariant QQmlDelegateChoice::roleValue() const
+{
+ return m_value;
+}
+
+void QQmlDelegateChoice::setRoleValue(const QVariant &value)
+{
+ if (m_value == value)
+ return;
+ m_value = value;
+ emit roleValueChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty index QtQml.Models::DelegateChoice::row
+ This property holds the value used to match the row value of model elements.
+ With models that have only the index property (and thus only one column), this property
+ should be intended as index, and set to the desired index value.
+
+ \note Setting both row and index has undefined behavior. The two are equivalent and only
+ one should be used.
+
+ \sa QtQml.Models::DelegateChoice::index
+*/
+
+/*!
+ \qmlproperty index QtQml.Models::DelegateChoice::index
+ This property holds the value used to match the index value of model elements.
+ This is effectively an alias for \l QtQml.Models::DelegateChoice::row
+
+ \sa QtQml.Models::DelegateChoice::row
+*/
+int QQmlDelegateChoice::row() const
+{
+ return m_row;
+}
+
+void QQmlDelegateChoice::setRow(int r)
+{
+ if (m_row == r)
+ return;
+ m_row = r;
+ emit rowChanged();
+ emit indexChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty index QtQml.Models::DelegateChoice::column
+ This property holds the value used to match the column value of model elements.
+*/
+int QQmlDelegateChoice::column() const
+{
+ return m_column;
+}
+
+void QQmlDelegateChoice::setColumn(int c)
+{
+ if (m_column == c)
+ return;
+ m_column = c;
+ emit columnChanged();
+ emit changed();
+}
+
+QQmlComponent *QQmlDelegateChoice::delegate() const
+{
+ return m_delegate;
+}
+
+/*!
+ \qmlproperty Component QtQml.Models::DelegateChoice::delegate
+ This property holds the delegate to use if this choice matches the model item.
+*/
+void QQmlDelegateChoice::setDelegate(QQmlComponent *delegate)
+{
+ if (m_delegate == delegate)
+ return;
+ QQmlAbstractDelegateComponent *adc = static_cast<QQmlAbstractDelegateComponent *>(m_delegate);
+ if (adc)
+ disconnect(adc, &QQmlAbstractDelegateComponent::delegateChanged, this, &QQmlDelegateChoice::delegateChanged);
+ m_delegate = delegate;
+ adc = static_cast<QQmlAbstractDelegateComponent *>(delegate);
+ if (adc)
+ connect(adc, &QQmlAbstractDelegateComponent::delegateChanged, this, &QQmlDelegateChoice::delegateChanged);
+ emit delegateChanged();
+ emit changed();
+}
+
+bool QQmlDelegateChoice::match(int row, int column, const QVariant &value) const
+{
+ if (!m_value.isValid() && m_row < 0 && m_column < 0)
+ return true;
+
+ const bool roleMatched = (m_value.isValid()) ? value == m_value : true;
+ const bool rowMatched = (m_row < 0 ) ? true : m_row == row;
+ const bool columnMatched = (m_column < 0 ) ? true : m_column == column;
+ return roleMatched && rowMatched && columnMatched;
+}
+
+/*!
+ \qmltype QQmlDelegateChooser
+ \instantiates QQmlDelegateChooser
+ \inqmlmodule Qt.labs.qmlmodels
+ \brief Allows a view to use different delegates for different types of items in the model.
+
+ The DelegateChooser is a special \l Component type intended for those scenarios where a Component is required
+ by a view and used as a delegate.
+ DelegateChooser encapsulates a set of \l DelegateChoices.
+ These choices are used determine the delegate that will be instantiated for each
+ item in the model.
+ The selection of the choice is performed based on the value that a model item has for \l role,
+ and also based on index.
+
+ \note This type is intended to transparently work only with TableView and any DelegateModel-based view.
+ Views (including user-defined views) that aren't internally based on a DelegateModel need to explicitly support
+ this type of component to make it function as described.
+
+ \sa DelegateChoice
+*/
+
+/*!
+ \qmlproperty string QtQml.Models::DelegateChooser::role
+ This property holds the role used to determine the delegate for a given model item.
+
+ \sa DelegateChoice
+*/
+void QQmlDelegateChooser::setRole(const QString &role)
+{
+ if (m_role == role)
+ return;
+ m_role = role;
+ emit roleChanged();
+}
+
+/*!
+ \qmlproperty list<DelegateChoice> QtQml.Models::DelegateChooser::choices
+ \default
+ The list of DelegateChoices for the chooser.
+
+ The list is treated as an ordered list, where the first DelegateChoice to match
+ will be used be a view.
+
+ It should not generally be necessary to refer to the \c choices property,
+ as it is the default property for DefaultDelegateChooser and thus all child items are
+ automatically assigned to this property.
+*/
+
+QQmlListProperty<QQmlDelegateChoice> QQmlDelegateChooser::choices()
+{
+ return QQmlListProperty<QQmlDelegateChoice>(this, nullptr,
+ QQmlDelegateChooser::choices_append,
+ QQmlDelegateChooser::choices_count,
+ QQmlDelegateChooser::choices_at,
+ QQmlDelegateChooser::choices_clear);
+}
+
+void QQmlDelegateChooser::choices_append(QQmlListProperty<QQmlDelegateChoice> *prop, QQmlDelegateChoice *choice)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ q->m_choices.append(choice);
+ connect(choice, &QQmlDelegateChoice::changed, q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->delegateChanged();
+}
+
+int QQmlDelegateChooser::choices_count(QQmlListProperty<QQmlDelegateChoice> *prop)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser*>(prop->object);
+ return q->m_choices.count();
+}
+
+QQmlDelegateChoice *QQmlDelegateChooser::choices_at(QQmlListProperty<QQmlDelegateChoice> *prop, int index)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser*>(prop->object);
+ return q->m_choices.at(index);
+}
+
+void QQmlDelegateChooser::choices_clear(QQmlListProperty<QQmlDelegateChoice> *prop)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ for (QQmlDelegateChoice *choice : q->m_choices)
+ disconnect(choice, &QQmlDelegateChoice::changed, q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->m_choices.clear();
+ q->delegateChanged();
+}
+
+QQmlComponent *QQmlDelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int row, int column) const
+{
+ QVariant v;
+ if (!m_role.isNull())
+ v = value(adaptorModel, row, column, m_role);
+ if (!v.isValid()) { // check if the row only has modelData, for example if the row is a QVariantMap
+ v = value(adaptorModel, row, column, QStringLiteral("modelData"));
+ if (v.isValid())
+ v = v.toMap().value(m_role);
+ }
+ // loop through choices, finding first one that fits
+ for (int i = 0; i < m_choices.count(); ++i) {
+ const QQmlDelegateChoice *choice = m_choices.at(i);
+ if (choice->match(row, column, v))
+ return choice->delegate();
+ }
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/types/qqmldelegatecomponent_p.h b/src/qml/types/qqmldelegatecomponent_p.h
new file mode 100644
index 0000000000..c925ed9a60
--- /dev/null
+++ b/src/qml/types/qqmldelegatecomponent_p.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLDELEGATECOMPONENT_P_H
+#define QQMLDELEGATECOMPONENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qtqmlglobal_p.h>
+#include <qqmlcomponent.h>
+
+QT_REQUIRE_CONFIG(qml_delegate_model);
+
+QT_BEGIN_NAMESPACE
+
+// TODO: consider making QQmlAbstractDelegateComponent public API
+class QQmlAbstractDelegateComponentPrivate;
+class QQmlAdaptorModel;
+class Q_QML_PRIVATE_EXPORT QQmlAbstractDelegateComponent : public QQmlComponent
+{
+ Q_OBJECT
+public:
+ QQmlAbstractDelegateComponent(QObject *parent = nullptr);
+ ~QQmlAbstractDelegateComponent() override;
+
+ virtual QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = 0) const = 0;
+
+signals:
+ void delegateChanged();
+
+protected:
+ QVariant value(QQmlAdaptorModel *adaptorModel,int row, int column, const QString &role) const;
+
+private:
+ Q_DECLARE_PRIVATE(QQmlAbstractDelegateComponent)
+ Q_DISABLE_COPY(QQmlAbstractDelegateComponent)
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDelegateChoice : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QVariant roleValue READ roleValue WRITE setRoleValue NOTIFY roleValueChanged)
+ Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged)
+ Q_PROPERTY(int index READ row WRITE setRow NOTIFY indexChanged)
+ Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged)
+ Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_CLASSINFO("DefaultProperty", "delegate")
+public:
+ QVariant roleValue() const;
+ void setRoleValue(const QVariant &roleValue);
+
+ int row() const;
+ void setRow(int r);
+
+ int column() const;
+ void setColumn(int c);
+
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
+ virtual bool match(int row, int column, const QVariant &value) const;
+
+signals:
+ void roleValueChanged();
+ void rowChanged();
+ void indexChanged();
+ void columnChanged();
+ void delegateChanged();
+ void changed();
+
+private:
+ QVariant m_value;
+ int m_row = -1;
+ int m_column = -1;
+ QQmlComponent *m_delegate = nullptr;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlDelegateChooser : public QQmlAbstractDelegateComponent
+{
+ Q_OBJECT
+ Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged)
+ Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT)
+ Q_CLASSINFO("DefaultProperty", "choices")
+
+public:
+ QString role() const { return m_role; }
+ void setRole(const QString &role);
+
+ virtual QQmlListProperty<QQmlDelegateChoice> choices();
+ static void choices_append(QQmlListProperty<QQmlDelegateChoice> *, QQmlDelegateChoice *);
+ static int choices_count(QQmlListProperty<QQmlDelegateChoice> *);
+ static QQmlDelegateChoice *choices_at(QQmlListProperty<QQmlDelegateChoice> *, int);
+ static void choices_clear(QQmlListProperty<QQmlDelegateChoice> *);
+
+ QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = -1) const override;
+
+signals:
+ void roleChanged();
+
+private:
+ QString m_role;
+ QList<QQmlDelegateChoice *> m_choices;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQmlDelegateChoice)
+QML_DECLARE_TYPE(QQmlDelegateChooser)
+
+#endif // QQMLDELEGATECOMPONENT_P_H
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 7a12813f0c..f6bf4a6647 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qqmldelegatemodel_p_p.h"
+#include "qqmldelegatecomponent_p.h"
#include <QtQml/qqmlinfo.h>
@@ -93,10 +94,10 @@ struct DelegateModelGroupFunction : QV4::FunctionObject
static Heap::DelegateModelGroupFunction *create(QV4::ExecutionContext *scope, uint flag, QV4::ReturnedValue (*code)(QQmlDelegateModelItem *item, uint flag, const QV4::Value &arg))
{
- return scope->engine()->memoryManager->allocObject<DelegateModelGroupFunction>(scope, flag, code);
+ return scope->engine()->memoryManager->allocate<DelegateModelGroupFunction>(scope, flag, code);
}
- static ReturnedValue call(const QV4::FunctionObject *that, const Value *thisObject, const Value *argv, int argc)
+ static ReturnedValue virtualCall(const QV4::FunctionObject *that, const Value *thisObject, const Value *argv, int argc)
{
QV4::Scope scope(that->engine());
QV4::Scoped<DelegateModelGroupFunction> f(scope, static_cast<const DelegateModelGroupFunction *>(that));
@@ -104,7 +105,7 @@ struct DelegateModelGroupFunction : QV4::FunctionObject
if (!o)
return scope.engine->throwTypeError(QStringLiteral("Not a valid VisualData object"));
- QV4::ScopedValue v(scope, argc ? argv[0] : Primitive::undefinedValue());
+ QV4::ScopedValue v(scope, argc ? argv[0] : Value::undefinedValue());
return f->d()->code(o->d()->item, f->d()->flag, v);
}
};
@@ -160,22 +161,6 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
//---------------------------------------------------------------------------
/*!
- \qmltype VisualDataModel
- \instantiates QQmlDelegateModel
- \inqmlmodule QtQuick
- \ingroup qtquick-models
- \brief Encapsulates a model and delegate.
-
- The VisualDataModel type encapsulates a model and the delegate that will
- be instantiated for items in a model.
-
- This type is provided by the \l{Qt QML} module due to compatibility reasons.
- The same implementation is now primarily available as DelegateModel in the
- \l{Qt QML Models QML Types}{Qt QML Models} module.
-
- \sa {QtQml.Models::DelegateModel}
-*/
-/*!
\qmltype DelegateModel
\instantiates QQmlDelegateModel
\inqmlmodule QtQml.Models
@@ -193,14 +178,11 @@ QQmlDelegateModelParts::QQmlDelegateModelParts(QQmlDelegateModel *parent)
The example below illustrates using a DelegateModel with a ListView.
- \snippet delegatemodel/visualdatamodel.qml 0
-
- \note This type is also available as \l VisualDataModel in the \l{Qt QML}
- module due to compatibility reasons.
+ \snippet delegatemodel/delegatemodel.qml 0
*/
QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt)
- : m_delegate(nullptr)
+ : m_delegateChooser(nullptr)
, m_cacheMetaType(nullptr)
, m_context(ctxt)
, m_parts(nullptr)
@@ -228,6 +210,14 @@ QQmlDelegateModelPrivate::~QQmlDelegateModelPrivate()
m_cacheMetaType->release();
}
+int QQmlDelegateModelPrivate::adaptorModelCount() const
+{
+ // QQmlDelegateModel currently only support list models.
+ // So even if a model is a table model, only the first
+ // column will be used.
+ return m_adaptorModel.rowCount();
+}
+
void QQmlDelegateModelPrivate::requestMoreIfNecessary()
{
Q_Q(QQmlDelegateModel);
@@ -263,6 +253,8 @@ QQmlDelegateModel::QQmlDelegateModel(QQmlContext *ctxt, QObject *parent)
QQmlDelegateModel::~QQmlDelegateModel()
{
Q_D(QQmlDelegateModel);
+ d->disconnectFromAbstractItemModel();
+ d->m_adaptorModel.setObject(nullptr, this);
for (QQmlDelegateModelItem *cacheItem : qAsConst(d->m_cache)) {
if (cacheItem->object) {
@@ -336,7 +328,7 @@ void QQmlDelegateModel::componentComplete()
static_cast<QQmlPartsModel *>(d->m_pendingParts.first())->updateFilterGroup();
QVector<Compositor::Insert> inserts;
- d->m_count = d->m_adaptorModel.count();
+ d->m_count = d->adaptorModelCount();
d->m_compositor.append(
&d->m_adaptorModel,
0,
@@ -368,6 +360,54 @@ QVariant QQmlDelegateModel::model() const
return d->m_adaptorModel.model();
}
+void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+{
+ Q_Q(QQmlDelegateModel);
+ if (!m_adaptorModel.adaptsAim())
+ return;
+
+ auto aim = m_adaptorModel.aim();
+
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ q, QQmlDelegateModel, SLOT(_q_rowsInserted(QModelIndex,int,int)));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ q, QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ q, QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+ q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, QQmlDelegateModel, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(modelReset()),
+ q, QQmlDelegateModel, SLOT(_q_modelReset()));
+ qmlobject_connect(aim, QAbstractItemModel, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ q, QQmlDelegateModel, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
+}
+
+void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+{
+ Q_Q(QQmlDelegateModel);
+ if (!m_adaptorModel.adaptsAim())
+ return;
+
+ auto aim = m_adaptorModel.aim();
+
+ QObject::disconnect(aim, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ q, SLOT(_q_rowsInserted(QModelIndex,int,int)));
+ QObject::disconnect(aim, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+ QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+ QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+ q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QObject::disconnect(aim, SIGNAL(modelReset()),
+ q, SLOT(_q_modelReset()));
+ QObject::disconnect(aim, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
+ q, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
+}
+
void QQmlDelegateModel::setModel(const QVariant &model)
{
Q_D(QQmlDelegateModel);
@@ -375,7 +415,10 @@ void QQmlDelegateModel::setModel(const QVariant &model)
if (d->m_complete)
_q_itemsRemoved(0, d->m_count);
+ d->disconnectFromAbstractItemModel();
d->m_adaptorModel.setModel(model, this, d->m_context->engine());
+ d->connectToAbstractItemModel();
+
d->m_adaptorModel.replaceWatchedRoles(QList<QByteArray>(), d->m_watchedRoles);
for (int i = 0; d->m_parts && i < d->m_parts->models.count(); ++i) {
d->m_adaptorModel.replaceWatchedRoles(
@@ -383,7 +426,7 @@ void QQmlDelegateModel::setModel(const QVariant &model)
}
if (d->m_complete) {
- _q_itemsInserted(0, d->m_adaptorModel.count());
+ _q_itemsInserted(0, d->adaptorModelCount());
d->requestMoreIfNecessary();
}
}
@@ -394,6 +437,8 @@ void QQmlDelegateModel::setModel(const QVariant &model)
The delegate provides a template defining each item instantiated by a view.
The index is exposed as an accessible \c index property. Properties of the
model are also available depending upon the type of \l {qml-data-models}{Data Model}.
+
+ \sa DelegateComponent
*/
QQmlComponent *QQmlDelegateModel::delegate() const
{
@@ -408,22 +453,25 @@ void QQmlDelegateModel::setDelegate(QQmlComponent *delegate)
qmlWarning(this) << tr("The delegate of a DelegateModel cannot be changed within onUpdated.");
return;
}
+ if (d->m_delegate == delegate)
+ return;
bool wasValid = d->m_delegate != nullptr;
- d->m_delegate = delegate;
+ d->m_delegate.setObject(delegate, this);
d->m_delegateValidated = false;
- if (wasValid && d->m_complete) {
- for (int i = 1; i < d->m_groupCount; ++i) {
- QQmlDelegateModelGroupPrivate::get(d->m_groups[i])->changeSet.remove(
- 0, d->m_compositor.count(Compositor::Group(i)));
- }
- }
- if (d->m_complete && d->m_delegate) {
- for (int i = 1; i < d->m_groupCount; ++i) {
- QQmlDelegateModelGroupPrivate::get(d->m_groups[i])->changeSet.insert(
- 0, d->m_compositor.count(Compositor::Group(i)));
+ if (d->m_delegateChooser)
+ QObject::disconnect(d->m_delegateChooserChanged);
+
+ d->m_delegateChooser = nullptr;
+ if (delegate) {
+ QQmlAbstractDelegateComponent *adc =
+ qobject_cast<QQmlAbstractDelegateComponent *>(delegate);
+ if (adc) {
+ d->m_delegateChooser = adc;
+ d->m_delegateChooserChanged = connect(adc, &QQmlAbstractDelegateComponent::delegateChanged,
+ [d](){ d->delegateChanged(); });
}
}
- d->emitChanges();
+ d->delegateChanged(d->m_delegate, wasValid);
}
/*!
@@ -442,10 +490,10 @@ void QQmlDelegateModel::setDelegate(QQmlComponent *delegate)
the new directory's contents.
\c main.cpp:
- \snippet delegatemodel/visualdatamodel_rootindex/main.cpp 0
+ \snippet delegatemodel/delegatemodel_rootindex/main.cpp 0
\c view.qml:
- \snippet delegatemodel/visualdatamodel_rootindex/view.qml 0
+ \snippet delegatemodel/delegatemodel_rootindex/view.qml 0
If the \l model is a QAbstractItemModel subclass, the delegate can also
reference a \c hasModelChildren property (optionally qualified by a
@@ -470,12 +518,16 @@ void QQmlDelegateModel::setRootIndex(const QVariant &root)
if (changed || !d->m_adaptorModel.isValid()) {
const int oldCount = d->m_count;
d->m_adaptorModel.rootIndex = modelIndex;
- if (!d->m_adaptorModel.isValid() && d->m_adaptorModel.aim()) // The previous root index was invalidated, so we need to reconnect the model.
+ if (!d->m_adaptorModel.isValid() && d->m_adaptorModel.aim()) {
+ // The previous root index was invalidated, so we need to reconnect the model.
+ d->disconnectFromAbstractItemModel();
d->m_adaptorModel.setModel(d->m_adaptorModel.list.list(), this, d->m_context->engine());
+ d->connectToAbstractItemModel();
+ }
if (d->m_adaptorModel.canFetchMore())
d->m_adaptorModel.fetchMore();
if (d->m_complete) {
- const int newCount = d->m_adaptorModel.count();
+ const int newCount = d->adaptorModelCount();
if (oldCount)
_q_itemsRemoved(0, oldCount);
if (newCount)
@@ -536,25 +588,24 @@ int QQmlDelegateModel::count() const
QQmlDelegateModel::ReleaseFlags QQmlDelegateModelPrivate::release(QObject *object)
{
- QQmlDelegateModel::ReleaseFlags stat = nullptr;
if (!object)
- return stat;
-
- if (QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(object)) {
- if (cacheItem->releaseObject()) {
- cacheItem->destroyObject();
- emitDestroyingItem(object);
- if (cacheItem->incubationTask) {
- releaseIncubator(cacheItem->incubationTask);
- cacheItem->incubationTask = nullptr;
- }
- cacheItem->Dispose();
- stat |= QQmlInstanceModel::Destroyed;
- } else {
- stat |= QQmlDelegateModel::Referenced;
- }
+ return QQmlDelegateModel::ReleaseFlags(0);
+
+ QQmlDelegateModelItem *cacheItem = QQmlDelegateModelItem::dataForObject(object);
+ if (!cacheItem)
+ return QQmlDelegateModel::ReleaseFlags(0);
+
+ if (!cacheItem->releaseObject())
+ return QQmlDelegateModel::Referenced;
+
+ cacheItem->destroyObject();
+ emitDestroyingItem(object);
+ if (cacheItem->incubationTask) {
+ releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask = nullptr;
}
- return stat;
+ cacheItem->Dispose();
+ return QQmlInstanceModel::Destroyed;
}
/*
@@ -649,7 +700,7 @@ QQmlDelegateModelGroup *QQmlDelegateModelPrivate::group_at(
The following example illustrates using groups to select items in a model.
- \snippet delegatemodel/visualdatagroup.qml 0
+ \snippet delegatemodel/delegatemodelgroup.qml 0
*/
QQmlListProperty<QQmlDelegateModelGroup> QQmlDelegateModel::groups()
@@ -667,7 +718,7 @@ QQmlListProperty<QQmlDelegateModelGroup> QQmlDelegateModel::groups()
/*!
\qmlproperty DelegateModelGroup QtQml.Models::DelegateModel::items
- This property holds visual data model's default group to which all new items are added.
+ This property holds default group to which all new items are added.
*/
QQmlDelegateModelGroup *QQmlDelegateModel::items()
@@ -679,7 +730,7 @@ QQmlDelegateModelGroup *QQmlDelegateModel::items()
/*!
\qmlproperty DelegateModelGroup QtQml.Models::DelegateModel::persistedItems
- This property holds visual data model's persisted items group.
+ This property holds delegate model's persisted items group.
Items in this group are not destroyed when released by a view, instead they are persisted
until removed from the group.
@@ -702,9 +753,9 @@ QQmlDelegateModelGroup *QQmlDelegateModel::persistedItems()
/*!
\qmlproperty string QtQml.Models::DelegateModel::filterOnGroup
- This property holds the name of the group used to filter the visual data model.
+ This property holds name of the group that is used to filter the delegate model.
- Only items which belong to this group are visible to a view.
+ Only items that belong to this group are visible to a view.
By default this is the \l items group.
*/
@@ -808,6 +859,12 @@ QObject *QQmlDelegateModel::parts()
return d->m_parts;
}
+const QAbstractItemModel *QQmlDelegateModel::abstractItemModel() const
+{
+ Q_D(const QQmlDelegateModel);
+ return d->m_adaptorModel.adaptsAim() ? d->m_adaptorModel.aim() : nullptr;
+}
+
void QQmlDelegateModelPrivate::emitCreatedPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package)
{
for (int i = 1; i < m_groupCount; ++i)
@@ -862,6 +919,13 @@ void QQmlDelegateModelPrivate::releaseIncubator(QQDMIncubationTask *incubationTa
}
}
+void QQmlDelegateModelPrivate::addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it)
+{
+ m_cache.insert(it.cacheIndex, item);
+ m_compositor.setFlags(it, 1, Compositor::CacheFlag);
+ Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+}
+
void QQmlDelegateModelPrivate::removeCacheItem(QQmlDelegateModelItem *cacheItem)
{
int cidx = m_cache.lastIndexOf(cacheItem);
@@ -892,7 +956,7 @@ void QQmlDelegateModelPrivate::incubatorStatusChanged(QQDMIncubationTask *incuba
emitCreatedItem(incubationTask, cacheItem->object);
cacheItem->releaseObject();
} else if (status == QQmlIncubator::Error) {
- qmlWarning(m_delegate, incubationTaskErrors + m_delegate->errors()) << "Error creating delegate";
+ qmlInfo(m_delegate, incubationTaskErrors + m_delegate->errors()) << "Cannot create delegate";
}
if (!cacheItem->isObjectReferenced()) {
@@ -951,10 +1015,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
return nullptr;
cacheItem->groups = it->flags;
-
- m_cache.insert(it.cacheIndex, cacheItem);
- m_compositor.setFlags(it, 1, Compositor::CacheFlag);
- Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
+ addCacheItem(cacheItem, it);
}
// Bump the reference counts temporarily so neither the content data or the delegate object
@@ -969,7 +1030,18 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
cacheItem->incubationTask->forceCompletion();
}
} else if (!cacheItem->object) {
- QQmlContext *creationContext = m_delegate->creationContext();
+ QQmlComponent *delegate = m_delegate;
+ if (m_delegateChooser) {
+ QQmlAbstractDelegateComponent *chooser = m_delegateChooser;
+ do {
+ delegate = chooser->delegate(&m_adaptorModel, index);
+ chooser = qobject_cast<QQmlAbstractDelegateComponent *>(delegate);
+ } while (chooser);
+ if (!delegate)
+ return nullptr;
+ }
+
+ QQmlContext *creationContext = delegate->creationContext();
cacheItem->scriptRef += 1;
@@ -994,10 +1066,10 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
}
}
- QQmlComponentPrivate *cp = QQmlComponentPrivate::get(m_delegate);
+ QQmlComponentPrivate *cp = QQmlComponentPrivate::get(delegate);
cp->incubateObject(
cacheItem->incubationTask,
- m_delegate,
+ delegate,
m_context->engine(),
ctxt,
QQmlContextData::get(m_context));
@@ -1046,7 +1118,10 @@ QQmlIncubator::Status QQmlDelegateModel::incubationStatus(int index)
if (!it->inCache())
return QQmlIncubator::Null;
- return d->m_cache.at(it.cacheIndex)->incubationTask->status();
+ if (auto incubationTask = d->m_cache.at(it.cacheIndex)->incubationTask)
+ return incubationTask->status();
+
+ return QQmlIncubator::Ready;
}
QString QQmlDelegateModelPrivate::stringValue(Compositor::Group group, int index, const QString &name)
@@ -1266,8 +1341,12 @@ void QQmlDelegateModel::_q_itemsInserted(int index, int count)
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
for (int i = 0, c = cache.count(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
- if (item->modelIndex() >= index)
- item->setModelIndex(item->modelIndex() + count);
+ if (item->modelIndex() >= index) {
+ const int newIndex = item->modelIndex() + count;
+ const int row = newIndex;
+ const int column = 0;
+ item->setModelIndex(newIndex, row, column);
+ }
}
QVector<Compositor::Insert> inserts;
@@ -1408,10 +1487,14 @@ void QQmlDelegateModel::_q_itemsRemoved(int index, int count)
if (!d->m_cache.contains(item))
continue;
- if (item->modelIndex() >= index + count)
- item->setModelIndex(item->modelIndex() - count);
- else if (item->modelIndex() >= index)
- item->setModelIndex(-1);
+ if (item->modelIndex() >= index + count) {
+ const int newIndex = item->modelIndex() - count;
+ const int row = newIndex;
+ const int column = 0;
+ item->setModelIndex(newIndex, row, column);
+ } else if (item->modelIndex() >= index) {
+ item->setModelIndex(-1, -1, -1);
+ }
}
QVector<Compositor::Remove> removes;
@@ -1456,10 +1539,17 @@ void QQmlDelegateModel::_q_itemsMoved(int from, int to, int count)
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
for (int i = 0, c = cache.count(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
- if (item->modelIndex() >= from && item->modelIndex() < from + count)
- item->setModelIndex(item->modelIndex() - from + to);
- else if (item->modelIndex() >= minimum && item->modelIndex() < maximum)
- item->setModelIndex(item->modelIndex() + difference);
+ if (item->modelIndex() >= from && item->modelIndex() < from + count) {
+ const int newIndex = item->modelIndex() - from + to;
+ const int row = newIndex;
+ const int column = 0;
+ item->setModelIndex(newIndex, row, column);
+ } else if (item->modelIndex() >= minimum && item->modelIndex() < maximum) {
+ const int newIndex = item->modelIndex() + difference;
+ const int row = newIndex;
+ const int column = 0;
+ item->setModelIndex(newIndex, row, column);
+ }
}
QVector<Compositor::Remove> removes;
@@ -1477,6 +1567,32 @@ void QQmlDelegateModelPrivate::emitModelUpdated(const QQmlChangeSet &changeSet,
emit q->countChanged();
}
+void QQmlDelegateModelPrivate::delegateChanged(bool add, bool remove)
+{
+ Q_Q(QQmlDelegateModel);
+ if (!m_complete)
+ return;
+
+ if (m_transaction) {
+ qmlWarning(q) << QQmlDelegateModel::tr("The delegates of a DelegateModel cannot be changed within onUpdated.");
+ return;
+ }
+
+ if (remove) {
+ for (int i = 1; i < m_groupCount; ++i) {
+ QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.remove(
+ 0, m_compositor.count(Compositor::Group(i)));
+ }
+ }
+ if (add) {
+ for (int i = 1; i < m_groupCount; ++i) {
+ QQmlDelegateModelGroupPrivate::get(m_groups[i])->changeSet.insert(
+ 0, m_compositor.count(Compositor::Group(i)));
+ }
+ }
+ emitChanges();
+}
+
void QQmlDelegateModelPrivate::emitChanges()
{
if (m_transaction || !m_complete || !m_context || !m_context->isValid())
@@ -1510,13 +1626,13 @@ void QQmlDelegateModel::_q_modelReset()
d->m_adaptorModel.rootIndex = QModelIndex();
if (d->m_complete) {
- d->m_count = d->m_adaptorModel.count();
+ d->m_count = d->adaptorModelCount();
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
for (int i = 0, c = cache.count(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
if (item->modelIndex() != -1)
- item->setModelIndex(-1);
+ item->setModelIndex(-1, -1, -1);
}
QVector<Compositor::Remove> removes;
@@ -1552,7 +1668,8 @@ void QQmlDelegateModel::_q_rowsAboutToBeRemoved(const QModelIndex &parent, int b
if (index.parent() == parent && index.row() >= begin && index.row() <= end) {
const int oldCount = d->m_count;
d->m_count = 0;
- d->m_adaptorModel.invalidateModel(this);
+ d->disconnectFromAbstractItemModel();
+ d->m_adaptorModel.invalidateModel();
if (d->m_complete && oldCount > 0) {
QVector<Compositor::Remove> removes;
@@ -1654,7 +1771,7 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const
if (!o)
return false;
- QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly|QV4::ObjectIterator::WithProtoChain);
+ QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly);
QV4::ScopedValue propertyName(scope);
QV4::ScopedValue v(scope);
while (1) {
@@ -1804,7 +1921,7 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const
QV4::ScopedValue v(scope);
uint arrayLength = array->getLength();
for (uint i = 0; i < arrayLength; ++i) {
- v = array->getIndexed(i);
+ v = array->get(i);
const QString groupName = v->toQString();
int index = groupNames.indexOf(groupName);
if (index != -1)
@@ -1906,18 +2023,21 @@ void QV4::Heap::QQmlDelegateModelItemObject::destroy()
}
-QQmlDelegateModelItem::QQmlDelegateModelItem(
- QQmlDelegateModelItemMetaType *metaType, int modelIndex)
+QQmlDelegateModelItem::QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType, int modelIndex, int row, int column)
: v4(metaType->v4Engine)
, metaType(metaType)
, contextData(nullptr)
, object(nullptr)
, attached(nullptr)
, incubationTask(nullptr)
+ , delegate(nullptr)
+ , poolTime(0)
, objectRef(0)
, scriptRef(0)
, groups(0)
, index(modelIndex)
+ , row(row)
+ , column(column)
{
metaType->addref();
}
@@ -1952,6 +2072,24 @@ void QQmlDelegateModelItem::Dispose()
delete this;
}
+void QQmlDelegateModelItem::setModelIndex(int idx, int newRow, int newColumn)
+{
+ const int prevIndex = index;
+ const int prevRow = row;
+ const int prevColumn = column;
+
+ index = idx;
+ row = newRow;
+ column = newColumn;
+
+ if (idx != prevIndex)
+ emit modelIndexChanged();
+ if (row != prevRow)
+ emit rowChanged();
+ if (column != prevColumn)
+ emit columnChanged();
+}
+
void QQmlDelegateModelItem::destroyObject()
{
Q_ASSERT(object);
@@ -2080,28 +2218,35 @@ QQmlDelegateModelAttached::QQmlDelegateModelAttached(
, m_previousGroups(cacheItem->groups)
{
QQml_setParent_noEvent(this, parent);
+ resetCurrentIndex();
+ // Let m_previousIndex be equal to m_currentIndex
+ std::copy(std::begin(m_currentIndex), std::end(m_currentIndex), std::begin(m_previousIndex));
+
+ if (!cacheItem->metaType->metaObject)
+ cacheItem->metaType->initializeMetaObject();
+
+ QObjectPrivate::get(this)->metaObject = cacheItem->metaType->metaObject;
+ cacheItem->metaType->metaObject->addref();
+}
+
+void QQmlDelegateModelAttached::resetCurrentIndex()
+{
if (QQDMIncubationTask *incubationTask = m_cacheItem->incubationTask) {
for (int i = 1; i < qMin<int>(m_cacheItem->metaType->groupCount, Compositor::MaximumGroupCount); ++i)
- m_currentIndex[i] = m_previousIndex[i] = incubationTask->index[i];
+ m_currentIndex[i] = incubationTask->index[i];
} else {
QQmlDelegateModelPrivate * const model = QQmlDelegateModelPrivate::get(m_cacheItem->metaType->model);
Compositor::iterator it = model->m_compositor.find(
Compositor::Cache, model->m_cache.indexOf(m_cacheItem));
for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i)
- m_currentIndex[i] = m_previousIndex[i] = it.index[i];
+ m_currentIndex[i] = it.index[i];
}
-
- if (!cacheItem->metaType->metaObject)
- cacheItem->metaType->initializeMetaObject();
-
- QObjectPrivate::get(this)->metaObject = cacheItem->metaType->metaObject;
- cacheItem->metaType->metaObject->addref();
}
/*!
\qmlattachedproperty int QtQml.Models::DelegateModel::model
- This attached property holds the visual data model this delegate instance belongs to.
+ This attached property holds the data model this delegate instance belongs to.
It is attached to each instance of the delegate.
*/
@@ -2148,7 +2293,7 @@ void QQmlDelegateModelAttached::setGroups(const QStringList &groups)
/*!
\qmlattachedproperty bool QtQml.Models::DelegateModel::isUnresolved
- This attached property holds whether the visual item is bound to a data model index.
+ This attached property indicates whether the visual item is bound to a data model index.
Returns true if the item is not bound to the model, and false if it is.
An unresolved item can be bound to the data model using the DelegateModelGroup::resolve()
@@ -2287,22 +2432,6 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package)
}
/*!
- \qmltype VisualDataGroup
- \instantiates QQmlDelegateModelGroup
- \inqmlmodule QtQuick
- \ingroup qtquick-models
- \brief Encapsulates a filtered set of visual data items.
-
- The VisualDataGroup type provides a means to address the model data of a
- model's delegate items, as well as sort and filter these delegate items.
-
- This type is provided by the \l{Qt QML} module due to compatibility reasons.
- The same implementation is now primarily available as \l DelegateModelGroup
- in the \l{Qt QML Models QML Types}{Qt QML Models} module.
-
- \sa {QtQml.Models::DelegateModelGroup}
-*/
-/*!
\qmltype DelegateModelGroup
\instantiates QQmlDelegateModelGroup
\inqmlmodule QtQml.Models
@@ -2335,9 +2464,6 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package)
type or to cherry-pick specific items that should be instantiated irregardless of whether
they're currently within a view's visible area.
- \note This type is also available as \l VisualDataGroup in the \l{Qt QML}
- module due to compatibility reasons.
-
\sa {QML Dynamic View Ordering Tutorial}
*/
QQmlDelegateModelGroup::QQmlDelegateModelGroup(QObject *parent)
@@ -2483,9 +2609,9 @@ QQmlV4Handle QQmlDelegateModelGroup::get(int index)
model->m_cacheMetaType->initializePrototype();
QV4::ExecutionEngine *v4 = model->m_cacheMetaType->v4Engine;
QV4::Scope scope(v4);
- QV4::ScopedObject o(scope, v4->memoryManager->allocObject<QQmlDelegateModelItemObject>(cacheItem));
+ QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(cacheItem));
QV4::ScopedObject p(scope, model->m_cacheMetaType->modelItemProto.value());
- o->setPrototype(p);
+ o->setPrototypeOf(p);
++cacheItem->scriptRef;
return QQmlV4Handle(o);
@@ -3194,7 +3320,10 @@ QQmlIncubator::Status QQmlPartsModel::incubationStatus(int index)
if (!it->inCache())
return QQmlIncubator::Null;
- return model->m_cache.at(it.cacheIndex)->incubationTask->status();
+ if (auto incubationTask = model->m_cache.at(it.cacheIndex)->incubationTask)
+ return incubationTask->status();
+
+ return QQmlIncubator::Ready;
}
int QQmlPartsModel::indexOf(QObject *item, QObject *) const
@@ -3214,7 +3343,10 @@ void QQmlPartsModel::createdPackage(int index, QQuickPackage *package)
void QQmlPartsModel::initPackage(int index, QQuickPackage *package)
{
- emit initItem(index, package->part(m_part));
+ if (m_modelUpdatePending)
+ m_pendingPackageInitializations << index;
+ else
+ emit initItem(index, package->part(m_part));
}
void QQmlPartsModel::destroyingPackage(QQuickPackage *package)
@@ -3226,9 +3358,22 @@ void QQmlPartsModel::destroyingPackage(QQuickPackage *package)
void QQmlPartsModel::emitModelUpdated(const QQmlChangeSet &changeSet, bool reset)
{
+ m_modelUpdatePending = false;
emit modelUpdated(changeSet, reset);
if (changeSet.difference() != 0)
emit countChanged();
+
+ QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model);
+ QVector<int> pendingPackageInitializations;
+ qSwap(pendingPackageInitializations, m_pendingPackageInitializations);
+ for (int index : pendingPackageInitializations) {
+ if (!model->m_delegate || index < 0 || index >= model->m_compositor.count(m_compositorGroup))
+ continue;
+ QObject *object = model->object(m_compositorGroup, index, QQmlIncubator::Asynchronous);
+ if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
+ emit initItem(index, package->part(m_part));
+ model->release(object);
+ }
}
//============================================================================
@@ -3238,7 +3383,7 @@ struct QQmlDelegateModelGroupChange : QV4::Object
V4_OBJECT2(QQmlDelegateModelGroupChange, QV4::Object)
static QV4::Heap::QQmlDelegateModelGroupChange *create(QV4::ExecutionEngine *e) {
- return e->memoryManager->allocObject<QQmlDelegateModelGroupChange>();
+ return e->memoryManager->allocate<QQmlDelegateModelGroupChange>();
}
static QV4::ReturnedValue method_get_index(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) {
@@ -3275,49 +3420,49 @@ struct QQmlDelegateModelGroupChangeArray : public QV4::Object
public:
static QV4::Heap::QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes)
{
- return engine->memoryManager->allocObject<QQmlDelegateModelGroupChangeArray>(changes);
+ return engine->memoryManager->allocate<QQmlDelegateModelGroupChangeArray>(changes);
}
quint32 count() const { return d()->changes->count(); }
const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); }
- static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
+ static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty)
{
- Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
- QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine();
- QV4::Scope scope(v4);
- QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m));
-
- if (index >= array->count()) {
- if (hasProperty)
- *hasProperty = false;
- return QV4::Primitive::undefinedValue().asReturnedValue();
- }
+ if (id.isArrayIndex()) {
+ uint index = id.asArrayIndex();
+ Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
+ QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine();
+ QV4::Scope scope(v4);
+ QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m));
+
+ if (index >= array->count()) {
+ if (hasProperty)
+ *hasProperty = false;
+ return QV4::Value::undefinedValue().asReturnedValue();
+ }
- const QQmlChangeSet::Change &change = array->at(index);
+ const QQmlChangeSet::Change &change = array->at(index);
- QV4::ScopedObject changeProto(scope, engineData(v4)->changeProto.value());
- QV4::Scoped<QQmlDelegateModelGroupChange> object(scope, QQmlDelegateModelGroupChange::create(v4));
- object->setPrototype(changeProto);
- object->d()->change = change;
+ QV4::ScopedObject changeProto(scope, engineData(v4)->changeProto.value());
+ QV4::Scoped<QQmlDelegateModelGroupChange> object(scope, QQmlDelegateModelGroupChange::create(v4));
+ object->setPrototypeOf(changeProto);
+ object->d()->change = change;
- if (hasProperty)
- *hasProperty = true;
- return object.asReturnedValue();
- }
+ if (hasProperty)
+ *hasProperty = true;
+ return object.asReturnedValue();
+ }
- static QV4::ReturnedValue get(const QV4::Managed *m, QV4::String *name, bool *hasProperty)
- {
Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
const QQmlDelegateModelGroupChangeArray *array = static_cast<const QQmlDelegateModelGroupChangeArray *>(m);
- if (name->equals(array->engine()->id_length())) {
+ if (id == array->engine()->id_length()->propertyKey()) {
if (hasProperty)
*hasProperty = true;
return QV4::Encode(array->count());
}
- return Object::get(m, name, hasProperty);
+ return Object::virtualGet(m, id, receiver, hasProperty);
}
};
diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h
index b0786cd088..0ad8939732 100644
--- a/src/qml/types/qqmldelegatemodel_p.h
+++ b/src/qml/types/qqmldelegatemodel_p.h
@@ -67,7 +67,6 @@ QT_REQUIRE_CONFIG(qml_delegate_model);
QT_BEGIN_NAMESPACE
class QQmlChangeSet;
-class QQmlComponent;
class QQuickPackage;
class QQmlV4Function;
class QQmlDelegateModelGroup;
@@ -130,6 +129,8 @@ public:
QQmlListProperty<QQmlDelegateModelGroup> groups();
QObject *parts();
+ const QAbstractItemModel *abstractItemModel() const override;
+
bool event(QEvent *) override;
static QQmlDelegateModelAttached *qmlAttachedProperties(QObject *obj);
@@ -212,6 +213,7 @@ public:
QQmlDelegateModelAttached(QQmlDelegateModelItem *cacheItem, QObject *parent);
~QQmlDelegateModelAttached() {}
+ void resetCurrentIndex();
void setCacheItem(QQmlDelegateModelItem *item);
QQmlDelegateModel *model() const;
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index 18980cfd7c..2d6fdf228e 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -67,8 +67,9 @@ QT_BEGIN_NAMESPACE
typedef QQmlListCompositor Compositor;
class QQmlDelegateModelAttachedMetaObject;
+class QQmlAbstractDelegateComponent;
-class QQmlDelegateModelItemMetaType : public QQmlRefCount
+class Q_QML_PRIVATE_EXPORT QQmlDelegateModelItemMetaType : public QQmlRefCount
{
public:
QQmlDelegateModelItemMetaType(QV4::ExecutionEngine *engine, QQmlDelegateModel *model, const QStringList &groupNames);
@@ -95,9 +96,11 @@ class QQmlDelegateModelItem : public QObject
{
Q_OBJECT
Q_PROPERTY(int index READ modelIndex NOTIFY modelIndexChanged)
+ Q_PROPERTY(int row MEMBER row NOTIFY rowChanged)
+ Q_PROPERTY(int column MEMBER column NOTIFY columnChanged)
Q_PROPERTY(QObject *model READ modelObject CONSTANT)
public:
- QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType, int modelIndex);
+ QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType, int modelIndex, int row, int column);
~QQmlDelegateModelItem();
void referenceObject() { ++objectRef; }
@@ -121,7 +124,7 @@ public:
int groupIndex(Compositor::Group group);
int modelIndex() const { return index; }
- void setModelIndex(int idx) { index = idx; Q_EMIT modelIndexChanged(); }
+ virtual void setModelIndex(int idx, int newRow, int newColumn);
virtual QV4::ReturnedValue get() { return QV4::QObjectWrapper::wrap(v4, this); }
@@ -141,6 +144,8 @@ public:
QPointer<QObject> object;
QPointer<QQmlDelegateModelAttached> attached;
QQDMIncubationTask *incubationTask;
+ QQmlComponent *delegate;
+ int poolTime;
int objectRef;
int scriptRef;
int groups;
@@ -148,9 +153,13 @@ public:
Q_SIGNALS:
void modelIndexChanged();
+ void rowChanged();
+ void columnChanged();
protected:
void objectDestroyed(QObject *);
+ int row;
+ int column;
};
namespace QV4 {
@@ -190,8 +199,8 @@ public:
void statusChanged(Status) override;
void setInitialState(QObject *) override;
- QQmlDelegateModelItem *incubating;
- QQmlDelegateModelPrivate *vdm;
+ QQmlDelegateModelItem *incubating = nullptr;
+ QQmlDelegateModelPrivate *vdm = nullptr;
int index[QQmlListCompositor::MaximumGroupCount];
};
@@ -256,6 +265,8 @@ public:
void init();
void connectModel(QQmlAdaptorModel *model);
+ void connectToAbstractItemModel();
+ void disconnectFromAbstractItemModel();
void requestMoreIfNecessary();
QObject *object(Compositor::Group group, int index, QQmlIncubator::IncubationMode incubationMode);
@@ -269,6 +280,7 @@ public:
Q_EMIT q_func()->initItem(incubationTask->index[m_compositorGroup], item); }
void emitDestroyingPackage(QQuickPackage *package);
void emitDestroyingItem(QObject *item) { Q_EMIT q_func()->destroyingItem(item); }
+ void addCacheItem(QQmlDelegateModelItem *item, Compositor::iterator it);
void removeCacheItem(QQmlDelegateModelItem *cacheItem);
void updateFilterGroup();
@@ -292,9 +304,12 @@ public:
void itemsChanged(const QVector<Compositor::Change> &changes);
void emitChanges();
void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override;
+ void delegateChanged(bool add = true, bool remove = true);
bool insert(Compositor::insert_iterator &before, const QV4::Value &object, int groups);
+ int adaptorModelCount() const;
+
static void group_append(QQmlListProperty<QQmlDelegateModelGroup> *property, QQmlDelegateModelGroup *group);
static int group_count(QQmlListProperty<QQmlDelegateModelGroup> *property);
static QQmlDelegateModelGroup *group_at(QQmlListProperty<QQmlDelegateModelGroup> *property, int index);
@@ -305,7 +320,9 @@ public:
QQmlAdaptorModel m_adaptorModel;
QQmlListCompositor m_compositor;
- QQmlComponent *m_delegate;
+ QQmlStrongJSQObjectReference<QQmlComponent> m_delegate;
+ QQmlAbstractDelegateComponent *m_delegateChooser;
+ QMetaObject::Connection m_delegateChooserChanged;
QQmlDelegateModelItemMetaType *m_cacheMetaType;
QPointer<QQmlContext> m_context;
QQmlDelegateModelParts *m_parts;
@@ -378,8 +395,10 @@ private:
QString m_part;
QString m_filterGroup;
QList<QByteArray> m_watchedRoles;
+ QVector<int> m_pendingPackageInitializations; // vector holds model indices
Compositor::Group m_compositorGroup;
bool m_inheritGroup;
+ bool m_modelUpdatePending = true;
};
class QMetaPropertyBuilder;
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 830c2bef5a..debf14df97 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -62,6 +62,8 @@
#include <QtCore/qdatetime.h>
#include <QScopedValueRollback>
+Q_DECLARE_METATYPE(const QV4::CompiledData::Binding*);
+
QT_BEGIN_NAMESPACE
// Set to 1024 as a debugging aid - easier to distinguish uids from indices of elements/models.
@@ -124,8 +126,8 @@ const ListLayout::Role &ListLayout::getRoleOrCreate(QV4::String *key, Role::Data
const ListLayout::Role &ListLayout::createRole(const QString &key, ListLayout::Role::DataType type)
{
- const int dataSizes[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QPointer<QObject>), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };
- const int dataAlignments[] = { sizeof(QString), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };
+ const int dataSizes[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QPointer<QObject>), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };
+ const int dataAlignments[] = { sizeof(StringOrTranslation), sizeof(double), sizeof(bool), sizeof(ListModel *), sizeof(QObject *), sizeof(QVariantMap), sizeof(QDateTime), sizeof(QJSValue) };
Role *r = new Role;
r->name = key;
@@ -227,6 +229,10 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV
data.value<QJSValue>().isCallable()) {
type = Role::Function;
break;
+ } else if (data.userType() == qMetaTypeId<const QV4::CompiledData::Binding*>()
+ && data.value<const QV4::CompiledData::Binding*>()->isTranslationBinding()) {
+ type = Role::String;
+ break;
} else {
type = Role::List;
break;
@@ -261,6 +267,75 @@ const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key) const
return r;
}
+StringOrTranslation::StringOrTranslation(const QString &s)
+{
+ d.setFlag();
+ setString(s);
+}
+
+StringOrTranslation::StringOrTranslation(const QV4::CompiledData::Binding *binding)
+{
+ d.setFlag();
+ clear();
+ d = binding;
+}
+
+StringOrTranslation::~StringOrTranslation()
+{
+ clear();
+}
+
+void StringOrTranslation::setString(const QString &s)
+{
+ d.setFlag();
+ clear();
+ QStringData *stringData = const_cast<QString &>(s).data_ptr();
+ d = stringData;
+ if (stringData)
+ stringData->ref.ref();
+}
+
+void StringOrTranslation::setTranslation(const QV4::CompiledData::Binding *binding)
+{
+ d.setFlag();
+ clear();
+ d = binding;
+}
+
+QString StringOrTranslation::toString(const QQmlListModel *owner) const
+{
+ if (d.isNull())
+ return QString();
+ if (d.isT1()) {
+ QStringDataPtr holder = { d.asT1() };
+ holder.ptr->ref.ref();
+ return QString(holder);
+ }
+ if (!owner)
+ return QString();
+ return d.asT2()->valueAsString(owner->m_compilationUnit.data());
+}
+
+QString StringOrTranslation::asString() const
+{
+ if (d.isNull())
+ return QString();
+ if (!d.isT1())
+ return QString();
+ QStringDataPtr holder = { d.asT1() };
+ holder.ptr->ref.ref();
+ return QString(holder);
+}
+
+void StringOrTranslation::clear()
+{
+ if (QStringData *strData = d.isT1() ? d.asT1() : nullptr) {
+ if (!strData->ref.deref())
+ QStringData::deallocate(strData);
+ }
+ d = static_cast<QStringData *>(nullptr);
+}
+
QObject *ListModel::getOrCreateModelObject(QQmlListModel *model, int elementIndex)
{
ListElement *e = elements[elementIndex];
@@ -488,7 +563,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)
QV4::Scope scope(v4);
QV4::ScopedObject o(scope);
- QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);
+ QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::EnumerableOnly);
QV4::ScopedString propertyName(scope);
QV4::ScopedValue propertyValue(scope);
while (1) {
@@ -512,7 +587,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
@@ -567,7 +642,7 @@ void ListModel::set(int elementIndex, QV4::Object *object)
QV4::ExecutionEngine *v4 = object->engine();
QV4::Scope scope(v4);
- QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::WithProtoChain|QV4::ObjectIterator::EnumerableOnly);
+ QV4::ObjectIterator it(scope, object, QV4::ObjectIterator::EnumerableOnly);
QV4::ScopedString propertyName(scope);
QV4::ScopedValue propertyValue(scope);
QV4::ScopedObject o(scope);
@@ -593,7 +668,7 @@ void ListModel::set(int elementIndex, QV4::Object *object)
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
@@ -717,11 +792,11 @@ ModelNodeMetaObject *ListElement::objectCache()
return ModelNodeMetaObject::get(m_objectCache);
}
-QString *ListElement::getStringProperty(const ListLayout::Role &role)
+StringOrTranslation *ListElement::getStringProperty(const ListLayout::Role &role)
{
char *mem = getPropertyMemory(role);
- QString *s = reinterpret_cast<QString *>(mem);
- return s->data_ptr() ? s : nullptr;
+ StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem);
+ return s;
}
QObject *ListElement::getQObjectProperty(const ListLayout::Role &role)
@@ -806,9 +881,9 @@ QVariant ListElement::getProperty(const ListLayout::Role &role, const QQmlListMo
break;
case ListLayout::Role::String:
{
- QString *value = reinterpret_cast<QString *>(mem);
- if (value->data_ptr() != nullptr)
- data = *value;
+ StringOrTranslation *value = reinterpret_cast<StringOrTranslation *>(mem);
+ if (value->isSet())
+ data = value->toString(owner);
}
break;
case ListLayout::Role::Bool:
@@ -878,15 +953,13 @@ int ListElement::setStringProperty(const ListLayout::Role &role, const QString &
if (role.type == ListLayout::Role::String) {
char *mem = getPropertyMemory(role);
- QString *c = reinterpret_cast<QString *>(mem);
+ StringOrTranslation *c = reinterpret_cast<StringOrTranslation *>(mem);
bool changed;
- if (c->data_ptr() == nullptr) {
- new (mem) QString(s);
+ if (!c->isSet() || c->isTranslation())
changed = true;
- } else {
- changed = c->compare(s) != 0;
- *c = s;
- }
+ else
+ changed = c->asString().compare(s) != 0;
+ c->setString(s);
if (changed)
roleIndex = role.index;
}
@@ -1048,11 +1121,25 @@ int ListElement::setFunctionProperty(const ListLayout::Role &role, const QJSValu
return roleIndex;
}
+int ListElement::setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b)
+{
+ int roleIndex = -1;
+
+ if (role.type == ListLayout::Role::String) {
+ char *mem = getPropertyMemory(role);
+ StringOrTranslation *s = reinterpret_cast<StringOrTranslation *>(mem);
+ s->setTranslation(b);
+ roleIndex = role.index;
+ }
+
+ return roleIndex;
+}
+
void ListElement::setStringPropertyFast(const ListLayout::Role &role, const QString &s)
{
char *mem = getPropertyMemory(role);
- new (mem) QString(s);
+ new (mem) StringOrTranslation(s);
}
void ListElement::setDoublePropertyFast(const ListLayout::Role &role, double d)
@@ -1219,9 +1306,9 @@ void ListElement::destroy(ListLayout *layout)
switch (r.type) {
case ListLayout::Role::String:
{
- QString *string = getStringProperty(r);
+ StringOrTranslation *string = getStringProperty(r);
if (string)
- string->~QString();
+ string->~StringOrTranslation();
}
break;
case ListLayout::Role::List:
@@ -1267,7 +1354,10 @@ void ListElement::destroy(ListLayout *layout)
}
}
- delete m_objectCache;
+ if (m_objectCache) {
+ m_objectCache->~QObject();
+ operator delete(m_objectCache);
+ }
}
if (next)
@@ -1284,7 +1374,10 @@ int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant
roleIndex = setDoubleProperty(role, d.toDouble());
break;
case ListLayout::Role::String:
- roleIndex = setStringProperty(role, d.toString());
+ if (d.userType() == qMetaTypeId<const QV4::CompiledData::Binding *>())
+ roleIndex = setTranslationProperty(role, d.value<const QV4::CompiledData::Binding*>());
+ else
+ roleIndex = setStringProperty(role, d.toString());
break;
case ListLayout::Role::Bool:
roleIndex = setBoolProperty(role, d.toBool());
@@ -1332,7 +1425,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
ListModel *subModel = new ListModel(role.subLayout, nullptr);
int arrayLength = a->getLength();
for (int j=0 ; j < arrayLength ; ++j) {
- o = a->getIndexed(j);
+ o = a->get(j);
subModel->append(o);
}
roleIndex = setListProperty(role, subModel);
@@ -1446,7 +1539,7 @@ void ModelNodeMetaObject::propertyWritten(int index)
return;
QString propName = QString::fromUtf8(name(index));
- QVariant value = operator[](index);
+ const QVariant value = this->value(index);
QV4::Scope scope(m_model->engine());
QV4::ScopedValue v(scope, scope.engine->fromVariant(value));
@@ -1474,29 +1567,37 @@ void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCo
namespace QV4 {
-bool ModelObject::put(Managed *m, String *name, const Value &value)
+bool ModelObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
{
+ if (!id.isString())
+ return Object::virtualPut(m, id, value, receiver);
+ QString propName = id.toQString();
+
ModelObject *that = static_cast<ModelObject*>(m);
ExecutionEngine *eng = that->engine();
const int elementIndex = that->d()->elementIndex();
- const QString propName = name->toQString();
int roleIndex = that->d()->m_model->m_listModel->setExistingProperty(elementIndex, propName, value, eng);
if (roleIndex != -1)
that->d()->m_model->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex));
ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object());
if (mo->initialized())
- mo->emitPropertyNotification(name->toQString().toUtf8());
+ mo->emitPropertyNotification(propName.toUtf8());
return true;
}
-ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty)
+ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
{
+ if (!id.isString())
+ return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
+
const ModelObject *that = static_cast<const ModelObject*>(m);
+ Scope scope(that);
+ ScopedString name(scope, id.asStringOrSymbol());
const ListLayout::Role *role = that->d()->m_model->m_listModel->getExistingRole(name);
if (!role)
- return QObjectWrapper::get(m, name, hasProperty);
+ return QObjectWrapper::virtualGet(m, id, receiver, hasProperty);
if (hasProperty)
*hasProperty = true;
@@ -1512,27 +1613,43 @@ ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty
return that->engine()->fromVariant(value);
}
-void ModelObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
+struct ModelObjectOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
{
- ModelObject *that = static_cast<ModelObject*>(m);
+ int roleNameIndex = 0;
+ ~ModelObjectOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey ModelObjectOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
+{
+ const ModelObject *that = static_cast<const ModelObject *>(o);
+
ExecutionEngine *v4 = that->engine();
- name->setM(nullptr);
- *index = UINT_MAX;
- if (it->arrayIndex < uint(that->d()->m_model->m_listModel->roleCount())) {
+ if (roleNameIndex < that->listModel()->roleCount()) {
Scope scope(that->engine());
- const ListLayout::Role &role = that->d()->m_model->m_listModel->getExistingRole(it->arrayIndex);
- ++it->arrayIndex;
+ const ListLayout::Role &role = that->listModel()->getExistingRole(roleNameIndex);
+ ++roleNameIndex;
ScopedString roleName(scope, v4->newString(role.name));
- name->setM(roleName->d());
- *attributes = QV4::Attr_Data;
- QVariant value = that->d()->m_model->data(that->d()->elementIndex(), role.index);
- p->value = v4->fromVariant(value);
- return;
+ if (attrs)
+ *attrs = QV4::Attr_Data;
+ if (pd) {
+ QVariant value = that->d()->m_model->data(that->d()->elementIndex(), role.index);
+ pd->value = v4->fromVariant(value);
+ }
+ return roleName->toPropertyKey();
}
+
// Fall back to QV4::Object as opposed to QV4::QObjectWrapper otherwise it will add
// unnecessary entries that relate to the roles used. These just create extra work
// later on as they will just be ignored.
- QV4::Object::advanceIterator(m, it, name, index, p, attributes);
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *ModelObject::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new ModelObjectOwnPropertyKeyIterator;
}
DEFINE_OBJECT_VTABLE(ModelObject);
@@ -1766,13 +1883,13 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
\snippet ../quick/threading/threadedlistmodel/timedisplay.qml 0
- The included file, \tt dataloader.js, looks like this:
+ The included file, \tt dataloader.mjs, looks like this:
- \snippet ../quick/threading/threadedlistmodel/dataloader.js 0
+ \snippet ../quick/threading/threadedlistmodel/dataloader.mjs 0
The timer in the main example sends messages to the worker script by calling
\l WorkerScript::sendMessage(). When this message is received,
- \c WorkerScript.onMessage() is invoked in \c dataloader.js,
+ \c WorkerScript.onMessage() is invoked in \c dataloader.mjs,
which appends the current time to the list model.
Note the call to sync() from the external thread.
@@ -1809,6 +1926,7 @@ QQmlListModel::QQmlListModel(const QQmlListModel *owner, ListModel *data, QV4::E
m_listModel = data;
m_engine = engine;
+ m_compilationUnit = owner->m_compilationUnit;
}
QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent)
@@ -1828,6 +1946,7 @@ QQmlListModel::QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agen
ListModel::sync(orig->m_listModel, m_listModel);
m_engine = nullptr;
+ m_compilationUnit = orig->m_compilationUnit;
}
QQmlListModel::~QQmlListModel()
@@ -2244,7 +2363,7 @@ void QQmlListModel::insert(QQmlV4Function *args)
int objectArrayLength = objectArray->getLength();
emitItemsAboutToBeInserted(index, objectArrayLength);
for (int i=0 ; i < objectArrayLength ; ++i) {
- argObject = objectArray->getIndexed(i);
+ argObject = objectArray->get(i);
if (m_dynamicRoles) {
m_modelObjects.insert(index+i, DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
@@ -2356,7 +2475,7 @@ void QQmlListModel::append(QQmlV4Function *args)
emitItemsAboutToBeInserted(index, objectArrayLength);
for (int i=0 ; i < objectArrayLength ; ++i) {
- argObject = objectArray->getIndexed(i);
+ argObject = objectArray->get(i);
if (m_dynamicRoles) {
m_modelObjects.append(DynamicRoleModelNode::create(scope.engine->variantMapFromJS(argObject), this));
@@ -2423,7 +2542,7 @@ void QQmlListModel::append(QQmlV4Function *args)
QQmlV4Handle QQmlListModel::get(int index) const
{
QV4::Scope scope(engine());
- QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue result(scope, QV4::Value::undefinedValue());
if (index >= 0 && index < count()) {
@@ -2434,7 +2553,7 @@ QQmlV4Handle QQmlListModel::get(int index) const
QObject *object = m_listModel->getOrCreateModelObject(const_cast<QQmlListModel *>(this), index);
QQmlData *ddata = QQmlData::get(object);
if (ddata->jsWrapper.isNullOrUndefined()) {
- result = scope.engine->memoryManager->allocObject<QV4::ModelObject>(object, const_cast<QQmlListModel *>(this));
+ result = scope.engine->memoryManager->allocate<QV4::ModelObject>(object, const_cast<QQmlListModel *>(this));
// Keep track of the QObjectWrapper in persistent value storage
ddata->jsWrapper.set(scope.engine, result);
} else {
@@ -2551,12 +2670,12 @@ void QQmlListModel::sync()
qmlWarning(this) << "List sync() can only be called from a WorkerScript";
}
-bool QQmlListModelParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
+bool QQmlListModelParser::verifyProperty(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
const quint32 targetObjectIndex = binding->value.objectIndex;
- const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex);
- QString objName = qmlUnit->stringAt(target->inheritedTypeNameIndex);
+ const QV4::CompiledData::Object *target = compilationUnit->objectAt(targetObjectIndex);
+ QString objName = compilationUnit->stringAt(target->inheritedTypeNameIndex);
if (objName != listElementTypeName) {
const QMetaObject *mo = resolveType(objName);
if (mo != &QQmlListElement::staticMetaObject) {
@@ -2566,23 +2685,23 @@ bool QQmlListModelParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit,
listElementTypeName = objName; // cache right name for next time
}
- if (!qmlUnit->stringAt(target->idNameIndex).isEmpty()) {
+ if (!compilationUnit->stringAt(target->idNameIndex).isEmpty()) {
error(target->locationOfIdProperty, QQmlListModel::tr("ListElement: cannot use reserved \"id\" property"));
return false;
}
const QV4::CompiledData::Binding *binding = target->bindingTable();
for (quint32 i = 0; i < target->nBindings; ++i, ++binding) {
- QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propName = compilationUnit->stringAt(binding->propertyNameIndex);
if (propName.isEmpty()) {
error(binding, QQmlListModel::tr("ListElement: cannot contain nested elements"));
return false;
}
- if (!verifyProperty(qmlUnit, binding))
+ if (!verifyProperty(compilationUnit, binding))
return false;
}
} else if (binding->type == QV4::CompiledData::Binding::Type_Script) {
- QString scriptStr = binding->valueAsScriptString(qmlUnit);
+ QString scriptStr = binding->valueAsScriptString(compilationUnit.data());
if (!binding->isFunctionExpression() && !definesEmptyList(scriptStr)) {
QByteArray script = scriptStr.toUtf8();
bool ok;
@@ -2597,14 +2716,14 @@ bool QQmlListModelParser::verifyProperty(const QV4::CompiledData::Unit *qmlUnit,
return true;
}
-bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex)
+bool QQmlListModelParser::applyProperty(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex)
{
- const QString elementName = qmlUnit->stringAt(binding->propertyNameIndex);
+ const QString elementName = compilationUnit->stringAt(binding->propertyNameIndex);
bool roleSet = false;
if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
const quint32 targetObjectIndex = binding->value.objectIndex;
- const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex);
+ const QV4::CompiledData::Object *target = compilationUnit->objectAt(targetObjectIndex);
ListModel *subModel = nullptr;
if (outterElementIndex == -1) {
@@ -2625,20 +2744,22 @@ bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *comp
const QV4::CompiledData::Binding *subBinding = target->bindingTable();
for (quint32 i = 0; i < target->nBindings; ++i, ++subBinding) {
- roleSet |= applyProperty(compilationUnit, qmlUnit, subBinding, subModel, elementIndex);
+ roleSet |= applyProperty(compilationUnit, subBinding, subModel, elementIndex);
}
} else {
QVariant value;
- if (binding->evaluatesToString()) {
- value = binding->valueAsString(qmlUnit);
+ if (binding->isTranslationBinding()) {
+ value = QVariant::fromValue<const QV4::CompiledData::Binding*>(binding);
+ } else if (binding->evaluatesToString()) {
+ value = binding->valueAsString(compilationUnit.data());
} else if (binding->type == QV4::CompiledData::Binding::Type_Number) {
- value = binding->valueAsNumber();
+ value = binding->valueAsNumber(compilationUnit->constants);
} else if (binding->type == QV4::CompiledData::Binding::Type_Boolean) {
value = binding->valueAsBoolean();
} else if (binding->type == QV4::CompiledData::Binding::Type_Script) {
- QString scriptStr = binding->valueAsScriptString(qmlUnit);
+ QString scriptStr = binding->valueAsScriptString(compilationUnit.data());
if (definesEmptyList(scriptStr)) {
const ListLayout::Role &role = model->getOrCreateListRole(elementName);
ListModel *emptyModel = new ListModel(role.subLayout, nullptr);
@@ -2673,35 +2794,34 @@ bool QQmlListModelParser::applyProperty(QV4::CompiledData::CompilationUnit *comp
return roleSet;
}
-void QQmlListModelParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void QQmlListModelParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
listElementTypeName = QString(); // unknown
for (const QV4::CompiledData::Binding *binding : bindings) {
- QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propName = compilationUnit->stringAt(binding->propertyNameIndex);
if (!propName.isEmpty()) { // isn't default property
error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName));
return;
}
- if (!verifyProperty(qmlUnit, binding))
+ if (!verifyProperty(compilationUnit, binding))
return;
}
}
-void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void QQmlListModelParser::applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
QQmlListModel *rv = static_cast<QQmlListModel *>(obj);
rv->m_engine = qmlEngine(rv)->handle();
-
- const QV4::CompiledData::Unit *qmlUnit = compilationUnit->data;
+ rv->m_compilationUnit = compilationUnit;
bool setRoles = false;
for (const QV4::CompiledData::Binding *binding : bindings) {
if (binding->type != QV4::CompiledData::Binding::Type_Object)
continue;
- setRoles |= applyProperty(compilationUnit, qmlUnit, binding, rv->m_listModel, /*outter element index*/-1);
+ setRoles |= applyProperty(compilationUnit, binding, rv->m_listModel, /*outter element index*/-1);
}
if (setRoles == false)
diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h
index 0c0859dc80..95b797c898 100644
--- a/src/qml/types/qqmllistmodel_p.h
+++ b/src/qml/types/qqmllistmodel_p.h
@@ -64,6 +64,8 @@
#include <private/qv4engine_p.h>
#include <private/qpodvector_p.h>
+QT_REQUIRE_CONFIG(qml_list_model);
+
QT_BEGIN_NAMESPACE
@@ -122,6 +124,7 @@ private:
friend class ListElement;
friend class DynamicRoleModelNode;
friend class DynamicRoleModelNodeMetaObject;
+ friend struct StringOrTranslation;
// Constructs a flat list model for a worker agent
QQmlListModel(QQmlListModel *orig, QQmlListModelWorkerAgent *agent);
@@ -133,6 +136,7 @@ private:
QQmlListModelWorkerAgent *m_agent;
mutable QV4::ExecutionEngine *m_engine;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;
bool m_mainThread;
bool m_primary;
@@ -183,13 +187,13 @@ public:
QQmlListModelParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {}
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
- void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
private:
- bool verifyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
+ bool verifyProperty(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding);
// returns true if a role was set
- bool applyProperty(QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex);
+ bool applyProperty(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex);
static bool definesEmptyList(const QString &);
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index ad5e94c909..ff52ee049f 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -57,6 +57,8 @@
#include <private/qv4qobjectwrapper_p.h>
#include <qqml.h>
+QT_REQUIRE_CONFIG(qml_list_model);
+
QT_BEGIN_NAMESPACE
@@ -142,16 +144,6 @@ protected:
private:
using QQmlOpenMetaObject::setValue;
- void setValue(const QByteArray &name, const QVariant &val, bool force)
- {
- if (force) {
- QVariant existingValue = value(name);
- if (existingValue.isValid()) {
- (*this)[name] = QVariant();
- }
- }
- setValue(name, val);
- }
void emitDirectNotifies(const int *changedRoles, int roleCount);
@@ -181,12 +173,15 @@ struct ModelObject : public QObjectWrapper {
struct ModelObject : public QObjectWrapper
{
- static bool put(Managed *m, String *name, const Value& value);
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
-
V4_OBJECT2(ModelObject, QObjectWrapper)
V4_NEEDS_DESTROY
+
+ ListModel *listModel() const { return d()->m_model->m_listModel; }
+
+protected:
+ static bool virtualPut(Managed *m, PropertyKey id, const Value& value, Value *receiver);
+ static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
+ static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
};
} // namespace QV4
@@ -252,6 +247,22 @@ private:
QStringHash<Role *> roleHash;
};
+struct StringOrTranslation
+{
+ explicit StringOrTranslation(const QString &s);
+ explicit StringOrTranslation(const QV4::CompiledData::Binding *binding);
+ ~StringOrTranslation();
+ bool isSet() const { return d.flag(); }
+ bool isTranslation() const { return d.isT2(); }
+ void setString(const QString &s);
+ void setTranslation(const QV4::CompiledData::Binding *binding);
+ QString toString(const QQmlListModel *owner) const;
+ QString asString() const;
+private:
+ void clear();
+ QBiPointer<QStringData, const QV4::CompiledData::Binding> d;
+};
+
/*!
\internal
*/
@@ -287,6 +298,7 @@ private:
int setVariantMapProperty(const ListLayout::Role &role, QVariantMap *m);
int setDateTimeProperty(const ListLayout::Role &role, const QDateTime &dt);
int setFunctionProperty(const ListLayout::Role &role, const QJSValue &f);
+ int setTranslationProperty(const ListLayout::Role &role, const QV4::CompiledData::Binding *b);
void setStringPropertyFast(const ListLayout::Role &role, const QString &s);
void setDoublePropertyFast(const ListLayout::Role &role, double n);
@@ -301,7 +313,7 @@ private:
QVariant getProperty(const ListLayout::Role &role, const QQmlListModel *owner, QV4::ExecutionEngine *eng);
ListModel *getListProperty(const ListLayout::Role &role);
- QString *getStringProperty(const ListLayout::Role &role);
+ StringOrTranslation *getStringProperty(const ListLayout::Role &role);
QObject *getQObjectProperty(const ListLayout::Role &role);
QPointer<QObject> *getGuardProperty(const ListLayout::Role &role);
QVariantMap *getVariantMapProperty(const ListLayout::Role &role);
diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h
index 2120f25744..ae2d4b11e0 100644
--- a/src/qml/types/qqmllistmodelworkeragent_p.h
+++ b/src/qml/types/qqmllistmodelworkeragent_p.h
@@ -59,6 +59,8 @@
#include <private/qv8engine_p.h>
+QT_REQUIRE_CONFIG(qml_list_model);
+
QT_BEGIN_NAMESPACE
diff --git a/src/qml/types/qqmlmodelsmodule.cpp b/src/qml/types/qqmlmodelsmodule.cpp
index e217b63c6f..30915d96fd 100644
--- a/src/qml/types/qqmlmodelsmodule.cpp
+++ b/src/qml/types/qqmlmodelsmodule.cpp
@@ -39,9 +39,12 @@
#include "qqmlmodelsmodule_p.h"
#include <QtCore/qitemselectionmodel.h>
+#if QT_CONFIG(qml_list_model)
#include <private/qqmllistmodel_p.h>
+#endif
#if QT_CONFIG(qml_delegate_model)
#include <private/qqmldelegatemodel_p.h>
+#include <private/qqmldelegatecomponent_p.h>
#endif
#include <private/qqmlobjectmodel_p.h>
@@ -51,8 +54,10 @@ void QQmlModelsModule::defineModule()
{
const char uri[] = "QtQml.Models";
+#if QT_CONFIG(qml_list_model)
qmlRegisterType<QQmlListElement>(uri, 2, 1, "ListElement");
qmlRegisterCustomType<QQmlListModel>(uri, 2, 1, "ListModel", new QQmlListModelParser);
+#endif
#if QT_CONFIG(qml_delegate_model)
qmlRegisterType<QQmlDelegateModel>(uri, 2, 1, "DelegateModel");
qmlRegisterType<QQmlDelegateModelGroup>(uri, 2, 1, "DelegateModelGroup");
@@ -63,4 +68,13 @@ void QQmlModelsModule::defineModule()
qmlRegisterType<QItemSelectionModel>(uri, 2, 2, "ItemSelectionModel");
}
+void QQmlModelsModule::defineLabsModule()
+{
+ const char uri[] = "Qt.labs.qmlmodels";
+
+ qmlRegisterUncreatableType<QQmlAbstractDelegateComponent>(uri, 1, 0, "AbstractDelegateComponent", QQmlAbstractDelegateComponent::tr("Cannot create instance of abstract class AbstractDelegateComponent."));
+ qmlRegisterType<QQmlDelegateChooser>(uri, 1, 0, "DelegateChooser");
+ qmlRegisterType<QQmlDelegateChoice>(uri, 1, 0, "DelegateChoice");
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/types/qqmlmodelsmodule_p.h b/src/qml/types/qqmlmodelsmodule_p.h
index bac9bea81e..939ecc1500 100644
--- a/src/qml/types/qqmlmodelsmodule_p.h
+++ b/src/qml/types/qqmlmodelsmodule_p.h
@@ -59,6 +59,7 @@ class Q_QML_PRIVATE_EXPORT QQmlModelsModule
{
public:
static void defineModule();
+ static void defineLabsModule();
};
QT_END_NAMESPACE
diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp
index d94af64fde..2f4d427430 100644
--- a/src/qml/types/qqmlobjectmodel.cpp
+++ b/src/qml/types/qqmlobjectmodel.cpp
@@ -206,27 +206,10 @@ public:
}
\endcode
- \image visualitemmodel.png
+ \image objectmodel.png
\sa {Qt Quick Examples - Views}
*/
-/*!
- \qmltype VisualItemModel
- \instantiates QQmlObjectModel
- \inqmlmodule QtQuick
- \brief Defines a set of objects to be used as a model.
-
- The VisualItemModel type contains the objects to be used
- as a model.
-
- This element is now primarily available as ObjectModel in the QtQml.Models module.
- VisualItemModel continues to be provided, with the same implementation, in \c QtQuick for
- compatibility reasons.
-
- For full details about the type, see the \l ObjectModel documentation.
-
- \sa {QtQml.Models::ObjectModel}
-*/
QQmlObjectModel::QQmlObjectModel(QObject *parent)
: QQmlInstanceModel(*(new QQmlObjectModelPrivate), parent)
diff --git a/src/qml/types/qqmlobjectmodel_p.h b/src/qml/types/qqmlobjectmodel_p.h
index 267828dcdd..4ac4f1c65b 100644
--- a/src/qml/types/qqmlobjectmodel_p.h
+++ b/src/qml/types/qqmlobjectmodel_p.h
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
class QObject;
class QQmlChangeSet;
+class QAbstractItemModel;
class Q_QML_PRIVATE_EXPORT QQmlInstanceModel : public QObject
{
@@ -83,6 +84,7 @@ public:
virtual QQmlIncubator::Status incubationStatus(int index) = 0;
virtual int indexOf(QObject *object, QObject *objectContext) const = 0;
+ virtual const QAbstractItemModel *abstractItemModel() const { return nullptr; }
Q_SIGNALS:
void countChanged();
diff --git a/src/qml/types/qqmltableinstancemodel.cpp b/src/qml/types/qqmltableinstancemodel.cpp
new file mode 100644
index 0000000000..1054158dc8
--- /dev/null
+++ b/src/qml/types/qqmltableinstancemodel.cpp
@@ -0,0 +1,542 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmltableinstancemodel_p.h"
+#include "qqmldelegatecomponent_p.h"
+
+#include <QtCore/QTimer>
+
+#include <QtQml/private/qqmlincubator_p.h>
+#include <QtQml/private/qqmlchangeset_p.h>
+#include <QtQml/private/qqmlcomponent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+const char* kModelItemTag = "_tableinstancemodel_modelItem";
+
+bool QQmlTableInstanceModel::isDoneIncubating(QQmlDelegateModelItem *modelItem)
+{
+ if (!modelItem->incubationTask)
+ return true;
+
+ const auto status = modelItem->incubationTask->status();
+ return (status == QQmlIncubator::Ready) || (status == QQmlIncubator::Error);
+}
+
+void QQmlTableInstanceModel::deleteModelItemLater(QQmlDelegateModelItem *modelItem)
+{
+ Q_ASSERT(modelItem);
+
+ delete modelItem->object;
+ modelItem->object = nullptr;
+
+ if (modelItem->contextData) {
+ modelItem->contextData->invalidate();
+ Q_ASSERT(modelItem->contextData->refCount == 1);
+ modelItem->contextData = nullptr;
+ }
+
+ modelItem->deleteLater();
+}
+
+QQmlTableInstanceModel::QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent)
+ : QQmlInstanceModel(*(new QObjectPrivate()), parent)
+ , m_qmlContext(qmlContext)
+ , m_metaType(new QQmlDelegateModelItemMetaType(m_qmlContext->engine()->handle(), nullptr, QStringList()))
+{
+}
+
+QQmlTableInstanceModel::~QQmlTableInstanceModel()
+{
+ for (const auto modelItem : m_modelItems) {
+ // No item in m_modelItems should be referenced at this point. The view
+ // should release all its items before it deletes this model. Only model items
+ // that are still being incubated should be left for us to delete.
+ Q_ASSERT(modelItem->objectRef == 0);
+ Q_ASSERT(modelItem->incubationTask);
+ // Check that we are not being deleted while we're
+ // in the process of e.g emitting a created signal.
+ Q_ASSERT(modelItem->scriptRef == 0);
+
+ if (modelItem->object) {
+ delete modelItem->object;
+ modelItem->object = nullptr;
+ modelItem->contextData->invalidate();
+ modelItem->contextData = nullptr;
+ }
+ }
+
+ deleteAllFinishedIncubationTasks();
+ qDeleteAll(m_modelItems);
+ drainReusableItemsPool(0);
+}
+
+QQmlComponent *QQmlTableInstanceModel::resolveDelegate(int index)
+{
+ if (m_delegateChooser) {
+ const int row = m_adaptorModel.rowAt(index);
+ const int column = m_adaptorModel.columnAt(index);
+ QQmlComponent *delegate = nullptr;
+ QQmlAbstractDelegateComponent *chooser = m_delegateChooser;
+ do {
+ delegate = chooser->delegate(&m_adaptorModel, row, column);
+ chooser = qobject_cast<QQmlAbstractDelegateComponent *>(delegate);
+ } while (chooser);
+ return delegate;
+ }
+
+ return m_delegate;
+}
+
+QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
+{
+ // Check if an item for the given index is already loaded and ready
+ QQmlDelegateModelItem *modelItem = m_modelItems.value(index, nullptr);
+ if (modelItem)
+ return modelItem;
+
+ QQmlComponent *delegate = resolveDelegate(index);
+ if (!delegate)
+ return nullptr;
+
+ // Check if the pool contains an item that can be reused
+ modelItem = takeFromReusableItemsPool(delegate);
+ if (modelItem) {
+ reuseItem(modelItem, index);
+ m_modelItems.insert(index, modelItem);
+ return modelItem;
+ }
+
+ // Create a new item from scratch
+ modelItem = m_adaptorModel.createItem(m_metaType, index);
+ if (modelItem) {
+ modelItem->delegate = delegate;
+ m_modelItems.insert(index, modelItem);
+ return modelItem;
+ }
+
+ qWarning() << Q_FUNC_INFO << "failed creating a model item for index: " << index;
+ return nullptr;
+}
+
+QObject *QQmlTableInstanceModel::object(int index, QQmlIncubator::IncubationMode incubationMode)
+{
+ Q_ASSERT(m_delegate);
+ Q_ASSERT(index >= 0 && index < m_adaptorModel.count());
+ Q_ASSERT(m_qmlContext && m_qmlContext->isValid());
+
+ QQmlDelegateModelItem *modelItem = resolveModelItem(index);
+ if (!modelItem)
+ return nullptr;
+
+ if (modelItem->object) {
+ // The model item has already been incubated. So
+ // just bump the ref-count and return it.
+ modelItem->referenceObject();
+ return modelItem->object;
+ }
+
+ // The object is not ready, and needs to be incubated
+ incubateModelItem(modelItem, incubationMode);
+ if (!isDoneIncubating(modelItem))
+ return nullptr;
+
+ // Incubation is done, so the task should be removed
+ Q_ASSERT(!modelItem->incubationTask);
+
+ if (!modelItem->object) {
+ // The object was incubated synchronously (otherwise we would return above). But since
+ // we have no object, the incubation must have failed. And when we have no object, there
+ // should be no object references either. And there should also not be any internal script
+ // refs at this point. So we delete the model item.
+ Q_ASSERT(!modelItem->isObjectReferenced());
+ Q_ASSERT(!modelItem->isReferenced());
+ m_modelItems.remove(modelItem->index);
+ delete modelItem;
+ return nullptr;
+ }
+
+ // Incubation was completed sync and successful
+ modelItem->referenceObject();
+ return modelItem->object;
+}
+
+QQmlInstanceModel::ReleaseFlags QQmlTableInstanceModel::release(QObject *object, ReusableFlag reusable)
+{
+ Q_ASSERT(object);
+ auto modelItem = qvariant_cast<QQmlDelegateModelItem *>(object->property(kModelItemTag));
+ Q_ASSERT(modelItem);
+
+ if (!modelItem->releaseObject())
+ return QQmlDelegateModel::Referenced;
+
+ if (modelItem->isReferenced()) {
+ // We still have an internal reference to this object, which means that we are told to release an
+ // object while the createdItem signal for it is still on the stack. This can happen when objects
+ // are e.g delivered async, and the user flicks back and forth quicker than the loading can catch
+ // up with. The view might then find that the object is no longer visible and should be released.
+ // We detect this case in incubatorStatusChanged(), and delete it there instead. But from the callers
+ // point of view, it should consider it destroyed.
+ return QQmlDelegateModel::Destroyed;
+ }
+
+ // The item is not referenced by anyone
+ m_modelItems.remove(modelItem->index);
+
+ if (reusable == Reusable) {
+ insertIntoReusableItemsPool(modelItem);
+ return QQmlInstanceModel::Referenced;
+ }
+
+ // The item is not reused or referenced by anyone, so just delete it
+ modelItem->destroyObject();
+ emit destroyingItem(object);
+
+ delete modelItem;
+ return QQmlInstanceModel::Destroyed;
+}
+
+void QQmlTableInstanceModel::cancel(int index)
+{
+ auto modelItem = m_modelItems.value(index);
+ Q_ASSERT(modelItem);
+
+ // Since the view expects the item to be incubating, there should be
+ // an incubation task. And since the incubation is not done, no-one
+ // should yet have received, and therfore hold a reference to, the object.
+ Q_ASSERT(modelItem->incubationTask);
+ Q_ASSERT(!modelItem->isObjectReferenced());
+
+ m_modelItems.remove(index);
+
+ if (modelItem->object)
+ delete modelItem->object;
+
+ // modelItem->incubationTask will be deleted from the modelItems destructor
+ delete modelItem;
+}
+
+void QQmlTableInstanceModel::insertIntoReusableItemsPool(QQmlDelegateModelItem *modelItem)
+{
+ // Currently, the only way for a view to reuse items is to call QQmlTableInstanceModel::release()
+ // with the second argument explicitly set to QQmlTableInstanceModel::Reusable. If the released
+ // item is no longer referenced, it will be added to the pool. Reusing of items can be specified
+ // per item, in case certain items cannot be recycled.
+ // A QQmlDelegateModelItem knows which delegate its object was created from. So when we are
+ // about to create a new item, we first check if the pool contains an item based on the same
+ // delegate from before. If so, we take it out of the pool (instead of creating a new item), and
+ // update all its context-, and attached properties.
+ // When a view is recycling items, it should call QQmlTableInstanceModel::drainReusableItemsPool()
+ // regularly. As there is currently no logic to 'hibernate' items in the pool, they are only
+ // meant to rest there for a short while, ideally only from the time e.g a row is unloaded
+ // on one side of the view, and until a new row is loaded on the opposite side. In-between
+ // this time, the application will see the item as fully functional and 'alive' (just not
+ // visible on screen). Since this time is supposed to be short, we don't take any action to
+ // notify the application about it, since we don't want to trigger any bindings that can
+ // disturb performance.
+ // A recommended time for calling drainReusableItemsPool() is each time a view has finished
+ // loading e.g a new row or column. If there are more items in the pool after that, it means
+ // that the view most likely doesn't need them anytime soon. Those items should be destroyed to
+ // not consume resources.
+ // Depending on if a view is a list or a table, it can sometimes be performant to keep
+ // items in the pool for a bit longer than one "row out/row in" cycle. E.g for a table, if the
+ // number of visible rows in a view is much larger than the number of visible columns.
+ // In that case, if you flick out a row, and then flick in a column, you would throw away a lot
+ // of items in the pool if completely draining it. The reason is that unloading a row places more
+ // items in the pool than what ends up being recycled when loading a new column. And then, when you
+ // next flick in a new row, you would need to load all those drained items again from scratch. For
+ // that reason, you can specify a maxPoolTime to the drainReusableItemsPool() that allows you to keep
+ // items in the pool for a bit longer, effectively keeping more items in circulation.
+ // A recommended maxPoolTime would be equal to the number of dimenstions in the view, which
+ // means 1 for a list view and 2 for a table view. If you specify 0, all items will be drained.
+ Q_ASSERT(!modelItem->incubationTask);
+ Q_ASSERT(!modelItem->isObjectReferenced());
+ Q_ASSERT(!modelItem->isReferenced());
+ Q_ASSERT(modelItem->object);
+
+ modelItem->poolTime = 0;
+ m_reusableItemsPool.append(modelItem);
+ emit itemPooled(modelItem->index, modelItem->object);
+}
+
+QQmlDelegateModelItem *QQmlTableInstanceModel::takeFromReusableItemsPool(const QQmlComponent *delegate)
+{
+ // Find the oldest item in the pool that was made from the same delegate as
+ // the given argument, remove it from the pool, and return it.
+ if (m_reusableItemsPool.isEmpty())
+ return nullptr;
+
+ for (auto it = m_reusableItemsPool.begin(); it != m_reusableItemsPool.end(); ++it) {
+ if ((*it)->delegate != delegate)
+ continue;
+ auto modelItem = *it;
+ m_reusableItemsPool.erase(it);
+ return modelItem;
+ }
+
+ return nullptr;
+}
+
+void QQmlTableInstanceModel::drainReusableItemsPool(int maxPoolTime)
+{
+ // Rather than releasing all pooled items upon a call to this function, each
+ // item has a poolTime. The poolTime specifies for how many loading cycles an item
+ // has been resting in the pool. And for each invocation of this function, poolTime
+ // will increase. If poolTime is equal to, or exceeds, maxPoolTime, it will be removed
+ // from the pool and released. This way, the view can tweak a bit for how long
+ // items should stay in "circulation", even if they are not recycled right away.
+ for (auto it = m_reusableItemsPool.begin(); it != m_reusableItemsPool.end();) {
+ auto modelItem = *it;
+ modelItem->poolTime++;
+ if (modelItem->poolTime <= maxPoolTime) {
+ ++it;
+ } else {
+ it = m_reusableItemsPool.erase(it);
+ release(modelItem->object, NotReusable);
+ }
+ }
+}
+
+void QQmlTableInstanceModel::reuseItem(QQmlDelegateModelItem *item, int newModelIndex)
+{
+ // Update the context properties index, row and column on
+ // the delegate item, and inform the application about it.
+ const int newRow = m_adaptorModel.rowAt(newModelIndex);
+ const int newColumn = m_adaptorModel.columnAt(newModelIndex);
+ item->setModelIndex(newModelIndex, newRow, newColumn);
+
+ // Notify the application that all 'dynamic'/role-based context data has
+ // changed as well (their getter function will use the updated index).
+ auto const itemAsList = QList<QQmlDelegateModelItem *>() << item;
+ auto const updateAllRoles = QVector<int>();
+ m_adaptorModel.notify(itemAsList, newModelIndex, 1, updateAllRoles);
+
+ // Inform the view that the item is recycled. This will typically result
+ // in the view updating its own attached delegate item properties.
+ emit itemReused(newModelIndex, item->object);
+}
+
+void QQmlTableInstanceModel::incubateModelItem(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode)
+{
+ // Guard the model item temporarily so that it's not deleted from
+ // incubatorStatusChanged(), in case the incubation is done synchronously.
+ modelItem->scriptRef++;
+
+ if (modelItem->incubationTask) {
+ // We're already incubating the model item from a previous request. If the previous call requested
+ // the item async, but the current request needs it sync, we need to force-complete the incubation.
+ const bool sync = (incubationMode == QQmlIncubator::Synchronous || incubationMode == QQmlIncubator::AsynchronousIfNested);
+ if (sync && modelItem->incubationTask->incubationMode() == QQmlIncubator::Asynchronous)
+ modelItem->incubationTask->forceCompletion();
+ } else {
+ modelItem->incubationTask = new QQmlTableInstanceModelIncubationTask(this, modelItem, incubationMode);
+
+ QQmlContextData *ctxt = new QQmlContextData;
+ QQmlContext *creationContext = modelItem->delegate->creationContext();
+ ctxt->setParent(QQmlContextData::get(creationContext ? creationContext : m_qmlContext.data()));
+ ctxt->contextObject = modelItem;
+ modelItem->contextData = ctxt;
+
+ QQmlComponentPrivate::get(modelItem->delegate)->incubateObject(
+ modelItem->incubationTask,
+ modelItem->delegate,
+ m_qmlContext->engine(),
+ ctxt,
+ QQmlContextData::get(m_qmlContext));
+ }
+
+ // Remove the temporary guard
+ modelItem->scriptRef--;
+}
+
+void QQmlTableInstanceModel::incubatorStatusChanged(QQmlTableInstanceModelIncubationTask *incubationTask, QQmlIncubator::Status status)
+{
+ QQmlDelegateModelItem *modelItem = incubationTask->modelItemToIncubate;
+ Q_ASSERT(modelItem->incubationTask);
+
+ modelItem->incubationTask = nullptr;
+ incubationTask->modelItemToIncubate = nullptr;
+
+ if (status == QQmlIncubator::Ready) {
+ // Tag the incubated object with the model item for easy retrieval upon release etc.
+ modelItem->object->setProperty(kModelItemTag, QVariant::fromValue(modelItem));
+
+ // Emit that the item has been created. What normally happens next is that the view
+ // upon receiving the signal asks for the model item once more. And since the item is
+ // now in the map, it will be returned directly.
+ Q_ASSERT(modelItem->object);
+ modelItem->scriptRef++;
+ emit createdItem(modelItem->index, modelItem->object);
+ modelItem->scriptRef--;
+ } else if (status == QQmlIncubator::Error) {
+ qWarning() << "Error incubating delegate:" << incubationTask->errors();
+ }
+
+ if (!modelItem->isReferenced() && !modelItem->isObjectReferenced()) {
+ // We have no internal reference to the model item, and the view has no
+ // reference to the incubated object. So just delete the model item.
+ // Note that being here means that the object was incubated _async_
+ // (otherwise modelItem->isReferenced() would be true).
+ m_modelItems.remove(modelItem->index);
+
+ if (modelItem->object) {
+ modelItem->scriptRef++;
+ emit destroyingItem(modelItem->object);
+ modelItem->scriptRef--;
+ Q_ASSERT(!modelItem->isReferenced());
+ }
+
+ deleteModelItemLater(modelItem);
+ }
+
+ deleteIncubationTaskLater(incubationTask);
+}
+
+QQmlIncubator::Status QQmlTableInstanceModel::incubationStatus(int index) {
+ const auto modelItem = m_modelItems.value(index, nullptr);
+ if (!modelItem)
+ return QQmlIncubator::Null;
+
+ if (modelItem->incubationTask)
+ return modelItem->incubationTask->status();
+
+ // Since we clear the incubation task when we're done
+ // incubating, it means that the status is Ready.
+ return QQmlIncubator::Ready;
+}
+
+void QQmlTableInstanceModel::deleteIncubationTaskLater(QQmlIncubator *incubationTask)
+{
+ // We often need to post-delete incubation tasks, since we cannot
+ // delete them while we're in the middle of an incubation change callback.
+ Q_ASSERT(!m_finishedIncubationTasks.contains(incubationTask));
+ m_finishedIncubationTasks.append(incubationTask);
+ if (m_finishedIncubationTasks.count() == 1)
+ QTimer::singleShot(1, this, &QQmlTableInstanceModel::deleteAllFinishedIncubationTasks);
+}
+
+void QQmlTableInstanceModel::deleteAllFinishedIncubationTasks()
+{
+ qDeleteAll(m_finishedIncubationTasks);
+ m_finishedIncubationTasks.clear();
+}
+
+QVariant QQmlTableInstanceModel::model() const
+{
+ return m_adaptorModel.model();
+}
+
+void QQmlTableInstanceModel::setModel(const QVariant &model)
+{
+ // Pooled items are still accessible/alive for the application, and
+ // needs to stay in sync with the model. So we need to drain the pool
+ // completely when the model changes.
+ drainReusableItemsPool(0);
+ if (auto const aim = abstractItemModel())
+ disconnect(aim, &QAbstractItemModel::dataChanged, this, &QQmlTableInstanceModel::dataChangedCallback);
+ m_adaptorModel.setModel(model, this, m_qmlContext->engine());
+ if (auto const aim = abstractItemModel())
+ connect(aim, &QAbstractItemModel::dataChanged, this, &QQmlTableInstanceModel::dataChangedCallback);
+}
+
+void QQmlTableInstanceModel::dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+{
+ // This function is called when model data has changed. In that case, we tell the adaptor model
+ // to go through all the items we have created, find the ones that are affected, and notify that
+ // their model data has changed. This will in turn update QML bindings inside the delegate items.
+ int numberOfRowsChanged = end.row() - begin.row() + 1;
+ int numberOfColumnsChanged = end.column() - begin.column() + 1;
+
+ for (int column = 0; column < numberOfColumnsChanged; ++column) {
+ const int columnIndex = begin.column() + column;
+ const int rowIndex = begin.row() + (columnIndex * rows());
+ m_adaptorModel.notify(m_modelItems.values(), rowIndex, numberOfRowsChanged, roles);
+ }
+}
+
+QQmlComponent *QQmlTableInstanceModel::delegate() const
+{
+ return m_delegate;
+}
+
+void QQmlTableInstanceModel::setDelegate(QQmlComponent *delegate)
+{
+ if (m_delegate == delegate)
+ return;
+
+ m_delegateChooser = nullptr;
+ if (delegate) {
+ QQmlAbstractDelegateComponent *adc =
+ qobject_cast<QQmlAbstractDelegateComponent *>(delegate);
+ if (adc)
+ m_delegateChooser = adc;
+ }
+
+ m_delegate = delegate;
+}
+
+const QAbstractItemModel *QQmlTableInstanceModel::abstractItemModel() const
+{
+ return m_adaptorModel.adaptsAim() ? m_adaptorModel.aim() : nullptr;
+}
+
+// --------------------------------------------------------
+
+void QQmlTableInstanceModelIncubationTask::setInitialState(QObject *object)
+{
+ modelItemToIncubate->object = object;
+ emit tableInstanceModel->initItem(modelItemToIncubate->index, object);
+}
+
+void QQmlTableInstanceModelIncubationTask::statusChanged(QQmlIncubator::Status status)
+{
+ if (!QQmlTableInstanceModel::isDoneIncubating(modelItemToIncubate))
+ return;
+
+ // We require the view to cancel any ongoing load
+ // requests before the tableInstanceModel is destructed.
+ Q_ASSERT(tableInstanceModel);
+
+ tableInstanceModel->incubatorStatusChanged(this, status);
+}
+
+#include "moc_qqmltableinstancemodel_p.cpp"
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/types/qqmltableinstancemodel_p.h b/src/qml/types/qqmltableinstancemodel_p.h
new file mode 100644
index 0000000000..03761af326
--- /dev/null
+++ b/src/qml/types/qqmltableinstancemodel_p.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTABLEINSTANCEMODEL_P_H
+#define QQMLTABLEINSTANCEMODEL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQml/private/qqmldelegatemodel_p.h>
+#include <QtQml/private/qqmldelegatemodel_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlTableInstanceModel;
+class QQmlAbstractDelegateComponent;
+
+class QQmlTableInstanceModelIncubationTask : public QQDMIncubationTask
+{
+public:
+ QQmlTableInstanceModelIncubationTask(
+ QQmlTableInstanceModel *tableInstanceModel
+ , QQmlDelegateModelItem* modelItemToIncubate
+ , IncubationMode mode)
+ : QQDMIncubationTask(nullptr, mode)
+ , modelItemToIncubate(modelItemToIncubate)
+ , tableInstanceModel(tableInstanceModel) {
+ clear();
+ }
+
+ void statusChanged(Status status) override;
+ void setInitialState(QObject *object) override;
+
+ QQmlDelegateModelItem *modelItemToIncubate = nullptr;
+ QQmlTableInstanceModel *tableInstanceModel = nullptr;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlTableInstanceModel : public QQmlInstanceModel
+{
+ Q_OBJECT
+
+public:
+
+ enum ReusableFlag {
+ NotReusable,
+ Reusable
+ };
+
+ QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent = nullptr);
+ ~QQmlTableInstanceModel() override;
+
+ int count() const override { return m_adaptorModel.count(); }
+ int rows() const { return m_adaptorModel.rowCount(); }
+ int columns() const { return m_adaptorModel.columnCount(); }
+
+ bool isValid() const override { return true; }
+
+ QVariant model() const;
+ void setModel(const QVariant &model);
+
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
+
+ const QAbstractItemModel *abstractItemModel() const override;
+
+ QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
+ ReleaseFlags release(QObject *object) override { return release(object, NotReusable); }
+ ReleaseFlags release(QObject *object, ReusableFlag reusable);
+ void cancel(int) override;
+
+ void insertIntoReusableItemsPool(QQmlDelegateModelItem *modelItem);
+ QQmlDelegateModelItem *takeFromReusableItemsPool(const QQmlComponent *delegate);
+ void drainReusableItemsPool(int maxPoolTime);
+ int poolSize() { return m_reusableItemsPool.size(); }
+ void reuseItem(QQmlDelegateModelItem *item, int newModelIndex);
+
+ QQmlIncubator::Status incubationStatus(int index) override;
+
+ QString stringValue(int, const QString &) override { Q_UNREACHABLE(); return QString(); }
+ void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); }
+ int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE(); return 0; }
+
+Q_SIGNALS:
+ void itemPooled(int index, QObject *object);
+ void itemReused(int index, QObject *object);
+
+private:
+ QQmlComponent *resolveDelegate(int index);
+
+ QQmlAdaptorModel m_adaptorModel;
+ QQmlAbstractDelegateComponent *m_delegateChooser = nullptr;
+ QQmlComponent *m_delegate = nullptr;
+ QPointer<QQmlContext> m_qmlContext;
+ QQmlDelegateModelItemMetaType *m_metaType;
+
+ QHash<int, QQmlDelegateModelItem *> m_modelItems;
+ QList<QQmlDelegateModelItem *> m_reusableItemsPool;
+ QList<QQmlIncubator *> m_finishedIncubationTasks;
+
+ void incubateModelItem(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode);
+ void incubatorStatusChanged(QQmlTableInstanceModelIncubationTask *dmIncubationTask, QQmlIncubator::Status status);
+ void deleteIncubationTaskLater(QQmlIncubator *incubationTask);
+ void deleteAllFinishedIncubationTasks();
+ QQmlDelegateModelItem *resolveModelItem(int index);
+
+ void dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles);
+
+ static bool isDoneIncubating(QQmlDelegateModelItem *modelItem);
+ static void deleteModelItemLater(QQmlDelegateModelItem *modelItem);
+
+ friend class QQmlTableInstanceModelIncubationTask;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLTABLEINSTANCEMODEL_P_H
diff --git a/src/qml/types/qqmltimer_p.h b/src/qml/types/qqmltimer_p.h
index d597869994..0160e97a2f 100644
--- a/src/qml/types/qqmltimer_p.h
+++ b/src/qml/types/qqmltimer_p.h
@@ -57,6 +57,8 @@
#include <private/qtqmlglobal_p.h>
+QT_REQUIRE_CONFIG(qml_animation);
+
QT_BEGIN_NAMESPACE
class QQmlTimerPrivate;
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index 98f819337b..fe51f8ec47 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -37,9 +37,12 @@
**
****************************************************************************/
+#include "qtqmlglobal_p.h"
#include "qquickworkerscript_p.h"
+#if QT_CONFIG(qml_list_model)
#include "qqmllistmodel_p.h"
#include "qqmllistmodelworkeragent_p.h"
+#endif
#include <private/qqmlengine_p.h>
#include <private/qqmlexpression_p.h>
@@ -136,49 +139,26 @@ public:
QQuickWorkerScriptEnginePrivate(QQmlEngine *eng);
- class WorkerEngine : public QV8Engine
- {
- public:
- WorkerEngine(QQuickWorkerScriptEnginePrivate *parent);
- ~WorkerEngine();
+ QQmlEngine *qmlengine;
- void init();
+ QMutex m_lock;
+ QWaitCondition m_wait;
+
+ struct WorkerScript : public QV8Engine {
+ WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent);
+ ~WorkerScript() override;
#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager() override;
#endif
- QQuickWorkerScriptEnginePrivate *p;
-
- QV4::ReturnedValue sendFunction(int id);
-
- QV4::PersistentValue onmessage;
- private:
- QV4::PersistentValue createsend;
+ QQuickWorkerScriptEnginePrivate *p = nullptr;
+ QUrl source;
+ QQuickWorkerScript *owner = nullptr;
#if QT_CONFIG(qml_network)
- QNetworkAccessManager *accessManager;
+ QScopedPointer<QNetworkAccessManager> accessManager;
#endif
- };
-
- WorkerEngine *workerEngine;
- static QQuickWorkerScriptEnginePrivate *get(QV8Engine *e) {
- return static_cast<WorkerEngine *>(e)->p;
- }
-
- QQmlEngine *qmlengine;
-
- QMutex m_lock;
- QWaitCondition m_wait;
-
- struct WorkerScript {
- WorkerScript();
- ~WorkerScript();
-
- int id;
- QUrl source;
- bool initialized;
- QQuickWorkerScript *owner;
- QV4::PersistentValue qmlContext;
+ int id = -1;
};
QHash<int, WorkerScript *> workers;
@@ -200,97 +180,8 @@ private:
void reportScriptException(WorkerScript *, const QQmlError &error);
};
-QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
- : QV8Engine(nullptr, new QV4::ExecutionEngine), p(parent)
-#if QT_CONFIG(qml_network)
-, accessManager(nullptr)
-#endif
-{
- m_v4Engine->v8Engine = this;
-}
-
-QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
-{
-#if QT_CONFIG(qml_network)
- delete accessManager;
-#endif
- delete m_v4Engine;
-}
-
-void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
-{
- initQmlGlobalObject();
-#define CALL_ONMESSAGE_SCRIPT \
- "(function(object, message) { "\
- "var isfunction = false; "\
- "try { "\
- "isfunction = object.WorkerScript.onMessage instanceof Function; "\
- "} catch (e) {}" \
- "if (isfunction) "\
- "object.WorkerScript.onMessage(message); "\
- "})"
-
-#define SEND_MESSAGE_CREATE_SCRIPT \
- "(function(method, engine) { "\
- "return (function(id) { "\
- "return (function(message) { "\
- "if (arguments.length) method(engine, id, message); "\
- "}); "\
- "}); "\
- "})"
-
- QV4::Scope scope(m_v4Engine);
- QV4::ExecutionContext *globalContext = scope.engine->rootContext();
- onmessage.set(scope.engine, QV4::Script(globalContext, QV4::Compiler::GlobalCode, QString::fromUtf8(CALL_ONMESSAGE_SCRIPT)).run()); // do not use QStringLiteral here, MSVC2012 cannot apply this cleanly to the macro
- Q_ASSERT(!scope.engine->hasException);
- QV4::Script createsendscript(globalContext, QV4::Compiler::GlobalCode, QString::fromUtf8(SEND_MESSAGE_CREATE_SCRIPT)); // do not use QStringLiteral here, MSVC2012 cannot apply this cleanly to the macro
- QV4::ScopedFunctionObject createsendconstructor(scope, createsendscript.run());
- Q_ASSERT(!scope.engine->hasException);
- QV4::ScopedString name(scope, m_v4Engine->newString(QStringLiteral("sendMessage")));
- QV4::ScopedValue function(scope, QV4::FunctionObject::createBuiltinFunction(globalContext, name,
- QQuickWorkerScriptEnginePrivate::method_sendMessage));
- QV4::JSCallData jsCallData(scope, 1);
- jsCallData->args[0] = function;
- *jsCallData->thisObject = m_v4Engine->global();
- createsend.set(scope.engine, createsendconstructor->call(jsCallData));
-}
-
-// Requires handle and context scope
-QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(int id)
-{
- QV4::ExecutionEngine *v4 = createsend.engine();
- if (!v4)
- return QV4::Encode::undefined();
-
- QV4::Scope scope(v4);
- QV4::ScopedFunctionObject f(scope, createsend.value());
-
- QV4::ScopedValue v(scope);
- QV4::JSCallData jsCallData(scope, 1);
- jsCallData->args[0] = QV4::Primitive::fromInt32(id);
- *jsCallData->thisObject = m_v4Engine->global();
- v = f->call(jsCallData);
- if (scope.hasException())
- v = scope.engine->catchException();
- return v->asReturnedValue();
-}
-
-#if QT_CONFIG(qml_network)
-QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
-{
- if (!accessManager) {
- if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
- accessManager = p->qmlengine->networkAccessManagerFactory()->create(p);
- } else {
- accessManager = new QNetworkAccessManager(p);
- }
- }
- return accessManager;
-}
-#endif
-
QQuickWorkerScriptEnginePrivate::QQuickWorkerScriptEnginePrivate(QQmlEngine *engine)
-: workerEngine(nullptr), qmlengine(engine), m_nextId(0)
+: qmlengine(engine), m_nextId(0)
{
}
@@ -298,35 +189,18 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(const QV4
const QV4::Value *, const QV4::Value *argv, int argc)
{
QV4::Scope scope(b);
- WorkerEngine *engine = static_cast<WorkerEngine *>(scope.engine->v8Engine);
-
- int id = argc > 1 ? argv[1].toInt32() : 0;
+ WorkerScript *script = static_cast<WorkerScript *>(scope.engine->v8Engine);
- QV4::ScopedValue v(scope, argc > 2 ? argv[2] : QV4::Primitive::undefinedValue());
+ QV4::ScopedValue v(scope, argc > 0 ? argv[0] : QV4::Value::undefinedValue());
QByteArray data = QV4::Serialize::serialize(v, scope.engine);
- QMutexLocker locker(&engine->p->m_lock);
- WorkerScript *script = engine->p->workers.value(id);
+ QMutexLocker locker(&script->p->m_lock);
if (script && script->owner)
QCoreApplication::postEvent(script->owner, new WorkerDataEvent(0, data));
return QV4::Encode::undefined();
}
-QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *script)
-{
- if (!script->initialized) {
- script->initialized = true;
-
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
- QV4::Scope scope(v4);
- QV4::ScopedValue v(scope, workerEngine->sendFunction(script->id));
- script->qmlContext.set(v4, QV4::QmlContext::createWorkerContext(v4->rootContext(), script->source, v));
- }
-
- return script->qmlContext.value();
-}
-
bool QQuickWorkerScriptEnginePrivate::event(QEvent *event)
{
if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
@@ -341,6 +215,7 @@ bool QQuickWorkerScriptEnginePrivate::event(QEvent *event)
emit stopThread();
return true;
} else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
+ QMutexLocker locker(&m_lock);
WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
QHash<int, WorkerScript *>::iterator itr = workers.find(workerEvent->workerId());
if (itr != workers.end()) {
@@ -359,19 +234,23 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d
if (!script)
return;
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(script);
QV4::Scope scope(v4);
- QV4::ScopedFunctionObject f(scope, workerEngine->onmessage.value());
+ QV4::ScopedString v(scope);
+ QV4::ScopedObject worker(scope, v4->globalObject->get((v = v4->newString(QStringLiteral("WorkerScript")))));
+ QV4::ScopedFunctionObject onmessage(scope);
+ if (worker)
+ onmessage = worker->get((v = v4->newString(QStringLiteral("onMessage"))));
+
+ if (!onmessage)
+ return;
QV4::ScopedValue value(scope, QV4::Serialize::deserialize(data, v4));
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, script->qmlContext.value());
- Q_ASSERT(!!qmlContext);
- QV4::JSCallData jsCallData(scope, 2);
+ QV4::JSCallData jsCallData(scope, 1);
*jsCallData->thisObject = v4->global();
- jsCallData->args[0] = qmlContext->d()->qml(); // ###
- jsCallData->args[1] = value;
- f->call(jsCallData);
+ jsCallData->args[0] = value;
+ onmessage->call(jsCallData);
if (scope.hasException()) {
QQmlError error = scope.engine->catchExceptionAsQmlError();
reportScriptException(script, error);
@@ -385,29 +264,37 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QString fileName = QQmlFile::urlToLocalFileOrQrc(url);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
- QV4::Scope scope(v4);
- QScopedPointer<QV4::Script> program;
-
WorkerScript *script = workers.value(id);
if (!script)
return;
+
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(script);
+
script->source = url;
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, getWorker(script));
- Q_ASSERT(!!qmlContext);
+ if (fileName.endsWith(QLatin1String(".mjs"))) {
+ auto moduleUnit = v4->loadModule(url);
+ if (moduleUnit) {
+ if (moduleUnit->instantiate(v4))
+ moduleUnit->evaluate();
+ } else {
+ v4->throwError(QStringLiteral("Could not load module file"));
+ }
+ } else {
+ QString error;
+ QV4::Scope scope(v4);
+ QScopedPointer<QV4::Script> program;
+ program.reset(QV4::Script::createFromFileOrCache(v4, /*qmlContext*/nullptr, fileName, url, &error));
+ if (program.isNull()) {
+ if (!error.isEmpty())
+ qWarning().nospace() << error;
+ return;
+ }
- QString error;
- program.reset(QV4::Script::createFromFileOrCache(v4, qmlContext, fileName, url, &error));
- if (program.isNull()) {
- if (!error.isEmpty())
- qWarning().nospace() << error;
- return;
+ if (!v4->hasException)
+ program->run();
}
- if (!v4->hasException)
- program->run();
-
if (v4->hasException) {
QQmlError error = v4->catchExceptionAsQmlError();
reportScriptException(script, error);
@@ -417,9 +304,7 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
void QQuickWorkerScriptEnginePrivate::reportScriptException(WorkerScript *script,
const QQmlError &error)
{
- QQuickWorkerScriptEnginePrivate *p = QQuickWorkerScriptEnginePrivate::get(workerEngine);
-
- QMutexLocker locker(&p->m_lock);
+ QMutexLocker locker(&script->p->m_lock);
if (script->owner)
QCoreApplication::postEvent(script->owner, new WorkerErrorEvent(error));
}
@@ -508,21 +393,47 @@ QQuickWorkerScriptEngine::~QQuickWorkerScriptEngine()
d->deleteLater();
}
-QQuickWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
-: id(-1), initialized(false), owner(nullptr)
+QQuickWorkerScriptEnginePrivate::WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent)
+ : QV8Engine(new QV4::ExecutionEngine)
+ , p(parent)
+ , id(id)
{
+ m_v4Engine->v8Engine = this;
+
+ initQmlGlobalObject();
+
+ QV4::Scope scope(m_v4Engine);
+ QV4::ScopedObject api(scope, scope.engine->newObject());
+ QV4::ScopedString name(scope, m_v4Engine->newString(QStringLiteral("sendMessage")));
+ QV4::ScopedValue sendMessage(scope, QV4::FunctionObject::createBuiltinFunction(m_v4Engine, name, method_sendMessage, 1));
+ api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), sendMessage);
+ m_v4Engine->globalObject->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api);
}
QQuickWorkerScriptEnginePrivate::WorkerScript::~WorkerScript()
{
+ delete m_v4Engine;
}
+#if QT_CONFIG(qml_network)
+QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerScript::networkAccessManager()
+{
+ if (!accessManager) {
+ if (p->qmlengine && p->qmlengine->networkAccessManagerFactory()) {
+ accessManager.reset(p->qmlengine->networkAccessManagerFactory()->create(p));
+ } else {
+ accessManager.reset(new QNetworkAccessManager(p));
+ }
+ }
+ return accessManager.data();
+}
+#endif
+
int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner)
{
typedef QQuickWorkerScriptEnginePrivate::WorkerScript WorkerScript;
- WorkerScript *script = new WorkerScript;
+ WorkerScript *script = new WorkerScript(d->m_nextId++, d);
- script->id = d->m_nextId++;
script->owner = owner;
d->m_lock.lock();
@@ -555,9 +466,6 @@ void QQuickWorkerScriptEngine::run()
{
d->m_lock.lock();
- d->workerEngine = new QQuickWorkerScriptEnginePrivate::WorkerEngine(d);
- d->workerEngine->init();
-
d->m_wait.wakeAll();
d->m_lock.unlock();
@@ -566,8 +474,6 @@ void QQuickWorkerScriptEngine::run()
qDeleteAll(d->workers);
d->workers.clear();
-
- delete d->workerEngine; d->workerEngine = nullptr;
}
@@ -589,22 +495,32 @@ void QQuickWorkerScriptEngine::run()
\snippet qml/workerscript/workerscript.qml 0
- The above worker script specifies a JavaScript file, "script.js", that handles
- the operations to be performed in the new thread. Here is \c script.js:
+ The above worker script specifies a JavaScript file, "script.mjs", that handles
+ the operations to be performed in the new thread. Here is \c script.mjs:
- \quotefile qml/workerscript/script.js
+ \quotefile qml/workerscript/script.mjs
When the user clicks anywhere within the rectangle, \c sendMessage() is
called, triggering the \tt WorkerScript.onMessage() handler in
- \tt script.js. This in turn sends a reply message that is then received
+ \tt script.mjs. This in turn sends a reply message that is then received
by the \tt onMessage() handler of \tt myWorker.
+ The example uses a script that is an ECMAScript module, because it has the ".mjs" extension.
+ It can use import statements to access functionality from other modules and it is run in JavaScript
+ strict mode.
+
+ If a worker script has the extension ".js" instead, then it is considered to contain plain JavaScript
+ statements and it is run in non-strict mode.
+
+ \note Each WorkerScript element will instantiate a separate JavaScript engine to ensure perfect
+ isolation and thread-safety. If the impact of that results in a memory consumption that is too
+ high for your environment, then consider sharing a WorkerScript element.
\section3 Restrictions
Since the \c WorkerScript.onMessage() function is run in a separate thread, the
JavaScript file is evaluated in a context separate from the main QML engine. This means
- that unlike an ordinary JavaScript file that is imported into QML, the \c script.js
+ that unlike an ordinary JavaScript file that is imported into QML, the \c script.mjs
in the above example cannot access the properties, methods or other attributes
of the QML item, nor can it access any context properties set on the QML object
through QQmlContext.
@@ -612,7 +528,8 @@ void QQuickWorkerScriptEngine::run()
Additionally, there are restrictions on the types of values that can be passed to and
from the worker script. See the sendMessage() documentation for details.
- Worker script can not use \l {qtqml-javascript-imports.html}{.import} syntax.
+ Worker scripts that are plain JavaScript sources can not use \l {qtqml-javascript-imports.html}{.import} syntax.
+ Scripts that are ECMAScript modules can freely use import and export statements.
\sa {Qt Quick Examples - Threading},
{Threaded ListModel Example}
@@ -632,6 +549,10 @@ QQuickWorkerScript::~QQuickWorkerScript()
This holds the url of the JavaScript file that implements the
\tt WorkerScript.onMessage() handler for threaded operations.
+
+ If the file name component of the url ends with ".mjs", then the script
+ is parsed as an ECMAScript module and run in strict mode. Otherwise it is considered to be
+ plain script.
*/
QUrl QQuickWorkerScript::source() const
{
@@ -679,7 +600,7 @@ void QQuickWorkerScript::sendMessage(QQmlV4Function *args)
}
QV4::Scope scope(args->v4engine());
- QV4::ScopedValue argument(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue argument(scope, QV4::Value::undefinedValue());
if (args->length() != 0)
argument = (*args)[0];
diff --git a/src/qml/types/types.pri b/src/qml/types/types.pri
index 8bcbd6e544..e74c89b1f1 100644
--- a/src/qml/types/types.pri
+++ b/src/qml/types/types.pri
@@ -1,39 +1,54 @@
SOURCES += \
$$PWD/qqmlbind.cpp \
$$PWD/qqmlconnections.cpp \
- $$PWD/qqmllistmodel.cpp \
- $$PWD/qqmllistmodelworkeragent.cpp \
$$PWD/qqmlmodelsmodule.cpp \
$$PWD/qqmlmodelindexvaluetype.cpp \
$$PWD/qqmlobjectmodel.cpp \
$$PWD/qquickpackage.cpp \
- $$PWD/qquickworkerscript.cpp \
- $$PWD/qqmlinstantiator.cpp
+ $$PWD/qqmlinstantiator.cpp \
+ $$PWD/qqmltableinstancemodel.cpp
HEADERS += \
$$PWD/qqmlbind_p.h \
$$PWD/qqmlconnections_p.h \
- $$PWD/qqmllistmodel_p.h \
- $$PWD/qqmllistmodel_p_p.h \
- $$PWD/qqmllistmodelworkeragent_p.h \
$$PWD/qqmlmodelsmodule_p.h \
$$PWD/qqmlmodelindexvaluetype_p.h \
$$PWD/qqmlobjectmodel_p.h \
$$PWD/qquickpackage_p.h \
- $$PWD/qquickworkerscript_p.h \
$$PWD/qqmlinstantiator_p.h \
- $$PWD/qqmlinstantiator_p_p.h
+ $$PWD/qqmlinstantiator_p_p.h \
+ $$PWD/qqmltableinstancemodel_p.h
+
+qtConfig(qml-worker-script) {
+ SOURCES += \
+ $$PWD/qquickworkerscript.cpp
+ HEADERS += \
+ $$PWD/qquickworkerscript_p.h
+}
+
+qtConfig(qml-list-model) {
+ SOURCES += \
+ $$PWD/qqmllistmodel.cpp \
+ $$PWD/qqmllistmodelworkeragent.cpp
+
+ HEADERS += \
+ $$PWD/qqmllistmodel_p.h \
+ $$PWD/qqmllistmodel_p_p.h \
+ $$PWD/qqmllistmodelworkeragent_p.h
+}
qtConfig(qml-delegate-model) {
SOURCES += \
- $$PWD/qqmldelegatemodel.cpp
+ $$PWD/qqmldelegatemodel.cpp \
+ $$PWD/qqmldelegatecomponent.cpp
HEADERS += \
$$PWD/qqmldelegatemodel_p.h \
- $$PWD/qqmldelegatemodel_p_p.h
+ $$PWD/qqmldelegatemodel_p_p.h \
+ $$PWD/qqmldelegatecomponent_p.h
}
-qtConfig(animation) {
+qtConfig(qml-animation) {
SOURCES += \
$$PWD/qqmltimer.cpp
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index b4bebb9d5d..b5caaba727 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -96,7 +96,7 @@ public:
QQmlDMCachedModelData(
QQmlDelegateModelItemMetaType *metaType,
VDMModelDelegateDataType *dataType,
- int index);
+ int index, int row, int column);
int metaCall(QMetaObject::Call call, int id, void **arguments);
@@ -228,8 +228,8 @@ public:
QV4::ScopedString name(scope, v4->newString(QString::fromUtf8(propertyName)));
QV4::ExecutionContext *global = v4->rootContext();
- QV4::ScopedFunctionObject g(scope, v4->memoryManager->allocObject<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::get_property));
- QV4::ScopedFunctionObject s(scope, v4->memoryManager->allocObject<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::set_property));
+ QV4::ScopedFunctionObject g(scope, v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::get_property));
+ QV4::ScopedFunctionObject s(scope, v4->memoryManager->allocate<QV4::IndexedBuiltinFunction>(global, propertyId, QQmlDMCachedModelData::set_property));
p->setGetter(g);
p->setSetter(s);
proto->insertMember(name, p, QV4::Attr_Accessor|QV4::Attr_NotEnumerable|QV4::Attr_NotConfigurable);
@@ -262,9 +262,8 @@ public:
bool hasModelData;
};
-QQmlDMCachedModelData::QQmlDMCachedModelData(
- QQmlDelegateModelItemMetaType *metaType, VDMModelDelegateDataType *dataType, int index)
- : QQmlDelegateModelItem(metaType, index)
+QQmlDMCachedModelData::QQmlDMCachedModelData(QQmlDelegateModelItemMetaType *metaType, VDMModelDelegateDataType *dataType, int index, int row, int column)
+ : QQmlDelegateModelItem(metaType, index, row, column)
, type(dataType)
{
if (index == -1)
@@ -326,13 +325,12 @@ void QQmlDMCachedModelData::setValue(const QString &role, const QVariant &value)
}
}
-bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx)
+bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &adaptorModel, int idx)
{
if (index == -1) {
Q_ASSERT(idx >= 0);
- index = idx;
cachedData.clear();
- emit modelIndexChanged();
+ setModelIndex(idx, adaptorModel.rowAt(idx), adaptorModel.columnAt(idx));
const QMetaObject *meta = metaObject();
const int propertyCount = type->propertyRoles.count();
for (int i = 0; i < propertyCount; ++i)
@@ -400,12 +398,13 @@ class QQmlDMAbstractItemModelData : public QQmlDMCachedModelData
{
Q_OBJECT
Q_PROPERTY(bool hasModelChildren READ hasModelChildren CONSTANT)
+
public:
QQmlDMAbstractItemModelData(
QQmlDelegateModelItemMetaType *metaType,
VDMModelDelegateDataType *dataType,
- int index)
- : QQmlDMCachedModelData(metaType, dataType, index)
+ int index, int row, int column)
+ : QQmlDMCachedModelData(metaType, dataType, index, row, column)
{
}
@@ -413,7 +412,7 @@ public:
{
if (index >= 0 && *type->model) {
const QAbstractItemModel * const model = type->model->aim();
- return model->hasChildren(model->index(index, 0, type->model->rootIndex));
+ return model->hasChildren(model->index(row, column, type->model->rootIndex));
} else {
return false;
}
@@ -421,13 +420,13 @@ public:
QVariant value(int role) const override
{
- return type->model->aim()->index(index, 0, type->model->rootIndex).data(role);
+ return type->model->aim()->index(row, column, type->model->rootIndex).data(role);
}
void setValue(int role, const QVariant &value) override
{
type->model->aim()->setData(
- type->model->aim()->index(index, 0, type->model->rootIndex), value, role);
+ type->model->aim()->index(row, column, type->model->rootIndex), value, role);
}
QV4::ReturnedValue get() override
@@ -438,8 +437,8 @@ public:
}
QV4::Scope scope(v4);
QV4::ScopedObject proto(scope, type->prototype.value());
- QV4::ScopedObject o(scope, proto->engine()->memoryManager->allocObject<QQmlDelegateModelItemObject>(this));
- o->setPrototype(proto);
+ QV4::ScopedObject o(scope, proto->engine()->memoryManager->allocate<QQmlDelegateModelItemObject>(this));
+ o->setPrototypeOf(proto);
++scriptRef;
return o.asReturnedValue();
}
@@ -453,31 +452,18 @@ public:
{
}
- int count(const QQmlAdaptorModel &model) const override
+ int rowCount(const QQmlAdaptorModel &model) const override
{
return model.aim()->rowCount(model.rootIndex);
}
- void cleanup(QQmlAdaptorModel &model, QQmlDelegateModel *vdm) const override
- {
- QAbstractItemModel * const aim = model.aim();
- if (aim && vdm) {
- QObject::disconnect(aim, SIGNAL(rowsInserted(QModelIndex,int,int)),
- vdm, SLOT(_q_rowsInserted(QModelIndex,int,int)));
- QObject::disconnect(aim, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- vdm, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- vdm, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
- QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
- vdm, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
- QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
- vdm, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
- QObject::disconnect(aim, SIGNAL(modelReset()),
- vdm, SLOT(_q_modelReset()));
- QObject::disconnect(aim, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
- vdm, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
- }
+ int columnCount(const QQmlAdaptorModel &model) const override
+ {
+ return model.aim()->columnCount(model.rootIndex);
+ }
+ void cleanup(QQmlAdaptorModel &) const override
+ {
const_cast<VDMAbstractItemModelDataType *>(this)->release();
}
@@ -485,9 +471,9 @@ public:
{
QHash<QByteArray, int>::const_iterator it = roleNames.find(role.toUtf8());
if (it != roleNames.end()) {
- return model.aim()->index(index, 0, model.rootIndex).data(*it);
+ return model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex).data(*it);
} else if (role == QLatin1String("hasModelChildren")) {
- return QVariant(model.aim()->hasChildren(model.aim()->index(index, 0, model.rootIndex)));
+ return QVariant(model.aim()->hasChildren(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex)));
} else {
return QVariant();
}
@@ -503,7 +489,7 @@ public:
QVariant modelIndex(const QQmlAdaptorModel &model, int index) const override
{
return model
- ? QVariant::fromValue(model.aim()->index(index, 0, model.rootIndex))
+ ? QVariant::fromValue(model.aim()->index(model.rowAt(index), model.columnAt(index), model.rootIndex))
: QVariant();
}
@@ -521,12 +507,12 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
QQmlDelegateModelItemMetaType *metaType,
- int index) const override
+ int index, int row, int column) const override
{
VDMAbstractItemModelDataType *dataType = const_cast<VDMAbstractItemModelDataType *>(this);
if (!metaObject)
dataType->initializeMetaType(model);
- return new QQmlDMAbstractItemModelData(metaType, dataType, index);
+ return new QQmlDMAbstractItemModelData(metaType, dataType, index, row, column);
}
void initializeMetaType(QQmlAdaptorModel &model)
@@ -567,8 +553,8 @@ class QQmlDMListAccessorData : public QQmlDelegateModelItem
Q_OBJECT
Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
public:
- QQmlDMListAccessorData(QQmlDelegateModelItemMetaType *metaType, int index, const QVariant &value)
- : QQmlDelegateModelItem(metaType, index)
+ QQmlDMListAccessorData(QQmlDelegateModelItemMetaType *metaType, int index, int row, int column, const QVariant &value)
+ : QQmlDelegateModelItem(metaType, index, row, column)
, cachedData(value)
{
}
@@ -580,10 +566,11 @@ public:
void setModelData(const QVariant &data)
{
- if (index == -1 && data != cachedData) {
- cachedData = data;
- emit modelDataChanged();
- }
+ if (data == cachedData)
+ return;
+
+ cachedData = data;
+ emit modelDataChanged();
}
static QV4::ReturnedValue get_modelData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
@@ -613,9 +600,9 @@ public:
{
QQmlAdaptorModelEngineData *data = engineData(v4);
QV4::Scope scope(v4);
- QV4::ScopedObject o(scope, v4->memoryManager->allocObject<QQmlDelegateModelItemObject>(this));
+ QV4::ScopedObject o(scope, v4->memoryManager->allocate<QQmlDelegateModelItemObject>(this));
QV4::ScopedObject p(scope, data->listItemProto.value());
- o->setPrototype(p);
+ o->setPrototypeOf(p);
++scriptRef;
return o.asReturnedValue();
}
@@ -653,11 +640,16 @@ class VDMListDelegateDataType : public QQmlAdaptorModel::Accessors
public:
inline VDMListDelegateDataType() {}
- int count(const QQmlAdaptorModel &model) const override
+ int rowCount(const QQmlAdaptorModel &model) const override
{
return model.list.count();
}
+ int columnCount(const QQmlAdaptorModel &) const override
+ {
+ return 1;
+ }
+
QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override
{
return role == QLatin1String("modelData")
@@ -668,13 +660,27 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
QQmlDelegateModelItemMetaType *metaType,
- int index) const override
+ int index, int row, int column) const override
{
return new QQmlDMListAccessorData(
metaType,
- index,
+ index, row, column,
index >= 0 && index < model.list.count() ? model.list.at(index) : QVariant());
}
+
+ bool notify(const QQmlAdaptorModel &model, const QList<QQmlDelegateModelItem *> &items, int index, int count, const QVector<int> &) const override
+ {
+ for (auto modelItem : items) {
+ const int modelItemIndex = modelItem->index;
+ if (modelItemIndex < index || modelItemIndex >= index + count)
+ continue;
+
+ auto listModelItem = static_cast<QQmlDMListAccessorData *>(modelItem);
+ QVariant updatedModelData = model.list.at(listModelItem->index);
+ listModelItem->setModelData(updatedModelData);
+ }
+ return true;
+ }
};
//-----------------------------------------------------------------
@@ -685,19 +691,31 @@ class VDMObjectDelegateDataType;
class QQmlDMObjectData : public QQmlDelegateModelItem, public QQmlAdaptorModelProxyInterface
{
Q_OBJECT
- Q_PROPERTY(QObject *modelData READ modelData CONSTANT)
+ Q_PROPERTY(QObject *modelData READ modelData NOTIFY modelDataChanged)
Q_INTERFACES(QQmlAdaptorModelProxyInterface)
public:
QQmlDMObjectData(
QQmlDelegateModelItemMetaType *metaType,
VDMObjectDelegateDataType *dataType,
- int index,
+ int index, int row, int column,
QObject *object);
+ void setModelData(QObject *modelData)
+ {
+ if (modelData == object)
+ return;
+
+ object = modelData;
+ emit modelDataChanged();
+ }
+
QObject *modelData() const { return object; }
QObject *proxiedObject() override { return object; }
QPointer<QObject> object;
+
+Q_SIGNALS:
+ void modelDataChanged();
};
class VDMObjectDelegateDataType : public QQmlRefCount, public QQmlAdaptorModel::Accessors
@@ -737,11 +755,16 @@ public:
free(metaObject);
}
- int count(const QQmlAdaptorModel &model) const override
+ int rowCount(const QQmlAdaptorModel &model) const override
{
return model.list.count();
}
+ int columnCount(const QQmlAdaptorModel &) const override
+ {
+ return 1;
+ }
+
QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override
{
if (QObject *object = model.list.at(index).value<QObject *>())
@@ -752,13 +775,13 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
QQmlDelegateModelItemMetaType *metaType,
- int index) const override
+ int index, int row, int column) const override
{
VDMObjectDelegateDataType *dataType = const_cast<VDMObjectDelegateDataType *>(this);
if (!metaObject)
dataType->initializeMetaType(model);
return index >= 0 && index < model.list.count()
- ? new QQmlDMObjectData(metaType, dataType, index, qvariant_cast<QObject *>(model.list.at(index)))
+ ? new QQmlDMObjectData(metaType, dataType, index, row, column, qvariant_cast<QObject *>(model.list.at(index)))
: nullptr;
}
@@ -769,10 +792,24 @@ public:
metaObject = builder.toMetaObject();
}
- void cleanup(QQmlAdaptorModel &, QQmlDelegateModel *) const override
+ void cleanup(QQmlAdaptorModel &) const override
{
const_cast<VDMObjectDelegateDataType *>(this)->release();
}
+
+ bool notify(const QQmlAdaptorModel &model, const QList<QQmlDelegateModelItem *> &items, int index, int count, const QVector<int> &) const override
+ {
+ for (auto modelItem : items) {
+ const int modelItemIndex = modelItem->index;
+ if (modelItemIndex < index || modelItemIndex >= index + count)
+ continue;
+
+ auto objectModelItem = static_cast<QQmlDMObjectData *>(modelItem);
+ QObject *updatedModelData = qvariant_cast<QObject *>(model.list.at(objectModelItem->index));
+ objectModelItem->setModelData(updatedModelData);
+ }
+ return true;
+ }
};
class QQmlDMObjectDataMetaObject : public QAbstractDynamicMetaObject
@@ -872,12 +909,11 @@ public:
VDMObjectDelegateDataType *m_type;
};
-QQmlDMObjectData::QQmlDMObjectData(
- QQmlDelegateModelItemMetaType *metaType,
+QQmlDMObjectData::QQmlDMObjectData(QQmlDelegateModelItemMetaType *metaType,
VDMObjectDelegateDataType *dataType,
- int index,
+ int index, int row, int column,
QObject *object)
- : QQmlDelegateModelItem(metaType, index)
+ : QQmlDelegateModelItem(metaType, index, row, column)
, object(object)
{
new QQmlDMObjectDataMetaObject(this, dataType);
@@ -904,50 +940,34 @@ QQmlAdaptorModel::~QQmlAdaptorModel()
accessors->cleanup(*this);
}
-void QQmlAdaptorModel::setModel(const QVariant &variant, QQmlDelegateModel *vdm, QQmlEngine *engine)
+void QQmlAdaptorModel::setModel(const QVariant &variant, QObject *parent, QQmlEngine *engine)
{
- accessors->cleanup(*this, vdm);
+ accessors->cleanup(*this);
list.setList(variant, engine);
if (QObject *object = qvariant_cast<QObject *>(list.list())) {
- setObject(object);
- if (QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(object)) {
+ setObject(object, parent);
+ if (qobject_cast<QAbstractItemModel *>(object))
accessors = new VDMAbstractItemModelDataType(this);
-
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
- vdm, QQmlDelegateModel, SLOT(_q_rowsInserted(QModelIndex,int,int)));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- vdm, QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- vdm, QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
- vdm, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
- vdm, QQmlDelegateModel, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int)));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(modelReset()),
- vdm, QQmlDelegateModel, SLOT(_q_modelReset()));
- qmlobject_connect(model, QAbstractItemModel, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
- vdm, QQmlDelegateModel, SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
- } else {
+ else
accessors = new VDMObjectDelegateDataType;
- }
} else if (list.type() == QQmlListAccessor::ListProperty) {
- setObject(static_cast<const QQmlListReference *>(variant.constData())->object());
+ setObject(static_cast<const QQmlListReference *>(variant.constData())->object(), parent);
accessors = new VDMObjectDelegateDataType;
} else if (list.type() != QQmlListAccessor::Invalid
&& list.type() != QQmlListAccessor::Instance) { // Null QObject
- setObject(nullptr);
+ setObject(nullptr, parent);
accessors = &qt_vdm_list_accessors;
} else {
- setObject(nullptr);
+ setObject(nullptr, parent);
accessors = &qt_vdm_null_accessors;
}
}
-void QQmlAdaptorModel::invalidateModel(QQmlDelegateModel *vdm)
+void QQmlAdaptorModel::invalidateModel()
{
- accessors->cleanup(*this, vdm);
+ accessors->cleanup(*this);
accessors = &qt_vdm_null_accessors;
// Don't clear the model object as we still need the guard to clear the list variant if the
// object is destroyed.
@@ -958,6 +978,38 @@ bool QQmlAdaptorModel::isValid() const
return accessors != &qt_vdm_null_accessors;
}
+int QQmlAdaptorModel::count() const
+{
+ return rowCount() * columnCount();
+}
+
+int QQmlAdaptorModel::rowCount() const
+{
+ return qMax(0, accessors->rowCount(*this));
+}
+
+int QQmlAdaptorModel::columnCount() const
+{
+ return qMax(isValid() ? 1 : 0, accessors->columnCount(*this));
+}
+
+int QQmlAdaptorModel::rowAt(int index) const
+{
+ int count = rowCount();
+ return count <= 0 ? -1 : index % count;
+}
+
+int QQmlAdaptorModel::columnAt(int index) const
+{
+ int count = rowCount();
+ return count <= 0 ? -1 : index / count;
+}
+
+int QQmlAdaptorModel::indexAt(int row, int column) const
+{
+ return column * rowCount() + row;
+}
+
void QQmlAdaptorModel::objectDestroyed(QObject *)
{
setModel(QVariant(), nullptr, nullptr);
diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h
index b152a886a5..b5e0881078 100644
--- a/src/qml/util/qqmladaptormodel_p.h
+++ b/src/qml/util/qqmladaptormodel_p.h
@@ -54,8 +54,9 @@
#include <QtCore/qabstractitemmodel.h>
#include "private/qqmllistaccessor_p.h"
-
+#include <private/qqmlglobal_p.h>
#include <private/qqmlguard_p.h>
+#include <private/qqmlnullablevalue_p.h>
QT_REQUIRE_CONFIG(qml_delegate_model);
@@ -67,7 +68,7 @@ class QQmlDelegateModel;
class QQmlDelegateModelItem;
class QQmlDelegateModelItemMetaType;
-class QQmlAdaptorModel : public QQmlGuard<QObject>
+class Q_QML_PRIVATE_EXPORT QQmlAdaptorModel : public QQmlStrongJSQObjectReference<QObject>
{
public:
class Accessors
@@ -75,8 +76,9 @@ public:
public:
inline Accessors() {}
virtual ~Accessors();
- virtual int count(const QQmlAdaptorModel &) const { return 0; }
- virtual void cleanup(QQmlAdaptorModel &, QQmlDelegateModel * = nullptr) const {}
+ virtual int rowCount(const QQmlAdaptorModel &) const { return 0; }
+ virtual int columnCount(const QQmlAdaptorModel &) const { return 0; }
+ virtual void cleanup(QQmlAdaptorModel &) const {}
virtual QVariant value(const QQmlAdaptorModel &, int, const QString &) const {
return QVariant(); }
@@ -84,7 +86,7 @@ public:
virtual QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &,
QQmlDelegateModelItemMetaType *,
- int) const { return nullptr; }
+ int, int, int) const { return nullptr; }
virtual bool notify(
const QQmlAdaptorModel &,
@@ -112,19 +114,25 @@ public:
~QQmlAdaptorModel();
inline QVariant model() const { return list.list(); }
- void setModel(const QVariant &variant, QQmlDelegateModel *vdm, QQmlEngine *engine);
- void invalidateModel(QQmlDelegateModel *vdm);
+ void setModel(const QVariant &variant, QObject *parent, QQmlEngine *engine);
+ void invalidateModel();
bool isValid() const;
-
+ int count() const;
+ int rowCount() const;
+ int columnCount() const;
+ int rowAt(int index) const;
+ int columnAt(int index) const;
+ int indexAt(int row, int column) const;
+
+ inline bool adaptsAim() const { return qobject_cast<QAbstractItemModel *>(object()); }
inline QAbstractItemModel *aim() { return static_cast<QAbstractItemModel *>(object()); }
inline const QAbstractItemModel *aim() const { return static_cast<const QAbstractItemModel *>(object()); }
- inline int count() const { return qMax(0, accessors->count(*this)); }
inline QVariant value(int index, const QString &role) const {
return accessors->value(*this, index, role); }
inline QQmlDelegateModelItem *createItem(QQmlDelegateModelItemMetaType *metaType, int index) {
- return accessors->createItem(*this, metaType, index); }
+ return accessors->createItem(*this, metaType, index, rowAt(index), columnAt(index)); }
inline bool hasProxyObject() const {
return list.type() == QQmlListAccessor::Instance || list.type() == QQmlListAccessor::ListProperty; }
diff --git a/src/qml/util/qqmllistaccessor.cpp b/src/qml/util/qqmllistaccessor.cpp
index ad55519ad3..46a11e2bc2 100644
--- a/src/qml/util/qqmllistaccessor.cpp
+++ b/src/qml/util/qqmllistaccessor.cpp
@@ -81,7 +81,26 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine)
} else if (d.userType() == QMetaType::QVariantList) {
m_type = VariantList;
} else if (d.canConvert(QVariant::Int)) {
- m_type = Integer;
+ // Here we have to check for an upper limit, because down the line code might (well, will)
+ // allocate memory depending on the number of elements. The upper limit cannot be INT_MAX:
+ // QVector<QPointer<QQuickItem>> something;
+ // something.resize(count());
+ // (See e.g. QQuickRepeater::regenerate())
+ // This will allocate data along the lines of:
+ // sizeof(QPointer<QQuickItem>) * count() + QVector::headerSize
+ // So, doing an approximate round-down-to-nice-number, we get:
+ const int upperLimit = 100 * 1000 * 1000;
+
+ int i = v.toInt();
+ if (i < 0) {
+ qWarning("Model size of %d is less than 0", i);
+ m_type = Invalid;
+ } else if (i > upperLimit) {
+ qWarning("Model size of %d is bigger than the upper limit %d", i, upperLimit);
+ m_type = Invalid;
+ } else {
+ m_type = Integer;
+ }
} else if ((!enginePrivate && QQmlMetaType::isQObject(d.userType())) ||
(enginePrivate && enginePrivate->isQObject(d.userType()))) {
QObject *data = enginePrivate?enginePrivate->toQObject(d):QQmlMetaType::toQObject(d);
diff --git a/src/qml/util/qqmllistcompositor.cpp b/src/qml/util/qqmllistcompositor.cpp
index 8b0b8f48f0..921e86f355 100644
--- a/src/qml/util/qqmllistcompositor.cpp
+++ b/src/qml/util/qqmllistcompositor.cpp
@@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE
ranges is often quite small, which helps as well. If there is a need for faster random access
then a skip list like index may be an appropriate addition.
- \sa VisualDataModel
+ \sa DelegateModel
*/
#ifdef QT_QML_VERIFY_MINIMAL
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
index 578c05086f..3f78ca6b69 100644
--- a/src/qml/util/qqmlpropertymap.cpp
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -122,7 +122,7 @@ QVariant QQmlPropertyMapMetaObject::propertyWriteValue(int index, const QVariant
void QQmlPropertyMapMetaObject::propertyWritten(int index)
{
- priv->emitChanged(priv->propertyName(index), operator[](index));
+ priv->emitChanged(priv->propertyName(index), value(index));
}
void QQmlPropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilder &b)
@@ -311,7 +311,7 @@ QVariant &QQmlPropertyMap::operator[](const QString &key)
if (!d->keys.contains(key))
insert(key, QVariant());//force creation -- needed below
- return (*(d->mo))[utf8key];
+ return d->mo->valueRef(utf8key);
}
/*!
diff --git a/src/qmldebug/qmldebug.pro b/src/qmldebug/qmldebug.pro
index 2c1b71797d..0807482d23 100644
--- a/src/qmldebug/qmldebug.pro
+++ b/src/qmldebug/qmldebug.pro
@@ -9,6 +9,7 @@ SOURCES += \
qqmldebugconnection.cpp \
qqmldebugmessageclient.cpp \
qqmlenginecontrolclient.cpp \
+ qqmlpreviewclient.cpp \
qqmlprofilerclient.cpp \
qqmlprofilerevent.cpp \
qqmlprofilereventlocation.cpp \
@@ -22,6 +23,8 @@ HEADERS += \
qqmldebugmessageclient_p.h \
qqmlenginecontrolclient_p.h \
qqmlenginecontrolclient_p_p.h \
+ qqmlpreviewclient_p.h \
+ qqmlpreviewclient_p_p.h \
qqmlprofilerclient_p.h \
qqmlprofilerclient_p_p.h \
qqmlprofilerevent_p.h \
diff --git a/src/qmldebug/qqmldebugclient.cpp b/src/qmldebug/qqmldebugclient.cpp
index d412b7b267..03123cc6e0 100644
--- a/src/qmldebug/qqmldebugclient.cpp
+++ b/src/qmldebug/qqmldebugclient.cpp
@@ -117,11 +117,6 @@ QQmlDebugConnection *QQmlDebugClient::connection() const
return d->connection;
}
-void QQmlDebugClient::stateChanged(QQmlDebugClient::State state)
-{
- Q_UNUSED(state);
-}
-
void QQmlDebugClient::messageReceived(const QByteArray &message)
{
Q_UNUSED(message);
diff --git a/src/qmldebug/qqmldebugclient_p.h b/src/qmldebug/qqmldebugclient_p.h
index 723de5ee43..469b65d4a9 100644
--- a/src/qmldebug/qqmldebugclient_p.h
+++ b/src/qmldebug/qqmldebugclient_p.h
@@ -76,13 +76,14 @@ public:
QQmlDebugConnection *connection() const;
+signals:
+ void stateChanged(State state);
+
protected:
QQmlDebugClient(QQmlDebugClientPrivate &dd);
private:
friend class QQmlDebugConnection;
-
- virtual void stateChanged(State state);
virtual void messageReceived(const QByteArray &message);
};
diff --git a/src/qmldebug/qqmldebugconnection.cpp b/src/qmldebug/qqmldebugconnection.cpp
index 67bad8d812..4e087ee6db 100644
--- a/src/qmldebug/qqmldebugconnection.cpp
+++ b/src/qmldebug/qqmldebugconnection.cpp
@@ -259,7 +259,7 @@ QQmlDebugConnection::~QQmlDebugConnection()
Q_D(QQmlDebugConnection);
QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter)
- iter.value()->stateChanged(QQmlDebugClient::NotConnected);
+ emit iter.value()->stateChanged(QQmlDebugClient::NotConnected);
}
int QQmlDebugConnection::currentDataStreamVersion() const
@@ -295,7 +295,7 @@ void QQmlDebugConnection::close()
QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter)
- iter.value()->stateChanged(QQmlDebugClient::NotConnected);
+ emit iter.value()->stateChanged(QQmlDebugClient::NotConnected);
}
if (d->device) {
diff --git a/src/qmldebug/qqmldebugmessageclient.cpp b/src/qmldebug/qqmldebugmessageclient.cpp
index a03c1f8af2..0892404194 100644
--- a/src/qmldebug/qqmldebugmessageclient.cpp
+++ b/src/qmldebug/qqmldebugmessageclient.cpp
@@ -58,11 +58,6 @@ QQmlDebugMessageClient::QQmlDebugMessageClient(QQmlDebugConnection *client)
{
}
-void QQmlDebugMessageClient::stateChanged(State state)
-{
- emit newState(state);
-}
-
void QQmlDebugMessageClient::messageReceived(const QByteArray &data)
{
QDataStream ds(data);
diff --git a/src/qmldebug/qqmldebugmessageclient_p.h b/src/qmldebug/qqmldebugmessageclient_p.h
index 75c70044e4..a2a7f28f81 100644
--- a/src/qmldebug/qqmldebugmessageclient_p.h
+++ b/src/qmldebug/qqmldebugmessageclient_p.h
@@ -71,15 +71,10 @@ class QQmlDebugMessageClient : public QQmlDebugClient
public:
explicit QQmlDebugMessageClient(QQmlDebugConnection *client);
- virtual void stateChanged(State state) override;
virtual void messageReceived(const QByteArray &) override;
signals:
- void newState(QQmlDebugClient::State);
void message(QtMsgType, const QString &, const QQmlDebugContextInfo &);
-
-private:
- Q_DISABLE_COPY(QQmlDebugMessageClient)
};
QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmlenginecontrolclient.cpp b/src/qmldebug/qqmlenginecontrolclient.cpp
index 45d672d4bc..cdc724ef2f 100644
--- a/src/qmldebug/qqmlenginecontrolclient.cpp
+++ b/src/qmldebug/qqmlenginecontrolclient.cpp
@@ -98,8 +98,8 @@ void QQmlEngineControlClient::messageReceived(const QByteArray &data)
{
Q_D(QQmlEngineControlClient);
QPacket stream(d->connection->currentDataStreamVersion(), data);
- int message;
- int id;
+ qint32 message;
+ qint32 id;
QString name;
stream >> message >> id;
@@ -150,7 +150,7 @@ void QQmlEngineControlClientPrivate::sendCommand(
{
Q_Q(QQmlEngineControlClient);
QPacket stream(connection->currentDataStreamVersion());
- stream << int(command) << engineId;
+ stream << static_cast<qint32>(command) << engineId;
q->sendMessage(stream.data());
}
diff --git a/src/qmldebug/qqmlpreviewclient.cpp b/src/qmldebug/qqmlpreviewclient.cpp
new file mode 100644
index 0000000000..60937b9cfd
--- /dev/null
+++ b/src/qmldebug/qqmlpreviewclient.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qqmlpreviewclient_p_p.h"
+#include <private/qpacket_p.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+#include <QtQml/qqmlfile.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlPreviewClient::QQmlPreviewClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(*(new QQmlPreviewClientPrivate(connection)))
+{
+}
+
+void QQmlPreviewClient::messageReceived(const QByteArray &message)
+{
+ QPacket packet(connection()->currentDataStreamVersion(), message);
+
+ qint8 command;
+ packet >> command;
+
+ switch (command) {
+ case Error: {
+ QString seviceError;
+ packet >> seviceError;
+ emit error(seviceError);
+ break;
+ }
+ case Request: {
+ QString fileName;
+ packet >> fileName;
+ emit request(fileName);
+ break;
+ }
+ case Fps: {
+ FpsInfo info;
+ packet >> info.numSyncs >> info.minSync >> info.maxSync >> info.totalSync
+ >> info.numRenders >> info.minRender >> info.maxRender >> info.totalRender;
+ emit fps(info);
+ break;
+ }
+ default:
+ emit error(QString::fromLatin1("Unknown command received: %1").arg(command));
+ break;
+ }
+}
+
+void QQmlPreviewClient::sendDirectory(const QString &path, const QStringList &entries)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Directory) << path << entries;
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::sendFile(const QString &path, const QByteArray &contents)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(File) << path << contents;
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::sendError(const QString &path)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Error) << path;
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::triggerLoad(const QUrl &url)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Load) << url;
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::triggerRerun()
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Rerun);
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::triggerZoom(float factor)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Zoom) << factor;
+ sendMessage(packet.data());
+}
+
+void QQmlPreviewClient::triggerLanguage(const QUrl &url, const QString &locale)
+{
+ QPacket packet(connection()->currentDataStreamVersion());
+ packet << static_cast<qint8>(Language) << url << locale;
+ sendMessage(packet.data());
+}
+
+QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmlpreviewclient_p.h b/src/qmldebug/qqmlpreviewclient_p.h
new file mode 100644
index 0000000000..65661613e9
--- /dev/null
+++ b/src/qmldebug/qqmlpreviewclient_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QQMLPREVIEWCLIENT_P_H
+#define QQMLPREVIEWCLIENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugconnection_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlPreviewClientPrivate;
+class QQmlPreviewClient : public QQmlDebugClient
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlPreviewClient)
+public:
+ enum Command {
+ File,
+ Load,
+ Request,
+ Error,
+ Rerun,
+ Directory,
+ ClearCache,
+ Zoom,
+ Fps,
+ Language
+ };
+
+ struct FpsInfo {
+ quint16 numSyncs = 0;
+ quint16 minSync = std::numeric_limits<quint16>::max();
+ quint16 maxSync = 0;
+ quint16 totalSync = 0;
+
+ quint16 numRenders = 0;
+ quint16 minRender = std::numeric_limits<quint16>::max();
+ quint16 maxRender = 0;
+ quint16 totalRender = 0;
+ };
+
+ QQmlPreviewClient(QQmlDebugConnection *parent);
+ void messageReceived(const QByteArray &message) override;
+
+ void sendDirectory(const QString &path, const QStringList &entries);
+ void sendFile(const QString &path, const QByteArray &contents);
+ void sendError(const QString &path);
+
+ void triggerLoad(const QUrl &url);
+ void triggerRerun();
+ void triggerZoom(float factor);
+ void triggerLanguage(const QUrl &url, const QString &locale);
+
+signals:
+ void request(const QString &path);
+ void error(const QString &message);
+ void fps(const FpsInfo &info);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLPREVIEWCLIENT_P_H
diff --git a/src/qml/qml/ftw/qdeferredcleanup_p.h b/src/qmldebug/qqmlpreviewclient_p_p.h
index 6b59f04a77..8fb2b4b18c 100644
--- a/src/qml/qml/ftw/qdeferredcleanup_p.h
+++ b/src/qmldebug/qqmlpreviewclient_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -37,8 +37,11 @@
**
****************************************************************************/
-#ifndef QDEFERREDCLEANUP_P_H
-#define QDEFERREDCLEANUP_P_H
+#ifndef QQMLPREVIEWCLIENT_P_P_H
+#define QQMLPREVIEWCLIENT_P_P_H
+
+#include "qqmlpreviewclient_p.h"
+#include "qqmldebugclient_p_p.h"
//
// W A R N I N G
@@ -51,24 +54,17 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
-
-#include <functional>
-
QT_BEGIN_NAMESPACE
-struct QDeferredCleanup
+class QQmlPreviewClientPrivate : public QQmlDebugClientPrivate
{
- std::function<void()> callback;
- template <typename Callback>
- QDeferredCleanup(Callback &&cb)
- : callback(cb)
+ Q_DECLARE_PUBLIC(QQmlPreviewClient)
+public:
+ QQmlPreviewClientPrivate(QQmlDebugConnection *connection)
+ : QQmlDebugClientPrivate(QLatin1String("QmlPreview"), connection)
{}
- ~QDeferredCleanup() { callback(); }
- QDeferredCleanup(const QDeferredCleanup &) = delete;
- QDeferredCleanup &operator=(const QDeferredCleanup &) = delete;
};
QT_END_NAMESPACE
-#endif // QDEFERREDCLEANUP_P_H
+#endif // QQMLPREVIEWCLIENT_P_P_H
diff --git a/src/qmldebug/qqmlprofilerclient.cpp b/src/qmldebug/qqmlprofilerclient.cpp
index 661b43f164..73db2ad94d 100644
--- a/src/qmldebug/qqmlprofilerclient.cpp
+++ b/src/qmldebug/qqmlprofilerclient.cpp
@@ -42,6 +42,10 @@
QT_BEGIN_NAMESPACE
+QQmlProfilerClientPrivate::~QQmlProfilerClientPrivate()
+{
+}
+
int QQmlProfilerClientPrivate::resolveType(const QQmlProfilerTypedEvent &event)
{
int typeIndex = -1;
@@ -165,6 +169,7 @@ QQmlProfilerClient::QQmlProfilerClient(QQmlDebugConnection *connection,
{
Q_D(QQmlProfilerClient);
setRequestedFeatures(features);
+ connect(this, &QQmlDebugClient::stateChanged, this, &QQmlProfilerClient::onStateChanged);
connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeAdded,
this, &QQmlProfilerClient::sendRecordingStatus);
connect(d->engineControl.data(), &QQmlEngineControlClient::engineAboutToBeRemoved,
@@ -314,7 +319,7 @@ bool QQmlProfilerClientPrivate::updateFeatures(ProfileFeature feature)
return true;
}
-void QQmlProfilerClient::stateChanged(State status)
+void QQmlProfilerClient::onStateChanged(State status)
{
if (status == Enabled) {
sendRecordingStatus(-1);
diff --git a/src/qmldebug/qqmlprofilerclient_p.h b/src/qmldebug/qqmlprofilerclient_p.h
index 7b8e286f5b..89c117a8b5 100644
--- a/src/qmldebug/qqmlprofilerclient_p.h
+++ b/src/qmldebug/qqmlprofilerclient_p.h
@@ -76,7 +76,6 @@ public:
void setRecording(bool);
quint64 recordedFeatures() const;
virtual void messageReceived(const QByteArray &) override;
- virtual void stateChanged(State status) override;
void clearEvents();
void clearAll();
@@ -87,6 +86,7 @@ public:
protected:
QQmlProfilerClient(QQmlProfilerClientPrivate &dd);
+ void onStateChanged(State status);
signals:
void complete(qint64 maximumTime);
diff --git a/src/qmldebug/qqmlprofilerclient_p_p.h b/src/qmldebug/qqmlprofilerclient_p_p.h
index 994c08cafc..df73209858 100644
--- a/src/qmldebug/qqmlprofilerclient_p_p.h
+++ b/src/qmldebug/qqmlprofilerclient_p_p.h
@@ -79,7 +79,7 @@ public:
{
}
- virtual ~QQmlProfilerClientPrivate() override {}
+ virtual ~QQmlProfilerClientPrivate() override;
void sendRecordingStatus(int engineId);
bool updateFeatures(ProfileFeature feature);
@@ -112,4 +112,3 @@ public:
QT_END_NAMESPACE
#endif // QQMLPROFILERCLIENT_P_P_H
-
diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro
index 23b7cf651e..05aa6f66f5 100644
--- a/src/qmldevtools/qmldevtools.pro
+++ b/src/qmldevtools/qmldevtools.pro
@@ -1,7 +1,7 @@
option(host_build)
TARGET = QtQmlDevTools
QT = core-private
-CONFIG += minimal_syncqt internal_module qmldevtools_build
+CONFIG += minimal_syncqt internal_module qmldevtools_build generated_privates
MODULE_INCNAME = QtQml
INCLUDEPATH += $$OUT_PWD/../qml
diff --git a/src/qmltest/doc/src/qtquicktest-index.qdoc b/src/qmltest/doc/src/qtquicktest-index.qdoc
index 1f84db405c..700bddc8d5 100644
--- a/src/qmltest/doc/src/qtquicktest-index.qdoc
+++ b/src/qmltest/doc/src/qtquicktest-index.qdoc
@@ -146,12 +146,20 @@
\li Name
\li Purpose
\row
+ \row
+ \li void applicationAvailable()
+ \li Called right after the QApplication object was instantiated.
+ Use this function to setup everything that is not related
+ to QML directly.
\li void qmlEngineAvailable(QQmlEngine*)
\li Called when the QML engine is available.
Any \l {QQmlEngine::addImportPath}{import paths},
\l {QQmlEngine::addPluginPath}{plugin paths},
and \l {QQmlFileSelector::setExtraSelectors}{extra file selectors}
will have been set on the engine by this point.
+ \li void cleanupTestCase()
+ \li Called right after the test execution has finished.
+ Use this function to clean up before everything will start to be destructed.
\endtable
Each function will be called once for each \c tst_*.qml file, so any
diff --git a/src/qmltest/qtestoptions_p.h b/src/qmltest/qtestoptions_p.h
index 68fe09f793..7be5c88590 100644
--- a/src/qmltest/qtestoptions_p.h
+++ b/src/qmltest/qtestoptions_p.h
@@ -51,7 +51,11 @@
// We mean it.
//
-#include <QtTest/qttestglobal.h>
+#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+# include <QtTest/qtest_global.h>
+#else
+# include <QtTest/qttestglobal.h>
+#endif
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 8b9ff4c5cd..f666bc2284 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -215,8 +215,8 @@ public:
m_errors += component.errors();
if (component.isReady()) {
- CompilationUnit *rootCompilationUnit = QQmlComponentPrivate::get(&component)->compilationUnit;
- TestCaseEnumerationResult result = enumerateTestCases(rootCompilationUnit);
+ QQmlRefPointer<CompilationUnit> rootCompilationUnit = QQmlComponentPrivate::get(&component)->compilationUnit;
+ TestCaseEnumerationResult result = enumerateTestCases(rootCompilationUnit.data());
m_testCases = result.testCases + result.finalizedPartialTestCases();
m_errors += result.errors;
}
@@ -258,8 +258,8 @@ private:
TestCaseEnumerationResult enumerateTestCases(CompilationUnit *compilationUnit, const Object *object = nullptr)
{
QQmlType testCaseType;
- for (quint32 i = 0; i < compilationUnit->data->nImports; ++i) {
- const Import *import = compilationUnit->data->importAt(i);
+ for (quint32 i = 0, count = compilationUnit->importCount(); i < count; ++i) {
+ const Import *import = compilationUnit->importAt(i);
if (compilationUnit->stringAt(import->uriIndex) != QLatin1Literal("QtTest"))
continue;
@@ -278,7 +278,7 @@ private:
if (!object) // Start at root of compilation unit if not enumerating a specific child
object = compilationUnit->objectAt(0);
- if (CompilationUnit *superTypeUnit = compilationUnit->resolvedTypes.value(object->inheritedTypeNameIndex)->compilationUnit) {
+ if (CompilationUnit *superTypeUnit = compilationUnit->resolvedTypes.value(object->inheritedTypeNameIndex)->compilationUnit.data()) {
// We have a non-C++ super type, which could indicate we're a subtype of a TestCase
if (testCaseType.isValid() && superTypeUnit->url() == testCaseType.sourceUrl())
result.isTestCase = true;
@@ -359,6 +359,11 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
}
}
+ if (setup) {
+ // Don't check the return value; it's OK if it doesn't exist.
+ QMetaObject::invokeMethod(setup, "applicationAvailable");
+ }
+
// Look for QML-specific command-line options.
// -import dir Specify an import directory.
// -plugins dir Specify a directory where to search for plugins.
@@ -476,6 +481,9 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
// Register the test object
qmlRegisterSingletonType<QTestRootObject>("Qt.test.qtestroot", 1, 0, "QTestRootObject", testRootObject);
+ QSet<QString> commandLineTestFunctions = QTest::testFunctions.toSet();
+ const bool filteringTestFunctions = !commandLineTestFunctions.isEmpty();
+
// Scan through all of the "tst_*.qml" files and run each of them
// in turn with a separate QQuickView (for test isolation).
for (const QString &file : qAsConst(files)) {
@@ -508,10 +516,10 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
continue;
}
- static const QSet<QString> commandLineTestFunctions = QTest::testFunctions.toSet();
- if (!commandLineTestFunctions.isEmpty() &&
- !availableTestFunctions.toSet().intersects(commandLineTestFunctions))
+ const QSet<QString> availableTestSet = availableTestFunctions.toSet();
+ if (filteringTestFunctions && !availableTestSet.intersects(commandLineTestFunctions))
continue;
+ commandLineTestFunctions.subtract(availableTestSet);
QQuickView view(&engine, nullptr);
view.setFlags(Qt::Window | Qt::WindowSystemMenuHint
@@ -580,10 +588,23 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
}
}
+ if (setup) {
+ // Don't check the return value; it's OK if it doesn't exist.
+ QMetaObject::invokeMethod(setup, "cleanupTestCase");
+ }
+
// Flush the current logging stream.
QuickTestResult::setProgramName(nullptr);
delete app;
+ // Check that all test functions passed on the command line were found
+ if (!commandLineTestFunctions.isEmpty()) {
+ qWarning() << "Could not find the following test functions:";
+ for (const QString &functionName : qAsConst(commandLineTestFunctions))
+ qWarning(" %s()", qUtf8Printable(functionName));
+ return commandLineTestFunctions.count();
+ }
+
// Return the number of failures as the exit code.
return QuickTestResult::exitCode();
}
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index ee375a896c..480811d95c 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -144,6 +144,7 @@ namespace QtQuickTest
int lastMouseTimestamp = 0;
+ // TODO should be Qt::MouseButtons buttons in case multiple buttons are pressed
static void mouseEvent(MouseAction action, QWindow *window,
QObject *item, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, const QPointF &_pos, int delay=-1)
@@ -252,6 +253,7 @@ bool QuickTestEvent::mousePress
QWindow *view = eventWindow(item);
if (!view)
return false;
+ m_pressedButtons.setFlag(Qt::MouseButton(button), true);
QtQuickTest::mouseEvent(QtQuickTest::MousePress, view, item,
Qt::MouseButton(button),
Qt::KeyboardModifiers(modifiers),
@@ -281,6 +283,7 @@ bool QuickTestEvent::mouseRelease
QWindow *view = eventWindow(item);
if (!view)
return false;
+ m_pressedButtons.setFlag(Qt::MouseButton(button), false);
QtQuickTest::mouseEvent(QtQuickTest::MouseRelease, view, item,
Qt::MouseButton(button),
Qt::KeyboardModifiers(modifiers),
@@ -336,8 +339,9 @@ bool QuickTestEvent::mouseMove
QWindow *view = eventWindow(item);
if (!view)
return false;
+ const Qt::MouseButtons effectiveButtons = buttons ? Qt::MouseButtons(buttons) : m_pressedButtons;
QtQuickTest::mouseEvent(QtQuickTest::MouseMove, view, item,
- Qt::MouseButton(buttons), Qt::NoModifier,
+ Qt::MouseButton(int(effectiveButtons)), Qt::NoModifier,
QPointF(x, y), delay);
return true;
}
diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h
index f33f339cdd..5208c03a82 100644
--- a/src/qmltest/quicktestevent_p.h
+++ b/src/qmltest/quicktestevent_p.h
@@ -119,6 +119,8 @@ private:
QWindow *activeWindow();
QTouchDevice *touchDevice();
+ Qt::MouseButtons m_pressedButtons;
+
friend class QQuickTouchEventSequence;
};
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index c4a3280cf6..3b854dfccd 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -61,6 +61,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/QUrl>
#include <QtCore/QDir>
+#include <QtCore/qregularexpression.h>
#include <QtQuick/qquickwindow.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qimagewriter.h>
@@ -625,9 +626,18 @@ void QuickTestResult::warn(const QString &message, const QUrl &location, int lin
QTestLog::warn(message.toLatin1().constData(), qtestFixUrl(location).toLatin1().constData(), line);
}
-void QuickTestResult::ignoreWarning(const QString &message)
+void QuickTestResult::ignoreWarning(const QJSValue &message)
{
- QTestLog::ignoreMessage(QtWarningMsg, message.toLatin1().constData());
+ if (message.isRegExp()) {
+ // ### we should probably handle QRegularExpression conversion engine-side
+ QRegExp re = message.toVariant().toRegExp();
+ QRegularExpression::PatternOptions opts = re.caseSensitivity() ==
+ Qt::CaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption;
+ QRegularExpression re2(re.pattern(), opts);
+ QTestLog::ignoreMessage(QtWarningMsg, re2);
+ } else {
+ QTestLog::ignoreMessage(QtWarningMsg, message.toString().toLatin1());
+ }
}
void QuickTestResult::wait(int ms)
diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h
index 6e7b72830e..f222cd3e87 100644
--- a/src/qmltest/quicktestresult_p.h
+++ b/src/qmltest/quicktestresult_p.h
@@ -137,7 +137,7 @@ public Q_SLOTS:
const QUrl &location, int line);
void warn(const QString &message, const QUrl &location, int line);
- void ignoreWarning(const QString &message);
+ void ignoreWarning(const QJSValue &message);
void wait(int ms);
void sleep(int ms);
diff --git a/src/quick/configure.json b/src/quick/configure.json
index 2c57c3318f..9ec3531ef4 100644
--- a/src/quick/configure.json
+++ b/src/quick/configure.json
@@ -15,6 +15,7 @@
"quick-flipable": "boolean",
"quick-gridview": "boolean",
"quick-listview": "boolean",
+ "quick-tableview": "boolean",
"quick-path": "boolean",
"quick-pathview": "boolean",
"quick-positioners": "boolean",
@@ -86,7 +87,7 @@
},
"quick-itemview": {
"label": "ItemView item",
- "condition": "features.quick-gridview || features.quick-listview",
+ "condition": "features.quick-gridview || features.quick-listview || features.quick-tableview",
"output": [
"privateFeature"
]
@@ -107,6 +108,14 @@
"privateFeature"
]
},
+ "quick-tableview": {
+ "label": "TableView item",
+ "purpose": "Provides the TableView item.",
+ "section": "Qt Quick",
+ "output": [
+ "privateFeature"
+ ]
+ },
"quick-particles": {
"label": "Particle support",
"purpose": "Provides a particle system.",
@@ -183,6 +192,7 @@
"quick-flipable",
"quick-gridview",
"quick-listview",
+ "quick-tableview",
"quick-path",
"quick-pathview",
"quick-positioners",
diff --git a/src/quick/designer/qqmldesignermetaobject.cpp b/src/quick/designer/qqmldesignermetaobject.cpp
index 09493c30d6..2efcdada8b 100644
--- a/src/quick/designer/qqmldesignermetaobject.cpp
+++ b/src/quick/designer/qqmldesignermetaobject.cpp
@@ -83,7 +83,7 @@ static QQmlPropertyCache *cacheForObject(QObject *object, QQmlEngine *engine)
{
QQmlVMEMetaObject *metaObject = QQmlVMEMetaObject::get(object);
if (metaObject)
- return metaObject->cache;
+ return metaObject->cache.data();
return QQmlEnginePrivate::get(engine)->cache(object);
}
@@ -139,7 +139,7 @@ QQmlDesignerMetaObject::QQmlDesignerMetaObject(QObject *object, QQmlEngine *engi
cache->setParent(ddata->propertyCache);
cache->invalidate(engine, this);
ddata->propertyCache->release();
- ddata->propertyCache = cache;
+ ddata->propertyCache = cache.data();
ddata->propertyCache->addref();
}
diff --git a/src/quick/designer/qquickdesignercustomparserobject.cpp b/src/quick/designer/qquickdesignercustomparserobject.cpp
index 9145b1367a..50a8b6a25b 100644
--- a/src/quick/designer/qquickdesignercustomparserobject.cpp
+++ b/src/quick/designer/qquickdesignercustomparserobject.cpp
@@ -46,12 +46,12 @@ QQuickDesignerCustomParserObject::QQuickDesignerCustomParserObject()
}
-void QQuickDesignerCustomParser::verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &)
+void QQuickDesignerCustomParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &)
{
/* Nothing to do we accept anything */
}
-void QQuickDesignerCustomParser::applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &)
+void QQuickDesignerCustomParser::applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &)
{
/* Nothing to do we accept anything */
}
diff --git a/src/quick/designer/qquickdesignercustomparserobject_p.h b/src/quick/designer/qquickdesignercustomparserobject_p.h
index e4d0765277..b38417d102 100644
--- a/src/quick/designer/qquickdesignercustomparserobject_p.h
+++ b/src/quick/designer/qquickdesignercustomparserobject_p.h
@@ -70,8 +70,8 @@ public:
QQuickDesignerCustomParser()
: QQmlCustomParser(AcceptsAttachedProperties | AcceptsSignalHandlers) {}
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
- void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
QT_END_NAMESPACE
diff --git a/src/quick/doc/images/9BcAYDlpuT8.jpg b/src/quick/doc/images/9BcAYDlpuT8.jpg
new file mode 100644
index 0000000000..0a69ab0034
--- /dev/null
+++ b/src/quick/doc/images/9BcAYDlpuT8.jpg
Binary files differ
diff --git a/src/quick/doc/images/pointDistanceThreshold.png b/src/quick/doc/images/pointDistanceThreshold.png
deleted file mode 100644
index c883f5f8a1..0000000000
--- a/src/quick/doc/images/pointDistanceThreshold.png
+++ /dev/null
Binary files differ
diff --git a/src/quick/doc/images/pointerHandlerMargin.png b/src/quick/doc/images/pointerHandlerMargin.png
new file mode 100644
index 0000000000..e996f57bf1
--- /dev/null
+++ b/src/quick/doc/images/pointerHandlerMargin.png
Binary files differ
diff --git a/src/quick/doc/images/pointDistanceThreshold.svg b/src/quick/doc/images/pointerHandlerMargin.svg
index 30d04e0df6..3e8b05f3f9 100644
--- a/src/quick/doc/images/pointDistanceThreshold.svg
+++ b/src/quick/doc/images/pointerHandlerMargin.svg
@@ -10,17 +10,17 @@
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg6318"
- inkscape:version="0.92.2 5c3e80d, 2017-08-06"
- viewBox="0 0 249.99999 100"
+ inkscape:version="0.92.2 2405546, 2018-03-11"
+ viewBox="0 0 148.46917 100.37263"
version="1.1"
- sodipodi:docname="pointDistanceThreshold.svg"
- width="250"
- height="100"
- inkscape:export-filename="/home/rutledge/dev/qt510/qtdeclarative/src/quick/doc/images/pointDistanceThreshold.png"
+ sodipodi:docname="pointerHandlerMargin.svg"
+ width="148.46918"
+ height="100.37263"
+ inkscape:export-filename="/home/rutledge/dev/qt5/qtdeclarative/src/quick/doc/images/pointerHandlerMargin.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<title
- id="title892">pointDistanceThreshold</title>
+ id="title892">pointerHandlerMargin</title>
<defs
id="defs20">
<marker
@@ -104,18 +104,18 @@
id="base"
bordercolor="#666666"
inkscape:pageshadow="2"
- inkscape:window-y="10"
+ inkscape:window-y="0"
pagecolor="#ffffff"
inkscape:zoom="2.1818696"
- inkscape:window-width="3025"
+ inkscape:window-width="1920"
inkscape:window-maximized="0"
- inkscape:window-x="275"
+ inkscape:window-x="0"
showgrid="false"
borderopacity="1.0"
inkscape:current-layer="layer1"
- inkscape:cx="-180.21887"
- inkscape:cy="-3.6626369"
- inkscape:window-height="2115"
+ inkscape:cx="-22.660169"
+ inkscape:cy="58.210886"
+ inkscape:window-height="1080"
inkscape:pageopacity="0.0"
inkscape:document-units="px"
fit-margin-top="0"
@@ -126,7 +126,7 @@
id="layer1"
inkscape:label="Camada 1"
inkscape:groupmode="layer"
- transform="translate(14.90473,-165.12199)">
+ transform="translate(-86.411864,-164.74934)">
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#006eed;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4231"
@@ -174,15 +174,15 @@
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker1145)" />
<text
id="text1335"
- y="227.02623"
- x="-37.15416"
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:125%;font-family:Sans;-inkscape-font-specification:Sans;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ y="226.88364"
+ x="104.81705"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:end;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"
transform="rotate(-6.0579549)"><tspan
- y="227.02623"
- x="-37.15416"
- id="tspan1333"
- sodipodi:role="line">pointDistanceThreshold</tspan></text>
+ y="226.88364"
+ x="104.81705"
+ sodipodi:role="line"
+ id="tspan862">margin</tspan></text>
</g>
<metadata
id="metadata19">
@@ -196,10 +196,10 @@
<dc:publisher>
<cc:Agent
rdf:about="http://openclipart.org/">
- <dc:title></dc:title>
+ <dc:title />
</cc:Agent>
</dc:publisher>
- <dc:title>pointDistanceThreshold</dc:title>
+ <dc:title>pointerHandlerMargin</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>The Qt Company</dc:title>
diff --git a/src/quick/doc/images/qml-item-canvas-lineDash.png b/src/quick/doc/images/qml-item-canvas-lineDash.png
new file mode 100644
index 0000000000..a2a038abe0
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-lineDash.png
Binary files differ
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index ad5e47002d..34ec66bf1d 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -89,3 +89,7 @@ navigation.qmltypespage = "Qt Quick QML Types"
# \svgcolor {#ffdead}
macro.svgcolor.HTML = "<div style=\"padding:10px;color:#fff;background:\1;\"></div>"
+
+# youtube video thumbnails that show up in offline and online docs
+HTML.extraimages += images/9BcAYDlpuT8.jpg
+qhp.QtQuick.extraFiles += images/9BcAYDlpuT8.jpg
diff --git a/src/quick/doc/snippets/pointerHandlers/dragHandler.qml b/src/quick/doc/snippets/pointerHandlers/dragHandler.qml
index 78a7db5b0c..04ea3967a0 100644
--- a/src/quick/doc/snippets/pointerHandlers/dragHandler.qml
+++ b/src/quick/doc/snippets/pointerHandlers/dragHandler.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.10
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
width: 100
diff --git a/src/quick/doc/snippets/pointerHandlers/dragHandlerDifferentTarget.qml b/src/quick/doc/snippets/pointerHandlers/dragHandlerDifferentTarget.qml
index 4c4168de83..7e7662539f 100644
--- a/src/quick/doc/snippets/pointerHandlers/dragHandlerDifferentTarget.qml
+++ b/src/quick/doc/snippets/pointerHandlers/dragHandlerDifferentTarget.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.10
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
@@ -58,8 +57,8 @@ Item {
Rectangle {
id: feedback
border.color: "red"
- width: Math.max(10, handler.point.ellipseDiameters.width)
- height: Math.max(10, handler.point.ellipseDiameters.height)
+ width: Math.max(10, handler.centroid.ellipseDiameters.width)
+ height: Math.max(10, handler.centroid.ellipseDiameters.height)
radius: Math.max(width, height) / 2
visible: handler.active
}
diff --git a/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml b/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
index 09429ec1d2..c33f2b2782 100644
--- a/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
+++ b/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.10
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
@@ -62,9 +61,9 @@ Item {
Text {
color: handler.active ? "darkgreen" : "black"
- text: handler.point.position.x.toFixed(1) + "," + handler.point.position.y.toFixed(1)
- x: handler.point.position.x - width / 2
- y: handler.point.position.y - height
+ text: handler.centroid.centroid.x.toFixed(1) + "," + handler.centroid.position.y.toFixed(1)
+ x: handler.centroid.position.x - width / 2
+ y: handler.centroid.position.y - height
}
}
//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml
index 955047d115..dd0542a953 100644
--- a/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml
+++ b/src/quick/doc/snippets/pointerHandlers/pinchHandler.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
width: 400
diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml
index a5255a64e3..b071e294af 100644
--- a/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml
+++ b/src/quick/doc/snippets/pointerHandlers/pinchHandlerDifferentTarget.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml
index 7d21efcb84..ade59d29f0 100644
--- a/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml
+++ b/src/quick/doc/snippets/pointerHandlers/pinchHandlerNullTarget.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
diff --git a/src/quick/doc/snippets/pointerHandlers/pointHandler.qml b/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
index 262eb607b6..20be120120 100644
--- a/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
+++ b/src/quick/doc/snippets/pointerHandlers/pointHandler.qml
@@ -48,9 +48,8 @@
**
****************************************************************************/
//![0]
-import QtQuick 2.10
+import QtQuick 2.12
import QtQuick.Window 2.2
-import Qt.labs.handlers 1.0
Window {
width: 480
diff --git a/src/quick/doc/snippets/qml/pathview/pathview.qml b/src/quick/doc/snippets/qml/pathview/pathview.qml
index 1a31f1372b..58d19b1a0c 100644
--- a/src/quick/doc/snippets/qml/pathview/pathview.qml
+++ b/src/quick/doc/snippets/qml/pathview/pathview.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -59,6 +59,7 @@ Rectangle {
id: delegate
Column {
id: wrapper
+ opacity: PathView.isCurrentItem ? 1 : 0.5
Image {
anchors.horizontalCenter: nameText.horizontalCenter
width: 64; height: 64
@@ -68,7 +69,6 @@ Rectangle {
id: nameText
text: name
font.pointSize: 16
- color: wrapper.PathView.isCurrentItem ? "red" : "black"
}
}
}
diff --git a/src/quick/doc/snippets/qml/rectangle/rectangle-gradient.qml b/src/quick/doc/snippets/qml/rectangle/rectangle-gradient.qml
index 031bee960d..e52a0ce0ef 100644
--- a/src/quick/doc/snippets/qml/rectangle/rectangle-gradient.qml
+++ b/src/quick/doc/snippets/qml/rectangle/rectangle-gradient.qml
@@ -80,5 +80,17 @@ Rectangle {
}
}
//! [rectangles]
+
+//! [presets]
+Rectangle {
+ y: 0; width: 80; height: 80
+ gradient: Gradient.NightFade
+}
+
+Rectangle {
+ y: 0; width: 80; height: 80
+ gradient: "NightFade"
+}
+//! [presets]
}
}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/src/quick/doc/snippets/qml/tableview/reusabledelegate.qml
index 73f7f10ace..4a49e809cc 100644
--- a/examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
+++ b/src/quick/doc/snippets/qml/tableview/reusabledelegate.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtQml module of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,19 +48,35 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
-Item {
- id: container
-
- property real progress: 0
+//![0]
+Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
- Behavior on opacity { NumberAnimation { duration: 600 } }
+ TableView.onPooled: rotationAnimation.pause()
+ TableView.onReused: rotationAnimation.resume()
- Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 }
+ Rectangle {
+ id: rect
+ anchors.centerIn: parent
+ width: 40
+ height: 5
+ color: "green"
- Rectangle {
- id: fill; color: "white"; height: container.height
- width: container.width * container.progress
+ RotationAnimation {
+ id: rotationAnimation
+ target: rect
+ duration: (Math.random() * 2000) + 200
+ from: 0
+ to: 359
+ running: true
+ loops: Animation.Infinite
+ }
+ }
}
}
+//![0]
diff --git a/src/quick/doc/snippets/qml/tableview/tablemodel.cpp b/src/quick/doc/snippets/qml/tableview/tablemodel.cpp
new file mode 100644
index 0000000000..ea9f76f131
--- /dev/null
+++ b/src/quick/doc/snippets/qml/tableview/tablemodel.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2018 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the documentation of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:BSD$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see https://www.qt.io/terms-conditions. For further
+ ** information use the contact form at https://www.qt.io/contact-us.
+ **
+ ** BSD License Usage
+ ** Alternatively, you may use this file under the terms of the BSD license
+ ** as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ ** * Redistributions of source code must retain the above copyright
+ ** notice, this list of conditions and the following disclaimer.
+ ** * Redistributions in binary form must reproduce the above copyright
+ ** notice, this list of conditions and the following disclaimer in
+ ** the documentation and/or other materials provided with the
+ ** distribution.
+ ** * Neither the name of The Qt Company Ltd nor the names of its
+ ** contributors may be used to endorse or promote products derived
+ ** from this software without specific prior written permission.
+ **
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+//![0]
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QAbstractTableModel>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+
+ int rowCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return 200;
+ }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return 200;
+ }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ switch (role) {
+ case Qt::DisplayRole:
+ return QString("%1, %2").arg(index.column()).arg(index.row());
+ default:
+ break;
+ }
+
+ return QVariant();
+ }
+
+ QHash<int, QByteArray> roleNames() const override
+ {
+ return { {Qt::DisplayRole, "display"} };
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<TableModel>("TableModel", 0, 1, "TableModel");
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
+#include "main.moc"
+//![0]
diff --git a/examples/quick/demos/samegame/content/MenuEmitter.qml b/src/quick/doc/snippets/qml/tableview/tablemodel.qml
index 20cbb2c1a6..8a8ec94958 100644
--- a/examples/quick/demos/samegame/content/MenuEmitter.qml
+++ b/src/quick/doc/snippets/qml/tableview/tablemodel.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,16 +48,24 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
+//![0]
+import QtQuick 2.12
+import TableModel 0.1
-Emitter {
+TableView {
anchors.fill: parent
- velocity: AngleDirection{angleVariation: 360; magnitude: 140; magnitudeVariation: 40}
- enabled: false;
- lifeSpan: 500;
- emitRate: 1
- size: 28
- endSize: 14
- group: "yellow"
+ columnSpacing: 1
+ rowSpacing: 1
+ clip: true
+
+ model: TableModel {}
+
+ delegate: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
+ Text {
+ text: display
+ }
+ }
}
+//![0]
diff --git a/examples/quick/demos/stocqt/content/+windows/Settings.qml b/src/quick/doc/snippets/qml/tableview/tableviewwithheader.qml
index 137ec546cc..2214328ee7 100644
--- a/examples/quick/demos/stocqt/content/+windows/Settings.qml
+++ b/src/quick/doc/snippets/qml/tableview/tableviewwithheader.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,9 +48,17 @@
**
****************************************************************************/
-pragma Singleton
-import QtQml 2.0
+import QtQuick 2.12
-QtObject {
- property string fontFamily: "Arial"
+//![0]
+TableView {
+ id: tableView
+
+ topMargin: header.implicitHeight
+
+ Text {
+ id: header
+ text: "A table header"
+ }
}
+//![0]
diff --git a/src/quick/doc/snippets/qml/models/visual-model-and-view.qml b/src/quick/doc/snippets/qml/tableview/tableviewwithprovider.qml
index baf489f8b9..028b12ca6c 100644
--- a/src/quick/doc/snippets/qml/models/visual-model-and-view.qml
+++ b/src/quick/doc/snippets/qml/tableview/tableviewwithprovider.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -47,22 +47,23 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-Rectangle {
- width: 200; height: 200
+import QtQuick 2.12
- //! [visual model and view]
- VisualItemModel {
- id: itemModel
- Rectangle { height: 30; width: 80; color: "red" }
- Rectangle { height: 30; width: 80; color: "green" }
- Rectangle { height: 30; width: 80; color: "blue" }
- }
+//![0]
+TableView {
+ id: tableView
+
+ property var columnWidths: [100, 50, 80, 150]
+ columnWidthProvider: function (column) { return columnWidths[column] }
- ListView {
- anchors.fill: parent
- model: itemModel
+ Timer {
+ running: true
+ interval: 2000
+ onTriggered: {
+ tableView.columnWidths[2] = 150
+ tableView.forceLayout();
+ }
}
- //! [visual model and view]
}
+//![0]
diff --git a/src/quick/doc/snippets/qml/transition-reversible.qml b/src/quick/doc/snippets/qml/transition-reversible.qml
index 58a88621c4..f74b6bffb3 100644
--- a/src/quick/doc/snippets/qml/transition-reversible.qml
+++ b/src/quick/doc/snippets/qml/transition-reversible.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -47,24 +47,26 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
//![0]
Rectangle {
id: rect
width: 100; height: 100
- color: "red"
+ color: "steelblue"
- MouseArea { id: mouseArea; anchors.fill: parent }
+ TapHandler { id: tapHandler }
states: State {
name: "brighter"
- when: mouseArea.pressed
- PropertyChanges { target: rect; color: "yellow"; x: 50 }
+ when: tapHandler.pressed
+ PropertyChanges { target: rect; color: "lightsteelblue"; x: 50 }
}
//! [sequential animations]
transitions: Transition {
+ to: "brighter"
+ reversible: true
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 1000 }
ColorAnimation { duration: 1000 }
diff --git a/src/quick/doc/src/concepts/effects/particles.qdoc b/src/quick/doc/src/concepts/effects/particles.qdoc
index 59f9c0db83..0b87eb4529 100644
--- a/src/quick/doc/src/concepts/effects/particles.qdoc
+++ b/src/quick/doc/src/concepts/effects/particles.qdoc
@@ -26,15 +26,16 @@
****************************************************************************/
/*!
- \qmlmodule QtQuick.Particles 2.11
+ \qmlmodule QtQuick.Particles 2.\QtMinorVersion
\title Qt Quick Particles QML Types
\ingroup qmlmodules
\brief Provides QML types for particle effects
This QML module contains a particle system for Qt Quick. To use these types, import the module with the following line:
- \code
- import QtQuick.Particles 2.11
- \endcode
+
+ \qml \QtMinorVersion
+ import QtQuick.Particles 2.\1
+ \endqml
For a simple overview of how the system can be used, see \l{Using the Qt Quick Particle System}.
@@ -48,10 +49,11 @@
Documentation for all Particle System types can be found on the \l QtQuick.Particles module page.
- Note that to use types from the particles module, you will need to import the types with the following line:
- \code
- import QtQuick.Particles 2.11
- \endcode
+ To use the types from the particles module, import the module with the following line:
+
+ \qml \QtMinorVersion
+ import QtQuick.Particles 2.\1
+ \endqml
\section1 The ParticleSystem
This particle system contains four main types of QML types: ParticleSystem, Painters, Emitters and Affectors.
diff --git a/src/quick/doc/src/concepts/input/mouse.qdoc b/src/quick/doc/src/concepts/input/mouse.qdoc
index 422c326898..cb506cb99a 100644
--- a/src/quick/doc/src/concepts/input/mouse.qdoc
+++ b/src/quick/doc/src/concepts/input/mouse.qdoc
@@ -33,6 +33,13 @@
\tableofcontents
+A more modern way of handling events from all pointing devices, including
+mouse and touchscreen, is via \l {Qt Quick Input Handlers}{Input Handlers}.
+This page describes the original Qt Quick \l MouseArea type, which was
+initially designed to handle mouse input, and later began handling single-touch
+events (in the form of synthetic mouse events) in simple touch-oriented user
+interfaces.
+
\section1 Mouse Types
\list
@@ -44,8 +51,8 @@
QML uses \l{qtqml-syntax-signals.html}{signals and handlers} to
deliver mouse interactions. Specifically, Qt Quick provides the \l MouseArea
-and \l MouseEvent types which allow developers to define signal handlers which
-accept mouse events within a defined area.
+and \l MouseEvent types that allow developers to define JavaScript callbacks
+(also called signal handlers), which accept mouse events within a defined area.
\section1 Defining a Mouse Area
@@ -59,8 +66,8 @@ definable.
\section1 Receiving Events
-The MouseArea type provides
-\l{qtqml-syntax-signals.html}{signals and handlers} to detect different
+The MouseArea type emits
+\l{qtqml-syntax-signals.html}{signals} in response to different
mouse events. The \l MouseArea type documentation describes these
gestures in greater detail:
@@ -76,8 +83,8 @@ gestures in greater detail:
\li released
\endlist
-These signals have signal handlers that are invoked when the signals are emitted.
-\snippet qml/mousearea/mousearea-snippet.qml mouse handlers
+These signals can have callbacks that are invoked when the signals are emitted.
+\snippet qml/mousearea/mousearea-snippet.qml signal handlers
\section1 Enabling Gestures
Some mouse gestures and button clicks need to be enabled before they send or
@@ -101,9 +108,9 @@ Additionally, to disable the whole mouse area, set the MouseArea
\section1 MouseEvent Object
-Signals and their handlers receive a \l MouseEvent object as a parameter. The
-\c mouse object contain information about the mouse event. For example, the
-mouse button that started the event is queried through the
+Signals and their callbacks receive a \l MouseEvent object as a parameter.
+The \c mouse object contains information about the mouse event. For example,
+the mouse button that started the event is queried through the
\l {MouseEvent::button}{mouse.button} property.
The \c MouseEvent object can also ignore a mouse event using its \c accepted
diff --git a/src/quick/doc/src/concepts/input/topic.qdoc b/src/quick/doc/src/concepts/input/topic.qdoc
index c23654cadb..95f4732f46 100644
--- a/src/quick/doc/src/concepts/input/topic.qdoc
+++ b/src/quick/doc/src/concepts/input/topic.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -35,30 +35,20 @@ design. Depending on the use-case that an application solves, and the
form-factor of the device that the application runs on, the best way
to receive user-input may be different.
-\section1 Touch
+\section1 Input from Pointing Devices
Allowing users to physically touch a screen to interact with an application is
a popular user-interface paradigm on portable devices like smartphones and
-tablets.
+tablets. In desktop applications, detecting and reacting to clicks and presses
+according to the mouse cursor position is a fundamental concept in
+user-interface design.
-Qt Quick was designed specifically with touch-driven user-interfaces in mind,
-and thus touch events are supported in various visual object types, from
-\l{Flickable} lists to the generic \l{MultiPointTouchArea} type, as well as
-in the \l{MouseArea} type (which will be documented thoroughly in a proceeding
-section).
+Touch-driven and mouse-driven user interfaces are supported by various
+\l{Qt Quick Input Handlers}{input handler} types, and visual object types
+such as \l{Flickable} and \l{MouseArea}.
-
-\section1 Mouse
-
-Mouse input is another important user input for user interfaces. Detecting
-and reacting to clicks and presses according to the mouse cursor position is a fundamental
-concept in user-interface design.
-
-Qt Quick provides the MouseArea visual object type which automatically receives
-mouse events (including clicks and wheel events) which allows developers to
-create custom user-interface objects to handle mouse input. Please see the
-documentation about \l{qtquick-input-mouseevents.html}
-{mouse events in Qt Quick} for more information on the topic.
+See also the documentation about
+\l{qtquick-input-mouseevents.html} {mouse events in Qt Quick}.
\section1 Keyboard Input and Keyboard Focus
diff --git a/src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers-index.qdoc b/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc
index fc1fd5fbc1..2ac9860e6f 100644
--- a/src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers-index.qdoc
+++ b/src/quick/doc/src/concepts/inputhandlers/qtquickhandlers-index.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -27,35 +27,34 @@
/*!
\page qtquickhandlers-index.html
- \title Qt Quick Pointer Handlers
- \brief A module with a set of QML elements that handle events from pointing devices in a user interface.
+ \title Qt Quick Input Handlers
+ \brief A module with a set of QML elements that handle events from input devices in a user interface.
- Qt Quick Pointer Handlers are a set of QML types used to handle events from
- touch, mouse, and stylus devices in a UI. In contrast to event-handling
- Items, such as \l MouseArea, Pointer Handlers require less memory and are
- intended to be used in greater numbers: one handler per type of
- interaction. Each Pointer Handler handles events on behalf of its \c parent
- Item. One Item can have multiple Pointer Handlers.
+ Qt Quick Input Handlers are a set of QML types used to handle events from
+ keyboard, touch, mouse, and stylus devices in a UI. In contrast to event-handling
+ items, such as \l MouseArea and \l Flickable, input handlers are explicitly non-visual,
+ require less memory and are intended to be used in greater numbers: one
+ handler instance per aspect of interaction. Each input handler instance
+ handles certain events on behalf of its \c parent Item. Thus the visual and
+ behavioral concerns are better separated, and the behavior is built up by
+ finer-grained composition.
- The module is introduced in Qt 5.10.
+ In Qt 5.10, these handlers were introduced in a separate Qt.labs.handlers module.
+ Now they are included with Qt Quick since 5.12. The pre-existing
+ \l Keys attached property is similar in concept, so we refer to the
+ pointing-device-oriented handlers plus \c Keys together as the set of Input Handlers.
+ We expect to offer more attached-property use cases in future versions of Qt.
- \section1 Pointer Handlers
+ \section1 Input Handlers
- \annotatedlist pointerhandlers
-
- \section1 Getting Started
-
- The QML types can be imported into your application using the following import statement in your \c {.qml} file.
-
- \code
- import Qt.labs.handlers 1.0
- \endcode
+ \annotatedlist qtquick-input-handlers
\section1 Key Features
Some of the key features are:
\list
+ \li Handle keystrokes within the focused Item
\li Handle gestures such as tapping or dragging regardless which device it comes from
\li Handle gestures from different classes of devices in different ways
\li Each Item can have unlimited Handlers
@@ -67,7 +66,5 @@
\list
\li \l{Qt Quick}
- \li \l{Qt Quick Pointer Handlers}
- \li \l{Qt Quick Pointer Handlers QML Types}{Qt Quick Pointer Handlers QML Types}
\endlist
*/
diff --git a/src/quick/doc/src/concepts/layouts/qtquicklayouts.qdoc b/src/quick/doc/src/concepts/layouts/qtquicklayouts.qdoc
index d82e35fb93..c33fc0cfa3 100644
--- a/src/quick/doc/src/concepts/layouts/qtquicklayouts.qdoc
+++ b/src/quick/doc/src/concepts/layouts/qtquicklayouts.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \qmlmodule QtQuick.Layouts 1.11
+ \qmlmodule QtQuick.Layouts 1.\QtMinorVersion
\title Qt Quick Layouts QML Types
\ingroup qmlmodules
\brief Provides QML types for arranging QML items in a user interface.
@@ -39,8 +39,8 @@
The QML types can be imported into your application using the
following import statement in your .qml file.
- \code
- import QtQuick.Layouts 1.11
- \endcode
+ \qml \QtMinorVersion
+ import QtQuick.Layouts 1.\1
+ \endqml
*/
diff --git a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
index 2705ca5e34..e8265b92d2 100644
--- a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
+++ b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc
@@ -41,9 +41,10 @@ QObjectList or a \l QAbstractItemModel. The first three are useful for exposing
simpler datasets, while QAbstractItemModel provides a more flexible solution for
more complex models.
-For a video tutorial that takes you through the whole process of exposing a C++
-model to QML, see the
-\l {https://youtu.be/9BcAYDlpuT8}{Using C++ Models in QML Tutorial}.
+Here is a video tutorial that takes you through the whole process of exposing a C++
+model to QML:
+
+\youtube 9BcAYDlpuT8
\section2 QStringList-based Model
diff --git a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
index 86beb38e6a..89b7929755 100644
--- a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
+++ b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
@@ -278,11 +278,6 @@ To visualize data, bind the view's \c model property to a model and the
}
\endcode
- \note VisualItemModel can also be used, but it is only provided for compatibility
- reasons. VisualItemModel allows a QML item to be provided as a model. This model
- contains both the data and delegate; the child items of a VisualItemModel
- provide the contents of the delegate. The model does not provide any roles.
-
\section2 Integers as Models
An integer can be used as a model that contains a certain number
@@ -307,6 +302,7 @@ To visualize data, bind the view's \c model property to a model and the
}
\endqml
+ \note The limit on the number of items in an integer model is 100,000,000.
\section2 Object Instances as Models
diff --git a/src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers.qdoc b/src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers.qdoc
deleted file mode 100644
index cf87c75e8c..0000000000
--- a/src/quick/doc/src/concepts/pointerhandlers/qtquickhandlers.qdoc
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \qmlmodule Qt.labs.handlers 1.0
- \title Qt Quick Pointer Handlers QML Types
- \ingroup qmlmodules
- \brief Provides QML types for handling events from pointing devices in a user interface.
-
- The \l{Qt Quick Pointer Handlers} module provides QML types for handling
- events from pointing devices in a UI. These QML types work in conjunction
- with \l{Qt Quick}.
-
- The QML types can be imported into your application using the
- following import statement in your .qml file.
-
- \code
- import Qt.labs.handlers 1.0
- \endcode
-*/
diff --git a/src/quick/doc/src/concepts/positioning/righttoleft.qdoc b/src/quick/doc/src/concepts/positioning/righttoleft.qdoc
index 4e1eca7ac3..7c8cd735b3 100644
--- a/src/quick/doc/src/concepts/positioning/righttoleft.qdoc
+++ b/src/quick/doc/src/concepts/positioning/righttoleft.qdoc
@@ -73,7 +73,7 @@ the effective alignment of the text element that takes the mirroring into accoun
(This applies to the \l Row, \l Grid, \l Flow, \l ListView and \l GridView types.)
-From Qt Quick 1.1 onwards, types used for horizontal positioning and model views have gained a \c layoutDirection
+Types used for horizontal positioning and model views have the \c layoutDirection
property for controlling the horizontal direction of the layouts. Setting \c layoutDirection to
\c Qt.RightToLeft causes items to be laid out from the right to left. By default Qt Quick follows
the left-to-right layout direction.
@@ -132,7 +132,7 @@ aligned and just make sure that text is translated and aligned properly.
(This applies to \l Image, \l BorderImage and \l AnimatedImage types.)
Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored.
-The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1:
+The painting of these icons can be mirrored with a dedicated \c mirror property:
\snippet qml/righttoleft.qml 5
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index 99175ab94e..4c94259139 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -796,6 +796,14 @@ with multiple windows.
\li Mipmapped Image items are not placed in the global atlas and will
not be batched.
+ \li A bug in the OpenGL driver related to framebuffer object (FBO) readbacks
+ may corrupt rendered glyphs. If you set the \c QML_USE_GLYPHCACHE_WORKAROUND
+ environment variable, Qt keeps an additional copy of the glyph in RAM. This
+ means that performance is slightly lower when drawing glyphs that have not
+ been drawn before, as Qt accesses the extra copy via the CPU. It also means
+ that the glyph cache will use twice as much memory. The quality is not
+ affected by this.
+
\endlist
If an application performs poorly, make sure that rendering is
diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
index c8bdfa28cd..f5599e404a 100644
--- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
@@ -197,9 +197,9 @@ so. To explain why, let's take a look at a simplified example.
Suppose we were writing the UI for a settings page:
-\qml
- import QtQuick 2.11
- import QtQuick.Controls 2.4
+\qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQuick.Controls 2.\1
Page {
Button {
@@ -296,9 +296,9 @@ into QML:
The QML then calls the C++ slot directly:
-\qml
- import QtQuick 2.11
- import QtQuick.Controls 2.4
+\qml \QtMinorVersion
+ import QtQuick 2.\1
+ import QtQuick.Controls 2.\1
Page {
Button {
diff --git a/src/quick/doc/src/qmltypereference.qdoc b/src/quick/doc/src/qmltypereference.qdoc
index e787ed31ef..ddf90f88d9 100644
--- a/src/quick/doc/src/qmltypereference.qdoc
+++ b/src/quick/doc/src/qmltypereference.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
-\qmlmodule QtQuick 2.11
+\qmlmodule QtQuick 2.\QtMinorVersion
\title Qt Quick QML Types
\ingroup qmlmodules
\brief Provides graphical QML types.
@@ -34,11 +34,11 @@
The \l{Qt Quick} module provides graphical primitive types. These types are only
available in a QML document if that document imports the \c QtQuick namespace.
-The current version of the \c QtQuick module is version 2.11, and thus it may be
-imported via the following statement:
+The current version of the \c QtQuick module is version \QtMinorVersion, and
+thus it may be imported via the following statement:
-\qml
-import QtQuick 2.11
+\qml \QtMinorVersion
+import QtQuick 2.\1
\endqml
Visit the \l {Qt Quick} module documentation for more
@@ -78,7 +78,7 @@ In addition, the \c QtQuick import provides the following basic types:
\section1 Object Types
-All object types provided by the \c QtQuick import are based on the \l{Item}
+Most object types provided by the \c QtQuick import are based on the \l{Item}
type, which itself derives from \l{QtQml::QtObject}{QtObject}. \l{Qt QML QML
Types#Object Types} {QML object types} provided by the Qt QML module (such as
\l{QtQml::QtObject}{QtObject} and \l{QtQml::Component}{Component}) are also
@@ -889,15 +889,16 @@ console.log(c + " " + d); // false true
*/
/*!
-\qmlmodule QtTest 1.11
+\qmlmodule QtTest 1.\QtMinorVersion
\title Qt Quick Test QML Types
\brief This module provides QML types to unit test your QML application
\ingroup qmlmodules
You can import this module using the following statement:
-\code
-import QtTest 1.11
-\endcode
+
+\qml \QtMinorVersion
+import QtTest 1.\1
+\endqml
For more information about how to use these types, see
\l{Qt Quick Test}.
diff --git a/src/quick/handlers/handlers.pri b/src/quick/handlers/handlers.pri
index 8bd74d95da..1258822f40 100644
--- a/src/quick/handlers/handlers.pri
+++ b/src/quick/handlers/handlers.pri
@@ -1,17 +1,22 @@
HEADERS += \
$$PWD/qquickdraghandler_p.h \
- $$PWD/qquickhandlersmodule_p.h \
+ $$PWD/qquickhandlerpoint_p.h \
+ $$PWD/qquickhoverhandler_p.h \
$$PWD/qquickmultipointhandler_p.h \
$$PWD/qquickpinchhandler_p.h \
$$PWD/qquickpointerdevicehandler_p.h \
+ $$PWD/qquickpointerdevicehandler_p_p.h \
$$PWD/qquickpointerhandler_p.h \
+ $$PWD/qquickpointerhandler_p_p.h \
$$PWD/qquickpointhandler_p.h \
$$PWD/qquicksinglepointhandler_p.h \
$$PWD/qquicktaphandler_p.h \
+ $$PWD/qquickdragaxis_p.h
SOURCES += \
$$PWD/qquickdraghandler.cpp \
- $$PWD/qquickhandlersmodule.cpp \
+ $$PWD/qquickhandlerpoint.cpp \
+ $$PWD/qquickhoverhandler.cpp \
$$PWD/qquickmultipointhandler.cpp \
$$PWD/qquickpinchhandler.cpp \
$$PWD/qquickpointerdevicehandler.cpp \
@@ -19,4 +24,4 @@ SOURCES += \
$$PWD/qquickpointhandler.cpp \
$$PWD/qquicksinglepointhandler.cpp \
$$PWD/qquicktaphandler.cpp \
-
+ $$PWD/qquickdragaxis.cpp
diff --git a/src/quick/handlers/qquickdragaxis.cpp b/src/quick/handlers/qquickdragaxis.cpp
new file mode 100644
index 0000000000..5efe19b2fe
--- /dev/null
+++ b/src/quick/handlers/qquickdragaxis.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qquickdragaxis_p.h"
+#include <limits>
+
+QQuickDragAxis::QQuickDragAxis()
+ : m_minimum(-std::numeric_limits<qreal>::max())
+ , m_maximum(std::numeric_limits<qreal>::max())
+ , m_enabled(true)
+{
+}
+
+void QQuickDragAxis::setMinimum(qreal minimum)
+{
+ if (m_minimum == minimum)
+ return;
+
+ m_minimum = minimum;
+ emit minimumChanged();
+}
+
+void QQuickDragAxis::setMaximum(qreal maximum)
+{
+ if (m_maximum == maximum)
+ return;
+
+ m_maximum = maximum;
+ emit maximumChanged();
+}
+
+void QQuickDragAxis::setEnabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+
+ m_enabled = enabled;
+ emit enabledChanged();
+}
+
diff --git a/src/quick/handlers/qquickdragaxis_p.h b/src/quick/handlers/qquickdragaxis_p.h
new file mode 100644
index 0000000000..2c2e0a426d
--- /dev/null
+++ b/src/quick/handlers/qquickdragaxis_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDRAGAXIS_P_H
+#define QQUICKDRAGAXIS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qglobal.h>
+
+class Q_AUTOTEST_EXPORT QQuickDragAxis : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
+ Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+
+public:
+ QQuickDragAxis();
+
+ qreal minimum() const { return m_minimum; }
+ void setMinimum(qreal minimum);
+
+ qreal maximum() const { return m_maximum; }
+ void setMaximum(qreal maximum);
+
+ bool enabled() const { return m_enabled; }
+ void setEnabled(bool enabled);
+
+signals:
+ void minimumChanged();
+ void maximumChanged();
+ void enabledChanged();
+
+private:
+ qreal m_minimum;
+ qreal m_maximum;
+ bool m_enabled;
+};
+
+#endif // QQUICKDRAGAXIS_P_H
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp
index 5e540b3615..aa66c16007 100644
--- a/src/quick/handlers/qquickdraghandler.cpp
+++ b/src/quick/handlers/qquickdraghandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -43,16 +43,20 @@
QT_BEGIN_NAMESPACE
+static const qreal DragAngleToleranceDegrees = 10;
+
+Q_LOGGING_CATEGORY(lcDragHandler, "qt.quick.handler.drag")
+
/*!
\qmltype DragHandler
\instantiates QQuickDragHandler
- \inherits SinglePointHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inherits MultiPointHandler
+ \inqmlmodule QtQuick
+ \ingroup qtquick-input-handlers
\brief Handler for dragging.
DragHandler is a handler that is used to interactively move an Item.
- Like other Pointer Handlers, by default it is fully functional, and
+ Like other Input Handlers, by default it is fully functional, and
manipulates its \l {PointerHandler::target} {target}.
\snippet pointerHandlers/dragHandler.qml 0
@@ -71,119 +75,173 @@ QT_BEGIN_NAMESPACE
\snippet pointerHandlers/dragHandlerNullTarget.qml 0
+ If minimumPointCount and maximumPointCount are set to values larger than 1,
+ the user will need to drag that many fingers in the same direction to start
+ dragging. A multi-finger drag gesture can be detected independently of both
+ a (default) single-finger DragHandler and a PinchHandler on the same Item,
+ and thus can be used to adjust some other feature independently of the
+ usual pinch behavior: for example adjust a tilt transformation, or adjust
+ some other numeric value, if the \c target is set to null. But if the
+ \l target is an Item, \l centroid is the point at which the drag begins and
+ to which the \c target will be moved (subject to constraints).
+
At this time, drag-and-drop is not yet supported.
\sa Drag, MouseArea
*/
-QQuickDragHandler::QQuickDragHandler(QObject *parent)
- : QQuickSinglePointHandler(parent)
-{
-}
-
-QQuickDragHandler::~QQuickDragHandler()
-{
-}
-
-bool QQuickDragHandler::wantsEventPoint(QQuickEventPoint *point)
+QQuickDragHandler::QQuickDragHandler(QQuickItem *parent)
+ : QQuickMultiPointHandler(parent, 1, 1)
{
- // If we've already been interested in a point, stay interested, even if it has strayed outside bounds.
- return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId())
- || QQuickSinglePointHandler::wantsEventPoint(point));
}
-bool QQuickDragHandler::targetContains(QQuickEventPoint *point)
+bool QQuickDragHandler::targetContainsCentroid()
{
Q_ASSERT(parentItem() && target());
- return target()->contains(localTargetPosition(point));
+ return target()->contains(targetCentroidPosition());
}
-QPointF QQuickDragHandler::localTargetPosition(QQuickEventPoint *point)
+QPointF QQuickDragHandler::targetCentroidPosition()
{
- QPointF pos = point->position();
+ QPointF pos = m_centroid.position();
if (target() != parentItem())
pos = parentItem()->mapToItem(target(), pos);
return pos;
}
-void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)
+void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point)
{
- if (grabber == this && stateChange == QQuickEventPoint::GrabExclusive) {
+ QQuickMultiPointHandler::onGrabChanged(grabber, transition, point);
+ if (grabber == this && transition == QQuickEventPoint::GrabExclusive) {
// In case the grab got handed over from another grabber, we might not get the Press.
if (!m_pressedInsideTarget) {
if (target())
m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2;
- m_pressScenePos = point->scenePosition();
} else if (m_pressTargetPos.isNull()) {
if (target())
- m_pressTargetPos = localTargetPosition(point);
- m_pressScenePos = point->scenePosition();
+ m_pressTargetPos = targetCentroidPosition();
}
}
- QQuickSinglePointHandler::onGrabChanged(grabber, stateChange, point);
}
void QQuickDragHandler::onActiveChanged()
{
- if (!active()) {
+ QQuickMultiPointHandler::onActiveChanged();
+ if (active()) {
+ if (auto parent = parentItem()) {
+ if (currentEvent()->asPointerTouchEvent())
+ parent->setKeepTouchGrab(true);
+ // tablet and mouse are treated the same by Item's legacy event handling, and
+ // touch becomes synth-mouse for Flickable, so we need to prevent stealing
+ // mouse grab too, whenever dragging occurs in an enabled direction
+ parent->setKeepMouseGrab(true);
+ }
+ } else {
m_pressTargetPos = QPointF();
- m_pressScenePos = m_pressTargetPos;
m_pressedInsideTarget = false;
+ if (auto parent = parentItem()) {
+ parent->setKeepTouchGrab(false);
+ parent->setKeepMouseGrab(false);
+ }
}
}
-void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)
+void QQuickDragHandler::handlePointerEventImpl(QQuickPointerEvent *event)
{
- point->setAccepted();
- switch (point->state()) {
- case QQuickEventPoint::Pressed:
- if (target()) {
- m_pressedInsideTarget = targetContains(point);
- m_pressTargetPos = localTargetPosition(point);
- }
- m_pressScenePos = point->scenePosition();
- setPassiveGrab(point);
- break;
- case QQuickEventPoint::Updated: {
- QVector2D accumulatedDragDelta = QVector2D(point->scenePosition() - m_pressScenePos);
- if (active()) {
- // update translation property. Make sure axis is respected for it.
- if (!m_xAxis.enabled())
+ QQuickMultiPointHandler::handlePointerEventImpl(event);
+ event->setAccepted(true);
+
+ if (active()) {
+ // Calculate drag delta, taking into account the axis enabled constraint
+ // i.e. if xAxis is not enabled, then ignore the horizontal component of the actual movement
+ QVector2D accumulatedDragDelta = QVector2D(m_centroid.scenePosition() - m_centroid.scenePressPosition());
+ if (!m_xAxis.enabled())
+ accumulatedDragDelta.setX(0);
+ if (!m_yAxis.enabled())
+ accumulatedDragDelta.setY(0);
+ setTranslation(accumulatedDragDelta);
+ } else {
+ // Check that all points have been dragged past the drag threshold,
+ // to the extent that the constraints allow,
+ // and in approximately the same direction
+ qreal minAngle = 361;
+ qreal maxAngle = -361;
+ bool allOverThreshold = !event->isReleaseEvent();
+ QVector <QQuickEventPoint *> chosenPoints;
+
+ if (event->isPressEvent())
+ m_pressedInsideTarget = target() && m_currentPoints.count() > 0;
+
+ for (const QQuickHandlerPoint &p : m_currentPoints) {
+ if (!allOverThreshold)
+ break;
+ QQuickEventPoint *point = event->pointById(p.id());
+ chosenPoints << point;
+ setPassiveGrab(point);
+ // Calculate drag delta, taking into account the axis enabled constraint
+ // i.e. if xAxis is not enabled, then ignore the horizontal component of the actual movement
+ QVector2D accumulatedDragDelta = QVector2D(point->scenePosition() - point->scenePressPosition());
+ if (!m_xAxis.enabled()) {
+ // If horizontal dragging is disallowed, but the user is dragging
+ // mostly horizontally, then don't activate.
+ if (qAbs(accumulatedDragDelta.x()) > qAbs(accumulatedDragDelta.y()))
+ accumulatedDragDelta.setY(0);
accumulatedDragDelta.setX(0);
- if (!m_yAxis.enabled())
+ }
+ if (!m_yAxis.enabled()) {
+ // If vertical dragging is disallowed, but the user is dragging
+ // mostly vertically, then don't activate.
+ if (qAbs(accumulatedDragDelta.y()) > qAbs(accumulatedDragDelta.x()))
+ accumulatedDragDelta.setX(0);
accumulatedDragDelta.setY(0);
- setTranslation(accumulatedDragDelta);
-
- if (target() && target()->parentItem()) {
- const QPointF newTargetTopLeft = localTargetPosition(point) - m_pressTargetPos;
- const QPointF xformOrigin = target()->transformOriginPoint();
- const QPointF targetXformOrigin = newTargetTopLeft + xformOrigin;
- QPointF pos = target()->parentItem()->mapFromItem(target(), targetXformOrigin);
- pos -= xformOrigin;
- QPointF targetItemPos = target()->position();
- if (!m_xAxis.enabled())
- pos.setX(targetItemPos.x());
- if (!m_yAxis.enabled())
- pos.setY(targetItemPos.y());
- enforceAxisConstraints(&pos);
- moveTarget(pos, point);
}
- } else if (!point->exclusiveGrabber() &&
- ((m_xAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta.x(), Qt::XAxis, point)) ||
- (m_yAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta.y(), Qt::YAxis, point)))) {
- setExclusiveGrab(point);
- if (auto parent = parentItem()) {
- if (point->pointerEvent()->asPointerTouchEvent())
- parent->setKeepTouchGrab(true);
- // tablet and mouse are treated the same by Item's legacy event handling, and
- // touch becomes synth-mouse for Flickable, so we need to prevent stealing
- // mouse grab too, whenever dragging occurs in an enabled direction
- parent->setKeepMouseGrab(true);
+ qreal angle = std::atan2(accumulatedDragDelta.y(), accumulatedDragDelta.x()) * 180 / M_PI;
+ bool overThreshold = QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta);
+ qCDebug(lcDragHandler) << "movement" << accumulatedDragDelta << "angle" << angle << "of point" << point
+ << "pressed @" << point->scenePressPosition() << "over threshold?" << overThreshold;
+ minAngle = qMin(angle, minAngle);
+ maxAngle = qMax(angle, maxAngle);
+ if (allOverThreshold && !overThreshold)
+ allOverThreshold = false;
+
+ if (event->isPressEvent()) {
+ // m_pressedInsideTarget should stay true iff ALL points in which DragHandler is interested
+ // have been pressed inside the target() Item. (E.g. in a Slider the parent might be the
+ // whole control while the target is just the knob.)
+ if (target()) {
+ const QPointF localPressPos = target()->mapFromScene(point->scenePressPosition());
+ m_pressedInsideTarget &= target()->contains(localPressPos);
+ m_pressTargetPos = targetCentroidPosition();
+ }
+ // QQuickWindowPrivate::deliverToPassiveGrabbers() skips subsequent delivery if the event is filtered.
+ // (That affects behavior for mouse but not for touch, because Flickable only handles mouse.)
+ // So we have to compensate by accepting the event here to avoid any parent Flickable from
+ // getting the event via direct delivery and grabbing too soon.
+ point->setAccepted(event->asPointerMouseEvent()); // stop propagation iff it's a mouse event
}
}
- } break;
- default:
- break;
+ if (allOverThreshold) {
+ qreal angleDiff = maxAngle - minAngle;
+ if (angleDiff > 180)
+ angleDiff = 360 - angleDiff;
+ qCDebug(lcDragHandler) << "angle min" << minAngle << "max" << maxAngle << "range" << angleDiff;
+ if (angleDiff < DragAngleToleranceDegrees && grabPoints(chosenPoints))
+ setActive(true);
+ }
+ }
+ if (active() && target() && target()->parentItem()) {
+ const QPointF newTargetTopLeft = targetCentroidPosition() - m_pressTargetPos;
+ const QPointF xformOrigin = target()->transformOriginPoint();
+ const QPointF targetXformOrigin = newTargetTopLeft + xformOrigin;
+ QPointF pos = target()->parentItem()->mapFromItem(target(), targetXformOrigin);
+ pos -= xformOrigin;
+ QPointF targetItemPos = target()->position();
+ if (!m_xAxis.enabled())
+ pos.setX(targetItemPos.x());
+ if (!m_yAxis.enabled())
+ pos.setY(targetItemPos.y());
+ enforceAxisConstraints(&pos);
+ moveTarget(pos);
}
}
@@ -243,39 +301,6 @@ void QQuickDragHandler::setTranslation(const QVector2D &trans)
applied to the \l {PointerHandler::target} {target}.
If \c enabled is true, vertical dragging is allowed.
*/
-QQuickDragAxis::QQuickDragAxis()
- : m_minimum(-DBL_MAX)
- , m_maximum(DBL_MAX)
- , m_enabled(true)
-{
-}
-
-void QQuickDragAxis::setMinimum(qreal minimum)
-{
- if (m_minimum == minimum)
- return;
-
- m_minimum = minimum;
- emit minimumChanged();
-}
-
-void QQuickDragAxis::setMaximum(qreal maximum)
-{
- if (m_maximum == maximum)
- return;
-
- m_maximum = maximum;
- emit maximumChanged();
-}
-
-void QQuickDragAxis::setEnabled(bool enabled)
-{
- if (m_enabled == enabled)
- return;
-
- m_enabled = enabled;
- emit enabledChanged();
-}
/*!
\readonly
diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h
index 363df31a64..387a81eb43 100644
--- a/src/quick/handlers/qquickdraghandler_p.h
+++ b/src/quick/handlers/qquickdraghandler_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -51,41 +51,12 @@
// We mean it.
//
-#include "qquicksinglepointhandler_p.h"
+#include "qquickmultipointhandler_p.h"
+#include "qquickdragaxis_p.h"
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickDragAxis : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
- Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
-
-public:
- QQuickDragAxis();
-
- qreal minimum() const { return m_minimum; }
- void setMinimum(qreal minimum);
-
- qreal maximum() const { return m_maximum; }
- void setMaximum(qreal maximum);
-
- bool enabled() const { return m_enabled; }
- void setEnabled(bool enabled);
-
-signals:
- void minimumChanged();
- void maximumChanged();
- void enabledChanged();
-
-private:
- qreal m_minimum;
- qreal m_maximum;
- bool m_enabled;
-};
-
-class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickSinglePointHandler
+class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickMultiPointHandler
{
Q_OBJECT
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
@@ -93,10 +64,9 @@ class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickSinglePointHandler
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
public:
- explicit QQuickDragHandler(QObject *parent = nullptr);
- ~QQuickDragHandler();
+ explicit QQuickDragHandler(QQuickItem *parent = nullptr);
- void handleEventPoint(QQuickEventPoint *point) override;
+ void handlePointerEventImpl(QQuickPointerEvent *event) override;
QQuickDragAxis *xAxis() { return &m_xAxis; }
QQuickDragAxis *yAxis() { return &m_yAxis; }
@@ -104,25 +74,22 @@ public:
QVector2D translation() const { return m_translation; }
void setTranslation(const QVector2D &trans);
- Q_INVOKABLE void enforceConstraints();
+ void enforceConstraints();
Q_SIGNALS:
-// void gestureStarted(QQuickGestureEvent *gesture);
void translationChanged();
protected:
- bool wantsEventPoint(QQuickEventPoint *point) override;
void onActiveChanged() override;
- void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override;
+ void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override;
private:
void ungrab();
void enforceAxisConstraints(QPointF *localPos);
- bool targetContains(QQuickEventPoint *point);
- QPointF localTargetPosition(QQuickEventPoint *point);
+ bool targetContainsCentroid();
+ QPointF targetCentroidPosition();
private:
- QPointF m_pressScenePos;
QPointF m_pressTargetPos; // We must also store the local targetPos, because we cannot deduce
// the press target pos from the scene pos in case there was e.g a
// flick in one of the ancestors during the drag.
diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp
new file mode 100644
index 0000000000..6a106b5464
--- /dev/null
+++ b/src/quick/handlers/qquickhandlerpoint.cpp
@@ -0,0 +1,352 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickhandlerpoint_p.h"
+#include "private/qquickevents_p_p.h"
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)
+
+/*!
+ \qmltype HandlerPoint
+ \instantiates QQuickHandlerPoint
+ \inqmlmodule QtQuick
+ \brief An event point.
+
+ A QML representation of a QQuickEventPoint.
+
+ It's possible to make bindings to properties of a \l SinglePointHandler's
+ current point. For example:
+
+ \snippet pointerHandlers/dragHandlerNullTarget.qml 0
+
+ The point is kept up-to-date when the DragHandler is actively responding to
+ an EventPoint; but when the point is released, or the current point is
+ being handled by a different handler, \c position.x and \c position.y are 0.
+
+ \note This is practically identical to QtQuick::EventPoint; however an
+ EventPoint is a long-lived QObject which is invalidated between gestures
+ and reused for subsequent event deliveries. Continuous bindings to its
+ properties are not possible, and an individual handler cannot rely on it
+ outside the period when that point is part of an active gesture which that
+ handler is handling. HandlerPoint is a Q_GADGET that the handler owns.
+ This allows you to make lifetime bindings to its properties.
+
+ \sa SinglePointHandler::point
+*/
+
+QQuickHandlerPoint::QQuickHandlerPoint()
+{}
+
+void QQuickHandlerPoint::localize(QQuickItem *item)
+{
+ m_pressPosition = item->mapFromScene(m_scenePressPosition);
+}
+
+void QQuickHandlerPoint::reset()
+{
+ m_id = 0;
+ m_uniqueId = QPointingDeviceUniqueId();
+ m_position = QPointF();
+ m_scenePosition = QPointF();
+ m_pressPosition = QPointF();
+ m_scenePressPosition = QPointF();
+ m_sceneGrabPosition = QPointF();
+ m_velocity = QVector2D();
+ m_rotation = 0;
+ m_pressure = 0;
+ m_ellipseDiameters = QSizeF();
+ m_pressedButtons = Qt::NoButton;
+ m_pressedModifiers = Qt::NoModifier;
+}
+
+void QQuickHandlerPoint::reset(const QQuickEventPoint *point)
+{
+ m_id = point->pointId();
+ const QQuickPointerEvent *event = point->pointerEvent();
+ switch (point->state()) {
+ case QQuickEventPoint::Pressed:
+ m_pressPosition = point->position();
+ m_scenePressPosition = point->scenePosition();
+ m_pressedButtons = event->buttons();
+ break;
+ case QQuickEventPoint::Released:
+ if (event->buttons() == Qt::NoButton) {
+ reset();
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ m_scenePressPosition = point->scenePressPosition();
+ m_pressedButtons = event->buttons();
+ m_pressedModifiers = event->modifiers();
+ if (event->asPointerTouchEvent()) {
+ const QQuickEventTouchPoint *tp = static_cast<const QQuickEventTouchPoint *>(point);
+ m_uniqueId = tp->uniqueId();
+ m_rotation = tp->rotation();
+ m_pressure = tp->pressure();
+ m_ellipseDiameters = tp->ellipseDiameters();
+ } else if (event->asPointerTabletEvent()) {
+ // TODO
+ } else {
+ m_uniqueId = event->device()->uniqueId();
+ m_rotation = 0;
+ m_pressure = event->buttons() ? 1 : 0;
+ m_ellipseDiameters = QSizeF();
+ }
+ m_position = point->position();
+ m_scenePosition = point->scenePosition();
+ if (point->state() == QQuickEventPoint::Updated)
+ m_velocity = point->velocity();
+}
+
+void QQuickHandlerPoint::reset(const QVector<QQuickHandlerPoint> &points)
+{
+ if (points.isEmpty()) {
+ qWarning("reset: no points");
+ return;
+ }
+ if (points.count() == 1) {
+ *this = points.first(); // copy all values
+ return;
+ }
+ // all points are required to be from the same event
+ QPointF posSum;
+ QPointF scenePosSum;
+ QPointF pressPosSum;
+ QPointF scenePressPosSum;
+ QVector2D velocitySum;
+ qreal pressureSum = 0;
+ QSizeF ellipseDiameterSum;
+ for (const QQuickHandlerPoint &point : points) {
+ posSum += point.position();
+ scenePosSum += point.scenePosition();
+ pressPosSum += point.pressPosition();
+ scenePressPosSum += point.scenePressPosition();
+ velocitySum += point.velocity();
+ pressureSum += point.pressure();
+ ellipseDiameterSum += point.ellipseDiameters();
+ }
+ m_id = 0;
+ m_uniqueId = QPointingDeviceUniqueId();
+ // all points are required to be from the same event, so pressed buttons and modifiers should be the same
+ m_pressedButtons = points.first().pressedButtons();
+ m_pressedModifiers = points.first().modifiers();
+ m_position = posSum / points.size();
+ m_scenePosition = scenePosSum / points.size();
+ m_pressPosition = pressPosSum / points.size();
+ m_scenePressPosition = scenePressPosSum / points.size();
+ m_velocity = velocitySum / points.size();
+ m_rotation = 0; // averaging the rotations of all the points isn't very sensible
+ m_pressure = pressureSum / points.size();
+ m_ellipseDiameters = ellipseDiameterSum / points.size();
+}
+
+/*!
+ \readonly
+ \qmlproperty int QtQuick::HandlerPoint::id
+ \brief The ID number of the point
+
+ During a touch gesture, from the time that the first finger is pressed
+ until the last finger is released, each touchpoint will have a unique ID
+ number. Likewise, if input from multiple devices occurs (for example
+ simultaneous mouse and touch presses), all the current event points from
+ all the devices will have unique IDs.
+
+ \note Do not assume that id numbers start at zero or that they are
+ sequential. Such an assumption is often false due to the way the underlying
+ drivers work.
+
+ \sa QTouchEvent::TouchPoint::id
+*/
+
+/*!
+ \readonly
+ \qmlproperty PointingDeviceUniqueId QtQuick::HandlerPoint::uniqueId
+ \brief The unique ID of the point, if any
+
+ This is normally empty, because touchscreens cannot uniquely identify fingers.
+
+ On some types of touchscreens, especially those using TUIO drivers,
+ it's possible to use recognizable physical tokens (fiducial objects)
+ in addition to fingers. So if this point is a touch point, and
+ uniqueId is set, it is the identifier for such an object.
+
+ On a graphics tablet, each type of stylus or other tool often has a unique
+ ID or serial number, which can be useful to respond in different ways to
+ different tools.
+
+ Interpreting the contents of this ID requires knowledge of the hardware and
+ drivers in use.
+
+ \sa QTabletEvent::uniqueId, QtQuick::TouchPoint::uniqueId, QtQuick::EventTouchPoint::uniqueId
+*/
+
+/*!
+ \readonly
+ \qmlproperty QPointF QtQuick::HandlerPoint::position
+ \brief The position within the \c parent Item
+
+ This is the position of the event point relative to the bounds of
+ the \l {PointerHandler::parent} {parent}.
+*/
+
+/*!
+ \readonly
+ \qmlproperty QPointF QtQuick::HandlerPoint::scenePosition
+ \brief The position within the scene
+
+ This is the position of the event point relative to the bounds of the Qt
+ Quick scene (typically the whole window).
+*/
+
+/*!
+ \readonly
+ \qmlproperty QPointF QtQuick::HandlerPoint::pressPosition
+ \brief The pressed position within the \c parent Item
+
+ This is the position at which this point was pressed, relative to the
+ bounds of the \l {PointerHandler::parent} {parent}.
+*/
+
+/*!
+ \readonly
+ \qmlproperty QPointF QtQuick::HandlerPoint::scenePressPosition
+ \brief The pressed position within the scene
+
+ This is the position at which this point was pressed, in the coordinate
+ system of the \l {Qt Quick Scene Graph}{scene graph}.
+*/
+
+/*!
+ \readonly
+ \qmlproperty QPointF QtQuick::HandlerPoint::sceneGrabPosition
+ \brief The grabbed position within the scene
+
+ If this point has been grabbed by a Pointer Handler or an Item, it means
+ that object has taken sole responsibility for handling the movement and the
+ release if this point. In that case, this is the position at which the grab
+ occurred, in the coordinate system of the \l {Qt Quick Scene Graph}{scene graph}.
+*/
+
+/*!
+ \readonly
+ \qmlproperty enumeration QtQuick::HandlerPoint::pressedButtons
+ \brief Which mouse or stylus buttons are currently pressed
+
+ \sa MouseArea::pressedButtons
+*/
+
+/*!
+ \readonly
+ \qmlproperty enumeration QtQuick::HandlerPoint::modifiers
+ \brief Which modifier keys are currently pressed
+
+ This property holds the keyboard modifiers that were pressed at the time
+ the event occurred.
+
+ \sa MouseArea::modifiers
+*/
+
+/*!
+ \readonly
+ \qmlproperty QVector2D QtQuick::HandlerPoint::velocity
+ \brief A vector representing the average speed and direction of movement
+
+ This is a velocity vector pointing in the direction of movement, in logical
+ pixels per second. It has x and y components, at least one of which will be
+ nonzero when this point is in motion. It holds the average recent velocity:
+ how fast and in which direction the event point has been moving recently.
+
+ \sa QtQuick::EventPoint::velocity, QtQuick::TouchPoint::velocity, QTouchEvent::TouchPoint::velocity
+*/
+
+/*!
+ \readonly
+ \qmlproperty qreal QtQuick::HandlerPoint::rotation
+
+ This property holds the rotation angle of the stylus on a graphics tablet
+ or the contact patch of a touchpoint on a touchscreen.
+
+ It is valid only with certain tablet stylus devices and touchscreens that
+ can measure the rotation angle. Otherwise, it will be zero.
+*/
+
+/*!
+ \readonly
+ \qmlproperty qreal QtQuick::HandlerPoint::pressure
+
+ This property tells how hard the user is pressing the stylus on a graphics
+ tablet or the finger against a touchscreen, in the range from \c 0 (no
+ measurable pressure) to \c 1.0 (maximum pressure which the device can
+ measure).
+
+ It is valid only with certain tablets and touchscreens that can measure
+ pressure. Otherwise, it will be zero.
+*/
+
+/*!
+ \readonly
+ \qmlproperty size QtQuick::HandlerPoint::ellipseDiameters
+
+ This property holds the diameters of the contact patch, if the event
+ comes from a touchpoint and the device provides this information.
+
+ A touchpoint is modeled as an elliptical area where the finger is pressed
+ against the touchscreen. (In fact, it could also be modeled as a bitmap;
+ but in that case we expect an elliptical bounding estimate to be fitted to
+ the contact patch before the event is sent.) The harder the user presses,
+ the larger the contact patch; so, these diameters provide an alternate way
+ of detecting pressure, in case the device does not include a separate
+ pressure sensor. The ellipse is centered on \l scenePosition (\l position
+ in the PointerHandler's Item's local coordinates). The \l rotation property
+ provides the rotation of the ellipse, if known. It is expected that if the
+ \l rotation is zero, the \l {QSize::height}{height} is the larger dimension
+ (the major axis), because of the usual hand position, reaching upward or
+ outward across the surface.
+
+ If the contact patch is unknown, or the device is not a touchscreen,
+ these values will be zero.
+
+ \sa QtQuick::EventTouchPoint::ellipseDiameters, QtQuick::TouchPoint::ellipseDiameters, QTouchEvent::TouchPoint::ellipseDiameters
+*/
+
+QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickhandlerpoint_p.h b/src/quick/handlers/qquickhandlerpoint_p.h
new file mode 100644
index 0000000000..44fd830af2
--- /dev/null
+++ b/src/quick/handlers/qquickhandlerpoint_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKHANDLERPOINT_H
+#define QQUICKHANDLERPOINT_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickpointerdevicehandler_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickMultiPointHandler;
+class QQuickSinglePointHandler;
+
+class Q_QUICK_PRIVATE_EXPORT QQuickHandlerPoint {
+ Q_GADGET
+ Q_PROPERTY(int id READ id)
+ Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId)
+ Q_PROPERTY(QPointF position READ position)
+ Q_PROPERTY(QPointF scenePosition READ scenePosition)
+ Q_PROPERTY(QPointF pressPosition READ pressPosition)
+ Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition)
+ Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition)
+ Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons)
+ Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers)
+ Q_PROPERTY(QVector2D velocity READ velocity)
+ Q_PROPERTY(qreal rotation READ rotation)
+ Q_PROPERTY(qreal pressure READ pressure)
+ Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters)
+
+public:
+ QQuickHandlerPoint();
+
+ int id() const { return m_id; }
+ Qt::MouseButtons pressedButtons() const { return m_pressedButtons; }
+ Qt::KeyboardModifiers modifiers() const { return m_pressedModifiers; }
+ QPointF pressPosition() const { return m_pressPosition; }
+ QPointF scenePressPosition() const { return m_scenePressPosition; }
+ QPointF sceneGrabPosition() const { return m_sceneGrabPosition; }
+ QPointF position() const { return m_position; }
+ QPointF scenePosition() const { return m_scenePosition; }
+ QVector2D velocity() const { return m_velocity; }
+ qreal rotation() const { return m_rotation; }
+ qreal pressure() const { return m_pressure; }
+ QSizeF ellipseDiameters() const { return m_ellipseDiameters; }
+ QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; }
+ void localize(QQuickItem *item);
+
+ void reset();
+ void reset(const QQuickEventPoint *point);
+ void reset(const QVector<QQuickHandlerPoint> &points);
+
+private:
+ int m_id = 0;
+ QPointingDeviceUniqueId m_uniqueId;
+ Qt::MouseButtons m_pressedButtons = Qt::NoButton;
+ Qt::KeyboardModifiers m_pressedModifiers = Qt::NoModifier;
+ QPointF m_position;
+ QPointF m_scenePosition;
+ QPointF m_pressPosition;
+ QPointF m_scenePressPosition;
+ QPointF m_sceneGrabPosition;
+ QVector2D m_velocity;
+ qreal m_rotation = 0;
+ qreal m_pressure = 0;
+ QSizeF m_ellipseDiameters;
+ friend class QQuickMultiPointHandler;
+ friend class QQuickSinglePointHandler;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickHandlerPoint)
+
+#endif // QQUICKHANDLERPOINT_H
diff --git a/src/quick/handlers/qquickhandlersmodule.cpp b/src/quick/handlers/qquickhandlersmodule.cpp
deleted file mode 100644
index c9e08fe4f2..0000000000
--- a/src/quick/handlers/qquickhandlersmodule.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickhandlersmodule_p.h"
-#include "qquickpointerhandler_p.h"
-#include "qquickdraghandler_p.h"
-#include "qquickpinchhandler_p.h"
-#include "qquickpointhandler_p.h"
-#include "qquicktaphandler_p.h"
-
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(qmake_Qt_labs_handlers);
-#endif
-}
-
-QT_BEGIN_NAMESPACE
-
-static QQmlPrivate::AutoParentResult handler_autoParent(QObject *obj, QObject *parent)
-{
- if (qmlobject_cast<QQuickItem *>(parent)) {
- QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj);
- if (handler) {
- handler->setParent(parent);
- return QQmlPrivate::Parented;
- }
- }
- return QQmlPrivate::IncompatibleObject;
-}
-
-static void qt_quickhandlers_defineModule(const char *uri, int major, int minor)
-{
- QQmlPrivate::RegisterAutoParent autoparent = { 0, &handler_autoParent };
- QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
- qmlRegisterUncreatableType<QQuickPointerEvent>(uri, major, minor, "PointerEvent",
- QQuickPointerHandler::tr("PointerEvent is only available as a parameter of several signals in PointerHandler"));
- qmlRegisterUncreatableType<QQuickEventPoint>(uri, major, minor, "EventPoint",
- QQuickPointerHandler::tr("EventPoint is only available as a member of PointerEvent"));
- qmlRegisterUncreatableType<QQuickEventTouchPoint>(uri, major, minor, "EventTouchPoint",
- QQuickPointerHandler::tr("EventTouchPoint is only available as a member of PointerEvent"));
- qmlRegisterUncreatableType<QQuickPointerDevice>(uri, major, minor, "PointerDevice",
- QQuickPointerHandler::tr("PointerDevice is only available as a property of PointerEvent"));
- qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
- qmlRegisterUncreatableType<QPointingDeviceUniqueId>(uri, major, minor, "PointingDeviceUniqueId",
- QQuickPointerHandler::tr("PointingDeviceUniqueId is only available as a property of PointerEvent"));
-
- qmlRegisterUncreatableType<QQuickPointerHandler>(uri,major,minor,"PointerHandler",
- QQuickPointerHandler::tr("PointerHandler is an abstract base class"));
- qmlRegisterType<QQuickPointHandler>(uri,major,minor,"PointHandler");
- qmlRegisterType<QQuickDragHandler>(uri,major,minor,"DragHandler");
- qmlRegisterUncreatableType<QQuickDragAxis>(uri, major, minor, "DragAxis",
- QQuickDragHandler::tr("DragAxis is only available as a grouped property of DragHandler"));
- qmlRegisterType<QQuickPinchHandler>(uri,major,minor,"PinchHandler");
- qmlRegisterType<QQuickTapHandler>(uri,major,minor,"TapHandler");
- qRegisterMetaType<QQuickHandlerPoint>();
-}
-
-void QQuickHandlersModule::defineModule()
-{
- initResources();
-
- const char uri[] = "Qt.labs.handlers";
- int majorVersion = 1;
- int minorVersion = 0;
-
- qt_quickhandlers_defineModule(uri, majorVersion, minorVersion);
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
new file mode 100644
index 0000000000..fbf71ea3fc
--- /dev/null
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickhoverhandler_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcHoverHandler, "qt.quick.handler.hover")
+
+/*!
+ \qmltype HoverHandler
+ \instantiates QQuickHoverHandler
+ \inqmlmodule QtQuick
+ \ingroup qtquick-input-handlers
+ \brief Handler for mouse and tablet hover
+
+ HoverHandler detects a hovering cursor. Since touchscreens don't generally
+ offer hover events, in practice it detects a hovering mouse or tablet stylus.
+
+ \sa MouseArea
+*/
+
+QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent)
+ : QQuickSinglePointHandler(parent)
+{
+ // Rule out the touchscreen for now (can be overridden in QML in case a hover-detecting touchscreen exists)
+ setAcceptedDevices(static_cast<QQuickPointerDevice::DeviceType>(
+ static_cast<int>(QQuickPointerDevice::AllDevices) ^ static_cast<int>(QQuickPointerDevice::TouchScreen)));
+}
+
+QQuickHoverHandler::~QQuickHoverHandler()
+{
+ if (auto parent = parentItem())
+ QQuickItemPrivate::get(parent)->setHasHoverInChild(false);
+}
+
+void QQuickHoverHandler::componentComplete()
+{
+ parentItem()->setAcceptHoverEvents(true);
+ QQuickItemPrivate::get(parentItem())->setHasHoverInChild(true);
+}
+
+bool QQuickHoverHandler::wantsPointerEvent(QQuickPointerEvent *event)
+{
+ QQuickEventPoint *point = event->point(0);
+ if (QQuickPointerDeviceHandler::wantsPointerEvent(event) && wantsEventPoint(point) && parentContains(point)) {
+ // assume this is a mouse event, so there's only one point
+ setPointId(point->pointId());
+ return true;
+ }
+ setHovered(false);
+ return false;
+}
+
+void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point)
+{
+ setHovered(true);
+ setPassiveGrab(point);
+}
+
+void QQuickHoverHandler::setHovered(bool hovered)
+{
+ if (m_hovered != hovered) {
+ qCDebug(lcHoverHandler) << objectName() << "hovered" << m_hovered << "->" << hovered;
+ m_hovered = hovered;
+ emit hoveredChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h
new file mode 100644
index 0000000000..1ee2aeb7e6
--- /dev/null
+++ b/src/quick/handlers/qquickhoverhandler_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKHOVERHANDLER_H
+#define QQUICKHOVERHANDLER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickitem.h"
+#include "qevent.h"
+#include "qquicksinglepointhandler_p.h"
+#include <QtCore/qbasictimer.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler
+{
+ Q_OBJECT
+ Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged)
+
+public:
+ explicit QQuickHoverHandler(QQuickItem *parent = nullptr);
+ ~QQuickHoverHandler();
+
+ bool isHovered() const { return m_hovered; }
+
+Q_SIGNALS:
+ void hoveredChanged();
+
+protected:
+ void componentComplete() override;
+ bool wantsPointerEvent(QQuickPointerEvent *event) override;
+ void handleEventPoint(QQuickEventPoint *point) override;
+
+private:
+ void setHovered(bool hovered);
+
+private:
+ bool m_hovered = false;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickHoverHandler)
+
+#endif // QQUICKHOVERHANDLER_H
diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp
index d595b4c9b4..2f4e9d45e9 100644
--- a/src/quick/handlers/qquickmultipointhandler.cpp
+++ b/src/quick/handlers/qquickmultipointhandler.cpp
@@ -51,23 +51,17 @@ QT_BEGIN_NAMESPACE
\preliminary
\instantiates QQuickMultiPointHandler
\inherits PointerDeviceHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
\brief Abstract handler for multi-point Pointer Events.
An intermediate class (not registered as a QML type)
for any type of handler which requires and acts upon a specific number
of multiple touchpoints.
*/
-QQuickMultiPointHandler::QQuickMultiPointHandler(QObject *parent, int minimumPointCount)
+QQuickMultiPointHandler::QQuickMultiPointHandler(QQuickItem *parent, int minimumPointCount, int maximumPointCount)
: QQuickPointerDeviceHandler(parent)
, m_minimumPointCount(minimumPointCount)
- , m_maximumPointCount(-1)
- , m_pointDistanceThreshold(0)
-{
-}
-
-QQuickMultiPointHandler::~QQuickMultiPointHandler()
+ , m_maximumPointCount(maximumPointCount)
{
}
@@ -81,34 +75,99 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event)
return true;
#endif
- if (sameAsCurrentPoints(event))
- return true;
+ if (event->asPointerScrollEvent())
+ return false;
+ // If points were pressed or released within parentItem, reset stored state
+ // and check eligible points again. This class of handlers is intended to
+ // handle a specific number of points, so a differing number of points will
+ // usually result in different behavior. But otherwise if the currentPoints
+ // are all still there in the event, we're good to go (do not reset
+ // m_currentPoints, because we don't want to lose the pressPosition, and do
+ // not want to reshuffle the order either).
const QVector<QQuickEventPoint *> candidatePoints = eligiblePoints(event);
+ if (candidatePoints.count() != m_currentPoints.count()) {
+ m_currentPoints.clear();
+ if (active()) {
+ setActive(false);
+ m_centroid.reset();
+ emit centroidChanged();
+ }
+ } else if (hasCurrentPoints(event)) {
+ return true;
+ }
+
const bool ret = (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount());
- if (ret)
- m_currentPoints = candidatePoints;
+ if (ret) {
+ const int c = candidatePoints.count();
+ m_currentPoints.resize(c);
+ for (int i = 0; i < c; ++i) {
+ m_currentPoints[i].reset(candidatePoints[i]);
+ m_currentPoints[i].localize(parentItem());
+ }
+ } else {
+ m_currentPoints.clear();
+ }
return ret;
}
+void QQuickMultiPointHandler::handlePointerEventImpl(QQuickPointerEvent *event)
+{
+ QQuickPointerHandler::handlePointerEventImpl(event);
+ // event's points can be reordered since the previous event, which is why m_currentPoints
+ // is _not_ a shallow copy of the QQuickPointerTouchEvent::m_touchPoints vector.
+ // So we have to update our m_currentPoints instances based on the given event.
+ for (QQuickHandlerPoint &p : m_currentPoints) {
+ const QQuickEventPoint *ep = event->pointById(p.id());
+ if (ep)
+ p.reset(ep);
+ }
+ QPointF sceneGrabPos = m_centroid.sceneGrabPosition();
+ m_centroid.reset(m_currentPoints);
+ m_centroid.m_sceneGrabPosition = sceneGrabPos; // preserve as it was
+ emit centroidChanged();
+}
+
+void QQuickMultiPointHandler::onActiveChanged()
+{
+ if (active()) {
+ m_centroid.m_sceneGrabPosition = m_centroid.m_scenePosition;
+ } else {
+ // Don't call m_centroid.reset() here, because in a QML onActiveChanged
+ // callback, we'd like to see what the position _was_, what the velocity _was_, etc.
+ // (having them undefined is not useful)
+ // But pressedButtons and pressedModifiers are meant to be more real-time than those
+ // (which seems a bit inconsistent, from one side).
+ m_centroid.m_pressedButtons = Qt::NoButton;
+ m_centroid.m_pressedModifiers = Qt::NoModifier;
+ }
+}
+
+void QQuickMultiPointHandler::onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *)
+{
+ // If another handler or item takes over this set of points, assume it has
+ // decided that it's the better fit for them. Don't immediately re-grab
+ // at the next opportunity. This should help to avoid grab cycles
+ // (e.g. between DragHandler and PinchHandler).
+ if (transition == QQuickEventPoint::UngrabExclusive || transition == QQuickEventPoint::CancelGrabExclusive)
+ m_currentPoints.clear();
+}
+
QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointerEvent *event)
{
QVector<QQuickEventPoint *> ret;
int c = event->pointCount();
- QRectF parentBounds = parentItem()->mapRectToScene(parentItem()->boundingRect())
- .marginsAdded(QMarginsF(m_pointDistanceThreshold, m_pointDistanceThreshold, m_pointDistanceThreshold, m_pointDistanceThreshold));
// If one or more points are newly pressed or released, all non-released points are candidates for this handler.
- // In other cases however, do not steal the grab: that is, if a point has a grabber,
- // it's not a candidate for this handler.
+ // In other cases however, check whether it would be OK to steal the grab if the handler chooses to do that.
bool stealingAllowed = event->isPressEvent() || event->isReleaseEvent();
for (int i = 0; i < c; ++i) {
QQuickEventPoint *p = event->point(i);
if (!stealingAllowed) {
QObject *exclusiveGrabber = p->exclusiveGrabber();
- if (exclusiveGrabber && exclusiveGrabber != this)
+ if (exclusiveGrabber && exclusiveGrabber != this && !canGrab(p))
continue;
}
- if (p->state() != QQuickEventPoint::Released && parentBounds.contains(p->scenePosition()))
+ if (p->state() != QQuickEventPoint::Released && wantsEventPoint(p))
ret << p;
}
return ret;
@@ -122,7 +181,7 @@ QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointe
If a smaller number of touchpoints are in contact with the
\l {PointerHandler::parent}{parent}, they will be ignored.
- Any ignored points are eligible to activate other Pointer Handlers that
+ Any ignored points are eligible to activate other Input Handlers that
have different constraints, on the same Item or on other Items.
The default value is 2.
@@ -148,7 +207,7 @@ void QQuickMultiPointHandler::setMinimumPointCount(int c)
chosen in the order that they are pressed, and the remaining points will
be ignored.
- Any ignored points are eligible to activate other Pointer Handlers that
+ Any ignored points are eligible to activate other Input Handlers that
have different constraints, on the same Item or on other Items.
The default value is the same as \l minimumPointCount.
@@ -162,70 +221,20 @@ void QQuickMultiPointHandler::setMaximumPointCount(int maximumPointCount)
emit maximumPointCountChanged();
}
-/*!
- \qmlproperty real MultiPointHandler::pointDistanceThreshold
-
- The margin beyond the bounds of the \l {PointerHandler::parent}{parent}
- item within which a touch point can activate this handler. For example, on
- a PinchHandler where the \l {PointerHandler::target}{target} is also the
- \c parent, it's useful to set this to a distance at least half the width
- of a typical user's finger, so that if the \c parent has been scaled down
- to a very small size, the pinch gesture is still possible.
-
- The default value is 0.
-
- \image pointDistanceThreshold.png
-*/
-void QQuickMultiPointHandler::setPointDistanceThreshold(qreal pointDistanceThreshold)
-{
- if (m_pointDistanceThreshold == pointDistanceThreshold)
- return;
-
- m_pointDistanceThreshold = pointDistanceThreshold;
- emit pointDistanceThresholdChanged();
-}
-
-bool QQuickMultiPointHandler::sameAsCurrentPoints(QQuickPointerEvent *event)
+bool QQuickMultiPointHandler::hasCurrentPoints(QQuickPointerEvent *event)
{
- bool ret = true;
- int c = event->pointCount();
- if (c != m_currentPoints.size())
+ if (event->pointCount() < m_currentPoints.size() || m_currentPoints.size() == 0)
return false;
// TODO optimize: either ensure the points are sorted,
// or use std::equal with a predicate
- for (int i = 0; ret && i < c; ++i) {
- if (event->point(i)->state() == QQuickEventPoint::Released)
+ for (const QQuickHandlerPoint &p : qAsConst(m_currentPoints)) {
+ const QQuickEventPoint *ep = event->pointById(p.id());
+ if (!ep)
+ return false;
+ if (ep->state() == QQuickEventPoint::Released)
return false;
- bool found = false;
- int pointId = event->point(i)->pointId();
- for (QQuickEventPoint *o : qAsConst(m_currentPoints))
- if (o && pointId == o->pointId())
- found = true;
- if (!found)
- ret = false;
}
- return ret;
-}
-
-// TODO make templates for these functions somehow?
-QPointF QQuickMultiPointHandler::touchPointCentroid()
-{
- QPointF ret;
- if (Q_UNLIKELY(m_currentPoints.size() == 0))
- return ret;
- for (QQuickEventPoint *point : qAsConst(m_currentPoints))
- ret += point->scenePosition();
- return ret / m_currentPoints.size();
-}
-
-QVector2D QQuickMultiPointHandler::touchPointCentroidVelocity()
-{
- QVector2D ret;
- if (Q_UNLIKELY(m_currentPoints.size() == 0))
- return ret;
- for (QQuickEventPoint *point : qAsConst(m_currentPoints))
- ret += point->velocity();
- return ret / m_currentPoints.size();
+ return true;
}
qreal QQuickMultiPointHandler::averageTouchPointDistance(const QPointF &ref)
@@ -233,8 +242,8 @@ qreal QQuickMultiPointHandler::averageTouchPointDistance(const QPointF &ref)
qreal ret = 0;
if (Q_UNLIKELY(m_currentPoints.size() == 0))
return ret;
- for (QQuickEventPoint *point : qAsConst(m_currentPoints))
- ret += QVector2D(point->scenePosition() - ref).length();
+ for (const QQuickHandlerPoint &p : m_currentPoints)
+ ret += QVector2D(p.scenePosition() - ref).length();
return ret / m_currentPoints.size();
}
@@ -244,8 +253,8 @@ qreal QQuickMultiPointHandler::averageStartingDistance(const QPointF &ref)
qreal ret = 0;
if (Q_UNLIKELY(m_currentPoints.size() == 0))
return ret;
- for (QQuickEventPoint *point : qAsConst(m_currentPoints))
- ret += QVector2D(point->sceneGrabPosition() - ref).length();
+ for (const QQuickHandlerPoint &p : m_currentPoints)
+ ret += QVector2D(p.sceneGrabPosition() - ref).length();
return ret / m_currentPoints.size();
}
@@ -253,9 +262,9 @@ QVector<QQuickMultiPointHandler::PointData> QQuickMultiPointHandler::angles(cons
{
QVector<PointData> angles;
angles.reserve(m_currentPoints.count());
- for (QQuickEventPoint *point : qAsConst(m_currentPoints)) {
- qreal angle = QLineF(ref, point->scenePosition()).angle();
- angles.append(PointData(point->pointId(), -angle)); // convert to clockwise, to be consistent with QQuickItem::rotation
+ for (const QQuickHandlerPoint &p : m_currentPoints) {
+ qreal angle = QLineF(ref, p.scenePosition()).angle();
+ angles.append(PointData(p.id(), -angle)); // convert to clockwise, to be consistent with QQuickItem::rotation
}
return angles;
}
@@ -302,7 +311,7 @@ bool QQuickMultiPointHandler::grabPoints(QVector<QQuickEventPoint *> points)
{
bool allowed = true;
for (QQuickEventPoint* point : points) {
- if (!canGrab(point)) {
+ if (point->exclusiveGrabber() != this && !canGrab(point)) {
allowed = false;
break;
}
@@ -314,4 +323,19 @@ bool QQuickMultiPointHandler::grabPoints(QVector<QQuickEventPoint *> points)
return allowed;
}
+void QQuickMultiPointHandler::moveTarget(QPointF pos)
+{
+ target()->setPosition(pos);
+ m_centroid.m_position = target()->mapFromScene(m_centroid.m_scenePosition);
+}
+
+/*!
+ \readonly
+ \qmlproperty QtQuick::HandlerPoint QtQuick::MultiPointHandler::centroid
+
+ A point exactly in the middle of the currently-pressed touch points.
+ If only one point is pressed, it's the same as that point.
+ A handler that has a \l target will normally transform it relative to this point.
+*/
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickmultipointhandler_p.h b/src/quick/handlers/qquickmultipointhandler_p.h
index 67e550d387..94142013cc 100644
--- a/src/quick/handlers/qquickmultipointhandler_p.h
+++ b/src/quick/handlers/qquickmultipointhandler_p.h
@@ -53,6 +53,7 @@
#include "qquickitem.h"
#include "qevent.h"
+#include "qquickhandlerpoint_p.h"
#include "qquickpointerdevicehandler_p.h"
QT_BEGIN_NAMESPACE
@@ -62,11 +63,10 @@ class Q_AUTOTEST_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHand
Q_OBJECT
Q_PROPERTY(int minimumPointCount READ minimumPointCount WRITE setMinimumPointCount NOTIFY minimumPointCountChanged)
Q_PROPERTY(int maximumPointCount READ maximumPointCount WRITE setMaximumPointCount NOTIFY maximumPointCountChanged)
- Q_PROPERTY(qreal pointDistanceThreshold READ pointDistanceThreshold WRITE setPointDistanceThreshold NOTIFY pointDistanceThresholdChanged)
+ Q_PROPERTY(QQuickHandlerPoint centroid READ centroid NOTIFY centroidChanged)
public:
- explicit QQuickMultiPointHandler(QObject *parent = nullptr, int minimumPointCount = 2);
- ~QQuickMultiPointHandler();
+ explicit QQuickMultiPointHandler(QQuickItem *parent = nullptr, int minimumPointCount = 2, int maximumPointCount = -1);
int minimumPointCount() const { return m_minimumPointCount; }
void setMinimumPointCount(int c);
@@ -74,13 +74,13 @@ public:
int maximumPointCount() const { return m_maximumPointCount >= 0 ? m_maximumPointCount : m_minimumPointCount; }
void setMaximumPointCount(int maximumPointCount);
- qreal pointDistanceThreshold() const { return m_pointDistanceThreshold; }
- void setPointDistanceThreshold(qreal pointDistanceThreshold);
+ QQuickHandlerPoint centroid() const { return m_centroid; }
signals:
void minimumPointCountChanged();
void maximumPointCountChanged();
- void pointDistanceThresholdChanged();
+ void marginChanged();
+ void centroidChanged();
protected:
struct PointData {
@@ -91,10 +91,11 @@ protected:
};
bool wantsPointerEvent(QQuickPointerEvent *event) override;
- bool sameAsCurrentPoints(QQuickPointerEvent *event);
+ void handlePointerEventImpl(QQuickPointerEvent *event) override;
+ void onActiveChanged() override;
+ void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override;
+ bool hasCurrentPoints(QQuickPointerEvent *event);
QVector<QQuickEventPoint *> eligiblePoints(QQuickPointerEvent *event);
- QPointF touchPointCentroid();
- QVector2D touchPointCentroidVelocity();
qreal averageTouchPointDistance(const QPointF &ref);
qreal averageStartingDistance(const QPointF &ref);
qreal averageTouchPointAngle(const QPointF &ref);
@@ -103,12 +104,13 @@ protected:
static qreal averageAngleDelta(const QVector<PointData> &old, const QVector<PointData> &newAngles);
void acceptPoints(const QVector<QQuickEventPoint *> &points);
bool grabPoints(QVector<QQuickEventPoint *> points);
+ void moveTarget(QPointF pos);
protected:
- QVector<QQuickEventPoint *> m_currentPoints;
+ QVector<QQuickHandlerPoint> m_currentPoints;
+ QQuickHandlerPoint m_centroid;
int m_minimumPointCount;
int m_maximumPointCount;
- qreal m_pointDistanceThreshold;
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index 57d851ed59..e6442e7258 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -47,6 +47,7 @@
#include <QMouseEvent>
#include <QDebug>
#include <qpa/qplatformnativeinterface.h>
+#include <math.h>
QT_BEGIN_NAMESPACE
@@ -56,12 +57,12 @@ Q_LOGGING_CATEGORY(lcPinchHandler, "qt.quick.handler.pinch")
\qmltype PinchHandler
\instantiates QQuickPinchHandler
\inherits MultiPointHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
+ \ingroup qtquick-input-handlers
\brief Handler for pinch gestures.
PinchHandler is a handler that interprets a multi-finger gesture to
- interactively rotate, zoom, and drag an Item. Like other Pointer Handlers,
+ interactively rotate, zoom, and drag an Item. Like other Input Handlers,
by default it is fully functional, and manipulates its \l target,
which is the Item within which it is declared.
@@ -85,26 +86,8 @@ Q_LOGGING_CATEGORY(lcPinchHandler, "qt.quick.handler.pinch")
\sa PinchArea
*/
-QQuickPinchHandler::QQuickPinchHandler(QObject *parent)
+QQuickPinchHandler::QQuickPinchHandler(QQuickItem *parent)
: QQuickMultiPointHandler(parent, 2)
- , m_activeScale(1)
- , m_activeRotation(0)
- , m_activeTranslation(0,0)
- , m_minimumScale(-qInf())
- , m_maximumScale(qInf())
- , m_minimumRotation(-qInf())
- , m_maximumRotation(qInf())
- , m_minimumX(-qInf())
- , m_maximumX(qInf())
- , m_minimumY(-qInf())
- , m_maximumY(qInf())
- , m_pinchOrigin(PinchCenter)
- , m_startScale(1)
- , m_startRotation(0)
-{
-}
-
-QQuickPinchHandler::~QQuickPinchHandler()
{
}
@@ -169,29 +152,6 @@ void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation)
}
/*!
- \qmlproperty real QtQuick::PinchHandler::pinchOrigin
-
- The point to be held in place, around which the \l target is scaled and
- rotated.
-
- \value FirstPoint
- the first touch point, wherever the first finger is pressed
- \value PinchCenter
- the centroid between all the touch points at the time when the
- PinchHandler becomes \l active
- \value TargetCenter
- the center of the \l target
-*/
-void QQuickPinchHandler::setPinchOrigin(QQuickPinchHandler::PinchOrigin pinchOrigin)
-{
- if (m_pinchOrigin == pinchOrigin)
- return;
-
- m_pinchOrigin = pinchOrigin;
- emit pinchOriginChanged();
-}
-
-/*!
\qmlproperty real QtQuick::PinchHandler::minimumX
The minimum acceptable x coordinate of the centroid
@@ -287,11 +247,11 @@ bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event)
void QQuickPinchHandler::onActiveChanged()
{
+ QQuickMultiPointHandler::onActiveChanged();
if (active()) {
m_startMatrix = QMatrix4x4();
- m_startCentroid = touchPointCentroid();
- m_startAngles = angles(m_startCentroid);
- m_startDistance = averageTouchPointDistance(m_startCentroid);
+ m_startAngles = angles(m_centroid.sceneGrabPosition());
+ m_startDistance = averageTouchPointDistance(m_centroid.sceneGrabPosition());
m_activeRotation = 0;
m_activeTranslation = QVector2D();
if (const QQuickItem *t = target()) {
@@ -304,7 +264,7 @@ void QQuickPinchHandler::onActiveChanged()
m_startMatrix.rotate(m_startRotation, 0, 0, -1);
m_startMatrix.translate(-xformOrigin);
} else {
- m_startScale = 1;
+ m_startScale = m_accumulatedScale;
m_startRotation = 0;
}
qCInfo(lcPinchHandler) << "activated with starting scale" << m_startScale << "rotation" << m_startRotation;
@@ -316,20 +276,21 @@ void QQuickPinchHandler::onActiveChanged()
void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
{
if (Q_UNLIKELY(lcPinchHandler().isDebugEnabled())) {
- for (QQuickEventPoint *point : qAsConst(m_currentPoints))
- qCDebug(lcPinchHandler) << point->state() << point->sceneGrabPosition() << "->" << point->scenePosition();
+ for (const QQuickHandlerPoint &p : m_currentPoints)
+ qCDebug(lcPinchHandler) << hex << p.id() << p.sceneGrabPosition() << "->" << p.scenePosition();
}
+ QQuickMultiPointHandler::handlePointerEventImpl(event);
qreal dist = 0;
#if QT_CONFIG(gestures)
if (const auto gesture = event->asPointerNativeGestureEvent()) {
+ m_centroid.reset(event->point(0));
switch (gesture->type()) {
case Qt::EndNativeGesture:
m_activeScale = 1;
m_activeRotation = 0;
m_activeTranslation = QVector2D();
- m_centroid = QPointF();
- m_centroidVelocity = QVector2D();
+ m_centroid.reset();
setActive(false);
emit updated();
return;
@@ -344,24 +305,81 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
return;
}
if (!active()) {
- m_centroid = gesture->point(0)->scenePosition();
setActive(true);
- m_startCentroid = m_centroid;
// Native gestures for 2-finger pinch do not allow dragging, so
// the centroid won't move during the gesture, and translation stays at zero
- m_centroidVelocity = QVector2D();
m_activeTranslation = QVector2D();
}
} else
#endif // QT_CONFIG(gestures)
{
- bool containsReleasedPoints = event->isReleaseEvent();
+ const bool containsReleasedPoints = event->isReleaseEvent();
+ QVector<QQuickEventPoint *> chosenPoints;
+ for (const QQuickHandlerPoint &p : m_currentPoints) {
+ QQuickEventPoint *ep = event->pointById(p.id());
+ chosenPoints << ep;
+ }
if (!active()) {
// Verify that at least one of the points has moved beyond threshold needed to activate the handler
- for (QQuickEventPoint *point : qAsConst(m_currentPoints)) {
- if (!containsReleasedPoints && QQuickWindowPrivate::dragOverThreshold(point) && grabPoints(m_currentPoints)) {
- setActive(true);
- break;
+ int numberOfPointsDraggedOverThreshold = 0;
+ QVector2D accumulatedDrag;
+ const QVector2D currentCentroid(m_centroid.scenePosition());
+ const QVector2D pressCentroid(m_centroid.scenePressPosition());
+
+ QStyleHints *styleHints = QGuiApplication::styleHints();
+ const int dragThreshold = styleHints->startDragDistance();
+ const int dragThresholdSquared = dragThreshold * dragThreshold;
+
+ double accumulatedCentroidDistance = 0; // Used to detect scale
+ if (event->isPressEvent())
+ m_accumulatedStartCentroidDistance = 0; // Used to detect scale
+
+ float accumulatedMovementMagnitude = 0;
+
+ for (QQuickEventPoint *point : qAsConst(chosenPoints)) {
+ if (!containsReleasedPoints) {
+ accumulatedDrag += QVector2D(point->scenePressPosition() - point->scenePosition());
+ /*
+ In order to detect a drag, we want to check if all points have moved more or
+ less in the same direction.
+
+ We then take each point, and convert the point to a local coordinate system where
+ the centroid is the origin. This is done both for the press positions and the
+ current positions. We will then have two positions:
+
+ - pressCentroidRelativePosition
+ is the start point relative to the press centroid
+ - currentCentroidRelativePosition
+ is the current point relative to the current centroid
+
+ If those two points are far enough apart, it might not be considered as a drag
+ anymore. (Note that the threshold will matched to the average of the relative
+ movement of all the points). Therefore, a big relative movement will make a big
+ contribution to the average relative movement.
+
+ The algorithm then can be described as:
+ For each point:
+ - Calculate vector pressCentroidRelativePosition (from the press centroid to the press position)
+ - Calculate vector currentCentroidRelativePosition (from the current centroid to the current position)
+ - Calculate the relative movement vector:
+
+ centroidRelativeMovement = currentCentroidRelativePosition - pressCentroidRelativePosition
+
+ and measure its magnitude. Add the magnitude to the accumulatedMovementMagnitude.
+
+ Finally, if the accumulatedMovementMagnitude is below some threshold, it means
+ that the points were stationary or they were moved in parallel (e.g. the hand
+ was moved, but the relative position between each finger remained very much
+ the same). This is then used to rule out if there is a rotation or scale.
+ */
+ QVector2D pressCentroidRelativePosition = QVector2D(point->scenePosition()) - currentCentroid;
+ QVector2D currentCentroidRelativePosition = QVector2D(point->scenePressPosition()) - pressCentroid;
+ QVector2D centroidRelativeMovement = currentCentroidRelativePosition - pressCentroidRelativePosition;
+ accumulatedMovementMagnitude += centroidRelativeMovement.length();
+
+ accumulatedCentroidDistance += pressCentroidRelativePosition.length();
+ if (event->isPressEvent())
+ m_accumulatedStartCentroidDistance += (QVector2D(point->scenePressPosition()) - pressCentroid).length();
} else {
setPassiveGrab(point);
}
@@ -369,47 +387,74 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
point->setAccepted(false); // don't stop propagation
setPassiveGrab(point);
}
+ if (QQuickWindowPrivate::dragOverThreshold(point))
+ ++numberOfPointsDraggedOverThreshold;
+ }
+
+ const bool requiredNumberOfPointsDraggedOverThreshold = numberOfPointsDraggedOverThreshold >= minimumPointCount() && numberOfPointsDraggedOverThreshold <= maximumPointCount();
+ accumulatedMovementMagnitude /= m_currentPoints.count();
+
+ QVector2D avgDrag = accumulatedDrag / m_currentPoints.count();
+ if (!xAxis()->enabled())
+ avgDrag.setX(0);
+ if (!yAxis()->enabled())
+ avgDrag.setY(0);
+
+ const qreal centroidMovementDelta = (currentCentroid - pressCentroid).length();
+
+ qreal distanceToCentroidDelta = qAbs(accumulatedCentroidDistance - m_accumulatedStartCentroidDistance); // Used to detect scale
+ if (numberOfPointsDraggedOverThreshold >= 1) {
+ if (requiredNumberOfPointsDraggedOverThreshold && avgDrag.lengthSquared() >= dragThresholdSquared && accumulatedMovementMagnitude < dragThreshold) {
+ // Drag
+ if (grabPoints(chosenPoints))
+ setActive(true);
+ } else if (distanceToCentroidDelta > dragThreshold) { // all points should in accumulation have been moved beyond threshold (?)
+ // Scale
+ if (grabPoints(chosenPoints))
+ setActive(true);
+ } else if (distanceToCentroidDelta < dragThreshold && (centroidMovementDelta < dragThreshold)) {
+ // Rotate
+ // Since it wasn't a scale and if we exceeded the dragthreshold, and the
+ // centroid didn't moved much, the points must have been moved around the centroid.
+ if (grabPoints(chosenPoints))
+ setActive(true);
+ }
}
if (!active())
return;
}
- // TODO check m_pinchOrigin: right now it acts like it's set to PinchCenter
- m_centroid = touchPointCentroid();
- m_centroidVelocity = touchPointCentroidVelocity();
+
// avoid mapping the minima and maxima, as they might have unmappable values
// such as -inf/+inf. Because of this we perform the bounding to min/max in local coords.
// 1. scale
- dist = averageTouchPointDistance(m_centroid);
+ dist = averageTouchPointDistance(m_centroid.scenePosition());
m_activeScale = dist / m_startDistance;
m_activeScale = qBound(m_minimumScale/m_startScale, m_activeScale, m_maximumScale/m_startScale);
// 2. rotate
- QVector<PointData> newAngles = angles(m_centroid);
+ QVector<PointData> newAngles = angles(m_centroid.scenePosition());
const qreal angleDelta = averageAngleDelta(m_startAngles, newAngles);
m_activeRotation += angleDelta;
m_startAngles = std::move(newAngles);
if (!containsReleasedPoints)
- acceptPoints(m_currentPoints);
+ acceptPoints(chosenPoints);
}
- QPointF centroidParentPos;
- QRectF bounds(m_minimumX, m_minimumY, m_maximumX - m_minimumX, m_maximumY - m_minimumY);
- if (target() && target()->parentItem()) {
- centroidParentPos = target()->parentItem()->mapFromScene(m_centroid);
- centroidParentPos = QPointF(qBound(bounds.left(), centroidParentPos.x(), bounds.right()),
- qBound(bounds.top(), centroidParentPos.y(), bounds.bottom()));
- }
const qreal totalRotation = m_startRotation + m_activeRotation;
const qreal rotation = qBound(m_minimumRotation, totalRotation, m_maximumRotation);
m_activeRotation += (rotation - totalRotation); //adjust for the potential bounding above
- const qreal scale = m_startScale * m_activeScale;
+ m_accumulatedScale = m_startScale * m_activeScale;
if (target() && target()->parentItem()) {
+ const QPointF centroidParentPos = target()->parentItem()->mapFromScene(m_centroid.scenePosition());
// 3. Drag/translate
- const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(m_startCentroid);
+ const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(m_centroid.sceneGrabPosition());
m_activeTranslation = QVector2D(centroidParentPos - centroidStartParentPos);
-
+ if (!xAxis()->enabled())
+ m_activeTranslation.setX(0);
+ if (!yAxis()->enabled())
+ m_activeTranslation.setY(0);
// apply rotation + scaling around the centroid - then apply translation.
QMatrix4x4 mat;
@@ -426,18 +471,23 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
QPointF pos = mat * xformOriginPoint;
pos -= xformOriginPoint;
+ if (xAxis()->enabled())
+ pos.setX(qBound(xAxis()->minimum(), pos.x(), xAxis()->maximum()));
+ if (yAxis()->enabled())
+ pos.setY(qBound(yAxis()->minimum(), pos.y(), yAxis()->maximum()));
+
target()->setPosition(pos);
target()->setRotation(rotation);
- target()->setScale(scale);
+ target()->setScale(m_accumulatedScale);
// TODO some translation inadvertently happens; try to hold the chosen pinch origin in place
} else {
- m_activeTranslation = QVector2D(m_centroid - m_startCentroid);
+ m_activeTranslation = QVector2D(m_centroid.scenePosition() - m_centroid.scenePressPosition());
}
- qCDebug(lcPinchHandler) << "centroid" << m_startCentroid << "->" << m_centroid
+ qCDebug(lcPinchHandler) << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition()
<< ", distance" << m_startDistance << "->" << dist
- << ", startScale" << m_startScale << "->" << scale
+ << ", startScale" << m_startScale << "->" << m_accumulatedScale
<< ", activeRotation" << m_activeRotation
<< ", rotation" << rotation
<< " from " << event->device()->type();
@@ -447,31 +497,33 @@ void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)
/*!
\readonly
- \qmlproperty QPointF QtQuick::PinchHandler::centroid
+ \qmlproperty QtQuick::HandlerPoint QtQuick::PinchHandler::centroid
A point exactly in the middle of the currently-pressed touch points.
- If \l pinchOrigin is set to \c PinchCenter, the \l target will be rotated
- around this point.
+ The \l target will be rotated around this point.
*/
/*!
\readonly
- \qmlproperty QVector2D QtQuick::PinchHandler::centroidVelocity
+ \qmlproperty real QtQuick::PinchHandler::scale
- The average velocity of the \l centroid: a vector representing the speed
- and direction of movement of the whole group of touchpoints, in logical
- pixels per second.
+ The scale factor that will automatically be set on the \l target if it is not null.
+ Otherwise, bindings can be used to do arbitrary things with this value.
+ While the pinch gesture is being performed, it is continuously multiplied by
+ \l activeScale; after the gesture ends, it stays the same; and when the next
+ pinch gesture begins, it begins to be multiplied by activeScale again.
*/
/*!
\readonly
- \qmlproperty real QtQuick::PinchHandler::scale
-
- The scale factor. It is 1.0 when the gesture begins, increases as the
- touchpoints are spread apart, and decreases as the touchpoints are brought
- together. If \l target is not null, this will be automatically applied to its
- \l {Item::scale}{scale}. Otherwise, bindings can be used to do arbitrary
- things with this value.
+ \qmlproperty real QtQuick::PinchHandler::activeScale
+
+ The scale factor while the pinch gesture is being performed.
+ It is 1.0 when the gesture begins, increases as the touchpoints are spread
+ apart, and decreases as the touchpoints are brought together.
+ If \l target is not null, its \l {Item::scale}{scale} will be automatically
+ multiplied by this value.
+ Otherwise, bindings can be used to do arbitrary things with this value.
*/
/*!
diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h
index 9a17971416..8f24d18166 100644
--- a/src/quick/handlers/qquickpinchhandler_p.h
+++ b/src/quick/handlers/qquickpinchhandler_p.h
@@ -55,6 +55,7 @@
#include "qevent.h"
#include "qquickmultipointhandler_p.h"
#include <private/qquicktranslate_p.h>
+#include "qquickdragaxis_p.h"
QT_BEGIN_NAMESPACE
@@ -65,25 +66,19 @@ class Q_AUTOTEST_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
- Q_PROPERTY(PinchOrigin pinchOrigin READ pinchOrigin WRITE setPinchOrigin NOTIFY pinchOriginChanged)
- Q_PROPERTY(QPointF centroid READ centroid NOTIFY updated)
- Q_PROPERTY(QVector2D centroidVelocity READ centroidVelocity NOTIFY updated)
Q_PROPERTY(qreal scale READ scale NOTIFY updated)
+ Q_PROPERTY(qreal activeScale READ activeScale NOTIFY updated)
Q_PROPERTY(qreal rotation READ rotation NOTIFY updated)
Q_PROPERTY(QVector2D translation READ translation NOTIFY updated)
Q_PROPERTY(qreal minimumX READ minimumX WRITE setMinimumX NOTIFY minimumXChanged)
Q_PROPERTY(qreal maximumX READ maximumX WRITE setMaximumX NOTIFY maximumXChanged)
Q_PROPERTY(qreal minimumY READ minimumY WRITE setMinimumY NOTIFY minimumYChanged)
Q_PROPERTY(qreal maximumY READ maximumY WRITE setMaximumY NOTIFY maximumYChanged)
+ Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
+ Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
public:
- enum PinchOrigin {
- FirstPoint, PinchCenter, TargetCenter
- };
- Q_ENUM(PinchOrigin)
-
- explicit QQuickPinchHandler(QObject *parent = nullptr);
- ~QQuickPinchHandler();
+ explicit QQuickPinchHandler(QQuickItem *parent = nullptr);
qreal minimumScale() const { return m_minimumScale; }
void setMinimumScale(qreal minimumScale);
@@ -97,15 +92,10 @@ public:
qreal maximumRotation() const { return m_maximumRotation; }
void setMaximumRotation(qreal maximumRotation);
- PinchOrigin pinchOrigin() const { return m_pinchOrigin; }
- void setPinchOrigin(PinchOrigin pinchOrigin);
-
QVector2D translation() const { return m_activeTranslation; }
- qreal scale() const { return m_activeScale; }
+ qreal scale() const { return m_accumulatedScale; }
+ qreal activeScale() const { return m_activeScale; }
qreal rotation() const { return m_activeRotation; }
- QPointF centroid() const { return m_centroid; }
- QVector2D centroidVelocity() const { return m_centroidVelocity; }
-
qreal minimumX() const { return m_minimumX; }
void setMinimumX(qreal minX);
qreal maximumX() const { return m_maximumX; }
@@ -115,6 +105,9 @@ public:
qreal maximumY() const { return m_maximumY; }
void setMaximumY(qreal maxY);
+ QQuickDragAxis *xAxis() { return &m_xAxis; }
+ QQuickDragAxis *yAxis() { return &m_yAxis; }
+
signals:
void minimumScaleChanged();
void maximumScaleChanged();
@@ -124,7 +117,6 @@ signals:
void maximumXChanged();
void minimumYChanged();
void maximumYChanged();
- void pinchOriginChanged();
void updated();
protected:
@@ -134,36 +126,34 @@ protected:
private:
// properties
- qreal m_activeScale;
- qreal m_activeRotation;
- QVector2D m_activeTranslation;
- QPointF m_centroid;
- QVector2D m_centroidVelocity;
-
- qreal m_minimumScale;
- qreal m_maximumScale;
+ qreal m_activeScale = 1;
+ qreal m_accumulatedScale = 1;
+ qreal m_activeRotation = 0;
+ QVector2D m_activeTranslation = QVector2D(0, 0);
- qreal m_minimumRotation;
- qreal m_maximumRotation;
+ qreal m_minimumScale = -qInf();
+ qreal m_maximumScale = qInf();
- qreal m_minimumX;
- qreal m_maximumX;
- qreal m_minimumY;
- qreal m_maximumY;
+ qreal m_minimumRotation = -qInf();
+ qreal m_maximumRotation = qInf();
- PinchOrigin m_pinchOrigin;
+ qreal m_minimumX = -qInf();
+ qreal m_maximumX = qInf();
+ qreal m_minimumY = -qInf();
+ qreal m_maximumY = qInf();
+ QQuickDragAxis m_xAxis;
+ QQuickDragAxis m_yAxis;
// internal
- qreal m_startScale;
- qreal m_startRotation;
- QPointF m_startCentroid;
- qreal m_startDistance;
+ qreal m_startScale = 1;
+ qreal m_startRotation = 0;
+ qreal m_startDistance = 0;
QPointF m_startPos;
+ qreal m_accumulatedStartCentroidDistance = 0;
QVector<PointData> m_startAngles;
QMatrix4x4 m_startMatrix;
QQuickMatrix4x4 m_transform;
-
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp
index 06831613b6..096fad2071 100644
--- a/src/quick/handlers/qquickpointerdevicehandler.cpp
+++ b/src/quick/handlers/qquickpointerdevicehandler.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qquickpointerdevicehandler_p.h"
+#include "qquickpointerdevicehandler_p_p.h"
#include <private/qquickitem_p.h>
#include <QMouseEvent>
#include <QDebug>
@@ -51,27 +51,87 @@ QT_BEGIN_NAMESPACE
\preliminary
\instantiates QQuickPointerDeviceHandler
\inherits PointerHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
\brief Abstract handler for pointer events with device-specific constraints.
An intermediate class (not registered as a QML type) for handlers which
allow filtering based on device type, pointer type, or keyboard modifiers.
*/
-QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QObject *parent)
- : QQuickPointerHandler(parent)
- , m_acceptedDevices(QQuickPointerDevice::AllDevices)
- , m_acceptedPointerTypes(QQuickPointerDevice::AllPointerTypes)
- , m_acceptedModifiers(Qt::KeyboardModifierMask)
+QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QQuickItem *parent)
+ : QQuickPointerHandler(*(new QQuickPointerDeviceHandlerPrivate), parent)
{
}
-QQuickPointerDeviceHandler::~QQuickPointerDeviceHandler()
+QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QQuickPointerDeviceHandlerPrivate &dd, QQuickItem *parent)
+ : QQuickPointerHandler(dd, parent)
{
}
+QQuickPointerDevice::DeviceTypes QQuickPointerDeviceHandler::acceptedDevices() const
+{
+ Q_D(const QQuickPointerDeviceHandler);
+ return d->acceptedDevices;
+}
+
+QQuickPointerDevice::PointerTypes QQuickPointerDeviceHandler::acceptedPointerTypes() const
+{
+ Q_D(const QQuickPointerDeviceHandler);
+ return d->acceptedPointerTypes;
+}
+
+/*!
+ \qmlproperty flags QtQuick::PointerDeviceHandler::acceptedButtons
+
+ The mouse buttons which can activate this Pointer Handler.
+
+ By default, this property is set to \l {QtQuick::MouseEvent::button} {Qt.LeftButton}.
+ It can be set to an OR combination of mouse buttons, and will ignore events
+ from other buttons.
+
+ For example, a control could be made to respond to left and right clicks
+ in different ways, with two handlers:
+
+ \qml
+ Item {
+ TapHandler {
+ onTapped: console.log("left clicked")
+ }
+ TapHandler {
+ acceptedButtons: Qt.RightButton
+ onTapped: console.log("right clicked")
+ }
+ }
+ \endqml
+
+ \note Tapping on a touchscreen or tapping the stylus on a graphics tablet
+ emulates clicking the left mouse button. This behavior can be altered via
+ \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices} or
+ \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes}.
+*/
+Qt::MouseButtons QQuickPointerDeviceHandler::acceptedButtons() const
+{
+ Q_D(const QQuickPointerDeviceHandler);
+ return d->acceptedButtons;
+}
+
+void QQuickPointerDeviceHandler::setAcceptedButtons(Qt::MouseButtons buttons)
+{
+ Q_D(QQuickPointerDeviceHandler);
+ if (d->acceptedButtons == buttons)
+ return;
+
+ d->acceptedButtons = buttons;
+ emit acceptedButtonsChanged();
+}
+
+Qt::KeyboardModifiers QQuickPointerDeviceHandler::acceptedModifiers() const
+{
+ Q_D(const QQuickPointerDeviceHandler);
+ return d->acceptedModifiers;
+}
+
/*!
- \qmlproperty int PointerDeviceHandler::acceptedDevices
+ \qmlproperty flags PointerDeviceHandler::acceptedDevices
The types of pointing devices that can activate this Pointer Handler.
@@ -98,15 +158,16 @@ QQuickPointerDeviceHandler::~QQuickPointerDeviceHandler()
*/
void QQuickPointerDeviceHandler::setAcceptedDevices(QQuickPointerDevice::DeviceTypes acceptedDevices)
{
- if (m_acceptedDevices == acceptedDevices)
+ Q_D(QQuickPointerDeviceHandler);
+ if (d->acceptedDevices == acceptedDevices)
return;
- m_acceptedDevices = acceptedDevices;
+ d->acceptedDevices = acceptedDevices;
emit acceptedDevicesChanged();
}
/*!
- \qmlproperty int PointerDeviceHandler::acceptedPointerTypes
+ \qmlproperty flags PointerDeviceHandler::acceptedPointerTypes
The types of pointing instruments (finger, stylus, eraser, etc.)
that can activate this Pointer Handler.
@@ -136,15 +197,16 @@ void QQuickPointerDeviceHandler::setAcceptedDevices(QQuickPointerDevice::DeviceT
*/
void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QQuickPointerDevice::PointerTypes acceptedPointerTypes)
{
- if (m_acceptedPointerTypes == acceptedPointerTypes)
+ Q_D(QQuickPointerDeviceHandler);
+ if (d->acceptedPointerTypes == acceptedPointerTypes)
return;
- m_acceptedPointerTypes = acceptedPointerTypes;
+ d->acceptedPointerTypes = acceptedPointerTypes;
emit acceptedPointerTypesChanged();
}
/*!
- \qmlproperty int PointerDeviceHandler::acceptedModifiers
+ \qmlproperty flags PointerDeviceHandler::acceptedModifiers
If this property is set, it will require the given keyboard modifiers to
be pressed in order to react to pointer events, and otherwise ignore them.
@@ -171,26 +233,28 @@ void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QQuickPointerDevice::Po
*/
void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)
{
- if (m_acceptedModifiers == acceptedModifiers)
+ Q_D(QQuickPointerDeviceHandler);
+ if (d->acceptedModifiers == acceptedModifiers)
return;
- m_acceptedModifiers = acceptedModifiers;
+ d->acceptedModifiers = acceptedModifiers;
emit acceptedModifiersChanged();
}
bool QQuickPointerDeviceHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
+ Q_D(QQuickPointerDeviceHandler);
if (!QQuickPointerHandler::wantsPointerEvent(event))
return false;
qCDebug(lcPointerHandlerDispatch) << objectName()
- << "checking device type" << m_acceptedDevices
- << "pointer type" << m_acceptedPointerTypes
- << "modifiers" << m_acceptedModifiers;
- if ((event->device()->type() & m_acceptedDevices) == 0)
+ << "checking device type" << d->acceptedDevices
+ << "pointer type" << d->acceptedPointerTypes
+ << "modifiers" << d->acceptedModifiers;
+ if ((event->device()->type() & d->acceptedDevices) == 0)
return false;
- if ((event->device()->pointerType() & m_acceptedPointerTypes) == 0)
+ if ((event->device()->pointerType() & d->acceptedPointerTypes) == 0)
return false;
- if (m_acceptedModifiers != Qt::KeyboardModifierMask && event->modifiers() != m_acceptedModifiers)
+ if (d->acceptedModifiers != Qt::KeyboardModifierMask && event->modifiers() != d->acceptedModifiers)
return false;
return true;
}
diff --git a/src/quick/handlers/qquickpointerdevicehandler_p.h b/src/quick/handlers/qquickpointerdevicehandler_p.h
index 1638604ea7..82b24369d3 100644
--- a/src/quick/handlers/qquickpointerdevicehandler_p.h
+++ b/src/quick/handlers/qquickpointerdevicehandler_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -36,6 +36,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "qquickpointerhandler_p.h"
#ifndef QQUICKPOINTERDEVICEHANDLER_H
#define QQUICKPOINTERDEVICEHANDLER_H
@@ -51,42 +52,44 @@
// We mean it.
//
-#include "qquickpointerhandler_p.h"
-
QT_BEGIN_NAMESPACE
+class QQuickPointerDeviceHandlerPrivate;
+
class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler
{
Q_OBJECT
Q_PROPERTY(QQuickPointerDevice::DeviceTypes acceptedDevices READ acceptedDevices WRITE setAcceptedDevices NOTIFY acceptedDevicesChanged)
Q_PROPERTY(QQuickPointerDevice::PointerTypes acceptedPointerTypes READ acceptedPointerTypes WRITE setAcceptedPointerTypes NOTIFY acceptedPointerTypesChanged)
+ Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(Qt::KeyboardModifiers acceptedModifiers READ acceptedModifiers WRITE setAcceptedModifiers NOTIFY acceptedModifiersChanged)
public:
- explicit QQuickPointerDeviceHandler(QObject *parent = nullptr);
- ~QQuickPointerDeviceHandler();
+ explicit QQuickPointerDeviceHandler(QQuickItem *parent = nullptr);
- QQuickPointerDevice::DeviceTypes acceptedDevices() const { return m_acceptedDevices; }
- QQuickPointerDevice::PointerTypes acceptedPointerTypes() const { return m_acceptedPointerTypes; }
- Qt::KeyboardModifiers acceptedModifiers() const { return m_acceptedModifiers; }
+ QQuickPointerDevice::DeviceTypes acceptedDevices() const;
+ QQuickPointerDevice::PointerTypes acceptedPointerTypes() const;
+ Qt::MouseButtons acceptedButtons() const;
+ Qt::KeyboardModifiers acceptedModifiers() const;
-public slots:
+public Q_SLOTS:
void setAcceptedDevices(QQuickPointerDevice::DeviceTypes acceptedDevices);
void setAcceptedPointerTypes(QQuickPointerDevice::PointerTypes acceptedPointerTypes);
+ void setAcceptedButtons(Qt::MouseButtons buttons);
void setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers);
Q_SIGNALS:
void acceptedDevicesChanged();
void acceptedPointerTypesChanged();
+ void acceptedButtonsChanged();
void acceptedModifiersChanged();
protected:
+ QQuickPointerDeviceHandler(QQuickPointerDeviceHandlerPrivate &dd, QQuickItem *parent = nullptr);
+
bool wantsPointerEvent(QQuickPointerEvent *event) override;
-protected:
- QQuickPointerDevice::DeviceTypes m_acceptedDevices;
- QQuickPointerDevice::PointerTypes m_acceptedPointerTypes;
- Qt::KeyboardModifiers m_acceptedModifiers;
+ Q_DECLARE_PRIVATE(QQuickPointerDeviceHandler)
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointerdevicehandler_p_p.h b/src/quick/handlers/qquickpointerdevicehandler_p_p.h
new file mode 100644
index 0000000000..6a950590f3
--- /dev/null
+++ b/src/quick/handlers/qquickpointerdevicehandler_p_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPOINTERDEVICEHANDLER_P_H
+#define QQUICKPOINTERDEVICEHANDLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickpointerdevicehandler_p.h"
+#include "qquickpointerhandler_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandlerPrivate : public QQuickPointerHandlerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPointerDeviceHandler)
+
+public:
+ static QQuickPointerDeviceHandlerPrivate* get(QQuickPointerDeviceHandler *q) { return q->d_func(); }
+ static const QQuickPointerDeviceHandlerPrivate* get(const QQuickPointerDeviceHandler *q) { return q->d_func(); }
+
+ QQuickPointerDevice::DeviceTypes acceptedDevices = QQuickPointerDevice::AllDevices;
+ QQuickPointerDevice::PointerTypes acceptedPointerTypes = QQuickPointerDevice::AllPointerTypes;
+ Qt::MouseButtons acceptedButtons = Qt::LeftButton;
+ Qt::KeyboardModifiers acceptedModifiers = Qt::KeyboardModifierMask;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPOINTERDEVICEHANDLER_P_H
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index e5b1dc8985..12c06aa179 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -38,6 +38,8 @@
****************************************************************************/
#include "qquickpointerhandler_p.h"
+#include "qquickpointerhandler_p_p.h"
+#include <QtQuick/private/qquickitem_p.h>
QT_BEGIN_NAMESPACE
@@ -51,24 +53,20 @@ Q_LOGGING_CATEGORY(lcPointerHandlerActive, "qt.quick.handler.active")
\since 5.10
\preliminary
\instantiates QQuickPointerHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
\brief Abstract handler for pointer events.
- PointerHandler is the base class handler (not registered as a QML type) for
- pointer events without regard to source (touch, mouse or graphics tablet).
+ PointerHandler is the base class Input Handler (not registered as a QML type) for
+ events from any kind of pointing device (touch, mouse or graphics tablet).
*/
-QQuickPointerHandler::QQuickPointerHandler(QObject *parent)
- : QObject(parent)
- , m_currentEvent(nullptr)
- , m_target(nullptr)
- , m_enabled(true)
- , m_active(false)
- , m_targetExplicitlySet(false)
- , m_hadKeepMouseGrab(false)
- , m_hadKeepTouchGrab(false)
- , m_grabPermissions(CanTakeOverFromItems | CanTakeOverFromHandlersOfDifferentType | ApprovesTakeOverByAnything)
+QQuickPointerHandler::QQuickPointerHandler(QQuickItem *parent)
+ : QObject(*(new QQuickPointerHandlerPrivate), parent)
+{
+}
+
+QQuickPointerHandler::QQuickPointerHandler(QQuickPointerHandlerPrivate &dd, QQuickItem *parent)
+ : QObject(dd, parent)
{
}
@@ -82,25 +80,58 @@ QQuickPointerHandler::~QQuickPointerHandler()
}
/*!
+ \qmlproperty real PointerHandler::margin
+
+ The margin beyond the bounds of the \l {PointerHandler::parent}{parent}
+ item within which an event point can activate this handler. For example, on
+ a PinchHandler where the \l {PointerHandler::target}{target} is also the
+ \c parent, it's useful to set this to a distance at least half the width
+ of a typical user's finger, so that if the \c parent has been scaled down
+ to a very small size, the pinch gesture is still possible. Or, if a
+ TapHandler-based button is placed near the screen edge, it can be used
+ to comply with Fitts's Law: react to mouse clicks at the screen edge
+ even though the button is visually spaced away from the edge by a few pixels.
+
+ The default value is 0.
+
+ \image pointerHandlerMargin.png
+*/
+qreal QQuickPointerHandler::margin() const
+{
+ Q_D(const QQuickPointerHandler);
+ return d->m_margin;
+}
+
+void QQuickPointerHandler::setMargin(qreal pointDistanceThreshold)
+{
+ Q_D(QQuickPointerHandler);
+ if (d->m_margin == pointDistanceThreshold)
+ return;
+
+ d->m_margin = pointDistanceThreshold;
+ emit marginChanged();
+}
+
+/*!
Notification that the grab has changed in some way which is relevant to this handler.
- The \a grabber (subject) will be the PointerHandler whose state is changing,
+ The \a grabber (subject) will be the Input Handler whose state is changing,
or null if the state change regards an Item.
- The \a stateChange (verb) tells what happened.
+ The \a transition (verb) tells what happened.
The \a point (object) is the point that was grabbed or ungrabbed.
EventPoint has the sole responsibility to call this function.
- The PointerHandler must react in whatever way is appropriate, and must
+ The Input Handler must react in whatever way is appropriate, and must
emit the relevant signals (for the benefit of QML code).
A subclass is allowed to override this virtual function, but must always
call its parent class's implementation in addition to (usually after)
whatever custom behavior it implements.
*/
-void QQuickPointerHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)
+void QQuickPointerHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point)
{
- qCDebug(lcPointerHandlerGrab) << point << stateChange << grabber;
+ qCDebug(lcPointerHandlerGrab) << point << transition << grabber;
Q_ASSERT(point);
if (grabber == this) {
bool wasCanceled = false;
- switch (stateChange) {
+ switch (transition) {
case QQuickEventPoint::GrabPassive:
case QQuickEventPoint::GrabExclusive:
break;
@@ -113,8 +144,9 @@ void QQuickPointerHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEv
setActive(false);
point->setAccepted(false);
if (auto par = parentItem()) {
- par->setKeepMouseGrab(m_hadKeepMouseGrab);
- par->setKeepTouchGrab(m_hadKeepTouchGrab);
+ Q_D(const QQuickPointerHandler);
+ par->setKeepMouseGrab(d->hadKeepMouseGrab);
+ par->setKeepTouchGrab(d->hadKeepTouchGrab);
}
break;
case QQuickEventPoint::OverrideGrabPassive:
@@ -124,19 +156,17 @@ void QQuickPointerHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEv
}
if (wasCanceled)
emit canceled(point);
- else
- emit grabChanged(point);
+ emit grabChanged(transition, point);
}
}
/*!
- \internal
Acquire or give up a passive grab of the given \a point, according to the \a grab state.
- Unlike the exclusive grab, multiple PointerHandlers can have passive grabs
+ Unlike the exclusive grab, multiple Input Handlers can have passive grabs
simultaneously. This means that each of them will receive further events
- when the \a point moves, and when it is finally released. Typically a
- PointerHandler should acquire a passive grab as soon as a point is pressed,
+ when the \a point moves, and when it is finally released. Typically an
+ Input Handler should acquire a passive grab as soon as a point is pressed,
if the handler's constraints do not clearly rule out any interest in that
point. For example, DragHandler needs a passive grab in order to watch the
movement of a point to see whether it will be dragged past the drag
@@ -181,19 +211,20 @@ bool QQuickPointerHandler::canGrab(QQuickEventPoint *point)
*/
bool QQuickPointerHandler::approveGrabTransition(QQuickEventPoint *point, QObject *proposedGrabber)
{
+ Q_D(const QQuickPointerHandler);
bool allowed = false;
if (proposedGrabber == this) {
QObject* existingGrabber = point->exclusiveGrabber();
- allowed = (existingGrabber == nullptr) || ((m_grabPermissions & CanTakeOverFromAnything) == CanTakeOverFromAnything);
+ allowed = (existingGrabber == nullptr) || ((d->grabPermissions & CanTakeOverFromAnything) == CanTakeOverFromAnything);
if (existingGrabber) {
if (QQuickPointerHandler *existingPhGrabber = point->grabberPointerHandler()) {
- if (!allowed && (m_grabPermissions & CanTakeOverFromHandlersOfDifferentType) &&
+ if (!allowed && (d->grabPermissions & CanTakeOverFromHandlersOfDifferentType) &&
existingPhGrabber->metaObject()->className() != metaObject()->className())
allowed = true;
- if (!allowed && (m_grabPermissions & CanTakeOverFromHandlersOfSameType) &&
+ if (!allowed && (d->grabPermissions & CanTakeOverFromHandlersOfSameType) &&
existingPhGrabber->metaObject()->className() == metaObject()->className())
allowed = true;
- } else if ((m_grabPermissions & CanTakeOverFromItems)) {
+ } else if ((d->grabPermissions & CanTakeOverFromItems)) {
QQuickItem * existingItemGrabber = point->grabberItem();
if (existingItemGrabber && !((existingItemGrabber->keepMouseGrab() && point->pointerEvent()->asPointerMouseEvent()) ||
(existingItemGrabber->keepTouchGrab() && point->pointerEvent()->asPointerTouchEvent())))
@@ -203,18 +234,18 @@ bool QQuickPointerHandler::approveGrabTransition(QQuickEventPoint *point, QObjec
} else {
// proposedGrabber is different: that means this instance will lose its grab
if (proposedGrabber) {
- if ((m_grabPermissions & ApprovesTakeOverByAnything) == ApprovesTakeOverByAnything)
+ if ((d->grabPermissions & ApprovesTakeOverByAnything) == ApprovesTakeOverByAnything)
allowed = true;
- if (!allowed && (m_grabPermissions & ApprovesTakeOverByHandlersOfDifferentType) &&
+ if (!allowed && (d->grabPermissions & ApprovesTakeOverByHandlersOfDifferentType) &&
proposedGrabber->metaObject()->className() != metaObject()->className())
allowed = true;
- if (!allowed && (m_grabPermissions & ApprovesTakeOverByHandlersOfSameType) &&
+ if (!allowed && (d->grabPermissions & ApprovesTakeOverByHandlersOfSameType) &&
proposedGrabber->metaObject()->className() == metaObject()->className())
allowed = true;
- if (!allowed && (m_grabPermissions & ApprovesTakeOverByItems) && proposedGrabber->inherits("QQuickItem"))
+ if (!allowed && (d->grabPermissions & ApprovesTakeOverByItems) && proposedGrabber->inherits("QQuickItem"))
allowed = true;
} else {
- if (!allowed && (m_grabPermissions & ApprovesCancellation))
+ if (!allowed && (d->grabPermissions & ApprovesCancellation))
allowed = true;
}
}
@@ -225,23 +256,49 @@ bool QQuickPointerHandler::approveGrabTransition(QQuickEventPoint *point, QObjec
}
/*!
- \qmlproperty bool QtQuick::PointerHandler::grabPermission
+ \qmlproperty flags QtQuick::PointerHandler::grabPermissions
This property specifies the permissions when this handler's logic decides
to take over the exclusive grab, or when it is asked to approve grab
takeover or cancellation by another handler.
+ \value PointerHandler.TakeOverForbidden
+ This handler neither takes from nor gives grab permission to any type of Item or Handler.
+ \value PointerHandler.CanTakeOverFromHandlersOfSameType
+ This handler can take the exclusive grab from another handler of the same class.
+ \value PointerHandler.CanTakeOverFromHandlersOfDifferentType
+ This handler can take the exclusive grab from any kind of handler.
+ \value PointerHandler.CanTakeOverFromAnything
+ This handler can take the exclusive grab from any type of Item or Handler.
+ \value PointerHandler.ApprovesTakeOverByHandlersOfSameType
+ This handler gives permission for another handler of the same class to take the grab.
+ \value PointerHandler.ApprovesTakeOverByHandlersOfDifferentType
+ This handler gives permission for any kind of handler to take the grab.
+ \value PointerHandler.ApprovesTakeOverByItems
+ This handler gives permission for any kind of Item to take the grab.
+ \value PointerHandler.ApprovesCancellation
+ This handler will allow its grab to be set to null.
+ \value PointerHandler.ApprovesTakeOverByAnything
+ This handler gives permission for any any type of Item or Handler to take the grab.
+
The default is
- \c {CanTakeOverFromItems | CanTakeOverFromHandlersOfDifferentType | ApprovesTakeOverByAnything}
+ \c {PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything}
which allows most takeover scenarios but avoids e.g. two PinchHandlers fighting
over the same touchpoints.
*/
+QQuickPointerHandler::GrabPermissions QQuickPointerHandler::grabPermissions() const
+{
+ Q_D(const QQuickPointerHandler);
+ return static_cast<QQuickPointerHandler::GrabPermissions>(d->grabPermissions);
+}
+
void QQuickPointerHandler::setGrabPermissions(GrabPermissions grabPermission)
{
- if (m_grabPermissions == grabPermission)
+ Q_D(QQuickPointerHandler);
+ if (d->grabPermissions == grabPermission)
return;
- m_grabPermissions = grabPermission;
+ d->grabPermissions = grabPermission;
emit grabPermissionChanged();
}
@@ -253,8 +310,13 @@ void QQuickPointerHandler::componentComplete()
{
}
+QQuickPointerEvent *QQuickPointerHandler::currentEvent()
+{
+ Q_D(const QQuickPointerHandler);
+ return d->currentEvent;
+}
+
/*!
- \internal
Acquire or give up the exclusive grab of the given \a point, according to
the \a grab state, and subject to the rules: canGrab(), and the rule not to
relinquish another handler's grab. Returns true if permission is granted,
@@ -284,7 +346,6 @@ bool QQuickPointerHandler::setExclusiveGrab(QQuickEventPoint *point, bool grab)
}
/*!
- \internal
Cancel any existing grab of the given \a point.
*/
void QQuickPointerHandler::cancelAllGrabs(QQuickEventPoint *point)
@@ -300,9 +361,19 @@ QPointF QQuickPointerHandler::eventPos(const QQuickEventPoint *point) const
bool QQuickPointerHandler::parentContains(const QQuickEventPoint *point) const
{
- if (point) {
- if (QQuickItem *par = parentItem())
- return par->contains(par->mapFromScene(point->scenePosition()));
+ if (!point)
+ return false;
+ if (QQuickItem *par = parentItem()) {
+ if (par->window()) {
+ QPoint screenPosition = par->window()->mapToGlobal(point->scenePosition().toPoint());
+ if (!par->window()->geometry().contains(screenPosition))
+ return false;
+ }
+ QPointF p = par->mapFromScene(point->scenePosition());
+ qreal m = margin();
+ if (m > 0)
+ return p.x() >= -m && p.y() >= -m && p.x() <= par->width() + m && p.y() <= par->height() + m;
+ return par->contains(p);
}
return false;
}
@@ -313,15 +384,28 @@ bool QQuickPointerHandler::parentContains(const QQuickEventPoint *point) const
If a PointerHandler is disabled, it will reject all events
and no signals will be emitted.
*/
+bool QQuickPointerHandler::enabled() const
+{
+ Q_D(const QQuickPointerHandler);
+ return d->enabled;
+}
+
void QQuickPointerHandler::setEnabled(bool enabled)
{
- if (m_enabled == enabled)
+ Q_D(QQuickPointerHandler);
+ if (d->enabled == enabled)
return;
- m_enabled = enabled;
+ d->enabled = enabled;
emit enabledChanged();
}
+bool QQuickPointerHandler::active() const
+{
+ Q_D(const QQuickPointerHandler);
+ return d->active;
+}
+
/*!
\qmlproperty Item QtQuick::PointerHandler::target
@@ -335,21 +419,28 @@ void QQuickPointerHandler::setEnabled(bool enabled)
*/
void QQuickPointerHandler::setTarget(QQuickItem *target)
{
- m_targetExplicitlySet = true;
- if (m_target == target)
+ Q_D(QQuickPointerHandler);
+ d->targetExplicitlySet = true;
+ if (d->target == target)
return;
- QQuickItem *oldTarget = m_target;
- m_target = target;
+ QQuickItem *oldTarget = d->target;
+ d->target = target;
onTargetChanged(oldTarget);
emit targetChanged();
}
+QQuickItem *QQuickPointerHandler::parentItem() const
+{
+ return static_cast<QQuickItem *>(QObject::parent());
+}
+
QQuickItem *QQuickPointerHandler::target() const
{
- if (!m_targetExplicitlySet)
+ Q_D(const QQuickPointerHandler);
+ if (!d->targetExplicitlySet)
return parentItem();
- return m_target;
+ return d->target;
}
void QQuickPointerHandler::handlePointerEvent(QQuickPointerEvent *event)
@@ -374,15 +465,24 @@ void QQuickPointerHandler::handlePointerEvent(QQuickPointerEvent *event)
bool QQuickPointerHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
+ Q_D(const QQuickPointerHandler);
Q_UNUSED(event)
- return m_enabled;
+ return d->enabled;
+}
+
+bool QQuickPointerHandler::wantsEventPoint(QQuickEventPoint *point)
+{
+ bool ret = point->exclusiveGrabber() == this || point->passiveGrabbers().contains(this) || parentContains(point);
+ qCDebug(lcPointerHandlerDispatch) << hex << point->pointId() << "@" << point->scenePosition()
+ << metaObject()->className() << objectName() << ret;
+ return ret;
}
/*!
\readonly
\qmlproperty bool QtQuick::PointerHandler::active
- This holds true whenever this PointerHandler has taken sole responsibility
+ This holds true whenever this Input Handler has taken sole responsibility
for handing one or more EventPoints, by successfully taking an exclusive
grab of those points. This means that it is keeping its properties
up-to-date according to the movements of those Event Points and actively
@@ -390,9 +490,10 @@ bool QQuickPointerHandler::wantsPointerEvent(QQuickPointerEvent *event)
*/
void QQuickPointerHandler::setActive(bool active)
{
- if (m_active != active) {
- qCDebug(lcPointerHandlerActive) << this << m_active << "->" << active;
- m_active = active;
+ Q_D(QQuickPointerHandler);
+ if (d->active != active) {
+ qCDebug(lcPointerHandlerActive) << this << d->active << "->" << active;
+ d->active = active;
onActiveChanged();
emit activeChanged();
}
@@ -400,7 +501,8 @@ void QQuickPointerHandler::setActive(bool active)
void QQuickPointerHandler::handlePointerEventImpl(QQuickPointerEvent *event)
{
- m_currentEvent = event;
+ Q_D(QQuickPointerHandler);
+ d->currentEvent = event;
}
/*!
@@ -417,10 +519,13 @@ void QQuickPointerHandler::handlePointerEventImpl(QQuickPointerEvent *event)
*/
/*!
- \qmlsignal QtQuick::PointerHandler::grabChanged(EventPoint point)
+ \qmlsignal QtQuick::PointerHandler::grabChanged(GrabTransition transition, EventPoint point)
- This signal is emitted when this handler has acquired or relinquished a
- passive or exclusive grab of the given \a point.
+ This signal is emitted when the grab has changed in some way which is
+ relevant to this handler.
+
+ The \a transition (verb) tells what happened.
+ The \a point (object) is the point that was grabbed or ungrabbed.
*/
/*!
@@ -430,4 +535,16 @@ void QQuickPointerHandler::handlePointerEventImpl(QQuickPointerEvent *event)
emitted when the grab is stolen by a different Pointer Handler or Item.
*/
+QQuickPointerHandlerPrivate::QQuickPointerHandlerPrivate()
+ : grabPermissions(QQuickPointerHandler::CanTakeOverFromItems |
+ QQuickPointerHandler::CanTakeOverFromHandlersOfDifferentType |
+ QQuickPointerHandler::ApprovesTakeOverByAnything)
+ , enabled(true)
+ , active(false)
+ , targetExplicitlySet(false)
+ , hadKeepMouseGrab(false)
+ , hadKeepTouchGrab(false)
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h
index e2bcce8fc9..c600e42491 100644
--- a/src/quick/handlers/qquickpointerhandler_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p.h
@@ -51,8 +51,6 @@
// We mean it.
//
-#include "qevent.h"
-
#include <QtQuick/private/qquickevents_p_p.h>
#include <QtQuick/private/qquickitem_p.h>
@@ -60,6 +58,8 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcPointerHandlerDispatch)
+class QQuickPointerHandlerPrivate;
+
class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlParserStatus
{
Q_OBJECT
@@ -70,10 +70,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlP
Q_PROPERTY(QQuickItem * target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QQuickItem * parent READ parentItem CONSTANT)
Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged)
+ Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
public:
- explicit QQuickPointerHandler(QObject *parent = nullptr);
- virtual ~QQuickPointerHandler();
+ explicit QQuickPointerHandler(QQuickItem *parent = nullptr);
+ ~QQuickPointerHandler();
enum GrabPermission {
TakeOverForbidden = 0x0,
@@ -91,40 +92,47 @@ public:
Q_FLAG(GrabPermissions)
public:
- bool enabled() const { return m_enabled; }
+ bool enabled() const;
void setEnabled(bool enabled);
- bool active() const { return m_active; }
+ bool active() const;
QQuickItem *target() const;
void setTarget(QQuickItem *target);
- QQuickItem * parentItem() const { return static_cast<QQuickItem *>(QObject::parent()); }
+ QQuickItem * parentItem() const;
void handlePointerEvent(QQuickPointerEvent *event);
- GrabPermissions grabPermissions() const { return static_cast<GrabPermissions>(m_grabPermissions); }
+ GrabPermissions grabPermissions() const;
void setGrabPermissions(GrabPermissions grabPermissions);
+ qreal margin() const;
+ void setMargin(qreal pointDistanceThreshold);
+
Q_SIGNALS:
void enabledChanged();
void activeChanged();
void targetChanged();
- void grabChanged(QQuickEventPoint *point);
+ void marginChanged();
+ void grabChanged(QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
void grabPermissionChanged();
void canceled(QQuickEventPoint *point);
protected:
+ QQuickPointerHandler(QQuickPointerHandlerPrivate &dd, QQuickItem *parent);
+
void classBegin() override;
void componentComplete() override;
- QQuickPointerEvent *currentEvent() { return m_currentEvent; }
+ QQuickPointerEvent *currentEvent();
virtual bool wantsPointerEvent(QQuickPointerEvent *event);
+ virtual bool wantsEventPoint(QQuickEventPoint *point);
virtual void handlePointerEventImpl(QQuickPointerEvent *event);
void setActive(bool active);
virtual void onTargetChanged(QQuickItem *oldTarget) { Q_UNUSED(oldTarget); }
virtual void onActiveChanged() { }
- virtual void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point);
+ virtual void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
virtual bool canGrab(QQuickEventPoint *point);
virtual bool approveGrabTransition(QQuickEventPoint *point, QObject *proposedGrabber);
void setPassiveGrab(QQuickEventPoint *point, bool grab = true);
@@ -133,19 +141,11 @@ protected:
QPointF eventPos(const QQuickEventPoint *point) const;
bool parentContains(const QQuickEventPoint *point) const;
-private:
- QQuickPointerEvent *m_currentEvent;
- QQuickItem *m_target;
- bool m_enabled : 1;
- bool m_active : 1;
- bool m_targetExplicitlySet : 1;
- bool m_hadKeepMouseGrab : 1; // some handlers override target()->setKeepMouseGrab(); this remembers previous state
- bool m_hadKeepTouchGrab : 1; // some handlers override target()->setKeepTouchGrab(); this remembers previous state
- uint m_reserved : 19;
- uint8_t m_grabPermissions : 8;
-
friend class QQuickEventPoint;
+ friend class QQuickItemPrivate;
friend class QQuickWindowPrivate;
+
+ Q_DECLARE_PRIVATE(QQuickPointerHandler)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerHandler::GrabPermissions)
diff --git a/src/quick/handlers/qquickpointerhandler_p_p.h b/src/quick/handlers/qquickpointerhandler_p_p.h
new file mode 100644
index 0000000000..2ea4905643
--- /dev/null
+++ b/src/quick/handlers/qquickpointerhandler_p_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPOINTERHANDLER_P_H
+#define QQUICKPOINTERHANDLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qevent.h"
+
+#include <QtQuick/private/qquickevents_p_p.h>
+#include <QtQuick/private/qquickpointerhandler_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandlerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickPointerHandler)
+
+public:
+ static QQuickPointerHandlerPrivate* get(QQuickPointerHandler *q) { return q->d_func(); }
+ static const QQuickPointerHandlerPrivate* get(const QQuickPointerHandler *q) { return q->d_func(); }
+
+ QQuickPointerHandlerPrivate();
+
+ QQuickPointerEvent *currentEvent = nullptr;
+ QQuickItem *target = nullptr;
+ qreal m_margin = 0;
+ uint8_t grabPermissions : 8;
+ bool enabled : 1;
+ bool active : 1;
+ bool targetExplicitlySet : 1;
+ bool hadKeepMouseGrab : 1; // some handlers override target()->setKeepMouseGrab(); this remembers previous state
+ bool hadKeepTouchGrab : 1; // some handlers override target()->setKeepTouchGrab(); this remembers previous state
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPOINTERHANDLER_P_H
diff --git a/src/quick/handlers/qquickpointhandler.cpp b/src/quick/handlers/qquickpointhandler.cpp
index 7e2d40452c..3bc1c06a1a 100644
--- a/src/quick/handlers/qquickpointhandler.cpp
+++ b/src/quick/handlers/qquickpointhandler.cpp
@@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE
\qmltype PointHandler
\instantiates QQuickPointHandler
\inherits SinglePointHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
+ \ingroup qtquick-input-handlers
\brief Handler for reacting to a single touchpoint.
PointHandler can be used to show feedback about a touchpoint or the mouse
@@ -97,7 +97,7 @@ QT_BEGIN_NAMESPACE
\snippet pointerHandlers/pointHandler.qml 0
- Like all pointer handlers, a PointHandler has a \l target property, which
+ Like all input handlers, a PointHandler has a \l target property, which
may be used as a convenient place to put a point-tracking Item; but
PointHandler will not automatically manipulate the \c target item in any way.
You need to use bindings to make it react to the \l point.
@@ -114,16 +114,12 @@ QT_BEGIN_NAMESPACE
\sa MultiPointTouchArea
*/
-QQuickPointHandler::QQuickPointHandler(QObject *parent)
+QQuickPointHandler::QQuickPointHandler(QQuickItem *parent)
: QQuickSinglePointHandler(parent)
{
setIgnoreAdditionalPoints();
}
-QQuickPointHandler::~QQuickPointHandler()
-{
-}
-
bool QQuickPointHandler::wantsEventPoint(QQuickEventPoint *pt)
{
// On press, we want it unless a sibling of the same type also does.
@@ -143,11 +139,16 @@ void QQuickPointHandler::handleEventPoint(QQuickEventPoint *point)
{
switch (point->state()) {
case QQuickEventPoint::Pressed:
- setPassiveGrab(point);
- setActive(true);
+ if (point->pointerEvent()->asPointerTouchEvent() ||
+ (point->pointerEvent()->buttons() & acceptedButtons()) != Qt::NoButton) {
+ setPassiveGrab(point);
+ setActive(true);
+ }
break;
case QQuickEventPoint::Released:
- setActive(false);
+ if (point->pointerEvent()->asPointerTouchEvent() ||
+ (point->pointerEvent()->buttons() & acceptedButtons()) == Qt::NoButton)
+ setActive(false);
break;
default:
break;
diff --git a/src/quick/handlers/qquickpointhandler_p.h b/src/quick/handlers/qquickpointhandler_p.h
index 5babab0c4d..380ce1f90f 100644
--- a/src/quick/handlers/qquickpointhandler_p.h
+++ b/src/quick/handlers/qquickpointhandler_p.h
@@ -61,8 +61,7 @@ class Q_AUTOTEST_EXPORT QQuickPointHandler : public QQuickSinglePointHandler
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
public:
- explicit QQuickPointHandler(QObject *parent = 0);
- ~QQuickPointHandler();
+ explicit QQuickPointHandler(QQuickItem *parent = nullptr);
QVector2D translation() const;
diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp
index 9df20390e4..82e5b1b05d 100644
--- a/src/quick/handlers/qquicksinglepointhandler.cpp
+++ b/src/quick/handlers/qquicksinglepointhandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -48,8 +48,7 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)
\preliminary
\instantiates QQuickSinglePointHandler
\inherits PointerDeviceHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
\brief Abstract handler for single-point Pointer Events.
An intermediate class (not registered as a QML type)
@@ -59,10 +58,8 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)
Override handleEventPoint() to implement a single-point handler.
*/
-QQuickSinglePointHandler::QQuickSinglePointHandler(QObject *parent)
+QQuickSinglePointHandler::QQuickSinglePointHandler(QQuickItem *parent)
: QQuickPointerDeviceHandler(parent)
- , m_acceptedButtons(Qt::LeftButton)
- , m_ignoreAdditionalPoints(false)
{
}
@@ -71,7 +68,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
if (!QQuickPointerDeviceHandler::wantsPointerEvent(event))
return false;
if (event->device()->pointerType() != QQuickPointerDevice::Finger &&
- (event->buttons() & m_acceptedButtons) == 0 && (event->button() & m_acceptedButtons) == 0)
+ (event->buttons() & acceptedButtons()) == 0 && (event->button() & acceptedButtons()) == 0)
return false;
if (m_pointInfo.m_id) {
@@ -79,16 +76,23 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
// It's expected to be an update or a release.
// If we no longer want it, cancel the grab.
int candidatePointCount = 0;
+ bool missing = true;
QQuickEventPoint *point = nullptr;
int c = event->pointCount();
for (int i = 0; i < c; ++i) {
QQuickEventPoint *p = event->point(i);
+ const bool found = (p->pointId() == m_pointInfo.m_id);
+ if (found)
+ missing = false;
if (wantsEventPoint(p)) {
++candidatePointCount;
- if (p->pointId() == m_pointInfo.m_id)
+ if (found)
point = p;
}
}
+ if (missing)
+ qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << m_pointInfo.m_id
+ << "is missing from current event, but was neither canceled nor released";
if (point) {
if (candidatePointCount == 1 || (candidatePointCount > 1 && m_ignoreAdditionalPoints)) {
point->setAccepted();
@@ -97,8 +101,6 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
point->cancelAllGrabs(this);
}
} else {
- qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << m_pointInfo.m_id
- << "is missing from current event, but was neither canceled nor released";
return false;
}
} else {
@@ -115,7 +117,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
}
}
if (chosen && candidatePointCount == 1) {
- m_pointInfo.m_id = chosen->pointId();
+ setPointId(chosen->pointId());
chosen->setAccepted();
}
}
@@ -127,64 +129,28 @@ void QQuickSinglePointHandler::handlePointerEventImpl(QQuickPointerEvent *event)
QQuickPointerDeviceHandler::handlePointerEventImpl(event);
QQuickEventPoint *currentPoint = event->pointById(m_pointInfo.m_id);
Q_ASSERT(currentPoint);
- if (!m_pointInfo.m_id || !currentPoint->isAccepted()) {
+ m_pointInfo.reset(currentPoint);
+ handleEventPoint(currentPoint);
+ if (currentPoint->state() == QQuickEventPoint::Released && (event->buttons() & acceptedButtons()) == Qt::NoButton) {
+ setExclusiveGrab(currentPoint, false);
reset();
- } else {
- if (event->asPointerTouchEvent()) {
- QQuickEventTouchPoint *tp = static_cast<QQuickEventTouchPoint *>(currentPoint);
- m_pointInfo.m_uniqueId = tp->uniqueId();
- m_pointInfo.m_rotation = tp->rotation();
- m_pointInfo.m_pressure = tp->pressure();
- m_pointInfo.m_ellipseDiameters = tp->ellipseDiameters();
- } else if (event->asPointerTabletEvent()) {
- // TODO
- } else {
- m_pointInfo.m_uniqueId = event->device()->uniqueId();
- m_pointInfo.m_rotation = 0;
- m_pointInfo.m_pressure = event->buttons() ? 1 : 0;
- m_pointInfo.m_ellipseDiameters = QSizeF();
- }
- m_pointInfo.m_position = currentPoint->position();
- m_pointInfo.m_scenePosition = currentPoint->scenePosition();
- if (currentPoint->state() == QQuickEventPoint::Updated)
- m_pointInfo.m_velocity = currentPoint->velocity();
- handleEventPoint(currentPoint);
- switch (currentPoint->state()) {
- case QQuickEventPoint::Pressed:
- m_pointInfo.m_pressPosition = currentPoint->position();
- m_pointInfo.m_scenePressPosition = currentPoint->scenePosition();
- m_pointInfo.m_pressedButtons = event->buttons();
- break;
- case QQuickEventPoint::Released:
- setExclusiveGrab(currentPoint, false);
- reset();
- break;
- default:
- m_pointInfo.m_pressedButtons = event->buttons();
- break;
- }
- emit pointChanged();
}
+ emit pointChanged();
}
-bool QQuickSinglePointHandler::wantsEventPoint(QQuickEventPoint *point)
-{
- return parentContains(point);
-}
-
-void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)
+void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point)
{
if (grabber != this)
return;
- switch (stateChange) {
+ switch (transition) {
case QQuickEventPoint::GrabExclusive:
m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
setActive(true);
- QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);
+ QQuickPointerHandler::onGrabChanged(grabber, transition, point);
break;
case QQuickEventPoint::GrabPassive:
m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
- QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);
+ QQuickPointerHandler::onGrabChanged(grabber, transition, point);
break;
case QQuickEventPoint::OverrideGrabPassive:
return; // don't emit
@@ -193,11 +159,10 @@ void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQui
case QQuickEventPoint::CancelGrabPassive:
case QQuickEventPoint::CancelGrabExclusive:
// the grab is lost or relinquished, so the point is no longer relevant
- QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);
+ QQuickPointerHandler::onGrabChanged(grabber, transition, point);
reset();
break;
}
- emit singlePointGrabChanged();
}
void QQuickSinglePointHandler::setIgnoreAdditionalPoints(bool v)
@@ -212,42 +177,9 @@ void QQuickSinglePointHandler::moveTarget(QPointF pos, QQuickEventPoint *point)
m_pointInfo.m_position = target()->mapFromScene(m_pointInfo.m_scenePosition);
}
-/*!
- \qmlproperty int QtQuick::SinglePointHandler::acceptedButtons
-
- The mouse buttons which can activate this Pointer Handler.
-
- By default, this property is set to \l {QtQuick::MouseEvent::button} {Qt.LeftButton}.
- It can be set to an OR combination of mouse buttons, and will ignore events
- from other buttons.
-
- For example, a control could be made to respond to left and right clicks
- in different ways, with two handlers:
-
- \qml
- Item {
- TapHandler {
- onTapped: console.log("left clicked")
- }
- TapHandler {
- acceptedButtons: Qt.RightButton
- onTapped: console.log("right clicked")
- }
- }
- \endqml
-
- \note Tapping on a touchscreen or tapping the stylus on a graphics tablet
- emulates clicking the left mouse button. This behavior can be altered via
- \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices} or
- \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes}.
-*/
-void QQuickSinglePointHandler::setAcceptedButtons(Qt::MouseButtons buttons)
+void QQuickSinglePointHandler::setPointId(int id)
{
- if (m_acceptedButtons == buttons)
- return;
-
- m_acceptedButtons = buttons;
- emit acceptedButtonsChanged();
+ m_pointInfo.m_id = id;
}
void QQuickSinglePointHandler::reset()
@@ -264,213 +196,4 @@ void QQuickSinglePointHandler::reset()
handled, this object is reset to default values (all coordinates are 0).
*/
-/*!
- \qmltype HandlerPoint
- \instantiates QQuickHandlerPoint
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
- \brief An event point.
-
- A QML representation of a QQuickEventPoint.
-
- It's possible to make bindings to properties of a \l SinglePointHandler's
- current point. For example:
-
- \snippet pointerHandlers/dragHandlerNullTarget.qml 0
-
- The point is kept up-to-date when the DragHandler is actively responding to
- an EventPoint; but when the point is released, or the current point is
- being handled by a different handler, \c position.x and \c position.y are 0.
-
- \note This is practically identical to QtQuick::EventPoint; however an
- EventPoint is a long-lived QObject which is invalidated between gestures
- and reused for subsequent event deliveries. Continuous bindings to its
- properties are not possible, and an individual handler cannot rely on it
- outside the period when that point is part of an active gesture which that
- handler is handling. HandlerPoint is a Q_GADGET that the handler owns.
- This allows you to make lifetime bindings to its properties.
-
- \sa SinglePointHandler::point
-*/
-
-QQuickHandlerPoint::QQuickHandlerPoint()
- : m_id(0)
- , m_rotation(0)
- , m_pressure(0)
-{}
-
-void QQuickHandlerPoint::reset()
-{
- m_id = 0;
- m_uniqueId = QPointingDeviceUniqueId();
- m_position = QPointF();
- m_scenePosition = QPointF();
- m_pressPosition = QPointF();
- m_scenePressPosition = QPointF();
- m_sceneGrabPosition = QPointF();
- m_velocity = QVector2D();
- m_rotation = 0;
- m_pressure = 0;
- m_ellipseDiameters = QSizeF();
- m_pressedButtons = Qt::NoButton;
-}
-
-/*!
- \readonly
- \qmlproperty int QtQuick::HandlerPoint::id
- \brief The ID number of the point
-
- During a touch gesture, from the time that the first finger is pressed
- until the last finger is released, each touchpoint will have a unique ID
- number. Likewise, if input from multiple devices occurs (for example
- simultaneous mouse and touch presses), all the current event points from
- all the devices will have unique IDs.
-
- \note Do not assume that id numbers start at zero or that they are
- sequential. Such an assumption is often false due to the way the underlying
- drivers work.
-
- \sa QTouchEvent::TouchPoint::id
-*/
-
-/*!
- \readonly
- \qmlproperty PointingDeviceUniqueId QtQuick::HandlerPoint::uniqueId
- \brief The unique ID of the point, if any
-
- This is normally empty, because touchscreens cannot uniquely identify fingers.
-
- On some types of touchscreens, especially those using TUIO drivers,
- it's possible to use recognizable physical tokens (fiducial objects)
- in addition to fingers. So if this point is a touch point, and
- uniqueId is set, it is the identifier for such an object.
-
- On a graphics tablet, each type of stylus or other tool often has a unique
- ID or serial number, which can be useful to respond in different ways to
- different tools.
-
- Interpreting the contents of this ID requires knowledge of the hardware and
- drivers in use.
-
- \sa QTabletEvent::uniqueId, QtQuick::TouchPoint::uniqueId, QtQuick::EventTouchPoint::uniqueId
-*/
-
-/*!
- \readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::position
- \brief The position within the \c parent Item
-
- This is the position of the event point relative to the bounds of
- the \l {PointerHandler::parent} {parent}.
-*/
-
-/*!
- \readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::scenePosition
- \brief The position within the scene
-
- This is the position of the event point relative to the bounds of the Qt
- Quick scene (typically the whole window).
-*/
-
-/*!
- \readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::pressPosition
- \brief The pressed position within the \c parent Item
-
- This is the position at which this point was pressed, relative to the
- bounds of the \l {PointerHandler::parent} {parent}.
-*/
-
-/*!
- \readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::scenePressPosition
- \brief The pressed position within the scene
-
- This is the position at which this point was pressed, in the coordinate
- system of the \l {Qt Quick Scene Graph}{scene graph}.
-*/
-
-/*!
- \readonly
- \qmlproperty QPointF QtQuick::HandlerPoint::sceneGrabPosition
- \brief The grabbed position within the scene
-
- If this point has been grabbed by a Pointer Handler or an Item, it means
- that object has taken sole responsibility for handling the movement and the
- release if this point. In that case, this is the position at which the grab
- occurred, in the coordinate system of the \l {Qt Quick Scene Graph}{scene graph}.
-*/
-
-/*!
- \readonly
- \qmlproperty enum QtQuick::HandlerPoint::pressedButtons
- \brief Which mouse or stylus buttons are currently pressed
-
- \sa MouseArea::pressedButtons
-*/
-
-/*!
- \readonly
- \qmlproperty QVector2D QtQuick::HandlerPoint::velocity
- \brief A vector representing the average speed and direction of movement
-
- This is a velocity vector pointing in the direction of movement, in logical
- pixels per second. It has x and y components, at least one of which will be
- nonzero when this point is in motion. It holds the average recent velocity:
- how fast and in which direction the event point has been moving recently.
-
- \sa QtQuick::EventPoint::velocity, QtQuick::TouchPoint::velocity, QTouchEvent::TouchPoint::velocity
-*/
-
-/*!
- \readonly
- \qmlproperty qreal QtQuick::HandlerPoint::rotation
-
- This property holds the rotation angle of the stylus on a graphics tablet
- or the contact patch of a touchpoint on a touchscreen.
-
- It is valid only with certain tablet stylus devices and touchscreens that
- can measure the rotation angle. Otherwise, it will be zero.
-*/
-
-/*!
- \readonly
- \qmlproperty qreal QtQuick::HandlerPoint::pressure
-
- This property tells how hard the user is pressing the stylus on a graphics
- tablet or the finger against a touchscreen, in the range from \c 0 (no
- measurable pressure) to \c 1.0 (maximum pressure which the device can
- measure).
-
- It is valid only with certain tablets and touchscreens that can measure
- pressure. Otherwise, it will be zero.
-*/
-
-/*!
- \readonly
- \qmlproperty size QtQuick::HandlerPoint::ellipseDiameters
-
- This property holds the diameters of the contact patch, if the event
- comes from a touchpoint and the device provides this information.
-
- A touchpoint is modeled as an elliptical area where the finger is pressed
- against the touchscreen. (In fact, it could also be modeled as a bitmap;
- but in that case we expect an elliptical bounding estimate to be fitted to
- the contact patch before the event is sent.) The harder the user presses,
- the larger the contact patch; so, these diameters provide an alternate way
- of detecting pressure, in case the device does not include a separate
- pressure sensor. The ellipse is centered on \l scenePosition (\l position
- in the PointerHandler's Item's local coordinates). The \l rotation property
- provides the rotation of the ellipse, if known. It is expected that if the
- \l rotation is zero, the \l {QSize::height}{height} is the larger dimension
- (the major axis), because of the usual hand position, reaching upward or
- outward across the surface.
-
- If the contact patch is unknown, or the device is not a touchscreen,
- these values will be zero.
-
- \sa QtQuick::EventTouchPoint::ellipseDiameters, QtQuick::TouchPoint::ellipseDiameters, QTouchEvent::TouchPoint::ellipseDiameters
-*/
-
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquicksinglepointhandler_p.h b/src/quick/handlers/qquicksinglepointhandler_p.h
index 7606b4f7ba..b9e5b12224 100644
--- a/src/quick/handlers/qquicksinglepointhandler_p.h
+++ b/src/quick/handlers/qquicksinglepointhandler_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -51,104 +51,47 @@
// We mean it.
//
+#include "qquickhandlerpoint_p.h"
#include "qquickpointerdevicehandler_p.h"
QT_BEGIN_NAMESPACE
-class QQuickSinglePointHandler;
-
-class Q_QUICK_PRIVATE_EXPORT QQuickHandlerPoint {
- Q_GADGET
- Q_PROPERTY(int id READ id)
- Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId)
- Q_PROPERTY(QPointF position READ position)
- Q_PROPERTY(QPointF scenePosition READ scenePosition)
- Q_PROPERTY(QPointF pressPosition READ pressPosition)
- Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition)
- Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition)
- Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons)
- Q_PROPERTY(QVector2D velocity READ velocity)
- Q_PROPERTY(qreal rotation READ rotation)
- Q_PROPERTY(qreal pressure READ pressure)
- Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters)
-
-public:
- QQuickHandlerPoint();
-
- int id() const { return m_id; }
- Qt::MouseButtons pressedButtons() const { return m_pressedButtons; }
- QPointF pressPosition() const { return m_pressPosition; }
- QPointF scenePressPosition() const { return m_scenePressPosition; }
- QPointF sceneGrabPosition() const { return m_sceneGrabPosition; }
- QPointF position() const { return m_position; }
- QPointF scenePosition() const { return m_scenePosition; }
- QVector2D velocity() const { return m_velocity; }
- qreal rotation() const { return m_rotation; }
- qreal pressure() const { return m_pressure; }
- QSizeF ellipseDiameters() const { return m_ellipseDiameters; }
- QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; }
-
-private:
- void reset();
- int m_id;
- QPointingDeviceUniqueId m_uniqueId;
- Qt::MouseButtons m_pressedButtons;
- QPointF m_position;
- QPointF m_scenePosition;
- QPointF m_pressPosition;
- QPointF m_scenePressPosition;
- QPointF m_sceneGrabPosition;
- QVector2D m_velocity;
- qreal m_rotation;
- qreal m_pressure;
- QSizeF m_ellipseDiameters;
- friend class QQuickSinglePointHandler;
-};
-
class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointHandler : public QQuickPointerDeviceHandler
{
Q_OBJECT
- Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(QQuickHandlerPoint point READ point NOTIFY pointChanged)
public:
- explicit QQuickSinglePointHandler(QObject *parent = nullptr);
- virtual ~QQuickSinglePointHandler() { }
-
- Qt::MouseButtons acceptedButtons() const { return m_acceptedButtons; }
- void setAcceptedButtons(Qt::MouseButtons buttons);
+ explicit QQuickSinglePointHandler(QQuickItem *parent = nullptr);
QQuickHandlerPoint point() const { return m_pointInfo; }
Q_SIGNALS:
void pointChanged();
- void singlePointGrabChanged(); // QQuickPointerHandler::grabChanged signal can't be a property notifier here
- void acceptedButtonsChanged();
protected:
bool wantsPointerEvent(QQuickPointerEvent *event) override;
- virtual bool wantsEventPoint(QQuickEventPoint *point);
void handlePointerEventImpl(QQuickPointerEvent *event) override;
virtual void handleEventPoint(QQuickEventPoint *point) = 0;
QQuickEventPoint *currentPoint(QQuickPointerEvent *ev) { return ev->pointById(m_pointInfo.m_id); }
- void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override;
+ void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override;
void setIgnoreAdditionalPoints(bool v = true);
void moveTarget(QPointF pos, QQuickEventPoint *point);
+ void setPointId(int id);
+
private:
void reset();
private:
QQuickHandlerPoint m_pointInfo;
- Qt::MouseButtons m_acceptedButtons;
- bool m_ignoreAdditionalPoints : 1;
+ bool m_ignoreAdditionalPoints = false;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QQuickHandlerPoint)
QML_DECLARE_TYPE(QQuickSinglePointHandler)
#endif // QQUICKPOINTERSINGLEHANDLER_H
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 902ff0df10..e97722d6b7 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -55,8 +55,8 @@ int QQuickTapHandler::m_touchMultiTapDistanceSquared(-1);
\qmltype TapHandler
\instantiates QQuickTapHandler
\inherits SinglePointHandler
- \inqmlmodule Qt.labs.handlers
- \ingroup qtquick-handlers
+ \inqmlmodule QtQuick
+ \ingroup qtquick-input-handlers
\brief Handler for taps and clicks.
TapHandler is a handler for taps on a touchscreen or clicks on a mouse.
@@ -65,7 +65,7 @@ int QQuickTapHandler::m_touchMultiTapDistanceSquared(-1);
value is DragThreshold, which requires the press and release to be close
together in both space and time. In this case, DragHandler is able to
function using only a passive grab, and therefore does not interfere with
- event delivery to any other Items or Pointer Handlers. So the default
+ event delivery to any other Items or Input Handlers. So the default
gesturePolicy is useful when you want to modify behavior of an existing
control or Item by adding a TapHandler with bindings and/or JavaScript
callbacks.
@@ -84,13 +84,8 @@ int QQuickTapHandler::m_touchMultiTapDistanceSquared(-1);
\sa MouseArea
*/
-QQuickTapHandler::QQuickTapHandler(QObject *parent)
+QQuickTapHandler::QQuickTapHandler(QQuickItem *parent)
: QQuickSinglePointHandler(parent)
- , m_pressed(false)
- , m_gesturePolicy(DragThreshold)
- , m_tapCount(0)
- , m_longPressThreshold(-1)
- , m_lastTapTimestamp(0.0)
{
if (m_mouseMultiClickDistanceSquared < 0) {
m_multiTapInterval = qApp->styleHints()->mouseDoubleClickInterval() / 1000.0;
@@ -103,11 +98,7 @@ QQuickTapHandler::QQuickTapHandler(QObject *parent)
}
}
-QQuickTapHandler::~QQuickTapHandler()
-{
-}
-
-static bool dragOverThreshold(QQuickEventPoint *point)
+static bool dragOverThreshold(const QQuickEventPoint *point)
{
QPointF delta = point->scenePosition() - point->scenePressPosition();
return (QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point) ||
@@ -121,6 +112,11 @@ bool QQuickTapHandler::wantsEventPoint(QQuickEventPoint *point)
// (e.g. DragHandler) gets a chance to take over.
// Don't forget to emit released in case of a cancel.
bool ret = false;
+ bool overThreshold = dragOverThreshold(point);
+ if (overThreshold) {
+ m_longPressTimer.stop();
+ m_holdTimer.invalidate();
+ }
switch (point->state()) {
case QQuickEventPoint::Pressed:
case QQuickEventPoint::Released:
@@ -129,7 +125,7 @@ bool QQuickTapHandler::wantsEventPoint(QQuickEventPoint *point)
case QQuickEventPoint::Updated:
switch (m_gesturePolicy) {
case DragThreshold:
- ret = !dragOverThreshold(point);
+ ret = !overThreshold;
break;
case WithinBounds:
ret = parentContains(point);
@@ -209,19 +205,6 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event)
}
/*!
- \qmlsignal QtQuick::TapHandler::tapped()
-
- This signal is emitted when the pointer device taps the item.
- */
-
-/*!
- \qmlsignal QtQuick::TapHandler::longPressed()
-
- This signal is emitted when a press occurs that is longer than the
- \l {TapHandler::longPressThreshold} {long press threshold}.
- */
-
-/*!
\qmlproperty enumeration QtQuick::TapHandler::gesturePolicy
The spatial constraint for a tap or long press gesture to be recognized,
@@ -237,12 +220,12 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event)
threshold (QStyleHints::startDragDistance), the tap gesture is
canceled, even if the button or finger is still pressed. This policy
can be useful whenever TapHandler needs to cooperate with other
- pointer handlers (for example \l DragHandler) or event-handling Items
+ input handlers (for example \l DragHandler) or event-handling Items
(for example QtQuick Controls), because in this case TapHandler
will not take the exclusive grab, but merely a passive grab.
\value TapHandler.WithinBounds
- If the event point leaves the bounds of the \l target item, the tap
+ If the event point leaves the bounds of the \l parent Item, the tap
gesture is canceled. The TapHandler will take the exclusive grab on
press, but will release the grab as soon as the boundary constraint
is no longer satisfied.
@@ -250,7 +233,7 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event)
\value TapHandler.ReleaseWithinBounds
At the time of release (the mouse button is released or the finger
is lifted), if the event point is outside the bounds of the
- \l target item, a tap gesture is not recognized. This corresponds to
+ \l parent Item, a tap gesture is not recognized. This corresponds to
typical behavior for button widgets: you can cancel a click by
dragging outside the button, and you can also change your mind by
dragging back inside the button before release. Note that it's
@@ -308,12 +291,12 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi
else
m_tapCount = 1;
qCDebug(lcTapHandler) << objectName() << "tapped" << m_tapCount << "times";
- emit tapped();
+ emit tapped(point);
emit tapCountChanged();
if (m_tapCount == 1)
- emit singleTapped();
+ emit singleTapped(point);
else if (m_tapCount == 2)
- emit doubleTapped();
+ emit doubleTapped(point);
m_lastTapTimestamp = ts;
m_lastTapPos = point->scenePosition();
} else {
@@ -330,10 +313,10 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi
}
}
-void QQuickTapHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)
+void QQuickTapHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point)
{
- QQuickSinglePointHandler::onGrabChanged(grabber, stateChange, point);
- bool isCanceled = stateChange == QQuickEventPoint::CancelGrabExclusive || stateChange == QQuickEventPoint::CancelGrabPassive;
+ QQuickSinglePointHandler::onGrabChanged(grabber, transition, point);
+ bool isCanceled = transition == QQuickEventPoint::CancelGrabExclusive || transition == QQuickEventPoint::CancelGrabPassive;
if (grabber == this && (isCanceled || point->state() == QQuickEventPoint::Released))
setPressed(false, isCanceled, point);
}
@@ -387,23 +370,45 @@ void QQuickTapHandler::updateTimeHeld()
*/
/*!
- \qmlsignal TapHandler::singleTapped
+ \qmlsignal QtQuick::TapHandler::tapped
+
+ This signal is emitted each time the \l parent Item is tapped.
+
+ That is, if you press and release a touchpoint or button within a time
+ period less than \l longPressThreshold, while any movement does not exceed
+ the drag threshold, then the \c tapped signal will be emitted at the time
+ of release.
+*/
+
+/*!
+ \qmlsignal QtQuick::TapHandler::singleTapped
\since 5.11
- This signal is emitted when the \l target is tapped once. After an amount
- of time greater than QStyleHints::mouseDoubleClickInterval, it can be
- tapped again; but if the time until the next tap is less, \l tapCount
- will increase.
+ This signal is emitted when the \l parent Item is tapped once.
+ After an amount of time greater than QStyleHints::mouseDoubleClickInterval,
+ it can be tapped again; but if the time until the next tap is less,
+ \l tapCount will increase.
*/
/*!
- \qmlsignal TapHandler::doubleTapped
+ \qmlsignal QtQuick::TapHandler::doubleTapped
\since 5.11
- This signal is emitted when the \l target is tapped twice within a short
- span of time (QStyleHints::mouseDoubleClickInterval) and distance
+ This signal is emitted when the \l parent Item is tapped twice within a
+ short span of time (QStyleHints::mouseDoubleClickInterval) and distance
(QPlatformTheme::MouseDoubleClickDistance or
- QPlatformTheme::TouchDoubleTapDistance). This signal always occurs
- after singleTapped, tapped and tapCountChanged.
+ QPlatformTheme::TouchDoubleTapDistance). This signal always occurs after
+ \l singleTapped, \l tapped, and \l tapCountChanged.
*/
+
+/*!
+ \qmlsignal QtQuick::TapHandler::longPressed
+
+ This signal is emitted when the \l parent Item is pressed and held for a
+ time period greater than \l longPressThreshold. That is, if you press and
+ hold a touchpoint or button, while any movement does not exceed the drag
+ threshold, then the \c longPressed signal will be emitted at the time that
+ \l timeHeld exceeds \l longPressThreshold.
+*/
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index b7c1895926..6ec5d55227 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -75,8 +75,7 @@ public:
};
Q_ENUM(GesturePolicy)
- explicit QQuickTapHandler(QObject *parent = nullptr);
- ~QQuickTapHandler();
+ explicit QQuickTapHandler(QQuickItem *parent = nullptr);
bool isPressed() const { return m_pressed; }
@@ -95,13 +94,13 @@ Q_SIGNALS:
void timeHeldChanged();
void longPressThresholdChanged();
void gesturePolicyChanged();
- void tapped();
- void singleTapped();
- void doubleTapped();
+ void tapped(QQuickEventPoint *eventPoint);
+ void singleTapped(QQuickEventPoint *eventPoint);
+ void doubleTapped(QQuickEventPoint *eventPoint);
void longPressed();
protected:
- void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override;
+ void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override;
void timerEvent(QTimerEvent *event) override;
bool wantsEventPoint(QQuickEventPoint *point) override;
void handleEventPoint(QQuickEventPoint *point) override;
@@ -113,14 +112,14 @@ private:
void updateTimeHeld();
private:
- bool m_pressed;
- GesturePolicy m_gesturePolicy;
- int m_tapCount;
- int m_longPressThreshold;
- QBasicTimer m_longPressTimer;
- QElapsedTimer m_holdTimer;
QPointF m_lastTapPos;
- qreal m_lastTapTimestamp;
+ qreal m_lastTapTimestamp = 0;
+ QElapsedTimer m_holdTimer;
+ QBasicTimer m_longPressTimer;
+ int m_tapCount = 0;
+ int m_longPressThreshold = -1;
+ GesturePolicy m_gesturePolicy = GesturePolicy::DragThreshold;
+ bool m_pressed = false;
static qreal m_multiTapInterval;
static int m_mouseMultiClickDistanceSquared;
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index eee64c9663..06dddabb65 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -735,7 +735,7 @@ void QQuickCanvasItem::updatePolish()
for (auto it = animationCallbacks.cbegin(), end = animationCallbacks.cend(); it != end; ++it) {
function = it.value().value();
- jsCall->args[0] = QV4::Primitive::fromUInt32(QDateTime::currentMSecsSinceEpoch() / 1000);
+ jsCall->args[0] = QV4::Value::fromUInt32(QDateTime::currentMSecsSinceEpoch() / 1000);
function->call(jsCall);
}
}
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 2c115f4d3c..32336b5baf 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -563,6 +563,8 @@ struct QQuickJSContext2D : public QV4::Object
static QV4::ReturnedValue method_set_lineWidth(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_set_miterLimit(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+ static QV4::ReturnedValue method_set_lineDashOffset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+ static QV4::ReturnedValue method_get_lineDashOffset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_get_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_set_shadowBlur(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
@@ -596,7 +598,7 @@ public:
static QV4::Heap::QQuickJSContext2DPrototype *create(QV4::ExecutionEngine *engine)
{
QV4::Scope scope(engine);
- QV4::Scoped<QQuickJSContext2DPrototype> o(scope, engine->memoryManager->allocObject<QQuickJSContext2DPrototype>());
+ QV4::Scoped<QQuickJSContext2DPrototype> o(scope, engine->memoryManager->allocate<QQuickJSContext2DPrototype>());
o->defineDefaultProperty(QStringLiteral("quadraticCurveTo"), method_quadraticCurveTo, 0);
o->defineDefaultProperty(QStringLiteral("restore"), method_restore, 0);
@@ -641,6 +643,8 @@ public:
o->defineDefaultProperty(QStringLiteral("createLinearGradient"), method_createLinearGradient, 0);
o->defineDefaultProperty(QStringLiteral("strokeRect"), method_strokeRect, 0);
o->defineDefaultProperty(QStringLiteral("closePath"), method_closePath, 0);
+ o->defineDefaultProperty(QStringLiteral("setLineDash"), method_setLineDash, 0);
+ o->defineDefaultProperty(QStringLiteral("getLineDash"), method_getLineDash, 0);
o->defineAccessorProperty(QStringLiteral("canvas"), QQuickJSContext2DPrototype::method_get_canvas, nullptr);
return o->d();
@@ -690,6 +694,8 @@ public:
static QV4::ReturnedValue method_createImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_getImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
static QV4::ReturnedValue method_putImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+ static QV4::ReturnedValue method_setLineDash(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
+ static QV4::ReturnedValue method_getLineDash(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
};
@@ -908,8 +914,8 @@ struct QQuickJSContext2DPixelData : public QV4::Object
V4_OBJECT2(QQuickJSContext2DPixelData, QV4::Object)
V4_NEEDS_DESTROY
- static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty);
- static bool putIndexed(QV4::Managed *m, uint index, const QV4::Value &value);
+ static QV4::ReturnedValue virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty);
+ static bool virtualPut(QV4::Managed *m, QV4::PropertyKey id, const QV4::Value &value, Value *receiver);
static QV4::ReturnedValue proto_get_length(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc);
};
@@ -938,7 +944,7 @@ struct QQuickJSContext2DImageData : public QV4::Object
void QV4::Heap::QQuickJSContext2DImageData::init()
{
Object::init();
- pixelData = QV4::Primitive::undefinedValue();
+ pixelData = QV4::Value::undefinedValue();
QV4::Scope scope(internalClass->engine);
QV4::ScopedObject o(scope, this);
@@ -954,19 +960,19 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionE
{
QV4::Scope scope(v4);
QQuickContext2DEngineData *ed = engineData(scope.engine);
- QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, scope.engine->memoryManager->allocObject<QQuickJSContext2DPixelData>());
+ QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, scope.engine->memoryManager->allocate<QQuickJSContext2DPixelData>());
QV4::ScopedObject p(scope, ed->pixelArrayProto.value());
- pixelData->setPrototype(p);
+ pixelData->setPrototypeOf(p);
if (image.isNull()) {
*pixelData->d()->image = QImage(w, h, QImage::Format_ARGB32);
pixelData->d()->image->fill(0x00000000);
} else {
- Q_ASSERT(image.width()== qRound(w * image.devicePixelRatio()) && image.height() == qRound(h * image.devicePixelRatio()));
+ Q_ASSERT(image.width()== qRound(w * image.devicePixelRatioF()) && image.height() == qRound(h * image.devicePixelRatioF()));
*pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32);
}
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, scope.engine->memoryManager->allocObject<QQuickJSContext2DImageData>());
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, scope.engine->memoryManager->allocate<QQuickJSContext2DImageData>());
imageData->d()->pixelData = pixelData.asReturnedValue();
return imageData.asReturnedValue();
}
@@ -1406,7 +1412,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(const QV4::FunctionOb
QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());
+ QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
if (value->as<Object>()) {
QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
@@ -1461,7 +1467,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(const QV4::FunctionObj
QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());
+ QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
if ((value->isString() && value->toQString() == QLatin1String("WindingFill"))
|| (value->isInt32() && value->integerValue() == Qt::WindingFill)) {
@@ -1515,7 +1521,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(const QV4::Function
QV4::Scoped<QQuickJSContext2D> r(scope, thisObject->as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());
+ QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
if (value->as<Object>()) {
QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
@@ -1582,9 +1588,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(const
}
QQuickContext2DEngineData *ed = engineData(scope.engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocObject<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());
QV4::ScopedObject p(scope, ed->gradientProto.value());
- gradient->setPrototype(p);
+ gradient->setPrototypeOf(p);
*gradient->d()->brush = QLinearGradient(x0, y0, x1, y1);
RETURN_RESULT(*gradient);
}
@@ -1634,9 +1640,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(const
QQuickContext2DEngineData *ed = engineData(scope.engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocObject<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());
QV4::ScopedObject p(scope, ed->gradientProto.value());
- gradient->setPrototype(p);
+ gradient->setPrototypeOf(p);
*gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r1, QPointF(x0, y0), r0);
RETURN_RESULT(*gradient);
}
@@ -1678,9 +1684,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(cons
QQuickContext2DEngineData *ed = engineData(scope.engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocObject<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());
QV4::ScopedObject p(scope, ed->gradientProto.value());
- gradient->setPrototype(p);
+ gradient->setPrototypeOf(p);
*gradient->d()->brush = QConicalGradient(x, y, angle);
RETURN_RESULT(*gradient);
}
@@ -1738,7 +1744,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(const QV4::F
CHECK_CONTEXT(r)
if (argc >= 2) {
- QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->allocObject<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>());
QColor color = scope.engine->toVariant(argv[0], qMetaTypeId<QColor>()).value<QColor>();
if (color.isValid()) {
@@ -1963,6 +1969,122 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(const QV4::FunctionO
RETURN_UNDEFINED();
}
+/*!
+ \qmlmethod array QtQuick::Context2D::getLineDash()
+ \since QtQuick 2.11
+ Returns an array of qreals representing the dash pattern of the line.
+
+ \sa setLineDash()
+ */
+QV4::ReturnedValue QQuickJSContext2DPrototype::method_getLineDash(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
+{
+ QV4::Scope scope(b);
+ QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
+ CHECK_CONTEXT(r)
+
+ const QVector<qreal> pattern = r->d()->context->state.lineDash;
+ QV4::ScopedArrayObject array(scope, scope.engine->newArrayObject(pattern.size()));
+ array->arrayReserve(pattern.size());
+ for (int i = 0; i < pattern.size(); i++)
+ array->put(i, QV4::Value::fromDouble(pattern[i]));
+
+ array->setArrayLengthUnchecked(pattern.size());
+
+ RETURN_RESULT(*array);
+}
+
+/*!
+ \qmlmethod QtQuick::Context2D::setLineDash(array pattern)
+ \since QtQuick 2.11
+ Sets the dash pattern to the given pattern
+
+ \a pattern a list of numbers that specifies distances to alternately draw a line and a gap.
+
+ If the number of elements in the array is odd, the elements of the array get copied
+ and concatenated. For example, [5, 15, 25] will become [5, 15, 25, 5, 15, 25].
+
+ \table 100%
+ \row
+ \li \inlineimage qml-item-canvas-lineDash.png
+ \li
+ \code
+ var space = 4
+ ctx.setLineDash([1, space, 3, space, 9, space, 27, space, 9, space])
+ ...
+ ctx.stroke();
+ \endcode
+ \endtable
+
+ \sa setLineDash
+ */
+QV4::ReturnedValue QQuickJSContext2DPrototype::method_setLineDash(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
+{
+ QV4::Scope scope(b);
+ QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
+ CHECK_CONTEXT_SETTER(r)
+
+ if (!argc)
+ RETURN_UNDEFINED();
+
+ QV4::ScopedArrayObject array(scope, argv[0]);
+ if (!array)
+ RETURN_UNDEFINED();
+
+ QV4::ScopedValue v(scope);
+ const uint arrayLength = array->getLength();
+ QVector<qreal> dashes;
+ dashes.reserve(arrayLength);
+ for (uint i = 0; i < arrayLength; ++i) {
+ v = array->get(i);
+ const double number = v->toNumber();
+
+ if (!qt_is_finite(number) || (number < 0))
+ RETURN_UNDEFINED();
+
+ dashes.append(v->toNumber());
+ }
+ if (dashes.size() % 2 != 0) {
+ dashes += dashes;
+ }
+
+ r->d()->context->state.lineDash = dashes;
+ r->d()->context->buffer()->setLineDash(dashes);
+
+ RETURN_UNDEFINED();
+}
+
+/*!
+ \qmlproperty real QtQuick::Context2D::lineDashOffset
+ \since QtQuick 2.11
+
+ Holds the current line dash offset
+ The default line dash ofset value is 0
+ */
+QV4::ReturnedValue QQuickJSContext2D::method_get_lineDashOffset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int)
+{
+ QV4::Scope scope(b);
+ QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
+ CHECK_CONTEXT(r)
+
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.lineDashOffset));
+}
+
+QV4::ReturnedValue QQuickJSContext2D::method_set_lineDashOffset(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
+{
+ QV4::Scope scope(b);
+ QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
+ CHECK_CONTEXT_SETTER(r)
+
+ const qreal offset = argc ? argv[0].toNumber() : -1;
+
+ if (qt_is_finite(offset) && offset != r->d()->context->state.lineDashOffset) {
+ r->d()->context->state.lineDashOffset = offset;
+ r->d()->context->buffer()->setLineDashOffset(offset);
+ }
+ RETURN_UNDEFINED();
+}
+
+
// shadows
/*!
\qmlproperty real QtQuick::Context2D::shadowBlur
@@ -2096,7 +2218,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(const QV4::FunctionObject
QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Primitive::undefinedValue());
+ QV4::ScopedValue value(scope, argc ? argv[0] : QV4::Value::undefinedValue());
r->d()->context->beginPath();
QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, value);
if (!!qobjectWrapper) {
@@ -2593,7 +2715,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(const QV4::F
bool pointInPath = false;
if (argc >= 2)
pointInPath = r->d()->context->isPointInPath(argv[0].toNumber(), argv[1].toNumber());
- RETURN_RESULT(QV4::Primitive::fromBoolean(pointInPath).asReturnedValue());
+ RETURN_RESULT(QV4::Value::fromBoolean(pointInPath).asReturnedValue());
}
QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawFocusRing(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int)
@@ -2652,7 +2774,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_font(const QV4::FunctionObject
QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert);
if (scope.engine->hasException)
RETURN_UNDEFINED();
QFont font = qt_font_from_string(s->toQString(), r->d()->context->state.font);
@@ -2704,7 +2826,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(const QV4::FunctionOb
QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert);
if (scope.engine->hasException)
RETURN_UNDEFINED();
QString textAlign = s->toQString();
@@ -2771,7 +2893,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(const QV4::Functio
QV4::Scope scope(b);
QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, argc ? argv[0] : QV4::Primitive::undefinedValue(), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert);
if (scope.engine->hasException)
RETURN_UNDEFINED();
QString textBaseline = s->toQString();
@@ -2858,7 +2980,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(const QV4::Fun
uint width = fm.width(argv[0].toQStringNoThrow());
QV4::ScopedObject tm(scope, scope.engine->newObject());
tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(),
- QV4::ScopedValue(scope, QV4::Primitive::fromDouble(width)));
+ QV4::ScopedValue(scope, QV4::Value::fromDouble(width)));
RETURN_RESULT(*tm);
}
RETURN_UNDEFINED();
@@ -3130,8 +3252,12 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(const QV4::Funct
RETURN_RESULT(QV4::Encode(r->d()->image->width() * r->d()->image->height() * 4));
}
-QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
+QV4::ReturnedValue QQuickJSContext2DPixelData::virtualGet(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty)
{
+ if (!id.isArrayIndex())
+ return QV4::Object::virtualGet(m, id, receiver, hasProperty);
+
+ uint index = id.asArrayIndex();
Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
QV4::ExecutionEngine *v4 = static_cast<const QQuickJSContext2DPixelData *>(m)->engine();
QV4::Scope scope(v4);
@@ -3156,19 +3282,24 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(const QV4::Managed *m,
return QV4::Encode(qAlpha(*pixel));
}
}
+
if (hasProperty)
*hasProperty = false;
return QV4::Encode::undefined();
}
-bool QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::Value &value)
+bool QQuickJSContext2DPixelData::virtualPut(QV4::Managed *m, QV4::PropertyKey id, const QV4::Value &value, QV4::Value *receiver)
{
+ if (!id.isArrayIndex())
+ return Object::virtualPut(m, id, value, receiver);
+
Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
QV4::ExecutionEngine *v4 = static_cast<QQuickJSContext2DPixelData *>(m)->engine();
QV4::Scope scope(v4);
if (scope.hasException())
return false;
+ uint index = id.asArrayIndex();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));
const int v = value.toInt32();
@@ -4303,6 +4434,7 @@ QQuickContext2DEngineData::QQuickContext2DEngineData(QV4::ExecutionEngine *v4)
proto->defineAccessorProperty(QStringLiteral("lineWidth"), QQuickJSContext2D::method_get_lineWidth, QQuickJSContext2D::method_set_lineWidth);
proto->defineAccessorProperty(QStringLiteral("textAlign"), QQuickJSContext2D::method_get_textAlign, QQuickJSContext2D::method_set_textAlign);
proto->defineAccessorProperty(QStringLiteral("shadowBlur"), QQuickJSContext2D::method_get_shadowBlur, QQuickJSContext2D::method_set_shadowBlur);
+ proto->defineAccessorProperty(QStringLiteral("lineDashOffset"), QQuickJSContext2D::method_get_lineDashOffset, QQuickJSContext2D::method_set_lineDashOffset);
contextPrototype = proto;
proto = scope.engine->newObject();
@@ -4366,6 +4498,10 @@ void QQuickContext2D::popState()
if (newState.shadowOffsetY != state.shadowOffsetY)
buffer()->setShadowOffsetY(newState.shadowOffsetY);
+
+ if (newState.lineDash != state.lineDash)
+ buffer()->setLineDash(newState.lineDash);
+
m_path = state.matrix.map(m_path);
state = newState;
m_path = state.matrix.inverted().map(m_path);
@@ -4399,9 +4535,9 @@ void QQuickContext2D::setV4Engine(QV4::ExecutionEngine *engine)
QQuickContext2DEngineData *ed = engineData(engine);
QV4::Scope scope(engine);
- QV4::Scoped<QQuickJSContext2D> wrapper(scope, engine->memoryManager->allocObject<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> wrapper(scope, engine->memoryManager->allocate<QQuickJSContext2D>());
QV4::ScopedObject p(scope, ed->contextPrototype.value());
- wrapper->setPrototype(p);
+ wrapper->setPrototypeOf(p);
wrapper->d()->context = this;
m_v4value = wrapper;
}
diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h
index 4cc07027b1..1ece6796f3 100644
--- a/src/quick/items/context2d/qquickcontext2d_p.h
+++ b/src/quick/items/context2d/qquickcontext2d_p.h
@@ -112,6 +112,8 @@ public:
LineWidth,
LineCap,
LineJoin,
+ LineDash,
+ LineDashOffset,
MiterLimit,
ShadowOffsetX,
ShadowOffsetY,
@@ -142,6 +144,7 @@ public:
, lineWidth(1)
, lineCap(Qt::FlatCap)
, lineJoin(Qt::MiterJoin)
+ , lineDashOffset(0)
, miterLimit(10)
, shadowOffsetX(0)
, shadowOffsetY(0)
@@ -170,6 +173,8 @@ public:
qreal lineWidth;
Qt::PenCapStyle lineCap;
Qt::PenJoinStyle lineJoin;
+ QVector<qreal> lineDash;
+ qreal lineDashOffset;
qreal miterLimit;
qreal shadowOffsetX;
qreal shadowOffsetY;
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
index 30895d9b0e..55ebbe907c 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
@@ -192,6 +192,10 @@ QPen QQuickContext2DCommandBuffer::makePen(const QQuickContext2D::State& state)
pen.setJoinStyle(state.lineJoin);
pen.setMiterLimit(state.miterLimit);
pen.setBrush(state.strokeStyle);
+ if (!state.lineDash.isEmpty()) {
+ pen.setDashPattern(state.lineDash);
+ }
+ pen.setDashOffset(state.lineDashOffset);
return pen;
}
@@ -361,6 +365,28 @@ void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& s
p->setPen(nPen);
break;
}
+ case QQuickContext2D::LineDash:
+ {
+ const qreal count = takeReal();
+ QVector<qreal> pattern;
+ pattern.reserve(count);
+ for (uint i = 0; i < count; i++) {
+ pattern.append(takeReal());
+ }
+ state.lineDash = pattern;
+ QPen nPen = p->pen();
+ nPen.setDashPattern(pattern);
+ p->setPen(nPen);
+ break;
+ }
+ case QQuickContext2D::LineDashOffset:
+ {
+ state.lineDashOffset = takeReal();
+ QPen nPen = p->pen();
+ nPen.setDashOffset(state.lineDashOffset);
+ p->setPen(nPen);
+ break;
+ }
case QQuickContext2D::MiterLimit:
{
state.miterLimit = takeMiterLimit();
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
index 2a1ac7304e..c3e844c929 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
@@ -201,6 +201,20 @@ public:
ints << join;
}
+ inline void setLineDash(const QVector<qreal> &pattern)
+ {
+ commands << QQuickContext2D::LineDash;
+ reals << pattern.length();
+ for (qreal r : pattern)
+ reals << r;
+ }
+
+ inline void setLineDashOffset( qreal offset)
+ {
+ commands << QQuickContext2D::LineDashOffset;
+ reals << offset;
+ }
+
inline void setMiterLimit( qreal limit)
{
commands << QQuickContext2D::MiterLimit;
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index 1acb3b5265..e649b5429d 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -122,9 +122,11 @@ qtConfig(quick-gridview) {
qtConfig(quick-itemview) {
HEADERS += \
+ $$PWD/qquickitemviewfxitem_p_p.h \
$$PWD/qquickitemview_p.h \
$$PWD/qquickitemview_p_p.h
SOURCES += \
+ $$PWD/qquickitemviewfxitem.cpp \
$$PWD/qquickitemview.cpp
}
@@ -142,6 +144,14 @@ qtConfig(quick-listview) {
$$PWD/qquicklistview.cpp
}
+qtConfig(quick-tableview) {
+ HEADERS += \
+ $$PWD/qquicktableview_p.h \
+ $$PWD/qquicktableview_p_p.h
+ SOURCES += \
+ $$PWD/qquicktableview.cpp
+}
+
qtConfig(quick-pathview) {
HEADERS += \
$$PWD/qquickpathview_p.h \
diff --git a/src/quick/items/qquickanchors_p.h b/src/quick/items/qquickanchors_p.h
index 931b963534..c7995cb7a8 100644
--- a/src/quick/items/qquickanchors_p.h
+++ b/src/quick/items/qquickanchors_p.h
@@ -108,6 +108,7 @@ public:
Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
};
Q_DECLARE_FLAGS(Anchors, Anchor)
+ Q_FLAG(Anchors)
QQuickAnchorLine left() const;
void setLeft(const QQuickAnchorLine &edge);
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 603d5a3120..18adb4e992 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -268,6 +268,16 @@ QT_BEGIN_NAMESPACE
Stops, then starts the sprite animation.
*/
+/*!
+ \qmlsignal QtQuick::AnimatedSprite::finished()
+ \since 5.12
+
+ This signal is emitted when the sprite has finished animating.
+
+ It is not emitted when running is set to \c false, nor for sprites whose
+ \l loops property is set to \c AnimatedSprite.Infinite.
+*/
+
QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
QQuickItem(*(new QQuickAnimatedSpritePrivate), parent)
{
@@ -806,6 +816,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node)
frameAt = 0;
d->m_running = false;
emit runningChanged(false);
+ emit finished();
maybeUpdate();
}
} else {
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index d7e60b909c..ff59591c9f 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -135,6 +135,8 @@ Q_SIGNALS:
void loopsChanged(int arg);
void currentFrameChanged(int arg);
+ Q_REVISION(12) void finished();
+
public Q_SLOTS:
void start();
void stop();
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index d4aba31e28..31c56b7cb7 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -642,6 +642,11 @@ QQuickPointerDevice *QQuickPointerDevice::touchDevice(const QTouchDevice *d)
return dev;
}
+const QTouchDevice *QQuickPointerDevice::qTouchDevice() const
+{
+ return g_touchDevices->key(const_cast<QQuickPointerDevice *>(this));
+}
+
QList<QQuickPointerDevice*> QQuickPointerDevice::touchDevices()
{
return g_touchDevices->values();
@@ -901,7 +906,7 @@ void QQuickEventPoint::setGrabberPointerHandler(QQuickPointerHandler *grabber, b
if (grabber) {
grabber->onGrabChanged(grabber, GrabExclusive, this);
for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) {
- if (passiveGrabber != grabber)
+ if (!passiveGrabber.isNull() && passiveGrabber != grabber)
passiveGrabber->onGrabChanged(grabber, OverrideGrabPassive, this);
}
}
@@ -1291,7 +1296,7 @@ QQuickPointerEvent *QQuickPointerMouseEvent::reset(QEvent *event)
Qt::TouchPointState state = Qt::TouchPointStationary;
switch (ev->type()) {
case QEvent::MouseButtonPress:
- m_mousePoint->clearPassiveGrabbers();
+ m_point->clearPassiveGrabbers();
Q_FALLTHROUGH();
case QEvent::MouseButtonDblClick:
state = Qt::TouchPointPressed;
@@ -1305,13 +1310,13 @@ QQuickPointerEvent *QQuickPointerMouseEvent::reset(QEvent *event)
default:
break;
}
- m_mousePoint->reset(state, ev->windowPos(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1
+ m_point->reset(state, ev->windowPos(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1
return this;
}
-void QQuickPointerMouseEvent::localize(QQuickItem *target)
+void QQuickSinglePointEvent::localize(QQuickItem *target)
{
- m_mousePoint->localizePosition(target);
+ m_point->localizePosition(target);
}
QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event)
@@ -1412,35 +1417,54 @@ QQuickPointerEvent *QQuickPointerNativeGestureEvent::reset(QEvent *event)
break;
}
quint64 deviceId = QTouchDevicePrivate::get(const_cast<QTouchDevice *>(ev->device()))->id; // a bit roundabout since QTouchDevice::mTouchDeviceId is protected
- m_gesturePoint->reset(state, ev->windowPos(), deviceId << 24, ev->timestamp());
+ m_point->reset(state, ev->windowPos(), deviceId << 24, ev->timestamp());
return this;
}
-
-void QQuickPointerNativeGestureEvent::localize(QQuickItem *target)
-{
- m_gesturePoint->localizePosition(target);
-}
#endif // QT_CONFIG(gestures)
-QQuickEventPoint *QQuickPointerMouseEvent::point(int i) const {
+QQuickEventPoint *QQuickSinglePointEvent::point(int i) const
+{
if (i == 0)
- return m_mousePoint;
+ return m_point;
return nullptr;
}
-QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const {
- if (i >= 0 && i < m_pointCount)
- return m_touchPoints.at(i);
- return nullptr;
+QQuickPointerEvent *QQuickPointerScrollEvent::reset(QEvent *event)
+{
+ m_event = static_cast<QInputEvent*>(event);
+ if (!event)
+ return this;
+#if QT_CONFIG(wheelevent)
+ if (event->type() == QEvent::Wheel) {
+ auto ev = static_cast<QWheelEvent*>(event);
+ m_device = QQuickPointerDevice::genericMouseDevice();
+ m_device->eventDeliveryTargets().clear();
+ // m_button = Qt::NoButton;
+ m_pressedButtons = ev->buttons();
+ m_angleDelta = QVector2D(ev->angleDelta());
+ m_pixelDelta = QVector2D(ev->pixelDelta());
+ m_phase = ev->phase();
+ m_synthSource = ev->source();
+ m_inverted = ev->inverted();
+
+ m_point->reset(Qt::TouchPointMoved, ev->posF(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1
+ }
+#endif
+ // TODO else if (event->type() == QEvent::Scroll) ...
+ return this;
}
-#if QT_CONFIG(gestures)
-QQuickEventPoint *QQuickPointerNativeGestureEvent::point(int i) const {
- if (i == 0)
- return m_gesturePoint;
+void QQuickPointerScrollEvent::localize(QQuickItem *target)
+{
+ m_point->localizePosition(target);
+}
+
+QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const
+{
+ if (i >= 0 && i < m_pointCount)
+ return m_touchPoints.at(i);
return nullptr;
}
-#endif // QT_CONFIG(gestures)
QQuickEventPoint::QQuickEventPoint(QQuickPointerEvent *parent)
: QObject(parent), m_pointId(0), m_exclusiveGrabber(nullptr), m_timestamp(0), m_pressTimestamp(0),
@@ -1454,17 +1478,19 @@ QQuickPointerEvent *QQuickEventPoint::pointerEvent() const
return static_cast<QQuickPointerEvent *>(parent());
}
-bool QQuickPointerMouseEvent::allPointsAccepted() const {
- return m_mousePoint->isAccepted();
+bool QQuickSinglePointEvent::allPointsAccepted() const
+{
+ return m_point->isAccepted();
}
-bool QQuickPointerMouseEvent::allUpdatedPointsAccepted() const {
- return m_mousePoint->state() == QQuickEventPoint::Pressed || m_mousePoint->isAccepted();
+bool QQuickSinglePointEvent::allUpdatedPointsAccepted() const
+{
+ return m_point->state() == QQuickEventPoint::Pressed || m_point->isAccepted();
}
-bool QQuickPointerMouseEvent::allPointsGrabbed() const
+bool QQuickSinglePointEvent::allPointsGrabbed() const
{
- return m_mousePoint->exclusiveGrabber() != nullptr;
+ return m_point->exclusiveGrabber() != nullptr;
}
QMouseEvent *QQuickPointerMouseEvent::asMouseEvent(const QPointF &localPos) const
@@ -1477,10 +1503,10 @@ QMouseEvent *QQuickPointerMouseEvent::asMouseEvent(const QPointF &localPos) cons
/*!
Returns the exclusive grabber of this event, if any, in a vector.
*/
-QVector<QObject *> QQuickPointerMouseEvent::exclusiveGrabbers() const
+QVector<QObject *> QQuickSinglePointEvent::exclusiveGrabbers() const
{
QVector<QObject *> result;
- if (QObject *grabber = m_mousePoint->exclusiveGrabber())
+ if (QObject *grabber = m_point->exclusiveGrabber())
result << grabber;
return result;
}
@@ -1488,17 +1514,18 @@ QVector<QObject *> QQuickPointerMouseEvent::exclusiveGrabbers() const
/*!
Remove all passive and exclusive grabbers of this event, without notifying.
*/
-void QQuickPointerMouseEvent::clearGrabbers() const {
- m_mousePoint->setGrabberItem(nullptr);
- m_mousePoint->clearPassiveGrabbers();
+void QQuickSinglePointEvent::clearGrabbers() const
+{
+ m_point->setGrabberItem(nullptr);
+ m_point->clearPassiveGrabbers();
}
/*!
Returns whether the given \a handler is the exclusive grabber of this event.
*/
-bool QQuickPointerMouseEvent::hasExclusiveGrabber(const QQuickPointerHandler *handler) const
+bool QQuickSinglePointEvent::hasExclusiveGrabber(const QQuickPointerHandler *handler) const
{
- return m_mousePoint->exclusiveGrabber() == handler;
+ return handler && (m_point->exclusiveGrabber() == handler);
}
bool QQuickPointerMouseEvent::isPressEvent() const
@@ -1526,7 +1553,8 @@ bool QQuickPointerMouseEvent::isReleaseEvent() const
return me && me->type() == QEvent::MouseButtonRelease;
}
-bool QQuickPointerTouchEvent::allPointsAccepted() const {
+bool QQuickPointerTouchEvent::allPointsAccepted() const
+{
for (int i = 0; i < m_pointCount; ++i) {
if (!m_touchPoints.at(i)->isAccepted())
return false;
@@ -1534,7 +1562,8 @@ bool QQuickPointerTouchEvent::allPointsAccepted() const {
return true;
}
-bool QQuickPointerTouchEvent::allUpdatedPointsAccepted() const {
+bool QQuickPointerTouchEvent::allUpdatedPointsAccepted() const
+{
for (int i = 0; i < m_pointCount; ++i) {
auto point = m_touchPoints.at(i);
if (point->state() != QQuickEventPoint::Pressed && !point->isAccepted())
@@ -1571,7 +1600,8 @@ QVector<QObject *> QQuickPointerTouchEvent::exclusiveGrabbers() const
Remove all passive and exclusive grabbers of all touchpoints in this event,
without notifying.
*/
-void QQuickPointerTouchEvent::clearGrabbers() const {
+void QQuickPointerTouchEvent::clearGrabbers() const
+{
for (auto point: m_touchPoints) {
point->setGrabberItem(nullptr);
point->clearPassiveGrabbers();
@@ -1629,7 +1659,8 @@ QVector<QPointF> QQuickPointerEvent::unacceptedPressedPointScenePositions() cons
If the touchpoint cannot be found, this returns nullptr.
Ownership of the event is NOT transferred to the caller.
*/
-QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickItem *relativeTo) const {
+QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickItem *relativeTo) const
+{
const QTouchEvent::TouchPoint *p = touchPointById(pointID);
if (!p)
return nullptr;
@@ -1669,33 +1700,6 @@ QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickIte
}
#if QT_CONFIG(gestures)
-/*!
- Returns the exclusive grabber of this event, if any, in a vector.
-*/
-QVector<QObject *> QQuickPointerNativeGestureEvent::exclusiveGrabbers() const
-{
- QVector<QObject *> result;
- if (QObject *grabber = m_gesturePoint->exclusiveGrabber())
- result << grabber;
- return result;
-}
-
-/*!
- Remove all passive and exclusive grabbers of this event, without notifying.
-*/
-void QQuickPointerNativeGestureEvent::clearGrabbers() const {
- m_gesturePoint->setGrabberItem(nullptr);
- m_gesturePoint->clearPassiveGrabbers();
-}
-
-/*!
- Returns whether the given \a handler is the exclusive grabber of this event.
-*/
-bool QQuickPointerNativeGestureEvent::hasExclusiveGrabber(const QQuickPointerHandler *handler) const
-{
- return m_gesturePoint->exclusiveGrabber() == handler;
-}
-
bool QQuickPointerNativeGestureEvent::isPressEvent() const
{
return type() == Qt::BeginNativeGesture;
@@ -1729,6 +1733,39 @@ qreal QQuickPointerNativeGestureEvent::value() const
#endif // QT_CONFIG(gestures)
/*!
+ Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads
+ which provide phase information, this is true when the fingers are placed
+ on the touchpad and scrolling begins. On other devices where this
+ information is not available, it remains false.
+*/
+bool QQuickPointerScrollEvent::isPressEvent() const
+{
+ return phase() == Qt::ScrollBegin;
+}
+
+/*!
+ Returns true when the scroll event has Qt::ScrollUpdate phase, or when the
+ phase is unknown. Some multi-touch-capable touchpads and trackpads provide
+ phase information; whereas ordinary mouse wheels and other types of
+ trackpads do not, and in such cases this is always true.
+*/
+bool QQuickPointerScrollEvent::isUpdateEvent() const
+{
+ return phase() == Qt::ScrollUpdate || phase() == Qt::NoScrollPhase;
+}
+
+/*!
+ Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads
+ which provide phase information, this is true when the fingers are lifted
+ from the touchpad. On other devices where this information is not
+ available, it remains false.
+*/
+bool QQuickPointerScrollEvent::isReleaseEvent() const
+{
+ return phase() == Qt::ScrollEnd;
+}
+
+/*!
\internal
Returns a pointer to the QQuickEventPoint which has the \a pointId as
\l {QQuickEventPoint::pointId}{pointId}.
@@ -1736,13 +1773,15 @@ qreal QQuickPointerNativeGestureEvent::value() const
\fn QQuickPointerEvent::pointById(int pointId) const
*/
-QQuickEventPoint *QQuickPointerMouseEvent::pointById(int pointId) const {
- if (m_mousePoint && pointId == m_mousePoint->pointId())
- return m_mousePoint;
+QQuickEventPoint *QQuickSinglePointEvent::pointById(int pointId) const
+{
+ if (m_point && pointId == m_point->pointId())
+ return m_point;
return nullptr;
}
-QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const {
+QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const
+{
auto it = std::find_if(m_touchPoints.constBegin(), m_touchPoints.constEnd(),
[pointId](const QQuickEventTouchPoint *tp) { return tp->pointId() == pointId; } );
if (it != m_touchPoints.constEnd())
@@ -1750,21 +1789,14 @@ QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const {
return nullptr;
}
-#if QT_CONFIG(gestures)
-QQuickEventPoint *QQuickPointerNativeGestureEvent::pointById(int pointId) const {
- if (m_gesturePoint && pointId == m_gesturePoint->pointId())
- return m_gesturePoint;
- return nullptr;
-}
-#endif
-
/*!
\internal
Returns a pointer to the original TouchPoint which has the same
\l {QTouchEvent::TouchPoint::id}{id} as \a pointId, if the original event is a
QTouchEvent, and if that point is found. Otherwise, returns nullptr.
*/
-const QTouchEvent::TouchPoint *QQuickPointerTouchEvent::touchPointById(int pointId) const {
+const QTouchEvent::TouchPoint *QQuickPointerTouchEvent::touchPointById(int pointId) const
+{
const QTouchEvent *ev = asTouchEvent();
if (!ev)
return nullptr;
@@ -1875,24 +1907,10 @@ QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const
return static_cast<QTouchEvent *>(m_event);
}
-#if QT_CONFIG(gestures)
-bool QQuickPointerNativeGestureEvent::allPointsAccepted() const {
- return m_gesturePoint->isAccepted();
-}
-
-bool QQuickPointerNativeGestureEvent::allUpdatedPointsAccepted() const {
- return m_gesturePoint->state() == QQuickEventPoint::Pressed || m_gesturePoint->isAccepted();
-}
-
-bool QQuickPointerNativeGestureEvent::allPointsGrabbed() const
-{
- return m_gesturePoint->exclusiveGrabber() != nullptr;
-}
-#endif // QT_CONFIG(gestures)
-
#ifndef QT_NO_DEBUG_STREAM
-Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *dev) {
+Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *dev)
+{
QDebugStateSaver saver(dbg);
dbg.nospace();
if (!dev) {
@@ -1914,7 +1932,8 @@ Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *
return dbg;
}
-Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerEvent *event) {
+Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerEvent *event)
+{
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg << "QQuickPointerEvent(";
@@ -1933,7 +1952,8 @@ Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerEvent *e
return dbg;
}
-Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickEventPoint *event) {
+Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickEventPoint *event)
+{
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg << "QQuickEventPoint(accepted:" << event->isAccepted()
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 4097845ec9..f3ce04d11e 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -69,6 +69,7 @@ class QQuickPointerMouseEvent;
#if QT_CONFIG(gestures)
class QQuickPointerNativeGestureEvent;
#endif
+class QQuickPointerScrollEvent;
class QQuickPointerTabletEvent;
class QQuickPointerTouchEvent;
class QQuickPointerHandler;
@@ -76,12 +77,12 @@ class QQuickPointerHandler;
class QQuickKeyEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(int key READ key)
- Q_PROPERTY(QString text READ text)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode)
+ Q_PROPERTY(int key READ key CONSTANT)
+ Q_PROPERTY(QString text READ text CONSTANT)
+ Q_PROPERTY(int modifiers READ modifiers CONSTANT)
+ Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat CONSTANT)
+ Q_PROPERTY(int count READ count CONSTANT)
+ Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
@@ -124,16 +125,16 @@ private:
class Q_QUICK_PRIVATE_EXPORT QQuickMouseEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(qreal x READ x)
- Q_PROPERTY(qreal y READ y)
- Q_PROPERTY(int button READ button)
- Q_PROPERTY(int buttons READ buttons)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(int source READ source REVISION 7)
- Q_PROPERTY(bool wasHeld READ wasHeld)
- Q_PROPERTY(bool isClick READ isClick)
+ Q_PROPERTY(qreal x READ x CONSTANT)
+ Q_PROPERTY(qreal y READ y CONSTANT)
+ Q_PROPERTY(int button READ button CONSTANT)
+ Q_PROPERTY(int buttons READ buttons CONSTANT)
+ Q_PROPERTY(int modifiers READ modifiers CONSTANT)
+ Q_PROPERTY(int source READ source CONSTANT REVISION 7)
+ Q_PROPERTY(bool wasHeld READ wasHeld CONSTANT)
+ Q_PROPERTY(bool isClick READ isClick CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
- Q_REVISION(11) Q_PROPERTY(int flags READ flags)
+ Q_PROPERTY(int flags READ flags CONSTANT REVISION 11)
public:
QQuickMouseEvent()
@@ -192,13 +193,13 @@ private:
class QQuickWheelEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(qreal x READ x)
- Q_PROPERTY(qreal y READ y)
- Q_PROPERTY(QPoint angleDelta READ angleDelta)
- Q_PROPERTY(QPoint pixelDelta READ pixelDelta)
- Q_PROPERTY(int buttons READ buttons)
- Q_PROPERTY(int modifiers READ modifiers)
- Q_PROPERTY(bool inverted READ inverted)
+ Q_PROPERTY(qreal x READ x CONSTANT)
+ Q_PROPERTY(qreal y READ y CONSTANT)
+ Q_PROPERTY(QPoint angleDelta READ angleDelta CONSTANT)
+ Q_PROPERTY(QPoint pixelDelta READ pixelDelta CONSTANT)
+ Q_PROPERTY(int buttons READ buttons CONSTANT)
+ Q_PROPERTY(int modifiers READ modifiers CONSTANT)
+ Q_PROPERTY(bool inverted READ inverted CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
@@ -258,15 +259,15 @@ private:
class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
{
Q_OBJECT
- Q_PROPERTY(QQuickPointerEvent *event READ pointerEvent)
- Q_PROPERTY(QPointF position READ position)
- Q_PROPERTY(QPointF scenePosition READ scenePosition)
- Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition)
- Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition)
- Q_PROPERTY(State state READ state)
- Q_PROPERTY(int pointId READ pointId)
- Q_PROPERTY(qreal timeHeld READ timeHeld)
- Q_PROPERTY(QVector2D velocity READ velocity)
+ Q_PROPERTY(QQuickPointerEvent *event READ pointerEvent CONSTANT)
+ Q_PROPERTY(QPointF position READ position CONSTANT)
+ Q_PROPERTY(QPointF scenePosition READ scenePosition CONSTANT)
+ Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition CONSTANT)
+ Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition CONSTANT)
+ Q_PROPERTY(State state READ state CONSTANT)
+ Q_PROPERTY(int pointId READ pointId CONSTANT)
+ Q_PROPERTY(qreal timeHeld READ timeHeld CONSTANT)
+ Q_PROPERTY(QVector2D velocity READ velocity CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
Q_PROPERTY(QObject *exclusiveGrabber READ exclusiveGrabber WRITE setExclusiveGrabber)
@@ -280,7 +281,7 @@ public:
Q_DECLARE_FLAGS(States, State)
Q_FLAG(States)
- enum GrabState {
+ enum GrabTransition {
GrabPassive = 0x01,
UngrabPassive = 0x02,
CancelGrabPassive = 0x03,
@@ -289,7 +290,7 @@ public:
UngrabExclusive = 0x20,
CancelGrabExclusive = 0x30,
};
- Q_ENUM(GrabState)
+ Q_ENUM(GrabTransition)
QQuickEventPoint(QQuickPointerEvent *parent);
@@ -385,10 +386,10 @@ private:
class Q_QUICK_PRIVATE_EXPORT QQuickPointerEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(QQuickPointerDevice *device READ device)
- Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers)
- Q_PROPERTY(Qt::MouseButtons button READ button)
- Q_PROPERTY(Qt::MouseButtons buttons READ buttons)
+ Q_PROPERTY(QQuickPointerDevice *device READ device CONSTANT)
+ Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers CONSTANT)
+ Q_PROPERTY(Qt::MouseButtons button READ button CONSTANT)
+ Q_PROPERTY(Qt::MouseButtons buttons READ buttons CONSTANT)
public:
QQuickPointerEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
@@ -419,16 +420,18 @@ public: // helpers for C++ only (during event delivery)
#if QT_CONFIG(gestures)
virtual QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() { return nullptr; }
#endif
+ virtual QQuickPointerScrollEvent *asPointerScrollEvent() { return nullptr; }
virtual const QQuickPointerMouseEvent *asPointerMouseEvent() const { return nullptr; }
virtual const QQuickPointerTouchEvent *asPointerTouchEvent() const { return nullptr; }
virtual const QQuickPointerTabletEvent *asPointerTabletEvent() const { return nullptr; }
#if QT_CONFIG(gestures)
virtual const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const { return nullptr; }
#endif
+ virtual const QQuickPointerScrollEvent *asPointerScrollEvent() const { return nullptr; }
virtual bool allPointsAccepted() const = 0;
virtual bool allUpdatedPointsAccepted() const = 0;
virtual bool allPointsGrabbed() const = 0;
- bool isAccepted() { return m_event->isAccepted(); }
+ bool isAccepted() { return m_event ? m_event->isAccepted() : false; }
void setAccepted(bool accepted) { if (m_event) m_event->setAccepted(accepted); }
QVector<QPointF> unacceptedPressedPointScenePositions() const;
@@ -439,7 +442,7 @@ public: // helpers for C++ only (during event delivery)
virtual void clearGrabbers() const = 0;
virtual bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const = 0;
- ulong timestamp() const { return m_event->timestamp(); }
+ ulong timestamp() const { return m_event ? m_event->timestamp() : 0; }
protected:
QQuickPointerDevice *m_device;
@@ -450,21 +453,14 @@ protected:
Q_DISABLE_COPY(QQuickPointerEvent)
};
-class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickPointerEvent
+class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointEvent : public QQuickPointerEvent
{
Q_OBJECT
public:
- QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickPointerEvent(parent, device), m_mousePoint(new QQuickEventPoint(this)) { }
+ QQuickSinglePointEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
+ : QQuickPointerEvent(parent, device), m_point(new QQuickEventPoint(this)) { }
- QQuickPointerEvent *reset(QEvent *) override;
void localize(QQuickItem *target) override;
- bool isPressEvent() const override;
- bool isDoubleClickEvent() const override;
- bool isUpdateEvent() const override;
- bool isReleaseEvent() const override;
- QQuickPointerMouseEvent *asPointerMouseEvent() override { return this; }
- const QQuickPointerMouseEvent *asPointerMouseEvent() const override { return this; }
int pointCount() const override { return 1; }
QQuickEventPoint *point(int i) const override;
QQuickEventPoint *pointById(int pointId) const override;
@@ -475,10 +471,28 @@ public:
void clearGrabbers() const override;
bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override;
- QMouseEvent *asMouseEvent(const QPointF& localPos) const;
+protected:
+ QQuickEventPoint *m_point;
-private:
- QQuickEventPoint *m_mousePoint;
+ Q_DISABLE_COPY(QQuickSinglePointEvent)
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickSinglePointEvent
+{
+ Q_OBJECT
+public:
+ QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
+ : QQuickSinglePointEvent(parent, device) { }
+
+ QQuickPointerEvent *reset(QEvent *) override;
+ bool isPressEvent() const override;
+ bool isDoubleClickEvent() const override;
+ bool isUpdateEvent() const override;
+ bool isReleaseEvent() const override;
+ QQuickPointerMouseEvent *asPointerMouseEvent() override { return this; }
+ const QQuickPointerMouseEvent *asPointerMouseEvent() const override { return this; }
+
+ QMouseEvent *asMouseEvent(const QPointF& localPos) const;
Q_DISABLE_COPY(QQuickPointerMouseEvent)
};
@@ -526,7 +540,7 @@ private:
};
#if QT_CONFIG(gestures)
-class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickPointerEvent
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickSinglePointEvent
{
Q_OBJECT
Q_PROPERTY(Qt::NativeGestureType type READ type CONSTANT)
@@ -534,34 +548,65 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickPoin
public:
QQuickPointerNativeGestureEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickPointerEvent(parent, device), m_gesturePoint(new QQuickEventPoint(this)) { }
+ : QQuickSinglePointEvent(parent, device) { }
QQuickPointerEvent *reset(QEvent *) override;
- void localize(QQuickItem *target) override;
bool isPressEvent() const override;
bool isUpdateEvent() const override;
bool isReleaseEvent() const override;
QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() override { return this; }
const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const override { return this; }
- int pointCount() const override { return 1; }
- QQuickEventPoint *point(int i) const override;
- QQuickEventPoint *pointById(int pointId) const override;
- bool allPointsAccepted() const override;
- bool allUpdatedPointsAccepted() const override;
- bool allPointsGrabbed() const override;
- QVector<QObject *> exclusiveGrabbers() const override;
- void clearGrabbers() const override;
- bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override;
Qt::NativeGestureType type() const;
qreal value() const;
-private:
- QQuickEventPoint *m_gesturePoint;
-
Q_DISABLE_COPY(QQuickPointerNativeGestureEvent)
};
#endif // QT_CONFIG(gestures)
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerScrollEvent : public QQuickSinglePointEvent
+{
+ Q_OBJECT
+ Q_PROPERTY(QVector2D angleDelta READ angleDelta CONSTANT)
+ Q_PROPERTY(QVector2D pixelDelta READ pixelDelta CONSTANT)
+ Q_PROPERTY(bool hasAngleDelta READ hasAngleDelta CONSTANT)
+ Q_PROPERTY(bool hasPixelDelta READ hasPixelDelta CONSTANT)
+ Q_PROPERTY(bool inverted READ isInverted CONSTANT)
+
+public:
+ QQuickPointerScrollEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
+ : QQuickSinglePointEvent(parent, device) { }
+
+ QQuickPointerEvent *reset(QEvent *) override;
+ void localize(QQuickItem *target) override;
+ bool isPressEvent() const override;
+ bool isUpdateEvent() const override;
+ bool isReleaseEvent() const override;
+ QQuickPointerScrollEvent *asPointerScrollEvent() override { return this; }
+ const QQuickPointerScrollEvent *asPointerScrollEvent() const override { return this; }
+ QVector2D angleDelta() const { return m_angleDelta; }
+ QVector2D pixelDelta() const { return m_pixelDelta; }
+ bool hasAngleDelta() const { return !angleDelta().isNull(); }
+ bool hasPixelDelta() const { return !pixelDelta().isNull(); }
+ bool isInverted() const { return m_inverted; }
+ Qt::ScrollPhase phase() const { return m_phase; }
+
+private:
+ // TODO add QQuickPointerDevice source() whenever QInputEvent is extended to have a source device
+ // then maybe Qt::MouseEventSource synthSource() will be obsolete... that's why it's not public now
+ Qt::MouseEventSource synthSource() const { return m_synthSource; }
+
+private:
+ QVector2D m_angleDelta;
+ QVector2D m_pixelDelta;
+ Qt::ScrollPhase m_phase = Qt::NoScrollPhase;
+ Qt::MouseEventSource m_synthSource = Qt::MouseEventNotSynthesized;
+ bool m_inverted = false;
+
+ friend class QQuickWindowPrivate;
+
+ Q_DISABLE_COPY(QQuickPointerScrollEvent)
+};
+
// ### Qt 6: move this to qtbase, replace QTouchDevice and the enums in QTabletEvent
class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject
@@ -587,7 +632,6 @@ public:
AllDevices = 0x7FFF
};
Q_DECLARE_FLAGS(DeviceTypes, DeviceType)
- Q_ENUM(DeviceType)
Q_FLAG(DeviceTypes)
enum PointerType : qint16 {
@@ -599,7 +643,6 @@ public:
AllPointerTypes = 0x7FFF
};
Q_DECLARE_FLAGS(PointerTypes, PointerType)
- Q_ENUM(PointerType)
Q_FLAG(PointerTypes)
enum CapabilityFlag : qint16 {
@@ -616,7 +659,6 @@ public:
YTilt = 0x1000
};
Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)
- Q_ENUM(CapabilityFlag)
Q_FLAG(Capabilities)
DeviceType type() const { return m_deviceType; }
@@ -627,6 +669,7 @@ public:
int buttonCount() const { return m_buttonCount; }
QString name() const { return m_name; }
QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; }
+ const QTouchDevice *qTouchDevice() const;
static QQuickPointerDevice *touchDevice(const QTouchDevice *d);
static QList<QQuickPointerDevice *> touchDevices();
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index cc35630fff..85045be411 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -69,10 +69,6 @@ static const int FlickThreshold = 15;
// will ensure the Flickable retains the grab on consecutive flicks.
static const int RetainGrabVelocity = 100;
-#ifdef Q_OS_OSX
-static const int MovementEndingTimerInterval = 100;
-#endif
-
// Currently std::round can't be used on Android when using ndk g++, so
// use C version instead. We could just define two versions of Round, one
// for float and one for double, but then only one of them would be used
@@ -248,6 +244,7 @@ QQuickFlickablePrivate::QQuickFlickablePrivate()
, stealMouse(false), pressed(false)
, scrollingPhase(false), interactive(true), calcVelocity(false)
, pixelAligned(false)
+ , syncDrag(false)
, lastPosTime(-1)
, lastPressTime(0)
, deceleration(QML_FLICK_DEFAULTDECELERATION)
@@ -508,7 +505,8 @@ static bool fuzzyLessThanOrEqualTo(qreal a, qreal b)
void QQuickFlickablePrivate::updateBeginningEnd()
{
Q_Q(QQuickFlickable);
- bool atBoundaryChange = false;
+ bool atXBeginningChange = false, atXEndChange = false;
+ bool atYBeginningChange = false, atYEndChange = false;
// Vertical
const qreal maxyextent = -q->maxYExtent();
@@ -519,11 +517,11 @@ void QQuickFlickablePrivate::updateBeginningEnd()
if (atBeginning != vData.atBeginning) {
vData.atBeginning = atBeginning;
- atBoundaryChange = true;
+ atYBeginningChange = true;
}
if (atEnd != vData.atEnd) {
vData.atEnd = atEnd;
- atBoundaryChange = true;
+ atYEndChange = true;
}
// Horizontal
@@ -535,11 +533,11 @@ void QQuickFlickablePrivate::updateBeginningEnd()
if (atBeginning != hData.atBeginning) {
hData.atBeginning = atBeginning;
- atBoundaryChange = true;
+ atXBeginningChange = true;
}
if (atEnd != hData.atEnd) {
hData.atEnd = atEnd;
- atBoundaryChange = true;
+ atXEndChange = true;
}
if (vData.extentsChanged) {
@@ -560,8 +558,16 @@ void QQuickFlickablePrivate::updateBeginningEnd()
}
}
- if (atBoundaryChange)
+ if (atXEndChange || atYEndChange || atXBeginningChange || atYBeginningChange)
emit q->isAtBoundaryChanged();
+ if (atXEndChange)
+ emit q->atXEndChanged();
+ if (atXBeginningChange)
+ emit q->atXBeginningChanged();
+ if (atYEndChange)
+ emit q->atYEndChanged();
+ if (atYBeginningChange)
+ emit q->atYBeginningChanged();
if (visibleArea)
visibleArea->updateVisible();
@@ -984,6 +990,33 @@ void QQuickFlickable::setPixelAligned(bool align)
}
}
+/*!
+ \qmlproperty bool QtQuick::Flickable::synchronousDrag
+ \since 5.12
+
+ If this property is set to true, then when the mouse or touchpoint moves
+ far enough to begin dragging the content, the content will jump, such that
+ the content pixel which was under the cursor or touchpoint when pressed
+ remains under that point.
+
+ The default is \c false, which provides a smoother experience (no jump)
+ at the cost that some of the drag distance is "lost" at the beginning.
+*/
+bool QQuickFlickable::synchronousDrag() const
+{
+ Q_D(const QQuickFlickable);
+ return d->syncDrag;
+}
+
+void QQuickFlickable::setSynchronousDrag(bool v)
+{
+ Q_D(QQuickFlickable);
+ if (v != d->syncDrag) {
+ d->syncDrag = v;
+ emit synchronousDragChanged();
+ }
+}
+
qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
@@ -1100,7 +1133,7 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp
if (overThreshold || elapsedSincePress > 200) {
if (!vMoved)
vData.dragStartOffset = dy;
- qreal newY = dy + vData.pressPos - vData.dragStartOffset;
+ qreal newY = dy + vData.pressPos - (syncDrag ? 0 : vData.dragStartOffset);
// Recalculate bounds in case margins have changed, but use the content
// size estimate taken at the start of the drag in case the drag causes
// the estimate to be altered
@@ -1176,7 +1209,7 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp
if (overThreshold || elapsedSincePress > 200) {
if (!hMoved)
hData.dragStartOffset = dx;
- qreal newX = dx + hData.pressPos - hData.dragStartOffset;
+ qreal newX = dx + hData.pressPos - (syncDrag ? 0 : hData.dragStartOffset);
const qreal minX = hData.dragMinBound + hData.startMargin;
const qreal maxX = hData.dragMaxBound - hData.endMargin;
if (!(boundsBehavior & QQuickFlickable::DragOverBounds)) {
@@ -1280,7 +1313,7 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp
void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
{
Q_Q(QQuickFlickable);
- if (!interactive || lastPosTime == -1)
+ if (!interactive || lastPosTime == -1 || event->buttons() == Qt::NoButton)
return;
qint64 currentTimestamp = computeCurrentTime(event);
@@ -1460,23 +1493,24 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event)
case Qt::ScrollUpdate:
if (d->scrollingPhase)
d->pressed = true;
-#ifdef Q_OS_MACOS
- // TODO eliminate this timer when ScrollMomentum has been added
- d->movementEndingTimer.start(MovementEndingTimerInterval, this);
-#endif
+ break;
+ case Qt::ScrollMomentum:
+ d->pressed = false;
+ d->scrollingPhase = false;
+ d->draggingEnding();
+ event->accept();
+ d->lastPosTime = -1;
break;
case Qt::ScrollEnd:
- // TODO most of this should be done at transition to ScrollMomentum phase,
- // then do what the movementEndingTimer triggers at transition to ScrollEnd phase
d->pressed = false;
d->scrollingPhase = false;
d->draggingEnding();
event->accept();
returnToBounds();
d->lastPosTime = -1;
-#ifdef Q_OS_MACOS
- d->movementEndingTimer.start(MovementEndingTimerInterval, this);
-#endif
+ d->stealMouse = false;
+ if (!d->velocityTimeline.isActive() && !d->timeline.isActive())
+ movementEnding(true, true);
return;
}
@@ -1672,14 +1706,6 @@ void QQuickFlickable::timerEvent(QTimerEvent *event)
if (d->delayedPressEvent) {
d->replayDelayedPress();
}
- } else if (event->timerId() == d->movementEndingTimer.timerId()) {
- d->movementEndingTimer.stop();
- if (!d->scrollingPhase) {
- d->pressed = false;
- d->stealMouse = false;
- if (!d->velocityTimeline.isActive() && !d->timeline.isActive())
- movementEnding(true, true);
- }
}
}
@@ -1821,8 +1847,8 @@ void QQuickFlickable::flick(qreal xVelocity, qreal yVelocity)
d->vData.velocity = yVelocity;
d->hData.vTime = d->vData.vTime = d->timeline.time();
- bool flickedX = d->flickX(xVelocity);
- bool flickedY = d->flickY(yVelocity);
+ const bool flickedX = xflick() && !qFuzzyIsNull(xVelocity) && d->flickX(xVelocity);
+ const bool flickedY = yflick() && !qFuzzyIsNull(yVelocity) && d->flickY(yVelocity);
if (flickedX)
d->hMoved = true;
@@ -2540,7 +2566,7 @@ void QQuickFlickablePrivate::draggingStarting()
void QQuickFlickablePrivate::draggingEnding()
{
Q_Q(QQuickFlickable);
- bool wasDragging = hData.dragging || vData.dragging;
+ const bool wasDragging = hData.dragging || vData.dragging;
if (hData.dragging) {
hData.dragging = false;
emit q->draggingHorizontallyChanged();
@@ -2549,12 +2575,14 @@ void QQuickFlickablePrivate::draggingEnding()
vData.dragging = false;
emit q->draggingVerticallyChanged();
}
- if (wasDragging && !hData.dragging && !vData.dragging) {
- emit q->draggingChanged();
- emit q->dragEnded();
+ if (wasDragging) {
+ if (!hData.dragging && !vData.dragging) {
+ emit q->draggingChanged();
+ emit q->dragEnded();
+ }
+ hData.inRebound = false;
+ vData.inRebound = false;
}
- hData.inRebound = false;
- vData.inRebound = false;
}
bool QQuickFlickablePrivate::isViewMoving() const
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 939e3af698..1bd8fc1020 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -98,14 +98,15 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
- Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
- Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
+ Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY atXEndChanged)
+ Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY atYEndChanged)
+ Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY atXBeginningChanged)
+ Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY atYBeginningChanged)
Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
+ Q_PROPERTY(bool synchronousDrag READ synchronousDrag WRITE setSynchronousDrag NOTIFY synchronousDragChanged REVISION 12)
Q_PROPERTY(qreal horizontalOvershoot READ horizontalOvershoot NOTIFY horizontalOvershootChanged REVISION 9)
Q_PROPERTY(qreal verticalOvershoot READ verticalOvershoot NOTIFY verticalOvershootChanged REVISION 9)
@@ -213,6 +214,9 @@ public:
bool pixelAligned() const;
void setPixelAligned(bool align);
+ bool synchronousDrag() const;
+ void setSynchronousDrag(bool v);
+
qreal horizontalOvershoot() const;
qreal verticalOvershoot() const;
@@ -259,9 +263,15 @@ Q_SIGNALS:
void dragStarted();
void dragEnded();
void pixelAlignedChanged();
+ Q_REVISION(12) void synchronousDragChanged();
Q_REVISION(9) void horizontalOvershootChanged();
Q_REVISION(9) void verticalOvershootChanged();
+ Q_REVISION(12) void atXEndChanged();
+ Q_REVISION(12) void atYEndChanged();
+ Q_REVISION(12) void atXBeginningChanged();
+ Q_REVISION(12) void atYBeginningChanged();
+
protected:
bool childMouseEventFilter(QQuickItem *, QEvent *) override;
void mousePressEvent(QMouseEvent *event) override;
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index 08f069e830..c538cf7878 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -221,8 +221,8 @@ public:
bool interactive : 1;
bool calcVelocity : 1;
bool pixelAligned : 1;
+ bool syncDrag : 1;
QElapsedTimer timer;
- QBasicTimer movementEndingTimer;
qint64 lastPosTime;
qint64 lastPressTime;
QPointF lastPos;
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index f2fa66332c..d7b3b0708c 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -914,7 +914,7 @@ void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
qreal tempPosition = isContentFlowReversed() ? -position()-size() : position();
if (snapMode == QQuickGridView::SnapOneRow && moveReason == Mouse) {
// if we've been dragged < rowSize()/2 then bias towards the next row
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = 0;
if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2)
bias = rowSize()/2;
@@ -925,13 +925,13 @@ void QQuickGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
tempPosition -= bias;
}
FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);
- if (strictHighlightRange && currentItem && (!topItem || topItem->index != currentIndex)) {
+ if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
topItem = currentItem;
}
FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);
- if (strictHighlightRange && currentItem && (!bottomItem || bottomItem->index != currentIndex)) {
+ if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
bottomItem = currentItem;
@@ -1013,7 +1013,7 @@ bool QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (data.move.value() < minExtent) {
if (snapMode == QQuickGridView::SnapOneRow) {
// if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0;
if (isContentFlowReversed())
bias = -bias;
@@ -1030,7 +1030,7 @@ bool QQuickGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (data.move.value() > maxExtent) {
if (snapMode == QQuickGridView::SnapOneRow) {
// if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0;
if (isContentFlowReversed())
bias = -bias;
@@ -1309,13 +1309,14 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
/*!
- \qmlproperty model QtQuick::GridView::model
- This property holds the model providing data for the grid.
+ \qmlproperty model QtQuick::GridView::model
+ This property holds the model providing data for the grid.
The model provides the set of data that is used to create the items
- in the view. Models can be created directly in QML using \l ListModel, \l XmlListModel
- or \l VisualItemModel, or provided by C++ model classes. If a C++ model class is
- used, it must be a subclass of \l QAbstractItemModel or a simple list.
+ in the view. Models can be created directly in QML using \l ListModel,
+ \l XmlListModel, \l DelegateModel, or \l ObjectModel, or provided by C++
+ model classes. If a C++ model class is used, it must be a subclass of
+ \l QAbstractItemModel or a simple list.
\sa {qml-data-models}{Data Models}
*/
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index e568a27ed7..8e2d32a818 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -67,6 +67,7 @@
#include <QtQuick/private/qquickstate_p.h>
#include <private/qquickitem_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
+#include <QtQuick/private/qquickhoverhandler_p.h>
#include <QtQuick/private/qquickpointerhandler_p.h>
#include <private/qv4engine_p.h>
@@ -356,7 +357,7 @@ void QQuickItemKeyFilter::componentComplete()
\qmltype KeyNavigation
\instantiates QQuickKeyNavigationAttached
\inqmlmodule QtQuick
- \ingroup qtquick-input
+ \ingroup qtquick-input-handlers
\brief Supports key navigation by arrow keys.
Key-based user interfaces commonly allow the use of arrow keys to navigate between
@@ -815,7 +816,7 @@ bool QQuickKeysAttached::isConnected(const char *signalName) const
\qmltype Keys
\instantiates QQuickKeysAttached
\inqmlmodule QtQuick
- \ingroup qtquick-input
+ \ingroup qtquick-input-handlers
\brief Provides key handling to Items.
All visual primitives support key handling via the Keys
@@ -2565,8 +2566,19 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
from = item->parentItem();
}
bool skip = false;
- QQuickItem * startItem = item;
- QQuickItem * firstFromItem = from;
+
+ QQuickItem *startItem = item;
+ // Protect from endless loop:
+ // If we start on an invisible item we will not find it again.
+ // If there is no other item which can become the focus item, we have a forever loop,
+ // since the protection only works if we encounter the first item again.
+ while (startItem && !startItem->isVisible()) {
+ startItem = startItem->parentItem();
+ }
+ if (!startItem)
+ return item;
+
+ QQuickItem *firstFromItem = from;
QQuickItem *current = item;
qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
@@ -5150,6 +5162,17 @@ void QQuickItemPrivate::deliverShortcutOverrideEvent(QKeyEvent *event)
}
}
+bool QQuickItemPrivate::anyPointerHandlerWants(QQuickEventPoint *point) const
+{
+ if (!hasPointerHandlers())
+ return false;
+ for (QQuickPointerHandler *handler : extra->pointerHandlers) {
+ if (handler->wantsEventPoint(point))
+ return true;
+ }
+ return false;
+}
+
/*!
\internal
Deliver the \a event to all PointerHandlers which are in the pre-determined
@@ -7353,6 +7376,8 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover)
QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild);
if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled)
return; // nope! sorry, something else wants it kept on.
+ if (otherChildPrivate->hasHoverHandlers())
+ return; // nope! sorry, we have pointer handlers which are interested.
}
}
@@ -8126,6 +8151,16 @@ bool QQuickItemPrivate::hasPointerHandlers() const
return extra.isAllocated() && !extra->pointerHandlers.isEmpty();
}
+bool QQuickItemPrivate::hasHoverHandlers() const
+{
+ if (!hasPointerHandlers())
+ return false;
+ for (QQuickPointerHandler *h : extra->pointerHandlers)
+ if (qmlobject_cast<QQuickHoverHandler *>(h))
+ return true;
+ return false;
+}
+
#if QT_CONFIG(quick_shadereffect)
QQuickItemLayer::QQuickItemLayer(QQuickItem *item)
: m_item(item)
@@ -8711,7 +8746,7 @@ void QV4::Heap::QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::MarkS
quint64 QQuickItemPrivate::_q_createJSWrapper(QV4::ExecutionEngine *engine)
{
- return (engine->memoryManager->allocObject<QQuickItemWrapper>(q_func()))->asReturnedValue();
+ return (engine->memoryManager->allocate<QQuickItemWrapper>(q_func()))->asReturnedValue();
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index cfdb2ad5b7..6f601e0872 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -163,6 +163,7 @@ public:
// Remember to increment the size of QQuickItemPrivate::flags
};
Q_DECLARE_FLAGS(Flags, Flag)
+ Q_FLAG(Flags)
enum ItemChange {
ItemChildAddedChange, // value.item
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 93287cf0aa..24941ab264 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -280,6 +280,7 @@ public:
QQuickItemLayer *layer() const;
bool hasPointerHandlers() const;
+ bool hasHoverHandlers() const;
// data property
static void data_append(QQmlListProperty<QObject> *, QObject *);
@@ -330,12 +331,26 @@ public:
Q_DECLARE_FLAGS(ChangeTypes, ChangeType)
struct ChangeListener {
- ChangeListener(QQuickItemChangeListener *l = nullptr, QQuickItemPrivate::ChangeTypes t = nullptr) : listener(l), types(t), gTypes(QQuickGeometryChange::All) {}
- ChangeListener(QQuickItemChangeListener *l, QQuickGeometryChange gt) : listener(l), types(Geometry), gTypes(gt) {}
+ using ChangeTypes = QQuickItemPrivate::ChangeTypes;
+
+ ChangeListener(QQuickItemChangeListener *l = nullptr, ChangeTypes t = nullptr)
+ : listener(l)
+ , types(t)
+ , gTypes(QQuickGeometryChange::All)
+ {}
+
+ ChangeListener(QQuickItemChangeListener *l, QQuickGeometryChange gt)
+ : listener(l)
+ , types(Geometry)
+ , gTypes(gt)
+ {}
+
+ bool operator==(const ChangeListener &other) const
+ { return listener == other.listener && types == other.types; }
+
QQuickItemChangeListener *listener;
- QQuickItemPrivate::ChangeTypes types;
+ ChangeTypes types;
QQuickGeometryChange gTypes; //NOTE: not used for ==
- bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; }
};
struct ExtraData {
@@ -581,6 +596,7 @@ public:
#endif
void deliverShortcutOverrideEvent(QKeyEvent *);
+ bool anyPointerHandlerWants(QQuickEventPoint *point) const;
virtual bool handlePointerEvent(QQuickPointerEvent *, bool avoidExclusiveGrabber = false);
virtual void setVisible(bool visible);
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 51a91e1f7a..a20150e3b9 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -64,6 +64,9 @@
#if QT_CONFIG(quick_pathview)
#include "qquickpathview_p.h"
#endif
+#if QT_CONFIG(quick_tableview)
+#include "qquicktableview_p.h"
+#endif
#if QT_CONFIG(quick_viewtransitions)
#include "qquickitemviewtransition_p.h"
#endif
@@ -113,6 +116,12 @@
#include <private/qqmlmetatype_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
+#include "handlers/qquickdraghandler_p.h"
+#include "handlers/qquickhoverhandler_p.h"
+#include "handlers/qquickpinchhandler_p.h"
+#include "handlers/qquickpointhandler_p.h"
+#include "handlers/qquicktaphandler_p.h"
+
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcTransient)
QT_END_NAMESPACE
@@ -135,6 +144,9 @@ static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject
win->setTransientParent(parentItem->window());
return QQmlPrivate::Parented;
}
+ } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) {
+ handler->setParent(parent);
+ return QQmlPrivate::Parented;
}
return QQmlPrivate::IncompatibleObject;
} else if (QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent)) {
@@ -422,6 +434,42 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickAnimatedImage, 11>(uri, 2, 11,"AnimatedImage");
#endif
qmlRegisterType<QQuickItem, 11>(uri, 2, 11,"Item");
+ qmlRegisterType<QQuickFlickable, 12>(uri, 2, 12, "Flickable");
+
+ // classes related to Input Handlers which are newly exposed since 5.12
+ qmlRegisterUncreatableType<QQuickPointerEvent>(uri, 2, 12, "PointerEvent",
+ QQuickPointerHandler::tr("PointerEvent is only available as a parameter of several signals in PointerHandler"));
+ qmlRegisterUncreatableType<QQuickPointerMouseEvent>(uri, 2, 12, "PointerMouseEvent",
+ QQuickPointerHandler::tr("PointerMouseEvent is only available as a parameter of several signals in PointerHandler"));
+ qmlRegisterUncreatableType<QQuickPointerTouchEvent>(uri, 2, 12, "PointerTouchEvent",
+ QQuickPointerHandler::tr("PointerTouchEvent is only available as a parameter of several signals in PointerHandler"));
+ qmlRegisterUncreatableType<QQuickEventPoint>(uri, 2, 12, "EventPoint",
+ QQuickPointerHandler::tr("EventPoint is only available as a member of PointerEvent"));
+ qmlRegisterUncreatableType<QQuickEventTouchPoint>(uri, 2, 12, "EventTouchPoint",
+ QQuickPointerHandler::tr("EventTouchPoint is only available as a member of PointerEvent"));
+ qmlRegisterUncreatableType<QQuickPointerDevice>(uri, 2, 12, "PointerDevice",
+ QQuickPointerHandler::tr("PointerDevice is only available as a property of PointerEvent"));
+
+ // Input Handlers are part of QtQuick, not a separate module, since 5.12
+ qmlRegisterUncreatableType<QQuickPointerHandler>(uri, 2, 12, "PointerHandler",
+ QQuickPointerHandler::tr("PointerHandler is an abstract base class"));
+ qmlRegisterType<QQuickPointHandler>(uri, 2, 12, "PointHandler");
+ qmlRegisterType<QQuickDragHandler>(uri, 2, 12, "DragHandler");
+ qmlRegisterUncreatableType<QQuickDragAxis>(uri, 2, 12, "DragAxis",
+ QQuickDragHandler::tr("DragAxis is only available as a grouped property of DragHandler"));
+ qmlRegisterType<QQuickHoverHandler>(uri, 2, 12, "HoverHandler");
+ qmlRegisterType<QQuickPinchHandler>(uri, 2, 12, "PinchHandler");
+ qmlRegisterType<QQuickTapHandler>(uri, 2, 12, "TapHandler");
+ qRegisterMetaType<QQuickHandlerPoint>();
+
+ // The rest of the 5.12 revisions
+ qmlRegisterType<QQuickAnimatedSprite, 12>("QtQuick", 2, 12, "AnimatedSprite");
+ qmlRegisterType<QQuickGradient, 12>(uri, 2, 12, "Gradient");
+ qmlRegisterType<QQuickFlickable, 12>(uri, 2, 12, "Flickable");
+ qmlRegisterType<QQuickText, 12>(uri, 2, 12, "Text");
+#if QT_CONFIG(quick_tableview)
+ qmlRegisterType<QQuickTableView>(uri, 2, 12, "TableView");
+#endif
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index f2e055e874..7493bdafda 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qquickitemview_p_p.h"
+#include "qquickitemviewfxitem_p_p.h"
#include <QtQuick/private/qquicktransition_p.h>
#include <QtQml/QQmlInfo>
#include "qplatformdefs.h"
@@ -52,117 +53,14 @@ Q_LOGGING_CATEGORY(lcItemViewDelegateLifecycle, "qt.quick.itemview.lifecycle")
#endif
FxViewItem::FxViewItem(QQuickItem *i, QQuickItemView *v, bool own, QQuickItemViewAttached *attached)
- : item(i)
+ : QQuickItemViewFxItem(i, own, QQuickItemViewPrivate::get(v))
, view(v)
- , transitionableItem(nullptr)
, attached(attached)
- , ownItem(own)
- , releaseAfterTransition(false)
- , trackGeom(false)
{
if (attached) // can be null for default components (see createComponentItem)
attached->setView(view);
}
-FxViewItem::~FxViewItem()
-{
- delete transitionableItem;
- if (ownItem && item) {
- trackGeometry(false);
- item->setParentItem(nullptr);
- item->deleteLater();
- item = nullptr;
- }
-}
-
-qreal FxViewItem::itemX() const
-{
- return transitionableItem ? transitionableItem->itemX() : (item ? item->x() : 0);
-}
-
-qreal FxViewItem::itemY() const
-{
- return transitionableItem ? transitionableItem->itemY() : (item ? item->y() : 0);
-}
-
-void FxViewItem::moveTo(const QPointF &pos, bool immediate)
-{
- if (transitionableItem)
- transitionableItem->moveTo(pos, immediate);
- else if (item)
- item->setPosition(pos);
-}
-
-void FxViewItem::setVisible(bool visible)
-{
- if (!visible && transitionableItem && transitionableItem->transitionScheduledOrRunning())
- return;
- if (item)
- QQuickItemPrivate::get(item)->setCulled(!visible);
-}
-
-void FxViewItem::trackGeometry(bool track)
-{
- if (track) {
- if (!trackGeom) {
- if (item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- trackGeom = true;
- }
- } else {
- if (trackGeom) {
- if (item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- trackGeom = false;
- }
- }
-}
-
-QQuickItemViewTransitioner::TransitionType FxViewItem::scheduledTransitionType() const
-{
- return transitionableItem ? transitionableItem->nextTransitionType : QQuickItemViewTransitioner::NoTransition;
-}
-
-bool FxViewItem::transitionScheduledOrRunning() const
-{
- return transitionableItem ? transitionableItem->transitionScheduledOrRunning() : false;
-}
-
-bool FxViewItem::transitionRunning() const
-{
- return transitionableItem ? transitionableItem->transitionRunning() : false;
-}
-
-bool FxViewItem::isPendingRemoval() const
-{
- return transitionableItem ? transitionableItem->isPendingRemoval() : false;
-}
-
-void FxViewItem::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget)
-{
- if (!transitioner)
- return;
- if (!transitionableItem)
- transitionableItem = new QQuickItemViewTransitionableItem(item);
- transitioner->transitionNextReposition(transitionableItem, type, asTarget);
-}
-
-bool FxViewItem::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds)
-{
- return transitionableItem ? transitionableItem->prepareTransition(transitioner, index, viewBounds) : false;
-}
-
-void FxViewItem::startTransition(QQuickItemViewTransitioner *transitioner)
-{
- if (transitionableItem)
- transitionableItem->startTransition(transitioner, index);
-}
-
-
QQuickItemViewChangeSet::QQuickItemViewChangeSet()
: active(false)
{
@@ -1329,6 +1227,12 @@ void QQuickItemView::trackedPositionChanged()
Q_D(QQuickItemView);
if (!d->trackedItem || !d->currentItem)
return;
+
+ if (d->inLayout) {
+ polish();
+ return;
+ }
+
if (d->moveReason == QQuickItemViewPrivate::SetIndex) {
qreal trackedPos = d->trackedItem->position();
qreal trackedSize = d->trackedItem->size();
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index e250cf0ccb..ea5b5df9c6 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -56,6 +56,7 @@
QT_REQUIRE_CONFIG(quick_itemview);
#include "qquickitemview_p.h"
+#include "qquickitemviewfxitem_p_p.h"
#include "qquickitemviewtransition_p.h"
#include "qquickflickable_p_p.h"
#include <QtQml/private/qqmlobjectmodel_p.h>
@@ -65,47 +66,13 @@ QT_REQUIRE_CONFIG(quick_itemview);
QT_BEGIN_NAMESPACE
-
-class Q_AUTOTEST_EXPORT FxViewItem
+class Q_AUTOTEST_EXPORT FxViewItem : public QQuickItemViewFxItem
{
public:
FxViewItem(QQuickItem *, QQuickItemView *, bool own, QQuickItemViewAttached *attached);
- virtual ~FxViewItem();
-
- qreal itemX() const;
- qreal itemY() const;
- inline qreal itemWidth() const { return item ? item->width() : 0; }
- inline qreal itemHeight() const { return item ? item->height() : 0; }
-
- void moveTo(const QPointF &pos, bool immediate);
- void setVisible(bool visible);
- void trackGeometry(bool track);
-
- QQuickItemViewTransitioner::TransitionType scheduledTransitionType() const;
- bool transitionScheduledOrRunning() const;
- bool transitionRunning() const;
- bool isPendingRemoval() const;
-
- void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget);
- bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds);
- void startTransition(QQuickItemViewTransitioner *transitioner);
-
- // these are positions and sizes along the current direction of scrolling/flicking
- virtual qreal position() const = 0;
- virtual qreal endPosition() const = 0;
- virtual qreal size() const = 0;
- virtual qreal sectionSize() const = 0;
-
- virtual bool contains(qreal x, qreal y) const = 0;
- QPointer<QQuickItem> item;
QQuickItemView *view;
- QQuickItemViewTransitionableItem *transitionableItem;
QQuickItemViewAttached *attached;
- int index;
- bool ownItem;
- bool releaseAfterTransition;
- bool trackGeom;
};
diff --git a/src/quick/items/qquickitemviewfxitem.cpp b/src/quick/items/qquickitemviewfxitem.cpp
new file mode 100644
index 0000000000..f9c65967ea
--- /dev/null
+++ b/src/quick/items/qquickitemviewfxitem.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickitemviewfxitem_p_p.h"
+#include "qquickitem_p.h"
+#include "qquickitemview_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickItemViewFxItem::QQuickItemViewFxItem(QQuickItem *item, bool ownItem, QQuickItemChangeListener* changeListener)
+ : item(item)
+ , ownItem(ownItem)
+ , changeListener(changeListener)
+ , transitionableItem(nullptr)
+ , releaseAfterTransition(false)
+ , trackGeom(false)
+{
+}
+
+QQuickItemViewFxItem::~QQuickItemViewFxItem()
+{
+ delete transitionableItem;
+ if (ownItem && item) {
+ trackGeometry(false);
+ item->setParentItem(0);
+ item->deleteLater();
+ }
+}
+
+qreal QQuickItemViewFxItem::itemX() const
+{
+ return transitionableItem ? transitionableItem->itemX() : (item ? item->x() : 0);
+}
+
+qreal QQuickItemViewFxItem::itemY() const
+{
+ return transitionableItem ? transitionableItem->itemY() : (item ? item->y() : 0);
+}
+
+void QQuickItemViewFxItem::moveTo(const QPointF &pos, bool immediate)
+{
+ if (transitionableItem)
+ transitionableItem->moveTo(pos, immediate);
+ else if (item)
+ item->setPosition(pos);
+}
+
+void QQuickItemViewFxItem::setVisible(bool visible)
+{
+ if (!visible && transitionableItem && transitionableItem->transitionScheduledOrRunning())
+ return;
+ if (item)
+ QQuickItemPrivate::get(item)->setCulled(!visible);
+}
+
+void QQuickItemViewFxItem::trackGeometry(bool track)
+{
+ if (track) {
+ if (!trackGeom) {
+ if (item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->addItemChangeListener(changeListener, QQuickItemPrivate::Geometry);
+ }
+ trackGeom = true;
+ }
+ } else {
+ if (trackGeom) {
+ if (item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->removeItemChangeListener(changeListener, QQuickItemPrivate::Geometry);
+ }
+ trackGeom = false;
+ }
+ }
+}
+
+QRectF QQuickItemViewFxItem::geometry() const
+{
+ return QRectF(item->position(), item->size());
+}
+
+void QQuickItemViewFxItem::setGeometry(const QRectF &geometry)
+{
+ item->setPosition(geometry.topLeft());
+ item->setSize(geometry.size());
+}
+
+QQuickItemViewTransitioner::TransitionType QQuickItemViewFxItem::scheduledTransitionType() const
+{
+ return transitionableItem ? transitionableItem->nextTransitionType : QQuickItemViewTransitioner::NoTransition;
+}
+
+bool QQuickItemViewFxItem::transitionScheduledOrRunning() const
+{
+ return transitionableItem ? transitionableItem->transitionScheduledOrRunning() : false;
+}
+
+bool QQuickItemViewFxItem::transitionRunning() const
+{
+ return transitionableItem ? transitionableItem->transitionRunning() : false;
+}
+
+bool QQuickItemViewFxItem::isPendingRemoval() const
+{
+ return transitionableItem ? transitionableItem->isPendingRemoval() : false;
+}
+
+void QQuickItemViewFxItem::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget)
+{
+ if (!transitioner)
+ return;
+ if (!transitionableItem)
+ transitionableItem = new QQuickItemViewTransitionableItem(item);
+ transitioner->transitionNextReposition(transitionableItem, type, asTarget);
+}
+
+bool QQuickItemViewFxItem::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds)
+{
+ return transitionableItem ? transitionableItem->prepareTransition(transitioner, index, viewBounds) : false;
+}
+
+void QQuickItemViewFxItem::startTransition(QQuickItemViewTransitioner *transitioner)
+{
+ if (transitionableItem)
+ transitionableItem->startTransition(transitioner, index);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/quick/items/qquickitemviewfxitem_p_p.h b/src/quick/items/qquickitemviewfxitem_p_p.h
new file mode 100644
index 0000000000..48ffe248bc
--- /dev/null
+++ b/src/quick/items/qquickitemviewfxitem_p_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFXVIEWITEM_P_P_H
+#define QQUICKFXVIEWITEM_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qtquickglobal_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickitemviewtransition_p.h>
+
+QT_REQUIRE_CONFIG(quick_itemview);
+
+QT_BEGIN_NAMESPACE
+
+class Q_AUTOTEST_EXPORT QQuickItemViewFxItem
+{
+public:
+ QQuickItemViewFxItem(QQuickItem *item, bool ownItem, QQuickItemChangeListener *changeListener);
+ virtual ~QQuickItemViewFxItem();
+
+ qreal itemX() const;
+ qreal itemY() const;
+ inline qreal itemWidth() const { return item ? item->width() : 0; }
+ inline qreal itemHeight() const { return item ? item->height() : 0; }
+
+ void moveTo(const QPointF &pos, bool immediate);
+ void setVisible(bool visible);
+ void trackGeometry(bool track);
+
+ QRectF geometry() const;
+ void setGeometry(const QRectF &geometry);
+
+ QQuickItemViewTransitioner::TransitionType scheduledTransitionType() const;
+ bool transitionScheduledOrRunning() const;
+ bool transitionRunning() const;
+ bool isPendingRemoval() const;
+
+ void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget);
+ bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds);
+ void startTransition(QQuickItemViewTransitioner *transitioner);
+
+ // these are positions and sizes along the current direction of scrolling/flicking
+ virtual qreal position() const = 0;
+ virtual qreal endPosition() const = 0;
+ virtual qreal size() const = 0;
+ virtual qreal sectionSize() const = 0;
+
+ virtual bool contains(qreal x, qreal y) const = 0;
+
+ int index = -1;
+ QPointer<QQuickItem> item;
+ bool ownItem;
+ QQuickItemChangeListener *changeListener;
+ QQuickItemViewTransitionableItem *transitionableItem;
+ bool releaseAfterTransition;
+ bool trackGeom;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKFXVIEWITEM_P_P_H
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp
index c06dcce0d9..0fde0beb75 100644
--- a/src/quick/items/qquickitemviewtransition.cpp
+++ b/src/quick/items/qquickitemviewtransition.cpp
@@ -500,6 +500,8 @@ void QQuickItemViewTransitionableItem::startTransition(QQuickItemViewTransitione
}
if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) {
+ if (transition)
+ transition->cancel();
delete transition;
transition = new QQuickItemViewTransitionJob;
}
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 19033e03f1..540805ac28 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1501,7 +1501,7 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
qreal tempPosition = isContentFlowReversed() ? -position()-size() : position();
if (snapMode == QQuickListView::SnapOneItem && moveReason == Mouse) {
// if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = 0;
if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < averageSize/2)
bias = averageSize/2;
@@ -1512,13 +1512,13 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
tempPosition -= bias;
}
FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);
- if (strictHighlightRange && currentItem && (!topItem || topItem->index != currentIndex)) {
+ if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
topItem = currentItem;
}
FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);
- if (strictHighlightRange && currentItem && (!bottomItem || bottomItem->index != currentIndex)) {
+ if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
bottomItem = currentItem;
@@ -1599,7 +1599,7 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (data.move.value() < minExtent) {
if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
// if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = dist < averageSize/2 ? averageSize/2 : 0;
if (isContentFlowReversed())
bias = -bias;
@@ -1616,7 +1616,7 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
if (data.move.value() > maxExtent) {
if (snapMode == QQuickListView::SnapOneItem && !hData.flicking && !vData.flicking) {
// if we've been dragged < averageSize/2 then bias towards the next item
- qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
+ qreal dist = data.move.value() - data.pressPos;
qreal bias = -dist < averageSize/2 ? averageSize/2 : 0;
if (isContentFlowReversed())
bias = -bias;
@@ -1982,7 +1982,7 @@ QQuickListView::~QQuickListView()
The model provides the set of data that is used to create the items
in the view. Models can be created directly in QML using \l ListModel, \l XmlListModel
- or \l VisualItemModel, or provided by C++ model classes. If a C++ model class is
+ or \l ObjectModel, or provided by C++ model classes. If a C++ model class is
used, it must be a subclass of \l QAbstractItemModel or a simple list.
\sa {qml-data-models}{Data Models}
@@ -2521,7 +2521,11 @@ void QQuickListView::setHighlightResizeDuration(int duration)
the view.
\li ListView.SnapOneItem - the view settles no more than one item away from the first
visible item at the time the mouse button is released. This mode is particularly
- useful for moving one page at a time.
+ useful for moving one page at a time. When SnapOneItem is enabled, the ListView will
+ show a stronger affinity to neighboring items when movement occurs. For example, a
+ short drag that snaps back to the current item with SnapToItem might snap to a
+ neighboring item with SnapOneItem.
+
\endlist
\c snapMode does not affect the \l currentIndex. To update the
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index b5ae41daef..d0e29c204e 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -54,7 +54,7 @@ static const QQuickItemPrivate::ChangeTypes watchedChanges
= QQuickItemPrivate::Geometry | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight;
QQuickLoaderPrivate::QQuickLoaderPrivate()
- : item(nullptr), object(nullptr), component(nullptr), itemContext(nullptr), incubator(nullptr), updatingSize(false),
+ : item(nullptr), object(nullptr), itemContext(nullptr), incubator(nullptr), updatingSize(false),
active(true), loadingFromSource(false), asynchronous(false)
{
}
@@ -111,11 +111,10 @@ void QQuickLoaderPrivate::clear()
QObject::disconnect(component, SIGNAL(progressChanged(qreal)),
q, SIGNAL(progressChanged()));
component->deleteLater();
- component = nullptr;
+ component.setObject(nullptr, q);
} else if (component) {
- component = nullptr;
+ component.setObject(nullptr, q);
}
- componentStrongReference.clear();
source = QUrl();
if (item) {
@@ -441,7 +440,7 @@ void QQuickLoader::loadFromSource()
if (isComponentComplete()) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
if (!d->component)
- d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
+ d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
d->load();
}
}
@@ -484,11 +483,7 @@ void QQuickLoader::setSourceComponent(QQmlComponent *comp)
d->clear();
- d->component = comp;
- if (comp) {
- if (QQmlData *ddata = QQmlData::get(comp))
- d->componentStrongReference = ddata->jsWrapper;
- }
+ d->component.setObject(comp, this);
d->loadingFromSource = false;
if (d->active)
@@ -832,7 +827,7 @@ void QQuickLoader::componentComplete()
if (d->loadingFromSource) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
if (!d->component)
- d->component = new QQmlComponent(qmlEngine(this), d->source, mode, this);
+ d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
}
d->load();
}
@@ -1007,7 +1002,7 @@ QUrl QQuickLoaderPrivate::resolveSourceUrl(QQmlV4Function *args)
QV4::ReturnedValue QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error)
{
QV4::Scope scope(args->v4engine());
- QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue());
+ QV4::ScopedValue valuemap(scope, QV4::Encode::undefined());
if (args->length() >= 2) {
QV4::ScopedValue v(scope, (*args)[1]);
if (!v->isObject() || v->as<QV4::ArrayObject>()) {
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index 7492527401..349b5c6c06 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -103,8 +103,7 @@ public:
QUrl source;
QQuickItem *item;
QObject *object;
- QQmlComponent *component;
- QV4::PersistentValue componentStrongReference; // To ensure GC doesn't delete components created by Qt.createComponent
+ QQmlStrongJSQObjectReference<QQmlComponent> component;
QQmlContext *itemContext;
QQuickLoaderIncubator *incubator;
QV4::PersistentValue initialPropertyValues;
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index b1438d7541..3eca535a67 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -610,6 +610,9 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
else { // QEvent::MouseButtonPress
addTouchPoint(me);
started = true;
+ _mouseQpaTouchPoint.setStartPos(me->localPos());
+ _mouseQpaTouchPoint.setStartScenePos(me->windowPos());
+ _mouseQpaTouchPoint.setStartScreenPos(me->screenPos());
_mouseQpaTouchPoint.setState(Qt::TouchPointPressed);
}
touchPoints << _mouseQpaTouchPoint;
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index f1550b4ac6..634ea1c2e2 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -185,8 +185,8 @@ private:
class QQuickGrabGestureEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints)
- Q_PROPERTY(qreal dragThreshold READ dragThreshold)
+ Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints CONSTANT)
+ Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT)
public:
QQuickGrabGestureEvent() : _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {}
diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h
index b057f4295d..ddc1fd99d9 100644
--- a/src/quick/items/qquickpainteditem.h
+++ b/src/quick/items/qquickpainteditem.h
@@ -71,6 +71,7 @@ public:
FastFBOResizing = 0x1
};
Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)
+ Q_FLAG(PerformanceHints)
void update(const QRect &rect = QRect());
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 55bafd9f83..512f59d799 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -900,11 +900,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
- positioner at the time of its creation. From \l {Qt Quick}{Qt Quick 2} onwards, positioners apply the
- \l populate transition to these items instead.
-
- \sa add, ViewTransition, {Qt Quick Examples - Positioners}
+ \sa add, populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick::Column::spacing
@@ -1089,11 +1085,7 @@ void QQuickColumn::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
- positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
- \l populate transition to these items instead.
-
- \sa add, ViewTransition, {Qt Quick Examples - Positioners}
+ \sa add, populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick::Row::spacing
@@ -1378,11 +1370,7 @@ void QQuickRow::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
- positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
- \l populate transition to these items instead.
-
- \sa add, ViewTransition, {Qt Quick Examples - Positioners}
+ \sa add, populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty qreal QtQuick::Grid::spacing
@@ -1974,11 +1962,7 @@ void QQuickGrid::reportConflictingAnchors()
cases, these lists will be empty. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note In \l {Qt Quick 1}, this transition was applied to all items that were part of the
- positioner at the time of its creation. From \l {Qt Quick}{QtQuick 2} onwards, positioners apply the
- \l populate transition to these items instead.
-
- \sa add, ViewTransition, {Qt Quick Examples - Positioners}
+ \sa add, populate, ViewTransition, {Qt Quick Examples - Positioners}
*/
/*!
\qmlproperty real QtQuick::Flow::spacing
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index bf030b9d80..5e217dcd0c 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -40,9 +40,13 @@
#include "qquickrectangle_p.h"
#include "qquickrectangle_p_p.h"
+#include <QtQml/qqmlinfo.h>
+
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qsgadaptationlayer_p.h>
+#include <private/qqmlmetatype_p.h>
+
#include <QtGui/qpixmapcache.h>
#include <QtCore/qmath.h>
#include <QtCore/qmetaobject.h>
@@ -219,10 +223,11 @@ void QQuickGradientStop::updateGradient()
of solid color fills or images. Consider using gradients for static items
in a user interface.
- In Qt 5.0, only vertical, linear gradients can be applied to items. If you
- need to apply different orientations of gradients, a combination of rotation
- and clipping will need to be applied to the relevant items. This can
- introduce additional performance requirements for your application.
+ Since Qt 5.12, vertical and horizontal linear gradients can be applied to items.
+ If you need to apply angled gradients, a combination of rotation and clipping
+ can be applied to the relevant items. Alternatively, consider using
+ QtQuick.Shapes::LinearGradient or QtGraphicalEffects::LinearGradient. These
+ approaches can all introduce additional performance requirements for your application.
The use of animations involving gradient stops may not give the desired
result. An alternative way to animate gradients is to use pre-generated
@@ -255,6 +260,28 @@ QQmlListProperty<QQuickGradientStop> QQuickGradient::stops()
return QQmlListProperty<QQuickGradientStop>(this, m_stops);
}
+/*!
+ \qmlproperty enumeration QtQuick::Gradient::orientation
+ \since 5.12
+
+ Set this property to define the direction of the gradient.
+ \list
+ \li Gradient.Vertical - a vertical gradient
+ \li Gradient.Horizontal - a horizontal gradient
+ \endlist
+
+ The default is Gradient.Vertical.
+*/
+void QQuickGradient::setOrientation(Orientation orientation)
+{
+ if (m_orientation == orientation)
+ return;
+
+ m_orientation = orientation;
+ emit orientationChanged();
+ emit updated();
+}
+
QGradientStops QQuickGradient::gradientStops() const
{
QGradientStops stops;
@@ -370,11 +397,11 @@ QQuickPen *QQuickRectangle::border()
}
/*!
- \qmlproperty Gradient QtQuick::Rectangle::gradient
+ \qmlproperty any QtQuick::Rectangle::gradient
The gradient to use to fill the rectangle.
- This property allows for the construction of simple vertical gradients.
+ This property allows for the construction of simple vertical or horizontal gradients.
Other gradients may be formed by adding rotation to the rectangle.
\div {class="float-left"}
@@ -384,37 +411,66 @@ QQuickPen *QQuickRectangle::border()
\snippet qml/rectangle/rectangle-gradient.qml rectangles
\clearfloat
+ The property also accepts gradient presets from QGradient::Preset. Note however
+ that due to Rectangle only supporting simple vertical or horizontal gradients,
+ any preset with an unsupported angle will revert to the closest representation.
+
+ \snippet qml/rectangle/rectangle-gradient.qml presets
+ \clearfloat
+
If both a gradient and a color are specified, the gradient will be used.
\sa Gradient, color
*/
-QQuickGradient *QQuickRectangle::gradient() const
+QJSValue QQuickRectangle::gradient() const
{
Q_D(const QQuickRectangle);
return d->gradient;
}
-void QQuickRectangle::setGradient(QQuickGradient *gradient)
+void QQuickRectangle::setGradient(const QJSValue &gradient)
{
Q_D(QQuickRectangle);
- if (d->gradient == gradient)
+ if (d->gradient.equals(gradient))
return;
- static int updatedSignalIdx = -1;
- if (updatedSignalIdx < 0)
- updatedSignalIdx = QMetaMethod::fromSignal(&QQuickGradient::updated).methodIndex();
+
+ static int updatedSignalIdx = QMetaMethod::fromSignal(&QQuickGradient::updated).methodIndex();
if (d->doUpdateSlotIdx < 0)
d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot("doUpdate()");
- if (d->gradient)
- QMetaObject::disconnect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
- d->gradient = gradient;
- if (d->gradient)
- QMetaObject::connect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
+
+ if (auto oldGradient = qobject_cast<QQuickGradient*>(d->gradient.toQObject()))
+ QMetaObject::disconnect(oldGradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
+
+ if (gradient.isQObject()) {
+ if (auto newGradient = qobject_cast<QQuickGradient*>(gradient.toQObject())) {
+ d->gradient = gradient;
+ QMetaObject::connect(newGradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
+ } else {
+ qmlWarning(this) << "Can't assign "
+ << QQmlMetaType::prettyTypeName(gradient.toQObject()) << " to gradient property";
+ d->gradient = QJSValue();
+ }
+ } else if (gradient.isNumber() || gradient.isString()) {
+ QGradient preset(gradient.toVariant().value<QGradient::Preset>());
+ if (preset.type() != QGradient::NoGradient) {
+ d->gradient = gradient;
+ } else {
+ qmlWarning(this) << "No such gradient preset '" << gradient.toString() << "'";
+ d->gradient = QJSValue();
+ }
+ } else if (gradient.isNull() || gradient.isUndefined()) {
+ d->gradient = gradient;
+ } else {
+ qmlWarning(this) << "Unknown gradient type. Expected int, string, or Gradient";
+ d->gradient = QJSValue();
+ }
+
update();
}
void QQuickRectangle::resetGradient()
{
- setGradient(nullptr);
+ setGradient(QJSValue());
}
/*!
@@ -510,10 +566,35 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
rectangle->setAntialiasing(antialiasing());
QGradientStops stops;
- if (d->gradient) {
- stops = d->gradient->gradientStops();
+ bool vertical = true;
+ if (d->gradient.isQObject()) {
+ auto gradient = qobject_cast<QQuickGradient*>(d->gradient.toQObject());
+ Q_ASSERT(gradient);
+ stops = gradient->gradientStops();
+ vertical = gradient->orientation() == QQuickGradient::Vertical;
+ } else if (d->gradient.isNumber() || d->gradient.isString()) {
+ QGradient preset(d->gradient.toVariant().value<QGradient::Preset>());
+ if (preset.type() == QGradient::LinearGradient) {
+ auto linearGradient = static_cast<QLinearGradient&>(preset);
+ const QPointF start = linearGradient.start();
+ const QPointF end = linearGradient.finalStop();
+ vertical = qAbs(start.y() - end.y()) >= qAbs(start.x() - end.x());
+ stops = linearGradient.stops();
+ if ((vertical && start.y() > end.y()) || (!vertical && start.x() > end.x())) {
+ // QSGInternalRectangleNode doesn't support stops in the wrong order,
+ // so we need to manually reverse them here.
+ QGradientStops reverseStops;
+ for (auto it = stops.rbegin(); it != stops.rend(); ++it) {
+ auto stop = *it;
+ stop.first = 1 - stop.first;
+ reverseStops.append(stop);
+ }
+ stops = reverseStops;
+ }
+ }
}
rectangle->setGradientStops(stops);
+ rectangle->setGradientVertical(vertical);
rectangle->update();
diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h
index c07ad835fb..d56a03d22d 100644
--- a/src/quick/items/qquickrectangle_p.h
+++ b/src/quick/items/qquickrectangle_p.h
@@ -119,24 +119,35 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGradient : public QObject
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QQuickGradientStop> stops READ stops)
+ Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged REVISION 12)
Q_CLASSINFO("DefaultProperty", "stops")
+ Q_ENUMS(QGradient::Preset)
public:
QQuickGradient(QObject *parent=nullptr);
~QQuickGradient() override;
+ enum Orientation { Vertical = Qt::Vertical,
+ Horizontal = Qt::Horizontal };
+ Q_ENUM(Orientation)
+
QQmlListProperty<QQuickGradientStop> stops();
+ Orientation orientation() const { return m_orientation; }
+ void setOrientation(Orientation orientation);
+
QGradientStops gradientStops() const;
Q_SIGNALS:
void updated();
+ void orientationChanged();
private:
void doUpdate();
private:
QList<QQuickGradientStop *> m_stops;
+ Orientation m_orientation = Vertical;
friend class QQuickRectangle;
friend class QQuickGradientStop;
};
@@ -147,7 +158,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRectangle : public QQuickItem
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(QQuickGradient *gradient READ gradient WRITE setGradient RESET resetGradient)
+ Q_PROPERTY(QJSValue gradient READ gradient WRITE setGradient RESET resetGradient)
Q_PROPERTY(QQuickPen * border READ border CONSTANT)
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
public:
@@ -158,8 +169,8 @@ public:
QQuickPen *border();
- QQuickGradient *gradient() const;
- void setGradient(QQuickGradient *gradient);
+ QJSValue gradient() const;
+ void setGradient(const QJSValue &gradient);
void resetGradient();
qreal radius() const;
diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h
index 3c1aaf7661..c7c5293f9b 100644
--- a/src/quick/items/qquickrectangle_p_p.h
+++ b/src/quick/items/qquickrectangle_p_p.h
@@ -73,7 +73,7 @@ public:
}
QColor color;
- QQuickGradient *gradient;
+ QJSValue gradient;
QQuickPen *pen;
qreal radius;
static int doUpdateSlotIdx;
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index fb1c6366f2..ec74660d96 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -187,7 +187,6 @@ void QQuickRenderControlPrivate::windowDestroyed()
{
if (window) {
rc->invalidate();
- QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
delete QQuickWindowPrivate::get(window)->animationController;
QQuickWindowPrivate::get(window)->animationController = nullptr;
@@ -392,6 +391,7 @@ QImage QQuickRenderControl::grab()
grabContent.setDevicePixelRatio(d->window->effectiveDevicePixelRatio());
}
#endif
+#if QT_CONFIG(thread)
} else if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::Software) {
QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window);
cd->polishItems();
@@ -409,6 +409,7 @@ QImage QQuickRenderControl::grab()
render();
softwareRenderer->setCurrentPaintDevice(prevDev);
}
+#endif
} else {
qWarning("QQuickRenderControl: grabs are not supported with the current Qt Quick backend");
}
diff --git a/src/quick/items/qquickscalegrid.cpp b/src/quick/items/qquickscalegrid.cpp
index d7a0f1b681..23f179be1d 100644
--- a/src/quick/items/qquickscalegrid.cpp
+++ b/src/quick/items/qquickscalegrid.cpp
@@ -66,6 +66,7 @@ void QQuickScaleGrid::setLeft(int pos)
{
if (_left != pos) {
_left = pos;
+ emit leftBorderChanged();
emit borderChanged();
}
}
@@ -74,6 +75,7 @@ void QQuickScaleGrid::setTop(int pos)
{
if (_top != pos) {
_top = pos;
+ emit topBorderChanged();
emit borderChanged();
}
}
@@ -82,6 +84,7 @@ void QQuickScaleGrid::setRight(int pos)
{
if (_right != pos) {
_right = pos;
+ emit rightBorderChanged();
emit borderChanged();
}
}
@@ -90,6 +93,7 @@ void QQuickScaleGrid::setBottom(int pos)
{
if (_bottom != pos) {
_bottom = pos;
+ emit bottomBorderChanged();
emit borderChanged();
}
}
diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h
index 5752f61e3f..f5187a8eea 100644
--- a/src/quick/items/qquickscalegrid_p_p.h
+++ b/src/quick/items/qquickscalegrid_p_p.h
@@ -65,10 +65,10 @@ class Q_AUTOTEST_EXPORT QQuickScaleGrid : public QObject
{
Q_OBJECT
- Q_PROPERTY(int left READ left WRITE setLeft NOTIFY borderChanged)
- Q_PROPERTY(int top READ top WRITE setTop NOTIFY borderChanged)
- Q_PROPERTY(int right READ right WRITE setRight NOTIFY borderChanged)
- Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY borderChanged)
+ Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftBorderChanged)
+ Q_PROPERTY(int top READ top WRITE setTop NOTIFY topBorderChanged)
+ Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightBorderChanged)
+ Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomBorderChanged)
public:
QQuickScaleGrid(QObject *parent=nullptr);
@@ -90,6 +90,10 @@ public:
Q_SIGNALS:
void borderChanged();
+ void leftBorderChanged();
+ void topBorderChanged();
+ void rightBorderChanged();
+ void bottomBorderChanged();
private:
int _left;
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index aea7e44a65..b057fd9d8f 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -396,24 +396,24 @@ void QQuickScreenInfo::setWrappedScreen(QScreen *screen)
if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
emit devicePixelRatioChanged();
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(widthChanged()));
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(heightChanged()));
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(virtualXChanged()));
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(virtualYChanged()));
- connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(orientationChanged()));
- connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(primaryOrientationChanged()));
- connect(screen, SIGNAL(virtualGeometryChanged(QRect)),
- this, SIGNAL(desktopGeometryChanged()));
- connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
- this, SIGNAL(logicalPixelDensityChanged()));
- connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
- this, SIGNAL(pixelDensityChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(geometryChanged(QRect)),
+ this, QQuickScreenInfo, SIGNAL(widthChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(geometryChanged(QRect)),
+ this, QQuickScreenInfo, SIGNAL(heightChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(geometryChanged(QRect)),
+ this, QQuickScreenInfo, SIGNAL(virtualXChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(geometryChanged(QRect)),
+ this, QQuickScreenInfo, SIGNAL(virtualYChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
+ this, QQuickScreenInfo, SIGNAL(orientationChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
+ this, QQuickScreenInfo, SIGNAL(primaryOrientationChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(virtualGeometryChanged(QRect)),
+ this, QQuickScreenInfo, SIGNAL(desktopGeometryChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(logicalDotsPerInchChanged(qreal)),
+ this, QQuickScreenInfo, SIGNAL(logicalPixelDensityChanged()));
+ qmlobject_connect(screen, QScreen, SIGNAL(physicalDotsPerInchChanged(qreal)),
+ this, QQuickScreenInfo, SIGNAL(pixelDensityChanged()));
}
QScreen *QQuickScreenInfo::wrappedScreen() const
@@ -473,11 +473,11 @@ int QQuickScreenAttached::angleBetween(int a, int b)
void QQuickScreenAttached::windowChanged(QQuickWindow* c)
{
if (m_window)
- disconnect(m_window, SIGNAL(screenChanged(QScreen*)), this, SLOT(screenChanged(QScreen*)));
+ qmlobject_disconnect(m_window, QQuickWindow, SIGNAL(screenChanged(QScreen*)), this, QQuickScreenAttached, SLOT(screenChanged(QScreen*)));
m_window = c;
screenChanged(c ? c->screen() : nullptr);
if (c)
- connect(c, SIGNAL(screenChanged(QScreen*)), this, SLOT(screenChanged(QScreen*)));
+ qmlobject_connect(c, QQuickWindow, SIGNAL(screenChanged(QScreen*)), this, QQuickScreenAttached, SLOT(screenChanged(QScreen*)));
}
void QQuickScreenAttached::screenChanged(QScreen *screen)
diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp
index 77b7cbc78d..804f548d21 100644
--- a/src/quick/items/qquickshadereffectmesh.cpp
+++ b/src/quick/items/qquickshadereffectmesh.cpp
@@ -64,6 +64,11 @@ QQuickShaderEffectMesh::QQuickShaderEffectMesh(QObject *parent)
{
}
+QQuickShaderEffectMesh::QQuickShaderEffectMesh(QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
/*!
\qmltype GridMesh
\instantiates QQuickGridMesh
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index 5d6641429a..62a9798e40 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -72,7 +72,7 @@ const char *qtTexCoordAttributeName();
class QSGGeometry;
class QRectF;
-class QQuickShaderEffectMesh : public QObject
+class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMesh : public QObject
{
Q_OBJECT
public:
@@ -87,9 +87,12 @@ public:
Q_SIGNALS:
// Emitted when the geometry needs to be updated.
void geometryChanged();
+
+protected:
+ QQuickShaderEffectMesh(QObjectPrivate &dd, QObject *parent = nullptr);
};
-class QQuickGridMesh : public QQuickShaderEffectMesh
+class Q_QUICK_PRIVATE_EXPORT QQuickGridMesh : public QQuickShaderEffectMesh
{
Q_OBJECT
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index da917683b6..d3944b4620 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -109,7 +109,7 @@ public:
virtual int variedDuration() const
{
- return qMax(qreal(0.0) , m_duration
+ return qMax(0.0 , m_duration
+ (m_durationVariation * QRandomGenerator::global()->bounded(2.0))
- m_durationVariation);
}
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
new file mode 100644
index 0000000000..2ae006be29
--- /dev/null
+++ b/src/quick/items/qquicktableview.cpp
@@ -0,0 +1,2024 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktableview_p.h"
+#include "qquicktableview_p_p.h"
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qdir.h>
+#include <QtQml/private/qqmldelegatemodel_p.h>
+#include <QtQml/private/qqmldelegatemodel_p_p.h>
+#include <QtQml/private/qqmlincubator_p.h>
+#include <QtQml/private/qqmlchangeset_p.h>
+#include <QtQml/qqmlinfo.h>
+
+#include <QtQuick/private/qquickflickable_p_p.h>
+#include <QtQuick/private/qquickitemviewfxitem_p_p.h>
+
+/*!
+ \qmltype TableView
+ \instantiates QQuickTableView
+ \inqmlmodule QtQuick
+ \ingroup qtquick-views
+ \inherits Flickable
+ \brief Provides a table view of items provided by the model.
+
+ A TableView has a \l model that defines the data to be displayed, and a
+ \l delegate that defines how the data should be displayed.
+
+ TableView inherits \l Flickable. This means that while the model can have
+ any number of rows and columns, only a subsection of the table is usually
+ visible inside the viewport. As soon as you flick, new rows and columns
+ enter the viewport, while old ones exit and are removed from the viewport.
+ The rows and columns that move out are reused for building the rows and columns
+ that move into the viewport. As such, the TableView support models of any
+ size without affecting performance.
+
+ A TableView displays data from models created from built-in QML types
+ such as ListModel and XmlListModel, which populates the first column only
+ in a TableView. To create models with multiple columns, create a model in
+ C++ that inherits QAbstractItemModel, and expose it to QML.
+
+ \section1 Example Usage
+
+ The following example shows how to create a model from C++ with multiple
+ columns:
+
+ \snippet qml/tableview/tablemodel.cpp 0
+
+ And then how to use it from QML:
+
+ \snippet qml/tableview/tablemodel.qml 0
+
+ \section1 Reusing items
+
+ TableView recycles delegate items by default, instead of instantiating from
+ the \l delegate whenever new rows and columns are flicked into view. This
+ can give a huge performance boost, depending on the complexity of the
+ delegate.
+
+ When an item is flicked out, it moves to the \e{reuse pool}, which is an
+ internal cache of unused items. When this happens, the \l TableView::pooled
+ signal is emitted to inform the item about it. Likewise, when the item is
+ moved back from the pool, the \l TableView::reused signal is emitted.
+
+ Any item properties that come from the model are updated when the
+ item is reused. This includes \c index, \c row, and \c column, but also
+ any model roles.
+
+ \note Avoid storing any state inside a delegate. If you do, reset it
+ manually on receiving the \l TableView::reused signal.
+
+ If an item has timers or animations, consider pausing them on receiving
+ the \l TableView::pooled signal. That way you avoid using the CPU resources
+ for items that are not visible. Likewise, if an item has resources that
+ cannot be reused, they could be freed up.
+
+ If you don't want to reuse items or if the \l delegate cannot support it,
+ you can set the \l reuseItems property to \c false.
+
+ \note While an item is in the pool, it might still be alive and respond
+ to connected signals and bindings.
+
+ The following example shows a delegate that animates a spinning rectangle. When
+ it is pooled, the animation is temporarily paused:
+
+ \snippet qml/tableview/reusabledelegate.qml 0
+
+ \section1 Row heights and column widths
+
+ When a new column is flicked into view, TableView will determine its width
+ by calling the \l columnWidthProvider function. TableView itself will never
+ store row height or column width, as it's designed to support large models
+ containing any number of rows and columns. Instead, it will ask the
+ application whenever it needs to know.
+
+ TableView uses the largest \c implicitWidth among the items as the column
+ width, unless the \l columnWidthProvider property is explicitly set. Once
+ the column width is found, all other items in the same column are resized
+ to this width, even if new items that are flicked in later have larger
+ \c implicitWidth. Setting an explicit \l width on an item is ignored and
+ overwritten.
+
+ \note The calculated width of a column is discarded when it is flicked out
+ of the viewport, and is recalculated if the column is flicked back in. The
+ calculation is always based on the items that are visible when the column
+ is flicked in. This means that it can end up different each time, depending
+ on which row you're at when the column enters. You should therefore have the
+ same \c implicitWidth for all items in a column, or set
+ \l columnWidthProvider. The same logic applies for the row height
+ calculation.
+
+ If you change the values that a \l rowHeightProvider or a
+ \l columnWidthProvider return for rows and columns inside the viewport, you
+ must call \l forceLayout. This informs TableView that it needs to use the
+ provider functions again to recalculate and update the layout.
+
+ \note The size of a row or column should be a whole number to avoid
+ sub-pixel alignment of items.
+
+ The following example shows how to set a simple \c columnWidthProvider
+ together with a timer that modifies the values the function returns. When
+ the array is modified, \l forceLayout is called to let the changes
+ take effect:
+
+ \snippet qml/tableview/tableviewwithprovider.qml 0
+
+ \section1 Overlays and underlays
+
+ Tableview inherits \l Flickable. And when new items are instantiated from the
+ delegate, it will parent them to the \l{Flickable::}{contentItem}
+ with a \c z value equal to \c 1. You can add your own items inside the
+ Tableview, as child items of the Flickable. By controlling their \c z
+ value, you can make them be on top of or underneath the table items.
+
+ Here is an example that shows how to add some text on top of the table, that
+ moves together with the table as you flick:
+
+ \snippet qml/tableview/tableviewwithheader.qml 0
+*/
+
+/*!
+ \qmlproperty int QtQuick::TableView::rows
+
+ This property holds the number of rows in the table. This is
+ equal to the number of rows in the model.
+
+ This property is read only.
+*/
+
+/*!
+ \qmlproperty int QtQuick::TableView::columns
+
+ This property holds the number of columns in the table. This is
+ equal to the number of columns in the model. If the model is
+ a list, columns will be 1.
+
+ This property is read only.
+*/
+
+/*!
+ \qmlproperty real QtQuick::TableView::rowSpacing
+
+ This property holds the spacing between the rows.
+
+ The default value is 0.
+*/
+
+/*!
+ \qmlproperty real QtQuick::TableView::columnSpacing
+
+ This property holds the spacing between the columns.
+
+ The default value is 0.
+*/
+
+/*!
+ \qmlproperty var QtQuick::TableView::rowHeightProvider
+
+ This property can hold a function that returns the row height for each row
+ in the model. When assigned, it will be called whenever TableView needs to
+ know the height of a specific row. The function takes one argument, \c row,
+ for which the TableView needs to know the height.
+
+ \note The height of a row must always be greater than \c 0.
+
+ \sa columnWidthProvider, {Row heights and column widths}
+*/
+
+/*!
+ \qmlproperty var QtQuick::TableView::columnWidthProvider
+
+ This property can hold a function that returns the column width for each
+ column in the model. When assigned, it is called whenever TableView needs
+ to know the width of a specific column. The function takes one argument,
+ \c column, for which the TableView needs to know the width.
+
+ \note The width of a column must always be greater than \c 0.
+
+ \sa rowHeightProvider, {Row heights and column widths}
+*/
+
+/*!
+ \qmlproperty model QtQuick::TableView::model
+ This property holds the model that provides data for the table.
+
+ The model provides the set of data that is used to create the items
+ in the view. Models can be created directly in QML using \l ListModel,
+ \l XmlListModel or \l VisualItemModel, or provided by a custom C++ model
+ class. If it is a C++ model, it must be a subclass of \l QAbstractItemModel
+ or a simple list.
+
+ \sa {qml-data-models}{Data Models}
+*/
+
+/*!
+ \qmlproperty Component QtQuick::TableView::delegate
+
+ The delegate provides a template defining each cell item instantiated by the
+ view. The model index is exposed as an accessible \c index property. The same
+ applies to \c row and \c column. Properties of the model are also available
+ depending upon the type of \l {qml-data-models}{Data Model}.
+
+ A delegate should specify its size using \l implicitWidth and \l implicitHeight.
+ The TableView lays out the items based on that information. Explicit \l width or
+ \l height settings are ignored and overwritten.
+
+ \note Delegates are instantiated as needed and may be destroyed at any time.
+ They are also reused if the \l reuseItems property is set to \c true. You
+ should therefore avoid storing state information in the delegates.
+
+ \sa {Row heights and column widths}, {Reusing items}
+*/
+
+/*!
+ \qmlproperty bool QtQuick::TableView::reuseItems
+
+ This property holds whether or not items instantiated from the \l delegate
+ should be reused. If set to \c false, any currently pooled items
+ are destroyed.
+
+ \sa {Reusing items}, TableView::pooled, TableView::reused
+*/
+
+/*!
+ \qmlproperty real QtQuick::TableView::contentWidth
+
+ This property holds the width of the \l contentView, which is also
+ the width of the table (including margins). As a TableView cannot
+ always know the exact width of the table without loading all columns
+ in the model, the \c contentWidth is usually an estimated width based on
+ the columns it has seen so far. This estimate is recalculated whenever
+ new columns are flicked into view, which means that the content width
+ can change dynamically.
+
+ If you know up front what the width of the table will be, assign a value
+ to \c contentWidth explicitly, to avoid unnecessary calculations and
+ updates to the TableView.
+
+ \sa contentHeight
+*/
+
+/*!
+ \qmlproperty real QtQuick::TableView::contentHeight
+
+ This property holds the height of the \l contentView, which is also
+ the height of the table (including margins). As a TableView cannot
+ always know the exact height of the table without loading all rows
+ in the model, the \c contentHeight is usually an estimated height
+ based on the rows it has seen so far. This estimate is recalculated
+ whenever new rows are flicked into view, which means that the content height
+ can change dynamically.
+
+ If you know up front what the height of the table will be, assign a
+ value to \c contentHeight explicitly, to avoid unnecessary calculations and
+ updates to the TableView.
+
+ \sa contentWidth
+*/
+
+/*!
+ \qmlmethod real QtQuick::TableView::forceLayout
+
+ Responding to changes in the model are batched so that they are handled
+ only once per frame. This means the TableView delays showing any changes
+ while a script is being run. The same is also true when changing
+ properties such as \l rowSpacing or \l leftMargin.
+
+ This method forces the TableView to immediately update the layout so
+ that any recent changes take effect.
+
+ Calling this function re-evaluates the size and position of each visible
+ row and column. This is needed if the functions assigned to
+ \l rowHeightProvider or \l columnWidthProvider return different values than
+ what is already assigned.
+*/
+
+/*!
+ \qmlattachedproperty TableView QtQuick::TableView::view
+
+ This attached property holds the view that manages the delegate instance.
+ It is attached to each instance of the delegate.
+*/
+
+/*!
+ \qmlattachedsignal QtQuick::TableView::pooled
+
+ This signal is emitted after an item has been added to the reuse
+ pool. You can use it to pause ongoing timers or animations inside
+ the item, or free up resources that cannot be reused.
+
+ This signal is emitted only if the \l reuseItems property is \c true.
+
+ \sa {Reusing items}, reuseItems, reused
+*/
+
+/*!
+ \qmlattachedsignal QtQuick::TableView::reused
+
+ This signal is emitted after an item has been reused. At this point, the
+ item has been taken out of the pool and placed inside the content view,
+ and the model properties such as index, row, and column have been updated.
+
+ Other properties that are not provided by the model does not change when an item
+ is reused. You should avoid storing any state inside a delegate, but if you do,
+ manually reset that state on receiving this signal.
+
+ This signal is emitted when the item is reused, and not the first time the
+ item is created.
+
+ This signal is emitted only if the \l reuseItems property is \c true.
+
+ \sa {Reusing items}, reuseItems, pooled
+*/
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcTableViewDelegateLifecycle, "qt.quick.tableview.lifecycle")
+
+#define Q_TABLEVIEW_UNREACHABLE(output) { dumpTable(); qWarning() << "output:" << output; Q_UNREACHABLE(); }
+#define Q_TABLEVIEW_ASSERT(cond, output) Q_ASSERT((cond) || [&](){ dumpTable(); qWarning() << "output:" << output; return false;}())
+
+static const Qt::Edge allTableEdges[] = { Qt::LeftEdge, Qt::RightEdge, Qt::TopEdge, Qt::BottomEdge };
+
+static QLine rectangleEdge(const QRect &rect, Qt::Edge tableEdge)
+{
+ switch (tableEdge) {
+ case Qt::LeftEdge:
+ return QLine(rect.topLeft(), rect.bottomLeft());
+ case Qt::RightEdge:
+ return QLine(rect.topRight(), rect.bottomRight());
+ case Qt::TopEdge:
+ return QLine(rect.topLeft(), rect.topRight());
+ case Qt::BottomEdge:
+ return QLine(rect.bottomLeft(), rect.bottomRight());
+ }
+ return QLine();
+}
+
+static QRect expandedRect(const QRect &rect, Qt::Edge edge, int increment)
+{
+ switch (edge) {
+ case Qt::LeftEdge:
+ return rect.adjusted(-increment, 0, 0, 0);
+ case Qt::RightEdge:
+ return rect.adjusted(0, 0, increment, 0);
+ case Qt::TopEdge:
+ return rect.adjusted(0, -increment, 0, 0);
+ case Qt::BottomEdge:
+ return rect.adjusted(0, 0, 0, increment);
+ }
+ return QRect();
+}
+
+const QPoint QQuickTableViewPrivate::kLeft = QPoint(-1, 0);
+const QPoint QQuickTableViewPrivate::kRight = QPoint(1, 0);
+const QPoint QQuickTableViewPrivate::kUp = QPoint(0, -1);
+const QPoint QQuickTableViewPrivate::kDown = QPoint(0, 1);
+
+QQuickTableViewPrivate::QQuickTableViewPrivate()
+ : QQuickFlickablePrivate()
+{
+}
+
+QQuickTableViewPrivate::~QQuickTableViewPrivate()
+{
+ releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ if (tableModel)
+ delete tableModel;
+}
+
+QString QQuickTableViewPrivate::tableLayoutToString() const
+{
+ return QString(QLatin1String("table cells: (%1,%2) -> (%3,%4), item count: %5, table rect: %6,%7 x %8,%9"))
+ .arg(loadedTable.topLeft().x()).arg(loadedTable.topLeft().y())
+ .arg(loadedTable.bottomRight().x()).arg(loadedTable.bottomRight().y())
+ .arg(loadedItems.count())
+ .arg(loadedTableOuterRect.x())
+ .arg(loadedTableOuterRect.y())
+ .arg(loadedTableOuterRect.width())
+ .arg(loadedTableOuterRect.height());
+}
+
+void QQuickTableViewPrivate::dumpTable() const
+{
+ auto listCopy = loadedItems.values();
+ std::stable_sort(listCopy.begin(), listCopy.end(),
+ [](const FxTableItem *lhs, const FxTableItem *rhs)
+ { return lhs->index < rhs->index; });
+
+ qWarning() << QStringLiteral("******* TABLE DUMP *******");
+ for (int i = 0; i < listCopy.count(); ++i)
+ qWarning() << static_cast<FxTableItem *>(listCopy.at(i))->cell;
+ qWarning() << tableLayoutToString();
+
+ const QString filename = QStringLiteral("QQuickTableView_dumptable_capture.png");
+ const QString path = QDir::current().absoluteFilePath(filename);
+ if (q_func()->window() && q_func()->window()->grabWindow().save(path))
+ qWarning() << "Window capture saved to:" << path;
+}
+
+QQuickTableViewAttached *QQuickTableViewPrivate::getAttachedObject(const QObject *object) const
+{
+ QObject *attachedObject = qmlAttachedPropertiesObject<QQuickTableView>(object);
+ return static_cast<QQuickTableViewAttached *>(attachedObject);
+}
+
+int QQuickTableViewPrivate::modelIndexAtCell(const QPoint &cell) const
+{
+ int availableRows = tableSize.height();
+ int modelIndex = cell.y() + (cell.x() * availableRows);
+ Q_TABLEVIEW_ASSERT(modelIndex < model->count(),
+ "modelIndex:" << modelIndex << "cell:" << cell << "count:" << model->count());
+ return modelIndex;
+}
+
+QPoint QQuickTableViewPrivate::cellAtModelIndex(int modelIndex) const
+{
+ int availableRows = tableSize.height();
+ Q_TABLEVIEW_ASSERT(availableRows > 0, availableRows);
+ int column = int(modelIndex / availableRows);
+ int row = modelIndex % availableRows;
+ return QPoint(column, row);
+}
+
+void QQuickTableViewPrivate::updateContentWidth()
+{
+ Q_Q(QQuickTableView);
+
+ if (explicitContentWidth.isValid()) {
+ // Don't calculate contentWidth when it
+ // was set explicitly by the application.
+ return;
+ }
+
+ const qreal thresholdBeforeAdjust = 0.1;
+ int currentRightColumn = loadedTable.right();
+
+ if (currentRightColumn > contentSizeBenchMarkPoint.x()) {
+ contentSizeBenchMarkPoint.setX(currentRightColumn);
+
+ const qreal spacing = currentRightColumn * cellSpacing.width();
+ qreal currentWidth = loadedTableOuterRect.right();
+ const qreal averageCellWidth = (currentWidth - spacing) / (currentRightColumn + 1);
+ qreal estimatedWidth = (tableSize.width() * (averageCellWidth + cellSpacing.width())) - cellSpacing.width();
+
+ if (currentRightColumn >= tableSize.width() - 1) {
+ // We are at the last column, and can set the exact width
+ if (!qFuzzyCompare(currentWidth, q->implicitWidth()))
+ q->QQuickFlickable::setContentWidth(currentWidth);
+ } else if (currentWidth >= q->implicitWidth()) {
+ // We are at the estimated width, but there are still more columns
+ q->QQuickFlickable::setContentWidth(estimatedWidth);
+ } else {
+ // Only set a new width if the new estimate is substantially different
+ qreal diff = 1 - (estimatedWidth / q->implicitWidth());
+ if (qAbs(diff) > thresholdBeforeAdjust)
+ q->QQuickFlickable::setContentWidth(estimatedWidth);
+ }
+ }
+}
+
+void QQuickTableViewPrivate::updateContentHeight()
+{
+ Q_Q(QQuickTableView);
+
+ if (explicitContentHeight.isValid()) {
+ // Don't calculate contentHeight when it
+ // was set explicitly by the application.
+ return;
+ }
+
+ const qreal thresholdBeforeAdjust = 0.1;
+ int currentBottomRow = loadedTable.bottom();
+
+ if (currentBottomRow > contentSizeBenchMarkPoint.y()) {
+ contentSizeBenchMarkPoint.setY(currentBottomRow);
+
+ const qreal spacing = currentBottomRow * cellSpacing.height();
+ qreal currentHeight = loadedTableOuterRect.bottom();
+ const qreal averageCellHeight = (currentHeight - spacing) / (currentBottomRow + 1);
+ qreal estimatedHeight = (tableSize.height() * (averageCellHeight + cellSpacing.height())) - cellSpacing.height();
+
+ if (currentBottomRow >= tableSize.height() - 1) {
+ // We are at the last row, and can set the exact height
+ if (!qFuzzyCompare(currentHeight, q->implicitHeight()))
+ q->QQuickFlickable::setContentHeight(currentHeight);
+ } else if (currentHeight >= q->implicitHeight()) {
+ // We are at the estimated height, but there are still more rows
+ q->QQuickFlickable::setContentHeight(estimatedHeight);
+ } else {
+ // Only set a new height if the new estimate is substantially different
+ qreal diff = 1 - (estimatedHeight / q->implicitHeight());
+ if (qAbs(diff) > thresholdBeforeAdjust)
+ q->QQuickFlickable::setContentHeight(estimatedHeight);
+ }
+ }
+}
+
+void QQuickTableViewPrivate::enforceTableAtOrigin()
+{
+ // Gaps before the first row/column can happen if rows/columns
+ // changes size while flicking e.g because of spacing changes or
+ // changes to a column maxWidth/row maxHeight. Check for this, and
+ // move the whole table rect accordingly.
+ bool layoutNeeded = false;
+ const qreal flickMargin = 50;
+
+ if (loadedTable.x() == 0 && loadedTableOuterRect.x() > 0) {
+ // The table is at the beginning, but not at the edge of the
+ // content view. So move the table to origin.
+ loadedTableOuterRect.moveLeft(0);
+ layoutNeeded = true;
+ } else if (loadedTableOuterRect.x() < 0) {
+ // The table is outside the beginning of the content view. Move
+ // the whole table inside, and make some room for flicking.
+ loadedTableOuterRect.moveLeft(loadedTable.x() == 0 ? 0 : flickMargin);
+ layoutNeeded = true;
+ }
+
+ if (loadedTable.y() == 0 && loadedTableOuterRect.y() > 0) {
+ loadedTableOuterRect.moveTop(0);
+ layoutNeeded = true;
+ } else if (loadedTableOuterRect.y() < 0) {
+ loadedTableOuterRect.moveTop(loadedTable.y() == 0 ? 0 : flickMargin);
+ layoutNeeded = true;
+ }
+
+ if (layoutNeeded) {
+ qCDebug(lcTableViewDelegateLifecycle);
+ relayoutTableItems();
+ }
+}
+
+void QQuickTableViewPrivate::updateAverageEdgeSize()
+{
+ int bottomCell = loadedTable.bottom();
+ int rightCell = loadedTable.right();
+ qreal accRowSpacing = bottomCell * cellSpacing.height();
+ qreal accColumnSpacing = rightCell * cellSpacing.width();
+ averageEdgeSize.setHeight((loadedTableOuterRect.bottom() - accRowSpacing) / (bottomCell + 1));
+ averageEdgeSize.setWidth((loadedTableOuterRect.right() - accColumnSpacing) / (rightCell + 1));
+}
+
+void QQuickTableViewPrivate::syncLoadedTableRectFromLoadedTable()
+{
+ QRectF topLeftRect = loadedTableItem(loadedTable.topLeft())->geometry();
+ QRectF bottomRightRect = loadedTableItem(loadedTable.bottomRight())->geometry();
+ loadedTableOuterRect = topLeftRect.united(bottomRightRect);
+ loadedTableInnerRect = QRectF(topLeftRect.bottomRight(), bottomRightRect.topLeft());
+}
+
+void QQuickTableViewPrivate::syncLoadedTableFromLoadRequest()
+{
+ if (loadRequest.edge() == Qt::Edge(0)) {
+ // No edge means we're loading the top-left item
+ loadedTable = QRect(loadRequest.firstCell(), loadRequest.lastCell());
+ return;
+ }
+
+ switch (loadRequest.edge()) {
+ case Qt::LeftEdge:
+ case Qt::TopEdge:
+ loadedTable.setTopLeft(loadRequest.firstCell());
+ break;
+ case Qt::RightEdge:
+ case Qt::BottomEdge:
+ loadedTable.setBottomRight(loadRequest.lastCell());
+ break;
+ }
+}
+
+FxTableItem *QQuickTableViewPrivate::itemNextTo(const FxTableItem *fxTableItem, const QPoint &direction) const
+{
+ return loadedTableItem(fxTableItem->cell + direction);
+}
+
+FxTableItem *QQuickTableViewPrivate::loadedTableItem(const QPoint &cell) const
+{
+ const int modelIndex = modelIndexAtCell(cell);
+ Q_TABLEVIEW_ASSERT(loadedItems.contains(modelIndex), modelIndex << cell);
+ return loadedItems.value(modelIndex);
+}
+
+FxTableItem *QQuickTableViewPrivate::createFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode)
+{
+ Q_Q(QQuickTableView);
+
+ bool ownItem = false;
+ int modelIndex = modelIndexAtCell(cell);
+
+ QObject* object = model->object(modelIndex, incubationMode);
+ if (!object) {
+ if (model->incubationStatus(modelIndex) == QQmlIncubator::Loading) {
+ // Item is incubating. Return nullptr for now, and let the table call this
+ // function again once we get a callback to itemCreatedCallback().
+ return nullptr;
+ }
+
+ qWarning() << "TableView: failed loading index:" << modelIndex;
+ object = new QQuickItem();
+ ownItem = true;
+ }
+
+ QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
+ if (!item) {
+ // The model could not provide an QQuickItem for the
+ // given index, so we create a placeholder instead.
+ qWarning() << "TableView: delegate is not an item:" << modelIndex;
+ model->release(object);
+ item = new QQuickItem();
+ ownItem = true;
+ } else {
+ QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors;
+ if (anchors && anchors->activeDirections())
+ qmlWarning(item) << "TableView: detected anchors on delegate with index: " << modelIndex
+ << ". Use implicitWidth and implicitHeight instead.";
+ }
+
+ if (ownItem) {
+ // Parent item is normally set early on from initItemCallback (to
+ // allow bindings to the parent property). But if we created the item
+ // within this function, we need to set it explicit.
+ item->setImplicitWidth(kDefaultColumnWidth);
+ item->setImplicitHeight(kDefaultRowHeight);
+ item->setParentItem(q->contentItem());
+ }
+ Q_TABLEVIEW_ASSERT(item->parentItem() == q->contentItem(), item->parentItem());
+
+ FxTableItem *fxTableItem = new FxTableItem(item, q, ownItem);
+ fxTableItem->setVisible(false);
+ fxTableItem->cell = cell;
+ fxTableItem->index = modelIndex;
+ return fxTableItem;
+}
+
+FxTableItem *QQuickTableViewPrivate::loadFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode)
+{
+#ifdef QT_DEBUG
+ // Since TableView needs to work flawlessly when e.g incubating inside an async
+ // loader, being able to override all loading to async while debugging can be helpful.
+ static const bool forcedAsync = forcedIncubationMode == QLatin1String("async");
+ if (forcedAsync)
+ incubationMode = QQmlIncubator::Asynchronous;
+#endif
+
+ // Note that even if incubation mode is asynchronous, the item might
+ // be ready immediately since the model has a cache of items.
+ QBoolBlocker guard(blockItemCreatedCallback);
+ auto item = createFxTableItem(cell, incubationMode);
+ qCDebug(lcTableViewDelegateLifecycle) << cell << "ready?" << bool(item);
+ return item;
+}
+
+void QQuickTableViewPrivate::releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag) {
+ // Make a copy and clear the list of items first to avoid destroyed
+ // items being accessed during the loop (QTBUG-61294)
+ auto const tmpList = loadedItems;
+ loadedItems.clear();
+ for (FxTableItem *item : tmpList)
+ releaseItem(item, reusableFlag);
+}
+
+void QQuickTableViewPrivate::releaseItem(FxTableItem *fxTableItem, QQmlTableInstanceModel::ReusableFlag reusableFlag)
+{
+ Q_Q(QQuickTableView);
+ auto item = fxTableItem->item;
+ Q_TABLEVIEW_ASSERT(item, fxTableItem->index);
+
+ if (fxTableItem->ownItem) {
+ delete item;
+ } else {
+ // Only QQmlTableInstanceModel supports reusing items
+ auto releaseFlag = tableModel ?
+ tableModel->release(item, reusableFlag) :
+ model->release(item);
+
+ if (releaseFlag != QQmlInstanceModel::Destroyed) {
+ // When items are not destroyed, it typically means that the
+ // item is reused, or that the model is an ObjectModel. If
+ // so, we just hide the item instead.
+ fxTableItem->setVisible(false);
+
+ // If the item (or a descendant) has focus, remove it, so
+ // that the item doesn't enter with focus when it's reused.
+ if (QQuickWindow *window = item->window()) {
+ const auto focusItem = qobject_cast<QQuickItem *>(window->focusObject());
+ if (focusItem) {
+ const bool hasFocus = item == focusItem || item->isAncestorOf(focusItem);
+ if (hasFocus) {
+ const auto focusChild = QQuickItemPrivate::get(q)->subFocusItem;
+ QQuickWindowPrivate::get(window)->clearFocusInScope(q, focusChild, Qt::OtherFocusReason);
+ }
+ }
+ }
+ }
+ }
+
+ delete fxTableItem;
+}
+
+void QQuickTableViewPrivate::unloadItem(const QPoint &cell)
+{
+ const int modelIndex = modelIndexAtCell(cell);
+ Q_TABLEVIEW_ASSERT(loadedItems.contains(modelIndex), modelIndex << cell);
+ releaseItem(loadedItems.take(modelIndex), reusableFlag);
+}
+
+void QQuickTableViewPrivate::unloadItems(const QLine &items)
+{
+ qCDebug(lcTableViewDelegateLifecycle) << items;
+
+ if (items.dx()) {
+ int y = items.p1().y();
+ for (int x = items.p1().x(); x <= items.p2().x(); ++x)
+ unloadItem(QPoint(x, y));
+ } else {
+ int x = items.p1().x();
+ for (int y = items.p1().y(); y <= items.p2().y(); ++y)
+ unloadItem(QPoint(x, y));
+ }
+}
+
+bool QQuickTableViewPrivate::canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const
+{
+ switch (tableEdge) {
+ case Qt::LeftEdge:
+ if (loadedTable.topLeft().x() == 0)
+ return false;
+ return loadedTableOuterRect.left() > fillRect.left() + cellSpacing.width();
+ case Qt::RightEdge:
+ if (loadedTable.bottomRight().x() >= tableSize.width() - 1)
+ return false;
+ return loadedTableOuterRect.right() < fillRect.right() - cellSpacing.width();
+ case Qt::TopEdge:
+ if (loadedTable.topLeft().y() == 0)
+ return false;
+ return loadedTableOuterRect.top() > fillRect.top() + cellSpacing.height();
+ case Qt::BottomEdge:
+ if (loadedTable.bottomRight().y() >= tableSize.height() - 1)
+ return false;
+ return loadedTableOuterRect.bottom() < fillRect.bottom() - cellSpacing.height();
+ }
+
+ return false;
+}
+
+bool QQuickTableViewPrivate::canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const
+{
+ // Note: if there is only one row or column left, we cannot unload, since
+ // they are needed as anchor point for further layouting.
+ switch (tableEdge) {
+ case Qt::LeftEdge:
+ if (loadedTable.width() <= 1)
+ return false;
+ return loadedTableInnerRect.left() <= fillRect.left();
+ case Qt::RightEdge:
+ if (loadedTable.width() <= 1)
+ return false;
+ return loadedTableInnerRect.right() >= fillRect.right();
+ case Qt::TopEdge:
+ if (loadedTable.height() <= 1)
+ return false;
+ return loadedTableInnerRect.top() <= fillRect.top();
+ case Qt::BottomEdge:
+ if (loadedTable.height() <= 1)
+ return false;
+ return loadedTableInnerRect.bottom() >= fillRect.bottom();
+ }
+ Q_TABLEVIEW_UNREACHABLE(tableEdge);
+ return false;
+}
+
+Qt::Edge QQuickTableViewPrivate::nextEdgeToLoad(const QRectF rect)
+{
+ for (Qt::Edge edge : allTableEdges) {
+ if (canLoadTableEdge(edge, rect))
+ return edge;
+ }
+ return Qt::Edge(0);
+}
+
+Qt::Edge QQuickTableViewPrivate::nextEdgeToUnload(const QRectF rect)
+{
+ for (Qt::Edge edge : allTableEdges) {
+ if (canUnloadTableEdge(edge, rect))
+ return edge;
+ }
+ return Qt::Edge(0);
+}
+
+qreal QQuickTableViewPrivate::cellWidth(const QPoint& cell)
+{
+ // Using an items width directly is not an option, since we change
+ // it during layout (which would also cause problems when recycling items).
+ auto const cellItem = loadedTableItem(cell)->item;
+ return cellItem->implicitWidth();
+}
+
+qreal QQuickTableViewPrivate::cellHeight(const QPoint& cell)
+{
+ // Using an items height directly is not an option, since we change
+ // it during layout (which would also cause problems when recycling items).
+ auto const cellItem = loadedTableItem(cell)->item;
+ return cellItem->implicitHeight();
+}
+
+qreal QQuickTableViewPrivate::sizeHintForColumn(int column)
+{
+ // Find the widest cell in the column, and return its width
+ qreal columnWidth = 0;
+ for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row)
+ columnWidth = qMax(columnWidth, cellWidth(QPoint(column, row)));
+
+ return columnWidth;
+}
+
+qreal QQuickTableViewPrivate::sizeHintForRow(int row)
+{
+ // Find the highest cell in the row, and return its height
+ qreal rowHeight = 0;
+ for (int column = loadedTable.left(); column <= loadedTable.right(); ++column)
+ rowHeight = qMax(rowHeight, cellHeight(QPoint(column, row)));
+
+ return rowHeight;
+}
+
+void QQuickTableViewPrivate::calculateTableSize()
+{
+ // tableSize is the same as row and column count, and will always
+ // be the same as the number of rows and columns in the model.
+ Q_Q(QQuickTableView);
+ QSize prevTableSize = tableSize;
+
+ if (tableModel)
+ tableSize = QSize(tableModel->columns(), tableModel->rows());
+ else if (model)
+ tableSize = QSize(1, model->count());
+ else
+ tableSize = QSize(0, 0);
+
+ if (prevTableSize.width() != tableSize.width())
+ emit q->columnsChanged();
+ if (prevTableSize.height() != tableSize.height())
+ emit q->rowsChanged();
+}
+
+qreal QQuickTableViewPrivate::resolveColumnWidth(int column)
+{
+ Q_TABLEVIEW_ASSERT(column >= loadedTable.left() && column <= loadedTable.right(), column);
+ qreal columnWidth = -1;
+
+ if (!columnWidthProvider.isUndefined()) {
+ if (columnWidthProvider.isCallable()) {
+ auto const columnAsArgument = QJSValueList() << QJSValue(column);
+ columnWidth = columnWidthProvider.call(columnAsArgument).toNumber();
+ if (qIsNaN(columnWidth) || columnWidth <= 0) {
+ // The column width needs to be greater than 0, otherwise we never reach the edge
+ // while loading/refilling columns. This would cause the application to hang.
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "columnWidthProvider did not return a valid width for column: " << column;
+ }
+ columnWidth = kDefaultColumnWidth;
+ }
+ } else {
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "columnWidthProvider doesn't contain a function";
+ }
+ columnWidth = kDefaultColumnWidth;
+ }
+ } else {
+ // If columnWidthProvider is left unspecified, we just iterate over the currently visible items in
+ // the column. The downside of doing that, is that the column width will then only be based
+ // on the implicit width of the currently loaded items (which can be different depending on
+ // which row you're at when the column is flicked in). The upshot is that you don't have to
+ // bother setting columnWidthProvider for small tables, or if the implicit width doesn't vary.
+ columnWidth = sizeHintForColumn(column);
+ if (qIsNaN(columnWidth) || columnWidth <= 0) {
+ // The column width needs to be greater than 0, otherwise we never reach the edge
+ // while loading/refilling columns. This would cause the application to hang.
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "the delegate's implicitWidth needs to be greater than zero";
+ }
+ columnWidth = kDefaultColumnWidth;
+ }
+ }
+
+ return columnWidth;
+}
+
+qreal QQuickTableViewPrivate::resolveRowHeight(int row)
+{
+ Q_TABLEVIEW_ASSERT(row >= loadedTable.top() && row <= loadedTable.bottom(), row);
+ qreal rowHeight = -1;
+
+ if (!rowHeightProvider.isUndefined()) {
+ if (rowHeightProvider.isCallable()) {
+ auto const rowAsArgument = QJSValueList() << QJSValue(row);
+ rowHeight = rowHeightProvider.call(rowAsArgument).toNumber();
+ if (qIsNaN(rowHeight) || rowHeight <= 0) {
+ // The row height needs to be greater than 0, otherwise we never reach the edge
+ // while loading/refilling rows. This would cause the application to hang.
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "rowHeightProvider did not return a valid height for row: " << row;
+ }
+ rowHeight = kDefaultRowHeight;
+ }
+ } else {
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "rowHeightProvider doesn't contain a function";
+ }
+ rowHeight = kDefaultRowHeight;
+ }
+ } else {
+ // If rowHeightProvider is left unspecified, we just iterate over the currently visible items in
+ // the row. The downside of doing that, is that the row height will then only be based
+ // on the implicit height of the currently loaded items (which can be different depending on
+ // which column you're at when the row is flicked in). The upshot is that you don't have to
+ // bother setting rowHeightProvider for small tables, or if the implicit height doesn't vary.
+ rowHeight = sizeHintForRow(row);
+ if (qIsNaN(rowHeight) || rowHeight <= 0) {
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "the delegate's implicitHeight needs to be greater than zero";
+ }
+ rowHeight = kDefaultRowHeight;
+ }
+ }
+
+ return rowHeight;
+}
+
+void QQuickTableViewPrivate::relayoutTable()
+{
+ relayoutTableItems();
+ syncLoadedTableRectFromLoadedTable();
+ enforceTableAtOrigin();
+ contentSizeBenchMarkPoint = QPoint(-1, -1);
+ updateContentWidth();
+ updateContentHeight();
+ // Return back to updatePolish to loadAndUnloadVisibleEdges()
+ // since the re-layout might have caused some edges to be pushed
+ // out, while others might have been pushed in.
+}
+
+void QQuickTableViewPrivate::relayoutTableItems()
+{
+ qCDebug(lcTableViewDelegateLifecycle);
+ columnRowPositionsInvalid = false;
+
+ qreal nextColumnX = loadedTableOuterRect.x();
+ qreal nextRowY = loadedTableOuterRect.y();
+
+ for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ // Adjust the geometry of all cells in the current column
+ const qreal width = resolveColumnWidth(column);
+
+ for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ auto item = loadedTableItem(QPoint(column, row));
+ QRectF geometry = item->geometry();
+ geometry.moveLeft(nextColumnX);
+ geometry.setWidth(width);
+ item->setGeometry(geometry);
+ }
+
+ nextColumnX += width + cellSpacing.width();
+ }
+
+ for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ // Adjust the geometry of all cells in the current row
+ const qreal height = resolveRowHeight(row);
+
+ for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ auto item = loadedTableItem(QPoint(column, row));
+ QRectF geometry = item->geometry();
+ geometry.moveTop(nextRowY);
+ geometry.setHeight(height);
+ item->setGeometry(geometry);
+ }
+
+ nextRowY += height + cellSpacing.height();
+ }
+
+ if (Q_UNLIKELY(lcTableViewDelegateLifecycle().isDebugEnabled())) {
+ for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ QPoint cell = QPoint(column, row);
+ qCDebug(lcTableViewDelegateLifecycle()) << "relayout item:" << cell << loadedTableItem(cell)->geometry();
+ }
+ }
+ }
+}
+
+void QQuickTableViewPrivate::layoutVerticalEdge(Qt::Edge tableEdge)
+{
+ int column = (tableEdge == Qt::LeftEdge) ? loadedTable.left() : loadedTable.right();
+ QPoint neighbourDirection = (tableEdge == Qt::LeftEdge) ? kRight : kLeft;
+ qreal width = resolveColumnWidth(column);
+
+ for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ auto fxTableItem = loadedTableItem(QPoint(column, row));
+ auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
+
+ QRectF geometry = fxTableItem->geometry();
+ geometry.setWidth(width);
+ geometry.setHeight(neighbourItem->geometry().height());
+ qreal left = tableEdge == Qt::LeftEdge ?
+ neighbourItem->geometry().left() - cellSpacing.width() - geometry.width() :
+ neighbourItem->geometry().right() + cellSpacing.width();
+
+ geometry.moveLeft(left);
+ geometry.moveTop(neighbourItem->geometry().top());
+
+ fxTableItem->setGeometry(geometry);
+ fxTableItem->setVisible(true);
+
+ qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(column, row) << fxTableItem->geometry();
+ }
+}
+
+void QQuickTableViewPrivate::layoutHorizontalEdge(Qt::Edge tableEdge)
+{
+ int row = (tableEdge == Qt::TopEdge) ? loadedTable.top() : loadedTable.bottom();
+ QPoint neighbourDirection = (tableEdge == Qt::TopEdge) ? kDown : kUp;
+ qreal height = resolveRowHeight(row);
+
+ for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ auto fxTableItem = loadedTableItem(QPoint(column, row));
+ auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
+
+ QRectF geometry = fxTableItem->geometry();
+ geometry.setWidth(neighbourItem->geometry().width());
+ geometry.setHeight(height);
+ qreal top = tableEdge == Qt::TopEdge ?
+ neighbourItem->geometry().top() - cellSpacing.height() - geometry.height() :
+ neighbourItem->geometry().bottom() + cellSpacing.height();
+
+ geometry.moveTop(top);
+ geometry.moveLeft(neighbourItem->geometry().left());
+
+ fxTableItem->setGeometry(geometry);
+ fxTableItem->setVisible(true);
+
+ qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(column, row) << fxTableItem->geometry();
+ }
+}
+
+void QQuickTableViewPrivate::layoutTopLeftItem()
+{
+ const QPoint cell = loadRequest.firstCell();
+ auto topLeftItem = loadedTableItem(cell);
+ auto item = topLeftItem->item;
+
+ item->setPosition(loadRequest.startPosition());
+ item->setSize(QSizeF(resolveColumnWidth(cell.x()), resolveRowHeight(cell.y())));
+ topLeftItem->setVisible(true);
+ qCDebug(lcTableViewDelegateLifecycle) << "geometry:" << topLeftItem->geometry();
+}
+
+void QQuickTableViewPrivate::layoutTableEdgeFromLoadRequest()
+{
+ if (loadRequest.edge() == Qt::Edge(0)) {
+ // No edge means we're loading the top-left item
+ layoutTopLeftItem();
+ return;
+ }
+
+ switch (loadRequest.edge()) {
+ case Qt::LeftEdge:
+ case Qt::RightEdge:
+ layoutVerticalEdge(loadRequest.edge());
+ break;
+ case Qt::TopEdge:
+ case Qt::BottomEdge:
+ layoutHorizontalEdge(loadRequest.edge());
+ break;
+ }
+}
+
+void QQuickTableViewPrivate::cancelLoadRequest()
+{
+ loadRequest.markAsDone();
+ model->cancel(modelIndexAtCell(loadRequest.currentCell()));
+
+ if (rebuildScheduled) {
+ // No reason to rollback already loaded edge items
+ // since we anyway are about to reload all items.
+ return;
+ }
+
+ if (loadRequest.atBeginning()) {
+ // No items have yet been loaded, so nothing to unload
+ return;
+ }
+
+ QLine rollbackItems;
+ rollbackItems.setP1(loadRequest.firstCell());
+ rollbackItems.setP2(loadRequest.previousCell());
+ qCDebug(lcTableViewDelegateLifecycle()) << "rollback:" << rollbackItems << tableLayoutToString();
+ unloadItems(rollbackItems);
+}
+
+void QQuickTableViewPrivate::processLoadRequest()
+{
+ Q_TABLEVIEW_ASSERT(loadRequest.isActive(), "");
+
+ while (loadRequest.hasCurrentCell()) {
+ QPoint cell = loadRequest.currentCell();
+ FxTableItem *fxTableItem = loadFxTableItem(cell, loadRequest.incubationMode());
+
+ if (!fxTableItem) {
+ // Requested item is not yet ready. Just leave, and wait for this
+ // function to be called again when the item is ready.
+ return;
+ }
+
+ loadedItems.insert(modelIndexAtCell(cell), fxTableItem);
+ loadRequest.moveToNextCell();
+ }
+
+ qCDebug(lcTableViewDelegateLifecycle()) << "all items loaded!";
+
+ syncLoadedTableFromLoadRequest();
+ layoutTableEdgeFromLoadRequest();
+ syncLoadedTableRectFromLoadedTable();
+
+ if (rebuildState == RebuildState::Done) {
+ enforceTableAtOrigin();
+ updateContentWidth();
+ updateContentHeight();
+ drainReusePoolAfterLoadRequest();
+ }
+
+ loadRequest.markAsDone();
+
+ qCDebug(lcTableViewDelegateLifecycle()) << "request completed! Table:" << tableLayoutToString();
+}
+
+void QQuickTableViewPrivate::processRebuildTable()
+{
+ moveToNextRebuildState();
+
+ if (rebuildState == RebuildState::LoadInitalTable) {
+ beginRebuildTable();
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ if (rebuildState == RebuildState::VerifyTable) {
+ if (loadedItems.isEmpty()) {
+ qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model or no delegate";
+ rebuildState = RebuildState::Done;
+ return;
+ }
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ if (rebuildState == RebuildState::LayoutTable) {
+ layoutAfterLoadingInitialTable();
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ if (rebuildState == RebuildState::LoadAndUnloadAfterLayout) {
+ loadAndUnloadVisibleEdges();
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ const bool preload = (rebuildOptions & RebuildOption::All
+ && reusableFlag == QQmlTableInstanceModel::Reusable);
+
+ if (rebuildState == RebuildState::PreloadColumns) {
+ if (preload && loadedTable.right() < tableSize.width() - 1)
+ loadEdge(Qt::RightEdge, QQmlIncubator::AsynchronousIfNested);
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ if (rebuildState == RebuildState::PreloadRows) {
+ if (preload && loadedTable.bottom() < tableSize.height() - 1)
+ loadEdge(Qt::BottomEdge, QQmlIncubator::AsynchronousIfNested);
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ if (rebuildState == RebuildState::MovePreloadedItemsToPool) {
+ while (Qt::Edge edge = nextEdgeToUnload(viewportRect))
+ unloadEdge(edge);
+ if (!moveToNextRebuildState())
+ return;
+ }
+
+ Q_TABLEVIEW_ASSERT(rebuildState == RebuildState::Done, int(rebuildState));
+}
+
+bool QQuickTableViewPrivate::moveToNextRebuildState()
+{
+ if (loadRequest.isActive()) {
+ // Items are still loading async, which means
+ // that the current state is not yet done.
+ return false;
+ }
+ rebuildState = RebuildState(int(rebuildState) + 1);
+ qCDebug(lcTableViewDelegateLifecycle()) << int(rebuildState);
+ return true;
+}
+
+void QQuickTableViewPrivate::beginRebuildTable()
+{
+ if (loadRequest.isActive())
+ cancelLoadRequest();
+
+ calculateTableSize();
+
+ QPoint topLeft;
+ QPointF topLeftPos;
+
+ if (rebuildOptions & RebuildOption::All) {
+ qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::All";
+ releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ } else if (rebuildOptions & RebuildOption::ViewportOnly) {
+ qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::ViewportOnly";
+ releaseLoadedItems(reusableFlag);
+
+ if (rebuildOptions & RebuildOption::CalculateNewTopLeftRow) {
+ const int newRow = int(viewportRect.y() / (averageEdgeSize.height() + cellSpacing.height()));
+ topLeft.ry() = qBound(0, newRow, tableSize.height() - 1);
+ topLeftPos.ry() = topLeft.y() * (averageEdgeSize.height() + cellSpacing.height());
+ } else {
+ topLeft.ry() = qBound(0, loadedTable.topLeft().y(), tableSize.height() - 1);
+ topLeftPos.ry() = loadedTableOuterRect.topLeft().y();
+ }
+ if (rebuildOptions & RebuildOption::CalculateNewTopLeftColumn) {
+ const int newColumn = int(viewportRect.x() / (averageEdgeSize.width() + cellSpacing.width()));
+ topLeft.rx() = qBound(0, newColumn, tableSize.width() - 1);
+ topLeftPos.rx() = topLeft.x() * (averageEdgeSize.width() + cellSpacing.width());
+ } else {
+ topLeft.rx() = qBound(0, loadedTable.topLeft().x(), tableSize.width() - 1);
+ topLeftPos.rx() = loadedTableOuterRect.topLeft().x();
+ }
+ } else {
+ Q_TABLEVIEW_UNREACHABLE(rebuildOptions);
+ }
+
+ loadedTable = QRect();
+ loadedTableOuterRect = QRect();
+ loadedTableInnerRect = QRect();
+ contentSizeBenchMarkPoint = QPoint(-1, -1);
+ columnRowPositionsInvalid = false;
+
+ loadInitialTopLeftItem(topLeft, topLeftPos);
+ loadAndUnloadVisibleEdges();
+}
+
+void QQuickTableViewPrivate::layoutAfterLoadingInitialTable()
+{
+ if (rowHeightProvider.isUndefined() || columnWidthProvider.isUndefined()) {
+ // Since we don't have both size providers, we need to calculate the
+ // size of each row and column based on the size of the delegate items.
+ // This couldn't be done while we were loading the initial rows and
+ // columns, since during the process, we didn't have all the items
+ // available yet for the calculation. So we do it now.
+ relayoutTable();
+ }
+
+ updateAverageEdgeSize();
+ updateContentWidth();
+ updateContentHeight();
+}
+
+void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos)
+{
+ Q_TABLEVIEW_ASSERT(loadedItems.isEmpty(), "");
+
+ if (tableSize.isEmpty())
+ return;
+
+ if (model->count() == 0)
+ return;
+
+ if (tableModel && !tableModel->delegate())
+ return;
+
+ // Load top-left item. After loaded, loadItemsInsideRect() will take
+ // care of filling out the rest of the table.
+ loadRequest.begin(cell, pos, QQmlIncubator::AsynchronousIfNested);
+ processLoadRequest();
+}
+
+void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge)
+{
+ unloadItems(rectangleEdge(loadedTable, edge));
+ loadedTable = expandedRect(loadedTable, edge, -1);
+ syncLoadedTableRectFromLoadedTable();
+ qCDebug(lcTableViewDelegateLifecycle) << tableLayoutToString();
+}
+
+void QQuickTableViewPrivate::loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode)
+{
+ QLine cellsToLoad = rectangleEdge(expandedRect(loadedTable, edge, 1), edge);
+ loadRequest.begin(cellsToLoad, edge, incubationMode);
+ processLoadRequest();
+}
+
+void QQuickTableViewPrivate::loadAndUnloadVisibleEdges()
+{
+ // Unload table edges that have been moved outside the visible part of the
+ // table (including buffer area), and load new edges that has been moved inside.
+ // Note: an important point is that we always keep the table rectangular
+ // and without holes to reduce complexity (we never leave the table in
+ // a half-loaded state, or keep track of multiple patches).
+ // We load only one edge (row or column) at a time. This is especially
+ // important when loading into the buffer, since we need to be able to
+ // cancel the buffering quickly if the user starts to flick, and then
+ // focus all further loading on the edges that are flicked into view.
+
+ if (loadRequest.isActive()) {
+ // Don't start loading more edges while we're
+ // already waiting for another one to load.
+ return;
+ }
+
+ if (loadedItems.isEmpty()) {
+ // We need at least the top-left item to be loaded before we can
+ // start loading edges around it. Not having a top-left item at
+ // this point means that the model is empty (or no delegate).
+ return;
+ }
+
+ bool tableModified;
+
+ do {
+ tableModified = false;
+
+ if (Qt::Edge edge = nextEdgeToUnload(viewportRect)) {
+ tableModified = true;
+ unloadEdge(edge);
+ }
+
+ if (Qt::Edge edge = nextEdgeToLoad(viewportRect)) {
+ tableModified = true;
+ loadEdge(edge, QQmlIncubator::AsynchronousIfNested);
+ if (loadRequest.isActive())
+ return;
+ }
+ } while (tableModified);
+
+}
+
+void QQuickTableViewPrivate::drainReusePoolAfterLoadRequest()
+{
+ Q_Q(QQuickTableView);
+
+ if (reusableFlag == QQmlTableInstanceModel::NotReusable || !tableModel)
+ return;
+
+ if (!qFuzzyIsNull(q->verticalOvershoot()) || !qFuzzyIsNull(q->horizontalOvershoot())) {
+ // Don't drain while we're overshooting, since this will fill up the
+ // pool, but we expect to reuse them all once the content item moves back.
+ return;
+ }
+
+ // When loading edges, we don't want to drain the reuse pool too aggressively. Normally,
+ // all the items in the pool are reused rapidly as the content view is flicked around
+ // anyway. Even if the table is temporarily flicked to a section that contains fewer
+ // cells than what used to be (e.g if the flicked-in rows are taller than average), it
+ // still makes sense to keep all the items in circulation; Chances are, that soon enough,
+ // thinner rows are flicked back in again (meaning that we can fit more items into the
+ // view). But at the same time, if a delegate chooser is in use, the pool might contain
+ // items created from different delegates. And some of those delegates might be used only
+ // occasionally. So to avoid situations where an item ends up in the pool for too long, we
+ // call drain after each load request, but with a sufficiently large pool time. (If an item
+ // in the pool has a large pool time, it means that it hasn't been reused for an equal
+ // amount of load cycles, and should be released).
+ //
+ // We calculate an appropriate pool time by figuring out what the minimum time must be to
+ // not disturb frequently reused items. Since the number of items in a row might be higher
+ // than in a column (or vice versa), the minimum pool time should take into account that
+ // you might be flicking out a single row (filling up the pool), before you continue
+ // flicking in several new columns (taking them out again, but now in smaller chunks). This
+ // will increase the number of load cycles items are kept in the pool (poolTime), but still,
+ // we shouldn't release them, as they are still being reused frequently.
+ // To get a flexible maxValue (that e.g tolerates rows and columns being flicked
+ // in with varying sizes, causing some items not to be resued immediately), we multiply the
+ // value by 2. Note that we also add an extra +1 to the column count, because the number of
+ // visible columns will fluctuate between +1/-1 while flicking.
+ const int w = loadedTable.width();
+ const int h = loadedTable.height();
+ const int minTime = int(std::ceil(w > h ? qreal(w + 1) / h : qreal(h + 1) / w));
+ const int maxTime = minTime * 2;
+ tableModel->drainReusableItemsPool(maxTime);
+}
+
+void QQuickTableViewPrivate::scheduleRebuildTable(RebuildOptions options) {
+ if (!q_func()->isComponentComplete()) {
+ // We'll rebuild the table once complete anyway
+ return;
+ }
+
+ rebuildScheduled = true;
+ scheduledRebuildOptions |= options;
+ q_func()->polish();
+}
+
+void QQuickTableViewPrivate::invalidateColumnRowPositions() {
+ columnRowPositionsInvalid = true;
+ q_func()->polish();
+}
+
+void QQuickTableViewPrivate::updatePolish()
+{
+ // Whenever something changes, e.g viewport moves, spacing is set to a
+ // new value, model changes etc, this function will end up being called. Here
+ // we check what needs to be done, and load/unload cells accordingly.
+
+ Q_TABLEVIEW_ASSERT(!polishing, "recursive updatePolish() calls are not allowed!");
+ QBoolBlocker polishGuard(polishing, true);
+
+ if (loadRequest.isActive()) {
+ // We're currently loading items async to build a new edge in the table. We see the loading
+ // as an atomic operation, which means that we don't continue doing anything else until all
+ // items have been received and laid out. Note that updatePolish is then called once more
+ // after the loadRequest has completed to handle anything that might have occurred in-between.
+ return;
+ }
+
+ if (rebuildState != RebuildState::Done) {
+ processRebuildTable();
+ return;
+ }
+
+ syncWithPendingChanges();
+
+ if (rebuildState == RebuildState::Begin) {
+ processRebuildTable();
+ return;
+ }
+
+ if (loadedItems.isEmpty())
+ return;
+
+ if (columnRowPositionsInvalid)
+ relayoutTable();
+
+ loadAndUnloadVisibleEdges();
+}
+
+void QQuickTableViewPrivate::fixup(QQuickFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent)
+{
+ if (rebuildScheduled || rebuildState != RebuildState::Done)
+ return;
+
+ QQuickFlickablePrivate::fixup(data, minExtent, maxExtent);
+}
+
+void QQuickTableViewPrivate::createWrapperModel()
+{
+ Q_Q(QQuickTableView);
+ // When the assigned model is not an instance model, we create a wrapper
+ // model (QQmlTableInstanceModel) that keeps a pointer to both the
+ // assigned model and the assigned delegate. This model will give us a
+ // common interface to any kind of model (js arrays, QAIM, number etc), and
+ // help us create delegate instances.
+ tableModel = new QQmlTableInstanceModel(qmlContext(q));
+ model = tableModel;
+}
+
+void QQuickTableViewPrivate::itemCreatedCallback(int modelIndex, QObject*)
+{
+ if (blockItemCreatedCallback)
+ return;
+
+ qCDebug(lcTableViewDelegateLifecycle) << "item done loading:"
+ << cellAtModelIndex(modelIndex);
+
+ // Since the item we waited for has finished incubating, we can
+ // continue with the load request. processLoadRequest will
+ // ask the model for the requested item once more, which will be
+ // quick since the model has cached it.
+ processLoadRequest();
+ loadAndUnloadVisibleEdges();
+ updatePolish();
+}
+
+void QQuickTableViewPrivate::initItemCallback(int modelIndex, QObject *object)
+{
+ Q_UNUSED(modelIndex);
+ Q_Q(QQuickTableView);
+
+ if (auto item = qmlobject_cast<QQuickItem*>(object)) {
+ item->setParentItem(q->contentItem());
+ item->setZ(1);
+ }
+
+ if (auto attached = getAttachedObject(object))
+ attached->setView(q);
+}
+
+void QQuickTableViewPrivate::itemPooledCallback(int modelIndex, QObject *object)
+{
+ Q_UNUSED(modelIndex);
+
+ if (auto attached = getAttachedObject(object))
+ emit attached->pooled();
+}
+
+void QQuickTableViewPrivate::itemReusedCallback(int modelIndex, QObject *object)
+{
+ Q_UNUSED(modelIndex);
+
+ if (auto attached = getAttachedObject(object))
+ emit attached->reused();
+}
+
+void QQuickTableViewPrivate::syncWithPendingChanges()
+{
+ // The application can change properties like the model or the delegate while
+ // we're e.g in the middle of e.g loading a new row. Since this will lead to
+ // unpredicted behavior, and possibly a crash, we need to postpone taking
+ // such assignments into effect until we're in a state that allows it.
+ Q_Q(QQuickTableView);
+ viewportRect = QRectF(q->contentX(), q->contentY(), q->width(), q->height());
+ syncRebuildOptions();
+ syncModel();
+ syncDelegate();
+}
+
+void QQuickTableViewPrivate::syncRebuildOptions()
+{
+ if (!rebuildScheduled)
+ return;
+
+ rebuildState = RebuildState::Begin;
+ rebuildOptions = scheduledRebuildOptions;
+ scheduledRebuildOptions = RebuildOption::None;
+ rebuildScheduled = false;
+}
+
+void QQuickTableViewPrivate::syncDelegate()
+{
+ if (tableModel && assignedDelegate == tableModel->delegate())
+ return;
+
+ if (!tableModel)
+ createWrapperModel();
+
+ tableModel->setDelegate(assignedDelegate);
+}
+
+void QQuickTableViewPrivate::syncModel()
+{
+ if (modelVariant == assignedModel)
+ return;
+
+ if (model)
+ disconnectFromModel();
+
+ modelVariant = assignedModel;
+ QVariant effectiveModelVariant = modelVariant;
+ if (effectiveModelVariant.userType() == qMetaTypeId<QJSValue>())
+ effectiveModelVariant = effectiveModelVariant.value<QJSValue>().toVariant();
+
+ const auto instanceModel = qobject_cast<QQmlInstanceModel *>(qvariant_cast<QObject*>(effectiveModelVariant));
+
+ if (instanceModel) {
+ if (tableModel) {
+ delete tableModel;
+ tableModel = nullptr;
+ }
+ model = instanceModel;
+ } else {
+ if (!tableModel)
+ createWrapperModel();
+ tableModel->setModel(effectiveModelVariant);
+ }
+
+ connectToModel();
+}
+
+void QQuickTableViewPrivate::connectToModel()
+{
+ Q_TABLEVIEW_ASSERT(model, "");
+
+ QObjectPrivate::connect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
+ QObjectPrivate::connect(model, &QQmlInstanceModel::initItem, this, &QQuickTableViewPrivate::initItemCallback);
+
+ if (tableModel) {
+ QObjectPrivate::connect(tableModel, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
+ QObjectPrivate::connect(tableModel, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
+ }
+
+ if (auto const aim = model->abstractItemModel()) {
+ // When the model exposes a QAIM, we connect to it directly. This means that if the current model is
+ // a QQmlDelegateModel, we just ignore all the change sets it emits. In most cases, the model will instead
+ // be our own QQmlTableInstanceModel, which doesn't bother creating change sets at all. For models that are
+ // not based on QAIM (like QQmlObjectModel, QQmlListModel, javascript arrays etc), there is currently no way
+ // to modify the model at runtime without also re-setting the model on the view.
+ connect(aim, &QAbstractItemModel::rowsMoved, this, &QQuickTableViewPrivate::rowsMovedCallback);
+ connect(aim, &QAbstractItemModel::columnsMoved, this, &QQuickTableViewPrivate::columnsMovedCallback);
+ connect(aim, &QAbstractItemModel::rowsInserted, this, &QQuickTableViewPrivate::rowsInsertedCallback);
+ connect(aim, &QAbstractItemModel::rowsRemoved, this, &QQuickTableViewPrivate::rowsRemovedCallback);
+ connect(aim, &QAbstractItemModel::columnsInserted, this, &QQuickTableViewPrivate::columnsInsertedCallback);
+ connect(aim, &QAbstractItemModel::columnsRemoved, this, &QQuickTableViewPrivate::columnsRemovedCallback);
+ connect(aim, &QAbstractItemModel::modelReset, this, &QQuickTableViewPrivate::modelResetCallback);
+ } else {
+ QObjectPrivate::connect(model, &QQmlInstanceModel::modelUpdated, this, &QQuickTableViewPrivate::modelUpdated);
+ }
+}
+
+void QQuickTableViewPrivate::disconnectFromModel()
+{
+ Q_TABLEVIEW_ASSERT(model, "");
+
+ QObjectPrivate::disconnect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
+ QObjectPrivate::disconnect(model, &QQmlInstanceModel::initItem, this, &QQuickTableViewPrivate::initItemCallback);
+
+ if (tableModel) {
+ QObjectPrivate::disconnect(tableModel, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
+ QObjectPrivate::disconnect(tableModel, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
+ }
+
+ if (auto const aim = model->abstractItemModel()) {
+ disconnect(aim, &QAbstractItemModel::rowsMoved, this, &QQuickTableViewPrivate::rowsMovedCallback);
+ disconnect(aim, &QAbstractItemModel::columnsMoved, this, &QQuickTableViewPrivate::columnsMovedCallback);
+ disconnect(aim, &QAbstractItemModel::rowsInserted, this, &QQuickTableViewPrivate::rowsInsertedCallback);
+ disconnect(aim, &QAbstractItemModel::rowsRemoved, this, &QQuickTableViewPrivate::rowsRemovedCallback);
+ disconnect(aim, &QAbstractItemModel::columnsInserted, this, &QQuickTableViewPrivate::columnsInsertedCallback);
+ disconnect(aim, &QAbstractItemModel::columnsRemoved, this, &QQuickTableViewPrivate::columnsRemovedCallback);
+ disconnect(aim, &QAbstractItemModel::modelReset, this, &QQuickTableViewPrivate::modelResetCallback);
+ } else {
+ QObjectPrivate::disconnect(model, &QQmlInstanceModel::modelUpdated, this, &QQuickTableViewPrivate::modelUpdated);
+ }
+}
+
+void QQuickTableViewPrivate::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
+{
+ Q_UNUSED(changeSet);
+ Q_UNUSED(reset);
+
+ Q_TABLEVIEW_ASSERT(!model->abstractItemModel(), "");
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::rowsMovedCallback(const QModelIndex &parent, int, int, const QModelIndex &, int )
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::columnsMovedCallback(const QModelIndex &parent, int, int, const QModelIndex &, int)
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::rowsInsertedCallback(const QModelIndex &parent, int, int)
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::rowsRemovedCallback(const QModelIndex &parent, int, int)
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::columnsInsertedCallback(const QModelIndex &parent, int, int)
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::columnsRemovedCallback(const QModelIndex &parent, int, int)
+{
+ if (parent != QModelIndex())
+ return;
+
+ scheduleRebuildTable(RebuildOption::ViewportOnly);
+}
+
+void QQuickTableViewPrivate::modelResetCallback()
+{
+ scheduleRebuildTable(RebuildOption::All);
+}
+
+QQuickTableView::QQuickTableView(QQuickItem *parent)
+ : QQuickFlickable(*(new QQuickTableViewPrivate), parent)
+{
+ setFlag(QQuickItem::ItemIsFocusScope);
+}
+
+int QQuickTableView::rows() const
+{
+ return d_func()->tableSize.height();
+}
+
+int QQuickTableView::columns() const
+{
+ return d_func()->tableSize.width();
+}
+
+qreal QQuickTableView::rowSpacing() const
+{
+ return d_func()->cellSpacing.height();
+}
+
+void QQuickTableView::setRowSpacing(qreal spacing)
+{
+ Q_D(QQuickTableView);
+ if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0)
+ return;
+ if (qFuzzyCompare(d->cellSpacing.height(), spacing))
+ return;
+
+ d->cellSpacing.setHeight(spacing);
+ d->invalidateColumnRowPositions();
+ emit rowSpacingChanged();
+}
+
+qreal QQuickTableView::columnSpacing() const
+{
+ return d_func()->cellSpacing.width();
+}
+
+void QQuickTableView::setColumnSpacing(qreal spacing)
+{
+ Q_D(QQuickTableView);
+ if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0)
+ return;
+ if (qFuzzyCompare(d->cellSpacing.width(), spacing))
+ return;
+
+ d->cellSpacing.setWidth(spacing);
+ d->invalidateColumnRowPositions();
+ emit columnSpacingChanged();
+}
+
+QJSValue QQuickTableView::rowHeightProvider() const
+{
+ return d_func()->rowHeightProvider;
+}
+
+void QQuickTableView::setRowHeightProvider(QJSValue provider)
+{
+ Q_D(QQuickTableView);
+ if (provider.strictlyEquals(d->rowHeightProvider))
+ return;
+
+ d->rowHeightProvider = provider;
+ d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::ViewportOnly);
+ emit rowHeightProviderChanged();
+}
+
+QJSValue QQuickTableView::columnWidthProvider() const
+{
+ return d_func()->columnWidthProvider;
+}
+
+void QQuickTableView::setColumnWidthProvider(QJSValue provider)
+{
+ Q_D(QQuickTableView);
+ if (provider.strictlyEquals(d->columnWidthProvider))
+ return;
+
+ d->columnWidthProvider = provider;
+ d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::ViewportOnly);
+ emit columnWidthProviderChanged();
+}
+
+QVariant QQuickTableView::model() const
+{
+ return d_func()->assignedModel;
+}
+
+void QQuickTableView::setModel(const QVariant &newModel)
+{
+ Q_D(QQuickTableView);
+ if (newModel == d->assignedModel)
+ return;
+
+ d->assignedModel = newModel;
+ d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::All);
+ emit modelChanged();
+}
+
+QQmlComponent *QQuickTableView::delegate() const
+{
+ return d_func()->assignedDelegate;
+}
+
+void QQuickTableView::setDelegate(QQmlComponent *newDelegate)
+{
+ Q_D(QQuickTableView);
+ if (newDelegate == d->assignedDelegate)
+ return;
+
+ d->assignedDelegate = newDelegate;
+ d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::All);
+
+ emit delegateChanged();
+}
+
+bool QQuickTableView::reuseItems() const
+{
+ return bool(d_func()->reusableFlag == QQmlTableInstanceModel::Reusable);
+}
+
+void QQuickTableView::setReuseItems(bool reuse)
+{
+ Q_D(QQuickTableView);
+ if (reuseItems() == reuse)
+ return;
+
+ d->reusableFlag = reuse ? QQmlTableInstanceModel::Reusable : QQmlTableInstanceModel::NotReusable;
+
+ if (!reuse && d->tableModel) {
+ // When we're told to not reuse items, we
+ // immediately, as documented, drain the pool.
+ d->tableModel->drainReusableItemsPool(0);
+ }
+
+ emit reuseItemsChanged();
+}
+
+void QQuickTableView::setContentWidth(qreal width)
+{
+ Q_D(QQuickTableView);
+ d->explicitContentWidth = width;
+ QQuickFlickable::setContentWidth(width);
+}
+
+void QQuickTableView::setContentHeight(qreal height)
+{
+ Q_D(QQuickTableView);
+ d->explicitContentHeight = height;
+ QQuickFlickable::setContentHeight(height);
+}
+
+void QQuickTableView::forceLayout()
+{
+ Q_D(QQuickTableView);
+ d->columnRowPositionsInvalid = true;
+
+ if (d->polishing) {
+ qWarning() << "TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!";
+ polish();
+ return;
+ }
+
+ d->updatePolish();
+}
+
+QQuickTableViewAttached *QQuickTableView::qmlAttachedProperties(QObject *obj)
+{
+ return new QQuickTableViewAttached(obj);
+}
+
+void QQuickTableView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickTableView);
+ QQuickFlickable::geometryChanged(newGeometry, oldGeometry);
+
+ if (d->tableModel) {
+ // When the view changes size, we force the pool to
+ // shrink by releasing all pooled items.
+ d->tableModel->drainReusableItemsPool(0);
+ }
+
+ polish();
+}
+
+void QQuickTableView::viewportMoved(Qt::Orientations orientation)
+{
+ Q_D(QQuickTableView);
+ QQuickFlickable::viewportMoved(orientation);
+
+ QQuickTableViewPrivate::RebuildOptions options = QQuickTableViewPrivate::RebuildOption::None;
+
+ // Check the viewport moved more than one page vertically
+ if (!d->viewportRect.intersects(QRectF(d->viewportRect.x(), contentY(), 1, height())))
+ options |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow;
+ // Check the viewport moved more than one page horizontally
+ if (!d->viewportRect.intersects(QRectF(contentX(), d->viewportRect.y(), width(), 1)))
+ options |= QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftColumn;
+
+ if (options) {
+ // When the viewport has moved more than one page vertically or horizontally, we switch
+ // strategy from refilling edges around the current table to instead rebuild the table
+ // from scratch inside the new viewport. This will greatly improve performance when flicking
+ // a long distance in one go, which can easily happen when dragging on scrollbars.
+ options |= QQuickTableViewPrivate::RebuildOption::ViewportOnly;
+ d->scheduleRebuildTable(options);
+ }
+
+ if (d->rebuildScheduled) {
+ // No reason to do anything, since we're about to rebuild the whole table anyway.
+ // Besides, calling updatePolish, which will start the rebuild, can easily cause
+ // binding loops to happen since we usually end up modifying the geometry of the
+ // viewport (contentItem) as well.
+ return;
+ }
+
+ // Calling polish() will schedule a polish event. But while the user is flicking, several
+ // mouse events will be handled before we get an updatePolish() call. And the updatePolish()
+ // call will only see the last mouse position. This results in a stuttering flick experience
+ // (especially on windows). We improve on this by calling updatePolish() directly. But this
+ // has the pitfall that we open up for recursive callbacks. E.g while inside updatePolish(), we
+ // load/unload items, and emit signals. The application can listen to those signals and set a
+ // new contentX/Y on the flickable. So we need to guard for this, to avoid unexpected behavior.
+ if (d->polishing)
+ polish();
+ else
+ d->updatePolish();
+}
+
+void QQuickTableViewPrivate::_q_componentFinalized()
+{
+ // Now that all bindings are evaluated, and we know
+ // our final geometery, we can build the table.
+ qCDebug(lcTableViewDelegateLifecycle);
+ updatePolish();
+}
+
+void QQuickTableViewPrivate::registerCallbackWhenBindingsAreEvaluated()
+{
+ // componentComplete() is called on us after all static values have been assigned, but
+ // before bindings to any anchestors has been evaluated. Especially this means that
+ // if our size is bound to the parents size, it will still be empty at that point.
+ // And we cannot build the table without knowing our own size. We could wait until we
+ // got the first updatePolish() callback, but at that time, any asynchronous loaders that we
+ // might be inside have already finished loading, which means that we would load all
+ // the delegate items synchronously instead of asynchronously. We therefore add a componentFinalized
+ // function that gets called after all the bindings we rely on has been evaluated.
+ // When receiving this call, we load the delegate items (and build the table).
+ Q_Q(QQuickTableView);
+ QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(q));
+ static int finalizedIdx = -1;
+ if (finalizedIdx < 0)
+ finalizedIdx = q->metaObject()->indexOfSlot("_q_componentFinalized()");
+ engPriv->registerFinalizeCallback(q, finalizedIdx);
+}
+
+void QQuickTableView::componentComplete()
+{
+ QQuickFlickable::componentComplete();
+ d_func()->registerCallbackWhenBindingsAreEvaluated();
+}
+
+#include "moc_qquicktableview_p.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
new file mode 100644
index 0000000000..9fcd4c6c17
--- /dev/null
+++ b/src/quick/items/qquicktableview_p.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTABLEVIEW_P_H
+#define QQUICKTABLEVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qtquickglobal_p.h>
+QT_REQUIRE_CONFIG(quick_tableview);
+
+#include <QtCore/qpointer.h>
+#include <QtQuick/private/qtquickglobal_p.h>
+#include <QtQuick/private/qquickflickable_p.h>
+#include <QtQml/private/qqmlnullablevalue_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickTableViewAttached;
+class QQuickTableViewPrivate;
+
+class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int rows READ rows NOTIFY rowsChanged)
+ Q_PROPERTY(int columns READ columns NOTIFY columnsChanged)
+ Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
+ Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
+ Q_PROPERTY(QJSValue rowHeightProvider READ rowHeightProvider WRITE setRowHeightProvider NOTIFY rowHeightProviderChanged)
+ Q_PROPERTY(QJSValue columnWidthProvider READ columnWidthProvider WRITE setColumnWidthProvider NOTIFY columnWidthProviderChanged)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged)
+ Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentWidth NOTIFY contentHeightChanged)
+
+public:
+ QQuickTableView(QQuickItem *parent = nullptr);
+
+ int rows() const;
+ int columns() const;
+
+ qreal rowSpacing() const;
+ void setRowSpacing(qreal spacing);
+
+ qreal columnSpacing() const;
+ void setColumnSpacing(qreal spacing);
+
+ QJSValue rowHeightProvider() const;
+ void setRowHeightProvider(QJSValue provider);
+
+ QJSValue columnWidthProvider() const;
+ void setColumnWidthProvider(QJSValue provider);
+
+ QVariant model() const;
+ void setModel(const QVariant &newModel);
+
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *);
+
+ bool reuseItems() const;
+ void setReuseItems(bool reuseItems);
+
+ void setContentWidth(qreal width);
+ void setContentHeight(qreal height);
+
+ Q_INVOKABLE void forceLayout();
+
+ static QQuickTableViewAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void rowsChanged();
+ void columnsChanged();
+ void rowSpacingChanged();
+ void columnSpacingChanged();
+ void rowHeightProviderChanged();
+ void columnWidthProviderChanged();
+ void modelChanged();
+ void delegateChanged();
+ void reuseItemsChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void viewportMoved(Qt::Orientations orientation) override;
+ void componentComplete() override;
+
+private:
+ Q_DISABLE_COPY(QQuickTableView)
+ Q_DECLARE_PRIVATE(QQuickTableView)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_componentFinalized())
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickTableViewAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuickTableView *view READ view NOTIFY viewChanged)
+
+public:
+ QQuickTableViewAttached(QObject *parent)
+ : QObject(parent) {}
+
+ QQuickTableView *view() const { return m_view; }
+ void setView(QQuickTableView *newTableView) {
+ if (newTableView == m_view)
+ return;
+ m_view = newTableView;
+ Q_EMIT viewChanged();
+ }
+
+Q_SIGNALS:
+ void viewChanged();
+ void pooled();
+ void reused();
+
+private:
+ QPointer<QQuickTableView> m_view;
+
+ friend class QQuickTableViewPrivate;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickTableView)
+QML_DECLARE_TYPEINFO(QQuickTableView, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QQUICKTABLEVIEW_P_H
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
new file mode 100644
index 0000000000..a4f829addd
--- /dev/null
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTABLEVIEW_P_P_H
+#define QQUICKTABLEVIEW_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquicktableview_p.h"
+
+#include <QtCore/qtimer.h>
+#include <QtQml/private/qqmltableinstancemodel_p.h>
+#include <QtQml/private/qqmlincubator_p.h>
+#include <QtQml/private/qqmlchangeset_p.h>
+#include <QtQml/qqmlinfo.h>
+
+#include <QtQuick/private/qquickflickable_p_p.h>
+#include <QtQuick/private/qquickitemviewfxitem_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(lcTableViewDelegateLifecycle)
+
+static const qreal kDefaultRowHeight = 50;
+static const qreal kDefaultColumnWidth = 50;
+
+class FxTableItem;
+
+class Q_QML_AUTOTEST_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickTableView)
+
+public:
+ class TableEdgeLoadRequest
+ {
+ // Whenever we need to load new rows or columns in the
+ // table, we fill out a TableEdgeLoadRequest.
+ // TableEdgeLoadRequest is just a struct that keeps track
+ // of which cells that needs to be loaded, and which cell
+ // the table is currently loading. The loading itself is
+ // done by QQuickTableView.
+
+ public:
+ void begin(const QPoint &cell, const QPointF &pos, QQmlIncubator::IncubationMode incubationMode)
+ {
+ Q_ASSERT(!active);
+ active = true;
+ tableEdge = Qt::Edge(0);
+ tableCells = QLine(cell, cell);
+ mode = incubationMode;
+ cellCount = 1;
+ currentIndex = 0;
+ startPos = pos;
+ qCDebug(lcTableViewDelegateLifecycle()) << "begin top-left:" << toString();
+ }
+
+ void begin(const QLine cellsToLoad, Qt::Edge edgeToLoad, QQmlIncubator::IncubationMode incubationMode)
+ {
+ Q_ASSERT(!active);
+ active = true;
+ tableEdge = edgeToLoad;
+ tableCells = cellsToLoad;
+ mode = incubationMode;
+ cellCount = tableCells.x2() - tableCells.x1() + tableCells.y2() - tableCells.y1() + 1;
+ currentIndex = 0;
+ qCDebug(lcTableViewDelegateLifecycle()) << "begin:" << toString();
+ }
+
+ inline void markAsDone() { active = false; }
+ inline bool isActive() { return active; }
+
+ inline QPoint firstCell() { return tableCells.p1(); }
+ inline QPoint lastCell() { return tableCells.p2(); }
+ inline QPoint currentCell() { return cellAt(currentIndex); }
+ inline QPoint previousCell() { return cellAt(currentIndex - 1); }
+
+ inline bool atBeginning() { return currentIndex == 0; }
+ inline bool hasCurrentCell() { return currentIndex < cellCount; }
+ inline void moveToNextCell() { ++currentIndex; }
+
+ inline Qt::Edge edge() { return tableEdge; }
+ inline QQmlIncubator::IncubationMode incubationMode() { return mode; }
+
+ inline QPointF startPosition() { return startPos; }
+
+ QString toString()
+ {
+ QString str;
+ QDebug dbg(&str);
+ dbg.nospace() << "TableSectionLoadRequest(" << "edge:"
+ << tableEdge << " cells:" << tableCells << " incubation:";
+
+ switch (mode) {
+ case QQmlIncubator::Asynchronous:
+ dbg << "Asynchronous";
+ break;
+ case QQmlIncubator::AsynchronousIfNested:
+ dbg << "AsynchronousIfNested";
+ break;
+ case QQmlIncubator::Synchronous:
+ dbg << "Synchronous";
+ break;
+ }
+
+ return str;
+ }
+
+ private:
+ Qt::Edge tableEdge = Qt::Edge(0);
+ QLine tableCells;
+ int currentIndex = 0;
+ int cellCount = 0;
+ bool active = false;
+ QQmlIncubator::IncubationMode mode = QQmlIncubator::AsynchronousIfNested;
+ QPointF startPos;
+
+ QPoint cellAt(int index)
+ {
+ int x = tableCells.p1().x() + (tableCells.dx() ? index : 0);
+ int y = tableCells.p1().y() + (tableCells.dy() ? index : 0);
+ return QPoint(x, y);
+ }
+ };
+
+ enum class RebuildState {
+ Begin = 0,
+ LoadInitalTable,
+ VerifyTable,
+ LayoutTable,
+ LoadAndUnloadAfterLayout,
+ PreloadColumns,
+ PreloadRows,
+ MovePreloadedItemsToPool,
+ Done
+ };
+
+ enum class RebuildOption {
+ None = 0,
+ ViewportOnly = 0x1,
+ CalculateNewTopLeftRow = 0x2,
+ CalculateNewTopLeftColumn = 0x4,
+ All = 0x8,
+ };
+ Q_DECLARE_FLAGS(RebuildOptions, RebuildOption)
+
+public:
+ QQuickTableViewPrivate();
+ ~QQuickTableViewPrivate() override;
+
+ static inline QQuickTableViewPrivate *get(QQuickTableView *q) { return q->d_func(); }
+
+ void updatePolish() override;
+ void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override;
+
+public:
+ QHash<int, FxTableItem *> loadedItems;
+
+ // model, tableModel and modelVariant all point to the same model. modelVariant
+ // is the model assigned by the user. And tableModel is the wrapper model we create
+ // around it. But if the model is an instance model directly, we cannot wrap it, so
+ // we need a pointer for that case as well.
+ QQmlInstanceModel* model = nullptr;
+ QPointer<QQmlTableInstanceModel> tableModel = nullptr;
+ QVariant modelVariant;
+
+ // When the applications assignes a new model or delegate to the view, we keep them
+ // around until we're ready to take them into use (syncWithPendingChanges).
+ QVariant assignedModel = QVariant(int(0));
+ QQmlComponent *assignedDelegate = nullptr;
+
+ // loadedTable describes the table cells that are currently loaded (from top left
+ // row/column to bottom right row/column). loadedTableOuterRect describes the actual
+ // pixels that those cells cover, and is matched agains the viewport to determine when
+ // we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels
+ // that the loaded table covers if you remove one row/column on each side of the table, and
+ // is used to determine rows/columns that are no longer visible and can be unloaded.
+ QRect loadedTable;
+ QRectF loadedTableOuterRect;
+ QRectF loadedTableInnerRect;
+
+ QRectF viewportRect = QRectF(0, 0, -1, -1);
+
+ QSize tableSize;
+
+ RebuildState rebuildState = RebuildState::Done;
+ RebuildOptions rebuildOptions = RebuildOption::All;
+ RebuildOptions scheduledRebuildOptions = RebuildOption::All;
+
+ TableEdgeLoadRequest loadRequest;
+
+ QPoint contentSizeBenchMarkPoint = QPoint(-1, -1);
+ QSizeF cellSpacing = QSizeF(0, 0);
+
+ QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable;
+
+ bool blockItemCreatedCallback = false;
+ bool columnRowPositionsInvalid = false;
+ bool layoutWarningIssued = false;
+ bool polishing = false;
+ bool rebuildScheduled = true;
+
+ QJSValue rowHeightProvider;
+ QJSValue columnWidthProvider;
+
+ // TableView uses contentWidth/height to report the size of the table (this
+ // will e.g make scrollbars written for Flickable work out of the box). This
+ // value is continuously calculated, and will change/improve as more columns
+ // are loaded into view. At the same time, we want to open up for the
+ // possibility that the application can set the content width explicitly, in
+ // case it knows what the exact width should be from the start. We therefore
+ // override the contentWidth/height properties from QQuickFlickable, to be able
+ // to implement this combined behavior. This also lets us lazy build the table
+ // if the application needs to know the content size early on.
+ QQmlNullableValue<qreal> explicitContentWidth;
+ QQmlNullableValue<qreal> explicitContentHeight;
+
+ QSizeF averageEdgeSize;
+
+ const static QPoint kLeft;
+ const static QPoint kRight;
+ const static QPoint kUp;
+ const static QPoint kDown;
+
+#ifdef QT_DEBUG
+ QString forcedIncubationMode = qEnvironmentVariable("QT_TABLEVIEW_INCUBATION_MODE");
+#endif
+
+public:
+ QQuickTableViewAttached *getAttachedObject(const QObject *object) const;
+
+ int modelIndexAtCell(const QPoint &cell) const;
+ QPoint cellAtModelIndex(int modelIndex) const;
+
+ qreal sizeHintForColumn(int column);
+ qreal sizeHintForRow(int row);
+ void calculateTableSize();
+
+ qreal resolveColumnWidth(int column);
+ qreal resolveRowHeight(int row);
+
+ void relayoutTable();
+ void relayoutTableItems();
+
+ void layoutVerticalEdge(Qt::Edge tableEdge);
+ void layoutHorizontalEdge(Qt::Edge tableEdge);
+ void layoutTopLeftItem();
+ void layoutTableEdgeFromLoadRequest();
+
+ void updateContentWidth();
+ void updateContentHeight();
+ void updateAverageEdgeSize();
+
+ void enforceTableAtOrigin();
+ void syncLoadedTableRectFromLoadedTable();
+ void syncLoadedTableFromLoadRequest();
+
+ bool canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
+ bool canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
+ Qt::Edge nextEdgeToLoad(const QRectF rect);
+ Qt::Edge nextEdgeToUnload(const QRectF rect);
+
+ qreal cellWidth(const QPoint &cell);
+ qreal cellHeight(const QPoint &cell);
+
+ FxTableItem *loadedTableItem(const QPoint &cell) const;
+ FxTableItem *itemNextTo(const FxTableItem *fxTableItem, const QPoint &direction) const;
+ FxTableItem *createFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
+ FxTableItem *loadFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
+
+ void releaseItem(FxTableItem *fxTableItem, QQmlTableInstanceModel::ReusableFlag reusableFlag);
+ void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag);
+
+ void unloadItem(const QPoint &cell);
+ void unloadItems(const QLine &items);
+
+ void loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos);
+ void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode);
+ void unloadEdge(Qt::Edge edge);
+ void loadAndUnloadVisibleEdges();
+ void drainReusePoolAfterLoadRequest();
+ void cancelLoadRequest();
+ void processLoadRequest();
+
+ void processRebuildTable();
+ bool moveToNextRebuildState();
+ void beginRebuildTable();
+ void layoutAfterLoadingInitialTable();
+
+ void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);
+ void invalidateColumnRowPositions();
+
+ void createWrapperModel();
+
+ void initItemCallback(int modelIndex, QObject *item);
+ void itemCreatedCallback(int modelIndex, QObject *object);
+ void itemPooledCallback(int modelIndex, QObject *object);
+ void itemReusedCallback(int modelIndex, QObject *object);
+ void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
+
+ inline void syncWithPendingChanges();
+ inline void syncDelegate();
+ inline void syncModel();
+ inline void syncRebuildOptions();
+
+ void connectToModel();
+ void disconnectFromModel();
+
+ void rowsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
+ void columnsMovedCallback(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
+ void rowsInsertedCallback(const QModelIndex &parent, int begin, int end);
+ void rowsRemovedCallback(const QModelIndex &parent, int begin, int end);
+ void columnsInsertedCallback(const QModelIndex &parent, int begin, int end);
+ void columnsRemovedCallback(const QModelIndex &parent, int begin, int end);
+ void modelResetCallback();
+
+ void _q_componentFinalized();
+ void registerCallbackWhenBindingsAreEvaluated();
+
+ inline QString tableLayoutToString() const;
+ void dumpTable() const;
+};
+
+class FxTableItem : public QQuickItemViewFxItem
+{
+public:
+ FxTableItem(QQuickItem *item, QQuickTableView *table, bool own)
+ : QQuickItemViewFxItem(item, own, QQuickTableViewPrivate::get(table))
+ {
+ }
+
+ qreal position() const override { return 0; }
+ qreal endPosition() const override { return 0; }
+ qreal size() const override { return 0; }
+ qreal sectionSize() const override { return 0; }
+ bool contains(qreal, qreal) const override { return false; }
+
+ QPoint cell;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 76720e5c5d..3cce30aaf6 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -88,6 +88,7 @@ QQuickTextPrivate::QQuickTextPrivate()
, truncated(false), hAlignImplicit(true), rightToLeftText(false)
, layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false), formatModifiesFontSize(false)
, polishSize(false)
+ , updateSizeRecursionGuard(false)
{
implicitAntialiasing = true;
}
@@ -442,6 +443,7 @@ void QQuickTextPrivate::updateSize()
//### need to confirm cost of always setting these for richText
internalWidthUpdate = true;
+ qreal oldWidth = q->width();
qreal iWidth = -1;
if (!q->widthValid())
iWidth = size.width();
@@ -449,30 +451,45 @@ void QQuickTextPrivate::updateSize()
q->setImplicitSize(iWidth + hPadding, size.height() + vPadding);
internalWidthUpdate = false;
- if (iWidth == -1)
- q->setImplicitHeight(size.height() + vPadding);
-
- QTextBlock firstBlock = extra->doc->firstBlock();
- while (firstBlock.layout()->lineCount() == 0)
- firstBlock = firstBlock.next();
-
- QTextBlock lastBlock = extra->doc->lastBlock();
- while (lastBlock.layout()->lineCount() == 0)
- lastBlock = lastBlock.previous();
-
- if (firstBlock.lineCount() > 0 && lastBlock.lineCount() > 0) {
- QTextLine firstLine = firstBlock.layout()->lineAt(0);
- QTextLine lastLine = lastBlock.layout()->lineAt(lastBlock.layout()->lineCount() - 1);
- advance = QSizeF(lastLine.horizontalAdvance(),
- (lastLine.y() + lastBlock.layout()->position().y()) - (firstLine.y() + firstBlock.layout()->position().y()));
+ // If the implicit width update caused a recursive change of the width,
+ // we will have skipped integral parts of the layout due to the
+ // internalWidthUpdate recursion guard. To make sure everything is up
+ // to date, we need to run a second pass over the layout when updateSize()
+ // is done.
+ if (!qFuzzyCompare(q->width(), oldWidth) && !updateSizeRecursionGuard) {
+ updateSizeRecursionGuard = true;
+ updateSize();
+ updateSizeRecursionGuard = false;
} else {
- advance = QSizeF();
+ if (iWidth == -1)
+ q->setImplicitHeight(size.height() + vPadding);
+
+ QTextBlock firstBlock = extra->doc->firstBlock();
+ while (firstBlock.layout()->lineCount() == 0)
+ firstBlock = firstBlock.next();
+
+ QTextBlock lastBlock = extra->doc->lastBlock();
+ while (lastBlock.layout()->lineCount() == 0)
+ lastBlock = lastBlock.previous();
+
+ if (firstBlock.lineCount() > 0 && lastBlock.lineCount() > 0) {
+ QTextLine firstLine = firstBlock.layout()->lineAt(0);
+ QTextLine lastLine = lastBlock.layout()->lineAt(lastBlock.layout()->lineCount() - 1);
+ advance = QSizeF(lastLine.horizontalAdvance(),
+ (lastLine.y() + lastBlock.layout()->position().y()) - (firstLine.y() + firstBlock.layout()->position().y()));
+ } else {
+ advance = QSizeF();
+ }
}
}
if (layedOutTextRect.size() != previousSize)
emit q->contentSizeChanged();
+ if (layedOutTextRect.width() != previousSize.width())
+ emit q->contentWidthChanged(layedOutTextRect.width());
+ if (layedOutTextRect.height() != previousSize.height())
+ emit q->contentHeightChanged(layedOutTextRect.height());
updateType = UpdatePaintNode;
q->update();
}
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index 15e989c13d..f4e7fa7046 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -79,10 +79,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
- Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
- Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
- Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged) // Compatibility
- Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
+ Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentHeightChanged)
+ Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentWidthChanged) // Compatibility
+ Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentHeightChanged)
Q_PROPERTY(qreal lineHeight READ lineHeight WRITE setLineHeight NOTIFY lineHeightChanged)
Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged)
Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
@@ -272,6 +272,8 @@ Q_SIGNALS:
void textFormatChanged(QQuickText::TextFormat textFormat);
void elideModeChanged(QQuickText::TextElideMode mode);
void contentSizeChanged();
+ Q_REVISION(12) void contentWidthChanged(qreal contentWidth);
+ Q_REVISION(12) void contentHeightChanged(qreal contentHeight);
void lineHeightChanged(qreal lineHeight);
void lineHeightModeChanged(LineHeightMode mode);
void fontSizeModeChanged();
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index b0b1492d57..fd26d966c8 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -174,6 +174,7 @@ public:
bool needToUpdateLayout:1;
bool formatModifiesFontSize:1;
bool polishSize:1; // Workaround for problem with polish called after updateSize (QTBUG-42636)
+ bool updateSizeRecursionGuard:1;
static const QChar elideChar;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 5cd04decf7..8caa568a6c 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -46,6 +46,7 @@
#include "qquickevents_p_p.h"
#include <private/qquickdrag_p.h>
+#include <private/qquickhoverhandler_p.h>
#include <private/qquickpointerhandler_p.h>
#include <QtQuick/private/qsgrenderer_p.h>
@@ -88,6 +89,8 @@ Q_LOGGING_CATEGORY(DBG_TOUCH, "qt.quick.touch")
Q_LOGGING_CATEGORY(DBG_TOUCH_TARGET, "qt.quick.touch.target")
Q_LOGGING_CATEGORY(DBG_MOUSE, "qt.quick.mouse")
Q_LOGGING_CATEGORY(DBG_MOUSE_TARGET, "qt.quick.mouse.target")
+Q_LOGGING_CATEGORY(lcWheelTarget, "qt.quick.wheel.target")
+Q_LOGGING_CATEGORY(lcGestureTarget, "qt.quick.gesture.target")
Q_LOGGING_CATEGORY(DBG_HOVER_TRACE, "qt.quick.hover.trace")
Q_LOGGING_CATEGORY(DBG_FOCUS, "qt.quick.focus")
Q_LOGGING_CATEGORY(DBG_DIRTY, "qt.quick.dirty")
@@ -256,14 +259,16 @@ void QQuickWindow::hideEvent(QHideEvent *)
void QQuickWindow::focusOutEvent(QFocusEvent *ev)
{
Q_D(QQuickWindow);
- d->contentItem->setFocus(false, ev->reason());
+ if (d->contentItem)
+ d->contentItem->setFocus(false, ev->reason());
}
/*! \reimp */
void QQuickWindow::focusInEvent(QFocusEvent *ev)
{
Q_D(QQuickWindow);
- d->contentItem->setFocus(true, ev->reason());
+ if (d->contentItem)
+ d->contentItem->setFocus(true, ev->reason());
d->updateFocusItemTransform();
}
@@ -610,6 +615,7 @@ QQmlListProperty<QObject> QQuickWindowPrivate::data()
static QMouseEvent *touchToMouseEvent(QEvent::Type type, const QTouchEvent::TouchPoint &p, QTouchEvent *event, QQuickItem *item, bool transformNeeded = true)
{
+ Q_ASSERT(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents));
// The touch point local position and velocity are not yet transformed.
QMouseEvent *me = new QMouseEvent(type, transformNeeded ? item->mapFromScene(p.scenePos()) : p.pos(), p.scenePos(), p.screenPos(),
Qt::LeftButton, (type == QEvent::MouseButtonRelease ? Qt::NoButton : Qt::LeftButton), event->modifiers());
@@ -651,6 +657,7 @@ bool QQuickWindowPrivate::checkIfDoubleClicked(ulong newPressEventTimestamp)
bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEvent *pointerEvent)
{
+ Q_ASSERT(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents));
Q_Q(QQuickWindow);
auto device = pointerEvent->device();
@@ -1315,7 +1322,9 @@ QQuickWindow::~QQuickWindow()
#if QT_CONFIG(draganddrop)
delete d->dragGrabber; d->dragGrabber = nullptr;
#endif
- delete d->contentItem; d->contentItem = nullptr;
+ QQuickRootItem *root = d->contentItem;
+ d->contentItem = nullptr;
+ delete root;
qDeleteAll(d->pointerEventInstances);
d->pointerEventInstances.clear();
@@ -1540,8 +1549,20 @@ bool QQuickWindowPrivate::clearHover(ulong timestamp)
QPointF pos = q->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint());
bool accepted = false;
- for (QQuickItem* item : qAsConst(hoverItems))
+ for (QQuickItem* item : qAsConst(hoverItems)) {
accepted = sendHoverEvent(QEvent::HoverLeave, item, pos, pos, QGuiApplication::keyboardModifiers(), timestamp, true) || accepted;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ if (itemPrivate->hasPointerHandlers()) {
+ pos = q->mapFromGlobal(QCursor::pos());
+ QQuickPointerEvent *pointerEvent = pointerEventInstance(QQuickPointerDevice::genericMouseDevice(), QEvent::MouseMove);
+ pointerEvent->point(0)->reset(Qt::TouchPointMoved, pos, quint64(1) << 24 /* mouse has device ID 1 */, timestamp, QVector2D());
+ pointerEvent->point(0)->setAccepted(true);
+ pointerEvent->localize(item);
+ for (QQuickPointerHandler *h : itemPrivate->extra->pointerHandlers)
+ if (QQuickHoverHandler *hh = qmlobject_cast<QQuickHoverHandler *>(h))
+ hh->handlePointerEvent(pointerEvent);
+ }
+ }
hoverItems.clear();
return accepted;
}
@@ -1571,6 +1592,8 @@ bool QQuickWindow::event(QEvent *e)
return d->deliverTouchCancelEvent(static_cast<QTouchEvent*>(e));
break;
case QEvent::Enter: {
+ if (!d->contentItem)
+ return false;
QEnterEvent *enter = static_cast<QEnterEvent*>(e);
bool accepted = enter->isAccepted();
bool delivered = d->deliverHoverEvent(d->contentItem, enter->windowPos(), d->lastMousePosition,
@@ -1592,7 +1615,8 @@ bool QQuickWindow::event(QEvent *e)
break;
#endif
case QEvent::WindowDeactivate:
- contentItem()->windowDeactivateEvent();
+ if (d->contentItem)
+ d->contentItem->windowDeactivateEvent();
break;
case QEvent::Close: {
// TOOD Qt 6 (binary incompatible)
@@ -1617,7 +1641,7 @@ bool QQuickWindow::event(QEvent *e)
}
#if QT_CONFIG(gestures)
case QEvent::NativeGesture:
- d->deliverNativeGestureEvent(d->contentItem, static_cast<QNativeGestureEvent*>(e));
+ d->deliverSinglePointEventUntilAccepted(d->pointerEventInstance(e));
break;
#endif
case QEvent::ShortcutOverride:
@@ -1684,6 +1708,7 @@ void QQuickWindowPrivate::deliverToPassiveGrabbers(const QVector<QPointer <QQuic
{
const QVector<QQuickPointerHandler *> &eventDeliveryTargets = pointerEvent->device()->eventDeliveryTargets();
QVarLengthArray<QPair<QQuickItem *, bool>, 4> sendFilteredPointerEventResult;
+ hasFiltered.clear();
for (auto handler : passiveGrabbers) {
// a null pointer in passiveGrabbers is unlikely, unless the grabbing handler was deleted dynamically
if (Q_LIKELY(handler) && !eventDeliveryTargets.contains(handler)) {
@@ -1720,6 +1745,7 @@ void QQuickWindowPrivate::deliverMouseEvent(QQuickPointerMouseEvent *pointerEven
if (point->exclusiveGrabber()) {
if (auto grabber = point->grabberItem()) {
bool handled = false;
+ hasFiltered.clear();
if (sendFilteredPointerEvent(pointerEvent, grabber))
handled = true;
// if the grabber is an Item:
@@ -1748,6 +1774,7 @@ void QQuickWindowPrivate::deliverMouseEvent(QQuickPointerMouseEvent *pointerEven
// if the grabber is not an Item, it must be a PointerHandler
auto handler = point->grabberPointerHandler();
pointerEvent->localize(handler->parentItem());
+ hasFiltered.clear();
if (!sendFilteredPointerEvent(pointerEvent, handler->parentItem()))
handler->handlePointerEvent(pointerEvent);
if (mouseIsReleased)
@@ -1767,12 +1794,13 @@ void QQuickWindowPrivate::deliverMouseEvent(QQuickPointerMouseEvent *pointerEven
// If some points weren't grabbed, deliver to non-grabber PointerHandlers in reverse paint order
if (!pointerEvent->allPointsGrabbed() && pointerEvent->buttons()) {
- QVector<QQuickItem *> targetItems = pointerTargets(contentItem, point->scenePosition(), false, false);
+ QVector<QQuickItem *> targetItems = pointerTargets(contentItem, point, false, false);
for (QQuickItem *item : targetItems) {
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
if (!itemPrivate->extra.isAllocated() || itemPrivate->extra->pointerHandlers.isEmpty())
continue;
pointerEvent->localize(item);
+ hasFiltered.clear();
if (!sendFilteredPointerEvent(pointerEvent, item)) {
if (itemPrivate->handlePointerEvent(pointerEvent, true)) // avoid re-delivering to grabbers
delivered = true;
@@ -1834,6 +1862,16 @@ bool QQuickWindowPrivate::deliverHoverEvent(QQuickItem *item, const QPointF &sce
}
}
+ if (itemPrivate->hasPointerHandlers()) {
+ QQuickPointerEvent *pointerEvent = pointerEventInstance(QQuickPointerDevice::genericMouseDevice(), QEvent::MouseMove);
+ pointerEvent->point(0)->reset(Qt::TouchPointMoved, scenePos, quint64(1) << 24 /* mouse has device ID 1 */, timestamp, QVector2D());
+ pointerEvent->point(0)->setAccepted(true);
+ pointerEvent->localize(item);
+ for (QQuickPointerHandler *h : itemPrivate->extra->pointerHandlers)
+ if (QQuickHoverHandler *hh = qmlobject_cast<QQuickHoverHandler *>(h))
+ hh->handlePointerEvent(pointerEvent);
+ }
+
if (itemPrivate->hoverEnabled) {
QPointF p = item->mapFromScene(scenePos);
if (item->contains(p)) {
@@ -1886,43 +1924,57 @@ bool QQuickWindowPrivate::deliverHoverEvent(QQuickItem *item, const QPointF &sce
return false;
}
-#if QT_CONFIG(wheelevent)
-bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event)
+// Simple delivery of non-mouse, non-touch Pointer Events: visit the items and handlers
+// in the usual reverse-paint-order until propagation is stopped
+bool QQuickWindowPrivate::deliverSinglePointEventUntilAccepted(QQuickPointerEvent *event)
{
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
- QPointF p = item->mapFromScene(event->posF());
- if (!item->contains(p))
- return false;
- }
-
- QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
- for (int ii = children.count() - 1; ii >= 0; --ii) {
- QQuickItem *child = children.at(ii);
- if (!child->isVisible() || !child->isEnabled() || QQuickItemPrivate::get(child)->culled)
- continue;
- if (deliverWheelEvent(child, event))
- return true;
- }
-
- QPointF p = item->mapFromScene(event->posF());
+ Q_ASSERT(event->pointCount() == 1);
+ QQuickEventPoint *point = event->point(0);
+ QVector<QQuickItem *> targetItems = pointerTargets(contentItem, point, false, false);
- if (item->contains(p)) {
- QWheelEvent wheel(p, event->globalPosF(), event->pixelDelta(), event->angleDelta(), event->delta(),
- event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
- wheel.setTimestamp(event->timestamp());
- wheel.accept();
- QCoreApplication::sendEvent(item, &wheel);
- if (wheel.isAccepted()) {
- event->accept();
+ for (QQuickItem *item : targetItems) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ event->localize(item);
+ // Let Pointer Handlers have the first shot
+ itemPrivate->handlePointerEvent(event);
+ if (point->isAccepted())
return true;
+ QPointF g = item->window()->mapToGlobal(point->scenePosition().toPoint());
+#if QT_CONFIG(wheelevent)
+ // Let the Item have a chance to handle it
+ if (QQuickPointerScrollEvent *pse = event->asPointerScrollEvent()) {
+ QWheelEvent wheel(point->position(), g, pse->pixelDelta().toPoint(), pse->angleDelta().toPoint(),
+ pse->buttons(), pse->modifiers(), pse->phase(),
+ pse->isInverted(), pse->synthSource());
+ wheel.setTimestamp(pse->timestamp());
+ wheel.accept();
+ QCoreApplication::sendEvent(item, &wheel);
+ if (wheel.isAccepted()) {
+ qCDebug(lcWheelTarget) << &wheel << "->" << item;
+ event->setAccepted(true);
+ return true;
+ }
}
+#endif
+#if QT_CONFIG(gestures)
+ if (QQuickPointerNativeGestureEvent *pnge = event->asPointerNativeGestureEvent()) {
+ QNativeGestureEvent nge(pnge->type(), pnge->device()->qTouchDevice(), point->position(), point->scenePosition(), g,
+ pnge->value(), 0L, 0L); // TODO can't copy things I can't access
+ nge.accept();
+ QCoreApplication::sendEvent(item, &nge);
+ if (nge.isAccepted()) {
+ qCDebug(lcGestureTarget) << &nge << "->" << item;
+ event->setAccepted(true);
+ return true;
+ }
+ }
+#endif // gestures
}
- return false;
+ return false; // it wasn't handled
}
+#if QT_CONFIG(wheelevent)
/*! \reimp */
void QQuickWindow::wheelEvent(QWheelEvent *event)
{
@@ -1937,55 +1989,11 @@ void QQuickWindow::wheelEvent(QWheelEvent *event)
return;
event->ignore();
- d->deliverWheelEvent(d->contentItem, event);
+ d->deliverPointerEvent(d->pointerEventInstance(event));
d->lastWheelEventAccepted = event->isAccepted();
}
#endif // wheelevent
-#if QT_CONFIG(gestures)
-bool QQuickWindowPrivate::deliverNativeGestureEvent(QQuickItem *item, QNativeGestureEvent *event)
-{
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- QPointF p = item->mapFromScene(event->windowPos());
- if ((itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) && !item->contains(p))
- return false;
-
- QList<QQuickItem *> children = itemPrivate->paintOrderChildItems();
- for (int ii = children.count() - 1; ii >= 0; --ii) {
- QQuickItem *child = children.at(ii);
- if (!child->isVisible() || !child->isEnabled() || QQuickItemPrivate::get(child)->culled)
- continue;
- if (deliverNativeGestureEvent(child, event))
- return true;
- }
-
- // Try the Item's pointer handlers first
- QQuickPointerEvent *pointerEvent = pointerEventInstance(event);
- pointerEvent->localize(item);
- if (itemPrivate->handlePointerEvent(pointerEvent, false)) {
- if (pointerEvent->allPointsAccepted()) {
- event->accept();
- return true;
- }
- }
-
- // If still not accepted, try direct delivery to the item
- if (item->contains(p)) {
- QNativeGestureEvent copy(event->gestureType(), event->device(), p, event->windowPos(), event->screenPos(),
- event->value(), 0L, 0L); // TODO can't copy things I can't access
- event->accept();
- item->event(&copy);
- if (copy.isAccepted()) {
- event->accept();
- return true;
- }
- }
-
- return false;
-}
-#endif // gestures
-
bool QQuickWindowPrivate::deliverTouchCancelEvent(QTouchEvent *event)
{
qCDebug(DBG_TOUCH) << event;
@@ -2229,6 +2237,8 @@ QQuickPointerEvent *QQuickWindowPrivate::queryPointerEventInstance(QQuickPointer
if (eventType == QEvent::NativeGesture && !qobject_cast<QQuickPointerNativeGestureEvent*>(e))
continue;
#endif
+ if (eventType == QEvent::Wheel && !qobject_cast<QQuickPointerScrollEvent*>(e))
+ continue;
// Otherwise we assume there's only one event type per device.
// More disambiguation tests might need to be added above if that changes later.
if (e->device() == device)
@@ -2248,7 +2258,10 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QQuickPointerDevic
// QWindowSystemInterface::handleMouseEvent() does not take a device parameter:
// we assume all mouse events come from one mouse (the "core pointer").
// So when the event is a mouse event, device == QQuickPointerDevice::genericMouseDevice()
- ev = new QQuickPointerMouseEvent(q, device);
+ if (eventType == QEvent::Wheel)
+ ev = new QQuickPointerScrollEvent(q, device);
+ else
+ ev = new QQuickPointerMouseEvent(q, device);
break;
case QQuickPointerDevice::TouchPad:
case QQuickPointerDevice::TouchScreen:
@@ -2282,6 +2295,7 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event) con
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
+ case QEvent::Wheel:
dev = QQuickPointerDevice::genericMouseDevice();
break;
case QEvent::TouchBegin:
@@ -2324,7 +2338,7 @@ void QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent *event)
} else if (event->asPointerTouchEvent()) {
deliverTouchEvent(event->asPointerTouchEvent());
} else {
- Q_ASSERT(false);
+ deliverSinglePointEventUntilAccepted(event);
}
event->reset(nullptr);
@@ -2332,16 +2346,16 @@ void QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent *event)
--pointerEventRecursionGuard;
}
-// check if item or any of its child items contain the point
+// check if item or any of its child items contain the point, or if any pointer handler "wants" the point
// FIXME: should this be iterative instead of recursive?
// If checkMouseButtons is true, it means we are finding targets for a mouse event, so no item for which acceptedMouseButtons() is NoButton will be added.
// If checkAcceptsTouch is true, it means we are finding targets for a touch event, so either acceptTouchEvents() must return true OR
// it must accept a synth. mouse event, thus if acceptTouchEvents() returns false but acceptedMouseButtons() is true, gets added; if not, it doesn't.
-QVector<QQuickItem *> QQuickWindowPrivate::pointerTargets(QQuickItem *item, const QPointF &scenePos, bool checkMouseButtons, bool checkAcceptsTouch) const
+QVector<QQuickItem *> QQuickWindowPrivate::pointerTargets(QQuickItem *item, QQuickEventPoint *point, bool checkMouseButtons, bool checkAcceptsTouch) const
{
QVector<QQuickItem *> targets;
auto itemPrivate = QQuickItemPrivate::get(item);
- QPointF itemPos = item->mapFromScene(scenePos);
+ QPointF itemPos = item->mapFromScene(point->scenePosition());
// if the item clips, we can potentially return early
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
if (!item->contains(itemPos))
@@ -2355,11 +2369,15 @@ QVector<QQuickItem *> QQuickWindowPrivate::pointerTargets(QQuickItem *item, cons
auto childPrivate = QQuickItemPrivate::get(child);
if (!child->isVisible() || !child->isEnabled() || childPrivate->culled)
continue;
- targets << pointerTargets(child, scenePos, checkMouseButtons, checkAcceptsTouch);
+ targets << pointerTargets(child, point, checkMouseButtons, checkAcceptsTouch);
}
bool relevant = item->contains(itemPos);
- if (!(itemPrivate->hasPointerHandlers())) {
+ if (itemPrivate->hasPointerHandlers()) {
+ if (!relevant)
+ if (itemPrivate->anyPointerHandlerWants(point))
+ relevant = true;
+ } else {
if (relevant && checkMouseButtons && item->acceptedMouseButtons() == Qt::NoButton)
relevant = false;
if (relevant && checkAcceptsTouch && !(item->acceptTouchEvents() || item->acceptedMouseButtons()))
@@ -2440,6 +2458,7 @@ void QQuickWindowPrivate::deliverUpdatedTouchPoints(QQuickPointerTouchEvent *eve
// The grabber is not an item? It's a handler then. Let it have the event first.
QQuickPointerHandler *handler = static_cast<QQuickPointerHandler *>(grabber);
receiver = static_cast<QQuickPointerHandler *>(grabber)->parentItem();
+ hasFiltered.clear();
if (sendFilteredPointerEvent(event, receiver))
done = true;
event->localize(receiver);
@@ -2469,7 +2488,7 @@ void QQuickWindowPrivate::deliverUpdatedTouchPoints(QQuickPointerTouchEvent *eve
QQuickEventPoint *point = event->point(i);
if (point->state() == QQuickEventPoint::Pressed)
continue; // presses were delivered earlier; not the responsibility of deliverUpdatedTouchPoints
- QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point->scenePosition(), false, false);
+ QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point, false, false);
if (targetItems.count()) {
targetItems = mergePointerTargets(targetItems, targetItemsForPoint);
} else {
@@ -2494,12 +2513,20 @@ bool QQuickWindowPrivate::deliverPressOrReleaseEvent(QQuickPointerEvent *event,
int pointCount = event->pointCount();
QVector<QQuickItem *> targetItems;
bool isTouchEvent = (event->asPointerTouchEvent() != nullptr);
+ if (isTouchEvent && event->isPressEvent()) {
+ // When a second point is pressed, we're starting over with delivery, so
+ // don't let prior conception of which one is acting as a mouse interfere
+ touchMouseId = -1;
+ touchMouseDevice = nullptr;
+ }
for (int i = 0; i < pointCount; ++i) {
auto point = event->point(i);
+ if (point->state() == QQuickEventPoint::Pressed && !event->isDoubleClickEvent())
+ point->clearPassiveGrabbers();
point->setAccepted(false); // because otherwise touchEventForItem will ignore it
if (point->grabberPointerHandler() && point->state() == QQuickEventPoint::Released)
point->setGrabberPointerHandler(nullptr, true);
- QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point->scenePosition(), !isTouchEvent, isTouchEvent);
+ QVector<QQuickItem *> targetItemsForPoint = pointerTargets(contentItem, point, !isTouchEvent, isTouchEvent);
if (targetItems.count()) {
targetItems = mergePointerTargets(targetItems, targetItemsForPoint);
} else {
@@ -2508,6 +2535,7 @@ bool QQuickWindowPrivate::deliverPressOrReleaseEvent(QQuickPointerEvent *event,
}
for (QQuickItem *item : targetItems) {
+ hasFiltered.clear();
if (!handlersOnly && sendFilteredPointerEvent(event, item)) {
if (event->isAccepted()) {
for (int i = 0; i < event->pointCount(); ++i)
@@ -2559,7 +2587,6 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo
// synthetic events - flickable sends one when setPressDelay is used.
auto oldMouseGrabber = q->mouseGrabberItem();
QPointF localPos = item->mapFromScene(point->scenePosition());
- Q_ASSERT(item->contains(localPos)); // transform is checked already
QMouseEvent *me = event->asMouseEvent(localPos);
me->accept();
QCoreApplication::sendEvent(item, me);
@@ -2587,6 +2614,7 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo
bool eventAccepted = false;
// If any parent filters the event, we're done.
+ hasFiltered.clear();
if (sendFilteredPointerEvent(pointerEvent, item))
return;
@@ -2596,10 +2624,12 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo
eventAccepted = touchEvent->isAccepted();
// If the touch event wasn't accepted, synthesize a mouse event and see if the item wants it.
- if (!eventAccepted && (itemPrivate->acceptedMouseButtons() & Qt::LeftButton)) {
- // send mouse event
- if (deliverTouchAsMouse(item, ptEvent))
- eventAccepted = true;
+ if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents))) {
+ if (!eventAccepted && (itemPrivate->acceptedMouseButtons() & Qt::LeftButton)) {
+ // send mouse event
+ if (deliverTouchAsMouse(item, ptEvent))
+ eventAccepted = true;
+ }
}
if (eventAccepted) {
@@ -2803,7 +2833,6 @@ QQuickItem *QQuickWindowPrivate::findCursorItem(QQuickItem *item, const QPointF
bool QQuickWindowPrivate::sendFilteredPointerEvent(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent)
{
- hasFiltered.clear();
return sendFilteredPointerEventImpl(event, receiver, filteringParent ? filteringParent : receiver->parentItem());
}
@@ -2864,7 +2893,7 @@ bool QQuickWindowPrivate::sendFilteredPointerEventImpl(QQuickPointerEvent *event
pt->setGrabberItem(filteringParent);
}
return true;
- } else {
+ } else if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents))) {
// filteringParent didn't filter the touch event. Give it a chance to filter a synthetic mouse event.
for (int i = 0; i < filteringParentTouchEvent->touchPoints().size(); ++i) {
const QTouchEvent::TouchPoint &tp = filteringParentTouchEvent->touchPoints().at(i);
@@ -2963,6 +2992,12 @@ bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent
return overThreshold;
}
+bool QQuickWindowPrivate::dragOverThreshold(QVector2D delta)
+{
+ int threshold = qApp->styleHints()->startDragDistance();
+ return qAbs(delta.x()) > threshold || qAbs(delta.y()) > threshold;
+}
+
/*!
\qmlproperty list<Object> Window::data
\default
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 817178fdac..79e8a11aa8 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -95,6 +95,7 @@ public:
};
Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
+ Q_FLAG(CreateTextureOptions)
enum SceneGraphError {
ContextNotAvailable = 1
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index b5e3a2c1eb..10c8477417 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -152,12 +152,7 @@ public:
bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
bool sendFilteredPointerEvent(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent = nullptr);
bool sendFilteredPointerEventImpl(QQuickPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
-#if QT_CONFIG(wheelevent)
- bool deliverWheelEvent(QQuickItem *, QWheelEvent *);
-#endif
-#if QT_CONFIG(gestures)
- bool deliverNativeGestureEvent(QQuickItem *, QNativeGestureEvent *);
-#endif
+ bool deliverSinglePointEventUntilAccepted(QQuickPointerEvent *);
// entry point of events to the window
void handleTouchEvent(QTouchEvent *);
@@ -180,7 +175,7 @@ public:
void deliverUpdatedTouchPoints(QQuickPointerTouchEvent *event);
void deliverMatchingPointsToItem(QQuickItem *item, QQuickPointerEvent *pointerEvent, bool handlersOnly = false);
- QVector<QQuickItem *> pointerTargets(QQuickItem *, const QPointF &, bool checkMouseButtons, bool checkAcceptsTouch) const;
+ QVector<QQuickItem *> pointerTargets(QQuickItem *, QQuickEventPoint *point, bool checkMouseButtons, bool checkAcceptsTouch) const;
QVector<QQuickItem *> mergePointerTargets(const QVector<QQuickItem *> &list1, const QVector<QQuickItem *> &list2) const;
// hover delivery
@@ -307,6 +302,7 @@ public:
QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point));
}
+ static bool dragOverThreshold(QVector2D delta);
// data property
static void data_append(QQmlListProperty<QObject> *, QObject *);
diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
index d715d900ba..2e5fdbbe6b 100644
--- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
@@ -77,6 +77,11 @@ QSGSoftwareRenderableNode *QSGAbstractSoftwareRenderer::renderableNode(QSGNode *
return m_nodes.value(node, nullptr);
}
+const QLinkedList<QSGSoftwareRenderableNode*> &QSGAbstractSoftwareRenderer::renderableNodes() const
+{
+ return m_renderableNodes;
+}
+
void QSGAbstractSoftwareRenderer::addNodeMapping(QSGNode *node, QSGSoftwareRenderableNode *renderableNode)
{
m_nodes.insert(node, renderableNode);
diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h
index f6594d931a..99204ef25e 100644
--- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h
@@ -88,6 +88,7 @@ protected:
QRect backgroundRect();
// only known after calling optimizeRenderList()
bool isOpaque() const { return m_isOpaque; }
+ const QLinkedList<QSGSoftwareRenderableNode*> &renderableNodes() const;
private:
void nodeAdded(QSGNode *node);
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
index a8b5944974..c33144344f 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
@@ -74,6 +74,7 @@ QSGContextFactoryInterface::Flags QSGSoftwareAdaptation::flags(const QString &)
QSGRenderLoop *QSGSoftwareAdaptation::createWindowManager()
{
+#if QT_CONFIG(thread)
static bool threaded = false;
static bool envChecked = false;
if (!envChecked) {
@@ -83,6 +84,7 @@ QSGRenderLoop *QSGSoftwareAdaptation::createWindowManager()
if (threaded)
return new QSGSoftwareThreadedRenderLoop;
+#endif
return new QSGSoftwareRenderLoop();
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
index 21f20c66cd..dd789b78c7 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareglyphnode.cpp
@@ -49,12 +49,40 @@ QSGSoftwareGlyphNode::QSGSoftwareGlyphNode()
setGeometry(&m_geometry);
}
+namespace {
+QRectF calculateBoundingRect(const QPointF &position, const QGlyphRun &glyphs)
+{
+ qreal minX = 0;
+ qreal minY = 0;
+ qreal maxX = 0;
+ qreal maxY = 0;
+
+ for (int i = 0, n = qMin(glyphs.glyphIndexes().size(), glyphs.positions().size()); i < n; ++i) {
+ QRectF glyphRect = glyphs.rawFont().boundingRect(glyphs.glyphIndexes()[i]);
+ glyphRect.translate(glyphs.positions()[i]);
+
+ if (i == 0) {
+ minX = glyphRect.left();
+ minY = glyphRect.top();
+ maxX = glyphRect.right();
+ maxY = glyphRect.bottom();
+ } else {
+ minX = qMin(glyphRect.left(), minX);
+ minY = qMin(glyphRect.top(), minY);
+ maxX = qMax(glyphRect.right(),maxX);
+ maxY = qMax(glyphRect.bottom(), maxY);
+ }
+ }
+ QRectF boundingRect(QPointF(minX, minY), QPointF(maxX, maxY));
+ return boundingRect.translated(position - QPointF(0.0, glyphs.rawFont().ascent()));
+}
+}
void QSGSoftwareGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
{
m_position = position;
m_glyphRun = glyphs;
- m_bounding_rect = glyphs.boundingRect().translated(m_position - QPointF(0.0, glyphs.rawFont().ascent()));
+ m_bounding_rect = calculateBoundingRect(position, glyphs);
}
void QSGSoftwareGlyphNode::setColor(const QColor &color)
@@ -91,8 +119,8 @@ void QSGSoftwareGlyphNode::paint(QPainter *painter)
QPointF pos = m_position - QPointF(0, m_glyphRun.rawFont().ascent());
qreal offset = 1.0;
- if (painter->device()->devicePixelRatio() != 0)
- offset = 1.0 / painter->device()->devicePixelRatio();
+ if (painter->device()->devicePixelRatioF() > 0.0)
+ offset = 1.0 / painter->device()->devicePixelRatioF();
switch (m_style) {
case QQuickText::Normal: break;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
index bf3141bc32..2c361e03e2 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
QSGSoftwareInternalRectangleNode::QSGSoftwareInternalRectangleNode()
: m_penWidth(0)
, m_radius(0)
+ , m_vertical(true)
, m_cornerPixmapIsDirty(true)
, m_devicePixelRatio(1)
{
@@ -186,6 +187,15 @@ void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &st
markDirty(DirtyMaterial);
}
+void QSGSoftwareInternalRectangleNode::setGradientVertical(bool vertical)
+{
+ if (m_vertical != vertical) {
+ m_vertical = vertical;
+ m_cornerPixmapIsDirty = true;
+ markDirty(DirtyMaterial);
+ }
+}
+
void QSGSoftwareInternalRectangleNode::setRadius(qreal radius)
{
if (m_radius != radius) {
@@ -209,7 +219,7 @@ void QSGSoftwareInternalRectangleNode::update()
}
if (!m_stops.isEmpty()) {
- QLinearGradient gradient(QPoint(0,0), QPoint(0,1));
+ QLinearGradient gradient(QPoint(0,0), QPoint(m_vertical ? 0 : 1, m_vertical ? 1 : 0));
gradient.setStops(m_stops);
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
m_brush = QBrush(gradient);
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h
index 1f87424d2a..125520de26 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h
@@ -69,6 +69,7 @@ public:
void setPenColor(const QColor &color) override;
void setPenWidth(qreal width) override;
void setGradientStops(const QGradientStops &stops) override;
+ void setGradientVertical(bool vertical) override;
void setRadius(qreal radius) override;
void setAntialiasing(bool antialiasing) override { Q_UNUSED(antialiasing) }
void setAligned(bool aligned) override;
@@ -91,6 +92,7 @@ private:
double m_radius;
QPen m_pen;
QBrush m_brush;
+ bool m_vertical;
bool m_cornerPixmapIsDirty;
QPixmap m_cornerPixmap;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
index 8fc87db179..b20d0a1828 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
@@ -72,7 +72,7 @@ class QSGSoftwareNinePatchNode;
class QSGSoftwareSpriteNode;
class QSGRenderNode;
-class QSGSoftwareRenderableNode
+class Q_QUICK_PRIVATE_EXPORT QSGSoftwareRenderableNode
{
public:
enum NodeType {
@@ -104,6 +104,7 @@ public:
bool isOpaque() const { return m_isOpaque; }
bool isDirty() const { return m_isDirty; }
bool isDirtyRegionEmpty() const;
+ QSGNode *handle() const { return m_handle.node; }
void setTransform(const QTransform &transform);
void setClipRegion(const QRegion &clipRegion, bool hasClipRegion = true);
@@ -123,6 +124,7 @@ public:
private:
union RenderableNodeHandle {
+ QSGNode *node;
QSGSimpleRectNode *simpleRectNode;
QSGSimpleTextureNode *simpleTextureNode;
QSGSoftwareInternalImageNode *imageNode;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
index ffcee5f56e..e9ed52d428 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderer.cpp
@@ -113,8 +113,8 @@ void QSGSoftwareRenderer::render()
setBackgroundColor(clearColor());
setBackgroundRect(QRect(0, 0,
- m_paintDevice->width() / m_paintDevice->devicePixelRatio(),
- m_paintDevice->height() / m_paintDevice->devicePixelRatio()));
+ m_paintDevice->width() / m_paintDevice->devicePixelRatioF(),
+ m_paintDevice->height() / m_paintDevice->devicePixelRatioF()));
// Build Renderlist
// The renderlist is created by visiting each node in the tree and when a
diff --git a/src/quick/scenegraph/adaptations/software/software.pri b/src/quick/scenegraph/adaptations/software/software.pri
index de5f01cdee..278dbe7944 100644
--- a/src/quick/scenegraph/adaptations/software/software.pri
+++ b/src/quick/scenegraph/adaptations/software/software.pri
@@ -18,8 +18,7 @@ SOURCES += \
$$PWD/qsgsoftwarerenderlistbuilder.cpp \
$$PWD/qsgsoftwarerenderloop.cpp \
$$PWD/qsgsoftwarelayer.cpp \
- $$PWD/qsgsoftwareadaptation.cpp \
- $$PWD/qsgsoftwarethreadedrenderloop.cpp
+ $$PWD/qsgsoftwareadaptation.cpp
HEADERS += \
$$PWD/qsgsoftwarecontext_p.h \
@@ -37,8 +36,7 @@ HEADERS += \
$$PWD/qsgsoftwarerenderlistbuilder_p.h \
$$PWD/qsgsoftwarerenderloop_p.h \
$$PWD/qsgsoftwarelayer_p.h \
- $$PWD/qsgsoftwareadaptation_p.h \
- $$PWD/qsgsoftwarethreadedrenderloop_p.h
+ $$PWD/qsgsoftwareadaptation_p.h
qtConfig(quick-sprite) {
SOURCES += \
@@ -46,3 +44,10 @@ qtConfig(quick-sprite) {
HEADERS += \
$$PWD/qsgsoftwarespritenode_p.h
}
+
+qtConfig(thread) {
+ SOURCES += \
+ $$PWD/qsgsoftwarethreadedrenderloop.cpp
+ HEADERS +=\
+ $$PWD/qsgsoftwarethreadedrenderloop_p.h
+}
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
index e868a4380e..796bc870de 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
@@ -56,7 +56,6 @@
#include <private/qquickprofiler_p.h>
#include <private/qsgtexture_p.h>
#include <private/qsgcompressedtexture_p.h>
-#include <private/qsgpkmhandler_p.h>
QT_BEGIN_NAMESPACE
@@ -154,13 +153,12 @@ QSGTexture *Texture::removedFromAtlas() const
}
if (!m_data.isEmpty()) {
- QSGCompressedTexture::DataPtr texData(QSGCompressedTexture::DataPtr::create());
- texData->data = m_data;
- texData->size = m_size;
- texData->format = static_cast<Atlas*>(m_atlas)->format();
- texData->hasAlpha = hasAlphaChannel();
- texData->dataLength = m_dataLength;
- texData->dataOffset = m_dataOffset;
+ QTextureFileData texData;
+ texData.setData(m_data);
+ texData.setSize(m_size);
+ texData.setGLInternalFormat(static_cast<Atlas*>(m_atlas)->format());
+ texData.setDataLength(m_dataLength);
+ texData.setDataOffset(m_dataOffset);
m_nonatlas_texture = new QSGCompressedTexture(texData);
m_nonatlas_texture->setMipmapFiltering(mipmapFiltering());
m_nonatlas_texture->setFiltering(filtering());
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
index 839c562989..d3310bc11c 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
@@ -49,50 +49,11 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(QSG_LOG_TEXTUREIO, "qt.scenegraph.textureio");
-bool QSGCompressedTextureData::isValid() const
-{
- if (data.isNull() || size.isEmpty() || !format)
- return false;
- if (dataLength < 0 || dataOffset < 0 || dataOffset >= data.length())
- return false;
- if (dataLength > 0 && qint64(dataOffset) + qint64(dataLength) > qint64(data.length()))
- return false;
-
- return true;
-}
-
-int QSGCompressedTextureData::sizeInBytes() const
-{
- if (!isValid())
- return 0;
- return dataLength > 0 ? dataLength : data.length() - dataOffset;
-}
-
-Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QSGCompressedTextureData *d)
-{
- QDebugStateSaver saver(dbg);
-
- dbg.nospace() << "QSGCompressedTextureData(";
- if (d) {
- dbg << d->logName << ' ';
- dbg << static_cast<QOpenGLTexture::TextureFormat>(d->format)
- << "[0x" << hex << d->format << dec << "]";
- dbg.space() << (d->hasAlpha ? "with" : "no") << "alpha" << d->size
- << "databuffer" << d->data.size() << "offset" << d->dataOffset << "length";
- dbg.nospace() << d->dataLength << ")";
- } else {
- dbg << "null)";
- }
- return dbg;
-}
-
-QSGCompressedTexture::QSGCompressedTexture(const DataPtr& texData)
+QSGCompressedTexture::QSGCompressedTexture(const QTextureFileData &texData)
: m_textureData(texData)
{
- if (m_textureData) {
- m_size = m_textureData->size;
- m_hasAlpha = m_textureData->hasAlpha;
- }
+ m_size = m_textureData.size();
+ m_hasAlpha = !formatIsOpaque(m_textureData.glInternalFormat());
}
QSGCompressedTexture::~QSGCompressedTexture()
@@ -155,37 +116,40 @@ void QSGCompressedTexture::bind()
if (m_uploaded)
return;
- QByteArray logName(m_textureData ? m_textureData->logName : QByteArrayLiteral("(unset)"));
-
- if (!m_textureData || !m_textureData->isValid()) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid texture data for %s", logName.constData());
+ if (!m_textureData.isValid()) {
+ qCDebug(QSG_LOG_TEXTUREIO, "Invalid texture data for %s", m_textureData.logName().constData());
funcs->glBindTexture(GL_TEXTURE_2D, 0);
return;
}
if (Q_UNLIKELY(QSG_LOG_TEXTUREIO().isDebugEnabled())) {
- qCDebug(QSG_LOG_TEXTUREIO) << "Uploading texture" << m_textureData.data();
+ qCDebug(QSG_LOG_TEXTUREIO) << "Uploading texture" << m_textureData;
while (funcs->glGetError() != GL_NO_ERROR);
}
- funcs->glCompressedTexImage2D(GL_TEXTURE_2D, 0, m_textureData->format,
- m_size.width(), m_size.height(), 0, m_textureData->sizeInBytes(),
- m_textureData->data.constData() + m_textureData->dataOffset);
+ funcs->glCompressedTexImage2D(GL_TEXTURE_2D, 0, m_textureData.glInternalFormat(),
+ m_size.width(), m_size.height(), 0, m_textureData.dataLength(),
+ m_textureData.data().constData() + m_textureData.dataOffset());
if (Q_UNLIKELY(QSG_LOG_TEXTUREIO().isDebugEnabled())) {
GLuint error = funcs->glGetError();
if (error != GL_NO_ERROR) {
- qCDebug(QSG_LOG_TEXTUREIO, "glCompressedTexImage2D failed for %s, error 0x%x", logName.constData(), error);
+ qCDebug(QSG_LOG_TEXTUREIO, "glCompressedTexImage2D failed for %s, error 0x%x", m_textureData.logName().constData(), error);
}
}
- m_textureData.clear(); // Release this memory, not needed anymore
+ m_textureData = QTextureFileData(); // Release this memory, not needed anymore
updateBindOptions(true);
m_uploaded = true;
#endif // QT_CONFIG(opengl)
}
+QTextureFileData QSGCompressedTexture::textureData() const
+{
+ return m_textureData;
+}
+
bool QSGCompressedTexture::formatIsOpaque(quint32 glTextureFormat)
{
switch (glTextureFormat) {
@@ -211,14 +175,14 @@ bool QSGCompressedTexture::formatIsOpaque(quint32 glTextureFormat)
}
}
-QSGCompressedTextureFactory::QSGCompressedTextureFactory(const QSGCompressedTexture::DataPtr &texData)
+QSGCompressedTextureFactory::QSGCompressedTextureFactory(const QTextureFileData &texData)
: m_textureData(texData)
{
}
QSGTexture *QSGCompressedTextureFactory::createTexture(QQuickWindow *window) const
{
- if (!m_textureData || !m_textureData->isValid())
+ if (!m_textureData.isValid())
return nullptr;
// attempt to atlas the texture
@@ -232,15 +196,12 @@ QSGTexture *QSGCompressedTextureFactory::createTexture(QQuickWindow *window) con
int QSGCompressedTextureFactory::textureByteCount() const
{
- return m_textureData ? m_textureData->sizeInBytes() : 0;
+ return qMax(0, m_textureData.data().size() - m_textureData.dataOffset());
}
-
QSize QSGCompressedTextureFactory::textureSize() const
{
- if (m_textureData && m_textureData->isValid())
- return m_textureData->size;
- return QSize();
+ return m_textureData.size();
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
index aa87316809..c3b58a2389 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <private/qtexturefiledata_p.h>
#include <QSGTexture>
#include <QtQuick/private/qsgcontext_p.h>
#include <QQuickTextureFactory>
@@ -58,30 +59,11 @@
QT_BEGIN_NAMESPACE
-struct Q_QUICK_PRIVATE_EXPORT QSGCompressedTextureData
-{
- QByteArray logName;
- QByteArray data;
- QSize size;
- uint format = 0;
- int dataOffset = 0;
- int dataLength = 0;
- bool hasAlpha = false;
-
- bool isValid() const;
- int sizeInBytes() const;
-};
-
-Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug, const QSGCompressedTextureData *);
-
-
class Q_QUICK_PRIVATE_EXPORT QSGCompressedTexture : public QSGTexture
{
Q_OBJECT
public:
- typedef QSharedPointer<QSGCompressedTextureData> DataPtr;
-
- QSGCompressedTexture(const DataPtr& texData);
+ QSGCompressedTexture(const QTextureFileData& texData);
virtual ~QSGCompressedTexture();
int textureId() const override;
@@ -91,12 +73,12 @@ public:
void bind() override;
- const QSGCompressedTextureData *textureData();
+ QTextureFileData textureData() const;
static bool formatIsOpaque(quint32 glTextureFormat);
protected:
- DataPtr m_textureData;
+ QTextureFileData m_textureData;
QSize m_size;
mutable uint m_textureId = 0;
bool m_hasAlpha = false;
@@ -110,13 +92,14 @@ namespace QSGAtlasTexture {
class Q_QUICK_PRIVATE_EXPORT QSGCompressedTextureFactory : public QQuickTextureFactory
{
public:
- QSGCompressedTextureFactory(const QSGCompressedTexture::DataPtr& texData);
+ QSGCompressedTextureFactory(const QTextureFileData& texData);
QSGTexture *createTexture(QQuickWindow *) const override;
int textureByteCount() const override;
QSize textureSize() const override;
protected:
- QSGCompressedTexture::DataPtr m_textureData;
+ QTextureFileData m_textureData;
+
private:
friend class QSGAtlasTexture::Manager;
};
diff --git a/src/quick/scenegraph/compressedtexture/qsgktxhandler.cpp b/src/quick/scenegraph/compressedtexture/qsgktxhandler.cpp
deleted file mode 100644
index e3e4ca6824..0000000000
--- a/src/quick/scenegraph/compressedtexture/qsgktxhandler.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsgktxhandler_p.h"
-#include "qsgcompressedtexture_p.h"
-#include <QOpenGLTexture>
-#include <QtEndian>
-
-//#define KTX_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-#define KTX_IDENTIFIER_LENGTH 12
-static const char ktxIdentifier[KTX_IDENTIFIER_LENGTH] = { '\xAB', 'K', 'T', 'X', ' ', '1', '1', '\xBB', '\r', '\n', '\x1A', '\n' };
-static const quint32 platformEndianIdentifier = 0x04030201;
-static const quint32 inversePlatformEndianIdentifier = 0x01020304;
-
-struct KTXHeader {
- quint8 identifier[KTX_IDENTIFIER_LENGTH]; //Must match ktxIdentifier
- quint32 endianness; //Either platformEndianIdentifier or inversePlatformEndianIdentifier, other values not allowed.
- quint32 glType;
- quint32 glTypeSize;
- quint32 glFormat;
- quint32 glInternalFormat;
- quint32 glBaseInternalFormat;
- quint32 pixelWidth;
- quint32 pixelHeight;
- quint32 pixelDepth;
- quint32 numberOfArrayElements;
- quint32 numberOfFaces;
- quint32 numberOfMipmapLevels;
- quint32 bytesOfKeyValueData;
-};
-
-static const int headerSize = sizeof(KTXHeader);
-
-// Currently unused, declared for future reference
-struct KTXKeyValuePairItem {
- quint32 keyAndValueByteSize;
- /*
- quint8 keyAndValue[keyAndValueByteSize];
- quint8 valuePadding[3 - ((keyAndValueByteSize + 3) % 4)];
- */
-};
-
-struct KTXMipmapLevel {
- quint32 imageSize;
- /*
- for each array_element in numberOfArrayElements*
- for each face in numberOfFaces
- for each z_slice in pixelDepth*
- for each row or row_of_blocks in pixelHeight*
- for each pixel or block_of_pixels in pixelWidth
- Byte data[format-specific-number-of-bytes]**
- end
- end
- end
- Byte cubePadding[0-3]
- end
- end
- quint8 mipPadding[3 - ((imageSize + 3) % 4)]
- */
-};
-
-bool QSGKtxHandler::canRead(const QByteArray &suffix, const QByteArray &block)
-{
- Q_UNUSED(suffix)
-
- return (qstrncmp(block.constData(), ktxIdentifier, KTX_IDENTIFIER_LENGTH) == 0);
-}
-
-QQuickTextureFactory *QSGKtxHandler::read()
-{
- if (!device())
- return nullptr;
-
- QByteArray buf = device()->readAll();
- if (buf.size() < headerSize || !canRead(QByteArray(), buf)) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid KTX file %s", logName().constData());
- return nullptr;
- }
-
- const KTXHeader *header = reinterpret_cast<const KTXHeader *>(buf.constData());
- if (!checkHeader(*header)) {
- qCDebug(QSG_LOG_TEXTUREIO, "Unsupported KTX file format in %s", logName().constData());
- return nullptr;
- }
-
- QSGCompressedTexture::DataPtr texData(QSGCompressedTexture::DataPtr::create());
-
- texData->size = QSize(decode(header->pixelWidth), decode(header->pixelHeight));
- texData->format = decode(header->glInternalFormat);
- texData->hasAlpha = !QSGCompressedTexture::formatIsOpaque(texData->format);
-
- // For now, ignore any additional mipmap levels
- int preambleSize = headerSize + decode(header->bytesOfKeyValueData);
- if (buf.size() >= preambleSize + int(sizeof(KTXMipmapLevel))) {
- texData->data = buf;
- texData->dataOffset = preambleSize + sizeof(quint32); // for the imageSize
- const KTXMipmapLevel *level = reinterpret_cast<const KTXMipmapLevel *>(buf.constData() + preambleSize);
- texData->dataLength = decode(level->imageSize);
- }
-
- if (!texData->isValid()) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid values in header of KTX file %s", logName().constData());
- return nullptr;
- }
-
- texData->logName = logName();
-#ifdef KTX_DEBUG
- qDebug() << "KTX file handler read" << texData.data();
-#endif
-
- return new QSGCompressedTextureFactory(texData);
-}
-
-bool QSGKtxHandler::checkHeader(const KTXHeader &header)
-{
- if (header.endianness != platformEndianIdentifier && header.endianness != inversePlatformEndianIdentifier)
- return false;
- inverseEndian = (header.endianness == inversePlatformEndianIdentifier);
-#ifdef KTX_DEBUG
- QMetaEnum tfme = QMetaEnum::fromType<QOpenGLTexture::TextureFormat>();
- QMetaEnum ptme = QMetaEnum::fromType<QOpenGLTexture::PixelType>();
- qDebug("Header of %s:", logName().constData());
- qDebug(" glType: 0x%x (%s)", decode(header.glType), ptme.valueToKey(decode(header.glType)));
- qDebug(" glTypeSize: %u", decode(header.glTypeSize));
- qDebug(" glFormat: 0x%x (%s)", decode(header.glFormat), tfme.valueToKey(decode(header.glFormat)));
- qDebug(" glInternalFormat: 0x%x (%s)", decode(header.glInternalFormat), tfme.valueToKey(decode(header.glInternalFormat)));
- qDebug(" glBaseInternalFormat: 0x%x (%s)", decode(header.glBaseInternalFormat), tfme.valueToKey(decode(header.glBaseInternalFormat)));
- qDebug(" pixelWidth: %u", decode(header.pixelWidth));
- qDebug(" pixelHeight: %u", decode(header.pixelHeight));
- qDebug(" pixelDepth: %u", decode(header.pixelDepth));
- qDebug(" numberOfArrayElements: %u", decode(header.numberOfArrayElements));
- qDebug(" numberOfFaces: %u", decode(header.numberOfFaces));
- qDebug(" numberOfMipmapLevels: %u", decode(header.numberOfMipmapLevels));
- qDebug(" bytesOfKeyValueData: %u", decode(header.bytesOfKeyValueData));
-#endif
- return ((decode(header.glType) == 0) &&
- (decode(header.glFormat) == 0) &&
- (decode(header.pixelDepth) == 0) &&
- (decode(header.numberOfFaces) == 1));
-}
-
-quint32 QSGKtxHandler::decode(quint32 val)
-{
- return inverseEndian ? qbswap<quint32>(val) : val;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp b/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp
deleted file mode 100644
index 618c0db045..0000000000
--- a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsgpkmhandler_p.h"
-#include "qsgcompressedtexture_p.h"
-
-#include <QFile>
-#include <QDebug>
-#include <qendian.h>
-#include <qopenglfunctions.h>
-#include <qqmlfile.h>
-#include <QOpenGLTexture>
-
-//#define ETC_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-static const int headerSize = 16;
-
-static unsigned int typeMap[5] = {
- QOpenGLTexture::RGB8_ETC1, // GL_ETC1_RGB8_OES,
- QOpenGLTexture::RGB8_ETC2, // GL_COMPRESSED_RGB8_ETC2,
- 0, // unused (obsolete)
- QOpenGLTexture::RGBA8_ETC2_EAC, // GL_COMPRESSED_RGBA8_ETC2_EAC,
- QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2 // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
-};
-
-bool QSGPkmHandler::canRead(const QByteArray &suffix, const QByteArray &block)
-{
- Q_UNUSED(suffix)
-
- return block.startsWith("PKM ");
-}
-
-QQuickTextureFactory *QSGPkmHandler::read()
-{
- if (!device())
- return nullptr;
-
- QSGCompressedTexture::DataPtr texData(QSGCompressedTexture::DataPtr::create());
-
- texData->data = device()->readAll();
- if (texData->data.size() < headerSize || !canRead(QByteArray(), texData->data)) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid PKM file %s", logName().constData());
- return nullptr;
- }
-
- const char *rawData = texData->data.constData();
-
- // ignore version (rawData + 4 & 5)
-
- // texture type
- quint16 type = qFromBigEndian<quint16>(rawData + 6);
- if (type > sizeof(typeMap)/sizeof(typeMap[0])) {
- qCDebug(QSG_LOG_TEXTUREIO, "Unknown compression format in PKM file %s", logName().constData());
- return nullptr;
- }
- texData->format = typeMap[type];
- texData->hasAlpha = !QSGCompressedTexture::formatIsOpaque(texData->format);
-
- // texture size
- const int bpb = (texData->format == QOpenGLTexture::RGBA8_ETC2_EAC) ? 16 : 8;
- QSize paddedSize(qFromBigEndian<quint16>(rawData + 8), qFromBigEndian<quint16>(rawData + 10));
- texData->dataLength = (paddedSize.width() / 4) * (paddedSize.height() / 4) * bpb;
- QSize texSize(qFromBigEndian<quint16>(rawData + 12), qFromBigEndian<quint16>(rawData + 14));
- texData->size = texSize;
-
- texData->dataOffset = headerSize;
-
- if (!texData->isValid()) {
- qCDebug(QSG_LOG_TEXTUREIO, "Invalid values in header of PKM file %s", logName().constData());
- return nullptr;
- }
-
- texData->logName = logName();
-#ifdef ETC_DEBUG
- qDebug() << "PKM file handler read" << texData.data();
-#endif
- return new QSGCompressedTextureFactory(texData);
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
index ab6fb4f317..b9805f9db6 100644
--- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
+++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h
@@ -61,6 +61,7 @@ public:
ClearStencilBuffer = 0x0004
};
Q_DECLARE_FLAGS(ClearMode, ClearModeBit)
+ Q_FLAG(ClearMode)
~QSGAbstractRenderer() override;
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index c64360f955..c99e149aa5 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -82,19 +82,26 @@ QSGDistanceFieldGlyphCache::~QSGDistanceFieldGlyphCache()
{
}
+QSGDistanceFieldGlyphCache::GlyphData &QSGDistanceFieldGlyphCache::emptyData(glyph_t glyph)
+{
+ GlyphData gd;
+ gd.texture = &s_emptyTexture;
+ QHash<glyph_t, GlyphData>::iterator it = m_glyphsData.insert(glyph, gd);
+ return it.value();
+}
+
QSGDistanceFieldGlyphCache::GlyphData &QSGDistanceFieldGlyphCache::glyphData(glyph_t glyph)
{
QHash<glyph_t, GlyphData>::iterator data = m_glyphsData.find(glyph);
if (data == m_glyphsData.end()) {
- GlyphData gd;
- gd.texture = &s_emptyTexture;
+ GlyphData &gd = emptyData(glyph);
gd.path = m_referenceFont.pathForGlyph(glyph);
// need bounding rect in base font size scale
qreal scaleFactor = qreal(1) / QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution);
QTransform scaleDown;
scaleDown.scale(scaleFactor, scaleFactor);
gd.boundingRect = scaleDown.mapRect(gd.path.boundingRect());
- data = m_glyphsData.insert(glyph, gd);
+ return gd;
}
return data.value();
}
@@ -234,10 +241,8 @@ void QSGDistanceFieldGlyphCache::setGlyphsPosition(const QList<GlyphPosition> &g
}
if (!invalidatedGlyphs.isEmpty()) {
- QLinkedList<QSGDistanceFieldGlyphConsumer *>::iterator it = m_registeredNodes.begin();
- while (it != m_registeredNodes.end()) {
- (*it)->invalidateGlyphs(invalidatedGlyphs);
- ++it;
+ for (QSGDistanceFieldGlyphConsumerList::iterator iter = m_registeredNodes.begin(); iter != m_registeredNodes.end(); ++iter) {
+ iter->invalidateGlyphs(invalidatedGlyphs);
}
}
}
@@ -280,10 +285,8 @@ void QSGDistanceFieldGlyphCache::setGlyphsTexture(const QVector<glyph_t> &glyphs
}
if (!invalidatedGlyphs.isEmpty()) {
- QLinkedList<QSGDistanceFieldGlyphConsumer*>::iterator it = m_registeredNodes.begin();
- while (it != m_registeredNodes.end()) {
- (*it)->invalidateGlyphs(invalidatedGlyphs);
- ++it;
+ for (QSGDistanceFieldGlyphConsumerList::iterator iter = m_registeredNodes.begin(); iter != m_registeredNodes.end(); ++iter) {
+ iter->invalidateGlyphs(invalidatedGlyphs);
}
}
}
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 9c88b8272c..ba5c4353b2 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -64,6 +64,7 @@
#include <QtGui/private/qdatabuffer_p.h>
#include <private/qopenglcontext_p.h>
#include <private/qdistancefield_p.h>
+#include <private/qintrusivelist_p.h>
// ### remove
#include <QtQuick/private/qquicktext_p.h>
@@ -82,6 +83,7 @@ class QSGGlyphNode;
class QSGRootNode;
class QSGSpriteNode;
class QSGRenderNode;
+class QSGRenderContext;
class Q_QUICK_PRIVATE_EXPORT QSGNodeVisitorEx
{
@@ -136,6 +138,7 @@ public:
virtual void setPenColor(const QColor &color) = 0;
virtual void setPenWidth(qreal width) = 0;
virtual void setGradientStops(const QGradientStops &stops) = 0;
+ virtual void setGradientVertical(bool vertical) = 0;
virtual void setRadius(qreal radius) = 0;
virtual void setAntialiasing(bool antialiasing) { Q_UNUSED(antialiasing) }
virtual void setAligned(bool aligned) = 0;
@@ -403,7 +406,9 @@ public:
virtual ~QSGDistanceFieldGlyphConsumer() {}
virtual void invalidateGlyphs(const QVector<quint32> &glyphs) = 0;
+ QIntrusiveListNode node;
};
+typedef QIntrusiveList<QSGDistanceFieldGlyphConsumer, &QSGDistanceFieldGlyphConsumer::node> QSGDistanceFieldGlyphConsumerList;
class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldGlyphCache
{
@@ -464,8 +469,8 @@ public:
void update();
- void registerGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.append(node); }
- void unregisterGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.removeOne(node); }
+ void registerGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.insert(node); }
+ void unregisterGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.remove(node); }
virtual void registerOwnerElement(QQuickItem *ownerElement);
virtual void unregisterOwnerElement(QQuickItem *ownerElement);
@@ -503,6 +508,7 @@ protected:
uint textureIdForGlyph(glyph_t glyph) const;
GlyphData &glyphData(glyph_t glyph);
+ GlyphData &emptyData(glyph_t glyph);
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
void saveTexture(GLuint textureId, int width, int height) const;
@@ -510,18 +516,21 @@ protected:
inline bool isCoreProfile() const { return m_coreProfile; }
-private:
+ bool m_doubleGlyphResolution;
+
+protected:
QRawFont m_referenceFont;
+
+private:
int m_glyphCount;
- bool m_doubleGlyphResolution;
bool m_coreProfile;
QList<Texture> m_textures;
QHash<glyph_t, GlyphData> m_glyphsData;
QDataBuffer<glyph_t> m_pendingGlyphs;
QSet<glyph_t> m_populatingGlyphs;
- QLinkedList<QSGDistanceFieldGlyphConsumer*> m_registeredNodes;
+ QSGDistanceFieldGlyphConsumerList m_registeredNodes;
static Texture s_emptyTexture;
};
diff --git a/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
index df124cce35..91317ee2d7 100644
--- a/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
@@ -68,19 +68,30 @@ namespace
{
float x, y;
Color4ub color;
- void set(float nx, float ny, Color4ub ncolor)
+
+ void set(float primary, float secondary, Color4ub ncolor, bool vertical)
{
- x = nx; y = ny; color = ncolor;
+ if (vertical) {
+ x = secondary; y = primary;
+ } else {
+ x = primary; y = secondary;
+ }
+ color = ncolor;
}
};
struct SmoothVertex : public Vertex
{
float dx, dy;
- void set(float nx, float ny, Color4ub ncolor, float ndx, float ndy)
+
+ void set(float primary, float secondary, Color4ub ncolor, float dPrimary, float dSecondary, bool vertical)
{
- Vertex::set(nx, ny, ncolor);
- dx = ndx; dy = ndy;
+ Vertex::set(primary, secondary, ncolor, vertical);
+ if (vertical) {
+ dx = dSecondary; dy = dPrimary;
+ } else {
+ dx = dPrimary; dy = dSecondary;
+ }
}
};
@@ -103,6 +114,7 @@ QSGBasicInternalRectangleNode::QSGBasicInternalRectangleNode()
, m_antialiasing(false)
, m_gradient_is_opaque(true)
, m_dirty_geometry(false)
+ , m_gradient_is_vertical(true)
, m_geometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 0)
{
setGeometry(&m_geometry);
@@ -160,6 +172,15 @@ void QSGBasicInternalRectangleNode::setGradientStops(const QGradientStops &stops
m_dirty_geometry = true;
}
+void QSGBasicInternalRectangleNode::setGradientVertical(bool vertical)
+{
+ if (vertical == m_gradient_is_vertical)
+ return;
+ m_gradient_is_vertical = vertical;
+ m_dirty_geometry = true;
+}
+
+
void QSGBasicInternalRectangleNode::setRadius(qreal radius)
{
if (radius == m_radius)
@@ -230,12 +251,15 @@ void QSGBasicInternalRectangleNode::updateGeometry()
Color4ub transparent = { 0, 0, 0, 0 };
const QGradientStops &stops = m_gradient_stops;
+ float length = (m_gradient_is_vertical ? height : width);
+ float secondaryLength = (m_gradient_is_vertical ? width : height);
+
int nextGradientStop = 0;
- float gradientPos = penWidth / height;
+ float gradientPos = penWidth / length;
while (nextGradientStop < stops.size() && stops.at(nextGradientStop).first <= gradientPos)
++nextGradientStop;
int lastGradientStop = stops.size() - 1;
- float lastGradientPos = 1.0f - penWidth / height;
+ float lastGradientPos = 1.0f - penWidth / length;
while (lastGradientStop >= nextGradientStop && stops.at(lastGradientStop).first >= lastGradientPos)
--lastGradientStop;
int gradientIntersections = (lastGradientStop - nextGradientStop + 1);
@@ -319,40 +343,46 @@ void QSGBasicInternalRectangleNode::updateGeometry()
quint16 *indices = g->indexDataAsUShort();
quint16 index = 0;
- float py = 0; // previous inner y-coordinate.
- float plx = 0; // previous inner left x-coordinate.
- float prx = 0; // previous inner right x-coordinate.
+ float pp = 0; // previous inner primary coordinate.
+ float pss = 0; // previous inner secondary start coordinate.
+ float pse = 0; // previous inner secondary end coordinate.
float angle = 0.5f * float(M_PI) / segments;
float cosStep = qFastCos(angle);
float sinStep = qFastSin(angle);
+ float innerStart = (m_gradient_is_vertical ? innerRect.top() : innerRect.left());
+ float innerEnd = (m_gradient_is_vertical ? innerRect.bottom() : innerRect.right());
+ float innerLength = (m_gradient_is_vertical ? innerRect.height() : innerRect.width());
+ float innerSecondaryStart = (m_gradient_is_vertical ? innerRect.left() : innerRect.top());
+ float innerSecondaryEnd = (m_gradient_is_vertical ? innerRect.right() : innerRect.bottom());
+
for (int part = 0; part < 2; ++part) {
float c = 1 - part;
float s = part;
for (int i = 0; i <= segments; ++i) {
- float y, lx, rx;
+ float p, ss, se;
if (innerRadius > 0) {
- y = (part ? innerRect.bottom() : innerRect.top()) - innerRadius * c; // current inner y-coordinate.
- lx = innerRect.left() - innerRadius * s; // current inner left x-coordinate.
- rx = innerRect.right() + innerRadius * s; // current inner right x-coordinate.
- gradientPos = ((part ? innerRect.height() : 0) + radius - innerRadius * c) / height;
+ p = (part ? innerEnd : innerStart) - innerRadius * c; // current inner primary coordinate.
+ ss = innerSecondaryStart - innerRadius * s; // current inner secondary start coordinate.
+ se = innerSecondaryEnd + innerRadius * s; // current inner secondary end coordinate.
+ gradientPos = ((part ? innerLength : 0) + radius - innerRadius * c) / length;
} else {
- y = (part ? innerRect.bottom() + innerRadius : innerRect.top() - innerRadius); // current inner y-coordinate.
- lx = innerRect.left() - innerRadius; // current inner left x-coordinate.
- rx = innerRect.right() + innerRadius; // current inner right x-coordinate.
- gradientPos = ((part ? innerRect.height() + innerRadius : -innerRadius) + radius) / height;
+ p = (part ? innerEnd + innerRadius : innerStart - innerRadius); // current inner primary coordinate.
+ ss = innerSecondaryStart - innerRadius; // current inner secondary start coordinate.
+ se = innerSecondaryEnd + innerRadius; // current inner secondary end coordinate.
+ gradientPos = ((part ? innerLength + innerRadius : -innerRadius) + radius) / length;
}
- float Y = (part ? innerRect.bottom() : innerRect.top()) - outerRadius * c; // current outer y-coordinate.
- float lX = innerRect.left() - outerRadius * s; // current outer left x-coordinate.
- float rX = innerRect.right() + outerRadius * s; // current outer right x-coordinate.
+ float outerEdge = (part ? innerEnd : innerStart) - outerRadius * c; // current outer primary coordinate.
+ float outerSecondaryStart = innerSecondaryStart - outerRadius * s; // current outer secondary start coordinate.
+ float outerSecondaryEnd = innerSecondaryEnd + outerRadius * s; // current outer secondary end coordinate.
while (nextGradientStop <= lastGradientStop && stops.at(nextGradientStop).first <= gradientPos) {
// Insert vertices at gradient stops.
- float gy = (innerRect.top() - radius) + stops.at(nextGradientStop).first * height;
- float t = (gy - py) / (y - py);
- float glx = plx * (1 - t) + t * lx;
- float grx = prx * (1 - t) + t * rx;
+ float gp = (innerStart - radius) + stops.at(nextGradientStop).first * length;
+ float t = (gp - pp) / (p - pp);
+ float gis = pss * (1 - t) + t * ss; // gradient inner start
+ float gie = pse * (1 - t) + t * se; // gradient inner end
fillColor = colorToColor4ub(stops.at(nextGradientStop).second);
@@ -377,23 +407,23 @@ void QSGBasicInternalRectangleNode::updateGeometry()
indices[innerAATail++] = index + 3;
bool lower = stops.at(nextGradientStop).first > 0.5f;
- float dy = lower ? qMin(0.0f, height - gy - delta) : qMax(0.0f, delta - gy);
- smoothVertices[index++].set(grx, gy, fillColor, width - grx - delta, dy);
- smoothVertices[index++].set(glx, gy, fillColor, delta - glx, dy);
+ float dp = lower ? qMin(0.0f, length - gp - delta) : qMax(0.0f, delta - gp);
+ smoothVertices[index++].set(gp, gie, fillColor, dp, secondaryLength - gie - delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, gis, fillColor, dp, delta - gis, m_gradient_is_vertical);
if (penWidth) {
- smoothVertices[index++].set(grx, gy, borderColor, 0.49f * penWidth * s, -0.49f * penWidth * c);
- smoothVertices[index++].set(glx, gy, borderColor, -0.49f * penWidth * s, -0.49f * penWidth * c);
+ smoothVertices[index++].set(gp, gie, borderColor, -0.49f * penWidth * c, 0.49f * penWidth * s, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, gis, borderColor, -0.49f * penWidth * c, -0.49f * penWidth * s, m_gradient_is_vertical);
} else {
- dy = lower ? delta : -delta;
- smoothVertices[index++].set(grx, gy, transparent, delta, dy);
- smoothVertices[index++].set(glx, gy, transparent, -delta, dy);
+ dp = lower ? delta : -delta;
+ smoothVertices[index++].set(gp, gie, transparent, dp, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, gis, transparent, dp, -delta, m_gradient_is_vertical);
}
} else {
- vertices[index++].set(grx, gy, fillColor);
- vertices[index++].set(glx, gy, fillColor);
+ vertices[index++].set(gp, gie, fillColor, m_gradient_is_vertical);
+ vertices[index++].set(gp, gis, fillColor, m_gradient_is_vertical);
if (penWidth) {
- vertices[index++].set(grx, gy, borderColor);
- vertices[index++].set(glx, gy, borderColor);
+ vertices[index++].set(gp, gie, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(gp, gis, borderColor, m_gradient_is_vertical);
}
}
++nextGradientStop;
@@ -430,41 +460,41 @@ void QSGBasicInternalRectangleNode::updateGeometry()
indices[innerAATail++] = index + 1;
indices[innerAATail++] = index + 3;
- float dy = part ? qMin(0.0f, height - y - delta) : qMax(0.0f, delta - y);
- smoothVertices[index++].set(rx, y, fillColor, width - rx - delta, dy);
- smoothVertices[index++].set(lx, y, fillColor, delta - lx, dy);
+ float dp = part ? qMin(0.0f, length - p - delta) : qMax(0.0f, delta - p);
+ smoothVertices[index++].set(p, se, fillColor, dp, secondaryLength - se - delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(p, ss, fillColor, dp, delta - ss, m_gradient_is_vertical);
- dy = part ? delta : -delta;
+ dp = part ? delta : -delta;
if (penWidth) {
- smoothVertices[index++].set(rx, y, borderColor, 0.49f * penWidth * s, -0.49f * penWidth * c);
- smoothVertices[index++].set(lx, y, borderColor, -0.49f * penWidth * s, -0.49f * penWidth * c);
- smoothVertices[index++].set(rX, Y, borderColor, -0.49f * penWidth * s, 0.49f * penWidth * c);
- smoothVertices[index++].set(lX, Y, borderColor, 0.49f * penWidth * s, 0.49f * penWidth * c);
- smoothVertices[index++].set(rX, Y, transparent, delta, dy);
- smoothVertices[index++].set(lX, Y, transparent, -delta, dy);
+ smoothVertices[index++].set(p, se, borderColor, -0.49f * penWidth * c, 0.49f * penWidth * s, m_gradient_is_vertical);
+ smoothVertices[index++].set(p, ss, borderColor, -0.49f * penWidth * c, -0.49f * penWidth * s, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryEnd, borderColor, 0.49f * penWidth * c, -0.49f * penWidth * s, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryStart, borderColor, 0.49f * penWidth * c, 0.49f * penWidth * s, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryEnd, transparent, dp, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryStart, transparent, dp, -delta, m_gradient_is_vertical);
indices[--outerAAHead] = index - 2;
indices[--outerAAHead] = index - 4;
indices[outerAATail++] = index - 3;
indices[outerAATail++] = index - 1;
} else {
- smoothVertices[index++].set(rx, y, transparent, delta, dy);
- smoothVertices[index++].set(lx, y, transparent, -delta, dy);
+ smoothVertices[index++].set(p, se, transparent, dp, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(p, ss, transparent, dp, -delta, m_gradient_is_vertical);
}
} else {
- vertices[index++].set(rx, y, fillColor);
- vertices[index++].set(lx, y, fillColor);
+ vertices[index++].set(p, se, fillColor, m_gradient_is_vertical);
+ vertices[index++].set(p, ss, fillColor, m_gradient_is_vertical);
if (penWidth) {
- vertices[index++].set(rx, y, borderColor);
- vertices[index++].set(lx, y, borderColor);
- vertices[index++].set(rX, Y, borderColor);
- vertices[index++].set(lX, Y, borderColor);
+ vertices[index++].set(p, se, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(p, ss, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(outerEdge, outerSecondaryEnd, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(outerEdge, outerSecondaryStart, borderColor, m_gradient_is_vertical);
}
}
- py = y;
- plx = lx;
- prx = rx;
+ pp = p;
+ pss = ss;
+ pse = se;
// Rotate
qreal tmp = c;
@@ -543,19 +573,24 @@ void QSGBasicInternalRectangleNode::updateGeometry()
quint16 *indices = g->indexDataAsUShort();
quint16 index = 0;
- float lx = innerRect.left();
- float rx = innerRect.right();
- float lX = outerRect.left();
- float rX = outerRect.right();
+ float innerStart = (m_gradient_is_vertical ? innerRect.top() : innerRect.left());
+ float innerEnd = (m_gradient_is_vertical ? innerRect.bottom() : innerRect.right());
+ float outerStart = (m_gradient_is_vertical ? outerRect.top() : outerRect.left());
+ float outerEnd = (m_gradient_is_vertical ? outerRect.bottom() : outerRect.right());
+
+ float innerSecondaryStart = (m_gradient_is_vertical ? innerRect.left() : innerRect.top());
+ float innerSecondaryEnd = (m_gradient_is_vertical ? innerRect.right() : innerRect.bottom());
+ float outerSecondaryStart = (m_gradient_is_vertical ? outerRect.left() : outerRect.top());
+ float outerSecondaryEnd = (m_gradient_is_vertical ? outerRect.right() : outerRect.bottom());
for (int part = -1; part <= 1; part += 2) {
- float y = (part == 1 ? innerRect.bottom() : innerRect.top());
- float Y = (part == 1 ? outerRect.bottom() : outerRect.top());
- gradientPos = (y - innerRect.top() + penWidth) / height;
+ float innerEdge = (part == 1 ? innerEnd : innerStart);
+ float outerEdge = (part == 1 ? outerEnd : outerStart);
+ gradientPos = (innerEdge - innerStart + penWidth) / length;
while (nextGradientStop <= lastGradientStop && stops.at(nextGradientStop).first <= gradientPos) {
// Insert vertices at gradient stops.
- float gy = (innerRect.top() - penWidth) + stops.at(nextGradientStop).first * height;
+ float gp = (innerStart - penWidth) + stops.at(nextGradientStop).first * length;
fillColor = colorToColor4ub(stops.at(nextGradientStop).second);
@@ -580,22 +615,22 @@ void QSGBasicInternalRectangleNode::updateGeometry()
indices[innerAATail++] = index + 3;
bool lower = stops.at(nextGradientStop).first > 0.5f;
- float dy = lower ? qMin(0.0f, height - gy - delta) : qMax(0.0f, delta - gy);
- smoothVertices[index++].set(rx, gy, fillColor, width - rx - delta, dy);
- smoothVertices[index++].set(lx, gy, fillColor, delta - lx, dy);
+ float dp = lower ? qMin(0.0f, length - gp - delta) : qMax(0.0f, delta - gp);
+ smoothVertices[index++].set(gp, innerSecondaryEnd, fillColor, dp, secondaryLength - innerSecondaryEnd - delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, innerSecondaryStart, fillColor, dp, delta - innerSecondaryStart, m_gradient_is_vertical);
if (penWidth) {
- smoothVertices[index++].set(rx, gy, borderColor, 0.49f * penWidth, (lower ? 0.49f : -0.49f) * penWidth);
- smoothVertices[index++].set(lx, gy, borderColor, -0.49f * penWidth, (lower ? 0.49f : -0.49f) * penWidth);
+ smoothVertices[index++].set(gp, innerSecondaryEnd, borderColor, (lower ? 0.49f : -0.49f) * penWidth, 0.49f * penWidth, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, innerSecondaryStart, borderColor, (lower ? 0.49f : -0.49f) * penWidth, -0.49f * penWidth, m_gradient_is_vertical);
} else {
- smoothVertices[index++].set(rx, gy, transparent, delta, lower ? delta : -delta);
- smoothVertices[index++].set(lx, gy, transparent, -delta, lower ? delta : -delta);
+ smoothVertices[index++].set(gp, innerSecondaryEnd, transparent, lower ? delta : -delta, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(gp, innerSecondaryStart, transparent, lower ? delta : -delta, -delta, m_gradient_is_vertical);
}
} else {
- vertices[index++].set(rx, gy, fillColor);
- vertices[index++].set(lx, gy, fillColor);
+ vertices[index++].set(gp, innerSecondaryEnd, fillColor, m_gradient_is_vertical);
+ vertices[index++].set(gp, innerSecondaryStart, fillColor, m_gradient_is_vertical);
if (penWidth) {
- vertices[index++].set(rx, gy, borderColor);
- vertices[index++].set(lx, gy, borderColor);
+ vertices[index++].set(gp, innerSecondaryEnd, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(gp, innerSecondaryStart, borderColor, m_gradient_is_vertical);
}
}
++nextGradientStop;
@@ -632,34 +667,34 @@ void QSGBasicInternalRectangleNode::updateGeometry()
indices[innerAATail++] = index + 1;
indices[innerAATail++] = index + 3;
- float dy = part == 1 ? qMin(0.0f, height - y - delta) : qMax(0.0f, delta - y);
- smoothVertices[index++].set(rx, y, fillColor, width - rx - delta, dy);
- smoothVertices[index++].set(lx, y, fillColor, delta - lx, dy);
+ float dp = part == 1 ? qMin(0.0f, length - innerEdge - delta) : qMax(0.0f, delta - innerEdge);
+ smoothVertices[index++].set(innerEdge, innerSecondaryEnd, fillColor, dp, secondaryLength - innerSecondaryEnd - delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(innerEdge, innerSecondaryStart, fillColor, dp, delta - innerSecondaryStart, m_gradient_is_vertical);
if (penWidth) {
- smoothVertices[index++].set(rx, y, borderColor, 0.49f * penWidth, 0.49f * penWidth * part);
- smoothVertices[index++].set(lx, y, borderColor, -0.49f * penWidth, 0.49f * penWidth * part);
- smoothVertices[index++].set(rX, Y, borderColor, -0.49f * penWidth, -0.49f * penWidth * part);
- smoothVertices[index++].set(lX, Y, borderColor, 0.49f * penWidth, -0.49f * penWidth * part);
- smoothVertices[index++].set(rX, Y, transparent, delta, delta * part);
- smoothVertices[index++].set(lX, Y, transparent, -delta, delta * part);
+ smoothVertices[index++].set(innerEdge, innerSecondaryEnd, borderColor, 0.49f * penWidth * part, 0.49f * penWidth, m_gradient_is_vertical);
+ smoothVertices[index++].set(innerEdge, innerSecondaryStart, borderColor, 0.49f * penWidth * part, -0.49f * penWidth, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryEnd, borderColor, -0.49f * penWidth * part, -0.49f * penWidth, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryStart, borderColor, -0.49f * penWidth * part, 0.49f * penWidth, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryEnd, transparent, delta * part, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(outerEdge, outerSecondaryStart, transparent, delta * part, -delta, m_gradient_is_vertical);
indices[--outerAAHead] = index - 2;
indices[--outerAAHead] = index - 4;
indices[outerAATail++] = index - 3;
indices[outerAATail++] = index - 1;
} else {
- smoothVertices[index++].set(rx, y, transparent, delta, delta * part);
- smoothVertices[index++].set(lx, y, transparent, -delta, delta * part);
+ smoothVertices[index++].set(innerEdge, innerSecondaryEnd, transparent, delta * part, delta, m_gradient_is_vertical);
+ smoothVertices[index++].set(innerEdge, innerSecondaryStart, transparent, delta * part, -delta, m_gradient_is_vertical);
}
} else {
- vertices[index++].set(rx, y, fillColor);
- vertices[index++].set(lx, y, fillColor);
+ vertices[index++].set(innerEdge, innerSecondaryEnd, fillColor, m_gradient_is_vertical);
+ vertices[index++].set(innerEdge, innerSecondaryStart, fillColor, m_gradient_is_vertical);
if (penWidth) {
- vertices[index++].set(rx, y, borderColor);
- vertices[index++].set(lx, y, borderColor);
- vertices[index++].set(rX, Y, borderColor);
- vertices[index++].set(lX, Y, borderColor);
+ vertices[index++].set(innerEdge, innerSecondaryEnd, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(innerEdge, innerSecondaryStart, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(outerEdge, outerSecondaryEnd, borderColor, m_gradient_is_vertical);
+ vertices[index++].set(outerEdge, outerSecondaryStart, borderColor, m_gradient_is_vertical);
}
}
}
diff --git a/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h b/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h
index 98e53669ce..99f26b9aed 100644
--- a/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h
@@ -66,6 +66,7 @@ public:
void setPenColor(const QColor &color) override;
void setPenWidth(qreal width) override;
void setGradientStops(const QGradientStops &stops) override;
+ void setGradientVertical(bool vertical) override;
void setRadius(qreal radius) override;
void setAntialiasing(bool antialiasing) override;
void setAligned(bool aligned) override;
@@ -90,6 +91,7 @@ protected:
uint m_antialiasing : 1;
uint m_gradient_is_opaque : 1;
uint m_dirty_geometry : 1;
+ uint m_gradient_is_vertical : 1;
QSGGeometry m_geometry;
};
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 628619fa46..66add51c55 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -73,6 +73,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
struct QSGAdaptationBackendData
{
QSGAdaptationBackendData();
+ ~QSGAdaptationBackendData();
+ Q_DISABLE_COPY(QSGAdaptationBackendData)
bool tried = false;
QSGContextFactoryInterface *factory = nullptr;
@@ -91,6 +93,11 @@ QSGAdaptationBackendData::QSGAdaptationBackendData()
builtIns.append(new QSGSoftwareAdaptation);
}
+QSGAdaptationBackendData::~QSGAdaptationBackendData()
+{
+ qDeleteAll(builtIns);
+}
+
Q_GLOBAL_STATIC(QSGAdaptationBackendData, qsg_adaptation_data)
// This only works when the backend is loaded (contextFactory() was called),
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index ef189ba461..ccc57b0b86 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -39,12 +39,18 @@
#include "qsgdefaultdistancefieldglyphcache_p.h"
+#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qbuffer.h>
+#include <QtQml/qqmlfile.h>
+
#include <QtGui/private/qdistancefield_p.h>
#include <QtGui/private/qopenglcontext_p.h>
#include <QtQml/private/qqmlglobal_p.h>
#include <qopenglfunctions.h>
#include <qopenglframebufferobject.h>
#include <qmath.h>
+#include "qsgcontext_p.h"
+
#if !defined(QT_OPENGL_ES_2)
#include <QtGui/qopenglfunctions_3_2_core.h>
@@ -59,10 +65,12 @@ DEFINE_BOOL_CONFIG_OPTION(qsgPreferFullSizeGlyphCacheTextures, QSG_PREFER_FULLSI
# define QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING 2
#endif
-QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QOpenGLContext *c, const QRawFont &font)
+QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QOpenGLContext *c,
+ const QRawFont &font)
: QSGDistanceFieldGlyphCache(c, font)
, m_maxTextureSize(0)
, m_maxTextureCount(3)
+ , m_areaAllocator(nullptr)
, m_blitProgram(nullptr)
, m_blitBuffer(QOpenGLBuffer::VertexBuffer)
, m_fboGuard(nullptr)
@@ -81,7 +89,8 @@ QSGDefaultDistanceFieldGlyphCache::QSGDefaultDistanceFieldGlyphCache(QOpenGLCont
qWarning("Buffer creation failed");
}
- m_areaAllocator = new QSGAreaAllocator(QSize(maxTextureSize(), m_maxTextureCount * maxTextureSize()));
+ // Load a pregenerated cache if the font contains one
+ loadPregeneratedCache(font);
}
QSGDefaultDistanceFieldGlyphCache::~QSGDefaultDistanceFieldGlyphCache()
@@ -101,6 +110,9 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyph
QList<GlyphPosition> glyphPositions;
QVector<glyph_t> glyphsToRender;
+ if (m_areaAllocator == nullptr)
+ m_areaAllocator = new QSGAreaAllocator(QSize(maxTextureSize(), m_maxTextureCount * maxTextureSize()));
+
for (QSet<glyph_t>::const_iterator it = glyphs.constBegin(); it != glyphs.constEnd() ; ++it) {
glyph_t glyphIndex = *it;
@@ -237,10 +249,23 @@ void QSGDefaultDistanceFieldGlyphCache::releaseGlyphs(const QSet<glyph_t> &glyph
m_unusedGlyphs += glyphs;
}
-void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int width, int height)
+void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo,
+ int width,
+ int height)
+{
+ QByteArray zeroBuf(width * height, 0);
+ createTexture(texInfo, width, height, zeroBuf.constData());
+}
+
+void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo,
+ int width,
+ int height,
+ const void *pixels)
{
- if (useTextureResizeWorkaround() && texInfo->image.isNull())
+ if (useTextureResizeWorkaround() && texInfo->image.isNull()) {
texInfo->image = QDistanceField(width, height);
+ memcpy(texInfo->image.bits(), pixels, width * height);
+ }
while (m_funcs->glGetError() != GL_NO_ERROR) { }
@@ -261,8 +286,7 @@ void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int
const GLenum format = GL_ALPHA;
#endif
- QByteArray zeroBuf(width * height, 0);
- m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, zeroBuf.constData());
+ m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pixels);
texInfo->size = QSize(width, height);
@@ -520,4 +544,261 @@ int QSGDefaultDistanceFieldGlyphCache::maxTextureSize() const
return m_maxTextureSize;
}
+namespace {
+ struct Qtdf {
+ // We need these structs to be tightly packed, but some compilers we use do not
+ // support #pragma pack(1), so we need to hardcode the offsets/sizes in the
+ // file format
+ enum TableSize {
+ HeaderSize = 14,
+ GlyphRecordSize = 46,
+ TextureRecordSize = 17
+ };
+
+ enum Offset {
+ // Header
+ majorVersion = 0,
+ minorVersion = 1,
+ pixelSize = 2,
+ textureSize = 4,
+ flags = 8,
+ headerPadding = 9,
+ numGlyphs = 10,
+
+ // Glyph record
+ glyphIndex = 0,
+ textureOffsetX = 4,
+ textureOffsetY = 8,
+ textureWidth = 12,
+ textureHeight = 16,
+ xMargin = 20,
+ yMargin = 24,
+ boundingRectX = 28,
+ boundingRectY = 32,
+ boundingRectWidth = 36,
+ boundingRectHeight = 40,
+ textureIndex = 44,
+
+ // Texture record
+ allocatedX = 0,
+ allocatedY = 4,
+ allocatedWidth = 8,
+ allocatedHeight = 12,
+ texturePadding = 16
+
+ };
+
+ template <typename T>
+ static inline T fetch(const char *data, Offset offset)
+ {
+ return qFromBigEndian<T>(data + int(offset));
+ }
+ };
+}
+
+bool QSGDefaultDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+{
+ // The pregenerated data must be loaded first, otherwise the area allocator
+ // will be wrong
+ if (m_areaAllocator != nullptr) {
+ qWarning("Font cache must be loaded before cache is used");
+ return false;
+ }
+
+ static QElapsedTimer timer;
+
+ bool profile = QSG_LOG_TIME_GLYPH().isDebugEnabled();
+ if (profile)
+ timer.start();
+
+ QByteArray qtdfTable = font.fontTable("qtdf");
+ if (qtdfTable.isEmpty())
+ return false;
+
+ typedef QHash<TextureInfo *, QVector<glyph_t> > GlyphTextureHash;
+
+ GlyphTextureHash glyphTextures;
+
+ if (uint(qtdfTable.size()) < Qtdf::HeaderSize) {
+ qWarning("Invalid qtdf table in font '%s'",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ const char *qtdfTableStart = qtdfTable.constData();
+ const char *qtdfTableEnd = qtdfTableStart + qtdfTable.size();
+
+ int padding = 0;
+ int textureCount = 0;
+ {
+ quint8 majorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::majorVersion);
+ quint8 minorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::minorVersion);
+ if (majorVersion != 5 || minorVersion != 12) {
+ qWarning("Invalid version of qtdf table %d.%d in font '%s'",
+ majorVersion,
+ minorVersion,
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ qreal pixelSize = qreal(Qtdf::fetch<quint16>(qtdfTableStart, Qtdf::pixelSize));
+ m_maxTextureSize = Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::textureSize);
+ m_doubleGlyphResolution = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::flags) == 1;
+ padding = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::headerPadding);
+
+ if (pixelSize <= 0.0) {
+ qWarning("Invalid pixel size in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ if (m_maxTextureSize <= 0) {
+ qWarning("Invalid texture size in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ int systemMaxTextureSize;
+ m_funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &systemMaxTextureSize);
+
+ if (m_maxTextureSize > systemMaxTextureSize) {
+ qWarning("System maximum texture size is %d. This is lower than the value in '%s', which is %d",
+ systemMaxTextureSize,
+ qPrintable(font.familyName()),
+ m_maxTextureSize);
+ }
+
+ if (padding != QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING) {
+ qWarning("Padding mismatch in '%s'. Font requires %d, but Qt is compiled with %d.",
+ qPrintable(font.familyName()),
+ padding,
+ QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING);
+ }
+
+ m_referenceFont.setPixelSize(pixelSize);
+
+ quint32 glyphCount = Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::numGlyphs);
+ m_unusedGlyphs.reserve(glyphCount);
+
+ const char *allocatorData = qtdfTableStart + Qtdf::HeaderSize;
+ {
+ m_areaAllocator = new QSGAreaAllocator(QSize(0, 0));
+ allocatorData = m_areaAllocator->deserialize(allocatorData, qtdfTableEnd - allocatorData);
+ if (allocatorData == nullptr)
+ return false;
+ }
+
+ if (m_areaAllocator->size().height() % m_maxTextureSize != 0) {
+ qWarning("Area allocator size mismatch in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ textureCount = m_areaAllocator->size().height() / m_maxTextureSize;
+ m_maxTextureCount = qMax(m_maxTextureCount, textureCount);
+
+ const char *textureRecord = allocatorData;
+ for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+ if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ TextureInfo *tex = textureInfo(i);
+ tex->allocatedArea.setX(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedX));
+ tex->allocatedArea.setY(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedY));
+ tex->allocatedArea.setWidth(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedWidth));
+ tex->allocatedArea.setHeight(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedHeight));
+ tex->padding = Qtdf::fetch<quint8>(textureRecord, Qtdf::texturePadding);
+ }
+
+ const char *glyphRecord = textureRecord;
+ for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+ if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ glyph_t glyph = Qtdf::fetch<quint32>(glyphRecord, Qtdf::glyphIndex);
+ m_unusedGlyphs.insert(glyph);
+
+ GlyphData &glyphData = emptyData(glyph);
+
+#define FROM_FIXED_POINT(value) \
+(((qreal)value)/(qreal)65536)
+
+ glyphData.texCoord.x = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetX));
+ glyphData.texCoord.y = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetY));
+ glyphData.texCoord.width = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureWidth));
+ glyphData.texCoord.height = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureHeight));
+ glyphData.texCoord.xMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::xMargin));
+ glyphData.texCoord.yMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::yMargin));
+ glyphData.boundingRect.setX(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectX)));
+ glyphData.boundingRect.setY(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectY)));
+ glyphData.boundingRect.setWidth(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectWidth)));
+ glyphData.boundingRect.setHeight(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectHeight)));
+
+#undef FROM_FIXED_POINT
+
+ int textureIndex = Qtdf::fetch<quint16>(glyphRecord, Qtdf::textureIndex);
+ if (textureIndex < 0 || textureIndex >= textureCount) {
+ qWarning("Invalid texture index %d (texture count == %d) in '%s'",
+ textureIndex,
+ textureCount,
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+
+ TextureInfo *texInfo = textureInfo(textureIndex);
+ m_glyphsTexture.insert(glyph, texInfo);
+
+ glyphTextures[texInfo].append(glyph);
+ }
+
+ GLint alignment = 4; // default value
+ m_funcs->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ const uchar *textureData = reinterpret_cast<const uchar *>(glyphRecord);
+ for (int i = 0; i < textureCount; ++i) {
+
+ TextureInfo *texInfo = textureInfo(i);
+
+ int width = texInfo->allocatedArea.width();
+ int height = texInfo->allocatedArea.height();
+ qint64 size = width * height;
+ if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ createTexture(texInfo, width, height, textureData);
+
+ QVector<glyph_t> glyphs = glyphTextures.value(texInfo);
+
+ Texture t;
+ t.textureId = texInfo->texture;
+ t.size = texInfo->size;
+
+ setGlyphsTexture(glyphs, t);
+
+ textureData += size;
+ }
+
+ m_funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+ }
+
+ if (profile) {
+ quint64 now = timer.elapsed();
+ qCDebug(QSG_LOG_TIME_GLYPH,
+ "distancefield: %d pre-generated glyphs loaded in %dms",
+ m_unusedGlyphs.size(),
+ (int) now);
+ }
+
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
index 76c0d20647..a0e4387af9 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
@@ -85,7 +85,10 @@ public:
void setMaxTextureCount(int max) { m_maxTextureCount = max; }
int maxTextureCount() const { return m_maxTextureCount; }
+
private:
+ bool loadPregeneratedCache(const QRawFont &font);
+
struct TextureInfo {
GLuint texture;
QSize size;
@@ -96,6 +99,7 @@ private:
TextureInfo(const QRect &preallocRect = QRect()) : texture(0), allocatedArea(preallocRect) { }
};
+ void createTexture(TextureInfo * texInfo, int width, int height, const void *pixels);
void createTexture(TextureInfo * texInfo, int width, int height);
void resizeTexture(TextureInfo * texInfo, int width, int height);
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 22e97a2dc9..73b79c6300 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -325,7 +325,8 @@ bool QSGDefaultRenderContext::separateIndexBuffer() const
// lifetime. An attempt to bind a buffer object to the other
// target will generate an INVALID_OPERATION error, and the
// current binding will remain untouched.
- static const bool isWebGL = qGuiApp->platformName().compare(QLatin1String("webgl")) == 0;
+ static const bool isWebGL = (qGuiApp->platformName().compare(QLatin1String("webgl")) == 0
+ || qGuiApp->platformName().compare(QLatin1String("wasm")) == 0);
return isWebGL;
}
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 05f635cf1d..3d579fde46 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -221,10 +221,12 @@ QSGRenderLoop *QSGRenderLoop::instance()
}
switch (loopType) {
+#if QT_CONFIG(thread)
case ThreadedRenderLoop:
qCDebug(QSG_LOG_INFO, "threaded render loop");
s_instance = new QSGThreadedRenderLoop();
break;
+#endif
case WindowsRenderLoop:
qCDebug(QSG_LOG_INFO, "windows render loop");
s_instance = new QSGWindowsRenderLoop();
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index 4f98638487..ddd7fb7f4c 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -115,7 +115,6 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/util/qsgdefaultimagenode.cpp \
$$PWD/util/qsgdefaultninepatchnode.cpp \
$$PWD/qsgdefaultlayer.cpp \
- $$PWD/qsgthreadedrenderloop.cpp \
$$PWD/qsgwindowsrenderloop.cpp
HEADERS += \
$$PWD/qsgdefaultglyphnode_p.h \
@@ -132,9 +131,15 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/util/qsgdefaultimagenode_p.h \
$$PWD/util/qsgdefaultninepatchnode_p.h \
$$PWD/qsgdefaultlayer_p.h \
- $$PWD/qsgthreadedrenderloop_p.h \
$$PWD/qsgwindowsrenderloop_p.h
+ qtConfig(thread) {
+ SOURCES += \
+ $$PWD/qsgthreadedrenderloop.cpp
+ HEADERS += \
+ $$PWD/qsgthreadedrenderloop_p.h
+ }
+
qtConfig(quick-sprite) {
SOURCES += \
$$PWD/qsgdefaultspritenode.cpp
@@ -230,14 +235,9 @@ SOURCES += \
qtConfig(opengl(es1|es2)?) {
HEADERS += \
$$PWD/compressedtexture/qsgcompressedatlastexture_p.h \
- $$PWD/compressedtexture/qsgcompressedtexture_p.h \
- $$PWD/compressedtexture/qsgtexturefilehandler_p.h \
- $$PWD/compressedtexture/qsgpkmhandler_p.h \
- $$PWD/compressedtexture/qsgktxhandler_p.h
+ $$PWD/compressedtexture/qsgcompressedtexture_p.h
SOURCES += \
$$PWD/compressedtexture/qsgcompressedatlastexture.cpp \
- $$PWD/compressedtexture/qsgcompressedtexture.cpp \
- $$PWD/compressedtexture/qsgpkmhandler.cpp \
- $$PWD/compressedtexture/qsgktxhandler.cpp
+ $$PWD/compressedtexture/qsgcompressedtexture.cpp
}
diff --git a/src/quick/scenegraph/util/qsgareaallocator.cpp b/src/quick/scenegraph/util/qsgareaallocator.cpp
index cd270a1d63..9a8c8e333b 100644
--- a/src/quick/scenegraph/util/qsgareaallocator.cpp
+++ b/src/quick/scenegraph/util/qsgareaallocator.cpp
@@ -42,6 +42,9 @@
#include <QtCore/qglobal.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qdatastream.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qendian.h>
QT_BEGIN_NAMESPACE
@@ -285,4 +288,145 @@ void QSGAreaAllocator::mergeNodeWithNeighbors(QSGAreaAllocatorNode *node)
} // end while(!done)
}
+namespace {
+ struct AreaAllocatorTable
+ {
+ enum TableSize {
+ HeaderSize = 10,
+ NodeSize = 9
+ };
+
+ enum Offset {
+ // Header
+ majorVersion = 0,
+ minorVersion = 1,
+ width = 2,
+ height = 6,
+
+ // Node
+ split = 0,
+ splitType = 4,
+ flags = 8
+ };
+
+ enum Flags {
+ IsOccupied = 1,
+ HasLeft = 2,
+ HasRight = 4
+ };
+
+ template <typename T>
+ static inline T fetch(const char *data, Offset offset)
+ {
+ return qFromBigEndian<T>(data + int(offset));
+ }
+
+ template <typename T>
+ static inline void put(char *data, Offset offset, T value)
+ {
+ qToBigEndian(value, data + int(offset));
+ }
+ };
+}
+
+QByteArray QSGAreaAllocator::serialize()
+{
+ QVarLengthArray<QSGAreaAllocatorNode *> nodesToProcess;
+
+ QStack<QSGAreaAllocatorNode *> nodes;
+ nodes.push(m_root);
+ while (!nodes.isEmpty()) {
+ QSGAreaAllocatorNode *node = nodes.pop();
+
+ nodesToProcess.append(node);
+ if (node->left != nullptr)
+ nodes.push(node->left);
+ if (node->right != nullptr)
+ nodes.push(node->right);
+ }
+
+ QByteArray ret;
+ ret.resize(AreaAllocatorTable::HeaderSize + AreaAllocatorTable::NodeSize * nodesToProcess.size());
+
+ char *data = ret.data();
+ AreaAllocatorTable::put(data, AreaAllocatorTable::majorVersion, quint8(5));
+ AreaAllocatorTable::put(data, AreaAllocatorTable::minorVersion, quint8(12));
+ AreaAllocatorTable::put(data, AreaAllocatorTable::width, quint32(m_size.width()));
+ AreaAllocatorTable::put(data, AreaAllocatorTable::height, quint32(m_size.height()));
+
+ data += AreaAllocatorTable::HeaderSize;
+ for (QSGAreaAllocatorNode *node : nodesToProcess) {
+ AreaAllocatorTable::put(data, AreaAllocatorTable::split, qint32(node->split));
+ AreaAllocatorTable::put(data, AreaAllocatorTable::splitType, quint32(node->splitType));
+
+ quint8 flags =
+ (node->isOccupied ? AreaAllocatorTable::IsOccupied : 0)
+ | (node->left != nullptr ? AreaAllocatorTable::HasLeft : 0)
+ | (node->right != nullptr ? AreaAllocatorTable::HasRight : 0);
+ AreaAllocatorTable::put(data, AreaAllocatorTable::flags, flags);
+ data += AreaAllocatorTable::NodeSize;
+ }
+
+ return ret;
+}
+
+const char *QSGAreaAllocator::deserialize(const char *data, int size)
+{
+ if (uint(size) < AreaAllocatorTable::HeaderSize) {
+ qWarning("QSGAreaAllocator::deserialize: Data not long enough to fit header");
+ return nullptr;
+ }
+
+ const char *end = data + size;
+
+ quint8 majorVersion = AreaAllocatorTable::fetch<quint8>(data, AreaAllocatorTable::majorVersion);
+ quint8 minorVersion = AreaAllocatorTable::fetch<quint8>(data, AreaAllocatorTable::minorVersion);
+ if (majorVersion != 5 || minorVersion != 12) {
+ qWarning("Unrecognized version %d.%d of QSGAreaAllocator",
+ majorVersion,
+ minorVersion);
+ return nullptr;
+ }
+
+ m_size = QSize(AreaAllocatorTable::fetch<quint32>(data, AreaAllocatorTable::width),
+ AreaAllocatorTable::fetch<quint32>(data, AreaAllocatorTable::height));
+
+ Q_ASSERT(m_root != nullptr);
+ Q_ASSERT(m_root->left == nullptr);
+ Q_ASSERT(m_root->right == nullptr);
+
+ QStack<QSGAreaAllocatorNode *> nodes;
+ nodes.push(m_root);
+
+ data += AreaAllocatorTable::HeaderSize;
+ while (!nodes.isEmpty()) {
+ if (data + AreaAllocatorTable::NodeSize > end) {
+ qWarning("QSGAreaAllocator::deseriable: Data not long enough for nodes");
+ return nullptr;
+ }
+
+ QSGAreaAllocatorNode *node = nodes.pop();
+
+ node->split = AreaAllocatorTable::fetch<qint32>(data, AreaAllocatorTable::split);
+ node->splitType = SplitType(AreaAllocatorTable::fetch<quint32>(data, AreaAllocatorTable::splitType));
+
+ quint8 flags = AreaAllocatorTable::fetch<quint8>(data, AreaAllocatorTable::flags);
+ node->isOccupied = flags & AreaAllocatorTable::IsOccupied;
+
+ if (flags & AreaAllocatorTable::HasLeft) {
+ node->left = new QSGAreaAllocatorNode(node);
+ nodes.push(node->left);
+ }
+
+ if (flags & AreaAllocatorTable::HasRight) {
+ node->right = new QSGAreaAllocatorNode(node);
+ nodes.push(node->right);
+ }
+
+ data += AreaAllocatorTable::NodeSize;
+ }
+
+ return data;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgareaallocator_p.h b/src/quick/scenegraph/util/qsgareaallocator_p.h
index 8bc05a5a5b..300a8128c0 100644
--- a/src/quick/scenegraph/util/qsgareaallocator_p.h
+++ b/src/quick/scenegraph/util/qsgareaallocator_p.h
@@ -69,6 +69,10 @@ public:
bool deallocate(const QRect &rect);
bool isEmpty() const { return m_root == nullptr; }
QSize size() const { return m_size; }
+
+ QByteArray serialize();
+ const char *deserialize(const char *data, int size);
+
private:
bool allocateInNode(const QSize &size, QPoint &result, const QRect &currentRect, QSGAreaAllocatorNode *node);
bool deallocateInNode(const QPoint &pos, QSGAreaAllocatorNode *node);
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 7608a81ddc..66c6d3a882 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -143,11 +143,11 @@ QSGTexture *Manager::create(const QImage &image, bool hasAlphaChannel)
QSGTexture *Manager::create(const QSGCompressedTextureFactory *factory)
{
QSGTexture *t = nullptr;
- if (!qsgEnableCompressedAtlas() || !factory->m_textureData || !factory->m_textureData->isValid())
+ if (!qsgEnableCompressedAtlas() || !factory->m_textureData.isValid())
return t;
// TODO: further abstract the atlas and remove this restriction
- unsigned int format = factory->m_textureData->format;
+ unsigned int format = factory->m_textureData.glInternalFormat();
switch (format) {
case QOpenGLTexture::RGB8_ETC1:
case QOpenGLTexture::RGB8_ETC2:
@@ -158,15 +158,15 @@ QSGTexture *Manager::create(const QSGCompressedTextureFactory *factory)
return t;
}
- QSize size = factory->m_textureData->size;
+ QSize size = factory->m_textureData.size();
if (size.width() < m_atlas_size_limit && size.height() < m_atlas_size_limit) {
QHash<unsigned int, QSGCompressedAtlasTexture::Atlas*>::iterator i = m_atlases.find(format);
if (i == m_atlases.end())
i = m_atlases.insert(format, new QSGCompressedAtlasTexture::Atlas(m_atlas_size, format));
// must be multiple of 4
QSize paddedSize(((size.width() + 3) / 4) * 4, ((size.height() + 3) / 4) * 4);
- QByteArray data = factory->m_textureData->data;
- t = i.value()->create(data, factory->m_textureData->sizeInBytes(), factory->m_textureData->dataOffset, size, paddedSize);
+ QByteArray data = factory->m_textureData.data();
+ t = i.value()->create(data, factory->m_textureData.dataLength(), factory->m_textureData.dataOffset(), size, paddedSize);
}
return t;
}
@@ -351,19 +351,6 @@ Texture *Atlas::create(const QImage &image)
return nullptr;
}
-static void swizzleBGRAToRGBA(QImage *image)
-{
- const int width = image->width();
- const int height = image->height();
- uint *p = (uint *) image->bits();
- int stride = image->bytesPerLine() / 4;
- for (int i = 0; i < height; ++i) {
- for (int x = 0; x < width; ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- p += stride;
- }
-}
-
void Atlas::upload(Texture *texture)
{
const QImage &image = texture->image();
@@ -395,7 +382,7 @@ void Atlas::upload(Texture *texture)
}
if (m_externalFormat == GL_RGBA)
- swizzleBGRAToRGBA(&tmp);
+ tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied);
QOpenGLContext::currentContext()->functions()->glTexSubImage2D(GL_TEXTURE_2D, 0,
r.x(), r.y(), r.width(), r.height(),
m_externalFormat, GL_UNSIGNED_BYTE, tmp.constBits());
diff --git a/src/quick/scenegraph/util/qsgengine.h b/src/quick/scenegraph/util/qsgengine.h
index e9e01dc710..e48b7784ae 100644
--- a/src/quick/scenegraph/util/qsgengine.h
+++ b/src/quick/scenegraph/util/qsgengine.h
@@ -66,6 +66,7 @@ public:
TextureIsOpaque = 0x0010
};
Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
+ Q_FLAG(CreateTextureOptions)
explicit QSGEngine(QObject *parent = nullptr);
~QSGEngine() override;
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index fea92a5121..982d05691d 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -659,17 +659,6 @@ QSGPlainTexture::~QSGPlainTexture()
#endif
}
-void qsg_swizzleBGRAToRGBA(QImage *image)
-{
- const int width = image->width();
- const int height = image->height();
- for (int i = 0; i < height; ++i) {
- uint *p = (uint *) image->scanLine(i);
- for (int x = 0; x < width; ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- }
-}
-
void QSGPlainTexture::setImage(const QImage &image)
{
m_image = image;
@@ -841,7 +830,7 @@ void QSGPlainTexture::bind()
internalFormat = GL_RGBA;
#endif
} else {
- qsg_swizzleBGRAToRGBA(&tmp);
+ tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied);
}
qint64 swizzleTime = 0;
diff --git a/src/quick/scenegraph/util/qsgtexturereader.cpp b/src/quick/scenegraph/util/qsgtexturereader.cpp
index 8e95f27120..5e12ca4035 100644
--- a/src/quick/scenegraph/util/qsgtexturereader.cpp
+++ b/src/quick/scenegraph/util/qsgtexturereader.cpp
@@ -38,36 +38,40 @@
****************************************************************************/
#include "qsgtexturereader_p.h"
-
-#include <private/qtquickglobal_p.h>
-
-#include <private/qsgtexturefilehandler_p.h>
+#include <private/qtexturefilereader_p.h>
#if QT_CONFIG(opengl)
-#include <private/qsgpkmhandler_p.h>
-#include <private/qsgktxhandler_p.h>
+#include <private/qsgcompressedtexture_p.h>
#endif
-#include <QFileInfo>
-
QT_BEGIN_NAMESPACE
QSGTextureReader::QSGTextureReader(QIODevice *device, const QString &fileName)
- : m_device(device), m_fileInfo(fileName)
{
+#if QT_CONFIG(opengl)
+ m_reader = new QTextureFileReader(device, fileName);
+#else
+ Q_UNUSED(device);
+ Q_UNUSED(fileName);
+#endif
}
QSGTextureReader::~QSGTextureReader()
{
- delete m_handler;
+ delete m_reader;
}
QQuickTextureFactory *QSGTextureReader::read()
{
#if QT_CONFIG(opengl)
- if (!isTexture())
+ if (!m_reader)
+ return nullptr;
+
+ QTextureFileData texData = m_reader->read();
+ if (!texData.isValid())
return nullptr;
- return m_handler->read();
+
+ return new QSGCompressedTextureFactory(texData);
#else
return nullptr;
#endif
@@ -75,41 +79,12 @@ QQuickTextureFactory *QSGTextureReader::read()
bool QSGTextureReader::isTexture()
{
-#if QT_CONFIG(opengl)
- if (!checked) {
- checked = true;
- if (!init())
- return false;
-
- QByteArray headerBlock = m_device->peek(64);
- QByteArray suffix = m_fileInfo.suffix().toLower().toLatin1();
- QByteArray logName = m_fileInfo.fileName().toUtf8();
-
- // Currently the handlers are hardcoded; later maybe a list of plugins
- if (QSGPkmHandler::canRead(suffix, headerBlock)) {
- m_handler = new QSGPkmHandler(m_device, logName);
- } else if (QSGKtxHandler::canRead(suffix, headerBlock)) {
- m_handler = new QSGKtxHandler(m_device, logName);
- }
- // else if OtherHandler::canRead() ...etc.
- }
- return (m_handler != nullptr);
-#else
- return false;
-#endif
+ return m_reader ? m_reader->canRead() : false;
}
QList<QByteArray> QSGTextureReader::supportedFileFormats()
{
- // Hardcoded for now
- return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx")};
-}
-
-bool QSGTextureReader::init()
-{
- if (!m_device)
- return false;
- return m_device->isReadable();
+ return QTextureFileReader::supportedFileFormats();
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgtexturereader_p.h b/src/quick/scenegraph/util/qsgtexturereader_p.h
index 19e33bf5c3..20c17fce50 100644
--- a/src/quick/scenegraph/util/qsgtexturereader_p.h
+++ b/src/quick/scenegraph/util/qsgtexturereader_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
class QIODevice;
class QQuickTextureFactory;
-class QSGTextureFileHandler;
+class QTextureFileReader;
class QSGTextureReader
{
@@ -75,11 +75,7 @@ public:
static QList<QByteArray> supportedFileFormats();
private:
- bool init();
- QIODevice *m_device = nullptr;
- QFileInfo m_fileInfo;
- QSGTextureFileHandler *m_handler = nullptr;
- bool checked = false;
+ QTextureFileReader *m_reader = nullptr;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index 9ee1a323e5..02be9daac0 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -234,6 +234,27 @@ QQmlProperty QQuickAbstractAnimationPrivate::createProperty(QObject *obj, const
The corresponding handler is \c onStopped.
*/
+/*!
+ \qmlsignal QtQuick::Animation::finished()
+ \since 5.12
+
+ This signal is emitted when the animation has finished naturally.
+
+ It is not emitted when \l running is set to \c false, nor for animations whose
+ \l loops property is set to \c Animation.Infinite.
+
+ In addition, it is only emitted for top-level, standalone animations. It
+ will not be emitted for animations in a Behavior or Transition, or
+ animations that are part of an animation group.
+
+ If \l alwaysRunToEnd is true, this signal will not be emitted until the
+ animation has completed its current iteration.
+
+ The corresponding handler is \c onFinished.
+
+ \sa stopped(), started(), running
+*/
+
void QQuickAbstractAnimation::setRunning(bool r)
{
Q_D(QQuickAbstractAnimation);
@@ -656,6 +677,7 @@ void QQuickAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*)
if (loopCount != 1)
animationInstance->setLoopCount(loopCount);
}
+ emit q->finished();
}
QQuickAbstractAnimation::ThreadingModel QQuickAbstractAnimation::threadingModel() const
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
index 2293f2597f..746cb938bd 100644
--- a/src/quick/util/qquickanimation_p.h
+++ b/src/quick/util/qquickanimation_p.h
@@ -126,6 +126,7 @@ Q_SIGNALS:
void pausedChanged(bool);
void alwaysRunToEndChanged(bool);
void loopCountChanged(int);
+ Q_REVISION(12) void finished();
public Q_SLOTS:
void restart();
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 7fa20636ec..5337bfd640 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -388,7 +388,7 @@ public:
float matVals[16];
QV4::ScopedValue v(scope);
for (quint32 i = 0; i < 16; ++i) {
- v = array->getIndexed(i);
+ v = array->get(i);
if (!v->isNumber())
return QMatrix4x4();
matVals[i] = v->asDouble();
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index f7c8724318..ced981de3e 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -39,8 +39,10 @@
#include "qquickimageprovider.h"
+#include "qquickimageprovider_p.h"
#include "qquickpixmapcache_p.h"
#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -160,7 +162,10 @@ QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage
Constructs the image response
*/
QQuickImageResponse::QQuickImageResponse()
+ : QObject(*(new QQuickImageResponsePrivate))
{
+ qmlobject_connect(this, QQuickImageResponse, SIGNAL(finished()),
+ this, QQuickImageResponse, SLOT(_q_finished()));
}
/*!
@@ -329,8 +334,6 @@ void QQuickImageResponse::cancel()
\c cache property to \c false for the relevant \l Image, \l BorderImage or
\l AnimatedImage object.
- The \l {Qt Quick 1} version of this class is named QDeclarativeImageProvider.
-
\sa QQmlEngine::addImageProvider()
*/
diff --git a/src/quick/util/qquickimageprovider.h b/src/quick/util/qquickimageprovider.h
index 4f8193789a..82d0501697 100644
--- a/src/quick/util/qquickimageprovider.h
+++ b/src/quick/util/qquickimageprovider.h
@@ -69,6 +69,8 @@ public:
static QQuickTextureFactory *textureFactoryForImage(const QImage &image);
};
+class QQuickImageResponsePrivate;
+
class Q_QUICK_EXPORT QQuickImageResponse : public QObject
{
Q_OBJECT
@@ -84,6 +86,10 @@ public Q_SLOTS:
Q_SIGNALS:
void finished();
+
+private:
+ Q_DECLARE_PRIVATE(QQuickImageResponse)
+ Q_PRIVATE_SLOT(d_func(), void _q_finished())
};
class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
diff --git a/src/quick/scenegraph/compressedtexture/qsgpkmhandler_p.h b/src/quick/util/qquickimageprovider_p.h
index 6154c51b84..b5baf79319 100644
--- a/src/quick/scenegraph/compressedtexture/qsgpkmhandler_p.h
+++ b/src/quick/util/qquickimageprovider_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGPKMHANDLER_H
-#define QSGPKMHANDLER_H
+#ifndef QQUICKQQUICKIMAGEPROVIDER_P_H
+#define QQUICKQQUICKIMAGEPROVIDER_P_H
//
// W A R N I N G
@@ -51,20 +51,22 @@
// We mean it.
//
-#include "qsgtexturefilehandler_p.h"
+#include <private/qtquickglobal_p.h>
+#include <private/qobject_p.h>
+#include <qquickimageprovider.h>
QT_BEGIN_NAMESPACE
-class QSGPkmHandler : public QSGTextureFileHandler
+class QQuickImageResponsePrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QQuickImageResponse)
public:
- using QSGTextureFileHandler::QSGTextureFileHandler;
+ bool finished = false;
- static bool canRead(const QByteArray &suffix, const QByteArray &block);
-
- QQuickTextureFactory *read() override;
+ void _q_finished() { finished = true; }
};
+
QT_END_NAMESPACE
-#endif // QSGPKMHANDLER_H
+#endif // QQUICKQQUICKIMAGEPROVIDER_P_H
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 4237ec3edf..0dd2a88ca1 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -39,6 +39,7 @@
#include "qquickpixmapcache_p.h"
#include <qquickimageprovider.h>
+#include "qquickimageprovider_p.h"
#include <qqmlengine.h>
#include <private/qqmlglobal_p.h>
@@ -179,6 +180,8 @@ public:
QQuickPixmapReaderThreadObject(QQuickPixmapReader *);
void processJobs();
bool event(QEvent *e) override;
+public slots:
+ void asyncResponseFinished(QQuickImageResponse *response);
private slots:
void networkRequestDone();
void asyncResponseFinished();
@@ -613,10 +616,15 @@ void QQuickPixmapReaderThreadObject::networkRequestDone()
#endif
}
+void QQuickPixmapReaderThreadObject::asyncResponseFinished(QQuickImageResponse *response)
+{
+ reader->asyncResponseFinished(response);
+}
+
void QQuickPixmapReaderThreadObject::asyncResponseFinished()
{
QQuickImageResponse *response = static_cast<QQuickImageResponse *>(sender());
- reader->asyncResponseFinished(response);
+ asyncResponseFinished(response);
}
void QQuickPixmapReader::processJobs()
@@ -800,7 +808,14 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
response = asyncProvider->requestImageResponse(imageId(url), runningJob->requestSize);
}
- QObject::connect(response, SIGNAL(finished()), threadObject, SLOT(asyncResponseFinished()));
+ // Might be that the async provider was so quick it emitted the signal before we
+ // could connect to it.
+ if (static_cast<QQuickImageResponsePrivate*>(QObjectPrivate::get(response))->finished) {
+ QMetaObject::invokeMethod(threadObject, "asyncResponseFinished",
+ Qt::QueuedConnection, Q_ARG(QQuickImageResponse*, response));
+ } else {
+ QObject::connect(response, SIGNAL(finished()), threadObject, SLOT(asyncResponseFinished()));
+ }
asyncResponses.insert(response, runningJob);
break;
diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp
index bd9f04e562..decc6eac31 100644
--- a/src/quick/util/qquickprofiler.cpp
+++ b/src/quick/util/qquickprofiler.cpp
@@ -116,9 +116,8 @@ void QQuickProfiler::stopProfilingImpl()
m_data.clear();
}
-void QQuickProfiler::reportDataImpl(bool trackLocations)
+void QQuickProfiler::reportDataImpl()
{
- Q_UNUSED(trackLocations);
QMutexLocker lock(&m_dataMutex);
emit dataReady(m_data);
m_data.clear();
diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h
index d699ddf371..28b058c2e8 100644
--- a/src/quick/util/qquickprofiler_p.h
+++ b/src/quick/util/qquickprofiler_p.h
@@ -357,7 +357,7 @@ protected:
void startProfilingImpl(quint64 features);
void stopProfilingImpl();
- void reportDataImpl(bool trackLocations);
+ void reportDataImpl();
void setTimer(const QElapsedTimer &t);
};
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index a3a598621f..8e2ac32ace 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -208,7 +208,7 @@ public:
bool isExplicit : 1;
void decode();
- void decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
+ void decodeBinding(const QString &propertyPrefix, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &qmlUnit, const QV4::CompiledData::Binding *binding);
class ExpressionChange {
public:
@@ -236,19 +236,19 @@ public:
QQmlProperty property(const QString &);
};
-void QQuickPropertyChangesParser::verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
+void QQuickPropertyChangesParser::verifyList(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
if (binding->type == QV4::CompiledData::Binding::Type_Object) {
- error(qmlUnit->objectAt(binding->value.objectIndex), QQuickPropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
+ error(compilationUnit->objectAt(binding->value.objectIndex), QQuickPropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
return;
}
if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
|| binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
- const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *subObj = compilationUnit->objectAt(binding->value.objectIndex);
const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
- verifyList(qmlUnit, subBinding);
+ verifyList(compilationUnit, subBinding);
}
}
}
@@ -259,26 +259,26 @@ void QQuickPropertyChangesPrivate::decode()
return;
for (const QV4::CompiledData::Binding *binding : qAsConst(bindings))
- decodeBinding(QString(), compilationUnit->data, binding);
+ decodeBinding(QString(), compilationUnit, binding);
bindings.clear();
decoded = true;
}
-void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
+void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
Q_Q(QQuickPropertyChanges);
- QString propertyName = propertyPrefix + qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propertyName = propertyPrefix + compilationUnit->stringAt(binding->propertyNameIndex);
if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
|| binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
QString pre = propertyName + QLatin1Char('.');
- const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *subObj = compilationUnit->objectAt(binding->value.objectIndex);
const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
- decodeBinding(pre, qmlUnit, subBinding);
+ decodeBinding(pre, compilationUnit, subBinding);
}
return;
}
@@ -298,7 +298,7 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
}
}
- if (binding->type == QV4::CompiledData::Binding::Type_Script || binding->containsTranslations()) {
+ if (binding->type == QV4::CompiledData::Binding::Type_Script || binding->isTranslationBinding()) {
QUrl url = QUrl();
int line = -1;
int column = -1;
@@ -313,8 +313,8 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
QString expression;
QQmlBinding::Identifier id = QQmlBinding::Invalid;
- if (!binding->containsTranslations()) {
- expression = binding->valueAsString(qmlUnit);
+ if (!binding->isTranslationBinding()) {
+ expression = binding->valueAsString(compilationUnit.data());
id = binding->value.compiledScriptIndex;
}
expressions << ExpressionChange(propertyName, binding, id, expression, url, line, column);
@@ -328,10 +328,10 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
case QV4::CompiledData::Binding::Type_TranslationById:
Q_UNREACHABLE();
case QV4::CompiledData::Binding::Type_String:
- var = binding->valueAsString(qmlUnit);
+ var = binding->valueAsString(compilationUnit.data());
break;
case QV4::CompiledData::Binding::Type_Number:
- var = binding->valueAsNumber();
+ var = binding->valueAsNumber(compilationUnit->constants);
break;
case QV4::CompiledData::Binding::Type_Boolean:
var = binding->valueAsBoolean();
@@ -343,13 +343,13 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
properties << qMakePair(propertyName, var);
}
-void QQuickPropertyChangesParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props)
+void QQuickPropertyChangesParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
for (int ii = 0; ii < props.count(); ++ii)
- verifyList(qmlUnit, props.at(ii));
+ verifyList(compilationUnit, props.at(ii));
}
-void QQuickPropertyChangesParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void QQuickPropertyChangesParser::applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
QQuickPropertyChangesPrivate *p =
static_cast<QQuickPropertyChangesPrivate *>(QObjectPrivate::get(obj));
@@ -468,7 +468,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
QQmlContextData *context = QQmlContextData::get(qmlContext(this));
QQmlBinding *newBinding = nullptr;
- if (e.binding && e.binding->containsTranslations()) {
+ if (e.binding && e.binding->isTranslationBinding()) {
newBinding = QQmlBinding::createTranslationBinding(d->compilationUnit, e.binding, object(), context);
} else if (e.id != QQmlBinding::Invalid) {
QV4::Scope scope(qmlEngine(this)->handle());
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
index 35b37e84cb..74fe511d6e 100644
--- a/src/quick/util/qquickpropertychanges_p.h
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -101,10 +101,10 @@ public:
QQuickPropertyChangesParser()
: QQmlCustomParser(AcceptsAttachedProperties) {}
- void verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
+ void verifyList(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding);
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
- void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
index b953ad1c7f..3ca6440784 100644
--- a/src/quick/util/qquickstate.cpp
+++ b/src/quick/util/qquickstate.cpp
@@ -222,7 +222,7 @@ bool QQuickState::isWhenKnown() const
QQmlBinding *QQuickState::when() const
{
Q_D(const QQuickState);
- return d->when;
+ return d->when.data();
}
void QQuickState::setWhen(QQmlBinding *when)
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
index f1bc24c558..61472b4d06 100644
--- a/src/quick/util/qquickstate_p_p.h
+++ b/src/quick/util/qquickstate_p_p.h
@@ -203,12 +203,12 @@ class QQuickStatePrivate : public QObjectPrivate
public:
QQuickStatePrivate()
- : when(nullptr), named(false), inState(false), group(nullptr) {}
+ : named(false), inState(false), group(nullptr) {}
typedef QList<QQuickSimpleAction> SimpleActionList;
QString name;
- QQmlBinding *when;
+ QQmlBinding::Ptr when;
bool named;
struct OperationGuard : public QQmlGuard<QQuickStateOperation>
diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp
index 2bf9c121d3..0687913565 100644
--- a/src/quick/util/qquicksvgparser.cpp
+++ b/src/quick/util/qquicksvgparser.cpp
@@ -280,11 +280,8 @@ bool QQuickSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &pa
++str;
QChar pathElem = *str;
++str;
- QChar endc = *end;
- *const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee
QVarLengthArray<qreal, 8> arg;
parseNumbersArray(str, arg);
- *const_cast<QChar *>(end) = endc;
if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
arg.append(0);//dummy
const qreal *num = arg.constData();
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
index a1367249c6..e51de1a02a 100644
--- a/src/quick/util/qquicktransitionmanager.cpp
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -91,10 +91,10 @@ void QQuickTransitionManager::complete()
{
d->applyBindings();
- for (int ii = 0; ii < d->completeList.count(); ++ii) {
- const QQmlProperty &prop = d->completeList.at(ii).property();
- prop.write(d->completeList.at(ii).value());
- }
+ // Explicitly take a copy in case the write action triggers a script that modifies the list.
+ QQuickTransitionManagerPrivate::SimpleActionList completeListCopy = d->completeList;
+ for (const QQuickSimpleAction &action : qAsConst(completeListCopy))
+ action.property().write(action.value());
d->completeList.clear();
@@ -131,7 +131,9 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
{
cancel();
+ // The copy below is ON PURPOSE, because firing actions might involve scripts that modify the list.
QQuickStateOperation::ActionList applyList = list;
+
// Determine which actions are binding changes and disable any current bindings
for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.toBinding)
@@ -156,8 +158,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
if (transition && !d->bindingsList.isEmpty()) {
// Apply all the property and binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- const QQuickStateAction &action = applyList.at(ii);
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.toBinding) {
QQmlPropertyPrivate::setBinding(action.toBinding.data(), QQmlPropertyPrivate::None, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
} else if (!action.event) {
@@ -170,17 +171,15 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
}
- // Read all the end values for binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- QQuickStateAction *action = &applyList[ii];
- if (action->event) {
- action->event->saveTargetValues();
+ // Read all the end values for binding changes.
+ for (auto it = applyList.begin(), eit = applyList.end(); it != eit; ++it) {
+ if (it->event) {
+ it->event->saveTargetValues();
continue;
}
- const QQmlProperty &prop = action->property;
- if (action->toBinding || !action->toValue.isValid()) {
- action->toValue = prop.read();
- }
+ const QQmlProperty &prop = it->property;
+ if (it->toBinding || !it->toValue.isValid())
+ it->toValue = prop.read();
}
// Revert back to the original values
@@ -210,29 +209,20 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
delete oldInstance;
// Modify the action list to remove actions handled in the transition
- for (int ii = 0; ii < applyList.count(); ++ii) {
- const QQuickStateAction &action = applyList.at(ii);
-
+ auto isHandledInTransition = [this, touched](const QQuickStateAction &action) {
if (action.event) {
-
- if (action.actionDone) {
- applyList.removeAt(ii);
- --ii;
- }
-
+ return action.actionDone;
} else {
-
if (touched.contains(action.property)) {
if (action.toValue != action.fromValue)
- d->completeList <<
- QQuickSimpleAction(action, QQuickSimpleAction::EndState);
-
- applyList.removeAt(ii);
- --ii;
+ d->completeList << QQuickSimpleAction(action, QQuickSimpleAction::EndState);
+ return true;
}
-
}
- }
+ return false;
+ };
+ auto newEnd = std::remove_if(applyList.begin(), applyList.end(), isHandledInTransition);
+ applyList.erase(newEnd, applyList.end());
}
// Any actions remaining have not been handled by the transition and should
@@ -270,12 +260,9 @@ void QQuickTransitionManager::cancel()
if (d->transitionInstance && d->transitionInstance->isRunning())
d->transitionInstance->stop();
- for(int i = 0; i < d->bindingsList.count(); ++i) {
- QQuickStateAction action = d->bindingsList[i];
+ for (const QQuickStateAction &action : qAsConst(d->bindingsList)) {
if (action.toBinding && action.deletableToBinding) {
QQmlPropertyPrivate::removeBinding(action.property);
- action.toBinding = nullptr;
- action.deletableToBinding = false;
} else if (action.event) {
//### what do we do here?
}
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index b2e5b84cf4..31d4d4c437 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -132,4 +132,7 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickShortcut,9>("QtQuick", 2, 9, "Shortcut");
#endif
+
+ qmlRegisterUncreatableType<QQuickAbstractAnimation, 12>("QtQuick", 2, 12, "Animation",
+ QQuickAbstractAnimation::tr("Animation is an abstract class"));
}
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index edcb268cd9..c51f082d03 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -53,6 +53,7 @@ HEADERS += \
$$PWD/qquickfontloader_p.h \
$$PWD/qquickstyledtext_p.h \
$$PWD/qquickimageprovider.h \
+ $$PWD/qquickimageprovider_p.h \
$$PWD/qquicksvgparser_p.h \
$$PWD/qquickvaluetypes_p.h \
$$PWD/qquickanimator_p.h \
diff --git a/src/imports/shapes/qquicknvprfunctions.cpp b/src/quickshapes/qquicknvprfunctions.cpp
index 409a59be7f..409a59be7f 100644
--- a/src/imports/shapes/qquicknvprfunctions.cpp
+++ b/src/quickshapes/qquicknvprfunctions.cpp
diff --git a/src/imports/shapes/qquicknvprfunctions_p.h b/src/quickshapes/qquicknvprfunctions_p.h
index 342e92cbc3..92246cf4c8 100644
--- a/src/imports/shapes/qquicknvprfunctions_p.h
+++ b/src/quickshapes/qquicknvprfunctions_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
#include <qopengl.h>
#include <QtGui/qsurfaceformat.h>
diff --git a/src/imports/shapes/qquicknvprfunctions_p_p.h b/src/quickshapes/qquicknvprfunctions_p_p.h
index 6df20566af..3d9ca0de9f 100644
--- a/src/imports/shapes/qquicknvprfunctions_p_p.h
+++ b/src/quickshapes/qquicknvprfunctions_p_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include "qquicknvprfunctions_p.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuickShapes/private/qquicknvprfunctions_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/shapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp
index 067a54736f..0c159ec21b 100644
--- a/src/imports/shapes/qquickshape.cpp
+++ b/src/quickshapes/qquickshape.cpp
@@ -577,10 +577,10 @@ void QQuickShapePath::resetFillGradient()
\li When running with the default, OpenGL backend of Qt Quick, both the
generic, triangulation-based and the NVIDIA-specific
- \c{GL_NV_path_rendering} methods are available. The choice is made at
- runtime, depending on the graphics driver's capabilities. When this is not
- desired, applications can force using the generic method by setting the
- Shape.vendorExtensionsEnabled property to \c false.
+ \c{GL_NV_path_rendering} methods are available. By default only the generic
+ approach is used. Setting Shape.vendorExtensionsEnabled property to \c true
+ leads to using NV_path_rendering on NVIDIA systems, and the generic method
+ on others.
\li The \c software backend is fully supported. The path is rendered via
QPainter::strokePath() and QPainter::fillPath() in this case.
@@ -624,9 +624,8 @@ void QQuickShapePath::resetFillGradient()
\li As a general rule, scenes should avoid using separate Shape items when
it is not absolutely necessary. Prefer using one Shape item with multiple
- ShapePath elements over multiple Shape items. Scenes that cannot avoid
- using a large number of individual Shape items should consider setting
- Shape.vendorExtensionsEnabled to \c false.
+ ShapePath elements over multiple Shape items.
+
\endlist
\sa {Qt Quick Examples - Shapes}, Path, PathMove, PathLine, PathQuad, PathCubic, PathArc, PathSvg
@@ -658,9 +657,22 @@ void QQuickShapePrivate::setStatus(QQuickShape::Status newStatus)
}
}
+struct QQuickShapeResourceInitializer
+{
+ QQuickShapeResourceInitializer()
+ {
+#if defined(QT_STATIC)
+ Q_INIT_RESOURCE(qtquickshapes);
+#endif
+ }
+};
+
+Q_GLOBAL_STATIC(QQuickShapeResourceInitializer, initQQuickShapeResources)
+
QQuickShape::QQuickShape(QQuickItem *parent)
: QQuickItem(*(new QQuickShapePrivate), parent)
{
+ initQQuickShapeResources();
setFlag(ItemHasContents);
}
@@ -737,11 +749,18 @@ void QQuickShape::setAsynchronous(bool async)
\qmlproperty bool QtQuick.Shapes::Shape::vendorExtensionsEnabled
This property controls the usage of non-standard OpenGL extensions like
- \c GL_NV_path_rendering. To disable Shape.NvprRenderer and force a uniform
- behavior regardless of the graphics card and drivers, set this property to
- \c false.
+ \c GL_NV_path_rendering.
+
+ The default value is \c false.
- The default value is \c true.
+ As of Qt 5.12 Shape.NvprRenderer is disabled by default and a uniform
+ behavior, based on triangulating the path and generating QSGGeometryNode
+ instances, is used regardless of the graphics card and drivers. To enable
+ using vendor-specific path rendering approaches set the value to \c true.
+ Depending on the platform and content, this can lead to improved
+ performance. Setting the value to \c true is safe in any case since
+ rendering falls back to the default method when the vendor-specific
+ approach, such as \c GL_NV_path_rendering, is not supported at run time.
*/
bool QQuickShape::vendorExtensionsEnabled() const
diff --git a/src/imports/shapes/qquickshape_p.h b/src/quickshapes/qquickshape_p.h
index 1dfeaf9228..cd242cafc3 100644
--- a/src/imports/shapes/qquickshape_p.h
+++ b/src/quickshapes/qquickshape_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include "qquickitem.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuick/qquickitem.h>
#include <private/qtquickglobal_p.h>
#include <private/qquickpath_p_p.h>
@@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QQuickShapePathPrivate;
class QQuickShapePrivate;
-class QQuickShapeGradient : public QQuickGradient
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeGradient : public QQuickGradient
{
Q_OBJECT
Q_PROPERTY(SpreadMode spread READ spread WRITE setSpread NOTIFY spreadChanged)
@@ -88,7 +89,7 @@ private:
SpreadMode m_spread;
};
-class QQuickShapeLinearGradient : public QQuickShapeGradient
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeLinearGradient : public QQuickShapeGradient
{
Q_OBJECT
Q_PROPERTY(qreal x1 READ x1 WRITE setX1 NOTIFY x1Changed)
@@ -120,7 +121,7 @@ private:
QPointF m_end;
};
-class QQuickShapeRadialGradient : public QQuickShapeGradient
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeRadialGradient : public QQuickShapeGradient
{
Q_OBJECT
Q_PROPERTY(qreal centerX READ centerX WRITE setCenterX NOTIFY centerXChanged)
@@ -167,7 +168,7 @@ private:
qreal m_focalRadius = 0;
};
-class QQuickShapeConicalGradient : public QQuickShapeGradient
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeConicalGradient : public QQuickShapeGradient
{
Q_OBJECT
Q_PROPERTY(qreal centerX READ centerX WRITE setCenterX NOTIFY centerXChanged)
@@ -197,7 +198,7 @@ private:
qreal m_angle = 0;
};
-class QQuickShapePath : public QQuickPath
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePath : public QQuickPath
{
Q_OBJECT
@@ -296,7 +297,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_fillGradientChanged())
};
-class QQuickShape : public QQuickItem
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShape : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(RendererType rendererType READ rendererType NOTIFY rendererChanged)
diff --git a/src/imports/shapes/qquickshape_p_p.h b/src/quickshapes/qquickshape_p_p.h
index ef2775885e..bc06c8fde8 100644
--- a/src/imports/shapes/qquickshape_p_p.h
+++ b/src/quickshapes/qquickshape_p_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include "qquickshape_p.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuickShapes/private/qquickshape_p.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QPainterPath>
#include <QColor>
@@ -122,7 +123,7 @@ struct QQuickShapeStrokeFillParams
QQuickShapeGradient *fillGradient;
};
-class QQuickShapePathPrivate : public QQuickPathPrivate
+class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate
{
Q_DECLARE_PUBLIC(QQuickShapePath)
@@ -181,7 +182,7 @@ public:
QQuickShape::ContainsMode containsMode = QQuickShape::BoundingRectContains;
bool spChanged = false;
bool async = false;
- bool enableVendorExts = true;
+ bool enableVendorExts = false;
bool syncTimingActive = false;
};
diff --git a/src/imports/shapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index 8a4785a83a..604da2a889 100644
--- a/src/imports/shapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -40,7 +40,10 @@
#include "qquickshapegenericrenderer_p.h"
#include <QtGui/private/qtriangulator_p.h>
#include <QtGui/private/qtriangulatingstroker_p.h>
+
+#if QT_CONFIG(thread)
#include <QThreadPool>
+#endif
#if QT_CONFIG(opengl)
#include <QSGVertexColorMaterial>
@@ -278,6 +281,7 @@ void QQuickShapeGenericRenderer::setAsyncCallback(void (*callback)(void *), void
m_asyncCallbackData = data;
}
+#if QT_CONFIG(thread)
static QThreadPool *pathWorkThreadPool = nullptr;
static void deletePathWorkThreadPool()
@@ -285,9 +289,16 @@ static void deletePathWorkThreadPool()
delete pathWorkThreadPool;
pathWorkThreadPool = nullptr;
}
+#endif
void QQuickShapeGenericRenderer::endSync(bool async)
{
+#if !QT_CONFIG(thread)
+ // Force synchronous mode for the no-thread configuration due
+ // to lack of QThreadPool.
+ async = false;
+#endif
+
bool didKickOffAsync = false;
for (int i = 0; i < m_sp.count(); ++i) {
@@ -311,13 +322,14 @@ void QQuickShapeGenericRenderer::endSync(bool async)
continue;
}
+#if QT_CONFIG(thread)
if (async && !pathWorkThreadPool) {
qAddPostRoutine(deletePathWorkThreadPool);
pathWorkThreadPool = new QThreadPool;
const int idealCount = QThread::idealThreadCount();
pathWorkThreadPool->setMaxThreadCount(idealCount > 0 ? idealCount * 2 : 4);
}
-
+#endif
if ((d.syncDirty & DirtyFillGeom) && d.fillColor.a) {
d.path.setFillRule(d.fillRule);
if (m_api == QSGRendererInterface::Unknown)
@@ -348,7 +360,9 @@ void QQuickShapeGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
+#if QT_CONFIG(thread)
pathWorkThreadPool->start(r);
+#endif
} else {
triangulateFill(d.path, d.fillColor, &d.fillVertices, &d.fillIndices, &d.indexType, q_supportsElementIndexUint(m_api));
}
@@ -376,7 +390,9 @@ void QQuickShapeGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
+#if QT_CONFIG(thread)
pathWorkThreadPool->start(r);
+#endif
} else {
triangulateStroke(d.path, d.pen, d.strokeColor, &d.strokeVertices,
QSize(m_item->width(), m_item->height()));
diff --git a/src/imports/shapes/qquickshapegenericrenderer_p.h b/src/quickshapes/qquickshapegenericrenderer_p.h
index 11070ae7dc..9928d7ab72 100644
--- a/src/imports/shapes/qquickshapegenericrenderer_p.h
+++ b/src/quickshapes/qquickshapegenericrenderer_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include "qquickshape_p_p.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuickShapes/private/qquickshape_p_p.h>
#include <qsgnode.h>
#include <qsggeometry.h>
#include <qsgmaterial.h>
diff --git a/src/imports/shapes/qquickshapenvprrenderer.cpp b/src/quickshapes/qquickshapenvprrenderer.cpp
index 51af0d8961..51af0d8961 100644
--- a/src/imports/shapes/qquickshapenvprrenderer.cpp
+++ b/src/quickshapes/qquickshapenvprrenderer.cpp
diff --git a/src/imports/shapes/qquickshapenvprrenderer_p.h b/src/quickshapes/qquickshapenvprrenderer_p.h
index f6c9fc169e..d40eb1bce9 100644
--- a/src/imports/shapes/qquickshapenvprrenderer_p.h
+++ b/src/quickshapes/qquickshapenvprrenderer_p.h
@@ -51,8 +51,9 @@
// We mean it.
//
-#include "qquickshape_p_p.h"
-#include "qquicknvprfunctions_p.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuickShapes/private/qquickshape_p_p.h>
+#include <QtQuickShapes/private/qquicknvprfunctions_p.h>
#include <qsgrendernode.h>
#include <QColor>
#include <QVector4D>
diff --git a/src/quickshapes/qquickshapesglobal.h b/src/quickshapes/qquickshapesglobal.h
new file mode 100644
index 0000000000..eb279c5d14
--- /dev/null
+++ b/src/quickshapes/qquickshapesglobal.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QQUICKSHAPESGLOBAL_H
+#define QQUICKSHAPESGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_STATIC
+# if defined(QT_BUILD_QUICKSHAPES_LIB)
+# define Q_QUICKSHAPES_EXPORT Q_DECL_EXPORT
+# else
+# define Q_QUICKSHAPES_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define Q_QUICKSHAPES_EXPORT
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSHAPESGLOBAL_H
+
diff --git a/src/quick/handlers/qquickhandlersmodule_p.h b/src/quickshapes/qquickshapesglobal_p.h
index 7eb8d39b98..2f559b45a0 100644
--- a/src/quick/handlers/qquickhandlersmodule_p.h
+++ b/src/quickshapes/qquickshapesglobal_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QQUICKHANDLERSMODULE_P_H
-#define QQUICKHANDLERSMODULE_P_H
+#ifndef QQUICKSHAPESGLOBAL_P_H
+#define QQUICKSHAPESGLOBAL_P_H
//
// W A R N I N G
@@ -51,18 +51,13 @@
// We mean it.
//
-#include <qqml.h>
-#include <private/qtquickglobal_p.h>
+#include "qquickshapesglobal.h"
QT_BEGIN_NAMESPACE
-class Q_QUICK_PRIVATE_EXPORT QQuickHandlersModule
-{
-public:
- static void defineModule();
-};
+#define Q_QUICKSHAPES_PRIVATE_EXPORT Q_QUICKSHAPES_EXPORT
QT_END_NAMESPACE
-#endif // QQUICKHANDLERSMODULE_P_H
+#endif // QQUICKSHAPESGLOBAL_P_H
diff --git a/src/imports/shapes/qquickshapesoftwarerenderer.cpp b/src/quickshapes/qquickshapesoftwarerenderer.cpp
index 0f5c3604b5..0f5c3604b5 100644
--- a/src/imports/shapes/qquickshapesoftwarerenderer.cpp
+++ b/src/quickshapes/qquickshapesoftwarerenderer.cpp
diff --git a/src/imports/shapes/qquickshapesoftwarerenderer_p.h b/src/quickshapes/qquickshapesoftwarerenderer_p.h
index 0abc2e37b0..11e658b4b7 100644
--- a/src/imports/shapes/qquickshapesoftwarerenderer_p.h
+++ b/src/quickshapes/qquickshapesoftwarerenderer_p.h
@@ -51,7 +51,8 @@
// We mean it.
//
-#include "qquickshape_p_p.h"
+#include <QtQuickShapes/private/qquickshapesglobal_p.h>
+#include <QtQuickShapes/private/qquickshape_p_p.h>
#include <qsgrendernode.h>
#include <QPen>
#include <QBrush>
diff --git a/src/imports/shapes/qtquickshapesplugin.qrc b/src/quickshapes/qtquickshapes.qrc
index f139861693..f139861693 100644
--- a/src/imports/shapes/qtquickshapesplugin.qrc
+++ b/src/quickshapes/qtquickshapes.qrc
diff --git a/src/quickshapes/quickshapes.pro b/src/quickshapes/quickshapes.pro
new file mode 100644
index 0000000000..5a59dec18e
--- /dev/null
+++ b/src/quickshapes/quickshapes.pro
@@ -0,0 +1,33 @@
+TARGET = QtQuickShapes
+
+QT = core gui-private qml quick-private
+
+CONFIG += simd optimize_full internal_module
+
+HEADERS += \
+ qquickshapesglobal.h \
+ qquickshapesglobal_p.h \
+ qquickshape_p.h \
+ qquickshape_p_p.h \
+ qquickshapegenericrenderer_p.h \
+ qquickshapesoftwarerenderer_p.h
+
+SOURCES += \
+ qquickshape.cpp \
+ qquickshapegenericrenderer.cpp \
+ qquickshapesoftwarerenderer.cpp
+
+qtConfig(opengl) {
+ HEADERS += \
+ qquicknvprfunctions_p.h \
+ qquicknvprfunctions_p_p.h \
+ qquickshapenvprrenderer_p.h
+
+ SOURCES += \
+ qquicknvprfunctions.cpp \
+ qquickshapenvprrenderer.cpp
+}
+
+RESOURCES += qtquickshapes.qrc
+
+load(qt_module)
diff --git a/src/imports/shapes/shaders/blit.frag b/src/quickshapes/shaders/blit.frag
index 505f0db179..505f0db179 100644
--- a/src/imports/shapes/shaders/blit.frag
+++ b/src/quickshapes/shaders/blit.frag
diff --git a/src/imports/shapes/shaders/blit.vert b/src/quickshapes/shaders/blit.vert
index f8306bd945..f8306bd945 100644
--- a/src/imports/shapes/shaders/blit.vert
+++ b/src/quickshapes/shaders/blit.vert
diff --git a/src/imports/shapes/shaders/blit_core.frag b/src/quickshapes/shaders/blit_core.frag
index 7073808fba..7073808fba 100644
--- a/src/imports/shapes/shaders/blit_core.frag
+++ b/src/quickshapes/shaders/blit_core.frag
diff --git a/src/imports/shapes/shaders/blit_core.vert b/src/quickshapes/shaders/blit_core.vert
index 5246441da3..5246441da3 100644
--- a/src/imports/shapes/shaders/blit_core.vert
+++ b/src/quickshapes/shaders/blit_core.vert
diff --git a/src/imports/shapes/shaders/conicalgradient.frag b/src/quickshapes/shaders/conicalgradient.frag
index af5fdd5ee0..af5fdd5ee0 100644
--- a/src/imports/shapes/shaders/conicalgradient.frag
+++ b/src/quickshapes/shaders/conicalgradient.frag
diff --git a/src/imports/shapes/shaders/conicalgradient.vert b/src/quickshapes/shaders/conicalgradient.vert
index 3350b0675a..3350b0675a 100644
--- a/src/imports/shapes/shaders/conicalgradient.vert
+++ b/src/quickshapes/shaders/conicalgradient.vert
diff --git a/src/imports/shapes/shaders/conicalgradient_core.frag b/src/quickshapes/shaders/conicalgradient_core.frag
index e18b80159a..e18b80159a 100644
--- a/src/imports/shapes/shaders/conicalgradient_core.frag
+++ b/src/quickshapes/shaders/conicalgradient_core.frag
diff --git a/src/imports/shapes/shaders/conicalgradient_core.vert b/src/quickshapes/shaders/conicalgradient_core.vert
index f94a56401b..f94a56401b 100644
--- a/src/imports/shapes/shaders/conicalgradient_core.vert
+++ b/src/quickshapes/shaders/conicalgradient_core.vert
diff --git a/src/imports/shapes/shaders/lineargradient.frag b/src/quickshapes/shaders/lineargradient.frag
index 7f4a739109..7f4a739109 100644
--- a/src/imports/shapes/shaders/lineargradient.frag
+++ b/src/quickshapes/shaders/lineargradient.frag
diff --git a/src/imports/shapes/shaders/lineargradient.vert b/src/quickshapes/shaders/lineargradient.vert
index eb21b8886b..eb21b8886b 100644
--- a/src/imports/shapes/shaders/lineargradient.vert
+++ b/src/quickshapes/shaders/lineargradient.vert
diff --git a/src/imports/shapes/shaders/lineargradient_core.frag b/src/quickshapes/shaders/lineargradient_core.frag
index 5908acfa67..5908acfa67 100644
--- a/src/imports/shapes/shaders/lineargradient_core.frag
+++ b/src/quickshapes/shaders/lineargradient_core.frag
diff --git a/src/imports/shapes/shaders/lineargradient_core.vert b/src/quickshapes/shaders/lineargradient_core.vert
index 60b56f38e3..60b56f38e3 100644
--- a/src/imports/shapes/shaders/lineargradient_core.vert
+++ b/src/quickshapes/shaders/lineargradient_core.vert
diff --git a/src/imports/shapes/shaders/radialgradient.frag b/src/quickshapes/shaders/radialgradient.frag
index 0f503bc0f7..0f503bc0f7 100644
--- a/src/imports/shapes/shaders/radialgradient.frag
+++ b/src/quickshapes/shaders/radialgradient.frag
diff --git a/src/imports/shapes/shaders/radialgradient.vert b/src/quickshapes/shaders/radialgradient.vert
index 3350b0675a..3350b0675a 100644
--- a/src/imports/shapes/shaders/radialgradient.vert
+++ b/src/quickshapes/shaders/radialgradient.vert
diff --git a/src/imports/shapes/shaders/radialgradient_core.frag b/src/quickshapes/shaders/radialgradient_core.frag
index 706ce53e4d..706ce53e4d 100644
--- a/src/imports/shapes/shaders/radialgradient_core.frag
+++ b/src/quickshapes/shaders/radialgradient_core.frag
diff --git a/src/imports/shapes/shaders/radialgradient_core.vert b/src/quickshapes/shaders/radialgradient_core.vert
index f94a56401b..f94a56401b 100644
--- a/src/imports/shapes/shaders/radialgradient_core.vert
+++ b/src/quickshapes/shaders/radialgradient_core.vert
diff --git a/src/src.pro b/src/src.pro
index 5177dfc743..2dc6fc2758 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -2,15 +2,18 @@ TEMPLATE = subdirs
CONFIG += ordered
include($$OUT_PWD/qml/qtqml-config.pri)
include($$OUT_PWD/quick/qtquick-config.pri)
-QT_FOR_CONFIG += qml quick-private
+QT_FOR_CONFIG += qml qml-private quick-private
SUBDIRS += \
qml
-qtHaveModule(gui):qtConfig(animation) {
+qtHaveModule(gui):qtConfig(qml-animation) {
SUBDIRS += \
- quick
+ quick \
+ quickshapes
+
+ qtConfig(testlib): \
+ SUBDIRS += qmltest
- qtConfig(testlib): SUBDIRS += qmltest
qtConfig(quick-particles): \
SUBDIRS += particles
qtHaveModule(widgets): SUBDIRS += quickwidgets
@@ -18,8 +21,9 @@ qtHaveModule(gui):qtConfig(animation) {
SUBDIRS += \
plugins \
- imports \
- qmldevtools
+ imports
+
+qtConfig(qml-devtools): SUBDIRS += qmldevtools
qmldevtools.depends = qml
@@ -27,3 +31,5 @@ qtConfig(qml-network) {
QT_FOR_CONFIG += network
qtConfig(localserver):qtConfig(qml-debug): SUBDIRS += qmldebug
}
+
+DISTFILES += sync.profile configure.json
diff --git a/sync.profile b/sync.profile
index 64abbd2eb9..642942d152 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,9 +1,13 @@
%modules = ( # path to module name map
"QtQml" => "$basedir/src/qml",
"QtQuick" => "$basedir/src/quick",
+ "QtQuickShapes" => "$basedir/src/quickshapes",
"QtQuickWidgets" => "$basedir/src/quickwidgets",
"QtQuickParticles" => "$basedir/src/particles",
"QtQuickTest" => "$basedir/src/qmltest",
"QtPacketProtocol" => "$basedir/src/plugins/qmltooling/packetprotocol",
"QtQmlDebug" => "$basedir/src/qmldebug",
);
+%inject_headers = (
+ "$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h" ],
+);
diff --git a/tests/auto/guiapplauncher/demos.txt b/tests/auto/guiapplauncher/demos.txt
deleted file mode 100644
index 1c48b6923d..0000000000
--- a/tests/auto/guiapplauncher/demos.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-"quick/demos/clocks Example", "examples/quick/demos/clocks", "clocks", 0, -1
-"quick/demos/maroon Example", "examples/quick/demos/maroon", "maroon", 0, -1
-"quick/demos/calqlatr Example", "examples/quick/demos/calqlatr", "calqlatr", 0, -1
-"quick/demos/stocqt Example", "examples/quick/demos/stocqt", "stocqt", 0, -1
-"quick/demos/tweetsearch Example", "examples/quick/demos/tweetsearch", "tweetsearch", 0, -1
-"quick/demos/samegame Example", "examples/quick/demos/samegame", "samegame", 0, -1
-"quick/demos/phoyosurface Example", "examples/quick/demos/photosurface", "photosurface", 10, -1
-"quick/demos/rssnews Example", "examples/quick/demos/rssnews", "rssnews", 0, -1
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro
index 63721cc575..5c328fbfcc 100644
--- a/tests/auto/qml/debugger/debugger.pro
+++ b/tests/auto/qml/debugger/debugger.pro
@@ -1,5 +1,7 @@
TEMPLATE = subdirs
+SUBDIRS += qqmldebugjsserver
+
PUBLICTESTS += \
qdebugmessageservice \
qqmlenginedebugservice \
@@ -11,7 +13,8 @@ PUBLICTESTS += \
qqmlenginecontrol \
qqmldebuggingenabler \
qqmlnativeconnector \
- qqmldebugprocess
+ qqmldebugprocess \
+ qqmlpreview
PRIVATETESTS += \
qqmldebugclient \
@@ -21,6 +24,9 @@ PRIVATETESTS += \
SUBDIRS += $$PUBLICTESTS
+qqmldebugjs.depends = qqmldebugjsserver
+qqmlprofilerservice.depends = qqmldebugjsserver
+
qtConfig(private_tests): \
SUBDIRS += $$PRIVATETESTS
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
index f851688b5e..d2cfd3897a 100644
--- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
+++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
@@ -89,21 +89,12 @@ public:
protected:
//inherited from QQmlDebugClient
- void stateChanged(State state);
void messageReceived(const QByteArray &data);
signals:
- void enabled();
void debugOutput();
};
-void QQmlDebugMsgClient::stateChanged(State state)
-{
- if (state == Enabled) {
- emit enabled();
- }
-}
-
void QQmlDebugMsgClient::messageReceived(const QByteArray &data)
{
QPacket ds(connection()->currentDataStreamVersion(), data);
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
index 452520cf11..ffdbf72ded 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -66,8 +66,6 @@ void tst_QQmlDebugClient::initTestCase()
QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
QQmlDebugConnector::setServices(QStringList()
<< QStringLiteral("tst_QQmlDebugClient::handshake()"));
- QTest::ignoreMessage(QtWarningMsg,
- "QML debugger: Cannot set plugin key after loading the plugin.");
m_service = new QQmlDebugTestService("tst_QQmlDebugClient::handshake()");
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
index 52e7f85e52..37118f4bd0 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
@@ -125,7 +125,7 @@ void tst_QQmlDebuggingEnabler::qmlscene()
QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
}
- QCOMPARE(m_process->state(), QLatin1String("running"));
+ QCOMPARE(m_process->state(), QProcess::Running);
if (!blockMode) {
QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains(
QLatin1String("Component.onCompleted")), 15000);
@@ -172,7 +172,7 @@ void tst_QQmlDebuggingEnabler::custom()
QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
}
- QCOMPARE(m_process->state(), QLatin1String("running"));
+ QCOMPARE(m_process->state(), QProcess::Running);
if (!blockMode) {
QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains(QLatin1String("QQmlEngine created")),
15000);
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/breakpointRelocation.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
index 06aabc94f9..06aabc94f9 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/breakpointRelocation.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/changeBreakpoint.qml b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
index 00a85e56ac..00a85e56ac 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/changeBreakpoint.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/condition.qml b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
index 3a50ba2eb7..3a50ba2eb7 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/condition.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/createComponent.qml b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
index 089cc03733..089cc03733 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/createComponent.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/encodeQmlScope.qml b/tests/auto/qml/debugger/qqmldebugjs/data/encodeQmlScope.qml
index 7ea048044f..7ea048044f 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/encodeQmlScope.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/encodeQmlScope.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/exception.qml b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
index 06f11fa016..06f11fa016 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/exception.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/loadjsfile.qml b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
index 088c1b19fd..088c1b19fd 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/loadjsfile.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/oncompleted.qml b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
index deba24cf91..deba24cf91 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/oncompleted.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/quit.qml b/tests/auto/qml/debugger/qqmldebugjs/data/quit.qml
index bc8c2b90ae..bc8c2b90ae 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/quit.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/quit.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/stepAction.qml b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
index fb0b6c401c..fb0b6c401c 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/stepAction.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.js b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
index 92e61d103c..92e61d103c 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.js
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.qml b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
index a36d0cae91..a36d0cae91 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/test.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/timer.qml b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
index 66e6b96e18..66e6b96e18 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/data/timer.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
index bd6debcea1..b9d5f116dc 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -1,4 +1,24 @@
-TEMPLATE = subdirs
-SUBDIRS = qqmldebugjs qqmldebugjsserver
+CONFIG += testcase
+TARGET = tst_qqmldebugjs
+QT += qml testlib gui-private core-private
+macos:CONFIG -= app_bundle
-qqmldebugjs.depends = qqmldebugjsserver
+SOURCES += tst_qqmldebugjs.cpp
+
+INCLUDEPATH += ../shared
+include(../shared/debugutil.pri)
+include(../shared/qqmlenginedebugclient.pri)
+
+TESTDATA = data/*
+
+OTHER_FILES += data/test.qml data/test.js \
+ data/timer.qml \
+ data/exception.qml \
+ data/oncompleted.qml \
+ data/loadjsfile.qml \
+ data/condition.qml \
+ data/changeBreakpoint.qml \
+ data/stepAction.qml \
+ data/breakpointRelocation.qml \
+ data/createComponent.qml \
+ data/encodeQmlScope.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro
deleted file mode 100644
index 52d70bd1b1..0000000000
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qqmldebugjs
-QT += qml testlib gui-private core-private
-CONFIG -= debug_and_release_target
-osx:CONFIG -= app_bundle
-
-SOURCES += tst_qqmldebugjs.cpp
-
-include(../../shared/debugutil.pri)
-include(../../shared/qqmlenginedebugclient.pri)
-
-TESTDATA = data/*
-
-OTHER_FILES += data/test.qml data/test.js \
- data/timer.qml \
- data/exception.qml \
- data/oncompleted.qml \
- data/loadjsfile.qml \
- data/condition.qml \
- data/changeBreakpoint.qml \
- data/stepAction.qml \
- data/breakpointRelocation.qml \
- data/createComponent.qml \
- data/encodeQmlScope.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.pro
deleted file mode 100644
index 837eaed9f1..0000000000
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += qml testlib
-osx:CONFIG -= app_bundle
-CONFIG -= debug_and_release_target
-INCLUDEPATH += ../../shared
-SOURCES += qqmldebugjsserver.cpp
-DEFINES += QT_QML_DEBUG_NO_WARNING
-
-DESTDIR = ../qqmldebugjs
-
-target.path = $$[QT_INSTALL_TESTS]/tst_qqmldebugjs
-INSTALLS += target
-
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index a28dbcd9de..c090be2633 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -28,14 +28,15 @@
#include "debugutil_p.h"
#include "qqmldebugprocess_p.h"
-#include "../../shared/qqmlenginedebugclient.h"
-#include "../../../../shared/util.h"
+#include "../shared/qqmlenginedebugclient.h"
+#include "../../../shared/util.h"
#include <private/qqmldebugclient_p.h>
#include <private/qqmldebugconnection_p.h>
#include <private/qpacket_p.h>
#include <QtTest/qtest.h>
+#include <QtTest/qtestsystem.h>
#include <QtCore/qprocess.h>
#include <QtCore/qtimer.h>
#include <QtCore/qfileinfo.h>
@@ -88,6 +89,7 @@ const char *SCRIPTS = "scripts";
const char *SOURCE = "source";
const char *SETBREAKPOINT = "setbreakpoint";
const char *CLEARBREAKPOINT = "clearbreakpoint";
+const char *CHANGEBREAKPOINT = "changebreakpoint";
const char *SETEXCEPTIONBREAK = "setexceptionbreak";
const char *VERSION = "version";
const char *DISCONNECT = "disconnect";
@@ -188,6 +190,9 @@ private slots:
void clearBreakpoint_data() { targetData(); }
void clearBreakpoint();
+ void changeBreakpoint_data() { targetData(); }
+ void changeBreakpoint();
+
void setExceptionBreak_data() { targetData(); }
void setExceptionBreak();
@@ -228,6 +233,7 @@ private:
void targetData();
bool waitForClientSignal(const char *signal, int timeout = 30000);
+ void checkVersionParameters();
QTime t;
};
@@ -256,9 +262,11 @@ public:
{
parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
+ QObject::connect(this, &QQmlDebugClient::stateChanged,
+ this, &QJSDebugClient::onStateChanged);
}
- void connect(bool redundantRefs = false, bool namesAsObjects = false);
+ void connect();
void interrupt();
void continueDebugging(StepAction stepAction);
@@ -271,13 +279,14 @@ public:
void setBreakpoint(QString target, int line = -1, int column = -1, bool enabled = true,
QString condition = QString(), int ignoreCount = -1);
void clearBreakpoint(int breakpoint);
+ void changeBreakpoint(int breakpoint, bool enabled);
void setExceptionBreak(Exception type, bool enabled = false);
void version();
void disconnect();
protected:
//inherited from QQmlDebugClient
- void stateChanged(State state);
+ void onStateChanged(State state);
void messageReceived(const QByteArray &data);
signals:
@@ -304,11 +313,9 @@ public:
};
-void QJSDebugClient::connect(bool redundantRefs, bool namesAsObjects)
+void QJSDebugClient::connect()
{
- QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}"));
- jsonVal.setProperty("redundantRefs", QJSValue(redundantRefs));
- jsonVal.setProperty("namesAsObjects", QJSValue(namesAsObjects));
+ const QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}"));
sendMessage(packMessage(CONNECT,
stringify.call(QJSValueList() << jsonVal).toString().toUtf8()));
}
@@ -609,6 +616,28 @@ void QJSDebugClient::clearBreakpoint(int breakpoint)
sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
+void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "changebreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to change>
+ // "enabled" : <bool: enables the break type if true, disables if false>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND), QLatin1String(CHANGEBREAKPOINT));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(BREAKPOINT), breakpoint);
+ args.setProperty(QLatin1String(ENABLED), enabled);
+ jsonVal.setProperty(QLatin1String(ARGUMENTS), args);
+
+ const QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
{
// { "seq" : <number>,
@@ -665,7 +694,7 @@ void QJSDebugClient::disconnect()
sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
}
-void QJSDebugClient::stateChanged(State state)
+void QJSDebugClient::onStateChanged(State state)
{
if (state == Enabled)
flushSendBuffer();
@@ -696,7 +725,8 @@ void QJSDebugClient::messageReceived(const QByteArray &data)
if (!value.value("success").toBool()) {
emit failure();
- qDebug() << "Received success == false response from application";
+ qDebug() << "Received success == false response from application:"
+ << value.value("message").toString();
return;
}
@@ -718,7 +748,6 @@ void QJSDebugClient::messageReceived(const QByteArray &data)
debugCommand == "setexceptionbreak" /*||
debugCommand == "profile"*/) {
emit result();
-
} else {
// DO NOTHING
}
@@ -770,7 +799,7 @@ QQmlDebugTest::ConnectResult tst_QQmlDebugJS::init(bool qmlscene, const QString
{
const QString executable = qmlscene
? QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"
- : QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebugjsserver");
+ : debugJsServerPath("qqmldebugjs");
return QQmlDebugTest::connect(
executable, restrictServices ? QStringLiteral("V8Debugger") : QString(),
testFile(qmlFile), blockMode);
@@ -796,6 +825,7 @@ void tst_QQmlDebugJS::connect()
QFETCH(bool, blockMode);
QFETCH(bool, restrictMode);
QFETCH(bool, qmlscene);
+
QCOMPARE(init(qmlscene, QString(TEST_QMLFILE), blockMode, restrictMode), ConnectSuccess);
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(connected())));
@@ -804,12 +834,10 @@ void tst_QQmlDebugJS::connect()
void tst_QQmlDebugJS::interrupt()
{
//void connect()
-
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
QCOMPARE(init(qmlscene), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
m_client->interrupt();
QVERIFY(waitForClientSignal(SIGNAL(interruptRequested())));
@@ -818,41 +846,37 @@ void tst_QQmlDebugJS::interrupt()
void tst_QQmlDebugJS::getVersion()
{
//void version()
-
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
QCOMPARE(init(qmlscene), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(connected())));
m_client->version();
QVERIFY(waitForClientSignal(SIGNAL(result())));
+ checkVersionParameters();
}
void tst_QQmlDebugJS::getVersionWhenAttaching()
{
//void version()
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
QCOMPARE(init(qmlscene, QLatin1String(TIMER_QMLFILE), false), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
m_client->version();
QVERIFY(waitForClientSignal(SIGNAL(result())));
+ checkVersionParameters();
}
void tst_QQmlDebugJS::disconnect()
{
//void disconnect()
-
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
QCOMPARE(init(qmlscene), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
m_client->disconnect();
QVERIFY(waitForClientSignal(SIGNAL(result())));
@@ -862,14 +886,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QString jsonString(m_client->response);
@@ -885,14 +907,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
QCOMPARE(init(qmlscene, CREATECOMPONENT_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QString jsonString(m_client->response);
@@ -907,12 +927,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
{
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
int sourceLine = 35;
QCOMPARE(init(qmlscene, TIMER_QMLFILE), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
//We can set the breakpoint after connect() here because the timer is repeating and if we miss
//its first iteration we can still catch the second one.
m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
@@ -931,14 +950,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 31;
QCOMPARE(init(qmlscene, LOADJSFILE_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(TEST_JSFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QString jsonString(m_client->response);
@@ -954,15 +971,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
int actualLine = 36;
QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
@@ -979,15 +994,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 35;
int actualLine = 36;
QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
@@ -1004,14 +1017,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
{
//void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 39;
QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QString jsonString(m_client->response);
@@ -1026,13 +1037,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
{
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
int out = 10;
int sourceLine = 37;
QCOMPARE(init(qmlscene, CONDITION_QMLFILE), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
//The breakpoint is in a timer loop so we can set it after connect().
m_client->setBreakpoint(QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
@@ -1065,14 +1075,13 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
{
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
QCOMPARE(init(qmlscene, QUIT_QMLFILE), ConnectSuccess);
int sourceLine = 36;
m_client->setBreakpoint(QLatin1String(QUIT_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QString jsonString(m_client->response);
@@ -1109,14 +1118,12 @@ void tst_QQmlDebugJS::clearBreakpoint()
{
//void clearBreakpoint(int breakpoint);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine1 = 37;
int sourceLine2 = 38;
QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
//The breakpoints are in a timer loop so we can set them after connect().
//Furthermore the breakpoints should be hit in the right order because setting of breakpoints
//can only occur in the QML event loop. (see QCOMPARE for sourceLine2 below)
@@ -1155,16 +1162,105 @@ void tst_QQmlDebugJS::clearBreakpoint()
QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
}
+void tst_QQmlDebugJS::changeBreakpoint()
+{
+ //void clearBreakpoint(int breakpoint);
+ QFETCH(bool, qmlscene);
+
+ int sourceLine2 = 37;
+ int sourceLine1 = 38;
+ QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess);
+
+ bool isStopped = false;
+ QObject::connect(m_client, &QJSDebugClient::stopped, this, [&]() { isStopped = true; });
+
+ auto continueDebugging = [&]() {
+ m_client->continueDebugging(QJSDebugClient::Continue);
+ isStopped = false;
+ };
+
+ m_client->connect();
+
+ auto extractBody = [&]() {
+ const QVariantMap value = m_client->parser.call(
+ QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
+ return value.value("body").toMap();
+ };
+
+ auto extractBreakPointId = [&](const QVariantMap &body) {
+ const QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+ if (breakpointsHit.size() != 1)
+ return -1;
+ return breakpointsHit[0].toInt();
+ };
+
+ auto setBreakPoint = [&](int sourceLine, bool enabled) {
+ int id = -1;
+ auto connection = QObject::connect(m_client, &QJSDebugClient::result, [&]() {
+ id = extractBody().value("breakpoint").toInt();
+ });
+
+ m_client->setBreakpoint(QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine, -1, enabled);
+ bool success = QTest::qWaitFor([&]() { return id >= 0; });
+ Q_UNUSED(success);
+
+ QObject::disconnect(connection);
+ return id;
+ };
+
+ //The breakpoints are in a timer loop so we can set them after connect().
+ //Furthermore the breakpoints should be hit in the right order because setting of breakpoints
+ //can only occur in the QML event loop. (see QCOMPARE for sourceLine2 below)
+ const int breakpoint1 = setBreakPoint(sourceLine1, false);
+ QVERIFY(breakpoint1 >= 0);
+
+ const int breakpoint2 = setBreakPoint(sourceLine2, true);
+ QVERIFY(breakpoint2 >= 0);
+
+ auto verifyBreakpoint = [&](int sourceLine, int breakpointId) {
+ QTRY_VERIFY_WITH_TIMEOUT(isStopped, 30000);
+ const QVariantMap body = extractBody();
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(extractBreakPointId(body), breakpointId);
+ };
+
+ verifyBreakpoint(sourceLine2, breakpoint2);
+
+ continueDebugging();
+ verifyBreakpoint(sourceLine2, breakpoint2);
+
+ m_client->changeBreakpoint(breakpoint2, false);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+
+ m_client->changeBreakpoint(breakpoint1, true);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+
+ continueDebugging();
+ verifyBreakpoint(sourceLine1, breakpoint1);
+
+ continueDebugging();
+ verifyBreakpoint(sourceLine1, breakpoint1);
+
+ m_client->changeBreakpoint(breakpoint2, true);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+
+ m_client->changeBreakpoint(breakpoint1, false);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+
+ for (int i = 0; i < 3; ++i) {
+ continueDebugging();
+ verifyBreakpoint(sourceLine2, breakpoint2);
+ }
+}
+
void tst_QQmlDebugJS::setExceptionBreak()
{
//void setExceptionBreak(QString type, bool enabled = false);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
QCOMPARE(init(qmlscene, EXCEPTION_QMLFILE), ConnectSuccess);
m_client->setExceptionBreak(QJSDebugClient::All,true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
}
@@ -1172,14 +1268,12 @@ void tst_QQmlDebugJS::stepNext()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 37;
QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->continueDebugging(QJSDebugClient::Next);
@@ -1206,15 +1300,13 @@ void tst_QQmlDebugJS::stepIn()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 41;
int actualLine = 36;
QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
@@ -1230,15 +1322,13 @@ void tst_QQmlDebugJS::stepOut()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 37;
int actualLine = 41;
QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
@@ -1254,8 +1344,6 @@ void tst_QQmlDebugJS::continueDebugging()
{
//void continueDebugging(StepAction stepAction, int stepCount = 1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine1 = 41;
int sourceLine2 = 38;
@@ -1263,7 +1351,7 @@ void tst_QQmlDebugJS::continueDebugging()
m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->continueDebugging(QJSDebugClient::Continue);
@@ -1282,14 +1370,12 @@ void tst_QQmlDebugJS::backtrace()
{
//void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->backtrace();
@@ -1300,14 +1386,12 @@ void tst_QQmlDebugJS::getFrameDetails()
{
//void frame(int number = -1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->frame();
@@ -1318,14 +1402,12 @@ void tst_QQmlDebugJS::getScopeDetails()
{
//void scope(int number = -1, int frameNumber = -1);
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
int sourceLine = 34;
QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->scope();
@@ -1353,15 +1435,13 @@ void tst_QQmlDebugJS::evaluateInGlobalScope()
void tst_QQmlDebugJS::evaluateInLocalScope()
{
//void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
-
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
int sourceLine = 34;
QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess);
m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->frame();
@@ -1438,14 +1518,12 @@ void tst_QQmlDebugJS::evaluateInContext()
void tst_QQmlDebugJS::getScripts()
{
//void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
-
QFETCH(bool, qmlscene);
- QFETCH(bool, redundantRefs);
- QFETCH(bool, namesAsObjects);
+
QCOMPARE(init(qmlscene), ConnectSuccess);
m_client->setBreakpoint(QString(TEST_QMLFILE), 35, -1, true);
- m_client->connect(redundantRefs, namesAsObjects);
+ m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
m_client->scripts();
@@ -1533,16 +1611,8 @@ QList<QQmlDebugClient *> tst_QQmlDebugJS::createClients()
void tst_QQmlDebugJS::targetData()
{
QTest::addColumn<bool>("qmlscene");
- QTest::addColumn<bool>("redundantRefs");
- QTest::addColumn<bool>("namesAsObjects");
- QTest::newRow("custom / redundant / objects") << false << true << true;
- QTest::newRow("qmlscene / redundant / objects") << true << true << true;
- QTest::newRow("custom / redundant / strings") << false << true << false;
- QTest::newRow("qmlscene / redundant / strings") << true << true << false;
- QTest::newRow("custom / sparse / objects") << false << false << true;
- QTest::newRow("qmlscene / sparse / objects") << true << false << true;
- QTest::newRow("custom / sparse / strings") << false << false << false;
- QTest::newRow("qmlscene / sparse / strings") << true << false << false;
+ QTest::newRow("custom") << false;
+ QTest::newRow("qmlscene") << true;
}
bool tst_QQmlDebugJS::waitForClientSignal(const char *signal, int timeout)
@@ -1550,6 +1620,17 @@ bool tst_QQmlDebugJS::waitForClientSignal(const char *signal, int timeout)
return QQmlDebugTest::waitForSignal(m_client.data(), signal, timeout);
}
+void tst_QQmlDebugJS::checkVersionParameters()
+{
+ const QVariantMap value = m_client->parser.call(
+ QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
+ QCOMPARE(value.value("command").toString(), QString("version"));
+ const QVariantMap body = value.value("body").toMap();
+ QCOMPARE(body.value("UnpausedEvaluate").toBool(), true);
+ QCOMPARE(body.value("ContextEvaluate").toBool(), true);
+ QCOMPARE(body.value("ChangeBreakpoint").toBool(), true);
+}
+
QTEST_MAIN(tst_QQmlDebugJS)
#include "tst_qqmldebugjs.moc"
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.cpp b/tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.cpp
index 6a4ec5cc75..6a4ec5cc75 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjsserver/qqmldebugjsserver.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.cpp
diff --git a/tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.pro b/tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.pro
new file mode 100644
index 0000000000..a31da57054
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjsserver/qqmldebugjsserver.pro
@@ -0,0 +1,9 @@
+QT += qml testlib
+macos:CONFIG -= app_bundle
+INCLUDEPATH += ../shared
+SOURCES += qqmldebugjsserver.cpp
+DEFINES += QT_QML_DEBUG_NO_WARNING
+
+target.path = $$[QT_INSTALL_TESTS]/qqmldebugjsserver
+INSTALLS += target
+
diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
index 5b3c0c5240..4e47c92c2a 100644
--- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
+++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
@@ -65,8 +65,6 @@ void tst_QQmlDebugLocal::initTestCase()
{
fileName = QString::fromLatin1("tst_QQmlDebugLocal%1").arg(std::time(nullptr));
QQmlDebugConnector::setPluginKey("QQmlDebugServer");
- QTest::ignoreMessage(QtWarningMsg,
- "QML debugger: Cannot set plugin key after loading the plugin.");
m_service = new QQmlDebugTestService("tst_QQmlDebugLocal::handshake()");
const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName);
diff --git a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp
index 993a1d5f63..35bd912d9b 100644
--- a/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp
+++ b/tests/auto/qml/debugger/qqmldebugprocess/qqmldebugprocess/tst_qqmldebugprocess.cpp
@@ -118,7 +118,7 @@ void tst_QQmlDebugProcess::sessionStart()
QTimer::singleShot(delay, process.data(), wait);
QTRY_VERIFY(done);
- QVERIFY(process->state().startsWith("not running"));
+ QCOMPARE(process->state(), QProcess::NotRunning);
}
QTEST_MAIN(tst_QQmlDebugProcess)
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
index 1daf6b581e..3557940386 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -75,8 +75,6 @@ void tst_QQmlDebugService::initTestCase()
QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
QQmlDebugConnector::setServices(QStringList()
<< QStringLiteral("tst_QQmlDebugService"));
- QTest::ignoreMessage(QtWarningMsg,
- "QML debugger: Cannot set plugin key after loading the plugin.");
m_service = new QQmlDebugTestService("tst_QQmlDebugService", 2);
foreach (const QString &service, QQmlDebuggingEnabler::debuggerServices())
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 417b75e760..c613d88b2b 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -1124,7 +1124,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
QCOMPARE(onEnteredRef.name, QString("onEntered"));
// Sorry, can't do that anymore: QCOMPARE(onEnteredRef.value, QVariant("{ console.log('hello') }"));
- QCOMPARE(onEnteredRef.value, QVariant("function() { [code] }"));
+ QCOMPARE(onEnteredRef.value, QVariant("function() { [native code] }"));
m_dbg->setBindingForObject(mouseAreaObject.debugId, "onEntered",
"{console.log('hello, world') }", false,
@@ -1144,7 +1144,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
QVERIFY(!mouseAreaObject.className.isEmpty());
onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
QCOMPARE(onEnteredRef.name, QString("onEntered"));
- QCOMPARE(onEnteredRef.value, QVariant("function() { [code] }"));
+ QCOMPARE(onEnteredRef.value, QVariant("function() { [native code] }"));
}
void tst_QQmlEngineDebugService::resetBindingForObject()
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/broken.qml b/tests/auto/qml/debugger/qqmlpreview/data/broken.qml
new file mode 100644
index 0000000000..4ebbf7576a
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/broken.qml
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/i18n/qml_fr_FR.qm b/tests/auto/qml/debugger/qqmlpreview/data/i18n/qml_fr_FR.qm
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/i18n/qml_fr_FR.qm
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/qtquick2.qml b/tests/auto/qml/debugger/qqmlpreview/data/qtquick2.qml
new file mode 100644
index 0000000000..b525ab4fa0
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/qtquick2.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 100
+ height: 100
+ color: "blue"
+
+ RotationAnimation on rotation {
+ duration: 3600
+ loops: Animation.Infinite
+ from: 0
+ to: 360
+ }
+
+ Timer {
+ interval: 300
+ repeat: true
+ running: true
+ property int prevHit: -1
+ property int prevRotation: -1
+ onTriggered: {
+ var date = new Date;
+ var millis = date.getMilliseconds()
+
+ if (prevHit < 0) {
+ prevHit = millis;
+ prevRotation = parent.rotation
+ return;
+ }
+
+ var milliDelta = millis - prevHit;
+ if (milliDelta <= 0)
+ milliDelta += 1000;
+ prevHit = millis;
+
+ var delta = parent.rotation - prevRotation;
+ if (delta < 0)
+ delta += 360
+ prevRotation = parent.rotation
+ console.log(milliDelta, delta, "ms/degrees ");
+ }
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/window.qml b/tests/auto/qml/debugger/qqmlpreview/data/window.qml
new file mode 100644
index 0000000000..f9f8d5aeb1
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/window.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+
+Window {
+ visible: true
+
+ height: 100
+ width: 100
+
+ Timer {
+ repeat: false
+ interval: 1000
+ running: true
+ onTriggered: console.log("window.qml");
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/window1.qml b/tests/auto/qml/debugger/qqmlpreview/data/window1.qml
new file mode 100644
index 0000000000..e8e9ad706d
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/window1.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.3
+
+Window {
+ visible: true
+
+ height: 200
+ width: 100
+
+ Timer {
+ interval: 1000
+ running: true
+ onTriggered: console.log("window1.qml");
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/window2.qml b/tests/auto/qml/debugger/qqmlpreview/data/window2.qml
new file mode 100644
index 0000000000..9ad42d2ee2
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/window2.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.3
+
+Window {
+ visible: true
+
+ height: 100
+ width: 200
+
+ Timer {
+ interval: 1000
+ running: true
+ onTriggered: console.log("window2.qml");
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlpreview/data/zoom.qml b/tests/auto/qml/debugger/qqmlpreview/data/zoom.qml
new file mode 100644
index 0000000000..0aca235de1
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/data/zoom.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.2
+
+Window {
+ id: w
+ height: 100
+ width: 100
+ visible: true
+
+ Rectangle {
+ width: 50
+ height: 50
+ color: "blue"
+ anchors.centerIn: parent
+ }
+
+ Timer {
+ interval: 100
+ running: true
+ repeat: true
+ onTriggered: console.log("zoom", w.screen.devicePixelRatio)
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlpreview/qqmlpreview.pro b/tests/auto/qml/debugger/qqmlpreview/qqmlpreview.pro
new file mode 100644
index 0000000000..4a0d385e1a
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/qqmlpreview.pro
@@ -0,0 +1,24 @@
+CONFIG += testcase
+TARGET = tst_qqmlpreview
+
+QT += qml testlib core qmldebug-private
+macos:CONFIG -= app_bundle
+
+INCLUDEPATH += ../../../../../src/plugins/qmltooling/qmldbg_preview/
+
+SOURCES += \
+ tst_qqmlpreview.cpp \
+ ../../../../../src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.cpp
+
+HEADERS += \
+ ../../../../../src/plugins/qmltooling/qmldbg_preview/qqmlpreviewblacklist.h
+
+include(../shared/debugutil.pri)
+
+TESTDATA = \
+ data/window.qml \
+ data/qtquick2.qml \
+ data/window2.qml \
+ data/window1.qml \
+ data/broken.qml \
+ data/zoom.qml
diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
new file mode 100644
index 0000000000..b4f8f389cf
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugprocess_p.h"
+#include "debugutil_p.h"
+#include "qqmlpreviewblacklist.h"
+
+#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qlibraryinfo.h>
+#include <QtNetwork/qhostaddress.h>
+
+#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlpreviewclient_p.h>
+
+class tst_QQmlPreview : public QQmlDebugTest
+{
+ Q_OBJECT
+
+private:
+ ConnectResult startQmlProcess(const QString &qmlFile);
+ void serveRequest(const QString &path);
+ QList<QQmlDebugClient *> createClients() override;
+ void verifyProcessOutputContains(const QString &string) const;
+
+ QPointer<QQmlPreviewClient> m_client;
+
+ QStringList m_files;
+ QStringList m_filesNotFound;
+ QStringList m_directories;
+ QStringList m_serviceErrors;
+ QQmlPreviewClient::FpsInfo m_frameStats;
+
+private slots:
+ void cleanup() final;
+
+ void connect();
+ void load();
+ void rerun();
+ void blacklist();
+ void error();
+ void zoom();
+ void fps();
+ void language();
+};
+
+QQmlDebugTest::ConnectResult tst_QQmlPreview::startQmlProcess(const QString &qmlFile)
+{
+ return QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml",
+ QStringLiteral("QmlPreview"), testFile(qmlFile), true);
+}
+
+void tst_QQmlPreview::serveRequest(const QString &path)
+{
+ QFileInfo info(path);
+
+ if (info.isDir()) {
+ m_directories.append(path);
+ m_client->sendDirectory(path, QDir(path).entryList());
+ } else {
+ QFile file(path);
+ if (file.open(QIODevice::ReadOnly)) {
+ m_files.append(path);
+ m_client->sendFile(path, file.readAll());
+ } else {
+ m_filesNotFound.append(path);
+ m_client->sendError(path);
+ }
+ }
+}
+
+QList<QQmlDebugClient *> tst_QQmlPreview::createClients()
+{
+ m_client = new QQmlPreviewClient(m_connection);
+
+ QObject::connect(m_client, &QQmlPreviewClient::request, this, &tst_QQmlPreview::serveRequest);
+ QObject::connect(m_client, &QQmlPreviewClient::error, this, [this](const QString &error) {
+ m_serviceErrors.append(error);
+ });
+ QObject::connect(m_client, &QQmlPreviewClient::fps,
+ this, [this](const QQmlPreviewClient::FpsInfo &info) {
+ m_frameStats = info;
+ });
+
+ return QList<QQmlDebugClient *>({m_client});
+}
+
+void tst_QQmlPreview::verifyProcessOutputContains(const QString &string) const
+{
+ QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains(string), 30000);
+}
+
+void checkFiles(const QStringList &files)
+{
+ QVERIFY(!files.contains("/etc/localtime"));
+ QVERIFY(!files.contains("/etc/timezome"));
+ QVERIFY(!files.contains(":/qgradient/webgradients.binaryjson"));
+}
+
+void tst_QQmlPreview::cleanup()
+{
+ // Use a separate function so that we don't return early from cleanup() on failure.
+ checkFiles(m_files);
+
+ QQmlDebugTest::cleanup();
+ if (QTest::currentTestFailed()) {
+ qDebug() << "Files loaded:" << m_files;
+ qDebug() << "Files not loaded:" << m_filesNotFound;
+ qDebug() << "Directories loaded:" << m_directories;
+ qDebug() << "Errors reported:" << m_serviceErrors;
+ }
+
+ m_directories.clear();
+ m_files.clear();
+ m_filesNotFound.clear();
+ m_serviceErrors.clear();
+ m_frameStats = QQmlPreviewClient::FpsInfo();
+}
+
+void tst_QQmlPreview::connect()
+{
+ const QString file("window.qml");
+ QCOMPARE(startQmlProcess(file), ConnectSuccess);
+ QVERIFY(m_client);
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+ m_client->triggerLoad(testFileUrl(file));
+ QTRY_VERIFY(m_files.contains(testFile(file)));
+ verifyProcessOutputContains(file);
+ m_process->stop();
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::NotConnected);
+ QVERIFY(m_serviceErrors.isEmpty());
+}
+
+void tst_QQmlPreview::load()
+{
+ const QString file("qtquick2.qml");
+ QCOMPARE(startQmlProcess(file), ConnectSuccess);
+ QVERIFY(m_client);
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+ m_client->triggerLoad(testFileUrl(file));
+ QTRY_VERIFY(m_files.contains(testFile(file)));
+ verifyProcessOutputContains("ms/degrees");
+
+ const QStringList files({"window2.qml", "window1.qml", "window.qml"});
+ for (const QString &newFile : files) {
+ m_client->triggerLoad(testFileUrl(newFile));
+ QTRY_VERIFY(m_files.contains(testFile(newFile)));
+ verifyProcessOutputContains(newFile);
+ }
+
+ m_process->stop();
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::NotConnected);
+ QVERIFY(m_serviceErrors.isEmpty());
+}
+
+void tst_QQmlPreview::rerun()
+{
+ const QString file("window.qml");
+ QCOMPARE(startQmlProcess(file), ConnectSuccess);
+ QVERIFY(m_client);
+ m_client->triggerLoad(testFileUrl(file));
+ const QLatin1String message("window.qml");
+ verifyProcessOutputContains(message);
+ const int pos = m_process->output().lastIndexOf(message) + message.size();
+ QVERIFY(pos >= 0);
+
+ m_client->triggerRerun();
+ QTRY_VERIFY_WITH_TIMEOUT(m_process->output().indexOf(message, pos) >= pos, 30000);
+
+ m_process->stop();
+ QVERIFY(m_serviceErrors.isEmpty());
+}
+
+void tst_QQmlPreview::blacklist()
+{
+ QQmlPreviewBlacklist blacklist;
+
+ QStringList strings({
+ "lalala", "lulul", "trakdkd", "suppe", "zack"
+ });
+
+ for (const QString &string : strings)
+ QVERIFY(!blacklist.isBlacklisted(string));
+
+ for (const QString &string : strings)
+ blacklist.blacklist(string);
+
+ for (const QString &string : strings) {
+ QVERIFY(blacklist.isBlacklisted(string));
+ QVERIFY(!blacklist.isBlacklisted(string.left(string.size() / 2)));
+ QVERIFY(!blacklist.isBlacklisted(string + "45"));
+ QVERIFY(!blacklist.isBlacklisted(" " + string));
+ QVERIFY(blacklist.isBlacklisted(string + "/45"));
+ }
+
+ for (auto begin = strings.begin(), it = begin, end = strings.end(); it != end; ++it) {
+ std::rotate(begin, it, end);
+ QString path = "/" + strings.join('/');
+ blacklist.blacklist(path);
+ QVERIFY(blacklist.isBlacklisted(path));
+ QVERIFY(blacklist.isBlacklisted(path + "/file"));
+ QVERIFY(!blacklist.isBlacklisted(path + "more"));
+ path.chop(1);
+ QVERIFY(!blacklist.isBlacklisted(path));
+ std::reverse(begin, end);
+ }
+
+ blacklist.clear();
+ for (const QString &string : strings)
+ QVERIFY(!blacklist.isBlacklisted(string));
+
+ blacklist.blacklist(":/qt-project.org");
+ QVERIFY(blacklist.isBlacklisted(":/qt-project.org/QmlRuntime/conf/configuration.qml"));
+ QVERIFY(!blacklist.isBlacklisted(":/qt-project.orgQmlRuntime/conf/configuration.qml"));
+
+ QQmlPreviewBlacklist blacklist2;
+
+ blacklist2.blacklist(":/qt-project.org");
+ blacklist2.blacklist(":/QtQuick/Controls/Styles");
+ blacklist2.blacklist(":/ExtrasImports/QtQuick/Controls/Styles");
+ blacklist2.blacklist(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath));
+ blacklist2.blacklist("/home/ulf/.local/share/QtProject/Qml Runtime/configuration.qml");
+ blacklist2.blacklist("/usr/share");
+ blacklist2.blacklist("/usr/share/QtProject/Qml Runtime/configuration.qml");
+ QVERIFY(blacklist2.isBlacklisted(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)));
+ blacklist2.blacklist("/usr/local/share/QtProject/Qml Runtime/configuration.qml");
+ blacklist2.blacklist("qml");
+ blacklist2.blacklist(""); // This should not remove all other paths.
+
+ QVERIFY(blacklist2.isBlacklisted(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) +
+ "/QtQuick/Window.2.0"));
+ QVERIFY(blacklist2.isBlacklisted(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)));
+ QVERIFY(blacklist2.isBlacklisted("/usr/share/QtProject/Qml Runtime/configuration.qml"));
+ QVERIFY(blacklist2.isBlacklisted("/usr/share/stuff"));
+ QVERIFY(blacklist2.isBlacklisted(""));
+
+ QQmlPreviewBlacklist blacklist3;
+ blacklist3.blacklist("/usr/share");
+ blacklist3.blacklist("/usr");
+ blacklist3.blacklist("/usrdings");
+ QVERIFY(blacklist3.isBlacklisted("/usrdings"));
+ QVERIFY(blacklist3.isBlacklisted("/usr/src"));
+ QVERIFY(!blacklist3.isBlacklisted("/opt/share"));
+ QVERIFY(!blacklist3.isBlacklisted("/opt"));
+
+ blacklist3.whitelist("/usr/share");
+ QVERIFY(blacklist3.isBlacklisted("/usrdings"));
+ QVERIFY(!blacklist3.isBlacklisted("/usr"));
+ QVERIFY(!blacklist3.isBlacklisted("/usr/share"));
+ QVERIFY(!blacklist3.isBlacklisted("/usr/src"));
+ QVERIFY(!blacklist3.isBlacklisted("/opt/share"));
+ QVERIFY(!blacklist3.isBlacklisted("/opt"));
+}
+
+void tst_QQmlPreview::error()
+{
+ QCOMPARE(startQmlProcess("window.qml"), ConnectSuccess);
+ QVERIFY(m_client);
+ m_client->triggerLoad(testFileUrl("broken.qml"));
+ QTRY_COMPARE_WITH_TIMEOUT(m_serviceErrors.count(), 1, 10000);
+ QVERIFY(m_serviceErrors.first().contains("broken.qml:32 Expected token `}'"));
+}
+
+static float parseZoomFactor(const QString &output)
+{
+ const QString prefix("zoom ");
+ const int start = output.lastIndexOf(prefix) + prefix.length();
+ if (start < 0)
+ return -1;
+ const int end = output.indexOf('\n', start);
+ if (end < 0)
+ return -1;
+ bool ok = false;
+ const float zoomFactor = output.mid(start, end - start).toFloat(&ok);
+ if (!ok)
+ return -1;
+ return zoomFactor;
+}
+
+static void verifyZoomFactor(const QQmlDebugProcess *process, float factor)
+{
+ QTRY_VERIFY_WITH_TIMEOUT(qFuzzyCompare(parseZoomFactor(process->output()), factor), 30000);
+}
+
+void tst_QQmlPreview::zoom()
+{
+ const QString file("zoom.qml");
+ QCOMPARE(startQmlProcess(file), ConnectSuccess);
+ QVERIFY(m_client);
+ m_client->triggerLoad(testFileUrl(file));
+ QTRY_VERIFY(m_files.contains(testFile(file)));
+ float baseZoomFactor = -1;
+ QTRY_VERIFY_WITH_TIMEOUT((baseZoomFactor = parseZoomFactor(m_process->output())) > 0, 30000);
+ m_client->triggerZoom(2.0f);
+ verifyZoomFactor(m_process, baseZoomFactor * 2.0f);
+ m_client->triggerZoom(1.5f);
+ verifyZoomFactor(m_process, baseZoomFactor * 1.5f);
+ m_client->triggerZoom(0.5f);
+ verifyZoomFactor(m_process, baseZoomFactor * 0.5f);
+ m_client->triggerZoom(-1.0f);
+ verifyZoomFactor(m_process, baseZoomFactor);
+ m_process->stop();
+ QVERIFY(m_serviceErrors.isEmpty());
+}
+
+void tst_QQmlPreview::fps()
+{
+ const QString file("qtquick2.qml");
+ QCOMPARE(startQmlProcess(file), ConnectSuccess);
+ QVERIFY(m_client);
+ m_client->triggerLoad(testFileUrl(file));
+ if (QGuiApplication::platformName() != "offscreen") {
+ QTRY_VERIFY(m_frameStats.numSyncs > 10);
+ QVERIFY(m_frameStats.minSync <= m_frameStats.maxSync);
+ QVERIFY(m_frameStats.totalSync / m_frameStats.numSyncs >= m_frameStats.minSync - 1);
+ QVERIFY(m_frameStats.totalSync / m_frameStats.numSyncs <= m_frameStats.maxSync);
+
+ QVERIFY(m_frameStats.numRenders > 0);
+ QVERIFY(m_frameStats.minRender <= m_frameStats.maxRender);
+ QVERIFY(m_frameStats.totalRender / m_frameStats.numRenders >= m_frameStats.minRender - 1);
+ QVERIFY(m_frameStats.totalRender / m_frameStats.numRenders <= m_frameStats.maxRender);
+ } else {
+ QSKIP("offscreen rendering doesn't produce any frames");
+ }
+}
+
+void tst_QQmlPreview::language()
+{
+ QCOMPARE(startQmlProcess("window.qml"), ConnectSuccess);
+ QVERIFY(m_client);
+ m_client->triggerLanguage(dataDirectoryUrl(), "fr_FR");
+ QTRY_VERIFY_WITH_TIMEOUT(m_files.contains(testFile("i18n/qml_fr_FR.qm")), 30000);
+}
+
+QTEST_MAIN(tst_QQmlPreview)
+
+#include "tst_qqmlpreview.moc"
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/quit.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/quit.qml
new file mode 100644
index 0000000000..bc8c2b90ae
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/quit.qml
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//DO NOT CHANGE
+
+Item {
+ Timer {
+ running: true
+ triggeredOnStart: true
+ onTriggered: Qt.quit();
+ }
+}
+
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 3cb315b355..eb0b0c2fe2 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -34,6 +34,7 @@
#include <private/qqmldebugconnection_p.h>
#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
#include <QtCore/qlibraryinfo.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -195,7 +196,9 @@ private:
};
ConnectResult connect(bool block, const QString &testFile, bool recordFromStart = true,
- uint flushInterval = 0, bool restrictServices = true);
+ uint flushInterval = 0, bool restrictServices = true,
+ const QString &executable
+ = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
void checkProcessTerminated();
void checkTraceReceived();
void checkJsHeap();
@@ -221,6 +224,7 @@ private slots:
void translationBinding();
void memory();
void compile();
+ void multiEngine();
private:
bool m_recordFromStart = true;
@@ -237,7 +241,7 @@ private:
QQmlDebugTest::ConnectResult tst_QQmlProfilerService::connect(
bool block, const QString &file, bool recordFromStart, uint flushInterval,
- bool restrictServices)
+ bool restrictServices, const QString &executable)
{
m_recordFromStart = recordFromStart;
m_flushInterval = flushInterval;
@@ -245,7 +249,7 @@ QQmlDebugTest::ConnectResult tst_QQmlProfilerService::connect(
// ### Still using qmlscene due to QTBUG-33377
return QQmlDebugTest::connect(
- QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene",
+ executable,
restrictServices ? "CanvasFrameRate,EngineControl,DebugMessages" : QString(),
testFile(file), block);
}
@@ -261,11 +265,13 @@ void tst_QQmlProfilerService::checkProcessTerminated()
QVERIFY(m_client->client);
QTRY_COMPARE(m_client->client->state(), QQmlDebugClient::NotConnected);
QVERIFY(m_process);
+ QVERIFY(m_process->exitStatus() != QProcess::CrashExit);
QTRY_COMPARE(m_process->exitStatus(), QProcess::NormalExit);
}
void tst_QQmlProfilerService::checkTraceReceived()
{
+ QVERIFY(m_process->exitStatus() != QProcess::CrashExit);
QTRY_VERIFY2(m_isComplete, "No trace received in time.");
QVector<qint64> numbers;
@@ -282,6 +288,7 @@ void tst_QQmlProfilerService::checkTraceReceived()
void tst_QQmlProfilerService::checkJsHeap()
{
+ QVERIFY(m_client);
QVERIFY2(m_client->jsHeapMessages.count() > 0, "no JavaScript heap messages received");
bool seen_alloc = false;
@@ -340,6 +347,11 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty
int expectedPosition, const QQmlProfilerEventType &expected,
quint32 checks, const QVector<qint64> &expectedNumbers)
{
+ if (!m_client) {
+ qWarning() << "No debug client available";
+ return false;
+ }
+
const QVector<QQmlProfilerEvent> *target = nullptr;
switch (type) {
case MessageListQML: target = &(m_client->qmlMessages); break;
@@ -349,6 +361,11 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty
case MessageListPixmap: target = &(m_client->pixmapMessages); break;
}
+ if (!target) {
+ qWarning() << "Invalid MessageListType" << type;
+ return false;
+ }
+
if (target->length() <= expectedPosition) {
qWarning() << "Not enough events. expected position:" << expectedPosition
<< "length:" << target->length();
@@ -629,7 +646,7 @@ void tst_QQmlProfilerService::scenegraphData()
void tst_QQmlProfilerService::profileOnExit()
{
- connect(true, "exit.qml");
+ QCOMPARE(connect(true, "exit.qml"), ConnectSuccess);
checkProcessTerminated();
checkTraceReceived();
@@ -711,7 +728,7 @@ void tst_QQmlProfilerService::flushInterval()
void tst_QQmlProfilerService::translationBinding()
{
- connect(true, "qstr.qml");
+ QCOMPARE(connect(true, "qstr.qml"), ConnectSuccess);
checkProcessTerminated();
checkTraceReceived();
@@ -727,12 +744,13 @@ void tst_QQmlProfilerService::translationBinding()
void tst_QQmlProfilerService::memory()
{
- connect(true, "memory.qml");
+ QCOMPARE(connect(true, "memory.qml"), ConnectSuccess);
checkProcessTerminated();
checkTraceReceived();
checkJsHeap();
+ QVERIFY(m_client);
int smallItems = 0;
for (auto message : m_client->jsHeapMessages) {
const QQmlProfilerEventType &type = m_client->types[message.typeIndex()];
@@ -757,6 +775,8 @@ void tst_QQmlProfilerService::compile()
// Flush interval so that we actually get the events before we stop recording.
connect(true, "test.qml", true, 100);
+ QVERIFY(m_client);
+
// We need to check specifically for compile events as we can otherwise stop recording after the
// StartTrace has arrived, but before it compiles anything.
QTRY_VERIFY(hasCompileEvents(m_client->types));
@@ -790,6 +810,22 @@ void tst_QQmlProfilerService::compile()
QCOMPARE(rangeStage, RangeEnd);
}
+void tst_QQmlProfilerService::multiEngine()
+{
+ QCOMPARE(connect(true, "quit.qml", true, 0, false, debugJsServerPath("qqmlprofilerservice")),
+ ConnectSuccess);
+
+ QSignalSpy spy(m_client->client, SIGNAL(complete(qint64)));
+
+ checkTraceReceived();
+ checkJsHeap();
+
+ QTRY_COMPARE(m_process->state(), QProcess::NotRunning);
+ QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
+
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QQmlProfilerService)
#include "tst_qqmlprofilerservice.moc"
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index c65c592f10..b75fb6b895 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -86,8 +86,7 @@ public:
QV4::Scope scope(v4);
QV4::ScopedString name(scope, v4->newString(functionName));
- QV4::ScopedContext ctx(scope, v4->rootContext());
- QV4::ScopedValue function(scope, FunctionObject::createBuiltinFunction(ctx, name, injectedFunction));
+ QV4::ScopedValue function(scope, FunctionObject::createBuiltinFunction(v4, name, injectedFunction, 0));
v4->globalObject->put(name, function);
}
@@ -106,7 +105,7 @@ public:
void run() {
QV4::Scope scope(collector->engine());
QV4::ScopedValue v(scope, *collector->engine()->exceptionValue);
- exception = collector->collect(v);
+ exception = collector->addValueRef(v);
}
QV4DataCollector::Ref exceptionValue() const { return exception; }
@@ -220,16 +219,26 @@ public:
{
for (int i = 0, ei = m_stackTrace.size(); i != ei; ++i) {
m_capturedScope.append(NamedRefs());
- ScopeJob job(&collector, i, 0);
+ FrameJob frameJob(&collector, i);
+ debugger->runInEngine(&frameJob);
+ QJsonObject frameObj = frameJob.returnValue();
+ QJsonArray scopes = frameObj.value(QLatin1String("scopes")).toArray();
+ int nscopes = scopes.size();
+ int s = 0;
+ for (s = 0; s < nscopes; ++s) {
+ QJsonObject o = scopes.at(s).toObject();
+ if (o.value(QLatin1String("type")).toInt(-2) == 1) // CallContext
+ break;
+ }
+ if (s == nscopes)
+ return;
+
+ ScopeJob job(&collector, i, s);
debugger->runInEngine(&job);
NamedRefs &refs = m_capturedScope.last();
QJsonObject object = job.returnValue();
object = object.value(QLatin1String("object")).toObject();
- if (object.contains("ref") && !object.contains("properties")) {
- QVERIFY(collector.redundantRefs());
- object = collector.lookupRef(object.value("ref").toInt(), true);
- QVERIFY(object.contains("properties"));
- }
+ QVERIFY(!object.contains("ref") || object.contains("properties"));
foreach (const QJsonValue &value, object.value(QLatin1String("properties")).toArray()) {
QJsonObject property = value.toObject();
QString name = property.value(QLatin1String("name")).toString();
@@ -295,14 +304,10 @@ private slots:
void conditionalBreakPointInQml();
// context access:
- void readArguments_data() { redundancy_data(); }
void readArguments();
void readComplicatedArguments();
- void readLocals_data() { redundancy_data(); }
void readLocals();
- void readObject_data() { redundancy_data(); }
void readObject();
- void readContextInAllFrames_data() { redundancy_data(); }
void readContextInAllFrames();
// exceptions:
@@ -310,9 +315,7 @@ private slots:
void breakInCatch();
void breakInWith();
- void evaluateExpression_data() { redundancy_data(); }
void evaluateExpression();
- void stepToEndOfScript_data() { redundancy_data(); }
void stepToEndOfScript();
void lastLineOfConditional_data();
@@ -332,8 +335,6 @@ private:
waitForSignal(m_engine, SIGNAL(evaluateFinished()), /*timeout*/0);
}
- void redundancy_data();
-
TestEngine *m_engine;
QV4::ExecutionEngine *m_v4;
TestAgent *m_debuggerAgent;
@@ -482,7 +483,7 @@ void tst_qv4debugger::conditionalBreakPoint()
QVERIFY(m_debuggerAgent->m_capturedScope.size() > 1);
const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedScope.at(0);
- QCOMPARE(frame0.size(), 2);
+ QCOMPARE(frame0.size(), 3);
QVERIFY(frame0.contains("i"));
QCOMPARE(frame0.value("i").toInt(), 11);
}
@@ -526,9 +527,6 @@ void tst_qv4debugger::conditionalBreakPointInQml()
void tst_qv4debugger::readArguments()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"var f = function(a, b, c, d) {\n"
@@ -541,7 +539,7 @@ void tst_qv4debugger::readArguments()
QVERIFY(m_debuggerAgent->m_wasPaused);
QVERIFY(m_debuggerAgent->m_capturedScope.size() > 1);
const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedScope.at(0);
- QCOMPARE(frame0.size(), 4);
+ QCOMPARE(frame0.size(), 5);
QVERIFY(frame0.contains(QStringLiteral("a")));
QCOMPARE(frame0.type(QStringLiteral("a")), QStringLiteral("number"));
QCOMPARE(frame0.value(QStringLiteral("a")).toDouble(), 1.0);
@@ -552,7 +550,6 @@ void tst_qv4debugger::readArguments()
void tst_qv4debugger::readComplicatedArguments()
{
- m_debuggerAgent->collector.setRedundantRefs(false);
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"var f = function(a) {\n"
@@ -565,7 +562,7 @@ void tst_qv4debugger::readComplicatedArguments()
QVERIFY(m_debuggerAgent->m_wasPaused);
QVERIFY(m_debuggerAgent->m_capturedScope.size() > 1);
const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedScope.at(0);
- QCOMPARE(frame0.size(), 1);
+ QCOMPARE(frame0.size(), 2);
QVERIFY(frame0.contains(QStringLiteral("a")));
QCOMPARE(frame0.type(QStringLiteral("a")), QStringLiteral("number"));
QCOMPARE(frame0.value(QStringLiteral("a")).toInt(), 12);
@@ -573,9 +570,6 @@ void tst_qv4debugger::readComplicatedArguments()
void tst_qv4debugger::readLocals()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"var f = function(a, b) {\n"
@@ -589,7 +583,7 @@ void tst_qv4debugger::readLocals()
QVERIFY(m_debuggerAgent->m_wasPaused);
QVERIFY(m_debuggerAgent->m_capturedScope.size() > 1);
const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedScope.at(0);
- QCOMPARE(frame0.size(), 4); // locals and parameters
+ QCOMPARE(frame0.size(), 5); // locals and parameters
QVERIFY(frame0.contains("c"));
QCOMPARE(frame0.type("c"), QStringLiteral("number"));
QCOMPARE(frame0.value("c").toDouble(), 3.0);
@@ -599,9 +593,6 @@ void tst_qv4debugger::readLocals()
void tst_qv4debugger::readObject()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"var f = function(a) {\n"
@@ -614,7 +605,7 @@ void tst_qv4debugger::readObject()
QVERIFY(m_debuggerAgent->m_wasPaused);
QVERIFY(m_debuggerAgent->m_capturedScope.size() > 1);
const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedScope.at(0);
- QCOMPARE(frame0.size(), 2);
+ QCOMPARE(frame0.size(), 3);
QVERIFY(frame0.contains("b"));
QCOMPARE(frame0.type("b"), QStringLiteral("object"));
QJsonObject b = frame0.rawValue("b");
@@ -623,7 +614,7 @@ void tst_qv4debugger::readObject()
QVERIFY(!b.contains(QStringLiteral("properties")));
QVERIFY(b.value("value").isDouble());
QCOMPARE(b.value("value").toInt(), 2);
- b = m_debuggerAgent->collector.lookupRef(b.value("ref").toInt(), true);
+ b = m_debuggerAgent->collector.lookupRef(b.value("ref").toInt());
QVERIFY(b.contains(QStringLiteral("properties")));
QVERIFY(b.value("properties").isArray());
QJsonArray b_props = b.value("properties").toArray();
@@ -639,8 +630,7 @@ void tst_qv4debugger::readObject()
QCOMPARE(b_tail.value("name").toString(), QStringLiteral("tail"));
QVERIFY(b_tail.contains("ref"));
- QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt(),
- true);
+ QJsonObject b_tail_value = m_debuggerAgent->collector.lookupRef(b_tail.value("ref").toInt());
QCOMPARE(b_tail_value.value("type").toString(), QStringLiteral("object"));
QVERIFY(b_tail_value.contains("properties"));
QJsonArray b_tail_props = b_tail_value.value("properties").toArray();
@@ -657,9 +647,6 @@ void tst_qv4debugger::readObject()
void tst_qv4debugger::readContextInAllFrames()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
m_debuggerAgent->m_captureContextInfo = true;
QString script =
"var fact = function(n) {\n"
@@ -679,7 +666,7 @@ void tst_qv4debugger::readContextInAllFrames()
for (int i = 0; i < 12; ++i) {
const TestAgent::NamedRefs &scope = m_debuggerAgent->m_capturedScope.at(i);
- QCOMPARE(scope.size(), 2);
+ QCOMPARE(scope.size(), 3);
QVERIFY(scope.contains("n"));
QCOMPARE(scope.type("n"), QStringLiteral("number"));
QCOMPARE(scope.value("n").toDouble(), i + 1.0);
@@ -707,8 +694,7 @@ void tst_qv4debugger::pauseOnThrow()
QCOMPARE(m_debuggerAgent->m_pauseReason, QV4Debugger::Throwing);
QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 2);
QVERIFY(m_debuggerAgent->m_thrownValue >= qint64(0));
- QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue,
- true);
+ QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue);
// DUMP_JSON(exception);
QCOMPARE(exception.value("type").toString(), QStringLiteral("string"));
QCOMPARE(exception.value("value").toString(), QStringLiteral("hard"));
@@ -752,9 +738,6 @@ void tst_qv4debugger::breakInWith()
void tst_qv4debugger::evaluateExpression()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
QString script =
"function testFunction() {\n"
" var x = 10\n"
@@ -796,9 +779,6 @@ void tst_qv4debugger::evaluateExpression()
void tst_qv4debugger::stepToEndOfScript()
{
- QFETCH(bool, redundantRefs);
- m_debuggerAgent->collector.setRedundantRefs(redundantRefs);
-
QString script =
"var ret = 0;\n"
"ret += 4;\n"
@@ -919,13 +899,6 @@ void tst_qv4debugger::readThis()
QCOMPARE(a.value("value").toInt(), 5);
}
-void tst_qv4debugger::redundancy_data()
-{
- QTest::addColumn<bool>("redundantRefs");
- QTest::addRow("redundant") << true;
- QTest::addRow("sparse") << false;
-}
-
QTEST_MAIN(tst_qv4debugger)
#include "tst_qv4debugger.moc"
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index b118b22c64..68446b53a4 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -98,6 +98,9 @@ QString QQmlDebugTest::connectionStateString(const QQmlDebugConnection *connecti
QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c)
: QQmlDebugClient(s, c)
{
+ connect(this, &QQmlDebugClient::stateChanged, this, [this](QQmlDebugClient::State newState) {
+ QCOMPARE(newState, state());
+ });
}
QByteArray QQmlDebugTestClient::waitForResponse()
@@ -111,31 +114,12 @@ QByteArray QQmlDebugTestClient::waitForResponse()
return lastMsg;
}
-void QQmlDebugTestClient::stateChanged(State stat)
-{
- QCOMPARE(stat, state());
- emit stateHasChanged();
-}
-
void QQmlDebugTestClient::messageReceived(const QByteArray &ba)
{
lastMsg = ba;
emit serverMessage(ba);
}
-template<typename F>
-struct Finalizer {
- F m_lambda;
- Finalizer(F &&lambda) : m_lambda(std::forward<F>(lambda)) {}
- ~Finalizer() { m_lambda(); }
-};
-
-template<typename F>
-static Finalizer<F> defer(F &&lambda)
-{
- return Finalizer<F>(std::forward<F>(lambda));
-}
-
QQmlDebugTest::ConnectResult QQmlDebugTest::connect(
const QString &executable, const QString &services, const QString &extraArgs,
bool block)
@@ -162,31 +146,27 @@ QQmlDebugTest::ConnectResult QQmlDebugTest::connect(
if (m_clients.contains(nullptr))
return ClientsFailed;
- auto allEnabled = [this]() {
- for (QQmlDebugClient *client : m_clients) {
- if (client->state() != QQmlDebugClient::Enabled)
- return false;
- }
- return true;
- };
+ ClientStateHandler stateHandler(m_clients, createOtherClients(m_connection), services.isEmpty()
+ ? QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
- QList<QQmlDebugClient *> others = createOtherClients(m_connection);
- auto deleter = defer([&others]() { qDeleteAll(others); });
- Q_UNUSED(deleter);
const int port = m_process->debugPort();
m_connection->connectToHost(QLatin1String("127.0.0.1"), port);
- for (int tries = 0; tries < 100 && !allEnabled(); ++tries)
- QTest::qWait(50);
- if (!allEnabled())
+
+ QEventLoop loop;
+ QTimer timer;
+ QObject::connect(&stateHandler, &ClientStateHandler::allOk, &loop, &QEventLoop::quit);
+ QObject::connect(m_connection, &QQmlDebugConnection::disconnected, &loop, &QEventLoop::quit);
+ QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
+
+ timer.start(5000);
+ loop.exec();
+
+ if (!stateHandler.allEnabled())
return EnableFailed;
- const QQmlDebugClient::State expectedState = services.isEmpty() ? QQmlDebugClient::Enabled
- : QQmlDebugClient::Unavailable;
- for (QQmlDebugClient *other : others) {
- if (other->state() != expectedState)
- return RestrictFailed;
- }
+ if (!stateHandler.othersAsExpected())
+ return RestrictFailed;
return ConnectSuccess;
}
@@ -211,7 +191,7 @@ void QQmlDebugTest::cleanup()
if (QTest::currentTestFailed()) {
const QString null = QStringLiteral("null");
- qDebug() << "Process State:" << (m_process ? m_process->state() : null);
+ qDebug() << "Process State:" << (m_process ? m_process->stateString() : null);
qDebug() << "Application Output:" << (m_process ? m_process->output() : null);
qDebug() << "Connection State:" << QQmlDebugTest::connectionStateString(m_connection);
for (QQmlDebugClient *client : m_clients) {
@@ -234,3 +214,50 @@ void QQmlDebugTest::cleanup()
m_process = nullptr;
}
}
+
+ClientStateHandler::ClientStateHandler(const QList<QQmlDebugClient *> &clients,
+ const QList<QQmlDebugClient *> &others,
+ QQmlDebugClient::State expectedOthers) :
+ m_clients(clients), m_others(others), m_expectedOthers(expectedOthers)
+{
+ for (QQmlDebugClient *client : m_clients) {
+ QObject::connect(client, &QQmlDebugClient::stateChanged,
+ this, &ClientStateHandler::checkStates);
+ }
+ for (QQmlDebugClient *client : m_others) {
+ QObject::connect(client, &QQmlDebugClient::stateChanged,
+ this, &ClientStateHandler::checkStates);
+ }
+}
+
+ClientStateHandler::~ClientStateHandler()
+{
+ qDeleteAll(m_others);
+}
+
+void ClientStateHandler::checkStates()
+{
+ for (QQmlDebugClient *client : m_clients) {
+ if (client->state() != QQmlDebugClient::Enabled)
+ return;
+ }
+
+ m_allEnabled = true;
+
+ for (QQmlDebugClient *other : m_others) {
+ if (other->state() != m_expectedOthers)
+ return;
+ }
+
+ m_othersAsExpected = true;
+ emit allOk();
+}
+
+QString debugJsServerPath(const QString &selfPath)
+{
+ static const char *debugserver = "qqmldebugjsserver";
+ QString appPath = QCoreApplication::applicationDirPath();
+ const int position = appPath.lastIndexOf(selfPath);
+ return (position == -1 ? appPath : appPath.replace(position, selfPath.length(), debugserver))
+ + "/" + debugserver;
+}
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index 94ad83bfce..1c32590305 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -88,11 +88,9 @@ public:
QByteArray waitForResponse();
signals:
- void stateHasChanged();
void serverMessage(const QByteArray &);
protected:
- virtual void stateChanged(State state);
virtual void messageReceived(const QByteArray &ba);
private:
@@ -116,4 +114,33 @@ public:
}
};
+class ClientStateHandler : public QObject
+{
+ Q_OBJECT
+public:
+ ClientStateHandler(const QList<QQmlDebugClient *> &clients,
+ const QList<QQmlDebugClient *> &others,
+ QQmlDebugClient::State expectedOthers);
+
+ ~ClientStateHandler();
+
+ bool allEnabled() const { return m_allEnabled; }
+ bool othersAsExpected() const { return m_othersAsExpected; }
+
+signals:
+ void allOk();
+
+private:
+ void checkStates();
+
+ const QList<QQmlDebugClient *> m_clients;
+ const QList<QQmlDebugClient *> m_others;
+ const QQmlDebugClient::State m_expectedOthers;
+
+ bool m_allEnabled = false;
+ bool m_othersAsExpected = false;
+};
+
+QString debugJsServerPath(const QString &selfPath);
+
#endif // DEBUGUTIL_P_H
diff --git a/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
index f2b85833c9..6f74edf863 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
@@ -50,6 +50,7 @@ QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent)
this, [this]() {
m_timer.stop();
m_eventLoop.quit();
+ emit finished();
});
connect(&m_timer, &QTimer::timeout,
this, &QQmlDebugProcess::timeout);
@@ -60,7 +61,7 @@ QQmlDebugProcess::~QQmlDebugProcess()
stop();
}
-QString QQmlDebugProcess::state()
+QString QQmlDebugProcess::stateString() const
{
QString stateStr;
switch (m_process.state()) {
@@ -155,6 +156,11 @@ bool QQmlDebugProcess::waitForFinished()
return m_process.waitForFinished();
}
+QProcess::ProcessState QQmlDebugProcess::state() const
+{
+ return m_process.state();
+}
+
QProcess::ExitStatus QQmlDebugProcess::exitStatus() const
{
return m_process.exitStatus();
diff --git a/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h b/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h
index fd2c89bb41..945cc58c85 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h
+++ b/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h
@@ -52,7 +52,7 @@ public:
QQmlDebugProcess(const QString &executable, QObject *parent = 0);
~QQmlDebugProcess();
- QString state();
+ QString stateString() const;
void addEnvironment(const QString &environment);
@@ -61,6 +61,7 @@ public:
int debugPort() const;
bool waitForFinished();
+ QProcess::ProcessState state() const;
QProcess::ExitStatus exitStatus() const;
QString output() const;
@@ -69,6 +70,7 @@ public:
signals:
void readyReadStandardOutput();
+ void finished();
private slots:
void timeout();
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
index 4dce07d824..896ed608fd 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
@@ -48,5 +48,4 @@ void QQmlDebugTestService::stateAboutToBeChanged(QQmlDebugService::State)
void QQmlDebugTestService::stateChanged(State)
{
Q_ASSERT(QThread::currentThread() != thread());
- emit stateHasChanged();
}
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
index 37b4a9f98c..9c39c0893d 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h
@@ -38,9 +38,6 @@ class QQmlDebugTestService : public QQmlDebugService
public:
QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
-signals:
- void stateHasChanged();
-
protected:
virtual void messageReceived(const QByteArray &ba);
virtual void stateAboutToBeChanged(State state);
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index 589f25d174..6236fe5036 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -1,177 +1,887 @@
-# wrong tests
-# uses octal number
-15.2.3.6-2-17-1 failing
+# ----- These are tests we will not fix
-# these fail after the update to Unicode 6.3.
-# the reason is that u+180e changed type from whitespace to control
-S9.3.1_A2
-S9.3.1_A3_T1
-S9.3.1_A3_T2
-S15.1.2.2_A2_T10
-S15.1.2.3_A2_T10
-15.5.4.20-3-2
-15.5.4.20-3-3
-15.5.4.20-3-4
-15.5.4.20-3-5
-15.5.4.20-3-6
+# The tests below rely on the ES6 spec quirk that allows 'let' as an identifier. We've
+# always treated 'let' as a reserved keyword (without ever getting a bug report about it),
+# so we'll keep it that way. It also removes a huge headache in the parser.
+language/statements/for-in/let-block-with-newline.js sloppyFails
+language/statements/for-of/let-block-with-newline.js sloppyFails
+language/statements/for/let-block-with-newline.js sloppyFails
+language/statements/if/let-block-with-newline.js sloppyFails
+language/statements/labeled/let-block-with-newline.js sloppyFails
+language/statements/while/let-block-with-newline.js sloppyFails
+language/statements/with/let-block-with-newline.js sloppyFails
+language/statements/for-in/let-identifier-with-newline.js sloppyFails
+language/statements/for-of/let-identifier-with-newline.js sloppyFails
+language/statements/for/let-identifier-with-newline.js sloppyFails
+language/statements/if/let-identifier-with-newline.js sloppyFails
+language/statements/labeled/let-identifier-with-newline.js sloppyFails
+language/statements/while/let-identifier-with-newline.js sloppyFails
+language/statements/with/let-identifier-with-newline.js sloppyFails
-11.2.3-3_3 failing
-S13_A15_T4 failing
-S15.4.4.3_A1_T1 failing
-S15.4.4.3_A3_T1 failing
-S15.5.4.11_A5_T1 failing
-S15.2.4.4_A14 failing
+# The ES6/7 spec says that [[DefineOwnProperty]] on the module namespace exotic object
+# always returns false. This was changed in https://github.com/tc39/ecma262/pull/858
+# but it's not in the published spec yet.
+language/module-code/namespace/internals/define-own-property.js strictFails
+# This test includes the above and therefore also fails.
+language/module-code/namespace/internals/set.js strictFails
-# Function declarations in conditionals. We allow them, because the real
-# world requires them.
-Sbp_12.5_A9_T3 failing
-Sbp_12.6.1_A13_T3 failing
-Sbp_12.6.2_A13_T3 failing
-Sbp_12.6.4_A13_T3 failing
-
-# es6: function length attributes are configurable, wasn't in es5
-S15.1.2.2_A9.2 failing
-S15.1.3.1_A5.2 failing
-S15.1.3.2_A5.2 failing
-S15.1.3.3_A5.2 failing
-S15.1.2.3_A7.2 failing
-S15.1.2.4_A2.2 failing
-S15.1.2.5_A2.2 failing
-S15.1.3.4_A5.2 failing
-15.2.3.3-4-186 failing
-S15.2.4.2_A9 failing
-S15.2.4.3_A9 failing
-S15.2.4.4_A9 failing
-S15.2.4.5_A9 failing
-S15.2.4.6_A9 failing
-S15.2.4.7_A9 failing
-15.3.3.2-1 failing
-15.4.4.2_A4.2
-S15.3.4.2_A9 failing
-S15.3.4.3_A9 failing
-S15.3.4.4_A9 failing
-15.3.4.5-15-2 failing
-S15.4.4.2_A4.2 failing
-S15.4.4.3_A4.2 failing
-S15.4.4.4_A4.2 failing
-S15.4.4.5_A6.2 failing
-S15.4.4.6_A5.2 failing
-S15.4.4.7_A6.2 failing
-S15.4.4.8_A5.2 failing
-S15.4.4.9_A5.2 failing
-S15.4.4.10_A5.2 failing
-S15.4.4.11_A7.2 failing
-S15.4.4.12_A5.2 failing
-S15.4.4.13_A5.2 failing
-S15.5.4.10_A9 failing
-S15.5.4.11_A9 failing
-S15.5.4.12_A9 failing
-S15.5.4.13_A9 failing
-S15.5.4.14_A9 failing
-S15.5.4.15_A9 failing
-S15.5.4.16_A9 failing
-S15.5.4.17_A9 failing
-S15.5.4.18_A9 failing
-S15.5.4.19_A9 failing
-S15.5.4.4_A9 failing
-S15.5.4.5_A9 failing
-S15.5.4.6_A9 failing
-S15.5.4.7_A9 failing
-S15.5.4.8_A9 failing
-S15.5.4.9_A9 failing
-S15.9.4.2_A3_T2 failing
-S15.9.4.3_A3_T2 failing
-S15.9.5.2_A3_T2 failing
-S15.9.5.3_A3_T2 failing
-S15.9.5.4_A3_T2 failing
-S15.9.5.5_A3_T2 failing
-S15.9.5.1_A3_T2 failing
-S15.9.5.10_A3_T2 failing
-S15.9.5.11_A3_T2 failing
-S15.9.5.12_A3_T2 failing
-S15.9.5.13_A3_T2 failing
-S15.9.5.14_A3_T2 failing
-S15.9.5.15_A3_T2 failing
-S15.9.5.16_A3_T2 failing
-S15.9.5.17_A3_T2 failing
-S15.9.5.18_A3_T2 failing
-S15.9.5.19_A3_T2 failing
-S15.9.5.20_A3_T2 failing
-S15.9.5.21_A3_T2 failing
-S15.9.5.22_A3_T2 failing
-S15.9.5.23_A3_T2 failing
-S15.9.5.24_A3_T2 failing
-S15.9.5.25_A3_T2 failing
-S15.9.5.26_A3_T2 failing
-S15.9.5.27_A3_T2 failing
-S15.9.5.28_A3_T2 failing
-S15.9.5.29_A3_T2 failing
-S15.9.5.30_A3_T2 failing
-S15.9.5.31_A3_T2 failing
-S15.9.5.32_A3_T2 failing
-S15.9.5.33_A3_T2 failing
-S15.9.5.34_A3_T2 failing
-S15.9.5.35_A3_T2 failing
-S15.9.5.36_A3_T2 failing
-S15.9.5.37_A3_T2 failing
-S15.9.5.38_A3_T2 failing
-S15.9.5.39_A3_T2 failing
-S15.9.5.40_A3_T2 failing
-S15.9.5.41_A3_T2 failing
-S15.9.5.42_A3_T2 failing
-S15.9.5.6_A3_T2 failing
-S15.9.5.7_A3_T2 failing
-S15.9.5.8_A3_T2 failing
-S15.9.5.9_A3_T2 failing
-S15.10.6.2_A9 failing
-S15.10.6.3_A9 failing
-S15.10.6.4_A9 failing
-
-# es6: Object.freeze(v) on a non-object returns v, no longer TypeError
-15.2.3.9-1 failing
-15.2.3.9-1-1 failing
-15.2.3.9-1-2 failing
-15.2.3.9-1-3 failing
-15.2.3.9-1-4 failing
-# es6: Object.preventExtensions(O) on a non-object, no longer TypeError
-15.2.3.10-1 failing
-15.2.3.10-1-3 failing
-15.2.3.10-1-4 failing
-# es6: Object.isSealed(O) on a non-object, no longer TypeError
-15.2.3.11-1
-# es6: Object.isFrozen(O) on a non-object, no longer TypeError
-15.2.3.12-1
-15.2.3.12-1-3
-15.2.3.12-1-4
-# es6: Object.isExtensible(O) on a non-object, no longer TypeError
-15.2.3.13-1
-15.2.3.13-1-3
-15.2.3.13-1-4
-# es6: Object.keys(O) on a non-object, no longer TypeError
-15.2.3.14-1-1
-15.2.3.14-1-2
-15.2.3.14-1-3
-15.2.3.14-1
-15.2.3.14-2
-15.2.3.14-3
-# es6: Object.getOwnPropertyDescriptor(O) on a non-object, no longer TypeError
-15.2.3.3-1
-15.2.3.3-1-3
-15.2.3.3-1-4
-# es6: Object.getPrototypeOf(O) on a non-object, no longer TypeError
-15.2.3.2-1
-15.2.3.2-1-3
-15.2.3.2-1-4
-# es6: Object.getOwnPropertyNames(O) on a non-object, no longer TypeError
-15.2.3.4-1
-15.2.3.4-1-4
-15.2.3.4-1-5
-# es6: Object.seal(O) on a non-object, no longer TypeError
-15.2.3.8-1
-15.2.3.8-1-1
-15.2.3.8-1-2
-15.2.3.8-1-3
-15.2.3.8-1-4
-
-# es6: Date.prototype is no longer a DateObject
-15.9.5.40_1 failing
+# ----- test failures that should be fixed
+built-ins/Array/prototype/concat/Array.prototype.concat_large-typed-array.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments-with-dupes.js sloppyFails
+built-ins/Array/prototype/concat/Array.prototype.concat_sloppy-arguments.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_small-typed-array.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-function.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-sparse-object.js fails
+built-ins/Array/prototype/concat/Array.prototype.concat_strict-arguments.js fails
+built-ins/Array/prototype/concat/S15.4.4.4_A3_T1.js fails
+built-ins/Array/prototype/concat/S15.4.4.4_A3_T2.js fails
+built-ins/Array/prototype/concat/S15.4.4.4_A3_T3.js fails
+built-ins/Array/prototype/concat/create-ctor-non-object.js fails
+built-ins/Array/prototype/concat/create-proxy.js fails
+built-ins/Array/prototype/concat/create-species-non-ctor.js fails
+built-ins/Array/prototype/concat/create-species.js fails
+built-ins/Array/prototype/concat/is-concat-spreadable-val-falsey.js fails
+built-ins/Array/prototype/every/15.4.4.16-3-29.js fails
+built-ins/Array/prototype/filter/create-ctor-non-object.js fails
+built-ins/Array/prototype/filter/create-proxy.js fails
+built-ins/Array/prototype/filter/create-species-non-ctor.js fails
+built-ins/Array/prototype/filter/create-species.js fails
+built-ins/Array/prototype/includes/length-boundaries.js fails
+built-ins/Array/prototype/indexOf/15.4.4.14-3-28.js fails
+built-ins/Array/prototype/indexOf/15.4.4.14-3-29.js fails
+built-ins/Array/prototype/join/S15.4.4.5_A4_T3.js fails
+built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js fails
+built-ins/Array/prototype/map/create-ctor-non-object.js fails
+built-ins/Array/prototype/map/create-proxy.js fails
+built-ins/Array/prototype/map/create-species-non-ctor.js fails
+built-ins/Array/prototype/map/create-species.js fails
+built-ins/Array/prototype/pop/S15.4.4.6_A2_T2.js fails
+built-ins/Array/prototype/pop/S15.4.4.6_A3_T1.js fails
+built-ins/Array/prototype/pop/S15.4.4.6_A3_T2.js fails
+built-ins/Array/prototype/pop/clamps-to-integer-limit.js fails
+built-ins/Array/prototype/pop/length-near-integer-limit.js fails
+built-ins/Array/prototype/push/S15.4.4.7_A2_T2.js fails
+built-ins/Array/prototype/push/S15.4.4.7_A3.js fails
+built-ins/Array/prototype/push/throws-if-integer-limit-exceeded.js fails
+built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js fails
+built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js fails
+built-ins/Array/prototype/slice/S15.4.4.10_A3_T1.js fails
+built-ins/Array/prototype/slice/S15.4.4.10_A3_T2.js fails
+built-ins/Array/prototype/slice/create-ctor-non-object.js fails
+built-ins/Array/prototype/slice/create-non-array-invalid-len.js fails
+built-ins/Array/prototype/slice/create-proxied-array-invalid-len.js fails
+built-ins/Array/prototype/slice/create-proxy.js fails
+built-ins/Array/prototype/slice/create-species-neg-zero.js fails
+built-ins/Array/prototype/slice/create-species-non-ctor.js fails
+built-ins/Array/prototype/slice/create-species.js fails
+built-ins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js fails
+built-ins/Array/prototype/slice/length-exceeding-integer-limit.js fails
+built-ins/Array/prototype/some/15.4.4.17-3-28.js fails
+built-ins/Array/prototype/some/15.4.4.17-3-29.js fails
+built-ins/Array/prototype/sort/comparefn-nonfunction-call-throws.js fails
+built-ins/Array/prototype/splice/S15.4.4.12_A3_T1.js fails
+built-ins/Array/prototype/splice/clamps-length-to-integer-limit.js fails
+built-ins/Array/prototype/splice/create-ctor-non-object.js fails
+built-ins/Array/prototype/splice/create-proxy.js fails
+built-ins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js fails
+built-ins/Array/prototype/splice/create-species-neg-zero.js fails
+built-ins/Array/prototype/splice/create-species-non-ctor.js fails
+built-ins/Array/prototype/splice/create-species.js fails
+built-ins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js fails
+built-ins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js fails
+built-ins/Array/prototype/splice/length-near-integer-limit-grow-array.js fails
+built-ins/Array/prototype/toLocaleString/primitive_this_value.js strictFails
+built-ins/Array/prototype/toLocaleString/primitive_this_value_getter.js strictFails
+built-ins/Array/prototype/unshift/clamps-to-integer-limit.js fails
+built-ins/Array/prototype/unshift/length-near-integer-limit.js fails
+built-ins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js fails
+built-ins/ArrayBuffer/data-allocation-after-object-creation.js fails
+built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js fails
+built-ins/AsyncFunction/AsyncFunction-construct.js fails
+built-ins/AsyncFunction/AsyncFunction-is-extensible.js fails
+built-ins/AsyncFunction/AsyncFunction-is-subclass.js fails
+built-ins/AsyncFunction/AsyncFunction-length.js fails
+built-ins/AsyncFunction/AsyncFunction-name.js fails
+built-ins/AsyncFunction/AsyncFunction-prototype.js fails
+built-ins/AsyncFunction/AsyncFunction.js fails
+built-ins/AsyncFunction/AsyncFunctionPrototype-is-extensible.js fails
+built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js fails
+built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js fails
+built-ins/AsyncFunction/instance-construct-throws.js fails
+built-ins/AsyncFunction/instance-has-name.js fails
+built-ins/AsyncFunction/instance-length.js fails
+built-ins/AsyncFunction/instance-prototype-property.js fails
+built-ins/AsyncGeneratorPrototype/next/name.js fails
+built-ins/AsyncGeneratorPrototype/return/name.js fails
+built-ins/AsyncGeneratorPrototype/throw/name.js fails
+built-ins/Atomics/wait/did-timeout.js fails
+built-ins/Atomics/wait/good-views.js fails
+built-ins/Atomics/wait/nan-timeout.js fails
+built-ins/Atomics/wait/negative-timeout.js fails
+built-ins/Atomics/wait/no-spurious-wakeup.js fails
+built-ins/Atomics/wait/was-woken.js fails
+built-ins/Atomics/wake/counts.js fails
+built-ins/Atomics/wake/wake-all-on-loc.js fails
+built-ins/Atomics/wake/wake-all.js fails
+built-ins/Atomics/wake/wake-in-order.js fails
+built-ins/Atomics/wake/wake-nan.js fails
+built-ins/Atomics/wake/wake-negative.js fails
+built-ins/Atomics/wake/wake-one.js fails
+built-ins/Atomics/wake/wake-two.js fails
+built-ins/Atomics/wake/wake-zero.js fails
+built-ins/DataView/custom-proto-if-object-is-used.js fails
+built-ins/Date/prototype/toDateString/format.js fails
+built-ins/Date/prototype/toDateString/invalid-date.js fails
+built-ins/Date/prototype/toString/format.js fails
+built-ins/Date/prototype/toTimeString/format.js fails
+built-ins/Date/prototype/toTimeString/invalid-date.js fails
+built-ins/Date/prototype/toUTCString/day-names.js fails
+built-ins/Date/prototype/toUTCString/format.js fails
+built-ins/Date/prototype/toUTCString/month-names.js fails
+built-ins/Date/subclassing.js fails
+built-ins/Function/internals/Construct/base-ctor-revoked-proxy.js fails
+built-ins/Function/prototype/bind/BoundFunction_restricted-properties.js fails
+built-ins/Function/prototype/bind/instance-name-chained.js fails
+built-ins/Function/prototype/bind/instance-name-non-string.js fails
+built-ins/Function/prototype/bind/instance-name.js fails
+built-ins/Function/prototype/toString/AsyncFunction.js fails
+built-ins/Function/prototype/toString/async-arrow-function.js fails
+built-ins/Function/prototype/toString/async-function-declaration.js fails
+built-ins/Function/prototype/toString/async-function-expression.js fails
+built-ins/Function/prototype/toString/async-method-class-expression-static.js fails
+built-ins/Function/prototype/toString/async-method-class-expression.js fails
+built-ins/Function/prototype/toString/async-method-class-statement-static.js fails
+built-ins/Function/prototype/toString/async-method-class-statement.js fails
+built-ins/Function/prototype/toString/async-method-object.js fails
+built-ins/Function/prototype/toString/intrinsics.js fails
+built-ins/Function/prototype/toString/method-computed-property-name.js fails
+built-ins/JSON/parse/revived-proxy-revoked.js fails
+built-ins/JSON/parse/revived-proxy.js fails
+built-ins/JSON/stringify/replacer-proxy-revoked.js fails
+built-ins/JSON/stringify/replacer-proxy.js fails
+built-ins/JSON/stringify/value-proxy.js fails
+built-ins/Map/prototype/forEach/iterates-values-deleted-then-readded.js fails
+built-ins/Math/round/S15.8.2.15_A7.js fails
+built-ins/Number/prototype/toPrecision/return-values.js fails
+built-ins/Object/create/15.2.3.5-4-14.js strictFails
+built-ins/Object/create/15.2.3.5-4-37.js strictFails
+built-ins/Object/entries/getter-making-future-key-nonenumerable.js fails
+built-ins/Object/entries/getter-removing-future-key.js fails
+built-ins/Object/entries/observable-operations.js fails
+built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js fails
+built-ins/Object/keys/proxy-keys.js fails
+built-ins/Object/proto-from-ctor.js fails
+built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js strictFails
+built-ins/Object/prototype/toString/proxy-array.js fails
+built-ins/Object/prototype/toString/proxy-function.js fails
+built-ins/Object/prototype/valueOf/S15.2.4.4_A14.js fails
+built-ins/Object/values/getter-adding-key.js fails
+built-ins/Object/values/observable-operations.js fails
+built-ins/Promise/S25.4.3.1_A1.1_T1.js fails
+built-ins/Promise/S25.4.3.1_A2.1_T1.js fails
+built-ins/Promise/S25.4.3.1_A2.2_T1.js fails
+built-ins/Promise/S25.4.3.1_A3.1_T1.js fails
+built-ins/Promise/Symbol.species/length.js fails
+built-ins/Promise/Symbol.species/prop-desc.js fails
+built-ins/Promise/Symbol.species/return-value.js fails
+built-ins/Promise/Symbol.species/symbol-species-name.js fails
+built-ins/Promise/Symbol.species/symbol-species.js fails
+built-ins/Promise/all/S25.4.4.1_A1.1_T1.js fails
+built-ins/Promise/all/S25.4.4.1_A2.1_T1.js fails
+built-ins/Promise/all/S25.4.4.1_A4.1_T1.js fails
+built-ins/Promise/all/S25.4.4.1_A6.1_T1.js fails
+built-ins/Promise/all/call-resolve-element-after-return.js fails
+built-ins/Promise/all/call-resolve-element-items.js fails
+built-ins/Promise/all/call-resolve-element.js fails
+built-ins/Promise/all/capability-executor-called-twice.js fails
+built-ins/Promise/all/capability-executor-not-callable.js fails
+built-ins/Promise/all/capability-resolve-throws-no-close.js fails
+built-ins/Promise/all/ctx-ctor-throws.js fails
+built-ins/Promise/all/ctx-ctor.js fails
+built-ins/Promise/all/ctx-non-ctor.js fails
+built-ins/Promise/all/ctx-non-object.js fails
+built-ins/Promise/all/invoke-resolve-error-close.js fails
+built-ins/Promise/all/invoke-resolve-get-error-close.js fails
+built-ins/Promise/all/invoke-resolve-return.js fails
+built-ins/Promise/all/invoke-resolve.js fails
+built-ins/Promise/all/invoke-then-error-close.js fails
+built-ins/Promise/all/invoke-then-get-error-close.js fails
+built-ins/Promise/all/invoke-then.js fails
+built-ins/Promise/all/iter-next-val-err-no-close.js fails
+built-ins/Promise/all/iter-step-err-no-close.js fails
+built-ins/Promise/all/length.js fails
+built-ins/Promise/all/name.js fails
+built-ins/Promise/all/new-resolve-function.js fails
+built-ins/Promise/all/prop-desc.js fails
+built-ins/Promise/all/resolve-before-loop-exit-from-same.js fails
+built-ins/Promise/all/resolve-before-loop-exit.js fails
+built-ins/Promise/all/resolve-element-function-extensible.js fails
+built-ins/Promise/all/resolve-element-function-length.js fails
+built-ins/Promise/all/resolve-element-function-name.js fails
+built-ins/Promise/all/resolve-element-function-nonconstructor.js fails
+built-ins/Promise/all/resolve-element-function-prototype.js fails
+built-ins/Promise/all/resolve-from-same-thenable.js fails
+built-ins/Promise/all/same-reject-function.js fails
+built-ins/Promise/all/species-get-error.js fails
+built-ins/Promise/exec-args.js fails
+built-ins/Promise/executor-function-extensible.js fails
+built-ins/Promise/executor-function-length.js fails
+built-ins/Promise/executor-function-name.js fails
+built-ins/Promise/executor-function-nonconstructor.js fails
+built-ins/Promise/executor-function-prototype.js fails
+built-ins/Promise/length.js fails
+built-ins/Promise/name.js fails
+built-ins/Promise/prototype/S25.4.4.2_A1.1_T1.js fails
+built-ins/Promise/prototype/S25.4.5_A3.1_T1.js fails
+built-ins/Promise/prototype/Symbol.toStringTag.js fails
+built-ins/Promise/prototype/catch/S25.4.5.1_A1.1_T1.js fails
+built-ins/Promise/prototype/catch/S25.4.5.1_A2.1_T1.js fails
+built-ins/Promise/prototype/catch/invokes-then.js fails
+built-ins/Promise/prototype/catch/length.js fails
+built-ins/Promise/prototype/catch/name.js fails
+built-ins/Promise/prototype/catch/prop-desc.js fails
+built-ins/Promise/prototype/catch/this-value-non-object.js fails
+built-ins/Promise/prototype/catch/this-value-obj-coercible.js fails
+built-ins/Promise/prototype/catch/this-value-then-not-callable.js fails
+built-ins/Promise/prototype/catch/this-value-then-poisoned.js fails
+built-ins/Promise/prototype/catch/this-value-then-throws.js fails
+built-ins/Promise/prototype/no-promise-state.js fails
+built-ins/Promise/prototype/prop-desc.js fails
+built-ins/Promise/prototype/proto.js fails
+built-ins/Promise/prototype/then/S25.4.5.3_A1.1_T1.js fails
+built-ins/Promise/prototype/then/S25.4.5.3_A1.1_T2.js fails
+built-ins/Promise/prototype/then/S25.4.5.3_A2.1_T1.js fails
+built-ins/Promise/prototype/then/S25.4.5.3_A2.1_T2.js fails
+built-ins/Promise/prototype/then/capability-executor-called-twice.js fails
+built-ins/Promise/prototype/then/capability-executor-not-callable.js fails
+built-ins/Promise/prototype/then/context-check-on-entry.js fails
+built-ins/Promise/prototype/then/ctor-custom.js fails
+built-ins/Promise/prototype/then/ctor-null.js fails
+built-ins/Promise/prototype/then/ctor-poisoned.js fails
+built-ins/Promise/prototype/then/ctor-throws.js fails
+built-ins/Promise/prototype/then/ctor-undef.js fails
+built-ins/Promise/prototype/then/length.js fails
+built-ins/Promise/prototype/then/name.js fails
+built-ins/Promise/prototype/then/prop-desc.js fails
+built-ins/Promise/race/S25.4.4.3_A1.1_T1.js fails
+built-ins/Promise/race/S25.4.4.3_A2.1_T1.js fails
+built-ins/Promise/race/S25.4.4.3_A3.1_T1.js fails
+built-ins/Promise/race/S25.4.4.3_A3.1_T2.js fails
+built-ins/Promise/race/capability-executor-called-twice.js fails
+built-ins/Promise/race/capability-executor-not-callable.js fails
+built-ins/Promise/race/ctx-ctor-throws.js fails
+built-ins/Promise/race/ctx-ctor.js fails
+built-ins/Promise/race/ctx-non-ctor.js fails
+built-ins/Promise/race/ctx-non-object.js fails
+built-ins/Promise/race/invoke-resolve-error-close.js fails
+built-ins/Promise/race/invoke-resolve-get-error-close.js fails
+built-ins/Promise/race/invoke-resolve-return.js fails
+built-ins/Promise/race/invoke-resolve.js fails
+built-ins/Promise/race/invoke-then-error-close.js fails
+built-ins/Promise/race/invoke-then-get-error-close.js fails
+built-ins/Promise/race/invoke-then.js fails
+built-ins/Promise/race/iter-next-val-err-no-close.js fails
+built-ins/Promise/race/iter-step-err-no-close.js fails
+built-ins/Promise/race/length.js fails
+built-ins/Promise/race/name.js fails
+built-ins/Promise/race/prop-desc.js fails
+built-ins/Promise/race/same-reject-function.js fails
+built-ins/Promise/race/same-resolve-function.js fails
+built-ins/Promise/race/species-get-error.js fails
+built-ins/Promise/reject-function-extensible.js fails
+built-ins/Promise/reject-function-length.js fails
+built-ins/Promise/reject-function-name.js fails
+built-ins/Promise/reject-function-nonconstructor.js fails
+built-ins/Promise/reject-function-prototype.js fails
+built-ins/Promise/reject/S25.4.4.4_A1.1_T1.js fails
+built-ins/Promise/reject/S25.4.4.4_A3.1_T1.js fails
+built-ins/Promise/reject/capability-executor-called-twice.js fails
+built-ins/Promise/reject/capability-executor-not-callable.js fails
+built-ins/Promise/reject/capability-invocation-error.js fails
+built-ins/Promise/reject/capability-invocation.js fails
+built-ins/Promise/reject/ctx-ctor-throws.js fails
+built-ins/Promise/reject/ctx-ctor.js fails
+built-ins/Promise/reject/ctx-non-ctor.js fails
+built-ins/Promise/reject/ctx-non-object.js fails
+built-ins/Promise/reject/length.js fails
+built-ins/Promise/reject/name.js fails
+built-ins/Promise/reject/prop-desc.js fails
+built-ins/Promise/resolve-function-extensible.js fails
+built-ins/Promise/resolve-function-length.js fails
+built-ins/Promise/resolve-function-name.js fails
+built-ins/Promise/resolve-function-nonconstructor.js fails
+built-ins/Promise/resolve-function-prototype.js fails
+built-ins/Promise/resolve/S25.4.4.5_A1.1_T1.js fails
+built-ins/Promise/resolve/S25.4.4.5_A2.1_T1.js fails
+built-ins/Promise/resolve/arg-uniq-ctor.js fails
+built-ins/Promise/resolve/capability-executor-called-twice.js fails
+built-ins/Promise/resolve/capability-executor-not-callable.js fails
+built-ins/Promise/resolve/capability-invocation-error.js fails
+built-ins/Promise/resolve/context-non-object-with-promise.js fails
+built-ins/Promise/resolve/ctx-ctor-throws.js fails
+built-ins/Promise/resolve/ctx-ctor.js fails
+built-ins/Promise/resolve/ctx-non-ctor.js fails
+built-ins/Promise/resolve/ctx-non-object.js fails
+built-ins/Promise/resolve/length.js fails
+built-ins/Promise/resolve/name.js fails
+built-ins/Promise/resolve/prop-desc.js fails
+built-ins/Promise/resolve/resolve-from-promise-capability.js fails
+built-ins/Promise/resolve/resolve-prms-cstm-then.js fails
+built-ins/Proxy/ownKeys/return-duplicate-entries-throws.js fails
+built-ins/Proxy/ownKeys/return-duplicate-symbol-entries-throws.js fails
+built-ins/RegExp/S15.10.2.12_A2_T1.js fails
+built-ins/RegExp/prototype/Symbol.match/builtin-success-u-return-val-groups.js fails
+built-ins/RegExp/prototype/Symbol.split/species-ctor.js fails
+built-ins/RegExp/prototype/exec/S15.10.6.2_A5_T3.js fails
+built-ins/RegExp/prototype/exec/failure-lastindex-access.js fails
+built-ins/RegExp/prototype/exec/success-lastindex-access.js fails
+built-ins/RegExp/prototype/source/value-line-terminator.js fails
+built-ins/RegExp/prototype/test/S15.10.6.3_A1_T22.js fails
+built-ins/RegExp/unicode_restricted_brackets.js fails
+built-ins/RegExp/unicode_restricted_character_class_escape.js fails
+built-ins/RegExp/unicode_restricted_identity_escape.js fails
+built-ins/RegExp/unicode_restricted_identity_escape_alpha.js fails
+built-ins/RegExp/unicode_restricted_identity_escape_c.js fails
+built-ins/RegExp/unicode_restricted_incomple_quantifier.js fails
+built-ins/RegExp/unicode_restricted_octal_escape.js fails
+built-ins/RegExp/unicode_restricted_quantifiable_assertion.js fails
+built-ins/RegExp/u180e.js fails
+built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js fails
+built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js fails
+built-ins/SharedArrayBuffer/prototype-from-newtarget.js fails
+built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js fails
+built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js fails
+built-ins/String/prototype/indexOf/position-tointeger-toprimitive.js fails
+built-ins/String/prototype/indexOf/position-tointeger.js fails
+built-ins/String/prototype/indexOf/searchstring-tostring-toprimitive.js fails
+built-ins/String/prototype/replace/cstm-replace-invocation.js fails
+built-ins/String/prototype/replace/this-value-not-obj-coercible.js fails
+built-ins/String/prototype/search/cstm-search-invocation.js fails
+built-ins/String/prototype/search/invoke-builtin-search-searcher-undef.js fails
+built-ins/String/prototype/search/invoke-builtin-search.js fails
+built-ins/String/prototype/slice/this-value-not-obj-coercible.js fails
+built-ins/String/prototype/split/cstm-split-invocation.js fails
+built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js fails
+built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js fails
+built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js fails
+built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js fails
+built-ins/String/prototype/toLowerCase/special_casing_conditional.js fails
+built-ins/String/raw/return-the-string-value-from-template.js fails
+built-ins/String/raw/special-characters.js fails
+built-ins/String/raw/template-substitutions-are-appended-on-same-index.js fails
+built-ins/String/raw/zero-literal-segments.js fails
+built-ins/Symbol/species/builtin-getter-name.js fails
+built-ins/TypedArray/from/arylk-get-length-error.js fails
+built-ins/TypedArray/from/arylk-to-length-error.js fails
+built-ins/TypedArray/from/iter-access-error.js fails
+built-ins/TypedArray/from/iter-invoke-error.js fails
+built-ins/TypedArray/from/iter-next-error.js fails
+built-ins/TypedArray/from/iter-next-value-error.js fails
+built-ins/TypedArray/from/length.js fails
+built-ins/TypedArray/from/name.js fails
+built-ins/TypedArray/from/prop-desc.js fails
+built-ins/TypedArray/prototype/constructor.js fails
+built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js fails
+built-ins/TypedArray/prototype/slice/bit-precision.js fails
+built-ins/TypedArray/prototype/sort/arraylength-internal.js fails
+built-ins/TypedArray/prototype/sort/comparefn-call-throws.js fails
+built-ins/TypedArray/prototype/sort/comparefn-calls.js fails
+built-ins/TypedArray/prototype/sort/detached-buffer-comparefn.js fails
+built-ins/TypedArray/prototype/sort/invoked-as-func.js fails
+built-ins/TypedArray/prototype/sort/invoked-as-method.js fails
+built-ins/TypedArray/prototype/sort/length.js fails
+built-ins/TypedArray/prototype/sort/name.js fails
+built-ins/TypedArray/prototype/sort/prop-desc.js fails
+built-ins/TypedArray/prototype/sort/return-same-instance.js fails
+built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js fails
+built-ins/TypedArray/prototype/sort/sorted-values-nan.js fails
+built-ins/TypedArray/prototype/sort/sorted-values.js fails
+built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length.js fails
+built-ins/TypedArrays/ctors/object-arg/as-generator-iterable-returns.js fails
+built-ins/TypedArrays/ctors/object-arg/iterator-not-callable-throws.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js fails
+built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js fails
+built-ins/TypedArrays/from/arylk-get-length-error.js fails
+built-ins/TypedArrays/from/arylk-to-length-error.js fails
+built-ins/TypedArrays/from/custom-ctor-returns-other-instance.js fails
+built-ins/TypedArrays/from/custom-ctor.js fails
+built-ins/TypedArrays/from/iter-access-error.js fails
+built-ins/TypedArrays/from/iter-invoke-error.js fails
+built-ins/TypedArrays/from/iter-next-error.js fails
+built-ins/TypedArrays/from/iter-next-value-error.js fails
+built-ins/TypedArrays/from/mapfn-abrupt-completion.js fails
+built-ins/TypedArrays/from/mapfn-arguments.js fails
+built-ins/TypedArrays/from/mapfn-this-with-thisarg.js fails
+built-ins/TypedArrays/from/mapfn-this-without-thisarg-non-strict.js sloppyFails
+built-ins/TypedArrays/from/mapfn-this-without-thisarg-strict.js strictFails
+built-ins/TypedArrays/from/nan-conversion.js fails
+built-ins/TypedArrays/from/new-instance-empty.js fails
+built-ins/TypedArrays/from/new-instance-from-ordinary-object.js fails
+built-ins/TypedArrays/from/new-instance-from-sparse-array.js fails
+built-ins/TypedArrays/from/new-instance-from-zero.js fails
+built-ins/TypedArrays/from/new-instance-using-custom-ctor.js fails
+built-ins/TypedArrays/from/new-instance-with-mapfn.js fails
+built-ins/TypedArrays/from/new-instance-without-mapfn.js fails
+built-ins/TypedArrays/from/property-abrupt-completion.js fails
+built-ins/TypedArrays/from/set-value-abrupt-completion.js fails
+built-ins/TypedArrays/internals/Get/key-is-not-integer.js fails
+built-ins/TypedArrays/internals/Get/key-is-not-minus-zero.js fails
+built-ins/TypedArrays/internals/Get/key-is-out-of-bounds.js fails
+built-ins/TypedArrays/internals/Set/detached-buffer.js fails
+built-ins/TypedArrays/internals/Set/tonumber-value-throws.js strictFails
+built-ins/global/global-object.js fails
+built-ins/global/property-descriptor.js fails
+built-ins/isFinite/toprimitive-not-callable-throws.js fails
+built-ins/isNaN/toprimitive-not-callable-throws.js fails
+language/computed-property-names/class/static/method-number.js fails
+language/computed-property-names/class/static/method-string.js fails
+language/computed-property-names/class/static/method-symbol.js fails
+language/eval-code/direct/new.target.js fails
+language/eval-code/direct/new.target-arrow.js fails
+language/eval-code/direct/non-definable-function-with-function.js sloppyFails
+language/eval-code/direct/non-definable-function-with-variable.js sloppyFails
+language/eval-code/direct/non-definable-global-function.js sloppyFails
+language/eval-code/direct/non-definable-global-generator.js sloppyFails
+language/eval-code/direct/super-call-arrow.js fails
+language/eval-code/direct/super-call-fn.js fails
+language/eval-code/direct/super-call-method.js fails
+language/eval-code/direct/super-call.js fails
+language/eval-code/direct/super-prop-arrow.js fails
+language/eval-code/direct/super-prop-dot-no-home.js fails
+language/eval-code/direct/super-prop-expr-no-home-no-eval.js fails
+language/eval-code/direct/super-prop-expr-no-home.js fails
+language/eval-code/direct/super-prop.js fails
+language/eval-code/direct/this-value-func-strict-source.js sloppyFails
+language/eval-code/direct/var-env-func-init-global-update-configurable.js sloppyFails
+language/eval-code/direct/var-env-global-lex-non-strict.js sloppyFails
+language/eval-code/direct/var-env-lower-lex-catch-non-strict.js sloppyFails
+language/eval-code/direct/var-env-lower-lex-non-strict.js sloppyFails
+language/eval-code/indirect/always-non-strict.js strictFails
+language/eval-code/indirect/new.target.js fails
+language/eval-code/indirect/non-definable-function-with-function.js sloppyFails
+language/eval-code/indirect/non-definable-function-with-variable.js sloppyFails
+language/eval-code/indirect/non-definable-global-function.js fails
+language/eval-code/indirect/non-definable-global-generator.js fails
+language/eval-code/indirect/super-call.js fails
+language/eval-code/indirect/super-prop.js fails
+language/eval-code/indirect/this-value-func.js strictFails
+language/eval-code/indirect/var-env-func-init-global-new.js strictFails
+language/eval-code/indirect/var-env-func-init-global-update-configurable.js fails
+language/eval-code/indirect/var-env-func-init-multi.js strictFails
+language/eval-code/indirect/var-env-func-non-strict.js strictFails
+language/eval-code/indirect/var-env-global-lex-non-strict.js fails
+language/eval-code/indirect/var-env-var-init-global-exstng.js strictFails
+language/eval-code/indirect/var-env-var-init-global-new.js strictFails
+language/eval-code/indirect/var-env-var-non-strict.js strictFails
+language/expressions/arrow-function/dflt-params-ref-later.js fails
+language/expressions/arrow-function/dflt-params-ref-self.js fails
+language/expressions/arrow-function/lexical-super-call-from-within-constructor.js fails
+language/expressions/arrow-function/lexical-supercall-from-immediately-invoked-arrow.js fails
+language/expressions/arrow-function/scope-body-lex-distinct.js sloppyFails
+language/expressions/arrow-function/scope-param-elem-var-close.js sloppyFails
+language/expressions/arrow-function/scope-param-elem-var-open.js sloppyFails
+language/expressions/arrow-function/scope-param-rest-elem-var-close.js sloppyFails
+language/expressions/arrow-function/scope-param-rest-elem-var-open.js sloppyFails
+language/expressions/arrow-function/scope-paramsbody-var-open.js fails
+language/expressions/assignment/S11.13.1_A5_T1.js sloppyFails
+language/expressions/assignment/S11.13.1_A5_T2.js sloppyFails
+language/expressions/assignment/S11.13.1_A5_T3.js sloppyFails
+language/expressions/assignment/S11.13.1_A5_T4.js sloppyFails
+language/expressions/assignment/S11.13.1_A5_T5.js fails
+language/expressions/assignment/S11.13.1_A6_T1.js sloppyFails
+language/expressions/assignment/S11.13.1_A6_T2.js sloppyFails
+language/expressions/assignment/S11.13.1_A6_T3.js sloppyFails
+language/expressions/assignment/S11.13.1_A7_T1.js fails
+language/expressions/assignment/S11.13.1_A7_T2.js fails
+language/expressions/assignment/S11.13.1_A7_T3.js fails
+language/expressions/assignment/destructuring/iterator-destructuring-property-reference-target-evaluation-order.js fails
+language/expressions/assignment/destructuring/keyed-destructuring-property-reference-target-evaluation-order.js fails
+language/expressions/assignment/dstr-array-elem-iter-rtrn-close-err.js fails
+language/expressions/assignment/dstr-array-elem-iter-thrw-close-err.js fails
+language/expressions/assignment/dstr-array-elem-iter-thrw-close.js fails
+language/expressions/assignment/dstr-array-elem-put-let.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-list-thrw-close-err.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-list-thrw-close.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-rest-rtrn-close-err.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-rest-rtrn-close-null.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-rest-rtrn-close.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-rest-thrw-close-err.js fails
+language/expressions/assignment/dstr-array-elem-trlg-iter-rest-thrw-close.js fails
+language/expressions/assignment/dstr-array-rest-iter-rtrn-close-err.js fails
+language/expressions/assignment/dstr-array-rest-iter-rtrn-close-null.js fails
+language/expressions/assignment/dstr-array-rest-iter-rtrn-close.js fails
+language/expressions/assignment/dstr-array-rest-iter-thrw-close-err.js fails
+language/expressions/assignment/dstr-array-rest-iter-thrw-close.js fails
+language/expressions/assignment/dstr-array-rest-lref-err.js fails
+language/expressions/assignment/dstr-array-rest-put-let.js fails
+language/expressions/assignment/dstr-obj-id-put-let.js fails
+language/expressions/assignment/dstr-obj-prop-put-let.js fails
+language/expressions/assignment/fn-name-lhs-cover.js fails
+language/expressions/assignment/fn-name-lhs-member.js fails
+language/expressions/async-function/expression-returns-promise.js fails
+language/expressions/async-function/syntax-expression-is-PrimaryExpression.js fails
+language/expressions/await/await-BindingIdentifier-in-global.js fails
+language/expressions/await/await-in-nested-function.js fails
+language/expressions/await/await-in-nested-generator.js fails
+language/expressions/await/await-throws-rejections.js fails
+language/expressions/call/11.2.3-3_3.js fails
+language/expressions/call/eval-spread-empty-leading.js fails
+language/expressions/call/eval-spread-empty-trailing.js fails
+language/expressions/call/eval-spread.js fails
+language/expressions/call/scope-lex-open.js fails
+language/expressions/call/tco-call-args.js strictFails
+language/expressions/call/tco-member-args.js strictFails
+language/expressions/call/tco-non-eval-function-dynamic.js sloppyFails
+language/expressions/call/tco-non-eval-function.js sloppyFails
+language/expressions/call/tco-non-eval-global.js sloppyFails
+language/expressions/call/tco-non-eval-with.js sloppyFails
+language/expressions/class/gen-meth-dflt-params-ref-later.js fails
+language/expressions/class/gen-meth-dflt-params-ref-self.js fails
+language/expressions/class/gen-meth-static-dflt-params-ref-later.js fails
+language/expressions/class/gen-meth-static-dflt-params-ref-self.js fails
+language/expressions/class/meth-dflt-params-ref-later.js fails
+language/expressions/class/meth-dflt-params-ref-self.js fails
+language/expressions/class/meth-static-dflt-params-ref-later.js fails
+language/expressions/class/meth-static-dflt-params-ref-self.js fails
+language/expressions/class/name.js fails
+language/expressions/class/scope-gen-meth-paramsbody-var-open.js fails
+language/expressions/class/scope-meth-paramsbody-var-open.js fails
+language/expressions/class/scope-setter-paramsbody-var-open.js fails
+language/expressions/class/scope-static-gen-meth-paramsbody-var-open.js fails
+language/expressions/class/scope-static-meth-paramsbody-var-open.js fails
+language/expressions/class/scope-static-setter-paramsbody-var-open.js fails
+language/expressions/comma/tco-final.js strictFails
+language/expressions/compound-assignment/S11.13.2_A5.10_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.10_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.10_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.10_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.10_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.11_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.11_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.11_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.11_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.11_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.1_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.1_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.1_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.1_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.1_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.2_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.2_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.2_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.2_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.2_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.3_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.3_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.3_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.3_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.3_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.4_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.4_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.4_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.4_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.4_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.5_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.5_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.5_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.5_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.5_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.6_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.6_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.6_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.6_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.6_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.7_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.7_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.7_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.7_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.7_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.8_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.8_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.8_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.8_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.8_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A5.9_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.9_T2.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.9_T3.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.9_T4.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A5.9_T5.js fails
+language/expressions/compound-assignment/S11.13.2_A6.10_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.11_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.1_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.2_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.3_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.4_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.5_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.6_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.7_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.8_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A6.9_T1.js sloppyFails
+language/expressions/compound-assignment/S11.13.2_A7.10_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.11_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.1_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.2_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.3_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.4_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.5_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.6_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.7_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.8_T4.js fails
+language/expressions/compound-assignment/S11.13.2_A7.9_T4.js fails
+language/expressions/delete/super-property.js fails
+language/expressions/conditional/tco-cond.js strictFails
+language/expressions/conditional/tco-pos.js strictFails
+language/expressions/function/arguments-with-arguments-fn.js sloppyFails
+language/expressions/function/arguments-with-arguments-lex.js sloppyFails
+language/expressions/function/dflt-params-ref-later.js fails
+language/expressions/function/dflt-params-ref-self.js fails
+language/expressions/function/name.js fails
+language/expressions/function/param-dflt-yield-non-strict.js sloppyFails
+language/expressions/function/scope-body-lex-distinct.js sloppyFails
+language/expressions/function/scope-name-var-open-non-strict.js sloppyFails
+language/expressions/function/scope-name-var-open-strict.js strictFails
+language/expressions/function/scope-param-elem-var-close.js sloppyFails
+language/expressions/function/scope-param-elem-var-open.js sloppyFails
+language/expressions/function/scope-param-rest-elem-var-close.js sloppyFails
+language/expressions/function/scope-param-rest-elem-var-open.js sloppyFails
+language/expressions/function/scope-paramsbody-var-open.js fails
+language/expressions/generators/arguments-with-arguments-fn.js sloppyFails
+language/expressions/generators/arguments-with-arguments-lex.js sloppyFails
+language/expressions/generators/default-proto.js fails
+language/expressions/generators/dflt-params-ref-later.js fails
+language/expressions/generators/dflt-params-ref-self.js fails
+language/expressions/generators/name.js fails
+language/expressions/generators/named-yield-identifier-non-strict.js sloppyFails
+language/expressions/generators/scope-body-lex-distinct.js sloppyFails
+language/expressions/generators/scope-name-var-open-non-strict.js sloppyFails
+language/expressions/generators/scope-name-var-open-strict.js strictFails
+language/expressions/generators/scope-param-elem-var-close.js sloppyFails
+language/expressions/generators/scope-param-elem-var-open.js sloppyFails
+language/expressions/generators/scope-param-rest-elem-var-close.js sloppyFails
+language/expressions/generators/scope-param-rest-elem-var-open.js sloppyFails
+language/expressions/generators/scope-paramsbody-var-open.js fails
+language/expressions/generators/yield-as-function-expression-binding-identifier.js sloppyFails
+language/expressions/generators/yield-as-identifier-in-nested-function.js sloppyFails
+language/expressions/generators/yield-as-literal-property-name.js fails
+language/expressions/generators/yield-as-property-name.js fails
+language/expressions/generators/yield-identifier-non-strict.js sloppyFails
+language/expressions/logical-and/tco-right.js strictFails
+language/expressions/logical-or/tco-right.js strictFails
+language/expressions/object/let-non-strict-access.js sloppyFails
+language/expressions/object/let-non-strict-syntax.js sloppyFails
+language/expressions/object/method-definition/gen-meth-dflt-params-ref-later.js fails
+language/expressions/object/method-definition/gen-meth-dflt-params-ref-self.js fails
+language/expressions/object/method-definition/gen-yield-identifier-non-strict.js sloppyFails
+language/expressions/object/method-definition/meth-dflt-params-ref-later.js fails
+language/expressions/object/method-definition/meth-dflt-params-ref-self.js fails
+language/expressions/object/method-definition/object-method-returns-promise.js fails
+language/expressions/object/method-definition/yield-as-function-expression-binding-identifier.js sloppyFails
+language/expressions/object/method-definition/yield-as-identifier-in-nested-function.js sloppyFails
+language/expressions/object/method-definition/yield-as-literal-property-name.js fails
+language/expressions/object/method-definition/yield-as-property-name.js fails
+language/expressions/object/properties-names-eval-arguments.js strictFails
+language/expressions/object/scope-gen-meth-body-lex-distinct.js sloppyFails
+language/expressions/object/scope-gen-meth-param-elem-var-close.js sloppyFails
+language/expressions/object/scope-gen-meth-param-elem-var-open.js sloppyFails
+language/expressions/object/scope-gen-meth-param-rest-elem-var-close.js sloppyFails
+language/expressions/object/scope-gen-meth-param-rest-elem-var-open.js sloppyFails
+language/expressions/object/scope-gen-meth-paramsbody-var-open.js fails
+language/expressions/object/scope-getter-body-lex-distinc.js sloppyFails
+language/expressions/object/scope-meth-body-lex-distinct.js sloppyFails
+language/expressions/object/scope-meth-param-elem-var-close.js sloppyFails
+language/expressions/object/scope-meth-param-elem-var-open.js sloppyFails
+language/expressions/object/scope-meth-param-rest-elem-var-close.js sloppyFails
+language/expressions/object/scope-meth-param-rest-elem-var-open.js sloppyFails
+language/expressions/object/scope-meth-paramsbody-var-open.js fails
+language/expressions/object/scope-setter-body-lex-distinc.js sloppyFails
+language/expressions/object/scope-setter-paramsbody-var-open.js fails
+language/expressions/postfix-decrement/S11.3.2_A5_T1.js sloppyFails
+language/expressions/postfix-decrement/S11.3.2_A5_T2.js sloppyFails
+language/expressions/postfix-decrement/S11.3.2_A5_T3.js sloppyFails
+language/expressions/postfix-decrement/S11.3.2_A5_T4.js sloppyFails
+language/expressions/postfix-decrement/S11.3.2_A5_T5.js fails
+language/expressions/postfix-decrement/S11.3.2_A6_T3.js fails
+language/expressions/postfix-increment/S11.3.1_A5_T1.js sloppyFails
+language/expressions/postfix-increment/S11.3.1_A5_T2.js sloppyFails
+language/expressions/postfix-increment/S11.3.1_A5_T3.js sloppyFails
+language/expressions/postfix-increment/S11.3.1_A5_T4.js sloppyFails
+language/expressions/postfix-increment/S11.3.1_A5_T5.js fails
+language/expressions/postfix-increment/S11.3.1_A6_T3.js fails
+language/expressions/prefix-decrement/S11.4.5_A5_T1.js sloppyFails
+language/expressions/prefix-decrement/S11.4.5_A5_T2.js sloppyFails
+language/expressions/prefix-decrement/S11.4.5_A5_T3.js sloppyFails
+language/expressions/prefix-decrement/S11.4.5_A5_T4.js sloppyFails
+language/expressions/prefix-decrement/S11.4.5_A5_T5.js fails
+language/expressions/prefix-decrement/S11.4.5_A6_T3.js fails
+language/expressions/prefix-increment/S11.4.4_A5_T1.js sloppyFails
+language/expressions/prefix-increment/S11.4.4_A5_T2.js sloppyFails
+language/expressions/prefix-increment/S11.4.4_A5_T3.js sloppyFails
+language/expressions/prefix-increment/S11.4.4_A5_T4.js sloppyFails
+language/expressions/prefix-increment/S11.4.4_A5_T5.js fails
+language/expressions/prefix-increment/S11.4.4_A6_T3.js fails
+language/expressions/tagged-template/cache-different-functions-same-site.js fails
+language/expressions/tagged-template/cache-eval-inner-function.js fails
+language/expressions/tagged-template/cache-same-site-top-level.js fails
+language/expressions/tagged-template/cache-same-site.js fails
+language/expressions/tagged-template/invalid-escape-sequences.js fails
+language/expressions/tagged-template/tco-call.js strictFails
+language/expressions/tagged-template/tco-member.js strictFails
+language/expressions/tagged-template/template-object-frozen-non-strict.js sloppyFails
+language/expressions/tagged-template/template-object-frozen-strict.js strictFails
+language/expressions/tagged-template/template-object.js fails
+language/expressions/tco-pos.js strictFails
+language/expressions/template-literal/tv-character-escape-sequence.js fails
+language/expressions/template-literal/tv-hex-escape-sequence.js fails
+language/expressions/template-literal/tv-line-continuation.js fails
+language/expressions/template-literal/tv-line-terminator-sequence.js fails
+language/expressions/template-literal/tv-no-substitution.js fails
+language/expressions/template-literal/tv-null-character-escape-sequence.js fails
+language/expressions/template-literal/tv-template-character.js fails
+language/expressions/template-literal/tv-template-characters.js fails
+language/expressions/template-literal/tv-template-head.js fails
+language/expressions/template-literal/tv-template-middle.js fails
+language/expressions/template-literal/tv-template-tail.js fails
+language/expressions/template-literal/tv-utf16-escape-sequence.js fails
+language/expressions/template-literal/tv-zwnbsp.js fails
+language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
+language/function-code/each-param-has-own-scope.js sloppyFails
+language/function-code/eval-param-env-with-computed-key.js sloppyFails
+language/function-code/eval-param-env-with-prop-initializer.js sloppyFails
+language/global-code/decl-lex-restricted-global.js fails
+language/global-code/script-decl-func-dups.js fails
+language/global-code/script-decl-func.js fails
+language/global-code/script-decl-lex-deletion.js sloppyFails
+language/global-code/script-decl-lex-lex.js fails
+language/global-code/script-decl-lex-restricted-global.js fails
+language/global-code/script-decl-lex-var.js fails
+language/global-code/script-decl-lex.js fails
+language/global-code/script-decl-var-collision.js fails
+language/global-code/script-decl-var.js fails
+language/identifiers/other_id_continue.js fails
+language/identifiers/other_id_start-escaped.js fails
+language/identifiers/other_id_start.js fails
+language/statements/async-function/cptn-decl.js fails
+language/statements/async-function/declaration-returns-promise.js fails
+language/statements/async-function/evaluation-body.js fails
+language/statements/async-function/syntax-declaration-line-terminators-allowed.js fails
+language/statements/block/tco-stmt-list.js strictFails
+language/statements/block/tco-stmt.js strictFails
+language/statements/class/constructor-inferred-observable-iteration.js fails
+language/statements/class/cptn-decl.js fails
+language/statements/class/definition/class-method-returns-promise.js fails
+language/statements/class/definition/getters-restricted-ids.js fails
+language/statements/class/definition/methods-gen-yield-as-literal-property-name.js fails
+language/statements/class/definition/methods-gen-yield-as-property-name.js fails
+language/statements/class/definition/methods-named-eval-arguments.js fails
+language/statements/class/definition/prototype-property.js fails
+language/statements/class/definition/setters-prop-desc.js fails
+language/statements/class/definition/setters-restricted-ids.js fails
+language/statements/class/definition/this-access-restriction-2.js fails
+language/statements/class/definition/this-access-restriction.js fails
+language/statements/class/definition/this-check-ordering.js fails
+language/statements/class/gen-meth-dflt-params-ref-later.js fails
+language/statements/class/gen-meth-dflt-params-ref-self.js fails
+language/statements/class/gen-meth-static-dflt-params-ref-later.js fails
+language/statements/class/gen-meth-static-dflt-params-ref-self.js fails
+language/statements/class/meth-dflt-params-ref-later.js fails
+language/statements/class/meth-dflt-params-ref-self.js fails
+language/statements/class/meth-static-dflt-params-ref-later.js fails
+language/statements/class/meth-static-dflt-params-ref-self.js fails
+language/statements/class/scope-gen-meth-paramsbody-var-open.js fails
+language/statements/class/scope-meth-paramsbody-var-open.js fails
+language/statements/class/scope-setter-paramsbody-var-open.js fails
+language/statements/class/scope-static-gen-meth-paramsbody-var-open.js fails
+language/statements/class/scope-static-meth-paramsbody-var-open.js fails
+language/statements/class/scope-static-setter-paramsbody-var-open.js fails
+language/statements/class/subclass/bound-function.js fails
+language/statements/class/subclass/builtin-objects/Promise/regular-subclassing.js fails
+language/statements/class/subclass/builtin-objects/Promise/super-must-be-called.js fails
+language/statements/class/subclass/default-constructor-spread-override.js fails
+language/statements/do-while/tco-body.js strictFails
+language/statements/for-in/head-lhs-let.js sloppyFails
+language/statements/for-in/head-var-bound-names-let.js sloppyFails
+language/statements/for-in/identifier-let-allowed-as-lefthandside-expression-not-strict.js sloppyFails
+language/statements/for-of/dstr-array-elem-iter-rtrn-close-err.js fails
+language/statements/for-of/dstr-array-elem-iter-thrw-close-err.js fails
+language/statements/for-of/dstr-array-elem-iter-thrw-close.js fails
+language/statements/for-of/dstr-array-elem-put-let.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-list-thrw-close-err.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-list-thrw-close.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-rest-rtrn-close-err.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-rest-rtrn-close-null.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-rest-rtrn-close.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-rest-thrw-close-err.js fails
+language/statements/for-of/dstr-array-elem-trlg-iter-rest-thrw-close.js fails
+language/statements/for-of/dstr-array-rest-iter-rtrn-close-err.js fails
+language/statements/for-of/dstr-array-rest-iter-rtrn-close-null.js fails
+language/statements/for-of/dstr-array-rest-iter-rtrn-close.js fails
+language/statements/for-of/dstr-array-rest-iter-thrw-close-err.js fails
+language/statements/for-of/dstr-array-rest-iter-thrw-close.js fails
+language/statements/for-of/dstr-array-rest-lref-err.js fails
+language/statements/for-of/dstr-array-rest-put-let.js fails
+language/statements/for-of/dstr-obj-id-put-let.js fails
+language/statements/for-of/dstr-obj-prop-put-let.js fails
+language/statements/for-of/head-var-bound-names-let.js sloppyFails
+language/statements/for-of/iterator-next-reference.js fails
+language/statements/for/head-lhs-let.js sloppyFails
+language/statements/for/scope-body-lex-open.js fails
+language/statements/for/tco-const-body.js strictFails
+language/statements/for/tco-let-body.js strictFails
+language/statements/for/tco-lhs-body.js strictFails
+language/statements/for/tco-var-body.js strictFails
+language/statements/function/13.2-30-s.js fails
+language/statements/function/S13_A15_T4.js sloppyFails
+language/statements/function/arguments-with-arguments-fn.js sloppyFails
+language/statements/function/arguments-with-arguments-lex.js sloppyFails
+language/statements/function/dflt-params-ref-later.js fails
+language/statements/function/dflt-params-ref-self.js fails
+language/statements/function/param-dflt-yield-non-strict.js sloppyFails
+language/statements/function/scope-body-lex-distinct.js sloppyFails
+language/statements/function/scope-param-elem-var-close.js sloppyFails
+language/statements/function/scope-param-elem-var-open.js sloppyFails
+language/statements/function/scope-param-rest-elem-var-close.js sloppyFails
+language/statements/function/scope-param-rest-elem-var-open.js sloppyFails
+language/statements/function/scope-paramsbody-var-open.js fails
+language/statements/generators/arguments-with-arguments-fn.js sloppyFails
+language/statements/generators/arguments-with-arguments-lex.js sloppyFails
+language/statements/generators/default-proto.js fails
+language/statements/generators/dflt-params-ref-later.js fails
+language/statements/generators/dflt-params-ref-self.js fails
+language/statements/generators/scope-body-lex-distinct.js sloppyFails
+language/statements/generators/scope-param-elem-var-close.js sloppyFails
+language/statements/generators/scope-param-elem-var-open.js sloppyFails
+language/statements/generators/scope-param-rest-elem-var-close.js sloppyFails
+language/statements/generators/scope-param-rest-elem-var-open.js sloppyFails
+language/statements/generators/scope-paramsbody-var-open.js fails
+language/statements/generators/yield-as-function-expression-binding-identifier.js sloppyFails
+language/statements/generators/yield-as-identifier-in-nested-function.js sloppyFails
+language/statements/generators/yield-as-literal-property-name.js fails
+language/statements/generators/yield-as-property-name.js fails
+language/statements/generators/yield-identifier-non-strict.js sloppyFails
+language/statements/if/tco-else-body.js strictFails
+language/statements/if/tco-if-body.js strictFails
+language/statements/labeled/tco.js strictFails
+language/statements/let/block-local-closure-set-before-initialization.js fails
+language/statements/let/function-local-closure-set-before-initialization.js fails
+language/statements/let/global-closure-set-before-initialization.js fails
+language/statements/return/tco.js strictFails
+language/statements/switch/tco-case-body-dflt.js strictFails
+language/statements/switch/tco-case-body.js strictFails
+language/statements/switch/tco-dftl-body.js strictFails
+language/statements/throw/S12.13_A2_T6.js strictFails
+language/statements/try/S12.14_A18_T6.js strictFails
+language/statements/try/scope-catch-block-lex-open.js fails
+language/statements/try/tco-catch-finally.js strictFails
+language/statements/try/tco-catch.js strictFails
+language/statements/try/tco-finally.js strictFails
+language/statements/variable/binding-resolution.js sloppyFails
+language/statements/while/tco-body.js strictFails
+language/statements/with/unscopables-inc-dec.js sloppyFails
+language/types/reference/put-value-prop-base-primitive.js strictFails
diff --git a/tests/auto/qml/ecmascripttests/ecmascripttests.pro b/tests/auto/qml/ecmascripttests/ecmascripttests.pro
index 6d3ee12307..9c09ee701e 100644
--- a/tests/auto/qml/ecmascripttests/ecmascripttests.pro
+++ b/tests/auto/qml/ecmascripttests/ecmascripttests.pro
@@ -1,20 +1,13 @@
-CONFIG += testcase
-TARGET = tst_ecmascripttests
-QT += testlib
-macos:CONFIG -= app_bundle
-SOURCES += tst_ecmascripttests.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-TESTSCRIPT=$$PWD/test262.py
-isEmpty(V4CMD): V4CMD = qmljs
+TEMPLATE = subdirs
+SUBDIRS = testcase.pro qjstest
checkjittarget.target = check-jit
-checkjittarget.commands = python $$TESTSCRIPT --command=$$V4CMD --parallel --with-test-expectations --update-expectations
+checkjittarget.commands = qjstest --jit --parallel --with-test-expectations --update-expectations
checkjittarget.depends = all
QMAKE_EXTRA_TARGETS += checkjittarget
checkmothtarget.target = check-interpreter
-checkmothtarget.commands = python $$TESTSCRIPT --command=\"$$V4CMD --interpret\" --parallel --with-test-expectations
+checkmothtarget.commands = qjstest --interpret --parallel --with-test-expectations
checkmothtarget.depends = all
QMAKE_EXTRA_TARGETS += checkmothtarget
diff --git a/tests/auto/qml/ecmascripttests/qjstest/main.cpp b/tests/auto/qml/ecmascripttests/qjstest/main.cpp
new file mode 100644
index 0000000000..4a3541d892
--- /dev/null
+++ b/tests/auto/qml/ecmascripttests/qjstest/main.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the V4VM module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QJSEngine>
+#include <QCoreApplication>
+#include <QCommandLineParser>
+#include <qdebug.h>
+#include <stdlib.h>
+
+#include "test262runner.h"
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption verbose("verbose", "Verbose output");
+ parser.addOption(verbose);
+ QCommandLineOption commandOption("command", "Javascript command line interpreter", "command");
+ parser.addOption(commandOption);
+ QCommandLineOption testDir("tests", "path to the tests", "tests", "test262");
+ parser.addOption(testDir);
+ QCommandLineOption cat("cat", "Print packaged test code that would be run");
+ parser.addOption(cat);
+ QCommandLineOption parallel("parallel", "Run tests in parallel");
+ parser.addOption(parallel);
+ QCommandLineOption jit("jit", "JIT all code");
+ parser.addOption(jit);
+ QCommandLineOption bytecode("interpret", "Run using the bytecode interpreter");
+ parser.addOption(bytecode);
+ QCommandLineOption withExpectations("with-test-expectations", "Parse TestExpectations to deal with known failures");
+ parser.addOption(withExpectations);
+ QCommandLineOption updateExpectations("update-expectations", "Update TestExpectations to remove unexepected passes");
+ parser.addOption(updateExpectations);
+ QCommandLineOption writeExpectations("write-expectations", "Generate a new TestExpectations file based on the results of the run");
+ parser.addOption(writeExpectations);
+ parser.addPositionalArgument("[filter]", "Only run tests that contain filter in their name");
+
+ parser.process(app);
+
+ Test262Runner testRunner(parser.value(commandOption), parser.value(testDir));
+
+ QStringList otherArgs = parser.positionalArguments();
+ if (otherArgs.size() > 1) {
+ qWarning() << "too many arguments";
+ return 1;
+ } else if (otherArgs.size()) {
+ testRunner.setFilter(otherArgs.at(0));
+ }
+
+ if (parser.isSet(cat)) {
+ testRunner.cat();
+ return 0;
+ }
+
+ if (parser.isSet(updateExpectations) && parser.isSet(writeExpectations)) {
+ qWarning() << "Can only specify one of --update-expectations and --write-expectations.";
+ exit(1);
+ }
+
+ if (parser.isSet(jit) && parser.isSet(bytecode)) {
+ qWarning() << "Can only specify one of --jit and --interpret.";
+ exit(1);
+ }
+
+ int flags = 0;
+ if (parser.isSet(verbose))
+ flags |= Test262Runner::Verbose;
+ if (parser.isSet(parallel))
+ flags |= Test262Runner::Parallel;
+ if (parser.isSet(jit))
+ flags |= Test262Runner::ForceJIT;
+ if (parser.isSet(bytecode))
+ flags |= Test262Runner::ForceBytecode;
+ if (parser.isSet(withExpectations))
+ flags |= Test262Runner::WithTestExpectations;
+ if (parser.isSet(updateExpectations))
+ flags |= Test262Runner::UpdateTestExpectations;
+ if (parser.isSet(writeExpectations))
+ flags |= Test262Runner::WriteTestExpectations;
+ testRunner.setFlags(flags);
+
+ if (testRunner.run())
+ return EXIT_SUCCESS;
+ else
+ return EXIT_FAILURE;
+}
diff --git a/tests/auto/qml/ecmascripttests/qjstest/qjstest.pro b/tests/auto/qml/ecmascripttests/qjstest/qjstest.pro
new file mode 100644
index 0000000000..6dec5f8f23
--- /dev/null
+++ b/tests/auto/qml/ecmascripttests/qjstest/qjstest.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = qjstest
+QT += qml-private
+INCLUDEPATH += .
+
+DEFINES += QT_DEPRECATED_WARNINGS
+
+HEADERS += test262runner.h
+SOURCES += main.cpp test262runner.cpp
+
+QMAKE_TARGET_DESCRIPTION = Javascript test runner
+
+load(qt_tool)
diff --git a/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
new file mode 100644
index 0000000000..a16f2414b0
--- /dev/null
+++ b/tests/auto/qml/ecmascripttests/qjstest/test262runner.cpp
@@ -0,0 +1,852 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the V4VM module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "test262runner.h"
+
+#include <qfile.h>
+#include <qdir.h>
+#include <qdiriterator.h>
+#include <qdebug.h>
+#include <qprocess.h>
+#include <qtemporaryfile.h>
+
+#include <private/qv4script_p.h>
+#include "private/qv4globalobject_p.h"
+#include "private/qqmlbuiltinfunctions_p.h"
+#include "private/qv4arraybuffer_p.h"
+
+#include "qrunnable.h"
+
+static const char *excludedFeatures[] = {
+ "BigInt",
+ "class-fields-public",
+ "class-fields-private",
+ "Promise.prototype.finally",
+ "async-iteration",
+ "Symbol.asyncIterator",
+ "object-rest",
+ "object-spread",
+ "optional-catch-binding",
+ "regexp-dotall",
+ "regexp-lookbehind",
+ "regexp-named-groups",
+ "regexp-unicode-property-escapes",
+ "Atomics",
+ "SharedArrayBuffer",
+ "Array.prototype.flatten",
+ "Array.prototype.flatMap",
+ "string-trimming",
+ "String.prototype.trimEnd",
+ "String.prototype.trimStart",
+ "numeric-separator-literal",
+
+ // optional features, not supported by us
+ "caller",
+ nullptr
+};
+
+static const char *excludedFilePatterns[] = {
+ "realm",
+ nullptr
+};
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+static ReturnedValue method_detachArrayBuffer(const FunctionObject *f, const Value *, const Value *argv, int argc)
+{
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+ Scoped<ArrayBuffer> a(scope, argv[0]);
+ if (!a)
+ return scope.engine->throwTypeError();
+
+ if (a->isShared())
+ return scope.engine->throwTypeError();
+
+ a->d()->detachArrayBuffer();
+
+ return Encode::null();
+}
+
+static void initD262(ExecutionEngine *e)
+{
+ Scope scope(e);
+ ScopedObject d262(scope, e->newObject());
+
+ d262->defineDefaultProperty(QStringLiteral("detachArrayBuffer"), method_detachArrayBuffer, 1);
+
+ ScopedString s(scope, e->newString(QStringLiteral("$262")));
+ e->globalObject->put(s, d262);
+}
+
+}
+
+QT_END_NAMESPACE
+
+Test262Runner::Test262Runner(const QString &command, const QString &dir)
+ : command(command), testDir(dir)
+{
+ if (testDir.endsWith(QLatin1Char('/')))
+ testDir = testDir.chopped(1);
+}
+
+Test262Runner::~Test262Runner()
+{
+ delete threadPool;
+}
+
+void Test262Runner::cat()
+{
+ if (!loadTests())
+ return;
+
+ if (testCases.size() != 1)
+ qWarning() << "test262 --cat: Ambiguous test case, using" << testCases.begin().key();
+ TestData data = getTestData(testCases.begin().value());
+ printf("%s", data.content.constData());
+}
+
+bool Test262Runner::run()
+{
+ if (!loadTests())
+ return false;
+
+ if (flags & Parallel) {
+ threadPool = new QThreadPool;
+ threadPool->setStackSize(16*1024*1024);
+ if (flags & Verbose)
+ qDebug() << "Running in parallel with" << QThread::idealThreadCount() << "threads.";
+ }
+
+ if (flags & ForceJIT)
+ qputenv("QV4_JIT_CALL_THRESHOLD", QByteArray("0"));
+ else if (flags & ForceBytecode)
+ qputenv("QV4_FORCE_INTERPRETER", QByteArray("1"));
+
+ if (flags & WithTestExpectations)
+ loadTestExpectations();
+
+ for (auto it = testCases.constBegin(); it != testCases.constEnd(); ++it) {
+ auto c = it.value();
+ if (!c.skipTestCase) {
+ int result = runSingleTest(c);
+ if (result == -2)
+ return false;
+ }
+ }
+
+ if (threadPool)
+ threadPool->waitForDone();
+
+ const bool testsOk = report();
+
+ if (flags & WriteTestExpectations)
+ writeTestExpectations();
+ else if (flags & UpdateTestExpectations)
+ updateTestExpectations();
+
+ return testsOk;
+}
+
+bool Test262Runner::report()
+{
+ qDebug() << "Test execution summary:";
+ qDebug() << " Executed" << testCases.size() << "test cases.";
+ QStringList crashes;
+ QStringList unexpectedFailures;
+ QStringList unexpectedPasses;
+ for (auto it = testCases.constBegin(); it != testCases.constEnd(); ++it) {
+ const auto c = it.value();
+ if (c.strictResult == c.strictExpectation && c.sloppyResult == c.sloppyExpectation)
+ continue;
+ auto report = [&] (TestCase::Result expected, TestCase::Result result, const char *s) {
+ if (result == TestCase::Crashes)
+ crashes << (it.key() + " crashed in " + s + " mode");
+ if (result == TestCase::Fails && expected == TestCase::Passes)
+ unexpectedFailures << (it.key() + " failed in " + s + " mode");
+ if (result == TestCase::Passes && expected == TestCase::Fails)
+ unexpectedPasses << (it.key() + " unexpectedly passed in " + s + " mode");
+ };
+ report(c.strictExpectation, c.strictResult, "strict");
+ report(c.sloppyExpectation, c.sloppyResult, "sloppy");
+ }
+ if (!crashes.isEmpty()) {
+ qDebug() << " Encountered" << crashes.size() << "crashes in the following files:";
+ for (const QString &f : qAsConst(crashes))
+ qDebug() << " " << f;
+ }
+ if (!unexpectedFailures.isEmpty()) {
+ qDebug() << " Encountered" << unexpectedFailures.size() << "unexpected failures in the following files:";
+ for (const QString &f : qAsConst(unexpectedFailures))
+ qDebug() << " " << f;
+ }
+ if (!unexpectedPasses.isEmpty()) {
+ qDebug() << " Encountered" << unexpectedPasses.size() << "unexpected passes in the following files:";
+ for (const QString &f : qAsConst(unexpectedPasses))
+ qDebug() << " " << f;
+ }
+ return crashes.isEmpty() && unexpectedFailures.isEmpty() && unexpectedPasses.isEmpty();
+}
+
+bool Test262Runner::loadTests()
+{
+ QDir dir(testDir + "/test");
+ if (!dir.exists()) {
+ qWarning() << "Could not load tests," << dir.path() << "does not exist.";
+ return false;
+ }
+
+ QString annexB = "annexB";
+ QString harness = "harness";
+ QString intl402 = "intl402";
+
+ int pathlen = dir.path().length() + 1;
+ QDirIterator it(dir, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ QString file = it.next().mid(pathlen);
+ if (!file.endsWith(".js"))
+ continue;
+ if (file.endsWith("_FIXTURE.js"))
+ continue;
+ if (!filter.isEmpty() && !file.contains(filter))
+ continue;
+ if (file.startsWith(annexB) || file.startsWith(harness) || file.startsWith(intl402))
+ continue;
+ const char **excluded = excludedFilePatterns;
+ bool skip = false;
+ while (*excluded) {
+ if (file.contains(QLatin1String(*excluded)))
+ skip = true;
+ ++excluded;
+ }
+ if (skip)
+ continue;
+
+ testCases.insert(file, TestCase{ file });
+ }
+ if (testCases.isEmpty()) {
+ qWarning() << "No tests to run.";
+ return false;
+ }
+
+ return true;
+}
+
+
+struct TestExpectationLine {
+ TestExpectationLine(const QByteArray &line);
+ enum State {
+ Fails,
+ SloppyFails,
+ StrictFails,
+ Skip,
+ Passes
+ } state;
+ QString testCase;
+
+ QByteArray toLine() const;
+ void update(const TestCase &testCase);
+
+ static TestExpectationLine fromTestCase(const TestCase &testCase);
+private:
+ TestExpectationLine() = default;
+ static State stateFromTestCase(const TestCase &testCase);
+};
+
+TestExpectationLine::TestExpectationLine(const QByteArray &line)
+{
+ int space = line.indexOf(' ');
+
+ testCase = QString::fromUtf8(space > 0 ? line.left(space) : line);
+ if (!testCase.endsWith(".js"))
+ testCase += ".js";
+
+ state = Fails;
+ if (space < 0)
+ return;
+ QByteArray qualifier = line.mid(space + 1);
+ if (qualifier == "skip")
+ state = Skip;
+ else if (qualifier == "strictFails")
+ state = StrictFails;
+ else if (qualifier == "sloppyFails")
+ state = SloppyFails;
+ else if (qualifier == "fails")
+ state = Fails;
+ else
+ qWarning() << "illegal format in TestExpectations, line" << line;
+}
+
+QByteArray TestExpectationLine::toLine() const {
+ const char *res = nullptr;
+ switch (state) {
+ case Fails:
+ res = " fails\n";
+ break;
+ case SloppyFails:
+ res = " sloppyFails\n";
+ break;
+ case StrictFails:
+ res = " strictFails\n";
+ break;
+ case Skip:
+ res = " skip\n";
+ break;
+ case Passes:
+ // no need for an entry
+ return QByteArray();
+ }
+ QByteArray result = testCase.toUtf8() + res;
+ return result;
+}
+
+void TestExpectationLine::update(const TestCase &testCase)
+{
+ Q_ASSERT(testCase.test == this->testCase);
+
+ State resultState = stateFromTestCase(testCase);
+ switch (resultState) {
+ case Fails:
+ // no improvement, don't update
+ break;
+ case SloppyFails:
+ if (state == Fails)
+ state = SloppyFails;
+ else if (state == StrictFails)
+ // we have a regression in sloppy mode, but strict now passes
+ state = Passes;
+ break;
+ case StrictFails:
+ if (state == Fails)
+ state = StrictFails;
+ else if (state == SloppyFails)
+ // we have a regression in strict mode, but sloppy now passes
+ state = Passes;
+ break;
+ case Skip:
+ Q_ASSERT(state == Skip);
+ // nothing to do
+ break;
+ case Passes:
+ state = Passes;
+ }
+}
+
+TestExpectationLine TestExpectationLine::fromTestCase(const TestCase &testCase)
+{
+ TestExpectationLine l;
+ l.testCase = testCase.test;
+ l.state = stateFromTestCase(testCase);
+ return l;
+}
+
+TestExpectationLine::State TestExpectationLine::stateFromTestCase(const TestCase &testCase)
+{
+ // keep skipped tests
+ if (testCase.skipTestCase)
+ return Skip;
+
+ bool strictFails = (testCase.strictResult == TestCase::Crashes || testCase.strictResult == TestCase::Fails);
+ bool sloppyFails = (testCase.sloppyResult == TestCase::Crashes || testCase.sloppyResult == TestCase::Fails);
+ if (strictFails && sloppyFails)
+ return Fails;
+ if (strictFails)
+ return StrictFails;
+ if (sloppyFails)
+ return SloppyFails;
+ return Passes;
+}
+
+
+void Test262Runner::loadTestExpectations()
+{
+ QFile file("TestExpectations");
+ if (!file.open(QFile::ReadOnly)) {
+ qWarning() << "Could not open TestExpectations file.";
+ return;
+ }
+
+ int line = 0;
+ while (!file.atEnd()) {
+ ++line;
+ QByteArray line = file.readLine().trimmed();
+ if (line.startsWith('#') || line.isEmpty())
+ continue;
+ TestExpectationLine expectation(line);
+ if (!filter.isEmpty() && !expectation.testCase.contains(filter))
+ continue;
+
+ if (!testCases.contains(expectation.testCase))
+ qWarning() << "Unknown test case" << expectation.testCase << "in TestExpectations file.";
+ //qDebug() << "TestExpectations:" << expectation.testCase << expectation.state;
+ TestCase &s = testCases[expectation.testCase];
+ switch (expectation.state) {
+ case TestExpectationLine::Fails:
+ s.strictExpectation = TestCase::Fails;
+ s.sloppyExpectation = TestCase::Fails;
+ break;
+ case TestExpectationLine::SloppyFails:
+ s.strictExpectation = TestCase::Passes;
+ s.sloppyExpectation = TestCase::Fails;
+ break;
+ case TestExpectationLine::StrictFails:
+ s.strictExpectation = TestCase::Fails;
+ s.sloppyExpectation = TestCase::Passes;
+ break;
+ case TestExpectationLine::Skip:
+ s.skipTestCase = true;
+ break;
+ case TestExpectationLine::Passes:
+ Q_UNREACHABLE();
+ }
+ }
+}
+
+void Test262Runner::updateTestExpectations()
+{
+ QFile file("TestExpectations");
+ if (!file.open(QFile::ReadOnly)) {
+ qWarning() << "Could not open TestExpectations file.";
+ return;
+ }
+
+ QTemporaryFile updatedExpectations;
+ updatedExpectations.open();
+
+ int line = 0;
+ while (!file.atEnd()) {
+ ++line;
+ QByteArray originalLine = file.readLine();
+ QByteArray line = originalLine.trimmed();
+ if (line.startsWith('#') || line.isEmpty()) {
+ updatedExpectations.write(originalLine);
+ continue;
+ }
+
+ TestExpectationLine expectation(line);
+// qDebug() << "checking: " << expectation.testCase;
+ if (!testCases.contains(expectation.testCase)) {
+ updatedExpectations.write(originalLine);
+ continue;
+ }
+ const TestCase &testcase = testCases.value(expectation.testCase);
+ expectation.update(testcase);
+
+ line = expectation.toLine();
+// qDebug() << "updated line:" << line;
+ updatedExpectations.write(line);
+ }
+ file.close();
+ updatedExpectations.close();
+ file.remove();
+ qDebug() << updatedExpectations.fileName() << file.fileName();
+ updatedExpectations.copy(file.fileName());
+ qDebug() << "Updated TestExpectations file written!";
+}
+
+void Test262Runner::writeTestExpectations()
+{
+ QFile file("TestExpectations");
+
+ QTemporaryFile expectations;
+ expectations.open();
+
+ for (auto c : qAsConst(testCases)) {
+ TestExpectationLine line = TestExpectationLine::fromTestCase(c);
+ expectations.write(line.toLine());
+ }
+
+ expectations.close();
+ if (file.exists())
+ file.remove();
+ qDebug() << expectations.fileName() << file.fileName();
+ expectations.copy(file.fileName());
+ qDebug() << "new TestExpectations file written!";
+
+}
+
+static bool executeTest(const QByteArray &data, bool runAsModule = false, const QString &testCasePath = QString(), const QByteArray &harnessForModules = QByteArray())
+{
+ QString testData = QString::fromUtf8(data);
+
+ QV4::ExecutionEngine vm;
+
+ QV4::Scope scope(&vm);
+
+ QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
+ QV4::initD262(&vm);
+
+ if (runAsModule) {
+ const QUrl rootModuleUrl = QUrl::fromLocalFile(testCasePath);
+ // inject all modules with the harness
+ QVector<QUrl> modulesToLoad = { rootModuleUrl };
+ while (!modulesToLoad.isEmpty()) {
+ QUrl url = modulesToLoad.takeFirst();
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> module;
+
+ QFile f(url.toLocalFile());
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray content = harnessForModules + f.readAll();
+ module = vm.compileModule(url.toString(), QString::fromUtf8(content), QFileInfo(f).lastModified());
+ if (vm.hasException)
+ break;
+ vm.injectModule(module);
+ } else {
+ vm.throwError(QStringLiteral("Could not load module"));
+ break;
+ }
+
+ for (const QString &request: module->moduleRequests()) {
+ const QUrl absoluteRequest = module->finalUrl().resolved(QUrl(request));
+ if (!vm.modules.contains(absoluteRequest))
+ modulesToLoad << absoluteRequest;
+ }
+ }
+
+ if (!vm.hasException) {
+ if (auto rootModuleUnit = vm.loadModule(rootModuleUrl)) {
+ if (rootModuleUnit->instantiate(&vm))
+ rootModuleUnit->evaluate();
+ }
+ }
+ } else {
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+
+ QV4::Script script(ctx, QV4::Compiler::ContextType::Global, testData);
+ script.parse();
+
+ if (!vm.hasException)
+ script.run();
+ }
+ return !vm.hasException;
+}
+
+class SingleTest : public QRunnable
+{
+public:
+ SingleTest(Test262Runner *runner, const TestData &data)
+ : runner(runner), data(data)
+ {
+ command = runner->command;
+ }
+ void run();
+
+ void runExternalTest();
+
+ QString command;
+ Test262Runner *runner;
+ TestData data;
+};
+
+void SingleTest::run()
+{
+ if (!command.isEmpty()) {
+ runExternalTest();
+ return;
+ }
+
+ if (data.runInSloppyMode) {
+ bool ok = ::executeTest(data.content);
+ if (data.negative)
+ ok = !ok;
+
+ data.sloppyResult = ok ? TestCase::Passes : TestCase::Fails;
+ } else {
+ data.sloppyResult = TestCase::Skipped;
+ }
+ if (data.runInStrictMode) {
+ const QString testCasePath = QFileInfo(runner->testDir + "/test/" + data.test).absoluteFilePath();
+ QByteArray c = "'use strict';\n" + data.content;
+ bool ok = ::executeTest(c, data.runAsModuleCode, testCasePath, data.harness);
+ if (data.negative)
+ ok = !ok;
+
+ data.strictResult = ok ? TestCase::Passes : TestCase::Fails;
+ } else {
+ data.strictResult = TestCase::Skipped;
+ }
+ runner->addResult(data);
+}
+
+void SingleTest::runExternalTest()
+{
+ auto runTest = [=] (const char *header, TestCase::Result *result) {
+ QTemporaryFile tempFile;
+ tempFile.open();
+ tempFile.write(header);
+ tempFile.write(data.content);
+ tempFile.close();
+
+ QProcess process;
+// if (flags & Verbose)
+// process.setReadChannelMode(QProcess::ForwardedChannels);
+
+ process.start(command, QStringList(tempFile.fileName()));
+ if (!process.waitForFinished(-1) || process.error() == QProcess::FailedToStart) {
+ qWarning() << "Could not execute" << command;
+ *result = TestCase::Crashes;
+ }
+ if (process.exitStatus() != QProcess::NormalExit) {
+ *result = TestCase::Crashes;
+ }
+ bool ok = (process.exitCode() == EXIT_SUCCESS);
+ if (data.negative)
+ ok = !ok;
+ *result = ok ? TestCase::Passes : TestCase::Fails;
+ };
+
+ if (data.runInSloppyMode)
+ runTest("", &data.sloppyResult);
+ if (data.runInStrictMode)
+ runTest("'use strict';\n", &data.strictResult);
+
+ runner->addResult(data);
+}
+
+int Test262Runner::runSingleTest(TestCase testCase)
+{
+ TestData data = getTestData(testCase);
+// qDebug() << "starting test" << data.test;
+
+ if (data.isExcluded || data.async)
+ return 0;
+
+ if (threadPool) {
+ SingleTest *test = new SingleTest(this, data);
+ threadPool->start(test);
+ return 0;
+ }
+ SingleTest test(this, data);
+ test.run();
+ return 0;
+}
+
+void Test262Runner::addResult(TestCase result)
+{
+ {
+ QMutexLocker locker(&mutex);
+ Q_ASSERT(result.strictExpectation == testCases[result.test].strictExpectation);
+ Q_ASSERT(result.sloppyExpectation == testCases[result.test].sloppyExpectation);
+ testCases[result.test] = result;
+ }
+
+ if (!(flags & Verbose))
+ return;
+
+ QString test = result.test;
+ if (result.strictResult == TestCase::Skipped) {
+ ;
+ } else if (result.strictResult == TestCase::Crashes) {
+ qDebug() << "FAIL:" << test << "crashed in strict mode!";
+ } else if ((result.strictResult == TestCase::Fails) && (result.strictExpectation == TestCase::Fails)) {
+ qDebug() << "PASS:" << test << "failed in strict mode as expected";
+ } else if ((result.strictResult == TestCase::Passes) == (result.strictExpectation == TestCase::Passes)) {
+ qDebug() << "PASS:" << test << "passed in strict mode";
+ } else if (!(result.strictExpectation == TestCase::Fails)) {
+ qDebug() << "FAIL:" << test << "failed in strict mode";
+ } else {
+ qDebug() << "XPASS:" << test << "unexpectedly passed in strict mode";
+ }
+
+ if (result.sloppyResult == TestCase::Skipped) {
+ ;
+ } else if (result.sloppyResult == TestCase::Crashes) {
+ qDebug() << "FAIL:" << test << "crashed in sloppy mode!";
+ } else if ((result.sloppyResult == TestCase::Fails) && (result.sloppyExpectation == TestCase::Fails)) {
+ qDebug() << "PASS:" << test << "failed in sloppy mode as expected";
+ } else if ((result.sloppyResult == TestCase::Passes) == (result.sloppyExpectation == TestCase::Passes)) {
+ qDebug() << "PASS:" << test << "passed in sloppy mode";
+ } else if (!(result.sloppyExpectation == TestCase::Fails)) {
+ qDebug() << "FAIL:" << test << "failed in sloppy mode";
+ } else {
+ qDebug() << "XPASS:" << test << "unexpectedly passed in sloppy mode";
+ }
+}
+
+TestData Test262Runner::getTestData(const TestCase &testCase)
+{
+ QFile testFile(testDir + "/test/" + testCase.test);
+ if (!testFile.open(QFile::ReadOnly)) {
+ qWarning() << "wrong test file" << testCase.test;
+ exit(1);
+ }
+ QByteArray content = testFile.readAll();
+ content.replace(QByteArrayLiteral("\r\n"), "\n");
+
+// qDebug() << "parsing test file" << test;
+
+ TestData data(testCase);
+ parseYaml(content, &data);
+
+ data.harness += harness("assert.js");
+ data.harness += harness("sta.js");
+
+ for (QByteArray inc : qAsConst(data.includes)) {
+ inc = inc.trimmed();
+ data.harness += harness(inc);
+ }
+
+ if (data.async)
+ data.harness += harness("doneprintHandle.js");
+
+ data.content = data.harness + content;
+
+ return data;
+}
+
+struct YamlSection {
+ YamlSection(const QByteArray &yaml, const char *sectionName);
+
+ bool contains(const char *keyword) const;
+ QList<QByteArray> keywords() const;
+
+ QByteArray yaml;
+ int start = -1;
+ int length = 0;
+ bool shortSection = false;
+};
+
+YamlSection::YamlSection(const QByteArray &yaml, const char *sectionName)
+ : yaml(yaml)
+{
+ start = yaml.indexOf(sectionName);
+ if (start < 0)
+ return;
+ start += static_cast<int>(strlen(sectionName));
+ int end = yaml.indexOf('\n', start + 1);
+ if (end < 0)
+ end = yaml.length();
+
+ int s = yaml.indexOf('[', start);
+ if (s > 0 && s < end) {
+ shortSection = true;
+ start = s + 1;
+ end = yaml.indexOf(']', s);
+ } else {
+ while (end < yaml.size() - 1 && yaml.at(end + 1) == ' ')
+ end = yaml.indexOf('\n', end + 1);
+ }
+ length = end - start;
+}
+
+bool YamlSection::contains(const char *keyword) const
+{
+ if (start < 0)
+ return false;
+ int idx = yaml.indexOf(keyword, start);
+ if (idx >= start && idx < start + length)
+ return true;
+ return false;
+}
+
+QList<QByteArray> YamlSection::keywords() const
+{
+ if (start < 0)
+ return QList<QByteArray>();
+
+ QByteArray content = yaml.mid(start, length);
+ QList<QByteArray> keywords;
+ if (shortSection) {
+ keywords = content.split(',');
+ } else {
+ const QList<QByteArray> list = content.split('\n');
+ for (const QByteArray &l : list) {
+ int i = 0;
+ while (i < l.size() && (l.at(i) == ' ' || l.at(i) == '-'))
+ ++i;
+ QByteArray entry = l.mid(i);
+ if (!entry.isEmpty())
+ keywords.append(entry);
+ }
+ }
+// qDebug() << "keywords:" << keywords;
+ return keywords;
+}
+
+
+void Test262Runner::parseYaml(const QByteArray &content, TestData *data)
+{
+ int start = content.indexOf("/*---");
+ if (start < 0)
+ return;
+ start += sizeof("/*---");
+
+ int end = content.indexOf("---*/");
+ if (end < 0)
+ return;
+
+ QByteArray yaml = content.mid(start, end - start);
+
+ if (yaml.contains("negative:"))
+ data->negative = true;
+
+ YamlSection flags(yaml, "flags:");
+ data->runInSloppyMode = !flags.contains("onlyStrict");
+ data->runInStrictMode = !flags.contains("noStrict") && !flags.contains("raw");
+ data->runAsModuleCode = flags.contains("module");
+ data->async = flags.contains("async");
+
+ if (data->runAsModuleCode) {
+ data->runInStrictMode = true;
+ data->runInSloppyMode = false;
+ }
+
+ YamlSection includes(yaml, "includes:");
+ data->includes = includes.keywords();
+
+ YamlSection features = YamlSection(yaml, "features:");
+
+ const char **f = excludedFeatures;
+ while (*f) {
+ if (features.contains(*f)) {
+ data->isExcluded = true;
+ break;
+ }
+ ++f;
+ }
+
+// qDebug() << "Yaml:\n" << yaml;
+}
+
+QByteArray Test262Runner::harness(const QByteArray &name)
+{
+ if (harnessFiles.contains(name))
+ return harnessFiles.value(name);
+
+ QFile h(testDir + QLatin1String("/harness/") + name);
+ if (!h.open(QFile::ReadOnly)) {
+ qWarning() << "Illegal test harness file" << name;
+ exit(1);
+ }
+
+ QByteArray content = h.readAll();
+ harnessFiles.insert(name, content);
+ return content;
+}
diff --git a/tests/auto/qml/ecmascripttests/qjstest/test262runner.h b/tests/auto/qml/ecmascripttests/qjstest/test262runner.h
new file mode 100644
index 0000000000..e20d4a7bdd
--- /dev/null
+++ b/tests/auto/qml/ecmascripttests/qjstest/test262runner.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the V4VM module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TEST262RUNNER_H
+#define TEST262RUNNER_H
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qset.h>
+#include <qmap.h>
+#include <qmutex.h>
+#include <qthreadpool.h>
+
+struct TestCase {
+ TestCase() = default;
+ TestCase(const QString &test)
+ : test(test) {}
+ enum Result {
+ Skipped,
+ Passes,
+ Fails,
+ Crashes
+ };
+ bool skipTestCase = false;
+ Result strictExpectation = Passes;
+ Result sloppyExpectation = Passes;
+ Result strictResult = Skipped;
+ Result sloppyResult = Skipped;
+
+ QString test;
+};
+
+struct TestData : TestCase {
+ TestData(const TestCase &testCase)
+ : TestCase(testCase) {}
+ // flags
+ bool negative = false;
+ bool runInStrictMode = true;
+ bool runInSloppyMode = true;
+ bool runAsModuleCode = false;
+ bool async = false;
+
+ bool isExcluded = false;
+
+ QList<QByteArray> includes;
+
+ QByteArray harness;
+ QByteArray content;
+};
+
+class Test262Runner
+{
+public:
+ Test262Runner(const QString &command, const QString &testDir);
+ ~Test262Runner();
+
+ enum Mode {
+ Sloppy = 0,
+ Strict = 1
+ };
+
+ enum Flags {
+ Verbose = 0x1,
+ Parallel = 0x2,
+ ForceBytecode = 0x4,
+ ForceJIT = 0x8,
+ WithTestExpectations = 0x10,
+ UpdateTestExpectations = 0x20,
+ WriteTestExpectations = 0x40,
+ };
+ void setFlags(int f) { flags = f; }
+
+ void setFilter(const QString &f) { filter = f; }
+
+ void cat();
+ bool run();
+
+ bool report();
+
+private:
+ friend class SingleTest;
+ bool loadTests();
+ void loadTestExpectations();
+ void updateTestExpectations();
+ void writeTestExpectations();
+ int runSingleTest(TestCase testCase);
+
+ TestData getTestData(const TestCase &testCase);
+ void parseYaml(const QByteArray &content, TestData *data);
+
+ QByteArray harness(const QByteArray &name);
+
+ void addResult(TestCase result);
+
+ QString command;
+ QString testDir;
+ int flags = 0;
+
+ QMutex mutex;
+ QString filter;
+
+ QMap<QString, TestCase> testCases;
+ QHash<QByteArray, QByteArray> harnessFiles;
+
+ QThreadPool *threadPool = nullptr;
+};
+
+
+#endif
diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262
-Subproject 40b4f28e98c416a092e26aa17489bf94ccb8bf4
+Subproject 6b0c42c63c2492bd0a7a96d3179d122b5f71793
diff --git a/tests/auto/qml/ecmascripttests/test262.py b/tests/auto/qml/ecmascripttests/test262.py
index e055c7a8e7..19551e3ba2 100755
--- a/tests/auto/qml/ecmascripttests/test262.py
+++ b/tests/auto/qml/ecmascripttests/test262.py
@@ -61,6 +61,35 @@ from parseTestRecord import parseTestRecord, stripHeader
from packagerConfig import *
+# excluded features that are still experimental and not part of any official standard
+# see also the features.txt file in test262/
+excludedFeatures = [
+ "BigInt",
+ "class-fields-public",
+ "class-fields-private",
+ "Promise.prototype.finally",
+ "async-iteration",
+ "Symbol.asyncIterator",
+ "object-rest",
+ "object-spread",
+ "optional-catch-binding",
+ "regexp-dotall",
+ "regexp-lookbehind",
+ "regexp-named-groups",
+ "regexp-unicode-property-escapes",
+ "Atomics",
+ "SharedArrayBuffer",
+ "Array.prototype.flatten",
+ "Array.prototype.flatMap",
+ "string-trimming",
+ "String.prototype.trimEnd",
+ "String.prototype.trimStart",
+ "numeric-separator-literal",
+
+ # optional features, not supported by us
+ "caller"
+]
+
# ############# Helpers needed for parallel multi-process test execution ############
def runTest(case, args):
@@ -95,19 +124,19 @@ class TestExpectations:
continue
record = line.split()
if len(record) == 1:
- self.testsToSkip.append(record[0])
+ self.failingTests.append(record[0])
else:
test = record[0]
expectation = record[1]
- if expectation == "failing":
- self.failingTests.append(test)
+ if expectation == "skip":
+ self.testsToSkip.append(test)
f.close()
def update(self, progress):
- unexpectedPasses = [c.case.name[-1] for c in progress.failed_tests if c.case.IsNegative()]
+ unexpectedPasses = [c.case.name for c in progress.failed_tests if c.case.IsNegative()]
# If a test fails that we expected to fail, then it actually passed unexpectedly.
- failures = [c.case.name[-1] for c in progress.failed_tests if not c.case.IsNegative()]
+ failures = [c.case.name for c in progress.failed_tests if not c.case.IsNegative()]
for failure in failures:
if failure in self.failingTests:
unexpectedPasses.append(failure)
@@ -116,7 +145,7 @@ class TestExpectations:
lines = f.read().splitlines()
oldLen = len(lines)
for result in unexpectedPasses:
- expectationLine = result + " failing"
+ expectationLine = result
try:
lines.remove(expectationLine)
except ValueError:
@@ -277,14 +306,17 @@ class TestCase(object):
f.close()
testRecord = parseTestRecord(self.contents, name)
self.test = testRecord["test"]
+ if 'features' in testRecord:
+ self.features = testRecord["features"];
+ else:
+ self.features = []
del testRecord["test"]
del testRecord["header"]
- del testRecord["commentary"]
self.testRecord = testRecord;
def GetName(self):
- return path.join(*self.name)
+ return self.name
def GetMode(self):
if self.strict_mode:
@@ -310,14 +342,20 @@ class TestCase(object):
def IsNoStrict(self):
return 'noStrict' in self.testRecord
+ def IsExperimental(self):
+ for f in self.features:
+ if excludedFeatures.count(f) >= 1:
+ return True;
+ return False
+
def GetSource(self):
# "var testDescrip = " + str(self.testRecord) + ';\n\n' + \
- source = self.suite.GetInclude("cth.js") + \
+ source = self.suite.GetInclude("assert.js") + \
self.suite.GetInclude("sta.js") + \
- self.suite.GetInclude("ed.js") + \
- self.suite.GetInclude("testBuiltInObject.js") + \
- self.suite.GetInclude("testIntl.js") + \
self.test + '\n'
+ if 'includes' in self.testRecord:
+ for inc in self.testRecord['includes']:
+ source += self.suite.GetInclude(inc);
if self.strict_mode:
source = '"use strict";\nvar strict_mode = true;\n' + source
@@ -403,14 +441,23 @@ class TestSuite(object):
def __init__(self, root, strict_only, non_strict_only, unmarked_default, load_expectations):
# TODO: derive from packagerConfig.py
- self.test_root = path.join(root, 'test', 'suite')
- self.lib_root = path.join(root, 'test', 'harness')
+ self.test_root = path.join(root, 'test')
+ self.lib_root = path.join(root, 'harness')
self.strict_only = strict_only
self.non_strict_only = non_strict_only
self.unmarked_default = unmarked_default
self.include_cache = { }
self.expectations = TestExpectations(load_expectations)
+ def IsExcludedTest(self, path):
+ if path.startswith('annexB'):
+ return True;
+ if path.startswith('harness'):
+ return True;
+ if path.startswith('intl402'):
+ return True;
+ return False;
+
def Validate(self):
if not path.exists(self.test_root):
ReportError("No test repository found")
@@ -459,25 +506,25 @@ class TestSuite(object):
else:
logging.warning("Unexpected path %s", full_path)
rel_path = full_path
- if self.ShouldRun(rel_path, tests) and not rel_path.startswith("intl402" + os.sep):
+ if self.ShouldRun(rel_path, tests) and not self.IsExcludedTest(rel_path):
basename = path.basename(full_path)[:-3]
- name = rel_path.split(path.sep)[:-1] + [basename]
- if EXCLUDE_LIST.count(basename) >= 1 or self.expectations.testsToSkip.count(basename) >= 1:
- print 'Excluded: ' + basename
+ name = rel_path.replace('.js', '')
+ if EXCLUDE_LIST.count(basename) >= 1 or self.expectations.testsToSkip.count(name) >= 1:
+ print 'Excluded: ' + rel_path
else:
if not self.non_strict_only:
strict_case = TestCase(self, name, full_path, True)
- if self.expectations.failingTests.count(basename) >= 1:
+ if self.expectations.failingTests.count(name) >= 1:
strict_case.NegateResult()
- if not strict_case.IsNoStrict():
+ if not strict_case.IsNoStrict() and not strict_case.IsExperimental():
if strict_case.IsOnlyStrict() or \
self.unmarked_default in ['both', 'strict']:
cases.append(strict_case)
if not self.strict_only:
non_strict_case = TestCase(self, name, full_path, False)
- if self.expectations.failingTests.count(basename) >= 1:
+ if self.expectations.failingTests.count(name) >= 1:
non_strict_case.NegateResult()
- if not non_strict_case.IsOnlyStrict():
+ if not non_strict_case.IsOnlyStrict() and not non_strict_case.IsExperimental():
if non_strict_case.IsNoStrict() or \
self.unmarked_default in ['both', 'non_strict']:
cases.append(non_strict_case)
diff --git a/tests/auto/qml/ecmascripttests/testcase.pro b/tests/auto/qml/ecmascripttests/testcase.pro
new file mode 100644
index 0000000000..5bf7ecd696
--- /dev/null
+++ b/tests/auto/qml/ecmascripttests/testcase.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_ecmascripttests
+QT += testlib qml-private
+macos:CONFIG -= app_bundle
+SOURCES += tst_ecmascripttests.cpp qjstest/test262runner.cpp
+HEADERS += qjstest/test262runner.h
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+# The ES test suite takes approximately 5 mins to run, on a fairly
+# vanilla developer machine, so the default watchdog timer kills the
+# test some of the time. Fix by raising time-out to 400s when
+# invoking tst_ecmascripttests:
+checkenv.name = QTEST_FUNCTION_TIMEOUT
+checkenv.value = 500000
+QT_TOOL_ENV += checkenv
diff --git a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
index 0d58d045b9..27d2822762 100644
--- a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
+++ b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp
@@ -30,55 +30,37 @@
#include <QtTest/QtTest>
#include <QProcess>
#include <QLibraryInfo>
+#include <qjstest/test262runner.h>
class tst_EcmaScriptTests : public QObject
{
Q_OBJECT
- void runTests(bool interpret);
-
private slots:
void runInterpreted();
void runJitted();
};
-void tst_EcmaScriptTests::runTests(bool interpret)
-{
-#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_X86_64)
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- if (interpret)
- env.insert("QV4_FORCE_INTERPRETER", "1");
- else
- env.insert("QV4_JIT_CALL_THRESHOLD", "0");
-
- QProcess process;
- process.setProcessChannelMode(QProcess::ForwardedChannels);
- process.setWorkingDirectory(QLatin1String(SRCDIR));
- process.setProgram("python");
- process.setProcessEnvironment(env);
- process.setArguments(QStringList() << "test262.py" << "--command=" + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmljs" << "--parallel" << "--with-test-expectations");
-
- qDebug() << "Going to run" << process.program() << process.arguments() << "in" << process.workingDirectory();
-
- process.start();
- QVERIFY(process.waitForStarted());
- const int timeoutInMSecs = 20 * 60 * 1000;
- QVERIFY2(process.waitForFinished(timeoutInMSecs), "Tests did not terminate in time -- see output above for details");
- QVERIFY2(process.exitStatus() == QProcess::NormalExit, "Running the test harness failed -- see output above for details");
- QVERIFY2(process.exitCode() == 0, "Tests failed -- see output above for details");
-#else
- QSKIP("Currently the ecmascript tests are only run on Linux/x86-64");
-#endif
-}
-
void tst_EcmaScriptTests::runInterpreted()
{
- runTests(true);
+#if defined(Q_PROCESSOR_X86_64)
+ QDir::setCurrent(QLatin1String(SRCDIR));
+ Test262Runner runner(QString(), "test262");
+ runner.setFlags(Test262Runner::ForceBytecode|Test262Runner::WithTestExpectations|Test262Runner::Parallel|Test262Runner::Verbose);
+ bool result = runner.run();
+ QVERIFY(result);
+#endif
}
void tst_EcmaScriptTests::runJitted()
{
- runTests(false);
+#if defined(Q_PROCESSOR_X86_64)
+ QDir::setCurrent(QLatin1String(SRCDIR));
+ Test262Runner runner(QString(), "test262");
+ runner.setFlags(Test262Runner::ForceJIT|Test262Runner::WithTestExpectations|Test262Runner::Parallel|Test262Runner::Verbose);
+ bool result = runner.run();
+ QVERIFY(result);
+#endif
}
QTEST_GUILESS_MAIN(tst_EcmaScriptTests)
diff --git a/tests/auto/qml/qjsengine/modulewithlexicals.mjs b/tests/auto/qml/qjsengine/modulewithlexicals.mjs
new file mode 100644
index 0000000000..c31cb5aef3
--- /dev/null
+++ b/tests/auto/qml/qjsengine/modulewithlexicals.mjs
@@ -0,0 +1,9 @@
+class Point {
+ constructor() {}
+}
+
+
+export function main() {
+ (new Point());
+ return 10;
+}
diff --git a/tests/auto/qml/qjsengine/qjsengine.pro b/tests/auto/qml/qjsengine/qjsengine.pro
index c9d78e22a0..1fb2d55b31 100644
--- a/tests/auto/qml/qjsengine/qjsengine.pro
+++ b/tests/auto/qml/qjsengine/qjsengine.pro
@@ -4,5 +4,6 @@ QT += qml qml-private widgets testlib gui-private
macx:CONFIG -= app_bundle
SOURCES += tst_qjsengine.cpp
RESOURCES += qjsengine.qrc
+RESOURCES += testmodule.mjs modulewithlexicals.mjs
TESTDATA = script/*
diff --git a/tests/auto/qml/qjsengine/testmodule.mjs b/tests/auto/qml/qjsengine/testmodule.mjs
new file mode 100644
index 0000000000..df561c06a1
--- /dev/null
+++ b/tests/auto/qml/qjsengine/testmodule.mjs
@@ -0,0 +1,6 @@
+
+export var value = 42;
+
+export function sideEffect() {
+ value = value + 1
+}
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index bb923951a8..92696c7e76 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -39,6 +39,8 @@
#include <qqmlcomponent.h>
#include <stdlib.h>
#include <private/qv4alloca_p.h>
+#include <private/qjsvalue_p.h>
+#include <QScopeGuard>
#ifdef Q_CC_MSVC
#define NO_INLINE __declspec(noinline)
@@ -206,7 +208,28 @@ private slots:
void scriptScopes();
+ void binaryNumbers();
+ void octalNumbers();
+
+ void incrementAfterNewline();
+
+ void deleteInsideForIn();
+
+ void functionToString_data();
+ void functionToString();
+
void protoChanges_QTBUG68369();
+ void multilineStrings();
+
+ void throwError();
+ void mathMinMax();
+
+ void importModule();
+ void importModuleRelative();
+ void importModuleWithLexicallyScopedVars();
+
+public:
+ Q_INVOKABLE QJSValue throwingCppMethod();
signals:
void testSignal();
@@ -496,12 +519,11 @@ void tst_QJSEngine::newRegExp()
// prototype should be RegExp.prototype
QVERIFY(!rexp.prototype().isUndefined());
QCOMPARE(rexp.prototype().isObject(), true);
- QCOMPARE(rexp.prototype().isRegExp(), true);
// Get [[Class]] internal property of RegExp Prototype Object.
// See ECMA-262 Section 8.6.2, "Object Internal Properties and Methods".
// See ECMA-262 Section 15.10.6, "Properties of the RegExp Prototype Object".
QJSValue r = eng.evaluate("Object.prototype.toString.call(RegExp.prototype)");
- QCOMPARE(r.toString(), QString::fromLatin1("[object RegExp]"));
+ QCOMPARE(r.toString(), QString::fromLatin1("[object Object]"));
QCOMPARE(rexp.prototype().strictlyEquals(eng.evaluate("RegExp.prototype")), true);
QCOMPARE(qjsvalue_cast<QRegExp>(rexp).pattern(), QRegExp("foo").pattern());
@@ -527,8 +549,7 @@ void tst_QJSEngine::jsRegExp()
QVERIFY(r2.strictlyEquals(r));
QJSValue r3 = rxCtor.call(QJSValueList() << r << "gim");
- QVERIFY(r3.isError());
- QVERIFY(r3.toString().contains(QString::fromLatin1("TypeError"))); // Cannot supply flags when constructing one RegExp from another
+ QVERIFY(!r3.isError());
QJSValue r4 = rxCtor.call(QJSValueList() << "foo" << "gim");
QVERIFY(r4.isRegExp());
@@ -536,9 +557,7 @@ void tst_QJSEngine::jsRegExp()
QJSValue r5 = rxCtor.callAsConstructor(QJSValueList() << r);
QVERIFY(r5.isRegExp());
QCOMPARE(r5.toString(), QString::fromLatin1("/foo/gim"));
- // In JSC, constructing a RegExp from another produces the same identical object.
- // This is different from SpiderMonkey and old back-end.
- QVERIFY(!r5.strictlyEquals(r));
+ QVERIFY(r5.strictlyEquals(r));
// See ECMA-262 Section 15.10.4.1, "new RegExp(pattern, flags)".
QJSValue r6 = rxCtor.callAsConstructor(QJSValueList() << "foo" << "bar");
@@ -942,12 +961,14 @@ void tst_QJSEngine::globalObjectProperties_enumerate()
<< "decodeURIComponent"
<< "Date"
<< "Array"
+ << "Symbol"
<< "escape"
<< "unescape"
<< "SyntaxError"
<< "undefined"
<< "JSON"
<< "ArrayBuffer"
+ << "SharedArrayBuffer"
<< "DataView"
<< "Int8Array"
<< "Uint8Array"
@@ -958,6 +979,13 @@ void tst_QJSEngine::globalObjectProperties_enumerate()
<< "Uint32Array"
<< "Float32Array"
<< "Float64Array"
+ << "WeakSet"
+ << "Set"
+ << "WeakMap"
+ << "Map"
+ << "Reflect"
+ << "Proxy"
+ << "Atomics"
;
QSet<QString> actualNames;
{
@@ -3207,9 +3235,7 @@ void tst_QJSEngine::threadedEngine()
void tst_QJSEngine::functionDeclarationsInConditionals()
{
- // Even though this is bad practice (and test262 covers it with best practices test cases),
- // we do allow for function declarations in if and while statements, as unfortunately that's
- // real world JavaScript. (QTBUG-33064 for example)
+ // Visibility of function declarations inside blocks is limited to the block
QJSEngine eng;
QJSValue result = eng.evaluate("if (true) {\n"
" function blah() { return false; }\n"
@@ -3217,8 +3243,7 @@ void tst_QJSEngine::functionDeclarationsInConditionals()
" function blah() { return true; }\n"
"}\n"
"blah();");
- QVERIFY(result.isBool());
- QCOMPARE(result.toBool(), true);
+ QVERIFY(result.isError());
}
void tst_QJSEngine::arrayPop_QTBUG_35979()
@@ -4169,6 +4194,88 @@ void tst_QJSEngine::scriptScopes()
QCOMPARE(use.toInt(), 42);
}
+void tst_QJSEngine::binaryNumbers()
+{
+ QJSEngine engine;
+
+ QJSValue result = engine.evaluate("0b1001");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == 9);
+
+ result = engine.evaluate("0B1001");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == 9);
+
+ result = engine.evaluate("0b2");
+ QVERIFY(result.isError());
+}
+
+void tst_QJSEngine::octalNumbers()
+{
+ QJSEngine engine;
+
+ QJSValue result = engine.evaluate("0o11");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == 9);
+
+ result = engine.evaluate("0O11");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == 9);
+
+ result = engine.evaluate("0o9");
+ QVERIFY(result.isError());
+}
+
+void tst_QJSEngine::incrementAfterNewline()
+{
+ QJSEngine engine;
+
+ QJSValue result = engine.evaluate("var x = 0; if (\n++x) x; else -x;");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == 1);
+
+ result = engine.evaluate("var x = 0; if (\n--x) x; else -x;");
+ QVERIFY(result.isNumber());
+ QVERIFY(result.toNumber() == -1);
+}
+
+void tst_QJSEngine::deleteInsideForIn()
+{
+ QJSEngine engine;
+
+ QJSValue iterationCount = engine.evaluate(
+ "var o = { a: 1, b: 2, c: 3, d: 4};\n"
+ "var count = 0;\n"
+ "for (var prop in o) { count++; delete o[prop]; }\n"
+ "count");
+ QVERIFY(iterationCount.isNumber());
+ QCOMPARE(iterationCount.toInt(), 4);
+}
+
+void tst_QJSEngine::functionToString_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("expectedString");
+
+ QTest::newRow("named function") << QString::fromLatin1("function f() {}; f.toString()")
+ << QString::fromLatin1("function f() { [native code] }");
+ QTest::newRow("anonymous function") << QString::fromLatin1("(function() {}).toString()")
+ << QString::fromLatin1("function() { [native code] }");
+}
+
+// Tests that function.toString() prints the function's name.
+void tst_QJSEngine::functionToString()
+{
+ QFETCH(QString, source);
+ QFETCH(QString, expectedString);
+
+ QJSEngine engine;
+ engine.installExtensions(QJSEngine::AllExtensions);
+ QJSValue evaluationResult = engine.evaluate(source);
+ QVERIFY(!evaluationResult.isError());
+ QCOMPARE(evaluationResult.toString(), expectedString);
+}
+
void tst_QJSEngine::protoChanges_QTBUG68369()
{
QJSEngine engine;
@@ -4185,6 +4292,117 @@ void tst_QJSEngine::protoChanges_QTBUG68369()
QVERIFY(ok.toBool() == true);
}
+void tst_QJSEngine::multilineStrings()
+{
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(
+ "var x = `a\nb`; x;"
+ );
+ QVERIFY(result.isString());
+ QVERIFY(result.toString() == QStringLiteral("a\nb"));
+
+}
+
+void tst_QJSEngine::throwError()
+{
+ QJSEngine engine;
+ QJSValue wrappedThis = engine.newQObject(this);
+ QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
+ engine.globalObject().setProperty("testCase", wrappedThis);
+
+ QJSValue result = engine.evaluate(
+ "function test(){\n"
+ "try {\n"
+ " return testCase.throwingCppMethod();\n"
+ "} catch (error) {\n"
+ " return error;\n"
+ "}\n"
+ "return \"not reached!\";\n"
+ "}\n"
+ "test();"
+ );
+ QVERIFY(result.isError());
+ QCOMPARE(result.property("lineNumber").toString(), "3");
+ QCOMPARE(result.property("message").toString(), "blub");
+ QVERIFY(!result.property("stack").isUndefined());
+}
+
+QJSValue tst_QJSEngine::throwingCppMethod()
+{
+ qjsEngine(this)->throwError("blub");
+ return QJSValue(47);
+}
+
+void tst_QJSEngine::mathMinMax()
+{
+ QJSEngine engine;
+
+ QJSValue result = engine.evaluate("var a = .5; Math.min(1, 2, 3.5 + a, '5')");
+ QCOMPARE(result.toNumber(), 1.0);
+ QVERIFY(QJSValuePrivate::getValue(&result) != nullptr);
+ QVERIFY(QJSValuePrivate::getValue(&result)->isInteger());
+
+ result = engine.evaluate("var a = .5; Math.max('0', 1, 2, 3.5 + a)");
+ QCOMPARE(result.toNumber(), 4.0);
+ QVERIFY(QJSValuePrivate::getValue(&result) != nullptr);
+ QVERIFY(QJSValuePrivate::getValue(&result)->isInteger());
+}
+
+void tst_QJSEngine::importModule()
+{
+ // This is just a basic test for the API. Primary test coverage is via the ES test suite.
+ QJSEngine engine;
+ QJSValue ns = engine.importModule(QStringLiteral(":/testmodule.mjs"));
+ QCOMPARE(ns.property("value").toInt(), 42);
+ ns.property("sideEffect").call();
+
+ // Make sure that importing a second time will return the same instance.
+ QJSValue secondNamespace = engine.importModule(QStringLiteral(":/testmodule.mjs"));
+ QCOMPARE(secondNamespace.property("value").toInt(), 43);
+}
+
+void tst_QJSEngine::importModuleRelative()
+{
+ const QString oldWorkingDirectory = QDir::currentPath();
+ auto workingDirectoryGuard = qScopeGuard([oldWorkingDirectory]{
+ QDir::setCurrent(oldWorkingDirectory);
+ });
+
+ QTemporaryDir tempDir;
+ QVERIFY(tempDir.isValid());
+ QDir::setCurrent(tempDir.path());
+
+ {
+ QFile f(QStringLiteral("relativemodule.mjs"));
+ QVERIFY(f.open(QIODevice::WriteOnly|QIODevice::Truncate));
+ f.write(QByteArrayLiteral("var value = 100; export { value }; export function change() { value = value + 1 }"));
+ }
+
+ QJSEngine engine;
+
+ {
+ QJSValue module = engine.importModule(QStringLiteral("relativemodule.mjs"));
+ QVERIFY2(!module.isError(), qPrintable(module.toString()));
+ QCOMPARE(module.property("value").toInt(), 100);
+
+ module.property("change").call();
+ }
+
+ {
+ QJSValue sameModule = engine.importModule(tempDir.filePath(QStringLiteral("relativemodule.mjs")));
+ QVERIFY2(!sameModule.isError(), qPrintable(sameModule.toString()));
+ QCOMPARE(sameModule.property("value").toInt(), 101);
+ }
+}
+
+void tst_QJSEngine::importModuleWithLexicallyScopedVars()
+{
+ QJSEngine engine;
+ QJSValue ns = engine.importModule(QStringLiteral(":/modulewithlexicals.mjs"));
+ QVERIFY2(!ns.isError(), qPrintable(ns.toString()));
+ QCOMPARE(ns.property("main").call().toInt(), 10);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index 6587408ae4..f9718e3699 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -1259,7 +1259,7 @@ void tst_QJSValue::isError_propertiesOfGlobalObject()
for (int i = 0; i < errors.size(); ++i) {
QJSValue ctor = eng.globalObject().property(errors.at(i));
QVERIFY(ctor.isCallable());
- QVERIFY(ctor.property("prototype").isError());
+ QVERIFY(ctor.property("prototype").isObject());
}
}
@@ -1638,7 +1638,7 @@ void tst_QJSValue::getSetPrototype_evalCyclicPrototype()
QJSEngine eng;
QJSValue ret = eng.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o");
QCOMPARE(ret.isError(), true);
- QCOMPARE(ret.toString(), QLatin1String("TypeError: Cyclic __proto__ value"));
+ QCOMPARE(ret.toString(), QLatin1String("TypeError: Could not change prototype."));
}
void tst_QJSValue::getSetPrototype_eval()
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 3433b56864..4d9e5c23c5 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -71,8 +71,10 @@ PRIVATETESTS += \
qqmlobjectmodel \
qv4assembler \
qv4mm \
+ qv4identifiertable \
ecmascripttests \
- bindingdependencyapi
+ bindingdependencyapi \
+ v4misc
qtHaveModule(widgets) {
PUBLICTESTS += \
diff --git a/tests/auto/qml/qmlcachegen/jsmoduleimport.qml b/tests/auto/qml/qmlcachegen/jsmoduleimport.qml
new file mode 100644
index 0000000000..c1fad7fee2
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/jsmoduleimport.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+import "script.mjs" as Script
+
+QtObject {
+ property bool ok: Script.ok()
+}
diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
index 6dee2a0454..7f7b3128cf 100644
--- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro
+++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
@@ -19,4 +19,6 @@ RESOURCES += Enums.qml
# QTBUG-46375
!win32: RESOURCES += trickypaths_umlaut.qrc
+RESOURCES += jsmoduleimport.qml script.mjs
+
QT += core-private qml-private testlib
diff --git a/tests/auto/qml/qmlcachegen/script.mjs b/tests/auto/qml/qmlcachegen/script.mjs
new file mode 100644
index 0000000000..459c336125
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/script.mjs
@@ -0,0 +1,4 @@
+
+export function ok() {
+ return true
+}
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 48eb694167..6c399f6874 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -32,6 +32,7 @@
#include <QQmlEngine>
#include <QProcess>
#include <QLibraryInfo>
+#include <QStandardPaths>
#include <QSysInfo>
#include <QLoggingCategory>
#include <private/qqmlcomponent_p.h>
@@ -56,9 +57,13 @@ private slots:
void trickyPaths_data();
void trickyPaths();
- void scriptImport();
+ void qrcScriptImport();
+ void fsScriptImport();
+ void moduleScriptImport();
void enums();
+
+ void sourceFileIndices();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -105,6 +110,13 @@ static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr
void tst_qmlcachegen::initTestCase()
{
qputenv("QML_FORCE_DISK_CACHE", "1");
+ QStandardPaths::setTestModeEnabled(true);
+
+ // make sure there's no pre-existing cache dir
+ QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ if (!cacheDir.isEmpty())
+ //QDir(cacheDir).removeRecursively();
+ qDebug() << cacheDir;
}
void tst_qmlcachegen::loadGeneratedFile()
@@ -137,6 +149,7 @@ void tst_qmlcachegen::loadGeneratedFile()
QVERIFY(cacheUnit);
QVERIFY(cacheUnit->flags & QV4::CompiledData::Unit::StaticData);
QVERIFY(cacheUnit->flags & QV4::CompiledData::Unit::PendingTypeCompilation);
+ QCOMPARE(uint(cacheUnit->sourceFileIndex), uint(0));
}
QVERIFY(QFile::remove(testFilePath));
@@ -151,8 +164,9 @@ void tst_qmlcachegen::loadGeneratedFile()
QVERIFY(componentPrivate);
auto compilationUnit = componentPrivate->compilationUnit;
QVERIFY(compilationUnit);
- QVERIFY(compilationUnit->data);
- QVERIFY(!(compilationUnit->data->flags & QV4::CompiledData::Unit::StaticData));
+ auto unitData = compilationUnit->unitData();
+ QVERIFY(unitData);
+ QVERIFY(unitData->flags & QV4::CompiledData::Unit::StaticData);
}
void tst_qmlcachegen::translationExpressionSupport()
@@ -223,12 +237,40 @@ void tst_qmlcachegen::signalHandlerParameters()
QVERIFY(QFile::exists(cacheFilePath));
QVERIFY(QFile::remove(testFilePath));
+ {
+ QFile cache(cacheFilePath);
+ QVERIFY(cache.open(QIODevice::ReadOnly));
+ const QV4::CompiledData::Unit *cacheUnit = reinterpret_cast<const QV4::CompiledData::Unit *>(cache.map(/*offset*/0, sizeof(QV4::CompiledData::Unit)));
+ QVERIFY(cacheUnit);
+ }
+
QQmlEngine engine;
CleanlyLoadingComponent component(&engine, QUrl::fromLocalFile(testFilePath));
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
QMetaObject::invokeMethod(obj.data(), "runTest");
QCOMPARE(obj->property("result").toInt(), 42);
+
+ {
+ auto componentPrivate = QQmlComponentPrivate::get(&component);
+ QVERIFY(componentPrivate);
+ auto compilationUnit = componentPrivate->compilationUnit;
+ QVERIFY(compilationUnit);
+ QVERIFY(compilationUnit->unitData());
+
+ // Verify that the QML objects don't come from the original data.
+ QVERIFY(compilationUnit->objectAt(0) != compilationUnit->unitData()->qmlUnit()->objectAt(0));
+
+ // Typically the final file name is one of those strings that is not in the original
+ // pre-compiled qml file's string table, while for example the signal parameter
+ // name ("value") is.
+ const auto isStringIndexInStringTable = [compilationUnit](uint index) {
+ return index < compilationUnit->unitData()->stringTableSize;
+ };
+
+ QVERIFY(isStringIndexInStringTable(compilationUnit->objectAt(0)->signalAt(0)->parameterAt(0)->nameIndex));
+ QVERIFY(!compilationUnit->dynamicStrings.isEmpty());
+ }
}
void tst_qmlcachegen::errorOnArgumentsInSignalHandler()
@@ -434,7 +476,7 @@ void tst_qmlcachegen::trickyPaths()
QCOMPARE(obj->property("success").toInt(), 42);
}
-void tst_qmlcachegen::scriptImport()
+void tst_qmlcachegen::qrcScriptImport()
{
QQmlEngine engine;
CleanlyLoadingComponent component(&engine, QUrl("qrc:///jsimport.qml"));
@@ -443,6 +485,90 @@ void tst_qmlcachegen::scriptImport()
QTRY_COMPARE(obj->property("value").toInt(), 42);
}
+void tst_qmlcachegen::fsScriptImport()
+{
+ QTemporaryDir tempDir;
+ QVERIFY(tempDir.isValid());
+
+ const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) {
+ QFile f(tempDir.path() + '/' + fileName);
+ const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate);
+ Q_ASSERT(ok);
+ f.write(contents);
+ return f.fileName();
+ };
+
+ const QString testFilePath = writeTempFile(
+ "test.qml",
+ "import QtQml 2.0\n"
+ "import \"test.js\" as ScriptTest\n"
+ "QtObject {\n"
+ " property int value: ScriptTest.value\n"
+ "}\n");
+
+ const QString scriptFilePath = writeTempFile(
+ "test.js",
+ "var value = 42"
+ );
+
+ QVERIFY(generateCache(scriptFilePath));
+ QVERIFY(generateCache(testFilePath));
+
+ const QString scriptCacheFilePath = scriptFilePath + QLatin1Char('c');
+ QVERIFY(QFile::exists(scriptFilePath));
+
+ {
+ QFile cache(scriptCacheFilePath);
+ QVERIFY(cache.open(QIODevice::ReadOnly));
+ const QV4::CompiledData::Unit *cacheUnit = reinterpret_cast<const QV4::CompiledData::Unit *>(cache.map(/*offset*/0, sizeof(QV4::CompiledData::Unit)));
+ QVERIFY(cacheUnit);
+ QVERIFY(cacheUnit->flags & QV4::CompiledData::Unit::StaticData);
+ QVERIFY(!(cacheUnit->flags & QV4::CompiledData::Unit::PendingTypeCompilation));
+ QCOMPARE(uint(cacheUnit->sourceFileIndex), uint(0));
+ }
+
+ // Remove source code to make sure that when loading succeeds, it is because we loaded
+ // the existing cache files.
+ QVERIFY(QFile::remove(testFilePath));
+ QVERIFY(QFile::remove(scriptFilePath));
+
+ QQmlEngine engine;
+ CleanlyLoadingComponent component(&engine, QUrl::fromLocalFile(testFilePath));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("value").toInt(), 42);
+}
+
+void tst_qmlcachegen::moduleScriptImport()
+{
+ QQmlEngine engine;
+ CleanlyLoadingComponent component(&engine, QUrl("qrc:///jsmoduleimport.qml"));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QTRY_VERIFY(obj->property("ok").toBool());
+
+ QVERIFY(QFile::exists(":/script.mjs"));
+ QCOMPARE(QFileInfo(":/script.mjs").size(), 0);
+
+ {
+ auto componentPrivate = QQmlComponentPrivate::get(&component);
+ QVERIFY(componentPrivate);
+ auto compilationUnit = componentPrivate->compilationUnit->dependentScripts.first()->compilationUnit();
+ QVERIFY(compilationUnit);
+ auto unitData = compilationUnit->unitData();
+ QVERIFY(unitData);
+ QVERIFY(unitData->flags & QV4::CompiledData::Unit::StaticData);
+ QVERIFY(unitData->flags & QV4::CompiledData::Unit::IsESModule);
+
+ QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError;
+ const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/script.mjs"), &error);
+ QVERIFY(unitFromResources);
+
+ QCOMPARE(unitFromResources, compilationUnit->unitData());
+ }
+}
+
void tst_qmlcachegen::enums()
{
QQmlEngine engine;
@@ -452,6 +578,18 @@ void tst_qmlcachegen::enums()
QTRY_COMPARE(obj->property("value").toInt(), 200);
}
+void tst_qmlcachegen::sourceFileIndices()
+{
+ QVERIFY(QFile::exists(":/versionchecks.qml"));
+ QCOMPARE(QFileInfo(":/versionchecks.qml").size(), 0);
+
+ QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError;
+ const QV4::CompiledData::Unit *unitFromResources = QQmlMetaType::findCachedCompilationUnit(QUrl("qrc:/versionchecks.qml"), &error);
+ QVERIFY(unitFromResources);
+ QVERIFY(unitFromResources->flags & QV4::CompiledData::Unit::PendingTypeCompilation);
+ QCOMPARE(uint(unitFromResources->sourceFileIndex), uint(0));
+}
+
QTEST_GUILESS_MAIN(tst_qmlcachegen)
#include "tst_qmlcachegen.moc"
diff --git a/tests/auto/qml/qmldiskcache/importmodule.qml b/tests/auto/qml/qmldiskcache/importmodule.qml
new file mode 100644
index 0000000000..f890d4cb5c
--- /dev/null
+++ b/tests/auto/qml/qmldiskcache/importmodule.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+import "module.mjs" as Module
+QtObject {
+ property bool ok: Module.ok()
+}
diff --git a/tests/auto/qml/qmldiskcache/module.mjs b/tests/auto/qml/qmldiskcache/module.mjs
new file mode 100644
index 0000000000..32e0651b8b
--- /dev/null
+++ b/tests/auto/qml/qmldiskcache/module.mjs
@@ -0,0 +1,2 @@
+
+export function ok() { return true; }
diff --git a/tests/auto/qml/qmldiskcache/qmldiskcache.pro b/tests/auto/qml/qmldiskcache/qmldiskcache.pro
index f98a157b6a..74aefa6944 100644
--- a/tests/auto/qml/qmldiskcache/qmldiskcache.pro
+++ b/tests/auto/qml/qmldiskcache/qmldiskcache.pro
@@ -4,6 +4,6 @@ osx:CONFIG -= app_bundle
SOURCES += tst_qmldiskcache.cpp
-RESOURCES += test.qml
+RESOURCES += test.qml importmodule.qml module.mjs
QT += core-private qml-private testlib
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index 01f047c323..70a5a73e0f 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -33,6 +33,7 @@
#include <private/qv8engine_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4codegen_p.h>
+#include <private/qqmlcomponent_p.h>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQmlFileSelector>
@@ -47,7 +48,9 @@ class tst_qmldiskcache: public QObject
private slots:
void initTestCase();
+ void cleanupTestCase();
+ void loadLocalAsFallback();
void regenerateAfterChange();
void registerImportForImplicitComponent();
void basicVersionChecks();
@@ -59,6 +62,10 @@ private slots:
void stableOrderOfDependentCompositeTypes();
void singletonDependency();
void cppRegisteredSingletonDependency();
+ void cacheModuleScripts();
+
+private:
+ QDir m_qmlCacheDirectory;
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -112,7 +119,7 @@ struct TestCompiler
{
closeMapping();
testFilePath = baseDirectory + QStringLiteral("/test.qml");
- cacheFilePath = baseDirectory + QStringLiteral("/test.qmlc");
+ cacheFilePath = QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(testFilePath));
mappedFile.setFileName(cacheFilePath);
}
@@ -210,6 +217,58 @@ struct TestCompiler
void tst_qmldiskcache::initTestCase()
{
qputenv("QML_FORCE_DISK_CACHE", "1");
+ QStandardPaths::setTestModeEnabled(true);
+
+ const QString cacheDirectory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ m_qmlCacheDirectory.setPath(cacheDirectory + QLatin1String("/qmlcache"));
+ if (m_qmlCacheDirectory.exists())
+ QVERIFY(m_qmlCacheDirectory.removeRecursively());
+ QVERIFY(QDir::root().mkpath(m_qmlCacheDirectory.absolutePath()));
+}
+
+void tst_qmldiskcache::cleanupTestCase()
+{
+ m_qmlCacheDirectory.removeRecursively();
+}
+
+void tst_qmldiskcache::loadLocalAsFallback()
+{
+ QQmlEngine engine;
+ TestCompiler testCompiler(&engine);
+
+ QVERIFY(testCompiler.tempDir.isValid());
+
+ const QByteArray contents = QByteArrayLiteral("import QtQml 2.0\n"
+ "QtObject {\n"
+ " property string blah: Qt.platform;\n"
+ "}");
+
+ QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString));
+
+ // Create an invalid side-by-side .qmlc
+ {
+ QFile f(testCompiler.tempDir.path() + "/test.qmlc");
+ QVERIFY(f.open(QIODevice::WriteOnly | QIODevice::Truncate));
+ QV4::CompiledData::Unit unit = {};
+ memcpy(unit.magic, QV4::CompiledData::magic_str, sizeof(unit.magic));
+ unit.version = QV4_DATA_STRUCTURE_VERSION;
+ unit.qtVersion = QT_VERSION;
+ unit.sourceTimeStamp = testCompiler.mappedFile.fileTime(QFile::FileModificationTime).toMSecsSinceEpoch();
+ unit.unitSize = ~0U; // make the size a silly number
+ // write something to the library hash that should cause it not to be loaded
+ memset(unit.libraryVersionHash, 'z', sizeof(unit.libraryVersionHash));
+ memset(unit.md5Checksum, 0, sizeof(unit.md5Checksum));
+
+ // leave the other fields unset, since they don't matter
+
+ f.write(reinterpret_cast<const char *>(&unit), sizeof(unit));
+ }
+
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = QV4::Compiler::Codegen::createUnitForLoading();
+ bool loaded = unit->loadFromDisk(QUrl::fromLocalFile(testCompiler.testFilePath), QFileInfo(testCompiler.testFilePath).lastModified(),
+ &testCompiler.lastErrorString);
+ QVERIFY2(loaded, qPrintable(testCompiler.lastErrorString));
+ QCOMPARE(unit->objectCount(), 1);
}
void tst_qmldiskcache::regenerateAfterChange()
@@ -230,9 +289,11 @@ void tst_qmldiskcache::regenerateAfterChange()
const QV4::CompiledData::Unit *testUnit = testCompiler.mapUnit();
QVERIFY2(testUnit, qPrintable(testCompiler.lastErrorString));
- QCOMPARE(quint32(testUnit->nObjects), quint32(1));
+ const QV4::CompiledData::QmlUnit *qmlUnit = testUnit->qmlUnit();
+
+ QCOMPARE(quint32(qmlUnit->nObjects), quint32(1));
- const QV4::CompiledData::Object *obj = testUnit->objectAt(0);
+ const QV4::CompiledData::Object *obj = qmlUnit->objectAt(0);
QCOMPARE(quint32(obj->nBindings), quint32(1));
QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Script));
QCOMPARE(quint32(obj->bindingTable()->value.compiledScriptIndex), quint32(0));
@@ -240,7 +301,7 @@ void tst_qmldiskcache::regenerateAfterChange()
QCOMPARE(quint32(testUnit->functionTableSize), quint32(1));
const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(0);
- QCOMPARE(testUnit->stringAt(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function
+ QCOMPARE(testUnit->stringAtInternal(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function
QVERIFY(bindingFunction->codeSize > 0);
QVERIFY(bindingFunction->codeOffset < testUnit->unitSize);
}
@@ -256,17 +317,19 @@ void tst_qmldiskcache::regenerateAfterChange()
const QV4::CompiledData::Unit *testUnit = testCompiler.mapUnit();
QVERIFY2(testUnit, qPrintable(testCompiler.lastErrorString));
- QCOMPARE(quint32(testUnit->nObjects), quint32(1));
+ const QV4::CompiledData::QmlUnit *qmlUnit = testUnit->qmlUnit();
- const QV4::CompiledData::Object *obj = testUnit->objectAt(0);
+ QCOMPARE(quint32(qmlUnit->nObjects), quint32(1));
+
+ const QV4::CompiledData::Object *obj = qmlUnit->objectAt(0);
QCOMPARE(quint32(obj->nBindings), quint32(2));
QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Number));
- QCOMPARE(obj->bindingTable()->valueAsNumber(), double(42));
+ QCOMPARE(obj->bindingTable()->valueAsNumber(reinterpret_cast<const QV4::Value *>(testUnit->constants())), double(42));
QCOMPARE(quint32(testUnit->functionTableSize), quint32(1));
const QV4::CompiledData::Function *bindingFunction = testUnit->functionAt(0);
- QCOMPARE(testUnit->stringAt(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function
+ QCOMPARE(testUnit->stringAtInternal(bindingFunction->nameIndex), QString("expression for blah")); // check if we have the correct function
QVERIFY(bindingFunction->codeSize > 0);
QVERIFY(bindingFunction->codeOffset < testUnit->unitSize);
}
@@ -289,22 +352,23 @@ void tst_qmldiskcache::registerImportForImplicitComponent()
const QV4::CompiledData::Unit *testUnit = testCompiler.mapUnit();
QVERIFY2(testUnit, qPrintable(testCompiler.lastErrorString));
- QCOMPARE(quint32(testUnit->nImports), quint32(2));
- QCOMPARE(testUnit->stringAt(testUnit->importAt(0)->uriIndex), QStringLiteral("QtQuick"));
+ const QV4::CompiledData::QmlUnit *qmlUnit = testUnit->qmlUnit();
+ QCOMPARE(quint32(qmlUnit->nImports), quint32(2));
+ QCOMPARE(testUnit->stringAtInternal(qmlUnit->importAt(0)->uriIndex), QStringLiteral("QtQuick"));
QQmlType componentType = QQmlMetaType::qmlType(&QQmlComponent::staticMetaObject);
- QCOMPARE(testUnit->stringAt(testUnit->importAt(1)->uriIndex), QString(componentType.module()));
- QCOMPARE(testUnit->stringAt(testUnit->importAt(1)->qualifierIndex), QStringLiteral("QmlInternals"));
+ QCOMPARE(testUnit->stringAtInternal(qmlUnit->importAt(1)->uriIndex), QString(componentType.module()));
+ QCOMPARE(testUnit->stringAtInternal(qmlUnit->importAt(1)->qualifierIndex), QStringLiteral("QmlInternals"));
- QCOMPARE(quint32(testUnit->nObjects), quint32(3));
+ QCOMPARE(quint32(qmlUnit->nObjects), quint32(3));
- const QV4::CompiledData::Object *obj = testUnit->objectAt(0);
+ const QV4::CompiledData::Object *obj = qmlUnit->objectAt(0);
QCOMPARE(quint32(obj->nBindings), quint32(1));
QCOMPARE(quint32(obj->bindingTable()->type), quint32(QV4::CompiledData::Binding::Type_Object));
- const QV4::CompiledData::Object *implicitComponent = testUnit->objectAt(obj->bindingTable()->value.objectIndex);
- QCOMPARE(testUnit->stringAt(implicitComponent->inheritedTypeNameIndex), QStringLiteral("QmlInternals.") + componentType.elementName());
+ const QV4::CompiledData::Object *implicitComponent = qmlUnit->objectAt(obj->bindingTable()->value.objectIndex);
+ QCOMPARE(testUnit->stringAtInternal(implicitComponent->inheritedTypeNameIndex), QStringLiteral("QmlInternals.") + componentType.elementName());
}
}
@@ -453,6 +517,10 @@ void tst_qmldiskcache::recompileAfterDirectoryChange()
testCompiler.clearCache();
QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString));
QVERIFY2(testCompiler.verify(), qPrintable(testCompiler.lastErrorString));
+ const QV4::CompiledData::Unit *unit = testCompiler.mapUnit();
+ QVERIFY(unit->sourceFileIndex != 0);
+ const QString expectedPath = QUrl::fromLocalFile(testCompiler.testFilePath).toString();
+ QCOMPARE(unit->stringAtInternal(unit->sourceFileIndex), expectedPath);
testCompiler.closeMapping();
}
@@ -505,7 +573,7 @@ void tst_qmldiskcache::fileSelectors()
QVERIFY(!obj.isNull());
QCOMPARE(obj->property("value").toInt(), 42);
- QFile cacheFile(testFilePath + "c");
+ QFile cacheFile(QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(testFilePath)));
QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
}
@@ -520,7 +588,7 @@ void tst_qmldiskcache::fileSelectors()
QVERIFY(!obj.isNull());
QCOMPARE(obj->property("value").toInt(), 100);
- QFile cacheFile(selectedTestFilePath + "c");
+ QFile cacheFile(QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(selectedTestFilePath)));
QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
}
}
@@ -570,14 +638,8 @@ void tst_qmldiskcache::localAliases()
void tst_qmldiskcache::cacheResources()
{
- const QString cacheDirectory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- QVERIFY(QDir::root().mkpath(cacheDirectory));
-
- const QString qmlCacheDirectory = cacheDirectory + QLatin1String("/qmlcache/");
- QVERIFY(QDir(qmlCacheDirectory).removeRecursively());
- QVERIFY(QDir::root().mkpath(qmlCacheDirectory));
- QVERIFY(QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot).isEmpty());
-
+ const QSet<QString> existingFiles =
+ m_qmlCacheDirectory.entryList(QDir::Files | QDir::NoDotAndDotDot).toSet();
QQmlEngine engine;
@@ -588,13 +650,14 @@ void tst_qmldiskcache::cacheResources()
QCOMPARE(obj->property("value").toInt(), 20);
}
- const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
+ const QSet<QString> entries =
+ m_qmlCacheDirectory.entryList(QDir::NoDotAndDotDot | QDir::Files).toSet().subtract(existingFiles);
QCOMPARE(entries.count(), 1);
QDateTime cacheFileTimeStamp;
{
- QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst());
+ QFile cacheFile(m_qmlCacheDirectory.absoluteFilePath(*entries.cbegin()));
QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString()));
QV4::CompiledData::Unit unit;
QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit));
@@ -617,10 +680,12 @@ void tst_qmldiskcache::cacheResources()
}
{
- const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
+ const QSet<QString> entries =
+ m_qmlCacheDirectory.entryList(QDir::NoDotAndDotDot | QDir::Files).toSet().subtract(existingFiles);
QCOMPARE(entries.count(), 1);
- QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch());
+ QCOMPARE(QFileInfo(m_qmlCacheDirectory.absoluteFilePath(*entries.cbegin())).lastModified().toMSecsSinceEpoch(),
+ cacheFileTimeStamp.toMSecsSinceEpoch());
}
}
@@ -673,7 +738,7 @@ void tst_qmldiskcache::stableOrderOfDependentCompositeTypes()
QVERIFY2(firstDependentTypeClassName.contains("QMLTYPE"), firstDependentTypeClassName.constData());
QVERIFY2(secondDependentTypeClassName.contains("QMLTYPE"), secondDependentTypeClassName.constData());
- const QString testFileCachePath = testFilePath + QLatin1Char('c');
+ const QString testFileCachePath = QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(testFilePath));
QVERIFY(QFile::exists(testFileCachePath));
QDateTime initialCacheTimeStamp = QFileInfo(testFileCachePath).lastModified();
@@ -751,7 +816,7 @@ void tst_qmldiskcache::singletonDependency()
QCOMPARE(obj->property("value").toInt(), 42);
}
- const QString testFileCachePath = testFilePath + QLatin1Char('c');
+ const QString testFileCachePath = QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(testFilePath));
QVERIFY(QFile::exists(testFileCachePath));
QDateTime initialCacheTimeStamp = QFileInfo(testFileCachePath).lastModified();
@@ -808,7 +873,7 @@ void tst_qmldiskcache::cppRegisteredSingletonDependency()
QCOMPARE(value.toInt(), 42);
}
- const QString testFileCachePath = testFilePath + QLatin1Char('c');
+ const QString testFileCachePath = QV4::CompiledData::CompilationUnit::localCacheFilePath(QUrl::fromLocalFile(testFilePath));
QVERIFY(QFile::exists(testFileCachePath));
QDateTime initialCacheTimeStamp = QFileInfo(testFileCachePath).lastModified();
@@ -835,6 +900,47 @@ void tst_qmldiskcache::cppRegisteredSingletonDependency()
}
}
+void tst_qmldiskcache::cacheModuleScripts()
+{
+ const QSet<QString> existingFiles =
+ m_qmlCacheDirectory.entryList(QDir::Files | QDir::NoDotAndDotDot).toSet();
+
+ QQmlEngine engine;
+
+ {
+ CleanlyLoadingComponent component(&engine, QUrl("qrc:/importmodule.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QVERIFY(obj->property("ok").toBool());
+
+ auto componentPrivate = QQmlComponentPrivate::get(&component);
+ QVERIFY(componentPrivate);
+ auto compilationUnit = componentPrivate->compilationUnit->dependentScripts.first()->compilationUnit();
+ QVERIFY(compilationUnit);
+ auto unitData = compilationUnit->unitData();
+ QVERIFY(unitData);
+ QVERIFY(unitData->flags & QV4::CompiledData::Unit::StaticData);
+ QVERIFY(unitData->flags & QV4::CompiledData::Unit::IsESModule);
+ QVERIFY(!compilationUnit->backingFile.isNull());
+ }
+
+ const QSet<QString> entries =
+ m_qmlCacheDirectory.entryList(QStringList("*.mjsc")).toSet().subtract(existingFiles);
+
+ QCOMPARE(entries.count(), 1);
+
+ QDateTime cacheFileTimeStamp;
+
+ {
+ QFile cacheFile(m_qmlCacheDirectory.absoluteFilePath(*entries.cbegin()));
+ QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString()));
+ QV4::CompiledData::Unit unit;
+ QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit));
+
+ QVERIFY(unit.flags & QV4::CompiledData::Unit::IsESModule);
+ }
+}
+
QTEST_MAIN(tst_qmldiskcache)
#include "tst_qmldiskcache.moc"
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 5941385c80..c393149f59 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -125,6 +125,9 @@ void tst_qmlmin::initTestCase()
invalidFiles << "tests/auto/qml/qqmlecmascript/data/stringParsing_error.6.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.1.qml";
invalidFiles << "tests/auto/qml/qqmlecmascript/data/numberParsing_error.2.qml";
+ invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js";
+ invalidFiles << "tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js";
+ invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml";
}
QStringList tst_qmlmin::findFiles(const QDir &d)
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 3a70890362..efd5bb571b 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -116,6 +116,7 @@ private slots:
void onDestructionCount();
void recursion();
void recursionContinuation();
+ void partialComponentCreation();
void callingContextForInitialProperties();
void setNonExistentInitialProperty();
void relativeUrl_data();
@@ -527,6 +528,29 @@ void tst_qqmlcomponent::recursionContinuation()
QVERIFY(object->property("success").toBool());
}
+void tst_qqmlcomponent::partialComponentCreation()
+{
+ const int maxCount = 17;
+ QQmlEngine engine;
+ QScopedPointer<QQmlComponent> components[maxCount];
+ QScopedPointer<QObject> objects[maxCount];
+ QQmlTestMessageHandler messageHandler;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ for (int i = 0; i < maxCount; i++) {
+ components[i].reset(new QQmlComponent(&engine, testFileUrl("QtObjectComponent.qml")));
+ objects[i].reset(components[i]->beginCreate(engine.rootContext()));
+ QVERIFY(objects[i].isNull() == false);
+ }
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+
+ for (int i = 0; i < maxCount; i++) {
+ components[i]->completeCreate();
+ }
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+}
+
class CallingContextCheckingClass : public QObject
{
Q_OBJECT
diff --git a/tests/auto/qml/qqmlconsole/data/categorized_logging.qml b/tests/auto/qml/qqmlconsole/data/categorized_logging.qml
index d19b6ecc41..d593f0dfa1 100644
--- a/tests/auto/qml/qqmlconsole/data/categorized_logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/categorized_logging.qml
@@ -37,7 +37,7 @@
**
****************************************************************************/
-import QtQuick 2.8
+import QtQuick 2.12
Item {
id:root
@@ -48,6 +48,12 @@ Item {
}
LoggingCategory {
+ id: testCategoryStartingFromWarning
+ name: "qt.test.warning"
+ defaultLogLevel: LoggingCategory.Warning
+ }
+
+ LoggingCategory {
id: emptyCategory
}
@@ -57,8 +63,14 @@ Item {
console.info(testCategory, "console.info");
console.warn(testCategory, "console.warn");
console.error(testCategory, "console.error");
+ console.debug(testCategoryStartingFromWarning, "console.debug");
+ console.log(testCategoryStartingFromWarning, "console.log");
+ console.info(testCategoryStartingFromWarning, "console.info");
+ console.warn(testCategoryStartingFromWarning, "console.warn");
+ console.error(testCategoryStartingFromWarning, "console.error");
testCategory.name = "qt.test2";
+ testCategory.defaultLogLevel = LoggingCategory.Debug;
console.error(emptyCategory, "console.error");
}
diff --git a/tests/auto/qml/qqmlconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml
index d55c99bcbd..0764ad7545 100644
--- a/tests/auto/qml/qqmlconsole/data/logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/logging.qml
@@ -67,6 +67,8 @@ QtObject {
console.log(1, "pong!", new Object);
console.log(1, ["ping","pong"], new Object, 2);
+ console.log(contextStringListProperty);
+
try {
console.log(exception);
} catch (e) {
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
index 0d915f98f8..817ca0a257 100644
--- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -29,6 +29,7 @@
#include <QDebug>
#include <QQmlEngine>
#include <QQmlComponent>
+#include <QQmlContext>
#include <QLoggingCategory>
#include "../../shared/util.h"
@@ -74,18 +75,22 @@ void tst_qqmlconsole::logging()
QTest::ignoreMessage(QtDebugMsg, "{\"a\":\"hello\",\"d\":1}");
QTest::ignoreMessage(QtDebugMsg, "undefined");
QTest::ignoreMessage(QtDebugMsg, "12");
- QTest::ignoreMessage(QtDebugMsg, "function() { [code] }");
+ QTest::ignoreMessage(QtDebugMsg, "function e() { [native code] }");
QTest::ignoreMessage(QtDebugMsg, "true");
// Printing QML object prints out the class/type of QML object with the memory address
// QTest::ignoreMessage(QtDebugMsg, "QtObject_QML_0(0xABCD..)");
// QTest::ignoreMessage(QtDebugMsg, "[object Object]");
QTest::ignoreMessage(QtDebugMsg, "1 pong! [object Object]");
QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] [object Object] 2");
+ QTest::ignoreMessage(QtDebugMsg, "[Hello,World]");
+
+ QScopedPointer<QQmlContext> loggingContext(new QQmlContext(engine.rootContext()));
+ QStringList stringList; stringList << QStringLiteral("Hello") << QStringLiteral("World");
+ loggingContext->setContextProperty("contextStringListProperty", stringList);
QQmlComponent component(&engine, testUrl);
- QObject *object = component.create();
+ QScopedPointer<QObject> object(component.create(loggingContext.data()));
QVERIFY(object != nullptr);
- delete object;
}
void tst_qqmlconsole::categorized_logging()
@@ -107,8 +112,13 @@ void tst_qqmlconsole::categorized_logging()
QVERIFY(messageHandler.messages().contains("qt.test: console.info"));
QVERIFY(messageHandler.messages().contains("qt.test: console.warn"));
QVERIFY(messageHandler.messages().contains("qt.test: console.error"));
+ QVERIFY(!messageHandler.messages().contains("qt.test.warning: console.debug"));
+ QVERIFY(!messageHandler.messages().contains("qt.test.warning: console.log"));
+ QVERIFY(!messageHandler.messages().contains("qt.test.warning: console.info"));
+ QVERIFY(messageHandler.messages().contains("qt.test.warning: console.warn"));
+ QVERIFY(messageHandler.messages().contains("qt.test.warning: console.error"));
- QString emptyCategory = "default: " + QString::fromLatin1("%1:%2:%3: ").arg(testUrl.toString()).arg(50).arg(5) +
+ QString emptyCategory = "default: " + QString::fromLatin1("%1:%2:%3: ").arg(testUrl.toString()).arg(56).arg(5) +
"QML LoggingCategory: Declaring the name of the LoggingCategory is mandatory and cannot be changed later !";
QVERIFY(messageHandler.messages().contains(emptyCategory));
@@ -116,7 +126,11 @@ void tst_qqmlconsole::categorized_logging()
"QML LoggingCategory: The name of a LoggingCategory cannot be changed after the Item is created";
QVERIFY(messageHandler.messages().contains(changedCategory));
- QString useEmptyCategory = "default: " + QString::fromLatin1("%1:%2: ").arg(testUrl.toString()).arg(63) +
+ QString changedDefaultLogLevel = "default: " + QString::fromLatin1("%1:%2:%3: ").arg(testUrl.toString()).arg(45).arg(5) +
+ "QML LoggingCategory: The defaultLogLevel of a LoggingCategory cannot be changed after the Item is created";
+ QVERIFY(messageHandler.messages().contains(changedDefaultLogLevel));
+
+ QString useEmptyCategory = "default: " + QString::fromLatin1("%1:%2: ").arg(testUrl.toString()).arg(75) +
"Error: A QmlLoggingCatgory was provided without a valid name";
QVERIFY(messageHandler.messages().contains(useEmptyCategory));
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index 5999bc42e9..990e364c76 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -803,7 +803,7 @@ void tst_qqmlcontext::contextLeak()
{
QV4::Scope scope(ddata->jsWrapper.engine());
QV4::ScopedValue scriptContextWrapper(scope);
- scriptContextWrapper = context->importedScripts.valueRef()->as<QV4::Object>()->getIndexed(0);
+ scriptContextWrapper = context->importedScripts.valueRef()->as<QV4::Object>()->get(uint(0));
scriptContext = scriptContextWrapper->as<QV4::QQmlContextWrapper>()->getContext();
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml
new file mode 100644
index 0000000000..3f838fe8f2
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.8.qml
@@ -0,0 +1,16 @@
+import QtQml 2.0
+QtObject {
+ function tryWritingReadOnlySequence() {
+ try {
+ Qt.application.arguments.push("hello")
+ } catch (e) {
+
+ try {
+ Qt.application.arguments.sort()
+ } catch (e) {
+ return true
+ }
+ }
+ return false
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.js
new file mode 100644
index 0000000000..500f04bec7
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.js
@@ -0,0 +1,7 @@
+.pragma library
+var Shadowed = 2;
+var global = (function(){return this})()
+
+// set Shadowed on the global object as well. This should be different from
+// the variable above, as the library has it's on context
+global.Shadowed = 1;
diff --git a/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.qml b/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.qml
new file mode 100644
index 0000000000..7cac09d342
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_shadow.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.0
+import "include_pragma_shadow.js" as Shadowed
+import "include_pragma_shadow.js" as Other
+
+Item {
+ property bool result
+
+ Component.onCompleted: {
+ result = false;
+ var global = (function(){return this})()
+ if (Shadowed.Shadowed === 2 && Other.Shadowed === 2 && global.Shadowed === 1)
+ result = true;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
index fa6497d99b..66e18ac2a9 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
@@ -7,5 +7,5 @@ function importIncrementedValue() {
i = i + 1;
// because LibraryImport is shared, and used in previous tests,
// the value will be large (already incremented a bunch of times).
- return (i + LibraryImport.importIncrementedValue());
+ return (i + LibraryImport.importIncrementedValue()); // 11 + 5
}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
index 01f08dbdc3..8264b7229d 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
@@ -3,5 +3,5 @@ import "importPragmaLibraryWithPragmaLibraryImports.js" as LibraryImport
QtObject {
id: root
- property int testValue: LibraryImport.importIncrementedValue(); // 10 + 1 + (7 due to previous tests) = 18
+ property int testValue: LibraryImport.importIncrementedValue(); // 16
}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml
index ae43e90210..0e314b20ea 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsImport.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
-import com.nokia.JsModule 1.0
-import com.nokia.JsModule 1.0 as RenamedModule
+import com.qt.JsModule 1.0
+import com.qt.JsModule 1.0 as RenamedModule
import "testJsModuleImport.js" as TestJsModuleImport
QtObject {
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js
index 2d21953d2c..7440f610c1 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleImport.js
@@ -1,4 +1,4 @@
-.import com.nokia.JsModule 1.0 as JsModule
+.import com.qt.JsModule 1.0 as JsModule
function importedValue() {
return JsModule.ScriptAPI.greeting();
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js
index e6e41bc6b2..6826f09da2 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js
@@ -1,4 +1,4 @@
-.import com.nokia.JsRemoteModule 1.0 as JsModule
+.import com.qt.JsRemoteModule 1.0 as JsModule
function importedValue() {
return JsModule.ScriptAPI.greeting();
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml
index 4199bb022d..f49b38df23 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
-import com.nokia.JsModule 1.0
-import com.nokia.JsModule 1.0 as RenamedModule
+import com.qt.JsModule 1.0
+import com.qt.JsModule 1.0 as RenamedModule
import "testJsModuleRemoteImport.js" as TestJsModuleImport
QtObject {
diff --git a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js b/tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/ScriptAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/ScriptAPI.js
+++ b/tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/ScriptAPI.js
diff --git a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir b/tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/qmldir
index c33d1e7a0d..c33d1e7a0d 100644
--- a/tests/auto/qml/qqmlecmascript/data/lib/com/nokia/JsModule/qmldir
+++ b/tests/auto/qml/qqmlecmascript/data/lib/com/qt/JsModule/qmldir
diff --git a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js b/tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/ScriptAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js
+++ b/tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/ScriptAPI.js
diff --git a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir b/tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/qmldir
index c33d1e7a0d..c33d1e7a0d 100644
--- a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir
+++ b/tests/auto/qml/qqmlecmascript/data/remote/com/qt/JsRemoteModule/qmldir
diff --git a/tests/auto/qml/qqmlecmascript/data/removeBindingsWithNoDependencies.qml b/tests/auto/qml/qqmlecmascript/data/removeBindingsWithNoDependencies.qml
new file mode 100644
index 0000000000..aacf16474d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/removeBindingsWithNoDependencies.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+Item {
+ property rect placement: Qt.rect(0, 0, 100, 100)
+
+ function someFunction() { return 42; }
+
+ property rect partialPlacement
+ partialPlacement.x: someFunction()
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
index 04b39f73d5..7f5a22a459 100644
--- a/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
@@ -8,6 +8,6 @@ MyQmlObject {
return 321
}
- value: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 123 }
+ qjsvalue: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 123 }
}
diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
index 231aaf0683..39d4f74e97 100644
--- a/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
@@ -7,6 +7,6 @@ MyQmlObject {
return 321
}
- value: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 321 }
+ qjsvalue: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 321 }
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index f40a9758f7..cf3eecff6d 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -49,6 +49,8 @@
#include <private/qv4object_p.h>
#include <private/qqmlcomponentattached_p.h>
#include <private/qv4objectiterator_p.h>
+#include <private/qqmlabstractbinding_p.h>
+#include <private/qqmlvaluetypeproxybinding_p.h>
#ifdef Q_CC_MSVC
#define NO_INLINE __declspec(noinline)
@@ -353,11 +355,12 @@ private slots:
void anotherNaN();
void callPropertyOnUndefined();
void jumpStrictNotEqualUndefined();
+ void removeBindingsWithNoDependencies();
+ void temporaryDeadZone();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
static void verifyContextLifetime(QQmlContextData *ctxt);
- QQmlEngine engine;
// When calling into JavaScript, the specific type of the return value can differ if that return
// value is a number. This is not only the case for non-integral numbers, or numbers that do not
@@ -384,13 +387,11 @@ void tst_qqmlecmascript::initTestCase()
{
QQmlDataTest::initTestCase();
registerTypes();
-
- QString dataDir(dataDirectory() + QLatin1Char('/') + QLatin1String("lib"));
- engine.addImportPath(dataDir);
}
void tst_qqmlecmascript::assignBasicTypes()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -470,6 +471,7 @@ void tst_qqmlecmascript::assignDate()
QFETCH(QUrl, source);
QFETCH(int, timeOffset);
+ QQmlEngine engine;
QQmlComponent component(&engine, source);
QScopedPointer<QObject> obj(component.create());
MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data());
@@ -550,6 +552,7 @@ void tst_qqmlecmascript::exportDate()
void tst_qqmlecmascript::idShortcutInvalidates()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -573,6 +576,7 @@ void tst_qqmlecmascript::idShortcutInvalidates()
void tst_qqmlecmascript::boolPropertiesEvaluateAsBool()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -591,6 +595,7 @@ void tst_qqmlecmascript::boolPropertiesEvaluateAsBool()
void tst_qqmlecmascript::signalAssignment()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -628,6 +633,7 @@ void tst_qqmlecmascript::signalAssignment()
void tst_qqmlecmascript::signalArguments()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("signalArguments.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -653,6 +659,7 @@ void tst_qqmlecmascript::signalArguments()
void tst_qqmlecmascript::methods()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("methods.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -706,6 +713,7 @@ void tst_qqmlecmascript::methods()
void tst_qqmlecmascript::bindingLoop()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("bindingLoop.qml"));
QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
@@ -747,6 +755,8 @@ void tst_qqmlecmascript::basicExpressions()
QFETCH(QVariant, result);
QFETCH(bool, nest);
+ QQmlEngine engine;
+
MyQmlObject object1;
MyQmlObject object2;
MyQmlObject object3;
@@ -779,6 +789,7 @@ void tst_qqmlecmascript::arrayExpressions()
QObject obj2;
QObject obj3;
+ QQmlEngine engine;
QQmlContext context(engine.rootContext());
context.setContextProperty("a", &obj1);
context.setContextProperty("b", &obj2);
@@ -798,6 +809,7 @@ void tst_qqmlecmascript::arrayExpressions()
// Tests that modifying a context property will reevaluate expressions
void tst_qqmlecmascript::contextPropertiesTriggerReeval()
{
+ QQmlEngine engine;
QQmlContext context(engine.rootContext());
MyQmlObject object1;
MyQmlObject object2;
@@ -861,6 +873,7 @@ void tst_qqmlecmascript::contextPropertiesTriggerReeval()
void tst_qqmlecmascript::objectPropertiesTriggerReeval()
{
+ QQmlEngine engine;
QQmlContext context(engine.rootContext());
MyQmlObject object1;
MyQmlObject object2;
@@ -927,6 +940,7 @@ void tst_qqmlecmascript::dependenciesWithFunctions()
void tst_qqmlecmascript::deferredProperties()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deferredProperties.qml"));
MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
@@ -950,6 +964,7 @@ void tst_qqmlecmascript::deferredProperties()
// Check errors on deferred properties are correctly emitted
void tst_qqmlecmascript::deferredPropertiesErrors()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
@@ -958,7 +973,7 @@ void tst_qqmlecmascript::deferredPropertiesErrors()
QVERIFY(!object->objectProperty());
QVERIFY(!object->objectProperty2());
- QString warning = component.url().toString() + ":6:21: Unable to assign [undefined] to QObject*";
+ QString warning = component.url().toString() + ":6:5: Unable to assign [undefined] to QObject*";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
qmlExecuteDeferred(object);
@@ -969,6 +984,7 @@ void tst_qqmlecmascript::deferredPropertiesErrors()
void tst_qqmlecmascript::deferredPropertiesInComponents()
{
// Test that it works when the property is set inside and outside component
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deferredPropertiesInComponents.qml"));
QObject *object = component.create();
if (!object)
@@ -1002,6 +1018,7 @@ void tst_qqmlecmascript::deferredPropertiesInDestruction()
//Test that the component does not get created at all if creation is deferred until the containing context is destroyed
//Very specific operation ordering is needed for this to occur, currently accessing object from object destructor.
//
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deferredPropertiesInDestruction.qml"));
QObject *object = component.create();
if (!object)
@@ -1012,6 +1029,7 @@ void tst_qqmlecmascript::deferredPropertiesInDestruction()
void tst_qqmlecmascript::extensionObjects()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("extensionObjects.qml"));
MyExtendedObject *object =
qobject_cast<MyExtendedObject *>(component.create());
@@ -1037,6 +1055,7 @@ void tst_qqmlecmascript::extensionObjects()
void tst_qqmlecmascript::overrideExtensionProperties()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
OverrideDefaultPropertyObject *object =
qobject_cast<OverrideDefaultPropertyObject *>(component.create());
@@ -1049,6 +1068,8 @@ void tst_qqmlecmascript::overrideExtensionProperties()
void tst_qqmlecmascript::attachedProperties()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("attachedProperty.qml"));
QObject *object = component.create();
@@ -1090,6 +1111,8 @@ void tst_qqmlecmascript::attachedProperties()
void tst_qqmlecmascript::enums()
{
+ QQmlEngine engine;
+
// Existent enums
{
QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
@@ -1119,13 +1142,13 @@ void tst_qqmlecmascript::enums()
{
QUrl file = testFileUrl("enums.2.qml");
QString w1 = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'MyEnum' for property 'MyUnregisteredEnumTypeObject::enumProperty'");
- QString w2 = QLatin1String("QQmlExpression: Expression ") + testFileUrl("enums.2.qml").toString() + QLatin1String(":9:21 depends on non-NOTIFYable properties:");
+ QString w2 = QLatin1String("QQmlExpression: Expression ") + testFileUrl("enums.2.qml").toString() + QLatin1String(":9:5 depends on non-NOTIFYable properties:");
QString w3 = QLatin1String(" MyUnregisteredEnumTypeObject::enumProperty");
- QString w4 = file.toString() + ":7:21: Unable to assign [undefined] to int";
- QString w5 = file.toString() + ":8:21: Unable to assign [undefined] to int";
- QString w6 = file.toString() + ":9:21: Unable to assign [undefined] to int";
- QString w7 = file.toString() + ":13:23: Unable to assign [undefined] to [unknown property type]";
- QString w8 = file.toString() + ":31:23: Unable to assign int to [unknown property type]";
+ QString w4 = file.toString() + ":7:5: Unable to assign [undefined] to int";
+ QString w5 = file.toString() + ":8:5: Unable to assign [undefined] to int";
+ QString w6 = file.toString() + ":9:5: Unable to assign [undefined] to int";
+ QString w7 = file.toString() + ":13:9: Unable to assign [undefined] to [unknown property type]";
+ QString w8 = file.toString() + ":31:9: Unable to assign int to [unknown property type]";
QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
@@ -1196,6 +1219,7 @@ void tst_qqmlecmascript::enums()
void tst_qqmlecmascript::valueTypeFunctions()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
QVERIFY(obj != nullptr);
@@ -1211,6 +1235,8 @@ binding.
*/
void tst_qqmlecmascript::constantsOverrideBindings()
{
+ QQmlEngine engine;
+
// From ECMAScript
{
QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
@@ -1288,6 +1314,7 @@ the original binding to be disabled.
*/
void tst_qqmlecmascript::outerBindingOverridesInnerBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine,
testFileUrl("outerBindingOverridesInnerBinding.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -1317,9 +1344,10 @@ Tests for a regression where this used to crash.
*/
void tst_qqmlecmascript::nonExistentAttachedObject()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
- QString warning = component.url().toString() + ":4:21: Unable to assign [undefined] to QString";
+ QString warning = component.url().toString() + ":4:5: Unable to assign [undefined] to QString";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
@@ -1330,6 +1358,8 @@ void tst_qqmlecmascript::nonExistentAttachedObject()
void tst_qqmlecmascript::scope()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("scope.qml"));
QObject *object = component.create();
@@ -1420,6 +1450,7 @@ void tst_qqmlecmascript::scope()
// importing context
void tst_qqmlecmascript::importScope()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("importScope.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -1435,6 +1466,7 @@ is essentially a test of QQmlMetaType::copy()
*/
void tst_qqmlecmascript::signalParameterTypes()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != nullptr);
@@ -1462,6 +1494,7 @@ Test that two JS objects for the same QObject compare as equal.
*/
void tst_qqmlecmascript::objectsCompareAsEqual()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -1482,6 +1515,7 @@ Tests for a regression where the binding would not reevaluate.
*/
void tst_qqmlecmascript::aliasPropertyAndBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -1503,6 +1537,7 @@ and that the aliased property is reset correctly if possible.
*/
void tst_qqmlecmascript::aliasPropertyReset()
{
+ QQmlEngine engine;
QObject *object = nullptr;
// test that a manual write (of undefined) to a resettable aliased property succeeds
@@ -1565,7 +1600,7 @@ void tst_qqmlecmascript::aliasPropertyReset()
// test that a manual write (of undefined) to a non-resettable property fails properly
QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
- QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
+ QString warning1 = url.toString() + QLatin1String(": Error: Cannot assign [undefined] to int");
QQmlComponent e1(&engine, url);
object = e1.create();
QVERIFY(object != nullptr);
@@ -1631,6 +1666,7 @@ void tst_qqmlecmascript::componentCreation()
QFETCH(QString, creationError);
QFETCH(QString, createdParent);
+ QQmlEngine engine;
QUrl testUrl(testFileUrl("componentCreation.qml"));
if (!creationError.isEmpty()) {
@@ -1677,6 +1713,7 @@ void tst_qqmlecmascript::dynamicCreation()
QFETCH(QString, method);
QFETCH(QString, createdName);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -1694,6 +1731,8 @@ void tst_qqmlecmascript::dynamicCreation()
*/
void tst_qqmlecmascript::dynamicDestruction()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
QPointer<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
@@ -1777,6 +1816,7 @@ void tst_qqmlecmascript::dynamicDestruction()
*/
void tst_qqmlecmascript::objectToString()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qmlToString.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -1797,6 +1837,7 @@ void tst_qqmlecmascript::objectHasOwnProperty()
QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+ QQmlEngine engine;
QQmlComponent component(&engine, url);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -1843,6 +1884,8 @@ This test is best run under valgrind to ensure no invalid memory access occur.
*/
void tst_qqmlecmascript::selfDeletingBinding()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
QObject *object = component.create();
@@ -1869,6 +1912,7 @@ and no synthesiszed properties).
*/
void tst_qqmlecmascript::extendedObjectPropertyLookup()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -1880,6 +1924,7 @@ Test that extended object properties can be accessed correctly.
*/
void tst_qqmlecmascript::extendedObjectPropertyLookup2()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -1896,6 +1941,7 @@ Test failure when trying to create and uncreatable extended type object.
*/
void tst_qqmlecmascript::uncreatableExtendedObjectFailureCheck()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("uncreatableExtendedObjectFailureCheck.qml"));
QObject *object = component.create();
@@ -1907,6 +1953,7 @@ Test that an subclass of an uncreatable extended object contains all the require
*/
void tst_qqmlecmascript::extendedObjectPropertyLookup3()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup3.qml"));
QObject *object = component.create();
@@ -1927,6 +1974,7 @@ Test file/lineNumbers for binding/Script errors.
*/
void tst_qqmlecmascript::scriptErrors()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("scriptErrors.qml"));
QString url = component.url().toString();
@@ -1935,7 +1983,7 @@ void tst_qqmlecmascript::scriptErrors()
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
QString warning4 = url + ":13: ReferenceError: a is not defined";
QString warning5 = url + ":11: ReferenceError: a is not defined";
- QString warning6 = url + ":10:21: Unable to assign [undefined] to int";
+ QString warning6 = url + ":10:5: Unable to assign [undefined] to int";
QString warning7 = url + ":15: TypeError: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
@@ -1964,6 +2012,7 @@ Test file/lineNumbers for inline functions.
*/
void tst_qqmlecmascript::functionErrors()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("functionErrors.qml"));
QString url = component.url().toString();
@@ -1994,6 +2043,7 @@ Test various errors that can occur when assigning a property from script
*/
void tst_qqmlecmascript::propertyAssignmentErrors()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
QString url = component.url().toString();
@@ -2013,6 +2063,7 @@ a signal script.
*/
void tst_qqmlecmascript::signalTriggeredBindings()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -2041,6 +2092,7 @@ Test that list properties can be iterated from ECMAScript
*/
void tst_qqmlecmascript::listProperties()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("listProperties.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -2055,6 +2107,7 @@ void tst_qqmlecmascript::listProperties()
void tst_qqmlecmascript::exceptionClearsOnReeval()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
QString url = component.url().toString();
@@ -2078,6 +2131,7 @@ void tst_qqmlecmascript::exceptionClearsOnReeval()
void tst_qqmlecmascript::exceptionSlotProducesWarning()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
QString url = component.url().toString();
@@ -2091,6 +2145,7 @@ void tst_qqmlecmascript::exceptionSlotProducesWarning()
void tst_qqmlecmascript::exceptionBindingProducesWarning()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
QString url = component.url().toString();
@@ -2105,6 +2160,7 @@ void tst_qqmlecmascript::exceptionBindingProducesWarning()
void tst_qqmlecmascript::compileInvalidBinding()
{
// QTBUG-23387: ensure that invalid bindings don't cause a crash.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("v8bindingException.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -2114,6 +2170,8 @@ void tst_qqmlecmascript::compileInvalidBinding()
// Check that transient binding errors are not displayed
void tst_qqmlecmascript::transientErrors()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("transientErrors.qml"));
@@ -2145,6 +2203,7 @@ void tst_qqmlecmascript::transientErrors()
// Check that errors during shutdown are minimized
void tst_qqmlecmascript::shutdownErrors()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("shutdownErrors.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -2158,6 +2217,7 @@ void tst_qqmlecmascript::shutdownErrors()
void tst_qqmlecmascript::compositePropertyType()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("compositePropertyType.qml"));
QTest::ignoreMessage(QtDebugMsg, "hello world");
@@ -2168,6 +2228,7 @@ void tst_qqmlecmascript::compositePropertyType()
// QTBUG-5759
void tst_qqmlecmascript::jsObject()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("jsObject.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -2179,6 +2240,8 @@ void tst_qqmlecmascript::jsObject()
void tst_qqmlecmascript::undefinedResetsProperty()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
QObject *object = component.create();
@@ -2214,6 +2277,7 @@ void tst_qqmlecmascript::undefinedResetsProperty()
// Aliases to variant properties should work
void tst_qqmlecmascript::qtbug_22464()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_22464.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -2225,6 +2289,7 @@ void tst_qqmlecmascript::qtbug_22464()
void tst_qqmlecmascript::qtbug_21580()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_21580.qml"));
QObject *object = component.create();
@@ -2238,6 +2303,7 @@ void tst_qqmlecmascript::qtbug_21580()
// Causes a v8 binding, but not all v8 bindings to be destroyed during evaluation
void tst_qqmlecmascript::singleV8BindingDestroyedDuringEvaluation()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("singleV8BindingDestroyedDuringEvaluation.qml"));
QObject *object = component.create();
@@ -2248,6 +2314,7 @@ void tst_qqmlecmascript::singleV8BindingDestroyedDuringEvaluation()
// QTBUG-6781
void tst_qqmlecmascript::bug1()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("bug.1.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -2268,6 +2335,7 @@ void tst_qqmlecmascript::bug1()
#ifndef QT_NO_WIDGETS
void tst_qqmlecmascript::bug2()
{
+ QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
@@ -2281,6 +2349,7 @@ void tst_qqmlecmascript::bug2()
// Don't crash in createObject when the component has errors.
void tst_qqmlecmascript::dynamicCreationCrash()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -2331,6 +2400,8 @@ void tst_qqmlecmascript::dynamicCreationOwnership()
void tst_qqmlecmascript::regExpBug()
{
+ QQmlEngine engine;
+
//QTBUG-9367
{
QQmlComponent component(&engine, testFileUrl("regExp.qml"));
@@ -2357,7 +2428,7 @@ static inline bool evaluate_error(QV4::ExecutionEngine *v4, const QV4::Value &o,
QLatin1String(source) + QLatin1String(" })");
QV4::Scope scope(v4);
- QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource);
+ QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource);
program.inheritContext = true;
QV4::ScopedFunctionObject function(scope, program.run());
@@ -2383,7 +2454,7 @@ static inline bool evaluate_value(QV4::ExecutionEngine *v4, const QV4::Value &o,
QLatin1String(source) + QLatin1String(" })");
QV4::Scope scope(v4);
- QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource);
+ QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource);
program.inheritContext = true;
QV4::ScopedFunctionObject function(scope, program.run());
@@ -2414,7 +2485,7 @@ static inline QV4::ReturnedValue evaluate(QV4::ExecutionEngine *v4, const QV4::V
QV4::Scope scope(v4);
- QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::EvalCode, functionSource);
+ QV4::Script program(QV4::ScopedContext(scope, scope.engine->rootContext()), QV4::Compiler::ContextType::Eval, functionSource);
program.inheritContext = true;
QV4::ScopedFunctionObject function(scope, program.run());
@@ -3058,6 +3129,7 @@ void tst_qqmlecmascript::resolveClashingProperties()
// QTBUG-13047 (check that you can pass registered object types as args)
void tst_qqmlecmascript::invokableObjectArg()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("invokableObjectArg.qml"));
QObject *o = component.create();
@@ -3072,6 +3144,7 @@ void tst_qqmlecmascript::invokableObjectArg()
// QTBUG-13047 (check that you can return registered object types from methods)
void tst_qqmlecmascript::invokableObjectRet()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("invokableObjectRet.qml"));
QObject *o = component.create();
@@ -3082,6 +3155,7 @@ void tst_qqmlecmascript::invokableObjectRet()
void tst_qqmlecmascript::invokableEnumRet()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("invokableEnumRet.qml"));
QObject *o = component.create();
@@ -3093,6 +3167,7 @@ void tst_qqmlecmascript::invokableEnumRet()
// QTBUG-5675
void tst_qqmlecmascript::listToVariant()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("listToVariant.qml"));
MyQmlContainer container;
@@ -3113,6 +3188,7 @@ void tst_qqmlecmascript::listToVariant()
// QTBUG-16316
void tst_qqmlecmascript::listAssignment()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("listAssignment.qml"));
QObject *obj = component.create();
QCOMPARE(obj->property("list1length").toInt(), 2);
@@ -3151,6 +3227,7 @@ void tst_qqmlecmascript::multiEngineObject()
// Test that references to QObjects are cleanup when the object is destroyed
void tst_qqmlecmascript::deletedObject()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
QObject *object = component.create();
@@ -3165,6 +3242,7 @@ void tst_qqmlecmascript::deletedObject()
void tst_qqmlecmascript::attachedPropertyScope()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
QObject *object = component.create();
@@ -3185,6 +3263,8 @@ void tst_qqmlecmascript::attachedPropertyScope()
void tst_qqmlecmascript::scriptConnect()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
@@ -3266,6 +3346,8 @@ void tst_qqmlecmascript::scriptConnect()
void tst_qqmlecmascript::scriptDisconnect()
{
+ QQmlEngine engine;
+
{
QQmlComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
@@ -3356,6 +3438,7 @@ public slots:
void tst_qqmlecmascript::ownership()
{
+ QQmlEngine engine;
OwnershipObject own;
QQmlContext *context = new QQmlContext(engine.rootContext());
context->setContextObject(&own);
@@ -3453,6 +3536,7 @@ void tst_qqmlecmascript::cppOwnershipReturnValue()
// QTBUG-15697
void tst_qqmlecmascript::ownershipCustomReturnValue()
{
+ QQmlEngine engine;
CppOwnershipReturnValue source;
{
@@ -3496,6 +3580,7 @@ public slots:
void tst_qqmlecmascript::ownershipRootObject()
{
+ QQmlEngine engine;
OwnershipChangingObject own;
QQmlContext *context = new QQmlContext(engine.rootContext());
context->setContextObject(&own);
@@ -3517,6 +3602,7 @@ void tst_qqmlecmascript::ownershipRootObject()
void tst_qqmlecmascript::ownershipConsistency()
{
+ QQmlEngine engine;
OwnershipChangingObject own;
QQmlContext *context = new QQmlContext(engine.rootContext());
context->setContextObject(&own);
@@ -3547,6 +3633,7 @@ void tst_qqmlecmascript::ownershipConsistency()
void tst_qqmlecmascript::ownershipQmlIncubated()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("ownershipQmlIncubated.qml"));
QObject *object = component.create();
QVERIFY(object);
@@ -3586,6 +3673,7 @@ private:
// Tests that returning a QList<QObject*> from a method works
void tst_qqmlecmascript::qlistqobjectMethods()
{
+ QQmlEngine engine;
QListQObjectMethodsObject obj;
QQmlContext *context = new QQmlContext(engine.rootContext());
context->setContextObject(&obj);
@@ -3604,6 +3692,7 @@ void tst_qqmlecmascript::qlistqobjectMethods()
// QTBUG-9205
void tst_qqmlecmascript::strictlyEquals()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("strictlyEquals.qml"));
QObject *object = component.create();
@@ -3623,6 +3712,7 @@ void tst_qqmlecmascript::strictlyEquals()
void tst_qqmlecmascript::compiled()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("compiled.qml"));
QObject *object = component.create();
@@ -3663,6 +3753,7 @@ void tst_qqmlecmascript::compiled()
// Test that numbers assigned in bindings as strings work consistently
void tst_qqmlecmascript::numberAssignment()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("numberAssignment.qml"));
QObject *object = component.create();
@@ -3689,6 +3780,7 @@ void tst_qqmlecmascript::numberAssignment()
void tst_qqmlecmascript::propertySplicing()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertySplicing.qml"));
QObject *object = component.create();
@@ -3702,6 +3794,7 @@ void tst_qqmlecmascript::propertySplicing()
// QTBUG-16683
void tst_qqmlecmascript::signalWithUnknownTypes()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -3755,6 +3848,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant()
QFETCH(QString, expression);
QFETCH(QString, compare);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != nullptr);
@@ -3779,6 +3873,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines()
QFETCH(QString, expression);
QFETCH(QString, compare);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != nullptr);
@@ -3809,6 +3904,7 @@ void tst_qqmlecmascript::signalWithQJSValue()
QFETCH(QString, expression);
QFETCH(QString, compare);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != nullptr);
@@ -4029,6 +4125,7 @@ void tst_qqmlecmascript::singletonTypeCaching()
void tst_qqmlecmascript::singletonTypeImportOrder()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeImportOrder.qml"));
QObject *object = component.create();
QVERIFY(object);
@@ -4038,6 +4135,7 @@ void tst_qqmlecmascript::singletonTypeImportOrder()
void tst_qqmlecmascript::singletonTypeResolution()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeResolution.qml"));
QObject *object = component.create();
QVERIFY(object);
@@ -4055,7 +4153,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
QV4::Scoped<QV4::QQmlContextWrapper> qml(scope);
for (quint32 i = 0; i < scripts->getLength(); ++i) {
QQmlContextData *scriptContext, *newContext;
- qml = scripts->getIndexed(i);
+ qml = scripts->get(i);
scriptContext = qml ? qml->getContext() : nullptr;
qml = QV4::Encode::undefined();
@@ -4067,7 +4165,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
}
ctxt->engine->collectGarbage();
- qml = scripts->getIndexed(i);
+ qml = scripts->get(i);
newContext = qml ? qml->getContext() : nullptr;
QCOMPARE(scriptContext, newContext);
}
@@ -4181,7 +4279,7 @@ void tst_qqmlecmascript::importScripts_data()
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(18));
+ << (QVariantList() << QVariant(16));
QTest::newRow("import singleton type into js import")
<< testFileUrl("jsimport/testImportSingletonType.qml")
@@ -4315,6 +4413,10 @@ void tst_qqmlecmascript::importScripts()
ThreadedTestHTTPServer server(dataDirectory() + "/remote");
+ QQmlEngine engine;
+ QString dataDir(dataDirectory() + QLatin1Char('/') + QLatin1String("lib"));
+ engine.addImportPath(dataDir);
+
QStringList importPathList = engine.importPathList();
QString remotePath(server.urlString("/"));
@@ -4358,6 +4460,7 @@ void tst_qqmlecmascript::importScripts()
void tst_qqmlecmascript::importCreationContext()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("jsimport/creationContext.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY(!object.isNull());
@@ -4378,6 +4481,7 @@ void tst_qqmlecmascript::scarceResources_other()
QPixmap origPixmap(100, 100);
origPixmap.fill(Qt::blue);
QString srp_name, expectedWarning;
+ QQmlEngine engine;
QV4::ExecutionEngine *v4 = engine.handle();
ScarceResourceObject *eo = nullptr;
QObject *srsc = nullptr;
@@ -4749,6 +4853,7 @@ void tst_qqmlecmascript::scarceResources()
QFETCH(QVariantList, expectedValues);
QFETCH(QStringList, expectedErrors);
+ QQmlEngine engine;
QV4::ExecutionEngine *v4 = engine.handle();
ScarceResourceObject *eo = nullptr;
QObject *object = nullptr;
@@ -4781,6 +4886,7 @@ void tst_qqmlecmascript::scarceResources()
void tst_qqmlecmascript::propertyChangeSlots()
{
// ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -4847,6 +4953,7 @@ void tst_qqmlecmascript::propertyVar()
{
QFETCH(QUrl, qmlFile);
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -4886,6 +4993,7 @@ void tst_qqmlecmascript::propertyQJSValue()
{
QFETCH(QUrl, qmlFile);
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -4903,6 +5011,7 @@ void tst_qqmlecmascript::propertyVarCpp()
// ensure that writing to and reading from a var property from cpp works as required.
// Literal values stored in var properties can be read and written as QVariants
// of a specific type, whereas object values are read as QVariantMaps.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
object = component.create();
QVERIFY(object != nullptr);
@@ -4924,6 +5033,8 @@ void tst_qqmlecmascript::propertyVarCpp()
void tst_qqmlecmascript::propertyVarOwnership()
{
+ QQmlEngine engine;
+
// Referenced JS objects are not collected
{
QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
@@ -5005,6 +5116,7 @@ void tst_qqmlecmascript::propertyVarImplicitOwnership()
// The childObject has a reference to a different QObject. We want to ensure
// that the different item will not be cleaned up until required. IE, the childObject
// has implicit ownership of the constructed QObject.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5032,6 +5144,7 @@ void tst_qqmlecmascript::propertyVarImplicitOwnership()
void tst_qqmlecmascript::propertyVarReparent()
{
// ensure that nothing breaks if we re-parent objects
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5074,6 +5187,7 @@ void tst_qqmlecmascript::propertyVarReparentNullContext()
// sometimes reparenting can cause problems
// (eg, if the ctxt is collected, varproperties are no longer available)
// this test ensures that no crash occurs in that situation.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5110,6 +5224,7 @@ void tst_qqmlecmascript::propertyVarReparentNullContext()
void tst_qqmlecmascript::propertyVarCircular()
{
// enforce behaviour regarding circular references - ensure qdvmemo deletion.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5142,6 +5257,7 @@ void tst_qqmlecmascript::propertyVarCircular2()
{
// track deletion of JS-owned parent item with Cpp-owned child
// where the child has a var property referencing its parent.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5170,6 +5286,7 @@ void tst_qqmlecmascript::propertyVarInheritance()
{
// enforce behaviour regarding element inheritance - ensure handle disposal.
// The particular component under test here has a chain of references.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5215,6 +5332,7 @@ void tst_qqmlecmascript::propertyVarInheritance2()
{
// The particular component under test here does NOT have a chain of references; the
// only link between rootObject and childObject is that rootObject is the parent of childObject.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5248,6 +5366,7 @@ void tst_qqmlecmascript::propertyVarInheritance2()
// Ensure that QObject type conversion works on binding assignment
void tst_qqmlecmascript::elementAssign()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("elementAssign.qml"));
QObject *object = component.create();
@@ -5261,6 +5380,7 @@ void tst_qqmlecmascript::elementAssign()
// QTBUG-12457
void tst_qqmlecmascript::objectPassThroughSignals()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
QObject *object = component.create();
@@ -5274,6 +5394,7 @@ void tst_qqmlecmascript::objectPassThroughSignals()
// QTBUG-21626
void tst_qqmlecmascript::objectConversion()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectConversion.qml"));
QObject *object = component.create();
@@ -5289,6 +5410,7 @@ void tst_qqmlecmascript::objectConversion()
// QTBUG-20242
void tst_qqmlecmascript::booleanConversion()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("booleanConversion.qml"));
QObject *object = component.create();
@@ -5401,6 +5523,7 @@ void tst_qqmlecmascript::handleReferenceManagement()
void tst_qqmlecmascript::stringArg()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("stringArg.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5417,6 +5540,7 @@ void tst_qqmlecmascript::stringArg()
void tst_qqmlecmascript::readonlyDeclaration()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
QObject *object = component.create();
@@ -5434,6 +5558,8 @@ Q_DECLARE_METATYPE(QList<QString>)
Q_DECLARE_METATYPE(QList<QUrl>)
void tst_qqmlecmascript::sequenceConversionRead()
{
+ QQmlEngine engine;
+
{
QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
QQmlComponent component(&engine, qmlFile);
@@ -5514,6 +5640,7 @@ void tst_qqmlecmascript::sequenceConversionRead()
void tst_qqmlecmascript::sequenceConversionWrite()
{
+ QQmlEngine engine;
{
QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
QQmlComponent component(&engine, qmlFile);
@@ -5562,6 +5689,7 @@ void tst_qqmlecmascript::sequenceConversionArray()
{
// ensure that in JS the returned sequences act just like normal JS Arrays.
QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
@@ -5583,6 +5711,7 @@ void tst_qqmlecmascript::sequenceConversionIndexes()
// ensure that we gracefully fail if unsupported index values are specified.
// Qt container classes only support non-negative, signed integer index values.
QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5604,6 +5733,7 @@ void tst_qqmlecmascript::sequenceConversionThreads()
// ensure that sequence conversion operations work correctly in a worker thread
// and that serialisation between the main and worker thread succeeds.
QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5641,6 +5771,7 @@ void tst_qqmlecmascript::sequenceConversionThreads()
void tst_qqmlecmascript::sequenceConversionBindings()
{
+ QQmlEngine engine;
{
QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
QQmlComponent component(&engine, qmlFile);
@@ -5656,7 +5787,7 @@ void tst_qqmlecmascript::sequenceConversionBindings()
{
QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
- QString warning = QString(QLatin1String("%1:17:27: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
+ QString warning = QString(QLatin1String("%1:17:9: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
@@ -5668,6 +5799,7 @@ void tst_qqmlecmascript::sequenceConversionBindings()
void tst_qqmlecmascript::sequenceConversionCopy()
{
QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -5686,6 +5818,8 @@ void tst_qqmlecmascript::sequenceConversionCopy()
void tst_qqmlecmascript::assignSequenceTypes()
{
+ QQmlEngine engine;
+
// test binding array to sequence type property
{
QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
@@ -5784,12 +5918,23 @@ void tst_qqmlecmascript::assignSequenceTypes()
QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
delete object;
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.8.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != nullptr);
+ QVariant result;
+ QMetaObject::invokeMethod(object.data(), "tryWritingReadOnlySequence", Q_RETURN_ARG(QVariant, result));
+ QVERIFY(result.type() == QVariant::Bool);
+ QVERIFY(result.toBool());
+ }
}
// Test that assigning a null object works
// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
void tst_qqmlecmascript::nullObjectBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
QObject *object = component.create();
@@ -5802,6 +5947,7 @@ void tst_qqmlecmascript::nullObjectBinding()
void tst_qqmlecmascript::nullObjectInitializer()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("nullObjectInitializer.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -5832,7 +5978,7 @@ void tst_qqmlecmascript::nullObjectInitializer()
{
const int propertyIndex = obj->metaObject()->indexOfProperty("testProperty");
QVERIFY(propertyIndex > 0);
- QVERIFY(ddata->hasBindingBit(propertyIndex));
+ QVERIFY(!ddata->hasBindingBit(propertyIndex));
}
QVERIFY(obj->property("success").toBool());
@@ -5869,6 +6015,7 @@ void tst_qqmlecmascript::deletedEngine()
// Test the crashing part of QTBUG-9705
void tst_qqmlecmascript::libraryScriptAssert()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
QObject *object = component.create();
@@ -5879,6 +6026,7 @@ void tst_qqmlecmascript::libraryScriptAssert()
void tst_qqmlecmascript::variantsAssignedUndefined()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
QObject *object = component.create();
@@ -5898,6 +6046,7 @@ void tst_qqmlecmascript::variantsAssignedUndefined()
void tst_qqmlecmascript::variants()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("variants.qml"));
QObject *object = component.create();
@@ -5921,6 +6070,7 @@ void tst_qqmlecmascript::variants()
void tst_qqmlecmascript::qtbug_9792()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_9792.qml"));
QQmlContext *context = new QQmlContext(engine.rootContext());
@@ -5945,6 +6095,7 @@ void tst_qqmlecmascript::qtbug_9792()
// Verifies that QPointer<>s used in the vmemetaobject are cleaned correctly
void tst_qqmlecmascript::qtcreatorbug_1289()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
QObject *o = component.create();
@@ -5966,6 +6117,7 @@ void tst_qqmlecmascript::qtcreatorbug_1289()
// Test that we shut down without stupid warnings
void tst_qqmlecmascript::noSpuriousWarningsAtShutdown()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
@@ -5994,6 +6146,7 @@ void tst_qqmlecmascript::noSpuriousWarningsAtShutdown()
void tst_qqmlecmascript::canAssignNullToQObject()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
@@ -6023,13 +6176,14 @@ void tst_qqmlecmascript::canAssignNullToQObject()
void tst_qqmlecmascript::functionAssignment_fromBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
QString url = component.url().toString();
- QString w1 = url + ":4:25: Unable to assign a function to a property of any type other than var.";
- QString w2 = url + ":5:25: Invalid use of Qt.binding() in a binding declaration.";
- QString w3 = url + ":6:21: Invalid use of Qt.binding() in a binding declaration.";
- QString w4 = url + ":7:15: Invalid use of Qt.binding() in a binding declaration.";
+ QString w1 = url + ":4:5: Unable to assign a function to a property of any type other than var.";
+ QString w2 = url + ":5:5: Invalid use of Qt.binding() in a binding declaration.";
+ QString w3 = url + ":6:5: Invalid use of Qt.binding() in a binding declaration.";
+ QString w4 = url + ":7:5: Invalid use of Qt.binding() in a binding declaration.";
QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, w2.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, w3.toLatin1().constData());
@@ -6047,6 +6201,7 @@ void tst_qqmlecmascript::functionAssignment_fromJS()
{
QFETCH(QString, triggerProperty);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
@@ -6079,6 +6234,7 @@ void tst_qqmlecmascript::functionAssignment_fromJS_data()
void tst_qqmlecmascript::functionAssignmentfromJS_invalid()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
@@ -6103,6 +6259,7 @@ void tst_qqmlecmascript::functionAssignmentfromJS_invalid()
void tst_qqmlecmascript::functionAssignment_afterBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("functionAssignment.3.qml"));
QString url = component.url().toString();
@@ -6119,6 +6276,7 @@ void tst_qqmlecmascript::functionAssignment_afterBinding()
void tst_qqmlecmascript::eval()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("eval.qml"));
QObject *o = component.create();
@@ -6135,6 +6293,7 @@ void tst_qqmlecmascript::eval()
void tst_qqmlecmascript::function()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("function.qml"));
QObject *o = component.create();
@@ -6150,6 +6309,7 @@ void tst_qqmlecmascript::function()
// Test the "Qt.include" method
void tst_qqmlecmascript::include()
{
+ QQmlEngine engine;
// Non-library relative include
{
QQmlComponent component(&engine, testFileUrl("include.qml"));
@@ -6208,6 +6368,14 @@ void tst_qqmlecmascript::include()
delete o;
}
+ // Including file with ".pragma library", shadowing a global var
+ {
+ QQmlComponent component(&engine, testFileUrl("include_pragma_shadow.qml"));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ QCOMPARE(o->property("result").toBool(), true);
+ }
+
// Remote - error
{
TestHTTPServer server;
@@ -6254,6 +6422,7 @@ void tst_qqmlecmascript::includeRemoteSuccess()
QVERIFY2(server.listen(), qPrintable(server.errorString()));
server.serveDirectory(dataDirectory());
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("include_remote.qml"));
QObject *o = component.beginCreate(engine.rootContext());
QVERIFY(o != nullptr);
@@ -6280,6 +6449,7 @@ void tst_qqmlecmascript::includeRemoteSuccess()
void tst_qqmlecmascript::signalHandlers()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("signalHandlers.qml"));
QScopedPointer<QObject> o(component.create());
QVERIFY(o != nullptr);
@@ -6340,6 +6510,7 @@ void tst_qqmlecmascript::qtbug_37351()
void tst_qqmlecmascript::qtbug_10696()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_10696.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6348,6 +6519,7 @@ void tst_qqmlecmascript::qtbug_10696()
void tst_qqmlecmascript::qtbug_11606()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_11606.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6357,6 +6529,7 @@ void tst_qqmlecmascript::qtbug_11606()
void tst_qqmlecmascript::qtbug_11600()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_11600.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6366,6 +6539,7 @@ void tst_qqmlecmascript::qtbug_11600()
void tst_qqmlecmascript::qtbug_21864()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_21864.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6375,6 +6549,7 @@ void tst_qqmlecmascript::qtbug_21864()
void tst_qqmlecmascript::rewriteMultiLineStrings()
{
+ QQmlEngine engine;
{
// QTBUG-23387
QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
@@ -6395,6 +6570,7 @@ void tst_qqmlecmascript::rewriteMultiLineStrings()
void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()
{
// QTBUG-23375
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml"));
QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined");
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
@@ -6409,6 +6585,7 @@ void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()
// Reading and writing non-scriptable properties should fail
void tst_qqmlecmascript::nonscriptable()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nonscriptable.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6420,6 +6597,7 @@ void tst_qqmlecmascript::nonscriptable()
// deleteLater() should not be callable from QML
void tst_qqmlecmascript::deleteLater()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deleteLater.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6430,6 +6608,7 @@ void tst_qqmlecmascript::deleteLater()
// objectNameChanged() should be usable from QML
void tst_qqmlecmascript::objectNameChangedSignal()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectNameChangedSignal.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6442,6 +6621,7 @@ void tst_qqmlecmascript::objectNameChangedSignal()
// destroyed() should not be usable from QML
void tst_qqmlecmascript::destroyedSignal()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("destroyedSignal.qml"));
QVERIFY(component.isError());
@@ -6451,6 +6631,7 @@ void tst_qqmlecmascript::destroyedSignal()
void tst_qqmlecmascript::in()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("in.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6461,6 +6642,7 @@ void tst_qqmlecmascript::in()
void tst_qqmlecmascript::typeOf()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("typeOf.qml"));
QObject *o = component.create();
@@ -6481,6 +6663,7 @@ void tst_qqmlecmascript::typeOf()
void tst_qqmlecmascript::qtbug_24448()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_24448.qml"));
QScopedPointer<QObject> o(component.create());
QVERIFY(o != nullptr);
@@ -6489,6 +6672,7 @@ void tst_qqmlecmascript::qtbug_24448()
void tst_qqmlecmascript::sharedAttachedObject()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6500,6 +6684,7 @@ void tst_qqmlecmascript::sharedAttachedObject()
// QTBUG-13999
void tst_qqmlecmascript::objectName()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("objectName.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6517,6 +6702,7 @@ void tst_qqmlecmascript::objectName()
void tst_qqmlecmascript::writeRemovesBinding()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6529,6 +6715,7 @@ void tst_qqmlecmascript::writeRemovesBinding()
// Test bindings assigned to alias properties actually assign to the alias' target
void tst_qqmlecmascript::aliasBindingsAssignCorrectly()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
QObject *o = component.create();
QVERIFY(o != nullptr);
@@ -6541,6 +6728,7 @@ void tst_qqmlecmascript::aliasBindingsAssignCorrectly()
// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
void tst_qqmlecmascript::aliasBindingsOverrideTarget()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
QObject *o = component.create();
@@ -6575,6 +6763,7 @@ void tst_qqmlecmascript::aliasBindingsOverrideTarget()
// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
void tst_qqmlecmascript::aliasWritesOverrideBindings()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
QObject *o = component.create();
@@ -6610,6 +6799,7 @@ void tst_qqmlecmascript::aliasWritesOverrideBindings()
// QTBUG-20200
void tst_qqmlecmascript::aliasToCompositeElement()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
QObject *object = component.create();
@@ -6620,6 +6810,7 @@ void tst_qqmlecmascript::aliasToCompositeElement()
void tst_qqmlecmascript::qtbug_20344()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_20344.qml"));
QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
@@ -6633,6 +6824,7 @@ void tst_qqmlecmascript::qtbug_20344()
void tst_qqmlecmascript::revisionErrors()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
QString url = component.url().toString();
@@ -6690,6 +6882,7 @@ void tst_qqmlecmascript::revisionErrors()
void tst_qqmlecmascript::revision()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
QString url = component.url().toString();
@@ -6736,6 +6929,7 @@ void tst_qqmlecmascript::revision()
void tst_qqmlecmascript::realToInt()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("realToInt.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != nullptr);
@@ -6748,6 +6942,7 @@ void tst_qqmlecmascript::realToInt()
void tst_qqmlecmascript::urlProperty()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
@@ -6762,6 +6957,7 @@ void tst_qqmlecmascript::urlProperty()
void tst_qqmlecmascript::urlPropertyWithEncoding()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
@@ -6776,6 +6972,7 @@ void tst_qqmlecmascript::urlPropertyWithEncoding()
void tst_qqmlecmascript::urlListPropertyWithEncoding()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("urlListProperty.qml"));
QObject *object = component.create();
@@ -6796,6 +6993,7 @@ void tst_qqmlecmascript::urlListPropertyWithEncoding()
void tst_qqmlecmascript::dynamicString()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("dynamicString.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6805,6 +7003,7 @@ void tst_qqmlecmascript::dynamicString()
void tst_qqmlecmascript::deleteLaterObjectMethodCall()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deleteLaterObjectMethodCall.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6812,6 +7011,7 @@ void tst_qqmlecmascript::deleteLaterObjectMethodCall()
void tst_qqmlecmascript::automaticSemicolon()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6819,6 +7019,7 @@ void tst_qqmlecmascript::automaticSemicolon()
void tst_qqmlecmascript::compatibilitySemicolon()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("compatibilitySemicolon.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6826,6 +7027,7 @@ void tst_qqmlecmascript::compatibilitySemicolon()
void tst_qqmlecmascript::incrDecrSemicolon1()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon1.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6833,6 +7035,7 @@ void tst_qqmlecmascript::incrDecrSemicolon1()
void tst_qqmlecmascript::incrDecrSemicolon2()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon2.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6840,6 +7043,7 @@ void tst_qqmlecmascript::incrDecrSemicolon2()
void tst_qqmlecmascript::incrDecrSemicolon_error1()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon_error1.qml"));
QObject *object = component.create();
QVERIFY(!object);
@@ -6847,6 +7051,7 @@ void tst_qqmlecmascript::incrDecrSemicolon_error1()
void tst_qqmlecmascript::unaryExpression()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("unaryExpression.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6855,6 +7060,7 @@ void tst_qqmlecmascript::unaryExpression()
// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
void tst_qqmlecmascript::doubleEvaluate()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6871,6 +7077,7 @@ void tst_qqmlecmascript::doubleEvaluate()
void tst_qqmlecmascript::nonNotifyable()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml"));
QQmlTestMessageHandler messageHandler;
@@ -6881,7 +7088,7 @@ void tst_qqmlecmascript::nonNotifyable()
QString expected1 = QLatin1String("QQmlExpression: Expression ") +
component.url().toString() +
- QLatin1String(":5:24 depends on non-NOTIFYable properties:");
+ QLatin1String(":5:5 depends on non-NOTIFYable properties:");
QString expected2 = QLatin1String(" ") +
QLatin1String(object->metaObject()->className()) +
QLatin1String("::value");
@@ -6895,6 +7102,7 @@ void tst_qqmlecmascript::nonNotifyable()
void tst_qqmlecmascript::nonNotifyableConstant()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nonNotifyableConstant.qml"));
QQmlTestMessageHandler messageHandler;
@@ -6907,6 +7115,7 @@ void tst_qqmlecmascript::nonNotifyableConstant()
void tst_qqmlecmascript::forInLoop()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("forInLoop.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6927,6 +7136,7 @@ void tst_qqmlecmascript::forInLoop()
// An object the binding depends on is deleted while the binding is still running
void tst_qqmlecmascript::deleteWhileBindingRunning()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -6937,6 +7147,7 @@ void tst_qqmlecmascript::qtbug_22679()
{
MyQmlObject object;
object.setStringProperty(QLatin1String("Please work correctly"));
+ QQmlEngine engine;
engine.rootContext()->setContextProperty("contextProp", &object);
QQmlComponent component(&engine, testFileUrl("qtbug_22679.qml"));
@@ -6966,6 +7177,7 @@ void tst_qqmlecmascript::qtbug_22843()
fileName += QLatin1String(".library");
fileName += QLatin1String(".qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl(fileName));
QString url = component.url().toString();
@@ -6978,6 +7190,7 @@ void tst_qqmlecmascript::qtbug_22843()
void tst_qqmlecmascript::switchStatement()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -7050,7 +7263,7 @@ void tst_qqmlecmascript::switchStatement()
{
QQmlComponent component(&engine, testFileUrl("switchStatement.4.qml"));
- QString warning = component.url().toString() + ":4:12: Unable to assign [undefined] to int";
+ QString warning = component.url().toString() + ":4:5: Unable to assign [undefined] to int";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -7124,6 +7337,7 @@ void tst_qqmlecmascript::switchStatement()
void tst_qqmlecmascript::withStatement()
{
+ QQmlEngine engine;
{
QUrl url = testFileUrl("withStatement.1.qml");
QQmlComponent component(&engine, url);
@@ -7136,6 +7350,7 @@ void tst_qqmlecmascript::withStatement()
void tst_qqmlecmascript::tryStatement()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
@@ -7157,7 +7372,7 @@ void tst_qqmlecmascript::tryStatement()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(object->value(), 1);
+ QVERIFY(object->qjsvalue().isUndefined());
}
{
@@ -7165,7 +7380,7 @@ void tst_qqmlecmascript::tryStatement()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(object->value(), 1);
+ QVERIFY(object->qjsvalue().isUndefined());
}
}
@@ -7211,6 +7426,7 @@ void tst_qqmlecmascript::invokableWithQObjectDerived()
void tst_qqmlecmascript::realTypePrecision()
{
// Properties and signal parameters of type real should have double precision.
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("realTypePrecision.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
@@ -7261,8 +7477,8 @@ void tst_qqmlecmascript::bindingBoundFunctions()
void tst_qqmlecmascript::deleteRootObjectInCreation()
{
- {
QQmlEngine engine;
+ {
QQmlComponent c(&engine, testFileUrl("deleteRootObjectInCreation.qml"));
QObject *obj = c.create();
QVERIFY(obj != nullptr);
@@ -7401,7 +7617,7 @@ void tst_qqmlecmascript::onDestructionViaGC()
QVERIFY2(!weakReferenceMutator.isNull(), qPrintable(component.errorString()));
weakReferenceMutator->init(v4, weakRef.data(), &mutatorResult);
- v4->memoryManager->allocObject<QV4::WeakReferenceSentinel>(weakRef.data(), &sentinelResult);
+ v4->memoryManager->allocate<QV4::WeakReferenceSentinel>(weakRef.data(), &sentinelResult);
}
gc(engine);
@@ -7475,6 +7691,7 @@ void tst_qqmlecmascript::signalEmitted()
// QTBUG-25647
void tst_qqmlecmascript::threadSignal()
{
+ QQmlEngine engine;
{
QQmlComponent c(&engine, testFileUrl("threadSignal.qml"));
QScopedPointer<QObject> object(c.create());
@@ -7493,6 +7710,7 @@ void tst_qqmlecmascript::threadSignal()
// ensure that the qqmldata::destroyed() handler doesn't cause problems
void tst_qqmlecmascript::qqmldataDestroyed()
{
+ QQmlEngine engine;
// gc cleans up a qobject, later the qqmldata destroyed handler will run.
{
QQmlComponent c(&engine, testFileUrl("qqmldataDestroyed.qml"));
@@ -7526,6 +7744,7 @@ void tst_qqmlecmascript::qqmldataDestroyed()
void tst_qqmlecmascript::secondAlias()
{
+ QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("secondAlias.qml"));
QObject *object = c.create();
QVERIFY(object != nullptr);
@@ -7536,6 +7755,7 @@ void tst_qqmlecmascript::secondAlias()
// An alias to a var property works
void tst_qqmlecmascript::varAlias()
{
+ QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("varAlias.qml"));
QObject *object = c.create();
QVERIFY(object != nullptr);
@@ -7546,6 +7766,7 @@ void tst_qqmlecmascript::varAlias()
// Used to trigger an assert in the lazy meta object creation stage
void tst_qqmlecmascript::overrideDataAssert()
{
+ QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("overrideDataAssert.qml"));
QObject *object = c.create();
QVERIFY(object != nullptr);
@@ -7571,6 +7792,7 @@ void tst_qqmlecmascript::fallbackBindings()
{
QFETCH(QString, source);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl(source));
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
@@ -7580,6 +7802,7 @@ void tst_qqmlecmascript::fallbackBindings()
void tst_qqmlecmascript::propertyOverride()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("propertyOverride.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
@@ -7615,6 +7838,7 @@ void tst_qqmlecmascript::sequenceSort()
QFETCH(QString, function);
QFETCH(bool, useComparer);
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("sequenceSort.qml"));
QObject *object = component.create();
@@ -7631,6 +7855,7 @@ void tst_qqmlecmascript::sequenceSort()
void tst_qqmlecmascript::dateParse()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("date.qml"));
QObject *object = component.create();
@@ -7651,6 +7876,7 @@ void tst_qqmlecmascript::dateParse()
void tst_qqmlecmascript::utcDate()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("utcdate.qml"));
QObject *object = component.create();
@@ -7666,6 +7892,7 @@ void tst_qqmlecmascript::utcDate()
void tst_qqmlecmascript::negativeYear()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("negativeyear.qml"));
QObject *object = component.create();
@@ -7687,6 +7914,7 @@ void tst_qqmlecmascript::negativeYear()
void tst_qqmlecmascript::concatenatedStringPropertyAccess()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("concatenatedStringPropertyAccess.qml"));
QObject *object = component.create();
QVERIFY(object);
@@ -7732,6 +7960,7 @@ void tst_qqmlecmascript::updateCall()
// documented it can be called from within QML. Make sure
// we don't crash when calling it.
QString file("updateCall.qml");
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl(file));
QObject *object = component.create();
QVERIFY(object != nullptr);
@@ -7739,6 +7968,7 @@ void tst_qqmlecmascript::updateCall()
void tst_qqmlecmascript::numberParsing()
{
+ QQmlEngine engine;
for (int i = 1; i < 8; ++i) {
QString file("numberParsing.%1.qml");
file = file.arg(i);
@@ -7756,6 +7986,7 @@ void tst_qqmlecmascript::numberParsing()
void tst_qqmlecmascript::stringParsing()
{
+ QQmlEngine engine;
for (int i = 1; i < 7; ++i) {
QString file("stringParsing_error.%1.qml");
file = file.arg(i);
@@ -7779,6 +8010,7 @@ void tst_qqmlecmascript::push_and_shift()
void tst_qqmlecmascript::qtbug_32801()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_32801.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -7791,6 +8023,7 @@ void tst_qqmlecmascript::qtbug_32801()
void tst_qqmlecmascript::thisObject()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("thisObject.qml"));
QObject *object = component.create();
QVERIFY(object);
@@ -7800,6 +8033,7 @@ void tst_qqmlecmascript::thisObject()
void tst_qqmlecmascript::qtbug_33754()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_33754.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -7808,6 +8042,7 @@ void tst_qqmlecmascript::qtbug_33754()
void tst_qqmlecmascript::qtbug_34493()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_34493.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -7823,6 +8058,7 @@ void tst_qqmlecmascript::qtbug_34493()
// as its type*, it's parent type* and as QObject*
void tst_qqmlecmascript::singletonFromQMLToCpp()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFile("singletonTest.qml"));
QScopedPointer<QObject> obj(component.create());
if (component.errors().size())
@@ -7840,6 +8076,7 @@ void tst_qqmlecmascript::singletonFromQMLToCpp()
// and correctly compares to itself
void tst_qqmlecmascript::singletonFromQMLAndBackAndCompare()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFile("singletonTest2.qml"));
QScopedPointer<QObject> o(component.create());
if (component.errors().size())
@@ -7864,9 +8101,10 @@ void tst_qqmlecmascript::singletonFromQMLAndBackAndCompare()
void tst_qqmlecmascript::setPropertyOnInvalid()
{
+ QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("setPropertyOnNull.qml"));
- QString warning = component.url().toString() + ":4: TypeError: Type error";
+ QString warning = component.url().toString() + ":4: TypeError: Value is null and could not be converted to an object";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
QVERIFY(object);
@@ -7875,7 +8113,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid()
{
QQmlComponent component(&engine, testFileUrl("setPropertyOnUndefined.qml"));
- QString warning = component.url().toString() + ":4: TypeError: Type error";
+ QString warning = component.url().toString() + ":4: TypeError: Value is undefined and could not be converted to an object";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
QVERIFY(object);
@@ -7885,6 +8123,7 @@ void tst_qqmlecmascript::setPropertyOnInvalid()
void tst_qqmlecmascript::miscTypeTest()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("misctypetest.qml"));
QObject *object = component.create();
@@ -7913,6 +8152,7 @@ void tst_qqmlecmascript::stackLimits()
void tst_qqmlecmascript::idsAsLValues()
{
+ QQmlEngine engine;
QString err = QString(QLatin1String("%1:5 left-hand side of assignment operator is not an lvalue\n")).arg(testFileUrl("idAsLValue.qml").toString());
QQmlComponent component(&engine, testFileUrl("idAsLValue.qml"));
QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
@@ -7923,6 +8163,7 @@ void tst_qqmlecmascript::idsAsLValues()
void tst_qqmlecmascript::qtbug_34792()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug34792.qml"));
QObject *object = component.create();
@@ -7934,6 +8175,7 @@ void tst_qqmlecmascript::qtbug_34792()
void tst_qqmlecmascript::noCaptureWhenWritingProperty()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("noCaptureWhenWritingProperty.qml"));
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
@@ -7942,6 +8184,7 @@ void tst_qqmlecmascript::noCaptureWhenWritingProperty()
void tst_qqmlecmascript::singletonWithEnum()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("singletontype/singletonWithEnum.qml"));
QScopedPointer<QObject> obj(component.create());
if (obj.isNull())
@@ -7963,48 +8206,53 @@ void tst_qqmlecmascript::singletonWithEnum()
void tst_qqmlecmascript::lazyBindingEvaluation()
{
- QQmlComponent component(&engine, testFileUrl("lazyBindingEvaluation.qml"));
- QScopedPointer<QObject> obj(component.create());
- if (obj.isNull())
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("lazyBindingEvaluation.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
qDebug() << component.errors().first().toString();
- QVERIFY(!obj.isNull());
- QVariant prop = obj->property("arrayLength");
- QCOMPARE(prop.type(), QVariant::Int);
- QCOMPARE(prop.toInt(), 2);
+ QVERIFY(!obj.isNull());
+ QVariant prop = obj->property("arrayLength");
+ QCOMPARE(prop.type(), QVariant::Int);
+ QCOMPARE(prop.toInt(), 2);
}
void tst_qqmlecmascript::varPropertyAccessOnObjectWithInvalidContext()
{
- QQmlComponent component(&engine, testFileUrl("varPropertyAccessOnObjectWithInvalidContext.qml"));
- QScopedPointer<QObject> obj(component.create());
- if (obj.isNull())
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("varPropertyAccessOnObjectWithInvalidContext.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
qDebug() << component.errors().first().toString();
- QVERIFY(!obj.isNull());
- QVERIFY(obj->property("success").toBool());
+ QVERIFY(!obj.isNull());
+ QVERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext()
{
- QQmlComponent component(&engine, testFileUrl("importedScriptsAccessOnObjectWithInvalidContext.qml"));
- QScopedPointer<QObject> obj(component.create());
- if (obj.isNull())
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("importedScriptsAccessOnObjectWithInvalidContext.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
qDebug() << component.errors().first().toString();
- QVERIFY(!obj.isNull());
- QTRY_VERIFY(obj->property("success").toBool());
+ QVERIFY(!obj.isNull());
+ QTRY_VERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::importedScriptsWithoutQmlMode()
{
- QQmlComponent component(&engine, testFileUrl("importScriptsWithoutQmlMode.qml"));
- QScopedPointer<QObject> obj(component.create());
- if (obj.isNull())
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("importScriptsWithoutQmlMode.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ if (obj.isNull())
qDebug() << component.errors().first().toString();
- QVERIFY(!obj.isNull());
- QTRY_VERIFY(obj->property("success").toBool());
+ QVERIFY(!obj.isNull());
+ QTRY_VERIFY(obj->property("success").toBool());
}
void tst_qqmlecmascript::contextObjectOnLazyBindings()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("contextObjectOnLazyBindings.qml"));
QScopedPointer<QObject> obj(component.create());
if (obj.isNull())
@@ -8017,6 +8265,7 @@ void tst_qqmlecmascript::contextObjectOnLazyBindings()
void tst_qqmlecmascript::garbageCollectionDuringCreation()
{
+ QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import Qt.test 1.0\n"
"QObjectContainerWithGCOnAppend {\n"
@@ -8044,6 +8293,7 @@ void tst_qqmlecmascript::garbageCollectionDuringCreation()
void tst_qqmlecmascript::qtbug_39520()
{
+ QQmlEngine engine;
QQmlComponent component(&engine);
component.setData("import QtQuick 2.0\n"
"Item {\n"
@@ -8165,6 +8415,7 @@ void tst_qqmlecmascript::switchExpression()
void tst_qqmlecmascript::qtbug_46022()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_46022.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -8175,6 +8426,7 @@ void tst_qqmlecmascript::qtbug_46022()
void tst_qqmlecmascript::qtbug_52340()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_52340.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY(!object.isNull());
@@ -8186,6 +8438,7 @@ void tst_qqmlecmascript::qtbug_52340()
void tst_qqmlecmascript::qtbug_54589()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_54589.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -8197,11 +8450,12 @@ void tst_qqmlecmascript::qtbug_54687()
{
QJSEngine e;
// it's simple: this shouldn't crash.
- engine.evaluate("12\n----12");
+ e.evaluate("12\n----12");
}
void tst_qqmlecmascript::stringify_qtbug_50592()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("stringify_qtbug_50592.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -8389,6 +8643,7 @@ void tst_qqmlecmascript::freeze_empty_object()
void tst_qqmlecmascript::singleBlockLoops()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug_59012.qml"));
QScopedPointer<QObject> obj(component.create());
@@ -8400,6 +8655,7 @@ void tst_qqmlecmascript::singleBlockLoops()
// This fix ensures it looks up the right thing.
void tst_qqmlecmascript::qtbug_60547()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("qtbug60547/main.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
@@ -8408,6 +8664,7 @@ void tst_qqmlecmascript::qtbug_60547()
void tst_qqmlecmascript::anotherNaN()
{
+ QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("nans.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
@@ -8513,6 +8770,48 @@ void tst_qqmlecmascript::jumpStrictNotEqualUndefined()
QCOMPARE(v.toInt(), 2);
}
+void tst_qqmlecmascript::removeBindingsWithNoDependencies()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("removeBindingsWithNoDependencies.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ QVariant rect = object->property("placement");
+ QCOMPARE(rect.toRectF(), QRectF(0, 0, 100, 100));
+ const QMetaObject *metaObject = object->metaObject();
+
+ {
+ const QMetaProperty prop = metaObject->property(metaObject->indexOfProperty("placement"));
+ QVERIFY(prop.isValid());
+ QVERIFY(!QQmlPropertyPrivate::binding(object.data(), QQmlPropertyIndex(prop.propertyIndex())));
+ }
+
+ {
+ const QMetaProperty prop = metaObject->property(metaObject->indexOfProperty("partialPlacement"));
+ QVERIFY(prop.isValid());
+ QQmlAbstractBinding *vtProxyBinding = QQmlPropertyPrivate::binding(object.data(), QQmlPropertyIndex(prop.propertyIndex()));
+ QVERIFY(vtProxyBinding);
+ QVERIFY(vtProxyBinding->isValueTypeProxy());
+
+ QQmlValueTypeProxyBinding *proxy = static_cast<QQmlValueTypeProxyBinding*>(vtProxyBinding);
+ QVERIFY(!proxy->subBindings());
+ }
+
+}
+
+void tst_qqmlecmascript::temporaryDeadZone()
+{
+ QJSEngine engine;
+ QJSValue v = engine.evaluate(QString::fromLatin1("a; let a;"));
+ QVERIFY(v.isError());
+ v = engine.evaluate(QString::fromLatin1("a.name; let a;"));
+ QVERIFY(v.isError());
+ v = engine.evaluate(QString::fromLatin1("var a = {}; a[b]; let b;"));
+ QVERIFY(v.isError());
+ v = engine.evaluate(QString::fromLatin1("class C { constructor() { super[x]; let x; } }; new C()"));
+ QVERIFY(v.isError());
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 95098648fa..f58ae38264 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -79,6 +79,7 @@ private slots:
void componentFromEval();
void qrcUrls();
void cppSignalAndEval();
+ void singletonInstance();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -543,7 +544,7 @@ void tst_qqmlengine::outputWarningsToStandardError()
delete o;
QCOMPARE(messageHandler.messages().count(), 1);
- QCOMPARE(messageHandler.messages().at(0), QLatin1String("<Unknown File>:1:48: Unable to assign [undefined] to int"));
+ QCOMPARE(messageHandler.messages().at(0), QLatin1String("<Unknown File>:1:32: Unable to assign [undefined] to int"));
messageHandler.clear();
engine.setOutputWarningsToStandardError(false);
@@ -905,23 +906,19 @@ void tst_qqmlengine::qrcUrls()
QQmlEnginePrivate *pEngine = QQmlEnginePrivate::get(&engine);
{
- QQmlRefPointer<QQmlTypeData> oneQml(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.qml")),
- QQmlRefPointer<QQmlTypeData>::Adopt);
- QVERIFY(oneQml != nullptr);
- QQmlRefPointer<QQmlTypeData> twoQml(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.qml")),
- QQmlRefPointer<QQmlTypeData>::Adopt);
- QVERIFY(twoQml != nullptr);
- QCOMPARE(oneQml, twoQml);
+ QQmlRefPointer<QQmlTypeData> oneQml(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.qml")));
+ QVERIFY(oneQml.data() != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoQml(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.qml")));
+ QVERIFY(twoQml.data() != nullptr);
+ QCOMPARE(oneQml.data(), twoQml.data());
}
{
- QQmlRefPointer<QQmlTypeData> oneJS(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.js")),
- QQmlRefPointer<QQmlTypeData>::Adopt);
- QVERIFY(oneJS != nullptr);
- QQmlRefPointer<QQmlTypeData> twoJS(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.js")),
- QQmlRefPointer<QQmlTypeData>::Adopt);
- QVERIFY(twoJS != nullptr);
- QCOMPARE(oneJS, twoJS);
+ QQmlRefPointer<QQmlTypeData> oneJS(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.js")));
+ QVERIFY(oneJS.data() != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoJS(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.js")));
+ QVERIFY(twoJS.data() != nullptr);
+ QCOMPARE(oneJS.data(), twoJS.data());
}
}
@@ -956,6 +953,96 @@ void tst_qqmlengine::cppSignalAndEval()
QCOMPARE(object->property("r"), 1.1234);
}
+class CppSingleton : public QObject {
+ Q_OBJECT
+public:
+ CppSingleton() {}
+
+ static QObject *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
+ {
+ Q_UNUSED(qmlEngine);
+ Q_UNUSED(jsEngine);
+ return new CppSingleton();
+ }
+};
+
+class JsSingleton : public QObject {
+ Q_OBJECT
+public:
+ JsSingleton() {}
+
+ static QJSValue create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
+ {
+ Q_UNUSED(qmlEngine);
+ QJSValue value = jsEngine->newQObject(new JsSingleton());
+ return value;
+ }
+};
+
+class SomeQObjectClass : public QObject {
+ Q_OBJECT
+public:
+ SomeQObjectClass() : QObject(nullptr){}
+};
+
+void tst_qqmlengine::singletonInstance()
+{
+ QQmlEngine engine;
+
+ int cppSingletonTypeId = qmlRegisterSingletonType<CppSingleton>("Test", 1, 0, "CppSingleton", &CppSingleton::create);
+ int jsValueSingletonTypeId = qmlRegisterSingletonType("Test", 1, 0, "JsSingleton", &JsSingleton::create);
+
+ {
+ // Cpp QObject singleton type
+ QJSValue value = engine.singletonInstance<QJSValue>(cppSingletonTypeId);
+ QVERIFY(!value.isUndefined());
+ QVERIFY(value.isQObject());
+ QObject *instance = value.toQObject();
+ QVERIFY(instance);
+ QCOMPARE(instance->metaObject()->className(), "CppSingleton");
+ }
+
+ {
+ // QJSValue QObject singleton type
+ QJSValue value = engine.singletonInstance<QJSValue>(jsValueSingletonTypeId);
+ QVERIFY(!value.isUndefined());
+ QVERIFY(value.isQObject());
+ QObject *instance = value.toQObject();
+ QVERIFY(instance);
+ QCOMPARE(instance->metaObject()->className(), "JsSingleton");
+ }
+
+ {
+ // Invalid types
+ QJSValue value;
+ value = engine.singletonInstance<QJSValue>(-4711);
+ QVERIFY(value.isUndefined());
+ value = engine.singletonInstance<QJSValue>(1701);
+ QVERIFY(value.isUndefined());
+ }
+
+ {
+ // Valid, but non-singleton type
+ int typeId = qmlRegisterType<CppSingleton>("Test", 1, 0, "NotASingleton");
+ QJSValue value = engine.singletonInstance<QJSValue>(typeId);
+ QVERIFY(value.isUndefined());
+ }
+
+ {
+ // Cpp QObject singleton type
+ CppSingleton *instance = engine.singletonInstance<CppSingleton*>(cppSingletonTypeId);
+ QVERIFY(instance);
+ QCOMPARE(instance->metaObject()->className(), "CppSingleton");
+ QCOMPARE(instance, engine.singletonInstance<QJSValue>(cppSingletonTypeId).toQObject());
+ }
+
+ {
+ // Wrong destination type
+ SomeQObjectClass * instance = engine.singletonInstance<SomeQObjectClass*>(cppSingletonTypeId);
+ QVERIFY(!instance);
+ }
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"
diff --git a/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
index eeda289d35..9f972e3e06 100644
--- a/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
+++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
@@ -1 +1 @@
--1:-1:Object destroyed during incubation
+-1:-1:Object or context destroyed during incubation
diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
index 015d55b03b..30b5193cd5 100644
--- a/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
@@ -1 +1 @@
-3:1:UnknownType is not a type
+4:5:UnknownType is not a type
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.1.mjs b/tests/auto/qml/qqmllanguage/data/importJsModule.1.mjs
new file mode 100644
index 0000000000..c17a351216
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.1.mjs
@@ -0,0 +1,4 @@
+
+export function ok() {
+ return true;
+}
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.1.qml b/tests/auto/qml/qqmllanguage/data/importJsModule.1.qml
new file mode 100644
index 0000000000..cc988a6114
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.1.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import "importJsModule.1.mjs" as JSModule
+
+Item {
+ property bool test: JSModule.ok()
+}
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.2.qml b/tests/auto/qml/qqmllanguage/data/importJsModule.2.qml
new file mode 100644
index 0000000000..0799585622
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.2.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import org.qtproject.PureESJsModule 1.0
+
+Item {
+ property bool test: ModuleAPI.ok()
+}
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.3.indirect.mjs b/tests/auto/qml/qqmllanguage/data/importJsModule.3.indirect.mjs
new file mode 100644
index 0000000000..41d2f391bf
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.3.indirect.mjs
@@ -0,0 +1,4 @@
+
+import { indirectOk } from "./importJsModule.3.mjs";
+
+export function ok() { return indirectOk(); }
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.3.mjs b/tests/auto/qml/qqmllanguage/data/importJsModule.3.mjs
new file mode 100644
index 0000000000..3623dc6f4f
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.3.mjs
@@ -0,0 +1,4 @@
+export function indirectOk() { return true; }
+
+export * from "./importJsModule.3.indirect.mjs";
+
diff --git a/tests/auto/qml/qqmllanguage/data/importJsModule.3.qml b/tests/auto/qml/qqmllanguage/data/importJsModule.3.qml
new file mode 100644
index 0000000000..3b187205c7
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/importJsModule.3.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import "importJsModule.3.mjs" as JSModule
+
+Item {
+ property bool test: JSModule.ok()
+}
diff --git a/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
index 3813680562..4f3f758b7e 100644
--- a/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
@@ -1,2 +1,2 @@
-3:1:Type IncorrectCaseType unavailable
+3:1:IncorrectCaseType is not a type
-1:-1:File name case mismatch
diff --git a/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/API.mjs b/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/API.mjs
new file mode 100644
index 0000000000..c17a351216
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/API.mjs
@@ -0,0 +1,4 @@
+
+export function ok() {
+ return true;
+}
diff --git a/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/qmldir b/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/qmldir
new file mode 100644
index 0000000000..59b4740f75
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/lib/org/qtproject/PureESJsModule/qmldir
@@ -0,0 +1 @@
+ModuleAPI 1.0 API.mjs
diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
index db7d9c0f60..cefd62f9d4 100644
--- a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
@@ -1 +1 @@
-4:18:Unexpected object assignment
+4:18:Unexpected object assignment for property "x"
diff --git a/tests/auto/qml/qqmllanguage/data/property.4.errors.txt b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
index b447186849..2807384ec4 100644
--- a/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
@@ -1 +1 @@
-5:1:Syntax error
+5:1:Expected token `:'
diff --git a/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml
new file mode 100644
index 0000000000..4f8174a52d
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml
@@ -0,0 +1,10 @@
+import QtQml 2.0
+import ScopedEnumsWithNameClashTest 1.0
+
+QtObject {
+ property bool success: false
+
+ Component.onCompleted: {
+ success = (ScopedEnum.ScopedEnum.OtherScopedEnum === 3)
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml
new file mode 100644
index 0000000000..84efa6859b
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml
@@ -0,0 +1,11 @@
+import QtQml 2.0
+import ScopedEnumsWithResolvedNameClashTest 1.0
+
+QtObject {
+ property bool success: false
+
+ Component.onCompleted: {
+ success = (ScopedEnum.ScopedEnum.OtherScopedEnum === 3)
+ && (ScopedEnum.OtherScopedEnum.ScopedVal2 === 1)
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/singletonTest18.qml b/tests/auto/qml/qqmllanguage/data/singletonTest18.qml
new file mode 100644
index 0000000000..7616c23531
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/singletonTest18.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+import "singleton"
+import Test 1.0
+
+Item {
+ property var qmlSingleton: SingletonType
+ property var jsSingleton: MyQJSValueQObjectSingleton
+ property var cppSingleton: MyTypeObjectSingleton
+}
diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
index 77cf210918..cedae349d2 100644
--- a/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
@@ -1 +1 @@
-4:24:Cannot assign object to property
+4:24:Cannot assign object of type "QtObject" to property of type "MyQmlObject*" as the former is neither the same as the latter nor a sub-class of it.
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 0eb4f26878..f9a6ee8e5a 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -35,6 +35,14 @@ static QObject *myTypeObjectSingleton(QQmlEngine *engine, QJSEngine *scriptEngin
return new MyTypeObject();
}
+static QJSValue myQJSValueQObjectSingleton(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+
+ QJSValue value = scriptEngine->newQObject(new MyTypeObject());
+ return value;
+}
+
void registerTypes()
{
qmlRegisterInterface<MyInterface>("MyInterface");
@@ -101,6 +109,7 @@ void registerTypes()
qmlRegisterType<MyCompositeBaseType>("Test", 1, 0, "MyCompositeBaseType");
qmlRegisterSingletonType<MyTypeObjectSingleton>("Test", 1, 0, "MyTypeObjectSingleton", myTypeObjectSingleton);
+ qmlRegisterSingletonType("Test", 1, 0, "MyQJSValueQObjectSingleton", myQJSValueQObjectSingleton);
qmlRegisterType<MyArrayBufferTestClass>("Test", 1, 0, "MyArrayBufferTestClass");
@@ -116,7 +125,7 @@ QVariant myCustomVariantTypeConverter(const QString &data)
}
-void CustomBindingParser::applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void CustomBindingParser::applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
CustomBinding *customBinding = qobject_cast<CustomBinding*>(object);
Q_ASSERT(customBinding);
@@ -129,7 +138,7 @@ void CustomBinding::componentComplete()
Q_ASSERT(m_target);
foreach (const QV4::CompiledData::Binding *binding, bindings) {
- QString name = compilationUnit->data->stringAt(binding->propertyNameIndex);
+ QString name = compilationUnit->stringAt(binding->propertyNameIndex);
int bindingId = binding->value.compiledScriptIndex;
@@ -145,7 +154,7 @@ void CustomBinding::componentComplete()
}
}
-void EnumSupportingCustomParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void EnumSupportingCustomParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
if (bindings.count() != 1) {
error(bindings.first(), QStringLiteral("Custom parser invoked incorrectly for unit test"));
@@ -153,7 +162,7 @@ void EnumSupportingCustomParser::verifyBindings(const QV4::CompiledData::Unit *q
}
const QV4::CompiledData::Binding *binding = bindings.first();
- if (qmlUnit->stringAt(binding->propertyNameIndex) != QStringLiteral("foo")) {
+ if (compilationUnit->stringAt(binding->propertyNameIndex) != QStringLiteral("foo")) {
error(binding, QStringLiteral("Custom parser invoked with the wrong property name"));
return;
}
@@ -162,7 +171,7 @@ void EnumSupportingCustomParser::verifyBindings(const QV4::CompiledData::Unit *q
error(binding, QStringLiteral("Custom parser invoked with the wrong property value. Expected script that evaluates to enum"));
return;
}
- QByteArray script = qmlUnit->stringAt(binding->stringIndex).toUtf8();
+ QByteArray script = compilationUnit->stringAt(binding->stringIndex).toUtf8();
bool ok;
int v = evaluateEnum(script, &ok);
if (!ok) {
@@ -175,7 +184,7 @@ void EnumSupportingCustomParser::verifyBindings(const QV4::CompiledData::Unit *q
}
}
-void SimpleObjectCustomParser::applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &bindings)
+void SimpleObjectCustomParser::applyBindings(QObject *object, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &bindings)
{
SimpleObjectWithCustomParser *o = qobject_cast<SimpleObjectWithCustomParser*>(object);
Q_ASSERT(o);
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 5025a6e7f2..d890668655 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -781,15 +781,15 @@ class MyCustomParserType : public QObject
class MyCustomParserTypeParser : public QQmlCustomParser
{
public:
- virtual void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &) {}
- virtual void applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &) {}
+ virtual void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) {}
+ virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) {}
};
class EnumSupportingCustomParser : public QQmlCustomParser
{
public:
- virtual void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &);
- virtual void applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &) {}
+ virtual void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &);
+ virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) {}
};
class MyParserStatus : public QObject, public QQmlParserStatus
@@ -1282,8 +1282,8 @@ public:
class CustomBindingParser : public QQmlCustomParser
{
- virtual void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &) {}
- virtual void applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &);
+ virtual void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) {}
+ virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &);
};
class SimpleObjectWithCustomParser : public QObject
@@ -1328,8 +1328,8 @@ private:
class SimpleObjectCustomParser : public QQmlCustomParser
{
- virtual void verifyBindings(const QV4::CompiledData::Unit *, const QList<const QV4::CompiledData::Binding *> &) {}
- virtual void applyBindings(QObject *, QV4::CompiledData::CompilationUnit *, const QList<const QV4::CompiledData::Binding *> &);
+ virtual void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) {}
+ virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &);
};
class RootObjectInCreationTester : public QObject
@@ -1384,6 +1384,30 @@ private:
QObjectList m_list;
};
+class ScopedEnumsWithNameClash
+{
+ Q_GADGET
+ Q_ENUMS(ScopedEnum)
+ Q_ENUMS(OtherScopedEnum)
+
+public:
+ enum class ScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3, OtherScopedEnum };
+ enum class OtherScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3 };
+};
+
+class ScopedEnumsWithResolvedNameClash
+{
+ Q_GADGET
+ Q_ENUMS(ScopedEnum)
+ Q_ENUMS(OtherScopedEnum)
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
+
+public:
+ enum class ScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3, OtherScopedEnum };
+ enum class OtherScopedEnum : int { ScopedVal1, ScopedVal2, ScopedVal3 };
+};
+
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 8913528d79..157fd500ad 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -34,11 +34,13 @@
#include <QtCore/qdebug.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
+#include <QtCore/qscopeguard.h>
#include <QSignalSpy>
#include <QFont>
#include <QQmlFileSelector>
#include <QFileSelector>
#include <QEasingCurve>
+#include <QScopeGuard>
#include <private/qqmlproperty_p.h>
#include <private/qqmlmetatype_p.h>
@@ -182,6 +184,8 @@ private slots:
void importIncorrectCase();
void importJs_data();
void importJs();
+ void importJsModule_data();
+ void importJsModule();
void explicitSelfImport();
void importInternalType();
@@ -215,6 +219,8 @@ private slots:
void lowercaseEnumCompileTime_data();
void lowercaseEnumCompileTime();
void scopedEnum();
+ void scopedEnumsWithNameClash();
+ void scopedEnumsWithResolvedNameClash();
void qmlEnums();
void literals_data();
void literals();
@@ -246,6 +252,8 @@ private slots:
void compositeSingletonRegistered();
void compositeSingletonCircular();
+ void singletonsHaveContextAndEngine();
+
void customParserBindingScopes();
void customParserEvaluateEnum();
void customParserProperties();
@@ -288,6 +296,8 @@ private slots:
void valueTypeGroupPropertiesInBehavior();
+ void retrieveQmlTypeId();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -2193,26 +2203,27 @@ void tst_qqmllanguage::scriptStringWithoutSourceCode()
QUrl url = testFileUrl("scriptString7.qml");
{
QQmlEnginePrivate *eng = QQmlEnginePrivate::get(&engine);
- QQmlTypeData *td = eng->typeLoader.getType(url);
+ QQmlRefPointer<QQmlTypeData> td = eng->typeLoader.getType(url);
Q_ASSERT(td);
- const QV4::CompiledData::Unit *readOnlyQmlUnit = td->compilationUnit()->data;
+ const QV4::CompiledData::Unit *readOnlyQmlUnit = td->compilationUnit()->unitData();
Q_ASSERT(readOnlyQmlUnit);
QV4::CompiledData::Unit *qmlUnit = reinterpret_cast<QV4::CompiledData::Unit *>(malloc(readOnlyQmlUnit->unitSize));
memcpy(qmlUnit, readOnlyQmlUnit, readOnlyQmlUnit->unitSize);
qmlUnit->flags &= ~QV4::CompiledData::Unit::StaticData;
- td->compilationUnit()->data = qmlUnit;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = td->compilationUnit();
+ compilationUnit->setUnitData(qmlUnit);
- const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(/*root object*/0);
- QCOMPARE(qmlUnit->stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject"));
+ const QV4::CompiledData::Object *rootObject = compilationUnit->objectAt(/*root object*/0);
+ QCOMPARE(compilationUnit->stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject"));
quint32 i;
for (i = 0; i < rootObject->nBindings; ++i) {
const QV4::CompiledData::Binding *binding = rootObject->bindingTable() + i;
- if (qmlUnit->stringAt(binding->propertyNameIndex) != QString("scriptProperty"))
+ if (compilationUnit->stringAt(binding->propertyNameIndex) != QString("scriptProperty"))
continue;
- QCOMPARE(binding->valueAsScriptString(qmlUnit), QString("intProperty"));
+ QCOMPARE(binding->valueAsScriptString(compilationUnit.data()), QString("intProperty"));
const_cast<QV4::CompiledData::Binding*>(binding)->stringIndex = 0; // empty string index
- QVERIFY(binding->valueAsScriptString(qmlUnit).isEmpty());
+ QVERIFY(binding->valueAsScriptString(compilationUnit.data()).isEmpty());
break;
}
QVERIFY(i < rootObject->nBindings);
@@ -3120,6 +3131,36 @@ void tst_qqmllanguage::importJs()
engine.setImportPathList(defaultImportPathList);
}
+void tst_qqmllanguage::importJsModule_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("plainImport")
+ << "importJsModule.1.qml";
+
+ QTest::newRow("ImportQmlStyle")
+ << "importJsModule.2.qml";
+
+ QTest::newRow("plainImportWithCycle")
+ << "importJsModule.3.qml";
+}
+
+void tst_qqmllanguage::importJsModule()
+{
+ QFETCH(QString, file);
+
+ engine.setImportPathList(QStringList(defaultImportPathList) << testFile("lib"));
+ auto importPathGuard = qScopeGuard([this]{
+ engine.setImportPathList(defaultImportPathList);
+ });
+
+ QQmlComponent component(&engine, testFileUrl(file));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != nullptr);
+ QCOMPARE(object->property("test").toBool(),true);
+}
+
void tst_qqmllanguage::explicitSelfImport()
{
engine.setImportPathList(QStringList(defaultImportPathList) << testFile("lib"));
@@ -3755,6 +3796,40 @@ void tst_qqmllanguage::scopedEnum()
QCOMPARE(o->property("noScope").toInt(), (int)MyTypeObject::MyScopedEnum::ScopedVal2);
}
+void tst_qqmllanguage::scopedEnumsWithNameClash()
+{
+ auto typeId = qmlRegisterUncreatableType<ScopedEnumsWithNameClash>("ScopedEnumsWithNameClashTest", 1, 0, "ScopedEnum", "Dummy reason");
+ auto registryGuard = qScopeGuard([typeId]() {
+ qmlUnregisterType(typeId);
+ });
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("scopedEnumsWithNameClash.qml"));
+
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "Previously registered enum will be overwritten due to name clash: ScopedEnumsWithNameClash.ScopedVal1");
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "Previously registered enum will be overwritten due to name clash: ScopedEnumsWithNameClash.ScopedVal2");
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "Previously registered enum will be overwritten due to name clash: ScopedEnumsWithNameClash.ScopedVal3");
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(obj != nullptr);
+ QVERIFY(obj->property("success").toBool());
+}
+
+void tst_qqmllanguage::scopedEnumsWithResolvedNameClash()
+{
+ auto typeId = qmlRegisterUncreatableType<ScopedEnumsWithResolvedNameClash>("ScopedEnumsWithResolvedNameClashTest", 1, 0, "ScopedEnum", "Dummy reason");
+ auto registryGuard = qScopeGuard([typeId]() {
+ qmlUnregisterType(typeId);
+ });
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("scopedEnumsWithResolvedNameClash.qml"));
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(obj != nullptr);
+ QVERIFY(obj->property("success").toBool());
+}
+
void tst_qqmllanguage::qmlEnums()
{
QQmlEngine engine;
@@ -3923,11 +3998,13 @@ void tst_qqmllanguage::getSingletonInstance(QObject* o, const char* propertyName
return;
QVariant variant = o->property(propertyName);
- QVERIFY(variant.userType() == qMetaTypeId<QObject *>());
+ QVERIFY(variant.isValid());
QObject *singleton = nullptr;
- if (variant.canConvert<QObject*>())
+ if (variant.userType() == qMetaTypeId<QObject *>())
singleton = variant.value<QObject*>();
+ else if (variant.userType() == qMetaTypeId<QJSValue>())
+ singleton = variant.value<QJSValue>().toQObject();
QVERIFY(singleton != nullptr);
*result = singleton;
@@ -4232,6 +4309,24 @@ void tst_qqmllanguage::compositeSingletonCircular()
QCOMPARE(o->property("value").toInt(), 2);
}
+void tst_qqmllanguage::singletonsHaveContextAndEngine()
+{
+ QObject *qmlSingleton = nullptr;
+ getSingletonInstance(engine, "singletonTest18.qml", "qmlSingleton", &qmlSingleton);
+ QVERIFY(qmlContext(qmlSingleton));
+ QCOMPARE(qmlEngine(qmlSingleton), &engine);
+
+ QObject *jsSingleton = nullptr;
+ getSingletonInstance(engine, "singletonTest18.qml", "jsSingleton", &jsSingleton);
+ QVERIFY(qmlContext(jsSingleton));
+ QCOMPARE(qmlEngine(jsSingleton), &engine);
+
+ QObject *cppSingleton = nullptr;
+ getSingletonInstance(engine, "singletonTest18.qml", "cppSingleton", &cppSingleton);
+ QVERIFY(qmlContext(cppSingleton));
+ QCOMPARE(qmlEngine(cppSingleton), &engine);
+}
+
void tst_qqmllanguage::customParserBindingScopes()
{
QQmlComponent component(&engine, testFile("customParserBindingScopes.qml"));
@@ -4934,6 +5029,26 @@ void tst_qqmllanguage::valueTypeGroupPropertiesInBehavior()
QCOMPARE(animation->property("easing").value<QEasingCurve>().type(), QEasingCurve::InOutQuad);
}
+void tst_qqmllanguage::retrieveQmlTypeId()
+{
+ // Register in reverse order to provoke wrong minor version matching.
+ int id2 = qmlRegisterType<QObject>("Test", 2, 3, "SomeTestType");
+ int id1 = qmlRegisterType<QObject>("Test", 2, 1, "SomeTestType");
+ QCOMPARE(qmlTypeId("Test", 2, 1, "SomeTestType"), id1);
+ QCOMPARE(qmlTypeId("Test", 2, 2, "SomeTestType"), id1);
+ QCOMPARE(qmlTypeId("Test", 2, 3, "SomeTestType"), id2);
+
+ // Error cases
+ QCOMPARE(qmlTypeId("Test", 2, 0, "SomeTestType"), -1);
+ QCOMPARE(qmlTypeId("Test", 2, 3, "DoesNotExist"), -1);
+ QCOMPARE(qmlTypeId("DoesNotExist", 2, 3, "SomeTestType"), -1);
+
+ // Must also work for other types (defined in testtpes.cpp)
+ QVERIFY(qmlTypeId("Test", 1, 0, "MyExtendedUncreateableBaseClass") >= 0);
+ QVERIFY(qmlTypeId("Test", 1, 0, "MyUncreateableBaseClass") >= 0);
+ QVERIFY(qmlTypeId("Test", 1, 0, "MyTypeObjectSingleton") >= 0);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmllistmodel/data/dynamicroles.qml b/tests/auto/qml/qqmllistmodel/data/dynamicroles.qml
new file mode 100644
index 0000000000..7d3650c3b9
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/dynamicroles.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ ListModel {
+ id: listModel
+ objectName: "listModel"
+ dynamicRoles: true
+
+ // have to add elements dynamically when dynamicRoles = true
+ function appendNewElement() {
+ listModel.append({"name": "test", "obj": null})
+ }
+
+ function setElementAgain() {
+ var element = listModel.get(0)
+ listModel.set(0, element)
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmllistmodel/data/qtbug38907.qml b/tests/auto/qml/qqmllistmodel/data/qtbug38907.qml
new file mode 100644
index 0000000000..0abf221f60
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/qtbug38907.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+import QtTest 1.0
+
+Item {
+
+ Item {
+ id : testItem
+ property string name : "testObject"
+ property var object : this
+ function testMethod() {
+ return -1;
+ }
+ }
+
+ ListModel {
+ id : listModel
+ dynamicRoles : true
+ }
+
+ function exec() {
+ listModel.append(testItem);
+ listModel.append({ item : testItem });
+ return true;
+ }
+}
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
index 9fdc54f067..771f3e5c4e 100644
--- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
+++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
@@ -106,6 +106,7 @@ private slots:
void get_nested_data();
void crash_model_with_multiple_roles();
void crash_model_with_unknown_roles();
+ void crash_model_with_dynamic_roles();
void set_model_cache();
void property_changes();
void property_changes_data();
@@ -126,6 +127,7 @@ private slots:
void stringifyModelEntry();
void qobjectTrackerForDynamicModelObjects();
void crash_append_empty_array();
+ void dynamic_roles_crash_QTBUG_38907();
};
bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object)
@@ -984,6 +986,97 @@ void tst_qqmllistmodel::crash_model_with_unknown_roles()
model->index(0, 0, QModelIndex()).data(Qt::UserRole);
}
+//QTBUG-35639
+void tst_qqmllistmodel::crash_model_with_dynamic_roles()
+{
+ {
+ // setting a dynamic role to a QObject value, then triggering dtor
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("dynamicroles.qml"));
+ QObject *rootItem = component.create();
+ qWarning() << component.errorString();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QQmlListModel *model = rootItem->findChild<QQmlListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ QMetaObject::invokeMethod(model, "appendNewElement");
+
+ QObject *testObj = new QObject;
+ model->setProperty(0, "obj", QVariant::fromValue<QObject*>(testObj));
+ delete testObj;
+
+ // delete the root item, which will cause the model dtor to run
+ // previously, this would crash as it attempted to delete testObj.
+ delete rootItem;
+ }
+
+ {
+ // setting a dynamic role to a QObject value, then triggering
+ // DynamicRoleModelNode::updateValues() to trigger unsafe qobject_cast
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("dynamicroles.qml"));
+ QObject *rootItem = component.create();
+ qWarning() << component.errorString();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QQmlListModel *model = rootItem->findChild<QQmlListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ QMetaObject::invokeMethod(model, "appendNewElement");
+
+ QObject *testObj = new QObject;
+ model->setProperty(0, "obj", QVariant::fromValue<QObject*>(testObj));
+ delete testObj;
+
+ QMetaObject::invokeMethod(model, "setElementAgain");
+
+ delete rootItem;
+ }
+
+ {
+ // setting a dynamic role to a QObject value, then triggering
+ // DynamicRoleModelNodeMetaObject::propertyWrite()
+
+ /*
+ XXX TODO: I couldn't reproduce this one simply - I think it
+ requires a WorkerScript sync() call, and that's non-trivial.
+ I thought I could do it simply via:
+
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("dynamicroles.qml"));
+ QObject *rootItem = component.create();
+ qWarning() << component.errorString();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QQmlListModel *model = rootItem->findChild<QQmlListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ QMetaObject::invokeMethod(model, "appendNewElement");
+
+ QObject *testObj = new QObject;
+ model->setProperty(0, "obj", QVariant::fromValue<QObject*>(testObj));
+ delete testObj;
+ QObject *testObj2 = new QObject;
+ model->setProperty(0, "obj", QVariant::fromValue<QObject*>(testObj2));
+
+ But it turns out that that doesn't work (the setValue() call within
+ setProperty() doesn't seem to trigger the right codepath, for some
+ reason), and you can't trigger it manually via:
+
+ QObject *testObj2 = new QObject;
+ void *a[] = { testObj2, 0 };
+ QMetaObject::metacall(dynamicNodeModel, QMetaObject::WriteProperty, 0, a);
+
+ because the dynamicNodeModel for that index cannot be retrieved
+ using the public API.
+
+ But, anyway, I think the above two test cases are sufficient to
+ show that QObject* values should be guarded internally.
+ */
+ }
+}
+
//QTBUG-15190
void tst_qqmllistmodel::set_model_cache()
{
@@ -1556,6 +1649,24 @@ void tst_qqmllistmodel::crash_append_empty_array()
QCOMPARE(spy.count(), 0);
}
+void tst_qqmllistmodel::dynamic_roles_crash_QTBUG_38907()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("qtbug38907.qml"));
+ QVERIFY(!component.isError());
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(component.create()));
+ QVERIFY(item != 0);
+
+ QVariant retVal;
+
+ QMetaObject::invokeMethod(item.data(),
+ "exec",
+ Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, retVal));
+
+ QVERIFY(retVal.toBool());
+}
+
QTEST_MAIN(tst_qqmllistmodel)
#include "tst_qqmllistmodel.moc"
diff --git a/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp b/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp
index 7fd4d69b5e..44ce1d6987 100644
--- a/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp
+++ b/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp
@@ -53,7 +53,7 @@ void tst_qqmlopenmetaobject::createProperties()
QQmlEngine engine;
CustomObject object;
const QQmlRefPointer<QQmlOpenMetaObjectType> mot = new QQmlOpenMetaObjectType(object.metaObject(), &engine);
- QQmlOpenMetaObject *const mo = new QQmlOpenMetaObject(&object, mot);
+ QQmlOpenMetaObject *const mo = new QQmlOpenMetaObject(&object, mot.data());
mo->setCached(true);
mot->createProperty("customProperty");
QVERIFY(true);
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index ba2b836a6d..ce9d0ac894 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -50,6 +50,9 @@ private slots:
void qmlParser();
#endif
void invalidEscapeSequence();
+ void stringLiteral();
+ void noSubstitutionTemplateLiteral();
+ void templateLiteral();
private:
QStringList excludedDirs;
@@ -78,6 +81,13 @@ public:
const quint32 parentBegin = parent->firstSourceLocation().begin();
const quint32 parentEnd = parent->lastSourceLocation().end();
+ if (node->firstSourceLocation().begin() < parentBegin)
+ qDebug() << "first source loc failed: node:" << node->kind << "at" << node->firstSourceLocation().startLine << "/" << node->firstSourceLocation().startColumn
+ << "parent" << parent->kind << "at" << parent->firstSourceLocation().startLine << "/" << parent->firstSourceLocation().startColumn;
+ if (node->lastSourceLocation().end() > parentEnd)
+ qDebug() << "first source loc failed: node:" << node->kind << "at" << node->lastSourceLocation().startLine << "/" << node->lastSourceLocation().startColumn
+ << "parent" << parent->kind << "at" << parent->lastSourceLocation().startLine << "/" << parent->lastSourceLocation().startColumn;
+
QVERIFY(node->firstSourceLocation().begin() >= parentBegin);
QVERIFY(node->lastSourceLocation().end() <= parentEnd);
}
@@ -183,13 +193,12 @@ void tst_qqmlparser::qmlParser()
Lexer lexer(&engine);
lexer.setCode(code, 1, qmlMode);
Parser parser(&engine);
- if (qmlMode)
- parser.parse();
- else
- parser.parseProgram();
+ bool ok = qmlMode ? parser.parse() : parser.parseProgram();
- check::Check chk;
- chk(parser.rootNode());
+ if (ok) {
+ check::Check chk;
+ chk(parser.rootNode());
+ }
}
#endif
@@ -204,6 +213,67 @@ void tst_qqmlparser::invalidEscapeSequence()
parser.parse();
}
+void tst_qqmlparser::stringLiteral()
+{
+ using namespace QQmlJS;
+
+ Engine engine;
+ Lexer lexer(&engine);
+ QLatin1String code("'hello string'");
+ lexer.setCode(code , 1);
+ Parser parser(&engine);
+ QVERIFY(parser.parseExpression());
+ AST::ExpressionNode *expression = parser.expression();
+ QVERIFY(expression);
+ auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
+ QVERIFY(literal);
+ QCOMPARE(literal->value, "hello string");
+ QCOMPARE(literal->firstSourceLocation().begin(), 0);
+ QCOMPARE(literal->lastSourceLocation().end(), code.size());
+}
+
+void tst_qqmlparser::noSubstitutionTemplateLiteral()
+{
+ using namespace QQmlJS;
+
+ Engine engine;
+ Lexer lexer(&engine);
+ QLatin1String code("`hello template`");
+ lexer.setCode(code, 1);
+ Parser parser(&engine);
+ QVERIFY(parser.parseExpression());
+ AST::ExpressionNode *expression = parser.expression();
+ QVERIFY(expression);
+
+ auto *literal = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
+ QVERIFY(literal);
+
+ QCOMPARE(literal->value, "hello template");
+ QCOMPARE(literal->firstSourceLocation().begin(), 0);
+ QCOMPARE(literal->lastSourceLocation().end(), code.size());
+}
+
+void tst_qqmlparser::templateLiteral()
+{
+ using namespace QQmlJS;
+
+ Engine engine;
+ Lexer lexer(&engine);
+ QLatin1String code("`one plus one equals ${1+1}!`");
+ lexer.setCode(code, 1);
+ Parser parser(&engine);
+ QVERIFY(parser.parseExpression());
+ AST::ExpressionNode *expression = parser.expression();
+ QVERIFY(expression);
+
+ auto *templateLiteral = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
+ QVERIFY(templateLiteral);
+
+ QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0);
+ auto *e = templateLiteral->expression;
+ QVERIFY(e);
+}
+
QTEST_MAIN(tst_qqmlparser)
#include "tst_qqmlparser.moc"
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index ef2136bc64..27e06c6f67 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -2007,15 +2007,15 @@ void tst_qqmlproperty::warnOnInvalidBinding()
QString expectedWarning;
// V4 error message for property-to-property binding
- expectedWarning = testUrl.toString() + QString::fromLatin1(":6:36: Unable to assign QQuickText to QQuickRectangle");
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":6:5: Unable to assign QQuickText to QQuickRectangle");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
// V8 error message for function-to-property binding
- expectedWarning = testUrl.toString() + QString::fromLatin1(":7:36: Unable to assign QQuickText to QQuickRectangle");
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":7:5: Unable to assign QQuickText to QQuickRectangle");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
// V8 error message for invalid binding to anchor
- expectedWarning = testUrl.toString() + QString::fromLatin1(":14:33: Unable to assign QQuickItem_QML_8 to QQuickAnchorLine");
+ expectedWarning = testUrl.toString() + QString::fromLatin1(":14:9: Unable to assign QQuickItem_QML_8 to QQuickAnchorLine");
QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData());
QQmlComponent component(&engine, testUrl);
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index b9e56b39a2..29f70c4e46 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -95,7 +95,7 @@ Q_SIGNALS:
void signalB();
};
-QQmlPropertyData *cacheProperty(QQmlPropertyCache *cache, const char *name)
+QQmlPropertyData *cacheProperty(const QQmlRefPointer<QQmlPropertyCache> &cache, const char *name)
{
return cache->property(QLatin1String(name), nullptr, nullptr);
}
diff --git a/tests/auto/qml/qqmlpropertymap/data/PropertyMapSubType.qml b/tests/auto/qml/qqmlpropertymap/data/PropertyMapSubType.qml
new file mode 100644
index 0000000000..90ff179408
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertymap/data/PropertyMapSubType.qml
@@ -0,0 +1,9 @@
+import QtQml 2.0
+import Test 1.0
+
+SimplePropertyMap {
+ Component.onCompleted: {
+ console.log("expected output")
+ newProperty = 42
+ }
+}
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
index 86229b95f3..237b65679e 100644
--- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -35,7 +35,7 @@
#include <QSignalSpy>
#include <QDebug>
-class tst_QQmlPropertyMap : public QObject
+class tst_QQmlPropertyMap : public QQmlDataTest
{
Q_OBJECT
public:
@@ -61,6 +61,7 @@ private slots:
void disallowExtending();
void QTBUG_35906();
void QTBUG_48136();
+ void lookupsInSubTypes();
};
class LazyPropertyMap : public QQmlPropertyMap, public QQmlParserStatus
@@ -89,9 +90,18 @@ private:
int value = 0;
};
+class SimplePropertyMap: public QQmlPropertyMap
+{
+ Q_OBJECT
+public:
+ SimplePropertyMap() : QQmlPropertyMap(this, nullptr) {}
+};
+
void tst_QQmlPropertyMap::initTestCase()
{
+ QQmlDataTest::initTestCase();
qmlRegisterType<LazyPropertyMap>("QTBUG_35233", 1, 0, "LazyPropertyMap");
+ qmlRegisterType<SimplePropertyMap>("Test", 1, 0, "SimplePropertyMap");
}
void tst_QQmlPropertyMap::insert()
@@ -496,6 +506,16 @@ void tst_QQmlPropertyMap::QTBUG_48136()
QCOMPARE(valueChangedSpy.count(), 1);
}
+void tst_QQmlPropertyMap::lookupsInSubTypes()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("PropertyMapSubType.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "expected output");
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ QCOMPARE(object->property("newProperty").toInt(), 42);
+}
+
QTEST_MAIN(tst_QQmlPropertyMap)
#include "tst_qqmlpropertymap.moc"
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index b96eecafe8..2d8115e867 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -505,8 +505,14 @@ void tst_qqmlqt::font()
QObject *object = component.create();
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QFont>(object->property("test1")), QFont("Arial", 22));
- QCOMPARE(qvariant_cast<QFont>(object->property("test2")), QFont("Arial", 20, QFont::DemiBold, true));
+ QFont f;
+ f.setFamily("Arial");
+ f.setPointSize(22);
+ QCOMPARE(qvariant_cast<QFont>(object->property("test1")), f);
+ f.setPointSize(20);
+ f.setWeight(QFont::DemiBold);
+ f.setItalic(true);
+ QCOMPARE(qvariant_cast<QFont>(object->property("test2")), f);
QCOMPARE(qvariant_cast<QFont>(object->property("test3")), QFont());
QCOMPARE(qvariant_cast<QFont>(object->property("test4")), QFont());
diff --git a/tests/auto/qml/qqmltranslation/data/translationChange.qml b/tests/auto/qml/qqmltranslation/data/translationChange.qml
index c48a482138..ae3231935c 100644
--- a/tests/auto/qml/qqmltranslation/data/translationChange.qml
+++ b/tests/auto/qml/qqmltranslation/data/translationChange.qml
@@ -3,6 +3,13 @@ import QtQuick 2.0
TranslationChangeBase {
id: root
+ ListModel {
+ id: listModel
+ ListElement {
+ text: qsTr("translate me")
+ }
+ }
+
baseProperty: "do not translate"
property string text1: qsTr("translate me")
function weDoTranslations() {
@@ -10,6 +17,7 @@ TranslationChangeBase {
}
property string text2: weDoTranslations()
property string text3
+ property string fromListModel: listModel.get(0).text
states: [
State {
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
index 1c67ba5541..809a9bd9db 100644
--- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
+++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
@@ -76,7 +76,7 @@ void tst_qqmltranslation::translation()
if (verifyCompiledData) {
QQmlContext *context = qmlContext(object);
QQmlEnginePrivate *engine = QQmlEnginePrivate::get(context->engine());
- QQmlTypeData *typeData = engine->typeLoader.getType(context->baseUrl());
+ QQmlRefPointer<QQmlTypeData> typeData = engine->typeLoader.getType(context->baseUrl());
QV4::CompiledData::CompilationUnit *compilationUnit = typeData->compilationUnit();
QVERIFY(compilationUnit);
@@ -85,11 +85,10 @@ void tst_qqmltranslation::translation()
<< QStringLiteral("disambiguation")
<< QStringLiteral("singular") << QStringLiteral("plural");
- const QV4::CompiledData::Unit *unit = compilationUnit->data;
- const QV4::CompiledData::Object *rootObject = unit->objectAt(/*root object*/0);
+ const QV4::CompiledData::Object *rootObject = compilationUnit->objectAt(/*root object*/0);
const QV4::CompiledData::Binding *binding = rootObject->bindingTable();
for (quint32 i = 0; i < rootObject->nBindings; ++i, ++binding) {
- const QString propertyName = unit->stringAt(binding->propertyNameIndex);
+ const QString propertyName = compilationUnit->stringAt(binding->propertyNameIndex);
const bool expectCompiledTranslation = compiledTranslations.contains(propertyName);
@@ -136,15 +135,14 @@ void tst_qqmltranslation::idTranslation()
{
QQmlContext *context = qmlContext(object);
QQmlEnginePrivate *engine = QQmlEnginePrivate::get(context->engine());
- QQmlTypeData *typeData = engine->typeLoader.getType(context->baseUrl());
+ QQmlRefPointer<QQmlTypeData> typeData = engine->typeLoader.getType(context->baseUrl());
QV4::CompiledData::CompilationUnit *compilationUnit = typeData->compilationUnit();
QVERIFY(compilationUnit);
- const QV4::CompiledData::Unit *unit = compilationUnit->data;
- const QV4::CompiledData::Object *rootObject = unit->objectAt(/*root object*/0);
+ const QV4::CompiledData::Object *rootObject = compilationUnit->objectAt(/*root object*/0);
const QV4::CompiledData::Binding *binding = rootObject->bindingTable();
for (quint32 i = 0; i < rootObject->nBindings; ++i, ++binding) {
- const QString propertyName = unit->stringAt(binding->propertyNameIndex);
+ const QString propertyName = compilationUnit->stringAt(binding->propertyNameIndex);
if (propertyName == "idTranslation") {
if (binding->type != QV4::CompiledData::Binding::Type_TranslationById)
qDebug() << "binding for property" << propertyName << "is not a compiled translation";
@@ -195,6 +193,7 @@ void tst_qqmltranslation::translationChange()
QCOMPARE(object->property("text1").toString(), QString::fromUtf8("translate me"));
QCOMPARE(object->property("text2").toString(), QString::fromUtf8("translate me"));
QCOMPARE(object->property("text3").toString(), QString::fromUtf8("translate me"));
+ QCOMPARE(object->property("fromListModel").toString(), QString::fromUtf8("translate me"));
DummyTranslator translator;
QCoreApplication::installTranslator(&translator);
@@ -206,6 +205,7 @@ void tst_qqmltranslation::translationChange()
QCOMPARE(object->property("text1").toString(), QString::fromUtf8("xxx"));
QCOMPARE(object->property("text2").toString(), QString::fromUtf8("xxx"));
QCOMPARE(object->property("text3").toString(), QString::fromUtf8("xxx"));
+ QCOMPARE(object->property("fromListModel").toString(), QString::fromUtf8("xxx"));
QCoreApplication::removeTranslator(&translator);
}
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index d336d033a3..cf3bc8b050 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -87,7 +87,7 @@ void tst_QQMLTypeLoader::trimCache()
QUrl url = testFileUrl("trim_cache.qml");
url.setQuery(QString::number(i));
- QQmlTypeData *data = loader.getType(url);
+ QQmlTypeData *data = loader.getType(url).take();
// Run an event loop to receive the callback that release()es.
QTRY_COMPARE(data->count(), 2);
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index a456facd2f..1ee4510e30 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -1020,7 +1020,7 @@ void tst_qqmlvaluetypes::bindingAssignment()
// function assignment should fail without crashing
{
- QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6:13: Invalid use of Qt.binding() in a binding declaration.");
+ QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6:5: Invalid use of Qt.binding() in a binding declaration.");
QString warning2 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":10: Cannot assign JavaScript function to value-type property");
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -1125,7 +1125,7 @@ void tst_qqmlvaluetypes::autoBindingRemoval()
{
QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
- QString warning = component.url().toString() + ":6:11: Unable to assign [undefined] to QRect";
+ QString warning = component.url().toString() + ":6:5: Unable to assign [undefined] to QRect";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != nullptr);
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
index 22c45c099d..94908f63c0 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
@@ -11,6 +11,9 @@ QtObject {
property bool headersReceived: false
property bool loading: false
property bool done: false
+ property bool onloadCalled: false
+ property bool onerrorCalled: false
+ property bool onloadendCalled: false
property bool resetException: false
@@ -62,6 +65,16 @@ QtObject {
}
}
+ x.onload = function() {
+ // test also that it was called after onreadystatechanged(DONE)
+ onloadCalled = (done === true) && (onerrorCalled === false);
+ }
+ x.onloadend = function() {
+ onloadendCalled = (done === true) && (onloadCalled === true || onerrorCalled === true);
+ }
+ x.onerror = function() {
+ onerrorCalled = (done === true) && (onloadCalled === false);
+ }
x.send()
diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
index ecce6515ed..6cf80ccfdb 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
+++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
@@ -917,6 +917,9 @@ void tst_qqmlxmlhttprequest::status()
QCOMPARE(object->property("loading").toBool(), true);
QCOMPARE(object->property("done").toBool(), true);
QCOMPARE(object->property("resetException").toBool(), true);
+ QCOMPARE(object->property("onloadCalled").toBool(), true);
+ QCOMPARE(object->property("onloadendCalled").toBool(), true);
+ QCOMPARE(object->property("onerrorCalled").toBool(), false);
}
void tst_qqmlxmlhttprequest::status_data()
diff --git a/tests/auto/qml/qquickworkerscript/data/messagehandler.mjs b/tests/auto/qml/qquickworkerscript/data/messagehandler.mjs
new file mode 100644
index 0000000000..749ff561da
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/data/messagehandler.mjs
@@ -0,0 +1,4 @@
+
+export function messageHandler(msg) {
+ WorkerScript.sendMessage("Hello from the module")
+}
diff --git a/tests/auto/qml/qquickworkerscript/data/script_global.js b/tests/auto/qml/qquickworkerscript/data/script_global.js
deleted file mode 100644
index cce4f2ceca..0000000000
--- a/tests/auto/qml/qquickworkerscript/data/script_global.js
+++ /dev/null
@@ -1,5 +0,0 @@
-WorkerScript.onMessage = function(msg) {
- world = "World"
- WorkerScript.sendMessage(msg + " " + world)
-}
-
diff --git a/tests/auto/qml/qquickworkerscript/data/script_global2.js b/tests/auto/qml/qquickworkerscript/data/script_global2.js
deleted file mode 100644
index 0867f7ee76..0000000000
--- a/tests/auto/qml/qquickworkerscript/data/script_global2.js
+++ /dev/null
@@ -1,6 +0,0 @@
-world = "World"
-
-WorkerScript.onMessage = function(msg) {
- WorkerScript.sendMessage(msg + " " + world)
-}
-
diff --git a/tests/auto/qml/qquickworkerscript/data/script_module.mjs b/tests/auto/qml/qquickworkerscript/data/script_module.mjs
new file mode 100644
index 0000000000..eaa191c5a7
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/data/script_module.mjs
@@ -0,0 +1,5 @@
+
+import { messageHandler as handler } from "./messagehandler.mjs";
+
+WorkerScript.onMessage = handler
+
diff --git a/tests/auto/qml/qquickworkerscript/data/worker_global.qml b/tests/auto/qml/qquickworkerscript/data/worker_global.qml
deleted file mode 100644
index 546afd2f39..0000000000
--- a/tests/auto/qml/qquickworkerscript/data/worker_global.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 2.0
-
-BaseWorker {
- source: "script_global.js"
-}
diff --git a/tests/auto/qml/qquickworkerscript/data/worker_global2.qml b/tests/auto/qml/qquickworkerscript/data/worker_global2.qml
deleted file mode 100644
index 42cad3852b..0000000000
--- a/tests/auto/qml/qquickworkerscript/data/worker_global2.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 2.0
-
-BaseWorker {
- source: "script_global2.js"
-}
diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
index e8a4be6faf..4ad58ba56c 100644
--- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
+++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
@@ -57,7 +57,6 @@ private slots:
void scriptError_onCall();
void script_function();
void script_var();
- void script_global();
void stressDispose();
private:
@@ -78,24 +77,30 @@ private:
void tst_QQuickWorkerScript::source()
{
QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
- QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QScopedPointer<QQuickWorkerScript>worker(qobject_cast<QQuickWorkerScript*>(component.create()));
QVERIFY(worker != nullptr);
const QMetaObject *mo = worker->metaObject();
QVariant value(100);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+ QVERIFY(QMetaObject::invokeMethod(worker.data(), "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker.data());
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker.data()).value<QVariant>(), value);
QUrl source = testFileUrl("script_fixed_return.js");
worker->setSource(source);
QCOMPARE(worker->source(), source);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
+ QVERIFY(QMetaObject::invokeMethod(worker.data(), "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker.data());
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker.data()).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
+
+ source = testFileUrl("script_module.mjs");
+ worker->setSource(source);
+ QCOMPARE(worker->source(), source);
+ QVERIFY(QMetaObject::invokeMethod(worker.data(), "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker.data());
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker.data()).value<QVariant>(), qVariantFromValue(QString("Hello from the module")));
qApp->processEvents();
- delete worker;
}
void tst_QQuickWorkerScript::messaging()
@@ -311,47 +316,6 @@ void tst_QQuickWorkerScript::script_var()
delete worker;
}
-void tst_QQuickWorkerScript::script_global()
-{
- {
- QQmlComponent component(&m_engine, testFileUrl("worker_global.qml"));
- QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
- QVERIFY(worker != nullptr);
-
- QString value("Hello");
-
- QtMessageHandler previousMsgHandler = qInstallMessageHandler(qquickworkerscript_warningsHandler);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
-
- QTRY_COMPARE(qquickworkerscript_lastWarning,
- testFileUrl("script_global.js").toString() + QLatin1String(":2: Invalid write to global property \"world\""));
-
- qInstallMessageHandler(previousMsgHandler);
-
- qApp->processEvents();
- delete worker;
- }
-
- qquickworkerscript_lastWarning = QString();
-
- {
- QtMessageHandler previousMsgHandler = qInstallMessageHandler(qquickworkerscript_warningsHandler);
-
- QQmlComponent component(&m_engine, testFileUrl("worker_global2.qml"));
- QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
- QVERIFY(worker != nullptr);
-
- QTRY_COMPARE(qquickworkerscript_lastWarning,
- testFileUrl("script_global2.js").toString() + QLatin1String(":1: Invalid write to global property \"world\""));
-
- qInstallMessageHandler(previousMsgHandler);
-
- qApp->processEvents();
- delete worker;
- }
-}
-
// Rapidly create and destroy worker scripts to test resources are being disposed
// in the correct isolate
void tst_QQuickWorkerScript::stressDispose()
diff --git a/tests/auto/qml/qv4identifiertable/qv4identifiertable.pro b/tests/auto/qml/qv4identifiertable/qv4identifiertable.pro
new file mode 100644
index 0000000000..64dc822367
--- /dev/null
+++ b/tests/auto/qml/qv4identifiertable/qv4identifiertable.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qv4identifiertable
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qv4identifiertable.cpp
+
+QT += qml qml-private testlib
+
diff --git a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
new file mode 100644
index 0000000000..095943cdc7
--- /dev/null
+++ b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 basysKom GmbH.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <private/qv4identifiertable_p.h>
+
+class tst_qv4identifiertable : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void sweepFirstEntryInBucket();
+ void sweepCenterEntryInBucket();
+ void sweepLastEntryInBucket();
+ void sweepFirstEntryInSameBucketWithDifferingHash();
+ void dontSweepAcrossBucketBoundaries();
+ void sweepAcrossBucketBoundariesIfFirstBucketFull();
+ void sweepBucketGap();
+};
+
+void tst_qv4identifiertable::sweepFirstEntryInBucket()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/1);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+
+ // All strings go into the same bucket
+ entry1->stringHash = 0;
+ entry2->stringHash = 0;
+ entry3->stringHash = 0;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+ table.asPropertyKey(entry3);
+
+ QCOMPARE(table.size, 3);
+ QCOMPARE(table.alloc, 5);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry3);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+
+ // first entry not marked
+ entry2->setMarkBit();
+ entry3->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry2);
+ QCOMPARE(table.entriesByHash[1], entry3);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+}
+
+void tst_qv4identifiertable::sweepCenterEntryInBucket()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/1);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+
+ // All strings go into the same bucket
+ entry1->stringHash = 0;
+ entry2->stringHash = 0;
+ entry3->stringHash = 0;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+ table.asPropertyKey(entry3);
+
+ QCOMPARE(table.size, 3);
+ QCOMPARE(table.alloc, 5);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry3);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+
+ entry1->setMarkBit();
+ // second entry not marked
+ entry3->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry3);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+}
+
+void tst_qv4identifiertable::sweepLastEntryInBucket()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/1);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+
+ // All strings go into the same bucket
+ entry1->stringHash = 0;
+ entry2->stringHash = 0;
+ entry3->stringHash = 0;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+ table.asPropertyKey(entry3);
+
+ QCOMPARE(table.size, 3);
+ QCOMPARE(table.alloc, 5);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry3);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+
+ entry1->setMarkBit();
+ entry2->setMarkBit();
+ // third entry not marked
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+}
+
+void tst_qv4identifiertable::sweepFirstEntryInSameBucketWithDifferingHash()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/1);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+
+ // First and second entry have differing hash but end up in the
+ // same bucket after modulo alloc.
+ entry1->stringHash = 0;
+ entry2->stringHash = 5;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+
+ QCOMPARE(table.size, 2);
+ QCOMPARE(table.alloc, 5);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+
+ // first entry not marked
+ entry2->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry2);
+ QCOMPARE(table.entriesByHash[1], nullptr);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+}
+
+void tst_qv4identifiertable::dontSweepAcrossBucketBoundaries()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/1);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+
+ // Different buckets for both entries.
+ entry1->stringHash = 0;
+ entry2->stringHash = 1;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+
+ QCOMPARE(table.size, 2);
+ QCOMPARE(table.alloc, 5);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+
+ // first entry not marked
+ entry2->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], nullptr);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], nullptr);
+}
+
+void tst_qv4identifiertable::sweepAcrossBucketBoundariesIfFirstBucketFull()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/3);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+ auto entry4 = engine.newString(QStringLiteral("four"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+ entry4->createHashValue();
+
+ // First, third and fourth entry have the same bucket (after modulo) and
+ // would typically end up in order [entry1, entry3, entry4, entry2]. However
+ // since null termination isn't guaranteed, an insertion order of
+ // entry1, entry2, entry3 and entry4 results in a
+ // table [entry1, entry2, entry3, entry4].
+ entry1->stringHash = 0;
+ entry2->stringHash = 1;
+ entry3->stringHash = 11;
+ entry4->stringHash = 11;
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+ table.asPropertyKey(entry3);
+ table.asPropertyKey(entry4);
+
+ QCOMPARE(table.size, 4);
+ QCOMPARE(table.alloc, 11);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry3);
+ QCOMPARE(table.entriesByHash[3], entry4);
+ QCOMPARE(table.entriesByHash[4], nullptr);
+
+ // first entry not marked
+ entry2->setMarkBit();
+ entry3->setMarkBit();
+ entry4->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry3);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry4);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+}
+
+void tst_qv4identifiertable::sweepBucketGap()
+{
+ QV4::ExecutionEngine engine;
+ QV4::IdentifierTable table(&engine, /*numBits*/3);
+
+ auto entry1 = engine.newString(QStringLiteral("one"));
+ auto entry2 = engine.newString(QStringLiteral("two"));
+ auto entry3 = engine.newString(QStringLiteral("three"));
+ auto entry4 = engine.newString(QStringLiteral("four"));
+
+ entry1->createHashValue();
+ entry2->createHashValue();
+ entry3->createHashValue();
+ entry4->createHashValue();
+
+ // We have two buckets where the second entry in the first bucket
+ // flows into the second bucket. So insertion into the second bucket
+ // will shift by one and create
+ // [entry1][entry2 (would map to first but overflows into second), entry3, entry4]
+ // Garbage collecting the first entry should not only move the second entry
+ // into its own first bucket (where there is space now), it is also critical to
+ // not leave a gap but move the third and fourth entries to the beginning of
+ // their bucket:
+ // [entry2][entry3, entry4]
+ entry1->stringHash = 0; // % 11 -> 0
+ entry2->stringHash = 11; // % 11 -> 0, but ends up at idx 1 because 0 taken
+ entry3->stringHash = 12; // % 11 -> 1, but ends up at idx 2 because 1 taken
+ entry4->stringHash = 12; // % 11 -> 1, but ends up at idx 3 because 1+2 taken
+
+ // trigger insertion
+ table.asPropertyKey(entry1);
+ table.asPropertyKey(entry2);
+ table.asPropertyKey(entry3);
+ table.asPropertyKey(entry4);
+
+ QCOMPARE(table.size, 4);
+ QCOMPARE(table.alloc, 11);
+
+ QCOMPARE(table.entriesByHash[0], entry1);
+ QCOMPARE(table.entriesByHash[1], entry2);
+ QCOMPARE(table.entriesByHash[2], entry3);
+ QCOMPARE(table.entriesByHash[3], entry4);
+ QCOMPARE(table.entriesByHash[4], nullptr);
+
+ // first entry not marked
+ entry2->setMarkBit();
+ entry3->setMarkBit();
+ entry4->setMarkBit();
+
+ table.sweep();
+
+ QCOMPARE(table.entriesByHash[0], entry2);
+ QCOMPARE(table.entriesByHash[1], entry3);
+ QCOMPARE(table.entriesByHash[2], entry4);
+ QCOMPARE(table.entriesByHash[3], nullptr);
+}
+
+QTEST_MAIN(tst_qv4identifiertable)
+
+#include "tst_qv4identifiertable.moc"
diff --git a/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/tests/auto/qml/qv4mm/tst_qv4mm.cpp
index d4ba363d00..07f8e9f1d1 100644
--- a/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+++ b/tests/auto/qml/qv4mm/tst_qv4mm.cpp
@@ -28,6 +28,7 @@
#include <qtest.h>
#include <QQmlEngine>
+#include <QLoggingCategory>
#include <private/qv4mm_p.h>
class tst_qv4mm : public QObject
@@ -36,23 +37,15 @@ class tst_qv4mm : public QObject
private slots:
void gcStats();
- void tweaks();
};
void tst_qv4mm::gcStats()
{
- qputenv(QV4_MM_STATS, "1");
+ QLoggingCategory::setFilterRules("qt.qml.gc.*=true");
QQmlEngine engine;
engine.collectGarbage();
}
-void tst_qv4mm::tweaks()
-{
- qputenv(QV4_MM_MAXBLOCK_SHIFT, "5");
- qputenv(QV4_MM_MAX_CHUNK_SIZE, "65536");
- QQmlEngine engine;
-}
-
QTEST_MAIN(tst_qv4mm)
#include "tst_qv4mm.moc"
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index 55a1f65608..22ff9c43fc 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -26,207 +26,82 @@
**
****************************************************************************/
-#include <qhashfunctions.h>
#include <qtest.h>
-
-#define V4_AUTOTEST
-#include <private/qv4ssa_p.h>
+#include <private/qv4instr_moth_p.h>
+#include <private/qv4script_p.h>
class tst_v4misc: public QObject
{
Q_OBJECT
private slots:
- void initTestCase();
-
- void rangeSplitting_1();
- void rangeSplitting_2();
- void rangeSplitting_3();
-
- void moveMapping_1();
- void moveMapping_2();
+ void tdzOptimizations_data();
+ void tdzOptimizations();
};
-using namespace QT_PREPEND_NAMESPACE(QV4::IR);
-
-void tst_v4misc::initTestCase()
-{
- qSetGlobalQHashSeed(0);
- QCOMPARE(qGlobalQHashSeed(), 0);
-}
-
-// split between two ranges
-void tst_v4misc::rangeSplitting_1()
+void tst_v4misc::tdzOptimizations_data()
{
- LifeTimeInterval interval;
- interval.addRange(59, 59);
- interval.addRange(61, 62);
- interval.addRange(64, 64);
- interval.addRange(69, 71);
- interval.validate();
- QCOMPARE(interval.end(), 71);
-
- LifeTimeInterval newInterval = interval.split(66, 70);
- interval.validate();
- newInterval.validate();
- QVERIFY(newInterval.isSplitFromInterval());
-
- QCOMPARE(interval.ranges().size(), 3);
- QCOMPARE(interval.ranges()[0].start, 59);
- QCOMPARE(interval.ranges()[0].end, 59);
- QCOMPARE(interval.ranges()[1].start, 61);
- QCOMPARE(interval.ranges()[1].end, 62);
- QCOMPARE(interval.ranges()[2].start, 64);
- QCOMPARE(interval.ranges()[2].end, 64);
- QCOMPARE(interval.end(), 70);
-
- QCOMPARE(newInterval.ranges().size(), 1);
- QCOMPARE(newInterval.ranges()[0].start, 70);
- QCOMPARE(newInterval.ranges()[0].end, 71);
- QCOMPARE(newInterval.end(), 71);
-}
+ QTest::addColumn<QString>("scriptToCompile");
-// split in the middle of a range
-void tst_v4misc::rangeSplitting_2()
-{
- LifeTimeInterval interval;
- interval.addRange(59, 59);
- interval.addRange(61, 64);
- interval.addRange(69, 71);
- interval.validate();
- QCOMPARE(interval.end(), 71);
-
- LifeTimeInterval newInterval = interval.split(62, 64);
- interval.validate();
- newInterval.validate();
- QVERIFY(newInterval.isSplitFromInterval());
-
- QCOMPARE(interval.ranges().size(), 2);
- QCOMPARE(interval.ranges()[0].start, 59);
- QCOMPARE(interval.ranges()[0].end, 59);
- QCOMPARE(interval.ranges()[1].start, 61);
- QCOMPARE(interval.ranges()[1].end, 62);
- QCOMPARE(interval.end(), 64);
-
- QCOMPARE(newInterval.ranges().size(), 2);
- QCOMPARE(newInterval.ranges()[0].start, 64);
- QCOMPARE(newInterval.ranges()[0].end, 64);
- QCOMPARE(newInterval.ranges()[1].start, 69);
- QCOMPARE(newInterval.ranges()[1].end, 71);
- QCOMPARE(newInterval.end(), 71);
+ QTest::newRow("access-after-let") << QString("let x; x = 10;");
+ QTest::newRow("access-after-const") << QString("const x = 10; print(x);");
+ QTest::newRow("access-after-let") << QString("for (let x of y) print(x);");
}
-// split in the middle of a range, and let it never go back to active again
-void tst_v4misc::rangeSplitting_3()
+void tst_v4misc::tdzOptimizations()
{
- LifeTimeInterval interval;
- interval.addRange(59, 59);
- interval.addRange(61, 64);
- interval.addRange(69, 71);
- interval.validate();
- QCOMPARE(interval.end(), 71);
-
- LifeTimeInterval newInterval = interval.split(64, LifeTimeInterval::InvalidPosition);
- interval.validate();
- newInterval.validate();
- QVERIFY(!newInterval.isValid());
-
- QCOMPARE(interval.ranges().size(), 2);
- QCOMPARE(interval.ranges()[0].start, 59);
- QCOMPARE(interval.ranges()[0].end, 59);
- QCOMPARE(interval.ranges()[1].start, 61);
- QCOMPARE(interval.ranges()[1].end, 64);
- QCOMPARE(interval.end(), 71);
-}
+ QFETCH(QString, scriptToCompile);
+
+ QV4::ExecutionEngine v4;
+ QV4::Script script(&v4, nullptr, scriptToCompile);
+ script.parse();
+ QVERIFY(!v4.hasException);
+
+ const auto function = script.compilationUnit->unitData()->functionAt(0);
+ const auto *code = function->code();
+ const auto len = function->codeSize;
+ const char *end = code + len;
+
+ const auto decodeInstruction = [&code]() {
+ QV4::Moth::Instr::Type type = QV4::Moth::Instr::Type(static_cast<uchar>(*code));
+ dispatch:
+ switch (type) {
+ case QV4::Moth::Instr::Type::Nop:
+ ++code;
+ type = QV4::Moth::Instr::Type(static_cast<uchar>(*code));
+ goto dispatch;
+ case QV4::Moth::Instr::Type::Nop_Wide: /* wide prefix */
+ ++code;
+ type = QV4::Moth::Instr::Type(0x100 | static_cast<uchar>(*code));
+ goto dispatch;
+
+#define CASE_AND_GOTO_INSTRUCTION(name, nargs, ...) \
+ case QV4::Moth::Instr::Type::name: \
+ MOTH_ADJUST_CODE(qint8, nargs); \
+ break;
+
+#define CASE_AND_GOTO_WIDE_INSTRUCTION(name, nargs, ...) \
+ case QV4::Moth::Instr::Type::name##_Wide: \
+ MOTH_ADJUST_CODE(int, nargs); \
+ type = QV4::Moth::Instr::Type::name; \
+ break;
+
+#define MOTH_DECODE_WITHOUT_ARGS(instr) \
+ INSTR_##instr(CASE_AND_GOTO) \
+ INSTR_##instr(CASE_AND_GOTO_WIDE)
+
+ FOR_EACH_MOTH_INSTR(MOTH_DECODE_WITHOUT_ARGS)
+ }
+ return type;
+ };
+
+ while (code < end) {
+ QV4::Moth::Instr::Type type = decodeInstruction();
+ QVERIFY(type != QV4::Moth::Instr::Type::DeadTemporalZoneCheck);
+ }
-void tst_v4misc::moveMapping_1()
-{
- Temp fp2(DoubleType, Temp::PhysicalRegister, 2);
- Temp fp3(DoubleType, Temp::PhysicalRegister, 3);
- Temp fp4(DoubleType, Temp::PhysicalRegister, 4);
- Temp fp5(DoubleType, Temp::PhysicalRegister, 5);
-
- MoveMapping mapping;
- mapping.add(&fp2, &fp3);
- mapping.add(&fp2, &fp4);
- mapping.add(&fp2, &fp5);
- mapping.add(&fp3, &fp2);
-
- mapping.order();
-// mapping.dump();
-
- QCOMPARE(mapping._moves.size(), 3);
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp2, &fp4, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp2, &fp5, false)));
- QVERIFY(mapping._moves.last() == MoveMapping::Move(&fp2, &fp3, true) ||
- mapping._moves.last() == MoveMapping::Move(&fp3, &fp2, true));
-}
-
-void tst_v4misc::moveMapping_2()
-{
- Temp fp1(DoubleType, Temp::PhysicalRegister, 1);
- Temp fp2(DoubleType, Temp::PhysicalRegister, 2);
- Temp fp3(DoubleType, Temp::PhysicalRegister, 3);
- Temp fp4(DoubleType, Temp::PhysicalRegister, 4);
- Temp fp5(DoubleType, Temp::PhysicalRegister, 5);
- Temp fp6(DoubleType, Temp::PhysicalRegister, 6);
- Temp fp7(DoubleType, Temp::PhysicalRegister, 7);
- Temp fp8(DoubleType, Temp::PhysicalRegister, 8);
- Temp fp9(DoubleType, Temp::PhysicalRegister, 9);
- Temp fp10(DoubleType, Temp::PhysicalRegister, 10);
- Temp fp11(DoubleType, Temp::PhysicalRegister, 11);
- Temp fp12(DoubleType, Temp::PhysicalRegister, 12);
- Temp fp13(DoubleType, Temp::PhysicalRegister, 13);
-
- MoveMapping mapping;
- mapping.add(&fp2, &fp1);
- mapping.add(&fp2, &fp3);
- mapping.add(&fp3, &fp2);
- mapping.add(&fp3, &fp4);
-
- mapping.add(&fp9, &fp8);
- mapping.add(&fp8, &fp7);
- mapping.add(&fp7, &fp6);
- mapping.add(&fp7, &fp5);
-
- mapping.add(&fp10, &fp11);
- mapping.add(&fp11, &fp12);
- mapping.add(&fp12, &fp13);
- mapping.add(&fp13, &fp10);
-
- mapping.order();
-// mapping.dump();
-
- QCOMPARE(mapping._moves.size(), 10);
-
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp2, &fp1, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp3, &fp4, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp7, &fp6, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp7, &fp5, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp8, &fp7, false)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp9, &fp8, false)));
-
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp2, &fp3, true)) ||
- mapping._moves.contains(MoveMapping::Move(&fp3, &fp2, true)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp10, &fp13, true)) ||
- mapping._moves.contains(MoveMapping::Move(&fp13, &fp10, true)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp12, &fp13, true)) ||
- mapping._moves.contains(MoveMapping::Move(&fp13, &fp12, true)));
- QVERIFY(mapping._moves.contains(MoveMapping::Move(&fp12, &fp11, true)) ||
- mapping._moves.contains(MoveMapping::Move(&fp11, &fp12, true)));
-
- QVERIFY(!mapping._moves.at(0).needsSwap);
- QVERIFY(!mapping._moves.at(1).needsSwap);
- QVERIFY(!mapping._moves.at(2).needsSwap);
- QVERIFY(!mapping._moves.at(3).needsSwap);
- QVERIFY(!mapping._moves.at(4).needsSwap);
- QVERIFY(!mapping._moves.at(5).needsSwap);
- QVERIFY(mapping._moves.at(6).needsSwap);
- QVERIFY(mapping._moves.at(7).needsSwap);
- QVERIFY(mapping._moves.at(8).needsSwap);
- QVERIFY(mapping._moves.at(9).needsSwap);
}
-QTEST_MAIN(tst_v4misc)
+QTEST_MAIN(tst_v4misc);
#include "tst_v4misc.moc"
diff --git a/tests/auto/qmltest/listview/data/MultiDelegate.qml b/tests/auto/qmltest/listview/data/MultiDelegate.qml
new file mode 100644
index 0000000000..b9640c18b4
--- /dev/null
+++ b/tests/auto/qmltest/listview/data/MultiDelegate.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQml.Models 2.12
+import Qt.labs.qmlmodels 1.0
+
+ListView {
+ width: 400
+ height: 400
+ model: ListModel {
+ ListElement { dataType: "rect"; color: "red" }
+ ListElement { dataType: "image"; source: "logo.png" }
+ ListElement { dataType: "text"; text: "Hello" }
+ ListElement { dataType: "text"; text: "World" }
+ ListElement { dataType: "rect"; color: "green" }
+ ListElement { dataType: "image"; source: "logo.png" }
+ ListElement { dataType: "rect"; color: "blue" }
+ ListElement { dataType: "" }
+ }
+
+ delegate: DelegateChooser {
+ role: "dataType"
+ DelegateChoice {
+ roleValue: "image"
+ delegate: Image {
+ width: parent.width
+ height: 50
+ fillMode: Image.PreserveAspectFit
+ source: model.source
+ }
+ }
+ DelegateChoice {
+ roleValue: "rect"
+ delegate: Rectangle {
+ width: parent.width
+ height: 50
+ color: model.color
+ }
+ }
+ DelegateChoice {
+ roleValue: "text"
+ delegate: Text {
+ width: parent.width
+ height: 50
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: model.text
+ }
+ }
+
+ DelegateChoice {
+ delegate: Item {
+ width: parent.width
+ height: 50
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/Banner.qml b/tests/auto/qmltest/listview/data/MultiDelegate2.qml
index bcba122043..f623204b98 100644
--- a/examples/quick/demos/stocqt/content/Banner.qml
+++ b/tests/auto/qmltest/listview/data/MultiDelegate2.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,49 +48,54 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Layouts 1.1
+import QtQuick 2.12
+import QtQml.Models 2.12
+import Qt.labs.qmlmodels 1.0
-Rectangle {
- id: banner
- height: 80
- color: "#000000"
+ListView {
+ width: 400
+ height: 400
+ model: 8
- GridLayout {
- anchors.fill: parent
- rows: 1
- columns: 3
- Rectangle {
- Layout.leftMargin: 10
- Layout.topMargin: 20
- Layout.alignment: Qt.AlignLeft | Qt.AlignTop
- Image {
- id: arrow
- source: "./images/icon-left-arrow.png"
- visible: root.currentIndex == 1 ? true : false
-
- MouseArea {
- anchors.fill: parent
- onClicked: root.currentIndex = 0;
- }
+ delegate: DelegateChooser {
+ DelegateChoice {
+ index: 0
+ delegate: Item {
+ property string choiceType: "1"
+ width: parent.width
+ height: 50
+ }
+ }
+ DelegateChoice {
+ index: 1
+ delegate: Item {
+ property string choiceType: "2"
+ width: parent.width
+ height: 50
}
}
- Text {
- id: stocText
- color: "#ffffff"
- font.family: "Abel"
- font.pointSize: 40
- text: "Stoc"
- Layout.alignment: Qt.AlignRight
- Layout.leftMargin: parent.width / 2.5
+ DelegateChoice {
+ index: 2
+ delegate: Item {
+ property string choiceType: "3"
+ width: parent.width
+ height: 50
+ }
}
- Text {
- id: qtText
- color: "#5caa15"
- font.family: "Abel"
- font.pointSize: 40
- text: "Qt"
- Layout.fillWidth: true
+ DelegateChoice {
+ index: 5
+ delegate: Item {
+ property string choiceType: "3"
+ width: parent.width
+ height: 50
+ }
+ }
+ DelegateChoice {
+ delegate: Item {
+ property string choiceType: "4"
+ width: parent.width
+ height: 50
+ }
}
}
}
diff --git a/tests/auto/qmltest/listview/data/logo.png b/tests/auto/qmltest/listview/data/logo.png
new file mode 100644
index 0000000000..d75936b007
--- /dev/null
+++ b/tests/auto/qmltest/listview/data/logo.png
Binary files differ
diff --git a/tests/auto/qmltest/listview/listview.pro b/tests/auto/qmltest/listview/listview.pro
index a7938e7003..b942729ffa 100644
--- a/tests/auto/qmltest/listview/listview.pro
+++ b/tests/auto/qmltest/listview/listview.pro
@@ -1 +1,2 @@
CONFIG += qmltestcase
+DISTFILES += $$PWD/tst_listview.qml $$files($$PWD/data/*.qml)
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index f7a34cbce2..5e9bb22e8e 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -50,6 +50,7 @@
import QtQuick 2.1
import QtTest 1.1
+import "data"
Item {
id: top
@@ -204,6 +205,14 @@ Item {
ListElement { component: "data/asynclistviewloader.qml" }
}
+ MultiDelegate {
+ id: multiDelegate
+ }
+
+ MultiDelegate2 {
+ id: multiDelegate2
+ }
+
TestCase {
name: "ListView"
when: windowShown
@@ -363,5 +372,47 @@ Item {
function test_viewWithAction() {
compare(viewWithActionModel.funcResult, "one")
}
+
+ function test_multipleDelegates_data() {
+ return [
+ { y: 25, type: "Rectangle", value: "red" },
+ { y: 75, type: "Image", value: Qt.resolvedUrl("data/logo.png") },
+ { y: 125, type: "Text", value: "Hello" },
+ { y: 175, type: "Text", value: "World" },
+ { y: 225, type: "Rectangle", value: "green" },
+ { y: 275, type: "Image", value: Qt.resolvedUrl("data/logo.png") },
+ { y: 325, type: "Rectangle", value: "blue" },
+ { y: 375, type: "Item", value: "" }
+ ]
+ }
+
+ function test_multipleDelegates(row) {
+ var delegate = multiDelegate.itemAt(10, row.y)
+ verify(delegate.toString().includes(row.type))
+ switch (row.type) {
+ case "Rectangle": verify(Qt.colorEqual(delegate.color, row.value)); break
+ case "Text": compare(delegate.text, row.value); break
+ case "Image": compare(delegate.source, row.value); break
+ case "Item": break
+ }
+ }
+
+ function test_multipleDelegates2_data() {
+ return [
+ { y: 25, type: "1" },
+ { y: 75, type: "2" },
+ { y: 125, type: "3" },
+ { y: 175, type: "4" },
+ { y: 225, type: "4" },
+ { y: 275, type: "3" },
+ { y: 325, type: "4" },
+ { y: 375, type: "4" }
+ ]
+ }
+
+ function test_multipleDelegates2(row) {
+ var delegate = multiDelegate2.itemAt(10, row.y)
+ compare(delegate.choiceType, row.type)
+ }
}
}
diff --git a/tests/auto/qmltest/rectangle/tst_rectangle.qml b/tests/auto/qmltest/rectangle/tst_rectangle.qml
index 9af55b6a79..cf57da0d73 100644
--- a/tests/auto/qmltest/rectangle/tst_rectangle.qml
+++ b/tests/auto/qmltest/rectangle/tst_rectangle.qml
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
import QtTest 1.1
Item {
@@ -83,6 +83,17 @@ Item {
}
Rectangle {
+ id: horizontalGradient
+ width: 300
+ height: 100
+ gradient: Gradient {
+ orientation: Gradient.Horizontal
+ GradientStop { position: 0.0; color: "red" }
+ GradientStop { position: 1.0; color: "green" }
+ }
+ }
+
+ Rectangle {
id: rectangleborder
width: 300
height: 150
@@ -132,8 +143,18 @@ Item {
compare(gstops[0].color.toString(), "#ff0000")
compare(gstops[1].color.toString(), "#ffff00")
compare(gstops[2].color.toString(), "#008000")
+ compare(grad.orientation, Gradient.Vertical)
+ }
+
+ function test_horizontalGradient() {
+ var grad = horizontalGradient.gradient;
+ var gstops = grad.stops;
+ compare(gstops[0].color.toString(), "#ff0000")
+ compare(gstops[1].color.toString(), "#008000")
+ compare(grad.orientation, Gradient.Horizontal)
}
+
function test_borders() {
compare(rectangleborder.border.width, 1)
compare(rectangleborder.border.color.toString(), "#808080")
diff --git a/tests/auto/qmltest/shadersource/BLACKLIST b/tests/auto/qmltest/shadersource/BLACKLIST
index cc1e110153..e788c776ba 100644
--- a/tests/auto/qmltest/shadersource/BLACKLIST
+++ b/tests/auto/qmltest/shadersource/BLACKLIST
@@ -1,3 +1,5 @@
# Blacklist for testing
[shadersource-dynamic-sourceobject::test_endresult]
linux
+[shadersource-dynamic-shadersource::test_endresult]
+ubuntu-18.04
diff --git a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
index fe794cf952..afc66948b0 100644
--- a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
+++ b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp
@@ -51,8 +51,8 @@ public:
view.setResizeMode(QQuickView::SizeViewToRootObject);
view.setSource(testFileUrl(fileName));
view.setVisible(true);
- QTest::qWaitForWindowExposed(&view);
- return view.grabWindow();
+ bool exposed = QTest::qWaitForWindowExposed(&view);
+ return exposed ? view.grabWindow() : QImage();
}
//It is important for platforms that only are able to show fullscreen windows
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index eee8dfcf26..ea8830fefa 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -74,7 +74,6 @@ tst_examples::tst_examples()
{
// Add files to exclude here
excludedFiles << "snippets/qml/listmodel/listmodel.qml"; //Just a ListModel, no root QQuickItem
- excludedFiles << "examples/quick/demos/photosurface/photosurface.qml"; // root item is Window rather than Item
// Add directories you want excluded here
excludedDirs << "shared"; //Not an example
@@ -91,9 +90,6 @@ tst_examples::tst_examples()
excludedFiles << "examples/quick/shapes/content/interactive.qml"; // relies on resources
#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "demos/twitter";
- excludedDirs << "demos/flickr";
- excludedDirs << "demos/photoviewer";
excludedFiles << "snippets/qml/xmlrole.qml";
excludedFiles << "particles/itemparticle/particleview.qml";
excludedFiles << "views/visualdatamodel/slideshow.qml";
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/GrooveDragSlider.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/GrooveDragSlider.qml
new file mode 100644
index 0000000000..7a32170bed
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/GrooveDragSlider.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Item {
+ id: root
+ property int value: 50
+ property int maximumValue: 99
+ property alias label: label.text
+ property alias tapEnabled: tap.enabled
+ property alias pressed: tap.pressed
+ signal tapped
+
+ DragHandler {
+ id: dragHandler
+ objectName: root.objectName + " DragHandler"
+ target: knob
+ xAxis.enabled: false
+ yAxis.minimum: slot.y
+ yAxis.maximum: slot.height + slot.y - knob.height
+ }
+
+ Rectangle {
+ id: slot
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ anchors.topMargin: 30
+ anchors.bottomMargin: 30
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: 10
+ color: "black"
+ radius: width / 2
+ smooth: true
+ }
+
+ Rectangle {
+ id: glow
+ anchors.fill: knob
+ anchors.margins: -5
+ anchors.leftMargin: -2
+ anchors.horizontalCenterOffset: 1
+ radius: 5
+ color: "#4400FFFF"
+ opacity: tap.pressed || tapFlash.running ? 1 : 0
+ FlashAnimation on visible {
+ id: tapFlash
+ }
+ }
+ Rectangle {
+ id: knob
+ objectName: "Slider Knob"
+ width: parent.width - 2
+ height: 20
+ radius: 5
+ color: "darkgray"
+ border.color: "black"
+ property bool programmatic: false
+ property real multiplier: root.maximumValue / (dragHandler.yAxis.maximum - dragHandler.yAxis.minimum)
+ onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier
+ transformOrigin: Item.Center
+ function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier }
+ TapHandler {
+ id: tap
+ objectName: root.objectName + " TapHandler"
+ gesturePolicy: TapHandler.DragThreshold
+ onTapped: {
+ tapFlash.start()
+ root.tapped
+ }
+ }
+ }
+
+ Text {
+ color: "red"
+ anchors.top: slot.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: root.value
+ }
+
+ Text {
+ id: label
+ font.pointSize: 9
+ color: "red"
+ anchors.bottom: slot.top
+ anchors.bottomMargin: 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ verticalAlignment: Text.AlignBottom
+ }
+
+ Component.onCompleted: {
+ knob.programmatic = true
+ knob.setValue(root.value)
+ knob.programmatic = false
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/KnobDragSlider.qml
index f6acd53615..b3d621c447 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/data/Slider.qml
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/KnobDragSlider.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
@@ -80,14 +79,14 @@ Item {
function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier }
DragHandler {
id: dragHandler
- objectName: label.text + " DragHandler"
+ objectName: root.objectName + " DragHandler"
xAxis.enabled: false
yAxis.minimum: slot.y
yAxis.maximum: slot.height + slot.y - knob.height
}
TapHandler {
id: tap
- objectName: label.text + " TapHandler"
+ objectName: root.objectName + " TapHandler"
gesturePolicy: TapHandler.DragThreshold
onTapped: {
tapFlash.start()
@@ -97,20 +96,20 @@ Item {
}
Text {
- font.pointSize: 16
color: "red"
- anchors.bottom: parent.bottom
+ anchors.top: slot.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: root.value
}
Text {
id: label
- font.pointSize: 12
+ font.pointSize: 9
color: "red"
- anchors.top: parent.top
- anchors.topMargin: 5
+ anchors.bottom: slot.top
+ anchors.bottomMargin: 5
anchors.horizontalCenter: parent.horizontalCenter
+ verticalAlignment: Text.AlignBottom
}
Component.onCompleted: {
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml
index 55f77460f1..2c9fa30a70 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/TapHandlerButton.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml b/tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml
index 7d7f53dd15..5693a6acd2 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/data/flickableWithHandlers.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
@@ -46,10 +45,15 @@ Rectangle {
Row {
spacing: 6
- Slider {
- label: "DragHandler"
- objectName: "Slider"
- value: 49; width: 100; height: 400
+ KnobDragSlider {
+ label: "Slider with\nDH on knob"
+ objectName: "knobSlider"
+ value: 49; width: 120; height: 400
+ }
+ GrooveDragSlider {
+ label: "Slider with\nDH on root"
+ objectName: "grooveSlider"
+ value: 49; width: 120; height: 400
}
Column {
spacing: 6
@@ -80,6 +84,7 @@ Rectangle {
objectName: "drag"
DragHandler {
id: drag1
+ objectName: "drag1"
}
Text {
anchors.centerIn: parent
@@ -96,6 +101,7 @@ Rectangle {
border.width: 3
TapHandler {
id: tap1
+ objectName: "tap1"
gesturePolicy: TapHandler.DragThreshold
}
Text {
@@ -113,9 +119,11 @@ Rectangle {
objectName: "dragAndTap"
DragHandler {
id: drag2
+ objectName: "drag2"
}
TapHandler {
id: tap2
+ objectName: "tap2"
gesturePolicy: TapHandler.DragThreshold
}
Text {
@@ -133,10 +141,12 @@ Rectangle {
objectName: "tapAndDrag"
TapHandler {
id: tap3
+ objectName: "tap3"
gesturePolicy: TapHandler.DragThreshold
}
DragHandler {
id: drag3
+ objectName: "drag3"
}
Text {
anchors.centerIn: parent
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
index f3513881cd..e544eedf05 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -57,8 +57,6 @@ public:
{}
private slots:
- void initTestCase();
-
void touchTapButton_data();
void touchTapButton();
void touchDragFlickableBehindButton_data();
@@ -69,6 +67,7 @@ private slots:
void mouseDragFlickableBehindButton();
void touchDragSlider();
void touchDragFlickableBehindSlider();
+ void mouseDragSlider_data();
void mouseDragSlider();
void mouseDragFlickableBehindSlider();
void touchDragFlickableBehindItemWithHandlers_data();
@@ -92,15 +91,7 @@ void tst_FlickableInterop::createView(QScopedPointer<QQuickView> &window, const
window->show();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
- QVERIFY(window->rootObject() != 0);
-}
-
-void tst_FlickableInterop::initTestCase()
-{
- // This test assumes that we don't get synthesized mouse events from QGuiApplication
- qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
-
- QQmlDataTest::initTestCase();
+ QVERIFY(window->rootObject() != nullptr);
}
void tst_FlickableInterop::touchTapButton_data()
@@ -189,8 +180,8 @@ void tst_FlickableInterop::touchDragFlickableBehindButton()
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
}
+ qCDebug(lcPointerTests) << "flickable started moving after" << i << "moves, when we got to" << p1;
QVERIFY(flickable->isMoving());
- qDebug() << "flickable started moving after" << i << "moves, when we got to" << p1;
QCOMPARE(i, 2);
QVERIFY(!button->property("pressed").toBool());
QTest::touchEvent(window, touchDevice).release(1, p1, window);
@@ -230,7 +221,7 @@ void tst_FlickableInterop::mouseClickButton()
// We can drag <= dragThreshold and the button still acts normal, Flickable doesn't grab
p1 = button->mapToScene(QPointF(20, 20)).toPoint();
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1, qApp->styleHints()->mouseDoubleClickInterval() + 10);
QTRY_VERIFY(button->property("pressed").toBool());
p1 += QPoint(dragThreshold, 0);
QTest::mouseMove(window, p1);
@@ -277,7 +268,7 @@ void tst_FlickableInterop::mouseDragFlickableBehindButton()
p1 += QPoint(1, 0);
QTest::mouseMove(window, p1);
}
- qDebug() << "flickable started moving after" << i << "moves, when we got to" << p1;
+ qCDebug(lcPointerTests) << "flickable started moving after" << i << "moves, when we got to" << p1;
QVERIFY(flickable->isMoving());
QCOMPARE(i, 2);
QVERIFY(!button->property("pressed").toBool());
@@ -293,7 +284,7 @@ void tst_FlickableInterop::touchDragSlider()
createView(windowPtr, "flickableWithHandlers.qml");
QQuickView * window = windowPtr.data();
- QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("Slider");
+ QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("knobSlider");
QVERIFY(slider);
QQuickDragHandler *drag = slider->findChild<QQuickDragHandler*>();
QVERIFY(drag);
@@ -339,6 +330,26 @@ void tst_FlickableInterop::touchDragSlider()
QCOMPARE(translationChangedSpy.count(), 1);
}
+void tst_FlickableInterop::mouseDragSlider_data()
+{
+ QTest::addColumn<QString>("nameOfSliderToDrag");
+ QTest::addColumn<QPoint>("pressPositionRelativeToKnob");
+ QTest::addColumn<QPoint>("dragDirection"); // a unit vector
+ QTest::addColumn<bool>("expectedTapHandlerPressed");
+ QTest::addColumn<bool>("expectedDragHandlerActive");
+ QTest::addColumn<bool>("expectedFlickableMoving");
+
+ QTest::newRow("drag down on knob of knobSlider") << "knobSlider" << QPoint(0, 0) << QPoint(0, 1) << true << true << false;
+ QTest::newRow("drag sideways on knob of knobSlider") << "knobSlider" << QPoint(0, 0) << QPoint(1, 0) << true << false << true;
+ QTest::newRow("drag down on groove of knobSlider") << "knobSlider" << QPoint(0, 20) << QPoint(0, 1) << false << false << true;
+ QTest::newRow("drag sideways on groove of knobSlider") << "knobSlider" << QPoint(0, 20) << QPoint(1, 0) << false << false << true;
+
+ QTest::newRow("drag down on knob of grooveSlider") << "grooveSlider" << QPoint(0, 0) << QPoint(0, 1) << true << true << false;
+ QTest::newRow("drag sideways on knob of grooveSlider") << "grooveSlider" << QPoint(0, 0) << QPoint(1, 0) << true << false << true;
+ QTest::newRow("drag down on groove of grooveSlider") << "grooveSlider" << QPoint(0, 20) << QPoint(0, 1) << false << true << false;
+ QTest::newRow("drag sideways on groove of grooveSlider") << "grooveSlider" << QPoint(0, 20) << QPoint(1, 0) << false << false << true;
+}
+
void tst_FlickableInterop::mouseDragSlider()
{
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
@@ -346,7 +357,14 @@ void tst_FlickableInterop::mouseDragSlider()
createView(windowPtr, "flickableWithHandlers.qml");
QQuickView * window = windowPtr.data();
- QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("Slider");
+ QFETCH(QString, nameOfSliderToDrag);
+ QFETCH(QPoint, pressPositionRelativeToKnob);
+ QFETCH(QPoint, dragDirection); // a unit vector
+ QFETCH(bool, expectedTapHandlerPressed);
+ QFETCH(bool, expectedDragHandlerActive);
+ QFETCH(bool, expectedFlickableMoving);
+
+ QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>(nameOfSliderToDrag);
QVERIFY(slider);
QQuickDragHandler *drag = slider->findChild<QQuickDragHandler*>();
QVERIFY(drag);
@@ -357,33 +375,40 @@ void tst_FlickableInterop::mouseDragSlider()
QSignalSpy tappedSpy(knob->parent(), SIGNAL(tapped()));
QSignalSpy translationChangedSpy(drag, SIGNAL(translationChanged()));
- // Drag the slider in the allowed (vertical) direction
+ // Drag the slider
tappedSpy.clear();
- QPoint p1 = knob->mapToScene(knob->clipRect().center()).toPoint();
+ QPoint p1 = knob->mapToScene(knob->clipRect().center()).toPoint() + pressPositionRelativeToKnob;
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
- QTRY_VERIFY(slider->property("pressed").toBool());
- p1 += QPoint(0, dragThreshold);
+ QTRY_COMPARE(slider->property("pressed").toBool(), expectedTapHandlerPressed);
+ p1 += QPoint(dragThreshold * dragDirection.x(), dragThreshold * dragDirection.y());
QTest::mouseMove(window, p1);
- QVERIFY(slider->property("pressed").toBool());
+ QCOMPARE(drag->active(), false);
+ QCOMPARE(slider->property("pressed").toBool(), expectedTapHandlerPressed);
QCOMPARE(slider->property("value").toInt(), 49);
- p1 += QPoint(0, 1);
+ p1 += dragDirection; // one more pixel
QTest::mouseMove(window, p1);
- p1 += QPoint(0, 10);
+ QCOMPARE(drag->active(), expectedDragHandlerActive);
+ // drag farther, to make sure the knob gets adjusted significantly
+ p1 += QPoint(10 * dragDirection.x(), 10 * dragDirection.y());
QTest::mouseMove(window, p1);
- QVERIFY(slider->property("value").toInt() < 49);
- QVERIFY(!flickable->isMoving());
- QVERIFY(!slider->property("pressed").toBool());
+ if (expectedDragHandlerActive && dragDirection.y() > 0)
+ QVERIFY(slider->property("value").toInt() < 49);
+ // by now, Flickable will have stolen the grab, if it decided that it wanted to during filtering of the last event
+ QCOMPARE(flickable->isMoving(), expectedFlickableMoving);
+ QCOMPARE(slider->property("pressed").toBool(), false);
- // Now that the DragHandler is active, the Flickable will not steal the grab
+ // If the DragHandler is active, the Flickable will not steal the grab
// even if we move a large distance horizontally
- p1 += QPoint(dragThreshold * 2, 0);
- QTest::mouseMove(window, p1);
- QVERIFY(!flickable->isMoving());
+ if (expectedDragHandlerActive) {
+ p1 += QPoint(dragThreshold * 2, 0);
+ QTest::mouseMove(window, p1);
+ QCOMPARE(flickable->isMoving(), false);
+ }
// Release, and do not expect the tapped signal
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(tappedSpy.count(), 0);
- QCOMPARE(translationChangedSpy.count(), 1);
+ QCOMPARE(translationChangedSpy.count(), expectedDragHandlerActive ? 1 : 0);
}
void tst_FlickableInterop::touchDragFlickableBehindSlider()
@@ -393,7 +418,7 @@ void tst_FlickableInterop::touchDragFlickableBehindSlider()
createView(windowPtr, "flickableWithHandlers.qml");
QQuickView * window = windowPtr.data();
- QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("Slider");
+ QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("knobSlider");
QVERIFY(slider);
QQuickDragHandler *drag = slider->findChild<QQuickDragHandler*>();
QVERIFY(drag);
@@ -421,7 +446,7 @@ void tst_FlickableInterop::touchDragFlickableBehindSlider()
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
}
- qDebug() << "flickable started moving after" << i << "moves, when we got to" << p1;
+ qCDebug(lcPointerTests) << "flickable started moving after" << i << "moves, when we got to" << p1;
QVERIFY(flickable->isMoving());
QCOMPARE(i, 2);
QVERIFY(!slider->property("pressed").toBool());
@@ -439,7 +464,7 @@ void tst_FlickableInterop::mouseDragFlickableBehindSlider()
createView(windowPtr, "flickableWithHandlers.qml");
QQuickView * window = windowPtr.data();
- QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("Slider");
+ QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("knobSlider");
QVERIFY(slider);
QQuickDragHandler *drag = slider->findChild<QQuickDragHandler*>();
QVERIFY(drag);
@@ -465,7 +490,7 @@ void tst_FlickableInterop::mouseDragFlickableBehindSlider()
p1 += QPoint(1, 0);
QTest::mouseMove(window, p1);
}
- qDebug() << "flickable started moving after" << i << "moves, when we got to" << p1;
+ qCDebug(lcPointerTests) << "flickable started moving after" << i << "moves, when we got to" << p1;
QVERIFY(flickable->isMoving());
QCOMPARE(i, 2);
QVERIFY(!slider->property("pressed").toBool());
@@ -568,7 +593,7 @@ void tst_FlickableInterop::touchDragSliderAndFlickable()
createView(windowPtr, "flickableWithHandlers.qml");
QQuickView * window = windowPtr.data();
- QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("Slider");
+ QQuickItem *slider = window->rootObject()->findChild<QQuickItem*>("knobSlider");
QVERIFY(slider);
QQuickDragHandler *drag = slider->findChild<QQuickDragHandler*>();
QVERIFY(drag);
@@ -576,6 +601,7 @@ void tst_FlickableInterop::touchDragSliderAndFlickable()
QVERIFY(knob);
QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>();
QVERIFY(flickable);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
// The knob is initially centered over the slider's "groove"
qreal initialXOffset = qAbs(knob->mapToScene(knob->clipRect().center()).x() - slider->mapToScene
@@ -584,66 +610,45 @@ void tst_FlickableInterop::touchDragSliderAndFlickable()
// Drag the slider in the allowed (vertical) direction with one finger
QPoint p1 = knob->mapToScene(knob->clipRect().center()).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ touchSeq.press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
p1 += QPoint(0, dragThreshold);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ touchSeq.move(1, p1, window).commit();
QQuickTouchUtils::flush(window);
p1 += QPoint(0, dragThreshold);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ touchSeq.move(1, p1, window).commit();
QQuickTouchUtils::flush(window);
p1 += QPoint(0, dragThreshold);
- QTest::touchEvent(window, touchDevice).move(1, p1, window);
+ touchSeq.move(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(slider->property("value").toInt() < 49);
QVERIFY(!flickable->isMoving());
// Drag the Flickable with a second finger
QPoint p2(300,300);
- QTest::touchEvent(window, touchDevice).stationary(1).press(2, p2, window);
+ touchSeq.stationary(1).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).stationary(2);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).stationary(1).move(2, p2, window);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).stationary(2);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).stationary(1).move(2, p2, window);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).stationary(2);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).stationary(1).move(2, p2, window);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).stationary(2);
- QQuickTouchUtils::flush(window);
- p1 += QPoint(-10, -10);
- p2 += QPoint(dragThreshold, 0);
- QTest::touchEvent(window, touchDevice).stationary(1).move(2, p2, window);
- QQuickTouchUtils::flush(window);
- QTRY_VERIFY(flickable->isMoving());
+ for (int i = 0; i < 4; ++i) {
+ p1 += QPoint(-10, -10);
+ p2 += QPoint(dragThreshold, 0);
+ touchSeq.move(1, p1, window).stationary(2).commit();
+ QQuickTouchUtils::flush(window);
+ p1 += QPoint(-10, -10);
+ p2 += QPoint(dragThreshold, 0);
+ touchSeq.stationary(1).move(2, p2, window).commit();
+ QQuickTouchUtils::flush(window);
+ qCDebug(lcPointerTests) << "step" << i << ": fingers @" << p1 << p2 << "is Flickable moving yet?" << flickable->isMoving();
+ }
+ QVERIFY(flickable->isMoving());
qreal knobSliderXOffset = qAbs(knob->mapToScene(knob->clipRect().center()).toPoint().x() -
slider->mapToScene(slider->clipRect().center()).toPoint().x()) - initialXOffset;
if (knobSliderXOffset > 1)
- qDebug() << "knob has slipped out of groove by" << knobSliderXOffset << "pixels";
+ qCDebug(lcPointerTests) << "knob has slipped out of groove by" << knobSliderXOffset << "pixels";
// See if the knob is still centered over the slider's "groove"
QVERIFY(qAbs(knobSliderXOffset) <= 1);
// Release
- QTest::touchEvent(window, touchDevice).release(1, p1, window).release(2, p2, window);
+ touchSeq.release(1, p1, window).release(2, p2, window).commit();
}
QTEST_MAIN(tst_FlickableInterop)
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
index 084cc25414..f1591a412e 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/data/pinchDragMPTA.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
width: 1024; height: 600
@@ -94,6 +93,7 @@ Rectangle {
id: dragHandler
objectName: "DragHandler"
target: container
+ grabPermissions: PointerHandler.CanTakeOverFromItems
}
PinchHandler {
id: pinch3
@@ -102,6 +102,7 @@ Rectangle {
minimumPointCount: 3
minimumScale: 0.1
maximumScale: 10
+ grabPermissions: PointerHandler.CanTakeOverFromItems
}
}
}
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index 4b096f9c3a..b994e0fc07 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -105,12 +105,12 @@ void tst_MptaInterop::touchDrag()
// Press one touchpoint:
// DragHandler gets a passive grab
// PinchHandler declines, because it wants 3 touchpoints
- // MPTA doesn't get a chance, because DragHandler accepted the single EventPoint
+ // MPTA grabs because DragHandler doesn't accept the single EventPoint
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice);
- QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag));
// Start moving
@@ -161,7 +161,7 @@ void tst_MptaInterop::touchesThenPinch()
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr);
+ QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
QTRY_COMPARE(pointerEvent->point(0)->passiveGrabbers().first(), drag);
// Press a second touchpoint: MPTA grabs it
@@ -170,56 +170,50 @@ void tst_MptaInterop::touchesThenPinch()
QQuickTouchUtils::flush(window);
QVERIFY(tp.at(0)->property("pressed").toBool());
QTRY_VERIFY(tp.at(1)->property("pressed").toBool());
- QCOMPARE(mptaPressedSpy.count(), 1);
-
- // ATM it's required that when PinchHandler sees the third touchpoint,
- // the pre-existing points must have moved far enough to exceed the drag threshold.
- // If MPTA is allowed to grab that third point, then PinchHandler won't steal.
- // TODO should we change that? make sure that if PH has a passive grab, it always gets updated even though MPTA has the grab?
- for (int i = 0; i < 2; ++i) {
- p1 += QPoint(dragThreshold, dragThreshold);
- p2 += QPoint(dragThreshold, dragThreshold);
- touch.move(1, p1).move(2, p2).commit();
- }
+ QCOMPARE(mptaPressedSpy.count(), 2);
- // Press a third touchpoint: PinchHandler grabs, MPTA loses its grabs
+ // Press a third touchpoint: MPTA grabs it too
QPoint p3 = mpta->mapToScene(QPointF(110, 200)).toPoint();
touch.stationary(1).stationary(2).press(3, p3).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
- QCOMPARE(mptaPressedSpy.count(), 1);
- QCOMPARE(mptaCanceledSpy.count(), 1);
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
- QTRY_COMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
- QTRY_COMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
- QVERIFY(pinch->active());
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
+ QCOMPARE(mptaPressedSpy.count(), 3);
+ QCOMPARE(mptaCanceledSpy.count(), 0);
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
+ QVERIFY(!pinch->active());
// Start moving: PinchHandler steals the exclusive grab from MPTA as soon as dragThreshold is exceeded
int pinchStoleGrab = 0;
- for (int i = 0; i < 8; ++i) {
- p1 += QPoint(dragThreshold / 2, dragThreshold / 2);
- p2 += QPoint(dragThreshold / 2, dragThreshold / 2);
- p3 += QPoint(-dragThreshold / 2, dragThreshold / 2);
+
+ const QPointF c = (p1 + p2 + p3)/3; // centroid of p1,p2,p3
+ QTransform xform; // transform to rotate around the centroid
+ xform.translate(c.x(), c.y()).rotate(1).translate(-c.x(), -c.y());
+
+ for (int i = 0; i < 16; ++i) {
+ p1 = xform.map(p1);
+ p2 = xform.map(p2);
+ p3 = xform.map(p3);
touch.move(1, p1).move(2, p2).move(3, p3).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(tp.at(0)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
- if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch)
+ if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch) {
pinchStoleGrab = i;
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
+ }
}
- qCDebug(lcPointerTests) << "pinch started after" << pinchStoleGrab << "moves; ended with scale" << pinch->scale() << "rot" << pinch->rotation();
+ qCDebug(lcPointerTests) << "pinch started after" << pinchStoleGrab << "moves; ended with scale" << pinch->activeScale() << "rot" << pinch->rotation();
QTRY_VERIFY(pinch->rotation() > 4);
- QVERIFY(pinch->scale() > 1);
+ QVERIFY(pinch->activeScale() > 1);
// Press one more point (pinkie finger)
QPoint p4 = mpta->mapToScene(QPointF(300, 200)).toPoint();
touch.move(1, p1).move(2, p2).move(3, p3).press(4, p4).commit();
- // PinchHandler gives up its grabs (only on non-stationary points at this time: see QQuickPointerHandler::handlePointerEvent())
- // because it has minimum touch points 3, maximum touch points 3, and now there are 4 points.
- // MPTA grabs all points which are not already grabbed
+ // PinchHandler deactivates, which lets MPTA grab all the points
QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
@@ -269,13 +263,19 @@ void tst_MptaInterop::touchesThenPinch()
// Release another finger
touch.stationary(2).release(3, p3).commit();
- // Move some more: DragHandler reacts.
- // It had a passive grab this whole time; now it activates and gets an exclusive grab.
+ // Move some more: DragHandler eventually reacts.
+ int dragTookGrab = 0;
for (int i = 0; i < 8; ++i) {
p2 += QPoint(8, -8);
touch.move(2, p2).commit();
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), drag);
+ QQuickTouchUtils::flush(window);
+ QVERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag));
+ if (!dragTookGrab && pointerEvent->point(0)->exclusiveGrabber() == drag)
+ dragTookGrab = i;
}
+ qCDebug(lcPointerTests) << "drag started after" << dragTookGrab << "moves; ended with translation" << drag->translation();
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), drag);
+ QTRY_VERIFY(drag->translation().x() > 0);
touch.release(2, p2).commit();
QQuickTouchUtils::flush(window);
diff --git a/tests/auto/quick/pointerhandlers/pointerhandlers.pro b/tests/auto/quick/pointerhandlers/pointerhandlers.pro
index 2492924944..950d6835eb 100644
--- a/tests/auto/quick/pointerhandlers/pointerhandlers.pro
+++ b/tests/auto/quick/pointerhandlers/pointerhandlers.pro
@@ -4,8 +4,10 @@ qtConfig(private_tests) {
SUBDIRS += \
flickableinterop \
multipointtoucharea_interop \
- qquickpointerhandler \
qquickdraghandler \
+ qquickhoverhandler \
+ qquickpinchhandler \
+ qquickpointerhandler \
+ qquickpointhandler \
qquicktaphandler \
}
-
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml
index fe5f74743d..778a799d70 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/DragAnywhereSlider.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml
index a41a8285b6..782750b783 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/Slider.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
index 5b701b4033..7b3601bea0 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
@@ -40,20 +39,21 @@ Item {
Rectangle {
id: ball
- objectName: "Ball " + index
+ objectName: "Ball " + (index + 1)
color: dragHandler.active ? "blue" : "lightsteelblue"
width: 80; height: 80; x: 200 + index * 200; y: 200; radius: width / 2
onParentChanged: console.log(this + " parent " + parent)
DragHandler {
id: dragHandler
- objectName: "DragHandler " + index
+ objectName: "DragHandler " + (index + 1)
}
Text {
color: "white"
anchors.centerIn: parent
- text: dragHandler.point.position.x.toFixed(1) + "," + dragHandler.point.position.y.toFixed(1)
+ horizontalAlignment: Text.AlignHCenter
+ text: ball.objectName + "\n" + dragHandler.centroid.position.x.toFixed(1) + "," + dragHandler.centroid.position.y.toFixed(1)
}
}
}
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml
index ba6e2d00a8..f6042f4461 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/multipleSliders.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/reparenting.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/reparenting.qml
index 3545badd86..e23cddf7a6 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/reparenting.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/reparenting.qml
@@ -1,5 +1,4 @@
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Grid {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/simpleTapAndDragHandlers.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/simpleTapAndDragHandlers.qml
index adb8332213..6e5574787c 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/simpleTapAndDragHandlers.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/simpleTapAndDragHandlers.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index 53bb10b7b8..0c544ef484 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -119,11 +119,11 @@ void tst_DragHandler::defaultPropertyValues()
QCOMPARE(dragHandler->acceptedButtons(), Qt::LeftButton);
QCOMPARE(dragHandler->translation(), QVector2D());
- QCOMPARE(dragHandler->point().position(), QPointF());
- QCOMPARE(dragHandler->point().scenePosition(), QPointF());
- QCOMPARE(dragHandler->point().pressPosition(), QPointF());
- QCOMPARE(dragHandler->point().scenePressPosition(), QPointF());
- QCOMPARE(dragHandler->point().sceneGrabPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().position(), QPointF());
+ QCOMPARE(dragHandler->centroid().scenePosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().pressPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), QPointF());
}
void tst_DragHandler::touchDrag()
@@ -139,6 +139,7 @@ void tst_DragHandler::touchDrag()
QVERIFY(dragHandler);
QSignalSpy translationChangedSpy(dragHandler, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy(dragHandler, SIGNAL(centroidChanged()));
QPointF ballCenter = ball->clipRect().center();
QPointF scenePressPos = ball->mapToScene(ballCenter);
@@ -146,39 +147,48 @@ void tst_DragHandler::touchDrag()
QTest::touchEvent(window, touchDevice).press(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), scenePressPos);
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
+ QCOMPARE(centroidChangedSpy.count(), 1);
p1 += QPoint(dragThreshold, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
+ QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.count(), 2);
QVERIFY(!dragHandler->active());
p1 += QPoint(1, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
QCOMPARE(translationChangedSpy.count(), 0);
+ QCOMPARE(centroidChangedSpy.count(), 3);
QCOMPARE(dragHandler->translation().x(), 0.0);
QPointF sceneGrabPos = p1;
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
p1 += QPoint(19, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter));
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), ball->mapToScene(ballCenter));
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->translation().y(), 0.0);
+ QVERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.count(), 4);
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
QCOMPARE(translationChangedSpy.count(), 1);
+ QCOMPARE(centroidChangedSpy.count(), 5);
}
void tst_DragHandler::mouseDrag()
@@ -194,41 +204,50 @@ void tst_DragHandler::mouseDrag()
QVERIFY(dragHandler);
QSignalSpy translationChangedSpy(dragHandler, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy(dragHandler, SIGNAL(centroidChanged()));
QPointF ballCenter = ball->clipRect().center();
QPointF scenePressPos = ball->mapToScene(ballCenter);
QPoint p1 = scenePressPos.toPoint();
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
QVERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), scenePressPos);
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().velocity(), QVector2D());
+ QCOMPARE(centroidChangedSpy.count(), 1);
p1 += QPoint(dragThreshold, 0);
QTest::mouseMove(window, p1);
+ QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.count(), 2);
QVERIFY(!dragHandler->active());
p1 += QPoint(1, 0);
QTest::mouseMove(window, p1);
QTRY_VERIFY(dragHandler->active());
QCOMPARE(translationChangedSpy.count(), 0);
+ QCOMPARE(centroidChangedSpy.count(), 3);
QCOMPARE(dragHandler->translation().x(), 0.0);
QPointF sceneGrabPos = p1;
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
p1 += QPoint(19, 0);
QTest::mouseMove(window, p1);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter));
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), ball->mapToScene(ballCenter));
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->translation().y(), 0.0);
+ QVERIFY(dragHandler->centroid().velocity().x() > 0);
+ QCOMPARE(centroidChangedSpy.count(), 4);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_VERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
QCOMPARE(translationChangedSpy.count(), 1);
+ QCOMPARE(centroidChangedSpy.count(), 5);
}
void tst_DragHandler::touchDragMulti()
@@ -243,12 +262,14 @@ void tst_DragHandler::touchDragMulti()
QQuickDragHandler *dragHandler1 = ball1->findChild<QQuickDragHandler*>();
QVERIFY(dragHandler1);
QSignalSpy translationChangedSpy1(dragHandler1, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy1(dragHandler1, SIGNAL(centroidChanged()));
QQuickItem *ball2 = window->rootObject()->childItems().at(1);
QVERIFY(ball2);
QQuickDragHandler *dragHandler2 = ball2->findChild<QQuickDragHandler*>();
QVERIFY(dragHandler2);
QSignalSpy translationChangedSpy2(dragHandler2, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy2(dragHandler1, SIGNAL(centroidChanged()));
QPointF ball1Center = ball1->clipRect().center();
QPointF scenePressPos1 = ball1->mapToScene(ball1Center);
@@ -256,27 +277,41 @@ void tst_DragHandler::touchDragMulti()
QPointF ball2Center = ball2->clipRect().center();
QPointF scenePressPos2 = ball2->mapToScene(ball2Center);
QPoint p2 = scenePressPos2.toPoint();
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
- QTest::touchEvent(window, touchDevice).press(1, p1, window).press(2, p2, window);
+ touchSeq.press(1, p1, window).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
- QCOMPARE(dragHandler1->point().position(), ball1Center);
- QCOMPARE(dragHandler1->point().pressPosition(), ball1Center);
- QCOMPARE(dragHandler1->point().scenePosition(), scenePressPos1);
- QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1);
+ QCOMPARE(centroidChangedSpy1.count(), 1);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition(), scenePressPos1);
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
QVERIFY(!dragHandler2->active());
- QCOMPARE(dragHandler2->point().position(), ball2Center);
- QCOMPARE(dragHandler2->point().pressPosition(), ball2Center);
- QCOMPARE(dragHandler2->point().scenePosition(), scenePressPos2);
- QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2);
+ QCOMPARE(centroidChangedSpy2.count(), 1);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition(), scenePressPos2);
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
p1 += QPoint(dragThreshold, 0);
p2 += QPoint(0, dragThreshold);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window);
+ touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
+ QCOMPARE(centroidChangedSpy1.count(), 2);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center + QPointF(dragThreshold, 0));
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition().toPoint(), p1);
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
+ QVERIFY(!dragHandler2->active());
+ QCOMPARE(centroidChangedSpy2.count(), 2);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center + QPointF(0, dragThreshold));
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition().toPoint(), p2);
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
p1 += QPoint(1, 0);
p2 += QPoint(0, 1);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window);
+ touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler1->active());
QVERIFY(dragHandler2->active());
@@ -284,40 +319,40 @@ void tst_DragHandler::touchDragMulti()
QCOMPARE(dragHandler1->translation().x(), 0.0);
QPointF sceneGrabPos1 = p1;
QPointF sceneGrabPos2 = p2;
- QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
+ QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
p1 += QPoint(19, 0);
p2 += QPoint(0, 19);
QVERIFY(dragHandler2->active());
QCOMPARE(translationChangedSpy2.count(), 0);
QCOMPARE(dragHandler2->translation().x(), 0.0);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
- QTest::touchEvent(window, touchDevice).move(1, p1, window).move(2, p2, window);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
+ touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(dragHandler1->active());
QVERIFY(dragHandler2->active());
- QCOMPARE(dragHandler1->point().position(), ball1Center);
- QCOMPARE(dragHandler1->point().pressPosition(), ball1Center);
- QCOMPARE(dragHandler1->point().scenePosition(), ball1->mapToScene(ball1Center));
- QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1);
- QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition(), ball1->mapToScene(ball1Center));
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
+ QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1);
QCOMPARE(dragHandler1->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler1->translation().y(), 0.0);
- QCOMPARE(dragHandler2->point().position(), ball2Center);
- QCOMPARE(dragHandler2->point().pressPosition(), ball2Center);
- QCOMPARE(dragHandler2->point().scenePosition(), ball2->mapToScene(ball2Center));
- QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition(), ball2->mapToScene(ball2Center));
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
QCOMPARE(dragHandler2->translation().x(), 0.0);
QCOMPARE(dragHandler2->translation().y(), dragThreshold + 20.0);
- QTest::touchEvent(window, touchDevice).release(1, p1, window).stationary(2);
+ touchSeq.release(1, p1, window).stationary(2).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler1->active());
QVERIFY(dragHandler2->active());
- QCOMPARE(dragHandler1->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler1->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball1->mapToScene(ball1Center).toPoint(), p1);
QCOMPARE(translationChangedSpy1.count(), 1);
- QTest::touchEvent(window, touchDevice).release(2, p2, window);
+ touchSeq.release(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler2->active());
QCOMPARE(ball2->mapToScene(ball2Center).toPoint(), p2);
@@ -453,7 +488,12 @@ void tst_DragHandler::touchPassiveGrabbers()
QQuickDragHandler *dragHandler = nullptr;
for (QQuickPointerHandler *handler: expectedPassiveGrabbers) {
- QCOMPARE(static_cast<QQuickSinglePointHandler *>(handler)->point().scenePressPosition(), p1);
+ QPointF scenePressPos;
+ if (QQuickMultiPointHandler *mph = qmlobject_cast<QQuickMultiPointHandler *>(handler))
+ scenePressPos = mph->centroid().scenePressPosition();
+ else
+ scenePressPos = static_cast<QQuickSinglePointHandler *>(handler)->point().scenePressPosition();
+ QCOMPARE(scenePressPos, p1);
QQuickDragHandler *dh = qmlobject_cast<QQuickDragHandler *>(handler);
if (dh)
dragHandler = dh;
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml
new file mode 100644
index 0000000000..9045247e94
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ id: root
+ width: 640
+ height: 480
+ color: "#444"
+
+ Component {
+ id: buttonsAndStuff
+ Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ Rectangle {
+ objectName: "buttonWithMA"
+ width: parent.width
+ height: 30
+ color: buttonMA.pressed ? "lightsteelblue" : "#999"
+ border.color: buttonMA.containsMouse ? "cyan" : "transparent"
+
+ MouseArea {
+ id: buttonMA
+ objectName: "buttonMA"
+ hoverEnabled: true
+ anchors.fill: parent
+ onClicked: console.log("clicked MA")
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
+
+ Rectangle {
+ objectName: "buttonWithHH"
+ width: parent.width
+ height: 30
+ color: flash ? "#999" : "white"
+ border.color: buttonHH.hovered ? "cyan" : "transparent"
+ property bool flash: true
+
+ HoverHandler {
+ id: buttonHH
+ objectName: "buttonHH"
+ acceptedDevices: PointerDevice.AllDevices
+ }
+
+ TapHandler { }
+
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: paddle
+ objectName: "paddle"
+ width: 100
+ height: 40
+ color: paddleHH.hovered ? "indianred" : "#888"
+ x: (parent.width - width) / 2
+ y: parent.height - 100
+ radius: 10
+
+ HoverHandler {
+ id: paddleHH
+ objectName: "paddleHH"
+ }
+ }
+
+ Rectangle {
+ objectName: "topSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ y: -radius
+ width: 120
+ height: 200
+ border.color: topSidebarHH.hovered ? "cyan" : "black"
+ color: "#777"
+
+ Rectangle {
+ color: "cyan"
+ width: 10
+ height: width
+ radius: width / 2
+ visible: topSidebarHH.hovered
+ x: topSidebarHH.point.position.x - width / 2
+ y: topSidebarHH.point.position.y - height / 2
+ z: 100
+ }
+
+ HoverHandler {
+ id: topSidebarHH
+ objectName: "topSidebarHH"
+ }
+
+ Loader {
+ objectName: "topSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+
+ Rectangle {
+ objectName: "bottomSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: -radius
+ width: 120
+ height: 200
+ border.color: bottomSidebarMA.containsMouse ? "cyan" : "black"
+ color: "#777"
+
+ MouseArea {
+ id: bottomSidebarMA
+ objectName: "bottomSidebarMA"
+ hoverEnabled: true
+ anchors.fill: parent
+ }
+
+ Loader {
+ objectName: "bottomSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/qquickhoverhandler.pro b/tests/auto/quick/pointerhandlers/qquickhoverhandler/qquickhoverhandler.pro
new file mode 100644
index 0000000000..34633e2532
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/qquickhoverhandler.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+
+TARGET = tst_qquickhoverhandler
+QT += core-private gui-private qml-private quick-private testlib
+
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qquickhoverhandler.cpp
+
+include (../../../shared/util.pri)
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+OTHER_FILES += data/lesHoverables.qml \
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
new file mode 100644
index 0000000000..52074aec4f
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -0,0 +1,234 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickhoverhandler_p.h>
+#include <QtQuick/private/qquickmousearea_p.h>
+#include <qpa/qwindowsysteminterface.h>
+
+#include <private/qquickwindow_p.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlproperty.h>
+
+#include "../../../shared/util.h"
+#include "../../shared/viewtestutil.h"
+
+Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests")
+
+static bool isPlatformWayland()
+{
+ return !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive);
+}
+
+class tst_HoverHandler : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_HoverHandler()
+ {}
+
+private slots:
+ void hoverHandlerAndUnderlyingHoverHandler();
+ void mouseAreaAndUnderlyingHoverHandler();
+ void hoverHandlerAndUnderlyingMouseArea();
+
+private:
+ void createView(QScopedPointer<QQuickView> &window, const char *fileName);
+};
+
+void tst_HoverHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName)
+{
+ window.reset(new QQuickView);
+ window->setSource(testFileUrl(fileName));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != nullptr);
+}
+
+void tst_HoverHandler::hoverHandlerAndUnderlyingHoverHandler()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "lesHoverables.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * topSidebar = window->rootObject()->findChild<QQuickItem *>("topSidebar");
+ QVERIFY(topSidebar);
+ QQuickItem * button = topSidebar->findChild<QQuickItem *>("buttonWithHH");
+ QVERIFY(button);
+ QQuickHoverHandler *topSidebarHH = topSidebar->findChild<QQuickHoverHandler *>("topSidebarHH");
+ QVERIFY(topSidebarHH);
+ QQuickHoverHandler *buttonHH = button->findChild<QQuickHoverHandler *>("buttonHH");
+ QVERIFY(buttonHH);
+
+ QPoint buttonCenter(button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QPoint rightOfButton(button->mapToScene(QPointF(button->width() + 2, button->height() / 2)).toPoint());
+ QPoint outOfSidebar(topSidebar->mapToScene(QPointF(topSidebar->width() + 2, topSidebar->height() / 2)).toPoint());
+ QSignalSpy sidebarHoveredSpy(topSidebarHH, SIGNAL(hoveredChanged()));
+ QSignalSpy buttonHoveredSpy(buttonHH, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(topSidebarHH->isHovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, buttonCenter);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonHH->isHovered(), true);
+ QCOMPARE(buttonHoveredSpy.count(), 1);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(topSidebarHH->isHovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 2);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+}
+
+void tst_HoverHandler::mouseAreaAndUnderlyingHoverHandler()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "lesHoverables.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * topSidebar = window->rootObject()->findChild<QQuickItem *>("topSidebar");
+ QVERIFY(topSidebar);
+ QQuickMouseArea * buttonMA = topSidebar->findChild<QQuickMouseArea *>("buttonMA");
+ QVERIFY(buttonMA);
+ QQuickHoverHandler *topSidebarHH = topSidebar->findChild<QQuickHoverHandler *>("topSidebarHH");
+ QVERIFY(topSidebarHH);
+
+ QPoint buttonCenter(buttonMA->mapToScene(QPointF(buttonMA->width() / 2, buttonMA->height() / 2)).toPoint());
+ QPoint rightOfButton(buttonMA->mapToScene(QPointF(buttonMA->width() + 2, buttonMA->height() / 2)).toPoint());
+ QPoint outOfSidebar(topSidebar->mapToScene(QPointF(topSidebar->width() + 2, topSidebar->height() / 2)).toPoint());
+ QSignalSpy sidebarHoveredSpy(topSidebarHH, SIGNAL(hoveredChanged()));
+ QSignalSpy buttonHoveredSpy(buttonMA, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(topSidebarHH->isHovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(buttonMA->hovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonMA->hovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, buttonCenter);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonMA->hovered(), true);
+ QCOMPARE(buttonHoveredSpy.count(), 1);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(topSidebarHH->isHovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonMA->hovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(topSidebarHH->isHovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 2);
+ QCOMPARE(buttonMA->hovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+}
+
+void tst_HoverHandler::hoverHandlerAndUnderlyingMouseArea()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "lesHoverables.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem * bottomSidebar = window->rootObject()->findChild<QQuickItem *>("bottomSidebar");
+ QVERIFY(bottomSidebar);
+ QQuickMouseArea *bottomSidebarMA = bottomSidebar->findChild<QQuickMouseArea *>("bottomSidebarMA");
+ QVERIFY(bottomSidebarMA);
+ QQuickItem * button = bottomSidebar->findChild<QQuickItem *>("buttonWithHH");
+ QVERIFY(button);
+ QQuickHoverHandler *buttonHH = button->findChild<QQuickHoverHandler *>("buttonHH");
+ QVERIFY(buttonHH);
+
+ QPoint buttonCenter(button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QPoint rightOfButton(button->mapToScene(QPointF(button->width() + 2, button->height() / 2)).toPoint());
+ QPoint outOfSidebar(bottomSidebar->mapToScene(QPointF(bottomSidebar->width() + 2, bottomSidebar->height() / 2)).toPoint());
+ QSignalSpy sidebarHoveredSpy(bottomSidebarMA, SIGNAL(hoveredChanged()));
+ QSignalSpy buttonHoveredSpy(buttonHH, SIGNAL(hoveredChanged()));
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(bottomSidebarMA->hovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 0);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(bottomSidebarMA->hovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 1);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 0);
+
+ QTest::mouseMove(window, buttonCenter);
+ QCOMPARE(bottomSidebarMA->hovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 2);
+ QCOMPARE(buttonHH->isHovered(), true);
+ QCOMPARE(buttonHoveredSpy.count(), 1);
+
+ QTest::mouseMove(window, rightOfButton);
+ QCOMPARE(bottomSidebarMA->hovered(), true);
+ QCOMPARE(sidebarHoveredSpy.count(), 3);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+
+ QTest::mouseMove(window, outOfSidebar);
+ QCOMPARE(bottomSidebarMA->hovered(), false);
+ QCOMPARE(sidebarHoveredSpy.count(), 4);
+ QCOMPARE(buttonHH->isHovered(), false);
+ QCOMPARE(buttonHoveredSpy.count(), 2);
+}
+
+QTEST_MAIN(tst_HoverHandler)
+
+#include "tst_qquickhoverhandler.moc"
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml
new file mode 100644
index 0000000000..15775df1e7
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/pinchproperties.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ id: whiteRect
+ property real scale: -1.0
+ property int activeCount : 0
+ property int deactiveCount : 0
+ width: 240; height: 320
+ color: "white"
+ Rectangle {
+ id: blackRect
+ objectName: "blackrect"
+ color: "black"
+ y: 50
+ x: 50
+ width: 100
+ height: 100
+ opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
+ Text { color: "white"; text: "opacity: " + blackRect.opacity + "\nscale: " + blackRect.scale}
+ PinchHandler {
+ id: pincharea
+ objectName: "pinchHandler"
+ minimumScale: 1.0
+ maximumScale: 4.0
+ minimumRotation: 0.0
+ maximumRotation: 90.0
+ xAxis.maximum: 140
+ yAxis.maximum: 170
+ onActiveChanged: {
+ whiteRect.scale = pincharea.scale
+ if (active) ++activeCount
+ else ++deactiveCount;
+ }
+
+ onUpdated: {
+ whiteRect.scale = pincharea.scale
+ //whiteRect.pointCount = pincharea.pointCount
+ }
+ }
+ }
+ }
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/threeFingers.qml b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/threeFingers.qml
new file mode 100644
index 0000000000..4d1a520c01
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/threeFingers.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ id: root
+ property variant centroid : pinchHandler.centroid
+ property real scale: pinchHandler.scale
+ property int pointCount: 0
+ property bool pinchActive: pinchHandler.active
+ width: 240; height: 320
+
+ Rectangle {
+ id: blackRect
+ objectName: "blackrect"
+ color: "black"
+ y: 50
+ x: 50
+ width: 200
+ height: 200
+
+ PinchHandler {
+ id: pinchHandler
+ objectName: "pinchHandler"
+ minimumScale: 0.5
+ maximumScale: 2.0
+ minimumRotation: 0.0
+ maximumRotation: 0.0
+ minimumPointCount: 3
+ maximumPointCount: 3
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/transformedPinchHandler.qml b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/transformedPinchHandler.qml
new file mode 100644
index 0000000000..46e9ccca87
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/data/transformedPinchHandler.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ x: 100
+ y: 100
+ width: 200
+ height: 200
+ rotation: 45
+
+ Rectangle {
+ id: rect
+ scale: 0.5
+ color: "black"
+ anchors.fill: parent
+
+ PinchHandler {
+ objectName: "pinchHandler"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/qquickpinchhandler.pro b/tests/auto/quick/pointerhandlers/qquickpinchhandler/qquickpinchhandler.pro
new file mode 100644
index 0000000000..7e177d9786
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/qquickpinchhandler.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquickpinchhandler
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpinchhandler.cpp
+OTHER_FILES = \
+ data/pinchproperties.qml \
+ data/threeFingers.qml \
+ data/transformedPinchArea.qml
+
+include (../../../shared/util.pri)
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
new file mode 100644
index 0000000000..818863bf86
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
@@ -0,0 +1,692 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtGui/QStyleHints>
+#include <qpa/qwindowsysteminterface.h>
+#include <private/qquickpinchhandler_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include "../../../shared/util.h"
+#include "../../shared/viewtestutil.h"
+
+class tst_QQuickPinchHandler: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickPinchHandler() : device(0) { }
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void pinchProperties();
+ void scale();
+ void scaleThreeFingers();
+ void pan();
+ void retouch();
+ void cancel();
+ void transformedpinchHandler_data();
+ void transformedpinchHandler();
+
+private:
+ QQuickView *createView();
+ QTouchDevice *device;
+};
+void tst_QQuickPinchHandler::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+}
+
+void tst_QQuickPinchHandler::cleanupTestCase()
+{
+
+}
+
+static bool withinBounds(qreal lower, qreal num, qreal upper)
+{
+ return num >= lower && num <= upper;
+}
+
+void tst_QQuickPinchHandler::pinchProperties()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(window->rootObject() != nullptr);
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+ QCOMPARE(blackRect, pinchHandler->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(rootItem != nullptr);
+ QSignalSpy targetSpy(pinchHandler, SIGNAL(targetChanged()));
+ pinchHandler->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ pinchHandler->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ /*
+ QCOMPARE(pinchHandler->axis(), QQuickPinch::XAndYAxis);
+ QSignalSpy axisSpy(pinchHandler, SIGNAL(dragAxisChanged()));
+ pinchHandler->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(pinchHandler->axis(), QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ pinchHandler->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum drag properties
+ QSignalSpy xminSpy(pinchHandler, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(pinchHandler, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(pinchHandler, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(pinchHandler, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(pinchHandler->xmin(), 0.0);
+ QCOMPARE(pinchHandler->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(pinchHandler->ymin(), 0.0);
+ QCOMPARE(pinchHandler->ymax(), rootItem->height()-blackRect->height());
+
+ pinchHandler->setXmin(10);
+ pinchHandler->setXmax(10);
+ pinchHandler->setYmin(10);
+ pinchHandler->setYmax(10);
+
+ QCOMPARE(pinchHandler->xmin(), 10.0);
+ QCOMPARE(pinchHandler->xmax(), 10.0);
+ QCOMPARE(pinchHandler->ymin(), 10.0);
+ QCOMPARE(pinchHandler->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ pinchHandler->setXmin(10);
+ pinchHandler->setXmax(10);
+ pinchHandler->setYmin(10);
+ pinchHandler->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+ */
+
+ // minimum and maximum scale properties
+ QSignalSpy scaleMinSpy(pinchHandler, SIGNAL(minimumScaleChanged()));
+ QSignalSpy scaleMaxSpy(pinchHandler, SIGNAL(maximumScaleChanged()));
+
+ QCOMPARE(pinchHandler->minimumScale(), 1.0);
+ QCOMPARE(pinchHandler->maximumScale(), 4.0);
+
+ pinchHandler->setMinimumScale(0.5);
+ pinchHandler->setMaximumScale(1.5);
+
+ QCOMPARE(pinchHandler->minimumScale(), 0.5);
+ QCOMPARE(pinchHandler->maximumScale(), 1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ pinchHandler->setMinimumScale(0.5);
+ pinchHandler->setMaximumScale(1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ // minimum and maximum rotation properties
+ QSignalSpy rotMinSpy(pinchHandler, SIGNAL(minimumRotationChanged()));
+ QSignalSpy rotMaxSpy(pinchHandler, SIGNAL(maximumRotationChanged()));
+
+ QCOMPARE(pinchHandler->minimumRotation(), 0.0);
+ QCOMPARE(pinchHandler->maximumRotation(), 90.0);
+
+ pinchHandler->setMinimumRotation(-90.0);
+ pinchHandler->setMaximumRotation(45.0);
+
+ QCOMPARE(pinchHandler->minimumRotation(), -90.0);
+ QCOMPARE(pinchHandler->maximumRotation(), 45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+
+ pinchHandler->setMinimumRotation(-90.0);
+ pinchHandler->setMaximumRotation(45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+}
+
+QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
+{
+ QTouchEvent::TouchPoint touchPoint(id);
+ touchPoint.setPos(i->mapFromScene(p));
+ touchPoint.setScreenPos(v->mapToGlobal(p));
+ touchPoint.setScenePos(p);
+ return touchPoint;
+}
+
+void tst_QQuickPinchHandler::scale()
+{
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+
+ QPoint p0(80, 80);
+ QPoint p1(100, 100);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p0, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object. Otherwise if we let it
+ // be destroyed and then start a new sequence, point 0 will default to being
+ // stationary at 0, 0, and pinchHandler will filter out that touchpoint because
+ // it is outside its bounds.
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QPoint pd(10, 10);
+ // move one point until PinchHandler activates
+ for (int pi = 0; pi < 10 && !pinchHandler->active(); ++pi) {
+ p1 += pd;
+ pinchSequence.stationary(0).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ }
+ QCOMPARE(pinchHandler->active(), true);
+ QLineF line(p0, p1);
+ const qreal startLength = line.length();
+
+ p1+=pd;
+ pinchSequence.stationary(0).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ line.setP2(p1);
+ qreal scale = line.length() / startLength;
+ QVERIFY(qFloatDistance(root->property("scale").toReal(), scale) < 10);
+ QVERIFY(qFloatDistance(blackRect->scale(), scale) < 10);
+
+ p1+=pd;
+ pinchSequence.stationary(0).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ line.setP2(p1);
+ scale = line.length() / startLength;
+
+ QVERIFY(qFloatDistance(root->property("scale").toReal(), scale) < 10);
+ QVERIFY(qFloatDistance(blackRect->scale(), scale) < 10);
+
+ QPointF expectedCentroid = p0 + (p1 - p0)/2;
+ QCOMPARE(pinchHandler->centroid().scenePosition(), expectedCentroid);
+ }
+
+ // scale beyond bound
+ p1 += QPoint(20, 20);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.stationary(0).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(blackRect->scale(), qreal(4)); // qquickpinchhandler does not manipulate scale property
+ pinchSequence.release(0, p0, window).release(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ }
+ QCOMPARE(pinchHandler->active(), false);
+}
+
+void tst_QQuickPinchHandler::scaleThreeFingers()
+{
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("threeFingers.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+
+ // center of blackrect is at 150,150
+ QPoint p0(80, 80);
+ QPoint p1(220, 80);
+ QPoint p2(150, 220);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p0, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object. Otherwise if we let it
+ // be destroyed and then start a new sequence, point 0 will default to being
+ // stationary at 0, 0, and pinchHandler will filter out that touchpoint because
+ // it is outside its bounds.
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ pinchSequence.stationary(0).stationary(1).press(2, p2, window).commit();
+ QQuickTouchUtils::flush(window);
+ for (int i = 0; i < 5;++i) {
+ p0 += QPoint(-4, -4);
+ p1 += QPoint(+4, -4);
+ p2 += QPoint( 0, +6);
+ pinchSequence.move(0, p0,window).move(1, p1,window).move(2, p2,window).commit();
+ QQuickTouchUtils::flush(window);
+ }
+
+ QCOMPARE(pinchHandler->active(), true);
+ // scale we got was 1.1729088738267854364, but keep some slack
+ QVERIFY(withinBounds(1.163, root->property("scale").toReal(), 1.183));
+ // should not rotate
+ QCOMPARE(root->property("rotation").toReal(), 0.);
+
+ for (int i = 0; i < 5;++i) {
+ p0 += QPoint(-4, -4);
+ p1 += QPoint(+4, -4);
+ p2 += QPoint( 0, +6);
+ pinchSequence.move(0, p0,window).move(1, p1,window).move(2, p2,window).commit();
+ QQuickTouchUtils::flush(window);
+ }
+ // scale we got was 1.4613, but keep some slack
+ QVERIFY(withinBounds(1.361, root->property("scale").toReal(), 1.561));
+
+ // since points were moved symetrically around the y axis, centroid should remain at x:150
+ QCOMPARE(root->property("centroid").value<QQuickHandlerPoint>().scenePosition().x(), 150); // blackrect is at 50,50
+
+ // scale beyond bound, we should reach the maximumScale
+ p0 += QPoint(-40, -40);
+ p1 += QPoint(+40, -40);
+ p2 += QPoint( 0, +60);
+ pinchSequence.move(0, p0,window).move(1, p1,window).move(2, p2,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 2.);
+ pinchSequence.release(0, p0, window).release(1, p1, window).release(2, p2, window).commit();
+ QQuickTouchUtils::flush(window);
+ }
+ QCOMPARE(pinchHandler->active(), false);
+}
+
+void tst_QQuickPinchHandler::pan()
+{
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+
+ QPoint p0(80, 80);
+ QPoint p1(100, 100);
+ {
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p0, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object.
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ QVERIFY(!root->property("pinchActive").toBool());
+ QCOMPARE(root->property("scale").toReal(), -1.0);
+
+ p0 += QPoint(dragThreshold, 0);
+ p1 += QPoint(dragThreshold, 0);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ // movement < dragThreshold: pinchHandler not yet active
+ QVERIFY(!root->property("pinchActive").toBool());
+ QCOMPARE(root->property("scale").toReal(), -1.0);
+
+ // just above the dragThreshold: pinchHandler starts
+ p0 += QPoint(1, 0);
+ p1 += QPoint(1, 0);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(pinchHandler->active(), true);
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ // Calculation of the center point is tricky at first:
+ // center point of the two touch points in item coordinates:
+ // scene coordinates: (80, 80) + (dragThreshold, 0), (100, 100) + (dragThreshold, 0)
+ // = ((180+dT)/2, 180/2) = (90+dT, 90)
+ // item coordinates: (scene) - (50, 50) = (40+dT, 40)
+ QCOMPARE(pinchHandler->centroid().scenePosition(), QPointF(90 + dragThreshold + 1, 90));
+ // pan started, but no actual movement registered yet:
+ // blackrect starts at 50,50
+ QCOMPARE(blackRect->x(), 50.0);
+ QCOMPARE(blackRect->y(), 50.0);
+
+ p0 += QPoint(10, 0);
+ p1 += QPoint(10, 0);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(pinchHandler->centroid().scenePosition(), QPointF(90 + dragThreshold + 11, 90));
+ QCOMPARE(blackRect->x(), 60.0);
+ QCOMPARE(blackRect->y(), 50.0);
+
+ p0 += QPoint(0, 10);
+ p1 += QPoint(0, 10);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(pinchHandler->centroid().scenePosition(), QPointF(90 + dragThreshold + 11, 90 + 10));
+ QCOMPARE(blackRect->x(), 60.0);
+ QCOMPARE(blackRect->y(), 60.0);
+
+ p0 += QPoint(10, 10);
+ p1 += QPoint(10, 10);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ // now the item moved again, thus the center point of the touch is moved in total by (10, 10)
+ QCOMPARE(pinchHandler->centroid().scenePosition(), QPointF(90 + dragThreshold + 21, 90 + 20));
+ QCOMPARE(blackRect->x(), 70.0);
+ QCOMPARE(blackRect->y(), 70.0);
+ }
+
+ // pan x beyond bound
+ p0 += QPoint(100,100);
+ p1 += QPoint(100,100);
+ QTest::touchEvent(window, device).move(0, p0, window).move(1, p1, window);
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(blackRect->x(), 140.0);
+ QCOMPARE(blackRect->y(), 170.0);
+
+ QTest::touchEvent(window, device).release(0, p0, window).release(1, p1, window);
+ QQuickTouchUtils::flush(window);
+ QVERIFY(!root->property("pinchActive").toBool());
+}
+
+// test pinchHandler, release one point, touch again to continue pinchHandler
+void tst_QQuickPinchHandler::retouch()
+{
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+
+ QPoint p0(80, 80);
+ QPoint p1(100, 100);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p0, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object.
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ const QPoint delta(dragThreshold + 1, dragThreshold + 1);
+ p0 -= delta;
+ p1 += delta;
+ pinchSequence.move(0, p0,window).move(1, p1,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(pinchHandler->active(), true);
+
+ p0 -= delta;
+ p1 += delta;
+ pinchSequence.move(0, p0,window).move(1, p1,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(pinchHandler->active(), true);
+
+ // accept some slack
+ QVERIFY(withinBounds(1.4, root->property("scale").toReal(), 1.6));
+ QCOMPARE(pinchHandler->centroid().position(), QPointF(40, 40)); // blackrect is at 50,50
+ QVERIFY(withinBounds(1.4, blackRect->scale(), 1.6));
+
+ QCOMPARE(root->property("activeCount").toInt(), 1);
+ QCOMPARE(root->property("deactiveCount").toInt(), 0);
+
+ // Hold down the first finger but release the second one
+ pinchSequence.stationary(0).release(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("activeCount").toInt(), 1);
+ QCOMPARE(root->property("deactiveCount").toInt(), 1);
+
+ // Keep holding down the first finger and re-touch the second one, then move them both
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ p0 -= QPoint(10,10);
+ p1 += QPoint(10,10);
+ pinchSequence.move(0, p0, window).move(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+
+ // Lifting and retouching results in onPinchStarted being called again
+ QCOMPARE(root->property("activeCount").toInt(), 2);
+ QCOMPARE(root->property("deactiveCount").toInt(), 1);
+
+ pinchSequence.release(0, p0, window).release(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(pinchHandler->active(), false);
+ QCOMPARE(root->property("activeCount").toInt(), 2);
+ QCOMPARE(root->property("deactiveCount").toInt(), 2);
+ }
+}
+
+void tst_QQuickPinchHandler::cancel()
+{
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+ QQuickView *window = createView();
+ QScopedPointer<QQuickView> scope(window);
+ window->setSource(testFileUrl("pinchproperties.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QVERIFY(window->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = window->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(window->rootObject());
+ QVERIFY(root != nullptr);
+
+ // target
+ QQuickItem *blackRect = window->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != nullptr);
+
+ QPoint p0(80, 80);
+ QPoint p1(100, 100);
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(window, device);
+ pinchSequence.press(0, p0, window).commit();
+ QQuickTouchUtils::flush(window);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object. Otherwise if we let it
+ // be destroyed and then start a new sequence, point 0 will default to being
+ // stationary at 0, 0, and pinchHandler will filter out that touchpoint because
+ // it is outside its bounds.
+ pinchSequence.stationary(0).press(1, p1, window).commit();
+ QQuickTouchUtils::flush(window);
+ const QPoint delta(dragThreshold + 1, dragThreshold + 1);
+ p0 -= delta;
+ p1 += delta;
+ pinchSequence.move(0, p0,window).move(1, p1,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(pinchHandler->active(), true);
+
+ p0 -= delta;
+ p1 += delta;
+ pinchSequence.move(0, p0,window).move(1, p1,window).commit();
+ QQuickTouchUtils::flush(window);
+
+ QVERIFY(withinBounds(1.4, root->property("scale").toReal(), 1.6));
+ QCOMPARE(pinchHandler->centroid().position(), QPointF(40, 40)); // blackrect is at 50,50
+ QVERIFY(withinBounds(1.4, blackRect->scale(), 1.6));
+
+ QSKIP("cancel is not supported atm");
+
+ QTouchEvent cancelEvent(QEvent::TouchCancel);
+ cancelEvent.setDevice(device);
+ QCoreApplication::sendEvent(window, &cancelEvent);
+ QQuickTouchUtils::flush(window);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.0);
+ QVERIFY(!root->property("pinchActive").toBool());
+ }
+}
+
+void tst_QQuickPinchHandler::transformedpinchHandler_data()
+{
+ QTest::addColumn<QPoint>("p0");
+ QTest::addColumn<QPoint>("p1");
+ QTest::addColumn<bool>("shouldPinch");
+
+ QTest::newRow("checking inner pinchHandler 1")
+ << QPoint(200, 140) << QPoint(200, 260) << true;
+
+ QTest::newRow("checking inner pinchHandler 2")
+ << QPoint(140, 200) << QPoint(200, 140) << true;
+
+ QTest::newRow("checking inner pinchHandler 3")
+ << QPoint(140, 200) << QPoint(260, 200) << true;
+
+ QTest::newRow("checking outer pinchHandler 1")
+ << QPoint(140, 140) << QPoint(260, 260) << false;
+
+ QTest::newRow("checking outer pinchHandler 2")
+ << QPoint(140, 140) << QPoint(200, 200) << false;
+
+ QTest::newRow("checking outer pinchHandler 3")
+ << QPoint(140, 260) << QPoint(260, 260) << false;
+}
+
+void tst_QQuickPinchHandler::transformedpinchHandler()
+{
+ QFETCH(QPoint, p0);
+ QFETCH(QPoint, p1);
+ QFETCH(bool, shouldPinch);
+
+ QQuickView *view = createView();
+ QScopedPointer<QQuickView> scope(view);
+ view->setSource(testFileUrl("transformedPinchHandler.qml"));
+ view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view));
+ QVERIFY(view->rootObject() != nullptr);
+ qApp->processEvents();
+
+ QQuickPinchHandler *pinchHandler = view->rootObject()->findChild<QQuickPinchHandler*>("pinchHandler");
+ QVERIFY(pinchHandler != nullptr);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ {
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(view, device);
+ // start pinchHandler
+ pinchSequence.press(0, p0, view).commit();
+ QQuickTouchUtils::flush(view);
+ // In order for the stationary point to remember its previous position,
+ // we have to reuse the same pinchSequence object.
+ pinchSequence.stationary(0).press(1, p1, view).commit();
+ QQuickTouchUtils::flush(view);
+
+ // we move along the line that the two points form.
+ // The distance we move should be above the threshold (threshold * 2 to be safe)
+ QVector2D delta(p1 - p0);
+ delta.normalize();
+ QVector2D movement = delta * (threshold * 2);
+ pinchSequence.stationary(0).move(1, p1 + movement.toPoint(), view).commit();
+ QQuickTouchUtils::flush(view);
+ QCOMPARE(pinchHandler->active(), shouldPinch);
+
+ // release pinchHandler
+ pinchSequence.release(0, p0, view).release(1, p1, view).commit();
+ QQuickTouchUtils::flush(view);
+ QCOMPARE(pinchHandler->active(), false);
+ }
+}
+
+QQuickView *tst_QQuickPinchHandler::createView()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setGeometry(0,0,240,320);
+
+ return window;
+}
+
+QTEST_MAIN(tst_QQuickPinchHandler)
+
+#include "tst_qquickpinchhandler.moc"
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
index 0158d864c4..e8b076052a 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
@@ -51,14 +51,14 @@ public:
};
Q_ENUM(Destination)
- Event(Destination d, QEvent::Type t, Qt::TouchPointState s, int grabState, QPointF item, QPointF scene)
- : destination(d), type(t), state(s), grabState(grabState), posWrtItem(item), posWrtScene(scene)
+ Event(Destination d, QEvent::Type t, Qt::TouchPointState s, int grabTransition, QPointF item, QPointF scene)
+ : destination(d), type(t), state(s), grabTransition(grabTransition), posWrtItem(item), posWrtScene(scene)
{}
Destination destination;
QEvent::Type type; // if this represents a QEvent that was received
Qt::TouchPointState state; // if this represents an event (pointer, touch or mouse)
- int grabState; // if this represents an onGrabChanged() notification (QQuickEventPoint::GrabState)
+ int grabTransition; // if this represents an onGrabChanged() notification (QQuickEventPoint::GrabTransition)
QPointF posWrtItem;
QPointF posWrtScene;
};
@@ -73,9 +73,9 @@ QDebug operator<<(QDebug dbg, const class Event &event) {
QtDebugUtils::formatQEnum(dbg, event.type);
dbg << ' ';
QtDebugUtils::formatQEnum(dbg, event.state);
- if (event.grabState) {
+ if (event.grabTransition) {
dbg << ' ';
- QtDebugUtils::formatQEnum(dbg, QQuickEventPoint::GrabState(event.grabState));
+ QtDebugUtils::formatQEnum(dbg, QQuickEventPoint::GrabTransition(event.grabTransition));
}
dbg << " @ ";
QtDebugUtils::formatQPoint(dbg, event.posWrtItem);
@@ -98,7 +98,7 @@ public:
: QQuickItem(parent), acceptPointer(false), grabPointer(false), acceptMouse(false), acceptTouch(false), filterTouch(false)
{}
- inline int grabState(bool accept, Qt::TouchPointState state) {
+ inline int grabTransition(bool accept, Qt::TouchPointState state) {
return (accept && (state != Qt::TouchPointReleased)) ? (int)QQuickEventPoint::GrabExclusive : (int)NoGrab;
}
@@ -106,31 +106,31 @@ public:
{
qCDebug(lcPointerTests) << event << "will accept?" << acceptTouch;
for (const QTouchEvent::TouchPoint &tp : event->touchPoints())
- eventList.append(Event(Event::TouchDestination, event->type(), tp.state(), grabState(acceptTouch, tp.state()), tp.pos(), tp.scenePos()));
+ eventList.append(Event(Event::TouchDestination, event->type(), tp.state(), grabTransition(acceptTouch, tp.state()), tp.pos(), tp.scenePos()));
event->setAccepted(acceptTouch);
}
void mousePressEvent(QMouseEvent *event)
{
qCDebug(lcPointerTests) << event;
- eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabState(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos()));
+ eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabTransition(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos()));
event->setAccepted(acceptMouse);
}
void mouseMoveEvent(QMouseEvent *event)
{
qCDebug(lcPointerTests) << event;
- eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointMoved, grabState(acceptMouse, Qt::TouchPointMoved), event->pos(), event->windowPos()));
+ eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointMoved, grabTransition(acceptMouse, Qt::TouchPointMoved), event->pos(), event->windowPos()));
event->setAccepted(acceptMouse);
}
void mouseReleaseEvent(QMouseEvent *event)
{
qCDebug(lcPointerTests) << event;
- eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointReleased, grabState(acceptMouse, Qt::TouchPointReleased), event->pos(), event->windowPos()));
+ eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointReleased, grabTransition(acceptMouse, Qt::TouchPointReleased), event->pos(), event->windowPos()));
event->setAccepted(acceptMouse);
}
void mouseDoubleClickEvent(QMouseEvent *event)
{
qCDebug(lcPointerTests) << event;
- eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabState(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos()));
+ eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabTransition(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos()));
event->setAccepted(acceptMouse);
}
@@ -177,7 +177,7 @@ public:
QCOMPARE(event.destination, d);\
QCOMPARE(event.type, t);\
QCOMPARE(event.state, s);\
- QCOMPARE(event.grabState, g);\
+ QCOMPARE(event.grabTransition, g);\
}\
class EventHandler : public QQuickPointerHandler
@@ -204,7 +204,7 @@ class EventHandler : public QQuickPointerHandler
}
}
- void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override
+ void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabTransition stateChange, QQuickEventPoint *point) override
{
EventItem *item = static_cast<EventItem *>(target());
item->eventList.append(Event(Event::HandlerDestination, QEvent::None,
@@ -223,6 +223,7 @@ public:
private slots:
void initTestCase();
+ void touchEventDelivery_data();
void touchEventDelivery();
void mouseEventDelivery();
void touchReleaseOutside_data();
@@ -274,16 +275,23 @@ void tst_PointerHandlers::createView(QScopedPointer<QQuickView> &window, const c
void tst_PointerHandlers::initTestCase()
{
- // This test assumes that we don't get synthesized mouse events from QGuiApplication
- qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
-
QQmlDataTest::initTestCase();
qmlRegisterType<EventItem>("Qt.test", 1, 0, "EventItem");
qmlRegisterType<EventHandler>("Qt.test", 1, 0, "EventHandler");
}
+void tst_PointerHandlers::touchEventDelivery_data()
+{
+ QTest::addColumn<bool>("synthMouse"); // AA_SynthesizeMouseForUnhandledTouchEvents
+ QTest::newRow("no synth") << false;
+ QTest::newRow("synth") << true;
+}
+
void tst_PointerHandlers::touchEventDelivery()
{
+ QFETCH(bool, synthMouse);
+ qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, synthMouse);
+
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "singleitem.qml");
QQuickView * window = windowPtr.data();
@@ -295,19 +303,20 @@ void tst_PointerHandlers::touchEventDelivery()
QPoint p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(eventItem1->eventList.size(), 3);
+ QTRY_COMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 3);
+ QCOMPARE_EVENT(eventItem1->eventList.size() - 1, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 5);
- QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 5 : 4);
+ QCOMPARE_EVENT(eventItem1->eventList.size() - 1, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
eventItem1->eventList.clear();
// Accept touch
@@ -343,33 +352,42 @@ void tst_PointerHandlers::touchEventDelivery()
p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 3);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive);
- QCOMPARE(window->mouseGrabberItem(), eventItem1);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE(window->mouseGrabberItem(), synthMouse ? eventItem1 : nullptr);
QPointF localPos = eventItem1->mapFromScene(p1);
QPointF scenePos = p1; // item is at 0,0
QCOMPARE(eventItem1->eventList.at(1).posWrtItem, localPos);
QCOMPARE(eventItem1->eventList.at(1).posWrtScene, scenePos);
- QCOMPARE(eventItem1->eventList.at(2).posWrtItem, localPos);
- QCOMPARE(eventItem1->eventList.at(2).posWrtScene, scenePos);
+ if (synthMouse) {
+ QCOMPARE(eventItem1->eventList.at(2).posWrtItem, localPos);
+ QCOMPARE(eventItem1->eventList.at(2).posWrtScene, scenePos);
+ }
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 6);
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
- QCOMPARE_EVENT(4, Event::TouchDestination, QEvent::TouchUpdate, Qt::TouchPointMoved, NoGrab);
- QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, Qt::TouchPointMoved, QQuickEventPoint::GrabExclusive);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 6 : 3);
+ if (synthMouse) {
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE_EVENT(4, Event::TouchDestination, QEvent::TouchUpdate, Qt::TouchPointMoved, NoGrab);
+ QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, Qt::TouchPointMoved, QQuickEventPoint::GrabExclusive);
+ }
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 10);
- QCOMPARE_EVENT(6, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(7, Event::TouchDestination, QEvent::TouchEnd, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(8, Event::MouseDestination, QEvent::MouseButtonRelease, Qt::TouchPointReleased, NoGrab);
- QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, Qt::TouchPointReleased, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 10 : 4);
+ if (synthMouse) {
+ QCOMPARE_EVENT(6, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(7, Event::TouchDestination, QEvent::TouchEnd, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(8, Event::MouseDestination, QEvent::MouseButtonRelease, Qt::TouchPointReleased, NoGrab);
+ QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, Qt::TouchPointReleased, QQuickEventPoint::UngrabExclusive);
+ } else {
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointReleased, NoGrab);
+ }
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -382,18 +400,19 @@ void tst_PointerHandlers::touchEventDelivery()
p1 = QPoint(20, 20);
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 3);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 3 : 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, NoGrab);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
+ if (synthMouse)
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, Qt::TouchPointPressed, NoGrab);
QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 4);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 3);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
- QCOMPARE(eventItem1->eventList.size(), 5);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 5 : 4);
eventItem1->eventList.clear();
// wait to avoid getting a double click event
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/data/pointTracker.qml b/tests/auto/quick/pointerhandlers/qquickpointhandler/data/pointTracker.qml
new file mode 100644
index 0000000000..674bbda850
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/data/pointTracker.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Item {
+ width: 200
+ height: 200
+ Rectangle {
+ id: rect
+ objectName: "pointTracker"
+ width: 20
+ height: 20
+ radius: 10
+ color: "green"
+ x: handler.point.position.x
+ y: handler.point.position.y
+ }
+
+ Text {
+ id: text
+ anchors.top: rect.bottom
+ anchors.left: rect.right
+ text: "<" + handler.point.position.x + ", " + handler.point.position.y + "> " + handler.point.pressedButtons + " [" + handler.point.pressure + "]"
+ }
+
+ PointHandler {
+ id: handler
+ objectName: "pointHandler"
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/qquickpointhandler.pro b/tests/auto/quick/pointerhandlers/qquickpointhandler/qquickpointhandler.pro
new file mode 100644
index 0000000000..d64fc96d74
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/qquickpointhandler.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+
+TARGET = tst_qquickpointhandler
+QT += core-private gui-private qml-private quick-private testlib
+
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpointhandler.cpp
+
+include (../../../shared/util.pri)
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+OTHER_FILES += data/pointTracker.qml \
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
new file mode 100644
index 0000000000..d91c89d833
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp
@@ -0,0 +1,267 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickpointhandler_p.h>
+#include <qpa/qwindowsysteminterface.h>
+
+#include <private/qquickwindow_p.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlproperty.h>
+
+#include "../../../shared/util.h"
+#include "../../shared/viewtestutil.h"
+
+Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests")
+
+class tst_PointHandler : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_PointHandler()
+ : touchDevice(QTest::createTouchDevice())
+ {}
+
+private slots:
+ void initTestCase();
+
+ void singleTouch();
+ void pressedMultipleButtons_data();
+ void pressedMultipleButtons();
+
+private:
+ void createView(QScopedPointer<QQuickView> &window, const char *fileName);
+ QTouchDevice *touchDevice;
+};
+
+void tst_PointHandler::createView(QScopedPointer<QQuickView> &window, const char *fileName)
+{
+ window.reset(new QQuickView);
+ window->setSource(testFileUrl(fileName));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != nullptr);
+}
+
+void tst_PointHandler::initTestCase()
+{
+ // This test assumes that we don't get synthesized mouse events from QGuiApplication
+ qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
+
+ QQmlDataTest::initTestCase();
+}
+
+void tst_PointHandler::singleTouch()
+{
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "pointTracker.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem *tracker = window->rootObject()->findChild<QQuickItem *>("pointTracker");
+ QVERIFY(tracker);
+ QQuickPointHandler *handler = window->rootObject()->findChild<QQuickPointHandler *>("pointHandler");
+ QVERIFY(handler);
+
+ QSignalSpy activeSpy(handler, SIGNAL(activeChanged()));
+ QSignalSpy pointSpy(handler, SIGNAL(pointChanged()));
+ QSignalSpy translationSpy(handler, SIGNAL(translationChanged()));
+
+ QPoint point(100,100);
+ QTest::touchEvent(window, touchDevice).press(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(pointSpy.count(), 1);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(handler->translation(), QVector2D());
+ QCOMPARE(translationSpy.count(), 1);
+
+ point += QPoint(10, 10);
+ QTest::touchEvent(window, touchDevice).move(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(handler->active(), true);
+ QCOMPARE(activeSpy.count(), 1);
+ QCOMPARE(pointSpy.count(), 2);
+ QCOMPARE(handler->point().position().toPoint(), point);
+ QCOMPARE(handler->point().scenePosition().toPoint(), point);
+ QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().scenePressPosition().toPoint(), QPoint(100, 100));
+ QCOMPARE(handler->point().pressedButtons(), Qt::NoButton);
+ QVERIFY(handler->point().velocity().x() > 0);
+ QVERIFY(handler->point().velocity().y() > 0);
+ QCOMPARE(handler->translation(), QVector2D(10, 10));
+ QCOMPARE(translationSpy.count(), 2);
+
+ QTest::touchEvent(window, touchDevice).release(1, point, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(handler->active(), false);
+ QCOMPARE(activeSpy.count(), 2);
+ QCOMPARE(pointSpy.count(), 3);
+ QCOMPARE(handler->translation(), QVector2D());
+ QCOMPARE(translationSpy.count(), 3);
+}
+
+void tst_PointHandler::pressedMultipleButtons_data()
+{
+ QTest::addColumn<Qt::MouseButtons>("accepted");
+ QTest::addColumn<QList<Qt::MouseButtons> >("buttons");
+ QTest::addColumn<QList<bool> >("active");
+ QTest::addColumn<QList<Qt::MouseButtons> >("pressedButtons");
+ QTest::addColumn<int>("changeCount");
+
+ QList<Qt::MouseButtons> buttons;
+ QList<bool> active;
+ QList<Qt::MouseButtons> pressedButtons;
+ buttons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::LeftButton
+ << Qt::NoButton;
+ active << true
+ << true
+ << true
+ << false;
+ pressedButtons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::LeftButton
+ << Qt::NoButton;
+ QTest::newRow("Accept Left - Press left, Press Right, Release Right")
+ << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 4;
+
+ buttons.clear();
+ active.clear();
+ pressedButtons.clear();
+ buttons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::RightButton
+ << Qt::NoButton;
+ active << true
+ << true
+ << false
+ << false;
+ pressedButtons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::NoButton // Not the "truth" but filtered according to this handler's acceptedButtons
+ << Qt::NoButton;
+ QTest::newRow("Accept Left - Press left, Press Right, Release Left")
+ << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 3;
+
+ buttons.clear();
+ active.clear();
+ pressedButtons.clear();
+ buttons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::LeftButton
+ << Qt::NoButton;
+ active << true
+ << true
+ << true
+ << false;
+ pressedButtons << Qt::LeftButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::LeftButton
+ << Qt::NoButton;
+ QTest::newRow("Accept Left|Right - Press left, Press Right, Release Right")
+ << (Qt::LeftButton | Qt::RightButton) << buttons << active << pressedButtons << 4;
+
+ buttons.clear();
+ active.clear();
+ pressedButtons.clear();
+ buttons << Qt::RightButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::LeftButton
+ << Qt::NoButton;
+ active << true
+ << true
+ << false
+ << false;
+ pressedButtons << Qt::RightButton
+ << (Qt::LeftButton | Qt::RightButton)
+ << Qt::NoButton // Not the "truth" but filtered according to this handler's acceptedButtons
+ << Qt::NoButton;
+ QTest::newRow("Accept Right - Press Right, Press Left, Release Right")
+ << Qt::MouseButtons(Qt::RightButton) << buttons << active << pressedButtons << 3;
+}
+
+void tst_PointHandler::pressedMultipleButtons()
+{
+ QFETCH(Qt::MouseButtons, accepted);
+ QFETCH(QList<Qt::MouseButtons>, buttons);
+ QFETCH(QList<bool>, active);
+ QFETCH(QList<Qt::MouseButtons>, pressedButtons);
+ QFETCH(int, changeCount);
+
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "pointTracker.qml");
+ QQuickView * window = windowPtr.data();
+ QQuickItem *tracker = window->rootObject()->findChild<QQuickItem *>("pointTracker");
+ QVERIFY(tracker);
+ QQuickPointHandler *handler = window->rootObject()->findChild<QQuickPointHandler *>("pointHandler");
+ QVERIFY(handler);
+
+ QSignalSpy activeSpy(handler, SIGNAL(activeChanged()));
+ QSignalSpy pointSpy(handler, SIGNAL(pointChanged()));
+ handler->setAcceptedButtons(accepted);
+
+ QPoint point(100,100);
+
+ for (int i = 0; i < buttons.count(); ++i) {
+ int btns = int(buttons.at(i));
+ int release = 0;
+ if (i > 0) {
+ int lastBtns = int(buttons.at(i - 1));
+ release = lastBtns & ~btns;
+ }
+ if (release)
+ QTest::mouseRelease(windowPtr.data(), Qt::MouseButton(release), Qt::NoModifier, point);
+ else
+ QTest::mousePress(windowPtr.data(), Qt::MouseButton(btns), Qt::NoModifier, point);
+
+ qCDebug(lcPointerTests) << i << ": acceptedButtons" << handler->acceptedButtons()
+ << "; comparing" << handler->point().pressedButtons() << pressedButtons.at(i);
+ QCOMPARE(handler->point().pressedButtons(), pressedButtons.at(i));
+ QCOMPARE(handler->active(), active.at(i));
+ }
+
+ QTest::mousePress(windowPtr.data(), Qt::NoButton, Qt::NoModifier, point);
+ QCOMPARE(handler->active(), false);
+ QCOMPARE(activeSpy.count(), 2);
+ QCOMPARE(pointSpy.count(), changeCount);
+}
+
+QTEST_MAIN(tst_PointHandler)
+
+#include "tst_qquickpointhandler.moc"
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
index 0b7713bd13..ba22e434ce 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml
index 219d4a70a8..4a8b8e1375 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttonOverrideHandler.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.0
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 320
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml
index 1df9bb9b96..821b8073e9 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/buttons.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.0
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 320
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index cf18b5eca1..467c964001 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -526,23 +526,24 @@ void tst_TapHandler::buttonsMultiTouch()
QQuickItem *buttonReleaseWithinBounds = window->rootObject()->findChild<QQuickItem*>("ReleaseWithinBounds");
QVERIFY(buttonReleaseWithinBounds);
QSignalSpy releaseWithinBoundsTappedSpy(buttonReleaseWithinBounds, SIGNAL(tapped()));
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
// can press multiple buttons at the same time
QPoint p1 = buttonDragThreshold->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).press(1, p1, window);
+ touchSeq.press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
QPoint p2 = buttonWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).stationary(1).press(2, p2, window);
+ touchSeq.stationary(1).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonWithinBounds->property("pressed").toBool());
QPoint p3 = buttonReleaseWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
- QTest::touchEvent(window, touchDevice).stationary(1).stationary(2).press(3, p3, window);
+ touchSeq.stationary(1).stationary(2).press(3, p3, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
// can release top button and press again: others stay pressed the whole time
- QTest::touchEvent(window, touchDevice).stationary(2).stationary(3).release(1, p1, window);
+ touchSeq.stationary(2).stationary(3).release(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonDragThreshold->property("pressed").toBool());
QCOMPARE(dragThresholdTappedSpy.count(), 1);
@@ -550,14 +551,14 @@ void tst_TapHandler::buttonsMultiTouch()
QCOMPARE(withinBoundsTappedSpy.count(), 0);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
QCOMPARE(releaseWithinBoundsTappedSpy.count(), 0);
- QTest::touchEvent(window, touchDevice).stationary(2).stationary(3).press(1, p1, window);
+ touchSeq.stationary(2).stationary(3).press(1, p1, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
QVERIFY(buttonWithinBounds->property("pressed").toBool());
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
// can release middle button and press again: others stay pressed the whole time
- QTest::touchEvent(window, touchDevice).stationary(1).stationary(3).release(2, p2, window);
+ touchSeq.stationary(1).stationary(3).release(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!buttonWithinBounds->property("pressed").toBool());
QCOMPARE(withinBoundsTappedSpy.count(), 1);
@@ -565,21 +566,21 @@ void tst_TapHandler::buttonsMultiTouch()
QCOMPARE(dragThresholdTappedSpy.count(), 1);
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
QCOMPARE(releaseWithinBoundsTappedSpy.count(), 0);
- QTest::touchEvent(window, touchDevice).stationary(1).stationary(3).press(2, p2, window);
+ touchSeq.stationary(1).stationary(3).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(buttonDragThreshold->property("pressed").toBool());
QVERIFY(buttonWithinBounds->property("pressed").toBool());
QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
// can release bottom button and press again: others stay pressed the whole time
- QTest::touchEvent(window, touchDevice).stationary(1).stationary(2).release(3, p3, window);
+ touchSeq.stationary(1).stationary(2).release(3, p3, window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(releaseWithinBoundsTappedSpy.count(), 1);
QVERIFY(buttonWithinBounds->property("pressed").toBool());
QCOMPARE(withinBoundsTappedSpy.count(), 1);
QVERIFY(!buttonReleaseWithinBounds->property("pressed").toBool());
QCOMPARE(dragThresholdTappedSpy.count(), 1);
- QTest::touchEvent(window, touchDevice).stationary(1).stationary(2).press(3, p3, window);
+ touchSeq.stationary(1).stationary(2).press(3, p3, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonDragThreshold->property("pressed").toBool());
QVERIFY(buttonWithinBounds->property("pressed").toBool());
@@ -599,8 +600,8 @@ void tst_TapHandler::componentUserBehavioralOverride()
QQuickTapHandler *userTapHandler = button->findChild<QQuickTapHandler*>("override");
QVERIFY(userTapHandler);
QSignalSpy tappedSpy(button, SIGNAL(tapped()));
- QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint *)));
- QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint *)));
+ QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *)));
+ QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *)));
QSignalSpy innerPressedChangedSpy(innerTapHandler, SIGNAL(pressedChanged()));
QSignalSpy userPressedChangedSpy(userTapHandler, SIGNAL(pressedChanged()));
diff --git a/tests/auto/quick/propertyrequirements/propertyrequirements.pro b/tests/auto/quick/propertyrequirements/propertyrequirements.pro
new file mode 100644
index 0000000000..8fe574e0bf
--- /dev/null
+++ b/tests/auto/quick/propertyrequirements/propertyrequirements.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_propertyrequirements
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_propertyrequirements.cpp
+
+QT += qml-private testlib
diff --git a/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp b/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp
new file mode 100644
index 0000000000..fbcd53cad4
--- /dev/null
+++ b/tests/auto/quick/propertyrequirements/tst_propertyrequirements.cpp
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Krammer <kevin.krammer@kdab.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/private/qhashedstring_p.h>
+#include <QtQml/private/qqmlmetatype_p.h>
+#include <QtCore/QDebug>
+#include <QtCore/QHash>
+#include <QtCore/QSet>
+
+class tst_PropertyRequirements : public QObject
+{
+ Q_OBJECT
+public:
+ tst_PropertyRequirements();
+
+private slots:
+ void constantOrNotifyableMain();
+ void constantOrNotifyableFull();
+
+private:
+ typedef QList<QQmlType> Failures;
+
+ /*!
+ All properties that do not pass the check and the affected QML types
+
+ Key: Property name formatted as C++-class-name::property-name
+ Value: List of QQmlType which have the property
+ */
+ typedef QHash<QString, Failures> FailuresByProperty;
+
+ enum TestDepth {
+ MainTypeOnly, //! Check only the properties of the main C++ type for each QML type
+ WithSuperClasses //! Check the super classes for each C++ type as well
+ };
+
+ void testAllQmlTypes(TestDepth testDepth, FailuresByProperty &failuresByProperty);
+ void testQmlType(TestDepth testDepth, const QQmlType &qmlType, FailuresByProperty &failuresByProperty);
+};
+
+
+tst_PropertyRequirements::tst_PropertyRequirements()
+{
+}
+
+void tst_PropertyRequirements::constantOrNotifyableMain()
+{
+ FailuresByProperty failuresByProperty;
+
+ // test
+ testAllQmlTypes(MainTypeOnly, failuresByProperty);
+
+ // report
+ QHash<QString, QStringList> occurrences;
+ for (auto it = failuresByProperty.constBegin(); it != failuresByProperty.constEnd(); ++it) {
+
+ occurrences[it.value().at(0).qmlTypeName()].append(it.key());
+ }
+
+ QStringList messages;
+ for (auto it = occurrences.constBegin(); it != occurrences.constEnd(); ++it) {
+ const QString occurrencePattern("%1:\n\t%2");
+
+ QStringList properties = it.value();
+ properties.sort();
+ messages.append(occurrencePattern.arg(it.key(), properties.join("\n\t")));
+ }
+ messages.sort();
+
+ const QString message("\nThe following QML Types have properties which are neither CONSTANT nor NOTIFYable:\n");
+ QWARN(qPrintable(message + messages.join("\n")));
+
+ // TODO enable once technical debt is fixes
+ // QCOMPARE(failuresByProperty.count(), 0);
+}
+
+void tst_PropertyRequirements::constantOrNotifyableFull()
+{
+ FailuresByProperty failuresByProperty;
+
+ // test
+ testAllQmlTypes(WithSuperClasses, failuresByProperty);
+
+ // report
+ QStringList messages;
+ for (auto it = failuresByProperty.constBegin(); it != failuresByProperty.constEnd(); ++it) {
+
+ QSet<QString> occurrences;
+ for (const QQmlType &qmlType : it.value()) {
+ static const QString occurrencePattern("%1 (%2)");
+
+ occurrences.insert(occurrencePattern.arg(qmlType.metaObject()->className(),
+ qmlType.qmlTypeName()));
+
+ }
+
+ static const QString messagePattern("\nProperty %1 neither CONSTANT nor NOTIFYable. Affected types:\n\t%2");
+ QStringList occurrencesList = occurrences.toList();
+ occurrencesList.sort();
+ messages.append(messagePattern.arg(it.key(), occurrencesList.join("\n\t")));
+
+ }
+ messages.sort();
+
+ QWARN(qPrintable(messages.join("\n")));
+
+ // TODO enable once technical debt is fixes
+ // QCOMPARE(failuresByProperty.count(), 0);
+}
+
+void tst_PropertyRequirements::testAllQmlTypes(TestDepth testDepth, FailuresByProperty &failuresByProperty)
+{
+ const QVector<QByteArray> qmlData {
+ "import QtQml 2.2\nQtObject {}",
+ "import QtQml.Models 2.2\nListModel {}",
+ "import QtQuick 2.5\nItem {}",
+ "import QtQuick.Window 2.2\nWindow {}",
+ "import QtQuick.Dialogs 1.2\nDialog {}",
+ "import QtQuick.Layouts 1.2\nGridLayout {}",
+ "import QtQuick.Controls 2.2\nButton {}",
+ "import QtQuick.Templates 2.2\nButton {}"
+ };
+
+ QQmlEngine engine;
+ QSet<QString> seenTypes;
+
+ for (const QByteArray &data : qmlData) {
+ QQmlComponent component(&engine);
+ component.setData(data, QUrl());
+
+ for (const QQmlType &qmlType : QQmlMetaType::qmlTypes()) {
+ if (!seenTypes.contains(qmlType.qmlTypeName())) {
+ testQmlType(testDepth, qmlType, failuresByProperty);
+ }
+ }
+ seenTypes.unite(QSet<QString>::fromList(QQmlMetaType::qmlTypeNames()));
+ }
+}
+
+void tst_PropertyRequirements::testQmlType(TestDepth testDepth, const QQmlType &qmlType, FailuresByProperty &failuresByProperty)
+{
+ QList<const QMetaObject*> inheritanceHierarchy;
+
+ const QMetaObject *mo = qmlType.metaObject();
+ while (mo) {
+ inheritanceHierarchy.prepend(mo);
+ mo = mo->superClass();
+ }
+
+ // check if this type is derived from QObject and even can have signals
+ // i.e. weed out the Q_GADGET classes
+ if (inheritanceHierarchy.first()->className() != QByteArray("QObject"))
+ return;
+
+ if (testDepth == MainTypeOnly) {
+ inheritanceHierarchy.clear();
+ inheritanceHierarchy.append(qmlType.metaObject());
+ }
+
+ for (const QMetaObject *metaClass : qAsConst(inheritanceHierarchy)) {
+ for (int idx = metaClass->propertyOffset(); idx < metaClass->propertyCount(); ++idx) {
+ const QMetaProperty property = metaClass->property(idx);
+
+ // needs to be either CONSTANT or have a NOTIFY signal
+ if (!property.isConstant() && !property.hasNotifySignal()) {
+ static const QString fullNamePattern("%1::%2");
+ const QString fullPropertyName = fullNamePattern.arg(metaClass->className(), property.name());
+
+ failuresByProperty[fullPropertyName].append(qmlType);
+ }
+ }
+ }
+}
+
+QTEST_MAIN(tst_PropertyRequirements)
+
+#include "tst_propertyrequirements.moc"
diff --git a/tests/auto/quick/qquickanimatedsprite/data/infiniteLoops.qml b/tests/auto/quick/qquickanimatedsprite/data/infiniteLoops.qml
new file mode 100644
index 0000000000..551329a457
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/data/infiniteLoops.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+AnimatedSprite {
+ loops: AnimatedSprite.Infinite
+ source: "squarefacesprite.png"
+ frameCount: 6
+ frameDuration: 240
+ width: 160
+ height: 160
+}
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index d24ebd9878..4ca31fd957 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -53,6 +53,7 @@ private slots:
void test_largeAnimation();
void test_reparenting();
void test_changeSourceToSmallerImgKeepingBigFrameSize();
+ void test_infiniteLoops();
void test_implicitSize();
};
@@ -79,8 +80,13 @@ void tst_qquickanimatedsprite::test_properties()
QVERIFY(sprite->interpolate());
QCOMPARE(sprite->loops(), 30);
+ QSignalSpy finishedSpy(sprite, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
sprite->setRunning(false);
QVERIFY(!sprite->running());
+ // The finished() signal shouldn't be emitted when running is manually set to false.
+ QCOMPARE(finishedSpy.count(), 0);
sprite->setInterpolate(false);
QVERIFY(!sprite->interpolate());
}
@@ -100,10 +106,15 @@ void tst_qquickanimatedsprite::test_runningChangedSignal()
QVERIFY(!sprite->running());
QSignalSpy runningChangedSpy(sprite, SIGNAL(runningChanged(bool)));
+ QSignalSpy finishedSpy(sprite, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
sprite->setRunning(true);
QTRY_COMPARE(runningChangedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
QTRY_VERIFY(!sprite->running());
QTRY_COMPARE(runningChangedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 1);
}
template <typename T>
@@ -357,6 +368,28 @@ void tst_qquickanimatedsprite::test_implicitSize()
QCOMPARE(frameImplicitHeightChangedSpy.count(), 1);
}
+void tst_qquickanimatedsprite::test_infiniteLoops()
+{
+ QQuickView window;
+ window.setSource(testFileUrl("infiniteLoops.qml"));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject());
+
+ QQuickAnimatedSprite* sprite = qobject_cast<QQuickAnimatedSprite*>(window.rootObject());
+ QVERIFY(sprite);
+
+ QTRY_VERIFY(sprite->running());
+
+ QSignalSpy finishedSpy(sprite, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
+ // The finished() signal shouldn't be emitted for infinite animations.
+ const int previousFrame = sprite->currentFrame();
+ QTRY_VERIFY(sprite->currentFrame() != previousFrame);
+ QCOMPARE(finishedSpy.count(), 0);
+}
+
QTEST_MAIN(tst_qquickanimatedsprite)
#include "tst_qquickanimatedsprite.moc"
diff --git a/tests/auto/quick/qquickanimations/data/finished.qml b/tests/auto/quick/qquickanimations/data/finished.qml
new file mode 100644
index 0000000000..a18b321501
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/finished.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Item {
+ id: root
+ width: 400
+ height: 400
+
+ property bool finishedUsableInQml: false
+
+ property alias simpleTopLevelAnimation: simpleTopLevelAnimation
+ property real foo: 0
+
+ property alias transitionRect: transitionRect
+ property alias transition: transition
+ property alias animationWithinTransition: animationWithinTransition
+
+ property real bar: 0
+ property alias animationWithinBehavior: animationWithinBehavior
+ property alias behavior: behavior
+
+ NumberAnimation {
+ id: simpleTopLevelAnimation
+ target: root
+ property: "foo"
+ from: 0
+ to: 1
+ duration: 10
+
+ onFinished: finishedUsableInQml = true
+ }
+
+ Rectangle {
+ id: transitionRect
+ color: "green"
+ width: 50
+ height: 50
+ anchors.centerIn: parent
+
+ states: State {
+ name: "go"
+ }
+ transitions: Transition {
+ id: transition
+ to: "go"
+ SequentialAnimation {
+ NumberAnimation {
+ id: animationWithinTransition
+ duration: 10
+ property: "foo"
+ from: 1
+ to: 2
+ }
+ }
+ }
+ }
+
+ Behavior on bar {
+ id: behavior
+ NumberAnimation {
+ id: animationWithinBehavior
+ duration: 10
+ property: "bar"
+ from: 0
+ to: 1
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/data/replacingTransitions.qml b/tests/auto/quick/qquickanimations/data/replacingTransitions.qml
new file mode 100644
index 0000000000..ff7c50cd67
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/replacingTransitions.qml
@@ -0,0 +1,51 @@
+import QtQuick 2.9
+
+Rectangle {
+ id: theRoot
+ property alias model: theModel
+ property alias addTimer: addToModel
+ property alias addTransition: addTrans
+ property alias displaceTransition: displaceTrans
+
+ width: 400
+ height: 400
+
+ ListModel {
+ id: theModel
+ }
+ Timer {
+ id: addToModel
+ interval: 1000
+ running: false
+ repeat: true
+ onTriggered: {
+ theModel.insert(0, {"name": "item " + theModel.count})
+ if (theModel.count > 2)
+ stop()
+ }
+ }
+ Component {
+ id: listDelegate
+ Text {
+ text: name
+ }
+ }
+ ListView {
+ id: listView
+
+ property int animationDuration: 10000
+
+ anchors.fill: parent
+ model: theModel
+ delegate: listDelegate
+ add: Transition {
+ id: addTrans
+ NumberAnimation { properties: "x"; from: 400; duration: listView.animationDuration }
+ NumberAnimation { properties: "y"; from: 400; duration: listView.animationDuration }
+ }
+ addDisplaced: Transition {
+ id: displaceTrans
+ NumberAnimation { properties: "x,y"; duration: listView.animationDuration }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index de86bb16db..0f095774e8 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -29,6 +29,8 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/qquickview.h>
+#include <QtQml/private/qqmltimer_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
#include <QtQml/private/qanimationgroupjob_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickitemanimation_p.h>
@@ -105,6 +107,8 @@ private slots:
void pathSvgAnimation();
void pathLineUnspecifiedXYBug();
void unsetAnimatorProxyJobWindow();
+ void finished();
+ void replacingTransitions();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -1612,6 +1616,113 @@ void tst_qquickanimations::unsetAnimatorProxyJobWindow()
QCOMPARE(proxy.job().data(), job);
}
+void tst_qquickanimations::finished()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("finished.qml"));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(root);
+
+ // Test that finished() is emitted for a simple top-level animation.
+ // (Each test is in its own block so that we can reuse the nice signal names :))
+ {
+ QQuickAbstractAnimation *simpleTopLevelAnimation
+ = root->property("simpleTopLevelAnimation").value<QQuickAbstractAnimation*>();
+ QVERIFY(simpleTopLevelAnimation);
+
+ QSignalSpy stoppedSpy(simpleTopLevelAnimation, SIGNAL(stopped()));
+ QVERIFY(stoppedSpy.isValid());
+
+ QSignalSpy finishedSpy(simpleTopLevelAnimation, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
+ QVERIFY(simpleTopLevelAnimation->setProperty("running", QVariant(true)));
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 1);
+
+ // Test that the signal is properly revisioned and hence accessible from QML.
+ QCOMPARE(root->property("finishedUsableInQml").toBool(), true);
+ }
+
+ // Test that finished() is not emitted for animations within a Transition.
+ {
+ QObject *transition = root->property("transition").value<QObject*>();
+ QVERIFY(transition);
+
+ QSignalSpy runningChangedSpy(transition, SIGNAL(runningChanged()));
+ QVERIFY(runningChangedSpy.isValid());
+
+ QQuickAbstractAnimation *animationWithinTransition
+ = root->property("animationWithinTransition").value<QQuickAbstractAnimation*>();
+ QVERIFY(animationWithinTransition);
+
+ QSignalSpy stoppedSpy(animationWithinTransition, SIGNAL(stopped()));
+ QVERIFY(stoppedSpy.isValid());
+
+ QSignalSpy finishedSpy(animationWithinTransition, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
+ QObject *transitionRect = root->property("transitionRect").value<QObject*>();
+ QVERIFY(transitionRect);
+ QVERIFY(transitionRect->setProperty("state", QVariant(QLatin1String("go"))));
+ QTRY_COMPARE(runningChangedSpy.count(), 1);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ }
+
+ // Test that finished() is not emitted for animations within a Behavior.
+ {
+ QQuickAbstractAnimation *animationWithinBehavior
+ = root->property("animationWithinBehavior").value<QQuickAbstractAnimation*>();
+ QVERIFY(animationWithinBehavior);
+
+ QSignalSpy stoppedSpy(animationWithinBehavior, SIGNAL(stopped()));
+ QVERIFY(stoppedSpy.isValid());
+
+ QSignalSpy finishedSpy(animationWithinBehavior, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
+ QVERIFY(root->setProperty("bar", QVariant(1.0)));
+ QTRY_COMPARE(root->property("bar").toReal(), 1.0);
+ QCOMPARE(stoppedSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+ }
+}
+
+void tst_qquickanimations::replacingTransitions()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("replacingTransitions.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));
+ if (!c.errors().isEmpty())
+ qDebug() << c.errorString();
+ QVERIFY(rect);
+
+ QQmlTimer *addTimer = rect->property("addTimer").value<QQmlTimer*>();
+ QVERIFY(addTimer);
+ QCOMPARE(addTimer->isRunning(), false);
+
+ QQuickTransition *addTrans = rect->property("addTransition").value<QQuickTransition*>();
+ QVERIFY(addTrans);
+ QCOMPARE(addTrans->running(), false);
+
+ QQuickTransition *displaceTrans = rect->property("displaceTransition").value<QQuickTransition*>();
+ QVERIFY(displaceTrans);
+ QCOMPARE(displaceTrans->running(), false);
+
+ QQmlListModel *model = rect->property("model").value<QQmlListModel *>();
+ QVERIFY(model);
+ QCOMPARE(model->count(), 0);
+
+ addTimer->start();
+ QTest::qWait(1000 + 1000 + 10000);
+
+ QTRY_COMPARE(addTimer->isRunning(), false);
+ QTRY_COMPARE(addTrans->running(), false);
+ QTRY_COMPARE(displaceTrans->running(), false);
+ QCOMPARE(model->count(), 3);
+}
+
QTEST_MAIN(tst_qquickanimations)
#include "tst_qquickanimations.moc"
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_line.qml b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
index 750f37638d..dc960a24d0 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
@@ -834,5 +834,96 @@ CanvasTestCase {
ctx.lineCap = 'square';
compare(ctx.lineCap, 'square');
+ }
+
+ function test_lineDash(row) {
+ var canvas = createCanvasObject(row);
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.strokeStyle = "#fff";
+ ctx.lineWidth = 2;
+ var pattern = [2, 3, 5, 1, 6, 3]
+ ctx.setLineDash(pattern)
+
+ compare(ctx.getLineDash(), pattern);
+
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(40, 0);
+ ctx.stroke();
+
+ comparePixel(ctx, 0,0, 255,255,255,255);
+ comparePixel(ctx, 1,0, 255,255,255,255);
+ comparePixel(ctx, 2,0, 255,255,255,255);
+ comparePixel(ctx, 3,0, 255,255,255,255);
+ comparePixel(ctx, 4,0, 0,0,0,0);
+ comparePixel(ctx, 5,0, 0,0,0,0);
+ comparePixel(ctx, 6,0, 0,0,0,0);
+ comparePixel(ctx, 7,0, 0,0,0,0);
+ comparePixel(ctx, 8,0, 0,0,0,0);
+ comparePixel(ctx, 9,0, 0,0,0,0);
+ comparePixel(ctx, 10,0, 255,255,255,255);
+ comparePixel(ctx, 11,0, 255,255,255,255);
+ comparePixel(ctx, 12,0, 255,255,255,255);
+ comparePixel(ctx, 13,0, 255,255,255,255);
+ comparePixel(ctx, 14,0, 255,255,255,255);
+ comparePixel(ctx, 15,0, 255,255,255,255);
+ comparePixel(ctx, 16,0, 255,255,255,255);
+ comparePixel(ctx, 17,0, 255,255,255,255);
+ comparePixel(ctx, 18,0, 255,255,255,255);
+ comparePixel(ctx, 19,0, 255,255,255,255);
+ comparePixel(ctx, 20,0, 0,0,0,0);
+ comparePixel(ctx, 21,0, 0,0,0,0);
+ comparePixel(ctx, 22,0, 255,255,255,255);
+ comparePixel(ctx, 23,0, 255,255,255,255);
+ comparePixel(ctx, 24,0, 255,255,255,255);
+ comparePixel(ctx, 25,0, 255,255,255,255);
+ comparePixel(ctx, 26,0, 255,255,255,255);
+ comparePixel(ctx, 27,0, 255,255,255,255);
+ comparePixel(ctx, 28,0, 255,255,255,255);
+ comparePixel(ctx, 29,0, 255,255,255,255);
+ comparePixel(ctx, 30,0, 255,255,255,255);
+ comparePixel(ctx, 31,0, 255,255,255,255);
+ comparePixel(ctx, 32,0, 255,255,255,255);
+ comparePixel(ctx, 33,0, 255,255,255,255);
+ comparePixel(ctx, 34,0, 0,0,0,0);
+ comparePixel(ctx, 35,0, 0,0,0,0);
+ comparePixel(ctx, 36,0, 0,0,0,0);
+ comparePixel(ctx, 37,0, 0,0,0,0);
+ comparePixel(ctx, 38,0, 0,0,0,0);
+ comparePixel(ctx, 39,0, 0,0,0,0);
+ }
+
+ function test_lineDashOffset(row) {
+ var canvas = createCanvasObject(row);
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ ctx.strokeStyle = "#fff";
+ ctx.lineWidth = 2;
+ var pattern = [2,2]
+ ctx.setLineDash(pattern)
+ ctx.lineDashOffset = 1
+ compare(ctx.getLineDash(), pattern);
+
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(40, 0);
+ ctx.stroke();
+
+
+ comparePixel(ctx, 0,0, 255,255,255,255);
+ comparePixel(ctx, 1,0, 255,255,255,255);
+ comparePixel(ctx, 2,0, 0,0,0,0);
+ comparePixel(ctx, 3,0, 0,0,0,0);
+ comparePixel(ctx, 4,0, 0,0,0,0);
+ comparePixel(ctx, 5,0, 0,0,0,0);
+ comparePixel(ctx, 6,0, 255,255,255,255);
+ comparePixel(ctx, 7,0, 255,255,255,255);
+ comparePixel(ctx, 8,0, 255,255,255,255);
+ comparePixel(ctx, 9,0, 255,255,255,255);
+ comparePixel(ctx, 10,0, 0,0,0,0);
+ comparePixel(ctx, 11,0, 0,0,0,0);
+ comparePixel(ctx, 12,0, 0,0,0,0);
+ comparePixel(ctx, 13,0, 0,0,0,0);
}
}
diff --git a/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml b/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml
index 68f456af99..63d65b435c 100644
--- a/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml
+++ b/tests/auto/quick/qquickdesignersupport/data/TestComponent.qml
@@ -4,6 +4,8 @@ Item {
width: 100
height: 62
- x: Math.max(0, 200)
+ // Add a dummy dependency to parent.x to ensure that the
+ // binding stays for the test.
+ x: parent.x + Math.max(0, 200) - parent.x
}
diff --git a/tests/auto/quick/qquickdesignersupport/data/test.qml b/tests/auto/quick/qquickdesignersupport/data/test.qml
index 1d43cb3b7e..6c89f15257 100644
--- a/tests/auto/quick/qquickdesignersupport/data/test.qml
+++ b/tests/auto/quick/qquickdesignersupport/data/test.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.0
+import QtQuick 2.11
Rectangle {
objectName: "rootItem"
@@ -13,7 +13,7 @@ Rectangle {
Rectangle {
objectName: "rectangleItem"
- gradient: Gradient {
+ containmentMask: Item {
}
}
diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
index 96a11e16e9..3e0765552a 100644
--- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
+++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp
@@ -209,15 +209,15 @@ void tst_qquickdesignersupport::objectProperties()
//Read gradient property as QObject
- int propertyIndex = rectangleItem->metaObject()->indexOfProperty("gradient");
+ int propertyIndex = rectangleItem->metaObject()->indexOfProperty("containmentMask");
QVERIFY(propertyIndex > 0);
QMetaProperty metaProperty = rectangleItem->metaObject()->property(propertyIndex);
QVERIFY(metaProperty.isValid());
QVERIFY(QQuickDesignerSupportProperties::isPropertyQObject(metaProperty));
- QObject*gradient = QQuickDesignerSupportProperties::readQObjectProperty(metaProperty, rectangleItem);
- QVERIFY(gradient);
+ QObject *containmentItem = QQuickDesignerSupportProperties::readQObjectProperty(metaProperty, rectangleItem);
+ QVERIFY(containmentItem);
//The width property is not a QObject
@@ -450,7 +450,7 @@ void tst_qquickdesignersupport::testNotifyPropertyChangeCallBack()
QQuickDesignerSupportMetaInfo::registerNotifyPropertyChangeCallBack(notifyPropertyChangeCallBackPointer);
- rectangle->setProperty("gradient", QVariant::fromValue<QQuickGradient *>(gradient));
+ rectangle->setProperty("gradient", QVariant::fromValue<QJSValue>(view->engine()->newQObject(gradient)));
QVERIFY(s_object);
QCOMPARE(s_object, rootItem);
diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST
index 826c024732..cc91754e68 100644
--- a/tests/auto/quick/qquickflickable/BLACKLIST
+++ b/tests/auto/quick/qquickflickable/BLACKLIST
@@ -1,22 +1,7 @@
-# QTBUG-36804
-osx-10.10
# QTBUG-26696
[rebound]
osx
-[movingAndFlicking:vertical]
-osx-10.10
-[movingAndFlicking:both]
-osx-10.10
-[movingAndFlicking:horizontal]
-osx-10.10
[stopAtBounds]
-osx-10.10
windows developer-build
[returnToBounds]
osx
-[pressWhileFlicking]
-osx-10.10
-[flickVelocity]
-osx-10.10
-[nestedSliderUsingTouch:keepNeither]
-ubuntu-16.04
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 248f8447e0..65a08ce87f 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -203,6 +203,8 @@ private slots:
void overshoot();
void overshoot_data();
void overshoot_reentrant();
+ void synchronousDrag_data();
+ void synchronousDrag();
private:
void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to);
@@ -1917,6 +1919,10 @@ void tst_qquickflickable::stopAtBounds()
else
QCOMPARE(transpose ? flickable->isAtYBeginning() : flickable->isAtXBeginning(), true);
+ QSignalSpy atXBeginningChangedSpy(flickable, &QQuickFlickable::atXBeginningChanged);
+ QSignalSpy atYBeginningChangedSpy(flickable, &QQuickFlickable::atYBeginningChanged);
+ QSignalSpy atXEndChangedSpy(flickable, &QQuickFlickable::atXEndChanged);
+ QSignalSpy atYEndChangedSpy(flickable, &QQuickFlickable::atYEndChanged);
// drag back towards boundary
for (int i = 0; i < 24; ++i) {
axis += invert ? threshold / 3 : -threshold / 3;
@@ -1928,6 +1934,11 @@ void tst_qquickflickable::stopAtBounds()
else
QCOMPARE(transpose ? flickable->isAtYBeginning() : flickable->isAtXBeginning(), false);
+ QCOMPARE(atXBeginningChangedSpy.count(), (!transpose && !invert) ? 1 : 0);
+ QCOMPARE(atYBeginningChangedSpy.count(), ( transpose && !invert) ? 1 : 0);
+ QCOMPARE(atXEndChangedSpy.count(), (!transpose && invert) ? 1 : 0);
+ QCOMPARE(atYEndChangedSpy.count(), ( transpose && invert) ? 1 : 0);
+
// Drag away from the aligned boundary again.
// None of the mouse movements will position the view at the boundary exactly,
// but the view should end up aligned on the boundary
@@ -2002,21 +2013,21 @@ void tst_qquickflickable::nestedSliderUsingTouch_data()
{
QTest::addColumn<bool>("keepMouseGrab");
QTest::addColumn<bool>("keepTouchGrab");
- QTest::addColumn<int>("updates");
+ QTest::addColumn<int>("minUpdates");
QTest::addColumn<int>("releases");
QTest::addColumn<int>("ungrabs");
QTest::newRow("keepBoth") << true << true << 8 << 1 << 0;
QTest::newRow("keepMouse") << true << false << 8 << 1 << 0;
QTest::newRow("keepTouch") << false << true << 8 << 1 << 0;
- QTest::newRow("keepNeither") << false << false << 6 << 0 << 1;
+ QTest::newRow("keepNeither") << false << false << 5 << 0 << 1;
}
void tst_qquickflickable::nestedSliderUsingTouch()
{
QFETCH(bool, keepMouseGrab);
QFETCH(bool, keepTouchGrab);
- QFETCH(int, updates);
+ QFETCH(int, minUpdates);
QFETCH(int, releases);
QFETCH(int, ungrabs);
@@ -2052,7 +2063,7 @@ void tst_qquickflickable::nestedSliderUsingTouch()
QTest::touchEvent(window, touchDevice).release(0, p0, window);
QQuickTouchUtils::flush(window);
QTRY_COMPARE(tda->touchPointStates.first(), Qt::TouchPointPressed);
- QTRY_COMPARE(tda->touchUpdates, updates);
+ QTRY_VERIFY(tda->touchUpdates >= minUpdates);
QTRY_COMPARE(tda->touchReleases, releases);
QTRY_COMPARE(tda->ungrabs, ungrabs);
}
@@ -2458,6 +2469,70 @@ void tst_qquickflickable::overshoot_reentrant()
QCOMPARE(flickable->verticalOvershoot(), 25.0);
}
+void tst_qquickflickable::synchronousDrag_data()
+{
+ QTest::addColumn<bool>("synchronousDrag");
+
+ QTest::newRow("default") << false;
+ QTest::newRow("synch") << true;
+}
+
+void tst_qquickflickable::synchronousDrag()
+{
+ QFETCH(bool, synchronousDrag);
+
+ QScopedPointer<QQuickView> scopedWindow(new QQuickView);
+ QQuickView *window = scopedWindow.data();
+ window->setSource(testFileUrl("longList.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window);
+ QQuickViewTestUtil::moveMouseAway(window);
+ window->show();
+ QVERIFY(window->rootObject() != nullptr);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != nullptr);
+ QCOMPARE(flickable->synchronousDrag(), false);
+ flickable->setSynchronousDrag(synchronousDrag);
+
+ QPoint p1(100, 100);
+ QPoint p2(95, 95);
+ QPoint p3(70, 70);
+ QPoint p4(50, 50);
+ QPoint p5(30, 30);
+ QCOMPARE(flickable->contentY(), 0.0f);
+
+ // Drag via mouse
+ moveAndPress(window, p1);
+ QTest::mouseMove(window, p2);
+ QTest::mouseMove(window, p3);
+ QTest::mouseMove(window, p4);
+ QCOMPARE(flickable->contentY(), synchronousDrag ? 50.0f : 0.0f);
+ QTest::mouseMove(window, p5);
+ if (!synchronousDrag)
+ QVERIFY(flickable->contentY() < 50.0f);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p5);
+
+ // Reset to initial condition
+ flickable->setContentY(0);
+
+ // Drag via touch
+ QTest::touchEvent(window, touchDevice).press(0, p1, window);
+ QQuickTouchUtils::flush(window);
+ QTest::touchEvent(window, touchDevice).move(0, p2, window);
+ QQuickTouchUtils::flush(window);
+ QTest::touchEvent(window, touchDevice).move(0, p3, window);
+ QQuickTouchUtils::flush(window);
+ QTest::touchEvent(window, touchDevice).move(0, p4, window);
+ QQuickTouchUtils::flush(window);
+ QCOMPARE(flickable->contentY(), synchronousDrag ? 50.0f : 0.0f);
+ QTest::touchEvent(window, touchDevice).move(0, p5, window);
+ QQuickTouchUtils::flush(window);
+ if (!synchronousDrag)
+ QVERIFY(flickable->contentY() < 50.0f);
+ QTest::touchEvent(window, touchDevice).release(0, p5, window);
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"
diff --git a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
index 805baebc7a..6aff66d61e 100644
--- a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
+++ b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp
@@ -193,7 +193,7 @@ void tst_QQuickFramebufferObject::testThatStuffWorks()
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QImage result = view.grabWindow();
@@ -233,7 +233,7 @@ void tst_QQuickFramebufferObject::testInvalidate()
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QCOMPARE(frameInfo.fboSize, QSize(200, 200));
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 915b9b43ea..7deed8c5a8 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -4387,24 +4387,34 @@ void tst_QQuickGridView::snapOneRow_data()
QTest::addColumn<qreal>("snapAlignment");
QTest::addColumn<qreal>("endExtent");
QTest::addColumn<qreal>("startExtent");
+ QTest::addColumn<qreal>("flickSlowdown");
QTest::newRow("vertical, left to right") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0;
+ << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0 << 1.0;
QTest::newRow("horizontal, left to right") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0;
+ << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0 << 1.0;
QTest::newRow("horizontal, right to left") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0;
+ << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0 << 1.0;
QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0;
+ << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0 << 1.0;
QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0;
+ << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0 << 1.0;
QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0;
+ << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0 << 1.0;
+
+ // Using e.g. 120 rather than 95 always went to the next row.
+ // Ensure this further movement has the same behavior
+ QTest::newRow("vertical, left to right, no more blindspot") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 160) << QPoint(20, 95) << 100.0 << 240.0 << 0.0 << 4.0;
+
+ // StrictlyEnforceRange should not override valid SnapOneItem decisions
+ QTest::newRow("vertical, left to right, no more blindspot, enforce range") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 160) << QPoint(20, 95) << 100.0 << 340.0 << -20.0 << 4.0;
}
void tst_QQuickGridView::snapOneRow()
@@ -4417,6 +4427,9 @@ void tst_QQuickGridView::snapOneRow()
QFETCH(qreal, snapAlignment);
QFETCH(qreal, endExtent);
QFETCH(qreal, startExtent);
+ QFETCH(qreal, flickSlowdown);
+
+ qreal flickDuration = 180 * flickSlowdown;
QQuickView *window = getView();
QQuickViewTestUtil::moveMouseAway(window);
@@ -4439,7 +4452,7 @@ void tst_QQuickGridView::snapOneRow()
QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged()));
// confirm that a flick hits next row boundary
- flick(window, flickStart, flickEnd, 180);
+ flick(window, flickStart, flickEnd, flickDuration);
QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
if (flow == QQuickGridView::FlowLeftToRight)
QCOMPARE(gridview->contentY(), snapAlignment);
@@ -4453,7 +4466,7 @@ void tst_QQuickGridView::snapOneRow()
// flick to end
do {
- flick(window, flickStart, flickEnd, 180);
+ flick(window, flickStart, flickEnd, flickDuration);
QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
} while (flow == QQuickGridView::FlowLeftToRight
? !gridview->isAtYEnd()
@@ -4471,7 +4484,7 @@ void tst_QQuickGridView::snapOneRow()
// flick to start
do {
- flick(window, flickEnd, flickStart, 180);
+ flick(window, flickEnd, flickStart, flickDuration);
QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
} while (flow == QQuickGridView::FlowLeftToRight
? !gridview->isAtYBeginning()
diff --git a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index d8464ebc74..4b75a7e008 100644
--- a/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -65,6 +65,7 @@ private slots:
void threadTest();
void asyncTextureTest();
+ void instantAsyncTextureTest();
private:
QString newImageFileName() const;
@@ -550,6 +551,70 @@ void tst_qquickimageprovider::asyncTextureTest()
}
}
+class InstantAsyncImageResponse : public QQuickImageResponse
+{
+ public:
+ InstantAsyncImageResponse(const QString &id, const QSize &requestedSize)
+ {
+ QImage image(50, 50, QImage::Format_RGB32);
+ image.fill(QColor(id).rgb());
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ m_texture = QQuickTextureFactory::textureFactoryForImage(image);
+ emit finished();
+ }
+
+ QQuickTextureFactory *textureFactory() const
+ {
+ return m_texture;
+ }
+
+ QQuickTextureFactory *m_texture;
+};
+
+class InstancAsyncProvider : public QQuickAsyncImageProvider
+{
+ public:
+ InstancAsyncProvider()
+ {
+ }
+
+ ~InstancAsyncProvider() {}
+
+ QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize)
+ {
+ return new InstantAsyncImageResponse(id, requestedSize);
+ }
+};
+
+void tst_qquickimageprovider::instantAsyncTextureTest()
+{
+ QQmlEngine engine;
+
+ InstancAsyncProvider *provider = new InstancAsyncProvider;
+
+ engine.addImageProvider("test_instantasync", provider);
+ QVERIFY(engine.imageProvider("test_instantasync") != nullptr);
+
+ QString componentStr = "import QtQuick 2.0\nItem { \n"
+ "Image { source: \"image://test_instantasync/blue\"; }\n"
+ "Image { source: \"image://test_instantasync/red\"; }\n"
+ "Image { source: \"image://test_instantasync/green\"; }\n"
+ "Image { source: \"image://test_instantasync/yellow\"; }\n"
+ " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> obj(component.create());
+
+ QVERIFY(!obj.isNull());
+ const QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
+ QCOMPARE(images.count(), 4);
+
+ for (QQuickImage *img: images) {
+ QTRY_COMPARE(img->status(), QQuickImage::Ready);
+ }
+}
+
QTEST_MAIN(tst_qquickimageprovider)
diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop.qml
new file mode 100644
index 0000000000..889e480f3b
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.6
+
+Item {
+ visible: true
+ Item {
+ visible: false
+ Item {
+ objectName: "hiddenChild"
+ activeFocusOnTab: true
+ focus: true
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index f0f5873ace..7107f4d995 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -64,6 +64,7 @@ private slots:
void activeFocusOnTab8();
void activeFocusOnTab9();
void activeFocusOnTab10();
+ void activeFocusOnTab_infiniteLoop();
void nextItemInFocusChain();
void nextItemInFocusChain2();
@@ -1023,6 +1024,22 @@ void tst_QQuickItem::activeFocusOnTab10()
delete window;
}
+void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+{
+ // see QTBUG-68271
+ // create a window where the currently focused item is not visible
+ QScopedPointer<QQuickView>window(new QQuickView());
+ window->setSource(testFileUrl("activeFocusOnTab_infiniteLoop.qml"));
+ window->show();
+ auto *hiddenChild = findItem<QQuickItem>(window->rootObject(), "hiddenChild");
+ QVERIFY(hiddenChild);
+
+ // move the focus - this used to result in an infinite loop
+ auto *item = hiddenChild->nextItemInFocusChain();
+ // focus is moved to the root object since there is no other candidate
+ QCOMPARE(item, window->rootObject());
+}
+
void tst_QQuickItem::nextItemInFocusChain()
{
if (!qt_tab_all_widgets())
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml
index e30355c675..6e12eeafca 100644
--- a/examples/quick/demos/stocqt/content/StockListView.qml
+++ b/tests/auto/quick/qquicklistview/data/setpositiononlayout.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -49,40 +49,39 @@
****************************************************************************/
import QtQuick 2.0
-import "."
Rectangle {
- id: root
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- color: "white"
-
- property string currentStockId: ""
- property string currentStockName: ""
+ width: 200
+ height: 720
ListView {
- id: view
anchors.fill: parent
- clip: true
- keyNavigationWraps: true
- highlightMoveDuration: 0
focus: true
- snapMode: ListView.SnapToItem
- model: StockListModel {}
- currentIndex: -1 // Don't pre-select any item
-
- onCurrentIndexChanged: {
- if (currentItem) {
- root.currentStockId = model.get(currentIndex).stockId;
- root.currentStockName = model.get(currentIndex).name;
+ highlightMoveDuration: 200
+ model: 50
+ spacing: 10
+ delegate: FocusScope {
+ implicitHeight: col.height
+ Column {
+ id: col
+ Text {
+ text: "YYYY"
+ }
+ ListView {
+ id: list
+ model: 1
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: 250
+ orientation: ListView.Horizontal
+ delegate: Rectangle {
+ id: self
+ height: 250
+ width: 150
+ color: "blue"
+ }
+ }
}
}
-
- delegate: StockListDelegate {}
-
- highlight: Rectangle {
- width: view.width
- color: "#eeeeee"
- }
}
}
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml
new file mode 100644
index 0000000000..f5b7b35d0c
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemWrongDirection.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+ListView {
+ width: 400
+ height: 400
+ focus: true
+
+ model: 10
+ delegate: Rectangle {
+ width: parent.width
+ height: 50
+ color: index % 2 ? "blue" : "green"
+ }
+
+ snapMode: ListView.SnapOneItem
+ Keys.onUpPressed: flick(0,500)
+ Keys.onDownPressed: flick(0,-500)
+}
diff --git a/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml
new file mode 100644
index 0000000000..45164222f2
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/usechooserwithoutdefault.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import Qt.labs.qmlmodels 1.0
+
+Item {
+ width: 640
+ height: 450
+
+ ListView {
+ width: 600
+ height: 400
+ model: 2
+ delegate: DelegateChooser {
+ DelegateChoice {
+ index: 0
+ delegate: Rectangle {
+ width: 100
+ height: 100
+ color:"green"
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index c1daddb561..a9be9d4fa4 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -118,6 +118,7 @@ private slots:
void noCurrentIndex();
void keyNavigation();
void keyNavigation_data();
+ void checkCountForMultiColumnModels();
void enforceRange();
void enforceRange_withoutHighlight();
void spacing();
@@ -181,6 +182,7 @@ private slots:
void snapOneItem_data();
void snapOneItem();
void snapOneItemCurrentIndexRemoveAnimation();
+ void snapOneItemWrongDirection();
void QTBUG_9791();
void QTBUG_33568();
@@ -265,7 +267,10 @@ private slots:
void QTBUG_34576_velocityZero();
void QTBUG_61537_modelChangesAsync();
+ void useDelegateChooserWithoutDefault();
+
void addOnCompleted();
+ void setPositionOnLayout();
private:
template <class T> void items(const QUrl &source);
@@ -1855,6 +1860,38 @@ void tst_QQuickListView::swapWithFirstItem()
delete testObject;
}
+void tst_QQuickListView::checkCountForMultiColumnModels()
+{
+ // Check that a list view will only load items for the first
+ // column, even if the model reports that it got several columns.
+ // We test this since QQmlDelegateModel has been changed to
+ // also understand multi-column models, but this should not affect ListView.
+ QScopedPointer<QQuickView> window(createView());
+
+ const int rowCount = 10;
+ const int columnCount = 10;
+
+ QaimModel model;
+ model.columns = columnCount;
+ for (int i = 0; i < rowCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = window->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QScopedPointer<TestObject> testObject(new TestObject);
+ ctxt->setContextProperty("testObject", testObject.data());
+
+ window->setSource(testFileUrl("listviewtest.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
+ QTRY_VERIFY(listview != nullptr);
+
+ QCOMPARE(listview->count(), rowCount);
+}
+
void tst_QQuickListView::enforceRange()
{
QScopedPointer<QQuickView> window(createView());
@@ -5481,38 +5518,50 @@ void tst_QQuickListView::snapOneItem_data()
QTest::addColumn<qreal>("snapAlignment");
QTest::addColumn<qreal>("endExtent");
QTest::addColumn<qreal>("startExtent");
+ QTest::addColumn<qreal>("flickSlowdown");
QTest::newRow("vertical, top to bottom")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0 << 1.0;
QTest::newRow("vertical, bottom to top")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -560.0 - 240.0 << -240.0;
+ << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -560.0 - 240.0 << -240.0 << 1.0;
QTest::newRow("horizontal, left to right")
<< QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0 << 1.0;
QTest::newRow("horizontal, right to left")
<< QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0;
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0 << 1.0;
QTest::newRow("vertical, top to bottom, enforce range")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0 << 1.0;
QTest::newRow("vertical, bottom to top, enforce range")
<< QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::BottomToTop << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -580.0 - 240.0 << -220.0;
+ << QPoint(20, 20) << QPoint(20, 200) << -420.0 << -580.0 - 240.0 << -220.0 << 1.0;
QTest::newRow("horizontal, left to right, enforce range")
<< QQuickListView::Horizontal << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0 << 1.0;
QTest::newRow("horizontal, right to left, enforce range")
<< QQuickListView::Horizontal << Qt::RightToLeft << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0;
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0 << 1.0;
+
+ // Using e.g. 120 rather than 95 always went to the next item.
+ // Ensure this further movement has the same behavior
+ QTest::newRow("vertical, top to bottom, no more blindspot")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 95) << 180.0 << 560.0 << 0.0 << 6.0;
+
+ // StrictlyEnforceRange should not override valid SnapOneItem decisions
+ QTest::newRow("vertical, top to bottom, no more blindspot, enforce range")
+ << QQuickListView::Vertical << Qt::LeftToRight << QQuickItemView::TopToBottom << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 95) << 180.0 << 580.0 << -20.0 << 6.0;
}
void tst_QQuickListView::snapOneItem()
@@ -5526,6 +5575,9 @@ void tst_QQuickListView::snapOneItem()
QFETCH(qreal, snapAlignment);
QFETCH(qreal, endExtent);
QFETCH(qreal, startExtent);
+ QFETCH(qreal, flickSlowdown);
+
+ qreal flickDuration = 180 * flickSlowdown;
QQuickView *window = getView();
QQuickViewTestUtil::moveMouseAway(window);
@@ -5550,7 +5602,7 @@ void tst_QQuickListView::snapOneItem()
QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
// confirm that a flick hits the next item boundary
- flick(window, flickStart, flickEnd, 180);
+ flick(window, flickStart, flickEnd, flickDuration);
QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
if (orientation == QQuickListView::Vertical)
QCOMPARE(listview->contentY(), snapAlignment);
@@ -5564,7 +5616,7 @@ void tst_QQuickListView::snapOneItem()
// flick to end
do {
- flick(window, flickStart, flickEnd, 180);
+ flick(window, flickStart, flickEnd, flickDuration);
QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
} while (orientation == QQuickListView::Vertical
? verticalLayoutDirection == QQuickItemView::TopToBottom ? !listview->isAtYEnd() : !listview->isAtYBeginning()
@@ -5582,7 +5634,7 @@ void tst_QQuickListView::snapOneItem()
// flick to start
do {
- flick(window, flickEnd, flickStart, 180);
+ flick(window, flickEnd, flickStart, flickDuration);
QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
} while (orientation == QQuickListView::Vertical
? verticalLayoutDirection == QQuickItemView::TopToBottom ? !listview->isAtYBeginning() : !listview->isAtYEnd()
@@ -5624,6 +5676,24 @@ void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation()
QCOMPARE(currentIndexSpy.count(), 0);
}
+void tst_QQuickListView::snapOneItemWrongDirection()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("snapOneItemWrongDirection.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QTRY_VERIFY(listview != nullptr);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+
+ listview->flick(0,500);
+ QTRY_VERIFY(!listview->isMovingHorizontally());
+ QCOMPARE(listview->contentX(), qreal(0));
+}
+
void tst_QQuickListView::attachedProperties_QTBUG_32836()
{
QScopedPointer<QQuickView> window(createView());
@@ -8791,6 +8861,31 @@ void tst_QQuickListView::addOnCompleted()
}
}
+void tst_QQuickListView::setPositionOnLayout()
+{
+ // Make sure we don't trigger a crash by removing items during layout from setPosition().
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("setpositiononlayout.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ for (int i = 0; i < 1000; ++i) {
+ QTest::keyPress(window.data(), Qt::Key_Down);
+ QTest::qWait(1);
+ QTest::keyRelease(window.data(), Qt::Key_Down);
+ }
+}
+
+void tst_QQuickListView::useDelegateChooserWithoutDefault()
+{
+ // Check that the application doesn't crash
+ // if the delegate chooser doesn't cover all cells
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("usechooserwithoutdefault.qml"));
+ window->show();
+};
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index 5c3729a8cd..fbdd87905b 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -739,7 +739,7 @@ void tst_QQuickLoader::initialPropertyValuesError_data()
<< (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": No such file or directory"));
QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Expected token `:'"));
QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
<< (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
@@ -885,7 +885,7 @@ void tst_QQuickLoader::asynchronous_data()
<< (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": No such file or directory"));
QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Expected token `:'"));
}
void tst_QQuickLoader::asynchronous()
diff --git a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
index cab6e2f7bf..cdb3e7733b 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
+++ b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
@@ -1,4 +1,6 @@
[nonOverlapping]
ubuntu-16.04
+ubuntu-18.04
[nested]
ubuntu-16.04
+ubuntu-18.04
diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/mouse.qml b/tests/auto/quick/qquickmultipointtoucharea/data/mouse.qml
index 0abcc76f7c..b0410dac4a 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/data/mouse.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/mouse.qml
@@ -6,6 +6,9 @@ MultiPointTouchArea {
property int touchCount: 0
property int cancelCount: 0
+ property int gestureStartedX: 0
+ property int gestureStartedY: 0
+ property bool grabGesture: false
minimumTouchPoints: 1
maximumTouchPoints: 4
@@ -17,6 +20,12 @@ MultiPointTouchArea {
onPressed: { touchCount = touchPoints.length }
onTouchUpdated: { touchCount = touchPoints.length }
onCanceled: { cancelCount = touchPoints.length }
+ onGestureStarted: {
+ gestureStartedX = gesture.touchPoints[0].startX
+ gestureStartedY = gesture.touchPoints[0].startY
+ if (grabGesture)
+ gesture.grab()
+ }
Rectangle {
color: "red"
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 73f3cab318..d4ad282701 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -69,6 +69,8 @@ private slots:
void transformedTouchArea();
void mouseInteraction();
void mouseInteraction_data();
+ void mouseGestureStarted_data();
+ void mouseGestureStarted();
void cancel();
private:
@@ -1196,6 +1198,57 @@ void tst_QQuickMultiPointTouchArea::mouseInteraction()
QCOMPARE(area->property("touchCount").toInt(), 0);
}
+void tst_QQuickMultiPointTouchArea::mouseGestureStarted_data()
+{
+ QTest::addColumn<bool>("grabGesture");
+ QTest::addColumn<int>("distanceFromOrigin");
+
+ QTest::newRow("near origin, don't grab") << false << 4;
+ QTest::newRow("near origin, grab") << true << 4;
+ QTest::newRow("away from origin, don't grab") << false << 100;
+ QTest::newRow("away from origin, grab") << true << 100;
+}
+
+void tst_QQuickMultiPointTouchArea::mouseGestureStarted() // QTBUG-70258
+{
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+ QFETCH(bool, grabGesture);
+ QFETCH(int, distanceFromOrigin);
+
+ QScopedPointer<QQuickView> view(createAndShowView("mouse.qml"));
+ QVERIFY(view->rootObject() != nullptr);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(view->rootObject());
+ QVERIFY(area);
+ area->setProperty("grabGesture", grabGesture);
+ QQuickTouchPoint *point1 = view->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QCOMPARE(point1->pressed(), false);
+ QSignalSpy gestureStartedSpy(area, SIGNAL(gestureStarted(QQuickGrabGestureEvent *)));
+
+ QPoint p1 = QPoint(distanceFromOrigin, distanceFromOrigin);
+ QTest::mousePress(view.data(), Qt::LeftButton, Qt::NoModifier, p1);
+ QCOMPARE(gestureStartedSpy.count(), 0);
+
+ p1 += QPoint(dragThreshold, dragThreshold);
+ QTest::mouseMove(view.data(), p1);
+ QCOMPARE(gestureStartedSpy.count(), 0);
+
+ p1 += QPoint(1, 1);
+ QTest::mouseMove(view.data(), p1);
+ QTRY_COMPARE(gestureStartedSpy.count(), 1);
+ QTRY_COMPARE(area->property("gestureStartedX").toInt(), distanceFromOrigin);
+ QCOMPARE(area->property("gestureStartedY").toInt(), distanceFromOrigin);
+
+ p1 += QPoint(10, 10);
+ QTest::mouseMove(view.data(), p1);
+ // if nobody called gesteure->grab(), gestureStarted will keep happening
+ QTRY_COMPARE(gestureStartedSpy.count(), grabGesture ? 1 : 2);
+ QCOMPARE(area->property("gestureStartedX").toInt(), distanceFromOrigin);
+ QCOMPARE(area->property("gestureStartedY").toInt(), distanceFromOrigin);
+
+ QTest::mouseRelease(view.data(), Qt::LeftButton);
+}
+
void tst_QQuickMultiPointTouchArea::cancel()
{
QScopedPointer<QQuickView> window(createAndShowView("cancel.qml"));
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index badc6f44c8..aceb61bde4 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -369,6 +369,10 @@ void tst_QQuickPathView::insertModel_data()
void tst_QQuickPathView::insertModel()
{
+#ifdef Q_OS_MACOS
+ QSKIP("this test currently crashes on MacOS. See QTBUG-68048");
+#endif
+
QFETCH(int, mode);
QFETCH(int, idx);
QFETCH(int, count);
@@ -775,6 +779,10 @@ void tst_QQuickPathView::path()
void tst_QQuickPathView::dataModel()
{
+#ifdef Q_OS_MACOS
+ QSKIP("this test currently crashes on MacOS. See QTBUG-68047");
+#endif
+
QScopedPointer<QQuickView> window(createView());
window->show();
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
index 2571e4f288..5b7108d96b 100644
--- a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 0395b08f10..9881af690c 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -40,6 +40,8 @@
using namespace QQuickViewTestUtil;
using namespace QQuickVisualTestUtil;
+Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests")
+
class tst_qquickpositioners : public QQmlDataTest
{
Q_OBJECT
@@ -4007,15 +4009,19 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
{
QQuickView *window = new QQuickView(nullptr);
- qDebug() << "1";
+ qCDebug(lcTests) << "created window";
window->setSource(QUrl::fromLocalFile(filename));
- qDebug() << "2";
+ qCDebug(lcTests) << "loaded content from" << filename;
window->show();
- qDebug() << "3";
+ qCDebug(lcTests) << "window shown";
+ bool exposed = true;
if (wait)
- QTest::qWaitForWindowExposed(window); //It may not relayout until the next frame, so it needs to be drawn
- qDebug() << "4";
+ exposed = QTest::qWaitForWindowExposed(window); //It may not relayout until the next frame, so it needs to be drawn
+ if (exposed)
+ qCDebug(lcTests) << "window exposed";
+ else
+ qCWarning(lcTests) << "window NOT exposed";
return window;
}
diff --git a/tests/auto/quick/qquickrectangle/data/gradient-preset.qml b/tests/auto/quick/qquickrectangle/data/gradient-preset.qml
new file mode 100644
index 0000000000..b740bdd610
--- /dev/null
+++ b/tests/auto/quick/qquickrectangle/data/gradient-preset.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+Item {
+ Rectangle {
+ objectName: "enum"
+ gradient: Gradient.NightFade
+ }
+ Rectangle {
+ objectName: "string"
+ gradient: "NightFade"
+ }
+ Rectangle {
+ objectName: "invalid"
+ gradient: -1
+ }
+}
diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
index 2aaad867bf..f6ca999cf5 100644
--- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
+++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
@@ -49,6 +49,7 @@ private slots:
void gradient_border();
void gradient_separate();
void gradient_multiple();
+ void gradient_preset();
void antialiasing();
private:
@@ -84,7 +85,7 @@ void tst_qquickrectangle::gradient()
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(component.create());
QVERIFY(rect);
- QQuickGradient *grad = rect->gradient();
+ QQuickGradient *grad = qobject_cast<QQuickGradient *>(rect->gradient().toQObject());
QVERIFY(grad);
QQmlListProperty<QQuickGradientStop> stops = grad->stops();
@@ -103,7 +104,7 @@ void tst_qquickrectangle::gradient()
QMetaObject::invokeMethod(rect, "resetGradient");
- grad = rect->gradient();
+ grad = qobject_cast<QQuickGradient *>(rect->gradient().toQObject());
QVERIFY(!grad);
delete rect;
@@ -174,6 +175,29 @@ void tst_qquickrectangle::gradient_multiple()
QVERIFY(secondIsDirty);
}
+void tst_qquickrectangle::gradient_preset()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("gradient-preset.qml"));
+ view.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QQuickRectangle *enumRect = view.rootObject()->findChild<QQuickRectangle *>("enum");
+ QVERIFY(enumRect);
+ QVERIFY(enumRect->gradient().isNumber());
+ QCOMPARE(enumRect->gradient().toUInt(), QGradient::NightFade);
+
+ QQuickRectangle *stringRect = view.rootObject()->findChild<QQuickRectangle *>("string");
+ QVERIFY(stringRect);
+ QVERIFY(stringRect->gradient().isString());
+ QCOMPARE(stringRect->gradient().toString(), QLatin1String("NightFade"));
+
+ QQuickRectangle *invalidRect = view.rootObject()->findChild<QQuickRectangle *>("invalid");
+ QVERIFY(invalidRect);
+ QVERIFY(invalidRect->gradient().isUndefined());
+}
+
void tst_qquickrectangle::antialiasing()
{
QQmlComponent component(&engine);
diff --git a/tests/auto/quick/qquickrepeater/data/ownership.qml b/tests/auto/quick/qquickrepeater/data/ownership.qml
new file mode 100644
index 0000000000..e13df3ab3a
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/ownership.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.0
+
+Repeater {
+}
diff --git a/tests/auto/quick/qquickrepeater/data/package.qml b/tests/auto/quick/qquickrepeater/data/package.qml
new file mode 100644
index 0000000000..1f9eb0d970
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/package.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.0
+import QtQml.Models 2.2
+import QtQuick.Window 2.0
+
+Window {
+ width: 300
+ height: 300
+ visible: true
+ DelegateModel {
+ id: mdl
+
+ model: 1
+ delegate: Package {
+ Item {
+ id: first
+ Package.name: "first"
+ objectName: "firstItem"
+ }
+ Item{
+ id: second
+ Package.name: "second"
+ objectName: "secondItem"
+ }
+ }
+ }
+
+ Repeater {
+ id: repeater1
+ model: mdl.parts.first
+ }
+ Repeater {
+ id: repeater2
+ model: mdl.parts.second
+ }
+}
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index 0499e2f9a6..e4b427f6ec 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -37,6 +37,7 @@
#include <QtQuick/private/qquicktext_p.h>
#include <QtQml/private/qqmllistmodel_p.h>
#include <QtQml/private/qqmlobjectmodel_p.h>
+#include <QtGui/qstandarditemmodel.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
@@ -76,6 +77,8 @@ private slots:
void stackingOrder();
void objectModel();
void QTBUG54859_asynchronousMove();
+ void package();
+ void ownership();
};
class TestObject : public QObject
@@ -130,6 +133,12 @@ void tst_QQuickRepeater::numberModel()
QMetaObject::invokeMethod(window->rootObject(), "checkProperties");
QVERIFY(!testObject->error());
+ ctxt->setContextProperty("testData", std::numeric_limits<int>::max());
+ QCOMPARE(repeater->parentItem()->childItems().count(), 1);
+
+ ctxt->setContextProperty("testData", -1234);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 1);
+
delete testObject;
delete window;
}
@@ -1014,6 +1023,91 @@ void tst_QQuickRepeater::QTBUG54859_asynchronousMove()
QTRY_COMPARE(item->property("finished"), QVariant(true));
}
+void tst_QQuickRepeater::package()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("package.qml"));
+
+ QScopedPointer<QObject>o(component.create()); // don't crash!
+ QVERIFY(o != nullptr);
+
+ {
+ QQuickRepeater *repeater1 = qobject_cast<QQuickRepeater*>(qmlContext(o.data())->contextProperty("repeater1").value<QObject*>());
+ QVERIFY(repeater1);
+ QCOMPARE(repeater1->count(), 1);
+ QCOMPARE(repeater1->itemAt(0)->objectName(), "firstItem");
+ }
+
+ {
+ QQuickRepeater *repeater2 = qobject_cast<QQuickRepeater*>(qmlContext(o.data())->contextProperty("repeater2").value<QObject*>());
+ QVERIFY(repeater2);
+ QCOMPARE(repeater2->count(), 1);
+ QCOMPARE(repeater2->itemAt(0)->objectName(), "secondItem");
+ }
+}
+
+void tst_QQuickRepeater::ownership()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("ownership.qml"));
+
+ QScopedPointer<QAbstractItemModel> aim(new QStandardItemModel);
+ QPointer<QAbstractItemModel> modelGuard(aim.data());
+ QQmlEngine::setObjectOwnership(aim.data(), QQmlEngine::JavaScriptOwnership);
+ {
+ QJSValue wrapper = engine.newQObject(aim.data());
+ }
+
+ QScopedPointer<QObject> repeater(component.create());
+ QVERIFY(!repeater.isNull());
+
+ QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.data()));
+
+ repeater->setProperty("model", QVariant::fromValue<QObject*>(aim.data()));
+
+ QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(aim.data()));
+
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
+
+ QVERIFY(modelGuard);
+
+ QScopedPointer<QQmlComponent> delegate(new QQmlComponent(&engine));
+ delegate->setData(QByteArrayLiteral("import QtQuick 2.0\nItem{}"), dataDirectoryUrl().resolved(QUrl("inline.qml")));
+ QPointer<QQmlComponent> delegateGuard(delegate.data());
+ QQmlEngine::setObjectOwnership(delegate.data(), QQmlEngine::JavaScriptOwnership);
+ {
+ QJSValue wrapper = engine.newQObject(delegate.data());
+ }
+
+ QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.data()));
+
+ repeater->setProperty("delegate", QVariant::fromValue<QObject*>(delegate.data()));
+
+ QVERIFY(!QQmlData::keepAliveDuringGarbageCollection(delegate.data()));
+
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
+
+ QVERIFY(delegateGuard);
+
+ repeater->setProperty("model", QVariant());
+ repeater->setProperty("delegate", QVariant());
+
+ QVERIFY(delegateGuard);
+ QVERIFY(modelGuard);
+
+ delegate.take();
+ aim.take();
+
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
+
+ QVERIFY(!delegateGuard);
+ QVERIFY(!modelGuard);
+}
+
QTEST_MAIN(tst_QQuickRepeater)
#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/quick/qquickshape/qquickshape.pro b/tests/auto/quick/qquickshape/qquickshape.pro
index 29c3502b86..a0e5c002e0 100644
--- a/tests/auto/quick/qquickshape/qquickshape.pro
+++ b/tests/auto/quick/qquickshape/qquickshape.pro
@@ -9,27 +9,5 @@ include (../shared/util.pri)
TESTDATA = data/*
-HEADERS += \
- ../../../../src/imports/shapes/qquickshape_p.h \
- ../../../../src/imports/shapes/qquickshape_p_p.h \
- ../../../../src/imports/shapes/qquickshapegenericrenderer_p.h \
- ../../../../src/imports/shapes/qquickshapesoftwarerenderer_p.h
-
-SOURCES += \
- ../../../../src/imports/shapes/qquickshape.cpp \
- ../../../../src/imports/shapes/qquickshapegenericrenderer.cpp \
- ../../../../src/imports/shapes/qquickshapesoftwarerenderer.cpp
-
-qtConfig(opengl) {
- HEADERS += \
- ../../../../src/imports/shapes/qquicknvprfunctions_p.h \
- ../../../../src/imports/shapes/qquicknvprfunctions_p_p.h \
- ../../../../src/imports/shapes/qquickshapenvprrenderer_p.h
-
- SOURCES += \
- ../../../../src/imports/shapes/qquicknvprfunctions.cpp \
- ../../../../src/imports/shapes/qquickshapenvprrenderer.cpp
-}
-
-QT += core-private gui-private qml-private quick-private testlib
+QT += core-private gui-private qml-private quick-private testlib quickshapes-private
qtHaveModule(widgets): QT += widgets
diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp
index 2a349d2013..3206129e72 100644
--- a/tests/auto/quick/qquickshape/tst_qquickshape.cpp
+++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp
@@ -33,7 +33,7 @@
#include <QtQml/qqmlcontext.h>
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlincubator.h>
-#include "../../../../src/imports/shapes/qquickshape_p.h"
+#include <QtQuickShapes/private/qquickshape_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
@@ -82,7 +82,7 @@ void tst_QQuickShape::initValues()
QVERIFY(obj != nullptr);
QVERIFY(obj->rendererType() == QQuickShape::UnknownRenderer);
QVERIFY(!obj->asynchronous());
- QVERIFY(obj->vendorExtensionsEnabled());
+ QVERIFY(!obj->vendorExtensionsEnabled());
QVERIFY(obj->status() == QQuickShape::Null);
auto vps = obj->data();
QVERIFY(vps.count(&vps) == 0);
@@ -99,7 +99,7 @@ void tst_QQuickShape::vpInitValues()
QVERIFY(obj != nullptr);
QVERIFY(obj->rendererType() == QQuickShape::UnknownRenderer);
QVERIFY(!obj->asynchronous());
- QVERIFY(obj->vendorExtensionsEnabled());
+ QVERIFY(!obj->vendorExtensionsEnabled());
QVERIFY(obj->status() == QQuickShape::Null);
auto vps = obj->data();
QVERIFY(vps.count(&vps) == 2);
diff --git a/tests/auto/quick/qquicktableview/data/alternatingrowheightcolumnwidth.qml b/tests/auto/quick/qquicktableview/data/alternatingrowheightcolumnwidth.qml
new file mode 100644
index 0000000000..e6cf9bf2a4
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/alternatingrowheightcolumnwidth.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Component delegate: tableViewDelegate
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: column % 2 ? 40 : 30
+ implicitHeight: row % 2 ? 40 : 20
+ color: "lightgray"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/asyncloader.qml b/tests/auto/quick/qquicktableview/data/asyncloader.qml
new file mode 100644
index 0000000000..ba99430416
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/asyncloader.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Item {
+ width: 640
+ height: 450
+
+ property alias loader: loader
+ property TableView tableView: loader.item ? loader.item.tableView : null
+ property string loaderSource: ""
+
+ Loader {
+ id: loader
+ anchors.fill: parent
+ source: Qt.resolvedUrl(loaderSource)
+ asynchronous: true
+ }
+}
diff --git a/tests/auto/quick/qquicktableview/data/asyncplain.qml b/tests/auto/quick/qquicktableview/data/asyncplain.qml
new file mode 100644
index 0000000000..df09d3e276
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/asyncplain.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import TestModel 0.1
+
+Item {
+ id: root
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Loader loader: parent
+
+ property int statusWhenDelegate0_0Created: Loader.Null
+ property int statusWhenDelegate5_5Created: Loader.Null
+
+ property real tableViewWidthWhileBuilding: -1
+ property real tableViewHeightWhileBuilding: -1
+
+ TableView {
+ id: tableView
+ anchors.fill: parent
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ model: TestModel {
+ rowCount: 100
+ columnCount: 100
+ }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
+ color: "lightgray"
+ border.width: 1
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+
+ Component.onCompleted: {
+ if (row === 0 && column === 0) {
+ statusWhenDelegate0_0Created = loader.status
+ tableViewWidthWhileBuilding = tableView.width
+ tableViewHeightWhileBuilding = tableView.height
+ }
+ else if (row === 5 && column === 5)
+ statusWhenDelegate5_5Created = loader.status
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/changemodelfromdelegate.qml b/tests/auto/quick/qquicktableview/data/changemodelfromdelegate.qml
new file mode 100644
index 0000000000..79a8e4351a
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/changemodelfromdelegate.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import TestModel 0.1
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property bool addRowFromDelegate: false
+
+ onAddRowFromDelegateChanged: {
+ if (!addRowFromDelegate)
+ return;
+ tableModel.addRow(0);
+ tableView.forceLayout();
+ }
+
+ TestModel {
+ id: tableModel
+ rowCount: 1
+ columnCount: 4
+ }
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ clip: true
+ model: tableModel
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: 100
+ implicitHeight: 100
+ color: "lightgray"
+ border.width: 1
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+
+ Component.onCompleted: {
+ if (!addRowFromDelegate)
+ return;
+ addRowFromDelegate = false;
+ tableModel.addRow(0);
+ }
+ }
+ }
+
+}
+
diff --git a/tests/auto/quick/qquicktableview/data/changemodelordelegateduringupdate.qml b/tests/auto/quick/qquicktableview/data/changemodelordelegateduringupdate.qml
new file mode 100644
index 0000000000..de404be63d
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/changemodelordelegateduringupdate.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property bool changeDelegate: false
+ property bool changeModel: false
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ clip: true
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 100
+ color: "lightgray"
+ border.width: 1
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+
+ Component.onCompleted: {
+ if (changeDelegate)
+ TableView.view.delegate = null
+ if (changeModel)
+ TableView.view.model = null
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/checkrowandcolumnnotchanged.qml b/tests/auto/quick/qquicktableview/data/checkrowandcolumnnotchanged.qml
new file mode 100644
index 0000000000..bef0df2501
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/checkrowandcolumnnotchanged.qml
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import Qt.labs.qmlmodels 1.0
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ delegate: DelegateChooser {
+ DelegateChoice {
+ row: 0
+ column: 0
+ delegate: maskDelegate
+ }
+ DelegateChoice {
+ row: 1
+ column: 1
+ delegate: maskDelegate
+ }
+ DelegateChoice {
+ delegate: tableViewDelegate
+ }
+ }
+ }
+
+ Component {
+ // Add this mask delegate, to force QQmlTableInstanceModel to
+ // reuse the precise cells that we want to swap in the test
+ id: maskDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
+ color: "green"
+ }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
+ Text {
+ anchors.fill: parent
+ text: column + "," + row
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/contentwidthheight.qml b/tests/auto/quick/qquicktableview/data/contentwidthheight.qml
new file mode 100644
index 0000000000..6b15e8dd21
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/contentwidthheight.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Component delegate: tableViewDelegate
+
+ TableView {
+ id: tableView
+ width: 500
+ height: 500
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ leftMargin: 10
+ rightMargin: 10
+ topMargin: 10
+ bottomMargin: 10
+ columnWidthProvider: function(column) { return column < 20 ? 100 : 200 }
+ rowHeightProvider: function(row) { return row < 20 ? 100 : 200 }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ color: "lightgray"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: column
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/countingtableview.qml b/tests/auto/quick/qquicktableview/data/countingtableview.qml
new file mode 100644
index 0000000000..ecd4ca3cc7
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/countingtableview.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ id: root
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ // currentDelegateCount is the number of currently visible items
+ property int currentDelegateCount: 0
+ // maxDelegateCount is the largest number of items that has ever been visible at the same time
+ property int maxDelegateCount: 0
+ // delegatesCreatedCount is the number of items created during the lifetime of the test
+ property int delegatesCreatedCount: 0
+
+ property real delegateWidth: 100
+ property real delegateHeight: 50
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: delegateWidth
+ implicitHeight: delegateHeight
+ color: "lightgray"
+ border.width: 1
+
+ property int pooledCount: 0
+ property int reusedCount: 0
+ TableView.onPooled: pooledCount++;
+ TableView.onReused: reusedCount++;
+
+ Text {
+ anchors.centerIn: parent
+ text: column
+ }
+ Component.onCompleted: {
+ delegatesCreatedCount++;
+ currentDelegateCount++;
+ maxDelegateCount = Math.max(maxDelegateCount, currentDelegateCount);
+ }
+ Component.onDestruction: {
+ currentDelegateCount--;
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/delegatewithanchors.qml b/tests/auto/quick/qquicktableview/data/delegatewithanchors.qml
new file mode 100644
index 0000000000..0b549f09a4
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/delegatewithanchors.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ anchors.fill: parent
+ implicitWidth: 100
+ implicitHeight: 100
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/forcelayout.qml b/tests/auto/quick/qquicktableview/data/forcelayout.qml
new file mode 100644
index 0000000000..f03dc2f25b
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/forcelayout.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property real columnWidths: 80
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+
+ columnWidthProvider: function(c) { return columnWidths; }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ color: "lightgray"
+ border.width: 1
+ implicitHeight: 100
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/plaintableview.qml b/tests/auto/quick/qquicktableview/data/plaintableview.qml
new file mode 100644
index 0000000000..90271eda71
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/plaintableview.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property real delegateWidth: 100
+ property real delegateHeight: 50
+ property Component delegate: tableViewDelegate
+ property bool delegateParentSetBeforeCompleted: false
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: delegateWidth
+ implicitHeight: delegateHeight
+ color: "lightgray"
+ border.width: 1
+
+ property string modelDataBinding: modelData
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+
+ Component.onCompleted: {
+ delegateParentSetBeforeCompleted = parent != null;
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml b/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
new file mode 100644
index 0000000000..38fca2c5cb
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/qqmllistpropertymodel.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ id: root
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ }
+
+ Item {
+ Repeater {
+ model: 100
+ Item { property string someCustomProperty: index }
+ }
+ Component.onCompleted: tableView.model = children
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: 100
+ implicitHeight: 50
+ color: "lightgray"
+ border.width: 1
+
+ Text {
+ anchors.centerIn: parent
+ text: column
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/setcontentpos.qml b/tests/auto/quick/qquicktableview/data/setcontentpos.qml
new file mode 100644
index 0000000000..fa040d3959
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/setcontentpos.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 400
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ contentX: (contentWidth - width) / 2;
+ contentY: (contentHeight - height) / 2;
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ implicitWidth: 100
+ implicitHeight: 100
+ color: "lightgray"
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/tableviewdefaultspacing.qml b/tests/auto/quick/qquicktableview/data/tableviewdefaultspacing.qml
new file mode 100644
index 0000000000..f4a3094dd2
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/tableviewdefaultspacing.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ color: "lightgray"
+ border.width: 1
+ implicitWidth: 15
+ implicitHeight: 10
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/tableviewfocus.qml b/tests/auto/quick/qquicktableview/data/tableviewfocus.qml
new file mode 100644
index 0000000000..c388e2c8de
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/tableviewfocus.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ clip: true
+ delegate: tableViewDelegate
+ }
+
+ Component {
+ id: tableViewDelegate
+ Item {
+ id: delegate
+ implicitWidth: 100
+ implicitHeight: 50
+ focus: true
+
+ property alias delegateRoot: delegate
+ property alias delegateChild: textInput
+
+ TextInput {
+ id: textInput
+ width: parent.width
+ height: parent.height
+ text: "TextInput"
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/tableviewimplicitsize.qml b/tests/auto/quick/qquicktableview/data/tableviewimplicitsize.qml
new file mode 100644
index 0000000000..425b950fce
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/tableviewimplicitsize.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ color: "lightgray"
+ border.width: 1
+ implicitWidth: 90
+ implicitHeight: 60
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/usechooserwithoutdefault.qml b/tests/auto/quick/qquicktableview/data/usechooserwithoutdefault.qml
new file mode 100644
index 0000000000..847500d71f
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/usechooserwithoutdefault.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import Qt.labs.qmlmodels 1.0
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ delegate: DelegateChooser {
+ DelegateChoice {
+ row: 0
+ delegate: Item {
+ implicitWidth: 100
+ implicitHeight: 100
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml b/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml
new file mode 100644
index 0000000000..32d1fc9d0d
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Component delegate: tableViewDelegate
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ columnWidthProvider: function(column) { }
+ rowHeightProvider: function(row) { return 0 }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: 20
+ implicitHeight: 20
+ color: "lightgray"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml b/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml
new file mode 100644
index 0000000000..04d12f8d20
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property Component delegate: tableViewDelegate
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ columnWidthProvider: function(column) { return column + 10 }
+ rowHeightProvider: function(row) { return row + 10 }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ implicitWidth: 20
+ implicitHeight: 20
+ color: "lightgray"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: modelData
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/qquicktableview.pro b/tests/auto/quick/qquicktableview/qquicktableview.pro
new file mode 100644
index 0000000000..f4d0265dd3
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/qquicktableview.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquicktableview
+macos:CONFIG -= app_bundle
+
+HEADERS += testmodel.h
+SOURCES += tst_qquicktableview.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+TESTDATA = data/*
+
+QT += core-private gui-private qml-private quick-private testlib
+
diff --git a/tests/auto/quick/qquicktableview/testmodel.h b/tests/auto/quick/qquicktableview/testmodel.h
new file mode 100644
index 0000000000..28ea466b82
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/testmodel.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtCore>
+#include <QtGui/QStandardItemModel>
+
+class TestModel : public QAbstractTableModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
+
+public:
+ TestModel(QObject *parent = nullptr)
+ : QAbstractTableModel(parent)
+ {}
+
+ TestModel(int rows, int columns, QObject *parent = nullptr)
+ : QAbstractTableModel(parent)
+ , m_rows(rows)
+ , m_columns(columns)
+ {}
+
+ int rowCount(const QModelIndex & = QModelIndex()) const override { return m_rows; }
+ void setRowCount(int count) { beginResetModel(); m_rows = count; emit rowCountChanged(); endResetModel(); }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override { return m_columns; }
+ void setColumnCount(int count) { beginResetModel(); m_columns = count; emit columnCountChanged(); endResetModel(); }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ if (!index.isValid() || role != Qt::DisplayRole)
+ return QVariant();
+
+ int serializedIndex = index.row() + (index.column() * m_columns);
+ if (modelData.contains(serializedIndex))
+ return modelData.value(serializedIndex);
+ return QStringLiteral("%1").arg(index.row());
+ }
+
+ QHash<int, QByteArray> roleNames() const override
+ {
+ return { {Qt::DisplayRole, "display"} };
+ }
+
+ Q_INVOKABLE void setModelData(const QPoint &cell, const QSize &span, const QString &prefix)
+ {
+ for (int c = 0; c < span.width(); ++c) {
+ for (int r = 0; r < span.height(); ++r) {
+ const int changedRow = cell.y() + r;
+ const int changedColumn = cell.x() + c;
+ const int serializedIndex = changedRow + (changedColumn * m_rows);
+ const QString string = prefix + QStringLiteral("%1,%2").arg(changedColumn).arg(changedRow);
+ modelData.insert(serializedIndex, string);
+ }
+ }
+
+ const auto topLeftIndex = createIndex(cell.y(), cell.x(), nullptr);
+ const auto bottomRightIndex = createIndex(cell.y() + span.height() - 1, cell.x() + span.width() - 1, nullptr);
+ emit dataChanged(topLeftIndex, bottomRightIndex);
+ }
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override
+ {
+ if (row < 0 || count <= 0)
+ return false;
+
+ beginInsertRows(parent, row, row + count - 1);
+ m_rows += count;
+ endInsertRows();
+ return true;
+ }
+
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override
+ {
+ if (!checkIndex(createIndex(row, 0)) || !checkIndex(createIndex(row + count - 1, 0)))
+ return false;
+
+ beginRemoveRows(parent, row, row + count - 1);
+ m_rows -= count;
+ endRemoveRows();
+ return true;
+ }
+
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override
+ {
+ if (column < 0 || count <= 0)
+ return false;
+
+ beginInsertColumns(parent, column, column + count - 1);
+ m_columns += count;
+ endInsertColumns();
+ return true;
+ }
+
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override
+ {
+ if (!checkIndex(createIndex(0, column)) || !checkIndex(createIndex(0, column + count - 1)))
+ return false;
+
+ beginRemoveColumns(parent, column, column + count - 1);
+ m_columns -= count;
+ endRemoveColumns();
+ return true;
+ }
+
+ void clear() {
+ beginResetModel();
+ m_rows = 0;
+ m_columns = 0;
+ endResetModel();
+ }
+
+ Q_INVOKABLE void addRow(int row)
+ {
+ insertRow(row, QModelIndex());
+ }
+
+signals:
+ void rowCountChanged();
+ void columnCountChanged();
+
+private:
+ int m_rows = 0;
+ int m_columns = 0;
+ QHash<int, QString> modelData;
+};
+
+#define TestModelAsVariant(...) QVariant::fromValue(QSharedPointer<TestModel>(new TestModel(__VA_ARGS__)))
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
new file mode 100644
index 0000000000..60b938d127
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -0,0 +1,1968 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquicktableview_p.h>
+#include <QtQuick/private/qquicktableview_p_p.h>
+#include <QtQuick/private/qquickloader_p.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQml/private/qqmlobjectmodel_p.h>
+#include <QtQml/private/qqmllistmodel_p.h>
+
+#include "testmodel.h"
+
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+static const char* kTableViewPropName = "tableView";
+static const char* kDelegateObjectName = "tableViewDelegate";
+static const char *kDelegatesCreatedCountProp = "delegatesCreatedCount";
+static const char *kModelDataBindingProp = "modelDataBinding";
+
+Q_DECLARE_METATYPE(QMarginsF);
+
+#define DECLARE_TABLEVIEW_VARIABLES \
+ auto tableView = view->rootObject()->property(kTableViewPropName).value<QQuickTableView *>(); \
+ QVERIFY(tableView); \
+ auto tableViewPrivate = QQuickTableViewPrivate::get(tableView); \
+ Q_UNUSED(tableViewPrivate)
+
+#define LOAD_TABLEVIEW(fileName) \
+ view->setSource(testFileUrl(fileName)); \
+ view->show(); \
+ QVERIFY(QTest::qWaitForWindowActive(view)); \
+ DECLARE_TABLEVIEW_VARIABLES
+
+#define LOAD_TABLEVIEW_ASYNC(fileName) \
+ view->setSource(testFileUrl("asyncloader.qml")); \
+ view->show(); \
+ QVERIFY(QTest::qWaitForWindowActive(view)); \
+ auto loader = view->rootObject()->property("loader").value<QQuickLoader *>(); \
+ loader->setSource(QUrl::fromLocalFile("data/" fileName)); \
+ QTRY_VERIFY(loader->item()); \
+ QCOMPARE(loader->status(), QQuickLoader::Status::Ready); \
+ DECLARE_TABLEVIEW_VARIABLES
+
+#define WAIT_UNTIL_POLISHED \
+ QVERIFY(tableViewPrivate->polishScheduled); \
+ QTRY_VERIFY(!tableViewPrivate->polishScheduled)
+
+class tst_QQuickTableView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickTableView();
+
+ QQuickTableViewAttached *getAttachedObject(const QObject *object) const;
+ QPoint getContextRowAndColumn(const QQuickItem *item) const;
+
+private:
+ QQuickView *view = nullptr;
+
+private slots:
+ void initTestCase() override;
+ void cleanupTestCase();
+
+ void setAndGetModel_data();
+ void setAndGetModel();
+ void emptyModel_data();
+ void emptyModel();
+ void checkPreload_data();
+ void checkPreload();
+ void checkZeroSizedDelegate();
+ void checkImplicitSizeDelegate();
+ void checkColumnWidthWithoutProvider();
+ void checkDelegateWithAnchors();
+ void checkColumnWidthProvider();
+ void checkColumnWidthProviderInvalidReturnValues();
+ void checkColumnWidthProviderNotCallable();
+ void checkRowHeightWithoutProvider();
+ void checkRowHeightProvider();
+ void checkRowHeightProviderInvalidReturnValues();
+ void checkRowHeightProviderNotCallable();
+ void checkForceLayoutFunction();
+ void checkContentWidthAndHeight();
+ void checkPageFlicking();
+ void checkExplicitContentWidthAndHeight();
+ void checkContentXY();
+ void noDelegate();
+ void changeDelegateDuringUpdate();
+ void changeModelDuringUpdate();
+ void countDelegateItems_data();
+ void countDelegateItems();
+ void checkLayoutOfEqualSizedDelegateItems_data();
+ void checkLayoutOfEqualSizedDelegateItems();
+ void checkFocusRemoved_data();
+ void checkFocusRemoved();
+ void fillTableViewButNothingMore_data();
+ void fillTableViewButNothingMore();
+ void checkInitialAttachedProperties_data();
+ void checkInitialAttachedProperties();
+ void checkSpacingValues();
+ void checkDelegateParent();
+ void flick_data();
+ void flick();
+ void flickOvershoot_data();
+ void flickOvershoot();
+ void checkRowColumnCount();
+ void modelSignals();
+ void dataChangedSignal();
+ void checkThatPoolIsDrainedWhenReuseIsFalse();
+ void checkIfDelegatesAreReused_data();
+ void checkIfDelegatesAreReused();
+ void checkIfDelegatesAreReusedAsymmetricTableSize();
+ void checkContextProperties_data();
+ void checkContextProperties();
+ void checkContextPropertiesQQmlListProperyModel_data();
+ void checkContextPropertiesQQmlListProperyModel();
+ void checkRowAndColumnChangedButNotIndex();
+ void checkChangingModelFromDelegate();
+ void checkRebuildViewportOnly();
+ void useDelegateChooserWithoutDefault();
+ void checkTableviewInsideAsyncLoader();
+};
+
+tst_QQuickTableView::tst_QQuickTableView()
+{
+}
+
+void tst_QQuickTableView::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestModel>("TestModel", 0, 1, "TestModel");
+ view = createView();
+}
+
+void tst_QQuickTableView::cleanupTestCase()
+{
+ delete view;
+}
+
+QQuickTableViewAttached *tst_QQuickTableView::getAttachedObject(const QObject *object) const
+{
+ QObject *attachedObject = qmlAttachedPropertiesObject<QQuickTableView>(object);
+ return static_cast<QQuickTableViewAttached *>(attachedObject);
+}
+
+QPoint tst_QQuickTableView::getContextRowAndColumn(const QQuickItem *item) const
+{
+ const auto context = qmlContext(item);
+ const int row = context->contextProperty("row").toInt();
+ const int column = context->contextProperty("column").toInt();
+ return QPoint(column, row);
+}
+
+void tst_QQuickTableView::setAndGetModel_data()
+{
+ QTest::addColumn<QVariant>("model");
+
+ QTest::newRow("QAIM 1x1") << TestModelAsVariant(1, 1);
+ QTest::newRow("Number model 1") << QVariant::fromValue(1);
+ QTest::newRow("QStringList 1") << QVariant::fromValue(QStringList() << "one");
+}
+
+void tst_QQuickTableView::setAndGetModel()
+{
+ // Test that we can set and get different kind of models
+ QFETCH(QVariant, model);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ tableView->setModel(model);
+ QCOMPARE(model, tableView->model());
+}
+
+void tst_QQuickTableView::emptyModel_data()
+{
+ QTest::addColumn<QVariant>("model");
+
+ QTest::newRow("QAIM") << TestModelAsVariant(0, 0);
+ QTest::newRow("Number model") << QVariant::fromValue(0);
+ QTest::newRow("QStringList") << QVariant::fromValue(QStringList());
+}
+
+void tst_QQuickTableView::emptyModel()
+{
+ // Check that if we assign an empty model to
+ // TableView, no delegate items will be created.
+ QFETCH(QVariant, model);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableViewPrivate->loadedItems.count(), 0);
+}
+
+void tst_QQuickTableView::checkPreload_data()
+{
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("reuse") << true;
+ QTest::newRow("not reuse") << false;
+}
+
+void tst_QQuickTableView::checkPreload()
+{
+ // Check that the reuse pool is filled up with one extra row and
+ // column (pluss corner) after rebuilding the table, but only if we reuse items.
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+ tableView->setReuseItems(reuseItems);
+
+ WAIT_UNTIL_POLISHED;
+
+ if (reuseItems) {
+ QSize visibleTableSize = tableViewPrivate->loadedTable.size();
+ int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
+ } else {
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+ }
+}
+
+void tst_QQuickTableView::checkZeroSizedDelegate()
+{
+ // Check that if we assign a delegate with empty width and height, we
+ // fall back to use kDefaultColumnWidth and kDefaultRowHeight as
+ // column/row sizes.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ view->rootObject()->setProperty("delegateWidth", 0);
+ view->rootObject()->setProperty("delegateHeight", 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*implicit"));
+
+ WAIT_UNTIL_POLISHED;
+
+ auto items = tableViewPrivate->loadedItems;
+ QVERIFY(!items.isEmpty());
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ auto item = fxItem->item;
+ QCOMPARE(item->width(), kDefaultColumnWidth);
+ QCOMPARE(item->height(), kDefaultRowHeight);
+ }
+}
+
+void tst_QQuickTableView::checkImplicitSizeDelegate()
+{
+ // Check that we can set the size of delegate items using
+ // implicit width/height, instead of forcing the user to
+ // create an attached object by using implicitWidth/Height.
+ LOAD_TABLEVIEW("tableviewimplicitsize.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ auto items = tableViewPrivate->loadedItems;
+ QVERIFY(!items.isEmpty());
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ auto item = fxItem->item;
+ QCOMPARE(item->width(), 90);
+ QCOMPARE(item->height(), 60);
+ }
+}
+
+void tst_QQuickTableView::checkColumnWidthWithoutProvider()
+{
+ // Checks that a function isn't assigned to the columnWidthProvider property
+ // and that the column width is then equal to sizeHintForColumn.
+ LOAD_TABLEVIEW("alternatingrowheightcolumnwidth.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+ QVERIFY(tableView->columnWidthProvider().isUndefined());
+
+ WAIT_UNTIL_POLISHED;
+
+ QRect table = tableViewPrivate->loadedTable;
+ for (int column = table.left(); column <= table.right(); ++column) {
+ const qreal expectedColumnWidth = tableViewPrivate->sizeHintForColumn(column);
+ for (int row = table.top(); row <= table.bottom(); ++row) {
+ const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item;
+ QCOMPARE(item->width(), expectedColumnWidth);
+ }
+ }
+}
+
+void tst_QQuickTableView::checkDelegateWithAnchors()
+{
+ // Checks that we issue a warning if the delegate has anchors
+ LOAD_TABLEVIEW("delegatewithanchors.qml");
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*anchors"));
+
+ auto model = TestModelAsVariant(1, 1);
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+}
+
+void tst_QQuickTableView::checkColumnWidthProvider()
+{
+ // Check that you can assign a function to the columnWidthProvider property, and
+ // that it's used to control (and override) the width of the columns.
+ LOAD_TABLEVIEW("userowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+ QVERIFY(tableView->columnWidthProvider().isCallable());
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ // expectedWidth mirrors the expected return value of the assigned javascript function
+ qreal expectedWidth = fxItem->cell.x() + 10;
+ QCOMPARE(fxItem->item->width(), expectedWidth);
+ }
+}
+
+void tst_QQuickTableView::checkColumnWidthProviderInvalidReturnValues()
+{
+ // Check that we fall back to use default columns widths, if you
+ // assign a function to columnWidthProvider that returns invalid values.
+ LOAD_TABLEVIEW("usefaultyrowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Provider.*valid"));
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), kDefaultColumnWidth);
+}
+
+void tst_QQuickTableView::checkColumnWidthProviderNotCallable()
+{
+ // Check that we fall back to use default columns widths, if you
+ // assign something to columnWidthProvider that is not callable.
+ LOAD_TABLEVIEW("usefaultyrowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+ tableView->setRowHeightProvider(QJSValue());
+ tableView->setColumnWidthProvider(QJSValue(10));
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".Provider.*function"));
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), kDefaultColumnWidth);
+}
+
+void tst_QQuickTableView::checkRowHeightWithoutProvider()
+{
+ // Checks that a function isn't assigned to the rowHeightProvider property
+ // and that the row height is then equal to sizeHintForRow.
+ LOAD_TABLEVIEW("alternatingrowheightcolumnwidth.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+ QVERIFY(tableView->rowHeightProvider().isUndefined());
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ QRect table = tableViewPrivate->loadedTable;
+ for (int row = table.top(); row <= table.bottom(); ++row) {
+ const qreal expectedRowHeight = tableViewPrivate->sizeHintForRow(row);
+ for (int column = table.left(); column <= table.right(); ++column) {
+ const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item;
+ QCOMPARE(item->height(), expectedRowHeight);
+ }
+ }
+}
+
+void tst_QQuickTableView::checkRowHeightProvider()
+{
+ // Check that you can assign a function to the columnWidthProvider property, and
+ // that it's used to control (and override) the width of the columns.
+ LOAD_TABLEVIEW("userowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+ QVERIFY(tableView->rowHeightProvider().isCallable());
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ // expectedWidth mirrors the expected return value of the assigned javascript function
+ qreal expectedHeight = fxItem->cell.y() + 10;
+ QCOMPARE(fxItem->item->height(), expectedHeight);
+ }
+}
+
+void tst_QQuickTableView::checkRowHeightProviderInvalidReturnValues()
+{
+ // Check that we fall back to use default row heights, if you
+ // assign a function to rowHeightProvider that returns invalid values.
+ LOAD_TABLEVIEW("usefaultyrowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Provider.*valid"));
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->height(), kDefaultRowHeight);
+}
+
+void tst_QQuickTableView::checkRowHeightProviderNotCallable()
+{
+ // Check that we fall back to use default row heights, if you
+ // assign something to rowHeightProvider that is not callable.
+ LOAD_TABLEVIEW("usefaultyrowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+
+ tableView->setColumnWidthProvider(QJSValue());
+ tableView->setRowHeightProvider(QJSValue(10));
+
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Provider.*function"));
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->height(), kDefaultRowHeight);
+}
+
+void tst_QQuickTableView::checkForceLayoutFunction()
+{
+ // When we set the 'columnWidths' property in the test file, the
+ // columnWidthProvider should return other values than it did during
+ // start-up. Check that this takes effect after a call to the 'forceLayout()' function.
+ LOAD_TABLEVIEW("forcelayout.qml");
+
+ const char *propertyName = "columnWidths";
+ auto model = TestModelAsVariant(10, 10);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Check that the initial column widths are as specified in the QML file
+ const qreal initialColumnWidth = view->rootObject()->property(propertyName).toReal();
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), initialColumnWidth);
+
+ // Change the return value from the columnWidthProvider to something else
+ const qreal newColumnWidth = 100;
+ view->rootObject()->setProperty(propertyName, newColumnWidth);
+ tableView->forceLayout();
+ // We don't have to polish; The re-layout happens immediately
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), newColumnWidth);
+}
+
+void tst_QQuickTableView::checkContentWidthAndHeight()
+{
+ // Check that contentWidth/Height reports the correct size of the the
+ // table, based on knowledge of the rows and columns that has been loaded.
+ LOAD_TABLEVIEW("contentwidthheight.qml");
+
+ // Vertical and horizontal properties should be mirrored, so we only have
+ // to do the calculations once, and use them for both axis, below.
+ QCOMPARE(tableView->width(), tableView->height());
+ QCOMPARE(tableView->rowSpacing(), tableView->columnSpacing());
+
+ const int tableSize = 100;
+ const int cellSizeSmall = 100;
+ const int cellSizeLarge = 200;
+ const int spacing = 1;
+ const int smallCellCount = 20;
+ const int largeCellCount = tableSize - smallCellCount;
+ const qreal accumulatedSpacing = ((tableSize - 1) * spacing);
+ auto model = TestModelAsVariant(tableSize, tableSize);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ const qreal expectedSizeInit = (tableSize * cellSizeSmall) + ((tableSize - 1) * spacing);
+ QCOMPARE(tableView->contentWidth(), expectedSizeInit);
+ QCOMPARE(tableView->contentHeight(), expectedSizeInit);
+
+ // Flick in 5 more rows and columns, but not so far that we start loading in
+ // the ones that are bigger. Loading in more rows and columns of the same
+ // size as the initial ones should not change the first prediction.
+ qreal flickTo = ((cellSizeSmall + spacing) * 5);
+ tableView->setContentX(flickTo);
+ tableView->setContentY(flickTo);
+
+ QCOMPARE(tableView->contentWidth(), expectedSizeInit);
+ QCOMPARE(tableView->contentHeight(), expectedSizeInit);
+
+ // Flick to row and column 20 (smallCellCount), since there the row and
+ // column sizes increases with 100. Check that TableView then adjusts
+ // contentWidth and contentHeight accordingly.
+ flickTo = ((cellSizeSmall + spacing) * smallCellCount) - spacing;
+ tableView->setContentX(flickTo);
+ tableView->setContentY(flickTo);
+
+ // Since we move the viewport more than a page, tableview
+ // will jump to the new position and do a rebuild.
+ QVERIFY(tableViewPrivate->polishScheduled);
+ QVERIFY(tableViewPrivate->rebuildScheduled);
+ WAIT_UNTIL_POLISHED;
+
+ const int largeSizeCellCountInView = qCeil(tableView->width() / cellSizeLarge);
+ const int columnCount = smallCellCount + largeSizeCellCountInView;
+ QCOMPARE(tableViewPrivate->loadedTable.left(), smallCellCount);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+
+ const qreal firstHalfLength = smallCellCount * cellSizeSmall;
+ const qreal secondHalfOneScreenLength = largeSizeCellCountInView * cellSizeLarge;
+ const qreal lengthAfterFlick = firstHalfLength + secondHalfOneScreenLength;
+
+ const qreal averageCellSize = lengthAfterFlick / columnCount;
+ const qreal expectedSizeHalf = (tableSize * averageCellSize) + accumulatedSpacing;
+
+ QCOMPARE(tableView->contentWidth(), expectedSizeHalf);
+ QCOMPARE(tableView->contentHeight(), expectedSizeHalf);
+
+ // Flick to the end (row/column 100, and overshoot a bit), and
+ // check that we then end up with the exact content width/height.
+ const qreal secondHalfLength = largeCellCount * cellSizeLarge;
+ const qreal expectedFullSize = (firstHalfLength + secondHalfLength) + accumulatedSpacing;
+
+ // If we flick more than one page at a time, tableview will jump to the new
+ // position and rebuild the table without loading the edges in-between. Which
+ // row and column that ends up as new top-left is then based on a prediction, and
+ // therefore unreliable. To avoid this to happen (which will also affect the
+ // reported size of the table), we flick to the end position in smaller chuncks.
+ QVERIFY(!tableViewPrivate->polishScheduled);
+ QVERIFY(!tableViewPrivate->rebuildScheduled);
+ int pages = qCeil((expectedFullSize - tableView->contentX()) / tableView->width());
+ for (int i = 0; i < pages; i++) {
+ tableView->setContentX(tableView->contentX() + tableView->width() - 1);
+ tableView->setContentY(tableView->contentY() + tableView->height() - 1);
+ QVERIFY(!tableViewPrivate->rebuildScheduled);
+ }
+
+ QCOMPARE(tableView->contentWidth(), expectedFullSize);
+ QCOMPARE(tableView->contentHeight(), expectedFullSize);
+
+ // Flick back to start. Since we know the actual table
+ // size, contentWidth/Height shouldn't change.
+ tableView->setContentX(0);
+ tableView->setContentY(0);
+
+ QCOMPARE(tableView->contentWidth(), expectedFullSize);
+ QCOMPARE(tableView->contentHeight(), expectedFullSize);
+}
+
+void tst_QQuickTableView::checkPageFlicking()
+{
+ // Check that we rebuild the table instead of refilling edges, if the viewport moves
+ // more than a page (the size of TableView).
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int cellWidth = 100;
+ const int cellHeight = 50;
+ auto model = TestModelAsVariant(10000, 10000);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Sanity check startup table
+ QRect tableRect = tableViewPrivate->loadedTable;
+ QCOMPARE(tableRect.x(), 0);
+ QCOMPARE(tableRect.y(), 0);
+ QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
+ QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+
+ // Since all cells have the same size, the average row/column
+ // size found by TableView should be exactly equal to this.
+ QCOMPARE(tableViewPrivate->averageEdgeSize.width(), cellWidth);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.height(), cellHeight);
+
+ QVERIFY(!tableViewPrivate->rebuildScheduled);
+ QCOMPARE(tableViewPrivate->scheduledRebuildOptions, QQuickTableViewPrivate::RebuildOption::None);
+
+ // Flick 5000 columns to the right, and check that this triggers a
+ // rebuild, and that we end up at the expected top-left.
+ const int flickToColumn = 5000;
+ const qreal columnSpacing = tableView->columnSpacing();
+ const qreal flickToColumnInPixels = ((cellWidth + columnSpacing) * flickToColumn) - columnSpacing;
+ tableView->setContentX(flickToColumnInPixels);
+
+ QVERIFY(tableViewPrivate->rebuildScheduled);
+ QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::ViewportOnly);
+ QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftColumn);
+ QVERIFY(!(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow));
+
+ WAIT_UNTIL_POLISHED;
+
+ tableRect = tableViewPrivate->loadedTable;
+ QCOMPARE(tableRect.x(), flickToColumn);
+ QCOMPARE(tableRect.y(), 0);
+ QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
+ QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+
+ // Flick 5000 rows down as well. Since flicking down should only calculate a new row (but
+ // keep the current column), we deliberatly change the average width to check that it's
+ // actually ignored by the rebuild, and that the column stays the same.
+ tableViewPrivate->averageEdgeSize.rwidth() /= 2;
+
+ const int flickToRow = 5000;
+ const qreal rowSpacing = tableView->rowSpacing();
+ const qreal flickToRowInPixels = ((cellHeight + rowSpacing) * flickToRow) - rowSpacing;
+ tableView->setContentY(flickToRowInPixels);
+
+ QVERIFY(tableViewPrivate->rebuildScheduled);
+ QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::ViewportOnly);
+ QVERIFY(!(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftColumn));
+ QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow);
+
+ WAIT_UNTIL_POLISHED;
+
+ tableRect = tableViewPrivate->loadedTable;
+ QCOMPARE(tableRect.x(), flickToRow);
+ QCOMPARE(tableRect.y(), flickToColumn);
+ QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
+ QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+}
+
+void tst_QQuickTableView::checkExplicitContentWidthAndHeight()
+{
+ // Check that you can set a custom contentWidth/Height, and that
+ // TableView doesn't override it while loading more rows and columns.
+ LOAD_TABLEVIEW("contentwidthheight.qml");
+
+ tableView->setContentWidth(1000);
+ tableView->setContentHeight(1000);
+ QCOMPARE(tableView->contentWidth(), 1000);
+ QCOMPARE(tableView->contentHeight(), 1000);
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+
+ // Flick somewhere. It should not affect the contentWidth/Height
+ tableView->setContentX(500);
+ tableView->setContentY(500);
+ QCOMPARE(tableView->contentWidth(), 1000);
+ QCOMPARE(tableView->contentHeight(), 1000);
+}
+
+void tst_QQuickTableView::checkContentXY()
+{
+ // Check that you can bind contentX and contentY to
+ // e.g show the center of the table at start-up
+ LOAD_TABLEVIEW("setcontentpos.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableView->width(), 400);
+ QCOMPARE(tableView->height(), 400);
+ QCOMPARE(tableView->contentWidth(), 1000);
+ QCOMPARE(tableView->contentHeight(), 1000);
+
+ // Check that the content item is positioned according
+ // to the binding in the QML file (which will set the
+ // viewport to be at the center of the table).
+ const qreal expectedXY = (tableView->contentWidth() - tableView->width()) / 2;
+ QCOMPARE(tableView->contentX(), expectedXY);
+ QCOMPARE(tableView->contentY(), expectedXY);
+
+ // Check that we end up at the correct top-left cell:
+ const qreal delegateWidth = tableViewPrivate->loadedItems.values().first()->item->width();
+ const int expectedCellXY = qCeil(expectedXY / delegateWidth);
+ QCOMPARE(tableViewPrivate->loadedTable.left(), expectedCellXY);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), expectedCellXY);
+}
+
+void tst_QQuickTableView::noDelegate()
+{
+ // Check that you can skip setting a delegate without
+ // it causing any problems (like crashing or asserting).
+ // And then set a delegate, and do a quick check that the
+ // view gets populated as expected.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int rows = 5;
+ const int columns = 5;
+ auto model = TestModelAsVariant(columns, rows);
+ tableView->setModel(model);
+
+ // Start with no delegate, and check
+ // that we end up with no items in the table.
+ tableView->setDelegate(nullptr);
+
+ WAIT_UNTIL_POLISHED;
+
+ auto items = tableViewPrivate->loadedItems;
+ QVERIFY(items.isEmpty());
+
+ // Set a delegate, and check that we end
+ // up with the expected number of items.
+ auto delegate = view->rootObject()->property("delegate").value<QQmlComponent *>();
+ QVERIFY(delegate);
+ tableView->setDelegate(delegate);
+
+ WAIT_UNTIL_POLISHED;
+
+ items = tableViewPrivate->loadedItems;
+ QCOMPARE(items.count(), rows * columns);
+
+ // And then unset the delegate again, and check
+ // that we end up with no items.
+ tableView->setDelegate(nullptr);
+
+ WAIT_UNTIL_POLISHED;
+
+ items = tableViewPrivate->loadedItems;
+ QVERIFY(items.isEmpty());
+}
+
+void tst_QQuickTableView::changeDelegateDuringUpdate()
+{
+ // Check that you can change the delegate (set it to null)
+ // while the TableView is busy loading the table.
+ LOAD_TABLEVIEW("changemodelordelegateduringupdate.qml");
+
+ auto model = TestModelAsVariant(1, 1);
+ tableView->setModel(model);
+ view->rootObject()->setProperty("changeDelegate", true);
+
+ WAIT_UNTIL_POLISHED;
+
+ // We should no longer have a delegate, and no
+ // items should therefore be loaded.
+ QCOMPARE(tableView->delegate(), nullptr);
+ QCOMPARE(tableViewPrivate->loadedItems.size(), 0);
+
+ // Even if the delegate is missing, we still report
+ // the correct size of the model
+ QCOMPARE(tableView->rows(), 1);
+ QCOMPARE(tableView->columns(), 1);
+};
+
+void tst_QQuickTableView::changeModelDuringUpdate()
+{
+ // Check that you can change the model (set it to null)
+ // while the TableView is buzy loading the table.
+ LOAD_TABLEVIEW("changemodelordelegateduringupdate.qml");
+
+ auto model = TestModelAsVariant(1, 1);
+ tableView->setModel(model);
+ view->rootObject()->setProperty("changeModel", true);
+
+ WAIT_UNTIL_POLISHED;
+
+ // We should no longer have a model, and the no
+ // items should therefore be loaded.
+ QVERIFY(tableView->model().isNull());
+ QCOMPARE(tableViewPrivate->loadedItems.size(), 0);
+
+ // The empty model has no rows or columns
+ QCOMPARE(tableView->rows(), 0);
+ QCOMPARE(tableView->columns(), 0);
+};
+
+void tst_QQuickTableView::countDelegateItems_data()
+{
+ QTest::addColumn<QVariant>("model");
+ QTest::addColumn<int>("count");
+
+ QTest::newRow("QAIM 1x1") << TestModelAsVariant(1, 1) << 1;
+ QTest::newRow("QAIM 2x1") << TestModelAsVariant(2, 1) << 2;
+ QTest::newRow("QAIM 1x2") << TestModelAsVariant(1, 2) << 2;
+ QTest::newRow("QAIM 2x2") << TestModelAsVariant(2, 2) << 4;
+ QTest::newRow("QAIM 4x4") << TestModelAsVariant(4, 4) << 16;
+
+ QTest::newRow("Number model 1") << QVariant::fromValue(1) << 1;
+ QTest::newRow("Number model 4") << QVariant::fromValue(4) << 4;
+
+ QTest::newRow("QStringList 1") << QVariant::fromValue(QStringList() << "one") << 1;
+ QTest::newRow("QStringList 4") << QVariant::fromValue(QStringList() << "one" << "two" << "three" << "four") << 4;
+}
+
+void tst_QQuickTableView::countDelegateItems()
+{
+ // Assign different models of various sizes, and check that the number of
+ // delegate items in the view matches the size of the model. Note that for
+ // this test to be valid, all items must be within the visible area of the view.
+ QFETCH(QVariant, model);
+ QFETCH(int, count);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+
+ // Check that tableview internals contain the expected number of items
+ auto const items = tableViewPrivate->loadedItems;
+ QCOMPARE(items.count(), count);
+
+ // Check that this also matches the items found in the view
+ auto foundItems = findItems<QQuickItem>(tableView, kDelegateObjectName);
+ QCOMPARE(foundItems.count(), count);
+}
+
+void tst_QQuickTableView::checkLayoutOfEqualSizedDelegateItems_data()
+{
+ QTest::addColumn<QVariant>("model");
+ QTest::addColumn<QSize>("tableSize");
+ QTest::addColumn<QSizeF>("spacing");
+ QTest::addColumn<QMarginsF>("margins");
+
+ // Check spacing together with different table setups
+ QTest::newRow("QAIM 1x1 1,1") << TestModelAsVariant(1, 1) << QSize(1, 1) << QSizeF(1, 1) << QMarginsF(0, 0, 0, 0);
+ QTest::newRow("QAIM 5x5 0,0") << TestModelAsVariant(5, 5) << QSize(5, 5) << QSizeF(0, 0) << QMarginsF(0, 0, 0, 0);
+ QTest::newRow("QAIM 5x5 1,0") << TestModelAsVariant(5, 5) << QSize(5, 5) << QSizeF(1, 0) << QMarginsF(0, 0, 0, 0);
+ QTest::newRow("QAIM 5x5 0,1") << TestModelAsVariant(5, 5) << QSize(5, 5) << QSizeF(0, 1) << QMarginsF(0, 0, 0, 0);
+
+ // Check spacing together with margins
+ QTest::newRow("QAIM 1x1 1,1 5555") << TestModelAsVariant(1, 1) << QSize(1, 1) << QSizeF(1, 1) << QMarginsF(5, 5, 5, 5);
+ QTest::newRow("QAIM 4x4 0,0 3333") << TestModelAsVariant(4, 4) << QSize(4, 4) << QSizeF(0, 0) << QMarginsF(3, 3, 3, 3);
+ QTest::newRow("QAIM 4x4 2,2 1234") << TestModelAsVariant(4, 4) << QSize(4, 4) << QSizeF(2, 2) << QMarginsF(1, 2, 3, 4);
+
+ // Check "list" models
+ QTest::newRow("NumberModel 1x4, 0000") << QVariant::fromValue(4) << QSize(1, 4) << QSizeF(1, 1) << QMarginsF(0, 0, 0, 0);
+ QTest::newRow("QStringList 1x4, 0,0 1111") << QVariant::fromValue(QStringList() << "one" << "two" << "three" << "four")
+ << QSize(1, 4) << QSizeF(0, 0) << QMarginsF(1, 1, 1, 1);
+}
+
+void tst_QQuickTableView::checkLayoutOfEqualSizedDelegateItems()
+{
+ // Check that the geometry of the delegate items are correct
+ QFETCH(QVariant, model);
+ QFETCH(QSize, tableSize);
+ QFETCH(QSizeF, spacing);
+ QFETCH(QMarginsF, margins);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const qreal expectedItemWidth = 100;
+ const qreal expectedItemHeight = 50;
+ const int expectedItemCount = tableSize.width() * tableSize.height();
+
+ tableView->setModel(model);
+ tableView->setRowSpacing(spacing.height());
+ tableView->setColumnSpacing(spacing.width());
+
+ // Setting margins on Flickable should not affect the layout of the
+ // delegate items, since the margins is "transparent" to the TableView.
+ tableView->setLeftMargin(margins.left());
+ tableView->setTopMargin(margins.top());
+ tableView->setRightMargin(margins.right());
+ tableView->setBottomMargin(margins.bottom());
+
+ WAIT_UNTIL_POLISHED;
+
+ auto const items = tableViewPrivate->loadedItems;
+ QVERIFY(!items.isEmpty());
+
+ for (int i = 0; i < expectedItemCount; ++i) {
+ const QQuickItem *item = items[i]->item;
+ QVERIFY(item);
+ QCOMPARE(item->parentItem(), tableView->contentItem());
+
+ const QPoint cell = getContextRowAndColumn(item);
+ qreal expectedX = cell.x() * (expectedItemWidth + spacing.width());
+ qreal expectedY = cell.y() * (expectedItemHeight + spacing.height());
+ QCOMPARE(item->x(), expectedX);
+ QCOMPARE(item->y(), expectedY);
+ QCOMPARE(item->z(), 1);
+ QCOMPARE(item->width(), expectedItemWidth);
+ QCOMPARE(item->height(), expectedItemHeight);
+ }
+}
+
+void tst_QQuickTableView::checkFocusRemoved_data()
+{
+ QTest::addColumn<QString>("focusedItemProp");
+
+ QTest::newRow("delegate root") << QStringLiteral("delegateRoot");
+ QTest::newRow("delegate child") << QStringLiteral("delegateChild");
+}
+
+void tst_QQuickTableView::checkFocusRemoved()
+{
+ // Check that we clear the focus of a delegate item when
+ // a child of the delegate item has focus, and the cell is
+ // flicked out of view.
+ QFETCH(QString, focusedItemProp);
+ LOAD_TABLEVIEW("tableviewfocus.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ auto const item = tableViewPrivate->loadedTableItem(QPoint(0, 0))->item;
+ auto const focusedItem = qvariant_cast<QQuickItem *>(item->property(focusedItemProp.toUtf8().data()));
+ QVERIFY(focusedItem);
+ QCOMPARE(tableView->hasActiveFocus(), false);
+ QCOMPARE(focusedItem->hasActiveFocus(), false);
+
+ focusedItem->forceActiveFocus();
+ QCOMPARE(tableView->hasActiveFocus(), true);
+ QCOMPARE(focusedItem->hasActiveFocus(), true);
+
+ // Flick the focused cell out, and check that none of the
+ // items in the table has focus (which means that the reused
+ // item lost focus when it was flicked out). But the tableview
+ // itself will maintain active focus.
+ tableView->setContentX(500);
+ QCOMPARE(tableView->hasActiveFocus(), true);
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ auto const focusedItem2 = qvariant_cast<QQuickItem *>(fxItem->item->property(focusedItemProp.toUtf8().data()));
+ QCOMPARE(focusedItem2->hasActiveFocus(), false);
+ }
+}
+
+void tst_QQuickTableView::fillTableViewButNothingMore_data()
+{
+ QTest::addColumn<QSizeF>("spacing");
+
+ QTest::newRow("0 0,0 0") << QSizeF(0, 0);
+ QTest::newRow("0 10,10 0") << QSizeF(10, 10);
+ QTest::newRow("100 10,10 0") << QSizeF(10, 10);
+ QTest::newRow("0 0,0 100") << QSizeF(0, 0);
+ QTest::newRow("0 10,10 100") << QSizeF(10, 10);
+ QTest::newRow("100 10,10 100") << QSizeF(10, 10);
+}
+
+void tst_QQuickTableView::fillTableViewButNothingMore()
+{
+ // Check that we end up filling the whole visible part of
+ // the tableview with cells, but nothing more.
+ QFETCH(QSizeF, spacing);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int rows = 100;
+ const int columns = 100;
+ auto model = TestModelAsVariant(rows, columns);
+
+ tableView->setModel(model);
+ tableView->setRowSpacing(spacing.height());
+ tableView->setColumnSpacing(spacing.width());
+
+ WAIT_UNTIL_POLISHED;
+
+ auto const topLeftFxItem = tableViewPrivate->loadedTableItem(QPoint(0, 0));
+ auto const topLeftItem = topLeftFxItem->item;
+
+ auto const bottomRightFxItem = tableViewPrivate->loadedTableItem(tableViewPrivate->loadedTable.bottomRight());
+ auto const bottomRightItem = bottomRightFxItem->item;
+ const QPoint bottomRightCell = getContextRowAndColumn(bottomRightItem.data());
+
+ // Check that the right-most item is overlapping the right edge of the view
+ QVERIFY(bottomRightItem->x() < tableView->width());
+ QVERIFY(bottomRightItem->x() + bottomRightItem->width() >= tableView->width() - spacing.width());
+
+ // Check that the actual number of columns matches what we expect
+ qreal cellWidth = bottomRightItem->width() + spacing.width();
+ int expectedColumns = qCeil(tableView->width() / cellWidth);
+ int actualColumns = bottomRightCell.x() + 1;
+ QCOMPARE(actualColumns, expectedColumns);
+
+ // Check that the bottom-most item is overlapping the bottom edge of the view
+ QVERIFY(bottomRightItem->y() < tableView->height());
+ QVERIFY(bottomRightItem->y() + bottomRightItem->height() >= tableView->height() - spacing.height());
+
+ // Check that the actual number of rows matches what we expect
+ qreal cellHeight = bottomRightItem->height() + spacing.height();
+ int expectedRows = qCeil(tableView->height() / cellHeight);
+ int actualRows = bottomRightCell.y() + 1;
+ QCOMPARE(actualRows, expectedRows);
+}
+
+void tst_QQuickTableView::checkInitialAttachedProperties_data()
+{
+ QTest::addColumn<QVariant>("model");
+
+ QTest::newRow("QAIM") << TestModelAsVariant(4, 4);
+ QTest::newRow("Number model") << QVariant::fromValue(4);
+ QTest::newRow("QStringList") << QVariant::fromValue(QStringList() << "0" << "1" << "2" << "3");
+}
+
+void tst_QQuickTableView::checkInitialAttachedProperties()
+{
+ // Check that the context and attached properties inside
+ // the delegate items are what we expect at start-up.
+ QFETCH(QVariant, model);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ const int index = fxItem->index;
+ const auto item = fxItem->item;
+ const auto context = qmlContext(item.data());
+ const QPoint cell = tableViewPrivate->cellAtModelIndex(index);
+ const int contextIndex = context->contextProperty("index").toInt();
+ const QPoint contextCell = getContextRowAndColumn(item.data());
+ const QString contextModelData = context->contextProperty("modelData").toString();
+
+ QCOMPARE(contextCell.y(), cell.y());
+ QCOMPARE(contextCell.x(), cell.x());
+ QCOMPARE(contextIndex, index);
+ QCOMPARE(contextModelData, QStringLiteral("%1").arg(cell.y()));
+ QCOMPARE(getAttachedObject(item)->view(), tableView);
+ }
+}
+
+void tst_QQuickTableView::checkSpacingValues()
+{
+ LOAD_TABLEVIEW("tableviewdefaultspacing.qml");
+
+ int rowCount = 9;
+ int columnCount = 9;
+ int delegateWidth = 15;
+ int delegateHeight = 10;
+ auto model = TestModelAsVariant(rowCount, columnCount);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Default spacing : 0
+ QCOMPARE(tableView->rowSpacing(), 0);
+ QCOMPARE(tableView->columnSpacing(), 0);
+
+ tableView->polish();
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->contentWidth(), columnCount * (delegateWidth + tableView->columnSpacing()) - tableView->columnSpacing());
+ QCOMPARE(tableView->contentHeight(), rowCount * (delegateHeight + tableView->rowSpacing()) - tableView->rowSpacing());
+
+ // Valid spacing assignment
+ tableView->setRowSpacing(42);
+ tableView->setColumnSpacing(12);
+ QCOMPARE(tableView->rowSpacing(), 42);
+ QCOMPARE(tableView->columnSpacing(), 12);
+
+ tableView->polish();
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->contentWidth(), columnCount * (delegateWidth + tableView->columnSpacing()) - tableView->columnSpacing());
+ QCOMPARE(tableView->contentHeight(), rowCount * (delegateHeight + tableView->rowSpacing()) - tableView->rowSpacing());
+
+ // Invalid assignments (should ignore)
+ tableView->setRowSpacing(-1);
+ tableView->setColumnSpacing(-5);
+ tableView->setRowSpacing(INFINITY);
+ tableView->setColumnSpacing(INFINITY);
+ tableView->setRowSpacing(NAN);
+ tableView->setColumnSpacing(NAN);
+ QCOMPARE(tableView->rowSpacing(), 42);
+ QCOMPARE(tableView->columnSpacing(), 12);
+}
+
+void tst_QQuickTableView::checkDelegateParent()
+{
+ // Check that TableView sets the delegate parent before
+ // bindings are evaluated, so that the app can bind to it.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ QVERIFY(view->rootObject()->property("delegateParentSetBeforeCompleted").toBool());
+}
+
+void tst_QQuickTableView::flick_data()
+{
+ QTest::addColumn<QSizeF>("spacing");
+ QTest::addColumn<QMarginsF>("margins");
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("s:0 m:0 reuse") << QSizeF(0, 0) << QMarginsF(0, 0, 0, 0) << true;
+ QTest::newRow("s:5 m:0 reuse") << QSizeF(5, 5) << QMarginsF(0, 0, 0, 0) << true;
+ QTest::newRow("s:0 m:20 reuse") << QSizeF(0, 0) << QMarginsF(20, 20, 20, 20) << true;
+ QTest::newRow("s:5 m:20 reuse") << QSizeF(5, 5) << QMarginsF(20, 20, 20, 20) << true;
+ QTest::newRow("s:0 m:0") << QSizeF(0, 0) << QMarginsF(0, 0, 0, 0) << false;
+ QTest::newRow("s:5 m:0") << QSizeF(5, 5) << QMarginsF(0, 0, 0, 0) << false;
+ QTest::newRow("s:0 m:20") << QSizeF(0, 0) << QMarginsF(20, 20, 20, 20) << false;
+ QTest::newRow("s:5 m:20") << QSizeF(5, 5) << QMarginsF(20, 20, 20, 20) << false;
+}
+
+void tst_QQuickTableView::flick()
+{
+ // Check that if we end up with the correct start and end column/row as we flick around
+ // with different table configurations.
+ QFETCH(QSizeF, spacing);
+ QFETCH(QMarginsF, margins);
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ const int visualColumnCount = 4;
+ const int visualRowCount = 4;
+ const qreal cellWidth = delegateWidth + spacing.width();
+ const qreal cellHeight = delegateHeight + spacing.height();
+ auto model = TestModelAsVariant(100, 100);
+
+ tableView->setModel(model);
+ tableView->setRowSpacing(spacing.height());
+ tableView->setColumnSpacing(spacing.width());
+ tableView->setLeftMargin(margins.left());
+ tableView->setTopMargin(margins.top());
+ tableView->setRightMargin(margins.right());
+ tableView->setBottomMargin(margins.bottom());
+ tableView->setReuseItems(reuseItems);
+ tableView->setWidth(margins.left() + (visualColumnCount * cellWidth) - spacing.width());
+ tableView->setHeight(margins.top() + (visualRowCount * cellHeight) - spacing.height());
+
+ WAIT_UNTIL_POLISHED;
+
+ // Check the "simple" case if the cells never lands egde-to-edge with the viewport. For
+ // that case we only accept that visible row/columns are loaded.
+ qreal flickValues[] = {0.5, 1.5, 4.5, 20.5, 10.5, 3.5, 1.5, 0.5};
+
+ for (qreal cellsToFlick : flickValues) {
+ // Flick to the beginning of the cell
+ tableView->setContentX(cellsToFlick * cellWidth);
+ tableView->setContentY(cellsToFlick * cellHeight);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ const QRect loadedTable = tableViewPrivate->loadedTable;
+
+ const int expectedTableLeft = cellsToFlick - int((margins.left() + spacing.width()) / cellWidth);
+ const int expectedTableTop = cellsToFlick - int((margins.top() + spacing.height()) / cellHeight);
+
+ QCOMPARE(loadedTable.left(), expectedTableLeft);
+ QCOMPARE(loadedTable.right(), expectedTableLeft + visualColumnCount);
+ QCOMPARE(loadedTable.top(), expectedTableTop);
+ QCOMPARE(loadedTable.bottom(), expectedTableTop + visualRowCount);
+ }
+}
+
+void tst_QQuickTableView::flickOvershoot_data()
+{
+ QTest::addColumn<QSizeF>("spacing");
+ QTest::addColumn<QMarginsF>("margins");
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("s:0 m:0 reuse") << QSizeF(0, 0) << QMarginsF(0, 0, 0, 0) << true;
+ QTest::newRow("s:5 m:0 reuse") << QSizeF(5, 5) << QMarginsF(0, 0, 0, 0) << true;
+ QTest::newRow("s:0 m:20 reuse") << QSizeF(0, 0) << QMarginsF(20, 20, 20, 20) << true;
+ QTest::newRow("s:5 m:20 reuse") << QSizeF(5, 5) << QMarginsF(20, 20, 20, 20) << true;
+ QTest::newRow("s:0 m:0") << QSizeF(0, 0) << QMarginsF(0, 0, 0, 0) << false;
+ QTest::newRow("s:5 m:0") << QSizeF(5, 5) << QMarginsF(0, 0, 0, 0) << false;
+ QTest::newRow("s:0 m:20") << QSizeF(0, 0) << QMarginsF(20, 20, 20, 20) << false;
+ QTest::newRow("s:5 m:20") << QSizeF(5, 5) << QMarginsF(20, 20, 20, 20) << false;
+}
+
+void tst_QQuickTableView::flickOvershoot()
+{
+ // Flick the table completely out and then in again, and see
+ // that we still contains the expected rows/columns
+ // Note that TableView always keeps top-left item loaded, even
+ // when everything is flicked out of view.
+ QFETCH(QSizeF, spacing);
+ QFETCH(QMarginsF, margins);
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const int rowCount = 5;
+ const int columnCount = 5;
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ const qreal cellWidth = delegateWidth + spacing.width();
+ const qreal cellHeight = delegateHeight + spacing.height();
+ const qreal tableWidth = margins.left() + margins.right() + (cellWidth * columnCount) - spacing.width();
+ const qreal tableHeight = margins.top() + margins.bottom() + (cellHeight * rowCount) - spacing.height();
+ const int outsideMargin = 10;
+ auto model = TestModelAsVariant(rowCount, columnCount);
+
+ tableView->setModel(model);
+ tableView->setRowSpacing(spacing.height());
+ tableView->setColumnSpacing(spacing.width());
+ tableView->setLeftMargin(margins.left());
+ tableView->setTopMargin(margins.top());
+ tableView->setRightMargin(margins.right());
+ tableView->setBottomMargin(margins.bottom());
+ tableView->setReuseItems(reuseItems);
+ tableView->setWidth(tableWidth - margins.right() - cellWidth / 2);
+ tableView->setHeight(tableHeight - margins.bottom() - cellHeight / 2);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Flick table out of view left
+ tableView->setContentX(-tableView->width() - outsideMargin);
+ tableView->setContentY(0);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+
+ // Flick table out of view right
+ tableView->setContentX(tableWidth + outsideMargin);
+ tableView->setContentY(0);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+
+ // Flick table out of view on top
+ tableView->setContentX(0);
+ tableView->setContentY(-tableView->height() - outsideMargin);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0);
+
+ // Flick table out of view at the bottom
+ tableView->setContentX(0);
+ tableView->setContentY(tableHeight + outsideMargin);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+
+ // Flick table out of view left and top at the same time
+ tableView->setContentX(-tableView->width() - outsideMargin);
+ tableView->setContentY(-tableView->height() - outsideMargin);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0);
+
+ // Flick table back to origo
+ tableView->setContentX(0);
+ tableView->setContentY(0);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+
+ // Flick table out of view right and bottom at the same time
+ tableView->setContentX(tableWidth + outsideMargin);
+ tableView->setContentY(tableHeight + outsideMargin);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+
+ // Flick table back to origo
+ tableView->setContentX(0);
+ tableView->setContentY(0);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
+ QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+}
+
+void tst_QQuickTableView::checkRowColumnCount()
+{
+ // If we flick several columns (rows) at the same time, check that we don't
+ // end up with loading more delegate items into memory than necessary. We
+ // should free up columns as we go before loading new ones.
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ const char *maxDelegateCountProp = "maxDelegateCount";
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ auto model = TestModelAsVariant(100, 100);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ // We expect that the number of created items after start-up should match
+ //the size of the visible table, pluss one extra preloaded row and column.
+ const QSize visibleTableSize = tableViewPrivate->loadedTable.size();
+ const int qmlCountAfterInit = view->rootObject()->property(maxDelegateCountProp).toInt();
+ const int expectedCount = (visibleTableSize.width() + 1) * (visibleTableSize.height() + 1);
+ QCOMPARE(qmlCountAfterInit, expectedCount);
+
+ // This test will keep track of the maximum number of delegate items TableView
+ // had to show at any point while flicking (in countingtableview.qml). Because
+ // of the geometries chosen for TableView and the delegate, only complete columns
+ // will be shown at start-up.
+ const QRect loadedTable = tableViewPrivate->loadedTable;
+ QVERIFY(loadedTable.height() > loadedTable.width());
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.width(), tableView->width());
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.height(), tableView->height());
+
+ // Flick half an item to the left+up, to force one extra column and row to load before we
+ // start. By doing so, we end up showing the maximum number of rows and columns that will
+ // ever be shown in the view. This will make things less complicated below, when checking
+ // how many items that end up visible while flicking.
+ tableView->setContentX(delegateWidth / 2);
+ tableView->setContentY(delegateHeight / 2);
+ const int qmlCountAfterFirstFlick = view->rootObject()->property(maxDelegateCountProp).toInt();
+
+ // Flick a long distance right
+ tableView->setContentX(tableView->width() * 2);
+
+ const int qmlCountAfterLongFlick = view->rootObject()->property(maxDelegateCountProp).toInt();
+ QCOMPARE(qmlCountAfterLongFlick, qmlCountAfterFirstFlick);
+
+ // Flick a long distance down
+ tableView->setContentX(tableView->height() * 2);
+
+ const int qmlCountAfterDownFlick = view->rootObject()->property(maxDelegateCountProp).toInt();
+ QCOMPARE(qmlCountAfterDownFlick, qmlCountAfterFirstFlick);
+
+ // Flick a long distance left
+ tableView->setContentX(0);
+
+ const int qmlCountAfterLeftFlick = view->rootObject()->property(maxDelegateCountProp).toInt();
+ QCOMPARE(qmlCountAfterLeftFlick, qmlCountAfterFirstFlick);
+
+ // Flick a long distance up
+ tableView->setContentY(0);
+
+ const int qmlCountAfterUpFlick = view->rootObject()->property(maxDelegateCountProp).toInt();
+ QCOMPARE(qmlCountAfterUpFlick, qmlCountAfterFirstFlick);
+}
+
+void tst_QQuickTableView::modelSignals()
+{
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ TestModel model(1, 1);
+ tableView->setModel(QVariant::fromValue(&model));
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 1);
+ QCOMPARE(tableView->columns(), 1);
+
+ QVERIFY(model.insertRows(0, 1));
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 2);
+ QCOMPARE(tableView->columns(), 1);
+
+ QVERIFY(model.removeRows(1, 1));
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 1);
+ QCOMPARE(tableView->columns(), 1);
+
+ model.insertColumns(1, 1);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 1);
+ QCOMPARE(tableView->columns(), 2);
+
+ model.removeColumns(1, 1);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 1);
+ QCOMPARE(tableView->columns(), 1);
+
+ model.setRowCount(10);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 10);
+ QCOMPARE(tableView->columns(), 1);
+
+ model.setColumnCount(10);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 10);
+ QCOMPARE(tableView->columns(), 10);
+
+ model.setRowCount(0);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 0);
+ QCOMPARE(tableView->columns(), 10);
+
+ model.setColumnCount(1);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 0);
+ QCOMPARE(tableView->columns(), 1);
+
+ model.setRowCount(10);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 10);
+ QCOMPARE(tableView->columns(), 1);
+
+ model.setColumnCount(10);
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 10);
+ QCOMPARE(tableView->columns(), 10);
+
+ model.clear();
+ WAIT_UNTIL_POLISHED;
+ QCOMPARE(tableView->rows(), 0);
+ QCOMPARE(tableView->columns(), 1);
+}
+
+void tst_QQuickTableView::dataChangedSignal()
+{
+ // Check that bindings to the model inside a delegate gets updated
+ // when the model item they bind to changes.
+ LOAD_TABLEVIEW("plaintableview.qml");
+
+ const QString prefix(QStringLiteral("changed"));
+
+ TestModel model(10, 10);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ const auto item = tableViewPrivate->loadedTableItem(fxItem->cell)->item;
+ const QString modelDataBindingProperty = item->property(kModelDataBindingProp).toString();
+ QString expectedModelData = QString::number(fxItem->cell.y());
+ QCOMPARE(modelDataBindingProperty, expectedModelData);
+ }
+
+ // Change one cell in the model
+ model.setModelData(QPoint(0, 0), QSize(1, 1), prefix);
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ const QPoint cell = fxItem->cell;
+ const auto modelIndex = model.index(cell.y(), cell.x());
+ QString expectedModelData = model.data(modelIndex, Qt::DisplayRole).toString();
+
+ const auto item = tableViewPrivate->loadedTableItem(fxItem->cell)->item;
+ const QString modelDataBindingProperty = item->property(kModelDataBindingProp).toString();
+
+ QCOMPARE(modelDataBindingProperty, expectedModelData);
+ }
+
+ // Change four cells in one go
+ model.setModelData(QPoint(1, 0), QSize(2, 2), prefix);
+
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ const QPoint cell = fxItem->cell;
+ const auto modelIndex = model.index(cell.y(), cell.x());
+ QString expectedModelData = model.data(modelIndex, Qt::DisplayRole).toString();
+
+ const auto item = tableViewPrivate->loadedTableItem(fxItem->cell)->item;
+ const QString modelDataBindingProperty = item->property(kModelDataBindingProp).toString();
+
+ QCOMPARE(modelDataBindingProperty, expectedModelData);
+ }
+}
+
+void tst_QQuickTableView::checkThatPoolIsDrainedWhenReuseIsFalse()
+{
+ // Check that the reuse pool is drained
+ // immediately when setting reuseItems to false.
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ // The pool should now contain preloaded items
+ QVERIFY(tableViewPrivate->tableModel->poolSize() > 0);
+ tableView->setReuseItems(false);
+ // The pool should now be empty
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+}
+
+void tst_QQuickTableView::checkIfDelegatesAreReused_data()
+{
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("reuse = true") << true;
+ QTest::newRow("reuse = false") << false;
+}
+
+void tst_QQuickTableView::checkIfDelegatesAreReused()
+{
+ // Check that we end up reusing delegate items while flicking if
+ // TableView has reuseItems set to true, but otherwise not.
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ const int pageFlickCount = 4;
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+ tableView->setReuseItems(reuseItems);
+
+ WAIT_UNTIL_POLISHED;
+
+ // Flick half an item to the side, to force one extra row and column to load before we start.
+ // This will make things less complicated below, when checking how many times the items
+ // have been reused (all items will then report the same number).
+ tableView->setContentX(delegateWidth / 2);
+ tableView->setContentY(delegateHeight / 2);
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+
+ // Some items have already been pooled and reused after we moved the content view, because
+ // we preload one extra row and column at start-up. So reset the count-properties back to 0
+ // before we continue.
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ fxItem->item->setProperty("pooledCount", 0);
+ fxItem->item->setProperty("reusedCount", 0);
+ }
+
+ const int visibleColumnCount = tableViewPrivate->loadedTable.width();
+ const int visibleRowCount = tableViewPrivate->loadedTable.height();
+ const int delegateCountAfterInit = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
+
+ for (int column = 1; column <= (visibleColumnCount * pageFlickCount); ++column) {
+ // Flick columns to the left (and add one pixel to ensure the left column is completely out)
+ tableView->setContentX((delegateWidth * column) + 1);
+ // Check that the number of delegate items created so far is what we expect.
+ const int delegatesCreatedCount = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
+ int expectedCount = delegateCountAfterInit + (reuseItems ? 0 : visibleRowCount * column);
+ QCOMPARE(delegatesCreatedCount, expectedCount);
+ }
+
+ // Check that each delegate item has been reused as many times
+ // as we have flicked pages (if reuse is enabled).
+ for (auto fxItem : tableViewPrivate->loadedItems) {
+ int pooledCount = fxItem->item->property("pooledCount").toInt();
+ int reusedCount = fxItem->item->property("reusedCount").toInt();
+ if (reuseItems) {
+ QCOMPARE(pooledCount, pageFlickCount);
+ QCOMPARE(reusedCount, pageFlickCount);
+ } else {
+ QCOMPARE(pooledCount, 0);
+ QCOMPARE(reusedCount, 0);
+ }
+ }
+}
+
+void tst_QQuickTableView::checkIfDelegatesAreReusedAsymmetricTableSize()
+{
+ // Check that we end up reusing all delegate items while flicking, also if the table contain
+ // more columns than rows. In that case, if we flick out a whole row, we'll move a lot of
+ // items into the pool. And if we then start flicking in columns, we'll only reuse a few of
+ // them for each column. Still, we don't want the pool to release the superfluous items after
+ // each load, since they are still in circulation and will be needed once we flick in a new
+ // row at the end of the test.
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ const int columnCount = 20;
+ const int rowCount = 2;
+ const qreal delegateWidth = tableView->width() / columnCount;
+ const qreal delegateHeight = (tableView->height() / rowCount) + 10;
+
+ auto model = TestModelAsVariant(100, 100);
+ tableView->setModel(model);
+
+ // Let the height of each row be much bigger than the width of each column.
+ view->rootObject()->setProperty("delegateWidth", delegateWidth);
+ view->rootObject()->setProperty("delegateHeight", delegateHeight);
+
+ WAIT_UNTIL_POLISHED;
+
+ auto initialTopLeftItem = tableViewPrivate->loadedTableItem(QPoint(0, 0))->item;
+ QVERIFY(initialTopLeftItem);
+ int pooledCount = initialTopLeftItem->property("pooledCount").toInt();
+ int reusedCount = initialTopLeftItem->property("reusedCount").toInt();
+ QCOMPARE(pooledCount, 0);
+ QCOMPARE(reusedCount, 0);
+
+ // Flick half an item left+down, to force one extra row and column to load. By doing
+ // so, we force the maximum number of rows and columns to show before we start the test.
+ // This will make things less complicated below, when checking how many
+ // times the items have been reused (all items will then report the same number).
+ tableView->setContentX(delegateWidth * 0.5);
+ tableView->setContentY(delegateHeight * 0.5);
+
+ // Since we have flicked half a delegate to the left, the number of visible
+ // columns is now one more than the column count were when we started the test.
+ const int visibleColumnCount = tableViewPrivate->loadedTable.width();
+ QCOMPARE(visibleColumnCount, columnCount + 1);
+
+ // We expect no items to have been pooled so far
+ pooledCount = initialTopLeftItem->property("pooledCount").toInt();
+ reusedCount = initialTopLeftItem->property("reusedCount").toInt();
+ QCOMPARE(pooledCount, 0);
+ QCOMPARE(reusedCount, 0);
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+
+ // Flick one row out of view. This will move one whole row of items into the
+ // pool without reusing them, since no new row is exposed at the bottom.
+ tableView->setContentY(delegateHeight + 1);
+ pooledCount = initialTopLeftItem->property("pooledCount").toInt();
+ reusedCount = initialTopLeftItem->property("reusedCount").toInt();
+ QCOMPARE(pooledCount, 1);
+ QCOMPARE(reusedCount, 0);
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), visibleColumnCount);
+
+ const int delegateCountAfterInit = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
+
+ // Start flicking in a lot of columns, and check that the created count stays the same
+ for (int column = 1; column <= 10; ++column) {
+ tableView->setContentX((delegateWidth * column) + 10);
+ const int delegatesCreatedCount = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
+ // Since we reuse items while flicking, the created count should stay the same
+ QCOMPARE(delegatesCreatedCount, delegateCountAfterInit);
+ // Since we flick out just as many columns as we flick in, the pool size should stay the same
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), visibleColumnCount);
+ }
+
+ // Finally, flick one row back into view (but without flicking so far that we push the third
+ // row out and into the pool). The pool should still contain the exact amount of items that
+ // we had after we flicked the first row out. And this should be exactly the amount of items
+ // needed to load the row back again. And this also means that the pool count should then return
+ // back to 0.
+ tableView->setContentY(delegateHeight - 1);
+ const int delegatesCreatedCount = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
+ QCOMPARE(delegatesCreatedCount, delegateCountAfterInit);
+ QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
+}
+
+void tst_QQuickTableView::checkContextProperties_data()
+{
+ QTest::addColumn<QVariant>("model");
+ QTest::addColumn<bool>("reuseItems");
+
+ auto stringList = QStringList();
+ for (int i = 0; i < 100; ++i)
+ stringList.append(QString::number(i));
+
+ QTest::newRow("QAIM, reuse=false") << TestModelAsVariant(100, 100) << false;
+ QTest::newRow("QAIM, reuse=true") << TestModelAsVariant(100, 100) << true;
+ QTest::newRow("Number model, reuse=false") << QVariant::fromValue(100) << false;
+ QTest::newRow("Number model, reuse=true") << QVariant::fromValue(100) << true;
+ QTest::newRow("QStringList, reuse=false") << QVariant::fromValue(stringList) << false;
+ QTest::newRow("QStringList, reuse=true") << QVariant::fromValue(stringList) << true;
+}
+
+void tst_QQuickTableView::checkContextProperties()
+{
+ // Check that the context properties of the delegate items
+ // are what we expect while flicking, with or without item recycling.
+ QFETCH(QVariant, model);
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ const int rowCount = 100;
+ const int pageFlickCount = 3;
+
+ tableView->setModel(model);
+ tableView->setReuseItems(reuseItems);
+
+ WAIT_UNTIL_POLISHED;
+
+ const int visibleRowCount = qMin(tableView->rows(), qCeil(tableView->height() / delegateHeight));
+ const int visibleColumnCount = qMin(tableView->columns(), qCeil(tableView->width() / delegateWidth));
+
+ for (int row = 1; row <= (visibleRowCount * pageFlickCount); ++row) {
+ // Flick rows up
+ tableView->setContentY((delegateHeight * row) + (delegateHeight / 2));
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ for (int col = 0; col < visibleColumnCount; ++col) {
+ const auto item = tableViewPrivate->loadedTableItem(QPoint(col, row))->item;
+ const auto context = qmlContext(item.data());
+ const int contextIndex = context->contextProperty("index").toInt();
+ const int contextRow = context->contextProperty("row").toInt();
+ const int contextColumn = context->contextProperty("column").toInt();
+ const QString contextModelData = context->contextProperty("modelData").toString();
+
+ QCOMPARE(contextIndex, row + (col * rowCount));
+ QCOMPARE(contextRow, row);
+ QCOMPARE(contextColumn, col);
+ QCOMPARE(contextModelData, QStringLiteral("%1").arg(row));
+ }
+ }
+}
+
+void tst_QQuickTableView::checkContextPropertiesQQmlListProperyModel_data()
+{
+ QTest::addColumn<bool>("reuseItems");
+
+ QTest::newRow("reuse=false") << false;
+ QTest::newRow("reuse=true") << true;
+}
+
+void tst_QQuickTableView::checkContextPropertiesQQmlListProperyModel()
+{
+ // Check that the context properties of the delegate items
+ // are what we expect while flicking, with or without item recycling.
+ // This test hard-codes the model to be a QQmlListPropertyModel from
+ // within the qml file.
+ QFETCH(bool, reuseItems);
+ LOAD_TABLEVIEW("qqmllistpropertymodel.qml");
+
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ const int rowCount = 100;
+ const int pageFlickCount = 3;
+
+ tableView->setReuseItems(reuseItems);
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ const int visibleRowCount = qMin(tableView->rows(), qCeil(tableView->height() / delegateHeight));
+ const int visibleColumnCount = qMin(tableView->columns(), qCeil(tableView->width() / delegateWidth));
+
+ for (int row = 1; row <= (visibleRowCount * pageFlickCount); ++row) {
+ // Flick rows up
+ tableView->setContentY((delegateHeight * row) + (delegateHeight / 2));
+ tableView->polish();
+
+ WAIT_UNTIL_POLISHED;
+
+ for (int col = 0; col < visibleColumnCount; ++col) {
+ const auto item = tableViewPrivate->loadedTableItem(QPoint(col, row))->item;
+ const auto context = qmlContext(item.data());
+ const int contextIndex = context->contextProperty("index").toInt();
+ const int contextRow = context->contextProperty("row").toInt();
+ const int contextColumn = context->contextProperty("column").toInt();
+ const QObject *contextModelData = qvariant_cast<QObject *>(context->contextProperty("modelData"));
+ const QString modelDataProperty = contextModelData->property("someCustomProperty").toString();
+
+ QCOMPARE(contextIndex, row + (col * rowCount));
+ QCOMPARE(contextRow, row);
+ QCOMPARE(contextColumn, col);
+ QCOMPARE(modelDataProperty, QStringLiteral("%1").arg(row));
+ }
+ }
+}
+
+void tst_QQuickTableView::checkRowAndColumnChangedButNotIndex()
+{
+ // Check that context row and column changes even if the index stays the
+ // same when the item is reused. This can happen in rare cases if the item
+ // is first used at e.g (row 1, col 0), but then reused at (row 0, col 1)
+ // while the model has changed row count in-between.
+ LOAD_TABLEVIEW("checkrowandcolumnnotchanged.qml");
+
+ TestModel model(2, 1);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ WAIT_UNTIL_POLISHED;
+
+ model.removeRow(1);
+ model.insertColumn(1);
+ tableView->forceLayout();
+
+ const auto item = tableViewPrivate->loadedTableItem(QPoint(1, 0))->item;
+ const auto context = qmlContext(item.data());
+ const int contextIndex = context->contextProperty("index").toInt();
+ const int contextRow = context->contextProperty("row").toInt();
+ const int contextColumn = context->contextProperty("column").toInt();
+
+ QCOMPARE(contextIndex, 1);
+ QCOMPARE(contextRow, 0);
+ QCOMPARE(contextColumn, 1);
+}
+
+void tst_QQuickTableView::checkChangingModelFromDelegate()
+{
+ // Check that we don't restart a rebuild of the table
+ // while we're in the middle of rebuilding it from before
+ LOAD_TABLEVIEW("changemodelfromdelegate.qml");
+
+ // Set addRowFromDelegate. This will trigger the QML code to add a new
+ // row and call forceLayout(). When TableView instantiates the first
+ // delegate in the new row, the Component.onCompleted handler will try to
+ // add a new row. But since we're currently rebuilding, this should be
+ // scheduled for later.
+ view->rootObject()->setProperty("addRowFromDelegate", true);
+
+ // We now expect two rows in the table, one more than initially
+ QCOMPARE(tableViewPrivate->tableSize.height(), 2);
+ QCOMPARE(tableViewPrivate->loadedTable.height(), 2);
+
+ // And since the QML code tried to add another row as well, we
+ // expect rebuildScheduled to be true, and a polish event to be pending.
+ QCOMPARE(tableViewPrivate->rebuildScheduled, true);
+ QCOMPARE(tableViewPrivate->polishScheduled, true);
+ WAIT_UNTIL_POLISHED;
+
+ // After handling the polish event, we expect also the third row to now be added
+ QCOMPARE(tableViewPrivate->tableSize.height(), 3);
+ QCOMPARE(tableViewPrivate->loadedTable.height(), 3);
+}
+
+void tst_QQuickTableView::checkRebuildViewportOnly()
+{
+ // Check that we only rebuild from the current top-left cell
+ // when you add or remove rows and columns. There should be
+ // no need to do a rebuild from scratch in such cases.
+ LOAD_TABLEVIEW("countingtableview.qml");
+
+ const char *propName = "delegatesCreatedCount";
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+
+ TestModel model(100, 100);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ WAIT_UNTIL_POLISHED;
+
+ // Flick to row/column 50, 50
+ tableView->setContentX(delegateWidth * 50);
+ tableView->setContentY(delegateHeight * 50);
+
+ // Set reuse items to false, just to make it easier to
+ // check the number of items created during a rebuild.
+ tableView->setReuseItems(false);
+ const int itemCountBeforeRebuild = tableViewPrivate->loadedItems.count();
+
+ // Since all cells have the same size, we expect that we end up creating
+ // the same amount of items that were already showing before, even after
+ // adding or removing rows and columns.
+ view->rootObject()->setProperty(propName, 0);
+ model.insertRow(51);
+ WAIT_UNTIL_POLISHED;
+ int countAfterRebuild = view->rootObject()->property(propName).toInt();
+ QCOMPARE(countAfterRebuild, itemCountBeforeRebuild);
+
+ view->rootObject()->setProperty(propName, 0);
+ model.removeRow(51);
+ WAIT_UNTIL_POLISHED;
+ countAfterRebuild = view->rootObject()->property(propName).toInt();
+ QCOMPARE(countAfterRebuild, itemCountBeforeRebuild);
+
+ view->rootObject()->setProperty(propName, 0);
+ model.insertColumn(51);
+ WAIT_UNTIL_POLISHED;
+ countAfterRebuild = view->rootObject()->property(propName).toInt();
+ QCOMPARE(countAfterRebuild, itemCountBeforeRebuild);
+
+ view->rootObject()->setProperty(propName, 0);
+ model.removeColumn(51);
+ WAIT_UNTIL_POLISHED;
+ countAfterRebuild = view->rootObject()->property(propName).toInt();
+ QCOMPARE(countAfterRebuild, itemCountBeforeRebuild);
+}
+
+void tst_QQuickTableView::useDelegateChooserWithoutDefault()
+{
+ // Check that the application issues a warning (but doesn't e.g
+ // crash) if the delegate chooser doesn't cover all cells
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*failed"));
+ LOAD_TABLEVIEW("usechooserwithoutdefault.qml");
+ auto model = TestModelAsVariant(2, 1);
+ tableView->setModel(model);
+ WAIT_UNTIL_POLISHED;
+};
+
+void tst_QQuickTableView::checkTableviewInsideAsyncLoader()
+{
+ // Check that you can put a TableView inside an async Loader, and
+ // that the delegate items are created before the loader is ready.
+ LOAD_TABLEVIEW_ASYNC("asyncplain.qml");
+
+ // At this point the Loader has finished
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+
+ // Check that TableView has finished building
+ QCOMPARE(tableViewPrivate->rebuildScheduled, false);
+ QCOMPARE(tableViewPrivate->rebuildState, QQuickTableViewPrivate::RebuildState::Done);
+
+ // Check that all expected delegate items have been loaded
+ const qreal delegateWidth = 100;
+ const qreal delegateHeight = 50;
+ int expectedColumns = qCeil(tableView->width() / delegateWidth);
+ int expectedRows = qCeil(tableView->height() / delegateHeight);
+ QCOMPARE(tableViewPrivate->loadedTable.width(), expectedColumns);
+ QCOMPARE(tableViewPrivate->loadedTable.height(), expectedRows);
+
+ // Check that the loader was still in a loading state while TableView was creating
+ // delegate items. If we delayed creating delegate items until we got the first
+ // updatePolish() callback in QQuickTableView, this would not be the case.
+ auto statusWhenDelegate0_0Completed = qvariant_cast<QQuickLoader::Status>(
+ loader->item()->property("statusWhenDelegate0_0Created"));
+ auto statusWhenDelegate5_5Completed = qvariant_cast<QQuickLoader::Status>(
+ loader->item()->property("statusWhenDelegate5_5Created"));
+ QCOMPARE(statusWhenDelegate0_0Completed, QQuickLoader::Loading);
+ QCOMPARE(statusWhenDelegate5_5Completed, QQuickLoader::Loading);
+
+ // Check that TableView had a valid geometry when we started to build. If the build
+ // was started too early (e.g upon QQuickTableView::componentComplete), width and
+ // height would still be 0 since the bindings would not have been evaluated yet.
+ qreal width = loader->item()->property("tableViewWidthWhileBuilding").toReal();
+ qreal height = loader->item()->property("tableViewHeightWhileBuilding").toReal();
+ QVERIFY(width > 0);
+ QVERIFY(height > 0);
+};
+
+QTEST_MAIN(tst_QQuickTableView)
+
+#include "tst_qquicktableview.moc"
diff --git a/tests/auto/quick/qquicktext/data/implicitSizeChangeRewrap.qml b/tests/auto/quick/qquicktext/data/implicitSizeChangeRewrap.qml
new file mode 100644
index 0000000000..fb8626a75a
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/implicitSizeChangeRewrap.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+
+Item
+{
+ id : _rootItem
+ width : 200
+ height : 1000
+ ColumnLayout
+ {
+ id : _textContainer
+ anchors.centerIn: parent
+ Layout.maximumWidth: (_rootItem.width - 40) // to have some space left / right
+ Text
+ {
+ id : text
+ objectName: "text"
+ font.italic: true
+ textFormat: Text.RichText
+ horizontalAlignment : Text.AlignHCenter
+ verticalAlignment : Text.AlignVCenter
+ wrapMode: Text.Wrap
+ Layout.maximumWidth: (_rootItem.width - 60)
+ Component.onCompleted: text.text = "This is a too long text for the interface with a stupid path also too long -> /home/long/long/long/to/force/it/to/need/to/wrap This is a too long text for the interface with a stupid path also too long -> /home/long/long/long/to/force/it/to/need/to/wrap This is a too long text for the interface with a stupid path also too long -> /home/long/long/long/to/force/it/to/need/to/wrap This is a too long text for the interface with a stupid path also too long -> /home/long/long/long/to/force/it/to/need/to/wrap"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 89d2590c03..63e023644f 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -105,6 +105,7 @@ private slots:
void implicitSize_data();
void implicitSize();
+ void implicitSizeChangeRewrap();
void dependentImplicitSizes();
void contentSize();
void implicitSizeBinding_data();
@@ -999,11 +1000,14 @@ static inline QByteArray msgNotLessThan(int n1, int n2)
void tst_qquicktext::hAlignImplicitWidth()
{
+#ifdef Q_OS_MACOS
+ QSKIP("this test currently crashes on MacOS. See QTBUG-68047");
+#endif
QQuickView view(testFileUrl("hAlignImplicitWidth.qml"));
view.setFlags(view.flags() | Qt::WindowStaysOnTopHint); // Prevent being obscured by other windows.
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowActive(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QQuickText *text = view.rootObject()->findChild<QQuickText*>("textItem");
QVERIFY(text != nullptr);
@@ -2380,23 +2384,31 @@ void tst_qquicktext::contentSize()
QScopedPointer<QObject> object(textComponent.create());
QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+ QSignalSpy spySize(textObject, SIGNAL(contentSizeChanged()));
+ QSignalSpy spyWidth(textObject, SIGNAL(contentWidthChanged(qreal)));
+ QSignalSpy spyHeight(textObject, SIGNAL(contentHeightChanged(qreal)));
textObject->setText("The quick red fox jumped over the lazy brown dog");
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spySize.count(), 1);
+ QCOMPARE(spyWidth.count(), 1);
+ QCOMPARE(spyHeight.count(), 0);
textObject->setWrapMode(QQuickText::WordWrap);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spySize.count(), 2);
+ QCOMPARE(spyWidth.count(), 2);
+ QCOMPARE(spyHeight.count(), 1);
textObject->setElideMode(QQuickText::ElideRight);
QVERIFY(textObject->contentWidth() <= textObject->width());
QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spySize.count(), 3);
+ QCOMPARE(spyWidth.count(), 3);
+ QCOMPARE(spyHeight.count(), 2);
int spyCount = 3;
qreal elidedWidth = textObject->contentWidth();
@@ -2405,14 +2417,16 @@ void tst_qquicktext::contentSize()
QVERIFY(textObject->contentHeight() < textObject->height());
// this text probably won't have the same elided width, but it's not guaranteed.
if (textObject->contentWidth() != elidedWidth)
- QCOMPARE(spy.count(), ++spyCount);
+ QCOMPARE(spySize.count(), ++spyCount);
else
- QCOMPARE(spy.count(), spyCount);
+ QCOMPARE(spySize.count(), spyCount);
textObject->setElideMode(QQuickText::ElideNone);
QVERIFY(textObject->contentWidth() > textObject->width());
QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), ++spyCount);
+ QCOMPARE(spySize.count(), ++spyCount);
+ QCOMPARE(spyWidth.count(), spyCount);
+ QCOMPARE(spyHeight.count(), 3);
}
void tst_qquicktext::geometryChanged()
@@ -4369,6 +4383,23 @@ void tst_qquicktext::fontInfo()
QVERIFY(copy->font().pixelSize() < 1000);
}
+void tst_qquicktext::implicitSizeChangeRewrap()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("implicitSizeChangeRewrap.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QObject *root = window->rootObject();
+
+ QQuickText *text = root->findChild<QQuickText *>("text");
+ QVERIFY(text != nullptr);
+
+ QVERIFY(text->contentWidth() < window->width());
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 65c9c9e8ad..ed2d535fda 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -1990,9 +1990,6 @@ void tst_qquicktextinput::validators()
QCOMPARE(intInput->hasAcceptableInput(), false);
QCOMPARE(intInput->property("acceptable").toBool(), false);
QCOMPARE(intSpy.count(), 0);
- QTest::keyPress(&window, Qt::Key_2);
- QTest::keyRelease(&window, Qt::Key_2, Qt::NoModifier);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
QCOMPARE(intInput->hasAcceptableInput(), false);
QCOMPARE(intInput->property("acceptable").toBool(), false);
QCOMPARE(intSpy.count(), 0);
@@ -5989,7 +5986,7 @@ void tst_qquicktextinput::QTBUG_19956_regexp()
{
QUrl url = testFileUrl("qtbug-19956regexp.qml");
- QString warning = url.toString() + ":11:17: Unable to assign [undefined] to QRegExp";
+ QString warning = url.toString() + ":11:9: Unable to assign [undefined] to QRegExp";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QQuickView window(url);
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index da227b871b..6498a80c79 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -2996,7 +2996,7 @@ void tst_qquickvisualdatamodel::insert_data()
"items.get(2).model.modelData = \"seven\"; }")
<< 4 << 5 << 0 << true << false << false << false << false
<< QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+ << (QStringList() << "eight" << "one" << "seven" << "three" << "four");
QTest::newRow("StringList.create prepend modelData")
<< stringListSource[i]
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 44cd1dd656..578ae56cca 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -547,7 +547,7 @@ void tst_qquickwindow::constantUpdatesOnWindow_data()
window.setTitle(QTest::currentTestFunction());
window.setGeometry(100, 100, 300, 200);
window.show();
- QTest::qWaitForWindowExposed(&window);
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
const bool threaded = QQuickWindowPrivate::get(&window)->context->thread() != QGuiApplication::instance()->thread();
if (threaded) {
QTest::newRow("blocked, beforeRender") << true << QByteArray(SIGNAL(beforeRendering()));
@@ -631,9 +631,10 @@ void tst_qquickwindow::touchEvent_basic()
topItem->setSize(QSizeF(150, 150));
QPointF pos(10, 10);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window, touchDevice, false);
// press single point
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window).commit();
QQuickTouchUtils::flush(window);
QTRY_COMPARE(topItem->lastEvent.touchPoints.count(), 1);
@@ -643,11 +644,11 @@ void tst_qquickwindow::touchEvent_basic()
// would put the decorated window at that position rather than the window itself.
COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
topItem->reset();
- QTest::touchEvent(window, touchDevice).release(0, topItem->mapToScene(pos).toPoint(), window);
+ touchSeq.release(0, topItem->mapToScene(pos).toPoint(), window).commit();
// press multiple points
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window)
- .press(1, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
@@ -656,35 +657,35 @@ void tst_qquickwindow::touchEvent_basic()
COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
topItem->reset();
bottomItem->reset();
- QTest::touchEvent(window, touchDevice).release(0, topItem->mapToScene(pos).toPoint(), window).release(1, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.release(0, topItem->mapToScene(pos).toPoint(), window).release(1, bottomItem->mapToScene(pos).toPoint(), window).commit();
// touch point on top item moves to bottom item, but top item should still receive the event
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, Qt::TouchPointMoved,
makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
topItem->reset();
- QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window).commit();
// touch point on bottom item moves to top item, but bottom item should still receive the event
- QTest::touchEvent(window, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.press(0, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), window);
+ touchSeq.move(0, topItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, window, Qt::TouchPointMoved,
makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos)));
bottomItem->reset();
- QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window).commit();
// a single stationary press on an item shouldn't cause an event
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).stationary(0)
- .press(1, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.stationary(0)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
@@ -696,13 +697,13 @@ void tst_qquickwindow::touchEvent_basic()
// cleanup: what is pressed must be released
// Otherwise you will get an assertion failure:
// ASSERT: "itemForTouchPointId.isEmpty()" in file items/qquickwindow.cpp
- QTest::touchEvent(window, touchDevice).release(0, pos.toPoint(), window).release(1, pos.toPoint(), window);
+ touchSeq.release(0, pos.toPoint(), window).release(1, pos.toPoint(), window).commit();
QQuickTouchUtils::flush(window);
// move touch point from top item to bottom, and release
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),window);
+ touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(),window).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, window, Qt::TouchPointReleased,
@@ -710,13 +711,13 @@ void tst_qquickwindow::touchEvent_basic()
topItem->reset();
// release while another point is pressed
- QTest::touchEvent(window, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),window)
- .press(1, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.press(0, topItem->mapToScene(pos).toPoint(),window)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), window);
+ touchSeq.move(0, bottomItem->mapToScene(pos).toPoint(), window).commit();
QQuickTouchUtils::flush(window);
- QTest::touchEvent(window, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), window)
- .stationary(1);
+ touchSeq.release(0, bottomItem->mapToScene(pos).toPoint(), window)
+ .stationary(1).commit();
QQuickTouchUtils::flush(window);
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
@@ -1233,8 +1234,8 @@ void tst_qquickwindow::synthMouseFromTouch()
QTest::touchEvent(window.data(), touchDevice).move(0, p2, window.data());
QTest::touchEvent(window.data(), touchDevice).release(0, p2, window.data());
- QCOMPARE(item->m_touchEvents.count(), 3);
- QCOMPARE(item->m_mouseEvents.count(), acceptTouch ? 0 : 3);
+ QCOMPARE(item->m_touchEvents.count(), !synthMouse && !acceptTouch ? 1 : 3);
+ QCOMPARE(item->m_mouseEvents.count(), (acceptTouch || !synthMouse) ? 0 : 3);
QCOMPARE(window->m_mouseEvents.count(), 0);
for (const QMouseEvent &ev : item->m_mouseEvents)
QCOMPARE(ev.source(), Qt::MouseEventSynthesizedByQt);
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
index 757cb8f513..bcff0c46fb 100644
--- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -354,7 +354,7 @@ void tst_qquickxmllistmodel::xml()
QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);
QTRY_COMPARE(spy.count(), 1); spy.clear();
@@ -410,6 +410,13 @@ void tst_qquickxmllistmodel::headers()
QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Ready);
+ // It doesn't do a network request for a local file
+ QCOMPARE(factory.lastSentHeaders.count(), 0);
+
+ model->setProperty("source", QUrl("http://localhost/filethatdoesnotexist.xml"));
+ QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Error);
+
QVariantMap expectedHeaders;
expectedHeaders["Accept"] = "application/xml,*/*";
@@ -433,7 +440,7 @@ void tst_qquickxmllistmodel::source()
QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);
QTRY_COMPARE(spy.count(), 1); spy.clear();
@@ -447,7 +454,7 @@ void tst_qquickxmllistmodel::source()
if (model->property("source").toString().isEmpty())
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Null);
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("progress").toDouble(), qreal(source.isLocalFile() ? 1.0 : 0.0));
QTRY_COMPARE(spy.count(), 1); spy.clear();
QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
QQuickXmlListModel::Loading);
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index a54a707f4a..6fc3bb5b1b 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -25,6 +25,7 @@ qtConfig(opengl(es1|es2)?) {
PRIVATETESTS += \
nokeywords \
+ propertyrequirements \
qquickanimations \
qquickapplication \
qquickbehaviors \
@@ -66,6 +67,7 @@ QUICKTESTS += \
qquickitem2 \
qquickitemlayer \
qquicklistview \
+ qquicktableview \
qquickloader \
qquickmousearea \
qquickmultipointtoucharea \
@@ -93,7 +95,7 @@ QUICKTESTS += \
SUBDIRS += $$PUBLICTESTS
# Following tests are too slow on qemu + software backend
-boot2qt: QUICKTESTS -= qquickgridview qquicklistview qquickpositioners
+boot2qt: QUICKTESTS -= qquickgridview qquicklistview qquicktableview qquickpositioners
!qtConfig(accessibility):QUICKTESTS -= qquickaccessible
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index dc813b9d59..3bfa23173e 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -153,6 +153,12 @@ int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const
return list.count();
}
+int QQuickViewTestUtil::QaimModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return columns;
+}
+
QHash<int,QByteArray> QQuickViewTestUtil::QaimModel::roleNames() const
{
QHash<int,QByteArray> roles = QAbstractListModel::roleNames();
@@ -174,7 +180,7 @@ QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role)
int QQuickViewTestUtil::QaimModel::count() const
{
- return rowCount();
+ return rowCount() * columnCount();
}
QString QQuickViewTestUtil::QaimModel::name(int index) const
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index b11d5e4859..04e1771ef8 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -76,6 +76,7 @@ namespace QQuickViewTestUtil
QaimModel(QObject *parent=0);
int rowCount(const QModelIndex &parent=QModelIndex()) const;
+ int columnCount(const QModelIndex &parent=QModelIndex()) const;
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
QHash<int,QByteArray> roleNames() const;
@@ -104,6 +105,8 @@ namespace QQuickViewTestUtil
using QAbstractListModel::dataChanged;
+ int columns = 1;
+
private:
QList<QPair<QString,QString> > list;
};
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index a69cd5bc34..052d81b6de 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -176,6 +176,7 @@ public:
private slots:
void initTestCase();
+ void simpleTouchEvent_data();
void simpleTouchEvent();
void testEventFilter();
void mouse();
@@ -226,15 +227,22 @@ QQuickView *tst_TouchMouse::createView()
void tst_TouchMouse::initTestCase()
{
- // This test assumes that we don't get synthesized mouse events from QGuiApplication
- qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
-
QQmlDataTest::initTestCase();
qmlRegisterType<EventItem>("Qt.test", 1, 0, "EventItem");
}
+void tst_TouchMouse::simpleTouchEvent_data()
+{
+ QTest::addColumn<bool>("synthMouse"); // AA_SynthesizeMouseForUnhandledTouchEvents
+ QTest::newRow("no synth") << false;
+ QTest::newRow("synth") << true;
+}
+
void tst_TouchMouse::simpleTouchEvent()
{
+ QFETCH(bool, synthMouse);
+ qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, synthMouse);
+
QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("singleitem.qml"));
window->show();
@@ -251,16 +259,16 @@ void tst_TouchMouse::simpleTouchEvent()
QTest::touchEvent(window.data(), device).press(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
// Get a touch and then mouse event offered
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
p1 += QPoint(10, 0);
QTest::touchEvent(window.data(), device).move(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
// Not accepted, no updates
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
QTest::touchEvent(window.data(), device).release(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
eventItem1->eventList.clear();
// Accept touch
@@ -288,10 +296,11 @@ void tst_TouchMouse::simpleTouchEvent()
p1 = QPoint(20, 20);
QTest::touchEvent(window.data(), device).press(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
- QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
- QCOMPARE(window->mouseGrabberItem(), eventItem1);
+ if (synthMouse)
+ QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
+ QCOMPARE(window->mouseGrabberItem(), synthMouse ? eventItem1 : nullptr);
QPoint localPos = eventItem1->mapFromScene(p1).toPoint();
QPoint globalPos = window->mapToGlobal(p1);
@@ -299,21 +308,31 @@ void tst_TouchMouse::simpleTouchEvent()
QCOMPARE(eventItem1->eventList.at(0).points.at(0).pos().toPoint(), localPos);
QCOMPARE(eventItem1->eventList.at(0).points.at(0).scenePos().toPoint(), scenePos);
QCOMPARE(eventItem1->eventList.at(0).points.at(0).screenPos().toPoint(), globalPos);
- QCOMPARE(eventItem1->eventList.at(1).mousePos, localPos);
- QCOMPARE(eventItem1->eventList.at(1).mousePosGlobal, globalPos);
+ if (synthMouse) {
+ QCOMPARE(eventItem1->eventList.at(1).mousePos, localPos);
+ QCOMPARE(eventItem1->eventList.at(1).mousePosGlobal, globalPos);
+ }
p1 += QPoint(10, 0);
QTest::touchEvent(window.data(), device).move(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 4);
- QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchUpdate);
- QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 4 : 1);
+ if (synthMouse) {
+ QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchUpdate);
+ QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
+ }
+ // else, if there was no synth-mouse and we didn't accept the touch,
+ // TouchUpdate was not sent to eventItem1 either.
QTest::touchEvent(window.data(), device).release(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 7);
- QCOMPARE(eventItem1->eventList.at(4).type, QEvent::TouchEnd);
- QCOMPARE(eventItem1->eventList.at(5).type, QEvent::MouseButtonRelease);
- QCOMPARE(eventItem1->eventList.at(6).type, QEvent::UngrabMouse);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 7 : 1);
+ if (synthMouse) {
+ QCOMPARE(eventItem1->eventList.at(4).type, QEvent::TouchEnd);
+ QCOMPARE(eventItem1->eventList.at(5).type, QEvent::MouseButtonRelease);
+ QCOMPARE(eventItem1->eventList.at(6).type, QEvent::UngrabMouse);
+ }
+ // else, if there was no synth-mouse and we didn't accept the touch,
+ // TouchEnd was not sent to eventItem1 either.
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -326,16 +345,17 @@ void tst_TouchMouse::simpleTouchEvent()
p1 = QPoint(20, 20);
QTest::touchEvent(window.data(), device).press(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
- QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
+ if (synthMouse)
+ QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
p1 += QPoint(10, 0);
QTest::touchEvent(window.data(), device).move(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
QTest::touchEvent(window.data(), device).release(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
- QCOMPARE(eventItem1->eventList.size(), 2);
+ QCOMPARE(eventItem1->eventList.size(), synthMouse ? 2 : 1);
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -824,6 +844,7 @@ void tst_TouchMouse::buttonOnTouch()
EventItem *eventItem4 = window->rootObject()->findChild<EventItem*>("eventItem4");
QVERIFY(eventItem4);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window.data(), device, false);
// Test the common case of a mouse area on top of pinch
eventItem1->setAcceptedMouseButtons(Qt::LeftButton);
@@ -835,9 +856,9 @@ void tst_TouchMouse::buttonOnTouch()
// Normal touch click
QPoint p1 = QPoint(10, 110);
- QTest::touchEvent(window.data(), device).press(0, p1, window.data());
+ touchSeq.press(0, p1, window.data()).commit();
QQuickTouchUtils::flush(window.data());
- QTest::touchEvent(window.data(), device).release(0, p1, window.data());
+ touchSeq.release(0, p1, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(eventItem1->eventList.size(), 5);
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
@@ -860,9 +881,9 @@ void tst_TouchMouse::buttonOnTouch()
QPoint p2 = QPoint(60, 10);
// Start the events after each other
- QTest::touchEvent(window.data(), device).press(0, p1, window.data());
+ touchSeq.press(0, p1, window.data()).commit();
QQuickTouchUtils::flush(window.data());
- QTest::touchEvent(window.data(), device).stationary(0).press(1, p2, window.data());
+ touchSeq.stationary(0).press(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(button1->scale(), 1.0);
@@ -870,24 +891,24 @@ void tst_TouchMouse::buttonOnTouch()
// This event seems to be discarded, let's ignore it for now until someone digs into pincharea
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
// QCOMPARE(button1->scale(), 1.5);
qDebug() << "Button scale: " << button1->scale();
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
// QCOMPARE(button1->scale(), 2.0);
qDebug() << "Button scale: " << button1->scale();
- QTest::touchEvent(window.data(), device).release(0, p1, window.data()).release(1, p2, window.data());
+ touchSeq.release(0, p1, window.data()).release(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
// QVERIFY(eventItem1->eventList.isEmpty());
// QCOMPARE(button1->scale(), 2.0);
@@ -901,7 +922,7 @@ void tst_TouchMouse::buttonOnTouch()
button1->setScale(1.0);
p1 = QPoint(40, 110);
p2 = QPoint(60, 110);
- QTest::touchEvent(window.data(), device).press(0, p1, window.data()).press(1, p2, window.data());
+ touchSeq.press(0, p1, window.data()).press(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(button1->scale(), 1.0);
QCOMPARE(eventItem1->eventList.count(), 2);
@@ -911,24 +932,24 @@ void tst_TouchMouse::buttonOnTouch()
// This event seems to be discarded, let's ignore it for now until someone digs into pincharea
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
//QCOMPARE(button1->scale(), 1.5);
qDebug() << button1->scale();
p1 -= QPoint(10, 0);
p2 += QPoint(10, 0);
- QTest::touchEvent(window.data(), device).move(0, p1, window.data()).move(1, p2, window.data());
+ touchSeq.move(0, p1, window.data()).move(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
qDebug() << button1->scale();
//QCOMPARE(button1->scale(), 2.0);
- QTest::touchEvent(window.data(), device).release(0, p1, window.data()).release(1, p2, window.data());
+ touchSeq.release(0, p1, window.data()).release(1, p2, window.data()).commit();
QQuickTouchUtils::flush(window.data());
// QCOMPARE(eventItem1->eventList.size(), 99);
qDebug() << button1->scale();
@@ -1334,6 +1355,7 @@ void tst_TouchMouse::touchPointDeliveryOrder()
QPoint pLeftMiddle = QPoint(200, 100);
QPoint pRightMiddle = QPoint(350, 100);
+ QTest::QTouchEventSequence touchSeq = QTest::touchEvent(window.data(), device, false);
QVector<QQuickItem*> events;
EventItem *background = window->rootObject()->findChild<EventItem*>("background");
@@ -1349,7 +1371,7 @@ void tst_TouchMouse::touchPointDeliveryOrder()
connect(middle, &EventItem::onTouchEvent, [&events](QQuickItem* receiver){ events.append(receiver); });
connect(right, &EventItem::onTouchEvent, [&events](QQuickItem* receiver){ events.append(receiver); });
- QTest::touchEvent(window.data(), device).press(0, pLeft, window.data());
+ touchSeq.press(0, pLeft, window.data()).commit();
QQuickTouchUtils::flush(window.data());
// Touch on left, then background
@@ -1359,7 +1381,7 @@ void tst_TouchMouse::touchPointDeliveryOrder()
events.clear();
// New press events are deliverd first, the stationary point was not accepted, thus it doesn't get delivered
- QTest::touchEvent(window.data(), device).stationary(0).press(1, pRightMiddle, window.data());
+ touchSeq.stationary(0).press(1, pRightMiddle, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(events.size(), 3);
QCOMPARE(events.at(0), middle);
@@ -1367,49 +1389,49 @@ void tst_TouchMouse::touchPointDeliveryOrder()
QCOMPARE(events.at(2), background);
events.clear();
- QTest::touchEvent(window.data(), device).release(0, pLeft, window.data()).release(1, pRightMiddle, window.data());
+ touchSeq.release(0, pLeft, window.data()).release(1, pRightMiddle, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(events.size(), 0); // no accepted events
// Two presses, the first point should come first
- QTest::touchEvent(window.data(), device).press(0, pLeft, window.data()).press(1, pRight, window.data());
+ touchSeq.press(0, pLeft, window.data()).press(1, pRight, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(events.size(), 3);
QCOMPARE(events.at(0), left);
QCOMPARE(events.at(1), right);
QCOMPARE(events.at(2), background);
- QTest::touchEvent(window.data(), device).release(0, pLeft, window.data()).release(1, pRight, window.data());
+ touchSeq.release(0, pLeft, window.data()).release(1, pRight, window.data()).commit();
events.clear();
// Again, pressing right first
- QTest::touchEvent(window.data(), device).press(0, pRight, window.data()).press(1, pLeft, window.data());
+ touchSeq.press(0, pRight, window.data()).press(1, pLeft, window.data()).commit();
QQuickTouchUtils::flush(window.data());
QCOMPARE(events.size(), 3);
QCOMPARE(events.at(0), right);
QCOMPARE(events.at(1), left);
QCOMPARE(events.at(2), background);
- QTest::touchEvent(window.data(), device).release(0, pRight, window.data()).release(1, pLeft, window.data());
+ touchSeq.release(0, pRight, window.data()).release(1, pLeft, window.data()).commit();
events.clear();
// Two presses, both hitting the middle item on top, then branching left and right, then bottom
// Each target should be offered the events exactly once, middle first, left must come before right (id 0)
- QTest::touchEvent(window.data(), device).press(0, pLeftMiddle, window.data()).press(1, pRightMiddle, window.data());
+ touchSeq.press(0, pLeftMiddle, window.data()).press(1, pRightMiddle, window.data()).commit();
QCOMPARE(events.size(), 4);
QCOMPARE(events.at(0), middle);
QCOMPARE(events.at(1), left);
QCOMPARE(events.at(2), right);
QCOMPARE(events.at(3), background);
- QTest::touchEvent(window.data(), device).release(0, pLeftMiddle, window.data()).release(1, pRightMiddle, window.data());
+ touchSeq.release(0, pLeftMiddle, window.data()).release(1, pRightMiddle, window.data()).commit();
events.clear();
- QTest::touchEvent(window.data(), device).press(0, pRightMiddle, window.data()).press(1, pLeftMiddle, window.data());
+ touchSeq.press(0, pRightMiddle, window.data()).press(1, pLeftMiddle, window.data()).commit();
qDebug() << events;
QCOMPARE(events.size(), 4);
QCOMPARE(events.at(0), middle);
QCOMPARE(events.at(1), right);
QCOMPARE(events.at(2), left);
QCOMPARE(events.at(3), background);
- QTest::touchEvent(window.data(), device).release(0, pRightMiddle, window.data()).release(1, pLeftMiddle, window.data());
+ touchSeq.release(0, pRightMiddle, window.data()).release(1, pLeftMiddle, window.data()).commit();
}
void tst_TouchMouse::hoverEnabled()
diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro
index 9d909f1d16..0e3f257e33 100644
--- a/tests/auto/quicktest/quicktest.pro
+++ b/tests/auto/quicktest/quicktest.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = \
signalspy \
- quicktestmainwithsetup
+ quicktestmainwithsetup \
+ testfiltering
diff --git a/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.cpp b/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.cpp
new file mode 100644
index 0000000000..656911f842
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(quicktestmain)
diff --git a/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.pro b/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.pro
new file mode 100644
index 0000000000..7b3e734cb4
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/quicktestmain/quicktestmain.pro
@@ -0,0 +1,11 @@
+CONFIG += qmltestcase
+macos:CONFIG -= app_bundle
+TARGET = quicktestmain
+
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${PWD}\\\"
+
+SOURCES += quicktestmain.cpp
+
+TESTDATA += $$PWD/*.qml
+
+DESTDIR = ./
diff --git a/tests/auto/quicktest/testfiltering/quicktestmain/tst_first.qml b/tests/auto/quicktest/testfiltering/quicktestmain/tst_first.qml
new file mode 100644
index 0000000000..55c9612b78
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/quicktestmain/tst_first.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+import QtTest 1.1
+
+TestCase {
+ name: "First"
+
+ function test_foo() { }
+ function test_bar() { }
+ function test_baz() { }
+}
diff --git a/tests/auto/quicktest/testfiltering/quicktestmain/tst_second.qml b/tests/auto/quicktest/testfiltering/quicktestmain/tst_second.qml
new file mode 100644
index 0000000000..2143d93e12
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/quicktestmain/tst_second.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+import QtTest 1.1
+
+TestCase {
+ name: "Second"
+
+ function test_dupfoo() { }
+ function test_dupbar() { }
+ function test_dupbaz() { }
+}
diff --git a/tests/auto/quicktest/testfiltering/test/test.pro b/tests/auto/quicktest/testfiltering/test/test.pro
new file mode 100644
index 0000000000..cecbdca725
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/test/test.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+QT += testlib
+TARGET = ../tst_testfiltering
+
+SOURCES = ../tst_testfiltering.cpp
diff --git a/tests/auto/quicktest/testfiltering/testfiltering.pro b/tests/auto/quicktest/testfiltering/testfiltering.pro
new file mode 100644
index 0000000000..ae7a039b8b
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/testfiltering.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ test \
+ quicktestmain
diff --git a/tests/auto/quicktest/testfiltering/tst_testfiltering.cpp b/tests/auto/quicktest/testfiltering/tst_testfiltering.cpp
new file mode 100644
index 0000000000..72bb8f02b7
--- /dev/null
+++ b/tests/auto/quicktest/testfiltering/tst_testfiltering.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QProcess>
+#include <QtTest>
+
+class tst_TestFiltering : public QObject
+{
+ Q_OBJECT
+private slots:
+ void noFilters();
+ void oneMatchingFilter();
+ void filterThatDoesntMatch();
+ void twoFilters();
+ void twoFiltersWithOneMatch();
+ void manyFilters();
+};
+
+
+const QString testExe =
+#if defined(Q_OS_WIN)
+ QFINDTESTDATA("quicktestmain/quicktestmain.exe");
+#else
+ QFINDTESTDATA("quicktestmain/quicktestmain");
+#endif
+
+void tst_TestFiltering::noFilters()
+{
+ QProcess process;
+ process.start(testExe);
+
+ QVERIFY(process.waitForFinished());
+
+ const QString output = process.readAll();
+ QVERIFY(output.contains(QLatin1String("Totals: 10 passed")));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+}
+
+void tst_TestFiltering::oneMatchingFilter()
+{
+ QProcess process;
+ process.start(testExe, {QLatin1String("First::test_bar")});
+
+ QVERIFY(process.waitForFinished());
+
+ const QString output = process.readAll();
+ QVERIFY(output.contains(QLatin1String("Totals: 3 passed")));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+}
+
+void tst_TestFiltering::filterThatDoesntMatch()
+{
+ QProcess process;
+ process.start(testExe, {QLatin1String("First::test_nonexisting")});
+
+ QVERIFY(process.waitForFinished());
+
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 1);
+}
+
+void tst_TestFiltering::twoFilters()
+{
+ QProcess process;
+ process.start(testExe,
+ {QLatin1String("Second::test_dupfoo"), QLatin1String("Second::test_dupbaz")});
+
+ QVERIFY(process.waitForFinished());
+
+ const QString output = process.readAll();
+ QVERIFY(output.contains(QLatin1String("Totals: 4 passed")));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+}
+
+void tst_TestFiltering::twoFiltersWithOneMatch()
+{
+ QProcess process;
+ process.start(testExe,
+ {QLatin1String("First::test_foo"), QLatin1String("Second::test_nonexisting")});
+
+ QVERIFY(process.waitForFinished());
+
+ const QString output = process.readAll();
+ QVERIFY(output.contains(QLatin1String("Totals: 3 passed")));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 1);
+}
+
+void tst_TestFiltering::manyFilters()
+{
+ QProcess process;
+ process.start(testExe,
+ {QLatin1String("First::test_foo"),
+ QLatin1String("First::test_baz"),
+ QLatin1String("Second::test_dupfoo"),
+ QLatin1String("Second::test_dupbaz")});
+
+ QVERIFY(process.waitForFinished());
+
+ const QString output = process.readAll();
+ QVERIFY(output.contains(QLatin1String("Totals: 8 passed")));
+ QCOMPARE(process.exitStatus(), QProcess::NormalExit);
+ QCOMPARE(process.exitCode(), 0);
+}
+
+QTEST_MAIN(tst_TestFiltering);
+
+#include "tst_testfiltering.moc"
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index af358925fe..e523274d0a 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -614,8 +614,8 @@ void tst_qquickwidget::synthMouseFromTouch()
QTest::touchEvent(&window, device).move(0, p2, &window);
QTest::touchEvent(&window, device).release(0, p2, &window);
- QCOMPARE(item->m_touchEvents.count(), 3);
- QCOMPARE(item->m_mouseEvents.count(), acceptTouch ? 0 : 3);
+ QCOMPARE(item->m_touchEvents.count(), !synthMouse && !acceptTouch ? 1 : 3);
+ QCOMPARE(item->m_mouseEvents.count(), (acceptTouch || !synthMouse) ? 0 : 3);
QCOMPARE(childView->m_mouseEvents.count(), 0);
for (const QMouseEvent &ev : item->m_mouseEvents)
QCOMPARE(ev.source(), Qt::MouseEventSynthesizedByQt);
diff --git a/tests/auto/toolsupport/tst_toolsupport.cpp b/tests/auto/toolsupport/tst_toolsupport.cpp
index 6ee1db805a..eec96f9174 100644
--- a/tests/auto/toolsupport/tst_toolsupport.cpp
+++ b/tests/auto/toolsupport/tst_toolsupport.cpp
@@ -101,7 +101,7 @@ void tst_toolsupport::offsets_data()
= QTest::newRow("CompiledData::CompilationUnit::data")
<< pmm_to_offsetof(&QV4::CompiledData::CompilationUnit::data);
- data << 12 << 24;
+ data << 20 << 40;
}
{
diff --git a/tests/manual/mousearea/main.qml b/tests/manual/mousearea/main.qml
index 6c284c3586..9a3243b670 100644
--- a/tests/manual/mousearea/main.qml
+++ b/tests/manual/mousearea/main.qml
@@ -26,9 +26,8 @@
**
****************************************************************************/
-import QtQuick 2.8
+import QtQuick 2.12
import QtQuick.Window 2.2
-import Qt.labs.handlers 1.0
import "qrc:/quick/shared/" as Examples
Window {
diff --git a/tests/manual/pointer/content/CheckBox.qml b/tests/manual/pointer/content/CheckBox.qml
index 477be56f05..3702457ee9 100644
--- a/tests/manual/pointer/content/CheckBox.qml
+++ b/tests/manual/pointer/content/CheckBox.qml
@@ -25,8 +25,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import Qt.labs.handlers 1.0
+
+import QtQuick 2.12
Row {
id: root
diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml
index dbcf48d2f7..ffb5c4e914 100644
--- a/tests/manual/pointer/content/FakeFlickable.qml
+++ b/tests/manual/pointer/content/FakeFlickable.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
@@ -68,7 +67,7 @@ Item {
DragHandler {
id: dragHandler
- onActiveChanged: if (!active) anim.restart(point.velocity)
+ onActiveChanged: if (!active) anim.restart(centroid.velocity)
}
MomentumAnimation {
id: anim
diff --git a/tests/manual/pointer/content/FlashAnimation.qml b/tests/manual/pointer/content/FlashAnimation.qml
index 4b2935b52e..57817e9aee 100644
--- a/tests/manual/pointer/content/FlashAnimation.qml
+++ b/tests/manual/pointer/content/FlashAnimation.qml
@@ -26,7 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
SequentialAnimation {
id: tapFlash
diff --git a/tests/manual/pointer/content/MomentumAnimation.qml b/tests/manual/pointer/content/MomentumAnimation.qml
index bd21475970..ae42f906a1 100644
--- a/tests/manual/pointer/content/MomentumAnimation.qml
+++ b/tests/manual/pointer/content/MomentumAnimation.qml
@@ -26,7 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
+import QtQuick 2.12
ParallelAnimation {
id: root
diff --git a/tests/manual/pointer/content/MouseAreaButton.qml b/tests/manual/pointer/content/MouseAreaButton.qml
index 43337520a5..f75b8f9c56 100644
--- a/tests/manual/pointer/content/MouseAreaButton.qml
+++ b/tests/manual/pointer/content/MouseAreaButton.qml
@@ -26,8 +26,8 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtQuick.Window 2.1
+import QtQuick 2.12
+import QtQuick.Window 2.12
Item {
id: container
diff --git a/tests/manual/pointer/content/MouseAreaSlider.qml b/tests/manual/pointer/content/MouseAreaSlider.qml
index 4e2cfee6a9..e784e959b1 100644
--- a/tests/manual/pointer/content/MouseAreaSlider.qml
+++ b/tests/manual/pointer/content/MouseAreaSlider.qml
@@ -26,7 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.7
+import QtQuick 2.12
Item {
id: root
diff --git a/tests/manual/pointer/content/MouseFeedbackSprite.qml b/tests/manual/pointer/content/MouseFeedbackSprite.qml
index c61a07b3ea..d3068ff503 100644
--- a/tests/manual/pointer/content/MouseFeedbackSprite.qml
+++ b/tests/manual/pointer/content/MouseFeedbackSprite.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
PointHandler {
id: handler
diff --git a/tests/manual/pointer/content/MptaButton.qml b/tests/manual/pointer/content/MptaButton.qml
index a35446632d..ed8702b9b3 100644
--- a/tests/manual/pointer/content/MptaButton.qml
+++ b/tests/manual/pointer/content/MptaButton.qml
@@ -26,8 +26,8 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Window 2.1
+import QtQuick 2.12
+import QtQuick.Window 2.12
Item {
id: container
diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml
index 2a41967a36..485784a875 100644
--- a/tests/manual/pointer/content/MultiButton.qml
+++ b/tests/manual/pointer/content/MultiButton.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
@@ -35,6 +34,7 @@ Rectangle {
property alias pressed: tap.pressed
property bool checked: false
property alias gesturePolicy: tap.gesturePolicy
+ property alias margin: tap.margin
signal tapped
width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0
diff --git a/tests/manual/pointer/content/ScrollBar.qml b/tests/manual/pointer/content/ScrollBar.qml
index e659c5d7af..9928433d1f 100644
--- a/tests/manual/pointer/content/ScrollBar.qml
+++ b/tests/manual/pointer/content/ScrollBar.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml
index 1741fb1bc6..c381d97c7c 100644
--- a/tests/manual/pointer/content/Slider.qml
+++ b/tests/manual/pointer/content/Slider.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
id: root
diff --git a/tests/manual/pointer/content/TapHandlerButton.qml b/tests/manual/pointer/content/TapHandlerButton.qml
index 28187044c2..2dc1d78a6f 100644
--- a/tests/manual/pointer/content/TapHandlerButton.qml
+++ b/tests/manual/pointer/content/TapHandlerButton.qml
@@ -26,9 +26,8 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Window 2.1
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
+import QtQuick.Window 2.12
Item {
id: container
diff --git a/tests/manual/pointer/content/TextBox.qml b/tests/manual/pointer/content/TextBox.qml
index 0fbfaf02e3..b59c21379f 100644
--- a/tests/manual/pointer/content/TextBox.qml
+++ b/tests/manual/pointer/content/TextBox.qml
@@ -25,7 +25,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
+
+import QtQuick 2.12
Rectangle {
id: r1
diff --git a/tests/manual/pointer/content/TouchpointFeedbackSprite.qml b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml
index ffcead59d4..bee3b8b795 100644
--- a/tests/manual/pointer/content/TouchpointFeedbackSprite.qml
+++ b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml
@@ -48,8 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
PointHandler {
id: handler
diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml
index bde378c33d..284e0d1f34 100644
--- a/tests/manual/pointer/fakeFlickable.qml
+++ b/tests/manual/pointer/fakeFlickable.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
diff --git a/tests/manual/pointer/flickableWithHandlers.qml b/tests/manual/pointer/flickableWithHandlers.qml
index 28009a7024..08cedb9a16 100644
--- a/tests/manual/pointer/flickableWithHandlers.qml
+++ b/tests/manual/pointer/flickableWithHandlers.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.7
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "qrc:/quick/shared/" as Examples
import "content"
diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml
index 3b0d359530..2bc6de7065 100644
--- a/tests/manual/pointer/flingAnimation.qml
+++ b/tests/manual/pointer/flingAnimation.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
@@ -91,7 +90,7 @@ Rectangle {
objectName: "dragHandler" + index
onActiveChanged: {
if (!active)
- anim.restart(point.velocity)
+ anim.restart(centroid.velocity)
}
}
Rectangle {
@@ -104,12 +103,12 @@ Rectangle {
Rectangle {
visible: width > 0
- width: dragHandler.point.velocity.length() * 100
+ width: dragHandler.centroid.velocity.length() * 100
height: 2
x: ball.width / 2
y: ball.height / 2
z: -1
- rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI
+ rotation: Math.atan2(dragHandler.centroid.velocity.y, dragHandler.centroid.velocity.x) * 180 / Math.PI
transformOrigin: Item.BottomLeft
antialiasing: true
diff --git a/tests/manual/pointer/joystick.qml b/tests/manual/pointer/joystick.qml
index f5be17ddc9..c8880f9100 100644
--- a/tests/manual/pointer/joystick.qml
+++ b/tests/manual/pointer/joystick.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.10
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: image.implicitWidth; height: image.implicitHeight
diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml
index bd9097c517..d382d8b23d 100644
--- a/tests/manual/pointer/main.qml
+++ b/tests/manual/pointer/main.qml
@@ -26,10 +26,9 @@
**
****************************************************************************/
-import QtQuick 2.8
-import QtQuick.Window 2.2
+import QtQuick 2.12
+import QtQuick.Window 2.12
import QtQuick.Layouts 1.2
-import Qt.labs.handlers 1.0
import org.qtproject.Test 1.0
import "qrc:/quick/shared/" as Examples
import "content"
@@ -45,6 +44,7 @@ Window {
anchors.fill: parent
Component.onCompleted: {
addExample("single point handler", "QQuickPointerSingleHandler: test properties copied from events", Qt.resolvedUrl("singlePointHandlerProperties.qml"))
+ addExample("hover", "ensure that a hierarchy of items can share the hover state", Qt.resolvedUrl("sidebar.qml"))
addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml"))
addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml"))
addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml"))
diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml
index 6ab6badfd0..c400874d58 100644
--- a/tests/manual/pointer/map.qml
+++ b/tests/manual/pointer/map.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the manual tests of the Qt Toolkit.
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
@@ -40,6 +39,7 @@ Item {
y: (parent.height - height) / 2
width: image.width
height: image.height
+ transform: Rotation { id: tilt; origin.x: width / 2; origin.y: height / 2; axis { x: 1; y: 0; z: 0 } }
Image {
id: image
@@ -48,18 +48,39 @@ Item {
source: "resources/map.svgz"
Component.onCompleted: { width = implicitWidth; height = implicitHeight }
}
+
+ Text {
+ anchors.centerIn: parent
+ text: image.sourceSize.width + " x " + image.sourceSize.height +
+ " scale " + map.scale.toFixed(2) + " active scale " + pinch.activeScale.toFixed(2)
+ }
+ }
+
+ DragHandler {
+ objectName: "single-point drag"
+ target: map
+ }
+
+ DragHandler {
+ id: tiltHandler
+ objectName: "two-point tilt"
+ minimumPointCount: 2
+ maximumPointCount: 2
+ xAxis.enabled: false
+ target: null
+ onTranslationChanged: tilt.angle = translation.y / -2
}
PinchHandler {
id: pinch
+ objectName: "two-point pinch"
target: map
minimumScale: 0.1
maximumScale: 10
+ xAxis.enabled: false
+ yAxis.enabled: false
onActiveChanged: if (!active) reRenderIfNecessary()
- }
-
- DragHandler {
- target: map
+ grabPermissions: PinchHandler.TakeOverForbidden // don't allow takeover if pinch has started
}
function reRenderIfNecessary() {
diff --git a/tests/manual/pointer/map2.qml b/tests/manual/pointer/map2.qml
index 4d8755b996..0f45013e92 100644
--- a/tests/manual/pointer/map2.qml
+++ b/tests/manual/pointer/map2.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 640
diff --git a/tests/manual/pointer/mixer.qml b/tests/manual/pointer/mixer.qml
index 64c4b102d1..6044b59633 100644
--- a/tests/manual/pointer/mixer.qml
+++ b/tests/manual/pointer/mixer.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
diff --git a/tests/manual/pointer/multibuttons.qml b/tests/manual/pointer/multibuttons.qml
index cd7c5d0b19..d143134a3a 100644
--- a/tests/manual/pointer/multibuttons.qml
+++ b/tests/manual/pointer/multibuttons.qml
@@ -26,10 +26,9 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.12
import QtQuick.Particles 2.0
import QtQuick.Layouts 1.0
-import Qt.labs.handlers 1.0
import "content"
Item {
@@ -44,6 +43,7 @@ Item {
label: "Launch Balloons"
Layout.fillWidth: true
gesturePolicy: TapHandler.WithinBounds
+ margin: 10
}
Text { text: "the goons"; font.pointSize: 12 }
MultiButton {
@@ -51,6 +51,7 @@ Item {
label: "Launch Missile"
Layout.fillWidth: true
gesturePolicy: TapHandler.ReleaseWithinBounds
+ margin: 10
onTapped: missileEmitter.burst(1)
}
MultiButton {
@@ -58,6 +59,7 @@ Item {
label: "Launch Fighters"
Layout.fillWidth: true
gesturePolicy: TapHandler.DragThreshold
+ margin: 10
}
}
ParticleSystem {
diff --git a/tests/manual/pointer/photosurface.qml b/tests/manual/pointer/photosurface.qml
index 04aef538f9..57ad12788e 100644
--- a/tests/manual/pointer/photosurface.qml
+++ b/tests/manual/pointer/photosurface.qml
@@ -26,10 +26,9 @@
**
****************************************************************************/
-import QtQuick 2.8
+import QtQuick 2.12
import QtQuick.Dialogs 1.0
import Qt.labs.folderlistmodel 1.0
-import Qt.labs.handlers 1.0
import "content"
Rectangle {
diff --git a/tests/manual/pointer/pinchDragFlingMPTA.qml b/tests/manual/pointer/pinchDragFlingMPTA.qml
index 2578d62466..b68c6cb8c1 100644
--- a/tests/manual/pointer/pinchDragFlingMPTA.qml
+++ b/tests/manual/pointer/pinchDragFlingMPTA.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
@@ -66,7 +65,7 @@ Rectangle {
minimumPointCount: 3
minimumScale: 0.1
maximumScale: 10
- onActiveChanged: if (!active) fling.restart(centroidVelocity)
+ onActiveChanged: if (!active) fling.restart(centroid.velocity)
}
DragHandler {
id: dragHandler
diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml
index 409b852b55..8ef6623f7f 100644
--- a/tests/manual/pointer/pinchHandler.qml
+++ b/tests/manual/pointer/pinchHandler.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
@@ -153,7 +152,7 @@ Rectangle {
maximumScale: 10
onActiveChanged: {
if (!active)
- anim.restart(centroidVelocity)
+ anim.restart(centroid.velocity)
}
}
TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect3.z = rect2.z + 1 }
@@ -164,8 +163,8 @@ Rectangle {
Rectangle {
id: centroidIndicator
property QtObject pincher: activePincher()
- x: pincher.centroid.x - radius
- y: pincher.centroid.y - radius
+ x: pincher.centroid.scenePosition.x - radius
+ y: pincher.centroid.scenePosition.y - radius
z: 1
visible: pincher.active
radius: width / 2
diff --git a/tests/manual/pointer/pointerDrag.qml b/tests/manual/pointer/pointerDrag.qml
index f3fbe66339..79044eb0b4 100644
--- a/tests/manual/pointer/pointerDrag.qml
+++ b/tests/manual/pointer/pointerDrag.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.0
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "content"
Rectangle {
diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc
index 11f64e156e..95bece180a 100644
--- a/tests/manual/pointer/qml.qrc
+++ b/tests/manual/pointer/qml.qrc
@@ -12,6 +12,7 @@
<file>pinchHandler.qml</file>
<file>pointerDrag.qml</file>
<file>singlePointHandlerProperties.qml</file>
+ <file>sidebar.qml</file>
<file>tapHandler.qml</file>
<file>content/CheckBox.qml</file>
<file>content/FakeFlickable.qml</file>
diff --git a/tests/manual/pointer/sidebar.qml b/tests/manual/pointer/sidebar.qml
new file mode 100644
index 0000000000..827dbd1980
--- /dev/null
+++ b/tests/manual/pointer/sidebar.qml
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the manual tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import "content"
+
+Rectangle {
+ id: root
+ width: 640
+ height: 480
+ color: "#444"
+
+ Component {
+ id: buttonsAndStuff
+ Column {
+ anchors.fill: parent
+ anchors.margins: 8
+ spacing: 8
+
+ Rectangle {
+ objectName: "buttonWithMA"
+ width: parent.width
+ height: 30
+ color: buttonMA.pressed ? "lightsteelblue" : "#999"
+ border.color: buttonMA.containsMouse ? "cyan" : "transparent"
+
+ MouseArea {
+ id: buttonMA
+ objectName: "buttonMA"
+ hoverEnabled: true
+ anchors.fill: parent
+ onClicked: console.log("clicked MA")
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "MouseArea"
+ }
+ }
+
+ Rectangle {
+ objectName: "buttonWithHH"
+ width: parent.width
+ height: 30
+ color: flash ? "#999" : "white"
+ border.color: buttonHH.hovered ? "cyan" : "transparent"
+ property bool flash: true
+
+ HoverHandler {
+ id: buttonHH
+ objectName: "buttonHH"
+ acceptedDevices: PointerDevice.AllDevices
+ }
+
+ TapHandler {
+ onTapped: tapFlash.start()
+ }
+
+ Text {
+ anchors.centerIn: parent
+ text: "HoverHandler"
+ }
+
+ FlashAnimation on flash {
+ id: tapFlash
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: paddle
+ width: 100
+ height: 40
+ color: paddleHH.hovered ? "indianred" : "#888"
+ y: parent.height - 100
+ radius: 10
+
+ HoverHandler {
+ id: paddleHH
+ objectName: "paddleHH"
+ }
+
+ SequentialAnimation on x {
+ NumberAnimation {
+ to: root.width - paddle.width
+ duration: 2000
+ easing { type: Easing.InOutQuad }
+ }
+ PauseAnimation { duration: 100 }
+ NumberAnimation {
+ to: 0
+ duration: 2000
+ easing { type: Easing.InOutQuad }
+ }
+ PauseAnimation { duration: 100 }
+ loops: Animation.Infinite
+ }
+ }
+
+ Rectangle {
+ objectName: "topSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ y: -radius
+ width: 120
+ height: 200
+ border.color: topSidebarHH.hovered ? "cyan" : "black"
+ color: "#777"
+
+ Rectangle {
+ color: "cyan"
+ width: 10
+ height: width
+ radius: width / 2
+ visible: topSidebarHH.hovered
+ x: topSidebarHH.point.position.x - width / 2
+ y: topSidebarHH.point.position.y - height / 2
+ z: 100
+ }
+
+ HoverHandler {
+ id: topSidebarHH
+ objectName: "topSidebarHH"
+ }
+
+ Loader {
+ objectName: "topSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+
+ Rectangle {
+ objectName: "bottomSidebar"
+ radius: 5
+ antialiasing: true
+ x: -radius
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: -radius
+ width: 120
+ height: 200
+ border.color: bottomSidebarMA.containsMouse ? "cyan" : "black"
+ color: "#777"
+
+ MouseArea {
+ id: bottomSidebarMA
+ objectName: "bottomSidebarMA"
+ hoverEnabled: true
+ anchors.fill: parent
+ }
+
+ Loader {
+ objectName: "bottomSidebarLoader"
+ sourceComponent: buttonsAndStuff
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml
index c11042cf14..71bff2d829 100644
--- a/tests/manual/pointer/singlePointHandlerProperties.qml
+++ b/tests/manual/pointer/singlePointHandlerProperties.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.9
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Rectangle {
id: root
@@ -37,11 +36,11 @@ Rectangle {
Item {
id: crosshairs
- x: dragHandler.point.position.x - width / 2
- y: dragHandler.point.position.y - height / 2
+ x: pointHandler.point.position.x - width / 2
+ y: pointHandler.point.position.y - height / 2
width: parent.width / 2; height: parent.height / 2
- visible: dragHandler.active
- rotation: dragHandler.point.rotation
+ visible: pointHandler.active
+ rotation: pointHandler.point.rotation
Rectangle {
color: "goldenrod"
@@ -57,21 +56,22 @@ Rectangle {
}
Rectangle {
color: "goldenrod"
- width: Math.max(2, 50 * dragHandler.point.pressure)
+ width: Math.max(2, 50 * pointHandler.point.pressure)
height: width
radius: width / 2
anchors.centerIn: parent
antialiasing: true
Rectangle {
- y: -40
+ y: -56
anchors.horizontalCenter: parent.horizontalCenter
color: "lightsteelblue"
implicitWidth: label.implicitWidth
implicitHeight: label.implicitHeight
Text {
id: label
- text: 'id: ' + dragHandler.point.id.toString(16) + " uid: " + dragHandler.point.uniqueId.numericId +
- '\npos: (' + dragHandler.point.position.x.toFixed(2) + ', ' + dragHandler.point.position.y.toFixed(2) + ')'
+ text: 'id: ' + pointHandler.point.id.toString(16) + " uid: " + pointHandler.point.uniqueId.numericId +
+ '\npos: (' + pointHandler.point.position.x.toFixed(2) + ', ' + pointHandler.point.position.y.toFixed(2) + ')' +
+ '\nmodifiers: ' + pointHandler.point.modifiers.toString(16)
}
}
}
@@ -79,8 +79,8 @@ Rectangle {
color: "transparent"
border.color: "white"
antialiasing: true
- width: dragHandler.point.ellipseDiameters.width
- height: dragHandler.point.ellipseDiameters.height
+ width: pointHandler.point.ellipseDiameters.width
+ height: pointHandler.point.ellipseDiameters.height
radius: Math.min(width / 2, height / 2)
anchors.centerIn: parent
}
@@ -88,11 +88,11 @@ Rectangle {
Rectangle {
id: velocityVector
visible: width > 0
- width: dragHandler.point.velocity.length() * 100
+ width: pointHandler.point.velocity.length() * 100
height: 2
- x: dragHandler.point.position.x
- y: dragHandler.point.position.y
- rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI
+ x: pointHandler.point.position.x
+ y: pointHandler.point.position.y
+ rotation: Math.atan2(pointHandler.point.velocity.y, pointHandler.point.velocity.x) * 180 / Math.PI
transformOrigin: Item.BottomLeft
antialiasing: true
@@ -135,8 +135,8 @@ Rectangle {
}
}
- DragHandler {
- id: dragHandler
+ PointHandler {
+ id: pointHandler
target: null
acceptedButtons: Qt.AllButtons
onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance
@@ -144,7 +144,7 @@ Rectangle {
grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16})
}
onPointChanged: {
- // Here, 'point' is referring to the property of the DragHandler
+ // Here, 'point' is referring to the property of the PointHandler
if (point.pressedButtons)
mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons})
}
diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml
index 94777c268c..8c1fac9a2f 100644
--- a/tests/manual/pointer/tapHandler.qml
+++ b/tests/manual/pointer/tapHandler.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the manual tests of the Qt Toolkit.
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
import "qrc:/quick/shared/" as Examples
Item {
@@ -54,18 +53,20 @@ Item {
borderBlink.blinkColor = "red"
borderBlink.start()
}
- onTapped: { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance
+ onTapped: { // 'eventPoint' is a signal parameter of type QQuickEventPoint*
+ console.log("tapped button " + eventPoint.event.button + " @ " + eventPoint.scenePosition +
+ " on device '" + eventPoint.event.device.name + "' " + (tapCount > 1 ? (tapCount + " times") : "for the first time"))
if (tapCount > 1) {
tapCountLabel.text = tapCount
flashAnimation.start()
} else {
- borderBlink.start()
+ borderBlink.tapFeedback(eventPoint.event.button)
}
}
onLongPressed: longPressFeedback.createObject(rect,
{"x": point.position.x, "y": point.position.y,
- "text": Math.round(handler.timeHeld).toFixed(3) + " sec",
- "color": borderBlink.blinkColor})
+ "text": handler.timeHeld.toFixed(3) + " sec",
+ "color": buttonToBlinkColor(point.pressedButtons)})
}
Text {
@@ -100,7 +101,7 @@ Item {
radius: handler.timeHeld * 100
visible: radius > 0 && handler.pressed
border.width: 3
- border.color: borderBlink.blinkColor
+ border.color: buttonToBlinkColor(handler.point.pressedButtons)
color: "transparent"
width: radius * 2
height: radius * 2
@@ -116,13 +117,11 @@ Item {
SequentialAnimation {
id: borderBlink
- property color blinkColor: (function(pbtns) {
- switch (pbtns) {
- case Qt.MiddleButton: return "orange";
- case Qt.RightButton: return "magenta";
- default: return "green";
- }
- })(handler.point.pressedButtons)
+ property color blinkColor: "red"
+ function tapFeedback(button) {
+ blinkColor = buttonToBlinkColor(button);
+ start();
+ }
loops: 3
ScriptAction { script: rect.border.color = borderBlink.blinkColor }
PauseAnimation { duration: 100 }
@@ -131,6 +130,14 @@ Item {
}
}
+ function buttonToBlinkColor(button) {
+ switch (button) {
+ case Qt.MiddleButton: return "orange";
+ case Qt.RightButton: return "magenta";
+ default: return "green";
+ }
+ }
+
Row {
spacing: 6
Text { text: "accepted mouse clicks:"; anchors.verticalCenter: leftAllowedCB.verticalCenter }
diff --git a/tests/manual/pointer/tapWithModifiers.qml b/tests/manual/pointer/tapWithModifiers.qml
index 74db33125d..8ca1c1bd63 100644
--- a/tests/manual/pointer/tapWithModifiers.qml
+++ b/tests/manual/pointer/tapWithModifiers.qml
@@ -26,8 +26,7 @@
**
****************************************************************************/
-import QtQuick 2.8
-import Qt.labs.handlers 1.0
+import QtQuick 2.12
Item {
width: 200
diff --git a/tests/manual/qmlplugindump/qmlplugindump.pro b/tests/manual/qmlplugindump/qmlplugindump.pro
index b072cdc0cf..51a5e82781 100644
--- a/tests/manual/qmlplugindump/qmlplugindump.pro
+++ b/tests/manual/qmlplugindump/qmlplugindump.pro
@@ -4,5 +4,7 @@ QT += testlib gui-private
osx:CONFIG -= app_bundle
CONFIG += parallel_test
+DEFINES += QT_TEST_DIR=\\\"$${_PRO_FILE_PWD_}/\\\"
+
SOURCES += tst_qmlplugindump.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
index 1bedd4427b..c5047a63a7 100644
--- a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
+++ b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
@@ -273,7 +273,7 @@ tst_qmlplugindump::tst_qmlplugindump()
QString tst_qmlplugindump::samplePath(const QString &name)
{
- return QCoreApplication::applicationDirPath()
+ return QT_TEST_DIR
+ QLatin1Char('/')
+ QString(QLatin1String(prefix)).replace(QRegularExpression(QLatin1String("\\.")),
QLatin1String("/")).append(name);
@@ -282,7 +282,7 @@ QString tst_qmlplugindump::samplePath(const QString &name)
bool tst_qmlplugindump::compileSample(const QString &name)
{
const QString path = samplePath(name);
- return run(path, QLatin1String("qmake"))
+ return run(path, QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmake"))
&& run(path, QLatin1String(systemMakeProgram));
}
@@ -305,8 +305,7 @@ bool tst_qmlplugindump::cleanUpSample(const QString &name)
void tst_qmlplugindump::initTestCase()
{
dumper = QLibraryInfo::location(QLibraryInfo::BinariesPath);
- tests = readAllTestDefinitions(QCoreApplication::applicationDirPath()
- + QLatin1String("/definitions"));
+ tests = readAllTestDefinitions(QT_TEST_DIR "/definitions");
dumper += QLatin1Char('/') + QLatin1String(systemQmlplugindumpProgram);
@@ -322,7 +321,7 @@ void tst_qmlplugindump::builtins()
QStringList args;
args += QLatin1String("-builtins");
RegexpsChecker check(QStringList(QLatin1String("Module {")));
- QString cwd = QCoreApplication::applicationDirPath();
+ QString cwd = QT_TEST_DIR;
QVERIFY(run(cwd, dumper, args, &check));
}
@@ -349,7 +348,7 @@ void tst_qmlplugindump::plugin()
QStringList args;
QString url = QLatin1String("tests.dumper.") + project;
- QString cwd = QCoreApplication::applicationDirPath();
+ QString cwd = QT_TEST_DIR;
args << QLatin1String("-nonrelocatable") << url << version << cwd;
RegexpsChecker check(expected);
QVERIFY(run(cwd, dumper, args, &check));
diff --git a/tests/manual/tableview/abstracttablemodel/Button.qml b/tests/manual/tableview/abstracttablemodel/Button.qml
new file mode 100644
index 0000000000..2d4dcde80d
--- /dev/null
+++ b/tests/manual/tableview/abstracttablemodel/Button.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+
+Rectangle {
+ width: 100
+ height: 40
+ border.width: 1
+ color: "lightgreen"
+
+ property string text
+ signal clicked
+
+ Text {
+ anchors.centerIn: parent
+ text: parent.text
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+}
diff --git a/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro b/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro
new file mode 100644
index 0000000000..fee8edc6c8
--- /dev/null
+++ b/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = tableview_abstracttablemodel
+QT += qml quick
+SOURCES += main.cpp
+RESOURCES += main.qml Button.qml
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/tests/manual/tableview/abstracttablemodel/main.cpp b/tests/manual/tableview/abstracttablemodel/main.cpp
new file mode 100644
index 0000000000..4fba938ee9
--- /dev/null
+++ b/tests/manual/tableview/abstracttablemodel/main.cpp
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QAbstractTableModel>
+#include <QSet>
+#include <QDebug>
+
+typedef QPair<QString, bool> CellData;
+
+class TestTableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
+
+public:
+ TestTableModel(QObject *parent = nullptr) : QAbstractTableModel(parent) { }
+
+ int rowCount(const QModelIndex & = QModelIndex()) const override { return m_rows; }
+ void setRowCount(int count) {
+ beginResetModel();
+ m_rows = count;
+ rebuildModel();
+ emit rowCountChanged();
+ endResetModel();
+ }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override { return m_cols; }
+ void setColumnCount(int count) {
+ beginResetModel();
+ m_cols = count;
+ rebuildModel();
+ emit columnCountChanged();
+ endResetModel();
+ }
+
+ int indexValue(const QModelIndex &index) const
+ {
+ return index.row() + (index.column() * rowCount());
+ }
+
+ void rebuildModel()
+ {
+ m_modelData = QVector<QVector<CellData>>(m_cols);
+ for (int x = 0; x < m_cols; ++x) {
+ m_modelData[x] = QVector<CellData>(m_rows);
+ for (int y = 0; y < m_rows; ++y)
+ m_modelData[x][y] = qMakePair(QStringLiteral("white"), false);
+ }
+ }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ if (!index.isValid())
+ return QVariant();
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return m_modelData[index.column()][index.row()].first;
+ case Qt::CheckStateRole:
+ return m_modelData[index.column()][index.row()].second;
+ default:
+ return QVariant();
+ }
+
+ return QVariant();
+ }
+
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole) override
+ {
+ if (role != Qt::CheckStateRole)
+ return false;
+
+ bool checked = value.toBool();
+ auto &cellData = m_modelData[index.column()][index.row()];
+ if (checked == cellData.second)
+ return false;
+
+ cellData.second = checked;
+
+ emit dataChanged(index, index, {role});
+ return true;
+ }
+
+ QHash<int, QByteArray> roleNames() const override
+ {
+ return {
+ {Qt::DisplayRole, "display"},
+ {Qt::CheckStateRole, "checked"}
+ };
+ }
+
+ Q_INVOKABLE void insertRows(int row, int count)
+ {
+ insertRows(row, count, QModelIndex());
+ }
+
+ Q_INVOKABLE void removeRows(int row, int count)
+ {
+ removeRows(row, count, QModelIndex());
+ }
+
+ Q_INVOKABLE void insertColumns(int column, int count)
+ {
+ insertColumns(column, count, QModelIndex());
+ }
+
+ Q_INVOKABLE void removeColumns(int column, int count)
+ {
+ removeColumns(column, count, QModelIndex());
+ }
+
+ bool insertRows(int row, int count, const QModelIndex &) override
+ {
+ if (row > m_rows)
+ return false;
+
+ beginInsertRows(QModelIndex(), row, row + count - 1);
+
+ m_rows += count;
+
+ for (int y = 0; y < count; ++y) {
+ for (int x = 0; x < m_cols; ++x)
+ m_modelData[x].insert(row, qMakePair(QStringLiteral("lightgreen"), false));
+ }
+
+ endInsertRows();
+
+ return true;
+ }
+
+ bool removeRows(int row, int count, const QModelIndex &) override
+ {
+ if (row + count > m_rows)
+ count = m_rows - row;
+ if (count < 1)
+ return false;
+
+ beginRemoveRows(QModelIndex(), row, row + count - 1);
+
+ m_rows -= count;
+
+ for (int y = 0; y < count; ++y) {
+ for (int x = 0; x < m_cols; ++x)
+ m_modelData[x].remove(row);
+ }
+
+ endRemoveRows();
+
+ return true;
+ }
+
+ bool insertColumns(int column, int count, const QModelIndex &) override
+ {
+ if (column > m_cols)
+ return false;
+
+ beginInsertColumns(QModelIndex(), column, column + count - 1);
+
+ m_cols += count;
+
+ for (int x = 0; x < count; ++x) {
+ const int c = column + x;
+ m_modelData.insert(c, QVector<CellData>(m_rows));
+ for (int y = 0; y < m_rows; ++y)
+ m_modelData[c][y] = qMakePair(QStringLiteral("lightblue"), false);
+ }
+
+ endInsertColumns();
+
+ return true;
+ }
+
+ bool removeColumns(int column, int count, const QModelIndex &) override
+ {
+ if (column + count > m_cols)
+ count = m_cols - column;
+ if (count < 1)
+ return false;
+
+ beginRemoveColumns(QModelIndex(), column, column + count - 1);
+
+ m_cols -= count;
+
+ for (int x = 0; x < count; ++x)
+ m_modelData.remove(column + x);
+
+ endRemoveColumns();
+
+ return true;
+ }
+
+signals:
+ void rowCountChanged();
+ void columnCountChanged();
+
+private:
+ int m_rows = 0;
+ int m_cols = 0;
+
+ QVector<QVector<CellData>> m_modelData;
+};
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<TestTableModel>("TestTableModel", 0, 1, "TestTableModel");
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml
new file mode 100644
index 0000000000..52967a1a0d
--- /dev/null
+++ b/tests/manual/tableview/abstracttablemodel/main.qml
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import QtQml.Models 2.2
+import TestTableModel 0.1
+
+Window {
+ id: window
+ width: 640
+ height: 480
+ visible: true
+
+ property int selectedX: -1
+ property int selectedY: -1
+
+ TestTableModel {
+ id: tableModel
+ rowCount: 200
+ columnCount: 5000
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 10
+ color: "darkgray"
+
+ Row {
+ id: menu
+ x: 2
+ y: 2
+ spacing: 1
+ Button {
+ text: "Add row"
+ onClicked: tableModel.insertRows(selectedY, 1)
+ }
+ Button {
+ text: "Remove row"
+ onClicked: tableModel.removeRows(selectedY, 1)
+ }
+ Button {
+ text: "Add column"
+ onClicked: tableModel.insertColumns(selectedX, 1)
+ }
+ Button {
+ text: "Remove column"
+ onClicked: tableModel.removeColumns(selectedX, 1)
+ }
+ }
+ Text {
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.margins: 2
+ text: "x:" + selectedX + ", y:" + selectedY
+ }
+
+ TableView {
+ id: tableView
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: menu.bottom
+ anchors.bottom: parent.bottom
+ anchors.margins: 2
+ clip: true
+
+ model: tableModel
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ id: delegate
+ implicitWidth: 100
+ implicitHeight: 50
+ color: display
+ border.width: row === selectedY && column == selectedX ? 2 : 0
+ border.color: "darkgreen"
+
+ Text {
+ anchors.fill: parent
+ text: column + ", " + row
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ selectedX = column
+ selectedY = row
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/tests/manual/tableview/listmodel/listmodel.pro b/tests/manual/tableview/listmodel/listmodel.pro
new file mode 100644
index 0000000000..dbae0db2b1
--- /dev/null
+++ b/tests/manual/tableview/listmodel/listmodel.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = tableview_listmodel
+QT += qml quick
+SOURCES += main.cpp
+RESOURCES += main.qml
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/tests/manual/tableview/listmodel/main.cpp b/tests/manual/tableview/listmodel/main.cpp
new file mode 100644
index 0000000000..2a3b90d392
--- /dev/null
+++ b/tests/manual/tableview/listmodel/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
diff --git a/tests/manual/tableview/listmodel/main.qml b/tests/manual/tableview/listmodel/main.qml
new file mode 100644
index 0000000000..dd0de60555
--- /dev/null
+++ b/tests/manual/tableview/listmodel/main.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import QtQml.Models 2.2
+
+Window {
+ id: window
+ width: 640
+ height: 480
+ visible: true
+
+ ListModel {
+ id: listModel
+ Component.onCompleted: {
+ for (var i = 0; i < 30; ++i)
+ listModel.append({"name" : i})
+ }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 10
+ color: "darkgray"
+
+ TableView {
+ id: tableView
+ anchors.fill: parent
+ anchors.margins: 1
+ clip: true
+ columnSpacing: 1
+ rowSpacing: 1
+ model: listModel
+ delegate: Component {
+ Rectangle {
+ id: tableDelegate
+ implicitWidth: 100
+ implicitHeight: 50
+
+ Text {
+ anchors.centerIn: parent
+ text: name + "\n[" + column + ", " + row + "]"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/manual/tableview/storagemodel/main.cpp b/tests/manual/tableview/storagemodel/main.cpp
new file mode 100644
index 0000000000..97ae619ce4
--- /dev/null
+++ b/tests/manual/tableview/storagemodel/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include "storagemodel.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<StorageModel>("StorageModel", 0, 1, "StorageModel");
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
diff --git a/tests/manual/tableview/storagemodel/main.qml b/tests/manual/tableview/storagemodel/main.qml
new file mode 100644
index 0000000000..2603fba0e2
--- /dev/null
+++ b/tests/manual/tableview/storagemodel/main.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+import StorageModel 0.1
+
+Window {
+ id: window
+ width: 640
+ height: 480
+ visible: true
+ color: "darkgray"
+ title: "Storage Volumes"
+
+ TableView {
+ id: table
+ anchors.fill: parent
+ anchors.margins: 10
+ clip: true
+ model: StorageModel { }
+ columnSpacing: 1
+ rowSpacing: 1
+ delegate: Rectangle {
+ id: tableDelegate
+ implicitWidth: displayText.implicitWidth + 8
+ implicitHeight: displayText.implicitHeight + 14
+
+ Text {
+ id: displayText
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ text: display
+ }
+ }
+ }
+}
diff --git a/tests/manual/tableview/storagemodel/storagemodel.cpp b/tests/manual/tableview/storagemodel/storagemodel.cpp
new file mode 100644
index 0000000000..b6b861a1a8
--- /dev/null
+++ b/tests/manual/tableview/storagemodel/storagemodel.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Ivan Komissarov
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "storagemodel.h"
+
+#include <QDir>
+#include <QLocale>
+#include <qmath.h>
+#include <algorithm>
+#include <cmath>
+
+StorageModel::StorageModel(QObject *parent) :
+ QAbstractTableModel(parent)
+{
+ refresh();
+}
+
+void StorageModel::refresh()
+{
+ beginResetModel();
+ m_volumes = QStorageInfo::mountedVolumes();
+ std::sort(m_volumes.begin(), m_volumes.end(),
+ [](const QStorageInfo &st1, const QStorageInfo &st2) {
+ static const QString rootSortString = QStringLiteral(" ");
+ return (st1.isRoot() ? rootSortString : st1.rootPath())
+ < (st2.isRoot() ? rootSortString : st2.rootPath());
+ });
+ endResetModel();
+}
+
+int StorageModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return int(Column::Count);
+}
+
+int StorageModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ return m_volumes.count();
+}
+
+Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags result = QAbstractTableModel::flags(index);
+ switch (Column(index.column())) {
+ case Column::Available:
+ case Column::IsReady:
+ case Column::IsReadOnly:
+ case Column::IsValid:
+ result |= Qt::ItemIsUserCheckable;
+ break;
+ default:
+ break;
+ }
+ return result;
+}
+
+QVariant StorageModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole) {
+ const QStorageInfo &volume = m_volumes.at(index.row());
+ switch (Column(index.column())) {
+ case Column::RootPath:
+ return QDir::toNativeSeparators(volume.rootPath());
+ case Column::Name:
+ return volume.name();
+ case Column::Device:
+ return volume.device();
+ case Column::FileSystemName:
+ return volume.fileSystemType();
+ case Column::Total:
+ return QLocale().formattedDataSize(volume.bytesTotal());
+ case Column::Free:
+ return QLocale().formattedDataSize(volume.bytesFree());
+ case Column::Available:
+ return QLocale().formattedDataSize(volume.bytesAvailable());
+ case Column::IsReady:
+ return volume.isReady();
+ case Column::IsReadOnly:
+ return volume.isReadOnly();
+ case Column::IsValid:
+ return volume.isValid();
+ default:
+ break;
+ }
+ } else if (role == Qt::CheckStateRole) {
+ const QStorageInfo &volume = m_volumes.at(index.row());
+ switch (Column(index.column())) {
+ case Column::IsReady:
+ return volume.isReady();
+ case Column::IsReadOnly:
+ return volume.isReadOnly();
+ case Column::IsValid:
+ return volume.isValid();
+ default:
+ break;
+ }
+ } else if (role == Qt::TextAlignmentRole) {
+ switch (Column(index.column())) {
+ case Column::Total:
+ case Column::Free:
+ case Column::Available:
+ return Qt::AlignTrailing;
+ default:
+ break;
+ }
+ return Qt::AlignLeading;
+ } else if (role == Qt::ToolTipRole) {
+ QLocale locale;
+ const QStorageInfo &volume = m_volumes.at(index.row());
+ return tr("Root path : %1\n"
+ "Name: %2\n"
+ "Display Name: %3\n"
+ "Device: %4\n"
+ "FileSystem: %5\n"
+ "Total size: %6\n"
+ "Free size: %7\n"
+ "Available size: %8\n"
+ "Is Ready: %9\n"
+ "Is Read-only: %10\n"
+ "Is Valid: %11\n"
+ "Is Root: %12"
+ ).
+ arg(QDir::toNativeSeparators(volume.rootPath())).
+ arg(volume.name()).
+ arg(volume.displayName()).
+ arg(QString::fromUtf8(volume.device())).
+ arg(QString::fromUtf8(volume.fileSystemType())).
+ arg(locale.formattedDataSize(volume.bytesTotal())).
+ arg(locale.formattedDataSize(volume.bytesFree())).
+ arg(locale.formattedDataSize(volume.bytesAvailable())).
+ arg(volume.isReady() ? tr("true") : tr("false")).
+ arg(volume.isReadOnly() ? tr("true") : tr("false")).
+ arg(volume.isValid() ? tr("true") : tr("false")).
+ arg(volume.isRoot() ? tr("true") : tr("false"));
+ }
+ return QVariant();
+}
+
+QVariant StorageModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation != Qt::Horizontal)
+ return QVariant();
+
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ switch (Column(section)) {
+ case Column::RootPath:
+ return tr("Root Path");
+ case Column::Name:
+ return tr("Volume Name");
+ case Column::Device:
+ return tr("Device");
+ case Column::FileSystemName:
+ return tr("File System");
+ case Column::Total:
+ return tr("Total");
+ case Column::Free:
+ return tr("Free");
+ case Column::Available:
+ return tr("Available");
+ case Column::IsReady:
+ return tr("Ready");
+ case Column::IsReadOnly:
+ return tr("Read-only");
+ case Column::IsValid:
+ return tr("Valid");
+ default:
+ break;
+ }
+
+ return QVariant();
+}
diff --git a/examples/quick/views/parallax/parallax.qml b/tests/manual/tableview/storagemodel/storagemodel.h
index 3ca28805c5..1f6f6f8b1f 100644
--- a/examples/quick/views/parallax/parallax.qml
+++ b/tests/manual/tableview/storagemodel/storagemodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Ivan Komissarov
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,39 +49,45 @@
**
****************************************************************************/
-import QtQuick 2.0
-import "content"
+#ifndef STORAGEMODEL_H
+#define STORAGEMODEL_H
-Rectangle {
- width: 320; height: 480
+#include <QAbstractTableModel>
+#include <QStorageInfo>
- ParallaxView {
- id: parallax
- anchors.fill: parent
- background: "content/pics/background.jpg"
+class StorageModel : public QAbstractTableModel
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(StorageModel)
+public:
+ enum class Column : int {
+ RootPath = 0,
+ Name,
+ Device,
+ FileSystemName,
+ Total,
+ Free,
+ Available,
+ IsReady,
+ IsReadOnly,
+ IsValid,
+ Count
+ };
- Item {
- property url icon: "content/pics/yast-wol.png"
- width: 320; height: 480
- Clock { anchors.centerIn: parent }
- }
+ explicit StorageModel(QObject *parent = nullptr);
- Item {
- property url icon: "content/pics/home-page.png"
- width: 320; height: 480
- Smiley { }
- }
+ int columnCount(const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex &parent) const override;
- Item {
- property url icon: "content/pics/yast-joystick.png"
- width: 320; height: 480
+ QVariant data(const QModelIndex &index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- Loader {
- anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter }
- width: 300; height: 400
- clip: true;
- source: "../../demos/samegame/samegame.qml"
- }
- }
- }
-}
+public slots:
+ void refresh();
+
+private:
+ QList<QStorageInfo> m_volumes;
+};
+
+#endif // STORAGEMODEL_H
diff --git a/tests/manual/tableview/storagemodel/storagemodel.pro b/tests/manual/tableview/storagemodel/storagemodel.pro
new file mode 100644
index 0000000000..c6a018239e
--- /dev/null
+++ b/tests/manual/tableview/storagemodel/storagemodel.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = tableview_storage
+QT += qml quick
+SOURCES += main.cpp storagemodel.cpp
+HEADERS += storagemodel.h
+RESOURCES += main.qml
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/tests/manual/tableview/tableview.pro b/tests/manual/tableview/tableview.pro
new file mode 100644
index 0000000000..5040f0e747
--- /dev/null
+++ b/tests/manual/tableview/tableview.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS += abstracttablemodel \
+ listmodel \
+ storagemodel
diff --git a/tests/manual/touch/flicktext.qml b/tests/manual/touch/flicktext.qml
index 6e8dcfded5..9e84261687 100644
--- a/tests/manual/touch/flicktext.qml
+++ b/tests/manual/touch/flicktext.qml
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.4
+import QtQuick 2.12
import "qrc:/quick/shared/" as Examples
Rectangle {
@@ -67,6 +67,7 @@ Rectangle {
contentWidth: text.implicitWidth
contentHeight: text.implicitHeight
pixelAligned: pxAlignCB.checked
+ synchronousDrag: syncDragCB.checked
Text {
id: text
text: "foo bar"
@@ -366,10 +367,15 @@ Rectangle {
}
Column {
+ spacing: 2
Examples.CheckBox {
id: pxAlignCB
text: "pixel aligned"
}
+ Examples.CheckBox {
+ id: syncDragCB
+ text: "synchronous drag"
+ }
Text {
text: "content X " + flick.contentX.toFixed(2) + " Y " + flick.contentY.toFixed(2)
}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 73b2700ba4..7dfae2b53d 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -55,7 +55,9 @@
#include <QLibraryInfo>
#include <qqml.h>
#include <qqmldebug.h>
-#if QT_CONFIG(animation)
+
+#include <private/qtqmlglobal_p.h>
+#if QT_CONFIG(qml_animation)
#include <private/qabstractanimation_p.h>
#endif
@@ -483,7 +485,7 @@ int main(int argc, char *argv[])
break;
else if (arg == QLatin1String("-verbose"))
verboseMode = true;
-#if QT_CONFIG(animation)
+#if QT_CONFIG(qml_animation)
else if (arg == QLatin1String("-slow-animations"))
QUnifiedTimer::instance()->setSlowModeEnabled(true);
else if (arg == QLatin1String("-fixed-animations"))
@@ -533,10 +535,9 @@ int main(int argc, char *argv[])
verboseMode = false;
#if QT_CONFIG(translation)
- //qt_ translations loaded by QQmlApplicationEngine
- QString sysLocale = QLocale::system().name();
-
- if (!translationFile.isEmpty()) { //Note: installed before QQmlApplicationEngine's automatic translation loading
+ // Need to be installed before QQmlApplicationEngine's automatic translation loading
+ // (qt_ translations are loaded there)
+ if (!translationFile.isEmpty()) {
QTranslator translator;
if (translator.load(translationFile)) {
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index 04704f9314..3f41707275 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -1,4 +1,4 @@
-QT = qml core-private
+QT = qml-private core-private
qtHaveModule(gui): QT += gui
qtHaveModule(widgets): QT += widgets
diff --git a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in
index 49ba4edde9..a5c531fb0d 100644
--- a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake
+++ b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in
@@ -2,9 +2,10 @@ include(CMakeParseArguments)
function(QTQUICK_COMPILER_DETERMINE_OUTPUT_FILENAME outvariable filename)
file(RELATIVE_PATH relpath ${CMAKE_CURRENT_SOURCE_DIR} ${filename})
- string(REPLACE ".qml" "_qml" relpath ${relpath})
- string(REPLACE ".js" "_js" relpath ${relpath})
- string(REPLACE "/" "_" relpath ${relpath})
+ string(REPLACE \".qml\" \"_qml\" relpath ${relpath})
+ string(REPLACE \".js\" \"_js\" relpath ${relpath})
+ string(REPLACE \".mjs\" \"_mjs\" relpath ${relpath})
+ string(REPLACE \"/\" \"_\" relpath ${relpath})
set(${outvariable} ${CMAKE_CURRENT_BINARY_DIR}/${relpath}.cpp PARENT_SCOPE)
endfunction()
@@ -13,11 +14,26 @@ function(QTQUICK_COMPILER_ADD_RESOURCES outfiles)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
- cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ cmake_parse_arguments(_RCC \"${options}\" \"${oneValueArgs}\" \"${multiValueArgs}\" ${ARGN})
find_package(Qt5 COMPONENTS Qml Core)
- set(compiler_path "${_qt5Core_install_prefix}/bin/qmlcachegen")
+!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+ set(compiler_path \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmlcachegen$$CMAKE_BIN_SUFFIX\")
+!!ELSE
+ set(compiler_path \"$${CMAKE_BIN_DIR}qmlcachegen$$CMAKE_BIN_SUFFIX\")
+!!ENDIF
+ if(NOT EXISTS \"${compiler_path}\" )
+ message(FATAL_ERROR \"The package \\\"Qt5QuickCompilerConfig\\\" references the file
+ \\\"${compiler_path}\\\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \\\"${CMAKE_CURRENT_LIST_FILE}\\\"
+but not all the files it references.
+\")
+ endif()
get_target_property(rcc_path ${Qt5Core_RCC_EXECUTABLE} IMPORTED_LOCATION)
@@ -37,18 +53,18 @@ function(QTQUICK_COMPILER_ADD_RESOURCES outfiles)
execute_process(COMMAND ${compiler_path} -filter-resource-file ${input_resource} -o ${new_resource_file} OUTPUT_VARIABLE remaining_files)
if(remaining_files)
list(APPEND filtered_rcc_files ${new_resource_file})
- list(APPEND loader_flags "--resource-file-mapping=${_resource}=${new_resource_file}")
+ list(APPEND loader_flags \"--resource-file-mapping=${_resource}=${new_resource_file}\")
else()
- list(APPEND loader_flags "--resource-file-mapping=${_resource}")
+ list(APPEND loader_flags \"--resource-file-mapping=${_resource}\")
endif()
set(rcc_file_with_compilation_units)
- execute_process(COMMAND ${rcc_path} -list "${input_resource}" OUTPUT_VARIABLE rcc_contents)
- string(REGEX REPLACE "[\r\n]+" ";" rcc_contents ${rcc_contents})
+ execute_process(COMMAND ${rcc_path} -list \"${input_resource}\" OUTPUT_VARIABLE rcc_contents)
+ string(REGEX REPLACE \"[\r\n]+\" \";\" rcc_contents ${rcc_contents})
foreach(it ${rcc_contents})
get_filename_component(extension ${it} EXT)
- if(extension STREQUAL ".qml" OR extension STREQUAL ".js" OR extension STREQUAL ".ui.qml")
+ if(extension STREQUAL \".qml\" OR extension STREQUAL \".js\" OR extension STREQUAL \".ui.qml\" OR extension STREQUAL \".mjs\")
qtquick_compiler_determine_output_filename(output_file ${it})
add_custom_command(OUTPUT ${output_file} COMMAND ${compiler_path} ARGS --resource=${input_resource} ${it} -o ${output_file} DEPENDS ${it})
list(APPEND compiler_output ${output_file})
@@ -70,4 +86,3 @@ function(QTQUICK_COMPILER_ADD_RESOURCES outfiles)
qt5_add_resources(output_resources ${filtered_rcc_files} OPTIONS ${options})
set(${outfiles} ${output_resources} ${compiler_output} PARENT_SCOPE)
endfunction()
-
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index 8a2776e808..762f6e7221 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -34,9 +34,12 @@
#include <QDateTime>
#include <QHashFunctions>
#include <QSaveFile>
+#include <QScopedPointer>
+#include <QScopeGuard>
#include <private/qqmlirbuilder_p.h>
#include <private/qqmljsparser_p.h>
+#include <private/qqmljslexer_p.h>
#include "resourcefilemapper.h"
@@ -66,6 +69,7 @@ struct Error
QString message;
void print();
Error augment(const QString &contextErrorMessage) const;
+ void appendDiagnostics(const QString &inputFileName, const QList<QQmlJS::DiagnosticMessage> &diagnostics);
};
void Error::print()
@@ -95,6 +99,15 @@ QString diagnosticErrorMessage(const QString &fileName, const QQmlJS::Diagnostic
return message;
}
+void Error::appendDiagnostics(const QString &inputFileName, const QList<DiagnosticMessage> &diagnostics)
+{
+ for (const QQmlJS::DiagnosticMessage &parseError: diagnostics) {
+ if (!message.isEmpty())
+ message += QLatin1Char('\n');
+ message += diagnosticErrorMessage(inputFileName, parseError);
+ }
+}
+
// Ensure that ListElement objects keep all property assignments in their string form
static void annotateListElements(QmlIR::Document *document)
{
@@ -161,7 +174,7 @@ static bool checkArgumentsObjectUseInSignalHandlers(const QmlIR::Document &doc,
return true;
}
-using SaveFunction = std::function<bool (QV4::CompiledData::CompilationUnit *, QString *)>;
+using SaveFunction = std::function<bool (const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &, QString *)>;
static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFunction, Error *error)
{
@@ -184,11 +197,7 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti
{
QmlIR::IRBuilder irBuilder(illegalNames);
if (!irBuilder.generateFromQml(sourceCode, inputFileName, &irDocument)) {
- for (const QQmlJS::DiagnosticMessage &parseError: qAsConst(irBuilder.errors)) {
- if (!error->message.isEmpty())
- error->message += QLatin1Char('\n');
- error->message += diagnosticErrorMessage(inputFileName, parseError);
- }
+ error->appendDiagnostics(inputFileName, irBuilder.errors);
return false;
}
}
@@ -212,11 +221,7 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti
const QVector<int> runtimeFunctionIndices = v4CodeGen.generateJSCodeForFunctionsAndBindings(functionsToCompile);
QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();
if (!jsErrors.isEmpty()) {
- for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) {
- if (!error->message.isEmpty())
- error->message += QLatin1Char('\n');
- error->message += diagnosticErrorMessage(inputFileName, e);
- }
+ error->appendDiagnostics(inputFileName, jsErrors);
return false;
}
@@ -231,10 +236,10 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti
QmlIR::QmlUnitGenerator generator;
irDocument.javaScriptCompilationUnit = v4CodeGen.generateCompilationUnit(/*generate unit*/false);
- QV4::CompiledData::Unit *unit = generator.generate(irDocument);
+ generator.generate(irDocument);
+ QV4::CompiledData::Unit *unit = const_cast<QV4::CompiledData::Unit*>(irDocument.javaScriptCompilationUnit->data);
unit->flags |= QV4::CompiledData::Unit::StaticData;
unit->flags |= QV4::CompiledData::Unit::PendingTypeCompilation;
- irDocument.javaScriptCompilationUnit->data = unit;
if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message))
return false;
@@ -246,7 +251,8 @@ static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFuncti
static bool compileJSFile(const QString &inputFileName, const QString &inputFileUrl, SaveFunction saveFunction, Error *error)
{
- QmlIR::Document irDocument(/*debugMode*/false);
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit;
+ QScopedPointer<QV4::CompiledData::Unit, QScopedPointerPodDeleter> unitDataToFree;
QString sourceCode;
{
@@ -262,79 +268,83 @@ static bool compileJSFile(const QString &inputFileName, const QString &inputFile
}
}
- QQmlJS::Engine *engine = &irDocument.jsParserEngine;
- QmlIR::ScriptDirectivesCollector directivesCollector(&irDocument);
- QQmlJS::Directives *oldDirs = engine->directives();
- engine->setDirectives(&directivesCollector);
+ const bool isModule = inputFileName.endsWith(QLatin1String(".mjs"));
+ if (isModule) {
+ QList<QQmlJS::DiagnosticMessage> diagnostics;
+ // Precompiled files are relocatable and the final location will be set when loading.
+ QString url;
+ unit = QV4::ExecutionEngine::compileModule(/*debugMode*/false, url, sourceCode, QDateTime(), &diagnostics);
+ error->appendDiagnostics(inputFileName, diagnostics);
+ if (!unit)
+ return false;
+ } else {
+ QmlIR::Document irDocument(/*debugMode*/false);
- QQmlJS::AST::Program *program = nullptr;
+ QQmlJS::Engine *engine = &irDocument.jsParserEngine;
+ QmlIR::ScriptDirectivesCollector directivesCollector(&irDocument);
+ QQmlJS::Directives *oldDirs = engine->directives();
+ engine->setDirectives(&directivesCollector);
+ auto directivesGuard = qScopeGuard([engine, oldDirs]{
+ engine->setDirectives(oldDirs);
+ });
- {
- QQmlJS::Lexer lexer(engine);
- lexer.setCode(sourceCode, /*line*/1, /*parseAsBinding*/false);
- QQmlJS::Parser parser(engine);
+ QQmlJS::AST::Program *program = nullptr;
- bool parsed = parser.parseProgram();
+ {
+ QQmlJS::Lexer lexer(engine);
+ lexer.setCode(sourceCode, /*line*/1, /*parseAsBinding*/false);
+ QQmlJS::Parser parser(engine);
- for (const QQmlJS::DiagnosticMessage &parseError: parser.diagnosticMessages()) {
- if (!error->message.isEmpty())
- error->message += QLatin1Char('\n');
- error->message += diagnosticErrorMessage(inputFileName, parseError);
- }
+ bool parsed = parser.parseProgram();
- if (!parsed) {
- engine->setDirectives(oldDirs);
- return false;
- }
+ error->appendDiagnostics(inputFileName, parser.diagnosticMessages());
- program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());
- if (!program) {
- lexer.setCode(QStringLiteral("undefined;"), 1, false);
- parsed = parser.parseProgram();
- Q_ASSERT(parsed);
- program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());
- Q_ASSERT(program);
- }
- }
+ if (!parsed)
+ return false;
- {
- QmlIR::JSCodeGen v4CodeGen(irDocument.code, &irDocument.jsGenerator,
- &irDocument.jsModule, &irDocument.jsParserEngine,
- irDocument.program, /*import cache*/nullptr,
- &irDocument.jsGenerator.stringTable, illegalNames);
- v4CodeGen.setUseFastLookups(false); // Disable lookups in non-standalone (aka QML) mode
- v4CodeGen.generateFromProgram(inputFileName, inputFileUrl, sourceCode, program,
- &irDocument.jsModule, QV4::Compiler::GlobalCode);
- QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();
- if (!jsErrors.isEmpty()) {
- for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) {
- if (!error->message.isEmpty())
- error->message += QLatin1Char('\n');
- error->message += diagnosticErrorMessage(inputFileName, e);
+ program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());
+ if (!program) {
+ lexer.setCode(QStringLiteral("undefined;"), 1, false);
+ parsed = parser.parseProgram();
+ Q_ASSERT(parsed);
+ program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());
+ Q_ASSERT(program);
}
- engine->setDirectives(oldDirs);
- return false;
}
- QmlIR::QmlUnitGenerator generator;
-
- irDocument.javaScriptCompilationUnit = v4CodeGen.generateCompilationUnit(/*generate unit*/false);
- QV4::CompiledData::Unit *unit = generator.generate(irDocument);
- unit->flags |= QV4::CompiledData::Unit::StaticData;
- irDocument.javaScriptCompilationUnit->data = unit;
+ {
+ QmlIR::JSCodeGen v4CodeGen(irDocument.code, &irDocument.jsGenerator,
+ &irDocument.jsModule, &irDocument.jsParserEngine,
+ irDocument.program, /*import cache*/nullptr,
+ &irDocument.jsGenerator.stringTable, illegalNames);
+ v4CodeGen.setUseFastLookups(false); // Disable lookups in non-standalone (aka QML) mode
+ v4CodeGen.generateFromProgram(inputFileName, inputFileUrl, sourceCode, program,
+ &irDocument.jsModule, QV4::Compiler::ContextType::Global);
+ QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();
+ if (!jsErrors.isEmpty()) {
+ error->appendDiagnostics(inputFileName, jsErrors);
+ return false;
+ }
- if (!saveFunction(irDocument.javaScriptCompilationUnit, &error->message)) {
- engine->setDirectives(oldDirs);
- return false;
+ // Precompiled files are relocatable and the final location will be set when loading.
+ irDocument.jsModule.fileName.clear();
+ irDocument.jsModule.finalUrl.clear();
+
+ irDocument.javaScriptCompilationUnit = v4CodeGen.generateCompilationUnit(/*generate unit*/false);
+ QmlIR::QmlUnitGenerator generator;
+ generator.generate(irDocument);
+ QV4::CompiledData::Unit *unitData = const_cast<QV4::CompiledData::Unit*>(irDocument.javaScriptCompilationUnit->data);
+ unitData->flags |= QV4::CompiledData::Unit::StaticData;
+ unitDataToFree.reset(unitData);
+ unit = irDocument.javaScriptCompilationUnit;
}
-
- free(unit);
}
- engine->setDirectives(oldDirs);
- return true;
+
+ return saveFunction(unit, &error->message);
}
-static bool saveUnitAsCpp(const QString &inputFileName, const QString &outputFileName, QV4::CompiledData::CompilationUnit *unit, QString *errorString)
+static bool saveUnitAsCpp(const QString &inputFileName, const QString &outputFileName,
+ const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, QString *errorString)
{
QSaveFile f(outputFileName);
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
@@ -434,9 +444,6 @@ int main(int argc, char **argv)
QCommandLineOption outputFileOption(QStringLiteral("o"), QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "file name"));
parser.addOption(outputFileOption);
- QCommandLineOption checkIfSupportedOption(QStringLiteral("check-if-supported"), QCoreApplication::translate("main", "Check if cache generate is supported on the specified target architecture"));
- parser.addOption(checkIfSupportedOption);
-
parser.addPositionalArgument(QStringLiteral("[qml file]"),
QStringLiteral("QML source file to generate cache for."));
@@ -525,12 +532,12 @@ int main(int argc, char **argv)
inputFileUrl = QStringLiteral("qrc://") + inputResourcePath;
- saveFunction = [inputResourcePath, outputFileName](QV4::CompiledData::CompilationUnit *unit, QString *errorString) {
+ saveFunction = [inputResourcePath, outputFileName](const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, QString *errorString) {
return saveUnitAsCpp(inputResourcePath, outputFileName, unit, errorString);
};
} else {
- saveFunction = [outputFileName](QV4::CompiledData::CompilationUnit *unit, QString *errorString) {
+ saveFunction = [outputFileName](const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, QString *errorString) {
return unit->saveToDisk(outputFileName, errorString);
};
}
@@ -544,7 +551,7 @@ int main(int argc, char **argv)
error.augment(QLatin1String("Error compiling qml file: ")).print();
return EXIT_FAILURE;
}
- } else if (inputFile.endsWith(QLatin1String(".js"))) {
+ } else if (inputFile.endsWith(QLatin1String(".js")) || inputFile.endsWith(QLatin1String(".mjs"))) {
Error error;
if (!compileJSFile(inputFile, inputFileUrl, saveFunction, &error)) {
error.augment(QLatin1String("Error compiling js file: ")).print();
diff --git a/tools/qmlcachegen/qmlcachegen.pro b/tools/qmlcachegen/qmlcachegen.pro
index 391f0c3889..9662690395 100644
--- a/tools/qmlcachegen/qmlcachegen.pro
+++ b/tools/qmlcachegen/qmlcachegen.pro
@@ -14,7 +14,21 @@ build_integration.path = $$[QT_HOST_DATA]/mkspecs/features
prefix_build: INSTALLS += build_integration
else: COPIES += build_integration
-cmake_build_integration.files = Qt5QuickCompilerConfig.cmake
+load(cmake_functions)
+
+CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+ CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+ CMAKE_BIN_DIR_IS_ABSOLUTE = True
+}
+
+load(qt_build_paths)
+
+cmake_config_file.input = $$PWD/Qt5QuickCompilerConfig.cmake.in
+cmake_config_file.output = $$MODULE_BASE_OUTDIR/lib/cmake/Qt5QuickCompiler/Qt5QuickCompilerConfig.cmake
+QMAKE_SUBSTITUTES += cmake_config_file
+
+cmake_build_integration.files = $$cmake_config_file.output
cmake_build_integration.path = $$[QT_INSTALL_LIBS]/cmake/Qt5QuickCompiler
prefix_build: INSTALLS += cmake_build_integration
else: COPIES += cmake_build_integration
diff --git a/tools/qmlcachegen/qtquickcompiler.prf b/tools/qmlcachegen/qtquickcompiler.prf
index d05908560d..7d8a857847 100644
--- a/tools/qmlcachegen/qtquickcompiler.prf
+++ b/tools/qmlcachegen/qtquickcompiler.prf
@@ -35,7 +35,7 @@ for(res, RESOURCES) {
absRes = $$absolute_path($$res, $$_PRO_FILE_PWD_)
rccContents = $$system($$QMAKE_RCC_DEP -list $$system_quote($$absRes),lines)
- contains(rccContents,.*\\.js$)|contains(rccContents,.*\\.qml$) {
+ contains(rccContents,.*\\.js$)|contains(rccContents,.*\\.qml$)|contains(rccContents,.*\\.mjs$) {
new_resource = $$qmlCacheResourceFileOutputName($$res)
mkpath($$dirname(new_resource))
remaining_files = $$system($$QML_CACHEGEN_FILTER -filter-resource-file -o $$system_quote($$new_resource) $$system_quote($$absRes),lines)
@@ -49,7 +49,7 @@ for(res, RESOURCES) {
QMLCACHE_RESOURCE_FILES += $$absRes
for(candidate, rccContents) {
- contains(candidate,.*\\.js$)|contains(candidate,.*\\.qml$) {
+ contains(candidate,.*\\.js$)|contains(candidate,.*\\.qml$)|contains(candidate,.*\\.mjs$) {
QMLCACHE_FILES += $$candidate
}
}
@@ -70,6 +70,7 @@ defineReplace(qmlCacheOutputName) {
name = $$relative_path($$name, $$_PRO_FILE_PWD_)
name = $$replace(name, \\.qml$, _qml)
name = $$replace(name, \\.js$, _js)
+ name = $$replace(name, \\.mjs$, _mjs)
name = $$replace(name,/,_)
name = $$QMLCACHE_DIR/$${name}
return($${name})
diff --git a/tools/qmlcachegen/resourcefilemapper.cpp b/tools/qmlcachegen/resourcefilemapper.cpp
index c2fd057541..6a00b39f2e 100644
--- a/tools/qmlcachegen/resourcefilemapper.cpp
+++ b/tools/qmlcachegen/resourcefilemapper.cpp
@@ -67,7 +67,7 @@ QStringList ResourceFileMapper::qmlCompilerFiles() const
it != end; ++it) {
const QString &qrcPath = it.key();
const QString suffix = QFileInfo(qrcPath).suffix();
- if (suffix != QStringLiteral("qml") && suffix != QStringLiteral("js"))
+ if (suffix != QStringLiteral("qml") && suffix != QStringLiteral("js") && suffix != QStringLiteral("mjs"))
continue;
files << qrcPath;
}
diff --git a/tools/qmlcachegen/resourcefilter.cpp b/tools/qmlcachegen/resourcefilter.cpp
index 196dbd4a75..3ad6e9ca0d 100644
--- a/tools/qmlcachegen/resourcefilter.cpp
+++ b/tools/qmlcachegen/resourcefilter.cpp
@@ -139,7 +139,9 @@ int filterResourceFile(const QString &input, const QString &output)
if (currentFileName.isEmpty())
continue;
- if (!currentFileName.endsWith(QStringLiteral(".qml")) && !currentFileName.endsWith(QStringLiteral(".js"))) {
+ if (!currentFileName.endsWith(QStringLiteral(".qml"))
+ && !currentFileName.endsWith(QStringLiteral(".js"))
+ && !currentFileName.endsWith(QStringLiteral(".mjs"))) {
writer.writeStartElement(QStringLiteral("file"));
if (!fileAttributes.hasAttribute(QStringLiteral("alias")))
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index ea014f3beb..56d4a7d383 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -37,6 +37,7 @@
#include "private/qv4context_p.h"
#include "private/qv4script_p.h"
#include "private/qv4string_p.h"
+#include "private/qv4module_p.h"
#include "private/qqmlbuiltinfunctions_p.h"
#include <QtCore/QCoreApplication>
@@ -77,14 +78,29 @@ int main(int argc, char *argv[])
args.removeFirst();
bool runAsQml = false;
+ bool runAsModule = false;
bool cache = false;
if (!args.isEmpty()) {
+ if (args.constFirst() == QLatin1String("--jit")) {
+ qputenv("QV4_JIT_CALL_THRESHOLD", QByteArray("0"));
+ args.removeFirst();
+ }
+ if (args.constFirst() == QLatin1String("--interpret")) {
+ qputenv("QV4_FORCE_INTERPRETER", QByteArray("1"));
+ args.removeFirst();
+ }
+
if (args.constFirst() == QLatin1String("--qml")) {
runAsQml = true;
args.removeFirst();
}
+ if (args.constFirst() == QLatin1String("--module")) {
+ runAsModule = true;
+ args.removeFirst();
+ }
+
if (args.constFirst() == QLatin1String("--cache")) {
cache = true;
args.removeFirst();
@@ -104,8 +120,21 @@ int main(int argc, char *argv[])
QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
for (const QString &fn : qAsConst(args)) {
- QFile file(fn);
- if (file.open(QFile::ReadOnly)) {
+ QV4::ScopedValue result(scope);
+ if (runAsModule) {
+ auto moduleUnit = vm.loadModule(QUrl::fromLocalFile(QFileInfo(fn).absoluteFilePath()));
+ if (moduleUnit) {
+ if (moduleUnit->instantiate(&vm))
+ moduleUnit->evaluate();
+ } else {
+ vm.throwError(QStringLiteral("Could not load module file"));
+ }
+ } else {
+ QFile file(fn);
+ if (!file.open(QFile::ReadOnly)) {
+ std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
+ return EXIT_FAILURE;
+ }
QScopedPointer<QV4::Script> script;
if (cache && QFile::exists(fn + QLatin1Char('c'))) {
QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = QV4::Compiler::Codegen::createUnitForLoading();
@@ -120,16 +149,15 @@ int main(int argc, char *argv[])
const QString code = QString::fromUtf8(file.readAll());
file.close();
- script.reset(new QV4::Script(ctx, QV4::Compiler::GlobalCode, code, fn));
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn));
script->parseAsBinding = runAsQml;
script->parse();
}
- QV4::ScopedValue result(scope);
if (!scope.engine->hasException) {
const auto unit = script->compilationUnit;
- if (cache && unit && !(unit->data->flags & QV4::CompiledData::Unit::StaticData)) {
- if (unit->data->sourceTimeStamp == 0) {
- const_cast<QV4::CompiledData::Unit*>(unit->data)->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
+ if (cache && unit && !(unit->unitData()->flags & QV4::CompiledData::Unit::StaticData)) {
+ if (unit->unitData()->sourceTimeStamp == 0) {
+ const_cast<QV4::CompiledData::Unit*>(unit->unitData())->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
}
QString saveError;
if (!unit->saveToDisk(QUrl::fromLocalFile(fn), &saveError)) {
@@ -140,20 +168,17 @@ int main(int argc, char *argv[])
result = script->run();
// std::cout << t.elapsed() << " ms. elapsed" << std::endl;
}
- if (scope.engine->hasException) {
- QV4::StackTrace trace;
- QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
- showException(ctx, ex, trace);
- return EXIT_FAILURE;
- }
- if (!result->isUndefined()) {
- if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
- std::cout << "exit value: " << qPrintable(result->toQString()) << std::endl;
- }
- } else {
- std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
+ }
+ if (scope.engine->hasException) {
+ QV4::StackTrace trace;
+ QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
+ showException(ctx, ex, trace);
return EXIT_FAILURE;
}
+ if (!result->isUndefined()) {
+ if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
+ std::cout << "exit value: " << qPrintable(result->toQString()) << std::endl;
+ }
}
return EXIT_SUCCESS;
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index 5641e6348e..26833d2a08 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -57,15 +57,48 @@ class QmlminLexer: protected Lexer, public Directives
QString _fileName;
QString _directives;
+protected:
+ QVector<int> _stateStack;
+ QList<int> _tokens;
+ QList<QString> _tokenStrings;
+ int yytoken = -1;
+ QString yytokentext;
+
+ void lex() {
+ if (_tokens.isEmpty()) {
+ _tokens.append(Lexer::lex());
+ _tokenStrings.append(tokenText());
+ }
+
+ yytoken = _tokens.takeFirst();
+ yytokentext = _tokenStrings.takeFirst();
+ }
+
+ int lookaheadToken()
+ {
+ if (yytoken < 0)
+ lex();
+ return yytoken;
+ }
+
+ void pushToken(int token)
+ {
+ _tokens.prepend(yytoken);
+ _tokenStrings.prepend(yytokentext);
+ yytoken = token;
+ yytokentext = QString();
+ }
+
public:
- QmlminLexer(): Lexer(&_engine) {}
+ QmlminLexer()
+ : Lexer(&_engine), _stateStack(128) {}
virtual ~QmlminLexer() {}
QString fileName() const { return _fileName; }
bool operator()(const QString &fileName, const QString &code)
{
- int startToken = T_FEED_JS_PROGRAM;
+ int startToken = T_FEED_JS_SCRIPT;
const QFileInfo fileInfo(fileName);
if (fileInfo.suffix().toLower() == QLatin1String("qml"))
startToken = T_FEED_UI_PROGRAM;
@@ -154,6 +187,24 @@ protected:
ruleno == J_SCRIPT_REGEXPLITERAL_RULE2;
}
+ void handleLookaheads(int ruleno) {
+ if (ruleno == J_SCRIPT_EXPRESSIONSTATEMENTLOOKAHEAD_RULE) {
+ int token = lookaheadToken();
+ if (token == T_LBRACE)
+ pushToken(T_FORCE_BLOCK);
+ else if (token == T_FUNCTION || token == T_CLASS || token == T_LET || token == T_CONST)
+ pushToken(T_FORCE_DECLARATION);
+ } else if (ruleno == J_SCRIPT_CONCISEBODYLOOKAHEAD_RULE) {
+ int token = lookaheadToken();
+ if (token == T_LBRACE)
+ pushToken(T_FORCE_BLOCK);
+ } else if (ruleno == J_SCRIPT_EXPORTDECLARATIONLOOKAHEAD_RULE) {
+ int token = lookaheadToken();
+ if (token == T_FUNCTION || token == T_CLASS)
+ pushToken(T_FORCE_DECLARATION);
+ }
+ }
+
bool scanRestOfRegExp(int ruleno, QString *restOfRegExp)
{
if (! scanRegExp(ruleno == J_SCRIPT_REGEXPLITERAL_RULE1 ? Lexer::NoPrefix : Lexer::EqualPrefix))
@@ -187,9 +238,6 @@ protected:
class Minify: public QmlminLexer
{
- QVector<int> _stateStack;
- QList<int> _tokens;
- QList<QString> _tokenStrings;
QString _minifiedCode;
int _maxWidth;
int _width;
@@ -206,7 +254,7 @@ protected:
};
Minify::Minify(int maxWidth)
- : _stateStack(128), _maxWidth(maxWidth), _width(0)
+ : _maxWidth(maxWidth), _width(0)
{
}
@@ -250,16 +298,14 @@ void Minify::escape(const QChar &ch, QString *out)
bool Minify::parse(int startToken)
{
int yyaction = 0;
- int yytoken = -1;
int yytos = -1;
- QString yytokentext;
QString assembled;
_minifiedCode.clear();
_tokens.append(startToken);
_tokenStrings.append(QString());
- if (startToken == T_FEED_JS_PROGRAM) {
+ if (startToken == T_FEED_JS_SCRIPT) {
// parse optional pragma directive
DiagnosticMessage error;
if (scanDirectives(this, &error)) {
@@ -282,15 +328,8 @@ bool Minify::parse(int startToken)
_stateStack[yytos] = yyaction;
again:
- if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) {
- if (_tokens.isEmpty()) {
- _tokens.append(lex());
- _tokenStrings.append(tokenText());
- }
-
- yytoken = _tokens.takeFirst();
- yytokentext = _tokenStrings.takeFirst();
- }
+ if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT)
+ lex();
yyaction = t_action(yyaction, yytoken);
if (yyaction > 0) {
@@ -366,6 +405,8 @@ bool Minify::parse(int startToken)
const int ruleno = -yyaction - 1;
yytos -= rhs[ruleno];
+ handleLookaheads(ruleno);
+
if (isRegExpRule(ruleno)) {
QString restOfRegExp;
@@ -398,13 +439,10 @@ bool Minify::parse(int startToken)
class Tokenize: public QmlminLexer
{
- QVector<int> _stateStack;
- QList<int> _tokens;
- QList<QString> _tokenStrings;
QStringList _minifiedCode;
public:
- Tokenize();
+ Tokenize() {}
QStringList tokenStream() const;
@@ -412,11 +450,6 @@ protected:
bool parse(int startToken) override;
};
-Tokenize::Tokenize()
- : _stateStack(128)
-{
-}
-
QStringList Tokenize::tokenStream() const
{
return _minifiedCode;
@@ -425,15 +458,13 @@ QStringList Tokenize::tokenStream() const
bool Tokenize::parse(int startToken)
{
int yyaction = 0;
- int yytoken = -1;
int yytos = -1;
- QString yytokentext;
_minifiedCode.clear();
_tokens.append(startToken);
_tokenStrings.append(QString());
- if (startToken == T_FEED_JS_PROGRAM) {
+ if (startToken == T_FEED_JS_SCRIPT) {
// parse optional pragma directive
DiagnosticMessage error;
if (scanDirectives(this, &error)) {
@@ -457,15 +488,8 @@ bool Tokenize::parse(int startToken)
_stateStack[yytos] = yyaction;
again:
- if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) {
- if (_tokens.isEmpty()) {
- _tokens.append(lex());
- _tokenStrings.append(tokenText());
- }
-
- yytoken = _tokens.takeFirst();
- yytokentext = _tokenStrings.takeFirst();
- }
+ if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT)
+ lex();
yyaction = t_action(yyaction, yytoken);
if (yyaction > 0) {
@@ -484,6 +508,8 @@ bool Tokenize::parse(int startToken)
const int ruleno = -yyaction - 1;
yytos -= rhs[ruleno];
+ handleLookaheads(ruleno);
+
if (isRegExpRule(ruleno)) {
QString restOfRegExp;
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 5c5a6a8eb1..dffac93f20 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -79,9 +79,9 @@
namespace {
const uint qtQmlMajorVersion = 2;
-const uint qtQmlMinorVersion = 2;
+const uint qtQmlMinorVersion = QT_VERSION_MINOR;
const uint qtQuickMajorVersion = 2;
-const uint qtQuickMinorVersion = 8;
+const uint qtQuickMinorVersion = QT_VERSION_MINOR;
const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2")
.arg(qtQuickMajorVersion)
@@ -124,14 +124,14 @@ void collectReachableMetaObjects(QObject *object, QSet<const QMetaObject *> *met
const QMetaObject *meta = object->metaObject();
if (verbose)
- std::cerr << "Processing object" << qPrintable( meta->className() ) << std::endl;
+ std::cerr << "Processing object " << qPrintable( meta->className() ) << std::endl;
collectReachableMetaObjects(meta, metas);
for (int index = 0; index < meta->propertyCount(); ++index) {
QMetaProperty prop = meta->property(index);
if (QQmlMetaType::isQObject(prop.userType())) {
if (verbose)
- std::cerr << " Processing property" << qPrintable( prop.name() ) << std::endl;
+ std::cerr << " Processing property " << qPrintable( prop.name() ) << std::endl;
currentProperty = QString("%1::%2").arg(meta->className(), prop.name());
// if the property was not initialized during construction,
@@ -337,7 +337,7 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
collectReachableMetaObjects(object, &metas);
object->deleteLater();
} else {
- std::cerr << "Could not create" << qPrintable(tyName) << std::endl;
+ std::cerr << "Could not create " << qPrintable(tyName) << std::endl;
}
}
}
@@ -732,7 +732,7 @@ enum ExitCode {
};
#ifdef Q_OS_UNIX
-void sigSegvHandler(int) {
+Q_NORETURN void sigSegvHandler(int) {
fprintf(stderr, "Error: SEGV\n");
if (!currentProperty.isEmpty())
fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData());
@@ -1014,7 +1014,7 @@ int main(int argc, char *argv[])
#endif // QT_WIDGETS_LIB
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
- const QStringList args = app->arguments();
+ QStringList args = app->arguments();
const QString appName = QFileInfo(app->applicationFilePath()).baseName();
if (args.size() < 2) {
printUsage(appName);
@@ -1046,6 +1046,10 @@ int main(int argc, char *argv[])
return EXIT_INVALIDARGUMENTS;
}
dependenciesFile = args.at(iArg);
+
+ // Remove absolute path so that it does not show up in the
+ // printed command line inside the plugins.qmltypes file.
+ args[iArg] = QFileInfo(args.at(iArg)).fileName();
} else if (arg == QLatin1String("--merge")
|| arg == QLatin1String("-merge")) {
if (++iArg == args.size()) {
diff --git a/tools/qmlpreview/main.cpp b/tools/qmlpreview/main.cpp
new file mode 100644
index 0000000000..c7a32da258
--- /dev/null
+++ b/tools/qmlpreview/main.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlpreviewapplication.h"
+
+int main(int argc, char *argv[])
+{
+ QmlPreviewApplication app(argc, argv);
+ app.parseArguments();
+ return app.exec();
+}
diff --git a/tools/qmlpreview/qmlpreview.pro b/tools/qmlpreview/qmlpreview.pro
new file mode 100644
index 0000000000..7d443b5f6c
--- /dev/null
+++ b/tools/qmlpreview/qmlpreview.pro
@@ -0,0 +1,13 @@
+QT = network core qmldebug-private
+CONFIG += no_import_scan
+
+SOURCES += \
+ main.cpp \
+ qmlpreviewapplication.cpp
+
+HEADERS += \
+ qmlpreviewapplication.h
+
+QMAKE_TARGET_DESCRIPTION = QML Preview
+
+load(qt_tool)
diff --git a/tools/qmlpreview/qmlpreviewapplication.cpp b/tools/qmlpreview/qmlpreviewapplication.cpp
new file mode 100644
index 0000000000..618769502c
--- /dev/null
+++ b/tools/qmlpreview/qmlpreviewapplication.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlpreviewapplication.h"
+
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+#include <QtCore/QProcess>
+#include <QtCore/QTimer>
+#include <QtCore/QDateTime>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QUrl>
+
+QmlPreviewApplication::QmlPreviewApplication(int &argc, char **argv) :
+ QCoreApplication(argc, argv),
+ m_verbose(false),
+ m_connectionAttempts(0)
+{
+ m_connection.reset(new QQmlDebugConnection);
+ m_qmlPreviewClient.reset(new QQmlPreviewClient(m_connection.data()));
+ m_connectTimer.setInterval(1000);
+
+ m_loadTimer.setInterval(100);
+ m_loadTimer.setSingleShot(true);
+ connect(&m_loadTimer, &QTimer::timeout, this, [this]() {
+ m_qmlPreviewClient->triggerLoad(QUrl());
+ });
+
+ connect(&m_connectTimer, &QTimer::timeout, this, &QmlPreviewApplication::tryToConnect);
+ connect(m_connection.data(), &QQmlDebugConnection::connected, &m_connectTimer, &QTimer::stop);
+
+ connect(m_qmlPreviewClient.data(), &QQmlPreviewClient::error,
+ this, &QmlPreviewApplication::logError);
+ connect(m_qmlPreviewClient.data(), &QQmlPreviewClient::request,
+ this, &QmlPreviewApplication::serveRequest);
+
+ connect(&m_watcher, &QFileSystemWatcher::fileChanged,
+ this, &QmlPreviewApplication::sendFile);
+ connect(&m_watcher, &QFileSystemWatcher::directoryChanged,
+ this, &QmlPreviewApplication::sendDirectory);
+}
+
+QmlPreviewApplication::~QmlPreviewApplication()
+{
+ if (m_process && m_process->state() != QProcess::NotRunning) {
+ logStatus("Terminating process ...");
+ m_process->disconnect();
+ m_process->terminate();
+ if (!m_process->waitForFinished(1000)) {
+ logStatus("Killing process ...");
+ m_process->kill();
+ }
+ }
+}
+
+void QmlPreviewApplication::parseArguments()
+{
+ setApplicationName(QLatin1String("qmlpreview"));
+ setApplicationVersion(QLatin1String(qVersion()));
+
+ QCommandLineParser parser;
+ parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
+ parser.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments);
+
+ parser.setApplicationDescription(QChar::LineFeed + tr(
+ "The QML Preview tool watches QML and JavaScript files on disk and updates\n"
+ "the application live with any changes. The application to be previewed\n"
+ "has to enable QML debugging. See the Qt Creator documentation on how to do\n"
+ "this for different Qt versions."));
+
+ QCommandLineOption verbose(QStringList() << QLatin1String("verbose"),
+ tr("Print debugging output."));
+ parser.addOption(verbose);
+
+ parser.addHelpOption();
+ parser.addVersionOption();
+
+ parser.addPositionalArgument(QLatin1String("program"),
+ tr("The program to be started and profiled."),
+ QLatin1String("[program]"));
+ parser.addPositionalArgument(QLatin1String("parameters"),
+ tr("Parameters for the program to be started."),
+ QLatin1String("[parameters...]"));
+
+ parser.process(*this);
+
+ QTemporaryFile file;
+ if (file.open())
+ m_socketFile = file.fileName();
+
+ if (parser.isSet(verbose))
+ m_verbose = true;
+
+ m_programArguments = parser.positionalArguments();
+ if (!m_programArguments.isEmpty())
+ m_programPath = m_programArguments.takeFirst();
+
+ if (m_programPath.isEmpty()) {
+ logError(tr("You have to specify a program to start."));
+ parser.showHelp(2);
+ }
+}
+
+int QmlPreviewApplication::exec()
+{
+ QTimer::singleShot(0, this, &QmlPreviewApplication::run);
+ return QCoreApplication::exec();
+}
+
+void QmlPreviewApplication::run()
+{
+ logStatus(QString("Listening on %1 ...").arg(m_socketFile));
+ m_connection->startLocalServer(m_socketFile);
+ m_process.reset(new QProcess(this));
+ QStringList arguments;
+ arguments << QString("-qmljsdebugger=file:%1,block,services:QmlPreview").arg(m_socketFile);
+ arguments << m_programArguments;
+
+ m_process->setProcessChannelMode(QProcess::MergedChannels);
+ connect(m_process.data(), &QIODevice::readyRead,
+ this, &QmlPreviewApplication::processHasOutput);
+ connect(m_process.data(), static_cast<void(QProcess::*)(int)>(&QProcess::finished),
+ this, [this](int){ processFinished(); });
+ logStatus(QString("Starting '%1 %2' ...").arg(m_programPath, arguments.join(QLatin1Char(' '))));
+ m_process->start(m_programPath, arguments);
+ if (!m_process->waitForStarted()) {
+ logError(QString("Could not run '%1': %2").arg(m_programPath, m_process->errorString()));
+ exit(1);
+ }
+ m_connectTimer.start();
+}
+
+void QmlPreviewApplication::tryToConnect()
+{
+ Q_ASSERT(!m_connection->isConnected());
+ ++m_connectionAttempts;
+
+ if (m_verbose && !(m_connectionAttempts % 5)) {// print every 5 seconds
+ logError(QString("No connection received on %1 for %2 seconds ...")
+ .arg(m_socketFile).arg(m_connectionAttempts));
+ }
+}
+
+void QmlPreviewApplication::processHasOutput()
+{
+ Q_ASSERT(m_process);
+ while (m_process->bytesAvailable()) {
+ QTextStream out(stderr);
+ out << m_process->readAll();
+ }
+}
+
+void QmlPreviewApplication::processFinished()
+{
+ Q_ASSERT(m_process);
+ int exitCode = 0;
+ if (m_process->exitStatus() == QProcess::NormalExit) {
+ logStatus(QString("Process exited (%1).").arg(m_process->exitCode()));
+ } else {
+ logError("Process crashed!");
+ exitCode = 3;
+ }
+ exit(exitCode);
+}
+
+void QmlPreviewApplication::logError(const QString &error)
+{
+ QTextStream err(stderr);
+ err << "Error: " << error << endl;
+}
+
+void QmlPreviewApplication::logStatus(const QString &status)
+{
+ if (!m_verbose)
+ return;
+ QTextStream err(stderr);
+ err << status << endl;
+}
+
+void QmlPreviewApplication::serveRequest(const QString &path)
+{
+ QFileInfo info(path);
+
+ if (info.isDir()) {
+ m_qmlPreviewClient->sendDirectory(path, QDir(path).entryList());
+ m_watcher.addPath(path);
+ } else {
+ QFile file(path);
+ if (file.open(QIODevice::ReadOnly)) {
+ m_qmlPreviewClient->sendFile(path, file.readAll());
+ m_watcher.addPath(path);
+
+ // Also watch the directory, because editors will rather replace a file than change it.
+ // Therefore when the file changes, we can't read it, but when the file is re-added we can
+ // see that from the directory changing.
+ m_watcher.addPath(info.absolutePath());
+ } else {
+ logStatus(QString("Could not open file %1 for reading: %2").arg(path)
+ .arg(file.errorString()));
+ m_qmlPreviewClient->sendError(path);
+ }
+ }
+}
+
+bool QmlPreviewApplication::sendFile(const QString &path)
+{
+ QFile file(path);
+ if (file.open(QIODevice::ReadOnly)) {
+ m_qmlPreviewClient->sendFile(path, file.readAll());
+ m_pendingFiles.removeAll(path);
+ // Defer the Load, because files tend to change multiple times in a row.
+ m_loadTimer.start();
+ return true;
+ }
+ if (!m_pendingFiles.contains(path))
+ m_pendingFiles.append(path);
+ logStatus(QString("Could not open file %1 for reading: %2").arg(path).arg(file.errorString()));
+ return false;
+}
+
+void QmlPreviewApplication::sendDirectory(const QString &path)
+{
+ m_qmlPreviewClient->sendDirectory(path, QDir(path).entryList());
+ for (auto it = m_pendingFiles.begin(); it != m_pendingFiles.end();) {
+ const QString filePath = *it;
+ QFile file(filePath);
+ if (file.open(QIODevice::ReadOnly)) {
+ logStatus(QString("Sending replaced file %1.").arg(filePath));
+ m_qmlPreviewClient->sendFile(filePath, file.readAll());
+ m_watcher.addPath(filePath);
+ it = m_pendingFiles.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ m_loadTimer.start();
+}
diff --git a/tools/qmlpreview/qmlpreviewapplication.h b/tools/qmlpreview/qmlpreviewapplication.h
new file mode 100644
index 0000000000..eb363b0eb6
--- /dev/null
+++ b/tools/qmlpreview/qmlpreviewapplication.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLPREVIEWAPPLICATION_H
+#define QMLPREVIEWAPPLICATION_H
+
+#include <private/qqmlpreviewclient_p.h>
+#include <private/qqmldebugconnection_p.h>
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qprocess.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qfilesystemwatcher.h>
+
+#include <QtNetwork/qabstractsocket.h>
+
+class QmlPreviewApplication : public QCoreApplication
+{
+ Q_OBJECT
+public:
+ QmlPreviewApplication(int &argc, char **argv);
+ ~QmlPreviewApplication();
+
+ void parseArguments();
+ int exec();
+
+private:
+ void run();
+ void tryToConnect();
+ void processHasOutput();
+ void processFinished();
+
+ void logError(const QString &error);
+ void logStatus(const QString &status);
+
+ void serveRequest(const QString &request);
+ bool sendFile(const QString &path);
+ void sendDirectory(const QString &path);
+
+ QString m_programPath;
+ QStringList m_programArguments;
+ QScopedPointer<QProcess> m_process;
+ bool m_verbose;
+
+ QString m_socketFile;
+
+ QScopedPointer<QQmlDebugConnection> m_connection;
+ QScopedPointer<QQmlPreviewClient> m_qmlPreviewClient;
+ QFileSystemWatcher m_watcher;
+
+ QTimer m_loadTimer;
+ QTimer m_connectTimer;
+ uint m_connectionAttempts;
+
+ QStringList m_pendingFiles;
+};
+
+#endif // QMLPREVIEWAPPLICATION_H
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 0b63a91e5b..6732766b46 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -120,6 +120,10 @@ QmlProfilerApplication::~QmlProfilerApplication()
logStatus("Killing process ...");
m_process->kill();
}
+ if (isInteractive()) {
+ QTextStream err(stderr);
+ err << endl;
+ }
delete m_process;
}
@@ -366,7 +370,7 @@ void QmlProfilerApplication::userCommand(const QString &command)
m_pendingRequest = REQUEST_NONE;
prompt();
} else {
- prompt(tr("The application is still generating data. Really quit (y/n)?"));
+ prompt(tr("Really quit (y/n)?"));
}
return;
}
diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp
index b69c7e73e1..f6cc6f39fe 100644
--- a/tools/qmlprofiler/qmlprofilerclient.cpp
+++ b/tools/qmlprofiler/qmlprofilerclient.cpp
@@ -57,6 +57,8 @@ QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *connection, QmlProfile
{
Q_D(QmlProfilerClient);
setRequestedFeatures(std::numeric_limits<quint64>::max());
+ connect(this, &QQmlDebugClient::stateChanged,
+ this, &QmlProfilerClient::onStateChanged);
connect(this, &QQmlProfilerClient::traceStarted,
d->data, &QmlProfilerData::setTraceStartTime);
connect(this, &QQmlProfilerClient::traceFinished,
@@ -65,7 +67,7 @@ QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *connection, QmlProfile
d->data, &QmlProfilerData::complete);
}
-void QmlProfilerClient::stateChanged(State state)
+void QmlProfilerClient::onStateChanged(State state)
{
Q_D(QmlProfilerClient);
if ((d->enabled && state != Enabled) || (!d->enabled && state == Enabled)) {
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index 30f4a51751..7355688222 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -48,7 +48,7 @@ signals:
void error(const QString &error);
private:
- void stateChanged(State state) override;
+ void onStateChanged(State state);
};
#endif // QMLPROFILERCLIENT_H
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index bc7fe72d4c..4d18a868a2 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -51,8 +51,10 @@
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/QApplication>
+#if QT_CONFIG(filedialog)
#include <QtWidgets/QFileDialog>
#endif
+#endif
#include <QtCore/QTranslator>
#include <QtCore/QLibraryInfo>
@@ -311,7 +313,7 @@ static void displayFileDialog(Options *options)
#if QT_CONFIG(translation)
static void loadTranslationFile(QTranslator &translator, const QString& directory)
{
- translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n"));
+ translator.load(QLocale(), QLatin1String("qml"), QLatin1String("_"), directory + QLatin1String("/i18n"));
QCoreApplication::installTranslator(&translator);
}
#endif
@@ -549,12 +551,12 @@ int main(int argc, char ** argv)
}
#if QT_CONFIG(translation)
- QTranslator translator;
+ QLocale locale;
QTranslator qtTranslator;
- QString sysLocale = QLocale::system().name();
- if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ if (qtTranslator.load(locale, QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app->installTranslator(&qtTranslator);
- if (translator.load(QLatin1String("qmlscene_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ QTranslator translator;
+ if (translator.load(locale, QLatin1String("qmlscene"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app->installTranslator(&translator);
QTranslator qmlTranslator;
diff --git a/tools/tools.pro b/tools/tools.pro
index 856906cc53..3f5f23eb32 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -1,17 +1,21 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += qml-private
-SUBDIRS += \
- qmlmin \
- qmlimportscanner
-qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen
+qtConfig(qml-devtools) {
+ SUBDIRS += \
+ qmlmin \
+ qmlimportscanner
+
+ qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen
+}
-!android|android_app {
+qtConfig(thread):!android|android_app {
SUBDIRS += \
- qml \
- qmllint
+ qml
+ qtConfig(qml-devtools): SUBDIRS += qmllint
qtConfig(qml-profiler): SUBDIRS += qmlprofiler
+ qtConfig(qml-preview): SUBDIRS += qmlpreview
qtHaveModule(quick) {
!static: {
@@ -30,8 +34,10 @@ qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen
qtConfig(private_tests): SUBDIRS += qmljs
}
-qml.depends = qmlimportscanner
-qmleasing.depends = qmlimportscanner
+qtConfig(qml-devtools) {
+ qml.depends = qmlimportscanner
+ qmleasing.depends = qmlimportscanner
+}
# qmlmin, qmlimportscanner & qmlcachegen are build tools.
# qmlscene is needed by the autotests.