Renamed warn Added assertType Added ASDoc
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/33845cf2 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/33845cf2 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/33845cf2 Branch: refs/heads/feature/strand-work Commit: 33845cf25e521b5c91d04252d92f606b50fec344 Parents: 0a006c4 Author: Harbs <[email protected]> Authored: Sun Jul 16 12:58:50 2017 +0300 Committer: Harbs <[email protected]> Committed: Sun Jul 16 12:58:50 2017 +0300 ---------------------------------------------------------------------- .../projects/Core/src/main/flex/CoreClasses.as | 1 + .../flex/org/apache/flex/debugging/assert.as | 3 ++ .../org/apache/flex/debugging/assertType.as | 42 +++++++++++++++++++ .../flex/org/apache/flex/debugging/check.as | 44 ++++++++++++++++++++ .../apache/flex/debugging/conditionalBreak.as | 4 ++ .../flex/org/apache/flex/debugging/notNull.as | 3 ++ .../main/flex/org/apache/flex/debugging/warn.as | 41 ------------------ 7 files changed, 97 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/CoreClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as index 0806acb..2055f9e 100644 --- a/frameworks/projects/Core/src/main/flex/CoreClasses.as +++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as @@ -114,6 +114,7 @@ internal class CoreClasses import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl; import org.apache.flex.debugging.assert; assert; + import org.apache.flex.debugging.assertType; assertType; // import org.apache.flex.debugging.conditionalBreak; conditionalBreak; import org.apache.flex.debugging.notNull; notNull; import org.apache.flex.debugging.warn; warn; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assert.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assert.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assert.as index ee0a4a1..794e785 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assert.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assert.as @@ -23,6 +23,9 @@ package org.apache.flex.debugging import goog.DEBUG; } + /** + * assert throws an error if the condition is not met. + */ public function assert(condition:Boolean,message:String):void { COMPILE::SWF http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as new file mode 100644 index 0000000..53bf4b5 --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.debugging +{ + + COMPILE::JS + { + import goog.DEBUG; + } + + /** + * asserts an object is of the desired type. + */ + public function assertType(obj:Object,type:Class):void + { + COMPILE::SWF + { + assert((obj is type),"object is not the correct type"); + } + COMPILE::JS + { + if(goog.DEBUG) + assert((obj is type),"object is not the correct type"); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/check.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/check.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/check.as new file mode 100644 index 0000000..2bc8889 --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/check.as @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.debugging +{ + COMPILE::JS + { + import goog.DEBUG; + } + + /** + * Traces a warning if the condition is not met. + */ + public function check(condition:Boolean,message:String):void + { + COMPILE::SWF + { + if(!condition) + trace("warning: " + message); + } + COMPILE::JS + { + if(goog.DEBUG && !condition) + { + trace("warning: " + message); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/conditionalBreak.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/conditionalBreak.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/conditionalBreak.as index fb079e0..24a481c 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/conditionalBreak.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/conditionalBreak.as @@ -26,6 +26,10 @@ package org.apache.flex.debugging { import goog.DEBUG; } + + /** + * If the condition is not met, the code will break into the debugger. + */ public function conditionalBreak(condition:Boolean):void { COMPILE::SWF http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as index c861e1f..eb4ba89 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as @@ -23,6 +23,9 @@ package org.apache.flex.debugging import goog.DEBUG; } + /** + * Throws an error if the object is null. + */ public function notNull(obj:Object):void { COMPILE::SWF http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/33845cf2/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/warn.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/warn.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/warn.as deleted file mode 100644 index e88c234..0000000 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/warn.as +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.debugging -{ - COMPILE::JS - { - import goog.DEBUG; - } - - public function warn(condition:Boolean,message:String):void - { - COMPILE::SWF - { - if(!condition) - trace("warning: " + message); - } - COMPILE::JS - { - if(goog.DEBUG && !condition) - { - trace("warning: " + message); - } - } - } -} \ No newline at end of file
