text:
/** \file reportReplvl.c
 *  \brief Report level implementation
 *
 *  \see reportReplvl.h
 */

/***************************************************************************/
/*																		   */
/*		MODULE:	reportReplvl.c											   */
/*    PURPOSE:	Report level implementation	 							   */
/*																		   */
/***************************************************************************/

#define __FILE_ID__  FILE_ID_88
#include "tidef.h"
#include "report.h"
#include "osApi.h"
#include "siteHash.h"
#include "rate.h"
#include "rsnApi.h"
#include "regulatoryDomainApi.h"
#include "siteMgrApi.h"
#include "TWDriver.h"
#include "StaCap.h"
#include "qosMngr_API.h"

/********************************************/
/*		Functions Implementation 			*/
/********************************************/

/************************************************************************
 *                        buildNullTemplate								*
 ************************************************************************
DESCRIPTION: This function build a NULL data template to set to the HAL
				when joining an infrastructure network
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure

OUTPUT:

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildNullTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
{
	paramInfo_t			param;
	nullDataTemplate_t	*pBuffer = (nullDataTemplate_t	*)pTemplate->ptr;
	siteEntry_t			*pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	TI_UINT16				fc;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(nullDataTemplate_t));

	/*
	 * Header First
	 */
	/* Set destination address */
	MAC_COPY (pBuffer->hdr.DA, pPrimarySite->bssid);

	/* Set BSSID address */
	MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);

	fc = DOT11_FC_DATA_NULL_FUNCTION;
	fc |= (TI_TRUE << DOT11_FC_TO_DS_SHIFT);

	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

	pTemplate->len = sizeof(dot11_mgmtHeader_t);
	return TI_OK;
}

/************************************************************************
 *                        buildDisconnTemplate								*
 ************************************************************************
DESCRIPTION: This function build a Death/Disassoc template to set to the HAL
				when joining an infrastructure network
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure

OUTPUT:

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildDisconnTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
{
	paramInfo_t			param;
	TI_UINT32				size;
	disconnTemplate_t	*pBuffer = (disconnTemplate_t	*)pTemplate->ptr;
	siteEntry_t			*pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	TI_UINT16				fc;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(disconnTemplate_t));

	/*
	 * Header First
	 */
	/* Set destination address */
	MAC_COPY (pBuffer->hdr.DA, pPrimarySite->bssid);

	/* Set BSSID address */
	MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);

	fc = DOT11_FC_DISASSOC; /* will be change by firmware to DOT11_FC_DEAUTH if needed */

	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

	pBuffer->disconnReason = 0; /* filled by firmware */

	size = sizeof(disconnTemplate_t);

	pTemplate->len = size;

	return TI_OK;
}

/**
 * \fn     setDefaultProbeReqTemplate
 * \brief  set Default Probe Req Template tp the FW.
 *
 * set Default Probe Req Template tp the FW.
 *
 * \param  hSiteMgr	-	Handle to site manager
 * \return None
 * \sa
 */
void setDefaultProbeReqTemplate (TI_HANDLE	hSiteMgr)
{
    siteMgr_t	*pSiteMgr = (siteMgr_t *)hSiteMgr;
    TSetTemplate        tTemplateStruct;
    probeReqTemplate_t  tProbeReqTemplate;
    TSsid               tBroadcastSSID;

    /*
     * Setting probe request temapltes for both bands.
     * allocating EMPTY 32 bytes for the SSID IE, to reserve space for different SSIDs the FW will set
     */
    tBroadcastSSID.len = MAX_SSID_LEN;
    os_memorySet (pSiteMgr->hOs, &(tBroadcastSSID.str[ 0 ]), 0, MAX_SSID_LEN);
    tTemplateStruct.ptr = (TI_UINT8 *)&tProbeReqTemplate;
    tTemplateStruct.type = PROBE_REQUEST_TEMPLATE;
    tTemplateStruct.eBand = RADIO_BAND_2_4_GHZ;
    tTemplateStruct.uRateMask = RATE_MASK_UNSPECIFIED;
    buildProbeReqTemplate (hSiteMgr, &tTemplateStruct, &tBroadcastSSID, RADIO_BAND_2_4_GHZ);
    TWD_CmdTemplate (pSiteMgr->hTWD, &tTemplateStruct, NULL, NULL);
    tTemplateStruct.eBand = RADIO_BAND_5_0_GHZ;
    buildProbeReqTemplate (hSiteMgr, &tTemplateStruct, &tBroadcastSSID, RADIO_BAND_5_0_GHZ);
    TWD_CmdTemplate (pSiteMgr->hTWD, &tTemplateStruct, NULL, NULL);
}

/************************************************************************
 *                        buildProbeReqTemplate							*
 ************************************************************************
DESCRIPTION: This function build a probe request template to set to the HAL in the scan process.
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure
			pSsid		-	Desired SSID

OUTPUT:

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildProbeReqTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate, TSsid *pSsid, ERadioBand radioBand)
{
	paramInfo_t			param;
	char				*pBuf;
	int i;
	probeReqTemplate_t	*pBuffer = (probeReqTemplate_t	*)pTemplate->ptr;
	TI_UINT32			 size;
	dot11_RATES_t		*pDot11Rates;
	TI_UINT32			 len = 0, ofdmIndex = 0;
	TI_UINT32			 suppRatesLen, extSuppRatesLen;
	TI_UINT8			 ratesBuf[DOT11_MAX_SUPPORTED_RATES];
#ifndef SUPPL_WPS_SUPPORT
	TI_UINT8             WSCOuiIe[DOT11_OUI_LEN] = { 0x00, 0x50, 0xf2, 0x04};
#endif
	TI_UINT32			 supportedRateMask,basicRateMask;
	TI_UINT16			 fc = DOT11_FC_PROBE_REQ;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeReqTemplate_t));

	/*
	 * Header First
	 */
	/* Set destination address */
	for (i = 0; i < MAC_ADDR_LEN; i++)
		pBuffer->hdr.DA[i] = 0xFF;

	/* Set BSSID address */

	for (i = 0; i < MAC_ADDR_LEN; i++)
		pBuffer->hdr.BSSID[i] = 0xFF;

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);

	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

	size = sizeof(dot11_mgmtHeader_t);
	pBuf = (char *)&(pBuffer->infoElements);

   /*
	* Informataion elements
	*/
	/* SSID */
    /* It looks like it never happens. Anyway decided to check */
    if ( pSsid->len > MAX_SSID_LEN )
    {
        TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
               "buildProbeReqTemplate. pSsid->len=%d exceeds the limit %d\n",
               pSsid->len, MAX_SSID_LEN);
        handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
        return TI_NOK;
    }
	((dot11_SSID_t *)(pBuf))->hdr[0] = DOT11_SSID_ELE_ID;
	((dot11_SSID_t *)(pBuf))->hdr[1] = pSsid->len;
	os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pSsid->str, pSsid->len);
	size += sizeof(dot11_eleHdr_t) + pSsid->len;
	pBuf += sizeof(dot11_eleHdr_t) + pSsid->len;

	/* Rates */
	pDot11Rates = (dot11_RATES_t *) pBuf;

    /*
     * Supported rates in probe request will always use the default rates for BG or A bands,
     * regardless of the STA desired rates.
     */
    if (radioBand == RADIO_BAND_2_4_GHZ)
	{
        /* Basic rates: 1,2,5.5,11 */
		basicRateMask = rate_BasicToDrvBitmap((EBasicRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_G_MODE]), TI_FALSE);
        /* Extended: 6,9,12,18,24,36,48,54 */
        supportedRateMask = rate_SupportedToDrvBitmap((ESupportedRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_G_MODE]), TI_FALSE);
    }
    else if (radioBand == RADIO_BAND_5_0_GHZ)
    {   /* Basic rates: 6,12,24 */
        basicRateMask = rate_BasicToDrvBitmap((EBasicRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_A_MODE]), TI_TRUE);
         /* Extended: 9,18,24,36,48,54 */
        supportedRateMask = rate_SupportedToDrvBitmap((ESupportedRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_A_MODE]), TI_TRUE);
	}
	else
	{
        TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "buildProbeReqTemplate, radioBand =%d ???\n",radioBand);
        /* Use default and pray for the best */
        /* Basic rates: 1,2,5.5,11 */
        basicRateMask = rate_BasicToDrvBitmap(BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
        /* Extended: 6,9,12,18,24,36,48,54 */
        supportedRateMask = rate_SupportedToDrvBitmap(SUPPORTED_RATE_SET_UP_TO_54, TI_FALSE);
	}

	rate_DrvBitmapToNetStr (supportedRateMask, basicRateMask, ratesBuf, &len, &ofdmIndex);

    TRACE5(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "buildProbeReqTemplate, supportedRateMask=0x%x, basicRateMask=0x%x, len=%d, ofdmIndex=%d, radioBand =%d\n",							 supportedRateMask,basicRateMask,len, ofdmIndex, radioBand);

    /* It looks like it never happens. Anyway decided to check */
    if ( len > DOT11_MAX_SUPPORTED_RATES )
    {
        TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
           "buildProbeReqTemplate. len=%d exceeds the limit %d\n",
               len, DOT11_MAX_SUPPORTED_RATES);
        handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
        return TI_NOK;
    }
    if(radioBand == RADIO_BAND_5_0_GHZ ||
       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
	   ofdmIndex == len)
	{
		pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = len;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
		size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
	}
	else
	{
		pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = ofdmIndex;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
		suppRatesLen = pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		pDot11Rates = (dot11_RATES_t *) (pBuf + suppRatesLen);
		pDot11Rates->hdr[0] = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = len - ofdmIndex;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr[1]);
		extSuppRatesLen = pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		size += suppRatesLen + extSuppRatesLen;
		pBuf += suppRatesLen + extSuppRatesLen;
	}

    /* add HT capabilities IE */
    StaCap_GetHtCapabilitiesIe (pSiteMgr->hStaCap, (TI_UINT8 *)pBuf, &len);
    size += len;
    pBuf += len;

#ifndef SUPPL_WPS_SUPPORT
    /* WiFi Simple Config */
    if (pSiteMgr->includeWSCinProbeReq && (pSiteMgr->siteMgrWSCCurrMode != TIWLN_SIMPLE_CONFIG_OFF))
    {
        ((dot11_WSC_t *)pBuf)->hdr[0] = DOT11_WSC_PARAM_ELE_ID;
        ((dot11_WSC_t *)pBuf)->hdr[1] = pSiteMgr->uWscIeSize + DOT11_OUI_LEN;
        pBuf += sizeof(dot11_eleHdr_t);
        os_memoryCopy(pSiteMgr->hOs, pBuf, &WSCOuiIe, DOT11_OUI_LEN);
        os_memoryCopy(pSiteMgr->hOs,
                      pBuf + DOT11_OUI_LEN,
                      &pSiteMgr->siteMgrWSCProbeReqParams,
                      pSiteMgr->uWscIeSize);
        size += sizeof(dot11_eleHdr_t) + pSiteMgr->uWscIeSize + DOT11_OUI_LEN;
        pBuf += sizeof(dot11_eleHdr_t) + pSiteMgr->uWscIeSize + DOT11_OUI_LEN;
    }
#endif /* SUPPL_WPS_SUPPORT */

	pTemplate->len = size;

	return TI_OK;
}

/************************************************************************
 *                        buildProbeRspTemplate							*
 ************************************************************************
DESCRIPTION: This function build a probe response template to set to the HAL
				when joining an IBSS network.
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr
				-	The template is built based on the chosen site attributes

			NOTE: This function is used to build beacon template too.
			The site manager set the template type (after thos function returns) to beacon or probe response accordingly.

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure

OUTPUT:

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildProbeRspTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
{
	paramInfo_t			param;
	TI_UINT8			*pBuf;
	probeRspTemplate_t	*pBuffer = (probeRspTemplate_t	*)pTemplate->ptr;
	siteEntry_t			*pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	TI_INT32			i, j;
	TI_UINT32			size;
	dot11_RATES_t		*pDot11Rates;
	dot11_ERP_t         *pdot11Erp;
	TI_UINT32			len = 0, ofdmIndex = 0;
	TI_BOOL				extRates = TI_FALSE;
	TI_BOOL             useProtection,NonErpPresent,barkerPreambleType;
	TCountry			*pCountry = NULL;
	TI_UINT8			ratesBuf[DOT11_MAX_SUPPORTED_RATES];
	TI_UINT32			supportedRateMask,basicRateMask;
	TI_UINT16			headerFC = DOT11_FC_PROBE_RESP;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeRspTemplate_t));

	/*
	 * Build WLAN Header:
	 * ==================
	 */

	/* Set destination address */
	for (i = 0; i < MAC_ADDR_LEN; i++)
		pBuffer->hdr.DA[i] = 0xFF;

	/* Set BSSID address */
	MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.SA, param.content.ctrlDataDeviceMacAddress);

    COPY_WLAN_WORD(&pBuffer->hdr.fc, &headerFC);

	size = sizeof(dot11_mgmtHeader_t);
	pBuf = (TI_UINT8 *)pBuffer->timeStamp;
   /*
	* Fixed Fields
	*/
	/* we skip the timestamp field */
	size += TIME_STAMP_LEN;
	pBuf += TIME_STAMP_LEN;

	/* Beacon interval */
    COPY_WLAN_WORD(pBuf, &pPrimarySite->beaconInterval);
	size += FIX_FIELD_LEN;
	pBuf += FIX_FIELD_LEN;

	/* capabilities */
    COPY_WLAN_WORD(pBuf, &pPrimarySite->capabilities);
	size += FIX_FIELD_LEN;
	pBuf += FIX_FIELD_LEN;

	/*
	 * Build Informataion Elements:
	 * ============================
	 */

	/* SSID IE */
    /* It looks like it never happens. Anyway decided to check */
    if ( pPrimarySite->ssid.len > MAX_SSID_LEN )
    {
        TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
               "buildProbeRspTemplate. pPrimarySite->ssid.len=%d exceeds the limit %d\n",
               pPrimarySite->ssid.len, MAX_SSID_LEN);
        handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
        return TI_NOK;
    }
	((dot11_SSID_t *)(pBuf))->hdr[0] = DOT11_SSID_ELE_ID;
	((dot11_SSID_t *)(pBuf))->hdr[1] = pPrimarySite->ssid.len;
	os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pPrimarySite->ssid.str, pPrimarySite->ssid.len);
	size += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;
	pBuf += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;

	/* Rates IE */

	pDot11Rates = (dot11_RATES_t *) pBuf;

	if (pPrimarySite->channel == SPECIAL_BG_CHANNEL)
	{
		supportedRateMask = rate_GetDrvBitmapForDefaultSupporteSet ();
		basicRateMask	  = rate_GetDrvBitmapForDefaultBasicSet ();
	}
	else
	{
		supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
		basicRateMask     = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
	}

	rate_DrvBitmapToNetStr (supportedRateMask, basicRateMask, ratesBuf, &len, &ofdmIndex);

    if(pSiteMgr->siteMgrOperationalMode != DOT11_G_MODE ||
       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
	   ofdmIndex == len)
	{
		pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = len;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
		size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
	}
	else
	{
		pDot11Rates->hdr[0] = DOT11_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = ofdmIndex;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr[1]);
		size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		extRates = TI_TRUE;
	}

	/* DS IE */
	((dot11_DS_PARAMS_t *)(pBuf))->hdr[0] = DOT11_DS_PARAMS_ELE_ID;
	((dot11_DS_PARAMS_t *)(pBuf))->hdr[1] = DOT11_DS_PARAMS_ELE_LEN;
	((dot11_DS_PARAMS_t *)(pBuf))->currChannel = pPrimarySite->channel;
	size += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;
	pBuf += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;

	/* IBSS IE */
	((dot11_IBSS_PARAMS_t *)(pBuf))->hdr[0] = DOT11_IBSS_PARAMS_ELE_ID;
	((dot11_IBSS_PARAMS_t *)(pBuf))->hdr[1] = DOT11_IBSS_PARAMS_ELE_LEN;
	COPY_WLAN_WORD(&((dot11_IBSS_PARAMS_t *)(pBuf))->atimWindow, &pPrimarySite->atimWindow);
	size += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;
	pBuf += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;

	/* Country IE */
	param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
	regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);

	if(	param.content.regulatoryDomainEnabled == TI_TRUE )
	{
        /* get country IE */
        param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
		regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain, &param);
		pCountry = param.content.pCountry;

        /* Check if a country IE was found */
		if(pCountry != NULL)
		{
			*pBuf = DOT11_COUNTRY_ELE_ID;
			pBuf++;
			size++;
			*pBuf = (TI_UINT8)(pCountry->len);
			pBuf++;
			size++;

			/* Note: The country structure is not byte-aligned so it is copied as follows to ensure
			           that there are no gaps in the output structure (pBuf). */

			os_memoryCopy(pSiteMgr->hOs, pBuf , &pCountry->countryIE.CountryString, DOT11_COUNTRY_STRING_LEN);
			pBuf += DOT11_COUNTRY_STRING_LEN;
			size += DOT11_COUNTRY_STRING_LEN;

			/* Loop on all tripletChannels. Each item has three fields ('i' counts rows and 'j' counts bytes). */
			for (i = 0, j = 0;  j < (pCountry->len - DOT11_COUNTRY_STRING_LEN);  i++, j+=3)
			{
				*(pBuf + j    ) = pCountry->countryIE.tripletChannels[i].firstChannelNumber;
				*(pBuf + j + 1) = pCountry->countryIE.tripletChannels[i].maxTxPowerLevel;
				*(pBuf + j + 2) = pCountry->countryIE.tripletChannels[i].numberOfChannels;
			}

			pBuf += (pCountry->len - DOT11_COUNTRY_STRING_LEN);
			size += (pCountry->len - DOT11_COUNTRY_STRING_LEN);
		}
	}

	/*ERP IE*/
	siteMgr_IsERP_Needed(pSiteMgr,&useProtection,&NonErpPresent,&barkerPreambleType);
	if (useProtection || NonErpPresent || barkerPreambleType)
	{
		pdot11Erp = (dot11_ERP_t *) pBuf;
		pdot11Erp->hdr[0] = DOT11_ERP_IE_ID;
		pdot11Erp->hdr[1] = 1;
		pdot11Erp->ctrl = 0;
		if (NonErpPresent)
			pdot11Erp->ctrl |= ERP_IE_NON_ERP_PRESENT_MASK;
		if (useProtection)
			pdot11Erp->ctrl |= ERP_IE_USE_PROTECTION_MASK;
		if (barkerPreambleType)
			pdot11Erp->ctrl |= ERP_IE_BARKER_PREAMBLE_MODE_MASK;
		size += pdot11Erp->hdr[1] + sizeof(dot11_eleHdr_t);
		pBuf += pdot11Erp->hdr[1] + sizeof(dot11_eleHdr_t);

	}

	/* Extended supported rates IE */
	if(extRates)
	{
		pDot11Rates = (dot11_RATES_t *) pBuf;
		pDot11Rates->hdr[0] = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
		pDot11Rates->hdr[1] = len - ofdmIndex;
		os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr[1]);
		size += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
		pBuf += pDot11Rates->hdr[1] + sizeof(dot11_eleHdr_t);
	}

    /* no need to insert RSN information elements */

	pTemplate->len = size;
TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Probe response template len = %d\n",size);

	return TI_OK;
}

/************************************************************************
 *                        buildPsPollTemplate							*
 ************************************************************************
DESCRIPTION: This function build a ps poll template
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure
			pSsid		-	Desired SSID

OUTPUT:

RETURN:     TI_OK
************************************************************************/
TI_STATUS buildPsPollTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate)
{
    paramInfo_t			param;
    TTwdParamInfo       tTwdParam;
	TI_UINT32				size;
	psPollTemplate_t	*pBuffer = (psPollTemplate_t *)pTemplate->ptr;
	siteEntry_t			*pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	TI_UINT16				fc;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(psPollTemplate_t));

	/*
	 * Header First
	 */

	/* Set BSSID address */
	MAC_COPY (pBuffer->hdr.BSSID, pPrimarySite->bssid);

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.TA, param.content.ctrlDataDeviceMacAddress);

    /*
    **   Building the Frame Control word (16 bits)
    ** ---------------------------------------------
    ** Type = Control
    ** SubType = Power Save (PS) POLL,  */
    fc = DOT11_FC_PS_POLL;
    /*
    ** setting the Power Management bit in the Frame control field
    ** to be "Power Save mode"
    */
    fc |= (0x1 << DOT11_FC_PWR_MGMT_SHIFT);

	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

    /*
    **   Association ID
    ** -----------------
    */
    tTwdParam.paramType = TWD_AID_PARAM_ID;
    TWD_GetParam (pSiteMgr->hTWD, &tTwdParam);

    /* AID should have its two MSB bit Set to "1"*/
    pBuffer->hdr.AID = tTwdParam.content.halCtrlAid | 0xC000;

	size = sizeof(dot11_PsPollFrameHeader_t);

	pTemplate->len = size;

	return TI_OK;
}

/************************************************************************
 *                        buildQosNullDataTemplate							*
 ************************************************************************
DESCRIPTION: This function build a qos null data template
				performs the following:
				-	Build a template & set the template len, the template type is set in the site mgr

INPUT:      pSiteMgr	-	Handle to site manager
			pTemplate	-	Pointer to the template structure
			pSsid		-	Desired SSID

OUTPUT:

RETURN:     TI_OK
************************************************************************/
TI_STATUS buildQosNullDataTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate, TI_UINT8 userPriority)
{
	paramInfo_t			param;
	TI_UINT32				size;
	QosNullDataTemplate_t	*pBuffer = (QosNullDataTemplate_t	*)pTemplate->ptr;
	siteEntry_t			*pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	TI_UINT16				fc;
	TI_UINT16				qosControl;

	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(QosNullDataTemplate_t));

	/*
	 * Header First
	 */
	/* Set destination address */
    if (pPrimarySite)
    {
	  MAC_COPY (pBuffer->hdr.address1, pPrimarySite->bssid);

	  /* Set BSSID address */
	  MAC_COPY (pBuffer->hdr.address3, pPrimarySite->bssid);
    }
    else
    {
TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "No Primary site so cannot fill QosNullData template\n");
    }

	/* Build Source address */
	param.paramType = CTRL_DATA_MAC_ADDRESS;
	ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.address2, param.content.ctrlDataDeviceMacAddress);

	fc = DOT11_FC_DATA_NULL_QOS | (1 << DOT11_FC_TO_DS_SHIFT);
	COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

    qosControl = (TI_UINT16)userPriority;
	qosControl <<= QOS_CONTROL_UP_SHIFT;
	COPY_WLAN_WORD(&pBuffer->hdr.qosControl, &qosControl); /* copy with endianess handling. */

	size = WLAN_QOS_HDR_LEN;

	pTemplate->len = size;

	return TI_OK;
}

/************************************************************************
 *                        buildArpRspTemplate							*
 ************************************************************************
DESCRIPTION: This function builds an ARP Response template to set to
			 the HAL when joining an infrastructure network.

             The function's steps:
             - It builds the template & set the template len.
             - If QoS is inactive, it discards the QoS Control Field.
             ** The template type is set in the site mgr.

INPUT:       pSiteMgr  - Handle to site manager.
			 pTemplate - Pointer to the template structure.

OUTPUT:

RETURN:     TI_OK

************************************************************************/
TI_STATUS buildArpRspTemplate(siteMgr_t *pSiteMgr, TSetTemplate *pTemplate, TIpAddr staIp)
{
	siteEntry_t		   *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
	ArpRspTemplate_t   *pBuffer      = (ArpRspTemplate_t *)pTemplate->ptr;
	TI_UINT8           *ptr          = (TI_UINT8 *)pBuffer;

	paramInfo_t         param;          /* To get Site and QoS params */
	TI_UINT16           fc;             /* Frame Control field in MAC header */
	TI_UINT16           macAddrItr;
	TI_BOOL   			privacyInvoked;
	TI_UINT8  			encryptionFieldSize, copyPayloadOffset, lenToCopy;

	/* Reset the buffer */
	os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(ArpRspTemplate_t));

	/* Turn on the To_DS bit in the Frame Control field */
	fc = (1 << DOT11_FC_TO_DS_SHIFT);

    /* Set MAC header address fields:
		-----------------------------
		Since To_DS is on and From_DS is off the address meaning is as follows:
		Address1 - BSSID
		Address2 - Source Address
		Address3 - Destination Address
		Address4 - Not present */

	/* - Set BSSID */
    if (pPrimarySite)
	{
		MAC_COPY (pBuffer->hdr.address1, pPrimarySite->bssid);
	}
	else
	{
		TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "No Primary site so cannot fill QosNullData template.\n");
	}
    /* - Set Source Address */
    param.paramType = CTRL_DATA_MAC_ADDRESS;
    ctrlData_getParam(pSiteMgr->hCtrlData, &param);
	MAC_COPY (pBuffer->hdr.address2, param.content.ctrlDataDeviceMacAddress);
	/* - Set Destination Address: ARP response should be sent with broadcast DA - Set accordingly */
	for (macAddrItr = 0; macAddrItr < MAC_ADDR_LEN; macAddrItr++)
    {
        pBuffer->hdr.address3[macAddrItr] = 0xFF;
    }

    pBuffer->LLC.DSAP    = 0xaa;
    pBuffer->LLC.SSAP    = 0xaa;
    pBuffer->LLC.Control = 0x03;

	/* pBuffer->LLC.Control.OUI these 3 bytes are zeroed already */
    pBuffer->LLC.Type = WLANTOHS((TI_UINT16)0x806);
    pBuffer->hardType = WLANTOHS((TI_UINT16)1);
    pBuffer->protType = WLANTOHS((TI_UINT16)0x800);
    pBuffer->hardSize = 6;
    pBuffer->protSize = 4;
    pBuffer->op       = WLANTOHS((TI_UINT16)2); /*filled as for ARP-RSP, not for RARP_RSP */

	MAC_COPY(pBuffer->StaMac, pBuffer->hdr.address2);
    IP_COPY(pBuffer->StaIp, staIp);

    pTemplate->len = sizeof(ArpRspTemplate_t);

	/* Get encryption status */
    txCtrlParams_getCurrentEncryptionInfo (pSiteMgr->hTxCtrl,  &privacyInvoked, &encryptionFieldSize);

    /* If no encryption is used, encryptionFieldSize has garbage value */
    encryptionFieldSize = privacyInvoked ? encryptionFieldSize : 0;

	/* Set the subtype field of fc with WEP_BIT */
	fc |= (privacyInvoked << DOT11_FC_WEP_SHIFT);

    /* Get QoS type to check if QoS is active */
    param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
    qosMngr_getParams(pSiteMgr->hQosMngr, &param);

    if(param.content.qosSiteProtocol == QOS_NONE)   /* QoS is not active */
    {
		copyPayloadOffset = sizeof(pBuffer->hdr.qosControl) + AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize;
        /* Set the subtype field of fc with DATA value (non Qos) */
        fc |= DOT11_FC_DATA;
    }
    else    /* QoS is active */
    {
		copyPayloadOffset = AES_AFTER_HEADER_FIELD_SIZE - encryptionFieldSize;
        /* Set the subtype field of fc with DATA_QOS */
        fc |= DOT11_FC_DATA_QOS;
    }

    /* Need to copy backward to overwrite security or QoS offset */
    if (copyPayloadOffset > 0)
    {
		ptr = (TI_UINT8 *)&pBuffer->LLC.DSAP;
        /* Copy back the actual payload without header & security */
        lenToCopy = sizeof(ArpRspTemplate_t) - sizeof(dot11_header_t) - AES_AFTER_HEADER_FIELD_SIZE;

        os_memoryCopy(pSiteMgr->hOs, ptr - copyPayloadOffset, ptr, lenToCopy);
        pTemplate->len -= copyPayloadOffset;
    }

    COPY_WLAN_WORD(&pBuffer->hdr.fc, &fc); /* copy with endianess handling. */

	return TI_OK;
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Scripta Mycol. , Tartu 20: 104 (2004)

#### Original name
Albotricha lupini Svrcek

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Phunkie\Cats;

interface Foldable
{
    public function foldLeft($initial); // curry -> (callable $f);
    public function foldRight($initial); // curry -> (callable $f);
    public function foldMap(callable $f);
    public function fold($initial);
}


text:
package bus

import (
	"crypto/tls"
	"sync"
	"testing"
	"time"
)

func TestEmitter(t *testing.T) {
	t.Parallel()

	tests := []struct {
		scenario string
		function func(*testing.T)
	}{
		{
			"create new emitter",
			testNewEmitter,
		},
		{
			"emit message",
			testEmitMessage,
		},
		{
			"emit async message",
			testEmitAsyncMessage,
		},
		{
			"request message",
			testRequestMessage,
		},
	}

	for _, test := range tests {
		t.Run(test.scenario, func(t *testing.T) {
			test.function(t)
		})
	}
}

func testNewEmitter(t *testing.T) {
	_, err := NewEmitter(EmitterConfig{
		Address:                 "localhost:4150",
		DialTimeout:             time.Second * 5,
		ReadTimeout:             time.Second * 5,
		WriteTimeout:            time.Second * 5,
		LocalAddr:               &localAddrMock{},
		LookupdPollInterval:     time.Second * 5,
		LookupdPollJitter:       1,
		MaxRequeueDelay:         time.Second * 5,
		DefaultRequeueDelay:     time.Second * 5,
		BackoffStrategy:         &backoffStrategyMock{},
		MaxBackoffDuration:      time.Second * 5,
		BackoffMultiplier:       time.Second * 5,
		MaxAttempts:             5,
		LowRdyIdleTimeout:       time.Second * 5,
		RDYRedistributeInterval: time.Second * 5,
		ClientID:                "foo",
		Hostname:                "foo",
		UserAgent:               "foo",
		HeartbeatInterval:       time.Second * 5,
		SampleRate:              10,
		TLSV1:                   true,
		TLSConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
		Deflate:             true,
		DeflateLevel:        1,
		Snappy:              true,
		OutputBufferSize:    1,
		OutputBufferTimeout: time.Second * 5,
		MaxInFlight:         1,
		MsgTimeout:          time.Second * 5,
		AuthSecret:          "foo",
	})

	if err != nil {
		t.Fatalf("expected to initialize emitter %v", err)
	}
}

func testEmitMessage(t *testing.T) {
	emitter, err := NewEmitter(EmitterConfig{})
	if err != nil {
		t.Fatalf("expected to initialize emitter %v", err)
	}

	type event struct{ Name string }
	e := event{"event"}
	if err := emitter.Emit("etopic", &e); err != nil {
		t.Fatalf("expected to emit message %v", err)
	}

	if err := emitter.Emit("", &e); err != ErrTopicRequired {
		t.Fatalf("unexpected error value %v", err)
	}
}

func testEmitAsyncMessage(t *testing.T) {
	emitter, err := NewEmitter(EmitterConfig{})
	if err != nil {
		t.Fatalf("expected to initialize emitter %v", err)
	}

	type event struct{ Name string }
	e := event{"event"}
	if err := emitter.EmitAsync("etopic", &e); err != nil {
		t.Fatalf("expected to emit message %v", err)
	}

	if err := emitter.Emit("", &e); err != ErrTopicRequired {
		t.Fatalf("unexpected error value %v", err)
	}
}

func testRequestMessage(t *testing.T) {
	emitter, err := NewEmitter(EmitterConfig{})
	if err != nil {
		t.Fatalf("expected to initialize emitter %v", err)
	}

	type event struct{ Name string }

	var wg sync.WaitGroup
	wg.Add(1)
	replyHandler := func(message *Message) (reply interface{}, err error) {
		defer wg.Done()
		e := event{}
		if err = message.DecodePayload(&e); err != nil {
			t.Errorf("Expected to unmarshal payload")
		}
		if e.Name != "event_reply" {
			t.Errorf("Expected name to be equal event %s", e.Name)
		}
		message.Finish()
		return
	}

	handler := func(message *Message) (reply interface{}, err error) {
		e := event{}
		if err = message.DecodePayload(&e); err != nil {
			t.Errorf("Expected to unmarshal payload")
		}
		reply = &event{"event_reply"}
		message.Finish()
		return
	}

	if err := On(ListenerConfig{
		Topic:       "etopic",
		Channel:     "test_request",
		HandlerFunc: handler,
	}); err != nil {
		t.Fatalf("expected to listen a message %v", err)
	}

	cases := []struct {
		topic   string
		event   event
		replyh  func(message *Message) (interface{}, error)
		wantErr bool
	}{
		{
			"etopic", event{"event"}, replyHandler, true,
		},
		{
			"", event{"event"}, replyHandler, false,
		},
		{
			"etopic", event{"event"}, nil, false,
		},
	}

	for _, c := range cases {
		if c.wantErr {
			if err := emitter.Request(c.topic, c.event, c.replyh); err != nil {
				t.Errorf("expected to request a message %v", err)
			}
		} else {
			if err := emitter.Request(c.topic, c.event, c.replyh); err == nil {
				t.Errorf("unexpected error value %v", err)
			}
		}
	}

	wg.Wait()
}

type localAddrMock struct{}

func (a *localAddrMock) Network() (s string) { return }
func (a *localAddrMock) String() (s string)  { return }

type backoffStrategyMock struct{}

func (b *backoffStrategyMock) Calculate(attempt int) (v time.Duration) { return }


text:
using System;
using ChartDirector;

namespace CSharpChartExplorer
{
    public class stackradar : DemoModule
    {
        //Name of demo module
        public string getName() { return "Stacked Radar Chart"; }

        //Number of charts produced in this demo module
        public int getNoOfCharts() { return 1; }

        //Main code for creating chart.
        //Note: the argument chartIndex is unused because this demo only has 1 chart.
        public void createChart(WinChartViewer viewer, int chartIndex)
        {
            // The data for the chart
            double[] data0 = {100, 100, 100, 100, 100};
            double[] data1 = {90, 85, 85, 80, 70};
            double[] data2 = {80, 65, 65, 75, 45};

            // The labels for the chart
            string[] labels = {"Population<*br*><*font=Arial*>6 millions",
                "GDP<*br*><*font=Arial*>120 billions", "Export<*br*><*font=Arial*>25 billions",
                "Import<*br*><*font=Arial*>24 billions",
                "Investments<*br*><*font=Arial*>20 billions"};

            // Create a PolarChart object of size 480 x 460 pixels. Set background color to silver,
            // with 1 pixel 3D border effect
            PolarChart c = new PolarChart(480, 460, Chart.silverColor(), 0x000000, 1);

            // Add a title to the chart using 15pt Times Bold Italic font. The title text is white
            // (ffffff) on a deep green (008000) background
            c.addTitle("Economic Growth", "Times New Roman Bold Italic", 15, 0xffffff
                ).setBackground(0x008000);

            // Set plot area center at (240, 270), with 150 pixels radius
            c.setPlotArea(240, 270, 150);

            // Use 1 pixel width semi-transparent black (c0000000) lines as grid lines
            c.setGridColor(unchecked((int)0xc0000000), 1, unchecked((int)0xc0000000), 1);

            // Add a legend box at top-center of plot area (240, 35) using horizontal layout. Use
            // 10pt Arial Bold font, with silver background and 1 pixel 3D border effect.
            LegendBox b = c.addLegend(240, 35, false, "Arial Bold", 10);
            b.setAlignment(Chart.TopCenter);
            b.setBackground(Chart.silverColor(), Chart.Transparent, 1);

            // Add area layers of different colors to represent the data
            c.addAreaLayer(data0, 0xcc8880, "Year 2004");
            c.addAreaLayer(data1, 0xffd080, "Year 1994");
            c.addAreaLayer(data2, 0xa0bce0, "Year 1984");

            // Set the labels to the angular axis as spokes.
            c.angularAxis().setLabels(labels);

            // Set radial axis from 0 - 100 with a tick every 20 units
            c.radialAxis().setLinearScale(0, 100, 20);

            // Just show the radial axis as a grid line. Hide the axis labels by setting the label
            // color to Transparent
            c.radialAxis().setColors(unchecked((int)0xc0000000), Chart.Transparent);

            // Output the chart
            viewer.Chart = c;

            //include tool tip for the chart
            viewer.ImageMap = c.getHTMLImageMap("clickable", "",
                "title='Current {label}: {value}% in {dataSetName}'");
        }
    }
}


text:
module("forge.barcode");

if (forge.is.mobile()) {
	asyncTest("Scan barcode", 1, function() {
		askQuestion("Does this device have a camera? If yes when prompted scan a barcode?", {
			Yes: function () {
				forge.barcode.scanWithFormat(function (barcode) {
					askQuestion("Is this your barcode: "+barcode.value+" and was it a: "+barcode.format, {
						Yes: function () {
							ok(true, "User claims success");
							start();
						},
						No: function () {
							ok(false, "User claims failure");
							start();
						}
					});
				}, function (e) {
					ok(false, "API call failure: "+e.message);
					start();
				});
			},
			No: function () {
				ok(true, "No camera");
				start();
			}
		});
	});
}


text:
#include "fsl_pit.h"

/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID
#define FSL_COMPONENT_ID "platform.drivers.pit"
#endif

/*******************************************************************************
 * Prototypes
 ******************************************************************************/
/*!
 * @brief Gets the instance from the base address to be used to gate or ungate the module clock
 *
 * @param base PIT peripheral base address
 *
 * @return The PIT instance
 */
static uint32_t PIT_GetInstance(PIT_Type *base);

/*******************************************************************************
 * Variables
 ******************************************************************************/
/*! @brief Pointers to PIT bases for each instance. */
static PIT_Type *const s_pitBases[] = PIT_BASE_PTRS;

#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/*! @brief Pointers to PIT clocks for each instance. */
static const clock_ip_name_t s_pitClocks[] = PIT_CLOCKS;
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */

/*******************************************************************************
 * Code
 ******************************************************************************/
static uint32_t PIT_GetInstance(PIT_Type *base)
{
    uint32_t instance;

    /* Find the instance index from base address mappings. */
    for (instance = 0; instance < ARRAY_SIZE(s_pitBases); instance++)
    {
        if (s_pitBases[instance] == base)
        {
            break;
        }
    }

    assert(instance < ARRAY_SIZE(s_pitBases));

    return instance;
}

void PIT_Init(PIT_Type *base, const pit_config_t *config)
{
    assert(config);

#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
    /* Ungate the PIT clock*/
    CLOCK_EnableClock(s_pitClocks[PIT_GetInstance(base)]);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */

#if defined(FSL_FEATURE_PIT_HAS_MDIS) && FSL_FEATURE_PIT_HAS_MDIS
    /* Enable PIT timers */
    base->MCR &= ~PIT_MCR_MDIS_MASK;
#endif
    /* Config timer operation when in debug mode */
    if (config->enableRunInDebug)
    {
        base->MCR &= ~PIT_MCR_FRZ_MASK;
    }
    else
    {
        base->MCR |= PIT_MCR_FRZ_MASK;
    }
}

void PIT_Deinit(PIT_Type *base)
{
#if defined(FSL_FEATURE_PIT_HAS_MDIS) && FSL_FEATURE_PIT_HAS_MDIS
    /* Disable PIT timers */
    base->MCR |= PIT_MCR_MDIS_MASK;
#endif

#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
    /* Gate the PIT clock*/
    CLOCK_DisableClock(s_pitClocks[PIT_GetInstance(base)]);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
}

#if defined(FSL_FEATURE_PIT_HAS_LIFETIME_TIMER) && FSL_FEATURE_PIT_HAS_LIFETIME_TIMER

uint64_t PIT_GetLifetimeTimerCount(PIT_Type *base)
{
    uint32_t valueH = 0U;
    uint32_t valueL = 0U;

    /* LTMR64H should be read before LTMR64L */
    valueH = base->LTMR64H;
    valueL = base->LTMR64L;

    return (((uint64_t)valueH << 32U) + (uint64_t)(valueL));
}

#endif /* FSL_FEATURE_PIT_HAS_LIFETIME_TIMER */


text:
package com.linecorp.armeria.common;

import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;

import com.linecorp.armeria.common.annotation.Nullable;

/**
 * Default {@link RpcRequest} implementation.
 */
final class DefaultRpcRequest implements RpcRequest {

    static final List<Object> SINGLE_NULL_PARAM = Collections.singletonList(null);

    private final Class<?> serviceType;
    @Nullable
    private final String serviceName;
    private final String method;
    private final List<Object> params;

    DefaultRpcRequest(Class<?> serviceType, @Nullable String serviceName, String method, Iterable<?> params) {
        this(serviceType, serviceName, method, copyParams(params));
    }

    DefaultRpcRequest(Class<?> serviceType, @Nullable String serviceName, String method, Object... params) {
        this(serviceType, serviceName, method, copyParams(params));
    }

    private DefaultRpcRequest(Class<?> serviceType, @Nullable String serviceName, String method,
                              List<Object> params) {
        this.serviceType = requireNonNull(serviceType, "serviceType");
        this.serviceName = serviceName;
        this.method = requireNonNull(method, "method");
        this.params = params;
    }

    private static List<Object> copyParams(Iterable<?> params) {
        requireNonNull(params, "params");
        if (params == SINGLE_NULL_PARAM || params instanceof ImmutableList) {
            //noinspection unchecked
            return (List<Object>) params;
        }

        // Note we do not use ImmutableList.copyOf() here,
        // because it does not allow a null element and we should allow a null argument.
        final List<Object> copy;
        if (params instanceof Collection) {
            copy = new ArrayList<>(((Collection<?>) params).size());
        } else {
            copy = new ArrayList<>(8);
        }

        for (Object p : params) {
            copy.add(p);
        }

        return Collections.unmodifiableList(copy);
    }

    private static List<Object> copyParams(Object... params) {
        if (params.length == 0) {
            return ImmutableList.of();
        }

        final List<Object> copy = new ArrayList<>(params.length);
        Collections.addAll(copy, params);
        return Collections.unmodifiableList(copy);
    }

    @Override
    public Class<?> serviceType() {
        return serviceType;
    }

    @Override
    public String serviceName() {
        if (serviceName != null) {
            return serviceName;
        } else {
            return serviceType.getName();
        }
    }

    @Override
    public String method() {
        return method;
    }

    @Override
    public List<Object> params() {
        return params;
    }

    @Override
    public int hashCode() {
        return method().hashCode() * 31 + params().hashCode();
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof RpcRequest)) {
            return false;
        }

        final RpcRequest that = (RpcRequest) obj;
        return method().equals(that.method()) &&
               params().equals(that.params());
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                          .add("serviceType", simpleServiceName())
                          .add("serviceName", serviceName())
                          .add("method", method())
                          .add("params", params()).toString();
    }

    /**
     * Returns the simplified name of the {@link #serviceType()}.
     */
    private String simpleServiceName() {
        final Class<?> serviceType = serviceType();
        final String fqcn = serviceType.getName();
        final int lastDot = fqcn.lastIndexOf('.');
        return lastDot < 0 ? fqcn : fqcn.substring(lastDot + 1);
    }
}


text:
class Subject < ApplicationRecord

  scope :visible, lambda { where(:visible => true) }
  scope :invisible, lambda { where(:visible => false) }
  scope :sorted, lambda { order("position ASC") }
  scope :newest_first, lambda { order("created_at DESC") }
  scope :search, lambda {|query| where(["name LIKE ?", "%#{query}%"]) }

end


text:
package io.ebean.mocker.backgroundexecutor;

import io.ebean.BackgroundExecutor;

import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
 * Implementation that ignores execution requests.
 * <p>
 * In the case of running tests usually you want the background task
 * to bulkUpdate immediately or not at all.
 */
public class IgnoreBackgroundExecutor implements BackgroundExecutor {

  @Override
  public void execute(Runnable r) {
    // just ignore
  }

  @Override
  public void executePeriodically(Runnable r, long delay, TimeUnit unit) {
    // just ignore
  }

  @Override
  public void executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit) {
    // just ignore
  }

  @Override
  public ScheduledFuture<?> schedule(Runnable r, long delay, TimeUnit unit) {
    return null;
  }

  @Override
  public <V> ScheduledFuture<V> schedule(Callable<V> c, long delay, TimeUnit unit) {
    return null;
  }

}


text:
package com.netflix.atlas.json

import com.fasterxml.jackson.annotation.JsonAlias
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.exc.ValueInstantiationException
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import munit.FunSuite

class CaseClassDeserializerSuite extends FunSuite {

  import CaseClassDeserializerSuite._

  private val mapper = new ObjectMapper()
    .registerModule(DefaultScalaModule)

  def decode[T: Manifest](json: String): T = {
    mapper.readValue[T](json, Reflection.typeReference[T])
  }

  test("read simple object") {
    val expected = SimpleObject(123, "abc", Some("def"))
    val actual = decode[SimpleObject]("""{"foo": 123, "bar": "abc", "baz": "def"}""")
    assertEquals(actual, expected)
  }

  test("read array") {
    intercept[JsonMappingException] {
      decode[SimpleObject]("""[]""")
    }
  }

  test("read int") {
    intercept[JsonMappingException] {
      decode[SimpleObject]("""42""")
    }
  }

  test("invalid type for field (quoted number)") {
    val expected = SimpleObject(123, "abc", Some("def"))
    val actual = decode[SimpleObject]("""{"foo": "123", "bar": "abc", "baz": "def"}""")
    assertEquals(actual, expected)
  }

  test("invalid type for field (invalid number)") {
    intercept[JsonMappingException] {
      decode[SimpleObject]("""{"foo": "that", "bar": "abc", "baz": "def"}""")
    }
  }

  test("read simple object missing Option") {
    val expected = SimpleObject(42, "abc", None)
    val actual = decode[SimpleObject]("""{"foo": 42, "bar": "abc"}""")
    assertEquals(actual, expected)
  }

  test("read simple object missing required") {
    val expected = SimpleObject(123, null, Some("def"))
    val actual = decode[SimpleObject]("""{"foo": 123, "baz": "def"}""")
    assertEquals(actual, expected)
  }

  test("read simple object with defaults") {
    val expected = SimpleObjectWithDefaults()
    val actual = decode[SimpleObjectWithDefaults]("""{}""")
    assertEquals(actual, expected)
  }

  test("read simple object with overridden defaults") {
    val expected = SimpleObjectWithDefaults(foo = 21)
    val actual = decode[SimpleObjectWithDefaults]("""{"foo": 21}""")
    assertEquals(actual, expected)
  }

  test("read simple object with one default") {
    val expected = SimpleObjectWithOneDefault(21)
    val actual = decode[SimpleObjectWithOneDefault]("""{"foo": 21}""")
    assertEquals(actual, expected)
  }

  test("read simple object with one default missing required") {
    val expected = SimpleObjectWithOneDefault(0)
    val actual = decode[SimpleObjectWithOneDefault]("""{}""")
    assertEquals(actual, expected)
  }

  test("read simple object with validation") {
    val expected = SimpleObjectWithValidation("abc")
    val actual = decode[SimpleObjectWithValidation]("""{"foo": "abc"}""")
    assertEquals(actual, expected)
  }

  test("read simple object with error") {
    intercept[ValueInstantiationException] {
      decode[SimpleObjectUnknownError]("""{"foo": "abc"}""")
    }
  }

  test("read with Option[Int] field") {
    val expected = OptionInt(Some(42))
    val actual = decode[OptionInt]("""{"v":42}""")
    assertEquals(actual, expected)
  }

  test("read with Option[Int] field, null") {
    val expected = OptionInt(None)
    val actual = decode[OptionInt]("""{"v":null}""")
    assertEquals(actual, expected)
  }

  test("read with Option[Long] field") {
    val expected = OptionLong(Some(42L))
    val actual = decode[OptionLong]("""{"v":42}""")
    assertEquals(actual, expected)
  }

  test("read with List[Option[Int]] field") {
    val expected = ListOptionInt(List(Some(42), Some(21)))
    val actual = decode[ListOptionInt]("""{"v":[42, 21]}""")
    assertEquals(actual, expected)
  }

  test("read with List[String] field") {
    val expected = ListString(List("a", "b"))
    val actual = decode[ListString]("""{"vs":["a", "b"]}""")
    assertEquals(actual, expected)
  }

  test("read with List[String] field, null") {
    val expected = ListString(null)
    val actual = decode[ListString]("""{"vs":null}""")
    assertEquals(actual, expected)
  }

  test("read with List[String] field, with default, null") {
    val expected = ListStringDflt()
    val actual = decode[ListStringDflt]("""{"vs":null}""")
    assertEquals(actual, expected)
  }

  test("generics") {
    val expected = Outer(List(List(Inner("a"), Inner("b")), List(Inner("c"))))
    val actual = decode[Outer]("""{"vs":[[{"v":"a"},{"v":"b"}],[{"v":"c"}]]}""")
    assertEquals(actual, expected)
  }

  test("generics 2") {
    val expected = OuterT(List(List(Inner("a"), Inner("b")), List(Inner("c"))))
    val actual =
      decode[OuterT[List[List[Inner]]]]("""{"vs":[[{"v":"a"},{"v":"b"}],[{"v":"c"}]]}""")
    assertEquals(actual, expected)
  }

  test("honors @JsonAlias annotation") {
    val expected = AliasAnno("foo")
    val actual = decode[AliasAnno]("""{"v":"foo"}""")
    assertEquals(actual, expected)
  }

  test("honors @JsonProperty annotation") {
    val expected = PropAnno("foo")
    val actual = decode[PropAnno]("""{"v":"foo"}""")
    assertEquals(actual, expected)
  }

  test("honors @JsonDeserialize.contentAs annotation") {
    val expected = DeserAnno(Some(42L))
    val actual = decode[DeserAnno]("""{"value":42}""")
    assertEquals(actual, expected)
    // Line above will pass even if a java.lang.Integer is created. The
    // check below will fail with:
    // java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
    assertEquals(actual.value.get.asInstanceOf[java.lang.Long], java.lang.Long.valueOf(42L))
  }

  test("honors @JsonDeserialize.using annotation") {
    val expected = DeserUsingAnno(43L)
    val actual = decode[DeserUsingAnno]("""{"value":42}""")
    assertEquals(actual, expected)
  }
}

object CaseClassDeserializerSuite {

  case class SimpleObject(foo: Int, bar: String, baz: Option[String])

  case class SimpleObjectWithDefaults(foo: Int = 42, bar: String = "abc")

  case class SimpleObjectWithOneDefault(foo: Int, bar: String = "abc")

  case class SimpleObjectWithValidation(foo: String) {
    require(foo != null)
  }

  case class SimpleObjectUnknownError(foo: String) {
    throw new IllegalArgumentException
  }

  case class OptionInt(v: Option[Int])

  case class OptionLong(v: Option[Long])

  case class ListOptionInt(v: List[Option[Int]])

  case class ListString(vs: List[String])

  case class ListStringDflt(vs: List[String] = Nil)

  case class Inner(v: String)

  case class Outer(vs: List[List[Inner]])

  case class OuterT[T](vs: T)

  case class AliasAnno(@JsonAlias(Array("v")) value: String)

  case class PropAnno(@JsonProperty("v") value: String)

  case class DeserAnno(@JsonDeserialize(contentAs = classOf[java.lang.Long]) value: Option[Long])

  case class DeserUsingAnno(@JsonDeserialize(using = classOf[AddOneDeserializer]) value: Long)

  class AddOneDeserializer extends JsonDeserializer[java.lang.Long] {

    override def deserialize(p: JsonParser, ctxt: DeserializationContext): java.lang.Long = {
      val v = p.getLongValue
      p.nextToken()
      java.lang.Long.valueOf(v + 1)
    }
  }
}


text:
/*
 * 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.
 */
package io.trino.plugin.hive.metastore.glue;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
import io.trino.plugin.hive.metastore.MetastoreUtil;
import io.trino.spi.predicate.Domain;
import io.trino.spi.predicate.Range;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spi.predicate.ValueSet;
import io.trino.spi.type.CharType;
import io.trino.spi.type.DateType;
import io.trino.spi.type.TimestampType;
import io.trino.spi.type.Type;
import io.trino.spi.type.VarcharType;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.lang.String.format;

public final class GlueExpressionUtil
{
    static final String NULL_STRING = "__HIVE_DEFAULT_PARTITION__";
    static final int GLUE_EXPRESSION_CHAR_LIMIT = 2048;

    private static final Set<String> QUOTED_TYPES = ImmutableSet.of("string", "char", "varchar", "date", "timestamp", "binary", "varbinary");
    private static final String CONJUNCT_SEPARATOR = " AND ";
    private static final Joiner CONJUNCT_JOINER = Joiner.on(CONJUNCT_SEPARATOR);
    private static final String DISJUNCT_SEPARATOR = " OR ";
    private static final Joiner DISJUNCT_JOINER = Joiner.on(DISJUNCT_SEPARATOR);

    private GlueExpressionUtil() {}

    private static boolean isQuotedType(Type type)
    {
        return QUOTED_TYPES.contains(type.getTypeSignature().getBase());
    }

    private static String valueToString(Type type, Object value)
    {
        String s = MetastoreUtil.sqlScalarToString(type, value, NULL_STRING);

        return isQuotedType(type) ? "'" + s + "'" : s;
    }

    private static boolean canConvertSqlTypeToStringForGlue(Type type, boolean assumeCanonicalPartitionKeys)
    {
        return !(type instanceof TimestampType) && !(type instanceof DateType) && (type instanceof CharType || type instanceof VarcharType || assumeCanonicalPartitionKeys);
    }

    /**
     * @return a valid glue expression <= {@link  GlueExpressionUtil#GLUE_EXPRESSION_CHAR_LIMIT}. A return value of "" means a valid glue expression could not be created, or
     * {@link TupleDomain#all()} was passed in as an argument
     */
    public static String buildGlueExpression(List<String> columnNames, TupleDomain<String> partitionKeysFilter, boolean assumeCanonicalPartitionKeys)
    {
        return buildGlueExpression(columnNames, partitionKeysFilter, assumeCanonicalPartitionKeys, GLUE_EXPRESSION_CHAR_LIMIT);
    }

    public static String buildGlueExpression(List<String> columnNames, TupleDomain<String> partitionKeysFilter, boolean assumeCanonicalPartitionKeys, int expressionLengthLimit)
    {
        // this should have been handled by callers
        checkState(!partitionKeysFilter.isNone());
        if (partitionKeysFilter.isAll()) {
            // glue handles both null and "" as a tautology
            return "";
        }

        List<String> perColumnExpressions = new ArrayList<>();
        int expressionLength = 0;
        Map<String, Domain> domains = partitionKeysFilter.getDomains().get();
        for (String columnName : columnNames) {
            Domain domain = domains.get(columnName);
            if (domain != null) {
                Optional<String> columnExpression = buildGlueExpressionForSingleDomain(columnName, domain, assumeCanonicalPartitionKeys);
                if (columnExpression.isPresent()) {
                    int newExpressionLength = expressionLength;
                    if (expressionLength > 0) {
                        newExpressionLength += CONJUNCT_SEPARATOR.length();
                    }

                    newExpressionLength += columnExpression.get().length();

                    if (newExpressionLength > expressionLengthLimit) {
                        continue;
                    }

                    perColumnExpressions.add(columnExpression.get());
                    expressionLength = newExpressionLength;
                }
            }
        }

        return Joiner.on(CONJUNCT_SEPARATOR).join(perColumnExpressions);
    }

    /**
     * Converts domain to a valid glue expression per
     * https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-partitions.html#aws-glue-api-catalog-partitions-GetPartitions
     *
     * @return optional glue-compatible expression. if empty, either tye type of the {@link Domain} cannot be converted to a string, or the filter is {@link Domain#all}
     */
    @VisibleForTesting
    static Optional<String> buildGlueExpressionForSingleDomain(String columnName, Domain domain, boolean assumeCanonicalPartitionKeys)
    {
        ValueSet valueSet = domain.getValues();

        if (domain.isAll() || !canConvertSqlTypeToStringForGlue(domain.getType(), assumeCanonicalPartitionKeys)) {
            // if the type can't be converted or Domain.all()
            return Optional.empty();
        }

        if (domain.getValues().isAll()) {
            return Optional.of(format("(%s <> '%s')", columnName, NULL_STRING));
        }

        // null must be allowed for this case since callers must filter Domain.none() out
        if (domain.getValues().isNone()) {
            return Optional.of(format("(%s = '%s')", columnName, NULL_STRING));
        }

        List<String> disjuncts = new ArrayList<>();
        List<String> singleValues = new ArrayList<>();
        for (Range range : valueSet.getRanges().getOrderedRanges()) {
            checkState(!range.isAll()); // Already checked
            if (range.isSingleValue()) {
                singleValues.add(valueToString(range.getType(), range.getSingleValue()));
            }
            else {
                List<String> rangeConjuncts = new ArrayList<>();
                if (!range.isLowUnbounded()) {
                    rangeConjuncts.add(format(
                            "%s %s %s",
                            columnName,
                            range.isLowInclusive() ? ">=" : ">",
                            valueToString(range.getType(), range.getLowBoundedValue())));
                }
                if (!range.isHighUnbounded()) {
                    rangeConjuncts.add(format(
                            "%s %s %s",
                            columnName,
                            range.isHighInclusive() ? "<=" : "<",
                            valueToString(range.getType(), range.getHighBoundedValue())));
                }
                // If rangeConjuncts is null, then the range was ALL, which should already have been checked for by callers
                checkState(!rangeConjuncts.isEmpty());
                disjuncts.add("(" + CONJUNCT_JOINER.join(rangeConjuncts) + ")");
            }
        }

        if (singleValues.size() == 1) {
            String equalsTest = format("(%s = %s)", columnName, getOnlyElement(singleValues));
            disjuncts.add(equalsTest);
        }
        else if (singleValues.size() > 1) {
            String values = Joiner.on(", ").join(singleValues);
            String inClause = format("(%s in (%s))", columnName, values);

            disjuncts.add(inClause);
        }

        return Optional.of("(" + DISJUNCT_JOINER.join(disjuncts) + ")");
    }
}


text:
// Generated from /home/aleksander/_Repositories/simple-compiler/Grammar/src/Simple.g4 by ANTLR 4.5.1
package Front;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class SimpleParser extends Parser {
	static { RuntimeMetaData.checkVersion("4.5.1", RuntimeMetaData.VERSION); }

	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		T__0=1, T__1=2, T__2=3, PRINT=4, READ=5, TOINT=6, TOREAL=7, ID=8, REAL=9,
		INT=10, ADD=11, MULT=12, SUB=13, DIV=14, NEWLINE=15, WS=16, COMMENT=17;
	public static final int
		RULE_prog = 0, RULE_stat = 1, RULE_expr0 = 2, RULE_expr1 = 3, RULE_expr2 = 4;
	public static final String[] ruleNames = {
		"prog", "stat", "expr0", "expr1", "expr2"
	};

	private static final String[] _LITERAL_NAMES = {
		null, "'='", "'('", "')'", "'print'", "'read'", "'(int)'", "'(real)'",
		null, null, null, "'+'", "'*'", "'-'", "'/'"
	};
	private static final String[] _SYMBOLIC_NAMES = {
		null, null, null, null, "PRINT", "READ", "TOINT", "TOREAL", "ID", "REAL",
		"INT", "ADD", "MULT", "SUB", "DIV", "NEWLINE", "WS", "COMMENT"
	};
	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);

	/**
	 * @deprecated Use {@link #VOCABULARY} instead.
	 */
	@Deprecated
	public static final String[] tokenNames;
	static {
		tokenNames = new String[_SYMBOLIC_NAMES.length];
		for (int i = 0; i < tokenNames.length; i++) {
			tokenNames[i] = VOCABULARY.getLiteralName(i);
			if (tokenNames[i] == null) {
				tokenNames[i] = VOCABULARY.getSymbolicName(i);
			}

			if (tokenNames[i] == null) {
				tokenNames[i] = "<INVALID>";
			}
		}
	}

	@Override
	@Deprecated
	public String[] getTokenNames() {
		return tokenNames;
	}

	@Override

	public Vocabulary getVocabulary() {
		return VOCABULARY;
	}

	@Override
	public String getGrammarFileName() { return "Simple.g4"; }

	@Override
	public String[] getRuleNames() { return ruleNames; }

	@Override
	public String getSerializedATN() { return _serializedATN; }

	@Override
	public ATN getATN() { return _ATN; }

	public SimpleParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}
	public static class ProgContext extends ParserRuleContext {
		public List<TerminalNode> NEWLINE() { return getTokens(SimpleParser.NEWLINE); }
		public TerminalNode NEWLINE(int i) {
			return getToken(SimpleParser.NEWLINE, i);
		}
		public List<StatContext> stat() {
			return getRuleContexts(StatContext.class);
		}
		public StatContext stat(int i) {
			return getRuleContext(StatContext.class,i);
		}
		public ProgContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_prog; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterProg(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitProg(this);
		}
	}

	public final ProgContext prog() throws RecognitionException {
		ProgContext _localctx = new ProgContext(_ctx, getState());
		enterRule(_localctx, 0, RULE_prog);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(16);
			_errHandler.sync(this);
			_la = _input.LA(1);
			while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PRINT) | (1L << READ) | (1L << ID) | (1L << NEWLINE))) != 0)) {
				{
				{
				setState(11);
				_la = _input.LA(1);
				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PRINT) | (1L << READ) | (1L << ID))) != 0)) {
					{
					setState(10);
					stat();
					}
				}

				setState(13);
				match(NEWLINE);
				}
				}
				setState(18);
				_errHandler.sync(this);
				_la = _input.LA(1);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class StatContext extends ParserRuleContext {
		public StatContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_stat; }

		public StatContext() { }
		public void copyFrom(StatContext ctx) {
			super.copyFrom(ctx);
		}
	}
	public static class PrintContext extends StatContext {
		public TerminalNode PRINT() { return getToken(SimpleParser.PRINT, 0); }
		public TerminalNode ID() { return getToken(SimpleParser.ID, 0); }
		public PrintContext(StatContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterPrint(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitPrint(this);
		}
	}
	public static class ReadContext extends StatContext {
		public TerminalNode READ() { return getToken(SimpleParser.READ, 0); }
		public TerminalNode ID() { return getToken(SimpleParser.ID, 0); }
		public ReadContext(StatContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterRead(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitRead(this);
		}
	}
	public static class AssignContext extends StatContext {
		public TerminalNode ID() { return getToken(SimpleParser.ID, 0); }
		public Expr0Context expr0() {
			return getRuleContext(Expr0Context.class,0);
		}
		public AssignContext(StatContext ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterAssign(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitAssign(this);
		}
	}

	public final StatContext stat() throws RecognitionException {
		StatContext _localctx = new StatContext(_ctx, getState());
		enterRule(_localctx, 2, RULE_stat);
		try {
			setState(26);
			switch (_input.LA(1)) {
			case ID:
				_localctx = new AssignContext(_localctx);
				enterOuterAlt(_localctx, 1);
				{
				setState(19);
				match(ID);
				setState(20);
				match(T__0);
				setState(21);
				expr0();
				}
				break;
			case PRINT:
				_localctx = new PrintContext(_localctx);
				enterOuterAlt(_localctx, 2);
				{
				setState(22);
				match(PRINT);
				setState(23);
				match(ID);
				}
				break;
			case READ:
				_localctx = new ReadContext(_localctx);
				enterOuterAlt(_localctx, 3);
				{
				setState(24);
				match(READ);
				setState(25);
				match(ID);
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class Expr0Context extends ParserRuleContext {
		public Expr0Context(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expr0; }

		public Expr0Context() { }
		public void copyFrom(Expr0Context ctx) {
			super.copyFrom(ctx);
		}
	}
	public static class Single0Context extends Expr0Context {
		public Expr1Context expr1() {
			return getRuleContext(Expr1Context.class,0);
		}
		public Single0Context(Expr0Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterSingle0(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitSingle0(this);
		}
	}
	public static class AddContext extends Expr0Context {
		public List<Expr1Context> expr1() {
			return getRuleContexts(Expr1Context.class);
		}
		public Expr1Context expr1(int i) {
			return getRuleContext(Expr1Context.class,i);
		}
		public TerminalNode ADD() { return getToken(SimpleParser.ADD, 0); }
		public AddContext(Expr0Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterAdd(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitAdd(this);
		}
	}
	public static class SubContext extends Expr0Context {
		public List<Expr1Context> expr1() {
			return getRuleContexts(Expr1Context.class);
		}
		public Expr1Context expr1(int i) {
			return getRuleContext(Expr1Context.class,i);
		}
		public TerminalNode SUB() { return getToken(SimpleParser.SUB, 0); }
		public SubContext(Expr0Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterSub(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitSub(this);
		}
	}

	public final Expr0Context expr0() throws RecognitionException {
		Expr0Context _localctx = new Expr0Context(_ctx, getState());
		enterRule(_localctx, 4, RULE_expr0);
		try {
			setState(37);
			switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
			case 1:
				_localctx = new Single0Context(_localctx);
				enterOuterAlt(_localctx, 1);
				{
				setState(28);
				expr1();
				}
				break;
			case 2:
				_localctx = new AddContext(_localctx);
				enterOuterAlt(_localctx, 2);
				{
				setState(29);
				expr1();
				setState(30);
				match(ADD);
				setState(31);
				expr1();
				}
				break;
			case 3:
				_localctx = new SubContext(_localctx);
				enterOuterAlt(_localctx, 3);
				{
				setState(33);
				expr1();
				setState(34);
				match(SUB);
				setState(35);
				expr1();
				}
				break;
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class Expr1Context extends ParserRuleContext {
		public Expr1Context(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expr1; }

		public Expr1Context() { }
		public void copyFrom(Expr1Context ctx) {
			super.copyFrom(ctx);
		}
	}
	public static class DivContext extends Expr1Context {
		public List<Expr2Context> expr2() {
			return getRuleContexts(Expr2Context.class);
		}
		public Expr2Context expr2(int i) {
			return getRuleContext(Expr2Context.class,i);
		}
		public TerminalNode DIV() { return getToken(SimpleParser.DIV, 0); }
		public DivContext(Expr1Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterDiv(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitDiv(this);
		}
	}
	public static class Single1Context extends Expr1Context {
		public Expr2Context expr2() {
			return getRuleContext(Expr2Context.class,0);
		}
		public Single1Context(Expr1Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterSingle1(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitSingle1(this);
		}
	}
	public static class MultContext extends Expr1Context {
		public List<Expr2Context> expr2() {
			return getRuleContexts(Expr2Context.class);
		}
		public Expr2Context expr2(int i) {
			return getRuleContext(Expr2Context.class,i);
		}
		public TerminalNode MULT() { return getToken(SimpleParser.MULT, 0); }
		public MultContext(Expr1Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterMult(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitMult(this);
		}
	}

	public final Expr1Context expr1() throws RecognitionException {
		Expr1Context _localctx = new Expr1Context(_ctx, getState());
		enterRule(_localctx, 6, RULE_expr1);
		try {
			setState(48);
			switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
			case 1:
				_localctx = new Single1Context(_localctx);
				enterOuterAlt(_localctx, 1);
				{
				setState(39);
				expr2();
				}
				break;
			case 2:
				_localctx = new MultContext(_localctx);
				enterOuterAlt(_localctx, 2);
				{
				setState(40);
				expr2();
				setState(41);
				match(MULT);
				setState(42);
				expr2();
				}
				break;
			case 3:
				_localctx = new DivContext(_localctx);
				enterOuterAlt(_localctx, 3);
				{
				setState(44);
				expr2();
				setState(45);
				match(DIV);
				setState(46);
				expr2();
				}
				break;
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class Expr2Context extends ParserRuleContext {
		public Expr2Context(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expr2; }

		public Expr2Context() { }
		public void copyFrom(Expr2Context ctx) {
			super.copyFrom(ctx);
		}
	}
	public static class ParContext extends Expr2Context {
		public Expr0Context expr0() {
			return getRuleContext(Expr0Context.class,0);
		}
		public ParContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterPar(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitPar(this);
		}
	}
	public static class ExidContext extends Expr2Context {
		public TerminalNode ID() { return getToken(SimpleParser.ID, 0); }
		public ExidContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterExid(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitExid(this);
		}
	}
	public static class TointContext extends Expr2Context {
		public TerminalNode TOINT() { return getToken(SimpleParser.TOINT, 0); }
		public Expr2Context expr2() {
			return getRuleContext(Expr2Context.class,0);
		}
		public TointContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterToint(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitToint(this);
		}
	}
	public static class TorealContext extends Expr2Context {
		public TerminalNode TOREAL() { return getToken(SimpleParser.TOREAL, 0); }
		public Expr2Context expr2() {
			return getRuleContext(Expr2Context.class,0);
		}
		public TorealContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterToreal(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitToreal(this);
		}
	}
	public static class RealContext extends Expr2Context {
		public TerminalNode REAL() { return getToken(SimpleParser.REAL, 0); }
		public RealContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterReal(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitReal(this);
		}
	}
	public static class IntContext extends Expr2Context {
		public TerminalNode INT() { return getToken(SimpleParser.INT, 0); }
		public IntContext(Expr2Context ctx) { copyFrom(ctx); }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).enterInt(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof SimpleListener ) ((SimpleListener)listener).exitInt(this);
		}
	}

	public final Expr2Context expr2() throws RecognitionException {
		Expr2Context _localctx = new Expr2Context(_ctx, getState());
		enterRule(_localctx, 8, RULE_expr2);
		try {
			setState(61);
			switch (_input.LA(1)) {
			case ID:
				_localctx = new ExidContext(_localctx);
				enterOuterAlt(_localctx, 1);
				{
				setState(50);
				match(ID);
				}
				break;
			case INT:
				_localctx = new IntContext(_localctx);
				enterOuterAlt(_localctx, 2);
				{
				setState(51);
				match(INT);
				}
				break;
			case REAL:
				_localctx = new RealContext(_localctx);
				enterOuterAlt(_localctx, 3);
				{
				setState(52);
				match(REAL);
				}
				break;
			case TOINT:
				_localctx = new TointContext(_localctx);
				enterOuterAlt(_localctx, 4);
				{
				setState(53);
				match(TOINT);
				setState(54);
				expr2();
				}
				break;
			case TOREAL:
				_localctx = new TorealContext(_localctx);
				enterOuterAlt(_localctx, 5);
				{
				setState(55);
				match(TOREAL);
				setState(56);
				expr2();
				}
				break;
			case T__1:
				_localctx = new ParContext(_localctx);
				enterOuterAlt(_localctx, 6);
				{
				setState(57);
				match(T__1);
				setState(58);
				expr0();
				setState(59);
				match(T__2);
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static final String _serializedATN =
		"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\23B\4\2\t\2\4\3\t"+
		"\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\5\2\16\n\2\3\2\7\2\21\n\2\f\2\16\2\24\13"+
		"\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3\35\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4"+
		"\3\4\3\4\5\4(\n\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\5\5\63\n\5\3\6\3"+
		"\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6@\n\6\3\6\2\2\7\2\4\6\b\n\2"+
		"\2I\2\22\3\2\2\2\4\34\3\2\2\2\6\'\3\2\2\2\b\62\3\2\2\2\n?\3\2\2\2\f\16"+
		"\5\4\3\2\r\f\3\2\2\2\r\16\3\2\2\2\16\17\3\2\2\2\17\21\7\21\2\2\20\r\3"+
		"\2\2\2\21\24\3\2\2\2\22\20\3\2\2\2\22\23\3\2\2\2\23\3\3\2\2\2\24\22\3"+
		"\2\2\2\25\26\7\n\2\2\26\27\7\3\2\2\27\35\5\6\4\2\30\31\7\6\2\2\31\35\7"+
		"\n\2\2\32\33\7\7\2\2\33\35\7\n\2\2\34\25\3\2\2\2\34\30\3\2\2\2\34\32\3"+
		"\2\2\2\35\5\3\2\2\2\36(\5\b\5\2\37 \5\b\5\2 !\7\r\2\2!\"\5\b\5\2\"(\3"+
		"\2\2\2#$\5\b\5\2$%\7\17\2\2%&\5\b\5\2&(\3\2\2\2\'\36\3\2\2\2\'\37\3\2"+
		"\2\2\'#\3\2\2\2(\7\3\2\2\2)\63\5\n\6\2*+\5\n\6\2+,\7\16\2\2,-\5\n\6\2"+
		"-\63\3\2\2\2./\5\n\6\2/\60\7\20\2\2\60\61\5\n\6\2\61\63\3\2\2\2\62)\3"+
		"\2\2\2\62*\3\2\2\2\62.\3\2\2\2\63\t\3\2\2\2\64@\7\n\2\2\65@\7\f\2\2\66"+
		"@\7\13\2\2\678\7\b\2\28@\5\n\6\29:\7\t\2\2:@\5\n\6\2;<\7\4\2\2<=\5\6\4"+
		"\2=>\7\5\2\2>@\3\2\2\2?\64\3\2\2\2?\65\3\2\2\2?\66\3\2\2\2?\67\3\2\2\2"+
		"?9\3\2\2\2?;\3\2\2\2@\13\3\2\2\2\b\r\22\34\'\62?";
	public static final ATN _ATN =
		new ATNDeserializer().deserialize(_serializedATN.toCharArray());
	static {
		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
		}
	}
}


text: Rails.application.config.session_store :cookie_store, key: '_construction-projects_session'


text:
.. _vim.host.Capability: ../../../vim/host/Capability.rst

.. _vmDirectPathGen2UnsupportedReason: ../../../vim/host/Capability.rst#vmDirectPathGen2UnsupportedReason

.. _vim.host.Capability.VmDirectPathGen2UnsupportedReason: ../../../vim/host/Capability/VmDirectPathGen2UnsupportedReason.rst

vim.host.Capability.VmDirectPathGen2UnsupportedReason
=====================================================
  Set of possible values for `vmDirectPathGen2UnsupportedReason`_ .
  :contained by: `vim.host.Capability`_

  :type: `vim.host.Capability.VmDirectPathGen2UnsupportedReason`_

  :name: hostNptDisabled

values:
--------

hostNptIncompatibleProduct
   The host software does not support VMDirectPath Gen 2.

hostNptIncompatibleHardware
   The host hardware does not support VMDirectPath Gen 2. Note that this is a general capability for the host and is independent of support by a given physical NIC.

hostNptDisabled
   The host is configured to disable VMDirectPath Gen 2.


text:
package com.oldbai.android.app.hebiace;

/**
 * Created by BaiGuoyong on 9/5/2017.
 */

public interface BaseView<T> {

    void setPresenter(T presenter);

}


text:
/**
* Created with catClicker.
* User: Phlammariont
* Date: 2015-10-18
* Time: 10:33 PM
* To change this template use Tools | Templates.
*/

App = {
    init: function (cats) {
        this.createCats(cats);
        this.cacheElments();
        this.bindEvents();
        this.instanceCounter();
    },
    createCats: function(cats) {
        var catArea = document.createElement('div');
        catArea.className="cat-clicker-area";

        var catPickerArea = document.createElement('div');
        catPickerArea.className="cat-picker-area";

        for (var i=0; i < cats.length; i++) {
            console.log("crating cat " + i);
            var actualCat = cats[i];
            var catClicker = document.createElement('div');
            catClicker.className="container-fluid cat-container";
            $(catClicker).append(
                '' +
                '
' +
                    '

' +
                '
' +
                '
' +
                    '
' + actualCat.name + '
' +
                '
'
            );
            $(catClicker).on("click", (function(counter) {
                return function () {
                    $(this).find(".counter-container").html(counter++);
                }
            })(actualCat.counter));
            catArea.appendChild(catClicker);

            var catPicker = document.createElement('div');
            catPicker.className="container-fluid cat-picker-container";
            $(catPicker).append(
                '' +
                '
' +
                    '
' + actualCat.name + '
' +
                '
'
            );
            $(catPicker).on("click", (function (cat) {
                return function () {
                    $(".cat-container").hide();
                    $(cat).show();
                }
            })(catClicker));
            catPickerArea.appendChild(catPicker);
        }

        document.body.appendChild(catPickerArea);
        document.body.appendChild(catArea);
    },
    cacheElments: function () {
        this.$catContainer = $(".cat-container");
        this.$countContainer = $(".count-container");
    },
    bindEvents: function () {
        //this.$catContainer.off("click").on("click", App.incrementCounCat);
    },
    incrementCounCat: function () {
        $(this).data("counter", $(this).data("counter") + 1);
        console.log("click" +  $(this).data("counter") )
        $(this).find(".count-container").html($(this).data("counter"));
    },
    instanceCounter: function () {
        this.$countContainer.parent().css('height', this.$countContainer.parent().width());
        this.$catContainer.hide();
    }
};
cats = [
    {
        name: "Farre-Cat",
        "image-url": "http://cdn.playbuzz.com/cdn/0079c830-3406-4c05-a5c1-bc43e8f01479/7dd84d70-768b-492b-88f7-a6c70f2db2e9.jpg",
        counter: 1
    },
    {
        name: "Kit-Cat",
        "image-url": "http://stylonica.com/wp-content/uploads/2014/03/2-cats.jpg",
        counter: 1
    },
    {
        name: "End-cat",
        "image-url": "http://www.gordonrigg.com/the-hub/wp-content/uploads/2015/06/little_cute_cat_1920x1080.jpg",
        counter: 1
    }
];
App.init(cats);


text:
import { Entity } from 'Cake/ORM/Entity';

export class Article extends Entity {

}


text:
SceneGraph::~SceneGraph()
{
	if (currentScene != nullptr)
	{
		currentScene->~BaseScene();
		currentScene = nullptr;
	}
}

void SceneGraph::Initialize()
{
}

void SceneGraph::Update(float dt)
{
	if (currentScene != nullptr) currentScene->Update(dt);
}

void SceneGraph::Draw(float dt)
{
	if (currentScene != nullptr) currentScene->Draw(dt);
}

void SceneGraph::OnKeyDown(SDL_Keycode key)
{
	if (currentScene != nullptr) currentScene->OnKeyDown(key);
}

void SceneGraph::OnKeyUp(SDL_Keycode key)
{
	if (currentScene != nullptr) currentScene->OnKeyUp(key);
}

void SceneGraph::GoToScene(int sceneId)
{
	if (currentScene != nullptr)
	{
		currentScene->~BaseScene();
		currentScene = nullptr;
	}
}


text:
from pyramid import testing

from git import Repo

from unicore.distribute.events import (
    RepositoryEvent, RepositoryCloned, RepositoryUpdated,
    ContentTypeObjectUpdated)
from unicore.distribute.tests.base import DistributeTestCase

class TestEvents(DistributeTestCase):

    def setUp(self):
        self.workspace = self.mk_workspace()
        self.config = testing.setUp()
        self.config.include('unicore.distribute.api')

    def tearDown(self):
        testing.tearDown()

    def get_handlers_for(self, config, event_cls):
        return map(
            lambda h: h.handler.__name__,
            filter(
                lambda h: h.required[0].implementedBy(event_cls),
                config.registry.registeredHandlers())
            )

    def test_repository_event(self):
        event_obj = RepositoryEvent(
            config='foo config',
            repo_dir=self.workspace.working_dir,
            repo_url='foo url')
        self.assertIsInstance(event_obj.repo, Repo)
        self.assertEqual(event_obj.repo, self.workspace.repo)
        self.assertEqual(event_obj.config, 'foo config')
        self.assertEqual(event_obj.repo_url, 'foo url')

    def test_configuration(self):
        self.assertNotIn('initialize_repo_index',
                         self.get_handlers_for(self.config, RepositoryCloned))
        self.assertNotIn('update_repo_index',
                         self.get_handlers_for(self.config, RepositoryUpdated))
        self.assertNotIn(
            'index_content_type_object',
            self.get_handlers_for(self.config, ContentTypeObjectUpdated))

        config = testing.setUp(settings={
            'es.indexing_enabled': 'true'
        })
        config.include('unicore.distribute.api')
        self.assertIn('initialize_repo_index',
                      self.get_handlers_for(config, RepositoryCloned))
        self.assertIn('update_repo_index',
                      self.get_handlers_for(config, RepositoryUpdated))
        self.assertIn('index_content_type_object',
                      self.get_handlers_for(config, ContentTypeObjectUpdated))


text:
import logging

from django.core.management.base import BaseCommand
from django.utils.translation import gettext_lazy as _

from oscar.core.loading import get_class

logger = logging.getLogger(__name__)

AlertsDispatcher = get_class('customer.alerts.utils', 'AlertsDispatcher')

class Command(BaseCommand):
    """
    Check stock records of products for availability and send out alerts
    to customers that have registered for an alert.
    """
    help = _("Check for products that are back in "
             "stock and send out alerts")

    def handle(self, **options):
        """
        Check all products with active product alerts for
        availability and send out email alerts when a product is
        available to buy.
        """
        AlertsDispatcher().send_alerts()


text:
This resource is used to create or remove SPTrustedIdentityTokenIssuer in a
SharePoint farm.

Either parameter SigningCertificateThumbPrint or SigningCertificateFilePath
must be set, but not both.

The SigningCertificateThumbPrint must be the thumbprint of the signing
certificate stored in the certificate store LocalMachine\My of the server

Note that the private key of the certificate must not be available in the
certiificate store because SharePoint does not accept it.

The SigningCertificateFilePath must be the file path to the public key of
the signing certificate.

The ClaimsMappings property is an array of MSFT_SPClaimTypeMapping to use
with cmdlet New-SPClaimTypeMapping. Each MSFT_SPClaimTypeMapping requires
properties Name and IncomingClaimType. Property LocalClaimType is not
required if its value is identical to IncomingClaimType.

The IdentifierClaim property must match an IncomingClaimType element in
ClaimsMappings array.

The ClaimProviderName property can be set to specify a custom claims provider.
It must be already installed in the SharePoint farm and returned by cmdlet

The default value for the Ensure parameter is Present. When not specifying this
parameter, the token issuer is created.


text:
<?xml version="1.0" encoding="utf-8"?><!--
  ~ The MIT License (MIT)
  ~
  ~ Copyright (c) 2015 Sven Dubbeld
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy of
  ~ this software and associated documentation files (the "Software"), to deal in
  ~ the Software without restriction, including without limitation the rights to
  ~ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  ~ the Software, and to permit persons to whom the Software is furnished to do so,
  ~ subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  ~ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  ~ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  ~ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  ~ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  -->

<resources>

    <style name="TextAppearance.Dialpad" parent="@android:style/TextAppearance.Material">
        <item name="android:layout_columnWeight">1</item>
        <item name="android:layout_gravity">fill</item>
        <item name="android:background">?android:selectableItemBackgroundBorderless</item>
        <item name="android:gravity">center</item>
        <item name="android:textSize">42sp</item>
    </style>
</resources>


text:
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;

public class KeyHelper : MonoBehaviour {
    void OnSelect()
    {
        transform.parent.SendMessage("OnSelect", new BaseEventData(EventSystem.current));
    }

    void OnGazeEnter()
    {
        transform.parent.SendMessage("OnGazeEnter", new BaseEventData(EventSystem.current));
    }

    void OnGazeLeave()
    {
        transform.parent.SendMessage("OnGazeLeave", new BaseEventData(EventSystem.current));
    }
}


text:
package com.winterwell.maths.timeseries;

import java.util.LinkedList;
import java.util.NoSuchElementException;

import com.winterwell.maths.stats.distributions.MeanVar;
import com.winterwell.utils.containers.AbstractIterator;
import com.winterwell.utils.time.Dt;
import com.winterwell.utils.time.TUnit;
import com.winterwell.utils.time.Time;

/**
 * MovingMeanDataStream -- experimental moving mean class
 *
 * Uses a circular buffer, with time rather than number of elements as the
 * radius. Does not apply a window function (i.e. boxcar mean) and all values are
 * treated equally regardless of spacing in time (i.e. no weighting of any
 * sort).
 *
 * @author alisdair@winterwell.com
 *
 */

public class MovingMeanDataStream extends ADataStream {

	class MovingMeanDataStreamIterator extends AbstractIterator<Datum> {
		private AbstractIterator<Datum> base_iterator;
		// this is the buffer that is used to generate the moving mean
		// it is always centred in time on the current entry in the base
		// DataStream
		private LinkedList<Datum> buffer;
		private int current_datum_index; // index of current datum in buffer
		private Dt radius;

		public MovingMeanDataStreamIterator() {
			this.base_iterator = base_stream.iterator();
			this.radius = window.multiply(0.5);
			this.current_datum_index = 0;
			this.buffer = new LinkedList<Datum>();
			if (base_iterator.hasNext()) { this.buffer.add(base_iterator.next()); }
		}

		@Override
		protected Datum next2() throws Exception {
			// It's possible that the next Datum is not in the window.
			// In this case, grab from the base_iterator. It should *always*
			// be the next item, so only check for this specific case
			// (anything else will correctly raise IndexOutOfBoundsException)
			if (this.current_datum_index == this.buffer.size()) {
				// If base iterator is exhausted, and we're past the end of the
				// buffer, we're done
				try {
					buffer.addLast(this.base_iterator.next());
				} catch (NoSuchElementException e) {
					return null;
				}
			}

			Datum current_datum = this.buffer.get(this.current_datum_index);

			Time window_start = null;
			Time window_end = null;
			if (trailing) {
				window_start = current_datum.time.minus(this.radius.multiply(2.0));
				window_end = current_datum.time.plus(new Dt(1,TUnit.MILLISECOND)); // make sure current is included ....
			} else {
				window_start = current_datum.time.minus(this.radius);
				window_end = current_datum.time.plus(this.radius);
			}

			// Now knock anything before window_start off the beginning of the
			// buffer
			while (buffer.getFirst().time.isBefore(window_start)) {
				buffer.removeFirst();
				current_datum_index--;
			}

			// Add data, until the next Datum would be after window_end
			while (this.base_iterator.peekNext() != null
					&& this.base_iterator.peekNext().time.isBefore(window_end)) {
				try {
					buffer.addLast(this.base_iterator.next());
				} catch (NoSuchElementException e) {
					; // intentional! this method should only return null when
						// we are at the end of the base iterator *and* the
						// buffer (see above)
				}
			}
			// Now return the mean -- using MeanVar as backend, but may want to
			// change this for speed
			MeanVar mean = new MeanVar(buffer.get(0).getDim());
			for (Datum datum : buffer) {
				mean.train1(DataUtils.newVector(datum.getData()));
			}
			this.current_datum_index++;
			return new Datum(current_datum.time, mean.getMean(), null);
		}
	}

	private static final long serialVersionUID = 1L;
	private IDataStream base_stream;
	private Dt window;
	private Boolean trailing;

	/**
	 * Create a moving mean centred on the current datum, with the given time radius
	 * @param _base_stream input stream
	 * @param _window time radius
	 */
	public MovingMeanDataStream(IDataStream _base_stream, Dt _window) {
		super(_base_stream.getDim());
		this.base_stream = _base_stream;
		this.window = _window;
		this.trailing = false;
	}

	/**
	 * Create a moving mean centred on or trailing from the current datum, with the
	 * given time radius
	 * @param _base_stream input stream
	 * @param _window time radius
	 * @param _trailing true if the window trails from the current datum (i.e. current
	 * is the latest element in the window), false if it is centred on the current datum.
	 */
	public MovingMeanDataStream(IDataStream _base_stream, Dt _window, Boolean _trailing) {
		super(_base_stream.getDim());
		this.base_stream = _base_stream;
		this.window = _window;
		this.trailing = _trailing;
	}

	@Override
	public AbstractIterator<Datum> iterator() {
		return new MovingMeanDataStreamIterator();
	}

}


text:
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
  var app = new EmberAddon(defaults, {
    // Add options here
  });

  /*
    This build file specifies the options for the dummy test app of this
    addon, located in `/tests/dummy`
    This build file does *not* influence how the addon or the app using it
    behave. You most likely want to be modifying `./index.js` or app's build file
  */

  app.import('bower_components/kendo-ui/styles/kendo.common-material.core.min.css');
  app.import('bower_components/kendo-ui/styles/kendo.common-material.min.css');
  app.import('bower_components/kendo-ui/styles/kendo.material.min.css');

  app.import('bower_components/kendo-ui/src/js/cultures/kendo.culture.ru-RU.js');

  return app.toTree();
};