cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omefire <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: Implementation for Unified platform API
Date Thu, 11 Jun 2015 17:31:58 GMT
Github user omefire commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/235#discussion_r32246260
  
    --- Diff: cordova-lib/src/platforms/PlatformApi.js ---
    @@ -0,0 +1,414 @@
    +/**
    +    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.
    +*/
    +
    +var Q = require('q'),
    +    fs = require('fs'),
    +    path = require('path'),
    +    shell = require('shelljs'),
    +    events = require('../events'),
    +    util = require('../cordova/util'),
    +    superspawn = require('../cordova/superspawn'),
    +    platforms = require('./platformsConfig.json'),
    +    ConfigParser = require('../configparser/ConfigParser');
    +
    +var BasePluginHandler = require('../plugman/platforms/PluginHandler');
    +var ParserHelper = require('../cordova/metadata/parserhelper/ParserHelper');
    +
    +// Avoid loading the same platform projects more than once (identified by path)
    +var cachedProjects = {};
    +
    +/**
    + * A single class that exposes platform-dependent functionality for cordova and
    + * plugman. This class works as a base, and provides some default implementation
    + * for that functionality. It should not be instantiated directly, only through
    + * 'getPlatformApi' module method.
    + * @param  {String} platform        Name of platform. Should be one of names, declared
    + *                                  in platformsConfig.json
    + * @param  {String} platformRootDir Optional. Path to platform directory. If not provided
    + *                                  default value is set to<cordova_project>/platforms/<platform>
    + */
    +function BasePlatformApi(platform, platformRootDir) {
    +    this.root = platformRootDir;
    +    this.platform = platform;
    +
    +    // Parser property of Platform API left for backward compatibility
    +    // and smooth transition to ne API. It also does the job of requiring
    +    // and constructing legacy Parser instance, which required for platforms
    +    // that still stores their code in cordova-lib.
    +    var parser;
    +    Object.defineProperty(this, 'parser', {
    +        get: function () {
    +            if (parser)return parser;
    +
    +            var ParserConstructor;
    +            try {
    +                ParserConstructor = require(platforms[this.platform].parser_file);
    +            } catch (e) { }
    +
    +            // parser === null is the special case which means that we've tried
    +            // to get embedded platform parser and failed. In this case instead of
    +            // parser's methods will be called PlatformApi default implementations.
    --- End diff --
    
    this sentence is a little confusing. 
    Maybe reword it to 'In this case, the default behavior as implemented by PlatformApi will
be used' ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message