From 4944abbc5230003b282fdc5d7f7c1222628d1c14 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Tue, 8 May 2018 18:44:21 -0600 Subject: [PATCH] Add Zephir/C PHP extension --- .gitignore | 13 + .travis.yml | 61 + boxfile.yml | 40 + calendars/0calendars.go | 22 + calendars/0calendars_test.go | 39 + calendars/0leapseconds.go | 8 +- calendars/gregorian.go | 6 +- calendars/gregorian_test.go | 2 +- calendars/stardate.go | 9 +- calends.go | 2 +- libcalends/calendars.go | 11 + libcalends/calendars_tests.go | 45 + libcalends/calends.go | 46 +- libcalends/libcalends_test.go | 8 + libcalends/php/calends/calendarinterface.zep | 10 + .../php/calends/calendarobjectinterface.zep | 10 + libcalends/php/calends/calends.zep | 783 ++++++++ libcalends/php/calends/calendsexception.zep | 3 + libcalends/php/calends/taitime.zep | 161 ++ libcalends/php/config.json | 67 + libcalends/php/ext/.gitignore | 57 + libcalends/php/ext/tests/.gitkeep | 0 libcalends/php/ext/tests/001.loaded.phpt | 14 + libcalends/php/ext/tests/002.create.phpt | 18 + libcalends/php/ext/tests/003.date.phpt | 21 + libcalends/php/ext/tests/004.duration.phpt | 21 + libcalends/php/ext/tests/005.endDate.phpt | 21 + libcalends/php/ext/tests/006.withDate.phpt | 24 + .../php/ext/tests/007.withDuration.phpt | 24 + .../ext/tests/008.withDurationFromEnd.phpt | 24 + libcalends/php/ext/tests/009.withEndDate.phpt | 24 + libcalends/php/ext/tests/010.add.phpt | 18 + libcalends/php/ext/tests/011.subtract.phpt | 18 + libcalends/php/ext/tests/012.addFromEnd.phpt | 18 + .../php/ext/tests/013.subtractFromEnd.phpt | 18 + libcalends/php/ext/tests/014.next.phpt | 18 + libcalends/php/ext/tests/015.previous.phpt | 18 + libcalends/php/ext/tests/016.merge.phpt | 19 + libcalends/php/ext/tests/017.intersect.phpt | 19 + libcalends/php/ext/tests/018.gap.phpt | 19 + libcalends/php/ext/tests/019.difference.phpt | 16 + libcalends/php/ext/tests/020.compare.phpt | 16 + libcalends/php/ext/tests/021.contains.phpt | 16 + libcalends/php/ext/tests/022.overlaps.phpt | 16 + libcalends/php/ext/tests/023.abuts.phpt | 16 + libcalends/php/ext/tests/024.isSame.phpt | 16 + libcalends/php/ext/tests/025.isShorter.phpt | 16 + .../php/ext/tests/026.isSameDuration.phpt | 16 + libcalends/php/ext/tests/027.isLonger.phpt | 16 + libcalends/php/ext/tests/028.isBefore.phpt | 16 + .../php/ext/tests/029.startsBefore.phpt | 16 + libcalends/php/ext/tests/030.endsBefore.phpt | 16 + libcalends/php/ext/tests/031.isDuring.phpt | 16 + .../php/ext/tests/032.startsDuring.phpt | 16 + libcalends/php/ext/tests/033.endsDuring.phpt | 16 + libcalends/php/ext/tests/034.isAfter.phpt | 16 + libcalends/php/ext/tests/035.startsAfter.phpt | 16 + libcalends/php/ext/tests/036.endsAfter.phpt | 16 + .../php/ext/tests/037.calendarRegistered.phpt | 27 + .../php/ext/tests/038.calendarRegister.phpt | 48 + .../tests/039.calendarRegister-extended.phpt | 63 + .../php/ext/tests/040.taitime_create.phpt | 94 + libcalends/php/ext/tests/041.taitime_add.phpt | 31 + libcalends/php/ext/tests/042.taitime_sub.phpt | 62 + .../php/ext/tests/043.taitime_toString.phpt | 17 + .../php/ext/tests/044.taitime_fromString.phpt | 30 + .../php/ext/tests/045.taitime_toHex.phpt | 17 + .../php/ext/tests/046.taitime_fromHex.phpt | 46 + .../php/ext/tests/047.taitime_toNumber.phpt | 17 + .../php/ext/tests/048.taitime_fromNumber.phpt | 46 + .../php/ext/tests/049.taitime_toUTC.phpt | 30 + .../php/ext/tests/050.taitime_fromUTC.phpt | 30 + .../php/ext/tests/051.panicHandling.phpt | 25 + .../php/ext/tests/052.calendarUnregister.phpt | 38 + libcalends/php/ext/wrap_libcalends.c | 1607 +++++++++++++++++ libcalends/php/ext/wrap_libcalends.h | 119 ++ libcalends/php/opt/CalendsAbutsOptimizer.php | 39 + .../php/opt/CalendsAddDoubleOptimizer.php | 35 + .../opt/CalendsAddFromEndDoubleOptimizer.php | 35 + .../CalendsAddFromEndLongLongOptimizer.php | 35 + .../opt/CalendsAddFromEndStringOptimizer.php | 35 + .../php/opt/CalendsAddLongLongOptimizer.php | 35 + .../php/opt/CalendsAddStringOptimizer.php | 35 + ...CalendsCalendarListRegisteredOptimizer.php | 37 + .../opt/CalendsCalendarRegisterOptimizer.php | 25 + .../CalendsCalendarRegisteredOptimizer.php | 39 + .../CalendsCalendarUnregisterOptimizer.php | 25 + .../php/opt/CalendsCompareOptimizer.php | 39 + .../php/opt/CalendsContainsOptimizer.php | 39 + .../CalendsCreateDoubleEndPeriodOptimizer.php | 35 + .../php/opt/CalendsCreateDoubleOptimizer.php | 35 + .../opt/CalendsCreateDoubleRangeOptimizer.php | 35 + ...alendsCreateDoubleStartPeriodOptimizer.php | 35 + ...alendsCreateLongLongEndPeriodOptimizer.php | 35 + .../opt/CalendsCreateLongLongOptimizer.php | 35 + .../CalendsCreateLongLongRangeOptimizer.php | 35 + ...endsCreateLongLongStartPeriodOptimizer.php | 35 + .../CalendsCreateStringEndPeriodOptimizer.php | 35 + .../php/opt/CalendsCreateStringOptimizer.php | 35 + .../opt/CalendsCreateStringRangeOptimizer.php | 35 + ...alendsCreateStringStartPeriodOptimizer.php | 35 + libcalends/php/opt/CalendsDateOptimizer.php | 39 + .../php/opt/CalendsDecodeJsonOptimizer.php | 35 + .../php/opt/CalendsDecodeTextOptimizer.php | 35 + .../php/opt/CalendsDifferenceOptimizer.php | 39 + .../php/opt/CalendsDurationOptimizer.php | 39 + .../php/opt/CalendsEncodeJsonOptimizer.php | 39 + .../php/opt/CalendsEncodeTextOptimizer.php | 39 + .../php/opt/CalendsEndDateOptimizer.php | 39 + .../php/opt/CalendsEndsAfterOptimizer.php | 39 + .../php/opt/CalendsEndsBeforeOptimizer.php | 39 + .../php/opt/CalendsEndsDuringOptimizer.php | 39 + libcalends/php/opt/CalendsGapOptimizer.php | 36 + .../php/opt/CalendsIntersectOptimizer.php | 36 + .../php/opt/CalendsIsAfterOptimizer.php | 39 + .../php/opt/CalendsIsBeforeOptimizer.php | 39 + .../php/opt/CalendsIsDuringOptimizer.php | 39 + .../php/opt/CalendsIsLongerOptimizer.php | 39 + .../opt/CalendsIsSameDurationOptimizer.php | 39 + libcalends/php/opt/CalendsIsSameOptimizer.php | 39 + .../php/opt/CalendsIsShorterOptimizer.php | 39 + libcalends/php/opt/CalendsMergeOptimizer.php | 36 + .../php/opt/CalendsNextDoubleOptimizer.php | 35 + .../php/opt/CalendsNextLongLongOptimizer.php | 35 + .../php/opt/CalendsNextStringOptimizer.php | 35 + .../php/opt/CalendsOverlapsOptimizer.php | 39 + .../opt/CalendsPreviousDoubleOptimizer.php | 35 + .../opt/CalendsPreviousLongLongOptimizer.php | 35 + .../opt/CalendsPreviousStringOptimizer.php | 35 + .../php/opt/CalendsReleaseOptimizer.php | 27 + .../php/opt/CalendsStartsAfterOptimizer.php | 39 + .../php/opt/CalendsStartsBeforeOptimizer.php | 39 + .../php/opt/CalendsStartsDuringOptimizer.php | 39 + libcalends/php/opt/CalendsStringOptimizer.php | 39 + .../opt/CalendsSubtractDoubleOptimizer.php | 35 + .../CalendsSubtractFromEndDoubleOptimizer.php | 35 + ...alendsSubtractFromEndLongLongOptimizer.php | 35 + .../CalendsSubtractFromEndStringOptimizer.php | 35 + .../opt/CalendsSubtractLongLongOptimizer.php | 35 + .../opt/CalendsSubtractStringOptimizer.php | 35 + .../opt/CalendsWithDateDoubleOptimizer.php | 35 + .../opt/CalendsWithDateLongLongOptimizer.php | 35 + .../opt/CalendsWithDateStringOptimizer.php | 35 + .../CalendsWithDurationDoubleOptimizer.php | 35 + ...endsWithDurationFromEndDoubleOptimizer.php | 35 + ...dsWithDurationFromEndLongLongOptimizer.php | 35 + ...endsWithDurationFromEndStringOptimizer.php | 35 + .../CalendsWithDurationLongLongOptimizer.php | 35 + .../CalendsWithDurationStringOptimizer.php | 35 + .../opt/CalendsWithEndDateDoubleOptimizer.php | 35 + .../CalendsWithEndDateLongLongOptimizer.php | 35 + .../opt/CalendsWithEndDateStringOptimizer.php | 35 + libcalends/php/opt/Tai64timeAddOptimizer.php | 39 + .../php/opt/Tai64timeDecodeTextOptimizer.php | 39 + .../php/opt/Tai64timeDoubleOptimizer.php | 39 + .../php/opt/Tai64timeEncodeTextOptimizer.php | 39 + .../php/opt/Tai64timeFromDoubleOptimizer.php | 39 + .../opt/Tai64timeFromHexStringOptimizer.php | 39 + .../php/opt/Tai64timeFromStringOptimizer.php | 39 + .../php/opt/Tai64timeHexStringOptimizer.php | 39 + .../php/opt/Tai64timeStringOptimizer.php | 39 + libcalends/php/opt/Tai64timeSubOptimizer.php | 39 + .../php/opt/Tai64timeTaiToUtcOptimizer.php | 39 + .../php/opt/Tai64timeUtcToTaiOptimizer.php | 39 + tests/core_dump_info.sh | 2 +- tests/failed_test_info.sh | 13 + tests/go.nanobox.sh | 4 + 167 files changed, 7580 insertions(+), 38 deletions(-) create mode 100644 boxfile.yml create mode 100644 libcalends/php/calends/calendarinterface.zep create mode 100644 libcalends/php/calends/calendarobjectinterface.zep create mode 100644 libcalends/php/calends/calends.zep create mode 100644 libcalends/php/calends/calendsexception.zep create mode 100644 libcalends/php/calends/taitime.zep create mode 100644 libcalends/php/config.json create mode 100644 libcalends/php/ext/.gitignore create mode 100644 libcalends/php/ext/tests/.gitkeep create mode 100644 libcalends/php/ext/tests/001.loaded.phpt create mode 100644 libcalends/php/ext/tests/002.create.phpt create mode 100644 libcalends/php/ext/tests/003.date.phpt create mode 100644 libcalends/php/ext/tests/004.duration.phpt create mode 100644 libcalends/php/ext/tests/005.endDate.phpt create mode 100644 libcalends/php/ext/tests/006.withDate.phpt create mode 100644 libcalends/php/ext/tests/007.withDuration.phpt create mode 100644 libcalends/php/ext/tests/008.withDurationFromEnd.phpt create mode 100644 libcalends/php/ext/tests/009.withEndDate.phpt create mode 100644 libcalends/php/ext/tests/010.add.phpt create mode 100644 libcalends/php/ext/tests/011.subtract.phpt create mode 100644 libcalends/php/ext/tests/012.addFromEnd.phpt create mode 100644 libcalends/php/ext/tests/013.subtractFromEnd.phpt create mode 100644 libcalends/php/ext/tests/014.next.phpt create mode 100644 libcalends/php/ext/tests/015.previous.phpt create mode 100644 libcalends/php/ext/tests/016.merge.phpt create mode 100644 libcalends/php/ext/tests/017.intersect.phpt create mode 100644 libcalends/php/ext/tests/018.gap.phpt create mode 100644 libcalends/php/ext/tests/019.difference.phpt create mode 100644 libcalends/php/ext/tests/020.compare.phpt create mode 100644 libcalends/php/ext/tests/021.contains.phpt create mode 100644 libcalends/php/ext/tests/022.overlaps.phpt create mode 100644 libcalends/php/ext/tests/023.abuts.phpt create mode 100644 libcalends/php/ext/tests/024.isSame.phpt create mode 100644 libcalends/php/ext/tests/025.isShorter.phpt create mode 100644 libcalends/php/ext/tests/026.isSameDuration.phpt create mode 100644 libcalends/php/ext/tests/027.isLonger.phpt create mode 100644 libcalends/php/ext/tests/028.isBefore.phpt create mode 100644 libcalends/php/ext/tests/029.startsBefore.phpt create mode 100644 libcalends/php/ext/tests/030.endsBefore.phpt create mode 100644 libcalends/php/ext/tests/031.isDuring.phpt create mode 100644 libcalends/php/ext/tests/032.startsDuring.phpt create mode 100644 libcalends/php/ext/tests/033.endsDuring.phpt create mode 100644 libcalends/php/ext/tests/034.isAfter.phpt create mode 100644 libcalends/php/ext/tests/035.startsAfter.phpt create mode 100644 libcalends/php/ext/tests/036.endsAfter.phpt create mode 100644 libcalends/php/ext/tests/037.calendarRegistered.phpt create mode 100644 libcalends/php/ext/tests/038.calendarRegister.phpt create mode 100644 libcalends/php/ext/tests/039.calendarRegister-extended.phpt create mode 100644 libcalends/php/ext/tests/040.taitime_create.phpt create mode 100644 libcalends/php/ext/tests/041.taitime_add.phpt create mode 100644 libcalends/php/ext/tests/042.taitime_sub.phpt create mode 100644 libcalends/php/ext/tests/043.taitime_toString.phpt create mode 100644 libcalends/php/ext/tests/044.taitime_fromString.phpt create mode 100644 libcalends/php/ext/tests/045.taitime_toHex.phpt create mode 100644 libcalends/php/ext/tests/046.taitime_fromHex.phpt create mode 100644 libcalends/php/ext/tests/047.taitime_toNumber.phpt create mode 100644 libcalends/php/ext/tests/048.taitime_fromNumber.phpt create mode 100644 libcalends/php/ext/tests/049.taitime_toUTC.phpt create mode 100644 libcalends/php/ext/tests/050.taitime_fromUTC.phpt create mode 100644 libcalends/php/ext/tests/051.panicHandling.phpt create mode 100644 libcalends/php/ext/tests/052.calendarUnregister.phpt create mode 100644 libcalends/php/ext/wrap_libcalends.c create mode 100644 libcalends/php/ext/wrap_libcalends.h create mode 100644 libcalends/php/opt/CalendsAbutsOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddFromEndDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddFromEndLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddFromEndStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsAddStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsCalendarListRegisteredOptimizer.php create mode 100644 libcalends/php/opt/CalendsCalendarRegisterOptimizer.php create mode 100644 libcalends/php/opt/CalendsCalendarRegisteredOptimizer.php create mode 100644 libcalends/php/opt/CalendsCalendarUnregisterOptimizer.php create mode 100644 libcalends/php/opt/CalendsCompareOptimizer.php create mode 100644 libcalends/php/opt/CalendsContainsOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateDoubleEndPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateDoubleRangeOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateDoubleStartPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateLongLongEndPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateLongLongRangeOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateLongLongStartPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateStringEndPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateStringRangeOptimizer.php create mode 100644 libcalends/php/opt/CalendsCreateStringStartPeriodOptimizer.php create mode 100644 libcalends/php/opt/CalendsDateOptimizer.php create mode 100644 libcalends/php/opt/CalendsDecodeJsonOptimizer.php create mode 100644 libcalends/php/opt/CalendsDecodeTextOptimizer.php create mode 100644 libcalends/php/opt/CalendsDifferenceOptimizer.php create mode 100644 libcalends/php/opt/CalendsDurationOptimizer.php create mode 100644 libcalends/php/opt/CalendsEncodeJsonOptimizer.php create mode 100644 libcalends/php/opt/CalendsEncodeTextOptimizer.php create mode 100644 libcalends/php/opt/CalendsEndDateOptimizer.php create mode 100644 libcalends/php/opt/CalendsEndsAfterOptimizer.php create mode 100644 libcalends/php/opt/CalendsEndsBeforeOptimizer.php create mode 100644 libcalends/php/opt/CalendsEndsDuringOptimizer.php create mode 100644 libcalends/php/opt/CalendsGapOptimizer.php create mode 100644 libcalends/php/opt/CalendsIntersectOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsAfterOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsBeforeOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsDuringOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsLongerOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsSameDurationOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsSameOptimizer.php create mode 100644 libcalends/php/opt/CalendsIsShorterOptimizer.php create mode 100644 libcalends/php/opt/CalendsMergeOptimizer.php create mode 100644 libcalends/php/opt/CalendsNextDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsNextLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsNextStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsOverlapsOptimizer.php create mode 100644 libcalends/php/opt/CalendsPreviousDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsPreviousLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsPreviousStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsReleaseOptimizer.php create mode 100644 libcalends/php/opt/CalendsStartsAfterOptimizer.php create mode 100644 libcalends/php/opt/CalendsStartsBeforeOptimizer.php create mode 100644 libcalends/php/opt/CalendsStartsDuringOptimizer.php create mode 100644 libcalends/php/opt/CalendsStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractFromEndDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractFromEndLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractFromEndStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsSubtractStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDateDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDateLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDateStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationFromEndDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationFromEndLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationFromEndStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithDurationStringOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithEndDateDoubleOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithEndDateLongLongOptimizer.php create mode 100644 libcalends/php/opt/CalendsWithEndDateStringOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeAddOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeDecodeTextOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeDoubleOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeEncodeTextOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeFromDoubleOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeFromHexStringOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeFromStringOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeHexStringOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeStringOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeSubOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeTaiToUtcOptimizer.php create mode 100644 libcalends/php/opt/Tai64timeUtcToTaiOptimizer.php create mode 100755 tests/failed_test_info.sh create mode 100755 tests/go.nanobox.sh diff --git a/.gitignore b/.gitignore index 56e7c1a..47675f6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,16 @@ /calends /coverage.htm + +.temp/ +compile.log +compile-errors.log +.libs/ +autom4te.cache/ +build/ +.deps +*/Makefile +*/Makefile.* +core* +!core*.sh +*~ diff --git a/.travis.yml b/.travis.yml index a3e694c..3e3abbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,68 @@ go: addons: apt: packages: + - valgrind - gdb + - libpcre3-dev + +matrix: + allow_failures: + - language: php + php: '7.0' + - language: php + php: 'nightly' + include: + - &phpDefaults + language: php + php: '7.2' + before_install: + - export ZEPHIR_VERSION="development" + - export ZEPHIR_PARSER_VERSION="v1.1.2" + - export RE2C_VERSION=1.0.3 + - export PHP_MAJOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 1)" + - export PHP_MINOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 2)" + install: + - git clone --depth=1 -v https://github.com/phalcon/zephir -b ${ZEPHIR_VERSION} + - cd zephir + - bash ./unit-tests/ci/install-re2c $RE2C_VERSION + - bash ./unit-tests/ci/install_zephir_parser.sh + - ./install -c + - cd .. + before_script: + - | + GIMME_OUTPUT="$(gimme 1.10 | tee -a ${HOME}/.bashrc)" && eval "$GIMME_OUTPUT" + export GOPATH=${HOME}/gopath + export PATH=${GOPATH}/bin:$PATH + mkdir -p ${GOPATH}/src/github.com/danhunsaker/calends + rsync -az ${TRAVIS_BUILD_DIR}/ ${GOPATH}/src/github.com/danhunsaker/calends/ + export TRAVIS_BUILD_DIR=${GOPATH}/src/github.com/danhunsaker/calends + - | + cd ${TRAVIS_BUILD_DIR} + go get -t -v ./... + - | + cd ${TRAVIS_BUILD_DIR}/libcalends + go build -o libcalends.so -buildmode=c-shared . + - | + cd ${TRAVIS_BUILD_DIR}/libcalends/php + zephir builddev -v + - echo "set auto-load safe-path /" > ~/.gdbinit + - ulimit -c unlimited || true + - echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern &> /dev/null + - sudo chmod +s $(which gdb) + script: + - | + cd ${TRAVIS_BUILD_DIR}/libcalends/php/ext + TRAVIS='' NO_INTERACTION=true php run-tests.php -P -d "extension=calends.so" + - ${TRAVIS_BUILD_DIR}/tests/failed_test_info.sh + + - << : *phpDefaults + php: '7.1' + + - << : *phpDefaults + php: '7.0' + + - << : *phpDefaults + php: 'nightly' before_script: - echo "set auto-load safe-path /" > ~/.gdbinit diff --git a/boxfile.yml b/boxfile.yml new file mode 100644 index 0000000..1beac90 --- /dev/null +++ b/boxfile.yml @@ -0,0 +1,40 @@ +run.config: + engine: php#option/no-default-cache-dirs + engine.config: + runtime: php-7.1 + extensions: + - xml + - zephir_parser + extra_packages: + - go + - autoconf + - re2c + cache_dirs: + - .gopath + extra_path_dirs: + - .gopath/bin + cwd: /app/.gopath/src/github.com/danhunsaker/calends + extra_steps: + - | + # Set up Go stuff + export GOPATH=/app/.gopath + echo /app/.gopath > /data/etc/env.d/GOPATH + mkdir -p /app/.gopath/{bin,src/github.com/danhunsaker} + ln -sfT /app /app/.gopath/src/github.com/danhunsaker/calends + cd /app/.gopath/src/github.com/danhunsaker/calends + go get -t -v ./... + - | + # Install Zephir + cd /data + if [ ! -d zephir ] + then + git clone https://github.com/phalcon/zephir + cd zephir + else + cd zephir + git pull + fi + sed "s#%ZEPHIRDIR%#$(pwd)#g" bin/zephir > bin/zephir-cmd + chmod 755 bin/zephir-cmd + cp bin/zephir-cmd /data/bin/zephir + rm bin/zephir-cmd diff --git a/calendars/0calendars.go b/calendars/0calendars.go index f74ca59..637bbc5 100644 --- a/calendars/0calendars.go +++ b/calendars/0calendars.go @@ -17,6 +17,7 @@ package calendars import ( "errors" // "fmt" + "sort" "strings" ) @@ -45,6 +46,8 @@ var ( ErrInvalidFormat = errors.New("Invalid Format") ) +// ErrUnknownCalendar generates a "calendar not registered" error including the +// calendar's actual name in the error message func ErrUnknownCalendar(calendar string) error { return errors.New("Unknown Calendar: " + calendar) } @@ -84,12 +87,31 @@ func RegisterElements( } } +// Unregister removes a calendar system from the callback list. +func Unregister(name string) { + if Registered(name) { + delete(registeredCalendars, canonCalendarName(name)) + } +} + // Registered returns whether or not a calendar system has been registered, yet. func Registered(calendar string) bool { _, set := registeredCalendars[canonCalendarName(calendar)] return set } +// ListRegistered returns the list of calendar systems currently registered. +func ListRegistered() []string { + var out []string + + for name := range registeredCalendars { + out = append(out, name) + } + sort.Strings(out) + + return out +} + // DefaultFormat returns the associated value from a registered calendar system. func DefaultFormat(calendar string) string { if !Registered(calendar) { diff --git a/calendars/0calendars_test.go b/calendars/0calendars_test.go index 9091a91..d7f504d 100644 --- a/calendars/0calendars_test.go +++ b/calendars/0calendars_test.go @@ -2,6 +2,7 @@ package calendars import ( "errors" + "strings" "testing" ) @@ -56,6 +57,21 @@ func TestRegisterElements(t *testing.T) { } } +func TestUnregister(t *testing.T) { + instance := testCalendarClass{} + RegisterClass("testCalendarClass", instance, instance.DefaultFormat) + + if !Registered("testCalendarClass") { + t.Errorf("RegisterClass(%#v, %#v) failed", "testCalendarClass", instance) + } + + Unregister("testCalendarClass") + + if Registered("testCalendarClass") { + t.Errorf("Unregister(%#v) failed", "testCalendarClass") + } +} + func TestRegistered(t *testing.T) { if Registered("testCalendar") { t.Errorf("Registered(testCalendar) failed - the calendar should not be registered before the test starts") @@ -69,6 +85,29 @@ func TestRegistered(t *testing.T) { } } +func TestListRegistered(t *testing.T) { + Unregister("testCalendar") + Unregister("testCalendarClass") + Unregister("testCalendarElements") + + got := ListRegistered() + want := []string{"Gregorian", "Jdc", "Stardate", "Tai64", "Unix"} + if strings.Join(got, ":") != strings.Join(want, ":") { + t.Errorf("ListRegistered() failed - the calendar list was incorrect:\n\twant: %v\n\t got: %v", want, got) + } + + instance := testCalendarClass{"test"} + RegisterClass("teSt CaLenDar", instance, instance.DefaultFormat) + + got = ListRegistered() + want = []string{"Gregorian", "Jdc", "Stardate", "Tai64", "TestCalendar", "Unix"} + if strings.Join(got, ":") != strings.Join(want, ":") { + t.Errorf("ListRegistered() failed - the calendar list was incorrect:\n\twant: %v\n\t got: %v", want, got) + } + + Unregister("test calendar") +} + func TestDefaultFormat(t *testing.T) { if !Registered("testCalendar") { TestRegistered(t) diff --git a/calendars/0leapseconds.go b/calendars/0leapseconds.go index 5e80985..7d92956 100644 --- a/calendars/0leapseconds.go +++ b/calendars/0leapseconds.go @@ -130,16 +130,16 @@ func init() { // UTCtoTAI removes the UTC leap second offset from a TAI64NAXURTime value. func UTCtoTAI(utc TAI64NAXURTime) (tai TAI64NAXURTime) { // Calculate year, month, day - oldYear, oldMonth, oldDay := time.Unix(utc.Seconds, int64(utc.Nano)).Date() + oldYear, oldMonth, oldDay := time.Unix(utc.Seconds, int64(utc.Nano)).UTC().Date() // Remove the leap second offset tai = utc.Sub(getTAIOffset(oldYear, oldMonth, oldDay)) // Ensure we used the correct offset - newYear, newMonth, newDay := time.Unix(tai.Seconds, int64(tai.Nano)).Date() + newYear, newMonth, newDay := time.Unix(tai.Seconds, int64(tai.Nano)).UTC().Date() for newYear != oldYear || newMonth != oldMonth || newDay != oldDay { tai = utc.Sub(getTAIOffset(newYear, newMonth, newDay)) oldYear, oldMonth, oldDay = newYear, newMonth, newDay - newYear, newMonth, newDay = time.Unix(tai.Seconds, int64(tai.Nano)).Date() + newYear, newMonth, newDay = time.Unix(tai.Seconds, int64(tai.Nano)).UTC().Date() } return @@ -148,7 +148,7 @@ func UTCtoTAI(utc TAI64NAXURTime) (tai TAI64NAXURTime) { // TAItoUTC adds the UTC leap second offset to a TAI64NAXURTime value. func TAItoUTC(tai TAI64NAXURTime) (utc TAI64NAXURTime) { // Calculate year, month, day - year, month, day := time.Unix(tai.Seconds, int64(tai.Nano)).Date() + year, month, day := time.Unix(tai.Seconds, int64(tai.Nano)).UTC().Date() // Add the leap second offset utc = tai.Add(getTAIOffset(year, month, day)) diff --git a/calendars/gregorian.go b/calendars/gregorian.go index cae0d77..81da8a5 100644 --- a/calendars/gregorian.go +++ b/calendars/gregorian.go @@ -66,7 +66,7 @@ func init() { }, // fromInternal func(stamp TAI64NAXURTime, format string) (date string, err error) { - tmp := time.Unix(stamp.Seconds, int64(stamp.Nano)) + tmp := time.Unix(stamp.Seconds, int64(stamp.Nano)).UTC() if strings.ContainsRune(format, '%') { date, err = datefmt.Strftime(format, tmp) } else { @@ -82,7 +82,7 @@ func init() { switch offset.(type) { case time.Duration: dur := offset.(time.Duration) - r := time.Unix(in.Seconds, int64(in.Nano)).Add(dur) + r := time.Unix(in.Seconds, int64(in.Nano)).UTC().Add(dur) out.Seconds = r.Unix() out.Nano = uint32(r.Nanosecond()) return @@ -101,7 +101,7 @@ func init() { w.Add(when_en.All...) w.Add(when_common.All...) - r, err := w.Parse(str, time.Unix(in.Seconds, int64(in.Nano))) + r, err := w.Parse(str, time.Unix(in.Seconds, int64(in.Nano)).UTC()) if err != nil { return } diff --git a/calendars/gregorian_test.go b/calendars/gregorian_test.go index a44a729..c76012f 100644 --- a/calendars/gregorian_test.go +++ b/calendars/gregorian_test.go @@ -11,7 +11,7 @@ func TestGregorianToInternal(t *testing.T) { {"in": []interface{}{"1970-01-01 00:00:01 UTC", "2006-01-02 15:04:05 MST"}, "want": []interface{}{TAI64NAXURTimeFromDecimalString("-6.997489999999999987778664944926276803016662598"), nil}}, {"in": []interface{}{"1970-01-01 00:00:01 UTC", "%Y-%m-%d %H:%M:%S %Z"}, "want": []interface{}{TAI64NAXURTimeFromDecimalString("-6.997489999999999987778664944926276803016662598"), nil}}, {"in": []interface{}{[]byte("Thu, 01 Jan 1970 00:00:01 UTC"), ""}, "want": []interface{}{TAI64NAXURTimeFromDecimalString("-6.997489999999999987778664944926276803016662598"), nil}}, - {"in": []interface{}{time.Unix(1, 0), ""}, "want": []interface{}{TAI64NAXURTimeFromDecimalString("-6.997489999999999987778664944926276803016662598"), nil}}, + {"in": []interface{}{time.Unix(1, 0).UTC(), ""}, "want": []interface{}{TAI64NAXURTimeFromDecimalString("-6.997489999999999987778664944926276803016662598"), nil}}, {"in": []interface{}{1, ""}, "want": []interface{}{TAI64NAXURTime{}, ErrUnsupportedInput}}, {"in": []interface{}{1., ""}, "want": []interface{}{TAI64NAXURTime{}, ErrUnsupportedInput}}, diff --git a/calendars/stardate.go b/calendars/stardate.go index 4decb0b..bc442e7 100644 --- a/calendars/stardate.go +++ b/calendars/stardate.go @@ -336,9 +336,8 @@ func stardateOffset(in TAI64NAXURTime, offset interface{}) (out TAI64NAXURTime, _, err = fmt.Sscanf(mod, "%s %s", &date, &format) if err != nil && err.Error() != "EOF" { return - } else { - err = nil } + err = nil adjust, err = stardateToInternal(date, format) if err != nil { @@ -399,7 +398,7 @@ func stardateJDCToMain(jdc big.Float) string { issue, _ = tmp.Quo(stardate, big.NewFloat(10000.0)).Int64() stardate.Sub(stardate, big.NewFloat(float64(10000*issue))) if stardate.Cmp(big.NewFloat(0)) < 0 { - issue -= 1 + issue-- stardate.Add(stardate, big.NewFloat(10000)) } format = "[%d]%04.6g" @@ -479,9 +478,9 @@ func stardatePughToJDC(stardate string, fixed bool) big.Float { if fixed { return *new(big.Float).Add(stardatePughEpoch, new(big.Float).Mul(new(big.Float).Add(new(big.Float).SetInt64(prefix), new(big.Float).Quo(suffix, big.NewFloat(1000.0))), big.NewFloat(365.2425))) - } else { - return yearfToJDC(*new(big.Float).Add(new(big.Float).Add(new(big.Float).SetInt64(prefix), big.NewFloat(2323.0)), new(big.Float).Quo(suffix, big.NewFloat(1000.0)))) } + + return yearfToJDC(*new(big.Float).Add(new(big.Float).Add(new(big.Float).SetInt64(prefix), big.NewFloat(2323.0)), new(big.Float).Quo(suffix, big.NewFloat(1000.0)))) } func stardateJDCToPugh(jdc big.Float, fixed bool) string { diff --git a/calends.go b/calends.go index 5c50663..2ac17bb 100644 --- a/calends.go +++ b/calends.go @@ -41,7 +41,7 @@ type Calends struct { } // Version of the library -var Version string = "0.0.3" +var Version = "0.0.3" // Create is the mechanism for constructing new Calends objects. /* diff --git a/libcalends/calendars.go b/libcalends/calendars.go index 505e52b..99ec337 100644 --- a/libcalends/calendars.go +++ b/libcalends/calendars.go @@ -57,6 +57,7 @@ import "C" import ( "math/big" + "strings" "unsafe" "github.com/danhunsaker/calends/calendars" @@ -84,11 +85,21 @@ func Calends_calendar_register( ) } +//export Calends_calendar_unregister +func Calends_calendar_unregister(name *C.char) { + calendars.Unregister(C.GoString(name)) +} + //export Calends_calendar_registered func Calends_calendar_registered(calendar *C.char) bool { return calendars.Registered(C.GoString(calendar)) } +//export Calends_calendar_list_registered +func Calends_calendar_list_registered() *C.char { + return C.CString(strings.Join(calendars.ListRegistered(), "\n")) +} + //export TAI64Time_add func TAI64Time_add(t C.TAI64Time, z C.TAI64Time) C.TAI64Time { base := taiCToGo(t) diff --git a/libcalends/calendars_tests.go b/libcalends/calendars_tests.go index d6d82f7..ff4f14e 100644 --- a/libcalends/calendars_tests.go +++ b/libcalends/calendars_tests.go @@ -86,6 +86,16 @@ func testCalends_calendar_registered(t *testing.T) { } } +func testCalends_calendar_list_registered(t *testing.T) { + t.Helper() + + ret := Calends_calendar_list_registered() + want := "Gregorian\nJdc\nStardate\nTai64\nUnix" + if C.GoString(ret) != want { + t.Errorf("Calends_calendar_list_registered() returned %#v; wanted %#v", C.GoString(ret), want) + } +} + func testCalends_calendar_register(t *testing.T) { t.Helper() @@ -169,6 +179,41 @@ func testCalends_calendar_register(t *testing.T) { } } +func testCalends_calendar_unregister(t *testing.T) { + t.Helper() + + if !Calends_calendar_registered(C.CString("test")) { + Calends_calendar_register( + C.CString("test"), C.CString("default"), + C.Calends_calendar_to_internal_string(C.test_Calends_calendar_to_internal_string), + C.Calends_calendar_to_internal_long_long(C.test_Calends_calendar_to_internal_long_long), + C.Calends_calendar_to_internal_double(C.test_Calends_calendar_to_internal_double), + C.Calends_calendar_to_internal_tai(C.test_Calends_calendar_to_internal_tai), + C.Calends_calendar_from_internal(C.test_Calends_calendar_from_internal), + C.Calends_calendar_offset_string(C.test_Calends_calendar_offset_string), + C.Calends_calendar_offset_long_long(C.test_Calends_calendar_offset_long_long), + C.Calends_calendar_offset_double(C.test_Calends_calendar_offset_double), + C.Calends_calendar_offset_tai(C.test_Calends_calendar_offset_tai), + ) + } + + in := "test" + ret := Calends_calendar_registered(C.CString(in)) + want := true + if bool(ret) != want { + t.Errorf("Calends_calendar_registered(%#v) returned %#v; wanted %#v", in, bool(ret), want) + } + + Calends_calendar_unregister(C.CString("test")) + + in = "test" + ret = Calends_calendar_registered(C.CString(in)) + want = false + if bool(ret) != want { + t.Errorf("Calends_calendar_registered(%#v) returned %#v; wanted %#v", in, bool(ret), want) + } +} + func testTAI64Time_add(t *testing.T) { t.Helper() diff --git a/libcalends/calends.go b/libcalends/calends.go index 2f77de2..66813b9 100644 --- a/libcalends/calends.go +++ b/libcalends/calends.go @@ -21,35 +21,35 @@ var SHARDS = uint64(64) type ConcurrentMap []*ConcurrentMapShard type ConcurrentMapShard struct { - items map[uint64]interface{} - sync.RWMutex + items map[uint64]interface{} + sync.RWMutex } func NewConcurrentMap() ConcurrentMap { - m := make(ConcurrentMap, SHARDS) - for i := uint64(0); i < SHARDS; i++ { - m[i] = &ConcurrentMapShard{items: make(map[uint64]interface{})} - } - return m + m := make(ConcurrentMap, SHARDS) + for i := uint64(0); i < SHARDS; i++ { + m[i] = &ConcurrentMapShard{items: make(map[uint64]interface{})} + } + return m } func (m ConcurrentMap) getShard(key uint64) *ConcurrentMapShard { - return m[key%SHARDS] + return m[key%SHARDS] } func (m ConcurrentMap) Store(key uint64, value interface{}) { - shard := m.getShard(key) - shard.Lock() - shard.items[key] = value - shard.Unlock() + shard := m.getShard(key) + shard.Lock() + shard.items[key] = value + shard.Unlock() } func (m ConcurrentMap) Load(key uint64) (interface{}, bool) { - shard := m.getShard(key) - shard.RLock() - val, ok := shard.items[key] - shard.RUnlock() - return val, ok + shard := m.getShard(key) + shard.RLock() + val, ok := shard.items[key] + shard.RUnlock() + return val, ok } func (m ConcurrentMap) Length() (out uint64) { @@ -73,18 +73,18 @@ func (m ConcurrentMap) All() (out []interface{}) { } func (m ConcurrentMap) Delete(key uint64) { - shard := m.getShard(key) - shard.Lock() - delete(shard.items, key) - shard.Unlock() + shard := m.getShard(key) + shard.Lock() + delete(shard.items, key) + shard.Unlock() } type IdGenerator struct { - id uint64 + id uint64 } func (generator *IdGenerator) Id() uint64 { - return atomic.AddUint64(&generator.id, 1) + return atomic.AddUint64(&generator.id, 1) } var panicHandlers ConcurrentMap diff --git a/libcalends/libcalends_test.go b/libcalends/libcalends_test.go index ddd4d22..d30d6f3 100644 --- a/libcalends/libcalends_test.go +++ b/libcalends/libcalends_test.go @@ -323,10 +323,18 @@ func TestCalends_calendar_registered(t *testing.T) { defer testingPanicCatcher(t) testCalends_calendar_registered(t) } +func TestCalends_calendar_list_registered(t *testing.T) { + defer testingPanicCatcher(t) + testCalends_calendar_list_registered(t) +} func TestCalends_calendar_register(t *testing.T) { defer testingPanicCatcher(t) testCalends_calendar_register(t) } +func TestCalends_calendar_unregister(t *testing.T) { + defer testingPanicCatcher(t) + testCalends_calendar_unregister(t) +} func TestTAI64Time_add(t *testing.T) { defer testingPanicCatcher(t) testTAI64Time_add(t) diff --git a/libcalends/php/calends/calendarinterface.zep b/libcalends/php/calends/calendarinterface.zep new file mode 100644 index 0000000..28a0234 --- /dev/null +++ b/libcalends/php/calends/calendarinterface.zep @@ -0,0 +1,10 @@ +namespace Calends; + +interface CalendarInterface +{ + public static function toInternal(var date, string format) -> ; + + public static function fromInternal( stamp, string format) -> string; + + public static function offset( stamp, var offset) -> ; +} diff --git a/libcalends/php/calends/calendarobjectinterface.zep b/libcalends/php/calends/calendarobjectinterface.zep new file mode 100644 index 0000000..ce4d3da --- /dev/null +++ b/libcalends/php/calends/calendarobjectinterface.zep @@ -0,0 +1,10 @@ +namespace Calends; + +interface CalendarObjectInterface +{ + public function toInternal(var date, string format) -> ; + + public function fromInternal( stamp, string format) -> string; + + public function offset( stamp, var offset) -> ; +} diff --git a/libcalends/php/calends/calends.zep b/libcalends/php/calends/calends.zep new file mode 100644 index 0000000..b3854ca --- /dev/null +++ b/libcalends/php/calends/calends.zep @@ -0,0 +1,783 @@ +namespace Calends; + +class Calends implements \Serializable//, \JsonSerializable +{ + private goId = 0.0; + + private static calendars = []; + + private function __construct() + { + return; + } + + public function __destruct() + { + Calends_release(this->goId); + } + + public function __toString() -> string + { + string out; + + let out = Calends_string(this->goId); + + return out; + } + + public function serialize() -> string + { + string out; + + let out = Calends_encode_text(this->goId); + + return out; + } + + public function unserialize(data) -> void + { + double result; + + let result = Calends_decode_text((string)data); + + let this->goId = result; + } + + // public function jsonSerialize() -> string + // { + // return this->serialize(); + // } + + public static function create(var date = null, string calendar = null, string format = null) -> + { + var out, start, duration, end; + double result; + let out = new Calends; + + if empty date { + let date = ""; + } + if empty calendar { + let calendar = ""; + } + if empty format { + let format = ""; + } + + switch typeof date { + case "string": + let result = Calends_create_string((string)date, calendar, format); + break; + case "integer": + let result = Calends_create_long_long((long)date, calendar, format); + break; + case "double": + let result = Calends_create_double((double)date, calendar, format); + break; + case "array": + if fetch start, date["start"] && fetch end, date["end"] { + switch typeof start { + case "string": + let result = Calends_create_string_range((string)start, (string)end, calendar, format); + break; + case "integer": + let result = Calends_create_long_long_range((long)start, (long)end, calendar, format); + break; + case "double": + let result = Calends_create_double_range((double)start, (double)end, calendar, format); + break; + default: + throw new CalendsException("Unsupported date type " . typeof start); + } + } elseif fetch start, date["start"] && fetch duration, date["duration"] { + switch typeof start { + case "string": + let result = Calends_create_string_start_period((string)start, (string)duration, calendar, format); + break; + case "integer": + let result = Calends_create_long_long_start_period((long)start, (long)duration, calendar, format); + break; + case "double": + let result = Calends_create_double_start_period((double)start, (double)duration, calendar, format); + break; + default: + throw new CalendsException("Unsupported date type " . typeof start); + } + } elseif fetch duration, date["duration"] && fetch end, date["end"] { + switch typeof duration { + case "string": + let result = Calends_create_string_end_period((string)duration, (string)end, calendar, format); + break; + case "integer": + let result = Calends_create_long_long_end_period((long)duration, (long)end, calendar, format); + break; + case "double": + let result = Calends_create_double_end_period((double)duration, (double)end, calendar, format); + break; + default: + throw new CalendsException("Unsupported date type " . typeof duration); + } + } + break; + default: + throw new CalendsException("Unsupported date type " . typeof date); + } + + let out->goId = result; + return out; + } + + public function date(string calendar = null, string format = null) -> string + { + string out; + + if empty calendar { + let calendar = ""; + } + if empty format { + let format = ""; + } + + let out = Calends_date(this->goId, calendar, format); + + return out; + } + + public function duration() -> string + { + string out; + + let out = Calends_duration(this->goId); + + return out; + } + + public function endDate(string calendar = null, string format = null) -> string + { + string out; + + if empty calendar { + let calendar = ""; + } + if empty format { + let format = ""; + } + + let out = Calends_end_date(this->goId, calendar, format); + + return out; + } + + public function json(string encoded = null) -> string|null + { + if empty encoded { + string out; + + let out = Calends_encode_json(this->goId); + + return out; + } else { + double result; + + let result = Calends_decode_json(encoded); + + let this->goId = result; + } + return; + } + + public function difference( z, string mode = null) -> string + { + string out; + + if empty mode { + let mode = ""; + } + + let out = Calends_difference(this->goId, z->goId, mode); + + return out; + } + + public function compare( z, string mode = null) -> int + { + var out; + + if empty mode { + let mode = ""; + } + + let out = Calends_compare(this->goId, z->goId, mode); + + return (int)out; + } + + public function isSame( z) -> bool + { + var out; + + let out = Calends_is_same(this->goId, z->goId); + + return (bool)out; + } + + public function isSameDuration( z) -> bool + { + var out; + + let out = Calends_is_same_duration(this->goId, z->goId); + + return (bool)out; + } + + public function isShorter( z) -> bool + { + var out; + + let out = Calends_is_shorter(this->goId, z->goId); + + return (bool)out; + } + + public function isLonger( z) -> bool + { + var out; + + let out = Calends_is_longer(this->goId, z->goId); + + return (bool)out; + } + + public function contains( z) -> bool + { + var out; + + let out = Calends_contains(this->goId, z->goId); + + return (bool)out; + } + + public function overlaps( z) -> bool + { + var out; + + let out = Calends_overlaps(this->goId, z->goId); + + return (bool)out; + } + + public function abuts( z) -> bool + { + var out; + + let out = Calends_abuts(this->goId, z->goId); + + return (bool)out; + } + + public function isBefore( z) -> bool + { + var out; + + let out = Calends_is_before(this->goId, z->goId); + + return (bool)out; + } + + public function startsBefore( z) -> bool + { + var out; + + let out = Calends_starts_before(this->goId, z->goId); + + return (bool)out; + } + + public function endsBefore( z) -> bool + { + var out; + + let out = Calends_ends_before(this->goId, z->goId); + + return (bool)out; + } + + public function isDuring( z) -> bool + { + var out; + + let out = Calends_is_during(this->goId, z->goId); + + return (bool)out; + } + + public function startsDuring( z) -> bool + { + var out; + + let out = Calends_starts_during(this->goId, z->goId); + + return (bool)out; + } + + public function endsDuring( z) -> bool + { + var out; + + let out = Calends_ends_during(this->goId, z->goId); + + return (bool)out; + } + + public function isAfter( z) -> bool + { + var out; + + let out = Calends_is_after(this->goId, z->goId); + + return (bool)out; + } + + public function startsAfter( z) -> bool + { + var out; + + let out = Calends_starts_after(this->goId, z->goId); + + return (bool)out; + } + + public function endsAfter( z) -> bool + { + var out; + + let out = Calends_ends_after(this->goId, z->goId); + + return (bool)out; + } + + public function add(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_add_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_add_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_add_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function subtract(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_subtract_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_subtract_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_subtract_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function addFromEnd(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_add_from_end_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_add_from_end_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_add_from_end_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function subtractFromEnd(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_subtract_from_end_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_subtract_from_end_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_subtract_from_end_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function next(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_next_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_next_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_next_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function previous(var offset = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty offset { + let offset = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof offset { + case "string": + let result = Calends_previous_string(this->goId, (string)offset, calendar); + break; + case "integer": + let result = Calends_previous_long_long(this->goId, (long)offset, calendar); + break; + case "double": + let result = Calends_previous_double(this->goId, (double)offset, calendar); + break; + default: + throw new CalendsException("Unsupported offset type " . typeof offset); + } + + let out->goId = result; + return out; + } + + public function withDate(var date = null, string calendar = null, string format = null) -> + { + var out; + double result; + let out = new Calends; + + if empty date { + let date = ""; + } + if empty calendar { + let calendar = ""; + } + if empty format { + let format = ""; + } + + switch typeof date { + case "string": + let result = Calends_with_date_string(this->goId, (string)date, calendar, format); + break; + case "integer": + let result = Calends_with_date_long_long(this->goId, (long)date, calendar, format); + break; + case "double": + let result = Calends_with_date_double(this->goId, (double)date, calendar, format); + break; + default: + throw new CalendsException("Unsupported date type " . typeof date); + } + + let out->goId = result; + return out; + } + + public function withDuration(var duration = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty duration { + let duration = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof duration { + case "string": + let result = Calends_with_duration_string(this->goId, (string)duration, calendar); + break; + case "integer": + let result = Calends_with_duration_long_long(this->goId, (long)duration, calendar); + break; + case "double": + let result = Calends_with_duration_double(this->goId, (double)duration, calendar); + break; + default: + throw new CalendsException("Unsupported duration type " . typeof duration); + } + + let out->goId = result; + return out; + } + + public function withDurationFromEnd(var duration = null, string calendar = null) -> + { + var out; + double result; + let out = new Calends; + + if empty duration { + let duration = ""; + } + if empty calendar { + let calendar = ""; + } + + switch typeof duration { + case "string": + let result = Calends_with_duration_from_end_string(this->goId, (string)duration, calendar); + break; + case "integer": + let result = Calends_with_duration_from_end_long_long(this->goId, (long)duration, calendar); + break; + case "double": + let result = Calends_with_duration_from_end_double(this->goId, (double)duration, calendar); + break; + default: + throw new CalendsException("Unsupported duration type " . typeof duration); + } + + let out->goId = result; + return out; + } + + public function withEndDate(var date = null, string calendar = null, string format = null) -> + { + var out; + double result; + let out = new Calends; + + if empty date { + let date = ""; + } + if empty calendar { + let calendar = ""; + } + if empty format { + let format = ""; + } + + switch typeof date { + case "string": + let result = Calends_with_end_date_string(this->goId, (string)date, calendar, format); + break; + case "integer": + let result = Calends_with_end_date_long_long(this->goId, (long)date, calendar, format); + break; + case "double": + let result = Calends_with_end_date_double(this->goId, (double)date, calendar, format); + break; + default: + throw new CalendsException("Unsupported date type " . typeof date); + } + + let out->goId = result; + return out; + } + + public function merge( z) -> + { + var out; + double result; + let out = new Calends; + + let result = Calends_merge(this->goId, z->goId); + + let out->goId = result; + return out; + } + + public function intersect( z) -> + { + var out; + double result; + let out = new Calends; + + let result = Calends_intersect(this->goId, z->goId); + + let out->goId = result; + return out; + } + + public function gap( z) -> + { + var out; + double result; + let out = new Calends; + + let result = Calends_gap(this->goId, z->goId); + + let out->goId = result; + return out; + } + + public static function calendarRegistered(string name) -> bool + { + var out; + + let out = Calends_calendar_registered(name); + + return (bool)out; + } + + public static function calendarListRegistered() -> array + { + var result; + + let result = explode("\n", Calends_calendar_list_registered()); + + return (array)result; + } + + public static function calendarRegister(string name, string defaultFormat, var calendar) -> void + { + if !((is_string(calendar) && class_exists(calendar) && is_subclass_of(calendar, "Calends\\CalendarInterface")) + || calendar instanceof CalendarInterface || calendar instanceof CalendarObjectInterface) { + if is_string(calendar) { + throw new CalendsException("Parameter 'calendar' must name or be an implementation of Calends\\CalendarInterface or Calends\\CalendarObjectInterface; got " . calendar . " instead"); + } else { + throw new CalendsException("Parameter 'calendar' must name or be an implementation of Calends\\CalendarInterface or Calends\\CalendarObjectInterface; got a(n) " . get_class(calendar) . " instead"); + } + } + + if is_string(calendar) && class_exists(calendar) && is_subclass_of(calendar, "Calends\\CalendarInterface") { + let self::calendars[name] = [ + "toInternal": calendar . "::" . "toInternal", + "fromInternal": calendar . "::" . "fromInternal", + "offset": calendar . "::" . "offset" + ]; + } elseif calendar instanceof CalendarInterface { + let self::calendars[name] = [ + "toInternal": typeof calendar . "::" . "toInternal", + "fromInternal": typeof calendar . "::" . "fromInternal", + "offset": typeof calendar . "::" . "offset" + ]; + } else { + let self::calendars[name] = [ + "toInternal": [calendar, "toInternal"], + "fromInternal": [calendar, "fromInternal"], + "offset": [calendar, "offset"] + ]; + } + + Calends_calendar_register(name, defaultFormat); + + return; + } + + public static function calendarUnregister(string name) -> void + { + var calendar; + + if name == "*" { + for calendar, _ in self::calendars { + self::calendarUnregister(calendar); + } + } elseif fetch calendar, self::calendars[name] { + Calends_calendar_unregister(name); + + unset(self::calendars[name]); + } else { + // This calendar was never registered, so there's nothing to do, here. + } + + return; + } +} diff --git a/libcalends/php/calends/calendsexception.zep b/libcalends/php/calends/calendsexception.zep new file mode 100644 index 0000000..701ccd0 --- /dev/null +++ b/libcalends/php/calends/calendsexception.zep @@ -0,0 +1,3 @@ +namespace Calends; + +class CalendsException extends \Exception {} diff --git a/libcalends/php/calends/taitime.zep b/libcalends/php/calends/taitime.zep new file mode 100644 index 0000000..d8a9c43 --- /dev/null +++ b/libcalends/php/calends/taitime.zep @@ -0,0 +1,161 @@ +namespace Calends; + +class TAITime implements \Serializable +{ + public seconds = 0.0; + public nano = 0; + public atto = 0; + public xicto = 0; + public ucto = 0; + public rocto = 0; + + public function __construct(stamp = null) + { + var result; + + if empty stamp { + let stamp = ""; + } + + switch typeof stamp { + case "string": + if substr(stamp, 0, 2) == "0x" { + let result = TAI64Time_from_hex_string(stamp); + } else { + let result = TAI64Time_from_string(stamp); + } + break; + case "integer": + case "double": + let result = TAI64Time_from_double((double)stamp); + break; + default: + throw new CalendsException("Unsupported input type " . typeof stamp); + } + + let this->seconds = result->seconds ?: 0.0; + let this->nano = result->nano ?: 0; + let this->atto = result->atto ?: 0; + let this->xicto = result->xicto ?: 0; + let this->ucto = result->ucto ?: 0; + let this->rocto = result->rocto ?: 0; + } + + public function __toString() -> string + { + return self::toString(); + } + + public function serialize() -> string + { + string out; + + let out = TAI64Time_encode_text(this); + + return out; + } + + public function unserialize(data) -> void + { + var result; + + let result = TAI64Time_decode_text((string)data); + + let this->seconds = result->seconds; + let this->nano = result->nano; + let this->atto = result->atto; + let this->xicto = result->xicto; + let this->ucto = result->ucto; + let this->rocto = result->rocto; + } + + public function add( z) -> + { + var result; + + let result = TAI64Time_add(this, z); + + return result; + } + + public function sub( z) -> + { + var result; + + let result = TAI64Time_sub(this, z); + + return result; + } + + public function toString() -> string + { + string out; + + let out = TAI64Time_string(this); + + return out; + } + + public static function fromString(string value = null) -> + { + var result; + + let result = TAI64Time_from_string(value); + + return result; + } + + public function toHex() -> string + { + string out; + + let out = TAI64Time_hex_string(this); + + return out; + } + + public static function fromHex(string value = null) -> + { + var result; + + let result = TAI64Time_from_hex_string(value); + + return result; + } + + public function toNumber() -> double + { + var out; + + let out = TAI64Time_double(this); + + return (double)out; + } + + public static function fromNumber(value = null) -> + { + var result; + + let result = TAI64Time_from_double((double)value); + + return result; + } + + public function toUTC() -> + { + var result; + + let result = TAI64Time_tai_to_utc(this); + + return result; + } + + public function fromUTC() -> + { + var result; + + let result = TAI64Time_utc_to_tai(this); + + return result; + } +} diff --git a/libcalends/php/config.json b/libcalends/php/config.json new file mode 100644 index 0000000..b7a9a49 --- /dev/null +++ b/libcalends/php/config.json @@ -0,0 +1,67 @@ +{ + "warnings": { + "unused-variable": true, + "unused-variable-external": false, + "possible-wrong-parameter": true, + "possible-wrong-parameter-undefined": false, + "nonexistent-function": true, + "nonexistent-class": true, + "non-valid-isset": true, + "non-array-update": true, + "non-valid-objectupdate": true, + "non-valid-fetch": true, + "invalid-array-index": true, + "non-array-append": true, + "invalid-return-type": true, + "unreachable-code": true, + "nonexistent-constant": true, + "not-supported-magic-constant": true, + "non-valid-decrement": true, + "non-valid-increment": true, + "non-valid-clone": true, + "non-valid-new": true, + "non-array-access": true, + "invalid-reference": true, + "invalid-typeof-comparison": true, + "conditional-initialization": true + }, + "optimizations": { + "static-type-inference": true, + "static-type-inference-second-pass": true, + "local-context-pass": true, + "constant-folding": true, + "static-constant-class-folding": true, + "call-gatherer-pass": true, + "check-invalid-reads": false, + "internal-call-transformation": false + }, + "namespace": "calends", + "name": "calends", + "description": "A PHP extension for handling dates and times across arbitrary calendar systems", + "author": "Dan Hunsaker ", + "version": "0.0.3", + "extra-cflags": "-I$(readlink -f $(pwd)/../..)", + "extra-libs": "-L$(readlink -f $(pwd)/../..) -lcalends", + "optimizer-dirs": [ + "opt" + ], + "extra-sources": [ + "wrap_libcalends.c" + ], + "initializers": { + "module": [ + { + "include": "wrap_libcalends.h", + "code": "Calends_register_panic_handler(ext_panic_handler)" + } + ] + }, + "destructors": { + "request": [ + { + "include": "wrap_libcalends.h", + "code": "ext_unregister_all_calendars()" + } + ] + } +} diff --git a/libcalends/php/ext/.gitignore b/libcalends/php/ext/.gitignore new file mode 100644 index 0000000..2e41fed --- /dev/null +++ b/libcalends/php/ext/.gitignore @@ -0,0 +1,57 @@ +.deps +*.gch +*.lo +*.la +.libs +acinclude.m4 +aclocal.m4 +autom4te.cache +build +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.ac +configure.in +include +install-sh +libtool +ltmain.sh +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +missing +mkinstalldirs +modules +run-tests.php +calends/ +calends/* +calends/** +calends.c +calends.h +clean +config.m4 +config.w32 +ext_config.h +ext.h +install +php_calends.h +php_ext.h +tests/*.diff +tests/**.diff +tests/*.out +tests/**.out +tests/*.php +tests/**.php +tests/*.exp +tests/**.exp +tests/*.log +tests/**.log +tests/*.sh +tests/**.sh +kernel/ diff --git a/libcalends/php/ext/tests/.gitkeep b/libcalends/php/ext/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/libcalends/php/ext/tests/001.loaded.phpt b/libcalends/php/ext/tests/001.loaded.phpt new file mode 100644 index 0000000..37799b9 --- /dev/null +++ b/libcalends/php/ext/tests/001.loaded.phpt @@ -0,0 +1,14 @@ +--TEST-- +Check if calends is loaded +--SKIPIF-- + +--FILE-- + +--EXPECT-- +The extension "calends" is available diff --git a/libcalends/php/ext/tests/002.create.phpt b/libcalends/php/ext/tests/002.create.phpt new file mode 100644 index 0000000..6e8e94b --- /dev/null +++ b/libcalends/php/ext/tests/002.create.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends::create() Basic test +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/003.date.phpt b/libcalends/php/ext/tests/003.date.phpt new file mode 100644 index 0000000..9a8c1ed --- /dev/null +++ b/libcalends/php/ext/tests/003.date.phpt @@ -0,0 +1,21 @@ +--TEST-- +Calends\Calends->date() Basic test +--SKIPIF-- + +--FILE-- +date(), "\n"; + $tmp = Calends\Calends::create(null, 'tai64', 'decimal'); + echo $tmp->date(), "\n"; + $tmp = Calends\Calends::create('10', 'tai64', 'decimal'); + echo $tmp->date(), "\n"; +?> +--EXPECT-- +1.994980000 +8.000082000 +18.000082000 diff --git a/libcalends/php/ext/tests/004.duration.phpt b/libcalends/php/ext/tests/004.duration.phpt new file mode 100644 index 0000000..77c31ea --- /dev/null +++ b/libcalends/php/ext/tests/004.duration.phpt @@ -0,0 +1,21 @@ +--TEST-- +Calends\Calends->duration() Basic test +--SKIPIF-- + +--FILE-- +duration(), "\n"; + $tmp = Calends\Calends::create('10', 'tai64', 'decimal'); + echo $tmp->duration(), "\n"; + $tmp = Calends\Calends::create(['start' => '0', 'end' => '10'], 'tai64', 'decimal'); + echo $tmp->duration(), "\n"; +?> +--EXPECT-- +0 +0 +10 diff --git a/libcalends/php/ext/tests/005.endDate.phpt b/libcalends/php/ext/tests/005.endDate.phpt new file mode 100644 index 0000000..0e29447 --- /dev/null +++ b/libcalends/php/ext/tests/005.endDate.phpt @@ -0,0 +1,21 @@ +--TEST-- +Calends\Calends->endDate() Basic test +--SKIPIF-- + +--FILE-- +endDate(), "\n"; + $tmp = Calends\Calends::create(null, 'tai64', 'decimal'); + echo $tmp->endDate(), "\n"; + $tmp = Calends\Calends::create('10', 'tai64', 'decimal'); + echo $tmp->endDate(), "\n"; +?> +--EXPECT-- +1.994980000 +8.000082000 +18.000082000 diff --git a/libcalends/php/ext/tests/006.withDate.phpt b/libcalends/php/ext/tests/006.withDate.phpt new file mode 100644 index 0000000..dd6431c --- /dev/null +++ b/libcalends/php/ext/tests/006.withDate.phpt @@ -0,0 +1,24 @@ +--TEST-- +Calends\Calends->withDate() Basic test +--SKIPIF-- + +--FILE-- +withDate()); + echo $ret->date(), "\n"; + echo $ret->duration(), "\n"; + echo $ret->endDate(), "\n"; +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} +1.994980000 +17.99749 +18.000082000 diff --git a/libcalends/php/ext/tests/007.withDuration.phpt b/libcalends/php/ext/tests/007.withDuration.phpt new file mode 100644 index 0000000..8a4c264 --- /dev/null +++ b/libcalends/php/ext/tests/007.withDuration.phpt @@ -0,0 +1,24 @@ +--TEST-- +Calends\Calends->withDuration() Basic test +--SKIPIF-- + +--FILE-- +withDuration(10)); + echo $ret->date(), "\n"; + echo $ret->duration(), "\n"; + echo $ret->endDate(), "\n"; +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} +1.994980000 +10.002592 +11.994980000 diff --git a/libcalends/php/ext/tests/008.withDurationFromEnd.phpt b/libcalends/php/ext/tests/008.withDurationFromEnd.phpt new file mode 100644 index 0000000..a2caa4d --- /dev/null +++ b/libcalends/php/ext/tests/008.withDurationFromEnd.phpt @@ -0,0 +1,24 @@ +--TEST-- +Calends\Calends->withDurationFromEnd() Basic test +--SKIPIF-- + +--FILE-- +withDurationFromEnd(10)); + echo $ret->date(), "\n"; + echo $ret->duration(), "\n"; + echo $ret->endDate(), "\n"; +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} +8.000082000 +10 +18.000082000 diff --git a/libcalends/php/ext/tests/009.withEndDate.phpt b/libcalends/php/ext/tests/009.withEndDate.phpt new file mode 100644 index 0000000..d7be510 --- /dev/null +++ b/libcalends/php/ext/tests/009.withEndDate.phpt @@ -0,0 +1,24 @@ +--TEST-- +Calends\Calends->withEndDate() Basic test +--SKIPIF-- + +--FILE-- +withEndDate('10', 'tai64', 'decimal')); + echo $ret->date(), "\n"; + echo $ret->duration(), "\n"; + echo $ret->endDate(), "\n"; +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} +1.994980000 +17.99749 +18.000082000 diff --git a/libcalends/php/ext/tests/010.add.phpt b/libcalends/php/ext/tests/010.add.phpt new file mode 100644 index 0000000..b55555a --- /dev/null +++ b/libcalends/php/ext/tests/010.add.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->add() Basic test +--SKIPIF-- + +--FILE-- +add()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/011.subtract.phpt b/libcalends/php/ext/tests/011.subtract.phpt new file mode 100644 index 0000000..c6280c9 --- /dev/null +++ b/libcalends/php/ext/tests/011.subtract.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->subtract() Basic test +--SKIPIF-- + +--FILE-- +subtract()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/012.addFromEnd.phpt b/libcalends/php/ext/tests/012.addFromEnd.phpt new file mode 100644 index 0000000..2222644 --- /dev/null +++ b/libcalends/php/ext/tests/012.addFromEnd.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->addFromEnd() Basic test +--SKIPIF-- + +--FILE-- +addFromEnd()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/013.subtractFromEnd.phpt b/libcalends/php/ext/tests/013.subtractFromEnd.phpt new file mode 100644 index 0000000..2e51a46 --- /dev/null +++ b/libcalends/php/ext/tests/013.subtractFromEnd.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->subtractFromEnd() Basic test +--SKIPIF-- + +--FILE-- +subtractFromEnd()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/014.next.phpt b/libcalends/php/ext/tests/014.next.phpt new file mode 100644 index 0000000..0220ea2 --- /dev/null +++ b/libcalends/php/ext/tests/014.next.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->next() Basic test +--SKIPIF-- + +--FILE-- +next()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/015.previous.phpt b/libcalends/php/ext/tests/015.previous.phpt new file mode 100644 index 0000000..ab6f833 --- /dev/null +++ b/libcalends/php/ext/tests/015.previous.phpt @@ -0,0 +1,18 @@ +--TEST-- +Calends\Calends->previous() Basic test +--SKIPIF-- + +--FILE-- +previous()); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/016.merge.phpt b/libcalends/php/ext/tests/016.merge.phpt new file mode 100644 index 0000000..93200c9 --- /dev/null +++ b/libcalends/php/ext/tests/016.merge.phpt @@ -0,0 +1,19 @@ +--TEST-- +Calends\Calends->merge() Basic test +--SKIPIF-- + +--FILE-- +merge($tmp2)); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/017.intersect.phpt b/libcalends/php/ext/tests/017.intersect.phpt new file mode 100644 index 0000000..55d037e --- /dev/null +++ b/libcalends/php/ext/tests/017.intersect.phpt @@ -0,0 +1,19 @@ +--TEST-- +Calends\Calends->intersect() Basic test +--SKIPIF-- + +--FILE-- +intersect($tmp2)); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/018.gap.phpt b/libcalends/php/ext/tests/018.gap.phpt new file mode 100644 index 0000000..9738e1b --- /dev/null +++ b/libcalends/php/ext/tests/018.gap.phpt @@ -0,0 +1,19 @@ +--TEST-- +Calends\Calends->gap() Basic test +--SKIPIF-- + +--FILE-- +gap($tmp2)); +?> +--EXPECTF-- +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} diff --git a/libcalends/php/ext/tests/019.difference.phpt b/libcalends/php/ext/tests/019.difference.phpt new file mode 100644 index 0000000..de18ee7 --- /dev/null +++ b/libcalends/php/ext/tests/019.difference.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->difference() Basic test +--SKIPIF-- + +--FILE-- +difference($tmp2)); +?> +--EXPECT-- +string(3) "-10" diff --git a/libcalends/php/ext/tests/020.compare.phpt b/libcalends/php/ext/tests/020.compare.phpt new file mode 100644 index 0000000..75a7188 --- /dev/null +++ b/libcalends/php/ext/tests/020.compare.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->compare() Basic test +--SKIPIF-- + +--FILE-- +compare($tmp2)); +?> +--EXPECT-- +int(-1) diff --git a/libcalends/php/ext/tests/021.contains.phpt b/libcalends/php/ext/tests/021.contains.phpt new file mode 100644 index 0000000..0af0da7 --- /dev/null +++ b/libcalends/php/ext/tests/021.contains.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->contains() Basic test +--SKIPIF-- + +--FILE-- +contains($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/022.overlaps.phpt b/libcalends/php/ext/tests/022.overlaps.phpt new file mode 100644 index 0000000..850fb38 --- /dev/null +++ b/libcalends/php/ext/tests/022.overlaps.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->overlaps() Basic test +--SKIPIF-- + +--FILE-- +overlaps($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/023.abuts.phpt b/libcalends/php/ext/tests/023.abuts.phpt new file mode 100644 index 0000000..e80763f --- /dev/null +++ b/libcalends/php/ext/tests/023.abuts.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->abuts() Basic test +--SKIPIF-- + +--FILE-- +abuts($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/024.isSame.phpt b/libcalends/php/ext/tests/024.isSame.phpt new file mode 100644 index 0000000..bb12adc --- /dev/null +++ b/libcalends/php/ext/tests/024.isSame.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isSame() Basic test +--SKIPIF-- + +--FILE-- +isSame($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/025.isShorter.phpt b/libcalends/php/ext/tests/025.isShorter.phpt new file mode 100644 index 0000000..129bc9e --- /dev/null +++ b/libcalends/php/ext/tests/025.isShorter.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isShorter() Basic test +--SKIPIF-- + +--FILE-- +isShorter($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/026.isSameDuration.phpt b/libcalends/php/ext/tests/026.isSameDuration.phpt new file mode 100644 index 0000000..aa33a8d --- /dev/null +++ b/libcalends/php/ext/tests/026.isSameDuration.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isSameDuration() Basic test +--SKIPIF-- + +--FILE-- +isSameDuration($tmp2)); +?> +--EXPECT-- +bool(true) diff --git a/libcalends/php/ext/tests/027.isLonger.phpt b/libcalends/php/ext/tests/027.isLonger.phpt new file mode 100644 index 0000000..b3219cc --- /dev/null +++ b/libcalends/php/ext/tests/027.isLonger.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isLonger() Basic test +--SKIPIF-- + +--FILE-- +isLonger($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/028.isBefore.phpt b/libcalends/php/ext/tests/028.isBefore.phpt new file mode 100644 index 0000000..7fb6294 --- /dev/null +++ b/libcalends/php/ext/tests/028.isBefore.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isBefore() Basic test +--SKIPIF-- + +--FILE-- +isBefore($tmp2)); +?> +--EXPECT-- +bool(true) diff --git a/libcalends/php/ext/tests/029.startsBefore.phpt b/libcalends/php/ext/tests/029.startsBefore.phpt new file mode 100644 index 0000000..304e09d --- /dev/null +++ b/libcalends/php/ext/tests/029.startsBefore.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->startsBefore() Basic test +--SKIPIF-- + +--FILE-- +startsBefore($tmp2)); +?> +--EXPECT-- +bool(true) diff --git a/libcalends/php/ext/tests/030.endsBefore.phpt b/libcalends/php/ext/tests/030.endsBefore.phpt new file mode 100644 index 0000000..cd00745 --- /dev/null +++ b/libcalends/php/ext/tests/030.endsBefore.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->endsBefore() Basic test +--SKIPIF-- + +--FILE-- +endsBefore($tmp2)); +?> +--EXPECT-- +bool(true) diff --git a/libcalends/php/ext/tests/031.isDuring.phpt b/libcalends/php/ext/tests/031.isDuring.phpt new file mode 100644 index 0000000..d870c7a --- /dev/null +++ b/libcalends/php/ext/tests/031.isDuring.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isDuring() Basic test +--SKIPIF-- + +--FILE-- +isDuring($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/032.startsDuring.phpt b/libcalends/php/ext/tests/032.startsDuring.phpt new file mode 100644 index 0000000..beab768 --- /dev/null +++ b/libcalends/php/ext/tests/032.startsDuring.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->startsDuring() Basic test +--SKIPIF-- + +--FILE-- +startsDuring($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/033.endsDuring.phpt b/libcalends/php/ext/tests/033.endsDuring.phpt new file mode 100644 index 0000000..2f6085c --- /dev/null +++ b/libcalends/php/ext/tests/033.endsDuring.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->endsDuring() Basic test +--SKIPIF-- + +--FILE-- +endsDuring($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/034.isAfter.phpt b/libcalends/php/ext/tests/034.isAfter.phpt new file mode 100644 index 0000000..f663827 --- /dev/null +++ b/libcalends/php/ext/tests/034.isAfter.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->isAfter() Basic test +--SKIPIF-- + +--FILE-- +isAfter($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/035.startsAfter.phpt b/libcalends/php/ext/tests/035.startsAfter.phpt new file mode 100644 index 0000000..0ed9b8b --- /dev/null +++ b/libcalends/php/ext/tests/035.startsAfter.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->startsAfter() Basic test +--SKIPIF-- + +--FILE-- +startsAfter($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/036.endsAfter.phpt b/libcalends/php/ext/tests/036.endsAfter.phpt new file mode 100644 index 0000000..0fec3d5 --- /dev/null +++ b/libcalends/php/ext/tests/036.endsAfter.phpt @@ -0,0 +1,16 @@ +--TEST-- +Calends\Calends->endsAfter() Basic test +--SKIPIF-- + +--FILE-- +endsAfter($tmp2)); +?> +--EXPECT-- +bool(false) diff --git a/libcalends/php/ext/tests/037.calendarRegistered.phpt b/libcalends/php/ext/tests/037.calendarRegistered.phpt new file mode 100644 index 0000000..b4e3e09 --- /dev/null +++ b/libcalends/php/ext/tests/037.calendarRegistered.phpt @@ -0,0 +1,27 @@ +--TEST-- +Calends\Calends::calendarRegistered() Basic test +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) diff --git a/libcalends/php/ext/tests/038.calendarRegister.phpt b/libcalends/php/ext/tests/038.calendarRegister.phpt new file mode 100644 index 0000000..a25fdc8 --- /dev/null +++ b/libcalends/php/ext/tests/038.calendarRegister.phpt @@ -0,0 +1,48 @@ +--TEST-- +Calends\Calends::calendarRegister() Basic test +--SKIPIF-- + +--FILE-- +toString()}::{$format}"; + } + + static function offset(Calends\TAITime $stamp, $offset): Calends\TAITime { + return $stamp; + } + } + + Calends\Calends::calendarRegister('test', 'default', TestCalendar::class); + + var_dump(Calends\Calends::calendarRegistered('test')); + var_dump(Calends\Calends::calendarListRegistered()); +?> +--EXPECT-- +bool(false) +bool(true) +array(6) { + [0]=> + string(9) "Gregorian" + [1]=> + string(3) "Jdc" + [2]=> + string(8) "Stardate" + [3]=> + string(5) "Tai64" + [4]=> + string(4) "Test" + [5]=> + string(4) "Unix" +} diff --git a/libcalends/php/ext/tests/039.calendarRegister-extended.phpt b/libcalends/php/ext/tests/039.calendarRegister-extended.phpt new file mode 100644 index 0000000..7b14e7c --- /dev/null +++ b/libcalends/php/ext/tests/039.calendarRegister-extended.phpt @@ -0,0 +1,63 @@ +--TEST-- +Calends\Calends::calendarRegister() Extended test +--SKIPIF-- + +--FILE-- +toString()}::{$format}"; + } + + function offset(Calends\TAITime $stamp, $offset): Calends\TAITime { + return $stamp; + } + } + + Calends\Calends::calendarRegister('test', 'default', new TestCalendar); + + if (!Calends\Calends::calendarRegistered('test')) { + echo "Calendar not registered!"; + exit; + } + + echo "testing toInternal():\n"; + $ret = Calends\Calends::create(null, 'test'); + var_dump($ret); + + echo "\ntesting fromInternal():\n"; + var_dump($ret->date('test')); + + echo "\ntesting offset():\n"; + var_dump($ret->add(null, 'test')); + var_dump($ret->add(null, 'test')->date('test')); +?> +--EXPECTF-- +testing toInternal(): +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} + +testing fromInternal(): +string(10) "0::default" + +testing offset(): +object(Calends\Calends)#%d (%d) { + ["goId":"Calends\Calends":private]=> + float(%d) +} +string(10) "0::default" diff --git a/libcalends/php/ext/tests/040.taitime_create.phpt b/libcalends/php/ext/tests/040.taitime_create.phpt new file mode 100644 index 0000000..1cfb73c --- /dev/null +++ b/libcalends/php/ext/tests/040.taitime_create.phpt @@ -0,0 +1,94 @@ +--TEST-- +Calends\TAITime::create() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/041.taitime_add.phpt b/libcalends/php/ext/tests/041.taitime_add.phpt new file mode 100644 index 0000000..0392ea6 --- /dev/null +++ b/libcalends/php/ext/tests/041.taitime_add.phpt @@ -0,0 +1,31 @@ +--TEST-- +Calends\TAITime->add() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +add($t2)); +?> +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(10) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/042.taitime_sub.phpt b/libcalends/php/ext/tests/042.taitime_sub.phpt new file mode 100644 index 0000000..3c2c933 --- /dev/null +++ b/libcalends/php/ext/tests/042.taitime_sub.phpt @@ -0,0 +1,62 @@ +--TEST-- +Calends\TAITime->sub() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +sub($t2); + var_dump($t3); +?> +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(10) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(-10) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/043.taitime_toString.phpt b/libcalends/php/ext/tests/043.taitime_toString.phpt new file mode 100644 index 0000000..6dd7c7b --- /dev/null +++ b/libcalends/php/ext/tests/043.taitime_toString.phpt @@ -0,0 +1,17 @@ +--TEST-- +Calends\TAITime->toString() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +toString()); +?> +--EXPECT-- +string(1) "0" diff --git a/libcalends/php/ext/tests/044.taitime_fromString.phpt b/libcalends/php/ext/tests/044.taitime_fromString.phpt new file mode 100644 index 0000000..193a685 --- /dev/null +++ b/libcalends/php/ext/tests/044.taitime_fromString.phpt @@ -0,0 +1,30 @@ +--TEST-- +Calends\TAITime->fromString() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/045.taitime_toHex.phpt b/libcalends/php/ext/tests/045.taitime_toHex.phpt new file mode 100644 index 0000000..91c6224 --- /dev/null +++ b/libcalends/php/ext/tests/045.taitime_toHex.phpt @@ -0,0 +1,17 @@ +--TEST-- +Calends\TAITime->toHex() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +toHex()); +?> +--EXPECT-- +string(56) "40000000000000000000000000000000000000000000000000000000" diff --git a/libcalends/php/ext/tests/046.taitime_fromHex.phpt b/libcalends/php/ext/tests/046.taitime_fromHex.phpt new file mode 100644 index 0000000..8d08602 --- /dev/null +++ b/libcalends/php/ext/tests/046.taitime_fromHex.phpt @@ -0,0 +1,46 @@ +--TEST-- +Calends\TAITime->fromHex() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/047.taitime_toNumber.phpt b/libcalends/php/ext/tests/047.taitime_toNumber.phpt new file mode 100644 index 0000000..b1bdf11 --- /dev/null +++ b/libcalends/php/ext/tests/047.taitime_toNumber.phpt @@ -0,0 +1,17 @@ +--TEST-- +Calends\TAITime->toNumber() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +toNumber()); +?> +--EXPECT-- +float(0) diff --git a/libcalends/php/ext/tests/048.taitime_fromNumber.phpt b/libcalends/php/ext/tests/048.taitime_fromNumber.phpt new file mode 100644 index 0000000..d64ee66 --- /dev/null +++ b/libcalends/php/ext/tests/048.taitime_fromNumber.phpt @@ -0,0 +1,46 @@ +--TEST-- +Calends\TAITime->fromNumber() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(0) + ["nano"]=> + int(0) + ["atto"]=> + int(0) + ["xicto"]=> + int(0) + ["ucto"]=> + int(0) + ["rocto"]=> + int(0) +} diff --git a/libcalends/php/ext/tests/049.taitime_toUTC.phpt b/libcalends/php/ext/tests/049.taitime_toUTC.phpt new file mode 100644 index 0000000..47af638 --- /dev/null +++ b/libcalends/php/ext/tests/049.taitime_toUTC.phpt @@ -0,0 +1,30 @@ +--TEST-- +Calends\TAITime->toUTC() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +toUTC()); +?> +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(8) + ["nano"]=> + int(81999) + ["atto"]=> + int(999999027) + ["xicto"]=> + int(295416453) + ["ucto"]=> + int(853249549) + ["rocto"]=> + int(865722656) +} diff --git a/libcalends/php/ext/tests/050.taitime_fromUTC.phpt b/libcalends/php/ext/tests/050.taitime_fromUTC.phpt new file mode 100644 index 0000000..905554c --- /dev/null +++ b/libcalends/php/ext/tests/050.taitime_fromUTC.phpt @@ -0,0 +1,30 @@ +--TEST-- +Calends\TAITime->fromUTC() Basic test +--INI-- +precision=20 +--SKIPIF-- + +--FILE-- +fromUTC()); +?> +--EXPECTF-- +object(Calends\TAITime)#%d (6) { + ["seconds"]=> + float(-7) + ["nano"]=> + int(997489999) + ["atto"]=> + int(999999987) + ["xicto"]=> + int(778664944) + ["ucto"]=> + int(926276803) + ["rocto"]=> + int(16662598) +} diff --git a/libcalends/php/ext/tests/051.panicHandling.phpt b/libcalends/php/ext/tests/051.panicHandling.phpt new file mode 100644 index 0000000..8525cd1 --- /dev/null +++ b/libcalends/php/ext/tests/051.panicHandling.phpt @@ -0,0 +1,25 @@ +--TEST-- +Panic handling test +--SKIPIF-- + +--FILE-- +getMessage()}\n"; + } + + try { + Calends\Calends::create(null, 'invalid'); + } catch (Calends\CalendsException $e) { + echo "Caught Calends\CalendsException: {$e->getMessage()}\n"; + } +?> +--EXPECTF-- +Caught Error: Call to private Calends\Calends::__construct() from invalid context +Caught Calends\CalendsException: Unknown Calendar: invalid diff --git a/libcalends/php/ext/tests/052.calendarUnregister.phpt b/libcalends/php/ext/tests/052.calendarUnregister.phpt new file mode 100644 index 0000000..5e5f6c4 --- /dev/null +++ b/libcalends/php/ext/tests/052.calendarUnregister.phpt @@ -0,0 +1,38 @@ +--TEST-- +Calends\Calends::calendarUnregister() Basic test +--SKIPIF-- + +--FILE-- +toString()}::{$format}"; + } + + function offset(Calends\TAITime $stamp, $offset): Calends\TAITime { + return $stamp; + } + } + + Calends\Calends::calendarRegister('test', 'default', new TestCalendar); + + var_dump(Calends\Calends::calendarRegistered('test')); + + Calends\Calends::calendarUnregister('test'); + + var_dump(Calends\Calends::calendarRegistered('test')); +?> +--EXPECT-- +bool(false) +bool(true) +bool(false) diff --git a/libcalends/php/ext/wrap_libcalends.c b/libcalends/php/ext/wrap_libcalends.c new file mode 100644 index 0000000..9f75571 --- /dev/null +++ b/libcalends/php/ext/wrap_libcalends.c @@ -0,0 +1,1607 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ext.h" +#include "kernel/array.h" +#include "kernel/exception.h" +#include "kernel/fcall.h" +#include "kernel/object.h" +#include "kernel/memory.h" +#include "calends/calends.zep.h" +#include "calends/calendsexception.zep.h" +#include "calends/taitime.zep.h" +#include "wrap_libcalends.h" + +double ext_Calends_create_string(zval *date_param, zval *calendar_param, zval *format_param) { + char *date, *calendar, *format; + + date = ZSTR_VAL(Z_STR(*date_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_string(date, calendar, format); +} + +double ext_Calends_create_string_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param) { + char *start, *end, *calendar, *format; + + start = ZSTR_VAL(Z_STR(*start_param)); + end = ZSTR_VAL(Z_STR(*end_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_string_range(start, end, calendar, format); +} + +double ext_Calends_create_string_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param) { + char *start, *duration, *calendar, *format; + + start = ZSTR_VAL(Z_STR(*start_param)); + duration = ZSTR_VAL(Z_STR(*duration_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_string_start_period(start, duration, calendar, format); +} + +double ext_Calends_create_string_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param) { + char *duration, *end, *calendar, *format; + + duration = ZSTR_VAL(Z_STR(*duration_param)); + end = ZSTR_VAL(Z_STR(*end_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_string_end_period(duration, end, calendar, format); +} + +double ext_Calends_create_long_long(zval *date_param, zval *calendar_param, zval *format_param) { + long long int date; + char *calendar, *format; + + date = Z_LVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_long_long(date, calendar, format); +} + +double ext_Calends_create_long_long_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param) { + long long int start, end; + char *calendar, *format; + + start = Z_LVAL(*start_param); + end = Z_LVAL(*end_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_long_long_range(start, end, calendar, format); +} + +double ext_Calends_create_long_long_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param) { + long long int start, duration; + char *calendar, *format; + + start = Z_LVAL(*start_param); + duration = Z_LVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_long_long_start_period(start, duration, calendar, format); +} + +double ext_Calends_create_long_long_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param) { + long long int duration, end; + char *calendar, *format; + + duration = Z_LVAL(*duration_param); + end = Z_LVAL(*end_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_long_long_end_period(duration, end, calendar, format); +} + +double ext_Calends_create_double(zval *date_param, zval *calendar_param, zval *format_param) { + double date; + char *calendar, *format; + + date = Z_DVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_double(date, calendar, format); +} + +double ext_Calends_create_double_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param) { + double start, end; + char *calendar, *format; + + start = Z_DVAL(*start_param); + end = Z_DVAL(*end_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_double_range(start, end, calendar, format); +} + +double ext_Calends_create_double_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param) { + double start, duration; + char *calendar, *format; + + start = Z_DVAL(*start_param); + duration = Z_DVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_double_start_period(start, duration, calendar, format); +} + +double ext_Calends_create_double_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param) { + double duration, end; + char *calendar, *format; + + duration = Z_DVAL(*duration_param); + end = Z_DVAL(*end_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_create_double_end_period(duration, end, calendar, format); +} + +zval ext_Calends_date(zval *p_param, zval *calendar_param, zval *format_param) { + double p; + char *calendar, *format; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + ZVAL_STRING(&out, Calends_date((long long unsigned int)p, calendar, format)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_duration(zval *p_param) { + double p; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + ZVAL_STRING(&out, Calends_duration((long long unsigned int)p)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_end_date(zval *p_param, zval *calendar_param, zval *format_param) { + double p; + char *calendar, *format; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + ZVAL_STRING(&out, Calends_end_date((long long unsigned int)p, calendar, format)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_string(zval *p_param) { + double p; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + ZVAL_STRING(&out, Calends_string((long long unsigned int)p)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_encode_text(zval *p_param) { + double p; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + ZVAL_STRING(&out, Calends_encode_text((long long unsigned int)p)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +double ext_Calends_decode_text(zval *encoded_param) { + char *encoded; + + encoded = ZSTR_VAL(Z_STR(*encoded_param)); + + return Calends_decode_text(encoded); +} + +zval ext_Calends_encode_json(zval *p_param) { + double p; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + ZVAL_STRING(&out, Calends_encode_json((long long unsigned int)p)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +double ext_Calends_decode_json(zval *encoded_param) { + char *encoded; + + encoded = ZSTR_VAL(Z_STR(*encoded_param)); + + return Calends_decode_json(encoded); +} + +zval ext_Calends_difference(zval *p_param, zval *z_param, zval *mode_param) { + double p, z; + char *mode; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + mode = ZSTR_VAL(Z_STR(*mode_param)); + ZVAL_STRING(&out, Calends_difference((long long unsigned int)p, (long long unsigned int)z, mode)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_compare(zval *p_param, zval *z_param, zval *mode_param) { + double p, z; + char *mode; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + mode = ZSTR_VAL(Z_STR(*mode_param)); + ZVAL_LONG(&out, Calends_compare((long long unsigned int)p, (long long unsigned int)z, mode)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_same(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_same((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_same_duration(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_same_duration((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_shorter(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_shorter((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_longer(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_longer((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_contains(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_contains((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_overlaps(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_overlaps((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_abuts(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_abuts((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_before(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_before((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_starts_before(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_starts_before((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_ends_before(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_ends_before((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_during(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_during((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_starts_during(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_starts_during((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_ends_during(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_ends_during((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_is_after(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_is_after((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_starts_after(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_starts_after((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_ends_after(zval *p_param, zval *z_param) { + double p, z; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + ZVAL_BOOL(&out, Calends_ends_after((long long unsigned int)p, (long long unsigned int)z)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +double ext_Calends_add_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_add_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_add_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_add_from_end_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_from_end_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_add_from_end_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_from_end_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_add_from_end_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_add_from_end_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_from_end_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_from_end_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_from_end_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_from_end_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_subtract_from_end_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_subtract_from_end_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_next_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_next_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_next_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_next_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_next_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_next_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_previous_string(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + char *offset, *calendar; + + p = Z_DVAL(*p_param); + offset = ZSTR_VAL(Z_STR(*offset_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_previous_string((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_previous_long_long(zval *p_param, zval *offset_param, zval *calendar_param) { + double p; + long long int offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_LVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_previous_long_long((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_previous_double(zval *p_param, zval *offset_param, zval *calendar_param) { + double p, offset; + char *calendar; + + p = Z_DVAL(*p_param); + offset = Z_DVAL(*offset_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_previous_double((long long unsigned int)p, offset, calendar); +} + +double ext_Calends_with_date_string(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p; + char *date, *calendar, *format; + + p = Z_DVAL(*p_param); + date = ZSTR_VAL(Z_STR(*date_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_date_string((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_date_long_long(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p; + long long int date; + char *calendar, *format; + + p = Z_DVAL(*p_param); + date = Z_LVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_date_long_long((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_date_double(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p, date; + char *calendar, *format; + + p = Z_DVAL(*p_param); + date = Z_DVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_date_double((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_end_date_string(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p; + char *date, *calendar, *format; + + p = Z_DVAL(*p_param); + date = ZSTR_VAL(Z_STR(*date_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_end_date_string((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_end_date_long_long(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p; + long long int date; + char *calendar, *format; + + p = Z_DVAL(*p_param); + date = Z_LVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_end_date_long_long((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_end_date_double(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param) { + double p, date; + char *calendar, *format; + + p = Z_DVAL(*p_param); + date = Z_DVAL(*date_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + format = ZSTR_VAL(Z_STR(*format_param)); + + return (double)Calends_with_end_date_double((long long unsigned int)p, date, calendar, format); +} + +double ext_Calends_with_duration_string(zval *p_param, zval *duration_param, zval *calendar_param) { + double p; + char *duration, *calendar; + + p = Z_DVAL(*p_param); + duration = ZSTR_VAL(Z_STR(*duration_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_string((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_with_duration_long_long(zval *p_param, zval *duration_param, zval *calendar_param) { + double p; + long long int duration; + char *calendar; + + p = Z_DVAL(*p_param); + duration = Z_LVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_long_long((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_with_duration_double(zval *p_param, zval *duration_param, zval *calendar_param) { + double p, duration; + char *calendar; + + p = Z_DVAL(*p_param); + duration = Z_DVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_double((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_with_duration_from_end_string(zval *p_param, zval *duration_param, zval *calendar_param) { + double p; + char *duration, *calendar; + + p = Z_DVAL(*p_param); + duration = ZSTR_VAL(Z_STR(*duration_param)); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_from_end_string((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_with_duration_from_end_long_long(zval *p_param, zval *duration_param, zval *calendar_param) { + double p; + long long int duration; + char *calendar; + + p = Z_DVAL(*p_param); + duration = Z_LVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_from_end_long_long((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_with_duration_from_end_double(zval *p_param, zval *duration_param, zval *calendar_param) { + double p, duration; + char *calendar; + + p = Z_DVAL(*p_param); + duration = Z_DVAL(*duration_param); + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + return (double)Calends_with_duration_from_end_double((long long unsigned int)p, duration, calendar); +} + +double ext_Calends_merge(zval *p_param, zval *z_param) { + double p, z; + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + + return (double)Calends_merge((long long unsigned int)p, (long long unsigned int)z); +} + +double ext_Calends_intersect(zval *p_param, zval *z_param) { + double p, z; + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + + return (double)Calends_intersect((long long unsigned int)p, (long long unsigned int)z); +} + +double ext_Calends_gap(zval *p_param, zval *z_param) { + double p, z; + + p = Z_DVAL(*p_param); + z = Z_DVAL(*z_param); + + return (double)Calends_gap((long long unsigned int)p, (long long unsigned int)z); +} + + +void ext_Calends_release(zval *p_param) { + double p; + + p = Z_DVAL(*p_param); + + Calends_release((long long unsigned int)p); +} + + +TAI64Time ext_Calends_calendar_to_internal_string(char* name_param, char* date_param, char* format_param) { + TAI64Time out; + zval out_zval, name, date, format; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_STRING(&date, date_param); + ZVAL_STRING(&format, format_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("toInternal"), PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &date, &format); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_to_internal_long_long(char* name_param, long long int date_param, char* format_param) { + TAI64Time out; + zval out_zval, name, date, format; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_DOUBLE(&date, date_param); + ZVAL_STRING(&format, format_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("toInternal"), PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &date, &format); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_to_internal_double(char* name_param, double date_param, char* format_param) { + TAI64Time out; + zval out_zval, name, date, format; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_DOUBLE(&date, date_param); + ZVAL_STRING(&format, format_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("toInternal"), PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &date, &format); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_to_internal_tai(char* name_param, TAI64Time date_param) { + TAI64Time out; + zval out_zval, name, date, format; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&date, date_param); + ZVAL_STRING(&format, ""); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("toInternal"), PH_NOISY, "calends/calendarinterface.zep", 5 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &date, &format); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +char* ext_Calends_calendar_from_internal(char* name_param, TAI64Time stamp_param, char* format_param) { + char *out; + zval out_zval, name, stamp, format; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&stamp); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&stamp, stamp_param); + ZVAL_STRING(&format, format_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 7 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("fromInternal"), PH_NOISY, "calends/calendarinterface.zep", 7 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &stamp, &format); + + out = ZSTR_VAL(Z_STR(out_zval)); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_offset_string(char* name_param, TAI64Time stamp_param, char* offset_param) { + TAI64Time out; + zval out_zval, name, stamp, offset; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&stamp); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&stamp, stamp_param); + ZVAL_STRING(&offset, offset_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("offset"), PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &stamp, &offset); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_offset_long_long(char* name_param, TAI64Time stamp_param, long long int offset_param) { + TAI64Time out; + zval out_zval, name, stamp, offset; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&stamp); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&stamp, stamp_param); + ZVAL_DOUBLE(&offset, offset_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("offset"), PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &stamp, &offset); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_offset_double(char* name_param, TAI64Time stamp_param, double offset_param) { + TAI64Time out; + zval out_zval, name, stamp, offset; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&stamp); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&stamp, stamp_param); + ZVAL_DOUBLE(&offset, offset_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("offset"), PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &stamp, &offset); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + +TAI64Time ext_Calends_calendar_offset_tai(char* name_param, TAI64Time stamp_param, TAI64Time offset_param) { + TAI64Time out; + zval out_zval, name, stamp, offset; + zval calendar_list, func_list, func; + zend_long ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&out_zval); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&stamp); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&calendar_list); + ZVAL_UNDEF(&func_list); + ZVAL_UNDEF(&func); + + ZEPHIR_MM_GROW(); + + ZVAL_STRING(&name, name_param); + ZVAL_TAITIME(&stamp, stamp_param); + ZVAL_TAITIME(&offset, offset_param); + + zephir_read_static_property_ce(&calendar_list, calends_calends_ce, SL("calendars"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&func_list, &calendar_list, &name, PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + zephir_array_fetch_string(&func, &func_list, SL("offset"), PH_NOISY, "calends/calendarinterface.zep", 9 TSRMLS_CC); + + ZEPHIR_CALL_ZVAL_FUNCTION(&out_zval, &func, NULL, 0, &stamp, &offset); + + out = Z_TAITIME(out_zval); + ZEPHIR_MM_RESTORE(); + return out; +} + + +void ext_Calends_calendar_register(zval *calendar_param, zval *default_format_param) { + char *calendar, *default_format; + + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + default_format = ZSTR_VAL(Z_STR(*default_format_param)); + + Calends_calendar_register(calendar, default_format, + ext_Calends_calendar_to_internal_string, + ext_Calends_calendar_to_internal_long_long, + ext_Calends_calendar_to_internal_double, + ext_Calends_calendar_to_internal_tai, + ext_Calends_calendar_from_internal, + ext_Calends_calendar_offset_string, + ext_Calends_calendar_offset_long_long, + ext_Calends_calendar_offset_double, + ext_Calends_calendar_offset_tai + ); +} + +void ext_Calends_calendar_unregister(zval *calendar_param) { + char *calendar; + + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + + Calends_calendar_unregister(calendar); +} + +zval ext_Calends_calendar_registered(zval *calendar_param) { + char *calendar; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + calendar = ZSTR_VAL(Z_STR(*calendar_param)); + ZVAL_BOOL(&out, Calends_calendar_registered(calendar)); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_Calends_calendar_list_registered() { + char *result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + // We'll let Zephir split the string. C's not great at it... + result = Calends_calendar_list_registered(); + ZVAL_STRING(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + + +zval ext_TAI64Time_add(zval *p_param, zval *z_param) { + TAI64Time p, z, result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + z = Z_TAITIME(*z_param); + result = TAI64Time_add(p, z); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_sub(zval *p_param, zval *z_param) { + TAI64Time p, z, result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + z = Z_TAITIME(*z_param); + result = TAI64Time_sub(p, z); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_string(zval *p_param) { + TAI64Time p; + char *result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_string(p); + ZVAL_STRING(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_from_string(zval *in_param) { + char *in; + TAI64Time result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + in = ZSTR_VAL(Z_STR(*in_param)); + result = TAI64Time_from_string(in); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_hex_string(zval *p_param) { + TAI64Time p; + char *result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_hex_string(p); + ZVAL_STRING(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_from_hex_string(zval *in_param) { + char *in; + TAI64Time result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + in = ZSTR_VAL(Z_STR(*in_param)); + result = TAI64Time_from_hex_string(in); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_double(zval *p_param) { + TAI64Time p; + double result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_double(p); + ZVAL_DOUBLE(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_from_double(zval *in_param) { + double in; + TAI64Time result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + in = Z_DVAL(*in_param); + result = TAI64Time_from_double(in); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_encode_text(zval *p_param) { + TAI64Time p; + char *result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_encode_text(p); + ZVAL_STRING(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_decode_text(zval *encoded_param) { + char *encoded; + TAI64Time result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + encoded = ZSTR_VAL(Z_STR(*encoded_param)); + result = TAI64Time_from_string(encoded); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_encode_binary(zval *p_param) { + //TODO... +} + +zval ext_TAI64Time_decode_binary(zval *encoded_param, zval *len_param) { + //TODO... +} + +zval ext_TAI64Time_utc_to_tai(zval *p_param) { + TAI64Time p, result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_utc_to_tai(p); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + +zval ext_TAI64Time_tai_to_utc(zval *p_param) { + TAI64Time p, result; + zval out; + + ZVAL_UNDEF(&out); + + ZEPHIR_MM_GROW(); + + p = Z_TAITIME(*p_param); + result = TAI64Time_tai_to_utc(p); + ZVAL_TAITIME(&out, result); + + ZEPHIR_MM_RESTORE(); + + return out; +} + + +void ZVAL_TAITIME(zval *out, TAI64Time tai_val) { + zval _sec, _nano, _atto, _xicto, _ucto, _rocto; + + ZVAL_UNDEF(&_sec); + ZVAL_UNDEF(&_nano); + ZVAL_UNDEF(&_atto); + ZVAL_UNDEF(&_xicto); + ZVAL_UNDEF(&_ucto); + ZVAL_UNDEF(&_rocto); + ZVAL_UNDEF(out); + + ZEPHIR_MM_GROW(); + + object_init_ex(out, calends_taitime_ce); + ZVAL_DOUBLE(&_sec, tai_val.Seconds); + zephir_update_property_zval(out, SL("seconds"), &_sec); + ZVAL_LONG(&_nano, tai_val.Nano); + zephir_update_property_zval(out, SL("nano"), &_nano); + ZVAL_LONG(&_atto, tai_val.Atto); + zephir_update_property_zval(out, SL("atto"), &_atto); + ZVAL_LONG(&_xicto, tai_val.Xicto); + zephir_update_property_zval(out, SL("xicto"), &_xicto); + ZVAL_LONG(&_ucto, tai_val.Ucto); + zephir_update_property_zval(out, SL("ucto"), &_ucto); + ZVAL_LONG(&_rocto, tai_val.Rocto); + zephir_update_property_zval(out, SL("rocto"), &_rocto); + + ZEPHIR_MM_RESTORE(); +} + +TAI64Time Z_TAITIME(zval in) { + zval _sec, _nano, _atto, _xicto, _ucto, _rocto; + + ZVAL_UNDEF(&_sec); + ZVAL_UNDEF(&_nano); + ZVAL_UNDEF(&_atto); + ZVAL_UNDEF(&_xicto); + ZVAL_UNDEF(&_ucto); + ZVAL_UNDEF(&_rocto); + + ZEPHIR_MM_GROW(); + + TAI64Time out = {0, 0, 0, 0, 0, 0, 0}; + + zephir_read_property(&_sec, &in, SL("seconds"), PH_NOISY_CC | PH_READONLY); + out.Seconds = Z_DVAL(_sec); + zephir_read_property(&_nano, &in, SL("nano"), PH_NOISY_CC | PH_READONLY); + out.Nano = Z_LVAL(_nano); + zephir_read_property(&_atto, &in, SL("atto"), PH_NOISY_CC | PH_READONLY); + out.Atto = Z_LVAL(_atto); + zephir_read_property(&_xicto, &in, SL("xicto"), PH_NOISY_CC | PH_READONLY); + out.Xicto = Z_LVAL(_xicto); + zephir_read_property(&_ucto, &in, SL("ucto"), PH_NOISY_CC | PH_READONLY); + out.Ucto = Z_LVAL(_ucto); + zephir_read_property(&_rocto, &in, SL("rocto"), PH_NOISY_CC | PH_READONLY); + out.Rocto = Z_LVAL(_rocto); + + ZEPHIR_MM_RESTORE(); + + return out; +} + + +void ext_panic_handler(char *error_message) { + ZEPHIR_THROW_EXCEPTION_STRW(calends_calendsexception_ce, error_message); +} + +void ext_unregister_all_calendars() { + zval _wildcard; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_null = NULL; + + ZVAL_UNDEF(&_wildcard); + + ZEPHIR_MM_GROW(); + + ZEPHIR_INIT_VAR(&_wildcard); + ZVAL_STRING(&_wildcard, "*"); + ZEPHIR_CALL_CE_STATIC(NULL, calends_calends_ce, "calendarunregister", &_null, 0, &_wildcard); + ZEPHIR_MM_RESTORE(); +} diff --git a/libcalends/php/ext/wrap_libcalends.h b/libcalends/php/ext/wrap_libcalends.h new file mode 100644 index 0000000..6a297d0 --- /dev/null +++ b/libcalends/php/ext/wrap_libcalends.h @@ -0,0 +1,119 @@ +#ifndef WRAP_LIBCALENDS_H +#define WRAP_LIBCALENDS_H + +#include "libcalends.h" + +double ext_Calends_create_string(zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_string_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_string_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_string_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_long_long(zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_long_long_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_long_long_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_long_long_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_double(zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_double_range(zval *start_param, zval *end_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_double_start_period(zval *start_param, zval *duration_param, zval *calendar_param, zval *format_param); +double ext_Calends_create_double_end_period(zval *duration_param, zval *end_param, zval *calendar_param, zval *format_param); +zval ext_Calends_date(zval *p_param, zval *calendar_param, zval *format_param); +zval ext_Calends_duration(zval *p_param); +zval ext_Calends_end_date(zval *p_param, zval *calendar_param, zval *format_param); +zval ext_Calends_string(zval *p_param); +zval ext_Calends_encode_text(zval *p_param); +double ext_Calends_decode_text(zval *encoded_param); +zval ext_Calends_encode_json(zval *p_param); +double ext_Calends_decode_json(zval *encoded_param); +zval ext_Calends_difference(zval *p_param, zval *z_param, zval *mode_param); +zval ext_Calends_compare(zval *p_param, zval *z_param, zval *mode_param); +zval ext_Calends_is_same(zval *p_param, zval *z_param); +zval ext_Calends_is_same_duration(zval *p_param, zval *z_param); +zval ext_Calends_is_shorter(zval *p_param, zval *z_param); +zval ext_Calends_is_longer(zval *p_param, zval *z_param); +zval ext_Calends_contains(zval *p_param, zval *z_param); +zval ext_Calends_overlaps(zval *p_param, zval *z_param); +zval ext_Calends_abuts(zval *p_param, zval *z_param); +zval ext_Calends_is_before(zval *p_param, zval *z_param); +zval ext_Calends_starts_before(zval *p_param, zval *z_param); +zval ext_Calends_ends_before(zval *p_param, zval *z_param); +zval ext_Calends_is_during(zval *p_param, zval *z_param); +zval ext_Calends_starts_during(zval *p_param, zval *z_param); +zval ext_Calends_ends_during(zval *p_param, zval *z_param); +zval ext_Calends_is_after(zval *p_param, zval *z_param); +zval ext_Calends_starts_after(zval *p_param, zval *z_param); +zval ext_Calends_ends_after(zval *p_param, zval *z_param); +double ext_Calends_add_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_add_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_add_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_add_from_end_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_add_from_end_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_add_from_end_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_from_end_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_from_end_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_subtract_from_end_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_next_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_next_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_next_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_previous_string(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_previous_long_long(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_previous_double(zval *p_param, zval *offset_param, zval *calendar_param); +double ext_Calends_with_date_string(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_date_long_long(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_date_double(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_end_date_string(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_end_date_long_long(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_end_date_double(zval *p_param, zval *date_param, zval *calendar_param, zval *format_param); +double ext_Calends_with_duration_string(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_with_duration_long_long(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_with_duration_double(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_with_duration_from_end_string(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_with_duration_from_end_long_long(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_with_duration_from_end_double(zval *p_param, zval *duration_param, zval *calendar_param); +double ext_Calends_merge(zval *p_param, zval *z_param); +double ext_Calends_intersect(zval *p_param, zval *z_param); +double ext_Calends_gap(zval *p_param, zval *z_param); + +void ext_Calends_release(zval *p_param); + +TAI64Time ext_Calends_calendar_to_internal_string(char* name, char* date, char* format); +TAI64Time ext_Calends_calendar_to_internal_long_long(char* name, long long int date, char* format); +TAI64Time ext_Calends_calendar_to_internal_double(char* name, double date, char* format); +TAI64Time ext_Calends_calendar_to_internal_tai(char* name, TAI64Time date); + +char* ext_Calends_calendar_from_internal(char* name, TAI64Time stamp, char* format); + +TAI64Time ext_Calends_calendar_offset_string(char* name, TAI64Time stamp, char* offset); +TAI64Time ext_Calends_calendar_offset_long_long(char* name, TAI64Time stamp, long long int offset); +TAI64Time ext_Calends_calendar_offset_double(char* name, TAI64Time stamp, double offset); +TAI64Time ext_Calends_calendar_offset_tai(char* name, TAI64Time stamp, TAI64Time offset); + +void ext_Calends_calendar_register(zval *calendar_param, zval *default_format_param); +void ext_Calends_calendar_unregister(zval *calendar_param); +zval ext_Calends_calendar_registered(zval *calendar_param); +zval ext_Calends_calendar_list_registered(); + +zval ext_TAI64Time_add(zval *p_param, zval *z_param); +zval ext_TAI64Time_sub(zval *p_param, zval *z_param); +zval ext_TAI64Time_string(zval *p_param); +zval ext_TAI64Time_from_string(zval *in_param); +zval ext_TAI64Time_hex_string(zval *p_param); +zval ext_TAI64Time_from_hex_string(zval *in_param); +zval ext_TAI64Time_double(zval *p_param); +zval ext_TAI64Time_from_double(zval *in_param); +zval ext_TAI64Time_encode_text(zval *p_param); +zval ext_TAI64Time_decode_text(zval *encoded_param); +zval ext_TAI64Time_encode_binary(zval *p_param); +zval ext_TAI64Time_decode_binary(zval *encoded_param, zval *len_param); +zval ext_TAI64Time_utc_to_tai(zval *p_param); +zval ext_TAI64Time_tai_to_utc(zval *p_param); + +// helpers, rather than wrappers +void ext_panic_handler(char *error_message); +void ext_unregister_all_calendars(); + +void ZVAL_TAITIME(zval *out, TAI64Time tai_val); +TAI64Time Z_TAITIME(zval in); + +#endif diff --git a/libcalends/php/opt/CalendsAbutsOptimizer.php b/libcalends/php/opt/CalendsAbutsOptimizer.php new file mode 100644 index 0000000..8afe3f2 --- /dev/null +++ b/libcalends/php/opt/CalendsAbutsOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_abuts(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddDoubleOptimizer.php b/libcalends/php/opt/CalendsAddDoubleOptimizer.php new file mode 100644 index 0000000..9b8b815 --- /dev/null +++ b/libcalends/php/opt/CalendsAddDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddFromEndDoubleOptimizer.php b/libcalends/php/opt/CalendsAddFromEndDoubleOptimizer.php new file mode 100644 index 0000000..1e7c288 --- /dev/null +++ b/libcalends/php/opt/CalendsAddFromEndDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_from_end_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddFromEndLongLongOptimizer.php b/libcalends/php/opt/CalendsAddFromEndLongLongOptimizer.php new file mode 100644 index 0000000..144401a --- /dev/null +++ b/libcalends/php/opt/CalendsAddFromEndLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_from_end_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddFromEndStringOptimizer.php b/libcalends/php/opt/CalendsAddFromEndStringOptimizer.php new file mode 100644 index 0000000..3e1fdcc --- /dev/null +++ b/libcalends/php/opt/CalendsAddFromEndStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_from_end_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddLongLongOptimizer.php b/libcalends/php/opt/CalendsAddLongLongOptimizer.php new file mode 100644 index 0000000..267d44c --- /dev/null +++ b/libcalends/php/opt/CalendsAddLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsAddStringOptimizer.php b/libcalends/php/opt/CalendsAddStringOptimizer.php new file mode 100644 index 0000000..ca924a7 --- /dev/null +++ b/libcalends/php/opt/CalendsAddStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_add_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCalendarListRegisteredOptimizer.php b/libcalends/php/opt/CalendsCalendarListRegisteredOptimizer.php new file mode 100644 index 0000000..14ee700 --- /dev/null +++ b/libcalends/php/opt/CalendsCalendarListRegisteredOptimizer.php @@ -0,0 +1,37 @@ +processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_calendar_list_registered();'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsCalendarRegisterOptimizer.php b/libcalends/php/opt/CalendsCalendarRegisterOptimizer.php new file mode 100644 index 0000000..f8270d2 --- /dev/null +++ b/libcalends/php/opt/CalendsCalendarRegisterOptimizer.php @@ -0,0 +1,25 @@ +headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + $context->codePrinter->output('ext_Calends_calendar_register(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('void', 'ext_Calends_calendar_register(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCalendarRegisteredOptimizer.php b/libcalends/php/opt/CalendsCalendarRegisteredOptimizer.php new file mode 100644 index 0000000..2f4ad80 --- /dev/null +++ b/libcalends/php/opt/CalendsCalendarRegisteredOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_calendar_registered(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsCalendarUnregisterOptimizer.php b/libcalends/php/opt/CalendsCalendarUnregisterOptimizer.php new file mode 100644 index 0000000..5bb79df --- /dev/null +++ b/libcalends/php/opt/CalendsCalendarUnregisterOptimizer.php @@ -0,0 +1,25 @@ +headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + $context->codePrinter->output('ext_Calends_calendar_unregister(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('void', 'ext_Calends_calendar_unregister(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCompareOptimizer.php b/libcalends/php/opt/CalendsCompareOptimizer.php new file mode 100644 index 0000000..6f2fcdd --- /dev/null +++ b/libcalends/php/opt/CalendsCompareOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_compare(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsContainsOptimizer.php b/libcalends/php/opt/CalendsContainsOptimizer.php new file mode 100644 index 0000000..4c63401 --- /dev/null +++ b/libcalends/php/opt/CalendsContainsOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_contains(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateDoubleEndPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateDoubleEndPeriodOptimizer.php new file mode 100644 index 0000000..8eed6f7 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateDoubleEndPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_double_end_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateDoubleOptimizer.php b/libcalends/php/opt/CalendsCreateDoubleOptimizer.php new file mode 100644 index 0000000..33552db --- /dev/null +++ b/libcalends/php/opt/CalendsCreateDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateDoubleRangeOptimizer.php b/libcalends/php/opt/CalendsCreateDoubleRangeOptimizer.php new file mode 100644 index 0000000..03f3cdc --- /dev/null +++ b/libcalends/php/opt/CalendsCreateDoubleRangeOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_double_range(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateDoubleStartPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateDoubleStartPeriodOptimizer.php new file mode 100644 index 0000000..81a4903 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateDoubleStartPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_double_start_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateLongLongEndPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateLongLongEndPeriodOptimizer.php new file mode 100644 index 0000000..b8b599b --- /dev/null +++ b/libcalends/php/opt/CalendsCreateLongLongEndPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_long_long_end_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateLongLongOptimizer.php b/libcalends/php/opt/CalendsCreateLongLongOptimizer.php new file mode 100644 index 0000000..0076fb0 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateLongLongRangeOptimizer.php b/libcalends/php/opt/CalendsCreateLongLongRangeOptimizer.php new file mode 100644 index 0000000..911a452 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateLongLongRangeOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_long_long_range(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateLongLongStartPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateLongLongStartPeriodOptimizer.php new file mode 100644 index 0000000..98afe68 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateLongLongStartPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_long_long_start_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateStringEndPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateStringEndPeriodOptimizer.php new file mode 100644 index 0000000..3956549 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateStringEndPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_string_end_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateStringOptimizer.php b/libcalends/php/opt/CalendsCreateStringOptimizer.php new file mode 100644 index 0000000..dfc63c2 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateStringRangeOptimizer.php b/libcalends/php/opt/CalendsCreateStringRangeOptimizer.php new file mode 100644 index 0000000..e80803b --- /dev/null +++ b/libcalends/php/opt/CalendsCreateStringRangeOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_string_range(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsCreateStringStartPeriodOptimizer.php b/libcalends/php/opt/CalendsCreateStringStartPeriodOptimizer.php new file mode 100644 index 0000000..54b9483 --- /dev/null +++ b/libcalends/php/opt/CalendsCreateStringStartPeriodOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_create_string_start_period(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsDateOptimizer.php b/libcalends/php/opt/CalendsDateOptimizer.php new file mode 100644 index 0000000..49b64e2 --- /dev/null +++ b/libcalends/php/opt/CalendsDateOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_date(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsDecodeJsonOptimizer.php b/libcalends/php/opt/CalendsDecodeJsonOptimizer.php new file mode 100644 index 0000000..f3ea636 --- /dev/null +++ b/libcalends/php/opt/CalendsDecodeJsonOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_decode_json(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsDecodeTextOptimizer.php b/libcalends/php/opt/CalendsDecodeTextOptimizer.php new file mode 100644 index 0000000..b285267 --- /dev/null +++ b/libcalends/php/opt/CalendsDecodeTextOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_decode_text(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsDifferenceOptimizer.php b/libcalends/php/opt/CalendsDifferenceOptimizer.php new file mode 100644 index 0000000..ae50bf7 --- /dev/null +++ b/libcalends/php/opt/CalendsDifferenceOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_difference(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsDurationOptimizer.php b/libcalends/php/opt/CalendsDurationOptimizer.php new file mode 100644 index 0000000..49b5564 --- /dev/null +++ b/libcalends/php/opt/CalendsDurationOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_duration(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEncodeJsonOptimizer.php b/libcalends/php/opt/CalendsEncodeJsonOptimizer.php new file mode 100644 index 0000000..7ab159b --- /dev/null +++ b/libcalends/php/opt/CalendsEncodeJsonOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_encode_json(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEncodeTextOptimizer.php b/libcalends/php/opt/CalendsEncodeTextOptimizer.php new file mode 100644 index 0000000..0d1edfe --- /dev/null +++ b/libcalends/php/opt/CalendsEncodeTextOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_encode_text(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEndDateOptimizer.php b/libcalends/php/opt/CalendsEndDateOptimizer.php new file mode 100644 index 0000000..c91e9ed --- /dev/null +++ b/libcalends/php/opt/CalendsEndDateOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_end_date(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEndsAfterOptimizer.php b/libcalends/php/opt/CalendsEndsAfterOptimizer.php new file mode 100644 index 0000000..e64af1c --- /dev/null +++ b/libcalends/php/opt/CalendsEndsAfterOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_ends_after(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEndsBeforeOptimizer.php b/libcalends/php/opt/CalendsEndsBeforeOptimizer.php new file mode 100644 index 0000000..28acbe7 --- /dev/null +++ b/libcalends/php/opt/CalendsEndsBeforeOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_ends_before(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsEndsDuringOptimizer.php b/libcalends/php/opt/CalendsEndsDuringOptimizer.php new file mode 100644 index 0000000..321393c --- /dev/null +++ b/libcalends/php/opt/CalendsEndsDuringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_ends_during(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsGapOptimizer.php b/libcalends/php/opt/CalendsGapOptimizer.php new file mode 100644 index 0000000..16be57d --- /dev/null +++ b/libcalends/php/opt/CalendsGapOptimizer.php @@ -0,0 +1,36 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_gap(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsIntersectOptimizer.php b/libcalends/php/opt/CalendsIntersectOptimizer.php new file mode 100644 index 0000000..601e9ba --- /dev/null +++ b/libcalends/php/opt/CalendsIntersectOptimizer.php @@ -0,0 +1,36 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_intersect(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsAfterOptimizer.php b/libcalends/php/opt/CalendsIsAfterOptimizer.php new file mode 100644 index 0000000..a86de1e --- /dev/null +++ b/libcalends/php/opt/CalendsIsAfterOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_after(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsBeforeOptimizer.php b/libcalends/php/opt/CalendsIsBeforeOptimizer.php new file mode 100644 index 0000000..b3ba71b --- /dev/null +++ b/libcalends/php/opt/CalendsIsBeforeOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_before(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsDuringOptimizer.php b/libcalends/php/opt/CalendsIsDuringOptimizer.php new file mode 100644 index 0000000..397b272 --- /dev/null +++ b/libcalends/php/opt/CalendsIsDuringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_during(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsLongerOptimizer.php b/libcalends/php/opt/CalendsIsLongerOptimizer.php new file mode 100644 index 0000000..3d277eb --- /dev/null +++ b/libcalends/php/opt/CalendsIsLongerOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_longer(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsSameDurationOptimizer.php b/libcalends/php/opt/CalendsIsSameDurationOptimizer.php new file mode 100644 index 0000000..0693f9c --- /dev/null +++ b/libcalends/php/opt/CalendsIsSameDurationOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_same_duration(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsSameOptimizer.php b/libcalends/php/opt/CalendsIsSameOptimizer.php new file mode 100644 index 0000000..a26be94 --- /dev/null +++ b/libcalends/php/opt/CalendsIsSameOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_same(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsIsShorterOptimizer.php b/libcalends/php/opt/CalendsIsShorterOptimizer.php new file mode 100644 index 0000000..ce6099d --- /dev/null +++ b/libcalends/php/opt/CalendsIsShorterOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_is_shorter(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsMergeOptimizer.php b/libcalends/php/opt/CalendsMergeOptimizer.php new file mode 100644 index 0000000..35e4396 --- /dev/null +++ b/libcalends/php/opt/CalendsMergeOptimizer.php @@ -0,0 +1,36 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_merge(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsNextDoubleOptimizer.php b/libcalends/php/opt/CalendsNextDoubleOptimizer.php new file mode 100644 index 0000000..1c4989e --- /dev/null +++ b/libcalends/php/opt/CalendsNextDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_next_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsNextLongLongOptimizer.php b/libcalends/php/opt/CalendsNextLongLongOptimizer.php new file mode 100644 index 0000000..3832a43 --- /dev/null +++ b/libcalends/php/opt/CalendsNextLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_next_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsNextStringOptimizer.php b/libcalends/php/opt/CalendsNextStringOptimizer.php new file mode 100644 index 0000000..8f11adb --- /dev/null +++ b/libcalends/php/opt/CalendsNextStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_next_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsOverlapsOptimizer.php b/libcalends/php/opt/CalendsOverlapsOptimizer.php new file mode 100644 index 0000000..bb3420f --- /dev/null +++ b/libcalends/php/opt/CalendsOverlapsOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_overlaps(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsPreviousDoubleOptimizer.php b/libcalends/php/opt/CalendsPreviousDoubleOptimizer.php new file mode 100644 index 0000000..6fbd42a --- /dev/null +++ b/libcalends/php/opt/CalendsPreviousDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_previous_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsPreviousLongLongOptimizer.php b/libcalends/php/opt/CalendsPreviousLongLongOptimizer.php new file mode 100644 index 0000000..ceeb25b --- /dev/null +++ b/libcalends/php/opt/CalendsPreviousLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_previous_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsPreviousStringOptimizer.php b/libcalends/php/opt/CalendsPreviousStringOptimizer.php new file mode 100644 index 0000000..dc150ab --- /dev/null +++ b/libcalends/php/opt/CalendsPreviousStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_previous_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsReleaseOptimizer.php b/libcalends/php/opt/CalendsReleaseOptimizer.php new file mode 100644 index 0000000..a3e8200 --- /dev/null +++ b/libcalends/php/opt/CalendsReleaseOptimizer.php @@ -0,0 +1,27 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + $context->codePrinter->output('ext_Calends_release(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('void', 'ext_Calends_release(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsStartsAfterOptimizer.php b/libcalends/php/opt/CalendsStartsAfterOptimizer.php new file mode 100644 index 0000000..53be4a5 --- /dev/null +++ b/libcalends/php/opt/CalendsStartsAfterOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_starts_after(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsStartsBeforeOptimizer.php b/libcalends/php/opt/CalendsStartsBeforeOptimizer.php new file mode 100644 index 0000000..99fc437 --- /dev/null +++ b/libcalends/php/opt/CalendsStartsBeforeOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_starts_before(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsStartsDuringOptimizer.php b/libcalends/php/opt/CalendsStartsDuringOptimizer.php new file mode 100644 index 0000000..5c2fb4e --- /dev/null +++ b/libcalends/php/opt/CalendsStartsDuringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Return value can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_starts_during(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsStringOptimizer.php b/libcalends/php/opt/CalendsStringOptimizer.php new file mode 100644 index 0000000..9021c3a --- /dev/null +++ b/libcalends/php/opt/CalendsStringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_Calends_string(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractDoubleOptimizer.php b/libcalends/php/opt/CalendsSubtractDoubleOptimizer.php new file mode 100644 index 0000000..c8be031 --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractFromEndDoubleOptimizer.php b/libcalends/php/opt/CalendsSubtractFromEndDoubleOptimizer.php new file mode 100644 index 0000000..504898e --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractFromEndDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_from_end_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractFromEndLongLongOptimizer.php b/libcalends/php/opt/CalendsSubtractFromEndLongLongOptimizer.php new file mode 100644 index 0000000..4a0831a --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractFromEndLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_from_end_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractFromEndStringOptimizer.php b/libcalends/php/opt/CalendsSubtractFromEndStringOptimizer.php new file mode 100644 index 0000000..f709628 --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractFromEndStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_from_end_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractLongLongOptimizer.php b/libcalends/php/opt/CalendsSubtractLongLongOptimizer.php new file mode 100644 index 0000000..df5a076 --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsSubtractStringOptimizer.php b/libcalends/php/opt/CalendsSubtractStringOptimizer.php new file mode 100644 index 0000000..5ceddac --- /dev/null +++ b/libcalends/php/opt/CalendsSubtractStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_subtract_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDateDoubleOptimizer.php b/libcalends/php/opt/CalendsWithDateDoubleOptimizer.php new file mode 100644 index 0000000..77bc796 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDateDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_date_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDateLongLongOptimizer.php b/libcalends/php/opt/CalendsWithDateLongLongOptimizer.php new file mode 100644 index 0000000..88d901a --- /dev/null +++ b/libcalends/php/opt/CalendsWithDateLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_date_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDateStringOptimizer.php b/libcalends/php/opt/CalendsWithDateStringOptimizer.php new file mode 100644 index 0000000..106d978 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDateStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_date_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationDoubleOptimizer.php b/libcalends/php/opt/CalendsWithDurationDoubleOptimizer.php new file mode 100644 index 0000000..b65f4c4 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationFromEndDoubleOptimizer.php b/libcalends/php/opt/CalendsWithDurationFromEndDoubleOptimizer.php new file mode 100644 index 0000000..d5f15c7 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationFromEndDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_from_end_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationFromEndLongLongOptimizer.php b/libcalends/php/opt/CalendsWithDurationFromEndLongLongOptimizer.php new file mode 100644 index 0000000..68c4844 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationFromEndLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_from_end_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationFromEndStringOptimizer.php b/libcalends/php/opt/CalendsWithDurationFromEndStringOptimizer.php new file mode 100644 index 0000000..c604449 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationFromEndStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_from_end_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationLongLongOptimizer.php b/libcalends/php/opt/CalendsWithDurationLongLongOptimizer.php new file mode 100644 index 0000000..bf6c0f7 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithDurationStringOptimizer.php b/libcalends/php/opt/CalendsWithDurationStringOptimizer.php new file mode 100644 index 0000000..96041e5 --- /dev/null +++ b/libcalends/php/opt/CalendsWithDurationStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_duration_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithEndDateDoubleOptimizer.php b/libcalends/php/opt/CalendsWithEndDateDoubleOptimizer.php new file mode 100644 index 0000000..1f30875 --- /dev/null +++ b/libcalends/php/opt/CalendsWithEndDateDoubleOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_end_date_double(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithEndDateLongLongOptimizer.php b/libcalends/php/opt/CalendsWithEndDateLongLongOptimizer.php new file mode 100644 index 0000000..32d8707 --- /dev/null +++ b/libcalends/php/opt/CalendsWithEndDateLongLongOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_end_date_long_long(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/CalendsWithEndDateStringOptimizer.php b/libcalends/php/opt/CalendsWithEndDateStringOptimizer.php new file mode 100644 index 0000000..ab7b59c --- /dev/null +++ b/libcalends/php/opt/CalendsWithEndDateStringOptimizer.php @@ -0,0 +1,35 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Calends objects are identified by 'double' type values", $expression); + } + + $context->headersManager->add('wrap_libcalends'); + $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + return new CompiledExpression('double', 'ext_Calends_with_end_date_string(' . implode($resolvedParams, ', ') . ')', $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeAddOptimizer.php b/libcalends/php/opt/Tai64timeAddOptimizer.php new file mode 100644 index 0000000..6eb3cf1 --- /dev/null +++ b/libcalends/php/opt/Tai64timeAddOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_add(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeDecodeTextOptimizer.php b/libcalends/php/opt/Tai64timeDecodeTextOptimizer.php new file mode 100644 index 0000000..8bb96a6 --- /dev/null +++ b/libcalends/php/opt/Tai64timeDecodeTextOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_decode_text(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeDoubleOptimizer.php b/libcalends/php/opt/Tai64timeDoubleOptimizer.php new file mode 100644 index 0000000..883e69f --- /dev/null +++ b/libcalends/php/opt/Tai64timeDoubleOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to 'variant' type variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_double(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeEncodeTextOptimizer.php b/libcalends/php/opt/Tai64timeEncodeTextOptimizer.php new file mode 100644 index 0000000..7d1d005 --- /dev/null +++ b/libcalends/php/opt/Tai64timeEncodeTextOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant or string variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_encode_text(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeFromDoubleOptimizer.php b/libcalends/php/opt/Tai64timeFromDoubleOptimizer.php new file mode 100644 index 0000000..ea6f3ef --- /dev/null +++ b/libcalends/php/opt/Tai64timeFromDoubleOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_from_double(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeFromHexStringOptimizer.php b/libcalends/php/opt/Tai64timeFromHexStringOptimizer.php new file mode 100644 index 0000000..f728910 --- /dev/null +++ b/libcalends/php/opt/Tai64timeFromHexStringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_from_hex_string(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeFromStringOptimizer.php b/libcalends/php/opt/Tai64timeFromStringOptimizer.php new file mode 100644 index 0000000..12ea98c --- /dev/null +++ b/libcalends/php/opt/Tai64timeFromStringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_from_string(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeHexStringOptimizer.php b/libcalends/php/opt/Tai64timeHexStringOptimizer.php new file mode 100644 index 0000000..998c3a8 --- /dev/null +++ b/libcalends/php/opt/Tai64timeHexStringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant or string variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_hex_string(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeStringOptimizer.php b/libcalends/php/opt/Tai64timeStringOptimizer.php new file mode 100644 index 0000000..4be23ba --- /dev/null +++ b/libcalends/php/opt/Tai64timeStringOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariableAndString()) { + throw new CompilerException("Returned values can only be assigned to variant or string variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_string(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeSubOptimizer.php b/libcalends/php/opt/Tai64timeSubOptimizer.php new file mode 100644 index 0000000..fc20d42 --- /dev/null +++ b/libcalends/php/opt/Tai64timeSubOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_sub(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeTaiToUtcOptimizer.php b/libcalends/php/opt/Tai64timeTaiToUtcOptimizer.php new file mode 100644 index 0000000..10e7846 --- /dev/null +++ b/libcalends/php/opt/Tai64timeTaiToUtcOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_tai_to_utc(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/libcalends/php/opt/Tai64timeUtcToTaiOptimizer.php b/libcalends/php/opt/Tai64timeUtcToTaiOptimizer.php new file mode 100644 index 0000000..a86ccd5 --- /dev/null +++ b/libcalends/php/opt/Tai64timeUtcToTaiOptimizer.php @@ -0,0 +1,39 @@ +getReadOnlyResolvedParams($expression['parameters'], $context, $expression); + + /** + * Process the expected symbol to be returned + */ + $call->processExpectedReturn($context); + $symbolVariable = $call->getSymbolVariable(true, $context); + if ($symbolVariable->isNotVariable()) { + throw new CompilerException("Returned values can only be assigned to variant variables", $expression); + } + $context->headersManager->add('wrap_libcalends'); + $context->headersManager->add('kernel/string'); + $symbolVariable->setDynamicTypes('string'); + if ($call->mustInitSymbolVariable()) { + $symbolVariable->initVariant($context); + } + $symbol = $context->backend->getVariableCode($symbolVariable); + $context->codePrinter->output($symbolVariable->getRealName() . ' = ext_TAI64Time_utc_to_tai(' . implode($resolvedParams, ', ') . ');'); + return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression); + } +} diff --git a/tests/core_dump_info.sh b/tests/core_dump_info.sh index b72e3a5..1d0580f 100755 --- a/tests/core_dump_info.sh +++ b/tests/core_dump_info.sh @@ -7,7 +7,7 @@ export LC_ALL=C for i in core*; do if [ -f "$i" -a "$(file "$i" | grep -o 'core file')" ]; then echo -e "\n--------\nExpanding info for $i\n========" - gdb -q $(phpenv which php || which php) "$i" </dev/null) "$i" <