Package org.hisrc.jscm.codemodel.expression

Examples of org.hisrc.jscm.codemodel.expression.JSObjectLiteral$JSPropertyAssignment


    JsonixModule module = getModule(elementInfo);
    MTypeInfo<T, C> typeInfo = elementInfo.getTypeInfo();
    MTypeInfo<T, C> scope = elementInfo.getScope();
    QName substitutionHead = elementInfo.getSubstitutionHead();

    final JSObjectLiteral value = this.codeModel.object();
    module.registerElementInfo(value);
    JSAssignmentExpression typeInfoDeclaration = getTypeInfoDeclaration(typeInfo);
    QName elementName = elementInfo.getElementName();
    value.append("elementName",
        module.createElementNameExpression(elementName));
    // TODO
    if (typeInfoDeclaration != null) {
      value.append("typeInfo", typeInfoDeclaration);
    }

    if (scope != null) {
      value.append("scope", getTypeInfoDeclaration(scope));
    }
    if (substitutionHead != null) {
      value.append("substitutionHead",
          module.createElementNameExpression(substitutionHead));
    }
    return value;
  }
View Full Code Here


    this.outputPackageName = packageMapping.getOutputPackageName();
    this.spaceName = packageMapping.getSpaceName();

    this.directory = packageMapping.getDirectory();
    this.fileName = packageMapping.getFileName();
    final JSObjectLiteral spaceBody = codeModel.object();

    spaceBody.append("name", codeModel.string(this.spaceName));

    this.defaultElementNamespaceURI = packageMapping
        .getDefaultElementNamespaceURI();
    if (this.defaultElementNamespaceURI != null) {
      spaceBody.append("defaultElementNamespaceURI",
          codeModel.string(this.defaultElementNamespaceURI));
    }

    this.defaultAttributeNamespaceURI = packageMapping
        .getDefaultAttributeNamespaceURI();
    if (this.defaultAttributeNamespaceURI != null) {
      spaceBody.append("defaultAttributeNamespaceURI",
          codeModel.string(this.defaultAttributeNamespaceURI));
    }

    this.space = this.declarations.var(this.spaceName, spaceBody);

    this.exportDeclarations
        ._if(this.codeModel.globalVariable("require").typeof()
            .eeq(codeModel.string("function")))
        ._then()
        .block()
        .expression(
            codeModel.globalVariable("module").p("exports")
                .p(this.spaceName)
                .assign(this.space.getVariable()));

    typeInfos = codeModel.array();
    spaceBody.append("typeInfos", typeInfos);

    elementInfos = codeModel.array();
    spaceBody.append("elementInfos", elementInfos);

  }
View Full Code Here

    if (ObjectUtils.equals(defaultNamespaceURI, namespaceURI)) {
      return this.codeModel.string(name.getLocalPart());
    } else {

      final JSObjectLiteral nameExpression = this.codeModel.object();

      nameExpression.append("localPart",
          this.codeModel.string(name.getLocalPart()));

      if (!StringUtils.isEmpty(namespaceURI)) {
        nameExpression.append("namespaceURI",
            this.codeModel.string(namespaceURI));

      }
      return nameExpression;
    }
View Full Code Here

  public JSAssignmentExpression visitClassInfo(MClassInfo<T, C> info) {
    return createTypeInfoDeclaration(info);
  }

  public JSAssignmentExpression visitList(MList<T, C> info) {
    final JSObjectLiteral list = this.codeModel.object();
    list.append("type", this.codeModel.string("list"));
    list.append("typeInfo",
        info.getItemTypeInfo().acceptTypeInfoVisitor(this));
    return list;
  }
View Full Code Here

    JSGlobalVariable $Object = codeModel.globalVariable("Object");
    JSGlobalVariable $navigator = codeModel.globalVariable("navigator");
    JSGlobalVariable $window = codeModel.globalVariable("window");
    JSGlobalVariable $document = codeModel.globalVariable("document");

    JSObjectLiteral _Prototype = codeModel.object();
    program.var("Prototype", _Prototype);

    {
      _Prototype.append("Version", codeModel.string("1.6.1"));
    }
    {
      final Function function = codeModel.function();
      JSFunctionBody body = function.getBody();
      JSVariable $ua = body.var("ua",
          $navigator.p("userAgent")).getVariable();
      JSVariable $isOpera = body.var(
          "isOpera",
          $Object.p("prototype").p("toString")
              .i("call").args($window.p("opera"))
              .eq(codeModel.string("[object Opera]")))
          .getVariable();
      body._return(codeModel
          .object()
          .append("IE",
              $window.p("attachEvent").not().not()
                  .and($isOpera.not()))
          .append("Opera", $isOpera)
          .append("WebKit",
              $ua.i("indexOf")
                  .args(codeModel.string("AppleWebKit/"))
                  .gt(codeModel.integer(-1)))
          .append("Gecko",
              $ua.i("indexOf")
                  .args(codeModel.string("Gecko"))
                  .gt(codeModel.integer(-1))
                  .and($ua.i("indexOf")
                      .args(codeModel.string("KHTML"))
                      .eeq(codeModel.integer(-1))))
      // Regexps are not supported at the moment
      // append("MobileSafari",
      // codeModel.regexp("/Apple.*Mobile.*Safari/").call("test").args($ua))
      );

      _Prototype.append("Browser", function.brackets().i());
    }

    {
      final JSObjectLiteral _BrowserFeatures = codeModel.object();
      _Prototype.append("BrowserFeatures", _BrowserFeatures);

      _BrowserFeatures.append("XPath", $document.p("evaluate")
          .not().not());
      _BrowserFeatures.append("SelectorsAPI",
          $document.p("querySelector").not().not());
      {
        final Function _ElementExtensions = codeModel.function();

        JSVariable $constructor = _ElementExtensions
            .getBody()
            .var(
                "constructor",
                $window.p("Element").or(
                    $window.p("HTMLElement")))
            .getVariable();
        _ElementExtensions.getBody()._return(
            $constructor.and($constructor.p("prototype"))
                .brackets().not().not());
        _BrowserFeatures.append("ElementExtensions", _ElementExtensions
            .brackets().i());
      }

      {
        final Function f = codeModel.function();
        _BrowserFeatures.append("SpecificElementExtensions", f
            .brackets().i());
        JSFunctionBody b = f.getBody();
        b._if($window.p("HTMLDivElement").typeof()
            .nee(codeModel.string("undefined")))._then()
            ._return(codeModel._boolean(true));
View Full Code Here

TOP

Related Classes of org.hisrc.jscm.codemodel.expression.JSObjectLiteral$JSPropertyAssignment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.