根据 ua 判断
@param    {[type]}                ua       [description]
@param    {[type]}                platform [description]
@return   {[type]}                [description]
@datetime 2016-12-15T22:11:20+080
@author wangxiao<i@muyao.me>
976742
function detect(ua, platform) {
  const os = {};
  const browser = {};

  const webkit = ua.match(/Web[kK]it[/]{0,1}([\d.]+)/);
  const android = ua.match(/(Android);?[\s/]+([\d.]+)?/);
  const osx = !!ua.match(/\(Macintosh; Intel /);
  const weixin = ua.match(/MicroMessenger/i);
  const weibo = ua.match(/Weibo/i);
  const qq = ua.indexOf('QQ/') !== -1;
  const ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  const iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  const webos = ua.match(/(webOS|hpwOS)[\s/]([\d.]+)/);
  const win = /Win\d{2}|Windows/.test(platform);
  const wp = ua.match(/Windows Phone ([\d.]+)/);
  const touchpad = webos && ua.match(/TouchPad/);
  const kindle = ua.match(/Kindle\/([\d.]+)/);
  const silk = ua.match(/Silk\/([\d._]+)/);
  const blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  const bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  const rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  const playbook = ua.match(/PlayBook/);
  const chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  const firefox = ua.match(/Firefox\/([\d.]+)/);
  const firefoxos = ua.match(/\((?:Mobile|Tablet); rv:([\d.]+)\).*Firefox\/[\d.]+/);
  const ie = ua.match(/MSIE\s([\d.]+)/) || ua.match(/Trident\/[\d](?=[^?]+).*rv:([0-9.].)/);
  const webview = !chrome && ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/);
  const safari = webview || ua.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/);

  // Todo: clean this up with a better OS/browser seperation:
  // - discern (more) between multiple browsers on android
  // - decide if kindle fire in silk mode is android or not
  // - Firefox on Android doesn't specify the Android version
  // - possibly devide in os, device and browser hashes

  if (android) {
    os.android = true;
    os.version = android[2];
  }

  if (iphone && !ipod) {
    os.ios = os.iphone = true;
    os.version = iphone[2].replace(/_/g, '.');
  }

  if (ipad) {
    os.ios = os.ipad = true;
    os.version = ipad[2].replace(/_/g, '.');
  }

  if (ipod) {
    os.ios = os.ipod = true;
    os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  }

  if (wp) {
    os.wp = true;
    os.version = wp[1];
  }

  if (webos) {
    os.webos = true;
    os.version = webos[2];
  }

  if (touchpad) {
    os.touchpad = true;
  }

  if (blackberry) {
    os.blackberry = true;
    os.version = blackberry[2];
  }

  if (bb10) {
    os.bb10 = true;
    os.version = bb10[2];
  }

  if (rimtabletos) {
    os.rimtabletos = true;
    os.version = rimtabletos[2];
  }

  if (kindle) {
    os.kindle = true;
    os.version = kindle[1];
  }

  if (firefoxos) {
    os.firefoxos = true;
    os.version = firefoxos[1];
  }

  // 浏览器判断
  if (webkit) {
    browser.webkit = true;
    browser.version = webkit[1];
  }

  if (weixin) {
    browser.weixin = true;
  }

  if (weibo) {
    browser.weibo = true;
  }

  if (qq) {
    browser.qq = true;
  }

  if (playbook) {
    browser.playbook = true;
  }

  if (silk) {
    browser.silk = true;
    browser.version = silk[1];
  }

  if (!silk && os.android && ua.match(/Kindle Fire/)) {
    browser.silk = true;
  }

  if (chrome) {
    browser.chrome = true;
    browser.version = chrome[1];
  }

  if (firefox) {
    browser.firefox = true;
    browser.version = firefox[1];
  }

  if (ie) {
    browser.ie = true;
    browser.version = ie[1];
  }

  if (safari && (osx || os.ios || win)) {
    browser.safari = true;
    if (!os.ios) {
      browser.version = safari[1];
    }
  }

  if (webview) {
    browser.webview = true;
  }

  os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
    (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));

  os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 ||
    (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
    (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));

  return {
    os,
    browser
  };
}
1040649
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        $result = null;

        if ($value !== null && ($dateOrNull = parent::convertToPHPValue($value, $platform)) !== null) {
            // despite the name it's not null already
            $result = DateTime::createFromDateTime($dateOrNull);
        }

        return $result;
    }
516334
function getPlatforms(tdef) {
	const platforms = [];

	if (tdef) {
		tdef.deployUnits.array.forEach((du) => {
			const platform = du.findFiltersByID('platform');
			if (platform && platforms.indexOf(platform.value) === -1) {
				platforms.push(platform.value);
			}
		});
	}

	return platforms;
}
1209609
function detectPlatform(platform) {
    var name = platform.toLowerCase();
    var prefix = "", suffix = "";

    // Detect NuGet/Squirrel.Windows files
    if (name == 'releases' || hasSuffix(name, '.nupkg')) return platforms.WINDOWS_32;

    // Detect prefix: osx, widnows or linux
    if (_.contains(name, 'win')
        || hasSuffix(name, '.exe')) prefix = platforms.WINDOWS;

    if (_.contains(name, 'linux')
        || _.contains(name, 'ubuntu')
        || hasSuffix(name, '.deb')
        || hasSuffix(name, '.rpm')
        || hasSuffix(name, '.tgz')
        || hasSuffix(name, '.tar.gz')) {

        if (_.contains(name, 'linux_deb') || hasSuffix(name, '.deb')) {
            prefix = platforms.LINUX_DEB;
        }
        else if (_.contains(name, 'linux_rpm') || hasSuffix(name, '.rpm')) {
            prefix = platforms.LINUX_RPM;
        }
        else if (_.contains(name, 'linux') || hasSuffix(name, '.tgz') || hasSuffix(name, '.tar.gz')) {
            prefix = platforms.LINUX;
        }
    }

    if (_.contains(name, 'mac')
        || _.contains(name, 'osx')
        || name.indexOf('darwin') >= 0
        || hasSuffix(name, '.dmg')) prefix = platforms.OSX;

    // Detect suffix: 32 or 64
    if (_.contains(name, '32')
        || _.contains(name, 'ia32')
        || _.contains(name, 'i386')) suffix = '32';
    if (_.contains(name, '64') || _.contains(name, 'x64') || _.contains(name, 'amd64')) suffix = '64';

    suffix = suffix || (prefix == platforms.OSX? '64' : '32');
    return _.compact([prefix, suffix]).join('_');
}
90312
function (projectName) {
  var deferred = Q.defer();
  var platforms = [];
  var xcodeFolder = '/Images.xcassets/LaunchImage.launchimage/';

  if (settings.OLD_XCODE_PATH) {
    xcodeFolder = '/Resources/splash/';
  }

  platforms.push({
    name : 'ios',
    // TODO: use async fs.exists
    isAdded : fs.existsSync('platforms/ios'),
    splashPath : 'platforms/ios/' + projectName + xcodeFolder,
    splash : [
      // iPhone
      { name: 'Default~iphone.png',            width: 320,  height: 480  },
      { name: 'Default@2x~iphone.png',         width: 640,  height: 960  },
      { name: 'Default-568h@2x~iphone.png',    width: 640,  height: 1136 },
      { name: 'Default-667h.png',              width: 750,  height: 1334 },
      { name: 'Default-736h.png',              width: 1242, height: 2208 },
      { name: 'Default-Landscape-736h.png',    width: 2208, height: 1242 },
      { name: 'Default-2436h.png',             width: 1125, height: 2436 },
      { name: 'Default-Landscape-2436h.png',   width: 2436, height: 1125 },
      { name: 'Default-2688h.png',             width: 1242, height: 2688 },
      { name: 'Default-Landscape-2688h.png',   width: 2688, height: 1242 },
      { name: 'Default-1792h.png',             width: 828, height: 1792 },
      { name: 'Default-Landscape-1792h.png',   width: 1792, height: 828 },
      // iPad
      { name: 'Default-Portrait~ipad.png',     width: 768,  height: 1024 },
      { name: 'Default-Portrait@2x~ipad.png',  width: 1536, height: 2048 },
      { name: 'Default-Landscape~ipad.png',    width: 1024, height: 768  },
      { name: 'Default-Landscape@2x~ipad.png', width: 2048, height: 1536 }
    ]
  });
  platforms.push({
    name : 'android',
    isAdded : fs.existsSync('platforms/android'),
    splashPath : 'platforms/android/res/',
    splash : [
      // Landscape
      { name: 'drawable-land-ldpi/screen.png',  width: 320,  height: 200  },
      { name: 'drawable-land-mdpi/screen.png',  width: 480,  height: 320  },
      { name: 'drawable-land-hdpi/screen.png',  width: 800,  height: 480  },
      { name: 'drawable-land-xhdpi/screen.png', width: 1280, height: 720  },
      { name: 'drawable-land-xxhdpi/screen.png', width: 1600, height: 960  },
      { name: 'drawable-land-xxxhdpi/screen.png', width: 1920, height: 1280  },
      // Portrait
      { name: 'drawable-port-ldpi/screen.png',  width: 200,  height: 320  },
      { name: 'drawable-port-mdpi/screen.png',  width: 320,  height: 480  },
      { name: 'drawable-port-hdpi/screen.png',  width: 480,  height: 800  },
      { name: 'drawable-port-xhdpi/screen.png', width: 720,  height: 1280 },
      { name: 'drawable-port-xxhdpi/screen.png', width: 960, height: 1600  },
      { name: 'drawable-port-xxxhdpi/screen.png', width: 1280, height: 1920  }
    ]
  });
  platforms.push({
    name : 'windows',
    isAdded : fs.existsSync('platforms/windows'),
    splashPath : 'platforms/windows/images/',
    splash : [
      // Landscape
      { name: 'SplashScreen.scale-100.png', width: 620,  height: 300  },
      { name: 'SplashScreen.scale-125.png', width: 775,  height: 375  },
      { name: 'SplashScreen.scale-140.png', width: 868,  height: 420  },
      { name: 'SplashScreen.scale-150.png', width: 930,  height: 450  },
      { name: 'SplashScreen.scale-180.png', width: 1116,  height: 540  },
      { name: 'SplashScreen.scale-200.png', width: 1240, height: 600  },
      { name: 'SplashScreen.scale-400.png', width: 2480, height: 1200 },
      // Portrait
      { name: 'SplashScreenPhone.scale-240.png', width: 1152,  height: 1920  },
      { name: 'SplashScreenPhone.scale-140.png', width: 672,  height: 1120  },
      { name: 'SplashScreenPhone.scale-100.png', width: 480,  height: 800  }
    ]
  });
  deferred.resolve(platforms);
  return deferred.promise;
}
65153
function getApiResult(data, status, message) {
    var result = {};

    // 成功处理并返回
    if (!status) {
        result.data = data;
    } else {
        result.status = status;
        result.statusInfo = {
            message: message
        };
    }

    return result;
}
1101272
public function convertToPHPValue($value, AbstractPlatform $platform) : ?DateTime
    {
        if ($value === null || $value instanceof DateTime) {

            return $value;
        }

        if ( ! $this->getUtc() instanceof DateTimeZone) {

            $this->setUtc(new DateTimeZone('UTC'));
        }

        /** @var DateTime $converted */
        $converted = DateTime::createFromFormat(
            $platform->getDateTimeFormatString(),
            $value,
            $this->getUtc()
        );

        if ( ! $converted) {
            throw ConversionException::conversionFailedFormat(
                $value,
                $this->getName(),
                $platform->getDateTimeFormatString()
            );
        }

        return $converted;
    }
1174332
function parseUseragent(ua) {

		if (!ua) {
			return null;
		}

		let platform,
		    webview = false,
		    version,
		    engine,
		    result,
		    major,
		    minor,
		    patch,
		    float,
		    index,
		    name,
		    temp,
		    os;

		ua = ua.toLowerCase();

		if (~ua.indexOf('mobile')) {
			platform = 'mobile';
		} else if (~ua.indexOf('tablet')) {
			platform = 'tablet';
		} else {
			platform = 'desktop';
		}

		if (~(index = ua.indexOf('msie'))) {
			name = 'internet explorer';
			platform = 'desktop';
		} else if (~(index = ua.indexOf('trident/'))) {
			name = 'internet explorer';
			platform = 'desktop';
			index += 13;
		} else if (~(index = ua.indexOf('edge/'))) {
			name = 'edge';
			engine = 'edgehtml';
		} else if (~(index = ua.indexOf('chrome/'))) {
			name = 'chrome';
		} else if (~(index = ua.indexOf('firefox/'))) {
			name = 'firefox';
			engine = 'gecko';
		} else if (~(index = ua.indexOf('safari/'))) {
			name = 'safari';
			index = ua.indexOf('version/');
			engine = 'webkit';
		}

		if (~index) {
			version = version_rx.exec(ua.slice(index));

			if (version) {
				float = parseFloat(version[0]);
				major = +version[1];
				minor = +version[2];
				patch = version[3] || '';
			}
		}

		if (!engine) {
			switch (name) {
				case 'internet explorer':
					engine = 'trident';
					break;

				case 'chrome':
					if (major < 28) {
						engine = 'webkit';
					} else {
						engine = 'blink';
					}
					break;
			}
		}

		if (platform != 'desktop') {
			if (~ua.indexOf('iphone') || ~ua.indexOf('ipad') || ~ua.indexOf('ipod')) {
				os = 'ios';

				if (ua.indexOf('safari') == -1) {
					webview = true;
				}
			} else if (~ua.indexOf('; wv')) {
				webview = true;
			}
		}

		result = {
			family    : name,
			version   : {
				major : major,
				minor : minor,
				patch : patch,
				float : float
			},
			platform  : platform,
			engine    : engine,
			webview   : webview,
			os        : os
		};

		return result;
	}
1266375
function git_clone_platform(git_url, branch) {
    // Create a tmp dir. Using /tmp is a problem because it's often on a different partition and sehll.mv()
    // fails in this case with "EXDEV, cross-device link not permitted".
    var tmp_subidr = 'tmp_cordova_git_' + process.pid + '_' + (new Date()).valueOf();
    var tmp_dir = path.join(util.libDirectory, 'tmp', tmp_subidr);
    shell.rm('-rf', tmp_dir);
    shell.mkdir('-p', tmp_dir);

    return HooksRunner.fire('before_platform_clone', {
        repository: git_url,
        location: tmp_dir
    }).then(function () {
        var branchToCheckout = branch || 'master';
        return gitclone.clone(git_url, branchToCheckout, tmp_dir);
    }).then(function () {
        HooksRunner.fire('after_platform_clone', {
            repository: git_url,
            location: tmp_dir
        });
        return tmp_dir;
    }).fail(function (err) {
        shell.rm('-rf', tmp_dir);
        return Q.reject(err);
    });
}
155994
function parsePlatformFilePath(
  filePath: string,
  platforms: Set<string>,
): PlatformFilePathParts {
  const dirPath = path.dirname(filePath);
  const fileName = path.basename(filePath);
  const match = fileName.match(PATH_RE);
  if (!match) {
    return {dirPath, baseName: fileName, platform: null, extension: null};
  }
  const extension = match[4] || null;
  const platform = match[3] || null;
  if (platform == null || platforms.has(platform)) {
    return {dirPath, baseName: match[1], platform, extension};
  }
  const baseName = `${match[1]}.${platform}`;
  return {dirPath, baseName, platform: null, extension};
}
1002740
function(platform) {
        events.emit('verbose', 'Beginning processing of action stack for ' + platform + ' project...');

        while (this.stack.length) {
            var action = this.stack.shift();
            var handler = action.handler.run;
            var action_params = action.handler.params;

            try {
                handler.apply(null, action_params);
            } catch(e) {
                events.emit('warn', 'Error during processing of action! Attempting to revert...');
                this.stack.unshift(action);
                var issue = 'Uh oh!\n';
                // revert completed tasks
                while(this.completed.length) {
                    var undo = this.completed.shift();
                    var revert = undo.reverter.run;
                    var revert_params = undo.reverter.params;

                    try {
                        revert.apply(null, revert_params);
                    } catch(err) {
                        events.emit('warn', 'Error during reversion of action! We probably really messed up your project now, sorry! D:');
                        issue += 'A reversion action failed: ' + err.message + '\n';
                    }
                }
                e.message = issue + e.message;
                
                return Q.reject(e);
            }
            this.completed.push(action);
        }
        events.emit('verbose', 'Action stack processing complete.');

        return Q();
    }
728832
def platforms
      platforms = []

      platformListPrograms = getPlatformList["data"]["program"]

      if @programNumber.to_s =~ /\d+/
        platformListPrograms.select! {|p| p["programNumber"].to_i == @programNumber.to_i }
      end
      
      platformListPrograms.each do |program|
        if program.key?("platform") and not program["platform"].is_a?(Array)
          platforms << program["platform"]["platformId"].to_i
        else
          platforms  += program["platform"].map {|p| p["platformId"].to_i}
        end
      end
      platforms
    end
330170
function getUAPVersions (config) {
    var baselineVersions = MSBuildTools.getAvailableUAPVersions();
    if (!baselineVersions || baselineVersions.length === 0) {
        return false;
    }

    baselineVersions.sort(Version.comparer);

    var uapTargetMinPreference = config.getUAPTargetMinVersion();

    return {
        minUAPVersion: uapTargetMinPreference,
        targetUAPVersion: baselineVersions[baselineVersions.length - 1] /* The highest available SDK on the system */
    };
}
751771
def get_platform():
	""""""
	# Detect
	platform_str = platform.system()
	print 'Platform detected: {}'.format(platform_str)
	# Instantiate
	if platform_str == 'Windows':
		return WindowsPlatform()
	elif platform_str == 'Linux':
		return LinuxPlatform()
	else:
		raise NotImplementedError('This platform is not yet supported')
1128380
function getShortcuts(platform) {
  // if it is mac platform
  if (platform && platform.indexOf('mac') !== -1) {
    return [{ name: 'Toggle Search Box', keys: ['⌘ ⇧ P', '⌃ ⇧ P'] }, { name: 'Toggle Action Logger position', keys: ['⌘ ⇧ J', '⌃ ⇧ J'] }, { name: 'Toggle Fullscreen Mode', keys: ['⌘ ⇧ F', '⌃ ⇧ F'] }, { name: 'Toggle Left Panel', keys: ['⌘ ⇧ L', '⌃ ⇧ L'] }, { name: 'Toggle Down Panel', keys: ['⌘ ⇧ D', '⌃ ⇧ D'] }, { name: 'Next Story', keys: ['⌘ ⇧ →', '⌃ ⇧ →'] }, { name: 'Previous Story', keys: ['⌘ ⇧ ←', '⌃ ⇧ ←'] }];
  }

  return [{ name: 'Toggle Search Box', keys: ['Ctrl + Shift + P'] }, { name: 'Toggle Action Logger position', keys: ['Ctrl + Shift + J'] }, { name: 'Toggle Fullscreen Mode', keys: ['Ctrl + Shift + F'] }, { name: 'Toggle Left Panel', keys: ['Ctrl + Shift + L'] }, { name: 'Toggle Down Panel', keys: ['Ctrl + Shift + D'] }, { name: 'Next Story', keys: ['Ctrl + Shift + →'] }, { name: 'Previous Story', keys: ['Ctrl + Shift + ←'] }];
}
554965
function _Platform_initialize(
    flagDecoder,
    args,
    init,
    update,
    subscriptions,
    stepperBuilder
  ) {
    var result = A2(
      _Json_run,
      flagDecoder,
      _Json_wrap(args ? args["flags"] : undefined)
    );
    elm$core$Result$isOk(result) ||
      _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/);
    var managers = {};
    result = init(result.a);
    var model = result.a;
    var stepper = stepperBuilder(sendToApp, model);
    var ports = _Platform_setupEffects(managers, sendToApp);

    function sendToApp(msg, viewMetadata) {
      result = A2(update, msg, model);
      stepper((model = result.a), viewMetadata);
      _Platform_dispatchEffects(managers, result.b, subscriptions(model));
    }

    _Platform_dispatchEffects(managers, result.b, subscriptions(model));

    return ports ? { ports: ports } : {};
  }
1031636
public function addPlatform(Platform $platform)
    {
        if (!isset($this->platforms)) {
            $this->platforms = [];
        }

        $this->platforms[] = $platform;

        return $this;
    }