All Downloads are FREE. Search and download functionalities are using the official Maven repository.

joo.MemberDeclaration.as Maven / Gradle / Ivy

There is a newer version: 4.1.8
Show newest version
/*
 * Copyright 2009 CoreMedia AG
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an "AS
 * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
 * express or implied. See the License for the specific language 
 * governing permissions and limitations under the License.
 */

// JangarooScript runtime support. Author: Frank Wienberg

package joo {

public class MemberDeclaration {

  public static const
          METHOD_TYPE_GET : String = "get",
          METHOD_TYPE_SET : String = "set",
          MEMBER_TYPE_VAR : String = "var",
          MEMBER_TYPE_CONST : String = "const",
          MEMBER_TYPE_FUNCTION : String = "function",
          MEMBER_TYPE_CLASS : String = "class",
          MEMBER_TYPE_INTERFACE : String = "interface",
          MEMBER_TYPE_NAMESPACE : String = "namespace",
          NAMESPACE_PRIVATE : String = "private",
          NAMESPACE_INTERNAL : String = "internal",
          NAMESPACE_PROTECTED : String = "protected",
          NAMESPACE_PUBLIC : String = "public",
          STATIC : String = "static",
          FINAL : String = "final",
          NATIVE : String = "native",
          OVERRIDE : String = "override",
          VIRTUAL : String = "virtual";

  private static var SUPPORTS_GETTERS_SETTERS : Boolean;
  private static var SUPPORTS_PROPERTIES : Boolean;
  private static var DEFINE_METHOD : Object;
  private static var LOOKUP_METHOD : Object;

{
  // no static initializers in system classes, use static block:
  if ('getOwnPropertyDescriptor' in Object) {
    try {
      // To make sure we are not in IE8, which implements this method only partially,
      // just try getting a property of some Object and see if it fails:
      SUPPORTS_PROPERTIES = Object['getOwnPropertyDescriptor']({foo:1},"foo").value === 1;
    } catch (e:*) {
      // ignore
    }
  }
  SUPPORTS_GETTERS_SETTERS = "__defineGetter__" in Object['prototype'];
  DEFINE_METHOD = {
    "get":  "__defineGetter__",
    "set": "__defineSetter__"
  };
  LOOKUP_METHOD = {
    "get": "__lookupGetter__",
    "set": "__lookupSetter__"
  };
}

  public static function create(memberDeclarationStr : String) : MemberDeclaration {
    var tokens : Array = memberDeclarationStr.split(/\s+/);
    // ignore imports:
    return tokens[0]=="import" ? null
           : new MemberDeclaration(tokens);
  }

  internal var
          _namespace : String = NAMESPACE_INTERNAL,
          _static : Boolean = false,
          _final : Boolean = false,
          _native : Boolean = false,
          _override : Boolean = false,
          _cloneFactory : Function;
  public var
          memberType : String,
          getterOrSetter : String,
          memberName : String,
          slot : String,
          value : *;
  /**
   * The metadata (annotations) associated with this member.
   */
  public var metadata : Object = {};

  public function MemberDeclaration(tokens : Array) {
    for (var j:int=0; j




© 2015 - 2025 Weber Informatics LLC | Privacy Policy